@tangle-network/agent-runtime 0.93.2 → 0.94.1

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.
Files changed (80) hide show
  1. package/README.md +4 -3
  2. package/dist/agent.d.ts +1 -1
  3. package/dist/agent.js +5 -6
  4. package/dist/agent.js.map +1 -1
  5. package/dist/{agentic-generator-B8oeE2Yv.d.ts → agentic-generator-D9ZmAuiL.d.ts} +1 -1
  6. package/dist/analyst-loop.d.ts +1 -1
  7. package/dist/candidate-execution/index.d.ts +10 -3
  8. package/dist/candidate-execution/index.js +9 -3
  9. package/dist/{chunk-6K5CI33W.js → chunk-D336OZHK.js} +1232 -19
  10. package/dist/chunk-D336OZHK.js.map +1 -0
  11. package/dist/{chunk-TU73X3I6.js → chunk-HPCJBBLS.js} +2 -2
  12. package/dist/chunk-ISTDY47H.js +849 -0
  13. package/dist/chunk-ISTDY47H.js.map +1 -0
  14. package/dist/{chunk-RTVVH2KL.js → chunk-JEP2WM24.js} +2 -2
  15. package/dist/{chunk-Z7K5BPKZ.js → chunk-K7OPNHU4.js} +2 -2
  16. package/dist/{chunk-OX3QRJOA.js → chunk-KHLE3C5G.js} +281 -251
  17. package/dist/chunk-KHLE3C5G.js.map +1 -0
  18. package/dist/{chunk-XDSWWUKE.js → chunk-MZH4HORF.js} +6 -29
  19. package/dist/chunk-MZH4HORF.js.map +1 -0
  20. package/dist/chunk-PJNGPWTA.js +634 -0
  21. package/dist/chunk-PJNGPWTA.js.map +1 -0
  22. package/dist/{chunk-X5KJKS33.js → chunk-RTSZNYXM.js} +3 -3
  23. package/dist/{chunk-WGR6QJ5H.js → chunk-SJHFJOCY.js} +8 -161
  24. package/dist/chunk-SJHFJOCY.js.map +1 -0
  25. package/dist/{chunk-2BQMAZAB.js → chunk-URMJTSXB.js} +1378 -28
  26. package/dist/chunk-URMJTSXB.js.map +1 -0
  27. package/dist/{chunk-3D2RHC4K.js → chunk-WIPGQ4GT.js} +1 -1
  28. package/dist/{chunk-3D2RHC4K.js.map → chunk-WIPGQ4GT.js.map} +1 -1
  29. package/dist/{chunk-R5GWDTM3.js → chunk-ZEYAT33L.js} +2 -2
  30. package/dist/{completion-gate-BLaiN0-X.d.ts → completion-gate-BAj3dXeW.d.ts} +14 -2
  31. package/dist/{coordination-DxJ83oZA.d.ts → coordination-B3ZuApR_.d.ts} +7 -5
  32. package/dist/environment-provider.d.ts +2 -2
  33. package/dist/{improve-DDhQaaJT.d.ts → improve-r8SvIxYv.d.ts} +13 -16
  34. package/dist/index.d.ts +39 -110
  35. package/dist/index.js +92 -36
  36. package/dist/index.js.map +1 -1
  37. package/dist/intelligence.d.ts +24 -7
  38. package/dist/intelligence.js +114 -20
  39. package/dist/intelligence.js.map +1 -1
  40. package/dist/knowledge.d.ts +7 -7
  41. package/dist/knowledge.js +5 -5
  42. package/dist/lifecycle.d.ts +3 -3
  43. package/dist/lifecycle.js +2 -2
  44. package/dist/{local-harness-dcD5WTTr.d.ts → local-harness-B7bNuNJw.d.ts} +49 -1
  45. package/dist/{loop-runner-bin-kKUNGLyV.d.ts → loop-runner-bin-D4bMIxmB.d.ts} +2 -2
  46. package/dist/loop-runner-bin.d.ts +6 -6
  47. package/dist/loop-runner-bin.js +6 -7
  48. package/dist/loops.d.ts +457 -18
  49. package/dist/loops.js +39 -41
  50. package/dist/mcp/bin.js +5 -5
  51. package/dist/mcp/index.d.ts +10 -10
  52. package/dist/mcp/index.js +9 -8
  53. package/dist/{mcp-serve-verifier-Bg4C3p5S.d.ts → mcp-serve-verifier-BuXjaZDE.d.ts} +1 -1
  54. package/dist/{openai-tools-E3woykz9.d.ts → openai-tools-D0ZSRCC6.d.ts} +1 -1
  55. package/dist/{prepare-DiVGKcwS.d.ts → prepare-BKxAiUcH.d.ts} +1 -1
  56. package/dist/profiles.d.ts +1 -1
  57. package/dist/{sanitize-C9go6tXj.d.ts → sanitize-C2jicjNf.d.ts} +1 -1
  58. package/dist/{supervise-T2pazU3G.d.ts → supervise-DTNcLDl2.d.ts} +4 -4
  59. package/dist/{types-DAdIm4AC.d.ts → types-Bb-CqxJH.d.ts} +5 -2
  60. package/dist/{types-B00NtbCs.d.ts → types-DWA64rbJ.d.ts} +1 -1
  61. package/dist/{worktree-fanout-BUb2Ag02.d.ts → worktree-fanout-IMKqdV_E.d.ts} +244 -244
  62. package/package.json +4 -4
  63. package/skills/build-with-agent-runtime/SKILL.md +1 -1
  64. package/dist/chunk-2BQMAZAB.js.map +0 -1
  65. package/dist/chunk-6K5CI33W.js.map +0 -1
  66. package/dist/chunk-FDJ7AHXG.js +0 -1229
  67. package/dist/chunk-FDJ7AHXG.js.map +0 -1
  68. package/dist/chunk-J2K6WIG6.js +0 -2172
  69. package/dist/chunk-J2K6WIG6.js.map +0 -1
  70. package/dist/chunk-OX3QRJOA.js.map +0 -1
  71. package/dist/chunk-PX6SXX3M.js +0 -146
  72. package/dist/chunk-PX6SXX3M.js.map +0 -1
  73. package/dist/chunk-WGR6QJ5H.js.map +0 -1
  74. package/dist/chunk-XDSWWUKE.js.map +0 -1
  75. package/dist/structural-rollout-DHGDbhvR.d.ts +0 -446
  76. /package/dist/{chunk-TU73X3I6.js.map → chunk-HPCJBBLS.js.map} +0 -0
  77. /package/dist/{chunk-RTVVH2KL.js.map → chunk-JEP2WM24.js.map} +0 -0
  78. /package/dist/{chunk-Z7K5BPKZ.js.map → chunk-K7OPNHU4.js.map} +0 -0
  79. /package/dist/{chunk-X5KJKS33.js.map → chunk-RTSZNYXM.js.map} +0 -0
  80. /package/dist/{chunk-R5GWDTM3.js.map → chunk-ZEYAT33L.js.map} +0 -0
@@ -1,16 +1,16 @@
1
1
  import { AgentProfile, AgentCandidateBundle, Sha256Digest, AgentProfileDiff, AgentProfileMcpServer } from '@tangle-network/agent-interface';
2
- import { g as LoopTraceEvent, b as RuntimeStreamEvent } from './types-B00NtbCs.js';
3
- import { b as ToolSpec, c as RuntimeTelemetryOptions } from './sanitize-C9go6tXj.js';
2
+ import { f as LoopTraceEvent, a as RuntimeStreamEvent } from './types-DWA64rbJ.js';
3
+ import { b as ToolSpec, c as RuntimeTelemetryOptions } from './sanitize-C2jicjNf.js';
4
4
  import { AnalystFinding } from '@tangle-network/agent-eval/analyst';
5
5
  import { Scenario, SelfImproveResult } from '@tangle-network/agent-eval/contract';
6
6
  import { R as RunAnalystLoopOpts, a as RunAnalystLoopResult } from './types-BC3bZpH0.js';
7
- import { A as AgentCandidateTaskExecution, a as AgentCandidateExecutionPorts, P as PrepareAgentCandidateExecutionOptions, E as ExecutePreparedAgentCandidateOptions, b as AgentCandidateRunFinalization, c as AgentCandidateBundleInput } from './prepare-DiVGKcwS.js';
8
- import { I as ImproveSurface, a as ImproveOptions, b as ImproveResult } from './improve-DDhQaaJT.js';
7
+ import { A as AgentCandidateBundleInput, a as AgentCandidateTaskExecution, b as AgentCandidateExecutionPorts, P as PrepareAgentCandidateExecutionOptions, E as ExecutePreparedAgentCandidateOptions, c as AgentCandidateRunFinalization } from './prepare-BKxAiUcH.js';
8
+ import { I as ImproveSurface, a as ImproveOptions, b as ImproveResult } from './improve-r8SvIxYv.js';
9
9
  import '@tangle-network/agent-eval';
10
10
  import '@tangle-network/sandbox';
11
- import './local-harness-dcD5WTTr.js';
11
+ import './local-harness-B7bNuNJw.js';
12
12
  import 'node:child_process';
13
- import './agentic-generator-B8oeE2Yv.js';
13
+ import './agentic-generator-D9ZmAuiL.js';
14
14
  import '@tangle-network/agent-eval/campaign';
15
15
 
16
16
  /**
@@ -133,6 +133,7 @@ interface AgentImprovementProposal<TScenario extends Scenario = Scenario, TArtif
133
133
  runId: string;
134
134
  surface: ImproveSurface;
135
135
  proposedAt: string;
136
+ baselineProfile: AgentProfile;
136
137
  baselineProfileHash: string;
137
138
  candidateProfile: AgentProfile;
138
139
  candidateProfileHash: string;
@@ -185,6 +186,16 @@ interface ProposeAgentImprovementResult<TScenario extends Scenario, TArtifact> {
185
186
  improvement: ImproveResult<TScenario, TArtifact>;
186
187
  proposal: AgentImprovementProposal<TScenario, TArtifact>;
187
188
  }
189
+ interface CreateAgentImprovementProposalOptions<TScenario extends Scenario, TArtifact> {
190
+ runId: string;
191
+ surface: ImproveSurface;
192
+ baselineProfile: AgentProfile;
193
+ candidateProfile: AgentProfile;
194
+ findings: readonly AnalystFinding[];
195
+ evaluation: SelfImproveResult<TScenario, TArtifact>;
196
+ candidateBundle?: AgentCandidateBundleInput | AgentCandidateBundle;
197
+ now?: () => Date;
198
+ }
188
199
  interface ReviewAgentImprovementInput {
189
200
  decision: AgentImprovementReviewDecision;
190
201
  reviewedBy: string;
@@ -208,6 +219,12 @@ interface ExecuteApprovedAgentCandidateResult {
208
219
  }
209
220
  /** Analyze one run and produce one measured, review-only improvement proposal. */
210
221
  declare function proposeAgentImprovement<TScenario extends Scenario, TArtifact>(options: ProposeAgentImprovementOptions<TScenario, TArtifact>): Promise<ProposeAgentImprovementResult<TScenario, TArtifact>>;
222
+ /**
223
+ * Freeze an already-measured improvement into the one reviewable proposal
224
+ * contract. Products that run analysis or evaluation in separate workers use
225
+ * this constructor instead of rerunning either phase or rebuilding digests.
226
+ */
227
+ declare function createAgentImprovementProposal<TScenario extends Scenario, TArtifact>(options: CreateAgentImprovementProposalOptions<TScenario, TArtifact>): AgentImprovementProposal<TScenario, TArtifact>;
211
228
  /** Persist an approve/reject/change-request decision bound to one exact proposal. */
212
229
  declare function reviewAgentImprovementProposal(inputProposal: AgentImprovementProposal, input: ReviewAgentImprovementInput): AgentImprovementReview;
213
230
  /** Verify, materialize, run, grade, and receipt only the exact approved bundle. */
@@ -1213,4 +1230,4 @@ interface DoctorReport {
1213
1230
  */
1214
1231
  declare function createIntelligenceClient(config: IntelligenceConfig): IntelligenceClient;
1215
1232
 
1216
- export { type AgentImprovementEvaluation, type AgentImprovementProposal, type AgentImprovementReview, type AgentImprovementReviewDecision, type AppliedIntelligence, type CandidateExecutionEvidence, type CapabilityAuth, type CapabilityInterface, type CapabilityManifest, CapabilityNotAdmittedError, type CapabilitySurface, type CertProvenance, type CertifiedArtifact, type CertifiedCapability, type CertifiedCapabilitySummary, type CertifiedProfile, type CertifiedPromptSource, type CertifiedPromptSourceOptions, type CertifiedPromptSurface, type ContentRef, type CorpusAccess, type CredentialRef, type DeliveryBinding, type DeliveryBindingKind, type DiffProvenance, type DoctorReport, type EffortOverrides, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type ExecuteApprovedAgentCandidateOptions, type ExecuteApprovedAgentCandidateResult, type HostSpec, type IntelligenceAgent, type IntelligenceClient, type IntelligenceConfig, type IntelligenceHookConfig, type IntelligenceWrapped, type JsonSchema, type ModeReadiness, type ProposeAgentImprovementOptions, type ProposeAgentImprovementResult, type ProposedProfileDiff, type ProvisionedHost, type PullCertifiedOptions, type PullOutcome, type RecordTraceMeta, type Redactor, type RepoConfig, type ResolveCtx, type ResolvedHook, type ResolvedRetrieval, type ResolvedSubagent, type ResolvedSurface, type ReviewAgentImprovementInput, type RunRecord, type RunReport, type TraceHandle, type TraceMeta, type TraceOutcome, type UsageClass, type UsageSplit, compileEffort, composeCertifiedProfile, composeCertifiedProfileFromWire, composeCertifiedPrompt, createCertifiedPromptSource, createIntelligenceClient, defaultEffortTier, defaultRedactor, executeApprovedAgentCandidate, isIntelligenceOff, manifestFromProfile, normalizeCertifiedProfile, proposeAgentImprovement, pullCertified, resolveEffort, resolveIntelligenceBaseUrl, resolveRedactor, reviewAgentImprovementProposal, verifyAgentImprovementProposal, verifyAgentImprovementReview, withIntelligence };
1233
+ export { type AgentImprovementEvaluation, type AgentImprovementProposal, type AgentImprovementReview, type AgentImprovementReviewDecision, type AppliedIntelligence, type CandidateExecutionEvidence, type CapabilityAuth, type CapabilityInterface, type CapabilityManifest, CapabilityNotAdmittedError, type CapabilitySurface, type CertProvenance, type CertifiedArtifact, type CertifiedCapability, type CertifiedCapabilitySummary, type CertifiedProfile, type CertifiedPromptSource, type CertifiedPromptSourceOptions, type CertifiedPromptSurface, type ContentRef, type CorpusAccess, type CreateAgentImprovementProposalOptions, type CredentialRef, type DeliveryBinding, type DeliveryBindingKind, type DiffProvenance, type DoctorReport, type EffortOverrides, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type ExecuteApprovedAgentCandidateOptions, type ExecuteApprovedAgentCandidateResult, type HostSpec, type IntelligenceAgent, type IntelligenceClient, type IntelligenceConfig, type IntelligenceHookConfig, type IntelligenceWrapped, type JsonSchema, type ModeReadiness, type ProposeAgentImprovementOptions, type ProposeAgentImprovementResult, type ProposedProfileDiff, type ProvisionedHost, type PullCertifiedOptions, type PullOutcome, type RecordTraceMeta, type Redactor, type RepoConfig, type ResolveCtx, type ResolvedHook, type ResolvedRetrieval, type ResolvedSubagent, type ResolvedSurface, type ReviewAgentImprovementInput, type RunRecord, type RunReport, type TraceHandle, type TraceMeta, type TraceOutcome, type UsageClass, type UsageSplit, compileEffort, composeCertifiedProfile, composeCertifiedProfileFromWire, composeCertifiedPrompt, createAgentImprovementProposal, createCertifiedPromptSource, createIntelligenceClient, defaultEffortTier, defaultRedactor, executeApprovedAgentCandidate, isIntelligenceOff, manifestFromProfile, normalizeCertifiedProfile, proposeAgentImprovement, pullCertified, resolveEffort, resolveIntelligenceBaseUrl, resolveRedactor, reviewAgentImprovementProposal, verifyAgentImprovementProposal, verifyAgentImprovementReview, withIntelligence };
@@ -1,6 +1,7 @@
1
1
  import {
2
+ applyImprovementWinnerToProfile,
2
3
  improve
3
- } from "./chunk-WGR6QJ5H.js";
4
+ } from "./chunk-SJHFJOCY.js";
4
5
  import {
5
6
  assertCandidateProfileBinding,
6
7
  canonicalCandidateDigest,
@@ -12,22 +13,21 @@ import {
12
13
  prepareAgentCandidateExecution,
13
14
  sealAgentCandidateBundle,
14
15
  verifyAgentCandidateBundle
15
- } from "./chunk-OX3QRJOA.js";
16
- import "./chunk-FDJ7AHXG.js";
16
+ } from "./chunk-KHLE3C5G.js";
17
17
  import {
18
18
  runAnalystLoop
19
19
  } from "./chunk-ZQZX77MM.js";
20
- import "./chunk-RTVVH2KL.js";
20
+ import "./chunk-JEP2WM24.js";
21
21
  import {
22
22
  buildLoopOtelSpans,
23
23
  buildRuntimeEventOtelSpans,
24
24
  createOtelExporter,
25
25
  flatOtelSpan
26
- } from "./chunk-J2K6WIG6.js";
27
- import "./chunk-3D2RHC4K.js";
26
+ } from "./chunk-ISTDY47H.js";
27
+ import "./chunk-WIPGQ4GT.js";
28
28
  import "./chunk-3MDZX7YU.js";
29
29
  import "./chunk-FVJ7M3DA.js";
30
- import "./chunk-PX6SXX3M.js";
30
+ import "./chunk-PJNGPWTA.js";
31
31
  import "./chunk-YEJR7IXO.js";
32
32
  import "./chunk-DGUM43GV.js";
33
33
 
@@ -433,26 +433,61 @@ async function proposeAgentImprovement(options) {
433
433
  "proposeAgentImprovement findings"
434
434
  );
435
435
  const improvement = await improve(options.profile, [...findings], options.improvement);
436
- const candidateBundle = improvement.shipped && options.buildCandidate ? sealBuiltCandidate(await options.buildCandidate({ analysis, improvement })) : void 0;
437
- if (candidateBundle) assertCandidateProfileBinding(improvement.profile, candidateBundle.profile);
438
- const surface = options.improvement.surface ?? "prompt";
439
- const evaluation = canonicalJsonValue(improvementEvaluation(improvement.raw));
440
- const proposalFindings = canonicalJsonValue([...findings]);
436
+ const candidateBundle = improvement.shipped && options.buildCandidate ? await options.buildCandidate({ analysis, improvement }) : void 0;
437
+ const proposal = createAgentImprovementProposal({
438
+ runId: options.runId,
439
+ surface: options.improvement.surface ?? "prompt",
440
+ baselineProfile: options.profile,
441
+ candidateProfile: improvement.profile,
442
+ findings,
443
+ evaluation: improvement.raw,
444
+ ...candidateBundle ? { candidateBundle } : {},
445
+ ...options.now ? { now: options.now } : {}
446
+ });
447
+ return { analysis, improvement, proposal };
448
+ }
449
+ function createAgentImprovementProposal(options) {
450
+ const findings = assertNoJudgeVerdict(
451
+ [...options.findings],
452
+ "createAgentImprovementProposal findings"
453
+ );
454
+ const candidateBundle = options.candidateBundle ? sealBuiltCandidate(options.candidateBundle) : void 0;
455
+ const baselineProfile = parseExactAgentProfile(
456
+ options.baselineProfile,
457
+ "proposal baseline profile"
458
+ );
459
+ const candidateProfile = parseExactAgentProfile(
460
+ options.candidateProfile,
461
+ "proposal candidate profile"
462
+ );
463
+ assertMeasuredProfileBinding({
464
+ surface: options.surface,
465
+ baselineProfile,
466
+ candidateProfile,
467
+ evaluation: options.evaluation,
468
+ hasExecutableBundle: candidateBundle !== void 0
469
+ });
470
+ if (candidateBundle) {
471
+ if (options.evaluation.gateDecision !== "ship") {
472
+ throw new Error("executable candidate bundle requires a passing measured comparison");
473
+ }
474
+ assertCandidateProfileBinding(candidateProfile, candidateBundle.profile);
475
+ }
441
476
  const withoutDigest = {
442
477
  schemaVersion: 1,
443
478
  kind: "agent-improvement-proposal",
444
479
  runId: options.runId,
445
- surface,
480
+ surface: options.surface,
446
481
  proposedAt: (options.now ?? (() => /* @__PURE__ */ new Date()))().toISOString(),
447
- baselineProfileHash: canonicalCandidateDigest(options.profile),
448
- candidateProfile: improvement.profile,
449
- candidateProfileHash: canonicalCandidateDigest(improvement.profile),
450
- findings: proposalFindings,
451
- evaluation,
482
+ baselineProfile,
483
+ baselineProfileHash: canonicalCandidateDigest(baselineProfile),
484
+ candidateProfile,
485
+ candidateProfileHash: canonicalCandidateDigest(candidateProfile),
486
+ findings: canonicalJsonValue([...findings]),
487
+ evaluation: canonicalJsonValue(improvementEvaluation(options.evaluation)),
452
488
  ...candidateBundle ? { candidateBundle } : {}
453
489
  };
454
- const proposal = canonicalCandidateDocument(withoutDigest).value;
455
- return { analysis, improvement, proposal };
490
+ return canonicalCandidateDocument(withoutDigest).value;
456
491
  }
457
492
  function reviewAgentImprovementProposal(inputProposal, input) {
458
493
  const proposal = verifyAgentImprovementProposal(inputProposal);
@@ -521,6 +556,13 @@ function verifyAgentImprovementProposal(input) {
521
556
  throw new Error("invalid agent improvement proposal");
522
557
  }
523
558
  const proposal = input;
559
+ const parsedBaselineProfile = parseExactAgentProfile(
560
+ proposal.baselineProfile,
561
+ "proposal baseline profile"
562
+ );
563
+ if (proposal.baselineProfileHash !== canonicalCandidateDigest(parsedBaselineProfile)) {
564
+ throw new Error("proposal baselineProfileHash does not match baselineProfile");
565
+ }
524
566
  const parsedProfile = parseExactAgentProfile(
525
567
  proposal.candidateProfile,
526
568
  "proposal candidate profile"
@@ -528,6 +570,13 @@ function verifyAgentImprovementProposal(input) {
528
570
  if (proposal.candidateProfileHash !== canonicalCandidateDigest(parsedProfile)) {
529
571
  throw new Error("proposal candidateProfileHash does not match candidateProfile");
530
572
  }
573
+ assertMeasuredProfileBinding({
574
+ surface: proposal.surface,
575
+ baselineProfile: parsedBaselineProfile,
576
+ candidateProfile: parsedProfile,
577
+ evaluation: proposal.evaluation,
578
+ hasExecutableBundle: proposal.candidateBundle !== void 0
579
+ });
531
580
  if (!Array.isArray(proposal.findings)) throw new Error("proposal findings must be an array");
532
581
  if (!isSha256Digest(proposal.digest)) throw new Error("proposal digest is invalid");
533
582
  if (proposal.candidateBundle) {
@@ -542,6 +591,50 @@ function verifyAgentImprovementProposal(input) {
542
591
  throw new Error("agent improvement proposal digest does not match");
543
592
  return immutableCandidateValue(proposal);
544
593
  }
594
+ function assertMeasuredProfileBinding(input) {
595
+ const baselineDigest = canonicalCandidateDigest(input.baselineProfile);
596
+ if (input.evaluation.gateDecision !== "ship") {
597
+ if (canonicalCandidateDigest(input.candidateProfile) !== baselineDigest) {
598
+ throw new Error("non-shipping evaluation must retain the baseline candidate profile");
599
+ }
600
+ return;
601
+ }
602
+ const measured = measuredWinnerProfile(
603
+ input.baselineProfile,
604
+ input.surface,
605
+ input.evaluation.winner.surface
606
+ );
607
+ if (!measured) {
608
+ if (input.hasExecutableBundle) {
609
+ throw new Error(
610
+ `executable '${input.surface}' candidate cannot be bound to its measured winner surface`
611
+ );
612
+ }
613
+ if (canonicalCandidateDigest(input.candidateProfile) !== baselineDigest) {
614
+ throw new Error(
615
+ `unbound '${input.surface}' improvement must retain the baseline candidate profile`
616
+ );
617
+ }
618
+ return;
619
+ }
620
+ if (canonicalCandidateDigest(input.candidateProfile) !== canonicalCandidateDigest(measured)) {
621
+ throw new Error("proposal candidate profile does not match the measured winner surface");
622
+ }
623
+ }
624
+ function measuredWinnerProfile(baselineProfile, surface, winner) {
625
+ if (surface === "code" || surface === "memory") return null;
626
+ if (typeof winner !== "string") {
627
+ throw new Error(`measured '${surface}' winner is not a serializable profile surface`);
628
+ }
629
+ if (surface !== "skills") {
630
+ return applyImprovementWinnerToProfile(baselineProfile, surface, winner);
631
+ }
632
+ try {
633
+ return applyImprovementWinnerToProfile(baselineProfile, surface, winner);
634
+ } catch {
635
+ return null;
636
+ }
637
+ }
545
638
  function sealBuiltCandidate(input) {
546
639
  if (!("digest" in input)) return sealAgentCandidateBundle(input);
547
640
  const parsed = agentCandidateBundleSchema.parse(input);
@@ -1420,6 +1513,7 @@ export {
1420
1513
  composeCertifiedProfile,
1421
1514
  composeCertifiedProfileFromWire,
1422
1515
  composeCertifiedPrompt,
1516
+ createAgentImprovementProposal,
1423
1517
  createCertifiedPromptSource,
1424
1518
  createIntelligenceClient,
1425
1519
  defaultEffortTier,