@tangle-network/agent-runtime 0.68.0 → 0.70.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.
Files changed (78) hide show
  1. package/README.md +81 -13
  2. package/dist/agent.d.ts +4 -5
  3. package/dist/agent.js +3 -6
  4. package/dist/agent.js.map +1 -1
  5. package/dist/chunk-BYZCXQHF.js +474 -0
  6. package/dist/chunk-BYZCXQHF.js.map +1 -0
  7. package/dist/{chunk-OYU5LR4T.js → chunk-EDCVUZZC.js} +2 -2
  8. package/dist/{chunk-QNUEFNU7.js → chunk-L5ZFBVT6.js} +6 -6
  9. package/dist/chunk-L5ZFBVT6.js.map +1 -0
  10. package/dist/{chunk-VKUHUFX7.js → chunk-QXWGSDAQ.js} +914 -590
  11. package/dist/chunk-QXWGSDAQ.js.map +1 -0
  12. package/dist/{chunk-LTEF2LYD.js → chunk-ZNQVMMR5.js} +3 -3
  13. package/dist/{coordination-Curpzeyc.d.ts → coordination-C7WxwHXq.d.ts} +8 -1
  14. package/dist/{delegates-CLFNAKyi.d.ts → delegates-DqAgo32T.d.ts} +105 -10
  15. package/dist/{improvement-adapter-BC4HhuAR.d.ts → improvement-adapter-BVuMragr.d.ts} +1 -1
  16. package/dist/index.d.ts +439 -100
  17. package/dist/index.js +583 -125
  18. package/dist/index.js.map +1 -1
  19. package/dist/intelligence.d.ts +2 -3
  20. package/dist/{loop-runner-bin-B6dzNZC8.d.ts → loop-runner-bin-B0NeLTRd.d.ts} +4 -4
  21. package/dist/loop-runner-bin.d.ts +7 -10
  22. package/dist/loop-runner-bin.js +4 -7
  23. package/dist/loops.d.ts +3149 -16
  24. package/dist/loops.js +34 -63
  25. package/dist/mcp/bin.js +14 -16
  26. package/dist/mcp/bin.js.map +1 -1
  27. package/dist/mcp/index.d.ts +8 -12
  28. package/dist/mcp/index.js +16 -19
  29. package/dist/mcp/index.js.map +1 -1
  30. package/dist/{openai-tools-CA2N3-Ak.d.ts → openai-tools-DPx9Gzvn.d.ts} +1 -1
  31. package/dist/profiles.d.ts +94 -6
  32. package/dist/profiles.js +320 -9
  33. package/dist/profiles.js.map +1 -1
  34. package/dist/{router-client-30Y_pca8.d.ts → router-client-C7kp_ECN.d.ts} +37 -1
  35. package/dist/{substrate-CUgk7F7s.d.ts → substrate-BoRXgvka.d.ts} +52 -1
  36. package/dist/{types-Crxftafi.d.ts → types-BYa2ZOAx.d.ts} +83 -2
  37. package/dist/{types-p8dWBIXL.d.ts → types-DJu6TBGp.d.ts} +2 -16
  38. package/dist/{worktree-fanout-DUiKPApb.d.ts → worktree-fanout-gNfl0Byj.d.ts} +9 -37
  39. package/package.json +9 -39
  40. package/dist/analyst-loop.d.ts +0 -52
  41. package/dist/analyst-loop.js +0 -11
  42. package/dist/analyst-loop.js.map +0 -1
  43. package/dist/audit.d.ts +0 -93
  44. package/dist/audit.js +0 -312
  45. package/dist/audit.js.map +0 -1
  46. package/dist/chunk-4B6U4CVQ.js +0 -15
  47. package/dist/chunk-4B6U4CVQ.js.map +0 -1
  48. package/dist/chunk-FCIPUALH.js +0 -214
  49. package/dist/chunk-FCIPUALH.js.map +0 -1
  50. package/dist/chunk-O2UPHN7X.js +0 -114
  51. package/dist/chunk-O2UPHN7X.js.map +0 -1
  52. package/dist/chunk-P5OKDSLB.js +0 -580
  53. package/dist/chunk-P5OKDSLB.js.map +0 -1
  54. package/dist/chunk-QNUEFNU7.js.map +0 -1
  55. package/dist/chunk-VKUHUFX7.js.map +0 -1
  56. package/dist/chunk-VLF5RHEQ.js +0 -143
  57. package/dist/chunk-VLF5RHEQ.js.map +0 -1
  58. package/dist/coder-2leJPOvC.d.ts +0 -52
  59. package/dist/improvement.d.ts +0 -208
  60. package/dist/improvement.js +0 -343
  61. package/dist/improvement.js.map +0 -1
  62. package/dist/local-harness-BE_h8szs.d.ts +0 -93
  63. package/dist/platform.d.ts +0 -255
  64. package/dist/platform.js +0 -229
  65. package/dist/platform.js.map +0 -1
  66. package/dist/run-loop-D3PwlG7J.d.ts +0 -112
  67. package/dist/runtime-hooks-C7JwKb9E.d.ts +0 -70
  68. package/dist/runtime.d.ts +0 -3108
  69. package/dist/runtime.js +0 -263
  70. package/dist/runtime.js.map +0 -1
  71. package/dist/topology.d.ts +0 -126
  72. package/dist/topology.js +0 -333
  73. package/dist/topology.js.map +0 -1
  74. package/dist/workflow.d.ts +0 -551
  75. package/dist/workflow.js +0 -1781
  76. package/dist/workflow.js.map +0 -1
  77. /package/dist/{chunk-OYU5LR4T.js.map → chunk-EDCVUZZC.js.map} +0 -0
  78. /package/dist/{chunk-LTEF2LYD.js.map → chunk-ZNQVMMR5.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,23 +1,21 @@
1
- import { AgentProfile, AgentEvalError, KnowledgeReadinessReport, RunRecord, ControlEvalResult, KnowledgeRequirement } from '@tangle-network/agent-eval';
1
+ import { AgentProfile, AgentEvalError, AnalystFinding, KnowledgeReadinessReport, RunRecord, ControlEvalResult, KnowledgeRequirement } from '@tangle-network/agent-eval';
2
2
  export { AgentEvalError, AgentEvalErrorCode, ConfigError, ControlBudget, ControlDecision, ControlEvalResult, ControlRunResult, ControlStep, DataAcquisitionPlan, JudgeError, KnowledgeReadinessReport, KnowledgeRequirement, NotFoundError, RunRecord, ValidationError } from '@tangle-network/agent-eval';
3
- import { h as AgentBackendInput, i as AgentExecutionBackend, c as OpenAIChatTool, j as OpenAIChatToolChoice, k as AgentBackendContext, R as RuntimeStreamEvent, K as KnowledgeReadinessDecision, l as RunAgentTaskOptions, m as AgentTaskRunResult, n as RunAgentTaskStreamOptions, o as AgentRuntimeEvent, p as AgentTaskStatus, q as RuntimeSessionStore, r as RuntimeSession } from './types-Crxftafi.js';
4
- export { s as AgentAdapter, t as AgentKnowledgeProvider, u as AgentRuntimeEventSink, v as AgentTaskContext, w as AgentTaskSpec, B as BackendErrorDetail, x as RuntimeRunHandle, y as RuntimeRunPersistenceAdapter, z as RuntimeRunRow, C as startRuntimeRun } from './types-Crxftafi.js';
5
- import { Scenario, ProfileDispatchFn } from '@tangle-network/agent-eval/campaign';
6
- export { C as CoderLoopRunnerOptions, D as DELEGATED_LOOP_MODES, a as DelegatedLoopMode, b as DelegatedLoopRegistry, c as DelegatedLoopResult, d as DelegatedLoopRunner, L as LoopRunnerCliArgs, e as LoopRunnerCliResult, R as ResearchLoopResult, f as ResearchLoopRunnerOptions, g as RunDelegatedLoopOptions, V as VetoedFact, W as WorktreeLoopRunnerOptions, h as auditLoopRunner, i as coderLoopRunner, j as isDelegatedLoopMode, p as parseLoopRunnerArgv, r as researchLoopRunner, k as runDelegatedLoop, l as runLoopRunnerCli, s as selfImproveLoopRunner, w as worktreeLoopRunner } from './loop-runner-bin-B6dzNZC8.js';
7
- export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from './openai-tools-CA2N3-Ak.js';
8
- export { aU as EvalRunEvent, aV as EvalRunGeneration, aW as EvalRunsExportConfig, aX as EvalRunsExportResult, aY as INTELLIGENCE_WIRE_VERSION, aZ as LoopSpanNode, a_ as OtelAttribute, a$ as OtelExportConfig, b0 as OtelExporter, b1 as OtelSpan, b2 as buildLoopOtelSpans, b3 as buildLoopSpanNodes, b4 as createOtelExporter, b5 as exportEvalRuns, b6 as loopEventToOtelSpan } from './delegates-CLFNAKyi.js';
9
- import { R as RuntimeHooks } from './runtime-hooks-C7JwKb9E.js';
10
- export { b as RuntimeDecisionEvidenceRef, c as RuntimeDecisionKind, d as RuntimeDecisionPoint, e as RuntimeHookContext, f as RuntimeHookErrorContext, a as RuntimeHookEvent, g as RuntimeHookPhase, h as RuntimeHookTarget, i as composeRuntimeHooks, j as defineRuntimeHooks, n as notifyRuntimeDecisionPoint, k as notifyRuntimeHookEvent } from './runtime-hooks-C7JwKb9E.js';
3
+ import { f as AgentBackendInput, g as AgentExecutionBackend, O as OpenAIChatTool, h as OpenAIChatToolChoice, i as AgentBackendContext, R as RuntimeStreamEvent, K as KnowledgeReadinessDecision, j as RunAgentTaskOptions, k as AgentTaskRunResult, l as RunAgentTaskStreamOptions, m as AgentRuntimeEvent, n as AgentTaskStatus, o as RuntimeSessionStore, p as RuntimeSession, b as RuntimeHooks } from './types-BYa2ZOAx.js';
4
+ export { q as AgentAdapter, r as AgentKnowledgeProvider, s as AgentRuntimeEventSink, t as AgentTaskContext, u as AgentTaskSpec, B as BackendErrorDetail, v as RuntimeDecisionEvidenceRef, w as RuntimeDecisionKind, x as RuntimeDecisionPoint, y as RuntimeHookContext, z as RuntimeHookErrorContext, C as RuntimeHookEvent, D as RuntimeHookPhase, E as RuntimeHookTarget, F as RuntimeRunHandle, G as RuntimeRunPersistenceAdapter, H as RuntimeRunRow, J as composeRuntimeHooks, M as defineRuntimeHooks, N as notifyRuntimeDecisionPoint, P as notifyRuntimeHookEvent, Q as startRuntimeRun } from './types-BYa2ZOAx.js';
5
+ import { AgentProfile as AgentProfile$1 } from '@tangle-network/agent-interface';
6
+ import { Scenario, ProfileDispatchFn, LabeledScenarioStore, WorktreeAdapter, SurfaceProposer } from '@tangle-network/agent-eval/campaign';
7
+ import { L as LocalHarness, r as runLocalHarness } from './delegates-DqAgo32T.js';
8
+ export { aY as EvalRunEvent, aZ as EvalRunGeneration, a_ as EvalRunsExportConfig, a$ as EvalRunsExportResult, b0 as INTELLIGENCE_WIRE_VERSION, b1 as LoopSpanNode, b2 as OtelAttribute, b3 as OtelExportConfig, b4 as OtelExporter, b5 as OtelSpan, b6 as buildLoopOtelSpans, b7 as buildLoopSpanNodes, b8 as createOtelExporter, b9 as exportEvalRuns, ba as loopEventToOtelSpan } from './delegates-DqAgo32T.js';
9
+ import { Scenario as Scenario$1, SurfaceProposer as SurfaceProposer$1, JudgeConfig, MutableSurface, DispatchContext, SelfImproveBudget, SelfImproveLlm, SelfImproveResult } from '@tangle-network/agent-eval/contract';
10
+ import { S as SurfaceImprovementEdit } from './improvement-adapter-BVuMragr.js';
11
+ import { I as ImprovementAdapter } from './types-DJu6TBGp.js';
12
+ export { C as CoderLoopRunnerOptions, D as DELEGATED_LOOP_MODES, a as DelegatedLoopMode, b as DelegatedLoopRegistry, c as DelegatedLoopResult, d as DelegatedLoopRunner, L as LoopRunnerCliArgs, e as LoopRunnerCliResult, R as ResearchLoopResult, f as ResearchLoopRunnerOptions, g as RunDelegatedLoopOptions, V as VetoedFact, W as WorktreeLoopRunnerOptions, h as auditLoopRunner, i as coderLoopRunner, j as isDelegatedLoopMode, p as parseLoopRunnerArgv, r as researchLoopRunner, k as runDelegatedLoop, l as runLoopRunnerCli, s as selfImproveLoopRunner, w as worktreeLoopRunner } from './loop-runner-bin-B0NeLTRd.js';
13
+ export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from './openai-tools-DPx9Gzvn.js';
11
14
  import '@tangle-network/sandbox';
12
- import '@tangle-network/agent-eval/contract';
13
- import './types-p8dWBIXL.js';
14
- import './kb-gate-CuzMYGYM.js';
15
- import './worktree-fanout-DUiKPApb.js';
16
- import '@tangle-network/agent-interface';
17
- import './local-harness-BE_h8szs.js';
18
15
  import 'node:child_process';
19
- import './coder-2leJPOvC.js';
20
- import './substrate-CUgk7F7s.js';
16
+ import './substrate-BoRXgvka.js';
17
+ import './kb-gate-CuzMYGYM.js';
18
+ import './worktree-fanout-gNfl0Byj.js';
21
19
 
22
20
  /**
23
21
  * @stable
@@ -671,6 +669,144 @@ declare function defineConversation(input: {
671
669
  policy: ConversationPolicy;
672
670
  }): Conversation;
673
671
 
672
+ /**
673
+ * `runPersonaConversation` — the persona loop runner: run a WORKER `AgentProfile`
674
+ * (the agent under test) as a multi-round conversation driven by a PERSONA (the
675
+ * simulated user), over the persistent conversation transcript.
676
+ *
677
+ * It is profiles-vs-profiles: the persona is itself a driver `AgentProfile` (an
678
+ * LLM role-playing the user from its facts) — `runConversation` runs the two
679
+ * against each other. Scripted persona turns are kept as a deterministic
680
+ * fast-path. Only the WORKER is metered (it is the side under test); the
681
+ * persona-driver is the test harness, not billed against the agent.
682
+ *
683
+ * `runPersonaDispatch` wraps the runner as a `ProfileDispatchFn` so it drops
684
+ * straight into `runProfileMatrix({ dispatch })` — the same loop serves a single
685
+ * cell and the whole matrix, replacing the per-agent hand-rolled
686
+ * `dispatchWithSurface` bridges.
687
+ */
688
+
689
+ /** A persona that drives the conversation: either a full driver `AgentProfile`
690
+ * (an LLM user-sim) or a deterministic script of user turns (the fast-path). */
691
+ type PersonaDriver = {
692
+ kind: 'profile';
693
+ profile: AgentProfile;
694
+ } | {
695
+ kind: 'scripted';
696
+ turns: string[];
697
+ };
698
+ interface RunPersonaConversationOptions {
699
+ /** The agent under test. Metered; its rendered prompt leads its turns. */
700
+ worker: AgentProfile;
701
+ /** The simulated user driving the dialogue. */
702
+ persona: PersonaDriver;
703
+ /** Turn an `AgentProfile` into a runnable backend (router / sandbox / fake).
704
+ * Applied to the worker and to a `profile`-kind persona. */
705
+ backendFor: (profile: AgentProfile, role: 'worker' | 'persona') => AgentExecutionBackend;
706
+ /** Render a profile's system prompt — prepended to that profile's messages. */
707
+ systemPromptOf: (profile: AgentProfile) => string;
708
+ /** Speaker-turn cap. Default for a scripted persona = `2 * turns.length`
709
+ * (worker answers each user turn). REQUIRED for a `profile` persona. */
710
+ maxTurns?: number;
711
+ /** Kickoff message routed to the first speaker (the persona). Default 'Begin.' */
712
+ seed?: string;
713
+ /** Content-based "until satisfied" halt, called after every turn. `maxTurns` is the
714
+ * hard ceiling; this is the early stop (the persona declares the goal met / unreachable). */
715
+ haltOn?: HaltPredicate;
716
+ signal?: AbortSignal;
717
+ /** Worker participant / transcript speaker label. Default 'agent'. */
718
+ workerName?: string;
719
+ }
720
+ interface PersonaConversationResult {
721
+ transcript: ConversationTurn[];
722
+ turns: number;
723
+ halted: HaltReason;
724
+ /** Worker-only spend (the side under test). */
725
+ costUsd: number;
726
+ tokensIn: number;
727
+ tokensOut: number;
728
+ }
729
+ /**
730
+ * Run one worker profile against one persona as a multi-round conversation.
731
+ * The persona leads (participant 0): it speaks, the worker answers, repeat,
732
+ * until `maxTurns`. Returns the persistent transcript + worker-only usage.
733
+ */
734
+ declare function runPersonaConversation(opts: RunPersonaConversationOptions): Promise<PersonaConversationResult>;
735
+ interface RunPersonaConfig<TScenario extends Scenario, TArtifact> {
736
+ /** Turn an `AgentProfile` into a runnable backend (router / sandbox / fake). */
737
+ backendFor: (profile: AgentProfile, role: 'worker' | 'persona') => AgentExecutionBackend;
738
+ /** Render a profile's system prompt. */
739
+ systemPromptOf: (profile: AgentProfile) => string;
740
+ /** The persona driving each scenario — a driver profile or scripted turns. */
741
+ personaOf: (scenario: TScenario) => PersonaDriver;
742
+ /** Build the scored artifact from the finished transcript. */
743
+ artifactOf: (transcript: ConversationTurn[], scenario: TScenario) => TArtifact;
744
+ /** Speaker-turn cap (required when a persona is profile-driven). */
745
+ maxTurns?: (scenario: TScenario) => number;
746
+ seed?: (scenario: TScenario) => string;
747
+ workerName?: string;
748
+ }
749
+ /**
750
+ * Wrap {@link runPersonaConversation} as a `ProfileDispatchFn` for
751
+ * `runProfileMatrix`: the profile axis is the worker-under-test, the scenario
752
+ * axis is the persona, and the runner is the cell. Meters the worker through
753
+ * `ctx.cost` so the matrix's backend-integrity guard sees real usage.
754
+ */
755
+ declare function runPersonaDispatch<TScenario extends Scenario, TArtifact>(config: RunPersonaConfig<TScenario, TArtifact>): ProfileDispatchFn<TScenario, TArtifact>;
756
+
757
+ /**
758
+ * `evalPersona` — the one-call user-sim product eval. Run a worker `AgentProfile` (the agent under
759
+ * test) against a PERSONA (a simulated user — a scripted script or an LLM driver profile) as a
760
+ * multi-round conversation, with the two seams `runPersonaConversation` otherwise makes you hand-wire
761
+ * defaulted:
762
+ *
763
+ * - `backendFor` defaults to `createOpenAICompatibleBackend({ apiKey, baseUrl, model })` (the
764
+ * OpenAI-compatible router endpoint) for both the worker and a profile-driven persona;
765
+ * - `systemPromptOf` defaults to `p.prompt?.systemPrompt ?? ''`.
766
+ *
767
+ * Either is overridable (tests pass a fake `backendFor` to run offline). `maxTurns` (the hard
768
+ * ceiling) and `haltOn` (the "until satisfied" early stop) pass straight through. Mirrors
769
+ * `supervise()`'s defaulting style: the common case is one call; the raw `runPersonaConversation`
770
+ * seam stays available for full control.
771
+ *
772
+ * The profile here is the authored `AgentProfile` (with `prompt.systemPrompt`), which is why the
773
+ * default `systemPromptOf` can read it. `runPersonaConversation` treats the profile opaquely — only
774
+ * the two callbacks inspect it — so the worker/persona profiles flow straight through.
775
+ */
776
+
777
+ interface EvalPersonaOptions {
778
+ /** Router (or OpenAI-compatible) endpoint for the DEFAULT backend. Required unless `backendFor`
779
+ * is supplied (tests/advanced override the backend entirely and may omit these). */
780
+ apiKey?: string;
781
+ baseUrl?: string;
782
+ model?: string;
783
+ /** Override the backend seam directly instead of deriving it from `apiKey`/`baseUrl`/`model`
784
+ * (the offline-test path: pass a fake here and the credentials are not needed). */
785
+ backendFor?: (profile: AgentProfile$1, role: 'worker' | 'persona') => AgentExecutionBackend;
786
+ /** Override system-prompt rendering. Default: `p.prompt?.systemPrompt ?? ''`. */
787
+ systemPromptOf?: (profile: AgentProfile$1) => string;
788
+ /** Hard speaker-turn ceiling. REQUIRED for a profile-driven persona; for a scripted persona it
789
+ * defaults to `2 * turns.length`. `maxTurns` is a CEILING, NOT a target — `maxTurns: 0` is zero
790
+ * turns, not run-until-done; `haltOn` is the "until satisfied" knob. */
791
+ maxTurns?: number;
792
+ /** Content-based early stop (the persona declares the goal met / unreachable). */
793
+ haltOn?: HaltPredicate;
794
+ /** Kickoff message to the persona. Default 'Begin.' */
795
+ seed?: string;
796
+ signal?: AbortSignal;
797
+ /** Worker transcript speaker label. Default 'agent'. */
798
+ workerName?: string;
799
+ }
800
+ /** The persona side, authored against the same `AgentProfile` shape as the worker. */
801
+ type EvalPersona = {
802
+ kind: 'scripted';
803
+ turns: string[];
804
+ } | {
805
+ kind: 'profile';
806
+ profile: AgentProfile$1;
807
+ };
808
+ declare function evalPersona(worker: AgentProfile$1, persona: EvalPersona, opts?: EvalPersonaOptions): Promise<PersonaConversationResult>;
809
+
674
810
  /**
675
811
  * @stable
676
812
  *
@@ -805,88 +941,6 @@ declare class SqlConversationJournal implements ConversationJournal {
805
941
  declare function runConversation(conversation: Conversation, options: RunConversationOptions): Promise<ConversationResult>;
806
942
  declare function runConversationStream(conversation: Conversation, options: RunConversationOptions): AsyncIterable<ConversationStreamEvent>;
807
943
 
808
- /**
809
- * `runPersonaConversation` — the persona loop runner: run a WORKER `AgentProfile`
810
- * (the agent under test) as a multi-round conversation driven by a PERSONA (the
811
- * simulated user), over the persistent conversation transcript.
812
- *
813
- * It is profiles-vs-profiles: the persona is itself a driver `AgentProfile` (an
814
- * LLM role-playing the user from its facts) — `runConversation` runs the two
815
- * against each other. Scripted persona turns are kept as a deterministic
816
- * fast-path. Only the WORKER is metered (it is the side under test); the
817
- * persona-driver is the test harness, not billed against the agent.
818
- *
819
- * `runPersonaDispatch` wraps the runner as a `ProfileDispatchFn` so it drops
820
- * straight into `runProfileMatrix({ dispatch })` — the same loop serves a single
821
- * cell and the whole matrix, replacing the per-agent hand-rolled
822
- * `dispatchWithSurface` bridges.
823
- */
824
-
825
- /** A persona that drives the conversation: either a full driver `AgentProfile`
826
- * (an LLM user-sim) or a deterministic script of user turns (the fast-path). */
827
- type PersonaDriver = {
828
- kind: 'profile';
829
- profile: AgentProfile;
830
- } | {
831
- kind: 'scripted';
832
- turns: string[];
833
- };
834
- interface RunPersonaConversationOptions {
835
- /** The agent under test. Metered; its rendered prompt leads its turns. */
836
- worker: AgentProfile;
837
- /** The simulated user driving the dialogue. */
838
- persona: PersonaDriver;
839
- /** Turn an `AgentProfile` into a runnable backend (router / sandbox / fake).
840
- * Applied to the worker and to a `profile`-kind persona. */
841
- backendFor: (profile: AgentProfile, role: 'worker' | 'persona') => AgentExecutionBackend;
842
- /** Render a profile's system prompt — prepended to that profile's messages. */
843
- systemPromptOf: (profile: AgentProfile) => string;
844
- /** Speaker-turn cap. Default for a scripted persona = `2 * turns.length`
845
- * (worker answers each user turn). REQUIRED for a `profile` persona. */
846
- maxTurns?: number;
847
- /** Kickoff message routed to the first speaker (the persona). Default 'Begin.' */
848
- seed?: string;
849
- signal?: AbortSignal;
850
- /** Worker participant / transcript speaker label. Default 'agent'. */
851
- workerName?: string;
852
- }
853
- interface PersonaConversationResult {
854
- transcript: ConversationTurn[];
855
- turns: number;
856
- halted: HaltReason;
857
- /** Worker-only spend (the side under test). */
858
- costUsd: number;
859
- tokensIn: number;
860
- tokensOut: number;
861
- }
862
- /**
863
- * Run one worker profile against one persona as a multi-round conversation.
864
- * The persona leads (participant 0): it speaks, the worker answers, repeat,
865
- * until `maxTurns`. Returns the persistent transcript + worker-only usage.
866
- */
867
- declare function runPersonaConversation(opts: RunPersonaConversationOptions): Promise<PersonaConversationResult>;
868
- interface RunPersonaConfig<TScenario extends Scenario, TArtifact> {
869
- /** Turn an `AgentProfile` into a runnable backend (router / sandbox / fake). */
870
- backendFor: (profile: AgentProfile, role: 'worker' | 'persona') => AgentExecutionBackend;
871
- /** Render a profile's system prompt. */
872
- systemPromptOf: (profile: AgentProfile) => string;
873
- /** The persona driving each scenario — a driver profile or scripted turns. */
874
- personaOf: (scenario: TScenario) => PersonaDriver;
875
- /** Build the scored artifact from the finished transcript. */
876
- artifactOf: (transcript: ConversationTurn[], scenario: TScenario) => TArtifact;
877
- /** Speaker-turn cap (required when a persona is profile-driven). */
878
- maxTurns?: (scenario: TScenario) => number;
879
- seed?: (scenario: TScenario) => string;
880
- workerName?: string;
881
- }
882
- /**
883
- * Wrap {@link runPersonaConversation} as a `ProfileDispatchFn` for
884
- * `runProfileMatrix`: the profile axis is the worker-under-test, the scenario
885
- * axis is the persona, and the runner is the cell. Meters the worker through
886
- * `ctx.cost` so the matrix's backend-integrity guard sees real usage.
887
- */
888
- declare function runPersonaDispatch<TScenario extends Scenario, TArtifact>(config: RunPersonaConfig<TScenario, TArtifact>): ProfileDispatchFn<TScenario, TArtifact>;
889
-
890
944
  /**
891
945
  * @stable
892
946
  *
@@ -1103,6 +1157,291 @@ declare class PlannerError extends AgentEvalError {
1103
1157
  });
1104
1158
  }
1105
1159
 
1160
+ /**
1161
+ * @experimental
1162
+ *
1163
+ * `improvementDriver` — the ONE reflective/agentic improvement proposer for
1164
+ * agent-eval's improvement loop. It implements `SurfaceProposer` and owns
1165
+ * the candidate lifecycle (worktree create → generate → finalize/discard,
1166
+ * × populationSize); it delegates the only thing that genuinely varies — HOW
1167
+ * a candidate change is produced — to a pluggable `CandidateGenerator`.
1168
+ *
1169
+ * There is no separate "analyst driver" vs "autoresearch driver": those are
1170
+ * the SAME driver at two settings of a dial.
1171
+ * - cheap reflective path → `reflectiveGenerator` (shots=1, no sandbox;
1172
+ * applies pre-drafted patches)
1173
+ * - full agentic path → `agenticGenerator` (shots=N, multi-shot
1174
+ * verify-in-session loop; an agent reads code +
1175
+ * report, edits, and re-tries on verifier failure)
1176
+ * Both emit changes into a worktree the driver finalizes into a
1177
+ * `CodeSurface{ worktreeRef }` the loop measures on the holdout. See
1178
+ * agent-eval's `docs/design/self-improvement-engine.md`.
1179
+ */
1180
+
1181
+ /** The byte-producing seam — the ONE thing that differs between the cheap
1182
+ * reflective path and the full agentic path. A generator makes (uncommitted)
1183
+ * changes inside `worktreePath`; the driver commits them via the worktree
1184
+ * adapter's `finalize`. */
1185
+ interface CandidateGenerator {
1186
+ kind: string;
1187
+ generate(args: {
1188
+ /** The candidate worktree — a fresh checkout of baseRef. Write changes here. */
1189
+ worktreePath: string;
1190
+ /** Phase-2 research report (analyst findings + diff), opaque. */
1191
+ report: unknown;
1192
+ /** Findings resolved from the report or the loop context. */
1193
+ findings: AnalystFinding[];
1194
+ /** Handle to all captured data, to ground the change. */
1195
+ dataset?: LabeledScenarioStore;
1196
+ /** DEPTH: max iterations the generator may take (agentic uses this; the
1197
+ * reflective generator ignores it). */
1198
+ maxShots: number;
1199
+ signal: AbortSignal;
1200
+ }): Promise<{
1201
+ applied: boolean;
1202
+ summary: string;
1203
+ }>;
1204
+ }
1205
+ interface ImprovementDriverOptions {
1206
+ worktree: WorktreeAdapter;
1207
+ generator: CandidateGenerator;
1208
+ /** Base ref candidate worktrees fork from. Default `main`. */
1209
+ baseRef?: string;
1210
+ }
1211
+ declare function improvementDriver(opts: ImprovementDriverOptions): SurfaceProposer<AnalystFinding>;
1212
+
1213
+ /**
1214
+ * @experimental
1215
+ *
1216
+ * `agenticGenerator` — the full-agentic `CandidateGenerator`: the
1217
+ * `shots=N, sandbox=on` setting of the one `improvementDriver`. It runs a real
1218
+ * coding harness (claude / codex / opencode) inside the candidate worktree the
1219
+ * driver already created, letting the agent read the codebase + the research
1220
+ * report and make the change in place. The driver then commits the worktree
1221
+ * into a `CodeSurface`.
1222
+ *
1223
+ * Mechanism: identical to the proven Phase-2.8 in-process executor — spawn the
1224
+ * harness as a subprocess with `cwd` = the worktree, on the same filesystem,
1225
+ * so edits land in place (no sandbox-mount round-trip). `runLocalHarness` is
1226
+ * the verified primitive. The OUTER sandbox is the improvement loop's own
1227
+ * execution context; the generator does not nest a second sandbox per
1228
+ * candidate (which would reintroduce a host↔sandbox worktree-transport
1229
+ * problem that does not need solving here).
1230
+ *
1231
+ * `maxShots` is the DEPTH dial — a multi-shot verify-in-session loop, NOT the
1232
+ * kernel `runLoop`. Each shot runs one full harness session in the (persistent)
1233
+ * worktree; between shots the loop refines based on what the last shot produced:
1234
+ * - empty tree → "you changed nothing, make the edits" → retry
1235
+ * - dirty + `verify` fails → feed the verifier's failure into the next shot
1236
+ * (the worktree persists, so the harness RESUMES atop its own failing
1237
+ * edits with the error in hand — no `--resume` session plumbing needed,
1238
+ * and harness-agnostic across claude/codex/opencode)
1239
+ * - dirty + `verify` ok (or no verifier configured) → return the candidate
1240
+ * A candidate that never verifies within `maxShots` is discarded (`applied:
1241
+ * false`), never shipped — if you configured a verifier, a non-passing tree is
1242
+ * not a candidate. With no verifier the legacy behavior holds: first dirty shot
1243
+ * is the candidate.
1244
+ */
1245
+
1246
+ /** Outcome of verifying a candidate worktree. `feedback` (compiler errors,
1247
+ * failing test output) is fed into the next shot when `ok` is false. */
1248
+ interface VerifyResult {
1249
+ ok: boolean;
1250
+ feedback?: string;
1251
+ }
1252
+ /** Verifies the edited worktree. Sync or async; throws only on a setup fault
1253
+ * (a candidate that fails verification returns `{ok:false}`, it does not
1254
+ * throw). */
1255
+ type Verifier = (worktreePath: string) => Promise<VerifyResult> | VerifyResult;
1256
+ interface AgenticGeneratorOptions {
1257
+ /** Local coding harness to run in the worktree. Default `claude`. */
1258
+ harness?: LocalHarness;
1259
+ /** Per-shot wall-clock timeout (ms). Default = `runLocalHarness` default (5m). */
1260
+ timeoutMs?: number;
1261
+ /** Build the harness task prompt from the report + findings. Override for
1262
+ * domain phrasing; the default turns findings into a concrete coder task. */
1263
+ buildPrompt?: (args: {
1264
+ report: unknown;
1265
+ findings: AnalystFinding[];
1266
+ }) => string;
1267
+ /** Verify the worktree after each dirtying shot. When set, a candidate that
1268
+ * fails verification is NOT returned — the failure feeds the next shot
1269
+ * (verify-in-session), up to `maxShots`; a candidate that never verifies is
1270
+ * discarded (`applied:false`), never shipped. Omitted ⇒ legacy behavior:
1271
+ * the first dirty shot is the candidate. See `commandVerifier`. */
1272
+ verify?: Verifier;
1273
+ /** Test seam — inject the harness runner (defaults to `runLocalHarness`). */
1274
+ runHarness?: typeof runLocalHarness;
1275
+ /** Test seam — inject the worktree-dirty check (defaults to `git status`). */
1276
+ isDirty?: (worktreePath: string) => boolean;
1277
+ }
1278
+ declare function agenticGenerator(opts?: AgenticGeneratorOptions): CandidateGenerator;
1279
+ /** A `Verifier` that runs a command in the worktree: exit 0 ⇒ ok, any other
1280
+ * exit ⇒ failed with stdout+stderr as feedback. The common case — verify by
1281
+ * `tsc --noEmit`, `pnpm build`, or a test command. A timeout is treated as a
1282
+ * FAILED candidate (a change that hangs the build is a bad change); a missing
1283
+ * binary or spawn fault throws (a setup bug, not a failed candidate — no
1284
+ * silent fallback). */
1285
+ declare function commandVerifier(command: string, args?: string[], timeoutMs?: number): Verifier;
1286
+
1287
+ /**
1288
+ * Build-prompt starting points for the two buildable artifact types. There is
1289
+ * NO `toolGenerator`/`mcpGenerator` wrapper — the factory is `agenticGenerator`
1290
+ * + a verifier (docs/artifact-lifecycle-frontier.md), so a tool or an MCP
1291
+ * server is built by composing the pieces directly:
1292
+ *
1293
+ * // a tool:
1294
+ * agenticGenerator({ buildPrompt: toolBuildPrompt, verify: commandVerifier('pnpm', ['test']) })
1295
+ * // an MCP server:
1296
+ * agenticGenerator({ buildPrompt: mcpBuildPrompt, verify: mcpServeVerifier({ command: 'node', args: ['server.mjs'] }) })
1297
+ *
1298
+ * These are the only type-specific bit (the phrasing that points the agent at a
1299
+ * tool vs. an MCP); the worktree, resume-on-failure loop, and improvement-loop
1300
+ * wrapper are shared. MCP is the load-bearing target — it is how a harness
1301
+ * acquires tools; raw tools matter where we control the loader.
1302
+ */
1303
+
1304
+ type FindingsArg = {
1305
+ report: unknown;
1306
+ findings: AnalystFinding[];
1307
+ };
1308
+ declare function toolBuildPrompt(args: FindingsArg): string;
1309
+ declare function mcpBuildPrompt(args: FindingsArg): string;
1310
+
1311
+ /**
1312
+ * @experimental
1313
+ *
1314
+ * `improve` — the ONE public, surface-pluggable RSI verb.
1315
+ *
1316
+ * A thin facade over agent-eval's `selfImprove` (the held-out-gated closed
1317
+ * loop). It removes the two things a caller otherwise has to know to drive the
1318
+ * loop by hand: WHICH `MutableSurface` of the profile is being optimized, and
1319
+ * WHICH `SurfaceProposer` mutates that surface. You name a `surface`; the
1320
+ * facade picks the matching default proposer, extracts the baseline surface from
1321
+ * the profile, runs `selfImprove`, and (on a ship verdict) writes the promoted
1322
+ * winner back into the corresponding profile field.
1323
+ *
1324
+ * - `surface: 'prompt'` → `gepaProposer` mutates `profile.prompt.systemPrompt`.
1325
+ * - `surface: 'skills'` → `skillOptProposer` mutates a skills document string.
1326
+ * - `surface` ∈ {`tools`, `mcp`, `hooks`, `code`} → no zero-config default
1327
+ * proposer exists (a code/config proposer needs caller-supplied wiring — a
1328
+ * worktree repo root, a candidate generator, a serializer). The facade
1329
+ * requires an explicit `opts.generator` for these and throws a `ConfigError`
1330
+ * otherwise. This is a designed boundary, not a missing default: there is
1331
+ * no safe value the facade could invent for those seams.
1332
+ *
1333
+ * Everything else (`scenarios`, `judge`, `agent`, `budget`, `llm`) passes
1334
+ * straight through to `selfImprove`.
1335
+ */
1336
+
1337
+ /** The agent-profile lever `improve` optimizes. Mirrors the AgentProfile-law
1338
+ * profile levers; `code` is the implementation-tier surface. */
1339
+ type ImproveSurface = 'prompt' | 'skills' | 'tools' | 'mcp' | 'hooks' | 'code';
1340
+ interface ImproveOptions<TScenario extends Scenario$1, TArtifact> {
1341
+ /** Which profile lever to optimize. Default `'prompt'`. Selects the default
1342
+ * generator + the baseline-surface extraction shape. */
1343
+ surface?: ImproveSurface;
1344
+ /** The `SurfaceProposer` that mutates the surface. When unset, the facade
1345
+ * picks the default for `surface` (`gepaProposer` for prompt, `skillOptProposer`
1346
+ * for skills); surfaces with no default REQUIRE this (fail-loud otherwise). */
1347
+ generator?: SurfaceProposer$1;
1348
+ /** Gate mode. `'holdout'` (default) runs the held-out promotion gate;
1349
+ * `'none'` is a baseline-only run (`budget.generations = 0`). */
1350
+ gate?: 'holdout' | 'none';
1351
+ /** Scenarios to evaluate against. Passthrough to `selfImprove`. */
1352
+ scenarios: TScenario[];
1353
+ /** Judge that scores artifacts. Passthrough to `selfImprove`. */
1354
+ judge: JudgeConfig<TArtifact, TScenario>;
1355
+ /** The agent under improvement — same shape as `selfImprove.agent`: it takes
1356
+ * the current surface + scenario + ctx and returns the artifact to judge. */
1357
+ agent: (surface: MutableSurface, scenario: TScenario, ctx: DispatchContext) => Promise<TArtifact>;
1358
+ /** Budget + loop shape. Passthrough; `gate: 'none'` forces `generations = 0`. */
1359
+ budget?: SelfImproveBudget;
1360
+ /** LLM config. Passthrough to `selfImprove` AND used to construct the default
1361
+ * reflective proposer (`gepaProposer`/`skillOptProposer`) when `generator` is unset. */
1362
+ llm?: SelfImproveLlm;
1363
+ /** Restrict the run to this subset of models. When set, the reflection model
1364
+ * (`llm.model`, or the default when unset) must be a member, or `improve()` throws
1365
+ * a `ConfigError` before the generator is built. Unset = unrestricted. */
1366
+ allowedModels?: readonly string[];
1367
+ }
1368
+ interface ImproveResult<TScenario extends Scenario$1, TArtifact> {
1369
+ /** The profile after improvement: the winner surface applied back into the
1370
+ * matching field when the gate shipped, else the input profile unchanged. */
1371
+ profile: AgentProfile$1;
1372
+ /** True when `gateDecision === 'ship'`. */
1373
+ shipped: boolean;
1374
+ /** Held-out lift (`winner − baseline` composite). */
1375
+ lift: number;
1376
+ /** The five-valued gate verdict from `selfImprove`. */
1377
+ gateDecision: SelfImproveResult<TScenario, TArtifact>['gateDecision'];
1378
+ /** Full `selfImprove` result for advanced inspection. */
1379
+ raw: SelfImproveResult<TScenario, TArtifact>;
1380
+ }
1381
+ /**
1382
+ * Run the held-out-gated self-improvement loop on ONE profile surface.
1383
+ *
1384
+ * @example Optimize the system prompt, default holdout gate:
1385
+ *
1386
+ * const out = await improve(profile, findings, {
1387
+ * surface: 'prompt',
1388
+ * scenarios,
1389
+ * judge,
1390
+ * agent: (surface, scenario, ctx) => runAgent(surface, scenario, ctx.signal),
1391
+ * })
1392
+ * if (out.shipped) deploy(out.profile)
1393
+ */
1394
+ declare function improve<TScenario extends Scenario$1, TArtifact>(profile: AgentProfile$1, findings: unknown[], opts: ImproveOptions<TScenario, TArtifact>): Promise<ImproveResult<TScenario, TArtifact>>;
1395
+
1396
+ /**
1397
+ * `mcpServeVerifier` — the intrinsic verifier for a built MCP server: the
1398
+ * boot-and-probe checker named in docs/artifact-lifecycle-frontier.md. A
1399
+ * generated MCP server is only a candidate if it actually *serves* — so this
1400
+ * boots it over stdio (the default local MCP transport) and runs the real
1401
+ * handshake: `initialize` → `notifications/initialized` → `tools/list`, and
1402
+ * asserts the server answers with at least `minTools` tools.
1403
+ *
1404
+ * Outcomes follow the `Verifier` contract: a server that fails to start, exits
1405
+ * early, errors the handshake, times out, or exposes no tools is a FAILED
1406
+ * candidate (`{ok:false}`, fed back into the next generation shot); a missing
1407
+ * start binary or spawn fault THROWS (a setup bug, never a silent fallback).
1408
+ *
1409
+ * Protocol matches the runtime's own stdio MCP server (src/mcp/server.ts):
1410
+ * newline-delimited JSON-RPC 2.0, protocol version 2024-11-05.
1411
+ */
1412
+
1413
+ interface McpServeSpec {
1414
+ /** Command that starts the built MCP server in the worktree (stdio transport). */
1415
+ command: string;
1416
+ args?: string[];
1417
+ /** Extra env for the server process (merged over `process.env`). */
1418
+ env?: Record<string, string>;
1419
+ /** Handshake timeout (ms). Default 30s. */
1420
+ timeoutMs?: number;
1421
+ /** Minimum tools the server must expose to pass. Default 1. */
1422
+ minTools?: number;
1423
+ }
1424
+ declare function mcpServeVerifier(spec: McpServeSpec): Verifier;
1425
+
1426
+ /**
1427
+ * @experimental
1428
+ *
1429
+ * `reflectiveGenerator` — the cheap, no-sandbox `CandidateGenerator`. It drafts
1430
+ * surface edits via the existing improvement adapter (`proposeFromFindings`,
1431
+ * one LLM patch per finding) and applies them as ONE coherent improvement into
1432
+ * the candidate worktree. `maxShots` is ignored — reflection is single-shot by
1433
+ * construction (the patches are already drafted).
1434
+ *
1435
+ * This is the `shots=1, sandbox=off` setting of the one improvement driver.
1436
+ * The `agenticGenerator` (a multi-shot verify-in-session loop) is the
1437
+ * `shots=N` setting — both plug into the same `improvementDriver`.
1438
+ */
1439
+
1440
+ interface ReflectiveGeneratorOptions {
1441
+ improvementAdapter: ImprovementAdapter<SurfaceImprovementEdit>;
1442
+ }
1443
+ declare function reflectiveGenerator(opts: ReflectiveGeneratorOptions): CandidateGenerator;
1444
+
1106
1445
  /**
1107
1446
  * @stable
1108
1447
  *
@@ -1547,4 +1886,4 @@ interface StreamToolLoopOptions<Raw> {
1547
1886
  * `capped` if it stops for any non-completed reason with calls still pending. */
1548
1887
  declare function streamToolLoop<Raw>(opts: StreamToolLoopOptions<Raw>): AsyncGenerator<StreamToolLoopYield<Raw>, void, unknown>;
1549
1888
 
1550
- export { AgentBackendContext, AgentBackendInput, AgentExecutionBackend, AgentRuntimeEvent, AgentTaskRunResult, AgentTaskStatus, type AuthSource, type BackendCallPolicy, BackendTransportError, type ChatStreamEvent, type ChatTurnHooks, type ChatTurnIdentity, type ChatTurnProducer, type ChatTurnResult, type CircuitBreakerConfig, CircuitBreakerState, CircuitOpenError, type Conversation, type ConversationDriveState, type ConversationJournal, type ConversationJournalEntry, type ConversationParticipant, type ConversationPolicy, type ConversationResult, type ConversationStreamEvent, type ConversationTurn, type D1DatabaseLike, type D1StmtLike, DEFAULT_MAX_DEPTH, DEFAULT_ROUTER_BASE_URL, DeadlineExceededError, FORWARD_HEADERS, FileConversationJournal, type ForwardHeaderName, type HaltContext, type HaltPredicate, type HaltReason, type HaltSignal, InMemoryConversationJournal, InMemoryRuntimeSessionStore, type ModelInfo, OpenAIChatTool, OpenAIChatToolChoice, type PersonaConversationResult, type PersonaDriver, PlannerError, type PropagatedHeaders, type ResolvedChatModel, type RetryBackoff, type RetryableErrorPredicate, type RouterEnv, type RunChatTurnInput, type RunConversationOptions, type RunPersonaConfig, type RunPersonaConversationOptions, type RunToolLoopOptions, type RuntimeEventCollector, RuntimeHooks, RuntimeRunStateError, RuntimeSessionStore, RuntimeStreamEvent, type RuntimeStreamEventCollector, type RuntimeTelemetryOptions, type SanitizedKnowledgeReadinessReport, type SqlAdapter, SqlConversationJournal, type StreamToolLoopOptions, type StreamToolLoopYield, type ToolCallOutcome, type ToolLoopAssistantToolCall, type ToolLoopCall, type ToolLoopEvent, type ToolLoopMessage, type ToolLoopResult, type ToolLoopStopReason, type TurnOrder, applyRunRecordDefaults, buildForwardHeaders, cleanModelId, computeBackoff, createConversationBackend, createIterableBackend, createOpenAICompatibleBackend, createRuntimeEventCollector, createRuntimeStreamEventCollector, createSandboxPromptBackend, d1ToSqlAdapter, decideKnowledgeReadiness, defaultIsRetryable, defineConversation, deriveExecutionId, getModels, handleChatTurn, isDepthExceeded, makePerAttemptSignal, readDepth, readinessServerSentEvent, resolveChatModel, resolveRouterBaseUrl, runAgentTask, runAgentTaskStream, runConversation, runConversationStream, runPersonaConversation, runPersonaDispatch, runToolLoop, runtimeStreamServerSentEvent, sanitizeAgentRuntimeEvent, sanitizeKnowledgeReadinessReport, sanitizeRuntimeStreamEvent, sleep, slugifySpeaker, streamToolLoop, turnId, validateChatModelId };
1889
+ export { AgentBackendContext, AgentBackendInput, AgentExecutionBackend, AgentRuntimeEvent, AgentTaskRunResult, AgentTaskStatus, type AgenticGeneratorOptions, type AuthSource, type BackendCallPolicy, BackendTransportError, type CandidateGenerator, type ChatStreamEvent, type ChatTurnHooks, type ChatTurnIdentity, type ChatTurnProducer, type ChatTurnResult, type CircuitBreakerConfig, CircuitBreakerState, CircuitOpenError, type Conversation, type ConversationDriveState, type ConversationJournal, type ConversationJournalEntry, type ConversationParticipant, type ConversationPolicy, type ConversationResult, type ConversationStreamEvent, type ConversationTurn, type D1DatabaseLike, type D1StmtLike, DEFAULT_MAX_DEPTH, DEFAULT_ROUTER_BASE_URL, DeadlineExceededError, type EvalPersonaOptions, FORWARD_HEADERS, FileConversationJournal, type ForwardHeaderName, type HaltContext, type HaltPredicate, type HaltReason, type HaltSignal, type ImproveOptions, type ImproveResult, type ImproveSurface, type ImprovementDriverOptions, InMemoryConversationJournal, InMemoryRuntimeSessionStore, type McpServeSpec, type ModelInfo, OpenAIChatTool, OpenAIChatToolChoice, type PersonaConversationResult, type PersonaDriver, PlannerError, type PropagatedHeaders, type ReflectiveGeneratorOptions, type ResolvedChatModel, type RetryBackoff, type RetryableErrorPredicate, type RouterEnv, type RunChatTurnInput, type RunConversationOptions, type RunPersonaConfig, type RunPersonaConversationOptions, type RunToolLoopOptions, type RuntimeEventCollector, RuntimeHooks, RuntimeRunStateError, RuntimeSessionStore, RuntimeStreamEvent, type RuntimeStreamEventCollector, type RuntimeTelemetryOptions, type SanitizedKnowledgeReadinessReport, type SqlAdapter, SqlConversationJournal, type StreamToolLoopOptions, type StreamToolLoopYield, type ToolCallOutcome, type ToolLoopAssistantToolCall, type ToolLoopCall, type ToolLoopEvent, type ToolLoopMessage, type ToolLoopResult, type ToolLoopStopReason, type TurnOrder, type Verifier, type VerifyResult, agenticGenerator, applyRunRecordDefaults, buildForwardHeaders, cleanModelId, commandVerifier, computeBackoff, createConversationBackend, createIterableBackend, createOpenAICompatibleBackend, createRuntimeEventCollector, createRuntimeStreamEventCollector, createSandboxPromptBackend, d1ToSqlAdapter, decideKnowledgeReadiness, defaultIsRetryable, defineConversation, deriveExecutionId, evalPersona, getModels, handleChatTurn, improve, improvementDriver, isDepthExceeded, makePerAttemptSignal, mcpBuildPrompt, mcpServeVerifier, readDepth, readinessServerSentEvent, reflectiveGenerator, resolveChatModel, resolveRouterBaseUrl, runAgentTask, runAgentTaskStream, runConversation, runConversationStream, runPersonaConversation, runPersonaDispatch, runToolLoop, runtimeStreamServerSentEvent, sanitizeAgentRuntimeEvent, sanitizeKnowledgeReadinessReport, sanitizeRuntimeStreamEvent, sleep, slugifySpeaker, streamToolLoop, toolBuildPrompt, turnId, validateChatModelId };