@parcha/agentrun-serve 0.1.0-beta.53 → 0.1.0-beta.55
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 +138 -3
- package/README.md +346 -99
- package/dist/adapters.d.ts +10 -0
- package/dist/adapters.js +46 -0
- package/dist/agent-package.d.ts +3 -3
- package/dist/agent-package.js +7 -14
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.js +7 -6
- package/dist/api-only.d.ts +17 -6
- package/dist/api-only.js +22 -9
- package/dist/cli.js +11 -4
- package/dist/composio-made.d.ts +26 -1
- package/dist/composio-made.js +39 -2
- package/dist/composio-preset.d.ts +6 -4
- package/dist/composio-preset.js +50 -17
- package/dist/computer-held-routes.js +2 -3
- package/dist/computer-needs.d.ts +1 -1
- package/dist/computer-needs.js +1 -1
- package/dist/computer-setting.d.ts +8 -4
- package/dist/computer-setting.js +0 -2
- package/dist/computers-running.d.ts +8 -0
- package/dist/computers-running.js +27 -0
- package/dist/computers.d.ts +0 -2
- package/dist/computers.js +1 -1
- package/dist/console/assets/backend-D5EmB4N3.js +166 -0
- package/dist/console/assets/index-DUYLaqiR.js +746 -0
- package/dist/console/assets/index-DYhU4adm.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/docker-host-addresses.d.ts +23 -3
- package/dist/docker-host-addresses.js +90 -18
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +7 -0
- package/dist/exa-keyless.d.ts +2 -3
- package/dist/exa-keyless.js +43 -127
- package/dist/firecrawl-keyless.d.ts +41 -0
- package/dist/firecrawl-keyless.js +152 -0
- package/dist/github-connection.d.ts +50 -1
- package/dist/github-connection.js +96 -3
- package/dist/github-faux.d.ts +11 -2
- package/dist/github-faux.js +138 -7
- package/dist/github-pull-request.d.ts +37 -0
- package/dist/github-pull-request.js +110 -0
- package/dist/handed-secret.d.ts +3 -1
- package/dist/handed-secret.js +4 -2
- package/dist/harness-keys.d.ts +98 -0
- package/dist/harness-keys.js +247 -0
- package/dist/harness-recipe-entry.d.ts +14 -9
- package/dist/harness-recipe-entry.js +25 -14
- package/dist/harness-table.d.ts +16 -1
- package/dist/harness-table.js +19 -7
- package/dist/harness.d.ts +4 -0
- package/dist/harness.js +12 -1
- package/dist/host-check.d.ts +2 -0
- package/dist/host-check.js +6 -0
- package/dist/import-summary.d.ts +1 -1
- package/dist/import-summary.js +1 -1
- package/dist/import.d.ts +5 -5
- package/dist/import.js +54 -67
- package/dist/keyless-mcp.d.ts +36 -0
- package/dist/keyless-mcp.js +127 -0
- package/dist/learn/audit.d.ts +3 -3
- package/dist/learn/audit.js +3 -3
- package/dist/learn/commit.d.ts +8 -7
- package/dist/learn/commit.js +60 -20
- package/dist/learn/compile.d.ts +4 -3
- package/dist/learn/compile.js +7 -5
- package/dist/learn/folder.d.ts +16 -3
- package/dist/learn/folder.js +46 -13
- package/dist/learn/promote.d.ts +37 -13
- package/dist/learn/promote.js +112 -40
- package/dist/learn/secrets.js +10 -2
- package/dist/learning-routes.d.ts +22 -17
- package/dist/learning-routes.js +40 -39
- package/dist/learning.js +2 -2
- package/dist/live-reach.d.ts +34 -7
- package/dist/live-reach.js +76 -11
- package/dist/manifest.d.ts +10 -0
- package/dist/manifest.js +30 -0
- package/dist/mcp-pin-first.d.ts +4 -2
- package/dist/mcp-pin-first.js +5 -2
- package/dist/mcp-probe.js +2 -2
- package/dist/mcp-secret-writes.d.ts +16 -7
- package/dist/mcp-secret-writes.js +35 -27
- package/dist/mcp-servers-store.d.ts +30 -6
- package/dist/mcp-servers-store.js +112 -28
- package/dist/mcp-sources.d.ts +10 -2
- package/dist/mcp-sources.js +9 -2
- package/dist/mcp-store.d.ts +13 -7
- package/dist/mcp-store.js +12 -9
- package/dist/model-form.d.ts +3 -2
- package/dist/model-form.js +11 -7
- package/dist/model.d.ts +20 -4
- package/dist/model.js +68 -9
- package/dist/native/history.d.ts +1 -1
- package/dist/native/history.js +2 -2
- package/dist/ollama-provider.d.ts +92 -0
- package/dist/ollama-provider.js +495 -0
- package/dist/openapi/agentrun-v2.openapi.json +2 -2
- package/dist/openapi.js +235 -41
- package/dist/page.d.ts +11 -3
- package/dist/page.js +22 -7
- package/dist/place-offers.d.ts +17 -1
- package/dist/place-offers.js +46 -5
- package/dist/print.js +1 -1
- package/dist/purged-workflow.d.ts +35 -7
- package/dist/purged-workflow.js +73 -26
- package/dist/run-computer.d.ts +2 -0
- package/dist/run-computer.js +2 -0
- package/dist/run-files.d.ts +4 -0
- package/dist/run-files.js +4 -0
- package/dist/run-keys.d.ts +2 -4
- package/dist/run-keys.js +6 -7
- package/dist/run-launch.d.ts +4 -0
- package/dist/run-launch.js +4 -0
- package/dist/run-reads-over-store.d.ts +3 -2
- package/dist/run-reads-over-store.js +66 -2
- package/dist/run-secrets.js +5 -2
- package/dist/runner/adapter-loop.d.ts +6 -3
- package/dist/runner/adapter-loop.js +34 -15
- package/dist/runner/adapter-run-spec.d.ts +3 -0
- package/dist/runner/adapter-run-spec.js +6 -4
- package/dist/runner/audit.js +8 -4
- package/dist/runner/beside.d.ts +2 -1
- package/dist/runner/beside.js +6 -2
- package/dist/runner/claim-secrets.d.ts +5 -8
- package/dist/runner/claim-secrets.js +6 -0
- package/dist/runner/cli-run-spec.d.ts +1 -1
- package/dist/runner/cli-run-spec.js +39 -7
- package/dist/runner/harness-loops.d.ts +22 -9
- package/dist/runner/harness-loops.js +21 -11
- package/dist/runner/held.d.ts +3 -0
- package/dist/runner/learning-end.d.ts +1 -1
- package/dist/runner/learning-end.js +8 -3
- package/dist/runner/loop-contract.d.ts +5 -4
- package/dist/runner/main.js +4 -2
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +26 -2
- package/dist/runner/mcp-run.d.ts +3 -0
- package/dist/runner/mcp-run.js +2 -1
- package/dist/runner/metrics.d.ts +10 -8
- package/dist/runner/metrics.js +20 -27
- package/dist/runner/model-route.d.ts +3 -0
- package/dist/runner/model-route.js +6 -2
- package/dist/runner/pr-checkout.d.ts +21 -4
- package/dist/runner/pr-checkout.js +103 -4
- package/dist/runner/promotion.d.ts +15 -9
- package/dist/runner/promotion.js +25 -15
- package/dist/runner/run-child-host.js +24 -11
- package/dist/runner/run-child.js +3 -1
- package/dist/runner/runner-check.d.ts +3 -0
- package/dist/runner/runner-check.js +23 -0
- package/dist/runner/sdk-loop.js +2 -0
- package/dist/runner/workflow-loop.d.ts +2 -2
- package/dist/runner/workflow-loop.js +1 -2
- package/dist/runner/workflow-spec.d.ts +1 -1
- package/dist/runner/workflow-spec.js +6 -6
- package/dist/sdk/check.d.ts +4 -1
- package/dist/sdk/check.js +2 -1
- package/dist/sdk/runs.d.ts +2 -2
- package/dist/sdk/runs.js +8 -6
- package/dist/secret-cut.js +2 -1
- package/dist/secret-writes.d.ts +3 -2
- package/dist/secret-writes.js +1 -1
- package/dist/server.d.ts +55 -8
- package/dist/server.js +363 -118
- package/dist/standard-webhooks.d.ts +11 -0
- package/dist/standard-webhooks.js +20 -2
- package/dist/store/agent-body.d.ts +2 -2
- package/dist/store/agent-body.js +2 -2
- package/dist/store/index.d.ts +1 -1
- package/dist/store/schema.js +5 -2
- package/dist/store/sqlite/store.js +90 -34
- package/dist/store/store.d.ts +54 -14
- package/dist/store-reads/journal.d.ts +7 -2
- package/dist/store-reads/journal.js +9 -6
- package/dist/store-reads/learning.d.ts +12 -9
- package/dist/store-reads/learning.js +18 -24
- package/dist/store-view.d.ts +0 -5
- package/dist/store-view.js +9 -8
- package/dist/suggestions.d.ts +282 -0
- package/dist/suggestions.js +919 -0
- package/dist/telemetry.d.ts +8 -1
- package/dist/telemetry.js +12 -4
- package/dist/template-eval.d.ts +49 -4
- package/dist/template-eval.js +168 -45
- package/dist/template-import.d.ts +17 -0
- package/dist/template-import.js +36 -2
- package/dist/templates.d.ts +83 -76
- package/dist/templates.js +29 -48
- package/dist/timeline/labels.d.ts +2 -2
- package/dist/timeline/labels.js +2 -2
- package/dist/timeline/timeline.d.ts +2 -2
- package/dist/timeline/timeline.js +1 -1
- package/dist/tool-plane.d.ts +17 -9
- package/dist/tool-plane.js +38 -17
- package/dist/tools.js +2 -2
- package/dist/trigger-launch-hook.d.ts +19 -9
- package/dist/trigger-launch-hook.js +35 -25
- package/dist/trigger-targets.d.ts +18 -8
- package/dist/trigger-targets.js +42 -19
- package/dist/triggers.d.ts +85 -23
- package/dist/triggers.js +303 -96
- package/dist/validate.d.ts +1 -1
- package/dist/validate.js +2 -2
- package/dist/web-fake.js +3 -3
- package/dist/web-fetch-direct.d.ts +4 -0
- package/dist/web-fetch-direct.js +8 -1
- package/dist/web-fetch.d.ts +12 -3
- package/dist/web-fetch.js +47 -14
- package/dist/web-search.d.ts +33 -4
- package/dist/web-search.js +100 -41
- package/dist/webhooks.js +4 -5
- package/dist/workspace/synced-folder.d.ts +1 -1
- package/dist/workspace/synced-folder.js +11 -14
- package/launcher/agentrun-serve +5 -1
- package/package.json +17 -13
- package/templates/README.md +5 -4
- package/templates/agent-scout/agent.md +46 -0
- package/templates/agent-scout/skills/scout/SKILL.md +88 -0
- package/templates/agent-scout/skills/scout/suggestions.schema.json +112 -0
- package/dist/console/assets/index-BFgyZzF_.js +0 -734
- package/dist/console/assets/index-DbilxljH.css +0 -1
- package/dist/import-sources.d.ts +0 -116
- package/dist/import-sources.js +0 -693
package/dist/page.d.ts
CHANGED
|
@@ -24,10 +24,18 @@ export declare const cookiesOf: (req: IncomingMessage, name: string) => string[]
|
|
|
24
24
|
export declare const overHttps: (req: IncomingMessage) => boolean;
|
|
25
25
|
export declare const ownOrigin: (req: IncomingMessage) => string;
|
|
26
26
|
export declare const isJson: (req: IncomingMessage) => boolean;
|
|
27
|
-
/** The owner's session cookie: `__Host-` on https, so no other host or path can set it; else one per port. */
|
|
27
|
+
/** The owner's session cookie: `__Host-` on https, so no other host or path can set it; else one per port the browser opened. */
|
|
28
28
|
export declare const ownerCookieName: (req: IncomingMessage) => string;
|
|
29
|
-
/** A Set-Cookie line for the owner's session: `value`, or an empty one that ends it (`maxAgeS` 0)
|
|
30
|
-
|
|
29
|
+
/** A Set-Cookie line for the owner's session: `value`, or an empty one that ends it (`maxAgeS` 0); under `name`, this
|
|
30
|
+
* request's own unless another is given. */
|
|
31
|
+
export declare const ownerCookie: (req: IncomingMessage, value: string, maxAgeS: number, name?: string) => string;
|
|
32
|
+
/** The owner's session cookies the request holds under this request's name and under any port's (`agentrun-<port>-session`),
|
|
33
|
+
* each with its name, valid or not: a browser sends a host's cookies to every port of it, so one signed in at 7340 and
|
|
34
|
+
* again through a tunnel at 8080 sends both to either. Which are this server's is the owner's to say (Owner.valid). */
|
|
35
|
+
export declare const sessionsAtEveryPort: (req: IncomingMessage) => Array<{
|
|
36
|
+
name: string;
|
|
37
|
+
value: string;
|
|
38
|
+
}>;
|
|
31
39
|
/** The owner's session cookies the request holds, valid or not. */
|
|
32
40
|
export declare const heldSessions: (req: IncomingMessage) => string[];
|
|
33
41
|
/** Whether the request holds a session the owner signed in. */
|
package/dist/page.js
CHANGED
|
@@ -9,7 +9,7 @@ import { readFile, realpath, stat } from "node:fs/promises";
|
|
|
9
9
|
import { extname, join, sep } from "node:path";
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
11
11
|
import { ApiError } from "./errors.js";
|
|
12
|
-
import { hostRefusedPage, movedPage } from "./host-check.js";
|
|
12
|
+
import { hostPort, hostRefusedPage, movedPage } from "./host-check.js";
|
|
13
13
|
// img-src names Google's favicon service and the four hosts it redirects to: the console's Keys page shows a provider's
|
|
14
14
|
// icon from it (apps/console/src/components/ProviderIcon.tsx), sent with no referrer. Everything else is this origin's.
|
|
15
15
|
const CSP = "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https://www.google.com https://t0.gstatic.com https://t1.gstatic.com https://t2.gstatic.com https://t3.gstatic.com; base-uri 'none'; form-action https://github.com; frame-ancestors 'none'";
|
|
@@ -65,16 +65,31 @@ export class ConsoleSessions {
|
|
|
65
65
|
return this.ids.has(digest(value).toString("hex"));
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
/** One name per port: cookies are kept per host, not per port, and another server on this machine has
|
|
69
|
-
|
|
68
|
+
/** One name per port the browser opened: cookies are kept per host, not per port, and another server on this machine has
|
|
69
|
+
* another token. The port is the Host header's, the browser's: a server in a container sees its own port on its socket
|
|
70
|
+
* (7340, published at 7350), and so does another beside it. A Host with no port keeps the socket's. */
|
|
71
|
+
const browserPort = (req) => hostPort(req.headers.host) ?? req.socket.localPort;
|
|
72
|
+
const cookieName = (req) => `agentrun-${browserPort(req)}`;
|
|
70
73
|
export const cookiesOf = (req, name) => String(req.headers.cookie ?? "").split(";").map((part) => part.trim()).filter((part) => part.startsWith(`${name}=`)).map((part) => part.slice(name.length + 1));
|
|
71
74
|
export const overHttps = (req) => String(req.headers["x-forwarded-proto"] ?? "").split(",")[0].trim().toLowerCase() === "https";
|
|
72
75
|
export const ownOrigin = (req) => `${overHttps(req) ? "https" : "http"}://${String(req.headers.host ?? "").toLowerCase()}`;
|
|
73
76
|
export const isJson = (req) => String(req.headers["content-type"] ?? "").split(";")[0].trim().toLowerCase() === "application/json";
|
|
74
|
-
/** The owner's session cookie: `__Host-` on https, so no other host or path can set it; else one per port. */
|
|
75
|
-
export const ownerCookieName = (req) => (overHttps(req) ? "__Host-agentrun-session" : `agentrun-${req
|
|
76
|
-
/** A Set-Cookie line for the owner's session: `value`, or an empty one that ends it (`maxAgeS` 0)
|
|
77
|
-
|
|
77
|
+
/** The owner's session cookie: `__Host-` on https, so no other host or path can set it; else one per port the browser opened. */
|
|
78
|
+
export const ownerCookieName = (req) => (overHttps(req) ? "__Host-agentrun-session" : `agentrun-${browserPort(req)}-session`);
|
|
79
|
+
/** A Set-Cookie line for the owner's session: `value`, or an empty one that ends it (`maxAgeS` 0); under `name`, this
|
|
80
|
+
* request's own unless another is given. */
|
|
81
|
+
export const ownerCookie = (req, value, maxAgeS, name = ownerCookieName(req)) => `${name}=${value}; HttpOnly; SameSite=Strict; Path=/; Max-Age=${maxAgeS}${overHttps(req) ? "; Secure" : ""}`;
|
|
82
|
+
/** The owner's session cookies the request holds under this request's name and under any port's (`agentrun-<port>-session`),
|
|
83
|
+
* each with its name, valid or not: a browser sends a host's cookies to every port of it, so one signed in at 7340 and
|
|
84
|
+
* again through a tunnel at 8080 sends both to either. Which are this server's is the owner's to say (Owner.valid). */
|
|
85
|
+
export const sessionsAtEveryPort = (req) => {
|
|
86
|
+
const own = ownerCookieName(req);
|
|
87
|
+
return String(req.headers.cookie ?? "").split(";").flatMap((part) => {
|
|
88
|
+
const at = part.indexOf("=");
|
|
89
|
+
const name = part.slice(0, at).trim();
|
|
90
|
+
return at > 0 && (name === own || /^agentrun-\d{1,5}-session$/.test(name)) ? [{ name, value: part.slice(at + 1).trim() }] : [];
|
|
91
|
+
});
|
|
92
|
+
};
|
|
78
93
|
/** The owner's session cookies the request holds, valid or not. */
|
|
79
94
|
export const heldSessions = (req) => cookiesOf(req, ownerCookieName(req));
|
|
80
95
|
/** Whether the request holds a session the owner signed in. */
|
package/dist/place-offers.d.ts
CHANGED
|
@@ -41,6 +41,19 @@ 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 a container that has no Docker socket: the one-container `docker run` and
|
|
45
|
+
* deploy/'s compose file give it none, so it asks a daemon that is not there. Starting Docker or joining its group
|
|
46
|
+
* would not help: compose.yaml at the repository's root mounts the host's socket. */
|
|
47
|
+
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, start AgentRun with `docker compose up -d` from compose.yaml at the repository's root, which gives it the socket";
|
|
48
|
+
/** The same, for a container given the socket and refused it: the group compose.yaml adds (DOCKER_GID) is not the
|
|
49
|
+
* socket's. usermod in the container would not last past its restart. */
|
|
50
|
+
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 (/.dockerenv, Podman's /run/.containerenv), and how it tells whether a path
|
|
52
|
+
* is there (`exists`: the socket a failed probe names). What a failed probe says to do. */
|
|
53
|
+
export type ContainerFacts = {
|
|
54
|
+
inside: boolean;
|
|
55
|
+
exists?: (path: string) => boolean;
|
|
56
|
+
};
|
|
44
57
|
/** How long Docker's probe may take. */
|
|
45
58
|
export declare const PROBE_TIMEOUT_MS = 5000;
|
|
46
59
|
/** What `docker version` says of this machine's Docker daemon: it answers (`up`), or why not. `absent`: no daemon
|
|
@@ -59,7 +72,7 @@ export declare function askDockerDaemon(env: NodeJS.ProcessEnv, signal: AbortSig
|
|
|
59
72
|
file: string;
|
|
60
73
|
user: string;
|
|
61
74
|
ids: readonly number[];
|
|
62
|
-
}): Promise<DockerDaemon>;
|
|
75
|
+
}, container?: ContainerFacts): Promise<DockerDaemon>;
|
|
63
76
|
/** What placeOffers takes beyond the environment. */
|
|
64
77
|
export type PlaceOffersOptions = {
|
|
65
78
|
/** A provider key's value as a run's claim reads it (key-meta.ts keyReader); default `env`'s alone. */
|
|
@@ -73,6 +86,9 @@ export type PlaceOffersOptions = {
|
|
|
73
86
|
user: string;
|
|
74
87
|
ids: readonly number[];
|
|
75
88
|
};
|
|
89
|
+
/** Whether this server runs in a container, and how a path is checked, which say a failed probe's fix (containerReason);
|
|
90
|
+
* default this process's. */
|
|
91
|
+
container?: ContainerFacts;
|
|
76
92
|
/** Under --faux only: Docker answers, whatever AGENTRUN_BOXES lists, and nothing asks it. */
|
|
77
93
|
fauxDocker?: boolean;
|
|
78
94
|
};
|
package/dist/place-offers.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
// provider requires are set (the server's environment, else saved in Settings → Computers), and are not asked anything
|
|
11
11
|
// at the start: a key the vendor refuses fails the run's computer start, in the vendor's words.
|
|
12
12
|
import { execFile } from "node:child_process";
|
|
13
|
+
import { existsSync } from "node:fs";
|
|
13
14
|
import { readFile } from "node:fs/promises";
|
|
14
15
|
import { userInfo } from "node:os";
|
|
15
16
|
import { PROVIDERS } from "@parcha/agentrun-computer";
|
|
@@ -81,6 +82,39 @@ const ownGroups = () => {
|
|
|
81
82
|
catch { }
|
|
82
83
|
return { file: "/etc/group", user, ids: process.getgroups?.() ?? [] };
|
|
83
84
|
};
|
|
85
|
+
/** Why docker is unavailable to a server in a container that has no Docker socket: the one-container `docker run` and
|
|
86
|
+
* deploy/'s compose file give it none, so it asks a daemon that is not there. Starting Docker or joining its group
|
|
87
|
+
* would not help: compose.yaml at the repository's root mounts the host's socket. */
|
|
88
|
+
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, start AgentRun with `docker compose up -d` from compose.yaml at the repository's root, which gives it the socket";
|
|
89
|
+
/** The same, for a container given the socket and refused it: the group compose.yaml adds (DOCKER_GID) is not the
|
|
90
|
+
* socket's. usermod in the container would not last past its restart. */
|
|
91
|
+
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
|
+
const ownContainer = () => ({ inside: existsSync("/.dockerenv") || existsSync("/run/.containerenv") });
|
|
93
|
+
/** The daemon address docker names when it cannot connect ("Cannot connect to the Docker daemon at unix:///….sock."):
|
|
94
|
+
* the one its DOCKER_HOST or current context resolved to. Matched, never shown. */
|
|
95
|
+
const DAEMON_AT = /docker daemon at ([a-z]+:\/\/\S+?)\.?(?:\s|$)/i;
|
|
96
|
+
/** Whether the socket a failed probe asked is there: the unix socket docker named (DAEMON_AT); any other address (tcp,
|
|
97
|
+
* ssh) is one; with none named, DOCKER_HOST or DOCKER_CONTEXT is one, else the default /var/run/docker.sock. */
|
|
98
|
+
function socketThere(endpoint, env, exists) {
|
|
99
|
+
if (endpoint !== undefined)
|
|
100
|
+
return endpoint.startsWith("unix://") ? exists(endpoint.slice("unix://".length)) : true;
|
|
101
|
+
return Boolean(env.DOCKER_HOST || env.DOCKER_CONTEXT) || exists("/var/run/docker.sock");
|
|
102
|
+
}
|
|
103
|
+
/** A failed probe's reason in a container, where the host's words (start Docker, usermod) are the wrong fix: a socket
|
|
104
|
+
* 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 (the host's Docker is down). */
|
|
106
|
+
const containerReason = (answer, env, container) => {
|
|
107
|
+
if (!container.inside || answer.failed === undefined)
|
|
108
|
+
return undefined;
|
|
109
|
+
if (answer.denied)
|
|
110
|
+
return DOCKER_SOCKET_GROUP;
|
|
111
|
+
return socketThere(answer.endpoint, env, container.exists ?? existsSync) ? undefined : DOCKER_NO_SOCKET;
|
|
112
|
+
};
|
|
113
|
+
/** The daemon address in docker's stderr, when it names one (DAEMON_AT). */
|
|
114
|
+
const endpointIn = (stderr) => {
|
|
115
|
+
const named = DAEMON_AT.exec(String(stderr))?.[1];
|
|
116
|
+
return named !== undefined ? { endpoint: named } : {};
|
|
117
|
+
};
|
|
84
118
|
/** docker's own words for a socket that refused this process (the CLI's, or the connect's EACCES). Matched, never shown. */
|
|
85
119
|
const SOCKET_DENIED = /permission denied while trying to connect to the docker daemon socket|docker\.sock: connect: permission denied/i;
|
|
86
120
|
/** How long Docker's probe may take. */
|
|
@@ -94,17 +128,21 @@ function errorName(error) {
|
|
|
94
128
|
}
|
|
95
129
|
/** Asks this machine's Docker daemon its version (`docker version`), as the Docker computer's check (docker-daemon.ts)
|
|
96
130
|
* does: the CLI is on PATH and its daemon answers this user. `signal` bounds it. */
|
|
97
|
-
export async function askDockerDaemon(env, signal, groups = ownGroups()) {
|
|
131
|
+
export async function askDockerDaemon(env, signal, groups = ownGroups(), container = ownContainer()) {
|
|
98
132
|
// Its environment is the server's through the cut a run's takes (withoutSecrets): no box key, no other secret, no
|
|
99
133
|
// name shaped like a key.
|
|
100
134
|
const dockerEnv = withoutSecrets(env);
|
|
101
135
|
const answer = await new Promise((resolve) => execFile("docker", ["version", "--format", "{{.Server.Version}}"], { env: dockerEnv, signal, maxBuffer: 64 * 1024 }, (error, stdout, stderr) => {
|
|
102
136
|
const code = error?.code;
|
|
103
|
-
resolve({ ...(error ? { failed: typeof code === "number" ? `exit ${code}` : errorName(error), ...(SOCKET_DENIED.test(String(stderr)) ? { denied: true } : {}) } : {}), out: String(stdout) });
|
|
137
|
+
resolve({ ...(error ? { failed: typeof code === "number" ? `exit ${code}` : errorName(error), ...(SOCKET_DENIED.test(String(stderr)) ? { denied: true } : {}), ...endpointIn(stderr) } : {}), out: String(stdout) });
|
|
104
138
|
}));
|
|
105
139
|
const absent = (reason) => ({ up: false, absent: true, reason });
|
|
106
140
|
// 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
|
|
107
141
|
// first-time user's first read: what is wrong in plain words, what the probe saw, then what to do.
|
|
142
|
+
// In a container, the fix is its socket or that socket's group (containerReason), never the host's.
|
|
143
|
+
const inside = containerReason(answer, env, container);
|
|
144
|
+
if (inside !== undefined)
|
|
145
|
+
return { up: false, absent: !answer.denied, reason: inside };
|
|
108
146
|
if (answer.failed === "ENOENT")
|
|
109
147
|
return absent("Docker isn't running on this machine (no docker command on PATH): install or start Docker, then restart AgentRun");
|
|
110
148
|
// Its socket refused this process: the group it lacks, and how to get it without a reboot (the words, never docker's):
|
|
@@ -119,7 +157,7 @@ export async function askDockerDaemon(env, signal, groups = ownGroups()) {
|
|
|
119
157
|
}
|
|
120
158
|
/** Docker's offer: `docker version` names the daemon's version, so the CLI is on PATH and its daemon answers this user.
|
|
121
159
|
* Bounded by `timeoutMs`; never rejects. */
|
|
122
|
-
async function probeDocker(env, timeoutMs, groups) {
|
|
160
|
+
async function probeDocker(env, timeoutMs, groups, container) {
|
|
123
161
|
const no = (reason) => ({ id: "docker", available: false, reason });
|
|
124
162
|
// Its environment is the server's through the cut a run's takes (withoutSecrets): no box key, no other secret, no
|
|
125
163
|
// name shaped like a key.
|
|
@@ -127,12 +165,15 @@ async function probeDocker(env, timeoutMs, groups) {
|
|
|
127
165
|
const answer = await new Promise((resolve) => execFile("docker", ["version", "--format", "{{.Server.Version}}"], { env: dockerEnv, timeout: timeoutMs, killSignal: "SIGKILL", maxBuffer: 64 * 1024 }, (error, stdout, stderr) => {
|
|
128
166
|
const failed = error;
|
|
129
167
|
const code = failed?.code;
|
|
130
|
-
resolve({ ...(failed ? { failed: typeof code === "number" ? `exit ${code}` : errorName(failed), ...(failed.killed ? { late: true } : {}), ...(SOCKET_DENIED.test(String(stderr)) ? { denied: true } : {}) } : {}), out: String(stdout) });
|
|
168
|
+
resolve({ ...(failed ? { failed: typeof code === "number" ? `exit ${code}` : errorName(failed), ...(failed.killed ? { late: true } : {}), ...(SOCKET_DENIED.test(String(stderr)) ? { denied: true } : {}), ...endpointIn(stderr) } : {}), out: String(stdout) });
|
|
131
169
|
}));
|
|
132
170
|
// Docker is on by default, so its reason is often a first-time user's first read: what is wrong in plain words, what
|
|
133
171
|
// the probe saw, then what to do.
|
|
134
172
|
if (answer.late)
|
|
135
173
|
return no(`Docker isn't answering on this machine (docker version took over ${timeoutMs} ms): start Docker, then restart AgentRun`);
|
|
174
|
+
const inside = containerReason(answer, env, container);
|
|
175
|
+
if (inside !== undefined)
|
|
176
|
+
return no(inside);
|
|
136
177
|
if (answer.failed === "ENOENT")
|
|
137
178
|
return no("Docker isn't running on this machine (no docker command on PATH): install or start Docker, then restart AgentRun");
|
|
138
179
|
// Its socket refused this process: the group it lacks, and how to get it without a reboot (the words, never docker's):
|
|
@@ -169,7 +210,7 @@ export async function placeOffers(env, options = {}) {
|
|
|
169
210
|
if (!enabled.has(id))
|
|
170
211
|
return { id, available: false, reason: notEnabled(id, enabled) };
|
|
171
212
|
if (id === "docker")
|
|
172
|
-
return probeDocker(env, options.timeoutMs ?? PROBE_TIMEOUT_MS, options.groups ?? ownGroups());
|
|
213
|
+
return probeDocker(env, options.timeoutMs ?? PROBE_TIMEOUT_MS, options.groups ?? ownGroups(), options.container ?? ownContainer());
|
|
173
214
|
return remoteOffer(id, keyOf);
|
|
174
215
|
}));
|
|
175
216
|
}
|
package/dist/print.js
CHANGED
|
@@ -16,7 +16,7 @@ export function banner(o) {
|
|
|
16
16
|
`AGENTRUN_API_KEY=${key}`,
|
|
17
17
|
...(o.tokenIds && (o.tokenIds.length > 1 || o.source === "list") ? [`API tokens taken (ids): ${o.tokenIds.join(", ")}`] : []),
|
|
18
18
|
o.apiOnly
|
|
19
|
-
? "API only (AGENTRUN_API_ONLY=1): the run and deploy routes are served; the console, sign-in, setup, settings, MCP, triggers and hooks are refused."
|
|
19
|
+
? "API only (AGENTRUN_API_ONLY=1): the run and deploy routes, the MCP server names, a Composio server's save and a server's delete are served; the console, sign-in, setup, other settings, the MCP endpoint, triggers and hooks are refused."
|
|
20
20
|
: o.accounts || o.launchCode === undefined ? `Open ${o.publicUrl ?? o.url}/` : `Open ${o.publicUrl ?? o.url}/?launch=${o.launchCode}`,
|
|
21
21
|
...(o.boxes ? [o.boxes] : []),
|
|
22
22
|
];
|
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
import { ApiError } from "./errors.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type LearningFolder, type SnapChange, type Snapshot } from "./learn/folder.js";
|
|
3
|
+
import type { PromotionRecord, Refused } from "./learn/promote.js";
|
|
3
4
|
import type { RunRow, Store } from "./store/index.js";
|
|
5
|
+
import type { Workspace } from "./workspace/index.js";
|
|
4
6
|
/** 410 purged for a route of a purged run (Runs.purge): its tombstone, what is kept of it. `tools_usd`: its paid tools'
|
|
5
7
|
* meter as /usage read it at its purge (null: unknown, or none read). */
|
|
6
8
|
export declare function purgedRun(row: RunRow): ApiError;
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
9
|
+
/** Which of `runIds` are purged, each with its row: by its row's purge time. One store read per run. */
|
|
10
|
+
export declare function purgedRows(store: Pick<Store, "runs">, runIds: Iterable<string>): Promise<ReadonlyMap<string, RunRow>>;
|
|
11
|
+
/** The one gate every read of the learning folder at a commit goes through, main's or a past commit's (learn/folder.ts
|
|
12
|
+
* snapshotAt, folderAt): the view, the log and a workflow's revisions, a merge's diff, a run's seed (learning.ts seedAt)
|
|
13
|
+
* and the champion read by digest, an SDK start's receipt, and a compile ask (runner/learning-end.ts compileAskOf).
|
|
14
|
+
* `workflows`: each learned workflow of `snapshot` whose workflow.json a purged run wrote (SnapLearned.run: the run of
|
|
15
|
+
* the newest commit that changed the file, over main's whole history, which a purge's put-back hands to the run that
|
|
16
|
+
* wrote those bytes), by name, with that run's row; no read lays, checks, replays, serves or shows it. `served`, read
|
|
17
|
+
* only when `log` is asked: whether a change of the snapshot's log is served (no purged run's merge is), so a log the
|
|
18
|
+
* folder rebuilds names one and still serves none. */
|
|
19
|
+
export declare function purgeGate(snapshot: Snapshot | undefined, store: Pick<Store, "runs">, log?: boolean): Promise<{
|
|
20
|
+
workflows: ReadonlyMap<string, RunRow>;
|
|
21
|
+
served: (change: SnapChange) => boolean;
|
|
22
|
+
}>;
|
|
23
|
+
/** The promotion records of `workflows` that championOf skips (learn/promote.ts Refused), read through purgeGate at
|
|
24
|
+
* each record's commit of the learning folder at `ws`: newest promotion first, whatever its digest's newest decision
|
|
25
|
+
* (a champion held since included: skipping it may leave an earlier one serving), one the gate refuses at its commit (a
|
|
26
|
+
* purged run wrote its workflow there) is skipped with every record of its workflow at that commit (by workflow and
|
|
27
|
+
* commit, so a copy of the records read later is skipped alike, a hold of it included), until the newest promotion left
|
|
28
|
+
* is one the gate lets through, or none is left. The holds are walked the same way, newest first: a hold at a commit the
|
|
29
|
+
* gate refuses (a check that ended after its revision's run was purged holds it there) is skipped with its commit's
|
|
30
|
+
* records, until the newest hold left is one the gate lets through, so the compile's held names (learn/compile.ts
|
|
31
|
+
* heldNamesOf) never ask a revision of a purged run's text. A record with no commit is let through, and so is a commit
|
|
32
|
+
* the folder no longer has (reading its text fails on its own). A commit whose read throws refuses none here and is said
|
|
33
|
+
* (Refused.unread), so the promotions trim trims nothing on it (recordPromotion); a store read of the gate's that throws
|
|
34
|
+
* throws, so every write that asks fails closed. One read-only exec per commit asked. */
|
|
35
|
+
export declare function refusedOf(records: readonly PromotionRecord[], workflows: Iterable<string>, ws: Workspace, store: Pick<Store, "runs">): Promise<Refused>;
|
|
36
|
+
/** refusedOf in the learning folder `folder` opens for each ask (ended after it), over `workflows` (every workflow of
|
|
37
|
+
* the records when absent): the port a champion's readers and the promotions trim ask (runner/promotion.ts
|
|
38
|
+
* PromotionDeps refused, learn/promote.ts recordPromotion). An end() that throws is said to `log` (when given) and never
|
|
39
|
+
* fails the ask: the answer was read. */
|
|
40
|
+
export declare const refusedIn: (folder: () => Pick<LearningFolder, "workspace" | "end">, store: Pick<Store, "runs">, log?: (line: string) => void) => (records: readonly PromotionRecord[], workflows?: Iterable<string>) => Promise<Refused>;
|
package/dist/purged-workflow.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
// What a purged run (DELETE /v2/runs/{id}, agent-delete.ts purgeRun) answers, and the one rule for a learned workflow
|
|
2
|
-
// whose text it wrote: its purge
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// purged before purges took it off) is 410 purged with the run's tombstone, as every route of the run is (purgedRun).
|
|
6
|
-
// - The champion read by digest (GET .../learning/promotions) reads no commit for it.
|
|
7
|
-
// - A later merge's diff (GET /runs/{id}/learning/diff) serves that file against nothing: never the purged text.
|
|
8
|
-
// - An SDK start sent again (sdk/runs.ts receipt) whose receipt pinned it is 410 purged, as the file read.
|
|
9
|
-
// - A run's seed (learning.ts seedAt) leaves it out, so no claim lays, checks, replays or serves it, and a champion
|
|
10
|
-
// read at its commit finds none: the run goes on as it does when no champion serves.
|
|
2
|
+
// whose text it wrote: its purge puts back the version before it, or takes it off main when it wrote it new
|
|
3
|
+
// (learn/commit.ts forgetRunText), and every read of the folder at a commit asks purgeGate, so a purged run's text is
|
|
4
|
+
// never served or executed and none of its merges is shown.
|
|
11
5
|
import { ApiError } from "./errors.js";
|
|
6
|
+
import { snapshotAt } from "./learn/folder.js";
|
|
12
7
|
const isoOrNull = (ms) => (ms === null ? null : new Date(ms).toISOString());
|
|
13
8
|
/** 410 purged for a route of a purged run (Runs.purge): its tombstone, what is kept of it. `tools_usd`: its paid tools'
|
|
14
9
|
* meter as /usage read it at its purge (null: unknown, or none read). */
|
|
@@ -22,22 +17,74 @@ export function purgedRun(row) {
|
|
|
22
17
|
},
|
|
23
18
|
});
|
|
24
19
|
}
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
/** Which of `runIds` are purged, each with its row: by its row's purge time. One store read per run. */
|
|
21
|
+
export async function purgedRows(store, runIds) {
|
|
22
|
+
const rows = await Promise.all([...new Set(runIds)].map((run) => store.runs.get(run)));
|
|
23
|
+
return new Map(rows.flatMap((row) => (row && row.purgedAt !== null ? [[row.id, row]] : [])));
|
|
24
|
+
}
|
|
25
|
+
/** The one gate every read of the learning folder at a commit goes through, main's or a past commit's (learn/folder.ts
|
|
26
|
+
* snapshotAt, folderAt): the view, the log and a workflow's revisions, a merge's diff, a run's seed (learning.ts seedAt)
|
|
27
|
+
* and the champion read by digest, an SDK start's receipt, and a compile ask (runner/learning-end.ts compileAskOf).
|
|
28
|
+
* `workflows`: each learned workflow of `snapshot` whose workflow.json a purged run wrote (SnapLearned.run: the run of
|
|
29
|
+
* the newest commit that changed the file, over main's whole history, which a purge's put-back hands to the run that
|
|
30
|
+
* wrote those bytes), by name, with that run's row; no read lays, checks, replays, serves or shows it. `served`, read
|
|
31
|
+
* only when `log` is asked: whether a change of the snapshot's log is served (no purged run's merge is), so a log the
|
|
32
|
+
* folder rebuilds names one and still serves none. */
|
|
33
|
+
export async function purgeGate(snapshot, store, log = false) {
|
|
34
|
+
const writers = new Map((snapshot?.workflows ?? []).flatMap((item) => (item.run ? [[item.name, item.run]] : [])));
|
|
35
|
+
const logged = log ? (snapshot?.log ?? []).flatMap(({ by }) => ("run" in by ? [by.run] : [])) : [];
|
|
36
|
+
const purged = await purgedRows(store, [...writers.values(), ...logged]);
|
|
37
|
+
const workflows = new Map([...writers].flatMap(([name, run]) => (purged.has(run) ? [[name, purged.get(run)]] : [])));
|
|
38
|
+
return {
|
|
39
|
+
workflows,
|
|
40
|
+
served: ({ by }) => {
|
|
41
|
+
if (!log)
|
|
42
|
+
throw new Error("the purge gate was not asked for the log");
|
|
43
|
+
return !("run" in by && purged.has(by.run));
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** The promotion records of `workflows` that championOf skips (learn/promote.ts Refused), read through purgeGate at
|
|
48
|
+
* each record's commit of the learning folder at `ws`: newest promotion first, whatever its digest's newest decision
|
|
49
|
+
* (a champion held since included: skipping it may leave an earlier one serving), one the gate refuses at its commit (a
|
|
50
|
+
* purged run wrote its workflow there) is skipped with every record of its workflow at that commit (by workflow and
|
|
51
|
+
* commit, so a copy of the records read later is skipped alike, a hold of it included), until the newest promotion left
|
|
52
|
+
* is one the gate lets through, or none is left. The holds are walked the same way, newest first: a hold at a commit the
|
|
53
|
+
* gate refuses (a check that ended after its revision's run was purged holds it there) is skipped with its commit's
|
|
54
|
+
* records, until the newest hold left is one the gate lets through, so the compile's held names (learn/compile.ts
|
|
55
|
+
* heldNamesOf) never ask a revision of a purged run's text. A record with no commit is let through, and so is a commit
|
|
56
|
+
* the folder no longer has (reading its text fails on its own). A commit whose read throws refuses none here and is said
|
|
57
|
+
* (Refused.unread), so the promotions trim trims nothing on it (recordPromotion); a store read of the gate's that throws
|
|
58
|
+
* throws, so every write that asks fails closed. One read-only exec per commit asked. */
|
|
59
|
+
export async function refusedOf(records, workflows, ws, store) {
|
|
60
|
+
const refused = new Set();
|
|
61
|
+
const skip = (one) => one.commit !== undefined && refused.has(`${one.workflow}\0${one.commit}`);
|
|
62
|
+
let unread = false;
|
|
63
|
+
const reads = new Map();
|
|
64
|
+
const gated = (commit) => reads.get(commit) ?? reads.set(commit, snapshotAt(ws, commit).then(async (at) => (await purgeGate(at, store)).workflows, () => {
|
|
65
|
+
unread = true;
|
|
66
|
+
return new Map();
|
|
67
|
+
})).get(commit);
|
|
68
|
+
const newestOf = (workflow, decided) => records.findLast((one) => one.workflow === workflow && one.decided === decided && !skip(one));
|
|
69
|
+
for (const workflow of new Set(workflows)) {
|
|
70
|
+
for (const decided of ["promote", "hold"]) {
|
|
71
|
+
for (let last = newestOf(workflow, decided); last?.commit && (await gated(last.commit)).has(workflow); last = newestOf(workflow, decided)) {
|
|
72
|
+
refused.add(`${workflow}\0${last.commit}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
41
75
|
}
|
|
42
|
-
return
|
|
76
|
+
return Object.assign(skip, { unread });
|
|
43
77
|
}
|
|
78
|
+
/** refusedOf in the learning folder `folder` opens for each ask (ended after it), over `workflows` (every workflow of
|
|
79
|
+
* the records when absent): the port a champion's readers and the promotions trim ask (runner/promotion.ts
|
|
80
|
+
* PromotionDeps refused, learn/promote.ts recordPromotion). An end() that throws is said to `log` (when given) and never
|
|
81
|
+
* fails the ask: the answer was read. */
|
|
82
|
+
export const refusedIn = (folder, store, log) => async (records, workflows) => {
|
|
83
|
+
const { workspace, end } = folder();
|
|
84
|
+
try {
|
|
85
|
+
return await refusedOf(records, workflows ?? records.map((one) => one.workflow), workspace, store);
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
await end().catch((error) => log?.(`learning: the learning folder did not end after the purge gate's ask: ${error instanceof Error ? error.message : String(error)}`));
|
|
89
|
+
}
|
|
90
|
+
};
|
package/dist/run-computer.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ComputerKind, ComputerSetting } from "./computer-setting.js";
|
|
2
2
|
/** What a computer is doing, as a run reads it. */
|
|
3
3
|
export type ComputerState = "starting" | "ready" | "taken_over" | "ended" | "failed";
|
|
4
|
+
/** The states of a computer its run still has. */
|
|
5
|
+
export declare const COMPUTER_UP: ReadonlySet<ComputerState>;
|
|
4
6
|
/** The port the run read's computer field reads: run `runId`'s computer state with the owner's hold, "taken_over" while
|
|
5
7
|
* the owner holds it, else `state` as given. */
|
|
6
8
|
export type ComputerStateOf = (runId: string, state: ComputerState) => ComputerState;
|
package/dist/run-computer.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { COMPUTER_UNAVAILABLE } from "./computers.js";
|
|
2
|
+
/** The states of a computer its run still has. */
|
|
3
|
+
export const COMPUTER_UP = new Set(["starting", "ready", "taken_over"]);
|
|
2
4
|
const ENDED = new Set(["completed", "failed", "cancelled", "expired"]);
|
|
3
5
|
/** The run's `computer` field: absent for a run with none; failed with why when its computer could not be had; ended
|
|
4
6
|
* once the run is over; else starting (queued) or ready (going), taken_over while the owner holds it (`stateOf`). */
|
package/dist/run-files.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ import { type Entry, type Workspace } from "./workspace/index.js";
|
|
|
4
4
|
export declare const WALK_DEPTH = 16;
|
|
5
5
|
/** The CSP a served HTML file runs under: an opaque origin, no scripts, no network. */
|
|
6
6
|
export declare const FILE_CSP = "default-src 'none'; style-src 'unsafe-inline'; img-src data:; sandbox; form-action 'none'";
|
|
7
|
+
/** The largest file a cut read (`?cut=run`) answers, in bytes: 256 KiB. redactSecrets runs synchronously over the whole
|
|
8
|
+
* text, on the server's event loop. At this size each shape's adversarial input (its prefix repeated with no end, in
|
|
9
|
+
* secrets-linear.test.mjs) takes under 100 ms here, and prose with 100 held values at most 162 ms. A bigger file is 413. */
|
|
10
|
+
export declare const RUN_FILE_CUT_MAX: number;
|
|
7
11
|
export type FileView = {
|
|
8
12
|
path: string;
|
|
9
13
|
size_bytes: number;
|
package/dist/run-files.js
CHANGED
|
@@ -7,6 +7,10 @@ export const WALK_DEPTH = 16;
|
|
|
7
7
|
const SEND_CHUNK = 4 * 1024 * 1024;
|
|
8
8
|
/** The CSP a served HTML file runs under: an opaque origin, no scripts, no network. */
|
|
9
9
|
export const FILE_CSP = "default-src 'none'; style-src 'unsafe-inline'; img-src data:; sandbox; form-action 'none'";
|
|
10
|
+
/** The largest file a cut read (`?cut=run`) answers, in bytes: 256 KiB. redactSecrets runs synchronously over the whole
|
|
11
|
+
* text, on the server's event loop. At this size each shape's adversarial input (its prefix repeated with no end, in
|
|
12
|
+
* secrets-linear.test.mjs) takes under 100 ms here, and prose with 100 held values at most 162 ms. A bigger file is 413. */
|
|
13
|
+
export const RUN_FILE_CUT_MAX = 256 * 1024;
|
|
10
14
|
/** File `path` as the API lists it, from its Workspace listing entry. */
|
|
11
15
|
export const viewOf = (path, entry) => ({
|
|
12
16
|
path, size_bytes: entry.size, modified_at: new Date(entry.mtimeMs).toISOString(), content_type: typeOf(path) ?? null, ...(entry.unreadable ? { unreadable: true } : {}),
|
package/dist/run-keys.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ import type { Revision } from "./agent-rows.js";
|
|
|
3
3
|
import { type RunNeeds } from "./run-secrets.js";
|
|
4
4
|
/** A run's own tool keys, by name. */
|
|
5
5
|
export type RunKeys = Readonly<Record<string, string>>;
|
|
6
|
-
/** The tool keys a run of `tools` reads (run-secrets.ts unlockedFields, over tool-keys.ts TOOL_KEYS). */
|
|
7
|
-
export declare const keysOfTools: (tools: readonly string[]) => string[];
|
|
8
6
|
/** The tool keys a template's apply made `revision` with (its package's `secrets`, kept on the revision): the ones a run
|
|
9
7
|
* can carry. A model key is not one. */
|
|
10
8
|
export declare const packageKeysOf: (revision: object) => string[];
|
|
@@ -28,8 +26,8 @@ export declare function withCarried(env: NodeJS.ProcessEnv, names: readonly stri
|
|
|
28
26
|
/** Under the run-keys setting, each tool key `revision`'s template declared that `env` (the server's) does not hold and
|
|
29
27
|
* the run does not carry, as a 409 issue at keys.<NAME>: the apply made it on the promise each run brings it. */
|
|
30
28
|
export declare function keysOwed(revision: object, env: NodeJS.ProcessEnv, carried: readonly string[]): InputIssue[];
|
|
31
|
-
/** The 409 a run that owes `owed` (keysOwed) gets at its start, and a trigger that could only start or
|
|
32
|
-
* gets when it is made or moved (firingsOwe). */
|
|
29
|
+
/** The 409 a run that owes `owed` (keysOwed) gets at its start or a message, and a trigger that could only start or
|
|
30
|
+
* message such runs gets when it is made or moved, and at a message_run firing (firingsOwe). */
|
|
33
31
|
export declare const keysOwedRefusal: (owed: readonly InputIssue[]) => ApiError;
|
|
34
32
|
/** Under the run-keys setting, whether a trigger's firings could never bring the keys runs of its agent owe (`owed`,
|
|
35
33
|
* keysOwed with nothing carried): a message_run's never do, hook or not; a start_run's do only through the launch hook,
|
package/dist/run-keys.js
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
//
|
|
8
8
|
// AGENTRUN_RUN_KEYS=1 (env-switch.ts): an install whose runs bring the tool keys it does not hold. A template's
|
|
9
9
|
// apply then makes its agent though a tool key the template declares is not set here, and says so in a warning; a run of
|
|
10
|
-
// that revision that does not carry the key is refused (409 agent_not_runnable, at keys.<NAME>),
|
|
11
|
-
// whose firings could not carry it (firingsOwe). Off, nothing
|
|
10
|
+
// that revision that does not carry the key is refused (409 agent_not_runnable, at keys.<NAME>), no trigger is made
|
|
11
|
+
// whose firings could not carry it (firingsOwe), and a firing of one made before is refused the same. Off, nothing
|
|
12
|
+
// changes.
|
|
12
13
|
import { ApiError } from "./errors.js";
|
|
13
14
|
import { handedSecretOf } from "./handed-secret.js";
|
|
14
15
|
import { LAUNCH_HOOK_SECRET_ENV, LAUNCH_HOOK_URL_ENV } from "./trigger-launch-hook.js";
|
|
@@ -16,15 +17,13 @@ import { needsOf, unlockedFields } from "./run-secrets.js";
|
|
|
16
17
|
import { TOOL_FIELDS } from "./tool-keys.js";
|
|
17
18
|
import { isObject } from "./validate.js";
|
|
18
19
|
import { RUN_KEYS_ENV } from "./env-switch.js";
|
|
19
|
-
/** The tool keys a run of `tools` reads (run-secrets.ts unlockedFields, over tool-keys.ts TOOL_KEYS). */
|
|
20
|
-
export const keysOfTools = (tools) => unlockedFields(tools);
|
|
21
20
|
/** The tool keys a template's apply made `revision` with (its package's `secrets`, kept on the revision): the ones a run
|
|
22
21
|
* can carry. A model key is not one. */
|
|
23
22
|
export const packageKeysOf = (revision) => (revision.package?.secrets ?? []).filter((name) => TOOL_FIELDS.includes(name));
|
|
24
23
|
/** The names a run of `revision`, whose needs are `needs` (run-secrets.ts needsOf), may carry in `keys`: each tool key its
|
|
25
24
|
* tools read (an agentic revision's tools, a workflow's on its nodes and calls, and its decision providers'), and its
|
|
26
25
|
* template's tool keys. */
|
|
27
|
-
export const declaredFrom = (needs, revision) => [...new Set([...
|
|
26
|
+
export const declaredFrom = (needs, revision) => [...new Set([...unlockedFields([...needs.tools, ...needs.decisionProviders.map((provider) => `decisions.${provider}`)]), ...packageKeysOf(revision)])];
|
|
28
27
|
/** The names a run of `revision` may carry in `keys` (declaredFrom). */
|
|
29
28
|
export async function declaredKeys(revision) {
|
|
30
29
|
return declaredFrom(await needsOf(revision), revision);
|
|
@@ -89,8 +88,8 @@ export function keysOwed(revision, env, carried) {
|
|
|
89
88
|
fix: `Send keys.${name} with the run.`,
|
|
90
89
|
}));
|
|
91
90
|
}
|
|
92
|
-
/** The 409 a run that owes `owed` (keysOwed) gets at its start, and a trigger that could only start or
|
|
93
|
-
* gets when it is made or moved (firingsOwe). */
|
|
91
|
+
/** The 409 a run that owes `owed` (keysOwed) gets at its start or a message, and a trigger that could only start or
|
|
92
|
+
* message such runs gets when it is made or moved, and at a message_run firing (firingsOwe). */
|
|
94
93
|
export const keysOwedRefusal = (owed) => new ApiError("agent_not_runnable", owed.map((one) => one.message).join(" "), { fields: [...owed], details: { unbound: [], missing: {} } });
|
|
95
94
|
/** Under the run-keys setting, whether a trigger's firings could never bring the keys runs of its agent owe (`owed`,
|
|
96
95
|
* keysOwed with nothing carried): a message_run's never do, hook or not; a start_run's do only through the launch hook,
|
package/dist/run-launch.d.ts
CHANGED
|
@@ -149,6 +149,10 @@ export declare function launchBody(launch: RunLaunch): Json;
|
|
|
149
149
|
* disk's (learn/learning-of.ts): the run starts with nothing learned (`other_disk`), its flags kept. Any other launch as
|
|
150
150
|
* read. readLaunchBody keeps the body as written: a finished run's views show what it ran. */
|
|
151
151
|
export declare function launchOnItsDisk(launch: RunLaunch): RunLaunch;
|
|
152
|
+
/** Whether a person started the run: no trigger fired it (a schedule's, a webhook's, a trigger's turn into a run), and it
|
|
153
|
+
* is no learned workflow's audit shadow (runner/audit.ts) or replay (runner/promotion.ts), which the server starts
|
|
154
|
+
* itself. Only such a run goes on its owner's own sign-in (runner/harness-loops.ts, cli-run-spec.ts). */
|
|
155
|
+
export declare const personStarted: (launch: Pick<RunLaunch, "trigger" | "audit" | "replay">) => boolean;
|
|
152
156
|
/** A launch body read back into a `RunLaunch`, with the input-origin fail-safe applied through the body's own trigger, or
|
|
153
157
|
* undefined when the body is not one (not an object, or it names no place: a damaged or hand-edited body). */
|
|
154
158
|
export declare function readLaunchBody(stored: unknown): RunLaunch | undefined;
|
package/dist/run-launch.js
CHANGED
|
@@ -128,6 +128,10 @@ export function launchOnItsDisk(launch) {
|
|
|
128
128
|
const { noWorkflows, model, use } = launch.learning;
|
|
129
129
|
return { ...launch, learning: { seed: null, section: "", seedFailed: "other_disk", ...(noWorkflows ? { noWorkflows } : {}), ...(model ? { model } : {}), ...(use ? { use } : {}) } };
|
|
130
130
|
}
|
|
131
|
+
/** Whether a person started the run: no trigger fired it (a schedule's, a webhook's, a trigger's turn into a run), and it
|
|
132
|
+
* is no learned workflow's audit shadow (runner/audit.ts) or replay (runner/promotion.ts), which the server starts
|
|
133
|
+
* itself. Only such a run goes on its owner's own sign-in (runner/harness-loops.ts, cli-run-spec.ts). */
|
|
134
|
+
export const personStarted = (launch) => launch.trigger === undefined && launch.audit === undefined && launch.replay === undefined;
|
|
131
135
|
/** A launch body read back into a `RunLaunch`, with the input-origin fail-safe applied through the body's own trigger, or
|
|
132
136
|
* undefined when the body is not one (not an object, or it names no place: a damaged or hand-edited body). */
|
|
133
137
|
export function readLaunchBody(stored) {
|
|
@@ -5,7 +5,7 @@ import { type Page } from "./rows.js";
|
|
|
5
5
|
import { type FileView } from "./run-files.js";
|
|
6
6
|
import type { RunStated } from "./store-view.js";
|
|
7
7
|
import { type Store } from "./store/index.js";
|
|
8
|
-
import type
|
|
8
|
+
import { type Workspace } from "./workspace/index.js";
|
|
9
9
|
/** The most files a list answers with (server.ts FILE_LIST_CAP). */
|
|
10
10
|
export declare const FILE_LIST_CAP = 2000;
|
|
11
11
|
/** The store slice these reads need. */
|
|
@@ -51,7 +51,8 @@ export declare function listRunFiles(store: RunReadsStore, runId: string, deps:
|
|
|
51
51
|
}>;
|
|
52
52
|
/** One of a run's files, through its Workspace (readRunFile): streamed to `res` as the route streams it, with the route's
|
|
53
53
|
* path check and its 404 words; a withheld run refuses (403) before anything is streamed. A path under recordings/ is
|
|
54
|
-
* one of the run's recordings (its recordings folder, beside its Workspace's), never a file the run made.
|
|
54
|
+
* one of the run's recordings (its recordings folder, beside its Workspace's), never a file the run made. With
|
|
55
|
+
* `?cut=run`, the file's text under the run's own cut instead (cutRunFile). */
|
|
55
56
|
export declare function readRunFile(store: RunReadsStore, runId: string, rawPath: string, req: IncomingMessage, res: ServerResponse, url: URL, deps: RunReadsDeps): Promise<void>;
|
|
56
57
|
/** A run's browser state (getRunBrowser): `live` with its viewer's link when its runner serves one; else `off` with why
|
|
57
58
|
* when the run has no browser or its browser is unavailable here now (the kept plane re-checked, as a launch would); else
|