@agimon-ai/po-computer-use 0.0.0-alpha.2 → 0.0.0-alpha.200
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +97 -8
- package/README.md +10 -9
- package/dist/apiContracts.cjs +67 -47
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts +2 -2
- package/dist/apiContracts.d.mts.map +1 -1
- package/dist/apiContracts.mjs +67 -47
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/extensionService-BKBTsnkI.cjs +1243 -0
- package/dist/extensionService-BKBTsnkI.cjs.map +1 -0
- package/dist/extensionService-DqtoB79s.mjs +1077 -0
- package/dist/extensionService-DqtoB79s.mjs.map +1 -0
- package/dist/extensions/mcp-ui.mjs +12 -9
- package/dist/extensions/mcp-ui.mjs.map +1 -1
- package/dist/extensions/mcp.cjs +3 -3
- package/dist/extensions/mcp.cjs.map +1 -1
- package/dist/extensions/mcp.d.mts +1 -1
- package/dist/extensions/mcp.mjs +3 -3
- package/dist/extensions/mcp.mjs.map +1 -1
- package/dist/extensions/native.mjs +1445 -5
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/server.cjs +1025 -653
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts +2 -2
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +1007 -635
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +959 -481
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/index.cjs +14 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +69 -12
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +14 -5
- package/dist/index.mjs.map +1 -1
- package/dist/po-runtime-identity.json +1 -0
- package/docs/computer-scripts.md +1 -1
- package/docs/remote-computer-use.md +11 -0
- package/llms.txt +1 -1
- package/package.json +74 -29
- package/src/prompts/codemode-how-to-computer-use/SKILL.md +83 -0
- package/src/types/computerUse.ts +72 -7
- package/src/types/computerUseApi.ts +26 -7
- package/dist/extensionService-Bp0q295i.cjs +0 -504
- package/dist/extensionService-Bp0q295i.cjs.map +0 -1
- package/dist/extensionService-DXvF7esO.mjs +0 -434
- package/dist/extensionService-DXvF7esO.mjs.map +0 -1
- package/src/prompts/po-use-computer-use/SKILL.md +0 -34
package/LICENSE
CHANGED
|
@@ -1,13 +1,102 @@
|
|
|
1
|
-
MIT License
|
|
1
|
+
# Functional Source License, Version 1.1, MIT Future License
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Abbreviation
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
FSL-1.1-MIT
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 Agimon Pty Ltd
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the MIT license that is effective on the second anniversary of the date we make
|
|
91
|
+
the Software available. On or after that date, you may use the Software under
|
|
92
|
+
the MIT license, in which case the following will apply:
|
|
93
|
+
|
|
94
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
95
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
96
|
+
the Software without restriction, including without limitation the rights to
|
|
97
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
98
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
99
|
+
so, subject to the following conditions:
|
|
11
100
|
|
|
12
101
|
The above copyright notice and this permission notice shall be included in all
|
|
13
102
|
copies or substantial portions of the Software.
|
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
|
|
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`
|
|
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
|
|
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
|
-
|
|
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
|
|
|
@@ -31,7 +34,7 @@ import { ComputerScriptRunner, createComputerUseSessionClient } from '@agimon-ai
|
|
|
31
34
|
import type { ComputerScriptRun } from '@agimon-ai/po-computer-use';
|
|
32
35
|
```
|
|
33
36
|
|
|
34
|
-
The session-scoped server
|
|
37
|
+
The session-scoped server plugin owns the agent and hub routes. Their host-issued context tokens remain opaque and session-bound inside the request broker.
|
|
35
38
|
|
|
36
39
|
## Development
|
|
37
40
|
|
|
@@ -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
|
+
Functional Source License 1.1, MIT Future License (FSL-1.1-MIT): free for any purpose except a Competing Use; each version converts to MIT two years after release. See [LICENSE](LICENSE).
|
package/dist/apiContracts.cjs
CHANGED
|
@@ -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([
|
|
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:
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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: "
|
|
107
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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,10 +226,10 @@ const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
|
|
|
206
226
|
artifact: O(Artifact)
|
|
207
227
|
}))
|
|
208
228
|
],
|
|
209
|
-
sockets: ["
|
|
229
|
+
sockets: ["host", "workspace"].flatMap((scope) => [{
|
|
210
230
|
id: "computer.state",
|
|
211
231
|
scope,
|
|
212
|
-
service: "po.hub
|
|
232
|
+
service: "po.hub",
|
|
213
233
|
member: "computer_use_state",
|
|
214
234
|
kind: "channel",
|
|
215
235
|
direction: "server-to-client",
|
|
@@ -222,7 +242,7 @@ const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
|
|
|
222
242
|
}, {
|
|
223
243
|
id: "computer.command",
|
|
224
244
|
scope,
|
|
225
|
-
service: "po.hub
|
|
245
|
+
service: "po.hub",
|
|
226
246
|
member: "computer_use_state",
|
|
227
247
|
kind: "channel",
|
|
228
248
|
direction: "client-to-server",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiContracts.cjs","names":["Type","jsonApiResponses","defineApiContract"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type DoomHttpContract } 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): DoomHttpContract => ({\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.v1',\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.v1',\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', '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a;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,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,EAA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,QAAAA,KAAK,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"}
|
package/dist/apiContracts.d.mts
CHANGED
|
@@ -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: "
|
|
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: "
|
|
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":";;
|
|
1
|
+
{"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";;qBA+Fa"}
|
package/dist/apiContracts.mjs
CHANGED
|
@@ -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([
|
|
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:
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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: "
|
|
103
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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,10 +222,10 @@ const apiContracts = defineApiContract({
|
|
|
202
222
|
artifact: O(Artifact)
|
|
203
223
|
}))
|
|
204
224
|
],
|
|
205
|
-
sockets: ["
|
|
225
|
+
sockets: ["host", "workspace"].flatMap((scope) => [{
|
|
206
226
|
id: "computer.state",
|
|
207
227
|
scope,
|
|
208
|
-
service: "po.hub
|
|
228
|
+
service: "po.hub",
|
|
209
229
|
member: "computer_use_state",
|
|
210
230
|
kind: "channel",
|
|
211
231
|
direction: "server-to-client",
|
|
@@ -218,7 +238,7 @@ const apiContracts = defineApiContract({
|
|
|
218
238
|
}, {
|
|
219
239
|
id: "computer.command",
|
|
220
240
|
scope,
|
|
221
|
-
service: "po.hub
|
|
241
|
+
service: "po.hub",
|
|
222
242
|
member: "computer_use_state",
|
|
223
243
|
kind: "channel",
|
|
224
244
|
direction: "client-to-server",
|