@agimon-ai/po-computer-use 0.0.0-alpha.21 → 0.0.0-alpha.210

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 (49) hide show
  1. package/LICENSE +110 -149
  2. package/README.md +9 -8
  3. package/dist/apiContracts.cjs +65 -45
  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 +65 -45
  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 +13 -5
  16. package/dist/extensions/mcp.cjs.map +1 -1
  17. package/dist/extensions/mcp.d.mts.map +1 -1
  18. package/dist/extensions/mcp.mjs +13 -5
  19. package/dist/extensions/mcp.mjs.map +1 -1
  20. package/dist/extensions/native.mjs +1493 -8
  21. package/dist/extensions/native.mjs.map +1 -1
  22. package/dist/extensions/server.cjs +1035 -645
  23. package/dist/extensions/server.cjs.map +1 -1
  24. package/dist/extensions/server.d.mts.map +1 -1
  25. package/dist/extensions/server.mjs +1020 -630
  26. package/dist/extensions/server.mjs.map +1 -1
  27. package/dist/extensions/web.mjs +1004 -480
  28. package/dist/extensions/web.mjs.map +1 -1
  29. package/dist/index.cjs +14 -5
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.mts +67 -10
  32. package/dist/index.d.mts.map +1 -1
  33. package/dist/index.mjs +14 -5
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/po-runtime-identity.json +1 -0
  36. package/docs/computer-scripts.md +1 -1
  37. package/docs/remote-computer-use.md +11 -0
  38. package/llms.txt +1 -1
  39. package/locales/vi.json +153 -0
  40. package/locales/zh-CN.json +153 -0
  41. package/package.json +84 -24
  42. package/src/prompts/codemode-how-to-computer-use/SKILL.md +83 -0
  43. package/src/types/computerUse.ts +72 -7
  44. package/src/types/computerUseApi.ts +24 -5
  45. package/dist/extensionService-Bp0q295i.cjs +0 -504
  46. package/dist/extensionService-Bp0q295i.cjs.map +0 -1
  47. package/dist/extensionService-DXvF7esO.mjs +0 -434
  48. package/dist/extensionService-DXvF7esO.mjs.map +0 -1
  49. 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: "po-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,19 +486,1056 @@ 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
+ //#endregion
723
+ //#region src/extensions/workspaces/sessions/(frontend)/fill/Computeruse.help.guides.native.ts
724
+ var Computeruse_help_guides_native_default = defineFill({
725
+ slot: "help.guides",
726
+ id: "Computeruse",
727
+ order: 280,
728
+ data: {
729
+ version: 1,
730
+ category: "tools",
731
+ labelKey: "computerUse.guides.computerUse",
732
+ label: "Computer use",
733
+ guides: [{
734
+ id: "about",
735
+ questionKey: "computerUse.guides.whatCanComputerUseDoForMe",
736
+ question: "What can computer use do for me?",
737
+ order: 0,
738
+ answerKey: "computerUse.guides.computerUseLetsPoControlAnApprovedWindowOrTheWholeDesktopOnASupportedMacOSPoDesktopYouChooseTheScopeAndDuration",
739
+ answer: "Computer use lets Po control an approved window or the whole desktop on a supported macOS Po Desktop. You choose the scope and duration.",
740
+ keywords: ["desktop", "permissions"]
741
+ }, {
742
+ id: "use",
743
+ questionKey: "computerUse.guides.howDoIStartAndStopComputerUse",
744
+ question: "How do I start and stop computer use?",
745
+ order: 1,
746
+ answerKey: "computerUse.guides.enableComputerUseInHostSettingsSelectComputerUseModeThenApprovePoSRequestStopInActivityOrPressCmdShiftEscOnMacOS",
747
+ answer: "Enable Computer Use in host settings, select Computer Use mode, then approve Po's request. Stop in Activity or press Cmd+Shift+Esc on macOS.",
748
+ keywords: ["stop", "approval"]
749
+ }]
750
+ }
751
+ });
752
+ const MS_PER_SECOND = 1e3;
753
+ /**
754
+ * The computer_action call as its two pieces: the action kind first, the element
755
+ * it targets second. Either may be missing; the empty ones are dropped.
756
+ */
757
+ function computerActionCallParts(args) {
758
+ return [typeof args.kind === "string" ? args.kind : "", typeof args.elementRef === "string" ? args.elementRef : ""].filter(Boolean);
759
+ }
760
+ /** The computer_exec call's summary: the script it ran. */
761
+ function computerExecCallSummary(args) {
762
+ return typeof args.scriptPath === "string" ? args.scriptPath : "";
763
+ }
764
+ /**
765
+ * The script path as its folder and its file name, so a phone header can let the
766
+ * folder truncate while the script name stays whole.
767
+ */
768
+ function computerExecPathParts(path) {
769
+ const cut = path.lastIndexOf("/");
770
+ return cut < 0 ? {
771
+ folder: "",
772
+ name: path
773
+ } : {
774
+ folder: path.slice(0, cut + 1),
775
+ name: path.slice(cut + 1)
776
+ };
777
+ }
778
+ function record(value) {
779
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
780
+ }
781
+ const text = (value) => typeof value === "string" ? value : "";
782
+ const count = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
783
+ /** The result's text blocks joined; images (the screenshot) are dropped, as the web cards drop them. */
784
+ function computerResultText(content) {
785
+ return content.flatMap((block) => {
786
+ const entry = record(block);
787
+ return entry?.type === "text" && typeof entry.text === "string" ? [entry.text] : [];
788
+ }).join("\n");
789
+ }
790
+ /** `AXTextField` as `text field`; a role without the AX prefix is kept as it came. */
791
+ function computerRoleWords(role) {
792
+ if (!role.startsWith("AX")) return role;
793
+ return role.slice(2).replace(/([a-z])([A-Z])/gu, "$1 $2").toLowerCase();
794
+ }
795
+ function element(value) {
796
+ const entry = record(value);
797
+ if (entry === void 0 || typeof entry.ref !== "string") return [];
798
+ return [{
799
+ ref: entry.ref,
800
+ role: computerRoleWords(text(entry.role)),
801
+ label: text(entry.label) || text(entry.value),
802
+ enabled: entry.enabled !== false,
803
+ secure: entry.secure === true
804
+ }];
805
+ }
806
+ /** An observation when the value is one: an application name and an element list. */
807
+ function computerObservationView(value) {
808
+ const entry = record(value);
809
+ if (entry === void 0 || typeof entry.applicationName !== "string" || !Array.isArray(entry.elements)) return void 0;
810
+ const nextOffset = count(entry.nextOffset);
811
+ const artifact = text(entry.screenshotArtifact);
812
+ return {
813
+ applicationName: entry.applicationName,
814
+ windowTitle: text(entry.windowTitle),
815
+ elements: entry.elements.flatMap(element),
816
+ truncated: entry.truncated === true || nextOffset !== void 0,
817
+ ...nextOffset === void 0 ? {} : { nextOffset },
818
+ ...artifact.length > 0 ? { screenshotArtifact: artifact } : {}
819
+ };
820
+ }
821
+ /** One value of a script result as a short phrase: scalars as they read, collections by their size. */
822
+ function phrase(value) {
823
+ if (value === null || value === void 0) return "none";
824
+ if (typeof value === "string") return value;
825
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
826
+ if (Array.isArray(value)) return `${String(value.length)} item${value.length === 1 ? "" : "s"}`;
827
+ const size = Object.keys(value).length;
828
+ return `${String(size)} field${size === 1 ? "" : "s"}`;
829
+ }
830
+ /** A script's return value as fields: an object's own keys, or one `result` field for anything else. */
831
+ function computerResultFields(value) {
832
+ if (value === void 0) return [];
833
+ const entry = record(value);
834
+ if (entry === void 0) return [{
835
+ key: "result",
836
+ value: phrase(value)
837
+ }];
838
+ return Object.entries(entry).map(([key, field]) => ({
839
+ key,
840
+ value: phrase(field)
841
+ }));
842
+ }
843
+ function run(entry) {
844
+ if (!Array.isArray(entry.logs)) return void 0;
845
+ const observation = computerObservationView(entry.observation);
846
+ const metrics = record(entry.metrics);
847
+ const actions = count(metrics?.actions);
848
+ const observations = count(metrics?.observations);
849
+ const durationMs = count(metrics?.durationMs);
850
+ return {
851
+ fields: computerResultFields(entry.result),
852
+ logs: entry.logs.filter((line) => typeof line === "string"),
853
+ ...actions === void 0 ? {} : { actions },
854
+ ...observations === void 0 ? {} : { observations },
855
+ ...durationMs === void 0 ? {} : { duration: `${(durationMs / MS_PER_SECOND).toFixed(1)}s` },
856
+ ...observation === void 0 ? {} : { observation }
857
+ };
858
+ }
859
+ function failure(entry) {
860
+ if (typeof entry.error !== "string") return void 0;
861
+ const completedActions = count(entry.completedActions);
862
+ return {
863
+ reason: entry.error,
864
+ ...completedActions === void 0 ? {} : { completedActions },
865
+ outcomeUncertain: entry.outcomeUncertain === true
866
+ };
867
+ }
868
+ /** The text as lines a card can count: CRLF folded, tabs widened, trailing blank lines dropped. */
869
+ function lines(value) {
870
+ if (value.length === 0) return [];
871
+ const split = value.replaceAll("\r\n", "\n").replaceAll(" ", " ").split("\n");
872
+ while (split.length > 0 && split.at(-1)?.trim() === "") split.pop();
873
+ return split;
874
+ }
875
+ /**
876
+ * A computer tool result as the card lays it out. The tools answer in JSON (an
877
+ * observation, an action's outcome, a script run, a script failure) or in a
878
+ * plain sentence when they fail early; anything that does not parse as a shape
879
+ * the card knows falls back to its text lines.
880
+ */
881
+ function computerResultView(content) {
882
+ const raw = computerResultText(content);
883
+ let parsed;
884
+ try {
885
+ parsed = JSON.parse(raw);
886
+ } catch {
887
+ return {
888
+ kind: "text",
889
+ lines: lines(raw)
890
+ };
891
+ }
892
+ const entry = record(parsed);
893
+ const observation = computerObservationView(parsed);
894
+ if (observation !== void 0) return {
895
+ kind: "observation",
896
+ observation
897
+ };
898
+ const ran = entry === void 0 ? void 0 : run(entry);
899
+ if (ran !== void 0) return {
900
+ kind: "run",
901
+ run: ran
902
+ };
903
+ const failed = entry === void 0 ? void 0 : failure(entry);
904
+ if (failed !== void 0) return {
905
+ kind: "failure",
906
+ failure: failed
907
+ };
908
+ if (entry?.launched === true && typeof entry.applicationName === "string") return {
909
+ kind: "launched",
910
+ applicationName: entry.applicationName,
911
+ bundleId: text(entry.bundleId)
912
+ };
913
+ if (entry?.applied === true) return { kind: "applied" };
914
+ return {
915
+ kind: "text",
916
+ lines: lines(raw)
917
+ };
918
+ }
919
+ /** How many rows the view holds back while collapsed, so the card offers expand only when it reveals something. */
920
+ function computerResultHidden(view) {
921
+ switch (view.kind) {
922
+ case "observation": return Math.max(0, view.observation.elements.length - 5);
923
+ case "run": return Math.max(0, view.run.logs.length - 3);
924
+ case "text": return Math.max(0, view.lines.length - 8);
925
+ default: return 0;
926
+ }
927
+ }
928
+ //#endregion
929
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/ComputerResultBody.native.tsx
930
+ /** The parsed result, or none before the tool answers. */
931
+ function computerResult(props) {
932
+ return props.result === null ? void 0 : computerResultView(props.result.content);
933
+ }
934
+ /** Whether the card has rows to reveal: the header offers expand only then, and never on a failure. */
935
+ function computerResultExpandable(props) {
936
+ const view = computerResult(props);
937
+ return !props.isError && view !== void 0 && computerResultHidden(view) > 0;
938
+ }
939
+ /**
940
+ * The body the three computer tool cards share on native. The web cards print
941
+ * the result's text; the tools answer in JSON, so this lays the parsed result
942
+ * out instead: the window and its elements, a script's figures and logs, an
943
+ * action's outcome. A preview shows while collapsed, as the web's first lines
944
+ * do. A failure shows only its reason in red, with a quiet note of any actions
945
+ * that already ran; the header's edge and outcome already say it failed.
946
+ */
947
+ function ComputerResultBody({ props, expanded }) {
948
+ const t = useT();
949
+ const { toolName, output, running, isError } = props;
950
+ const view = computerResult(props);
951
+ const testID = `tool-result-${toolName}`;
952
+ if (isError) {
953
+ const failure = view?.kind === "failure" ? view.failure : {
954
+ reason: view?.kind === "text" ? view.lines.join("\n") : output.trim(),
955
+ outcomeUncertain: false
956
+ };
957
+ return failure.reason.length === 0 ? null : /* @__PURE__ */ jsx(MessageItemBody, {
958
+ testID,
959
+ children: /* @__PURE__ */ jsx(FailureBlock, { failure })
960
+ });
961
+ }
962
+ if (view === void 0) return running ? /* @__PURE__ */ jsx(MessageItemBody, {
963
+ testID,
964
+ children: /* @__PURE__ */ jsx(MessageItemStatus, {
965
+ tone: "running",
966
+ children: t("computerUse.ui.running", "running")
967
+ })
968
+ }) : null;
969
+ if (view.kind === "text" && view.lines.length === 0) return null;
970
+ return /* @__PURE__ */ jsx(MessageItemBody, {
971
+ testID,
972
+ children: /* @__PURE__ */ jsxs(View, {
973
+ style: styles$3.stack,
974
+ children: [
975
+ view.kind === "observation" ? /* @__PURE__ */ jsx(ObservationBlock, {
976
+ observation: view.observation,
977
+ expanded
978
+ }) : null,
979
+ view.kind === "run" ? /* @__PURE__ */ jsx(RunBlock, {
980
+ run: view.run,
981
+ expanded
982
+ }) : null,
983
+ view.kind === "applied" ? /* @__PURE__ */ jsx(Text, {
984
+ style: [styles$3.sans, styles$3.text],
985
+ children: t("computerUse.ui.appliedToTheElement", "Applied to the element.")
986
+ }) : null,
987
+ view.kind === "launched" ? /* @__PURE__ */ jsxs(View, {
988
+ style: styles$3.figure,
989
+ children: [/* @__PURE__ */ jsxs(Text, {
990
+ numberOfLines: 1,
991
+ style: [
992
+ styles$3.sans,
993
+ styles$3.strong,
994
+ styles$3.keep
995
+ ],
996
+ children: [
997
+ t("computerUse.ui.opened", "Opened"),
998
+ " ",
999
+ view.applicationName
1000
+ ]
1001
+ }), /* @__PURE__ */ jsx(Text, {
1002
+ numberOfLines: 1,
1003
+ style: [
1004
+ styles$3.mono,
1005
+ styles$3.faint,
1006
+ styles$3.yield
1007
+ ],
1008
+ children: view.bundleId
1009
+ })]
1010
+ }) : null,
1011
+ view.kind === "text" ? /* @__PURE__ */ jsx(TextLines, {
1012
+ lines: view.lines,
1013
+ expanded
1014
+ }) : null,
1015
+ running ? /* @__PURE__ */ jsx(MessageItemStatus, {
1016
+ tone: "running",
1017
+ children: t("computerUse.ui.running", "running")
1018
+ }) : null
1019
+ ]
1020
+ })
1021
+ });
1022
+ }
1023
+ function FailureBlock({ failure }) {
1024
+ const t = useT();
1025
+ const done = failure.completedActions;
1026
+ 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);
1027
+ return /* @__PURE__ */ jsxs(View, {
1028
+ style: styles$3.stack,
1029
+ children: [/* @__PURE__ */ jsx(Text, {
1030
+ selectable: true,
1031
+ style: [styles$3.sans, styles$3.error],
1032
+ children: failure.reason
1033
+ }), note.length > 0 ? /* @__PURE__ */ jsxs(Text, {
1034
+ style: [styles$3.small, styles$3.faint],
1035
+ children: [note.join(", "), "."]
1036
+ }) : null]
1037
+ });
1038
+ }
1039
+ function WindowLine({ observation, lead }) {
1040
+ return /* @__PURE__ */ jsxs(View, {
1041
+ style: styles$3.figure,
1042
+ children: [/* @__PURE__ */ jsxs(Text, {
1043
+ numberOfLines: 1,
1044
+ style: [
1045
+ styles$3.sans,
1046
+ styles$3.strong,
1047
+ styles$3.keep
1048
+ ],
1049
+ children: [lead === void 0 ? "" : `${lead} `, observation.applicationName]
1050
+ }), observation.windowTitle.length > 0 ? /* @__PURE__ */ jsx(Text, {
1051
+ numberOfLines: 1,
1052
+ style: [
1053
+ styles$3.sans,
1054
+ styles$3.dim,
1055
+ styles$3.yield
1056
+ ],
1057
+ children: observation.windowTitle
1058
+ }) : null]
1059
+ });
1060
+ }
1061
+ function ElementRow({ element }) {
1062
+ const t = useT();
1063
+ const secure = element.secure && !element.role.includes("secure");
1064
+ const traits = [
1065
+ element.role,
1066
+ element.enabled ? "" : t("computerUse.ui.disabled", "disabled"),
1067
+ secure ? t("computerUse.ui.secure", "secure") : ""
1068
+ ].filter(Boolean);
1069
+ return /* @__PURE__ */ jsxs(View, {
1070
+ style: styles$3.row,
1071
+ accessibilityLabel: `${element.label} ${traits.join(" ")} ${element.ref}`,
1072
+ children: [
1073
+ /* @__PURE__ */ jsx(Text, {
1074
+ numberOfLines: 1,
1075
+ style: [
1076
+ styles$3.sans,
1077
+ element.enabled ? styles$3.text : styles$3.faint,
1078
+ styles$3.yield
1079
+ ],
1080
+ children: element.label.length > 0 ? element.label : element.role
1081
+ }),
1082
+ /* @__PURE__ */ jsx(Text, {
1083
+ numberOfLines: 1,
1084
+ style: [
1085
+ styles$3.small,
1086
+ styles$3.faint,
1087
+ styles$3.keep
1088
+ ],
1089
+ children: traits.join(" · ")
1090
+ }),
1091
+ /* @__PURE__ */ jsx(Text, {
1092
+ numberOfLines: 1,
1093
+ style: [
1094
+ styles$3.mono,
1095
+ styles$3.faint,
1096
+ styles$3.ref
1097
+ ],
1098
+ children: element.ref
1099
+ })
1100
+ ]
1101
+ });
1102
+ }
1103
+ function ObservationBlock({ observation, expanded }) {
1104
+ const t = useT();
1105
+ const { elements } = observation;
1106
+ const shown = expanded ? elements : elements.slice(0, 5);
1107
+ const hidden = elements.length - shown.length;
1108
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1109
+ /* @__PURE__ */ jsx(WindowLine, { observation }),
1110
+ /* @__PURE__ */ jsxs(View, {
1111
+ style: styles$3.chips,
1112
+ children: [/* @__PURE__ */ jsx(Badge, {
1113
+ size: "xs",
1114
+ children: elements.length === 1 ? t("computerUse.ui.elementCountOne", "{count} element", { count: elements.length }) : t("computerUse.ui.elementCount", "{count} elements", { count: elements.length })
1115
+ }), observation.truncated ? /* @__PURE__ */ jsx(Badge, {
1116
+ size: "xs",
1117
+ tone: "yellow",
1118
+ children: observation.nextOffset === void 0 ? t("computerUse.ui.moreNotShown", "more not shown") : t("computerUse.ui.moreFromOffset", "more from offset {offset}", { offset: observation.nextOffset })
1119
+ }) : null]
1120
+ }),
1121
+ shown.length > 0 ? /* @__PURE__ */ jsx(View, {
1122
+ style: styles$3.list,
1123
+ children: shown.map((element) => /* @__PURE__ */ jsx(ElementRow, { element }, element.ref))
1124
+ }) : null,
1125
+ hidden > 0 ? /* @__PURE__ */ jsx(MessageItemStatus, {
1126
+ expands: true,
1127
+ children: hidden === 1 ? t("computerUse.ui.moreElementsOne", "{count} more element", { count: hidden }) : t("computerUse.ui.moreElements", "{count} more elements", { count: hidden })
1128
+ }) : null,
1129
+ observation.screenshotArtifact === void 0 ? null : /* @__PURE__ */ jsx(Text, {
1130
+ numberOfLines: 2,
1131
+ style: [styles$3.small, styles$3.faint],
1132
+ children: t("computerUse.ui.screenshotSaved", "Screenshot saved to {path}", { path: observation.screenshotArtifact })
1133
+ })
1134
+ ] });
1135
+ }
1136
+ function RunBlock({ run, expanded }) {
1137
+ const t = useT();
1138
+ const figures = [
1139
+ 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 }),
1140
+ 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 }),
1141
+ run.duration ?? ""
1142
+ ].filter(Boolean);
1143
+ const logs = expanded ? run.logs : run.logs.slice(0, 3);
1144
+ const hidden = run.logs.length - logs.length;
1145
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1146
+ figures.length > 0 ? /* @__PURE__ */ jsx(View, {
1147
+ style: styles$3.chips,
1148
+ children: figures.map((figure) => /* @__PURE__ */ jsx(Badge, {
1149
+ size: "xs",
1150
+ children: figure
1151
+ }, figure))
1152
+ }) : null,
1153
+ run.fields.length > 0 ? /* @__PURE__ */ jsx(View, {
1154
+ style: styles$3.list,
1155
+ children: run.fields.map((field) => /* @__PURE__ */ jsxs(View, {
1156
+ style: styles$3.row,
1157
+ children: [/* @__PURE__ */ jsx(Text, {
1158
+ numberOfLines: 1,
1159
+ style: [
1160
+ styles$3.small,
1161
+ styles$3.faint,
1162
+ styles$3.key
1163
+ ],
1164
+ children: field.key
1165
+ }), /* @__PURE__ */ jsx(Text, {
1166
+ numberOfLines: 1,
1167
+ selectable: true,
1168
+ style: [
1169
+ styles$3.sans,
1170
+ styles$3.text,
1171
+ styles$3.yield
1172
+ ],
1173
+ children: field.value
1174
+ })]
1175
+ }, field.key))
1176
+ }) : null,
1177
+ logs.length > 0 ? /* @__PURE__ */ jsx(View, {
1178
+ style: styles$3.list,
1179
+ children: logs.map((line, index) => /* @__PURE__ */ jsx(Text, {
1180
+ numberOfLines: 1,
1181
+ selectable: true,
1182
+ style: [styles$3.mono, styles$3.dim],
1183
+ children: line
1184
+ }, `${String(index)}-${line}`))
1185
+ }) : null,
1186
+ hidden > 0 ? /* @__PURE__ */ jsx(MessageItemStatus, {
1187
+ expands: true,
1188
+ children: hidden === 1 ? t("computerUse.ui.moreLogLinesOne", "{count} more log line", { count: hidden }) : t("computerUse.ui.moreLogLines", "{count} more log lines", { count: hidden })
1189
+ }) : null,
1190
+ run.observation === void 0 ? null : /* @__PURE__ */ jsx(WindowLine, {
1191
+ observation: run.observation,
1192
+ lead: t("computerUse.ui.endedOn", "Ended on")
1193
+ })
1194
+ ] });
1195
+ }
1196
+ function TextLines({ lines, expanded }) {
1197
+ const t = useT();
1198
+ const shown = expanded ? lines : lines.slice(0, 8);
1199
+ const hidden = lines.length - shown.length;
1200
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(View, {
1201
+ style: styles$3.list,
1202
+ children: shown.map((line, index) => /* @__PURE__ */ jsx(Text, {
1203
+ selectable: true,
1204
+ style: [styles$3.sans, styles$3.dim],
1205
+ children: line
1206
+ }, `${String(index)}-${line}`))
1207
+ }), hidden > 0 ? /* @__PURE__ */ jsx(MessageItemStatus, {
1208
+ expands: true,
1209
+ children: hidden === 1 ? t("computerUse.ui.moreLinesOne", "{count} more line", { count: hidden }) : t("computerUse.ui.moreLines", "{count} more lines", { count: hidden })
1210
+ }) : null] });
1211
+ }
1212
+ const styles$3 = StyleSheet.create((theme) => ({
1213
+ stack: {
1214
+ gap: theme.spacing(2),
1215
+ uni__dependencies: [0]
1216
+ },
1217
+ list: {
1218
+ gap: theme.spacing(1),
1219
+ uni__dependencies: [0]
1220
+ },
1221
+ chips: {
1222
+ flexDirection: "row",
1223
+ flexWrap: "wrap",
1224
+ gap: theme.spacing(1.5),
1225
+ uni__dependencies: [0]
1226
+ },
1227
+ figure: {
1228
+ flexDirection: "row",
1229
+ alignItems: "baseline",
1230
+ gap: theme.spacing(2),
1231
+ minWidth: 0,
1232
+ uni__dependencies: [0]
1233
+ },
1234
+ row: {
1235
+ flexDirection: "row",
1236
+ alignItems: "baseline",
1237
+ gap: theme.spacing(2),
1238
+ minWidth: 0,
1239
+ uni__dependencies: [0]
1240
+ },
1241
+ sans: {
1242
+ fontFamily: fontOf(theme.fontFamily.sans),
1243
+ fontSize: theme.fontSize.base,
1244
+ lineHeight: theme.lineHeight.base,
1245
+ uni__dependencies: [0]
1246
+ },
1247
+ small: {
1248
+ fontFamily: fontOf(theme.fontFamily.sans),
1249
+ fontSize: theme.fontSize.sm,
1250
+ lineHeight: theme.lineHeight.sm,
1251
+ uni__dependencies: [0]
1252
+ },
1253
+ mono: {
1254
+ fontFamily: fontOf(theme.fontFamily.mono),
1255
+ fontSize: theme.fontSize.sm,
1256
+ lineHeight: theme.lineHeight.sm,
1257
+ uni__dependencies: [0]
1258
+ },
1259
+ strong: {
1260
+ color: theme.colors.text,
1261
+ fontWeight: theme.fontWeight.semibold,
1262
+ uni__dependencies: [0]
1263
+ },
1264
+ text: {
1265
+ color: theme.colors.text,
1266
+ uni__dependencies: [0]
1267
+ },
1268
+ dim: {
1269
+ color: theme.colors.dim,
1270
+ uni__dependencies: [0]
1271
+ },
1272
+ faint: {
1273
+ color: theme.colors.faint,
1274
+ uni__dependencies: [0]
1275
+ },
1276
+ error: {
1277
+ color: theme.colors.red,
1278
+ uni__dependencies: [0]
1279
+ },
1280
+ keep: {
1281
+ flexShrink: 0,
1282
+ maxWidth: "60%"
1283
+ },
1284
+ yield: {
1285
+ flexShrink: 1,
1286
+ minWidth: 0
1287
+ },
1288
+ key: {
1289
+ flexShrink: 0,
1290
+ maxWidth: "40%"
1291
+ },
1292
+ ref: {
1293
+ flexShrink: 0,
1294
+ marginLeft: "auto"
1295
+ }
1296
+ }));
1297
+ //#endregion
1298
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/ComputerActionToolCard.native.tsx
1299
+ /**
1300
+ * The computer_action tool's timeline item on native, as the web's: the action
1301
+ * and the element it targets in the header, the outcome's first lines beneath.
1302
+ */
1303
+ function ComputerActionToolCard(props) {
1304
+ const { toolName, args, running, isError } = props;
1305
+ const [kind, ...target] = computerActionCallParts(args);
1306
+ return /* @__PURE__ */ jsx(MessageItem, {
1307
+ tone: toolTone({
1308
+ running,
1309
+ isError
1310
+ }),
1311
+ expandable: computerResultExpandable(props),
1312
+ children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MessageItemHeader, {
1313
+ title: toolName,
1314
+ children: /* @__PURE__ */ jsxs(View, {
1315
+ testID: `tool-call-${toolName}`,
1316
+ style: styles$2.summary,
1317
+ children: [kind === void 0 ? null : /* @__PURE__ */ jsx(Text, {
1318
+ numberOfLines: 1,
1319
+ style: [styles$2.sans, styles$2.primary],
1320
+ children: kind
1321
+ }), target.length > 0 ? /* @__PURE__ */ jsx(Text, {
1322
+ numberOfLines: 1,
1323
+ style: [styles$2.sans, styles$2.detail],
1324
+ children: target.join(" ")
1325
+ }) : null]
1326
+ })
1327
+ }), /* @__PURE__ */ jsx(ComputerResultBody, {
1328
+ props,
1329
+ expanded
1330
+ })] })
1331
+ });
1332
+ }
1333
+ const styles$2 = StyleSheet.create((theme) => ({
1334
+ summary: {
1335
+ flex: 1,
1336
+ flexDirection: "row",
1337
+ alignItems: "center",
1338
+ gap: theme.spacing(2),
1339
+ minWidth: 0,
1340
+ uni__dependencies: [0]
1341
+ },
1342
+ sans: {
1343
+ fontFamily: fontOf(theme.fontFamily.sans),
1344
+ fontSize: theme.fontSize.base,
1345
+ lineHeight: theme.lineHeight.base,
1346
+ uni__dependencies: [0]
1347
+ },
1348
+ primary: {
1349
+ flexShrink: 0,
1350
+ maxWidth: "45%",
1351
+ color: theme.colors.text,
1352
+ uni__dependencies: [0]
1353
+ },
1354
+ detail: {
1355
+ flexShrink: 1,
1356
+ color: theme.colors.dim,
1357
+ uni__dependencies: [0]
1358
+ }
1359
+ }));
1360
+ //#endregion
1361
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/computer-action.native.tsx
1362
+ var computer_action_native_default = defineToolRenderer({
1363
+ tools: ["computer_action"],
1364
+ message: ComputerActionToolCard
1365
+ });
1366
+ //#endregion
1367
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/ComputerExecToolCard.native.tsx
1368
+ /**
1369
+ * The computer_exec tool's timeline item on native, as the web's: the script
1370
+ * path in the header, the run's first lines beneath it.
1371
+ */
1372
+ function ComputerExecToolCard(props) {
1373
+ const { toolName, args, running, isError } = props;
1374
+ const path = computerExecPathParts(computerExecCallSummary(args));
1375
+ return /* @__PURE__ */ jsx(MessageItem, {
1376
+ tone: toolTone({
1377
+ running,
1378
+ isError
1379
+ }),
1380
+ expandable: computerResultExpandable(props),
1381
+ children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MessageItemHeader, {
1382
+ title: toolName,
1383
+ children: /* @__PURE__ */ jsxs(View, {
1384
+ testID: `tool-call-${toolName}`,
1385
+ style: styles$1.summary,
1386
+ children: [path.folder.length > 0 ? /* @__PURE__ */ jsx(Text, {
1387
+ numberOfLines: 1,
1388
+ style: [styles$1.sans, styles$1.folder],
1389
+ children: path.folder
1390
+ }) : null, /* @__PURE__ */ jsx(Text, {
1391
+ numberOfLines: 1,
1392
+ style: [styles$1.sans, styles$1.primary],
1393
+ children: path.name
1394
+ })]
1395
+ })
1396
+ }), /* @__PURE__ */ jsx(ComputerResultBody, {
1397
+ props,
1398
+ expanded
1399
+ })] })
1400
+ });
1401
+ }
1402
+ const styles$1 = StyleSheet.create((theme) => ({
1403
+ summary: {
1404
+ flex: 1,
1405
+ flexDirection: "row",
1406
+ alignItems: "center",
1407
+ minWidth: 0
1408
+ },
1409
+ sans: {
1410
+ fontFamily: fontOf(theme.fontFamily.sans),
1411
+ fontSize: theme.fontSize.base,
1412
+ lineHeight: theme.lineHeight.base,
1413
+ uni__dependencies: [0]
1414
+ },
1415
+ folder: {
1416
+ flexShrink: 1,
1417
+ minWidth: 0,
1418
+ color: theme.colors.dim,
1419
+ uni__dependencies: [0]
1420
+ },
1421
+ primary: {
1422
+ flexShrink: 0,
1423
+ maxWidth: "100%",
1424
+ color: theme.colors.text,
1425
+ uni__dependencies: [0]
1426
+ }
1427
+ }));
1428
+ //#endregion
1429
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/computer-exec.native.tsx
1430
+ var computer_exec_native_default = defineToolRenderer({
1431
+ tools: ["computer_exec"],
1432
+ message: ComputerExecToolCard
1433
+ });
1434
+ //#endregion
1435
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/ComputerStateToolCard.native.tsx
1436
+ /**
1437
+ * The computer_state tool's timeline item on native, as the web's: the observed
1438
+ * window in the header, the observation's first lines beneath it.
1439
+ */
1440
+ function ComputerStateToolCard(props) {
1441
+ const t = useT();
1442
+ const { toolName, running, isError } = props;
1443
+ return /* @__PURE__ */ jsx(MessageItem, {
1444
+ tone: toolTone({
1445
+ running,
1446
+ isError
1447
+ }),
1448
+ expandable: computerResultExpandable(props),
1449
+ children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MessageItemHeader, {
1450
+ title: toolName,
1451
+ children: /* @__PURE__ */ jsx(View, {
1452
+ testID: `tool-call-${toolName}`,
1453
+ style: styles.summary,
1454
+ children: /* @__PURE__ */ jsx(Text, {
1455
+ numberOfLines: 1,
1456
+ style: [styles.sans, styles.primary],
1457
+ children: toolName === "computer_state" ? t("computerUse.ui.authorizedWindow", "authorized window") : null
1458
+ })
1459
+ })
1460
+ }), /* @__PURE__ */ jsx(ComputerResultBody, {
1461
+ props,
1462
+ expanded
1463
+ })] })
1464
+ });
1465
+ }
1466
+ const styles = StyleSheet.create((theme) => ({
1467
+ summary: {
1468
+ flex: 1,
1469
+ flexDirection: "row",
1470
+ alignItems: "center",
1471
+ gap: theme.spacing(2),
1472
+ minWidth: 0,
1473
+ uni__dependencies: [0]
1474
+ },
1475
+ sans: {
1476
+ fontFamily: fontOf(theme.fontFamily.sans),
1477
+ fontSize: theme.fontSize.base,
1478
+ lineHeight: theme.lineHeight.base,
1479
+ uni__dependencies: [0]
1480
+ },
1481
+ primary: {
1482
+ flexShrink: 1,
1483
+ color: theme.colors.text,
1484
+ uni__dependencies: [0]
1485
+ }
1486
+ }));
1487
+ //#endregion
1488
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/computer-state.native.tsx
1489
+ var computer_state_native_default = defineToolRenderer({
1490
+ tools: [
1491
+ "computer_state",
1492
+ "computer_targets",
1493
+ "computer_request"
1494
+ ],
1495
+ message: ComputerStateToolCard
1496
+ });
1497
+ //#endregion
41
1498
  //#region generated/native.ts
42
- const via = (identity, value) => value === void 0 ? void 0 : {
43
- ...identity,
44
- ...value
1499
+ const via = (identity, value) => {
1500
+ if (value === void 0) return void 0;
1501
+ const declaration = value;
1502
+ return {
1503
+ ...identity,
1504
+ ...declaration,
1505
+ ...declaration.relations === void 0 ? {} : { relations: declaration.relations.map((relation) => ({
1506
+ evidence: "declared",
1507
+ ...relation
1508
+ })) }
1509
+ };
45
1510
  };
46
1511
  const nativePlugin = defineNativePlugin({
47
1512
  id: "computer-use",
1513
+ packageName: "@agimon-ai/po-computer-use",
1514
+ host: { get settingsPanels() {
1515
+ return [via({ id: "desktop-permissions" }, desktop_permissions_panel_native_default)];
1516
+ } },
48
1517
  session: {
49
1518
  get activityGroups() {
50
1519
  return [via({ name: "computer-use" }, computer_use_native_default$1)];
51
1520
  },
52
1521
  get channels() {
53
1522
  return [via({ channel: "computer_use" }, computer_use_native_default)];
1523
+ },
1524
+ get fills() {
1525
+ return [via({
1526
+ slot: "activity.computer-use",
1527
+ id: "computer-use"
1528
+ }, ComputerUse_activity_computer_use_native_default), via({
1529
+ slot: "help.guides",
1530
+ id: "computeruse"
1531
+ }, Computeruse_help_guides_native_default)];
1532
+ },
1533
+ get toolRenderers() {
1534
+ return [
1535
+ via({ tools: ["computer_action"] }, computer_action_native_default),
1536
+ via({ tools: ["computer_exec"] }, computer_exec_native_default),
1537
+ via({ tools: ["computer_state"] }, computer_state_native_default)
1538
+ ];
54
1539
  }
55
1540
  }
56
1541
  });