@agimon-ai/po-computer-use 0.0.0-alpha.175 → 0.0.0-alpha.177

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 (36) hide show
  1. package/README.md +5 -5
  2. package/dist/apiContracts.cjs +21 -47
  3. package/dist/apiContracts.cjs.map +1 -1
  4. package/dist/apiContracts.d.mts.map +1 -1
  5. package/dist/apiContracts.mjs +21 -47
  6. package/dist/apiContracts.mjs.map +1 -1
  7. package/dist/{extensionService-BB08HbHP.cjs → extensionService-BKBTsnkI.cjs} +103 -74
  8. package/dist/extensionService-BKBTsnkI.cjs.map +1 -0
  9. package/dist/{extensionService-D8bAAsIN.mjs → extensionService-DqtoB79s.mjs} +86 -75
  10. package/dist/extensionService-DqtoB79s.mjs.map +1 -0
  11. package/dist/extensions/mcp.cjs.map +1 -1
  12. package/dist/extensions/mcp.mjs.map +1 -1
  13. package/dist/extensions/native.mjs +30 -249
  14. package/dist/extensions/native.mjs.map +1 -1
  15. package/dist/extensions/server.cjs +349 -66
  16. package/dist/extensions/server.cjs.map +1 -1
  17. package/dist/extensions/server.d.mts.map +1 -1
  18. package/dist/extensions/server.mjs +349 -66
  19. package/dist/extensions/server.mjs.map +1 -1
  20. package/dist/extensions/web.mjs +20 -236
  21. package/dist/extensions/web.mjs.map +1 -1
  22. package/dist/index.cjs +1 -1
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.mts +30 -10
  25. package/dist/index.d.mts.map +1 -1
  26. package/dist/index.mjs +1 -1
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/po-runtime-identity.json +1 -1
  29. package/docs/computer-scripts.md +1 -1
  30. package/docs/remote-computer-use.md +5 -23
  31. package/package.json +12 -12
  32. package/src/prompts/codemode-how-to-computer-use/SKILL.md +31 -21
  33. package/src/types/computerUse.ts +41 -7
  34. package/src/types/computerUseApi.ts +17 -6
  35. package/dist/extensionService-BB08HbHP.cjs.map +0 -1
  36. package/dist/extensionService-D8bAAsIN.mjs.map +0 -1
package/README.md CHANGED
@@ -10,22 +10,22 @@ Session-scoped semantic computer control through the Po Desktop capability.
10
10
 
11
11
  ## Use
12
12
 
13
- In Desktop, enable Computer Use in host settings, then select the default-off **Computer Use** mode. Request control from the session's Activity section, available in web and native clients when the host supplies the capability. The Mac selects the application window and requires native confirmation. Only one session can hold a live Desktop run. The host opt-in setting remains Desktop-only; remote activation does not bypass it or the native grant.
13
+ In Desktop, enable Computer Use in host settings, then select the default-off **Computer Use** mode. When the agent needs control, it asks for a window or the whole desktop and a duration. Approve once from an owner-authenticated client. The computer-use Activity card monitors the live grant and offers Stop; there is no separate setup form. Only one session can hold a live Desktop run. Remote activation does not bypass Desktop opt-in or grant checks. To stop from another app on macOS, press **Cmd+Shift+Esc**. If macOS cannot register the shortcut, use **Computer Use → Stop Computer Use** in Po Desktop or stop from Activity.
14
14
 
15
15
  The `computer-use` mode exposes Activate, Deactivate, and Doctor actions. `/computer-use` reports the current state.
16
16
 
17
17
  While active, the package exposes three tools:
18
18
 
19
19
  - `computer_state` observes the authorized window and returns a semantic snapshot. `saveScreenshot: true` also keeps the screenshot in session artifacts under `computer-use/<run>/` and returns its `artifact:` path.
20
- - `computer_action` performs one semantic press, focus change, value change, or scroll against a current snapshot.
20
+ - `computer_action` performs one of the semantic actions advertised for an element in a current snapshot. Approved-window grants use the bundled, unmodified agent-desktop CLI and show a visual agent cursor. The cursor is not a separate keyboard or mouse. Whole-desktop grants continue to use the Swift backend for the existing cross-app, Dock and menu-bar behavior.
21
21
  - `computer_exec` executes a reusable JavaScript or erasable TypeScript function and its relative helpers in a restricted runtime, then returns a fresh semantic observation.
22
22
 
23
- Every finished recording is copied from the native store into session artifacts under `computer-use/`, in bounded ranges, when artifacts are available. The private player keeps its own copy.
23
+ Po’s Swift helper records MP4 and audio. Finished recordings are copied into session artifacts under `computer-use/` in bounded ranges. For a window grant, an approved request for extra trace capture also keeps bounded JSONL action metadata and PNGs of that window. The trace does not contain element refs, entered text, or raw CLI debug output. Recording and tracing stop before sensitive input can be sent. Treat these artifacts as private desktop content.
24
24
  Generated functions receive the authorized program API, JSON input, bounded logging, and cancellation. They do not receive Node or filesystem access. Script-internal observations omit screenshots by default, and `includeScreenshot: true` requests an image explicitly. Full Node execution requires both `trusted: true` and an exact host-configured `PO_COMPUTER_USE_SCRIPT_PATHS` allowlist. Trusted scripts remain unsandboxed, including their imported dependencies. See [Author computer functions](./docs/computer-scripts.md) for the contract, limits, trust boundary, and examples.
25
25
 
26
- With code mode, the same operations are the `computer` namespace in `exec` (`state`, `act`, `run`, `stop`), registered only while the native grant is active, and the three tools are withdrawn from the agent. The `codemode-how-to-computer-use` guide is listed whenever the mode is selected. MCP clients and hosts without code mode keep the tools.
26
+ With code mode, `computer.targets()` lists candidate windows and `computer.request()` asks for human approval. Hosts without code mode use `computer_targets` and `computer_request`. The `state`, `act`, `run` and `stop` members are available only during an active grant. The `codemode-how-to-computer-use` guide is listed whenever the mode is selected.
27
27
 
28
- All three tools remain unavailable during setup and are admitted only after the native grant becomes active. Disabling the mode or host opt-in, stopping control, expiry, or Desktop disconnection stops further actions. Once Desktop claims a session, browser and remote MCP clients cannot drive its agent, including previously attached clients. This is separate from requesting or cancelling an activation through the authorized client API. This ownership stays pinned for the server lifetime and is not restored from saved session data.
28
+ Disabling the mode or host opt-in, stopping control, expiry, or Desktop disconnection stops further actions. An approval does not change who can access the session. The owner can monitor or stop control from the same signed-in browser that approved it.
29
29
 
30
30
  ## Public API
31
31
 
@@ -70,14 +70,28 @@ const Reference = {
70
70
  };
71
71
  const ComputerActionSchema = typebox.Type.Union([
72
72
  typebox.Type.Object({
73
- kind: values(["press", "focus"]),
73
+ kind: values([
74
+ "press",
75
+ "focus",
76
+ "expand",
77
+ "collapse",
78
+ "toggle",
79
+ "check",
80
+ "uncheck",
81
+ "scroll_to"
82
+ ]),
74
83
  ...Reference
75
84
  }, { additionalProperties: false }),
76
85
  typebox.Type.Object({
77
- kind: typebox.Type.Literal("set_value"),
86
+ kind: values(["set_value", "select"]),
78
87
  ...Reference,
79
88
  value: S
80
89
  }, { additionalProperties: false }),
90
+ typebox.Type.Object({
91
+ kind: typebox.Type.Literal("type"),
92
+ ...Reference,
93
+ text: S
94
+ }, { additionalProperties: false }),
81
95
  typebox.Type.Object({
82
96
  kind: typebox.Type.Literal("scroll"),
83
97
  ...Reference,
@@ -87,7 +101,10 @@ const ComputerActionSchema = typebox.Type.Union([
87
101
  "left",
88
102
  "right"
89
103
  ]),
90
- amount: values(["line", "page"])
104
+ amount: typebox.Type.Union([values(["line", "page"]), typebox.Type.Integer({
105
+ minimum: 1,
106
+ maximum: 100
107
+ })])
91
108
  }, { additionalProperties: false })
92
109
  ]);
93
110
  const internal = (method, path, output, body, status = 200) => ({
@@ -142,50 +159,6 @@ const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
142
159
  }
143
160
  }
144
161
  }))),
145
- {
146
- id: "computer.activation.state",
147
- scope: "session",
148
- basePath: "computer-use",
149
- path: "/activate",
150
- method: "GET",
151
- authentication: "owner",
152
- description: "Read state as the matching pending requester or approved recording reader.",
153
- responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(ComputerStateSchema)
154
- },
155
- {
156
- id: "computer.activation.cancel",
157
- scope: "session",
158
- basePath: "computer-use",
159
- path: "/activate",
160
- method: "DELETE",
161
- authentication: "owner",
162
- description: "Cancel only the matching requester pending activation.",
163
- responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(ComputerStateSchema, 202)
164
- },
165
- {
166
- id: "computer.activate",
167
- scope: "session",
168
- basePath: "computer-use",
169
- path: "/activate",
170
- method: "POST",
171
- authentication: "owner",
172
- description: "Request confirmed Desktop access with admitted caller and remote step-up context. The target is one application window or the whole desktop; a remote caller may omit it so the local Mac selects.",
173
- body: {
174
- required: true,
175
- contentType: "application/json",
176
- schema: typebox.Type.Object({
177
- target: O(typebox.Type.Union([typebox.Type.Object({
178
- windowId: S,
179
- bundleId: S
180
- }), typebox.Type.Object({ scope: typebox.Type.Literal("desktop") })])),
181
- durationMs: typebox.Type.Integer({
182
- minimum: 1e3,
183
- maximum: 18e5
184
- })
185
- })
186
- },
187
- responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(ComputerStateSchema, 202)
188
- },
189
162
  {
190
163
  id: "computer.artifact",
191
164
  scope: "session",
@@ -213,6 +186,7 @@ const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
213
186
  },
214
187
  internal("GET", "/agent/state", ComputerStateSchema),
215
188
  internal("GET", "/hub/state", ComputerStateSchema),
189
+ internal("POST", "/hub/request-stop", ComputerStateSchema, void 0, 202),
216
190
  internal("POST", "/agent/observe", Json),
217
191
  internal("POST", "/agent/action", Json, ComputerActionSchema),
218
192
  internal("POST", "/agent/stop", ComputerStateSchema, void 0, 202),
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.cjs","names":["Type","jsonApiResponses","defineApiContract"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst O = Type.Optional;\nconst values = <T extends string>(items: T[]) => Type.Union(items.map((item) => Type.Literal(item)));\nconst Json = Type.Unknown({\n description:\n 'Desktop provider JSON value. Targets, observations and action results are supplied by the admitted Desktop provider.',\n});\nconst Target = Type.Record(S, Json);\nconst Error = Type.Object({ code: S, message: S });\nconst Artifact = Type.Object({\n artifactId: S,\n status: values(['ready', 'failed']),\n sizeBytes: O(N),\n downloadUrl: O(S),\n previewUrl: O(S),\n actionCount: O(N),\n completedAt: O(S),\n failure: O(Error),\n});\nexport const ComputerStateSchema = Type.Object({\n sessionId: S,\n revision: N,\n wake: N,\n phase: values(['inactive', 'awaiting_confirmation', 'activating', 'active', 'stopping', 'failed']),\n requestId: O(S),\n target: O(Target),\n durationMs: O(N),\n expiresAt: O(N),\n failure: O(Error),\n artifact: O(Artifact),\n});\nconst Permission = values(['accessibility', 'screen-recording', 'microphone', 'automation', 'full-disk-access']);\nconst PermissionState = values(['granted', 'denied', 'not-determined', 'per-app']);\nexport const DesktopPermissionStatesSchema = Type.Object({\n accessibility: PermissionState,\n 'screen-recording': PermissionState,\n microphone: PermissionState,\n automation: PermissionState,\n 'full-disk-access': PermissionState,\n});\nconst Reference = { snapshotId: Type.String({ minLength: 1 }), elementRef: Type.String({ minLength: 1 }) };\nexport const ComputerActionSchema = Type.Union([\n Type.Object({ kind: values(['press', 'focus']), ...Reference }, { additionalProperties: false }),\n Type.Object({ kind: Type.Literal('set_value'), ...Reference, value: S }, { additionalProperties: false }),\n Type.Object(\n {\n kind: Type.Literal('scroll'),\n ...Reference,\n direction: values(['up', 'down', 'left', 'right']),\n amount: values(['line', 'page']),\n },\n { additionalProperties: false },\n ),\n]);\nconst internal = (\n method: 'GET' | 'POST',\n path: string,\n output: object,\n body?: object,\n status = 200,\n): PoHttpContract => ({\n id: `computer.${path.slice(1).replaceAll('/', '.')}`,\n scope: 'session',\n basePath: 'computer-use',\n path,\n method,\n authentication: 'owner',\n description: `Computer use broker ${path}. Requires the host-issued ${path.startsWith('/agent/') ? 'agent' : 'hub'} bearer token.`,\n availability: 'Internal broker route; ordinary browser credentials are insufficient.',\n parameters: [{ name: 'Authorization', in: 'header', required: true, schema: Type.String({ pattern: '^Bearer .+' }) }],\n ...(body ? { body: { required: true, contentType: 'application/json', schema: body } } : {}),\n responses: jsonApiResponses(output, status),\n});\nexport const apiContracts = defineApiContract({\n version: 1,\n dynamic: ['Desktop provider target extensions, observations and operation results are runtime-defined JSON.'],\n http: [\n ...(['host', 'workspace', 'session'] as const).flatMap((scope) =>\n (['GET', 'POST'] as const).map((method) => ({\n id: `computer.permissions.${method === 'GET' ? 'read' : 'request'}`,\n scope,\n basePath: 'desktop-permissions',\n path: '/',\n method,\n authentication: 'owner' as const,\n description:\n method === 'GET'\n ? 'Read the Mac-owned permission states. Requires an authorized local Desktop caller or trusted remote caller.'\n : 'Ask macOS for one named permission. Requires an authorized local Desktop caller or remote passkey step-up.',\n availability: 'Requires Po Desktop to be running this server; otherwise returns 404.',\n ...(method === 'POST'\n ? {\n body: {\n required: true,\n contentType: 'application/json',\n schema: Type.Object({ permission: Permission }),\n },\n }\n : {}),\n responses: {\n ...jsonApiResponses(DesktopPermissionStatesSchema),\n '502': { description: 'Desktop permission request failed.', schema: Type.Object({ error: S }) },\n },\n })),\n ),\n {\n id: 'computer.activation.state',\n scope: 'session',\n basePath: 'computer-use',\n path: '/activate',\n method: 'GET',\n authentication: 'owner',\n description: 'Read state as the matching pending requester or approved recording reader.',\n responses: jsonApiResponses(ComputerStateSchema),\n },\n {\n id: 'computer.activation.cancel',\n scope: 'session',\n basePath: 'computer-use',\n path: '/activate',\n method: 'DELETE',\n authentication: 'owner',\n description: 'Cancel only the matching requester pending activation.',\n responses: jsonApiResponses(ComputerStateSchema, 202),\n },\n {\n id: 'computer.activate',\n scope: 'session',\n basePath: 'computer-use',\n path: '/activate',\n method: 'POST',\n authentication: 'owner',\n description:\n 'Request confirmed Desktop access with admitted caller and remote step-up context. The target is one application window or the whole desktop; a remote caller may omit it so the local Mac selects.',\n body: {\n required: true,\n contentType: 'application/json',\n schema: Type.Object({\n target: O(\n Type.Union([Type.Object({ windowId: S, bundleId: S }), Type.Object({ scope: Type.Literal('desktop') })]),\n ),\n durationMs: Type.Integer({ minimum: 1000, maximum: 1800000 }),\n }),\n },\n responses: jsonApiResponses(ComputerStateSchema, 202),\n },\n {\n id: 'computer.artifact',\n scope: 'session',\n basePath: 'computer-use',\n path: '/artifact',\n method: 'GET',\n authentication: 'owner',\n description: 'Read at most 1 MiB of a recording belonging to this session and approved caller.',\n parameters: [\n { name: 'artifactId', in: 'query', required: true, schema: S },\n { name: 'offset', in: 'query', required: true, schema: Type.Integer({ minimum: 0 }) },\n ],\n responses: {\n 206: {\n description: 'Bounded recording bytes.',\n contentType: 'video/mp4',\n schema: Type.String({ format: 'binary' }),\n },\n },\n },\n internal('GET', '/agent/state', ComputerStateSchema),\n internal('GET', '/hub/state', ComputerStateSchema),\n internal('POST', '/agent/observe', Json),\n internal('POST', '/agent/action', Json, ComputerActionSchema),\n internal('POST', '/agent/stop', ComputerStateSchema, undefined, 202),\n internal(\n 'GET',\n '/hub/activation',\n Type.Union([\n Type.Null(),\n Type.Object({\n requestId: S,\n target: Target,\n durationSeconds: N,\n createdAt: N,\n confirmationExpiresAt: N,\n caller: Type.Object({ locality: values(['local', 'remote']), stepUp: S }),\n }),\n ]),\n ),\n internal('GET', '/hub/authorization', Type.Union([Type.Null(), Type.Object({ grantId: S, expiresAt: O(N) })])),\n internal(\n 'GET',\n '/hub/next',\n Type.Union([\n Type.Null(),\n Type.Object({ id: S, operation: values(['observe', 'act']), payload: O(Json), grantId: S, sequence: O(N) }),\n ]),\n ),\n internal('POST', '/hub/complete', ComputerStateSchema, Type.Object({ id: S, error: O(S), result: O(Json) })),\n internal(\n 'POST',\n '/hub/stop',\n ComputerStateSchema,\n Type.Object({ error: O(S), host: O(Type.Object({ grantId: S, expiresAt: N })), artifact: O(Artifact) }),\n ),\n ],\n sockets: (['host', 'workspace'] as const).flatMap((scope) => [\n {\n id: 'computer.state',\n scope,\n service: 'po.hub',\n member: 'computer_use_state',\n kind: 'channel',\n direction: 'server-to-client',\n description: 'Computer use channel payload.',\n input: Type.Object({ state: ComputerStateSchema, targets: Type.Array(Target), busy: O(Type.Literal(true)) }),\n },\n {\n id: 'computer.command',\n scope,\n service: 'po.hub',\n member: 'computer_use_state',\n kind: 'channel',\n direction: 'client-to-server',\n description: 'Computer use browser channel command.',\n input: Type.Object({ action: values(['status', 'targets', 'stop', 'artifacts']) }),\n },\n ]),\n});\nexport default apiContracts;\n"],"mappings":";;;;;;;AAGA,MAAM,IAAIA,QAAAA,KAAK,OAAO;AACtB,MAAM,IAAIA,QAAAA,KAAK,OAAO;AACtB,MAAM,IAAIA,QAAAA,KAAK;AACf,MAAM,UA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AAC,CACH;EACA,SAAS,QAAQ,iBAAiB,qBAAqBA,QAAAA,KAAK,OAAO;GAAE,IAAI;GAAG,OAAO,EAAE,CAAC;GAAG,QAAQ,EAAE,IAAI;EAAE,CAAC,CAAC;EAC3G,SACE,QACA,aACA,qBACAA,QAAAA,KAAK,OAAO;GAAE,OAAO,EAAE,CAAC;GAAG,MAAM,EAAEA,QAAAA,KAAK,OAAO;IAAE,SAAS;IAAG,WAAW;GAAE,CAAC,CAAC;GAAG,UAAU,EAAE,QAAQ;EAAE,CAAC,CACxG;CACF;CACA,SAAU,CAAC,QAAQ,WAAW,CAAC,CAAW,SAAS,UAAU,CAC3D;EACE,IAAI;EACJ;EACA,SAAS;EACT,QAAQ;EACR,MAAM;EACN,WAAW;EACX,aAAa;EACb,OAAOA,QAAAA,KAAK,OAAO;GAAE,OAAO;GAAqB,SAASA,QAAAA,KAAK,MAAM,MAAM;GAAG,MAAM,EAAEA,QAAAA,KAAK,QAAQ,IAAI,CAAC;EAAE,CAAC;CAC7G,GACA;EACE,IAAI;EACJ;EACA,SAAS;EACT,QAAQ;EACR,MAAM;EACN,WAAW;EACX,aAAa;EACb,OAAOA,QAAAA,KAAK,OAAO,EAAE,QAAQ,OAAO;GAAC;GAAU;GAAW;GAAQ;EAAW,CAAC,EAAE,CAAC;CACnF,CACF,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"apiContracts.cjs","names":["Type","jsonApiResponses","defineApiContract"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst O = Type.Optional;\nconst values = <T extends string>(items: T[]) => Type.Union(items.map((item) => Type.Literal(item)));\nconst Json = Type.Unknown({\n description:\n 'Desktop provider JSON value. Targets, observations and action results are supplied by the admitted Desktop provider.',\n});\nconst Target = Type.Record(S, Json);\nconst Error = Type.Object({ code: S, message: S });\nconst Artifact = Type.Object({\n artifactId: S,\n status: values(['ready', 'failed']),\n sizeBytes: O(N),\n downloadUrl: O(S),\n previewUrl: O(S),\n actionCount: O(N),\n completedAt: O(S),\n failure: O(Error),\n});\nexport const ComputerStateSchema = Type.Object({\n sessionId: S,\n revision: N,\n wake: N,\n phase: values(['inactive', 'awaiting_confirmation', 'activating', 'active', 'stopping', 'failed']),\n requestId: O(S),\n target: O(Target),\n durationMs: O(N),\n expiresAt: O(N),\n failure: O(Error),\n artifact: O(Artifact),\n});\nconst Permission = values(['accessibility', 'screen-recording', 'microphone', 'automation', 'full-disk-access']);\nconst PermissionState = values(['granted', 'denied', 'not-determined', 'per-app']);\nexport const DesktopPermissionStatesSchema = Type.Object({\n accessibility: PermissionState,\n 'screen-recording': PermissionState,\n microphone: PermissionState,\n automation: PermissionState,\n 'full-disk-access': PermissionState,\n});\nconst Reference = {\n snapshotId: Type.String({ minLength: 1 }),\n elementRef: Type.String({ minLength: 1 }),\n};\nexport const ComputerActionSchema = Type.Union([\n Type.Object(\n { kind: values(['press', 'focus', 'expand', 'collapse', 'toggle', 'check', 'uncheck', 'scroll_to']), ...Reference },\n { additionalProperties: false },\n ),\n Type.Object({ kind: values(['set_value', 'select']), ...Reference, value: S }, { additionalProperties: false }),\n Type.Object({ kind: Type.Literal('type'), ...Reference, text: S }, { additionalProperties: false }),\n Type.Object(\n {\n kind: Type.Literal('scroll'),\n ...Reference,\n direction: values(['up', 'down', 'left', 'right']),\n amount: Type.Union([values(['line', 'page']), Type.Integer({ minimum: 1, maximum: 100 })]),\n },\n { additionalProperties: false },\n ),\n]);\nconst internal = (\n method: 'GET' | 'POST',\n path: string,\n output: object,\n body?: object,\n status = 200,\n): PoHttpContract => ({\n id: `computer.${path.slice(1).replaceAll('/', '.')}`,\n scope: 'session',\n basePath: 'computer-use',\n path,\n method,\n authentication: 'owner',\n description: `Computer use broker ${path}. Requires the host-issued ${path.startsWith('/agent/') ? 'agent' : 'hub'} bearer token.`,\n availability: 'Internal broker route; ordinary browser credentials are insufficient.',\n parameters: [\n {\n name: 'Authorization',\n in: 'header',\n required: true,\n schema: Type.String({ pattern: '^Bearer .+' }),\n },\n ],\n ...(body\n ? {\n body: { required: true, contentType: 'application/json', schema: body },\n }\n : {}),\n responses: jsonApiResponses(output, status),\n});\nexport const apiContracts = defineApiContract({\n version: 1,\n dynamic: ['Desktop provider target extensions, observations and operation results are runtime-defined JSON.'],\n http: [\n ...(['host', 'workspace', 'session'] as const).flatMap((scope) =>\n (['GET', 'POST'] as const).map((method) => ({\n id: `computer.permissions.${method === 'GET' ? 'read' : 'request'}`,\n scope,\n basePath: 'desktop-permissions',\n path: '/',\n method,\n authentication: 'owner' as const,\n description:\n method === 'GET'\n ? 'Read the Mac-owned permission states. Requires an authorized local Desktop caller or trusted remote caller.'\n : 'Ask macOS for one named permission. Requires an authorized local Desktop caller or remote passkey step-up.',\n availability: 'Requires Po Desktop to be running this server; otherwise returns 404.',\n ...(method === 'POST'\n ? {\n body: {\n required: true,\n contentType: 'application/json',\n schema: Type.Object({ permission: Permission }),\n },\n }\n : {}),\n responses: {\n ...jsonApiResponses(DesktopPermissionStatesSchema),\n '502': {\n description: 'Desktop permission request failed.',\n schema: Type.Object({ error: S }),\n },\n },\n })),\n ),\n {\n id: 'computer.artifact',\n scope: 'session',\n basePath: 'computer-use',\n path: '/artifact',\n method: 'GET',\n authentication: 'owner',\n description: 'Read at most 1 MiB of a recording belonging to this session and approved caller.',\n parameters: [\n { name: 'artifactId', in: 'query', required: true, schema: S },\n {\n name: 'offset',\n in: 'query',\n required: true,\n schema: Type.Integer({ minimum: 0 }),\n },\n ],\n responses: {\n 206: {\n description: 'Bounded recording bytes.',\n contentType: 'video/mp4',\n schema: Type.String({ format: 'binary' }),\n },\n },\n },\n internal('GET', '/agent/state', ComputerStateSchema),\n internal('GET', '/hub/state', ComputerStateSchema),\n internal('POST', '/hub/request-stop', ComputerStateSchema, undefined, 202),\n internal('POST', '/agent/observe', Json),\n internal('POST', '/agent/action', Json, ComputerActionSchema),\n internal('POST', '/agent/stop', ComputerStateSchema, undefined, 202),\n internal(\n 'GET',\n '/hub/activation',\n Type.Union([\n Type.Null(),\n Type.Object({\n requestId: S,\n target: Target,\n durationSeconds: N,\n createdAt: N,\n confirmationExpiresAt: N,\n caller: Type.Object({\n locality: values(['local', 'remote']),\n stepUp: S,\n }),\n }),\n ]),\n ),\n internal('GET', '/hub/authorization', Type.Union([Type.Null(), Type.Object({ grantId: S, expiresAt: O(N) })])),\n internal(\n 'GET',\n '/hub/next',\n Type.Union([\n Type.Null(),\n Type.Object({\n id: S,\n operation: values(['observe', 'act']),\n payload: O(Json),\n grantId: S,\n sequence: O(N),\n }),\n ]),\n ),\n internal('POST', '/hub/complete', ComputerStateSchema, Type.Object({ id: S, error: O(S), result: O(Json) })),\n internal(\n 'POST',\n '/hub/stop',\n ComputerStateSchema,\n Type.Object({\n error: O(S),\n host: O(Type.Object({ grantId: S, expiresAt: N })),\n artifact: O(Artifact),\n }),\n ),\n ],\n sockets: (['host', 'workspace'] as const).flatMap((scope) => [\n {\n id: 'computer.state',\n scope,\n service: 'po.hub',\n member: 'computer_use_state',\n kind: 'channel',\n direction: 'server-to-client',\n description: 'Computer use channel payload.',\n input: Type.Object({\n state: ComputerStateSchema,\n targets: Type.Array(Target),\n busy: O(Type.Literal(true)),\n }),\n },\n {\n id: 'computer.command',\n scope,\n service: 'po.hub',\n member: 'computer_use_state',\n kind: 'channel',\n direction: 'client-to-server',\n description: 'Computer use browser channel command.',\n input: Type.Object({\n action: values(['status', 'targets', 'stop', 'artifacts']),\n }),\n },\n ]),\n});\nexport default apiContracts;\n"],"mappings":";;;;;;;AAGA,MAAM,IAAIA,QAAAA,KAAK,OAAO;AACtB,MAAM,IAAIA,QAAAA,KAAK,OAAO;AACtB,MAAM,IAAIA,QAAAA,KAAK;AACf,MAAM,UAA4B,UAAeA,QAAAA,KAAK,MAAM,MAAM,KAAK,SAASA,QAAAA,KAAK,QAAQ,IAAI,C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AAA,KAAK,QAAQ,IAAI,CAAC;EAC5B,CAAC;CACH,GACA;EACE,IAAI;EACJ;EACA,SAAS;EACT,QAAQ;EACR,MAAM;EACN,WAAW;EACX,aAAa;EACb,OAAOA,QAAAA,KAAK,OAAO,EACjB,QAAQ,OAAO;GAAC;GAAU;GAAW;GAAQ;EAAW,CAAC,EAC3D,CAAC;CACH,CACF,CAAC;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";;qBA6Ea"}
1
+ {"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";;qBA+Fa"}
@@ -66,14 +66,28 @@ const Reference = {
66
66
  };
67
67
  const ComputerActionSchema = Type.Union([
68
68
  Type.Object({
69
- kind: values(["press", "focus"]),
69
+ kind: values([
70
+ "press",
71
+ "focus",
72
+ "expand",
73
+ "collapse",
74
+ "toggle",
75
+ "check",
76
+ "uncheck",
77
+ "scroll_to"
78
+ ]),
70
79
  ...Reference
71
80
  }, { additionalProperties: false }),
72
81
  Type.Object({
73
- kind: Type.Literal("set_value"),
82
+ kind: values(["set_value", "select"]),
74
83
  ...Reference,
75
84
  value: S
76
85
  }, { additionalProperties: false }),
86
+ Type.Object({
87
+ kind: Type.Literal("type"),
88
+ ...Reference,
89
+ text: S
90
+ }, { additionalProperties: false }),
77
91
  Type.Object({
78
92
  kind: Type.Literal("scroll"),
79
93
  ...Reference,
@@ -83,7 +97,10 @@ const ComputerActionSchema = Type.Union([
83
97
  "left",
84
98
  "right"
85
99
  ]),
86
- amount: values(["line", "page"])
100
+ amount: Type.Union([values(["line", "page"]), Type.Integer({
101
+ minimum: 1,
102
+ maximum: 100
103
+ })])
87
104
  }, { additionalProperties: false })
88
105
  ]);
89
106
  const internal = (method, path, output, body, status = 200) => ({
@@ -138,50 +155,6 @@ const apiContracts = defineApiContract({
138
155
  }
139
156
  }
140
157
  }))),
141
- {
142
- id: "computer.activation.state",
143
- scope: "session",
144
- basePath: "computer-use",
145
- path: "/activate",
146
- method: "GET",
147
- authentication: "owner",
148
- description: "Read state as the matching pending requester or approved recording reader.",
149
- responses: jsonApiResponses(ComputerStateSchema)
150
- },
151
- {
152
- id: "computer.activation.cancel",
153
- scope: "session",
154
- basePath: "computer-use",
155
- path: "/activate",
156
- method: "DELETE",
157
- authentication: "owner",
158
- description: "Cancel only the matching requester pending activation.",
159
- responses: jsonApiResponses(ComputerStateSchema, 202)
160
- },
161
- {
162
- id: "computer.activate",
163
- scope: "session",
164
- basePath: "computer-use",
165
- path: "/activate",
166
- method: "POST",
167
- authentication: "owner",
168
- description: "Request confirmed Desktop access with admitted caller and remote step-up context. The target is one application window or the whole desktop; a remote caller may omit it so the local Mac selects.",
169
- body: {
170
- required: true,
171
- contentType: "application/json",
172
- schema: Type.Object({
173
- target: O(Type.Union([Type.Object({
174
- windowId: S,
175
- bundleId: S
176
- }), Type.Object({ scope: Type.Literal("desktop") })])),
177
- durationMs: Type.Integer({
178
- minimum: 1e3,
179
- maximum: 18e5
180
- })
181
- })
182
- },
183
- responses: jsonApiResponses(ComputerStateSchema, 202)
184
- },
185
158
  {
186
159
  id: "computer.artifact",
187
160
  scope: "session",
@@ -209,6 +182,7 @@ const apiContracts = defineApiContract({
209
182
  },
210
183
  internal("GET", "/agent/state", ComputerStateSchema),
211
184
  internal("GET", "/hub/state", ComputerStateSchema),
185
+ internal("POST", "/hub/request-stop", ComputerStateSchema, void 0, 202),
212
186
  internal("POST", "/agent/observe", Json),
213
187
  internal("POST", "/agent/action", Json, ComputerActionSchema),
214
188
  internal("POST", "/agent/stop", ComputerStateSchema, void 0, 202),
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst O = Type.Optional;\nconst values = <T extends string>(items: T[]) => Type.Union(items.map((item) => Type.Literal(item)));\nconst Json = Type.Unknown({\n description:\n 'Desktop provider JSON value. Targets, observations and action results are supplied by the admitted Desktop provider.',\n});\nconst Target = Type.Record(S, Json);\nconst Error = Type.Object({ code: S, message: S });\nconst Artifact = Type.Object({\n artifactId: S,\n status: values(['ready', 'failed']),\n sizeBytes: O(N),\n downloadUrl: O(S),\n previewUrl: O(S),\n actionCount: O(N),\n completedAt: O(S),\n failure: O(Error),\n});\nexport const ComputerStateSchema = Type.Object({\n sessionId: S,\n revision: N,\n wake: N,\n phase: values(['inactive', 'awaiting_confirmation', 'activating', 'active', 'stopping', 'failed']),\n requestId: O(S),\n target: O(Target),\n durationMs: O(N),\n expiresAt: O(N),\n failure: O(Error),\n artifact: O(Artifact),\n});\nconst Permission = values(['accessibility', 'screen-recording', 'microphone', 'automation', 'full-disk-access']);\nconst PermissionState = values(['granted', 'denied', 'not-determined', 'per-app']);\nexport const DesktopPermissionStatesSchema = Type.Object({\n accessibility: PermissionState,\n 'screen-recording': PermissionState,\n microphone: PermissionState,\n automation: PermissionState,\n 'full-disk-access': PermissionState,\n});\nconst Reference = { snapshotId: Type.String({ minLength: 1 }), elementRef: Type.String({ minLength: 1 }) };\nexport const ComputerActionSchema = Type.Union([\n Type.Object({ kind: values(['press', 'focus']), ...Reference }, { additionalProperties: false }),\n Type.Object({ kind: Type.Literal('set_value'), ...Reference, value: S }, { additionalProperties: false }),\n Type.Object(\n {\n kind: Type.Literal('scroll'),\n ...Reference,\n direction: values(['up', 'down', 'left', 'right']),\n amount: values(['line', 'page']),\n },\n { additionalProperties: false },\n ),\n]);\nconst internal = (\n method: 'GET' | 'POST',\n path: string,\n output: object,\n body?: object,\n status = 200,\n): PoHttpContract => ({\n id: `computer.${path.slice(1).replaceAll('/', '.')}`,\n scope: 'session',\n basePath: 'computer-use',\n path,\n method,\n authentication: 'owner',\n description: `Computer use broker ${path}. Requires the host-issued ${path.startsWith('/agent/') ? 'agent' : 'hub'} bearer token.`,\n availability: 'Internal broker route; ordinary browser credentials are insufficient.',\n parameters: [{ name: 'Authorization', in: 'header', required: true, schema: Type.String({ pattern: '^Bearer .+' }) }],\n ...(body ? { body: { required: true, contentType: 'application/json', schema: body } } : {}),\n responses: jsonApiResponses(output, status),\n});\nexport const apiContracts = defineApiContract({\n version: 1,\n dynamic: ['Desktop provider target extensions, observations and operation results are runtime-defined JSON.'],\n http: [\n ...(['host', 'workspace', 'session'] as const).flatMap((scope) =>\n (['GET', 'POST'] as const).map((method) => ({\n id: `computer.permissions.${method === 'GET' ? 'read' : 'request'}`,\n scope,\n basePath: 'desktop-permissions',\n path: '/',\n method,\n authentication: 'owner' as const,\n description:\n method === 'GET'\n ? 'Read the Mac-owned permission states. Requires an authorized local Desktop caller or trusted remote caller.'\n : 'Ask macOS for one named permission. Requires an authorized local Desktop caller or remote passkey step-up.',\n availability: 'Requires Po Desktop to be running this server; otherwise returns 404.',\n ...(method === 'POST'\n ? {\n body: {\n required: true,\n contentType: 'application/json',\n schema: Type.Object({ permission: Permission }),\n },\n }\n : {}),\n responses: {\n ...jsonApiResponses(DesktopPermissionStatesSchema),\n '502': { description: 'Desktop permission request failed.', schema: Type.Object({ error: S }) },\n },\n })),\n ),\n {\n id: 'computer.activation.state',\n scope: 'session',\n basePath: 'computer-use',\n path: '/activate',\n method: 'GET',\n authentication: 'owner',\n description: 'Read state as the matching pending requester or approved recording reader.',\n responses: jsonApiResponses(ComputerStateSchema),\n },\n {\n id: 'computer.activation.cancel',\n scope: 'session',\n basePath: 'computer-use',\n path: '/activate',\n method: 'DELETE',\n authentication: 'owner',\n description: 'Cancel only the matching requester pending activation.',\n responses: jsonApiResponses(ComputerStateSchema, 202),\n },\n {\n id: 'computer.activate',\n scope: 'session',\n basePath: 'computer-use',\n path: '/activate',\n method: 'POST',\n authentication: 'owner',\n description:\n 'Request confirmed Desktop access with admitted caller and remote step-up context. The target is one application window or the whole desktop; a remote caller may omit it so the local Mac selects.',\n body: {\n required: true,\n contentType: 'application/json',\n schema: Type.Object({\n target: O(\n Type.Union([Type.Object({ windowId: S, bundleId: S }), Type.Object({ scope: Type.Literal('desktop') })]),\n ),\n durationMs: Type.Integer({ minimum: 1000, maximum: 1800000 }),\n }),\n },\n responses: jsonApiResponses(ComputerStateSchema, 202),\n },\n {\n id: 'computer.artifact',\n scope: 'session',\n basePath: 'computer-use',\n path: '/artifact',\n method: 'GET',\n authentication: 'owner',\n description: 'Read at most 1 MiB of a recording belonging to this session and approved caller.',\n parameters: [\n { name: 'artifactId', in: 'query', required: true, schema: S },\n { name: 'offset', in: 'query', required: true, schema: Type.Integer({ minimum: 0 }) },\n ],\n responses: {\n 206: {\n description: 'Bounded recording bytes.',\n contentType: 'video/mp4',\n schema: Type.String({ format: 'binary' }),\n },\n },\n },\n internal('GET', '/agent/state', ComputerStateSchema),\n internal('GET', '/hub/state', ComputerStateSchema),\n internal('POST', '/agent/observe', Json),\n internal('POST', '/agent/action', Json, ComputerActionSchema),\n internal('POST', '/agent/stop', ComputerStateSchema, undefined, 202),\n internal(\n 'GET',\n '/hub/activation',\n Type.Union([\n Type.Null(),\n Type.Object({\n requestId: S,\n target: Target,\n durationSeconds: N,\n createdAt: N,\n confirmationExpiresAt: N,\n caller: Type.Object({ locality: values(['local', 'remote']), stepUp: S }),\n }),\n ]),\n ),\n internal('GET', '/hub/authorization', Type.Union([Type.Null(), Type.Object({ grantId: S, expiresAt: O(N) })])),\n internal(\n 'GET',\n '/hub/next',\n Type.Union([\n Type.Null(),\n Type.Object({ id: S, operation: values(['observe', 'act']), payload: O(Json), grantId: S, sequence: O(N) }),\n ]),\n ),\n internal('POST', '/hub/complete', ComputerStateSchema, Type.Object({ id: S, error: O(S), result: O(Json) })),\n internal(\n 'POST',\n '/hub/stop',\n ComputerStateSchema,\n Type.Object({ error: O(S), host: O(Type.Object({ grantId: S, expiresAt: N })), artifact: O(Artifact) }),\n ),\n ],\n sockets: (['host', 'workspace'] as const).flatMap((scope) => [\n {\n id: 'computer.state',\n scope,\n service: 'po.hub',\n member: 'computer_use_state',\n kind: 'channel',\n direction: 'server-to-client',\n description: 'Computer use channel payload.',\n input: Type.Object({ state: ComputerStateSchema, targets: Type.Array(Target), busy: O(Type.Literal(true)) }),\n },\n {\n id: 'computer.command',\n scope,\n service: 'po.hub',\n member: 'computer_use_state',\n kind: 'channel',\n direction: 'client-to-server',\n description: 'Computer use browser channel command.',\n input: Type.Object({ action: values(['status', 'targets', 'stop', 'artifacts']) }),\n },\n ]),\n});\nexport default apiContracts;\n"],"mappings":";;;AAGA,MAAM,IAAI,KAAK,OAAO;AACtB,MAAM,IAAI,KAAK,OAAO;AACtB,MAAM,IAAI,KAAK;AACf,MAAM,UAA4B,UAAe,KAAK,MAAM,MAAM,KAAK,SAAS,KAAK,QAAQ,IAAI,CAAC,CAAC;AACnG,MAAM,OAAO,KAAK,QAAQ,EACxB,aACE,uHACJ,CAAC;AACD,MAAM,SAAS,KAAK,OAAO,GAAG,IAAI;AAClC,MAAM,QAAQ,KAAK,OAAO;CAAE,MAAM;CAAG,SAAS;AAAE,CAAC;AACjD,MAAM,WAAW,KAAK,OAAO;CAC3B,YAAY;CACZ,QAAQ,OAAO,CAAC,SAAS,QAAQ,CAAC;CAClC,WAAW,EAAE,CAAC;CACd,aAAa,EAAE,CAAC;CAChB,YAAY,EAAE,CAAC;CACf,aAAa,EAAE,CAAC;CAChB,aAAa,EAAE,CAAC;CAChB,SAAS,EAAE,KAAK;AAClB,CAAC;AACD,MAAa,sBAAsB,KAAK,OAAO;CAC7C,WAAW;CACX,UAAU;CACV,MAAM;CACN,OAAO,OAAO;EAAC;EAAY;EAAyB;EAAc;EAAU;EAAY;CAAQ,CAAC;CACjG,WAAW,EAAE,CAAC;CACd,QAAQ,EAAE,MAAM;CAChB,YAAY,EAAE,CAAC;CACf,WAAW,EAAE,CAAC;CACd,SAAS,EAAE,KAAK;CAChB,UAAU,EAAE,QAAQ;AACtB,CAAC;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AE,CAAC;EAAE,CAAC,CAC5G,CAAC,CACH;EACA,SAAS,QAAQ,iBAAiB,qBAAqB,KAAK,OAAO;GAAE,IAAI;GAAG,OAAO,EAAE,CAAC;GAAG,QAAQ,EAAE,IAAI;EAAE,CAAC,CAAC;EAC3G,SACE,QACA,aACA,qBACA,KAAK,OAAO;GAAE,OAAO,EAAE,CAAC;GAAG,MAAM,EAAE,KAAK,OAAO;IAAE,SAAS;IAAG,WAAW;GAAE,CAAC,CAAC;GAAG,UAAU,EAAE,QAAQ;EAAE,CAAC,CACxG;CACF;CACA,SAAU,CAAC,QAAQ,WAAW,CAAC,CAAW,SAAS,UAAU,CAC3D;EACE,IAAI;EACJ;EACA,SAAS;EACT,QAAQ;EACR,MAAM;EACN,WAAW;EACX,aAAa;EACb,OAAO,KAAK,OAAO;GAAE,OAAO;GAAqB,SAAS,KAAK,MAAM,MAAM;GAAG,MAAM,EAAE,KAAK,QAAQ,IAAI,CAAC;EAAE,CAAC;CAC7G,GACA;EACE,IAAI;EACJ;EACA,SAAS;EACT,QAAQ;EACR,MAAM;EACN,WAAW;EACX,aAAa;EACb,OAAO,KAAK,OAAO,EAAE,QAAQ,OAAO;GAAC;GAAU;GAAW;GAAQ;EAAW,CAAC,EAAE,CAAC;CACnF,CACF,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst O = Type.Optional;\nconst values = <T extends string>(items: T[]) => Type.Union(items.map((item) => Type.Literal(item)));\nconst Json = Type.Unknown({\n description:\n 'Desktop provider JSON value. Targets, observations and action results are supplied by the admitted Desktop provider.',\n});\nconst Target = Type.Record(S, Json);\nconst Error = Type.Object({ code: S, message: S });\nconst Artifact = Type.Object({\n artifactId: S,\n status: values(['ready', 'failed']),\n sizeBytes: O(N),\n downloadUrl: O(S),\n previewUrl: O(S),\n actionCount: O(N),\n completedAt: O(S),\n failure: O(Error),\n});\nexport const ComputerStateSchema = Type.Object({\n sessionId: S,\n revision: N,\n wake: N,\n phase: values(['inactive', 'awaiting_confirmation', 'activating', 'active', 'stopping', 'failed']),\n requestId: O(S),\n target: O(Target),\n durationMs: O(N),\n expiresAt: O(N),\n failure: O(Error),\n artifact: O(Artifact),\n});\nconst Permission = values(['accessibility', 'screen-recording', 'microphone', 'automation', 'full-disk-access']);\nconst PermissionState = values(['granted', 'denied', 'not-determined', 'per-app']);\nexport const DesktopPermissionStatesSchema = Type.Object({\n accessibility: PermissionState,\n 'screen-recording': PermissionState,\n microphone: PermissionState,\n automation: PermissionState,\n 'full-disk-access': PermissionState,\n});\nconst Reference = {\n snapshotId: Type.String({ minLength: 1 }),\n elementRef: Type.String({ minLength: 1 }),\n};\nexport const ComputerActionSchema = Type.Union([\n Type.Object(\n { kind: values(['press', 'focus', 'expand', 'collapse', 'toggle', 'check', 'uncheck', 'scroll_to']), ...Reference },\n { additionalProperties: false },\n ),\n Type.Object({ kind: values(['set_value', 'select']), ...Reference, value: S }, { additionalProperties: false }),\n Type.Object({ kind: Type.Literal('type'), ...Reference, text: S }, { additionalProperties: false }),\n Type.Object(\n {\n kind: Type.Literal('scroll'),\n ...Reference,\n direction: values(['up', 'down', 'left', 'right']),\n amount: Type.Union([values(['line', 'page']), Type.Integer({ minimum: 1, maximum: 100 })]),\n },\n { additionalProperties: false },\n ),\n]);\nconst internal = (\n method: 'GET' | 'POST',\n path: string,\n output: object,\n body?: object,\n status = 200,\n): PoHttpContract => ({\n id: `computer.${path.slice(1).replaceAll('/', '.')}`,\n scope: 'session',\n basePath: 'computer-use',\n path,\n method,\n authentication: 'owner',\n description: `Computer use broker ${path}. Requires the host-issued ${path.startsWith('/agent/') ? 'agent' : 'hub'} bearer token.`,\n availability: 'Internal broker route; ordinary browser credentials are insufficient.',\n parameters: [\n {\n name: 'Authorization',\n in: 'header',\n required: true,\n schema: Type.String({ pattern: '^Bearer .+' }),\n },\n ],\n ...(body\n ? {\n body: { required: true, contentType: 'application/json', schema: body },\n }\n : {}),\n responses: jsonApiResponses(output, status),\n});\nexport const apiContracts = defineApiContract({\n version: 1,\n dynamic: ['Desktop provider target extensions, observations and operation results are runtime-defined JSON.'],\n http: [\n ...(['host', 'workspace', 'session'] as const).flatMap((scope) =>\n (['GET', 'POST'] as const).map((method) => ({\n id: `computer.permissions.${method === 'GET' ? 'read' : 'request'}`,\n scope,\n basePath: 'desktop-permissions',\n path: '/',\n method,\n authentication: 'owner' as const,\n description:\n method === 'GET'\n ? 'Read the Mac-owned permission states. Requires an authorized local Desktop caller or trusted remote caller.'\n : 'Ask macOS for one named permission. Requires an authorized local Desktop caller or remote passkey step-up.',\n availability: 'Requires Po Desktop to be running this server; otherwise returns 404.',\n ...(method === 'POST'\n ? {\n body: {\n required: true,\n contentType: 'application/json',\n schema: Type.Object({ permission: Permission }),\n },\n }\n : {}),\n responses: {\n ...jsonApiResponses(DesktopPermissionStatesSchema),\n '502': {\n description: 'Desktop permission request failed.',\n schema: Type.Object({ error: S }),\n },\n },\n })),\n ),\n {\n id: 'computer.artifact',\n scope: 'session',\n basePath: 'computer-use',\n path: '/artifact',\n method: 'GET',\n authentication: 'owner',\n description: 'Read at most 1 MiB of a recording belonging to this session and approved caller.',\n parameters: [\n { name: 'artifactId', in: 'query', required: true, schema: S },\n {\n name: 'offset',\n in: 'query',\n required: true,\n schema: Type.Integer({ minimum: 0 }),\n },\n ],\n responses: {\n 206: {\n description: 'Bounded recording bytes.',\n contentType: 'video/mp4',\n schema: Type.String({ format: 'binary' }),\n },\n },\n },\n internal('GET', '/agent/state', ComputerStateSchema),\n internal('GET', '/hub/state', ComputerStateSchema),\n internal('POST', '/hub/request-stop', ComputerStateSchema, undefined, 202),\n internal('POST', '/agent/observe', Json),\n internal('POST', '/agent/action', Json, ComputerActionSchema),\n internal('POST', '/agent/stop', ComputerStateSchema, undefined, 202),\n internal(\n 'GET',\n '/hub/activation',\n Type.Union([\n Type.Null(),\n Type.Object({\n requestId: S,\n target: Target,\n durationSeconds: N,\n createdAt: N,\n confirmationExpiresAt: N,\n caller: Type.Object({\n locality: values(['local', 'remote']),\n stepUp: S,\n }),\n }),\n ]),\n ),\n internal('GET', '/hub/authorization', Type.Union([Type.Null(), Type.Object({ grantId: S, expiresAt: O(N) })])),\n internal(\n 'GET',\n '/hub/next',\n Type.Union([\n Type.Null(),\n Type.Object({\n id: S,\n operation: values(['observe', 'act']),\n payload: O(Json),\n grantId: S,\n sequence: O(N),\n }),\n ]),\n ),\n internal('POST', '/hub/complete', ComputerStateSchema, Type.Object({ id: S, error: O(S), result: O(Json) })),\n internal(\n 'POST',\n '/hub/stop',\n ComputerStateSchema,\n Type.Object({\n error: O(S),\n host: O(Type.Object({ grantId: S, expiresAt: N })),\n artifact: O(Artifact),\n }),\n ),\n ],\n sockets: (['host', 'workspace'] as const).flatMap((scope) => [\n {\n id: 'computer.state',\n scope,\n service: 'po.hub',\n member: 'computer_use_state',\n kind: 'channel',\n direction: 'server-to-client',\n description: 'Computer use channel payload.',\n input: Type.Object({\n state: ComputerStateSchema,\n targets: Type.Array(Target),\n busy: O(Type.Literal(true)),\n }),\n },\n {\n id: 'computer.command',\n scope,\n service: 'po.hub',\n member: 'computer_use_state',\n kind: 'channel',\n direction: 'client-to-server',\n description: 'Computer use browser channel command.',\n input: Type.Object({\n action: values(['status', 'targets', 'stop', 'artifacts']),\n }),\n },\n ]),\n});\nexport default apiContracts;\n"],"mappings":";;;AAGA,MAAM,IAAI,KAAK,OAAO;AACtB,MAAM,IAAI,KAAK,OAAO;AACtB,MAAM,IAAI,KAAK;AACf,MAAM,UAA4B,UAAe,KAAK,MAAM,MAAM,KAAK,SAAS,KAAK,QAAQ,IAAI,CAAC,CAAC;AACnG,MAAM,OAAO,KAAK,QAAQ,EACxB,aACE,uHACJ,CAAC;AACD,MAAM,SAAS,KAAK,OAAO,G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