@parcha/agentrun-serve 0.1.0-beta.41 → 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 +53 -0
- package/NOTICE +2 -0
- package/README.md +77 -12
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.js +3 -1
- 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 +3 -1
- 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.js +2 -14
- package/dist/console/assets/index-DYJ_wj27.js +711 -0
- package/dist/console/index.html +1 -1
- package/dist/eval-feed.d.ts +2 -2
- package/dist/eval-feed.js +9 -5
- package/dist/feed/parse.d.ts +3 -2
- package/dist/feed/parse.js +9 -18
- 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 +14 -0
- package/dist/learn/check.js +194 -14
- 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/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 +8 -0
- package/dist/mcp-oauth.js +7 -0
- package/dist/mcp-private-hosts.d.ts +13 -0
- package/dist/mcp-private-hosts.js +16 -0
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +105 -9
- package/dist/run-files.d.ts +6 -2
- package/dist/run-files.js +29 -7
- 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/runner/adapter-loop.d.ts +1 -1
- package/dist/runner/adapter-loop.js +3 -6
- package/dist/runner/adapter-run-spec.d.ts +16 -1
- package/dist/runner/adapter-run-spec.js +20 -6
- package/dist/runner/beside.js +1 -1
- package/dist/runner/cli-run-spec.js +10 -7
- 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 +11 -0
- package/dist/runner/main.js +29 -2
- package/dist/runner/mcp-run.d.ts +2 -2
- package/dist/runner/promotion.d.ts +36 -4
- package/dist/runner/promotion.js +280 -20
- 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 +0 -6
- package/dist/runner/workflow-first.js +7 -13
- package/dist/runs-over-store.d.ts +1 -1
- package/dist/sdk/runs.js +2 -1
- package/dist/secrets.js +2 -2
- package/dist/server.d.ts +4 -3
- package/dist/server.js +72 -11
- package/dist/store/agent-body.d.ts +5 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store-reads/learning.d.ts +1 -1
- package/dist/store-reads/loop.d.ts +1 -0
- package/dist/store-reads/loop.js +14 -4
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +4 -0
- package/dist/template-eval.d.ts +7 -0
- package/dist/template-eval.js +54 -6
- package/dist/templates.d.ts +3 -1
- package/dist/templates.js +14 -1
- package/dist/timeline/computer.js +2 -1
- package/dist/tool-list.js +1 -0
- package/dist/tools.d.ts +7 -0
- package/dist/tools.js +11 -0
- package/dist/trigger-feed.js +67 -18
- package/dist/validate.js +7 -2
- package/dist/workspace/computer-for-claim.d.ts +7 -0
- package/dist/workspace/computer-for-claim.js +12 -2
- package/dist/workspace/paths.d.ts +4 -0
- package/dist/workspace/paths.js +9 -0
- package/dist/workspace/resolve-computer.d.ts +3 -1
- package/launcher/agentrun-serve +31 -24
- package/package.json +10 -9
- package/templates/README.md +11 -2
- package/dist/console/assets/index-COGhx_2Z.js +0 -711
|
@@ -135,9 +135,13 @@ export interface AdapterSpecDeps {
|
|
|
135
135
|
* or standalone runner's loopback is its host's other services. */
|
|
136
136
|
readonly mcpLoopback?: boolean;
|
|
137
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) never goes to
|
|
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
139
|
* their ports, as the server's own requests never do. */
|
|
140
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[]>;
|
|
141
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
|
|
142
146
|
* runner, in the eval's process, is given it (runner/beside.ts); no environment variable, flag, setting or API field
|
|
143
147
|
* maps onto it. Absent, or undefined for a run: none. */
|
|
@@ -315,9 +319,20 @@ export declare function buildToolHost(opts: {
|
|
|
315
319
|
readonly toolSettings?: unknown;
|
|
316
320
|
/** The run's template eval fakes, where the eval's own runner gives them (AdapterSpecDeps.evalFakes). */
|
|
317
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[];
|
|
318
326
|
}): ToolHost;
|
|
319
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
|
|
320
328
|
* catalog name and wrapped as the hands are (host-tools.ts hostToolOf, with `ctx`), the one binding the pi spec and the
|
|
321
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
|
|
322
330
|
* paid requests on the run's one ledger itself (bookedIn): they carry no settle of their own. */
|
|
323
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";
|
|
@@ -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.
|
|
@@ -298,7 +300,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
298
300
|
// words before the session opens. The seal key is the runner's own (deps.sealKey), not re-read from the environment.
|
|
299
301
|
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactor.
|
|
300
302
|
const hold = (values) => cut.hold(values);
|
|
301
|
-
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 });
|
|
302
304
|
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
303
305
|
holds.hold({ passed: mcp });
|
|
304
306
|
// The run's computer, from the one shared claim-time function (the CLI spec takes the same): none for a runner place, a
|
|
@@ -312,8 +314,9 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
312
314
|
// A person's stop ends the claim's waits at once: a first image pull or registration (Agent37's runs minutes) among them.
|
|
313
315
|
// Whether an earlier claim made the run a computer of its own is the run's journal's to say (hadComputer): a later
|
|
314
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
|
|
315
|
-
// computer a park kept, attached again, brings its mount credential with it (inheritMount): none is minted.
|
|
316
|
-
|
|
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) } : {}) });
|
|
317
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
|
|
318
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).
|
|
319
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,
|
|
@@ -460,7 +463,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
460
463
|
// chosen before the learned_workflow tool is bound, so the tool runs the text that serves. Only a promoted digest
|
|
461
464
|
// serves (runner/promotion.ts: replayed on the agent's graded inputs first, or promoted on its dry run with fewer than
|
|
462
465
|
// five); while the folder's revision replays or is held, the champion (the digest promoted last) serves in its place
|
|
463
|
-
// (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the
|
|
466
|
+
// (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the agent takes the run.
|
|
464
467
|
const promotion = claimPromotion({
|
|
465
468
|
store: deps.store, agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, launch, context, log, folder: learningFolder, shown, sealKey: deps.sealKey,
|
|
466
469
|
});
|
|
@@ -502,7 +505,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
502
505
|
// An agent whose computer is a browser the claim started gets the browser tool on that one session (tools.ts).
|
|
503
506
|
const claimBrowser = computer.computer?.kind === "browser" ? computer.computer.browser : undefined;
|
|
504
507
|
const fakes = deps.evalFakes?.(runRow.agentId);
|
|
505
|
-
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 } : {}) };
|
|
506
509
|
gate.askedOn(host);
|
|
507
510
|
// The run's tools. The hands (read/write/edit/bash and the background tools) are the kernel registry's over the run's
|
|
508
511
|
// Workspace and computer (runTools.hostTools); the gate is the adapter loop's own (spec.gate), so they run as asked.
|
|
@@ -842,6 +845,8 @@ export function buildToolHost(opts) {
|
|
|
842
845
|
...(web ? { web } : {}),
|
|
843
846
|
...(now ? { now } : {}),
|
|
844
847
|
...(email ? { emailFake: email } : {}),
|
|
848
|
+
...(opts.loopback ? { calendarLoopback: true } : {}),
|
|
849
|
+
...(opts.own ? { serverOwn: opts.own } : {}),
|
|
845
850
|
// The run's directory and its per-claim environment: the hands come from runTools, so the non-hand tools get the run's
|
|
846
851
|
// environment only.
|
|
847
852
|
where: { root, work: root, ref: { id: claim.runId } },
|
|
@@ -931,3 +936,12 @@ async function bindNonHandTools(host, kind, granted, run, context, results, root
|
|
|
931
936
|
// seam when it lands; never a second journalSessions + runCap over the one journal (the double-book we closed).
|
|
932
937
|
return tools;
|
|
933
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.js
CHANGED
|
@@ -63,7 +63,7 @@ export async function runnerBeside(dataDir, { loops, drainMs, env, janitor, hub,
|
|
|
63
63
|
const { hostCommandRefusals } = await import("../computers.js");
|
|
64
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 } : {}) });
|
|
65
65
|
// `mcpLoopback`: the server beside it is a local install (Serve.localInstall), so its runs may reach an MCP server on
|
|
66
|
-
// 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
67
|
// loopback read never goes to. A run's log lines (a learning run's skipped generality check) go to
|
|
68
68
|
// stderr with the runner's other lines. `evalFakes`: the template eval's fakes (EvalFakes: a case's web, now, monid and
|
|
69
69
|
// email), by the agent each of its runs is of; only the eval, in its own process, hands them. `harnessInstall`: what a
|
|
@@ -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";
|
|
@@ -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
|
|
@@ -378,8 +380,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
378
380
|
// whose computer is a browser is refused in words at its claim, before anything is made.
|
|
379
381
|
// A person's stop ends the claim's waits at once: a first image pull or registration (Agent37's runs minutes) among them.
|
|
380
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
|
|
381
|
-
// spec asks it. The computer a park kept, attached again, brings its mount credential with it (inheritMount).
|
|
382
|
-
|
|
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) } : {}) });
|
|
383
386
|
holds.hold({ computer });
|
|
384
387
|
const loopComputer = loopComputerOf(computer.computer, computer.held, computer.made);
|
|
385
388
|
const heldComputer = heldSpecOf(launch, loopComputer);
|
|
@@ -550,7 +553,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
550
553
|
// chosen before the learned_workflow tool is bound, so the tool runs the text that serves. Only a promoted digest
|
|
551
554
|
// serves (runner/promotion.ts: replayed on the agent's graded inputs first, or promoted on its dry run with fewer than
|
|
552
555
|
// five); while the folder's revision replays or is held, the champion (the digest promoted last) serves in its place
|
|
553
|
-
// (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the
|
|
556
|
+
// (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the agent takes the run.
|
|
554
557
|
const promotion = claimPromotion({
|
|
555
558
|
store: deps.store, agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, launch, context, log, folder: learningFolder, shown, sealKey: deps.sealKey,
|
|
556
559
|
});
|
|
@@ -583,7 +586,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
583
586
|
toolEnv[TOOL_PLANE_ENV] = JSON.stringify(launch.plane);
|
|
584
587
|
if (webNames.length) {
|
|
585
588
|
life = hostLifecycle();
|
|
586
|
-
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 });
|
|
587
590
|
gate.askedOn(host);
|
|
588
591
|
webTools = await webHostTools(host, granted, ctx);
|
|
589
592
|
}
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import { type Grade } from "../learn/promote.js";
|
|
2
2
|
import type { RunPath } from "../learning-cost.js";
|
|
3
3
|
import { type Command, type Store } from "../store/store.js";
|
|
4
|
-
export declare const FEEDBACK_ROUNDS: readonly ["
|
|
4
|
+
export declare const FEEDBACK_ROUNDS: readonly ["look_back"];
|
|
5
5
|
export type FeedbackRound = (typeof FEEDBACK_ROUNDS)[number];
|
|
6
6
|
/** A feedback round, as its steer's body carries it (`feedback`) and its FEEDBACK entry keeps it: the round, whether the
|
|
7
|
-
* grade said right,
|
|
7
|
+
* grade said right, and the grade's words (`text`). */
|
|
8
8
|
export interface FeedbackData {
|
|
9
9
|
readonly round: FeedbackRound;
|
|
10
10
|
readonly correct: boolean;
|
|
11
|
-
readonly workflow?: string;
|
|
12
11
|
readonly text: string;
|
|
13
12
|
}
|
|
14
|
-
/** What a grade asks for: `
|
|
15
|
-
*
|
|
13
|
+
/** What a grade asks for: `look_back` for a graded run the agent finished when the grade has words, else none
|
|
14
|
+
* (undefined): a run its learned workflow answered alone opens none, right or wrong (its grade is kept). A replay run
|
|
15
|
+
* is never graded. */
|
|
16
16
|
export declare function feedbackRoundOf(grade: {
|
|
17
|
-
readonly correct: boolean;
|
|
18
17
|
readonly path: RunPath;
|
|
19
|
-
readonly workflow?: string;
|
|
20
18
|
}, label: string | undefined): FeedbackRound | undefined;
|
|
21
|
-
/** The grade's words as the round says them: its `label`, else the fields a right answer holds (`expected`), else
|
|
22
|
-
* "(no words)". Never the verdict: feedbackAsk and the compile ask each say it once. (A right grade opens a round only
|
|
23
|
-
* with a label (feedbackRoundOf), so none reaches here without one.) */
|
|
24
|
-
export declare function feedbackWords(label: string | undefined, expected: Readonly<Record<string, unknown>> | undefined): string;
|
|
25
19
|
/** The feedback round a steer's body asks for (`body.feedback`, the server's own: server.ts gradeRun writes it, and the
|
|
26
20
|
* message API never does), else undefined. */
|
|
27
21
|
export declare function feedbackOf(body: unknown): FeedbackData | undefined;
|
|
@@ -31,17 +25,8 @@ export declare function pendingFeedbackOf(entries: readonly {
|
|
|
31
25
|
readonly kind: string;
|
|
32
26
|
readonly data?: unknown;
|
|
33
27
|
}[]): FeedbackData | undefined;
|
|
34
|
-
/** What the end-of-run turn of a feedback round is told before its prompt:
|
|
35
|
-
|
|
36
|
-
* (`job`, `served`); then the grade and its words. The look-back keeps notes only: a revision's ask to give the workflow
|
|
37
|
-
* again changed is the compile turn's, after it (learning-end.ts compileAskOf reads the round, learn/compile.ts asks). */
|
|
38
|
-
export declare function feedbackAsk(feedback: FeedbackData, seen?: {
|
|
39
|
-
readonly job: string;
|
|
40
|
-
readonly served: {
|
|
41
|
-
readonly workflow: string;
|
|
42
|
-
readonly answer: string;
|
|
43
|
-
};
|
|
44
|
-
}): string;
|
|
28
|
+
/** What the end-of-run turn of a feedback round is told before its prompt: the grade and its words. */
|
|
29
|
+
export declare function feedbackAsk(feedback: FeedbackData): string;
|
|
45
30
|
/** How a feedback round stands (GET /runs/{id}/learning `graded.feedback_status`): `running` until it settles; `ended`,
|
|
46
31
|
* its run took the grade's words and ended after them; `not_run`, its run ended before it took them. */
|
|
47
32
|
export declare const FEEDBACK_STATUSES: readonly ["running", "ended", "not_run"];
|
|
@@ -65,9 +50,8 @@ export interface OpenedRound {
|
|
|
65
50
|
readonly command: number;
|
|
66
51
|
}
|
|
67
52
|
/** Opens run `grade.run` again on the feedback round its grade asks for (feedbackRoundOf), with the grade's words
|
|
68
|
-
* (`label
|
|
69
|
-
* never one that only uses what was learned,
|
|
70
|
-
* feedback, neither archived nor of an archived
|
|
53
|
+
* (`label`), and says which, with its steer: only a run that learns (its launch's learning start,
|
|
54
|
+
* never one that only uses what was learned), whose runner supports managed feedback, neither archived nor of an archived
|
|
71
55
|
* agent (closed history: a grade of it starts no paid work), and one the store opens again (an agentic run that answered
|
|
72
56
|
* or that a person stopped). Null when the grade asks for nothing more, or the run can't be opened again (the grade is
|
|
73
57
|
* kept either way). */
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
// A grade's feedback round: what a run's grade (PUT /runs/{id}/grade, a person's feedback or an eval's label) asks of its
|
|
2
2
|
// learning, and how the run's next end reads it. The run's path is who wrote its final answer, so a grade never makes
|
|
3
3
|
// the agent answer the job again:
|
|
4
|
-
// - a run its learned workflow answered alone (path `workflow`), graded right: the grade is kept (
|
|
5
|
-
// read it) and nothing else happens: no turn, $0;
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// whose look-back hears the job, the workflow's answer and the grade's words (notes), and whose compile turn asks for
|
|
9
|
-
// the workflow again, changed (learning-end.ts compileAskOf). Its spend is learning spend, and the run's path stays
|
|
10
|
-
// `workflow`;
|
|
4
|
+
// - a run its learned workflow answered alone (path `workflow`), graded right or wrong: the grade is kept (the graded
|
|
5
|
+
// hold, replay and refit read it) and nothing else happens: no round, no turn, $0. One wrong answer is one sample;
|
|
6
|
+
// the graded hold reads it among the workflow's others, and a hold asks the workflow's revision (learning-end.ts
|
|
7
|
+
// compileAskOf);
|
|
11
8
|
// - a run the agent finished (path `agent` or `handed_back`) graded with words (`label`): a look-back round on them
|
|
12
|
-
// (#2579's later round, notes)
|
|
9
|
+
// (#2579's later round, notes). The run opens again on it: the grade's words are on its record, the agent is asked no
|
|
10
|
+
// turn of the job's, and the run goes straight to its end-of-run turn, which reads the words. Its spend is learning
|
|
11
|
+
// spend.
|
|
13
12
|
// A grade with neither asks for nothing more. The server writes the round's steer (server.ts gradeRun, runs.reopen); the
|
|
14
13
|
// adapter loop takes it (adapter-loop.ts steer: a FEEDBACK entry, no turn), and the end-of-run step reads it
|
|
15
14
|
// (learning-end.ts: heard, never "nothing new"; adapter-loop.ts askEndOfRun: feedbackAsk before the prompt).
|
|
@@ -18,24 +17,12 @@ import { readLaunchBody } from "../run-launch.js";
|
|
|
18
17
|
import { RunFinal } from "../store/store.js";
|
|
19
18
|
import { KINDS } from "./journal-kinds.js";
|
|
20
19
|
import { commandRequest } from "./loop.js";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
20
|
+
export const FEEDBACK_ROUNDS = ["look_back"];
|
|
21
|
+
/** What a grade asks for: `look_back` for a graded run the agent finished when the grade has words, else none
|
|
22
|
+
* (undefined): a run its learned workflow answered alone opens none, right or wrong (its grade is kept). A replay run
|
|
23
|
+
* is never graded. */
|
|
25
24
|
export function feedbackRoundOf(grade, label) {
|
|
26
|
-
|
|
27
|
-
return !grade.correct && grade.workflow ? "revise" : undefined;
|
|
28
|
-
if (grade.path === "agent" || grade.path === "handed_back")
|
|
29
|
-
return label ? "look_back" : undefined;
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
/** The grade's words as the round says them: its `label`, else the fields a right answer holds (`expected`), else
|
|
33
|
-
* "(no words)". Never the verdict: feedbackAsk and the compile ask each say it once. (A right grade opens a round only
|
|
34
|
-
* with a label (feedbackRoundOf), so none reaches here without one.) */
|
|
35
|
-
export function feedbackWords(label, expected) {
|
|
36
|
-
if (label?.trim())
|
|
37
|
-
return label.trim();
|
|
38
|
-
return expected ? `A right answer holds: ${JSON.stringify(expected)}` : "(no words)";
|
|
25
|
+
return (grade.path === "agent" || grade.path === "handed_back") && label ? "look_back" : undefined;
|
|
39
26
|
}
|
|
40
27
|
/** The feedback round a steer's body asks for (`body.feedback`, the server's own: server.ts gradeRun writes it, and the
|
|
41
28
|
* message API never does), else undefined. */
|
|
@@ -44,7 +31,7 @@ export function feedbackOf(body) {
|
|
|
44
31
|
const text = body?.text;
|
|
45
32
|
if (!fed || typeof fed !== "object" || !FEEDBACK_ROUNDS.includes(fed.round) || typeof fed.correct !== "boolean" || typeof text !== "string")
|
|
46
33
|
return undefined;
|
|
47
|
-
return { round: fed.round, correct: fed.correct,
|
|
34
|
+
return { round: fed.round, correct: fed.correct, text };
|
|
48
35
|
}
|
|
49
36
|
/** The feedback round the run's root `entries` say its next end closes: its newest FEEDBACK entry when no end came after
|
|
50
37
|
* it, else undefined. */
|
|
@@ -54,13 +41,9 @@ export function pendingFeedbackOf(entries) {
|
|
|
54
41
|
return undefined;
|
|
55
42
|
return feedbackOf({ feedback: entries[at].data, text: entries[at].data?.text });
|
|
56
43
|
}
|
|
57
|
-
/** What the end-of-run turn of a feedback round is told before its prompt:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
* again changed is the compile turn's, after it (learning-end.ts compileAskOf reads the round, learn/compile.ts asks). */
|
|
61
|
-
export function feedbackAsk(feedback, seen) {
|
|
62
|
-
const graded = `A reviewer graded ${seen ? "that" : "this run's"} answer ${feedback.correct ? "right" : "wrong"}. What they said:`;
|
|
63
|
-
return [...(seen ? [seen.job, servedAnswerText(seen.served.workflow, seen.served.answer)] : []), graded, "", feedback.text].join("\n\n").replace(/\n{3,}/g, "\n\n");
|
|
44
|
+
/** What the end-of-run turn of a feedback round is told before its prompt: the grade and its words. */
|
|
45
|
+
export function feedbackAsk(feedback) {
|
|
46
|
+
return [`A reviewer graded this run's answer ${feedback.correct ? "right" : "wrong"}. What they said:`, "", feedback.text].join("\n\n").replace(/\n{3,}/g, "\n\n");
|
|
64
47
|
}
|
|
65
48
|
/** How a feedback round stands (GET /runs/{id}/learning `graded.feedback_status`): `running` until it settles; `ended`,
|
|
66
49
|
* its run took the grade's words and ended after them; `not_run`, its run ended before it took them. */
|
|
@@ -83,16 +66,15 @@ export function feedbackStatus(entries, command) {
|
|
|
83
66
|
return command.refused !== null ? "not_run" : "running";
|
|
84
67
|
}
|
|
85
68
|
/** Opens run `grade.run` again on the feedback round its grade asks for (feedbackRoundOf), with the grade's words
|
|
86
|
-
* (`label
|
|
87
|
-
* never one that only uses what was learned,
|
|
88
|
-
* feedback, neither archived nor of an archived
|
|
69
|
+
* (`label`), and says which, with its steer: only a run that learns (its launch's learning start,
|
|
70
|
+
* never one that only uses what was learned), whose runner supports managed feedback, neither archived nor of an archived
|
|
89
71
|
* agent (closed history: a grade of it starts no paid work), and one the store opens again (an agentic run that answered
|
|
90
72
|
* or that a person stopped). Null when the grade asks for nothing more, or the run can't be opened again (the grade is
|
|
91
73
|
* kept either way). */
|
|
92
74
|
export async function openFeedbackRound(store, grade, label) {
|
|
93
75
|
const words = label?.trim() ? label.trim() : undefined;
|
|
94
76
|
const round = feedbackRoundOf(grade, words);
|
|
95
|
-
if (!round)
|
|
77
|
+
if (!round || !words)
|
|
96
78
|
return null;
|
|
97
79
|
const run = await store.runs.get(grade.run);
|
|
98
80
|
if (!run || run.archivedAt !== null || (await store.agents.get(run.agentId))?.archivedAt !== null)
|
|
@@ -103,11 +85,11 @@ export async function openFeedbackRound(store, grade, label) {
|
|
|
103
85
|
if (launch?.native || launch?.sdk)
|
|
104
86
|
return null;
|
|
105
87
|
const learning = launch?.learning;
|
|
106
|
-
if (!learning || learning.use
|
|
88
|
+
if (!learning || learning.use)
|
|
107
89
|
return null;
|
|
108
|
-
const feedback = { round, correct: grade.correct
|
|
90
|
+
const feedback = { round, correct: grade.correct };
|
|
109
91
|
try {
|
|
110
|
-
const steer = await store.runs.reopen(grade.run, { kind: "steer", body: { text:
|
|
92
|
+
const steer = await store.runs.reopen(grade.run, { kind: "steer", body: { text: words, feedback } });
|
|
111
93
|
return { round, command: steer.id };
|
|
112
94
|
}
|
|
113
95
|
catch (error) {
|
|
@@ -78,6 +78,15 @@ export declare function modelsOwn(rows: readonly TimelineEvent[]): (row: Timelin
|
|
|
78
78
|
* came in. Anything else is asked its end-of-run turn. Read on the job's turns (withoutFeedbackRounds): a grade's
|
|
79
79
|
* feedback round is no message of the job's. */
|
|
80
80
|
export declare function onlyLearnedWorkflows(rows: readonly TimelineEvent[]): boolean;
|
|
81
|
+
/** Whether a run carries its owner's feedback, the only thing a run of a job that compiles workflows is looked back on
|
|
82
|
+
* for: a grade's words its end closes (a feedback round, feedback-round.ts pendingFeedbackOf over its root `entries`),
|
|
83
|
+
* or a person's message after its first in its timeline `rows` (a follow-up, or a word while it ran: traceFrom's
|
|
84
|
+
* feedback), the end-of-run turn's own, a grade's round's and a subagent's (a child conversation's rows carry its
|
|
85
|
+
* spawning call, parent_tool_use_id: its task prompt is the job's, not the owner's) rows left out. */
|
|
86
|
+
export declare function ownerSaid(entries: readonly {
|
|
87
|
+
readonly kind: string;
|
|
88
|
+
readonly data?: unknown;
|
|
89
|
+
}[], rows: readonly TimelineEvent[]): boolean;
|
|
81
90
|
/** The path a run took (learning-cost.ts RunPath), by its timeline `rows` as runTimeline labels them (its end-of-run
|
|
82
91
|
* turn's rows, LEARNING_LABEL, are the learning's and left out): `workflow` when its job did only what
|
|
83
92
|
* onlyLearnedWorkflows asks of a run with nothing new to look back on, `handed_back` when it called a learned workflow
|
|
@@ -99,12 +108,14 @@ export declare function traceOf(store: Store, runId: string, refuse: readonly st
|
|
|
99
108
|
* shape. */
|
|
100
109
|
export declare function traceFrom(timeline: readonly TimelineEvent[], refuse: readonly string[]): CompileTrace;
|
|
101
110
|
/** The compile turn's facts for run `runId` of agent `agentId` (learn/compile.ts): a revision of the learned workflow
|
|
102
|
-
* that
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* agent
|
|
106
|
-
*
|
|
107
|
-
* of its last COMPILE_QUIET_RUNS runs compiled, and it
|
|
111
|
+
* that fits the run's input and whose promotion holds it at main's digest (runner/promotion.ts: its replay on the
|
|
112
|
+
* agent's graded inputs, or its graded served runs, fell under the bar; its champion served the run, or the agent did by
|
|
113
|
+
* hand), its text as main holds it, with the hold's numbers, once per hold (none when any run since the hold compiled
|
|
114
|
+
* it, read from the agent's kept learning; a check's hold with the inputs it disagreed on, a stopped check's none);
|
|
115
|
+
* else, when the job is due (compileDue: the run completed, the agent has no learned workflow active or waiting, none
|
|
116
|
+
* of its last COMPILE_QUIET_RUNS runs compiled, and it has its definition's compile_after completed agent runs), a new
|
|
117
|
+
* one. Nothing else asks one: a hand-back, a wrong grade of a served answer and the money rule's
|
|
118
|
+
* stop are single runs, which the hold reads among many. Either way the
|
|
108
119
|
* agent's active notes whole, the traces of its last COMPILE_TRACES completed runs before this one, the tools a call node
|
|
109
120
|
* may run (draftTools) with what each takes and gives, its decision providers, the run's input (`input`, its fields for
|
|
110
121
|
* the workflow's input schema), the agent's output schema when it has one (its final output's shape) and the DSL's
|
|
@@ -116,6 +127,5 @@ export declare function compileAskOf(deps: LearningEndDeps, input: {
|
|
|
116
127
|
outcome: "completed" | "failed";
|
|
117
128
|
refuse: readonly string[];
|
|
118
129
|
input?: unknown;
|
|
119
|
-
seedNotes?: number;
|
|
120
130
|
seedWorkflows?: number;
|
|
121
131
|
}): Promise<CompileAsk | undefined>;
|