@parcha/agentrun-serve 0.1.0-beta.57 → 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 +52 -0
- package/README.md +64 -33
- package/dist/api-only.d.ts +2 -4
- package/dist/api-only.js +2 -4
- package/dist/box-paths.d.ts +4 -3
- package/dist/box-paths.js +7 -4
- package/dist/claude-login-token.d.ts +117 -0
- package/dist/claude-login-token.js +737 -0
- package/dist/claude-login.d.ts +52 -12
- package/dist/claude-login.js +164 -39
- package/dist/cli.js +7 -41
- package/dist/computer-attach.d.ts +35 -17
- package/dist/computer-attach.js +301 -49
- package/dist/computers.d.ts +10 -10
- package/dist/computers.js +5 -5
- package/dist/console/assets/{backend-DVhHzJX2.js → backend-CSAWUqtZ.js} +1 -1
- package/dist/console/assets/index-DPh29cyz.js +747 -0
- package/dist/console/index.html +1 -1
- package/dist/dial-relay.d.ts +25 -4
- package/dist/dial-relay.js +129 -1
- package/dist/env-switch.d.ts +1 -3
- package/dist/env-switch.js +1 -3
- package/dist/fal-price.d.ts +1 -3
- package/dist/fal-price.js +77 -26
- 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/learning-cost.d.ts +22 -20
- package/dist/learning-cost.js +15 -21
- package/dist/live-reach.d.ts +2 -0
- package/dist/live-reach.js +2 -0
- package/dist/mcp-api-only-origins.d.ts +8 -3
- package/dist/mcp-api-only-origins.js +17 -17
- package/dist/micro.d.ts +2 -0
- package/dist/micro.js +2 -0
- package/dist/model.d.ts +5 -4
- package/dist/model.js +7 -6
- package/dist/monid.d.ts +14 -1
- package/dist/monid.js +103 -26
- package/dist/openapi.js +34 -12
- package/dist/place-offers.d.ts +4 -0
- package/dist/place-offers.js +7 -4
- package/dist/provider.d.ts +2 -2
- package/dist/provider.js +9 -5
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-view.d.ts +1 -2
- package/dist/run-view.js +2 -1
- package/dist/runner/adapter-loop.js +3 -16
- package/dist/runner/adapter-run-spec.d.ts +20 -13
- package/dist/runner/adapter-run-spec.js +57 -48
- package/dist/runner/beside.d.ts +9 -2
- package/dist/runner/beside.js +24 -7
- package/dist/runner/claim-secrets.d.ts +17 -15
- package/dist/runner/claim-secrets.js +32 -34
- package/dist/runner/cli-run-spec.js +21 -9
- package/dist/runner/held.d.ts +16 -4
- package/dist/runner/main.d.ts +11 -6
- package/dist/runner/main.js +12 -7
- package/dist/runner/mcp-claim.js +3 -2
- package/dist/runner/mcp-run.d.ts +3 -6
- package/dist/runner/mcp-run.js +3 -4
- 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 +19 -8
- package/dist/runner/run-child-host.js +80 -34
- package/dist/runner/runner.d.ts +3 -0
- package/dist/runner/runner.js +1 -1
- package/dist/runner/save-slots.js +2 -1
- package/dist/runner/subagent.d.ts +11 -0
- package/dist/runner/subagent.js +17 -3
- package/dist/runner/workflow-first.d.ts +27 -14
- package/dist/runner/workflow-first.js +29 -22
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/server.d.ts +18 -7
- package/dist/server.js +150 -64
- package/dist/slots.d.ts +9 -0
- package/dist/slots.js +45 -0
- package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
- package/dist/store/schema.d.ts +17 -0
- package/dist/store/schema.js +47 -1
- package/dist/store/sqlite/run-patch.d.ts +11 -1
- package/dist/store/sqlite/run-patch.js +29 -1
- package/dist/store/sqlite/store.js +72 -9
- package/dist/store/store.d.ts +14 -0
- package/dist/store-reads/learning.d.ts +81 -124
- package/dist/store-reads/learning.js +207 -286
- package/dist/template-eval.d.ts +19 -0
- package/dist/template-eval.js +92 -43
- package/dist/template-import.d.ts +0 -10
- package/dist/template-import.js +5 -10
- package/dist/timeline/web-calls.d.ts +12 -14
- package/dist/timeline/web-calls.js +14 -30
- package/dist/web-save.d.ts +4 -9
- package/dist/web-save.js +4 -43
- package/dist/workspace/attached-computers.d.ts +32 -9
- package/dist/workspace/attached-computers.js +77 -13
- package/dist/workspace/computer-deps.d.ts +6 -1
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.js +6 -3
- package/dist/workspace/paired-route.d.ts +91 -0
- package/dist/workspace/paired-route.js +153 -0
- package/dist/wrapped.d.ts +8 -2
- package/dist/wrapped.js +21 -6
- package/package.json +12 -12
- package/templates/README.md +3 -3
- package/dist/console/assets/index-okP-y8PK.js +0 -747
|
@@ -43,11 +43,12 @@ import { openRunMcpAuth, sealRunMcpAuth } from "../store/seal.js";
|
|
|
43
43
|
import { runZone } from "../environment.js";
|
|
44
44
|
import { shadowRunId } from "../learn/audit.js";
|
|
45
45
|
import { LEARNING_SCRIPT, learningWorkspace } from "../learn/folder.js";
|
|
46
|
+
import { agreeOnOf } from "../learning-setting.js";
|
|
46
47
|
import { openRunWorkspace } from "../workspace/run-workspace.js";
|
|
47
48
|
import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
|
|
48
49
|
import { agentDirName, recordingsFolder, runFolder, scratchFolder } from "../workspace/paths.js";
|
|
49
50
|
import { keptKeyOf } from "../workspace/computer-kept.js";
|
|
50
|
-
import { claimModelKey, claimSecrets, claimSpendOff, hostDecisionKeys, learnedDecisionKeys, openRunModelKey,
|
|
51
|
+
import { claimModelKey, claimSecrets, claimSpendOff, hostDecisionKeys, learnedDecisionKeys, openRunModelKey, savedModelKeys, serverKeyless, tierModelKeys, withoutModelKeys } from "./claim-secrets.js";
|
|
51
52
|
import { githubAppAccess } from "./github-app.js";
|
|
52
53
|
import { githubPullOf, githubTargetOf } from "../github.js";
|
|
53
54
|
import { isObject } from "../validate.js";
|
|
@@ -61,11 +62,12 @@ import { compareEndOfRun } from "./compare-end.js";
|
|
|
61
62
|
import { learnedFirst } from "./learned-first.js";
|
|
62
63
|
import { workflowsAt } from "./learning-seed.js";
|
|
63
64
|
import { claimMetering, heldMcpOf, mcpForClaim } from "./mcp-run.js";
|
|
64
|
-
import {
|
|
65
|
+
import { learnedTiers, learnsWorkflows, mcpReachOf } from "./adapter-run-spec.js";
|
|
65
66
|
import { createDispatchLoop } from "./dispatch.js";
|
|
66
67
|
import { refuseRecipeTriggerRun, resolveRunnerLoop, withSavedGatewayDeps } from "./harness-loops.js";
|
|
67
68
|
import { isWorkflowRevision } from "./workflow-loop.js";
|
|
68
69
|
import { loginForRun } from "../claude-login.js";
|
|
70
|
+
import { agentRunLogin, LOGIN_NOT_HANDED, loginRunnerInProcess, loginTokensFor } from "../claude-login-token.js";
|
|
69
71
|
import { heardComputerHold } from "./computer-journal.js";
|
|
70
72
|
import { ClaimRefused } from "./loop-contract.js";
|
|
71
73
|
import { Channel, ChannelClosed } from "./run-channel.js";
|
|
@@ -74,7 +76,7 @@ import { exposeSaveSlots } from "./save-slots.js";
|
|
|
74
76
|
import { runBigWrites } from "./big-writes.js";
|
|
75
77
|
import { SERVER_SLOTS } from "../web-save.js";
|
|
76
78
|
import { launchOnItsDisk, readLaunchBody } from "../run-launch.js";
|
|
77
|
-
import { SUBAGENT_TOOL } from "./subagent.js";
|
|
79
|
+
import { routedSubagentTiers, SUBAGENT_TOOL } from "./subagent.js";
|
|
78
80
|
import { sourceSyncOf } from "../source-sync/types.js";
|
|
79
81
|
import { sourceAuxiliaryAdmitter } from "../source-sync/auxiliary.js";
|
|
80
82
|
import { beginSourceIO } from "../source-sync/io.js";
|
|
@@ -707,6 +709,35 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
707
709
|
return undefined;
|
|
708
710
|
return { state: plan.state, models: [...plan.models], token: () => plan.token(), refused: (sent) => plan.refused(sent), watch: (listener) => plan.watch(listener) };
|
|
709
711
|
},
|
|
712
|
+
// The claim's own login, as this runner reads the claim (its harness, its place, no model key of its own), whatever
|
|
713
|
+
// the process names: its access token alone, read again at each ask and renewed here when it must be (near its end,
|
|
714
|
+
// or refused); never its folder or its refresh token. Each token is carried into the runner's redactor for this run
|
|
715
|
+
// (redact.ts carry) before it is handed, a renewed one too: model text that repeats it is cut from the run's journal
|
|
716
|
+
// as the runner writes it (runner.ts fenced), from what it stages and from its rows, as the run's own tool keys are.
|
|
717
|
+
// This answer is the claim's one decision whether it goes on the login: none, it does not; a login other than
|
|
718
|
+
// AgentRun's own folder is refused in words, never left to a model key. The process reads no setting or machine id.
|
|
719
|
+
claudeLogin: async () => {
|
|
720
|
+
if (await runKeyed())
|
|
721
|
+
return undefined;
|
|
722
|
+
const harness = launch.harness ?? revision.body.harness;
|
|
723
|
+
const at = await loginForRun(store.settings, deps.data, deps.env ?? {}, harness, launch.place);
|
|
724
|
+
if (!at)
|
|
725
|
+
return undefined;
|
|
726
|
+
if (!agentRunLogin(at, deps.data))
|
|
727
|
+
throw new ClaimRefused(LOGIN_NOT_HANDED);
|
|
728
|
+
const carry = cut.carry;
|
|
729
|
+
if (!carry)
|
|
730
|
+
throw new ClaimRefused("This runner has no redactor that can cut the login's token from what its run writes, so it hands none.");
|
|
731
|
+
const tokens = loginTokensFor(at);
|
|
732
|
+
return {
|
|
733
|
+
token: async () => {
|
|
734
|
+
const token = await tokens.token();
|
|
735
|
+
carry.call(cut, claim.runId, [token]);
|
|
736
|
+
return token;
|
|
737
|
+
},
|
|
738
|
+
refused: (sent) => tokens.refused(sent),
|
|
739
|
+
};
|
|
740
|
+
},
|
|
710
741
|
signInReadsBack: () => handedSignInReadsBack(store, sealKey, run),
|
|
711
742
|
runSignIn: (resolution) => {
|
|
712
743
|
const vendorFetch = async () => (claimed[FAUX_ENV] ? fauxFetch(claimed, FAUX_VENDOR_API_ENV) : fetch);
|
|
@@ -716,7 +747,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
716
747
|
mcp: (ask) => projectCall(async () => {
|
|
717
748
|
const reach = await mcpReachOf(deps);
|
|
718
749
|
const harness = { commit: (change) => change({ appendEntry: async (_conversation, entry) => void (await ask.appendRoot(dataOnly(entry))) }) };
|
|
719
|
-
const made = await mcpForClaim({ claim, store, sealKey, grants: granted, harness: harness, work: () => runFolder(deps.data, run.agentId, claim.runId), launchInput: launch.input, githubAppAccess: () => github(), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps,
|
|
750
|
+
const made = await mcpForClaim({ claim, store, sealKey, grants: granted, harness: harness, work: () => runFolder(deps.data, run.agentId, claim.runId), launchInput: launch.input, githubAppAccess: () => github(), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, undefined, launch) });
|
|
720
751
|
if (!made)
|
|
721
752
|
return undefined;
|
|
722
753
|
releases.push(() => made.release());
|
|
@@ -748,22 +779,24 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
|
|
|
748
779
|
};
|
|
749
780
|
return { api: access.api, target: bound, mint, ...(access.revoke ? { revoke: access.revoke } : {}), ...(access.same ? { same: access.same } : {}) };
|
|
750
781
|
},
|
|
751
|
-
|
|
752
|
-
//
|
|
753
|
-
//
|
|
754
|
-
//
|
|
755
|
-
|
|
756
|
-
//
|
|
757
|
-
//
|
|
758
|
-
//
|
|
759
|
-
//
|
|
760
|
-
// kept from running, which
|
|
761
|
-
|
|
762
|
-
const
|
|
763
|
-
|
|
782
|
+
subagentTierKeys: async () => {
|
|
783
|
+
// A subagent's tiers alone: an agentic run granted the subagent tool routes each tier its revision's modelTiers or
|
|
784
|
+
// the host's tier variable names, and no other (adapter-run-spec.ts), so its process is handed those tiers' models'
|
|
785
|
+
// keys (tierModelKeys, the revision's model of a tier over the host's): never a provider's no tier of it reaches, nor
|
|
786
|
+
// a key for a tier it routes no model on. A replay's or an audit's grade (adapter-run-spec.ts graderRouteOf) routes
|
|
787
|
+
// the fast tier of that same answer, whose model may be another provider's than its agent's: its process is handed
|
|
788
|
+
// that tier's model's key alone (through a gateway, the gateway's), none when the revision names agree_on (no
|
|
789
|
+
// grader). A learning run's grade and an SDK run's compile turn stay in the runner (runsInRunner): their process
|
|
790
|
+
// never asks, and gets none. And never for a run that holds a key of its own (its launch's, read now): the server's
|
|
791
|
+
// keys are not its to spend, whatever its process asks; nor for a held run its model kept from running, which routes
|
|
792
|
+
// no model and grades nothing.
|
|
793
|
+
const subagent = !modelRefused && revision.kind === "agentic" && granted.includes(SUBAGENT_TOOL);
|
|
794
|
+
const grades = !modelRefused && (launch.replay !== undefined || launch.audit !== undefined) && !agreeOnOf(revision.body.learning)?.length;
|
|
795
|
+
if (!subagent && !grades)
|
|
764
796
|
return {};
|
|
765
|
-
const
|
|
766
|
-
|
|
797
|
+
const { tiers, refs } = routedSubagentTiers(revision.body, keys.env ?? {});
|
|
798
|
+
const keyed = await runKeyed();
|
|
799
|
+
return stringsOf(keyed ? {} : await tierModelKeys(keys, subagent ? tiers : tiers.filter((tier) => tier === "fast"), refs));
|
|
767
800
|
},
|
|
768
801
|
tierModelKeys: async (tiers) => {
|
|
769
802
|
// The tiers the claim's learned workflows name (learnedTiers), as this runner chose them (learnedFirst below): a
|
|
@@ -1038,19 +1071,26 @@ export const childArgv = () => [process.execPath, "--import", new URL("../secret
|
|
|
1038
1071
|
* A native run (launch.native): its agent is the source machine's own sign-in, reached through the server's
|
|
1039
1072
|
* connectors, whose rows are the server's. */
|
|
1040
1073
|
export const runsInRunner = (harness, launch) => harness === "learning" || Boolean(launch.sdk) || Boolean(launch.native) || Boolean(launch.cli_learning);
|
|
1041
|
-
/** The words a run on
|
|
1042
|
-
|
|
1074
|
+
/** The words a run on this machine's own Claude Code login (the `machine` place: claude-login.ts machineFolder, ~/.claude
|
|
1075
|
+
* or the server's CLAUDE_CONFIG_DIR) is refused in where each run is a user of its own: only AgentRun's own login folder
|
|
1076
|
+
* is handed to such a run, as its access token. */
|
|
1077
|
+
export const LOGIN_MACHINE_NEEDS_SERVER_USER = `A run on this machine's own Claude Code login (~/.claude, or the CLAUDE_CONFIG_DIR AgentRun was started with) needs runs under the server's own user, and this runner runs each run as a user of its own: switch to AgentRun's own login folder under Settings → Model keys, set ${RUN_USER_ENV}=same, or give the run a model_key.`;
|
|
1078
|
+
/** The words a run on the login is refused in where each run is a user of its own while runner `other`, on the same data
|
|
1079
|
+
* folder, runs its runs on the login in its own process, whose CLI renews the login in that folder itself. */
|
|
1080
|
+
export const loginRunnerInProcessWords = (other) => `This runner runs each run as a user of its own, and runner ${other} on the same data folder runs Claude Code's login runs in its own process, whose CLI renews that login itself: stop ${other}, set ${RUN_USER_ENV}=same on this runner too, or give the run a model_key.`;
|
|
1043
1081
|
/** The words a run on a harness recipe is refused in where each run is a user of its own (harness-table.ts recipeHarness). */
|
|
1044
1082
|
export const RECIPE_NEEDS_SERVER_USER = `A run on a harness recipe needs runs under the server's own user, since its install, its check and its owner's sign-in are that user's alone, and this runner runs each run as a user of its own: set ${RUN_USER_ENV}=same on this runner.`;
|
|
1045
1083
|
export { RECIPE_SIGN_IN_PERSON_ONLY } from "./harness-loops.js";
|
|
1046
1084
|
/** Whether run `runId` stays in its runner's process: runsInRunner's, and a workflow run on a server with a documents
|
|
1047
1085
|
* directory (launch.documents), whose reads and writes (a pdf_pages call's pages) are rooted in a folder the server's
|
|
1048
1086
|
* user holds and no slot's user is given; its nodes run the server's own tools alone, no agent's code. A run on Claude
|
|
1049
|
-
* Code's login on this machine (claude-login.ts loginForRun)
|
|
1050
|
-
*
|
|
1051
|
-
*
|
|
1052
|
-
* the
|
|
1053
|
-
*
|
|
1087
|
+
* Code's login on this machine (claude-login.ts loginForRun), where runs are the runner's own user (`process`), stays in
|
|
1088
|
+
* the runner, its CLI on the login's folder. Where each run is a user of its own (`uid`), a run on AgentRun's own login
|
|
1089
|
+
* folder is a process of its own handed the login's access token alone (held.ts claudeLogin, claude-login-token.ts),
|
|
1090
|
+
* never the folder; it is refused at its claim (ClaimRefused, in words) on this machine's own login (machineFolder), and
|
|
1091
|
+
* while a `process` runner on the same data folder is live (its CLI renews the folder's login itself). A run its caller
|
|
1092
|
+
* handed a model key (model_key) runs on that key and never on the login (cli-run-spec.ts), so it is a process of its
|
|
1093
|
+
* own like any other. */
|
|
1054
1094
|
export async function staysInRunner(deps, harness, launch, runId, isolation) {
|
|
1055
1095
|
// A recipe's harness reads its install, its check's note and its owner's sign-in, each the server user's alone: never
|
|
1056
1096
|
// opened to a slot's user (the sign-in least of all), so where each run is a user of its own it is refused here. And a
|
|
@@ -1067,13 +1107,19 @@ export async function staysInRunner(deps, harness, launch, runId, isolation) {
|
|
|
1067
1107
|
if (revision && isWorkflowRevision(revision))
|
|
1068
1108
|
return true;
|
|
1069
1109
|
}
|
|
1070
|
-
|
|
1110
|
+
const login = await loginForRun(deps.store.settings, deps.data, deps.env ?? {}, harness, launch.place);
|
|
1111
|
+
if (login === undefined)
|
|
1071
1112
|
return false;
|
|
1072
1113
|
if ((await openRunModelKey({ store: deps.store, sealKey: deps.sealKey }, runId)) !== undefined)
|
|
1073
1114
|
return false;
|
|
1074
|
-
if (isolation.kind
|
|
1075
|
-
|
|
1076
|
-
|
|
1115
|
+
if (isolation.kind !== "uid")
|
|
1116
|
+
return true;
|
|
1117
|
+
if (!agentRunLogin(login, deps.data))
|
|
1118
|
+
throw new ClaimRefused(LOGIN_MACHINE_NEEDS_SERVER_USER);
|
|
1119
|
+
const other = await loginRunnerInProcess(deps.data, deps.store.runners);
|
|
1120
|
+
if (other !== undefined)
|
|
1121
|
+
throw new ClaimRefused(loginRunnerInProcessWords(other));
|
|
1122
|
+
return false;
|
|
1077
1123
|
}
|
|
1078
1124
|
/** The runner's loop factory where each run is a process of its own: a ChildLoop per claim, but for a run that stays in
|
|
1079
1125
|
* the runner (staysInRunner). */
|
|
@@ -1209,10 +1255,10 @@ function childLoop(options, slots, loopDeps) {
|
|
|
1209
1255
|
// host's default's now, where its revision names no model and a key saved since moved that default.
|
|
1210
1256
|
const claimed = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv, redact: loopDeps.redact }, revisionRow, launch, claim.runId);
|
|
1211
1257
|
// A --faux start alone is pinned to the faux model (model.ts chooseModel), which stands in for its revision's and
|
|
1212
|
-
// sends no key: its process is handed its revision's model's key with them, as a run of that model is handed it.
|
|
1213
|
-
//
|
|
1214
|
-
// nowhere.
|
|
1215
|
-
const ofRevision = launch.model?.provider === FAUX_PROVIDER ? await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv, redact: loopDeps.redact }, revisionRow, { ...(launch.plane ? { plane: launch.plane } : {}), ...(launch.hold ? { hold: launch.hold } : {}) }) : {};
|
|
1258
|
+
// sends no key: its process is handed its revision's model's key with them, as a run of that model is handed it.
|
|
1259
|
+
// Only on a runner in faux mode too: a faux launch claimed where FAUX_ENV is unset gets no second claim. A held run its
|
|
1260
|
+
// model kept from running at its create (hold.refused) is laid no model key here either: its model runs nowhere.
|
|
1261
|
+
const ofRevision = launch.model?.provider === FAUX_PROVIDER && claimEnv[FAUX_ENV] ? await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv, redact: loopDeps.redact }, revisionRow, { ...(launch.plane ? { plane: launch.plane } : {}), ...(launch.hold ? { hold: launch.hold } : {}) }) : {};
|
|
1216
1262
|
// A run that holds a model key of its own (model_key, its launch's) spends that key alone: its process is handed
|
|
1217
1263
|
// none of the server's model keys, as its spec drops them from its tools' (claim-secrets.ts withoutModelKeys).
|
|
1218
1264
|
// Copies: the runner's own reads (heldFor's `claimed`: what the run's learning must never keep) stay whole.
|
package/dist/runner/runner.d.ts
CHANGED
|
@@ -50,6 +50,9 @@ export interface RunnerOptions {
|
|
|
50
50
|
* answers on the same row, under the same incarnation): used as is, never closed here. Default: one of its own,
|
|
51
51
|
* removed at its close. */
|
|
52
52
|
presence?: Presence;
|
|
53
|
+
/** The incarnation its own presence says (no `presence` given): the runner beside a server runs under the one the
|
|
54
|
+
* server gave it (Serve.beside), which its paired computers' routes name. Default: a new one. */
|
|
55
|
+
incarnation?: string;
|
|
53
56
|
/** Most runs held at once. */
|
|
54
57
|
loops?: number;
|
|
55
58
|
/** How long a claim lasts unless renewed. */
|
package/dist/runner/runner.js
CHANGED
|
@@ -1117,7 +1117,7 @@ export function startRunner(options) {
|
|
|
1117
1117
|
};
|
|
1118
1118
|
// Its word in the store that a runner that claims is here (presence.ts), for as long as it runs: a server reads a
|
|
1119
1119
|
// refusal left by an earlier runner as over once this is there. One its caller keeps is its caller's to close.
|
|
1120
|
-
const presence = options.presence ? undefined : store.runners ? keepPresence(store.runners, name, null, { warn: (line) => emit({ type: "error", step: "presence", message: line }), slots: loops }) : undefined;
|
|
1120
|
+
const presence = options.presence ? undefined : store.runners ? keepPresence(store.runners, name, null, { warn: (line) => emit({ type: "error", step: "presence", message: line }), slots: loops, ...(options.incarnation ? { incarnation: options.incarnation } : {}) }) : undefined;
|
|
1121
1121
|
poll();
|
|
1122
1122
|
commandTimer = setTimeout(deliverAll, commandPollMs);
|
|
1123
1123
|
// A run queued in this process is claimed now (claimNow). A command written for a run this runner holds is handed on
|
|
@@ -69,7 +69,8 @@ export function remoteSaveSlots(channel) {
|
|
|
69
69
|
waiting++;
|
|
70
70
|
let release;
|
|
71
71
|
try {
|
|
72
|
-
|
|
72
|
+
// The channel takes a slot under a signal: with none given, one that never aborts (Slots.take waits until free).
|
|
73
|
+
release = await channel.call(TARGET, "take", [signal ?? new AbortController().signal]);
|
|
73
74
|
}
|
|
74
75
|
finally {
|
|
75
76
|
waiting--;
|
|
@@ -4,6 +4,17 @@ export declare const SUBAGENT_TOOL = "subagent";
|
|
|
4
4
|
* none runs its child on the agent's own model. */
|
|
5
5
|
export declare const SUBAGENT_TIERS: readonly ["fast", "strong"];
|
|
6
6
|
export type SubagentTier = (typeof SUBAGENT_TIERS)[number];
|
|
7
|
+
/** The subagent tiers a run routes a model on, with the model its revision names for each: a tier its revision's
|
|
8
|
+
* modelTiers names (a string), else one `env`'s tier variable names (AGENT_MODEL_FAST, AGENT_MODEL_STRONG: tierModelOf),
|
|
9
|
+
* and no other. The one answer for the runner that hands a run's process its tiers' saved model keys (run-child-host.ts
|
|
10
|
+
* heldFor), for the run that routes the tiers (adapter-run-spec.ts) and for a replay's grader on the fast tier, so a
|
|
11
|
+
* tier is never routed with no key handed for it, nor a key handed for a tier no route reads. */
|
|
12
|
+
export declare function routedSubagentTiers(body: {
|
|
13
|
+
readonly modelTiers?: unknown;
|
|
14
|
+
}, env: NodeJS.ProcessEnv): {
|
|
15
|
+
readonly tiers: SubagentTier[];
|
|
16
|
+
readonly refs: Partial<Record<SubagentTier, string>>;
|
|
17
|
+
};
|
|
7
18
|
/** How many of a run's children work at once; a call past it waits for a slot. */
|
|
8
19
|
export declare const SUBAGENT_PARALLEL = 4;
|
|
9
20
|
/** A child's instructions: the call's prompt is its whole task. Nothing of the parent's prompt is carried over. */
|
package/dist/runner/subagent.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { configure, defineTool, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
2
2
|
import { HOST_RESULT_MAX_CHARS } from "@parcha/agentrun-kernel";
|
|
3
|
+
import { tierModelOf } from "../model.js";
|
|
3
4
|
import { ASK_TOOL } from "../tools.js";
|
|
4
|
-
import {
|
|
5
|
+
import { slots } from "../slots.js";
|
|
5
6
|
import { durableWait } from "../workflow/pi-versions.js";
|
|
6
7
|
import { HOST_TOOL_OUTPUT } from "./adapters/pi.js";
|
|
7
8
|
import { cutAtLimit } from "./loop-contract.js";
|
|
@@ -10,6 +11,19 @@ export const SUBAGENT_TOOL = "subagent";
|
|
|
10
11
|
/** The tiers a call may name for its child (its definition's model_tiers, else this server's tier); a call that names
|
|
11
12
|
* none runs its child on the agent's own model. */
|
|
12
13
|
export const SUBAGENT_TIERS = ["fast", "strong"];
|
|
14
|
+
/** The subagent tiers a run routes a model on, with the model its revision names for each: a tier its revision's
|
|
15
|
+
* modelTiers names (a string), else one `env`'s tier variable names (AGENT_MODEL_FAST, AGENT_MODEL_STRONG: tierModelOf),
|
|
16
|
+
* and no other. The one answer for the runner that hands a run's process its tiers' saved model keys (run-child-host.ts
|
|
17
|
+
* heldFor), for the run that routes the tiers (adapter-run-spec.ts) and for a replay's grader on the fast tier, so a
|
|
18
|
+
* tier is never routed with no key handed for it, nor a key handed for a tier no route reads. */
|
|
19
|
+
export function routedSubagentTiers(body, env) {
|
|
20
|
+
const named = (body.modelTiers ?? {});
|
|
21
|
+
const refs = {};
|
|
22
|
+
for (const tier of SUBAGENT_TIERS)
|
|
23
|
+
if (typeof named[tier] === "string")
|
|
24
|
+
refs[tier] = named[tier];
|
|
25
|
+
return { tiers: SUBAGENT_TIERS.filter((tier) => refs[tier] !== undefined || tierModelOf(env, tier) !== undefined), refs };
|
|
26
|
+
}
|
|
13
27
|
/** How many of a run's children work at once; a call past it waits for a slot. */
|
|
14
28
|
export const SUBAGENT_PARALLEL = 4;
|
|
15
29
|
/** Tools no child is given: a subagent of its own (depth 1), and the person, whom only the run's own conversation asks. */
|
|
@@ -51,7 +65,7 @@ export function chosenTools(asked, options) {
|
|
|
51
65
|
/** The subagent tool: one of the session's own tools (adapters/pi.ts `tools`), so it needs no extension of its own. */
|
|
52
66
|
export function subagentTool(options) {
|
|
53
67
|
// The run's children's slots (SUBAGENT_PARALLEL), handed out in call order.
|
|
54
|
-
const free =
|
|
68
|
+
const free = slots(SUBAGENT_PARALLEL);
|
|
55
69
|
return defineTool({
|
|
56
70
|
name: SUBAGENT_TOOL,
|
|
57
71
|
description: `Run a subagent: a fresh conversation that starts with nothing but your prompt, on your own model (or the model tier you name: ${SUBAGENT_TIERS.join(" or ")}), with only the tools you list (a subset of your own), and get its final answer back as text. Write the prompt self-contained: the subagent sees none of your conversation. Several calls in one turn run at once, at most ${SUBAGENT_PARALLEL} at a time; more wait their turn. A subagent cannot start subagents of its own.`,
|
|
@@ -96,7 +110,7 @@ export function subagentTool(options) {
|
|
|
96
110
|
const missing = [...names].filter((name) => !tools.some((registration) => registration.name === name));
|
|
97
111
|
if (missing.length)
|
|
98
112
|
return fail(`subagent: ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} not bound in this run, so no subagent may have ${missing.length === 1 ? "it" : "them"}. Nothing ran.`);
|
|
99
|
-
const release = await free.take(context.abortSignal
|
|
113
|
+
const release = await free.take(context.abortSignal);
|
|
100
114
|
try {
|
|
101
115
|
const child = await api.commit(async (tx) => {
|
|
102
116
|
// The ownership index remembers the child: a rerun of this call reuses it.
|
|
@@ -52,11 +52,9 @@ export interface Revise {
|
|
|
52
52
|
readonly by_hand_usd: number;
|
|
53
53
|
readonly runs: number;
|
|
54
54
|
}
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
* moneyAllInOf: its booked cost and every learning round booked for it, a run off the served paths less its compile
|
|
59
|
-
* turns; null when any part is unknown), when it started. */
|
|
55
|
+
/** One of the agent's runs as the money rule reads it: its record's path fields, its all-in cost (the cost series'
|
|
56
|
+
* `total_usd`, learn/ledger.ts RunFigures: the job, its look-back and its audit's shadow; null when any part is
|
|
57
|
+
* unknown), when it started. */
|
|
60
58
|
export type PastRun = {
|
|
61
59
|
readonly metrics: unknown;
|
|
62
60
|
readonly allInUsd: number | null;
|
|
@@ -67,12 +65,26 @@ type Mean = {
|
|
|
67
65
|
readonly runs: number;
|
|
68
66
|
readonly mean_usd: number;
|
|
69
67
|
};
|
|
70
|
-
/**
|
|
71
|
-
* its
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
/** What the money rule reads of the agent (store-reads/learning.ts pastRunsOf): of its newest PAST_RUNS runs on no named
|
|
69
|
+
* disk, those since its learning's reset (`runs`, any order), and the by-hand cost over those same runs (`by_hand`: the
|
|
70
|
+
* mean job's own $ of the ones on the `agent` path, learning left out) with the by-hand runs it left out for an unknown
|
|
71
|
+
* cost (`by_hand_unknown`). */
|
|
72
|
+
export type PastRuns = {
|
|
73
|
+
readonly runs: readonly PastRun[];
|
|
74
|
+
readonly by_hand: Mean | null;
|
|
75
|
+
readonly by_hand_unknown: number;
|
|
76
|
+
};
|
|
77
|
+
/** No runs read: nothing to stop. */
|
|
78
|
+
export declare const NO_PAST_RUNS: PastRuns;
|
|
79
|
+
/** How many of the agent's newest runs on no named disk the money rule reads, both sides (store-reads/learning.ts
|
|
80
|
+
* pastRunsOf): a launch's read is bounded whatever the agent's history, and the cost page reads the same window. */
|
|
81
|
+
export declare const PAST_RUNS = 500;
|
|
82
|
+
/** The money rule's two sides for workflow `name` at `digest`, over the agent's runs (`past`): `served`, the mean all-in
|
|
83
|
+
* of its newest COST_WINDOW runs served first at that digest (path workflow or handed_back) whose all-in is known (the
|
|
84
|
+
* cost page's `after` side reads the same figure); `by_hand`, as given (PastRuns: the job's own $ over the same runs,
|
|
85
|
+
* never a second baseline here); `unknown_runs`, the runs either side would have read that it left out for an unknown cost (the cost
|
|
86
|
+
* page's rule: left out and counted). */
|
|
87
|
+
export declare function costLineOf(past: PastRuns, name: string, digest: string): {
|
|
76
88
|
served: Mean | {
|
|
77
89
|
runs: 0;
|
|
78
90
|
mean_usd: null;
|
|
@@ -86,11 +98,11 @@ export declare const overLine: (line: ReturnType<typeof costLineOf>) => boolean;
|
|
|
86
98
|
/** The money rule's decision over the agent's runs (`past`, store-reads/learning.ts pastRunsOverStore): whether it stops a
|
|
87
99
|
* workflow at a digest from running first (overLine), the one workflowFirstOf reads at a claim. Each workflow's state
|
|
88
100
|
* (learn/promote.ts servingStateOf) folds it in at its champion's digest. */
|
|
89
|
-
export declare const costStopOf: (past:
|
|
101
|
+
export declare const costStopOf: (past: PastRuns) => CostStop;
|
|
90
102
|
/** Each learned workflow that has served one of the agent's runs (`past`) first, at the digest its newest served run
|
|
91
103
|
* ran, with the money rule's two sides there, the runs they left out for an unknown all-in, and where it stands:
|
|
92
104
|
* `serving`, or `needs_revision` once over the line (overLine). What the agent's cost per run shows its owner. */
|
|
93
|
-
export declare function workflowCostsOf(past:
|
|
105
|
+
export declare function workflowCostsOf(past: PastRuns): {
|
|
94
106
|
workflow: string;
|
|
95
107
|
digest: string;
|
|
96
108
|
state: "serving" | "needs_revision";
|
|
@@ -156,7 +168,7 @@ export declare const workflowDigest: (workflow: Pick<LearnedWorkflow, "workflow"
|
|
|
156
168
|
* run (launch.replay) serves the workflow it replays, by name, alone: no promotion, no money rule; none when its claim
|
|
157
169
|
* laid no workflow by that name at that digest (runner/promotion.ts replayClaimed then refuses the claim: the run ends
|
|
158
170
|
* failed, never on the agent's path). */
|
|
159
|
-
export declare function workflowFirstOf(kind: string, workflows: readonly LearnedWorkflow[], launch: RunLaunch, log?: (line: string) => void, past?: () => Promise<
|
|
171
|
+
export declare function workflowFirstOf(kind: string, workflows: readonly LearnedWorkflow[], launch: RunLaunch, log?: (line: string) => void, past?: () => Promise<PastRuns>, promoted?: Promoted, outputSchema?: unknown): Promise<FirstChoice>;
|
|
160
172
|
/** What a run's workflow-first step did, from its root entries (the WORKFLOW_FIRST entry): the workflow, its digest, the
|
|
161
173
|
* promotion it served under (WorkflowFirst.promotion), and whether it answered or handed back; undefined when it served
|
|
162
174
|
* none. `cut` on a hand-back the workflow never made itself: its call's end (WORKFLOW_FIRST_CALL) is `interrupted`, a
|
|
@@ -196,6 +208,7 @@ export declare function pathMetrics(launch: RunLaunch, classified: {
|
|
|
196
208
|
workflow_promotion?: number;
|
|
197
209
|
workflow_cut?: true;
|
|
198
210
|
not_auditable?: true;
|
|
211
|
+
not_served?: "cost_stop";
|
|
199
212
|
loops?: LoopRow[];
|
|
200
213
|
replay?: ReplayMetrics;
|
|
201
214
|
audit?: NonNullable<RunLaunch["audit"]> & {
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
// is one sample; a revision is asked only of a workflow its promotion holds), and never keeps the workflow from serving.
|
|
13
13
|
// One money rule does (costLineOf): a workflow
|
|
14
14
|
// serves while its all-in cost a run over its last COST_WINDOW served runs at its digest stays under the agent's by-hand
|
|
15
|
-
// cost
|
|
16
|
-
// all-in (
|
|
17
|
-
// and
|
|
18
|
-
// its
|
|
19
|
-
//
|
|
15
|
+
// cost. Both are the cost page's own (store-reads/learning.ts, over learn/ledger.ts summarize): the served side reads a
|
|
16
|
+
// run's all-in (its booked cost, the workflow and any handback's agent work together, and every learning round booked
|
|
17
|
+
// for it), and the by-hand cost is the job's own cost of the agent's runs on its own path among the same runs (its newest
|
|
18
|
+
// PAST_RUNS on no named disk since its learning's reset), so a compile turn is never by hand: it is its revision's spend. A run
|
|
19
|
+
// whose cost is unknown is left out of its side's mean and counted, never read as 0. Over that line it stops running
|
|
20
20
|
// first: the agent takes the run, the run's journal keeps why with the two numbers (WORKFLOW_FIRST, outcome
|
|
21
21
|
// needs_revision), and the agent's cost per run shows it stopped. The stop asks for no compile. A new revision of it (a
|
|
22
22
|
// new digest: one its hold asked, or its owner's) serves again from zero. Fewer than
|
|
@@ -39,19 +39,22 @@ import { comparedOf, sameAnswer } from "../learn/promote.js";
|
|
|
39
39
|
export const WORKFLOW_FIRST = "agentrun.workflow_first";
|
|
40
40
|
/** The one call id a run's workflow-first call goes under: replay never, a crash's call is ended interrupted. */
|
|
41
41
|
export const WORKFLOW_FIRST_CALL = "workflow-first";
|
|
42
|
-
/**
|
|
42
|
+
/** No runs read: nothing to stop. */
|
|
43
|
+
export const NO_PAST_RUNS = { runs: [], by_hand: null, by_hand_unknown: 0 };
|
|
44
|
+
/** How many of the agent's newest runs on no named disk the money rule reads, both sides (store-reads/learning.ts
|
|
45
|
+
* pastRunsOf): a launch's read is bounded whatever the agent's history, and the cost page reads the same window. */
|
|
43
46
|
export const PAST_RUNS = 500;
|
|
44
47
|
const SERVED = ["workflow", "handed_back"];
|
|
45
48
|
const usd = (value) => Math.round(value * 1e6) / 1e6;
|
|
46
49
|
const meanOf = (costs) => (costs.length ? { runs: costs.length, mean_usd: usd(costs.reduce((a, b) => a + b, 0) / costs.length) } : null);
|
|
47
50
|
const pathFields = (metrics) => (isObject(metrics) ? metrics : {});
|
|
48
|
-
/** The money rule's two sides for workflow `name` at `digest`, over the agent's runs (`past`,
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
/** The money rule's two sides for workflow `name` at `digest`, over the agent's runs (`past`): `served`, the mean all-in
|
|
52
|
+
* of its newest COST_WINDOW runs served first at that digest (path workflow or handed_back) whose all-in is known (the
|
|
53
|
+
* cost page's `after` side reads the same figure); `by_hand`, as given (PastRuns: the job's own $ over the same runs,
|
|
54
|
+
* never a second baseline here); `unknown_runs`, the runs either side would have read that it left out for an unknown cost (the cost
|
|
55
|
+
* page's rule: left out and counted). */
|
|
53
56
|
export function costLineOf(past, name, digest) {
|
|
54
|
-
const newest = [...past].sort((a, b) => b.startedAt - a.startedAt);
|
|
57
|
+
const newest = [...past.runs].sort((a, b) => b.startedAt - a.startedAt);
|
|
55
58
|
const known = (run) => typeof run.allInUsd === "number" && Number.isFinite(run.allInUsd);
|
|
56
59
|
const ran = (run) => { const m = pathFields(run.metrics); return m.workflow === name && SERVED.includes(m.path); };
|
|
57
60
|
// Newest first, until COST_WINDOW known: an unknown one met before the window filled is one it left out.
|
|
@@ -65,11 +68,7 @@ export function costLineOf(past, name, digest) {
|
|
|
65
68
|
else
|
|
66
69
|
servedUnknown += 1;
|
|
67
70
|
}
|
|
68
|
-
|
|
69
|
-
const first = Math.min(...newest.filter(ran).map((run) => run.startedAt));
|
|
70
|
-
const hand = agent.some(known) ? agent : newest.filter((run) => run.startedAt < first && !SERVED.includes(pathFields(run.metrics).path) && pathFields(run.metrics).path !== "replay" && pathFields(run.metrics).path !== "audit");
|
|
71
|
-
const byHand = hand.filter(known).map((run) => run.allInUsd);
|
|
72
|
-
return { served: meanOf(served) ?? { runs: 0, mean_usd: null }, by_hand: meanOf(byHand), unknown_runs: servedUnknown + hand.length - byHand.length };
|
|
71
|
+
return { served: meanOf(served) ?? { runs: 0, mean_usd: null }, by_hand: past.by_hand, unknown_runs: servedUnknown + past.by_hand_unknown };
|
|
73
72
|
}
|
|
74
73
|
/** Whether a cost line is over the money rule's line: COST_WINDOW served runs or more at the digest, a by-hand cost to
|
|
75
74
|
* hold them to, and their mean at or over it. */
|
|
@@ -83,7 +82,7 @@ export const costStopOf = (past) => (workflow, digest) => overLine(costLineOf(pa
|
|
|
83
82
|
* `serving`, or `needs_revision` once over the line (overLine). What the agent's cost per run shows its owner. */
|
|
84
83
|
export function workflowCostsOf(past) {
|
|
85
84
|
const newest = new Map();
|
|
86
|
-
for (const run of [...past].sort((a, b) => b.startedAt - a.startedAt)) {
|
|
85
|
+
for (const run of [...past.runs].sort((a, b) => b.startedAt - a.startedAt)) {
|
|
87
86
|
const m = pathFields(run.metrics);
|
|
88
87
|
if (SERVED.includes(m.path) && typeof m.workflow === "string" && typeof m.workflow_digest === "string" && !newest.has(m.workflow))
|
|
89
88
|
newest.set(m.workflow, m.workflow_digest);
|
|
@@ -215,18 +214,23 @@ export async function workflowFirstOf(kind, workflows, launch, log, past, promot
|
|
|
215
214
|
const serve = { ...champion, serve: { name: chosen.name, digest, ...(promotion !== undefined ? { promotion } : {}), input: launch.input, revision: launch.learning.seed, ...(outputSchema !== undefined ? { outputSchema } : {}) } };
|
|
216
215
|
if (!past)
|
|
217
216
|
return serve;
|
|
218
|
-
|
|
217
|
+
// Runs it can't read stop nothing: the run is served unchecked, and the log says so.
|
|
218
|
+
const read = await past().catch((error) => {
|
|
219
|
+
log?.(`workflow-first: the money rule could not read the agent's past runs (${error instanceof Error ? error.message : String(error)}); ${chosen.name} serves this run unchecked`);
|
|
220
|
+
return NO_PAST_RUNS;
|
|
221
|
+
});
|
|
222
|
+
const line = costLineOf(read, chosen.name, digest);
|
|
219
223
|
if (line.served.runs < COST_WINDOW)
|
|
220
224
|
return serve;
|
|
221
225
|
if (line.by_hand === null) {
|
|
222
|
-
log?.(`workflow-first: no by-hand cost to hold ${chosen.name} to (no run on the agent's path
|
|
226
|
+
log?.(`workflow-first: no by-hand cost to hold ${chosen.name} to (no run of known cost on the agent's path before a learned workflow first served); it runs first`);
|
|
223
227
|
return serve;
|
|
224
228
|
}
|
|
225
229
|
if (!overLine(line))
|
|
226
230
|
return serve;
|
|
227
231
|
const revise = { workflow: chosen.name, digest, served_usd: line.served.mean_usd, by_hand_usd: line.by_hand.mean_usd, runs: line.served.runs, revision: launch.learning.seed, ...(outputSchema !== undefined ? { outputSchema } : {}) };
|
|
228
232
|
const unknown = line.unknown_runs ? ` (${line.unknown_runs} run${line.unknown_runs === 1 ? "" : "s"} of unknown cost left out)` : "";
|
|
229
|
-
log?.(`workflow-first: ${chosen.name} cost $${revise.served_usd} a run over its last ${revise.runs} served runs, at or over $${revise.by_hand_usd} by hand
|
|
233
|
+
log?.(`workflow-first: ${chosen.name} cost $${revise.served_usd} a run over its last ${revise.runs} served runs, at or over $${revise.by_hand_usd} by hand (served all-in, by hand the job's own, over the same runs)${unknown}; it does not run first until a new revision of it; the agent takes this run`);
|
|
230
234
|
return { ...champion, revise };
|
|
231
235
|
}
|
|
232
236
|
/** What a run's workflow-first step did, from its root entries (the WORKFLOW_FIRST entry): the workflow, its digest, the
|
|
@@ -275,7 +279,10 @@ export function pathMetrics(launch, classified, entries = []) {
|
|
|
275
279
|
}
|
|
276
280
|
// A served run a trigger started (learn/audit.ts auditableLaunch) is never audited: counted on the promotions read.
|
|
277
281
|
const notAuditable = SERVED_PATHS.includes(path) && !auditableLaunch(launch);
|
|
278
|
-
|
|
282
|
+
// The money rule stopped its workflow from running first (its WORKFLOW_FIRST entry asks for a revision): why it was not
|
|
283
|
+
// served, the ledger's (learn/ledger.ts record).
|
|
284
|
+
const costStop = path === "agent" && entries.some((entry) => entry.kind === WORKFLOW_FIRST && entry.data?.outcome === "needs_revision");
|
|
285
|
+
return { path, ...(launch.learning.seed ? { learned_revision: launch.learning.seed } : {}), ...(workflow ? { workflow } : {}), ...(digest ? { workflow_digest: digest } : {}), ...(promotion !== undefined ? { workflow_promotion: promotion } : {}), ...(cut && path === "handed_back" ? { workflow_cut: true } : {}), ...(notAuditable ? { not_auditable: true } : {}), ...(costStop ? { not_served: "cost_stop" } : {}), ...rows };
|
|
279
286
|
}
|
|
280
287
|
/** What run `entries` (its root's) say its learned workflow answered alone: the workflow and its answer (the model's
|
|
281
288
|
* message written just before the WORKFLOW_FIRST entry, in its commit); undefined for a run it did not answer. A follow-up that opens such a
|
|
@@ -173,7 +173,7 @@ export function workflowSpecOf(deps) {
|
|
|
173
173
|
withoutModelKeys(claimedEnv);
|
|
174
174
|
if (runKey && run?.redact)
|
|
175
175
|
holdRunKey(run.redact, runKey);
|
|
176
|
-
const providerOf = deps.providerOf ?? routeProviderOf(claimModelEnv(deps.env ?? process.env, claimedEnv, runKey, claim));
|
|
176
|
+
const providerOf = deps.providerOf ?? routeProviderOf(claimModelEnv(deps.env ?? process.env, [claimedEnv], runKey, claim));
|
|
177
177
|
// Each tier's provider and cap model, resolved once; the proxies start here (before the Harness opens, since the models
|
|
178
178
|
// catalog the Harness takes points at them), their hooks deferred to the booking wired at harnessReady.
|
|
179
179
|
const providers = new Map();
|
package/dist/server.d.ts
CHANGED
|
@@ -97,9 +97,7 @@ export type ServeOptions = {
|
|
|
97
97
|
* (the console, sign-in, setup, settings, MCP, triggers, hooks, ...) with a 404 before anything reads the request.
|
|
98
98
|
* It has no owner: accounts and open setup are off, there being no page to sign in to. */
|
|
99
99
|
apiOnly?: boolean;
|
|
100
|
-
/**
|
|
101
|
-
* (AGENTRUN_API_ONLY_MCP_ORIGINS, api-only.ts apiOnlyMcpSave), normalized as the environment's are (a bad entry
|
|
102
|
-
* stops the start). None, that save is refused as any route outside the profile's. Read only with apiOnly. */
|
|
100
|
+
/** AGENTRUN_API_ONLY_MCP_ORIGINS, read as the environment's is (the serve README's API-only section); only with apiOnly. */
|
|
103
101
|
apiOnlyMcpOrigins?: readonly string[];
|
|
104
102
|
/** The launch hook (AGENTRUN_LAUNCH_HOOK_URL and _SECRET, trigger-launch-hook.ts): each trigger firing that would start
|
|
105
103
|
* a run is handed to the host instead, which starts it through the API. None, firings start their runs here. */
|
|
@@ -181,6 +179,9 @@ export type ServeOptions = {
|
|
|
181
179
|
/** Under `faux`: a file read as this server's /proc/self/mountinfo (box-paths.ts), a container's in a test; absent (and
|
|
182
180
|
* no FAUX_MOUNTINFO_ENV), a faux server is on a host. */
|
|
183
181
|
fauxMountinfo?: string;
|
|
182
|
+
/** Under `faux`: the directory a Docker computer's computerd build is looked for in at the start (the computer
|
|
183
|
+
* package's dockerDaemonOf), in place of that package's own build; absent, a faux server doesn't check for one. */
|
|
184
|
+
fauxDaemonDir?: string;
|
|
184
185
|
/** For tests: whether Docker's start probe takes this server to be in a container (place-offers.ts containerReason),
|
|
185
186
|
* in place of its own marks; a faux server's is a host's. */
|
|
186
187
|
probeContainer?: ContainerFacts;
|
|
@@ -198,8 +199,9 @@ export type ServeOptions = {
|
|
|
198
199
|
* LISTER_IDLE_MS). `Infinity`: it builds only when Serve.listingSettled asks, so a test reads what a list builds alone. */
|
|
199
200
|
listerIdleMs?: number;
|
|
200
201
|
/** No runner beside this server in its process (the CLI's --no-runner, the image's server-and-runner): a paired
|
|
201
|
-
* computer's socket is held here
|
|
202
|
-
*
|
|
202
|
+
* computer's socket is held here while no run holds it, and relayed to the runner that holds a run of it
|
|
203
|
+
* (workspace/paired-route.ts); while no runner relays, a pairing code, the pair answer and each paired computer say no
|
|
204
|
+
* run reaches it, and what to do instead (attached-computers.ts RUNNER_APART_WORDS). */
|
|
203
205
|
runnerApart?: boolean;
|
|
204
206
|
/** For tests: the attach socket's liveness timing (computer-attach.ts AttachTiming), a relayed dial's included; the
|
|
205
207
|
* protocol's by default. */
|
|
@@ -313,6 +315,14 @@ export type Serve = {
|
|
|
313
315
|
/** The live sockets of the computers paired with this server (computer-attach.ts): a runner beside the server in this
|
|
314
316
|
* process takes it (runner/beside.ts), so its runs can use them. */
|
|
315
317
|
attachHub: AttachHub;
|
|
318
|
+
/** The name and incarnation the runner beside this server in its process runs under (runner/beside.ts), new at each
|
|
319
|
+
* start: its run's route of a paired box names them, and this server's attach routes read such a route as this hub's
|
|
320
|
+
* (computer-attach.ts beside), so the box stays here for the run and a runner apart's take for another run is
|
|
321
|
+
* refused meanwhile. */
|
|
322
|
+
beside: {
|
|
323
|
+
readonly runner: string;
|
|
324
|
+
readonly incarnation: string;
|
|
325
|
+
};
|
|
316
326
|
/** What a dial provider's create takes of this server (HostedProvider's dial): the address its machines dial
|
|
317
327
|
* (AGENTRUN_PUBLIC_URL, absent without one), the tokens it mints for them (computer-attach.ts machineTokens) and the
|
|
318
328
|
* hub their sockets land in. The runner beside the server hands it to its remote providers (runner/beside.ts). */
|
|
@@ -1104,8 +1114,9 @@ export declare const HARNESS_SIGN_IN_NOT_LOCAL = "HARNESS_SIGN_IN_NOT_LOCAL";
|
|
|
1104
1114
|
export declare function whyNotOwnMachine(options: Pick<ServeOptions, "host" | "publicUrl" | "runnerApart" | "apiOnly" | "token" | "tokens">, data: string, ownUser: boolean): string[];
|
|
1105
1115
|
/** Why `options` on `data` is not one owner's server on their own machine as far as who reaches it goes, each reason in
|
|
1106
1116
|
* words: whyNotOwnMachine's facts but its runner's. What may read this machine's own files for whoever asks (GET
|
|
1107
|
-
* /v2/wrapped).
|
|
1108
|
-
|
|
1117
|
+
* /v2/wrapped). `keys`: the live API keys made in the console (api-keys.ts), each one more caller, as a second token is
|
|
1118
|
+
* (claude-login.ts whyNotOneOwner counts them too); 0 where none can open the server. */
|
|
1119
|
+
export declare function whyNotOwnersServer(options: Pick<ServeOptions, "host" | "publicUrl" | "apiOnly" | "token" | "tokens">, data: string, keys?: number): string[];
|
|
1109
1120
|
/** Why `options` on `data` may not run a recipe on its owner's own sign-in (--harness-sign-in), in words; undefined when
|
|
1110
1121
|
* it may: one owner's own server on their own machine alone (whyNotOwnMachine). A check, a schedule and a shared server
|
|
1111
1122
|
* run on a key (HARNESS.md#sign-in). */
|