@openagt/dashboard 0.9.0 → 0.11.0
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/README.md +9 -17
- package/dist/built-in.d.ts +45 -16
- package/dist/built-in.d.ts.map +1 -1
- package/dist/built-in.js +95 -32
- package/dist/built-in.js.map +1 -1
- package/dist/cli.d.ts +4 -10
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +11 -67
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +2 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -4
- package/dist/client.js.map +1 -1
- package/dist/daemon-runtime.d.ts +12 -12
- package/dist/daemon-runtime.d.ts.map +1 -1
- package/dist/daemon-runtime.js +97 -37
- package/dist/daemon-runtime.js.map +1 -1
- package/dist/daemon.d.ts +3 -14
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +15 -26
- package/dist/daemon.js.map +1 -1
- package/dist/dashboard/bridge-endpoints.d.ts +5 -5
- package/dist/dashboard/bridge-endpoints.js +5 -5
- package/dist/dashboard/http.d.ts +1 -1
- package/dist/dashboard/http.js +1 -1
- package/dist/dashboard/machine-call.d.ts +10 -0
- package/dist/dashboard/machine-call.d.ts.map +1 -0
- package/dist/dashboard/machine-call.js +86 -0
- package/dist/dashboard/machine-call.js.map +1 -0
- package/dist/dashboard/relay-endpoints.d.ts +26 -17
- package/dist/dashboard/relay-endpoints.d.ts.map +1 -1
- package/dist/dashboard/relay-endpoints.js +70 -27
- package/dist/dashboard/relay-endpoints.js.map +1 -1
- package/dist/dashboard/remote-run.d.ts +77 -32
- package/dist/dashboard/remote-run.d.ts.map +1 -1
- package/dist/dashboard/remote-run.js +120 -42
- package/dist/dashboard/remote-run.js.map +1 -1
- package/dist/dashboard/rpc-serve.d.ts +19 -25
- package/dist/dashboard/rpc-serve.d.ts.map +1 -1
- package/dist/dashboard/rpc-serve.js +11 -22
- package/dist/dashboard/rpc-serve.js.map +1 -1
- package/dist/dashboard/screen.d.ts +53 -0
- package/dist/dashboard/screen.d.ts.map +1 -0
- package/dist/dashboard/screen.js +175 -0
- package/dist/dashboard/screen.js.map +1 -0
- package/dist/dashboard/server.d.ts +18 -19
- package/dist/dashboard/server.d.ts.map +1 -1
- package/dist/dashboard/server.js +52 -81
- package/dist/dashboard/server.js.map +1 -1
- package/dist/dashboard/start-branch.d.ts +32 -0
- package/dist/dashboard/start-branch.d.ts.map +1 -0
- package/dist/dashboard/start-branch.js +47 -0
- package/dist/dashboard/start-branch.js.map +1 -0
- package/dist/dashboard/types.d.ts +6 -14
- package/dist/dashboard/types.d.ts.map +1 -1
- package/dist/dashboard/web-start-endpoints.d.ts +2 -2
- package/dist/dashboard/web-start-endpoints.js +1 -1
- package/dist/dashboard-bundle/assets/main-9Xb8Ao4p.css +2 -0
- package/dist/dashboard-bundle/assets/main-DTyyQ0jM.js +140 -0
- package/dist/dashboard-bundle/assets/{module-v213KWfH.js → module-DKd-4BTU.js} +4 -4
- package/dist/dashboard-bundle/host/module.js +1 -1
- package/dist/dashboard-bundle/index.html +3 -3
- package/dist/dashboard-rpc/context.d.ts +4 -4
- package/dist/dashboard-rpc/context.js +5 -5
- package/dist/dashboard-rpc/context.js.map +1 -1
- package/dist/dashboard-rpc/control.d.ts +1 -1
- package/dist/dashboard-rpc/control.js +7 -7
- package/dist/dashboard-rpc/control.js.map +1 -1
- package/dist/dashboard-rpc/events.d.ts +1 -1
- package/dist/dashboard-rpc/events.js +1 -1
- package/dist/dashboard-rpc/index.d.ts +2 -1
- package/dist/dashboard-rpc/index.d.ts.map +1 -1
- package/dist/dashboard-rpc/index.js +5 -3
- package/dist/dashboard-rpc/index.js.map +1 -1
- package/dist/dashboard-rpc/machines.d.ts +52 -0
- package/dist/dashboard-rpc/machines.d.ts.map +1 -0
- package/dist/dashboard-rpc/machines.js +82 -0
- package/dist/dashboard-rpc/machines.js.map +1 -0
- package/dist/dashboard-rpc/modules.d.ts +1 -1
- package/dist/dashboard-rpc/modules.js +2 -2
- package/dist/dashboard-rpc/modules.js.map +1 -1
- package/dist/dashboard-rpc/projects.d.ts +2 -0
- package/dist/dashboard-rpc/projects.d.ts.map +1 -1
- package/dist/dashboard-rpc/projects.js +10 -2
- package/dist/dashboard-rpc/projects.js.map +1 -1
- package/dist/dashboard-rpc/reads.d.ts +3 -4
- package/dist/dashboard-rpc/reads.d.ts.map +1 -1
- package/dist/dashboard-rpc/reads.js +5 -6
- package/dist/dashboard-rpc/reads.js.map +1 -1
- package/dist/dashboard-rpc/relay-agent.d.ts +3 -3
- package/dist/dashboard-rpc/relay-agent.js +3 -3
- package/dist/dashboard-rpc/relay-dispatch.d.ts +4 -4
- package/dist/dashboard-rpc/relay-dispatch.d.ts.map +1 -1
- package/dist/dashboard-rpc/relay-dispatch.js +7 -7
- package/dist/dashboard-rpc/relay-dispatch.js.map +1 -1
- package/dist/dashboard-rpc/skills.d.ts +80 -0
- package/dist/dashboard-rpc/skills.d.ts.map +1 -0
- package/dist/dashboard-rpc/skills.js +84 -0
- package/dist/dashboard-rpc/skills.js.map +1 -0
- package/dist/dashboard-rpc/test-context.js +1 -1
- package/dist/dashboard-rpc/test-context.js.map +1 -1
- package/dist/events.d.ts +4 -3
- package/dist/events.d.ts.map +1 -1
- package/dist/loopback-host.d.ts +3 -5
- package/dist/loopback-host.d.ts.map +1 -1
- package/dist/loopback-host.js +3 -5
- package/dist/loopback-host.js.map +1 -1
- package/dist/machine-link.d.ts +21 -0
- package/dist/machine-link.d.ts.map +1 -0
- package/dist/machine-link.js +20 -0
- package/dist/machine-link.js.map +1 -0
- package/dist/module-server.d.ts +1 -1
- package/dist/module-types/dashboard/components/ui/switch.d.ts +7 -0
- package/dist/module-types/dashboard/lib/draft-handoff.d.ts +5 -9
- package/dist/module-types/dashboard/module/index.d.ts +46 -0
- package/dist/module-types/src/built-in.d.ts +45 -16
- package/dist/module-types/src/client.d.ts +2 -1
- package/dist/module-types/src/dashboard/bridge-endpoints.d.ts +5 -5
- package/dist/module-types/src/dashboard/http.d.ts +1 -1
- package/dist/module-types/src/dashboard/machine-call.d.ts +9 -0
- package/dist/module-types/src/dashboard/remote-run.d.ts +77 -32
- package/dist/module-types/src/dashboard/rpc-serve.d.ts +19 -25
- package/dist/module-types/src/dashboard/start-branch.d.ts +31 -0
- package/dist/module-types/src/dashboard/types.d.ts +6 -14
- package/dist/module-types/src/dashboard-rpc/context.d.ts +4 -4
- package/dist/module-types/src/dashboard-rpc/control.d.ts +1 -1
- package/dist/module-types/src/dashboard-rpc/events.d.ts +1 -1
- package/dist/module-types/src/dashboard-rpc/index.d.ts +2 -1
- package/dist/module-types/src/dashboard-rpc/machines.d.ts +51 -0
- package/dist/module-types/src/dashboard-rpc/modules.d.ts +1 -1
- package/dist/module-types/src/dashboard-rpc/projects.d.ts +2 -0
- package/dist/module-types/src/dashboard-rpc/reads.d.ts +3 -4
- package/dist/module-types/src/dashboard-rpc/relay-agent.d.ts +3 -3
- package/dist/module-types/src/dashboard-rpc/skills.d.ts +79 -0
- package/dist/module-types/src/events.d.ts +4 -3
- package/dist/module-types/src/loopback-host.d.ts +3 -5
- package/dist/module-types/src/machine-link.d.ts +20 -0
- package/dist/module-types/src/openagent-dir.d.ts +3 -5
- package/dist/module-types/src/project-commands.d.ts +4 -0
- package/dist/module-types/src/project-hooks.d.ts +8 -5
- package/dist/module-types/src/project-modules.d.ts +8 -6
- package/dist/module-types/src/registry.d.ts +59 -16
- package/dist/module-types/src/repository-address.d.ts +22 -0
- package/dist/module-types/src/screens.d.ts +13 -0
- package/dist/module-types/src/store/agent-store.d.ts +2 -2
- package/dist/module-types/src/store/branches.d.ts +1 -1
- package/dist/module-types/src/store/git-host.d.ts +1 -1
- package/dist/module-types/src/store/queue.d.ts +1 -1
- package/dist/module-types/src/store/runs.d.ts +1 -1
- package/dist/module-types/src/store/tickets.d.ts +1 -1
- package/dist/module-types/src/version.d.ts +1 -0
- package/dist/openagent-dir.d.ts +3 -5
- package/dist/openagent-dir.d.ts.map +1 -1
- package/dist/openagent-dir.js +3 -5
- package/dist/openagent-dir.js.map +1 -1
- package/dist/package-services.d.ts +27 -0
- package/dist/package-services.d.ts.map +1 -0
- package/dist/package-services.js +62 -0
- package/dist/package-services.js.map +1 -0
- package/dist/project-commands.d.ts +4 -0
- package/dist/project-commands.d.ts.map +1 -1
- package/dist/project-commands.js.map +1 -1
- package/dist/project-hooks.d.ts +8 -5
- package/dist/project-hooks.d.ts.map +1 -1
- package/dist/project-hooks.js +9 -6
- package/dist/project-hooks.js.map +1 -1
- package/dist/project-modules.d.ts +8 -6
- package/dist/project-modules.d.ts.map +1 -1
- package/dist/project-modules.js +7 -13
- package/dist/project-modules.js.map +1 -1
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +1 -2
- package/dist/project.js.map +1 -1
- package/dist/registry.d.ts +59 -16
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +91 -20
- package/dist/registry.js.map +1 -1
- package/dist/repository-address.d.ts +23 -0
- package/dist/repository-address.d.ts.map +1 -0
- package/dist/repository-address.js +38 -0
- package/dist/repository-address.js.map +1 -0
- package/dist/screens.d.ts +14 -0
- package/dist/screens.d.ts.map +1 -0
- package/dist/screens.js +40 -0
- package/dist/screens.js.map +1 -0
- package/dist/store/agent-store.d.ts +2 -2
- package/dist/store/agent-store.d.ts.map +1 -1
- package/dist/store/branches.d.ts +1 -1
- package/dist/store/branches.js +1 -1
- package/dist/store/git-host.d.ts +1 -1
- package/dist/store/git-host.js +2 -2
- package/dist/store/git-host.js.map +1 -1
- package/dist/store/queue.d.ts +1 -1
- package/dist/store/queue.js +1 -1
- package/dist/store/runs.d.ts +1 -1
- package/dist/store/runs.js +1 -1
- package/dist/store/test-branches.d.ts +0 -8
- package/dist/store/test-branches.d.ts.map +1 -1
- package/dist/store/test-branches.js +0 -24
- package/dist/store/test-branches.js.map +1 -1
- package/dist/store/tickets.d.ts +1 -1
- package/dist/store/tickets.js +1 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +26 -0
- package/dist/version.js.map +1 -0
- package/package.json +19 -13
- package/dist/dashboard-bundle/assets/main-B98UOA3_.js +0 -140
- package/dist/dashboard-bundle/assets/main-ByRjbCiA.css +0 -2
- package/dist/dashboard-rpc/devices.d.ts +0 -9
- package/dist/dashboard-rpc/devices.d.ts.map +0 -1
- package/dist/dashboard-rpc/devices.js +0 -12
- package/dist/dashboard-rpc/devices.js.map +0 -1
- package/dist/install.d.ts +0 -31
- package/dist/install.d.ts.map +0 -1
- package/dist/install.js +0 -54
- package/dist/install.js.map +0 -1
- package/dist/module-types/src/dashboard-rpc/devices.d.ts +0 -8
- package/dist/module-types/src/openagent-gitignore.d.ts +0 -11
- package/dist/openagent-gitignore.d.ts +0 -12
- package/dist/openagent-gitignore.d.ts.map +0 -1
- package/dist/openagent-gitignore.js +0 -19
- package/dist/openagent-gitignore.js.map +0 -1
|
@@ -1,74 +1,137 @@
|
|
|
1
1
|
import { EventStream } from '../event-stream.js';
|
|
2
2
|
import { errorMessage } from '../error-message.js';
|
|
3
|
+
import { machineFetch } from './machine-call.js';
|
|
3
4
|
const START_TIMEOUT_MS = 15_000;
|
|
4
|
-
/** How long a status ping waits before calling a
|
|
5
|
+
/** How long a status ping waits before calling a machine offline (#1072): short, since it polls. */
|
|
5
6
|
const PING_TIMEOUT_MS = 3_000;
|
|
7
|
+
/** One `GET /_relay/ping` with this computer's key: the answer when it is a 2xx, else nothing (the key no longer lets in, the host is unreachable, the time is up). */
|
|
8
|
+
async function ping(target) {
|
|
9
|
+
try {
|
|
10
|
+
const res = await machineFetch(`${trimSlashes(target.url)}/_relay/ping`, target.pin, {
|
|
11
|
+
headers: { authorization: `Bearer ${target.key}` },
|
|
12
|
+
signal: AbortSignal.timeout(PING_TIMEOUT_MS),
|
|
13
|
+
});
|
|
14
|
+
return res.ok ? res : undefined;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
6
20
|
/**
|
|
7
|
-
* Health-check a saved
|
|
8
|
-
*
|
|
9
|
-
* persisted, same as {@link startRemoteAgent}. This is how the browser's status dots learn reachable
|
|
10
|
-
* from not: it has the tokens, the daemon does the cross-origin request.
|
|
21
|
+
* Health-check a saved machine (#1072): true when it answers this computer's key. This is how
|
|
22
|
+
* the browser's status dots learn reachable from not.
|
|
11
23
|
*/
|
|
12
24
|
export async function pingRemote(target) {
|
|
25
|
+
return (await ping(target)) !== undefined;
|
|
26
|
+
}
|
|
27
|
+
/** The OpenAgent a saved machine runs, as its ping tells it; nothing for a machine that does not answer, or does not say. */
|
|
28
|
+
export async function remoteVersion(target) {
|
|
29
|
+
const said = await (await ping(target))?.json().catch(() => undefined);
|
|
30
|
+
const version = said && typeof said === 'object' ? said.version : undefined;
|
|
31
|
+
// What a machine says is shown on a page: only what reads as a version is one.
|
|
32
|
+
return typeof version === 'string' && /^[0-9A-Za-z.+-]{1,64}$/.test(version) ? version : undefined;
|
|
33
|
+
}
|
|
34
|
+
/** The two headers every relay request carries: JSON, and this computer's key there. No Origin on purpose. */
|
|
35
|
+
function relayHeaders(key) {
|
|
36
|
+
return { 'content-type': 'application/json', authorization: `Bearer ${key}` };
|
|
37
|
+
}
|
|
38
|
+
/** What a machine says when this computer's key no longer lets it in: it was removed there. */
|
|
39
|
+
const NOT_IN = 'this computer is no longer in on the machine: add the machine again, with a new link';
|
|
40
|
+
const ENTER_TIMEOUT_MS = 10_000;
|
|
41
|
+
/** How long a machine gets to take this computer out: it is not waited for by a person. */
|
|
42
|
+
const LEAVE_TIMEOUT_MS = 5_000;
|
|
43
|
+
/** What a machine answers to a code that was used before or is too old. */
|
|
44
|
+
const CODE_SPENT = 'this code no longer works';
|
|
45
|
+
/**
|
|
46
|
+
* Ask a machine to let this computer in, with the code its link carries, under `name`. The code
|
|
47
|
+
* is good once: a link used before, or older than a few minutes, is refused.
|
|
48
|
+
*/
|
|
49
|
+
export async function enterRemote(door, code, name, pin) {
|
|
50
|
+
let res;
|
|
13
51
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
52
|
+
res = await machineFetch(door, pin, {
|
|
53
|
+
method: 'POST',
|
|
54
|
+
headers: { 'content-type': 'application/json' },
|
|
55
|
+
body: JSON.stringify({ code, computer: name }),
|
|
56
|
+
signal: AbortSignal.timeout(ENTER_TIMEOUT_MS),
|
|
17
57
|
});
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
return { ok: false, error: `The machine did not answer: ${errorMessage(err)}` };
|
|
61
|
+
}
|
|
62
|
+
if (res.status === 403) {
|
|
63
|
+
// The machine says why in words: a link that was used is one reason among others (this
|
|
64
|
+
// computer is on another network than the machine, the machine's list is full).
|
|
65
|
+
const why = (await res.text().catch(() => '')).trim().slice(0, 200);
|
|
66
|
+
if (why === CODE_SPENT)
|
|
67
|
+
return { ok: false, error: 'This link no longer works. A link works once, and for a short time: make a new one on the other machine.' };
|
|
68
|
+
return { ok: false, error: why ? `The machine refused: ${why}.` : 'The machine refused.' };
|
|
69
|
+
}
|
|
70
|
+
if (!res.ok)
|
|
71
|
+
return { ok: false, error: `The machine refused (${res.status}).` };
|
|
72
|
+
const key = await res.json().then(body => body?.key, () => undefined);
|
|
73
|
+
return typeof key === 'string' && key ? { ok: true, key } : { ok: false, error: 'What answered at this link is not an OpenAgent that lets a machine in.' };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Take this computer out of a machine: its key there stops working. Whether the machine did;
|
|
77
|
+
* one that cannot be reached keeps the key until this computer is removed there by hand.
|
|
78
|
+
*/
|
|
79
|
+
export async function leaveRemote(machine) {
|
|
80
|
+
try {
|
|
81
|
+
const res = await machineFetch(machine.door, machine.pin, { method: 'DELETE', headers: { authorization: `Bearer ${machine.key}` }, signal: AbortSignal.timeout(LEAVE_TIMEOUT_MS) });
|
|
18
82
|
return res.ok;
|
|
19
83
|
}
|
|
20
84
|
catch {
|
|
21
85
|
return false;
|
|
22
86
|
}
|
|
23
87
|
}
|
|
24
|
-
/** The two headers every relay request carries: JSON, and the shared-token cookie (#1051). No Origin on purpose. */
|
|
25
|
-
function relayHeaders(token) {
|
|
26
|
-
return { 'content-type': 'application/json', cookie: `oa_daemon=${token}` };
|
|
27
|
-
}
|
|
28
88
|
/**
|
|
29
|
-
* Start an agent on the remote daemon
|
|
30
|
-
* id). A non-2xx or a transport failure surfaces as an
|
|
31
|
-
* same shape a local refusal has, so the caller does
|
|
89
|
+
* Start an agent on the remote daemon, in its project cloned from `target.project`, and return
|
|
90
|
+
* what it answered (with the remote's own run id). A non-2xx or a transport failure surfaces as an
|
|
91
|
+
* `ok: false` result the dashboard shows, the same shape a local refusal has, so the caller does
|
|
92
|
+
* not special-case remote errors.
|
|
32
93
|
*/
|
|
33
94
|
export async function startRemoteAgent(target, body) {
|
|
34
95
|
try {
|
|
35
|
-
const res = await
|
|
96
|
+
const res = await machineFetch(`${trimSlashes(target.url)}/_relay/start`, target.pin, {
|
|
36
97
|
method: 'POST',
|
|
37
|
-
headers: relayHeaders(target.
|
|
38
|
-
body: JSON.stringify(body),
|
|
98
|
+
headers: relayHeaders(target.key),
|
|
99
|
+
body: JSON.stringify({ ...body, project: target.project }),
|
|
39
100
|
signal: AbortSignal.timeout(START_TIMEOUT_MS),
|
|
40
101
|
});
|
|
102
|
+
if (res.status === 401)
|
|
103
|
+
return { ok: false, error: NOT_IN };
|
|
41
104
|
if (!res.ok)
|
|
42
|
-
return { ok: false, error: `the
|
|
105
|
+
return { ok: false, error: `the machine refused the run (${res.status})` };
|
|
43
106
|
return (await res.json());
|
|
44
107
|
}
|
|
45
108
|
catch (err) {
|
|
46
|
-
return { ok: false, error: `could not reach the
|
|
109
|
+
return { ok: false, error: `could not reach the machine: ${errorMessage(err)}` };
|
|
47
110
|
}
|
|
48
111
|
}
|
|
49
|
-
const RPC_TIMEOUT_MS = 60_000; // a relayed git push/PR runs over the network on the
|
|
112
|
+
const RPC_TIMEOUT_MS = 60_000; // a relayed git push/PR runs over the network on the machine
|
|
50
113
|
/**
|
|
51
|
-
* Relay one run-scoped RPC to the
|
|
52
|
-
* holds
|
|
53
|
-
* {fn, args} to the remote's /_relay/rpc
|
|
54
|
-
* result. Throws on an unreachable
|
|
114
|
+
* Relay one run-scoped RPC to the machine that owns a remote agent (#1067 slice 2). The local daemon
|
|
115
|
+
* holds this computer's key there, so a read/diff/handoff/push/PR for a relayed agent runs ON the machine: POST
|
|
116
|
+
* {fn, args} to the remote's /_relay/rpc with the key (no Origin), returning the machine's
|
|
117
|
+
* result. Throws on an unreachable machine or a non-2xx so the caller falls back to its own empty/error
|
|
55
118
|
* shape, the same way a failed local read does.
|
|
56
119
|
*/
|
|
57
120
|
export async function relayRpc(target, fn, args) {
|
|
58
|
-
const res = await
|
|
121
|
+
const res = await machineFetch(`${trimSlashes(target.url)}/_relay/rpc`, target.pin, {
|
|
59
122
|
method: 'POST',
|
|
60
|
-
headers: relayHeaders(target.
|
|
61
|
-
body: JSON.stringify({ fn, args }),
|
|
123
|
+
headers: relayHeaders(target.key),
|
|
124
|
+
body: JSON.stringify({ fn, args, project: target.project }),
|
|
62
125
|
signal: AbortSignal.timeout(RPC_TIMEOUT_MS),
|
|
63
126
|
});
|
|
64
127
|
if (!res.ok)
|
|
65
|
-
throw new Error(`the
|
|
128
|
+
throw new Error(`the machine refused the request (${res.status})`);
|
|
66
129
|
const body = (await res.json());
|
|
67
130
|
return body.result;
|
|
68
131
|
}
|
|
69
132
|
/**
|
|
70
133
|
* Fetch-stream a remote agent's newline-delimited events into `onEvent` until the remote closes the
|
|
71
|
-
* body, the agent ends, or `cancel()` is called. A 401 (
|
|
134
|
+
* body, the agent ends, or `cancel()` is called. A 401 (this computer was removed there) ends the stream
|
|
72
135
|
* cleanly rather than as an error, so the dashboard sees a normal `done`, not a lost connection.
|
|
73
136
|
* Returns a cancel function; calling it aborts the fetch and releases the reader.
|
|
74
137
|
*/
|
|
@@ -83,9 +146,9 @@ export function streamRemoteEvents(target, agentId, onEvent, onEnd) {
|
|
|
83
146
|
};
|
|
84
147
|
void (async () => {
|
|
85
148
|
try {
|
|
86
|
-
const url = `${trimSlashes(target.url)}/_relay/events?run=${encodeURIComponent(agentId)}`;
|
|
87
|
-
const res = await
|
|
88
|
-
// 401 =
|
|
149
|
+
const url = `${trimSlashes(target.url)}/_relay/events?run=${encodeURIComponent(agentId)}&project=${encodeURIComponent(target.project)}`;
|
|
150
|
+
const res = await machineFetch(url, target.pin, { headers: relayHeaders(target.key), signal: controller.signal });
|
|
151
|
+
// 401 = this computer was removed on the machine. Nothing more will stream; end cleanly (a done, not a loss).
|
|
89
152
|
if (!res.ok || !res.body)
|
|
90
153
|
return end();
|
|
91
154
|
const reader = res.body.getReader();
|
|
@@ -133,11 +196,12 @@ function emitLine(line, onEvent) {
|
|
|
133
196
|
/**
|
|
134
197
|
* The local daemon's live relayed runs (#1067), keyed by the remote agent id. Registering an agent opens
|
|
135
198
|
* an {@link EventStream} the dashboard reads through `onEvents`, fed by {@link streamRemoteEvents}
|
|
136
|
-
* from the remote.
|
|
137
|
-
* run
|
|
199
|
+
* from the remote. The target is the saved machine as it was at the Start. A machine is not
|
|
200
|
+
* removed while a run is at work on it ({@link working}); the runs that ended there before it
|
|
201
|
+
* was removed read as unreachable, and one added again answers for them with its new key ({@link rekey}).
|
|
138
202
|
*
|
|
139
203
|
* The `targets` map outlives the event pump (#1067 slice 2): a finished remote agent's post-run reads,
|
|
140
|
-
* open-PR and merge still have to reach the
|
|
204
|
+
* open-PR and merge still have to reach the machine after its event stream has ended, so the machine
|
|
141
205
|
* target is kept until {@link dispose} clears it, not dropped when the stream closes.
|
|
142
206
|
*
|
|
143
207
|
* The `metas` map (#1077) holds a local {@link AgentMeta} stub per relayed agent so `onAgents` can show a
|
|
@@ -158,7 +222,7 @@ export class RelayedAgents {
|
|
|
158
222
|
const stream = new EventStream();
|
|
159
223
|
const cancel = streamRemoteEvents(target, agentId, event => {
|
|
160
224
|
stream.push(event);
|
|
161
|
-
this.apply(agentId, event); // fold the event into the run's list row, mirroring the
|
|
225
|
+
this.apply(agentId, event); // fold the event into the run's list row, mirroring the machine
|
|
162
226
|
}, () => this.endStream(agentId));
|
|
163
227
|
this.agents.set(agentId, { target, stream, cancel });
|
|
164
228
|
}
|
|
@@ -166,10 +230,24 @@ export class RelayedAgents {
|
|
|
166
230
|
get(agentId) {
|
|
167
231
|
return agentId ? this.agents.get(agentId)?.stream : undefined;
|
|
168
232
|
}
|
|
169
|
-
/** The
|
|
233
|
+
/** The machine a relayed agent runs on, kept past the event stream so post-run push/PR still reach it. */
|
|
170
234
|
target(agentId) {
|
|
171
235
|
return agentId ? this.targets.get(agentId) : undefined;
|
|
172
236
|
}
|
|
237
|
+
/** Whether a run this daemon follows is still at work on the machine at `url`: its events still stream. */
|
|
238
|
+
working(url) {
|
|
239
|
+
for (const agent of this.agents.values())
|
|
240
|
+
if (agent.target.url === url)
|
|
241
|
+
return true;
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
/** How the machine at `url` is reached since it was added again, for the runs kept from before: this computer's new key there, and the key the machine is known by. */
|
|
245
|
+
rekey(url, key, pin) {
|
|
246
|
+
for (const [agentId, target] of this.targets) {
|
|
247
|
+
if (target.url === url)
|
|
248
|
+
this.targets.set(agentId, { url, key, ...(pin ? { pin } : {}), project: target.project });
|
|
249
|
+
}
|
|
250
|
+
}
|
|
173
251
|
/** A project's relayed run stubs (#1077), newest-first, so `onAgents` can surface them in the list. */
|
|
174
252
|
list(projectId) {
|
|
175
253
|
const rows = [];
|
|
@@ -180,7 +258,7 @@ export class RelayedAgents {
|
|
|
180
258
|
return rows.sort((a, b) => (a.startedAt < b.startedAt ? 1 : a.startedAt > b.startedAt ? -1 : 0));
|
|
181
259
|
}
|
|
182
260
|
/** Fold each relayed event into the agent's list row via the store's own reducer (#1077), so the
|
|
183
|
-
* local stub mirrors the
|
|
261
|
+
* local stub mirrors the machine: the terminal status on `end`, the waiting flag while it is parked
|
|
184
262
|
* (#785), the driver once its session starts. Events carry no write time, so this stamps its own. */
|
|
185
263
|
apply(agentId, event) {
|
|
186
264
|
const entry = this.metas.get(agentId);
|
|
@@ -200,7 +278,7 @@ export class RelayedAgents {
|
|
|
200
278
|
if (entry && entry.meta.status === 'running')
|
|
201
279
|
entry.meta.status = 'stopped';
|
|
202
280
|
}
|
|
203
|
-
/** Stop every pump, close every stream, and forget every
|
|
281
|
+
/** Stop every pump, close every stream, and forget every machine target + list stub, on daemon shutdown. */
|
|
204
282
|
dispose() {
|
|
205
283
|
for (const [agentId, agent] of this.agents) {
|
|
206
284
|
agent.cancel();
|
|
@@ -216,8 +294,8 @@ function trimSlashes(url) {
|
|
|
216
294
|
return url.replace(/\/+$/, '');
|
|
217
295
|
}
|
|
218
296
|
/**
|
|
219
|
-
* Fold one relayed event into the memory-only row of a run on a
|
|
220
|
-
* card would say, kept here because that card is on the
|
|
297
|
+
* Fold one relayed event into the memory-only row of a run on a machine: what the machine's own
|
|
298
|
+
* card would say, kept here because that card is on the machine. The events are the ones a run's
|
|
221
299
|
* diary yields: the agent's session id, its cost, its end.
|
|
222
300
|
*/
|
|
223
301
|
export function foldRelayedEvent(meta, event, at) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-run.js","sourceRoot":"","sources":["../../src/dashboard/remote-run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAIhD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AA0BlD,MAAM,gBAAgB,GAAG,MAAM,CAAA;AAE/B,mGAAmG;AACnG,MAAM,eAAe,GAAG,KAAK,CAAA;AAE7B;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAoB;IACnD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE;YAChE,OAAO,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ChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAe,EAAE,KAAqB,EAAE,EAAU;IACjF,MAAM,IAAI,GAAc,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAA;IAClD,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB;QAAE,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAA;SAChE,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;QAAE,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAA;SACxE,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAA;QAClG,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;IACnB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -7,6 +7,7 @@ import type { BridgeBrowserOwner } from '../bridge-browser.js';
|
|
|
7
7
|
import type { ProjectErrorsReader } from '../project-errors.js';
|
|
8
8
|
import type { AddProjectResult, RemoveProjectResult, StartAgentOptions, StartAgentResult } from './types.js';
|
|
9
9
|
import type { AgentMeta } from '../store/index.js';
|
|
10
|
+
import type { RemoteTarget } from './remote-run.js';
|
|
10
11
|
/** Wired by the daemon so `sendStart` can reach the daemon's own `startAgent` closure. */
|
|
11
12
|
export type StartAgentHandler = (prompt: string, options: StartAgentOptions, projectId?: string) => StartAgentResult | Promise<StartAgentResult>;
|
|
12
13
|
/** Wired by the daemon so `sendAddProject` can install + register a repo (#433). */
|
|
@@ -14,19 +15,20 @@ export type AddProjectHandler = (path: string, share: boolean) => AddProjectResu
|
|
|
14
15
|
/** Wired by the daemon so `sendRemoveProject` can take a project off the list, by its id, and with `files` remove what OpenAgent left in its folder. */
|
|
15
16
|
export type RemoveProjectHandler = (projectId: string, files: boolean) => RemoveProjectResult | Promise<RemoveProjectResult>;
|
|
16
17
|
/** Resolve an agent to its live event stream: the relay feeds `onEvents` from its own in-memory stream
|
|
17
|
-
* rather than a file on disk (#426), and the daemon feeds an agent it is relaying from a
|
|
18
|
+
* rather than a file on disk (#426), and the daemon feeds an agent it is relaying from a machine (#1067).
|
|
18
19
|
* Returns undefined when there is no in-memory stream, so `onEvents` falls back to tailing the log. */
|
|
19
20
|
export type EventsSource = (projectId: string, agentId?: string) => AsyncIterable<OpenAgentEvent> | undefined;
|
|
20
|
-
/** Look up the
|
|
21
|
+
/** Look up the machine a relayed agent (#1067) executes on, or undefined for an ordinary local agent. The
|
|
21
22
|
* daemon wires this from its live relayed-agent map; a run-scoped RPC uses it to forward a remote agent's
|
|
22
|
-
* read/steer/handoff to that
|
|
23
|
+
* read/steer/handoff to that machine instead of resolving a (nonexistent) local checkout. */
|
|
23
24
|
export interface RemoteAgents {
|
|
24
|
-
target(agentId: string | undefined):
|
|
25
|
-
url: string;
|
|
26
|
-
token: string;
|
|
27
|
-
} | undefined;
|
|
25
|
+
target(agentId: string | undefined): RemoteTarget | undefined;
|
|
28
26
|
/** A project's relayed run stubs (#1077), so `onAgents` can show a remote agent in the list and re-open it after a reload. */
|
|
29
27
|
list(projectId: string): AgentMeta[];
|
|
28
|
+
/** Whether a run relayed from here is still at work on the machine at `url`. */
|
|
29
|
+
working(url: string): boolean;
|
|
30
|
+
/** How the machine at `url` is reached since it was added again, for the runs kept from before. */
|
|
31
|
+
rekey(url: string, key: string, pin?: string): void;
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
34
|
* What every RPC acts through.
|
|
@@ -40,10 +42,10 @@ export interface DashboardContext {
|
|
|
40
42
|
startAgent: StartAgentHandler;
|
|
41
43
|
addProject: AddProjectHandler;
|
|
42
44
|
removeProject: RemoveProjectHandler;
|
|
43
|
-
/** The in-memory event stream for an agent relayed from a
|
|
45
|
+
/** The in-memory event stream for an agent relayed from a saved machine (#1067), else undefined. */
|
|
44
46
|
eventsSource: EventsSource;
|
|
45
47
|
/** The relayed-agent lookup (#1067 slice 2), so a run-scoped RPC can tell a local agent from one
|
|
46
|
-
* running on a
|
|
48
|
+
* running on a saved machine and forward the call there. */
|
|
47
49
|
remote: RemoteAgents;
|
|
48
50
|
/** The user-preferences store (#410), over the registry file. */
|
|
49
51
|
preferences: PreferencesStore;
|
|
@@ -72,16 +74,12 @@ export declare function isSameOriginRequest(req: IncomingMessage): boolean;
|
|
|
72
74
|
* the mount, `sendStart` included, is reachable from a page the user merely visited.
|
|
73
75
|
*
|
|
74
76
|
* The `Host` header is what still gives the attacker away: it carries the name the browser was
|
|
75
|
-
* asked for (`evil.com`), not the address it resolved to.
|
|
76
|
-
* only `Host` a real user's browser can send is a loopback
|
|
77
|
-
* anything else is a rebound name and is rejected. An absent `Host` is rejected too
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* A non-loopback bind (`--host`, #1051) is reached by a hostname we cannot predict, so there is
|
|
81
|
-
* no allowlist to check against; that case gates behind the shared daemon token instead. Hosts
|
|
82
|
-
* that never pass a bind host at all (the relay, which serves a public domain) are unaffected.
|
|
77
|
+
* asked for (`evil.com`), not the address it resolved to. The dashboard listens on this
|
|
78
|
+
* computer's own address only, so the only `Host` a real user's browser can send is a loopback
|
|
79
|
+
* one — anything else is a rebound name and is rejected. An absent `Host` is rejected too:
|
|
80
|
+
* HTTP/1.1 requires it, and every browser sends it.
|
|
83
81
|
*/
|
|
84
|
-
export declare function isExpectedHost(req: IncomingMessage
|
|
82
|
+
export declare function isExpectedHost(req: IncomingMessage): boolean;
|
|
85
83
|
/** Where the dashboard's RPCs live. One prefix, so the static handler can decline it by path. */
|
|
86
84
|
export declare const RPC_PREFIX = "/_rpc";
|
|
87
85
|
/**
|
|
@@ -90,17 +88,13 @@ export declare const RPC_PREFIX = "/_rpc";
|
|
|
90
88
|
* `sendStart` reaches the daemon's own `startAgent` through the wired {@link DashboardContext}.
|
|
91
89
|
*
|
|
92
90
|
* Cross-origin POSTs are rejected (CSRF: a page on evil.com must not steer or start a session), as
|
|
93
|
-
* are requests carrying someone else's `Host`
|
|
94
|
-
*
|
|
95
|
-
* address the server is bound to — to enable that second check. Returns whether the request was
|
|
96
|
-
* the RPC surface's.
|
|
91
|
+
* are requests carrying someone else's `Host` (DNS rebinding: the same page must not reach us by
|
|
92
|
+
* pointing its own name at `127.0.0.1`). Returns whether the request was the RPC surface's.
|
|
97
93
|
*
|
|
98
94
|
* This replaced Telefunc (F3), which required a build-time transform over every `.telefunc.ts`
|
|
99
95
|
* file, a registration table pinning each RPC to the client-baked key of the *dashboard* source
|
|
100
96
|
* path it was re-exported from, and a request-context indirection for wiring that never varied
|
|
101
97
|
* per request. What it bought over this was type-safety across a package boundary that A7 removed.
|
|
102
98
|
*/
|
|
103
|
-
export declare function makeRpcMount(context: DashboardContext,
|
|
104
|
-
host?: string;
|
|
105
|
-
}): (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
|
|
99
|
+
export declare function makeRpcMount(context: DashboardContext): (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
|
|
106
100
|
//# sourceMappingURL=rpc-serve.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-serve.d.ts","sourceRoot":"","sources":["../../src/dashboard/rpc-serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAKhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC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iG;IACjG,aAAa,EAAE,mBAAmB,CAAA;IAClC,yFAAyF;IACzF,aAAa,EAAE,kBAAkB,CAAA;CAClC;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAYjE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAG5D;AAED,iGAAiG;AACjG,eAAO,MAAM,UAAU,UAAU,CAAA;AAmEjC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CA6CvH"}
|
|
@@ -33,23 +33,14 @@ export function isSameOriginRequest(req) {
|
|
|
33
33
|
* the mount, `sendStart` included, is reachable from a page the user merely visited.
|
|
34
34
|
*
|
|
35
35
|
* The `Host` header is what still gives the attacker away: it carries the name the browser was
|
|
36
|
-
* asked for (`evil.com`), not the address it resolved to.
|
|
37
|
-
* only `Host` a real user's browser can send is a loopback
|
|
38
|
-
* anything else is a rebound name and is rejected. An absent `Host` is rejected too
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* A non-loopback bind (`--host`, #1051) is reached by a hostname we cannot predict, so there is
|
|
42
|
-
* no allowlist to check against; that case gates behind the shared daemon token instead. Hosts
|
|
43
|
-
* that never pass a bind host at all (the relay, which serves a public domain) are unaffected.
|
|
36
|
+
* asked for (`evil.com`), not the address it resolved to. The dashboard listens on this
|
|
37
|
+
* computer's own address only, so the only `Host` a real user's browser can send is a loopback
|
|
38
|
+
* one — anything else is a rebound name and is rejected. An absent `Host` is rejected too:
|
|
39
|
+
* HTTP/1.1 requires it, and every browser sends it.
|
|
44
40
|
*/
|
|
45
|
-
export function isExpectedHost(req
|
|
46
|
-
if (boundHost === undefined || !isLoopbackHost(boundHost))
|
|
47
|
-
return true;
|
|
41
|
+
export function isExpectedHost(req) {
|
|
48
42
|
const header = req.headers.host;
|
|
49
|
-
|
|
50
|
-
return false;
|
|
51
|
-
const hostname = hostnameFromHostHeader(header);
|
|
52
|
-
return isLoopbackHost(hostname) || hostname === boundHost;
|
|
43
|
+
return header !== undefined && header !== '' && isLoopbackHost(hostnameFromHostHeader(header));
|
|
53
44
|
}
|
|
54
45
|
/** Where the dashboard's RPCs live. One prefix, so the static handler can decline it by path. */
|
|
55
46
|
export const RPC_PREFIX = '/_rpc';
|
|
@@ -87,7 +78,7 @@ async function serveEventStream(req, res, url) {
|
|
|
87
78
|
'content-type': 'text/event-stream',
|
|
88
79
|
'cache-control': 'no-store',
|
|
89
80
|
connection: 'keep-alive',
|
|
90
|
-
//
|
|
81
|
+
// What passes a device's request on to the daemon must not hold the lines back.
|
|
91
82
|
'x-accel-buffering': 'no',
|
|
92
83
|
});
|
|
93
84
|
let finished = false;
|
|
@@ -118,17 +109,15 @@ async function serveEventStream(req, res, url) {
|
|
|
118
109
|
* `sendStart` reaches the daemon's own `startAgent` through the wired {@link DashboardContext}.
|
|
119
110
|
*
|
|
120
111
|
* Cross-origin POSTs are rejected (CSRF: a page on evil.com must not steer or start a session), as
|
|
121
|
-
* are requests carrying someone else's `Host`
|
|
122
|
-
*
|
|
123
|
-
* address the server is bound to — to enable that second check. Returns whether the request was
|
|
124
|
-
* the RPC surface's.
|
|
112
|
+
* are requests carrying someone else's `Host` (DNS rebinding: the same page must not reach us by
|
|
113
|
+
* pointing its own name at `127.0.0.1`). Returns whether the request was the RPC surface's.
|
|
125
114
|
*
|
|
126
115
|
* This replaced Telefunc (F3), which required a build-time transform over every `.telefunc.ts`
|
|
127
116
|
* file, a registration table pinning each RPC to the client-baked key of the *dashboard* source
|
|
128
117
|
* path it was re-exported from, and a request-context indirection for wiring that never varied
|
|
129
118
|
* per request. What it bought over this was type-safety across a package boundary that A7 removed.
|
|
130
119
|
*/
|
|
131
|
-
export function makeRpcMount(context
|
|
120
|
+
export function makeRpcMount(context) {
|
|
132
121
|
setDashboardContext(context);
|
|
133
122
|
return async (req, res) => {
|
|
134
123
|
// A fixed base, like every other request parse here: only the path and the query are read,
|
|
@@ -142,7 +131,7 @@ export function makeRpcMount(context, opts = {}) {
|
|
|
142
131
|
res.end('cross-origin request forbidden');
|
|
143
132
|
return true;
|
|
144
133
|
}
|
|
145
|
-
if (!isExpectedHost(req
|
|
134
|
+
if (!isExpectedHost(req)) {
|
|
146
135
|
res.writeHead(403, { 'content-type': 'text/plain' });
|
|
147
136
|
res.end('unexpected Host header');
|
|
148
137
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-serve.js","sourceRoot":"","sources":["../../src/dashboard/rpc-serve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"rpc-serve.js","sourceRoot":"","sources":["../../src/dashboard/rpc-serve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAuElD;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAoB;IACtD,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAA;IACjC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IACxB,MAAM,IAAI,GAAG,GAAG,CAA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,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import type { RemoteTarget } from './remote-run.js';
|
|
3
|
+
/**
|
|
4
|
+
* A run's live screen, for whoever watches the run from this OpenAgent: on this computer, on a
|
|
5
|
+
* phone that got in, or on another computer that follows the run. A `screen` line in the run's
|
|
6
|
+
* diary names where the screen answers, on the loopback of the computer the run is on. That
|
|
7
|
+
* address is reached by nothing but the OpenAgent of that computer, which passes on two calls
|
|
8
|
+
* and no other:
|
|
9
|
+
*
|
|
10
|
+
* - `GET /_screen/stream?project=<id>&run=<id>`: what the screen shows, as the screen's own bytes.
|
|
11
|
+
* - `POST /_screen/input?project=<id>&run=<id>`: what the person did on it, as JSON.
|
|
12
|
+
*
|
|
13
|
+
* For a run this computer follows on another machine, both are asked of that machine
|
|
14
|
+
* (`/_relay/screen/…`), with this computer's key there.
|
|
15
|
+
*
|
|
16
|
+
* What a screen answers is written by whatever the agent ran, and for a run on another machine
|
|
17
|
+
* it comes from that machine. So it is never a page here: the bytes are answered as bytes no
|
|
18
|
+
* browser renders or runs, and the answer to an input is its status alone. What draws the screen
|
|
19
|
+
* is this OpenAgent's own.
|
|
20
|
+
*/
|
|
21
|
+
export declare const SCREEN_PREFIX = "/_screen";
|
|
22
|
+
/** The two calls a screen takes. */
|
|
23
|
+
export type ScreenCall = 'stream' | 'input';
|
|
24
|
+
export interface ScreenHandlers {
|
|
25
|
+
/** Where the live screen of a run on this computer answers; nothing when the run has none. */
|
|
26
|
+
local: (projectId: string, agentId: string) => Promise<string | undefined>;
|
|
27
|
+
/** The machine a run this computer follows is on; nothing for a run of this computer's own. */
|
|
28
|
+
remote: (agentId: string) => RemoteTarget | undefined;
|
|
29
|
+
}
|
|
30
|
+
/** The call a path names, when it names one. */
|
|
31
|
+
export declare function screenCallOf(pathname: string, prefix: string): ScreenCall | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* The address one call to a screen goes to. Only a screen on this computer's own loopback is
|
|
34
|
+
* called, at its own two paths: the line that names it was written by whatever the agent ran.
|
|
35
|
+
*/
|
|
36
|
+
export declare function screenCallAddress(screen: string, call: ScreenCall): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Where the live screen of the run whose diary is the file at `diary` answers; nothing when it
|
|
39
|
+
* has none, or no diary. Only the lines that can say so are read as JSON, a screen's and a run's
|
|
40
|
+
* end: a diary is as long as the run, and this is asked for as long as someone looks.
|
|
41
|
+
*/
|
|
42
|
+
export declare function screenInDiary(diary: string): Promise<string | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* `find`, asked at most once in a while for the same run, and once for all who ask at the same
|
|
45
|
+
* moment: where a screen answers changes only when a browser opens or closes. Only a run's own
|
|
46
|
+
* screen is kept: an ask that found none is asked again, and keeps nothing.
|
|
47
|
+
*/
|
|
48
|
+
export declare function kept(find: ScreenHandlers['local'], now?: () => number): ScreenHandlers['local'];
|
|
49
|
+
/** Route a `/_screen/*` request of this computer's own dashboard, or of a device that got in. */
|
|
50
|
+
export declare function handleScreenRequest(req: IncomingMessage, res: ServerResponse, pathname: string, handlers: ScreenHandlers | undefined): Promise<void>;
|
|
51
|
+
/** Pass one call on to the screen at `screen`, on this computer; a 404 when there is none. */
|
|
52
|
+
export declare function passToScreen(req: IncomingMessage, res: ServerResponse, call: ScreenCall, screen: string | undefined): Promise<void>;
|
|
53
|
+
//# sourceMappingURL=screen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../../src/dashboard/screen.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAMhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa,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