@agimon-ai/po-computer-use 0.0.0-alpha.63 → 0.0.0-alpha.65

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.
@@ -1,7 +1,7 @@
1
1
  import { createApiClient, defineActivityGroup, defineChannelFile, defineFill, defineNativePlugin, defineSessionStore, nativeApiTransport, sessionApiAddress } from "@agimon-ai/po-core/native";
2
2
  import { View } from "react-native-unistyles/components/native/View";
3
3
  import { Text } from "react-native-unistyles/components/native/Text";
4
- import { Button, CheckIcon, SegmentedControl, fontOf } from "@agimon-ai/po-native-components";
4
+ import { Button, CheckIcon, Dialog, DialogBody, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, SegmentedControl, fontOf } from "@agimon-ai/po-native-components";
5
5
  import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
6
6
  import { StyleSheet } from "react-native-unistyles";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -12,7 +12,7 @@ const COMPUTER_USE_MAX_DURATION_MS = 18e5;
12
12
  const COMPUTER_USE_DEFAULT_DURATION_MS = 3e5;
13
13
  /** The session lengths a person can pick when granting control, up to the maximum. */
14
14
  const COMPUTER_USE_DURATION_CHOICES_MS = [
15
- 3e5,
15
+ COMPUTER_USE_DEFAULT_DURATION_MS,
16
16
  9e5,
17
17
  COMPUTER_USE_MAX_DURATION_MS
18
18
  ];
@@ -204,6 +204,9 @@ createApiClient(routes, {
204
204
  });
205
205
  //#endregion
206
206
  //#region src/extensions/workspaces/sessions/(frontend)/fill/_components/ComputerUsePanel.native.tsx
207
+ function text(value, fallback) {
208
+ return typeof value === "string" || typeof value === "number" ? String(value) : fallback;
209
+ }
207
210
  function remaining(ms) {
208
211
  const seconds = Math.max(0, Math.ceil(ms / 1e3));
209
212
  return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")} left`;
@@ -212,7 +215,17 @@ const DURATION_OPTIONS = COMPUTER_USE_DURATION_CHOICES_MS.map((choice) => ({
212
215
  value: String(choice),
213
216
  label: `${choice / 6e4} min`
214
217
  }));
215
- function ComputerUseView({ state, busy = false, error, submitting = false, durationMs = COMPUTER_USE_DEFAULT_DURATION_MS, onDurationChange, onActivate, onCancel, onStop }) {
218
+ function ComputerUseView({ state, targets = [], busy = false, error, submitting = false, durationMs = COMPUTER_USE_DEFAULT_DURATION_MS, onDurationChange, onActivate, onCancel, onStop }) {
219
+ const [selected, setSelected] = useState(0);
220
+ const [confirmation, setConfirmation] = useState();
221
+ const choices = [{
222
+ label: "Whole desktop",
223
+ target: { scope: "desktop" }
224
+ }, ...targets.map((target) => ({
225
+ label: `${text(target.applicationName, "Application")}: ${text(target.windowTitle, text(target.windowId, "Window"))}`,
226
+ target
227
+ }))];
228
+ const chosen = choices[selected] ?? choices[0];
216
229
  const pending = state.phase === "awaiting_confirmation" || state.phase === "activating";
217
230
  const active = state.phase === "active" || state.phase === "stopping";
218
231
  const failure = error ?? state.failure?.message;
@@ -260,22 +273,15 @@ function ComputerUseView({ state, busy = false, error, submitting = false, durat
260
273
  style: styles.error,
261
274
  children: state.artifact.failure.message
262
275
  }) : null,
263
- pending ? /* @__PURE__ */ jsxs(Fragment, { children: [
264
- /* @__PURE__ */ jsx(Text, {
265
- style: styles.text,
266
- children: "Waiting for you on your Mac."
267
- }),
268
- /* @__PURE__ */ jsx(Text, {
269
- style: styles.detail,
270
- children: "Choose the whole desktop or one window, then confirm."
271
- }),
272
- /* @__PURE__ */ jsx(Button, {
273
- variant: "outline",
274
- disabled: submitting,
275
- onPress: onCancel,
276
- children: "Cancel activation"
277
- })
278
- ] }) : active ? /* @__PURE__ */ jsxs(Fragment, { children: [
276
+ pending ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Text, {
277
+ style: styles.text,
278
+ children: "Desktop activation is pending."
279
+ }), /* @__PURE__ */ jsx(Button, {
280
+ variant: "outline",
281
+ disabled: submitting,
282
+ onPress: onCancel,
283
+ children: "Cancel activation"
284
+ })] }) : active ? /* @__PURE__ */ jsxs(Fragment, { children: [
279
285
  /* @__PURE__ */ jsxs(View, {
280
286
  style: styles.row,
281
287
  accessibilityLiveRegion: "polite",
@@ -310,8 +316,17 @@ function ComputerUseView({ state, busy = false, error, submitting = false, durat
310
316
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
311
317
  /* @__PURE__ */ jsx(Text, {
312
318
  style: styles.detail,
313
- children: "Po asks before it takes control. Choose the whole desktop or one window on your Mac. You can stop at any time."
319
+ children: "Po asks before it takes control. You can stop at any time."
314
320
  }),
321
+ /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
322
+ variant: "outline",
323
+ disabled: busy || submitting,
324
+ accessibilityLabel: "What Po may control",
325
+ children: chosen.label
326
+ }), /* @__PURE__ */ jsx(DropdownMenuContent, { children: choices.map((choice, index) => /* @__PURE__ */ jsx(DropdownMenuItem, {
327
+ onSelect: () => setSelected(index),
328
+ children: choice.label
329
+ }, `${index}:${choice.label}`)) })] }),
315
330
  onDurationChange ? /* @__PURE__ */ jsx(SegmentedControl, {
316
331
  accessibilityLabel: "For how long",
317
332
  options: DURATION_OPTIONS,
@@ -322,10 +337,22 @@ function ComputerUseView({ state, busy = false, error, submitting = false, durat
322
337
  /* @__PURE__ */ jsx(Button, {
323
338
  variant: "primary",
324
339
  disabled: busy || submitting,
325
- onPress: onActivate,
326
- children: "Choose on Mac"
340
+ onPress: () => setConfirmation({
341
+ target: Object.freeze({ ...chosen.target }),
342
+ durationMs
343
+ }),
344
+ children: "Request activation"
327
345
  })
328
- ] })
346
+ ] }),
347
+ confirmation ? /* @__PURE__ */ jsx(ComputerUseConfirmation, {
348
+ target: confirmation.target,
349
+ durationMs: confirmation.durationMs,
350
+ onCancel: () => setConfirmation(void 0),
351
+ onConfirm: () => {
352
+ setConfirmation(void 0);
353
+ onActivate(confirmation.target, confirmation.durationMs);
354
+ }
355
+ }) : null
329
356
  ]
330
357
  });
331
358
  }
@@ -347,6 +374,10 @@ function SessionPanel({ sessionId, sendSessionFrame }) {
347
374
  type: computerUseChannelType,
348
375
  payload: { action: "status" }
349
376
  });
377
+ sendSessionFrame(sessionId, {
378
+ type: computerUseChannelType,
379
+ payload: { action: "targets" }
380
+ });
350
381
  const poll = async () => {
351
382
  try {
352
383
  const result = await computerUse.session(sessionId).activationState({ signal: controller.signal });
@@ -362,7 +393,7 @@ function SessionPanel({ sessionId, sendSessionFrame }) {
362
393
  clearTimeout(timer);
363
394
  };
364
395
  }, [sessionId, sendSessionFrame]);
365
- const submit = async (action) => {
396
+ const submit = async (action, target, approvedDurationMs = durationMs) => {
366
397
  const signal = requests.current?.signal;
367
398
  if (!signal || signal.aborted || submitting) return;
368
399
  setError(void 0);
@@ -370,7 +401,11 @@ function SessionPanel({ sessionId, sendSessionFrame }) {
370
401
  try {
371
402
  const client = computerUse.session(sessionId);
372
403
  const result = action === "activate" ? await client.activate({
373
- body: { durationMs },
404
+ body: {
405
+ target,
406
+ durationMs: approvedDurationMs,
407
+ confirmed: true
408
+ },
374
409
  signal
375
410
  }) : await client.cancelActivation({ signal });
376
411
  if (signal.aborted) return;
@@ -384,12 +419,13 @@ function SessionPanel({ sessionId, sendSessionFrame }) {
384
419
  };
385
420
  return /* @__PURE__ */ jsx(ComputerUseView, {
386
421
  state: session.state,
422
+ targets: session.targets,
387
423
  busy: session.busy,
388
424
  error,
389
425
  submitting,
390
426
  durationMs,
391
427
  onDurationChange: setDurationMs,
392
- onActivate: () => void submit("activate"),
428
+ onActivate: (target, duration) => void submit("activate", target, duration),
393
429
  onCancel: () => void submit("cancel"),
394
430
  onStop: () => {
395
431
  setError(void 0);
@@ -413,6 +449,51 @@ function ComputerUsePanel(props) {
413
449
  sessionId: props.sessionId
414
450
  }, props.sessionId);
415
451
  }
452
+ function ComputerUseConfirmation({ target, durationMs, onConfirm, onCancel }) {
453
+ const desktop = target.scope === "desktop";
454
+ return /* @__PURE__ */ jsx(Dialog, {
455
+ open: true,
456
+ onOpenChange: (open) => {
457
+ if (!open) onCancel();
458
+ },
459
+ children: /* @__PURE__ */ jsxs(DialogContent, { children: [/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { children: [
460
+ "Allow Po to control ",
461
+ desktop ? "your whole desktop" : "this window",
462
+ "?"
463
+ ] }) }), /* @__PURE__ */ jsxs(DialogBody, { children: [
464
+ /* @__PURE__ */ jsx(DialogDescription, { children: desktop ? "Every app window on the main display, except Po and system security windows." : `${text(target.applicationName, "Application")}: ${text(target.windowTitle, text(target.windowId, "Window"))}` }),
465
+ /* @__PURE__ */ jsxs(Text, {
466
+ style: styles.text,
467
+ children: [
468
+ "For ",
469
+ durationMs / 6e4,
470
+ " minutes. You can stop at any time."
471
+ ]
472
+ }),
473
+ /* @__PURE__ */ jsxs(Text, {
474
+ style: styles.detail,
475
+ children: [
476
+ "Po records ",
477
+ desktop ? "the main display" : "this window",
478
+ ", system sound and microphone audio when permission is granted."
479
+ ]
480
+ }),
481
+ /* @__PURE__ */ jsx(Text, {
482
+ style: styles.detail,
483
+ children: "Only this session and its approved device receive control."
484
+ }),
485
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
486
+ variant: "outline",
487
+ onPress: onCancel,
488
+ children: "Cancel"
489
+ }), /* @__PURE__ */ jsx(Button, {
490
+ variant: "primary",
491
+ onPress: onConfirm,
492
+ children: "Allow control"
493
+ })] })
494
+ ] })] })
495
+ });
496
+ }
416
497
  const styles = StyleSheet.create((theme) => ({
417
498
  panel: {
418
499
  gap: theme.spacing(3),
@@ -1 +1 @@
1
- {"version":3,"file":"native.mjs","names":["computerUse","WebPluginSlotProps","Button","CheckIcon","fontOf","SegmentedControl","PoNativeTheme","useCallback","useEffect","useRef","useState","useSyncExternalStore","StyleSheet","computerUse","api","COMPUTER_USE_DEFAULT_DURATION_MS","COMPUTER_USE_DURATION_CHOICES_MS","computerUseChannelType","ComputerUseSessionView","updateComputerUseState","remaining","ms","seconds","Math","max","ceil","floor","String","padStart","DURATION_OPTIONS","map","choice","value","label","ComputerUseView","state","busy","error","submitting","durationMs","onDurationChange","onActivate","onCancel","onStop","pending","phase","active","failure","message","expiresAt","undefined","now","setNow","Date","timer","setInterval","clearInterval","left","total","controlled","target","scope","applicationName","styles","panel","title","detail","artifact","status","row","check","text","dot","live","track","min","fill","width","Number","SessionPanel","sessionId","sendSessionFrame","subscribe","listener","subscription","store","unsubscribe","session","select","setError","setSubmitting","setDurationMs","requests","AbortController","controller","current","ReturnType","setTimeout","type","payload","action","poll","result","activationState","signal","ok","aborted","data","abort","clearTimeout","submit","client","activate","body","cancelActivation","ComputerUsePanel","props","create","theme","gap","spacing","uni__dependencies","fontFamily","sans","fontSize","base","fontWeight","color","colors","hi","paddingBottom","borderBottomWidth","borderBottomColor","flexDirection","alignItems","height","borderRadius","backgroundColor","green","lineHeight","lineHeightRelaxed","flex","overflow","justifyContent","sm","dim","red","computerUse","api","activityGroupComputerUse","channelComputerUse","fillComputerUse"],"sources":["../../src/types/computerUseApi.ts","../../src/extensions/workspaces/sessions/(frontend)/activity-group/computer-use.native.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/computerUseStore.native.ts","../../src/extensions/workspaces/sessions/(frontend)/channel/computer-use.native.ts","../../src/types/apiRoutes.ts","../../generated/client.native.ts","../../src/extensions/workspaces/sessions/(frontend)/fill/_components/ComputerUsePanel.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/fill/ComputerUse.activity.computer-use.native.tsx","../../generated/native.ts"],"sourcesContent":["import type { PoApiCaller } from '@agimon-ai/po-core/packageApi';\n\nexport const API_BASE_PATH = 'computer-use';\nexport const computerUseChannelType = 'computer_use_state';\nexport const COMPUTER_USE_MODE_ID = 'computer-use';\nexport const COMPUTER_USE_STATUS_KEY = 'po-computer-use';\nexport const COMPUTER_USE_MODE_STATUS_KEY = 'po-computer-use-mode';\nexport const COMPUTER_USE_MAX_DURATION_MS = 1_800 * 1_000;\nexport const COMPUTER_USE_DEFAULT_DURATION_MS = 300 * 1_000;\n/** The session lengths a person can pick when granting control, up to the maximum. */\nexport const COMPUTER_USE_DURATION_CHOICES_MS = [300_000, 900_000, COMPUTER_USE_MAX_DURATION_MS] as const;\nexport const COMPUTER_USE_CONFIRMATION_WINDOW_MS = 2 * 60 * 1_000;\n\n/**\n * Every path this API answers on, below its mount.\n *\n * The typed route table in `./apiRoutes` is built from this, the dispatcher\n * reads that table, and the hub channel addresses the broker with these same\n * strings, so a route cannot move on one side alone.\n */\nexport const COMPUTER_USE_ROUTES = {\n activate: '/activate',\n artifact: '/artifact',\n agentState: '/agent/state',\n agentObserve: '/agent/observe',\n agentAction: '/agent/action',\n agentStop: '/agent/stop',\n hubState: '/hub/state',\n hubActivation: '/hub/activation',\n hubAuthorization: '/hub/authorization',\n hubNext: '/hub/next',\n hubComplete: '/hub/complete',\n hubStop: '/hub/stop',\n} as const;\n\nexport const COMPUTER_USE_WAKE_LIMIT = 1_000_000;\n\nexport interface ComputerUseArtifactView {\n readonly artifactId: string;\n readonly status: 'ready' | 'failed';\n readonly sizeBytes?: number;\n readonly downloadUrl?: string;\n readonly previewUrl?: string;\n readonly actionCount?: number;\n readonly completedAt?: string;\n readonly failure?: { readonly code: string; readonly message: string };\n}\n\nexport interface ComputerUseSessionView {\n readonly sessionId: string;\n readonly revision: number;\n readonly wake: number;\n readonly phase: 'inactive' | 'awaiting_confirmation' | 'activating' | 'active' | 'stopping' | 'failed';\n readonly requestId?: string;\n readonly target?: Record<string, unknown>;\n readonly durationMs?: number;\n readonly expiresAt?: number;\n readonly failure?: { readonly code: string; readonly message: string };\n readonly artifact?: ComputerUseArtifactView;\n}\n\nexport interface ComputerUseActivationRequest {\n readonly requestId: string;\n readonly target?: Record<string, unknown>;\n readonly durationSeconds: number;\n readonly createdAt: number;\n readonly confirmationExpiresAt: number;\n readonly caller: PoApiCaller;\n}\n\nexport interface ComputerUseBrokerRequest {\n readonly id: string;\n readonly operation: 'observe' | 'act';\n readonly payload?: unknown;\n readonly grantId: string;\n readonly sequence?: number;\n}\n\nexport interface ComputerUseChannelPayload {\n readonly state: ComputerUseSessionView;\n readonly targets: readonly Record<string, unknown>[];\n readonly busy?: true;\n}\n\nexport type ComputerUseBrowserCommand = { readonly action: 'status' | 'targets' | 'stop' | 'artifacts' };\n","import { defineActivityGroup } from '@agimon-ai/po-core/native';\n\nimport { COMPUTER_USE_STATUS_KEY } from '../../../../../types/computerUseApi';\n\n/** Remote clients request control from the Desktop host through their session Activity. */\nexport default defineActivityGroup({\n name: 'computer-use',\n keys: 'c e',\n order: 70,\n statusKey: COMPUTER_USE_STATUS_KEY,\n hideWhenEmpty: true,\n marksBackgroundWork: false,\n});\n","import { defineSessionStore } from '@agimon-ai/po-core/native';\n\nimport { computerUseChannelType } from '../../../../../types/computerUseApi';\nimport type { ComputerUseChannelPayload, ComputerUseSessionView } from '../../../../../types/computerUseApi';\n\nexport interface ComputerUseSession extends ComputerUseChannelPayload {}\n\nconst initialState: ComputerUseSession = {\n state: { sessionId: '', revision: 0, wake: 0, phase: 'inactive' },\n targets: [],\n};\n\nexport const computerUse = defineSessionStore<ComputerUseSession>(initialState);\n\n/** Revision zero must hydrate the empty selector once; equal status polls then retain identity. */\nexport function updateComputerUseState(sessionId: string, state: ComputerUseSessionView) {\n computerUse.update(sessionId, (current) =>\n current.state.sessionId === '' || state.revision > current.state.revision ? { ...current, state } : current,\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport const computerUseChannel = computerUse.channel<ComputerUseChannelPayload>({\n channel: computerUseChannelType,\n parse(input) {\n if (!isRecord(input) || !isRecord(input.state) || !Array.isArray(input.targets)) return null;\n if (typeof input.state.phase !== 'string' || typeof input.state.revision !== 'number') return null;\n return input as unknown as ComputerUseChannelPayload;\n },\n reduce: (_current, payload) => payload,\n});\n","import { defineChannelFile } from '@agimon-ai/po-core/native';\n\nimport { computerUseChannel } from '../_lib/computerUseStore.native';\n\nexport default defineChannelFile(computerUseChannel);\n","import type { ApiResponseOf, ApiRoutes } from '@agimon-ai/po-core/web';\n\nimport {\n COMPUTER_USE_ROUTES,\n type ComputerUseActivationRequest,\n type ComputerUseBrokerRequest,\n type ComputerUseSessionView,\n} from './computerUseApi';\nimport { DESKTOP_PERMISSIONS_PATH, type DesktopPermissionStates } from './desktopPermissions';\n\n/**\n * This package's routes, as data.\n *\n * No scope and no base path: the build reads both off\n * `src/extensions/workspaces/sessions/(backend)/api/computer-use/`, so the\n * mount is stated once, by the folder that creates it.\n *\n * The paths come from `COMPUTER_USE_ROUTES` rather than being written out\n * again. That table already addressed the broker from the hub channel and from\n * the broker's own dispatcher, and a second copy here is exactly the\n * disagreement this file exists to prevent. The dispatcher now reads this\n * table, so the page, the broker and the hub all resolve one set of strings.\n *\n * Activation, status, cancellation and recording reads are reachable from a browser. The `/agent/` and `/hub/` routes\n * each demand a host-issued bearer token and answer 404 without one; they are\n * declared here because they are this API's surface, not because a page calls\n * them.\n */\nconst routes = {\n artifact: {\n method: 'GET',\n path: COMPUTER_USE_ROUTES.artifact,\n query: ['artifactId', 'offset'],\n raw: true,\n },\n activationState: {\n method: 'GET',\n path: COMPUTER_USE_ROUTES.activate,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n cancelActivation: {\n method: 'DELETE',\n path: COMPUTER_USE_ROUTES.activate,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n activate: {\n method: 'POST',\n path: COMPUTER_USE_ROUTES.activate,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n agentState: {\n method: 'GET',\n path: COMPUTER_USE_ROUTES.agentState,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n /** Answers whatever the admitted Desktop provider returned, which is runtime-defined JSON. */\n agentObserve: {\n method: 'POST',\n path: COMPUTER_USE_ROUTES.agentObserve,\n response: undefined as unknown as ApiResponseOf<unknown>,\n },\n agentAction: {\n method: 'POST',\n path: COMPUTER_USE_ROUTES.agentAction,\n response: undefined as unknown as ApiResponseOf<unknown>,\n },\n agentStop: {\n method: 'POST',\n path: COMPUTER_USE_ROUTES.agentStop,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n hubState: {\n method: 'GET',\n path: COMPUTER_USE_ROUTES.hubState,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n /** Null until a reader has confirmed one; reading it moves the session to `activating`. */\n hubActivation: {\n method: 'GET',\n path: COMPUTER_USE_ROUTES.hubActivation,\n response: undefined as unknown as ApiResponseOf<ComputerUseActivationRequest | null>,\n },\n hubAuthorization: {\n method: 'GET',\n path: COMPUTER_USE_ROUTES.hubAuthorization,\n response: undefined as unknown as ApiResponseOf<{ readonly grantId: string; readonly expiresAt?: number } | null>,\n },\n hubNext: {\n method: 'GET',\n path: COMPUTER_USE_ROUTES.hubNext,\n response: undefined as unknown as ApiResponseOf<ComputerUseBrokerRequest | null>,\n },\n hubComplete: {\n method: 'POST',\n path: COMPUTER_USE_ROUTES.hubComplete,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n hubStop: {\n method: 'POST',\n path: COMPUTER_USE_ROUTES.hubStop,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n /** Desktop's macOS permission states, served by the hub's `desktop-permissions` mount. */\n desktopPermissions: {\n method: 'GET',\n path: DESKTOP_PERMISSIONS_PATH,\n response: undefined as unknown as ApiResponseOf<DesktopPermissionStates>,\n },\n /** Asks macOS for the body's permission on the Mac running Desktop; answers the states after. */\n requestDesktopPermission: {\n method: 'POST',\n path: DESKTOP_PERMISSIONS_PATH,\n response: undefined as unknown as ApiResponseOf<DesktopPermissionStates>,\n },\n} as const satisfies ApiRoutes;\n\nexport default routes;\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { createApiClient, nativeApiTransport, sessionApiAddress } from '@agimon-ai/po-core/native';\n\nimport routes from '../src/types/apiRoutes';\n\n/** Scopes the tree mounts 'computer-use' at for the computer-use mount. */\nexport const computerUseScopes = ['session'] as const;\n\nexport const computerUse = createApiClient(routes, {\n scopes: computerUseScopes,\n basePath: 'computer-use',\n transport: nativeApiTransport,\n sessionAddress: sessionApiAddress,\n});\n\n/** Scopes the tree mounts 'desktop-permissions' at for the desktop-permissions mount. */\nexport const desktopPermissionsScopes = ['global', 'workspace', 'session'] as const;\n\nexport const desktopPermissions = createApiClient(routes, {\n scopes: desktopPermissionsScopes,\n basePath: 'desktop-permissions',\n transport: nativeApiTransport,\n sessionAddress: sessionApiAddress,\n});\n","import type { WebPluginSlotProps } from '@agimon-ai/po-core/native';\nimport { Button, CheckIcon, fontOf, SegmentedControl } from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { computerUse as api } from '../../../../../../../generated/client.native';\nimport {\n COMPUTER_USE_DEFAULT_DURATION_MS,\n COMPUTER_USE_DURATION_CHOICES_MS,\n computerUseChannelType,\n} from '../../../../../../types/computerUseApi';\nimport type { ComputerUseSessionView } from '../../../../../../types/computerUseApi';\nimport { computerUse, updateComputerUseState } from '../../_lib/computerUseStore.native';\n\nfunction remaining(ms: number): string {\n const seconds = Math.max(0, Math.ceil(ms / 1000));\n return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')} left`;\n}\n\nconst DURATION_OPTIONS = COMPUTER_USE_DURATION_CHOICES_MS.map((choice) => ({\n value: String(choice),\n label: `${choice / 60_000} min`,\n}));\nexport function ComputerUseView({\n state,\n busy = false,\n error,\n submitting = false,\n durationMs = COMPUTER_USE_DEFAULT_DURATION_MS,\n onDurationChange,\n onActivate,\n onCancel,\n onStop,\n}: {\n state: ComputerUseSessionView;\n busy?: boolean;\n error?: string;\n submitting?: boolean;\n durationMs?: number;\n onDurationChange?: (durationMs: number) => void;\n onActivate: () => void;\n onCancel: () => void;\n onStop: () => void;\n}) {\n const pending = state.phase === 'awaiting_confirmation' || state.phase === 'activating';\n const active = state.phase === 'active' || state.phase === 'stopping';\n const failure = error ?? state.failure?.message;\n const expiresAt = state.phase === 'active' ? state.expiresAt : undefined;\n const [now, setNow] = useState(Date.now);\n useEffect(() => {\n if (expiresAt === undefined) return;\n const timer = setInterval(() => setNow(Date.now()), 1000);\n return () => clearInterval(timer);\n }, [expiresAt]);\n const left = expiresAt === undefined ? undefined : expiresAt - now;\n const total = state.durationMs ?? COMPUTER_USE_DEFAULT_DURATION_MS;\n const controlled =\n state.target?.scope === 'desktop'\n ? 'your whole desktop'\n : typeof state.target?.applicationName === 'string'\n ? state.target.applicationName\n : 'the chosen window';\n return (\n <View style={styles.panel}>\n <Text style={styles.title} accessibilityRole=\"header\">\n Computer use\n </Text>\n {busy ? <Text style={styles.detail}>Computer use is busy in another session.</Text> : null}\n {failure ? (\n <Text style={styles.error} accessibilityRole=\"alert\">\n {failure}\n </Text>\n ) : null}\n {state.artifact?.status === 'ready' ? (\n <View style={styles.row}>\n <View style={styles.check}>\n <CheckIcon size={12} color=\"rail\" />\n </View>\n <Text style={styles.text}>Recording saved to session artifacts.</Text>\n </View>\n ) : null}\n {state.artifact?.failure ? <Text style={styles.error}>{state.artifact.failure.message}</Text> : null}\n {pending ? (\n <>\n <Text style={styles.text}>Waiting for you on your Mac.</Text>\n <Text style={styles.detail}>Choose the whole desktop or one window, then confirm.</Text>\n <Button variant=\"outline\" disabled={submitting} onPress={onCancel}>\n Cancel activation\n </Button>\n </>\n ) : active ? (\n <>\n <View style={styles.row} accessibilityLiveRegion=\"polite\">\n <View style={styles.dot} />\n <Text style={styles.live}>\n {state.phase === 'stopping' ? 'Po is handing control back' : `Po is controlling ${controlled}`}\n </Text>\n </View>\n {left === undefined ? null : (\n <View style={styles.row}>\n <View\n style={styles.track}\n accessibilityRole=\"progressbar\"\n accessibilityLabel=\"Time left\"\n accessibilityValue={{ min: 0, max: total, now: Math.max(0, left) }}\n >\n <View style={[styles.fill, { width: `${Math.min(100, Math.max(0, (left / total) * 100))}%` }]} />\n </View>\n <Text style={styles.detail}>{remaining(left)}</Text>\n </View>\n )}\n <Button variant=\"outline\" disabled={submitting || state.phase === 'stopping'} onPress={onStop}>\n Stop computer use\n </Button>\n </>\n ) : (\n <>\n <Text style={styles.detail}>\n Po asks before it takes control. Choose the whole desktop or one window on your Mac. You can stop at any\n time.\n </Text>\n {onDurationChange ? (\n <SegmentedControl\n accessibilityLabel=\"For how long\"\n options={DURATION_OPTIONS}\n value={String(durationMs)}\n disabled={busy || submitting}\n onValueChange={(value) => onDurationChange(Number(value))}\n />\n ) : null}\n <Button variant=\"primary\" disabled={busy || submitting} onPress={onActivate}>\n Choose on Mac\n </Button>\n </>\n )}\n </View>\n );\n}\n\nfunction SessionPanel({ sessionId, sendSessionFrame }: WebPluginSlotProps & { sessionId: string }) {\n const subscribe = useCallback((listener: () => void) => {\n const subscription = computerUse.store.subscribe(listener);\n return () => subscription.unsubscribe();\n }, []);\n // Native plugins may not import @tanstack/react-store; it is not a native host module.\n const session = useSyncExternalStore(subscribe, () => computerUse.select(computerUse.store.state, sessionId));\n const [error, setError] = useState<string>();\n const [submitting, setSubmitting] = useState(false);\n const [durationMs, setDurationMs] = useState<number>(COMPUTER_USE_DEFAULT_DURATION_MS);\n const requests = useRef<AbortController | null>(null);\n\n useEffect(() => {\n const controller = new AbortController();\n requests.current = controller;\n let timer: ReturnType<typeof setTimeout> | undefined;\n sendSessionFrame(sessionId, { type: computerUseChannelType, payload: { action: 'status' } });\n const poll = async () => {\n try {\n const result = await api.session(sessionId).activationState({ signal: controller.signal });\n if (result.ok && !controller.signal.aborted) updateComputerUseState(sessionId, result.data);\n } catch {\n if (!controller.signal.aborted) setError('The session is unreachable.');\n }\n if (!controller.signal.aborted) timer = setTimeout(() => void poll(), 2000);\n };\n void poll();\n return () => {\n controller.abort();\n clearTimeout(timer);\n };\n }, [sessionId, sendSessionFrame]);\n\n const submit = async (action: 'activate' | 'cancel') => {\n const signal = requests.current?.signal;\n if (!signal || signal.aborted || submitting) return;\n setError(undefined);\n setSubmitting(true);\n try {\n const client = api.session(sessionId);\n const result =\n action === 'activate'\n ? await client.activate({ body: { durationMs }, signal })\n : await client.cancelActivation({ signal });\n if (signal.aborted) return;\n if (result.ok) updateComputerUseState(sessionId, result.data);\n else\n setError(\n result.status === 0 ? 'The session is unreachable.' : result.error || 'The activation request failed.',\n );\n } catch {\n if (!signal.aborted) setError('The activation request is unavailable.');\n } finally {\n if (!signal.aborted) setSubmitting(false);\n }\n };\n\n return (\n <ComputerUseView\n state={session.state}\n busy={session.busy}\n error={error}\n submitting={submitting}\n durationMs={durationMs}\n onDurationChange={setDurationMs}\n onActivate={() => void submit('activate')}\n onCancel={() => void submit('cancel')}\n onStop={() => {\n setError(undefined);\n try {\n sendSessionFrame(sessionId, { type: computerUseChannelType, payload: { action: 'stop' } });\n } catch {\n setError('The stop request is unavailable.');\n }\n }}\n />\n );\n}\n\nexport function ComputerUsePanel(props: WebPluginSlotProps) {\n return props.sessionId === null ? (\n <Text style={styles.detail}>Select a session.</Text>\n ) : (\n <SessionPanel key={props.sessionId} {...props} sessionId={props.sessionId} />\n );\n}\n\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n panel: { gap: theme.spacing(3) },\n title: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n fontWeight: '600',\n color: theme.colors.hi,\n paddingBottom: theme.spacing(2),\n borderBottomWidth: 1,\n borderBottomColor: theme.colors['border-soft'],\n },\n row: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2) },\n dot: { width: 8, height: 8, borderRadius: 4, backgroundColor: theme.colors.green },\n live: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeightRelaxed.base,\n color: theme.colors.green,\n },\n track: { flex: 1, height: 6, borderRadius: 3, overflow: 'hidden', backgroundColor: theme.colors['border-soft'] },\n fill: { height: '100%', borderRadius: 3, backgroundColor: theme.colors.green },\n check: {\n width: 20,\n height: 20,\n borderRadius: 10,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: theme.colors.green,\n },\n text: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeightRelaxed.base,\n color: theme.colors.text,\n },\n detail: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n color: theme.colors.dim,\n },\n error: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeightRelaxed.base,\n color: theme.colors.red,\n },\n}));\n","import { defineFill } from '@agimon-ai/po-core/native';\n\nimport { ComputerUsePanel } from './_components/ComputerUsePanel.native';\n\nexport default defineFill({ id: 'computer-use', slot: 'activity.computer-use', component: ComputerUsePanel });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport activityGroupComputerUse from '../src/extensions/workspaces/sessions/(frontend)/activity-group/computer-use.native';\nimport channelComputerUse from '../src/extensions/workspaces/sessions/(frontend)/channel/computer-use.native';\nimport fillComputerUse from '../src/extensions/workspaces/sessions/(frontend)/fill/ComputerUse.activity.computer-use.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'computer-use',\n session: {\n get activityGroups(): WebPluginContributions['activityGroups'] { return [via({ name: 'computer-use' }, activityGroupComputerUse)]; },\n get channels(): WebPluginContributions['channels'] { return [via({ channel: 'computer_use' }, channelComputerUse)]; },\n get fills(): WebPluginContributions['fills'] { return [via({ slot: 'activity.computer-use', id: 'computer-use' }, fillComputerUse)]; },\n },\n});\n"],"mappings":";;;;;;;;AAGA,MAAa,yBAAyB;AAEtC,MAAa,0BAA0B;AAEvC,MAAa,+BAA+B;AAC5C,MAAa,mCAAmC;;AAEhD,MAAa,mCAAmC;CAAC;CAAS;CAAS;AAA4B;;;;;;;;AAU/F,MAAa,sBAAsB;CACjC,UAAU;CACV,UAAU;CACV,YAAY;CACZ,cAAc;CACd,aAAa;CACb,WAAW;CACX,UAAU;CACV,eAAe;CACf,kBAAkB;CAClB,SAAS;CACT,aAAa;CACb,SAAS;AACX;;;;AC5BA,IAAA,gCAAe,oBAAoB;CACjC,MAAM;CACN,MAAM;CACN,OAAO;CACP,WAAW;CACX,eAAe;CACf,qBAAqB;AACvB,CAAC;ACAD,MAAaA,gBAAc,mBAAuC;CAJhE,OAAO;EAAE,WAAW;EAAI,UAAU;EAAG,MAAM;EAAG,OAAO;CAAW;CAChE,SAAS,CAAC;AAGsD,CAAY;;AAG9E,SAAgB,uBAAuB,WAAmB,OAA+B;CACvF,cAAY,OAAO,YAAY,YAC7B,QAAQ,MAAM,cAAc,MAAM,MAAM,WAAW,QAAQ,MAAM,WAAW;EAAE,GAAG;EAAS;CAAM,IAAI,OACtG;AACF;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,MAAa,qBAAqBA,cAAY,QAAmC;CAC/E,SAAS;CACT,MAAM,OAAO;EACX,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,MAAM,KAAK,KAAK,CAAC,MAAM,QAAQ,MAAM,OAAO,GAAG,OAAO;EACxF,IAAI,OAAO,MAAM,MAAM,UAAU,YAAY,OAAO,MAAM,MAAM,aAAa,UAAU,OAAO;EAC9F,OAAO;CACT;CACA,SAAS,UAAU,YAAY;AACjC,CAAC;;;AC7BD,IAAA,8BAAe,k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MAAMM,SAASoB;EACzBL,YAAYrB,MAAMsB,kBAAkBI;EACpCjB,OAAOT,MAAMU,OAAOiB;EAAGxB,mBAAA,CAAA,CAAA;CACzB;CACApF,OAAO;EACLqF,YAAYtH,OAAOkH,MAAMI,WAAWC,IAAI;EACxCC,UAAUN,MAAMM,SAASC;EACzBc,YAAYrB,MAAMsB,kBAAkBf;EACpCE,OAAOT,MAAMU,OAAOkB;EAAGzB,mBAAA,CAAA,CAAA;CACzB;AACF,EAAE;;;AC/QF,IAAA,mDAAe,WAAW;CAAE,IAAI;CAAgB,MAAM;CAAyB,WAAW;AAAiB,CAAC;;;ACG5G,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,SAAS;EACP,IAAI,iBAA2D;GAAE,OAAO,CAAC,IAAI,EAAE,MAAM,eAAe,GAAG4B,6BAAwB,CAAC;EAAG;EACnI,IAAI,WAA+C;GAAE,OAAO,CAAC,IAAI,EAAE,SAAS,eAAe,GAAGC,2BAAkB,CAAC;EAAG;EACpH,IAAI,QAAyC;GAAE,OAAO,CAAC,IAAI;IAAE,MAAM;IAAyB,IAAI;GAAe,GAAGC,gDAAe,CAAC;EAAG;CACvI;AACF,CAAC"}
1
+ {"version":3,"file":"native.mjs","names":["computerUse","WebPluginSlotProps","Button","CheckIcon","Dialog","DialogBody","DialogContent","DialogDescription","DialogFooter","DialogHeader","DialogTitle","DropdownMenu","DropdownMenuContent","DropdownMenuItem","DropdownMenuTrigger","fontOf","SegmentedControl","PoNativeTheme","useCallback","useEffect","useRef","useState","useSyncExternalStore","StyleSheet","computerUse","api","COMPUTER_USE_DEFAULT_DURATION_MS","COMPUTER_USE_DURATION_CHOICES_MS","computerUseChannelType","ComputerUseSessionView","updateComputerUseState","text","value","fallback","String","remaining","ms","seconds","Math","max","ceil","floor","padStart","DURATION_OPTIONS","map","choice","label","ComputerUseView","state","targets","busy","error","submitting","durationMs","onDurationChange","onActivate","onCancel","onStop","Record","target","selected","setSelected","confirmation","setConfirmation","choices","scope","applicationName","windowTitle","windowId","chosen","pending","phase","active","failure","message","expiresAt","undefined","now","setNow","Date","timer","setInterval","clearInterval","left","total","controlled","styles","panel","title","detail","artifact","status","row","check","dot","live","track","min","fill","width","index","Number","Object","freeze","SessionPanel","sessionId","sendSessionFrame","subscribe","listener","subscription","store","unsubscribe","session","select","setError","setSubmitting","setDurationMs","requests","AbortController","controller","current","ReturnType","setTimeout","type","payload","action","poll","result","activationState","signal","ok","aborted","data","abort","clearTimeout","submit","approvedDurationMs","client","activate","body","confirmed","cancelActivation","duration","ComputerUsePanel","props","ComputerUseConfirmation","onConfirm","desktop","open","create","theme","gap","spacing","uni__dependencies","fontFamily","sans","fontSize","base","fontWeight","color","colors","hi","paddingBottom","borderBottomWidth","borderBottomColor","flexDirection","alignItems","height","borderRadius","backgroundColor","green","lineHeight","lineHeightRelaxed","flex","overflow","justifyContent","sm","dim","red","computerUse","api","activityGroupComputerUse","channelComputerUse","fillComputerUse"],"sources":["../../src/types/computerUseApi.ts","../../src/extensions/workspaces/sessions/(frontend)/activity-group/computer-use.native.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/computerUseStore.native.ts","../../src/extensions/workspaces/sessions/(frontend)/channel/computer-use.native.ts","../../src/types/apiRoutes.ts","../../generated/client.native.ts","../../src/extensions/workspaces/sessions/(frontend)/fill/_components/ComputerUsePanel.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/fill/ComputerUse.activity.computer-use.native.tsx","../../generated/native.ts"],"sourcesContent":["import type { PoApiCaller } from '@agimon-ai/po-core/packageApi';\n\nexport const API_BASE_PATH = 'computer-use';\nexport const computerUseChannelType = 'computer_use_state';\nexport const COMPUTER_USE_MODE_ID = 'computer-use';\nexport const COMPUTER_USE_STATUS_KEY = 'po-computer-use';\nexport const COMPUTER_USE_MODE_STATUS_KEY = 'po-computer-use-mode';\nexport const COMPUTER_USE_MAX_DURATION_MS = 1_800 * 1_000;\nexport const COMPUTER_USE_DEFAULT_DURATION_MS = 300 * 1_000;\n/** The session lengths a person can pick when granting control, up to the maximum. */\nexport const COMPUTER_USE_DURATION_CHOICES_MS = [\n COMPUTER_USE_DEFAULT_DURATION_MS,\n 900_000,\n COMPUTER_USE_MAX_DURATION_MS,\n] as const;\nexport const COMPUTER_USE_CONFIRMATION_WINDOW_MS = 2 * 60 * 1_000;\n\n/**\n * Every path this API answers on, below its mount.\n *\n * The typed route table in `./apiRoutes` is built from this, the dispatcher\n * reads that table, and the hub channel addresses the broker with these same\n * strings, so a route cannot move on one side alone.\n */\nexport const COMPUTER_USE_ROUTES = {\n activate: '/activate',\n artifact: '/artifact',\n agentState: '/agent/state',\n agentObserve: '/agent/observe',\n agentAction: '/agent/action',\n agentStop: '/agent/stop',\n hubState: '/hub/state',\n hubActivation: '/hub/activation',\n hubAuthorization: '/hub/authorization',\n hubNext: '/hub/next',\n hubComplete: '/hub/complete',\n hubStop: '/hub/stop',\n} as const;\n\nexport const COMPUTER_USE_WAKE_LIMIT = 1_000_000;\n\nexport interface ComputerUseArtifactView {\n readonly artifactId: string;\n readonly status: 'ready' | 'failed';\n readonly sizeBytes?: number;\n readonly downloadUrl?: string;\n readonly previewUrl?: string;\n readonly actionCount?: number;\n readonly completedAt?: string;\n readonly failure?: { readonly code: string; readonly message: string };\n}\n\nexport interface ComputerUseSessionView {\n readonly sessionId: string;\n readonly revision: number;\n readonly wake: number;\n readonly phase: 'inactive' | 'awaiting_confirmation' | 'activating' | 'active' | 'stopping' | 'failed';\n readonly requestId?: string;\n readonly target?: Record<string, unknown>;\n readonly durationMs?: number;\n readonly expiresAt?: number;\n readonly failure?: { readonly code: string; readonly message: string };\n readonly artifact?: ComputerUseArtifactView;\n}\n\nexport interface ComputerUseActivationRequest {\n readonly requestId: string;\n readonly target?: Record<string, unknown>;\n readonly durationSeconds: number;\n readonly createdAt: number;\n readonly confirmationExpiresAt: number;\n /** Set by the session broker only after the person approves the in-app dialog. */\n readonly confirmedAt?: number;\n readonly caller: PoApiCaller;\n}\n\nexport interface ComputerUseBrokerRequest {\n readonly id: string;\n readonly operation: 'observe' | 'act';\n readonly payload?: unknown;\n readonly grantId: string;\n readonly sequence?: number;\n}\n\nexport interface ComputerUseChannelPayload {\n readonly state: ComputerUseSessionView;\n readonly targets: readonly Record<string, unknown>[];\n readonly busy?: true;\n}\n\nexport type ComputerUseBrowserCommand = { readonly action: 'status' | 'targets' | 'stop' | 'artifacts' };\n","import { defineActivityGroup } from '@agimon-ai/po-core/native';\n\nimport { COMPUTER_USE_STATUS_KEY } from '../../../../../types/computerUseApi';\n\n/** Remote clients request control from the Desktop host through their session Activity. */\nexport default defineActivityGroup({\n name: 'computer-use',\n keys: 'c e',\n order: 70,\n statusKey: COMPUTER_USE_STATUS_KEY,\n hideWhenEmpty: true,\n marksBackgroundWork: false,\n});\n","import { defineSessionStore } from '@agimon-ai/po-core/native';\n\nimport { computerUseChannelType } from '../../../../../types/computerUseApi';\nimport type { ComputerUseChannelPayload, ComputerUseSessionView } from '../../../../../types/computerUseApi';\n\nexport interface ComputerUseSession extends ComputerUseChannelPayload {}\n\nconst initialState: ComputerUseSession = {\n state: { sessionId: '', revision: 0, wake: 0, phase: 'inactive' },\n targets: [],\n};\n\nexport const computerUse = defineSessionStore<ComputerUseSession>(initialState);\n\n/** Revision zero must hydrate the empty selector once; equal status polls then retain identity. */\nexport function updateComputerUseState(sessionId: string, state: ComputerUseSessionView) {\n computerUse.update(sessionId, (current) =>\n current.state.sessionId === '' || state.revision > current.state.revision ? { ...current, state } : current,\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport const computerUseChannel = computerUse.channel<ComputerUseChannelPayload>({\n channel: computerUseChannelType,\n parse(input) {\n if (!isRecord(input) || !isRecord(input.state) || !Array.isArray(input.targets)) return null;\n if (typeof input.state.phase !== 'string' || typeof input.state.revision !== 'number') return null;\n return input as unknown as ComputerUseChannelPayload;\n },\n reduce: (_current, payload) => payload,\n});\n","import { defineChannelFile } from '@agimon-ai/po-core/native';\n\nimport { computerUseChannel } from '../_lib/computerUseStore.native';\n\nexport default defineChannelFile(computerUseChannel);\n","import type { ApiResponseOf, ApiRoutes } from '@agimon-ai/po-core/web';\n\nimport {\n COMPUTER_USE_ROUTES,\n type ComputerUseActivationRequest,\n type ComputerUseBrokerRequest,\n type ComputerUseSessionView,\n} from './computerUseApi';\nimport { DESKTOP_PERMISSIONS_PATH, type DesktopPermissionStates } from './desktopPermissions';\n\n/**\n * This package's routes, as data.\n *\n * No scope and no base path: the build reads both off\n * `src/extensions/workspaces/sessions/(backend)/api/computer-use/`, so the\n * mount is stated once, by the folder that creates it.\n *\n * The paths come from `COMPUTER_USE_ROUTES` rather than being written out\n * again. That table already addressed the broker from the hub channel and from\n * the broker's own dispatcher, and a second copy here is exactly the\n * disagreement this file exists to prevent. The dispatcher now reads this\n * table, so the page, the broker and the hub all resolve one set of strings.\n *\n * Activation, status, cancellation and recording reads are reachable from a browser. The `/agent/` and `/hub/` routes\n * each demand a host-issued bearer token and answer 404 without one; they are\n * declared here because they are this API's surface, not because a page calls\n * them.\n */\nconst routes = {\n artifact: {\n method: 'GET',\n path: COMPUTER_USE_ROUTES.artifact,\n query: ['artifactId', 'offset'],\n raw: true,\n },\n activationState: {\n method: 'GET',\n path: COMPUTER_USE_ROUTES.activate,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n cancelActivation: {\n method: 'DELETE',\n path: COMPUTER_USE_ROUTES.activate,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n activate: {\n method: 'POST',\n path: COMPUTER_USE_ROUTES.activate,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n agentState: {\n method: 'GET',\n path: COMPUTER_USE_ROUTES.agentState,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n /** Answers whatever the admitted Desktop provider returned, which is runtime-defined JSON. */\n agentObserve: {\n method: 'POST',\n path: COMPUTER_USE_ROUTES.agentObserve,\n response: undefined as unknown as ApiResponseOf<unknown>,\n },\n agentAction: {\n method: 'POST',\n path: COMPUTER_USE_ROUTES.agentAction,\n response: undefined as unknown as ApiResponseOf<unknown>,\n },\n agentStop: {\n method: 'POST',\n path: COMPUTER_USE_ROUTES.agentStop,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n hubState: {\n method: 'GET',\n path: COMPUTER_USE_ROUTES.hubState,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n /** Null until a reader has confirmed one; reading it moves the session to `activating`. */\n hubActivation: {\n method: 'GET',\n path: COMPUTER_USE_ROUTES.hubActivation,\n response: undefined as unknown as ApiResponseOf<ComputerUseActivationRequest | null>,\n },\n hubAuthorization: {\n method: 'GET',\n path: COMPUTER_USE_ROUTES.hubAuthorization,\n response: undefined as unknown as ApiResponseOf<{ readonly grantId: string; readonly expiresAt?: number } | null>,\n },\n hubNext: {\n method: 'GET',\n path: COMPUTER_USE_ROUTES.hubNext,\n response: undefined as unknown as ApiResponseOf<ComputerUseBrokerRequest | null>,\n },\n hubComplete: {\n method: 'POST',\n path: COMPUTER_USE_ROUTES.hubComplete,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n hubStop: {\n method: 'POST',\n path: COMPUTER_USE_ROUTES.hubStop,\n response: undefined as unknown as ApiResponseOf<ComputerUseSessionView>,\n },\n /** Desktop's macOS permission states, served by the hub's `desktop-permissions` mount. */\n desktopPermissions: {\n method: 'GET',\n path: DESKTOP_PERMISSIONS_PATH,\n response: undefined as unknown as ApiResponseOf<DesktopPermissionStates>,\n },\n /** Asks macOS for the body's permission on the Mac running Desktop; answers the states after. */\n requestDesktopPermission: {\n method: 'POST',\n path: DESKTOP_PERMISSIONS_PATH,\n response: undefined as unknown as ApiResponseOf<DesktopPermissionStates>,\n },\n} as const satisfies ApiRoutes;\n\nexport default routes;\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { createApiClient, nativeApiTransport, sessionApiAddress } from '@agimon-ai/po-core/native';\n\nimport routes from '../src/types/apiRoutes';\n\n/** Scopes the tree mounts 'computer-use' at for the computer-use mount. */\nexport const computerUseScopes = ['session'] as const;\n\nexport const computerUse = createApiClient(routes, {\n scopes: computerUseScopes,\n basePath: 'computer-use',\n transport: nativeApiTransport,\n sessionAddress: sessionApiAddress,\n});\n\n/** Scopes the tree mounts 'desktop-permissions' at for the desktop-permissions mount. */\nexport const desktopPermissionsScopes = ['global', 'workspace', 'session'] as const;\n\nexport const desktopPermissions = createApiClient(routes, {\n scopes: desktopPermissionsScopes,\n basePath: 'desktop-permissions',\n transport: nativeApiTransport,\n sessionAddress: sessionApiAddress,\n});\n","import type { WebPluginSlotProps } from '@agimon-ai/po-core/native';\nimport {\n Button,\n CheckIcon,\n Dialog,\n DialogBody,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n fontOf,\n SegmentedControl,\n} from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { computerUse as api } from '../../../../../../../generated/client.native';\nimport {\n COMPUTER_USE_DEFAULT_DURATION_MS,\n COMPUTER_USE_DURATION_CHOICES_MS,\n computerUseChannelType,\n} from '../../../../../../types/computerUseApi';\nimport type { ComputerUseSessionView } from '../../../../../../types/computerUseApi';\nimport { computerUse, updateComputerUseState } from '../../_lib/computerUseStore.native';\n\nfunction text(value: unknown, fallback: string): string {\n return typeof value === 'string' || typeof value === 'number' ? String(value) : fallback;\n}\n\nfunction remaining(ms: number): string {\n const seconds = Math.max(0, Math.ceil(ms / 1000));\n return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')} left`;\n}\n\nconst DURATION_OPTIONS = COMPUTER_USE_DURATION_CHOICES_MS.map((choice) => ({\n value: String(choice),\n label: `${choice / 60_000} min`,\n}));\nexport function ComputerUseView({\n state,\n targets = [],\n busy = false,\n error,\n submitting = false,\n durationMs = COMPUTER_USE_DEFAULT_DURATION_MS,\n onDurationChange,\n onActivate,\n onCancel,\n onStop,\n}: {\n state: ComputerUseSessionView;\n targets?: readonly Record<string, unknown>[];\n busy?: boolean;\n error?: string;\n submitting?: boolean;\n durationMs?: number;\n onDurationChange?: (durationMs: number) => void;\n onActivate: (target: Record<string, unknown>, durationMs: number) => void;\n onCancel: () => void;\n onStop: () => void;\n}) {\n const [selected, setSelected] = useState(0);\n const [confirmation, setConfirmation] = useState<{ target: Record<string, unknown>; durationMs: number }>();\n const choices = [\n { label: 'Whole desktop', target: { scope: 'desktop' } },\n ...targets.map((target) => ({\n label: `${text(target.applicationName, 'Application')}: ${text(target.windowTitle, text(target.windowId, 'Window'))}`,\n target,\n })),\n ];\n const chosen = choices[selected] ?? choices[0]!;\n const pending = state.phase === 'awaiting_confirmation' || state.phase === 'activating';\n const active = state.phase === 'active' || state.phase === 'stopping';\n const failure = error ?? state.failure?.message;\n const expiresAt = state.phase === 'active' ? state.expiresAt : undefined;\n const [now, setNow] = useState(Date.now);\n useEffect(() => {\n if (expiresAt === undefined) return;\n const timer = setInterval(() => setNow(Date.now()), 1000);\n return () => clearInterval(timer);\n }, [expiresAt]);\n const left = expiresAt === undefined ? undefined : expiresAt - now;\n const total = state.durationMs ?? COMPUTER_USE_DEFAULT_DURATION_MS;\n const controlled =\n state.target?.scope === 'desktop'\n ? 'your whole desktop'\n : typeof state.target?.applicationName === 'string'\n ? state.target.applicationName\n : 'the chosen window';\n return (\n <View style={styles.panel}>\n <Text style={styles.title} accessibilityRole=\"header\">\n Computer use\n </Text>\n {busy ? <Text style={styles.detail}>Computer use is busy in another session.</Text> : null}\n {failure ? (\n <Text style={styles.error} accessibilityRole=\"alert\">\n {failure}\n </Text>\n ) : null}\n {state.artifact?.status === 'ready' ? (\n <View style={styles.row}>\n <View style={styles.check}>\n <CheckIcon size={12} color=\"rail\" />\n </View>\n <Text style={styles.text}>Recording saved to session artifacts.</Text>\n </View>\n ) : null}\n {state.artifact?.failure ? <Text style={styles.error}>{state.artifact.failure.message}</Text> : null}\n {pending ? (\n <>\n <Text style={styles.text}>Desktop activation is pending.</Text>\n <Button variant=\"outline\" disabled={submitting} onPress={onCancel}>\n Cancel activation\n </Button>\n </>\n ) : active ? (\n <>\n <View style={styles.row} accessibilityLiveRegion=\"polite\">\n <View style={styles.dot} />\n <Text style={styles.live}>\n {state.phase === 'stopping' ? 'Po is handing control back' : `Po is controlling ${controlled}`}\n </Text>\n </View>\n {left === undefined ? null : (\n <View style={styles.row}>\n <View\n style={styles.track}\n accessibilityRole=\"progressbar\"\n accessibilityLabel=\"Time left\"\n accessibilityValue={{ min: 0, max: total, now: Math.max(0, left) }}\n >\n <View style={[styles.fill, { width: `${Math.min(100, Math.max(0, (left / total) * 100))}%` }]} />\n </View>\n <Text style={styles.detail}>{remaining(left)}</Text>\n </View>\n )}\n <Button variant=\"outline\" disabled={submitting || state.phase === 'stopping'} onPress={onStop}>\n Stop computer use\n </Button>\n </>\n ) : (\n <>\n <Text style={styles.detail}>Po asks before it takes control. You can stop at any time.</Text>\n <DropdownMenu>\n <DropdownMenuTrigger\n variant=\"outline\"\n disabled={busy || submitting}\n accessibilityLabel=\"What Po may control\"\n >\n {chosen.label}\n </DropdownMenuTrigger>\n <DropdownMenuContent>\n {choices.map((choice, index) => (\n <DropdownMenuItem key={`${index}:${choice.label}`} onSelect={() => setSelected(index)}>\n {choice.label}\n </DropdownMenuItem>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n {onDurationChange ? (\n <SegmentedControl\n accessibilityLabel=\"For how long\"\n options={DURATION_OPTIONS}\n value={String(durationMs)}\n disabled={busy || submitting}\n onValueChange={(value) => onDurationChange(Number(value))}\n />\n ) : null}\n <Button\n variant=\"primary\"\n disabled={busy || submitting}\n onPress={() => setConfirmation({ target: Object.freeze({ ...chosen.target }), durationMs })}\n >\n Request activation\n </Button>\n </>\n )}\n {confirmation ? (\n <ComputerUseConfirmation\n target={confirmation.target}\n durationMs={confirmation.durationMs}\n onCancel={() => setConfirmation(undefined)}\n onConfirm={() => {\n setConfirmation(undefined);\n onActivate(confirmation.target, confirmation.durationMs);\n }}\n />\n ) : null}\n </View>\n );\n}\n\nfunction SessionPanel({ sessionId, sendSessionFrame }: WebPluginSlotProps & { sessionId: string }) {\n const subscribe = useCallback((listener: () => void) => {\n const subscription = computerUse.store.subscribe(listener);\n return () => subscription.unsubscribe();\n }, []);\n // Native plugins may not import @tanstack/react-store; it is not a native host module.\n const session = useSyncExternalStore(subscribe, () => computerUse.select(computerUse.store.state, sessionId));\n const [error, setError] = useState<string>();\n const [submitting, setSubmitting] = useState(false);\n const [durationMs, setDurationMs] = useState<number>(COMPUTER_USE_DEFAULT_DURATION_MS);\n const requests = useRef<AbortController | null>(null);\n\n useEffect(() => {\n const controller = new AbortController();\n requests.current = controller;\n let timer: ReturnType<typeof setTimeout> | undefined;\n sendSessionFrame(sessionId, { type: computerUseChannelType, payload: { action: 'status' } });\n sendSessionFrame(sessionId, { type: computerUseChannelType, payload: { action: 'targets' } });\n const poll = async () => {\n try {\n const result = await api.session(sessionId).activationState({ signal: controller.signal });\n if (result.ok && !controller.signal.aborted) updateComputerUseState(sessionId, result.data);\n } catch {\n if (!controller.signal.aborted) setError('The session is unreachable.');\n }\n if (!controller.signal.aborted) timer = setTimeout(() => void poll(), 2000);\n };\n void poll();\n return () => {\n controller.abort();\n clearTimeout(timer);\n };\n }, [sessionId, sendSessionFrame]);\n\n const submit = async (\n action: 'activate' | 'cancel',\n target?: Record<string, unknown>,\n approvedDurationMs = durationMs,\n ) => {\n const signal = requests.current?.signal;\n if (!signal || signal.aborted || submitting) return;\n setError(undefined);\n setSubmitting(true);\n try {\n const client = api.session(sessionId);\n const result =\n action === 'activate'\n ? await client.activate({ body: { target, durationMs: approvedDurationMs, confirmed: true }, signal })\n : await client.cancelActivation({ signal });\n if (signal.aborted) return;\n if (result.ok) updateComputerUseState(sessionId, result.data);\n else\n setError(\n result.status === 0 ? 'The session is unreachable.' : result.error || 'The activation request failed.',\n );\n } catch {\n if (!signal.aborted) setError('The activation request is unavailable.');\n } finally {\n if (!signal.aborted) setSubmitting(false);\n }\n };\n\n return (\n <ComputerUseView\n state={session.state}\n targets={session.targets}\n busy={session.busy}\n error={error}\n submitting={submitting}\n durationMs={durationMs}\n onDurationChange={setDurationMs}\n onActivate={(target, duration) => void submit('activate', target, duration)}\n onCancel={() => void submit('cancel')}\n onStop={() => {\n setError(undefined);\n try {\n sendSessionFrame(sessionId, { type: computerUseChannelType, payload: { action: 'stop' } });\n } catch {\n setError('The stop request is unavailable.');\n }\n }}\n />\n );\n}\n\nexport function ComputerUsePanel(props: WebPluginSlotProps) {\n return props.sessionId === null ? (\n <Text style={styles.detail}>Select a session.</Text>\n ) : (\n <SessionPanel key={props.sessionId} {...props} sessionId={props.sessionId} />\n );\n}\n\nexport function ComputerUseConfirmation({\n target,\n durationMs,\n onConfirm,\n onCancel,\n}: {\n target: Record<string, unknown>;\n durationMs: number;\n onConfirm: () => void;\n onCancel: () => void;\n}) {\n const desktop = target.scope === 'desktop';\n return (\n <Dialog\n open\n onOpenChange={(open) => {\n if (!open) onCancel();\n }}\n >\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Allow Po to control {desktop ? 'your whole desktop' : 'this window'}?</DialogTitle>\n </DialogHeader>\n <DialogBody>\n <DialogDescription>\n {desktop\n ? 'Every app window on the main display, except Po and system security windows.'\n : `${text(target.applicationName, 'Application')}: ${text(target.windowTitle, text(target.windowId, 'Window'))}`}\n </DialogDescription>\n <Text style={styles.text}>For {durationMs / 60_000} minutes. You can stop at any time.</Text>\n <Text style={styles.detail}>\n Po records {desktop ? 'the main display' : 'this window'}, system sound and microphone audio when permission\n is granted.\n </Text>\n <Text style={styles.detail}>Only this session and its approved device receive control.</Text>\n <DialogFooter>\n <Button variant=\"outline\" onPress={onCancel}>\n Cancel\n </Button>\n <Button variant=\"primary\" onPress={onConfirm}>\n Allow control\n </Button>\n </DialogFooter>\n </DialogBody>\n </DialogContent>\n </Dialog>\n );\n}\n\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n panel: { gap: theme.spacing(3) },\n title: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n fontWeight: '600',\n color: theme.colors.hi,\n paddingBottom: theme.spacing(2),\n borderBottomWidth: 1,\n borderBottomColor: theme.colors['border-soft'],\n },\n row: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2) },\n dot: { width: 8, height: 8, borderRadius: 4, backgroundColor: theme.colors.green },\n live: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeightRelaxed.base,\n color: theme.colors.green,\n },\n track: { flex: 1, height: 6, borderRadius: 3, overflow: 'hidden', backgroundColor: theme.colors['border-soft'] },\n fill: { height: '100%', borderRadius: 3, backgroundColor: theme.colors.green },\n check: {\n width: 20,\n height: 20,\n borderRadius: 10,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: theme.colors.green,\n },\n text: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeightRelaxed.base,\n color: theme.colors.text,\n },\n detail: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n color: theme.colors.dim,\n },\n error: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeightRelaxed.base,\n color: theme.colors.red,\n },\n}));\n","import { defineFill } from '@agimon-ai/po-core/native';\n\nimport { ComputerUsePanel } from './_components/ComputerUsePanel.native';\n\nexport default defineFill({ id: 'computer-use', slot: 'activity.computer-use', component: ComputerUsePanel });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport activityGroupComputerUse from '../src/extensions/workspaces/sessions/(frontend)/activity-group/computer-use.native';\nimport channelComputerUse from '../src/extensions/workspaces/sessions/(frontend)/channel/computer-use.native';\nimport fillComputerUse from '../src/extensions/workspaces/sessions/(frontend)/fill/ComputerUse.activity.computer-use.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'computer-use',\n session: {\n get activityGroups(): WebPluginContributions['activityGroups'] { return [via({ name: 'computer-use' }, activityGroupComputerUse)]; },\n get channels(): WebPluginContributions['channels'] { return [via({ channel: 'computer_use' }, channelComputerUse)]; },\n get fills(): WebPluginContributions['fills'] { return [via({ slot: 'activity.computer-use', id: 'computer-use' }, fillComputerUse)]; },\n },\n});\n"],"mappings":";;;;;;;;AAGA,MAAa,yBAAyB;AAEtC,MAAa,0BAA0B;AAEvC,MAAa,+BAA+B;AAC5C,MAAa,mCAAmC;;AAEhD,MAAa,mCAAmC;CAC9C;CACA;CACA;AACF;;;;;;;;AAUA,MAAa,sBAAsB;CACjC,UAAU;CACV,UAAU;CACV,YAAY;CACZ,cAAc;CACd,aAAa;CACb,WAAW;CACX,UAAU;CACV,eAAe;CACf,kBAAkB;CAClB,SAAS;CACT,aAAa;CACb,SAAS;AACX;;;;AChCA,IAAA,gCAAe,oBAAoB;CACjC,MAAM;CACN,MAAM;CACN,OAAO;CACP,WAAW;CACX,eAAe;CACf,qBAAqB;AACvB,CAAC;ACAD,MAAaA,gBAAc,mBAAuC;CAJhE,OAAO;EAAE,WAAW;EAAI,UAAU;EAAG,MAAM;EAAG,OAAO;CAAW;CAChE,SAAS,CAAC;AAGsD,CA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AG;EACpH,IAAI,QAAyC;GAAE,OAAO,CAAC,IAAI;IAAE,MAAM;IAAyB,IAAI;GAAe,GAAGC,gDAAe,CAAC;EAAG;CACvI;AACF,CAAC"}
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_extensionService = require("../extensionService-CC9-p-Av.cjs");
5
+ const require_extensionService = require("../extensionService-BS2Lz9R8.cjs");
6
6
  let node_path = require("node:path");
7
7
  node_path = require_extensionService.__toESM(node_path, 1);
8
8
  let node_crypto = require("node:crypto");
@@ -1,4 +1,4 @@
1
- import { a as routes, b as COMPUTER_USE_TOOL_NAMES, c as COMPUTER_USE_MODE_ID, d as computerUseChannelType, f as COMMAND_DESCRIPTION, g as COMPUTER_USE_CODEMODE_GUIDANCE, h as COMPUTER_USE_ARTIFACT_DIRECTORY, i as createComputerUseApi, l as COMPUTER_USE_ROUTES, m as COMPUTER_USE_ARTIFACTS_SERVICE, n as ComputerScriptExecutionError, o as isDesktopPermission, p as COMMAND_NAME, r as ComputerScriptRunner, s as API_BASE_PATH, t as DefaultComputerUseExtensionService, u as COMPUTER_USE_STATUS_KEY, v as COMPUTER_USE_RECORDING_CHUNK_BYTES } from "../extensionService-yFkQXjJz.mjs";
1
+ import { a as routes, b as COMPUTER_USE_TOOL_NAMES, c as COMPUTER_USE_MODE_ID, d as computerUseChannelType, f as COMMAND_DESCRIPTION, g as COMPUTER_USE_CODEMODE_GUIDANCE, h as COMPUTER_USE_ARTIFACT_DIRECTORY, i as createComputerUseApi, l as COMPUTER_USE_ROUTES, m as COMPUTER_USE_ARTIFACTS_SERVICE, n as ComputerScriptExecutionError, o as isDesktopPermission, p as COMMAND_NAME, r as ComputerScriptRunner, s as API_BASE_PATH, t as DefaultComputerUseExtensionService, u as COMPUTER_USE_STATUS_KEY, v as COMPUTER_USE_RECORDING_CHUNK_BYTES } from "../extensionService-DGTnZr5E.mjs";
2
2
  import path, { join, resolve } from "node:path";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { composeServerProviderOverrides, defineServerPlugin, packageResourcePath, readPackageResource } from "@agimon-ai/po-core/serverPlugin";
@@ -1,5 +1,5 @@
1
1
  import { createApiClient, defineActivityGroup, defineChannelFile, defineFill, defineMinorModeFile, defineSessionStore, defineSettingsPanel, defineSettingsSection, defineToolRenderer, defineWebPlugin, sessionApiAddress, toolResultTextLines } from "@agimon-ai/po-core/web";
2
- import { Badge, Button, CheckIcon, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, MessageLines, MonitorIcon, SettingsActions, SettingsCard, SettingsRow, SettingsRowDescription, SettingsRowText, SettingsRowTitle, SettingsSection, SettingsSectionDescription, SettingsSectionHeader, SettingsSectionTitle, ShieldIcon, collapseLines, toolTone } from "@agimon-ai/po-web-components";
2
+ import { Badge, Button, CheckIcon, Dialog, DialogBody, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, MessageLines, MonitorIcon, SettingsActions, SettingsCard, SettingsRow, SettingsRowDescription, SettingsRowText, SettingsRowTitle, SettingsSection, SettingsSectionDescription, SettingsSectionHeader, SettingsSectionTitle, ShieldIcon, collapseLines, toolTone } from "@agimon-ai/po-web-components";
3
3
  import { useCallback, useEffect, useState } from "react";
4
4
  import { browserTransport } from "@agimon-ai/po-web-security/browser";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -86,7 +86,7 @@ const COMPUTER_USE_MAX_DURATION_MS = 18e5;
86
86
  const COMPUTER_USE_DEFAULT_DURATION_MS = 3e5;
87
87
  /** The session lengths a person can pick when granting control, up to the maximum. */
88
88
  const COMPUTER_USE_DURATION_CHOICES_MS = [
89
- 3e5,
89
+ COMPUTER_USE_DEFAULT_DURATION_MS,
90
90
  9e5,
91
91
  COMPUTER_USE_MAX_DURATION_MS
92
92
  ];
@@ -461,11 +461,15 @@ function remaining(ms) {
461
461
  const seconds = Math.max(0, Math.ceil(ms / 1e3));
462
462
  return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")} left`;
463
463
  }
464
- function ComputerUsePanel({ sessionId, sendSessionFrame }) {
464
+ function ComputerUsePanel(props) {
465
+ return /* @__PURE__ */ jsx(SessionPanel, { ...props }, props.sessionId ?? "none");
466
+ }
467
+ function SessionPanel({ sessionId, sendSessionFrame }) {
465
468
  const session = useStore(computerUse.store, (state) => computerUse.select(state, sessionId));
466
469
  const [selected, setSelected] = useState(0);
467
470
  const [durationMs, setDurationMs] = useState(COMPUTER_USE_DEFAULT_DURATION_MS);
468
- const [confirmationTarget, setConfirmationTarget] = useState();
471
+ const [confirmation, setConfirmation] = useState();
472
+ const [submitting, setSubmitting] = useState(false);
469
473
  const [error, setError] = useState();
470
474
  const [now, setNow] = useState(Date.now);
471
475
  const expiresAt = session.state.phase === "active" ? session.state.expiresAt : void 0;
@@ -518,29 +522,32 @@ function ComputerUsePanel({ sessionId, sendSessionFrame }) {
518
522
  const choices = [{
519
523
  label: "Whole desktop",
520
524
  target: DESKTOP_TARGET
521
- }, ...session.targets.length === 0 ? [{ label: "Choose window on Mac" }] : session.targets.map((item) => ({
522
- label: text(item.applicationName, text(item.windowTitle, text(item.windowId, "Window"))),
525
+ }, ...session.targets.map((item) => ({
526
+ label: `${text(item.applicationName, "Application")}: ${text(item.windowTitle, text(item.windowId, "Window"))}`,
523
527
  target: item
524
528
  }))];
525
529
  const target = (choices[selected] ?? choices[0]).target;
526
- const desktopConfirmation = confirmationTarget?.scope === "desktop";
527
530
  const artifact = state.artifact;
528
531
  const controlled = state.target?.scope === "desktop" ? "your whole desktop" : text(state.target?.applicationName, "the chosen window");
529
532
  const left = expiresAt === void 0 ? void 0 : expiresAt - now;
530
533
  const total = state.durationMs ?? 3e5;
531
- const confirm = async (chosenTarget = confirmationTarget) => {
534
+ const confirm = async () => {
535
+ if (!confirmation || confirmation.sessionId !== sessionId || submitting) return;
536
+ const approved = confirmation;
537
+ setConfirmation(void 0);
538
+ setSubmitting(true);
532
539
  setError(void 0);
533
540
  try {
534
541
  const result = await computerUse$1.session(sessionId).activate({ body: {
535
- ...chosenTarget === void 0 ? {} : { target: chosenTarget },
536
- durationMs
542
+ target: approved.target,
543
+ durationMs: approved.durationMs,
544
+ confirmed: true
537
545
  } });
538
546
  if (!result.ok) {
539
547
  if (result.status === 0) setError("The session is unreachable.");
540
548
  else setError(result.error === "" ? `Activation failed with HTTP ${result.status}.` : result.error);
541
549
  return;
542
550
  }
543
- setConfirmationTarget(void 0);
544
551
  computerUse.update(sessionId, (current) => ({
545
552
  ...current,
546
553
  state: result.data
@@ -548,6 +555,8 @@ function ComputerUsePanel({ sessionId, sendSessionFrame }) {
548
555
  send({ action: "status" });
549
556
  } catch {
550
557
  setError("The activation request is unavailable.");
558
+ } finally {
559
+ setSubmitting(false);
551
560
  }
552
561
  };
553
562
  return /* @__PURE__ */ jsxs("div", {
@@ -599,7 +608,7 @@ function ComputerUsePanel({ sessionId, sendSessionFrame }) {
599
608
  className: "text-po-red",
600
609
  children: artifact.failure.message
601
610
  }) : null,
602
- (state.phase === "inactive" || state.phase === "failed") && confirmationTarget === void 0 ? /* @__PURE__ */ jsxs("div", {
611
+ state.phase === "inactive" || state.phase === "failed" ? /* @__PURE__ */ jsxs("div", {
603
612
  className: "flex flex-col gap-2",
604
613
  children: [
605
614
  /* @__PURE__ */ jsx("label", {
@@ -639,45 +648,24 @@ function ComputerUsePanel({ sessionId, sendSessionFrame }) {
639
648
  /* @__PURE__ */ jsx(Button, {
640
649
  size: "sm",
641
650
  type: "button",
642
- disabled: Boolean(session.busy),
651
+ disabled: Boolean(session.busy) || submitting,
643
652
  variant: "primary",
644
653
  onClick: () => {
645
- if (target === void 0) confirm();
646
- else setConfirmationTarget(Object.freeze({ ...target }));
654
+ setConfirmation({
655
+ sessionId,
656
+ target: Object.freeze({ ...target }),
657
+ durationMs
658
+ });
647
659
  },
648
- children: target === void 0 ? "Choose window on Mac" : "Request activation"
660
+ children: "Request activation"
649
661
  })
650
662
  ]
651
663
  }) : null,
652
- confirmationTarget !== void 0 ? /* @__PURE__ */ jsxs("div", {
653
- className: "rounded border border-po-blue p-3",
654
- children: [
655
- /* @__PURE__ */ jsx("strong", { children: "Confirm computer control" }),
656
- /* @__PURE__ */ jsx("p", {
657
- className: "my-2 text-po-text",
658
- children: desktopConfirmation ? "Your whole desktop" : `${text(confirmationTarget.applicationName, "Application")}: ${text(confirmationTarget.windowTitle, text(confirmationTarget.windowId, "Window"))}`
659
- }),
660
- /* @__PURE__ */ jsx("p", {
661
- className: "my-2 text-po-dim",
662
- children: desktopConfirmation ? `Confirm a ${durationMs / 6e4} minute session for every app on your main display. Po's own windows stay out of reach.` : `Confirm a ${durationMs / 6e4} minute session for this exact application window.`
663
- }),
664
- /* @__PURE__ */ jsxs("div", {
665
- className: "flex gap-2",
666
- children: [/* @__PURE__ */ jsx(Button, {
667
- size: "sm",
668
- type: "button",
669
- variant: "primary",
670
- onClick: () => void confirm(),
671
- children: "Confirm"
672
- }), /* @__PURE__ */ jsx(Button, {
673
- size: "sm",
674
- type: "button",
675
- className: "min-h-7 rounded border border-po-border bg-po-panel px-2 py-1",
676
- onClick: () => setConfirmationTarget(void 0),
677
- children: "Cancel"
678
- })]
679
- })
680
- ]
664
+ confirmation?.sessionId === sessionId ? /* @__PURE__ */ jsx(ComputerUseConfirmation, {
665
+ target: confirmation.target,
666
+ durationMs: confirmation.durationMs,
667
+ onConfirm: () => void confirm(),
668
+ onCancel: () => setConfirmation(void 0)
681
669
  }) : null,
682
670
  state.phase === "awaiting_confirmation" || state.phase === "activating" ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", { children: "Desktop activation is pending." }), /* @__PURE__ */ jsx(Button, {
683
671
  size: "sm",
@@ -739,6 +727,50 @@ function ComputerUsePanel({ sessionId, sendSessionFrame }) {
739
727
  ]
740
728
  });
741
729
  }
730
+ function ComputerUseConfirmation({ target, durationMs, onConfirm, onCancel }) {
731
+ const desktop = target.scope === "desktop";
732
+ return /* @__PURE__ */ jsx(Dialog, {
733
+ open: true,
734
+ onOpenChange: (open) => {
735
+ if (!open) onCancel();
736
+ },
737
+ children: /* @__PURE__ */ jsxs(DialogContent, { children: [/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { children: [
738
+ "Allow Po to control ",
739
+ desktop ? "your whole desktop" : "this window",
740
+ "?"
741
+ ] }) }), /* @__PURE__ */ jsxs(DialogBody, { children: [
742
+ /* @__PURE__ */ jsx(DialogDescription, { children: desktop ? "Every app window on the main display, except Po and system security windows." : `${text(target.applicationName, "Application")}: ${text(target.windowTitle, text(target.windowId, "Window"))}` }),
743
+ /* @__PURE__ */ jsxs("p", { children: [
744
+ "For ",
745
+ durationMs / 6e4,
746
+ " minutes. You can stop at any time."
747
+ ] }),
748
+ /* @__PURE__ */ jsxs("p", {
749
+ className: "text-sm text-po-dim",
750
+ children: [
751
+ "Po records ",
752
+ desktop ? "the main display" : "this window",
753
+ ", system sound and microphone audio when permission is granted."
754
+ ]
755
+ }),
756
+ /* @__PURE__ */ jsx("p", {
757
+ className: "text-sm text-po-dim",
758
+ children: "Only this session and its approved device receive control."
759
+ }),
760
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
761
+ type: "button",
762
+ variant: "outline",
763
+ onClick: onCancel,
764
+ children: "Cancel"
765
+ }), /* @__PURE__ */ jsx(Button, {
766
+ type: "button",
767
+ variant: "primary",
768
+ onClick: onConfirm,
769
+ children: "Allow control"
770
+ })] })
771
+ ] })] })
772
+ });
773
+ }
742
774
  //#endregion
743
775
  //#region src/extensions/workspaces/sessions/(frontend)/tool/_lib/computerActionToolRender.ts
744
776
  const computerActionToolName = "computer_action";