@devries-cameron20 / composio-1 / commits / 7477aa956
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

feat(cli): scaffold native UI sidecar (#3418)

## Summary - Scaffold a macOS Swift `composio-native-ui` sidecar with a borderless floating native overlay and Metal-driven pulsing/liquid-glass visual treatment. - Add a hidden/dev `composio dev native-ui` command that spawns the bundled sidecar from CLI local-tool assets. - Wire the sidecar into local-tool binary build scripts and CLI binary release packaging checks for Darwin artifacts. ## Tests - `pnpm install --frozen-lockfile` - `pnpm typecheck` - `pnpm --filter @composio/cli build` - `pnpm --filter @composio/cli-local-tools build:composio-native-ui -- --target darwin-arm64` - Manual launch via `COMPOSIO_LOCAL_TOOLS_BIN_DIR=../cli-local-tools/local-tools-binaries bun dist/bin.mjs dev native-ui --timeout 35` ## Notes / Risks - This is a scaffold/prototype and is intentionally opened as a draft PR. - The visual effect uses a transparent AppKit panel, `NSVisualEffectView`, and a Metal overlay. True optical distortion of arbitrary content behind the window would require a different approach such as ScreenCaptureKit/backdrop sampling and associated permissions. - Generated sidecar executables remain ignored; release jobs rebuild them before packaging artifacts. --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Rahul Tarak committed May 13, 2026 at 01:30 UTC 7477aa956659b8b9403b90858a4e578b0027776b
12 files changed +1078 -1
.github/workflows/build-cli-binaries.yml
+3
@@ -5,6 +5,7 @@ on:
5 branches: [next]
6 paths:
7 - 'ts/packages/cli/**'
8 + - 'ts/packages/cli-local-tools/**'
9 workflow_dispatch:
10 inputs:
11 action:
@@ -253,6 +254,7 @@ jobs:
254 run: |
255 test -x ts/packages/cli-local-tools/local-tools-binaries/beeper-imessage/${{ matrix.local_tools_target }}/imessage-cli
256 test -x ts/packages/cli-local-tools/local-tools-binaries/peekaboo/${{ matrix.local_tools_target }}/peekaboo
257 + test -x ts/packages/cli-local-tools/local-tools-binaries/composio-native-ui/${{ matrix.local_tools_target }}/composio-native-ui
258
259 - name: Cross-compile CLI binary
260 working-directory: ts/packages/cli
@@ -289,6 +291,7 @@ jobs:
291 run: |
292 unzip -Z1 dist/binaries/${{ matrix.artifact }}.zip | grep -F "local-tools-binaries/beeper-imessage/${{ matrix.local_tools_target }}/imessage-cli"
293 unzip -Z1 dist/binaries/${{ matrix.artifact }}.zip | grep -F "local-tools-binaries/peekaboo/${{ matrix.local_tools_target }}/peekaboo"
294 + unzip -Z1 dist/binaries/${{ matrix.artifact }}.zip | grep -F "local-tools-binaries/composio-native-ui/${{ matrix.local_tools_target }}/composio-native-ui"
295
296 - name: Upload artifact
297 uses: actions/upload-artifact@v6
ts/packages/cli-local-tools/local-tools-binaries/.gitignore
+1
@@ -2,3 +2,4 @@
2 # Keep notices/licenses in git, but never commit generated executables.
3 /beeper-imessage/darwin-*/imessage-cli
4 /peekaboo/darwin-*/peekaboo
5 +/composio-native-ui/darwin-*/composio-native-ui
ts/packages/cli-local-tools/local-tools-binaries/README.md
+2 -1
@@ -1,6 +1,6 @@
1 # Local tool binary assets
2
3 -Platform-specific executable and dynamic-library assets for first-party local tool integrations are generated into this directory during local-tool binary builds.
3 +Platform-specific executable and dynamic-library assets for first-party local tool integrations and CLI native sidecars are generated into this directory during local-tool binary builds.
4
5 Do not commit generated executables. Keep notices/licenses in git, pin source with git submodules under `ts/packages/cli-local-tools/vendor/`, and regenerate binaries in CLI release jobs before packaging artifacts.
6
@@ -8,6 +8,7 @@ Current native binary sources:
8
9 - Beeper iMessage: `vendor/platform-imessage` (`https://github.com/ComposioHQ/platform-imessage`)
10 - Peekaboo: `vendor/peekaboo` (`https://github.com/steipete/Peekaboo`)
11 +- Composio native UI sidecar: `native/composio-native-ui` (in-repository Swift package)
12
13 Build macOS sidecars for the current host/target with:
14
ts/packages/cli-local-tools/local-tools-binaries/composio-native-ui/NOTICE.md new
+11
@@ -0,0 +1,11 @@
1 +# Composio native UI sidecar
2 +
3 +The `composio-native-ui` binaries are built from the in-repository Swift package at `ts/packages/cli-local-tools/native/composio-native-ui`.
4 +
5 +- Purpose: native macOS UI surface that the Bun-compiled Composio CLI can spawn for auth flows, tool pickers, and other desktop affordances.
6 +- Build command: `pnpm --filter @composio/cli-local-tools build:composio-native-ui -- --target <darwin-arm64|darwin-x64>`
7 +- Underlying Swift build commands:
8 + - `swift build -c release --product composio-native-ui --arch arm64`
9 + - `swift build -c release --product composio-native-ui --arch x86_64`
10 +
11 +The scaffold currently opens a small AppKit panel near the bottom-right corner of the active screen. Generated executables are intentionally not committed; release jobs rebuild them before packaging CLI artifacts.
ts/packages/cli-local-tools/native/composio-native-ui/.gitignore new
+2
@@ -0,0 +1,2 @@
1 +.build/
2 +.swiftpm/
ts/packages/cli-local-tools/native/composio-native-ui/Package.swift new
+18
@@ -0,0 +1,18 @@
1 +// swift-tools-version: 6.0
2 +import PackageDescription
3 +
4 +let package = Package(
5 + name: "ComposioNativeUI",
6 + platforms: [
7 + .macOS(.v13)
8 + ],
9 + products: [
10 + .executable(name: "composio-native-ui", targets: ["ComposioNativeUI"])
11 + ],
12 + targets: [
13 + .executableTarget(
14 + name: "ComposioNativeUI",
15 + path: "Sources/ComposioNativeUI"
16 + )
17 + ]
18 +)
ts/packages/cli-local-tools/native/composio-native-ui/Sources/ComposioNativeUI/main.swift new
+822
@@ -0,0 +1,822 @@
1 +import AppKit
2 +import MetalKit
3 +import QuartzCore
4 +
5 +struct Configuration {
6 + // Content (programmatic):
7 + var tool: String = "GMAIL_GET_PROFILE"
8 + var account: String = "gmail_pall-seba"
9 + var callerAgent: String? = nil // claude | codex | openclaw | composio (omit → CLI mode)
10 + var callerName: String? = nil // overrides agent.displayName
11 + var title: String? = nil // overrides the auto-built title
12 + var subtitle: String? = nil // overrides the auto-built subtitle
13 + var denyLabel: String = "Deny"
14 + var allowSessionLabel: String = "Allow for session"
15 + var allowOnceLabel: String = "Allow once"
16 +
17 + // Window:
18 + var width: CGFloat = 460
19 + var height: CGFloat = 200
20 + var margin: CGFloat = 24
21 + var timeoutSeconds: TimeInterval?
22 +
23 + // Result channel: if set, the decision JSON is written to this file path.
24 + // Otherwise it is written to stdout. Either way the process exits 0 for a
25 + // button press, 1 for dismissed / timeout / window-close.
26 + var callbackFile: String?
27 +
28 + var resolvedAgent: Agent? { callerAgent.map(Agents.resolve) }
29 + var resolvedCallerName: String { callerName ?? resolvedAgent?.displayName ?? "The composio cli" }
30 +
31 + // Sentinel used when no custom --title is supplied; makeContentView
32 + // builds an attributed string with an inline agent logo at this point.
33 + var resolvedTitle: String {
34 + title ?? ""
35 + }
36 +
37 + var resolvedSubtitle: String {
38 + if let subtitle, !subtitle.isEmpty { return subtitle }
39 + return "Approve once, for the rest of this session, or deny."
40 + }
41 +
42 + init(arguments: [String]) {
43 + var index = 0
44 + while index < arguments.count {
45 + let argument = arguments[index]
46 + let value = index + 1 < arguments.count ? arguments[index + 1] : nil
47 +
48 + switch argument {
49 + case "--tool":
50 + if let value { tool = value; index += 1 }
51 + case "--account":
52 + if let value { account = value; index += 1 }
53 + case "--caller-agent", "--agent":
54 + if let value { callerAgent = value; index += 1 }
55 + case "--caller-name":
56 + if let value { callerName = value; index += 1 }
57 + case "--title", "--message":
58 + if let value { title = value; index += 1 }
59 + case "--subtitle", "--detail":
60 + if let value { subtitle = value; index += 1 }
61 + case "--deny-label":
62 + if let value { denyLabel = value; index += 1 }
63 + case "--allow-session-label":
64 + if let value { allowSessionLabel = value; index += 1 }
65 + case "--allow-once-label":
66 + if let value { allowOnceLabel = value; index += 1 }
67 + case "--callback-file":
68 + if let value { callbackFile = value; index += 1 }
69 + case "--width":
70 + if let value, let parsed = Double(value) { width = CGFloat(parsed); index += 1 }
71 + case "--height":
72 + if let value, let parsed = Double(value) { height = CGFloat(parsed); index += 1 }
73 + case "--margin":
74 + if let value, let parsed = Double(value) { margin = CGFloat(parsed); index += 1 }
75 + case "--timeout":
76 + if let value, let parsed = Double(value), parsed > 0 {
77 + timeoutSeconds = parsed
78 + index += 1
79 + }
80 + case "--help", "-h":
81 + print("""
82 + Usage: composio-native-ui [options]
83 +
84 + Content:
85 + --tool <slug> Tool slug shown in the title. Default: GMAIL_GET_PROFILE
86 + --account <name> Account identifier. Default: gmail_pall-seba
87 + --caller-agent <id> Agent calling the tool. claude | codex | openclaw | composio (default).
88 + --caller-name <text> Override the agent display name shown in the title.
89 + --title <text> Override the auto-built title entirely.
90 + --message <text> Alias for --title, used by CLI dev previews.
91 + --subtitle <text> Subtitle / description line.
92 + --deny-label <text> Override the "Deny" button label.
93 + --allow-session-label <text>
94 + --allow-once-label <text> Override the action button labels.
95 +
96 + Window:
97 + --width <points> Window width. Default: 460
98 + --height <points> Window height. Default: 200
99 + --margin <points> Margin from visible screen edges. Default: 24
100 + --timeout <secs> Auto-close after the given number of seconds.
101 +
102 + Result:
103 + --callback-file <path> Write the decision JSON to this file. If omitted, JSON is printed to stdout.
104 +
105 + Emits a single JSON line:
106 + {"decision":"allow_once|allow_session|deny|dismissed","tool":"...","account":"..."}
107 +
108 + Exit code: 0 on button press, 1 on dismissed/timeout/window-close.
109 + """)
110 + Foundation.exit(0)
111 + default:
112 + break
113 + }
114 +
115 + index += 1
116 + }
117 + }
118 +}
119 +
120 +// MARK: - Shader
121 +
122 +final class ShaderRenderer: NSObject, MTKViewDelegate {
123 + private let commandQueue: MTLCommandQueue
124 + private let pipelineState: MTLRenderPipelineState
125 + private let startTime = CACurrentMediaTime()
126 +
127 + init?(device: MTLDevice, pixelFormat: MTLPixelFormat) {
128 + guard let commandQueue = device.makeCommandQueue() else { return nil }
129 + self.commandQueue = commandQueue
130 +
131 + let source = """
132 + #include <metal_stdlib>
133 + using namespace metal;
134 +
135 + struct VertexOut {
136 + float4 position [[position]];
137 + float2 uv;
138 + };
139 +
140 + vertex VertexOut vertex_main(uint vertexID [[vertex_id]]) {
141 + float2 positions[3] = {
142 + float2(-1.0, -1.0),
143 + float2( 3.0, -1.0),
144 + float2(-1.0, 3.0)
145 + };
146 + VertexOut out;
147 + out.position = float4(positions[vertexID], 0.0, 1.0);
148 + out.uv = positions[vertexID] * 0.5 + 0.5;
149 + return out;
150 + }
151 +
152 + // Ordered 8x8 Bayer matrix, normalised to [0,1).
153 + float bayer8(int2 p) {
154 + const int M[64] = {
155 + 0, 32, 8, 40, 2, 34, 10, 42,
156 + 48, 16, 56, 24, 50, 18, 58, 26,
157 + 12, 44, 4, 36, 14, 46, 6, 38,
158 + 60, 28, 52, 20, 62, 30, 54, 22,
159 + 3, 35, 11, 43, 1, 33, 9, 41,
160 + 51, 19, 59, 27, 49, 17, 57, 25,
161 + 15, 47, 7, 39, 13, 45, 5, 37,
162 + 63, 31, 55, 23, 61, 29, 53, 21
163 + };
164 + int x = ((p.x % 8) + 8) % 8;
165 + int y = ((p.y % 8) + 8) % 8;
166 + return float(M[y * 8 + x]) / 64.0;
167 + }
168 +
169 + // Matches the dashboard's <Dither + SineWave> composition:
170 + // colorB="#c2c2c2" pattern="bayer8" pixelSize=2
171 + // spread=0.8 threshold=0.59
172 + // SineWave amplitude=0.1 angle=162 frequency=0.5 softness=1 speed=-0.4
173 + fragment float4 fragment_main(VertexOut in [[stage_in]], constant float &time [[buffer(0)]]) {
174 + const float PI = 3.14159265;
175 + float2 uv = in.uv;
176 +
177 + // SineWave field across the canvas. Angle 162° from horizontal.
178 + float ang = 162.0 * PI / 180.0;
179 + float2 dir = float2(cos(ang), sin(ang));
180 + float frequency = 0.5;
181 + float amplitude = 0.10;
182 + float softness = 1.0;
183 + float speed = -0.4;
184 +
185 + float coord = dot(uv - 0.5, dir) * frequency * 6.28318 + time * speed * 3.0;
186 + float wave = 0.5 + 0.5 * sin(coord); // 0..1
187 + // softness=1 → broad, gentle band; softness<1 would sharpen.
188 + wave = pow(wave, 1.0 / max(softness, 0.001));
189 + // amplitude=0.1 modulates a small swing around 0.5.
190 + float sineValue = 0.5 + (wave - 0.5) * (amplitude * 4.0);
191 +
192 + // Bayer-ordered dither at pixelSize=2.
193 + int2 pix = int2(floor(in.position.xy * 0.5));
194 + float b = bayer8(pix);
195 + float spread = 0.80;
196 + float threshold = 0.59;
197 +
198 + // Standard ordered-dither comparison.
199 + float mask = step(threshold, sineValue + (b - 0.5) * spread);
200 +
201 + float3 white = float3(1.0, 1.0, 1.0);
202 + float3 grey = float3(0.7607, 0.7607, 0.7607); // #c2c2c2
203 +
204 + float3 color = mix(grey, white, mask);
205 + return float4(color, 1.0);
206 + }
207 + """
208 +
209 + do {
210 + let library = try device.makeLibrary(source: source, options: nil)
211 + let descriptor = MTLRenderPipelineDescriptor()
212 + descriptor.vertexFunction = library.makeFunction(name: "vertex_main")
213 + descriptor.fragmentFunction = library.makeFunction(name: "fragment_main")
214 + descriptor.colorAttachments[0].pixelFormat = pixelFormat
215 + descriptor.colorAttachments[0].isBlendingEnabled = false
216 + self.pipelineState = try device.makeRenderPipelineState(descriptor: descriptor)
217 + } catch {
218 + fputs("Failed to compile Metal shader: \(error)\n", stderr)
219 + return nil
220 + }
221 +
222 + super.init()
223 + }
224 +
225 + func mtkView(_ view: MTKView, drawableSizeWillChange size: CGSize) {}
226 +
227 + func draw(in view: MTKView) {
228 + guard
229 + let descriptor = view.currentRenderPassDescriptor,
230 + let drawable = view.currentDrawable,
231 + let commandBuffer = commandQueue.makeCommandBuffer(),
232 + let encoder = commandBuffer.makeRenderCommandEncoder(descriptor: descriptor)
233 + else { return }
234 +
235 + var elapsed = Float(CACurrentMediaTime() - startTime)
236 + encoder.setRenderPipelineState(pipelineState)
237 + encoder.setFragmentBytes(&elapsed, length: MemoryLayout<Float>.stride, index: 0)
238 + encoder.drawPrimitives(type: .triangle, vertexStart: 0, vertexCount: 3)
239 + encoder.endEncoding()
240 + commandBuffer.present(drawable)
241 + commandBuffer.commit()
242 + }
243 +}
244 +
245 +@MainActor
246 +final class MetalBackgroundView: MTKView {
247 + private var shaderRenderer: ShaderRenderer?
248 +
249 + init(frame: CGRect) {
250 + let device = MTLCreateSystemDefaultDevice()
251 + super.init(frame: frame, device: device)
252 +
253 + wantsLayer = true
254 + layer?.isOpaque = true
255 + colorPixelFormat = .bgra8Unorm
256 + framebufferOnly = true
257 + isPaused = false
258 + enableSetNeedsDisplay = false
259 + preferredFramesPerSecond = 60
260 + clearColor = MTLClearColor(red: 0, green: 0, blue: 0, alpha: 1)
261 +
262 + if let device, let renderer = ShaderRenderer(device: device, pixelFormat: colorPixelFormat) {
263 + shaderRenderer = renderer
264 + delegate = renderer
265 + }
266 + }
267 +
268 + required init(coder: NSCoder) {
269 + fatalError("init(coder:) has not been implemented")
270 + }
271 +}
272 +
273 +// MARK: - Tokens
274 +
275 +// SVG logos for each caller agent — embedded so the sidecar remains a
276 +// single binary with no asset bundle. macOS NSImage decodes SVG directly.
277 +
278 +struct Agent {
279 + let id: String
280 + let displayName: String
281 + let svg: String
282 +
283 + func makeImage() -> NSImage? {
284 + guard let data = svg.data(using: .utf8),
285 + let image = NSImage(data: data) else { return nil }
286 + return image
287 + }
288 +}
289 +
290 +enum Agents {
291 + static let composioSVG = #"""
292 + <svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
293 + <g clip-path="url(#clip0_2367_5)">
294 + <path d="M91.7032 28.1801L35.3611 16.6572C31.6669 15.8988 28.1929 18.7367 28.1929 22.5043V49.1954V50.6144V77.3052C28.1929 81.0729 31.6669 83.9112 35.3611 83.1526L91.7032 71.6296" stroke="black" stroke-width="2.8556" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
295 + <path d="M48.1992 7.38531C48.1993 2.09223 53.6097 -1.44765 58.4546 0.57874L58.6851 0.679333L58.6902 0.68227L88.8308 14.6023C91.4759 15.7947 93.1338 18.4366 93.1346 21.3053V33.0975C93.1346 37.3994 89.4707 40.797 85.1902 40.4658L51.0547 37.918V61.8914L85.185 59.3435L85.585 59.323C89.6842 59.2231 93.1331 62.5334 93.109 66.6876V78.4797C93.109 81.3707 91.4075 83.9737 88.8105 85.1812L88.806 85.1827L58.691 99.0774L58.6917 99.0782C53.7808 101.351 48.1992 97.7714 48.1992 92.3759V81.1383C47.9779 81.2256 47.741 81.2834 47.4921 81.3015L30.8347 82.5007C29.4429 82.6007 28.2584 81.4977 28.2582 80.1023V67.7354C28.2583 67.256 28.4014 66.8063 28.6474 66.4277L14.9439 67.4513H14.9388C10.6701 67.7539 7.00001 64.3671 7 60.0823V39.7271C7.00031 35.4239 10.6671 32.0248 14.9491 32.3589H14.9483L28.3486 33.3589C28.2905 33.152 28.2583 32.9345 28.2582 32.7099V19.6826C28.2582 17.7807 29.9597 16.3299 31.8377 16.6304L47.6992 19.168C47.8735 19.1959 48.0404 19.2435 48.1992 19.3059V7.38531ZM85.4075 62.191H85.4023L51.0547 64.755V79.6601L90.2541 71.4669V66.6774L90.2496 66.435C90.1323 63.9438 87.9489 61.9928 85.4075 62.191ZM27.7075 36.1748C27.9471 36.5495 28.0863 36.9936 28.0864 37.4678V62.7813C28.0864 63.0748 28.0314 63.3559 27.9344 63.6169L48.1992 62.1044V37.7043L27.7075 36.1748ZM51.0547 35.0544L85.4023 37.6183L85.4075 37.6191L85.6511 37.6316C88.1632 37.6928 90.279 35.6595 90.279 33.0975V28.1405L51.0547 19.9411V35.0544Z" fill="black"/>
296 + </g>
297 + <defs>
298 + <clipPath id="clip0_2367_5">
299 + <rect width="86.4662" height="100" fill="white" transform="translate(7)"/>
300 + </clipPath>
301 + </defs>
302 + </svg>
303 + """#
304 +
305 + static let claudeSVG = #"""
306 + <svg preserveAspectRatio="xMidYMid" viewBox="0 0 256 257" xmlns="http://www.w3.org/2000/svg"><path fill="#D97757" d="m50.228 170.321 50.357-28.257.843-2.463-.843-1.361h-2.462l-8.426-.518-28.775-.778-24.952-1.037-24.175-1.296-6.092-1.297L0 125.796l.583-3.759 5.12-3.434 7.324.648 16.202 1.101 24.304 1.685 17.629 1.037 26.118 2.722h4.148l.583-1.685-1.426-1.037-1.101-1.037-25.147-17.045-27.22-18.017-14.258-10.37-7.713-5.25-3.888-4.925-1.685-10.758 7-7.713 9.397.649 2.398.648 9.527 7.323 20.35 15.75L94.817 91.9l3.889 3.24 1.555-1.102.195-.777-1.75-2.917-14.453-26.118-15.425-26.572-6.87-11.018-1.814-6.61c-.648-2.723-1.102-4.991-1.102-7.778l7.972-10.823L71.42 0 82.05 1.426l4.472 3.888 6.61 15.101 10.694 23.786 16.591 32.34 4.861 9.592 2.592 8.879.973 2.722h1.685v-1.556l1.36-18.211 2.528-22.36 2.463-28.776.843-8.1 4.018-9.722 7.971-5.25 6.222 2.981 5.12 7.324-.713 4.73-3.046 19.768-5.962 30.98-3.889 20.739h2.268l2.593-2.593 10.499-13.934 17.628-22.036 7.778-8.749 9.073-9.657 5.833-4.601h11.018l8.1 12.055-3.628 12.443-11.342 14.388-9.398 12.184-13.48 18.147-8.426 14.518.778 1.166 2.01-.194 30.46-6.481 16.462-2.982 19.637-3.37 8.88 4.148.971 4.213-3.5 8.62-20.998 5.184-24.628 4.926-36.682 8.685-.454.324.519.648 16.526 1.555 7.065.389h17.304l32.21 2.398 8.426 5.574 5.055 6.805-.843 5.184-12.962 6.611-17.498-4.148-40.83-9.721-14-3.5h-1.944v1.167l11.666 11.406 21.387 19.314 26.767 24.887 1.36 6.157-3.434 4.86-3.63-.518-23.526-17.693-9.073-7.972-20.545-17.304h-1.36v1.814l4.73 6.935 25.017 37.59 1.296 11.536-1.814 3.76-6.481 2.268-7.13-1.297-14.647-20.544-15.1-23.138-12.185-20.739-1.49.843-7.194 77.448-3.37 3.953-7.778 2.981-6.48-4.925-3.436-7.972 3.435-15.749 4.148-20.544 3.37-16.333 3.046-20.285 1.815-6.74-.13-.454-1.49.194-15.295 20.999-23.267 31.433-18.406 19.702-4.407 1.75-7.648-3.954.713-7.064 4.277-6.286 25.47-32.405 15.36-20.092 9.917-11.6-.065-1.686h-.583L44.07 198.125l-12.055 1.555-5.185-4.86.648-7.972 2.463-2.593 20.35-13.999-.064.065Z"/></svg>
307 + """#
308 +
309 + // Codex glyph — original artwork is white-on-dark; we recolor to near-black
310 + // so it reads on the light card without a containing dark plate.
311 + static let codexSVG = #"""
312 + <svg fill="#0A0A0A" fill-rule="evenodd" style="flex:none;line-height:1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z"/></svg>
313 + """#
314 +
315 + static let openclawSVG = #"""
316 + <svg viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="openclaw__lobster-gradient" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stop-color="#ff4d4d"/><stop offset="100%" stop-color="#991b1b"/></linearGradient></defs><path d="M60 10 C30 10 15 35 15 55 C15 75 30 95 45 100 L45 110 L55 110 L55 100 C55 100 60 102 65 100 L65 110 L75 110 L75 100 C90 95 105 75 105 55 C105 35 90 10 60 10Z" fill="url(#openclaw__lobster-gradient)"/><path d="M20 45 C5 40 0 50 5 60 C10 70 20 65 25 55 C28 48 25 45 20 45Z" fill="url(#openclaw__lobster-gradient)"/><path d="M100 45 C115 40 120 50 115 60 C110 70 100 65 95 55 C92 48 95 45 100 45Z" fill="url(#openclaw__lobster-gradient)"/><path d="M45 15 Q35 5 30 8" stroke="#ff4d4d" stroke-width="3" stroke-linecap="round"/><path d="M75 15 Q85 5 90 8" stroke="#ff4d4d" stroke-width="3" stroke-linecap="round"/><circle cx="45" cy="35" r="6" fill="#050810"/><circle cx="75" cy="35" r="6" fill="#050810"/><circle cx="46" cy="34" r="2.5" fill="#00e5cc"/><circle cx="76" cy="34" r="2.5" fill="#00e5cc"/></svg>
317 + """#
318 +
319 + static let composio = Agent(id: "composio", displayName: "Composio", svg: composioSVG)
320 + static let claude = Agent(id: "claude", displayName: "Claude", svg: claudeSVG)
321 + static let codex = Agent(id: "codex", displayName: "Codex", svg: codexSVG)
322 + static let openclaw = Agent(id: "openclaw", displayName: "OpenClaw", svg: openclawSVG)
323 +
324 + static func resolve(_ id: String) -> Agent {
325 + switch id.lowercased() {
326 + case "claude", "claude-code", "claudecode": return claude
327 + case "codex": return codex
328 + case "openclaw", "open-claw": return openclaw
329 + case "composio", "": return composio
330 + default: return composio
331 + }
332 + }
333 +}
334 +
335 +// Matches the dashboard's light theme (oklch tokens flattened to sRGB).
336 +enum Palette {
337 + static let cardBg = NSColor.white.withAlphaComponent(0.86) // bg-card/80
338 + static let border = NSColor(white: 0.0, alpha: 0.10) // border-border
339 + static let divider = NSColor(white: 0.0, alpha: 0.08)
340 + static let textPrimary = NSColor(white: 0.07, alpha: 1.0) // near-black
341 + static let textSecondary = NSColor(white: 0.40, alpha: 1.0) // text-muted-foreground
342 + static let textMuted = NSColor(white: 0.55, alpha: 1.0)
343 + static let primary = NSColor(white: 0.09, alpha: 1.0) // primary button
344 + static let primaryHover = NSColor(white: 0.18, alpha: 1.0)
345 + static let onPrimary = NSColor.white
346 +}
347 +
348 +// MARK: - Card chrome
349 +
350 +// Light-theme card: rounded-2xl + border + subtle inner stroke, like
351 +// `border-border bg-card/80 rounded-2xl shadow-* backdrop-blur-md`.
352 +@MainActor
353 +final class CardView: NSView {
354 + private let innerStroke = CAShapeLayer()
355 +
356 + override init(frame frameRect: NSRect) {
357 + super.init(frame: frameRect)
358 + wantsLayer = true
359 + layer?.cornerRadius = 16
360 + layer?.cornerCurve = .continuous
361 + layer?.masksToBounds = true
362 +
363 + innerStroke.fillColor = NSColor.clear.cgColor
364 + innerStroke.strokeColor = Palette.border.cgColor
365 + innerStroke.lineWidth = 1
366 + layer?.addSublayer(innerStroke)
367 + }
368 +
369 + required init?(coder: NSCoder) { fatalError() }
370 +
371 + override func layout() {
372 + super.layout()
373 + innerStroke.frame = bounds
374 + innerStroke.path = CGPath(
375 + roundedRect: bounds.insetBy(dx: 0.5, dy: 0.5),
376 + cornerWidth: 15.5, cornerHeight: 15.5, transform: nil
377 + )
378 + }
379 +}
380 +
381 +enum AccentStyle {
382 + case primary // dark filled, white text
383 + case secondary // transparent w/ border, dark text
384 +}
385 +
386 +@MainActor
387 +final class AccentButton: NSButton {
388 + private let action_: () -> Void
389 + private let style: AccentStyle
390 + private let fill = CALayer()
391 + private let stroke = CAShapeLayer()
392 + private let glow = CALayer()
393 + private var isHovering = false
394 + private var isPressed = false
395 +
396 + init(title: String, style: AccentStyle = .primary, action: @escaping () -> Void) {
397 + self.action_ = action
398 + self.style = style
399 + super.init(frame: .zero)
400 + self.title = ""
401 + isBordered = false
402 + wantsLayer = true
403 + layer?.masksToBounds = false
404 + focusRingType = .none
405 +
406 + glow.backgroundColor = NSColor.clear.cgColor
407 + glow.shadowColor = NSColor.black.cgColor
408 + glow.shadowOpacity = 0.0
409 + glow.shadowRadius = 12
410 + glow.shadowOffset = CGSize(width: 0, height: 2)
411 + layer?.addSublayer(glow)
412 +
413 + fill.cornerRadius = 8
414 + fill.cornerCurve = .continuous
415 + layer?.addSublayer(fill)
416 +
417 + stroke.fillColor = NSColor.clear.cgColor
418 + stroke.lineWidth = 1
419 + layer?.addSublayer(stroke)
420 +
421 + let textColor: NSColor
422 + switch style {
423 + case .primary:
424 + fill.backgroundColor = Palette.primary.cgColor
425 + stroke.strokeColor = NSColor.clear.cgColor
426 + textColor = Palette.onPrimary
427 + case .secondary:
428 + fill.backgroundColor = NSColor.white.withAlphaComponent(0.55).cgColor
429 + stroke.strokeColor = Palette.border.cgColor
430 + textColor = Palette.textPrimary
431 + }
432 +
433 + let attr = NSMutableAttributedString(string: title, attributes: [
434 + .font: NSFont.systemFont(ofSize: 12.5, weight: .medium),
435 + .foregroundColor: textColor,
436 + .kern: 0.1,
437 + ])
438 + attributedTitle = attr
439 +
440 + target = self
441 + self.action = #selector(invoke)
442 +
443 + let tracking = NSTrackingArea(rect: .zero,
444 + options: [.mouseEnteredAndExited, .inVisibleRect, .activeInActiveApp],
445 + owner: self, userInfo: nil)
446 + addTrackingArea(tracking)
447 + }
448 +
449 + required init?(coder: NSCoder) { fatalError() }
450 +
451 + override var intrinsicContentSize: NSSize {
452 + let base = super.intrinsicContentSize
453 + return NSSize(width: base.width + 22, height: 30)
454 + }
455 +
456 + override func layout() {
457 + super.layout()
458 + fill.frame = bounds
459 + glow.frame = bounds
460 + glow.shadowPath = CGPath(roundedRect: bounds, cornerWidth: 8, cornerHeight: 8, transform: nil)
461 + stroke.frame = bounds
462 + stroke.path = CGPath(
463 + roundedRect: bounds.insetBy(dx: 0.5, dy: 0.5),
464 + cornerWidth: 7.5, cornerHeight: 7.5, transform: nil
465 + )
466 + }
467 +
468 + override func resetCursorRects() {
469 + addCursorRect(bounds, cursor: .pointingHand)
470 + }
471 +
472 + override func mouseEntered(with event: NSEvent) {
473 + isHovering = true
474 + setState(hover: true, pressed: isPressed)
475 + }
476 +
477 + override func mouseExited(with event: NSEvent) {
478 + isHovering = false
479 + setState(hover: false, pressed: false)
480 + }
481 +
482 + override func mouseDown(with event: NSEvent) {
483 + isPressed = true
484 + setState(hover: isHovering, pressed: true)
485 + super.mouseDown(with: event)
486 + isPressed = false
487 + setState(hover: isHovering, pressed: false)
488 + }
489 +
490 + private func setState(hover: Bool, pressed: Bool) {
491 + CATransaction.begin()
492 + CATransaction.setAnimationDuration(0.14)
493 + let scale: CGFloat = pressed ? 0.97 : 1.0
494 + layer?.transform = CATransform3DMakeScale(scale, scale, 1)
495 + switch style {
496 + case .primary:
497 + glow.shadowOpacity = hover ? 0.18 : 0.0
498 + fill.backgroundColor = (hover ? Palette.primaryHover : Palette.primary).cgColor
499 + case .secondary:
500 + glow.shadowOpacity = 0.0
501 + fill.backgroundColor = (hover
502 + ? NSColor.white.withAlphaComponent(0.85)
503 + : NSColor.white.withAlphaComponent(0.55)).cgColor
504 + }
505 + CATransaction.commit()
506 + }
507 +
508 + @objc private func invoke() { action_() }
509 +}
510 +
511 +// MARK: - Decision callback
512 +
513 +enum Decision: String {
514 + case deny = "deny"
515 + case allowOnce = "allow_once"
516 + case allowSession = "allow_session"
517 + case dismissed = "dismissed"
518 +}
519 +
520 +@MainActor
521 +final class DecisionSink {
522 + static let shared = DecisionSink()
523 + private var hasEmitted = false
524 + private var configuration: Configuration?
525 +
526 + func configure(_ config: Configuration) {
527 + self.configuration = config
528 + }
529 +
530 + func emitAndExit(_ decision: Decision) {
531 + guard !hasEmitted, let config = configuration else {
532 + Foundation.exit(decision == .dismissed ? 1 : 0)
533 + }
534 + hasEmitted = true
535 +
536 + let payload: [String: Any] = [
537 + "decision": decision.rawValue,
538 + "tool": config.tool,
539 + "account": config.account,
540 + ]
541 + let line: String
542 + if let data = try? JSONSerialization.data(withJSONObject: payload, options: [.sortedKeys]),
543 + let json = String(data: data, encoding: .utf8) {
544 + line = json + "\n"
545 + } else {
546 + line = "{\"decision\":\"\(decision.rawValue)\"}\n"
547 + }
548 +
549 + if let path = config.callbackFile {
550 + try? line.write(toFile: path, atomically: true, encoding: .utf8)
551 + } else {
552 + FileHandle.standardOutput.write(Data(line.utf8))
553 + }
554 +
555 + Foundation.exit(decision == .dismissed ? 1 : 0)
556 + }
557 +}
558 +
559 +// MARK: - App
560 +
561 +@MainActor
562 +final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
563 + private let configuration: Configuration
564 + private var window: NSWindow?
565 +
566 + init(configuration: Configuration) {
567 + self.configuration = configuration
568 + super.init()
569 + }
570 +
571 + func applicationDidFinishLaunching(_ notification: Notification) {
572 + NSApp.setActivationPolicy(.accessory)
573 + DecisionSink.shared.configure(configuration)
574 + createWindow()
575 +
576 + if let timeoutSeconds = configuration.timeoutSeconds {
577 + Timer.scheduledTimer(withTimeInterval: timeoutSeconds, repeats: false) { _ in
578 + Task { @MainActor in
579 + DecisionSink.shared.emitAndExit(.dismissed)
580 + }
581 + }
582 + }
583 + }
584 +
585 + func windowWillClose(_ notification: Notification) {
586 + DecisionSink.shared.emitAndExit(.dismissed)
587 + }
588 +
589 + private func createWindow() {
590 + let frame = bottomRightFrame()
591 +
592 + let panel = NSPanel(
593 + contentRect: frame,
594 + styleMask: [.borderless, .nonactivatingPanel],
595 + backing: .buffered,
596 + defer: false
597 + )
598 + panel.isOpaque = false
599 + panel.backgroundColor = .clear
600 + panel.hasShadow = false
601 + panel.ignoresMouseEvents = false
602 + panel.isMovableByWindowBackground = true
603 + panel.isFloatingPanel = true
604 + panel.animationBehavior = .none
605 + panel.level = .floating
606 + panel.collectionBehavior = [.moveToActiveSpace, .fullScreenAuxiliary]
607 + panel.delegate = self
608 + panel.contentView = makeContentView()
609 + panel.setFrame(frame, display: true, animate: false)
610 + panel.orderFrontRegardless()
611 +
612 + DispatchQueue.main.async { [weak panel] in
613 + panel?.setFrame(self.bottomRightFrame(), display: true, animate: false)
614 + }
615 +
616 + window = panel
617 + }
618 +
619 + private func bottomRightFrame() -> NSRect {
620 + let screen = screenForPlacement()
621 + let visibleFrame = screen.visibleFrame
622 + let size = NSSize(width: configuration.width, height: configuration.height)
623 + let origin = NSPoint(
624 + x: visibleFrame.maxX - size.width - configuration.margin,
625 + y: visibleFrame.minY + configuration.margin
626 + )
627 + return NSRect(origin: origin, size: size)
628 + }
629 +
630 + private func screenForPlacement() -> NSScreen {
631 + let mouseLocation = NSEvent.mouseLocation
632 + if let containingMouse = NSScreen.screens.first(where: { NSMouseInRect(mouseLocation, $0.frame, false) }) {
633 + return containingMouse
634 + }
635 + return NSScreen.main ?? NSScreen.screens.first ?? NSScreen()
636 + }
637 +
638 + private func makeContentView() -> NSView {
639 + let root = NSView(frame: NSRect(x: 0, y: 0, width: configuration.width, height: configuration.height))
640 + root.wantsLayer = true
641 + root.layer?.backgroundColor = NSColor.clear.cgColor
642 + root.layer?.masksToBounds = false
643 +
644 + // Soft drop shadow behind the card.
645 + let shadowHost = NSView()
646 + shadowHost.wantsLayer = true
647 + shadowHost.translatesAutoresizingMaskIntoConstraints = false
648 + if let l = shadowHost.layer {
649 + l.shadowColor = NSColor.black.cgColor
650 + l.shadowOpacity = 0.18
651 + l.shadowRadius = 30
652 + l.shadowOffset = CGSize(width: 0, height: -12)
653 + l.masksToBounds = false
654 + }
655 + root.addSubview(shadowHost)
656 +
657 + let card = CardView()
658 + card.translatesAutoresizingMaskIntoConstraints = false
659 + shadowHost.addSubview(card)
660 +
661 + // Dithered sine-wave shader — fills the card.
662 + let background = MetalBackgroundView(frame: .zero)
663 + background.translatesAutoresizingMaskIntoConstraints = false
664 + card.addSubview(background)
665 +
666 + // Translucent white wash so the dither reads more softly under text.
667 + let wash = NSView()
668 + wash.wantsLayer = true
669 + wash.layer?.backgroundColor = NSColor.white.withAlphaComponent(0.55).cgColor
670 + wash.translatesAutoresizingMaskIntoConstraints = false
671 + card.addSubview(wash)
672 +
673 + // --- Bottom-left brand mark is always Composio.
674 + let logoView = NSImageView()
675 + logoView.image = Agents.composio.makeImage()
676 + logoView.imageScaling = .scaleProportionallyUpOrDown
677 + logoView.imageAlignment = .alignCenter
678 + logoView.translatesAutoresizingMaskIntoConstraints = false
679 + card.addSubview(logoView)
680 +
681 + // --- Title: "[agent-icon] wants to use TOOL with ACCOUNT".
682 + // Agent logo is inlined into the attributed string via NSTextAttachment,
683 + // so it sits on the same baseline as the rest of the title.
684 + let toolSlug = configuration.tool
685 + let account = configuration.account
686 + let titleFont = NSFont.systemFont(ofSize: 15, weight: .semibold)
687 + let monoFont = NSFont.monospacedSystemFont(ofSize: 13, weight: .semibold)
688 + let textAttrs: [NSAttributedString.Key: Any] = [
689 + .font: titleFont,
690 + .foregroundColor: Palette.textPrimary,
691 + .kern: -0.2,
692 + ]
693 + let monoAttrs: [NSAttributedString.Key: Any] = [
694 + .font: monoFont,
695 + .foregroundColor: Palette.textPrimary,
696 + ]
697 +
698 + let titleAttr = NSMutableAttributedString()
699 + if let customTitle = configuration.title, !customTitle.isEmpty {
700 + // Caller supplied a verbatim title — render as-is, still
701 + // monospacing the tool/account if they appear.
702 + titleAttr.append(NSAttributedString(string: customTitle, attributes: textAttrs))
703 + if let r = customTitle.range(of: toolSlug) {
704 + titleAttr.addAttribute(.font, value: monoFont,
705 + range: NSRange(r, in: customTitle))
706 + }
707 + if let r = customTitle.range(of: account) {
708 + titleAttr.addAttribute(.font, value: monoFont,
709 + range: NSRange(r, in: customTitle))
710 + }
711 + } else if let agent = configuration.resolvedAgent {
712 + // Inline agent logo as the subject of the sentence.
713 + if let agentImage = agent.makeImage() {
714 + let attachment = NSTextAttachment()
715 + attachment.image = agentImage
716 + attachment.bounds = CGRect(x: 0, y: -7, width: 28, height: 28)
717 + titleAttr.append(NSAttributedString(attachment: attachment))
718 + titleAttr.append(NSAttributedString(string: " ", attributes: textAttrs))
719 + }
720 + titleAttr.append(NSAttributedString(string: "wants to use ", attributes: textAttrs))
721 + titleAttr.append(NSAttributedString(string: toolSlug, attributes: monoAttrs))
722 + } else {
723 + // No caller agent — plain CLI-mode sentence, no inline logo.
724 + titleAttr.append(NSAttributedString(string: "The composio cli wants to execute ", attributes: textAttrs))
725 + titleAttr.append(NSAttributedString(string: toolSlug, attributes: monoAttrs))
726 + }
727 +
728 + let title = NSTextField(labelWithAttributedString: titleAttr)
729 + title.lineBreakMode = .byTruncatingTail
730 + title.maximumNumberOfLines = 2
731 + title.translatesAutoresizingMaskIntoConstraints = false
732 + card.addSubview(title)
733 +
734 + // --- Account line: "Account: <account>"
735 + let accountAttr = NSMutableAttributedString()
736 + accountAttr.append(NSAttributedString(string: "Account: ", attributes: [
737 + .font: NSFont.systemFont(ofSize: 12, weight: .regular),
738 + .foregroundColor: Palette.textSecondary,
739 + ]))
740 + accountAttr.append(NSAttributedString(string: account, attributes: [
741 + .font: NSFont.monospacedSystemFont(ofSize: 12, weight: .semibold),
742 + .foregroundColor: Palette.textPrimary,
743 + ]))
744 + let accountField = NSTextField(labelWithAttributedString: accountAttr)
745 + accountField.lineBreakMode = .byTruncatingTail
746 + accountField.maximumNumberOfLines = 1
747 + accountField.translatesAutoresizingMaskIntoConstraints = false
748 + card.addSubview(accountField)
749 +
750 + // --- Three actions matching the elicitation oneOf decisions.
751 + let denyButton = AccentButton(title: configuration.denyLabel, style: .secondary) {
752 + DecisionSink.shared.emitAndExit(.deny)
753 + }
754 + let allowSessionButton = AccentButton(title: configuration.allowSessionLabel, style: .secondary) {
755 + DecisionSink.shared.emitAndExit(.allowSession)
756 + }
757 + let allowOnceButton = AccentButton(title: configuration.allowOnceLabel, style: .primary) {
758 + DecisionSink.shared.emitAndExit(.allowOnce)
759 + }
760 + // Enter triggers the default action.
761 + allowOnceButton.keyEquivalent = "\r"
762 +
763 + let buttonRow = NSStackView(views: [denyButton, allowSessionButton, allowOnceButton])
764 + buttonRow.orientation = .horizontal
765 + buttonRow.alignment = .centerY
766 + buttonRow.spacing = 8
767 + buttonRow.translatesAutoresizingMaskIntoConstraints = false
768 + card.addSubview(buttonRow)
769 +
770 + let hPad: CGFloat = 22
771 + let headerTop: CGFloat = 20
772 + let bodyBottom: CGFloat = 18
773 + let logoSize: CGFloat = 32
774 +
775 + NSLayoutConstraint.activate([
776 + shadowHost.leadingAnchor.constraint(equalTo: root.leadingAnchor),
777 + shadowHost.trailingAnchor.constraint(equalTo: root.trailingAnchor),
778 + shadowHost.topAnchor.constraint(equalTo: root.topAnchor),
779 + shadowHost.bottomAnchor.constraint(equalTo: root.bottomAnchor),
780 +
781 + card.leadingAnchor.constraint(equalTo: shadowHost.leadingAnchor),
782 + card.trailingAnchor.constraint(equalTo: shadowHost.trailingAnchor),
783 + card.topAnchor.constraint(equalTo: shadowHost.topAnchor),
784 + card.bottomAnchor.constraint(equalTo: shadowHost.bottomAnchor),
785 +
786 + background.leadingAnchor.constraint(equalTo: card.leadingAnchor),
787 + background.trailingAnchor.constraint(equalTo: card.trailingAnchor),
788 + background.topAnchor.constraint(equalTo: card.topAnchor),
789 + background.bottomAnchor.constraint(equalTo: card.bottomAnchor),
790 +
791 + wash.leadingAnchor.constraint(equalTo: card.leadingAnchor),
792 + wash.trailingAnchor.constraint(equalTo: card.trailingAnchor),
793 + wash.topAnchor.constraint(equalTo: card.topAnchor),
794 + wash.bottomAnchor.constraint(equalTo: card.bottomAnchor),
795 +
796 + // Logo anchored to the bottom-left, aligned with button row baseline.
797 + logoView.leadingAnchor.constraint(equalTo: card.leadingAnchor, constant: hPad),
798 + logoView.bottomAnchor.constraint(equalTo: card.bottomAnchor, constant: -bodyBottom - 4),
799 + logoView.widthAnchor.constraint(equalToConstant: logoSize),
800 + logoView.heightAnchor.constraint(equalToConstant: logoSize),
801 +
802 + title.leadingAnchor.constraint(equalTo: card.leadingAnchor, constant: hPad),
803 + title.trailingAnchor.constraint(lessThanOrEqualTo: card.trailingAnchor, constant: -hPad),
804 + title.topAnchor.constraint(equalTo: card.topAnchor, constant: headerTop),
805 +
806 + accountField.leadingAnchor.constraint(equalTo: title.leadingAnchor),
807 + accountField.trailingAnchor.constraint(lessThanOrEqualTo: card.trailingAnchor, constant: -hPad),
808 + accountField.topAnchor.constraint(equalTo: title.bottomAnchor, constant: 6),
809 +
810 + buttonRow.trailingAnchor.constraint(equalTo: card.trailingAnchor, constant: -hPad),
811 + buttonRow.bottomAnchor.constraint(equalTo: card.bottomAnchor, constant: -bodyBottom),
812 + ])
813 +
814 + return root
815 + }
816 +}
817 +
818 +let configuration = Configuration(arguments: Array(CommandLine.arguments.dropFirst()))
819 +let application = NSApplication.shared
820 +let delegate = AppDelegate(configuration: configuration)
821 +application.delegate = delegate
822 +application.run()
ts/packages/cli-local-tools/package.json
+1
@@ -38,6 +38,7 @@
38 "build": "pnpm exec tsdown",
39 "build:beeper-imessage": "bun run ./scripts/build-beeper-imessage-binaries.ts",
40 "build:peekaboo": "bun run ./scripts/build-peekaboo-binaries.ts",
41 + "build:composio-native-ui": "bun run ./scripts/build-composio-native-ui-binaries.ts",
42 "build:local-tool-binaries": "bun run ./scripts/build-local-tool-binaries.ts",
43 "test": "vitest run",
44 "typecheck": "pnpm exec tsgo --noEmit -p ./tsconfig.src.json",
ts/packages/cli-local-tools/scripts/build-composio-native-ui-binaries.ts new
+113
@@ -0,0 +1,113 @@
1 +#!/usr/bin/env bun
2 +
3 +import { $ } from 'bun';
4 +import fs from 'node:fs/promises';
5 +import path from 'node:path';
6 +import { fileURLToPath } from 'node:url';
7 +
8 +const scriptDir = path.dirname(fileURLToPath(import.meta.url));
9 +const packageRoot = path.resolve(scriptDir, '..');
10 +const repoRoot = path.resolve(packageRoot, '../../..');
11 +const swiftPackagePath = path.join(packageRoot, 'native/composio-native-ui');
12 +const outputRoot = path.join(packageRoot, 'local-tools-binaries/composio-native-ui');
13 +
14 +const targets = [
15 + {
16 + platform: 'darwin-arm64',
17 + swiftArch: 'arm64',
18 + buildPath: '.build/arm64-apple-macosx/release/composio-native-ui',
19 + },
20 + {
21 + platform: 'darwin-x64',
22 + swiftArch: 'x86_64',
23 + buildPath: '.build/x86_64-apple-macosx/release/composio-native-ui',
24 + },
25 +] as const;
26 +
27 +type Target = (typeof targets)[number];
28 +
29 +const exists = async (filePath: string): Promise<boolean> =>
30 + fs
31 + .access(filePath)
32 + .then(() => true)
33 + .catch(() => false);
34 +
35 +const ensurePlatform = () => {
36 + if (process.platform !== 'darwin') {
37 + throw new Error(
38 + 'Building the Composio native UI sidecar requires macOS and the Swift toolchain.'
39 + );
40 + }
41 +};
42 +
43 +const buildTarget = async (target: Target) => {
44 + console.log(`Building composio-native-ui for ${target.platform} (${target.swiftArch})...`);
45 + await $`swift build -c release --product composio-native-ui --arch ${target.swiftArch}`.cwd(
46 + swiftPackagePath
47 + );
48 +
49 + const builtBinary = path.join(swiftPackagePath, target.buildPath);
50 + if (!(await exists(builtBinary))) {
51 + throw new Error(`Swift build completed but ${target.buildPath} was not produced.`);
52 + }
53 +
54 + const targetDir = path.join(outputRoot, target.platform);
55 + const outputBinary = path.join(targetDir, 'composio-native-ui');
56 + await fs.mkdir(targetDir, { recursive: true });
57 + await fs.copyFile(builtBinary, outputBinary);
58 + await fs.chmod(outputBinary, 0o755);
59 + console.log(`Wrote ${path.relative(repoRoot, outputBinary)}`);
60 +};
61 +
62 +const writeNotice = async () => {
63 + const notice = `# Composio native UI sidecar
64 +
65 +The \`composio-native-ui\` binaries are built from the in-repository Swift package at \`ts/packages/cli-local-tools/native/composio-native-ui\`.
66 +
67 +- Purpose: native macOS UI surface that the Bun-compiled Composio CLI can spawn for auth flows, tool pickers, and other desktop affordances.
68 +- Build command: \`pnpm --filter @composio/cli-local-tools build:composio-native-ui -- --target <darwin-arm64|darwin-x64>\`
69 +- Underlying Swift build commands:
70 + - \`swift build -c release --product composio-native-ui --arch arm64\`
71 + - \`swift build -c release --product composio-native-ui --arch x86_64\`
72 +
73 +The scaffold currently opens a small AppKit panel near the bottom-right corner of the active screen. Generated executables are intentionally not committed; release jobs rebuild them before packaging CLI artifacts.
74 +`;
75 + await fs.writeFile(path.join(outputRoot, 'NOTICE.md'), notice, 'utf8');
76 +};
77 +
78 +const parseTargets = (): ReadonlyArray<Target> => {
79 + const rawArgs = process.argv.slice(2).filter(arg => arg !== '--');
80 + const targetIndex = rawArgs.indexOf('--target');
81 + const args =
82 + targetIndex >= 0 && rawArgs[targetIndex + 1]
83 + ? [rawArgs[targetIndex + 1]!]
84 + : rawArgs.filter(arg => !arg.startsWith('--'));
85 +
86 + if (args.length === 0 || args.includes('all')) return targets;
87 +
88 + const selected = targets.filter(target => args.includes(target.platform));
89 + const unknown = args.filter(arg => !targets.some(target => target.platform === arg));
90 + if (unknown.length > 0) {
91 + throw new Error(
92 + `Unknown target(s): ${unknown.join(', ')}. Expected one of: all, ${targets
93 + .map(target => target.platform)
94 + .join(', ')}`
95 + );
96 + }
97 + return selected;
98 +};
99 +
100 +const main = async () => {
101 + ensurePlatform();
102 + await fs.mkdir(outputRoot, { recursive: true });
103 + const selectedTargets = parseTargets();
104 + for (const target of selectedTargets) {
105 + await buildTarget(target);
106 + }
107 + await writeNotice();
108 +};
109 +
110 +main().catch(error => {
111 + console.error(error instanceof Error ? error.message : error);
112 + process.exit(1);
113 +});
ts/packages/cli-local-tools/scripts/build-local-tool-binaries.ts
+1
@@ -69,6 +69,7 @@ const main = async () => {
69 console.log(`Building native local-tool binaries for ${target}...`);
70 await runScript('build-beeper-imessage-binaries.ts', target);
71 await runScript('build-peekaboo-binaries.ts', target);
72 + await runScript('build-composio-native-ui-binaries.ts', target);
73 };
74
75 main().catch(error => {
ts/packages/cli/src/commands/dev.cmd.ts
+2
@@ -9,6 +9,7 @@ import { authConfigsCmd } from './auth-configs/auth-configs.cmd';
9 import { connectedAccountsCmd } from './connected-accounts/connected-accounts.cmd';
10 import { triggersCmd } from './triggers/triggers.cmd';
11 import { projectsCmd } from './projects/projects.cmd';
12 +import { devNativeUiCmd } from './dev/dev.native-ui.cmd';
13 import { ComposioCliUserConfig, resolveCliConfigPathSync } from 'src/services/cli-user-config';
14 import { Stdin } from 'src/services/stdin';
15 import { TerminalUI } from 'src/services/terminal-ui';
@@ -29,6 +30,7 @@ const devSubcommands = [
30 connectedAccountsCmd,
31 triggersCmd,
32 projectsCmd,
33 + devNativeUiCmd,
34 ] as const;
35
36 const describeCurrentMode = (enabled: boolean) =>
ts/packages/cli/src/commands/dev/dev.native-ui.cmd.ts new
+102
@@ -0,0 +1,102 @@
1 +import { Command, Options } from '@effect/cli';
2 +import { Effect, Option } from 'effect';
3 +import { spawn } from 'node:child_process';
4 +import fs from 'node:fs';
5 +import path from 'node:path';
6 +import {
7 + detectCliPlatform,
8 + ensureBundledBinaryExecutable,
9 + getLocalToolsBundleRootCandidates,
10 +} from '@composio/cli-local-tools';
11 +import { TerminalUI } from 'src/services/terminal-ui';
12 +
13 +const title = Options.text('title').pipe(
14 + Options.withDefault('Composio'),
15 + Options.withDescription('Title for the native sidecar window.')
16 +);
17 +
18 +const message = Options.text('message').pipe(
19 + Options.withDefault('Native UI sidecar scaffold'),
20 + Options.withDescription('Primary text displayed in the native sidecar window.')
21 +);
22 +
23 +const detail = Options.text('detail').pipe(
24 + Options.withDefault('This window is rendered by a Swift sidecar bundled with the CLI.'),
25 + Options.withDescription('Secondary text displayed in the native sidecar window.')
26 +);
27 +
28 +const timeout = Options.optional(Options.text('timeout')).pipe(
29 + Options.withDescription('Optional auto-close timeout in seconds.')
30 +);
31 +
32 +const NATIVE_UI_BINARY_NAME = 'composio-native-ui';
33 +
34 +const resolveNativeUiBinary = () => {
35 + const platform = detectCliPlatform();
36 + if (!platform.startsWith('darwin-')) {
37 + return {
38 + _tag: 'unsupported' as const,
39 + platform,
40 + };
41 + }
42 +
43 + const candidates = getLocalToolsBundleRootCandidates().map(root =>
44 + path.join(root, NATIVE_UI_BINARY_NAME, platform, NATIVE_UI_BINARY_NAME)
45 + );
46 + const binaryPath = candidates.find(candidate => fs.existsSync(candidate));
47 +
48 + return binaryPath
49 + ? {
50 + _tag: 'found' as const,
51 + binaryPath,
52 + }
53 + : {
54 + _tag: 'missing' as const,
55 + platform,
56 + candidates,
57 + };
58 +};
59 +
60 +export const devNativeUiCmd = Command.make('native-ui', { title, message, detail, timeout }).pipe(
61 + Command.withDescription('Open the experimental native macOS UI sidecar.'),
62 + Command.withHandler(({ title, message, detail, timeout }) =>
63 + Effect.gen(function* () {
64 + const ui = yield* TerminalUI;
65 + const resolved = resolveNativeUiBinary();
66 +
67 + if (resolved._tag === 'unsupported') {
68 + yield* ui.log.error(
69 + `The native UI sidecar is currently only available on macOS (detected ${resolved.platform}).`
70 + );
71 + return;
72 + }
73 +
74 + if (resolved._tag === 'missing') {
75 + yield* ui.log.error('The native UI sidecar binary was not found.');
76 + yield* ui.log.step(
77 + `Build it with: pnpm --filter @composio/cli-local-tools build:composio-native-ui -- --target ${resolved.platform}`
78 + );
79 + yield* ui.log.step(`Checked: ${resolved.candidates.join(', ')}`);
80 + return;
81 + }
82 +
83 + yield* Effect.tryPromise(() => ensureBundledBinaryExecutable(resolved.binaryPath));
84 +
85 + const args = ['--title', title, '--message', message, '--detail', detail];
86 + const timeoutValue = Option.getOrUndefined(timeout)?.trim();
87 + if (timeoutValue) {
88 + args.push('--timeout', timeoutValue);
89 + }
90 +
91 + yield* Effect.sync(() => {
92 + const child = spawn(resolved.binaryPath, args, {
93 + detached: true,
94 + stdio: 'ignore',
95 + });
96 + child.unref();
97 + });
98 +
99 + yield* ui.log.success('Opened native UI sidecar.');
100 + })
101 + )
102 +);