@parcha/agentrun-serve 0.1.0-beta.60 → 0.1.0-beta.61

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.
Files changed (93) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +42 -14
  3. package/dist/acp-package.d.ts +4 -0
  4. package/dist/api-only.d.ts +19 -1
  5. package/dist/api-only.js +38 -3
  6. package/dist/browser-person.d.ts +1 -1
  7. package/dist/browser-person.js +1 -1
  8. package/dist/calendar/tools.js +1 -1
  9. package/dist/cli.js +42 -10
  10. package/dist/console/assets/{backend-QnwGVBeU.js → backend-C9ffXUR5.js} +1 -1
  11. package/dist/console/assets/index-BnZV3lvW.js +639 -0
  12. package/dist/console/assets/{share-pz61zIn9.js → share-B1o5mJ56.js} +2 -2
  13. package/dist/console/assets/{styles-CcceGcu2.js → styles-D_znYrHR.js} +2 -2
  14. package/dist/console/index.html +2 -2
  15. package/dist/console/share.html +2 -2
  16. package/dist/errors.d.ts +1 -0
  17. package/dist/errors.js +2 -0
  18. package/dist/harness-check.js +2 -1
  19. package/dist/harness-recipe.d.ts +13 -2
  20. package/dist/harness-recipe.js +30 -7
  21. package/dist/harness-sign-in.js +2 -1
  22. package/dist/harness-table.d.ts +5 -3
  23. package/dist/harness-table.js +7 -5
  24. package/dist/key-refusal.js +6 -4
  25. package/dist/learn/secrets.d.ts +2 -1
  26. package/dist/learn/secrets.js +2 -2
  27. package/dist/learned-nodes.d.ts +36 -0
  28. package/dist/learned-nodes.js +23 -0
  29. package/dist/local-model.d.ts +144 -0
  30. package/dist/local-model.js +214 -0
  31. package/dist/mcp-probe.d.ts +7 -0
  32. package/dist/mcp-probe.js +7 -0
  33. package/dist/ollama-provider.d.ts +35 -0
  34. package/dist/ollama-provider.js +108 -2
  35. package/dist/openapi.js +59 -7
  36. package/dist/place.d.ts +7 -6
  37. package/dist/place.js +13 -10
  38. package/dist/print.js +1 -1
  39. package/dist/redact/match.d.ts +17 -4
  40. package/dist/redact/match.js +57 -15
  41. package/dist/run-export.js +4 -2
  42. package/dist/run-usage.js +3 -2
  43. package/dist/runner/adapter-loop.d.ts +8 -1
  44. package/dist/runner/adapter-loop.js +100 -20
  45. package/dist/runner/adapter-run-spec.d.ts +3 -5
  46. package/dist/runner/adapter-run-spec.js +26 -43
  47. package/dist/runner/adapters/pi.d.ts +3 -2
  48. package/dist/runner/adapters/pi.js +3 -1
  49. package/dist/runner/audit.d.ts +1 -1
  50. package/dist/runner/cli-run-spec.js +13 -10
  51. package/dist/runner/compare-end.d.ts +1 -1
  52. package/dist/runner/dispatch.js +2 -2
  53. package/dist/runner/harness-loops.d.ts +9 -0
  54. package/dist/runner/harness-loops.js +47 -4
  55. package/dist/runner/held.d.ts +4 -1
  56. package/dist/runner/live-ticker.js +3 -4
  57. package/dist/runner/mcp-claim.js +3 -2
  58. package/dist/runner/mcp-run.d.ts +19 -4
  59. package/dist/runner/mcp-run.js +29 -2
  60. package/dist/runner/metrics.d.ts +4 -0
  61. package/dist/runner/metrics.js +9 -3
  62. package/dist/runner/monid-run.js +3 -1
  63. package/dist/runner/native-loop.js +1 -1
  64. package/dist/runner/redact.d.ts +3 -0
  65. package/dist/runner/redact.js +7 -0
  66. package/dist/runner/run-child-host.js +1 -1
  67. package/dist/runner/sdk-loop.js +5 -3
  68. package/dist/runner/workflow-calls.d.ts +4 -1
  69. package/dist/runner/workflow-calls.js +35 -18
  70. package/dist/runner/workflow-loop.d.ts +1 -1
  71. package/dist/runner/workflow-loop.js +3 -1
  72. package/dist/runner/workflow-spec.d.ts +4 -0
  73. package/dist/runner/workflow-spec.js +18 -13
  74. package/dist/runs-over-store.d.ts +2 -2
  75. package/dist/runs-over-store.js +1 -1
  76. package/dist/secret-cut.js +7 -4
  77. package/dist/secret-rules.js +97 -83
  78. package/dist/server.d.ts +7 -0
  79. package/dist/server.js +97 -34
  80. package/dist/slack.js +2 -1
  81. package/dist/store/postgres/migrate.js +3 -1
  82. package/dist/store-reads/learning.d.ts +5 -4
  83. package/dist/store-reads/learning.js +7 -4
  84. package/dist/tool-plane.d.ts +23 -1
  85. package/dist/tool-plane.js +70 -2
  86. package/dist/tools.d.ts +12 -2
  87. package/dist/tools.js +42 -7
  88. package/dist/trigger-launch-hook.d.ts +2 -2
  89. package/dist/trigger-launch-hook.js +1 -1
  90. package/dist/triggers.d.ts +7 -4
  91. package/dist/triggers.js +4 -4
  92. package/package.json +12 -12
  93. package/dist/console/assets/index-DZi-muIj.js +0 -629
@@ -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 ? deps.redact(text) : text;
604
+ return deps.redact(text);
602
605
  };
603
606
  let stopped = () => { };
604
607
  const stopping = new Promise((resolve) => (stopped = resolve));
@@ -710,6 +713,9 @@ function adapterLoop(specOf, options, deps) {
710
713
  let waitHolds = [];
711
714
  /** The wait's own `reopen`, while it is set. */
712
715
  let waitTurn;
716
+ /** Ends the wait in the claim at once, the run parking on its question as a lapse does, though no host's hold lapsed:
717
+ * set while the wait holds (waitInClaim). */
718
+ let endWaitNow;
713
719
  /** The `reopen` of a CLI run parked on its question (its turn cut there: no steer reaches its idle session), while it is
714
720
  * set: the person's answer is the claim's turn, and a trigger's message is no answer. */
715
721
  let askReopen;
@@ -772,6 +778,7 @@ function adapterLoop(specOf, options, deps) {
772
778
  if (reopen === waitTurn)
773
779
  reopen = undefined;
774
780
  waitTurn = undefined;
781
+ endWaitNow = undefined;
775
782
  for (const hold of waitHolds.splice(0)) {
776
783
  try {
777
784
  hold.drop();
@@ -820,6 +827,11 @@ function adapterLoop(specOf, options, deps) {
820
827
  /** The pass's MCP (spec.mcp), until the pass ends; and whether a command row came since its credentials were last made
821
828
  * fresh (a parked token may have expired meanwhile). */
822
829
  let mcp;
830
+ /** The pass's phase row (AdapterRun.phase), until the pass ends; and whether a message of the pass was left for the
831
+ * run's next turn, as one handing the credential of a server its claim left out (steer): every message after it waits
832
+ * too, and the timeline says so once a pass (connectedLaterWords). */
833
+ let phaseNow;
834
+ let leftForNextTurn = false;
823
835
  /** 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
836
  * the ask is read: one of them the gate lets through was let through by a person's answer. */
825
837
  const askedCalls = new Set();
@@ -1062,6 +1074,28 @@ function adapterLoop(specOf, options, deps) {
1062
1074
  // untaken for the next claim, which hands it on again; never refused for good.
1063
1075
  if (!gate || !session || gate.sealed)
1064
1076
  return { later: "the run is parking: the steer waits for its resume" };
1077
+ // A message that hands the credential of a server whose tools this claim left out (mcpWhereHeld, ClaimMcp.leftOut):
1078
+ // the session's tools are fixed for the claim, so a turn it reached could not call them. Left untaken, it runs as
1079
+ // 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
1080
+ // that comes while the run ends), and a park's resume takes it. Every message after it waits the same way, whatever
1081
+ // the credentials say at its own check (a later message may hand them no longer), so none runs before it. Said once
1082
+ // on the timeline, since the API answered the message as steered.
1083
+ if (leftForNextTurn)
1084
+ return { later: "a message before this one runs as the run's next turn: this one runs after it" };
1085
+ const claimMcp = mcp;
1086
+ const leftOut = claimMcp?.leftOut;
1087
+ if (claimMcp && leftOut?.length) {
1088
+ const still = new Set(await claimMcp.fresh());
1089
+ const handed = leftOut.filter((server) => !still.has(server));
1090
+ if (handed.length) {
1091
+ phaseNow?.(connectedLaterWords(handed));
1092
+ leftForNextTurn = true;
1093
+ // A wait in the claim on the person's answer (waitInClaim) ends here: no message reaches it from now on, the
1094
+ // answer included, so the run parks on its question and its next claim takes them in the order they came.
1095
+ endWaitNow?.();
1096
+ 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" };
1097
+ }
1098
+ }
1065
1099
  // A trigger's message into a session on its owner's sign-in (personOnly): refused for good, before it is queued or
1066
1100
  // 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
1101
  // source originOf does not know is still a trigger's), or by answering nothing (answers: false, a trigger's message).
@@ -1178,7 +1212,7 @@ function adapterLoop(specOf, options, deps) {
1178
1212
  const sendId = first ? INPUT_REQUEST : requestId;
1179
1213
  // A run its learned workflow answered alone: the job, what the workflow answered (cut of the runner's secrets, as a
1180
1214
  // handback is), then the message.
1181
- const answered = first && servedAnswer ? servedAnswerText(servedAnswer.workflow, deps.redact ? deps.redact(servedAnswer.answer) : servedAnswer.answer) : undefined;
1215
+ const answered = first && servedAnswer ? servedAnswerText(servedAnswer.workflow, deps.redact(servedAnswer.answer)) : undefined;
1182
1216
  const content = first ? [first.input, ...(answered ? [answered] : []), text].join("\n\n") : text;
1183
1217
  // The row is taken only once the session holds the prompt: pi's in its submission's commit; a CLI's (whose harness
1184
1218
  // writes no submission) in the record's follow-up entry, written right after the send, as sendAfterTurn takes its
@@ -1339,7 +1373,7 @@ function adapterLoop(specOf, options, deps) {
1339
1373
  * it unanswered (outputRetried). Its turn's end is what this gives. */
1340
1374
  const sendOutputRetry = async (why) => {
1341
1375
  outputRetrySent = true;
1342
- const text = outputRetryWords(deps.redact ? deps.redact(why) : why);
1376
+ const text = outputRetryWords(deps.redact(why));
1343
1377
  await cliRecord?.followUp(text, OUTPUT_RETRY_REQUEST, OUTPUT_RETRY_ORIGIN);
1344
1378
  await session.send(text, { id: OUTPUT_RETRY_REQUEST, origin: OUTPUT_RETRY_ORIGIN });
1345
1379
  await specNow?.hooks?.afterMessageSent?.();
@@ -1517,6 +1551,8 @@ function adapterLoop(specOf, options, deps) {
1517
1551
  await phasing.commit((tx) => tx.appendEntry(ROOT_CONVERSATION_ID, { kind: HOST_PHASE, data }), context);
1518
1552
  })().catch((error) => console.warn(`[runner] a phase row was not written: ${said(error)}`));
1519
1553
  };
1554
+ phaseNow = phase;
1555
+ leftForNextTurn = false;
1520
1556
  const passGate = gate;
1521
1557
  const rowSummaryOn = (kind, test, summary) => {
1522
1558
  if (passGate.sealed)
@@ -2450,6 +2486,33 @@ function adapterLoop(specOf, options, deps) {
2450
2486
  return answer;
2451
2487
  }
2452
2488
  : nestedGate;
2489
+ // An agent's learned_workflow call the gate refuses (a deny set, a person's deny of its ask, the cap's wrap-up)
2490
+ // never reaches the tool, which keeps every other call's record: its record is kept here, as serveFirst keeps the
2491
+ // platform's (learned-nodes.ts refusedRecord), so the run's workflow_calls name it, refused, on pi and on every
2492
+ // CLI alike. A name the run has no workflow of keeps none, as the tool keeps none for it. Each attempt the gate lets
2493
+ // go is marked first (LEARNED_ALLOWED), committed before the tool runs: a call issued again after a crash cut it may
2494
+ // have run nodes and spent on such an attempt, so its refusal is then no proof it ran nothing, and it is kept
2495
+ // `failed`, never `refused`, priced from what its call id booked (failedRecord). The newest of the call's marks and
2496
+ // records says which (learned-nodes.ts learnedCallRan): its bridge can't alone (a tool that nests is asked alike on
2497
+ // every attempt: process/tools.ts runNesting), nor can the call's start on the CLI record, which a refusal writes
2498
+ // too. With neither, the bridge's `replayed` stands in: a run begun before the marks existed has none. Whatever is
2499
+ // kept, a refusal reads `failed` once anything was booked under the call id (workflow-calls.ts workflowCallsOf).
2500
+ const learnedEntry = async (call, answer) => {
2501
+ const named = call.tool === LEARNED_WORKFLOW_TOOL ? spec.gate?.learnedOf?.(call.args) : undefined;
2502
+ const [journalOf, rootOf] = [harness, root];
2503
+ if (!named || !journalOf || !rootOf || !gate || gate.sealed)
2504
+ return;
2505
+ const [kind, data] = answer === "allow"
2506
+ ? [LEARNED_ALLOWED, { call: call.callId }]
2507
+ : [LEARNED_NODES, (learnedCallRan(await entriesOf(gate.journal, rootOf.id, context), call.callId, call.replayed === true) ? failedRecord : refusedRecord)(call.callId, named.workflow, named.digest, "agent")];
2508
+ await journalOf.commit((tx) => tx.appendEntry(rootOf.id, { kind, data: data }), context).catch(unlessSealed);
2509
+ };
2510
+ const sessionGate = async (call, hookContext) => {
2511
+ const answer = await bridgeGate(call, hookContext);
2512
+ if (answer === "allow" || "deny" in answer)
2513
+ await learnedEntry(call, answer);
2514
+ return answer;
2515
+ };
2453
2516
  // A tool no call of which reaches the gate before it runs (Codex's live search, inside its model requests): its
2454
2517
  // setting now, read again at each request, so a deny or ask set mid-run reaches the next one.
2455
2518
  const permission = spec.gate?.permission;
@@ -2483,7 +2546,7 @@ function adapterLoop(specOf, options, deps) {
2483
2546
  trace?.event(tracedEvent(event, { mcp: (name) => mcp?.catalogOf(specNow?.facts?.hostName?.(name) ?? name) !== undefined, ...(deps.redact ? { redact: deps.redact } : {}) }));
2484
2547
  recorded?.(event);
2485
2548
  };
2486
- const io = { writer, models: counted, signal: deps.signal, onEvent: traceAnd, gate: bridgeGate, ...(permission ? { permission } : {}), hostTool: hosted, ...(ownCalls ? { ownCalls } : {}), bookedCost, keepCalls, ...(record ? {} : { nestedEnded }) };
2549
+ const io = { writer, models: counted, signal: deps.signal, onEvent: traceAnd, gate: sessionGate, ...(permission ? { permission } : {}), hostTool: hosted, ...(ownCalls ? { ownCalls } : {}), bookedCost, keepCalls, ...(record ? {} : { nestedEnded }) };
2487
2550
  // The end-of-run turn an earlier claim asked and never saw end (its runner lost mid look-back or mid compile): the
2488
2551
  // 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
2552
  // session opens. The job's turn ended before it, answered: this pass runs no job turn (no recovery as the job's, no
@@ -2836,9 +2899,9 @@ function adapterLoop(specOf, options, deps) {
2836
2899
  answer = taken(answer);
2837
2900
  const outcome = answer.isError ? "handed_back" : "answered";
2838
2901
  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 LEARNED_NODES
2840
- // `refused`): no workflow ran it, so the money rule charges none and the run names none.
2841
- const refusal = refused ? { call: WORKFLOW_FIRST_CALL, workflow: first.name, digest: first.digest, caller: "platform", nodes: [], ended: "failed", refused: true } : undefined;
2902
+ // A call refused at its gate keeps its record as one the tool refused does (learned-nodes.ts refusedRecord): no
2903
+ // workflow ran it, so the money rule charges none and the run names none.
2904
+ const refusal = refused ? refusedRecord(WORKFLOW_FIRST_CALL, first.name, first.digest, "platform") : undefined;
2842
2905
  await on.commit(async (tx) => {
2843
2906
  if (outcome === "answered")
2844
2907
  await tx.appendEntry(theRoot.id, { kind: KINDS.message, data: { role: "model", text: answer.text, at: now() } });
@@ -2897,7 +2960,7 @@ function adapterLoop(specOf, options, deps) {
2897
2960
  else if (served?.outcome === "handed_back") {
2898
2961
  // The agent's first input: the handback, the server's (its row "AgentRun: …"), the job whole after it. Cut of
2899
2962
  // every secret the runner holds: the workflow's words may quote what its steps read.
2900
- const text = deps.redact ? deps.redact(served.text) : served.text;
2963
+ const text = deps.redact(served.text);
2901
2964
  await record?.message(text, HANDED_BACK_ORIGIN);
2902
2965
  await session.send(text, { origin: HANDED_BACK_ORIGIN });
2903
2966
  }
@@ -3005,7 +3068,7 @@ function adapterLoop(specOf, options, deps) {
3005
3068
  // What the model said last, on the record before the run's end.
3006
3069
  await record?.flushText();
3007
3070
  // 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 ? deps.redact(outcome.error) : outcome.error);
3071
+ await record?.turnEnded(outcome.status, outcome.error === undefined ? undefined : deps.redact(outcome.error));
3009
3072
  await harness.waitForIdle(context);
3010
3073
  const settledEntries = await entriesOf(gate.journal, root.id, context);
3011
3074
  const cutOff = restartLimited(settledEntries);
@@ -3053,7 +3116,7 @@ function adapterLoop(specOf, options, deps) {
3053
3116
  // answer (the same row the run's end would have written).
3054
3117
  const said = outcome.error?.trim() ?? "";
3055
3118
  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 ? deps.redact(said) : said, TURN_ERROR_MAX) : "the turn gave no answer (failed)", now())] }), context);
3119
+ 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
3120
  turn = sendAfterTurn(gate, afterTurn.shift());
3058
3121
  continue;
3059
3122
  }
@@ -3072,7 +3135,7 @@ function adapterLoop(specOf, options, deps) {
3072
3135
  // 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
3136
  // 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
3137
  if (said && spec.record === "loop")
3075
- failedWith = deps.redact ? deps.redact(said) : said;
3138
+ failedWith = deps.redact(said);
3076
3139
  }
3077
3140
  else if (turnEndedOnAsk(settledEntries) !== undefined) {
3078
3141
  // The turn ended on a tool that waits on the person (ask_person ended its turn). With something a tool host keeps
@@ -3605,7 +3668,7 @@ function adapterLoop(specOf, options, deps) {
3605
3668
  /** A job's end as KINDS.jobEnd keeps it: its summary cut of every secret the runner holds, as every summary is when
3606
3669
  * served. */
3607
3670
  function jobEndOf(data, failedWith, endedAt) {
3608
- const end = data.summary !== undefined && deps.redact ? { ...data, summary: deps.redact(data.summary) } : data;
3671
+ const end = data.summary !== undefined ? { ...data, summary: deps.redact(data.summary) } : data;
3609
3672
  return { end, ...(failedWith !== undefined ? { failedWith } : {}), endedAt };
3610
3673
  }
3611
3674
  /** 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 +3704,11 @@ function adapterLoop(specOf, options, deps) {
3641
3704
  await options.beforePersonWait?.();
3642
3705
  if (!session || !gate || gate.sealed || !root)
3643
3706
  return parkingOnAsk();
3644
- if (!holders.length) {
3645
- // Nothing to hold open: the run parks, unless the answer already came, between the question's turn end and here,
3646
- // placed as a steer of the idle session (steer): then its turn is the next, at once, never cut by the park's seal.
3707
+ if (!holders.length || leftForNextTurn) {
3708
+ // Nothing to hold open, or a message of this claim is left for the run's next turn (steer), so none, the answer
3709
+ // included, would reach the wait: the run parks, unless the answer already came, between the question's turn end
3710
+ // and here, placed as a steer of the idle session (steer): then its turn is the next, at once, never cut by the
3711
+ // park's seal.
3647
3712
  const early = idleSteer;
3648
3713
  idleSteer = undefined;
3649
3714
  if (early && (await early.placed))
@@ -3695,13 +3760,16 @@ function adapterLoop(specOf, options, deps) {
3695
3760
  const next = new Promise((resolve, reject) => {
3696
3761
  let done = false;
3697
3762
  let lapsed = false;
3763
+ /** Ended by a message left for the run's next turn (endWaitNow), no hold having lapsed. */
3764
+ let cut = false;
3698
3765
  const finish = (value) => {
3699
3766
  if (done)
3700
3767
  return;
3701
3768
  done = true;
3702
3769
  if (value === "lapsed") {
3703
- for (const hold of waitHolds)
3704
- hold.confirmed?.();
3770
+ if (lapsed)
3771
+ for (const hold of waitHolds)
3772
+ hold.confirmed?.();
3705
3773
  // The run parks on its question (the turn loop's "lapsed"): the person's next message is the resume's.
3706
3774
  parkingOnAsk();
3707
3775
  }
@@ -3715,6 +3783,17 @@ function adapterLoop(specOf, options, deps) {
3715
3783
  if (!mine.sent)
3716
3784
  finish("lapsed");
3717
3785
  }, () => undefined);
3786
+ // So does a message left for the run's next turn (steer), the same way; one left while the wait was starting ends it
3787
+ // as soon as it holds.
3788
+ if (waitTurn === mine) {
3789
+ endWaitNow = () => {
3790
+ cut = true;
3791
+ if (!mine.sent)
3792
+ finish("lapsed");
3793
+ };
3794
+ if (leftForNextTurn)
3795
+ endWaitNow();
3796
+ }
3718
3797
  void (async () => {
3719
3798
  for (;;) {
3720
3799
  await placing;
@@ -3726,7 +3805,7 @@ function adapterLoop(specOf, options, deps) {
3726
3805
  // Not placed (the steer was refused): the next message may be.
3727
3806
  mine.sent = undefined;
3728
3807
  placing = new Promise((resolve) => (mine.placed = resolve));
3729
- if (lapsed)
3808
+ if (lapsed || cut)
3730
3809
  return finish("lapsed");
3731
3810
  }
3732
3811
  }
@@ -3748,6 +3827,7 @@ function adapterLoop(specOf, options, deps) {
3748
3827
  // The pass's MCP credentials go with it.
3749
3828
  mcp?.release();
3750
3829
  mcp = undefined;
3830
+ phaseNow = undefined;
3751
3831
  // The pass's resources go once nothing more is written through them (AdapterRunSpec.release), once each.
3752
3832
  // A park's keeps the run's computer (keepAtPark).
3753
3833
  const release = releaseNow;
@@ -3865,7 +3945,7 @@ function adapterLoop(specOf, options, deps) {
3865
3945
  // A grade's feedback round (feedbackNow): its first ask is told the grade first (feedback-round.ts feedbackAsk), cut
3866
3946
  // of every secret the runner holds. Only a run the agent finished opens one, so its session saw the job.
3867
3947
  if (feedbackNow && !again && step === undefined) {
3868
- const cut = (text) => (deps.redact ? deps.redact(text) : text);
3948
+ const cut = (text) => deps.redact(text);
3869
3949
  prompt = `${feedbackAsk({ ...feedbackNow, text: cut(feedbackNow.text) })}\n\n${prompt}`;
3870
3950
  }
3871
3951
  let timer;
@@ -376,11 +376,9 @@ export declare function liveViewersOf(store: LiveViewerStore, sealKey: Buffer |
376
376
  drop(tag?: string): Promise<void>;
377
377
  };
378
378
  /** `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 (timeline/web-calls.ts webCut), so what the harness stores still parses and keeps
380
- * its links whole for a grader's link check; one whose strings, read joined, hold a held value no cut in place takes (a
381
- * value split across two of them) is "[redacted]" (webHeld). The join is read against the values `cut` holds
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. */
379
+ * string by string inside its JSON (tools.ts webAnswerCut), so what the harness stores still parses and keeps its links
380
+ * whole for a grader's link check; one whose strings, read joined, hold a held value split across two of them is
381
+ * "[redacted]". */
384
382
  export declare function answersCut(tool: HostTool, cut: Redact): HostTool;
385
383
  /** 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
384
  * the claim's environment (claim-secrets.ts: the run's keys from the store, its plane set), the run's registry for an
@@ -28,11 +28,9 @@ import { isWebHostTool } from "../tool-list.js";
28
28
  import { deniedText, noApproverText, runGate } from "../tool-gate.js";
29
29
  import { DECISION_PROVIDER_KEYS, loadToolSettings, recheckPlane, TOOL_PLANE_ENV } from "../tool-plane.js";
30
30
  import { readApprovers } from "../server-approvers.js";
31
- import { ASK_TOOL, askPerson, toolOf } from "../tools.js";
31
+ import { ASK_TOOL, askPerson, toolOf, webAnswerCut } from "../tools.js";
32
32
  import { hostToolOf } from "../host-tools.js";
33
33
  import { WEB_SEARCH_TOOL } from "../web-search.js";
34
- import { webCut } from "../timeline/web-calls.js";
35
- import { withheldWhole } from "../key-refusal.js";
36
34
  import { environmentLine, runZone } from "../environment.js";
37
35
  import { effortGuidance } from "../effort-guidance.js";
38
36
  import { outputContract } from "../answer-json.js";
@@ -67,7 +65,7 @@ import { journalEntries } from "./journal-reader.js";
67
65
  import { hashedMcpOf, piShaped } from "../store-reads/journal.js";
68
66
  import { replayCallsOver } from "./promotion.js";
69
67
  import { learnedFirstWhereHeld } from "./learned-first.js";
70
- import { servedOf } from "./workflow-first.js";
68
+ import { servedOf, workflowDigest } from "./workflow-first.js";
71
69
  import { AUDIT_PARKED, withAudit } from "./audit.js";
72
70
  import { runPathMetricsOverStore } from "../store-reads/learning.js";
73
71
  import { specBuilt } from "./spec-holds.js";
@@ -76,7 +74,7 @@ import { loadArchilSettings } from "../archil-settings.js";
76
74
  import { settingOfDefinition } from "../computer-setting.js";
77
75
  import { computerFilesNote, computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
78
76
  import { computerTurnedOff, hadComputer, recordComputerOff } from "./computer-journal.js";
79
- import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
77
+ import { holdClaimed, mustHold, runnerSecrets } from "./redact.js";
80
78
  import { planBeforeRun, PLAN_PROVIDER } from "../chatgpt-plan.js";
81
79
  import { heldSpecOf } from "./held-run.js";
82
80
  import { loopComputerOf } from "./computer-channel.js";
@@ -333,11 +331,18 @@ export async function adapterRunGate(store, claim, revision, root, shell, option
333
331
  return refused(noApproverText(asks[0].tool, "no"));
334
332
  return asks.length ? { ask: learnedAskShown(asks) } : decision;
335
333
  };
334
+ /** The learned workflow of the run's a learned_workflow call's arguments name, if any. */
335
+ const flowOf = (args) => learned.find((one) => one.name === args?.name);
336
336
  /** The MCP actions the learned workflow a learned_workflow call names can call; none for another call or workflow. */
337
337
  const mcpOf = async (args) => {
338
- const flow = learned.find((one) => one.name === args?.name);
338
+ const flow = flowOf(args);
339
339
  return flow ? learnedMcpCalls(flow.workflow) : [];
340
340
  };
341
+ /** That workflow's name and digest (SpecGate.learnedOf): what the record of a call of it the gate refuses names. */
342
+ const learnedOf = (args) => {
343
+ const flow = flowOf(args);
344
+ return flow ? { workflow: flow.name, digest: workflowDigest(flow) } : undefined;
345
+ };
341
346
  // An ask is named as main's pending approval is (RunGate.askedAs: its settings key), beside the decision, which is
342
347
  // unchanged. The permissions are the learned workflow's (main's toolGate.policy and denyFrom), over the same settings.
343
348
  const permissions = { policy: (tool) => gate.policy(tool), denyFrom: (tool) => gate.denyFrom(tool), refresh: async () => { current = await storeSettings(store); } };
@@ -348,7 +353,7 @@ export async function adapterRunGate(store, claim, revision, root, shell, option
348
353
  current = await storeSettings(store);
349
354
  return current.unreadable ? "deny" : gate.policy(tool);
350
355
  };
351
- return Object.assign(decide, { askedAs: (tool, args) => gate.askedAs(tool, args), permissions, permission, learn: (flows) => void (learned = flows), askedOn: (made) => void (host = made), computerOff: () => gate.computerOff !== undefined, writes: () => gate.writeBar() === undefined });
356
+ return Object.assign(decide, { askedAs: (tool, args) => gate.askedAs(tool, args), permissions, permission, learnedOf, learn: (flows) => void (learned = flows), askedOn: (made) => void (host = made), computerOff: () => gate.computerOff !== undefined, writes: () => gate.writeBar() === undefined });
352
357
  }
353
358
  /** The server's tool settings from the store now; a read that throws is unread (no value of it said). A workflow's call
354
359
  * and model nodes read theirs through it too (workflow-spec.ts callPolicyOf), so both gates fail closed alike. */
@@ -368,13 +373,14 @@ export function adapterRunSpecFromLaunch(launch, run, deps, claim, runner = RUNN
368
373
  return specBuilt((holds) => adapterSpec(launch, run, deps, claim, holds, runner));
369
374
  }
370
375
  async function adapterSpec(launch, run, deps, claim, holds, runner) {
376
+ mustHold(run.redact, "A pi run's spec");
371
377
  const context = BACKGROUND_CONTEXT;
372
378
  // What this claim may reach on loopback, read once for its MCP servers and its calendar_events alike (mcpReachOf).
373
379
  const reach = await mcpReachOf(deps);
374
380
  // The runner's one redactor (the loop's, LoopDeps.redact), for every text a secret could reach: the spec's log lines
375
- // (a release, a workspace's end), the model route's translation and the session's model proxy. A spec built with no
376
- // runner around it cuts every secret the runner's env holds. It holds the keys the claim opens (below), too.
377
- const cut = heldRedactor(run.redact ?? secretRedactor(runnerSecrets(deps.env)));
381
+ // (a release, a workspace's end), the model route's translation and the session's model proxy. It holds the keys the
382
+ // claim opens (below), too.
383
+ const cut = run.redact;
378
384
  const log = (line) => (deps.log ?? (() => { }))(cut(line));
379
385
  holds.logTo(log);
380
386
  const runRow = await deps.store.runs.get(claim.runId);
@@ -455,7 +461,8 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
455
461
  // credentials opened under the server's seal key into this claim's memory, one gateway for the claim. First, before
456
462
  // 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
457
463
  // words before the session opens. The seal key is the runner's own (deps.sealKey), not re-read from the environment.
458
- // A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactor.
464
+ // A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactor. A
465
+ // per_run server the run was handed no credential for is left out of its tools, and its timeline says so.
459
466
  // A held run its model kept from running at its create (hold.refused) opens none: nothing can call one.
460
467
  const heldRefusal = launch.hold?.refused?.message;
461
468
  // What its gateway files (a long answer, a server's results) goes in the run's own files. In Mode 1 that is the run's
@@ -466,7 +473,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
466
473
  // and a call reaches it only through the session this spec returns, after `tools` is made.
467
474
  let filedIn;
468
475
  const hold = (values) => cut.hold(values);
469
- const mcp = heldRefusal !== undefined ? undefined : await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, toolSettings: body.toolSettings, work: () => (mode === 2 ? filedIn ?? ws.workspace : 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 } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, fakes?.web, launch) });
476
+ const mcp = heldRefusal !== undefined ? undefined : await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, toolSettings: body.toolSettings, work: () => (mode === 2 ? filedIn ?? ws.workspace : 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 } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, say: (words) => run.phase?.(words), ...claimMetering(deps, fakes?.web, launch) });
470
477
  // The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
471
478
  holds.hold({ passed: mcp });
472
479
  // The run's computer, from the one shared claim-time function (the CLI spec takes the same): none for a runner place, a
@@ -803,7 +810,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
803
810
  // A run the promoted workflow answered (path `workflow`) starts its shadow audit after the step, drawn at 1 in k (runner/audit.ts
804
811
  // withAudit): at its end, so the shadow's cap is what the run's own left.
805
812
  // A held run (no audits) takes none, and its runner refuses one too (run-child-host.ts heldFor).
806
- const endOfRun = audits === undefined ? undefined : launch.replay || launch.audit ? withGrader(compareEndOfRun(launch, { store: deps.store, log, ...(run.redact ? { redact: run.redact } : {}) }), graderRoute ? { model: graderRoute.model, models: () => run.ledger.models(GRADER, GRADER) } : undefined) : withAudit(learningEndOfRun(launch, {
813
+ const endOfRun = audits === undefined ? undefined : launch.replay || launch.audit ? withGrader(compareEndOfRun(launch, { store: deps.store, log, redact: run.redact }), graderRoute ? { model: graderRoute.model, models: () => run.ledger.models(GRADER, GRADER) } : undefined) : withAudit(learningEndOfRun(launch, {
807
814
  store: deps.store,
808
815
  data: deps.data,
809
816
  ...(deps.env ? { env: deps.env } : {}),
@@ -816,7 +823,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
816
823
  log,
817
824
  // A workflow draft's decision nodes are checked against the host's decision providers, on its keys (LS-07).
818
825
  decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, DECISION_PROVIDER_KEYS)) }),
819
- }), { ...audits, launch, ...(run.redact ? { redact: run.redact } : {}) });
826
+ }), { ...audits, launch, redact: run.redact });
820
827
  return {
821
828
  adapter,
822
829
  facts,
@@ -884,7 +891,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
884
891
  // The path it took, the learned revision it ran on, its learned workflow calls and why its first choice served or
885
892
  // did not, for a run that learns (workflow-first.ts pathMetrics), by the one writer every harness's end calls
886
893
  // (runPathMetricsOverStore).
887
- const path = await runPathMetricsOverStore(deps.store, claim.runId, launch, { ...(run.redact ? { redact: run.redact } : {}), choice: firstChoice.reason });
894
+ const path = await runPathMetricsOverStore(deps.store, claim.runId, launch, { redact: run.redact, choice: firstChoice.reason });
888
895
  // A run its learned workflow served first: that call is on the loop's record (no pi answer carries its tokens), so its
889
896
  // metrics are its booking's, as a CLI harness's run reads them: the workflow's nodes and the agent's own after a handback.
890
897
  // An MCP tool called by a hashed wire name is counted under its catalog name, as its timeline names it.
@@ -1058,29 +1065,16 @@ export function liveViewersOf(store, sealKey, claim, cut) {
1058
1065
  };
1059
1066
  }
1060
1067
  /** `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
1061
- * string by string inside its JSON (timeline/web-calls.ts webCut), so what the harness stores still parses and keeps
1062
- * its links whole for a grader's link check; one whose strings, read joined, hold a held value no cut in place takes (a
1063
- * value split across two of them) is "[redacted]" (webHeld). The join is read against the values `cut` holds
1064
- * (key-refusal.ts withheldWhole), or through `cut` itself when it does not know them (joinCut). Each string is cut once
1065
- * in a call, for the join's read and the answer both. */
1068
+ * string by string inside its JSON (tools.ts webAnswerCut), so what the harness stores still parses and keeps its links
1069
+ * whole for a grader's link check; one whose strings, read joined, hold a held value split across two of them is
1070
+ * "[redacted]". */
1066
1071
  export function answersCut(tool, cut) {
1067
1072
  return {
1068
1073
  ...tool,
1069
1074
  call: async (args, context) => {
1070
1075
  try {
1071
1076
  const answer = await tool.call(args, context);
1072
- const seen = new Map();
1073
- const once = (text) => {
1074
- let out = seen.get(text);
1075
- if (out === undefined)
1076
- seen.set(text, (out = cut(text)));
1077
- return out;
1078
- };
1079
- const holds = (joined, parts) => {
1080
- const values = cut.heldValues?.();
1081
- return values ? withheldWhole(joined, values) : joinCut(joined, parts, once);
1082
- };
1083
- return { ...answer, text: webCut(tool.name, answer.text, once, holds) ?? cut(answer.text) };
1077
+ return { ...answer, text: webAnswerCut(cut)(tool.name, answer.text) ?? cut(answer.text) };
1084
1078
  }
1085
1079
  catch (error) {
1086
1080
  if (error instanceof Error) {
@@ -1094,17 +1088,6 @@ export function answersCut(tool, cut) {
1094
1088
  },
1095
1089
  };
1096
1090
  }
1097
- /** Whether `cut`, a redactor that does not know its values, takes from `joined` (`parts` joined by line breaks) what it
1098
- * does not take from the parts each read alone: a held value split across two parts. Its cut of the join whole being
1099
- * "[redacted]" is not enough: it reads a text longer than a piece in pieces of 8,192 characters (key-refusal.ts
1100
- * redactedAnswer), and a value split inside one piece withholds only that piece, the rest of the join served. It misses
1101
- * nothing: no value split across parts is in a part to cut, so the join's cut and the parts' differ wherever the join
1102
- * holds one; where nothing spans two parts they are the same, as every piece ends at whitespace or inside a run longer
1103
- * than a piece, and a line break ends each part. */
1104
- function joinCut(joined, parts, cut) {
1105
- const whole = cut(joined);
1106
- return whole === "[redacted]" || whole !== parts.map(cut).join("\n");
1107
- }
1108
1091
  /** 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
1109
1092
  * the claim's environment (claim-secrets.ts: the run's keys from the store, its plane set), the run's registry for an
1110
1093
  * extension a binding installs, the install lifecycle (`life`, run by the adapter loop from the spec's `lifecycle`), the
@@ -7,6 +7,7 @@ import { type SessionLike, type SessionModelPort } from "../../port-models.js";
7
7
  import { type CallStatus } from "../journal-kinds.js";
8
8
  import { CALL_REFUSED } from "../../timeline/index.js";
9
9
  import { type ComputerCallRecord } from "../../computer-calls.js";
10
+ import { type HeldRedact } from "../redact.js";
10
11
  /** What the adapter loop lends pi for one claim: the run's Harness, its registry, and where pi's models go. */
11
12
  export interface PiRun {
12
13
  readonly harness: Harness;
@@ -74,7 +75,7 @@ export interface PiAdapterOptions {
74
75
  readonly fetch?: typeof fetch;
75
76
  /** The runner's one redactor, which a provider's error passes through in the session's proxy before pi has it
76
77
  * (ModelProxyOptions.redact; the proxy's own cut of the credential comes first). */
77
- readonly redact?: (text: string) => string;
78
+ readonly redact: HeldRedact;
78
79
  /** pi-native extensions the run's root agent carries beside the session's own (the browser's durable extension, as a
79
80
  * pi DurableRun on main installs it): installed in the claim's registry, so their tools run as pi's own tool tasks (a
80
81
  * taskId, a memo, conversations they own) and their own task kinds (a browser.release) under pi's recovery, all in the
@@ -119,7 +120,7 @@ export interface TierProxies {
119
120
  * keys, AdapterSession.port's `tier`), sent by pi-ai's client of the tier model's own wire (port-models.ts), so a tier
120
121
  * proxy speaks its model's route (model-route.ts routeOf, its translation fetch for a model of neither wire), never the
121
122
  * harness's. One that fails to start closes those started. */
122
- export declare function openTierProxies(tiers: ReadonlyMap<string, TierModel>, hooks: SessionIO["models"], redact?: (text: string) => string, tools?: readonly string[]): Promise<TierProxies>;
123
+ export declare function openTierProxies(tiers: ReadonlyMap<string, TierModel>, hooks: SessionIO["models"], redact: (text: string) => string, tools?: readonly string[]): Promise<TierProxies>;
123
124
  /** The session proxy's policy on Messages: claude-agent's (no fork), with pi's tools, the host's own names (`tools`), as
124
125
  * the names its client offers by themselves (its builtins). The CLI's own `mcp__hands__` prefix is not pi's: under it
125
126
  * every one of pi's tool definitions would be dropped and the model offered none. Every other tool definition is
@@ -13,6 +13,7 @@ import { sessionProvider, tierProvider } from "../../port-models.js";
13
13
  import { KINDS } from "../journal-kinds.js";
14
14
  import { CALL_REFUSED } from "../../timeline/index.js";
15
15
  import { recordingCalls } from "../../computer-calls.js";
16
+ import { mustHold } from "../redact.js";
16
17
  /** `extension` with each of its tools run inside recordingCalls, its calls kept by `keep` under the call's id. A call pi
17
18
  * runs again after a restart keeps what that attempt makes: a code mode script's replay hands back the results of the
18
19
  * calls its earlier attempt made, never making them again, so none is kept twice. The earlier attempt's own record goes
@@ -64,6 +65,7 @@ const HOST_VALUE = "agentrun.value";
64
65
  const INPUT_REQUEST = "agentrun:input";
65
66
  /** pi as an AgentAdapter for one claim's run. */
66
67
  export function piAdapter(options) {
68
+ mustHold(options.redact, "A pi adapter");
67
69
  return {
68
70
  // pi is the default harness: its id is the harness table's, never a literal of its own.
69
71
  id: DEFAULT_HARNESS,
@@ -116,7 +118,7 @@ async function routeProxy(route, hooks, tools, redact, tier, webSearch = false)
116
118
  ...(price ? { price: price } : {}),
117
119
  ...(route.provider.headers ? { headers: route.provider.headers } : {}),
118
120
  ...(route.fetch ? { fetch: route.fetch } : {}),
119
- ...(redact ? { redact } : {}),
121
+ redact,
120
122
  }, randomBytes(32).toString("base64url"));
121
123
  }
122
124
  /** A run's models of other tiers than its own (a learned workflow's node of a tier: AGENT_MODEL_FAST, AGENT_MODEL_STRONG),
@@ -49,7 +49,7 @@ export declare const AUDIT_PARKED = "the audit ended where it would wait on a pe
49
49
  * could never be audited (no learning start, or not auditableLaunch) keeps `step` as it is. */
50
50
  export declare function withAudit(step: EndOfRunTurn | undefined, deps: AuditDeps & {
51
51
  readonly launch: RunLaunch;
52
- readonly redact?: (text: string) => string;
52
+ readonly redact: (text: string) => string;
53
53
  }): EndOfRunTurn | undefined;
54
54
  /** Starts the shadow of run `runId`, at its end, when the learned workflow `serve` served it first and its id is drawn:
55
55
  * never for a replay or a shadow, a run that does not learn, one not auditable (auditableLaunch: a trigger started it,