@parcha/agentrun-serve 0.1.0-beta.52 → 0.1.0-beta.54
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 +149 -1
- package/README.md +295 -37
- package/dist/agent-delete.d.ts +5 -6
- package/dist/agent-delete.js +30 -67
- package/dist/agent-package.d.ts +71 -0
- package/dist/agent-package.js +345 -0
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.d.ts +26 -20
- package/dist/agents-store.js +42 -34
- package/dist/api-only.d.ts +25 -6
- package/dist/api-only.js +34 -13
- package/dist/claude-login.d.ts +1 -0
- package/dist/claude-login.js +1 -1
- package/dist/cli-learning/cli.d.ts +3 -0
- package/dist/cli-learning/cli.js +17 -3
- package/dist/cli-learning/connections.js +3 -2
- package/dist/cli-learning/schema.js +2 -1
- package/dist/cli.js +76 -8
- package/dist/composio-preset.d.ts +3 -1
- package/dist/composio-preset.js +5 -3
- package/dist/composio-triggers.d.ts +4 -0
- package/dist/composio-triggers.js +4 -1
- package/dist/computer-needs.d.ts +32 -0
- package/dist/computer-needs.js +80 -0
- package/dist/computer-setting.d.ts +5 -2
- package/dist/computer-setting.js +8 -1
- package/dist/computers.d.ts +0 -2
- package/dist/computers.js +1 -1
- package/dist/console/assets/index-B_85An2t.js +745 -0
- package/dist/console/assets/index-n1YsbnYh.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +1 -0
- package/dist/console-links.js +2 -0
- package/dist/env-switch.d.ts +14 -0
- package/dist/env-switch.js +23 -0
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +10 -0
- package/dist/eval-previous.js +4 -3
- package/dist/fal-price.js +10 -13
- 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 +4 -0
- package/dist/handed-secret.js +10 -0
- package/dist/harness-archive.d.ts +15 -5
- package/dist/harness-archive.js +71 -34
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +36 -95
- package/dist/harness-egress.d.ts +23 -0
- package/dist/harness-egress.js +69 -0
- package/dist/harness-recipe-entry.d.ts +71 -0
- package/dist/harness-recipe-entry.js +184 -0
- package/dist/harness-recipe.d.ts +73 -6
- package/dist/harness-recipe.js +185 -31
- package/dist/harness-sign-in.d.ts +29 -0
- package/dist/harness-sign-in.js +122 -0
- package/dist/harness-table.d.ts +21 -0
- package/dist/harness-table.js +58 -3
- package/dist/harness-zip.d.ts +6 -0
- package/dist/harness-zip.js +203 -0
- package/dist/ids.d.ts +11 -0
- package/dist/ids.js +36 -0
- package/dist/learn/commit.d.ts +14 -1
- package/dist/learn/commit.js +156 -1
- package/dist/learn/compile.js +22 -8
- package/dist/learn/folder.d.ts +5 -0
- package/dist/learn/folder.js +10 -1
- package/dist/learn/learning.sh +15 -3
- package/dist/learn/promote.d.ts +2 -2
- package/dist/learn/secrets.js +30 -7
- package/dist/learning-routes.d.ts +23 -11
- package/dist/learning-routes.js +110 -20
- package/dist/learning.d.ts +9 -6
- package/dist/learning.js +9 -4
- package/dist/live-reach.d.ts +34 -7
- package/dist/live-reach.js +76 -11
- package/dist/mcp-gateway.js +15 -2
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +8 -3
- package/dist/mcp-resources.d.ts +44 -0
- package/dist/mcp-resources.js +100 -0
- package/dist/mcp-servers-store.d.ts +16 -12
- package/dist/model.d.ts +4 -4
- package/dist/model.js +6 -6
- package/dist/native/cli.js +9 -2
- package/dist/native/connection.d.ts +2 -2
- package/dist/native/connection.js +5 -2
- package/dist/native/discovery.d.ts +2 -0
- package/dist/native/discovery.js +10 -6
- package/dist/native/remote-worker-bridge.js +36 -4
- package/dist/native/remote.d.ts +18 -1
- package/dist/native/remote.js +126 -37
- package/dist/native/schema.d.ts +6 -0
- package/dist/native/schema.js +31 -6
- package/dist/native/source-account.d.ts +13 -0
- package/dist/native/source-account.js +114 -0
- package/dist/native/source-capture-hooks.d.ts +5 -0
- package/dist/native/source-capture-hooks.js +102 -0
- package/dist/native/source-mcp-selection.d.ts +13 -0
- package/dist/native/source-mcp-selection.js +72 -0
- package/dist/native/source-runtime-tools.d.ts +19 -0
- package/dist/native/source-runtime-tools.js +103 -0
- package/dist/native/source-snapshot-types.d.ts +138 -0
- package/dist/native/source-snapshot-types.js +12 -0
- package/dist/native/source-snapshot.d.ts +8 -0
- package/dist/native/source-snapshot.js +1201 -0
- package/dist/observation/learning.js +3 -2
- package/dist/openapi.js +275 -40
- package/dist/print.js +1 -1
- package/dist/purged-workflow.d.ts +12 -0
- package/dist/purged-workflow.js +43 -0
- package/dist/run-keys.d.ts +46 -0
- package/dist/run-keys.js +109 -0
- package/dist/run-launch.d.ts +16 -1
- package/dist/run-launch.js +30 -1
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-model-key.d.ts +2 -2
- package/dist/run-model-key.js +5 -5
- package/dist/run-secrets.d.ts +2 -0
- package/dist/run-secrets.js +7 -4
- package/dist/run-view.d.ts +17 -0
- package/dist/run-view.js +25 -1
- package/dist/runner/adapter-loop.d.ts +11 -3
- package/dist/runner/adapter-loop.js +138 -22
- package/dist/runner/adapter-run-spec.js +26 -13
- package/dist/runner/audit.d.ts +2 -0
- package/dist/runner/audit.js +9 -1
- package/dist/runner/beside.js +2 -1
- package/dist/runner/claim-secrets.d.ts +29 -3
- package/dist/runner/claim-secrets.js +38 -4
- package/dist/runner/cli-run-spec.js +24 -13
- package/dist/runner/harness-loops.d.ts +6 -0
- package/dist/runner/harness-loops.js +11 -1
- package/dist/runner/held.d.ts +4 -0
- package/dist/runner/journal-kinds.d.ts +2 -0
- package/dist/runner/learned-first.d.ts +2 -0
- package/dist/runner/learned-first.js +1 -1
- package/dist/runner/learning-end.d.ts +7 -2
- package/dist/runner/learning-end.js +22 -10
- package/dist/runner/learning-seed.d.ts +9 -3
- package/dist/runner/learning-seed.js +2 -2
- package/dist/runner/main.d.ts +1 -0
- package/dist/runner/main.js +20 -13
- package/dist/runner/mcp-claim.js +6 -1
- package/dist/runner/mcp-run.d.ts +10 -7
- package/dist/runner/mcp-run.js +3 -5
- package/dist/runner/metrics.d.ts +4 -2
- package/dist/runner/metrics.js +15 -3
- package/dist/runner/monid-run.js +9 -11
- package/dist/runner/pr-checkout.d.ts +21 -4
- package/dist/runner/pr-checkout.js +103 -4
- package/dist/runner/project-checkpoint.d.ts +35 -0
- package/dist/runner/project-checkpoint.js +116 -0
- package/dist/runner/project-drain.d.ts +8 -0
- package/dist/runner/project-drain.js +25 -0
- package/dist/runner/project-host.d.ts +10 -0
- package/dist/runner/project-host.js +52 -0
- package/dist/runner/promotion.d.ts +14 -6
- package/dist/runner/promotion.js +98 -41
- package/dist/runner/redact.d.ts +13 -0
- package/dist/runner/redact.js +67 -1
- package/dist/runner/run-channel.d.ts +9 -0
- package/dist/runner/run-channel.js +15 -2
- package/dist/runner/run-child-host.d.ts +8 -4
- package/dist/runner/run-child-host.js +178 -45
- package/dist/runner/run-errors.js +2 -2
- package/dist/runner/runner-check.d.ts +3 -0
- package/dist/runner/runner-check.js +28 -2
- package/dist/runner/runner.js +26 -9
- package/dist/runner/store-secrets.js +7 -3
- package/dist/runner/workflow-first.d.ts +4 -0
- package/dist/runner/workflow-first.js +13 -0
- package/dist/runner/workflow-loop.d.ts +2 -1
- package/dist/runner/workflow-loop.js +2 -1
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/runs-over-store.d.ts +34 -6
- package/dist/runs-over-store.js +133 -25
- package/dist/sdk/runs.d.ts +11 -1
- package/dist/sdk/runs.js +117 -26
- package/dist/sdk/schema.js +12 -2
- package/dist/sdk/workflows.d.ts +1 -1
- package/dist/server.d.ts +79 -32
- package/dist/server.js +673 -113
- package/dist/skills/agentrun-serve/SKILL.md +2 -1
- package/dist/source-sync/adoption.d.ts +15 -0
- package/dist/source-sync/adoption.js +36 -0
- package/dist/source-sync/auxiliary.d.ts +23 -0
- package/dist/source-sync/auxiliary.js +64 -0
- package/dist/source-sync/capture-git.d.ts +5 -0
- package/dist/source-sync/capture-git.js +272 -0
- package/dist/source-sync/capture-project.d.ts +53 -0
- package/dist/source-sync/capture-project.js +206 -0
- package/dist/source-sync/capture-refusal.d.ts +7 -0
- package/dist/source-sync/capture-refusal.js +16 -0
- package/dist/source-sync/capture.d.ts +11 -0
- package/dist/source-sync/capture.js +22 -0
- package/dist/source-sync/checkpoint-gate.d.ts +21 -0
- package/dist/source-sync/checkpoint-gate.js +52 -0
- package/dist/source-sync/checkpoints.d.ts +66 -0
- package/dist/source-sync/checkpoints.js +168 -0
- package/dist/source-sync/claim.d.ts +11 -0
- package/dist/source-sync/claim.js +48 -0
- package/dist/source-sync/destination.d.ts +47 -0
- package/dist/source-sync/destination.js +239 -0
- package/dist/source-sync/io.d.ts +15 -0
- package/dist/source-sync/io.js +52 -0
- package/dist/source-sync/local.d.ts +43 -0
- package/dist/source-sync/local.js +229 -0
- package/dist/source-sync/prepare.d.ts +59 -0
- package/dist/source-sync/prepare.js +93 -0
- package/dist/source-sync/projects.d.ts +61 -0
- package/dist/source-sync/projects.js +130 -0
- package/dist/source-sync/registry.d.ts +95 -0
- package/dist/source-sync/registry.js +226 -0
- package/dist/source-sync/service.d.ts +33 -0
- package/dist/source-sync/service.js +118 -0
- package/dist/source-sync/skill-edits.d.ts +12 -0
- package/dist/source-sync/skill-edits.js +122 -0
- package/dist/source-sync/snapshots.d.ts +48 -0
- package/dist/source-sync/snapshots.js +448 -0
- package/dist/source-sync/types.d.ts +9 -0
- package/dist/source-sync/types.js +14 -0
- package/dist/source-sync/workspace.d.ts +66 -0
- package/dist/source-sync/workspace.js +273 -0
- package/dist/store/agent-body.d.ts +6 -2
- package/dist/store/agent-body.js +18 -7
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +2 -1
- package/dist/store/seal.d.ts +5 -1
- package/dist/store/seal.js +12 -3
- package/dist/store/sqlite/project-checkpoints.d.ts +11 -0
- package/dist/store/sqlite/project-checkpoints.js +70 -0
- package/dist/store/sqlite/run-launch.d.ts +4 -12
- package/dist/store/sqlite/run-launch.js +5 -19
- package/dist/store/sqlite/store.js +224 -170
- package/dist/store/store.d.ts +116 -39
- package/dist/store/store.js +14 -1
- package/dist/store-reads/learning.d.ts +2 -2
- package/dist/store-view.d.ts +3 -1
- package/dist/store-view.js +17 -5
- 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-import.d.ts +27 -2
- package/dist/template-import.js +148 -13
- package/dist/templates.d.ts +103 -77
- package/dist/templates.js +71 -17
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -0
- package/dist/timeline/timeline.js +8 -0
- package/dist/tool-plane.d.ts +12 -12
- package/dist/tools.d.ts +8 -8
- package/dist/trigger-launch-hook.d.ts +49 -0
- package/dist/trigger-launch-hook.js +91 -0
- package/dist/trigger-targets.d.ts +14 -1
- package/dist/trigger-targets.js +20 -0
- package/dist/triggers.d.ts +54 -5
- package/dist/triggers.js +143 -8
- package/dist/uploads-archil.js +1 -1
- package/dist/uploads.js +1 -1
- package/dist/validate.d.ts +1 -1
- package/dist/validate.js +3 -4
- package/dist/workspace/computer-for-claim.d.ts +2 -0
- package/dist/workspace/computer-for-claim.js +43 -0
- package/dist/workspace/paths.d.ts +6 -0
- package/dist/workspace/paths.js +6 -0
- package/dist/workspace/resolve-computer.d.ts +1 -0
- package/dist/workspace/run-tools.d.ts +2 -0
- package/dist/workspace/run-tools.js +8 -0
- package/dist/workspace/synced-folder.d.ts +1 -1
- package/dist/workspace/synced-folder.js +11 -14
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +2 -1
- package/templates/README.md +8 -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-B-D0EM3j.js +0 -733
- package/dist/console/assets/index-DlQepP2J.css +0 -1
|
@@ -21,20 +21,22 @@ import { ARCHIL_SETTINGS_ENV } from "../archil-settings.js";
|
|
|
21
21
|
import { BOX_ALLOW_ENV } from "../box-settings.js";
|
|
22
22
|
import { TOOL_KEY_ROWS } from "../key-words.js";
|
|
23
23
|
import { PRIVATE_HOSTS_ENV } from "../mcp-private-hosts.js";
|
|
24
|
-
import { HARNESS_MODULES_SETTING } from "../harness-table.js";
|
|
24
|
+
import { HARNESS_MODULES_SETTING, HARNESS_RECIPES_SETTING } from "../harness-table.js";
|
|
25
25
|
import { GATEWAY_IDS_ENV } from "../model-gateway.js";
|
|
26
26
|
import { BOX_CPUS_ENV, BOX_MEMORY_ENV, BOX_PIDS_ENV, MCP_ALLOW_LOOPBACK_ENV } from "../start-switches.js";
|
|
27
27
|
import { DOCKER_IMAGE_ENV } from "../box-image.js";
|
|
28
|
+
import { RunnerLiveRefused, runnerLiveOf } from "../live-reach.js";
|
|
28
29
|
import { bootSealKey } from "../seal-key.js";
|
|
29
30
|
import { SECRET_NAMES } from "../secrets.js";
|
|
30
31
|
import { SEAL_KEY_ENV } from "../tool-keys.js";
|
|
32
|
+
import { LAUNCH_HOOK_SECRET_ENV } from "../trigger-launch-hook.js";
|
|
31
33
|
/** The store.settings key a server keeps the names of its run-facing environment under at each start: `{ v: 1, names }`. */
|
|
32
34
|
export const RUN_ENV_KEY = "server.run_env";
|
|
33
35
|
export const STORE_URL_ENV = "AGENTRUN_STORE_URL";
|
|
34
36
|
/** The most connections a Postgres store holds at once; its start refuses a value that is no size (store/open.ts). */
|
|
35
37
|
const POOL_SIZE_ENV = "AGENTRUN_STORE_POOL_SIZE";
|
|
36
38
|
/** The server's own secrets: never a runner's (runner/main.ts RUNNER_ONLY keeps them from its runs, too). */
|
|
37
|
-
const SERVER_ONLY = ["AGENTRUN_TOKEN", "AGENTRUN_TOKENS", "AGENTRUN_API_KEY"];
|
|
39
|
+
const SERVER_ONLY = ["AGENTRUN_TOKEN", "AGENTRUN_TOKENS", "AGENTRUN_API_KEY", LAUNCH_HOOK_SECRET_ENV];
|
|
38
40
|
/** Names that are neither the server's run-facing environment nor the runner's: its own store and key (checked on their
|
|
39
41
|
* own), the server's secrets, and a client's address of the server. */
|
|
40
42
|
const NOT_RUN_FACING = new Set([...SERVER_ONLY, STORE_URL_ENV, SEAL_KEY_ENV, "AGENTRUN_BASE_URL"]);
|
|
@@ -61,6 +63,8 @@ const FIXED = new Set([
|
|
|
61
63
|
// The harness modules a server loads (harness-table.ts): a runner without them claims their runs and has no harness to
|
|
62
64
|
// run them on.
|
|
63
65
|
HARNESS_MODULES_SETTING,
|
|
66
|
+
// And the harness recipes it runs (harness-table.ts), for the same reason.
|
|
67
|
+
HARNESS_RECIPES_SETTING,
|
|
64
68
|
// A Docker computer's image and size (box-image.ts, workspace/computer-deps.ts dockerLimitsOf): read where the run's
|
|
65
69
|
// computer starts, the runner.
|
|
66
70
|
DOCKER_IMAGE_ENV,
|
|
@@ -194,8 +198,30 @@ export async function checkRunnerEnv(options) {
|
|
|
194
198
|
for (const name of SERVER_ONLY)
|
|
195
199
|
if (read(name)?.trim())
|
|
196
200
|
rows.push({ state: "warn", name, why: "the server's own secret: a runner never needs it, so leave it off the runner" });
|
|
201
|
+
const liveRow = liveHostRow(env, options.interfaces);
|
|
202
|
+
if (liveRow)
|
|
203
|
+
rows.push(liveRow);
|
|
197
204
|
return rows;
|
|
198
205
|
}
|
|
206
|
+
/** AGENTRUN_RUNNER_LIVE_HOST's row, where it is set: the host the server reaches this runner at (an address, never a
|
|
207
|
+
* secret); warn where it names no host; bad where an IPv4 block holds none or several of this machine's addresses (live-reach.ts runnerLiveOf). */
|
|
208
|
+
function liveHostRow(env, interfaces) {
|
|
209
|
+
const name = "AGENTRUN_RUNNER_LIVE_HOST";
|
|
210
|
+
if (!env[name]?.trim())
|
|
211
|
+
return undefined;
|
|
212
|
+
try {
|
|
213
|
+
// The key is not read here: the host alone is.
|
|
214
|
+
const live = runnerLiveOf(env, Buffer.alloc(32), interfaces);
|
|
215
|
+
return live
|
|
216
|
+
? { state: "ok", name, why: `the server reaches this runner's relay and viewers at ${live.host}` }
|
|
217
|
+
: { state: "warn", name, why: "not a host name, an IPv4 address or an IPv4 block other than loopback: this runner's relay and viewers stay on loopback, where a server on another host cannot reach them" };
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
if (error instanceof RunnerLiveRefused)
|
|
221
|
+
return { state: "bad", name, why: error.message };
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
199
225
|
/** The check's lines: one per row (its state, its name, why), then the outcome. */
|
|
200
226
|
export function checkLines(rows) {
|
|
201
227
|
const width = Math.max(0, ...rows.map((row) => row.name.length));
|
package/dist/runner/runner.js
CHANGED
|
@@ -18,11 +18,12 @@ import { HAND_BACK } from "./hand-back.js";
|
|
|
18
18
|
import { KINDS, withdrawnAnswers } from "./journal-kinds.js";
|
|
19
19
|
import { journalEntries } from "./journal-reader.js";
|
|
20
20
|
import { ClaimRefused, stopEnd } from "./loop-contract.js";
|
|
21
|
+
import { FrameTooLarge } from "./run-channel.js";
|
|
21
22
|
import { isFenced } from "./store-port.js";
|
|
22
23
|
import { FINAL_STATES } from "../store/store.js";
|
|
23
24
|
import { Unanswered } from "../store/postgres/connection.js";
|
|
24
25
|
import { clearWaitEnded } from "../browser-wait-ended.js";
|
|
25
|
-
import { heldRedactor, processSecretRedactor } from "./redact.js";
|
|
26
|
+
import { cutDeep, heldRedactor, processSecretRedactor } from "./redact.js";
|
|
26
27
|
import { withLiveTicker } from "./live-ticker.js";
|
|
27
28
|
import { keepPresence } from "./presence.js";
|
|
28
29
|
/** Tries of the re-read after a claim or release commit was answered Unanswered (the commit may have landed). */
|
|
@@ -49,6 +50,9 @@ export const RUNNER_RENEW_EVERY_MS = 10_000;
|
|
|
49
50
|
export const runnerName = () => `${hostname()}:${process.pid}:${randomUUID().slice(0, 8)}`;
|
|
50
51
|
/** A failed end's code when the claim was refused for good before any loop started (loop-contract's ClaimRefused). */
|
|
51
52
|
const CLAIM_REFUSED = "claim-refused";
|
|
53
|
+
/** A failed end's code when the run's records no longer cross the channel to its process (run-channel's FrameTooLarge):
|
|
54
|
+
* every try reads the same records, so none can go on. */
|
|
55
|
+
const TOO_LARGE = "frame-too-large";
|
|
52
56
|
/** The untaken row a run ends on when no loop can: a cancel before a stop (it ends the run for good, in its words). */
|
|
53
57
|
const endingRow = (untaken) => untaken.find((row) => row.kind === "cancel") ?? untaken.find((row) => row.kind === "stop");
|
|
54
58
|
/** A commit by a loop whose claim this runner gave up: refused before it reaches the store. */
|
|
@@ -166,10 +170,16 @@ export function startRunner(options) {
|
|
|
166
170
|
* then the run is ending, before the loop's teardown, so a renew answered Fenced by that end's epoch is never a lost
|
|
167
171
|
* claim. The patch lands exactly when the batch that writes its effect (the record it is staged with) is stored
|
|
168
172
|
* (RunStorage.commit): a group commit stores its batches in order up to the first it refuses, so the end's batch can
|
|
169
|
-
* land while a later sibling is refused, and an end whose own batch is refused has not landed.
|
|
173
|
+
* land while a later sibling is refused, and an end whose own batch is refused has not landed. What it writes and
|
|
174
|
+
* stages is cut of the run's own tool keys (redact.ts carry), its names too: they are erased at its turn's end, so no
|
|
175
|
+
* read could. */
|
|
170
176
|
const fenced = (journal, fence, runId, ended) => {
|
|
171
177
|
/** The effect of the final patch staged and not yet landed, as the store keeps it until a commit stores it. */
|
|
172
178
|
let finalEffect;
|
|
179
|
+
const carriedOut = (given) => {
|
|
180
|
+
const carried = redact.carried(runId);
|
|
181
|
+
return carried ? cutDeep(given, carried, true) : given;
|
|
182
|
+
};
|
|
173
183
|
return new Proxy(journal, {
|
|
174
184
|
get(target, property) {
|
|
175
185
|
const value = Reflect.get(target, property, target);
|
|
@@ -177,7 +187,7 @@ export function startRunner(options) {
|
|
|
177
187
|
return value;
|
|
178
188
|
if (property === "stage") {
|
|
179
189
|
return (staged, ...rest) => {
|
|
180
|
-
const result = value.call(target, staged, ...rest);
|
|
190
|
+
const result = value.call(target, carriedOut(staged), ...rest);
|
|
181
191
|
// As the store keeps it: a run patch or rows staged again replace the one staged before.
|
|
182
192
|
if (staged?.run !== undefined || staged?.also !== undefined)
|
|
183
193
|
finalEffect = FINAL.has(staged.run?.state ?? "") ? Number(staged.effect) : undefined;
|
|
@@ -194,7 +204,7 @@ export function startRunner(options) {
|
|
|
194
204
|
const effect = finalEffect;
|
|
195
205
|
const batches = (Array.isArray(args[0]) ? args[0] : [args[0]]);
|
|
196
206
|
const at = effect === undefined ? -1 : batches.findIndex((batch) => (Array.isArray(batch) ? batch : [batch]).some((write) => Number(write?.value?.id) === effect));
|
|
197
|
-
return value.apply(target, args).then((result) => {
|
|
207
|
+
return value.apply(target, [carriedOut(args[0]), ...args.slice(1)]).then((result) => {
|
|
198
208
|
if (at >= 0 && at < (result?.stored ?? 0) && finalEffect === effect) {
|
|
199
209
|
finalEffect = undefined;
|
|
200
210
|
ended();
|
|
@@ -576,8 +586,10 @@ export function startRunner(options) {
|
|
|
576
586
|
// with why, and a person can raise again or stop it (#1944-5). A claim its spec refuses (ClaimRefused: a handed
|
|
577
587
|
// sign-in that won't read back, an MCP pin refused) never comes here: the loop writes that end itself, final, the run
|
|
578
588
|
// failed in the refusal's words.
|
|
579
|
-
// A claim refused for good (CLAIM_REFUSED)
|
|
580
|
-
|
|
589
|
+
// A claim refused for good (CLAIM_REFUSED), or a run whose records no longer cross to its process (TOO_LARGE), is no
|
|
590
|
+
// resume to try again: it fails the run below, parked or not, and the row that woke it (an approval already answered
|
|
591
|
+
// 204) is refused as a failed run's, never left to wait.
|
|
592
|
+
if (threw && end.state === "failed" && claim.from === "parked" && end.error.code !== CLAIM_REFUSED && end.error.code !== TOO_LARGE)
|
|
581
593
|
return await resumeFailed(held, end.error.message);
|
|
582
594
|
if (threw && end.state === "failed") {
|
|
583
595
|
// A loop that failed with no end written: a person's stop waiting now is the run's end (stopped, its row taken),
|
|
@@ -634,9 +646,12 @@ export function startRunner(options) {
|
|
|
634
646
|
emit({ type: "error", runId: claim.runId, step: isFenced(error) ? "release (fenced)" : "release", message: message(error) });
|
|
635
647
|
}
|
|
636
648
|
finally {
|
|
637
|
-
// Only its own entry: a run this runner lost and claimed again holds a new one under the same id.
|
|
638
|
-
|
|
649
|
+
// Only its own entry: a run this runner lost and claimed again holds a new one under the same id. Its own keys go
|
|
650
|
+
// with it: a next claim opens them again.
|
|
651
|
+
if (runs.get(claim.runId) === held) {
|
|
639
652
|
runs.delete(claim.runId);
|
|
653
|
+
redact.dropCarried(claim.runId);
|
|
654
|
+
}
|
|
640
655
|
}
|
|
641
656
|
};
|
|
642
657
|
/** A parked run's resume that threw: one more try on the row that woke it, released parked with a backoff; after
|
|
@@ -718,7 +733,9 @@ export function startRunner(options) {
|
|
|
718
733
|
threw = true;
|
|
719
734
|
// A claim refused before any loop could start (the dispatch's ClaimRefused: a harness this host never holds) is
|
|
720
735
|
// for good: the run fails in its words, whatever woke it.
|
|
721
|
-
end =
|
|
736
|
+
end = error instanceof FrameTooLarge
|
|
737
|
+
? { state: "failed", error: { code: TOO_LARGE, message: `the run's records no longer fit the channel to its process (${error.message}), so it cannot go on` } }
|
|
738
|
+
: { state: "failed", error: { code: error instanceof ClaimRefused ? CLAIM_REFUSED : "loop-threw", message: message(error) } };
|
|
722
739
|
}
|
|
723
740
|
await finish(held, end, threw);
|
|
724
741
|
})();
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// flight (mcp_oauth_pending); each trigger source's settings, a webhook trigger's signing secret and the GitHub App's key
|
|
8
8
|
// and webhook secret among them, the outbound webhook's signing secret and Slack's incoming-webhook URL (whole and its
|
|
9
9
|
// token alone, slack-url.ts), each it held before too (trigger_settings), but a field its source marks public; browser sign-in pointers, live and forgotten; live viewer tokens; a launch's sealed
|
|
10
|
-
// part (a run's handed MCP credentials and its own
|
|
10
|
+
// part (a run's handed MCP credentials, its own model key and its own tool keys). Beside the store, what the data directory keeps where the runner shares it (server-secrets.ts besideTheStore: the
|
|
11
11
|
// owner's API token and the sign-in session secret). Each value in every spelling the server's list has
|
|
12
12
|
// (standard-webhooks.ts secretForms), a PEM key whole and line by line. A value that does not open under the runner's key
|
|
13
13
|
// is left out: the store never holds one in the clear, and nothing of this runner can be handed it.
|
|
@@ -59,8 +59,8 @@ function jsonSecrets(text) {
|
|
|
59
59
|
}
|
|
60
60
|
/** A launch's sealed JSON: its own listed values (jsonSecrets), each handed MCP credential's headers (store/seal.ts
|
|
61
61
|
* sealRunLaunch: `{"mcp": {"<server>": {"headers": {...}}}}`), as a saved server's are listed, each per-run Composio
|
|
62
|
-
* binding's user and account (`{"mcp": {"<server>": {"composio": {"user_id", "connected_account_id"}}}}`),
|
|
63
|
-
* own model key (`{"model": {"key": "..."}}`). */
|
|
62
|
+
* binding's user and account (`{"mcp": {"<server>": {"composio": {"user_id", "connected_account_id"}}}}`), the run's
|
|
63
|
+
* own model key (`{"model": {"key": "..."}}`) and each of its own tool keys (`{"keys": {"<NAME>": "..."}}`). */
|
|
64
64
|
function launchSecrets(text) {
|
|
65
65
|
const out = jsonSecrets(text);
|
|
66
66
|
let opened;
|
|
@@ -82,6 +82,10 @@ function launchSecrets(text) {
|
|
|
82
82
|
}
|
|
83
83
|
if (typeof opened?.model?.key === "string")
|
|
84
84
|
out.push(opened.model.key);
|
|
85
|
+
if (opened?.keys && typeof opened.keys === "object")
|
|
86
|
+
for (const value of Object.values(opened.keys))
|
|
87
|
+
if (typeof value === "string")
|
|
88
|
+
out.push(value);
|
|
85
89
|
return out;
|
|
86
90
|
}
|
|
87
91
|
/** The ChatGPT sign-in's sealed row (chatgpt-plan.ts): its access and refresh tokens, each alone, as a renewal in any
|
|
@@ -135,6 +135,10 @@ declare function inputSchemaOf(text: string, resolve: (doc: {
|
|
|
135
135
|
}, schema: Record<string, unknown>) => Record<string, unknown>): Record<string, unknown> | undefined;
|
|
136
136
|
/** Whether `workflow` takes `input` as it is: a schema with a required field, which the input passes at its top level. */
|
|
137
137
|
export declare function fits(workflow: LearnedWorkflow, input: unknown, resolve: Parameters<typeof inputSchemaOf>[1]): boolean;
|
|
138
|
+
/** Whether a connected agent's turn on `task` (the text its start was given) is an input of `workflow`: a JSON object
|
|
139
|
+
* task is the input, so it must fit (fits, the managed rule); a prose task's input is resolved by the client from the
|
|
140
|
+
* turn's recorded tool inputs or the host's resolveCheckInput, so any workflow may take it. */
|
|
141
|
+
export declare function sdkTakes(workflow: LearnedWorkflow, task: string, resolve: Parameters<typeof inputSchemaOf>[1]): boolean;
|
|
138
142
|
/** A learned workflow's digest: the first 16 hex of its text's sha256. A new revision of it is a new digest. */
|
|
139
143
|
export declare const workflowDigest: (workflow: Pick<LearnedWorkflow, "workflow">) => string;
|
|
140
144
|
/** The workflow a run serves first (`serve`), or the one the money rule stopped (`revise`), or neither: the run is
|
|
@@ -123,6 +123,19 @@ export function fits(workflow, input, resolve) {
|
|
|
123
123
|
const required = Array.isArray(schema?.required) ? schema.required.filter((key) => typeof key === "string") : [];
|
|
124
124
|
return schema !== undefined && required.length > 0 && inputIssues(input, schema).length === 0;
|
|
125
125
|
}
|
|
126
|
+
/** Whether a connected agent's turn on `task` (the text its start was given) is an input of `workflow`: a JSON object
|
|
127
|
+
* task is the input, so it must fit (fits, the managed rule); a prose task's input is resolved by the client from the
|
|
128
|
+
* turn's recorded tool inputs or the host's resolveCheckInput, so any workflow may take it. */
|
|
129
|
+
export function sdkTakes(workflow, task, resolve) {
|
|
130
|
+
let parsed;
|
|
131
|
+
try {
|
|
132
|
+
parsed = JSON.parse(task);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
return !isObject(parsed) || fits(workflow, parsed, resolve);
|
|
138
|
+
}
|
|
126
139
|
/** A learned workflow's digest: the first 16 hex of its text's sha256. A new revision of it is a new digest. */
|
|
127
140
|
export const workflowDigest = (workflow) => createHash("sha256").update(workflow.workflow).digest("hex").slice(0, 16);
|
|
128
141
|
/** The workflow a run serves first (`serve`), or the one the money rule stopped (`revise`), or neither: the run is
|
|
@@ -5,6 +5,7 @@ import type { Workflow } from "@parcha/agentrun-dsl";
|
|
|
5
5
|
import { type WorkflowTaskHost } from "../workflow/task.js";
|
|
6
6
|
import { type BudgetData, type EndData } from "./journal-kinds.js";
|
|
7
7
|
import { type Claim, type Journal, type LoopFactory } from "./loop-contract.js";
|
|
8
|
+
import { type HeldRedact } from "./redact.js";
|
|
8
9
|
/** A cap refusal, as the kernel cap hands one to parkOf/checkRaise (the loop never imports the cap; its rule is handed in
|
|
9
10
|
* via the spec, so flat or tiered pricing is the cap's, not this loop's). */
|
|
10
11
|
/** `node`: the label of the workflow node whose step the cap held (a model node's request, a call node's call, a
|
|
@@ -129,7 +130,7 @@ export declare const isWorkflowRevision: (revision: {
|
|
|
129
130
|
/** What a claim's spec is built from beside the claim: the runner's one redactor (LoopDeps.redact), which holds the keys
|
|
130
131
|
* the claim opens from the store (redact.ts holdClaimed). */
|
|
131
132
|
export interface WorkflowSpecRun {
|
|
132
|
-
readonly redact?:
|
|
133
|
+
readonly redact?: HeldRedact;
|
|
133
134
|
/** A fresh journal of the claim, for what the spec reads from the run's records at its end (its decisions' booked
|
|
134
135
|
* cost): a fresh one, since the Harness closes its own before the end is written. */
|
|
135
136
|
readonly journal?: () => Journal;
|
|
@@ -23,6 +23,7 @@ import { createWorkflowExtension } from "../workflow/task.js";
|
|
|
23
23
|
import { readWorkflowRun, startWorkflowRevision, workflowCarry } from "../workflow-run.js";
|
|
24
24
|
import { KINDS } from "./journal-kinds.js";
|
|
25
25
|
import { stopEnd } from "./loop-contract.js";
|
|
26
|
+
import { heldRedactor } from "./redact.js";
|
|
26
27
|
import { END_PATCH_MS, END_PATCH_UNKNOWN, readAgain } from "./loop.js";
|
|
27
28
|
/** A paused run's words, its row's summary while it waits for a resume. */
|
|
28
29
|
export const PAUSED_WORDS = "Paused.";
|
|
@@ -217,7 +218,7 @@ function workflowLoop(specOf, deps) {
|
|
|
217
218
|
const parkController = new AbortController();
|
|
218
219
|
let heldRefusal;
|
|
219
220
|
const context = withAbortSignal(AbortSignal.any([deps.signal, parkController.signal]), BACKGROUND_CONTEXT);
|
|
220
|
-
spec = await specOf(claim, { ...(deps.redact ? { redact: deps.redact } : {}), journal: () => deps.journal(claim) });
|
|
221
|
+
spec = await specOf(claim, { ...(deps.redact ? { redact: heldRedactor(deps.redact) } : {}), journal: () => deps.journal(claim) });
|
|
221
222
|
claimNow = claim;
|
|
222
223
|
specReady();
|
|
223
224
|
const revision = { id: spec.revisionId, kind: "workflow", body: { workflow: spec.workflow, tools: [...spec.tools] } };
|
|
@@ -160,7 +160,7 @@ export function workflowSpecOf(deps) {
|
|
|
160
160
|
// models, its decisions, its call nodes' effects and its model nodes' tools all run on these, never on another run's
|
|
161
161
|
// keys or on this process's whole environment.
|
|
162
162
|
// Held by the runner's one redactor before anything can echo one (holding: run.redact), as the decision keys were.
|
|
163
|
-
const claimedEnv = await holding(claimSecrets({ store: deps.store, sealKey: deps.sealKey, ...(deps.env ? { env: deps.env } : {}) }, claimed.revision, { plane: claimed.plane }));
|
|
163
|
+
const claimedEnv = await holding(claimSecrets({ store: deps.store, sealKey: deps.sealKey, ...(deps.env ? { env: deps.env } : {}), redact: run?.redact }, claimed.revision, { plane: claimed.plane }, claim.runId));
|
|
164
164
|
// The run's models resolve the one way the runner resolves any (routeProviderOf over routeOf), unless a test gives its
|
|
165
165
|
// own: each tier's key from the runner's environment, else the one the claim opened (a key saved in
|
|
166
166
|
// Settings → Model keys runs the next run with no restart).
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SourceIOReceipt } from "./source-sync/io.js";
|
|
1
2
|
import type { Revision } from "./agent-rows.js";
|
|
2
3
|
import type { MessageOrigin } from "./timeline/index.js";
|
|
3
4
|
import { type AgentEntry, type ExternalRef } from "./agents-store.js";
|
|
@@ -88,8 +89,6 @@ export declare function raiseCap(store: RunsStore, moment: RunMoment, cap: numbe
|
|
|
88
89
|
* each write or lose to the store's one-answer index, and the one that loses reads the one that won. The note is the
|
|
89
90
|
* person's words, carried on the command for the run's gate. */
|
|
90
91
|
export declare function approve(store: RunsStore, moment: RunMoment, id: string, decision: "allow" | "deny", note?: string, confirmed?: boolean): Promise<void>;
|
|
91
|
-
/** A UUIDv7 run id: time-ordered, so a listing by start time is stable, and unique per run. */
|
|
92
|
-
export declare function uuidv7(now?: number): string;
|
|
93
92
|
/** The revision's body fields a start reads: its default cap, its place, and (agentic) its tools, for the place
|
|
94
93
|
* fallback. Read with the shapes the old start read them with. */
|
|
95
94
|
type StartBody = {
|
|
@@ -124,9 +123,11 @@ export interface StartDeps {
|
|
|
124
123
|
explainRun(issues: InputIssue[], body: Json, revision: Revision | null | undefined): Promise<InputIssue[]>;
|
|
125
124
|
/** Marks an input refusal as told from a revision (server.ts told). */
|
|
126
125
|
told(error: ApiError): ApiError;
|
|
127
|
-
/** Refuses a revision this host cannot run, by field (server.ts runnable)
|
|
126
|
+
/** Refuses a revision this host cannot run, by field (server.ts runnable), each tool key the run carries (`carried`, by
|
|
127
|
+
* name) read as one the host holds. */
|
|
128
128
|
runnable(revision: Revision, place: Place, options: {
|
|
129
129
|
capped: boolean;
|
|
130
|
+
carried?: readonly string[];
|
|
130
131
|
}): Promise<void>;
|
|
131
132
|
/** The revision a run starts on, its MCP tools pinned: one that grants an MCP tool and was saved with no pin (before
|
|
132
133
|
* pins were made at save, or an inline agent's version stored then) is pinned once, at its first run (server.ts
|
|
@@ -148,6 +149,26 @@ export interface StartDeps {
|
|
|
148
149
|
undo(): Promise<void>;
|
|
149
150
|
} | undefined>;
|
|
150
151
|
};
|
|
152
|
+
/** Complete a moved project's placement before admission. Upload placement has already pinned its destination disk.
|
|
153
|
+
* `undo` may remove only this exclusively prepared run and must await outstanding writes. The caller invokes it only
|
|
154
|
+
* after a definite admission refusal; unknown admission keeps the preparation for explicit reconciliation. */
|
|
155
|
+
readonly project?: {
|
|
156
|
+
hold?(input: {
|
|
157
|
+
runId: string;
|
|
158
|
+
agentId: string;
|
|
159
|
+
}): Promise<SourceIOReceipt>;
|
|
160
|
+
place(input: {
|
|
161
|
+
hold?: SourceIOReceipt;
|
|
162
|
+
runId: string;
|
|
163
|
+
agentId: string;
|
|
164
|
+
revision: Pick<NewRevision, "id" | "kind" | "body">;
|
|
165
|
+
launch: RunLaunch;
|
|
166
|
+
}): Promise<{
|
|
167
|
+
readonly launch: RunLaunch;
|
|
168
|
+
undo(): Promise<void>;
|
|
169
|
+
admitted?(): Promise<void>;
|
|
170
|
+
} | undefined>;
|
|
171
|
+
};
|
|
151
172
|
/** Where a revision naming these tools and no place runs here (server.ts fallbackPlace). */
|
|
152
173
|
fallbackPlace(kind: "agentic" | "workflow", tools: readonly unknown[]): Place;
|
|
153
174
|
/** The Archil disk the run's launch record keeps (server.ts launchDiskOf): the one its body's `archil_disk` names, else
|
|
@@ -206,6 +227,8 @@ export interface StartOptions {
|
|
|
206
227
|
readonly origin?: RunOrigin;
|
|
207
228
|
readonly capped?: boolean;
|
|
208
229
|
readonly from?: MessageOrigin;
|
|
230
|
+
/** The names of the tool keys the run carries (`keys`, run-keys.ts; their values go only into `sealed`). */
|
|
231
|
+
readonly keys?: readonly string[];
|
|
209
232
|
}
|
|
210
233
|
/** The run's learning start: undefined when the run does not learn (the server's learning off, a workflow revision, or
|
|
211
234
|
* its revision does not say learning), else the seed sha it starts from, its # Learned text (its owner's corrections,
|
|
@@ -227,7 +250,12 @@ export declare function learningStartFor(deps: StartDeps, entry: AgentEntry, rev
|
|
|
227
250
|
* (store.runs.create), which a runner reads at its claim. No process, no door, no setup file: where the run runs is the
|
|
228
251
|
* runner's. Under `origin`, a key that already started a run gets that run (the store's one-run-per-key), so a retry never
|
|
229
252
|
* starts a second. */
|
|
230
|
-
export declare function startRun(store:
|
|
253
|
+
export declare function startRun(store: Store, deps: StartDeps, entry: AgentEntry, body: Json, { trigger, origin, capped, from, title, sealed, keys }?: StartOptions): Promise<RunRow>;
|
|
254
|
+
/** Writes run `runId` of agent `agentId` with `write`, its files (launch.files) held for it first (StartDeps.files): a
|
|
255
|
+
* hold that fails part way, a write that fails, or one that answers another run (an origin key's run started before),
|
|
256
|
+
* lets go of the hold. In Mode 2 they are placed in the run's folder instead (StartDeps.files.place), and the run is
|
|
257
|
+
* written with the launch that says so; the same failures undo the placing. */
|
|
258
|
+
export declare function withHeldFiles(store: Pick<Store, "runs">, deps: Pick<StartDeps, "files" | "project">, runId: string, agentId: string, revision: Pick<NewRevision, "id" | "kind" | "body">, launch: RunLaunch, write: (launch: RunLaunch) => Promise<RunRow>): Promise<RunRow>;
|
|
231
259
|
/** An agent given inline (POST /runs): its reference in its source with the version, its name and description, and the
|
|
232
260
|
* revision its checked definition makes (agents-store makeRevision), not yet stored. */
|
|
233
261
|
export interface InlineAgent {
|
|
@@ -249,14 +277,14 @@ export interface InlineAgent {
|
|
|
249
277
|
* agent already mapped to the reference is the run's (its id, its learning), so a run of a later version learns from the
|
|
250
278
|
* earlier ones. A different definition under a version already run is 409 external_body_conflict, nothing written; under
|
|
251
279
|
* `origin`, a key that already started a run gets that run, as startRun's. */
|
|
252
|
-
export declare function startInline(store: Pick<Store, "runs" | "runOfOrigin" | "agents">, deps: StartDeps, inline: InlineAgent, body: Json, options?: Pick<StartOptions, "origin" | "sealed">): Promise<RunRow>;
|
|
280
|
+
export declare function startInline(store: Pick<Store, "runs" | "runOfOrigin" | "agents">, deps: StartDeps, inline: InlineAgent, body: Json, options?: Pick<StartOptions, "origin" | "sealed" | "keys">): Promise<RunRow>;
|
|
253
281
|
/** A run's launch from its create body, with every check the old start made before a run started, in the same order and
|
|
254
282
|
* words: the body's fields, the revision it pins, the input against its schema, the cap rules, the plane this host
|
|
255
283
|
* resolves, whether the revision can run here; then its title, plane, model and learning start. Nothing is written: the
|
|
256
284
|
* caller INSERTs the run with it (startRun; an inline agent's run, which writes its agent and revision in the same
|
|
257
285
|
* transaction). `revision`: the revision the run starts on, given (an inline agent's, not yet stored), in place of the
|
|
258
286
|
* one the body pins or the agent's current (deps.pinnedOf). */
|
|
259
|
-
export declare function prepareLaunch(deps: StartDeps, entry: AgentEntry, body: Json, { trigger, capped, from, title: given, revision: onRevision }?: Omit<StartOptions, "origin"> & {
|
|
287
|
+
export declare function prepareLaunch(deps: StartDeps, entry: AgentEntry, body: Json, { trigger, capped, from, title: given, revision: onRevision, keys }?: Omit<StartOptions, "origin"> & {
|
|
260
288
|
readonly revision?: Revision;
|
|
261
289
|
}): Promise<{
|
|
262
290
|
launch: RunLaunch;
|