@tangle-network/agent-runtime 0.93.2 → 0.94.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 +4 -3
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +3 -4
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/candidate-execution/index.d.ts +10 -3
- package/dist/candidate-execution/index.js +8 -2
- package/dist/{chunk-XDSWWUKE.js → chunk-4E2GM63H.js} +6 -29
- package/dist/chunk-4E2GM63H.js.map +1 -0
- package/dist/{chunk-TU73X3I6.js → chunk-4GBT4WQ6.js} +2 -2
- package/dist/{chunk-Z7K5BPKZ.js → chunk-55P6V5JT.js} +2 -2
- package/dist/{chunk-OX3QRJOA.js → chunk-7I2AOKCI.js} +280 -250
- package/dist/chunk-7I2AOKCI.js.map +1 -0
- package/dist/{chunk-2BQMAZAB.js → chunk-FHZHADIM.js} +1327 -19
- package/dist/chunk-FHZHADIM.js.map +1 -0
- package/dist/{chunk-WGR6QJ5H.js → chunk-H2D3DCEB.js} +7 -160
- package/dist/chunk-H2D3DCEB.js.map +1 -0
- package/dist/chunk-ISTDY47H.js +849 -0
- package/dist/chunk-ISTDY47H.js.map +1 -0
- package/dist/{chunk-X5KJKS33.js → chunk-MRYPFDHJ.js} +3 -3
- package/dist/{chunk-6K5CI33W.js → chunk-OO4EK3JB.js} +1228 -18
- package/dist/chunk-OO4EK3JB.js.map +1 -0
- package/dist/{chunk-R5GWDTM3.js → chunk-ZEYAT33L.js} +2 -2
- package/dist/{completion-gate-BLaiN0-X.d.ts → completion-gate-BDkEYB_-.d.ts} +1 -1
- package/dist/{coordination-DxJ83oZA.d.ts → coordination-EGoRbbsd.d.ts} +4 -4
- package/dist/environment-provider.d.ts +2 -2
- package/dist/{improve-DDhQaaJT.d.ts → improve-ZzTEkpF_.d.ts} +11 -14
- package/dist/index.d.ts +35 -106
- package/dist/index.js +89 -33
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +22 -5
- package/dist/intelligence.js +111 -17
- package/dist/intelligence.js.map +1 -1
- package/dist/knowledge.d.ts +6 -6
- package/dist/knowledge.js +3 -3
- package/dist/{loop-runner-bin-kKUNGLyV.d.ts → loop-runner-bin-BRXC1RwC.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +5 -5
- package/dist/loop-runner-bin.js +4 -5
- package/dist/loops.d.ts +456 -17
- package/dist/loops.js +37 -39
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +8 -8
- package/dist/mcp/index.js +5 -6
- package/dist/mcp/index.js.map +1 -1
- package/dist/{openai-tools-E3woykz9.d.ts → openai-tools-D0ZSRCC6.d.ts} +1 -1
- package/dist/{prepare-DiVGKcwS.d.ts → prepare-BKxAiUcH.d.ts} +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{sanitize-C9go6tXj.d.ts → sanitize-C2jicjNf.d.ts} +1 -1
- package/dist/{supervise-T2pazU3G.d.ts → supervise-Gmf709kn.d.ts} +4 -4
- package/dist/{types-DAdIm4AC.d.ts → types-Cg_teUPO.d.ts} +2 -2
- package/dist/{types-B00NtbCs.d.ts → types-DWA64rbJ.d.ts} +1 -1
- package/dist/{worktree-fanout-BUb2Ag02.d.ts → worktree-fanout-BrB4att3.d.ts} +233 -233
- package/package.json +4 -4
- package/skills/build-with-agent-runtime/SKILL.md +1 -1
- package/dist/chunk-2BQMAZAB.js.map +0 -1
- package/dist/chunk-6K5CI33W.js.map +0 -1
- package/dist/chunk-FDJ7AHXG.js +0 -1229
- package/dist/chunk-FDJ7AHXG.js.map +0 -1
- package/dist/chunk-J2K6WIG6.js +0 -2172
- package/dist/chunk-J2K6WIG6.js.map +0 -1
- package/dist/chunk-OX3QRJOA.js.map +0 -1
- package/dist/chunk-WGR6QJ5H.js.map +0 -1
- package/dist/chunk-XDSWWUKE.js.map +0 -1
- package/dist/structural-rollout-DHGDbhvR.d.ts +0 -446
- /package/dist/{chunk-TU73X3I6.js.map → chunk-4GBT4WQ6.js.map} +0 -0
- /package/dist/{chunk-Z7K5BPKZ.js.map → chunk-55P6V5JT.js.map} +0 -0
- /package/dist/{chunk-X5KJKS33.js.map → chunk-MRYPFDHJ.js.map} +0 -0
- /package/dist/{chunk-R5GWDTM3.js.map → chunk-ZEYAT33L.js.map} +0 -0
|
@@ -72,6 +72,283 @@ function sealAgentCandidateBundle(input) {
|
|
|
72
72
|
return immutableCandidateValue(parsed);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
// src/candidate-execution/profile.ts
|
|
76
|
+
import {
|
|
77
|
+
agentCandidateProfileSchema,
|
|
78
|
+
agentProfileDiffSchema,
|
|
79
|
+
agentProfileSchema,
|
|
80
|
+
applyAgentProfileDiff
|
|
81
|
+
} from "@tangle-network/agent-interface";
|
|
82
|
+
var CANDIDATE_PROFILE_DIRECT_FIELDS = [
|
|
83
|
+
"name",
|
|
84
|
+
"description",
|
|
85
|
+
"version",
|
|
86
|
+
"tags",
|
|
87
|
+
"prompt",
|
|
88
|
+
"harness",
|
|
89
|
+
"permissions",
|
|
90
|
+
"tools",
|
|
91
|
+
"confidential"
|
|
92
|
+
];
|
|
93
|
+
function freezeGenericAgentCandidateProfile(input) {
|
|
94
|
+
const profile = parseExactAgentProfile(input, "profile");
|
|
95
|
+
if (profile.connections !== void 0) unsupportedProfileField("connections");
|
|
96
|
+
if (profile.metadata !== void 0) unsupportedProfileField("metadata");
|
|
97
|
+
if (profile.extensions !== void 0) unsupportedProfileField("extensions");
|
|
98
|
+
if (profile.model?.metadata !== void 0) unsupportedProfileField("model.metadata");
|
|
99
|
+
const candidate = {};
|
|
100
|
+
copyDirectProfileFields(candidate, profile);
|
|
101
|
+
if (profile.model) {
|
|
102
|
+
const { metadata: _metadata, ...model } = profile.model;
|
|
103
|
+
candidate.model = model;
|
|
104
|
+
}
|
|
105
|
+
if (profile.mcp) candidate.mcp = freezeMcpServers(profile.mcp);
|
|
106
|
+
if (profile.subagents) {
|
|
107
|
+
candidate.subagents = Object.fromEntries(
|
|
108
|
+
Object.entries(profile.subagents).map(([name, subagent]) => {
|
|
109
|
+
if (subagent.metadata !== void 0) unsupportedProfileField(`subagents.${name}.metadata`);
|
|
110
|
+
const { metadata: _metadata, ...value } = subagent;
|
|
111
|
+
return [name, value];
|
|
112
|
+
})
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
if (profile.resources) candidate.resources = freezeResources(profile.resources);
|
|
116
|
+
if (profile.hooks && Object.values(profile.hooks).some((commands) => commands.length > 0)) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
"generic AgentProfile hooks cannot be safely tokenized; use a candidate-profile source with executable/args"
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
if (profile.hooks) candidate.hooks = profile.hooks;
|
|
122
|
+
if (profile.modes) {
|
|
123
|
+
candidate.modes = Object.fromEntries(
|
|
124
|
+
Object.entries(profile.modes).map(([name, mode]) => {
|
|
125
|
+
if (mode.metadata !== void 0) unsupportedProfileField(`modes.${name}.metadata`);
|
|
126
|
+
const { metadata: _metadata, ...value } = mode;
|
|
127
|
+
return [name, value];
|
|
128
|
+
})
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
const parsed = parseExactCandidateProfile(candidate);
|
|
132
|
+
assertCandidateProfileBinding(profile, parsed);
|
|
133
|
+
return parsed;
|
|
134
|
+
}
|
|
135
|
+
function assertCandidateProfileBinding(measuredInput, bundled) {
|
|
136
|
+
const measured = parseExactAgentProfile(measuredInput, "proposal candidate profile");
|
|
137
|
+
if (measured.connections || measured.metadata || measured.extensions) {
|
|
138
|
+
throw new Error("proposal candidate profile contains fields unsupported by sealed candidates");
|
|
139
|
+
}
|
|
140
|
+
const normalized = candidateProfileAsAgentProfile(bundled);
|
|
141
|
+
if (canonicalCandidateDigest(measured) !== canonicalCandidateDigest(normalized)) {
|
|
142
|
+
throw new Error("proposal candidateProfile does not match candidateBundle.profile");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function parseExactAgentProfile(input, label) {
|
|
146
|
+
const parsed = agentProfileSchema.parse(input);
|
|
147
|
+
assertCanonicalParse(input, parsed, label);
|
|
148
|
+
return parsed;
|
|
149
|
+
}
|
|
150
|
+
function parseExactAgentProfileDiff(input, label) {
|
|
151
|
+
const parsed = agentProfileDiffSchema.parse(input);
|
|
152
|
+
assertCanonicalParse(input, parsed, label);
|
|
153
|
+
return parsed;
|
|
154
|
+
}
|
|
155
|
+
function applyExactAgentProfileDiff(baseInput, diffInput, label) {
|
|
156
|
+
const base = parseExactAgentProfile(baseInput, `${label} base profile`);
|
|
157
|
+
const diff = parseExactAgentProfileDiff(diffInput, `${label} diff`);
|
|
158
|
+
const applied = omitUndefinedObjectFields(applyAgentProfileDiff(base, diff), label);
|
|
159
|
+
return parseExactAgentProfile(applied, `${label} result`);
|
|
160
|
+
}
|
|
161
|
+
function parseExactCandidateProfile(input) {
|
|
162
|
+
const parsed = agentCandidateProfileSchema.parse(input);
|
|
163
|
+
assertCanonicalParse(input, parsed, "candidate profile");
|
|
164
|
+
return parsed;
|
|
165
|
+
}
|
|
166
|
+
function assertCandidateProfileExecutionSupport(profile) {
|
|
167
|
+
const fields = ["tools", "permissions", "modes", "confidential"];
|
|
168
|
+
const unsupported = fields.filter((field) => hasEntries(profile[field]));
|
|
169
|
+
if (unsupported.length > 0) {
|
|
170
|
+
throw new Error(
|
|
171
|
+
`candidate execution cannot prove in-session effects for non-empty AgentProfile fields: ${unsupported.join(", ")}`
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function candidateProfileAsAgentProfile(candidate) {
|
|
176
|
+
const output = {};
|
|
177
|
+
copyDirectProfileFields(output, candidate);
|
|
178
|
+
if (candidate.model) output.model = { ...candidate.model };
|
|
179
|
+
if (candidate.mcp) {
|
|
180
|
+
output.mcp = Object.fromEntries(
|
|
181
|
+
Object.entries(candidate.mcp).map(([name, server]) => [
|
|
182
|
+
name,
|
|
183
|
+
{
|
|
184
|
+
...server,
|
|
185
|
+
...server.args ? { args: server.args.map(publicValue) } : {},
|
|
186
|
+
...server.env ? { env: mapPublicValues(server.env) } : {}
|
|
187
|
+
}
|
|
188
|
+
])
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
if (candidate.subagents) output.subagents = cloneRecord(candidate.subagents);
|
|
192
|
+
if (candidate.modes) output.modes = cloneRecord(candidate.modes);
|
|
193
|
+
if (candidate.hooks) {
|
|
194
|
+
output.hooks = Object.fromEntries(
|
|
195
|
+
Object.entries(candidate.hooks).map(([event, hooks]) => [
|
|
196
|
+
event,
|
|
197
|
+
hooks.map(({ executable, args, env, ...hook }) => ({
|
|
198
|
+
...hook,
|
|
199
|
+
command: [executable, ...(args ?? []).map(publicValue)].map(shellQuote).join(" "),
|
|
200
|
+
...env ? { env: mapPublicValues(env) } : {}
|
|
201
|
+
}))
|
|
202
|
+
])
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
if (candidate.resources) {
|
|
206
|
+
if (candidate.resources.failOnError !== true) {
|
|
207
|
+
throw new Error("proposal candidate profile contains fields unsupported by sealed candidates");
|
|
208
|
+
}
|
|
209
|
+
output.resources = {
|
|
210
|
+
failOnError: true,
|
|
211
|
+
...candidate.resources.files ? {
|
|
212
|
+
files: candidate.resources.files.map((file) => ({
|
|
213
|
+
...file,
|
|
214
|
+
resource: publicResource(file.resource)
|
|
215
|
+
}))
|
|
216
|
+
} : {},
|
|
217
|
+
...candidate.resources.tools ? { tools: candidate.resources.tools.map(publicResource) } : {},
|
|
218
|
+
...candidate.resources.skills ? { skills: candidate.resources.skills.map(publicResource) } : {},
|
|
219
|
+
...candidate.resources.agents ? { agents: candidate.resources.agents.map(publicResource) } : {},
|
|
220
|
+
...candidate.resources.commands ? { commands: candidate.resources.commands.map(publicResource) } : {},
|
|
221
|
+
...candidate.resources.instructions !== void 0 ? {
|
|
222
|
+
instructions: typeof candidate.resources.instructions === "string" ? candidate.resources.instructions : publicResource(candidate.resources.instructions)
|
|
223
|
+
} : {}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return output;
|
|
227
|
+
}
|
|
228
|
+
function omitUndefinedObjectFields(value, path) {
|
|
229
|
+
if (Array.isArray(value)) {
|
|
230
|
+
return value.map((entry, index) => {
|
|
231
|
+
if (entry === void 0) {
|
|
232
|
+
throw new Error(`${path} produced an undefined array entry at ${index}`);
|
|
233
|
+
}
|
|
234
|
+
return omitUndefinedObjectFields(entry, `${path}[${index}]`);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
if (value === null || typeof value !== "object") return value;
|
|
238
|
+
return Object.fromEntries(
|
|
239
|
+
Object.entries(value).filter(([, entry]) => entry !== void 0).map(([key, entry]) => [key, omitUndefinedObjectFields(entry, `${path}.${key}`)])
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
function freezeMcpServers(servers) {
|
|
243
|
+
return Object.fromEntries(
|
|
244
|
+
Object.entries(servers).map(([name, server]) => {
|
|
245
|
+
if (server.transport !== void 0 && server.transport !== "stdio") {
|
|
246
|
+
unsupportedProfileField(`mcp.${name}.transport=${server.transport}`);
|
|
247
|
+
}
|
|
248
|
+
if (server.url !== void 0) unsupportedProfileField(`mcp.${name}.url`);
|
|
249
|
+
if (server.headers !== void 0) unsupportedProfileField(`mcp.${name}.headers`);
|
|
250
|
+
if (server.metadata !== void 0) unsupportedProfileField(`mcp.${name}.metadata`);
|
|
251
|
+
return [
|
|
252
|
+
name,
|
|
253
|
+
{
|
|
254
|
+
...server.transport ? { transport: server.transport } : {},
|
|
255
|
+
...server.command ? { command: server.command } : {},
|
|
256
|
+
...server.args ? { args: server.args.map(candidatePublicValue) } : {},
|
|
257
|
+
...server.env ? { env: mapCandidatePublicValues(server.env) } : {},
|
|
258
|
+
...server.cwd ? { cwd: server.cwd } : {},
|
|
259
|
+
...server.enabled === void 0 ? {} : { enabled: server.enabled }
|
|
260
|
+
}
|
|
261
|
+
];
|
|
262
|
+
})
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
function freezeResources(resources) {
|
|
266
|
+
if (resources.failOnError !== true) {
|
|
267
|
+
throw new Error("candidate profile resources require failOnError: true");
|
|
268
|
+
}
|
|
269
|
+
return {
|
|
270
|
+
failOnError: true,
|
|
271
|
+
...resources.files ? {
|
|
272
|
+
files: resources.files.map((file) => ({
|
|
273
|
+
...file,
|
|
274
|
+
resource: freezeResource(file.resource)
|
|
275
|
+
}))
|
|
276
|
+
} : {},
|
|
277
|
+
...resources.tools ? { tools: resources.tools.map(freezeResource) } : {},
|
|
278
|
+
...resources.skills ? { skills: resources.skills.map(freezeResource) } : {},
|
|
279
|
+
...resources.agents ? { agents: resources.agents.map(freezeResource) } : {},
|
|
280
|
+
...resources.commands ? { commands: resources.commands.map(freezeResource) } : {},
|
|
281
|
+
...resources.instructions === void 0 ? {} : {
|
|
282
|
+
instructions: typeof resources.instructions === "string" ? resources.instructions : freezeResource(resources.instructions)
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function freezeResource(resource) {
|
|
287
|
+
if (resource.kind === "github") {
|
|
288
|
+
throw new Error(
|
|
289
|
+
"generic GitHub profile resources do not carry byte identity; use a candidate-profile source with a pinned commit, digest, and byte length"
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
const bytes = Buffer.from(resource.content, "utf8");
|
|
293
|
+
return {
|
|
294
|
+
...resource,
|
|
295
|
+
sha256: embeddedCandidateArtifact(bytes).sha256,
|
|
296
|
+
byteLength: bytes.byteLength
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function copyDirectProfileFields(target, source) {
|
|
300
|
+
for (const key of CANDIDATE_PROFILE_DIRECT_FIELDS) {
|
|
301
|
+
if (source[key] !== void 0) target[key] = source[key];
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
function assertCanonicalParse(input, parsed, label) {
|
|
305
|
+
if (!Buffer.from(canonicalCandidateBytes(input)).equals(canonicalCandidateBytes(parsed))) {
|
|
306
|
+
throw new Error(`${label} contains unsupported or non-canonical fields`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function publicResource(resource) {
|
|
310
|
+
if (resource.kind === "inline") {
|
|
311
|
+
return { kind: "inline", name: resource.name, content: resource.content };
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
kind: "github",
|
|
315
|
+
repository: `${resource.repository.owner}/${resource.repository.repo}`,
|
|
316
|
+
path: resource.path,
|
|
317
|
+
ref: resource.commit,
|
|
318
|
+
...resource.name ? { name: resource.name } : {}
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function candidatePublicValue(value) {
|
|
322
|
+
return { kind: "public", value };
|
|
323
|
+
}
|
|
324
|
+
function mapCandidatePublicValues(values) {
|
|
325
|
+
return Object.fromEntries(
|
|
326
|
+
Object.entries(values).map(([name, value]) => [name, candidatePublicValue(value)])
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
function publicValue(value) {
|
|
330
|
+
return value.value;
|
|
331
|
+
}
|
|
332
|
+
function mapPublicValues(values) {
|
|
333
|
+
return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, publicValue(value)]));
|
|
334
|
+
}
|
|
335
|
+
function cloneRecord(values) {
|
|
336
|
+
return Object.fromEntries(
|
|
337
|
+
Object.entries(values).map(([key, value]) => [key, { ...value }])
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
function hasEntries(value) {
|
|
341
|
+
return value !== void 0 && value !== null && typeof value === "object" ? Object.keys(value).length > 0 : false;
|
|
342
|
+
}
|
|
343
|
+
function shellQuote(value) {
|
|
344
|
+
return /^[A-Za-z0-9_./:@%+=,-]+$/.test(value) ? value : `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
345
|
+
}
|
|
346
|
+
function unsupportedProfileField(path) {
|
|
347
|
+
throw new Error(
|
|
348
|
+
`generic AgentProfile field ${path} is not representable in a sealed candidate profile`
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
|
|
75
352
|
// src/candidate-execution/types.ts
|
|
76
353
|
var verifiedCandidateBrand = /* @__PURE__ */ Symbol("verifiedAgentCandidate");
|
|
77
354
|
var preparedCandidateBrand = /* @__PURE__ */ Symbol("preparedAgentCandidate");
|
|
@@ -4028,255 +4305,6 @@ import {
|
|
|
4028
4305
|
applyAgentCandidateWorkspacePlan,
|
|
4029
4306
|
materializeCandidateProfile
|
|
4030
4307
|
} from "@tangle-network/agent-profile-materialize";
|
|
4031
|
-
|
|
4032
|
-
// src/candidate-execution/profile.ts
|
|
4033
|
-
import { agentCandidateProfileSchema, agentProfileSchema } from "@tangle-network/agent-interface";
|
|
4034
|
-
var CANDIDATE_PROFILE_DIRECT_FIELDS = [
|
|
4035
|
-
"name",
|
|
4036
|
-
"description",
|
|
4037
|
-
"version",
|
|
4038
|
-
"tags",
|
|
4039
|
-
"prompt",
|
|
4040
|
-
"harness",
|
|
4041
|
-
"permissions",
|
|
4042
|
-
"tools",
|
|
4043
|
-
"confidential"
|
|
4044
|
-
];
|
|
4045
|
-
function freezeGenericAgentCandidateProfile(input) {
|
|
4046
|
-
const profile = parseExactAgentProfile(input, "profile");
|
|
4047
|
-
if (profile.connections !== void 0) unsupportedProfileField("connections");
|
|
4048
|
-
if (profile.metadata !== void 0) unsupportedProfileField("metadata");
|
|
4049
|
-
if (profile.extensions !== void 0) unsupportedProfileField("extensions");
|
|
4050
|
-
if (profile.model?.metadata !== void 0) unsupportedProfileField("model.metadata");
|
|
4051
|
-
const candidate = {};
|
|
4052
|
-
copyDirectProfileFields(candidate, profile);
|
|
4053
|
-
if (profile.model) {
|
|
4054
|
-
const { metadata: _metadata, ...model } = profile.model;
|
|
4055
|
-
candidate.model = model;
|
|
4056
|
-
}
|
|
4057
|
-
if (profile.mcp) candidate.mcp = freezeMcpServers(profile.mcp);
|
|
4058
|
-
if (profile.subagents) {
|
|
4059
|
-
candidate.subagents = Object.fromEntries(
|
|
4060
|
-
Object.entries(profile.subagents).map(([name, subagent]) => {
|
|
4061
|
-
if (subagent.metadata !== void 0) unsupportedProfileField(`subagents.${name}.metadata`);
|
|
4062
|
-
const { metadata: _metadata, ...value } = subagent;
|
|
4063
|
-
return [name, value];
|
|
4064
|
-
})
|
|
4065
|
-
);
|
|
4066
|
-
}
|
|
4067
|
-
if (profile.resources) candidate.resources = freezeResources(profile.resources);
|
|
4068
|
-
if (profile.hooks && Object.values(profile.hooks).some((commands) => commands.length > 0)) {
|
|
4069
|
-
throw new Error(
|
|
4070
|
-
"generic AgentProfile hooks cannot be safely tokenized; use a candidate-profile source with executable/args"
|
|
4071
|
-
);
|
|
4072
|
-
}
|
|
4073
|
-
if (profile.hooks) candidate.hooks = profile.hooks;
|
|
4074
|
-
if (profile.modes) {
|
|
4075
|
-
candidate.modes = Object.fromEntries(
|
|
4076
|
-
Object.entries(profile.modes).map(([name, mode]) => {
|
|
4077
|
-
if (mode.metadata !== void 0) unsupportedProfileField(`modes.${name}.metadata`);
|
|
4078
|
-
const { metadata: _metadata, ...value } = mode;
|
|
4079
|
-
return [name, value];
|
|
4080
|
-
})
|
|
4081
|
-
);
|
|
4082
|
-
}
|
|
4083
|
-
const parsed = parseExactCandidateProfile(candidate);
|
|
4084
|
-
assertCandidateProfileBinding(profile, parsed);
|
|
4085
|
-
return parsed;
|
|
4086
|
-
}
|
|
4087
|
-
function assertCandidateProfileBinding(measuredInput, bundled) {
|
|
4088
|
-
const measured = parseExactAgentProfile(measuredInput, "proposal candidate profile");
|
|
4089
|
-
if (measured.connections || measured.metadata || measured.extensions) {
|
|
4090
|
-
throw new Error("proposal candidate profile contains fields unsupported by sealed candidates");
|
|
4091
|
-
}
|
|
4092
|
-
const normalized = candidateProfileAsAgentProfile(bundled);
|
|
4093
|
-
if (canonicalCandidateDigest(measured) !== canonicalCandidateDigest(normalized)) {
|
|
4094
|
-
throw new Error("proposal candidateProfile does not match candidateBundle.profile");
|
|
4095
|
-
}
|
|
4096
|
-
}
|
|
4097
|
-
function parseExactAgentProfile(input, label) {
|
|
4098
|
-
const parsed = agentProfileSchema.parse(input);
|
|
4099
|
-
assertCanonicalParse(input, parsed, label);
|
|
4100
|
-
return parsed;
|
|
4101
|
-
}
|
|
4102
|
-
function parseExactCandidateProfile(input) {
|
|
4103
|
-
const parsed = agentCandidateProfileSchema.parse(input);
|
|
4104
|
-
assertCanonicalParse(input, parsed, "candidate profile");
|
|
4105
|
-
return parsed;
|
|
4106
|
-
}
|
|
4107
|
-
function assertCandidateProfileExecutionSupport(profile) {
|
|
4108
|
-
const fields = ["tools", "permissions", "modes", "confidential"];
|
|
4109
|
-
const unsupported = fields.filter((field) => hasEntries(profile[field]));
|
|
4110
|
-
if (unsupported.length > 0) {
|
|
4111
|
-
throw new Error(
|
|
4112
|
-
`candidate execution cannot prove in-session effects for non-empty AgentProfile fields: ${unsupported.join(", ")}`
|
|
4113
|
-
);
|
|
4114
|
-
}
|
|
4115
|
-
}
|
|
4116
|
-
function candidateProfileAsAgentProfile(candidate) {
|
|
4117
|
-
const output = {};
|
|
4118
|
-
copyDirectProfileFields(output, candidate);
|
|
4119
|
-
if (candidate.model) output.model = { ...candidate.model };
|
|
4120
|
-
if (candidate.mcp) {
|
|
4121
|
-
output.mcp = Object.fromEntries(
|
|
4122
|
-
Object.entries(candidate.mcp).map(([name, server]) => [
|
|
4123
|
-
name,
|
|
4124
|
-
{
|
|
4125
|
-
...server,
|
|
4126
|
-
...server.args ? { args: server.args.map(publicValue) } : {},
|
|
4127
|
-
...server.env ? { env: mapPublicValues(server.env) } : {}
|
|
4128
|
-
}
|
|
4129
|
-
])
|
|
4130
|
-
);
|
|
4131
|
-
}
|
|
4132
|
-
if (candidate.subagents) output.subagents = cloneRecord(candidate.subagents);
|
|
4133
|
-
if (candidate.modes) output.modes = cloneRecord(candidate.modes);
|
|
4134
|
-
if (candidate.hooks) {
|
|
4135
|
-
output.hooks = Object.fromEntries(
|
|
4136
|
-
Object.entries(candidate.hooks).map(([event, hooks]) => [
|
|
4137
|
-
event,
|
|
4138
|
-
hooks.map(({ executable, args, env, ...hook }) => ({
|
|
4139
|
-
...hook,
|
|
4140
|
-
command: [executable, ...(args ?? []).map(publicValue)].map(shellQuote).join(" "),
|
|
4141
|
-
...env ? { env: mapPublicValues(env) } : {}
|
|
4142
|
-
}))
|
|
4143
|
-
])
|
|
4144
|
-
);
|
|
4145
|
-
}
|
|
4146
|
-
if (candidate.resources) {
|
|
4147
|
-
if (candidate.resources.failOnError !== true) {
|
|
4148
|
-
throw new Error("proposal candidate profile contains fields unsupported by sealed candidates");
|
|
4149
|
-
}
|
|
4150
|
-
output.resources = {
|
|
4151
|
-
failOnError: true,
|
|
4152
|
-
...candidate.resources.files ? {
|
|
4153
|
-
files: candidate.resources.files.map((file) => ({
|
|
4154
|
-
...file,
|
|
4155
|
-
resource: publicResource(file.resource)
|
|
4156
|
-
}))
|
|
4157
|
-
} : {},
|
|
4158
|
-
...candidate.resources.tools ? { tools: candidate.resources.tools.map(publicResource) } : {},
|
|
4159
|
-
...candidate.resources.skills ? { skills: candidate.resources.skills.map(publicResource) } : {},
|
|
4160
|
-
...candidate.resources.agents ? { agents: candidate.resources.agents.map(publicResource) } : {},
|
|
4161
|
-
...candidate.resources.commands ? { commands: candidate.resources.commands.map(publicResource) } : {},
|
|
4162
|
-
...candidate.resources.instructions !== void 0 ? {
|
|
4163
|
-
instructions: typeof candidate.resources.instructions === "string" ? candidate.resources.instructions : publicResource(candidate.resources.instructions)
|
|
4164
|
-
} : {}
|
|
4165
|
-
};
|
|
4166
|
-
}
|
|
4167
|
-
return output;
|
|
4168
|
-
}
|
|
4169
|
-
function freezeMcpServers(servers) {
|
|
4170
|
-
return Object.fromEntries(
|
|
4171
|
-
Object.entries(servers).map(([name, server]) => {
|
|
4172
|
-
if (server.transport !== void 0 && server.transport !== "stdio") {
|
|
4173
|
-
unsupportedProfileField(`mcp.${name}.transport=${server.transport}`);
|
|
4174
|
-
}
|
|
4175
|
-
if (server.url !== void 0) unsupportedProfileField(`mcp.${name}.url`);
|
|
4176
|
-
if (server.headers !== void 0) unsupportedProfileField(`mcp.${name}.headers`);
|
|
4177
|
-
if (server.metadata !== void 0) unsupportedProfileField(`mcp.${name}.metadata`);
|
|
4178
|
-
return [
|
|
4179
|
-
name,
|
|
4180
|
-
{
|
|
4181
|
-
...server.transport ? { transport: server.transport } : {},
|
|
4182
|
-
...server.command ? { command: server.command } : {},
|
|
4183
|
-
...server.args ? { args: server.args.map(candidatePublicValue) } : {},
|
|
4184
|
-
...server.env ? { env: mapCandidatePublicValues(server.env) } : {},
|
|
4185
|
-
...server.cwd ? { cwd: server.cwd } : {},
|
|
4186
|
-
...server.enabled === void 0 ? {} : { enabled: server.enabled }
|
|
4187
|
-
}
|
|
4188
|
-
];
|
|
4189
|
-
})
|
|
4190
|
-
);
|
|
4191
|
-
}
|
|
4192
|
-
function freezeResources(resources) {
|
|
4193
|
-
if (resources.failOnError !== true) {
|
|
4194
|
-
throw new Error("candidate profile resources require failOnError: true");
|
|
4195
|
-
}
|
|
4196
|
-
return {
|
|
4197
|
-
failOnError: true,
|
|
4198
|
-
...resources.files ? {
|
|
4199
|
-
files: resources.files.map((file) => ({
|
|
4200
|
-
...file,
|
|
4201
|
-
resource: freezeResource(file.resource)
|
|
4202
|
-
}))
|
|
4203
|
-
} : {},
|
|
4204
|
-
...resources.tools ? { tools: resources.tools.map(freezeResource) } : {},
|
|
4205
|
-
...resources.skills ? { skills: resources.skills.map(freezeResource) } : {},
|
|
4206
|
-
...resources.agents ? { agents: resources.agents.map(freezeResource) } : {},
|
|
4207
|
-
...resources.commands ? { commands: resources.commands.map(freezeResource) } : {},
|
|
4208
|
-
...resources.instructions === void 0 ? {} : {
|
|
4209
|
-
instructions: typeof resources.instructions === "string" ? resources.instructions : freezeResource(resources.instructions)
|
|
4210
|
-
}
|
|
4211
|
-
};
|
|
4212
|
-
}
|
|
4213
|
-
function freezeResource(resource) {
|
|
4214
|
-
if (resource.kind === "github") {
|
|
4215
|
-
throw new Error(
|
|
4216
|
-
"generic GitHub profile resources do not carry byte identity; use a candidate-profile source with a pinned commit, digest, and byte length"
|
|
4217
|
-
);
|
|
4218
|
-
}
|
|
4219
|
-
const bytes = Buffer.from(resource.content, "utf8");
|
|
4220
|
-
return {
|
|
4221
|
-
...resource,
|
|
4222
|
-
sha256: embeddedCandidateArtifact(bytes).sha256,
|
|
4223
|
-
byteLength: bytes.byteLength
|
|
4224
|
-
};
|
|
4225
|
-
}
|
|
4226
|
-
function copyDirectProfileFields(target, source) {
|
|
4227
|
-
for (const key of CANDIDATE_PROFILE_DIRECT_FIELDS) {
|
|
4228
|
-
if (source[key] !== void 0) target[key] = source[key];
|
|
4229
|
-
}
|
|
4230
|
-
}
|
|
4231
|
-
function assertCanonicalParse(input, parsed, label) {
|
|
4232
|
-
if (!Buffer.from(canonicalCandidateBytes(input)).equals(canonicalCandidateBytes(parsed))) {
|
|
4233
|
-
throw new Error(`${label} contains unsupported or non-canonical fields`);
|
|
4234
|
-
}
|
|
4235
|
-
}
|
|
4236
|
-
function publicResource(resource) {
|
|
4237
|
-
if (resource.kind === "inline") {
|
|
4238
|
-
return { kind: "inline", name: resource.name, content: resource.content };
|
|
4239
|
-
}
|
|
4240
|
-
return {
|
|
4241
|
-
kind: "github",
|
|
4242
|
-
repository: `${resource.repository.owner}/${resource.repository.repo}`,
|
|
4243
|
-
path: resource.path,
|
|
4244
|
-
ref: resource.commit,
|
|
4245
|
-
...resource.name ? { name: resource.name } : {}
|
|
4246
|
-
};
|
|
4247
|
-
}
|
|
4248
|
-
function candidatePublicValue(value) {
|
|
4249
|
-
return { kind: "public", value };
|
|
4250
|
-
}
|
|
4251
|
-
function mapCandidatePublicValues(values) {
|
|
4252
|
-
return Object.fromEntries(
|
|
4253
|
-
Object.entries(values).map(([name, value]) => [name, candidatePublicValue(value)])
|
|
4254
|
-
);
|
|
4255
|
-
}
|
|
4256
|
-
function publicValue(value) {
|
|
4257
|
-
return value.value;
|
|
4258
|
-
}
|
|
4259
|
-
function mapPublicValues(values) {
|
|
4260
|
-
return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, publicValue(value)]));
|
|
4261
|
-
}
|
|
4262
|
-
function cloneRecord(values) {
|
|
4263
|
-
return Object.fromEntries(
|
|
4264
|
-
Object.entries(values).map(([key, value]) => [key, { ...value }])
|
|
4265
|
-
);
|
|
4266
|
-
}
|
|
4267
|
-
function hasEntries(value) {
|
|
4268
|
-
return value !== void 0 && value !== null && typeof value === "object" ? Object.keys(value).length > 0 : false;
|
|
4269
|
-
}
|
|
4270
|
-
function shellQuote(value) {
|
|
4271
|
-
return /^[A-Za-z0-9_./:@%+=,-]+$/.test(value) ? value : `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
4272
|
-
}
|
|
4273
|
-
function unsupportedProfileField(path) {
|
|
4274
|
-
throw new Error(
|
|
4275
|
-
`generic AgentProfile field ${path} is not representable in a sealed candidate profile`
|
|
4276
|
-
);
|
|
4277
|
-
}
|
|
4278
|
-
|
|
4279
|
-
// src/candidate-execution/prepare.ts
|
|
4280
4308
|
var MATERIALIZER_HARNESSES = /* @__PURE__ */ new Set([
|
|
4281
4309
|
"claude-code",
|
|
4282
4310
|
"claude",
|
|
@@ -5014,6 +5042,8 @@ export {
|
|
|
5014
5042
|
freezeGenericAgentCandidateProfile,
|
|
5015
5043
|
assertCandidateProfileBinding,
|
|
5016
5044
|
parseExactAgentProfile,
|
|
5045
|
+
parseExactAgentProfileDiff,
|
|
5046
|
+
applyExactAgentProfileDiff,
|
|
5017
5047
|
parseExactCandidateProfile,
|
|
5018
5048
|
CLAIM_FORMAT_VERSION,
|
|
5019
5049
|
PENDING_FORMAT_VERSION,
|
|
@@ -5051,4 +5081,4 @@ export {
|
|
|
5051
5081
|
verifyAgentCandidateBundle,
|
|
5052
5082
|
prepareAgentCandidateExecution
|
|
5053
5083
|
};
|
|
5054
|
-
//# sourceMappingURL=chunk-
|
|
5084
|
+
//# sourceMappingURL=chunk-7I2AOKCI.js.map
|