@tangle-network/agent-interface 2.4.0 → 2.6.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.
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import type { AgentCandidateLineage } from "./agent-candidate.js";
2
3
  export declare const agentCandidateKnowledgeSchema: z.ZodObject<{
3
4
  candidate: z.ZodObject<{
4
5
  kind: z.ZodLiteral<"knowledge-improvement-candidate">;
@@ -10,6 +11,10 @@ export declare const agentCandidateKnowledgeSchema: z.ZodObject<{
10
11
  evidenceHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
11
12
  promotionPlanHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
12
13
  }, z.core.$strict>;
14
+ stateScope: z.ZodOptional<z.ZodObject<{
15
+ pagesDirectory: z.ZodString;
16
+ researchState: z.ZodBoolean;
17
+ }, z.core.$strict>>;
13
18
  snapshot: z.ZodObject<{
14
19
  kind: z.ZodLiteral<"agent-candidate-workspace-snapshot">;
15
20
  digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
@@ -120,9 +125,19 @@ export declare const agentCandidateMemoryPolicySchema: z.ZodDiscriminatedUnion<[
120
125
  byteLength: z.ZodNumber;
121
126
  }, z.core.$strict>>;
122
127
  }, z.core.$strict>], "mode">;
128
+ /**
129
+ * Sources whose candidate was PRODUCED from a parent rather than supplied whole.
130
+ *
131
+ * One list, read by the lineage schema and by every experiment schema that gates on it. Three
132
+ * call sites branched on `optimizer || compound` independently, so adding a fourth generated
133
+ * source silently exempted it from the "name your baseline" rule in two of them.
134
+ */
135
+ export declare const generatedCandidateSources: readonly ["optimizer", "compound", "frontier-author"];
136
+ export declare function isGeneratedCandidateSource(source: AgentCandidateLineage["source"]): boolean;
123
137
  export declare const agentCandidateLineageSchema: z.ZodObject<{
124
138
  source: z.ZodEnum<{
125
139
  compound: "compound";
140
+ "frontier-author": "frontier-author";
126
141
  human: "human";
127
142
  import: "import";
128
143
  optimizer: "optimizer";
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { agentCandidateArtifactRefSchema, agentCandidateCapturedArtifactSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, } from "./agent-candidate-artifact-schema.js";
3
- import { addDuplicateIssues, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
3
+ import { addDuplicateIssues, isSafeRelativePath, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
4
4
  export const agentCandidateKnowledgeSchema = z
5
5
  .object({
6
6
  candidate: z
@@ -15,6 +15,15 @@ export const agentCandidateKnowledgeSchema = z
15
15
  promotionPlanHash: sha256DigestSchema,
16
16
  })
17
17
  .strict(),
18
+ stateScope: z
19
+ .object({
20
+ pagesDirectory: z
21
+ .string()
22
+ .refine((value) => isSafeRelativePath(value, false), "pagesDirectory must be a canonical workspace-relative directory"),
23
+ researchState: z.boolean(),
24
+ })
25
+ .strict()
26
+ .optional(),
18
27
  snapshot: agentCandidateWorkspaceSnapshotEvidenceSchema,
19
28
  retrievalConfig: agentCandidateCapturedArtifactSchema.optional(),
20
29
  evaluation: agentCandidateCapturedArtifactSchema,
@@ -30,9 +39,30 @@ export const agentCandidateMemoryPolicySchema = z.discriminatedUnion("mode", [
30
39
  })
31
40
  .strict(),
32
41
  ]);
42
+ /**
43
+ * Sources whose candidate was PRODUCED from a parent rather than supplied whole.
44
+ *
45
+ * One list, read by the lineage schema and by every experiment schema that gates on it. Three
46
+ * call sites branched on `optimizer || compound` independently, so adding a fourth generated
47
+ * source silently exempted it from the "name your baseline" rule in two of them.
48
+ */
49
+ export const generatedCandidateSources = [
50
+ "optimizer",
51
+ "compound",
52
+ "frontier-author",
53
+ ];
54
+ export function isGeneratedCandidateSource(source) {
55
+ return generatedCandidateSources.includes(source);
56
+ }
33
57
  export const agentCandidateLineageSchema = z
34
58
  .object({
35
- source: z.enum(["optimizer", "human", "import", "compound"]),
59
+ source: z.enum([
60
+ "optimizer",
61
+ "human",
62
+ "import",
63
+ "compound",
64
+ "frontier-author",
65
+ ]),
36
66
  parentDigests: z.array(sha256DigestSchema).optional(),
37
67
  runIds: z.array(z.string().min(1)).optional(),
38
68
  profileDiffIds: z.array(z.string().min(1)).optional(),
@@ -53,7 +83,9 @@ export const agentCandidateLineageSchema = z
53
83
  message: "compound candidates must name at least two distinct parents",
54
84
  });
55
85
  }
56
- if (lineage.source === "optimizer" || lineage.source === "compound") {
86
+ // Every generated lineage names what it came from and the run that produced
87
+ // it, whoever generated it.
88
+ if (isGeneratedCandidateSource(lineage.source)) {
57
89
  if ((lineage.parentDigests?.length ?? 0) === 0) {
58
90
  ctx.addIssue({
59
91
  code: "custom",
@@ -68,6 +100,13 @@ export const agentCandidateLineageSchema = z
68
100
  message: "generated candidates must name their producing run",
69
101
  });
70
102
  }
103
+ }
104
+ // A development split exists only when an offline search produced the
105
+ // candidate. An agent that authors a profile inside a run has no held-out
106
+ // set to pin, so requiring one would force a fabricated digest into the
107
+ // evidence record. This branch is deliberately NOT the generated-source
108
+ // list above.
109
+ if (lineage.source === "optimizer" || lineage.source === "compound") {
71
110
  if (lineage.developmentSplitDigest === undefined) {
72
111
  ctx.addIssue({
73
112
  code: "custom",
@@ -724,6 +724,10 @@ export declare const agentCandidateExperimentSchema: z.ZodObject<{
724
724
  evidenceHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
725
725
  promotionPlanHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
726
726
  }, z.core.$strict>;
727
+ stateScope: z.ZodOptional<z.ZodObject<{
728
+ pagesDirectory: z.ZodString;
729
+ researchState: z.ZodBoolean;
730
+ }, z.core.$strict>>;
727
731
  snapshot: z.ZodObject<{
728
732
  kind: z.ZodLiteral<"agent-candidate-workspace-snapshot">;
729
733
  digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
@@ -1557,6 +1561,10 @@ export declare const agentCandidateExperimentSchema: z.ZodObject<{
1557
1561
  evidenceHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
1558
1562
  promotionPlanHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
1559
1563
  }, z.core.$strict>;
1564
+ stateScope: z.ZodOptional<z.ZodObject<{
1565
+ pagesDirectory: z.ZodString;
1566
+ researchState: z.ZodBoolean;
1567
+ }, z.core.$strict>>;
1560
1568
  snapshot: z.ZodObject<{
1561
1569
  kind: z.ZodLiteral<"agent-candidate-workspace-snapshot">;
1562
1570
  digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
@@ -1672,6 +1680,7 @@ export declare const agentCandidateExperimentSchema: z.ZodObject<{
1672
1680
  candidateLineage: z.ZodObject<{
1673
1681
  source: z.ZodEnum<{
1674
1682
  compound: "compound";
1683
+ "frontier-author": "frontier-author";
1675
1684
  human: "human";
1676
1685
  import: "import";
1677
1686
  optimizer: "optimizer";
@@ -4313,6 +4322,10 @@ export declare const agentImprovementMeasuredComparisonSchema: z.ZodObject<{
4313
4322
  evidenceHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
4314
4323
  promotionPlanHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
4315
4324
  }, z.core.$strict>;
4325
+ stateScope: z.ZodOptional<z.ZodObject<{
4326
+ pagesDirectory: z.ZodString;
4327
+ researchState: z.ZodBoolean;
4328
+ }, z.core.$strict>>;
4316
4329
  snapshot: z.ZodObject<{
4317
4330
  kind: z.ZodLiteral<"agent-candidate-workspace-snapshot">;
4318
4331
  digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
@@ -5146,6 +5159,10 @@ export declare const agentImprovementMeasuredComparisonSchema: z.ZodObject<{
5146
5159
  evidenceHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
5147
5160
  promotionPlanHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
5148
5161
  }, z.core.$strict>;
5162
+ stateScope: z.ZodOptional<z.ZodObject<{
5163
+ pagesDirectory: z.ZodString;
5164
+ researchState: z.ZodBoolean;
5165
+ }, z.core.$strict>>;
5149
5166
  snapshot: z.ZodObject<{
5150
5167
  kind: z.ZodLiteral<"agent-candidate-workspace-snapshot">;
5151
5168
  digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
@@ -5261,6 +5278,7 @@ export declare const agentImprovementMeasuredComparisonSchema: z.ZodObject<{
5261
5278
  candidateLineage: z.ZodObject<{
5262
5279
  source: z.ZodEnum<{
5263
5280
  compound: "compound";
5281
+ "frontier-author": "frontier-author";
5264
5282
  human: "human";
5265
5283
  import: "import";
5266
5284
  optimizer: "optimizer";
@@ -9332,6 +9350,10 @@ export declare const agentImprovementProposalSchema: z.ZodObject<{
9332
9350
  evidenceHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
9333
9351
  promotionPlanHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
9334
9352
  }, z.core.$strict>;
9353
+ stateScope: z.ZodOptional<z.ZodObject<{
9354
+ pagesDirectory: z.ZodString;
9355
+ researchState: z.ZodBoolean;
9356
+ }, z.core.$strict>>;
9335
9357
  snapshot: z.ZodObject<{
9336
9358
  kind: z.ZodLiteral<"agent-candidate-workspace-snapshot">;
9337
9359
  digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
@@ -10165,6 +10187,10 @@ export declare const agentImprovementProposalSchema: z.ZodObject<{
10165
10187
  evidenceHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
10166
10188
  promotionPlanHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
10167
10189
  }, z.core.$strict>;
10190
+ stateScope: z.ZodOptional<z.ZodObject<{
10191
+ pagesDirectory: z.ZodString;
10192
+ researchState: z.ZodBoolean;
10193
+ }, z.core.$strict>>;
10168
10194
  snapshot: z.ZodObject<{
10169
10195
  kind: z.ZodLiteral<"agent-candidate-workspace-snapshot">;
10170
10196
  digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
@@ -10280,6 +10306,7 @@ export declare const agentImprovementProposalSchema: z.ZodObject<{
10280
10306
  candidateLineage: z.ZodObject<{
10281
10307
  source: z.ZodEnum<{
10282
10308
  compound: "compound";
10309
+ "frontier-author": "frontier-author";
10283
10310
  human: "human";
10284
10311
  import: "import";
10285
10312
  optimizer: "optimizer";
@@ -13642,6 +13669,7 @@ export declare const agentImprovementProposalSchema: z.ZodObject<{
13642
13669
  candidateLineage: z.ZodObject<{
13643
13670
  source: z.ZodEnum<{
13644
13671
  compound: "compound";
13672
+ "frontier-author": "frontier-author";
13645
13673
  human: "human";
13646
13674
  import: "import";
13647
13675
  optimizer: "optimizer";
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { AGENT_IMPROVEMENT_SURFACES } from "./agent-candidate.js";
3
3
  import { agentCandidateBundleSchema } from "./agent-candidate-schema.js";
4
- import { agentCandidateLineageSchema } from "./agent-candidate-lineage-schema.js";
4
+ import { agentCandidateLineageSchema, isGeneratedCandidateSource, } from "./agent-candidate-lineage-schema.js";
5
5
  import { agentCandidateBenchmarkSuiteInputsSchema } from "./agent-candidate-task-schema.js";
6
6
  import { canonicalCandidateDigest, isCanonicalJsonValue, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
7
7
  import { refineAgentExecutionWithinLimits } from "./agent-execution-limits.js";
@@ -23,7 +23,7 @@ export const agentCandidateExperimentSchema = z
23
23
  .strict()
24
24
  .superRefine((experiment, ctx) => {
25
25
  const source = experiment.candidateLineage.source;
26
- if ((source === "optimizer" || source === "compound") &&
26
+ if (isGeneratedCandidateSource(source) &&
27
27
  !experiment.candidateLineage.parentDigests?.includes(experiment.baseline.digest)) {
28
28
  ctx.addIssue({
29
29
  code: "custom",
@@ -728,6 +728,10 @@ export declare const agentCandidateBundleSchema: z.ZodObject<{
728
728
  evidenceHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
729
729
  promotionPlanHash: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
730
730
  }, z.core.$strict>;
731
+ stateScope: z.ZodOptional<z.ZodObject<{
732
+ pagesDirectory: z.ZodString;
733
+ researchState: z.ZodBoolean;
734
+ }, z.core.$strict>>;
731
735
  snapshot: z.ZodObject<{
732
736
  kind: z.ZodLiteral<"agent-candidate-workspace-snapshot">;
733
737
  digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
@@ -227,8 +227,15 @@ export interface AgentCandidateKnowledgeRef {
227
227
  evidenceHash: Sha256Digest;
228
228
  promotionPlanHash: Sha256Digest;
229
229
  }
230
+ /** Canonical selection of knowledge state included in the candidate hash. */
231
+ export interface AgentCandidateKnowledgeStateScope {
232
+ pagesDirectory: string;
233
+ researchState: boolean;
234
+ }
230
235
  export interface AgentCandidateKnowledge {
231
236
  candidate: AgentCandidateKnowledgeRef;
237
+ /** Absent scopes retain the knowledge provider's default selection. */
238
+ stateScope?: AgentCandidateKnowledgeStateScope;
232
239
  snapshot: AgentCandidateWorkspaceSnapshotEvidence;
233
240
  retrievalConfig?: AgentCandidateCapturedArtifact;
234
241
  evaluation: AgentCandidateCapturedArtifact;
@@ -281,7 +288,20 @@ export interface AgentCandidateFixedSpend {
281
288
  }
282
289
  /** Evidence and ancestry that produced the immutable candidate. */
283
290
  export interface AgentCandidateLineage {
284
- source: "optimizer" | "human" | "import" | "compound";
291
+ /**
292
+ * Who produced this candidate.
293
+ *
294
+ * `frontier-author` is an agent that wrote another agent's profile — the same
295
+ * member {@link AgentProfileDiff}`.source.kind` already carries, so the two
296
+ * enums name one actor with one word. It covers a supervising agent authoring
297
+ * a child's full `AgentProfile` from inside a run, which `spawn_worker`
298
+ * exposes and a `driver` role promotes to a sub-supervisor.
299
+ *
300
+ * It carries `optimizer`'s parent and run requirements and not its
301
+ * `developmentSplitDigest`: there is no held-out split and no offline search
302
+ * behind a profile an agent wrote while working.
303
+ */
304
+ source: "optimizer" | "human" | "import" | "compound" | "frontier-author";
285
305
  parentDigests?: Sha256Digest[];
286
306
  runIds?: string[];
287
307
  profileDiffIds?: string[];
@@ -236,6 +236,7 @@ export declare const agentProfileImprovementExperimentSchema: z.ZodObject<{
236
236
  candidateLineage: z.ZodObject<{
237
237
  source: z.ZodEnum<{
238
238
  compound: "compound";
239
+ "frontier-author": "frontier-author";
239
240
  human: "human";
240
241
  import: "import";
241
242
  optimizer: "optimizer";
@@ -768,6 +769,7 @@ export declare const agentProfileImprovementMeasuredComparisonSchema: z.ZodObjec
768
769
  candidateLineage: z.ZodObject<{
769
770
  source: z.ZodEnum<{
770
771
  compound: "compound";
772
+ "frontier-author": "frontier-author";
771
773
  human: "human";
772
774
  import: "import";
773
775
  optimizer: "optimizer";
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { changedAgentProfileAxes } from "./profile-diff.js";
3
- import { agentCandidateLineageSchema } from "./agent-candidate-lineage-schema.js";
3
+ import { agentCandidateLineageSchema, isGeneratedCandidateSource, } from "./agent-candidate-lineage-schema.js";
4
4
  import { canonicalCandidateDigest, isCanonicalJsonValue, omitTopLevelDigest, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
5
5
  import { refineAgentExecutionWithinLimits } from "./agent-execution-limits.js";
6
6
  import { agentCandidateBenchmarkGraderIdentitySchema, agentCandidateExecutionLimitsSchema, agentCandidateResolvedModelSchema, } from "./agent-candidate-execution-plan-schema.js";
@@ -189,7 +189,7 @@ export const agentProfileImprovementExperimentSchema = z
189
189
  });
190
190
  }
191
191
  const source = experiment.candidateLineage.source;
192
- if ((source === "optimizer" || source === "compound") &&
192
+ if (isGeneratedCandidateSource(source) &&
193
193
  !experiment.candidateLineage.parentDigests?.includes(experiment.baseline.stateDigest)) {
194
194
  ctx.addIssue({
195
195
  code: "custom",
@@ -49,6 +49,11 @@ export interface AgentProfileDiff {
49
49
  description?: string;
50
50
  rationale?: string;
51
51
  source?: {
52
+ /**
53
+ * Who produced this change. `frontier-author` is an agent that wrote it —
54
+ * the same member {@link AgentCandidateLineage}`.source` carries, so the two
55
+ * enums name one actor with one word.
56
+ */
52
57
  kind: "trace" | "frontier-author" | "human" | "optimizer" | "compound";
53
58
  artifacts?: readonly string[];
54
59
  notes?: readonly string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-interface",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",