@tangle-network/agent-runtime 0.209.0 → 0.210.0
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/README.md +4 -0
- package/dist/{activation-tFdeirCa.d.ts → activation-4oMAHaQz.d.ts} +2 -2
- package/dist/{activation-Cjhm5Tds.js → activation-Bwyehqhg.js} +2 -2
- package/dist/{activation-Cjhm5Tds.js.map → activation-Bwyehqhg.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/{coordination-driver-C-hPz1zy.js → coordination-driver-Bp9a4LdC.js} +2 -2
- package/dist/{coordination-driver-C-hPz1zy.js.map → coordination-driver-Bp9a4LdC.js.map} +1 -1
- package/dist/{delegate-CB4CkJdV.js → delegate-Dmm9ITBZ.js} +2 -2
- package/dist/{delegate-CB4CkJdV.js.map → delegate-Dmm9ITBZ.js.map} +1 -1
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +2 -2
- package/dist/{graph-Ud2-Ytos.js → graph-D1QQu6lY.js} +3 -3
- package/dist/{graph-Ud2-Ytos.js.map → graph-D1QQu6lY.js.map} +1 -1
- package/dist/{improvement-cycle-B7ia6rTj.js → improvement-cycle-BlvbrKLq.js} +3 -3
- package/dist/{improvement-cycle-B7ia6rTj.js.map → improvement-cycle-BlvbrKLq.js.map} +1 -1
- package/dist/{index-0p5DiJoy.d.ts → index-lXtwqnQA.d.ts} +6 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -7
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +3 -3
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +8 -8
- package/dist/{loop-runner-bin-q-xGzEK9.d.ts → loop-runner-bin-CpJtH4zl.d.ts} +3 -3
- package/dist/{loop-runner-bin-B30d3Yla.js → loop-runner-bin-QKH_nf8M.js} +3 -3
- package/dist/{loop-runner-bin-B30d3Yla.js.map → loop-runner-bin-QKH_nf8M.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.js +4 -4
- package/dist/{provision-supervisor-C-nLaaQ_.js → provision-supervisor-Dq81wDhU.js} +3 -3
- package/dist/{provision-supervisor-C-nLaaQ_.js.map → provision-supervisor-Dq81wDhU.js.map} +1 -1
- package/dist/{redact-va_1mmv8.js → redact-CE6Hfkrp.js} +6093 -6084
- package/dist/redact-CE6Hfkrp.js.map +1 -0
- package/dist/{runtime-D0_b9wFH.js → runtime-BgOCbw6N.js} +8 -8
- package/dist/{runtime-D0_b9wFH.js.map → runtime-BgOCbw6N.js.map} +1 -1
- package/dist/{server-pq1x3C2i.js → server-xYvBM-Te.js} +3 -3
- package/dist/{server-pq1x3C2i.js.map → server-xYvBM-Te.js.map} +1 -1
- package/dist/{stream-agent-turn-BaKYHbHg.d.ts → stream-agent-turn-BXZMQQ0K.d.ts} +367 -361
- package/dist/{structural-rollout-BaYBLUeI.js → structural-rollout-CcO70n6X.js} +2 -2
- package/dist/{structural-rollout-BaYBLUeI.js.map → structural-rollout-CcO70n6X.js.map} +1 -1
- package/dist/{supervise-CMWpmY_1.js → supervise-DNh1_cHO.js} +7 -3
- package/dist/supervise-DNh1_cHO.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +12 -12
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/package.json +1 -1
- package/dist/redact-va_1mmv8.js.map +0 -1
- package/dist/supervise-CMWpmY_1.js.map +0 -1
|
@@ -1219,6 +1219,10 @@ interface Agent<Task, Out> {
|
|
|
1219
1219
|
* path; returning `true` means the message was accepted for the current manager session.
|
|
1220
1220
|
*/
|
|
1221
1221
|
deliver?(msg: unknown): void | boolean;
|
|
1222
|
+
/** Optional live tool evidence exposed by executors that can observe it. */
|
|
1223
|
+
traceSource?(): TraceSource | undefined;
|
|
1224
|
+
/** Optional live execution progress exposed by executors that can observe it. */
|
|
1225
|
+
progress?(): ExecutorProgress | undefined;
|
|
1222
1226
|
}
|
|
1223
1227
|
/**
|
|
1224
1228
|
* The leaf runtime — ONE open interface, not a closed union. `execute` returns a
|
|
@@ -3587,177 +3591,6 @@ interface InPlaceHarnessResult {
|
|
|
3587
3591
|
harness: WorktreeHarnessResult['harness'];
|
|
3588
3592
|
}
|
|
3589
3593
|
//#endregion
|
|
3590
|
-
//#region src/runtime/harness-usage.d.ts
|
|
3591
|
-
/**
|
|
3592
|
-
* One harness's own token-usage report for one turn, in the runtime's field names.
|
|
3593
|
-
*
|
|
3594
|
-
* `input` is the provider's TOTAL prompt count and `output` is its TOTAL completion count.
|
|
3595
|
-
* The other three counters CLASSIFY a part of one of those totals; none of them adds to it.
|
|
3596
|
-
* `cachedInput` and `cacheWriteInput` classify `input`, which is the convention
|
|
3597
|
-
* `promptCacheTokenClasses` (`util.ts`) folds: `freshInput = input - cacheRead - cacheWrite`.
|
|
3598
|
-
* `reasoningOutput` classifies `output`.
|
|
3599
|
-
*
|
|
3600
|
-
* A counter the harness does not report stays absent, because a zero would claim the harness
|
|
3601
|
-
* measured none.
|
|
3602
|
-
*/
|
|
3603
|
-
interface HarnessUsage {
|
|
3604
|
-
/** The harness family whose adapter produced this report. */
|
|
3605
|
-
readonly harness: HarnessType;
|
|
3606
|
-
/** Total prompt tokens the provider charged for the turn, the cached ones included. */
|
|
3607
|
-
readonly input: number;
|
|
3608
|
-
/** Total completion tokens the provider charged for the turn, the reasoning ones included. */
|
|
3609
|
-
readonly output: number;
|
|
3610
|
-
/** The part of `input` the provider served from its prompt cache. */
|
|
3611
|
-
readonly cachedInput?: number;
|
|
3612
|
-
/** The part of `input` the provider wrote into its prompt cache. */
|
|
3613
|
-
readonly cacheWriteInput?: number;
|
|
3614
|
-
/** The part of `output` the model spent on reasoning. Never added to `output`. */
|
|
3615
|
-
readonly reasoningOutput?: number;
|
|
3616
|
-
}
|
|
3617
|
-
/**
|
|
3618
|
-
* Decode a sandbox event with one harness's adapter, or `undefined` when the event carries no
|
|
3619
|
-
* harness-native usage.
|
|
3620
|
-
*
|
|
3621
|
-
* A NAMED harness reads with that harness's adapter only, and a named harness with no adapter
|
|
3622
|
-
* reports nothing. It never falls through to another harness's adapter: a different harness's
|
|
3623
|
-
* `turn.completed` decoded as codex would either drop the counters codex does not name or fail on
|
|
3624
|
-
* a field codex requires, and both answers would be about the wrong harness. The composite over
|
|
3625
|
-
* every registered adapter runs only when the caller cannot name the harness.
|
|
3626
|
-
*
|
|
3627
|
-
* Throws `ValidationError` when an adapter recognizes the event as its harness's usage carrier and
|
|
3628
|
-
* cannot read the numbers.
|
|
3629
|
-
*/
|
|
3630
|
-
declare function decodeHarnessUsage(event: SandboxEvent, harness?: HarnessType): HarnessUsage | undefined;
|
|
3631
|
-
//#endregion
|
|
3632
|
-
//#region src/runtime/codex-rollout-store.d.ts
|
|
3633
|
-
/** Who wrote one rollout, exactly as its own `session_meta` states it. Nothing here is inferred. */
|
|
3634
|
-
interface CodexRolloutIdentity {
|
|
3635
|
-
/** The rollout's own thread id (`session_meta.payload.id`). */
|
|
3636
|
-
readonly sessionId: string;
|
|
3637
|
-
/** The thread this one was spawned or forked from, when it was. */
|
|
3638
|
-
readonly parentThreadId?: string;
|
|
3639
|
-
/** The thread whose rows are prepended into this file, when this file is a fork. */
|
|
3640
|
-
readonly forkedFromId?: string;
|
|
3641
|
-
/** True when `thread_source` reads `subagent`: a harness-native child, invisible to the journal. */
|
|
3642
|
-
readonly nativeChild: boolean;
|
|
3643
|
-
/** The child's own path in the harness's agent tree (`/root/c1_b_grid`), when it has one. */
|
|
3644
|
-
readonly agentPath?: string;
|
|
3645
|
-
/** The harness's own nickname for the child ("Turing"), when it has one. */
|
|
3646
|
-
readonly agentNickname?: string;
|
|
3647
|
-
/** Spawn depth the harness recorded. `1` is a direct child of the seat. */
|
|
3648
|
-
readonly depth?: number;
|
|
3649
|
-
/** The working directory the session ran in, used to attribute a store to a workspace. */
|
|
3650
|
-
readonly cwd?: string;
|
|
3651
|
-
/** The codex build that wrote it. */
|
|
3652
|
-
readonly cliVersion?: string;
|
|
3653
|
-
/** When the session itself started, from its own `session_meta` timestamp. */
|
|
3654
|
-
readonly startedAtMs?: number;
|
|
3655
|
-
}
|
|
3656
|
-
/** How this reader isolated the session's own rows from the parent rows prepended to its file. */
|
|
3657
|
-
type CodexForkBoundary =
|
|
3658
|
-
/** Not a fork: every row in the file belongs to this session. */
|
|
3659
|
-
{
|
|
3660
|
-
readonly kind: 'whole-file';
|
|
3661
|
-
} |
|
|
3662
|
-
/** A fork whose own first turn was isolated, and by which rule. */
|
|
3663
|
-
{
|
|
3664
|
-
readonly kind: 'resolved';
|
|
3665
|
-
readonly rule: 'history-start-ordinal' | 'turn-is-session' | 'turn-uuid-v7' | 'turn-start-time';
|
|
3666
|
-
/** The `turn_id` of the session's own first turn. */
|
|
3667
|
-
readonly turnId?: string;
|
|
3668
|
-
/** Rows credited to the parent and excluded from `own`. */
|
|
3669
|
-
readonly inheritedTurns: number;
|
|
3670
|
-
} |
|
|
3671
|
-
/** A fork this reader could not isolate. `own` is absent; nothing may be charged. */
|
|
3672
|
-
{
|
|
3673
|
-
readonly kind: 'unresolved';
|
|
3674
|
-
readonly reason: string;
|
|
3675
|
-
};
|
|
3676
|
-
/** One turn of one session, with the counters it added to the session's cumulative total. */
|
|
3677
|
-
interface CodexRolloutTurn {
|
|
3678
|
-
readonly turnId?: string;
|
|
3679
|
-
readonly startedAtMs?: number;
|
|
3680
|
-
readonly usage: HarnessUsage;
|
|
3681
|
-
}
|
|
3682
|
-
/** One rollout file, read. */
|
|
3683
|
-
interface CodexRolloutSession {
|
|
3684
|
-
readonly identity: CodexRolloutIdentity;
|
|
3685
|
-
readonly boundary: CodexForkBoundary;
|
|
3686
|
-
/**
|
|
3687
|
-
* The session's OWN spend — the cumulative delta from its fork boundary to its last report.
|
|
3688
|
-
* ABSENT when the boundary is unresolved: an unattributable number must not be charged.
|
|
3689
|
-
*/
|
|
3690
|
-
readonly own?: HarnessUsage;
|
|
3691
|
-
/** The session's own turns, newest last. Empty when the file reported no usage. */
|
|
3692
|
-
readonly turns: readonly CodexRolloutTurn[];
|
|
3693
|
-
/**
|
|
3694
|
-
* The file's final cumulative `total_token_usage`, kept ONLY as the diagnostic that shows how
|
|
3695
|
-
* far a naive file total is from the truth. Never charge this.
|
|
3696
|
-
*/
|
|
3697
|
-
readonly fileCumulativeInput: number;
|
|
3698
|
-
readonly fileCumulativeOutput: number;
|
|
3699
|
-
}
|
|
3700
|
-
/** What one incremental read of a store observed. */
|
|
3701
|
-
interface CodexStoreDelta {
|
|
3702
|
-
/** Spend by sessions that are NOT native children — the seat's own turns. */
|
|
3703
|
-
readonly seat: HarnessUsage;
|
|
3704
|
-
/** Spend by `thread_source: subagent` sessions — the harness-native children. */
|
|
3705
|
-
readonly native: HarnessUsage;
|
|
3706
|
-
/** Sessions whose fork boundary could not be isolated, so their spend is absent, not zero. */
|
|
3707
|
-
readonly unresolved: ReadonlyArray<{
|
|
3708
|
-
readonly sessionId: string;
|
|
3709
|
-
readonly reason: string;
|
|
3710
|
-
}>;
|
|
3711
|
-
/**
|
|
3712
|
-
* Every session this read touched, for evidence. Each one states its WHOLE own spend and turn
|
|
3713
|
-
* list, which is not the same number as `seat` / `native`: those two carry only what this read
|
|
3714
|
-
* newly observed.
|
|
3715
|
-
*/
|
|
3716
|
-
readonly sessions: readonly CodexRolloutSession[];
|
|
3717
|
-
}
|
|
3718
|
-
/** A store reader that credits each turn once: it tails only the bytes appended since the last read. */
|
|
3719
|
-
interface CodexRolloutStoreReader {
|
|
3720
|
-
/**
|
|
3721
|
-
* Read everything appended since the previous call and attribute it.
|
|
3722
|
-
*
|
|
3723
|
-
* The FIRST call establishes the baseline. Call it before the first turn so pre-existing rows are
|
|
3724
|
-
* consumed and credited to nothing; every later call returns exactly that turn's spend.
|
|
3725
|
-
*/
|
|
3726
|
-
read(): Promise<CodexStoreDelta>;
|
|
3727
|
-
}
|
|
3728
|
-
/** Where a harness keeps its own session store, and which workspace may be credited from it. */
|
|
3729
|
-
interface CodexRolloutStoreRef {
|
|
3730
|
-
/**
|
|
3731
|
-
* Absolute path to the harness home the CLI writes into — `CODEX_HOME`, or `$HOME/.codex`.
|
|
3732
|
-
* This MUST be the run's own isolated store. Pointing it at an ambient host store credits one
|
|
3733
|
-
* run with another run's files, which is the exact defect this reader exists to end.
|
|
3734
|
-
*/
|
|
3735
|
-
readonly root: string;
|
|
3736
|
-
/**
|
|
3737
|
-
* Credit only sessions whose recorded `cwd` is this path or below it. Absent credits every
|
|
3738
|
-
* session under `root`, which is correct only for a store no other run writes to.
|
|
3739
|
-
*/
|
|
3740
|
-
readonly workspaceRoot?: string;
|
|
3741
|
-
}
|
|
3742
|
-
/**
|
|
3743
|
-
* Read one rollout's rows into a session record.
|
|
3744
|
-
*
|
|
3745
|
-
* `rows` is the file's JSON values in file order. Pass the whole file to read a completed session;
|
|
3746
|
-
* the store reader passes appended slices and carries the identity forward itself.
|
|
3747
|
-
*/
|
|
3748
|
-
declare function readCodexRolloutSession(rows: Iterable<unknown>): CodexRolloutSession | undefined;
|
|
3749
|
-
/**
|
|
3750
|
-
* Open an incremental reader over a codex store.
|
|
3751
|
-
*
|
|
3752
|
-
* Nothing is read until `read()` is called, and every read is bounded by the bytes appended since
|
|
3753
|
-
* the previous one, so a 695MB rollout is scanned once rather than once per turn.
|
|
3754
|
-
*/
|
|
3755
|
-
declare function createCodexRolloutStoreReader(ref: CodexRolloutStoreRef): CodexRolloutStoreReader;
|
|
3756
|
-
/** Sum two usage reports on every counter both of them state. */
|
|
3757
|
-
declare function addHarnessUsage(left: HarnessUsage, right: HarnessUsage): HarnessUsage;
|
|
3758
|
-
/** True when a report states any spend at all. */
|
|
3759
|
-
declare function harnessUsageIsEmpty(usage: HarnessUsage): boolean;
|
|
3760
|
-
//#endregion
|
|
3761
3594
|
//#region src/runtime/provider-placement.d.ts
|
|
3762
3595
|
/** Caller-declared execution placement. Matching never changes the authored profile.
|
|
3763
3596
|
* @experimental */
|
|
@@ -3915,56 +3748,6 @@ interface ProviderExecutorOptions {
|
|
|
3915
3748
|
* @experimental */
|
|
3916
3749
|
declare function providerAsExecutor(provider: AgentEnvironmentProvider, options?: ProviderExecutorOptions): ExecutorFactory<unknown>;
|
|
3917
3750
|
//#endregion
|
|
3918
|
-
//#region src/runtime/key-provider.d.ts
|
|
3919
|
-
/** Resolve named secrets. The ONE seam every secret store adapts to. */
|
|
3920
|
-
interface KeyProvider {
|
|
3921
|
-
/** The value for `name`, or `undefined` when this provider does not hold it. */
|
|
3922
|
-
get(name: string): Promise<string | undefined>;
|
|
3923
|
-
}
|
|
3924
|
-
/** The env-backed provider: reads the (dotenvx-loaded) process env. Empty /
|
|
3925
|
-
* whitespace-only values count as absent — fail loud, not with a blank key. */
|
|
3926
|
-
declare function envKeyProvider(env?: Record<string, string | undefined>): KeyProvider;
|
|
3927
|
-
/** The `AgentProfileMcpServer.metadata` key the declarative secret-env map
|
|
3928
|
-
* rides under: `{ ENV_VAR_NAME: 'PROVIDER_KEY_NAME' }`. Names only — values
|
|
3929
|
-
* are resolved at materialize time and never stored. */
|
|
3930
|
-
declare const mcpSecretEnvMetadataKey = "secretEnv";
|
|
3931
|
-
/** Read (and validate) a server entry's declared secret-env map, if any.
|
|
3932
|
-
* Malformed metadata throws — a half-declared secret must never half-boot. */
|
|
3933
|
-
declare function secretEnvOfMcpServer(server: AgentProfileMcpServer): Record<string, string> | undefined;
|
|
3934
|
-
/**
|
|
3935
|
-
* Resolve a declared secret-env map into the real env entries for a server
|
|
3936
|
-
* spawn. Fail-closed: no provider or a missing key throws, naming the KEY
|
|
3937
|
-
* NAME only (the value never appears in any message). `label` names the
|
|
3938
|
-
* server for the error (e.g. `profile.mcp['exa']`).
|
|
3939
|
-
*/
|
|
3940
|
-
declare function resolveSecretEnv(secretEnv: Record<string, string>, keys: KeyProvider | undefined, label: string): Promise<Record<string, string>>;
|
|
3941
|
-
/** The spawn-ready strings for one stdio MCP server: profile config values
|
|
3942
|
-
* resolved, secrets separated so the client can redact them. */
|
|
3943
|
-
interface ResolvedMcpServerLaunch {
|
|
3944
|
-
args?: string[];
|
|
3945
|
-
/** Public env, safe to appear in diagnostics. */
|
|
3946
|
-
env?: Record<string, string>;
|
|
3947
|
-
/** Resolved secret env. Reaches only the child process; redacted everywhere else. */
|
|
3948
|
-
protectedEnv?: Record<string, string>;
|
|
3949
|
-
}
|
|
3950
|
-
/**
|
|
3951
|
-
* Resolve a profile MCP server's `args`/`env` config values (interface ≥0.40
|
|
3952
|
-
* `AgentProfileConfigValue`) plus the legacy `metadata.secretEnv` channel into
|
|
3953
|
-
* the plain strings a spawn needs.
|
|
3954
|
-
*
|
|
3955
|
-
* Rules, all fail-closed:
|
|
3956
|
-
* - `args` must be public values. A secret-ref in argv is refused: argv is
|
|
3957
|
-
* readable by every host process (/proc/PID/cmdline) and outside the
|
|
3958
|
-
* protected-value redaction channel, so a secret there cannot be contained.
|
|
3959
|
-
* - `env` secret-refs resolve through the KeyProvider (missing provider or key
|
|
3960
|
-
* throws, naming the KEY NAME only) and land in `protectedEnv`.
|
|
3961
|
-
* - An env var declared secret on BOTH channels (env secret-ref and
|
|
3962
|
-
* metadata.secretEnv) is ambiguous configuration and throws.
|
|
3963
|
-
* - A public `env` entry shadowed by a legacy metadata secret keeps the
|
|
3964
|
-
* pre-0.40 spawn precedence: the secret value wins in the child env.
|
|
3965
|
-
*/
|
|
3966
|
-
declare function resolveMcpServerLaunch(server: AgentProfileMcpServer, keys: KeyProvider | undefined, label: string): Promise<ResolvedMcpServerLaunch>;
|
|
3967
|
-
//#endregion
|
|
3968
3751
|
//#region src/runtime/sandbox-events.d.ts
|
|
3969
3752
|
/** The provider/model the platform reports it actually bound to a turn, when it reports one.
|
|
3970
3753
|
* `source` is the platform's own account of where that choice came from — `environment` means
|
|
@@ -4208,39 +3991,367 @@ interface SandboxLeafOut {
|
|
|
4208
3991
|
outcome?: AgentRunOutcome;
|
|
4209
3992
|
}
|
|
4210
3993
|
//#endregion
|
|
4211
|
-
//#region src/runtime/
|
|
4212
|
-
/**
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
*
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
readonly
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
/**
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
3994
|
+
//#region src/runtime/harness-usage.d.ts
|
|
3995
|
+
/**
|
|
3996
|
+
* One harness's own token-usage report for one turn, in the runtime's field names.
|
|
3997
|
+
*
|
|
3998
|
+
* `input` is the provider's TOTAL prompt count and `output` is its TOTAL completion count.
|
|
3999
|
+
* The other three counters CLASSIFY a part of one of those totals; none of them adds to it.
|
|
4000
|
+
* `cachedInput` and `cacheWriteInput` classify `input`, which is the convention
|
|
4001
|
+
* `promptCacheTokenClasses` (`util.ts`) folds: `freshInput = input - cacheRead - cacheWrite`.
|
|
4002
|
+
* `reasoningOutput` classifies `output`.
|
|
4003
|
+
*
|
|
4004
|
+
* A counter the harness does not report stays absent, because a zero would claim the harness
|
|
4005
|
+
* measured none.
|
|
4006
|
+
*/
|
|
4007
|
+
interface HarnessUsage {
|
|
4008
|
+
/** The harness family whose adapter produced this report. */
|
|
4009
|
+
readonly harness: HarnessType;
|
|
4010
|
+
/** Total prompt tokens the provider charged for the turn, the cached ones included. */
|
|
4011
|
+
readonly input: number;
|
|
4012
|
+
/** Total completion tokens the provider charged for the turn, the reasoning ones included. */
|
|
4013
|
+
readonly output: number;
|
|
4014
|
+
/** The part of `input` the provider served from its prompt cache. */
|
|
4015
|
+
readonly cachedInput?: number;
|
|
4016
|
+
/** The part of `input` the provider wrote into its prompt cache. */
|
|
4017
|
+
readonly cacheWriteInput?: number;
|
|
4018
|
+
/** The part of `output` the model spent on reasoning. Never added to `output`. */
|
|
4019
|
+
readonly reasoningOutput?: number;
|
|
4020
|
+
}
|
|
4021
|
+
/**
|
|
4022
|
+
* Decode a sandbox event with one harness's adapter, or `undefined` when the event carries no
|
|
4023
|
+
* harness-native usage.
|
|
4024
|
+
*
|
|
4025
|
+
* A NAMED harness reads with that harness's adapter only, and a named harness with no adapter
|
|
4026
|
+
* reports nothing. It never falls through to another harness's adapter: a different harness's
|
|
4027
|
+
* `turn.completed` decoded as codex would either drop the counters codex does not name or fail on
|
|
4028
|
+
* a field codex requires, and both answers would be about the wrong harness. The composite over
|
|
4029
|
+
* every registered adapter runs only when the caller cannot name the harness.
|
|
4030
|
+
*
|
|
4031
|
+
* Throws `ValidationError` when an adapter recognizes the event as its harness's usage carrier and
|
|
4032
|
+
* cannot read the numbers.
|
|
4033
|
+
*/
|
|
4034
|
+
declare function decodeHarnessUsage(event: SandboxEvent, harness?: HarnessType): HarnessUsage | undefined;
|
|
4035
|
+
//#endregion
|
|
4036
|
+
//#region src/runtime/codex-rollout-store.d.ts
|
|
4037
|
+
/** Who wrote one rollout, exactly as its own `session_meta` states it. Nothing here is inferred. */
|
|
4038
|
+
interface CodexRolloutIdentity {
|
|
4039
|
+
/** The rollout's own thread id (`session_meta.payload.id`). */
|
|
4040
|
+
readonly sessionId: string;
|
|
4041
|
+
/** The thread this one was spawned or forked from, when it was. */
|
|
4042
|
+
readonly parentThreadId?: string;
|
|
4043
|
+
/** The thread whose rows are prepended into this file, when this file is a fork. */
|
|
4044
|
+
readonly forkedFromId?: string;
|
|
4045
|
+
/** True when `thread_source` reads `subagent`: a harness-native child, invisible to the journal. */
|
|
4046
|
+
readonly nativeChild: boolean;
|
|
4047
|
+
/** The child's own path in the harness's agent tree (`/root/c1_b_grid`), when it has one. */
|
|
4048
|
+
readonly agentPath?: string;
|
|
4049
|
+
/** The harness's own nickname for the child ("Turing"), when it has one. */
|
|
4050
|
+
readonly agentNickname?: string;
|
|
4051
|
+
/** Spawn depth the harness recorded. `1` is a direct child of the seat. */
|
|
4052
|
+
readonly depth?: number;
|
|
4053
|
+
/** The working directory the session ran in, used to attribute a store to a workspace. */
|
|
4054
|
+
readonly cwd?: string;
|
|
4055
|
+
/** The codex build that wrote it. */
|
|
4056
|
+
readonly cliVersion?: string;
|
|
4057
|
+
/** When the session itself started, from its own `session_meta` timestamp. */
|
|
4058
|
+
readonly startedAtMs?: number;
|
|
4059
|
+
}
|
|
4060
|
+
/** How this reader isolated the session's own rows from the parent rows prepended to its file. */
|
|
4061
|
+
type CodexForkBoundary =
|
|
4062
|
+
/** Not a fork: every row in the file belongs to this session. */
|
|
4063
|
+
{
|
|
4064
|
+
readonly kind: 'whole-file';
|
|
4065
|
+
} |
|
|
4066
|
+
/** A fork whose own first turn was isolated, and by which rule. */
|
|
4067
|
+
{
|
|
4068
|
+
readonly kind: 'resolved';
|
|
4069
|
+
readonly rule: 'history-start-ordinal' | 'turn-is-session' | 'turn-uuid-v7' | 'turn-start-time';
|
|
4070
|
+
/** The `turn_id` of the session's own first turn. */
|
|
4071
|
+
readonly turnId?: string;
|
|
4072
|
+
/** Rows credited to the parent and excluded from `own`. */
|
|
4073
|
+
readonly inheritedTurns: number;
|
|
4074
|
+
} |
|
|
4075
|
+
/** A fork this reader could not isolate. `own` is absent; nothing may be charged. */
|
|
4076
|
+
{
|
|
4077
|
+
readonly kind: 'unresolved';
|
|
4078
|
+
readonly reason: string;
|
|
4079
|
+
};
|
|
4080
|
+
/** One turn of one session, with the counters it added to the session's cumulative total. */
|
|
4081
|
+
interface CodexRolloutTurn {
|
|
4082
|
+
readonly turnId?: string;
|
|
4083
|
+
readonly startedAtMs?: number;
|
|
4084
|
+
readonly usage: HarnessUsage;
|
|
4085
|
+
}
|
|
4086
|
+
/** One rollout file, read. */
|
|
4087
|
+
interface CodexRolloutSession {
|
|
4088
|
+
readonly identity: CodexRolloutIdentity;
|
|
4089
|
+
readonly boundary: CodexForkBoundary;
|
|
4090
|
+
/**
|
|
4091
|
+
* The session's OWN spend — the cumulative delta from its fork boundary to its last report.
|
|
4092
|
+
* ABSENT when the boundary is unresolved: an unattributable number must not be charged.
|
|
4093
|
+
*/
|
|
4094
|
+
readonly own?: HarnessUsage;
|
|
4095
|
+
/** The session's own turns, newest last. Empty when the file reported no usage. */
|
|
4096
|
+
readonly turns: readonly CodexRolloutTurn[];
|
|
4097
|
+
/**
|
|
4098
|
+
* The file's final cumulative `total_token_usage`, kept ONLY as the diagnostic that shows how
|
|
4099
|
+
* far a naive file total is from the truth. Never charge this.
|
|
4100
|
+
*/
|
|
4101
|
+
readonly fileCumulativeInput: number;
|
|
4102
|
+
readonly fileCumulativeOutput: number;
|
|
4103
|
+
}
|
|
4104
|
+
/** What one incremental read of a store observed. */
|
|
4105
|
+
interface CodexStoreDelta {
|
|
4106
|
+
/** Spend by sessions that are NOT native children — the seat's own turns. */
|
|
4107
|
+
readonly seat: HarnessUsage;
|
|
4108
|
+
/** Spend by `thread_source: subagent` sessions — the harness-native children. */
|
|
4109
|
+
readonly native: HarnessUsage;
|
|
4110
|
+
/** Sessions whose fork boundary could not be isolated, so their spend is absent, not zero. */
|
|
4111
|
+
readonly unresolved: ReadonlyArray<{
|
|
4112
|
+
readonly sessionId: string;
|
|
4113
|
+
readonly reason: string;
|
|
4114
|
+
}>;
|
|
4115
|
+
/**
|
|
4116
|
+
* Every session this read touched, for evidence. Each one states its WHOLE own spend and turn
|
|
4117
|
+
* list, which is not the same number as `seat` / `native`: those two carry only what this read
|
|
4118
|
+
* newly observed.
|
|
4119
|
+
*/
|
|
4120
|
+
readonly sessions: readonly CodexRolloutSession[];
|
|
4121
|
+
}
|
|
4122
|
+
/** A store reader that credits each turn once: it tails only the bytes appended since the last read. */
|
|
4123
|
+
interface CodexRolloutStoreReader {
|
|
4124
|
+
/**
|
|
4125
|
+
* Read everything appended since the previous call and attribute it.
|
|
4126
|
+
*
|
|
4127
|
+
* The FIRST call establishes the baseline. Call it before the first turn so pre-existing rows are
|
|
4128
|
+
* consumed and credited to nothing; every later call returns exactly that turn's spend.
|
|
4129
|
+
*/
|
|
4130
|
+
read(): Promise<CodexStoreDelta>;
|
|
4131
|
+
}
|
|
4132
|
+
/** Where a harness keeps its own session store, and which workspace may be credited from it. */
|
|
4133
|
+
interface CodexRolloutStoreRef {
|
|
4134
|
+
/**
|
|
4135
|
+
* Absolute path to the harness home the CLI writes into — `CODEX_HOME`, or `$HOME/.codex`.
|
|
4136
|
+
* This MUST be the run's own isolated store. Pointing it at an ambient host store credits one
|
|
4137
|
+
* run with another run's files, which is the exact defect this reader exists to end.
|
|
4138
|
+
*/
|
|
4139
|
+
readonly root: string;
|
|
4140
|
+
/**
|
|
4141
|
+
* Credit only sessions whose recorded `cwd` is this path or below it. Absent credits every
|
|
4142
|
+
* session under `root`, which is correct only for a store no other run writes to.
|
|
4143
|
+
*/
|
|
4144
|
+
readonly workspaceRoot?: string;
|
|
4145
|
+
}
|
|
4146
|
+
/**
|
|
4147
|
+
* Read one rollout's rows into a session record.
|
|
4148
|
+
*
|
|
4149
|
+
* `rows` is the file's JSON values in file order. Pass the whole file to read a completed session;
|
|
4150
|
+
* the store reader passes appended slices and carries the identity forward itself.
|
|
4151
|
+
*/
|
|
4152
|
+
declare function readCodexRolloutSession(rows: Iterable<unknown>): CodexRolloutSession | undefined;
|
|
4153
|
+
/**
|
|
4154
|
+
* Open an incremental reader over a codex store.
|
|
4155
|
+
*
|
|
4156
|
+
* Nothing is read until `read()` is called, and every read is bounded by the bytes appended since
|
|
4157
|
+
* the previous one, so a 695MB rollout is scanned once rather than once per turn.
|
|
4158
|
+
*/
|
|
4159
|
+
declare function createCodexRolloutStoreReader(ref: CodexRolloutStoreRef): CodexRolloutStoreReader;
|
|
4160
|
+
/** Sum two usage reports on every counter both of them state. */
|
|
4161
|
+
declare function addHarnessUsage(left: HarnessUsage, right: HarnessUsage): HarnessUsage;
|
|
4162
|
+
/** True when a report states any spend at all. */
|
|
4163
|
+
declare function harnessUsageIsEmpty(usage: HarnessUsage): boolean;
|
|
4164
|
+
//#endregion
|
|
4165
|
+
//#region src/runtime/key-provider.d.ts
|
|
4166
|
+
/** Resolve named secrets. The ONE seam every secret store adapts to. */
|
|
4167
|
+
interface KeyProvider {
|
|
4168
|
+
/** The value for `name`, or `undefined` when this provider does not hold it. */
|
|
4169
|
+
get(name: string): Promise<string | undefined>;
|
|
4170
|
+
}
|
|
4171
|
+
/** The env-backed provider: reads the (dotenvx-loaded) process env. Empty /
|
|
4172
|
+
* whitespace-only values count as absent — fail loud, not with a blank key. */
|
|
4173
|
+
declare function envKeyProvider(env?: Record<string, string | undefined>): KeyProvider;
|
|
4174
|
+
/** The `AgentProfileMcpServer.metadata` key the declarative secret-env map
|
|
4175
|
+
* rides under: `{ ENV_VAR_NAME: 'PROVIDER_KEY_NAME' }`. Names only — values
|
|
4176
|
+
* are resolved at materialize time and never stored. */
|
|
4177
|
+
declare const mcpSecretEnvMetadataKey = "secretEnv";
|
|
4178
|
+
/** Read (and validate) a server entry's declared secret-env map, if any.
|
|
4179
|
+
* Malformed metadata throws — a half-declared secret must never half-boot. */
|
|
4180
|
+
declare function secretEnvOfMcpServer(server: AgentProfileMcpServer): Record<string, string> | undefined;
|
|
4181
|
+
/**
|
|
4182
|
+
* Resolve a declared secret-env map into the real env entries for a server
|
|
4183
|
+
* spawn. Fail-closed: no provider or a missing key throws, naming the KEY
|
|
4184
|
+
* NAME only (the value never appears in any message). `label` names the
|
|
4185
|
+
* server for the error (e.g. `profile.mcp['exa']`).
|
|
4186
|
+
*/
|
|
4187
|
+
declare function resolveSecretEnv(secretEnv: Record<string, string>, keys: KeyProvider | undefined, label: string): Promise<Record<string, string>>;
|
|
4188
|
+
/** The spawn-ready strings for one stdio MCP server: profile config values
|
|
4189
|
+
* resolved, secrets separated so the client can redact them. */
|
|
4190
|
+
interface ResolvedMcpServerLaunch {
|
|
4191
|
+
args?: string[];
|
|
4192
|
+
/** Public env, safe to appear in diagnostics. */
|
|
4193
|
+
env?: Record<string, string>;
|
|
4194
|
+
/** Resolved secret env. Reaches only the child process; redacted everywhere else. */
|
|
4195
|
+
protectedEnv?: Record<string, string>;
|
|
4196
|
+
}
|
|
4197
|
+
/**
|
|
4198
|
+
* Resolve a profile MCP server's `args`/`env` config values (interface ≥0.40
|
|
4199
|
+
* `AgentProfileConfigValue`) plus the legacy `metadata.secretEnv` channel into
|
|
4200
|
+
* the plain strings a spawn needs.
|
|
4201
|
+
*
|
|
4202
|
+
* Rules, all fail-closed:
|
|
4203
|
+
* - `args` must be public values. A secret-ref in argv is refused: argv is
|
|
4204
|
+
* readable by every host process (/proc/PID/cmdline) and outside the
|
|
4205
|
+
* protected-value redaction channel, so a secret there cannot be contained.
|
|
4206
|
+
* - `env` secret-refs resolve through the KeyProvider (missing provider or key
|
|
4207
|
+
* throws, naming the KEY NAME only) and land in `protectedEnv`.
|
|
4208
|
+
* - An env var declared secret on BOTH channels (env secret-ref and
|
|
4209
|
+
* metadata.secretEnv) is ambiguous configuration and throws.
|
|
4210
|
+
* - A public `env` entry shadowed by a legacy metadata secret keeps the
|
|
4211
|
+
* pre-0.40 spawn precedence: the secret value wins in the child env.
|
|
4212
|
+
*/
|
|
4213
|
+
declare function resolveMcpServerLaunch(server: AgentProfileMcpServer, keys: KeyProvider | undefined, label: string): Promise<ResolvedMcpServerLaunch>;
|
|
4214
|
+
//#endregion
|
|
4215
|
+
//#region src/runtime/supervise/bridge-config.d.ts
|
|
4216
|
+
/**
|
|
4217
|
+
* cli-bridge seam. A local OpenAI-compatible bridge that fronts harness CLIs
|
|
4218
|
+
* (claude-code / opencode / kimi / pi) behind one HTTP surface. The spawned
|
|
4219
|
+
* `AgentProfile` is the sole harness/provider/model and behavioral authority and
|
|
4220
|
+
* is forwarded verbatim per request; this seam carries transport data only.
|
|
4221
|
+
*
|
|
4222
|
+
* The executor opens a resumable cli-bridge session. `sessionId` identifies the
|
|
4223
|
+
* harness conversation across turns; each turn also receives its own durable run id.
|
|
4224
|
+
* A dropped HTTP reader reattaches to that exact run and explicit cancel is the only
|
|
4225
|
+
* operation allowed to stop it. Omit `sessionId` and the executor mints one per spawn.
|
|
4226
|
+
*
|
|
4227
|
+
* ── HOW TO CONTROL WHAT THE HARNESS LOADS (there is no argv field, by design) ──
|
|
4228
|
+
*
|
|
4229
|
+
* A worker often needs the harness started in a KNOWN state — no ambient extensions, skills,
|
|
4230
|
+
* context files, or prompt templates — because ambient state is how a paired experiment silently
|
|
4231
|
+
* loses its pairing: an installed extension that persists memory across runs carries arm A's state
|
|
4232
|
+
* into arm B, and nothing reports it.
|
|
4233
|
+
*
|
|
4234
|
+
* That is what the spawned `AgentProfile` is FOR. `agent_profile`
|
|
4235
|
+
* rides every request verbatim, and cli-bridge maps it onto each harness's own native controls:
|
|
4236
|
+
*
|
|
4237
|
+
* - Materializing any profile at all already starts the harness isolated from ambient
|
|
4238
|
+
* workspace state — for pi that is `--no-context-files --no-skills --no-prompt-templates`,
|
|
4239
|
+
* applied to every request that carries an `agent_profile`.
|
|
4240
|
+
* - `AgentProfile.extensions.<harness>` is the named, per-harness control channel. An explicit
|
|
4241
|
+
* `extensions: { pi: { load: [] } }` disables ambient extension discovery outright
|
|
4242
|
+
* (pi's `--no-extensions`); listing package names loads exactly those and nothing else.
|
|
4243
|
+
* - `permissions` / `tools` / `mcp` map onto the harness's native tool and server controls.
|
|
4244
|
+
*
|
|
4245
|
+
* A caller therefore does NOT need to hand-roll an `Executor` to isolate a harness run, and the
|
|
4246
|
+
* profile expressing it stays portable: the same declaration means the same thing on a different
|
|
4247
|
+
* harness, whereas an argv string means nothing anywhere else.
|
|
4248
|
+
*
|
|
4249
|
+
* WHY NOT A GENERAL ARGV PASSTHROUGH. `bridgeUrl` addresses a process-spawning server. Forwarding
|
|
4250
|
+
* an arbitrary argv array to it would let any caller holding a bearer token choose the flags of a
|
|
4251
|
+
* process on the bridge host — which for real harness CLIs includes flags that load code from a
|
|
4252
|
+
* path, read a file into the prompt, redirect the working directory, or turn off the isolation the
|
|
4253
|
+
* bridge applies. cli-bridge deliberately confines workers (a filesystem jail and deny-by-default
|
|
4254
|
+
* network egress), and every one of those confinements is expressed as spawn configuration, so an
|
|
4255
|
+
* argv channel is a channel for unwinding them. It would also break this executor's own contract:
|
|
4256
|
+
* the durable-run replay protocol, session pinning, and streaming mode are all argv the bridge
|
|
4257
|
+
* owns, and a caller-supplied duplicate silently wins or corrupts the parse. The structured profile
|
|
4258
|
+
* channel is validated, per-harness, portable, and refuses controls it does not understand — keep
|
|
4259
|
+
* new harness capability there.
|
|
4260
|
+
*/
|
|
4261
|
+
interface BridgeSeam {
|
|
4262
|
+
bridgeUrl: string;
|
|
4263
|
+
bridgeBearer: string;
|
|
4264
|
+
/**
|
|
4265
|
+
* Optional request-scoped model credential.
|
|
4266
|
+
*
|
|
4267
|
+
* The key name is portable configuration. The provider is a live service and is intentionally
|
|
4268
|
+
* not serialised. Runtime resolves both values immediately before every bridge POST and sends
|
|
4269
|
+
* them only to a loopback bridge through private request headers.
|
|
4270
|
+
*/
|
|
4271
|
+
modelCredential?: BridgeModelCredential;
|
|
4272
|
+
/** Optional working directory forwarded to cli-bridge and persisted with the session. */
|
|
4273
|
+
cwd?: string;
|
|
4274
|
+
/**
|
|
4275
|
+
* The harness's OWN on-disk session store, read as a spend receipt.
|
|
4276
|
+
*
|
|
4277
|
+
* cli-bridge forwards no token usage for a codex worker, so a turn whose provider counters exist
|
|
4278
|
+
* only in codex's rollout meters `{0, 0}` with `tokensKnown: false`. Measured on one live seat
|
|
4279
|
+
* (discovery#80): 9 of 9 `metered` events read zero while 27,320,482 codex tokens sat in the same
|
|
4280
|
+
* run directory, 1,453,948 of them belonging to harness-native children the journal never saw.
|
|
4281
|
+
*
|
|
4282
|
+
* Naming the store here turns those rows into evidence. The executor tails it once per turn and
|
|
4283
|
+
* credits the DELTA, so each turn is charged once, and it reports the counters with
|
|
4284
|
+
* `provenance: 'harness-store'` so a reader can tell a disk receipt from a stream receipt.
|
|
4285
|
+
*
|
|
4286
|
+
* The path must be the run's OWN isolated store. An ambient host store credits this run with
|
|
4287
|
+
* another run's files, and `workspaceRoot` is the structural guard against it.
|
|
4288
|
+
*/
|
|
4289
|
+
harnessStore?: BridgeHarnessStore;
|
|
4290
|
+
/** Caller-owned deadline for each bridge turn. Runtime enforces it locally and sends the
|
|
4291
|
+
* same value in `execution.timeoutMs` so the bridge-owned process follows the same policy. */
|
|
4292
|
+
timeoutMs?: number;
|
|
4293
|
+
/** Stable, caller-owned cli-bridge session id for harness-side resume. Defaults
|
|
4294
|
+
* to a freshly minted per-spawn id so each worker is its own resumable session. */
|
|
4295
|
+
sessionId?: string;
|
|
4296
|
+
/** Transport reconnects allowed after the first POST. Default 3; set 0 to disable. */
|
|
4297
|
+
maxReconnects?: number;
|
|
4298
|
+
/** Newest-last activity window `progress()` reports. Default 12. */
|
|
4299
|
+
activityWindow?: number;
|
|
4300
|
+
}
|
|
4301
|
+
/**
|
|
4302
|
+
* A harness's own session store on the bridge host, named so the runtime may read it.
|
|
4303
|
+
*
|
|
4304
|
+
* Only `codex` has a reader today. Any other harness is REFUSED rather than read with codex's
|
|
4305
|
+
* decoder: a different harness's file decoded as a codex rollout would either drop counters it does
|
|
4306
|
+
* not name or credit a number that is about the wrong wire shape.
|
|
4307
|
+
*/
|
|
4308
|
+
interface BridgeHarnessStore extends CodexRolloutStoreRef {
|
|
4309
|
+
/** The harness family that wrote the store. */
|
|
4310
|
+
readonly harness: HarnessType;
|
|
4311
|
+
}
|
|
4312
|
+
/** A live, request-scoped model credential reference for a local cli-bridge. */
|
|
4313
|
+
interface BridgeModelCredential {
|
|
4314
|
+
/** Provider key name for the scoped model token. */
|
|
4315
|
+
key: string;
|
|
4316
|
+
/** Provider key name for the exact scoped HTTPS model gateway URL. */
|
|
4317
|
+
baseUrlKey: string;
|
|
4318
|
+
/** Live credential service. Runtime retains this reference through reusable captures. */
|
|
4319
|
+
provider: KeyProvider;
|
|
4320
|
+
}
|
|
4321
|
+
//#endregion
|
|
4322
|
+
//#region src/runtime/supervise/inbox.d.ts
|
|
4323
|
+
/** A message from the run's AUTHORITY — the parent driver. These two kinds carry instruction. */
|
|
4324
|
+
interface AuthorityInboxMessage {
|
|
4325
|
+
readonly kind: 'steer' | 'answer';
|
|
4326
|
+
readonly text: string;
|
|
4327
|
+
/** Forceful messages abort the in-flight turn; queued ones wait for the boundary flush. */
|
|
4328
|
+
readonly interrupt: boolean;
|
|
4329
|
+
/** Present for an `answer` — the question id it resolves. */
|
|
4330
|
+
readonly questionId?: string;
|
|
4331
|
+
}
|
|
4332
|
+
/** A message from a SIBLING worker. Information, never instruction — the parent stays the only
|
|
4333
|
+
* authority over this worker's task. */
|
|
4334
|
+
interface PeerInboxMessage {
|
|
4335
|
+
readonly kind: 'mail';
|
|
4336
|
+
readonly text: string;
|
|
4337
|
+
/** Always false. Peer mail is queued by construction; see this file's header. */
|
|
4338
|
+
readonly interrupt: false;
|
|
4339
|
+
readonly envelope: PeerMailEnvelope;
|
|
4340
|
+
}
|
|
4341
|
+
type InboxMessage = AuthorityInboxMessage | PeerInboxMessage;
|
|
4342
|
+
interface Inbox {
|
|
4343
|
+
/** The `Executor.deliver` implementation. Returns false when the raw message is malformed and
|
|
4344
|
+
* therefore was not queued; callers must not acknowledge a message this inbox discarded. */
|
|
4345
|
+
deliver(msg: unknown): boolean;
|
|
4346
|
+
/** Remove and return all pending messages (the flush). */
|
|
4347
|
+
drain(): InboxMessage[];
|
|
4348
|
+
pending(): number;
|
|
4349
|
+
/** Pending messages from the run's AUTHORITY only. This is what the pre-settle fence counts:
|
|
4350
|
+
* a worker may not finish while a steer or answer it never read is queued, but peer mail must
|
|
4351
|
+
* never be able to hold a finished worker open. */
|
|
4352
|
+
pendingAuthority(): number;
|
|
4353
|
+
/** Open a fresh per-turn interrupt signal; a later forceful `deliver` aborts it. The loop links
|
|
4354
|
+
* this into the signal it passes to its inference call, then re-plans when it fires. */
|
|
4244
4355
|
freshInterrupt(): AbortSignal;
|
|
4245
4356
|
/** Render drained messages as ONE operator turn to fold into the worker's conversation. */
|
|
4246
4357
|
fold(messages: ReadonlyArray<InboxMessage>): string;
|
|
@@ -4462,111 +4573,6 @@ interface CliWorktreeBridgeSeam {
|
|
|
4462
4573
|
/** Transport reconnects allowed after the first POST. Default 3; set 0 to disable. */
|
|
4463
4574
|
maxReconnects?: number;
|
|
4464
4575
|
}
|
|
4465
|
-
/**
|
|
4466
|
-
* cli-bridge seam. A local OpenAI-compatible bridge that fronts harness CLIs
|
|
4467
|
-
* (claude-code / opencode / kimi / pi) behind one HTTP surface. The spawned
|
|
4468
|
-
* `AgentProfile` is the sole harness/provider/model and behavioral authority and
|
|
4469
|
-
* is forwarded verbatim per request; this seam carries transport data only.
|
|
4470
|
-
*
|
|
4471
|
-
* The executor opens a resumable cli-bridge session. `sessionId` identifies the
|
|
4472
|
-
* harness conversation across turns; each turn also receives its own durable run id.
|
|
4473
|
-
* A dropped HTTP reader reattaches to that exact run and explicit cancel is the only
|
|
4474
|
-
* operation allowed to stop it. Omit `sessionId` and the executor mints one per spawn.
|
|
4475
|
-
*
|
|
4476
|
-
* ── HOW TO CONTROL WHAT THE HARNESS LOADS (there is no argv field, by design) ──
|
|
4477
|
-
*
|
|
4478
|
-
* A worker often needs the harness started in a KNOWN state — no ambient extensions, skills,
|
|
4479
|
-
* context files, or prompt templates — because ambient state is how a paired experiment silently
|
|
4480
|
-
* loses its pairing: an installed extension that persists memory across runs carries arm A's state
|
|
4481
|
-
* into arm B, and nothing reports it.
|
|
4482
|
-
*
|
|
4483
|
-
* That is what the spawned `AgentProfile` is FOR. `agent_profile`
|
|
4484
|
-
* rides every request verbatim, and cli-bridge maps it onto each harness's own native controls:
|
|
4485
|
-
*
|
|
4486
|
-
* - Materializing any profile at all already starts the harness isolated from ambient
|
|
4487
|
-
* workspace state — for pi that is `--no-context-files --no-skills --no-prompt-templates`,
|
|
4488
|
-
* applied to every request that carries an `agent_profile`.
|
|
4489
|
-
* - `AgentProfile.extensions.<harness>` is the named, per-harness control channel. An explicit
|
|
4490
|
-
* `extensions: { pi: { load: [] } }` disables ambient extension discovery outright
|
|
4491
|
-
* (pi's `--no-extensions`); listing package names loads exactly those and nothing else.
|
|
4492
|
-
* - `permissions` / `tools` / `mcp` map onto the harness's native tool and server controls.
|
|
4493
|
-
*
|
|
4494
|
-
* A caller therefore does NOT need to hand-roll an `Executor` to isolate a harness run, and the
|
|
4495
|
-
* profile expressing it stays portable: the same declaration means the same thing on a different
|
|
4496
|
-
* harness, whereas an argv string means nothing anywhere else.
|
|
4497
|
-
*
|
|
4498
|
-
* WHY NOT A GENERAL ARGV PASSTHROUGH. `bridgeUrl` addresses a process-spawning server. Forwarding
|
|
4499
|
-
* an arbitrary argv array to it would let any caller holding a bearer token choose the flags of a
|
|
4500
|
-
* process on the bridge host — which for real harness CLIs includes flags that load code from a
|
|
4501
|
-
* path, read a file into the prompt, redirect the working directory, or turn off the isolation the
|
|
4502
|
-
* bridge applies. cli-bridge deliberately confines workers (a filesystem jail and deny-by-default
|
|
4503
|
-
* network egress), and every one of those confinements is expressed as spawn configuration, so an
|
|
4504
|
-
* argv channel is a channel for unwinding them. It would also break this executor's own contract:
|
|
4505
|
-
* the durable-run replay protocol, session pinning, and streaming mode are all argv the bridge
|
|
4506
|
-
* owns, and a caller-supplied duplicate silently wins or corrupts the parse. The structured profile
|
|
4507
|
-
* channel is validated, per-harness, portable, and refuses controls it does not understand — keep
|
|
4508
|
-
* new harness capability there.
|
|
4509
|
-
*/
|
|
4510
|
-
interface BridgeSeam {
|
|
4511
|
-
bridgeUrl: string;
|
|
4512
|
-
bridgeBearer: string;
|
|
4513
|
-
/**
|
|
4514
|
-
* Optional request-scoped model credential.
|
|
4515
|
-
*
|
|
4516
|
-
* The key name is portable configuration. The provider is a live service and is intentionally
|
|
4517
|
-
* not serialised. Runtime resolves both values immediately before every bridge POST and sends
|
|
4518
|
-
* them only to a loopback bridge through private request headers.
|
|
4519
|
-
*/
|
|
4520
|
-
modelCredential?: BridgeModelCredential;
|
|
4521
|
-
/** Optional working directory forwarded to cli-bridge and persisted with the session. */
|
|
4522
|
-
cwd?: string;
|
|
4523
|
-
/**
|
|
4524
|
-
* The harness's OWN on-disk session store, read as a spend receipt.
|
|
4525
|
-
*
|
|
4526
|
-
* cli-bridge forwards no token usage for a codex worker, so a turn whose provider counters exist
|
|
4527
|
-
* only in codex's rollout meters `{0, 0}` with `tokensKnown: false`. Measured on one live seat
|
|
4528
|
-
* (discovery#80): 9 of 9 `metered` events read zero while 27,320,482 codex tokens sat in the same
|
|
4529
|
-
* run directory, 1,453,948 of them belonging to harness-native children the journal never saw.
|
|
4530
|
-
*
|
|
4531
|
-
* Naming the store here turns those rows into evidence. The executor tails it once per turn and
|
|
4532
|
-
* credits the DELTA, so each turn is charged once, and it reports the counters with
|
|
4533
|
-
* `provenance: 'harness-store'` so a reader can tell a disk receipt from a stream receipt.
|
|
4534
|
-
*
|
|
4535
|
-
* The path must be the run's OWN isolated store. An ambient host store credits this run with
|
|
4536
|
-
* another run's files, and `workspaceRoot` is the structural guard against it.
|
|
4537
|
-
*/
|
|
4538
|
-
harnessStore?: BridgeHarnessStore;
|
|
4539
|
-
/** Caller-owned deadline for each bridge turn. Runtime enforces it locally and sends the
|
|
4540
|
-
* same value in `execution.timeoutMs` so the bridge-owned process follows the same policy. */
|
|
4541
|
-
timeoutMs?: number;
|
|
4542
|
-
/** Stable, caller-owned cli-bridge session id for harness-side resume. Defaults
|
|
4543
|
-
* to a freshly minted per-spawn id so each worker is its own resumable session. */
|
|
4544
|
-
sessionId?: string;
|
|
4545
|
-
/** Transport reconnects allowed after the first POST. Default 3; set 0 to disable. */
|
|
4546
|
-
maxReconnects?: number;
|
|
4547
|
-
/** Newest-last activity window `progress()` reports. Default 12. */
|
|
4548
|
-
activityWindow?: number;
|
|
4549
|
-
}
|
|
4550
|
-
/**
|
|
4551
|
-
* A harness's own session store on the bridge host, named so the runtime may read it.
|
|
4552
|
-
*
|
|
4553
|
-
* Only `codex` has a reader today. Any other harness is REFUSED rather than read with codex's
|
|
4554
|
-
* decoder: a different harness's file decoded as a codex rollout would either drop counters it does
|
|
4555
|
-
* not name or credit a number that is about the wrong wire shape.
|
|
4556
|
-
*/
|
|
4557
|
-
interface BridgeHarnessStore extends CodexRolloutStoreRef {
|
|
4558
|
-
/** The harness family that wrote the store. */
|
|
4559
|
-
readonly harness: HarnessType;
|
|
4560
|
-
}
|
|
4561
|
-
/** A live, request-scoped model credential reference for a local cli-bridge. */
|
|
4562
|
-
interface BridgeModelCredential {
|
|
4563
|
-
/** Provider key name for the scoped model token. */
|
|
4564
|
-
key: string;
|
|
4565
|
-
/** Provider key name for the exact scoped HTTPS model gateway URL. */
|
|
4566
|
-
baseUrlKey: string;
|
|
4567
|
-
/** Live credential service. Runtime retains this reference through reusable captures. */
|
|
4568
|
-
provider: KeyProvider;
|
|
4569
|
-
}
|
|
4570
4576
|
/**
|
|
4571
4577
|
* Generic environment provider executor config. External packages implement
|
|
4572
4578
|
* `AgentEnvironmentProvider`; this built-in wrapper lets `createExecutor` consume them as backend
|
|
@@ -4806,5 +4812,5 @@ declare function streamAgentTurn(backend: AgentTurnBackend, input: AgentTurnInpu
|
|
|
4806
4812
|
*/
|
|
4807
4813
|
declare function collectAgentTurn(stream: AsyncIterable<RuntimeStreamEvent>): Promise<CollectedAgentTurn>;
|
|
4808
4814
|
//#endregion
|
|
4809
|
-
export {
|
|
4810
|
-
//# sourceMappingURL=stream-agent-turn-
|
|
4815
|
+
export { decodeHarnessUsage as $, RetainedRunCancellation as $a, SanitizedKnowledgeRequirement as $i, Redactor as $n, SteerableRootHandle as $r, WorktreeCommandResult as $t, createInbox as A, createActivityLog as Aa, LoopSpanNode as Ai, ToolLoopToolCall as An, ProfileMaterializationReceipt as Ar, CreateAgentEnvironmentInput$1 as At, secretEnvOfMcpServer as B, NativeContextContinuationHandle as Ba, createOtelExporter as Bi, PeerMailRefusal as Bn, RootProviderModelEvidence as Br, SandboxClientProviderOptions as Bt, SteerableSandboxArgs as C, sandboxSessionTraceSource as Ca, readTraceContextFromEnv as Ci, RouterTransportConfig as Cn, MaterializedExecutionIdentity as Cr, AgentProfileRef$1 as Ct, Inbox as D, ExecutorProgress as Da, EvalRunsExportConfig as Di, ToolLoopCompaction as Dn, NodeId as Dr, AgentTurnResult$2 as Dt, AuthorityInboxMessage as E, DEFAULT_STALL_AFTER_MS as Ea, EvalRunGeneration as Ei, ToolLoopChat as En, NodeExecutionIdentity as Er, AgentSessionStatus$1 as Et, ResolvedMcpServerLaunch as F, RetainedInteractiveEnvironmentInput as Fa, RuntimeEventOtelOptions as Fi, PeerMailEvent as Fn, ResultBlobStore as Fr, ProviderAsSandboxClientOptions as Ft, CodexRolloutStoreRef as G, RecoverRetainedRunResult as Ga, padTraceId as Gi, createPeerMailbox as Gn, SpawnEvent as Gr, resolveAgentEnvironmentProvider as Gt, CodexRolloutIdentity as H, ReconnectRetainedRunOptions as Ha, generateSpanId as Hi, PeerMailbox as Hn, Runtime as Hr, createAgentEnvironmentProviderRegistry as Ht, envKeyProvider as I, RetainedInteractiveRunHandle as Ia, buildLoopOtelSpans as Ii, PeerMailKind as In, ResumedKeyState as Ir, ProviderExecutorOptions as It, addHarnessUsage as J, RetainedInteractiveIntentAdmission as Ja, RuntimeStreamEventCollector as Ji, peerMailVerbNames as Jn, SpawnPrior as Jr, SandboxControlClient as Jt, CodexRolloutTurn as K, RetainedInteractiveAdmission as Ka, toOtelAttributes as Ki, isPeerMailEnvelope as Kn, SpawnJournal as Kr, sandboxClientAsProvider as Kt, mcpSecretEnvMetadataKey as L, RetainedInteractiveStartMaterial as La, buildLoopSpanNodes as Li, PeerMailLimits as Ln, ResumedWork as Lr, ProviderLeafOut as Lt, BridgeModelCredential as M, ReconnectRetainedInteractiveRunOptions as Ma, OtelExportConfig as Mi, DEFAULT_PEER_MAIL_LIMITS as Mn, ProviderModelExecutionEvidence as Mr, ExecResult as Mt, BridgeSeam as N, RecoverRetainedInteractiveRunOptions as Na, OtelExporter as Ni, PEER_MAIL_WIRE_KEY as Nn, ResourceLimit as Nr, ForkRequest as Nt, InboxMessage as O, ScopeProgressInput as Oa, EvalRunsExportResult as Oi, ToolLoopCompactionOptions as On, NodeSnapshot as Or, CheckpointRef as Ot, KeyProvider as P, RetainedInteractiveAdmissionHook as Pa, OtelSpan as Pi, PeerMailEnvelope as Pn, ResourceSpend as Pr, PlacementInfo as Pt, HarnessUsage as Q, RetainedRunCancelOptions as Qa, SanitizedKnowledgeReadinessReport as Qi, McpTransport as Qn, SpendGap as Qr, WorktreeCheckRunner as Qt, resolveMcpServerLaunch as R, StartRetainedInteractiveRunOptions as Ra, buildRuntimeEventOtelSpans as Ri, PeerMailOutcome as Rn, RootHandle as Rr, ProviderPromptOptions as Rt, SandboxSteeringOptions as S, decodeToolPart as Sa, mergeTraceEnv as Si, runLocalHarness as Sn, Handle as Sr, AgentEnvironmentSummary as St, createSteerableSandboxSession as T, ActivityNote as Ta, EvalRunEvent as Ti, ToolLoopCallContext as Tn, NoWinnerError as Tr, AgentSessionRef as Tt, CodexRolloutSession as U, RecoverRetainedRunIntentOptions as Ua, loopEventToOtelSpan as Ui, PeerMailboxOptions as Un, Scope as Ur, providerAsExecutor as Ut, CodexForkBoundary as V, NativeContextContinuationInput as Va, exportEvalRuns as Vi, PeerMailSendInput as Vn, RootSignal as Vr, WorkspaceRequest as Vt, CodexRolloutStoreReader as W, RecoverRetainedRunOptions as Wa, padSpanId as Wi, claimsAuthority as Wn, Settled as Wr, providerAsSandboxClient as Wt, harnessUsageIsEmpty as X, RetainedRunAdmission as Xa, RuntimeStreamEventSummary as Xi, JsonRpcResponse as Xn, Spend as Xr, ProviderPlacement as Xt, createCodexRolloutStoreReader as Y, RetainedInteractiveStartedAdmission as Ya, RuntimeStreamEventSink as Yi, JsonRpcMessage as Yn, SpawnRejection as Yr, createTangleSandboxExactProcessProvider as Yt, readCodexRolloutSession as Z, RetainedRunAdmissionHook as Za, RuntimeTelemetryOptions as Zi, McpToolDescriptor as Zn, SpendChannel as Zr, InPlaceHarnessResult as Zt, cliInPlaceExecutor as _, SessionMessageLike as _a, workerTraceEnv as _i, LocalHarnessResult as _n, createBudgetPool as _o, ExecutorProgressEvent as _r, AgentEnvironmentProvider$1 as _t, StreamAgentTurnOptions as a, PendingWait as aa, UnconfirmedTeardown as ai, GitRunner as an, RetainedRunIntentAdmission as ao, Budget as ar, assertSandboxServedModel as at, createExecutorRegistry as b, TraceSource as ba, TraceContext as bi, localHarnessExecutable as bn, ExecutorTeardownWarning as br, AgentEnvironmentQuery as bt, CliInPlaceSeam as c, WaitProbeRegistry as ca, WaitOpts as ci, captureWorktreeDiff as cn, RetainedRunStartMaterial as co, Executor as cr, extractLlmCallEvent as ct, CliWorktreeSeam as d, createWaitProbes as da, WorkerInteractiveUnavailableReason as di, CodexExecutionEvidence as dn, StartRetainedRunOptions as do, ExecutorCancellationRequest as dr, sandboxEventServedBackend as dt, createRuntimeEventCollector as ea, SupervisedResult as ei, WorktreeHarnessResult as en, RetainedRunDispatchedAdmission as eo, defaultRedactor as er, SandboxLeafOut as et, ExecutorConfig as f, isWaitOutcome as fa, WorkerTraceEvidence as fi, CodexExecutionPolicy as fn, BudgetPool as fo, ExecutorContext as fr, sandboxProgressEvents as ft, SandboxSeam as g, waitUntil as ga, readWorkerTraceContext as gi, LocalHarness as gn, ReservationTicket as go, ExecutorNodeContext as gr, AgentEnvironmentEvent$1 as gt, RouterToolsSeam as h, validateWaitSpec as ha, WorkerTraceSeamCarrier as hi, LOCAL_HARNESSES as hn, ReservationRejection as ho, ExecutorMaterialization as hr, AgentEnvironmentCapabilities$1 as ht, CollectedAgentTurn as i, sanitizeRuntimeStreamEvent as ia, TreeView as ii, DiffResult as in, RetainedRunHandle as io, AgentSpec as ir, SandboxUsageLedger as it, BridgeHarnessStore as j, readWorkerProgress as ja, OtelAttribute as ji, AUTHORITY_MARKERS as jn, ProviderModelAttemptEvidence as jr, ExecRequest as jt, PeerInboxMessage as k, WorkerProgress as ka, INTELLIGENCE_WIRE_VERSION as ki, ToolLoopMessageRecord as kn, NodeStatus as kr, CheckpointRequest as kt, CliSeam as l, WaitRejection as la, WidenGate as li, createWorktree as ln, RetainedRunTurnInput as lo, ExecutorAccounting as lr, mapSandboxEvent as lt, RouterSeam as m, timerAt as ma, WorkerTraceResolver as mi, DEFAULT_LOCAL_HARNESS as mn, BudgetReadout as mo, ExecutorFactory as mr, AgentEnvironment$1 as mt, AgentTurnInput$1 as n, sanitizeAgentRuntimeEvent as na, SupervisorOpts as ni, CreateWorktreeOptions as nn, RetainedRunEnvironmentAdmission as no, Agent as nr, SandboxServedBackend as nt, collectAgentTurn as o, WaitOutcome as oa, UnknownMaterializationReason as oi, RemoveWorktreeOptions as on, RetainedRunReplayPoint as oo, DefaultVerdict as or, createSandboxToolPartState as ot, ProviderSeam as p, pollFor as pa, WorkerTraceUnavailableReason as pi, CodexTokenUsage as pn, BudgetPoolRestore as po, ExecutorExecutionBinding as pr, sumSandboxUsage as pt, CodexStoreDelta as q, RetainedInteractiveEnvironmentAdmission as qa, RuntimeEventCollector as qi, peerMailTools as qn, SpawnOpts as qr, CreateTangleSandboxExactProcessProviderOptions as qt, AgentTurnUsage as r, sanitizeKnowledgeReadinessReport as ra, TokenUsageProvenance as ri, DiffOptions as rn, RetainedRunEventOptions as ro, AgentExecutionRef as rr, SandboxToolPartState as rt, streamAgentTurn as s, WaitProbe as sa, UsageEvent as si, WorktreeHandle as sn, RetainedRunSnapshot as so, ExecutionBindingReceipt as sr, createSandboxUsageLedger as st, AgentTurnBackend as t, createRuntimeStreamEventCollector as ta, Supervisor as ti, WorktreeProfileMaterializationReceipt as tn, RetainedRunEffect as to, resolveRedactor as tr, SandboxOutputMarker as tt, CliWorktreeBridgeSeam as u, WaitSpec as ua, WorkerInteractiveSession as ui, removeWorktree as un, StartRetainedRunInEnvironmentOptions as uo, ExecutorCancellation as ur, mapSandboxToolEvent as ut, cliWorktreeExecutor as v, SessionTraceBox as va, workerTraceHeaders as vi, RunLocalHarnessOptions as vn, spendFromUsageEvents as vo, ExecutorRegistry as vr, AgentEnvironmentProviderRef as vt, SteerableSandboxSession as w, ActivityLog as wa, traceContextToEnv as wi, ToolSpec as wn, MaterializedModelIdentity as wr, AgentSession as wt, DEFAULT_SANDBOX_STEERING_MAX_TURNS as x, createPushTraceSource as xa, createPropagatingTraceEmitter as xi, parseCodexTokenUsage as xn, ExecutorToolCall as xr, AgentEnvironmentStatus as xt, createExecutor as y, ToolStepInput as ya, workerTraceSeamKey as yi, harnessSupportsReasoningEffort as yn, ExecutorResult as yr, AgentEnvironmentProviderRegistry as yt, resolveSecretEnv as z, NativeContextContinuationExecution as za, createOpenInferenceFileExporter as zi, PeerMailReadout as zn, RootMaterialization as zr, ResourceRequest as zt };
|
|
4816
|
+
//# sourceMappingURL=stream-agent-turn-BXZMQQ0K.d.ts.map
|