@tangle-network/agent-runtime 0.247.0 → 0.252.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/dist/{activation-DYqnl8zq.js → activation-BSLatbiJ.js} +34 -4
- package/dist/activation-BSLatbiJ.js.map +1 -0
- package/dist/{activation-DizpINK3.d.ts → activation-BykUtuec.d.ts} +2 -2
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/bundle-DXrBPEFw.js +17 -0
- package/dist/bundle-DXrBPEFw.js.map +1 -0
- package/dist/candidate-execution/index.js +4 -4
- package/dist/{coordination-driver-BV4AAUns.js → coordination-driver-QxitIuva.js} +162 -17
- package/dist/coordination-driver-QxitIuva.js.map +1 -0
- package/dist/{delegate-DQAzB5Xv.js → delegate-BB90iDo7.js} +2 -2
- package/dist/{delegate-DQAzB5Xv.js.map → delegate-BB90iDo7.js.map} +1 -1
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +2 -2
- package/dist/{graph-DcBmMLIp.js → graph-yC6wqOIt.js} +3 -3
- package/dist/{graph-DcBmMLIp.js.map → graph-yC6wqOIt.js.map} +1 -1
- package/dist/{improvement-cycle-B049YmQ8.js → improvement-cycle-on_u94aK.js} +5 -5
- package/dist/{improvement-cycle-B049YmQ8.js.map → improvement-cycle-on_u94aK.js.map} +1 -1
- package/dist/{index-DLzlXwr6.d.ts → index-DGWG7wSS.d.ts} +20 -9
- package/dist/index.d.ts +8 -6
- package/dist/index.js +32 -50
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +18 -11
- package/dist/intelligence.js +93 -38
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +4 -4
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-HbMECmxT.d.ts → loop-runner-bin-CsVNUclF.d.ts} +3 -3
- package/dist/{loop-runner-bin-iqq1azfy.js → loop-runner-bin-PL0dItet.js} +3 -3
- package/dist/{loop-runner-bin-iqq1azfy.js.map → loop-runner-bin-PL0dItet.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +5 -5
- package/dist/mcp/index.js +4 -4
- package/dist/{openai-tools-DvLk_Ddg.d.ts → openai-tools-zrajPyXe.d.ts} +2 -2
- package/dist/{prepare-CibQrhfi.js → prepare-RuaAclli.js} +8 -598
- package/dist/prepare-RuaAclli.js.map +1 -0
- package/dist/profiles.d.ts +2 -2
- package/dist/{protected-model-port-Dhdi5mDl.js → protected-model-port-BFhSgMAy.js} +3 -3
- package/dist/{protected-model-port-Dhdi5mDl.js.map → protected-model-port-BFhSgMAy.js.map} +1 -1
- package/dist/{protected-redaction-Fn1ETfJ-.js → protected-redaction--F3v1oo8.js} +3 -54
- package/dist/protected-redaction--F3v1oo8.js.map +1 -0
- package/dist/{provision-supervisor-BgQx2Avp.js → provision-supervisor-DsAhgOpn.js} +4 -4
- package/dist/{provision-supervisor-BgQx2Avp.js.map → provision-supervisor-DsAhgOpn.js.map} +1 -1
- package/dist/{run-layout-hKAJGF4g.js → run-layout-vwd4SwX_.js} +15 -9
- package/dist/run-layout-vwd4SwX_.js.map +1 -0
- package/dist/{runtime-HpTXhB3g.js → runtime-CMNTa7Rw.js} +11 -10
- package/dist/{runtime-HpTXhB3g.js.map → runtime-CMNTa7Rw.js.map} +1 -1
- package/dist/{server-OOE7mXrN.js → server-2fL_QElQ.js} +3 -3
- package/dist/{server-OOE7mXrN.js.map → server-2fL_QElQ.js.map} +1 -1
- package/dist/{stream-agent-turn-CcumM0Bu.d.ts → stream-agent-turn-oeWkjxMi.d.ts} +32 -5
- package/dist/{structural-rollout-z1A0okaB.js → structural-rollout-DRD-WnV-.js} +2 -2
- package/dist/{structural-rollout-z1A0okaB.js.map → structural-rollout-DRD-WnV-.js.map} +1 -1
- package/dist/{substrate-CQ0hfewn.d.ts → substrate-Ctmos75o.d.ts} +2 -2
- package/dist/{supervise-DZEOpzRw.js → supervise-BXzkqfTE.js} +25 -8
- package/dist/supervise-BXzkqfTE.js.map +1 -0
- package/dist/{supervisor-BIBWUFUr.js → supervisor-OJwKAnFd.js} +391 -187
- package/dist/supervisor-OJwKAnFd.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +14 -14
- package/dist/{top-app-d-bmwO7O.js → top-app-VAOrBskv.js} +2 -2
- package/dist/{top-app-d-bmwO7O.js.map → top-app-VAOrBskv.js.map} +1 -1
- package/dist/tui/bin.js +1 -1
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/{types-BUhz284C.d.ts → types-BmxS-W-f.d.ts} +22 -11
- package/dist/workspace-archive-DQGFwvM6.js +1209 -0
- package/dist/workspace-archive-DQGFwvM6.js.map +1 -0
- package/package.json +4 -4
- package/dist/activation-DYqnl8zq.js.map +0 -1
- package/dist/coordination-driver-BV4AAUns.js.map +0 -1
- package/dist/prepare-CibQrhfi.js.map +0 -1
- package/dist/protected-redaction-Fn1ETfJ-.js.map +0 -1
- package/dist/run-layout-hKAJGF4g.js.map +0 -1
- package/dist/supervise-DZEOpzRw.js.map +0 -1
- package/dist/supervisor-BIBWUFUr.js.map +0 -1
- package/dist/workspace-archive-DSRT4Tro.js +0 -572
- package/dist/workspace-archive-DSRT4Tro.js.map +0 -1
|
@@ -1,6 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { C as canonicalCandidateDocument, E as immutableCandidateValue, S as canonicalCandidateDigest$1, k as verifyCanonicalCandidateDocument } from "./workspace-archive-DQGFwvM6.js";
|
|
2
|
+
import { A as agentImprovementTargetInput, M as agentProfileImprovementStateDigest, c as requireSealedCandidateExperiment, d as verifyAgentImprovementActivation, f as verifyAgentImprovementProposal, k as agentImprovementTargetDigest } from "./improvement-cycle-on_u94aK.js";
|
|
3
3
|
import { agentImprovementActivationResultSchema, agentImprovementActivationSchema, agentProfileImprovementExperimentSchema } from "@tangle-network/agent-interface";
|
|
4
|
+
//#region src/runtime-usage.ts
|
|
5
|
+
function createRuntimeUsageTotals() {
|
|
6
|
+
return {
|
|
7
|
+
tokensIn: 0,
|
|
8
|
+
tokensOut: 0,
|
|
9
|
+
costUsd: 0,
|
|
10
|
+
llmCalls: 0
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function isUsageAmount(value) {
|
|
14
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
15
|
+
}
|
|
16
|
+
/** Fold normalized per-call events. Backend adapters own cumulative receipt reconciliation. */
|
|
17
|
+
function addRuntimeUsage(totals, event) {
|
|
18
|
+
totals.llmCalls += 1;
|
|
19
|
+
for (const key of [
|
|
20
|
+
"tokensIn",
|
|
21
|
+
"tokensOut",
|
|
22
|
+
"costUsd"
|
|
23
|
+
]) {
|
|
24
|
+
const value = event[key];
|
|
25
|
+
if (isUsageAmount(value)) totals[key] += value;
|
|
26
|
+
else if (key === "costUsd") totals.usdKnown = false;
|
|
27
|
+
else totals.tokensKnown = false;
|
|
28
|
+
}
|
|
29
|
+
if (event.tokensKnown === false) totals.tokensKnown = false;
|
|
30
|
+
if (event.usdKnown === false) totals.usdKnown = false;
|
|
31
|
+
if (isUsageAmount(event.estimatedCostUsd)) totals.estimatedCostUsd = (totals.estimatedCostUsd ?? 0) + event.estimatedCostUsd;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
4
34
|
//#region src/intelligence/activation.ts
|
|
5
35
|
/** Create the exact result a product stores in the same transaction as its target write. */
|
|
6
36
|
function createAgentImprovementActivationResult(transition, options) {
|
|
@@ -199,6 +229,6 @@ function targetIdentity(target) {
|
|
|
199
229
|
return `${target.surface}\u0000${target.identity}`;
|
|
200
230
|
}
|
|
201
231
|
//#endregion
|
|
202
|
-
export { executeAgentImprovementActivation as n, verifyAgentImprovementActivationResult as r, createAgentImprovementActivationResult as t };
|
|
232
|
+
export { createRuntimeUsageTotals as a, addRuntimeUsage as i, executeAgentImprovementActivation as n, isUsageAmount as o, verifyAgentImprovementActivationResult as r, createAgentImprovementActivationResult as t };
|
|
203
233
|
|
|
204
|
-
//# sourceMappingURL=activation-
|
|
234
|
+
//# sourceMappingURL=activation-BSLatbiJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activation-BSLatbiJ.js","names":["canonicalCandidateDigest"],"sources":["../src/runtime-usage.ts","../src/intelligence/activation.ts"],"sourcesContent":["import type { RuntimeStreamEvent } from './types'\n\n/** Observed subtotals, with missing measurements kept separate from measured zeroes. */\nexport interface RuntimeUsageTotals {\n /** Observed input tokens across normalized per-call events. */\n tokensIn: number\n /** Observed output tokens across normalized per-call events. */\n tokensOut: number\n /** Observed dollar subtotal; incomplete when `usdKnown` is false. */\n costUsd: number\n /** Number of observed model calls, including unpriced or incompletely metered calls. */\n llmCalls: number\n /** False when any observed call has incomplete token usage. */\n tokensKnown?: false\n /** False when any observed call lacks complete provider-billed cost. */\n usdKnown?: false\n /** Sum of reported external estimates; never included in `costUsd` or proof of complete cost. */\n estimatedCostUsd?: number\n}\n\nexport function createRuntimeUsageTotals(): RuntimeUsageTotals {\n return { tokensIn: 0, tokensOut: 0, costUsd: 0, llmCalls: 0 }\n}\n\nexport function isUsageAmount(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value) && value >= 0\n}\n\n/** Fold normalized per-call events. Backend adapters own cumulative receipt reconciliation. */\nexport function addRuntimeUsage(\n totals: RuntimeUsageTotals,\n event: Extract<RuntimeStreamEvent, { type: 'llm_call' }>,\n): void {\n totals.llmCalls += 1\n for (const key of ['tokensIn', 'tokensOut', 'costUsd'] as const) {\n const value = event[key]\n if (isUsageAmount(value)) totals[key] += value\n else if (key === 'costUsd') totals.usdKnown = false\n else totals.tokensKnown = false\n }\n if (event.tokensKnown === false) totals.tokensKnown = false\n if (event.usdKnown === false) totals.usdKnown = false\n if (isUsageAmount(event.estimatedCostUsd)) {\n totals.estimatedCostUsd = (totals.estimatedCostUsd ?? 0) + event.estimatedCostUsd\n }\n}\n","import type {\n AgentCandidateBundle,\n AgentCandidateExperiment,\n AgentImprovementActivation,\n AgentImprovementActivationOutcome,\n AgentImprovementActivationResult,\n AgentImprovementActivationTarget,\n AgentImprovementProposal,\n AgentImprovementReview,\n AgentImprovementSurface,\n AgentProfileImprovementChange,\n AgentProfileImprovementExperiment,\n Sha256Digest,\n} from '@tangle-network/agent-interface'\nimport {\n agentImprovementActivationResultSchema,\n agentImprovementActivationSchema,\n agentProfileImprovementExperimentSchema,\n} from '@tangle-network/agent-interface'\n\nimport {\n canonicalCandidateDigest,\n canonicalCandidateDocument,\n immutableCandidateValue,\n verifyCanonicalCandidateDocument,\n} from '../candidate-execution/digest'\nimport {\n requireSealedCandidateExperiment,\n verifyAgentImprovementActivation,\n verifyAgentImprovementProposal,\n} from './improvement-cycle'\nimport {\n agentImprovementTargetDigest,\n agentImprovementTargetInput,\n agentProfileImprovementStateDigest,\n} from './improvement-surfaces'\n\nexport interface CreateAgentImprovementActivationResultOptions {\n completedAt: string\n outcome: AgentImprovementActivationOutcome\n}\n\nexport interface AgentImprovementActivationTargetPlan extends AgentImprovementActivationTarget {\n desiredDigest: Sha256Digest\n /**\n * Exact measured input the product must apply to reach `desiredDigest`.\n * Transition surfaces such as code and knowledge are applied operations, so\n * their resulting state digest is not the digest of this input document.\n */\n desiredInput: unknown\n}\n\nexport type AgentProfileImprovementActivationOperation =\n | {\n kind: 'apply-change'\n changes: AgentProfileImprovementChange\n }\n | {\n /** The product must load its own saved state at `desiredStateDigest`. */\n kind: 'restore-state'\n }\n\nexport interface AgentProfileImprovementActivationTargetPlan\n extends AgentImprovementActivationTarget {\n desiredDigest: Sha256Digest\n desiredInput: AgentProfileImprovementActivationOperation\n}\n\nexport interface SealedCandidateActivationTransitionInput {\n kind: 'sealed-candidate'\n activation: AgentImprovementActivation\n candidateBundle: AgentCandidateBundle\n bundle: AgentCandidateBundle\n targets: [AgentImprovementActivationTargetPlan, ...AgentImprovementActivationTargetPlan[]]\n attemptedAt: string\n expired: boolean\n}\n\n/**\n * A measured profile change without raw profile bytes.\n * The product owns the private state lookup and atomic write.\n */\nexport interface ProfileImprovementActivationTransitionInput {\n kind: 'profile-improvement'\n activation: AgentImprovementActivation\n experiment: AgentProfileImprovementExperiment\n sourceStateDigest: Sha256Digest\n desiredStateDigest: Sha256Digest\n operation: AgentProfileImprovementActivationOperation\n targets: [\n AgentProfileImprovementActivationTargetPlan,\n ...AgentProfileImprovementActivationTargetPlan[],\n ]\n attemptedAt: string\n expired: boolean\n}\n\nexport type AgentImprovementActivationTransitionInput =\n | SealedCandidateActivationTransitionInput\n | ProfileImprovementActivationTransitionInput\n\nexport interface AgentImprovementActivationResultStore {\n load(idempotencyKey: Sha256Digest): Promise<unknown | undefined>\n putIfAbsent(result: AgentImprovementActivationResult): Promise<unknown>\n}\n\n/**\n * Product-owned or Runtime-composed transition.\n *\n * Implementations resolve a stored result for `activation.digest`, compare\n * every target, and make the write durably idempotent. Co-located targets store\n * the all-or-none write with its result. Other targets throw when result\n * storage fails so a retry can reconcile it. Runtime never invokes this write\n * function after authorization expires.\n */\nexport type AgentImprovementActivationTransition = (\n input: AgentImprovementActivationTransitionInput,\n) => Promise<unknown>\n\n/**\n * Target-read-only check for a prior exact write.\n * It may persist recovered result metadata, but must not change an activation target.\n * Return undefined only when no target write can have committed.\n */\nexport type AgentImprovementActivationReconciliation = (\n input: AgentImprovementActivationTransitionInput,\n) => Promise<unknown | undefined>\n\nexport interface ExecuteAgentImprovementActivationInput {\n proposal: AgentImprovementProposal\n review: AgentImprovementReview\n activation: AgentImprovementActivation\n}\n\nexport interface ExecuteAgentImprovementActivationOptions {\n transition: AgentImprovementActivationTransition\n reconcile?: AgentImprovementActivationReconciliation\n now?: () => Date\n}\n\n/** Create the exact result a product stores in the same transaction as its target write. */\nexport function createAgentImprovementActivationResult(\n transition: AgentImprovementActivationTransitionInput,\n options: CreateAgentImprovementActivationResultOptions,\n): AgentImprovementActivationResult {\n const activation = verifyCanonicalCandidateDocument(\n agentImprovementActivationSchema.parse(transition.activation),\n 'agent improvement activation',\n )\n assertTransitionInput(activation, transition)\n const result = agentImprovementActivationResultSchema.parse(\n canonicalCandidateDocument<AgentImprovementActivationResult>({\n kind: 'agent-improvement-activation-result',\n idempotencyKey: activation.digest,\n attemptedAt: transition.attemptedAt,\n completedAt: options.completedAt,\n outcome: options.outcome,\n }).value,\n )\n assertResultAgainstActivation(activation, result)\n assertOutcomeDesiredState(\n activation,\n result,\n new Map(transition.targets.map((target) => [targetIdentity(target), target.desiredDigest])),\n )\n return immutableCandidateValue(result)\n}\n\n/**\n * Recompute one historical activation result against the exact measured proposal and authority.\n * The result records that attempt; it is not a query of the target's current state.\n */\nexport function verifyAgentImprovementActivationResult(input: {\n proposal: unknown\n review: unknown\n activation: unknown\n result: unknown\n}): AgentImprovementActivationResult {\n const proposal = verifyAgentImprovementProposal(input.proposal)\n const activation = verifyAgentImprovementActivation(input)\n const result = verifyCanonicalCandidateDocument(\n agentImprovementActivationResultSchema.parse(input.result),\n 'agent improvement activation result',\n )\n assertResultAgainstActivation(activation, result)\n assertResultDesiredState(proposal, activation, result)\n return result\n}\n\n/** Validate and execute one product-owned activation transition. */\nexport async function executeAgentImprovementActivation(\n input: ExecuteAgentImprovementActivationInput,\n options: ExecuteAgentImprovementActivationOptions,\n): Promise<AgentImprovementActivationResult> {\n const proposal = verifyAgentImprovementProposal(input.proposal)\n const activation = verifyAgentImprovementActivation(input)\n const observedAt = (options.now ?? (() => new Date()))().toISOString()\n const attemptedAt =\n Date.parse(observedAt) < Date.parse(activation.authorizedAt)\n ? activation.authorizedAt\n : observedAt\n const expired = Date.parse(attemptedAt) >= Date.parse(activation.expiresAt)\n const transition = immutableCandidateValue<AgentImprovementActivationTransitionInput>(\n proposal.evaluation.kind === 'agent-improvement-measured-comparison'\n ? sealedCandidateTransition(proposal.evaluation.experiment, activation, attemptedAt, expired)\n : profileImprovementTransition(\n proposal.evaluation.experiment,\n activation,\n attemptedAt,\n expired,\n ),\n )\n\n if (transition.expired) {\n if (!options.reconcile) {\n return uncertainActivationResult(transition, 'RECONCILIATION_UNAVAILABLE')\n }\n let reconciled: unknown\n try {\n reconciled = await options.reconcile(transition)\n } catch {\n return uncertainActivationResult(transition, 'RECONCILIATION_THROW')\n }\n if (reconciled === undefined) {\n return createAgentImprovementActivationResult(transition, {\n completedAt: transition.attemptedAt,\n outcome: { status: 'expired' },\n })\n }\n try {\n return verifyAgentImprovementActivationResult({ ...input, result: reconciled })\n } catch {\n return uncertainActivationResult(transition, 'INVALID_RECONCILIATION')\n }\n }\n\n let rawResult: unknown\n try {\n rawResult = await options.transition(transition)\n } catch {\n return uncertainActivationResult(transition, 'TRANSITION_THROW')\n }\n try {\n return verifyAgentImprovementActivationResult({ ...input, result: rawResult })\n } catch {\n return uncertainActivationResult(transition, 'INVALID_RESULT')\n }\n}\n\nfunction sealedCandidateTransition(\n experiment: AgentCandidateExperiment,\n activation: AgentImprovementActivation,\n attemptedAt: string,\n expired: boolean,\n): SealedCandidateActivationTransitionInput {\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n return {\n kind: 'sealed-candidate',\n activation,\n candidateBundle: experiment.candidate,\n bundle: experiment[targetArm],\n targets: activation.targets.map((target) => ({\n ...target,\n desiredDigest: agentImprovementTargetDigest(experiment, targetArm, target.surface),\n desiredInput: agentImprovementTargetInput(experiment[targetArm], target.surface),\n })) as SealedCandidateActivationTransitionInput['targets'],\n attemptedAt,\n expired,\n }\n}\n\nfunction profileImprovementTransition(\n experiment: AgentProfileImprovementExperiment,\n activation: AgentImprovementActivation,\n attemptedAt: string,\n expired: boolean,\n): ProfileImprovementActivationTransitionInput {\n const sourceArm = activation.intent === 'activate-candidate' ? 'baseline' : 'candidate'\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n const operation = profileImprovementOperation(experiment, activation.intent)\n return {\n kind: 'profile-improvement',\n activation,\n experiment,\n sourceStateDigest: agentProfileImprovementStateDigest(experiment, sourceArm),\n desiredStateDigest: agentProfileImprovementStateDigest(experiment, targetArm),\n operation,\n targets: activation.targets.map((target) => ({\n ...target,\n desiredDigest: agentProfileImprovementStateDigest(experiment, targetArm),\n desiredInput: operation,\n })) as ProfileImprovementActivationTransitionInput['targets'],\n attemptedAt,\n expired,\n }\n}\n\nfunction profileImprovementOperation(\n experiment: AgentProfileImprovementExperiment,\n intent: AgentImprovementActivation['intent'],\n): AgentProfileImprovementActivationOperation {\n return intent === 'activate-candidate'\n ? { kind: 'apply-change', changes: experiment.change }\n : { kind: 'restore-state' }\n}\n\nfunction uncertainActivationResult(\n transition: AgentImprovementActivationTransitionInput,\n code: string,\n): AgentImprovementActivationResult {\n return createAgentImprovementActivationResult(transition, {\n completedAt: transition.attemptedAt,\n outcome: {\n status: 'indeterminate',\n code,\n message: 'The product transition did not return a trustworthy commit result.',\n },\n })\n}\n\nfunction assertTransitionInput(\n activation: AgentImprovementActivation,\n transition: AgentImprovementActivationTransitionInput,\n): void {\n if (transition.kind === 'sealed-candidate') {\n assertSealedCandidateTransitionInput(activation, transition)\n return\n }\n assertProfileImprovementTransitionInput(activation, transition)\n}\n\nfunction assertSealedCandidateTransitionInput(\n activation: AgentImprovementActivation,\n transition: SealedCandidateActivationTransitionInput,\n): void {\n assertAuthorizedTransitionTargets(activation, transition.targets)\n const desiredInputsMatch = transition.targets.every(\n (target) =>\n canonicalCandidateDigest(target.desiredInput) ===\n canonicalCandidateDigest(agentImprovementTargetInput(transition.bundle, target.surface)),\n )\n if (\n transition.expired !== Date.parse(transition.attemptedAt) >= Date.parse(activation.expiresAt) ||\n transition.candidateBundle.digest !== activation.candidateDigest ||\n !desiredInputsMatch ||\n (activation.intent === 'activate-candidate' &&\n transition.bundle.digest !== transition.candidateBundle.digest)\n ) {\n throw new Error('activation transition does not match its authorization')\n }\n}\n\nfunction assertProfileImprovementTransitionInput(\n activation: AgentImprovementActivation,\n transition: ProfileImprovementActivationTransitionInput,\n): void {\n assertAuthorizedTransitionTargets(activation, transition.targets)\n const targetsAgentProfile = activation.targets.some(\n (target) => target.surface === 'agent-profile',\n )\n const experiment = agentProfileImprovementExperimentSchema.parse(transition.experiment)\n const sourceArm = activation.intent === 'activate-candidate' ? 'baseline' : 'candidate'\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n const sourceStateDigest = agentProfileImprovementStateDigest(experiment, sourceArm)\n const desiredStateDigest = agentProfileImprovementStateDigest(experiment, targetArm)\n const operation = profileImprovementOperation(experiment, activation.intent)\n const targetsMatch = transition.targets.every(\n (target) =>\n target.expectedBaseDigest === sourceStateDigest &&\n target.desiredDigest === desiredStateDigest &&\n canonicalCandidateDigest(target.desiredInput) === canonicalCandidateDigest(operation),\n )\n if (\n transition.expired !== Date.parse(transition.attemptedAt) >= Date.parse(activation.expiresAt) ||\n experiment.digest !== activation.experimentDigest ||\n experiment.candidate.stateDigest !== activation.candidateDigest ||\n (targetsAgentProfile &&\n (activation.executionRef === undefined ||\n canonicalCandidateDigest(activation.executionRef) !==\n canonicalCandidateDigest(experiment.executionRef))) ||\n transition.sourceStateDigest !== sourceStateDigest ||\n transition.desiredStateDigest !== desiredStateDigest ||\n canonicalCandidateDigest(transition.operation) !== canonicalCandidateDigest(operation) ||\n !targetsMatch\n ) {\n throw new Error('activation transition does not match its authorization')\n }\n}\n\nfunction assertAuthorizedTransitionTargets(\n activation: AgentImprovementActivation,\n targets: readonly AgentImprovementActivationTargetPlan[],\n): void {\n const authorized = targetMap(activation.targets)\n const planned = targetMap(targets)\n if (\n authorized.size !== planned.size ||\n [...authorized.entries()].some(\n ([identity, target]) =>\n planned.get(identity)?.expectedBaseDigest !== target.expectedBaseDigest,\n )\n ) {\n throw new Error('activation transition does not match its authorization')\n }\n}\n\nfunction assertResultAgainstActivation(\n activation: AgentImprovementActivation,\n result: AgentImprovementActivationResult,\n): void {\n const attemptedAt = Date.parse(result.attemptedAt)\n const completedAt = Date.parse(result.completedAt)\n const expiresAt = Date.parse(activation.expiresAt)\n if (\n result.idempotencyKey !== activation.digest ||\n attemptedAt < Date.parse(activation.authorizedAt) ||\n completedAt < attemptedAt\n ) {\n throw new Error('activation result does not bind its authorization')\n }\n const expired = attemptedAt >= expiresAt\n if (\n (result.outcome.status === 'expired' && !expired) ||\n (expired && !['expired', 'indeterminate', 'already-applied'].includes(result.outcome.status))\n ) {\n throw new Error('activation result does not honor its authorization expiry')\n }\n if (!('targets' in result.outcome)) return\n const authorized = targetMap(activation.targets)\n const observed = new Set(result.outcome.targets.map(targetIdentity))\n if (\n authorized.size !== observed.size ||\n [...authorized.keys()].some((identity) => !observed.has(identity))\n ) {\n throw new Error('activation result must cover every authorized target exactly once')\n }\n if (\n result.outcome.status === 'applied' &&\n result.outcome.targets.some(\n (target) =>\n target.beforeDigest !== authorized.get(targetIdentity(target))?.expectedBaseDigest,\n )\n ) {\n throw new Error('applied activation did not start from its authorized base state')\n }\n}\n\nfunction assertResultDesiredState(\n proposal: AgentImprovementProposal,\n activation: AgentImprovementActivation,\n result: AgentImprovementActivationResult,\n): void {\n if (!('targets' in result.outcome)) return\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n const desiredStateDigest =\n proposal.evaluation.kind === 'agent-profile-improvement-measured-comparison'\n ? agentProfileImprovementStateDigest(proposal.evaluation.experiment, targetArm)\n : undefined\n const desired = new Map(\n activation.targets.map((target) => [\n targetIdentity(target),\n desiredStateDigest ??\n agentImprovementTargetDigest(\n requireSealedCandidateExperiment(proposal),\n targetArm,\n target.surface,\n ),\n ]),\n )\n assertOutcomeDesiredState(activation, result, desired)\n}\n\nfunction assertOutcomeDesiredState(\n activation: AgentImprovementActivation,\n result: AgentImprovementActivationResult,\n desired: ReadonlyMap<string, Sha256Digest>,\n): void {\n if (!('targets' in result.outcome)) return\n if (result.outcome.status === 'applied') {\n if (\n result.outcome.targets.some(\n (target) => target.afterDigest !== desired.get(targetIdentity(target)),\n )\n ) {\n throw new Error('applied activation does not match the requested bundle')\n }\n return\n }\n const allDesired = result.outcome.targets.every(\n (target) => target.currentDigest === desired.get(targetIdentity(target)),\n )\n if (result.outcome.status === 'already-applied') {\n if (!allDesired) throw new Error('already-applied activation is not at the requested state')\n return\n }\n const authorized = targetMap(activation.targets)\n const hasStaleTarget = result.outcome.targets.some(\n (target) => target.currentDigest !== authorized.get(targetIdentity(target))?.expectedBaseDigest,\n )\n if (allDesired || !hasStaleTarget) {\n throw new Error('activation conflict does not identify stale target state')\n }\n}\n\nfunction targetMap<T extends { surface: AgentImprovementSurface; identity: string }>(\n targets: readonly T[],\n): Map<string, T> {\n return new Map(targets.map((target) => [targetIdentity(target), target]))\n}\n\nfunction targetIdentity(target: { surface: AgentImprovementSurface; identity: string }): string {\n return `${target.surface}\\u0000${target.identity}`\n}\n"],"mappings":";;;;AAoBA,SAAgB,2BAA+C;CAC7D,OAAO;EAAE,UAAU;EAAG,WAAW;EAAG,SAAS;EAAG,UAAU;CAAE;AAC9D;AAEA,SAAgB,cAAc,OAAiC;CAC7D,OAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,SAAS;AACzE;;AAGA,SAAgB,gBACd,QACA,OACM;CACN,OAAO,YAAY;CACnB,KAAK,MAAM,OAAO;EAAC;EAAY;EAAa;CAAS,GAAY;EAC/D,MAAM,QAAQ,MAAM;EACpB,IAAI,cAAc,KAAK,GAAG,OAAO,QAAQ;OACpC,IAAI,QAAQ,WAAW,OAAO,WAAW;OACzC,OAAO,cAAc;CAC5B;CACA,IAAI,MAAM,gBAAgB,OAAO,OAAO,cAAc;CACtD,IAAI,MAAM,aAAa,OAAO,OAAO,WAAW;CAChD,IAAI,cAAc,MAAM,gBAAgB,GACtC,OAAO,oBAAoB,OAAO,oBAAoB,KAAK,MAAM;AAErE;;;;ACgGA,SAAgB,uCACd,YACA,SACkC;CAClC,MAAM,aAAa,iCACjB,iCAAiC,MAAM,WAAW,UAAU,GAC5D,8BACF;CACA,sBAAsB,YAAY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AM,IAAI,MAAM,0DAA0D;EAC3F;CACF;CACA,MAAM,aAAa,UAAU,WAAW,OAAO;CAC/C,MAAM,iBAAiB,OAAO,QAAQ,QAAQ,MAC3C,WAAW,OAAO,kBAAkB,WAAW,IAAI,eAAe,MAAM,CAAC,CAAC,EAAE,kBAC/E;CACA,IAAI,cAAc,CAAC,gBACjB,MAAM,IAAI,MAAM,0DAA0D;AAE9E;AAEA,SAAS,UACP,SACgB;CAChB,OAAO,IAAI,IAAI,QAAQ,KAAK,WAAW,CAAC,eAAe,MAAM,GAAG,MAAM,CAAC,CAAC;AAC1E;AAEA,SAAS,eAAe,QAAwE;CAC9F,OAAO,GAAG,OAAO,QAAQ,QAAQ,OAAO;AAC1C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as ExecutorConfig, i as CollectedAgentTurn, r as AgentTurnUsage } from "./stream-agent-turn-
|
|
1
|
+
import { f as ExecutorConfig, i as CollectedAgentTurn, r as AgentTurnUsage } from "./stream-agent-turn-oeWkjxMi.js";
|
|
2
2
|
import { AgentCandidateBundle, AgentImprovementActivation, AgentImprovementActivationOutcome, AgentImprovementActivationResult, AgentImprovementActivationTarget, AgentImprovementProposal, AgentImprovementReview, AgentImprovementSurface, AgentProfile, AgentProfileDiff, AgentProfileImprovementChange, AgentProfileImprovementExperiment, AgentTrainingReceipt, AgentTrainingTask, HarnessType, ReasoningEffort, Sha256Digest } from "@tangle-network/agent-interface";
|
|
3
3
|
import { CostLedgerHandle, MaximumCharge, ProposalFinding } from "@tangle-network/agent-eval";
|
|
4
4
|
import { CampaignScenarioIdentity, CompareOptimizationMethodsOptions, OptimizationMethod, OptimizationMethodComparison, WorktreeAdapter } from "@tangle-network/agent-eval/campaign";
|
|
@@ -768,4 +768,4 @@ declare function verifyAgentImprovementActivationResult(input: {
|
|
|
768
768
|
declare function executeAgentImprovementActivation(input: ExecuteAgentImprovementActivationInput, options: ExecuteAgentImprovementActivationOptions): Promise<AgentImprovementActivationResult>;
|
|
769
769
|
//#endregion
|
|
770
770
|
export { ImprovementMaterializedProfilePopulationCandidate as $, ImproveCodeResult as A, ImproveMethodSource as B, TrainingBoundaryResult as C, CandidateGenerator as Ct, ImproveCandidateValidator as D, ImproveCandidateValidationInput as E, ImproveMethodContext as F, ImproveProfileSurface as G, ImproveOptions as H, ImproveMethodFactory as I, ImproveScenarioPartitions as J, ImproveResult as K, ImproveMethodLineage as L, ImproveCost as M, ImproveCustomCodeGeneratorOptions as N, ImproveCodeBaseOptions as O, ImproveLineage as P, ImprovementCodeCandidate as Q, ImproveMethodOptions as R, ProfileTrainerRequest as S, defaultBuildPrompt as St, createCommandProfileTrainer as T, ImproveProfileAgent as U, ImproveOptimizationRunOptions as V, ImproveProfileComponents as W, ImproveSurface as X, ImproveSkillsOptions as Y, ImprovementCandidate as Z, CheckpointServingPort as _, AgenticGeneratorShotReceipt as _t, AgentImprovementActivationTransitionInput as a, ImprovementProfilePopulationCandidate as at, ImproveTrainingResult as b, agenticGenerator as bt, CreateAgentImprovementActivationResultOptions as c, ImprovementProfilePopulationLineageNode as ct, ProfileImprovementActivationTransitionInput as d, DeepReadonly as dt, ImprovementProfileCandidate as et, SealedCandidateActivationTransitionInput as f, ReadonlyAgentProfile as ft, improve as g, AgenticGeneratorShotExecution as gt, verifyAgentImprovementActivationResult as h, AgenticGeneratorShotDisposition as ht, AgentImprovementActivationTransition as i, ImprovementProfilePopulationArtifactSource as it, ImproveCodeRunOptions as j, ImproveCodeOptions as k, ExecuteAgentImprovementActivationInput as l, ImprovementProfilePopulationObservationSource as lt, executeAgentImprovementActivation as m, AgenticGeneratorOptions as mt, AgentImprovementActivationResultStore as n, ImprovementProfileCandidatePopulationAvailable as nt, AgentProfileImprovementActivationOperation as o, ImprovementProfilePopulationCandidateSource as ot, createAgentImprovementActivationResult as p, AgenticGeneratorExecutorForWorktree as pt, ImproveRuntimeCodeGeneratorOptions as q, AgentImprovementActivationTargetPlan as r, ImprovementProfileCandidatePopulationUnavailable as rt, AgentProfileImprovementActivationTargetPlan as s, ImprovementProfilePopulationLineage as st, AgentImprovementActivationReconciliation as t, ImprovementProfileCandidatePopulation as tt, ExecuteAgentImprovementActivationOptions as u, ImprovementRefusedProfilePopulationCandidate as ut, ControlledTrainingCommand as v, Verifier as vt, TrainingDatasetDocument as w, ProfileTrainer as x, commandVerifier as xt, ImproveTrainingOptions as y, VerifyResult as yt, ImproveMethodResult as z };
|
|
771
|
-
//# sourceMappingURL=activation-
|
|
771
|
+
//# sourceMappingURL=activation-BykUtuec.d.ts.map
|
package/dist/agent.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Gi as RuntimeStreamEvent, Vr as AgentRunSpec, fi as SandboxClient, ui as OutputAdapter } from "./types-
|
|
1
|
+
import { Gi as RuntimeStreamEvent, Vr as AgentRunSpec, fi as SandboxClient, ui as OutputAdapter } from "./types-BmxS-W-f.js";
|
|
2
2
|
import { a as createSurfaceImprovementProposer, c as SurfaceValidationIssue, d as validateSurfaces, i as SurfaceImprovementEdit, l as renderSurfaceIssues, n as DraftPatchInput, o as AgentSurfaces, r as DraftPatchOutput, s as ResolvedSurface, t as CreateSurfaceImprovementProposerOptions, u as resolveSubjectPath } from "./improvement-adapter-D5gwwoXQ.js";
|
|
3
|
-
import { Am as DefineProfileMaterializationContractOptions, Bm as promptControlProfileMaterialization, Dm as AgentProfileMaterializationAxis, Em as AGENT_PROFILE_MATERIALIZATION_AXES, Fm as assertProfileMaterialization, Gm as sandboxActProfileMaterialization, Hm as promptOnlyProfileMaterialization, Im as controlProfileMaterialization, Km as validateProfileMaterialization, Lm as defineProfileMaterializationContract, Mm as ProfileMaterializationContract, Nm as ProfileMaterializationIssue, Om as AssertProfileMaterializationOptions, Pm as ValidateProfileMaterializationOptions, Rm as fullProfileMaterialization, Um as promptResourceProfileMaterialization, Vm as promptModelProfileMaterialization, Wm as renderProfileMaterializationIssues, jm as KnownAgentProfileMaterializationAxis, km as CanonicalAgentProfileMaterializationAxis, qm as worktreeCliProfileMaterialization, zm as profileMaterializationAxes } from "./index-
|
|
3
|
+
import { Am as DefineProfileMaterializationContractOptions, Bm as promptControlProfileMaterialization, Dm as AgentProfileMaterializationAxis, Em as AGENT_PROFILE_MATERIALIZATION_AXES, Fm as assertProfileMaterialization, Gm as sandboxActProfileMaterialization, Hm as promptOnlyProfileMaterialization, Im as controlProfileMaterialization, Km as validateProfileMaterialization, Lm as defineProfileMaterializationContract, Mm as ProfileMaterializationContract, Nm as ProfileMaterializationIssue, Om as AssertProfileMaterializationOptions, Pm as ValidateProfileMaterializationOptions, Rm as fullProfileMaterialization, Um as promptResourceProfileMaterialization, Vm as promptModelProfileMaterialization, Wm as renderProfileMaterializationIssues, jm as KnownAgentProfileMaterializationAxis, km as CanonicalAgentProfileMaterializationAxis, qm as worktreeCliProfileMaterialization, zm as profileMaterializationAxes } from "./index-DGWG7wSS.js";
|
|
4
4
|
import { AgentProfile, AgentProfileFileMount, AgentProfileMcpServer } from "@tangle-network/agent-interface";
|
|
5
5
|
import { TraceAnalystDefinition } from "@tangle-network/agent-eval";
|
|
6
6
|
import { SandboxEvent } from "@tangle-network/sandbox";
|
package/dist/agent.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Ai as mapSandboxEvent, Br as promptControlProfileMaterialization, Fr as assertProfileMaterialization, Hr as promptOnlyProfileMaterialization, Ir as controlProfileMaterialization, Jr as validateProfileMaterialization, Kr as sandboxActProfileMaterialization, Lr as defineProfileMaterializationContract, Pr as AGENT_PROFILE_MATERIALIZATION_AXES, Rr as fullProfileMaterialization, Ur as promptResourceProfileMaterialization, Vr as promptModelProfileMaterialization, Wr as renderProfileMaterializationIssues, Yr as worktreeCliProfileMaterialization, mn as createSandboxForSpec, zr as profileMaterializationAxes } from "./supervisor-
|
|
2
|
-
import "./runtime-
|
|
1
|
+
import { Ai as mapSandboxEvent, Br as promptControlProfileMaterialization, Fr as assertProfileMaterialization, Hr as promptOnlyProfileMaterialization, Ir as controlProfileMaterialization, Jr as validateProfileMaterialization, Kr as sandboxActProfileMaterialization, Lr as defineProfileMaterializationContract, Pr as AGENT_PROFILE_MATERIALIZATION_AXES, Rr as fullProfileMaterialization, Ur as promptResourceProfileMaterialization, Vr as promptModelProfileMaterialization, Wr as renderProfileMaterializationIssues, Yr as worktreeCliProfileMaterialization, mn as createSandboxForSpec, zr as profileMaterializationAxes } from "./supervisor-OJwKAnFd.js";
|
|
2
|
+
import "./runtime-CMNTa7Rw.js";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
5
5
|
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { D as omitTopLevelDigest, E as immutableCandidateValue, S as canonicalCandidateDigest$1 } from "./workspace-archive-DQGFwvM6.js";
|
|
2
|
+
import { agentCandidateBundleSchema } from "@tangle-network/agent-interface";
|
|
3
|
+
//#region src/candidate-execution/bundle.ts
|
|
4
|
+
/** Validate and content-address a candidate bundle before it crosses an approval boundary. */
|
|
5
|
+
function sealAgentCandidateBundle(input) {
|
|
6
|
+
const digest = canonicalCandidateDigest$1(input);
|
|
7
|
+
const parsed = agentCandidateBundleSchema.parse({
|
|
8
|
+
...input,
|
|
9
|
+
digest
|
|
10
|
+
});
|
|
11
|
+
if (canonicalCandidateDigest$1(omitTopLevelDigest(parsed)) !== digest) throw new Error("candidate bundle changed while validating its canonical wire shape");
|
|
12
|
+
return immutableCandidateValue(parsed);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { sealAgentCandidateBundle as t };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=bundle-DXrBPEFw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-DXrBPEFw.js","names":["canonicalCandidateDigest"],"sources":["../src/candidate-execution/bundle.ts"],"sourcesContent":["import type { AgentCandidateBundle } from '@tangle-network/agent-interface'\nimport { agentCandidateBundleSchema } from '@tangle-network/agent-interface'\n\nimport { canonicalCandidateDigest, immutableCandidateValue, omitTopLevelDigest } from './digest'\n\n/** Exact candidate wire shape before the runtime computes its canonical digest. */\nexport type AgentCandidateBundleInput = Omit<AgentCandidateBundle, 'digest'>\n\n/** Validate and content-address a candidate bundle before it crosses an approval boundary. */\nexport function sealAgentCandidateBundle(input: AgentCandidateBundleInput): AgentCandidateBundle {\n const digest = canonicalCandidateDigest(input)\n const parsed = agentCandidateBundleSchema.parse({ ...input, digest })\n const parsedDigest = canonicalCandidateDigest(omitTopLevelDigest(parsed))\n if (parsedDigest !== digest) {\n throw new Error('candidate bundle changed while validating its canonical wire shape')\n }\n return immutableCandidateValue(parsed)\n}\n"],"mappings":";;;;AASA,SAAgB,yBAAyB,OAAwD;CAC/F,MAAM,SAASA,2BAAyB,KAAK;CAC7C,MAAM,SAAS,2BAA2B,MAAM;EAAE,GAAG;EAAO;CAAO,CAAC;CAEpE,IADqBA,2BAAyB,mBAAmB,MAAM,CACxD,MAAM,QACnB,MAAM,IAAI,MAAM,oEAAoE;CAEtF,OAAO,wBAAwB,MAAM;AACvC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as canonicalCandidateBytes$1,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as exactProcessProviderAsCandidateExecutor, t as createProtectedAgentCandidateModelPort } from "../protected-model-port-
|
|
1
|
+
import { T as embeddedCandidateArtifact, a as persistCandidateOutputArtifact, g as scanMaterializedWorkspaceManifest, h as readVerifiedArtifact, n as captureAgentCandidateWorkspaceFiles, p as candidateWorkspaceManifest, r as createAgentCandidateWorkspacePort, t as captureAgentCandidateWorkspace, x as canonicalCandidateBytes$1, y as verifyMaterializedWorkspace } from "../workspace-archive-DQGFwvM6.js";
|
|
2
|
+
import { B as assertRecoveryMatchesStaged, C as applyExactAgentProfileDiff, D as freezeGenericAgentCandidateProfile, F as InMemoryAgentCandidateExecutionClaimStore, G as rejectedFinish, H as assertTerminalMatchesClaim, I as candidateClaimFileInternals, J as sealTerminalDigest, K as rejectedStage, L as candidateCleanupDeadline, M as parseExactAgentProfileDiff, N as parseExactCandidateProfile, R as candidateCleanupTimeout, S as agentCandidateProfileAsAgentProfile, U as assertTerminalMatchesStaged, V as assertTerminalAllowedInPhase, W as recoveredTerminalRecord, Y as terminalRecord, _ as consumePreparedCandidateExecution, a as AGENT_CANDIDATE_EXECUTION_SUPPORT, c as executePreparedAgentCandidate, d as sealAgentCandidateModelSettlement, g as beginPreparedCandidateDisposal, h as assertPreparedCandidateIntegrity, i as candidateKnowledgeExecutionPaths, j as parseExactAgentProfile, k as omitUndefinedObjectFields, l as RecoveryAgentCandidateTraceStore, m as candidateExecutionClaim, n as CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV, p as sealAgentCandidateExecutorStopAcknowledgement, q as requireStagedTerminal, r as CANDIDATE_KNOWLEDGE_ROOT_ENV, s as verifyAgentCandidateBundle, t as prepareAgentCandidateExecution, u as persistCandidateModelSettlementEvidence, v as CANDIDATE_TRACE_ENV, w as assertCandidateProfileBinding, y as CANDIDATE_TRACE_TAGS, z as withinCandidateCleanupDeadline } from "../prepare-RuaAclli.js";
|
|
3
|
+
import { t as sealAgentCandidateBundle } from "../bundle-DXrBPEFw.js";
|
|
4
|
+
import { n as exactProcessProviderAsCandidateExecutor, t as createProtectedAgentCandidateModelPort } from "../protected-model-port-BFhSgMAy.js";
|
|
5
5
|
import { agentCandidateExecutionPlanMaterialSchema, agentCandidateMaterializationReceiptSchema } from "@tangle-network/agent-interface";
|
|
6
6
|
import { createHash, randomUUID } from "node:crypto";
|
|
7
7
|
import { constants, linkSync } from "node:fs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $i as withBudgetResources, $r as writeAllBytes, At as workerTraceAnalysisStore, Hi as promptCacheTokenClasses, Ji as unmeteredSpend, Li as chargedTokens, Mt as assertValidBudget, Qr as readCommittedJsonLines, Qt as createPeerMailbox, R as scopeRetainedOwnerResourceReader, U as resolveSpawnResourcePaths, Yn as resolveRedactor, Zi as addResourceSpend, Zr as prepareJsonlAppend, _t as FileResultBlobStore, a as pickBestDelivered, bi as detachedFrozen, bt as InMemorySpawnJournal, ci as providerAttemptEvidence, dt as createExecutorRegistry, g as withDriverExecutor, kt as parseWorkerToolTraceArtifact, nn as isLiveNodeStatus, o as runFinalizer, qt as createInbox, r as bestDelivered, rn as isTerminalNodeStatus, rt as freeSlots, s as runTree, tt as errMessage, vt as FileSpawnJournal, wn as runBrainLoop, x as meterRuntimeOwnedProviderAttempt, yt as InMemoryResultBlobStore } from "./supervisor-
|
|
1
|
+
import { $i as withBudgetResources, $r as writeAllBytes, At as workerTraceAnalysisStore, Hi as promptCacheTokenClasses, Ji as unmeteredSpend, Li as chargedTokens, Mt as assertValidBudget, Qr as readCommittedJsonLines, Qt as createPeerMailbox, R as scopeRetainedOwnerResourceReader, U as resolveSpawnResourcePaths, Yn as resolveRedactor, Zi as addResourceSpend, Zr as prepareJsonlAppend, _t as FileResultBlobStore, a as pickBestDelivered, bi as detachedFrozen, bt as InMemorySpawnJournal, ci as providerAttemptEvidence, dt as createExecutorRegistry, g as withDriverExecutor, kt as parseWorkerToolTraceArtifact, nn as isLiveNodeStatus, o as runFinalizer, qt as createInbox, r as bestDelivered, rn as isTerminalNodeStatus, rt as freeSlots, s as runTree, tt as errMessage, vt as FileSpawnJournal, wn as runBrainLoop, x as meterRuntimeOwnedProviderAttempt, yt as InMemoryResultBlobStore } from "./supervisor-OJwKAnFd.js";
|
|
2
2
|
import { f as RuntimeRunStateError, m as ValidationError } from "./errors-DodWX-cb.js";
|
|
3
|
-
import { A as writeWorkerCancellation, M as writeWorkerSteerAcknowledgement, b as workerCancellationsDir, c as readWorkerCancelRequests, d as readWorkerSteerRequests, k as writeRunCancellation, l as readWorkerCancellation, o as readRunCancelRequest, r as claimWorkerSteerDelivery, s as readRunCancellation, u as readWorkerSteerAcknowledgement } from "./run-layout-
|
|
3
|
+
import { A as writeWorkerCancellation, M as writeWorkerSteerAcknowledgement, b as workerCancellationsDir, c as readWorkerCancelRequests, d as readWorkerSteerRequests, k as writeRunCancellation, l as readWorkerCancellation, o as readRunCancelRequest, r as claimWorkerSteerDelivery, s as readRunCancellation, u as readWorkerSteerAcknowledgement } from "./run-layout-vwd4SwX_.js";
|
|
4
4
|
import { agentProfileSchema, canonicalCandidateDigest } from "@tangle-network/agent-interface";
|
|
5
5
|
import { argHash, errorStreakDetector, observeAll, repeatedActionDetector } from "@tangle-network/agent-eval";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
@@ -120,6 +120,110 @@ function createEventBus(now = Date.now) {
|
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
//#endregion
|
|
123
|
+
//#region src/mcp/tools/worker-output.ts
|
|
124
|
+
const WORKER_OUTPUT_PAGE_CHARS = 16384;
|
|
125
|
+
function workerOutputReadOptions(raw) {
|
|
126
|
+
const offset = raw.outputOffset ?? 0;
|
|
127
|
+
const limit = raw.outputLimit ?? 16384;
|
|
128
|
+
const path = raw.outputPath === void 0 ? [] : raw.outputPath;
|
|
129
|
+
if (!Array.isArray(path) || !path.every((part) => typeof part === "string")) throw new Error("observe_agent outputPath must be an array of field names");
|
|
130
|
+
if (typeof offset !== "number" || !Number.isSafeInteger(offset) || offset < 0) throw new Error("observe_agent outputOffset must be a nonnegative safe integer");
|
|
131
|
+
if (typeof limit !== "number" || !Number.isSafeInteger(limit) || limit < 1 || limit > 16384) throw new Error(`observe_agent outputLimit must be an integer from 1 to ${WORKER_OUTPUT_PAGE_CHARS}`);
|
|
132
|
+
return {
|
|
133
|
+
offset,
|
|
134
|
+
limit,
|
|
135
|
+
path
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function samePath(left, right) {
|
|
139
|
+
return left.length === right.length && left.every((field, index) => field === right[index]);
|
|
140
|
+
}
|
|
141
|
+
function selectWorkerOutput(output, path) {
|
|
142
|
+
let selected = output;
|
|
143
|
+
for (const field of path) {
|
|
144
|
+
if (selected === null || typeof selected !== "object" || !Object.hasOwn(selected, field)) throw new Error("observe_agent outputPath does not identify a retained field");
|
|
145
|
+
selected = selected[field];
|
|
146
|
+
}
|
|
147
|
+
return selected;
|
|
148
|
+
}
|
|
149
|
+
async function encodeWorkerOutput(blobs, outRef, path) {
|
|
150
|
+
const retained = await blobs.get(outRef);
|
|
151
|
+
if (retained === void 0) return { kind: "missing" };
|
|
152
|
+
const output = selectWorkerOutput(retained, path);
|
|
153
|
+
const text = JSON.stringify(output);
|
|
154
|
+
if (text === void 0) throw new Error("observe_agent result blob is not JSON-serializable");
|
|
155
|
+
return text.length > 16384 ? {
|
|
156
|
+
kind: "page",
|
|
157
|
+
text
|
|
158
|
+
} : {
|
|
159
|
+
kind: "small",
|
|
160
|
+
output,
|
|
161
|
+
text
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function readEncodedWorkerOutput(encoded, { offset, limit }) {
|
|
165
|
+
if (encoded.kind === "missing") return {
|
|
166
|
+
output: null,
|
|
167
|
+
outputUnavailable: "result-blob-missing"
|
|
168
|
+
};
|
|
169
|
+
const { text } = encoded;
|
|
170
|
+
if (offset > text.length) throw new Error("observe_agent outputOffset exceeds the retained output");
|
|
171
|
+
if (encoded.kind === "small" && offset === 0 && text.length <= limit) return { output: encoded.output };
|
|
172
|
+
const end = Math.min(offset + limit, text.length);
|
|
173
|
+
return {
|
|
174
|
+
output: null,
|
|
175
|
+
outputPage: {
|
|
176
|
+
format: "json",
|
|
177
|
+
text: text.slice(offset, end),
|
|
178
|
+
offset,
|
|
179
|
+
nextOffset: end < text.length ? end : null,
|
|
180
|
+
totalChars: text.length
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Create a manager-scoped reader for immutable retained artifacts.
|
|
186
|
+
*
|
|
187
|
+
* At most one selected `outRef` + path is retained. Concurrent reads for that selection share the
|
|
188
|
+
* blob read and JSON encoding; missing blobs and rejected selections are evicted after all readers
|
|
189
|
+
* leave so a transient failure cannot poison later observations.
|
|
190
|
+
*/
|
|
191
|
+
function createWorkerOutputReader(blobs) {
|
|
192
|
+
let cached;
|
|
193
|
+
return async (outRef, options) => {
|
|
194
|
+
if (outRef === void 0) return { output: null };
|
|
195
|
+
let entry = cached;
|
|
196
|
+
if (entry === void 0 || entry.outRef !== outRef || !samePath(entry.path, options.path)) {
|
|
197
|
+
const path = [...options.path];
|
|
198
|
+
entry = {
|
|
199
|
+
outRef,
|
|
200
|
+
path,
|
|
201
|
+
result: encodeWorkerOutput(blobs, outRef, path),
|
|
202
|
+
activeReads: 0,
|
|
203
|
+
releaseWhenIdle: false
|
|
204
|
+
};
|
|
205
|
+
cached = entry;
|
|
206
|
+
}
|
|
207
|
+
entry.activeReads += 1;
|
|
208
|
+
try {
|
|
209
|
+
const encoded = await entry.result;
|
|
210
|
+
const reply = readEncodedWorkerOutput(encoded, options);
|
|
211
|
+
if (encoded.kind === "missing") entry.releaseWhenIdle = true;
|
|
212
|
+
else {
|
|
213
|
+
const page = reply.outputPage;
|
|
214
|
+
if (page === void 0 || page.nextOffset === null) entry.releaseWhenIdle = true;
|
|
215
|
+
}
|
|
216
|
+
return reply;
|
|
217
|
+
} catch (error) {
|
|
218
|
+
entry.releaseWhenIdle = true;
|
|
219
|
+
throw error;
|
|
220
|
+
} finally {
|
|
221
|
+
entry.activeReads -= 1;
|
|
222
|
+
if (entry.releaseWhenIdle && entry.activeReads === 0 && cached === entry) cached = void 0;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
//#endregion
|
|
123
227
|
//#region src/mcp/tools/coordination.ts
|
|
124
228
|
/**
|
|
125
229
|
*
|
|
@@ -659,6 +763,7 @@ function createCoordinationTools(opts) {
|
|
|
659
763
|
/** Internal manager binding; its lifetime fences delivery without cancelling the worker scope. */
|
|
660
764
|
function createCoordinationToolsForManager(opts, lifetime) {
|
|
661
765
|
const deliverable = opts.deliverable;
|
|
766
|
+
const readWorkerOutput = createWorkerOutputReader(opts.blobs);
|
|
662
767
|
const priorSubmission = deliverable === void 0 ? void 0 : opts.priorJournal?.find((record) => record.event.type === "submission");
|
|
663
768
|
let stopped = priorSubmission !== void 0;
|
|
664
769
|
let reason = priorSubmission === void 0 ? void 0 : "result-accepted";
|
|
@@ -1220,7 +1325,11 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
1220
1325
|
type: "settled",
|
|
1221
1326
|
settled: id,
|
|
1222
1327
|
status,
|
|
1223
|
-
...evidence
|
|
1328
|
+
...evidence,
|
|
1329
|
+
...evidence.outRef === void 0 ? {} : { outputRead: {
|
|
1330
|
+
tool: "observe_agent",
|
|
1331
|
+
arguments: { workerId: id }
|
|
1332
|
+
} }
|
|
1224
1333
|
};
|
|
1225
1334
|
}
|
|
1226
1335
|
if (ev.type === "question") return {
|
|
@@ -1795,6 +1904,10 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
1795
1904
|
resumed: "completed",
|
|
1796
1905
|
status,
|
|
1797
1906
|
...evidence,
|
|
1907
|
+
...evidence.outRef === void 0 ? {} : { outputRead: {
|
|
1908
|
+
tool: "observe_agent",
|
|
1909
|
+
arguments: { workerId: id }
|
|
1910
|
+
} },
|
|
1798
1911
|
live: liveWorkerCount(),
|
|
1799
1912
|
freeSlots: freeWorkerSlots()
|
|
1800
1913
|
});
|
|
@@ -1839,14 +1952,34 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
1839
1952
|
},
|
|
1840
1953
|
{
|
|
1841
1954
|
name: "observe_agent",
|
|
1842
|
-
description: "Inspect a worker WHILE IT RUNS, not only after it finishes: status, spend so far, and `progress` — how long since it last did anything (`idleMs`), whether that counts as stalled, how many turns it has taken, the last tools/files it touched (`recentActivity`), what its executor CHANGED about the profile you gave it (`derived` — an MCP config it materialized, an extension it had to add), whether a steer can even reach it (`steerable`), and how many steers it has not yet read (`pendingMessages`). A worker whose executor has FINISHED but whose settlement you have not yet drained reports `settlementPending` with its terminal kind; its `status` still reads running until await_event delivers it, so call await_event, not observe_agent again. The settled output artifact is returned once drained. Use this BEFORE steer_agent: a steer is only worth sending when the progress says the worker is on the wrong path or has stopped making any.",
|
|
1955
|
+
description: "Inspect a worker WHILE IT RUNS, not only after it finishes: status, spend so far, and `progress` — how long since it last did anything (`idleMs`), whether that counts as stalled, how many turns it has taken, the last tools/files it touched (`recentActivity`), what its executor CHANGED about the profile you gave it (`derived` — an MCP config it materialized, an extension it had to add), whether a steer can even reach it (`steerable`), and how many steers it has not yet read (`pendingMessages`). A worker whose executor has FINISHED but whose settlement you have not yet drained reports `settlementPending` with its terminal kind; its `status` still reads running until await_event delivers it, so call await_event, not observe_agent again. The settled output artifact is returned once drained. Select a field with `outputPath`, for example [\"content\"] to read a provider result without its event history. Omit it to read the complete artifact. Large outputs return a bounded JSON `outputPage`; repeat with `outputOffset: outputPage.nextOffset` until it is null, concatenate page text, then parse the JSON. Offsets and limits count UTF-16 characters. The full artifact stays retained; an outRef is a content address, not a workspace path. Use this BEFORE steer_agent: a steer is only worth sending when the progress says the worker is on the wrong path or has stopped making any.",
|
|
1843
1956
|
inputSchema: {
|
|
1844
1957
|
type: "object",
|
|
1845
|
-
properties: {
|
|
1958
|
+
properties: {
|
|
1959
|
+
workerId: idArg,
|
|
1960
|
+
outputPath: {
|
|
1961
|
+
type: "array",
|
|
1962
|
+
items: { type: "string" },
|
|
1963
|
+
description: "Own field names from the artifact root; array indices use strings. Default: the complete artifact."
|
|
1964
|
+
},
|
|
1965
|
+
outputOffset: {
|
|
1966
|
+
type: "integer",
|
|
1967
|
+
minimum: 0,
|
|
1968
|
+
description: "Start at this retained JSON character offset; default 0."
|
|
1969
|
+
},
|
|
1970
|
+
outputLimit: {
|
|
1971
|
+
type: "integer",
|
|
1972
|
+
minimum: 1,
|
|
1973
|
+
maximum: WORKER_OUTPUT_PAGE_CHARS,
|
|
1974
|
+
description: `Maximum JSON characters per page; default ${WORKER_OUTPUT_PAGE_CHARS}.`
|
|
1975
|
+
}
|
|
1976
|
+
},
|
|
1846
1977
|
required: ["workerId"]
|
|
1847
1978
|
},
|
|
1848
1979
|
handler: async (raw) => {
|
|
1849
|
-
const
|
|
1980
|
+
const args = obj(raw);
|
|
1981
|
+
const id = str(args.workerId, "workerId");
|
|
1982
|
+
const outputRead = workerOutputReadOptions(args);
|
|
1850
1983
|
const node = opts.scope.view.nodes.find((n) => n.id === id);
|
|
1851
1984
|
if (!node) {
|
|
1852
1985
|
const resumed = opts.scope.resume?.view.nodes.find((n) => n.id === id);
|
|
@@ -1854,21 +1987,19 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
1854
1987
|
error: "unknown-worker",
|
|
1855
1988
|
reason: `no worker of this manager has the id ${JSON.stringify(id)}; spawn_worker returns the ids you may observe`
|
|
1856
1989
|
};
|
|
1857
|
-
const output = resumed.outRef ? await opts.blobs.get(resumed.outRef) : void 0;
|
|
1858
1990
|
return {
|
|
1859
1991
|
...projectNodeEvidence(resumed, true),
|
|
1860
1992
|
outRef: resumed.outRef ?? null,
|
|
1861
|
-
|
|
1993
|
+
...await readWorkerOutput(resumed.outRef, outputRead),
|
|
1862
1994
|
progress: null
|
|
1863
1995
|
};
|
|
1864
1996
|
}
|
|
1865
|
-
const output = node.outRef ? await opts.blobs.get(node.outRef) : void 0;
|
|
1866
1997
|
const progress = readProgress(id);
|
|
1867
1998
|
const pending = node.settlementPending;
|
|
1868
1999
|
return {
|
|
1869
2000
|
...projectNodeEvidence(node),
|
|
1870
2001
|
outRef: node.outRef ?? null,
|
|
1871
|
-
|
|
2002
|
+
...await readWorkerOutput(node.outRef, outputRead),
|
|
1872
2003
|
progress: progress ?? null,
|
|
1873
2004
|
...pending ? {
|
|
1874
2005
|
settlementPending: pending,
|
|
@@ -1914,7 +2045,7 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
1914
2045
|
},
|
|
1915
2046
|
{
|
|
1916
2047
|
name: "await_event",
|
|
1917
|
-
description: "Wait for and pull the next message a worker, sub-driver, or analyst sent up — the unified inbox. An event is one of: a settled worker output ('settled'), a question needing your answer ('question', from ask_parent / the worker's ask-user), or a trace-analyst finding ('finding', from analyze-on-settle). Pass kinds:['settled'] for just the next finished worker; omit `kinds` to also receive questions and findings. Returns { idle: true } when nothing is queued and no workers are live. If a worker is still running when the wait elapses, returns { pending: true, live: [...] } (the workers still in flight) instead of blocking indefinitely — call await_event again to keep waiting; the settlement is not lost. Every reply carries `freeSlots`: how many more workers you can start right now (`null` = uncapped). A settled worker frees its slot, so `freeSlots > 0` means capacity is sitting idle — spawn into it before waiting again.",
|
|
2048
|
+
description: "Wait for and pull the next message a worker, sub-driver, or analyst sent up — the unified inbox. Read a settled artifact with the returned `outputRead` call; the receipt carries its reference, not its bytes. An event is one of: a settled worker output ('settled'), a question needing your answer ('question', from ask_parent / the worker's ask-user), or a trace-analyst finding ('finding', from analyze-on-settle). Pass kinds:['settled'] for just the next finished worker; omit `kinds` to also receive questions and findings. Returns { idle: true } when nothing is queued and no workers are live. If a worker is still running when the wait elapses, returns { pending: true, live: [...] } (the workers still in flight) instead of blocking indefinitely — call await_event again to keep waiting; the settlement is not lost. Every reply carries `freeSlots`: how many more workers you can start right now (`null` = uncapped). A settled worker frees its slot, so `freeSlots > 0` means capacity is sitting idle — spawn into it before waiting again.",
|
|
1918
2049
|
inputSchema: {
|
|
1919
2050
|
type: "object",
|
|
1920
2051
|
properties: { kinds: {
|
|
@@ -2131,11 +2262,22 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
2131
2262
|
accepted = false;
|
|
2132
2263
|
thrown = error instanceof Error ? error.message : String(error);
|
|
2133
2264
|
}
|
|
2134
|
-
if (!accepted)
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2265
|
+
if (!accepted) {
|
|
2266
|
+
let explanation;
|
|
2267
|
+
let diagnosticError;
|
|
2268
|
+
if (thrown === void 0 && deliverable.explainFailure) try {
|
|
2269
|
+
const detail = await deliverable.explainFailure(result);
|
|
2270
|
+
if (typeof detail === "string" && detail.trim()) explanation = detail.trim();
|
|
2271
|
+
} catch (error) {
|
|
2272
|
+
diagnosticError = error instanceof Error ? error.message : String(error);
|
|
2273
|
+
}
|
|
2274
|
+
return {
|
|
2275
|
+
accepted: false,
|
|
2276
|
+
stop: false,
|
|
2277
|
+
reason: thrown === void 0 ? `the independent check did not pass on this result${explanation ? `. ${explanation}` : deliverable.describe ? `. Expected: ${deliverable.describe}` : ""}` : `the independent check THREW, so nothing was accepted: ${thrown}. This is a fault in the check, not necessarily in your result — report it rather than resubmitting unchanged`,
|
|
2278
|
+
...diagnosticError === void 0 ? {} : { diagnosticError }
|
|
2279
|
+
};
|
|
2280
|
+
}
|
|
2139
2281
|
if (submitted) return {
|
|
2140
2282
|
accepted: true,
|
|
2141
2283
|
retained: "earlier-passing-result",
|
|
@@ -2470,6 +2612,7 @@ function applyRunCancellation(dir, abortRun, now, path = "turn-boundary") {
|
|
|
2470
2612
|
requestedAt: request.at,
|
|
2471
2613
|
observedAt,
|
|
2472
2614
|
...request.reason === void 0 ? {} : { reason: request.reason },
|
|
2615
|
+
...request.operator === void 0 ? {} : { operator: request.operator },
|
|
2473
2616
|
detail: "root abort issued to the whole run; termination not yet proven"
|
|
2474
2617
|
};
|
|
2475
2618
|
writeRunCancellation(dir, record);
|
|
@@ -3213,6 +3356,7 @@ function createSteerAcknowledger(deps) {
|
|
|
3213
3356
|
});
|
|
3214
3357
|
continue;
|
|
3215
3358
|
}
|
|
3359
|
+
if (rootRequest && deps.deliverRootReady !== void 0 && !deps.deliverRootReady()) continue;
|
|
3216
3360
|
if (!claimWorkerSteerDelivery(deps.dir, {
|
|
3217
3361
|
...base(request),
|
|
3218
3362
|
effect: "unknown",
|
|
@@ -3438,6 +3582,7 @@ function createCancelAcknowledger(deps) {
|
|
|
3438
3582
|
requestedAt: runRequest.at,
|
|
3439
3583
|
observedAt: iso(),
|
|
3440
3584
|
...runRequest.reason === void 0 ? {} : { reason: runRequest.reason },
|
|
3585
|
+
...runRequest.operator === void 0 ? {} : { operator: runRequest.operator },
|
|
3441
3586
|
detail: "run ended before the request was applied"
|
|
3442
3587
|
});
|
|
3443
3588
|
for (const request of readWorkerCancelRequests(deps.dir)) {
|
|
@@ -3889,4 +4034,4 @@ function safeJson(v) {
|
|
|
3889
4034
|
//#endregion
|
|
3890
4035
|
export { downMessageRefusalReasons as A, ANALYST_DEFINITION_BOUNDS as C, coordinationVerbNames as D, canonicalFindingEvent as E, defaultToolDetectors as F, watchTrace as I, parseAuthoredAnalystDefinition as M, questionEscalationTargets as N, createCoordinationTools as O, createEventBus as P, watchRunCancellation as S, analystToolGroupNames as T, renderAnytimeTable as _, allOf as a, FileCoordinationLog as b, createProgressTracker as c, progressStop as d, sampleFromSettled as f, plateauLength as g, bestSoFar as h, finalizeBestDelivered as i, normalizeAnalyzeOnSettle as j, createCoordinationToolsForManager as k, noProgressFor as l, areaUnderCurve as m, createSteerAcknowledger as n, allWorkersStalled as o, anytimeReport as p, driverAgent as r, anyOf as s, createCancelAcknowledger as t, plateau as u, createFileRunContext as v, DEFAULT_AWAIT_EVENT_TIMEOUT_MS as w, applyRunCancellation as x, createInMemoryRunContext as y };
|
|
3891
4036
|
|
|
3892
|
-
//# sourceMappingURL=coordination-driver-
|
|
4037
|
+
//# sourceMappingURL=coordination-driver-QxitIuva.js.map
|