@tangle-network/agent-interface 0.34.0 → 0.36.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.
@@ -178,6 +178,11 @@ export declare const agentProfileImprovementSuiteInputsSchema: z.ZodObject<{
178
178
  export declare const agentProfileImprovementArmSchema: z.ZodObject<{
179
179
  stateDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
180
180
  }, z.core.$strict>;
181
+ export declare const agentProfileImprovementExecutionRefSchema: z.ZodObject<{
182
+ identity: z.ZodString;
183
+ digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
184
+ kind: z.ZodLiteral<"agent-profile-improvement-execution-ref">;
185
+ }, z.core.$strict>;
181
186
  /**
182
187
  * The first product path changes only prompt and skills, but it uses the
183
188
  * shared profile-diff language so execution and activation apply identical
@@ -194,6 +199,11 @@ export declare const agentProfileImprovementExperimentSchema: z.ZodObject<{
194
199
  sourceDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
195
200
  sourceRevision: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
196
201
  }, z.core.$strict>;
202
+ executionRef: z.ZodObject<{
203
+ identity: z.ZodString;
204
+ digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
205
+ kind: z.ZodLiteral<"agent-profile-improvement-execution-ref">;
206
+ }, z.core.$strict>;
197
207
  baseline: z.ZodObject<{
198
208
  stateDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
199
209
  }, z.core.$strict>;
@@ -360,6 +370,11 @@ export declare const agentProfileImprovementRunReceiptSchema: z.ZodObject<{
360
370
  kind: z.ZodLiteral<"agent-profile-improvement-run">;
361
371
  digestAlgorithm: z.ZodLiteral<"rfc8785-sha256">;
362
372
  executionId: z.ZodString;
373
+ executionRef: z.ZodObject<{
374
+ identity: z.ZodString;
375
+ digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
376
+ kind: z.ZodLiteral<"agent-profile-improvement-execution-ref">;
377
+ }, z.core.$strict>;
363
378
  runCell: z.ZodObject<{
364
379
  kind: z.ZodLiteral<"agent-profile-improvement-run-cell">;
365
380
  experimentDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
@@ -395,6 +410,7 @@ export declare const agentProfileImprovementRunReceiptSchema: z.ZodObject<{
395
410
  endedAtMs: z.ZodNumber;
396
411
  durationMs: z.ZodNumber;
397
412
  }, z.core.$strict>;
413
+ steps: z.ZodNumber;
398
414
  resolvedModel: z.ZodObject<{
399
415
  requested: z.ZodString;
400
416
  provider: z.ZodString;
@@ -425,6 +441,10 @@ export declare const agentProfileImprovementRunReceiptSchema: z.ZodObject<{
425
441
  reasoningTokens: z.ZodNumber;
426
442
  modelCalls: z.ZodNumber;
427
443
  costUsdNanos: z.ZodNumber;
444
+ costProvenance: z.ZodEnum<{
445
+ observed: "observed";
446
+ estimated: "estimated";
447
+ }>;
428
448
  }, z.core.$strict>;
429
449
  trace: z.ZodObject<{
430
450
  evidence: z.ZodObject<{
@@ -484,6 +504,10 @@ export declare const agentProfileImprovementRunReceiptSchema: z.ZodObject<{
484
504
  reasoningTokens: z.ZodNumber;
485
505
  modelCalls: z.ZodNumber;
486
506
  costUsdNanos: z.ZodNumber;
507
+ costProvenance: z.ZodEnum<{
508
+ observed: "observed";
509
+ estimated: "estimated";
510
+ }>;
487
511
  }, z.core.$strict>;
488
512
  score: z.ZodNumber;
489
513
  passed: z.ZodBoolean;
@@ -639,12 +663,37 @@ export declare const agentProfileImprovementMeasuredComparisonSchema: z.ZodObjec
639
663
  diff: z.ZodString;
640
664
  evaluation: z.ZodObject<{
641
665
  generationsExplored: z.ZodNumber;
642
- searchDurationMs: z.ZodNumber;
643
- executionDurationMs: z.ZodNumber;
644
- durationMs: z.ZodNumber;
645
- searchCostUsd: z.ZodNumber;
646
- executionCostUsd: z.ZodNumber;
647
- totalCostUsd: z.ZodNumber;
666
+ preparation: z.ZodObject<{
667
+ wallDurationMs: z.ZodNumber;
668
+ cost: z.ZodObject<{
669
+ usd: z.ZodNumber;
670
+ provenance: z.ZodEnum<{
671
+ observed: "observed";
672
+ estimated: "estimated";
673
+ }>;
674
+ }, z.core.$strict>;
675
+ }, z.core.$strict>;
676
+ measurement: z.ZodObject<{
677
+ wallDurationMs: z.ZodNumber;
678
+ workDurationMs: z.ZodNumber;
679
+ cost: z.ZodObject<{
680
+ usd: z.ZodNumber;
681
+ provenance: z.ZodEnum<{
682
+ observed: "observed";
683
+ estimated: "estimated";
684
+ }>;
685
+ }, z.core.$strict>;
686
+ }, z.core.$strict>;
687
+ total: z.ZodObject<{
688
+ wallDurationMs: z.ZodNumber;
689
+ cost: z.ZodObject<{
690
+ usd: z.ZodNumber;
691
+ provenance: z.ZodEnum<{
692
+ observed: "observed";
693
+ estimated: "estimated";
694
+ }>;
695
+ }, z.core.$strict>;
696
+ }, z.core.$strict>;
648
697
  }, z.core.$strict>;
649
698
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodCustom<import("./agent-candidate.js").AgentCandidateJsonValue, import("./agent-candidate.js").AgentCandidateJsonValue>>>;
650
699
  kind: z.ZodLiteral<"agent-profile-improvement-measured-comparison">;
@@ -657,6 +706,11 @@ export declare const agentProfileImprovementMeasuredComparisonSchema: z.ZodObjec
657
706
  sourceDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
658
707
  sourceRevision: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
659
708
  }, z.core.$strict>;
709
+ executionRef: z.ZodObject<{
710
+ identity: z.ZodString;
711
+ digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
712
+ kind: z.ZodLiteral<"agent-profile-improvement-execution-ref">;
713
+ }, z.core.$strict>;
660
714
  baseline: z.ZodObject<{
661
715
  stateDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
662
716
  }, z.core.$strict>;
@@ -808,6 +862,11 @@ export declare const agentProfileImprovementMeasuredComparisonSchema: z.ZodObjec
808
862
  kind: z.ZodLiteral<"agent-profile-improvement-run">;
809
863
  digestAlgorithm: z.ZodLiteral<"rfc8785-sha256">;
810
864
  executionId: z.ZodString;
865
+ executionRef: z.ZodObject<{
866
+ identity: z.ZodString;
867
+ digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
868
+ kind: z.ZodLiteral<"agent-profile-improvement-execution-ref">;
869
+ }, z.core.$strict>;
811
870
  runCell: z.ZodObject<{
812
871
  kind: z.ZodLiteral<"agent-profile-improvement-run-cell">;
813
872
  experimentDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
@@ -843,6 +902,7 @@ export declare const agentProfileImprovementMeasuredComparisonSchema: z.ZodObjec
843
902
  endedAtMs: z.ZodNumber;
844
903
  durationMs: z.ZodNumber;
845
904
  }, z.core.$strict>;
905
+ steps: z.ZodNumber;
846
906
  resolvedModel: z.ZodObject<{
847
907
  requested: z.ZodString;
848
908
  provider: z.ZodString;
@@ -873,6 +933,10 @@ export declare const agentProfileImprovementMeasuredComparisonSchema: z.ZodObjec
873
933
  reasoningTokens: z.ZodNumber;
874
934
  modelCalls: z.ZodNumber;
875
935
  costUsdNanos: z.ZodNumber;
936
+ costProvenance: z.ZodEnum<{
937
+ observed: "observed";
938
+ estimated: "estimated";
939
+ }>;
876
940
  }, z.core.$strict>;
877
941
  trace: z.ZodObject<{
878
942
  evidence: z.ZodObject<{
@@ -932,6 +996,10 @@ export declare const agentProfileImprovementMeasuredComparisonSchema: z.ZodObjec
932
996
  reasoningTokens: z.ZodNumber;
933
997
  modelCalls: z.ZodNumber;
934
998
  costUsdNanos: z.ZodNumber;
999
+ costProvenance: z.ZodEnum<{
1000
+ observed: "observed";
1001
+ estimated: "estimated";
1002
+ }>;
935
1003
  }, z.core.$strict>;
936
1004
  score: z.ZodNumber;
937
1005
  passed: z.ZodBoolean;
@@ -946,6 +1014,11 @@ export declare const agentProfileImprovementMeasuredComparisonSchema: z.ZodObjec
946
1014
  kind: z.ZodLiteral<"agent-profile-improvement-run">;
947
1015
  digestAlgorithm: z.ZodLiteral<"rfc8785-sha256">;
948
1016
  executionId: z.ZodString;
1017
+ executionRef: z.ZodObject<{
1018
+ identity: z.ZodString;
1019
+ digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
1020
+ kind: z.ZodLiteral<"agent-profile-improvement-execution-ref">;
1021
+ }, z.core.$strict>;
949
1022
  runCell: z.ZodObject<{
950
1023
  kind: z.ZodLiteral<"agent-profile-improvement-run-cell">;
951
1024
  experimentDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
@@ -981,6 +1054,7 @@ export declare const agentProfileImprovementMeasuredComparisonSchema: z.ZodObjec
981
1054
  endedAtMs: z.ZodNumber;
982
1055
  durationMs: z.ZodNumber;
983
1056
  }, z.core.$strict>;
1057
+ steps: z.ZodNumber;
984
1058
  resolvedModel: z.ZodObject<{
985
1059
  requested: z.ZodString;
986
1060
  provider: z.ZodString;
@@ -1011,6 +1085,10 @@ export declare const agentProfileImprovementMeasuredComparisonSchema: z.ZodObjec
1011
1085
  reasoningTokens: z.ZodNumber;
1012
1086
  modelCalls: z.ZodNumber;
1013
1087
  costUsdNanos: z.ZodNumber;
1088
+ costProvenance: z.ZodEnum<{
1089
+ observed: "observed";
1090
+ estimated: "estimated";
1091
+ }>;
1014
1092
  }, z.core.$strict>;
1015
1093
  trace: z.ZodObject<{
1016
1094
  evidence: z.ZodObject<{
@@ -1070,6 +1148,10 @@ export declare const agentProfileImprovementMeasuredComparisonSchema: z.ZodObjec
1070
1148
  reasoningTokens: z.ZodNumber;
1071
1149
  modelCalls: z.ZodNumber;
1072
1150
  costUsdNanos: z.ZodNumber;
1151
+ costProvenance: z.ZodEnum<{
1152
+ observed: "observed";
1153
+ estimated: "estimated";
1154
+ }>;
1073
1155
  }, z.core.$strict>;
1074
1156
  score: z.ZodNumber;
1075
1157
  passed: z.ZodBoolean;
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { agentCandidateLineageSchema } from "./agent-candidate-lineage-schema.js";
3
3
  import { canonicalCandidateDigest, isCanonicalJsonValue, omitTopLevelDigest, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
4
+ import { refineAgentExecutionWithinLimits } from "./agent-execution-limits.js";
4
5
  import { agentCandidateBenchmarkGraderIdentitySchema, agentCandidateExecutionLimitsSchema, agentCandidateResolvedModelSchema, } from "./agent-candidate-execution-plan-schema.js";
5
6
  import { agentCandidateBenchmarkDimensionSchema, agentCandidateFixedSpendSchema, } from "./agent-candidate-outcome-schema.js";
6
7
  import { agentCandidateEvaluationPolicySchema, createMeasuredComparisonIdentityRegistry, measuredComparisonCommonShape, refineMeasuredComparisonSummary, } from "./agent-improvement-measurement-schema.js";
@@ -97,6 +98,11 @@ export const agentProfileImprovementArmSchema = z
97
98
  stateDigest: sha256DigestSchema,
98
99
  })
99
100
  .strict();
101
+ export const agentProfileImprovementExecutionRefSchema = profileImprovementEvidenceSchema
102
+ .extend({
103
+ kind: z.literal("agent-profile-improvement-execution-ref"),
104
+ })
105
+ .strict();
100
106
  /**
101
107
  * The first product path changes only prompt and skills, but it uses the
102
108
  * shared profile-diff language so execution and activation apply identical
@@ -175,6 +181,7 @@ export const agentProfileImprovementExperimentSchema = z
175
181
  kind: z.literal("agent-profile-improvement-experiment"),
176
182
  digestAlgorithm: z.literal("rfc8785-sha256"),
177
183
  source: agentImprovementSourceSchema,
184
+ executionRef: agentProfileImprovementExecutionRefSchema,
178
185
  baseline: agentProfileImprovementArmSchema,
179
186
  candidate: agentProfileImprovementArmSchema,
180
187
  change: agentProfileImprovementChangeSchema,
@@ -304,12 +311,14 @@ export const agentProfileImprovementRunReceiptSchema = z
304
311
  kind: z.literal("agent-profile-improvement-run"),
305
312
  digestAlgorithm: z.literal("rfc8785-sha256"),
306
313
  executionId: z.string().min(1).max(500),
314
+ executionRef: agentProfileImprovementExecutionRefSchema,
307
315
  runCell: agentProfileImprovementRunCellSchema,
308
316
  runRecord: profileImprovementEvidenceSchema,
309
317
  billing: z
310
318
  .tuple([profileImprovementEvidenceSchema])
311
319
  .rest(profileImprovementEvidenceSchema),
312
320
  timing: timingSchema,
321
+ steps: z.number().int().nonnegative().safe(),
313
322
  resolvedModel: agentCandidateResolvedModelSchema,
314
323
  limits: agentCandidateExecutionLimitsSchema,
315
324
  usage: agentCandidateFixedSpendSchema,
@@ -357,6 +366,11 @@ export const agentProfileImprovementRunReceiptSchema = z
357
366
  message: "profile trace must retain at least one event for every model call",
358
367
  });
359
368
  }
369
+ refineAgentExecutionWithinLimits(receipt.limits, {
370
+ durationMs: receipt.timing.durationMs,
371
+ steps: receipt.steps,
372
+ usage: combinedProfileUsage(receipt.usage, receipt.grading.usage),
373
+ }, ctx);
360
374
  const billing = receipt.billing.map(evidenceKey);
361
375
  if (new Set(billing).size !== billing.length) {
362
376
  ctx.addIssue({
@@ -373,6 +387,19 @@ export const agentProfileImprovementRunReceiptSchema = z
373
387
  });
374
388
  }
375
389
  });
390
+ function combinedProfileUsage(execution, grading) {
391
+ return {
392
+ inputTokens: execution.inputTokens + grading.inputTokens,
393
+ outputTokens: execution.outputTokens + grading.outputTokens,
394
+ cachedInputTokens: execution.cachedInputTokens + grading.cachedInputTokens,
395
+ reasoningTokens: execution.reasoningTokens + grading.reasoningTokens,
396
+ modelCalls: execution.modelCalls + grading.modelCalls,
397
+ costUsdNanos: execution.costUsdNanos + grading.costUsdNanos,
398
+ costProvenance: execution.costProvenance === "observed" && grading.costProvenance === "observed"
399
+ ? "observed"
400
+ : "estimated",
401
+ };
402
+ }
376
403
  const agentProfileImprovementMeasurementSchema = z
377
404
  .object({
378
405
  baseline: agentProfileImprovementRunReceiptSchema,
@@ -448,6 +475,11 @@ function refineProfileImprovementComparison(comparison, ctx) {
448
475
  [...armPath, "runCell", "experimentDigest"],
449
476
  "profile run receipt must bind the measured experiment",
450
477
  ],
478
+ [
479
+ JSON.stringify(receipt.executionRef) === JSON.stringify(comparison.experiment.executionRef),
480
+ [...armPath, "executionRef"],
481
+ "profile run receipt must bind the measured executor",
482
+ ],
451
483
  [
452
484
  cell.arm === arm,
453
485
  [...armPath, "runCell", "arm"],
@@ -530,6 +562,7 @@ function refineProfileImprovementComparison(comparison, ctx) {
530
562
  score: (receipt) => receipt.grading.score,
531
563
  dimension: (receipt, name) => receipt.grading.dimensions.find((dimension) => dimension.name === name)?.score,
532
564
  cost: profileImprovementExecutionCostUsd,
565
+ costProvenance: profileImprovementExecutionCostProvenance,
533
566
  latency: profileImprovementExecutionLatencyMs,
534
567
  }, ctx);
535
568
  if (!isCanonicalJsonValue(comparison)) {
@@ -548,6 +581,12 @@ function evidenceKey(evidence) {
548
581
  function profileImprovementExecutionCostUsd(receipt) {
549
582
  return (receipt.usage.costUsdNanos + receipt.grading.usage.costUsdNanos) / 1_000_000_000;
550
583
  }
584
+ function profileImprovementExecutionCostProvenance(receipt) {
585
+ return receipt.usage.costProvenance === "observed" &&
586
+ receipt.grading.usage.costProvenance === "observed"
587
+ ? "observed"
588
+ : "estimated";
589
+ }
551
590
  function profileImprovementExecutionLatencyMs(receipt) {
552
591
  return receipt.timing.durationMs + receipt.grading.timing.durationMs;
553
592
  }
@@ -44,6 +44,10 @@ export interface AgentProfileImprovementSuiteInputs {
44
44
  export interface AgentProfileImprovementArm {
45
45
  stateDigest: Sha256Digest;
46
46
  }
47
+ /** Exact non-secret identity of the runner that measured and can activate a profile change. */
48
+ export interface AgentProfileImprovementExecutionRef extends AgentProfileImprovementEvidence {
49
+ kind: "agent-profile-improvement-execution-ref";
50
+ }
47
51
  /**
48
52
  * Ordered portable profile patches retained for review and activation.
49
53
  *
@@ -58,6 +62,7 @@ export interface AgentProfileImprovementExperimentMaterial {
58
62
  kind: "agent-profile-improvement-experiment";
59
63
  digestAlgorithm: AgentCandidateDigestAlgorithm;
60
64
  source: AgentImprovementSource;
65
+ executionRef: AgentProfileImprovementExecutionRef;
61
66
  baseline: AgentProfileImprovementArm;
62
67
  candidate: AgentProfileImprovementArm;
63
68
  change: AgentProfileImprovementChange;
@@ -89,6 +94,7 @@ export interface AgentProfileImprovementRunReceipt {
89
94
  kind: "agent-profile-improvement-run";
90
95
  digestAlgorithm: AgentCandidateDigestAlgorithm;
91
96
  executionId: string;
97
+ executionRef: AgentProfileImprovementExecutionRef;
92
98
  runCell: AgentProfileImprovementRunCell;
93
99
  runRecord: AgentProfileImprovementEvidence;
94
100
  billing: [AgentProfileImprovementEvidence, ...AgentProfileImprovementEvidence[]];
@@ -97,6 +103,7 @@ export interface AgentProfileImprovementRunReceipt {
97
103
  endedAtMs: number;
98
104
  durationMs: number;
99
105
  };
106
+ steps: number;
100
107
  resolvedModel: AgentCandidateResolvedModel;
101
108
  limits: AgentCandidateExecutionLimits;
102
109
  usage: AgentCandidateFixedSpend;
package/dist/index.d.ts CHANGED
@@ -613,11 +613,15 @@ export interface SdkProviderAdapter {
613
613
  export * from "./interaction.js";
614
614
  export * from "./agent-candidate.js";
615
615
  export * from "./agent-candidate-schema.js";
616
+ export type { Sha256Digest } from "./agent-candidate.js";
617
+ export { canonicalCandidateBytes, canonicalCandidateDigest, canonicalCandidateJson, sha256Bytes, sha256DigestSchema, sha256Utf8, } from "./agent-candidate-schema-common.js";
618
+ export { numbersApproximatelyEqual } from "./number-validation.js";
616
619
  export * from "./agent-candidate-promotion-schema.js";
617
620
  export { agentCandidateEvaluationPolicySchema } from "./agent-improvement-measurement-schema.js";
618
621
  export * from "./agent-improvement-source.js";
619
622
  export * from "./agent-profile-improvement.js";
620
623
  export * from "./agent-profile-improvement-schema.js";
624
+ export * from "./agent-execution-limits.js";
621
625
  export * from "./agent-profile.js";
622
626
  export * from "./certified-context.js";
623
627
  export * from "./profile-diff.js";
package/dist/index.js CHANGED
@@ -126,11 +126,14 @@ export function resolveNativeWebTools(tools) {
126
126
  export * from "./interaction.js";
127
127
  export * from "./agent-candidate.js";
128
128
  export * from "./agent-candidate-schema.js";
129
+ export { canonicalCandidateBytes, canonicalCandidateDigest, canonicalCandidateJson, sha256Bytes, sha256DigestSchema, sha256Utf8, } from "./agent-candidate-schema-common.js";
130
+ export { numbersApproximatelyEqual } from "./number-validation.js";
129
131
  export * from "./agent-candidate-promotion-schema.js";
130
132
  export { agentCandidateEvaluationPolicySchema } from "./agent-improvement-measurement-schema.js";
131
133
  export * from "./agent-improvement-source.js";
132
134
  export * from "./agent-profile-improvement.js";
133
135
  export * from "./agent-profile-improvement-schema.js";
136
+ export * from "./agent-execution-limits.js";
134
137
  export * from "./agent-profile.js";
135
138
  export * from "./certified-context.js";
136
139
  export * from "./profile-diff.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-interface",
3
- "version": "0.34.0",
3
+ "version": "0.36.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",