@parcha/agentrun-serve 0.1.0-beta.40 → 0.1.0-beta.42
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 +130 -0
- package/NOTICE +2 -0
- package/README.md +149 -21
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.js +3 -1
- package/dist/api-only.d.ts +3 -1
- package/dist/api-only.js +4 -2
- package/dist/api-token.d.ts +30 -0
- package/dist/api-token.js +89 -0
- package/dist/calendar/address.d.ts +49 -0
- package/dist/calendar/address.js +153 -0
- package/dist/calendar/fetch.d.ts +24 -0
- package/dist/calendar/fetch.js +146 -0
- package/dist/calendar/ics-faux.d.ts +39 -0
- package/dist/calendar/ics-faux.js +236 -0
- package/dist/calendar/labels.d.ts +3 -0
- package/dist/calendar/labels.js +61 -0
- package/dist/calendar/names.d.ts +52 -0
- package/dist/calendar/names.js +54 -0
- package/dist/calendar/parse.d.ts +108 -0
- package/dist/calendar/parse.js +625 -0
- package/dist/calendar/routes.d.ts +17 -0
- package/dist/calendar/routes.js +81 -0
- package/dist/calendar/tools.d.ts +23 -0
- package/dist/calendar/tools.js +124 -0
- package/dist/cli.js +22 -6
- package/dist/composio-made.d.ts +54 -0
- package/dist/composio-made.js +83 -0
- package/dist/composio-preset.d.ts +16 -8
- package/dist/composio-preset.js +106 -43
- package/dist/composio-triggers.d.ts +7 -2
- package/dist/composio-triggers.js +13 -7
- package/dist/computer-attach.d.ts +29 -11
- package/dist/computer-attach.js +141 -47
- package/dist/computer-keys.d.ts +4 -0
- package/dist/computer-keys.js +5 -0
- package/dist/computer-record.d.ts +55 -0
- package/dist/computer-record.js +315 -0
- package/dist/computer-setting.d.ts +1 -0
- package/dist/computer-setting.js +15 -2
- package/dist/computers.d.ts +11 -1
- package/dist/computers.js +23 -26
- package/dist/console/assets/{index-B8Zn1Iqn.css → index-C3gNPz58.css} +1 -1
- package/dist/console/assets/index-DYJ_wj27.js +711 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.js +9 -2
- package/dist/eval-feed.d.ts +26 -0
- package/dist/eval-feed.js +72 -0
- package/dist/eval-mailbox.d.ts +4 -1
- package/dist/eval-mailbox.js +11 -3
- package/dist/exa-keyless.d.ts +1 -1
- package/dist/exa-keyless.js +1 -1
- package/dist/feed/feed-faux.d.ts +62 -0
- package/dist/feed/feed-faux.js +123 -0
- package/dist/feed/fetch.d.ts +41 -0
- package/dist/feed/fetch.js +128 -0
- package/dist/feed/parse.d.ts +42 -0
- package/dist/feed/parse.js +291 -0
- package/dist/feed/pointer.d.ts +2 -0
- package/dist/feed/pointer.js +17 -0
- package/dist/file-types.js +1 -0
- package/dist/host-command.d.ts +3 -0
- package/dist/host-command.js +18 -0
- package/dist/host.d.ts +3 -0
- package/dist/host.js +3 -0
- package/dist/learn/check.d.ts +17 -1
- package/dist/learn/check.js +240 -5
- package/dist/learn/compile.d.ts +48 -27
- package/dist/learn/compile.js +134 -101
- package/dist/learn/promote.d.ts +61 -5
- package/dist/learn/promote.js +12 -2
- package/dist/learned-nodes.d.ts +21 -4
- package/dist/learned-nodes.js +21 -8
- package/dist/learned-workflow.d.ts +3 -3
- package/dist/learned-workflow.js +14 -5
- package/dist/learning-setting.d.ts +23 -0
- package/dist/learning-setting.js +51 -0
- package/dist/learning-words.d.ts +3 -0
- package/dist/learning-words.js +3 -0
- package/dist/learning.d.ts +3 -2
- package/dist/learning.js +5 -3
- package/dist/mcp-oauth.d.ts +23 -1
- package/dist/mcp-oauth.js +46 -5
- package/dist/mcp-pin-first.d.ts +4 -2
- package/dist/mcp-pin-first.js +4 -3
- package/dist/mcp-private-hosts.d.ts +13 -0
- package/dist/mcp-private-hosts.js +16 -0
- package/dist/mcp-servers-store.d.ts +58 -5
- package/dist/mcp-servers-store.js +136 -17
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +2 -2
- package/dist/observation/http.d.ts +4 -1
- package/dist/observation/http.js +5 -4
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +151 -21
- package/dist/print.d.ts +6 -3
- package/dist/print.js +4 -2
- package/dist/run-files.d.ts +6 -2
- package/dist/run-files.js +29 -7
- package/dist/run-labels.d.ts +23 -0
- package/dist/run-labels.js +79 -0
- package/dist/run-learning-served.d.ts +1 -1
- package/dist/run-reads-over-store.d.ts +5 -1
- package/dist/run-reads-over-store.js +8 -4
- package/dist/run-recordings.d.ts +20 -0
- package/dist/run-recordings.js +133 -0
- package/dist/run-secrets.js +12 -4
- package/dist/runner/adapter-loop.d.ts +1 -1
- package/dist/runner/adapter-loop.js +94 -16
- package/dist/runner/adapter-run-spec.d.ts +19 -0
- package/dist/runner/adapter-run-spec.js +57 -36
- package/dist/runner/beside.d.ts +6 -3
- package/dist/runner/beside.js +9 -7
- package/dist/runner/cli-run-spec.js +41 -32
- package/dist/runner/conformance/harness.js +69 -14
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/feedback-round.d.ts +9 -25
- package/dist/runner/feedback-round.js +22 -40
- package/dist/runner/learning-end.d.ts +17 -7
- package/dist/runner/learning-end.js +79 -53
- package/dist/runner/main.d.ts +12 -1
- package/dist/runner/main.js +31 -4
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +1 -1
- package/dist/runner/mcp-run.d.ts +6 -2
- package/dist/runner/mcp-run.js +5 -3
- package/dist/runner/model-route.d.ts +4 -2
- package/dist/runner/model-route.js +8 -8
- package/dist/runner/promotion.d.ts +44 -4
- package/dist/runner/promotion.js +323 -21
- package/dist/runner/reflect-hook.d.ts +5 -0
- package/dist/runner/reflect-hook.js +22 -14
- package/dist/runner/store-secrets.js +3 -1
- package/dist/runner/workflow-first.d.ts +6 -11
- package/dist/runner/workflow-first.js +16 -20
- package/dist/runs-over-store.d.ts +1 -1
- package/dist/runs-over-store.js +5 -2
- package/dist/sdk/runs.d.ts +7 -1
- package/dist/sdk/runs.js +21 -7
- package/dist/secret-cut.js +3 -1
- package/dist/secrets.js +5 -3
- package/dist/server.d.ts +31 -5
- package/dist/server.js +240 -61
- package/dist/store/agent-body.d.ts +5 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store/dialect.d.ts +3 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/postgres/dialect.js +1 -0
- package/dist/store/postgres/migrations/0015_run_labels.sql +5 -0
- package/dist/store/postgres/migrations/0016_minted_tokens.sql +21 -0
- package/dist/store/schema.d.ts +9 -0
- package/dist/store/schema.js +26 -2
- package/dist/store/sqlite/connection.js +11 -3
- package/dist/store/sqlite/run-patch.d.ts +2 -1
- package/dist/store/sqlite/run-patch.js +3 -2
- package/dist/store/sqlite/store.js +64 -10
- package/dist/store/store.d.ts +38 -1
- package/dist/store-reads/journal.js +2 -1
- package/dist/store-reads/learning.d.ts +1 -1
- package/dist/store-reads/learning.js +6 -1
- package/dist/store-reads/loop.d.ts +1 -0
- package/dist/store-reads/loop.js +14 -4
- package/dist/store-reads/runs.d.ts +4 -3
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +8 -2
- package/dist/template-eval.d.ts +11 -0
- package/dist/template-eval.js +177 -52
- package/dist/templates.d.ts +13 -1
- package/dist/templates.js +89 -18
- package/dist/timeline/computer.js +2 -1
- package/dist/timeline/origin.d.ts +1 -1
- package/dist/timeline/origin.js +2 -2
- package/dist/tool-list.js +1 -0
- package/dist/tools.d.ts +7 -0
- package/dist/tools.js +11 -0
- package/dist/trigger-adapter.d.ts +9 -4
- package/dist/trigger-adapters.js +2 -1
- package/dist/trigger-feed.d.ts +12 -0
- package/dist/trigger-feed.js +420 -0
- package/dist/triggers.d.ts +2 -1
- package/dist/triggers.js +23 -5
- package/dist/validate.js +7 -2
- package/dist/webhooks.js +9 -5
- package/dist/workspace/computer-deps.d.ts +5 -1
- package/dist/workspace/computer-deps.js +2 -2
- package/dist/workspace/computer-for-claim.d.ts +7 -0
- package/dist/workspace/computer-for-claim.js +12 -2
- package/dist/workspace/index.d.ts +1 -0
- package/dist/workspace/index.js +2 -0
- package/dist/workspace/paths.d.ts +4 -0
- package/dist/workspace/paths.js +9 -0
- package/dist/workspace/resolve-computer.d.ts +35 -4
- package/dist/workspace/resolve-computer.js +47 -9
- package/launcher/agentrun-serve +34 -22
- package/package.json +11 -9
- package/templates/README.md +38 -4
- package/dist/console/assets/index-Jbxjcmdp.js +0 -705
|
@@ -134,6 +134,14 @@ export interface AdapterSpecDeps {
|
|
|
134
134
|
* server (runner/beside.ts, Serve.localInstall) is told so, by that server in its own process. Absent, never: a hosted
|
|
135
135
|
* or standalone runner's loopback is its host's other services. */
|
|
136
136
|
readonly mcpLoopback?: boolean;
|
|
137
|
+
/** That server's own addresses (Serve.own: where it listens, and its public address on loopback), told with
|
|
138
|
+
* mcpLoopback: a run's loopback request (an MCP server's, its authorization server's, a pin's listing, calendar_events') never goes to
|
|
139
|
+
* their ports, as the server's own requests never do. */
|
|
140
|
+
readonly mcpOwn?: readonly string[];
|
|
141
|
+
/** More own addresses, read at each claim beside mcpOwn: a standalone runner's (runner/main.ts runnerLoop), the ones
|
|
142
|
+
* the server kept in the store at its last start (mcp-private-hosts.ts serverOwn), so a server on any port stays
|
|
143
|
+
* refused. Read only when mcpLoopback is set. */
|
|
144
|
+
readonly mcpOwnOf?: () => Promise<readonly string[]>;
|
|
137
145
|
/** A template eval's fakes, by the agent a run is of (template-eval.ts, from its case: EvalFakes). Only the eval's own
|
|
138
146
|
* runner, in the eval's process, is given it (runner/beside.ts); no environment variable, flag, setting or API field
|
|
139
147
|
* maps onto it. Absent, or undefined for a run: none. */
|
|
@@ -311,9 +319,20 @@ export declare function buildToolHost(opts: {
|
|
|
311
319
|
readonly toolSettings?: unknown;
|
|
312
320
|
/** The run's template eval fakes, where the eval's own runner gives them (AdapterSpecDeps.evalFakes). */
|
|
313
321
|
readonly fakes?: EvalFakes;
|
|
322
|
+
/** The server is a local install (AdapterSpecDeps.mcpLoopback): calendar_events may read a calendar on loopback. */
|
|
323
|
+
readonly loopback?: boolean;
|
|
324
|
+
/** That server's own addresses (AdapterSpecDeps.mcpOwn): never the ports calendar_events reads on loopback. */
|
|
325
|
+
readonly own?: readonly string[];
|
|
314
326
|
}): ToolHost;
|
|
315
327
|
/** The run's web host tools (tool-list.ts `host` rows: web_fetch, web_search, monid) as HostTool[], each bound through `host` by its
|
|
316
328
|
* catalog name and wrapped as the hands are (host-tools.ts hostToolOf, with `ctx`), the one binding the pi spec and the
|
|
317
329
|
* CLI spec share. Each runs under the adapter loop's one gate (spec.gate) on the claim's keys (host.env), and books its
|
|
318
330
|
* paid requests on the run's one ledger itself (bookedIn): they carry no settle of their own. */
|
|
319
331
|
export declare function webHostTools(host: ToolHost, granted: readonly string[], ctx: HostToolCtx): Promise<HostTool[]>;
|
|
332
|
+
/** What a claim's MCP servers and calendar_events may reach on loopback (mcpForClaim's and buildToolHost's `loopback` and
|
|
333
|
+
* `own`): nothing unless mcpLoopback; else loopback, never at mcpOwn's ports nor mcpOwnOf's, read now. Read once per
|
|
334
|
+
* claim. */
|
|
335
|
+
export declare function mcpReachOf(deps: Pick<AdapterSpecDeps, "mcpLoopback" | "mcpOwn" | "mcpOwnOf">): Promise<{
|
|
336
|
+
loopback?: true;
|
|
337
|
+
own?: readonly string[];
|
|
338
|
+
}>;
|
|
@@ -29,7 +29,7 @@ import { PORT_PROVIDER, tieredModels, tierProvider } from "../port-models.js";
|
|
|
29
29
|
import { promptOf, readsFiles } from "../skills.js";
|
|
30
30
|
import { openRunWorkspace } from "../workspace/run-workspace.js";
|
|
31
31
|
import { layOwnSkills } from "../workspace/revision-skills.js";
|
|
32
|
-
import { COMPUTER_ROOT, runFolder } from "../workspace/paths.js";
|
|
32
|
+
import { COMPUTER_ROOT, recordingsFolder, runFolder } from "../workspace/paths.js";
|
|
33
33
|
import { runTools, withKindTools } from "../workspace/run-tools.js";
|
|
34
34
|
import { placeRunInputs } from "../uploads.js";
|
|
35
35
|
import { handedSignInReadsBack, signInReads } from "../sign-ins-store.js";
|
|
@@ -45,8 +45,8 @@ import { ClaimRefused } from "./loop-contract.js";
|
|
|
45
45
|
import { bookedSpend, cliRunMetrics, endCostOf, runCostOf, runMetrics } from "./metrics.js";
|
|
46
46
|
import { journalEntries } from "./journal-reader.js";
|
|
47
47
|
import { hashedMcpOf, piShaped } from "../store-reads/journal.js";
|
|
48
|
-
import { claimPromotion, promotionGate, replayCallsFor, replayClaimed, replayLaid } from "./promotion.js";
|
|
49
|
-
import {
|
|
48
|
+
import { claimPromotion, promotionGate, replayCallsFor, replayClaimed, replayLaid, toolFlowsFor } from "./promotion.js";
|
|
49
|
+
import { pathMetrics, servedOf, workflowFirstOf } from "./workflow-first.js";
|
|
50
50
|
import { pastRunsOverStore, runPathOverStore } from "../store-reads/learning.js";
|
|
51
51
|
import { specBuilt } from "./spec-holds.js";
|
|
52
52
|
import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
|
|
@@ -209,6 +209,8 @@ export function adapterRunSpecFromLaunch(launch, run, deps, claim) {
|
|
|
209
209
|
}
|
|
210
210
|
async function adapterSpec(launch, run, deps, claim, holds) {
|
|
211
211
|
const context = BACKGROUND_CONTEXT;
|
|
212
|
+
// What this claim may reach on loopback, read once for its MCP servers and its calendar_events alike (mcpReachOf).
|
|
213
|
+
const reach = await mcpReachOf(deps);
|
|
212
214
|
// The runner's one redactor (the loop's, LoopDeps.redact), for every text a secret could reach: the spec's log lines
|
|
213
215
|
// (a release, a workspace's end), the model route's translation and the session's model proxy. A spec built with no
|
|
214
216
|
// runner around it cuts every secret the runner's env holds. It holds the keys the claim opens (below), too.
|
|
@@ -262,13 +264,43 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
262
264
|
// person's stop ends the fetch at once (run.stopped).
|
|
263
265
|
const checkout = body.checkout === "pull_request" ? await prCheckoutForClaim(deps, ws.workspace, launch, cut, run.stopped ?? run.signal, (part) => holds.hold({ checkout: part })) : undefined;
|
|
264
266
|
holds.hold({ checkout });
|
|
267
|
+
// The run's skills and its learning seed, laid in its folder through the run's Workspace now, before its computer
|
|
268
|
+
// exists: on Archil the computer's mount of the folder takes the disk's write delegation, and from then on every write
|
|
269
|
+
// over the disk's file API is refused (409) while the mount holds it, so a lay after the mount fails the run. The lay
|
|
270
|
+
// reads nothing of the computer: the kind skill is the revision's computer setting's kind. A later claim lays only what
|
|
271
|
+
// is not there yet (layOwnSkills keeps every folder an earlier claim laid).
|
|
272
|
+
// The launch's learning start (none: the run does not learn), decided once at launch.
|
|
273
|
+
const start = learningStartOf(launch);
|
|
274
|
+
// The revision's own skills are laid in the run's .agents/skills/ before they are read (main's server start laid them;
|
|
275
|
+
// on the one store the claim does), from the revision row's texts (the body keeps only each file's SHA-256): each
|
|
276
|
+
// folder not there yet, never over a learned skill or an earlier claim's. A desktop or a phone (the revision's computer
|
|
277
|
+
// setting, the one computerForClaim starts) brings its kind's skill, named in the prompt beside the revision's own.
|
|
278
|
+
const kindSkills = await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: settingOfDefinition(body)?.computer.kind });
|
|
279
|
+
// A learning run's seed, read once from its learning folder where the run's place keeps it: its notes in .learning/
|
|
280
|
+
// and its learned skills beside the revision's own (runner/learning-seed.ts), cut of the server's secrets, the learned
|
|
281
|
+
// skills then in the skill list the prompt names, its learned workflows the ones its learned_workflow tool runs. Laid
|
|
282
|
+
// before the run's tools are bound. A learning fault, or a seed that failed (seedFailed), lays nothing.
|
|
283
|
+
const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true });
|
|
284
|
+
const learningFolder = () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil }));
|
|
285
|
+
const seedLaid = start && !seedFailed(start)
|
|
286
|
+
? await layLearningSeed({
|
|
287
|
+
work: ws.workspace,
|
|
288
|
+
seed: start.seed,
|
|
289
|
+
folder: learningFolder,
|
|
290
|
+
own: Object.keys(revisionRow.skills ?? {}),
|
|
291
|
+
shown,
|
|
292
|
+
log,
|
|
293
|
+
...(start.notesOnly ? { workflows: false } : {}),
|
|
294
|
+
...(start.notesLeftOut?.length ? { notesLeftOut: start.notesLeftOut } : {}),
|
|
295
|
+
})
|
|
296
|
+
: undefined;
|
|
265
297
|
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin, the one its revision's save made, read, its
|
|
266
298
|
// credentials opened under the server's seal key into this claim's memory, one gateway for the claim. First, before
|
|
267
299
|
// anything the spec would have to let go: a refusal (a granted tool its pin does not hold, a pinned meta tool) ends the run in its
|
|
268
300
|
// words before the session opens. The seal key is the runner's own (deps.sealKey), not re-read from the environment.
|
|
269
301
|
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactor.
|
|
270
302
|
const hold = (values) => cut.hold(values);
|
|
271
|
-
const mcp = await mcpForClaim({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => ws.workspace, 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 } : {}), ...
|
|
303
|
+
const mcp = await mcpForClaim({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => ws.workspace, 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 } : {}), ...reach });
|
|
272
304
|
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
273
305
|
holds.hold({ passed: mcp });
|
|
274
306
|
// The run's computer, from the one shared claim-time function (the CLI spec takes the same): none for a runner place, a
|
|
@@ -282,8 +314,9 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
282
314
|
// A person's stop ends the claim's waits at once: a first image pull or registration (Agent37's runs minutes) among them.
|
|
283
315
|
// Whether an earlier claim made the run a computer of its own is the run's journal's to say (hadComputer): a later
|
|
284
316
|
// claim's is a new one whatever ended the earlier claim (a lost runner, a server's stop, a park past its keep). The
|
|
285
|
-
// computer a park kept, attached again, brings its mount credential with it (inheritMount): none is minted.
|
|
286
|
-
|
|
317
|
+
// computer a park kept, attached again, brings its mount credential with it (inheritMount): none is minted. A
|
|
318
|
+
// recording of its screen (computer.record) goes in the run's recordings folder, beside its folder, said on its timeline.
|
|
319
|
+
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
|
|
287
320
|
// The run's shell is its computer's (600 s) where one mounts its folder; with none, Archil's serverless exec in Mode 2
|
|
288
321
|
// (295 s), and in Mode 1 none at all: no bash family, its folder being one of this server's own (run-tools.ts).
|
|
289
322
|
// A desktop's or a phone's hold (the person's take-over) wraps its ports: a call made while the person holds it waits,
|
|
@@ -420,31 +453,6 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
420
453
|
delete toolEnv[TOOL_PLANE_ENV];
|
|
421
454
|
if (launch.plane && Object.keys(launch.plane).length)
|
|
422
455
|
toolEnv[TOOL_PLANE_ENV] = JSON.stringify(launch.plane);
|
|
423
|
-
// The launch's learning start (none: the run does not learn), decided once at launch.
|
|
424
|
-
const start = learningStartOf(launch);
|
|
425
|
-
// The revision's own skills are laid in the run's .agents/skills/ before they are read (main's server start laid them;
|
|
426
|
-
// on the one store the claim does), from the revision row's texts (the body keeps only each file's SHA-256): each
|
|
427
|
-
// folder not there yet, never over a learned skill or an earlier claim's. A desktop or a phone (the revision's computer
|
|
428
|
-
// setting, the one computerForClaim starts) brings its kind's skill, named in the prompt beside the revision's own.
|
|
429
|
-
const kindSkills = await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: settingOfDefinition(body)?.computer.kind });
|
|
430
|
-
// A learning run's seed, read once from its learning folder where the run's place keeps it: its notes in .learning/
|
|
431
|
-
// and its learned skills beside the revision's own (runner/learning-seed.ts), cut of the server's secrets, the learned
|
|
432
|
-
// skills then in the skill list the prompt names, its learned workflows the ones its learned_workflow tool runs. Laid
|
|
433
|
-
// before the run's tools are bound. A learning fault, or a seed that failed (seedFailed), lays nothing.
|
|
434
|
-
const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true });
|
|
435
|
-
const learningFolder = () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil }));
|
|
436
|
-
const seedLaid = start && !seedFailed(start)
|
|
437
|
-
? await layLearningSeed({
|
|
438
|
-
work: ws.workspace,
|
|
439
|
-
seed: start.seed,
|
|
440
|
-
folder: learningFolder,
|
|
441
|
-
own: Object.keys(revisionRow.skills ?? {}),
|
|
442
|
-
shown,
|
|
443
|
-
log,
|
|
444
|
-
...(start.notesOnly ? { workflows: false } : {}),
|
|
445
|
-
...(start.notesLeftOut?.length ? { notesLeftOut: start.notesLeftOut } : {}),
|
|
446
|
-
})
|
|
447
|
-
: undefined;
|
|
448
456
|
// The decision keys its learned workflows' typed questions need (claim-secrets.ts learnedDecisionKeys), read once the lay
|
|
449
457
|
// chose them, scoped as the revision's own: each provider the run's gate does not deny, held by the run's one redactor,
|
|
450
458
|
// onto the tools' environment alone. The model's route was built on the revision's keys above, so a decision key never
|
|
@@ -455,17 +463,19 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
455
463
|
// chosen before the learned_workflow tool is bound, so the tool runs the text that serves. Only a promoted digest
|
|
456
464
|
// serves (runner/promotion.ts: replayed on the agent's graded inputs first, or promoted on its dry run with fewer than
|
|
457
465
|
// five); while the folder's revision replays or is held, the champion (the digest promoted last) serves in its place
|
|
458
|
-
// (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the
|
|
459
|
-
const
|
|
466
|
+
// (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the agent takes the run.
|
|
467
|
+
const promotion = claimPromotion({
|
|
460
468
|
store: deps.store, agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, launch, context, log, folder: learningFolder, shown, sealKey: deps.sealKey,
|
|
461
|
-
})
|
|
469
|
+
});
|
|
470
|
+
const firstChoice = learnsWorkflows(revision.kind, laidFlows) ? await workflowFirstOf(revision.kind, laidFlows, launch, log, () => pastRunsOverStore(deps.store, runRow.agentId), promotionGate(promotion), revision.body.outputSchema) : {};
|
|
462
471
|
// A replay run runs only its revision, while it still replays: else its claim is refused (the run ends failed, no agent).
|
|
463
472
|
await replayClaimed(deps.store, runRow.agentId, claim.runId, launch, firstChoice);
|
|
464
473
|
// A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
|
|
465
474
|
// answered from that recording (runner/promotion.ts replayCallsFor, learn/replay-calls.ts).
|
|
466
475
|
const replay = await replayCallsFor(deps.store, claim.runId, launch, context);
|
|
467
476
|
const { serve: workflowFirst, revise: workflowRevise } = firstChoice;
|
|
468
|
-
|
|
477
|
+
// The tool runs what serves, never a revision not promoted (runner/promotion.ts toolFlowsFor).
|
|
478
|
+
const workflows = await toolFlowsFor(promotion, launch, laidFlows, firstChoice);
|
|
469
479
|
// A tier a learned workflow's node names and the host has a model of: none can't be reached is left as `why`, and its
|
|
470
480
|
// node fails in those words (learnedWorkflowHostTool), never on another model.
|
|
471
481
|
const tierUnreachable = new Map();
|
|
@@ -495,7 +505,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
495
505
|
// An agent whose computer is a browser the claim started gets the browser tool on that one session (tools.ts).
|
|
496
506
|
const claimBrowser = computer.computer?.kind === "browser" ? computer.computer.browser : undefined;
|
|
497
507
|
const fakes = deps.evalFakes?.(runRow.agentId);
|
|
498
|
-
const host = { ...buildToolHost({ root, workspace: ws.workspace, claim, env: toolEnv, run, store: deps.store, sealKey: deps.sealKey, life, redact: cut, launch, toolSettings: body.toolSettings, ...(fakes ? { fakes } : {}) }), ...(claimBrowser ? { browserComputer: claimBrowser } : {}) };
|
|
508
|
+
const host = { ...buildToolHost({ root, workspace: ws.workspace, claim, env: toolEnv, run, store: deps.store, sealKey: deps.sealKey, life, redact: cut, launch, toolSettings: body.toolSettings, ...(fakes ? { fakes } : {}), ...reach }), ...(claimBrowser ? { browserComputer: claimBrowser } : {}) };
|
|
499
509
|
gate.askedOn(host);
|
|
500
510
|
// The run's tools. The hands (read/write/edit/bash and the background tools) are the kernel registry's over the run's
|
|
501
511
|
// Workspace and computer (runTools.hostTools); the gate is the adapter loop's own (spec.gate), so they run as asked.
|
|
@@ -835,6 +845,8 @@ export function buildToolHost(opts) {
|
|
|
835
845
|
...(web ? { web } : {}),
|
|
836
846
|
...(now ? { now } : {}),
|
|
837
847
|
...(email ? { emailFake: email } : {}),
|
|
848
|
+
...(opts.loopback ? { calendarLoopback: true } : {}),
|
|
849
|
+
...(opts.own ? { serverOwn: opts.own } : {}),
|
|
838
850
|
// The run's directory and its per-claim environment: the hands come from runTools, so the non-hand tools get the run's
|
|
839
851
|
// environment only.
|
|
840
852
|
where: { root, work: root, ref: { id: claim.runId } },
|
|
@@ -924,3 +936,12 @@ async function bindNonHandTools(host, kind, granted, run, context, results, root
|
|
|
924
936
|
// seam when it lands; never a second journalSessions + runCap over the one journal (the double-book we closed).
|
|
925
937
|
return tools;
|
|
926
938
|
}
|
|
939
|
+
/** What a claim's MCP servers and calendar_events may reach on loopback (mcpForClaim's and buildToolHost's `loopback` and
|
|
940
|
+
* `own`): nothing unless mcpLoopback; else loopback, never at mcpOwn's ports nor mcpOwnOf's, read now. Read once per
|
|
941
|
+
* claim. */
|
|
942
|
+
export async function mcpReachOf(deps) {
|
|
943
|
+
if (!deps.mcpLoopback)
|
|
944
|
+
return {};
|
|
945
|
+
const own = [...(deps.mcpOwn ?? []), ...((await deps.mcpOwnOf?.()) ?? [])];
|
|
946
|
+
return { loopback: true, ...(own.length ? { own } : {}) };
|
|
947
|
+
}
|
package/dist/runner/beside.d.ts
CHANGED
|
@@ -27,15 +27,18 @@ export declare function besideStopping(server: {
|
|
|
27
27
|
* caller hands its own: the template eval's in-process server, its faux's). `loops` and `drainMs`: the runner's
|
|
28
28
|
* (RunnerOptions), the CLI start's from the server's flags (besideRunnerOptions). `janitor`: run the computer janitor
|
|
29
29
|
* too (workspace/computer-janitor.ts), as the CLI's start asks. `hub`: the server's AttachHub (Serve.attachHub), which
|
|
30
|
-
* holds each paired computer's socket in this process, so a run here takes one.
|
|
31
|
-
*
|
|
32
|
-
|
|
30
|
+
* holds each paired computer's socket in this process, so a run here takes one. `dial`: the server's (Serve.dial), which
|
|
31
|
+
* a remote provider's create takes, so a machine that dials the server lands in this process's hub. Returns the runner
|
|
32
|
+
* and a close() that stops both and closes its store. */
|
|
33
|
+
export declare function runnerBeside(dataDir: string, { loops, drainMs, env, janitor, hub, dial, mcpLoopback, mcpOwn, evalFakes, harnessInstall, onLine }?: {
|
|
33
34
|
loops?: number;
|
|
34
35
|
drainMs?: number;
|
|
35
36
|
env?: NodeJS.ProcessEnv;
|
|
36
37
|
janitor?: boolean;
|
|
37
38
|
hub?: import("@parcha/agentrun-computer").AttachHub;
|
|
39
|
+
dial?: import("@parcha/agentrun-computer").HostedDial;
|
|
38
40
|
mcpLoopback?: boolean;
|
|
41
|
+
mcpOwn?: readonly string[];
|
|
39
42
|
evalFakes?: (agentId: string) => import("./adapter-run-spec.js").EvalFakes | undefined;
|
|
40
43
|
harnessInstall?: import("../harness-install.js").HarnessInstaller;
|
|
41
44
|
onLine?: (line: string) => void;
|
package/dist/runner/beside.js
CHANGED
|
@@ -28,9 +28,10 @@ export function besideStopping(server, held, drainMs) {
|
|
|
28
28
|
* caller hands its own: the template eval's in-process server, its faux's). `loops` and `drainMs`: the runner's
|
|
29
29
|
* (RunnerOptions), the CLI start's from the server's flags (besideRunnerOptions). `janitor`: run the computer janitor
|
|
30
30
|
* too (workspace/computer-janitor.ts), as the CLI's start asks. `hub`: the server's AttachHub (Serve.attachHub), which
|
|
31
|
-
* holds each paired computer's socket in this process, so a run here takes one.
|
|
32
|
-
*
|
|
33
|
-
|
|
31
|
+
* holds each paired computer's socket in this process, so a run here takes one. `dial`: the server's (Serve.dial), which
|
|
32
|
+
* a remote provider's create takes, so a machine that dials the server lands in this process's hub. Returns the runner
|
|
33
|
+
* and a close() that stops both and closes its store. */
|
|
34
|
+
export async function runnerBeside(dataDir, { loops, drainMs, env, janitor, hub, dial, mcpLoopback, mcpOwn, evalFakes, harnessInstall, onLine } = {}) {
|
|
34
35
|
const { runnerName, startRunner } = await import("./runner.js");
|
|
35
36
|
const { dispatchRunner } = await import("./harness-loops.js");
|
|
36
37
|
const { routeOf } = await import("./model-route.js");
|
|
@@ -60,14 +61,15 @@ export async function runnerBeside(dataDir, { loops, drainMs, env, janitor, hub,
|
|
|
60
61
|
const { hostAddressesOnce } = await import("../docker-host-addresses.js");
|
|
61
62
|
const { PROVIDERS } = await import("@parcha/agentrun-computer");
|
|
62
63
|
const { hostCommandRefusals } = await import("../computers.js");
|
|
63
|
-
const computers = runnerComputers(store, runs, seal.key, { dockerPaths: () => dockerPathsForRuns(runs, dataDir), hostAddresses: () => hostAddressesOnce(runs), hostWhy: hostCommandRefusals(PROVIDERS, process.env.PATH), ...(hub ? { hub } : {}) });
|
|
64
|
+
const computers = runnerComputers(store, runs, seal.key, { dockerPaths: () => dockerPathsForRuns(runs, dataDir), hostAddresses: () => hostAddressesOnce(runs), hostWhy: hostCommandRefusals(PROVIDERS, process.env.PATH), ...(hub ? { hub } : {}), ...(dial ? { dial } : {}) });
|
|
64
65
|
// `mcpLoopback`: the server beside it is a local install (Serve.localInstall), so its runs may reach an MCP server on
|
|
65
|
-
// loopback;
|
|
66
|
+
// loopback; a runner in its own process does only as its own environment says (main.ts runnerLoopback). `mcpOwn`: that server's own addresses (Serve.own), whose ports a run's
|
|
67
|
+
// loopback read never goes to. A run's log lines (a learning run's skipped generality check) go to
|
|
66
68
|
// stderr with the runner's other lines. `evalFakes`: the template eval's fakes (EvalFakes: a case's web, now, monid and
|
|
67
69
|
// email), by the agent each of its runs is of; only the eval, in its own process, hands them. `harnessInstall`: what a
|
|
68
70
|
// claim's first-use install installs with (the eval's sharedInstaller, which the server beside it takes too).
|
|
69
71
|
const { installForClaim } = await import("../harness-install.js");
|
|
70
|
-
const createLoop = dispatchRunner({ env: runs, data: dataDir, journal: (claim) => store.journal(claim), store, sealKey: seal.key, routeOf, computerForClaim: computers.computerForClaim, computerDeps: computers.computerDeps, ...(mcpLoopback ? { mcpLoopback: true } : {}), ...(evalFakes ? { evalFakes } : {}), ...(harnessInstall ? { installForClaim: (entry, dir, pins, given) => installForClaim(entry, dir, pins, { ...given, install: harnessInstall }) } : {}), log: (line) => console.error(`agentrun-serve runner: ${line}`) });
|
|
72
|
+
const createLoop = dispatchRunner({ env: runs, data: dataDir, journal: (claim) => store.journal(claim), store, sealKey: seal.key, routeOf, computerForClaim: computers.computerForClaim, computerDeps: computers.computerDeps, ...(mcpLoopback ? { mcpLoopback: true } : {}), ...(mcpOwn ? { mcpOwn } : {}), ...(evalFakes ? { evalFakes } : {}), ...(harnessInstall ? { installForClaim: (entry, dir, pins, given) => installForClaim(entry, dir, pins, { ...given, install: harnessInstall }) } : {}), log: (line) => console.error(`agentrun-serve runner: ${line}`) });
|
|
71
73
|
// It claims by the host's memory as well as by --max-runs (memory-claim.ts): a heavy harness's run waits queued for room.
|
|
72
74
|
const { runnerMemory } = await import("./memory-claim.js");
|
|
73
75
|
// Before it claims: the scratch folders of runs that ended after their runner died (scratch-sweep.ts).
|
|
@@ -109,7 +111,7 @@ export async function serveWithRunner(options) {
|
|
|
109
111
|
const { besideRunEnv } = await import("./main.js");
|
|
110
112
|
const { loops, drainMs } = besideRunnerOptions(options, process.env);
|
|
111
113
|
const serve = await startServe(options);
|
|
112
|
-
const beside = await runnerBeside(options.data, { loops, drainMs, env: besideRunEnv(process.env, fauxEnvOf(options)), hub: serve.attachHub, mcpLoopback: serve.localInstall, ...(options.log ? { onLine: options.log } : {}) }).catch(async (error) => {
|
|
114
|
+
const beside = await runnerBeside(options.data, { loops, drainMs, env: besideRunEnv(process.env, fauxEnvOf(options)), hub: serve.attachHub, dial: serve.dial, mcpLoopback: serve.localInstall, mcpOwn: serve.own, ...(options.log ? { onLine: options.log } : {}) }).catch(async (error) => {
|
|
113
115
|
await serve.close();
|
|
114
116
|
throw error;
|
|
115
117
|
});
|
|
@@ -37,7 +37,7 @@ import { learningStartOf, seedFailed } from "../run-launch.js";
|
|
|
37
37
|
import { readsFiles, systemOf } from "../skills.js";
|
|
38
38
|
import { DATA_ENV } from "../server-fs.js";
|
|
39
39
|
import { placeRunInputs } from "../uploads.js";
|
|
40
|
-
import { runFolder, scratchFolder } from "../workspace/paths.js";
|
|
40
|
+
import { recordingsFolder, runFolder, scratchFolder } from "../workspace/paths.js";
|
|
41
41
|
import { openRunWorkspace } from "../workspace/run-workspace.js";
|
|
42
42
|
import { layOwnSkills } from "../workspace/revision-skills.js";
|
|
43
43
|
import { runTools, withKindTools } from "../workspace/run-tools.js";
|
|
@@ -47,7 +47,7 @@ import { settingOfDefinition } from "../computer-setting.js";
|
|
|
47
47
|
import { computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
48
48
|
import { hadComputer } from "./computer-journal.js";
|
|
49
49
|
import { hostLifecycle } from "./adapter-loop.js";
|
|
50
|
-
import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, modelAskOf, PI_WIRES, webHostTools } from "./adapter-run-spec.js";
|
|
50
|
+
import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, mcpReachOf, modelAskOf, PI_WIRES, webHostTools } from "./adapter-run-spec.js";
|
|
51
51
|
import { openTierProxies } from "./adapters/pi.js";
|
|
52
52
|
import { signInReads } from "../sign-ins-store.js";
|
|
53
53
|
import { isWebHostTool } from "../tool-list.js";
|
|
@@ -63,8 +63,8 @@ import { entriesOf } from "./loop.js";
|
|
|
63
63
|
import { bookedSpend, cliModelWorked, cliRunMetrics, endCostOf, runCostOf } from "./metrics.js";
|
|
64
64
|
import { journalEntries } from "./journal-reader.js";
|
|
65
65
|
import { hashedMcpOf, piShaped } from "../store-reads/journal.js";
|
|
66
|
-
import { claimPromotion, promotionGate, replayCallsFor, replayClaimed, replayLaid } from "./promotion.js";
|
|
67
|
-
import {
|
|
66
|
+
import { claimPromotion, promotionGate, replayCallsFor, replayClaimed, replayLaid, toolFlowsFor } from "./promotion.js";
|
|
67
|
+
import { pathMetrics, workflowFirstOf } from "./workflow-first.js";
|
|
68
68
|
import { pastRunsOverStore, runPathOverStore } from "../store-reads/learning.js";
|
|
69
69
|
import { specBuilt } from "./spec-holds.js";
|
|
70
70
|
import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
|
|
@@ -226,6 +226,8 @@ export function cliRunSpecFromLaunch(launch, run, deps, claim) {
|
|
|
226
226
|
}
|
|
227
227
|
async function cliSpec(launch, run, deps, claim, holds) {
|
|
228
228
|
const context = BACKGROUND_CONTEXT;
|
|
229
|
+
// What this claim may reach on loopback, read once for its MCP servers and its calendar_events alike (mcpReachOf).
|
|
230
|
+
const reach = await mcpReachOf(deps);
|
|
229
231
|
// The spec's log lines carry error text (a release, a computer, a workspace's end): cut of every secret the runner's env
|
|
230
232
|
// holds.
|
|
231
233
|
const cut = heldRedactor(secretRedactor(runnerSecrets(deps.env)));
|
|
@@ -314,7 +316,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
314
316
|
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors.
|
|
315
317
|
const hold = (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
316
318
|
redact.hold(values); };
|
|
317
|
-
const mcp = await mcpForClaim({ 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 } : {}), ...
|
|
319
|
+
const mcp = await mcpForClaim({ 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 } : {}), ...reach });
|
|
318
320
|
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
319
321
|
holds.hold({ passed: mcp });
|
|
320
322
|
// The run's mode is the server's: Mode 2 where its Archil settings are saved (archil-settings.ts), the run's folder then
|
|
@@ -343,6 +345,30 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
343
345
|
const checkout = body.checkout === "pull_request" ? await prCheckoutForClaim(deps, ws.workspace, launch, cut, run.stopped ?? run.signal, (part) => holds.hold({ checkout: part })) : undefined;
|
|
344
346
|
holds.hold({ checkout });
|
|
345
347
|
await placeRunInputs(deps.data, claim.runId, ws.workspace, launch.files ?? [], messageText(launch.input));
|
|
348
|
+
// The run's skills and its learning seed laid before its computer exists, as the pi spec lays them (adapter-run-spec.ts):
|
|
349
|
+
// on Archil the computer's mount takes the disk's write delegation, and a lay over the disk's file API after it is
|
|
350
|
+
// refused (409) while the mount holds it.
|
|
351
|
+
// The launch's learning start (none: the run does not learn), decided once at launch.
|
|
352
|
+
const start = learningStartOf(launch);
|
|
353
|
+
// The revision's own skills laid before they are read, as the pi spec lays them (adapter-run-spec.ts), with the kind's
|
|
354
|
+
// skill of a desktop or a phone (the revision's computer setting), in the harness's skill list beside the revision's.
|
|
355
|
+
const kindSkills = await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: settingOfDefinition(body)?.computer.kind });
|
|
356
|
+
// A learning run's seed laid as the pi spec lays it (runner/learning-seed.ts), its learned skills then in the skill list
|
|
357
|
+
// the harness is handed (its native skills, or the prompt's), its learned workflows the ones learned_workflow runs.
|
|
358
|
+
const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true });
|
|
359
|
+
const learningFolder = () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil }));
|
|
360
|
+
const seedLaid = start && !seedFailed(start)
|
|
361
|
+
? await layLearningSeed({
|
|
362
|
+
work: ws.workspace,
|
|
363
|
+
seed: start.seed,
|
|
364
|
+
folder: learningFolder,
|
|
365
|
+
own: Object.keys(revisionRow.skills ?? {}),
|
|
366
|
+
shown,
|
|
367
|
+
log,
|
|
368
|
+
...(start.notesOnly ? { workflows: false } : {}),
|
|
369
|
+
...(start.notesLeftOut?.length ? { notesLeftOut: start.notesLeftOut } : {}),
|
|
370
|
+
})
|
|
371
|
+
: undefined;
|
|
346
372
|
// The run's computer, from the one shared claim-time function (the pi spec takes the same): none for a runner place.
|
|
347
373
|
// It throws computer_unavailable (nothing made) when the computer cannot be had: the run fails in its words.
|
|
348
374
|
const claimSignal = run.stopped ?? run.signal;
|
|
@@ -354,8 +380,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
354
380
|
// whose computer is a browser is refused in words at its claim, before anything is made.
|
|
355
381
|
// A person's stop ends the claim's waits at once: a first image pull or registration (Agent37's runs minutes) among them.
|
|
356
382
|
// Whether an earlier claim made the run a computer of its own is the run's journal's to say (hadComputer), as the pi
|
|
357
|
-
// spec asks it. The computer a park kept, attached again, brings its mount credential with it (inheritMount).
|
|
358
|
-
|
|
383
|
+
// spec asks it. The computer a park kept, attached again, brings its mount credential with it (inheritMount). Its
|
|
384
|
+
// screen's recording (computer.record) goes in the run's recordings folder, as the pi spec's does.
|
|
385
|
+
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
|
|
359
386
|
holds.hold({ computer });
|
|
360
387
|
const loopComputer = loopComputerOf(computer.computer, computer.held, computer.made);
|
|
361
388
|
const heldComputer = heldSpecOf(launch, loopComputer);
|
|
@@ -388,29 +415,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
388
415
|
// own skills through systemOf with the harness's own check (a harness that loads skills itself keeps in the prompt only
|
|
389
416
|
// those it would refuse, and is handed the rest), the output schema it answers in (answer-json.ts outputContract, as the
|
|
390
417
|
// pi spec gives it), then the effort guidance.
|
|
391
|
-
const start = learningStartOf(launch);
|
|
392
418
|
// A start whose seed failed tells the run nothing: it is never asked what to keep (learning-end.ts drops it).
|
|
393
419
|
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section, start.use === true) : (body.instructions ?? "");
|
|
394
420
|
const check = await entry.skillCheck?.();
|
|
395
|
-
// The revision's own skills laid before they are read, as the pi spec lays them (adapter-run-spec.ts), with the kind's
|
|
396
|
-
// skill of a desktop or a phone (the revision's computer setting), in the harness's skill list beside the revision's.
|
|
397
|
-
const kindSkills = await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: settingOfDefinition(body)?.computer.kind });
|
|
398
|
-
// A learning run's seed laid as the pi spec lays it (runner/learning-seed.ts), its learned skills then in the skill list
|
|
399
|
-
// the harness is handed (its native skills, or the prompt's), its learned workflows the ones learned_workflow runs.
|
|
400
|
-
const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true });
|
|
401
|
-
const learningFolder = () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil }));
|
|
402
|
-
const seedLaid = start && !seedFailed(start)
|
|
403
|
-
? await layLearningSeed({
|
|
404
|
-
work: ws.workspace,
|
|
405
|
-
seed: start.seed,
|
|
406
|
-
folder: learningFolder,
|
|
407
|
-
own: Object.keys(revisionRow.skills ?? {}),
|
|
408
|
-
shown,
|
|
409
|
-
log,
|
|
410
|
-
...(start.notesOnly ? { workflows: false } : {}),
|
|
411
|
-
...(start.notesLeftOut?.length ? { notesLeftOut: start.notesLeftOut } : {}),
|
|
412
|
-
})
|
|
413
|
-
: undefined;
|
|
414
421
|
const { system: instructions, native } = await systemOf(laid, [...Object.keys(body.skills ?? {}), ...kindSkills, ...(seedLaid?.skills ?? [])], ws.workspace, check, { onDemand: readsFiles(granted) });
|
|
415
422
|
const guidance = effortGuidance(launch.effort);
|
|
416
423
|
// The run's model (the launch's, pinned at start, else the revision's) and its adapter, as main builds them, on the
|
|
@@ -546,17 +553,19 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
546
553
|
// chosen before the learned_workflow tool is bound, so the tool runs the text that serves. Only a promoted digest
|
|
547
554
|
// serves (runner/promotion.ts: replayed on the agent's graded inputs first, or promoted on its dry run with fewer than
|
|
548
555
|
// five); while the folder's revision replays or is held, the champion (the digest promoted last) serves in its place
|
|
549
|
-
// (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the
|
|
550
|
-
const
|
|
556
|
+
// (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the agent takes the run.
|
|
557
|
+
const promotion = claimPromotion({
|
|
551
558
|
store: deps.store, agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, launch, context, log, folder: learningFolder, shown, sealKey: deps.sealKey,
|
|
552
|
-
})
|
|
559
|
+
});
|
|
560
|
+
const firstChoice = learnsWorkflows(revision.kind, laidFlows) ? await workflowFirstOf(revision.kind, laidFlows, launch, log, () => pastRunsOverStore(deps.store, runRow.agentId), promotionGate(promotion), revision.body.outputSchema) : {};
|
|
553
561
|
// A replay run runs only its revision, while it still replays: else its claim is refused (the run ends failed, no agent).
|
|
554
562
|
await replayClaimed(deps.store, runRow.agentId, claim.runId, launch, firstChoice);
|
|
555
563
|
// A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
|
|
556
564
|
// answered from that recording (runner/promotion.ts replayCallsFor, learn/replay-calls.ts).
|
|
557
565
|
const replay = await replayCallsFor(deps.store, claim.runId, launch, context);
|
|
558
566
|
const { serve: workflowFirst, revise: workflowRevise } = firstChoice;
|
|
559
|
-
|
|
567
|
+
// The tool runs what serves, never a revision not promoted (runner/promotion.ts toolFlowsFor).
|
|
568
|
+
const workflows = await toolFlowsFor(promotion, launch, laidFlows, firstChoice);
|
|
560
569
|
const learns = learnsWorkflows(revision.kind, workflows);
|
|
561
570
|
if (webNames.length || learns) {
|
|
562
571
|
// The claim's keys (above, already held by the redactors), a copy of its own for the tools' plane below.
|
|
@@ -577,7 +586,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
577
586
|
toolEnv[TOOL_PLANE_ENV] = JSON.stringify(launch.plane);
|
|
578
587
|
if (webNames.length) {
|
|
579
588
|
life = hostLifecycle();
|
|
580
|
-
const host = buildToolHost({ root, workspace: ws.workspace, claim, env: toolEnv, run, store: deps.store, sealKey: deps.sealKey, life, redact: held, launch, toolSettings: body.toolSettings, ...(fakes ? { fakes } : {}) });
|
|
589
|
+
const host = buildToolHost({ root, workspace: ws.workspace, claim, env: toolEnv, run, store: deps.store, sealKey: deps.sealKey, life, redact: held, launch, toolSettings: body.toolSettings, ...(fakes ? { fakes } : {}), ...reach });
|
|
581
590
|
gate.askedOn(host);
|
|
582
591
|
webTools = await webHostTools(host, granted, ctx);
|
|
583
592
|
}
|