@tangle-network/agent-interface 0.20.0 → 0.22.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 +24 -0
- package/dist/agent-candidate-artifact-schema.d.ts +311 -0
- package/dist/agent-candidate-artifact-schema.js +192 -0
- package/dist/agent-candidate-code-schema.d.ts +295 -0
- package/dist/agent-candidate-code-schema.js +185 -0
- package/dist/agent-candidate-execution-plan-schema.d.ts +1193 -0
- package/dist/agent-candidate-execution-plan-schema.js +418 -0
- package/dist/agent-candidate-lineage-schema.d.ts +78 -0
- package/dist/agent-candidate-lineage-schema.js +96 -0
- package/dist/agent-candidate-outcome-schema.d.ts +618 -0
- package/dist/agent-candidate-outcome-schema.js +293 -0
- package/dist/agent-candidate-profile-schema.d.ts +267 -0
- package/dist/agent-candidate-profile-schema.js +125 -0
- package/dist/agent-candidate-receipt-schema.d.ts +2468 -0
- package/dist/agent-candidate-receipt-schema.js +388 -0
- package/dist/agent-candidate-schema-common.d.ts +32 -0
- package/dist/agent-candidate-schema-common.js +251 -0
- package/dist/agent-candidate-schema.d.ts +499 -0
- package/dist/agent-candidate-schema.js +145 -0
- package/dist/agent-candidate.d.ts +634 -0
- package/dist/agent-candidate.js +6 -0
- package/dist/agent-candidate.test-fixture.d.ts +160 -0
- package/dist/agent-candidate.test-fixture.js +151 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/interaction.d.ts +4 -4
- package/dist/profile-diff.d.ts +4 -1
- package/dist/profile-diff.js +64 -64
- package/dist/profile-schema.d.ts +1 -0
- package/dist/profile-schema.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,30 @@ const provider: AgentEnvironmentProvider = {
|
|
|
62
62
|
};
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
## Frozen improvement candidates
|
|
66
|
+
|
|
67
|
+
`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.
|
|
68
|
+
Execution either pins a candidate-selected container in the bundle or delegates container selection to the benchmark evaluator.
|
|
69
|
+
For evaluator-owned task images, the protected runtime creates a separate plan for every candidate/task pair and binds the root repository, exact Git base, exact UTF-8 instruction bytes, selected OCI index, manifest, platform, task workspace, model, launch, counted attempt, retry policy, and tool-step limit before execution.
|
|
70
|
+
Instruction delivery is closed to one final argv element, exact stdin bytes followed by EOF, or a fixed file path exposed through `TANGLE_CANDIDATE_TASK_PATH`.
|
|
71
|
+
That plan also binds the profile target workspace and every mounted path; benchmark adapters must restore or exclude task-targeted profile paths before capturing the submitted solution patch.
|
|
72
|
+
Resources are embedded, addressed through closed S3/IPFS locators, or pinned to a full GitHub commit plus content digest.
|
|
73
|
+
Candidate-authored process configuration is explicitly public; model authorization is evaluator-mediated and secret values never belong in the bundle.
|
|
74
|
+
Because prompts and inline files are arbitrary text, producers must also run their normal secret scanner before persistence.
|
|
75
|
+
Candidate v1 rejects unregistered backend extensions instead of accepting an untyped behavior or credential channel.
|
|
76
|
+
|
|
77
|
+
`agentCandidateBundleSchema.parse()` proves only that the wire shape is valid.
|
|
78
|
+
Before execution, an integrity verifier must omit only the top-level `digest`, canonicalize the rest with RFC 8785, hash the UTF-8 bytes to lowercase `sha256:<hex>`, verify every artifact, apply any Git patch to the declared base tree, and emit an `AgentCandidateMaterializationReceipt`.
|
|
79
|
+
Artifact and OCI resolvers must also reject redirects or DNS results that reach loopback, private, or link-local addresses; schema parsing cannot prove network resolution safety.
|
|
80
|
+
Attach the materialization and `AgentCandidateRunReceipt` records to the benchmark run so the result names the exact profile plan, code tree, launch plan, selected OCI manifest/platform and source, model, memory isolation, trace, termination, harness, and container that ran.
|
|
81
|
+
A timeout, signal, or cancellation remains distinct from a process exit; if the protected evaluator cannot recover complete usage and trace evidence, it must mark the cell as invalid capture instead of minting a zero-usage receipt.
|
|
82
|
+
|
|
83
|
+
The three code states are intentionally distinct:
|
|
84
|
+
|
|
85
|
+
- `{ kind: "disabled", reason: "control" }` is the fixed control; `reason: "not-applicable"` keeps code unchanged while another surface is optimized.
|
|
86
|
+
- `{ kind: "no-op" }` means a proposer ran and returned no change.
|
|
87
|
+
- `{ kind: "git-patch" }` carries a non-empty binary Git diff whose resulting tree must be verified.
|
|
88
|
+
|
|
65
89
|
## License
|
|
66
90
|
|
|
67
91
|
MIT
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const agentCandidateS3LocatorSchema: z.ZodObject<{
|
|
3
|
+
kind: z.ZodLiteral<"s3">;
|
|
4
|
+
bucket: z.ZodString;
|
|
5
|
+
key: z.ZodString;
|
|
6
|
+
region: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
export declare const agentCandidateIpfsLocatorSchema: z.ZodObject<{
|
|
9
|
+
kind: z.ZodLiteral<"ipfs">;
|
|
10
|
+
cid: z.ZodString;
|
|
11
|
+
path: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
export declare const agentCandidateArtifactLocatorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
14
|
+
kind: z.ZodLiteral<"s3">;
|
|
15
|
+
bucket: z.ZodString;
|
|
16
|
+
key: z.ZodString;
|
|
17
|
+
region: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
19
|
+
kind: z.ZodLiteral<"ipfs">;
|
|
20
|
+
cid: z.ZodString;
|
|
21
|
+
path: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strict>], "kind">;
|
|
23
|
+
export declare const agentCandidateArtifactRefSchema: z.ZodObject<{
|
|
24
|
+
locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
25
|
+
kind: z.ZodLiteral<"s3">;
|
|
26
|
+
bucket: z.ZodString;
|
|
27
|
+
key: z.ZodString;
|
|
28
|
+
region: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
30
|
+
kind: z.ZodLiteral<"ipfs">;
|
|
31
|
+
cid: z.ZodString;
|
|
32
|
+
path: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}, z.core.$strict>], "kind">;
|
|
34
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
35
|
+
byteLength: z.ZodNumber;
|
|
36
|
+
}, z.core.$strict>;
|
|
37
|
+
export declare const agentCandidateEmbeddedArtifactSchema: z.ZodObject<{
|
|
38
|
+
encoding: z.ZodLiteral<"base64">;
|
|
39
|
+
content: z.ZodString;
|
|
40
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
41
|
+
byteLength: z.ZodNumber;
|
|
42
|
+
}, z.core.$strict>;
|
|
43
|
+
export declare const agentCandidateCapturedArtifactSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
44
|
+
locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
45
|
+
kind: z.ZodLiteral<"s3">;
|
|
46
|
+
bucket: z.ZodString;
|
|
47
|
+
key: z.ZodString;
|
|
48
|
+
region: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
50
|
+
kind: z.ZodLiteral<"ipfs">;
|
|
51
|
+
cid: z.ZodString;
|
|
52
|
+
path: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strict>], "kind">;
|
|
54
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
55
|
+
byteLength: z.ZodNumber;
|
|
56
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
57
|
+
encoding: z.ZodLiteral<"base64">;
|
|
58
|
+
content: z.ZodString;
|
|
59
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
60
|
+
byteLength: z.ZodNumber;
|
|
61
|
+
}, z.core.$strict>]>;
|
|
62
|
+
export declare const agentCandidateWorkspaceManifestMaterialSchema: z.ZodObject<{
|
|
63
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
64
|
+
kind: z.ZodLiteral<"agent-candidate-workspace-manifest">;
|
|
65
|
+
files: z.ZodArray<z.ZodObject<{
|
|
66
|
+
path: z.ZodString;
|
|
67
|
+
mode: z.ZodUnion<readonly [z.ZodLiteral<420>, z.ZodLiteral<493>]>;
|
|
68
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
69
|
+
byteLength: z.ZodNumber;
|
|
70
|
+
}, z.core.$strict>>;
|
|
71
|
+
}, z.core.$strict>;
|
|
72
|
+
export declare const agentCandidateWorkspaceSnapshotEvidenceSchema: z.ZodObject<{
|
|
73
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
74
|
+
kind: z.ZodLiteral<"agent-candidate-workspace-snapshot">;
|
|
75
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
76
|
+
material: z.ZodObject<{
|
|
77
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
78
|
+
kind: z.ZodLiteral<"agent-candidate-workspace-manifest">;
|
|
79
|
+
files: z.ZodArray<z.ZodObject<{
|
|
80
|
+
path: z.ZodString;
|
|
81
|
+
mode: z.ZodUnion<readonly [z.ZodLiteral<420>, z.ZodLiteral<493>]>;
|
|
82
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
83
|
+
byteLength: z.ZodNumber;
|
|
84
|
+
}, z.core.$strict>>;
|
|
85
|
+
}, z.core.$strict>;
|
|
86
|
+
manifest: z.ZodUnion<readonly [z.ZodObject<{
|
|
87
|
+
locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
88
|
+
kind: z.ZodLiteral<"s3">;
|
|
89
|
+
bucket: z.ZodString;
|
|
90
|
+
key: z.ZodString;
|
|
91
|
+
region: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
93
|
+
kind: z.ZodLiteral<"ipfs">;
|
|
94
|
+
cid: z.ZodString;
|
|
95
|
+
path: z.ZodOptional<z.ZodString>;
|
|
96
|
+
}, z.core.$strict>], "kind">;
|
|
97
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
98
|
+
byteLength: z.ZodNumber;
|
|
99
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
100
|
+
encoding: z.ZodLiteral<"base64">;
|
|
101
|
+
content: z.ZodString;
|
|
102
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
103
|
+
byteLength: z.ZodNumber;
|
|
104
|
+
}, z.core.$strict>]>;
|
|
105
|
+
archive: z.ZodUnion<readonly [z.ZodObject<{
|
|
106
|
+
locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
107
|
+
kind: z.ZodLiteral<"s3">;
|
|
108
|
+
bucket: z.ZodString;
|
|
109
|
+
key: z.ZodString;
|
|
110
|
+
region: z.ZodOptional<z.ZodString>;
|
|
111
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
112
|
+
kind: z.ZodLiteral<"ipfs">;
|
|
113
|
+
cid: z.ZodString;
|
|
114
|
+
path: z.ZodOptional<z.ZodString>;
|
|
115
|
+
}, z.core.$strict>], "kind">;
|
|
116
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
117
|
+
byteLength: z.ZodNumber;
|
|
118
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
119
|
+
encoding: z.ZodLiteral<"base64">;
|
|
120
|
+
content: z.ZodString;
|
|
121
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
122
|
+
byteLength: z.ZodNumber;
|
|
123
|
+
}, z.core.$strict>]>;
|
|
124
|
+
}, z.core.$strict>;
|
|
125
|
+
export declare function validateEmbeddedArtifact(artifact: {
|
|
126
|
+
content: string;
|
|
127
|
+
byteLength: number;
|
|
128
|
+
}, ctx: z.RefinementCtx): void;
|
|
129
|
+
export declare const agentCandidateInlineResourceSchema: z.ZodObject<{
|
|
130
|
+
kind: z.ZodLiteral<"inline">;
|
|
131
|
+
name: z.ZodString;
|
|
132
|
+
content: z.ZodString;
|
|
133
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
134
|
+
byteLength: z.ZodNumber;
|
|
135
|
+
}, z.core.$strict>;
|
|
136
|
+
export declare const agentCandidateGitHubResourceSchema: z.ZodObject<{
|
|
137
|
+
kind: z.ZodLiteral<"github">;
|
|
138
|
+
repository: z.ZodObject<{
|
|
139
|
+
kind: z.ZodLiteral<"github">;
|
|
140
|
+
owner: z.ZodString;
|
|
141
|
+
repo: z.ZodString;
|
|
142
|
+
}, z.core.$strict>;
|
|
143
|
+
path: z.ZodString;
|
|
144
|
+
commit: z.ZodString;
|
|
145
|
+
name: z.ZodOptional<z.ZodString>;
|
|
146
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
147
|
+
byteLength: z.ZodNumber;
|
|
148
|
+
}, z.core.$strict>;
|
|
149
|
+
export declare const agentCandidateResourceRefSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
150
|
+
kind: z.ZodLiteral<"inline">;
|
|
151
|
+
name: z.ZodString;
|
|
152
|
+
content: z.ZodString;
|
|
153
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
154
|
+
byteLength: z.ZodNumber;
|
|
155
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
156
|
+
kind: z.ZodLiteral<"github">;
|
|
157
|
+
repository: z.ZodObject<{
|
|
158
|
+
kind: z.ZodLiteral<"github">;
|
|
159
|
+
owner: z.ZodString;
|
|
160
|
+
repo: z.ZodString;
|
|
161
|
+
}, z.core.$strict>;
|
|
162
|
+
path: z.ZodString;
|
|
163
|
+
commit: z.ZodString;
|
|
164
|
+
name: z.ZodOptional<z.ZodString>;
|
|
165
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
166
|
+
byteLength: z.ZodNumber;
|
|
167
|
+
}, z.core.$strict>], "kind">;
|
|
168
|
+
export declare const agentCandidateFileMountSchema: z.ZodObject<{
|
|
169
|
+
path: z.ZodString;
|
|
170
|
+
resource: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
171
|
+
kind: z.ZodLiteral<"inline">;
|
|
172
|
+
name: z.ZodString;
|
|
173
|
+
content: z.ZodString;
|
|
174
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
175
|
+
byteLength: z.ZodNumber;
|
|
176
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
177
|
+
kind: z.ZodLiteral<"github">;
|
|
178
|
+
repository: z.ZodObject<{
|
|
179
|
+
kind: z.ZodLiteral<"github">;
|
|
180
|
+
owner: z.ZodString;
|
|
181
|
+
repo: z.ZodString;
|
|
182
|
+
}, z.core.$strict>;
|
|
183
|
+
path: z.ZodString;
|
|
184
|
+
commit: z.ZodString;
|
|
185
|
+
name: z.ZodOptional<z.ZodString>;
|
|
186
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
187
|
+
byteLength: z.ZodNumber;
|
|
188
|
+
}, z.core.$strict>], "kind">;
|
|
189
|
+
executable: z.ZodOptional<z.ZodBoolean>;
|
|
190
|
+
}, z.core.$strict>;
|
|
191
|
+
export declare const agentCandidateResourcesSchema: z.ZodObject<{
|
|
192
|
+
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
193
|
+
path: z.ZodString;
|
|
194
|
+
resource: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
195
|
+
kind: z.ZodLiteral<"inline">;
|
|
196
|
+
name: z.ZodString;
|
|
197
|
+
content: z.ZodString;
|
|
198
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
199
|
+
byteLength: z.ZodNumber;
|
|
200
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
201
|
+
kind: z.ZodLiteral<"github">;
|
|
202
|
+
repository: z.ZodObject<{
|
|
203
|
+
kind: z.ZodLiteral<"github">;
|
|
204
|
+
owner: z.ZodString;
|
|
205
|
+
repo: z.ZodString;
|
|
206
|
+
}, z.core.$strict>;
|
|
207
|
+
path: z.ZodString;
|
|
208
|
+
commit: z.ZodString;
|
|
209
|
+
name: z.ZodOptional<z.ZodString>;
|
|
210
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
211
|
+
byteLength: z.ZodNumber;
|
|
212
|
+
}, z.core.$strict>], "kind">;
|
|
213
|
+
executable: z.ZodOptional<z.ZodBoolean>;
|
|
214
|
+
}, z.core.$strict>>>;
|
|
215
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
216
|
+
kind: z.ZodLiteral<"inline">;
|
|
217
|
+
name: z.ZodString;
|
|
218
|
+
content: z.ZodString;
|
|
219
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
220
|
+
byteLength: z.ZodNumber;
|
|
221
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
222
|
+
kind: z.ZodLiteral<"github">;
|
|
223
|
+
repository: z.ZodObject<{
|
|
224
|
+
kind: z.ZodLiteral<"github">;
|
|
225
|
+
owner: z.ZodString;
|
|
226
|
+
repo: z.ZodString;
|
|
227
|
+
}, z.core.$strict>;
|
|
228
|
+
path: z.ZodString;
|
|
229
|
+
commit: z.ZodString;
|
|
230
|
+
name: z.ZodOptional<z.ZodString>;
|
|
231
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
232
|
+
byteLength: z.ZodNumber;
|
|
233
|
+
}, z.core.$strict>], "kind">>>;
|
|
234
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
235
|
+
kind: z.ZodLiteral<"inline">;
|
|
236
|
+
name: z.ZodString;
|
|
237
|
+
content: z.ZodString;
|
|
238
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
239
|
+
byteLength: z.ZodNumber;
|
|
240
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
241
|
+
kind: z.ZodLiteral<"github">;
|
|
242
|
+
repository: z.ZodObject<{
|
|
243
|
+
kind: z.ZodLiteral<"github">;
|
|
244
|
+
owner: z.ZodString;
|
|
245
|
+
repo: z.ZodString;
|
|
246
|
+
}, z.core.$strict>;
|
|
247
|
+
path: z.ZodString;
|
|
248
|
+
commit: z.ZodString;
|
|
249
|
+
name: z.ZodOptional<z.ZodString>;
|
|
250
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
251
|
+
byteLength: z.ZodNumber;
|
|
252
|
+
}, z.core.$strict>], "kind">>>;
|
|
253
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
254
|
+
kind: z.ZodLiteral<"inline">;
|
|
255
|
+
name: z.ZodString;
|
|
256
|
+
content: z.ZodString;
|
|
257
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
258
|
+
byteLength: z.ZodNumber;
|
|
259
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
260
|
+
kind: z.ZodLiteral<"github">;
|
|
261
|
+
repository: z.ZodObject<{
|
|
262
|
+
kind: z.ZodLiteral<"github">;
|
|
263
|
+
owner: z.ZodString;
|
|
264
|
+
repo: z.ZodString;
|
|
265
|
+
}, z.core.$strict>;
|
|
266
|
+
path: z.ZodString;
|
|
267
|
+
commit: z.ZodString;
|
|
268
|
+
name: z.ZodOptional<z.ZodString>;
|
|
269
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
270
|
+
byteLength: z.ZodNumber;
|
|
271
|
+
}, z.core.$strict>], "kind">>>;
|
|
272
|
+
commands: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
273
|
+
kind: z.ZodLiteral<"inline">;
|
|
274
|
+
name: z.ZodString;
|
|
275
|
+
content: z.ZodString;
|
|
276
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
277
|
+
byteLength: z.ZodNumber;
|
|
278
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
279
|
+
kind: z.ZodLiteral<"github">;
|
|
280
|
+
repository: z.ZodObject<{
|
|
281
|
+
kind: z.ZodLiteral<"github">;
|
|
282
|
+
owner: z.ZodString;
|
|
283
|
+
repo: z.ZodString;
|
|
284
|
+
}, z.core.$strict>;
|
|
285
|
+
path: z.ZodString;
|
|
286
|
+
commit: z.ZodString;
|
|
287
|
+
name: z.ZodOptional<z.ZodString>;
|
|
288
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
289
|
+
byteLength: z.ZodNumber;
|
|
290
|
+
}, z.core.$strict>], "kind">>>;
|
|
291
|
+
instructions: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
292
|
+
kind: z.ZodLiteral<"inline">;
|
|
293
|
+
name: z.ZodString;
|
|
294
|
+
content: z.ZodString;
|
|
295
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
296
|
+
byteLength: z.ZodNumber;
|
|
297
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
298
|
+
kind: z.ZodLiteral<"github">;
|
|
299
|
+
repository: z.ZodObject<{
|
|
300
|
+
kind: z.ZodLiteral<"github">;
|
|
301
|
+
owner: z.ZodString;
|
|
302
|
+
repo: z.ZodString;
|
|
303
|
+
}, z.core.$strict>;
|
|
304
|
+
path: z.ZodString;
|
|
305
|
+
commit: z.ZodString;
|
|
306
|
+
name: z.ZodOptional<z.ZodString>;
|
|
307
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
308
|
+
byteLength: z.ZodNumber;
|
|
309
|
+
}, z.core.$strict>], "kind">]>>;
|
|
310
|
+
failOnError: z.ZodLiteral<true>;
|
|
311
|
+
}, z.core.$strict>;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { agentCandidateGitHubRepositorySchema, gitObjectSchema, isSafeRelativePath, isWellFormedUnicode, looksLikeCredential, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
|
|
3
|
+
const base64Pattern = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
4
|
+
const base64Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
5
|
+
const s3BucketPattern = /^(?!\d+\.\d+\.\d+\.\d+$)[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/;
|
|
6
|
+
const awsRegionPattern = /^[a-z]{2}(?:-gov)?-[a-z]+-\d$/;
|
|
7
|
+
const ipfsCidPattern = /^(?:Qm[1-9A-HJ-NP-Za-km-z]{44}|b[a-z2-7]{20,})$/;
|
|
8
|
+
function decodedBase64ByteLength(value) {
|
|
9
|
+
if (value.length === 0)
|
|
10
|
+
return 0;
|
|
11
|
+
const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
|
|
12
|
+
return (value.length / 4) * 3 - padding;
|
|
13
|
+
}
|
|
14
|
+
function hasCanonicalBase64Padding(value) {
|
|
15
|
+
if (value.endsWith("==")) {
|
|
16
|
+
const index = base64Alphabet.indexOf(value.at(-3) ?? "");
|
|
17
|
+
return index >= 0 && (index & 0x0f) === 0;
|
|
18
|
+
}
|
|
19
|
+
if (value.endsWith("=")) {
|
|
20
|
+
const index = base64Alphabet.indexOf(value.at(-2) ?? "");
|
|
21
|
+
return index >= 0 && (index & 0x03) === 0;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
export const agentCandidateS3LocatorSchema = z
|
|
26
|
+
.object({
|
|
27
|
+
kind: z.literal("s3"),
|
|
28
|
+
bucket: z.string().regex(s3BucketPattern),
|
|
29
|
+
key: z
|
|
30
|
+
.string()
|
|
31
|
+
.refine((value) => isSafeRelativePath(value, false) && !looksLikeCredential(value), "S3 key must be a canonical relative artifact path"),
|
|
32
|
+
region: z.string().regex(awsRegionPattern).optional(),
|
|
33
|
+
})
|
|
34
|
+
.strict();
|
|
35
|
+
export const agentCandidateIpfsLocatorSchema = z
|
|
36
|
+
.object({
|
|
37
|
+
kind: z.literal("ipfs"),
|
|
38
|
+
cid: z.string().regex(ipfsCidPattern),
|
|
39
|
+
path: z
|
|
40
|
+
.string()
|
|
41
|
+
.refine((value) => isSafeRelativePath(value, false) && !looksLikeCredential(value), "IPFS path must be a canonical relative artifact path")
|
|
42
|
+
.optional(),
|
|
43
|
+
})
|
|
44
|
+
.strict();
|
|
45
|
+
export const agentCandidateArtifactLocatorSchema = z.discriminatedUnion("kind", [agentCandidateS3LocatorSchema, agentCandidateIpfsLocatorSchema]);
|
|
46
|
+
export const agentCandidateArtifactRefSchema = z
|
|
47
|
+
.object({
|
|
48
|
+
locator: agentCandidateArtifactLocatorSchema,
|
|
49
|
+
sha256: sha256DigestSchema,
|
|
50
|
+
byteLength: z.number().int().nonnegative(),
|
|
51
|
+
})
|
|
52
|
+
.strict();
|
|
53
|
+
export const agentCandidateEmbeddedArtifactSchema = z
|
|
54
|
+
.object({
|
|
55
|
+
encoding: z.literal("base64"),
|
|
56
|
+
content: z.string().regex(base64Pattern),
|
|
57
|
+
sha256: sha256DigestSchema,
|
|
58
|
+
byteLength: z.number().int().nonnegative(),
|
|
59
|
+
})
|
|
60
|
+
.strict()
|
|
61
|
+
.superRefine(validateEmbeddedArtifact);
|
|
62
|
+
export const agentCandidateCapturedArtifactSchema = z.union([
|
|
63
|
+
agentCandidateArtifactRefSchema,
|
|
64
|
+
agentCandidateEmbeddedArtifactSchema,
|
|
65
|
+
]);
|
|
66
|
+
export const agentCandidateWorkspaceManifestMaterialSchema = z
|
|
67
|
+
.object({
|
|
68
|
+
schemaVersion: z.literal(1),
|
|
69
|
+
kind: z.literal("agent-candidate-workspace-manifest"),
|
|
70
|
+
files: z.array(z
|
|
71
|
+
.object({
|
|
72
|
+
path: z
|
|
73
|
+
.string()
|
|
74
|
+
.refine((value) => isSafeRelativePath(value, false), "workspace manifest paths must be canonical and relative"),
|
|
75
|
+
mode: z.union([z.literal(0o644), z.literal(0o755)]),
|
|
76
|
+
sha256: sha256DigestSchema,
|
|
77
|
+
byteLength: z.number().int().nonnegative(),
|
|
78
|
+
})
|
|
79
|
+
.strict()),
|
|
80
|
+
})
|
|
81
|
+
.strict()
|
|
82
|
+
.superRefine((material, ctx) => {
|
|
83
|
+
for (let index = 1; index < material.files.length; index++) {
|
|
84
|
+
const previous = material.files[index - 1]?.path ?? "";
|
|
85
|
+
const current = material.files[index]?.path ?? "";
|
|
86
|
+
if (previous >= current) {
|
|
87
|
+
ctx.addIssue({
|
|
88
|
+
code: "custom",
|
|
89
|
+
path: ["files", index, "path"],
|
|
90
|
+
message: "workspace manifest paths must be unique and lexicographically sorted",
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
export const agentCandidateWorkspaceSnapshotEvidenceSchema = z
|
|
96
|
+
.object({
|
|
97
|
+
schemaVersion: z.literal(1),
|
|
98
|
+
kind: z.literal("agent-candidate-workspace-snapshot"),
|
|
99
|
+
digest: sha256DigestSchema,
|
|
100
|
+
material: agentCandidateWorkspaceManifestMaterialSchema,
|
|
101
|
+
manifest: agentCandidateCapturedArtifactSchema,
|
|
102
|
+
archive: agentCandidateCapturedArtifactSchema,
|
|
103
|
+
})
|
|
104
|
+
.strict()
|
|
105
|
+
.superRefine((evidence, ctx) => {
|
|
106
|
+
if (evidence.manifest.sha256 !== evidence.digest) {
|
|
107
|
+
ctx.addIssue({
|
|
108
|
+
code: "custom",
|
|
109
|
+
path: ["manifest", "sha256"],
|
|
110
|
+
message: "workspace digest must equal the canonical manifest hash",
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (evidence.manifest.byteLength === 0 || evidence.archive.byteLength === 0) {
|
|
114
|
+
ctx.addIssue({
|
|
115
|
+
code: "custom",
|
|
116
|
+
message: "workspace evidence requires non-empty manifest and archive bytes",
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
export function validateEmbeddedArtifact(artifact, ctx) {
|
|
121
|
+
if (!hasCanonicalBase64Padding(artifact.content)) {
|
|
122
|
+
ctx.addIssue({
|
|
123
|
+
code: "custom",
|
|
124
|
+
path: ["content"],
|
|
125
|
+
message: "base64 content must use canonical zero padding bits",
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (decodedBase64ByteLength(artifact.content) !== artifact.byteLength) {
|
|
129
|
+
ctx.addIssue({
|
|
130
|
+
code: "custom",
|
|
131
|
+
path: ["byteLength"],
|
|
132
|
+
message: "byteLength must match the decoded base64 content",
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export const agentCandidateInlineResourceSchema = z
|
|
137
|
+
.object({
|
|
138
|
+
kind: z.literal("inline"),
|
|
139
|
+
name: z.string().min(1).refine(isWellFormedUnicode),
|
|
140
|
+
content: z.string().refine(isWellFormedUnicode),
|
|
141
|
+
sha256: sha256DigestSchema,
|
|
142
|
+
byteLength: z.number().int().nonnegative(),
|
|
143
|
+
})
|
|
144
|
+
.strict()
|
|
145
|
+
.superRefine((resource, ctx) => {
|
|
146
|
+
if (new TextEncoder().encode(resource.content).byteLength !== resource.byteLength) {
|
|
147
|
+
ctx.addIssue({
|
|
148
|
+
code: "custom",
|
|
149
|
+
path: ["byteLength"],
|
|
150
|
+
message: "byteLength must match UTF-8 content",
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
export const agentCandidateGitHubResourceSchema = z
|
|
155
|
+
.object({
|
|
156
|
+
kind: z.literal("github"),
|
|
157
|
+
repository: agentCandidateGitHubRepositorySchema,
|
|
158
|
+
path: z
|
|
159
|
+
.string()
|
|
160
|
+
.refine((value) => isSafeRelativePath(value, false), "path must be a canonical repository-relative path"),
|
|
161
|
+
commit: gitObjectSchema,
|
|
162
|
+
name: z.string().min(1).refine(isWellFormedUnicode).optional(),
|
|
163
|
+
sha256: sha256DigestSchema,
|
|
164
|
+
byteLength: z.number().int().nonnegative(),
|
|
165
|
+
})
|
|
166
|
+
.strict();
|
|
167
|
+
export const agentCandidateResourceRefSchema = z.discriminatedUnion("kind", [
|
|
168
|
+
agentCandidateInlineResourceSchema,
|
|
169
|
+
agentCandidateGitHubResourceSchema,
|
|
170
|
+
]);
|
|
171
|
+
export const agentCandidateFileMountSchema = z
|
|
172
|
+
.object({
|
|
173
|
+
path: z
|
|
174
|
+
.string()
|
|
175
|
+
.refine((value) => isSafeRelativePath(value, false), "mount path must be a canonical workspace-relative path"),
|
|
176
|
+
resource: agentCandidateResourceRefSchema,
|
|
177
|
+
executable: z.boolean().optional(),
|
|
178
|
+
})
|
|
179
|
+
.strict();
|
|
180
|
+
export const agentCandidateResourcesSchema = z
|
|
181
|
+
.object({
|
|
182
|
+
files: z.array(agentCandidateFileMountSchema).optional(),
|
|
183
|
+
tools: z.array(agentCandidateResourceRefSchema).optional(),
|
|
184
|
+
skills: z.array(agentCandidateResourceRefSchema).optional(),
|
|
185
|
+
agents: z.array(agentCandidateResourceRefSchema).optional(),
|
|
186
|
+
commands: z.array(agentCandidateResourceRefSchema).optional(),
|
|
187
|
+
instructions: z
|
|
188
|
+
.union([z.string().refine(isWellFormedUnicode), agentCandidateResourceRefSchema])
|
|
189
|
+
.optional(),
|
|
190
|
+
failOnError: z.literal(true),
|
|
191
|
+
})
|
|
192
|
+
.strict();
|