@parcha/agentrun-serve 0.1.0-beta.57 → 0.1.0-beta.58
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/CHANGELOG.md +52 -0
- package/README.md +64 -33
- package/dist/api-only.d.ts +2 -4
- package/dist/api-only.js +2 -4
- package/dist/box-paths.d.ts +4 -3
- package/dist/box-paths.js +7 -4
- package/dist/claude-login-token.d.ts +117 -0
- package/dist/claude-login-token.js +737 -0
- package/dist/claude-login.d.ts +52 -12
- package/dist/claude-login.js +164 -39
- package/dist/cli.js +7 -41
- package/dist/computer-attach.d.ts +35 -17
- package/dist/computer-attach.js +301 -49
- package/dist/computers.d.ts +10 -10
- package/dist/computers.js +5 -5
- package/dist/console/assets/{backend-DVhHzJX2.js → backend-CSAWUqtZ.js} +1 -1
- package/dist/console/assets/index-DPh29cyz.js +747 -0
- package/dist/console/index.html +1 -1
- package/dist/dial-relay.d.ts +25 -4
- package/dist/dial-relay.js +129 -1
- package/dist/env-switch.d.ts +1 -3
- package/dist/env-switch.js +1 -3
- package/dist/fal-price.d.ts +1 -3
- package/dist/fal-price.js +77 -26
- package/dist/learn/ledger.d.ts +170 -0
- package/dist/learn/ledger.js +218 -0
- package/dist/learn/promote.d.ts +3 -3
- package/dist/learn/promote.js +1 -1
- package/dist/learning-cost.d.ts +22 -20
- package/dist/learning-cost.js +15 -21
- package/dist/live-reach.d.ts +2 -0
- package/dist/live-reach.js +2 -0
- package/dist/mcp-api-only-origins.d.ts +8 -3
- package/dist/mcp-api-only-origins.js +17 -17
- package/dist/micro.d.ts +2 -0
- package/dist/micro.js +2 -0
- package/dist/model.d.ts +5 -4
- package/dist/model.js +7 -6
- package/dist/monid.d.ts +14 -1
- package/dist/monid.js +103 -26
- package/dist/openapi.js +34 -12
- package/dist/place-offers.d.ts +4 -0
- package/dist/place-offers.js +7 -4
- package/dist/provider.d.ts +2 -2
- package/dist/provider.js +9 -5
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-view.d.ts +1 -2
- package/dist/run-view.js +2 -1
- package/dist/runner/adapter-loop.js +3 -16
- package/dist/runner/adapter-run-spec.d.ts +20 -13
- package/dist/runner/adapter-run-spec.js +57 -48
- package/dist/runner/beside.d.ts +9 -2
- package/dist/runner/beside.js +24 -7
- package/dist/runner/claim-secrets.d.ts +17 -15
- package/dist/runner/claim-secrets.js +32 -34
- package/dist/runner/cli-run-spec.js +21 -9
- package/dist/runner/held.d.ts +16 -4
- package/dist/runner/main.d.ts +11 -6
- package/dist/runner/main.js +12 -7
- package/dist/runner/mcp-claim.js +3 -2
- package/dist/runner/mcp-run.d.ts +3 -6
- package/dist/runner/mcp-run.js +3 -4
- package/dist/runner/presence.d.ts +11 -1
- package/dist/runner/presence.js +7 -0
- package/dist/runner/reflect-hook.js +1 -1
- package/dist/runner/run-child-host.d.ts +19 -8
- package/dist/runner/run-child-host.js +80 -34
- package/dist/runner/runner.d.ts +3 -0
- package/dist/runner/runner.js +1 -1
- package/dist/runner/save-slots.js +2 -1
- package/dist/runner/subagent.d.ts +11 -0
- package/dist/runner/subagent.js +17 -3
- package/dist/runner/workflow-first.d.ts +27 -14
- package/dist/runner/workflow-first.js +29 -22
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/server.d.ts +18 -7
- package/dist/server.js +150 -64
- package/dist/slots.d.ts +9 -0
- package/dist/slots.js +45 -0
- package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
- package/dist/store/schema.d.ts +17 -0
- package/dist/store/schema.js +47 -1
- package/dist/store/sqlite/run-patch.d.ts +11 -1
- package/dist/store/sqlite/run-patch.js +29 -1
- package/dist/store/sqlite/store.js +72 -9
- package/dist/store/store.d.ts +14 -0
- package/dist/store-reads/learning.d.ts +81 -124
- package/dist/store-reads/learning.js +207 -286
- package/dist/template-eval.d.ts +19 -0
- package/dist/template-eval.js +92 -43
- package/dist/template-import.d.ts +0 -10
- package/dist/template-import.js +5 -10
- package/dist/timeline/web-calls.d.ts +12 -14
- package/dist/timeline/web-calls.js +14 -30
- package/dist/web-save.d.ts +4 -9
- package/dist/web-save.js +4 -43
- package/dist/workspace/attached-computers.d.ts +32 -9
- package/dist/workspace/attached-computers.js +77 -13
- package/dist/workspace/computer-deps.d.ts +6 -1
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.js +6 -3
- package/dist/workspace/paired-route.d.ts +91 -0
- package/dist/workspace/paired-route.js +153 -0
- package/dist/wrapped.d.ts +8 -2
- package/dist/wrapped.js +21 -6
- package/package.json +12 -12
- package/templates/README.md +3 -3
- package/dist/console/assets/index-okP-y8PK.js +0 -747
|
@@ -3,7 +3,10 @@ import type { Duplex } from "node:stream";
|
|
|
3
3
|
import { type AttachHub, type AttachSocket, type HelloResult, type MachineTokens } from "@parcha/agentrun-computer";
|
|
4
4
|
import { WebSocket } from "ws";
|
|
5
5
|
import { type LiveReach } from "./live-reach.js";
|
|
6
|
-
import type { MintedTokens, PairedComputerRow, PairedComputers,
|
|
6
|
+
import type { MintedTokens, PairedComputerRow, PairedComputers, Runners } from "./store/index.js";
|
|
7
|
+
import { type Route, type RouteSettings } from "./workspace/paired-route.js";
|
|
8
|
+
export { liveRelays, type RelayRow } from "./runner/presence.js";
|
|
9
|
+
export { RELAY_CONNECT_MS } from "./live-reach.js";
|
|
7
10
|
/** The characters of a pairing code: no 0, O, 1 or I, so a person reads it off a screen without a doubt. */
|
|
8
11
|
export declare const PAIRING_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
9
12
|
/** A computer's token starts with this, so a secret scanner knows one. */
|
|
@@ -64,8 +67,8 @@ export type PairedView = {
|
|
|
64
67
|
serves: string[];
|
|
65
68
|
/** When it serves no kind, why, naming what its driver lacks (servesNoKind); null when it serves one. */
|
|
66
69
|
unserved: string | null;
|
|
67
|
-
/** On a server whose runner runs in a process of its own, why no run here can use it
|
|
68
|
-
* instead (RUNNER_APART_WORDS); null where its runs can. */
|
|
70
|
+
/** On a server whose runner runs in a process of its own and relays no computer's socket, why no run here can use it
|
|
71
|
+
* and what to do instead (RUNNER_APART_WORDS); null where its runs can. */
|
|
69
72
|
runs_refused: string | null;
|
|
70
73
|
os: string;
|
|
71
74
|
os_version: string | null;
|
|
@@ -84,16 +87,25 @@ export type PairedView = {
|
|
|
84
87
|
off: string;
|
|
85
88
|
}>;
|
|
86
89
|
driver: string;
|
|
90
|
+
/** Its socket is up: in this server's hub, or relayed to the runner that holds its run. */
|
|
87
91
|
online: boolean;
|
|
88
92
|
held_by_run: string | null;
|
|
89
93
|
held_until: string | null;
|
|
94
|
+
/** The runner whose hub holds it for the run (its route, workspace/paired-route.ts); null while this server's hub does. */
|
|
95
|
+
held_on: string | null;
|
|
96
|
+
/** Why a run's route of it was refused or dropped, in words (its runner gone or restarted, it did not reach the runner
|
|
97
|
+
* in time), until it next attaches here; null when there is nothing to say. */
|
|
98
|
+
hold_note: string | null;
|
|
90
99
|
/** The pairing (createPairing's id) whose code paired it. */
|
|
91
100
|
pairing: string;
|
|
92
101
|
created_at: string;
|
|
93
102
|
/** Its last hello: the live socket's while it is attached (never null while online), else the last one kept. */
|
|
94
103
|
seen_at: string | null;
|
|
95
104
|
};
|
|
96
|
-
|
|
105
|
+
/** `row` as GET /v2/computers lists it. `runsRefused`: why no run here can use it (RUNNER_APART_WORDS), or null. `route`:
|
|
106
|
+
* its route (workspace/paired-route.ts), which names the run that holds it and the runner whose hub does while a run's
|
|
107
|
+
* claim routed it there; `relayed`: its socket is relayed to that runner now (createAttachRoutes relayedPaired). */
|
|
108
|
+
export declare function pairedView(row: PairedComputerRow, hub: Pick<AttachHub, "online" | "since" | "hello" | "claimed" | "deadline">, serves: readonly string[], runsRefused?: string | null, route?: Route, relayed?: boolean): PairedView;
|
|
97
109
|
/** How the socket's liveness is timed: ATTACH_HEARTBEAT_MS and ATTACH_IDLE_MS, unless a test gives its own. */
|
|
98
110
|
export type AttachTiming = {
|
|
99
111
|
readonly heartbeatMs: number;
|
|
@@ -106,9 +118,12 @@ export type AttachTiming = {
|
|
|
106
118
|
* once ws gives up on it. */
|
|
107
119
|
export declare function attachSocketOf(ws: WebSocket, timing?: AttachTiming, closing?: (code: number, reason: string) => void): AttachSocket;
|
|
108
120
|
export interface AttachRoutesOptions {
|
|
121
|
+
/** `settings`: where the paired computers' routes are (workspace/paired-route.ts); absent, no paired computer is
|
|
122
|
+
* routed (every one is this hub's on the server, and none is taken on a runner's listener). */
|
|
109
123
|
readonly store: {
|
|
110
124
|
readonly pairedComputers: PairedComputers;
|
|
111
125
|
readonly mintedTokens: MintedTokens;
|
|
126
|
+
readonly settings?: RouteSettings;
|
|
112
127
|
};
|
|
113
128
|
readonly hub: AttachHub;
|
|
114
129
|
/** Told each event worth a line: a computer paired, attached, refused at its hello, removed; a machine's token minted
|
|
@@ -117,9 +132,13 @@ export interface AttachRoutesOptions {
|
|
|
117
132
|
/** An API-only server's (api-only.ts): the socket takes a hosted machine's minted token alone, and a paired computer's
|
|
118
133
|
* (the console's) is 401 as one it does not know. */
|
|
119
134
|
readonly machinesOnly?: boolean;
|
|
120
|
-
/** No runner in this server's process (ServeOptions.runnerApart):
|
|
121
|
-
* can use a paired computer, and
|
|
135
|
+
/** No runner in this server's process (ServeOptions.runnerApart): while no runner relays (`relayed`), a pairing code
|
|
136
|
+
* and the pair answer say no run here can use a paired computer, and what to do so one can (RUNNER_APART_WORDS).
|
|
137
|
+
* Not runnerApart, the route tick stops at its read while no route row is there and no box is relayed. */
|
|
122
138
|
readonly runnerApart?: boolean;
|
|
139
|
+
/** Whether a runner in a process of its own relays now (server.ts relayed), read at each pairing code and pair answer;
|
|
140
|
+
* absent: none does. */
|
|
141
|
+
readonly relayed?: () => Promise<boolean>;
|
|
123
142
|
/** The socket's liveness timing: the protocol's unless a test gives its own. */
|
|
124
143
|
readonly timing?: AttachTiming;
|
|
125
144
|
readonly now?: () => number;
|
|
@@ -138,20 +157,16 @@ export interface AttachRoutesOptions {
|
|
|
138
157
|
readonly runners: Pick<Runners, "live">;
|
|
139
158
|
readonly reach: LiveReach;
|
|
140
159
|
};
|
|
160
|
+
/** On the server: the runner beside it in its process (Serve.beside, runner/beside.ts), whose run's route keeps a
|
|
161
|
+
* paired box in this hub. A route that names it and its incarnation is this hub's: the upgrade takes the box here,
|
|
162
|
+
* and the tick moves it here (from a runner apart that still has it) and never away. */
|
|
163
|
+
readonly beside?: {
|
|
164
|
+
readonly runner: string;
|
|
165
|
+
readonly incarnation: string;
|
|
166
|
+
};
|
|
141
167
|
}
|
|
142
168
|
/** A request's Bearer token, or undefined. */
|
|
143
169
|
export declare const bearerOf: (authorization: string | undefined) => string | undefined;
|
|
144
|
-
/** A runner's row that says where its relay answers. */
|
|
145
|
-
export type RelayRow = RunnerRow & {
|
|
146
|
-
readonly host: string;
|
|
147
|
-
readonly port: number;
|
|
148
|
-
};
|
|
149
|
-
/** The runners whose relay takes dials now: their rows seen within PRESENCE_STALE_MS on the store's clock (Runners.live,
|
|
150
|
-
* the database's on Postgres), never one process's, that say where their relay answers. The server relays a dial only
|
|
151
|
-
* to one of these, and says a dial provider is served while one answers at a host it dials (server.ts relayed). */
|
|
152
|
-
export declare function liveRelays(runners: Pick<Runners, "live">): Promise<RelayRow[]>;
|
|
153
|
-
/** How long the server waits for a runner's attach listener to take a relayed dial. */
|
|
154
|
-
export declare const RELAY_CONNECT_MS = 10000;
|
|
155
170
|
/** Two WebSockets joined frame by frame, each an attach socket with `timing` (attachSocketOf: its idle close, its binary
|
|
156
171
|
* refusal, the server's maxPayload), each closing the other with its code and reason: once it ended, or as soon as it
|
|
157
172
|
* starts a close of its own, so an idle peer's close reaches the other side at once. */
|
|
@@ -175,5 +190,8 @@ export declare function createAttachRoutes(options: AttachRoutesOptions): {
|
|
|
175
190
|
close: () => Promise<void>;
|
|
176
191
|
machineTokens: MachineTokens;
|
|
177
192
|
daemon: (authorization: string | undefined, arch: string | null) => Promise<string>;
|
|
193
|
+
tick: () => Promise<void>;
|
|
194
|
+
relayedTo: (id: string) => string | undefined;
|
|
195
|
+
runsRefused: () => Promise<string | null>;
|
|
178
196
|
};
|
|
179
197
|
export type AttachRoutes = ReturnType<typeof createAttachRoutes>;
|