@agimon-ai/po-computer-use 0.0.0-alpha.2 → 0.0.0-alpha.200

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/LICENSE +97 -8
  2. package/README.md +10 -9
  3. package/dist/apiContracts.cjs +67 -47
  4. package/dist/apiContracts.cjs.map +1 -1
  5. package/dist/apiContracts.d.mts +2 -2
  6. package/dist/apiContracts.d.mts.map +1 -1
  7. package/dist/apiContracts.mjs +67 -47
  8. package/dist/apiContracts.mjs.map +1 -1
  9. package/dist/extensionService-BKBTsnkI.cjs +1243 -0
  10. package/dist/extensionService-BKBTsnkI.cjs.map +1 -0
  11. package/dist/extensionService-DqtoB79s.mjs +1077 -0
  12. package/dist/extensionService-DqtoB79s.mjs.map +1 -0
  13. package/dist/extensions/mcp-ui.mjs +12 -9
  14. package/dist/extensions/mcp-ui.mjs.map +1 -1
  15. package/dist/extensions/mcp.cjs +3 -3
  16. package/dist/extensions/mcp.cjs.map +1 -1
  17. package/dist/extensions/mcp.d.mts +1 -1
  18. package/dist/extensions/mcp.mjs +3 -3
  19. package/dist/extensions/mcp.mjs.map +1 -1
  20. package/dist/extensions/native.mjs +1445 -5
  21. package/dist/extensions/native.mjs.map +1 -1
  22. package/dist/extensions/server.cjs +1025 -653
  23. package/dist/extensions/server.cjs.map +1 -1
  24. package/dist/extensions/server.d.mts +2 -2
  25. package/dist/extensions/server.d.mts.map +1 -1
  26. package/dist/extensions/server.mjs +1007 -635
  27. package/dist/extensions/server.mjs.map +1 -1
  28. package/dist/extensions/web.mjs +959 -481
  29. package/dist/extensions/web.mjs.map +1 -1
  30. package/dist/index.cjs +14 -5
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.mts +69 -12
  33. package/dist/index.d.mts.map +1 -1
  34. package/dist/index.mjs +14 -5
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/po-runtime-identity.json +1 -0
  37. package/docs/computer-scripts.md +1 -1
  38. package/docs/remote-computer-use.md +11 -0
  39. package/llms.txt +1 -1
  40. package/package.json +74 -29
  41. package/src/prompts/codemode-how-to-computer-use/SKILL.md +83 -0
  42. package/src/types/computerUse.ts +72 -7
  43. package/src/types/computerUseApi.ts +26 -7
  44. package/dist/extensionService-Bp0q295i.cjs +0 -504
  45. package/dist/extensionService-Bp0q295i.cjs.map +0 -1
  46. package/dist/extensionService-DXvF7esO.mjs +0 -434
  47. package/dist/extensionService-DXvF7esO.mjs.map +0 -1
  48. package/src/prompts/po-use-computer-use/SKILL.md +0 -34
@@ -1,16 +1,464 @@
1
- import { defineActivityGroup, defineChannelFile, defineNativePlugin, defineSessionStore } from "@agimon-ai/po-core/native";
1
+ import { createApiClient, defineActivityGroup, defineChannelFile, defineFill, defineNativePlugin, defineSessionStore, defineSettingsPanel, defineToolRenderer, sessionApiAddress, t, useT } from "@agimon-ai/po-core/native";
2
+ import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
3
+ import { AppState } from "react-native";
4
+ import { View } from "react-native-unistyles/components/native/View";
5
+ import { Text } from "react-native-unistyles/components/native/Text";
6
+ import { Badge, Button, CheckIcon, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, Panel, fontOf, toolTone } from "@agimon-ai/po-native-components";
7
+ import { StyleSheet } from "react-native-unistyles";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
9
  //#region src/types/computerUseApi.ts
3
10
  const computerUseChannelType = "computer_use_state";
11
+ const COMPUTER_USE_STATUS_KEY = "po-computer-use";
12
+ /**
13
+ * Every path this API answers on, below its mount.
14
+ *
15
+ * The typed route table in `./apiRoutes` is built from this, the dispatcher
16
+ * reads that table, and the hub channel addresses the broker with these same
17
+ * strings, so a route cannot move on one side alone.
18
+ */
19
+ const COMPUTER_USE_ROUTES = {
20
+ artifact: "/artifact",
21
+ agentState: "/agent/state",
22
+ agentObserve: "/agent/observe",
23
+ agentAction: "/agent/action",
24
+ agentStop: "/agent/stop",
25
+ hubState: "/hub/state",
26
+ hubActivation: "/hub/activation",
27
+ hubAuthorization: "/hub/authorization",
28
+ hubNext: "/hub/next",
29
+ hubComplete: "/hub/complete",
30
+ hubStop: "/hub/stop",
31
+ hubRequestStop: "/hub/request-stop"
32
+ };
33
+ //#endregion
34
+ //#region src/types/desktopPermissions.ts
35
+ /** The macOS privacy permissions Desktop reports, in the order the settings page shows them. */
36
+ const DESKTOP_PERMISSIONS = [
37
+ "accessibility",
38
+ "screen-recording",
39
+ "microphone",
40
+ "automation",
41
+ "full-disk-access"
42
+ ];
43
+ //#endregion
44
+ //#region src/types/apiRoutes.ts
45
+ /**
46
+ * This package's routes, as data.
47
+ *
48
+ * No scope and no base path: the build reads both off
49
+ * `src/extensions/workspaces/sessions/(backend)/api/computer-use/`, so the
50
+ * mount is stated once, by the folder that creates it.
51
+ *
52
+ * The paths come from `COMPUTER_USE_ROUTES` rather than being written out
53
+ * again. That table already addressed the broker from the hub channel and from
54
+ * the broker's own dispatcher, and a second copy here is exactly the
55
+ * disagreement this file exists to prevent. The dispatcher now reads this
56
+ * table, so the page, the broker and the hub all resolve one set of strings.
57
+ *
58
+ * Recording reads can be reached from a browser with recording authorization. The `/agent/` and `/hub/` routes
59
+ * each demand a host-issued bearer token and answer 404 without one; they are
60
+ * declared here because they are this API's surface, not because a page calls
61
+ * them.
62
+ */
63
+ const routes = {
64
+ artifact: {
65
+ method: "GET",
66
+ path: COMPUTER_USE_ROUTES.artifact,
67
+ query: ["artifactId", "offset"],
68
+ raw: true
69
+ },
70
+ agentState: {
71
+ method: "GET",
72
+ path: COMPUTER_USE_ROUTES.agentState,
73
+ response: void 0
74
+ },
75
+ /** Answers whatever the admitted Desktop provider returned, which is runtime-defined JSON. */
76
+ agentObserve: {
77
+ method: "POST",
78
+ path: COMPUTER_USE_ROUTES.agentObserve,
79
+ response: void 0
80
+ },
81
+ agentAction: {
82
+ method: "POST",
83
+ path: COMPUTER_USE_ROUTES.agentAction,
84
+ response: void 0
85
+ },
86
+ agentStop: {
87
+ method: "POST",
88
+ path: COMPUTER_USE_ROUTES.agentStop,
89
+ response: void 0
90
+ },
91
+ hubState: {
92
+ method: "GET",
93
+ path: COMPUTER_USE_ROUTES.hubState,
94
+ response: void 0
95
+ },
96
+ /** Null until a reader has confirmed one; reading it moves the session to `activating`. */
97
+ hubActivation: {
98
+ method: "GET",
99
+ path: COMPUTER_USE_ROUTES.hubActivation,
100
+ response: void 0
101
+ },
102
+ hubAuthorization: {
103
+ method: "GET",
104
+ path: COMPUTER_USE_ROUTES.hubAuthorization,
105
+ response: void 0
106
+ },
107
+ hubNext: {
108
+ method: "GET",
109
+ path: COMPUTER_USE_ROUTES.hubNext,
110
+ response: void 0
111
+ },
112
+ hubComplete: {
113
+ method: "POST",
114
+ path: COMPUTER_USE_ROUTES.hubComplete,
115
+ response: void 0
116
+ },
117
+ hubRequestStop: {
118
+ method: "POST",
119
+ path: COMPUTER_USE_ROUTES.hubRequestStop,
120
+ response: void 0
121
+ },
122
+ hubStop: {
123
+ method: "POST",
124
+ path: COMPUTER_USE_ROUTES.hubStop,
125
+ response: void 0
126
+ },
127
+ /** Desktop's macOS permission states, served by the hub's `desktop-permissions` mount. */
128
+ desktopPermissions: {
129
+ method: "GET",
130
+ path: "/",
131
+ response: void 0
132
+ },
133
+ /** Asks macOS for the body's permission on the Mac running Desktop; answers the states after. */
134
+ requestDesktopPermission: {
135
+ method: "POST",
136
+ path: "/",
137
+ response: void 0
138
+ }
139
+ };
140
+ //#endregion
141
+ //#region src/extensions/(frontend)/setting/_lib/desktopPermissions.native.ts
142
+ /** Reads the Mac, never the phone. A request uses the host's step-up transport. */
143
+ async function readDesktopPermissions(request, permission) {
144
+ try {
145
+ const api = createApiClient(routes, {
146
+ scopes: ["host"],
147
+ basePath: "desktop-permissions",
148
+ transport: request,
149
+ sessionAddress: sessionApiAddress
150
+ });
151
+ const route = permission === void 0 ? api.host.desktopPermissions : api.host.requestDesktopPermission;
152
+ const response = await request(route.url(), permission === void 0 ? void 0 : {
153
+ method: route.spec.method,
154
+ headers: { "content-type": "application/json" },
155
+ body: JSON.stringify({ permission })
156
+ });
157
+ if (response.status === 404) return { status: "unavailable" };
158
+ const body = await response.json().catch(() => void 0);
159
+ if (typeof body === "object" && body !== null && !Array.isArray(body)) {
160
+ const record = body;
161
+ if (response.ok && !("error" in record) && DESKTOP_PERMISSIONS.every((key) => [
162
+ "granted",
163
+ "denied",
164
+ "not-determined",
165
+ "per-app"
166
+ ].includes(record[key]))) return {
167
+ status: "ready",
168
+ states: record
169
+ };
170
+ if (typeof record.error === "string") return {
171
+ status: "error",
172
+ error: record.error
173
+ };
174
+ }
175
+ return {
176
+ status: "error",
177
+ get error() {
178
+ return t("computerUse.ui.poDesktopDidNotReturnPermissionStates", "Po Desktop did not return permission states. Try again.");
179
+ }
180
+ };
181
+ } catch (error) {
182
+ return {
183
+ status: "error",
184
+ error: error instanceof Error ? error.message : String(error)
185
+ };
186
+ }
187
+ }
188
+ //#endregion
189
+ //#region src/extensions/(frontend)/setting/_components/DesktopPermissionsView.native.tsx
190
+ const COPY = {
191
+ accessibility: {
192
+ get title() {
193
+ return t("computerUse.ui.accessibility", "Accessibility");
194
+ },
195
+ get detail() {
196
+ return t("computerUse.ui.letsPoPressButtonsFillFieldsAnd", "Lets Po press buttons, fill fields and scroll in the app window you approve for computer use.");
197
+ }
198
+ },
199
+ "screen-recording": {
200
+ get title() {
201
+ return t("computerUse.ui.screenAndSystemAudioRecording", "Screen and system audio recording");
202
+ },
203
+ get detail() {
204
+ return t("computerUse.ui.letsPoSeeAndRecordTheWindow", "Lets Po see and record the window you approve, with its sound. macOS asks you to reopen Po after you allow it.");
205
+ }
206
+ },
207
+ microphone: {
208
+ get title() {
209
+ return t("computerUse.ui.microphone", "Microphone");
210
+ },
211
+ get detail() {
212
+ return t("computerUse.ui.letsYouTalkToPoAndAdds", "Lets you talk to Po, and adds your voice to computer-use recordings.");
213
+ }
214
+ },
215
+ automation: {
216
+ get title() {
217
+ return t("computerUse.ui.automation", "Automation");
218
+ },
219
+ get detail() {
220
+ return t("computerUse.ui.letsPoAndItsAgentsControlOther", "Lets Po and its agents control other apps, such as Finder or Mail. macOS asks once for each app; your answers are listed in System Settings.");
221
+ }
222
+ },
223
+ "full-disk-access": {
224
+ get title() {
225
+ return t("computerUse.ui.fullDiskAccess", "Full Disk Access");
226
+ },
227
+ get detail() {
228
+ return t("computerUse.ui.optionalLetsAgentsAndTheirToolsRead", "Optional. Lets agents and their tools read Documents, Downloads and Mail without a prompt for each folder.");
229
+ }
230
+ }
231
+ };
232
+ const LABEL = {
233
+ get granted() {
234
+ return t("computerUse.ui.allowed", "Allowed");
235
+ },
236
+ get denied() {
237
+ return t("computerUse.ui.notAllowed", "Not allowed");
238
+ },
239
+ get "not-determined"() {
240
+ return t("computerUse.ui.notAskedYet", "Not asked yet");
241
+ },
242
+ get "per-app"() {
243
+ return t("computerUse.ui.askedPerApp", "Asked per app");
244
+ }
245
+ };
246
+ function DesktopPermissionsView({ state, remote = true, onAsk, onRefresh }) {
247
+ const t = useT();
248
+ return /* @__PURE__ */ jsxs(View, {
249
+ style: styles$5.page,
250
+ children: [/* @__PURE__ */ jsxs(View, {
251
+ style: styles$5.sectionHead,
252
+ children: [/* @__PURE__ */ jsxs(View, {
253
+ style: styles$5.sectionText,
254
+ children: [/* @__PURE__ */ jsx(Text, {
255
+ accessibilityRole: "header",
256
+ style: styles$5.sectionTitle,
257
+ children: t("computerUse.ui.onThePairedMac", "On the paired Mac")
258
+ }), /* @__PURE__ */ jsx(Text, {
259
+ style: styles$5.detail,
260
+ children: remote ? t("computerUse.ui.theseBelongToTheMacRunningPo", "These belong to the Mac running Po Desktop. When you ask from here, macOS shows its prompt on that Mac.") : t("computerUse.ui.poAsksMacOSForEachOneWhen", "Po asks macOS for each one when you are ready. The permission prompt appears on the Mac running Po Desktop. You can change them any time in System Settings, Privacy and Security.")
261
+ })]
262
+ }), state.status === "ready" ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
263
+ variant: "ghost",
264
+ disabled: state.asking !== void 0,
265
+ accessibilityLabel: t("computerUse.ui.permissionsActionsForThePairedMac", "Permissions actions for the paired Mac"),
266
+ style: styles$5.control,
267
+ children: "⋯"
268
+ }), /* @__PURE__ */ jsx(DropdownMenuContent, { children: /* @__PURE__ */ jsx(DropdownMenuItem, {
269
+ onSelect: onRefresh,
270
+ children: t("computerUse.ui.checkAgain", "Check again")
271
+ }) })] }) : null]
272
+ }), /* @__PURE__ */ jsx(Panel, {
273
+ style: styles$5.card,
274
+ children: state.status === "ready" ? DESKTOP_PERMISSIONS.map((permission, index) => {
275
+ const value = state.states[permission];
276
+ const asking = state.asking === permission;
277
+ const action = asking ? t("computerUse.ui.waitingForMacOS", "Waiting for macOS") : value === "not-determined" ? t("computerUse.ui.allow", "Allow") : t("computerUse.ui.openSystemSettings", "Open System Settings");
278
+ return /* @__PURE__ */ jsxs(View, {
279
+ style: [styles$5.row, index > 0 && styles$5.divider],
280
+ children: [
281
+ /* @__PURE__ */ jsxs(View, {
282
+ style: styles$5.rowHeading,
283
+ children: [/* @__PURE__ */ jsx(Text, {
284
+ style: styles$5.rowTitle,
285
+ children: COPY[permission].title
286
+ }), /* @__PURE__ */ jsx(Badge, {
287
+ tone: value === "granted" ? "green" : "neutral",
288
+ children: LABEL[value]
289
+ })]
290
+ }),
291
+ /* @__PURE__ */ jsx(Text, {
292
+ style: styles$5.detail,
293
+ children: COPY[permission].detail
294
+ }),
295
+ value !== "granted" ? /* @__PURE__ */ jsx(Button, {
296
+ variant: "outline",
297
+ style: styles$5.control,
298
+ disabled: state.asking !== void 0,
299
+ accessibilityLabel: t("computerUse.ui.permissionAction", "{action}: {permission} on the paired Mac", {
300
+ action,
301
+ permission: COPY[permission].title
302
+ }),
303
+ onPress: () => onAsk(permission),
304
+ children: action
305
+ }) : null,
306
+ asking ? /* @__PURE__ */ jsx(Text, {
307
+ accessibilityLiveRegion: "polite",
308
+ style: styles$5.detail,
309
+ children: t("computerUse.ui.waitingForYourAnswerOnTheMac", "Waiting for your answer on the Mac.")
310
+ }) : null
311
+ ]
312
+ }, permission);
313
+ }) : /* @__PURE__ */ jsxs(View, {
314
+ style: styles$5.row,
315
+ children: [
316
+ /* @__PURE__ */ jsx(Text, {
317
+ accessibilityRole: state.status === "error" ? "alert" : "header",
318
+ style: styles$5.rowTitle,
319
+ children: state.status === "loading" ? t("computerUse.ui.checkingWithMacOS", "Checking with macOS") : state.status === "unavailable" ? t("computerUse.ui.poDesktopIsNotRunningHere", "Po Desktop is not running here") : t("computerUse.ui.poCouldnTReadThePermissionsJust", "Po couldn't read the permissions just now")
320
+ }),
321
+ /* @__PURE__ */ jsx(Text, {
322
+ style: styles$5.detail,
323
+ children: state.status === "loading" ? t("computerUse.ui.thisTakesAMoment", "This takes a moment.") : state.status === "unavailable" ? t("computerUse.ui.permissionsBelongToTheMacRunningPo", "Permissions belong to the Mac running Po Desktop. Open Po Desktop there to see and change them.") : state.error
324
+ }),
325
+ state.status === "error" ? /* @__PURE__ */ jsx(Button, {
326
+ variant: "outline",
327
+ style: styles$5.control,
328
+ accessibilityLabel: t("computerUse.ui.tryReadingPermissionsFromThePairedMac", "Try reading permissions from the paired Mac again"),
329
+ onPress: onRefresh,
330
+ children: t("computerUse.ui.tryAgain", "Try again")
331
+ }) : null
332
+ ]
333
+ })
334
+ })]
335
+ });
336
+ }
337
+ const styles$5 = StyleSheet.create((theme) => ({
338
+ page: {
339
+ gap: theme.spacing(5),
340
+ uni__dependencies: [0]
341
+ },
342
+ sectionHead: {
343
+ flexDirection: "row",
344
+ alignItems: "flex-start",
345
+ gap: theme.spacing(2),
346
+ uni__dependencies: [0]
347
+ },
348
+ sectionText: {
349
+ flex: 1,
350
+ minWidth: 0,
351
+ gap: theme.spacing(2),
352
+ uni__dependencies: [0]
353
+ },
354
+ sectionTitle: {
355
+ fontFamily: fontOf(theme.fontFamily.sans),
356
+ fontSize: theme.fontSize.lg,
357
+ lineHeight: theme.lineHeight.lg,
358
+ fontWeight: theme.fontWeight.semibold,
359
+ color: theme.colors.hi,
360
+ uni__dependencies: [0]
361
+ },
362
+ detail: {
363
+ fontFamily: fontOf(theme.fontFamily.sans),
364
+ fontSize: theme.fontSize.sm,
365
+ lineHeight: theme.lineHeightRelaxed.sm,
366
+ color: theme.colors.dim,
367
+ uni__dependencies: [0]
368
+ },
369
+ card: {
370
+ padding: 0,
371
+ overflow: "hidden"
372
+ },
373
+ row: {
374
+ padding: theme.spacing(4),
375
+ gap: theme.spacing(3),
376
+ uni__dependencies: [0]
377
+ },
378
+ rowHeading: {
379
+ flexDirection: "row",
380
+ flexWrap: "wrap",
381
+ alignItems: "center",
382
+ gap: theme.spacing(2),
383
+ uni__dependencies: [0]
384
+ },
385
+ rowTitle: {
386
+ fontFamily: fontOf(theme.fontFamily.sans),
387
+ fontSize: theme.fontSize.base,
388
+ lineHeight: theme.lineHeight.base,
389
+ fontWeight: theme.fontWeight.semibold,
390
+ color: theme.colors.hi,
391
+ flexShrink: 1,
392
+ uni__dependencies: [0]
393
+ },
394
+ divider: {
395
+ borderTopWidth: StyleSheet.hairlineWidth,
396
+ borderTopColor: theme.colors["border-soft"],
397
+ uni__dependencies: [0]
398
+ },
399
+ control: {
400
+ minHeight: 44,
401
+ minWidth: 44,
402
+ alignSelf: "flex-start"
403
+ }
404
+ }));
405
+ //#endregion
406
+ //#region src/extensions/(frontend)/setting/_components/DesktopPermissionsPanel.native.tsx
407
+ function DesktopPermissionsPanel({ request, requestWithStepUp }) {
408
+ const [state, setState] = useState({ status: "loading" });
409
+ const generation = useRef(0);
410
+ const busy = useRef(false);
411
+ const run = useCallback(async (permission) => {
412
+ if (busy.current) return;
413
+ busy.current = true;
414
+ const version = ++generation.current;
415
+ setState((current) => permission !== void 0 && current.status === "ready" ? {
416
+ ...current,
417
+ asking: permission
418
+ } : { status: "loading" });
419
+ const next = await readDesktopPermissions(permission === void 0 ? request : requestWithStepUp, permission);
420
+ if (generation.current !== version) return;
421
+ busy.current = false;
422
+ setState(next);
423
+ }, [request, requestWithStepUp]);
424
+ useEffect(() => {
425
+ run();
426
+ const subscription = AppState.addEventListener("change", (next) => {
427
+ if (next === "active") run();
428
+ });
429
+ return () => {
430
+ generation.current += 1;
431
+ busy.current = false;
432
+ subscription.remove();
433
+ };
434
+ }, [run]);
435
+ return /* @__PURE__ */ jsx(DesktopPermissionsView, {
436
+ state,
437
+ onAsk: (permission) => void run(permission),
438
+ onRefresh: () => void run()
439
+ });
440
+ }
441
+ //#endregion
442
+ //#region src/extensions/(frontend)/setting/desktop-permissions.panel.native.tsx
443
+ var desktop_permissions_panel_native_default = defineSettingsPanel({
444
+ get label() {
445
+ return t("computerUse.ui.permissions", "Permissions");
446
+ },
447
+ get detail() {
448
+ return t("computerUse.ui.whatPoMayDoOnThePaired", "What Po may do on the paired Mac");
449
+ },
450
+ order: 46,
451
+ component: DesktopPermissionsPanel
452
+ });
4
453
  //#endregion
5
454
  //#region src/extensions/workspaces/sessions/(frontend)/activity-group/computer-use.native.ts
6
- /** Computer control remains a desktop capability, including when its status is reported to a phone. */
455
+ /** Remote clients request control from the Desktop host through their session Activity. */
7
456
  var computer_use_native_default$1 = defineActivityGroup({
457
+ label: (t) => t("computerUse.activityGroup.label", "Computer use"),
8
458
  name: "computer-use",
9
459
  keys: "c e",
10
- order: 70,
11
- statusKey: "doom-computer-use",
460
+ statusKey: COMPUTER_USE_STATUS_KEY,
12
461
  hideWhenEmpty: true,
13
- desktopOnly: true,
14
462
  marksBackgroundWork: false
15
463
  });
16
464
  const computerUse = defineSessionStore({
@@ -38,6 +486,981 @@ const computerUseChannel = computerUse.channel({
38
486
  //#region src/extensions/workspaces/sessions/(frontend)/channel/computer-use.native.ts
39
487
  var computer_use_native_default = defineChannelFile(computerUseChannel);
40
488
  //#endregion
489
+ //#region src/extensions/workspaces/sessions/(frontend)/fill/_components/ComputerUsePanel.native.tsx
490
+ function remaining(ms) {
491
+ const seconds = Math.max(0, Math.ceil(ms / 1e3));
492
+ return t("computerUse.ui.remainingTime", "{time} left", { time: `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}` });
493
+ }
494
+ function ComputerUseView({ state, error, onCancel, onStop }) {
495
+ const t = useT();
496
+ const pending = state.phase === "awaiting_confirmation" || state.phase === "activating";
497
+ const active = state.phase === "active" || state.phase === "stopping";
498
+ const failure = error ?? state.failure?.message;
499
+ const expiresAt = state.phase === "active" ? state.expiresAt : void 0;
500
+ const [now, setNow] = useState(Date.now);
501
+ useEffect(() => {
502
+ if (expiresAt === void 0) return;
503
+ const timer = setInterval(() => setNow(Date.now()), 1e3);
504
+ return () => clearInterval(timer);
505
+ }, [expiresAt]);
506
+ const left = expiresAt === void 0 ? void 0 : expiresAt - now;
507
+ const total = state.durationMs ?? 3e5;
508
+ const controlled = state.target?.scope === "desktop" ? t("computerUse.ui.yourWholeDesktop", "your whole desktop") : typeof state.target?.applicationName === "string" ? state.target.applicationName : t("computerUse.ui.theChosenWindow", "the chosen window");
509
+ if (state.phase === "inactive") return null;
510
+ return /* @__PURE__ */ jsxs(View, {
511
+ style: styles$4.panel,
512
+ children: [
513
+ /* @__PURE__ */ jsx(View, {
514
+ style: styles$4.header,
515
+ children: /* @__PURE__ */ jsx(Text, {
516
+ style: styles$4.title,
517
+ accessibilityRole: "header",
518
+ children: t("computerUse.ui.computerUseText", "Computer use")
519
+ })
520
+ }),
521
+ failure ? /* @__PURE__ */ jsx(Text, {
522
+ style: styles$4.error,
523
+ accessibilityRole: "alert",
524
+ children: failure
525
+ }) : null,
526
+ state.artifact?.status === "ready" ? /* @__PURE__ */ jsxs(View, {
527
+ style: styles$4.row,
528
+ children: [/* @__PURE__ */ jsx(View, {
529
+ style: styles$4.check,
530
+ children: /* @__PURE__ */ jsx(CheckIcon, {
531
+ size: 12,
532
+ color: "rail"
533
+ })
534
+ }), /* @__PURE__ */ jsx(Text, {
535
+ style: styles$4.text,
536
+ children: t("computerUse.ui.recordingFinished", "Recording finished.")
537
+ })]
538
+ }) : null,
539
+ state.artifact?.failure ? /* @__PURE__ */ jsx(Text, {
540
+ style: styles$4.error,
541
+ children: state.artifact.failure.message
542
+ }) : null,
543
+ pending ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Text, {
544
+ style: styles$4.text,
545
+ children: t("computerUse.ui.desktopActivationIsPending", "Desktop activation is pending.")
546
+ }), /* @__PURE__ */ jsx(Button, {
547
+ variant: "outline",
548
+ onPress: onCancel,
549
+ children: t("computerUse.ui.cancelActivation", "Cancel activation")
550
+ })] }) : active ? /* @__PURE__ */ jsxs(Fragment, { children: [
551
+ /* @__PURE__ */ jsxs(View, {
552
+ style: styles$4.row,
553
+ accessibilityLiveRegion: "polite",
554
+ children: [/* @__PURE__ */ jsx(View, { style: styles$4.dot }), /* @__PURE__ */ jsx(Text, {
555
+ style: styles$4.live,
556
+ children: state.phase === "stopping" ? t("computerUse.ui.poIsHandingControlBack", "Po is handing control back") : t("computerUse.ui.controlling", "Po is controlling {target}", { target: controlled })
557
+ })]
558
+ }),
559
+ left === void 0 ? null : /* @__PURE__ */ jsxs(View, {
560
+ style: styles$4.row,
561
+ children: [/* @__PURE__ */ jsx(View, {
562
+ style: styles$4.track,
563
+ accessibilityRole: "progressbar",
564
+ accessibilityLabel: t("computerUse.ui.timeLeft", "Time left"),
565
+ accessibilityValue: {
566
+ min: 0,
567
+ max: total,
568
+ now: Math.max(0, left)
569
+ },
570
+ children: /* @__PURE__ */ jsx(View, { style: [styles$4.fill, { width: `${Math.min(100, Math.max(0, left / total * 100))}%` }] })
571
+ }), /* @__PURE__ */ jsx(Text, {
572
+ style: styles$4.detail,
573
+ children: remaining(left)
574
+ })]
575
+ }),
576
+ /* @__PURE__ */ jsx(Button, {
577
+ variant: "outline",
578
+ disabled: state.phase === "stopping",
579
+ onPress: onStop,
580
+ children: t("computerUse.ui.stopComputerUse", "Stop computer use")
581
+ })
582
+ ] }) : null
583
+ ]
584
+ });
585
+ }
586
+ function SessionPanel({ sessionId, sendSessionFrame }) {
587
+ const t = useT();
588
+ const subscribe = useCallback((listener) => {
589
+ const subscription = computerUse.store.subscribe(listener);
590
+ return () => subscription.unsubscribe();
591
+ }, []);
592
+ const session = useSyncExternalStore(subscribe, () => computerUse.select(computerUse.store.state, sessionId));
593
+ const [error, setError] = useState();
594
+ useEffect(() => {
595
+ sendSessionFrame(sessionId, {
596
+ type: computerUseChannelType,
597
+ payload: { action: "status" }
598
+ });
599
+ }, [sessionId, sendSessionFrame]);
600
+ const stop = (message) => {
601
+ setError(void 0);
602
+ try {
603
+ sendSessionFrame(sessionId, {
604
+ type: computerUseChannelType,
605
+ payload: { action: "stop" }
606
+ });
607
+ } catch {
608
+ setError(message);
609
+ }
610
+ };
611
+ return /* @__PURE__ */ jsx(ComputerUseView, {
612
+ state: session.state,
613
+ error,
614
+ onCancel: () => stop(t("computerUse.ui.theActivationCouldNotBeCancelled", "The activation could not be cancelled.")),
615
+ onStop: () => stop(t("computerUse.ui.theStopRequestIsUnavailable", "The stop request is unavailable."))
616
+ });
617
+ }
618
+ function ComputerUsePanel(props) {
619
+ const t = useT();
620
+ return props.sessionId === null ? /* @__PURE__ */ jsx(Text, {
621
+ style: styles$4.detail,
622
+ children: t("computerUse.ui.selectASession", "Select a session.")
623
+ }) : /* @__PURE__ */ jsx(SessionPanel, {
624
+ ...props,
625
+ sessionId: props.sessionId
626
+ }, props.sessionId);
627
+ }
628
+ const styles$4 = StyleSheet.create((theme) => ({
629
+ panel: {
630
+ gap: theme.spacing(3),
631
+ uni__dependencies: [0]
632
+ },
633
+ header: {
634
+ flexDirection: "row",
635
+ alignItems: "center",
636
+ gap: theme.spacing(2),
637
+ paddingBottom: theme.spacing(2),
638
+ borderBottomWidth: 1,
639
+ borderBottomColor: theme.colors["border-soft"],
640
+ uni__dependencies: [0]
641
+ },
642
+ title: {
643
+ flex: 1,
644
+ fontFamily: fontOf(theme.fontFamily.sans),
645
+ fontSize: theme.fontSize.base,
646
+ fontWeight: "600",
647
+ color: theme.colors.hi,
648
+ uni__dependencies: [0]
649
+ },
650
+ row: {
651
+ flexDirection: "row",
652
+ alignItems: "center",
653
+ gap: theme.spacing(2),
654
+ uni__dependencies: [0]
655
+ },
656
+ dot: {
657
+ width: 8,
658
+ height: 8,
659
+ borderRadius: 4,
660
+ backgroundColor: theme.colors.green,
661
+ uni__dependencies: [0]
662
+ },
663
+ live: {
664
+ fontFamily: fontOf(theme.fontFamily.sans),
665
+ fontSize: theme.fontSize.base,
666
+ lineHeight: theme.lineHeightRelaxed.base,
667
+ color: theme.colors.green,
668
+ uni__dependencies: [0]
669
+ },
670
+ track: {
671
+ flex: 1,
672
+ height: 6,
673
+ borderRadius: 3,
674
+ overflow: "hidden",
675
+ backgroundColor: theme.colors["border-soft"],
676
+ uni__dependencies: [0]
677
+ },
678
+ fill: {
679
+ height: "100%",
680
+ borderRadius: 3,
681
+ backgroundColor: theme.colors.green,
682
+ uni__dependencies: [0]
683
+ },
684
+ check: {
685
+ width: 20,
686
+ height: 20,
687
+ borderRadius: 10,
688
+ alignItems: "center",
689
+ justifyContent: "center",
690
+ backgroundColor: theme.colors.green,
691
+ uni__dependencies: [0]
692
+ },
693
+ text: {
694
+ fontFamily: fontOf(theme.fontFamily.sans),
695
+ fontSize: theme.fontSize.base,
696
+ lineHeight: theme.lineHeightRelaxed.base,
697
+ color: theme.colors.text,
698
+ uni__dependencies: [0]
699
+ },
700
+ detail: {
701
+ fontFamily: fontOf(theme.fontFamily.sans),
702
+ fontSize: theme.fontSize.sm,
703
+ lineHeight: theme.lineHeightRelaxed.sm,
704
+ color: theme.colors.dim,
705
+ uni__dependencies: [0]
706
+ },
707
+ error: {
708
+ fontFamily: fontOf(theme.fontFamily.sans),
709
+ fontSize: theme.fontSize.base,
710
+ lineHeight: theme.lineHeightRelaxed.base,
711
+ color: theme.colors.red,
712
+ uni__dependencies: [0]
713
+ }
714
+ }));
715
+ //#endregion
716
+ //#region src/extensions/workspaces/sessions/(frontend)/fill/ComputerUse.activity.computer-use.native.tsx
717
+ var ComputerUse_activity_computer_use_native_default = defineFill({
718
+ id: "computer-use",
719
+ slot: "activity.computer-use",
720
+ component: ComputerUsePanel
721
+ });
722
+ const MS_PER_SECOND = 1e3;
723
+ /**
724
+ * The computer_action call as its two pieces: the action kind first, the element
725
+ * it targets second. Either may be missing; the empty ones are dropped.
726
+ */
727
+ function computerActionCallParts(args) {
728
+ return [typeof args.kind === "string" ? args.kind : "", typeof args.elementRef === "string" ? args.elementRef : ""].filter(Boolean);
729
+ }
730
+ /** The computer_exec call's summary: the script it ran. */
731
+ function computerExecCallSummary(args) {
732
+ return typeof args.scriptPath === "string" ? args.scriptPath : "";
733
+ }
734
+ /**
735
+ * The script path as its folder and its file name, so a phone header can let the
736
+ * folder truncate while the script name stays whole.
737
+ */
738
+ function computerExecPathParts(path) {
739
+ const cut = path.lastIndexOf("/");
740
+ return cut < 0 ? {
741
+ folder: "",
742
+ name: path
743
+ } : {
744
+ folder: path.slice(0, cut + 1),
745
+ name: path.slice(cut + 1)
746
+ };
747
+ }
748
+ function record(value) {
749
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
750
+ }
751
+ const text = (value) => typeof value === "string" ? value : "";
752
+ const count = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
753
+ /** The result's text blocks joined; images (the screenshot) are dropped, as the web cards drop them. */
754
+ function computerResultText(content) {
755
+ return content.flatMap((block) => {
756
+ const entry = record(block);
757
+ return entry?.type === "text" && typeof entry.text === "string" ? [entry.text] : [];
758
+ }).join("\n");
759
+ }
760
+ /** `AXTextField` as `text field`; a role without the AX prefix is kept as it came. */
761
+ function computerRoleWords(role) {
762
+ if (!role.startsWith("AX")) return role;
763
+ return role.slice(2).replace(/([a-z])([A-Z])/gu, "$1 $2").toLowerCase();
764
+ }
765
+ function element(value) {
766
+ const entry = record(value);
767
+ if (entry === void 0 || typeof entry.ref !== "string") return [];
768
+ return [{
769
+ ref: entry.ref,
770
+ role: computerRoleWords(text(entry.role)),
771
+ label: text(entry.label) || text(entry.value),
772
+ enabled: entry.enabled !== false,
773
+ secure: entry.secure === true
774
+ }];
775
+ }
776
+ /** An observation when the value is one: an application name and an element list. */
777
+ function computerObservationView(value) {
778
+ const entry = record(value);
779
+ if (entry === void 0 || typeof entry.applicationName !== "string" || !Array.isArray(entry.elements)) return void 0;
780
+ const nextOffset = count(entry.nextOffset);
781
+ const artifact = text(entry.screenshotArtifact);
782
+ return {
783
+ applicationName: entry.applicationName,
784
+ windowTitle: text(entry.windowTitle),
785
+ elements: entry.elements.flatMap(element),
786
+ truncated: entry.truncated === true || nextOffset !== void 0,
787
+ ...nextOffset === void 0 ? {} : { nextOffset },
788
+ ...artifact.length > 0 ? { screenshotArtifact: artifact } : {}
789
+ };
790
+ }
791
+ /** One value of a script result as a short phrase: scalars as they read, collections by their size. */
792
+ function phrase(value) {
793
+ if (value === null || value === void 0) return "none";
794
+ if (typeof value === "string") return value;
795
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
796
+ if (Array.isArray(value)) return `${String(value.length)} item${value.length === 1 ? "" : "s"}`;
797
+ const size = Object.keys(value).length;
798
+ return `${String(size)} field${size === 1 ? "" : "s"}`;
799
+ }
800
+ /** A script's return value as fields: an object's own keys, or one `result` field for anything else. */
801
+ function computerResultFields(value) {
802
+ if (value === void 0) return [];
803
+ const entry = record(value);
804
+ if (entry === void 0) return [{
805
+ key: "result",
806
+ value: phrase(value)
807
+ }];
808
+ return Object.entries(entry).map(([key, field]) => ({
809
+ key,
810
+ value: phrase(field)
811
+ }));
812
+ }
813
+ function run(entry) {
814
+ if (!Array.isArray(entry.logs)) return void 0;
815
+ const observation = computerObservationView(entry.observation);
816
+ const metrics = record(entry.metrics);
817
+ const actions = count(metrics?.actions);
818
+ const observations = count(metrics?.observations);
819
+ const durationMs = count(metrics?.durationMs);
820
+ return {
821
+ fields: computerResultFields(entry.result),
822
+ logs: entry.logs.filter((line) => typeof line === "string"),
823
+ ...actions === void 0 ? {} : { actions },
824
+ ...observations === void 0 ? {} : { observations },
825
+ ...durationMs === void 0 ? {} : { duration: `${(durationMs / MS_PER_SECOND).toFixed(1)}s` },
826
+ ...observation === void 0 ? {} : { observation }
827
+ };
828
+ }
829
+ function failure(entry) {
830
+ if (typeof entry.error !== "string") return void 0;
831
+ const completedActions = count(entry.completedActions);
832
+ return {
833
+ reason: entry.error,
834
+ ...completedActions === void 0 ? {} : { completedActions },
835
+ outcomeUncertain: entry.outcomeUncertain === true
836
+ };
837
+ }
838
+ /** The text as lines a card can count: CRLF folded, tabs widened, trailing blank lines dropped. */
839
+ function lines(value) {
840
+ if (value.length === 0) return [];
841
+ const split = value.replaceAll("\r\n", "\n").replaceAll(" ", " ").split("\n");
842
+ while (split.length > 0 && split.at(-1)?.trim() === "") split.pop();
843
+ return split;
844
+ }
845
+ /**
846
+ * A computer tool result as the card lays it out. The tools answer in JSON (an
847
+ * observation, an action's outcome, a script run, a script failure) or in a
848
+ * plain sentence when they fail early; anything that does not parse as a shape
849
+ * the card knows falls back to its text lines.
850
+ */
851
+ function computerResultView(content) {
852
+ const raw = computerResultText(content);
853
+ let parsed;
854
+ try {
855
+ parsed = JSON.parse(raw);
856
+ } catch {
857
+ return {
858
+ kind: "text",
859
+ lines: lines(raw)
860
+ };
861
+ }
862
+ const entry = record(parsed);
863
+ const observation = computerObservationView(parsed);
864
+ if (observation !== void 0) return {
865
+ kind: "observation",
866
+ observation
867
+ };
868
+ const ran = entry === void 0 ? void 0 : run(entry);
869
+ if (ran !== void 0) return {
870
+ kind: "run",
871
+ run: ran
872
+ };
873
+ const failed = entry === void 0 ? void 0 : failure(entry);
874
+ if (failed !== void 0) return {
875
+ kind: "failure",
876
+ failure: failed
877
+ };
878
+ if (entry?.launched === true && typeof entry.applicationName === "string") return {
879
+ kind: "launched",
880
+ applicationName: entry.applicationName,
881
+ bundleId: text(entry.bundleId)
882
+ };
883
+ if (entry?.applied === true) return { kind: "applied" };
884
+ return {
885
+ kind: "text",
886
+ lines: lines(raw)
887
+ };
888
+ }
889
+ /** How many rows the view holds back while collapsed, so the card offers expand only when it reveals something. */
890
+ function computerResultHidden(view) {
891
+ switch (view.kind) {
892
+ case "observation": return Math.max(0, view.observation.elements.length - 5);
893
+ case "run": return Math.max(0, view.run.logs.length - 3);
894
+ case "text": return Math.max(0, view.lines.length - 8);
895
+ default: return 0;
896
+ }
897
+ }
898
+ //#endregion
899
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/ComputerResultBody.native.tsx
900
+ /** The parsed result, or none before the tool answers. */
901
+ function computerResult(props) {
902
+ return props.result === null ? void 0 : computerResultView(props.result.content);
903
+ }
904
+ /** Whether the card has rows to reveal: the header offers expand only then, and never on a failure. */
905
+ function computerResultExpandable(props) {
906
+ const view = computerResult(props);
907
+ return !props.isError && view !== void 0 && computerResultHidden(view) > 0;
908
+ }
909
+ /**
910
+ * The body the three computer tool cards share on native. The web cards print
911
+ * the result's text; the tools answer in JSON, so this lays the parsed result
912
+ * out instead: the window and its elements, a script's figures and logs, an
913
+ * action's outcome. A preview shows while collapsed, as the web's first lines
914
+ * do. A failure shows only its reason in red, with a quiet note of any actions
915
+ * that already ran; the header's edge and outcome already say it failed.
916
+ */
917
+ function ComputerResultBody({ props, expanded }) {
918
+ const t = useT();
919
+ const { toolName, output, running, isError } = props;
920
+ const view = computerResult(props);
921
+ const testID = `tool-result-${toolName}`;
922
+ if (isError) {
923
+ const failure = view?.kind === "failure" ? view.failure : {
924
+ reason: view?.kind === "text" ? view.lines.join("\n") : output.trim(),
925
+ outcomeUncertain: false
926
+ };
927
+ return failure.reason.length === 0 ? null : /* @__PURE__ */ jsx(MessageItemBody, {
928
+ testID,
929
+ children: /* @__PURE__ */ jsx(FailureBlock, { failure })
930
+ });
931
+ }
932
+ if (view === void 0) return running ? /* @__PURE__ */ jsx(MessageItemBody, {
933
+ testID,
934
+ children: /* @__PURE__ */ jsx(MessageItemStatus, {
935
+ tone: "running",
936
+ children: t("computerUse.ui.running", "running")
937
+ })
938
+ }) : null;
939
+ if (view.kind === "text" && view.lines.length === 0) return null;
940
+ return /* @__PURE__ */ jsx(MessageItemBody, {
941
+ testID,
942
+ children: /* @__PURE__ */ jsxs(View, {
943
+ style: styles$3.stack,
944
+ children: [
945
+ view.kind === "observation" ? /* @__PURE__ */ jsx(ObservationBlock, {
946
+ observation: view.observation,
947
+ expanded
948
+ }) : null,
949
+ view.kind === "run" ? /* @__PURE__ */ jsx(RunBlock, {
950
+ run: view.run,
951
+ expanded
952
+ }) : null,
953
+ view.kind === "applied" ? /* @__PURE__ */ jsx(Text, {
954
+ style: [styles$3.sans, styles$3.text],
955
+ children: t("computerUse.ui.appliedToTheElement", "Applied to the element.")
956
+ }) : null,
957
+ view.kind === "launched" ? /* @__PURE__ */ jsxs(View, {
958
+ style: styles$3.figure,
959
+ children: [/* @__PURE__ */ jsxs(Text, {
960
+ numberOfLines: 1,
961
+ style: [
962
+ styles$3.sans,
963
+ styles$3.strong,
964
+ styles$3.keep
965
+ ],
966
+ children: [
967
+ t("computerUse.ui.opened", "Opened"),
968
+ " ",
969
+ view.applicationName
970
+ ]
971
+ }), /* @__PURE__ */ jsx(Text, {
972
+ numberOfLines: 1,
973
+ style: [
974
+ styles$3.mono,
975
+ styles$3.faint,
976
+ styles$3.yield
977
+ ],
978
+ children: view.bundleId
979
+ })]
980
+ }) : null,
981
+ view.kind === "text" ? /* @__PURE__ */ jsx(TextLines, {
982
+ lines: view.lines,
983
+ expanded
984
+ }) : null,
985
+ running ? /* @__PURE__ */ jsx(MessageItemStatus, {
986
+ tone: "running",
987
+ children: t("computerUse.ui.running", "running")
988
+ }) : null
989
+ ]
990
+ })
991
+ });
992
+ }
993
+ function FailureBlock({ failure }) {
994
+ const t = useT();
995
+ const done = failure.completedActions;
996
+ const note = [done === void 0 ? "" : done === 1 ? t("computerUse.ui.actionsRanOne", "{count} action already ran", { count: done }) : t("computerUse.ui.actionsRan", "{count} actions already ran", { count: done }), failure.outcomeUncertain ? t("computerUse.ui.theLastOutcomeIsUncertain", "the last outcome is uncertain") : ""].filter(Boolean);
997
+ return /* @__PURE__ */ jsxs(View, {
998
+ style: styles$3.stack,
999
+ children: [/* @__PURE__ */ jsx(Text, {
1000
+ selectable: true,
1001
+ style: [styles$3.sans, styles$3.error],
1002
+ children: failure.reason
1003
+ }), note.length > 0 ? /* @__PURE__ */ jsxs(Text, {
1004
+ style: [styles$3.small, styles$3.faint],
1005
+ children: [note.join(", "), "."]
1006
+ }) : null]
1007
+ });
1008
+ }
1009
+ function WindowLine({ observation, lead }) {
1010
+ return /* @__PURE__ */ jsxs(View, {
1011
+ style: styles$3.figure,
1012
+ children: [/* @__PURE__ */ jsxs(Text, {
1013
+ numberOfLines: 1,
1014
+ style: [
1015
+ styles$3.sans,
1016
+ styles$3.strong,
1017
+ styles$3.keep
1018
+ ],
1019
+ children: [lead === void 0 ? "" : `${lead} `, observation.applicationName]
1020
+ }), observation.windowTitle.length > 0 ? /* @__PURE__ */ jsx(Text, {
1021
+ numberOfLines: 1,
1022
+ style: [
1023
+ styles$3.sans,
1024
+ styles$3.dim,
1025
+ styles$3.yield
1026
+ ],
1027
+ children: observation.windowTitle
1028
+ }) : null]
1029
+ });
1030
+ }
1031
+ function ElementRow({ element }) {
1032
+ const t = useT();
1033
+ const secure = element.secure && !element.role.includes("secure");
1034
+ const traits = [
1035
+ element.role,
1036
+ element.enabled ? "" : t("computerUse.ui.disabled", "disabled"),
1037
+ secure ? t("computerUse.ui.secure", "secure") : ""
1038
+ ].filter(Boolean);
1039
+ return /* @__PURE__ */ jsxs(View, {
1040
+ style: styles$3.row,
1041
+ accessibilityLabel: `${element.label} ${traits.join(" ")} ${element.ref}`,
1042
+ children: [
1043
+ /* @__PURE__ */ jsx(Text, {
1044
+ numberOfLines: 1,
1045
+ style: [
1046
+ styles$3.sans,
1047
+ element.enabled ? styles$3.text : styles$3.faint,
1048
+ styles$3.yield
1049
+ ],
1050
+ children: element.label.length > 0 ? element.label : element.role
1051
+ }),
1052
+ /* @__PURE__ */ jsx(Text, {
1053
+ numberOfLines: 1,
1054
+ style: [
1055
+ styles$3.small,
1056
+ styles$3.faint,
1057
+ styles$3.keep
1058
+ ],
1059
+ children: traits.join(" · ")
1060
+ }),
1061
+ /* @__PURE__ */ jsx(Text, {
1062
+ numberOfLines: 1,
1063
+ style: [
1064
+ styles$3.mono,
1065
+ styles$3.faint,
1066
+ styles$3.ref
1067
+ ],
1068
+ children: element.ref
1069
+ })
1070
+ ]
1071
+ });
1072
+ }
1073
+ function ObservationBlock({ observation, expanded }) {
1074
+ const t = useT();
1075
+ const { elements } = observation;
1076
+ const shown = expanded ? elements : elements.slice(0, 5);
1077
+ const hidden = elements.length - shown.length;
1078
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1079
+ /* @__PURE__ */ jsx(WindowLine, { observation }),
1080
+ /* @__PURE__ */ jsxs(View, {
1081
+ style: styles$3.chips,
1082
+ children: [/* @__PURE__ */ jsx(Badge, {
1083
+ size: "xs",
1084
+ children: elements.length === 1 ? t("computerUse.ui.elementCountOne", "{count} element", { count: elements.length }) : t("computerUse.ui.elementCount", "{count} elements", { count: elements.length })
1085
+ }), observation.truncated ? /* @__PURE__ */ jsx(Badge, {
1086
+ size: "xs",
1087
+ tone: "yellow",
1088
+ children: observation.nextOffset === void 0 ? t("computerUse.ui.moreNotShown", "more not shown") : t("computerUse.ui.moreFromOffset", "more from offset {offset}", { offset: observation.nextOffset })
1089
+ }) : null]
1090
+ }),
1091
+ shown.length > 0 ? /* @__PURE__ */ jsx(View, {
1092
+ style: styles$3.list,
1093
+ children: shown.map((element) => /* @__PURE__ */ jsx(ElementRow, { element }, element.ref))
1094
+ }) : null,
1095
+ hidden > 0 ? /* @__PURE__ */ jsx(MessageItemStatus, {
1096
+ expands: true,
1097
+ children: hidden === 1 ? t("computerUse.ui.moreElementsOne", "{count} more element", { count: hidden }) : t("computerUse.ui.moreElements", "{count} more elements", { count: hidden })
1098
+ }) : null,
1099
+ observation.screenshotArtifact === void 0 ? null : /* @__PURE__ */ jsx(Text, {
1100
+ numberOfLines: 2,
1101
+ style: [styles$3.small, styles$3.faint],
1102
+ children: t("computerUse.ui.screenshotSaved", "Screenshot saved to {path}", { path: observation.screenshotArtifact })
1103
+ })
1104
+ ] });
1105
+ }
1106
+ function RunBlock({ run, expanded }) {
1107
+ const t = useT();
1108
+ const figures = [
1109
+ run.actions === void 0 ? "" : run.actions === 1 ? t("computerUse.ui.actionCountOne", "{count} action", { count: run.actions }) : t("computerUse.ui.actionCount", "{count} actions", { count: run.actions }),
1110
+ run.observations === void 0 ? "" : run.observations === 1 ? t("computerUse.ui.observationCountOne", "{count} observation", { count: run.observations }) : t("computerUse.ui.observationCount", "{count} observations", { count: run.observations }),
1111
+ run.duration ?? ""
1112
+ ].filter(Boolean);
1113
+ const logs = expanded ? run.logs : run.logs.slice(0, 3);
1114
+ const hidden = run.logs.length - logs.length;
1115
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1116
+ figures.length > 0 ? /* @__PURE__ */ jsx(View, {
1117
+ style: styles$3.chips,
1118
+ children: figures.map((figure) => /* @__PURE__ */ jsx(Badge, {
1119
+ size: "xs",
1120
+ children: figure
1121
+ }, figure))
1122
+ }) : null,
1123
+ run.fields.length > 0 ? /* @__PURE__ */ jsx(View, {
1124
+ style: styles$3.list,
1125
+ children: run.fields.map((field) => /* @__PURE__ */ jsxs(View, {
1126
+ style: styles$3.row,
1127
+ children: [/* @__PURE__ */ jsx(Text, {
1128
+ numberOfLines: 1,
1129
+ style: [
1130
+ styles$3.small,
1131
+ styles$3.faint,
1132
+ styles$3.key
1133
+ ],
1134
+ children: field.key
1135
+ }), /* @__PURE__ */ jsx(Text, {
1136
+ numberOfLines: 1,
1137
+ selectable: true,
1138
+ style: [
1139
+ styles$3.sans,
1140
+ styles$3.text,
1141
+ styles$3.yield
1142
+ ],
1143
+ children: field.value
1144
+ })]
1145
+ }, field.key))
1146
+ }) : null,
1147
+ logs.length > 0 ? /* @__PURE__ */ jsx(View, {
1148
+ style: styles$3.list,
1149
+ children: logs.map((line, index) => /* @__PURE__ */ jsx(Text, {
1150
+ numberOfLines: 1,
1151
+ selectable: true,
1152
+ style: [styles$3.mono, styles$3.dim],
1153
+ children: line
1154
+ }, `${String(index)}-${line}`))
1155
+ }) : null,
1156
+ hidden > 0 ? /* @__PURE__ */ jsx(MessageItemStatus, {
1157
+ expands: true,
1158
+ children: hidden === 1 ? t("computerUse.ui.moreLogLinesOne", "{count} more log line", { count: hidden }) : t("computerUse.ui.moreLogLines", "{count} more log lines", { count: hidden })
1159
+ }) : null,
1160
+ run.observation === void 0 ? null : /* @__PURE__ */ jsx(WindowLine, {
1161
+ observation: run.observation,
1162
+ lead: t("computerUse.ui.endedOn", "Ended on")
1163
+ })
1164
+ ] });
1165
+ }
1166
+ function TextLines({ lines, expanded }) {
1167
+ const t = useT();
1168
+ const shown = expanded ? lines : lines.slice(0, 8);
1169
+ const hidden = lines.length - shown.length;
1170
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(View, {
1171
+ style: styles$3.list,
1172
+ children: shown.map((line, index) => /* @__PURE__ */ jsx(Text, {
1173
+ selectable: true,
1174
+ style: [styles$3.sans, styles$3.dim],
1175
+ children: line
1176
+ }, `${String(index)}-${line}`))
1177
+ }), hidden > 0 ? /* @__PURE__ */ jsx(MessageItemStatus, {
1178
+ expands: true,
1179
+ children: hidden === 1 ? t("computerUse.ui.moreLinesOne", "{count} more line", { count: hidden }) : t("computerUse.ui.moreLines", "{count} more lines", { count: hidden })
1180
+ }) : null] });
1181
+ }
1182
+ const styles$3 = StyleSheet.create((theme) => ({
1183
+ stack: {
1184
+ gap: theme.spacing(2),
1185
+ uni__dependencies: [0]
1186
+ },
1187
+ list: {
1188
+ gap: theme.spacing(1),
1189
+ uni__dependencies: [0]
1190
+ },
1191
+ chips: {
1192
+ flexDirection: "row",
1193
+ flexWrap: "wrap",
1194
+ gap: theme.spacing(1.5),
1195
+ uni__dependencies: [0]
1196
+ },
1197
+ figure: {
1198
+ flexDirection: "row",
1199
+ alignItems: "baseline",
1200
+ gap: theme.spacing(2),
1201
+ minWidth: 0,
1202
+ uni__dependencies: [0]
1203
+ },
1204
+ row: {
1205
+ flexDirection: "row",
1206
+ alignItems: "baseline",
1207
+ gap: theme.spacing(2),
1208
+ minWidth: 0,
1209
+ uni__dependencies: [0]
1210
+ },
1211
+ sans: {
1212
+ fontFamily: fontOf(theme.fontFamily.sans),
1213
+ fontSize: theme.fontSize.base,
1214
+ lineHeight: theme.lineHeight.base,
1215
+ uni__dependencies: [0]
1216
+ },
1217
+ small: {
1218
+ fontFamily: fontOf(theme.fontFamily.sans),
1219
+ fontSize: theme.fontSize.sm,
1220
+ lineHeight: theme.lineHeight.sm,
1221
+ uni__dependencies: [0]
1222
+ },
1223
+ mono: {
1224
+ fontFamily: fontOf(theme.fontFamily.mono),
1225
+ fontSize: theme.fontSize.sm,
1226
+ lineHeight: theme.lineHeight.sm,
1227
+ uni__dependencies: [0]
1228
+ },
1229
+ strong: {
1230
+ color: theme.colors.text,
1231
+ fontWeight: theme.fontWeight.semibold,
1232
+ uni__dependencies: [0]
1233
+ },
1234
+ text: {
1235
+ color: theme.colors.text,
1236
+ uni__dependencies: [0]
1237
+ },
1238
+ dim: {
1239
+ color: theme.colors.dim,
1240
+ uni__dependencies: [0]
1241
+ },
1242
+ faint: {
1243
+ color: theme.colors.faint,
1244
+ uni__dependencies: [0]
1245
+ },
1246
+ error: {
1247
+ color: theme.colors.red,
1248
+ uni__dependencies: [0]
1249
+ },
1250
+ keep: {
1251
+ flexShrink: 0,
1252
+ maxWidth: "60%"
1253
+ },
1254
+ yield: {
1255
+ flexShrink: 1,
1256
+ minWidth: 0
1257
+ },
1258
+ key: {
1259
+ flexShrink: 0,
1260
+ maxWidth: "40%"
1261
+ },
1262
+ ref: {
1263
+ flexShrink: 0,
1264
+ marginLeft: "auto"
1265
+ }
1266
+ }));
1267
+ //#endregion
1268
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/ComputerActionToolCard.native.tsx
1269
+ /**
1270
+ * The computer_action tool's timeline item on native, as the web's: the action
1271
+ * and the element it targets in the header, the outcome's first lines beneath.
1272
+ */
1273
+ function ComputerActionToolCard(props) {
1274
+ const { toolName, args, running, isError } = props;
1275
+ const [kind, ...target] = computerActionCallParts(args);
1276
+ return /* @__PURE__ */ jsx(MessageItem, {
1277
+ tone: toolTone({
1278
+ running,
1279
+ isError
1280
+ }),
1281
+ expandable: computerResultExpandable(props),
1282
+ children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MessageItemHeader, {
1283
+ title: toolName,
1284
+ children: /* @__PURE__ */ jsxs(View, {
1285
+ testID: `tool-call-${toolName}`,
1286
+ style: styles$2.summary,
1287
+ children: [kind === void 0 ? null : /* @__PURE__ */ jsx(Text, {
1288
+ numberOfLines: 1,
1289
+ style: [styles$2.sans, styles$2.primary],
1290
+ children: kind
1291
+ }), target.length > 0 ? /* @__PURE__ */ jsx(Text, {
1292
+ numberOfLines: 1,
1293
+ style: [styles$2.sans, styles$2.detail],
1294
+ children: target.join(" ")
1295
+ }) : null]
1296
+ })
1297
+ }), /* @__PURE__ */ jsx(ComputerResultBody, {
1298
+ props,
1299
+ expanded
1300
+ })] })
1301
+ });
1302
+ }
1303
+ const styles$2 = StyleSheet.create((theme) => ({
1304
+ summary: {
1305
+ flex: 1,
1306
+ flexDirection: "row",
1307
+ alignItems: "center",
1308
+ gap: theme.spacing(2),
1309
+ minWidth: 0,
1310
+ uni__dependencies: [0]
1311
+ },
1312
+ sans: {
1313
+ fontFamily: fontOf(theme.fontFamily.sans),
1314
+ fontSize: theme.fontSize.base,
1315
+ lineHeight: theme.lineHeight.base,
1316
+ uni__dependencies: [0]
1317
+ },
1318
+ primary: {
1319
+ flexShrink: 0,
1320
+ maxWidth: "45%",
1321
+ color: theme.colors.text,
1322
+ uni__dependencies: [0]
1323
+ },
1324
+ detail: {
1325
+ flexShrink: 1,
1326
+ color: theme.colors.dim,
1327
+ uni__dependencies: [0]
1328
+ }
1329
+ }));
1330
+ //#endregion
1331
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/computer-action.native.tsx
1332
+ var computer_action_native_default = defineToolRenderer({
1333
+ tools: ["computer_action"],
1334
+ message: ComputerActionToolCard
1335
+ });
1336
+ //#endregion
1337
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/ComputerExecToolCard.native.tsx
1338
+ /**
1339
+ * The computer_exec tool's timeline item on native, as the web's: the script
1340
+ * path in the header, the run's first lines beneath it.
1341
+ */
1342
+ function ComputerExecToolCard(props) {
1343
+ const { toolName, args, running, isError } = props;
1344
+ const path = computerExecPathParts(computerExecCallSummary(args));
1345
+ return /* @__PURE__ */ jsx(MessageItem, {
1346
+ tone: toolTone({
1347
+ running,
1348
+ isError
1349
+ }),
1350
+ expandable: computerResultExpandable(props),
1351
+ children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MessageItemHeader, {
1352
+ title: toolName,
1353
+ children: /* @__PURE__ */ jsxs(View, {
1354
+ testID: `tool-call-${toolName}`,
1355
+ style: styles$1.summary,
1356
+ children: [path.folder.length > 0 ? /* @__PURE__ */ jsx(Text, {
1357
+ numberOfLines: 1,
1358
+ style: [styles$1.sans, styles$1.folder],
1359
+ children: path.folder
1360
+ }) : null, /* @__PURE__ */ jsx(Text, {
1361
+ numberOfLines: 1,
1362
+ style: [styles$1.sans, styles$1.primary],
1363
+ children: path.name
1364
+ })]
1365
+ })
1366
+ }), /* @__PURE__ */ jsx(ComputerResultBody, {
1367
+ props,
1368
+ expanded
1369
+ })] })
1370
+ });
1371
+ }
1372
+ const styles$1 = StyleSheet.create((theme) => ({
1373
+ summary: {
1374
+ flex: 1,
1375
+ flexDirection: "row",
1376
+ alignItems: "center",
1377
+ minWidth: 0
1378
+ },
1379
+ sans: {
1380
+ fontFamily: fontOf(theme.fontFamily.sans),
1381
+ fontSize: theme.fontSize.base,
1382
+ lineHeight: theme.lineHeight.base,
1383
+ uni__dependencies: [0]
1384
+ },
1385
+ folder: {
1386
+ flexShrink: 1,
1387
+ minWidth: 0,
1388
+ color: theme.colors.dim,
1389
+ uni__dependencies: [0]
1390
+ },
1391
+ primary: {
1392
+ flexShrink: 0,
1393
+ maxWidth: "100%",
1394
+ color: theme.colors.text,
1395
+ uni__dependencies: [0]
1396
+ }
1397
+ }));
1398
+ //#endregion
1399
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/computer-exec.native.tsx
1400
+ var computer_exec_native_default = defineToolRenderer({
1401
+ tools: ["computer_exec"],
1402
+ message: ComputerExecToolCard
1403
+ });
1404
+ //#endregion
1405
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/ComputerStateToolCard.native.tsx
1406
+ /**
1407
+ * The computer_state tool's timeline item on native, as the web's: the observed
1408
+ * window in the header, the observation's first lines beneath it.
1409
+ */
1410
+ function ComputerStateToolCard(props) {
1411
+ const t = useT();
1412
+ const { toolName, running, isError } = props;
1413
+ return /* @__PURE__ */ jsx(MessageItem, {
1414
+ tone: toolTone({
1415
+ running,
1416
+ isError
1417
+ }),
1418
+ expandable: computerResultExpandable(props),
1419
+ children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MessageItemHeader, {
1420
+ title: toolName,
1421
+ children: /* @__PURE__ */ jsx(View, {
1422
+ testID: `tool-call-${toolName}`,
1423
+ style: styles.summary,
1424
+ children: /* @__PURE__ */ jsx(Text, {
1425
+ numberOfLines: 1,
1426
+ style: [styles.sans, styles.primary],
1427
+ children: t("computerUse.ui.authorizedWindow", "authorized window")
1428
+ })
1429
+ })
1430
+ }), /* @__PURE__ */ jsx(ComputerResultBody, {
1431
+ props,
1432
+ expanded
1433
+ })] })
1434
+ });
1435
+ }
1436
+ const styles = StyleSheet.create((theme) => ({
1437
+ summary: {
1438
+ flex: 1,
1439
+ flexDirection: "row",
1440
+ alignItems: "center",
1441
+ gap: theme.spacing(2),
1442
+ minWidth: 0,
1443
+ uni__dependencies: [0]
1444
+ },
1445
+ sans: {
1446
+ fontFamily: fontOf(theme.fontFamily.sans),
1447
+ fontSize: theme.fontSize.base,
1448
+ lineHeight: theme.lineHeight.base,
1449
+ uni__dependencies: [0]
1450
+ },
1451
+ primary: {
1452
+ flexShrink: 1,
1453
+ color: theme.colors.text,
1454
+ uni__dependencies: [0]
1455
+ }
1456
+ }));
1457
+ //#endregion
1458
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/computer-state.native.tsx
1459
+ var computer_state_native_default = defineToolRenderer({
1460
+ tools: ["computer_state"],
1461
+ message: ComputerStateToolCard
1462
+ });
1463
+ //#endregion
41
1464
  //#region generated/native.ts
42
1465
  const via = (identity, value) => value === void 0 ? void 0 : {
43
1466
  ...identity,
@@ -45,12 +1468,29 @@ const via = (identity, value) => value === void 0 ? void 0 : {
45
1468
  };
46
1469
  const nativePlugin = defineNativePlugin({
47
1470
  id: "computer-use",
1471
+ packageName: "@agimon-ai/po-computer-use",
1472
+ host: { get settingsPanels() {
1473
+ return [via({ id: "desktop-permissions" }, desktop_permissions_panel_native_default)];
1474
+ } },
48
1475
  session: {
49
1476
  get activityGroups() {
50
1477
  return [via({ name: "computer-use" }, computer_use_native_default$1)];
51
1478
  },
52
1479
  get channels() {
53
1480
  return [via({ channel: "computer_use" }, computer_use_native_default)];
1481
+ },
1482
+ get fills() {
1483
+ return [via({
1484
+ slot: "activity.computer-use",
1485
+ id: "computer-use"
1486
+ }, ComputerUse_activity_computer_use_native_default)];
1487
+ },
1488
+ get toolRenderers() {
1489
+ return [
1490
+ via({ tools: ["computer_action"] }, computer_action_native_default),
1491
+ via({ tools: ["computer_exec"] }, computer_exec_native_default),
1492
+ via({ tools: ["computer_state"] }, computer_state_native_default)
1493
+ ];
54
1494
  }
55
1495
  }
56
1496
  });