@tangle-network/agent-runtime 2.3.3 → 2.3.4
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/dist/agent.js +1 -1
- package/dist/index.js +1 -1
- package/dist/kernel.js +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/{loop-runner-Dazsm0A5.js → loop-runner-w2R6GUSp.js} +2 -2
- package/dist/{loop-runner-Dazsm0A5.js.map → loop-runner-w2R6GUSp.js.map} +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/{runtime-7qnbJxS_.js → runtime-DVwFHx7i.js} +16 -3
- package/dist/{runtime-7qnbJxS_.js.map → runtime-DVwFHx7i.js.map} +1 -1
- package/dist/testing.js +8 -8
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Br as sandboxActProfileMaterialization, Dt as createSandboxForSpec, Mr as assertProfileMaterializes, jr as assertProfileMaterialization } from "./supervisor-ByarsrwH.js";
|
|
2
2
|
import { Ot as mapSandboxEvent } from "./root-stream-To4qAc0e.js";
|
|
3
3
|
import { l as sha256 } from "./jsonl-file-BBP9Dz9w.js";
|
|
4
|
-
import "./runtime-
|
|
4
|
+
import "./runtime-DVwFHx7i.js";
|
|
5
5
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
6
6
|
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
7
7
|
import { parseFindingSubject } from "@tangle-network/agent-eval/analyst";
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { n as createAgentImprovementActivationResult } from "./activation-SA2R6S
|
|
|
12
12
|
import { l as sharedBoxLane, o as routerLane, r as dedicatedLane, t as SearchEnvironmentFault, u as subscriptionLane, y as decideSearchImprovement } from "./search-executor-DRzb2WwZ.js";
|
|
13
13
|
import { t as sealAgentCandidateBundle } from "./bundle-PDYNXIEf.js";
|
|
14
14
|
import { t as supervise } from "./supervise-BwUx_gjv.js";
|
|
15
|
-
import { n as auditLoopRunner } from "./loop-runner-
|
|
15
|
+
import { n as auditLoopRunner } from "./loop-runner-w2R6GUSp.js";
|
|
16
16
|
import { toW3CSpanId as padSpanId, toW3CTraceId as padTraceId } from "@tangle-network/agent-trace-contract";
|
|
17
17
|
import { agentCandidateKnowledgeSchema, agentCandidateWorkspaceManifestMaterialSchema, agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, sha256DigestSchema } from "@tangle-network/agent-interface";
|
|
18
18
|
import { FAILURE_CLASSES, acquisitionPlansForKnowledgeGaps, blockingKnowledgeEval, canonicalJson, runAgentControlLoop, scoreKnowledgeReadiness, userQuestionsForKnowledgeGaps } from "@tangle-network/agent-eval";
|
package/dist/kernel.js
CHANGED
|
@@ -7,7 +7,7 @@ import { f as createFileRunContext, h as FileCoordinationLog, i as watchTrace, m
|
|
|
7
7
|
import { A as analyzesFindingsReportPrompt, B as anyOf, D as defaultEdgeTraversalCap, F as formatPromptHandle, G as bestSoFar, H as plateau, I as kernelPromptRegistry, J as createSupervisorSpanRecorder, K as plateauLength, L as naiveContinuationPrompt, M as delegatesWorkerBriefPrompt, N as dumbContinuationFailPrompt, P as dumbContinuationPassPrompt, R as promptHandle, U as anytimeReport, V as noProgressFor, W as areaUnderCurve, c as retryPreSpawnRefusals, d as supervisorAgent, g as serveCoordinationMcp, h as composeReentryTask, j as createPromptRegistry, l as withWorkerSpawnRetry, m as UNPROVEN_CONTINUITY, n as superviseFleetCapabilities, o as isPreSpawnExecutorFailure, q as renderAnytimeTable, s as resolveWorkerSpawnRetry, t as supervise, u as workerFromBackend, x as GraphRouteError, z as allWorkersStalled } from "./supervise-BwUx_gjv.js";
|
|
8
8
|
import { i as readRunCancellation, n as cancelRun, r as readRunCancelRequest } from "./run-cancellation-BhP0Nw6G.js";
|
|
9
9
|
import { a as graphRegistry, b as graphRouteWhenSchema, c as loadGraph, d as recordGraphRun, f as recordStoredGraphRun, i as graphFromStored, l as lookupGraph, m as taskShapeDigest, n as graphCorpusSummary, o as graphRunsFor, p as storedGraphDigests, r as graphDigest, s as listGraphRuns, t as digestOfGraph, u as pickBestGraph, y as graphFileSchema } from "./graph-registry-72DlMnUl.js";
|
|
10
|
-
import { $ as runBenchmark, $t as renderLeaderboardHtml, A as searchPresets, At as sanitizeMcpToolSchema, B as graphFromSessionFacts, Bt as assertDeclaredCheck, C as withUntrackedArtifacts, Ct as harvestCorpus, D as SEARCH_SPEC_CORRELATION_KEY, Dt as connectStdioMcp, E as createFencedSqlRunContext, Et as McpSpawnFault, F as loadProfile, Ft as secretEnvOfMcpServer, G as chatWorkerSeam, Gt as readDeclaredCheck, H as loadGraphFile, Ht as declaredCheckDeliverable, I as pickBestProfile, It as inlineSandboxClient, J as strategyTournament, Jt as deterministicCompletion, K as createChatSessionStore, Kt as runIsolatedCheck, L as profileRegistry, Lt as loopCampaignDispatch, M as connectRemoteSupervisor, Mt as mcpSecretEnvMetadataKey, N as connectRemoteSupervisorControl, Nt as resolveMcpServerLaunch, O as assertSearchSpec, Ot as materializeLocalMcp, P as bestProfileFor, Pt as resolveSecretEnv, Q as printBenchmarkReport, Qt as pairwiseSignificance, R as profileRunsForName, Rt as loopDispatch, S as copyUntrackedIntoClone, St as HarvestError, T as validateStoredGraph, Tt as resolveSandboxClient, U as graphDesignerExtraTools, Ut as declaredCheckDigest, V as GraphFileResolutionError, Vt as checkProgramDigest, W as chatTransportExecutor, Wt as declaredCheckJudge, X as openSandboxRun, Xt as stopSentinel, Y as SandboxRunAbortError, Yt as sentinelCompletion, Z as createS3PrivateCasStore, Zt as leaderboard, _ as NOTE_MAX_CHARS, _t as buildSteerContext, a as localShell, at as FileCorpus, b as composeWorkerEvidence, bt as observationFromRegistry, c as createVerifierEnvironment, ct as fanout, d as harvestSurfaceDiffs, dt as panel, en as renderLeaderboardMarkdown, et as createPrivateCasArtifactPort, f as analystsFromRegistry, ft as pipeline, g as EVIDENCE_MAX_CHARS, gt as assertTraceDerivedFindings, ht as widen, i as jjWorkspace, in as openSqlRunStore, it as runPersonified, j as searchSpecDigest, jt as envKeyProvider, k as compileSearchSpec, kt as createMcpEnvironment, l as boxSurfaceReader, lt as flatWidenGate, m as worktreeFanout, mt as verify, n as makeFinding, nn as renderPairwiseMarkdown, nt as trajectoryReport, o as runInWorkspace, ot as InMemoryCorpus, p as failuresAnalyst, pt as selectValidWinner, q as runStrategyEvolution, qt as completionAuthorizes, r as gitWorkspace, rn as SqlRunOwnershipError, rt as definePersona, s as createWaterfallCollector, st as renderCorpusToInstructions, t as computeFindingId, tn as renderLeaderboardSvg, tt as equalKOnCost, u as fsSurfaceReader, ut as loopUntil, v as VERIFY_TAIL_CHARS, vt as createScopeAnalyst, w as analyzeTrace, wt as defineLeaderboard, x as settledWorkerOut, xt as inProcessSandboxClient, y as closingWorkerNote, yt as registryScopeAnalyst, z as recordProfileRun, zt as superviseDispatch } from "./runtime-
|
|
10
|
+
import { $ as runBenchmark, $t as renderLeaderboardHtml, A as searchPresets, At as sanitizeMcpToolSchema, B as graphFromSessionFacts, Bt as assertDeclaredCheck, C as withUntrackedArtifacts, Ct as harvestCorpus, D as SEARCH_SPEC_CORRELATION_KEY, Dt as connectStdioMcp, E as createFencedSqlRunContext, Et as McpSpawnFault, F as loadProfile, Ft as secretEnvOfMcpServer, G as chatWorkerSeam, Gt as readDeclaredCheck, H as loadGraphFile, Ht as declaredCheckDeliverable, I as pickBestProfile, It as inlineSandboxClient, J as strategyTournament, Jt as deterministicCompletion, K as createChatSessionStore, Kt as runIsolatedCheck, L as profileRegistry, Lt as loopCampaignDispatch, M as connectRemoteSupervisor, Mt as mcpSecretEnvMetadataKey, N as connectRemoteSupervisorControl, Nt as resolveMcpServerLaunch, O as assertSearchSpec, Ot as materializeLocalMcp, P as bestProfileFor, Pt as resolveSecretEnv, Q as printBenchmarkReport, Qt as pairwiseSignificance, R as profileRunsForName, Rt as loopDispatch, S as copyUntrackedIntoClone, St as HarvestError, T as validateStoredGraph, Tt as resolveSandboxClient, U as graphDesignerExtraTools, Ut as declaredCheckDigest, V as GraphFileResolutionError, Vt as checkProgramDigest, W as chatTransportExecutor, Wt as declaredCheckJudge, X as openSandboxRun, Xt as stopSentinel, Y as SandboxRunAbortError, Yt as sentinelCompletion, Z as createS3PrivateCasStore, Zt as leaderboard, _ as NOTE_MAX_CHARS, _t as buildSteerContext, a as localShell, at as FileCorpus, b as composeWorkerEvidence, bt as observationFromRegistry, c as createVerifierEnvironment, ct as fanout, d as harvestSurfaceDiffs, dt as panel, en as renderLeaderboardMarkdown, et as createPrivateCasArtifactPort, f as analystsFromRegistry, ft as pipeline, g as EVIDENCE_MAX_CHARS, gt as assertTraceDerivedFindings, ht as widen, i as jjWorkspace, in as openSqlRunStore, it as runPersonified, j as searchSpecDigest, jt as envKeyProvider, k as compileSearchSpec, kt as createMcpEnvironment, l as boxSurfaceReader, lt as flatWidenGate, m as worktreeFanout, mt as verify, n as makeFinding, nn as renderPairwiseMarkdown, nt as trajectoryReport, o as runInWorkspace, ot as InMemoryCorpus, p as failuresAnalyst, pt as selectValidWinner, q as runStrategyEvolution, qt as completionAuthorizes, r as gitWorkspace, rn as SqlRunOwnershipError, rt as definePersona, s as createWaterfallCollector, st as renderCorpusToInstructions, t as computeFindingId, tn as renderLeaderboardSvg, tt as equalKOnCost, u as fsSurfaceReader, ut as loopUntil, v as VERIFY_TAIL_CHARS, vt as createScopeAnalyst, w as analyzeTrace, wt as defineLeaderboard, x as settledWorkerOut, xt as inProcessSandboxClient, y as closingWorkerNote, yt as registryScopeAnalyst, z as recordProfileRun, zt as superviseDispatch } from "./runtime-DVwFHx7i.js";
|
|
11
11
|
import { n as workerFromInteractiveProvider, r as claimRetainedInteractiveControl, t as provisionSupervisor } from "./provision-supervisor-DG4E0Viy.js";
|
|
12
12
|
import { a as defaultProfileRichnessThresholds, i as assessAuthoredProfile, n as delegate, o as profileRichnessFinding, r as asAuthoredProfile, s as supervisorInstructions, t as defaultDelegateBudget } from "./delegate-Drwq3e6S.js";
|
|
13
13
|
import { n as runGraph, t as GraphEdgeCapError } from "./graph-Bio7TWRa.js";
|
package/dist/loop-runner-bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as runDelegatedLoop, r as isDelegatedLoopMode, t as DELEGATED_LOOP_MODES } from "./loop-runner-
|
|
2
|
+
import { i as runDelegatedLoop, r as isDelegatedLoopMode, t as DELEGATED_LOOP_MODES } from "./loop-runner-w2R6GUSp.js";
|
|
3
3
|
// src/loop-runner-bin.ts
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as ConfigError } from "./errors-AzSuGI23.js";
|
|
2
2
|
import { t as runAnalystLoop } from "./analyst-loop-BZvXCDKy.js";
|
|
3
|
-
import "./runtime-
|
|
3
|
+
import "./runtime-DVwFHx7i.js";
|
|
4
4
|
// src/loop-runner.ts
|
|
5
5
|
/** All valid delegated-loop mode names — used for validation and CLI surfaces. @experimental */
|
|
6
6
|
const DELEGATED_LOOP_MODES = [
|
|
@@ -55,4 +55,4 @@ function auditLoopRunner(options) {
|
|
|
55
55
|
}
|
|
56
56
|
export { runDelegatedLoop as i, auditLoopRunner as n, isDelegatedLoopMode as r, DELEGATED_LOOP_MODES as t };
|
|
57
57
|
|
|
58
|
-
//# sourceMappingURL=loop-runner-
|
|
58
|
+
//# sourceMappingURL=loop-runner-w2R6GUSp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop-runner-Dazsm0A5.js","names":[],"sources":["../src/loop-runner.ts"],"sourcesContent":["/**\n *\n * `runDelegatedLoop` — the configured delegated loop-runner.\n *\n * One typed entrypoint a worker agent (or a scheduled routine) calls to run a\n * disciplined loop in a chosen MODE, over agent-runtime's hardened engines:\n *\n * code → build-in-a-loop on the GENERIC recursive path (worktreeLoopRunner: author one\n * `AgentProfile` per harness → worktree-CLI leaves → `patchDelivered` gate)\n * review → caller-registered runner — a `code` runner with an approval gate over candidates\n * research → research-in-a-loop with valid-only KB growth (createKbGate)\n * audit → analyze trace/run data → findings (runAnalystLoop, caller-wired)\n * self-improve → caller-registered `improve(profile, options)` run\n *\n * It is intentionally a thin façade: the value is that EVERY product reuses the\n * one hardened engine instead of forking delegation logic. The dispatcher owns\n * mode routing, timing, fail-loud on an unregistered mode, and a uniform result\n * shape; each mode's engine is a pre-configured runner in the registry (build it\n * with the factories below, or inject your own / a stub).\n *\n * @experimental\n */\n\nimport type { AgentProfile } from '@tangle-network/agent-interface'\nimport { runAnalystLoop } from './analyst-loop'\nimport type { RunAnalystLoopOpts, RunAnalystLoopResult } from './analyst-loop/types'\nimport { ConfigError } from './errors'\nimport { type CreateKbGateOptions, createKbGate, type FactCandidate } from './mcp/kb-gate'\nimport {\n type AuthoredHarness,\n type Budget,\n createExecutorRegistry,\n definePersona,\n runPersonified,\n type WinnerStrategy,\n type WorktreeFanoutOptions,\n type WorktreePatchArtifact,\n worktreeFanout,\n} from './runtime'\n\n/** All valid delegated-loop mode names — used for validation and CLI surfaces. @experimental */\nexport const DELEGATED_LOOP_MODES = ['code', 'review', 'research', 'audit', 'self-improve'] as const\n\n/** @experimental */\nexport type DelegatedLoopMode = (typeof DELEGATED_LOOP_MODES)[number]\n\n/** Type guard — returns true when `value` is a valid `DelegatedLoopMode` string. @experimental */\nexport function isDelegatedLoopMode(value: unknown): value is DelegatedLoopMode {\n return typeof value === 'string' && (DELEGATED_LOOP_MODES as readonly string[]).includes(value)\n}\n\n/** @experimental A pre-configured loop for one mode. Returns the mode's raw\n * output; the dispatcher wraps it in a `DelegatedLoopResult`. */\nexport type DelegatedLoopRunner<T = unknown> = (signal: AbortSignal) => Promise<T>\n\n/** @experimental Mode → configured runner. Partial: only register the modes a\n * given product/routine actually uses. */\nexport type DelegatedLoopRegistry = Partial<Record<DelegatedLoopMode, DelegatedLoopRunner>>\n\n/** @experimental Uniform result — never throws from a registered runner; a\n * thrown engine becomes `{ ok: false, error }` so a routine can record + move on. */\nexport interface DelegatedLoopResult<T = unknown> {\n mode: DelegatedLoopMode\n ok: boolean\n output?: T\n error?: string\n durationMs: number\n}\n\n/** @experimental */\ninterface RunDelegatedLoopOptions {\n signal?: AbortSignal\n /** Clock override for deterministic tests. */\n now?: () => number\n}\n\n/**\n *\n * Dispatch a configured loop by mode. Fails loud (throws `ConfigError`) when no\n * runner is registered for the mode — a routine pointed at an unwired mode is a\n * config bug, not a silent no-op. A runner that throws is captured as\n * `{ ok: false }` so unattended runs record the failure rather than crash.\n *\n * @experimental\n */\nexport async function runDelegatedLoop<T = unknown>(\n mode: DelegatedLoopMode,\n registry: DelegatedLoopRegistry,\n options: RunDelegatedLoopOptions = {},\n): Promise<DelegatedLoopResult<T>> {\n const runner = registry[mode] as DelegatedLoopRunner<T> | undefined\n if (!runner) {\n throw new ConfigError(\n `runDelegatedLoop: no runner registered for mode '${mode}' (registered: ${\n Object.keys(registry).join(', ') || 'none'\n })`,\n )\n }\n const now = options.now ?? Date.now\n const signal = options.signal ?? new AbortController().signal\n const start = now()\n try {\n const output = await runner(signal)\n return { mode, ok: true, output, durationMs: now() - start }\n } catch (err) {\n return {\n mode,\n ok: false,\n error: err instanceof Error ? err.message : String(err),\n durationMs: now() - start,\n }\n }\n}\n\n/** @experimental Options for the local-repo `code` runner over the GENERIC recursive path. */\ninterface WorktreeLoopRunnerOptions {\n /** Exact profile carried by the personified root that owns this fanout. */\n rootProfile: AgentProfile\n /** Absolute path to the local git checkout each worktree is cut from. */\n repoRoot: string\n /** The instruction handed to every authored harness (composed under each profile's systemPrompt). */\n taskPrompt: string\n /** The supervisor-authored harness profiles — one fanout item (one worktree-CLI leaf) each. */\n harnesses: ReadonlyArray<AuthoredHarness>\n /** Conserved budget pool bounding the fanout (equal-k holds by construction). */\n budget: Budget\n /** Shell command run in each worktree to derive the tests-PASS signal. */\n testCmd?: string\n /** Shell command run in each worktree to derive the typecheck-PASS signal. */\n typecheckCmd?: string\n /** Which verification signals the deliverable REQUIRES present-and-passing (default none). */\n require?: ReadonlyArray<'tests' | 'typecheck'>\n /** Diff-size cap (lines). */\n maxDiffLines?: number\n /** Literal path prefixes the patch must not touch (the secret-floor is always on regardless). */\n forbiddenPaths?: string[]\n /** Winner-selection strategy among gated candidates. Default `highest-score`. */\n winnerStrategy?: WinnerStrategy\n /** Test seams forwarded to the worktree-CLI leaves so the runner drives offline. */\n runGit?: WorktreeFanoutOptions['runGit']\n runHarness?: WorktreeFanoutOptions['runHarness']\n runCommand?: WorktreeFanoutOptions['runCommand']\n}\n\n/**\n *\n * `code` mode on the GENERIC recursive path: author one `AgentProfile` per harness, run them as a\n * `worktreeFanout` (N `createWorktreeCliExecutor` leaves, each `gateOnDeliverable`) through\n * `runPersonified` on the keystone Supervisor. The sandbox-session counterpart that drives the in-box\n * harness over a `SandboxClient` is `detachedSessionDelegate` (`./mcp/delegates`); here there is no\n * `runAgentRounds` driver, no role-coupled delegate — the harness list is the fanout, the gate is\n * `patchDelivered`,\n * the winner is the shared valid-only selector (NOT `defaultSelectWinner`, whose non-valid fallback\n * would surface an ungated patch). Equal-k holds by the conserved budget pool. Returns the winning\n * patch artifact, or throws when no candidate is delivered (fail loud, never a vacuous done).\n *\n * @experimental\n */\nexport function worktreeLoopRunner(\n options: WorktreeLoopRunnerOptions,\n): DelegatedLoopRunner<WorktreePatchArtifact> {\n const shape = worktreeFanout<string>({\n repoRoot: options.repoRoot,\n taskPrompt: options.taskPrompt,\n harnesses: options.harnesses,\n ...(options.testCmd !== undefined ? { testCmd: options.testCmd } : {}),\n ...(options.typecheckCmd !== undefined ? { typecheckCmd: options.typecheckCmd } : {}),\n ...(options.require !== undefined ? { require: options.require } : {}),\n ...(options.maxDiffLines !== undefined ? { maxDiffLines: options.maxDiffLines } : {}),\n ...(options.forbiddenPaths !== undefined ? { forbiddenPaths: options.forbiddenPaths } : {}),\n ...(options.winnerStrategy !== undefined ? { winnerStrategy: options.winnerStrategy } : {}),\n ...(options.runGit ? { runGit: options.runGit } : {}),\n ...(options.runHarness ? { runHarness: options.runHarness } : {}),\n ...(options.runCommand ? { runCommand: options.runCommand } : {}),\n })\n // The persona's only role here is to carry the fanout shape onto the Supervisor; each item's\n // executor is BYO (the gated worktree-CLI leaf), so the registry only needs to pass BYO through.\n const persona = definePersona<WorktreePatchArtifact>({\n name: 'worktree-coder',\n root: { profile: options.rootProfile, harness: null },\n directive: 'deliver a minimal validated patch on a fresh worktree',\n context: { role: 'coder' },\n executors: { registry: createExecutorRegistry() },\n })\n return async (signal) => {\n const result = await runPersonified<string, WorktreePatchArtifact>({\n persona,\n shape,\n task: options.taskPrompt,\n budget: options.budget,\n signal,\n })\n if (result.kind !== 'winner' || result.out.kind !== 'done') {\n const blockers =\n result.kind === 'winner' && result.out.kind === 'blocked'\n ? result.out.blockers.join('; ')\n : `supervisor settled ${result.kind}`\n throw new Error(`worktreeLoopRunner: no delivered patch (${blockers})`)\n }\n return result.out.deliverable\n }\n}\n\n/** @experimental A fact rejected at the KB gate — surfaced, never dropped. */\nexport interface VetoedFact {\n candidate: FactCandidate\n vetoedBy?: string\n reason?: string\n}\n\n/** @experimental */\ninterface ResearchLoopResult {\n /** Facts that passed the fail-closed gate — safe to write to the KB. */\n accepted: FactCandidate[]\n /** Facts the gate vetoed in the final round — escalate, do not silently drop. */\n vetoed: VetoedFact[]\n /** Research rounds actually run. */\n rounds: number\n}\n\n/** @experimental Options for the default `research` runner. */\ninterface ResearchLoopRunnerOptions {\n /**\n * The research engine (the consumer's web/doc searcher + extractor). Called\n * each round with the prior round's vetoes so it can re-research the gaps.\n * Returns fact candidates carrying their grounding (`verbatimPassage` +\n * `sourceText`).\n */\n research: (round: number, vetoed: VetoedFact[]) => Promise<FactCandidate[]>\n /** Gate config (extra judges, self-artifact kinds, …). The floor is always on. */\n gate?: CreateKbGateOptions\n /** Max research rounds (correct-on-veto remediation). Default 1. */\n maxRounds?: number\n}\n\n/**\n * `research` mode — research-in-a-loop with valid-only KB growth.\n *\n * Each round: research → gate every candidate (fail-closed; passage MUST be in\n * the source) → accept the clean ones → re-research the vetoed ones next round,\n * up to `maxRounds`. Vetoed facts in the final round are RETURNED (escalate,\n * never silently dropped) so the caller audits vs retries.\n *\n * @experimental\n */\nexport function researchLoopRunner(\n o: ResearchLoopRunnerOptions,\n): DelegatedLoopRunner<ResearchLoopResult> {\n const gate = createKbGate(o.gate)\n const maxRounds = Math.max(1, Math.trunc(o.maxRounds ?? 1))\n return async (signal) => {\n const accepted: FactCandidate[] = []\n let vetoed: VetoedFact[] = []\n let rounds = 0\n for (let round = 0; round < maxRounds; round += 1) {\n if (signal.aborted) break\n rounds += 1\n const candidates = await o.research(round, vetoed)\n if (candidates.length === 0) break\n vetoed = []\n for (const c of candidates) {\n const v = await gate(c)\n if (v.accepted) accepted.push(c)\n else vetoed.push({ candidate: c, vetoedBy: v.vetoedBy, reason: v.reason })\n }\n if (vetoed.length === 0) break\n }\n return { accepted, vetoed, rounds }\n }\n}\n\n/**\n * `audit` mode — analyst loop over captured trace/run data.\n *\n * @experimental\n */\nexport function auditLoopRunner<TProposal = unknown, TEdit = unknown>(\n options: RunAnalystLoopOpts,\n): DelegatedLoopRunner<RunAnalystLoopResult<TProposal, TEdit>> {\n return async () => runAnalystLoop<TProposal, TEdit>(options)\n}\n"],"mappings":";;;;;AAyCA,MAAa,uBAAuB;CAAC;CAAQ;CAAU;CAAY;CAAS;AAAc;;AAM1F,SAAgB,oBAAoB,OAA4C;CAC9E,OAAO,OAAO,UAAU,YAAa,qBAA2C,SAAS,KAAK;AAChG;;;;;;;;;;AAoCA,eAAsB,iBACpB,MACA,UACA,UAAmC,CAAC,GACH;CACjC,MAAM,SAAS,SAAS;CACxB,IAAI,CAAC,QACH,MAAM,IAAI,YACR,oDAAoD,KAAK,iBACvD,OAAO,KAAK,QAAQ,CAAC,CAAC,KAAK,IAAI,KAAK,OACrC,EACH;CAEF,MAAM,MAAM,QAAQ,OAAO,KAAK;CAChC,MAAM,SAAS,QAAQ,UAAU,IAAI,gBAAgB,CAAC,CAAC;CACvD,MAAM,QAAQ,IAAI;CAClB,IAAI;EAEF,OAAO;GAAE;GAAM,IAAI;GAAM,QAAA,MADJ,OAAO,MAAM;GACD,YAAY,IAAI,IAAI;EAAM;CAC7D,SAAS,KAAK;EACZ,OAAO;GACL;GACA,IAAI;GACJ,OAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;GACtD,YAAY,IAAI,IAAI;EACtB;CACF;AACF;;;;;;AAoKA,SAAgB,gBACd,SAC6D;CAC7D,OAAO,YAAY,eAAiC,OAAO;AAC7D"}
|
|
1
|
+
{"version":3,"file":"loop-runner-w2R6GUSp.js","names":[],"sources":["../src/loop-runner.ts"],"sourcesContent":["/**\n *\n * `runDelegatedLoop` — the configured delegated loop-runner.\n *\n * One typed entrypoint a worker agent (or a scheduled routine) calls to run a\n * disciplined loop in a chosen MODE, over agent-runtime's hardened engines:\n *\n * code → build-in-a-loop on the GENERIC recursive path (worktreeLoopRunner: author one\n * `AgentProfile` per harness → worktree-CLI leaves → `patchDelivered` gate)\n * review → caller-registered runner — a `code` runner with an approval gate over candidates\n * research → research-in-a-loop with valid-only KB growth (createKbGate)\n * audit → analyze trace/run data → findings (runAnalystLoop, caller-wired)\n * self-improve → caller-registered `improve(profile, options)` run\n *\n * It is intentionally a thin façade: the value is that EVERY product reuses the\n * one hardened engine instead of forking delegation logic. The dispatcher owns\n * mode routing, timing, fail-loud on an unregistered mode, and a uniform result\n * shape; each mode's engine is a pre-configured runner in the registry (build it\n * with the factories below, or inject your own / a stub).\n *\n * @experimental\n */\n\nimport type { AgentProfile } from '@tangle-network/agent-interface'\nimport { runAnalystLoop } from './analyst-loop'\nimport type { RunAnalystLoopOpts, RunAnalystLoopResult } from './analyst-loop/types'\nimport { ConfigError } from './errors'\nimport { type CreateKbGateOptions, createKbGate, type FactCandidate } from './mcp/kb-gate'\nimport {\n type AuthoredHarness,\n type Budget,\n createExecutorRegistry,\n definePersona,\n runPersonified,\n type WinnerStrategy,\n type WorktreeFanoutOptions,\n type WorktreePatchArtifact,\n worktreeFanout,\n} from './runtime'\n\n/** All valid delegated-loop mode names — used for validation and CLI surfaces. @experimental */\nexport const DELEGATED_LOOP_MODES = ['code', 'review', 'research', 'audit', 'self-improve'] as const\n\n/** @experimental */\nexport type DelegatedLoopMode = (typeof DELEGATED_LOOP_MODES)[number]\n\n/** Type guard — returns true when `value` is a valid `DelegatedLoopMode` string. @experimental */\nexport function isDelegatedLoopMode(value: unknown): value is DelegatedLoopMode {\n return typeof value === 'string' && (DELEGATED_LOOP_MODES as readonly string[]).includes(value)\n}\n\n/** @experimental A pre-configured loop for one mode. Returns the mode's raw\n * output; the dispatcher wraps it in a `DelegatedLoopResult`. */\nexport type DelegatedLoopRunner<T = unknown> = (signal: AbortSignal) => Promise<T>\n\n/** @experimental Mode → configured runner. Partial: only register the modes a\n * given product/routine actually uses. */\nexport type DelegatedLoopRegistry = Partial<Record<DelegatedLoopMode, DelegatedLoopRunner>>\n\n/** @experimental Uniform result — never throws from a registered runner; a\n * thrown engine becomes `{ ok: false, error }` so a routine can record + move on. */\nexport interface DelegatedLoopResult<T = unknown> {\n mode: DelegatedLoopMode\n ok: boolean\n output?: T\n error?: string\n durationMs: number\n}\n\n/** @experimental */\ninterface RunDelegatedLoopOptions {\n signal?: AbortSignal\n /** Clock override for deterministic tests. */\n now?: () => number\n}\n\n/**\n *\n * Dispatch a configured loop by mode. Fails loud (throws `ConfigError`) when no\n * runner is registered for the mode — a routine pointed at an unwired mode is a\n * config bug, not a silent no-op. A runner that throws is captured as\n * `{ ok: false }` so unattended runs record the failure rather than crash.\n *\n * @experimental\n */\nexport async function runDelegatedLoop<T = unknown>(\n mode: DelegatedLoopMode,\n registry: DelegatedLoopRegistry,\n options: RunDelegatedLoopOptions = {},\n): Promise<DelegatedLoopResult<T>> {\n const runner = registry[mode] as DelegatedLoopRunner<T> | undefined\n if (!runner) {\n throw new ConfigError(\n `runDelegatedLoop: no runner registered for mode '${mode}' (registered: ${\n Object.keys(registry).join(', ') || 'none'\n })`,\n )\n }\n const now = options.now ?? Date.now\n const signal = options.signal ?? new AbortController().signal\n const start = now()\n try {\n const output = await runner(signal)\n return { mode, ok: true, output, durationMs: now() - start }\n } catch (err) {\n return {\n mode,\n ok: false,\n error: err instanceof Error ? err.message : String(err),\n durationMs: now() - start,\n }\n }\n}\n\n/** @experimental Options for the local-repo `code` runner over the GENERIC recursive path. */\ninterface WorktreeLoopRunnerOptions {\n /** Exact profile carried by the personified root that owns this fanout. */\n rootProfile: AgentProfile\n /** Absolute path to the local git checkout each worktree is cut from. */\n repoRoot: string\n /** The instruction handed to every authored harness (composed under each profile's systemPrompt). */\n taskPrompt: string\n /** The supervisor-authored harness profiles — one fanout item (one worktree-CLI leaf) each. */\n harnesses: ReadonlyArray<AuthoredHarness>\n /** Conserved budget pool bounding the fanout (equal-k holds by construction). */\n budget: Budget\n /** Shell command run in each worktree to derive the tests-PASS signal. */\n testCmd?: string\n /** Shell command run in each worktree to derive the typecheck-PASS signal. */\n typecheckCmd?: string\n /** Which verification signals the deliverable REQUIRES present-and-passing (default none). */\n require?: ReadonlyArray<'tests' | 'typecheck'>\n /** Diff-size cap (lines). */\n maxDiffLines?: number\n /** Literal path prefixes the patch must not touch (the secret-floor is always on regardless). */\n forbiddenPaths?: string[]\n /** Winner-selection strategy among gated candidates. Default `highest-score`. */\n winnerStrategy?: WinnerStrategy\n /** Test seams forwarded to the worktree-CLI leaves so the runner drives offline. */\n runGit?: WorktreeFanoutOptions['runGit']\n runHarness?: WorktreeFanoutOptions['runHarness']\n runCommand?: WorktreeFanoutOptions['runCommand']\n}\n\n/**\n *\n * `code` mode on the GENERIC recursive path: author one `AgentProfile` per harness, run them as a\n * `worktreeFanout` (N `createWorktreeCliExecutor` leaves, each `gateOnDeliverable`) through\n * `runPersonified` on the keystone Supervisor. The sandbox-session counterpart that drives the in-box\n * harness over a `SandboxClient` is `detachedSessionDelegate` (`./mcp/delegates`); here there is no\n * `runAgentRounds` driver, no role-coupled delegate — the harness list is the fanout, the gate is\n * `patchDelivered`,\n * the winner is the shared valid-only selector (NOT `defaultSelectWinner`, whose non-valid fallback\n * would surface an ungated patch). Equal-k holds by the conserved budget pool. Returns the winning\n * patch artifact, or throws when no candidate is delivered (fail loud, never a vacuous done).\n *\n * @experimental\n */\nexport function worktreeLoopRunner(\n options: WorktreeLoopRunnerOptions,\n): DelegatedLoopRunner<WorktreePatchArtifact> {\n const shape = worktreeFanout<string>({\n repoRoot: options.repoRoot,\n taskPrompt: options.taskPrompt,\n harnesses: options.harnesses,\n ...(options.testCmd !== undefined ? { testCmd: options.testCmd } : {}),\n ...(options.typecheckCmd !== undefined ? { typecheckCmd: options.typecheckCmd } : {}),\n ...(options.require !== undefined ? { require: options.require } : {}),\n ...(options.maxDiffLines !== undefined ? { maxDiffLines: options.maxDiffLines } : {}),\n ...(options.forbiddenPaths !== undefined ? { forbiddenPaths: options.forbiddenPaths } : {}),\n ...(options.winnerStrategy !== undefined ? { winnerStrategy: options.winnerStrategy } : {}),\n ...(options.runGit ? { runGit: options.runGit } : {}),\n ...(options.runHarness ? { runHarness: options.runHarness } : {}),\n ...(options.runCommand ? { runCommand: options.runCommand } : {}),\n })\n // The persona's only role here is to carry the fanout shape onto the Supervisor; each item's\n // executor is BYO (the gated worktree-CLI leaf), so the registry only needs to pass BYO through.\n const persona = definePersona<WorktreePatchArtifact>({\n name: 'worktree-coder',\n root: { profile: options.rootProfile, harness: null },\n directive: 'deliver a minimal validated patch on a fresh worktree',\n context: { role: 'coder' },\n executors: { registry: createExecutorRegistry() },\n })\n return async (signal) => {\n const result = await runPersonified<string, WorktreePatchArtifact>({\n persona,\n shape,\n task: options.taskPrompt,\n budget: options.budget,\n signal,\n })\n if (result.kind !== 'winner' || result.out.kind !== 'done') {\n const blockers =\n result.kind === 'winner' && result.out.kind === 'blocked'\n ? result.out.blockers.join('; ')\n : `supervisor settled ${result.kind}`\n throw new Error(`worktreeLoopRunner: no delivered patch (${blockers})`)\n }\n return result.out.deliverable\n }\n}\n\n/** @experimental A fact rejected at the KB gate — surfaced, never dropped. */\nexport interface VetoedFact {\n candidate: FactCandidate\n vetoedBy?: string\n reason?: string\n}\n\n/** @experimental */\ninterface ResearchLoopResult {\n /** Facts that passed the fail-closed gate — safe to write to the KB. */\n accepted: FactCandidate[]\n /** Facts the gate vetoed in the final round — escalate, do not silently drop. */\n vetoed: VetoedFact[]\n /** Research rounds actually run. */\n rounds: number\n}\n\n/** @experimental Options for the default `research` runner. */\ninterface ResearchLoopRunnerOptions {\n /**\n * The research engine (the consumer's web/doc searcher + extractor). Called\n * each round with the prior round's vetoes so it can re-research the gaps.\n * Returns fact candidates carrying their grounding (`verbatimPassage` +\n * `sourceText`).\n */\n research: (round: number, vetoed: VetoedFact[]) => Promise<FactCandidate[]>\n /** Gate config (extra judges, self-artifact kinds, …). The floor is always on. */\n gate?: CreateKbGateOptions\n /** Max research rounds (correct-on-veto remediation). Default 1. */\n maxRounds?: number\n}\n\n/**\n * `research` mode — research-in-a-loop with valid-only KB growth.\n *\n * Each round: research → gate every candidate (fail-closed; passage MUST be in\n * the source) → accept the clean ones → re-research the vetoed ones next round,\n * up to `maxRounds`. Vetoed facts in the final round are RETURNED (escalate,\n * never silently dropped) so the caller audits vs retries.\n *\n * @experimental\n */\nexport function researchLoopRunner(\n o: ResearchLoopRunnerOptions,\n): DelegatedLoopRunner<ResearchLoopResult> {\n const gate = createKbGate(o.gate)\n const maxRounds = Math.max(1, Math.trunc(o.maxRounds ?? 1))\n return async (signal) => {\n const accepted: FactCandidate[] = []\n let vetoed: VetoedFact[] = []\n let rounds = 0\n for (let round = 0; round < maxRounds; round += 1) {\n if (signal.aborted) break\n rounds += 1\n const candidates = await o.research(round, vetoed)\n if (candidates.length === 0) break\n vetoed = []\n for (const c of candidates) {\n const v = await gate(c)\n if (v.accepted) accepted.push(c)\n else vetoed.push({ candidate: c, vetoedBy: v.vetoedBy, reason: v.reason })\n }\n if (vetoed.length === 0) break\n }\n return { accepted, vetoed, rounds }\n }\n}\n\n/**\n * `audit` mode — analyst loop over captured trace/run data.\n *\n * @experimental\n */\nexport function auditLoopRunner<TProposal = unknown, TEdit = unknown>(\n options: RunAnalystLoopOpts,\n): DelegatedLoopRunner<RunAnalystLoopResult<TProposal, TEdit>> {\n return async () => runAnalystLoop<TProposal, TEdit>(options)\n}\n"],"mappings":";;;;;AAyCA,MAAa,uBAAuB;CAAC;CAAQ;CAAU;CAAY;CAAS;AAAc;;AAM1F,SAAgB,oBAAoB,OAA4C;CAC9E,OAAO,OAAO,UAAU,YAAa,qBAA2C,SAAS,KAAK;AAChG;;;;;;;;;;AAoCA,eAAsB,iBACpB,MACA,UACA,UAAmC,CAAC,GACH;CACjC,MAAM,SAAS,SAAS;CACxB,IAAI,CAAC,QACH,MAAM,IAAI,YACR,oDAAoD,KAAK,iBACvD,OAAO,KAAK,QAAQ,CAAC,CAAC,KAAK,IAAI,KAAK,OACrC,EACH;CAEF,MAAM,MAAM,QAAQ,OAAO,KAAK;CAChC,MAAM,SAAS,QAAQ,UAAU,IAAI,gBAAgB,CAAC,CAAC;CACvD,MAAM,QAAQ,IAAI;CAClB,IAAI;EAEF,OAAO;GAAE;GAAM,IAAI;GAAM,QAAA,MADJ,OAAO,MAAM;GACD,YAAY,IAAI,IAAI;EAAM;CAC7D,SAAS,KAAK;EACZ,OAAO;GACL;GACA,IAAI;GACJ,OAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;GACtD,YAAY,IAAI,IAAI;EACtB;CACF;AACF;;;;;;AAoKA,SAAgB,gBACd,SAC6D;CAC7D,OAAO,YAAY,eAAiC,OAAO;AAC7D"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { s as deleteBoxSafe, v as sleep, x as throwIfAborted } from "../util-BX2
|
|
|
4
4
|
import { t as assertExecutableAgentProfile } from "../model-policy-C-RGAUW4.js";
|
|
5
5
|
import { t as createCoordinationTools } from "../coordination-manager-BxnEJXsv.js";
|
|
6
6
|
import { n as createStdioToolServer } from "../tool-server-CZWd_Opp.js";
|
|
7
|
-
import { h as runCoderChecks, pt as selectValidWinner } from "../runtime-
|
|
7
|
+
import { h as runCoderChecks, pt as selectValidWinner } from "../runtime-DVwFHx7i.js";
|
|
8
8
|
import { a as composeLoopTraceEmitters, i as FileDelegationStore, n as createDelegateHandler, r as DelegationTaskQueue, t as createMcpServer } from "../server-BNsxRqPY.js";
|
|
9
9
|
import { agentProfileSchema } from "@tangle-network/agent-interface";
|
|
10
10
|
import { isRecord } from "@tangle-network/agent-core";
|
|
@@ -7460,7 +7460,7 @@ async function expandProfile(node, options) {
|
|
|
7460
7460
|
});
|
|
7461
7461
|
if (!selected) refuse$2(`node ${node.id} needs a canonical profile or resolveSeat from Bridge login inventory`);
|
|
7462
7462
|
}
|
|
7463
|
-
const connections = await Promise.all((node.needs ?? []).map(async (provider) => {
|
|
7463
|
+
const connections = await Promise.all([...new Set(node.needs ?? [])].map(async (provider) => {
|
|
7464
7464
|
if (options.needs && Object.hasOwn(options.needs, provider)) return options.needs[provider];
|
|
7465
7465
|
const connection = await options.resolveNeed?.(provider, context);
|
|
7466
7466
|
if (connection === void 0) throw new GraphFileResolutionError(provider, node.id);
|
|
@@ -7480,7 +7480,20 @@ async function expandProfile(node, options) {
|
|
|
7480
7480
|
...selected.reasoningEffort === void 0 ? {} : { reasoningEffort: selected.reasoningEffort }
|
|
7481
7481
|
};
|
|
7482
7482
|
}
|
|
7483
|
-
if (node.needs)
|
|
7483
|
+
if (node.needs) {
|
|
7484
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7485
|
+
profile.connections = [...node.profile?.connections ?? [], ...connections].filter((connection) => {
|
|
7486
|
+
let key;
|
|
7487
|
+
try {
|
|
7488
|
+
key = canonicalCandidateDigest(connection);
|
|
7489
|
+
} catch {
|
|
7490
|
+
return true;
|
|
7491
|
+
}
|
|
7492
|
+
if (seen.has(key)) return false;
|
|
7493
|
+
seen.add(key);
|
|
7494
|
+
return true;
|
|
7495
|
+
});
|
|
7496
|
+
}
|
|
7484
7497
|
const parsed = agentProfileSchema.safeParse(profile);
|
|
7485
7498
|
if (!parsed.success) refuse$2(`node ${node.id} has an invalid profile: ${parsed.error.message}`);
|
|
7486
7499
|
assertExecutableAgentProfile(parsed.data, `loadGraphFile node ${node.id}`);
|
|
@@ -10032,4 +10045,4 @@ function tail(s) {
|
|
|
10032
10045
|
}
|
|
10033
10046
|
export { runBenchmark as $, renderLeaderboardHtml as $t, searchPresets as A, sanitizeMcpToolSchema as At, graphFromSessionFacts as B, assertDeclaredCheck as Bt, withUntrackedArtifacts as C, harvestCorpus as Ct, SEARCH_SPEC_CORRELATION_KEY as D, connectStdioMcp as Dt, createFencedSqlRunContext as E, McpSpawnFault as Et, loadProfile as F, secretEnvOfMcpServer as Ft, chatWorkerSeam as G, readDeclaredCheck as Gt, loadGraphFile as H, declaredCheckDeliverable as Ht, pickBestProfile as I, inlineSandboxClient as It, strategyTournament as J, deterministicCompletion as Jt, createChatSessionStore as K, runIsolatedCheck as Kt, profileRegistry as L, loopCampaignDispatch as Lt, connectRemoteSupervisor as M, mcpSecretEnvMetadataKey as Mt, connectRemoteSupervisorControl as N, resolveMcpServerLaunch as Nt, assertSearchSpec as O, materializeLocalMcp as Ot, bestProfileFor as P, resolveSecretEnv as Pt, printBenchmarkReport as Q, pairwiseSignificance as Qt, profileRunsForName as R, loopDispatch as Rt, copyUntrackedIntoClone as S, HarvestError as St, validateStoredGraph as T, resolveSandboxClient as Tt, graphDesignerExtraTools as U, declaredCheckDigest as Ut, GraphFileResolutionError as V, checkProgramDigest as Vt, chatTransportExecutor as W, declaredCheckJudge as Wt, openSandboxRun as X, stopSentinel as Xt, SandboxRunAbortError as Y, sentinelCompletion as Yt, createS3PrivateCasStore as Z, leaderboard as Zt, NOTE_MAX_CHARS as _, buildSteerContext as _t, localShell as a, FileCorpus as at, composeWorkerEvidence as b, observationFromRegistry as bt, createVerifierEnvironment as c, fanout as ct, harvestSurfaceDiffs as d, panel as dt, renderLeaderboardMarkdown as en, createPrivateCasArtifactPort as et, analystsFromRegistry as f, pipeline as ft, EVIDENCE_MAX_CHARS as g, assertTraceDerivedFindings as gt, runCoderChecks as h, widen as ht, jjWorkspace as i, openSqlRunStore as in, runPersonified as it, searchSpecDigest as j, envKeyProvider as jt, compileSearchSpec as k, createMcpEnvironment as kt, boxSurfaceReader as l, flatWidenGate as lt, worktreeFanout as m, verify as mt, makeFinding$1 as n, renderPairwiseMarkdown as nn, trajectoryReport as nt, runInWorkspace as o, InMemoryCorpus as ot, failuresAnalyst as p, selectValidWinner as pt, runStrategyEvolution as q, completionAuthorizes as qt, gitWorkspace as r, SqlRunOwnershipError as rn, definePersona as rt, createWaterfallCollector as s, renderCorpusToInstructions as st, computeFindingId$1 as t, renderLeaderboardSvg as tn, equalKOnCost as tt, fsSurfaceReader as u, loopUntil as ut, VERIFY_TAIL_CHARS as v, createScopeAnalyst as vt, analyzeTrace as w, defineLeaderboard as wt, settledWorkerOut as x, inProcessSandboxClient as xt, closingWorkerNote as y, registryScopeAnalyst as yt, recordProfileRun as z, superviseDispatch as zt };
|
|
10034
10047
|
|
|
10035
|
-
//# sourceMappingURL=runtime-
|
|
10048
|
+
//# sourceMappingURL=runtime-DVwFHx7i.js.map
|