@parcha/agentrun-serve 0.1.0-beta.60 → 0.1.0-beta.62
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 +124 -0
- package/README.md +139 -22
- package/dist/acp-package.d.ts +4 -0
- package/dist/api-only.d.ts +23 -1
- package/dist/api-only.js +43 -4
- package/dist/archil-settings.d.ts +9 -0
- package/dist/archil-settings.js +8 -1
- package/dist/bash-read-only.d.ts +3 -0
- package/dist/bash-read-only.js +6 -3
- package/dist/browser-person.d.ts +1 -1
- package/dist/browser-person.js +1 -1
- package/dist/calendar/tools.js +1 -1
- package/dist/chatgpt-plan.d.ts +26 -8
- package/dist/chatgpt-plan.js +89 -21
- package/dist/claude-login.d.ts +12 -5
- package/dist/claude-login.js +28 -3
- package/dist/cli.js +61 -18
- package/dist/composio-triggers.d.ts +9 -3
- package/dist/computers.d.ts +3 -0
- package/dist/computers.js +2 -1
- package/dist/console/assets/{backend-QnwGVBeU.js → backend-DEgVn5lC.js} +1 -1
- package/dist/console/assets/index-CG5tELph.js +639 -0
- package/dist/console/assets/share-CIeFK2Oe.js +6 -0
- package/dist/console/assets/{styles-CcceGcu2.js → styles-BGZxYkky.js} +2 -2
- package/dist/console/assets/{styles-fjQBFfMv.css → styles-D0SufbzK.css} +1 -1
- package/dist/console/index.html +3 -3
- package/dist/console/share.html +3 -3
- package/dist/cut-pool.d.ts +14 -0
- package/dist/cut-pool.js +98 -0
- package/dist/cut-worker.d.ts +14 -0
- package/dist/cut-worker.js +16 -0
- package/dist/decisions.d.ts +4 -0
- package/dist/decisions.js +9 -1
- package/dist/env-switch.d.ts +3 -0
- package/dist/env-switch.js +3 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/harness-check.js +2 -1
- package/dist/harness-recipe.d.ts +13 -2
- package/dist/harness-recipe.js +30 -7
- package/dist/harness-sign-in.js +2 -1
- package/dist/harness-table.d.ts +12 -3
- package/dist/harness-table.js +13 -8
- package/dist/import.d.ts +8 -1
- package/dist/import.js +36 -5
- package/dist/key-check.js +22 -8
- package/dist/key-refusal.js +6 -4
- package/dist/learn/secrets.d.ts +2 -1
- package/dist/learn/secrets.js +2 -2
- package/dist/learned-nodes.d.ts +37 -0
- package/dist/learned-nodes.js +24 -0
- package/dist/local-model.d.ts +144 -0
- package/dist/local-model.js +214 -0
- package/dist/mcp-gateway.d.ts +24 -0
- package/dist/mcp-gateway.js +97 -8
- package/dist/mcp-probe.d.ts +7 -0
- package/dist/mcp-probe.js +7 -0
- package/dist/mcp-servers-store.d.ts +7 -10
- package/dist/mcp-servers-store.js +15 -9
- package/dist/native/cli.js +5 -1
- package/dist/ollama-provider.d.ts +42 -0
- package/dist/ollama-provider.js +118 -2
- package/dist/openapi.js +85 -16
- package/dist/otel/tracer.d.ts +6 -3
- package/dist/otel/tracer.js +24 -6
- package/dist/page.d.ts +7 -0
- package/dist/page.js +17 -4
- package/dist/place.d.ts +28 -11
- package/dist/place.js +43 -14
- package/dist/print.d.ts +3 -2
- package/dist/print.js +8 -6
- package/dist/redact/match.d.ts +17 -4
- package/dist/redact/match.js +57 -15
- package/dist/run-export.js +4 -2
- package/dist/run-launch.js +16 -3
- package/dist/run-model-key.d.ts +2 -1
- package/dist/run-model-key.js +2 -1
- package/dist/run-reads-over-store.d.ts +7 -0
- package/dist/run-reads-over-store.js +32 -4
- package/dist/run-usage.js +3 -2
- package/dist/runnable.d.ts +6 -3
- package/dist/runnable.js +16 -6
- package/dist/runner/adapter-loop.d.ts +8 -1
- package/dist/runner/adapter-loop.js +148 -29
- package/dist/runner/adapter-run-spec.d.ts +9 -6
- package/dist/runner/adapter-run-spec.js +38 -52
- package/dist/runner/adapters/index.d.ts +4 -0
- package/dist/runner/adapters/index.js +2 -1
- package/dist/runner/adapters/pi.d.ts +3 -2
- package/dist/runner/adapters/pi.js +3 -1
- package/dist/runner/audit.d.ts +1 -1
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +18 -7
- package/dist/runner/cli-run-spec.js +24 -17
- package/dist/runner/compare-end.d.ts +1 -1
- package/dist/runner/dispatch.js +4 -2
- package/dist/runner/harness-loops.d.ts +14 -0
- package/dist/runner/harness-loops.js +51 -5
- package/dist/runner/held.d.ts +4 -1
- package/dist/runner/live-ticker.js +5 -4
- package/dist/runner/loop-contract.d.ts +4 -1
- package/dist/runner/mcp-claim.js +3 -2
- package/dist/runner/mcp-run.d.ts +24 -4
- package/dist/runner/mcp-run.js +47 -2
- package/dist/runner/meta-tools.js +4 -4
- package/dist/runner/metrics.d.ts +6 -0
- package/dist/runner/metrics.js +12 -4
- package/dist/runner/monid-run.js +3 -1
- package/dist/runner/native-loop.js +3 -3
- package/dist/runner/redact.d.ts +3 -0
- package/dist/runner/redact.js +7 -0
- package/dist/runner/run-child-host.d.ts +10 -6
- package/dist/runner/run-child-host.js +44 -29
- package/dist/runner/run-child.js +1 -0
- package/dist/runner/runner.js +2 -0
- package/dist/runner/sdk-loop.js +5 -3
- package/dist/runner/workflow-calls.d.ts +5 -1
- package/dist/runner/workflow-calls.js +65 -19
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +3 -1
- package/dist/runner/workflow-spec.d.ts +4 -0
- package/dist/runner/workflow-spec.js +18 -13
- package/dist/runs-over-store.d.ts +2 -2
- package/dist/runs-over-store.js +1 -1
- package/dist/secret-cut.js +7 -4
- package/dist/secret-rules.d.ts +0 -1
- package/dist/secret-rules.js +122 -88
- package/dist/server.d.ts +17 -1
- package/dist/server.js +208 -69
- package/dist/share-host.d.ts +111 -0
- package/dist/share-host.js +666 -0
- package/dist/slack.js +2 -1
- package/dist/store/postgres/migrate.js +3 -1
- package/dist/store-reads/analytics.d.ts +15 -0
- package/dist/store-reads/analytics.js +17 -0
- package/dist/store-reads/learning.d.ts +5 -4
- package/dist/store-reads/learning.js +7 -4
- package/dist/suggestions.js +32 -3
- package/dist/templates.d.ts +3 -1
- package/dist/templates.js +7 -3
- package/dist/tool-gate.d.ts +25 -9
- package/dist/tool-gate.js +58 -19
- package/dist/tool-plane.d.ts +24 -1
- package/dist/tool-plane.js +75 -3
- package/dist/tools.d.ts +12 -2
- package/dist/tools.js +42 -7
- package/dist/trigger-composio.js +1 -1
- package/dist/trigger-launch-hook.d.ts +2 -2
- package/dist/trigger-launch-hook.js +1 -1
- package/dist/triggers.d.ts +7 -4
- package/dist/triggers.js +4 -4
- package/dist/webhooks.d.ts +3 -0
- package/dist/webhooks.js +5 -0
- package/dist/workspace/archil-claim.d.ts +7 -3
- package/dist/workspace/archil-claim.js +13 -5
- package/dist/workspace/archil-mount-credential.d.ts +6 -0
- package/dist/workspace/archil-mount-credential.js +11 -0
- package/dist/workspace/computer-deps.d.ts +5 -3
- package/dist/workspace/computer-deps.js +11 -9
- package/dist/workspace/computer-for-claim.d.ts +6 -2
- package/dist/workspace/computer-for-claim.js +43 -12
- package/dist/workspace/computer-janitor.d.ts +7 -4
- package/dist/workspace/computer-janitor.js +7 -4
- package/dist/workspace/computer-kept.d.ts +7 -1
- package/dist/workspace/computer-kept.js +7 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +12 -3
- package/dist/workspace/mount-revoke-left.d.ts +16 -4
- package/dist/workspace/mount-revoke-left.js +42 -22
- package/dist/workspace/resolve-computer.d.ts +11 -5
- package/dist/workspace/resolve-computer.js +22 -13
- package/dist/workspace/run-end-computers.js +1 -1
- package/dist/workspace/run-tools.d.ts +10 -3
- package/dist/workspace/run-tools.js +5 -4
- package/dist/wrapped.d.ts +29 -2
- package/dist/wrapped.js +20 -3
- package/launcher/agentrun-serve +1 -1
- package/package.json +12 -12
- package/dist/console/assets/index-DZi-muIj.js +0 -629
- package/dist/console/assets/share-pz61zIn9.js +0 -6
package/dist/runnable.js
CHANGED
|
@@ -11,7 +11,8 @@ import { harnessOf, onAdapter } from "./harness-table.js";
|
|
|
11
11
|
import { capShortOf } from "./cap-short.js";
|
|
12
12
|
import { chooseModel } from "./model.js";
|
|
13
13
|
import { llmTiers, MODEL_NODES, nodeTiers, unpricedModels, workflowNodes } from "./model.js";
|
|
14
|
-
import {
|
|
14
|
+
import { noExecWords } from "./archil-settings.js";
|
|
15
|
+
import { boxAvailability, newAgentPlace, noExecIssue, noPlaceIssue, placeFix } from "./place.js";
|
|
15
16
|
import { allows, BOUND_TOOLS, CALL_TOOLS, grantedTools, missingEnv, NODE_TOOLS, shellTools, toolOf, workflowTools } from "./tools.js";
|
|
16
17
|
import { DENIED, isUnavailable, NO_PARALLEL_KEY, planeFor, whyUnavailable } from "./tool-plane.js";
|
|
17
18
|
import { computerDenied, denyPlace, permissionFrom, permissionKeys, permissionOf } from "./tool-gate.js";
|
|
@@ -69,9 +70,11 @@ export async function deniedComputer(revision, settings, shellOf) {
|
|
|
69
70
|
* setting can be had here now, or its refusal (resolve-computer.ts computerReadiness); none given, the box check.
|
|
70
71
|
* `shellOf`: where a run of an agent with that computer setting has its shell here now (resolve-computer.ts
|
|
71
72
|
* runShellOf, in the server's mode): a sandbox-only tool on the runner is let by it (Mode 2's Archil exec runs bash);
|
|
72
|
-
* none given, the runner has no shell. `
|
|
73
|
-
*
|
|
74
|
-
|
|
73
|
+
* none given, the runner has no shell. `noExec`: in Mode 2, the server's Archil region where it has no serverless exec
|
|
74
|
+
* (archil-settings.ts noExecRegionOf), so a sandbox-only tool on the runner names a sandbox computer, never Docker's box,
|
|
75
|
+
* which can't mount Archil. `capUsd`: a save's cap (with `capped`), whose shortfall for one more step and an answer is
|
|
76
|
+
* a warning of its own (`short`, cap-short.ts); a run's check never names one. */
|
|
77
|
+
export async function blockersOf(env, revision, settings = {}, { capped = false, capUsd, boxes = [], offers, mcp, monid, decisionPrice, computerReady, shellOf, noExec } = {}) {
|
|
75
78
|
const out = [];
|
|
76
79
|
/** A web tool its run would resolve unavailable (tool-plane.ts): a warning at save, a 409 at a run, never another
|
|
77
80
|
* provider in its place. One set to deny is not: its run starts, and the gate refuses each call. */
|
|
@@ -124,6 +127,12 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
|
|
|
124
127
|
* Docker's box is not here and both ways out, fixing that or keeping the agent on the runner without the tool. Where
|
|
125
128
|
* the runner has a shell that runs others (Mode 2's Archil exec runs bash), it says which. */
|
|
126
129
|
const shellOnRunner = (tool, field, named) => {
|
|
130
|
+
// On a Mode 2 region with no exec the runner has no shell and Docker's box can't mount Archil: a sandbox computer is
|
|
131
|
+
// the one way to run the tool. With no place named, in the words its save is refused in (noExecIssue).
|
|
132
|
+
if (noExec !== undefined && !named)
|
|
133
|
+
return { ...noExecIssue(noExec), host: false, tool };
|
|
134
|
+
if (noExec !== undefined)
|
|
135
|
+
return { field, reason: "not_an_option", message: `${tool} runs only in a box, and this agent's place is the runner, which has no shell here: ${noExecWords(noExec)}, and the docker box can't mount Archil. Give it a sandbox computer (a box), or remove "${tool}" from definition.tools.`, fix: `Remove "${tool}" from definition.tools.`, host: false, tool };
|
|
127
136
|
const fresh = newAgentPlace(boxes);
|
|
128
137
|
if (!named && !runnerShell.size && "reason" in fresh) {
|
|
129
138
|
// A tool the box refuses (the browser) keeps this agent out of every box, so naming one is no way out: its words
|
|
@@ -212,10 +221,11 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
|
|
|
212
221
|
if (!allows(BOUND_TOOLS, tool))
|
|
213
222
|
out.push({ field: `definition.tools[${index}]`, reason: "not_an_option", message: `${tool} is not a tool here: grant one of ${BOUND_TOOLS.join(", ")}, an MCP server's tool as mcp:<server>/<tool>, or a monid endpoint as monid:<provider>/<endpoint>.`, host: false, tool });
|
|
214
223
|
// A shell runs in a box; on the runner (no place names one) only what its shell here runs (runnerShell).
|
|
215
|
-
// One that names no place is refused
|
|
224
|
+
// One that names no place is refused once, whatever shell tools it names: at its place (Mode 1), or at its computer
|
|
225
|
+
// on a Mode 2 region with no exec.
|
|
216
226
|
else if (toolOf(tool).sandboxOnly && (place?.mode ?? "runner") === "runner" && !runnerShell.has(tool)) {
|
|
217
227
|
const blocker = shellOnRunner(tool, `definition.tools[${index}]`, !!place && !revision.unnamed);
|
|
218
|
-
if (!out.some((b) => b.field ===
|
|
228
|
+
if (!out.some((b) => b.field === blocker.field && b.message === blocker.message))
|
|
219
229
|
out.push(blocker);
|
|
220
230
|
}
|
|
221
231
|
// Its writes into work/ go by path from this machine, and a box's command could swap a link in on their way.
|
|
@@ -8,7 +8,7 @@ import { type GenAiTracing } from "../otel/tracer.js";
|
|
|
8
8
|
import { type AgentOfRun, type RouteTrace } from "../otel/genai.js";
|
|
9
9
|
type EndCost = Required<Pick<EndData, "costUsd" | "costUpperBound">>;
|
|
10
10
|
import { type Claim, type EndOfRunTurn, type LoopFactory } from "./loop-contract.js";
|
|
11
|
-
import type
|
|
11
|
+
import { type HeldRedact } from "./redact.js";
|
|
12
12
|
import { type BoundTimer, Parked } from "./loop.js";
|
|
13
13
|
import type { PiRun } from "./adapters/pi.js";
|
|
14
14
|
import { type HeldSpec } from "./held-run.js";
|
|
@@ -84,6 +84,13 @@ export type SpecGate = ((call: ToolCall, options?: {
|
|
|
84
84
|
/** A tool's setting now, by any name a call reaches the gate by (a harness's own, Codex's `web_search`), read again at
|
|
85
85
|
* each ask: what the session reads (SessionIO.permission) for a tool no call of which reaches the gate before it runs. */
|
|
86
86
|
readonly permission?: (tool: string) => Promise<"allow" | "ask" | "deny">;
|
|
87
|
+
/** The run's learned workflow a learned_workflow call's arguments name (its name and its digest, workflow-first.ts
|
|
88
|
+
* workflowDigest), or undefined for a name the run has none of: what the record of such a call the gate refuses
|
|
89
|
+
* names (learnedEntry). */
|
|
90
|
+
readonly learnedOf?: (args: unknown) => {
|
|
91
|
+
readonly workflow: string;
|
|
92
|
+
readonly digest: string;
|
|
93
|
+
} | undefined;
|
|
87
94
|
};
|
|
88
95
|
/** What one claimed run's adapter loop runs. */
|
|
89
96
|
export interface AdapterRunSpec {
|
|
@@ -20,6 +20,7 @@ import { ASK_PERSON_WAITING, capNowOf, endedAnswer, KINDS, MESSAGE_SENT_AGAIN, t
|
|
|
20
20
|
import { turnEndedOnAsk } from "../store-reads/journal.js";
|
|
21
21
|
import { CAP_REFUSED, CAP_WRAPUP, COMPUTER_NOTE, endsTurn, HOST_PHASE, MESSAGE_ORIGIN, originOf, REQUEST_ENDED, REQUEST_STARTED, RUN_RESUMED } from "../timeline/index.js";
|
|
22
22
|
import { raiseFollowUpId } from "../run-view.js";
|
|
23
|
+
import { connectedLaterWords } from "../mcp-probe.js";
|
|
23
24
|
import { durableWait } from "../workflow/pi-versions.js";
|
|
24
25
|
import { genAiTracing } from "../otel/tracer.js";
|
|
25
26
|
import { tracedAgent, tracedEvent, tracedModel } from "../otel/genai.js";
|
|
@@ -43,6 +44,7 @@ const outputRetried = (entries) => {
|
|
|
43
44
|
return at >= 0 && entries.slice(at + 1).some((entry) => entry.kind === "pi.assistant" || (entry.kind === KINDS.message && entry.data?.role === "model"));
|
|
44
45
|
};
|
|
45
46
|
import { ClaimRefused, deniedText, noteOf, stopEnd } from "./loop-contract.js";
|
|
47
|
+
import { mustHold } from "./redact.js";
|
|
46
48
|
import { deniedText as setToDenyText, ENDED_WHILE_WAITING, refusedText, STOPPED_WHILE_WAITING } from "../refusal-words.js";
|
|
47
49
|
import { ADAPTER_API } from "../turn-end.js";
|
|
48
50
|
import { answerText, REFLECT_PREFIX, reflectRequestId } from "./end-of-run.js";
|
|
@@ -68,7 +70,7 @@ import { Fenced } from "../store/index.js";
|
|
|
68
70
|
import { answerAsServed } from "../answer-json.js";
|
|
69
71
|
import { reserveFor, stepAndAnswerFor, wrappingUp, wrapUpText } from "../wrap-up.js";
|
|
70
72
|
import { LEARNED_CARD_FIELDS, LEARNED_CLIP, LEARNED_WORKFLOW_TOOL, learnedApprovedTools } from "../learned-workflow.js";
|
|
71
|
-
import { LEARNED_NODES } from "../learned-nodes.js";
|
|
73
|
+
import { failedRecord, LEARNED_ALLOWED, LEARNED_NODES, learnedCallRan, refusedRecord } from "../learned-nodes.js";
|
|
72
74
|
import { warnHoldShort } from "../print.js";
|
|
73
75
|
import { feedbackAsk, feedbackOf, jobEndOpen, pendingFeedbackOf } from "./feedback-round.js";
|
|
74
76
|
import { handbackText, servedAnswerOf, servedAnswerText, WORKFLOW_FIRST, WORKFLOW_FIRST_CALL } from "./workflow-first.js";
|
|
@@ -579,6 +581,7 @@ export function createAdapterLoop(spec, options = {}) {
|
|
|
579
581
|
return (deps) => adapterLoop(spec, options, deps);
|
|
580
582
|
}
|
|
581
583
|
function adapterLoop(specOf, options, deps) {
|
|
584
|
+
mustHold(deps.redact, "An adapter loop");
|
|
582
585
|
const restartLimit = options.restartLimit ?? DEFAULT_RESTART_LIMIT;
|
|
583
586
|
const retry = options.retry ?? MODEL_RETRY;
|
|
584
587
|
const stream = options.stream ?? MODEL_STREAM;
|
|
@@ -598,7 +601,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
598
601
|
* (LoopDeps.redact), since a provider's or a computer's error may echo one. */
|
|
599
602
|
const said = (error) => {
|
|
600
603
|
const text = error?.message ?? String(error);
|
|
601
|
-
return deps.redact
|
|
604
|
+
return deps.redact(text);
|
|
602
605
|
};
|
|
603
606
|
let stopped = () => { };
|
|
604
607
|
const stopping = new Promise((resolve) => (stopped = resolve));
|
|
@@ -697,8 +700,9 @@ function adapterLoop(specOf, options, deps) {
|
|
|
697
700
|
* The agent is asked no turn of the job's: the run goes to its end-of-run turn, told the grade first (feedbackAsk). */
|
|
698
701
|
let feedbackNow;
|
|
699
702
|
/** A reopen of a run whose session is still new (a person stopped it before its first input was sent): resolved once the
|
|
700
|
-
* person's message is placed as that first input
|
|
701
|
-
*
|
|
703
|
+
* person's message is placed as that first input, or once the reopen's own message was answered unplaced (command):
|
|
704
|
+
* then no message places it, and the claim ends the run on the end it had before, sending nothing. The claim waits on
|
|
705
|
+
* it, never sending the input they stopped, however late the runner hands the message over. */
|
|
702
706
|
let firstInputPlaced;
|
|
703
707
|
/** Resolved once a pass of this claim has sent what its session starts on (the run's input, a follow-up, a recovery),
|
|
704
708
|
* or found nothing to send: a message handed over while the session is still new waits for it, so it lands after the
|
|
@@ -710,6 +714,9 @@ function adapterLoop(specOf, options, deps) {
|
|
|
710
714
|
let waitHolds = [];
|
|
711
715
|
/** The wait's own `reopen`, while it is set. */
|
|
712
716
|
let waitTurn;
|
|
717
|
+
/** Ends the wait in the claim at once, the run parking on its question as a lapse does, though no host's hold lapsed:
|
|
718
|
+
* set while the wait holds (waitInClaim). */
|
|
719
|
+
let endWaitNow;
|
|
713
720
|
/** The `reopen` of a CLI run parked on its question (its turn cut there: no steer reaches its idle session), while it is
|
|
714
721
|
* set: the person's answer is the claim's turn, and a trigger's message is no answer. */
|
|
715
722
|
let askReopen;
|
|
@@ -772,6 +779,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
772
779
|
if (reopen === waitTurn)
|
|
773
780
|
reopen = undefined;
|
|
774
781
|
waitTurn = undefined;
|
|
782
|
+
endWaitNow = undefined;
|
|
775
783
|
for (const hold of waitHolds.splice(0)) {
|
|
776
784
|
try {
|
|
777
785
|
hold.drop();
|
|
@@ -820,6 +828,11 @@ function adapterLoop(specOf, options, deps) {
|
|
|
820
828
|
/** The pass's MCP (spec.mcp), until the pass ends; and whether a command row came since its credentials were last made
|
|
821
829
|
* fresh (a parked token may have expired meanwhile). */
|
|
822
830
|
let mcp;
|
|
831
|
+
/** The pass's phase row (AdapterRun.phase), until the pass ends; and whether a message of the pass was left for the
|
|
832
|
+
* run's next turn, as one handing the credential of a server its claim left out (steer): every message after it waits
|
|
833
|
+
* too, and the timeline says so once a pass (connectedLaterWords). */
|
|
834
|
+
let phaseNow;
|
|
835
|
+
let leftForNextTurn = false;
|
|
823
836
|
/** The calls of this run a person was asked about (their ask in the journal, on this claim or read on a resume), set as
|
|
824
837
|
* the ask is read: one of them the gate lets through was let through by a person's answer. */
|
|
825
838
|
const askedCalls = new Set();
|
|
@@ -1062,6 +1075,35 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1062
1075
|
// untaken for the next claim, which hands it on again; never refused for good.
|
|
1063
1076
|
if (!gate || !session || gate.sealed)
|
|
1064
1077
|
return { later: "the run is parking: the steer waits for its resume" };
|
|
1078
|
+
// A message that hands the credential of a server whose tools this claim left out (mcpWhereHeld, ClaimMcp.leftOut):
|
|
1079
|
+
// the session's tools are fixed for the claim, so a turn it reached could not call them. Left untaken, it runs as
|
|
1080
|
+
// the run's next turn, on a claim that lists them: the run's end opens it again with the message (as for a message
|
|
1081
|
+
// that comes while the run ends), and a park's resume takes it. Every message after it waits the same way, whatever
|
|
1082
|
+
// the credentials say at its own check (a later message may hand them no longer), so none runs before it. Said once
|
|
1083
|
+
// on the timeline, since the API answered the message as steered. A reopen's own message (the claim's turn, not yet
|
|
1084
|
+
// sent; never a wait's answer) came before the claim opened, so whatever it handed, the claim opened with: a
|
|
1085
|
+
// credential handed since is a later message's, and this one is still the claim's turn. Held, a reopen of a session
|
|
1086
|
+
// still new would wait for a first input that never comes. It is the first message to reach here while the reopen
|
|
1087
|
+
// is unsent (`by`): one after it, though that message was refused or left, is no reopen's and is checked.
|
|
1088
|
+
if (leftForNextTurn)
|
|
1089
|
+
return { later: "a message before this one runs as the run's next turn: this one runs after it" };
|
|
1090
|
+
const claimMcp = mcp;
|
|
1091
|
+
const leftOut = claimMcp?.leftOut;
|
|
1092
|
+
const claimTurn = reopen !== undefined && !reopen.sent && reopen !== waitTurn ? reopen : undefined;
|
|
1093
|
+
if (claimTurn)
|
|
1094
|
+
claimTurn.by ??= command.id;
|
|
1095
|
+
if (claimMcp && leftOut?.length && claimTurn?.by !== command.id) {
|
|
1096
|
+
const still = new Set(await claimMcp.fresh());
|
|
1097
|
+
const handed = leftOut.filter((server) => !still.has(server));
|
|
1098
|
+
if (handed.length) {
|
|
1099
|
+
phaseNow?.(connectedLaterWords(handed));
|
|
1100
|
+
leftForNextTurn = true;
|
|
1101
|
+
// A wait in the claim on the person's answer (waitInClaim) ends here: no message reaches it from now on, the
|
|
1102
|
+
// answer included, so the run parks on its question and its next claim takes them in the order they came.
|
|
1103
|
+
endWaitNow?.();
|
|
1104
|
+
return { later: "the message hands the credential of a server this claim left out: it runs as the run's next turn, which lists its tools" };
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1065
1107
|
// A trigger's message into a session on its owner's sign-in (personOnly): refused for good, before it is queued or
|
|
1066
1108
|
// placed, so no turn of it reaches the vendor on that sign-in. Known by its origin's kind as written (an origin whose
|
|
1067
1109
|
// source originOf does not know is still a trigger's), or by answering nothing (answers: false, a trigger's message).
|
|
@@ -1075,8 +1117,9 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1075
1117
|
// and a person's stop or cancel (the stop that cuts the workflow's call, its spend and custody), a raise or a hand-back
|
|
1076
1118
|
// would never reach the run. `taken` here means its take rides on the commit that places it once the input is sent; a
|
|
1077
1119
|
// claim that ends first (a stop, a park, the workflow's answer) leaves the row untaken, for the run's end or its next
|
|
1078
|
-
// claim to settle, as any message the run's end finds untaken.
|
|
1079
|
-
|
|
1120
|
+
// claim to settle, as any message the run's end finds untaken. Once the claim sends nothing more (turnsOver), nothing
|
|
1121
|
+
// waits: the message is the run's next claim's.
|
|
1122
|
+
if (!turnsOver && (waitingFirst > 0 || (!reopen && session.state === "new") || servingFirst)) {
|
|
1080
1123
|
waitingFirst += 1;
|
|
1081
1124
|
const placing = afterFirst.then(() => placeSteer(command));
|
|
1082
1125
|
afterFirst = placing.then(() => void (waitingFirst -= 1), (error) => {
|
|
@@ -1178,7 +1221,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1178
1221
|
const sendId = first ? INPUT_REQUEST : requestId;
|
|
1179
1222
|
// A run its learned workflow answered alone: the job, what the workflow answered (cut of the runner's secrets, as a
|
|
1180
1223
|
// handback is), then the message.
|
|
1181
|
-
const answered = first && servedAnswer ? servedAnswerText(servedAnswer.workflow, deps.redact
|
|
1224
|
+
const answered = first && servedAnswer ? servedAnswerText(servedAnswer.workflow, deps.redact(servedAnswer.answer)) : undefined;
|
|
1182
1225
|
const content = first ? [first.input, ...(answered ? [answered] : []), text].join("\n\n") : text;
|
|
1183
1226
|
// The row is taken only once the session holds the prompt: pi's in its submission's commit; a CLI's (whose harness
|
|
1184
1227
|
// writes no submission) in the record's follow-up entry, written right after the send, as sendAfterTurn takes its
|
|
@@ -1339,7 +1382,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1339
1382
|
* it unanswered (outputRetried). Its turn's end is what this gives. */
|
|
1340
1383
|
const sendOutputRetry = async (why) => {
|
|
1341
1384
|
outputRetrySent = true;
|
|
1342
|
-
const text = outputRetryWords(deps.redact
|
|
1385
|
+
const text = outputRetryWords(deps.redact(why));
|
|
1343
1386
|
await cliRecord?.followUp(text, OUTPUT_RETRY_REQUEST, OUTPUT_RETRY_ORIGIN);
|
|
1344
1387
|
await session.send(text, { id: OUTPUT_RETRY_REQUEST, origin: OUTPUT_RETRY_ORIGIN });
|
|
1345
1388
|
await specNow?.hooks?.afterMessageSent?.();
|
|
@@ -1517,6 +1560,8 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1517
1560
|
await phasing.commit((tx) => tx.appendEntry(ROOT_CONVERSATION_ID, { kind: HOST_PHASE, data }), context);
|
|
1518
1561
|
})().catch((error) => console.warn(`[runner] a phase row was not written: ${said(error)}`));
|
|
1519
1562
|
};
|
|
1563
|
+
phaseNow = phase;
|
|
1564
|
+
leftForNextTurn = false;
|
|
1520
1565
|
const passGate = gate;
|
|
1521
1566
|
const rowSummaryOn = (kind, test, summary) => {
|
|
1522
1567
|
if (passGate.sealed)
|
|
@@ -2304,7 +2349,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2304
2349
|
const traced = specNow?.trace;
|
|
2305
2350
|
const routed = request.route === undefined ? traced?.model : traced?.routes?.get(request.route)?.model;
|
|
2306
2351
|
const known = (asked) => asked === traced?.model || [...(traced?.routes?.values() ?? [])].some((via) => via.model === asked) || specNow?.runCap.modelOf(asked)?.id === asked;
|
|
2307
|
-
const model = tracedModel(request.model, { known, ...(routed ? { routed } : {}),
|
|
2352
|
+
const model = tracedModel(request.model, { known, ...(routed ? { routed } : {}), redact: deps.redact });
|
|
2308
2353
|
chats.set(ticket.turn, trace.request(model, request.route));
|
|
2309
2354
|
}
|
|
2310
2355
|
// The conversation that asked, as its client named it (pi's, one of several asking at once): whose answer reads
|
|
@@ -2450,6 +2495,35 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2450
2495
|
return answer;
|
|
2451
2496
|
}
|
|
2452
2497
|
: nestedGate;
|
|
2498
|
+
// An agent's learned_workflow call the gate refuses (a deny set, a person's deny of its ask, the cap's wrap-up)
|
|
2499
|
+
// never reaches the tool, which keeps every other call's record: its record is kept here, as serveFirst keeps the
|
|
2500
|
+
// platform's (learned-nodes.ts refusedRecord), so the run's workflow_calls name it, refused, on pi and on every
|
|
2501
|
+
// CLI alike. A name the run has no workflow of keeps none, as the tool keeps none for it. Each attempt the gate lets
|
|
2502
|
+
// go is marked first (LEARNED_ALLOWED), committed before the tool runs: a call issued again after a crash cut it may
|
|
2503
|
+
// have run nodes and spent on such an attempt, so its refusal is then no proof it ran nothing, and it is kept
|
|
2504
|
+
// `failed`, never `refused`, priced from what its call id booked (failedRecord). The newest of the call's marks and
|
|
2505
|
+
// records says which (learned-nodes.ts learnedCallRan): its bridge can't alone (a tool that nests is asked as
|
|
2506
|
+
// `replayed` only once an earlier attempt fixed a value or nested a call: process/tools.ts runNesting), nor can the
|
|
2507
|
+
// call's start on the CLI record, which a refusal writes too. With neither, the bridge's `replayed` stands in: a
|
|
2508
|
+
// run begun before the marks existed has none. Whatever is
|
|
2509
|
+
// kept, a refusal reads `failed` once anything was booked under the call id, or while an attempt let go was closed
|
|
2510
|
+
// by no refusal (workflow-calls.ts workflowCallsOf).
|
|
2511
|
+
const learnedEntry = async (call, answer) => {
|
|
2512
|
+
const named = call.tool === LEARNED_WORKFLOW_TOOL ? spec.gate?.learnedOf?.(call.args) : undefined;
|
|
2513
|
+
const [journalOf, rootOf] = [harness, root];
|
|
2514
|
+
if (!named || !journalOf || !rootOf || !gate || gate.sealed)
|
|
2515
|
+
return;
|
|
2516
|
+
const [kind, data] = answer === "allow"
|
|
2517
|
+
? [LEARNED_ALLOWED, { call: call.callId }]
|
|
2518
|
+
: [LEARNED_NODES, (learnedCallRan(await entriesOf(gate.journal, rootOf.id, context), call.callId, call.replayed === true) ? failedRecord : refusedRecord)(call.callId, named.workflow, named.digest, "agent")];
|
|
2519
|
+
await journalOf.commit((tx) => tx.appendEntry(rootOf.id, { kind, data: data }), context).catch(unlessSealed);
|
|
2520
|
+
};
|
|
2521
|
+
const sessionGate = async (call, hookContext) => {
|
|
2522
|
+
const answer = await bridgeGate(call, hookContext);
|
|
2523
|
+
if (answer === "allow" || "deny" in answer)
|
|
2524
|
+
await learnedEntry(call, answer);
|
|
2525
|
+
return answer;
|
|
2526
|
+
};
|
|
2453
2527
|
// A tool no call of which reaches the gate before it runs (Codex's live search, inside its model requests): its
|
|
2454
2528
|
// setting now, read again at each request, so a deny or ask set mid-run reaches the next one.
|
|
2455
2529
|
const permission = spec.gate?.permission;
|
|
@@ -2480,10 +2554,10 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2480
2554
|
// Every harness's events reach its trace first (its tool calls, a plan harness's turns), with a record or without.
|
|
2481
2555
|
const recorded = record ? onEvent(record) : undefined;
|
|
2482
2556
|
const traceAnd = (event) => {
|
|
2483
|
-
trace?.event(tracedEvent(event, { mcp: (name) => mcp?.catalogOf(specNow?.facts?.hostName?.(name) ?? name) !== undefined,
|
|
2557
|
+
trace?.event(tracedEvent(event, { mcp: (name) => mcp?.catalogOf(specNow?.facts?.hostName?.(name) ?? name) !== undefined, redact: deps.redact }));
|
|
2484
2558
|
recorded?.(event);
|
|
2485
2559
|
};
|
|
2486
|
-
const io = { writer, models: counted, signal: deps.signal, onEvent: traceAnd, gate:
|
|
2560
|
+
const io = { writer, models: counted, signal: deps.signal, onEvent: traceAnd, gate: sessionGate, ...(permission ? { permission } : {}), hostTool: hosted, ...(ownCalls ? { ownCalls } : {}), bookedCost, keepCalls, ...(record ? {} : { nestedEnded }) };
|
|
2487
2561
|
// The end-of-run turn an earlier claim asked and never saw end (its runner lost mid look-back or mid compile): the
|
|
2488
2562
|
// root's newest input still in flight is that turn's (end-of-run.ts REFLECT_PREFIX), which pi picks up again as its
|
|
2489
2563
|
// session opens. The job's turn ended before it, answered: this pass runs no job turn (no recovery as the job's, no
|
|
@@ -2662,6 +2736,10 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2662
2736
|
const resumes = raising.resumes;
|
|
2663
2737
|
await takeRaises();
|
|
2664
2738
|
if (paused) {
|
|
2739
|
+
// No raise resumed it (each refused, or a retry of one before): its pause stands as it was, its budget entry
|
|
2740
|
+
// unanswered, so it parks again on that entry with nothing written, never a second entry at the same cap.
|
|
2741
|
+
if (!resumes && (await raiseStateOf()).pause !== undefined)
|
|
2742
|
+
return await parkAgain(harness, gate);
|
|
2665
2743
|
if (!resumes || raising.capUsd === undefined || !spec.cap?.followUpOf)
|
|
2666
2744
|
return await parkAtCap(harness, root, gate, paused, "cap");
|
|
2667
2745
|
// The server's words, shown as its row ("AgentRun: …"), never as the person's; under the id a raise's answer named.
|
|
@@ -2697,7 +2775,18 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2697
2775
|
// runner reads on a later poll is waited for (or the run's stop, park or loss).
|
|
2698
2776
|
if (firstInputPlaced && !reopen.sent) {
|
|
2699
2777
|
const lost = new Promise((resolve) => (deps.signal.aborted ? resolve() : deps.signal.addEventListener("abort", () => resolve(), { once: true })));
|
|
2700
|
-
await Promise.race([firstInputPlaced, stopping, parking, harness.closed.then(() =>
|
|
2778
|
+
const woke = await Promise.race([firstInputPlaced.then(() => true), stopping.then(() => false), parking.then(() => false), harness.closed.then(() => false, () => false), lost.then(() => false)]);
|
|
2779
|
+
// Woken with nothing placed (the reopen's own message refused or left): the claim sends nothing into the
|
|
2780
|
+
// session that never started, asks nothing of it, and ends the run on the end it had before (a stop's, or its
|
|
2781
|
+
// learned workflow's answer). A message handed over from here on is the run's next claim's (`later`), never
|
|
2782
|
+
// queued for a first input that is never sent.
|
|
2783
|
+
if (woke && !reopen.sent) {
|
|
2784
|
+
turnsOver = true;
|
|
2785
|
+
reopen = undefined;
|
|
2786
|
+
inputSent();
|
|
2787
|
+
const { projectCheckpoint: _, ...before } = foundEntries.findLast((entry) => entry.kind === KINDS.end).data;
|
|
2788
|
+
return await writeEnd(harness, root, gate, before, []);
|
|
2789
|
+
}
|
|
2701
2790
|
}
|
|
2702
2791
|
const sent = reopen.sent;
|
|
2703
2792
|
const fed = reopen.feedback;
|
|
@@ -2836,9 +2925,9 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2836
2925
|
answer = taken(answer);
|
|
2837
2926
|
const outcome = answer.isError ? "handed_back" : "answered";
|
|
2838
2927
|
const data = { workflow: first.name, digest: first.digest, ...(first.promotion !== undefined ? { promotion: first.promotion } : {}), revision: first.revision, call: WORKFLOW_FIRST_CALL, outcome };
|
|
2839
|
-
// A call refused at its gate keeps its record as one the tool refused does (learned-nodes.ts
|
|
2840
|
-
//
|
|
2841
|
-
const refusal = refused ?
|
|
2928
|
+
// A call refused at its gate keeps its record as one the tool refused does (learned-nodes.ts refusedRecord): no
|
|
2929
|
+
// workflow ran it, so the money rule charges none and the run names none.
|
|
2930
|
+
const refusal = refused ? refusedRecord(WORKFLOW_FIRST_CALL, first.name, first.digest, "platform") : undefined;
|
|
2842
2931
|
await on.commit(async (tx) => {
|
|
2843
2932
|
if (outcome === "answered")
|
|
2844
2933
|
await tx.appendEntry(theRoot.id, { kind: KINDS.message, data: { role: "model", text: answer.text, at: now() } });
|
|
@@ -2897,7 +2986,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2897
2986
|
else if (served?.outcome === "handed_back") {
|
|
2898
2987
|
// The agent's first input: the handback, the server's (its row "AgentRun: …"), the job whole after it. Cut of
|
|
2899
2988
|
// every secret the runner holds: the workflow's words may quote what its steps read.
|
|
2900
|
-
const text = deps.redact
|
|
2989
|
+
const text = deps.redact(served.text);
|
|
2901
2990
|
await record?.message(text, HANDED_BACK_ORIGIN);
|
|
2902
2991
|
await session.send(text, { origin: HANDED_BACK_ORIGIN });
|
|
2903
2992
|
}
|
|
@@ -3005,7 +3094,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3005
3094
|
// What the model said last, on the record before the run's end.
|
|
3006
3095
|
await record?.flushText();
|
|
3007
3096
|
// The turn's end on the record, after its last text: a CLI run reads working until here.
|
|
3008
|
-
await record?.turnEnded(outcome.status, outcome.error === undefined ? undefined : deps.redact
|
|
3097
|
+
await record?.turnEnded(outcome.status, outcome.error === undefined ? undefined : deps.redact(outcome.error));
|
|
3009
3098
|
await harness.waitForIdle(context);
|
|
3010
3099
|
const settledEntries = await entriesOf(gate.journal, root.id, context);
|
|
3011
3100
|
const cutOff = restartLimited(settledEntries);
|
|
@@ -3053,7 +3142,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3053
3142
|
// answer (the same row the run's end would have written).
|
|
3054
3143
|
const said = outcome.error?.trim() ?? "";
|
|
3055
3144
|
const rootId = root.id;
|
|
3056
|
-
await harness.commit((tx) => tx.appendEntry(rootId, { kind: PI_ASSISTANT, model: [cliErrorAnswer(specNow?.adapter.id ?? "cli", said ? cutWhole(deps.redact
|
|
3145
|
+
await harness.commit((tx) => tx.appendEntry(rootId, { kind: PI_ASSISTANT, model: [cliErrorAnswer(specNow?.adapter.id ?? "cli", said ? cutWhole(deps.redact(said), TURN_ERROR_MAX) : "the turn gave no answer (failed)", now())] }), context);
|
|
3057
3146
|
turn = sendAfterTurn(gate, afterTurn.shift());
|
|
3058
3147
|
continue;
|
|
3059
3148
|
}
|
|
@@ -3072,7 +3161,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3072
3161
|
// A CLI's turn (record "loop"; pi journals its own): its error is also main's error row, pi's error answer in the
|
|
3073
3162
|
// end's commit, cut of every secret the runner holds, so the timeline shows it as an error row with no key in it.
|
|
3074
3163
|
if (said && spec.record === "loop")
|
|
3075
|
-
failedWith = deps.redact
|
|
3164
|
+
failedWith = deps.redact(said);
|
|
3076
3165
|
}
|
|
3077
3166
|
else if (turnEndedOnAsk(settledEntries) !== undefined) {
|
|
3078
3167
|
// The turn ended on a tool that waits on the person (ask_person ended its turn). With something a tool host keeps
|
|
@@ -3605,7 +3694,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3605
3694
|
/** A job's end as KINDS.jobEnd keeps it: its summary cut of every secret the runner holds, as every summary is when
|
|
3606
3695
|
* served. */
|
|
3607
3696
|
function jobEndOf(data, failedWith, endedAt) {
|
|
3608
|
-
const end = data.summary !== undefined
|
|
3697
|
+
const end = data.summary !== undefined ? { ...data, summary: deps.redact(data.summary) } : data;
|
|
3609
3698
|
return { end, ...(failedWith !== undefined ? { failedWith } : {}), endedAt };
|
|
3610
3699
|
}
|
|
3611
3700
|
/** The job's end for a claim that found the end-of-run turn open (lookingBackOpen), or a grade's round (its steer's
|
|
@@ -3641,9 +3730,11 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3641
3730
|
await options.beforePersonWait?.();
|
|
3642
3731
|
if (!session || !gate || gate.sealed || !root)
|
|
3643
3732
|
return parkingOnAsk();
|
|
3644
|
-
if (!holders.length) {
|
|
3645
|
-
// Nothing to hold open
|
|
3646
|
-
//
|
|
3733
|
+
if (!holders.length || leftForNextTurn) {
|
|
3734
|
+
// Nothing to hold open, or a message of this claim is left for the run's next turn (steer), so none, the answer
|
|
3735
|
+
// included, would reach the wait: the run parks, unless the answer already came, between the question's turn end
|
|
3736
|
+
// and here, placed as a steer of the idle session (steer): then its turn is the next, at once, never cut by the
|
|
3737
|
+
// park's seal.
|
|
3647
3738
|
const early = idleSteer;
|
|
3648
3739
|
idleSteer = undefined;
|
|
3649
3740
|
if (early && (await early.placed))
|
|
@@ -3695,13 +3786,16 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3695
3786
|
const next = new Promise((resolve, reject) => {
|
|
3696
3787
|
let done = false;
|
|
3697
3788
|
let lapsed = false;
|
|
3789
|
+
/** Ended by a message left for the run's next turn (endWaitNow), no hold having lapsed. */
|
|
3790
|
+
let cut = false;
|
|
3698
3791
|
const finish = (value) => {
|
|
3699
3792
|
if (done)
|
|
3700
3793
|
return;
|
|
3701
3794
|
done = true;
|
|
3702
3795
|
if (value === "lapsed") {
|
|
3703
|
-
|
|
3704
|
-
hold
|
|
3796
|
+
if (lapsed)
|
|
3797
|
+
for (const hold of waitHolds)
|
|
3798
|
+
hold.confirmed?.();
|
|
3705
3799
|
// The run parks on its question (the turn loop's "lapsed"): the person's next message is the resume's.
|
|
3706
3800
|
parkingOnAsk();
|
|
3707
3801
|
}
|
|
@@ -3715,6 +3809,17 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3715
3809
|
if (!mine.sent)
|
|
3716
3810
|
finish("lapsed");
|
|
3717
3811
|
}, () => undefined);
|
|
3812
|
+
// So does a message left for the run's next turn (steer), the same way; one left while the wait was starting ends it
|
|
3813
|
+
// as soon as it holds. One left while an answer is placed (a message that waited for the run's first input is placed
|
|
3814
|
+
// off the runner's delivery, so the next row can arrive meanwhile) ends it once that answer is refused: no message
|
|
3815
|
+
// reaches the wait after it.
|
|
3816
|
+
endWaitNow = () => {
|
|
3817
|
+
cut = true;
|
|
3818
|
+
if (!mine.sent)
|
|
3819
|
+
finish("lapsed");
|
|
3820
|
+
};
|
|
3821
|
+
if (leftForNextTurn)
|
|
3822
|
+
endWaitNow();
|
|
3718
3823
|
void (async () => {
|
|
3719
3824
|
for (;;) {
|
|
3720
3825
|
await placing;
|
|
@@ -3726,7 +3831,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3726
3831
|
// Not placed (the steer was refused): the next message may be.
|
|
3727
3832
|
mine.sent = undefined;
|
|
3728
3833
|
placing = new Promise((resolve) => (mine.placed = resolve));
|
|
3729
|
-
if (lapsed)
|
|
3834
|
+
if (lapsed || cut)
|
|
3730
3835
|
return finish("lapsed");
|
|
3731
3836
|
}
|
|
3732
3837
|
}
|
|
@@ -3748,6 +3853,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3748
3853
|
// The pass's MCP credentials go with it.
|
|
3749
3854
|
mcp?.release();
|
|
3750
3855
|
mcp = undefined;
|
|
3856
|
+
phaseNow = undefined;
|
|
3751
3857
|
// The pass's resources go once nothing more is written through them (AdapterRunSpec.release), once each.
|
|
3752
3858
|
// A park's keeps the run's computer (keepAtPark).
|
|
3753
3859
|
const release = releaseNow;
|
|
@@ -3865,7 +3971,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3865
3971
|
// A grade's feedback round (feedbackNow): its first ask is told the grade first (feedback-round.ts feedbackAsk), cut
|
|
3866
3972
|
// of every secret the runner holds. Only a run the agent finished opens one, so its session saw the job.
|
|
3867
3973
|
if (feedbackNow && !again && step === undefined) {
|
|
3868
|
-
const cut = (text) =>
|
|
3974
|
+
const cut = (text) => deps.redact(text);
|
|
3869
3975
|
prompt = `${feedbackAsk({ ...feedbackNow, text: cut(feedbackNow.text) })}\n\n${prompt}`;
|
|
3870
3976
|
}
|
|
3871
3977
|
let timer;
|
|
@@ -3972,6 +4078,12 @@ function adapterLoop(specOf, options, deps) {
|
|
|
3972
4078
|
await pauseAtCap(on, conversation, theGate, data);
|
|
3973
4079
|
return parkClaim(on, theGate, cause);
|
|
3974
4080
|
}
|
|
4081
|
+
/** The run parked again at the pause it was woken from, which no raise of this claim answered: nothing is written (its
|
|
4082
|
+
* budget entry and the row's words stand), and the release parks the row again (LoopEnd `again`). */
|
|
4083
|
+
async function parkAgain(on, theGate) {
|
|
4084
|
+
const end = await parkClaim(on, theGate, "cap");
|
|
4085
|
+
return end.state === "parked" ? { ...end, again: true } : end;
|
|
4086
|
+
}
|
|
3975
4087
|
/** Waits, at most the spec's parkSiblingsMs (PARK_SIBLINGS_MS), until no call pi started beside a parked one is still
|
|
3976
4088
|
* running: a model call of the same answer (its assistant entry) past its stored intent. Each one's result is then on the
|
|
3977
4089
|
* journal before the park seals it, and the resume hands it to the model with the parked call's answer, never as a call
|
|
@@ -4260,8 +4372,15 @@ function adapterLoop(specOf, options, deps) {
|
|
|
4260
4372
|
// never runs the message on the key held before it.
|
|
4261
4373
|
await specNow?.modelKey?.fresh();
|
|
4262
4374
|
}
|
|
4263
|
-
if (command.kind === "steer")
|
|
4264
|
-
|
|
4375
|
+
if (command.kind === "steer") {
|
|
4376
|
+
const outcome = await steer(command);
|
|
4377
|
+
// The reopen's own message refused or left (a trigger's in a session on its owner's sign-in): no message is the
|
|
4378
|
+
// claim's turn now, and a message after it is checked as any other, so a reopen of a session still new stops
|
|
4379
|
+
// waiting for its first input (firstInputPlaced); a message left meanwhile reopens the run on its next claim.
|
|
4380
|
+
if (!("taken" in outcome) && reopen !== undefined && reopen !== waitTurn && !reopen.sent && reopen.by === command.id)
|
|
4381
|
+
reopen.placed?.();
|
|
4382
|
+
return outcome;
|
|
4383
|
+
}
|
|
4265
4384
|
if (command.kind === "approve" || command.kind === "deny") {
|
|
4266
4385
|
// An answer names its approval: the asked call's id. One that names no call waiting for its answer (an old
|
|
4267
4386
|
// approval, another run's) is refused, never applied to the call that waits now.
|
|
@@ -95,6 +95,10 @@ export interface AdapterSpecDeps {
|
|
|
95
95
|
readonly journal: (claim: Claim) => Journal;
|
|
96
96
|
/** The one store: `runs` and `agents` for the run's revision, and the live-viewer seam for the browser tool. */
|
|
97
97
|
readonly store: Store & LiveViewerStore;
|
|
98
|
+
/** The plane the claim's runner capped (run-child-host.ts, by underServerCeilings) and chose the run's keys by, handed to
|
|
99
|
+
* the run's own process (run-child.ts): taken as it is there, never capped again on settings read later, so the run's
|
|
100
|
+
* tools and the keys it was handed are of one reading. Absent: the claim caps its launch itself. */
|
|
101
|
+
readonly claimedPlane?: RunLaunch["plane"];
|
|
98
102
|
/** The key the store's sealed values are opened under (store/seal.ts): the runner's. Undefined in a run's own process
|
|
99
103
|
* (run-child.ts), which never holds it: what a claim opens with it is asked of the runner there (held.ts). */
|
|
100
104
|
readonly sealKey: Buffer | undefined;
|
|
@@ -295,7 +299,8 @@ export declare function adapterRunGate(store: Pick<Store, "settings">, claim: Pi
|
|
|
295
299
|
readonly learn: (flows: readonly LearnedWorkflow[]) => void;
|
|
296
300
|
readonly askedOn: (host: ToolHost) => void;
|
|
297
301
|
readonly computerOff: () => boolean; /** Whether the run can write a file now, as its gate decides a save_as (RunGate.writeBar): what its files note and computer_screenshot's save_as are offered by. */
|
|
298
|
-
readonly writes: () => boolean;
|
|
302
|
+
readonly writes: () => boolean; /** The computer ops the gate refuses whatever their arguments (RunGate.opsRefused: not given, denied, or an ask no one can approve): what computer_op and a script's `computer` leave out. */
|
|
303
|
+
readonly opsRefused: () => readonly string[];
|
|
299
304
|
}>;
|
|
300
305
|
/** The server's tool settings from the store now; a read that throws is unread (no value of it said). A workflow's call
|
|
301
306
|
* and model nodes read theirs through it too (workflow-spec.ts callPolicyOf), so both gates fail closed alike. */
|
|
@@ -376,11 +381,9 @@ export declare function liveViewersOf(store: LiveViewerStore, sealKey: Buffer |
|
|
|
376
381
|
drop(tag?: string): Promise<void>;
|
|
377
382
|
};
|
|
378
383
|
/** `tool` with its answer's text, and a throw's message, cut by `cut` (the run's one redactor). A web call's answer is cut
|
|
379
|
-
* string by string inside its JSON (
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
* (key-refusal.ts withheldWhole), or through `cut` itself when it does not know them (joinCut). Each string is cut once
|
|
383
|
-
* in a call, for the join's read and the answer both. */
|
|
384
|
+
* string by string inside its JSON (tools.ts webAnswerCut), so what the harness stores still parses and keeps its links
|
|
385
|
+
* whole for a grader's link check; one whose strings, read joined, hold a held value split across two of them is
|
|
386
|
+
* "[redacted]". */
|
|
384
387
|
export declare function answersCut(tool: HostTool, cut: Redact): HostTool;
|
|
385
388
|
/** The ToolHost a run's non-hand tools bind through, the one both the pi spec and the CLI spec build: the run's folder and
|
|
386
389
|
* the claim's environment (claim-secrets.ts: the run's keys from the store, its plane set), the run's registry for an
|