@parcha/agentrun-serve 0.1.0-beta.55 → 0.1.0-beta.56
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 +32 -0
- package/README.md +44 -10
- package/dist/adapters.d.ts +3 -2
- package/dist/adapters.js +6 -3
- package/dist/answer-json.d.ts +6 -2
- package/dist/answer-json.js +22 -4
- package/dist/api-only.js +2 -0
- package/dist/calendar/tools.js +3 -2
- package/dist/chatgpt-plan.d.ts +16 -1
- package/dist/chatgpt-plan.js +116 -12
- package/dist/claude-login.d.ts +34 -5
- package/dist/claude-login.js +31 -7
- package/dist/claude-sign-in.d.ts +35 -0
- package/dist/claude-sign-in.js +90 -0
- package/dist/console/assets/{backend-D5EmB4N3.js → backend-Boh7tC4i.js} +1 -1
- package/dist/console/assets/{index-DUYLaqiR.js → index-CQ3cJRzI.js} +130 -130
- package/dist/console/assets/index-DKkaS3a0.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/host-check.d.ts +4 -0
- package/dist/host-check.js +4 -0
- package/dist/key-refusal.d.ts +21 -5
- package/dist/key-refusal.js +231 -37
- package/dist/learn/secrets.d.ts +20 -10
- package/dist/learn/secrets.js +44 -184
- package/dist/llms.txt +1 -1
- package/dist/openapi.d.ts +3 -3
- package/dist/openapi.js +70 -18
- package/dist/place-offers.d.ts +14 -6
- package/dist/place-offers.js +26 -13
- package/dist/redact/match.d.ts +74 -0
- package/dist/redact/match.js +771 -0
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +4 -4
- package/dist/runner/adapter-loop.d.ts +3 -0
- package/dist/runner/adapter-loop.js +1 -1
- package/dist/runner/adapter-run-spec.js +4 -1
- package/dist/runner/beside.js +7 -3
- package/dist/runner/cli-run-spec.js +3 -1
- package/dist/runner/loop-contract.d.ts +4 -0
- package/dist/runner/main.js +8 -4
- package/dist/runner/presence.d.ts +4 -3
- package/dist/runner/presence.js +4 -2
- package/dist/runner/run-child-host.d.ts +2 -0
- package/dist/runner/run-child-host.js +2 -2
- package/dist/runner/runner.d.ts +4 -0
- package/dist/runner/runner.js +33 -3
- package/dist/server.d.ts +5 -2
- package/dist/server.js +41 -10
- package/dist/store/dialect.d.ts +3 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/dialect.js +3 -0
- package/dist/store/sqlite/store.js +43 -13
- package/dist/store/store.d.ts +10 -1
- package/dist/store/store.js +7 -0
- package/dist/store-view.js +1 -1
- package/dist/template-eval.d.ts +2 -2
- package/dist/template-eval.js +9 -8
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +12 -7
- package/dist/timeline/timeline.js +14 -6
- package/dist/tool-gate.js +3 -1
- package/dist/validate.js +1 -1
- package/dist/workspace/computer-deps.d.ts +2 -1
- package/dist/workspace/computer-deps.js +5 -4
- package/dist/workspace/computer-for-claim.d.ts +8 -2
- package/dist/workspace/computer-for-claim.js +28 -9
- package/dist/workspace/computer-janitor.d.ts +15 -7
- package/dist/workspace/computer-janitor.js +33 -8
- package/dist/workspace/computer-kept.d.ts +52 -4
- package/dist/workspace/computer-kept.js +118 -6
- package/dist/workspace/run-end-computers.d.ts +5 -1
- package/dist/workspace/run-end-computers.js +27 -1
- package/dist/wrapped.d.ts +57 -0
- package/dist/wrapped.js +51 -0
- package/package.json +11 -11
- package/templates/README.md +8 -7
- package/dist/console/assets/index-DYhU4adm.css +0 -1
package/dist/place-offers.d.ts
CHANGED
|
@@ -41,19 +41,27 @@ export declare function boxesLog(offers: readonly BoxOffer[], listed: ReadonlySe
|
|
|
41
41
|
export declare const DOCKER_NOT_IN_GROUP = "This server's process isn't in the docker group: restart your user manager with `sudo systemctl restart user@$(id -u)`, or log in again if linger is off";
|
|
42
42
|
/** The same, when the group file does not list this user in the docker group (or cannot say): joining comes first. */
|
|
43
43
|
export declare const DOCKER_JOIN_GROUP = "This server's process isn't in the docker group: add this user to it with `sudo usermod -aG docker $USER`, then restart your user manager with `sudo systemctl restart user@$(id -u)`, or log in again if linger is off";
|
|
44
|
-
/** Why docker is unavailable to a server in
|
|
45
|
-
* deploy/'s compose file give it none, so it asks a daemon that is not there. Starting Docker or
|
|
46
|
-
* would not help: compose.yaml at the repository's root mounts the host's socket
|
|
47
|
-
|
|
44
|
+
/** Why docker is unavailable to a server in AgentRun's image that has no Docker socket: the one-container `docker run`,
|
|
45
|
+
* deploy/'s compose file and a Kubernetes pod give it none, so it asks a daemon that is not there. Starting Docker or
|
|
46
|
+
* joining its group would not help: compose.yaml at the repository's root mounts the host's socket, which is root on
|
|
47
|
+
* that host (compose.yaml's own header says so), so the words say that too. */
|
|
48
|
+
export declare const DOCKER_NO_SOCKET = "This server runs in a container with no Docker socket, so its agents get file tools and web_fetch but no shell: for a shell in Docker sandboxes, give it the host's Docker socket, as `docker compose up -d` with compose.yaml at the repository's root does. That socket is root on the host, so give it only where you would give AgentRun root";
|
|
48
49
|
/** The same, for a container given the socket and refused it: the group compose.yaml adds (DOCKER_GID) is not the
|
|
49
50
|
* socket's. usermod in the container would not last past its restart. */
|
|
50
51
|
export declare const DOCKER_SOCKET_GROUP = "This server's container may not use the Docker socket: set DOCKER_GID in .env to the socket's group, as compose.yaml says, then run `docker compose up -d` again";
|
|
51
|
-
/** Whether this server runs in a container
|
|
52
|
-
* is there (`exists`: the socket a failed probe names). What a failed probe says to do. */
|
|
52
|
+
/** Whether this server runs in a container, whether it is AgentRun's own image (IMAGE_ENV), and how it tells whether a
|
|
53
|
+
* path is there (`exists`: the socket a failed probe names). What a failed probe says to do. */
|
|
53
54
|
export type ContainerFacts = {
|
|
54
55
|
inside: boolean;
|
|
56
|
+
image?: boolean;
|
|
55
57
|
exists?: (path: string) => boolean;
|
|
56
58
|
};
|
|
59
|
+
/** Set by AgentRun's image (packages/serve/docker/Dockerfile): the socket advice (DOCKER_NO_SOCKET, DOCKER_SOCKET_GROUP)
|
|
60
|
+
* is for it alone, and Kubernetes and other containerd runtimes, which write no mark of their own, run it too. */
|
|
61
|
+
export declare const IMAGE_ENV = "AGENTRUN_IN_IMAGE";
|
|
62
|
+
/** A container: AgentRun's image (IMAGE_ENV), or a runtime's mark (/.dockerenv, Podman's /run/.containerenv), which alone
|
|
63
|
+
* is some other container (a dev container). */
|
|
64
|
+
export declare const containerOf: (env: NodeJS.ProcessEnv, exists?: (path: string) => boolean) => ContainerFacts;
|
|
57
65
|
/** How long Docker's probe may take. */
|
|
58
66
|
export declare const PROBE_TIMEOUT_MS = 5000;
|
|
59
67
|
/** What `docker version` says of this machine's Docker daemon: it answers (`up`), or why not. `absent`: no daemon
|
package/dist/place-offers.js
CHANGED
|
@@ -82,14 +82,26 @@ const ownGroups = () => {
|
|
|
82
82
|
catch { }
|
|
83
83
|
return { file: "/etc/group", user, ids: process.getgroups?.() ?? [] };
|
|
84
84
|
};
|
|
85
|
-
/** Why docker is unavailable to a server in
|
|
86
|
-
* deploy/'s compose file give it none, so it asks a daemon that is not there. Starting Docker or
|
|
87
|
-
* would not help: compose.yaml at the repository's root mounts the host's socket
|
|
88
|
-
|
|
85
|
+
/** Why docker is unavailable to a server in AgentRun's image that has no Docker socket: the one-container `docker run`,
|
|
86
|
+
* deploy/'s compose file and a Kubernetes pod give it none, so it asks a daemon that is not there. Starting Docker or
|
|
87
|
+
* joining its group would not help: compose.yaml at the repository's root mounts the host's socket, which is root on
|
|
88
|
+
* that host (compose.yaml's own header says so), so the words say that too. */
|
|
89
|
+
export const DOCKER_NO_SOCKET = "This server runs in a container with no Docker socket, so its agents get file tools and web_fetch but no shell: for a shell in Docker sandboxes, give it the host's Docker socket, as `docker compose up -d` with compose.yaml at the repository's root does. That socket is root on the host, so give it only where you would give AgentRun root";
|
|
89
90
|
/** The same, for a container given the socket and refused it: the group compose.yaml adds (DOCKER_GID) is not the
|
|
90
91
|
* socket's. usermod in the container would not last past its restart. */
|
|
91
92
|
export const DOCKER_SOCKET_GROUP = "This server's container may not use the Docker socket: set DOCKER_GID in .env to the socket's group, as compose.yaml says, then run `docker compose up -d` again";
|
|
92
|
-
|
|
93
|
+
/** Set by AgentRun's image (packages/serve/docker/Dockerfile): the socket advice (DOCKER_NO_SOCKET, DOCKER_SOCKET_GROUP)
|
|
94
|
+
* is for it alone, and Kubernetes and other containerd runtimes, which write no mark of their own, run it too. */
|
|
95
|
+
export const IMAGE_ENV = "AGENTRUN_IN_IMAGE";
|
|
96
|
+
/** A container: AgentRun's image (IMAGE_ENV), or a runtime's mark (/.dockerenv, Podman's /run/.containerenv), which alone
|
|
97
|
+
* is some other container (a dev container). */
|
|
98
|
+
export const containerOf = (env, exists = existsSync) => {
|
|
99
|
+
const image = env[IMAGE_ENV] === "1";
|
|
100
|
+
return { inside: image || exists("/.dockerenv") || exists("/run/.containerenv"), image };
|
|
101
|
+
};
|
|
102
|
+
/** A reason in a container that is not AgentRun's image: the host's words, said to be the container's (its own Docker, its
|
|
103
|
+
* own docker group), never compose.yaml's, which is not there to use. */
|
|
104
|
+
const inOtherContainer = (container, reason) => (container.inside && !container.image ? `This server runs in a container. ${reason}` : reason);
|
|
93
105
|
/** The daemon address docker names when it cannot connect ("Cannot connect to the Docker daemon at unix:///….sock."):
|
|
94
106
|
* the one its DOCKER_HOST or current context resolved to. Matched, never shown. */
|
|
95
107
|
const DAEMON_AT = /docker daemon at ([a-z]+:\/\/\S+?)\.?(?:\s|$)/i;
|
|
@@ -100,11 +112,12 @@ function socketThere(endpoint, env, exists) {
|
|
|
100
112
|
return endpoint.startsWith("unix://") ? exists(endpoint.slice("unix://".length)) : true;
|
|
101
113
|
return Boolean(env.DOCKER_HOST || env.DOCKER_CONTEXT) || exists("/var/run/docker.sock");
|
|
102
114
|
}
|
|
103
|
-
/** A failed probe's reason in
|
|
115
|
+
/** A failed probe's reason in AgentRun's image, where the host's words (start Docker, usermod) are the wrong fix: a socket
|
|
104
116
|
* that refused this process (wherever it is) is its group's; a socket that is not there is compose.yaml's. Undefined on
|
|
105
|
-
* a host, and for a socket that is there and whose daemon does not answer
|
|
117
|
+
* a host and in another container (inOtherContainer), and for a socket that is there and whose daemon does not answer
|
|
118
|
+
* (the host's Docker is down). */
|
|
106
119
|
const containerReason = (answer, env, container) => {
|
|
107
|
-
if (!container.inside || answer.failed === undefined)
|
|
120
|
+
if (!container.inside || !container.image || answer.failed === undefined)
|
|
108
121
|
return undefined;
|
|
109
122
|
if (answer.denied)
|
|
110
123
|
return DOCKER_SOCKET_GROUP;
|
|
@@ -128,7 +141,7 @@ function errorName(error) {
|
|
|
128
141
|
}
|
|
129
142
|
/** Asks this machine's Docker daemon its version (`docker version`), as the Docker computer's check (docker-daemon.ts)
|
|
130
143
|
* does: the CLI is on PATH and its daemon answers this user. `signal` bounds it. */
|
|
131
|
-
export async function askDockerDaemon(env, signal, groups = ownGroups(), container =
|
|
144
|
+
export async function askDockerDaemon(env, signal, groups = ownGroups(), container = containerOf(env)) {
|
|
132
145
|
// Its environment is the server's through the cut a run's takes (withoutSecrets): no box key, no other secret, no
|
|
133
146
|
// name shaped like a key.
|
|
134
147
|
const dockerEnv = withoutSecrets(env);
|
|
@@ -136,7 +149,7 @@ export async function askDockerDaemon(env, signal, groups = ownGroups(), contain
|
|
|
136
149
|
const code = error?.code;
|
|
137
150
|
resolve({ ...(error ? { failed: typeof code === "number" ? `exit ${code}` : errorName(error), ...(SOCKET_DENIED.test(String(stderr)) ? { denied: true } : {}), ...endpointIn(stderr) } : {}), out: String(stdout) });
|
|
138
151
|
}));
|
|
139
|
-
const absent = (reason) => ({ up: false, absent: true, reason });
|
|
152
|
+
const absent = (reason) => ({ up: false, absent: true, reason: inOtherContainer(container, reason) });
|
|
140
153
|
// The box's probe runs once, at the start: each fix takes a restart. Docker is on by default, so its reason is often a
|
|
141
154
|
// first-time user's first read: what is wrong in plain words, what the probe saw, then what to do.
|
|
142
155
|
// In a container, the fix is its socket or that socket's group (containerReason), never the host's.
|
|
@@ -148,7 +161,7 @@ export async function askDockerDaemon(env, signal, groups = ownGroups(), contain
|
|
|
148
161
|
// Its socket refused this process: the group it lacks, and how to get it without a reboot (the words, never docker's):
|
|
149
162
|
// a restart alone where the group file already lists this user, else joining it first.
|
|
150
163
|
if (answer.denied)
|
|
151
|
-
return { up: false, absent: false, reason: (await joinedSince(groups)) ? DOCKER_NOT_IN_GROUP : DOCKER_JOIN_GROUP };
|
|
164
|
+
return { up: false, absent: false, reason: inOtherContainer(container, (await joinedSince(groups)) ? DOCKER_NOT_IN_GROUP : DOCKER_JOIN_GROUP) };
|
|
152
165
|
if (answer.failed)
|
|
153
166
|
return absent(`Docker isn't running on this machine, or this user may not use it (docker version failed: ${answer.failed}): start Docker, or add this user to the docker group, then restart AgentRun`);
|
|
154
167
|
if (!answer.out.trim())
|
|
@@ -158,7 +171,7 @@ export async function askDockerDaemon(env, signal, groups = ownGroups(), contain
|
|
|
158
171
|
/** Docker's offer: `docker version` names the daemon's version, so the CLI is on PATH and its daemon answers this user.
|
|
159
172
|
* Bounded by `timeoutMs`; never rejects. */
|
|
160
173
|
async function probeDocker(env, timeoutMs, groups, container) {
|
|
161
|
-
const no = (reason) => ({ id: "docker", available: false, reason });
|
|
174
|
+
const no = (reason) => ({ id: "docker", available: false, reason: inOtherContainer(container, reason) });
|
|
162
175
|
// Its environment is the server's through the cut a run's takes (withoutSecrets): no box key, no other secret, no
|
|
163
176
|
// name shaped like a key.
|
|
164
177
|
const dockerEnv = withoutSecrets(env);
|
|
@@ -210,7 +223,7 @@ export async function placeOffers(env, options = {}) {
|
|
|
210
223
|
if (!enabled.has(id))
|
|
211
224
|
return { id, available: false, reason: notEnabled(id, enabled) };
|
|
212
225
|
if (id === "docker")
|
|
213
|
-
return probeDocker(env, options.timeoutMs ?? PROBE_TIMEOUT_MS, options.groups ?? ownGroups(), options.container ??
|
|
226
|
+
return probeDocker(env, options.timeoutMs ?? PROBE_TIMEOUT_MS, options.groups ?? ownGroups(), options.container ?? containerOf(env));
|
|
214
227
|
return remoteOffer(id, keyOf);
|
|
215
228
|
}));
|
|
216
229
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export type Span = [start: number, end: number];
|
|
2
|
+
/** The characters the shape scanners have visited in this process: the text each prefix search passes over, each run
|
|
3
|
+
* read, each guard read back. A test sets it to 0, redacts, and reads it: a scanner that read a run once per start
|
|
4
|
+
* inside it would count the square of the run's length. */
|
|
5
|
+
export declare const scanned: {
|
|
6
|
+
chars: number;
|
|
7
|
+
};
|
|
8
|
+
/** `text` with A-Z lowered and nothing else changed, so each offset is the same in both. */
|
|
9
|
+
export declare const asciiLower: (text: string) => string;
|
|
10
|
+
/** What a scan of one start found: the span it matched (start -1 for none), and where the search for the next prefix
|
|
11
|
+
* goes on. */
|
|
12
|
+
type Found = {
|
|
13
|
+
start: number;
|
|
14
|
+
end: number;
|
|
15
|
+
next: number;
|
|
16
|
+
};
|
|
17
|
+
/** A secret's shape as a scanner: its prefixes (found as written, or in the text lowered with `ci`), and what reads on
|
|
18
|
+
* from one. Each scan says where the next start is looked for: past the run it read, less the prefix's length but one,
|
|
19
|
+
* as a prefix can start in a run's last characters and end past it; a start inside the run is not read again, as it
|
|
20
|
+
* ends where the run does and is no longer than this one. Where a shape's run can hold its own prefix and start a
|
|
21
|
+
* different run (a Bearer scheme inside a token), its scan says so. */
|
|
22
|
+
export type Shape = {
|
|
23
|
+
readonly kind: string;
|
|
24
|
+
readonly prefixes: readonly string[];
|
|
25
|
+
readonly ci?: boolean;
|
|
26
|
+
readonly scan: (text: string, at: number, prefix: string) => Found;
|
|
27
|
+
};
|
|
28
|
+
/** Text shaped like a secret, by kind. The same shapes the Pi learning loop's guard refuses. */
|
|
29
|
+
export declare const SECRET_SHAPES: readonly Shape[];
|
|
30
|
+
/** A bank's numbers beside their words, which learning never keeps: an account, IBAN, routing or sort-code number. Not
|
|
31
|
+
* one of SECRET_SHAPES: a run may show its user an account number (a finance job's answer), and those shapes cut every
|
|
32
|
+
* run's view; only what learning keeps refuses them. */
|
|
33
|
+
export declare const MONEY_SHAPES: readonly Shape[];
|
|
34
|
+
/** The kinds of `shapes` in `text`, each once, in their order. */
|
|
35
|
+
export declare function shapeKinds(text: string, shapes: readonly Shape[]): string[];
|
|
36
|
+
/** What the matcher looks for of a set of held values (learn/secrets.ts derives it of each value and its spellings):
|
|
37
|
+
* - `forms`: found as they stand and cut in place (as written, as JSON writes it, squeezed, base64, percent);
|
|
38
|
+
* - `hexes`: a value's hex, lowered, found in any case and cut in place;
|
|
39
|
+
* - `folds`: a hex identifier's digits, found in any case with one separator ("-", "_", ":", ".") allowed between any
|
|
40
|
+
* two, and cut in place;
|
|
41
|
+
* - `plain`: what the whole-text check looks for in each squeezed view (with `hexes` in it lowered, `folds` in it
|
|
42
|
+
* folded). */
|
|
43
|
+
export type Needles = {
|
|
44
|
+
readonly forms: readonly string[];
|
|
45
|
+
readonly hexes: readonly string[];
|
|
46
|
+
readonly folds: readonly string[];
|
|
47
|
+
readonly plain: readonly string[];
|
|
48
|
+
};
|
|
49
|
+
/** `found` in order, each run of overlapping or touching spans as one. */
|
|
50
|
+
export declare function merged(found: readonly (readonly [number, number])[]): Span[];
|
|
51
|
+
/** `text` with each of `spans` (merged, in order) replaced by "[redacted]". */
|
|
52
|
+
export declare function cutAt(text: string, spans: readonly Span[]): string;
|
|
53
|
+
/** Whether `text` holds a held value in a form the cut does not find as it stands: split by whitespace, percent or
|
|
54
|
+
* form encoded, an NFKC variant, its hex in any case, a hex identifier folded (`fold`). With `cuts`, a value whose
|
|
55
|
+
* every character the view read comes from inside the cuts is not held: it is cut in place. */
|
|
56
|
+
export declare function holds(text: string, needles: Needles, { fold, cuts }?: {
|
|
57
|
+
fold?: boolean;
|
|
58
|
+
cuts?: readonly Span[];
|
|
59
|
+
}): boolean;
|
|
60
|
+
/** planCut's first step: every form, hex, folded identifier and shape of `text` as it came, and `held`, merged. */
|
|
61
|
+
export declare function cutSpans(text: string, needles: Needles, shapes: readonly Shape[], held?: readonly (readonly [number, number])[]): Span[];
|
|
62
|
+
/** Where `text` is cut of `needles` and of each of `shapes`, and the text so cut; or "whole" when it must be withheld
|
|
63
|
+
* whole. `held`: spans cut in place beside the finds. The order is fixed:
|
|
64
|
+
* 1. every form, hex, folded identifier and shape is found in the text as it came, and the spans merged;
|
|
65
|
+
* 2. the views of the text as it came are read for each held value: one any of whose characters comes from outside
|
|
66
|
+
* the spans withholds the text (a cut can hide part of a value, so the check never reads the cut text for it);
|
|
67
|
+
* 3. the spans are cut;
|
|
68
|
+
* 4. what is left is read again, for a value or a shape the cut made (a value whose rest the cut joined, a shape whose
|
|
69
|
+
* guard the cut removed), and withholds the text if it holds one. */
|
|
70
|
+
export declare function planCut(text: string, needles: Needles, shapes: readonly Shape[], held?: readonly (readonly [number, number])[]): {
|
|
71
|
+
spans: Span[];
|
|
72
|
+
out: string;
|
|
73
|
+
} | "whole";
|
|
74
|
+
export {};
|