@tangle-network/agent-interface 0.30.0 → 0.32.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/README.md +7 -0
- package/dist/agent-candidate-code-schema.js +10 -0
- package/dist/agent-candidate-execution-plan-schema.js +7 -0
- package/dist/agent-candidate-outcome-schema.d.ts +4 -4
- package/dist/agent-candidate-promotion-schema.d.ts +139 -10
- package/dist/agent-candidate-promotion-schema.js +116 -16
- package/dist/agent-candidate-receipt-schema.d.ts +2 -2
- package/dist/agent-candidate.d.ts +47 -0
- package/dist/agent-candidate.test-fixture.d.ts +4 -0
- package/dist/agent-candidate.test-fixture.js +1 -0
- package/dist/environment-provider.d.ts +128 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,13 @@ const provider: AgentEnvironmentProvider = {
|
|
|
62
62
|
};
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
## Exact process environments
|
|
66
|
+
|
|
67
|
+
Providers may expose the optional `exactProcess` capability for isolated, reproducible process execution.
|
|
68
|
+
It is separate from agent-backed `create()` because it guarantees a fresh environment, immutable image identity, explicit resources, bounded exact-byte file reads, shell-free argv, replacement process environment, recoverable output and terminal reason, bounded network access, and collision-safe idempotent recovery without starting a provider-managed agent.
|
|
69
|
+
Higher-level runtimes can use this primitive for measured candidates without making candidate lifecycle part of the provider contract.
|
|
70
|
+
Providers must omit the capability unless every property is enforced on their real execution path.
|
|
71
|
+
|
|
65
72
|
## Frozen improvement candidates
|
|
66
73
|
|
|
67
74
|
`AgentCandidateBundle` is the portable output of an improvement run: a recursively strict profile, an explicit disabled/no-op/changed code result, a shell-free launch, optional knowledge, isolated memory, ancestry, and spend.
|
|
@@ -174,6 +174,16 @@ export const agentCandidateExecutionSchema = z
|
|
|
174
174
|
})
|
|
175
175
|
.strict()
|
|
176
176
|
.superRefine((execution, ctx) => {
|
|
177
|
+
const requiresPath = execution.launch.kind === "container-command"
|
|
178
|
+
? !execution.launch.executable.startsWith("/")
|
|
179
|
+
: execution.launch.interpreter !== undefined;
|
|
180
|
+
if (requiresPath && !execution.env?.PATH?.value.trim()) {
|
|
181
|
+
ctx.addIssue({
|
|
182
|
+
code: "custom",
|
|
183
|
+
path: ["env", "PATH"],
|
|
184
|
+
message: "relative candidate executables require an explicit public PATH",
|
|
185
|
+
});
|
|
186
|
+
}
|
|
177
187
|
if (execution.env?.TANGLE_CANDIDATE_TASK_PATH !== undefined) {
|
|
178
188
|
ctx.addIssue({
|
|
179
189
|
code: "custom",
|
|
@@ -320,6 +320,13 @@ export const agentCandidateExecutionPlanMaterialSchema = z
|
|
|
320
320
|
})
|
|
321
321
|
.strict()
|
|
322
322
|
.superRefine((material, ctx) => {
|
|
323
|
+
if (!material.launch.executable.startsWith("/") && !material.launch.env.PATH?.value.trim()) {
|
|
324
|
+
ctx.addIssue({
|
|
325
|
+
code: "custom",
|
|
326
|
+
path: ["launch", "env", "PATH"],
|
|
327
|
+
message: "relative execution-plan executables require an explicit public PATH",
|
|
328
|
+
});
|
|
329
|
+
}
|
|
323
330
|
const routeIds = material.model.routes.map((route) => route.kind === "mode" || route.kind === "subagent"
|
|
324
331
|
? `${route.kind}:${route.name}`
|
|
325
332
|
: route.kind);
|
|
@@ -12,8 +12,8 @@ export declare const agentCandidateModelSettlementCallSchema: z.ZodObject<{
|
|
|
12
12
|
generationId: z.ZodString;
|
|
13
13
|
traceSpanId: z.ZodString;
|
|
14
14
|
status: z.ZodEnum<{
|
|
15
|
-
succeeded: "succeeded";
|
|
16
15
|
failed: "failed";
|
|
16
|
+
succeeded: "succeeded";
|
|
17
17
|
}>;
|
|
18
18
|
model: z.ZodString;
|
|
19
19
|
startedAtMs: z.ZodNumber;
|
|
@@ -30,8 +30,8 @@ export declare const agentCandidateModelSettlementMaterialSchema: z.ZodObject<{
|
|
|
30
30
|
generationId: z.ZodString;
|
|
31
31
|
traceSpanId: z.ZodString;
|
|
32
32
|
status: z.ZodEnum<{
|
|
33
|
-
succeeded: "succeeded";
|
|
34
33
|
failed: "failed";
|
|
34
|
+
succeeded: "succeeded";
|
|
35
35
|
}>;
|
|
36
36
|
model: z.ZodString;
|
|
37
37
|
startedAtMs: z.ZodNumber;
|
|
@@ -79,7 +79,7 @@ export declare const agentCandidateModelSettlementEvidenceSchema: z.ZodObject<{
|
|
|
79
79
|
callId: string;
|
|
80
80
|
generationId: string;
|
|
81
81
|
traceSpanId: string;
|
|
82
|
-
status: "
|
|
82
|
+
status: "failed" | "succeeded";
|
|
83
83
|
model: string;
|
|
84
84
|
startedAtMs: number;
|
|
85
85
|
endedAtMs: number;
|
|
@@ -114,7 +114,7 @@ export declare const agentCandidateModelSettlementEvidenceSchema: z.ZodObject<{
|
|
|
114
114
|
callId: string;
|
|
115
115
|
generationId: string;
|
|
116
116
|
traceSpanId: string;
|
|
117
|
-
status: "
|
|
117
|
+
status: "failed" | "succeeded";
|
|
118
118
|
model: string;
|
|
119
119
|
startedAtMs: number;
|
|
120
120
|
endedAtMs: number;
|
|
@@ -2266,7 +2266,7 @@ export declare const candidateExecutionEvidenceSchema: z.ZodObject<{
|
|
|
2266
2266
|
callId: string;
|
|
2267
2267
|
generationId: string;
|
|
2268
2268
|
traceSpanId: string;
|
|
2269
|
-
status: "
|
|
2269
|
+
status: "failed" | "succeeded";
|
|
2270
2270
|
model: string;
|
|
2271
2271
|
startedAtMs: number;
|
|
2272
2272
|
endedAtMs: number;
|
|
@@ -2301,7 +2301,7 @@ export declare const candidateExecutionEvidenceSchema: z.ZodObject<{
|
|
|
2301
2301
|
callId: string;
|
|
2302
2302
|
generationId: string;
|
|
2303
2303
|
traceSpanId: string;
|
|
2304
|
-
status: "
|
|
2304
|
+
status: "failed" | "succeeded";
|
|
2305
2305
|
model: string;
|
|
2306
2306
|
startedAtMs: number;
|
|
2307
2307
|
endedAtMs: number;
|
|
@@ -4991,7 +4991,7 @@ export declare const agentImprovementMeasuredComparisonSchema: z.ZodObject<{
|
|
|
4991
4991
|
callId: string;
|
|
4992
4992
|
generationId: string;
|
|
4993
4993
|
traceSpanId: string;
|
|
4994
|
-
status: "
|
|
4994
|
+
status: "failed" | "succeeded";
|
|
4995
4995
|
model: string;
|
|
4996
4996
|
startedAtMs: number;
|
|
4997
4997
|
endedAtMs: number;
|
|
@@ -5026,7 +5026,7 @@ export declare const agentImprovementMeasuredComparisonSchema: z.ZodObject<{
|
|
|
5026
5026
|
callId: string;
|
|
5027
5027
|
generationId: string;
|
|
5028
5028
|
traceSpanId: string;
|
|
5029
|
-
status: "
|
|
5029
|
+
status: "failed" | "succeeded";
|
|
5030
5030
|
model: string;
|
|
5031
5031
|
startedAtMs: number;
|
|
5032
5032
|
endedAtMs: number;
|
|
@@ -6342,7 +6342,7 @@ export declare const agentImprovementMeasuredComparisonSchema: z.ZodObject<{
|
|
|
6342
6342
|
callId: string;
|
|
6343
6343
|
generationId: string;
|
|
6344
6344
|
traceSpanId: string;
|
|
6345
|
-
status: "
|
|
6345
|
+
status: "failed" | "succeeded";
|
|
6346
6346
|
model: string;
|
|
6347
6347
|
startedAtMs: number;
|
|
6348
6348
|
endedAtMs: number;
|
|
@@ -6377,7 +6377,7 @@ export declare const agentImprovementMeasuredComparisonSchema: z.ZodObject<{
|
|
|
6377
6377
|
callId: string;
|
|
6378
6378
|
generationId: string;
|
|
6379
6379
|
traceSpanId: string;
|
|
6380
|
-
status: "
|
|
6380
|
+
status: "failed" | "succeeded";
|
|
6381
6381
|
model: string;
|
|
6382
6382
|
startedAtMs: number;
|
|
6383
6383
|
endedAtMs: number;
|
|
@@ -9249,7 +9249,7 @@ export declare const agentImprovementProposalSchema: z.ZodObject<{
|
|
|
9249
9249
|
callId: string;
|
|
9250
9250
|
generationId: string;
|
|
9251
9251
|
traceSpanId: string;
|
|
9252
|
-
status: "
|
|
9252
|
+
status: "failed" | "succeeded";
|
|
9253
9253
|
model: string;
|
|
9254
9254
|
startedAtMs: number;
|
|
9255
9255
|
endedAtMs: number;
|
|
@@ -9284,7 +9284,7 @@ export declare const agentImprovementProposalSchema: z.ZodObject<{
|
|
|
9284
9284
|
callId: string;
|
|
9285
9285
|
generationId: string;
|
|
9286
9286
|
traceSpanId: string;
|
|
9287
|
-
status: "
|
|
9287
|
+
status: "failed" | "succeeded";
|
|
9288
9288
|
model: string;
|
|
9289
9289
|
startedAtMs: number;
|
|
9290
9290
|
endedAtMs: number;
|
|
@@ -10600,7 +10600,7 @@ export declare const agentImprovementProposalSchema: z.ZodObject<{
|
|
|
10600
10600
|
callId: string;
|
|
10601
10601
|
generationId: string;
|
|
10602
10602
|
traceSpanId: string;
|
|
10603
|
-
status: "
|
|
10603
|
+
status: "failed" | "succeeded";
|
|
10604
10604
|
model: string;
|
|
10605
10605
|
startedAtMs: number;
|
|
10606
10606
|
endedAtMs: number;
|
|
@@ -10635,7 +10635,7 @@ export declare const agentImprovementProposalSchema: z.ZodObject<{
|
|
|
10635
10635
|
callId: string;
|
|
10636
10636
|
generationId: string;
|
|
10637
10637
|
traceSpanId: string;
|
|
10638
|
-
status: "
|
|
10638
|
+
status: "failed" | "succeeded";
|
|
10639
10639
|
model: string;
|
|
10640
10640
|
startedAtMs: number;
|
|
10641
10641
|
endedAtMs: number;
|
|
@@ -11242,6 +11242,10 @@ export declare const agentImprovementActivationSchema: z.ZodObject<{
|
|
|
11242
11242
|
reviewDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
11243
11243
|
experimentDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
11244
11244
|
candidateBundleDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
11245
|
+
intent: z.ZodEnum<{
|
|
11246
|
+
"activate-candidate": "activate-candidate";
|
|
11247
|
+
"restore-baseline": "restore-baseline";
|
|
11248
|
+
}>;
|
|
11245
11249
|
targets: z.ZodTuple<[z.ZodObject<{
|
|
11246
11250
|
surface: z.ZodEnum<{
|
|
11247
11251
|
prompt: "prompt";
|
|
@@ -11276,5 +11280,130 @@ export declare const agentImprovementActivationSchema: z.ZodObject<{
|
|
|
11276
11280
|
fundingOwner: z.ZodString;
|
|
11277
11281
|
authorizedBy: z.ZodString;
|
|
11278
11282
|
authorizedAt: z.ZodISODateTime;
|
|
11283
|
+
expiresAt: z.ZodISODateTime;
|
|
11284
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
11285
|
+
}, z.core.$strict>;
|
|
11286
|
+
export declare const agentImprovementActivationResultSchema: z.ZodObject<{
|
|
11287
|
+
kind: z.ZodLiteral<"agent-improvement-activation-result">;
|
|
11288
|
+
idempotencyKey: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
11289
|
+
attemptedAt: z.ZodISODateTime;
|
|
11290
|
+
completedAt: z.ZodISODateTime;
|
|
11291
|
+
outcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
11292
|
+
status: z.ZodLiteral<"applied">;
|
|
11293
|
+
transactionId: z.ZodString;
|
|
11294
|
+
targets: z.ZodTuple<[z.ZodObject<{
|
|
11295
|
+
surface: z.ZodEnum<{
|
|
11296
|
+
prompt: "prompt";
|
|
11297
|
+
tools: "tools";
|
|
11298
|
+
mcp: "mcp";
|
|
11299
|
+
subagents: "subagents";
|
|
11300
|
+
hooks: "hooks";
|
|
11301
|
+
skills: "skills";
|
|
11302
|
+
"agent-profile": "agent-profile";
|
|
11303
|
+
memory: "memory";
|
|
11304
|
+
code: "code";
|
|
11305
|
+
knowledge: "knowledge";
|
|
11306
|
+
}>;
|
|
11307
|
+
identity: z.ZodString;
|
|
11308
|
+
beforeDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
11309
|
+
afterDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
11310
|
+
}, z.core.$strict>], z.ZodObject<{
|
|
11311
|
+
surface: z.ZodEnum<{
|
|
11312
|
+
prompt: "prompt";
|
|
11313
|
+
tools: "tools";
|
|
11314
|
+
mcp: "mcp";
|
|
11315
|
+
subagents: "subagents";
|
|
11316
|
+
hooks: "hooks";
|
|
11317
|
+
skills: "skills";
|
|
11318
|
+
"agent-profile": "agent-profile";
|
|
11319
|
+
memory: "memory";
|
|
11320
|
+
code: "code";
|
|
11321
|
+
knowledge: "knowledge";
|
|
11322
|
+
}>;
|
|
11323
|
+
identity: z.ZodString;
|
|
11324
|
+
beforeDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
11325
|
+
afterDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
11326
|
+
}, z.core.$strict>>;
|
|
11327
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
11328
|
+
status: z.ZodLiteral<"already-applied">;
|
|
11329
|
+
targets: z.ZodTuple<[z.ZodObject<{
|
|
11330
|
+
surface: z.ZodEnum<{
|
|
11331
|
+
prompt: "prompt";
|
|
11332
|
+
tools: "tools";
|
|
11333
|
+
mcp: "mcp";
|
|
11334
|
+
subagents: "subagents";
|
|
11335
|
+
hooks: "hooks";
|
|
11336
|
+
skills: "skills";
|
|
11337
|
+
"agent-profile": "agent-profile";
|
|
11338
|
+
memory: "memory";
|
|
11339
|
+
code: "code";
|
|
11340
|
+
knowledge: "knowledge";
|
|
11341
|
+
}>;
|
|
11342
|
+
identity: z.ZodString;
|
|
11343
|
+
currentDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
11344
|
+
}, z.core.$strict>], z.ZodObject<{
|
|
11345
|
+
surface: z.ZodEnum<{
|
|
11346
|
+
prompt: "prompt";
|
|
11347
|
+
tools: "tools";
|
|
11348
|
+
mcp: "mcp";
|
|
11349
|
+
subagents: "subagents";
|
|
11350
|
+
hooks: "hooks";
|
|
11351
|
+
skills: "skills";
|
|
11352
|
+
"agent-profile": "agent-profile";
|
|
11353
|
+
memory: "memory";
|
|
11354
|
+
code: "code";
|
|
11355
|
+
knowledge: "knowledge";
|
|
11356
|
+
}>;
|
|
11357
|
+
identity: z.ZodString;
|
|
11358
|
+
currentDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
11359
|
+
}, z.core.$strict>>;
|
|
11360
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
11361
|
+
status: z.ZodLiteral<"conflict">;
|
|
11362
|
+
targets: z.ZodTuple<[z.ZodObject<{
|
|
11363
|
+
surface: z.ZodEnum<{
|
|
11364
|
+
prompt: "prompt";
|
|
11365
|
+
tools: "tools";
|
|
11366
|
+
mcp: "mcp";
|
|
11367
|
+
subagents: "subagents";
|
|
11368
|
+
hooks: "hooks";
|
|
11369
|
+
skills: "skills";
|
|
11370
|
+
"agent-profile": "agent-profile";
|
|
11371
|
+
memory: "memory";
|
|
11372
|
+
code: "code";
|
|
11373
|
+
knowledge: "knowledge";
|
|
11374
|
+
}>;
|
|
11375
|
+
identity: z.ZodString;
|
|
11376
|
+
currentDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
11377
|
+
}, z.core.$strict>], z.ZodObject<{
|
|
11378
|
+
surface: z.ZodEnum<{
|
|
11379
|
+
prompt: "prompt";
|
|
11380
|
+
tools: "tools";
|
|
11381
|
+
mcp: "mcp";
|
|
11382
|
+
subagents: "subagents";
|
|
11383
|
+
hooks: "hooks";
|
|
11384
|
+
skills: "skills";
|
|
11385
|
+
"agent-profile": "agent-profile";
|
|
11386
|
+
memory: "memory";
|
|
11387
|
+
code: "code";
|
|
11388
|
+
knowledge: "knowledge";
|
|
11389
|
+
}>;
|
|
11390
|
+
identity: z.ZodString;
|
|
11391
|
+
currentDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
11392
|
+
}, z.core.$strict>>;
|
|
11393
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
11394
|
+
status: z.ZodLiteral<"expired">;
|
|
11395
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
11396
|
+
status: z.ZodLiteral<"unsupported">;
|
|
11397
|
+
code: z.ZodString;
|
|
11398
|
+
message: z.ZodString;
|
|
11399
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
11400
|
+
status: z.ZodLiteral<"failed">;
|
|
11401
|
+
code: z.ZodString;
|
|
11402
|
+
message: z.ZodString;
|
|
11403
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
11404
|
+
status: z.ZodLiteral<"indeterminate">;
|
|
11405
|
+
code: z.ZodString;
|
|
11406
|
+
message: z.ZodString;
|
|
11407
|
+
}, z.core.$strict>], "status">;
|
|
11279
11408
|
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
11280
11409
|
}, z.core.$strict>;
|
|
@@ -750,6 +750,13 @@ export const agentImprovementReviewSchema = z
|
|
|
750
750
|
})
|
|
751
751
|
.strict()
|
|
752
752
|
.refine(isCanonicalJsonValue, "review must contain only RFC 8785 JSON values");
|
|
753
|
+
const improvementActivationTargetSchema = z
|
|
754
|
+
.object({
|
|
755
|
+
surface: improvementSurfaceSchema,
|
|
756
|
+
identity: z.string().min(1).max(500),
|
|
757
|
+
expectedBaseDigest: sha256DigestSchema,
|
|
758
|
+
})
|
|
759
|
+
.strict();
|
|
753
760
|
export const agentImprovementActivationSchema = z
|
|
754
761
|
.object({
|
|
755
762
|
kind: z.literal("agent-improvement-activation"),
|
|
@@ -757,26 +764,14 @@ export const agentImprovementActivationSchema = z
|
|
|
757
764
|
reviewDigest: sha256DigestSchema,
|
|
758
765
|
experimentDigest: sha256DigestSchema,
|
|
759
766
|
candidateBundleDigest: sha256DigestSchema,
|
|
767
|
+
intent: z.enum(["activate-candidate", "restore-baseline"]),
|
|
760
768
|
targets: z
|
|
761
|
-
.tuple([
|
|
762
|
-
|
|
763
|
-
.object({
|
|
764
|
-
surface: improvementSurfaceSchema,
|
|
765
|
-
identity: z.string().min(1).max(500),
|
|
766
|
-
expectedBaseDigest: sha256DigestSchema,
|
|
767
|
-
})
|
|
768
|
-
.strict(),
|
|
769
|
-
])
|
|
770
|
-
.rest(z
|
|
771
|
-
.object({
|
|
772
|
-
surface: improvementSurfaceSchema,
|
|
773
|
-
identity: z.string().min(1).max(500),
|
|
774
|
-
expectedBaseDigest: sha256DigestSchema,
|
|
775
|
-
})
|
|
776
|
-
.strict()),
|
|
769
|
+
.tuple([improvementActivationTargetSchema])
|
|
770
|
+
.rest(improvementActivationTargetSchema),
|
|
777
771
|
fundingOwner: z.string().min(1).max(500),
|
|
778
772
|
authorizedBy: z.string().min(1).max(500),
|
|
779
773
|
authorizedAt: z.iso.datetime(),
|
|
774
|
+
expiresAt: z.iso.datetime(),
|
|
780
775
|
digest: sha256DigestSchema,
|
|
781
776
|
})
|
|
782
777
|
.strict()
|
|
@@ -789,7 +784,112 @@ export const agentImprovementActivationSchema = z
|
|
|
789
784
|
message: "activation targets must be unique by surface and identity",
|
|
790
785
|
});
|
|
791
786
|
}
|
|
787
|
+
if (Date.parse(activation.expiresAt) <= Date.parse(activation.authorizedAt)) {
|
|
788
|
+
ctx.addIssue({
|
|
789
|
+
code: "custom",
|
|
790
|
+
path: ["expiresAt"],
|
|
791
|
+
message: "activation expiry must follow its authorization time",
|
|
792
|
+
});
|
|
793
|
+
}
|
|
792
794
|
if (!isCanonicalJsonValue(activation)) {
|
|
793
795
|
ctx.addIssue({ code: "custom", message: "activation must contain only RFC 8785 JSON values" });
|
|
794
796
|
}
|
|
795
797
|
});
|
|
798
|
+
const improvementActivationTargetTransitionSchema = z
|
|
799
|
+
.object({
|
|
800
|
+
surface: improvementSurfaceSchema,
|
|
801
|
+
identity: z.string().min(1).max(500),
|
|
802
|
+
beforeDigest: sha256DigestSchema,
|
|
803
|
+
afterDigest: sha256DigestSchema,
|
|
804
|
+
})
|
|
805
|
+
.strict();
|
|
806
|
+
const improvementActivationTargetStateSchema = z
|
|
807
|
+
.object({
|
|
808
|
+
surface: improvementSurfaceSchema,
|
|
809
|
+
identity: z.string().min(1).max(500),
|
|
810
|
+
currentDigest: sha256DigestSchema,
|
|
811
|
+
})
|
|
812
|
+
.strict();
|
|
813
|
+
const improvementActivationOutcomeSchema = z.discriminatedUnion("status", [
|
|
814
|
+
z
|
|
815
|
+
.object({
|
|
816
|
+
status: z.literal("applied"),
|
|
817
|
+
transactionId: z.string().min(1).max(500),
|
|
818
|
+
targets: z
|
|
819
|
+
.tuple([improvementActivationTargetTransitionSchema])
|
|
820
|
+
.rest(improvementActivationTargetTransitionSchema),
|
|
821
|
+
})
|
|
822
|
+
.strict(),
|
|
823
|
+
z
|
|
824
|
+
.object({
|
|
825
|
+
status: z.literal("already-applied"),
|
|
826
|
+
targets: z
|
|
827
|
+
.tuple([improvementActivationTargetStateSchema])
|
|
828
|
+
.rest(improvementActivationTargetStateSchema),
|
|
829
|
+
})
|
|
830
|
+
.strict(),
|
|
831
|
+
z
|
|
832
|
+
.object({
|
|
833
|
+
status: z.literal("conflict"),
|
|
834
|
+
targets: z
|
|
835
|
+
.tuple([improvementActivationTargetStateSchema])
|
|
836
|
+
.rest(improvementActivationTargetStateSchema),
|
|
837
|
+
})
|
|
838
|
+
.strict(),
|
|
839
|
+
z.object({ status: z.literal("expired") }).strict(),
|
|
840
|
+
z
|
|
841
|
+
.object({
|
|
842
|
+
status: z.literal("unsupported"),
|
|
843
|
+
code: z.string().min(1).max(100),
|
|
844
|
+
message: z.string().min(1).max(2_000),
|
|
845
|
+
})
|
|
846
|
+
.strict(),
|
|
847
|
+
z
|
|
848
|
+
.object({
|
|
849
|
+
status: z.literal("failed"),
|
|
850
|
+
code: z.string().min(1).max(100),
|
|
851
|
+
message: z.string().min(1).max(2_000),
|
|
852
|
+
})
|
|
853
|
+
.strict(),
|
|
854
|
+
z
|
|
855
|
+
.object({
|
|
856
|
+
status: z.literal("indeterminate"),
|
|
857
|
+
code: z.string().min(1).max(100),
|
|
858
|
+
message: z.string().min(1).max(2_000),
|
|
859
|
+
})
|
|
860
|
+
.strict(),
|
|
861
|
+
]);
|
|
862
|
+
export const agentImprovementActivationResultSchema = z
|
|
863
|
+
.object({
|
|
864
|
+
kind: z.literal("agent-improvement-activation-result"),
|
|
865
|
+
idempotencyKey: sha256DigestSchema,
|
|
866
|
+
attemptedAt: z.iso.datetime(),
|
|
867
|
+
completedAt: z.iso.datetime(),
|
|
868
|
+
outcome: improvementActivationOutcomeSchema,
|
|
869
|
+
digest: sha256DigestSchema,
|
|
870
|
+
})
|
|
871
|
+
.strict()
|
|
872
|
+
.superRefine((result, ctx) => {
|
|
873
|
+
if (Date.parse(result.completedAt) < Date.parse(result.attemptedAt)) {
|
|
874
|
+
ctx.addIssue({
|
|
875
|
+
code: "custom",
|
|
876
|
+
path: ["completedAt"],
|
|
877
|
+
message: "activation completion cannot predate its attempt",
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
const targets = "targets" in result.outcome ? result.outcome.targets : [];
|
|
881
|
+
const identities = targets.map((target) => `${target.surface}\u0000${target.identity}`);
|
|
882
|
+
if (new Set(identities).size !== identities.length) {
|
|
883
|
+
ctx.addIssue({
|
|
884
|
+
code: "custom",
|
|
885
|
+
path: ["outcome", "targets"],
|
|
886
|
+
message: "activation outcome targets must be unique by surface and identity",
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
if (!isCanonicalJsonValue(result)) {
|
|
890
|
+
ctx.addIssue({
|
|
891
|
+
code: "custom",
|
|
892
|
+
message: "activation result must contain only RFC 8785 JSON values",
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
});
|
|
@@ -1023,7 +1023,7 @@ export declare const agentCandidateRunReceiptSchema: z.ZodObject<{
|
|
|
1023
1023
|
callId: string;
|
|
1024
1024
|
generationId: string;
|
|
1025
1025
|
traceSpanId: string;
|
|
1026
|
-
status: "
|
|
1026
|
+
status: "failed" | "succeeded";
|
|
1027
1027
|
model: string;
|
|
1028
1028
|
startedAtMs: number;
|
|
1029
1029
|
endedAtMs: number;
|
|
@@ -1058,7 +1058,7 @@ export declare const agentCandidateRunReceiptSchema: z.ZodObject<{
|
|
|
1058
1058
|
callId: string;
|
|
1059
1059
|
generationId: string;
|
|
1060
1060
|
traceSpanId: string;
|
|
1061
|
-
status: "
|
|
1061
|
+
status: "failed" | "succeeded";
|
|
1062
1062
|
model: string;
|
|
1063
1063
|
startedAtMs: number;
|
|
1064
1064
|
endedAtMs: number;
|
|
@@ -806,6 +806,7 @@ export interface AgentImprovementActivationTarget {
|
|
|
806
806
|
/** Current target state that activation is allowed to replace. */
|
|
807
807
|
expectedBaseDigest: Sha256Digest;
|
|
808
808
|
}
|
|
809
|
+
export type AgentImprovementActivationIntent = "activate-candidate" | "restore-baseline";
|
|
809
810
|
/** Authority receipt permitting activation of one already-measured candidate. */
|
|
810
811
|
export interface AgentImprovementActivation {
|
|
811
812
|
kind: "agent-improvement-activation";
|
|
@@ -813,10 +814,56 @@ export interface AgentImprovementActivation {
|
|
|
813
814
|
reviewDigest: Sha256Digest;
|
|
814
815
|
experimentDigest: Sha256Digest;
|
|
815
816
|
candidateBundleDigest: Sha256Digest;
|
|
817
|
+
intent: AgentImprovementActivationIntent;
|
|
816
818
|
targets: [AgentImprovementActivationTarget, ...AgentImprovementActivationTarget[]];
|
|
817
819
|
fundingOwner: string;
|
|
818
820
|
authorizedBy: string;
|
|
819
821
|
authorizedAt: string;
|
|
822
|
+
expiresAt: string;
|
|
823
|
+
digest: Sha256Digest;
|
|
824
|
+
}
|
|
825
|
+
export interface AgentImprovementActivationTargetTransition {
|
|
826
|
+
surface: AgentImprovementSurface;
|
|
827
|
+
identity: string;
|
|
828
|
+
beforeDigest: Sha256Digest;
|
|
829
|
+
afterDigest: Sha256Digest;
|
|
830
|
+
}
|
|
831
|
+
export interface AgentImprovementActivationTargetState {
|
|
832
|
+
surface: AgentImprovementSurface;
|
|
833
|
+
identity: string;
|
|
834
|
+
currentDigest: Sha256Digest;
|
|
835
|
+
}
|
|
836
|
+
export type AgentImprovementActivationOutcome = {
|
|
837
|
+
/** Every target changed atomically from the authorized state to the requested bundle. */
|
|
838
|
+
status: "applied";
|
|
839
|
+
transactionId: string;
|
|
840
|
+
targets: [
|
|
841
|
+
AgentImprovementActivationTargetTransition,
|
|
842
|
+
...AgentImprovementActivationTargetTransition[]
|
|
843
|
+
];
|
|
844
|
+
} | {
|
|
845
|
+
/** No write occurred; targets are already desired or no longer match the authorized base. */
|
|
846
|
+
status: "already-applied" | "conflict";
|
|
847
|
+
targets: [
|
|
848
|
+
AgentImprovementActivationTargetState,
|
|
849
|
+
...AgentImprovementActivationTargetState[]
|
|
850
|
+
];
|
|
851
|
+
} | {
|
|
852
|
+
status: "expired";
|
|
853
|
+
} | {
|
|
854
|
+
/** `failed` proves no write; `indeterminate` means commit state must be reconciled. */
|
|
855
|
+
status: "unsupported" | "failed" | "indeterminate";
|
|
856
|
+
code: string;
|
|
857
|
+
message: string;
|
|
858
|
+
};
|
|
859
|
+
/** Immutable outcome of one idempotent, transaction-wide activation attempt. */
|
|
860
|
+
export interface AgentImprovementActivationResult {
|
|
861
|
+
kind: "agent-improvement-activation-result";
|
|
862
|
+
/** The activation digest is also its stable retry key. */
|
|
863
|
+
idempotencyKey: Sha256Digest;
|
|
864
|
+
attemptedAt: string;
|
|
865
|
+
completedAt: string;
|
|
866
|
+
outcome: AgentImprovementActivationOutcome;
|
|
820
867
|
digest: Sha256Digest;
|
|
821
868
|
}
|
|
822
869
|
/** Complete execution of one exact experiment attempt. */
|
|
@@ -62,6 +62,7 @@ export function candidateFixture() {
|
|
|
62
62
|
cwd: { workspace: "candidate", path: "." },
|
|
63
63
|
env: {
|
|
64
64
|
NODE_ENV: { kind: "public", value: "production" },
|
|
65
|
+
PATH: { kind: "public", value: "/usr/local/bin:/usr/bin:/bin" },
|
|
65
66
|
},
|
|
66
67
|
environment: {
|
|
67
68
|
kind: "pinned-container",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AgentProfile, AgentProfileCapabilities, AgentProfileValidationResult } from "./agent-profile.js";
|
|
2
|
+
import type { AgentCandidateTermination } from "./agent-candidate.js";
|
|
2
3
|
import type { InputPart, StreamEvent, TokenUsage } from "./index.js";
|
|
3
4
|
/** Portable profile reference: inline profile or provider catalog id. */
|
|
4
5
|
export type AgentProfileRef = AgentProfile | string;
|
|
@@ -48,6 +49,128 @@ export interface ExecResult {
|
|
|
48
49
|
stdout: string;
|
|
49
50
|
stderr: string;
|
|
50
51
|
}
|
|
52
|
+
export type AgentExactProcessEgressMode = "blocked" | "strict";
|
|
53
|
+
/**
|
|
54
|
+
* Outbound network policy for an exact process environment. `blocked` denies
|
|
55
|
+
* every protocol. `strict` permits only the named domains; direct-address,
|
|
56
|
+
* alternate-protocol, and cross-environment bypasses must fail.
|
|
57
|
+
*/
|
|
58
|
+
export type AgentExactProcessEgressPolicy = {
|
|
59
|
+
mode: "blocked";
|
|
60
|
+
} | {
|
|
61
|
+
mode: "strict";
|
|
62
|
+
allowDomains: readonly string[];
|
|
63
|
+
};
|
|
64
|
+
/** Explicit portable limits for an exact process environment. */
|
|
65
|
+
export interface AgentExactProcessResources {
|
|
66
|
+
/** Positive CPU core count. */
|
|
67
|
+
cpu: number;
|
|
68
|
+
/** Positive integer mebibytes of memory. */
|
|
69
|
+
memoryMb: number;
|
|
70
|
+
/** Positive integer mebibytes of disk. */
|
|
71
|
+
diskMb: number;
|
|
72
|
+
}
|
|
73
|
+
/** Terminal or running state reported by an exact process host. */
|
|
74
|
+
export interface AgentExactProcessStatus {
|
|
75
|
+
pid: number;
|
|
76
|
+
running: boolean;
|
|
77
|
+
/** -1 while running; the exact process exit code after termination. */
|
|
78
|
+
exitCode: number;
|
|
79
|
+
exitSignal?: string;
|
|
80
|
+
/** Required after termination; absent only while running. */
|
|
81
|
+
termination?: AgentCandidateTermination;
|
|
82
|
+
}
|
|
83
|
+
/** Recoverable handle for one shell-free process. */
|
|
84
|
+
export interface AgentExactProcess {
|
|
85
|
+
readonly pid: number;
|
|
86
|
+
status(): Promise<AgentExactProcessStatus>;
|
|
87
|
+
wait(): Promise<AgentCandidateTermination>;
|
|
88
|
+
/** Force-stop the full process tree. Idempotent after the process exits. */
|
|
89
|
+
kill(): Promise<void>;
|
|
90
|
+
/** Each iteration replays buffered UTF-8 stdout, then continues until exit. */
|
|
91
|
+
stdout(): AsyncIterable<string>;
|
|
92
|
+
/** Each iteration replays buffered UTF-8 stderr, then continues until exit. */
|
|
93
|
+
stderr(): AsyncIterable<string>;
|
|
94
|
+
}
|
|
95
|
+
/** Shell-free launch whose environment replaces, rather than extends, ambient variables. */
|
|
96
|
+
export interface AgentExactProcessLaunch {
|
|
97
|
+
/** Absolute path unless {@link env} supplies an explicit `PATH`. */
|
|
98
|
+
executable: string;
|
|
99
|
+
args: readonly string[];
|
|
100
|
+
cwd: string;
|
|
101
|
+
env: Readonly<Record<string, string>>;
|
|
102
|
+
stdin?: string;
|
|
103
|
+
/** Positive integer milliseconds, or zero to disable the process timeout. */
|
|
104
|
+
timeoutMs: number;
|
|
105
|
+
}
|
|
106
|
+
export interface AgentExactProcessManager {
|
|
107
|
+
list(): Promise<AgentExactProcessStatus[]>;
|
|
108
|
+
get(pid: number): Promise<AgentExactProcess | null>;
|
|
109
|
+
/** Providers must honor the abort signal when supplied. */
|
|
110
|
+
spawn(input: AgentExactProcessLaunch, options?: {
|
|
111
|
+
signal?: AbortSignal;
|
|
112
|
+
}): Promise<AgentExactProcess>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Fresh environment with no provider-managed user workload.
|
|
116
|
+
*
|
|
117
|
+
* Authenticated provider control services may exist, but no customer workload
|
|
118
|
+
* ingress or provider-managed user process may exist. The launched process
|
|
119
|
+
* sees only its supplied environment variables, with no ambient or injected
|
|
120
|
+
* secrets.
|
|
121
|
+
*/
|
|
122
|
+
export interface AgentExactProcessEnvironment {
|
|
123
|
+
readonly id: string;
|
|
124
|
+
readonly provider: string;
|
|
125
|
+
readonly metadata?: Record<string, unknown>;
|
|
126
|
+
readonly process: AgentExactProcessManager;
|
|
127
|
+
/** Write exact bytes to an absolute path with a POSIX mode from 0 through 07777. Providers must honor the abort signal when supplied. */
|
|
128
|
+
writeFile(path: string, bytes: Uint8Array, options: {
|
|
129
|
+
mode: number;
|
|
130
|
+
signal?: AbortSignal;
|
|
131
|
+
}): Promise<void>;
|
|
132
|
+
/** Read exact bytes or fail before content is loaded when the file exceeds maxBytes. */
|
|
133
|
+
readFile(path: string, options: {
|
|
134
|
+
maxBytes: number;
|
|
135
|
+
signal?: AbortSignal;
|
|
136
|
+
}): Promise<Uint8Array>;
|
|
137
|
+
destroy(): Promise<void>;
|
|
138
|
+
}
|
|
139
|
+
export interface AgentExactProcessEnvironmentQuery {
|
|
140
|
+
/** Every supplied key/value must match persisted environment metadata exactly. */
|
|
141
|
+
metadata?: Record<string, unknown>;
|
|
142
|
+
providerOptions?: Record<string, unknown>;
|
|
143
|
+
}
|
|
144
|
+
/** Input for a fresh environment with no provider-managed agent process. */
|
|
145
|
+
export interface CreateAgentExactProcessEnvironmentInput {
|
|
146
|
+
/** Provider-specific immutable image reference. */
|
|
147
|
+
image: string;
|
|
148
|
+
egress: AgentExactProcessEgressPolicy;
|
|
149
|
+
/** Positive integer milliseconds. */
|
|
150
|
+
maxLifetimeMs: number;
|
|
151
|
+
/** Positive integer milliseconds when supplied. */
|
|
152
|
+
provisionTimeoutMs?: number;
|
|
153
|
+
/** Required limits; exact execution never inherits provider defaults. */
|
|
154
|
+
resources: AgentExactProcessResources;
|
|
155
|
+
metadata: Record<string, unknown>;
|
|
156
|
+
idempotencyKey: string;
|
|
157
|
+
signal?: AbortSignal;
|
|
158
|
+
/** Provider-native fields may narrow, but never weaken, the isolation contract. */
|
|
159
|
+
providerOptions?: Record<string, unknown>;
|
|
160
|
+
}
|
|
161
|
+
/** Optional all-or-nothing exact process capability of an environment provider. */
|
|
162
|
+
export interface AgentExactProcessProvider {
|
|
163
|
+
/**
|
|
164
|
+
* Repeating the same idempotency key and input returns the same environment.
|
|
165
|
+
* Reusing the key with any different create input must fail.
|
|
166
|
+
* Unsupported egress modes must fail instead of weakening the policy.
|
|
167
|
+
*/
|
|
168
|
+
create(input: CreateAgentExactProcessEnvironmentInput): Promise<AgentExactProcessEnvironment>;
|
|
169
|
+
/** Ordinary environments must return null. */
|
|
170
|
+
get(id: string): Promise<AgentExactProcessEnvironment | null>;
|
|
171
|
+
/** Return every matching exact environment; providers own any native pagination. */
|
|
172
|
+
list(query?: AgentExactProcessEnvironmentQuery): Promise<AgentExactProcessEnvironment[]>;
|
|
173
|
+
}
|
|
51
174
|
export interface CheckpointRequest {
|
|
52
175
|
name?: string;
|
|
53
176
|
metadata?: Record<string, unknown>;
|
|
@@ -165,6 +288,10 @@ export interface AgentEnvironmentCapabilities {
|
|
|
165
288
|
placement: boolean;
|
|
166
289
|
usage: boolean;
|
|
167
290
|
confidential: boolean;
|
|
291
|
+
/** Present only when {@link AgentEnvironmentProvider.exactProcess} is implemented. */
|
|
292
|
+
exactProcess?: {
|
|
293
|
+
egress: readonly AgentExactProcessEgressMode[];
|
|
294
|
+
};
|
|
168
295
|
}
|
|
169
296
|
export interface CreateAgentEnvironmentInput {
|
|
170
297
|
profile: AgentProfileRef;
|
|
@@ -182,6 +309,7 @@ export interface CreateAgentEnvironmentInput {
|
|
|
182
309
|
}
|
|
183
310
|
export interface AgentEnvironmentProvider {
|
|
184
311
|
readonly name: string;
|
|
312
|
+
readonly exactProcess?: AgentExactProcessProvider;
|
|
185
313
|
capabilities(): AgentEnvironmentCapabilities | Promise<AgentEnvironmentCapabilities>;
|
|
186
314
|
validateProfile?(profile: AgentProfileRef): AgentProfileValidationResult | Promise<AgentProfileValidationResult>;
|
|
187
315
|
create(input: CreateAgentEnvironmentInput): Promise<AgentEnvironment>;
|