@parcha/agentrun-harness-codex 0.1.0-beta.62 → 0.1.0-beta.63
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 +10 -0
- package/dist/adapter.d.ts +3 -1
- package/dist/adapter.js +10 -2
- package/dist/code-mode.d.ts +5 -2
- package/dist/code-mode.js +19 -8
- package/dist/harness.d.ts +5 -1
- package/dist/harness.js +7 -3
- package/dist/host/machine.d.ts +2 -0
- package/dist/host/machine.js +1 -0
- package/dist/host/process.d.ts +2 -2
- package/dist/host/process.js +1 -1
- package/dist/scripts.d.ts +19 -8
- package/dist/scripts.js +44 -25
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## 0.1.0-beta.63 (2026-11-26)
|
|
6
|
+
|
|
7
|
+
- A tool result is held to the model's context window, not only to the fixed 120,000-character bound: a model with a small window (an Ollama model at 65,536 tokens, a 16k one) is never handed a result that fills its context. <!-- changes/tool-result-window-bound.md -->
|
|
8
|
+
- `boundResult(text, budget?)` takes the model's window (`{ contextWindow, baseInputTokens? }`): a result may take at most a quarter of what the window leaves (`RESULT_WINDOW_SHARE`), at three characters a token (`RESULT_CHARS_PER_TOKEN`), and never more than `HOST_RESULT_MAX_CHARS`. Past that it is cut with a note saying it was cut to fit the window and how to read on; a window too small for any cut refuses the result in words, and a result of at most 400 characters (`RESULT_ALWAYS_WHOLE_CHARS`) always stands whole, so bounding a bound changes nothing. With no window the bound is exactly as before. `resultMaxChars(budget)` gives the bound, and `boundTo(text, max)` cuts to a given bound, saying how (`ResultBound`: the characters kept, the whole length, the bound).
|
|
9
|
+
- `SessionSpec.contextWindow` carries the session model's window, and each harness adapter (Claude, Codex, ACP, OpenCode) takes a `contextWindow` option for when the host passes none; Codex and OpenCode are told that window in place of their 272,000 guess. A Codex script cut off by a crash is answered within the same bound (`recoveryMaxChars`), not `EXEC_RECOVERY_MAX_CHARS`.
|
|
10
|
+
- agentrun-serve puts the run's model window from its catalog on every session, and pi now holds every tool result to it too: a host tool's and a pi-native one's (web_fetch, web_search, the browser's), which before reached the model up to pi's own output limits. What a host tool streams while it runs is held to the bound too (`boundedProgress`), since pi writes a call cut off past its restart limit from that text, without its hooks.
|
|
11
|
+
- A turn's results together fit what the window has left (`TurnBudget`, `ResultBudget.turn`): from what the context already holds (the last request's input tokens and its answer's output, else the session's system prompt and tool schemas counted with o200k), less the room kept for the model's answer (`answerReserve`: a quarter of the window, at most `ANSWER_RESERVE_MAX_TOKENS`, 16,384 tokens), each call the model made takes the smaller of its own bound and what is left over the calls still unanswered, so parallel calls split it, and below the least a cut keeps a result is refused in words. The kernel owns the rule; the session's model proxy reports each answer's facts (`ModelProxyOptions.turn`, its calls counted from the stream by `toolCallsIn`) for Claude, Codex, OpenCode and Goose, and pi and Claude Code on a person's login report them from their own hooks (pi's afterResponse, the login's stream booking). `windowBudget(window, system?)` builds the budget with its turn. A call whose result goes to the harness's own tool rather than the model (`ToolBridgeOptions.outsideTurn`: Codex's code-mode script calls) takes the per-result bound alone, outside the turn's split.
|
|
12
|
+
- The bridge records each cut it hands a harness (`bound:<callId>`, `boundKey`), and a replay of the call is cut by that record. Codex compares a nested call's two records on those lengths, never on the note's words; `boundOf` is gone. A session written before the record still agrees where Codex got the host's bound's cut, as before.
|
|
13
|
+
- On Claude, Codex, ACP and OpenCode, a turn's budget outlasts a process that stops in the turn (a park, a crash): each answer's facts and each result's length as it was handed go to the session's journal as they happen (`journalTurn`, `TURN_STREAM`), and a budget that has read no answer yet takes them back before any call claims (`TurnBudget.restore`). The calls a resume answers split what their answer left, and a result handed before the stop keeps its part. Codex's recovered script outputs claim their room in the turn too and are held to that claim (`ResultBudget.maxChars`). pi's turn budget is not journaled yet: a pi session opened again starts a fresh one, and each result there keeps its per-result bound.
|
|
14
|
+
|
|
5
15
|
## 0.1.0-beta.59 (2026-11-25)
|
|
6
16
|
|
|
7
17
|
- A model the runner's route translates onto a harness's wire (this machine's Ollama models on Anthropic's Messages and OpenAI's Responses) is offered only to a harness whose proxy forwards with the route's `fetch`, and the Messages translation no longer drops what it can't run. Before, any harness on the wire was offered those models, including a module that sends its requests to the network, where nothing answers. <!-- changes/b51-route-hints.md -->
|
package/dist/adapter.d.ts
CHANGED
|
@@ -49,7 +49,9 @@ export interface CodexAdapterOptions {
|
|
|
49
49
|
webSearch?: CodexWebSearch;
|
|
50
50
|
/** The most output tokens one request may ask for. Default 32 000. */
|
|
51
51
|
maxOutputTokens?: number;
|
|
52
|
-
/** The model's context window
|
|
52
|
+
/** The model's context window, in tokens: Codex is told it (`model_context_window`), and the host's bound on one tool
|
|
53
|
+
* result is its share of it (the kernel's resultMaxChars). A session's own (SessionSpec.contextWindow) wins. With
|
|
54
|
+
* neither, Codex is told 272 000 and the host's bound alone holds a result. */
|
|
53
55
|
contextWindow?: number;
|
|
54
56
|
/** Where sessions keep their private directories when the host lends none (`io.dir`): one per session key. */
|
|
55
57
|
sessionsDir?: string;
|
package/dist/adapter.js
CHANGED
|
@@ -14,7 +14,7 @@ import { join } from "node:path";
|
|
|
14
14
|
import { HOST_RESULT_MAX_CHARS, READ_SKILL_FILE, hostedTool, readSkillFileTool, skillProblems, toolSchemaProblems } from "@parcha/agentrun-kernel";
|
|
15
15
|
import { abortedOutcome, openDrive, SessionHalt } from "@parcha/agentrun-kernel/kernel";
|
|
16
16
|
import { pendingSubmissions } from "@parcha/agentrun-kernel/kernel";
|
|
17
|
-
import { bridgeTool, NativeJournal, recoveryNote, settleTurn, transcriptOf } from "@parcha/agentrun-kernel/process";
|
|
17
|
+
import { bridgeTool, NativeJournal, recoveryNote, settleTurn, transcriptOf, windowBudget } from "@parcha/agentrun-kernel/process";
|
|
18
18
|
import { codexSchemaProblems, describedDescription } from "./schema.js";
|
|
19
19
|
import { markParked } from "./scripts.js";
|
|
20
20
|
import { withCheckedBinary } from "./host/sandbox.js";
|
|
@@ -148,6 +148,10 @@ export function codexAdapter(options) {
|
|
|
148
148
|
const hostNames = new Map(tools.map((t) => [codexToolName(t.name), t.name]));
|
|
149
149
|
const hostName = (name) => hostNames.get(name) ?? name;
|
|
150
150
|
const effort = spec.effort ?? spec.thinking;
|
|
151
|
+
const window = spec.contextWindow ?? options.contextWindow;
|
|
152
|
+
// Each tool result held to the model's share of the window, and a turn's results to what it has left, which the
|
|
153
|
+
// session's model proxy reads from each answer (its turn).
|
|
154
|
+
const budget = windowBudget(window, spec.system);
|
|
151
155
|
// The live search runs inside a model request, where no call reaches the gate: it is offered only while the host's
|
|
152
156
|
// web_search setting allows it, read before each request (a deny or ask set mid-run drops it from the next one).
|
|
153
157
|
const searchAllowed = options.webSearch && io.permission ? async () => (await io.permission("web_search")) === "allow" : undefined;
|
|
@@ -184,7 +188,10 @@ export function codexAdapter(options) {
|
|
|
184
188
|
...(effort ? { effort } : {}),
|
|
185
189
|
credential: async () => options.provider.credential(),
|
|
186
190
|
gatewayUrl: options.provider.origin,
|
|
187
|
-
|
|
191
|
+
// The window the host knows (the session's, from its catalog; else this adapter's). Only with neither is Codex told
|
|
192
|
+
// 272,000, a guess at a large OpenAI model's, and then no tool result is held to it: the host's bound alone.
|
|
193
|
+
contextWindow: window ?? 272_000,
|
|
194
|
+
...budget,
|
|
188
195
|
...(options.log ? { log: options.log } : {}),
|
|
189
196
|
...(options.standIn ? { test: { command: options.standIn.command, args: options.standIn.args ?? [] } } : {}),
|
|
190
197
|
machine: {
|
|
@@ -201,6 +208,7 @@ export function codexAdapter(options) {
|
|
|
201
208
|
...(options.webSearch ? { webSearch: options.webSearch, ...(searchAllowed ? { searchAllowed } : {}) } : {}),
|
|
202
209
|
proxy: {
|
|
203
210
|
hooks: io.models,
|
|
211
|
+
...(budget.resultBudget?.turn ? { turn: budget.resultBudget.turn } : {}),
|
|
204
212
|
tools: tools.map((t) => codexToolName(t.name)),
|
|
205
213
|
...(options.log ? { log: options.log } : {}),
|
|
206
214
|
...(options.price ? { price: options.price } : {}),
|
package/dist/code-mode.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OwnCalls } from "@parcha/agentrun-kernel";
|
|
2
2
|
import type { DriveContext } from "./host/kernel.js";
|
|
3
|
-
import type { SessionMachine } from "./host/process.js";
|
|
3
|
+
import type { ResultBudget, SessionMachine } from "./host/process.js";
|
|
4
4
|
import { type RolloutSummary } from "./rollout.js";
|
|
5
5
|
/** The stream that ties each nested call to the `exec` it ran under: `{ callId, exec, since }` (`since`: the turn it ran in), written before the call runs. */
|
|
6
6
|
export declare const NESTED_STREAM = "codex.nested";
|
|
@@ -64,6 +64,9 @@ export interface CodeModeDeps {
|
|
|
64
64
|
/** The host's record of each `exec` (SessionIO.ownCalls): its row from its rollout lines, and each nested call it makes
|
|
65
65
|
* named under it before the call reaches the gate. */
|
|
66
66
|
ownCalls?: OwnCalls;
|
|
67
|
+
/** The bridge's budget (CodexHarnessOptions.resultBudget): a result handed Codex from the log is held to it as the
|
|
68
|
+
* bridge holds one it runs. */
|
|
69
|
+
budget?: ResultBudget;
|
|
67
70
|
}
|
|
68
71
|
interface Dangling {
|
|
69
72
|
callId: string;
|
|
@@ -122,7 +125,7 @@ export declare function codeMode(deps: CodeModeDeps): {
|
|
|
122
125
|
* held to the host's bound as the tool bridge holds a call's result (`boundResult`): these come from the log, not through the bridge, and
|
|
123
126
|
* both repairs (with a recovery note and without) inject what this leaves. A recovered script's output (a cut-off exec's, a resumed
|
|
124
127
|
* `wait`'s) quotes each finished call's result as the script was handed it and holds its whole to its own bound
|
|
125
|
-
* (scripts.ts
|
|
128
|
+
* (scripts.ts recoveryMaxChars, at the session's window); on a resume, the calls it tells the outcome of are recorded for the note (SHOWN_STREAM). `resume`: the open turn a recovery note resumes, whose
|
|
126
129
|
* parked nested calls run now; the repair of an ended turn (repairUnnoted) only tells, and runs nothing. */
|
|
127
130
|
recoverItems(items: Record<string, unknown>[], dangling: readonly Dangling[], lines: readonly string[], since: number, resume?: boolean): Promise<void>;
|
|
128
131
|
/** With no recovery note, the calls the rollout has no output for get theirs from the log before any turn is sent: a turn that ended without
|
package/dist/code-mode.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { boundResult, failureText, openTurn, recoveryNote, recoverySystemNote, recoveryUserTurn, toolKey, transcriptOf } from "./host/process.js";
|
|
1
|
+
import { boundKey, boundResult, failureText, openTurn, recoveryNote, recoverySystemNote, recoveryUserTurn, toolKey, transcriptOf } from "./host/process.js";
|
|
2
2
|
// cycle with harness.ts: read repairOutput only inside functions, never at module top level (pinned by "code mode and the harness
|
|
3
3
|
// load in either order and the repair reads repairOutput"). A host loads harness.js first, so at that point none of its const bindings is set.
|
|
4
4
|
import { repairOutput } from "./harness.js";
|
|
@@ -50,10 +50,14 @@ const failedText = (error) => (error ? failureText(error) : "");
|
|
|
50
50
|
function factOf(state, rolled, tie, told = new Map()) {
|
|
51
51
|
const e = state.effects.get(toolKey(tie.callId));
|
|
52
52
|
const status = told.get(tie.callId);
|
|
53
|
+
// The bridge's record of the cut it handed Codex, if it cut the result: what settle compares the two records on.
|
|
54
|
+
const cut = state.effects.get(boundKey(tie.callId));
|
|
55
|
+
const bound = cut?.status === "completed" ? cut.output : undefined;
|
|
56
|
+
const lengths = bound && typeof bound.kept === "number" && typeof bound.whole === "number" ? { bound: { kept: bound.kept, whole: bound.whole } } : {};
|
|
53
57
|
return {
|
|
54
58
|
callId: tie.callId,
|
|
55
59
|
tool: e ? e.name.replace(/^tool\./, "") : (rolled.get(tie.callId)?.tool ?? tie.tool ?? "a tool"),
|
|
56
|
-
...(e ? { store: { status: e.status === "completed" ? "completed" : e.status === "failed" ? "failed" : "started", text: e.status === "failed" ? failedText(e.error) : outputTextOf(e.output), ...(e.status === "completed" ? sentOf(e.output) : {}), ...(e.error?.interrupted ? { interrupted: true } : {}) } } : {}),
|
|
60
|
+
...(e ? { store: { status: e.status === "completed" ? "completed" : e.status === "failed" ? "failed" : "started", text: e.status === "failed" ? failedText(e.error) : outputTextOf(e.output), ...(e.status === "completed" ? sentOf(e.output) : {}), ...(e.error?.interrupted ? { interrupted: true } : {}), ...lengths } } : {}),
|
|
57
61
|
...(rolled.has(tie.callId) ? { rollout: rolled.get(tie.callId) } : {}),
|
|
58
62
|
...(status ? { told: status } : {}),
|
|
59
63
|
...(state.effects.get(parkedKey(tie.callId))?.status === "completed" ? { parked: true } : {}),
|
|
@@ -224,7 +228,7 @@ export function codeMode(deps) {
|
|
|
224
228
|
// parses it, so no words go before it.
|
|
225
229
|
if (callId !== undefined && NESTED_CALL.test(callId) && again.sent !== undefined)
|
|
226
230
|
return again.sent;
|
|
227
|
-
return boundResult(`Recorded earlier in this turn, not run again: ${again.text}
|
|
231
|
+
return boundResult(`Recorded earlier in this turn, not run again: ${again.text}`, deps.budget).text;
|
|
228
232
|
}
|
|
229
233
|
/** The cell a dangling call waited on, when it is code mode's `wait` (a function call named `wait` with a `cell_id`, and no host tool of
|
|
230
234
|
* that name); otherwise `undefined`. */
|
|
@@ -295,7 +299,7 @@ export function codeMode(deps) {
|
|
|
295
299
|
* held to the host's bound as the tool bridge holds a call's result (`boundResult`): these come from the log, not through the bridge, and
|
|
296
300
|
* both repairs (with a recovery note and without) inject what this leaves. A recovered script's output (a cut-off exec's, a resumed
|
|
297
301
|
* `wait`'s) quotes each finished call's result as the script was handed it and holds its whole to its own bound
|
|
298
|
-
* (scripts.ts
|
|
302
|
+
* (scripts.ts recoveryMaxChars, at the session's window); on a resume, the calls it tells the outcome of are recorded for the note (SHOWN_STREAM). `resume`: the open turn a recovery note resumes, whose
|
|
299
303
|
* parked nested calls run now; the repair of an ended turn (repairUnnoted) only tells, and runs nothing. */
|
|
300
304
|
async recoverItems(items, dangling, lines, since, resume = false) {
|
|
301
305
|
const ties = (await journal.read(NESTED_STREAM)).map((r) => r.data);
|
|
@@ -347,10 +351,15 @@ export function codeMode(deps) {
|
|
|
347
351
|
const yielders = new Scripts();
|
|
348
352
|
for (const line of lines)
|
|
349
353
|
yielders.note(line);
|
|
350
|
-
// The outputs built here hold their quoted results to their own bound (scripts.ts
|
|
354
|
+
// The outputs built here hold their quoted results to their own bound (scripts.ts recoveryMaxChars, at the session's window): every other is
|
|
351
355
|
// held to the host's below. The calls whose outcome they tell, for the turn's recovery note.
|
|
352
356
|
const built = new Set();
|
|
353
357
|
const shown = [];
|
|
358
|
+
// Each output is one result the model reads in this turn: it claims its room in the turn's budget (the answer's facts,
|
|
359
|
+
// taken back from the journal by a new process), as a call through the bridge does, and is held to that claim.
|
|
360
|
+
const turn = deps.budget?.turn;
|
|
361
|
+
await turn?.ready();
|
|
362
|
+
const budgets = dangling.map((c) => (deps.budget && turn ? { ...deps.budget, maxChars: turn.claim(c.callId, deps.budget.contextWindow) } : deps.budget));
|
|
354
363
|
dangling.forEach((c, i) => {
|
|
355
364
|
if (!isExec(c)) {
|
|
356
365
|
// Code mode's `wait` on a cell had started: the generic answer, that the call never started, would be false.
|
|
@@ -361,7 +370,7 @@ export function codeMode(deps) {
|
|
|
361
370
|
const done = state.effects.get(toolKey(c.callId));
|
|
362
371
|
const pictured = cell === undefined && done?.status === "completed" ? imagesNoted(done.output) : undefined;
|
|
363
372
|
const answered = cell !== undefined && i === carrier && yieldedTies.length > 0 ? yieldedTies.map((tie) => ({ ...factOf(state, rolled, tie, told), resumed: resumed.get(tie.callId) })) : undefined;
|
|
364
|
-
const recovered = answered && cell !== undefined ? waitResumed(cell, answered) : undefined;
|
|
373
|
+
const recovered = answered && cell !== undefined ? waitResumed(cell, answered, budgets[i]) : undefined;
|
|
365
374
|
const waited = cell === undefined ? undefined : recovered ? recovered.output : waitStoppedText(cell);
|
|
366
375
|
if (recovered) {
|
|
367
376
|
built.add(i);
|
|
@@ -376,7 +385,7 @@ export function codeMode(deps) {
|
|
|
376
385
|
}
|
|
377
386
|
const { own, loose } = listed.get(c.callId);
|
|
378
387
|
// Only the calls the output still tells after its bound: a call cut from it is not said to be above.
|
|
379
|
-
const recovered = execRecovery(own, loose);
|
|
388
|
+
const recovered = execRecovery(own, loose, budgets[i]);
|
|
380
389
|
items[i] = { type: "custom_tool_call_output", call_id: c.callId, output: recovered.output };
|
|
381
390
|
journal.append(RECOVERED_END_STREAM, { exec: c.callId, failed: recoveredFailed(own) });
|
|
382
391
|
built.add(i);
|
|
@@ -384,7 +393,9 @@ export function codeMode(deps) {
|
|
|
384
393
|
});
|
|
385
394
|
items.forEach((item, i) => {
|
|
386
395
|
if (!built.has(i) && typeof item.output === "string")
|
|
387
|
-
item.output = boundResult(item.output).text;
|
|
396
|
+
item.output = boundResult(item.output, budgets[i]).text;
|
|
397
|
+
if (typeof item.output === "string")
|
|
398
|
+
turn?.settle(dangling[i].callId, item.output.length);
|
|
388
399
|
});
|
|
389
400
|
if (resume && shown.length > 0)
|
|
390
401
|
journal.append(SHOWN_STREAM, { since, callIds: shown });
|
package/dist/harness.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GateAnswer, GateCall, OwnCalls } from '@parcha/agentrun-kernel';
|
|
2
2
|
import { type Harness, type HostTool, type ReplayPolicy, type SessionState, type Submission } from './host/kernel.js';
|
|
3
|
-
import { type AcquireMachine } from './host/process.js';
|
|
3
|
+
import { type AcquireMachine, type ResultBudget } from './host/process.js';
|
|
4
4
|
import { type TomlValue } from './config.js';
|
|
5
5
|
import { type RolloutCall } from './rollout.js';
|
|
6
6
|
/**
|
|
@@ -117,6 +117,10 @@ export interface CodexHarnessOptions {
|
|
|
117
117
|
name?: string;
|
|
118
118
|
/** The model's context window (Gateway ids are unknown to Codex). Default 272,000. */
|
|
119
119
|
contextWindow?: number;
|
|
120
|
+
/** What the session's model can take of one tool result (its context window): the tool bridge holds every result to
|
|
121
|
+
* it (boundResult's budget), and so does each result code mode hands Codex from the log. Absent: the host's bound
|
|
122
|
+
* alone (HOST_RESULT_MAX_CHARS). */
|
|
123
|
+
resultBudget?: ResultBudget;
|
|
120
124
|
/** Extra `config.toml` settings, merged over the generated ones. The keys the harness sets itself (`RESERVED_CONFIG_KEYS`) throw. */
|
|
121
125
|
config?: Record<string, TomlValue>;
|
|
122
126
|
/** How often to read the inbox for steers while a turn runs, without hints. Default 500 ms (5 s with hints). */
|
package/dist/harness.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
// Changed by Parcha, and AgentRun's own since the port from upstream froze on 2026-11-07.
|
|
4
4
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
5
5
|
import { Unavailable, UNAVAILABLE_STEP } from './host/kernel.js';
|
|
6
|
-
import { BuiltinCalls, CODEX_ROUTES, failureText, gatewayCredential, gatewayHandler, gatewayUrl, isBrandedMachine, ModelSteps, Mutex, NativeJournal, placeSubmissions, recoveryNote, restartEvent, resumeUnstartedCalls, settleAbandonedModelSteps, toolBridge, toolKey, transcriptOf, } from './host/process.js';
|
|
6
|
+
import { BuiltinCalls, CODEX_ROUTES, failureText, gatewayCredential, gatewayHandler, gatewayUrl, isBrandedMachine, ModelSteps, journalTurn, Mutex, NativeJournal, placeSubmissions, recoveryNote, restartEvent, resumeUnstartedCalls, settleAbandonedModelSteps, toolBridge, toolKey, transcriptOf, } from './host/process.js';
|
|
7
7
|
import { acknowledgeInDrive, attachInDrive, cliPath, CODEX_CLI, DriveFiles, SANDBOX_DOC } from './host/sandbox.js';
|
|
8
8
|
import { AppServer } from './app-server.js';
|
|
9
9
|
import { codeMode } from './code-mode.js';
|
|
10
|
+
import { NESTED_CALL } from './scripts.js';
|
|
10
11
|
import { danglingCalls, nextRolloutOrdinal, settleCall } from './transcript.js';
|
|
11
12
|
import { BUILTINS_ON, checkConfig, codexConfig, toToml } from './config.js';
|
|
12
13
|
import { callIdOf, endsTurn, isRolloutPath, isSessionMeta, rolloutPathIn, rolloutStream, rolloutText, summarizeRollout, THREAD_STREAM, } from './rollout.js';
|
|
@@ -147,6 +148,8 @@ export function codexHarness(options = {}) {
|
|
|
147
148
|
/** One drive on one attach of the session's VM. */
|
|
148
149
|
async function driveOn(ctx, spec, deadline, invocation, held) {
|
|
149
150
|
const journal = new NativeJournal(ctx);
|
|
151
|
+
// The turn's budget kept on this drive's journal: a resume answers the calls it left on its answer's facts.
|
|
152
|
+
journalTurn(options.resultBudget?.turn, journal);
|
|
150
153
|
// A rollout that keeps being tampered with (only possible under
|
|
151
154
|
// danger-full-access): the turn ends, instead of a redelivery that boots
|
|
152
155
|
// the VM and spends model calls again.
|
|
@@ -208,7 +211,8 @@ export function codexHarness(options = {}) {
|
|
|
208
211
|
// A `never` tool waits for the journal: its call is in the log before its intent (the barrier ran first, below).
|
|
209
212
|
// The host's gate first, inside the bridge: after the call's line is in the log (the barrier) and before its intent, so
|
|
210
213
|
// a refused or parked call leaves no intent, and a parked one's line is there for the resume to settle it.
|
|
211
|
-
|
|
214
|
+
// A code-mode script's calls (Codex's own `exec-<uuid>` ids) answer the script, not the model: outside the turn's split.
|
|
215
|
+
const bridge = toolBridge(ctx, tools, { beforeNever: () => journal.flush(), ...(options.gate ? { gate: options.gate } : {}), ...(options.resultBudget ? { budget: options.resultBudget } : {}), outsideTurn: (callId) => NESTED_CALL.test(callId) });
|
|
212
216
|
/** What the model must hear about this attach (a lost Drive), once per invocation, with its first message; acknowledged after that turn. */
|
|
213
217
|
let notes = machine.notes.length && !invocation.notesShown ? machine.notes.map((n) => `[Sandbox] ${n}`).join('\n') : undefined;
|
|
214
218
|
let proc;
|
|
@@ -374,7 +378,7 @@ export function codexHarness(options = {}) {
|
|
|
374
378
|
}
|
|
375
379
|
mirror();
|
|
376
380
|
};
|
|
377
|
-
const code = codeMode({ ctx, machine, journal, logged, synced, bridge, log, lines, rpc: () => rpc, guard: (p) => guard(p), threadId: () => threadId, tries: BARRIER_TRIES, declined: LAGGING_RESULT, ...(options.ownCalls ? { ownCalls: options.ownCalls } : {}) });
|
|
381
|
+
const code = codeMode({ ctx, machine, journal, logged, synced, bridge, log, lines, rpc: () => rpc, guard: (p) => guard(p), threadId: () => threadId, tries: BARRIER_TRIES, declined: LAGGING_RESULT, ...(options.ownCalls ? { ownCalls: options.ownCalls } : {}), ...(options.resultBudget ? { budget: options.resultBudget } : {}) });
|
|
378
382
|
/**
|
|
379
383
|
* The hard barrier before a `never` call (§5.6): its `function_call`
|
|
380
384
|
* line in the log, flushed, before its intent. Codex's rollout writer is
|
package/dist/host/machine.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export interface LocalMachineOptions {
|
|
|
31
31
|
* from the harness. */
|
|
32
32
|
proxy: {
|
|
33
33
|
hooks: ModelProxyHooks;
|
|
34
|
+
/** The session's turn budget (ResultBudget.turn), which the proxy opens with each answer's facts. */
|
|
35
|
+
turn?: ModelProxyOptions["turn"];
|
|
34
36
|
tools: readonly string[];
|
|
35
37
|
price?: ModelProxyOptions["price"];
|
|
36
38
|
maxOutputTokens?: number;
|
package/dist/host/machine.js
CHANGED
|
@@ -236,6 +236,7 @@ export function localMachine(options) {
|
|
|
236
236
|
},
|
|
237
237
|
}),
|
|
238
238
|
hooks: options.proxy.hooks,
|
|
239
|
+
...(options.proxy.turn ? { turn: options.proxy.turn } : {}),
|
|
239
240
|
model: route.models.model,
|
|
240
241
|
origin: route.target,
|
|
241
242
|
credential: async () => (await route.credential()) ?? "",
|
package/dist/host/process.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { toolBridge as kernelToolBridge, type ToolBridge, type ToolBridgeOptions
|
|
|
2
2
|
import type { CapCut, JsonValue, ToolImage } from "@parcha/agentrun-kernel";
|
|
3
3
|
import type { TomlValue } from "../config.js";
|
|
4
4
|
import type { DriveContext } from "./kernel.js";
|
|
5
|
-
export { boundResult, BuiltinCalls, failureText, Mutex, NativeJournal, openTurn, placeSubmissions, recoveryNote, recoverySystemNote, recoveryUserTurn, restartEvent, resumeUnstartedCalls, toolKey, transcriptOf, } from "@parcha/agentrun-kernel/process";
|
|
6
|
-
export type { BuiltinStart, ToolResult, TranscriptEntry } from "@parcha/agentrun-kernel/process";
|
|
5
|
+
export { boundKey, boundResult, BuiltinCalls, failureText, journalTurn, Mutex, NativeJournal, openTurn, placeSubmissions, recoveryNote, recoverySystemNote, recoveryUserTurn, restartEvent, resultMaxChars, resumeUnstartedCalls, toolKey, transcriptOf, } from "@parcha/agentrun-kernel/process";
|
|
6
|
+
export type { BuiltinStart, ResultBudget, ToolResult, TranscriptEntry } from "@parcha/agentrun-kernel/process";
|
|
7
7
|
/** What a call answered beside its text: its images, and its value (a computer tool's, its images' data left out). */
|
|
8
8
|
export type CallExtras = {
|
|
9
9
|
readonly images?: readonly ToolImage[];
|
package/dist/host/process.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// and, written for AgentRun, the session machine's types (a local machine, machine.ts), its brand, the model route the
|
|
3
3
|
// harness describes for its model proxy (the policy), and model-step tracking (nothing to track locally).
|
|
4
4
|
import { toolBridge as kernelToolBridge } from "@parcha/agentrun-kernel/process";
|
|
5
|
-
export { boundResult, BuiltinCalls, failureText, Mutex, NativeJournal, openTurn, placeSubmissions, recoveryNote, recoverySystemNote, recoveryUserTurn, restartEvent, resumeUnstartedCalls, toolKey, transcriptOf, } from "@parcha/agentrun-kernel/process";
|
|
5
|
+
export { boundKey, boundResult, BuiltinCalls, failureText, journalTurn, Mutex, NativeJournal, openTurn, placeSubmissions, recoveryNote, recoverySystemNote, recoveryUserTurn, restartEvent, resultMaxChars, resumeUnstartedCalls, toolKey, transcriptOf, } from "@parcha/agentrun-kernel/process";
|
|
6
6
|
export function toolBridge(ctx, tools, options) {
|
|
7
7
|
const bridge = kernelToolBridge(ctx, tools, options);
|
|
8
8
|
const extras = new Map();
|
package/dist/scripts.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DriveContext } from "@parcha/agentrun-kernel/kernel";
|
|
2
|
+
import { type ResultBudget } from "./host/process.js";
|
|
2
3
|
/** The id Codex gives a host tool called from a code-mode script. */
|
|
3
4
|
export declare const NESTED_CALL: RegExp;
|
|
4
5
|
/** What the session is told when the proxy could not watch an answer to its end: the answer may carry an `exec` it did not see, so
|
|
@@ -68,7 +69,11 @@ export interface NestedFact {
|
|
|
68
69
|
status: "completed" | "failed" | "started";
|
|
69
70
|
text?: string;
|
|
70
71
|
interrupted?: boolean; /** What a script's nested call was sent for a tool with a value (scriptAnswer: the value as JSON, its images' data in it), which the rollout holds instead of `text`. */
|
|
71
|
-
sent?: string;
|
|
72
|
+
sent?: string; /** How the bridge cut the result it handed Codex (its record, `boundKey`): the characters kept and the whole length. */
|
|
73
|
+
bound?: {
|
|
74
|
+
kept: number;
|
|
75
|
+
whole: number;
|
|
76
|
+
};
|
|
72
77
|
};
|
|
73
78
|
/** What the harness's recovery note of the same turn calls it (the kernel's one rule, process/recovery.ts): `retryable` is a
|
|
74
79
|
* safe tool's call that a crash cut off, which the note tells the model is safe to repeat. */
|
|
@@ -105,9 +110,11 @@ export declare const markParked: (ctx: DriveContext, callId: string) => Promise<
|
|
|
105
110
|
/** What a nested call came to. A call the host parked is `parked`, whatever else holds: it never ran. Else the store's record first, the rollout's completion second: both complete and agreeing, or
|
|
106
111
|
* one of them, is that outcome; both complete and disagreeing, or a call that started and has no end in either, is
|
|
107
112
|
* interrupted (its effect is unknown), and a failure the store marks interrupted is interrupted. They agree when the
|
|
108
|
-
* rollout holds what the bridge handed Codex for the stored text: the
|
|
109
|
-
* (`
|
|
110
|
-
*
|
|
113
|
+
* rollout holds what the bridge handed Codex for the stored text: the stored text itself; or, where the bridge recorded
|
|
114
|
+
* its cut (`store.bound`), a text that starts with the stored text's kept characters, the stored text as long as the
|
|
115
|
+
* record says, compared on those lengths and never on the cut's note, whose words are free to change; or the stored
|
|
116
|
+
* text cut at the host's bound, as a session written before the record (a release before it) holds it. Any other cut
|
|
117
|
+
* with no record is no proof the two are one call's. */
|
|
111
118
|
export declare function settle(fact: NestedFact): Settled;
|
|
112
119
|
/** The most a recovered script's output holds (a cut-off `exec`'s, or the `wait` on its cell): one result at the host's bound, as
|
|
113
120
|
* the script was handed it, and the words that tell each call's outcome around it. It stands in for the script's own output,
|
|
@@ -116,6 +123,10 @@ export declare function settle(fact: NestedFact): Settled;
|
|
|
116
123
|
* call's outcome is still told. Only when the lines alone pass it is the output itself cut, with its note: the calls past
|
|
117
124
|
* the cut are not in it, and the recovery note does not say they are (`Recovered.shown`). */
|
|
118
125
|
export declare const EXEC_RECOVERY_MAX_CHARS: number;
|
|
126
|
+
/** The most a recovered output holds for a model of `budget` (the session's window): EXEC_RECOVERY_MAX_CHARS with none, or
|
|
127
|
+
* one too large to bind (as it always was); else the per-model bound itself (the kernel's resultMaxChars), words and all,
|
|
128
|
+
* since the output is one tool result the model reads. */
|
|
129
|
+
export declare function recoveryMaxChars(budget?: ResultBudget): number;
|
|
119
130
|
/** A recovered output, and the calls whose outcome it tells (`shown`): each whose line is whole in it and quotes some of its
|
|
120
131
|
* result or error (all of it, or its start with the line saying where it was cut). */
|
|
121
132
|
export interface Recovered {
|
|
@@ -143,9 +154,9 @@ export declare function outcomeShown(fact: NestedFact): boolean;
|
|
|
143
154
|
* whose script could not be told (given to the last cut-off exec only), listed apart under their own heading. */
|
|
144
155
|
/** What a dangling `wait` on a yielded exec's cell is told when calls of that script that waited for a person's approval
|
|
145
156
|
* were answered on this resume (code-mode.ts recoverItems): each call's outcome, in order. */
|
|
146
|
-
export declare function waitResumedText(cell: string, resumed: readonly NestedFact[]): string;
|
|
157
|
+
export declare function waitResumedText(cell: string, resumed: readonly NestedFact[], budget?: ResultBudget): string;
|
|
147
158
|
/** waitResumedText, and the calls whose outcome it tells. */
|
|
148
|
-
export declare function waitResumed(cell: string, resumed: readonly NestedFact[]): Recovered;
|
|
159
|
+
export declare function waitResumed(cell: string, resumed: readonly NestedFact[], budget?: ResultBudget): Recovered;
|
|
149
160
|
/** What the host's row of an `exec` a recovery answered shows: the model is told its script was cut short, but on the record
|
|
150
161
|
* those words belong to an exec that failed (recoveredFailed). One that ended ok shows its calls' outcomes alone. */
|
|
151
162
|
export declare function recoveredRowText(output: string, failed: boolean): string;
|
|
@@ -155,9 +166,9 @@ export declare function recoveredRowText(output: string, failed: boolean): strin
|
|
|
155
166
|
* no call of its own. A script whose last call ran and answered (one that parked and was allowed, too) was stopped and
|
|
156
167
|
* resumed, not failed. `own`: its calls, in order. */
|
|
157
168
|
export declare function recoveredFailed(own: readonly NestedFact[]): boolean;
|
|
158
|
-
export declare function execRecoveryOutput(facts: readonly NestedFact[], loose?: readonly NestedFact[]): string;
|
|
169
|
+
export declare function execRecoveryOutput(facts: readonly NestedFact[], loose?: readonly NestedFact[], budget?: ResultBudget): string;
|
|
159
170
|
/** execRecoveryOutput, and the calls whose outcome it tells: only those the recovery note may say are above. */
|
|
160
|
-
export declare function execRecovery(facts: readonly NestedFact[], loose?: readonly NestedFact[]): Recovered;
|
|
171
|
+
export declare function execRecovery(facts: readonly NestedFact[], loose?: readonly NestedFact[], budget?: ResultBudget): Recovered;
|
|
161
172
|
/** The text of a tool's recorded output (a string, or `{ text }` with images). */
|
|
162
173
|
export declare function outputTextOf(output: unknown): string;
|
|
163
174
|
/** A call by its tool and arguments, whatever the order of the arguments' keys: what a `never` tool's call is matched on. */
|
package/dist/scripts.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// The proxy offers no `exec` while a cell runs and no parallel calls, so one script is live at a time. A model that writes an
|
|
12
12
|
// `exec` anyway makes two live, and then a nested call cannot be told from the other's.
|
|
13
13
|
import { HOST_RESULT_MAX_CHARS } from "@parcha/agentrun-kernel";
|
|
14
|
-
import { boundResult } from "./host/process.js";
|
|
14
|
+
import { boundResult, resultMaxChars } from "./host/process.js";
|
|
15
15
|
import { parseLine } from "./rollout.js";
|
|
16
16
|
/** The id Codex gives a host tool called from a code-mode script. */
|
|
17
17
|
export const NESTED_CALL = /^exec-[0-9a-f-]{36}$/;
|
|
@@ -130,9 +130,11 @@ export const markParked = (ctx, callId) => ctx.effect(parkedKey(callId), { name:
|
|
|
130
130
|
/** What a nested call came to. A call the host parked is `parked`, whatever else holds: it never ran. Else the store's record first, the rollout's completion second: both complete and agreeing, or
|
|
131
131
|
* one of them, is that outcome; both complete and disagreeing, or a call that started and has no end in either, is
|
|
132
132
|
* interrupted (its effect is unknown), and a failure the store marks interrupted is interrupted. They agree when the
|
|
133
|
-
* rollout holds what the bridge handed Codex for the stored text: the
|
|
134
|
-
* (`
|
|
135
|
-
*
|
|
133
|
+
* rollout holds what the bridge handed Codex for the stored text: the stored text itself; or, where the bridge recorded
|
|
134
|
+
* its cut (`store.bound`), a text that starts with the stored text's kept characters, the stored text as long as the
|
|
135
|
+
* record says, compared on those lengths and never on the cut's note, whose words are free to change; or the stored
|
|
136
|
+
* text cut at the host's bound, as a session written before the record (a release before it) holds it. Any other cut
|
|
137
|
+
* with no record is no proof the two are one call's. */
|
|
136
138
|
export function settle(fact) {
|
|
137
139
|
if (fact.parked)
|
|
138
140
|
return { kind: "parked" };
|
|
@@ -140,9 +142,12 @@ export function settle(fact) {
|
|
|
140
142
|
const stored = store?.status === "completed" ? { kind: "completed", text: store.text ?? "" } : store?.status === "failed" && !store.interrupted ? { kind: "failed", text: store.text ?? "" } : undefined;
|
|
141
143
|
const rolled = rollout ? { kind: rollout.ok ? "completed" : "failed", text: rollout.text } : undefined;
|
|
142
144
|
if (stored && rolled)
|
|
143
|
-
return stored.kind === rolled.kind && (rolled.text === stored.text || rolled.text === boundResult(stored.text).text || (store?.sent !== undefined && rolled.text === store.sent)) ? stored : { kind: "interrupted" };
|
|
145
|
+
return stored.kind === rolled.kind && (rolled.text === stored.text || cutOf(rolled.text, stored.text, store?.bound) || rolled.text === boundResult(stored.text).text || (store?.sent !== undefined && rolled.text === store.sent)) ? stored : { kind: "interrupted" };
|
|
144
146
|
return stored ?? rolled ?? { kind: "interrupted" };
|
|
145
147
|
}
|
|
148
|
+
/** Whether `text` is the cut of `whole` the bridge recorded (`bound`): `whole` as long as the record says, and `text`
|
|
149
|
+
* starting with its kept characters. */
|
|
150
|
+
const cutOf = (text, whole, bound) => bound !== undefined && whole.length === bound.whole && bound.kept <= whole.length && text.startsWith(whole.slice(0, bound.kept));
|
|
146
151
|
/** The most a recovered script's output holds (a cut-off `exec`'s, or the `wait` on its cell): one result at the host's bound, as
|
|
147
152
|
* the script was handed it, and the words that tell each call's outcome around it. It stands in for the script's own output,
|
|
148
153
|
* which the model reads as one tool result. Past it, every result it quotes is cut to the same share, each keeping its start
|
|
@@ -150,6 +155,13 @@ export function settle(fact) {
|
|
|
150
155
|
* call's outcome is still told. Only when the lines alone pass it is the output itself cut, with its note: the calls past
|
|
151
156
|
* the cut are not in it, and the recovery note does not say they are (`Recovered.shown`). */
|
|
152
157
|
export const EXEC_RECOVERY_MAX_CHARS = HOST_RESULT_MAX_CHARS + 2_000;
|
|
158
|
+
/** The most a recovered output holds for a model of `budget` (the session's window): EXEC_RECOVERY_MAX_CHARS with none, or
|
|
159
|
+
* one too large to bind (as it always was); else the per-model bound itself (the kernel's resultMaxChars), words and all,
|
|
160
|
+
* since the output is one tool result the model reads. */
|
|
161
|
+
export function recoveryMaxChars(budget) {
|
|
162
|
+
const max = resultMaxChars(budget);
|
|
163
|
+
return max < HOST_RESULT_MAX_CHARS ? max : EXEC_RECOVERY_MAX_CHARS;
|
|
164
|
+
}
|
|
153
165
|
/** A last line longer than this is not kept when a result is cut: it is the result's own text, not a pointer to the rest. */
|
|
154
166
|
const LAST_LINE_MAX = 1_000;
|
|
155
167
|
/** `text` within `cap` characters: whole when it fits; else its start, a line saying where it was cut (as `boundResult`'s
|
|
@@ -171,10 +183,11 @@ function cut(text, cap) {
|
|
|
171
183
|
/** A told call's line, the text it quotes held to `cap`. */
|
|
172
184
|
const lineOf = (told, cap) => (told.text === undefined ? `${told.head}${told.tail}` : `${told.head}${JSON.stringify(cut(told.text, cap).text)}${told.tail}`);
|
|
173
185
|
/** A recovered output built by `build` from its calls' lines (`told`, in the order `build` writes them) at a cap on each
|
|
174
|
-
* quoted text: whole when it fits in
|
|
186
|
+
* quoted text: whole when it fits in recoveryMaxChars(budget); else at the largest cap that fits (the same for every quoted
|
|
175
187
|
* text); else, the lines alone passing the bound, the output cut to the bound with its note, and the calls past the cut
|
|
176
188
|
* not in it. */
|
|
177
|
-
function fitted(told, build) {
|
|
189
|
+
function fitted(told, build, budget) {
|
|
190
|
+
const max = recoveryMaxChars(budget);
|
|
178
191
|
const at = (cap, output, limit = output.length) => {
|
|
179
192
|
const shown = [];
|
|
180
193
|
let from = 0;
|
|
@@ -190,18 +203,23 @@ function fitted(told, build) {
|
|
|
190
203
|
return { output, shown };
|
|
191
204
|
};
|
|
192
205
|
const whole = build(Number.POSITIVE_INFINITY);
|
|
193
|
-
if (whole.length <=
|
|
206
|
+
if (whole.length <= max)
|
|
194
207
|
return at(Number.POSITIVE_INFINITY, whole);
|
|
195
208
|
const least = build(0);
|
|
196
|
-
if (least.length >
|
|
197
|
-
const { text, kept } = cut(least,
|
|
209
|
+
if (least.length > max) {
|
|
210
|
+
const { text, kept } = cut(least, max);
|
|
211
|
+
// A window too small for even the lines, where cut keeps a short last line past its cap: held to the kernel's bound
|
|
212
|
+
// (which refuses it in words), and then it tells no call's outcome. With no window binding this is never taken, and
|
|
213
|
+
// the output and the calls it tells are exactly as they always were.
|
|
214
|
+
if (max < EXEC_RECOVERY_MAX_CHARS && text.length > max)
|
|
215
|
+
return { output: boundResult(text, budget).text, shown: [] };
|
|
198
216
|
return at(0, text, kept);
|
|
199
217
|
}
|
|
200
218
|
let lo = 0;
|
|
201
219
|
let hi = whole.length;
|
|
202
220
|
while (lo < hi) {
|
|
203
221
|
const mid = Math.ceil((lo + hi) / 2);
|
|
204
|
-
if (build(mid).length <=
|
|
222
|
+
if (build(mid).length <= max)
|
|
205
223
|
lo = mid;
|
|
206
224
|
else
|
|
207
225
|
hi = mid - 1;
|
|
@@ -219,11 +237,12 @@ export function recoveryFacts(execs, ties, since, factOf) {
|
|
|
219
237
|
return out;
|
|
220
238
|
}
|
|
221
239
|
/** What a call of a recovered script came to, as its line tells it. A result or an error it quotes is the one the script was
|
|
222
|
-
* handed live: held to the
|
|
223
|
-
|
|
240
|
+
* handed live: held to the bound for the session's model as the bridge holds it (`boundResult` at `budget`); the
|
|
241
|
+
* session's record keeps it whole. */
|
|
242
|
+
const describeCall = (fact, label, budget) => {
|
|
224
243
|
const settled = settle(fact);
|
|
225
244
|
const shows = outcomeShown(fact);
|
|
226
|
-
const told = (head, text, tail) => ({ head, text: boundResult(text).text, tail, callId: fact.callId, shows });
|
|
245
|
+
const told = (head, text, tail) => ({ head, text: boundResult(text, budget).text, tail, callId: fact.callId, shows });
|
|
227
246
|
if (settled.kind === "parked")
|
|
228
247
|
return { head: `${label} was waiting for a person's approval and did not run; it was not run again.`, tail: "" };
|
|
229
248
|
const again = fact.resumed;
|
|
@@ -255,13 +274,13 @@ export function outcomeShown(fact) {
|
|
|
255
274
|
* whose script could not be told (given to the last cut-off exec only), listed apart under their own heading. */
|
|
256
275
|
/** What a dangling `wait` on a yielded exec's cell is told when calls of that script that waited for a person's approval
|
|
257
276
|
* were answered on this resume (code-mode.ts recoverItems): each call's outcome, in order. */
|
|
258
|
-
export function waitResumedText(cell, resumed) {
|
|
259
|
-
return waitResumed(cell, resumed).output;
|
|
277
|
+
export function waitResumedText(cell, resumed, budget) {
|
|
278
|
+
return waitResumed(cell, resumed, budget).output;
|
|
260
279
|
}
|
|
261
280
|
/** waitResumedText, and the calls whose outcome it tells. */
|
|
262
|
-
export function waitResumed(cell, resumed) {
|
|
263
|
-
const told = resumed.map((fact, i) => describeCall(fact, `${i + 1}. ${fact.tool}
|
|
264
|
-
return fitted(told, (cap) => `${waitCutOpener(cell)}${told.map((t) => lineOf(t, cap)).join("\n")}\nNothing else of the script was run again. Check the actual state before relying on it
|
|
281
|
+
export function waitResumed(cell, resumed, budget) {
|
|
282
|
+
const told = resumed.map((fact, i) => describeCall(fact, `${i + 1}. ${fact.tool}`, budget));
|
|
283
|
+
return fitted(told, (cap) => `${waitCutOpener(cell)}${told.map((t) => lineOf(t, cap)).join("\n")}\nNothing else of the script was run again. Check the actual state before relying on it.`, budget);
|
|
265
284
|
}
|
|
266
285
|
/** The words a resumed `wait`'s output opens with (waitResumed): the model is told its cell's script went with the session. */
|
|
267
286
|
const waitCutOpener = (cell) => `The session stopped while waiting on cell ${cell}; that cell's script was cut off. Its calls that waited for a person's approval were answered since, each once:\n`;
|
|
@@ -289,15 +308,15 @@ export function recoveredFailed(own) {
|
|
|
289
308
|
return !last.resumed.ran || last.resumed.isError;
|
|
290
309
|
return settle(last).kind !== "completed";
|
|
291
310
|
}
|
|
292
|
-
export function execRecoveryOutput(facts, loose = []) {
|
|
293
|
-
return execRecovery(facts, loose).output;
|
|
311
|
+
export function execRecoveryOutput(facts, loose = [], budget) {
|
|
312
|
+
return execRecovery(facts, loose, budget).output;
|
|
294
313
|
}
|
|
295
314
|
/** execRecoveryOutput, and the calls whose outcome it tells: only those the recovery note may say are above. */
|
|
296
|
-
export function execRecovery(facts, loose = []) {
|
|
315
|
+
export function execRecovery(facts, loose = [], budget) {
|
|
297
316
|
if (facts.length === 0 && loose.length === 0)
|
|
298
317
|
return { output: `The exec was cut short before any tool call of it was recorded; it ran none. Run it again if it is still needed.`, shown: [] };
|
|
299
|
-
const own = facts.map((fact, i) => describeCall(fact, `${i + 1}. ${fact.tool}
|
|
300
|
-
const others = loose.map((fact, i) => describeCall(fact, `${i + 1}. ${fact.tool}
|
|
318
|
+
const own = facts.map((fact, i) => describeCall(fact, `${i + 1}. ${fact.tool}`, budget));
|
|
319
|
+
const others = loose.map((fact, i) => describeCall(fact, `${i + 1}. ${fact.tool}`, budget));
|
|
301
320
|
return fitted([...own, ...others], (cap) => {
|
|
302
321
|
const apart = others.length
|
|
303
322
|
? `\n${others.length} ${others.length === 1 ? "call" : "calls"} ran whose script could not be told (an answer of the model's could not be read to its end):\n${others.map((t) => lineOf(t, cap)).join("\n")}`
|
|
@@ -305,7 +324,7 @@ export function execRecovery(facts, loose = []) {
|
|
|
305
324
|
if (own.length === 0)
|
|
306
325
|
return `The exec was cut short, and no call of its own was recorded; the calls below ran, though which script made them could not be told, so do not run it again to find out.${apart}`;
|
|
307
326
|
return `${EXEC_CUT_OPENER}${own.map((t) => lineOf(t, cap)).join("\n")}${apart}`;
|
|
308
|
-
});
|
|
327
|
+
}, budget);
|
|
309
328
|
}
|
|
310
329
|
/** The text of a tool's recorded output (a string, or `{ text }` with images). */
|
|
311
330
|
export function outputTextOf(output) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-harness-codex",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.63",
|
|
4
4
|
"description": "Codex as an AgentRun harness: a tool-less Codex app-server behind a loopback model proxy, durable in AgentRun's own store, with the host's tools as its only tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"test": "node --test --test-concurrency=8 'test/*.test.mjs'"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@parcha/agentrun-kernel": "0.1.0-beta.
|
|
47
|
+
"@parcha/agentrun-kernel": "0.1.0-beta.63"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@openai/codex": "0.164.0"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@openai/codex": "0.164.0",
|
|
59
|
-
"@parcha/agentrun-dsl": "0.1.0-beta.
|
|
59
|
+
"@parcha/agentrun-dsl": "0.1.0-beta.63"
|
|
60
60
|
},
|
|
61
61
|
"repository": {
|
|
62
62
|
"type": "git",
|