@tangle-network/agent-runtime 9.0.16 → 10.0.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/CHANGELOG.md +72 -0
- package/dist/{activation-y6NAn3sW.d.ts → activation-CDlOqX5a.d.ts} +7 -8
- package/dist/{activation-DgT20fzX.js → activation-CEGkyzEG.js} +2 -2
- package/dist/{activation-DgT20fzX.js.map → activation-CEGkyzEG.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +3 -3
- package/dist/candidate-execution/index.d.ts +3 -0
- package/dist/candidate-execution/index.js +10 -3
- package/dist/candidate-execution/index.js.map +1 -1
- package/dist/{delegate-Cmu5OF3M.js → delegate-V2Nz8GgO.js} +2 -2
- package/dist/{delegate-Cmu5OF3M.js.map → delegate-V2Nz8GgO.js.map} +1 -1
- package/dist/{coordination-manager-CFtnSLPw.js → driver-control-acknowledgers-CJDYLJmW.js} +1042 -1042
- package/dist/driver-control-acknowledgers-CJDYLJmW.js.map +1 -0
- package/dist/durable.d.ts +5 -5
- package/dist/durable.js +13 -13
- package/dist/durable.js.map +1 -1
- package/dist/{failure-cause-WifbY42M.js → failure-cause-BI7cfDWx.js} +14 -2
- package/dist/failure-cause-BI7cfDWx.js.map +1 -0
- package/dist/{graph-registry-B_1C7qye.js → graph-registry-DxhlgHdA.js} +1 -1
- package/dist/{graph-registry-BbZN5deo.js → graph-registry-j9t9J0KT.js} +11 -12
- package/dist/{graph-registry-BbZN5deo.js.map → graph-registry-j9t9J0KT.js.map} +1 -1
- package/dist/{graph-DqtIiS94.js → graph-wJOMQ1kC.js} +8 -8
- package/dist/{graph-DqtIiS94.js.map → graph-wJOMQ1kC.js.map} +1 -1
- package/dist/{improve-B0vNv6e7.js → improve-DOjywiPq.js} +42 -26
- package/dist/{improve-B0vNv6e7.js.map → improve-DOjywiPq.js.map} +1 -1
- package/dist/index.d.ts +38 -6
- package/dist/index.js +59 -20
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +93 -63
- package/dist/intelligence.js +166 -73
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +3 -3
- package/dist/kernel.js +16 -15
- package/dist/{loop-runner-BvVdDdZC.js → loop-runner-CPTOzSol.js} +2 -2
- package/dist/{loop-runner-BvVdDdZC.js.map → loop-runner-CPTOzSol.js.map} +1 -1
- package/dist/{loop-runner-CfMOsISJ.d.ts → loop-runner-DwxZbYW5.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 +1 -1
- package/dist/mcp/index.js +7 -7
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/{model-policy-CZwhXp8O.js → model-policy-CqDuBTq-.js} +12 -2
- package/dist/model-policy-CqDuBTq-.js.map +1 -0
- package/dist/{prepare-Cw4ZaN01.js → prepare-DT-ibRsm.js} +2 -2
- package/dist/{prepare-Cw4ZaN01.js.map → prepare-DT-ibRsm.js.map} +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/profiles.js +1 -1
- package/dist/{provision-supervisor-BjKluSKl.js → provision-supervisor-B1_Kow9m.js} +6 -6
- package/dist/{provision-supervisor-BjKluSKl.js.map → provision-supervisor-B1_Kow9m.js.map} +1 -1
- package/dist/{run-cancellation-BvGEEwRG.js → run-cancellation-D5m6JHPH.js} +2 -2
- package/dist/{run-cancellation-BvGEEwRG.js.map → run-cancellation-D5m6JHPH.js.map} +1 -1
- package/dist/{run-state-Dd_AjWd6.js → run-state-DKOXe08H.js} +5 -5
- package/dist/{run-state-Dd_AjWd6.js.map → run-state-DKOXe08H.js.map} +1 -1
- package/dist/{runtime-7VEM9muH.js → runtime-C5cWSMqU.js} +191 -24
- package/dist/runtime-C5cWSMqU.js.map +1 -0
- package/dist/{search-executor-Dqtm1fOC.js → search-executor-CA6fTYWz.js} +5 -5
- package/dist/{search-executor-Dqtm1fOC.js.map → search-executor-CA6fTYWz.js.map} +1 -1
- package/dist/{server-B8Kmit_v.js → server-C8Z3vYdI.js} +4 -4
- package/dist/{server-B8Kmit_v.js.map → server-C8Z3vYdI.js.map} +1 -1
- package/dist/{settle-record-BvH2-Ao5.js → settle-record-BDxPAO4m.js} +2 -2
- package/dist/{settle-record-BvH2-Ao5.js.map → settle-record-BDxPAO4m.js.map} +1 -1
- package/dist/{structural-rollout-CYc8PE2N.js → structural-rollout-B0HPcP9G.js} +5 -5
- package/dist/{structural-rollout-CYc8PE2N.js.map → structural-rollout-B0HPcP9G.js.map} +1 -1
- package/dist/{supervise-BayNu7qZ.js → supervise-Dvj-8S6D.js} +2341 -2283
- package/dist/supervise-Dvj-8S6D.js.map +1 -0
- package/dist/{supervision-discovery-Ca4QO4rG.js → supervision-discovery-CbrwcgJy.js} +3 -3
- package/dist/{supervision-discovery-Ca4QO4rG.js.map → supervision-discovery-CbrwcgJy.js.map} +1 -1
- package/dist/{supervisor-Bx21Hy27.js → supervisor-DwdeUC2l.js} +218 -47
- package/dist/supervisor-DwdeUC2l.js.map +1 -0
- package/dist/{supervisor-accounting-StDNW1YT.js → supervisor-accounting-C48Yo9QC.js} +507 -341
- package/dist/supervisor-accounting-C48Yo9QC.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +11 -11
- package/dist/{tool-server-CirrqFlr.js → tool-server-DsCeBr-C.js} +2 -2
- package/dist/{tool-server-CirrqFlr.js.map → tool-server-DsCeBr-C.js.map} +1 -1
- package/dist/{top-web-Cg7ywIkF.js → top-web-CTOq4psb.js} +6 -6
- package/dist/{top-web-Cg7ywIkF.js.map → top-web-CTOq4psb.js.map} +1 -1
- package/dist/tui/bin.js +3 -3
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/{types-_j53efrk.d.ts → types-lnF0wIJW.d.ts} +8245 -8153
- package/dist/{workspace-streams-BakRr-Pl.js → workspace-streams-C7PGLAUd.js} +3 -3
- package/dist/workspace-streams-C7PGLAUd.js.map +1 -0
- package/package.json +5 -4
- package/dist/coordination-manager-CFtnSLPw.js.map +0 -1
- package/dist/failure-cause-WifbY42M.js.map +0 -1
- package/dist/model-policy-CZwhXp8O.js.map +0 -1
- package/dist/runtime-7VEM9muH.js.map +0 -1
- package/dist/supervise-BayNu7qZ.js.map +0 -1
- package/dist/supervisor-Bx21Hy27.js.map +0 -1
- package/dist/supervisor-accounting-StDNW1YT.js.map +0 -1
- package/dist/workspace-streams-BakRr-Pl.js.map +0 -1
package/dist/intelligence.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as RuntimeStreamEvent, Vi as ReadonlyAgentProfile, eS as Redactor, ky as RuntimeTelemetryOptions, ng as AgentEnvironmentProviderRegistry, rw as LoopTraceEvent, tS as defaultRedactor, tg as AgentEnvironmentProviderRef, yy as OtelExportStats } from "./types-lnF0wIJW.js";
|
|
2
2
|
import { b as AgentCandidateExecutionClaimStore, f as PrepareAgentCandidateExecutionOptions, i as CreateProtectedAgentCandidateModelPortOptions, m as ExecutePreparedAgentCandidateOptions, u as parseAgentCandidateProfileActivation } from "./protected-model-port-uN4M48vT.js";
|
|
3
|
-
import { A as AgentProfileMeasuredSurface, C as verifyAgentImprovementProposal, D as AgentImprovementActivationTargetIdentity, E as AGENT_PROFILE_MEASURED_SURFACES, F as isAgentImprovementProfileSurface, I as isAgentProfileMeasuredSurface, M as agentImprovementProfileSurfaceDigest, N as agentImprovementProfileSurfaceInput, O as AgentImprovementProfileSurface, P as agentImprovementTargetProfileDiffs, S as verifyAgentImprovementActivationResult, T as AGENT_IMPROVEMENT_PROFILE_SURFACES, _ as createAgentImprovementActivationResult, _t as ImproveResult, a as AgentImprovementActivationTransitionInput, b as reviewAgentImprovementProposal, c as CreateAgentImprovementActivationOptions, d as ExecuteAgentImprovementActivationInput, f as ExecuteAgentImprovementActivationOptions, g as createAgentImprovementActivation, h as SealedCandidateActivationTransitionInput, j as agentImprovementProfileDiffs, k as AgentImprovementTargetProfileDiffOptions, l as CreateAgentImprovementActivationResultOptions, lt as ImproveMethodOptions, m as ReviewAgentImprovementInput, o as AgentProfileImprovementActivationOperation, p as ProfileImprovementActivationTransitionInput, pt as ImproveOptions, r as AgentImprovementActivationTargetPlan, s as AgentProfileImprovementActivationTargetPlan, u as CreateAgentImprovementProposalOptions, ut as ImproveMethodResult, v as createAgentImprovementProposal, w as verifyAgentImprovementReview, x as verifyAgentImprovementActivation, y as executeAgentImprovementActivation, yt as ImproveScenarioPartitions } from "./activation-
|
|
3
|
+
import { A as AgentProfileMeasuredSurface, C as verifyAgentImprovementProposal, Ct as ImproveSearchOptions, D as AgentImprovementActivationTargetIdentity, E as AGENT_PROFILE_MEASURED_SURFACES, F as isAgentImprovementProfileSurface, I as isAgentProfileMeasuredSurface, M as agentImprovementProfileSurfaceDigest, N as agentImprovementProfileSurfaceInput, O as AgentImprovementProfileSurface, P as agentImprovementTargetProfileDiffs, S as verifyAgentImprovementActivationResult, T as AGENT_IMPROVEMENT_PROFILE_SURFACES, _ as createAgentImprovementActivationResult, _t as ImproveResult, a as AgentImprovementActivationTransitionInput, b as reviewAgentImprovementProposal, c as CreateAgentImprovementActivationOptions, d as ExecuteAgentImprovementActivationInput, f as ExecuteAgentImprovementActivationOptions, g as createAgentImprovementActivation, h as SealedCandidateActivationTransitionInput, j as agentImprovementProfileDiffs, k as AgentImprovementTargetProfileDiffOptions, l as CreateAgentImprovementActivationResultOptions, lt as ImproveMethodOptions, m as ReviewAgentImprovementInput, o as AgentProfileImprovementActivationOperation, p as ProfileImprovementActivationTransitionInput, pt as ImproveOptions, r as AgentImprovementActivationTargetPlan, s as AgentProfileImprovementActivationTargetPlan, u as CreateAgentImprovementProposalOptions, ut as ImproveMethodResult, v as createAgentImprovementProposal, w as verifyAgentImprovementReview, wt as ImproveSearchResult, x as verifyAgentImprovementActivation, y as executeAgentImprovementActivation, yt as ImproveScenarioPartitions } from "./activation-CDlOqX5a.js";
|
|
4
4
|
import { d as RunAnalystLoopResult, u as RunAnalystLoopOpts } from "./types-qsqfyQoY.js";
|
|
5
5
|
import { P as AgentCandidateTaskExecution, T as AgentCandidateOutputArtifactPort, d as AgentCandidateExecutionPorts, l as AgentCandidateBenchmarkGraderPort, m as AgentCandidateExecutorPort } from "./workspace-archive-DS9E9tUr.js";
|
|
6
|
-
import { AgentCandidateBenchmarkCellRef, AgentCandidateEvaluationPolicy, AgentCandidateExperiment, AgentCandidateExperimentMaterial, AgentCandidateExperimentMeasurement, AgentCandidateLineage, AgentImprovementActivation, AgentImprovementActivationIntent, AgentImprovementActivationOutcome, AgentImprovementActivationResult, AgentImprovementActivationTargetState, AgentImprovementActivationTargetTransition, AgentImprovementEvaluation, AgentImprovementMeasuredComparison, AgentImprovementProposal, AgentImprovementProposal as AgentImprovementProposal$1, AgentImprovementReview, AgentImprovementReviewDecision, AgentImprovementSource, AgentProfile, AgentProfileDiff, AgentProfileImprovementExecutionRef, AgentProfileImprovementExperiment, AgentProfileImprovementMeasuredComparison, AgentProfileImprovementMeasurement, AgentProfileImprovementRunReceipt, AgentProfileImprovementTaskMaterial, CandidateExecutionEvidence, CandidateExecutionEvidence as CandidateExecutionEvidence$1, Sha256Digest } from "@tangle-network/agent-interface";
|
|
7
|
-
import { CostLedgerHandle, TraceStore } from "@tangle-network/agent-eval";
|
|
6
|
+
import { AgentCandidateBenchmarkCellRef, AgentCandidateEvaluationPolicy, AgentCandidateExperiment, AgentCandidateExperimentMaterial, AgentCandidateExperimentMeasurement, AgentCandidateLineage, AgentImprovementActivation, AgentImprovementActivationIntent, AgentImprovementActivationOutcome, AgentImprovementActivationResult, AgentImprovementActivationTargetState, AgentImprovementActivationTargetTransition, AgentImprovementEvaluation, AgentImprovementMeasuredComparison, AgentImprovementProposal, AgentImprovementProposal as AgentImprovementProposal$1, AgentImprovementReview, AgentImprovementReviewDecision, AgentImprovementSource, AgentProfile, AgentProfileDiff, AgentProfileImprovementExecutionRef, AgentProfileImprovementExperiment, AgentProfileImprovementMeasuredComparison, AgentProfileImprovementMeasurement, AgentProfileImprovementModelBinding, AgentProfileImprovementRecordedRunReceipt, AgentProfileImprovementRunReceipt, AgentProfileImprovementTaskMaterial, CandidateExecutionEvidence, CandidateExecutionEvidence as CandidateExecutionEvidence$1, Sha256Digest } from "@tangle-network/agent-interface";
|
|
7
|
+
import { CostLedger, CostLedgerHandle, CostLedgerSummary, TraceStore } from "@tangle-network/agent-eval";
|
|
8
8
|
import { AgentExactProcessResources } from "@tangle-network/agent-interface/environment-provider";
|
|
9
9
|
import { ProposalFinding as ProposalFinding$1 } from "@tangle-network/agent-eval/analyst";
|
|
10
10
|
import { CampaignScenarioIdentity, OptimizationMethodComparison, OptimizationPackageSource, OptimizationTokenUsage } from "@tangle-network/agent-eval/campaign";
|
|
11
|
-
import { AgentProfileImprovementExperimentExecutionInput, CandidateExperimentExecutionInput, CompareCandidateExperimentOptions, Scenario as Scenario$1 } from "@tangle-network/agent-eval/contract";
|
|
11
|
+
import { AgentProfileImprovementExperimentExecutionInput, AgentProfileImprovementIncompleteExperimentRun, CandidateExperimentExecutionInput, CompareCandidateExperimentOptions, Scenario as Scenario$1 } from "@tangle-network/agent-eval/contract";
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
14
14
|
* EffortPolicy — pure data, no execution. Resolves a named tier into a flat
|
|
@@ -239,6 +239,59 @@ interface ProposeAgentImprovementResult<TScenario extends Scenario$1, TArtifact>
|
|
|
239
239
|
measurements: AgentCandidateExperimentMeasurement[];
|
|
240
240
|
proposal: AgentImprovementProposal$1;
|
|
241
241
|
}
|
|
242
|
+
/** Execute both arms of one immutable experiment and derive its paired result. */
|
|
243
|
+
export declare function runAgentCandidateExperiment(options: RunAgentCandidateExperimentOptions): Promise<RunAgentCandidateExperimentResult>;
|
|
244
|
+
/** Execute one exact arm, task, repetition, seed, and attempt through Runtime. */
|
|
245
|
+
export declare function executeAgentCandidateExperimentCell(options: ExecuteAgentCandidateExperimentCellOptions): Promise<CandidateExecutionEvidence$1>;
|
|
246
|
+
/** Search one profile, then independently measure its exact states before proposing. */
|
|
247
|
+
export declare function proposeAgentProfileImprovement<TScenario extends Scenario$1, TArtifact>(options: RecordAgentProfileImprovementOptions<TScenario, TArtifact>): Promise<ProposeAgentProfileImprovementResult | ProposeAgentProfileImprovementIncompleteResult | ProposeAgentProfileImprovementHeldResult>;
|
|
248
|
+
export declare function proposeAgentProfileImprovement<TScenario extends Scenario$1, TArtifact>(options: ProposeAgentProfileImprovementOptions<TScenario, TArtifact>): Promise<ProposeAgentProfileImprovementResult>;
|
|
249
|
+
/** Analyze, search, then remeasure the resulting exact candidate before proposing it. */
|
|
250
|
+
export declare function proposeAgentImprovement<TScenario extends Scenario$1, TArtifact>(options: ProposeAgentImprovementOptions<TScenario, TArtifact>): Promise<ProposeAgentImprovementResult<TScenario, TArtifact>>;
|
|
251
|
+
/** Recheck one Runtime receipt against its exact signed experiment cell. */
|
|
252
|
+
export declare function verifyCandidateExecutionEvidence(input: unknown, options: VerifyCandidateExecutionEvidenceOptions): CandidateExecutionEvidence$1;
|
|
253
|
+
type OptimizationProvenance = NonNullable<OptimizationMethodComparison['best']['provenance']>;
|
|
254
|
+
interface OptimizationActivationReceipt {
|
|
255
|
+
kind: 'optimization-activation-receipt';
|
|
256
|
+
method: string;
|
|
257
|
+
source: OptimizationPackageSource;
|
|
258
|
+
bridge?: OptimizationPackageSource;
|
|
259
|
+
modules?: OptimizationProvenance['modules'];
|
|
260
|
+
python?: OptimizationProvenance['python'];
|
|
261
|
+
models?: {
|
|
262
|
+
candidate?: NonNullable<AgentProfile['model']>;
|
|
263
|
+
optimizer?: string;
|
|
264
|
+
};
|
|
265
|
+
usage: {
|
|
266
|
+
optimizerEvaluations: number;
|
|
267
|
+
optimizerTokens?: OptimizationTokenUsage;
|
|
268
|
+
};
|
|
269
|
+
cost: {
|
|
270
|
+
optimization: OptimizationReceiptCost;
|
|
271
|
+
finalTest: OptimizationReceiptCost;
|
|
272
|
+
total: OptimizationReceiptCost;
|
|
273
|
+
};
|
|
274
|
+
invocation: {
|
|
275
|
+
runtimeInvocationId: string;
|
|
276
|
+
optimizerRunId: string;
|
|
277
|
+
compatibleOptimizerRunId?: string;
|
|
278
|
+
resumed: boolean;
|
|
279
|
+
artifactDir: string;
|
|
280
|
+
};
|
|
281
|
+
developmentDataDigest: Sha256Digest;
|
|
282
|
+
finalTestDataDigest: Sha256Digest;
|
|
283
|
+
scenarioPartitions: ImproveScenarioPartitions;
|
|
284
|
+
digest: Sha256Digest;
|
|
285
|
+
}
|
|
286
|
+
interface OptimizationReceiptCost {
|
|
287
|
+
totalUsd: number;
|
|
288
|
+
accountingComplete: boolean;
|
|
289
|
+
incompleteReasons: string[];
|
|
290
|
+
}
|
|
291
|
+
/** Build a detached receipt only for methods backed by an identified external optimizer. */
|
|
292
|
+
export declare function createOptimizationActivationReceipt(improvement: ImproveMethodResult): OptimizationActivationReceipt | undefined;
|
|
293
|
+
/** Read and verify the optimizer evidence carried by a measured proposal. */
|
|
294
|
+
export declare function optimizationActivationReceiptFromMetadata(metadata: AgentImprovementMeasuredComparison['metadata']): OptimizationActivationReceipt | undefined;
|
|
242
295
|
/** Product-owned task material that Runtime freezes before either profile state runs. */
|
|
243
296
|
interface AgentProfileImprovementBenchmark {
|
|
244
297
|
tasks: [AgentProfileImprovementTaskMaterial, ...AgentProfileImprovementTaskMaterial[]];
|
|
@@ -258,10 +311,15 @@ interface AgentProfileImprovementExecutor<TScenario extends Scenario$1, TArtifac
|
|
|
258
311
|
}): Promise<AgentProfileImprovementRunReceipt>;
|
|
259
312
|
}
|
|
260
313
|
/** The portable profile changes that the measured-profile contract permits. */
|
|
261
|
-
type AgentProfileImprovementMethodOptions<TScenario extends Scenario$1, TArtifact> = Omit<ImproveMethodOptions<TScenario, TArtifact>, 'agent' | 'executionRef' | 'findings' | 'surface'> & {
|
|
314
|
+
type AgentProfileImprovementMethodOptions<TScenario extends Scenario$1, TArtifact> = (Omit<ImproveMethodOptions<TScenario, TArtifact>, 'agent' | 'executionRef' | 'findings' | 'surface'> | Omit<ImproveSearchOptions<TScenario, TArtifact>, 'agent' | 'executionRef' | 'findings' | 'surface'>) & {
|
|
262
315
|
surface?: AgentProfileMeasuredSurface;
|
|
263
316
|
findings?: readonly ProposalFinding$1[];
|
|
264
317
|
};
|
|
318
|
+
/** Resolved once on frozen source profiles, before the final experiment is sealed. */
|
|
319
|
+
type AgentProfileImprovementModelBindingSource = AgentProfileImprovementModelBinding | ((input: {
|
|
320
|
+
baseline: ReadonlyAgentProfile;
|
|
321
|
+
candidate: ReadonlyAgentProfile;
|
|
322
|
+
}) => AgentProfileImprovementModelBinding | Promise<AgentProfileImprovementModelBinding>);
|
|
265
323
|
/**
|
|
266
324
|
* Complete profile-improvement path for a product-owned source.
|
|
267
325
|
* Runtime owns analysis, search ancestry, profile diffs, experiment sealing,
|
|
@@ -277,6 +335,8 @@ interface ProposeAgentProfileImprovementOptions<TScenario extends Scenario$1, TA
|
|
|
277
335
|
improvement: AgentProfileImprovementMethodOptions<TScenario, TArtifact>;
|
|
278
336
|
benchmark: AgentProfileImprovementBenchmark;
|
|
279
337
|
executor: AgentProfileImprovementExecutor<TScenario, TArtifact>;
|
|
338
|
+
modelBinding?: AgentProfileImprovementModelBindingSource;
|
|
339
|
+
allowIncomplete?: false;
|
|
280
340
|
/** One customer-approved maximum for analysis, optimization, and measurement. */
|
|
281
341
|
budgetUsd: number;
|
|
282
342
|
maxConcurrency?: number;
|
|
@@ -287,24 +347,36 @@ interface ProposeAgentProfileImprovementOptions<TScenario extends Scenario$1, TA
|
|
|
287
347
|
}
|
|
288
348
|
interface ProposeAgentProfileImprovementResult {
|
|
289
349
|
analysis: RunAnalystLoopResult;
|
|
290
|
-
improvement: ImproveMethodResult;
|
|
350
|
+
improvement: ImproveMethodResult | ImproveSearchResult;
|
|
291
351
|
experiment: AgentProfileImprovementExperiment;
|
|
292
352
|
measurements: AgentProfileImprovementMeasurement[];
|
|
293
353
|
proposal: AgentImprovementProposal$1;
|
|
294
354
|
}
|
|
295
|
-
/**
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
355
|
+
/** Opt-in measurement records may be incomplete; the proposal API remains the same. */
|
|
356
|
+
interface RecordAgentProfileImprovementOptions<TScenario extends Scenario$1, TArtifact> extends Omit<ProposeAgentProfileImprovementOptions<TScenario, TArtifact>, 'executor' | 'allowIncomplete'> {
|
|
357
|
+
allowIncomplete: true;
|
|
358
|
+
executor: Omit<AgentProfileImprovementExecutor<TScenario, TArtifact>, 'measure'> & {
|
|
359
|
+
measure(input: AgentProfileImprovementExperimentExecutionInput & {
|
|
360
|
+
profile: AgentProfile;
|
|
361
|
+
}): Promise<AgentProfileImprovementRecordedRunReceipt>;
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
interface ProposeAgentProfileImprovementIncompleteResult extends AgentProfileImprovementIncompleteExperimentRun {
|
|
365
|
+
analysis: RunAnalystLoopResult;
|
|
366
|
+
improvement: ImproveMethodResult | ImproveSearchResult;
|
|
367
|
+
experiment: AgentProfileImprovementExperiment;
|
|
368
|
+
}
|
|
369
|
+
/** Opt-in normal hold before a paired experiment can be measured. No proposal is constructed. */
|
|
370
|
+
interface ProposeAgentProfileImprovementHeldResult {
|
|
371
|
+
status: 'held';
|
|
372
|
+
decision: 'hold';
|
|
373
|
+
phase: 'search' | 'preparation';
|
|
374
|
+
source: AgentImprovementSource;
|
|
375
|
+
analysis: RunAnalystLoopResult;
|
|
376
|
+
improvement: ImproveMethodResult | ImproveSearchResult;
|
|
377
|
+
accounting: CostLedgerSummary;
|
|
378
|
+
reasons: string[];
|
|
379
|
+
}
|
|
308
380
|
/** Lineage accepted by the direct candidate path. Optimizer lineage belongs to `improve()`. */
|
|
309
381
|
type AuthoredAgentProfileCandidateLineage = Omit<AgentCandidateLineage, 'source' | 'profileDiffIds'> & {
|
|
310
382
|
source: Exclude<AgentCandidateLineage['source'], 'optimizer'>;
|
|
@@ -763,48 +835,6 @@ interface ProtectedExactProcessCandidateExperimentExecutor extends ExactProcessC
|
|
|
763
835
|
export declare function createExactProcessCandidateExperimentExecutor(options: CreateExactProcessCandidateExperimentExecutorOptions): ExactProcessCandidateExperimentExecutor;
|
|
764
836
|
/** Compose host-owned execution ports with protected model access for one exact-process run. */
|
|
765
837
|
export declare function createProtectedExactProcessCandidateExperimentExecutor(options: CreateProtectedExactProcessCandidateExperimentExecutorOptions): ProtectedExactProcessCandidateExperimentExecutor;
|
|
766
|
-
type OptimizationProvenance = NonNullable<OptimizationMethodComparison['best']['provenance']>;
|
|
767
|
-
interface OptimizationActivationReceipt {
|
|
768
|
-
kind: 'optimization-activation-receipt';
|
|
769
|
-
method: string;
|
|
770
|
-
source: OptimizationPackageSource;
|
|
771
|
-
bridge?: OptimizationPackageSource;
|
|
772
|
-
modules?: OptimizationProvenance['modules'];
|
|
773
|
-
python?: OptimizationProvenance['python'];
|
|
774
|
-
models?: {
|
|
775
|
-
candidate?: NonNullable<AgentProfile['model']>;
|
|
776
|
-
optimizer?: string;
|
|
777
|
-
};
|
|
778
|
-
usage: {
|
|
779
|
-
optimizerEvaluations: number;
|
|
780
|
-
optimizerTokens?: OptimizationTokenUsage;
|
|
781
|
-
};
|
|
782
|
-
cost: {
|
|
783
|
-
optimization: OptimizationReceiptCost;
|
|
784
|
-
finalTest: OptimizationReceiptCost;
|
|
785
|
-
total: OptimizationReceiptCost;
|
|
786
|
-
};
|
|
787
|
-
invocation: {
|
|
788
|
-
runtimeInvocationId: string;
|
|
789
|
-
optimizerRunId: string;
|
|
790
|
-
compatibleOptimizerRunId?: string;
|
|
791
|
-
resumed: boolean;
|
|
792
|
-
artifactDir: string;
|
|
793
|
-
};
|
|
794
|
-
developmentDataDigest: Sha256Digest;
|
|
795
|
-
finalTestDataDigest: Sha256Digest;
|
|
796
|
-
scenarioPartitions: ImproveScenarioPartitions;
|
|
797
|
-
digest: Sha256Digest;
|
|
798
|
-
}
|
|
799
|
-
interface OptimizationReceiptCost {
|
|
800
|
-
totalUsd: number;
|
|
801
|
-
accountingComplete: boolean;
|
|
802
|
-
incompleteReasons: string[];
|
|
803
|
-
}
|
|
804
|
-
/** Build a detached receipt only for methods backed by an identified external optimizer. */
|
|
805
|
-
export declare function createOptimizationActivationReceipt(improvement: ImproveMethodResult): OptimizationActivationReceipt | undefined;
|
|
806
|
-
/** Read and verify the optimizer evidence carried by a measured proposal. */
|
|
807
|
-
export declare function optimizationActivationReceiptFromMetadata(metadata: AgentImprovementMeasuredComparison['metadata']): OptimizationActivationReceipt | undefined;
|
|
808
838
|
/** What the hook hands the agent each run. Additive over the prompt-only
|
|
809
839
|
* delivery: `composePrompt` folds the certified prompt surface (as before);
|
|
810
840
|
* `proposals`/`applyProfile` surface the promoted profile DIFFS — never
|
|
@@ -1130,5 +1160,5 @@ export interface DoctorReport {
|
|
|
1130
1160
|
* and best-effort export must never spam an unauthenticated plane).
|
|
1131
1161
|
*/
|
|
1132
1162
|
export declare function createIntelligenceClient(config: IntelligenceConfig): IntelligenceClient;
|
|
1133
|
-
export { type AGENT_IMPROVEMENT_PROFILE_SURFACES, type AGENT_PROFILE_MEASURED_SURFACES, type AgentCandidateExecutionHostPorts, type AgentCandidateExperimentCellPlacement, type AgentEnvironmentProviderRef, type AgentImprovementActivation, type AgentImprovementActivationIntent, type AgentImprovementActivationOutcome, type AgentImprovementActivationResult, type AgentImprovementActivationTargetIdentity, type AgentImprovementActivationTargetPlan, type AgentImprovementActivationTransitionInput, type AgentImprovementAnalysisOptions, type AgentImprovementEvaluation, type AgentImprovementExperimentMaterial, type AgentImprovementProfileActivationInput, type AgentImprovementProfileActivationPreparation, type AgentImprovementProfileActivationTarget, type AgentImprovementProfileReplacement, type AgentImprovementProfileStateDigest, type AgentImprovementProfileStateDigestInput, type AgentImprovementProfileStateResolver, type AgentImprovementProfileStateResolverInput, type AgentImprovementProfileSurface, type AgentImprovementProfileTargetState, type AgentImprovementProfileTargetTransition, type AgentImprovementProposal, type AgentImprovementReview, type AgentImprovementReviewDecision, type AgentImprovementTargetProfileDiffOptions, type AgentProfileCandidateMeasurementExecutor, type AgentProfileImprovementActivationOperation, type AgentProfileImprovementActivationTargetPlan, type AgentProfileImprovementBenchmark, type AgentProfileImprovementExecutor, type AgentProfileImprovementMethodOptions, type AgentProfileMeasuredSurface, type AppliedIntelligence, type AuthoredAgentProfileCandidateLineage, type CandidateExecutionEvidence, type CapabilityAuth, type CapabilityInterface, type CapabilityManifest, type CertProvenance, type CertifiedArtifact, type CertifiedCapability, type CertifiedCapabilitySummary, type CertifiedProfile, type CertifiedPromptSource, type CertifiedPromptSourceOptions, type CertifiedPromptSurface, type ContentRef, type CorpusAccess, type CreateAgentImprovementActivationOptions, type CreateAgentImprovementActivationResultOptions, type CreateAgentImprovementProposalOptions, type CreateExactProcessCandidateExperimentExecutorOptions, type CreateProtectedExactProcessCandidateExperimentExecutorOptions, type CredentialRef, type DeliveryBinding, type DiffProvenance, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type ExactProcessCandidateExperimentExecution, type ExactProcessCandidateExperimentExecutor, type ExecuteAgentCandidateExperimentCellOptions, type ExecuteAgentImprovementActivationInput, type ExecuteAgentImprovementActivationOptions, type HostSpec, type ImproveResult, type IntelligenceAgent, type IntelligenceHookConfig, type IntelligenceWrapped, type JsonSchema, type OptimizationActivationReceipt, type OptimizationReceiptCost, type PrepareAgentCandidateExecutionOptions, type ProfileImprovementActivationTransitionInput, type ProposeAgentImprovementOptions, type ProposeAgentImprovementResult, type ProposeAgentProfileImprovementOptions, type ProposeAgentProfileImprovementResult, type ProposeAuthoredAgentProfileImprovementOptions, type ProposeAuthoredAgentProfileImprovementResult, type ProposedProfileDiff, type ProtectedExactProcessCandidateExperimentExecutor, type PullCertifiedOptions, type PullOutcome, type Redactor, type ReviewAgentImprovementInput, type RunAgentCandidateExperimentOptions, type RunAgentCandidateExperimentResult, type SealedCandidateActivationTransitionInput, type VerifyCandidateExecutionEvidenceOptions, agentImprovementProfileDiffs, agentImprovementProfileSurfaceDigest, agentImprovementProfileSurfaceInput, agentImprovementTargetProfileDiffs, createAgentImprovementActivation, createAgentImprovementActivationResult, createAgentImprovementProposal, defaultRedactor, executeAgentImprovementActivation, isAgentImprovementProfileSurface, isAgentProfileMeasuredSurface, parseAgentCandidateProfileActivation as parseCandidateProfileMaterialization, reviewAgentImprovementProposal, verifyAgentImprovementActivation, verifyAgentImprovementActivationResult, verifyAgentImprovementProposal, verifyAgentImprovementReview };
|
|
1163
|
+
export { type AGENT_IMPROVEMENT_PROFILE_SURFACES, type AGENT_PROFILE_MEASURED_SURFACES, type AgentCandidateExecutionHostPorts, type AgentCandidateExperimentCellPlacement, type AgentEnvironmentProviderRef, type AgentImprovementActivation, type AgentImprovementActivationIntent, type AgentImprovementActivationOutcome, type AgentImprovementActivationResult, type AgentImprovementActivationTargetIdentity, type AgentImprovementActivationTargetPlan, type AgentImprovementActivationTransitionInput, type AgentImprovementAnalysisOptions, type AgentImprovementEvaluation, type AgentImprovementExperimentMaterial, type AgentImprovementProfileActivationInput, type AgentImprovementProfileActivationPreparation, type AgentImprovementProfileActivationTarget, type AgentImprovementProfileReplacement, type AgentImprovementProfileStateDigest, type AgentImprovementProfileStateDigestInput, type AgentImprovementProfileStateResolver, type AgentImprovementProfileStateResolverInput, type AgentImprovementProfileSurface, type AgentImprovementProfileTargetState, type AgentImprovementProfileTargetTransition, type AgentImprovementProposal, type AgentImprovementReview, type AgentImprovementReviewDecision, type AgentImprovementTargetProfileDiffOptions, type AgentProfileCandidateMeasurementExecutor, type AgentProfileImprovementActivationOperation, type AgentProfileImprovementActivationTargetPlan, type AgentProfileImprovementBenchmark, type AgentProfileImprovementExecutor, type AgentProfileImprovementMethodOptions, type AgentProfileImprovementModelBindingSource, type AgentProfileMeasuredSurface, type AppliedIntelligence, type AuthoredAgentProfileCandidateLineage, type CandidateExecutionEvidence, type CapabilityAuth, type CapabilityInterface, type CapabilityManifest, type CertProvenance, type CertifiedArtifact, type CertifiedCapability, type CertifiedCapabilitySummary, type CertifiedProfile, type CertifiedPromptSource, type CertifiedPromptSourceOptions, type CertifiedPromptSurface, type ContentRef, type CorpusAccess, type CreateAgentImprovementActivationOptions, type CreateAgentImprovementActivationResultOptions, type CreateAgentImprovementProposalOptions, type CreateExactProcessCandidateExperimentExecutorOptions, type CreateProtectedExactProcessCandidateExperimentExecutorOptions, type CredentialRef, type DeliveryBinding, type DiffProvenance, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type ExactProcessCandidateExperimentExecution, type ExactProcessCandidateExperimentExecutor, type ExecuteAgentCandidateExperimentCellOptions, type ExecuteAgentImprovementActivationInput, type ExecuteAgentImprovementActivationOptions, type HostSpec, type ImproveResult, type IntelligenceAgent, type IntelligenceHookConfig, type IntelligenceWrapped, type JsonSchema, type OptimizationActivationReceipt, type OptimizationReceiptCost, type PrepareAgentCandidateExecutionOptions, type ProfileImprovementActivationTransitionInput, type ProposeAgentImprovementOptions, type ProposeAgentImprovementResult, type ProposeAgentProfileImprovementHeldResult, type ProposeAgentProfileImprovementIncompleteResult, type ProposeAgentProfileImprovementOptions, type ProposeAgentProfileImprovementResult, type ProposeAuthoredAgentProfileImprovementOptions, type ProposeAuthoredAgentProfileImprovementResult, type ProposedProfileDiff, type ProtectedExactProcessCandidateExperimentExecutor, type PullCertifiedOptions, type PullOutcome, type RecordAgentProfileImprovementOptions, type Redactor, type ReviewAgentImprovementInput, type RunAgentCandidateExperimentOptions, type RunAgentCandidateExperimentResult, type SealedCandidateActivationTransitionInput, type VerifyCandidateExecutionEvidenceOptions, agentImprovementProfileDiffs, agentImprovementProfileSurfaceDigest, agentImprovementProfileSurfaceInput, agentImprovementTargetProfileDiffs, createAgentImprovementActivation, createAgentImprovementActivationResult, createAgentImprovementProposal, defaultRedactor, executeAgentImprovementActivation, isAgentImprovementProfileSurface, isAgentProfileMeasuredSurface, parseAgentCandidateProfileActivation as parseCandidateProfileMaterialization, reviewAgentImprovementProposal, verifyAgentImprovementActivation, verifyAgentImprovementActivationResult, verifyAgentImprovementProposal, verifyAgentImprovementReview };
|
|
1134
1164
|
//# sourceMappingURL=intelligence.d.ts.map
|
package/dist/intelligence.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ar as authoredAgentIdentity, Gn as buildRuntimeEventOtelSpans, Jn as flatOtelSpan, Un as buildLoopOtelSpans, qn as createOtelExporter } from "./supervisor-accounting-C48Yo9QC.js";
|
|
2
2
|
import { f as resolveRedactor, u as defaultRedactor } from "./snapshot-BKI_w3JD.js";
|
|
3
|
-
import { a as assertProfileTrainingIsHeldOut, f as addRuntimeUsage, l as rethrowAfterCleanup, m as isUsageAmount, p as createRuntimeUsageTotals, t as improve } from "./improve-
|
|
3
|
+
import { a as assertProfileTrainingIsHeldOut, f as addRuntimeUsage, l as rethrowAfterCleanup, m as isUsageAmount, p as createRuntimeUsageTotals, t as improve } from "./improve-DOjywiPq.js";
|
|
4
4
|
import { _ as parseAgentCandidateProfileActivation, a as applyExactAgentProfileDiff, d as createAgentCandidateProfileActivation, g as omitUndefinedObjectFields, m as materializeAgentCandidateProfilePlan, o as assertCandidateProfileBinding, v as parseExactAgentProfile } from "./profile-Cxl_Ajl2.js";
|
|
5
|
-
import { _ as agentImprovementTargetProfileDiffs, a as reviewAgentImprovementProposal, b as isAgentProfileMeasuredSurface, c as verifyAgentImprovementProposal, d as attachOptimizationActivationReceipt, f as createOptimizationActivationReceipt, g as agentImprovementProfileSurfaceInput, h as agentImprovementProfileSurfaceDigest, i as executeAgentImprovementActivation, l as verifyAgentImprovementReview, m as agentImprovementProfileDiffs, n as createAgentImprovementActivationResult, o as verifyAgentImprovementActivation, p as optimizationActivationReceiptFromMetadata, r as createAgentImprovementProposal, s as verifyAgentImprovementActivationResult, t as createAgentImprovementActivation, u as assertNoCallerOptimizationReceipt, v as assertProfileImprovementTargetsShareIdentity, y as isAgentImprovementProfileSurface } from "./activation-
|
|
5
|
+
import { _ as agentImprovementTargetProfileDiffs, a as reviewAgentImprovementProposal, b as isAgentProfileMeasuredSurface, c as verifyAgentImprovementProposal, d as attachOptimizationActivationReceipt, f as createOptimizationActivationReceipt, g as agentImprovementProfileSurfaceInput, h as agentImprovementProfileSurfaceDigest, i as executeAgentImprovementActivation, l as verifyAgentImprovementReview, m as agentImprovementProfileDiffs, n as createAgentImprovementActivationResult, o as verifyAgentImprovementActivation, p as optimizationActivationReceiptFromMetadata, r as createAgentImprovementProposal, s as verifyAgentImprovementActivationResult, t as createAgentImprovementActivation, u as assertNoCallerOptimizationReceipt, v as assertProfileImprovementTargetsShareIdentity, y as isAgentImprovementProfileSurface } from "./activation-CEGkyzEG.js";
|
|
6
6
|
import { h as canonicalCandidateDocument, m as canonicalCandidateDigest$1, p as canonicalCandidateBytes$1, v as immutableCandidateValue, x as verifyCanonicalCandidateDocument, y as omitTopLevelDigest } from "./output-artifacts-AqkZ8lO2.js";
|
|
7
|
-
import { C as verifiedResourceTextByDigest, S as AGENT_CANDIDATE_EXECUTION_SUPPORT, n as executePreparedAgentCandidate, t as prepareAgentCandidateExecution, w as verifyAgentCandidateBundle, x as exactProcessProviderAsCandidateExecutor, y as createProtectedAgentCandidateModelPort } from "./prepare-
|
|
8
|
-
import { W as resolveAgentEnvironmentProvider } from "./supervisor-
|
|
7
|
+
import { C as verifiedResourceTextByDigest, S as AGENT_CANDIDATE_EXECUTION_SUPPORT, n as executePreparedAgentCandidate, t as prepareAgentCandidateExecution, w as verifyAgentCandidateBundle, x as exactProcessProviderAsCandidateExecutor, y as createProtectedAgentCandidateModelPort } from "./prepare-DT-ibRsm.js";
|
|
8
|
+
import { W as resolveAgentEnvironmentProvider } from "./supervisor-DwdeUC2l.js";
|
|
9
9
|
import { t as runAnalystLoop } from "./analyst-loop-BZvXCDKy.js";
|
|
10
10
|
import { ATTR, agentIdentityAttributes } from "@tangle-network/agent-trace-contract";
|
|
11
|
-
import { AGENT_IMPROVEMENT_SOURCE_METADATA_KEY, agentCandidateMaterializationReceiptSchema, agentCandidateRunReceiptSchema, agentImprovementSourceMetadata, agentImprovementSourceSchema, agentProfileImprovementArmSchema, applyAgentProfileDiff, candidateExecutionEvidenceSchema, numbersApproximatelyEqual } from "@tangle-network/agent-interface";
|
|
11
|
+
import { AGENT_IMPROVEMENT_SOURCE_METADATA_KEY, agentCandidateMaterializationReceiptSchema, agentCandidateRunReceiptSchema, agentImprovementSourceMetadata, agentImprovementSourceSchema, agentProfileImprovementArmSchema, agentProfileImprovementExpectedModel, agentProfileImprovementModelBindingSchema, agentProfileImprovementRunReceiptSchema, applyAgentProfileDiff, candidateExecutionEvidenceSchema, numbersApproximatelyEqual } from "@tangle-network/agent-interface";
|
|
12
12
|
import { CostLedger, contentHash } from "@tangle-network/agent-eval";
|
|
13
13
|
import { toOtlpAttributes } from "@tangle-network/agent-trace-contract/otlp";
|
|
14
14
|
import { assertProposalFindings } from "@tangle-network/agent-eval/analyst";
|
|
15
|
-
import { campaignSplitDigestFromIdentities } from "@tangle-network/agent-eval/campaign";
|
|
15
|
+
import { campaignScenarioIdentity, campaignSplitDigestFromIdentities } from "@tangle-network/agent-eval/campaign";
|
|
16
16
|
import { measuredComparisonFromAgentProfileImprovementExperiment, measuredComparisonFromCandidateExperiment, runAgentProfileImprovementExperiment, runCandidateExperiment, sealAgentProfileImprovementExperiment, sealAgentProfileImprovementSuite, sealAgentProfileImprovementTask, sealCandidateExperiment, verifyAgentProfileImprovementExperimentComparison, verifyCandidateExperiment, verifyCandidateExperimentComparison } from "@tangle-network/agent-eval/contract";
|
|
17
17
|
// src/intelligence/delivery.ts
|
|
18
18
|
const defaultPlaneBaseUrl = "https://intelligence.tangle.tools";
|
|
@@ -483,6 +483,26 @@ function withMissingAttributes(span, attributes) {
|
|
|
483
483
|
};
|
|
484
484
|
}
|
|
485
485
|
// src/intelligence/profile-improvement-experiment.ts
|
|
486
|
+
function profileImprovementHold(allowIncomplete, source, analysis, improvement, ledger) {
|
|
487
|
+
if (allowIncomplete !== true) return void 0;
|
|
488
|
+
const accounting = ledger.summary();
|
|
489
|
+
const phase = improvement.decision !== "ship" ? "search" : !accounting.accountingComplete || accounting.costProvenance.kind === "uncaptured" ? "preparation" : void 0;
|
|
490
|
+
if (!phase) return void 0;
|
|
491
|
+
return {
|
|
492
|
+
status: "held",
|
|
493
|
+
decision: "hold",
|
|
494
|
+
phase,
|
|
495
|
+
source,
|
|
496
|
+
analysis,
|
|
497
|
+
improvement,
|
|
498
|
+
accounting,
|
|
499
|
+
reasons: [
|
|
500
|
+
...phase === "search" ? ["Search did not establish a promotable profile change"] : [],
|
|
501
|
+
...accounting.incompleteReasons,
|
|
502
|
+
...accounting.costProvenance.kind === "uncaptured" ? ["Preparation cost provenance is uncaptured"] : []
|
|
503
|
+
]
|
|
504
|
+
};
|
|
505
|
+
}
|
|
486
506
|
function createProfileImprovementCostLedger(budgetUsd, context = "profile improvement") {
|
|
487
507
|
if (!Number.isFinite(budgetUsd) || budgetUsd < 0) throw new Error(`${context} budgetUsd must be a non-negative finite number`);
|
|
488
508
|
return new CostLedger({ costCeilingUsd: budgetUsd });
|
|
@@ -511,6 +531,98 @@ function profileStateDigest$1(stateDigest, identity, profile) {
|
|
|
511
531
|
profile
|
|
512
532
|
}) }).stateDigest;
|
|
513
533
|
}
|
|
534
|
+
/** Parse a static binding before any spend. The returned step resolves a function binding once on
|
|
535
|
+
* frozen states, refuses a state that changed meanwhile, and checks each task's expected model. */
|
|
536
|
+
function profileImprovementModelBinding(binding) {
|
|
537
|
+
const source = typeof binding === "function" || binding === void 0 ? binding : immutableCandidateValue(agentProfileImprovementModelBindingSchema.parse(binding));
|
|
538
|
+
return async ({ change, tasks, profiles, unchanged }) => {
|
|
539
|
+
const modelBinding = source === void 0 ? void 0 : agentProfileImprovementModelBindingSchema.parse(typeof source === "function" ? await source(immutableCandidateValue(profiles)) : source);
|
|
540
|
+
if (!unchanged()) throw new Error("profile state changed before the measured experiment was sealed");
|
|
541
|
+
for (const task of tasks) for (const arm of ["baseline", "candidate"]) agentProfileImprovementExpectedModel({
|
|
542
|
+
change,
|
|
543
|
+
modelBinding
|
|
544
|
+
}, task, arm, profiles[arm]);
|
|
545
|
+
return modelBinding;
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
/** Measure only the sealed profile states, re-checking each state and its model before the cell. */
|
|
549
|
+
function profileImprovementMeasure(options, sourceIdentity, experiment, profiles) {
|
|
550
|
+
return async (input) => {
|
|
551
|
+
const measuredProfile = profiles.get(input.stateDigest);
|
|
552
|
+
if (!measuredProfile) throw new Error("profile improvement execution requested an unknown profile state");
|
|
553
|
+
if (profileStateDigest$1(options.stateDigest, sourceIdentity, measuredProfile) !== input.stateDigest) throw new Error("profile state changed before measurement");
|
|
554
|
+
agentProfileImprovementExpectedModel(experiment, input.task, input.arm, measuredProfile);
|
|
555
|
+
const { signal, ...cell } = input;
|
|
556
|
+
const receipt = await options.executor.measure({
|
|
557
|
+
...immutableCandidateValue({
|
|
558
|
+
...cell,
|
|
559
|
+
profile: measuredProfile
|
|
560
|
+
}),
|
|
561
|
+
...signal ? { signal } : {}
|
|
562
|
+
});
|
|
563
|
+
return options.allowIncomplete === true ? receipt : agentProfileImprovementRunReceiptSchema.parse(receipt);
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
/** Seal the optimizer's exact candidate state, resolve its model binding on the frozen states, and
|
|
567
|
+
* measure both states. `assertCandidate` runs on the parsed candidate before the binding resolves. */
|
|
568
|
+
async function measureProfileImprovementCandidate(options, input) {
|
|
569
|
+
const { source, baseline, benchmark, costLedger } = input;
|
|
570
|
+
const profile = parseExactAgentProfile(input.candidate, "profile improvement candidate");
|
|
571
|
+
const stateDigest = profileStateDigest$1(options.stateDigest, source.sourceIdentity, profile);
|
|
572
|
+
if (stateDigest === baseline.stateDigest) throw new Error("profile improvement candidate state digest matches the baseline");
|
|
573
|
+
const change = agentImprovementProfileDiffs(baseline.profile, profile, {
|
|
574
|
+
id: `profile-improvement:${stateDigest}`,
|
|
575
|
+
metadata: {
|
|
576
|
+
sourceIdentity: source.sourceIdentity,
|
|
577
|
+
sourceRevision: source.sourceRevision
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
const profileDiffIds = change.map((step) => {
|
|
581
|
+
if (!step.id) throw new Error("profile improvement change requires an exact diff id");
|
|
582
|
+
return step.id;
|
|
583
|
+
});
|
|
584
|
+
input.assertCandidate(profile);
|
|
585
|
+
const modelBinding = await input.resolveModelBinding({
|
|
586
|
+
change,
|
|
587
|
+
tasks: benchmark.tasks,
|
|
588
|
+
profiles: {
|
|
589
|
+
baseline: baseline.profile,
|
|
590
|
+
candidate: profile
|
|
591
|
+
},
|
|
592
|
+
unchanged: () => profileStateDigest$1(options.stateDigest, source.sourceIdentity, baseline.profile) === baseline.stateDigest && profileStateDigest$1(options.stateDigest, source.sourceIdentity, profile) === stateDigest
|
|
593
|
+
});
|
|
594
|
+
const experiment = sealAgentProfileImprovementExperiment({
|
|
595
|
+
kind: "agent-profile-improvement-experiment",
|
|
596
|
+
digestAlgorithm: "rfc8785-sha256",
|
|
597
|
+
source,
|
|
598
|
+
executionRef: options.executor.executionRef,
|
|
599
|
+
baseline: { stateDigest: baseline.stateDigest },
|
|
600
|
+
candidate: { stateDigest },
|
|
601
|
+
change,
|
|
602
|
+
...modelBinding && { modelBinding },
|
|
603
|
+
candidateLineage: {
|
|
604
|
+
source: "optimizer",
|
|
605
|
+
parentDigests: [source.sourceDigest],
|
|
606
|
+
runIds: [input.lineage.runId],
|
|
607
|
+
profileDiffIds,
|
|
608
|
+
developmentSplitDigest: input.lineage.developmentSplitDigest
|
|
609
|
+
},
|
|
610
|
+
benchmark,
|
|
611
|
+
policy: input.policy
|
|
612
|
+
});
|
|
613
|
+
return {
|
|
614
|
+
experiment,
|
|
615
|
+
preparation: profilePreparationAccounting(costLedger, input.preparationStartedAt),
|
|
616
|
+
run: await runAgentProfileImprovementExperiment({
|
|
617
|
+
allowIncomplete: true,
|
|
618
|
+
experiment,
|
|
619
|
+
...options.maxConcurrency === void 0 ? {} : { maxConcurrency: options.maxConcurrency },
|
|
620
|
+
costLedger,
|
|
621
|
+
...options.signal ? { signal: options.signal } : {},
|
|
622
|
+
execute: profileImprovementMeasure(options, source.sourceIdentity, experiment, /* @__PURE__ */ new Map([[baseline.stateDigest, baseline.profile], [stateDigest, profile]]))
|
|
623
|
+
})
|
|
624
|
+
};
|
|
625
|
+
}
|
|
514
626
|
function sealProfileImprovementBenchmark(input) {
|
|
515
627
|
const tasks = input.tasks.map((task) => sealAgentProfileImprovementTask(task));
|
|
516
628
|
return sealAgentProfileImprovementSuite({
|
|
@@ -825,6 +937,18 @@ function isStringRecord(v) {
|
|
|
825
937
|
function isJsonSchema(v) {
|
|
826
938
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
827
939
|
}
|
|
940
|
+
// src/intelligence/improvement-experiment-lineage.ts
|
|
941
|
+
/** The outer exam cannot reuse an exact task already exposed to search. */
|
|
942
|
+
function assertReleaseScenariosAreFresh(partitions, heldOutScenarios) {
|
|
943
|
+
const optimizerScenarios = /* @__PURE__ */ new Map();
|
|
944
|
+
for (const [partition, scenarios] of [
|
|
945
|
+
["train", partitions.train],
|
|
946
|
+
["selection", partitions.selection ?? []],
|
|
947
|
+
["final-test", partitions.finalTest ?? []]
|
|
948
|
+
]) for (const scenario of scenarios) optimizerScenarios.set(canonicalCandidateDigest$1(scenario), partition);
|
|
949
|
+
const reused = heldOutScenarios.filter((scenario) => optimizerScenarios.has(canonicalCandidateDigest$1(scenario))).map((scenario) => String(scenario.id) + " (" + optimizerScenarios.get(canonicalCandidateDigest$1(scenario)) + ")");
|
|
950
|
+
if (reused.length > 0) throw new Error("release benchmark reuses optimizer scenario(s): [" + reused.join(", ") + "]");
|
|
951
|
+
}
|
|
828
952
|
// src/intelligence/improvement-cycle.ts
|
|
829
953
|
/** A failed baseline or candidate cell with its complete Runtime failure result. */
|
|
830
954
|
var AgentCandidateExperimentCellExecutionError = class extends Error {
|
|
@@ -948,6 +1072,7 @@ async function analyzeAgentImprovement(runId, options, costLedger, signal) {
|
|
|
948
1072
|
const analysis = await runAnalystLoop({
|
|
949
1073
|
...options,
|
|
950
1074
|
runId,
|
|
1075
|
+
log: () => {},
|
|
951
1076
|
...costLedger ? {
|
|
952
1077
|
costLedger,
|
|
953
1078
|
costPhase: "profile-improvement-analysis"
|
|
@@ -992,37 +1117,24 @@ function assertAnalysisCostRecorded(analysis, costLedger) {
|
|
|
992
1117
|
}
|
|
993
1118
|
function assertReleaseSplitIsFresh(heldOutSplitDigest, improvement) {
|
|
994
1119
|
const consumedSplits = [improvement.lineage.developmentSplitDigest];
|
|
995
|
-
if (improvement.mode
|
|
1120
|
+
if (improvement.mode !== "code") {
|
|
996
1121
|
const finalTestSplitDigest = improvement.lineage.finalTestSplitDigest;
|
|
997
|
-
if (!finalTestSplitDigest) throw new Error("
|
|
1122
|
+
if (!finalTestSplitDigest) throw new Error("profile improvement does not retain its final-test split digest");
|
|
998
1123
|
consumedSplits.push(finalTestSplitDigest);
|
|
999
1124
|
}
|
|
1000
1125
|
if (consumedSplits.includes(heldOutSplitDigest)) throw new Error("release benchmark reuses an optimizer development or final-test split");
|
|
1001
1126
|
}
|
|
1002
|
-
function assertReleaseScenariosAreFresh(improvement, heldOutScenarios) {
|
|
1003
|
-
const optimizerScenarios = /* @__PURE__ */ new Map();
|
|
1004
|
-
for (const [partition, scenarios] of [
|
|
1005
|
-
["train", improvement.lineage.scenarioPartitions.train],
|
|
1006
|
-
["selection", improvement.lineage.scenarioPartitions.selection],
|
|
1007
|
-
["final-test", improvement.lineage.scenarioPartitions.finalTest]
|
|
1008
|
-
]) for (const scenario of scenarios) optimizerScenarios.set(canonicalCandidateDigest$1(scenario), partition);
|
|
1009
|
-
const reused = heldOutScenarios.filter((scenario) => optimizerScenarios.has(canonicalCandidateDigest$1(scenario))).map((scenario) => `${scenario.id} (${optimizerScenarios.get(canonicalCandidateDigest$1(scenario))})`);
|
|
1010
|
-
if (reused.length > 0) throw new Error(`release benchmark reuses optimizer scenario(s): [${reused.join(", ")}]`);
|
|
1011
|
-
}
|
|
1012
1127
|
function assertCandidateReleaseWorkIsFresh(experiment, improvement) {
|
|
1013
1128
|
for (const splitDigest of new Set(experiment.benchmark.tasks.map((task) => task.benchmark.splitDigest))) assertReleaseSplitIsFresh(splitDigest, improvement);
|
|
1014
|
-
if (improvement.mode
|
|
1015
|
-
assertReleaseScenariosAreFresh(improvement, experiment.benchmark.tasks.map((task) => task.scenario));
|
|
1129
|
+
if (improvement.mode === "code") return;
|
|
1130
|
+
assertReleaseScenariosAreFresh(improvement.lineage.scenarioPartitions, experiment.benchmark.tasks.map((task) => task.scenario));
|
|
1016
1131
|
}
|
|
1017
1132
|
function assertProfileReleaseWorkIsFresh(benchmark, improvement) {
|
|
1018
1133
|
assertReleaseSplitIsFresh(benchmark.suite.splitDigest, improvement);
|
|
1019
|
-
assertReleaseScenariosAreFresh(improvement, benchmark.tasks.map(profileTaskScenarioIdentity));
|
|
1134
|
+
assertReleaseScenariosAreFresh(improvement.lineage.scenarioPartitions, benchmark.tasks.map(profileTaskScenarioIdentity));
|
|
1020
1135
|
}
|
|
1021
|
-
/**
|
|
1022
|
-
* Analyze a product-owned profile, search one profile surface, then run the
|
|
1023
|
-
* exact baseline and candidate through the product executor before proposing.
|
|
1024
|
-
*/
|
|
1025
1136
|
async function proposeAgentProfileImprovement(options) {
|
|
1137
|
+
const resolveModelBinding = profileImprovementModelBinding(options.modelBinding);
|
|
1026
1138
|
const source = agentImprovementSourceSchema.parse(options.source);
|
|
1027
1139
|
const surface = options.improvement.surface ?? "prompt";
|
|
1028
1140
|
if (!isAgentProfileMeasuredSurface(surface)) throw new Error("measured profile improvement supports profile surfaces or a complete agent profile; use the sealed-candidate path for this surface");
|
|
@@ -1052,58 +1164,37 @@ async function proposeAgentProfileImprovement(options) {
|
|
|
1052
1164
|
findings: proposalFindings
|
|
1053
1165
|
});
|
|
1054
1166
|
try {
|
|
1167
|
+
const held = profileImprovementHold(options.allowIncomplete, source, analysis, improvement, costLedger);
|
|
1168
|
+
if (held) return held;
|
|
1055
1169
|
if (improvement.decision !== "ship") throw new Error("agent profile improvement search did not produce a promotable candidate");
|
|
1056
|
-
const
|
|
1057
|
-
const candidateStateDigest = profileStateDigest$1(options.stateDigest, source.sourceIdentity, candidateProfile);
|
|
1058
|
-
if (candidateStateDigest === baselineStateDigest) throw new Error("profile improvement candidate state digest matches the baseline");
|
|
1059
|
-
const change = agentImprovementProfileDiffs(profile, candidateProfile, {
|
|
1060
|
-
id: `profile-improvement:${candidateStateDigest}`,
|
|
1061
|
-
metadata: {
|
|
1062
|
-
sourceIdentity: source.sourceIdentity,
|
|
1063
|
-
sourceRevision: source.sourceRevision
|
|
1064
|
-
}
|
|
1065
|
-
});
|
|
1066
|
-
const profileDiffIds = change.map((step) => {
|
|
1067
|
-
if (!step.id) throw new Error("profile improvement change requires an exact diff id");
|
|
1068
|
-
return step.id;
|
|
1069
|
-
});
|
|
1070
|
-
assertProfileTrainingIsHeldOut(candidateProfile, heldOutDigests);
|
|
1071
|
-
assertProfileReleaseWorkIsFresh(benchmark, improvement);
|
|
1072
|
-
const experiment = sealAgentProfileImprovementExperiment({
|
|
1073
|
-
kind: "agent-profile-improvement-experiment",
|
|
1074
|
-
digestAlgorithm: "rfc8785-sha256",
|
|
1170
|
+
const { experiment, preparation, run } = await measureProfileImprovementCandidate(options, {
|
|
1075
1171
|
source,
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
change,
|
|
1080
|
-
candidateLineage: {
|
|
1081
|
-
source: "optimizer",
|
|
1082
|
-
parentDigests: [source.sourceDigest],
|
|
1083
|
-
runIds: [improvement.lineage.runId],
|
|
1084
|
-
profileDiffIds,
|
|
1085
|
-
developmentSplitDigest: improvement.lineage.developmentSplitDigest
|
|
1172
|
+
baseline: {
|
|
1173
|
+
profile,
|
|
1174
|
+
stateDigest: baselineStateDigest
|
|
1086
1175
|
},
|
|
1176
|
+
candidate: improvement.candidate.profile,
|
|
1177
|
+
lineage: improvement.lineage,
|
|
1087
1178
|
benchmark,
|
|
1088
|
-
policy
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
...options.maxConcurrency === void 0 ? {} : { maxConcurrency: options.maxConcurrency },
|
|
1179
|
+
policy,
|
|
1180
|
+
resolveModelBinding,
|
|
1181
|
+
assertCandidate: (candidateProfile) => {
|
|
1182
|
+
assertProfileTrainingIsHeldOut(candidateProfile, heldOutDigests);
|
|
1183
|
+
assertProfileReleaseWorkIsFresh(benchmark, improvement);
|
|
1184
|
+
},
|
|
1095
1185
|
costLedger,
|
|
1096
|
-
|
|
1097
|
-
execute: async (input) => {
|
|
1098
|
-
const measuredProfile = profilesByStateDigest.get(input.stateDigest);
|
|
1099
|
-
if (!measuredProfile) throw new Error("profile improvement execution requested an unknown profile state");
|
|
1100
|
-
return options.executor.measure({
|
|
1101
|
-
...input,
|
|
1102
|
-
profile: measuredProfile
|
|
1103
|
-
});
|
|
1104
|
-
}
|
|
1186
|
+
preparationStartedAt
|
|
1105
1187
|
});
|
|
1106
|
-
|
|
1188
|
+
if ("status" in run) {
|
|
1189
|
+
if (options.allowIncomplete !== true) throw new Error("profile improvement measurement accounting is incomplete");
|
|
1190
|
+
return {
|
|
1191
|
+
...run,
|
|
1192
|
+
analysis,
|
|
1193
|
+
improvement,
|
|
1194
|
+
experiment
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
const optimizationReceipt = improvement.mode === "method" ? createOptimizationActivationReceipt(improvement) : void 0;
|
|
1107
1198
|
const evaluation = verifyAgentProfileImprovementExperimentComparison(measuredComparisonFromAgentProfileImprovementExperiment({
|
|
1108
1199
|
experiment,
|
|
1109
1200
|
measurements: run.measurements,
|
|
@@ -1145,7 +1236,8 @@ async function proposeAgentImprovement(options) {
|
|
|
1145
1236
|
};
|
|
1146
1237
|
const improvement = improvementInput.surface === "code" ? await improve(improvementInput) : await improve(options.profile, improvementInput);
|
|
1147
1238
|
try {
|
|
1148
|
-
|
|
1239
|
+
const deferredCode = options.improvement.surface === "code" && options.improvement.budget?.holdout === "deferred" && improvement.mode === "code" && improvement.raw.raw.holdout === "deferred";
|
|
1240
|
+
if (improvement.decision !== "ship" && !deferredCode) throw new Error("agent improvement search did not produce a promotable candidate");
|
|
1149
1241
|
const searchAccounting = completeImprovementSearchAccounting(analysisAccounting, improvement);
|
|
1150
1242
|
const preparation = {
|
|
1151
1243
|
wallDurationMs: searchAccounting.searchDurationMs,
|
|
@@ -1159,6 +1251,7 @@ async function proposeAgentImprovement(options) {
|
|
|
1159
1251
|
analysis,
|
|
1160
1252
|
improvement
|
|
1161
1253
|
}), improvement);
|
|
1254
|
+
if (deferredCode && options.improvement.surface === "code") assertReleaseScenariosAreFresh({ train: options.improvement.scenarios.map(campaignScenarioIdentity) }, experiment.benchmark.tasks.map((task) => task.scenario));
|
|
1162
1255
|
assertCandidateProfileBinding(options.profile, experiment.baseline.profile);
|
|
1163
1256
|
assertImprovementCandidateBinding(improvement, experiment);
|
|
1164
1257
|
const measured = await runAgentCandidateExperiment({
|