@tangle-network/agent-runtime 0.126.0 → 0.131.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 +70 -20
- package/dist/{activation-DhWJ3p8N.js → activation-BCzMOTaV.js} +3 -3
- package/dist/{activation-DhWJ3p8N.js.map → activation-BCzMOTaV.js.map} +1 -1
- package/dist/agent.d.ts +2 -3
- package/dist/agent.js +4 -5
- package/dist/agent.js.map +1 -1
- package/dist/{analyst-loop-DvSciOfB.js → analyst-loop-BE8cDs5Q.js} +2 -2
- package/dist/{analyst-loop-DvSciOfB.js.map → analyst-loop-BE8cDs5Q.js.map} +1 -1
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/analyst-loop.js +1 -1
- package/dist/authoring-CvHwo1oW.js +163 -0
- package/dist/authoring-CvHwo1oW.js.map +1 -0
- package/dist/candidate-execution/index.js +4 -4
- package/dist/{candidate-execution-BFpq-Xi6.js → candidate-execution-BNxKr-Bu.js} +5 -5
- package/dist/{candidate-execution-BFpq-Xi6.js.map → candidate-execution-BNxKr-Bu.js.map} +1 -1
- package/dist/{conversation-BpLQZGPH.js → conversation-DNtxaJ1Z.js} +113 -31
- package/dist/conversation-DNtxaJ1Z.js.map +1 -0
- package/dist/conversation.d.ts +2 -2
- package/dist/conversation.js +2 -2
- package/dist/environment-provider-CxvSd1W6.d.ts +86 -0
- package/dist/{environment-provider-DqFS6FSZ.js → environment-provider-Dyg8DtLK.js} +8 -4
- package/dist/environment-provider-Dyg8DtLK.js.map +1 -0
- package/dist/environment-provider.d.ts +1 -1
- package/dist/environment-provider.js +1 -1
- package/dist/graph-BJTxGOFB.js +471 -0
- package/dist/graph-BJTxGOFB.js.map +1 -0
- package/dist/{improvement-cycle-IJgCbKWQ.js → improvement-cycle-Csp38cWg.js} +133 -224
- package/dist/improvement-cycle-Csp38cWg.js.map +1 -0
- package/dist/{index-EdjCQBV9.d.ts → index-CoO7atyo.d.ts} +640 -1184
- package/dist/{index-DIV33AF5.d.ts → index-DwGtu9nc.d.ts} +7 -9
- package/dist/{index-Efjb3nrQ.d.ts → index-qYHpsmG2.d.ts} +36 -18
- package/dist/index.d.ts +353 -11
- package/dist/index.js +111 -354
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +6 -6
- package/dist/intelligence.js +9 -8
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +7 -5
- package/dist/kernel.js +13 -9
- package/dist/{knowledge-EnuEqm_Y.js → knowledge-ce0_uKCl.js} +19 -17
- package/dist/knowledge-ce0_uKCl.js.map +1 -0
- package/dist/knowledge.d.ts +1 -1
- package/dist/knowledge.js +1 -1
- package/dist/{loop-runner-bin-Bo29_fiD.d.ts → loop-runner-bin-BwgZ8m_7.d.ts} +6 -3
- package/dist/{loop-runner-bin-qwT_4F5I.js → loop-runner-bin-DSbuDDqM.js} +5 -27
- package/dist/loop-runner-bin-DSbuDDqM.js.map +1 -0
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/materialization-COJ1UYQ-.js +272 -0
- package/dist/materialization-COJ1UYQ-.js.map +1 -0
- package/dist/mcp/bin.js +39 -47
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +24 -30
- package/dist/mcp/index.js +66 -83
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/{memory-server-DL6cE2Ag.js → memory-server-5HEJH672.js} +2 -2
- package/dist/{memory-server-DL6cE2Ag.js.map → memory-server-5HEJH672.js.map} +1 -1
- package/dist/model-policy-CqziaqS1.js +232 -0
- package/dist/model-policy-CqziaqS1.js.map +1 -0
- package/dist/{openai-tools-B68JaOCx.d.ts → openai-tools-D3oMyVGl.d.ts} +2 -2
- package/dist/{openai-tools-Bp1KSkP6.js → openai-tools-ru75mLjq.js} +2 -2
- package/dist/openai-tools-ru75mLjq.js.map +1 -0
- package/dist/{prepare--8EvLqCr.js → prepare-DYWjVcPx.js} +169 -153
- package/dist/prepare-DYWjVcPx.js.map +1 -0
- package/dist/primeintellect/index.d.ts +7 -6
- package/dist/primeintellect/index.js +9 -11
- package/dist/primeintellect/index.js.map +1 -1
- package/dist/profiles.d.ts +21 -174
- package/dist/profiles.js +67 -276
- package/dist/profiles.js.map +1 -1
- package/dist/{protected-model-port-CXVfOUu_.js → protected-model-port-48ALLGxT.js} +2 -2
- package/dist/{protected-model-port-CXVfOUu_.js.map → protected-model-port-48ALLGxT.js.map} +1 -1
- package/dist/{redact-PQzmE1Jn.d.ts → redact-9_Gf-8m3.d.ts} +58 -69
- package/dist/{researcher-CoVqNhfI.js → researcher-Skz5-Uc8.js} +50 -26
- package/dist/researcher-Skz5-Uc8.js.map +1 -0
- package/dist/{run-layout-C2FGmZ3v.js → run-layout-CeJsEAom.js} +2 -2
- package/dist/{run-layout-C2FGmZ3v.js.map → run-layout-CeJsEAom.js.map} +1 -1
- package/dist/runtime-D-QfLbSd.d.ts +893 -0
- package/dist/{runtime-BzXz7OjS.js → runtime-hiAABiTk.js} +329 -854
- package/dist/runtime-hiAABiTk.js.map +1 -0
- package/dist/{sandbox-events-Yhd1GYWl.js → sandbox-events-CRDwc5WN.js} +42 -5
- package/dist/sandbox-events-CRDwc5WN.js.map +1 -0
- package/dist/snapshot-CXiiuHhL.js +21 -0
- package/dist/snapshot-CXiiuHhL.js.map +1 -0
- package/dist/{spawn-journal-DsZKDqeh.js → spawn-journal-saHQzqYi.js} +15 -21
- package/dist/spawn-journal-saHQzqYi.js.map +1 -0
- package/dist/stream-agent-turn-C852AgMT.d.ts +128 -0
- package/dist/stream-agent-turn-rYgaOLO0.js +910 -0
- package/dist/stream-agent-turn-rYgaOLO0.js.map +1 -0
- package/dist/{structural-rollout-zY0oqQzO.js → structural-rollout-3uxVGcg2.js} +459 -235
- package/dist/structural-rollout-3uxVGcg2.js.map +1 -0
- package/dist/{supervise-Ds8FtyI9.js → supervise-iPN27pO0.js} +932 -4771
- package/dist/supervise-iPN27pO0.js.map +1 -0
- package/dist/{supervisor-DpjO0Gmy.js → supervisor-CV6Jh28D.js} +7439 -2897
- package/dist/supervisor-CV6Jh28D.js.map +1 -0
- package/dist/testing.d.ts +3 -1
- package/dist/testing.js +271 -221
- package/dist/testing.js.map +1 -1
- package/dist/{top-app-5unxqovu.js → top-app-G4M18b6i.js} +3 -3
- package/dist/{top-app-5unxqovu.js.map → top-app-G4M18b6i.js.map} +1 -1
- package/dist/tui/bin.js +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{environment-provider-PM9PeW_J.d.ts → types-C6Q-J0Dt.d.ts} +57 -114
- package/dist/{types-DnNGJ5Gz.d.ts → types-ebIY0dMG.d.ts} +556 -30
- package/dist/{util-MVgdwuIS.js → util-Bw6srryQ.js} +3 -2
- package/dist/{util-MVgdwuIS.js.map → util-Bw6srryQ.js.map} +1 -1
- package/dist/{workspace-archive-BQxvkypI.js → workspace-archive-aOfJ47ms.js} +3 -3
- package/dist/{workspace-archive-BQxvkypI.js.map → workspace-archive-aOfJ47ms.js.map} +1 -1
- package/package.json +12 -15
- package/skills/agent-graphs/IMPROVE.md +58 -0
- package/skills/agent-graphs/SKILL.md +139 -0
- package/skills/agent-graphs/cases/artifact-mission-release-notes.json +10 -0
- package/skills/agent-graphs/cases/audited-single-writer.json +9 -0
- package/skills/agent-graphs/cases/cap-as-stop-mistake.json +8 -0
- package/skills/agent-graphs/cases/mission-in-deliverable.json +8 -0
- package/skills/agent-graphs/cases/review-pipeline.json +13 -0
- package/skills/agent-graphs/cases/runtime-discovered-fanout.json +8 -0
- package/skills/agent-graphs/cases/single-agent-suffices.json +7 -0
- package/skills/agent-graphs/cases/steer-heavy-drafting.json +9 -0
- package/skills/agent-graphs/cases/unmeasured-harness.json +7 -0
- package/skills/agent-graphs/generations/gen1-baseline.json +248 -0
- package/skills/agent-graphs/generations/gen2.json +375 -0
- package/skills/agent-graphs/generations/gen3.json +702 -0
- package/skills/build-with-agent-runtime/SKILL.md +1 -0
- package/dist/backends-CiOCyRHb.js +0 -743
- package/dist/backends-CiOCyRHb.js.map +0 -1
- package/dist/conversation-BpLQZGPH.js.map +0 -1
- package/dist/environment-provider-DqFS6FSZ.js.map +0 -1
- package/dist/improvement-cycle-IJgCbKWQ.js.map +0 -1
- package/dist/index-D_M4d1_B.d.ts +0 -545
- package/dist/knowledge-EnuEqm_Y.js.map +0 -1
- package/dist/local-harness-BIajef4A.d.ts +0 -465
- package/dist/loop-runner-bin-qwT_4F5I.js.map +0 -1
- package/dist/model-resolution-Btd9iIKV.js +0 -98
- package/dist/model-resolution-Btd9iIKV.js.map +0 -1
- package/dist/openai-tools-Bp1KSkP6.js.map +0 -1
- package/dist/prepare--8EvLqCr.js.map +0 -1
- package/dist/researcher-CoVqNhfI.js.map +0 -1
- package/dist/runtime-BzXz7OjS.js.map +0 -1
- package/dist/sandbox-events-Yhd1GYWl.js.map +0 -1
- package/dist/spawn-journal-DsZKDqeh.js.map +0 -1
- package/dist/structural-rollout-zY0oqQzO.js.map +0 -1
- package/dist/supervise-Ds8FtyI9.js.map +0 -1
- package/dist/supervisor-DpjO0Gmy.js.map +0 -1
- package/dist/types-C9j4qg6l.d.ts +0 -500
package/dist/index.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import { a as JudgeError, c as RuntimeRunStateError, i as ConfigError, o as NotFoundError, r as BackendTransportError, s as PlannerError, t as AgentEvalError, u as ValidationError } from "./errors-DEAvWQPy.js";
|
|
2
|
-
import { a as
|
|
3
|
-
import { $ as parseExactAgentProfile, G as agentCandidateProfileAsAgentProfile, K as applyExactAgentProfileDiff, S as CANDIDATE_TRACE_TAGS,
|
|
4
|
-
import { i as sealAgentCandidateBundle, n as captureAgentCandidateWorkspaceFiles, r as createAgentCandidateWorkspacePort, t as captureAgentCandidateWorkspace } from "./workspace-archive-
|
|
5
|
-
import { i as buildAgentCandidateBundle, n as disposePreparedAgentCandidateExecution, r as FileAgentCandidateExecutionClaimStore, t as recoverExpiredAgentCandidateExecution } from "./candidate-execution-
|
|
6
|
-
import { n as exactProcessProviderAsCandidateExecutor, t as createProtectedAgentCandidateModelPort } from "./protected-model-port-
|
|
7
|
-
import { C as makePerAttemptSignal, S as defaultIsRetryable, _ as readDepth, a as FileConversationJournal, b as DeadlineExceededError, c as createConversationBackend, d as slugifySpeaker, f as turnId, g as isDepthExceeded, h as buildForwardHeaders, i as d1ToSqlAdapter, l as runConversation, m as FORWARD_HEADERS, n as runPersonaDispatch, o as InMemoryConversationJournal, p as DEFAULT_MAX_DEPTH, r as SqlConversationJournal, s as defineConversation, t as runPersonaConversation, u as runConversationStream, v as CircuitBreakerState, w as sleep, x as computeBackoff, y as CircuitOpenError } from "./conversation-
|
|
8
|
-
import {
|
|
9
|
-
import { D as researchDriverNote, E as optimizerMethod, O as strategyAuthorMethod, T as buildDriverSystem } from "./structural-rollout-zY0oqQzO.js";
|
|
10
|
-
import { A as improve, B as agenticGenerator, F as normalizeRolloutPolicy, G as summarizeFindings, H as defaultBuildPrompt, I as parseRolloutPolicy, K as worktreeChangedPaths, L as serializeRolloutPolicy, M as rawTraceDistiller, N as ROLLOUT_POLICY_EXTENSION, P as applyRolloutPolicyToProfile, R as structuralRolloutPolicyFromProfile, U as rawTraceEvidenceProblem, V as commandVerifier, W as requiresRawTraceEvidence, j as withMethodRuntimeControls, z as AGENTIC_PROFILE_RESOURCE_ROOT } from "./improvement-cycle-IJgCbKWQ.js";
|
|
2
|
+
import { a as normalizeBackendStreamEvent, c as nowIso, i as createSandboxPromptBackend, l as startOrResumeRuntimeSession, o as InMemoryRuntimeSessionStore, r as createIterableBackend, u as touchSession } from "./stream-agent-turn-rYgaOLO0.js";
|
|
3
|
+
import { $ as parseExactAgentProfile, G as agentCandidateProfileAsAgentProfile, K as applyExactAgentProfileDiff, S as CANDIDATE_TRACE_TAGS, Y as freezeGenericAgentCandidateProfile, Z as omitUndefinedObjectFields, _ as candidateExecutionClaim, a as persistCandidateOutputArtifact, c as CANDIDATE_KNOWLEDGE_ROOT_ENV, et as parseExactAgentProfileDiff, f as verifyAgentCandidateBundle, h as InMemoryAgentCandidateExecutionClaimStore, l as candidateKnowledgeExecutionPaths, n as executePreparedAgentCandidate, q as assertCandidateProfileBinding, rt as canonicalCandidateDigest, s as CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV, t as prepareAgentCandidateExecution, tt as parseExactCandidateProfile, u as AGENT_CANDIDATE_EXECUTION_SUPPORT, x as CANDIDATE_TRACE_ENV } from "./prepare-DYWjVcPx.js";
|
|
4
|
+
import { i as sealAgentCandidateBundle, n as captureAgentCandidateWorkspaceFiles, r as createAgentCandidateWorkspacePort, t as captureAgentCandidateWorkspace } from "./workspace-archive-aOfJ47ms.js";
|
|
5
|
+
import { i as buildAgentCandidateBundle, n as disposePreparedAgentCandidateExecution, r as FileAgentCandidateExecutionClaimStore, t as recoverExpiredAgentCandidateExecution } from "./candidate-execution-BNxKr-Bu.js";
|
|
6
|
+
import { n as exactProcessProviderAsCandidateExecutor, t as createProtectedAgentCandidateModelPort } from "./protected-model-port-48ALLGxT.js";
|
|
7
|
+
import { C as makePerAttemptSignal, S as defaultIsRetryable, T as createProfileExecutionBackend, _ as readDepth, a as FileConversationJournal, b as DeadlineExceededError, c as createConversationBackend, d as slugifySpeaker, f as turnId, g as isDepthExceeded, h as buildForwardHeaders, i as d1ToSqlAdapter, l as runConversation, m as FORWARD_HEADERS, n as runPersonaDispatch, o as InMemoryConversationJournal, p as DEFAULT_MAX_DEPTH, r as SqlConversationJournal, s as defineConversation, t as runPersonaConversation, u as runConversationStream, v as CircuitBreakerState, w as sleep, x as computeBackoff, y as CircuitOpenError } from "./conversation-DNtxaJ1Z.js";
|
|
8
|
+
import { Ct as sanitizeAgentRuntimeEvent, St as createRuntimeStreamEventCollector, Tt as sanitizeRuntimeStreamEvent, _t as loopEventToOtelSpan, bt as toOtelAttributes, ct as INTELLIGENCE_WIRE_VERSION, dt as buildRuntimeEventOtelSpans, ft as createOpenInferenceFileExporter, gt as generateSpanId, lt as buildLoopOtelSpans, mt as exportEvalRuns, pt as createOtelExporter, ut as buildLoopSpanNodes, vt as padSpanId, wt as sanitizeKnowledgeReadinessReport, xt as createRuntimeEventCollector, yt as padTraceId } from "./supervisor-CV6Jh28D.js";
|
|
11
9
|
import { i as notifyRuntimeHookEvent, n as defineRuntimeHooks, r as notifyRuntimeDecisionPoint, t as composeRuntimeHooks } from "./runtime-hooks-C7iJOWm3.js";
|
|
12
|
-
import {
|
|
10
|
+
import { D as optimizerMethod, O as strategyAuthorMethod } from "./structural-rollout-3uxVGcg2.js";
|
|
11
|
+
import { A as improve, B as commandVerifier, F as normalizeRolloutPolicy, I as parseRolloutPolicy, L as serializeRolloutPolicy, M as rawTraceDistiller, N as ROLLOUT_POLICY_EXTENSION, P as applyRolloutPolicyToProfile, R as structuralRolloutPolicyFromProfile, V as defaultBuildPrompt, j as withMethodRuntimeControls, z as agenticGenerator } from "./improvement-cycle-Csp38cWg.js";
|
|
12
|
+
import { Dt as McpSpawnFault, Ot as connectStdioMcp } from "./runtime-hiAABiTk.js";
|
|
13
13
|
import { n as defaultRedactorIdentityMaterial, r as resolveRedactor, t as defaultRedactor } from "./redact-D-u-rrcn.js";
|
|
14
|
-
import { a as createSupervisedKnowledgeUpdater, c as runSupervisedKnowledgeUpdate, i as RESEARCH_SUPERVISOR_SYSTEM_PROMPT, l as createKnowledgeImprovementActivationExecutor, n as createAgentKnowledgeReadinessCheck, o as formatSupervisedKnowledgeTask, r as runKnowledgeImprovementJob, s as knowledgeReadinessDeliverable, t as buildKnowledgeImprovementExperimentBundles } from "./knowledge-
|
|
15
|
-
import { a as isDelegatedLoopMode, c as worktreeLoopRunner, i as auditLoopRunner, n as runLoopRunnerCli, o as researchLoopRunner, r as DELEGATED_LOOP_MODES, s as runDelegatedLoop, t as parseLoopRunnerArgv } from "./loop-runner-bin-
|
|
16
|
-
import { n as mcpToolsForRuntimeMcpSubset, t as mcpToolsForRuntimeMcp } from "./openai-tools-
|
|
17
|
-
import { a as resolveRouterBaseUrl, i as resolveChatModel, n as cleanModelId, o as validateChatModelId, r as getModels, t as DEFAULT_ROUTER_BASE_URL } from "./model-resolution-Btd9iIKV.js";
|
|
14
|
+
import { a as createSupervisedKnowledgeUpdater, c as runSupervisedKnowledgeUpdate, i as RESEARCH_SUPERVISOR_SYSTEM_PROMPT, l as createKnowledgeImprovementActivationExecutor, n as createAgentKnowledgeReadinessCheck, o as formatSupervisedKnowledgeTask, r as runKnowledgeImprovementJob, s as knowledgeReadinessDeliverable, t as buildKnowledgeImprovementExperimentBundles } from "./knowledge-ce0_uKCl.js";
|
|
15
|
+
import { a as isDelegatedLoopMode, c as worktreeLoopRunner, i as auditLoopRunner, n as runLoopRunnerCli, o as researchLoopRunner, r as DELEGATED_LOOP_MODES, s as runDelegatedLoop, t as parseLoopRunnerArgv } from "./loop-runner-bin-DSbuDDqM.js";
|
|
16
|
+
import { n as mcpToolsForRuntimeMcpSubset, t as mcpToolsForRuntimeMcp } from "./openai-tools-ru75mLjq.js";
|
|
18
17
|
import { FAILURE_CLASSES, acquisitionPlansForKnowledgeGaps, blockingKnowledgeEval, canonicalJson, runAgentControlLoop, scoreKnowledgeReadiness, userQuestionsForKnowledgeGaps } from "@tangle-network/agent-eval";
|
|
19
18
|
import { gepaOptimizationMethod, skillOptOptimizationMethod } from "@tangle-network/agent-eval/campaign";
|
|
20
|
-
import { readFileSync, statSync } from "node:fs";
|
|
21
|
-
import { resolve, sep } from "node:path";
|
|
22
19
|
import { spawnSync } from "node:child_process";
|
|
23
20
|
import { isDeepStrictEqual } from "node:util";
|
|
24
21
|
//#region src/improvement/build-prompts.ts
|
|
@@ -89,277 +86,6 @@ function mcpBuildPrompt(args) {
|
|
|
89
86
|
].join("\n");
|
|
90
87
|
}
|
|
91
88
|
//#endregion
|
|
92
|
-
//#region src/improvement/driver-loop-generator.ts
|
|
93
|
-
/**
|
|
94
|
-
* `driverLoopGenerator` — the driver→worker `CandidateGenerator`: the build
|
|
95
|
-
* loop run by the ATOM instead of the canned respawn.
|
|
96
|
-
*
|
|
97
|
-
* `agenticGenerator` steers with three hardcoded conditions picking a canned
|
|
98
|
-
* note (`EMPTY_TREE_NOTE` / `failureNote`) and respawns. This generator swaps
|
|
99
|
-
* that respawn brain for a real driver: an LLM on the canonical tool-loop seam
|
|
100
|
-
* (`runBrainLoop` + `ToolLoopChat` — the exact loop `driverAgent` runs its
|
|
101
|
-
* brain on) that AUTHORS each worker instruction, OBSERVES what the session
|
|
102
|
-
* actually produced (diff, files, verifier output), RATES it, and DECIDES
|
|
103
|
-
* refine / re-scope / decompose — prompted with the senior scientific-method
|
|
104
|
-
* doctrine (`buildDriverSystem`).
|
|
105
|
-
*
|
|
106
|
-
* The worker stays the proven primitive: `runLocalHarness` in the candidate
|
|
107
|
-
* worktree, same as `agenticGenerator` — only the brain between sessions
|
|
108
|
-
* changes. The worktree machinery (`worktreeBuildCandidate`) and verifiers
|
|
109
|
-
* (`commandVerifier` / `mcpServeVerifier`) are reused verbatim.
|
|
110
|
-
*
|
|
111
|
-
* Completion-oracle invariant (the supervisor doctrine, kept): the driver's
|
|
112
|
-
* prose NEVER decides the outcome. After the loop, code re-checks ground
|
|
113
|
-
* truth — tree dirty, raw-trace evidence present, verifier green — and only
|
|
114
|
-
* that decides `applied`. A driver that claims success over a failing verifier
|
|
115
|
-
* produces a discarded candidate, not a shipped one.
|
|
116
|
-
*
|
|
117
|
-
* @experimental
|
|
118
|
-
*/
|
|
119
|
-
const workerOutputTailChars = 2e3;
|
|
120
|
-
const diffMaxChars = 6e3;
|
|
121
|
-
const readFileDefaultBytes = 8192;
|
|
122
|
-
const researchResultMaxChars = 8e3;
|
|
123
|
-
/** Driver→worker `CandidateGenerator`: an LLM driver on the canonical tool-loop authors, observes, rates, and steers coding-harness sessions in the worktree until the verifier passes or the session budget is spent. */
|
|
124
|
-
function driverLoopGenerator(opts) {
|
|
125
|
-
const harness = opts.harness ?? "claude-code";
|
|
126
|
-
const buildPrompt = opts.buildPrompt ?? defaultBuildPrompt;
|
|
127
|
-
const run = opts.runHarness ?? runLocalHarness;
|
|
128
|
-
const changed = opts.changedPaths ?? worktreeChangedPaths;
|
|
129
|
-
const readDiff = opts.readDiff ?? worktreeDiff;
|
|
130
|
-
const verify = opts.verify;
|
|
131
|
-
return {
|
|
132
|
-
kind: `driver-loop:${harness}`,
|
|
133
|
-
async generate({ worktreePath, findings, maxShots, signal }) {
|
|
134
|
-
signal.throwIfAborted();
|
|
135
|
-
const briefing = buildPrompt({ findings });
|
|
136
|
-
const needsRawTraceEvidence = requiresRawTraceEvidence(findings);
|
|
137
|
-
const sessionCap = Math.max(1, maxShots);
|
|
138
|
-
let sessionsUsed = 0;
|
|
139
|
-
const groundVerify = async () => {
|
|
140
|
-
signal.throwIfAborted();
|
|
141
|
-
if (changed(worktreePath).length === 0) return {
|
|
142
|
-
ok: false,
|
|
143
|
-
feedback: "the working tree has no changes — nothing to verify"
|
|
144
|
-
};
|
|
145
|
-
if (needsRawTraceEvidence) {
|
|
146
|
-
const problem = rawTraceEvidenceProblem(worktreePath, findings);
|
|
147
|
-
if (problem) return {
|
|
148
|
-
ok: false,
|
|
149
|
-
feedback: problem
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
if (!verify) return {
|
|
153
|
-
ok: true,
|
|
154
|
-
feedback: "no verifier configured: a dirty tree is the candidate"
|
|
155
|
-
};
|
|
156
|
-
const result = await verify(worktreePath, signal);
|
|
157
|
-
signal.throwIfAborted();
|
|
158
|
-
return result;
|
|
159
|
-
};
|
|
160
|
-
const execute = async (name, args) => {
|
|
161
|
-
signal.throwIfAborted();
|
|
162
|
-
switch (name) {
|
|
163
|
-
case "run_worker": {
|
|
164
|
-
const instruction = typeof args.instruction === "string" ? args.instruction.trim() : "";
|
|
165
|
-
if (instruction.length === 0) return "error: run_worker requires a non-empty `instruction`";
|
|
166
|
-
if (sessionsUsed >= sessionCap) return `error: worker-session budget exhausted (${sessionsUsed}/${sessionCap} used). Inspect and verify what exists, then stop with your final assessment.`;
|
|
167
|
-
sessionsUsed += 1;
|
|
168
|
-
const result = await run({
|
|
169
|
-
harness,
|
|
170
|
-
cwd: worktreePath,
|
|
171
|
-
taskPrompt: instruction,
|
|
172
|
-
...opts.timeoutMs !== void 0 ? { timeoutMs: opts.timeoutMs } : {},
|
|
173
|
-
signal
|
|
174
|
-
});
|
|
175
|
-
signal.throwIfAborted();
|
|
176
|
-
if (result.aborted) throw new Error("driverLoopGenerator: worker session was cancelled by the caller");
|
|
177
|
-
return JSON.stringify({
|
|
178
|
-
session: `${sessionsUsed}/${sessionCap}`,
|
|
179
|
-
exitCode: result.exitCode,
|
|
180
|
-
timedOut: result.timedOut,
|
|
181
|
-
aborted: result.aborted ?? false,
|
|
182
|
-
killedBySignal: result.killedBySignal,
|
|
183
|
-
durationMs: result.durationMs,
|
|
184
|
-
changedPaths: changed(worktreePath),
|
|
185
|
-
stdoutTail: tail(result.stdout, workerOutputTailChars),
|
|
186
|
-
stderrTail: tail(result.stderr, workerOutputTailChars)
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
case "inspect_worktree": {
|
|
190
|
-
const paths = changed(worktreePath);
|
|
191
|
-
const diff = truncate(readDiff(worktreePath), diffMaxChars);
|
|
192
|
-
return JSON.stringify({
|
|
193
|
-
changedPaths: paths,
|
|
194
|
-
diff: diff.length > 0 ? diff : "(no tracked-file diff — new files are untracked; read_file them)"
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
case "read_file": return readWorktreeFile(worktreePath, args);
|
|
198
|
-
case "research": {
|
|
199
|
-
if (!opts.research) return "error: research tool is not provisioned in this run";
|
|
200
|
-
const query = typeof args.query === "string" ? args.query.trim() : "";
|
|
201
|
-
if (query.length === 0) return "error: research requires a non-empty `query`";
|
|
202
|
-
const result = await opts.research(query);
|
|
203
|
-
signal.throwIfAborted();
|
|
204
|
-
return truncate(result, researchResultMaxChars);
|
|
205
|
-
}
|
|
206
|
-
case "run_verifier": {
|
|
207
|
-
const result = await groundVerify();
|
|
208
|
-
return JSON.stringify({
|
|
209
|
-
ok: result.ok,
|
|
210
|
-
feedback: truncate(result.feedback ?? "", 4e3)
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
default: return `error: unknown tool: ${name}`;
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
await runBrainLoop({
|
|
217
|
-
chat: opts.brain,
|
|
218
|
-
tools: opts.research ? [...driverToolSpecs, researchToolSpec] : driverToolSpecs,
|
|
219
|
-
execute,
|
|
220
|
-
initialMessages: [{
|
|
221
|
-
role: "system",
|
|
222
|
-
content: opts.research ? `${buildDriverSystem}\n\n${researchDriverNote}` : buildDriverSystem
|
|
223
|
-
}, {
|
|
224
|
-
role: "user",
|
|
225
|
-
content: [
|
|
226
|
-
`THE BUILD BRIEF (the contract your workers must satisfy — fold what each needs into its instruction; workers never see this brief):`,
|
|
227
|
-
"",
|
|
228
|
-
briefing,
|
|
229
|
-
"",
|
|
230
|
-
`Worker-session budget: ${sessionCap}. The worktree is a fresh checkout at ${worktreePath}.`
|
|
231
|
-
].join("\n")
|
|
232
|
-
}],
|
|
233
|
-
maxTurns: opts.maxTurns ?? Math.max(8, 2 + sessionCap * 3),
|
|
234
|
-
hooks: { stopBefore: () => signal.aborted }
|
|
235
|
-
});
|
|
236
|
-
signal.throwIfAborted();
|
|
237
|
-
const verdict = await groundVerify();
|
|
238
|
-
signal.throwIfAborted();
|
|
239
|
-
if (!verdict.ok) return {
|
|
240
|
-
applied: false,
|
|
241
|
-
summary: ""
|
|
242
|
-
};
|
|
243
|
-
return {
|
|
244
|
-
applied: true,
|
|
245
|
-
summary: summarizeFindings(findings)
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
const driverToolSpecs = [
|
|
251
|
-
{
|
|
252
|
-
type: "function",
|
|
253
|
-
function: {
|
|
254
|
-
name: "run_worker",
|
|
255
|
-
description: "Run ONE coding-harness session in the worktree with your instruction as its entire goal. The worktree persists between sessions. Sessions are capped — author each instruction richly (outcome, context, placement, the check it is held to).",
|
|
256
|
-
parameters: {
|
|
257
|
-
type: "object",
|
|
258
|
-
properties: { instruction: {
|
|
259
|
-
type: "string",
|
|
260
|
-
description: "The complete, self-contained goal for this worker session."
|
|
261
|
-
} },
|
|
262
|
-
required: ["instruction"]
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
type: "function",
|
|
268
|
-
function: {
|
|
269
|
-
name: "inspect_worktree",
|
|
270
|
-
description: "Current git state of the worktree: changed paths + the tracked-file diff (truncated). New untracked files show in changedPaths only — read_file them.",
|
|
271
|
-
parameters: {
|
|
272
|
-
type: "object",
|
|
273
|
-
properties: {}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
type: "function",
|
|
279
|
-
function: {
|
|
280
|
-
name: "read_file",
|
|
281
|
-
description: "Read one file from the worktree (paths are worktree-relative).",
|
|
282
|
-
parameters: {
|
|
283
|
-
type: "object",
|
|
284
|
-
properties: {
|
|
285
|
-
path: {
|
|
286
|
-
type: "string",
|
|
287
|
-
description: "Worktree-relative file path."
|
|
288
|
-
},
|
|
289
|
-
maxBytes: {
|
|
290
|
-
type: "number",
|
|
291
|
-
description: "Byte cap (default 8192)."
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
required: ["path"]
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
type: "function",
|
|
300
|
-
function: {
|
|
301
|
-
name: "run_verifier",
|
|
302
|
-
description: "Run the intrinsic check of the surface (compile+tests / boot-and-probe). Its result — not your judgment — decides whether the candidate is kept.",
|
|
303
|
-
parameters: {
|
|
304
|
-
type: "object",
|
|
305
|
-
properties: {}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
];
|
|
310
|
-
/** Only offered when `opts.research` is wired — a tool the driver cannot call
|
|
311
|
-
* must never appear in its tool list. */
|
|
312
|
-
const researchToolSpec = {
|
|
313
|
-
type: "function",
|
|
314
|
-
function: {
|
|
315
|
-
name: "research",
|
|
316
|
-
description: "Search external sources (MCP registries, vendor docs) for an EXISTING server that closes the capability gap — the adopt-not-build check. Returns text findings.",
|
|
317
|
-
parameters: {
|
|
318
|
-
type: "object",
|
|
319
|
-
properties: { query: {
|
|
320
|
-
type: "string",
|
|
321
|
-
description: "What capability / server to search for."
|
|
322
|
-
} },
|
|
323
|
-
required: ["query"]
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
};
|
|
327
|
-
/** `git diff` over the worktree (tracked files). Fails loud like `worktreeChangedPaths` — a git
|
|
328
|
-
* fault on a fresh checkout is a broken setup, not an empty diff. */
|
|
329
|
-
function worktreeDiff(worktreePath) {
|
|
330
|
-
const result = spawnSync("git", ["diff"], {
|
|
331
|
-
cwd: worktreePath,
|
|
332
|
-
encoding: "utf-8"
|
|
333
|
-
});
|
|
334
|
-
if (result.error) throw new Error(`driverLoopGenerator: git diff failed to spawn in ${worktreePath}: ${result.error.message}`);
|
|
335
|
-
if (result.status !== 0) throw new Error(`driverLoopGenerator: git diff exited ${result.status} in ${worktreePath}: ${result.stderr.trim()}`);
|
|
336
|
-
return result.stdout;
|
|
337
|
-
}
|
|
338
|
-
/** Bounded, worktree-jailed file read for the driver's `read_file`. A path escaping the worktree
|
|
339
|
-
* is refused (the driver only rates work in the candidate tree; it has no business elsewhere). */
|
|
340
|
-
function readWorktreeFile(worktreePath, args) {
|
|
341
|
-
const rel = typeof args.path === "string" ? args.path : "";
|
|
342
|
-
if (rel.length === 0) return "error: read_file requires `path`";
|
|
343
|
-
const root = resolve(worktreePath);
|
|
344
|
-
const target = resolve(root, rel);
|
|
345
|
-
if (target !== root && !target.startsWith(root + sep)) return `error: path escapes the worktree: ${rel}`;
|
|
346
|
-
const maxBytes = typeof args.maxBytes === "number" && args.maxBytes > 0 ? Math.min(args.maxBytes, 65536) : readFileDefaultBytes;
|
|
347
|
-
try {
|
|
348
|
-
const size = statSync(target).size;
|
|
349
|
-
const body = readFileSync(target, "utf-8").slice(0, maxBytes);
|
|
350
|
-
return size > maxBytes ? `${body}\n… (${size - maxBytes} bytes truncated)` : body;
|
|
351
|
-
} catch (e) {
|
|
352
|
-
return `error: ${e instanceof Error ? e.message : String(e)}`;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
function tail(s, n) {
|
|
356
|
-
const trimmed = s.trim();
|
|
357
|
-
return trimmed.length <= n ? trimmed : `…${trimmed.slice(-n)}`;
|
|
358
|
-
}
|
|
359
|
-
function truncate(s, n) {
|
|
360
|
-
return s.length <= n ? s : `${s.slice(0, n - 1)}…`;
|
|
361
|
-
}
|
|
362
|
-
//#endregion
|
|
363
89
|
//#region src/improvement/mcp-serve-verifier.ts
|
|
364
90
|
/**
|
|
365
91
|
* `mcpServeVerifier` — the intrinsic verifier for a built MCP server: the
|
|
@@ -414,7 +140,7 @@ function mcpServeVerifier(spec) {
|
|
|
414
140
|
//#region src/improvement/official-optimizers.ts
|
|
415
141
|
const defaultMaxFindingsChars = 5e4;
|
|
416
142
|
const pythonClientDocs = "https://github.com/tangle-network/agent-eval/tree/main/clients/python";
|
|
417
|
-
const bridgeInstall = "`python -m pip install \"agent-eval-rpc==0.
|
|
143
|
+
const bridgeInstall = "`python -m pip install \"agent-eval-rpc==0.144.6\"`";
|
|
418
144
|
const gepaWheelInstall = "`python -m pip install \"gepa[full]==0.1.4\"`";
|
|
419
145
|
const gepaSourceInstall = "`python -m pip install \"gepa[full] @ git+https://github.com/gepa-ai/gepa.git@f919db0a622e2e9f9204779b81fe00cc1b2d808f\"`";
|
|
420
146
|
const skillOptInstall = `${bridgeInstall}, then \`python -m pip install "skillopt @ git+https://github.com/microsoft/SkillOpt.git@61735e3922efc2b90c6d6cab561e62e98452ca90"\``;
|
|
@@ -687,7 +413,7 @@ function isMissingDependency(optimizer, cause) {
|
|
|
687
413
|
* This is the `shots=1, sandbox=off` code-candidate setting.
|
|
688
414
|
* `agenticGenerator` supplies the multi-shot verify-in-session setting.
|
|
689
415
|
*
|
|
690
|
-
* @
|
|
416
|
+
* @stable
|
|
691
417
|
*/
|
|
692
418
|
/** Cheap no-sandbox `CandidateGenerator` (the `shots=1` setting): draft surface edits via the improvement adapter and apply them as one coherent candidate. */
|
|
693
419
|
function reflectiveGenerator(opts) {
|
|
@@ -727,6 +453,101 @@ function applyPatch(patch, cwd) {
|
|
|
727
453
|
}).status === 0;
|
|
728
454
|
}
|
|
729
455
|
//#endregion
|
|
456
|
+
//#region src/model-resolution.ts
|
|
457
|
+
/** Default Tangle Router base URL used when no env override is set. */
|
|
458
|
+
const DEFAULT_ROUTER_BASE_URL = "https://router.tangle.tools";
|
|
459
|
+
/** Resolve the router base URL from env, normalised — no trailing `/v1` or `/`. */
|
|
460
|
+
function resolveRouterBaseUrl(env = {}) {
|
|
461
|
+
return (env.TANGLE_ROUTER_URL ?? env.TANGLE_ROUTER_BASE_URL ?? "https://router.tangle.tools").replace(/\/v1\/?$/, "").replace(/\/$/, "");
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Fetch the model catalog from the router's `/v1/models`. Throws on a non-2xx
|
|
465
|
+
* response — callers decide whether to fail open (empty catalog) or closed.
|
|
466
|
+
*/
|
|
467
|
+
async function getModels(routerBaseUrl = DEFAULT_ROUTER_BASE_URL) {
|
|
468
|
+
const res = await fetch(`${routerBaseUrl}/v1/models`, { headers: { Accept: "application/json" } });
|
|
469
|
+
if (!res.ok) throw new Error(`router /v1/models ${res.status}`);
|
|
470
|
+
const body = await res.json();
|
|
471
|
+
return Array.isArray(body.data) ? body.data : [];
|
|
472
|
+
}
|
|
473
|
+
/** Trim a candidate model id; `undefined` for non-strings and blanks. */
|
|
474
|
+
function cleanModelId(value) {
|
|
475
|
+
if (typeof value !== "string") return void 0;
|
|
476
|
+
const trimmed = value.trim();
|
|
477
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Resolve a chat model by precedence: the first candidate carrying a
|
|
481
|
+
* non-blank model wins, else `fallback`. The caller owns the precedence
|
|
482
|
+
* order, so each product keeps its own policy (request → workspace → env,
|
|
483
|
+
* etc.) while the first-non-blank logic and the telemetry shape stay shared.
|
|
484
|
+
*/
|
|
485
|
+
function resolveChatModel(candidates, fallback) {
|
|
486
|
+
for (const candidate of candidates) {
|
|
487
|
+
const model = cleanModelId(candidate.model);
|
|
488
|
+
if (model) return {
|
|
489
|
+
source: candidate.source,
|
|
490
|
+
model
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
return fallback;
|
|
494
|
+
}
|
|
495
|
+
const WELL_FORMED_MODEL_ID = /^[A-Za-z0-9._/@:-]+$/;
|
|
496
|
+
function isWellFormedModelId(modelId) {
|
|
497
|
+
return modelId.length <= 200 && WELL_FORMED_MODEL_ID.test(modelId);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Every id a catalog entry can be addressed by — its bare id, plus a
|
|
501
|
+
* `provider/id` form when the router exposes a separate provider slug.
|
|
502
|
+
*/
|
|
503
|
+
function catalogIdsForModel(model) {
|
|
504
|
+
const ids = /* @__PURE__ */ new Set();
|
|
505
|
+
const id = cleanModelId(model.id);
|
|
506
|
+
if (id) ids.add(id);
|
|
507
|
+
const provider = cleanModelId(model._provider) ?? cleanModelId(model.provider);
|
|
508
|
+
if (provider && id && !id.includes("/")) ids.add(`${provider}/${id}`);
|
|
509
|
+
return [...ids];
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Validate a caller-supplied chat-model id. Rejects non-strings, malformed
|
|
513
|
+
* ids, and ids absent from both the caller's `allowlist` and the live router
|
|
514
|
+
* catalog. Fails closed: when the catalog cannot be fetched, an unverifiable
|
|
515
|
+
* id is rejected rather than admitted — a bad model never reaches the agent.
|
|
516
|
+
*/
|
|
517
|
+
async function validateChatModelId(modelId, options = {}) {
|
|
518
|
+
const { allowlist = [], routerBaseUrl = DEFAULT_ROUTER_BASE_URL, loadModels = getModels } = options;
|
|
519
|
+
const cleaned = cleanModelId(modelId);
|
|
520
|
+
if (!cleaned) return {
|
|
521
|
+
succeeded: false,
|
|
522
|
+
error: "Model id must be a non-empty string."
|
|
523
|
+
};
|
|
524
|
+
if (!isWellFormedModelId(cleaned)) return {
|
|
525
|
+
succeeded: false,
|
|
526
|
+
error: `Model id is malformed: ${cleaned}`
|
|
527
|
+
};
|
|
528
|
+
if (allowlist.some((id) => cleanModelId(id) === cleaned)) return {
|
|
529
|
+
succeeded: true,
|
|
530
|
+
value: cleaned
|
|
531
|
+
};
|
|
532
|
+
let catalog;
|
|
533
|
+
try {
|
|
534
|
+
catalog = await loadModels(routerBaseUrl);
|
|
535
|
+
} catch (err) {
|
|
536
|
+
return {
|
|
537
|
+
succeeded: false,
|
|
538
|
+
error: `Could not validate model catalog: ${err instanceof Error ? err.message : String(err)}`
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
if (!new Set(catalog.flatMap(catalogIdsForModel)).has(cleaned)) return {
|
|
542
|
+
succeeded: false,
|
|
543
|
+
error: `Model is not available: ${cleaned}`
|
|
544
|
+
};
|
|
545
|
+
return {
|
|
546
|
+
succeeded: true,
|
|
547
|
+
value: cleaned
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
//#endregion
|
|
730
551
|
//#region src/readiness.ts
|
|
731
552
|
const DEFAULT_MINIMUM_READINESS_SCORE = .7;
|
|
732
553
|
/**
|
|
@@ -771,70 +592,6 @@ function decideKnowledgeReadiness(report, options = {}) {
|
|
|
771
592
|
};
|
|
772
593
|
}
|
|
773
594
|
//#endregion
|
|
774
|
-
//#region src/resolve-agent-backend.ts
|
|
775
|
-
/**
|
|
776
|
-
* The product-facing backend selector for `runChatThroughRuntime` /
|
|
777
|
-
* `runAgentTaskStream`: one call turns a `--backend {router,tcloud,cli-bridge,
|
|
778
|
-
* sandbox}` choice into the `AgentExecutionBackend` the chat leg runs on.
|
|
779
|
-
*
|
|
780
|
-
* It is the `AgentExecutionBackend` sibling of `resolveSandboxClient` (which
|
|
781
|
-
* resolves the `SandboxClient` a `runAgentRounds` drives). Both exist for the same
|
|
782
|
-
* reason: every in-process eval product hand-rolled the identical
|
|
783
|
-
* "`backend-name` → `createOpenAICompatibleBackend`" branch, and the copies
|
|
784
|
-
* drift. This is the single generic resolver they share.
|
|
785
|
-
*
|
|
786
|
-
* - `router` / `tcloud` / `cli-bridge` → OpenAI-compatible chat completions.
|
|
787
|
-
* All three speak `POST {baseUrl}/chat/completions` in OpenAI's SSE shape —
|
|
788
|
-
* the router (a.k.a. tcloud) IS that endpoint, and cli-bridge fronts a
|
|
789
|
-
* harness CLI behind the same protocol at its own `/v1`. They differ only
|
|
790
|
-
* in `baseUrl` / `apiKey` and the `kind` label a product wants on its
|
|
791
|
-
* traces. cli-bridge REQUIRES `model` in the request body, so it MUST route
|
|
792
|
-
* through `createOpenAICompatibleBackend` (which sends it), never a
|
|
793
|
-
* transport that drops the field.
|
|
794
|
-
* - `sandbox` → the caller's own domain backend. The sandbox variant carries
|
|
795
|
-
* product specifics (system prompt, workspace id, in-box D1 executor) that
|
|
796
|
-
* do NOT belong in the substrate, so the product passes a `sandboxBackend()`
|
|
797
|
-
* seam that this resolver simply invokes.
|
|
798
|
-
*
|
|
799
|
-
* This resolver is PURE backend selection. Product concerns — credit hard-cuts,
|
|
800
|
-
* fetch-capture shims, D1 platform wiring — stay as product-side WRAPPERS
|
|
801
|
-
* around the returned backend. The OpenAI-compat passthrough fields (`tools`,
|
|
802
|
-
* `toolChoice`, `responseFormat`, `temperature`, `maxTokens`, `fetchImpl`,
|
|
803
|
-
* `retry`) are forwarded verbatim so a product can advertise its app tools,
|
|
804
|
-
* preserve generation settings, or install a capturing fetch without
|
|
805
|
-
* re-opening the branch this consolidation closes.
|
|
806
|
-
*/
|
|
807
|
-
/**
|
|
808
|
-
* Resolve the `AgentExecutionBackend` for the chosen `kind`. Reuse this instead
|
|
809
|
-
* of hand-rolling the `createOpenAICompatibleBackend` branch in each product.
|
|
810
|
-
*/
|
|
811
|
-
function resolveAgentBackend(opts) {
|
|
812
|
-
switch (opts.kind) {
|
|
813
|
-
case "router":
|
|
814
|
-
case "tcloud":
|
|
815
|
-
case "cli-bridge": {
|
|
816
|
-
const passthrough = {};
|
|
817
|
-
if (opts.tools !== void 0) passthrough.tools = opts.tools;
|
|
818
|
-
if (opts.toolChoice !== void 0) passthrough.toolChoice = opts.toolChoice;
|
|
819
|
-
if (opts.responseFormat !== void 0) passthrough.responseFormat = opts.responseFormat;
|
|
820
|
-
if (opts.temperature !== void 0) passthrough.temperature = opts.temperature;
|
|
821
|
-
if (opts.maxTokens !== void 0) passthrough.maxTokens = opts.maxTokens;
|
|
822
|
-
if (opts.fetchImpl !== void 0) passthrough.fetchImpl = opts.fetchImpl;
|
|
823
|
-
if (opts.retry !== void 0) passthrough.retry = opts.retry;
|
|
824
|
-
return createOpenAICompatibleBackend({
|
|
825
|
-
apiKey: opts.apiKey,
|
|
826
|
-
baseUrl: opts.baseUrl,
|
|
827
|
-
model: opts.model,
|
|
828
|
-
kind: opts.label ?? opts.kind,
|
|
829
|
-
...passthrough
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
case "sandbox":
|
|
833
|
-
if (!opts.sandboxBackend) throw new Error("resolveAgentBackend: kind 'sandbox' requires opts.sandboxBackend");
|
|
834
|
-
return opts.sandboxBackend();
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
//#endregion
|
|
838
595
|
//#region src/run.ts
|
|
839
596
|
/**
|
|
840
597
|
*
|
|
@@ -1478,6 +1235,6 @@ function stripNewlines(value) {
|
|
|
1478
1235
|
return value.replace(/[\r\n]/g, " ");
|
|
1479
1236
|
}
|
|
1480
1237
|
//#endregion
|
|
1481
|
-
export {
|
|
1238
|
+
export { AGENT_CANDIDATE_EXECUTION_SUPPORT, AgentEvalError, BackendTransportError, CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV, CANDIDATE_KNOWLEDGE_ROOT_ENV, CANDIDATE_TRACE_ENV, CANDIDATE_TRACE_TAGS, CircuitBreakerState, CircuitOpenError, ConfigError, DEFAULT_MAX_DEPTH, DEFAULT_ROUTER_BASE_URL, DELEGATED_LOOP_MODES, DeadlineExceededError, FORWARD_HEADERS, FileAgentCandidateExecutionClaimStore, FileConversationJournal, INTELLIGENCE_WIRE_VERSION, InMemoryAgentCandidateExecutionClaimStore, InMemoryConversationJournal, InMemoryRuntimeSessionStore, JudgeError, NotFoundError, OfficialOptimizerUnavailableError, PlannerError, RESEARCH_SUPERVISOR_SYSTEM_PROMPT, ROLLOUT_POLICY_EXTENSION, RuntimeRunStateError, SqlConversationJournal, ValidationError, agentCandidateProfileAsAgentProfile, agenticGenerator, applyExactAgentProfileDiff, applyRolloutPolicyToProfile, applyRunRecordDefaults, assertCandidateProfileBinding, auditLoopRunner, buildAgentCandidateBundle, buildForwardHeaders, buildKnowledgeImprovementExperimentBundles, buildLoopOtelSpans, buildLoopSpanNodes, buildRuntimeEventOtelSpans, candidateExecutionClaim, candidateKnowledgeExecutionPaths, captureAgentCandidateWorkspace, captureAgentCandidateWorkspaceFiles, cleanModelId, commandVerifier, composeRuntimeHooks, computeBackoff, createAgentCandidateWorkspacePort, createAgentKnowledgeReadinessCheck, createConversationBackend, createIterableBackend, createKnowledgeImprovementActivationExecutor, createOpenInferenceFileExporter, createOtelExporter, createProfileExecutionBackend, createProtectedAgentCandidateModelPort, createRuntimeEventCollector, createRuntimeStreamEventCollector, createSandboxPromptBackend, createSupervisedKnowledgeUpdater, d1ToSqlAdapter, decideKnowledgeReadiness, defaultBuildPrompt, defaultIsRetryable, defineConversation, defineRuntimeHooks, disposePreparedAgentCandidateExecution, exactProcessProviderAsCandidateExecutor, executePreparedAgentCandidate, exportEvalRuns, findingLines, formatSupervisedKnowledgeTask, freezeGenericAgentCandidateProfile, generateSpanId, getModels, improve, isDelegatedLoopMode, isDepthExceeded, knowledgeReadinessDeliverable, loopEventToOtelSpan, makePerAttemptSignal, mcpBuildPrompt, mcpServeVerifier, mcpToolsForRuntimeMcp, mcpToolsForRuntimeMcpSubset, normalizeRolloutPolicy, notifyRuntimeDecisionPoint, notifyRuntimeHookEvent, officialGepa, officialSkillOpt, omitUndefinedObjectFields, optimizerMethod, padSpanId, padTraceId, parseExactAgentProfile, parseExactAgentProfileDiff, parseExactCandidateProfile, parseLoopRunnerArgv, parseRolloutPolicy, persistCandidateOutputArtifact, prepareAgentCandidateExecution, rawTraceDistiller, readDepth, readinessServerSentEvent, recoverExpiredAgentCandidateExecution, reflectiveGenerator, researchLoopRunner, resolveChatModel, resolveRouterBaseUrl, runAgentTask, runAgentTaskStream, runConversation, runConversationStream, runDelegatedLoop, runKnowledgeImprovementJob, runLoopRunnerCli, runPersonaConversation, runPersonaDispatch, runSupervisedKnowledgeUpdate, runtimeStreamServerSentEvent, sanitizeAgentRuntimeEvent, sanitizeKnowledgeReadinessReport, sanitizeRuntimeStreamEvent, sealAgentCandidateBundle, serializeRolloutPolicy, sleep, slugifySpeaker, startRuntimeRun, strategyAuthorMethod, structuralRolloutPolicyFromProfile, toOtelAttributes, toolBuildPrompt, turnId, validateChatModelId, verifyAgentCandidateBundle, worktreeLoopRunner };
|
|
1482
1239
|
|
|
1483
1240
|
//# sourceMappingURL=index.js.map
|