@parcha/agentrun-serve 0.1.0-beta.56 → 0.1.0-beta.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +281 -0
- package/README.md +246 -66
- package/dist/acp-package.d.ts +2 -0
- package/dist/adapters.d.ts +15 -3
- package/dist/adapters.js +17 -6
- package/dist/agent-package.d.ts +3 -3
- package/dist/agent-package.js +17 -8
- package/dist/api-keys.d.ts +76 -0
- package/dist/api-keys.js +217 -0
- package/dist/api-only.d.ts +15 -5
- package/dist/api-only.js +32 -8
- package/dist/box-paths.d.ts +4 -3
- package/dist/box-paths.js +7 -4
- package/dist/browser-hold.d.ts +23 -0
- package/dist/browser-hold.js +48 -0
- package/dist/browser-person.d.ts +3 -0
- package/dist/browser-person.js +4 -1
- package/dist/chatgpt-plan.d.ts +18 -8
- package/dist/chatgpt-plan.js +91 -34
- package/dist/claude-login-token.d.ts +117 -0
- package/dist/claude-login-token.js +737 -0
- package/dist/claude-login.d.ts +120 -22
- package/dist/claude-login.js +347 -63
- package/dist/claude-sign-in.d.ts +17 -6
- package/dist/claude-sign-in.js +42 -39
- package/dist/cli.js +33 -10
- package/dist/composio-made.d.ts +4 -0
- package/dist/composio-made.js +4 -0
- package/dist/composio-preset.d.ts +43 -2
- package/dist/composio-preset.js +92 -4
- package/dist/computer-attach.d.ts +35 -17
- package/dist/computer-attach.js +301 -49
- package/dist/computer-held-routes.d.ts +5 -4
- package/dist/computer-held-routes.js +29 -8
- package/dist/computer-held.d.ts +6 -1
- package/dist/computer-held.js +14 -0
- package/dist/computer-record.js +4 -2
- package/dist/computer-viewer.js +4 -1
- package/dist/computers.d.ts +10 -10
- package/dist/computers.js +5 -5
- package/dist/console/assets/{backend-Boh7tC4i.js → backend-CSAWUqtZ.js} +19 -19
- package/dist/console/assets/index-Bwn1oTem.css +1 -0
- package/dist/console/assets/index-DPh29cyz.js +747 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +1 -1
- package/dist/dial-relay.d.ts +25 -4
- package/dist/dial-relay.js +129 -1
- package/dist/docker-host-addresses.d.ts +22 -11
- package/dist/docker-host-addresses.js +38 -26
- package/dist/env-switch.d.ts +8 -0
- package/dist/env-switch.js +31 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +56 -20
- package/dist/fal-price.js +400 -90
- package/dist/handed-values.d.ts +43 -1
- package/dist/handed-values.js +119 -2
- package/dist/harness-archive.d.ts +13 -10
- package/dist/harness-archive.js +60 -34
- package/dist/harness-check.d.ts +3 -1
- package/dist/harness-check.js +25 -46
- package/dist/harness-keys.d.ts +73 -27
- package/dist/harness-keys.js +194 -61
- package/dist/harness-recipe-entry.d.ts +8 -7
- package/dist/harness-recipe-entry.js +21 -32
- package/dist/harness-recipe.d.ts +38 -25
- package/dist/harness-recipe.js +49 -36
- package/dist/harness-sign-in.js +12 -23
- package/dist/harness-table.d.ts +10 -3
- package/dist/harness-table.js +26 -21
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +17 -5
- package/dist/hosted-search.d.ts +1 -1
- package/dist/hosted-search.js +1 -2
- package/dist/import-worker.d.ts +4 -2
- package/dist/import-worker.js +9 -2
- package/dist/in-flight.d.ts +26 -0
- package/dist/in-flight.js +52 -0
- package/dist/key-refusal.d.ts +9 -4
- package/dist/key-refusal.js +107 -25
- package/dist/learn/ledger.d.ts +170 -0
- package/dist/learn/ledger.js +218 -0
- package/dist/learn/promote.d.ts +3 -3
- package/dist/learn/promote.js +1 -1
- package/dist/learn/secrets.d.ts +13 -3
- package/dist/learn/secrets.js +118 -17
- package/dist/learning-cost.d.ts +28 -23
- package/dist/learning-cost.js +19 -23
- package/dist/link-check.js +1 -1
- package/dist/live-reach.d.ts +2 -0
- package/dist/live-reach.js +2 -0
- package/dist/llms.txt +1 -1
- package/dist/marketplace.d.ts +77 -0
- package/dist/marketplace.js +224 -0
- package/dist/mcp-api-only-origins.d.ts +35 -0
- package/dist/mcp-api-only-origins.js +57 -0
- package/dist/mcp-gateway.d.ts +7 -5
- package/dist/mcp-gateway.js +9 -12
- package/dist/mcp-secret-writes.js +5 -3
- package/dist/mcp-servers-store.d.ts +28 -6
- package/dist/mcp-servers-store.js +53 -4
- package/dist/media-duration.d.ts +3 -0
- package/dist/media-duration.js +90 -9
- package/dist/micro.d.ts +2 -0
- package/dist/micro.js +2 -0
- package/dist/model-form.d.ts +5 -4
- package/dist/model-form.js +11 -7
- package/dist/model.d.ts +10 -6
- package/dist/model.js +16 -11
- package/dist/monid.d.ts +14 -1
- package/dist/monid.js +103 -26
- package/dist/ollama-provider.d.ts +7 -1
- package/dist/ollama-provider.js +14 -2
- package/dist/openapi.js +210 -37
- package/dist/otel/genai.d.ts +65 -0
- package/dist/otel/genai.js +116 -0
- package/dist/otel/tracer.d.ts +55 -0
- package/dist/otel/tracer.js +308 -0
- package/dist/page.d.ts +2 -0
- package/dist/page.js +3 -1
- package/dist/paid-calls.d.ts +1 -32
- package/dist/paid-calls.js +4 -39
- package/dist/place-offers.d.ts +4 -0
- package/dist/place-offers.js +7 -4
- package/dist/provider.d.ts +11 -2
- package/dist/provider.js +59 -8
- package/dist/redact/match.d.ts +30 -3
- package/dist/redact/match.js +422 -41
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +11 -0
- package/dist/run-census.d.ts +67 -0
- package/dist/run-census.js +240 -0
- package/dist/run-computer.d.ts +6 -3
- package/dist/run-computer.js +4 -1
- package/dist/run-cut.d.ts +15 -6
- package/dist/run-cut.js +30 -9
- package/dist/run-files.d.ts +3 -0
- package/dist/run-files.js +3 -0
- package/dist/run-launch.d.ts +12 -1
- package/dist/run-launch.js +9 -10
- package/dist/run-learning-served.d.ts +4 -2
- package/dist/run-model-key.d.ts +8 -0
- package/dist/run-model-key.js +31 -1
- package/dist/run-reads-over-store.d.ts +24 -6
- package/dist/run-reads-over-store.js +67 -23
- package/dist/run-recordings.d.ts +5 -1
- package/dist/run-recordings.js +39 -14
- package/dist/run-timeline-served.d.ts +2 -0
- package/dist/run-timeline-served.js +2 -2
- package/dist/run-usage.d.ts +1 -0
- package/dist/run-view.d.ts +1 -2
- package/dist/run-view.js +2 -1
- package/dist/runnable.d.ts +10 -1
- package/dist/runnable.js +20 -8
- package/dist/runner/adapter-loop.d.ts +11 -0
- package/dist/runner/adapter-loop.js +58 -26
- package/dist/runner/adapter-run-spec.d.ts +55 -11
- package/dist/runner/adapter-run-spec.js +183 -52
- package/dist/runner/adapters/pi.js +25 -3
- package/dist/runner/beside.d.ts +9 -2
- package/dist/runner/beside.js +27 -9
- package/dist/runner/big-writes.js +1 -10
- package/dist/runner/claim-secrets.d.ts +27 -10
- package/dist/runner/claim-secrets.js +49 -22
- package/dist/runner/cli-run-spec.d.ts +6 -0
- package/dist/runner/cli-run-spec.js +97 -38
- package/dist/runner/computer-journal.d.ts +9 -1
- package/dist/runner/computer-journal.js +26 -0
- package/dist/runner/conformance/harness.js +1 -1
- package/dist/runner/feedback-round.js +3 -0
- package/dist/runner/harness-loops.d.ts +6 -5
- package/dist/runner/harness-loops.js +7 -7
- package/dist/runner/held.d.ts +24 -6
- package/dist/runner/journal-kinds.d.ts +5 -0
- package/dist/runner/journal-kinds.js +5 -0
- package/dist/runner/main.d.ts +11 -6
- package/dist/runner/main.js +19 -9
- package/dist/runner/mcp-claim.js +31 -3
- package/dist/runner/mcp-run.d.ts +9 -0
- package/dist/runner/mcp-run.js +11 -5
- package/dist/runner/model-route.d.ts +17 -0
- package/dist/runner/model-route.js +120 -2
- package/dist/runner/presence.d.ts +11 -1
- package/dist/runner/presence.js +7 -0
- package/dist/runner/reflect-hook.js +1 -1
- package/dist/runner/run-child-host.d.ts +22 -8
- package/dist/runner/run-child-host.js +128 -41
- package/dist/runner/run-child.js +5 -2
- package/dist/runner/runner.d.ts +17 -3
- package/dist/runner/runner.js +130 -34
- package/dist/runner/save-slots.js +2 -1
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +6 -0
- package/dist/runner/store-secrets.js +49 -7
- package/dist/runner/subagent.d.ts +11 -0
- package/dist/runner/subagent.js +16 -38
- package/dist/runner/workflow-first.d.ts +35 -15
- package/dist/runner/workflow-first.js +38 -25
- package/dist/runner/workflow-spec.js +4 -3
- package/dist/runs-over-store.d.ts +15 -6
- package/dist/runs-over-store.js +33 -21
- package/dist/scrub-command.d.ts +73 -0
- package/dist/scrub-command.js +307 -0
- package/dist/secret-cut.d.ts +73 -0
- package/dist/secret-cut.js +291 -4
- package/dist/secret-rules.d.ts +143 -0
- package/dist/secret-rules.js +2564 -0
- package/dist/secrets.d.ts +7 -0
- package/dist/secrets.js +20 -0
- package/dist/server-keys.d.ts +20 -0
- package/dist/server-keys.js +25 -6
- package/dist/server.d.ts +65 -13
- package/dist/server.js +470 -157
- package/dist/skills/agentrun-serve/SKILL.md +4 -0
- package/dist/slots.d.ts +9 -0
- package/dist/slots.js +45 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +1 -1
- package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
- package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
- package/dist/store/schema.d.ts +23 -0
- package/dist/store/schema.js +58 -2
- package/dist/store/seal.d.ts +6 -1
- package/dist/store/seal.js +5 -3
- package/dist/store/sqlite/run-launch.d.ts +9 -1
- package/dist/store/sqlite/run-launch.js +24 -13
- package/dist/store/sqlite/run-patch.d.ts +12 -2
- package/dist/store/sqlite/run-patch.js +42 -5
- package/dist/store/sqlite/store.js +105 -12
- package/dist/store/store.d.ts +57 -2
- package/dist/store/store.js +20 -0
- package/dist/store-reads/learning.d.ts +84 -124
- package/dist/store-reads/learning.js +210 -274
- package/dist/store-view.d.ts +3 -0
- package/dist/store-view.js +3 -3
- package/dist/suggestions.js +3 -2
- package/dist/template-eval.d.ts +39 -9
- package/dist/template-eval.js +191 -60
- package/dist/template-import.js +6 -2
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +28 -8
- package/dist/timeline/labels.d.ts +6 -4
- package/dist/timeline/labels.js +18 -6
- package/dist/timeline/timeline.d.ts +5 -0
- package/dist/timeline/timeline.js +14 -8
- package/dist/timeline/util.js +1 -1
- package/dist/timeline/web-calls.d.ts +22 -7
- package/dist/timeline/web-calls.js +106 -35
- package/dist/tool-gate.d.ts +42 -3
- package/dist/tool-gate.js +66 -5
- package/dist/tool-keys-store.d.ts +2 -4
- package/dist/tool-keys-store.js +5 -21
- package/dist/tool-keys.d.ts +2 -2
- package/dist/tool-keys.js +2 -2
- package/dist/tool-list.js +1 -1
- package/dist/tool-plane.d.ts +2 -2
- package/dist/tool-plane.js +35 -33
- package/dist/tools.js +13 -7
- package/dist/trigger-targets.d.ts +4 -0
- package/dist/trigger-targets.js +9 -2
- package/dist/triggers.d.ts +67 -4
- package/dist/triggers.js +171 -22
- package/dist/until.d.ts +3 -0
- package/dist/until.js +11 -0
- package/dist/web-fake.d.ts +1 -3
- package/dist/web-fake.js +7 -18
- package/dist/web-fetch.d.ts +6 -72
- package/dist/web-fetch.js +11 -265
- package/dist/web-run.d.ts +31 -0
- package/dist/web-run.js +90 -0
- package/dist/web-save.d.ts +10 -13
- package/dist/web-save.js +13 -55
- package/dist/web-search.d.ts +9 -127
- package/dist/web-search.js +23 -259
- package/dist/wires.d.ts +13 -0
- package/dist/wires.js +11 -0
- package/dist/workflow-run.d.ts +5 -4
- package/dist/workflow-run.js +5 -4
- package/dist/workspace/attached-computers.d.ts +32 -9
- package/dist/workspace/attached-computers.js +77 -13
- package/dist/workspace/computer-deps.d.ts +8 -2
- package/dist/workspace/computer-deps.js +10 -3
- package/dist/workspace/computer-for-claim.d.ts +12 -1
- package/dist/workspace/computer-for-claim.js +83 -11
- package/dist/workspace/computer-kept.d.ts +3 -0
- package/dist/workspace/computer-kept.js +11 -2
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/kind-skills.d.ts +4 -0
- package/dist/workspace/kind-skills.js +9 -0
- package/dist/workspace/paired-route.d.ts +91 -0
- package/dist/workspace/paired-route.js +153 -0
- package/dist/workspace/synced-folder.js +3 -4
- package/dist/wrapped.d.ts +20 -6
- package/dist/wrapped.js +66 -25
- package/package.json +17 -11
- package/skills/agentrun-serve/SKILL.md +4 -0
- package/templates/README.md +32 -10
- package/dist/console/assets/index-CQ3cJRzI.js +0 -746
- package/dist/console/assets/index-DKkaS3a0.css +0 -1
- package/dist/exa-keyless.d.ts +0 -34
- package/dist/exa-keyless.js +0 -118
- package/dist/firecrawl-keyless.d.ts +0 -41
- package/dist/firecrawl-keyless.js +0 -152
- package/dist/keyless-mcp.d.ts +0 -36
- package/dist/keyless-mcp.js +0 -127
- package/dist/text-urls.d.ts +0 -38
- package/dist/text-urls.js +0 -170
- package/dist/web-fetch-direct.d.ts +0 -119
- package/dist/web-fetch-direct.js +0 -190
package/dist/server.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { modelsInFlight } from "./in-flight.js";
|
|
1
2
|
import { CALLS_PAGE_ROWS } from "./timeline/index.js";
|
|
2
3
|
import { prepareProjectSkillEdit } from "./source-sync/skill-edits.js";
|
|
3
4
|
import { sourceSyncOf } from "./source-sync/types.js";
|
|
@@ -26,12 +27,13 @@ import { isNativeRuntime, NATIVE_RUNTIME_FACTS } from "./native/runtimes.js";
|
|
|
26
27
|
import { connectNative, launchNative, updateNative, verifyConnection } from "./native/connection.js";
|
|
27
28
|
// The /v2 API over the agent store in a data directory: the contract agentrun.v2/0, served on loopback with a bearer
|
|
28
29
|
// token.
|
|
29
|
-
import { createHash, createHmac, randomBytes } from "node:crypto";
|
|
30
|
+
import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
30
31
|
import { chmod, lstat, mkdir, readFile, realpath, rename, stat, writeFile } from "node:fs/promises";
|
|
31
32
|
import { createServer } from "node:http";
|
|
32
33
|
import proxyaddr from "proxy-addr";
|
|
33
|
-
import { API_ONLY_HOOKED_KINDS, apiOnlyRefusal, apiOnlyTriggerSkipped, servedApiOnly } from "./api-only.js";
|
|
34
|
-
import { RUN_KEYS_ENV } from "./env-switch.js";
|
|
34
|
+
import { API_ONLY_HOOKED_KINDS, apiOnlyMcpSave, apiOnlyRefusal, apiOnlyTriggerSkipped, servedApiOnly } from "./api-only.js";
|
|
35
|
+
import { API_ONLY_MCP_ORIGINS_ENV, apiOnlyMcpOriginsFrom, RUN_KEYS_ENV } from "./env-switch.js";
|
|
36
|
+
import { holdApiOnlyMcpOrigins, offApiOnlyMcpServers } from "./mcp-api-only-origins.js";
|
|
35
37
|
import { declaredKeys, keysOwed, keysOwedRefusal, runKeysOf, runKeysTriggerSkipped, undeclaredKeys, withCarried } from "./run-keys.js";
|
|
36
38
|
import { capacityOverStore, capacityWindowOf } from "./capacity.js";
|
|
37
39
|
import { carriedFields } from "./answer-json.js";
|
|
@@ -48,17 +50,15 @@ import { uuidv7 } from "./ids.js";
|
|
|
48
50
|
import { agentRevision, agentRevisions, agentView, commitAgent, createAgent, definitionOf, etagOf, externalKey, getAgent, listAgents, makeRevision, ownedElsewhere, refuseExternal, revisionView, setAgentArchived, setCurrentRevision } from "./agents-store.js";
|
|
49
51
|
import { WORKFLOW_ADAPTERS } from "./runner/workflow-adapters.js";
|
|
50
52
|
import { DECISION_ADAPTER, decisionsOf, FAUX_JEV_ENV, FAUX_OPENROUTER_ENV, FAUX_PARALLEL_ENV, fauxFetch } from "./decisions.js";
|
|
51
|
-
import { FAUX_WEB_ENV } from "./web-
|
|
52
|
-
import { FAUX_MONID_ENV, MONID_KEY_ENV, pinMonid, PRICED_BY_USAGE } from "./monid.js";
|
|
53
|
-
import { FAUX_EXA_ENV } from "./exa-keyless.js";
|
|
54
|
-
import { FAUX_FIRECRAWL_ENV } from "./firecrawl-keyless.js";
|
|
53
|
+
import { FAUX_EXA_ENV, FAUX_FIRECRAWL_ENV, FAUX_WEB_ENV } from "./web-run.js";
|
|
54
|
+
import { FAUX_MONID_ENV, MONID_KEY_ENV, monidReads, pinMonid, PRICED_BY_USAGE } from "./monid.js";
|
|
55
55
|
import { FAUX_BROWSER_ENV, NODE_TOOLS, shellTools, toolingOf, toolOf, toolsView } from "./tools.js";
|
|
56
56
|
import { ApiError, invalid, sentence, unsupported } from "./errors.js";
|
|
57
57
|
import { deref, explain } from "./explain.js";
|
|
58
58
|
import { HOME_HOST_OWNED } from "./files.js";
|
|
59
59
|
import { DATA_ENV, syncDir, TOKEN_FILE, writeDurable } from "./server-fs.js";
|
|
60
60
|
import { homePath, hostOwnedOf } from "./home-path.js";
|
|
61
|
-
import { asksOllama, chooseModel, EFFORTS, FAUX_ENV,
|
|
61
|
+
import { asksOllama, chooseModel, EFFORTS, FAUX_ENV, hostModel, MODEL_NODES, modelSource, THINKING_LEVELS, unpricedModels, withoutFaux } from "./model.js";
|
|
62
62
|
import { DEFAULT_HARNESS, HARNESSES, harnessOfBody, harnessOffers } from "./harness.js";
|
|
63
63
|
import { HARNESS_MODULES_ENV, HARNESS_MODULES_SETTING, HARNESS_RECIPES_ENV, HARNESS_RECIPES_SETTING, HARNESS_TABLE_ENV, harnessIds, harnessModulesEnv, harnessOf, harnessRecipesEnv, planRecipesOf, recipeHarness, tableIds } from "./harness-table.js";
|
|
64
64
|
import { claudeCliIn, HarnessInstall, installDirOf, NPM_STOP_GRACE_MS, npmInstall } from "./harness-install.js";
|
|
@@ -76,6 +76,7 @@ import { boxAvailability, boxesLine, defaultPlaceOf, NEW_AGENT_TOOLS, newAgentPl
|
|
|
76
76
|
import { boxAllowOf, boxAllowSetIn } from "./box-settings.js";
|
|
77
77
|
import { dockerLimitsOf } from "./workspace/computer-deps.js";
|
|
78
78
|
import { Owner, passwordProblem, SESSION_MS } from "./owner.js";
|
|
79
|
+
import { API_KEYS_LIMIT, ApiKeys } from "./api-keys.js";
|
|
79
80
|
import { acceptedTokens, bearerCheck, tokenProblem } from "./api-token.js";
|
|
80
81
|
import { answerPage, byConsoleSession, byOwnerSession, ConsoleSessions, consoleEntry, heldSessions, isJson, overHttps, ownerCookie, ownerCookieName, ownOrigin, sessionsAtEveryPort, sendHostRefused, sendMoved, sendMovedPage, signedIn } from "./page.js";
|
|
81
82
|
import { hostFix, hostName, isLoopbackName, loopbackNames, movedFix } from "./host-check.js";
|
|
@@ -101,7 +102,7 @@ import { servedTimelineRows } from "./run-timeline-served.js";
|
|
|
101
102
|
import { servedRunTrace } from "./run-trace.js";
|
|
102
103
|
import { servedRunUsage } from "./run-usage.js";
|
|
103
104
|
import { servedRunDiff, servedRunLearning } from "./run-learning-served.js";
|
|
104
|
-
import { agentPointers, WITHHELD_LEARNING } from "./handed-values.js";
|
|
105
|
+
import { agentPointers, cutHanded, handedSecretValues, launchValuesOf, RETIRED_MAX, retiredValues, WITHHELD_LEARNING, WITHHELD_MESSAGE } from "./handed-values.js";
|
|
105
106
|
import { runCutValues } from "./run-cut.js";
|
|
106
107
|
import { readLaunchBody } from "./run-launch.js";
|
|
107
108
|
import { modelKeyMisfit, modelKeyOf, modelKeyRequired, noServerKeyFor, runModelOrigin, serverKeyMissing } from "./run-model-key.js";
|
|
@@ -127,7 +128,7 @@ import { championOf, forgetRunCopies, GRADE_SOURCES, gradeView, LABEL_MAX, promo
|
|
|
127
128
|
import { workflowNodesOf } from "./learn/workflow-nodes.js";
|
|
128
129
|
import { deleteLearning } from "./learn/delete.js";
|
|
129
130
|
import { runModelRef } from "./model.js";
|
|
130
|
-
import { ollamaHostOf, ollamaHostRefused, ollamaListing, ollamaModels } from "./ollama-provider.js";
|
|
131
|
+
import { ollamaHostOf, ollamaHostRefused, ollamaListing, ollamaModels, ollamaReading } from "./ollama-provider.js";
|
|
131
132
|
import { REDACTED } from "./secret-cut.js";
|
|
132
133
|
// The v2 run statuses, as the run view names them (run-view.ts Status), for the list filter's validation. */
|
|
133
134
|
const STATUSES = ["queued", "working", "paused", "input_required", "completed", "failed", "cancelled"];
|
|
@@ -137,20 +138,22 @@ import { dockerComputerRefusal, dockerPathsOf, FAUX_MOUNTINFO_ENV, remoteDockerO
|
|
|
137
138
|
import { dockerDaemonCheck } from "./docker-daemon.js";
|
|
138
139
|
import { hostAddressesOnce, noHostAddresses, retryHostAddresses, unionOf } from "./docker-host-addresses.js";
|
|
139
140
|
import { DOCUMENTS_ENV } from "./pdf-pages.js";
|
|
140
|
-
import { blockersOf, CODE_NODES_ENV, issueOf, NOT_SET_UP } from "./runnable.js";
|
|
141
|
+
import { blockersOf, CODE_NODES_ENV, deniedComputer, issueOf, NOT_SET_UP } from "./runnable.js";
|
|
142
|
+
import { computerDeniedWords } from "./refusal-words.js";
|
|
141
143
|
import { hostSecrets, SECRET_NAMES, secret, withSecrets } from "./secrets.js";
|
|
142
144
|
import { isSecretWriteOperation, secretPageFor, secretsWritableFields, secretWriteRefusal, secretWriterFacts, writesSecretFor, writesSecretsAllowed } from "./secret-writes.js";
|
|
143
145
|
import { ChatGPTPlan, planOf, PlanSignInRefused, SIGN_OUT_UNCONFIRMED, withPlan } from "./chatgpt-plan.js";
|
|
144
146
|
import { modelGatewayRoute, readSavedGateway, withSavedGateway } from "./model-gateway.js";
|
|
145
|
-
import { CLAUDE_LOGIN_ROUTES, ClaudeLoginRefused, claudeLoginOf, claudeLoginRouteOff, claudeLoginSwitchedOff, claudeLoginSetting, claudeLoginView, dropRefusedLogin, envAtPlace, LOGIN_HARNESS, loginOf, loopback, startLoginHere, turnOffClaudeLogin, turnOnClaudeLogin,
|
|
147
|
+
import { CLAUDE_LOGIN_ROUTES, LOGIN_REFUSES_API_KEYS, oneOwnerDeps, ClaudeLoginRefused, claudeLoginOf, claudeLoginRouteOff, claudeLoginSwitchedOff, claudeLoginSetting, claudeLoginView, dropRefusedLogin, envAtPlace, homeOf, LOGIN_HARNESS, loginOf, loginOnRunnerOnly, loopback, startLoginHere, turnOffClaudeLogin, turnOnClaudeLogin, withClaudeLogin } from "./claude-login.js";
|
|
146
148
|
import { ClaudeSignIns } from "./claude-sign-in.js";
|
|
147
149
|
import { bootSealKey, parametersDigest, withSealKey } from "./seal-key.js";
|
|
148
150
|
import { ServerLockHeldError, takeServerLock } from "./server-lock.js";
|
|
149
151
|
import { recordDataRoot } from "./runner/disk-free.js";
|
|
150
152
|
import { recordRunEnv, runFacingNames } from "./runner/runner-check.js";
|
|
151
153
|
import { DRAIN_TIMEOUT } from "./runner/beside.js";
|
|
154
|
+
import { runnerName } from "./runner/runner.js";
|
|
152
155
|
import { analyticsFilter, analyticsView, statsView } from "./stats.js";
|
|
153
|
-
import {
|
|
156
|
+
import { loggedReads, within, WRAPPED_WAIT_MS, wrappedView } from "./wrapped.js";
|
|
154
157
|
import { joinedBasis } from "./runner/metrics.js";
|
|
155
158
|
import { unifiedUsage } from "./unified-usage.js";
|
|
156
159
|
import { agentLoopOverStore } from "./store-reads/loop.js";
|
|
@@ -164,7 +167,7 @@ import { SIGN_INS_DIR, vendorsOver } from "./sign-ins.js";
|
|
|
164
167
|
import { signInsOverStore } from "./sign-ins-store.js";
|
|
165
168
|
import { boundTool, MCP_AUTH_TYPES, marked, mcpAuthOf, nameOf as mcpNameOf } from "./mcp-probe.js";
|
|
166
169
|
import { composioEnvKey, composioMadeKey, composioPerRun } from "./composio-made.js";
|
|
167
|
-
import { COMPOSIO_PER_RUN, composioForget, composioNote, composioSave, composioTools } from "./composio-preset.js";
|
|
170
|
+
import { COMPOSIO_PER_RUN, composioForget, composioNote, composioSave, composioToolkits, composioTools } from "./composio-preset.js";
|
|
168
171
|
import { ComposioTriggers, composioNoPublicUrl } from "./composio-triggers.js";
|
|
169
172
|
import { loopbackWords, mcpServersOverStore } from "./mcp-servers-store.js";
|
|
170
173
|
import { MCP_ALLOW_LOOPBACK_ENV, startSwitches, WEBHOOK_PRIVATE_TARGETS_ENV } from "./start-switches.js";
|
|
@@ -191,10 +194,11 @@ import { webhook } from "./trigger-webhook.js";
|
|
|
191
194
|
import { SCHEME_NAMES } from "./trigger-signatures.js";
|
|
192
195
|
import { permissionFrom, pinnedEffect, toolEffect } from "./tool-gate.js";
|
|
193
196
|
import { mcpNameOf as mcpToolOf, mcpToolName } from "./tool-names.js";
|
|
194
|
-
import { CATCHUP_WINDOW_S, FAILURES_TO_PAUSE, HISTORY_KEPT, MIN_EVERY_S, SOURCE_KINDS, TARGET_KINDS, Triggers } from "./triggers.js";
|
|
197
|
+
import { CATCHUP_WINDOW_S, FAILURES_TO_PAUSE, HISTORY_KEPT, MIN_EVERY_S, RELEASE_WORDS_MAX, SOURCE_KINDS, TARGET_KINDS, Triggers } from "./triggers.js";
|
|
195
198
|
import { PAYLOAD_KEPT_BYTES } from "./trigger-adapter.js";
|
|
196
199
|
import { applyBodyOf, choiceUnrunnable, COMPOSIO_TRIGGER_FIX, composioTriggerSkipped, COMPUTER_FIX, compiled, feedLeftEmpty, feedTriggerEmpty, githubTriggerUnconnected, githubTriggerWords, madeTriggerIssues, mcpSetUp, onServerName, onServers, packageDetail, packageModel, packageTiers, packageView, pickComputer, readPackages, notSetUpYet, serversFor, TemplateRegistry } from "./templates.js";
|
|
197
200
|
import { applyImported, deleteTemplate, dropRemovedUploads, importTemplate, loadImported, UPLOAD_PREFIX } from "./template-import.js";
|
|
201
|
+
import { hereOf, Marketplace, marketplaceUrlOf } from "./marketplace.js";
|
|
198
202
|
import { templateInstallLink, templateLink, templatesLink } from "./console-links.js";
|
|
199
203
|
import { GITHUB_HOSTS, IMPORT_LIMITS } from "./template-source.js";
|
|
200
204
|
import { checkDefinitionBody, DEFAULT_INPUT_SCHEMA, definitionBodyIssues, EXTERNAL_NAME, ID, IDEMPOTENCY_TTL_S, inputIssues, inputSchemaOf, isObject, stable, unknownFields } from "./validate.js";
|
|
@@ -212,8 +216,10 @@ import { COMPUTER_ROUTES, computerHoldOf, computerRoute, runComputerKind } from
|
|
|
212
216
|
import { runOver } from "./computer-commands.js";
|
|
213
217
|
import { mintViewerCredential, VIEWER_PARAM, viewerCookie, viewerCredentialFor, viewerCredentialKey, viewerCredentialOf } from "./viewer-credential.js";
|
|
214
218
|
import { ATTACH_PATH, AttachHub, PROVIDERS as COMPUTER_PROVIDERS, SETTING_KINDS, servingRefusals } from "@parcha/agentrun-computer";
|
|
219
|
+
import { dockerDaemonOf } from "@parcha/agentrun-computer/docker";
|
|
215
220
|
import { createAttachRoutes, liveRelays, pairedView } from "./computer-attach.js";
|
|
216
221
|
import { pairedRefusal, withPaired } from "./workspace/attached-computers.js";
|
|
222
|
+
import { PAIRED_ROUTE_MS, readRoute } from "./workspace/paired-route.js";
|
|
217
223
|
import { COMPUTER_TOOLS, hostToolDefs } from "@parcha/agentrun-kernel/kernel";
|
|
218
224
|
import { freeModelRequestsOf } from "@parcha/agentrun-kernel/kernel/cap";
|
|
219
225
|
import { archilRoute, createArchilRoutes, liveRunsOnDisk } from "./archil-routes.js";
|
|
@@ -232,8 +238,10 @@ import { resetLearning } from "./learning-reset.js";
|
|
|
232
238
|
import { agentComputerHoldKey } from "./workspace/agent-computer.js";
|
|
233
239
|
import { sdkRunKey } from "./sdk/runs.js";
|
|
234
240
|
import { waitEndedKey } from "./browser-wait-ended.js";
|
|
241
|
+
import { browserHoldKey } from "./browser-hold.js";
|
|
235
242
|
import { agentComputerOf, agentComputerView, agentDirName, agentFolder, agentHomeFolder, claimKinds, runFolder, scratchFolder, computerProviderFactories, computerProviderMakers, computerReadiness, dockerHostAddressesOf, isWorkspaceError, localWorkspace, reconcileAgentComputer, registryHere, runShellOf, serverRunWorkspace, storeLedger } from "./workspace/index.js";
|
|
236
243
|
import { keyReader } from "./key-meta.js";
|
|
244
|
+
import { redacted } from "./key-refusal.js";
|
|
237
245
|
export const CONTRACT = "agentrun.v2/0";
|
|
238
246
|
/** A process's flags for a worker of it: without --input-type and the code string given with -e, --eval, -p or --print. */
|
|
239
247
|
const workerArgs = (args) => args.filter((arg, i) => !arg.startsWith("--input-type") && !/^(?:-e|--eval|-p|--print)(?:=|$)/.test(arg) && !/^(?:-e|--eval|-p|--print)$/.test(args[i - 1] ?? ""));
|
|
@@ -277,7 +285,7 @@ const HOME_WRITES_OFF = "This server can't write a home's files safely here: a w
|
|
|
277
285
|
const LINK_REFUSED = "A link is on the way to this path, or is the file: this server follows none.";
|
|
278
286
|
/** Each test switch a run's process reads, by the variable it reads it from: set only under `faux`, but the faux
|
|
279
287
|
* harness's, which scripts the harnesses with or without it. */
|
|
280
|
-
const FAUX_SWITCHES = [["fauxBrowser", FAUX_BROWSER_ENV], ["fauxWeb", FAUX_WEB_ENV], ["fauxJev", FAUX_JEV_ENV], ["fauxParallel", FAUX_PARALLEL_ENV], ["fauxOpenrouter", FAUX_OPENROUTER_ENV], ["fauxMonid", FAUX_MONID_ENV], ["
|
|
288
|
+
const FAUX_SWITCHES = [["fauxBrowser", FAUX_BROWSER_ENV], ["fauxWeb", FAUX_WEB_ENV], ["fauxJev", FAUX_JEV_ENV], ["fauxParallel", FAUX_PARALLEL_ENV], ["fauxOpenrouter", FAUX_OPENROUTER_ENV], ["fauxMonid", FAUX_MONID_ENV], ["fauxExa", FAUX_EXA_ENV]];
|
|
281
289
|
/** The switches a run's process gets, each module path resolved: the owner's harness modules (harnessModules), and the test
|
|
282
290
|
* switches, which are empty outside tests. A test's in-process runner takes the same (test/support.mjs
|
|
283
291
|
* startInProcessRunner). */
|
|
@@ -482,6 +490,7 @@ export const ROUTES = [
|
|
|
482
490
|
{ method: "GET", pattern: /^\/settings\/mcp-server-names$/, name: "listMcpServerNames" },
|
|
483
491
|
{ method: "POST", pattern: /^\/settings\/mcp-servers\/preview$/, name: "previewMcpServer" },
|
|
484
492
|
{ method: "POST", pattern: /^\/settings\/mcp-servers\/composio\/tools$/, name: "listComposioTools" },
|
|
493
|
+
{ method: "POST", pattern: /^\/settings\/mcp-servers\/composio\/toolkits$/, name: "listComposioToolkits" },
|
|
485
494
|
{ method: "GET", pattern: /^\/settings\/mcp-servers\/([^/]+)$/, name: "getMcpServer" },
|
|
486
495
|
{ method: "PUT", pattern: /^\/settings\/mcp-servers\/([^/]+)$/, name: "saveMcpServer" },
|
|
487
496
|
{ method: "PUT", pattern: /^\/settings\/mcp-servers\/([^/]+)\/composio$/, name: "saveComposioServer" },
|
|
@@ -502,6 +511,11 @@ export const ROUTES = [
|
|
|
502
511
|
{ method: "PUT", pattern: /^\/settings\/mcp-servers\/oauth\/private-hosts$/, name: "putMcpPrivateHosts" },
|
|
503
512
|
{ method: "GET", pattern: /^\/settings\/tools$/, name: "getToolSettings" },
|
|
504
513
|
{ method: "PUT", pattern: /^\/settings\/tools$/, name: "putToolSettings" },
|
|
514
|
+
// The API keys a person makes for their apps (api-keys.ts): a read with any token; making and revoking one are secret
|
|
515
|
+
// writes, so the one secret-write check takes them from the owner's session alone.
|
|
516
|
+
{ method: "GET", pattern: /^\/settings\/api-keys$/, name: "listApiKeys" },
|
|
517
|
+
{ method: "POST", pattern: /^\/settings\/api-keys$/, name: "createApiKey" },
|
|
518
|
+
{ method: "DELETE", pattern: /^\/settings\/api-keys\/([^/]+)$/, name: "revokeApiKey" },
|
|
505
519
|
{ method: "GET", pattern: /^\/settings\/webhook$/, name: "getWebhook" },
|
|
506
520
|
{ method: "PUT", pattern: /^\/settings\/webhook$/, name: "saveWebhook" },
|
|
507
521
|
{ method: "DELETE", pattern: /^\/settings\/webhook$/, name: "deleteWebhook" },
|
|
@@ -522,9 +536,11 @@ export const ROUTES = [
|
|
|
522
536
|
{ method: "DELETE", pattern: /^\/triggers\/([^/]+)$/, name: "deleteTrigger" },
|
|
523
537
|
{ method: "POST", pattern: /^\/triggers\/([^/]+)\/fire$/, name: "fireTrigger" },
|
|
524
538
|
{ method: "GET", pattern: /^\/triggers\/([^/]+)\/firings$/, name: "listTriggerFirings" },
|
|
539
|
+
{ method: "POST", pattern: /^\/triggers\/([^/]+)\/firings\/([^/]+)\/release$/, name: "releaseTriggerFiring" },
|
|
525
540
|
{ method: "POST", pattern: /^\/triggers\/([^/]+)\/secret$/, name: "rotateTriggerSecret" },
|
|
526
541
|
{ method: "GET", pattern: /^\/templates$/, name: "listTemplates" },
|
|
527
542
|
{ method: "POST", pattern: /^\/templates\/import$/, name: "importTemplate" },
|
|
543
|
+
{ method: "GET", pattern: /^\/marketplace\/templates$/, name: "listMarketplaceTemplates" },
|
|
528
544
|
{ method: "GET", pattern: /^\/templates\/([^/]+)$/, name: "getTemplate" },
|
|
529
545
|
{ method: "DELETE", pattern: /^\/templates\/([^/]+)$/, name: "deleteTemplate" },
|
|
530
546
|
{ method: "POST", pattern: /^\/templates\/([^/]+)\/apply$/, name: "applyTemplate" },
|
|
@@ -640,7 +656,7 @@ const GATEWAY_VARS = ["AGENT_MODEL_BASE_URL", "AGENT_MODEL_GATEWAY_IDS", "AGENT_
|
|
|
640
656
|
* saved key is one of those; the rest of the environment is the server's start's), and the models the Ollama here
|
|
641
657
|
* listed when last asked (ollamaListing). Held to tell whether a write, or a new listing, needs the offers probed again,
|
|
642
658
|
* never shown. */
|
|
643
|
-
const offersInputs = (env) => [...SECRET_NAMES.filter((name) => !TOOL_FIELDS.includes(name)).map((name) => env[name]), ...GATEWAY_VARS.map((name) => env[name]), planOf(env)?.state, planOf(env)?.models.join(" "), claudeLoginOf(env)
|
|
659
|
+
const offersInputs = (env) => [...SECRET_NAMES.filter((name) => !TOOL_FIELDS.includes(name)).map((name) => env[name]), ...GATEWAY_VARS.map((name) => env[name]), planOf(env)?.state, planOf(env)?.models.join(" "), ...[claudeLoginOf(env)].map((login) => (login && "dir" in login ? login.dir : undefined)), ollamaListing(env)];
|
|
644
660
|
/** A sign-in step's answer; its refusal (a stale or bad pasted address, no sign-in waiting, OpenAI's no) a 400 in words. */
|
|
645
661
|
async function planStep(step) {
|
|
646
662
|
try {
|
|
@@ -653,11 +669,14 @@ async function planStep(step) {
|
|
|
653
669
|
}
|
|
654
670
|
}
|
|
655
671
|
async function needsOf(env) {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
672
|
+
// A reading no run waits on, as the offers are (ollamaReading): a key's save never waits on a stuck Ollama's /api/show.
|
|
673
|
+
return ollamaReading(async () => {
|
|
674
|
+
const chosen = await chooseModel(env, undefined);
|
|
675
|
+
const learning_model = await learningModelOf(env);
|
|
676
|
+
if ("why" in chosen)
|
|
677
|
+
return { needs: chosen.needs, priced: null, learning_model };
|
|
678
|
+
return { needs: null, priced: (await unpricedModels(env, undefined)).length === 0, learning_model };
|
|
679
|
+
});
|
|
661
680
|
}
|
|
662
681
|
/** The server's reading of `base`, whole: its secrets, saved keys among them (`env`), the harnesses' offers, probed from
|
|
663
682
|
* env without the tool keys (offersEnvOf), and its capabilities made from both under its learning switch (`learning`,
|
|
@@ -779,18 +798,25 @@ function capabilitiesWith(env, maxRuns, harnesses, learning, { needs, priced, le
|
|
|
779
798
|
* (tool-keys-store.ts), never in the clear. */
|
|
780
799
|
tool_keys: { routes: true, at_rest: "sealed" },
|
|
781
800
|
/** GET /settings/harness-keys and PUT/DELETE of one key: a plan-billed recipe's keys, saved for that harness alone
|
|
782
|
-
* (harness-keys.ts); `harnesses` its ids here,
|
|
783
|
-
|
|
801
|
+
* (harness-keys.ts); `harnesses` its ids here, and `kept` each id with keys saved whose recipe it no longer names
|
|
802
|
+
* (a running server's, from its store: HarnessKeysOverStore.unnamed), so the console offers the page only where
|
|
803
|
+
* there is one or a key to remove. */
|
|
804
|
+
harness_keys: { routes: true, at_rest: "sealed", harnesses: planRecipesOf(env).map((recipe) => recipe.id), kept: [] },
|
|
784
805
|
/** /settings/mcp-servers: remote MCP servers previewed and saved, each credential sealed under the server's seal key,
|
|
785
806
|
* which always exists (seal-key.ts), so MCP credentials are always kept sealed. Every harness of the table runs a
|
|
786
|
-
* grant (runnable.ts takes one on any), a module's among them.
|
|
787
|
-
|
|
807
|
+
* grant (runnable.ts takes one on any), a module's among them. `composio_per_run`: a per-run Composio server takes
|
|
808
|
+
* each run's own Composio account (mcp_auth's ComposioRunBinding, composioperrun/1), said here so a backend in
|
|
809
|
+
* front learns it from this answer, which an API-only server serves, not from the API document, which it refuses. */
|
|
810
|
+
mcp_client: { transports: ["streamable-http"], auth: [...MCP_AUTH_TYPES], at_rest: "sealed", harnesses: [...harnessIds(env)], composio_per_run: true },
|
|
788
811
|
/** This server's learning switch (`--learning`): on, a run learns when its agent says `learning: true`; off, none does. */
|
|
789
812
|
learning,
|
|
790
813
|
/** /settings/webhook: one URL POSTed, signed by the Standard Webhooks spec, when a run needs its person and when it
|
|
791
814
|
* ends (webhooks.ts); its secret kept sealed under the same seal key. */
|
|
792
815
|
// Always sealed: the server starts with its seal key (seal-key.ts bootSealKey), so nothing is kept in the clear.
|
|
793
816
|
webhooks: { routes: true, events: [...WEBHOOK_EVENTS], signing: "standard-webhooks/v1", at_rest: "sealed" },
|
|
817
|
+
/** /settings/api-keys: the keys a person makes in the console for their apps (api-keys.ts), each shown once and
|
|
818
|
+
* kept as a keyed hash alone; `limit`, the most a server keeps. */
|
|
819
|
+
api_keys: { routes: true, limit: API_KEYS_LIMIT, at_rest: "hashed" },
|
|
794
820
|
/** /settings/slack: one Slack incoming-webhook URL each of `events` is posted to as a readable message (slack.ts); the
|
|
795
821
|
* URL kept sealed, never shown. */
|
|
796
822
|
slack: { routes: true, events: [...SLACK_EVENTS], at_rest: "sealed" },
|
|
@@ -849,6 +875,8 @@ function integerParam(value, name, max) {
|
|
|
849
875
|
throw new ApiError("bad_request", `${name} is an integer from 0 to ${max}`);
|
|
850
876
|
return Number(value);
|
|
851
877
|
}
|
|
878
|
+
/** Why a server started on its owner's own sign-in makes no API key for an app, in one line. */
|
|
879
|
+
export const HARNESS_SIGN_IN_REFUSES_API_KEYS = "This server runs on its owner's own sign-in (--harness-sign-in), which is one person's: it creates no API key for an app, and a key created before opens nothing here. Revoke the ones listed that you no longer want.";
|
|
852
880
|
/** A start with --harness-sign-in on a server that is not one owner's own, on their own machine. */
|
|
853
881
|
export const HARNESS_SIGN_IN_NOT_LOCAL = "HARNESS_SIGN_IN_NOT_LOCAL";
|
|
854
882
|
/** Why `options` on `data` is not one owner's own server on their own machine, each reason in words; none when it is. One
|
|
@@ -859,6 +887,17 @@ export const HARNESS_SIGN_IN_NOT_LOCAL = "HARNESS_SIGN_IN_NOT_LOCAL";
|
|
|
859
887
|
* starts under (harnessSignInRefusal), and where the Ollama at this machine's default address is a model of the person
|
|
860
888
|
* who starts runs (ollama-provider.ts ollamaHostOf). */
|
|
861
889
|
export function whyNotOwnMachine(options, data, ownUser) {
|
|
890
|
+
return [
|
|
891
|
+
...whyNotOwnersServer(options, data),
|
|
892
|
+
...(options.runnerApart ? ["runs no runner beside it (--no-runner)"] : []),
|
|
893
|
+
...(ownUser ? [] : ["runs each run as a user of its own (unset AGENTRUN_RUN_USER=slot, or set AGENTRUN_RUN_USER=same)"]),
|
|
894
|
+
];
|
|
895
|
+
}
|
|
896
|
+
/** Why `options` on `data` is not one owner's server on their own machine as far as who reaches it goes, each reason in
|
|
897
|
+
* words: whyNotOwnMachine's facts but its runner's. What may read this machine's own files for whoever asks (GET
|
|
898
|
+
* /v2/wrapped). `keys`: the live API keys made in the console (api-keys.ts), each one more caller, as a second token is
|
|
899
|
+
* (claude-login.ts whyNotOneOwner counts them too); 0 where none can open the server. */
|
|
900
|
+
export function whyNotOwnersServer(options, data, keys = 0) {
|
|
862
901
|
const host = options.host ?? DEFAULT_HOST;
|
|
863
902
|
// Every token the server takes (acceptedTokens): AGENTRUN_TOKEN's as `default` beside the list's, or else DIR/.token's alone.
|
|
864
903
|
const tokens = (options.token === undefined ? 0 : 1) + (options.tokens?.length ?? 0);
|
|
@@ -867,9 +906,8 @@ export function whyNotOwnMachine(options, data, ownUser) {
|
|
|
867
906
|
...(options.publicUrl ? [`has a public address (${options.publicUrl})`] : []),
|
|
868
907
|
...(options.apiOnly ? ["has no owner (the API-only profile), so anyone with its token starts runs"] : []),
|
|
869
908
|
...(tokens > 1 ? [`takes ${tokens} API tokens (AGENTRUN_TOKEN and AGENTRUN_TOKENS together), so more than one person starts runs`] : []),
|
|
909
|
+
...(keys > 0 ? [`has ${keys === 1 ? "an API key" : `${keys} API keys`} made for apps (Settings → AgentRun API keys), so more than one caller reaches it`] : []),
|
|
870
910
|
...(storeTarget(data).kind === "sqlite" ? [] : ["keeps its store in Postgres (AGENTRUN_STORE_URL), which servers elsewhere share"]),
|
|
871
|
-
...(options.runnerApart ? ["runs no runner beside it (--no-runner)"] : []),
|
|
872
|
-
...(ownUser ? [] : ["runs each run as a user of its own (unset AGENTRUN_RUN_USER=slot, or set AGENTRUN_RUN_USER=same)"]),
|
|
873
911
|
];
|
|
874
912
|
}
|
|
875
913
|
/** Why `options` on `data` may not run a recipe on its owner's own sign-in (--harness-sign-in), in words; undefined when
|
|
@@ -1040,6 +1078,8 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1040
1078
|
// The packages served: the bundled ones, read and checked before the start, and those imported here, which the store
|
|
1041
1079
|
// keeps and are checked again as they load (template-import.ts). One that no longer checks is left out, said in the log.
|
|
1042
1080
|
const registry = new TemplateRegistry(templates);
|
|
1081
|
+
// The marketplace's list (marketplace.ts), read when the console or a caller asks for it, never at the start.
|
|
1082
|
+
const marketplace = new Marketplace(options.marketplace !== undefined ? options.marketplace : marketplaceUrlOf(process.env, Boolean(options.faux)));
|
|
1043
1083
|
await loadImported({ registry, store }, (id, why) => log?.(logLine("template_import_skipped", { template: id, why })));
|
|
1044
1084
|
stopObservationRetention = await maintainObservations(new Observations(store), {
|
|
1045
1085
|
onError: () => { process.stderr.write("agentrun-serve: observation retention failed; retrying on the next sweep\n"); },
|
|
@@ -1048,6 +1088,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1048
1088
|
// which the runner beside the server shares (Serve.attachHub), so one process holds them. A second server on this
|
|
1049
1089
|
// store is refused above (its owner lock).
|
|
1050
1090
|
const attachHub = new AttachHub();
|
|
1091
|
+
// The runner beside this server, as its run's route of a paired box names it (Serve.beside): a new name and
|
|
1092
|
+
// incarnation at each start, so a route an earlier start's runner left names a runner that is gone, and goes stale.
|
|
1093
|
+
const beside = { runner: runnerName(), incarnation: randomUUID() };
|
|
1051
1094
|
// The data root's own lock, once the store is held (so a deploy on Postgres waits at the store's owner lock first): the
|
|
1052
1095
|
// store's lock holds one store, but the data root also holds what the server writes beside it (its token, its seal key,
|
|
1053
1096
|
// uploads, harness installs, learning folders), which two servers on two stores (two Postgres schemas, or SQLite and
|
|
@@ -1091,12 +1134,26 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1091
1134
|
// the proxy's proof under the seal key (live-reach.ts); any other host is never dialled. A hosted machine a runner in a
|
|
1092
1135
|
// process of its own made is relayed to that runner's attach listener the same way (dial-relay.ts).
|
|
1093
1136
|
const reach = liveReachOf(process.env, seal.key);
|
|
1137
|
+
// A runner in a process of its own that relays its dials (dial-relay.ts): one whose attach listener said it is there
|
|
1138
|
+
// within PRESENCE_STALE_MS on the store's clock (liveRelays), at a host this server dials.
|
|
1139
|
+
const relayedNow = async () => (await liveRelays(store.runners)).some((row) => dialHost(row.host, reach) !== undefined);
|
|
1140
|
+
const attachLog = (event, fields) => (log ? log(logLine(event, fields)) : void process.stderr.write(`agentrun-serve: ${logLine(event, fields)}\n`));
|
|
1094
1141
|
const attach = createAttachRoutes({
|
|
1095
|
-
store, hub: attachHub, machinesOnly: options.apiOnly === true, runnerApart: options.runnerApart === true,
|
|
1142
|
+
store, hub: attachHub, machinesOnly: options.apiOnly === true, runnerApart: options.runnerApart === true, relayed: relayedNow,
|
|
1096
1143
|
relay: { runners: store.runners, reach },
|
|
1144
|
+
beside,
|
|
1097
1145
|
...(options.attachTiming ? { timing: options.attachTiming } : {}),
|
|
1098
|
-
log:
|
|
1146
|
+
log: attachLog,
|
|
1099
1147
|
});
|
|
1148
|
+
// A paired computer's socket goes where its route says (workspace/paired-route.ts): the tick moves a socket in the
|
|
1149
|
+
// wrong place, every PAIRED_ROUTE_MS. A runner apart takes a route whether this server's own runner runs beside it or
|
|
1150
|
+
// not (its runners on other hosts, AGENTRUN_RUNNER_HOSTS), so the tick runs on both. It does nothing while no computer
|
|
1151
|
+
// is paired; with a runner beside it, nothing past its one read of the routes while no route row is there and no box
|
|
1152
|
+
// is relayed (computer-attach.ts tick).
|
|
1153
|
+
const routeTick = options.apiOnly !== true
|
|
1154
|
+
? setInterval(() => void attach.tick().catch((error) => attachLog("computer_route_tick_failed", { error: error instanceof Error ? error.message : String(error) })), PAIRED_ROUTE_MS)
|
|
1155
|
+
: undefined;
|
|
1156
|
+
routeTick?.unref();
|
|
1100
1157
|
// This server's own key on every environment it reads its secrets from, so a reader opens what this store holds with the
|
|
1101
1158
|
// key checked against it, never another data directory's that this process booted too (secrets.ts holds one made key).
|
|
1102
1159
|
const own = (env) => withSealKey(env, seal.text);
|
|
@@ -1121,6 +1178,8 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1121
1178
|
// A start that fails aborts it too: what began on it (the host-address read's retry) stops with that start.
|
|
1122
1179
|
const stopping = new AbortController();
|
|
1123
1180
|
stops.push(async () => stopping.abort());
|
|
1181
|
+
/** monid's listing and inspects as this server's saves read them: a burst of saves reads each once (monid.ts monidReads). */
|
|
1182
|
+
const monidShared = monidReads();
|
|
1124
1183
|
/** The after-start seal by the events' schemas (composio-triggers.ts sealMarked), drained by stop. */
|
|
1125
1184
|
let schemaSealed = Promise.resolve();
|
|
1126
1185
|
// The start's sweep of ended runs whose stored cost is unknown (cost-heal.ts), once this server listens; stop drains it.
|
|
@@ -1130,6 +1189,18 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1130
1189
|
const storedKeys = (name) => toolKeys.value(name);
|
|
1131
1190
|
// A stored key that does not open is said once at the start, never a refusal to start.
|
|
1132
1191
|
toolKeys.view();
|
|
1192
|
+
// The API-only profile's MCP origins, normalized as the environment's are (a list passed in code included), and held in
|
|
1193
|
+
// the store for every reader of a saved server there (mcp-api-only-origins.ts); removed when the profile is off.
|
|
1194
|
+
const apiOnlyMcpOrigins = options.apiOnly ? apiOnlyMcpOriginsFrom((options.apiOnlyMcpOrigins ?? []).join(",")) : [];
|
|
1195
|
+
await holdApiOnlyMcpOrigins(store, options.apiOnly === true, apiOnlyMcpOrigins);
|
|
1196
|
+
// Said once at an API-only start: the per_run servers the token saved whose origin is off that list (with the setting
|
|
1197
|
+
// unset, every one, as on an upgrade whose operator has not listed them), whose runs are refused until it lists them.
|
|
1198
|
+
// Their names alone, never an address. Nothing is said when there are none.
|
|
1199
|
+
const offList = options.apiOnly ? await offApiOnlyMcpServers(store) : [];
|
|
1200
|
+
if (offList.length) {
|
|
1201
|
+
const fields = { count: offList.length, servers: offList.join(","), line: `runs that grant these per_run MCP servers the API token saved are refused, nothing sent, until ${API_ONLY_MCP_ORIGINS_ENV} lists their origin` };
|
|
1202
|
+
log ? log(logLine("api_only_mcp_off_list", fields)) : void process.stderr.write(`agentrun-serve: ${logLine("api_only_mcp_off_list", fields)}\n`);
|
|
1203
|
+
}
|
|
1133
1204
|
const mcpServers = mcpServersOverStore(store, own(withSecrets(base, "own")), VERSION);
|
|
1134
1205
|
if (options.githubMcpOrigin)
|
|
1135
1206
|
mcpServers.appOrigin = options.githubMcpOrigin;
|
|
@@ -1176,13 +1247,44 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1176
1247
|
// where it is signed in. A sign-in, a sign-out or an expiry it sees makes the reading again, as a key's save does.
|
|
1177
1248
|
const plan = new ChatGPTPlan({ store, sealKey: seal.key, log: (fields) => (log ? log(logLine("chatgpt", fields)) : void process.stderr.write(`agentrun-serve: ${logLine("chatgpt", fields)}\n`)), changed: () => keysChanged() });
|
|
1178
1249
|
await plan.load();
|
|
1179
|
-
stops.push(async () => plan.close());
|
|
1250
|
+
stops.push(async () => void plan.close());
|
|
1180
1251
|
// Claude Code's login on this machine (claude-login.ts): env carries where it is while the owner has it on, so
|
|
1181
1252
|
// claude-agent's model checks see a model without a key. Unset, its switch follows the listen address: there on
|
|
1182
1253
|
// loopback, off past it. A setting kept where the mode is now off or refused goes first.
|
|
1183
1254
|
const loginOff = claudeLoginSwitchedOff(base, options.host ?? DEFAULT_HOST);
|
|
1184
|
-
|
|
1185
|
-
|
|
1255
|
+
// The API keys made in the console (api-keys.ts), read once here: this process is the store's one server, so the keys
|
|
1256
|
+
// it holds are the store's. No value is kept, so none joins the server's secrets: a key in a text is cut by its shape
|
|
1257
|
+
// (redact/match.ts).
|
|
1258
|
+
// On two servers the keys are dormant, so a key made on this store before opens nothing there and their tokens are the
|
|
1259
|
+
// ones they were started with: an API-only server (api-only.ts), which has no owner and serves none of the keys'
|
|
1260
|
+
// routes, and one started on its owner's own sign-in (--harness-sign-in), which is one person's. Dormant keys are
|
|
1261
|
+
// still read: the owner of the second sees and revokes them, and they count for the one-owner rule below, so none
|
|
1262
|
+
// waits unseen for a start that takes keys again.
|
|
1263
|
+
const apiKeys = new ApiKeys(store, seal.key, {
|
|
1264
|
+
say: (fields) => (log ? log(logLine("api_key", fields)) : void process.stderr.write(`agentrun-serve: ${logLine("api_key", fields)}\n`)),
|
|
1265
|
+
dormant: options.apiOnly === true || options.harnessSignIn === true,
|
|
1266
|
+
});
|
|
1267
|
+
stops.push(() => apiKeys.close());
|
|
1268
|
+
await apiKeys.load();
|
|
1269
|
+
// A key is one more caller that starts runs, as a second token is: counted each time the login's refusal is asked,
|
|
1270
|
+
// since keys are made and revoked while the server runs, and the login's turn-on takes the keys' turn (oneOwnerDeps).
|
|
1271
|
+
const oneOwner = oneOwnerDeps({ apiOnly: options.apiOnly === true, tokens: tokens.length, keysDormant: options.harnessSignIn === true }, apiKeys);
|
|
1272
|
+
/** Why this server makes no API key now, in words; undefined when it does. The one-owner rule from its other side: a
|
|
1273
|
+
* recipe on the owner's own sign-in, and Claude Code's login on this machine while it is on, are one person's. */
|
|
1274
|
+
const apiKeysRefused = async () => options.harnessSignIn ? HARNESS_SIGN_IN_REFUSES_API_KEYS : (await claudeLoginSetting(store.settings)) ? LOGIN_REFUSES_API_KEYS : undefined;
|
|
1275
|
+
// Making a key, revoking one and turning the login on each take a turn (ApiKeys.inTurn; the login's is taken in
|
|
1276
|
+
// turnOnClaudeLogin, through oneOwnerDeps' `turn`), one at a time: each decides by what the others left once their writes
|
|
1277
|
+
// landed or were undone, never by a key taken out for a removal that then fails.
|
|
1278
|
+
// The sign-in this server starts, kept for this process (claude-sign-in.ts). Its queue is the one way the login's
|
|
1279
|
+
// setting changes, the drop here included. A server whose user owns no home for the login (homeOf) drops it too.
|
|
1280
|
+
const claudeSignIns = new ClaudeSignIns({ limitMs: options.claudeSignInLimitMs });
|
|
1281
|
+
await dropRefusedLogin(claudeSignIns, store.settings, loginOff ?? oneOwner.refused() ?? homeOf(base).refused, (line) => (log ? log(logLine("claude_login", { line })) : void process.stderr.write(`agentrun-serve: ${line}\n`)));
|
|
1282
|
+
// The status checks' folders a server killed mid-check left in the temporary folder, each with a copy of the account
|
|
1283
|
+
// file (the harness's sweepClaudeStatusFolders): this user's alone, and only once the check has ended by the end it
|
|
1284
|
+
// wrote in its folder, so a check another server on this host runs now stays. Where the mode is there, as status
|
|
1285
|
+
// checks are; a sweep that fails never stops the start.
|
|
1286
|
+
if (loginOff === undefined)
|
|
1287
|
+
await import("@parcha/agentrun-harness-claude").then((claude) => claude.sweepClaudeStatusFolders()).catch(() => []);
|
|
1186
1288
|
let claudeLogin = loginOf(await claudeLoginSetting(store.settings), data, base);
|
|
1187
1289
|
// The model gateway saved in the console (model-gateway.ts), its key opened: laid over every reading of env, where the
|
|
1188
1290
|
// environment names no gateway of its own. Read again at each save or removal (gatewayChanged).
|
|
@@ -1208,25 +1310,55 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1208
1310
|
// The start-time switches as this server was started: its options, else the CLI's variables. mcpLoopback is the
|
|
1209
1311
|
// option alone, as everywhere it is read here (localInstall): the CLI sets it from AGENTRUN_MCP_ALLOW_LOOPBACK.
|
|
1210
1312
|
const switched = { mcpLoopback: options.mcpLoopback === true, webhookPrivateTargets: switchedOnBy(process.env, options).webhookPrivateTargets };
|
|
1211
|
-
|
|
1313
|
+
// harness_keys.kept from the store's snapshot, made again at each key's save or removal (harnessKeysChanged's probe).
|
|
1314
|
+
const compose = (runnerShell) => {
|
|
1315
|
+
const made = askNeeds(capabilitiesWith(env, maxRuns, offers, learning, needs, settings.get(), boxOffers, toolKeys.refused(), runnerShell, isolation, switched));
|
|
1316
|
+
return { ...made, features: { ...made.features, harness_keys: { ...made.features.harness_keys, kept: harnessKeys.unnamed() } } };
|
|
1317
|
+
};
|
|
1212
1318
|
const recompose = () => void (caps = compose());
|
|
1213
1319
|
// What the offers held now were made from (offersInputs), and the latest probe: one a later probe overtook is dropped.
|
|
1214
1320
|
let offersFrom;
|
|
1215
1321
|
let probes = 0;
|
|
1216
|
-
|
|
1322
|
+
// What the latest probe is made from, once it has read it, until it lands or fails: none while no probe is out. A
|
|
1323
|
+
// probe that fails never lands; when it is the latest, it clears this as it fails, so no probe is out after it.
|
|
1324
|
+
let probing;
|
|
1325
|
+
// The latest probe's turn: it ends as that probe lands or fails, or as a later probe starts and overtakes it, whichever
|
|
1326
|
+
// is first, and never fails. A change that waits for the probe out waits for its turn (keysChanged), so a dropped
|
|
1327
|
+
// probe holds no one up and its failure is no one else's.
|
|
1328
|
+
let turn = Promise.resolve();
|
|
1329
|
+
let endTurn = () => { };
|
|
1330
|
+
const probe = (why) => {
|
|
1331
|
+
endTurn();
|
|
1332
|
+
turn = new Promise((resolve) => (endTurn = resolve));
|
|
1333
|
+
const probed = probeOffers(why);
|
|
1334
|
+
probed.then(endTurn, endTurn);
|
|
1335
|
+
return probed;
|
|
1336
|
+
};
|
|
1337
|
+
const probeOffers = async (why) => {
|
|
1217
1338
|
const mine = ++probes;
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1339
|
+
probing = undefined;
|
|
1340
|
+
try {
|
|
1341
|
+
// The Ollama listing the offers are made from is read before they are, so the first capabilities do not remake them.
|
|
1342
|
+
if (asksOllama(env))
|
|
1343
|
+
await ollamaModels(env);
|
|
1344
|
+
const from = offersInputs(env);
|
|
1345
|
+
if (mine === probes)
|
|
1346
|
+
probing = from;
|
|
1347
|
+
const started = performance.now();
|
|
1348
|
+
const next = await harnessOffers(offersEnvOf(env));
|
|
1349
|
+
log?.(logLine("harness_offers", { why, ms: Math.round(performance.now() - started) }));
|
|
1350
|
+
if (mine !== probes)
|
|
1351
|
+
return;
|
|
1352
|
+
[offers, offersFrom] = [next, from];
|
|
1353
|
+
recompose();
|
|
1354
|
+
}
|
|
1355
|
+
finally {
|
|
1356
|
+
if (mine === probes)
|
|
1357
|
+
probing = undefined;
|
|
1358
|
+
}
|
|
1229
1359
|
};
|
|
1360
|
+
/** Whether `a` and `b` are the same offers' inputs (offersInputs). */
|
|
1361
|
+
const sameInputs = (a, b) => a.length === b.length && a.every((value, i) => value === b[i]);
|
|
1230
1362
|
/** After a save or delete of a key, the one writer of its file: env again, then what reads it. Writes can overlap
|
|
1231
1363
|
* (needsOf may wait, and another write lands meanwhile): the latest write's `needs` stands, an earlier one's that
|
|
1232
1364
|
* finishes after it is dropped. */
|
|
@@ -1240,7 +1372,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1240
1372
|
...(options.listerIdleMs !== undefined ? { idleMs: options.listerIdleMs } : {}),
|
|
1241
1373
|
});
|
|
1242
1374
|
/** Whether the offers held now were made from `inputs` (offersInputs). */
|
|
1243
|
-
const offersMadeFrom = (inputs) => offersFrom !== undefined && inputs
|
|
1375
|
+
const offersMadeFrom = (inputs) => offersFrom !== undefined && sameInputs(inputs, offersFrom);
|
|
1244
1376
|
const keysChanged = async () => {
|
|
1245
1377
|
// A run's learning, view, list and timeline row are cut of the keys saved now by the run view at read time (it reads
|
|
1246
1378
|
// serverSecrets live, store-view), and a list builds a listing cut of other keys again (builtOfNow). A failed run's error words
|
|
@@ -1251,10 +1383,29 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1251
1383
|
const next = await needsOf(env);
|
|
1252
1384
|
if (mine === needsAsked)
|
|
1253
1385
|
needs = next;
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1386
|
+
// A probe still out from other inputs (a turn-on's, after its turn-off) would put back offers made from them as it
|
|
1387
|
+
// lands: a probe of these overtakes it. Only a change starts one, at most one per change, so nothing loops. While the
|
|
1388
|
+
// probe out has read these inputs, a change starts none: with the offers held made from them too it recomposes at
|
|
1389
|
+
// once; with them behind (a tool key saved while a turn-on's probe is out) it waits for that probe's turn, then
|
|
1390
|
+
// decides again from the inputs read then (a later change's, if one landed meanwhile): the probe landed, and it
|
|
1391
|
+
// recomposes; it failed, and the change probes for itself; a later probe overtook it, and the change goes by that
|
|
1392
|
+
// one. So it never answers another request's failure, and never waits on a dropped probe. With no probe out that has
|
|
1393
|
+
// read its inputs (none out, or the latest still reading the Ollama listing), it recomposes when the offers held are
|
|
1394
|
+
// made from these inputs and probes when not; a probe it starts itself fails it if it fails.
|
|
1395
|
+
for (;;) {
|
|
1396
|
+
const inputs = offersInputs(env);
|
|
1397
|
+
const out = probing !== undefined && sameInputs(probing, inputs);
|
|
1398
|
+
if (out && !offersMadeFrom(inputs)) {
|
|
1399
|
+
log?.(logLine("harness_offers_wait", { why: "key" }));
|
|
1400
|
+
await turn;
|
|
1401
|
+
continue;
|
|
1402
|
+
}
|
|
1403
|
+
if (offersMadeFrom(inputs) && (probing === undefined || out))
|
|
1404
|
+
recompose();
|
|
1405
|
+
else
|
|
1406
|
+
await probe("key");
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1258
1409
|
};
|
|
1259
1410
|
/** The Ollama here, as capabilities read it: its listing asked again behind the answer once stale (ollamaModels), and
|
|
1260
1411
|
* the reading made again, as a key's save does, once a listing differs from the one the offers were made from. So a
|
|
@@ -1277,19 +1428,12 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1277
1428
|
savedGateway = await readSavedGateway(store, seal.key);
|
|
1278
1429
|
await keysChanged();
|
|
1279
1430
|
};
|
|
1280
|
-
/** The sign-in as the store holds it now: a
|
|
1281
|
-
*
|
|
1282
|
-
const planNow =
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
else
|
|
1287
|
-
await plan.changeAgain();
|
|
1288
|
-
};
|
|
1289
|
-
/** What Claude Code's login routes use: a turn on or off reads the setting again, then env, as a key's save does. A
|
|
1290
|
-
* sign-in this server starts opens a browser on its machine, so only where the console is on loopback here; it is
|
|
1291
|
-
* kept for this process (claude-sign-in.ts), and one still waiting is ended at the stop. */
|
|
1292
|
-
const claudeSignIns = new ClaudeSignIns({ limitMs: options.claudeSignInLimitMs });
|
|
1431
|
+
/** The sign-in as the store holds it now (ChatGPTPlan.refresh): a change reads env again, and so does one this server
|
|
1432
|
+
* failed to take (changed_failed), until it takes. */
|
|
1433
|
+
const planNow = () => plan.refresh();
|
|
1434
|
+
/** What Claude Code's login routes use: a turn on or off hands over the login it saved, then env is read again, as a
|
|
1435
|
+
* key's save does. A sign-in this server starts opens a browser on its machine, so only where the console is on
|
|
1436
|
+
* loopback here; it is kept for this process (claudeSignIns, above), and one still waiting is ended at the stop. */
|
|
1293
1437
|
stops.push(async () => claudeSignIns.close());
|
|
1294
1438
|
const loginDeps = () => ({
|
|
1295
1439
|
signIns: claudeSignIns,
|
|
@@ -1297,13 +1441,14 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1297
1441
|
data,
|
|
1298
1442
|
env: base,
|
|
1299
1443
|
pinned: async () => claudeCliIn(installDirOf(data, LOGIN_HARNESS), (await import("@parcha/agentrun-harness-claude")).claudeAgentPlatform()),
|
|
1300
|
-
refused
|
|
1444
|
+
// `refused` and `turn`: the keys are counted when the refusal is asked (inside the turn-on's turn, the keys' own).
|
|
1445
|
+
...oneOwner,
|
|
1301
1446
|
sameMachine: isLoopback(host) && !options.publicUrl,
|
|
1302
1447
|
claude: () => import("@parcha/agentrun-harness-claude"),
|
|
1303
|
-
|
|
1304
|
-
claudeLogin =
|
|
1305
|
-
await keysChanged();
|
|
1448
|
+
saved: (login) => {
|
|
1449
|
+
claudeLogin = login;
|
|
1306
1450
|
},
|
|
1451
|
+
changed: keysChanged,
|
|
1307
1452
|
});
|
|
1308
1453
|
// The boxes a place may name, read once from the computers runs execute on (place-offers.ts): AGENTRUN_BOXES lists
|
|
1309
1454
|
// them, docker alone when it is not set; docker by its probe, daytona and modal by their providers' keys, read as a
|
|
@@ -1311,7 +1456,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1311
1456
|
const fauxDocker = Boolean(options.faux) && options.fauxDocker === true;
|
|
1312
1457
|
// A faux server's probe is on a host, as its Docker paths are below, so a test reads the same words in a container;
|
|
1313
1458
|
// `probeContainer` sets it for a test of a real one.
|
|
1314
|
-
|
|
1459
|
+
// The probe names Docker's architecture too, which says which computerd build a Docker computer binds (below).
|
|
1460
|
+
let dockerArch;
|
|
1461
|
+
const found = await placeOffers(env, { keyOf: keyReader(store, seal.key, env), fauxDocker, dockerArch: (arch) => (dockerArch = arch), ...(options.probeContainer ? { container: options.probeContainer } : options.faux ? { container: { inside: false } } : {}) });
|
|
1315
1462
|
const docker = found.some((offer) => offer.id === "docker" && offer.available);
|
|
1316
1463
|
// Under --faux, the mountinfo a test gives (fauxMountinfo, or FAUX_MOUNTINFO_ENV in the process's own environment, which
|
|
1317
1464
|
// `env` leaves out: a server under test in a container names its own /proc/self/mountinfo there); with none, a faux
|
|
@@ -1326,41 +1473,52 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1326
1473
|
// A run's Docker computer mounts the run's folder, and the computer's daemon, by this server's paths: as they are on
|
|
1327
1474
|
// its Docker's own host, or as its named data volume's subpaths from a container of that Docker's (compose.yaml).
|
|
1328
1475
|
// Any other layout, or a daemon of another machine (DOCKER_HOST, or the current context's endpoint: box-paths.ts
|
|
1329
|
-
// remoteDockerOnce), can't run one, and
|
|
1330
|
-
//
|
|
1331
|
-
|
|
1476
|
+
// remoteDockerOnce), can't run one, and neither can a server with no computerd build for its Docker's architecture as
|
|
1477
|
+
// the probe named it (`npm run build` without `npm run build:daemon`): the computer package's dockerDaemonOf, the file
|
|
1478
|
+
// and words its create() takes. Each says so here (dockerComputerRefusal), where capabilities, the run's start
|
|
1479
|
+
// (dockerAnswers) and a place's box check all read it: no run starts only to fail at its create. A faux server checks
|
|
1480
|
+
// the build only in the directory a test names (fauxDaemonDir); an architecture the probe didn't name is left to create().
|
|
1481
|
+
const daemonDir = options.faux ? options.fauxDaemonDir : undefined;
|
|
1482
|
+
const noDaemon = dockerArch === undefined || (options.faux && daemonDir === undefined) ? undefined : (daemonDir === undefined ? dockerDaemonOf(dockerArch) : dockerDaemonOf(dockerArch, daemonDir)).missing;
|
|
1483
|
+
const dockerUnrunnable = fauxDocker || !docker ? undefined : dockerComputerRefusal(dockerPaths, await remoteDockerOnce(env), noDaemon);
|
|
1332
1484
|
// From a container, a Docker computer keeps this server's allow-list only knowing the Docker host's own addresses: the
|
|
1333
1485
|
// union of the read through the socket and AGENTRUN_DOCKER_HOST_ADDRESSES (docker-host-addresses.ts), the same read the
|
|
1334
1486
|
// runner beside this server takes. Said at the start with what was found; with none, Docker isn't offered, in words.
|
|
1335
1487
|
// A read that failed with none known is read again in the background (retryHostAddresses) until one answers and the
|
|
1336
1488
|
// helper containers the failed reads left are gone, or this server stops: the boxes are made again from the answer and
|
|
1337
1489
|
// said again, so Docker is offered with no restart. Every reader of boxOffers reads it when it is called; capabilities
|
|
1338
|
-
// are composed again.
|
|
1490
|
+
// are composed again. One that failed with the operator's addresses known changes no box: the retry only removes the
|
|
1491
|
+
// containers it left. The close cuts a read in flight (its client killed) and stop() awaits the retry last, so the
|
|
1492
|
+
// read's container is removed within the stop's deadline (docker-host-addresses.ts REMOVE_MS).
|
|
1339
1493
|
const boxesOf = (hostAddresses) => {
|
|
1340
1494
|
if (hostAddresses)
|
|
1341
1495
|
log?.(logLine("docker_host_addresses", { addresses: hostAddresses.addresses.join(",") || "none", ...(hostAddresses.why ? { read: hostAddresses.why } : {}) }));
|
|
1342
|
-
const dockerRefused =
|
|
1496
|
+
const dockerRefused = dockerUnrunnable ?? (hostAddresses && hostAddresses.addresses.length === 0 ? noHostAddresses(hostAddresses.why ?? "the read through Docker's socket found none") : undefined);
|
|
1343
1497
|
// Each box with what it reaches (place-offers.ts withNetworks).
|
|
1344
1498
|
const offers = withNetworks(found, boxAllow, { ...(dockerRefused !== undefined ? { refused: dockerRefused } : {}), ...(hostAddresses ? { hostAddresses: hostAddresses.addresses } : {}), faux: fauxDocker });
|
|
1345
1499
|
log?.(logLine("boxes", boxesLog(offers, enabledBoxes(env))));
|
|
1346
1500
|
return offers;
|
|
1347
1501
|
};
|
|
1348
|
-
const hostAddresses =
|
|
1502
|
+
const hostAddresses = dockerUnrunnable === undefined && "paths" in dockerPaths && boxAllow !== "none" ? unionOf(await hostAddressesOnce(env), dockerHostAddressesOf(env)) : undefined;
|
|
1349
1503
|
let boxOffers = boxesOf(hostAddresses);
|
|
1350
|
-
|
|
1351
|
-
|
|
1504
|
+
const hostRetried = hostAddresses === undefined || hostAddresses.why === undefined
|
|
1505
|
+
? Promise.resolve()
|
|
1506
|
+
: retryHostAddresses({
|
|
1352
1507
|
env,
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1508
|
+
...(hostAddresses.addresses.length === 0
|
|
1509
|
+
? {
|
|
1510
|
+
read: () => hostAddressesOnce(env, stopping.signal),
|
|
1511
|
+
found: (read) => {
|
|
1512
|
+
boxOffers = boxesOf(unionOf(read, dockerHostAddressesOf(env)));
|
|
1513
|
+
// Capabilities are first composed at the start's probe, below; before it, there is nothing to compose again.
|
|
1514
|
+
if (caps)
|
|
1515
|
+
recompose();
|
|
1516
|
+
},
|
|
1517
|
+
}
|
|
1518
|
+
: {}),
|
|
1360
1519
|
signal: stopping.signal,
|
|
1361
1520
|
...(options.hostReadWait ? { wait: options.hostReadWait } : {}),
|
|
1362
|
-
});
|
|
1363
|
-
}
|
|
1521
|
+
}).catch(() => undefined);
|
|
1364
1522
|
const adapters = options.triggerAdapters ?? TRIGGER_ADAPTERS;
|
|
1365
1523
|
const openapi = openapiDocument((operationId) => ROUTES.find((r) => r.name === operationId)?.capability, adapters);
|
|
1366
1524
|
const sealKey = seal.key;
|
|
@@ -1411,11 +1569,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1411
1569
|
// A provider's key set where the server starts is one of its secrets, held off process.env (secrets.ts): read by name
|
|
1412
1570
|
// from what the server was started with, as computerReady below reads it.
|
|
1413
1571
|
store, sealKey, tools: kindTools, mode: folderModeOf(store, process.env), env: withSecrets(process.env, "own"),
|
|
1414
|
-
|
|
1572
|
+
// Each with its route (who holds it, on which runner, and why a route was refused), and online while relayed.
|
|
1573
|
+
paired: { rows: () => store.pairedComputers.list(), viewOf: async (row, serves, runsRefused) => pairedView(row, attachHub, serves, runsRefused, await readRoute(store.settings, row.id), attach.relayedTo(row.id) !== undefined) },
|
|
1415
1574
|
runnerApart: options.runnerApart === true,
|
|
1416
|
-
|
|
1417
|
-
// within PRESENCE_STALE_MS on the store's clock (liveRelays), at a host this server dials.
|
|
1418
|
-
relayed: async () => (await liveRelays(store.runners)).some((row) => dialHost(row.host, reach) !== undefined),
|
|
1575
|
+
relayed: relayedNow,
|
|
1419
1576
|
...(options.faux
|
|
1420
1577
|
// --faux's providers stand in for every vendor's, a local one's daemon included.
|
|
1421
1578
|
? { kinds: fauxOf().kinds, factories: fauxOf().factories, keyTable: fauxOf().keyTable }
|
|
@@ -1441,11 +1598,11 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1441
1598
|
/** A key as the runner reads it: the secrets this process was started with (withSecrets "own"), else the saved one. */
|
|
1442
1599
|
const runnerKeys = () => keyReader(store, sealKey, own(withSecrets(process.env, "own")));
|
|
1443
1600
|
// A paired computer is one more provider of the registry (workspace/attached-computers.ts), ready while its driver is
|
|
1444
|
-
// attached to this process's hub.
|
|
1601
|
+
// attached: to this process's hub, or relayed to the runner that holds a run of it.
|
|
1445
1602
|
const computerReady = async (setting) => {
|
|
1446
1603
|
const paired = await store.pairedComputers.list();
|
|
1447
1604
|
const row = paired.find((one) => one.id === setting.provider);
|
|
1448
|
-
const offline = row ? pairedRefusal(row, attachHub) : undefined;
|
|
1605
|
+
const offline = row ? pairedRefusal(row, { online: (id) => attachHub.online(id) || attach.relayedTo(id) !== undefined }) : undefined;
|
|
1449
1606
|
if (offline)
|
|
1450
1607
|
return { refused: offline };
|
|
1451
1608
|
return computerReadiness(setting, await modeNow(), withPaired(claimRegistry(), paired), runnerKeys(), dockerAnswers, boxAllow, (provider) => (Object.hasOwn(hostWhy, provider) ? hostWhy[provider] : undefined));
|
|
@@ -1504,7 +1661,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1504
1661
|
};
|
|
1505
1662
|
/** The run read's costs (A8, store-reads/learning.ts runAllInOverStore): `cost.usd` its own spend, the
|
|
1506
1663
|
* job's (its compile turn is learning's), null while unknown; what learning spent for it
|
|
1507
|
-
* (`learning_usd`) and the two (`all_in_usd`)
|
|
1664
|
+
* (`learning_usd`) and the two (`all_in_usd`), with what makes up `learning_usd` (`compile_usd`, `followup_usd`,
|
|
1665
|
+
* `shadow_usd`, `share_usd`): the figures the agent's cost page gives the run (learn/ledger.ts figuresOf, one formula).
|
|
1666
|
+
* A cost known only as a bound keeps its bound, and all-in is unknown.
|
|
1508
1667
|
* `tools_usd`: the part of `usd` its paid tool calls cost (store-view.ts toolsUsdOverStore). */
|
|
1509
1668
|
const allInViewOf = async (runId, view) => {
|
|
1510
1669
|
const cost = (view.cost ?? {});
|
|
@@ -1526,9 +1685,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1526
1685
|
}));
|
|
1527
1686
|
if (!all)
|
|
1528
1687
|
return {};
|
|
1529
|
-
// A bound stays the view's bound. Otherwise usd is the job's (
|
|
1688
|
+
// A bound stays the view's bound. Otherwise usd is the job's (its ledger row's, the same figure the cost series
|
|
1530
1689
|
// gives): known as it answered even when its compile turn's cost is not; the row's while the run is at work.
|
|
1531
|
-
|
|
1690
|
+
const { learning_usd, all_in_usd, compile_usd, followup_usd, shadow_usd, share_usd } = all;
|
|
1691
|
+
return { cost: { ...cost, ...(cost.upper_bound === true ? {} : { usd: all.usd }), tools_usd: await toolsUsdOverStore(store, runId), learning_usd, all_in_usd, compile_usd, followup_usd, shadow_usd, share_usd, ...(degraded ? { degraded: true } : {}) } };
|
|
1532
1692
|
};
|
|
1533
1693
|
// The agents accessor the routes call, over the one store (module A): the agents-store functions, with the run-row reads
|
|
1534
1694
|
// the server makes (store-reads) under `.store`. `.request` is a thin pass-through — the store runs its own transactions,
|
|
@@ -1870,7 +2030,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1870
2030
|
};
|
|
1871
2031
|
// What a run held for its owner's OK reads as it stands on its agent's learning folder's main (statusesOf).
|
|
1872
2032
|
const statuses = (agentId) => statusesOf(data, agentId);
|
|
1873
|
-
const viewDepsFor = (origin) => ({ origin, serverSecrets, signIns, keyEnv: () => withSavedGateway(own(withSecrets(process.env, "all", storedKeys)), savedGateway), statuses });
|
|
2033
|
+
const viewDepsFor = (origin) => ({ origin, serverSecrets, signIns, sealKey, keyEnv: () => withSavedGateway(own(withSecrets(process.env, "all", storedKeys)), savedGateway), statuses });
|
|
1874
2034
|
// A run read as a whole (its own read, its archive) lists its recordings too, from its recordings folder on this machine
|
|
1875
2035
|
// (run-recordings.ts), where the runner beside it wrote them; every other read of the view opens no file.
|
|
1876
2036
|
const recordings = (agentId, runId, endedAt) => recordingsOf(recordingsFolder(data, agentId, runId), endedAt);
|
|
@@ -1895,14 +2055,15 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1895
2055
|
env,
|
|
1896
2056
|
runFacts: (_store, runId) => factsOverStore(store, runId, viewDepsFor(ownOriginOf())),
|
|
1897
2057
|
withheld: (_store, runId) => withheldOverStore(store, runId, viewDepsFor(ownOriginOf())),
|
|
1898
|
-
cutValues: (_store, runId) => runCutValues({ serverSecrets, signIns }, store, runId),
|
|
2058
|
+
cutValues: (_store, runId) => runCutValues({ serverSecrets, signIns, sealKey }, store, runId),
|
|
1899
2059
|
context: ctx,
|
|
2060
|
+
sealKey,
|
|
1900
2061
|
liveViewer: (runId) => liveViewerLink(store, sealKey, runId, answers(runId)),
|
|
1901
2062
|
};
|
|
1902
2063
|
// The run timeline reader over the store (run-reads-over-store runTimelines): one change-numbered RowLog per run, synced
|
|
1903
2064
|
// from its journal (store-reads) on each read, its view (viewOverStore) for status/state/cost and whether it is final.
|
|
1904
2065
|
// The route frames the SSE around its `page`, which long-polls the journal, byte-identical to the old live run's page.
|
|
1905
|
-
const servedTimelineDeps = { serverSecrets, signIns, keyEnv: () => withSavedGateway(own(withSecrets(process.env, "all", storedKeys)), savedGateway), statuses };
|
|
2066
|
+
const servedTimelineDeps = { serverSecrets, signIns, sealKey, keyEnv: () => withSavedGateway(own(withSecrets(process.env, "all", storedKeys)), savedGateway), statuses };
|
|
1906
2067
|
const timelines = runTimelines({
|
|
1907
2068
|
context: ctx,
|
|
1908
2069
|
// The run's rows as served (run-timeline-served.ts), by its one cut (run-cut.ts, read for each page: a secret rotated
|
|
@@ -1912,7 +2073,24 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1912
2073
|
// from its journal, which keeps what the run said whole.
|
|
1913
2074
|
timelineRows: (forStore, runId, context, calls) => servedTimelineRows(servedTimelineDeps, forStore, runId, context, calls),
|
|
1914
2075
|
runView: (forStore, runId) => viewOverStore(forStore, runId, viewDepsFor(ownOriginOf())),
|
|
2076
|
+
// A live run's model requests sent and not answered (in-flight.ts), from its booking's records in its journal.
|
|
2077
|
+
inFlight: async (forStore, runId, context) => modelsInFlight(await runEntries(forStore, runId, context)),
|
|
1915
2078
|
});
|
|
2079
|
+
/** `text` as a message to run `runId` is written: cut of `handed` (what the message itself hands) and of what the run
|
|
2080
|
+
* holds now (its turn's end erases those, and a read after it could no longer cut them). A run whose seal doesn't
|
|
2081
|
+
* open here (its seal key changed or is missing, or what was sealed is damaged or lost) takes no message: 409
|
|
2082
|
+
* not_continuable, reason withheld (WITHHELD_MESSAGE), and nothing is written, since what it can't read it can't
|
|
2083
|
+
* cut, and a message written uncut would show those values once the run's end lets its reads go uncut-withheld.
|
|
2084
|
+
* Read inside the turn that writes the message (runWrite), never before it: a message written first in that turn
|
|
2085
|
+
* (one that hands a new key) is in the seal read here, so a message that says that key without handing it is cut of
|
|
2086
|
+
* it too. Both writers of a message read it: a person's (sendMessage) and a trigger's (trigger-targets.ts
|
|
2087
|
+
* message_run, which skips with those words). */
|
|
2088
|
+
async function cutHeld(runId, text, handed = []) {
|
|
2089
|
+
const held = launchValuesOf(sealKey, runId, (await store.runs.launch(runId)).sealed);
|
|
2090
|
+
if (held === "unreadable")
|
|
2091
|
+
throw new ApiError("not_continuable", WITHHELD_MESSAGE, { details: { reason: "withheld" } });
|
|
2092
|
+
return cutHanded(text, [...handed, ...held]);
|
|
2093
|
+
}
|
|
1916
2094
|
const triggerDeps = {
|
|
1917
2095
|
...(options.beforeSubmit ? { beforeSubmit: options.beforeSubmit } : {}),
|
|
1918
2096
|
start: startDeps,
|
|
@@ -1925,6 +2103,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1925
2103
|
planRecipe: (harness) => recipeHarness(base, harness) === "plan" && !harnessKeysSavedHere(data, harness),
|
|
1926
2104
|
// Read when a firing's message is sent (declared below, with the delete turn).
|
|
1927
2105
|
runWrite: (agentId, runId, work) => runWrite(agentId, runId, work),
|
|
2106
|
+
cutHeld: (runId, text) => cutHeld(runId, text),
|
|
1928
2107
|
runStatus: async (runId) => (await viewOverStore(store, runId, viewDepsFor(ownOriginOf())))?.status ?? null,
|
|
1929
2108
|
completedOutput: async (runId) => {
|
|
1930
2109
|
const view = await viewOverStore(store, runId, viewDepsFor(ownOriginOf()));
|
|
@@ -1944,12 +2123,24 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1944
2123
|
// of the one that opened a request is kept with it for its log line (tokenUsed), never the secret.
|
|
1945
2124
|
const bearerOf = bearerCheck(tokens);
|
|
1946
2125
|
const tokenUsed = new WeakMap();
|
|
1947
|
-
|
|
2126
|
+
/** Whether `header` carries a token this server was started with: the one credential that stands in for the setup
|
|
2127
|
+
* code (ownerRoute). A key made in the console never does. */
|
|
2128
|
+
const startToken = (header, req) => {
|
|
1948
2129
|
const id = bearerOf(header);
|
|
1949
2130
|
if (id !== undefined && req)
|
|
1950
2131
|
tokenUsed.set(req, id);
|
|
1951
2132
|
return id !== undefined;
|
|
1952
2133
|
};
|
|
2134
|
+
// A key made in the console (api-keys.ts) opens what a token opens, but for setup. Its id is kept for the log line too.
|
|
2135
|
+
const keyUsed = new WeakMap();
|
|
2136
|
+
const bearer = (header, req) => {
|
|
2137
|
+
// Both are checked whatever the first says, so the time taken does not say which kind was presented.
|
|
2138
|
+
const started = startToken(header, req);
|
|
2139
|
+
const key = apiKeys.used(header);
|
|
2140
|
+
if (key !== undefined && req)
|
|
2141
|
+
keyUsed.set(req, key);
|
|
2142
|
+
return started || key !== undefined;
|
|
2143
|
+
};
|
|
1953
2144
|
// Answered keys are kept in the data directory for the retention capabilities state, and written before the answer
|
|
1954
2145
|
// is sent, so a client that retries after a restart gets the first answer back.
|
|
1955
2146
|
// A key's fingerprint is an HMAC of its request's body (stable JSON) under a key derived from the server's seal key:
|
|
@@ -2315,13 +2506,14 @@ async function startHolding(options, data, checked, stops) {
|
|
|
2315
2506
|
let closing = false;
|
|
2316
2507
|
const workers = new Map();
|
|
2317
2508
|
// Once the server closes, no worker starts: a setup still being answered then leaves its yes for the next start.
|
|
2318
|
-
const onWorker = (task, projects) => closing ? Promise.resolve({ stopped: true }) : new Promise((answered, failed) => {
|
|
2509
|
+
const onWorker = (task, projects, year) => closing ? Promise.resolve({ stopped: true }) : new Promise((answered, failed) => {
|
|
2319
2510
|
const worker = new Worker(new URL("./import-worker.js", import.meta.url), {
|
|
2320
2511
|
// The secrets this process holds (secrets.ts keeps them out of every environment, so the worker's has none), in the
|
|
2321
2512
|
// worker's memory alone: what the import cuts out of everything it writes. The keys saved on the Tool keys page are
|
|
2322
2513
|
// not passed; the worker reads them from the store over the port (sealed rows it opens with the seal key among these
|
|
2323
2514
|
// secrets), the same cut as the CLI's import, where a saved key and the server's own of the same name may differ.
|
|
2324
|
-
|
|
2515
|
+
// A Wrapped read (`year`) writes nothing, so it is handed no secret.
|
|
2516
|
+
workerData: { task, data, ...(projects ? { projects } : {}), ...(year !== undefined ? { year } : {}), home: options.sessionsHome?.home ?? homedir(), ...(options.sessionsHome?.temp ? { temp: options.sessionsHome.temp } : {}), ...(task === "wrapped" ? {} : { secrets: Object.fromEntries(SECRET_NAMES.flatMap((name) => { const value = name === SEAL_KEY_ENV ? seal.text : secret(name); return value === undefined ? [] : [[name, value]]; })) }) },
|
|
2325
2517
|
// Started from a string (node --input-type=module -e, as a test or a `--` command may), the server's flags are given again
|
|
2326
2518
|
// without that string and its type: a worker started from a file with them is refused. Otherwise the worker
|
|
2327
2519
|
// inherits them as Node passes them on, which leaves out the flags a worker may not take (on Node 24 a test
|
|
@@ -2347,12 +2539,16 @@ async function startHolding(options, data, checked, stops) {
|
|
|
2347
2539
|
if (answer)
|
|
2348
2540
|
answered(answer);
|
|
2349
2541
|
// A count the close ended: stopped, not failed (the next start counts again).
|
|
2350
|
-
else if (closing && task
|
|
2542
|
+
else if (closing && task !== "import")
|
|
2351
2543
|
answered({ stopped: true });
|
|
2352
2544
|
else
|
|
2353
2545
|
failed(new Error(`the import's worker ended (${code}) with no answer`));
|
|
2354
2546
|
});
|
|
2355
2547
|
});
|
|
2548
|
+
// GET /v2/wrapped's reads of this machine's home (wrapped.ts), each year's on the import worker, so its parsing never holds
|
|
2549
|
+
// up a request; shared and kept as keptReads says. A read the close ended answers `stopped`, a failure like any other. A
|
|
2550
|
+
// failure is logged here, once per read: the ask that started it may have had its 503 long before.
|
|
2551
|
+
const readWrapped = loggedReads((year) => onWorker("wrapped", undefined, year).then((answer) => ("wrapped" in answer ? answer : Promise.reject(new Error("the server stopped before this machine's session history was read")))), (year, error) => void (closing || process.stderr.write(`agentrun-serve: the read of this machine's session history for ${year} failed: ${error.message}\n`)));
|
|
2356
2552
|
// The count of what setup would import: started once (at start, or by the page's first read), read as it stands. One
|
|
2357
2553
|
// stopped (by close, or by setup) starts again on the next read; one that failed stays failed.
|
|
2358
2554
|
let count;
|
|
@@ -2737,11 +2933,12 @@ async function startHolding(options, data, checked, stops) {
|
|
|
2737
2933
|
// The run's folder (its work and what sits beside it), its scratch and its native context, on this machine.
|
|
2738
2934
|
for (const folder of [dirname(runFolder(data, agentId, runId)), scratchFolder(data, agentId, runId), join(data, "native-context", runId)])
|
|
2739
2935
|
await rm(folder, { recursive: true, force: true });
|
|
2740
|
-
// Its settings: an SDK run's row, its browser wait's end, the Archil disk it resolved to. Its kept computer's row
|
|
2936
|
+
// Its settings: an SDK run's row, its browser wait's end and take, the Archil disk it resolved to. Its kept computer's row
|
|
2741
2937
|
// (workspace/computer-kept.ts) is left to the janitor, which deletes the computer of a run no longer there and then
|
|
2742
2938
|
// the row: removed here, the computer would have nothing left to reach it.
|
|
2743
2939
|
await store.settings.remove(sdkRunKey(runId));
|
|
2744
2940
|
await store.settings.remove(waitEndedKey(runId));
|
|
2941
|
+
await store.settings.remove(browserHoldKey(runId));
|
|
2745
2942
|
await store.settings.remove(runDiskKey(runId));
|
|
2746
2943
|
await forgetKept("run", runId);
|
|
2747
2944
|
},
|
|
@@ -2905,8 +3102,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
2905
3102
|
* starts with the checks a save makes (runnable.ts): one a save refused, or one a setting of this host fixes that it
|
|
2906
3103
|
* does not have yet. `capped`: the run has a spend cap, which a web tool's resolution reads (tool-plane.ts). `price`:
|
|
2907
3104
|
* what prices an OpenRouter decision model under that cap; a start's reads OpenRouter's catalog (decisionPrice).
|
|
2908
|
-
* `carried`: the names of the tool keys the run carries (run-keys.ts), each read as one this host holds.
|
|
2909
|
-
|
|
3105
|
+
* `carried`: the names of the tool keys the run carries (run-keys.ts), each read as one this host holds. `held`: the
|
|
3106
|
+
* run holds its computer (hold: true): kept from running by its model alone, it is not refused, and the refusal is
|
|
3107
|
+
* returned for its launch, its start to answer it (computer-held.ts). */
|
|
3108
|
+
async function runnable(revision, place, { capped = false, price = decisionPrice, carried = [], held = false } = {}) {
|
|
2910
3109
|
if (cliLearningOf(revision.body))
|
|
2911
3110
|
throw new ApiError("agent_not_runnable", "Continue in the original CLI session; this connection records learning without launching its tools.");
|
|
2912
3111
|
if (sdkOf(revision.body))
|
|
@@ -2985,7 +3184,13 @@ async function startHolding(options, data, checked, stops) {
|
|
|
2985
3184
|
const blockers = await blockersOf(withCarried(envAtPlace(env, shape.place), carried), shape, settings.get(), { capped, boxes: boxOffers, computerReady, shellOf, offers, mcp: revision.kind === "agentic" ? pinnedTools : mcpTools, monid, decisionPrice: price });
|
|
2986
3185
|
if (!blockers.length)
|
|
2987
3186
|
return;
|
|
2988
|
-
|
|
3187
|
+
// An agent refused for its model in a box while its harness runs on the login at the runner, on a model the login
|
|
3188
|
+
// runs: the words say so, and how to run it there (details.login_on_runner, the console's offer to move it). Its
|
|
3189
|
+
// model is the blocker whichever field names it (runnable.ts Blocker.model: an agent that names none is refused on its
|
|
3190
|
+
// harness), and the model it would run on the runner is its own, else the runner's default for its harness
|
|
3191
|
+
// (hostModel: AGENT_MODEL first), so one whose default there is an OpenRouter model is offered no move.
|
|
3192
|
+
const runnerOnly = shape.kind === "agentic" && blockers.some((b) => b.model && b.reason === NOT_SET_UP && !b.unpriced) ? loginOnRunnerOnly(env, shape.harness, shape.model || hostModel(envAtPlace(env, { mode: "runner" }), "default", shape.harness), shape.place) : undefined;
|
|
3193
|
+
const message = [...blockers.map((b) => b.message), ...(runnerOnly ? [runnerOnly] : [])].join(" ");
|
|
2989
3194
|
// Each blocker as a 422 names its issue: its field, reason and message, and the fix when it has one.
|
|
2990
3195
|
const fields = blockers.map(issueOf);
|
|
2991
3196
|
const unbound = blockers.flatMap((b) => (b.tool ? [b.tool] : []));
|
|
@@ -2995,8 +3200,15 @@ async function startHolding(options, data, checked, stops) {
|
|
|
2995
3200
|
const harness = blockers.find((b) => b.harness)?.harness;
|
|
2996
3201
|
const box = blockers.find((b) => b.box)?.box;
|
|
2997
3202
|
const named = { ...(harness ? { harness } : {}), ...(box ? { box } : {}), ...(notGrantable.length ? { not_grantable: notGrantable } : {}) };
|
|
2998
|
-
if (revision.kind === "agentic")
|
|
2999
|
-
|
|
3203
|
+
if (revision.kind === "agentic") {
|
|
3204
|
+
const details = { unbound, missing, ...named, ...(runnerOnly ? { login_on_runner: true } : {}) };
|
|
3205
|
+
// A held run kept from running by its model alone opens (runnable.ts Blocker.model: a CLI harness that lacks only a
|
|
3206
|
+
// model key here among them): its computer is its owner's to call, and these words are its start's refusal
|
|
3207
|
+
// (computer-held.ts). Any other blocker refuses it here, as any run.
|
|
3208
|
+
if (held && blockers.every((b) => b.model))
|
|
3209
|
+
return { message, fields, details };
|
|
3210
|
+
throw new ApiError("agent_not_runnable", message, { fields, details });
|
|
3211
|
+
}
|
|
3000
3212
|
const tier = blockers.find((b) => b.tier)?.tier;
|
|
3001
3213
|
const decisions = Object.fromEntries(blockers.flatMap((b) => (b.decision ? [[b.decision.provider, { reason: b.reason, needs: b.decision.needs }]] : [])));
|
|
3002
3214
|
const denied = blockers.flatMap((b) => (b.denied ? [b.denied] : []));
|
|
@@ -3093,6 +3305,16 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3093
3305
|
}
|
|
3094
3306
|
if (cliLearningOf(body) || sdkOf(body))
|
|
3095
3307
|
return { warnings: [], stamp: {} };
|
|
3308
|
+
// A workflow's own issues, as POST /workflows/validate lists them (workflowIssues: the DSL's checks, the durable
|
|
3309
|
+
// runner's refusal), refuse its save before anything is written, each at its path under definition.workflow. Asked
|
|
3310
|
+
// with no tools list: its run binds every tool its call nodes name whether `tools` lists it or not (tools.ts
|
|
3311
|
+
// grantedTools), so a call node's unlisted tool is validate's hint, never a reason to refuse a runnable workflow.
|
|
3312
|
+
if (revision.kind === "workflow") {
|
|
3313
|
+
const { workflowIssues } = await import("./workflow-run.js");
|
|
3314
|
+
const { issues } = await workflowIssues(body.workflow);
|
|
3315
|
+
if (issues.length)
|
|
3316
|
+
throw invalid(issues.map(({ path, code, message }) => ({ field: `definition.workflow${path}`, reason: "invalid", code, message })));
|
|
3317
|
+
}
|
|
3096
3318
|
// An agent on a harness that installs on first use starts its install, if it is not in yet: its first run waits for less.
|
|
3097
3319
|
const harnessId = revision.kind === "agentic" ? harnessOfBody(body) : undefined;
|
|
3098
3320
|
const install = harnessId !== undefined && Object.hasOwn(installs, harnessId) ? installs[harnessId] : undefined;
|
|
@@ -3124,7 +3346,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3124
3346
|
if (never.length)
|
|
3125
3347
|
throw invalid(never.map(issueOf));
|
|
3126
3348
|
const mcpPin = listing.pin();
|
|
3127
|
-
|
|
3349
|
+
// A computer every tool of which is set to deny, here or in the agent's own settings: its runs never start it.
|
|
3350
|
+
const denied = await deniedComputer(shape, settings.get(), shellOf);
|
|
3351
|
+
const off = denied ? [{ field: "definition.computer", reason: "not_allowed", message: computerDeniedWords(denied) }] : [];
|
|
3352
|
+
return { warnings: [...blockers.map(issueOf), ...off, ...usage], stamp: { ...(mcpPin ? { mcpPin } : {}), ...(monid ? { monidPin: monid } : {}) } };
|
|
3128
3353
|
}
|
|
3129
3354
|
/** An agentic `revision`'s monid pin (monid.ts pinMonid) and a warning per endpoint priced by usage; a grant that
|
|
3130
3355
|
* cannot be pinned refuses the save (422). Undefined when it grants none. */
|
|
@@ -3135,7 +3360,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3135
3360
|
const send = await checkFetch("monid");
|
|
3136
3361
|
const before = previous?.kind === "agentic" ? { grants: previous.body.tools ?? [], pin: previous.monidPin } : undefined;
|
|
3137
3362
|
// The key as the server reads it (env: what it was started with, its handed secrets and its saved keys).
|
|
3138
|
-
const pinned = await pinMonid(tools, { key: env[MONID_KEY_ENV]?.trim(), fetch: send ?? (async () => { throw new Error("no fake of monid's API under faux"); }), signal: stopping.signal, ...(before ? { previous: before } : {}) });
|
|
3363
|
+
const pinned = await pinMonid(tools, { key: env[MONID_KEY_ENV]?.trim(), fetch: send ?? (async () => { throw new Error("no fake of monid's API under faux"); }), signal: stopping.signal, shared: monidShared, ...(before ? { previous: before } : {}) });
|
|
3139
3364
|
if (pinned && "refused" in pinned)
|
|
3140
3365
|
throw invalid(pinned.refused.map(({ tool, message }) => ({ field: tools.includes(tool) ? `definition.tools[${tools.indexOf(tool)}]` : "definition.tools", reason: "not_an_option", message })));
|
|
3141
3366
|
return pinned && { monid: pinned.pin, warnings: pinned.warnings.map(({ tool, message }) => ({ field: `definition.tools[${tools.indexOf(tool)}]`, reason: PRICED_BY_USAGE, message })) };
|
|
@@ -3770,8 +3995,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3770
3995
|
function startSeal(handed) {
|
|
3771
3996
|
if (handed.mcp === undefined && handed.model === undefined && handed.keys === undefined)
|
|
3772
3997
|
return undefined;
|
|
3773
|
-
return (runId,
|
|
3774
|
-
const target = { kind, model: launch.model, native: Boolean(launch.native) };
|
|
3998
|
+
return (runId, _launch, target) => {
|
|
3775
3999
|
if (handed.model !== undefined) {
|
|
3776
4000
|
const why = modelKeyMisfit(env, target);
|
|
3777
4001
|
if (why)
|
|
@@ -3791,9 +4015,15 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3791
4015
|
* which then writes nothing, so a turn never starts with no key to spend. Its `keys` replace the run's whole, each one
|
|
3792
4016
|
* its revision reads (else 422 by name); under the run-keys setting, a message that would leave the run without a tool
|
|
3793
4017
|
* key its template declared and this host does not hold (its last turn's end erased them) is refused, 409, nothing
|
|
3794
|
-
* written.
|
|
4018
|
+
* written. A value the run held that the message replaces is kept sealed as `retired`, only to be cut, until the turn's
|
|
4019
|
+
* end erases the seal; where what the run holds does not open here, or past RETIRED_MAX values replaced, the seal says
|
|
4020
|
+
* so (`lost`), and the run is withheld until its end, which counts nothing (handed-values.ts launchValuesOf). */
|
|
3795
4021
|
async function messageSeal(run, handed) {
|
|
3796
4022
|
const launch = readLaunchBody((await store.runs.launch(run.id)).body);
|
|
4023
|
+
// A held run its model kept from running takes no message (runs-over-store.ts message refuses it in its create's
|
|
4024
|
+
// words): nothing to seal, and no key check answers before that refusal (its launch pins no model to check).
|
|
4025
|
+
if (launch?.hold?.refused)
|
|
4026
|
+
return undefined;
|
|
3797
4027
|
const target = { kind: run.kind, model: launch?.model, native: Boolean(launch?.native) };
|
|
3798
4028
|
if (handed.model !== undefined) {
|
|
3799
4029
|
const why = modelKeyMisfit(env, target);
|
|
@@ -3813,7 +4043,8 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3813
4043
|
return undefined;
|
|
3814
4044
|
const origin = runModelOrigin(env);
|
|
3815
4045
|
return (current) => {
|
|
3816
|
-
const
|
|
4046
|
+
const opened = openRunLaunch(sealKey, run.id, current);
|
|
4047
|
+
const held = opened ?? {};
|
|
3817
4048
|
const mcp = handed.mcp ?? held.mcp;
|
|
3818
4049
|
const model = handed.model !== undefined && origin ? { key: handed.model, origin } : held.model;
|
|
3819
4050
|
const keys = handed.keys ?? held.keys;
|
|
@@ -3822,7 +4053,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3822
4053
|
const unpaid = owed.length && revision ? keysOwed(revision, env, Object.keys(keys ?? {})) : [];
|
|
3823
4054
|
if (unpaid.length)
|
|
3824
4055
|
throw keysOwedRefusal(unpaid);
|
|
3825
|
-
|
|
4056
|
+
const next = { ...(mcp ? { mcp } : {}), ...(model ? { model } : {}), ...(keys ? { keys } : {}) };
|
|
4057
|
+
const retired = retiredValues(held, next);
|
|
4058
|
+
const lost = opened === undefined || held.lost === true || retired.length > RETIRED_MAX;
|
|
4059
|
+
return sealRunLaunch(sealKey, run.id, { ...next, ...(lost ? { lost: true } : { retired }) });
|
|
3826
4060
|
};
|
|
3827
4061
|
}
|
|
3828
4062
|
async function createRun(req, agentId) {
|
|
@@ -3844,7 +4078,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3844
4078
|
const run = await triggers.handedStart(given, agentId, async (firing) => {
|
|
3845
4079
|
const secrets = await handed();
|
|
3846
4080
|
const seal = startSeal(secrets);
|
|
3847
|
-
|
|
4081
|
+
// What the server writes of the start (its input, which the run's title is read from) is cut of what it hands.
|
|
4082
|
+
const cut = cutHanded(rest, handedSecretValues(secrets));
|
|
4083
|
+
return targets.start(firing.target, cut.input, firing.trigger, firing.from, firing.title, firing.previous, { body: cut, ...(seal ? { sealed: seal } : {}), ...carriedOf(secrets) });
|
|
3848
4084
|
});
|
|
3849
4085
|
return { status: 202, body: await viewOverStore(store, run.run_id, viewDepsFor(linkOrigin(req))), headers: { location: `/v2/runs/${run.run_id}`, ...(run.replayed ? { "idempotent-replayed": "true" } : {}) } };
|
|
3850
4086
|
}
|
|
@@ -3859,7 +4095,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3859
4095
|
}
|
|
3860
4096
|
const secrets = await handed();
|
|
3861
4097
|
const seal = startSeal(secrets);
|
|
3862
|
-
|
|
4098
|
+
// What the server writes of the start (its input, which the run's title is read from) is cut of what it hands; the
|
|
4099
|
+
// idempotency fingerprint stays the body's as sent.
|
|
4100
|
+
const run = await startRunOf(entry, cutHanded(body, handedSecretValues(secrets)), { ...(origin ? { origin } : {}), ...(seal ? { sealed: seal } : {}), ...carriedOf(secrets) });
|
|
3863
4101
|
// Its view from the store: the run and its launch were inserted in one transaction, so the view reads it whole.
|
|
3864
4102
|
return { status: 202, body: await viewOverStore(store, run.id, viewDepsFor(linkOrigin(req))), headers: { location: `/v2/runs/${run.id}` } };
|
|
3865
4103
|
});
|
|
@@ -3917,7 +4155,8 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3917
4155
|
}
|
|
3918
4156
|
const secrets = await handed();
|
|
3919
4157
|
const seal = startSeal(secrets);
|
|
3920
|
-
|
|
4158
|
+
// What the server writes of the start (its input, which the run's title is read from) is cut of what it hands.
|
|
4159
|
+
const started = await startInline(store, startDeps, inline, cutHanded(run, handedSecretValues(secrets)), { ...(origin ? { origin } : {}), ...(seal ? { sealed: seal } : {}), ...carriedOf(secrets) });
|
|
3921
4160
|
return { status: 202, body: await viewOverStore(store, started.id, viewDepsFor(linkOrigin(req))), headers: { location: `/v2/runs/${started.id}` } };
|
|
3922
4161
|
});
|
|
3923
4162
|
}
|
|
@@ -4008,7 +4247,16 @@ async function startHolding(options, data, checked, stops) {
|
|
|
4008
4247
|
throw new ApiError("bad_request", "archived is true or false");
|
|
4009
4248
|
return value === "true";
|
|
4010
4249
|
}
|
|
4011
|
-
|
|
4250
|
+
/** GET /runs' `source`, once: a source's name (claude-code, codex, ...) keeps the runs imported from it, `live` the runs not imported. */
|
|
4251
|
+
function sourceParam(url) {
|
|
4252
|
+
const given = url.searchParams.getAll("source");
|
|
4253
|
+
if (given.length === 0)
|
|
4254
|
+
return undefined;
|
|
4255
|
+
if (given.length > 1 || !/^[a-z][a-z0-9-]{0,31}$/.test(given[0]))
|
|
4256
|
+
throw new ApiError("bad_request", "source is one source's name (claude-code, codex, ...), or live; once");
|
|
4257
|
+
return given[0];
|
|
4258
|
+
}
|
|
4259
|
+
async function runsPage(url, filter, origin, source) {
|
|
4012
4260
|
const limit = limitOf(url.searchParams.get("limit"));
|
|
4013
4261
|
const offset = cursorOf(url.searchParams.get("cursor"));
|
|
4014
4262
|
const status = url.searchParams.get("status");
|
|
@@ -4025,7 +4273,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
4025
4273
|
// ordered and cut to the page in one query, so a list costs the same at ten runs and at thousands, however long their
|
|
4026
4274
|
// journals. An audit's shadow run is no row of the list (learn/audit.ts): it is read by id, and its cost is its served
|
|
4027
4275
|
// run's. A run's archive is its own or its agent's.
|
|
4028
|
-
const where = { ...(filter.agent !== undefined ? { agentId: filter.agent } : {}), ...(filter.revision !== undefined ? { revisionId: filter.revision } : {}), ...(labels ? { labels } : {}), archived };
|
|
4276
|
+
const where = { ...(filter.agent !== undefined ? { agentId: filter.agent } : {}), ...(filter.revision !== undefined ? { revisionId: filter.revision } : {}), ...(labels ? { labels } : {}), ...(source !== undefined ? { source } : {}), archived };
|
|
4029
4277
|
// A listing is built by the server's lister (run-listing.ts) once per change, so a list finds it current. One that is
|
|
4030
4278
|
// behind (a write landed since, or the lister has not reached it since the store was upgraded) is built here, written
|
|
4031
4279
|
// back, and shown as built: for a status filter, first every run still going whose listing is behind (its row's
|
|
@@ -4315,7 +4563,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
4315
4563
|
switch (path) {
|
|
4316
4564
|
case "/setup": {
|
|
4317
4565
|
const byToken = req.headers.authorization !== undefined;
|
|
4318
|
-
if (byToken && !
|
|
4566
|
+
if (byToken && !startToken(req.headers.authorization, req))
|
|
4319
4567
|
throw new ApiError("unauthenticated", "the Bearer here is the server's token, or none", {}, { "www-authenticate": "Bearer" });
|
|
4320
4568
|
if (!byToken)
|
|
4321
4569
|
fromPage(req);
|
|
@@ -4334,7 +4582,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
4334
4582
|
const along = takes ? { keep: () => writeDurable(importAsked, chosen ? JSON.stringify({ projects: chosen }) : ""), drop: () => rm(importAsked, { force: true }) } : undefined;
|
|
4335
4583
|
// The server's API token stands in for the code in the code field too (on Render it is in the Environment tab, the
|
|
4336
4584
|
// code only in the log), compared as the header is, in constant time; a wrong one counts as a wrong code.
|
|
4337
|
-
const tokenAsCode = typeof body.code === "string" && body.code !== "" &&
|
|
4585
|
+
const tokenAsCode = typeof body.code === "string" && body.code !== "" && startToken(`Bearer ${body.code}`, req);
|
|
4338
4586
|
const made = await me.setFirst(password, body.code, byToken || tokenAsCode, along);
|
|
4339
4587
|
if (made === "exists")
|
|
4340
4588
|
throw new ApiError("forbidden", "this server has its owner, or is being set up: sign in");
|
|
@@ -4536,7 +4784,12 @@ async function startHolding(options, data, checked, stops) {
|
|
|
4536
4784
|
// skew check; left out when the store cannot say (a read that failed).
|
|
4537
4785
|
const state = await store.schemaState?.().catch(() => undefined);
|
|
4538
4786
|
const storeSchema = state ? { store_schema: { version: state.version, runner_floor: state.runnerFloor, known: state.known } } : {};
|
|
4539
|
-
|
|
4787
|
+
// features.harness_keys.kept names which harness ids still have keys stored: the owner's session or a holder of
|
|
4788
|
+
// the server's token reads it; a caller with neither (this route answers before any bearer check) reads none.
|
|
4789
|
+
const keptShown = byOwnerSession(req) || bearer(req.headers.authorization, req);
|
|
4790
|
+
const keptCap = { ...answer.features.harness_keys, kept: keptShown ? answer.features.harness_keys.kept : [] };
|
|
4791
|
+
// features.api_keys.routes: false on an API-only server, which serves none of the keys' routes and reads no key.
|
|
4792
|
+
return send(res, 200, { ...answer, ...storeSchema, runner_refused: runnerRefused, features: { ...answer.features, harness_keys: keptCap, computers: await computerCapabilities(computersOf()), triggers: { ...answer.features.triggers, public_url: Boolean(options.publicUrl) }, claude_login: !loginOff && !options.apiOnly, api_keys: { ...answer.features.api_keys, routes: !options.apiOnly } } });
|
|
4540
4793
|
}
|
|
4541
4794
|
if (found.name === "getOpenapi")
|
|
4542
4795
|
return send(res, 200, servedOpenapi(openapi, ownerCookieName(req)));
|
|
@@ -4812,7 +5065,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
4812
5065
|
await new CliLearningConnections(store, sdkSecret).recordWindow(connection.connection_id, connection.generation, runId, launch.cli_learning.session_id);
|
|
4813
5066
|
return send(res, 200, result);
|
|
4814
5067
|
}
|
|
4815
|
-
return send(res, 200, { ...await sdk.status(runId), learning: await servedRunLearning({ serverSecrets, signIns, statuses }, store, runId) });
|
|
5068
|
+
return send(res, 200, { ...await sdk.status(runId), learning: await servedRunLearning({ serverSecrets, signIns, sealKey, statuses }, store, runId) });
|
|
4816
5069
|
}
|
|
4817
5070
|
if (["getSdkRun", "sdkRunEvents", "completeSdkRun"].includes(found.name)) {
|
|
4818
5071
|
const runId = decodeURIComponent(found.pattern.exec(path)[1]);
|
|
@@ -4822,7 +5075,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
4822
5075
|
return send(res, 200, await sdk.events(runId, await bodyOf(req)));
|
|
4823
5076
|
if (found.name === "completeSdkRun")
|
|
4824
5077
|
return send(res, 200, await sdk.complete(runId, await bodyOf(req)));
|
|
4825
|
-
return send(res, 200, { ...await sdk.status(runId), learning: await servedRunLearning({ serverSecrets, signIns, statuses }, store, runId) });
|
|
5078
|
+
return send(res, 200, { ...await sdk.status(runId), learning: await servedRunLearning({ serverSecrets, signIns, sealKey, statuses }, store, runId) });
|
|
4826
5079
|
}
|
|
4827
5080
|
if (!bearer(req.headers.authorization, req)) {
|
|
4828
5081
|
authFailed(`/v2${path}`, req.headers.authorization === undefined ? "no_credential" : "wrong_token");
|
|
@@ -5217,7 +5470,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5217
5470
|
case "listAllRuns": {
|
|
5218
5471
|
const agent = url.searchParams.get("agent") ?? undefined;
|
|
5219
5472
|
const revision = url.searchParams.get("revision") ?? undefined;
|
|
5220
|
-
return send(res, 200, await runsPage(url, { ...(agent ? { agent } : {}), ...(revision ? { revision } : {}) }, linkOrigin(req)));
|
|
5473
|
+
return send(res, 200, await runsPage(url, { ...(agent ? { agent } : {}), ...(revision ? { revision } : {}) }, linkOrigin(req), sourceParam(url)));
|
|
5221
5474
|
}
|
|
5222
5475
|
case "getRun": {
|
|
5223
5476
|
const run = await runRead(id, linkOrigin(req));
|
|
@@ -5236,18 +5489,23 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5236
5489
|
throw unsupported("messages.steer_workflow_runs", "A workflow run takes no messages here: its workflow runs to its end, or a cancel ends it.");
|
|
5237
5490
|
const { body, handed } = handedLaunchSecrets(await bodyOf(req));
|
|
5238
5491
|
const answer = await idempotent(req, `/runs/${id}/messages`, body, async () => {
|
|
5239
|
-
const
|
|
5492
|
+
const secrets = await handed();
|
|
5493
|
+
const seal = await messageSeal(run, secrets);
|
|
5240
5494
|
const extra = unknownFields(body, ["content"]);
|
|
5241
5495
|
if (extra.length)
|
|
5242
5496
|
throw invalid(extra);
|
|
5243
|
-
const
|
|
5244
|
-
if (typeof
|
|
5245
|
-
throw invalid([{ field: "content", reason:
|
|
5246
|
-
if (
|
|
5497
|
+
const given = body.content;
|
|
5498
|
+
if (typeof given !== "string" || !/\S/.test(given))
|
|
5499
|
+
throw invalid([{ field: "content", reason: given === undefined ? "missing" : "wrong_type", message: "content is a non-empty string" }]);
|
|
5500
|
+
if (given.length > MAX_MESSAGE)
|
|
5247
5501
|
throw invalid([{ field: "content", reason: "too_long", message: `content is at most ${MAX_MESSAGE} characters` }]);
|
|
5248
5502
|
// Its mcp_auth and model_key replace the run's in the steer's own write, so the turn it starts uses them.
|
|
5249
5503
|
// In its agent's delete turn (runWrite): a message that may open the run again never lands under its purge.
|
|
5250
|
-
|
|
5504
|
+
// Its text is cut of what it hands and of what the run holds, read in that turn (cutHeld).
|
|
5505
|
+
const { mode, messageId } = await runWrite(run.agentId, run.id, async () => {
|
|
5506
|
+
const content = await cutHeld(run.id, given, handedSecretValues(secrets));
|
|
5507
|
+
return message(store, run, content, { ...(seal ? { launchSealed: seal } : {}), ...(options.beforeSubmit ? { beforeSubmit: options.beforeSubmit } : {}) });
|
|
5508
|
+
});
|
|
5251
5509
|
// The run's state after the command row is written (the run view): the runner applies the steer; the client polls.
|
|
5252
5510
|
const { status, state } = await runStatusState(run.id);
|
|
5253
5511
|
return { status: 202, body: { run_id: run.id, message_id: messageId, mode, status, state, poll_after_ms: 1000 } };
|
|
@@ -5507,7 +5765,8 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5507
5765
|
await needRun(id);
|
|
5508
5766
|
// A run's files through the server's read-only Workspace of its folder (serverRunWorkspace); a run with no folder
|
|
5509
5767
|
// lists none, a withheld run refuses (403), as the base did (filesShown). Same shape and cap the file route answered.
|
|
5510
|
-
|
|
5768
|
+
// With ?cut=run, each file's name under the run's cut too.
|
|
5769
|
+
return send(res, 200, await listRunFilesOverStore(store, id, runReadsDeps, url.searchParams.get("cut")));
|
|
5511
5770
|
}
|
|
5512
5771
|
// An archived agent's home is read and written as any other's: as its definition is.
|
|
5513
5772
|
case "listHomeFiles": {
|
|
@@ -5596,7 +5855,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5596
5855
|
// The run's lines from its booking (run-usage.ts), the figures its cost.usd joins: none, with why, while it is at work
|
|
5597
5856
|
// or where its figure is not its booking's.
|
|
5598
5857
|
// Names through the run's cut, and a withheld run refused (403), as its trace is.
|
|
5599
|
-
return send(res, 200, await servedRunUsage({ serverSecrets, signIns }, store, id));
|
|
5858
|
+
return send(res, 200, await servedRunUsage({ serverSecrets, signIns, sealKey }, store, id));
|
|
5600
5859
|
case "getRunTrace":
|
|
5601
5860
|
await needRun(id);
|
|
5602
5861
|
// The run's spans over its served Timeline rows and its journal (run-trace.ts): cut by the run's one cut, as its
|
|
@@ -5661,17 +5920,31 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5661
5920
|
case "getCapacity":
|
|
5662
5921
|
return send(res, 200, await capacityOverStore(store.runners, capacityWindowOf(url)));
|
|
5663
5922
|
case "getWrapped": {
|
|
5664
|
-
// The session files of the machine this server runs on
|
|
5665
|
-
//
|
|
5666
|
-
//
|
|
5667
|
-
|
|
5668
|
-
|
|
5923
|
+
// The session files of the machine this server runs on, read for whoever holds a token: only one owner's server on
|
|
5924
|
+
// their own machine answers (whyNotOwnersServer: loopback, no public URL, an owner, one API token and no live API key
|
|
5925
|
+
// made in the console, its own SQLite store). Keys are counted at each ask: they are made and revoked while it runs.
|
|
5926
|
+
// Dormant keys (API-only, --harness-sign-in) open nothing, so they are not callers here. A name an operator allowed (--allow-host) passes the server's Host check for its other routes, but a page
|
|
5927
|
+
// that rebound one to this address must not read the machine's files: here the Host is a loopback name or address.
|
|
5928
|
+
const notOwn = whyNotOwnersServer(options, data, options.apiOnly === true || options.harnessSignIn === true ? 0 : apiKeys.count);
|
|
5929
|
+
if (!isLoopbackName(hostName(req.headers.host)))
|
|
5930
|
+
notOwn.push("was reached at a name that is not this machine's own");
|
|
5931
|
+
if (notOwn.length)
|
|
5932
|
+
throw new ApiError("forbidden", `wrapped reads this machine's own session files, so only one owner's server on their own machine, reached by a loopback name, answers it. This one ${notOwn.join("; ")}.`);
|
|
5669
5933
|
const given = url.searchParams.get("year");
|
|
5670
5934
|
const year = given === null ? new Date().getFullYear() : Number(given);
|
|
5671
5935
|
if (given !== null && !/^[1-9]\d{3}$/.test(given))
|
|
5672
5936
|
throw new ApiError("bad_request", "year is a four-digit year");
|
|
5673
|
-
|
|
5674
|
-
|
|
5937
|
+
if (year > new Date().getFullYear())
|
|
5938
|
+
throw new ApiError("bad_request", "year is this year or an earlier one");
|
|
5939
|
+
// A long home is read on, shared, past the wait: the answer says when to ask again rather than hold the request.
|
|
5940
|
+
// A failed read is kept for its minute (keptReads): each ask in it is this 500, the reason in the server's log.
|
|
5941
|
+
const read = await within(readWrapped(year), options.wrappedWaitMs ?? WRAPPED_WAIT_MS).catch(() => {
|
|
5942
|
+
throw new ApiError("internal", `This machine's session history for ${year} could not be read: the server's log says why. Ask again in a minute to read it again.`);
|
|
5943
|
+
});
|
|
5944
|
+
if (!read)
|
|
5945
|
+
throw new ApiError("unavailable", `This machine's session history for ${year} is still being read: ask again in a few seconds.`, { retry_after_ms: 5_000 });
|
|
5946
|
+
const analytics = await analyticsOverStore(store, { from: new Date(year, 0, 1).toISOString(), to: new Date(year + 1, 0, 1).toISOString() });
|
|
5947
|
+
return send(res, 200, wrappedView(read.wrapped, analytics.bySource.filter((g) => g.source !== "live").map((g) => ({ source: g.source, runs: g.runs })), read.unread));
|
|
5675
5948
|
}
|
|
5676
5949
|
case "getStats": {
|
|
5677
5950
|
const filter = analyticsFilter(url);
|
|
@@ -5724,8 +5997,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5724
5997
|
await harnessKeysChanged();
|
|
5725
5998
|
return void res.writeHead(204, { "cache-control": "no-store" }).end();
|
|
5726
5999
|
}
|
|
6000
|
+
// A recipe this server names, or an id whose recipe it no longer names that still has keys kept: removed all the same.
|
|
5727
6001
|
case "deleteHarnessKey":
|
|
5728
|
-
await harnessKeys.remove(harnessKeys.
|
|
6002
|
+
await harnessKeys.remove(harnessKeys.held(id), decodeURIComponent(second));
|
|
5729
6003
|
await harnessKeysChanged();
|
|
5730
6004
|
return void res.writeHead(204, { "cache-control": "no-store" }).end();
|
|
5731
6005
|
// Never through `idempotent`: its record keeps the body, and the body holds the password.
|
|
@@ -5818,8 +6092,15 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5818
6092
|
return send(res, 200, await mcpServers.preview(await bodyOf(req), stopping.signal));
|
|
5819
6093
|
case "saveMcpServer": {
|
|
5820
6094
|
const body = await bodyOf(req);
|
|
6095
|
+
const preset = await mcpServers.composioPreset(id);
|
|
6096
|
+
// API-only, where this route is served only with the operator's MCP origins: a per_run server at one of them alone,
|
|
6097
|
+
// under a name no Composio preset has (api-only.ts apiOnlyMcpSave). Anything else is the refused route's own 404,
|
|
6098
|
+
// before anything reaches the address. The secret-write gate has already refused a credential, and a save over a
|
|
6099
|
+
// server the token did not save or one that seals a credential (403).
|
|
6100
|
+
if (options.apiOnly && !apiOnlyMcpSave(body, preset, apiOnlyMcpOrigins))
|
|
6101
|
+
throw new ApiError("not_found", apiOnlyRefusal(`/v2${path}`));
|
|
5821
6102
|
// A server that isn't a Composio preset's is saved at once, as ever: no save waits on another's listing.
|
|
5822
|
-
if (!
|
|
6103
|
+
if (!preset) {
|
|
5823
6104
|
const saved = await mcpServers.save(id, body, stopping.signal, secretSeen, undefined, undefined, undefined, undefined, byToken);
|
|
5824
6105
|
await refreshMcpMeta();
|
|
5825
6106
|
return send(res, 200, saved);
|
|
@@ -5845,6 +6126,8 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5845
6126
|
// Composio makes the managed MCP server; what is kept is the ordinary MCP save, so the key is a sealed header.
|
|
5846
6127
|
case "listComposioTools":
|
|
5847
6128
|
return send(res, 200, await composioTools(await bodyOf(req), options.composioControl ?? {}, stopping.signal), { "cache-control": "no-store" });
|
|
6129
|
+
case "listComposioToolkits":
|
|
6130
|
+
return send(res, 200, await composioToolkits(await bodyOf(req), options.composioControl ?? {}, stopping.signal), { "cache-control": "no-store" });
|
|
5848
6131
|
case "saveComposioServer": {
|
|
5849
6132
|
// The name is checked before Composio is called: a refused name leaves nothing made there.
|
|
5850
6133
|
mcpNameOf(id);
|
|
@@ -5875,7 +6158,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5875
6158
|
case "deleteComposioSubscription":
|
|
5876
6159
|
return send(res, 200, await composioTriggers.forget(id), { "cache-control": "no-store" });
|
|
5877
6160
|
case "refreshMcpServer": {
|
|
5878
|
-
const refreshed = await mcpServers.refresh(id, stopping.signal);
|
|
6161
|
+
const refreshed = await mcpServers.refresh(id, stopping.signal, options.composioControl ?? {});
|
|
5879
6162
|
await refreshMcpMeta();
|
|
5880
6163
|
return send(res, 200, refreshed);
|
|
5881
6164
|
}
|
|
@@ -6075,7 +6358,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6075
6358
|
const values = await learningValues(id);
|
|
6076
6359
|
const read = await agentLoopOverStore(store, id);
|
|
6077
6360
|
const compiles = await Promise.all(read.compiles.map(async (one) => {
|
|
6078
|
-
const cut = await runCutValues({ serverSecrets, signIns }, store, one.run_id).catch(() => "unreadable");
|
|
6361
|
+
const cut = await runCutValues({ serverSecrets, signIns, sealKey }, store, one.run_id).catch(() => "unreadable");
|
|
6079
6362
|
const workflow = one.workflow === null ? null : shown.name(one.workflow);
|
|
6080
6363
|
if (cut === "unreadable")
|
|
6081
6364
|
return { ...one, workflow, attempts: one.attempts.map(({ ok }) => ({ ok, errors: [] })), draft_errors: [], withheld: true };
|
|
@@ -6163,15 +6446,26 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6163
6446
|
// The run's learning view over the store (learning-1's runLearningOverStore): its end, the notes it was given and its seed
|
|
6164
6447
|
// 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.
|
|
6165
6448
|
// Cut by the run's one cut, and refused for a withheld run (run-learning-served.ts).
|
|
6166
|
-
return send(res, 200, await servedRunLearning({ serverSecrets, signIns, statuses }, store, run.id));
|
|
6449
|
+
return send(res, 200, await servedRunLearning({ serverSecrets, signIns, sealKey, statuses }, store, run.id));
|
|
6167
6450
|
}
|
|
6168
6451
|
case "getRunLearningDiff": {
|
|
6169
6452
|
const run = await needRun(id);
|
|
6170
6453
|
// The run's learning diff over the store (learning-routes.ts runDiffOverStore): its merge from its agent's learning
|
|
6171
6454
|
// folder, else its kept proposal's notes against its seed, else no file against the seed its launch names. Cut by the
|
|
6172
6455
|
// run's one cut, and refused for a withheld run, as its learning is (run-learning-served.ts).
|
|
6173
|
-
return send(res, 200, await servedRunDiff({ serverSecrets, signIns }, store, data, run.id));
|
|
6174
|
-
}
|
|
6456
|
+
return send(res, 200, await servedRunDiff({ serverSecrets, signIns, sealKey }, store, data, run.id));
|
|
6457
|
+
}
|
|
6458
|
+
case "listApiKeys":
|
|
6459
|
+
return send(res, 200, apiKeys.list(await apiKeysRefused()));
|
|
6460
|
+
case "createApiKey": {
|
|
6461
|
+
// A secret write: the dispatch's one check let only the owner's session this far (api-keys.ts). Never through
|
|
6462
|
+
// `idempotent`, whose record would keep the answer, and the answer holds the key. Refused, in words, where the
|
|
6463
|
+
// server is one person's (apiKeysRefused), asked in the create's own turn.
|
|
6464
|
+
return send(res, 201, await apiKeys.create(await bodyOf(req), apiKeysRefused));
|
|
6465
|
+
}
|
|
6466
|
+
case "revokeApiKey":
|
|
6467
|
+
await apiKeys.revoke(id);
|
|
6468
|
+
return void res.writeHead(204, { "cache-control": "no-store" }).end();
|
|
6175
6469
|
case "getWebhook":
|
|
6176
6470
|
return send(res, 200, webhooks.view());
|
|
6177
6471
|
case "saveWebhook": {
|
|
@@ -6239,6 +6533,12 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6239
6533
|
const pickView = await computerHere(listed);
|
|
6240
6534
|
return send(res, 200, { templates: listed.map((pkg) => ({ ...packageView(pkg), computer_here: pickView(pkg) })) });
|
|
6241
6535
|
}
|
|
6536
|
+
case "listMarketplaceTemplates": {
|
|
6537
|
+
// The marketplace's list as read (or kept), each entry with the package here that it is, when one is.
|
|
6538
|
+
const read = await marketplace.list();
|
|
6539
|
+
const here = registry.list();
|
|
6540
|
+
return send(res, 200, { ...read, templates: read.templates.map((entry) => { const id = hereOf(entry, here); return id ? { ...entry, here: id } : entry; }) });
|
|
6541
|
+
}
|
|
6242
6542
|
case "importTemplate": {
|
|
6243
6543
|
// Read from GitHub, or uploaded whole ({files}), and checked; a dry run answers it (200), else it is stored and
|
|
6244
6544
|
// served (201). The answer shows the package whole, its instructions and every skill file, for a person to read
|
|
@@ -6318,6 +6618,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6318
6618
|
}
|
|
6319
6619
|
case "listTriggerFirings":
|
|
6320
6620
|
return send(res, 200, await triggers.firings(id));
|
|
6621
|
+
case "releaseTriggerFiring":
|
|
6622
|
+
// The launch hook's host took the firing and will start no run for it: failed now, its trigger's room free. Its
|
|
6623
|
+
// words are kept and sent on (trigger.failed) as any stored string is, cut of every secret the server holds.
|
|
6624
|
+
return send(res, 200, await triggers.release(id, decodeURIComponent(second), await bodyOf(req), (text) => redacted(text, serverSecrets(), RELEASE_WORDS_MAX)));
|
|
6321
6625
|
}
|
|
6322
6626
|
throw new ApiError("not_found", `no route ${path}`);
|
|
6323
6627
|
}
|
|
@@ -6407,10 +6711,11 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6407
6711
|
const started = performance.now();
|
|
6408
6712
|
const method = req.method ?? "GET";
|
|
6409
6713
|
const path = (req.url ?? "/").split("?")[0];
|
|
6410
|
-
// Who the request was answered for: the owner's or the console's session,
|
|
6411
|
-
// (api-token.ts), never a secret. A request opened by
|
|
6714
|
+
// Who the request was answered for: the owner's or the console's session, the id of the API token it carried
|
|
6715
|
+
// (api-token.ts), or the id of the key made in the console (api-keys.ts): never a secret. A request opened by none
|
|
6716
|
+
// has no such field.
|
|
6412
6717
|
res.once("finish", () => {
|
|
6413
|
-
const by = byOwnerSession(req) ? { session: "owner" } : byConsoleSession(req) ? { session: "console" } : tokenUsed.has(req) ? { token: tokenUsed.get(req) } : {};
|
|
6718
|
+
const by = byOwnerSession(req) ? { session: "owner" } : byConsoleSession(req) ? { session: "console" } : tokenUsed.has(req) ? { token: tokenUsed.get(req) } : keyUsed.has(req) ? { api_key: keyUsed.get(req) } : {};
|
|
6414
6719
|
log(logLine("request", { method, path, status: res.statusCode, ms: Math.round(performance.now() - started), ...by }));
|
|
6415
6720
|
});
|
|
6416
6721
|
}
|
|
@@ -6456,7 +6761,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6456
6761
|
const raw = (req.url ?? "/").split("?")[0];
|
|
6457
6762
|
// API-only (api-only.ts): any address but the run routes is refused here, before the page, the owner's routes, the
|
|
6458
6763
|
// MCP endpoint, the token-less hooks or the token check read anything of the request.
|
|
6459
|
-
if (options.apiOnly && !servedApiOnly(ROUTES, req.method, raw))
|
|
6764
|
+
if (options.apiOnly && !servedApiOnly(ROUTES, req.method, raw, apiOnlyMcpOrigins.length > 0))
|
|
6460
6765
|
return fail(new ApiError("not_found", apiOnlyRefusal(raw)));
|
|
6461
6766
|
// Before the page: its cookie must not stand in for the token on the owner's own routes, nor on the MCP endpoint.
|
|
6462
6767
|
if (owner && (raw === "/v2/setup" || raw === "/v2/setup/import" || raw === "/v2/setup/code" || raw.startsWith("/v2/auth/")))
|
|
@@ -6904,8 +7209,8 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6904
7209
|
closing = true;
|
|
6905
7210
|
stopping.abort();
|
|
6906
7211
|
clearInterval(localSourceTimer);
|
|
6907
|
-
// Cancel a pending ChatGPT callback without signing out or changing the saved credential.
|
|
6908
|
-
plan.close();
|
|
7212
|
+
// Cancel a pending ChatGPT callback without signing out or changing the saved credential (not waited for).
|
|
7213
|
+
void plan.close();
|
|
6909
7214
|
// The CLI's sign-in still waiting for its browser ends with the server, which forgets it: left running, its CLI would
|
|
6910
7215
|
// keep the browser's callback port from the next server's sign-in. Awaited until its process is gone.
|
|
6911
7216
|
const signInStopped = claudeSignIns.close();
|
|
@@ -6918,11 +7223,12 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6918
7223
|
// triggers close, so it never turns one off into a closed file.
|
|
6919
7224
|
const githubStopped = githubConnect.close();
|
|
6920
7225
|
triggers.close();
|
|
7226
|
+
// A count and a Wrapped read write nothing: ended outright. An import stops between two files and keeps what it wrote.
|
|
6921
7227
|
for (const [worker, { task }] of workers) {
|
|
6922
|
-
if (task === "
|
|
6923
|
-
void worker.terminate();
|
|
6924
|
-
else
|
|
7228
|
+
if (task === "import")
|
|
6925
7229
|
worker.postMessage("stop");
|
|
7230
|
+
else
|
|
7231
|
+
void worker.terminate();
|
|
6926
7232
|
}
|
|
6927
7233
|
await Promise.all([...workers.values()].map((w) => w.exit));
|
|
6928
7234
|
await importing;
|
|
@@ -6938,8 +7244,11 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6938
7244
|
await slack.close();
|
|
6939
7245
|
// An upgraded socket is no connection closeAllConnections ends, and server.close waits for it.
|
|
6940
7246
|
viewers.close();
|
|
7247
|
+
clearInterval(routeTick);
|
|
6941
7248
|
await attach.close();
|
|
6942
7249
|
await new Promise((done) => (server.close(done), server.closeAllConnections()));
|
|
7250
|
+
// No request is left to use a key: its last-use writes end before the store they write to closes.
|
|
7251
|
+
await apiKeys.close();
|
|
6943
7252
|
await mcpStopped;
|
|
6944
7253
|
await githubStopped;
|
|
6945
7254
|
// --faux-github's fake GitHub API, once nothing asks it anything.
|
|
@@ -6959,6 +7268,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6959
7268
|
await store.close();
|
|
6960
7269
|
dataLock.release();
|
|
6961
7270
|
seal.release();
|
|
7271
|
+
// Last, so a stop cut at its deadline has closed the rest: the host-address retry, aborted above, its read in flight
|
|
7272
|
+
// cut then and its container's removal running since, within two REMOVE_MS.
|
|
7273
|
+
await hostRetried;
|
|
6962
7274
|
}
|
|
6963
7275
|
return {
|
|
6964
7276
|
url,
|
|
@@ -6972,6 +7284,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6972
7284
|
...(consoleSessions ? { launchCode: consoleSessions.code } : {}),
|
|
6973
7285
|
boxesLine: boxesLine(boxOffers, enabledBoxes(env), boxAllow, boxesByDefault(env)),
|
|
6974
7286
|
attachHub,
|
|
7287
|
+
beside,
|
|
6975
7288
|
dial: { ...(options.publicUrl ? { url: options.publicUrl.replace(/\/+$/, "") } : {}), tokens: attach.machineTokens, hub: attachHub },
|
|
6976
7289
|
localInstall,
|
|
6977
7290
|
ollamaHost,
|