@parcha/agentrun-serve 0.1.0-beta.54 → 0.1.0-beta.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +110 -2
- package/README.md +266 -88
- package/dist/adapters.d.ts +10 -0
- package/dist/adapters.js +46 -0
- package/dist/agent-package.d.ts +3 -3
- package/dist/agent-package.js +6 -13
- package/dist/agents-store.js +6 -5
- package/dist/api-only.d.ts +16 -4
- package/dist/api-only.js +21 -7
- package/dist/cli.js +5 -3
- package/dist/composio-made.d.ts +26 -1
- package/dist/composio-made.js +39 -2
- package/dist/composio-preset.d.ts +3 -2
- package/dist/composio-preset.js +46 -14
- package/dist/computer-held-routes.js +2 -3
- package/dist/computer-setting.d.ts +4 -2
- package/dist/computer-setting.js +0 -2
- package/dist/computers-running.d.ts +8 -0
- package/dist/computers-running.js +27 -0
- package/dist/console/assets/backend-D5EmB4N3.js +166 -0
- package/dist/console/assets/index-DUYLaqiR.js +746 -0
- package/dist/console/assets/index-DYhU4adm.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/docker-host-addresses.d.ts +23 -3
- package/dist/docker-host-addresses.js +90 -18
- package/dist/exa-keyless.d.ts +2 -3
- package/dist/exa-keyless.js +43 -127
- package/dist/firecrawl-keyless.d.ts +41 -0
- package/dist/firecrawl-keyless.js +152 -0
- package/dist/handed-secret.d.ts +3 -1
- package/dist/handed-secret.js +4 -2
- package/dist/harness-keys.d.ts +98 -0
- package/dist/harness-keys.js +247 -0
- package/dist/harness-recipe-entry.d.ts +14 -9
- package/dist/harness-recipe-entry.js +25 -14
- package/dist/harness-table.d.ts +16 -1
- package/dist/harness-table.js +19 -7
- package/dist/harness.d.ts +4 -0
- package/dist/harness.js +12 -1
- package/dist/host-check.d.ts +2 -0
- package/dist/host-check.js +6 -0
- package/dist/import-summary.d.ts +1 -1
- package/dist/import-summary.js +1 -1
- package/dist/import.d.ts +5 -5
- package/dist/import.js +54 -67
- package/dist/keyless-mcp.d.ts +36 -0
- package/dist/keyless-mcp.js +127 -0
- package/dist/learn/audit.d.ts +3 -3
- package/dist/learn/audit.js +3 -3
- package/dist/learn/commit.d.ts +8 -7
- package/dist/learn/commit.js +60 -20
- package/dist/learn/compile.d.ts +4 -3
- package/dist/learn/compile.js +7 -5
- package/dist/learn/folder.d.ts +16 -3
- package/dist/learn/folder.js +46 -13
- package/dist/learn/promote.d.ts +37 -13
- package/dist/learn/promote.js +112 -40
- package/dist/learn/secrets.js +10 -2
- package/dist/learning-routes.d.ts +22 -17
- package/dist/learning-routes.js +40 -39
- package/dist/learning.js +2 -2
- package/dist/manifest.d.ts +10 -0
- package/dist/manifest.js +30 -0
- package/dist/mcp-pin-first.d.ts +4 -2
- package/dist/mcp-pin-first.js +5 -2
- package/dist/mcp-secret-writes.d.ts +16 -7
- package/dist/mcp-secret-writes.js +35 -27
- package/dist/mcp-servers-store.d.ts +30 -6
- package/dist/mcp-servers-store.js +112 -28
- package/dist/mcp-sources.d.ts +10 -2
- package/dist/mcp-sources.js +9 -2
- package/dist/mcp-store.d.ts +13 -7
- package/dist/mcp-store.js +12 -9
- package/dist/model-form.d.ts +3 -2
- package/dist/model-form.js +11 -7
- package/dist/model.d.ts +20 -4
- package/dist/model.js +68 -9
- package/dist/native/history.d.ts +1 -1
- package/dist/native/history.js +2 -2
- package/dist/ollama-provider.d.ts +92 -0
- package/dist/ollama-provider.js +495 -0
- package/dist/openapi/agentrun-v2.openapi.json +2 -2
- package/dist/openapi.js +127 -37
- package/dist/page.d.ts +11 -3
- package/dist/page.js +22 -7
- package/dist/place-offers.d.ts +17 -1
- package/dist/place-offers.js +46 -5
- package/dist/print.js +1 -1
- package/dist/purged-workflow.d.ts +35 -7
- package/dist/purged-workflow.js +73 -26
- package/dist/run-computer.d.ts +2 -0
- package/dist/run-computer.js +2 -0
- package/dist/run-files.d.ts +4 -0
- package/dist/run-files.js +4 -0
- package/dist/run-keys.d.ts +2 -4
- package/dist/run-keys.js +6 -7
- package/dist/run-launch.d.ts +4 -0
- package/dist/run-launch.js +4 -0
- package/dist/run-reads-over-store.d.ts +3 -2
- package/dist/run-reads-over-store.js +66 -2
- package/dist/run-secrets.js +5 -2
- package/dist/runner/adapter-loop.d.ts +6 -3
- package/dist/runner/adapter-loop.js +34 -15
- package/dist/runner/adapter-run-spec.d.ts +3 -0
- package/dist/runner/adapter-run-spec.js +5 -3
- package/dist/runner/audit.js +8 -4
- package/dist/runner/beside.d.ts +2 -1
- package/dist/runner/beside.js +6 -2
- package/dist/runner/claim-secrets.d.ts +5 -8
- package/dist/runner/claim-secrets.js +6 -0
- package/dist/runner/cli-run-spec.d.ts +1 -1
- package/dist/runner/cli-run-spec.js +38 -6
- package/dist/runner/harness-loops.d.ts +22 -9
- package/dist/runner/harness-loops.js +21 -11
- package/dist/runner/held.d.ts +3 -0
- package/dist/runner/learning-end.d.ts +1 -1
- package/dist/runner/learning-end.js +8 -3
- package/dist/runner/loop-contract.d.ts +5 -4
- package/dist/runner/main.js +4 -2
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +26 -2
- package/dist/runner/mcp-run.d.ts +3 -0
- package/dist/runner/mcp-run.js +2 -1
- package/dist/runner/metrics.d.ts +10 -10
- package/dist/runner/metrics.js +19 -38
- package/dist/runner/model-route.d.ts +3 -0
- package/dist/runner/model-route.js +6 -2
- package/dist/runner/promotion.d.ts +15 -9
- package/dist/runner/promotion.js +25 -15
- package/dist/runner/run-child-host.js +17 -7
- package/dist/runner/run-child.js +3 -1
- package/dist/runner/sdk-loop.js +2 -0
- package/dist/runner/workflow-loop.d.ts +2 -2
- package/dist/runner/workflow-loop.js +1 -2
- package/dist/runner/workflow-spec.d.ts +1 -1
- package/dist/runner/workflow-spec.js +6 -6
- package/dist/sdk/check.d.ts +4 -1
- package/dist/sdk/check.js +2 -1
- package/dist/sdk/runs.d.ts +2 -2
- package/dist/sdk/runs.js +8 -6
- package/dist/secret-cut.js +2 -1
- package/dist/secret-writes.d.ts +3 -2
- package/dist/secret-writes.js +1 -1
- package/dist/server.d.ts +44 -8
- package/dist/server.js +283 -108
- package/dist/standard-webhooks.d.ts +11 -0
- package/dist/standard-webhooks.js +20 -2
- package/dist/store/index.d.ts +1 -1
- package/dist/store/schema.js +5 -2
- package/dist/store/sqlite/store.js +90 -34
- package/dist/store/store.d.ts +54 -14
- package/dist/store-reads/journal.d.ts +7 -2
- package/dist/store-reads/journal.js +9 -6
- package/dist/store-reads/learning.d.ts +12 -9
- package/dist/store-reads/learning.js +18 -24
- package/dist/store-view.d.ts +0 -5
- package/dist/store-view.js +9 -8
- package/dist/template-eval.d.ts +49 -4
- package/dist/template-eval.js +168 -45
- package/dist/template-import.js +4 -2
- package/dist/templates.d.ts +5 -3
- package/dist/templates.js +19 -40
- package/dist/timeline/labels.d.ts +2 -2
- package/dist/timeline/labels.js +2 -2
- package/dist/timeline/timeline.d.ts +2 -2
- package/dist/timeline/timeline.js +1 -1
- package/dist/tool-plane.d.ts +17 -9
- package/dist/tool-plane.js +38 -17
- package/dist/tools.js +2 -2
- package/dist/trigger-launch-hook.d.ts +16 -8
- package/dist/trigger-launch-hook.js +32 -23
- package/dist/trigger-targets.d.ts +18 -8
- package/dist/trigger-targets.js +42 -19
- package/dist/triggers.d.ts +85 -23
- package/dist/triggers.js +303 -96
- package/dist/web-fake.js +3 -3
- package/dist/web-fetch-direct.d.ts +4 -0
- package/dist/web-fetch-direct.js +8 -1
- package/dist/web-fetch.d.ts +12 -3
- package/dist/web-fetch.js +47 -14
- package/dist/web-search.d.ts +33 -4
- package/dist/web-search.js +100 -41
- package/dist/webhooks.js +4 -5
- package/launcher/agentrun-serve +5 -1
- package/package.json +17 -13
- package/templates/README.md +2 -2
- package/dist/console/assets/index-B_85An2t.js +0 -745
- package/dist/console/assets/index-n1YsbnYh.css +0 -1
- package/dist/import-sources.d.ts +0 -116
- package/dist/import-sources.js +0 -693
package/dist/server.js
CHANGED
|
@@ -31,7 +31,7 @@ import { createServer } from "node:http";
|
|
|
31
31
|
import proxyaddr from "proxy-addr";
|
|
32
32
|
import { API_ONLY_HOOKED_KINDS, apiOnlyRefusal, apiOnlyTriggerSkipped, servedApiOnly } from "./api-only.js";
|
|
33
33
|
import { RUN_KEYS_ENV } from "./env-switch.js";
|
|
34
|
-
import { declaredKeys, keysOwed, keysOwedRefusal,
|
|
34
|
+
import { declaredKeys, keysOwed, keysOwedRefusal, runKeysOf, runKeysTriggerSkipped, undeclaredKeys, withCarried } from "./run-keys.js";
|
|
35
35
|
import { capacityOverStore, capacityWindowOf } from "./capacity.js";
|
|
36
36
|
import { carriedFields } from "./answer-json.js";
|
|
37
37
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
@@ -50,15 +50,16 @@ import { DECISION_ADAPTER, decisionsOf, FAUX_JEV_ENV, FAUX_OPENROUTER_ENV, FAUX_
|
|
|
50
50
|
import { FAUX_WEB_ENV } from "./web-fetch-direct.js";
|
|
51
51
|
import { FAUX_MONID_ENV, MONID_KEY_ENV, pinMonid, PRICED_BY_USAGE } from "./monid.js";
|
|
52
52
|
import { FAUX_EXA_ENV } from "./exa-keyless.js";
|
|
53
|
+
import { FAUX_FIRECRAWL_ENV } from "./firecrawl-keyless.js";
|
|
53
54
|
import { FAUX_BROWSER_ENV, NODE_TOOLS, shellTools, toolingOf, toolOf, toolsView } from "./tools.js";
|
|
54
55
|
import { ApiError, invalid, sentence, unsupported } from "./errors.js";
|
|
55
56
|
import { deref, explain } from "./explain.js";
|
|
56
57
|
import { HOME_HOST_OWNED } from "./files.js";
|
|
57
58
|
import { DATA_ENV, syncDir, TOKEN_FILE, writeDurable } from "./server-fs.js";
|
|
58
59
|
import { homePath, hostOwnedOf } from "./home-path.js";
|
|
59
|
-
import { chooseModel, EFFORTS, FAUX_ENV, FAUX_UPSTREAM_ENV, MODEL_NODES, modelSource, THINKING_LEVELS, unpricedModels, withoutFaux } from "./model.js";
|
|
60
|
+
import { asksOllama, chooseModel, EFFORTS, FAUX_ENV, FAUX_UPSTREAM_ENV, MODEL_NODES, modelSource, THINKING_LEVELS, unpricedModels, withoutFaux } from "./model.js";
|
|
60
61
|
import { DEFAULT_HARNESS, HARNESSES, harnessOfBody, harnessOffers } from "./harness.js";
|
|
61
|
-
import { HARNESS_MODULES_ENV, HARNESS_MODULES_SETTING, HARNESS_RECIPES_ENV, HARNESS_RECIPES_SETTING, HARNESS_TABLE_ENV, harnessIds, harnessModulesEnv, harnessOf, harnessRecipesEnv, recipeHarness, tableIds } from "./harness-table.js";
|
|
62
|
+
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";
|
|
62
63
|
import { claudeCliIn, HarnessInstall, installDirOf, NPM_STOP_GRACE_MS, npmInstall } from "./harness-install.js";
|
|
63
64
|
import { DEFAULT_PORT, healthOf, hostMemory, maxRunsOf, runsThatFit } from "./host.js";
|
|
64
65
|
import { DEFAULT_HOST, elsewhereOf, listenOn, minFreeMibOf, takeOver, urlOf } from "./listen-first.js";
|
|
@@ -67,7 +68,7 @@ import { answerStoreCall } from "./import-proxy.js";
|
|
|
67
68
|
import { LEARNING_LABEL, learningFolderOf, secretsShown, learningOf, learnsOf, RUN_LEARNING_USE, seedOf, withAgentRepo } from "./learning.js";
|
|
68
69
|
import { askReplay, ReplayRefused, replayView } from "./runner/promotion.js";
|
|
69
70
|
import { agentLearning, changeWorkflow, correctionsView, correctionsWrite, forgetRunLearning, learningLog, pendingCount, readLearnedFile, sendText, statusesOf, textBody, workflowAtDigest, workflowRevisions } from "./learning-routes.js";
|
|
70
|
-
import { purgedRun } from "./purged-workflow.js";
|
|
71
|
+
import { purgedRun, refusedIn } from "./purged-workflow.js";
|
|
71
72
|
import { answerLlms, MCP_PATH, mcpEndpoint } from "./mcp.js";
|
|
72
73
|
import { openapiDocument, servedOpenapi, UNSUPPORTED } from "./openapi.js";
|
|
73
74
|
import { boxAvailability, boxesLine, defaultPlaceOf, NEW_AGENT_TOOLS, newAgentPlace, noBoxReason, placesOf, resolvePlace } from "./place.js";
|
|
@@ -75,7 +76,7 @@ import { boxAllowOf, boxAllowSetIn } from "./box-settings.js";
|
|
|
75
76
|
import { dockerLimitsOf } from "./workspace/computer-deps.js";
|
|
76
77
|
import { Owner, passwordProblem, SESSION_MS } from "./owner.js";
|
|
77
78
|
import { acceptedTokens, bearerCheck, tokenProblem } from "./api-token.js";
|
|
78
|
-
import { answerPage, byConsoleSession, byOwnerSession, ConsoleSessions, consoleEntry, heldSessions, isJson, overHttps, ownerCookie, ownOrigin, sendHostRefused, sendMoved, sendMovedPage, signedIn } from "./page.js";
|
|
79
|
+
import { answerPage, byConsoleSession, byOwnerSession, ConsoleSessions, consoleEntry, heldSessions, isJson, overHttps, ownerCookie, ownerCookieName, ownOrigin, sessionsAtEveryPort, sendHostRefused, sendMoved, sendMovedPage, signedIn } from "./page.js";
|
|
79
80
|
import { hostFix, hostName, loopbackNames, movedFix } from "./host-check.js";
|
|
80
81
|
import { movedAddress, publicAddressChanged, readPublicAddress } from "./public-address.js";
|
|
81
82
|
import { computerViewerLink, familyReaches, liveViewerById, liveViewerFor, liveViewerLink, OpenViewers, proxyLiveUpgrade, serveViewerFile, viewerAnswers } from "./browser-live.js";
|
|
@@ -125,6 +126,7 @@ import { championOf, forgetRunCopies, GRADE_SOURCES, gradeView, LABEL_MAX, promo
|
|
|
125
126
|
import { workflowNodesOf } from "./learn/workflow-nodes.js";
|
|
126
127
|
import { deleteLearning } from "./learn/delete.js";
|
|
127
128
|
import { runModelRef } from "./model.js";
|
|
129
|
+
import { ollamaHostOf, ollamaHostRefused, ollamaListing, ollamaModels } from "./ollama-provider.js";
|
|
128
130
|
import { REDACTED } from "./secret-cut.js";
|
|
129
131
|
// The v2 run statuses, as the run view names them (run-view.ts Status), for the list filter's validation. */
|
|
130
132
|
const STATUSES = ["queued", "working", "paused", "input_required", "completed", "failed", "cancelled"];
|
|
@@ -132,7 +134,7 @@ import { runLines } from "./usage-lines.js";
|
|
|
132
134
|
import { boxesByDefault, boxesLog, enabledBoxes, placeOffers, withNetworks } from "./place-offers.js";
|
|
133
135
|
import { dockerComputerRefusal, dockerPathsOf, FAUX_MOUNTINFO_ENV, remoteDockerOnce } from "./box-paths.js";
|
|
134
136
|
import { dockerDaemonCheck } from "./docker-daemon.js";
|
|
135
|
-
import { hostAddressesOnce, noHostAddresses, unionOf } from "./docker-host-addresses.js";
|
|
137
|
+
import { hostAddressesOnce, noHostAddresses, retryHostAddresses, unionOf } from "./docker-host-addresses.js";
|
|
136
138
|
import { DOCUMENTS_ENV } from "./pdf-pages.js";
|
|
137
139
|
import { blockersOf, CODE_NODES_ENV, issueOf, NOT_SET_UP } from "./runnable.js";
|
|
138
140
|
import { hostSecrets, SECRET_NAMES, secret, withSecrets } from "./secrets.js";
|
|
@@ -154,10 +156,11 @@ import { agentCostOverStore, agentLearningOverStore, costStopOverStore, learning
|
|
|
154
156
|
import { costCsv, learningCostQuery, RUN_PATHS } from "./learning-cost.js";
|
|
155
157
|
import { keyOf, SEAL_KEY_ENV, TOOL_FIELDS } from "./tool-keys.js";
|
|
156
158
|
import { toolKeysOverStore } from "./tool-keys-store.js";
|
|
159
|
+
import { HarnessKeysOverStore, harnessKeysSavedHere } from "./harness-keys.js";
|
|
157
160
|
import { SIGN_INS_DIR, vendorsOver } from "./sign-ins.js";
|
|
158
161
|
import { signInsOverStore } from "./sign-ins-store.js";
|
|
159
162
|
import { boundTool, MCP_AUTH_TYPES, marked, mcpAuthOf, nameOf as mcpNameOf } from "./mcp-probe.js";
|
|
160
|
-
import { composioMadeKey, composioPerRun } from "./composio-made.js";
|
|
163
|
+
import { composioEnvKey, composioMadeKey, composioPerRun } from "./composio-made.js";
|
|
161
164
|
import { COMPOSIO_PER_RUN, composioForget, composioNote, composioSave, composioTools } from "./composio-preset.js";
|
|
162
165
|
import { ComposioTriggers, composioNoPublicUrl } from "./composio-triggers.js";
|
|
163
166
|
import { loopbackWords, mcpServersOverStore } from "./mcp-servers-store.js";
|
|
@@ -216,8 +219,9 @@ import { emailRoute } from "./email/routes.js";
|
|
|
216
219
|
import { addressForms, openCalendar } from "./calendar/address.js";
|
|
217
220
|
import { calendarRoute } from "./calendar/routes.js";
|
|
218
221
|
import { agentDiskOf, ARCHIL_DISK_ID, archilSettingsFromEnv, inArchilMode, loadArchilSettings, runDiskKept, runDiskKey } from "./archil-settings.js";
|
|
219
|
-
import { computerOfPlace } from "./computer-setting.js";
|
|
222
|
+
import { computerOfPlace, settingOfDefinition } from "./computer-setting.js";
|
|
220
223
|
import { computerCapabilities, createComputerRoutes, folderModeOf, hostCommandRefusals, settingsComputerRoute } from "./computers.js";
|
|
224
|
+
import { runningComputers } from "./computers-running.js";
|
|
221
225
|
import { fauxComputers } from "./faux-computers.js";
|
|
222
226
|
import { writesHeld } from "./workspace.js";
|
|
223
227
|
import { deleteExternalAgent, oneAtATime, purgeAgent, purgeRun, purgingKey } from "./agent-delete.js";
|
|
@@ -248,6 +252,9 @@ const IMPORT_STARTS = 3;
|
|
|
248
252
|
const IMPORT_HEAP_MB = 2048;
|
|
249
253
|
const MAX_MESSAGE = 20_000;
|
|
250
254
|
const MAX_WAIT_MS = 25_000;
|
|
255
|
+
/** A run body's fields that a launch hook's host can't set on a firing's run (RunCreate `trigger_firing`): its trigger's
|
|
256
|
+
* target fixes them. */
|
|
257
|
+
const HANDED_FIXED = ["revision", "hold", "hold_minutes"];
|
|
251
258
|
/** How often the server fails the runs still queued while no runner here can take them (runner/presence.ts). */
|
|
252
259
|
const REFUSED_SWEEP_MS = 2_000;
|
|
253
260
|
const PAGE_ROWS = 500;
|
|
@@ -280,6 +287,9 @@ export function fauxEnvOf(options) {
|
|
|
280
287
|
for (const [option, name] of FAUX_SWITCHES)
|
|
281
288
|
if (options[option])
|
|
282
289
|
env[name] = resolve(options[option]);
|
|
290
|
+
// A URL, so never resolved as a path.
|
|
291
|
+
if (options.fauxFirecrawl)
|
|
292
|
+
env[FAUX_FIRECRAWL_ENV] = options.fauxFirecrawl;
|
|
283
293
|
// The mountinfo the server itself reads (fauxMountinfo in serve), also when its own environment names it: a CLI server
|
|
284
294
|
// in a container hands it to the runner beside it, whose environment drops every faux variable it inherited.
|
|
285
295
|
const mountinfo = options.fauxMountinfo ?? process.env[FAUX_MOUNTINFO_ENV];
|
|
@@ -404,6 +414,7 @@ export const ROUTES = [
|
|
|
404
414
|
// Settings → Computers (computers.ts settingsComputerRoute) and the owner's Archil settings (archil-routes.ts
|
|
405
415
|
// archilRoute): the server switch dispatches them, once the server opens its store.
|
|
406
416
|
{ method: "GET", pattern: /^\/computers$/, name: "listComputers" },
|
|
417
|
+
{ method: "GET", pattern: /^\/computers\/running$/, name: "listRunningComputers" },
|
|
407
418
|
{ method: "PUT", pattern: /^\/computers\/([^/]+)\/keys$/, name: "saveComputerKeys" },
|
|
408
419
|
{ method: "POST", pattern: /^\/computers\/([^/]+)\/test$/, name: "testComputer" },
|
|
409
420
|
{ method: "GET", pattern: /^\/computers\/([^/]+)\/choices$/, name: "listComputerChoices" },
|
|
@@ -434,6 +445,10 @@ export const ROUTES = [
|
|
|
434
445
|
{ method: "GET", pattern: /^\/settings\/tool-keys$/, name: "listToolKeys" },
|
|
435
446
|
{ method: "PUT", pattern: /^\/settings\/tool-keys\/([^/]+)$/, name: "saveToolKey" },
|
|
436
447
|
{ method: "DELETE", pattern: /^\/settings\/tool-keys\/([^/]+)$/, name: "deleteToolKey" },
|
|
448
|
+
// The keys a plan-billed harness recipe runs on, saved for that harness alone (harness-keys.ts): the owner's session's.
|
|
449
|
+
{ method: "GET", pattern: /^\/settings\/harness-keys$/, name: "listHarnessKeys" },
|
|
450
|
+
{ method: "PUT", pattern: /^\/settings\/harness-keys\/([^/]+)\/([^/]+)$/, name: "saveHarnessKey" },
|
|
451
|
+
{ method: "DELETE", pattern: /^\/settings\/harness-keys\/([^/]+)\/([^/]+)$/, name: "deleteHarnessKey" },
|
|
437
452
|
// The server's email account (email/routes.ts): the owner's session's alone, its password in no answer.
|
|
438
453
|
{ method: "GET", pattern: /^\/settings\/email$/, name: "getEmailAccount" },
|
|
439
454
|
{ method: "PUT", pattern: /^\/settings\/email$/, name: "saveEmailAccount" },
|
|
@@ -617,9 +632,10 @@ export function offersEnvOf(env) {
|
|
|
617
632
|
* harnesses run, and on what, follow them. */
|
|
618
633
|
const GATEWAY_VARS = ["AGENT_MODEL_BASE_URL", "AGENT_MODEL_GATEWAY_IDS", "AGENT_MODEL", "AGENT_MODEL_FAST", "AGENT_MODEL_STRONG"];
|
|
619
634
|
/** What of `env` a write can change that the harnesses' offers are made from: each secret but the tool keys' fields (a
|
|
620
|
-
* saved key is one of those; the rest of the environment is the server's start's)
|
|
621
|
-
* the offers probed again,
|
|
622
|
-
|
|
635
|
+
* saved key is one of those; the rest of the environment is the server's start's), and the models the Ollama here
|
|
636
|
+
* listed when last asked (ollamaListing). Held to tell whether a write, or a new listing, needs the offers probed again,
|
|
637
|
+
* never shown. */
|
|
638
|
+
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)?.dir, ollamaListing(env)];
|
|
623
639
|
/** 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. */
|
|
624
640
|
async function planStep(step) {
|
|
625
641
|
try {
|
|
@@ -690,8 +706,12 @@ function capabilitiesWith(env, maxRuns, harnesses, learning, { needs, priced, le
|
|
|
690
706
|
* a user of its own too. */
|
|
691
707
|
run_isolation: isolation,
|
|
692
708
|
/** The harnesses a revision may name (`definition.harness`), whether this server runs each, and how many at once. */
|
|
693
|
-
// `keys`, what a model key would unlock, is the key rows' (listToolKeys), never served here.
|
|
694
|
-
|
|
709
|
+
// `keys`, what a model key would unlock, is the key rows' (listToolKeys), never served here. Served `available` is
|
|
710
|
+
// whether a run of it can start now on some model it offers: one whose every model lacks a key or the sign-in
|
|
711
|
+
// (noModelRuns: pi with neither) is not, though a save and a run read it as a harness that runs here (runnable.ts), so
|
|
712
|
+
// their words name the model it lacks. One whose default lacks a key while another model runs is (its `needs` says
|
|
713
|
+
// what the default lacks).
|
|
714
|
+
harnesses: harnesses.map(({ keys: _keys, noModelRuns, ...offer }) => ({ ...offer, available: offer.available && !noModelRuns, max_concurrent_runs: Math.min(maxRuns, runsThatFit(offer.id, memory, env)) })),
|
|
695
715
|
/** The places a revision may name (`definition.place`), this host's default, and whether this server has each box. */
|
|
696
716
|
places: placesOf(boxes, boxAllowOf(env)),
|
|
697
717
|
models,
|
|
@@ -753,6 +773,9 @@ function capabilitiesWith(env, maxRuns, harnesses, learning, { needs, priced, le
|
|
|
753
773
|
/** GET, PUT and DELETE /settings/tool-keys: a tool's key saved by name, kept sealed under the server's seal key
|
|
754
774
|
* (tool-keys-store.ts), never in the clear. */
|
|
755
775
|
tool_keys: { routes: true, at_rest: "sealed" },
|
|
776
|
+
/** GET /settings/harness-keys and PUT/DELETE of one key: a plan-billed recipe's keys, saved for that harness alone
|
|
777
|
+
* (harness-keys.ts); `harnesses` its ids here, so the console offers the page only where there is one. */
|
|
778
|
+
harness_keys: { routes: true, at_rest: "sealed", harnesses: planRecipesOf(env).map((recipe) => recipe.id) },
|
|
756
779
|
/** /settings/mcp-servers: remote MCP servers previewed and saved, each credential sealed under the server's seal key,
|
|
757
780
|
* which always exists (seal-key.ts), so MCP credentials are always kept sealed. Every harness of the table runs a
|
|
758
781
|
* grant (runnable.ts takes one on any), a module's among them. */
|
|
@@ -823,17 +846,18 @@ function integerParam(value, name, max) {
|
|
|
823
846
|
}
|
|
824
847
|
/** A start with --harness-sign-in on a server that is not one owner's own, on their own machine. */
|
|
825
848
|
export const HARNESS_SIGN_IN_NOT_LOCAL = "HARNESS_SIGN_IN_NOT_LOCAL";
|
|
826
|
-
/** Why `options` on `data`
|
|
827
|
-
*
|
|
828
|
-
*
|
|
829
|
-
*
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
|
|
849
|
+
/** Why `options` on `data` is not one owner's own server on their own machine, each reason in words; none when it is. One
|
|
850
|
+
* owner's own: it listens on loopback alone, with no public address; its store is the SQLite one in its data directory (no
|
|
851
|
+
* AGENTRUN_STORE_URL, which servers elsewhere share); its runs run beside it as its own user (`ownUser`:
|
|
852
|
+
* runIsolationOf's `process`), never under --no-runner or a user of their own; and one person starts them, as Claude
|
|
853
|
+
* Code's login on this machine asks (claude-login.ts whyNotOneOwner): an owner, and one API token. What --harness-sign-in
|
|
854
|
+
* starts under (harnessSignInRefusal), and where the Ollama at this machine's default address is a model of the person
|
|
855
|
+
* who starts runs (ollama-provider.ts ollamaHostOf). */
|
|
856
|
+
export function whyNotOwnMachine(options, data, ownUser) {
|
|
833
857
|
const host = options.host ?? DEFAULT_HOST;
|
|
834
858
|
// Every token the server takes (acceptedTokens): AGENTRUN_TOKEN's as `default` beside the list's, or else DIR/.token's alone.
|
|
835
859
|
const tokens = (options.token === undefined ? 0 : 1) + (options.tokens?.length ?? 0);
|
|
836
|
-
|
|
860
|
+
return [
|
|
837
861
|
...(loopback(host) ? [] : [`listens on ${host}, past loopback`]),
|
|
838
862
|
...(options.publicUrl ? [`has a public address (${options.publicUrl})`] : []),
|
|
839
863
|
...(options.apiOnly ? ["has no owner (the API-only profile), so anyone with its token starts runs"] : []),
|
|
@@ -842,6 +866,12 @@ export function harnessSignInRefusal(options, data, ownUser) {
|
|
|
842
866
|
...(options.runnerApart ? ["runs no runner beside it (--no-runner)"] : []),
|
|
843
867
|
...(ownUser ? [] : ["runs each run as a user of its own (unset AGENTRUN_RUN_USER=slot, or set AGENTRUN_RUN_USER=same)"]),
|
|
844
868
|
];
|
|
869
|
+
}
|
|
870
|
+
/** Why `options` on `data` may not run a recipe on its owner's own sign-in (--harness-sign-in), in words; undefined when
|
|
871
|
+
* it may: one owner's own server on their own machine alone (whyNotOwnMachine). A check, a schedule and a shared server
|
|
872
|
+
* run on a key (HARNESS.md#sign-in). */
|
|
873
|
+
export function harnessSignInRefusal(options, data, ownUser) {
|
|
874
|
+
const why = whyNotOwnMachine(options, data, ownUser);
|
|
845
875
|
return why.length ? `${HARNESS_SIGN_IN_NOT_LOCAL}: --harness-sign-in runs a recipe on its owner's own sign-in on one owner's own machine alone, and this server ${why.join("; ")}. Start it without --harness-sign-in: its plan-billed recipes run on keys.` : undefined;
|
|
846
876
|
}
|
|
847
877
|
// A data directory an earlier version wrote (old agent homes, an old runs/ layout, or an earlier store version) is refused
|
|
@@ -861,12 +891,16 @@ export async function startServe(options) {
|
|
|
861
891
|
await mkdir(resolve(options.data), { recursive: true, mode: 0o700 });
|
|
862
892
|
// Canonical once, here: a computer's mount source below it must then be its own canonical path, through no link.
|
|
863
893
|
const data = await realpath(resolve(options.data));
|
|
894
|
+
const { runsAsOwnUser } = await import("./runner/run-child-host.js");
|
|
895
|
+
const ownUser = runsAsOwnUser(process.env);
|
|
864
896
|
if (options.harnessSignIn) {
|
|
865
|
-
const
|
|
866
|
-
const refused = harnessSignInRefusal(options, data, runsAsOwnUser(process.env));
|
|
897
|
+
const refused = harnessSignInRefusal(options, data, ownUser);
|
|
867
898
|
if (refused)
|
|
868
899
|
throw new Error(refused);
|
|
869
900
|
}
|
|
901
|
+
// The Ollama this server asks, and its runner beside it: OLLAMA_HOST, else the default address on one owner's own machine
|
|
902
|
+
// alone (ollamaHostOf). Read once, at the start: a refused one is said once, here, in the base rule's words.
|
|
903
|
+
const ollamaHost = ollamaHostOf(process.env, whyNotOwnMachine(options, data, ownUser).length === 0);
|
|
870
904
|
const tokenRefused = options.token === undefined ? undefined : tokenProblem(options.token);
|
|
871
905
|
if (tokenRefused)
|
|
872
906
|
throw new Error(tokenRefused);
|
|
@@ -907,7 +941,7 @@ export async function startServe(options) {
|
|
|
907
941
|
// store handle it opened.
|
|
908
942
|
const stops = [];
|
|
909
943
|
try {
|
|
910
|
-
return await startHolding(options, data, { maxRuns, minFreeBytes, learning, boxAllow, templates }, stops);
|
|
944
|
+
return await startHolding(options, data, { maxRuns, minFreeBytes, learning, boxAllow, templates, ollamaHost }, stops);
|
|
911
945
|
}
|
|
912
946
|
catch (error) {
|
|
913
947
|
for (const stop of stops)
|
|
@@ -937,7 +971,7 @@ async function whileReplaced(take, held, until, waiting) {
|
|
|
937
971
|
}
|
|
938
972
|
}
|
|
939
973
|
async function startHolding(options, data, checked, stops) {
|
|
940
|
-
const { maxRuns, minFreeBytes, learning, boxAllow, templates } = checked;
|
|
974
|
+
const { maxRuns, minFreeBytes, learning, boxAllow, templates, ollamaHost } = checked;
|
|
941
975
|
/** What an agent's view says of its learning: how many learned items wait for its owner's OK, for an agent that learns
|
|
942
976
|
* on this server (learning on, its current revision `learning: true`); none for another, or when the count cannot be
|
|
943
977
|
* read (the view never fails for it). */
|
|
@@ -959,7 +993,12 @@ async function startHolding(options, data, checked, stops) {
|
|
|
959
993
|
// shown nowhere.
|
|
960
994
|
let secretStores;
|
|
961
995
|
let triggerSettings = new Map();
|
|
962
|
-
const base = { ...withoutFaux(process.env), [DATA_ENV]: data, ...(options.allowCodeNodes ? { [CODE_NODES_ENV]: "1" } : {}), ...(options.faux ? { [FAUX_ENV]: resolve(options.faux) } : {}), ...(options.harnessTable ? { [HARNESS_TABLE_ENV]: resolve(options.harnessTable) } : {}), ...harnessModulesEnv(options.harnessModules ?? [], data), ...harnessRecipesEnv(options.harnessRecipes ?? [], data, { signIn: options.harnessSignIn === true }) };
|
|
996
|
+
const base = { ...withoutFaux(process.env), [DATA_ENV]: data, ...(options.allowCodeNodes ? { [CODE_NODES_ENV]: "1" } : {}), ...(options.faux ? { [FAUX_ENV]: resolve(options.faux) } : {}), ...(options.harnessTable ? { [HARNESS_TABLE_ENV]: resolve(options.harnessTable) } : {}), ...harnessModulesEnv(options.harnessModules ?? [], data), ...harnessRecipesEnv(options.harnessRecipes ?? [], data, { signIn: options.harnessSignIn === true }), ...(ollamaHost ? { OLLAMA_HOST: ollamaHost } : {}) };
|
|
997
|
+
// A refused OLLAMA_HOST lists nothing (ollama-provider.ts baseOf): said once, at the start, in the base rule's words,
|
|
998
|
+
// which never hold the value (a user or password in it stays unsaid).
|
|
999
|
+
const ollamaRefused = ollamaHostRefused(base);
|
|
1000
|
+
if (ollamaRefused)
|
|
1001
|
+
log ? log(logLine("ollama_host_refused", { line: ollamaRefused })) : void process.stderr.write(`agentrun-serve: ${ollamaRefused}\n`);
|
|
963
1002
|
// The table, loaded once here: a harness module that is missing, names a built-in harness or gives half an entry refuses
|
|
964
1003
|
// the start, in words, before anything else opens.
|
|
965
1004
|
// The harness ids a definition may name here: the table's, the built-in ones and those the modules add, and one the
|
|
@@ -1060,6 +1099,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1060
1099
|
// call each the server's, and none could be deleted. The keys are sealed rows in the store; load() reads them once here.
|
|
1061
1100
|
const toolKeys = toolKeysOverStore(store, own(withSecrets(base, "own")), (fields) => (log ? log(logLine("tool_keys", fields)) : void process.stderr.write(`agentrun-serve: ${logLine("tool_keys", fields)}\n`)));
|
|
1062
1101
|
await toolKeys.load();
|
|
1102
|
+
// The keys each plan-billed harness recipe this server names runs on, saved for that harness alone (harness-keys.ts):
|
|
1103
|
+
// sealed rows in the store, loaded once here and kept in step with every save, so its listing reads them at once.
|
|
1104
|
+
const harnessKeys = new HarnessKeysOverStore(store, seal.key, planRecipesOf(base), data);
|
|
1105
|
+
await harnessKeys.load();
|
|
1063
1106
|
// A key's check as it is saved (key-check.ts) goes to its provider; under faux only to the tests' fake for that provider,
|
|
1064
1107
|
// the one its runs are given (monid, Parallel, TypeSafe's Jev), never to the network: one with no fake is not checked.
|
|
1065
1108
|
const fakes = { monid: options.fauxMonid, parallel: options.fauxParallel, typesafe: options.fauxJev, browserbase: options.fauxBrowserbase, kernel: options.fauxKernel };
|
|
@@ -1070,7 +1113,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1070
1113
|
return fake ? (await import(pathToFileURL(resolve(fake)).href)).default : undefined;
|
|
1071
1114
|
};
|
|
1072
1115
|
// Aborted as close() begins: a key's check still waiting on its provider stops waiting, and its save stores nothing.
|
|
1116
|
+
// A start that fails aborts it too: what began on it (the host-address read's retry) stops with that start.
|
|
1073
1117
|
const stopping = new AbortController();
|
|
1118
|
+
stops.push(async () => stopping.abort());
|
|
1074
1119
|
/** The after-start seal by the events' schemas (composio-triggers.ts sealMarked), drained by stop. */
|
|
1075
1120
|
let schemaSealed = Promise.resolve();
|
|
1076
1121
|
// The start's sweep of ended runs whose stored cost is unknown (cost-heal.ts), once this server listens; stop drains it.
|
|
@@ -1083,16 +1128,22 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1083
1128
|
const mcpServers = mcpServersOverStore(store, own(withSecrets(base, "own")), VERSION);
|
|
1084
1129
|
if (options.githubMcpOrigin)
|
|
1085
1130
|
mcpServers.appOrigin = options.githubMcpOrigin;
|
|
1131
|
+
if (options.composioMcpOrigin)
|
|
1132
|
+
mcpServers.composioOrigin = options.composioMcpOrigin;
|
|
1086
1133
|
mcpServers.standIns = options.mcpStandIns === true;
|
|
1087
1134
|
// The saved MCP servers' metadata (their addresses and the tools they list), a snapshot the checks read in step (which
|
|
1088
1135
|
// servers are saved, a workflow's grants, the template apply): the server is the one writer of these rows (a save,
|
|
1089
1136
|
// refresh, sign-in or delete), so the snapshot is refreshed after each of those and reads what is saved now. An agent's
|
|
1090
1137
|
// save lists its granted servers live and pins their tools on its revision (saveable, mcpListingOf); the runner reads
|
|
1091
1138
|
// that pin and the credentials from the store at a run's claim (runner/mcp-claim.ts); this server hands a run no MCP
|
|
1092
|
-
// source. Each with what it is (its source and toolkit, mcp-sources.ts), which a template's apply maps its MCP needs on
|
|
1139
|
+
// source. Each with what it is (its source and toolkit, mcp-sources.ts), which a template's apply maps its MCP needs on,
|
|
1140
|
+
// and the variable a Composio server saved with api_key_env reads its key from (`keyEnv`), which a run's start checks.
|
|
1093
1141
|
let mcpMeta = new Map();
|
|
1094
1142
|
const refreshMcpMeta = async () => {
|
|
1095
|
-
mcpMeta = new Map(await Promise.all((await listMcpServers(store)).map(async (row) =>
|
|
1143
|
+
mcpMeta = new Map(await Promise.all((await listMcpServers(store)).map(async (row) => {
|
|
1144
|
+
const keyEnv = await mcpServers.keyEnvOf(row);
|
|
1145
|
+
return [row.name, { url: row.url, auth: row.auth, tools: row.tools ?? [], source: await mcpServers.sourceOf(row), ...(keyEnv ? { keyEnv } : {}) }];
|
|
1146
|
+
})));
|
|
1096
1147
|
};
|
|
1097
1148
|
await refreshMcpMeta();
|
|
1098
1149
|
// Each saved server's tools in the harnesses' shape (the registry keeps input_schema; a bound tool takes inputSchema),
|
|
@@ -1159,6 +1210,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1159
1210
|
let probes = 0;
|
|
1160
1211
|
const probe = async (why) => {
|
|
1161
1212
|
const mine = ++probes;
|
|
1213
|
+
// The Ollama listing the offers are made from is read before they are, so the first capabilities do not remake them.
|
|
1214
|
+
if (asksOllama(env))
|
|
1215
|
+
await ollamaModels(env);
|
|
1162
1216
|
const from = offersInputs(env);
|
|
1163
1217
|
const started = performance.now();
|
|
1164
1218
|
const next = await harnessOffers(offersEnvOf(env));
|
|
@@ -1180,6 +1234,8 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1180
1234
|
log: (what, error) => log?.(logLine(what, { error: error.message })),
|
|
1181
1235
|
...(options.listerIdleMs !== undefined ? { idleMs: options.listerIdleMs } : {}),
|
|
1182
1236
|
});
|
|
1237
|
+
/** Whether the offers held now were made from `inputs` (offersInputs). */
|
|
1238
|
+
const offersMadeFrom = (inputs) => offersFrom !== undefined && inputs.length === offersFrom.length && inputs.every((value, i) => value === offersFrom[i]);
|
|
1183
1239
|
const keysChanged = async () => {
|
|
1184
1240
|
// 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
|
|
1185
1241
|
// serverSecrets live, store-view), and a list builds a listing cut of other keys again (builtOfNow). A failed run's error words
|
|
@@ -1190,12 +1246,27 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1190
1246
|
const next = await needsOf(env);
|
|
1191
1247
|
if (mine === needsAsked)
|
|
1192
1248
|
needs = next;
|
|
1193
|
-
|
|
1194
|
-
if (offersFrom && inputs.length === offersFrom.length && inputs.every((value, i) => value === offersFrom[i]))
|
|
1249
|
+
if (offersMadeFrom(offersInputs(env)))
|
|
1195
1250
|
recompose();
|
|
1196
1251
|
else
|
|
1197
1252
|
await probe("key");
|
|
1198
1253
|
};
|
|
1254
|
+
/** The Ollama here, as capabilities read it: its listing asked again behind the answer once stale (ollamaModels), and
|
|
1255
|
+
* the reading made again, as a key's save does, once a listing differs from the one the offers were made from. So a
|
|
1256
|
+
* model pulled, or Ollama started after this server, shows in a later answer with no restart. */
|
|
1257
|
+
const ollamaNow = async () => {
|
|
1258
|
+
if (!asksOllama(env))
|
|
1259
|
+
return;
|
|
1260
|
+
void ollamaModels(env);
|
|
1261
|
+
if (offersFrom && !offersMadeFrom(offersInputs(env)))
|
|
1262
|
+
await keysChanged();
|
|
1263
|
+
};
|
|
1264
|
+
/** After a harness key is saved or removed (harness-keys.ts): the listings built again, cut of it, and the offers probed
|
|
1265
|
+
* again, as a recipe is offered once every key it runs on is saved here (harnessKeysSavedHere). No environment changes. */
|
|
1266
|
+
const harnessKeysChanged = async () => {
|
|
1267
|
+
await lister.keysChanged();
|
|
1268
|
+
await probe("harness-key");
|
|
1269
|
+
};
|
|
1199
1270
|
/** After the model gateway is saved or removed in the console: the saved gateway read again, then env, as a key's save. */
|
|
1200
1271
|
const gatewayChanged = async () => {
|
|
1201
1272
|
savedGateway = await readSavedGateway(store, seal.key);
|
|
@@ -1226,7 +1297,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1226
1297
|
// them, docker alone when it is not set; docker by its probe, daytona and modal by their providers' keys, read as a
|
|
1227
1298
|
// run's claim reads them. Under --faux, `fauxDocker` stands in for Docker's answer, and nothing asks Docker.
|
|
1228
1299
|
const fauxDocker = Boolean(options.faux) && options.fauxDocker === true;
|
|
1229
|
-
|
|
1300
|
+
// 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;
|
|
1301
|
+
// `probeContainer` sets it for a test of a real one.
|
|
1302
|
+
const found = await placeOffers(env, { keyOf: keyReader(store, seal.key, env), fauxDocker, ...(options.probeContainer ? { container: options.probeContainer } : options.faux ? { container: { inside: false } } : {}) });
|
|
1230
1303
|
const docker = found.some((offer) => offer.id === "docker" && offer.available);
|
|
1231
1304
|
// Under --faux, the mountinfo a test gives (fauxMountinfo, or FAUX_MOUNTINFO_ENV in the process's own environment, which
|
|
1232
1305
|
// `env` leaves out: a server under test in a container names its own /proc/self/mountinfo there); with none, a faux
|
|
@@ -1247,13 +1320,35 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1247
1320
|
// From a container, a Docker computer keeps this server's allow-list only knowing the Docker host's own addresses: the
|
|
1248
1321
|
// union of the read through the socket and AGENTRUN_DOCKER_HOST_ADDRESSES (docker-host-addresses.ts), the same read the
|
|
1249
1322
|
// runner beside this server takes. Said at the start with what was found; with none, Docker isn't offered, in words.
|
|
1323
|
+
// A read that failed with none known is read again in the background (retryHostAddresses) until one answers and the
|
|
1324
|
+
// helper containers the failed reads left are gone, or this server stops: the boxes are made again from the answer and
|
|
1325
|
+
// said again, so Docker is offered with no restart. Every reader of boxOffers reads it when it is called; capabilities
|
|
1326
|
+
// are composed again.
|
|
1327
|
+
const boxesOf = (hostAddresses) => {
|
|
1328
|
+
if (hostAddresses)
|
|
1329
|
+
log?.(logLine("docker_host_addresses", { addresses: hostAddresses.addresses.join(",") || "none", ...(hostAddresses.why ? { read: hostAddresses.why } : {}) }));
|
|
1330
|
+
const dockerRefused = dockerElsewhere ?? (hostAddresses && hostAddresses.addresses.length === 0 ? noHostAddresses(hostAddresses.why ?? "the read through Docker's socket found none") : undefined);
|
|
1331
|
+
// Each box with what it reaches (place-offers.ts withNetworks).
|
|
1332
|
+
const offers = withNetworks(found, boxAllow, { ...(dockerRefused !== undefined ? { refused: dockerRefused } : {}), ...(hostAddresses ? { hostAddresses: hostAddresses.addresses } : {}), faux: fauxDocker });
|
|
1333
|
+
log?.(logLine("boxes", boxesLog(offers, enabledBoxes(env))));
|
|
1334
|
+
return offers;
|
|
1335
|
+
};
|
|
1250
1336
|
const hostAddresses = dockerElsewhere === undefined && "paths" in dockerPaths && boxAllow !== "none" ? unionOf(await hostAddressesOnce(env), dockerHostAddressesOf(env)) : undefined;
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1337
|
+
let boxOffers = boxesOf(hostAddresses);
|
|
1338
|
+
if (hostAddresses?.why !== undefined && hostAddresses.addresses.length === 0) {
|
|
1339
|
+
void retryHostAddresses({
|
|
1340
|
+
env,
|
|
1341
|
+
read: () => hostAddressesOnce(env),
|
|
1342
|
+
found: (read) => {
|
|
1343
|
+
boxOffers = boxesOf(unionOf(read, dockerHostAddressesOf(env)));
|
|
1344
|
+
// Capabilities are first composed at the start's probe, below; before it, there is nothing to compose again.
|
|
1345
|
+
if (caps)
|
|
1346
|
+
recompose();
|
|
1347
|
+
},
|
|
1348
|
+
signal: stopping.signal,
|
|
1349
|
+
...(options.hostReadWait ? { wait: options.hostReadWait } : {}),
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1257
1352
|
const adapters = options.triggerAdapters ?? TRIGGER_ADAPTERS;
|
|
1258
1353
|
const openapi = openapiDocument((operationId) => ROUTES.find((r) => r.name === operationId)?.capability, adapters);
|
|
1259
1354
|
const sealKey = seal.key;
|
|
@@ -1393,10 +1488,8 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1393
1488
|
* list reads it, so a tool of bash's family the run would not have shows unavailable (tool-plane.ts shellUnavailable). */
|
|
1394
1489
|
const shellOfRevision = async (revision) => {
|
|
1395
1490
|
const body = revision.body;
|
|
1396
|
-
return shellOf(body
|
|
1491
|
+
return shellOf(settingOfDefinition(body)?.computer ?? computerOfPlace(fallbackPlace(revision.kind, revision.kind === "agentic" ? (body.tools ?? []) : [])));
|
|
1397
1492
|
};
|
|
1398
|
-
/** A run's computer on its read: its revision's computer setting, else the one its place says; absent for none. */
|
|
1399
|
-
const runComputerOf = (runId, view) => runComputerRead(store, runId, view, { context: ctx });
|
|
1400
1493
|
/** The run read's costs (A8, store-reads/learning.ts runAllInOverStore): `cost.usd` its own spend, the
|
|
1401
1494
|
* job's (its compile turn is learning's), null while unknown; what learning spent for it
|
|
1402
1495
|
* (`learning_usd`) and the two (`all_in_usd`). A cost known only as a bound keeps its bound, and all-in is unknown.
|
|
@@ -1404,12 +1497,26 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1404
1497
|
const allInViewOf = async (runId, view) => {
|
|
1405
1498
|
const cost = (view.cost ?? {});
|
|
1406
1499
|
const own = typeof cost.usd === "number" && cost.upper_bound !== true ? cost.usd : null;
|
|
1407
|
-
|
|
1500
|
+
// A purge gate that can't be asked (its store read of a writer's row fails) leaves this read without its answer, never
|
|
1501
|
+
// a 500: the revision ledger its `learning_usd` and `all_in_usd` share is read from takes the champion with no record
|
|
1502
|
+
// skipped (as before the purge), so a revision a purged run wrote may be the one it counts as serving, for this read
|
|
1503
|
+
// alone. Figures only: no text is read or shown. Every write that asks the gate still fails closed (decideCheck
|
|
1504
|
+
// throws, so no promote lands; recordPromotion trims nothing). Such a read says so: `cost.degraded`.
|
|
1505
|
+
let degraded = false;
|
|
1506
|
+
const all = await runAllInOverStore(store, runId, own, (agentId, records) => refusedFor(agentId, records).catch((error) => {
|
|
1507
|
+
degraded = true;
|
|
1508
|
+
const line = `learning: run ${runId}: its costs were read without the purge gate's answer: ${error instanceof Error ? error.message : String(error)}`;
|
|
1509
|
+
if (log)
|
|
1510
|
+
log(logLine("learning", { line }));
|
|
1511
|
+
else
|
|
1512
|
+
process.stderr.write(`agentrun-serve: ${line}\n`);
|
|
1513
|
+
return Object.assign(() => false, { unread: true });
|
|
1514
|
+
}));
|
|
1408
1515
|
if (!all)
|
|
1409
1516
|
return {};
|
|
1410
1517
|
// A bound stays the view's bound. Otherwise usd is the job's (runCostOf's cost_usd, the same figure the cost series
|
|
1411
1518
|
// gives): known as it answered even when its compile turn's cost is not; the row's while the run is at work.
|
|
1412
|
-
return { cost: { ...cost, ...(cost.upper_bound === true ? {} : { usd: all.usd }), tools_usd: await toolsUsdOverStore(store, runId), learning_usd: all.learning_usd, all_in_usd: all.all_in_usd } };
|
|
1519
|
+
return { cost: { ...cost, ...(cost.upper_bound === true ? {} : { usd: all.usd }), tools_usd: await toolsUsdOverStore(store, runId), learning_usd: all.learning_usd, all_in_usd: all.all_in_usd, ...(degraded ? { degraded: true } : {}) } };
|
|
1413
1520
|
};
|
|
1414
1521
|
// The agents accessor the routes call, over the one store (module A): the agents-store functions, with the run-row reads
|
|
1415
1522
|
// the server makes (store-reads) under `.store`. `.request` is a thin pass-through — the store runs its own transactions,
|
|
@@ -1438,6 +1545,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1438
1545
|
secretStores.add("server", () => tokens.map((entry) => entry.token));
|
|
1439
1546
|
// The model gateway's key saved in the console (model-gateway.ts): cut from everything shown, as every saved key is.
|
|
1440
1547
|
secretStores.add("model-gateway", () => (savedGateway?.key ? [savedGateway.key] : []));
|
|
1548
|
+
// Each harness key saved, and each replaced or removed one still kept sealed (harness-keys.ts RETIRED_KEPT): a timeline
|
|
1549
|
+
// written while one was live stays cut after it changes.
|
|
1550
|
+
secretStores.add("harness-keys", () => harnessKeys.values());
|
|
1441
1551
|
// The email account's password (email/account.ts), and each one saved since this server started: cut from everything
|
|
1442
1552
|
// it shows, so a tool's error or a model's text that ever echoed it shows it nowhere.
|
|
1443
1553
|
const emailPasswords = new Set();
|
|
@@ -1732,12 +1842,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1732
1842
|
return [...serverSecrets(), ...pointers];
|
|
1733
1843
|
};
|
|
1734
1844
|
const learningShown = async (agentId) => secretsShown(await learningValues(agentId));
|
|
1735
|
-
//
|
|
1736
|
-
//
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
return new Set(runIds.filter((_, i) => rows[i] !== undefined && rows[i].purgedAt !== null));
|
|
1740
|
-
};
|
|
1845
|
+
// What championOf skips of the agent's promotion records (purged-workflow.ts refusedIn): a champion the purge gate
|
|
1846
|
+
// refuses at its commit, so the views name the champion a run's claim serves. A folder whose end() throws after the ask
|
|
1847
|
+
// is logged, never the read's 500.
|
|
1848
|
+
const refusedFor = (agentId, records) => refusedIn(() => learningFolderOf(data, agentId), store, (line) => (log ? log(logLine("learning", { line })) : void process.stderr.write(`agentrun-serve: ${line}\n`)))(records);
|
|
1741
1849
|
// The agent's audit ledger on its learning folder's main (learn/audit.ts), oldest first.
|
|
1742
1850
|
const auditsOfAgent = async (agentId) => {
|
|
1743
1851
|
const { workspace, end } = learningFolderOf(data, agentId);
|
|
@@ -1755,6 +1863,11 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1755
1863
|
// (run-recordings.ts), where the runner beside it wrote them; every other read of the view opens no file.
|
|
1756
1864
|
const recordings = (agentId, runId, endedAt) => recordingsOf(recordingsFolder(data, agentId, runId), endedAt);
|
|
1757
1865
|
const runReadDepsFor = (origin) => ({ ...viewDepsFor(origin), recordings });
|
|
1866
|
+
/** A run as GET /v2/runs/{run_id} answers it, its links at `origin`. */
|
|
1867
|
+
const runRead = async (runId, origin) => {
|
|
1868
|
+
const view = await viewOverStore(store, runId, runReadDepsFor(origin));
|
|
1869
|
+
return view && { ...view, ...(await runComputerRead(store, runId, view, { context: ctx })), ...(await allInViewOf(runId, view)) };
|
|
1870
|
+
};
|
|
1758
1871
|
const ownOriginOf = () => options.publicUrl ?? url;
|
|
1759
1872
|
// The run read routes (a run's files, its browser state, its workflow graph) over the one store (run-reads-over-store):
|
|
1760
1873
|
// a run's files through the server's read-only Workspace of its folder (serverRunWorkspace, no runner claim), its view
|
|
@@ -1794,8 +1907,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
1794
1907
|
getAgent: async (agentId) => (await getAgent(store, agentId)) ?? undefined,
|
|
1795
1908
|
needAgent,
|
|
1796
1909
|
momentOf: (runId) => momentOverStore(store, runId, viewDepsFor(ownOriginOf())),
|
|
1797
|
-
// A trigger never messages a run on a plan-billed recipe: its turn would run on its
|
|
1798
|
-
|
|
1910
|
+
// A trigger never messages a run on a plan-billed recipe whose keys are not all saved: its turn would run on its
|
|
1911
|
+
// owner's own sign-in. With them saved, the turn runs on them (harness-keys.ts), and a claim that opens not every one
|
|
1912
|
+
// is refused (cli-run-spec.ts).
|
|
1913
|
+
planRecipe: (harness) => recipeHarness(base, harness) === "plan" && !harnessKeysSavedHere(data, harness),
|
|
1799
1914
|
// Read when a firing's message is sent (declared below, with the delete turn).
|
|
1800
1915
|
runWrite: (agentId, runId, work) => runWrite(agentId, runId, work),
|
|
1801
1916
|
runStatus: async (runId) => (await viewOverStore(store, runId, viewDepsFor(ownOriginOf())))?.status ?? null,
|
|
@@ -2640,7 +2755,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
2640
2755
|
// purged or kept as the purge had got, and the next DELETE does it again.
|
|
2641
2756
|
forgetCopies: async (agentId, runId) => {
|
|
2642
2757
|
await forgetRunCopies(store.settings, agentId, runId);
|
|
2643
|
-
await notYetWith(() => forgetRunLearning(data, agentId, runId), ["unavailable"], "The agent's learning folder keeps the run's text until the DELETE is sent again.");
|
|
2758
|
+
await notYetWith(() => forgetRunLearning(data, agentId, runId, store), ["unavailable"], "The agent's learning folder keeps the run's text until the DELETE is sent again.");
|
|
2644
2759
|
},
|
|
2645
2760
|
// /usage's meters and a live read's spend, from its journal, as they read now (store-reads/cap.ts), and how its
|
|
2646
2761
|
// learning ended as /stats counts it (its state and reason alone).
|
|
@@ -2825,6 +2940,18 @@ async function startHolding(options, data, checked, stops) {
|
|
|
2825
2940
|
});
|
|
2826
2941
|
if (unpinned.length)
|
|
2827
2942
|
throw new ApiError("agent_not_runnable", unpinned.map((one) => one.message).join(" "), { fields: unpinned.map(({ tool: _tool, ...issue }) => issue), details: { unbound: unpinned.map((one) => one.tool), missing: {} } });
|
|
2943
|
+
// A granted tool of a Composio server that reads its key from the environment (api_key_env) while that variable is
|
|
2944
|
+
// unset, or whose address is off Composio's origin: refused by its name before the run starts, never launched
|
|
2945
|
+
// without the server's tools, and nothing sent (composioEnvKey).
|
|
2946
|
+
const unset = (revision.body.tools ?? []).flatMap((tool, index) => {
|
|
2947
|
+
const named = mcpToolOf(tool);
|
|
2948
|
+
const saved = named ? mcpMeta.get(named.server) : undefined;
|
|
2949
|
+
const keyEnv = saved?.keyEnv;
|
|
2950
|
+
const got = named && saved && keyEnv ? composioEnvKey(named.server, saved.url, keyEnv, mcpServers.composioOrigin) : undefined;
|
|
2951
|
+
return got && "refused" in got ? [{ field: `definition.tools[${index}]`, reason: got.reason, message: got.refused, tool, keyEnv: keyEnv, unset: got.reason === "missing" }] : [];
|
|
2952
|
+
});
|
|
2953
|
+
if (unset.length)
|
|
2954
|
+
throw new ApiError("agent_not_runnable", [...new Set(unset.map((one) => one.message))].join(" "), { fields: unset.map(({ tool: _tool, keyEnv: _keyEnv, unset: _unset, ...issue }) => issue), details: { unbound: [], missing: Object.fromEntries(unset.filter((one) => one.unset).map((one) => [one.tool, [one.keyEnv]])) } });
|
|
2828
2955
|
}
|
|
2829
2956
|
const pinnedTools = (server) => {
|
|
2830
2957
|
const saved = mcpMeta.get(server);
|
|
@@ -3133,11 +3260,15 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3133
3260
|
return false;
|
|
3134
3261
|
throw error;
|
|
3135
3262
|
};
|
|
3263
|
+
/** A fresh apply's twins: the live agents here made from the package `pkgId` with the parameters `digest` digests. The
|
|
3264
|
+
* apply still makes another and warns of each (applyWith); its plan names them first (planTemplate). None for an
|
|
3265
|
+
* apply onto an agent (`onto`). */
|
|
3266
|
+
const twinsOf = async (onto, pkgId, digest) => onto ? [] : (await agents.list()).filter((one) => one.template?.id === pkgId && one.template.parameters_digest === digest).map((one) => one.agent.id);
|
|
3136
3267
|
/** POST /templates/{id}/apply {dry_run: true}: the apply's plan, from the same reads and checks as the apply
|
|
3137
3268
|
* (prepareApply), with nothing written: whether it makes an agent or revises the one agent_id names (and its current
|
|
3138
|
-
* revision), the keys and MCP servers this server lacks (where the apply
|
|
3139
|
-
* what becomes of each trigger (made, changed in place, removed, or
|
|
3140
|
-
* the computer it picks. Any other refusal is the apply's own. */
|
|
3269
|
+
* revision), the agents a fresh one would make a twin of, the keys and MCP servers this server lacks (where the apply
|
|
3270
|
+
* would refuse with 409, the plan lists them), what becomes of each trigger (made, changed in place, removed, or
|
|
3271
|
+
* skipped for a connection this server lacks), and the computer it picks. Any other refusal is the apply's own. */
|
|
3141
3272
|
async function planTemplate(template, body) {
|
|
3142
3273
|
const p = await prepareApply(template, body, { plan: true });
|
|
3143
3274
|
// A monid grant is pinned to monid's listing when the agent is saved (saveable: monidPinOf), read with the monid key:
|
|
@@ -3148,6 +3279,8 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3148
3279
|
const was = p.onto?.revision?.kind === "agentic" ? p.onto.revision : undefined;
|
|
3149
3280
|
const unread = !env[MONID_KEY_ENV]?.trim() && (await pinMonid(tools, { key: undefined, ...(was ? { previous: { grants: was.body.tools ?? [], pin: was.monidPin ?? null } } : {}) }));
|
|
3150
3281
|
const missing = unread && "refused" in unread && !p.missing.includes(MONID_KEY_ENV) ? [...p.missing, MONID_KEY_ENV] : p.missing;
|
|
3282
|
+
// A skip's `code` is the apply's warning's for it: not_set_up_here for one this server makes once it is set up (a
|
|
3283
|
+
// connection, a feed's URLs, a launch hook), not_an_option for one it never makes.
|
|
3151
3284
|
const planned = [];
|
|
3152
3285
|
for (const [i, trigger] of p.made.triggers.entries()) {
|
|
3153
3286
|
const name = String(trigger.name).trim();
|
|
@@ -3155,11 +3288,11 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3155
3288
|
// On an API-only server, skipped in the apply's own words (prepareApply).
|
|
3156
3289
|
const hostSkip = p.hostless.get(i);
|
|
3157
3290
|
if (hostSkip) {
|
|
3158
|
-
planned.push({ name, kind, action: "skip", reason: hostSkip.message });
|
|
3291
|
+
planned.push({ name, kind, action: "skip", code: hostSkip.reason, reason: hostSkip.message });
|
|
3159
3292
|
continue;
|
|
3160
3293
|
}
|
|
3161
3294
|
if (p.emptyFeeds.has(i)) {
|
|
3162
|
-
planned.push({ name, kind, action: "skip", reason: feedTriggerEmpty(p.pkg.name, trigger, isObject(p.pkg.triggers[i]?.source) ? p.pkg.triggers[i].source.urls : undefined) });
|
|
3295
|
+
planned.push({ name, kind, action: "skip", code: NOT_SET_UP, reason: feedTriggerEmpty(p.pkg.name, trigger, isObject(p.pkg.triggers[i]?.source) ? p.pkg.triggers[i].source.urls : undefined) });
|
|
3163
3296
|
continue;
|
|
3164
3297
|
}
|
|
3165
3298
|
const was = p.hadByName.get(name);
|
|
@@ -3172,7 +3305,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3172
3305
|
// (any trigger, on or off), read here; its account and subscription are Composio's to answer, which a plan never asks.
|
|
3173
3306
|
const refusal = kind === "composio" && !options.publicUrl ? composioNoPublicUrl() : trigger.enabled !== false && !(was && !was.enabled) ? await triggerUnavailable(kind) : undefined;
|
|
3174
3307
|
if (refusal && notSetUpYet(kind, refusal.code))
|
|
3175
|
-
planned.push({ name, kind, action: "skip", reason: refusal.message });
|
|
3308
|
+
planned.push({ name, kind, action: "skip", code: NOT_SET_UP, reason: refusal.message });
|
|
3176
3309
|
else if (refusal)
|
|
3177
3310
|
throw refusal;
|
|
3178
3311
|
else
|
|
@@ -3186,6 +3319,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3186
3319
|
action: p.onto ? "revise" : "create",
|
|
3187
3320
|
agent_id: p.onto?.agent.id ?? null,
|
|
3188
3321
|
current_revision_id: p.onto?.revision?.id ?? null,
|
|
3322
|
+
twins: await twinsOf(p.onto, p.pkg.id, p.digest),
|
|
3189
3323
|
missing_secrets: missing,
|
|
3190
3324
|
unmatched_mcp: p.unsaved.map((need) => ({ source: need.source, toolkit: need.toolkit, required: need.required })),
|
|
3191
3325
|
triggers: planned,
|
|
@@ -3287,11 +3421,16 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3287
3421
|
// A trigger is made only when its firings have somewhere to go: on an API-only server, a schedule or a feed with the
|
|
3288
3422
|
// launch hook set (api-only.ts); under the run-keys setting, for an agent whose runs owe keys, only with the launch
|
|
3289
3423
|
// hook, the one way a firing's run carries them (run-keys.ts). Each other is said, and stays listed, so a trigger the
|
|
3290
|
-
// agent has by its name is left as it is, never removed.
|
|
3424
|
+
// agent has by its name is left as it is, never removed. One left on still fires, so its skip says so and how to stop it.
|
|
3291
3425
|
const hooked = options.launchHook !== undefined;
|
|
3292
3426
|
const hostless = new Map(made.triggers.flatMap((trigger, i) => {
|
|
3293
3427
|
const skip = (options.apiOnly ? apiOnlyTriggerSkipped(pkg.name, trigger, hooked) : undefined) ?? runKeysTriggerSkipped(pkg.name, trigger, brought, hooked);
|
|
3294
|
-
|
|
3428
|
+
if (!skip)
|
|
3429
|
+
return [];
|
|
3430
|
+
const keptOn = had.find((row) => row.enabled && row.name === String(trigger.name).trim());
|
|
3431
|
+
// An API-only server serves no trigger route: its archive is what turns the agent's triggers off.
|
|
3432
|
+
const off = options.apiOnly ? "archiving the agent turns it off" : `PATCH /v2/triggers/${keptOn?.id} with {"enabled": false} turns it off`;
|
|
3433
|
+
return [[i, keptOn ? { ...skip, message: `${skip.message} The agent's trigger ${keptOn.id} of that name is kept as it was, and still fires: ${off}.` } : skip]];
|
|
3295
3434
|
}));
|
|
3296
3435
|
const unmade = (i) => emptyFeeds.has(i) || hostless.has(i);
|
|
3297
3436
|
const refusedTriggers = madeTriggerIssues(made.triggers, options.triggerClock?.now() ?? Date.now(), pkg.inputSchema).filter((issue) => !unmade(Number(/^triggers\.(\d+)\./.exec(issue.field)?.[1])));
|
|
@@ -3366,9 +3505,8 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3366
3505
|
const { pkg, onto, saved, mapped, grants, made, emptyFeeds, hostless, unmade, hadByName, remade, resent, removing, digest, origin, warned } = await prepareApply(template, body, { plan: false });
|
|
3367
3506
|
// A fresh apply of what already made a live agent here (the same package and parameters) still makes one, and says
|
|
3368
3507
|
// which is there: an apply with its agent_id updates that one instead. Read before this apply's agent is made.
|
|
3369
|
-
const twins =
|
|
3370
|
-
.
|
|
3371
|
-
.map((one) => ({ field: "agent_id", reason: "duplicate", message: `The agent ${one.agent.id} was made from the ${pkg.name} template with these parameters, and this apply made another. To change that one instead, apply with agent_id ${one.agent.id}.` }));
|
|
3508
|
+
const twins = (await twinsOf(onto, pkg.id, digest))
|
|
3509
|
+
.map((id) => ({ field: "agent_id", reason: "duplicate", message: `The agent ${id} was made from the ${pkg.name} template with these parameters, and this apply made another. To change that one instead, apply with agent_id ${id}.` }));
|
|
3372
3510
|
// An update writes the package as a new revision of the agent, as an edit does (its id, name and description are the
|
|
3373
3511
|
// agent's own: the package's never replace them), but what the package owns and leaves out is gone (fromPackage); only onto the
|
|
3374
3512
|
// revision it read, else 412 with nothing changed. A fresh apply makes the agent as POST /agents does.
|
|
@@ -3657,7 +3795,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3657
3795
|
if (undeclared.length)
|
|
3658
3796
|
throw invalid(undeclared);
|
|
3659
3797
|
}
|
|
3660
|
-
const owed = options.runKeys && revision ?
|
|
3798
|
+
const owed = options.runKeys && revision ? keysOwed(revision, env, []) : [];
|
|
3661
3799
|
const needsKey = handed.model === undefined && serverKeyMissing(env, target);
|
|
3662
3800
|
if (handed.mcp === undefined && handed.model === undefined && handed.keys === undefined && !needsKey && !owed.length)
|
|
3663
3801
|
return undefined;
|
|
@@ -3669,9 +3807,9 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3669
3807
|
const keys = handed.keys ?? held.keys;
|
|
3670
3808
|
if (!model && needsKey)
|
|
3671
3809
|
throw modelKeyRequired(true);
|
|
3672
|
-
const unpaid = revision ? keysOwed(revision, env, Object.keys(keys ?? {})) : [];
|
|
3673
|
-
if (
|
|
3674
|
-
throw
|
|
3810
|
+
const unpaid = owed.length && revision ? keysOwed(revision, env, Object.keys(keys ?? {})) : [];
|
|
3811
|
+
if (unpaid.length)
|
|
3812
|
+
throw keysOwedRefusal(unpaid);
|
|
3675
3813
|
return sealRunLaunch(sealKey, run.id, { ...(mcp ? { mcp } : {}), ...(model ? { model } : {}), ...(keys ? { keys } : {}) });
|
|
3676
3814
|
};
|
|
3677
3815
|
}
|
|
@@ -3679,21 +3817,24 @@ async function startHolding(options, data, checked, stops) {
|
|
|
3679
3817
|
const entry = await needRunnableAgent(agentId);
|
|
3680
3818
|
const { body, handed } = handedLaunchSecrets(await bodyOf(req));
|
|
3681
3819
|
// The host's run for a firing the launch hook handed it: the firing's own run, under the firing's key (a second start
|
|
3682
|
-
// answers that run),
|
|
3683
|
-
//
|
|
3820
|
+
// answers that run), started by the trigger's target policy as a firing here starts one (its cap, which the host's may
|
|
3821
|
+
// lower, its effort when it sets one, its previous result, its trigger, origin and title), with the host's body and
|
|
3822
|
+
// launch secrets over it. The firing is its key, so it takes no Idempotency-Key, whose check across a restart is the run's origin.
|
|
3684
3823
|
if (body.trigger_firing !== undefined) {
|
|
3685
3824
|
if (req.headers["idempotency-key"] !== undefined)
|
|
3686
3825
|
throw invalid([{ field: "trigger_firing", reason: "not_allowed", message: "A run for a trigger firing is keyed by the firing, and a second start answers its run: send it without Idempotency-Key." }]);
|
|
3826
|
+
// It starts on its trigger's target as a firing here would: on the agent's current revision, holding no computer.
|
|
3827
|
+
const fixed = HANDED_FIXED.filter((field) => body[field] !== undefined);
|
|
3828
|
+
if (fixed.length)
|
|
3829
|
+
throw invalid(fixed.map((field) => ({ field, reason: "not_allowed", message: `A run for a trigger firing starts on its trigger's target, on the agent's current revision and holding no computer: send it without ${field}.` })));
|
|
3687
3830
|
const { trigger_firing: given, ...rest } = body;
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
await triggers.handedRan(firing.trigger.id, firing.key, run.id);
|
|
3696
|
-
return { status: 202, body: await viewOverStore(store, run.id, viewDepsFor(linkOrigin(req))), headers: { location: `/v2/runs/${run.id}` } };
|
|
3831
|
+
// The firing's room is checked and held as drive's is while its run is written; the firing is started with the run.
|
|
3832
|
+
const run = await triggers.handedStart(given, agentId, async (firing) => {
|
|
3833
|
+
const secrets = await handed();
|
|
3834
|
+
const seal = startSeal(secrets);
|
|
3835
|
+
return targets.start(firing.target, rest.input, firing.trigger, firing.from, firing.title, firing.previous, { body: rest, ...(seal ? { sealed: seal } : {}), ...carriedOf(secrets) });
|
|
3836
|
+
});
|
|
3837
|
+
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" } : {}) } };
|
|
3697
3838
|
}
|
|
3698
3839
|
return idempotent(req, `/agents/${agentId}/runs`, body, async (origin) => {
|
|
3699
3840
|
// A run the store started under this key, though no answer was kept (its server went down first): that run, as it is now.
|
|
@@ -4265,16 +4406,19 @@ async function startHolding(options, data, checked, stops) {
|
|
|
4265
4406
|
return send(res, 200, { signed_in: true }, { "set-cookie": ownerCookie(req, me.session(), SESSION_S) });
|
|
4266
4407
|
}
|
|
4267
4408
|
// This browser: its session revoked on the server (a copy of its cookie is no session either) and its cookie
|
|
4268
|
-
// cleared; every other browser's session left as it is. A viewer watching with it is cut off.
|
|
4409
|
+
// cleared; every other browser's session left as it is. A viewer watching with it is cut off. Its sessions at this
|
|
4410
|
+
// server's other ports go too (page.ts sessionsAtEveryPort: a browser sends a host's cookies to every port), each
|
|
4411
|
+
// name cleared; a cookie this server did not make (another server's on the same host) is left as it is.
|
|
4269
4412
|
case "/auth/sign-out": {
|
|
4270
4413
|
fromPage(req);
|
|
4271
4414
|
if (!signedIn(req, me))
|
|
4272
4415
|
throw new ApiError("unauthenticated", "this browser is not signed in");
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4416
|
+
const ended = sessionsAtEveryPort(req).filter(({ value }) => me.valid(value));
|
|
4417
|
+
for (const { value } of ended)
|
|
4418
|
+
me.revoke(value);
|
|
4276
4419
|
viewers.recheck();
|
|
4277
|
-
|
|
4420
|
+
const names = new Set([ownerCookieName(req), ...ended.map(({ name }) => name)]);
|
|
4421
|
+
return send(res, 200, { signed_out: true }, { "set-cookie": [...names].map((name) => ownerCookie(req, "", 0, name)) });
|
|
4278
4422
|
}
|
|
4279
4423
|
// Every browser and phone: the sessions' epoch moves on, so every cookie made before is none, this one's too.
|
|
4280
4424
|
case "/auth/sign-out-everywhere": {
|
|
@@ -4368,6 +4512,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
4368
4512
|
// in Mode 2): where there is one, the document is made again with it (cheap), its tools available with no box.
|
|
4369
4513
|
const runnerShell = shellTools(await shellOf({ kind: "none" }));
|
|
4370
4514
|
await planNow();
|
|
4515
|
+
await ollamaNow();
|
|
4371
4516
|
const answer = forCaller(runnerShell.size ? compose(runnerShell) : caps, byOwnerSession(req));
|
|
4372
4517
|
// features.triggers.public_url: whether Composio (or any sender) has a public address to reach, never the address.
|
|
4373
4518
|
// runner_refused: why no runner here can take a run, in their words, while every runner there refused to claim
|
|
@@ -4377,7 +4522,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
4377
4522
|
// skew check; left out when the store cannot say (a read that failed).
|
|
4378
4523
|
const state = await store.schemaState?.().catch(() => undefined);
|
|
4379
4524
|
const storeSchema = state ? { store_schema: { version: state.version, runner_floor: state.runnerFloor, known: state.known } } : {};
|
|
4380
|
-
return send(res, 200, { ...answer, ...storeSchema, runner_refused: runnerRefused, features: { ...answer.features, computers: await computerCapabilities(computersOf()), triggers: { ...answer.features.triggers, public_url: Boolean(options.publicUrl) } } });
|
|
4525
|
+
return send(res, 200, { ...answer, ...storeSchema, runner_refused: runnerRefused, features: { ...answer.features, computers: await computerCapabilities(computersOf()), triggers: { ...answer.features.triggers, public_url: Boolean(options.publicUrl) }, claude_login: !loginOff && !options.apiOnly } });
|
|
4381
4526
|
}
|
|
4382
4527
|
if (found.name === "getOpenapi")
|
|
4383
4528
|
return send(res, 200, servedOpenapi(openapi, req.socket.localPort));
|
|
@@ -4502,8 +4647,13 @@ async function startHolding(options, data, checked, stops) {
|
|
|
4502
4647
|
// non-secret edit on the same route still goes through. A body that does not read counts as the plane says of none.
|
|
4503
4648
|
// What a stored predicate read to let the request through (SecretRequest.seen): the operation's write is refused if
|
|
4504
4649
|
// that changed before it lands, so a write allowed against one stored credential never lands over another.
|
|
4650
|
+
// `byToken`: the gate read this request as the API token's, so an MCP server it saves is recorded as the token's, and
|
|
4651
|
+
// it saves over or removes only one the token saved (mcp-secret-writes.ts tokenWriteOverRefused), compared again in
|
|
4652
|
+
// the statement that writes or removes the row (mcp-servers-store.ts save, remove).
|
|
4505
4653
|
let secretSeen;
|
|
4654
|
+
let byToken = false;
|
|
4506
4655
|
if (isSecretWriteOperation(found.name) && req.headers.authorization !== undefined && !writesSecretsAllowed(req, { accounts: owner !== undefined, loopbackBound: isLoopback(host) })) {
|
|
4656
|
+
byToken = true;
|
|
4507
4657
|
const body = req.method === "DELETE" || req.method === "GET" ? undefined : await bodyOf(req).catch(() => undefined);
|
|
4508
4658
|
// A segment that is not valid percent-encoding is taken as it came: the request goes on to the token's own check.
|
|
4509
4659
|
const params = (found.pattern.exec(path) ?? []).slice(1).map((part) => {
|
|
@@ -4514,7 +4664,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
4514
4664
|
return part;
|
|
4515
4665
|
}
|
|
4516
4666
|
});
|
|
4517
|
-
const checked = { params, store };
|
|
4667
|
+
const checked = { params, store, apiOnly: options.apiOnly === true };
|
|
4518
4668
|
if (await writesSecretFor(found.name, body, checked)) {
|
|
4519
4669
|
authFailed(`/v2${path}`, "secret_without_session");
|
|
4520
4670
|
// Where the person finishes it: the operation's console page, filled with what the request held that is no
|
|
@@ -5056,10 +5206,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5056
5206
|
return send(res, 200, await runsPage(url, { ...(agent ? { agent } : {}), ...(revision ? { revision } : {}) }, linkOrigin(req)));
|
|
5057
5207
|
}
|
|
5058
5208
|
case "getRun": {
|
|
5059
|
-
const
|
|
5060
|
-
if (!
|
|
5209
|
+
const run = await runRead(id, linkOrigin(req));
|
|
5210
|
+
if (!run)
|
|
5061
5211
|
throw new ApiError("not_found", `no run ${id}`);
|
|
5062
|
-
return send(res, 200,
|
|
5212
|
+
return send(res, 200, run);
|
|
5063
5213
|
}
|
|
5064
5214
|
case "getTimeline":
|
|
5065
5215
|
await needRun(id);
|
|
@@ -5118,13 +5268,8 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5118
5268
|
const row = ID.test(id) ? await store.runs.get(id) : undefined;
|
|
5119
5269
|
if (!row)
|
|
5120
5270
|
throw new ApiError("not_found", `no run ${id}`);
|
|
5121
|
-
// API-only (api-only.ts)
|
|
5122
|
-
//
|
|
5123
|
-
if (options.apiOnly) {
|
|
5124
|
-
const agent = await store.agents.get(row.agentId);
|
|
5125
|
-
if (!agent || !ownedElsewhere(agent))
|
|
5126
|
-
throw new ApiError("not_found", apiOnlyRefusal(`/v2${path}`));
|
|
5127
|
-
}
|
|
5271
|
+
// API-only (api-only.ts) purges a run wherever its token may delete the run's whole agent, which is any agent:
|
|
5272
|
+
// another system's, and one made here once archived. One run is less than all of them, so it is served alike.
|
|
5128
5273
|
await deleteInTurn(row.agentId, () => purgeRun(agentDeleteHost, id));
|
|
5129
5274
|
res.writeHead(204, { "cache-control": "no-store", "x-content-type-options": "nosniff" });
|
|
5130
5275
|
return void res.end();
|
|
@@ -5319,6 +5464,10 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5319
5464
|
case "deleteComputer":
|
|
5320
5465
|
await attach.remove(id);
|
|
5321
5466
|
return void res.writeHead(204, { "cache-control": "no-store" }).end();
|
|
5467
|
+
case "listRunningComputers": {
|
|
5468
|
+
const origin = linkOrigin(req);
|
|
5469
|
+
return send(res, 200, await runningComputers(store, (runId) => runRead(runId, origin)), { "cache-control": "no-store" });
|
|
5470
|
+
}
|
|
5322
5471
|
case "listComputers":
|
|
5323
5472
|
case "saveComputerKeys":
|
|
5324
5473
|
case "testComputer":
|
|
@@ -5533,6 +5682,25 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5533
5682
|
await toolKeys.remove(id);
|
|
5534
5683
|
await keysChanged();
|
|
5535
5684
|
return void res.writeHead(204, { "cache-control": "no-store" }).end();
|
|
5685
|
+
case "listHarnessKeys":
|
|
5686
|
+
return send(res, 200, harnessKeys.list());
|
|
5687
|
+
// Never through `idempotent`: its record keeps the body, and this body is the value. The owner's session alone (the
|
|
5688
|
+
// dispatch's secret-write check, harness-keys.ts registerSecretWrite), for a recipe this server names and a key it
|
|
5689
|
+
// runs on; the next claim of a run on that harness opens it, with no restart. Then the listings are built again, cut
|
|
5690
|
+
// of it, and the harness offers probed again: whether the recipe is offered turns on its keys being saved.
|
|
5691
|
+
case "saveHarnessKey": {
|
|
5692
|
+
const recipe = harnessKeys.recipe(id);
|
|
5693
|
+
const body = await bodyOf(req);
|
|
5694
|
+
if (stopping.signal.aborted)
|
|
5695
|
+
throw new ApiError("unavailable", "The server is shutting down: the key was not saved.");
|
|
5696
|
+
await harnessKeys.save(recipe, decodeURIComponent(second), body);
|
|
5697
|
+
await harnessKeysChanged();
|
|
5698
|
+
return void res.writeHead(204, { "cache-control": "no-store" }).end();
|
|
5699
|
+
}
|
|
5700
|
+
case "deleteHarnessKey":
|
|
5701
|
+
await harnessKeys.remove(harnessKeys.recipe(id), decodeURIComponent(second));
|
|
5702
|
+
await harnessKeysChanged();
|
|
5703
|
+
return void res.writeHead(204, { "cache-control": "no-store" }).end();
|
|
5536
5704
|
// Never through `idempotent`: its record keeps the body, and the body holds the password.
|
|
5537
5705
|
case "getEmailAccount":
|
|
5538
5706
|
case "saveEmailAccount":
|
|
@@ -5625,7 +5793,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5625
5793
|
const body = await bodyOf(req);
|
|
5626
5794
|
// A server that isn't a Composio preset's is saved at once, as ever: no save waits on another's listing.
|
|
5627
5795
|
if (!(await mcpServers.composioPreset(id))) {
|
|
5628
|
-
const saved = await mcpServers.save(id, body, stopping.signal, secretSeen);
|
|
5796
|
+
const saved = await mcpServers.save(id, body, stopping.signal, secretSeen, undefined, undefined, undefined, undefined, byToken);
|
|
5629
5797
|
await refreshMcpMeta();
|
|
5630
5798
|
return send(res, 200, saved);
|
|
5631
5799
|
}
|
|
@@ -5643,7 +5811,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5643
5811
|
}),
|
|
5644
5812
|
inUse: () => composioTriggers.inUse(id, SAVE_AFTER_TRIGGERS),
|
|
5645
5813
|
};
|
|
5646
|
-
const saved = await mcpServers.save(id, body, stopping.signal, secretSeen, undefined, undefined, (left) => (over.dropped = left), guard);
|
|
5814
|
+
const saved = await mcpServers.save(id, body, stopping.signal, secretSeen, undefined, undefined, (left) => (over.dropped = left), guard, byToken);
|
|
5647
5815
|
await refreshMcpMeta();
|
|
5648
5816
|
return send(res, 200, over.note ? { ...saved, composio: over.note } : saved);
|
|
5649
5817
|
}
|
|
@@ -5658,11 +5826,14 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5658
5826
|
// made and what that save made that this one no longer stands on (an account of another user, an auth config of
|
|
5659
5827
|
// another toolkit), with the key it was made with, and says so as a delete does; what another saved server uses is
|
|
5660
5828
|
// that one's now, and said too. A save as another user or auth config is refused while Composio triggers use the
|
|
5661
|
-
// server, in the delete's words, checked in its project's turn before the row is written.
|
|
5829
|
+
// server, in the delete's words, checked in its project's turn before the row is written. An API-only server's token
|
|
5830
|
+
// saves one that names its key by api_key_env (the secret-write gate), and over a saved server only one it saved
|
|
5831
|
+
// (mcp-secret-writes.ts tokenWriteOverRefused), landing only while the row still has the credential the gate read
|
|
5832
|
+
// (secretSeen) and the token's mark. The body names no address or headers (composioSave refuses them).
|
|
5662
5833
|
const answer = await inComposioTurn(async () => {
|
|
5663
5834
|
const over = {};
|
|
5664
5835
|
const guard = { turn: (work) => composioTriggers.inTurnOf(id, work), inUse: () => composioTriggers.inUse(id, SAVE_AFTER_TRIGGERS) };
|
|
5665
|
-
const saved = await composioSave(body, options.composioControl ?? {}, (mcp, made, stands) => mcpServers.save(id, mcp, stopping.signal,
|
|
5836
|
+
const saved = await composioSave(body, options.composioControl ?? {}, (mcp, made, stands) => mcpServers.save(id, mcp, stopping.signal, secretSeen, made, stands, (left) => (over.dropped = left), guard, byToken), id, stopping.signal, async () => (await mcpServers.get(id)).url);
|
|
5666
5837
|
await refreshMcpMeta();
|
|
5667
5838
|
return over.dropped ? { ...saved, composio: await composioLeft(id, over.dropped) } : saved;
|
|
5668
5839
|
});
|
|
@@ -5756,7 +5927,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5756
5927
|
// its Composio project's turn, so a trigger still being made on it is counted (composio-triggers.ts deleting). All of
|
|
5757
5928
|
// it in the Composio turn, so a Composio save still at work finishes first and its record is counted.
|
|
5758
5929
|
const forgotten = await inComposioTurn(async () => {
|
|
5759
|
-
const { composio: made } = await composioTriggers.deleting(id, () => mcpServers.remove(id, secretSeen));
|
|
5930
|
+
const { composio: made } = await composioTriggers.deleting(id, () => mcpServers.remove(id, secretSeen, byToken));
|
|
5760
5931
|
await refreshMcpMeta();
|
|
5761
5932
|
return !made ? undefined : "unusable" in made ? composioNote(id, made.cleanup) : await composioForget(options.composioControl ?? {}, made.key, made.id, id, stopping.signal, made.cleanup);
|
|
5762
5933
|
});
|
|
@@ -5796,16 +5967,17 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5796
5967
|
// over the same records and the money rule's decision, costStopOverStore), so the view never says a workflow serves
|
|
5797
5968
|
// that does not run first.
|
|
5798
5969
|
const records = await promotionsOf(store.settings, id);
|
|
5970
|
+
const refused = await refusedFor(id, records);
|
|
5799
5971
|
const costStop = await costStopOverStore(store, id);
|
|
5800
5972
|
const body = entry.revision?.body;
|
|
5801
5973
|
const modelEnv = !body || sdkOf(body) || nativeOf(body) ? env : envAtPlace(env, resolvePlace(body.place, fallbackPlace(entry.revision.kind === "workflow" ? "workflow" : "agentic", body.tools ?? [])));
|
|
5802
|
-
return send(res, 200, { ...await agentLearning(data, id, await learningShown(id), counts, impact, (workflow) => servingStateOf(records, workflow, costStop),
|
|
5974
|
+
return send(res, 200, { ...await agentLearning(data, id, await learningShown(id), counts, impact, (workflow) => servingStateOf(records, workflow, costStop, refused), store), learning_model: await learningModelOf(modelEnv, entry.revision) });
|
|
5803
5975
|
}
|
|
5804
5976
|
case "getLearningCost": {
|
|
5805
5977
|
await needAgent(id);
|
|
5806
5978
|
// The agent's cost per run over the one store (agentCostOverStore): each ended run's figures and path, aggregates only.
|
|
5807
5979
|
const { limit, csv } = learningCostQuery(url);
|
|
5808
|
-
const read = await agentCostOverStore(store, id, limit);
|
|
5980
|
+
const read = await agentCostOverStore(store, id, limit, refusedFor);
|
|
5809
5981
|
// Each workflow's name as the other learning reads show it: one that holds a secret or a sign-in's value is cut.
|
|
5810
5982
|
const shown = await learningShown(id);
|
|
5811
5983
|
const cost = { ...read, runs: read.runs.map((run) => (run.workflow === null ? run : { ...run, workflow: shown.name(run.workflow) })), workflows: read.workflows.map((one) => ({ ...one, workflow: shown.name(one.workflow) })), bill: { ...read.bill, revisions: read.bill.revisions.map((one) => ({ ...one, workflow: shown.name(one.workflow) })), holds: read.bill.holds.map((one) => ({ ...one, workflow: shown.name(one.workflow), reason: shown.text(one.reason) })) } };
|
|
@@ -5822,13 +5994,15 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5822
5994
|
// (promotionsShown: a reason as well as each workflow's name). Beside what serves, each one's state, its check's
|
|
5823
5995
|
// numbers and its audit line (learn/audit.ts servingLinesOf), at the agent's numbers.
|
|
5824
5996
|
const records = await promotionsOf(store.settings, id);
|
|
5997
|
+
// Every champion below skips a record the purge gate refuses at its commit, as a run's claim does (championOf).
|
|
5998
|
+
const refused = await refusedFor(id, records);
|
|
5825
5999
|
const shown = await learningShown(id);
|
|
5826
|
-
const shownRead = promotionsShown(records, shown);
|
|
6000
|
+
const shownRead = promotionsShown(records, shown, refused);
|
|
5827
6001
|
// A ledger that can't be read now leaves each audit line at no rows, never the read refused.
|
|
5828
6002
|
const loop = auditLoopOf(entry.revision?.body?.learning);
|
|
5829
6003
|
// Each one's state with the money rule's decision a run's launch reads (costStopOverStore): a champion it stopped
|
|
5830
6004
|
// running first reads `stopped`.
|
|
5831
|
-
const lines = servingLinesOf(records, await auditsOfAgent(id).catch(() => []), loop, await costStopOverStore(store, id));
|
|
6005
|
+
const lines = servingLinesOf(records, await auditsOfAgent(id).catch(() => []), loop, await costStopOverStore(store, id), refused);
|
|
5832
6006
|
// Why its runs are never audited, when the agent can call a tool that writes (learn/audit.ts auditWriterOf, the
|
|
5833
6007
|
// rule startAudit reads); and how many of the serving revision's runs a trigger started (never audited).
|
|
5834
6008
|
const writer = auditWriterOf(entry.revision ?? undefined);
|
|
@@ -5837,7 +6011,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5837
6011
|
// first), then main: never by paging the workflow's history. Its nodes with their tiers and code checks, and the
|
|
5838
6012
|
// check it was promoted on; nodes null when no commit read holds its text (or the folder can't be read now).
|
|
5839
6013
|
const championRead = async (workflow, digest) => {
|
|
5840
|
-
const champion = championOf(records, workflow);
|
|
6014
|
+
const champion = championOf(records, workflow, refused);
|
|
5841
6015
|
const record = champion?.digest === digest ? champion : undefined;
|
|
5842
6016
|
const commits = records.filter((one) => one.workflow === workflow && one.digest === digest && one.commit).map((one) => one.commit).reverse();
|
|
5843
6017
|
const read = await workflowAtDigest(data, id, workflow, digest, commits, store).catch(() => undefined);
|
|
@@ -5850,7 +6024,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5850
6024
|
}
|
|
5851
6025
|
return shownDeep({ digest, commit: read?.commit ?? null, nodes: doc === undefined ? null : workflowNodesOf(doc), check: record?.check ?? null }, shown);
|
|
5852
6026
|
};
|
|
5853
|
-
const serving = await Promise.all(servingOf(records).map(async (one, i) => ({
|
|
6027
|
+
const serving = await Promise.all(servingOf(records, refused).map(async (one, i) => ({
|
|
5854
6028
|
...shownRead.serving[i], ...lines[i], audits_off: auditsOff,
|
|
5855
6029
|
not_auditable: one.digest === null ? 0 : await notAuditableOf(store, id, one.workflow, one.digest, loop).catch(() => 0),
|
|
5856
6030
|
champion: one.digest === null ? null : await championRead(one.workflow, one.digest),
|
|
@@ -5886,7 +6060,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5886
6060
|
}
|
|
5887
6061
|
case "listLearningLog":
|
|
5888
6062
|
await needAgent(id);
|
|
5889
|
-
return send(res, 200, await learningLog(data, id, url.searchParams, await learningShown(id),
|
|
6063
|
+
return send(res, 200, await learningLog(data, id, url.searchParams, await learningShown(id), store));
|
|
5890
6064
|
case "getLearningCorrections": {
|
|
5891
6065
|
await needAgent(id);
|
|
5892
6066
|
// corrections.md whole, as every run of the agent is served it under # Learned, with its ETag in the body and the header.
|
|
@@ -5913,7 +6087,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5913
6087
|
}
|
|
5914
6088
|
case "listLearnedWorkflowRevisions":
|
|
5915
6089
|
await needAgent(id);
|
|
5916
|
-
return send(res, 200, await workflowRevisions(data, id, second, url.searchParams, await learningShown(id),
|
|
6090
|
+
return send(res, 200, await workflowRevisions(data, id, second, url.searchParams, await learningShown(id), store));
|
|
5917
6091
|
case "readLearningFile":
|
|
5918
6092
|
await needAgent(id);
|
|
5919
6093
|
return sendText(res, 200, await readLearnedFile(data, id, second, await learningShown(id), store));
|
|
@@ -5924,7 +6098,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
5924
6098
|
const refuse = await learningValues(id);
|
|
5925
6099
|
const action = found.name === "approveLearningFile" ? "approve" : found.name === "restoreLearningFile" ? "restore" : "retire";
|
|
5926
6100
|
// A change to a workflow is a write to the agent's learning: in its delete turn (agentWrite).
|
|
5927
|
-
const written = await agentWrite(id, () => changeWorkflow(data, id, second, { action, ifMatch: typeof req.headers["if-match"] === "string" ? req.headers["if-match"] : undefined, refuse, draftTools: () => learnedDraftToolsOf(id) }));
|
|
6101
|
+
const written = await agentWrite(id, () => changeWorkflow(data, id, second, { action, ifMatch: typeof req.headers["if-match"] === "string" ? req.headers["if-match"] : undefined, refuse, draftTools: () => learnedDraftToolsOf(id), store }));
|
|
5928
6102
|
// A run's list row that read a workflow held for the owner's OK says what the folder says now, at the next list.
|
|
5929
6103
|
await lister.learningChanged(id);
|
|
5930
6104
|
return sendText(res, written.status, { ...written, text: secretsShown(refuse).text(written.text) });
|
|
@@ -6769,6 +6943,7 @@ async function startHolding(options, data, checked, stops) {
|
|
|
6769
6943
|
attachHub,
|
|
6770
6944
|
dial: { ...(options.publicUrl ? { url: options.publicUrl.replace(/\/+$/, "") } : {}), tokens: attach.machineTokens, hub: attachHub },
|
|
6771
6945
|
localInstall,
|
|
6946
|
+
ollamaHost,
|
|
6772
6947
|
own: mcpServers.own,
|
|
6773
6948
|
...(fauxGitHub ? { fauxGitHub: { api: fauxGitHub.url, ...(fauxGitHub.web ? { web: fauxGitHub.web } : {}) } } : {}),
|
|
6774
6949
|
// Once: a second call, at any time, is the first one's promise, so a close repeated after the next server started
|