@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
|
@@ -154,8 +154,12 @@ export async function hostDecisionKeys(deps, providers) {
|
|
|
154
154
|
/** The model keys the host's models of `tiers` need (model.ts modelKeys: each one's provider's, or the gateway's), read as
|
|
155
155
|
* claimSecrets reads a run's (the runner's environment first, then the key saved in Settings → Model keys), for a run's
|
|
156
156
|
* learned workflow nodes of those tiers (adapter-run-spec.ts learnedTierRoutes): claimSecrets opens only the run's own
|
|
157
|
-
* model's. For the tiers' routes alone, through withModelKeys (never enumerable), never onto a tool's environment.
|
|
158
|
-
|
|
157
|
+
* model's. For the tiers' routes alone, through withModelKeys (never enumerable), never onto a tool's environment.
|
|
158
|
+
* `refs`: a model named for a tier in place of the host's (an agentic revision's modelTiers, for its subagent tiers:
|
|
159
|
+
* subagentTierKeys), read on the runner alone; a run's process names none. It scopes the key names alone: the ChatGPT
|
|
160
|
+
* sign-in is given for the host's models of `tiers`, as before (a revision's own model on the plan reaches the sign-in
|
|
161
|
+
* through its claim: claimSecrets reachesPlan). */
|
|
162
|
+
export async function tierModelKeys(deps, tiers, refs = {}) {
|
|
159
163
|
if (!tiers.length)
|
|
160
164
|
return {};
|
|
161
165
|
// A run's own process holds no seal key: its runner reads them, the plan's reader with them (held.ts).
|
|
@@ -166,7 +170,7 @@ export async function tierModelKeys(deps, tiers) {
|
|
|
166
170
|
}
|
|
167
171
|
const working = await workingEnv(deps);
|
|
168
172
|
const out = {};
|
|
169
|
-
for (const name of modelKeys(working, undefined, tiers))
|
|
173
|
+
for (const name of modelKeys(working, undefined, tiers, refs))
|
|
170
174
|
if (working[name] !== undefined)
|
|
171
175
|
out[name] = working[name];
|
|
172
176
|
// The ChatGPT sign-in, when a host model of those tiers is on the plan (claimSecrets gives it only to a run whose own
|
|
@@ -182,9 +186,11 @@ export const MODEL_KEY_NAMES = [...new Set([...Object.values(PROVIDER_KEYS).flat
|
|
|
182
186
|
* a claim opened from the store (claimSecrets, scoped to the run's model), or every one the server holds
|
|
183
187
|
* (savedModelKeys). So a model key saved in Settings → Model keys reaches the next run's model requests with no
|
|
184
188
|
* restart, as a tool key reaches its tools; a key set where AgentRun starts still wins (claimSecrets reads it first),
|
|
185
|
-
* and a provider the runner holds any key of gets none of its saved ones.
|
|
189
|
+
* and a provider the runner holds any key of gets none of its saved ones. Each name is read from the first of `opened`
|
|
190
|
+
* that holds it, by name, as a run's process is handed its keys (run-child-host.ts handed): a claim's model keys, never
|
|
191
|
+
* enumerable, count as any other.
|
|
186
192
|
* The keys added are never enumerable either: a spread of the result, or a spawn given it, carries none of them. */
|
|
187
|
-
export function withModelKeys(env, opened) {
|
|
193
|
+
export function withModelKeys(env, ...opened) {
|
|
188
194
|
// A provider's keys are filled together or not at all: only when the runner holds none of them. A credential handed where
|
|
189
195
|
// AgentRun started (ANTHROPIC_AUTH_TOKEN, an AWS key id) is never mixed with a saved key of the same provider, which its
|
|
190
196
|
// route would send first (ANTHROPIC_API_KEY before the token) or pair with it (another AWS name). A key held empty
|
|
@@ -193,9 +199,11 @@ export function withModelKeys(env, opened) {
|
|
|
193
199
|
for (const names of [...Object.values(PROVIDER_KEYS), [GATEWAY_KEY_ENV]]) {
|
|
194
200
|
if (names.some((name) => env[name]))
|
|
195
201
|
continue;
|
|
196
|
-
for (const name of names)
|
|
197
|
-
|
|
198
|
-
|
|
202
|
+
for (const name of names) {
|
|
203
|
+
const value = opened.map((from) => from[name]).find((held) => held);
|
|
204
|
+
if (value)
|
|
205
|
+
fill.set(name, value);
|
|
206
|
+
}
|
|
199
207
|
}
|
|
200
208
|
// Every property of `env` as it is (enumerable or not, as runEnv made it), but a name the fill replaces, so a fixed empty
|
|
201
209
|
// property is never copied in its way.
|
|
@@ -207,14 +215,22 @@ export function withModelKeys(env, opened) {
|
|
|
207
215
|
for (const [name, value] of fill)
|
|
208
216
|
Object.defineProperty(out, name, { value, enumerable: false, writable: false, configurable: false });
|
|
209
217
|
// The claim's ChatGPT sign-in (claimSecrets), else the runner's own.
|
|
210
|
-
return withPlan(out, planOf(
|
|
218
|
+
return withPlan(out, opened.map(planOf).find((plan) => plan) ?? planOf(env));
|
|
219
|
+
}
|
|
220
|
+
/** The saved model keys of the models of a run's subagent tiers (`tiers`, `refs` as subagent.ts routedSubagentTiers
|
|
221
|
+
* gives them; the revision's model of a tier over the host's): each model's provider's key, or the gateway's. None for
|
|
222
|
+
* no tier. */
|
|
223
|
+
export async function subagentTierKeys(deps, tiers, refs) {
|
|
224
|
+
if (!tiers.length)
|
|
225
|
+
return {};
|
|
226
|
+
// A run's own process holds no seal key: its runner reads them for the claim's tiers (held.ts).
|
|
227
|
+
const at = deps.sealKey ? undefined : held();
|
|
228
|
+
return at ? { ...(await at.subagentTierKeys()) } : tierModelKeys(deps, tiers, refs);
|
|
211
229
|
}
|
|
212
230
|
/** Every model key the server holds, for a model route with no revision to scope it by (an SDK run's compile turn): each
|
|
213
231
|
* by its name from `deps.env` first, then the store's sealed value, as claimSecrets reads them. */
|
|
214
232
|
export async function savedModelKeys(deps) {
|
|
215
|
-
|
|
216
|
-
const at = deps.sealKey ? undefined : held();
|
|
217
|
-
const out = at ? { ...(await at.savedModelKeys()) } : {};
|
|
233
|
+
const out = {};
|
|
218
234
|
for (const name of MODEL_KEY_NAMES) {
|
|
219
235
|
const value = deps.env?.[name] || (deps.sealKey ? await getSealedKey(deps.store, deps.sealKey, name) : undefined);
|
|
220
236
|
if (value !== undefined)
|
|
@@ -222,19 +238,6 @@ export async function savedModelKeys(deps) {
|
|
|
222
238
|
}
|
|
223
239
|
return out;
|
|
224
240
|
}
|
|
225
|
-
/** Of `saved` (savedModelKeys'), the keys a route to `model` (`provider/model-id`) reads and no other: its provider's
|
|
226
|
-
* (PROVIDER_KEYS), or through a gateway (`env`'s AGENT_MODEL_BASE_URL, as modelKeys reads it) the gateway's key alone.
|
|
227
|
-
* None for no model, or one whose provider names no key. What a runner hands a run's process for one route of its
|
|
228
|
-
* (run-child-host.ts savedModelKeys): never every key the server holds. */
|
|
229
|
-
export function routeModelKeys(saved, env, model) {
|
|
230
|
-
const out = {};
|
|
231
|
-
if (model === undefined)
|
|
232
|
-
return out;
|
|
233
|
-
for (const name of modelKeys(env, model))
|
|
234
|
-
if (saved[name] !== undefined)
|
|
235
|
-
out[name] = saved[name];
|
|
236
|
-
return out;
|
|
237
|
-
}
|
|
238
241
|
/** How many times fresh() reads a run's launch before it gives up, and the first wait between reads (doubled each time). */
|
|
239
242
|
const FRESH_TRIES = 3;
|
|
240
243
|
const FRESH_WAIT_MS = 50;
|
|
@@ -348,13 +351,13 @@ export async function claimSpendOff(deps, runKey) {
|
|
|
348
351
|
return (what) => (runKey?.everHeld() ? runKeyEndedFor(what) : keyless ? noServerKeyWords(what) : undefined);
|
|
349
352
|
}
|
|
350
353
|
/** The env a claimed run's model routes read: the run's own key alone where the claim opened one (withRunModelKey); else
|
|
351
|
-
* the runner's environment with the keys `opened` for it
|
|
352
|
-
* once a message hands it one (withRunModelKeyLater). */
|
|
354
|
+
* the runner's environment with the keys `opened` for it, each name from the first source that holds it (withModelKeys),
|
|
355
|
+
* whose gateway variables read the run's key once a message hands it one (withRunModelKeyLater). */
|
|
353
356
|
export function claimModelEnv(env, opened, runKey, claim) {
|
|
354
357
|
// The claim's run, turn and attempt, which each request on serve's gateway names (request-metadata.ts).
|
|
355
358
|
if (!runKey)
|
|
356
|
-
return withRequestMetadata(withModelKeys(env, opened), claim);
|
|
357
|
-
return withRequestMetadata(keyedAtClaim(runKey) ? withRunModelKey(env, runKey) : withRunModelKeyLater(withModelKeys(env, opened), runKey), claim);
|
|
359
|
+
return withRequestMetadata(withModelKeys(env, ...opened), claim);
|
|
360
|
+
return withRequestMetadata(keyedAtClaim(runKey) ? withRunModelKey(env, runKey) : withRunModelKeyLater(withModelKeys(env, ...opened), runKey), claim);
|
|
358
361
|
}
|
|
359
362
|
/** The decision providers' own keys (decisions.ts: Jev's TypeSafe key, OpenRouter's, Parallel's): some are also pi-ai
|
|
360
363
|
* provider names, but a run's model key never replaces them, so withoutModelKeys keeps them. */
|
|
@@ -368,8 +371,3 @@ export function withoutModelKeys(toolEnv) {
|
|
|
368
371
|
delete toolEnv[name];
|
|
369
372
|
return toolEnv;
|
|
370
373
|
}
|
|
371
|
-
/** `under` and `over` as one set of opened keys for claimModelEnv, `over`'s value winning by name: every property as it
|
|
372
|
-
* is, so a claim's model keys (claimSecrets: never enumerable), which a spread would drop, reach the route. */
|
|
373
|
-
export function keysOver(under, over) {
|
|
374
|
-
return Object.defineProperties({}, { ...Object.getOwnPropertyDescriptors(under), ...Object.getOwnPropertyDescriptors(over) });
|
|
375
|
-
}
|
|
@@ -59,7 +59,7 @@ import { isWebHostTool } from "../tool-list.js";
|
|
|
59
59
|
import { hostToolOf } from "../host-tools.js";
|
|
60
60
|
import { ASK_TOOL, askPerson } from "../tools.js";
|
|
61
61
|
import { fakedPlane } from "../web-fake.js";
|
|
62
|
-
import { claimModelEnv, claimModelKey, claimSecrets, claimSpendOff, holdRunKey, keyedAtClaim, hostDecisionKeys,
|
|
62
|
+
import { claimModelEnv, claimModelKey, claimSecrets, claimSpendOff, holdRunKey, keyedAtClaim, hostDecisionKeys, learnedDecisionKeys, tierModelKeys, underClaimed, withoutModelKeys } from "./claim-secrets.js";
|
|
63
63
|
import { claimMetering, mcpWhereHeld } from "./mcp-run.js";
|
|
64
64
|
import { held as runnerSeam, heldSignInReads } from "./held.js";
|
|
65
65
|
import { DECISION_PROVIDER_KEYS, TOOL_PLANE_ENV } from "../tool-plane.js";
|
|
@@ -79,7 +79,8 @@ import { runPathOverStore } from "../store-reads/learning.js";
|
|
|
79
79
|
import { specBuilt } from "./spec-holds.js";
|
|
80
80
|
import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
|
|
81
81
|
import { planBeforeRun, PLAN_PROVIDER } from "../chatgpt-plan.js";
|
|
82
|
-
import { CLAUDE_LOGIN_PROVIDER, loginBeforeRun, loginCli, loginForRun, withClaudeLogin } from "../claude-login.js";
|
|
82
|
+
import { CLAUDE_LOGIN_PROVIDER, loginBeforeRun, loginByToken, loginCli, loginForRun, withClaudeLogin } from "../claude-login.js";
|
|
83
|
+
import { heldTokenLogin } from "../claude-login-token.js";
|
|
83
84
|
import { heldSpecOf } from "./held-run.js";
|
|
84
85
|
import { loopComputerOf } from "./computer-channel.js";
|
|
85
86
|
import { githubAppAccess } from "./github-app.js";
|
|
@@ -176,7 +177,7 @@ export async function cliCapModel(entry, env, ref) {
|
|
|
176
177
|
export function cliRunEnv(env, data, claimed = {}, plane, runKey, claim) {
|
|
177
178
|
// A run with its own model key: that key alone, in the variables its route sends (claimModelEnv, never enumerable), and
|
|
178
179
|
// the claim's request metadata beside it (request-metadata.ts, never enumerable either).
|
|
179
|
-
const out = claimModelEnv(env ?? {}, claimed, runKey, claim);
|
|
180
|
+
const out = claimModelEnv(env ?? {}, [claimed], runKey, claim);
|
|
180
181
|
Object.defineProperty(out, DATA_ENV, { value: data, enumerable: true, writable: true, configurable: true });
|
|
181
182
|
delete out[TOOL_PLANE_ENV];
|
|
182
183
|
if (plane && Object.keys(plane).length)
|
|
@@ -359,7 +360,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
359
360
|
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors.
|
|
360
361
|
const hold = (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
361
362
|
redact.hold(values); };
|
|
362
|
-
const mcp = await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => runFolder(deps.data, runRow.agentId, claim.runId), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps,
|
|
363
|
+
const mcp = await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => runFolder(deps.data, runRow.agentId, claim.runId), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, web, launch) });
|
|
363
364
|
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
364
365
|
holds.hold({ passed: mcp });
|
|
365
366
|
// The run's mode is the server's: Mode 2 where its Archil settings are saved (archil-settings.ts), the run's folder then
|
|
@@ -489,8 +490,14 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
489
490
|
}
|
|
490
491
|
// Claude Code's login on this machine, where the owner turned it on for claude-agent here (claude-login.ts): the run
|
|
491
492
|
// carries only where it is, and its CLI says it is signed in before the run starts. A run that brought its own key
|
|
492
|
-
// runs on that key, and a run in a sandbox place on the model keys.
|
|
493
|
-
|
|
493
|
+
// runs on that key, and a run in a sandbox place on the model keys. A run's own process (a user of its own, which
|
|
494
|
+
// cannot open the login's folder) goes on its runner's reader of the login's access token alone (held.ts claudeLogin),
|
|
495
|
+
// each token it hands held by the redactors and this process's own; its CLI then never gets a refresh token. Whether
|
|
496
|
+
// such a claim goes on the login at all is its runner's answer alone (none: it does not): the setting names the
|
|
497
|
+
// machine by the id in the server's data folder (claude-login.ts machineId), which the run's user can neither read nor
|
|
498
|
+
// make there.
|
|
499
|
+
const handed = keyed || deps.sealKey ? undefined : await runnerSeam()?.claudeLogin();
|
|
500
|
+
const login = keyed ? undefined : handed ? heldTokenLogin(handed, hold) : deps.sealKey ? await loginForRun(deps.store.settings, deps.data, deps.env ?? {}, name, launch.place) : undefined;
|
|
494
501
|
const env = withClaudeLogin(cliRunEnv(deps.env, deps.data, claimed, launch.plane, runKey, claim), login);
|
|
495
502
|
// A plan-billed recipe's keys saved for its harness alone (harness-keys.ts), opened at each claim for this run's harness
|
|
496
503
|
// and no other (a run's own process asks its runner, which opens its claim's own: held.ts harnessKeys), held by the
|
|
@@ -530,8 +537,13 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
530
537
|
if (heldRefusal === undefined) {
|
|
531
538
|
await planBeforeRun(env, chosen.model);
|
|
532
539
|
if (login && entry.priceModel(env, chosen.model).provider === CLAUDE_LOGIN_PROVIDER) {
|
|
533
|
-
|
|
534
|
-
|
|
540
|
+
// On a token: one read before the run, refused in its words (signed out, near its end) as the CLI's own check is.
|
|
541
|
+
if (loginByToken(login))
|
|
542
|
+
await login.token();
|
|
543
|
+
else {
|
|
544
|
+
const claude = await import("@parcha/agentrun-harness-claude");
|
|
545
|
+
await loginBeforeRun(login, loginCli(claudeCliIn(installDirOf(deps.data, name), claude.claudeAgentPlatform()), env), (cli, at) => claude.claudeLoginStatus(cli, at, env.PATH ? { path: env.PATH } : {}), { data: deps.data });
|
|
546
|
+
}
|
|
535
547
|
}
|
|
536
548
|
}
|
|
537
549
|
// The CLI's own process (the Claude CLI, Codex, OpenCode) starts under the no_new_privs pi's commands start under
|
|
@@ -727,7 +739,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
727
739
|
const tierKeys = keyed ? {} : await tierModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, learnedTiers(workflows));
|
|
728
740
|
for (const redact of new Set([held, cut]))
|
|
729
741
|
holdClaimed(redact, tierKeys);
|
|
730
|
-
const modelEnv = claimModelEnv(deps.env,
|
|
742
|
+
const modelEnv = claimModelEnv(deps.env, [tierKeys, claimed], runKey, claim);
|
|
731
743
|
const tiers = new Map();
|
|
732
744
|
for (const [tier, routed] of await learnedTierRoutes(workflows, modelEnv, (tier) => deps.routeOf(undefined, modelEnv, tier, PI_WIRES, undefined, cut))) {
|
|
733
745
|
if ("why" in routed)
|
package/dist/runner/held.d.ts
CHANGED
|
@@ -62,6 +62,17 @@ export interface Held {
|
|
|
62
62
|
projectCheckpoint(signal?: AbortSignal): Promise<ProjectCheckpoint>;
|
|
63
63
|
/** The ChatGPT sign-in's reader (chatgpt-plan.ts planReaderOf), for a run whose models reach the plan; else none. */
|
|
64
64
|
plan(): Promise<PlanReader | undefined>;
|
|
65
|
+
/** Claude Code's login on this machine, for a claim of a run that goes on it (claude-login.ts loginForRun, the
|
|
66
|
+
* claim's own harness and place, and no model key of its own): its access token alone, read by the runner at each ask
|
|
67
|
+
* and renewed by it when near its end (claude-login-token.ts LoginTokens), which throws in words where there is none
|
|
68
|
+
* to hand; `refused(sent)` tells the runner Anthropic refused `sent` (the CLI's 401), so the next ask renews it. Else
|
|
69
|
+
* none, and the claim does not go on the login: the one answer to that, since the process can read neither the
|
|
70
|
+
* setting's machine id nor the login's folder. A claim on a login other than AgentRun's own folder is refused
|
|
71
|
+
* (LOGIN_NOT_HANDED). */
|
|
72
|
+
claudeLogin(): Promise<{
|
|
73
|
+
token(): Promise<string>;
|
|
74
|
+
refused(sent: string): Promise<void>;
|
|
75
|
+
} | undefined>;
|
|
65
76
|
/** Whether a browser sign-in handed to the run reads back here (sign-ins-store.ts handedSignInReadsBack). */
|
|
66
77
|
signInReadsBack(): Promise<boolean>;
|
|
67
78
|
/** The run's browser sign-in for vendor `resolution` (sign-ins-store.ts runSignIn). */
|
|
@@ -74,10 +85,11 @@ export interface Held {
|
|
|
74
85
|
* out and its launch's payload names the pull request. Its mint makes a token of that repository alone, contents
|
|
75
86
|
* read, whatever the process names; its MCP mints on the runner (mcp). */
|
|
76
87
|
githubAppAccess(): Promise<GithubAppAccessAt | undefined>;
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
/** The saved model keys of the models of the claim's subagent tiers (claim-secrets.ts subagentTierKeys asks): an agentic
|
|
89
|
+
* run granted the subagent tool gets its routed tiers' keys; a replay's or an audit's grader, its fast tier's key alone
|
|
90
|
+
* (none when its revision names agree_on or routes no fast tier). None to any other run, to one that holds a model key
|
|
91
|
+
* of its own, or to a held run its model kept from running. */
|
|
92
|
+
subagentTierKeys(): Promise<Record<string, string>>;
|
|
81
93
|
/** The model keys the host's models of `tiers` need (claim-secrets.ts tierModelKeys), the plan's reader with them: of
|
|
82
94
|
* the tiers the claim's learned workflows name, as the runner chose them (learnedFirst), alone. */
|
|
83
95
|
tierModelKeys(tiers: readonly Tier[]): Promise<{
|
package/dist/runner/main.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type HostedDial } from "@parcha/agentrun-computer";
|
|
2
|
+
import type { PairedRelay } from "../workspace/attached-computers.js";
|
|
2
3
|
import { type Store } from "../store/index.js";
|
|
3
4
|
import { type KeyEnv } from "../key-meta.js";
|
|
4
5
|
import { type ComputerDeps, type ComputerDepsOptions } from "../workspace/computer-deps.js";
|
|
@@ -22,8 +23,9 @@ export interface RunnerProcessOptions {
|
|
|
22
23
|
/** This runner's name in the runs it claims, its lines and its heartbeat. Default runner.ts runnerName(). */
|
|
23
24
|
name?: string;
|
|
24
25
|
/** Each claimed run's loop; default the runner's dispatch over the store (runnerLoop), with the computers it composed.
|
|
25
|
-
* A factory of the store is given the runner's dial too, where it has a relay
|
|
26
|
-
|
|
26
|
+
* A factory of the store is given the runner's dial and its paired computers' relay too, where it has a relay
|
|
27
|
+
* (dial-relay.ts). */
|
|
28
|
+
createLoop?: LoopFactory | StoreFactory;
|
|
27
29
|
/** Run the computer janitor (workspace/computer-janitor.ts) over the computers createLoop composed: at the start, then
|
|
28
30
|
* on its interval. Only the runner subcommand asks for it; a test that does not ask runs none. */
|
|
29
31
|
janitor?: boolean;
|
|
@@ -81,7 +83,7 @@ export declare function runEnv(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
|
81
83
|
* provider loader in place of the computer package's. Under --faux (the runs' environment names the faux model, as a
|
|
82
84
|
* --faux server's and a `runner --faux` give it), --faux's computers are beside them, as the server's start check
|
|
83
85
|
* reads them (server.ts computerReady): a run on the faux desktop is claimed, and its live view opened, the real way. */
|
|
84
|
-
export declare const runnerComputers: (store: Store, env: KeyEnv, sealKey: Buffer, own?: Pick<ComputerDepsOptions, "kinds" | "load" | "dockerPaths" | "hostAddresses" | "hostWhy" | "hub" | "dial">) => {
|
|
86
|
+
export declare const runnerComputers: (store: Store, env: KeyEnv, sealKey: Buffer, own?: Pick<ComputerDepsOptions, "kinds" | "load" | "dockerPaths" | "hostAddresses" | "hostWhy" | "hub" | "dial" | "pairedRelay">) => {
|
|
85
87
|
computerForClaim: typeof import("../workspace/computer-deps.js").claimComputer;
|
|
86
88
|
computerDeps: ComputerDeps;
|
|
87
89
|
factories: import("../computer-keys.js").ProviderFactories;
|
|
@@ -96,7 +98,7 @@ export declare function besideRunEnv(env: NodeJS.ProcessEnv, switches: NodeJS.Pr
|
|
|
96
98
|
* its launch (harness-loops.ts resolveRunnerLoop), with the data directory, the run environment (runEnv), the store's
|
|
97
99
|
* journal, the seal key and the model route. `booted`: the seal key startRunnerProcess booted against the store (else
|
|
98
100
|
* this process's, as it was handed or booted). Refused in words with no seal key. */
|
|
99
|
-
export declare function runnerLoop(store: Store, dataDir: string, env?: NodeJS.ProcessEnv, booted?: Buffer, isolation?: RunIsolation, dial?: HostedDial): RunnerParts;
|
|
101
|
+
export declare function runnerLoop(store: Store, dataDir: string, env?: NodeJS.ProcessEnv, booted?: Buffer, isolation?: RunIsolation, dial?: HostedDial, paired?: PairedRelay): RunnerParts;
|
|
100
102
|
/** What a runner in its own process may reach on loopback, from its own environment alone, as a server takes its opt-in
|
|
101
103
|
* (cli.ts mcpLoopback): with AGENTRUN_MCP_ALLOW_LOOPBACK=1, an MCP server on this machine's loopback (the machine this
|
|
102
104
|
* process runs on, its container's in a container), never at `own`: the port a server listens on unless --port says
|
|
@@ -129,8 +131,11 @@ export declare function checkRunner(options: {
|
|
|
129
131
|
};
|
|
130
132
|
/** Opens the store as a runner and starts claiming runs. */
|
|
131
133
|
export declare function startRunnerProcess(options: RunnerProcessOptions): Promise<RunnerProcess>;
|
|
132
|
-
/**
|
|
133
|
-
|
|
134
|
+
/** A function of the store: startRunnerProcess gives it the store it opens, and its relay's dial and paired computers'
|
|
135
|
+
* relay where it has a relay. */
|
|
136
|
+
type StoreFactory = (store: Store, sealKey: Buffer, dial?: HostedDial, paired?: PairedRelay) => LoopFactory | RunnerParts;
|
|
137
|
+
/** Marks `make` as a function of the store (StoreFactory). */
|
|
138
|
+
export declare function ofStore<Made extends LoopFactory | RunnerParts>(make: (store: Store, sealKey: Buffer, dial?: HostedDial, paired?: PairedRelay) => Made): (store: Store, sealKey: Buffer, dial?: HostedDial, paired?: PairedRelay) => Made;
|
|
134
139
|
/** How long a runner process lets each busy run finish its turn on SIGTERM, unless --drain-timeout or
|
|
135
140
|
* AGENTRUN_DRAIN_TIMEOUT says: the image's server drain (its CMD's --drain-timeout 6s), so a runner beside a --no-runner
|
|
136
141
|
* server drains as the server's own runner would.
|
package/dist/runner/main.js
CHANGED
|
@@ -50,6 +50,7 @@ import { computerDepsFrom } from "../workspace/computer-deps.js";
|
|
|
50
50
|
import { startJanitor } from "../workspace/computer-janitor.js";
|
|
51
51
|
import { projectRunEnded } from "../source-sync/checkpoints.js";
|
|
52
52
|
import { runEndComputers } from "../workspace/run-end-computers.js";
|
|
53
|
+
import { sayLoginRunner } from "../claude-login-token.js";
|
|
53
54
|
import { createDispatchLoop } from "./dispatch.js";
|
|
54
55
|
import { resolveRunnerLoop } from "./harness-loops.js";
|
|
55
56
|
import { routeOf } from "./model-route.js";
|
|
@@ -144,7 +145,7 @@ export function besideRunEnv(env, switches) {
|
|
|
144
145
|
* its launch (harness-loops.ts resolveRunnerLoop), with the data directory, the run environment (runEnv), the store's
|
|
145
146
|
* journal, the seal key and the model route. `booted`: the seal key startRunnerProcess booted against the store (else
|
|
146
147
|
* this process's, as it was handed or booted). Refused in words with no seal key. */
|
|
147
|
-
export function runnerLoop(store, dataDir, env = process.env, booted, isolation, dial) {
|
|
148
|
+
export function runnerLoop(store, dataDir, env = process.env, booted, isolation, dial, paired) {
|
|
148
149
|
const sealKey = booted ?? sealKeyOf(secret(SEAL_KEY_ENV) ?? env[SEAL_KEY_ENV]);
|
|
149
150
|
if (!sealKey)
|
|
150
151
|
throw new RunnerRefused(`A runner needs the server's seal key (${SEAL_KEY_ENV}): start it through the server's launcher, which hands it over.`);
|
|
@@ -153,8 +154,9 @@ export function runnerLoop(store, dataDir, env = process.env, booted, isolation,
|
|
|
153
154
|
// agent's setting, its keys read from the run environment first, then the store's sealed rows; a Docker computer's
|
|
154
155
|
// mounts by where this process's Docker has the data directory (box-paths.ts), read once; a desktop's or a phone's live
|
|
155
156
|
// view opened with it. A machine that dials goes to this runner's own hub, through the server's relay (`dial`, its
|
|
156
|
-
// relay's: dial-relay.ts); with none, its provider refuses.
|
|
157
|
-
|
|
157
|
+
// relay's: dial-relay.ts); with none, its provider refuses. A paired computer is brought onto that same hub for the run
|
|
158
|
+
// (`paired`, the relay's); with none, it is refused in words.
|
|
159
|
+
const computers = runnerComputers(store, runs, sealKey, { dockerPaths: () => dockerPathsForRuns(runs, dataDir), hostAddresses: () => hostAddressesOnce(runs), hostWhy: hostCommandRefusals(PROVIDERS, process.env.PATH), ...(dial ? { dial } : {}), ...(paired ? { pairedRelay: paired } : {}) });
|
|
158
160
|
const loopback = runnerLoopback(env);
|
|
159
161
|
// The operator's bound on owner-allowed private hosts (mcp-private-hosts.ts), read by every dial this runner and its
|
|
160
162
|
// runs' processes make (they inherit it, runEnv): said at the start when it narrows the owner's list.
|
|
@@ -265,9 +267,9 @@ export async function startRunnerProcess(options) {
|
|
|
265
267
|
// Its relay (dial-relay.ts), where its environment names the server's public address: a machine that dials the
|
|
266
268
|
// server lands in this runner's hub, through the server. Its log lines are the runner's warnings.
|
|
267
269
|
relay = await startRunnerRelay({ store, sealKey: seal.key, runner: name, presence, env, log: warn });
|
|
268
|
-
const made = options.createLoop ?? ofStore((opened, sealKey, dial) => runnerLoop(opened, options.dataDir, undefined, sealKey, undefined, dial));
|
|
270
|
+
const made = options.createLoop ?? ofStore((opened, sealKey, dial, paired) => runnerLoop(opened, options.dataDir, undefined, sealKey, undefined, dial, paired));
|
|
269
271
|
// A factory of the store (marked by ofStore) is given the store; a loop factory is used as is.
|
|
270
|
-
const parts = isStoreFactory(made) ? made(store, seal.key, relay?.dial) : made;
|
|
272
|
+
const parts = isStoreFactory(made) ? made(store, seal.key, relay?.dial, relay?.paired) : made;
|
|
271
273
|
const createLoop = typeof parts === "function" ? parts : parts.createLoop;
|
|
272
274
|
// The janitor sweeps with the computers the loop composed, never a second composition. Its lines are the runner's
|
|
273
275
|
// warnings, said where the runner says its others (warn: stderr unless a test gives its own).
|
|
@@ -376,7 +378,7 @@ function watchFloor(store, known, everyMs) {
|
|
|
376
378
|
};
|
|
377
379
|
}
|
|
378
380
|
const storeFactories = new WeakSet();
|
|
379
|
-
/** Marks `make` as a function of the store (
|
|
381
|
+
/** Marks `make` as a function of the store (StoreFactory). */
|
|
380
382
|
export function ofStore(make) {
|
|
381
383
|
storeFactories.add(make);
|
|
382
384
|
return make;
|
|
@@ -635,6 +637,9 @@ export async function runnerMain(argv, given = process.env, hooks = {}) {
|
|
|
635
637
|
holds = { ...holds, loops: isolationLoops(isolation, holds.loops) };
|
|
636
638
|
let started;
|
|
637
639
|
const runnerOf = name ?? runnerName();
|
|
640
|
+
// Said on the data folder before it claims: whether its runs on Claude Code's login stay in this process, its CLI on
|
|
641
|
+
// the login's folder (claude-login-token.ts sayLoginRunner), for a runner whose runs are users of their own to read.
|
|
642
|
+
sayLoginRunner(args.dataDir, runnerOf, isolation.kind === "uid" ? "uid" : "process");
|
|
638
643
|
// The last resort, in this process only (never the library, the server's CLI or the runner beside a server): an error
|
|
639
644
|
// nothing handled is said with its stack, and the process exits 1 at once (lastResort: crashing is the safe failure).
|
|
640
645
|
const fatal = lastResort(runnerOf);
|
|
@@ -661,7 +666,7 @@ export async function runnerMain(argv, given = process.env, hooks = {}) {
|
|
|
661
666
|
drainMs: holds.drainMs,
|
|
662
667
|
// Each run a process of its own (`isolation`); its computer, with this runner's relay's dial, held here in the
|
|
663
668
|
// runner, which the run's process asks for it over its channel (run-child-host.ts, held.ts computer).
|
|
664
|
-
createLoop: ofStore((store, sealKey, dial) => runnerLoop(store, args.dataDir, env, sealKey, isolation, dial)),
|
|
669
|
+
createLoop: ofStore((store, sealKey, dial, paired) => runnerLoop(store, args.dataDir, env, sealKey, isolation, dial, paired)),
|
|
665
670
|
// Each run's own process weighed beside its harness's run (memory-claim.ts RUN_PROCESS_MIB).
|
|
666
671
|
processMib: RUN_PROCESS_MIB,
|
|
667
672
|
// The runner subcommand ends what a crashed runner of this server left (never under --faux).
|
package/dist/runner/mcp-claim.js
CHANGED
|
@@ -443,8 +443,9 @@ export async function mcpClaim(options) {
|
|
|
443
443
|
// The list is read first: with none held (a full server's store) the row is not read, and nothing is refused.
|
|
444
444
|
let listMoved = false;
|
|
445
445
|
if (stamp.auth === "per_run") {
|
|
446
|
-
const
|
|
447
|
-
|
|
446
|
+
const held = await heldApiOnlyMcpOrigins(store);
|
|
447
|
+
const row = held ? await getMcpServer(store, name) : undefined;
|
|
448
|
+
listMoved = (row !== undefined && (await offApiOnlyMcpOrigins(store, name, row, held)) !== undefined) !== offList.has(name);
|
|
448
449
|
if (released)
|
|
449
450
|
return;
|
|
450
451
|
}
|
package/dist/runner/mcp-run.d.ts
CHANGED
|
@@ -75,15 +75,12 @@ export interface McpForClaimOptions {
|
|
|
75
75
|
readonly hold?: (values: string[]) => void;
|
|
76
76
|
}
|
|
77
77
|
/** What a spec builder gives a claim's MCP for its metered jobs (`capped` and `media`), the same for every builder:
|
|
78
|
-
* whether its launch has a cap, and where a job's input media are read from: the
|
|
79
|
-
* builder's `env`, in web_save's slots. */
|
|
78
|
+
* whether its launch has a cap, and where a job's input media are read from: the run's eval web fake (`web`, as its
|
|
79
|
+
* builder read the run's fakes, once), else the builder's `env`, in web_save's slots. */
|
|
80
80
|
export declare function claimMetering(deps: {
|
|
81
81
|
readonly env: NodeJS.ProcessEnv;
|
|
82
|
-
readonly evalFakes?: (agentId: string) => {
|
|
83
|
-
readonly web?: WebFake;
|
|
84
|
-
} | undefined;
|
|
85
82
|
readonly saveSlots?: SaveSlots;
|
|
86
|
-
},
|
|
83
|
+
}, web: WebFake | undefined, launch: {
|
|
87
84
|
readonly maxCostUsd?: number | undefined;
|
|
88
85
|
}): Pick<McpForClaimOptions, "capped" | "media">;
|
|
89
86
|
/** A claim's MCP (AdapterRunSpec.mcp): what the loop reaches the gateway by, and the claim step's own hooks. */
|
package/dist/runner/mcp-run.js
CHANGED
|
@@ -14,10 +14,9 @@ import { registryListing } from "../mcp-pin-first.js";
|
|
|
14
14
|
import { heldOrThrow } from "./held.js";
|
|
15
15
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
16
16
|
/** What a spec builder gives a claim's MCP for its metered jobs (`capped` and `media`), the same for every builder:
|
|
17
|
-
* whether its launch has a cap, and where a job's input media are read from: the
|
|
18
|
-
* builder's `env`, in web_save's slots. */
|
|
19
|
-
export function claimMetering(deps,
|
|
20
|
-
const web = deps.evalFakes?.(agentId)?.web;
|
|
17
|
+
* whether its launch has a cap, and where a job's input media are read from: the run's eval web fake (`web`, as its
|
|
18
|
+
* builder read the run's fakes, once), else the builder's `env`, in web_save's slots. */
|
|
19
|
+
export function claimMetering(deps, web, launch) {
|
|
21
20
|
return { capped: launch.maxCostUsd !== undefined, media: { env: deps.env, ...(web ? { web } : {}), ...(deps.saveSlots ? { slots: deps.saveSlots } : {}) } };
|
|
22
21
|
}
|
|
23
22
|
/** The wire names a subagent's `grant` gives of the run's MCP and monid tools, by the gate's keys; else the grant's own. */
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import { type Runners } from "../store/store.js";
|
|
1
|
+
import { type RunnerRow, type Runners } from "../store/store.js";
|
|
2
2
|
/** How often a runner says again that it is there. */
|
|
3
3
|
export declare const PRESENCE_RENEW_MS = 10000;
|
|
4
4
|
/** How old a runner's word can be and still count: three renewals missed. The store's (RUNNER_STALE_MS), which its claim
|
|
5
5
|
* rule reads for a kept computer's pin. */
|
|
6
6
|
export declare const PRESENCE_STALE_MS = 30000;
|
|
7
|
+
/** A runner's row that says where its relay answers. */
|
|
8
|
+
export type RelayRow = RunnerRow & {
|
|
9
|
+
readonly host: string;
|
|
10
|
+
readonly port: number;
|
|
11
|
+
};
|
|
12
|
+
/** The runners whose relay takes dials now: their rows seen within PRESENCE_STALE_MS on the store's clock (Runners.live,
|
|
13
|
+
* the database's on Postgres), never one process's, that say where their relay answers. The server relays a dial only
|
|
14
|
+
* to one of these (computer-attach.ts), says a dial provider is served while one answers at a host it dials (server.ts
|
|
15
|
+
* relayed), and a paired computer's route to a runner not among them is stale (workspace/paired-route.ts). */
|
|
16
|
+
export declare function liveRelays(runners: Pick<Runners, "live">): Promise<RelayRow[]>;
|
|
7
17
|
/** This build's version (the serve package's), which every runner says on its row (runners.version) for the server's
|
|
8
18
|
* capacity read (GET /v2/capacity). */
|
|
9
19
|
export declare const RUNNER_VERSION: string;
|
package/dist/runner/presence.js
CHANGED
|
@@ -18,6 +18,13 @@ export const PRESENCE_RENEW_MS = 10_000;
|
|
|
18
18
|
/** How old a runner's word can be and still count: three renewals missed. The store's (RUNNER_STALE_MS), which its claim
|
|
19
19
|
* rule reads for a kept computer's pin. */
|
|
20
20
|
export const PRESENCE_STALE_MS = RUNNER_STALE_MS;
|
|
21
|
+
/** The runners whose relay takes dials now: their rows seen within PRESENCE_STALE_MS on the store's clock (Runners.live,
|
|
22
|
+
* the database's on Postgres), never one process's, that say where their relay answers. The server relays a dial only
|
|
23
|
+
* to one of these (computer-attach.ts), says a dial provider is served while one answers at a host it dials (server.ts
|
|
24
|
+
* relayed), and a paired computer's route to a runner not among them is stale (workspace/paired-route.ts). */
|
|
25
|
+
export async function liveRelays(runners) {
|
|
26
|
+
return (await runners.live(PRESENCE_STALE_MS)).filter((row) => row.host !== null && row.port !== null);
|
|
27
|
+
}
|
|
21
28
|
/** This build's version (the serve package's), which every runner says on its row (runners.version) for the server's
|
|
22
29
|
* capacity read (GET /v2/capacity). */
|
|
23
30
|
export const RUNNER_VERSION = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8")).version;
|
|
@@ -47,7 +47,7 @@ export function createReflectHook(deps) {
|
|
|
47
47
|
// What the step's model turns cost: the run's spend once it closed less the job's, unknown when either is. Kept with
|
|
48
48
|
// every end once a compile turn was asked; 0 for an end that asked none. The step's only model turn is its compile
|
|
49
49
|
// turn, so this is the compile's spend: it joins the revision it drafts, or the bill's unattributed when it kept no
|
|
50
|
-
// draft (
|
|
50
|
+
// draft (learn/ledger.ts record and summarize), never the run's own.
|
|
51
51
|
let asked = begun;
|
|
52
52
|
const spent = async () => {
|
|
53
53
|
if (!asked)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Duplex } from "node:stream";
|
|
2
|
+
import { type HeldRedact, type Redact } from "./redact.js";
|
|
2
3
|
import type { Workspace } from "../workspace/workspace.js";
|
|
3
4
|
import { type AdapterSpecDeps } from "./adapter-run-spec.js";
|
|
4
5
|
import type { Held } from "./held.js";
|
|
@@ -120,12 +121,15 @@ interface ClaimReads {
|
|
|
120
121
|
/** The runner's presence incarnation (LoopDeps.incarnation): with the claim's runner, who keeps a computer a park pins. */
|
|
121
122
|
readonly incarnation?: string;
|
|
122
123
|
}
|
|
124
|
+
/** The runner's redactor as the host side of a run's process holds it (LoopDeps.redact): its cut, and the carry of a
|
|
125
|
+
* value into what it cuts from the run's journal, which a token the runner hands the run needs (claudeLogin). */
|
|
126
|
+
export type RunnerCut = Redact & Partial<Pick<HeldRedact, "carry">>;
|
|
123
127
|
/** Held (held.ts) for one claim, on the runner: each answer the claim's own, read with the runner's seal key from the
|
|
124
128
|
* runner's own reads of the claim; every argument from the run's process is checked or ignored. `bigs`: the run's pieced
|
|
125
129
|
* writes (big-writes.ts), let go at the claim's release and, by the caller, when the run's channel ends. */
|
|
126
130
|
export declare function heldFor(deps: AdapterSpecDeps & {
|
|
127
131
|
readonly sealKey: Buffer;
|
|
128
|
-
}, reads: ClaimReads, cut:
|
|
132
|
+
}, reads: ClaimReads, cut: RunnerCut, log: (line: string) => void, bigs?: RunBigWrites): {
|
|
129
133
|
held: Held;
|
|
130
134
|
inputs(): Promise<void>;
|
|
131
135
|
release(): Promise<void>;
|
|
@@ -158,19 +162,26 @@ export declare const childArgv: () => string[];
|
|
|
158
162
|
* A native run (launch.native): its agent is the source machine's own sign-in, reached through the server's
|
|
159
163
|
* connectors, whose rows are the server's. */
|
|
160
164
|
export declare const runsInRunner: (harness: string, launch: Pick<RunLaunch, "sdk" | "native" | "cli_learning">) => boolean;
|
|
161
|
-
/** The words a run on
|
|
162
|
-
|
|
165
|
+
/** The words a run on this machine's own Claude Code login (the `machine` place: claude-login.ts machineFolder, ~/.claude
|
|
166
|
+
* 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
|
|
167
|
+
* is handed to such a run, as its access token. */
|
|
168
|
+
export declare 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 \u2192 Model keys, set AGENTRUN_RUN_USER=same, or give the run a model_key.";
|
|
169
|
+
/** 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
|
|
170
|
+
* folder, runs its runs on the login in its own process, whose CLI renews the login in that folder itself. */
|
|
171
|
+
export declare const loginRunnerInProcessWords: (other: string) => string;
|
|
163
172
|
/** The words a run on a harness recipe is refused in where each run is a user of its own (harness-table.ts recipeHarness). */
|
|
164
173
|
export declare 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 AGENTRUN_RUN_USER=same on this runner.";
|
|
165
174
|
export { RECIPE_SIGN_IN_PERSON_ONLY } from "./harness-loops.js";
|
|
166
175
|
/** Whether run `runId` stays in its runner's process: runsInRunner's, and a workflow run on a server with a documents
|
|
167
176
|
* directory (launch.documents), whose reads and writes (a pdf_pages call's pages) are rooted in a folder the server's
|
|
168
177
|
* 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
|
|
169
|
-
* Code's login on this machine (claude-login.ts loginForRun)
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* the
|
|
173
|
-
*
|
|
178
|
+
* Code's login on this machine (claude-login.ts loginForRun), where runs are the runner's own user (`process`), stays in
|
|
179
|
+
* 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
|
|
180
|
+
* folder is a process of its own handed the login's access token alone (held.ts claudeLogin, claude-login-token.ts),
|
|
181
|
+
* never the folder; it is refused at its claim (ClaimRefused, in words) on this machine's own login (machineFolder), and
|
|
182
|
+
* while a `process` runner on the same data folder is live (its CLI renews the folder's login itself). A run its caller
|
|
183
|
+
* 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
|
|
184
|
+
* own like any other. */
|
|
174
185
|
export declare function staysInRunner(deps: Pick<AdapterSpecDeps, "store" | "data" | "env" | "sealKey">, harness: string, launch: RunLaunch, runId: string, isolation: RunIsolation): Promise<boolean>;
|
|
175
186
|
/** 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
|
|
176
187
|
* the runner (staysInRunner). */
|