@agimon-ai/po-computer-use 0.0.0-alpha.18 → 0.0.0-alpha.181

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 (44) hide show
  1. package/LICENSE +149 -21
  2. package/README.md +9 -8
  3. package/dist/apiContracts.cjs +65 -45
  4. package/dist/apiContracts.cjs.map +1 -1
  5. package/dist/apiContracts.d.mts +2 -2
  6. package/dist/apiContracts.d.mts.map +1 -1
  7. package/dist/apiContracts.mjs +65 -45
  8. package/dist/apiContracts.mjs.map +1 -1
  9. package/dist/extensionService-BKBTsnkI.cjs +1243 -0
  10. package/dist/extensionService-BKBTsnkI.cjs.map +1 -0
  11. package/dist/extensionService-DqtoB79s.mjs +1077 -0
  12. package/dist/extensionService-DqtoB79s.mjs.map +1 -0
  13. package/dist/extensions/mcp.cjs +2 -2
  14. package/dist/extensions/mcp.cjs.map +1 -1
  15. package/dist/extensions/mcp.mjs +2 -2
  16. package/dist/extensions/mcp.mjs.map +1 -1
  17. package/dist/extensions/native.mjs +1396 -4
  18. package/dist/extensions/native.mjs.map +1 -1
  19. package/dist/extensions/server.cjs +956 -639
  20. package/dist/extensions/server.cjs.map +1 -1
  21. package/dist/extensions/server.d.mts.map +1 -1
  22. package/dist/extensions/server.mjs +941 -624
  23. package/dist/extensions/server.mjs.map +1 -1
  24. package/dist/extensions/web.mjs +872 -470
  25. package/dist/extensions/web.mjs.map +1 -1
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.mts +62 -9
  29. package/dist/index.d.mts.map +1 -1
  30. package/dist/index.mjs +1 -1
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/po-runtime-identity.json +1 -0
  33. package/docs/computer-scripts.md +1 -1
  34. package/docs/remote-computer-use.md +11 -0
  35. package/llms.txt +1 -1
  36. package/package.json +68 -23
  37. package/src/prompts/codemode-how-to-computer-use/SKILL.md +83 -0
  38. package/src/types/computerUse.ts +72 -7
  39. package/src/types/computerUseApi.ts +24 -5
  40. package/dist/extensionService-Bp0q295i.cjs +0 -504
  41. package/dist/extensionService-Bp0q295i.cjs.map +0 -1
  42. package/dist/extensionService-DXvF7esO.mjs +0 -434
  43. package/dist/extensionService-DXvF7esO.mjs.map +0 -1
  44. package/src/prompts/po-use-computer-use/SKILL.md +0 -34
package/LICENSE CHANGED
@@ -1,21 +1,149 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Vuong Ngo
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
2
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
3
+
4
+ Parameters
5
+
6
+ Licensor: Agimon Pty Ltd
7
+ Licensed Work: Po, the software in the Po source repository and the
8
+ packages released from it, in each version released by
9
+ the Licensor.
10
+ The Licensed Work is (c) 2026 Agimon Pty Ltd.
11
+ Material identified as third-party in the "Third-party
12
+ components" section at the end of this file or in a
13
+ NOTICE file, and any package or directory whose own
14
+ license file grants a different license, is not part of
15
+ the Licensed Work and remains under its own license.
16
+ Additional Use Grant: You may make production use of the Licensed Work if
17
+ your use is Eligible Use. "Eligible Use" is production use that falls
18
+ within at least one of the following:
19
+
20
+ (a) Personal Use. Use by an individual for their own personal purposes,
21
+ and not on behalf of, or for the benefit of, an employer, client, or
22
+ other Organization. Use by an individual in the course of employment
23
+ or engagement by an Organization is use by that Organization.
24
+
25
+ (b) Small Organization Use. Use by or on behalf of an Organization whose
26
+ Annual Revenue is less than USD 1,000,000.
27
+
28
+ (c) Non-profit, Education and Research Use. Use, regardless of Annual
29
+ Revenue, by (i) an Organization registered or recognized as a
30
+ non-profit or charitable organization under the laws of its
31
+ jurisdiction, for its non-profit purposes; (ii) an accredited school,
32
+ college, or university, for teaching, learning, or academic research;
33
+ or (iii) a publicly funded research institution, for its research.
34
+
35
+ (d) Service Provider Use. Use by a consultant, contractor, agency, or other
36
+ service provider, regardless of its own Annual Revenue, solely to
37
+ build, deploy, host, operate, or support the Licensed Work for a client
38
+ whose own use would be Eligible Use under (a), (b), or (c). A service
39
+ provider's use for its own purposes is Eligible Use only if the service
40
+ provider itself qualifies under (b) or (c).
41
+
42
+
43
+ Hosted services. Offering the Licensed Work to third parties as a hosted
44
+ or managed service whose primary value is the Licensed Work is Eligible
45
+ Use only if each such third party's own use would be Eligible Use.
46
+
47
+ Definitions. "Organization" means any company, partnership, sole
48
+ proprietorship, trust, association, government body, or other entity, and
49
+ includes an individual acting in a business or professional capacity.
50
+ "Affiliate" means any entity that directly or indirectly controls, is
51
+ controlled by, or is under common control with an Organization, where
52
+ "control" means ownership of more than 50% of the voting interests of an
53
+ entity or the power to direct its management and policies by contract or
54
+ otherwise. "Annual Revenue" means the total gross revenue of an
55
+ Organization and all of its Affiliates combined, from all sources and
56
+ whether or not related to the Licensed Work, for its most recently
57
+ completed fiscal year, or, if it has not completed a fiscal year, for the
58
+ twelve months before the use (or since its formation, if shorter),
59
+ converted into US dollars at the average exchange rate for that period.
60
+ Proceeds of equity or debt financing are not revenue.
61
+
62
+ Threshold. If an Organization stops qualifying under (b), its existing
63
+ production use remains Eligible Use for 90 days after it stops
64
+ qualifying, after which it must obtain a commercial license or stop
65
+ production use. Use that was Eligible Use when it occurred never requires
66
+ a commercial license after the fact.
67
+ Change Date: Four years from the date a version of the Licensed Work
68
+ is first publicly released by the Licensor.
69
+ Change License: Apache License, Version 2.0
70
+
71
+ For information about alternative licensing arrangements for the Licensed
72
+ Work, please visit: https://agimon.ai/licensing
73
+
74
+ Notice
75
+
76
+ The Business Source License (this document, or the "License") is not an Open
77
+ Source license. However, the Licensed Work will eventually be made available
78
+ under an Open Source License, as stated in this License.
79
+
80
+ -----------------------------------------------------------------------------
81
+
82
+ Business Source License 1.1
83
+
84
+ Terms
85
+
86
+ The Licensor hereby grants you the right to copy, modify, create derivative
87
+ works, redistribute, and make non-production use of the Licensed Work. The
88
+ Licensor may make an Additional Use Grant, above, permitting limited
89
+ production use.
90
+
91
+ Effective on the Change Date, or the fourth anniversary of the first publicly
92
+ available distribution of a specific version of the Licensed Work under this
93
+ License, whichever comes first, the Licensor hereby grants you rights under
94
+ the terms of the Change License, and the rights granted in the paragraph
95
+ above terminate.
96
+
97
+ If your use of the Licensed Work does not comply with the requirements
98
+ currently in effect as described in this License, you must purchase a
99
+ commercial license from the Licensor, its affiliated entities, or authorized
100
+ resellers, or you must refrain from using the Licensed Work.
101
+
102
+ All copies of the original and modified Licensed Work, and derivative works
103
+ of the Licensed Work, are subject to this License. This License applies
104
+ separately for each version of the Licensed Work and the Change Date may vary
105
+ for each version of the Licensed Work released by Licensor.
106
+
107
+ You must conspicuously display this License on each original or modified copy
108
+ of the Licensed Work. If you receive the Licensed Work in original or
109
+ modified form from a third party, the terms and conditions set forth in this
110
+ License apply to your use of that work.
111
+
112
+ Any use of the Licensed Work in violation of this License will automatically
113
+ terminate your rights under this License for the current and all other
114
+ versions of the Licensed Work.
115
+
116
+ This License does not grant you any right in any trademark or logo of
117
+ Licensor or its affiliates (provided that you may use a trademark or logo of
118
+ Licensor as expressly required by this License).
119
+
120
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
121
+ AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
122
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
123
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
124
+ TITLE.
125
+
126
+ MariaDB hereby grants you permission to use this License’s text to license
127
+ your works, and to refer to it using the trademark “Business Source License”,
128
+ as long as you comply with the Covenants of Licensor below.
129
+
130
+ Covenants of Licensor
131
+
132
+ In consideration of the right to use this License’s text and the “Business
133
+ Source License” name and trademark, Licensor covenants to MariaDB, and to all
134
+ other recipients of the licensed work to be provided by Licensor:
135
+
136
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
137
+ or a license that is compatible with GPL Version 2.0 or a later version,
138
+ where “compatible” means that software provided under the Change License can
139
+ be included in a program with software provided under GPL Version 2.0 or a
140
+ later version. Licensor may specify additional Change Licenses without
141
+ limitation.
142
+
143
+ 2. To either: (a) specify an additional grant of rights to use that does not
144
+ impose any additional restriction on the right granted in this License, as
145
+ the Additional Use Grant; or (b) insert the text “None”.
146
+
147
+ 3. To specify a Change Date.
148
+
149
+ 4. Not to modify this License in any other way.
package/README.md CHANGED
@@ -10,19 +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 global settings, then select the default-off **Computer Use** minor mode. Its Activity section lists eligible application windows and starts native confirmation. Only one session can hold a live Desktop run. The setting, minor-mode row, and Activity group are hidden in a normal browser, including a browser opened against the Desktop server.
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
- The `computer-use` minor mode exposes Activate, Deactivate, and Doctor actions. `/computer-use` reports the current state.
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
- - `computer_state` observes the authorized window and returns a semantic snapshot.
20
- - `computer_action` performs one semantic press, focus change, value change, or scroll against a current snapshot.
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 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
+ 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.
23
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.
24
25
 
25
- All three tools remain unavailable during setup and are admitted only after the native grant becomes active. Disabling the mode or global opt-in, stopping control, expiry, or Desktop disconnection stops further actions. Once Desktop claims a session, browser and remote MCP clients cannot drive it, including previously attached clients. This ownership stays pinned for the server lifetime and is not restored from saved session data.
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
+
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.
26
29
 
27
30
  ## Public API
28
31
 
@@ -44,6 +47,4 @@ pnpm build
44
47
 
45
48
  ## License
46
49
 
47
- MIT
48
-
49
- Direct plugin routes live in `src/extensions`. The session root constructs one broker shared by the typed agent client and activation API. The host owns the Desktop IPC connection, native renderer authentication, session identity, and grant lifetime. The hub channel uses lifecycle events rather than polling to forward operations. Public exports remain under `src/exports`.
50
+ Business Source License 1.1: free for personal use, organisations under USD 1M revenue, non-profits and education. See [LICENSE](LICENSE) and https://agimon.ai/licensing.
@@ -44,20 +44,54 @@ const ComputerStateSchema = typebox.Type.Object({
44
44
  failure: O(Error),
45
45
  artifact: O(Artifact)
46
46
  });
47
+ const Permission = values([
48
+ "accessibility",
49
+ "screen-recording",
50
+ "microphone",
51
+ "automation",
52
+ "full-disk-access"
53
+ ]);
54
+ const PermissionState = values([
55
+ "granted",
56
+ "denied",
57
+ "not-determined",
58
+ "per-app"
59
+ ]);
60
+ const DesktopPermissionStatesSchema = typebox.Type.Object({
61
+ accessibility: PermissionState,
62
+ "screen-recording": PermissionState,
63
+ microphone: PermissionState,
64
+ automation: PermissionState,
65
+ "full-disk-access": PermissionState
66
+ });
47
67
  const Reference = {
48
68
  snapshotId: typebox.Type.String({ minLength: 1 }),
49
69
  elementRef: typebox.Type.String({ minLength: 1 })
50
70
  };
51
71
  const ComputerActionSchema = typebox.Type.Union([
52
72
  typebox.Type.Object({
53
- 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
+ ]),
54
83
  ...Reference
55
84
  }, { additionalProperties: false }),
56
85
  typebox.Type.Object({
57
- kind: typebox.Type.Literal("set_value"),
86
+ kind: values(["set_value", "select"]),
58
87
  ...Reference,
59
88
  value: S
60
89
  }, { additionalProperties: false }),
90
+ typebox.Type.Object({
91
+ kind: typebox.Type.Literal("type"),
92
+ ...Reference,
93
+ text: S
94
+ }, { additionalProperties: false }),
61
95
  typebox.Type.Object({
62
96
  kind: typebox.Type.Literal("scroll"),
63
97
  ...Reference,
@@ -67,7 +101,10 @@ const ComputerActionSchema = typebox.Type.Union([
67
101
  "left",
68
102
  "right"
69
103
  ]),
70
- amount: values(["line", "page"])
104
+ amount: typebox.Type.Union([values(["line", "page"]), typebox.Type.Integer({
105
+ minimum: 1,
106
+ maximum: 100
107
+ })])
71
108
  }, { additionalProperties: false })
72
109
  ]);
73
110
  const internal = (method, path, output, body, status = 200) => ({
@@ -96,50 +133,32 @@ const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
96
133
  version: 1,
97
134
  dynamic: ["Desktop provider target extensions, observations and operation results are runtime-defined JSON."],
98
135
  http: [
99
- {
100
- id: "computer.activation.state",
101
- scope: "session",
102
- basePath: "computer-use",
103
- path: "/activate",
104
- method: "GET",
136
+ ...[
137
+ "host",
138
+ "workspace",
139
+ "session"
140
+ ].flatMap((scope) => ["GET", "POST"].map((method) => ({
141
+ id: `computer.permissions.${method === "GET" ? "read" : "request"}`,
142
+ scope,
143
+ basePath: "desktop-permissions",
144
+ path: "/",
145
+ method,
105
146
  authentication: "owner",
106
- description: "Read state as the matching pending requester or approved recording reader.",
107
- responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(ComputerStateSchema)
108
- },
109
- {
110
- id: "computer.activation.cancel",
111
- scope: "session",
112
- basePath: "computer-use",
113
- path: "/activate",
114
- method: "DELETE",
115
- authentication: "owner",
116
- description: "Cancel only the matching requester pending activation.",
117
- responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(ComputerStateSchema, 202)
118
- },
119
- {
120
- id: "computer.activate",
121
- scope: "session",
122
- basePath: "computer-use",
123
- path: "/activate",
124
- method: "POST",
125
- authentication: "owner",
126
- description: "Request confirmed Desktop access with admitted caller and remote step-up context. A remote caller may omit target so the local Mac selects the window.",
127
- body: {
147
+ description: method === "GET" ? "Read the Mac-owned permission states. Requires an authorized local Desktop caller or trusted remote caller." : "Ask macOS for one named permission. Requires an authorized local Desktop caller or remote passkey step-up.",
148
+ availability: "Requires Po Desktop to be running this server; otherwise returns 404.",
149
+ ...method === "POST" ? { body: {
128
150
  required: true,
129
151
  contentType: "application/json",
130
- schema: typebox.Type.Object({
131
- target: O(typebox.Type.Object({
132
- windowId: S,
133
- bundleId: S
134
- })),
135
- durationMs: typebox.Type.Integer({
136
- minimum: 1e3,
137
- maximum: 18e5
138
- })
139
- })
140
- },
141
- responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(ComputerStateSchema, 202)
142
- },
152
+ schema: typebox.Type.Object({ permission: Permission })
153
+ } } : {},
154
+ responses: {
155
+ ...(0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(DesktopPermissionStatesSchema),
156
+ "502": {
157
+ description: "Desktop permission request failed.",
158
+ schema: typebox.Type.Object({ error: S })
159
+ }
160
+ }
161
+ }))),
143
162
  {
144
163
  id: "computer.artifact",
145
164
  scope: "session",
@@ -167,6 +186,7 @@ const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
167
186
  },
168
187
  internal("GET", "/agent/state", ComputerStateSchema),
169
188
  internal("GET", "/hub/state", ComputerStateSchema),
189
+ internal("POST", "/hub/request-stop", ComputerStateSchema, void 0, 202),
170
190
  internal("POST", "/agent/observe", Json),
171
191
  internal("POST", "/agent/action", Json, ComputerActionSchema),
172
192
  internal("POST", "/agent/stop", ComputerStateSchema, void 0, 202),
@@ -206,7 +226,7 @@ const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
206
226
  artifact: O(Artifact)
207
227
  }))
208
228
  ],
209
- sockets: ["global", "workspace"].flatMap((scope) => [{
229
+ sockets: ["host", "workspace"].flatMap((scope) => [{
210
230
  id: "computer.state",
211
231
  scope,
212
232
  service: "po.hub",
@@ -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 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 {\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. A remote caller may omit target so the local Mac selects the window.',\n body: {\n required: true,\n contentType: 'application/json',\n schema: Type.Object({\n target: O(Type.Object({ windowId: S, bundleId: S })),\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: (['global', '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', 'st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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,CAAC,CAAC;AACnG,MAAM,OAAOA,QAAAA,KAAK,QAAQ,EACxB,aACE,uHACJ,CAAC;AACD,MAAM,SAASA,QAAAA,KAAK,OAAO,GAAG,IAAI;AAClC,MAAM,QAAQA,QAAAA,KAAK,OAAO;CAAE,MAAM;CAAG,SAAS;AAAE,CAAC;AACjD,MAAM,WAAWA,QAAAA,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,sBAAsBA,QAAAA,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,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OAAO;GAAE,IAAI;GAAG,OAAO,EAAE,CAAC;GAAG,QAAQ,EAAE,IAAI;EAAE,CAAC,CAAC;EAC3G,SACE,QACA,aACA,qBACAA,QAAAA,KAAK,OAAO;GACV,OAAO,EAAE,CAAC;GACV,MAAM,EAAEA,QAAAA,KAAK,OAAO;IAAE,SAAS;IAAG,WAAW;GAAE,CAAC,CAAC;GACjD,UAAU,EAAE,QAAQ;EACtB,CAAC,CACH;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;GACjB,OAAO;GACP,SAASA,QAAAA,KAAK,MAAM,MAAM;GAC1B,MAAM,EAAEA,QAAAA,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"}
@@ -6,7 +6,7 @@ export declare const apiContracts: {
6
6
  schemas?: Record<string, boolean | object> | undefined;
7
7
  http: {
8
8
  id: string;
9
- scope: "global" | "session" | "workspace";
9
+ scope: "host" | "session" | "workspace";
10
10
  basePath?: string | undefined;
11
11
  path: string;
12
12
  method: "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT";
@@ -34,7 +34,7 @@ export declare const apiContracts: {
34
34
  }[];
35
35
  sockets: {
36
36
  id: string;
37
- scope: "global" | "session" | "workspace";
37
+ scope: "host" | "session" | "workspace";
38
38
  description: string;
39
39
  availability?: string | undefined;
40
40
  service: string;
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";;qBAoEa"}
1
+ {"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";;qBA+Fa"}
@@ -40,20 +40,54 @@ const ComputerStateSchema = Type.Object({
40
40
  failure: O(Error),
41
41
  artifact: O(Artifact)
42
42
  });
43
+ const Permission = values([
44
+ "accessibility",
45
+ "screen-recording",
46
+ "microphone",
47
+ "automation",
48
+ "full-disk-access"
49
+ ]);
50
+ const PermissionState = values([
51
+ "granted",
52
+ "denied",
53
+ "not-determined",
54
+ "per-app"
55
+ ]);
56
+ const DesktopPermissionStatesSchema = Type.Object({
57
+ accessibility: PermissionState,
58
+ "screen-recording": PermissionState,
59
+ microphone: PermissionState,
60
+ automation: PermissionState,
61
+ "full-disk-access": PermissionState
62
+ });
43
63
  const Reference = {
44
64
  snapshotId: Type.String({ minLength: 1 }),
45
65
  elementRef: Type.String({ minLength: 1 })
46
66
  };
47
67
  const ComputerActionSchema = Type.Union([
48
68
  Type.Object({
49
- 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
+ ]),
50
79
  ...Reference
51
80
  }, { additionalProperties: false }),
52
81
  Type.Object({
53
- kind: Type.Literal("set_value"),
82
+ kind: values(["set_value", "select"]),
54
83
  ...Reference,
55
84
  value: S
56
85
  }, { additionalProperties: false }),
86
+ Type.Object({
87
+ kind: Type.Literal("type"),
88
+ ...Reference,
89
+ text: S
90
+ }, { additionalProperties: false }),
57
91
  Type.Object({
58
92
  kind: Type.Literal("scroll"),
59
93
  ...Reference,
@@ -63,7 +97,10 @@ const ComputerActionSchema = Type.Union([
63
97
  "left",
64
98
  "right"
65
99
  ]),
66
- amount: values(["line", "page"])
100
+ amount: Type.Union([values(["line", "page"]), Type.Integer({
101
+ minimum: 1,
102
+ maximum: 100
103
+ })])
67
104
  }, { additionalProperties: false })
68
105
  ]);
69
106
  const internal = (method, path, output, body, status = 200) => ({
@@ -92,50 +129,32 @@ const apiContracts = defineApiContract({
92
129
  version: 1,
93
130
  dynamic: ["Desktop provider target extensions, observations and operation results are runtime-defined JSON."],
94
131
  http: [
95
- {
96
- id: "computer.activation.state",
97
- scope: "session",
98
- basePath: "computer-use",
99
- path: "/activate",
100
- method: "GET",
132
+ ...[
133
+ "host",
134
+ "workspace",
135
+ "session"
136
+ ].flatMap((scope) => ["GET", "POST"].map((method) => ({
137
+ id: `computer.permissions.${method === "GET" ? "read" : "request"}`,
138
+ scope,
139
+ basePath: "desktop-permissions",
140
+ path: "/",
141
+ method,
101
142
  authentication: "owner",
102
- description: "Read state as the matching pending requester or approved recording reader.",
103
- responses: jsonApiResponses(ComputerStateSchema)
104
- },
105
- {
106
- id: "computer.activation.cancel",
107
- scope: "session",
108
- basePath: "computer-use",
109
- path: "/activate",
110
- method: "DELETE",
111
- authentication: "owner",
112
- description: "Cancel only the matching requester pending activation.",
113
- responses: jsonApiResponses(ComputerStateSchema, 202)
114
- },
115
- {
116
- id: "computer.activate",
117
- scope: "session",
118
- basePath: "computer-use",
119
- path: "/activate",
120
- method: "POST",
121
- authentication: "owner",
122
- description: "Request confirmed Desktop access with admitted caller and remote step-up context. A remote caller may omit target so the local Mac selects the window.",
123
- body: {
143
+ description: method === "GET" ? "Read the Mac-owned permission states. Requires an authorized local Desktop caller or trusted remote caller." : "Ask macOS for one named permission. Requires an authorized local Desktop caller or remote passkey step-up.",
144
+ availability: "Requires Po Desktop to be running this server; otherwise returns 404.",
145
+ ...method === "POST" ? { body: {
124
146
  required: true,
125
147
  contentType: "application/json",
126
- schema: Type.Object({
127
- target: O(Type.Object({
128
- windowId: S,
129
- bundleId: S
130
- })),
131
- durationMs: Type.Integer({
132
- minimum: 1e3,
133
- maximum: 18e5
134
- })
135
- })
136
- },
137
- responses: jsonApiResponses(ComputerStateSchema, 202)
138
- },
148
+ schema: Type.Object({ permission: Permission })
149
+ } } : {},
150
+ responses: {
151
+ ...jsonApiResponses(DesktopPermissionStatesSchema),
152
+ "502": {
153
+ description: "Desktop permission request failed.",
154
+ schema: Type.Object({ error: S })
155
+ }
156
+ }
157
+ }))),
139
158
  {
140
159
  id: "computer.artifact",
141
160
  scope: "session",
@@ -163,6 +182,7 @@ const apiContracts = defineApiContract({
163
182
  },
164
183
  internal("GET", "/agent/state", ComputerStateSchema),
165
184
  internal("GET", "/hub/state", ComputerStateSchema),
185
+ internal("POST", "/hub/request-stop", ComputerStateSchema, void 0, 202),
166
186
  internal("POST", "/agent/observe", Json),
167
187
  internal("POST", "/agent/action", Json, ComputerActionSchema),
168
188
  internal("POST", "/agent/stop", ComputerStateSchema, void 0, 202),
@@ -202,7 +222,7 @@ const apiContracts = defineApiContract({
202
222
  artifact: O(Artifact)
203
223
  }))
204
224
  ],
205
- sockets: ["global", "workspace"].flatMap((scope) => [{
225
+ sockets: ["host", "workspace"].flatMap((scope) => [{
206
226
  id: "computer.state",
207
227
  scope,
208
228
  service: "po.hub",