@parcha/agentrun-serve 0.1.0-beta.33 → 0.1.0-beta.34
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 +233 -0
- package/README.md +266 -201
- package/dist/adapters.d.ts +0 -4
- package/dist/adapters.js +11 -15
- package/dist/agent-rows.d.ts +98 -0
- package/dist/agent-rows.js +1 -0
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +60 -25
- package/dist/agents.d.ts +9 -125
- package/dist/agents.js +15 -305
- package/dist/answer-json.d.ts +23 -0
- package/dist/answer-json.js +58 -0
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/bash-read-only.d.ts +22 -0
- package/dist/bash-read-only.js +701 -0
- package/dist/box-settings.d.ts +3 -23
- package/dist/box-settings.js +7 -51
- package/dist/boxes.d.ts +17 -0
- package/dist/boxes.js +27 -20
- package/dist/browser-commands.d.ts +5 -2
- package/dist/browser-commands.js +4 -4
- package/dist/browser-computer.d.ts +5 -0
- package/dist/browser-computer.js +21 -0
- package/dist/browser-cost.d.ts +9 -6
- package/dist/browser-cost.js +92 -50
- package/dist/browser-live.d.ts +7 -20
- package/dist/browser-live.js +15 -93
- package/dist/browser-person.d.ts +18 -51
- package/dist/browser-person.js +94 -277
- package/dist/cap.d.ts +8 -5
- package/dist/cap.js +12 -5
- package/dist/cli.js +39 -13
- package/dist/closed-pipes.d.ts +2 -0
- package/dist/closed-pipes.js +13 -0
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +2 -0
- package/dist/computer-keys.js +5 -2
- package/dist/computer-setting.d.ts +20 -4
- package/dist/computer-setting.js +25 -5
- package/dist/computers.d.ts +30 -2
- package/dist/computers.js +70 -11
- package/dist/confine.d.ts +120 -0
- package/dist/confine.js +436 -0
- package/dist/console/assets/index-RPHGlXmM.js +540 -0
- package/dist/console/assets/index-opTN5Naq.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/decision-rows.d.ts +1 -1
- package/dist/decision-rows.js +1 -1
- package/dist/docker-daemon.d.ts +31 -0
- package/dist/docker-daemon.js +56 -0
- package/dist/effort-guidance.js +4 -3
- package/dist/environment.d.ts +0 -3
- package/dist/environment.js +3 -5
- package/dist/errors.d.ts +0 -2
- package/dist/errors.js +6 -9
- package/dist/filed-answer.d.ts +32 -0
- package/dist/filed-answer.js +160 -0
- package/dist/files.d.ts +1 -3
- package/dist/files.js +2 -4
- package/dist/github-connection.d.ts +1 -1
- package/dist/graph-view.d.ts +3 -5
- package/dist/graph-view.js +4 -14
- package/dist/handed-values.d.ts +9 -0
- package/dist/handed-values.js +26 -0
- package/dist/harness-install.d.ts +1 -7
- package/dist/harness-install.js +1 -18
- package/dist/harness-opencode/adapter.d.ts +7 -0
- package/dist/harness-opencode/adapter.js +23 -6
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/verify.d.ts +17 -0
- package/dist/harness-opencode/verify.js +30 -10
- package/dist/harness-table.js +6 -1
- package/dist/heard.js +1 -1
- package/dist/held-fd.d.ts +5 -0
- package/dist/held-fd.js +14 -0
- package/dist/host-calls.d.ts +20 -0
- package/dist/host-calls.js +12 -0
- package/dist/host-tools.d.ts +4 -21
- package/dist/host-tools.js +4 -61
- package/dist/host.d.ts +2 -4
- package/dist/host.js +2 -7
- package/dist/import-summary.d.ts +1 -5
- package/dist/import-summary.js +0 -21
- package/dist/import.d.ts +6 -6
- package/dist/import.js +14 -15
- package/dist/key-refusal.d.ts +5 -1
- package/dist/key-refusal.js +19 -4
- package/dist/learn/check.d.ts +6 -2
- package/dist/learn/check.js +83 -29
- package/dist/learn/folder.d.ts +5 -1
- package/dist/learn/folder.js +10 -3
- package/dist/learn/grade.d.ts +14 -0
- package/dist/learn/grade.js +68 -12
- package/dist/learn/index.d.ts +4 -4
- package/dist/learn/index.js +4 -4
- package/dist/learn/reflect.d.ts +31 -2
- package/dist/learn/reflect.js +79 -4
- package/dist/learn/relevance.d.ts +24 -0
- package/dist/learn/relevance.js +91 -0
- package/dist/learn/secrets.d.ts +7 -1
- package/dist/learn/secrets.js +86 -19
- package/dist/learn/skills.d.ts +112 -14
- package/dist/learn/skills.js +556 -52
- package/dist/learned-workflow.d.ts +32 -1
- package/dist/learned-workflow.js +100 -9
- package/dist/learning-routes.d.ts +8 -4
- package/dist/learning-routes.js +23 -9
- package/dist/learning-run.d.ts +9 -26
- package/dist/learning-run.js +22 -32
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +18 -9
- package/dist/learning.d.ts +93 -77
- package/dist/learning.js +176 -304
- package/dist/live/stream.js +1 -1
- package/dist/live/translate.js +12 -2
- package/dist/local-models.d.ts +11 -5
- package/dist/local-models.js +13 -8
- package/dist/mcp-gateway.d.ts +11 -49
- package/dist/mcp-gateway.js +44 -135
- package/dist/mcp-oauth.d.ts +10 -14
- package/dist/mcp-oauth.js +14 -32
- package/dist/mcp-probe.d.ts +0 -7
- package/dist/mcp-probe.js +4 -10
- package/dist/mcp-servers-store.d.ts +6 -6
- package/dist/mcp-servers-store.js +12 -14
- package/dist/mcp-store.js +3 -4
- package/dist/mcp.js +4 -3
- package/dist/model.d.ts +6 -7
- package/dist/model.js +43 -27
- package/dist/monid.d.ts +0 -2
- package/dist/monid.js +3 -6
- package/dist/openapi.d.ts +8 -1
- package/dist/openapi.js +121 -47
- package/dist/page.d.ts +1 -3
- package/dist/page.js +6 -18
- package/dist/paid-calls.d.ts +21 -27
- package/dist/paid-calls.js +25 -60
- package/dist/propose.js +83 -39
- package/dist/push-handler.d.ts +1 -1
- package/dist/reflect-range.d.ts +25 -0
- package/dist/reflect-range.js +30 -0
- package/dist/refusal-words.d.ts +5 -1
- package/dist/refusal-words.js +5 -1
- package/dist/rows.d.ts +1 -1
- package/dist/run-cut.d.ts +0 -6
- package/dist/run-cut.js +0 -6
- package/dist/run-db.d.ts +2 -11
- package/dist/run-db.js +2 -37
- package/dist/run-launch.d.ts +19 -2
- package/dist/run-launch.js +13 -5
- package/dist/run-learning-served.d.ts +10 -4
- package/dist/run-learning-served.js +23 -13
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-reads-over-store.js +15 -6
- package/dist/run-secrets.d.ts +1 -1
- package/dist/run-timeline-served.d.ts +5 -1
- package/dist/run-timeline-served.js +15 -4
- package/dist/run-view.d.ts +7 -8
- package/dist/run-view.js +26 -7
- package/dist/runnable.d.ts +18 -10
- package/dist/runnable.js +21 -10
- package/dist/runner/adapter-loop.d.ts +6 -1
- package/dist/runner/adapter-loop.js +423 -53
- package/dist/runner/adapter-run-spec.d.ts +21 -8
- package/dist/runner/adapter-run-spec.js +90 -32
- package/dist/runner/adapters/index.js +11 -1
- package/dist/runner/adapters/pi.d.ts +12 -2
- package/dist/runner/adapters/pi.js +16 -5
- package/dist/runner/beside.d.ts +30 -3
- package/dist/runner/beside.js +36 -5
- package/dist/runner/claim-secrets.d.ts +10 -1
- package/dist/runner/claim-secrets.js +48 -14
- package/dist/runner/cli-run-spec.d.ts +2 -0
- package/dist/runner/cli-run-spec.js +45 -16
- package/dist/runner/commands.js +1 -1
- package/dist/runner/computer-journal.d.ts +15 -2
- package/dist/runner/computer-journal.js +41 -5
- package/dist/runner/conformance/harness.js +118 -8
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/dispatch.d.ts +8 -1
- package/dist/runner/dispatch.js +81 -7
- package/dist/runner/end-of-run.d.ts +8 -2
- package/dist/runner/end-of-run.js +10 -4
- package/dist/runner/github-app.js +1 -1
- package/dist/runner/harness-loops.d.ts +9 -1
- package/dist/runner/harness-loops.js +15 -2
- package/dist/runner/journal-kinds.d.ts +24 -6
- package/dist/runner/journal-kinds.js +20 -5
- package/dist/runner/journal-reader.d.ts +1 -1
- package/dist/runner/journal-reader.js +2 -2
- package/dist/runner/learning-ask.d.ts +4 -0
- package/dist/runner/learning-ask.js +15 -1
- package/dist/runner/learning-end.d.ts +18 -3
- package/dist/runner/learning-end.js +113 -11
- package/dist/runner/learning-loop.d.ts +5 -0
- package/dist/runner/learning-loop.js +26 -6
- package/dist/runner/main.d.ts +56 -9
- package/dist/runner/main.js +127 -18
- package/dist/runner/mcp-claim.js +1 -2
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +15 -5
- package/dist/runner/memory-claim.d.ts +9 -0
- package/dist/runner/memory-claim.js +25 -0
- package/dist/runner/metrics.d.ts +33 -1
- package/dist/runner/metrics.js +85 -1
- package/dist/runner/model-route.d.ts +13 -0
- package/dist/runner/model-route.js +133 -9
- package/dist/runner/reflect-hook.d.ts +12 -1
- package/dist/runner/reflect-hook.js +33 -3
- package/dist/runner/runner.d.ts +20 -0
- package/dist/runner/runner.js +56 -10
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +3 -3
- package/dist/runner/store-secrets.js +8 -12
- package/dist/runner/text-tools.d.ts +44 -0
- package/dist/runner/text-tools.js +237 -0
- package/dist/runner/workflow-loop.d.ts +6 -0
- package/dist/runner/workflow-loop.js +6 -4
- package/dist/runner/workflow-spec.d.ts +18 -0
- package/dist/runner/workflow-spec.js +63 -17
- package/dist/runs-over-store.d.ts +7 -2
- package/dist/runs-over-store.js +60 -14
- package/dist/seal-key.js +5 -43
- package/dist/sealed-settings-store.d.ts +19 -4
- package/dist/sealed-settings-store.js +9 -9
- package/dist/sealing.d.ts +4 -0
- package/dist/sealing.js +20 -0
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-name.d.ts +9 -0
- package/dist/secret-name.js +15 -0
- package/dist/secret-writes.d.ts +0 -1
- package/dist/secret-writes.js +0 -1
- package/dist/server-fs.d.ts +4 -0
- package/dist/server-fs.js +8 -2
- package/dist/server-lock.d.ts +0 -24
- package/dist/server-lock.js +1 -80
- package/dist/server-secrets-store.d.ts +4 -4
- package/dist/server-secrets-store.js +9 -31
- package/dist/server-secrets.d.ts +4 -9
- package/dist/server-secrets.js +12 -36
- package/dist/server.d.ts +16 -38
- package/dist/server.js +145 -106
- package/dist/sign-ins-store.d.ts +34 -36
- package/dist/sign-ins-store.js +27 -38
- package/dist/sign-ins.d.ts +2 -119
- package/dist/sign-ins.js +5 -311
- package/dist/standard-webhooks.d.ts +1 -1
- package/dist/standard-webhooks.js +1 -1
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.d.ts +8 -2
- package/dist/store/agent-body.js +16 -4
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +2 -2
- package/dist/store/open.d.ts +6 -3
- package/dist/store/open.js +2 -2
- package/dist/store/postgres/connection.d.ts +18 -2
- package/dist/store/postgres/connection.js +156 -32
- package/dist/store/postgres/migrate.d.ts +4 -0
- package/dist/store/postgres/migrate.js +9 -2
- package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
- package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
- package/dist/store/postgres/store.d.ts +9 -2
- package/dist/store/postgres/store.js +9 -0
- package/dist/store/schema.js +1 -1
- package/dist/store/seal.js +2 -2
- package/dist/store/sqlite/connection.js +49 -5
- package/dist/store/sqlite/run-patch.d.ts +3 -0
- package/dist/store/sqlite/run-patch.js +3 -0
- package/dist/store/sqlite/store.js +41 -12
- package/dist/store/store.d.ts +35 -6
- package/dist/store/store.js +12 -2
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +22 -4
- package/dist/store-reads/journal.d.ts +9 -6
- package/dist/store-reads/journal.js +93 -17
- package/dist/store-reads/learning.d.ts +26 -8
- package/dist/store-reads/learning.js +12 -4
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-reads/workflow.js +1 -1
- package/dist/store-view.d.ts +5 -1
- package/dist/store-view.js +53 -18
- package/dist/template-eval.d.ts +60 -4
- package/dist/template-eval.js +120 -54
- package/dist/templates.d.ts +24 -10
- package/dist/templates.js +69 -38
- package/dist/timeline/group.d.ts +33 -0
- package/dist/timeline/group.js +77 -0
- package/dist/timeline/index.d.ts +7 -0
- package/dist/timeline/index.js +7 -0
- package/dist/timeline/labels.d.ts +79 -0
- package/dist/timeline/labels.js +150 -0
- package/dist/timeline/origin.d.ts +56 -0
- package/dist/timeline/origin.js +92 -0
- package/dist/timeline/render-text.d.ts +11 -0
- package/dist/timeline/render-text.js +62 -0
- package/dist/timeline/timeline.d.ts +274 -0
- package/dist/timeline/timeline.js +1308 -0
- package/dist/timeline/util.d.ts +17 -0
- package/dist/timeline/util.js +49 -0
- package/dist/tool-gate.d.ts +41 -216
- package/dist/tool-gate.js +79 -540
- package/dist/tool-keys-store.d.ts +11 -12
- package/dist/tool-keys-store.js +24 -31
- package/dist/tool-keys.d.ts +5 -101
- package/dist/tool-keys.js +8 -267
- package/dist/tool-plane.d.ts +14 -42
- package/dist/tool-plane.js +23 -81
- package/dist/tool-settings-store.d.ts +1 -2
- package/dist/tool-settings-store.js +5 -8
- package/dist/tools.d.ts +30 -18
- package/dist/tools.js +97 -107
- package/dist/trigger-adapter.d.ts +2 -2
- package/dist/trigger-targets.d.ts +13 -1
- package/dist/trigger-targets.js +31 -1
- package/dist/triggers.d.ts +2 -2
- package/dist/triggers.js +3 -3
- package/dist/turn-end.d.ts +1 -1
- package/dist/turn-end.js +1 -1
- package/dist/turns.d.ts +0 -6
- package/dist/turns.js +0 -19
- package/dist/uploads.js +1 -1
- package/dist/usage.d.ts +0 -2
- package/dist/usage.js +0 -2
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +23 -14
- package/dist/webhooks.d.ts +102 -76
- package/dist/webhooks.js +266 -233
- package/dist/workflow-run.d.ts +114 -0
- package/dist/workflow-run.js +144 -0
- package/dist/workspace/beneath.d.ts +19 -0
- package/dist/workspace/beneath.js +106 -0
- package/dist/workspace/computer-deps.d.ts +24 -6
- package/dist/workspace/computer-deps.js +108 -20
- package/dist/workspace/computer-for-claim.d.ts +12 -11
- package/dist/workspace/computer-for-claim.js +76 -15
- package/dist/workspace/computer-hold.d.ts +6 -1
- package/dist/workspace/computer-hold.js +6 -1
- package/dist/workspace/computer-janitor.d.ts +47 -0
- package/dist/workspace/computer-janitor.js +182 -0
- package/dist/workspace/grep-worker.d.ts +5 -0
- package/dist/workspace/grep-worker.js +9 -6
- package/dist/workspace/index.d.ts +3 -2
- package/dist/workspace/index.js +3 -3
- package/dist/workspace/local.d.ts +11 -2
- package/dist/workspace/local.js +161 -43
- package/dist/workspace/resolve-computer.d.ts +50 -10
- package/dist/workspace/resolve-computer.js +46 -11
- package/dist/workspace/run-tools.d.ts +13 -31
- package/dist/workspace/run-tools.js +10 -27
- package/dist/workspace-paths.d.ts +0 -17
- package/dist/workspace-paths.js +1 -41
- package/dist/workspace.d.ts +0 -14
- package/dist/workspace.js +3 -96
- package/package.json +13 -13
- package/templates/README.md +9 -3
- package/templates/market-monitor/agent.md +2 -2
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/dist/bound-files.d.ts +0 -4
- package/dist/bound-files.js +0 -164
- package/dist/coding-tools.d.ts +0 -47
- package/dist/coding-tools.js +0 -189
- package/dist/computer-adb.d.ts +0 -12
- package/dist/computer-adb.js +0 -14
- package/dist/console/assets/index-Dn0ngwG9.js +0 -535
- package/dist/console/assets/index-DvW6Aled.css +0 -1
- package/dist/grade.d.ts +0 -63
- package/dist/grade.js +0 -150
- package/dist/mcp-servers.d.ts +0 -269
- package/dist/mcp-servers.js +0 -456
- package/dist/packs.d.ts +0 -71
- package/dist/packs.js +0 -180
- package/dist/sealed-settings.d.ts +0 -60
- package/dist/sealed-settings.js +0 -171
- package/dist/sessions.d.ts +0 -6
- package/dist/sessions.js +0 -109
- package/dist/workspace/computer-serves.d.ts +0 -12
- package/dist/workspace/computer-serves.js +0 -15
package/dist/server.js
CHANGED
|
@@ -18,7 +18,7 @@ import { DECISION_ADAPTER, decisionsOf, FAUX_JEV_ENV, FAUX_OPENROUTER_ENV, FAUX_
|
|
|
18
18
|
import { FAUX_WEB_ENV } from "./web-fetch-direct.js";
|
|
19
19
|
import { FAUX_MONID_ENV } from "./monid.js";
|
|
20
20
|
import { FAUX_EXA_ENV } from "./exa-keyless.js";
|
|
21
|
-
import { FAUX_BROWSER_ENV, NODE_TOOLS, toolingOf, toolOf, toolsView } from "./tools.js";
|
|
21
|
+
import { FAUX_BROWSER_ENV, NODE_TOOLS, shellTools, toolingOf, toolOf, toolsView } from "./tools.js";
|
|
22
22
|
import { ApiError, invalid, unsupported } from "./errors.js";
|
|
23
23
|
import { deref, explain } from "./explain.js";
|
|
24
24
|
import { HOME_HOST_OWNED } from "./files.js";
|
|
@@ -27,16 +27,17 @@ import { homePath, hostOwnedOf } from "./home-path.js";
|
|
|
27
27
|
import { chooseModel, EFFORTS, FAUX_ENV, FAUX_UPSTREAM_ENV, MODEL_NODES, modelSource, THINKING_LEVELS, unpricedModels, withoutFaux } from "./model.js";
|
|
28
28
|
import { DEFAULT_HARNESS, HARNESSES, harnessOfBody, harnessOffers } from "./harness.js";
|
|
29
29
|
import { HARNESS_TABLE_ENV, harnessOf } from "./harness-table.js";
|
|
30
|
-
import { HarnessInstall,
|
|
30
|
+
import { HarnessInstall, installDirOf, NPM_STOP_GRACE_MS, npmInstall } from "./harness-install.js";
|
|
31
31
|
import { healthOf, hostMemory, maxRunsOf, MIN_FREE_MIB, runsThatFit } from "./host.js";
|
|
32
32
|
import { IMPORT_ASKED } from "./import.js";
|
|
33
33
|
import { answerStoreCall } from "./import-proxy.js";
|
|
34
34
|
import { gradeModelOf, LEARNING_LABEL, learningBudgetOf, learningOf, seedOf } from "./learning.js";
|
|
35
|
-
import { agentLearning, learningLog, learningNotes, noteBody, pendingCount, readNote, secretsShown, sendNote, writeNote } from "./learning-routes.js";
|
|
35
|
+
import { agentLearning, learningLog, learningNotes, noteBody, pendingCount, readNote, secretsShown, sendNote, statusesOf, writeNote } from "./learning-routes.js";
|
|
36
36
|
import { answerLlms, MCP_PATH, mcpEndpoint } from "./mcp.js";
|
|
37
37
|
import { openapiDocument, servedOpenapi, UNSUPPORTED } from "./openapi.js";
|
|
38
38
|
import { boxAvailability, boxesLine, defaultPlaceOf, NEW_AGENT_TOOLS, newAgentPlace, noBoxReason, placesOf } from "./place.js";
|
|
39
|
-
import { BOX_ALLOW_ENV, boxAllowOf,
|
|
39
|
+
import { BOX_ALLOW_ENV, boxAllowOf, boxAllowSetIn, boxNetworkOf, FAUX_BOX_ENV, fauxBoxes } from "./box-settings.js";
|
|
40
|
+
import { dockerLimitsOf } from "./workspace/computer-deps.js";
|
|
40
41
|
import { Owner, passwordProblem, SESSION_MS } from "./owner.js";
|
|
41
42
|
import { answerPage, byOwnerSession, heldSessions, isJson, overHttps, ownerCookie, ownOrigin, sendHostRefused, signedIn } from "./page.js";
|
|
42
43
|
import { hostFix, hostName, loopbackNames } from "./host-check.js";
|
|
@@ -49,6 +50,7 @@ import { momentOverStore, summaryOverStore, timelineOverStore, viewOverStore, wi
|
|
|
49
50
|
import { HELD_WAITS } from "./runner/journal-kinds.js";
|
|
50
51
|
import { servedTimelineRows } from "./run-timeline-served.js";
|
|
51
52
|
import { servedRunDiff, servedRunLearning } from "./run-learning-served.js";
|
|
53
|
+
import { agentPointers, WITHHELD_LEARNING } from "./handed-values.js";
|
|
52
54
|
import { runCutValues } from "./run-cut.js";
|
|
53
55
|
import { readLaunchBody } from "./run-launch.js";
|
|
54
56
|
import { listRunFiles as listRunFilesOverStore, readRunFile as readRunFileOverStore, runGraphView, runTimelines } from "./run-reads-over-store.js";
|
|
@@ -60,17 +62,15 @@ import { watchRun } from "./live/stream.js";
|
|
|
60
62
|
import { stats as statsOverStore } from "./store-reads/stats.js";
|
|
61
63
|
import { analytics as analyticsOverStore } from "./store-reads/analytics.js";
|
|
62
64
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
63
|
-
import { openStore
|
|
65
|
+
import { openStore } from "./store/index.js";
|
|
66
|
+
import { answerOf, logged } from "./agents.js";
|
|
64
67
|
import { FINAL_STATES } from "./store/store.js";
|
|
65
68
|
import { runModelRef } from "./model.js";
|
|
66
69
|
// The v2 run statuses, as the run view names them (run-view.ts Status), for the list filter's validation. */
|
|
67
70
|
const STATUSES = ["queued", "working", "paused", "input_required", "completed", "failed", "cancelled"];
|
|
68
|
-
/** A busy store, and the home_busy answer it maps to (byte-identical to the old agents.ts words), for a read or write that
|
|
69
|
-
* meets the one store under load. */
|
|
70
|
-
const storeBusy = (error) => error instanceof StoreBusy;
|
|
71
|
-
const homeBusy = () => new ApiError("home_busy", "the agent store is busy with another write; try again", { retry_after_ms: 500 });
|
|
72
71
|
import { runLines } from "./usage-lines.js";
|
|
73
72
|
import { boxesByDefault, boxesLog, boxRegistry, enabledBoxes, VM_NO_LIST, VM_PROVIDER } from "./boxes.js";
|
|
73
|
+
import { dockerDaemonCheck } from "./docker-daemon.js";
|
|
74
74
|
import { egressParentTooLong, FAUX_EGRESS_ENV, MAX_EGRESS_PARENT, sweepEgressDirs } from "./box-egress.js";
|
|
75
75
|
import { startEgressContainer } from "./box-egress-vm.js";
|
|
76
76
|
import { dockerComputerRefusal, dockerPathsOf, egressParentOf, FAUX_MOUNTINFO_ENV, remoteDockerOnce } from "./box-paths.js";
|
|
@@ -84,21 +84,17 @@ import { hostSecrets, SECRET_NAMES, secret, withSecrets } from "./secrets.js";
|
|
|
84
84
|
import { isSecretWriteOperation, SECRET_WRITE_REFUSAL, secretsWritableFields, secretWriterFacts, writesSecretFor, writesSecretsAllowed } from "./secret-writes.js";
|
|
85
85
|
import { bootSealKey, withSealKey } from "./seal-key.js";
|
|
86
86
|
import { analyticsFilter, analyticsView, statsView } from "./stats.js";
|
|
87
|
-
import { agentLearningOverStore, learningCountsOverStore } from "./store-reads/learning.js";
|
|
88
|
-
import {
|
|
89
|
-
import { keyOf, SEAL_KEY_ENV, sealKeyOf, TOOL_FIELDS } from "./tool-keys.js";
|
|
87
|
+
import { agentLearningOverStore, learningCountsOverStore, learningSpendOverStore } from "./store-reads/learning.js";
|
|
88
|
+
import { keyOf, SEAL_KEY_ENV, TOOL_FIELDS } from "./tool-keys.js";
|
|
90
89
|
import { toolKeysOverStore } from "./tool-keys-store.js";
|
|
91
90
|
import { SIGN_INS_DIR, vendorsOver } from "./sign-ins.js";
|
|
92
|
-
// E1b builds the store-backed sign-ins bridge (the old SignIns interface — peek/forgotten/view/forget — over store.signIns,
|
|
93
|
-
// byte-identical v2 shapes; "held"/held_by from a live run whose sign_in_handed holds the pointer, verified_at from the
|
|
94
|
-
// last holder's lease end). TODO(E1b): wire its sha; named import until then.
|
|
95
91
|
import { signInsOverStore } from "./sign-ins-store.js";
|
|
96
92
|
import { MCP_AUTH_TYPES } from "./mcp-probe.js";
|
|
97
93
|
import { mcpServersOverStore } from "./mcp-servers-store.js";
|
|
98
94
|
import { privateHostsRoute } from "./mcp-private-hosts.js";
|
|
99
95
|
import { metaToolOf } from "./mcp-meta.js";
|
|
100
96
|
import { MCP_SETTINGS_PAGE, signInCookie, startedHere } from "./mcp-oauth.js";
|
|
101
|
-
import { WEBHOOK_EVENTS, Webhooks } from "./webhooks.js";
|
|
97
|
+
import { OUTBOUND_WEBHOOK, WEBHOOK_EVENTS, waitMarkerOf, Webhooks } from "./webhooks.js";
|
|
102
98
|
import { appPermissionWarnings } from "./template-github-permissions.js";
|
|
103
99
|
import { templateApplied, templateTriggerSecret, templateWebhookSecrets, triggerMade, triggerRotated, webhookSaved, withTriggerSecret } from "./trigger-secrets-shown.js";
|
|
104
100
|
import { openServerSecretsOverStore } from "./server-secrets-store.js";
|
|
@@ -109,7 +105,7 @@ import { HookCut, receivePush } from "./push-handler.js";
|
|
|
109
105
|
import { TRIGGER_ADAPTERS } from "./trigger-adapters.js";
|
|
110
106
|
import { webhook } from "./trigger-webhook.js";
|
|
111
107
|
import { SCHEME_NAMES } from "./trigger-signatures.js";
|
|
112
|
-
import { permissionFrom
|
|
108
|
+
import { permissionFrom } from "./tool-gate.js";
|
|
113
109
|
import { CATCHUP_WINDOW_S, FAILURES_TO_PAUSE, HISTORY_KEPT, MIN_EVERY_S, PAYLOAD_KEPT_BYTES, SOURCE_KINDS, TARGET_KINDS, Triggers } from "./triggers.js";
|
|
114
110
|
import { applyBodyOf, compiled, GITHUB_TRIGGER_UNCONNECTED, githubTriggerWords, madeTriggerIssues, packageModel, packageView, readPackages } from "./templates.js";
|
|
115
111
|
import { checkDefinitionBody, DEFAULT_INPUT_SCHEMA, definitionBodyIssues, EXTERNAL_NAME, ID, IDEMPOTENCY_TTL_S, inputIssues, isObject, stable, unknownFields } from "./validate.js";
|
|
@@ -127,7 +123,7 @@ import { computerCapabilities, createComputerRoutes, folderModeOf, settingsCompu
|
|
|
127
123
|
import { FAUX_VIEW_PATH, fauxComputers } from "./faux-computers.js";
|
|
128
124
|
import { runComputerField } from "./run-computer.js";
|
|
129
125
|
import { writesHeld } from "./workspace.js";
|
|
130
|
-
import { agentHomeFolder, claimKinds, computerProviderFactories, computerProviderMakers, computerReadiness, dockerHostAddressesOf, isWorkspaceError, localWorkspace, serverRunWorkspace, storeLedger } from "./workspace/index.js";
|
|
126
|
+
import { agentHomeFolder, claimKinds, computerProviderFactories, computerProviderMakers, computerReadiness, dockerHostAddressesOf, isWorkspaceError, localWorkspace, runShellOf, serverRunWorkspace, storeLedger } from "./workspace/index.js";
|
|
131
127
|
import { keyReader } from "./key-meta.js";
|
|
132
128
|
// server-lock.ts is gone: the store's EXCLUSIVE connection is the one-server lock (StoreOwned refuses a second server).
|
|
133
129
|
export const CONTRACT = "agentrun.v2/0";
|
|
@@ -213,8 +209,6 @@ export const ROUTES = [
|
|
|
213
209
|
{ method: "DELETE", pattern: /^\/agents\/([^/]+)\/sign-ins\/([^/]+)$/, name: "forgetSignIn" },
|
|
214
210
|
{ method: "POST", pattern: /^\/agents\/([^/]+)\/runs$/, name: "createRun" },
|
|
215
211
|
{ method: "GET", pattern: /^\/agents\/([^/]+)\/runs$/, name: "listRuns" },
|
|
216
|
-
{ method: "GET", pattern: /^\/agents\/([^/]+)\/home$/, name: "exportHome", capability: "home.export" },
|
|
217
|
-
{ method: "PUT", pattern: /^\/agents\/([^/]+)\/home$/, name: "importHome", capability: "home.import" },
|
|
218
212
|
{ method: "GET", pattern: /^\/agents\/([^/]+)\/home\/files$/, name: "listHomeFiles" },
|
|
219
213
|
{ method: "GET", pattern: /^\/agents\/([^/]+)\/home\/files\/(.+)$/, name: "readHomeFile" },
|
|
220
214
|
{ method: "PUT", pattern: /^\/agents\/([^/]+)\/home\/files\/(.+)$/, name: "writeHomeFile" },
|
|
@@ -230,7 +224,6 @@ export const ROUTES = [
|
|
|
230
224
|
{ method: "POST", pattern: /^\/runs\/([^/]+)\/approvals\/([^/]+)$/, name: "answerApproval" },
|
|
231
225
|
{ method: "POST", pattern: /^\/runs\/([^/]+)\/archive$/, name: "archiveRun" },
|
|
232
226
|
{ method: "POST", pattern: /^\/runs\/([^/]+)\/unarchive$/, name: "unarchiveRun" },
|
|
233
|
-
{ method: "POST", pattern: /^\/runs\/([^/]+)\/kill$/, name: "killRun", capability: "runs.kill" },
|
|
234
227
|
{ method: "GET", pattern: /^\/runs\/([^/]+)\/graph$/, name: "getRunGraph" },
|
|
235
228
|
{ method: "POST", pattern: /^\/workflows\/validate$/, name: "validateWorkflow" },
|
|
236
229
|
{ method: "POST", pattern: /^\/runs\/([^/]+)\/pause$/, name: "pauseRun" },
|
|
@@ -409,14 +402,15 @@ export function forCaller(caps, ownerSession) {
|
|
|
409
402
|
}
|
|
410
403
|
/** The capabilities document from offers already resolved, under the server's learning switch, tool settings and box
|
|
411
404
|
* offers: cheap, made again after each key or tool-settings write with the offers the server holds; and `needs` as
|
|
412
|
-
* needsOf says it for a revision that names no model (null when it runs).
|
|
413
|
-
|
|
405
|
+
* needsOf says it for a revision that names no model (null when it runs). `runnerShell`: the sandbox-only tools a run
|
|
406
|
+
* on the runner has a shell for here (tools.ts shellTools; bash in Mode 2), available with no box. */
|
|
407
|
+
function capabilitiesWith(env, maxRuns, harnesses, learning, { needs, priced }, toolSettings, boxes, gradeModel, refused = {}, runnerShell) {
|
|
414
408
|
const models = { ...modelSource(env), ready: needs === null, needs, priced };
|
|
415
409
|
// Both limits apply: the cap on the count, and the memory each run reserves (host.ts).
|
|
416
410
|
const memory = hostMemory();
|
|
417
411
|
// The browser's key is its vendor's row: Kernel's where Kernel is picked or resolved (tool-plane.ts browserKeyRow).
|
|
418
412
|
const keyFor = (tool) => (tool.name === "browser" ? browserKeyRow(tool.provider, tool.resolves?.[DEFAULT_HARNESS]) : keyOf(tool.name));
|
|
419
|
-
const tools = toolsView(env, toolSettings, noBoxReason(boxes), refused).map((tool) => (keyFor(tool) ? { ...tool, key: keyFor(tool) } : tool));
|
|
413
|
+
const tools = toolsView(env, toolSettings, noBoxReason(boxes), refused, runnerShell).map((tool) => (keyFor(tool) ? { ...tool, key: keyFor(tool) } : tool));
|
|
420
414
|
const browser = tools.find((tool) => tool.name === "browser");
|
|
421
415
|
return {
|
|
422
416
|
backend: "local",
|
|
@@ -476,13 +470,13 @@ function capabilitiesWith(env, maxRuns, harnesses, learning, { needs, priced },
|
|
|
476
470
|
* it over from the viewer and hands it back, and answers the agent's ask for them (POST /runs/{id}/browser/hand-back,
|
|
477
471
|
* browser-person.ts). */
|
|
478
472
|
browser_live: { read_only: false, take_over: true, ask: true },
|
|
479
|
-
/** An agent's browser stays signed in between its runs (sign-ins.ts)
|
|
480
|
-
* browser vendor here (Browserbase's or Kernel's; local Chrome keeps none). */
|
|
481
|
-
sign_ins:
|
|
473
|
+
/** An agent's browser stays signed in between its runs (sign-ins-store.ts), each pointer sealed under the server's seal
|
|
474
|
+
* key: with a browser vendor here (Browserbase's or Kernel's; local Chrome keeps none). */
|
|
475
|
+
sign_ins: tools.some((tool) => tool.name === "browser" && tool.available),
|
|
482
476
|
vault: false,
|
|
483
477
|
query: false,
|
|
484
|
-
/** GET, PUT and DELETE /settings/tool-keys: a tool's key saved by name, kept sealed under the
|
|
485
|
-
* (tool-keys.ts)
|
|
478
|
+
/** GET, PUT and DELETE /settings/tool-keys: a tool's key saved by name, kept sealed under the server's seal key
|
|
479
|
+
* (tool-keys-store.ts), never in the clear. */
|
|
486
480
|
tool_keys: { routes: true, at_rest: "sealed" },
|
|
487
481
|
/** /settings/mcp-servers: remote MCP servers previewed and saved, each credential sealed under the server's seal key,
|
|
488
482
|
* which always exists (seal-key.ts), so MCP credentials are always kept sealed. */
|
|
@@ -490,7 +484,7 @@ function capabilitiesWith(env, maxRuns, harnesses, learning, { needs, priced },
|
|
|
490
484
|
/** This server's learning switch (`--learning`): on, a run learns when its agent says `learning: true`; off, none does. */
|
|
491
485
|
learning,
|
|
492
486
|
/** /settings/webhook: one URL POSTed, signed by the Standard Webhooks spec, when a run needs its person and when it
|
|
493
|
-
* ends (webhooks.ts); its secret kept sealed under the same seal key
|
|
487
|
+
* ends (webhooks.ts); its secret kept sealed under the same seal key. */
|
|
494
488
|
// Always sealed: the server starts with its seal key (seal-key.ts bootSealKey), so nothing is kept in the clear.
|
|
495
489
|
webhooks: { routes: true, events: [...WEBHOOK_EVENTS], signing: "standard-webhooks/v1", at_rest: "sealed" },
|
|
496
490
|
/** /triggers: what starts an agent's capped runs with no caller (triggers.ts). */
|
|
@@ -555,7 +549,9 @@ export async function startServe(options) {
|
|
|
555
549
|
if (options.drainTimeout !== undefined && durationMs(options.drainTimeout) === undefined)
|
|
556
550
|
throw new Error(`the drain timeout ${options.drainTimeout} is not a duration such as 8s`);
|
|
557
551
|
enabledBoxes(process.env);
|
|
558
|
-
|
|
552
|
+
// A Docker computer's size an operator sets (workspace/computer-deps.ts): a value the Docker provider refuses stops the
|
|
553
|
+
// start, in its words.
|
|
554
|
+
dockerLimitsOf(process.env);
|
|
559
555
|
// The Docker host's addresses an operator names (workspace/computer-deps.ts): a bad entry stops the start, in words.
|
|
560
556
|
dockerHostAddressesOf(process.env);
|
|
561
557
|
const boxAllow = boxAllowOf(process.env);
|
|
@@ -620,7 +616,12 @@ async function startHolding(options, data, checked, stops) {
|
|
|
620
616
|
// words, to start fresh (no oldHomes/oldLayout checks, no migration). Every agent, run, setting and sign-in is a row; the
|
|
621
617
|
// server writes and reads rows, and a runner (its own process, sharing only this store) runs every run.
|
|
622
618
|
// On Postgres when this process's AGENTRUN_STORE_URL secret names one (store/open.ts), its owner lock the one-server lock.
|
|
623
|
-
|
|
619
|
+
// A server deploying while the old one still holds the schema waits for it (said once), never exits at once.
|
|
620
|
+
const store = await openStore({
|
|
621
|
+
dataDir: data, role: "server",
|
|
622
|
+
warn: (message) => void process.stderr.write(`agentrun-serve: ${message}\n`),
|
|
623
|
+
...(options.onStoreLost ? { onOwnerLost: options.onStoreLost } : {}),
|
|
624
|
+
});
|
|
624
625
|
stops.push(() => store.close());
|
|
625
626
|
// No start without a seal key (seal-key.ts), checked against the store before anything reads it: the one handed over,
|
|
626
627
|
// else the one in the data directory beside the store, made at the first start with only its path printed. A store whose
|
|
@@ -631,7 +632,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
631
632
|
// This server's own key on every environment it reads its secrets from, so a reader opens what this store holds with the
|
|
632
633
|
// key checked against it, never another data directory's that this process booted too (secrets.ts holds one made key).
|
|
633
634
|
const own = (env) => withSealKey(env, seal.text);
|
|
634
|
-
// Which fields are the server's is read from what it is started with alone: handed the saved keys too,
|
|
635
|
+
// Which fields are the server's is read from what it is started with alone: handed the saved keys too, the tool keys would
|
|
635
636
|
// call each the server's, and none could be deleted. The keys are sealed rows in the store; load() reads them once here.
|
|
636
637
|
const toolKeys = toolKeysOverStore(store, own(withSecrets(base, "own")), (fields) => (log ? log(logLine("tool_keys", fields)) : void process.stderr.write(`agentrun-serve: ${logLine("tool_keys", fields)}\n`)));
|
|
637
638
|
await toolKeys.load();
|
|
@@ -696,7 +697,8 @@ async function startHolding(options, data, checked, stops) {
|
|
|
696
697
|
// With accounts off no one can answer an ask (the answer route takes the owner's session alone): each tool ask is
|
|
697
698
|
// offered for says it needs the password sign-in, as learning's approve does.
|
|
698
699
|
const askNeeds = (made) => (options.accounts ? made : { ...made, tools: made.tools.map((tool) => (tool.permissions.includes("ask") ? { ...tool, ask_needs: "password" } : tool)) });
|
|
699
|
-
const
|
|
700
|
+
const compose = (runnerShell) => askNeeds(capabilitiesWith(env, maxRuns, offers, learning, needs, settings.get(), boxOffers, options.gradeModel, toolKeys.refused(), runnerShell));
|
|
701
|
+
const recompose = () => void (caps = compose());
|
|
700
702
|
// What the offers held now were made from (offersInputs), and the latest probe: one a later probe overtook is dropped.
|
|
701
703
|
let offersFrom;
|
|
702
704
|
let probes = 0;
|
|
@@ -829,10 +831,6 @@ async function startHolding(options, data, checked, stops) {
|
|
|
829
831
|
// process sees it.
|
|
830
832
|
const vmSecrets = () => [...serverSecrets(), ...VM_PROVIDER.keys.map((name) => env[name] ?? "").filter(Boolean)];
|
|
831
833
|
const vmRelayHalf = vmBoxes && vmClient ? vmRelay(vmClient, vmSecrets) : undefined;
|
|
832
|
-
const vmLimits = (() => {
|
|
833
|
-
const limits = boxLimitsOf(env);
|
|
834
|
-
return { cpus: limits.cpus, memoryMb: memoryMbOf(limits.memory) };
|
|
835
|
-
})();
|
|
836
834
|
// Daytona could not keep a run's box's domain list: said in the log and in capabilities, which recompose now.
|
|
837
835
|
// Daytona's own words go to the log, so a refusal for another cause is not taken silently for a tier that takes no list.
|
|
838
836
|
const onNoBoxList = (code, message) => {
|
|
@@ -876,15 +874,37 @@ async function startHolding(options, data, checked, stops) {
|
|
|
876
874
|
: kind === "browser" ? browserToolNames : capabilityToolDefs(kind).map((def) => def.name);
|
|
877
875
|
let faux;
|
|
878
876
|
const fauxOf = () => (faux ??= fauxComputers({ viewerBase: ownOriginOf() }));
|
|
877
|
+
/** Whether a computer on a provider that binds a folder of this machine (Docker) can be had here now: Settings →
|
|
878
|
+
* Computers' view and a run's start check (below) both ask it. Where AGENTRUN_BOXES lists Docker and it is no faux
|
|
879
|
+
* box, its daemon is asked (docker-daemon.ts: a short `docker version`, its answer kept a while and asked again, so a
|
|
880
|
+
* daemon that stops after the start is seen, and one that is gone says so in noDockerWords); once it answers, the
|
|
881
|
+
* box's start-time answer stands. A box the start did not make keeps its reason ("start Docker, then restart
|
|
882
|
+
* AgentRun"): the start's checks of Docker (Docker elsewhere, this server's paths, host addresses, its network) ran
|
|
883
|
+
* without it, so a daemon that answers later is not taken. Else the box's start-time answer (boxOffers), with its
|
|
884
|
+
* reason, which says how to fix it. */
|
|
885
|
+
const dockerDaemon = dockerDaemonCheck({ env });
|
|
886
|
+
const dockerAnswers = async (provider) => {
|
|
887
|
+
const box = boxAvailability(boxOffers).find((one) => one.id === provider);
|
|
888
|
+
if (provider === "docker" && !fauxBox && enabledBoxes(env).has("docker")) {
|
|
889
|
+
const daemon = await dockerDaemon();
|
|
890
|
+
if (!daemon.up || box?.available)
|
|
891
|
+
return daemon;
|
|
892
|
+
}
|
|
893
|
+
else if (box?.available)
|
|
894
|
+
return { up: true };
|
|
895
|
+
return { up: false, absent: false, reason: box?.reason ?? `${provider} is not a box this server has` };
|
|
896
|
+
};
|
|
879
897
|
let computerRoutes;
|
|
880
898
|
const computersOf = () => (computerRoutes ??= createComputerRoutes({
|
|
881
899
|
store, sealKey, tools: kindTools, mode: folderModeOf(store), env: process.env,
|
|
882
900
|
...(options.faux
|
|
901
|
+
// --faux's providers stand in for every vendor's, a local one's daemon included.
|
|
883
902
|
? { kinds: fauxOf().kinds, factories: fauxOf().factories, keyTable: fauxOf().keyTable }
|
|
884
903
|
: {
|
|
885
904
|
kinds: { SETTING_KINDS, PROVIDERS: COMPUTER_PROVIDERS, servingRefusals },
|
|
886
905
|
// The one place serve builds a provider (workspace/computer-providers.ts), the claim's makers' own.
|
|
887
906
|
factories: computerProviderFactories(computerProviderMakers(), (id) => storeLedger(store.computerLedger, id)),
|
|
907
|
+
answers: dockerAnswers,
|
|
888
908
|
}),
|
|
889
909
|
}));
|
|
890
910
|
/** Whether an agent's computer setting can be had here now, by the answers the runner's claim gives (resolve-computer.ts
|
|
@@ -892,13 +912,14 @@ async function startHolding(options, data, checked, stops) {
|
|
|
892
912
|
* runner composes with: runner/main.ts gives it no faux, so the package's, under --faux too), in the folder mode of
|
|
893
913
|
* now, with keys read as the runner reads them (the secrets this process was started with, withSecrets "own", as
|
|
894
914
|
* runner/main.ts runEnv hands them; else the saved one). What runnable.ts checks for an agent with
|
|
895
|
-
* a computer setting, in place of the box check
|
|
896
|
-
|
|
897
|
-
const
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
915
|
+
* a computer setting, in place of the box check; whether Docker answers here is dockerAnswers'. */
|
|
916
|
+
/** The server's folder mode now: 2 when the owner's Archil settings are saved (the run's folder on the disk), else 1. */
|
|
917
|
+
const modeNow = async () => ((await folderModeOf(store)()) === "disk" ? 2 : 1);
|
|
918
|
+
const computerReady = async (setting) => computerReadiness(setting, await modeNow(), claimKinds({}), keyReader(store, sealKey, own(withSecrets(process.env, "own"))), dockerAnswers, boxAllow);
|
|
919
|
+
/** Where a run of an agent with computer `setting` has its shell here now (resolve-computer.ts runShellOf, in the
|
|
920
|
+
* folder mode of now, over the registry the claim reads): what runnable.ts lets a sandbox-only tool on the runner by,
|
|
921
|
+
* and capabilities show bash by. In Mode 2 a run with no computer has bash on Archil's serverless exec. */
|
|
922
|
+
const shellOf = async (setting) => runShellOf(setting, await modeNow(), claimKinds({}));
|
|
902
923
|
const archil = createArchilRoutes({ store, sealKey, env: process.env });
|
|
903
924
|
/** A run's computer on its read: its revision's computer setting, else the one its place says; absent for none. */
|
|
904
925
|
const runComputerOf = async (runId, view) => {
|
|
@@ -940,9 +961,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
940
961
|
// (under faux, the vendor's fake alone), under this server's seal key. The store holds whether a sign-in is still held
|
|
941
962
|
// (a live run's sign_in_handed) and who was handed it, so this takes no `holds`/`handedTo` callback — one store, one lock.
|
|
942
963
|
const signIns = signInsOverStore(store, sealKey, vendorsOver(() => env, checkFetch));
|
|
943
|
-
|
|
944
|
-
//
|
|
945
|
-
|
|
964
|
+
// The outbound webhook and its outbox, in the store; its signing secret among the server's sealed settings, which list it
|
|
965
|
+
// (and each one it held before) with the server's own secrets.
|
|
966
|
+
const webhooks = new Webhooks(store, triggerSettings.get(OUTBOUND_WEBHOOK.id), (fields) => (log ? log(logLine("webhook", fields)) : void process.stderr.write(`agentrun-serve: ${logLine("webhook", fields)}\n`)), options.webhookRetryMs);
|
|
967
|
+
await webhooks.load();
|
|
946
968
|
stops.push(() => webhooks.close());
|
|
947
969
|
const uploads = new Uploads(join(data, UPLOADS_DIR));
|
|
948
970
|
// Under the data directory's lock and before this server answers anything, so no PUT of its own is in flight: an upload
|
|
@@ -957,10 +979,6 @@ async function startHolding(options, data, checked, stops) {
|
|
|
957
979
|
// of each at a time, which every run on that harness, and the save of an agent on it, waits for or starts; once one is
|
|
958
980
|
// in, the offers are probed again, so capabilities no longer say it installs on first use. Each is its table entry's
|
|
959
981
|
// `installs` (a test's stand-in has none).
|
|
960
|
-
// Claude Code as an earlier build installed it, at the top of the harnesses directory itself (read-only): removed once,
|
|
961
|
-
// before the first install, which then goes in beside nothing. Any other layout is left as it is.
|
|
962
|
-
let flat;
|
|
963
|
-
const flatRemoved = () => (flat ??= removeFlatInstall(harnessesOf(data)).then((removed) => void (removed && log?.(logLine("harness_install_removed", { dir: harnessesOf(data), said: `removed the earlier Claude Code install at ${harnessesOf(data)}: it installs again under harnesses/claude-agent` }))), (error) => ((flat = undefined), Promise.reject(error))));
|
|
964
982
|
const installed = HARNESSES.flatMap((id) => {
|
|
965
983
|
const harness = harnessOf(base, id);
|
|
966
984
|
return harness?.installs && harness.pins ? [{ entry: harness.installs, pins: harness.pins }] : [];
|
|
@@ -969,7 +987,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
969
987
|
const lock = options.harnessLocks?.[entry.id];
|
|
970
988
|
// npm past its SIGTERM's grace (it waits on a tarball once it writes): killed, and the line says so.
|
|
971
989
|
const onKilled = () => log?.(logLine("harness_install_killed", { harness: entry.id, said: `npm did not stop within ${NPM_STOP_GRACE_MS / 1000} s of SIGTERM; killed` }));
|
|
972
|
-
return [entry.id, new HarnessInstall(entry, installDirOf(data, entry.id), pins,
|
|
990
|
+
return [entry.id, new HarnessInstall(entry, installDirOf(data, entry.id), pins, (entry, dir, pins, signal) => npmInstall(entry, dir, pins, { signal, onKilled, ...(lock ? { lock } : {}) }), (ms) => {
|
|
973
991
|
log?.(logLine("harness_installed", { harness: entry.id, ms, dir: installDirOf(data, entry.id) }));
|
|
974
992
|
void probe(`${entry.id}_installed`).catch(() => undefined);
|
|
975
993
|
})];
|
|
@@ -1011,15 +1029,22 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1011
1029
|
approvers: options.accounts === true,
|
|
1012
1030
|
...(documents ? { documents: resolve(documents) } : {}),
|
|
1013
1031
|
...(boxAllow !== undefined ? { boxAllow } : {}),
|
|
1032
|
+
// Whether that is the operator's own setting, not the default: a browser is held to an operator's list alone.
|
|
1033
|
+
...(boxAllowSetIn(process.env) ? { boxAllowSet: true } : {}),
|
|
1014
1034
|
modelOf,
|
|
1015
1035
|
// The run's learning start, decided at start as the old file-backed start decided it (learning-run.ts onStart/seedFor):
|
|
1016
1036
|
// the server's learning switch, the budget its # Learned section fits, the agent's seed read now from its learning folder
|
|
1017
|
-
// (git), and the host's secrets as they are shown now to cut the notes a run is given
|
|
1018
|
-
//
|
|
1019
|
-
//
|
|
1020
|
-
//
|
|
1037
|
+
// (git), and the host's secrets as they are shown now to cut the notes a run is given, a loopback address kept (local),
|
|
1038
|
+
// as the run's .learning/ files keep it: the run's own machine, which an agent with no read tool learns of only here.
|
|
1039
|
+
// runs-over-store.learningStartFor pins the result (given/seed/section/seedNotes) in the launch for the runner; a seed
|
|
1040
|
+
// that cannot be read starts the run with nothing learned (a fault never refuses it). The runner's spec builders read
|
|
1041
|
+
// it back as the run's end-of-run step (runner/learning-end.ts learningEndOfRun, in adapter-run-spec.ts and
|
|
1042
|
+
// cli-run-spec.ts).
|
|
1021
1043
|
learning,
|
|
1022
1044
|
learningBudget,
|
|
1045
|
+
// The model the server names to grade what a run proposes (capabilities' learning.grade_model), carried on each learning
|
|
1046
|
+
// start for the runner's learning run to grade on: none, the agent's own.
|
|
1047
|
+
...(gradeModelOf(env, options.gradeModel) ? { gradeModel: gradeModelOf(env, options.gradeModel) } : {}),
|
|
1023
1048
|
seedFor: async (agentId) => {
|
|
1024
1049
|
// The switch runs no git in this process (learning.ts seedOf: the folder's own script and file API, which checks git
|
|
1025
1050
|
// itself); a git or folder fault surfaces here as a seedOf error, so the run starts with nothing learned, never refused.
|
|
@@ -1028,20 +1053,30 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1028
1053
|
return { failed: error.message };
|
|
1029
1054
|
});
|
|
1030
1055
|
},
|
|
1031
|
-
shown: () => secretsShown(serverSecrets()),
|
|
1056
|
+
shown: () => secretsShown(serverSecrets(), { local: true }),
|
|
1032
1057
|
};
|
|
1033
1058
|
// A run's served view and its live moment, from the store (store-view): `origin` is where this request reaches the
|
|
1034
1059
|
// console, the secrets are cut live, and the sign-ins give the handed-pointer cut. Trigger and background reads (no
|
|
1035
1060
|
// request) use the server's public address, else its own.
|
|
1036
1061
|
// The run's key read from this server's environment with the keys a person saved, as its Timeline reads it (keyEnv below).
|
|
1037
|
-
|
|
1062
|
+
// The learning routes' cut: the server's secrets and agent `agentId`'s own sign-in pointers, live and forgotten; 403 when
|
|
1063
|
+
// one of them can't be read here (agentPointers), never a shorter cut.
|
|
1064
|
+
const learningValues = async (agentId) => {
|
|
1065
|
+
const pointers = await agentPointers(signIns, agentId);
|
|
1066
|
+
if (pointers === "unreadable")
|
|
1067
|
+
throw new ApiError("forbidden", WITHHELD_LEARNING);
|
|
1068
|
+
return [...serverSecrets(), ...pointers];
|
|
1069
|
+
};
|
|
1070
|
+
const learningShown = async (agentId) => secretsShown(await learningValues(agentId));
|
|
1071
|
+
// What a run held for its owner's OK reads as it stands on its agent's learning folder's main (statusesOf).
|
|
1072
|
+
const statuses = (agentId) => statusesOf(data, agentId);
|
|
1073
|
+
const viewDepsFor = (origin) => ({ origin, serverSecrets, signIns, keyEnv: () => own(withSecrets(process.env, "all", storedKeys)), statuses });
|
|
1038
1074
|
const ownOriginOf = () => options.publicUrl ?? url;
|
|
1039
1075
|
// The run read routes (a run's files, its browser state, its workflow graph) over the one store (run-reads-over-store):
|
|
1040
1076
|
// a run's files through the server's read-only Workspace of its folder (serverRunWorkspace, no runner claim), its view
|
|
1041
1077
|
// and withheld verdict from store-view. The live browser viewer reads the runner's published handover from the store
|
|
1042
|
-
// (liveViewerLink, the one the runner's browser tool wrote under its claim),
|
|
1043
|
-
//
|
|
1044
|
-
// its own stub (store-reads journal + SSE) until E2c's timeline lands.
|
|
1078
|
+
// (liveViewerLink, the one the runner's browser tool wrote under its claim), opened with the server's seal key. The
|
|
1079
|
+
// timeline route keeps its own stub (store-reads journal + SSE) until E2c's timeline lands.
|
|
1045
1080
|
const runReadsDeps = {
|
|
1046
1081
|
runWorkspace: (_store, runId) => serverRunWorkspace(store, runId, { data, sealKey }),
|
|
1047
1082
|
env,
|
|
@@ -1061,7 +1096,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1061
1096
|
// shows and each browser sign-in pointer the run was handed; its decision rows among them, its error rows in the
|
|
1062
1097
|
// error's words. A run whose hand can't be read back here is withheld: none of its rows. A run's Timeline is read
|
|
1063
1098
|
// from its journal, which keeps what the run said whole.
|
|
1064
|
-
timelineRows: (forStore, runId, context) => servedTimelineRows({ serverSecrets, signIns, keyEnv: () => own(withSecrets(process.env, "all", storedKeys)) }, forStore, runId, context),
|
|
1099
|
+
timelineRows: (forStore, runId, context) => servedTimelineRows({ serverSecrets, signIns, keyEnv: () => own(withSecrets(process.env, "all", storedKeys)), statuses }, forStore, runId, context),
|
|
1065
1100
|
runView: (forStore, runId) => viewOverStore(forStore, runId, viewDepsFor(ownOriginOf())),
|
|
1066
1101
|
});
|
|
1067
1102
|
const triggerDeps = {
|
|
@@ -1070,6 +1105,12 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1070
1105
|
needAgent,
|
|
1071
1106
|
momentOf: (runId) => momentOverStore(store, runId, viewDepsFor(ownOriginOf())),
|
|
1072
1107
|
runStatus: async (runId) => (await viewOverStore(store, runId, viewDepsFor(ownOriginOf())))?.status ?? null,
|
|
1108
|
+
completedOutput: async (runId) => {
|
|
1109
|
+
const view = await viewOverStore(store, runId, viewDepsFor(ownOriginOf()));
|
|
1110
|
+
if (view?.status !== "completed")
|
|
1111
|
+
return undefined;
|
|
1112
|
+
return { output: view.result?.output ?? null, endedAt: view.ended_at ?? null };
|
|
1113
|
+
},
|
|
1073
1114
|
};
|
|
1074
1115
|
const targets = triggerTargets(store, triggerDeps);
|
|
1075
1116
|
const expected = digest(`Bearer ${token}`);
|
|
@@ -1407,7 +1448,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1407
1448
|
* does not have yet. `capped`: the run has a spend cap, which a web tool's resolution reads (tool-plane.ts). */
|
|
1408
1449
|
async function runnable(revision, place, { capped = false } = {}) {
|
|
1409
1450
|
const shape = { ...shapeOf(revision), place, ...(revision.body.place ? {} : { unnamed: true }) };
|
|
1410
|
-
const blockers = await blockersOf(env, shape, settings.get(), { capped, boxes: boxOffers, computerReady, offers, mcp: mcpTools, decisionPrice });
|
|
1451
|
+
const blockers = await blockersOf(env, shape, settings.get(), { capped, boxes: boxOffers, computerReady, shellOf, offers, mcp: mcpTools, decisionPrice });
|
|
1411
1452
|
if (!blockers.length)
|
|
1412
1453
|
return;
|
|
1413
1454
|
const message = blockers.map((b) => b.message).join(" ");
|
|
@@ -1443,14 +1484,14 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1443
1484
|
}
|
|
1444
1485
|
const named = (revision.kind === "agentic" ? { kind: "agentic", ...body } : workflowShape(body));
|
|
1445
1486
|
const shape = named.place ? named : { ...named, place: fallbackPlace(named.kind, named.tools ?? []), unnamed: true };
|
|
1446
|
-
const blockers = await blockersOf(env, shape, settings.get(), { boxes: boxOffers, computerReady, offers, mcp: mcpTools });
|
|
1487
|
+
const blockers = await blockersOf(env, shape, settings.get(), { boxes: boxOffers, computerReady, shellOf, offers, mcp: mcpTools });
|
|
1447
1488
|
// An agent's default cap caps each run started without one of its own, and a web tool resolves by the cap: what a cap
|
|
1448
1489
|
// alone keeps from running under the definition's own picks, whatever this host's settings, would keep every such run
|
|
1449
1490
|
// from running, so the save is refused, not each run (claude-agent's or codex's own search, picked, under a cap).
|
|
1450
1491
|
if ((body.maxCostUsd ?? 0) > 0) {
|
|
1451
1492
|
const key = (b) => `${b.field}\n${b.message}`;
|
|
1452
|
-
const plain = new Set((await blockersOf(env, shape, {}, { boxes: boxOffers, computerReady, offers, mcp: mcpTools })).map(key));
|
|
1453
|
-
const capped = await blockersOf(env, shape, {}, { capped: true, boxes: boxOffers, computerReady, offers, mcp: mcpTools, decisionPrice });
|
|
1493
|
+
const plain = new Set((await blockersOf(env, shape, {}, { boxes: boxOffers, computerReady, shellOf, offers, mcp: mcpTools })).map(key));
|
|
1494
|
+
const capped = await blockersOf(env, shape, {}, { capped: true, boxes: boxOffers, computerReady, shellOf, offers, mcp: mcpTools, decisionPrice });
|
|
1454
1495
|
// A model with no price (`unpriced`) is a setting this host fixes (AGENT_MODEL_PRICE): a warning, as it is; the
|
|
1455
1496
|
// agent saves and updates, and only a run under the cap is refused (409). A tool's pick a cap rules out refuses it.
|
|
1456
1497
|
const added = capped.filter((b) => !plain.has(key(b)));
|
|
@@ -1487,14 +1528,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1487
1528
|
const saved = pkg.mcp.filter((need) => mcpMeta.has(need.server));
|
|
1488
1529
|
const unsaved = pkg.mcp.filter((need) => !saved.includes(need));
|
|
1489
1530
|
const needed = unsaved.filter((need) => need.required);
|
|
1490
|
-
|
|
1491
|
-
// the agent is made, so the apply is refused first, naming each one.
|
|
1492
|
-
const unsealed = sealKeyOf(env[SEAL_KEY_ENV]) ? [] : pkg.triggers.flatMap((trigger, i) => (isObject(trigger.source) && trigger.source.kind === "webhook" ? [i] : []));
|
|
1493
|
-
if (missing.length || needed.length || unsealed.length) {
|
|
1531
|
+
if (missing.length || needed.length) {
|
|
1494
1532
|
const fix = "Add it in Settings → Model keys or Settings → Tool keys, or set it where AgentRun starts, then apply the template again.";
|
|
1495
1533
|
const server = "Add it in Settings → MCP servers, under that name, then apply the template again.";
|
|
1496
|
-
|
|
1497
|
-
throw new ApiError("agent_not_runnable", `The ${pkg.name} template needs ${[...missing, ...needed.map((need) => `the MCP server ${need.server}`), ...(unsealed.length ? ["a seal key for its webhook trigger's secret"] : [])].join(" and ")}, which this server does not have. Nothing was created.`, { fields: [...missing.map((name) => ({ field: `secrets.${name}`, reason: NOT_SET_UP, message: `${name} is not set on this server.`, fix })), ...needed.map((need) => ({ field: `mcp.${need.server}`, reason: NOT_SET_UP, message: `No MCP server ${need.server} is saved on this server.`, fix: server })), ...unsealed.map((i) => ({ field: `triggers.${i}`, reason: NOT_SET_UP, message: `This server has no seal key (${SEAL_KEY_ENV}), so it cannot keep the webhook trigger's secret.`, fix: sealing }))] });
|
|
1534
|
+
throw new ApiError("agent_not_runnable", `The ${pkg.name} template needs ${[...missing, ...needed.map((need) => `the MCP server ${need.server}`)].join(" and ")}, which this server does not have. Nothing was created.`, { fields: [...missing.map((name) => ({ field: `secrets.${name}`, reason: NOT_SET_UP, message: `${name} is not set on this server.`, fix })), ...needed.map((need) => ({ field: `mcp.${need.server}`, reason: NOT_SET_UP, message: `No MCP server ${need.server} is saved on this server.`, fix: server }))] });
|
|
1498
1535
|
}
|
|
1499
1536
|
// An MCP server the package can do without is skipped, and said: its tools are not granted.
|
|
1500
1537
|
const skipped = unsaved.map((need) => ({ field: `mcp.${need.server}`, reason: NOT_SET_UP, message: `No MCP server ${need.server} is saved on this server, so the agent was made without its tools (${need.tools.join(", ")}). Save it in Settings → MCP servers and apply again to grant them.` }));
|
|
@@ -1509,13 +1546,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1509
1546
|
const server = settings.get();
|
|
1510
1547
|
const denied = grants.filter((tool) => { const set = permissionFrom(tool, server); return set.from === "server" && set.permission === "deny"; });
|
|
1511
1548
|
const kept = denied.map((tool) => ({ field: `grants.${tool}`, reason: "not_allowed", message: `${tool} is denied on this server (Settings → Tools), so the agent was not allowed it: its runs are refused it until the owner changes that setting.` }));
|
|
1512
|
-
// The tools this server's own settings pin (or hold refused for a pin that does not read): a package's pin the agent
|
|
1513
|
-
// store can't keep yet is covered there, so its grant stands; any other such tool is made deny (compiled).
|
|
1514
1549
|
// The agent's approvals: the apply's override, else the package's own (a template whose job runs on triggers says
|
|
1515
1550
|
// never), else ask. Deny and pins hold either way.
|
|
1516
1551
|
const chosenApprovals = approvals ?? pkg.approvals;
|
|
1517
|
-
const
|
|
1518
|
-
const made = compiled(pkg, parameters, { ...(harness ? { harness } : {}), ...(model ? { model } : {}), mcp: saved, defaultTools, grants: grants.filter((tool) => !denied.includes(tool)), serverPinned, ...(chosenApprovals ? { approvals: chosenApprovals } : {}) }, templateDeps);
|
|
1552
|
+
const made = compiled(pkg, parameters, { ...(harness ? { harness } : {}), ...(model ? { model } : {}), mcp: saved, defaultTools, grants: grants.filter((tool) => !denied.includes(tool)), ...(chosenApprovals ? { approvals: chosenApprovals } : {}) }, templateDeps);
|
|
1519
1553
|
// Every trigger is checked as POST /triggers checks it, its parameters filled, before anything is made: a schedule
|
|
1520
1554
|
// from a parameter that does not read, or a date that has passed, refuses the apply (422 under triggers.<i>).
|
|
1521
1555
|
const refusedTriggers = madeTriggerIssues(made.triggers, Date.now());
|
|
@@ -1568,9 +1602,6 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1568
1602
|
}
|
|
1569
1603
|
// A pinned send whose destination parameter was not given is denied, never let go anywhere: said, by its gate name.
|
|
1570
1604
|
const unpinned = made.unpinned.map(({ tool, parameters: named }) => ({ field: `pins.${tool}`, reason: NOT_SET_UP, message: `${tool}'s arguments are fixed by ${named.map((one) => `the ${one} parameter`).join(" and ")}, which was not given, so the agent was made with ${tool} set to deny: it can't call it at all. Apply again with ${named.join(" and ")} set to let it.` }));
|
|
1571
|
-
// A pin this server's agent store does not keep yet (tool-plane.ts AGENT_LAYER_PINS): said, with the setting that holds
|
|
1572
|
-
// the send to its destination meanwhile, the server's.
|
|
1573
|
-
const unkept = made.unkept.map(({ tool, pin }) => ({ field: `pins.${tool}`, reason: NOT_SET_UP, message: serverPinned.has(tool) ? `${tool} is not pinned to ${pinWords(pin)} for this agent yet (this server's agent store keeps an agent's own pin from the store cutover on); this server's own pin of ${tool} holds its calls meanwhile.` : `${tool} is not pinned to ${pinWords(pin)} for this agent yet: this server's agent store keeps an agent's own pin from the store cutover on. Until then the agent was made with ${tool} set to deny, so nothing it reads can send it elsewhere. Pin it on this server, which holds every agent's calls of ${tool}, and apply again to let it.`, ...(serverPinned.has(tool) ? {} : { fix: `Add ${JSON.stringify({ [tool]: { pin } })} to this server's tool settings (Settings → Tools; PUT /v2/settings/tools replaces the whole map, so send it with the rest).` }) }));
|
|
1574
1605
|
// A GitHub tool the package grants that Connect GitHub's App may not use (its manifest asks for less), where the github
|
|
1575
1606
|
// MCP server runs on the App's tokens: said now, before a run's first call is refused (template-github-permissions.ts).
|
|
1576
1607
|
const appShort = appPermissionWarnings({ name: pkg.name, mcp: saved }, (server) => mcpMeta.get(server)?.auth === "github_app");
|
|
@@ -1583,7 +1614,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1583
1614
|
// Each trigger it made, a webhook trigger's with its secret's metadata; the values go back beside the answer, never in it
|
|
1584
1615
|
// (the route adds them to the first answer to the owner's session, after the Idempotency-Key's record is written).
|
|
1585
1616
|
const minted = new Map(secrets.map(({ trigger_id, secret }) => [trigger_id, secret]));
|
|
1586
|
-
const applied = { template: pkg.name, version: pkg.version, agent_id: entry.agent.id, trigger_ids: ids, ...templateWebhookSecrets([...minted.keys()], new Date().toISOString()), warnings: [...skipped, ...kept, ...modelWarnings, ...unpinned, ...
|
|
1617
|
+
const applied = { template: pkg.name, version: pkg.version, agent_id: entry.agent.id, trigger_ids: ids, ...templateWebhookSecrets([...minted.keys()], new Date().toISOString()), warnings: [...skipped, ...kept, ...modelWarnings, ...unpinned, ...warnings, ...hooks, ...githubTriggers, ...appShort] };
|
|
1587
1618
|
return { applied, minted };
|
|
1588
1619
|
}
|
|
1589
1620
|
/** A run create's issues told from the input this server checks (explain.ts): an agentic run's `{content: string}`,
|
|
@@ -1986,8 +2017,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1986
2017
|
total.unpriced++;
|
|
1987
2018
|
total.usd += usd ?? soFar;
|
|
1988
2019
|
}
|
|
1989
|
-
// What learning spent on this server, outside any run (
|
|
1990
|
-
|
|
2020
|
+
// What learning spent on this server, outside any run (store-reads/learning.ts learningSpendOverStore): each run's grade, on
|
|
2021
|
+
// the day its learning ended.
|
|
2022
|
+
for (const entry of await learningSpendOverStore(store, { from, to })) {
|
|
1991
2023
|
const at = Date.parse(entry.at);
|
|
1992
2024
|
if (at >= from && at < to)
|
|
1993
2025
|
add(lineKey(entry.agent, entry.at, "learning"), entry.cost);
|
|
@@ -2217,8 +2249,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
2217
2249
|
throw new ApiError("method_not_allowed", `${req.method} is not a method of ${path}`, {}, { allow: [...new Set(matching.map((r) => r.method))].join(", ") });
|
|
2218
2250
|
if (found.name === "getCapabilities") {
|
|
2219
2251
|
// features.computers: the computer kinds this server offers now (computers.ts), read at each answer, since turning
|
|
2220
|
-
// Archil on or off, or saving a key, changes them.
|
|
2221
|
-
|
|
2252
|
+
// Archil on or off, or saving a key, changes them. So does a shell on the runner (bash on Archil's serverless exec
|
|
2253
|
+
// in Mode 2): where there is one, the document is made again with it (cheap), its tools available with no box.
|
|
2254
|
+
const runnerShell = shellTools(await shellOf({ kind: "none" }));
|
|
2255
|
+
const answer = forCaller(runnerShell.size ? compose(runnerShell) : caps, byOwnerSession(req));
|
|
2222
2256
|
return send(res, 200, { ...answer, features: { ...answer.features, computers: await computerCapabilities(computersOf()) } });
|
|
2223
2257
|
}
|
|
2224
2258
|
if (found.name === "getOpenapi")
|
|
@@ -2666,7 +2700,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
2666
2700
|
throw invalid([{ field: "workflow", reason: body.workflow === undefined ? "missing" : "wrong_type", message: "workflow is the workflow definition, an object" }]);
|
|
2667
2701
|
if (body.tools !== undefined && !(Array.isArray(body.tools) && body.tools.every((t) => typeof t === "string")))
|
|
2668
2702
|
throw invalid([{ field: "tools", reason: "wrong_type", message: "tools is a list of tool names" }]);
|
|
2669
|
-
const { workflowIssues } = await import("
|
|
2703
|
+
const { workflowIssues } = await import("./workflow-run.js");
|
|
2670
2704
|
const { issues, warnings } = await workflowIssues(body.workflow, body.tools);
|
|
2671
2705
|
// What a save refuses on this host (a model node's tool, a code node where none runs), and what it lacks yet.
|
|
2672
2706
|
if (!issues.length) {
|
|
@@ -2849,14 +2883,15 @@ async function startHolding(options, data, checked, stops) {
|
|
|
2849
2883
|
return send(res, 200, withDefaults(settings.get()));
|
|
2850
2884
|
}
|
|
2851
2885
|
// A person's view and control of what an agent learned (learning-routes.ts). Every text cut of the host's secrets as
|
|
2852
|
-
// they are now
|
|
2886
|
+
// they are now and of the agent's own sign-in pointers, live and forgotten (agentPointers); a write as the
|
|
2887
|
+
// definition's: an archived agent's too.
|
|
2853
2888
|
case "getAgentLearning": {
|
|
2854
2889
|
await needAgent(id);
|
|
2855
2890
|
// The agent's learning view: its notes, skills, workflows and log from its learning folder; its run-fared counts, each
|
|
2856
2891
|
// note's runs (given it and that read it) and its impact over the one store (agentLearningOverStore), from each run's
|
|
2857
2892
|
// launch, journal and learning end.
|
|
2858
2893
|
const { counts, impact, notes } = await agentLearningOverStore(store, id);
|
|
2859
|
-
return send(res, 200, await agentLearning(data, id,
|
|
2894
|
+
return send(res, 200, await agentLearning(data, id, await learningShown(id), counts, impact, notes));
|
|
2860
2895
|
}
|
|
2861
2896
|
case "listLearningNotes":
|
|
2862
2897
|
case "listLearningLog":
|
|
@@ -2864,12 +2899,12 @@ async function startHolding(options, data, checked, stops) {
|
|
|
2864
2899
|
if (found.name === "listLearningNotes") {
|
|
2865
2900
|
// The notes from the agent's learning folder, each with its runs over the one store (agentLearningOverStore's noteRuns).
|
|
2866
2901
|
const { notes } = await agentLearningOverStore(store, id);
|
|
2867
|
-
return send(res, 200, await learningNotes(data, id, url.searchParams,
|
|
2902
|
+
return send(res, 200, await learningNotes(data, id, url.searchParams, await learningShown(id), notes));
|
|
2868
2903
|
}
|
|
2869
|
-
return send(res, 200, await learningLog(data, id, url.searchParams,
|
|
2904
|
+
return send(res, 200, await learningLog(data, id, url.searchParams, await learningShown(id)));
|
|
2870
2905
|
case "readLearningFile":
|
|
2871
2906
|
await needAgent(id);
|
|
2872
|
-
return sendNote(res, 200, await readNote(data, id, second,
|
|
2907
|
+
return sendNote(res, 200, await readNote(data, id, second, await learningShown(id)));
|
|
2873
2908
|
case "writeLearningFile":
|
|
2874
2909
|
case "retireLearningFile":
|
|
2875
2910
|
case "approveLearningFile":
|
|
@@ -2877,18 +2912,20 @@ async function startHolding(options, data, checked, stops) {
|
|
|
2877
2912
|
await needAgent(id);
|
|
2878
2913
|
const header = (name) => (typeof req.headers[name] === "string" ? req.headers[name] : undefined);
|
|
2879
2914
|
const body = found.name === "writeLearningFile" ? await noteBody(req, MAX_BODY) : undefined;
|
|
2880
|
-
|
|
2915
|
+
// What it refuses is what the reads cut: a note shown cut is never saved over the hidden text.
|
|
2916
|
+
const refuse = await learningValues(id);
|
|
2917
|
+
const written = await writeNote(data, id, second, { ifMatch: header("if-match"), ifNoneMatch: header("if-none-match"), body, refuse, approve: found.name === "approveLearningFile", restore: found.name === "restoreLearningFile", draftTools: () => learnedDraftToolsOf(id) });
|
|
2881
2918
|
// A name holding a secret (one the checks let by) is never echoed, not even as where the note is.
|
|
2882
|
-
const shown = secretsShown(
|
|
2919
|
+
const shown = secretsShown(refuse);
|
|
2883
2920
|
const located = written.status === 201 && shown.name(written.file) === written.file;
|
|
2884
2921
|
return sendNote(res, written.status, { ...written, text: shown.text(written.text) }, located ? { location: `/v2/agents/${encodeURIComponent(id)}/learning/files/${written.file}` } : {});
|
|
2885
2922
|
}
|
|
2886
2923
|
case "getRunLearning": {
|
|
2887
2924
|
const run = await needRun(id);
|
|
2888
2925
|
// The run's learning view over the store (learning-1's runLearningOverStore): its end, the notes it was given and its seed
|
|
2889
|
-
// from its launch, what it holds for the owner's OK as the store's run view reads it (
|
|
2926
|
+
// from its launch, what it holds for the owner's OK as the store's run view reads it (on its folder's main), as main.
|
|
2890
2927
|
// Cut by the run's one cut, and refused for a withheld run (run-learning-served.ts).
|
|
2891
|
-
return send(res, 200, await servedRunLearning({ serverSecrets, signIns }, store, run.id));
|
|
2928
|
+
return send(res, 200, await servedRunLearning({ serverSecrets, signIns, statuses }, store, run.id));
|
|
2892
2929
|
}
|
|
2893
2930
|
case "getRunLearningDiff": {
|
|
2894
2931
|
const run = await needRun(id);
|
|
@@ -2902,11 +2939,11 @@ async function startHolding(options, data, checked, stops) {
|
|
|
2902
2939
|
case "saveWebhook": {
|
|
2903
2940
|
// Never through `idempotent`: its record would keep the answer, and the first one holds the secret.
|
|
2904
2941
|
// Its minted secret to the owner's session alone (trigger-secrets-shown.ts); the token gets its metadata and the words.
|
|
2905
|
-
const saved = webhooks.save(await bodyOf(req));
|
|
2942
|
+
const saved = await webhooks.save(await bodyOf(req));
|
|
2906
2943
|
return send(res, saved.created ? 201 : 200, webhookSaved(saved.view, saved.secret, mayHoldSecrets(req)));
|
|
2907
2944
|
}
|
|
2908
2945
|
case "deleteWebhook":
|
|
2909
|
-
webhooks.remove();
|
|
2946
|
+
await webhooks.remove();
|
|
2910
2947
|
return void res.writeHead(204, { "cache-control": "no-store" }).end();
|
|
2911
2948
|
case "testWebhook":
|
|
2912
2949
|
return send(res, 200, await webhooks.test());
|
|
@@ -3025,9 +3062,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3025
3062
|
// A request cut before its body was read (push-handler.ts readCapped): its socket goes once the answer is out.
|
|
3026
3063
|
if (error instanceof HookCut)
|
|
3027
3064
|
res.once("finish", () => req.socket.destroy());
|
|
3028
|
-
// A store still busy past a request's wait is home_busy, whichever read or
|
|
3029
|
-
|
|
3030
|
-
|
|
3065
|
+
// A store still busy past a request's wait, or a write still open at its deadline, is home_busy, whichever read or
|
|
3066
|
+
// write met it: the request may be sent again, never a 500 (agents.ts answerOf, as an MCP tool's call answers).
|
|
3067
|
+
const known = answerOf(error);
|
|
3068
|
+
if (logged(error))
|
|
3031
3069
|
process.stderr.write(`agentrun-serve: ${error?.stack ?? String(error)}\n`);
|
|
3032
3070
|
send(res, known.status, known.body(requestId), known.headers);
|
|
3033
3071
|
};
|
|
@@ -3058,7 +3096,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3058
3096
|
return void mcp(req, res).catch(fail);
|
|
3059
3097
|
if (raw === "/llms.txt")
|
|
3060
3098
|
return void answerLlms(req, res).catch(fail);
|
|
3061
|
-
if (answerPage(req, res, raw, { token,
|
|
3099
|
+
if (answerPage(req, res, raw, { token, authFailed, console: options.console, takesBytes, ...(owner ? { owner } : {}), ...(options.publicUrl ? { publicUrl: options.publicUrl } : {}) }))
|
|
3062
3100
|
return;
|
|
3063
3101
|
// Under --faux only: a faux desktop's live view, a page on this server's own address (faux-computers.ts viewPage), so
|
|
3064
3102
|
// a run's take-over has a viewer to open in the console's real-browser flows. Gone after the computer's release.
|
|
@@ -3197,8 +3235,8 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3197
3235
|
const heldReadAt = new Map();
|
|
3198
3236
|
const HELD_WAIT_REREAD_MS = 1_000;
|
|
3199
3237
|
const waitKinds = new Set(["question", "approval", "budget", "browser"]);
|
|
3200
|
-
/** The wait of a run its runner left parked (or let go of),
|
|
3201
|
-
*
|
|
3238
|
+
/** The wait of a run its runner left parked (or let go of), or holds in its claim, told once per ask: its marker the
|
|
3239
|
+
* ask's own (webhooks.ts waitMarkerOf), its kind the pending card's (a stop's when it waits on no card). */
|
|
3202
3240
|
const tellWait = async (row) => {
|
|
3203
3241
|
const seen = `${row.state}\n${row.epoch}\n${row.runner ?? ""}\n${row.summary ?? ""}`;
|
|
3204
3242
|
if (readWaits.get(row.id) === seen)
|
|
@@ -3207,13 +3245,14 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3207
3245
|
if (view?.status !== "input_required")
|
|
3208
3246
|
return void readWaits.set(row.id, seen);
|
|
3209
3247
|
const rows = (await timelineOverStore(store, row.id, viewDepsFor(ownOriginOf()))) ?? [];
|
|
3210
|
-
|
|
3248
|
+
// One marker per ask, so the held read and the let-go read of one ask agree, whatever row shows last.
|
|
3249
|
+
const marker = waitMarkerOf(rows, view.pending, view.state === "waiting", LEARNING_LABEL);
|
|
3211
3250
|
if (!marker)
|
|
3212
3251
|
return void readWaits.set(row.id, seen);
|
|
3213
3252
|
const card = view.pending?.kind;
|
|
3214
3253
|
const kind = view.state !== "waiting" ? "stopped" : typeof card === "string" && waitKinds.has(card) ? card : "question";
|
|
3215
3254
|
const notice = { run_id: row.id, agent_id: row.agentId, status: "input_required", title: typeof view.title === "string" ? view.title : "", pending: { kind } };
|
|
3216
|
-
if (webhooks.emit("run.needs_input", notice, marker) !== "unsaved")
|
|
3255
|
+
if ((await webhooks.emit("run.needs_input", notice, marker)) !== "unsaved")
|
|
3217
3256
|
readWaits.set(row.id, seen);
|
|
3218
3257
|
};
|
|
3219
3258
|
let openRuns = new Set();
|
|
@@ -3253,7 +3292,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3253
3292
|
heldReadAt.delete(id);
|
|
3254
3293
|
if (!now?.endedAt || toldEnds.get(id) === now.endedAt)
|
|
3255
3294
|
continue;
|
|
3256
|
-
if (webhooks.emit("run.ended", now.notice, now.endedAt) !== "unsaved")
|
|
3295
|
+
if ((await webhooks.emit("run.ended", now.notice, now.endedAt)) !== "unsaved")
|
|
3257
3296
|
toldEnds.set(id, now.endedAt);
|
|
3258
3297
|
}
|
|
3259
3298
|
openRuns = open;
|