@tangle-network/agent-runtime 0.314.1 → 0.316.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 +6 -0
- package/dist/{activation-BpMnOlw5.d.ts → activation-BFDmjaKP.d.ts} +2 -2
- package/dist/{activation-Ci20OAsG.js → activation-CvdE2HIU.js} +3 -3
- package/dist/{activation-Ci20OAsG.js.map → activation-CvdE2HIU.js.map} +1 -1
- package/dist/agent.d.ts +2 -1
- package/dist/agent.js +2 -2
- package/dist/{bundle-BK3XBY6q.js → bundle-RgHpAFDY.js} +2 -2
- package/dist/{bundle-BK3XBY6q.js.map → bundle-RgHpAFDY.js.map} +1 -1
- package/dist/candidate-execution/index.js +5 -5
- package/dist/{coordination-driver-CyJF37L8.js → coordination-driver-DGhN8GO9.js} +3 -3
- package/dist/{coordination-driver-CyJF37L8.js.map → coordination-driver-DGhN8GO9.js.map} +1 -1
- package/dist/{delegate-CTezpiM2.js → delegate-B5pmSbQa.js} +2 -2
- package/dist/{delegate-CTezpiM2.js.map → delegate-B5pmSbQa.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +4 -4
- package/dist/{graph-DGDrO_ZW.js → graph-G0j1ysqe.js} +4 -4
- package/dist/{graph-DGDrO_ZW.js.map → graph-G0j1ysqe.js.map} +1 -1
- package/dist/{improvement-cycle-DReg-Qi4.js → improvement-cycle-D7yR6GC2.js} +6 -6
- package/dist/{improvement-cycle-DReg-Qi4.js.map → improvement-cycle-D7yR6GC2.js.map} +1 -1
- package/dist/{index-B89bMKhD.d.ts → index-CUh40yUJ.d.ts} +13 -90
- package/dist/index.d.ts +4 -4
- package/dist/index.js +9 -9
- package/dist/integrations-DopfCC2a.d.ts +190 -0
- package/dist/integrations-dFi-ALk7.js +132 -0
- package/dist/integrations-dFi-ALk7.js.map +1 -0
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +7 -7
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-eoycPwY3.js → loop-runner-bin-CFVX4oi0.js} +3 -3
- package/dist/{loop-runner-bin-eoycPwY3.js.map → loop-runner-bin-CFVX4oi0.js.map} +1 -1
- package/dist/{loop-runner-bin-BM1in-RT.d.ts → loop-runner-bin-DQKLUt0l.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +74 -33
- package/dist/mcp/index.js +129 -6
- package/dist/mcp/index.js.map +1 -1
- package/dist/{openai-tools-xPO6dzf4.d.ts → openai-tools-u3gWBi3x.d.ts} +2 -2
- package/dist/placement.d.ts +132 -0
- package/dist/placement.js +319 -0
- package/dist/placement.js.map +1 -0
- package/dist/platform.d.ts +1 -188
- package/dist/platform.js +1 -129
- package/dist/platform.js.map +1 -1
- package/dist/{prepare-8A1CAWG8.js → prepare-CD9kR0gS.js} +3 -3
- package/dist/{prepare-8A1CAWG8.js.map → prepare-CD9kR0gS.js.map} +1 -1
- package/dist/{profile-BhQShsM1.js → profile-CHXYmpGd.js} +2 -2
- package/dist/{profile-BhQShsM1.js.map → profile-CHXYmpGd.js.map} +1 -1
- package/dist/profile-materialization-Cca615eu.d.ts +90 -0
- package/dist/profiles.d.ts +1 -1
- package/dist/{protected-model-port-ug52OmvB.js → protected-model-port-B0pHd65J.js} +4 -4
- package/dist/{protected-model-port-ug52OmvB.js.map → protected-model-port-B0pHd65J.js.map} +1 -1
- package/dist/{provision-supervisor-B6D3XRbL.js → provision-supervisor-BQLLrUtn.js} +4 -4
- package/dist/{provision-supervisor-B6D3XRbL.js.map → provision-supervisor-BQLLrUtn.js.map} +1 -1
- package/dist/{runtime-NlIVxRXu.js → runtime-B9BOFyEp.js} +10 -9
- package/dist/runtime-B9BOFyEp.js.map +1 -0
- package/dist/{search-executor-DFs-79tK.js → search-executor-B5ZVFsDV.js} +3 -3
- package/dist/{search-executor-DFs-79tK.js.map → search-executor-B5ZVFsDV.js.map} +1 -1
- package/dist/{server-B8ubWXpW.js → server-TwpH9aik.js} +4 -4
- package/dist/{server-B8ubWXpW.js.map → server-TwpH9aik.js.map} +1 -1
- package/dist/{supervise-BE9ta8bl.js → supervise-CU6AuxWY.js} +119 -29
- package/dist/supervise-CU6AuxWY.js.map +1 -0
- package/dist/{supervisor-DmSuKksw.js → supervisor-CbFyf48U.js} +3 -3
- package/dist/{supervisor-DmSuKksw.js.map → supervisor-CbFyf48U.js.map} +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +14 -14
- package/dist/tool-loop.d.ts +35 -5
- package/dist/tool-loop.js +48 -21
- package/dist/tool-loop.js.map +1 -1
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/workspace-store/index.d.ts +206 -0
- package/dist/workspace-store/index.js +855 -0
- package/dist/workspace-store/index.js.map +1 -0
- package/dist/{workspace-streams-BEvSX97P.js → workspace-streams-DkijayqX.js} +16 -3
- package/dist/workspace-streams-DkijayqX.js.map +1 -0
- package/package.json +14 -4
- package/skills/profile-authoring/SKILL.md +114 -171
- package/dist/runtime-NlIVxRXu.js.map +0 -1
- package/dist/supervise-BE9ta8bl.js.map +0 -1
- package/dist/workspace-streams-BEvSX97P.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop-runner-bin-eoycPwY3.js","names":[],"sources":["../src/loop-runner.ts","../src/loop-runner-bin.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 {@link 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 */\nexport interface 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. */\nexport interface 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 */\nexport interface 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. */\nexport interface 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","#!/usr/bin/env node\n/**\n *\n * `agent-runtime-loop` — the schedulable entrypoint for the configured\n * delegated loop-runner. A cron job / routine / Makefile target invokes:\n *\n * agent-runtime-loop --mode research --config ./loops.config.js\n *\n * The config module wires the registry (with full access to env / creds —\n * which is why the deps live there, not in this generic bin). It must default-\n * export a `DelegatedLoopRegistry`, or a `() => DelegatedLoopRegistry | Promise<…>`.\n * The bin runs the selected mode, prints the `DelegatedLoopResult` as JSON, and\n * exits 0 on `ok`, 1 on a recorded failure, 2 on a usage/config error.\n *\n * @experimental\n */\n\nimport {\n DELEGATED_LOOP_MODES,\n type DelegatedLoopMode,\n type DelegatedLoopRegistry,\n type DelegatedLoopResult,\n isDelegatedLoopMode,\n runDelegatedLoop,\n} from './loop-runner'\n\n/** @experimental Parsed CLI invocation. */\nexport interface LoopRunnerCliArgs {\n mode: string\n /** Loads the registry — the bin wires this from `--config`; tests inject a stub. */\n loadRegistry: () => Promise<DelegatedLoopRegistry> | DelegatedLoopRegistry\n now?: () => number\n}\n\n/** @experimental */\nexport interface LoopRunnerCliResult {\n exitCode: number\n result?: DelegatedLoopResult\n error?: string\n}\n\n/**\n *\n * Pure CLI core (no process / argv / IO) so it's unit-testable: validate the\n * mode, load the registry, dispatch, map to an exit code (0 ok / 1 failed /\n * 2 usage). Exported for embedding in custom runners + tests.\n *\n * @experimental\n */\nexport async function runLoopRunnerCli(args: LoopRunnerCliArgs): Promise<LoopRunnerCliResult> {\n if (!isDelegatedLoopMode(args.mode)) {\n return {\n exitCode: 2,\n error: `unknown mode '${args.mode}' (expected one of: ${DELEGATED_LOOP_MODES.join(', ')})`,\n }\n }\n let registry: DelegatedLoopRegistry\n try {\n registry = await args.loadRegistry()\n } catch (err) {\n return { exitCode: 2, error: `failed to load registry: ${errMsg(err)}` }\n }\n if (!registry[args.mode]) {\n return {\n exitCode: 2,\n error: `config registers no runner for mode '${args.mode}' (registered: ${\n Object.keys(registry).join(', ') || 'none'\n })`,\n }\n }\n // runDelegatedLoop throws only on a missing runner (guarded above); a failing\n // engine is captured as { ok: false } → exit 1, not a crash.\n const result = await runDelegatedLoop(args.mode as DelegatedLoopMode, registry, {\n ...(args.now ? { now: args.now } : {}),\n })\n return { exitCode: result.ok ? 0 : 1, result }\n}\n\n/** Parse `--mode X --config Y` from an argv tail (`process.argv.slice(2)`). */\nexport function parseLoopRunnerArgv(argv: string[]): { mode?: string; config?: string } {\n const out: { mode?: string; config?: string } = {}\n for (let i = 0; i < argv.length; i += 1) {\n const a = argv[i]\n if (a === '--mode') out.mode = argv[++i]\n else if (a === '--config') out.config = argv[++i]\n else if (a?.startsWith('--mode=')) out.mode = a.slice('--mode='.length)\n else if (a?.startsWith('--config=')) out.config = a.slice('--config='.length)\n }\n return out\n}\n\n/** Normalize a config module's default export → a registry. */\nfunction resolveRegistry(mod: unknown): DelegatedLoopRegistry {\n const def = (mod as { default?: unknown })?.default ?? mod\n const value = typeof def === 'function' ? (def as () => unknown)() : def\n return value as DelegatedLoopRegistry\n}\n\nfunction errMsg(err: unknown): string {\n return err instanceof Error ? err.message : String(err)\n}\n\n/** The argv → IO → exit shell. Kept thin; logic lives in `runLoopRunnerCli`. */\nasync function main(): Promise<void> {\n const { mode, config } = parseLoopRunnerArgv(process.argv.slice(2))\n if (!mode || !config) {\n process.stderr.write(\n 'usage: agent-runtime-loop --mode <mode> --config <module>\\n' +\n ` modes: ${DELEGATED_LOOP_MODES.join(' | ')}\\n` +\n ' config: a JS/TS module default-exporting a DelegatedLoopRegistry (or a factory)\\n',\n )\n process.exit(2)\n }\n const { pathToFileURL } = await import('node:url')\n const { resolve } = await import('node:path')\n const cli = await runLoopRunnerCli({\n mode,\n loadRegistry: async () => resolveRegistry(await import(pathToFileURL(resolve(config)).href)),\n })\n process.stdout.write(`${JSON.stringify(cli.result ?? { error: cli.error }, null, 2)}\\n`)\n if (cli.error) process.stderr.write(`${cli.error}\\n`)\n process.exit(cli.exitCode)\n}\n\n// Run only when executed as the bin — never when imported for the testable\n// core, and never when bundled into a runtime that has no `process.argv`\n// (e.g. Cloudflare Workers, where `process` is a shim without `argv`). Reading\n// `process.argv[1]` directly would throw at module load there; `process.argv?.`\n// keeps the guard a no-op instead of crashing the Worker on startup.\nconst invokedScript = typeof process !== 'undefined' ? process.argv?.[1] : undefined\nif (invokedScript && /loop-runner-bin\\.(js|ts|mjs)$/.test(invokedScript)) {\n void main()\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,IAA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D,MAAM,MAAO,KAA+B,WAAW;CAEvD,OADc,OAAO,QAAQ,aAAc,IAAsB,IAAI;AAEvE;AAEA,SAAS,OAAO,KAAsB;CACpC,OAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AACxD;;AAGA,eAAe,OAAsB;CACnC,MAAM,EAAE,MAAM,WAAW,oBAAoB,QAAQ,KAAK,MAAM,CAAC,CAAC;CAClE,IAAI,CAAC,QAAQ,CAAC,QAAQ;EACpB,QAAQ,OAAO,MACb;WACc,qBAAqB,KAAK,KAAK,EAAE;CAEjD;EACA,QAAQ,KAAK,CAAC;CAChB;CACA,MAAM,EAAE,kBAAkB,MAAM,OAAO;CACvC,MAAM,EAAE,YAAY,MAAM,OAAO;CACjC,MAAM,MAAM,MAAM,iBAAiB;EACjC;EACA,cAAc,YAAY,gBAAgB,MAAM,OAAO,cAAc,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK;CAC7F,CAAC;CACD,QAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,IAAI,UAAU,EAAE,OAAO,IAAI,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG;CACvF,IAAI,IAAI,OAAO,QAAQ,OAAO,MAAM,GAAG,IAAI,MAAM,GAAG;CACpD,QAAQ,KAAK,IAAI,QAAQ;AAC3B;AAOA,MAAM,gBAAgB,OAAO,YAAY,cAAc,QAAQ,OAAO,KAAK,KAAA;AAC3E,IAAI,iBAAiB,gCAAgC,KAAK,aAAa,GACrE,KAAU"}
|
|
1
|
+
{"version":3,"file":"loop-runner-bin-CFVX4oi0.js","names":[],"sources":["../src/loop-runner.ts","../src/loop-runner-bin.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 {@link 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 */\nexport interface 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. */\nexport interface 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 */\nexport interface 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. */\nexport interface 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","#!/usr/bin/env node\n/**\n *\n * `agent-runtime-loop` — the schedulable entrypoint for the configured\n * delegated loop-runner. A cron job / routine / Makefile target invokes:\n *\n * agent-runtime-loop --mode research --config ./loops.config.js\n *\n * The config module wires the registry (with full access to env / creds —\n * which is why the deps live there, not in this generic bin). It must default-\n * export a `DelegatedLoopRegistry`, or a `() => DelegatedLoopRegistry | Promise<…>`.\n * The bin runs the selected mode, prints the `DelegatedLoopResult` as JSON, and\n * exits 0 on `ok`, 1 on a recorded failure, 2 on a usage/config error.\n *\n * @experimental\n */\n\nimport {\n DELEGATED_LOOP_MODES,\n type DelegatedLoopMode,\n type DelegatedLoopRegistry,\n type DelegatedLoopResult,\n isDelegatedLoopMode,\n runDelegatedLoop,\n} from './loop-runner'\n\n/** @experimental Parsed CLI invocation. */\nexport interface LoopRunnerCliArgs {\n mode: string\n /** Loads the registry — the bin wires this from `--config`; tests inject a stub. */\n loadRegistry: () => Promise<DelegatedLoopRegistry> | DelegatedLoopRegistry\n now?: () => number\n}\n\n/** @experimental */\nexport interface LoopRunnerCliResult {\n exitCode: number\n result?: DelegatedLoopResult\n error?: string\n}\n\n/**\n *\n * Pure CLI core (no process / argv / IO) so it's unit-testable: validate the\n * mode, load the registry, dispatch, map to an exit code (0 ok / 1 failed /\n * 2 usage). Exported for embedding in custom runners + tests.\n *\n * @experimental\n */\nexport async function runLoopRunnerCli(args: LoopRunnerCliArgs): Promise<LoopRunnerCliResult> {\n if (!isDelegatedLoopMode(args.mode)) {\n return {\n exitCode: 2,\n error: `unknown mode '${args.mode}' (expected one of: ${DELEGATED_LOOP_MODES.join(', ')})`,\n }\n }\n let registry: DelegatedLoopRegistry\n try {\n registry = await args.loadRegistry()\n } catch (err) {\n return { exitCode: 2, error: `failed to load registry: ${errMsg(err)}` }\n }\n if (!registry[args.mode]) {\n return {\n exitCode: 2,\n error: `config registers no runner for mode '${args.mode}' (registered: ${\n Object.keys(registry).join(', ') || 'none'\n })`,\n }\n }\n // runDelegatedLoop throws only on a missing runner (guarded above); a failing\n // engine is captured as { ok: false } → exit 1, not a crash.\n const result = await runDelegatedLoop(args.mode as DelegatedLoopMode, registry, {\n ...(args.now ? { now: args.now } : {}),\n })\n return { exitCode: result.ok ? 0 : 1, result }\n}\n\n/** Parse `--mode X --config Y` from an argv tail (`process.argv.slice(2)`). */\nexport function parseLoopRunnerArgv(argv: string[]): { mode?: string; config?: string } {\n const out: { mode?: string; config?: string } = {}\n for (let i = 0; i < argv.length; i += 1) {\n const a = argv[i]\n if (a === '--mode') out.mode = argv[++i]\n else if (a === '--config') out.config = argv[++i]\n else if (a?.startsWith('--mode=')) out.mode = a.slice('--mode='.length)\n else if (a?.startsWith('--config=')) out.config = a.slice('--config='.length)\n }\n return out\n}\n\n/** Normalize a config module's default export → a registry. */\nfunction resolveRegistry(mod: unknown): DelegatedLoopRegistry {\n const def = (mod as { default?: unknown })?.default ?? mod\n const value = typeof def === 'function' ? (def as () => unknown)() : def\n return value as DelegatedLoopRegistry\n}\n\nfunction errMsg(err: unknown): string {\n return err instanceof Error ? err.message : String(err)\n}\n\n/** The argv → IO → exit shell. Kept thin; logic lives in `runLoopRunnerCli`. */\nasync function main(): Promise<void> {\n const { mode, config } = parseLoopRunnerArgv(process.argv.slice(2))\n if (!mode || !config) {\n process.stderr.write(\n 'usage: agent-runtime-loop --mode <mode> --config <module>\\n' +\n ` modes: ${DELEGATED_LOOP_MODES.join(' | ')}\\n` +\n ' config: a JS/TS module default-exporting a DelegatedLoopRegistry (or a factory)\\n',\n )\n process.exit(2)\n }\n const { pathToFileURL } = await import('node:url')\n const { resolve } = await import('node:path')\n const cli = await runLoopRunnerCli({\n mode,\n loadRegistry: async () => resolveRegistry(await import(pathToFileURL(resolve(config)).href)),\n })\n process.stdout.write(`${JSON.stringify(cli.result ?? { error: cli.error }, null, 2)}\\n`)\n if (cli.error) process.stderr.write(`${cli.error}\\n`)\n process.exit(cli.exitCode)\n}\n\n// Run only when executed as the bin — never when imported for the testable\n// core, and never when bundled into a runtime that has no `process.argv`\n// (e.g. Cloudflare Workers, where `process` is a shim without `argv`). Reading\n// `process.argv[1]` directly would throw at module load there; `process.argv?.`\n// keeps the guard a no-op instead of crashing the Worker on startup.\nconst invokedScript = typeof process !== 'undefined' ? process.argv?.[1] : undefined\nif (invokedScript && /loop-runner-bin\\.(js|ts|mjs)$/.test(invokedScript)) {\n void main()\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;;;;;;;;;;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,SAAS,EAAE,MAAM,CAAkB;CAC9E;CACA,OAAO;AACT;;AAGA,SAAS,gBAAgB,KAAqC;CAC5D,MAAM,MAAO,KAA+B,WAAW;CAEvD,OADc,OAAO,QAAQ,aAAc,IAAsB,IAAI;AAEvE;AAEA,SAAS,OAAO,KAAsB;CACpC,OAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AACxD;;AAGA,eAAe,OAAsB;CACnC,MAAM,EAAE,MAAM,WAAW,oBAAoB,QAAQ,KAAK,MAAM,CAAC,CAAC;CAClE,IAAI,CAAC,QAAQ,CAAC,QAAQ;EACpB,QAAQ,OAAO,MACb;WACc,qBAAqB,KAAK,KAAK,EAAE;CAEjD;EACA,QAAQ,KAAK,CAAC;CAChB;CACA,MAAM,EAAE,kBAAkB,MAAM,OAAO;CACvC,MAAM,EAAE,YAAY,MAAM,OAAO;CACjC,MAAM,MAAM,MAAM,iBAAiB;EACjC;EACA,cAAc,YAAY,gBAAgB,MAAM,OAAO,cAAc,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK;CAC7F,CAAC;CACD,QAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,IAAI,UAAU,EAAE,OAAO,IAAI,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG;CACvF,IAAI,IAAI,OAAO,QAAQ,OAAO,MAAM,GAAG,IAAI,MAAM,GAAG;CACpD,QAAQ,KAAK,IAAI,QAAQ;AAC3B;AAOA,MAAM,gBAAgB,OAAO,YAAY,cAAc,QAAQ,OAAO,KAAK,KAAA;AAC3E,IAAI,iBAAiB,gCAAgC,KAAK,aAAa,GACrE,KAAU"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $o as WinnerStrategy, C as AuthoredHarness, St as WorktreePatchArtifact,
|
|
1
|
+
import { $o as WinnerStrategy, C as AuthoredHarness, St as WorktreePatchArtifact, Zd as Budget, w as WorktreeFanoutOptions } from "./index-CUh40yUJ.js";
|
|
2
2
|
import { d as RunAnalystLoopOpts, f as RunAnalystLoopResult } from "./types-zWfqDjeL.js";
|
|
3
3
|
import { n as FactCandidate, t as CreateKbGateOptions } from "./kb-gate-C8z2juK8.js";
|
|
4
4
|
import { AgentProfile } from "@tangle-network/agent-interface";
|
|
@@ -161,4 +161,4 @@ declare function parseLoopRunnerArgv(argv: string[]): {
|
|
|
161
161
|
};
|
|
162
162
|
//#endregion
|
|
163
163
|
export { researchLoopRunner as _, DELEGATED_LOOP_MODES as a, DelegatedLoopResult as c, ResearchLoopRunnerOptions as d, RunDelegatedLoopOptions as f, isDelegatedLoopMode as g, auditLoopRunner as h, runLoopRunnerCli as i, DelegatedLoopRunner as l, WorktreeLoopRunnerOptions as m, LoopRunnerCliResult as n, DelegatedLoopMode as o, VetoedFact as p, parseLoopRunnerArgv as r, DelegatedLoopRegistry as s, LoopRunnerCliArgs as t, ResearchLoopResult as u, runDelegatedLoop as v, worktreeLoopRunner as y };
|
|
164
|
-
//# sourceMappingURL=loop-runner-bin-
|
|
164
|
+
//# sourceMappingURL=loop-runner-bin-DQKLUt0l.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as runLoopRunnerCli, n as LoopRunnerCliResult, r as parseLoopRunnerArgv, t as LoopRunnerCliArgs } from "./loop-runner-bin-
|
|
1
|
+
import { i as runLoopRunnerCli, n as LoopRunnerCliResult, r as parseLoopRunnerArgv, t as LoopRunnerCliArgs } from "./loop-runner-bin-DQKLUt0l.js";
|
|
2
2
|
export { LoopRunnerCliArgs, LoopRunnerCliResult, parseLoopRunnerArgv, runLoopRunnerCli };
|
package/dist/loop-runner-bin.js
CHANGED
package/dist/mcp/bin.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Rr as readTraceContextFromEnv } from "../supervisor-
|
|
2
|
+
import { Rr as readTraceContextFromEnv } from "../supervisor-CbFyf48U.js";
|
|
3
3
|
import { i as ConfigError } from "../errors-DodWX-cb.js";
|
|
4
|
-
import { s as supervisorInstructions } from "../delegate-
|
|
5
|
-
import { _ as FileDelegationStore, n as createMcpServer, p as DelegationTaskQueue } from "../server-
|
|
4
|
+
import { s as supervisorInstructions } from "../delegate-B5pmSbQa.js";
|
|
5
|
+
import { _ as FileDelegationStore, n as createMcpServer, p as DelegationTaskQueue } from "../server-TwpH9aik.js";
|
|
6
6
|
//#region src/mcp/delegate-supervisor-provisioning.ts
|
|
7
7
|
function trimmed(value) {
|
|
8
8
|
const v = value?.trim();
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { $b as
|
|
1
|
+
import { $b as DelegationTraceCaps, $v as FleetWorkspaceExecutorOptions, $y as delegationProfiles, Ah as DelegateArgs, Am as DefinedAnalystRecord, Ay as DelegateResearchArgs, Bm as ManagerWake, Bv as CoderDelegate, By as DelegationHistoryEntry, Ch as McpServer, Cv as harnessSupportsReasoningEffort, Cy as SubmitOutput, Dh as DELEGATE_DESCRIPTION, Dy as DelegateCodeResult, Eh as createMcpServer, Em as CoordinationEvent, Ev as runLocalHarness, Ey as DelegateCodeConfig, Fh as validateDelegateArgs, Fm as EscalateQuestion, Fx as McpToolAnnotations, Fy as DelegateUiAuditResult, Gm as QuestionEscalationTarget, Gv as DetachedWinnerSelection, Gy as DelegationStatus, Hm as QuestionDecision, Hv as CoderReviewer, Hy as DelegationProfile, Im as EventAcknowledgement, Iv as FeedbackEvent, Ix as McpToolDescriptor, Iy as DelegateUiAuditRoute, Jm as QuestionPolicy, Jv as coderTaskFromArgs, Jy as FeedbackRating, Km as QuestionLevel, Kv as SettleDetachedCoderTurnOptions, Ky as DelegationStatusArgs, Lm as LeadMessage, Lv as FeedbackStore, Lx as McpTransport, Ly as DelegationError, Mh as DelegateHandlerOptions, Mm as DownMessageDeliveryAttempt, My as DelegateResearchResult, Nh as DelegateResult, Nm as DownMessageDeliveryOutcome, Nx as JsonRpcMessage, Ny as DelegateUiAuditArgs, Oh as DELEGATE_INPUT_SCHEMA, Om as CoordinationTools, Oy as DelegateFeedbackArgs, Ph as createDelegateHandler, Pm as DownMessageEvent, Px as JsonRpcResponse, Py as DelegateUiAuditConfig, Qb as DELEGATION_TRACE_MAX_SPANS, Qv as FleetHandle, Qy as UiAuditorDelegationOutput, Rm as MakeWorkerAgent, Rv as InMemoryFeedbackStore, Ry as DelegationFeedbackSnapshot, Sh as resolveSpawnResourcePaths, Sm as AwaitWakeInput, Sv as RunLocalHarnessOptions, Sy as SubmitInput, Th as createInProcessTransport, Tv as parseCodexTokenUsage, Ty as DelegateCodeArgs, Um as QuestionEscalationOutcome, Uv as DelegateRunCtx, Uy as DelegationProgress, Vm as Question, Vv as CoderReview, Vy as DelegationHistoryResult, Wm as QuestionEscalationRecord, Wv as DetachedSessionDelegateOptions, Wy as DelegationResultPayload, Xb as CappedDelegationTrace, Xm as QuestionUrgency, Xv as settleDetachedCoderTurn, Xy as ResearchOutputShape, Ym as QuestionRecord, Yv as detachedSessionDelegate, Yy as FeedbackRefersTo, ZC as LoopSandboxPlacement, Zb as DELEGATION_TRACE_MAX_BYTES, Zm as SettledWorker, Zv as DelegationExecutor, Zy as UiAuditLensFilter, _b as createPropagatingTraceEmitter, _h as SpawnResourceBytes, _v as CodexTokenUsage, _y as DelegationResumeDriver, ab as UiLens, ah as WorkerSpawnContext, ax as createDelegationTraceCollector, ay as DetachedTurnResumeDriverOptions, bb as traceContextToEnv, bh as environmentReader, bm as AuthorizeDownMessage, bv as LocalHarness, by as DelegationTaskQueue, cv as DiffResult, cx as DelegationStore, cy as RunDetachedTurnOptions, dm as AnalystDefinitionIssue, dv as WorktreeHandle, dx as InMemoryDelegationStore, dy as formatDetachedSessionRef, ex as DelegationTraceCollector, ey as SiblingSandboxExecutorOptions, fh as parseAuthoredAnalystDefinition, fm as AnalystFindingEvent, fv as captureWorktreeDiff, fx as CoderOutput, fy as parseDetachedSessionRef, gb as TraceContext, gh as SPAWN_RESOURCE_PATH_MAX_BYTES, gm as AnalystToolGroupName, gv as CodexExecutionPolicy, gy as DelegationResumeContext, hh as ResolvedSpawnResourcePath, hm as AnalystRegistry, hv as CodexExecutionEvidence, hy as DelegationRecord, ix as composeLoopTraceEmitters, iy as DetachedTurn, jh as DelegateError, jm as DownMessageAuthorizationInput, jy as DelegateResearchConfig, kh as DELEGATE_TOOL_NAME, km as CoordinationToolsOptions, ky as DelegateFeedbackResult, lh as createCoordinationTools, lm as ANALYST_DEFINITION_BOUNDS, lv as GitRunner, lx as FileDelegationStore, ly as createDetachedTurnResumeDriver, mh as ResolveSpawnResourcePathsResult, mv as removeWorktree, my as DelegationArgs, nx as buildDelegationTraceSpans, ny as createSiblingSandboxExecutor, oh as WorkerWatchOptions, ov as CreateWorktreeOptions, ox as DelegationPersistenceError, oy as DriveTurnCapableBox, ph as questionEscalationTargets, pm as AnalystKind, pv as createWorktree, py as runDetachedTurn, qm as QuestionOption, qv as UiAuditorDelegate, qy as DelegationStatusResult, rh as ToolOutcomeEvent, rx as capDelegationTrace, ry as DetachedSessionRefParts, sh as analystToolGroupNames, sv as DiffOptions, sx as DelegationStateCorruptError, sy as DriveTurnTick, tx as DelegationTraceSpan, ty as createFleetWorkspaceExecutor, ub as ResearchSource, uh as downMessageRefusalReasons, um as AnalystAssignmentRecord, uv as RemoveWorktreeOptions, ux as FileDelegationStoreOptions, uy as detachedTurnEvents, vb as mergeTraceEnv, vh as SpawnResourceRead, vm as AuthoredAnalystDefinition, vv as DEFAULT_LOCAL_HARNESS, vy as DelegationResumeTick, wh as McpServerOptions, wm as ContinuationInstruction, wv as localHarnessExecutable, wy as hashIdempotencyInput, xh as hostDirectoryReader, xm as AuthorizedDownMessage, xv as LocalHarnessResult, xy as DelegationTaskQueueOptions, yb as readTraceContextFromEnv, yh as SpawnResourceReader, ym as AuthoredAnalystLimits, yv as LOCAL_HARNESSES, yy as DelegationRunContext, zm as ManagerReentryState, zv as eventToSnapshot, zy as DelegationHistoryArgs } from "../index-CUh40yUJ.js";
|
|
2
2
|
import { a as KbGateResult, i as FactJudgeVerdict, n as FactCandidate, o as createKbGate, r as FactJudge, t as CreateKbGateOptions } from "../kb-gate-C8z2juK8.js";
|
|
3
|
-
import { n as mcpToolsForRuntimeMcpSubset, t as mcpToolsForRuntimeMcp } from "../openai-tools-
|
|
3
|
+
import { n as mcpToolsForRuntimeMcpSubset, t as mcpToolsForRuntimeMcp } from "../openai-tools-u3gWBi3x.js";
|
|
4
|
+
import { l as PlatformConnection } from "../integrations-DopfCC2a.js";
|
|
4
5
|
import { AgentProfileMcpServer, HarnessType } from "@tangle-network/agent-interface";
|
|
5
6
|
//#region src/mcp/codex-diagnostics.d.ts
|
|
6
7
|
/** Bounded, credential-redacted process context attached when reproducible Codex output fails
|
|
@@ -51,6 +52,76 @@ declare function harnessNativeToolNames(harness: HarnessType): ReadonlyArray<str
|
|
|
51
52
|
*/
|
|
52
53
|
declare function collidesWithHarnessNativeTool(name: string): ReadonlyArray<SourcedHarness>;
|
|
53
54
|
//#endregion
|
|
55
|
+
//#region src/mcp/tool-server.d.ts
|
|
56
|
+
/**
|
|
57
|
+
* Protocol versions this server speaks, newest first. `initialize` answers with
|
|
58
|
+
* the client's requested version when it is listed here, and otherwise with
|
|
59
|
+
* `PROTOCOL_VERSION` (2024-11-05), which every client that speaks 2024-11-05 accepts.
|
|
60
|
+
*/
|
|
61
|
+
declare const SUPPORTED_PROTOCOL_VERSIONS: readonly string[];
|
|
62
|
+
/** @experimental */
|
|
63
|
+
interface StdioToolServerOptions {
|
|
64
|
+
/** Server display name surfaced via `initialize`. */
|
|
65
|
+
serverName: string;
|
|
66
|
+
/** Server version surfaced via `initialize`. */
|
|
67
|
+
serverVersion: string;
|
|
68
|
+
/** The tools to serve. Duplicate names throw — a silent shadow would hide a tool. */
|
|
69
|
+
tools: readonly McpToolDescriptor[];
|
|
70
|
+
}
|
|
71
|
+
/** @experimental */
|
|
72
|
+
interface StdioToolServer {
|
|
73
|
+
/** Tools currently registered, keyed by name. */
|
|
74
|
+
readonly tools: ReadonlyMap<string, McpToolDescriptor>;
|
|
75
|
+
/** Handle a single parsed JSON-RPC message. Returns the response object (or `null` for notifications). */
|
|
76
|
+
handle(message: JsonRpcMessage): Promise<JsonRpcResponse | null>;
|
|
77
|
+
/** Drive the server on a stdio-shaped transport until `stop()` is called. */
|
|
78
|
+
serve(transport?: McpTransport): Promise<void>;
|
|
79
|
+
/** Stop a `serve` call. Subsequent requests are rejected. */
|
|
80
|
+
stop(): void;
|
|
81
|
+
}
|
|
82
|
+
/** Build the generic stdio JSON-RPC tool server. */
|
|
83
|
+
declare function createStdioToolServer(options: StdioToolServerOptions): StdioToolServer;
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/mcp/hub-server.d.ts
|
|
86
|
+
/** The substrate data providers whose Hub adapters become agent tools. */
|
|
87
|
+
declare const HUB_DATA_PROVIDER_KINDS: readonly string[];
|
|
88
|
+
/** The subset of `PlatformHubClient` this module needs — mocks plug in here. */
|
|
89
|
+
interface HubIntegrationClient {
|
|
90
|
+
listConnections(): Promise<PlatformConnection[]>;
|
|
91
|
+
exec(input: {
|
|
92
|
+
path: string;
|
|
93
|
+
input?: unknown;
|
|
94
|
+
connectionId?: string;
|
|
95
|
+
}): Promise<unknown>;
|
|
96
|
+
}
|
|
97
|
+
interface HubIntegrationToolsOptions {
|
|
98
|
+
client: HubIntegrationClient;
|
|
99
|
+
/** Provider kinds to expose. Defaults to `HUB_DATA_PROVIDER_KINDS`. */
|
|
100
|
+
providers?: readonly string[];
|
|
101
|
+
/** Also serve connections whose last health probe failed. Default false. */
|
|
102
|
+
includeUnhealthy?: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* One router tool per active Hub connection to a data provider. The tool
|
|
106
|
+
* handler never holds provider credentials — it execs through the Hub, which
|
|
107
|
+
* enforces the per-user action policy and writes the audit record.
|
|
108
|
+
*/
|
|
109
|
+
declare function hubIntegrationTools(options: HubIntegrationToolsOptions): Promise<McpToolDescriptor[]>;
|
|
110
|
+
interface CreateHubIntegrationToolServerOptions extends HubIntegrationToolsOptions {
|
|
111
|
+
/** Server display name surfaced via `initialize`. Default 'agent-hub-integrations'. */
|
|
112
|
+
serverName?: string;
|
|
113
|
+
/** Server version surfaced via `initialize`. Default '0'. */
|
|
114
|
+
serverVersion?: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Build the hub integration MCP server on the shared stdio JSON-RPC core —
|
|
118
|
+
* the same wire protocol every in-repo MCP server speaks. Serves zero tools
|
|
119
|
+
* when the caller has no active data-provider connections (a session without
|
|
120
|
+
* connections simply gets no database tools, mirroring the memory server's
|
|
121
|
+
* "no artifact, no server" discipline).
|
|
122
|
+
*/
|
|
123
|
+
declare function createHubIntegrationToolServer(options: CreateHubIntegrationToolServerOptions): Promise<StdioToolServer>;
|
|
124
|
+
//#endregion
|
|
54
125
|
//#region src/mcp/in-process-executor.d.ts
|
|
55
126
|
/** @experimental */
|
|
56
127
|
interface InProcessExecutorOptions {
|
|
@@ -97,36 +168,6 @@ interface InProcessExecutorDescribePlacement extends LoopSandboxPlacement {
|
|
|
97
168
|
*/
|
|
98
169
|
declare function createInProcessExecutor(options: InProcessExecutorOptions): DelegationExecutor;
|
|
99
170
|
//#endregion
|
|
100
|
-
//#region src/mcp/tool-server.d.ts
|
|
101
|
-
/**
|
|
102
|
-
* Protocol versions this server speaks, newest first. `initialize` answers with
|
|
103
|
-
* the client's requested version when it is listed here, and otherwise with
|
|
104
|
-
* `PROTOCOL_VERSION` (2024-11-05), which every client that speaks 2024-11-05 accepts.
|
|
105
|
-
*/
|
|
106
|
-
declare const SUPPORTED_PROTOCOL_VERSIONS: readonly string[];
|
|
107
|
-
/** @experimental */
|
|
108
|
-
interface StdioToolServerOptions {
|
|
109
|
-
/** Server display name surfaced via `initialize`. */
|
|
110
|
-
serverName: string;
|
|
111
|
-
/** Server version surfaced via `initialize`. */
|
|
112
|
-
serverVersion: string;
|
|
113
|
-
/** The tools to serve. Duplicate names throw — a silent shadow would hide a tool. */
|
|
114
|
-
tools: readonly McpToolDescriptor[];
|
|
115
|
-
}
|
|
116
|
-
/** @experimental */
|
|
117
|
-
interface StdioToolServer {
|
|
118
|
-
/** Tools currently registered, keyed by name. */
|
|
119
|
-
readonly tools: ReadonlyMap<string, McpToolDescriptor>;
|
|
120
|
-
/** Handle a single parsed JSON-RPC message. Returns the response object (or `null` for notifications). */
|
|
121
|
-
handle(message: JsonRpcMessage): Promise<JsonRpcResponse | null>;
|
|
122
|
-
/** Drive the server on a stdio-shaped transport until `stop()` is called. */
|
|
123
|
-
serve(transport?: McpTransport): Promise<void>;
|
|
124
|
-
/** Stop a `serve` call. Subsequent requests are rejected. */
|
|
125
|
-
stop(): void;
|
|
126
|
-
}
|
|
127
|
-
/** Build the generic stdio JSON-RPC tool server. */
|
|
128
|
-
declare function createStdioToolServer(options: StdioToolServerOptions): StdioToolServer;
|
|
129
|
-
//#endregion
|
|
130
171
|
//#region src/mcp/memory-server.d.ts
|
|
131
172
|
/** One row of agent memory: a crisp lesson/fact with provenance. */
|
|
132
173
|
interface MemoryItem {
|
|
@@ -444,5 +485,5 @@ interface DelegationStatusHandlerOptions {
|
|
|
444
485
|
/** Build the MCP tool handler that polls a `DelegationTaskQueue` for task status. @stable */
|
|
445
486
|
declare function createDelegationStatusHandler(options: DelegationStatusHandlerOptions): (raw: unknown) => Promise<DelegationStatusResult>;
|
|
446
487
|
//#endregion
|
|
447
|
-
export { ANALYST_DEFINITION_BOUNDS, type AgentMemorySpec, type AnalystAssignmentRecord, type AnalystDefinitionIssue, type AnalystFindingEvent, type AnalystKind, type AnalystRegistry, type AnalystToolGroupName, type AuthoredAnalystDefinition, type AuthoredAnalystLimits, type AuthorizeDownMessage, type AuthorizedDownMessage, type AwaitWakeInput, type CappedDelegationTrace, type CoderDelegate, type CoderOutput, type CoderReview, type CoderReviewer, CodexExecutionDiagnosticError, type CodexExecutionEvidence, type CodexExecutionFailureDiagnostic, type CodexExecutionPolicy, type CodexTokenUsage, type ContinuationInstruction, type CoordinationEvent, type CoordinationTools, type CoordinationToolsOptions, type CreateKbGateOptions, type CreateMemoryToolServerOptions, type CreateWorktreeOptions, DEFAULT_LOCAL_HARNESS, DELEGATE_DESCRIPTION, DELEGATE_FEEDBACK_DESCRIPTION, DELEGATE_FEEDBACK_INPUT_SCHEMA, DELEGATE_FEEDBACK_TOOL_NAME, DELEGATE_INPUT_SCHEMA, DELEGATE_TOOL_NAME, DELEGATE_UI_AUDIT_DESCRIPTION, DELEGATE_UI_AUDIT_INPUT_SCHEMA, DELEGATE_UI_AUDIT_TOOL_NAME, DELEGATION_HISTORY_DESCRIPTION, DELEGATION_HISTORY_INPUT_SCHEMA, DELEGATION_HISTORY_TOOL_NAME, DELEGATION_STATUS_DESCRIPTION, DELEGATION_STATUS_INPUT_SCHEMA, DELEGATION_STATUS_TOOL_NAME, DELEGATION_TRACE_MAX_BYTES, DELEGATION_TRACE_MAX_SPANS, type DefinedAnalystRecord, type DelegateArgs, type DelegateCodeArgs, type DelegateCodeConfig, type DelegateCodeResult, type DelegateError, type DelegateFeedbackArgs, type DelegateFeedbackHandlerOptions, type DelegateFeedbackResult, type DelegateHandlerOptions, type DelegateResearchArgs, type DelegateResearchConfig, type DelegateResearchResult, type DelegateResult, type DelegateRunCtx, type DelegateUiAuditArgs, type DelegateUiAuditConfig, type DelegateUiAuditHandlerOptions, type DelegateUiAuditResult, type DelegateUiAuditRoute, type DelegationArgs, type DelegationError, type DelegationExecutor, type DelegationFeedbackSnapshot, type DelegationHistoryArgs, type DelegationHistoryEntry, type DelegationHistoryHandlerOptions, type DelegationHistoryResult, DelegationPersistenceError, type DelegationProfile, type DelegationProgress, type DelegationRecord, type DelegationResultPayload, type DelegationResumeContext, type DelegationResumeDriver, type DelegationResumeTick, type DelegationRunContext, DelegationStateCorruptError, type DelegationStatus, type DelegationStatusArgs, type DelegationStatusHandlerOptions, type DelegationStatusResult, type DelegationStore, DelegationTaskQueue, type DelegationTaskQueueOptions, type DelegationTraceCaps, type DelegationTraceCollector, type DelegationTraceSpan, type DetachedSessionDelegateOptions, type DetachedSessionRefParts, type DetachedTurn, type DetachedTurnResumeDriverOptions, type DetachedWinnerSelection, type DiffOptions, type DiffResult, type DownMessageAuthorizationInput, type DownMessageDeliveryAttempt, type DownMessageDeliveryOutcome, type DownMessageEvent, type DriveTurnCapableBox, type DriveTurnTick, type EscalateQuestion, type EventAcknowledgement, type FactCandidate, type FactJudge, type FactJudgeVerdict, type FeedbackEvent, type FeedbackRating, type FeedbackRefersTo, type FeedbackStore, FileDelegationStore, type FileDelegationStoreOptions, type FleetHandle, type FleetWorkspaceExecutorOptions, type GitRunner, InMemoryDelegationStore, InMemoryFeedbackStore, type InProcessExecutorDescribePlacement, type InProcessExecutorOptions, type JsonRpcMessage, type JsonRpcResponse, type KbGateResult, LOCAL_HARNESSES, type LeadMessage, type LocalHarness, type LocalHarnessResult, MEMORY_FILE_ENV, MEMORY_ITEMS_ENV, MEMORY_LOG_ENV, MEMORY_NAME_ENV, type MakeWorkerAgent, type ManagerReentryState, type ManagerWake, type McpServer, type McpServerOptions, type McpToolAnnotations, type McpToolDescriptor, type McpTransport, type MemoryItem, type Question, type QuestionDecision, type QuestionEscalationOutcome, type QuestionEscalationRecord, type QuestionEscalationTarget, type QuestionLevel, type QuestionOption, type QuestionPolicy, type QuestionRecord, type QuestionUrgency, type RemoveWorktreeOptions, type ResearchOutputShape, type ResearchSource, type ResolveSpawnResourcePathsResult, type ResolvedMemoryEnv, type ResolvedSpawnResourcePath, type RunDetachedTurnOptions, type RunLocalHarnessOptions, SPAWN_RESOURCE_PATH_MAX_BYTES, SUPPORTED_PROTOCOL_VERSIONS, type SettleDetachedCoderTurnOptions, type SettledWorker, type SiblingSandboxExecutorOptions, type SourcedHarness, type SpawnResourceBytes, type SpawnResourceRead, type SpawnResourceReader, type StdioToolServer, type StdioToolServerOptions, type SubmitInput, type SubmitOutput, type ToolOutcomeEvent, type TraceContext, type UiAuditLensFilter, type UiAuditorDelegate, type UiAuditorDelegationOutput, type WorkerSpawnContext, type WorkerWatchOptions, type WorktreeHandle, analystToolGroupNames, buildDelegationTraceSpans, capDelegationTrace, captureWorktreeDiff, coderTaskFromArgs, collidesWithHarnessNativeTool, composeLoopTraceEmitters, createCoordinationTools, createDelegateFeedbackHandler, createDelegateHandler, createDelegateUiAuditHandler, createDelegationHistoryHandler, createDelegationStatusHandler, createDelegationTraceCollector, createDetachedTurnResumeDriver, createFleetWorkspaceExecutor, createInProcessExecutor, createInProcessTransport, createKbGate, createMcpServer, createMemoryToolServer, createPropagatingTraceEmitter, createSiblingSandboxExecutor, createStdioToolServer, createWorktree, delegationProfiles, detachedSessionDelegate, detachedTurnEvents, downMessageRefusalReasons, environmentReader, eventToSnapshot, formatDetachedSessionRef, harnessNativeToolNames, harnessNativeTools, harnessSupportsReasoningEffort, hashIdempotencyInput, hostDirectoryReader, localHarnessExecutable, mcpToolsForRuntimeMcp, mcpToolsForRuntimeMcpSubset, mergeTraceEnv, parseAuthoredAnalystDefinition, parseCodexTokenUsage, parseDetachedSessionRef, parseMemoryItems, questionEscalationTargets, readMemoryItemsFile, readTraceContextFromEnv, removeWorktree, resolveMemoryFromEnv, resolveSpawnResourcePaths, runDetachedTurn, settleDetachedCoderTurn, sourcedHarnesses, traceContextToEnv, validateDelegateArgs, validateDelegateFeedbackArgs, validateDelegateUiAuditArgs, validateDelegationHistoryArgs, validateDelegationStatusArgs };
|
|
488
|
+
export { ANALYST_DEFINITION_BOUNDS, type AgentMemorySpec, type AnalystAssignmentRecord, type AnalystDefinitionIssue, type AnalystFindingEvent, type AnalystKind, type AnalystRegistry, type AnalystToolGroupName, type AuthoredAnalystDefinition, type AuthoredAnalystLimits, type AuthorizeDownMessage, type AuthorizedDownMessage, type AwaitWakeInput, type CappedDelegationTrace, type CoderDelegate, type CoderOutput, type CoderReview, type CoderReviewer, CodexExecutionDiagnosticError, type CodexExecutionEvidence, type CodexExecutionFailureDiagnostic, type CodexExecutionPolicy, type CodexTokenUsage, type ContinuationInstruction, type CoordinationEvent, type CoordinationTools, type CoordinationToolsOptions, type CreateHubIntegrationToolServerOptions, type CreateKbGateOptions, type CreateMemoryToolServerOptions, type CreateWorktreeOptions, DEFAULT_LOCAL_HARNESS, DELEGATE_DESCRIPTION, DELEGATE_FEEDBACK_DESCRIPTION, DELEGATE_FEEDBACK_INPUT_SCHEMA, DELEGATE_FEEDBACK_TOOL_NAME, DELEGATE_INPUT_SCHEMA, DELEGATE_TOOL_NAME, DELEGATE_UI_AUDIT_DESCRIPTION, DELEGATE_UI_AUDIT_INPUT_SCHEMA, DELEGATE_UI_AUDIT_TOOL_NAME, DELEGATION_HISTORY_DESCRIPTION, DELEGATION_HISTORY_INPUT_SCHEMA, DELEGATION_HISTORY_TOOL_NAME, DELEGATION_STATUS_DESCRIPTION, DELEGATION_STATUS_INPUT_SCHEMA, DELEGATION_STATUS_TOOL_NAME, DELEGATION_TRACE_MAX_BYTES, DELEGATION_TRACE_MAX_SPANS, type DefinedAnalystRecord, type DelegateArgs, type DelegateCodeArgs, type DelegateCodeConfig, type DelegateCodeResult, type DelegateError, type DelegateFeedbackArgs, type DelegateFeedbackHandlerOptions, type DelegateFeedbackResult, type DelegateHandlerOptions, type DelegateResearchArgs, type DelegateResearchConfig, type DelegateResearchResult, type DelegateResult, type DelegateRunCtx, type DelegateUiAuditArgs, type DelegateUiAuditConfig, type DelegateUiAuditHandlerOptions, type DelegateUiAuditResult, type DelegateUiAuditRoute, type DelegationArgs, type DelegationError, type DelegationExecutor, type DelegationFeedbackSnapshot, type DelegationHistoryArgs, type DelegationHistoryEntry, type DelegationHistoryHandlerOptions, type DelegationHistoryResult, DelegationPersistenceError, type DelegationProfile, type DelegationProgress, type DelegationRecord, type DelegationResultPayload, type DelegationResumeContext, type DelegationResumeDriver, type DelegationResumeTick, type DelegationRunContext, DelegationStateCorruptError, type DelegationStatus, type DelegationStatusArgs, type DelegationStatusHandlerOptions, type DelegationStatusResult, type DelegationStore, DelegationTaskQueue, type DelegationTaskQueueOptions, type DelegationTraceCaps, type DelegationTraceCollector, type DelegationTraceSpan, type DetachedSessionDelegateOptions, type DetachedSessionRefParts, type DetachedTurn, type DetachedTurnResumeDriverOptions, type DetachedWinnerSelection, type DiffOptions, type DiffResult, type DownMessageAuthorizationInput, type DownMessageDeliveryAttempt, type DownMessageDeliveryOutcome, type DownMessageEvent, type DriveTurnCapableBox, type DriveTurnTick, type EscalateQuestion, type EventAcknowledgement, type FactCandidate, type FactJudge, type FactJudgeVerdict, type FeedbackEvent, type FeedbackRating, type FeedbackRefersTo, type FeedbackStore, FileDelegationStore, type FileDelegationStoreOptions, type FleetHandle, type FleetWorkspaceExecutorOptions, type GitRunner, HUB_DATA_PROVIDER_KINDS, type HubIntegrationClient, type HubIntegrationToolsOptions, InMemoryDelegationStore, InMemoryFeedbackStore, type InProcessExecutorDescribePlacement, type InProcessExecutorOptions, type JsonRpcMessage, type JsonRpcResponse, type KbGateResult, LOCAL_HARNESSES, type LeadMessage, type LocalHarness, type LocalHarnessResult, MEMORY_FILE_ENV, MEMORY_ITEMS_ENV, MEMORY_LOG_ENV, MEMORY_NAME_ENV, type MakeWorkerAgent, type ManagerReentryState, type ManagerWake, type McpServer, type McpServerOptions, type McpToolAnnotations, type McpToolDescriptor, type McpTransport, type MemoryItem, type Question, type QuestionDecision, type QuestionEscalationOutcome, type QuestionEscalationRecord, type QuestionEscalationTarget, type QuestionLevel, type QuestionOption, type QuestionPolicy, type QuestionRecord, type QuestionUrgency, type RemoveWorktreeOptions, type ResearchOutputShape, type ResearchSource, type ResolveSpawnResourcePathsResult, type ResolvedMemoryEnv, type ResolvedSpawnResourcePath, type RunDetachedTurnOptions, type RunLocalHarnessOptions, SPAWN_RESOURCE_PATH_MAX_BYTES, SUPPORTED_PROTOCOL_VERSIONS, type SettleDetachedCoderTurnOptions, type SettledWorker, type SiblingSandboxExecutorOptions, type SourcedHarness, type SpawnResourceBytes, type SpawnResourceRead, type SpawnResourceReader, type StdioToolServer, type StdioToolServerOptions, type SubmitInput, type SubmitOutput, type ToolOutcomeEvent, type TraceContext, type UiAuditLensFilter, type UiAuditorDelegate, type UiAuditorDelegationOutput, type WorkerSpawnContext, type WorkerWatchOptions, type WorktreeHandle, analystToolGroupNames, buildDelegationTraceSpans, capDelegationTrace, captureWorktreeDiff, coderTaskFromArgs, collidesWithHarnessNativeTool, composeLoopTraceEmitters, createCoordinationTools, createDelegateFeedbackHandler, createDelegateHandler, createDelegateUiAuditHandler, createDelegationHistoryHandler, createDelegationStatusHandler, createDelegationTraceCollector, createDetachedTurnResumeDriver, createFleetWorkspaceExecutor, createHubIntegrationToolServer, createInProcessExecutor, createInProcessTransport, createKbGate, createMcpServer, createMemoryToolServer, createPropagatingTraceEmitter, createSiblingSandboxExecutor, createStdioToolServer, createWorktree, delegationProfiles, detachedSessionDelegate, detachedTurnEvents, downMessageRefusalReasons, environmentReader, eventToSnapshot, formatDetachedSessionRef, harnessNativeToolNames, harnessNativeTools, harnessSupportsReasoningEffort, hashIdempotencyInput, hostDirectoryReader, hubIntegrationTools, localHarnessExecutable, mcpToolsForRuntimeMcp, mcpToolsForRuntimeMcpSubset, mergeTraceEnv, parseAuthoredAnalystDefinition, parseCodexTokenUsage, parseDetachedSessionRef, parseMemoryItems, questionEscalationTargets, readMemoryItemsFile, readTraceContextFromEnv, removeWorktree, resolveMemoryFromEnv, resolveSpawnResourcePaths, runDetachedTurn, settleDetachedCoderTurn, sourcedHarnesses, traceContextToEnv, validateDelegateArgs, validateDelegateFeedbackArgs, validateDelegateUiAuditArgs, validateDelegationHistoryArgs, validateDelegationStatusArgs };
|
|
448
489
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { $ as environmentReader, Ir as createPropagatingTraceEmitter, Lr as mergeTraceEnv, Q as SPAWN_RESOURCE_PATH_MAX_BYTES, Rr as readTraceContextFromEnv, Sn as assertBoxlessPromptOptions, _n as runAgentRounds, ci as createWorktree, di as LOCAL_HARNESSES, et as hostDirectoryReader, gi as CodexExecutionDiagnosticError, hi as parseCodexTokenUsage, li as removeWorktree, mi as localHarnessExecutable, mn as createSandboxForSpec, oi as runWorktreeHarness, pi as harnessSupportsReasoningEffort, si as captureWorktreeDiff, tt as resolveSpawnResourcePaths, ui as DEFAULT_LOCAL_HARNESS, zr as traceContextToEnv } from "../supervisor-
|
|
1
|
+
import { $ as environmentReader, Ir as createPropagatingTraceEmitter, Lr as mergeTraceEnv, Q as SPAWN_RESOURCE_PATH_MAX_BYTES, Rr as readTraceContextFromEnv, Sn as assertBoxlessPromptOptions, _n as runAgentRounds, ci as createWorktree, di as LOCAL_HARNESSES, et as hostDirectoryReader, gi as CodexExecutionDiagnosticError, hi as parseCodexTokenUsage, li as removeWorktree, mi as localHarnessExecutable, mn as createSandboxForSpec, oi as runWorktreeHarness, pi as harnessSupportsReasoningEffort, si as captureWorktreeDiff, tt as resolveSpawnResourcePaths, ui as DEFAULT_LOCAL_HARNESS, zr as traceContextToEnv } from "../supervisor-CbFyf48U.js";
|
|
2
2
|
import { i as ConfigError, m as ValidationError } from "../errors-DodWX-cb.js";
|
|
3
|
-
import {
|
|
3
|
+
import { G as deleteBoxSafe, at as throwIfAborted, it as throwAbort, nt as sleep } from "../workspace-streams-DkijayqX.js";
|
|
4
4
|
import { t as assertExecutableAgentProfile } from "../model-policy-DhvyZ8-O.js";
|
|
5
|
-
import { E as runCoderChecks, at as selectValidWinner } from "../runtime-
|
|
6
|
-
import { A as analystToolGroupNames, F as downMessageRefusalReasons, L as parseAuthoredAnalystDefinition, N as createCoordinationTools, R as questionEscalationTargets, k as ANALYST_DEFINITION_BOUNDS } from "../coordination-driver-
|
|
5
|
+
import { E as runCoderChecks, at as selectValidWinner } from "../runtime-B9BOFyEp.js";
|
|
6
|
+
import { A as analystToolGroupNames, F as downMessageRefusalReasons, L as parseAuthoredAnalystDefinition, N as createCoordinationTools, R as questionEscalationTargets, k as ANALYST_DEFINITION_BOUNDS } from "../coordination-driver-DGhN8GO9.js";
|
|
7
7
|
import { n as SUPPORTED_PROTOCOL_VERSIONS, r as createStdioToolServer } from "../tool-server-Dqer2M4_.js";
|
|
8
8
|
import { t as createKbGate } from "../kb-gate-DpaSwXVx.js";
|
|
9
9
|
import { _ as InMemoryFeedbackStore, a as validateDelegationStatusArgs, c as DELEGATION_HISTORY_TOOL_NAME, d as delegationProfiles, f as DELEGATE_FEEDBACK_DESCRIPTION, g as validateDelegateFeedbackArgs, h as createDelegateFeedbackHandler, i as createDelegationStatusHandler, l as createDelegationHistoryHandler, m as DELEGATE_FEEDBACK_TOOL_NAME, n as DELEGATION_STATUS_INPUT_SCHEMA, o as DELEGATION_HISTORY_DESCRIPTION, p as DELEGATE_FEEDBACK_INPUT_SCHEMA, r as DELEGATION_STATUS_TOOL_NAME, s as DELEGATION_HISTORY_INPUT_SCHEMA, t as DELEGATION_STATUS_DESCRIPTION, u as validateDelegationHistoryArgs, v as eventToSnapshot } from "../delegation-status-CF4D0NZ_.js";
|
|
10
10
|
import { n as mcpToolsForRuntimeMcpSubset, t as mcpToolsForRuntimeMcp } from "../openai-tools-DoQ32vpe.js";
|
|
11
11
|
import { t as coderTaskToPrompt } from "../coder-yhVWbdWc.js";
|
|
12
|
-
import {
|
|
12
|
+
import { n as PlatformHubError } from "../integrations-dFi-ALk7.js";
|
|
13
|
+
import { C as composeLoopTraceEmitters, S as capDelegationTrace, _ as FileDelegationStore, a as DELEGATE_UI_AUDIT_TOOL_NAME, b as DELEGATION_TRACE_MAX_SPANS, c as DELEGATE_DESCRIPTION, d as createDelegateHandler, f as validateDelegateArgs, g as DelegationStateCorruptError, h as DelegationPersistenceError, i as DELEGATE_UI_AUDIT_INPUT_SCHEMA, l as DELEGATE_INPUT_SCHEMA, m as hashIdempotencyInput, n as createMcpServer, o as createDelegateUiAuditHandler, p as DelegationTaskQueue, r as DELEGATE_UI_AUDIT_DESCRIPTION, s as validateDelegateUiAuditArgs, t as createInProcessTransport, u as DELEGATE_TOOL_NAME, v as InMemoryDelegationStore, w as createDelegationTraceCollector, x as buildDelegationTraceSpans, y as DELEGATION_TRACE_MAX_BYTES } from "../server-TwpH9aik.js";
|
|
13
14
|
import { a as createMemoryToolServer, c as resolveMemoryFromEnv, i as MEMORY_NAME_ENV, n as MEMORY_ITEMS_ENV, o as parseMemoryItems, r as MEMORY_LOG_ENV, s as readMemoryItemsFile, t as MEMORY_FILE_ENV } from "../memory-server-DXQ8IxGR.js";
|
|
14
15
|
import { agentProfileSchema } from "@tangle-network/agent-interface";
|
|
15
16
|
import { randomUUID } from "node:crypto";
|
|
@@ -935,6 +936,128 @@ function collidesWithHarnessNativeTool(name) {
|
|
|
935
936
|
return sourcedHarnesses.filter((harness) => harnessNativeTools[harness].some((native) => native.toLowerCase() === wanted));
|
|
936
937
|
}
|
|
937
938
|
//#endregion
|
|
939
|
+
//#region src/mcp/hub-server.ts
|
|
940
|
+
/**
|
|
941
|
+
* Hub integration MCP server — the user's connected databases and vector
|
|
942
|
+
* stores as agent tools, mid-turn.
|
|
943
|
+
*
|
|
944
|
+
* The Tangle Platform Hub (`PlatformHubClient`, platform/integrations.ts)
|
|
945
|
+
* already turns a provider credential into a per-user, per-action-policy'd,
|
|
946
|
+
* approved, audited access surface: the user connects Pinecone/Qdrant/
|
|
947
|
+
* Weaviate/Neon/Supabase/… once, and every later call goes through
|
|
948
|
+
* `POST /v1/hub/exec`. This module is the thin bridge from that surface to
|
|
949
|
+
* the agent's tool loop: for every ACTIVE connection to a data provider it
|
|
950
|
+
* serves ONE router tool (`hub_<provider>`) whose `action` + `input`
|
|
951
|
+
* arguments are dispatched to the provider's Hub adapter.
|
|
952
|
+
*
|
|
953
|
+
* Why one router tool per connection instead of one tool per adapter action:
|
|
954
|
+
* the Hub catalog publishes capability counts, not capability schemas, so a
|
|
955
|
+
* per-action tool surface would have to bundle the whole adapter registry.
|
|
956
|
+
* The router tool keeps the layer thin — the Hub adapter IS the tool, the
|
|
957
|
+
* Hub exec endpoint IS the invocation, and the Hub policy IS the permission.
|
|
958
|
+
* Every call is policy-gated server-side; a denial surfaces to the agent as
|
|
959
|
+
* the Hub's own error message. When the platform grows a capabilities
|
|
960
|
+
* endpoint, per-action tools can be generated from it without changing this
|
|
961
|
+
* module's contract.
|
|
962
|
+
*
|
|
963
|
+
* Tool lists are resolved at construction (session-scoped, like the memory
|
|
964
|
+
* server): connections the user adds later appear after the server restarts.
|
|
965
|
+
*
|
|
966
|
+
* @experimental
|
|
967
|
+
*/
|
|
968
|
+
/** The substrate data providers whose Hub adapters become agent tools. */
|
|
969
|
+
const HUB_DATA_PROVIDER_KINDS = [
|
|
970
|
+
"pinecone",
|
|
971
|
+
"qdrant",
|
|
972
|
+
"weaviate",
|
|
973
|
+
"neon",
|
|
974
|
+
"supabase",
|
|
975
|
+
"mongodb",
|
|
976
|
+
"postgres",
|
|
977
|
+
"mysql",
|
|
978
|
+
"redis"
|
|
979
|
+
];
|
|
980
|
+
/** An action name: dot-separated identifiers — `vectors.query`, `branches.list`. */
|
|
981
|
+
const ACTION_NAME_PATTERN = /^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)+$/;
|
|
982
|
+
const MCP_TOOL_NAME_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
|
983
|
+
function toolNameFor(providerId, connectionId, taken) {
|
|
984
|
+
const base = `hub_${providerId}`.replace(/[^A-Za-z0-9_-]/g, "-");
|
|
985
|
+
const candidates = [base, `${base}-${connectionId.replace(/[^A-Za-z0-9_-]/g, "-").slice(0, 64 - base.length - 1)}`];
|
|
986
|
+
for (const candidate of candidates) if (MCP_TOOL_NAME_PATTERN.test(candidate) && !taken.has(candidate)) {
|
|
987
|
+
taken.add(candidate);
|
|
988
|
+
return candidate;
|
|
989
|
+
}
|
|
990
|
+
throw new ValidationError(`hubIntegrationTools: cannot derive a unique tool name for connection '${connectionId}' of provider '${providerId}'`);
|
|
991
|
+
}
|
|
992
|
+
function connectionLabel(connection) {
|
|
993
|
+
const account = connection.accountDisplay ? ` (${connection.accountDisplay})` : "";
|
|
994
|
+
return `${connection.displayName || connection.providerId}${account}`;
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* One router tool per active Hub connection to a data provider. The tool
|
|
998
|
+
* handler never holds provider credentials — it execs through the Hub, which
|
|
999
|
+
* enforces the per-user action policy and writes the audit record.
|
|
1000
|
+
*/
|
|
1001
|
+
async function hubIntegrationTools(options) {
|
|
1002
|
+
const providers = new Set(options.providers ?? HUB_DATA_PROVIDER_KINDS);
|
|
1003
|
+
const eligible = (await options.client.listConnections()).filter((connection) => providers.has(connection.providerId) && connection.status === "active" && (options.includeUnhealthy === true || connection.health !== "unhealthy"));
|
|
1004
|
+
const taken = /* @__PURE__ */ new Set();
|
|
1005
|
+
return eligible.map((connection) => {
|
|
1006
|
+
const providerId = connection.providerId;
|
|
1007
|
+
const name = toolNameFor(providerId, connection.id, taken);
|
|
1008
|
+
return {
|
|
1009
|
+
name,
|
|
1010
|
+
description: `Execute a ${providerId} action on the user's Hub connection '${connectionLabel(connection)}' (connection ${connection.id}). Pass action (e.g. "vectors.query", "branches.list", "collections.list") and its input object. Every call is policy-gated and audited by the Tangle Hub; a denied action returns the Hub's error message. Read actions list data; mutations may require prior approval.`,
|
|
1011
|
+
inputSchema: {
|
|
1012
|
+
type: "object",
|
|
1013
|
+
properties: {
|
|
1014
|
+
action: {
|
|
1015
|
+
type: "string",
|
|
1016
|
+
description: `The ${providerId} adapter action name, e.g. "vectors.query".`
|
|
1017
|
+
},
|
|
1018
|
+
input: {
|
|
1019
|
+
type: "object",
|
|
1020
|
+
description: "Arguments object for the action.",
|
|
1021
|
+
additionalProperties: true
|
|
1022
|
+
}
|
|
1023
|
+
},
|
|
1024
|
+
required: ["action"],
|
|
1025
|
+
additionalProperties: false
|
|
1026
|
+
},
|
|
1027
|
+
handler: async (raw) => {
|
|
1028
|
+
const args = raw ?? {};
|
|
1029
|
+
if (typeof args.action !== "string" || !ACTION_NAME_PATTERN.test(args.action)) throw new TypeError(`${name}: action must be a provider action name like "vectors.query" (dot-separated, no path or spaces)`);
|
|
1030
|
+
if (args.input !== void 0 && (typeof args.input !== "object" || args.input === null || Array.isArray(args.input))) throw new TypeError(`${name}: input must be an object of action arguments`);
|
|
1031
|
+
const path = `${providerId}.${args.action}`;
|
|
1032
|
+
try {
|
|
1033
|
+
return await options.client.exec({
|
|
1034
|
+
path,
|
|
1035
|
+
input: args.input ?? {},
|
|
1036
|
+
connectionId: connection.id
|
|
1037
|
+
});
|
|
1038
|
+
} catch (error) {
|
|
1039
|
+
if (error instanceof PlatformHubError) throw new Error(`${name}: hub exec '${path}' failed (${error.status}${error.code ? ` ${error.code}` : ""}): ${error.message}`);
|
|
1040
|
+
throw error;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
};
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Build the hub integration MCP server on the shared stdio JSON-RPC core —
|
|
1048
|
+
* the same wire protocol every in-repo MCP server speaks. Serves zero tools
|
|
1049
|
+
* when the caller has no active data-provider connections (a session without
|
|
1050
|
+
* connections simply gets no database tools, mirroring the memory server's
|
|
1051
|
+
* "no artifact, no server" discipline).
|
|
1052
|
+
*/
|
|
1053
|
+
async function createHubIntegrationToolServer(options) {
|
|
1054
|
+
return createStdioToolServer({
|
|
1055
|
+
serverName: options.serverName ?? "agent-hub-integrations",
|
|
1056
|
+
serverVersion: options.serverVersion ?? "0",
|
|
1057
|
+
tools: await hubIntegrationTools(options)
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
//#endregion
|
|
938
1061
|
//#region src/mcp/in-process-executor.ts
|
|
939
1062
|
/**
|
|
940
1063
|
*
|
|
@@ -1116,6 +1239,6 @@ async function defaultRunPostCheck(cmd, cwd, signal) {
|
|
|
1116
1239
|
});
|
|
1117
1240
|
}
|
|
1118
1241
|
//#endregion
|
|
1119
|
-
export { ANALYST_DEFINITION_BOUNDS, CodexExecutionDiagnosticError, DEFAULT_LOCAL_HARNESS, DELEGATE_DESCRIPTION, DELEGATE_FEEDBACK_DESCRIPTION, DELEGATE_FEEDBACK_INPUT_SCHEMA, DELEGATE_FEEDBACK_TOOL_NAME, DELEGATE_INPUT_SCHEMA, DELEGATE_TOOL_NAME, DELEGATE_UI_AUDIT_DESCRIPTION, DELEGATE_UI_AUDIT_INPUT_SCHEMA, DELEGATE_UI_AUDIT_TOOL_NAME, DELEGATION_HISTORY_DESCRIPTION, DELEGATION_HISTORY_INPUT_SCHEMA, DELEGATION_HISTORY_TOOL_NAME, DELEGATION_STATUS_DESCRIPTION, DELEGATION_STATUS_INPUT_SCHEMA, DELEGATION_STATUS_TOOL_NAME, DELEGATION_TRACE_MAX_BYTES, DELEGATION_TRACE_MAX_SPANS, DelegationPersistenceError, DelegationStateCorruptError, DelegationTaskQueue, FileDelegationStore, InMemoryDelegationStore, InMemoryFeedbackStore, LOCAL_HARNESSES, MEMORY_FILE_ENV, MEMORY_ITEMS_ENV, MEMORY_LOG_ENV, MEMORY_NAME_ENV, SPAWN_RESOURCE_PATH_MAX_BYTES, SUPPORTED_PROTOCOL_VERSIONS, analystToolGroupNames, buildDelegationTraceSpans, capDelegationTrace, captureWorktreeDiff, coderTaskFromArgs, collidesWithHarnessNativeTool, composeLoopTraceEmitters, createCoordinationTools, createDelegateFeedbackHandler, createDelegateHandler, createDelegateUiAuditHandler, createDelegationHistoryHandler, createDelegationStatusHandler, createDelegationTraceCollector, createDetachedTurnResumeDriver, createFleetWorkspaceExecutor, createInProcessExecutor, createInProcessTransport, createKbGate, createMcpServer, createMemoryToolServer, createPropagatingTraceEmitter, createSiblingSandboxExecutor, createStdioToolServer, createWorktree, delegationProfiles, detachedSessionDelegate, detachedTurnEvents, downMessageRefusalReasons, environmentReader, eventToSnapshot, formatDetachedSessionRef, harnessNativeToolNames, harnessNativeTools, harnessSupportsReasoningEffort, hashIdempotencyInput, hostDirectoryReader, localHarnessExecutable, mcpToolsForRuntimeMcp, mcpToolsForRuntimeMcpSubset, mergeTraceEnv, parseAuthoredAnalystDefinition, parseCodexTokenUsage, parseDetachedSessionRef, parseMemoryItems, questionEscalationTargets, readMemoryItemsFile, readTraceContextFromEnv, removeWorktree, resolveMemoryFromEnv, resolveSpawnResourcePaths, runDetachedTurn, settleDetachedCoderTurn, sourcedHarnesses, traceContextToEnv, validateDelegateArgs, validateDelegateFeedbackArgs, validateDelegateUiAuditArgs, validateDelegationHistoryArgs, validateDelegationStatusArgs };
|
|
1242
|
+
export { ANALYST_DEFINITION_BOUNDS, CodexExecutionDiagnosticError, DEFAULT_LOCAL_HARNESS, DELEGATE_DESCRIPTION, DELEGATE_FEEDBACK_DESCRIPTION, DELEGATE_FEEDBACK_INPUT_SCHEMA, DELEGATE_FEEDBACK_TOOL_NAME, DELEGATE_INPUT_SCHEMA, DELEGATE_TOOL_NAME, DELEGATE_UI_AUDIT_DESCRIPTION, DELEGATE_UI_AUDIT_INPUT_SCHEMA, DELEGATE_UI_AUDIT_TOOL_NAME, DELEGATION_HISTORY_DESCRIPTION, DELEGATION_HISTORY_INPUT_SCHEMA, DELEGATION_HISTORY_TOOL_NAME, DELEGATION_STATUS_DESCRIPTION, DELEGATION_STATUS_INPUT_SCHEMA, DELEGATION_STATUS_TOOL_NAME, DELEGATION_TRACE_MAX_BYTES, DELEGATION_TRACE_MAX_SPANS, DelegationPersistenceError, DelegationStateCorruptError, DelegationTaskQueue, FileDelegationStore, HUB_DATA_PROVIDER_KINDS, InMemoryDelegationStore, InMemoryFeedbackStore, LOCAL_HARNESSES, MEMORY_FILE_ENV, MEMORY_ITEMS_ENV, MEMORY_LOG_ENV, MEMORY_NAME_ENV, SPAWN_RESOURCE_PATH_MAX_BYTES, SUPPORTED_PROTOCOL_VERSIONS, analystToolGroupNames, buildDelegationTraceSpans, capDelegationTrace, captureWorktreeDiff, coderTaskFromArgs, collidesWithHarnessNativeTool, composeLoopTraceEmitters, createCoordinationTools, createDelegateFeedbackHandler, createDelegateHandler, createDelegateUiAuditHandler, createDelegationHistoryHandler, createDelegationStatusHandler, createDelegationTraceCollector, createDetachedTurnResumeDriver, createFleetWorkspaceExecutor, createHubIntegrationToolServer, createInProcessExecutor, createInProcessTransport, createKbGate, createMcpServer, createMemoryToolServer, createPropagatingTraceEmitter, createSiblingSandboxExecutor, createStdioToolServer, createWorktree, delegationProfiles, detachedSessionDelegate, detachedTurnEvents, downMessageRefusalReasons, environmentReader, eventToSnapshot, formatDetachedSessionRef, harnessNativeToolNames, harnessNativeTools, harnessSupportsReasoningEffort, hashIdempotencyInput, hostDirectoryReader, hubIntegrationTools, localHarnessExecutable, mcpToolsForRuntimeMcp, mcpToolsForRuntimeMcpSubset, mergeTraceEnv, parseAuthoredAnalystDefinition, parseCodexTokenUsage, parseDetachedSessionRef, parseMemoryItems, questionEscalationTargets, readMemoryItemsFile, readTraceContextFromEnv, removeWorktree, resolveMemoryFromEnv, resolveSpawnResourcePaths, runDetachedTurn, settleDetachedCoderTurn, sourcedHarnesses, traceContextToEnv, validateDelegateArgs, validateDelegateFeedbackArgs, validateDelegateUiAuditArgs, validateDelegationHistoryArgs, validateDelegationStatusArgs };
|
|
1120
1243
|
|
|
1121
1244
|
//# sourceMappingURL=index.js.map
|