@tangle-network/agent-runtime 0.93.0 → 0.93.1
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/dist/candidate-execution/index.js +2 -2
- package/dist/{chunk-26WCEARH.js → chunk-OX3QRJOA.js} +251 -236
- package/dist/{chunk-26WCEARH.js.map → chunk-OX3QRJOA.js.map} +1 -1
- package/dist/{chunk-3VU2OWOY.js → chunk-XDSWWUKE.js} +2 -2
- package/dist/index.js +2 -2
- package/dist/intelligence.js +1 -1
- package/package.json +1 -1
- /package/dist/{chunk-3VU2OWOY.js.map → chunk-XDSWWUKE.js.map} +0 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createProtectedAgentCandidateModelPort,
|
|
5
5
|
disposePreparedAgentCandidateExecution,
|
|
6
6
|
recoverExpiredAgentCandidateExecution
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-XDSWWUKE.js";
|
|
8
8
|
import {
|
|
9
9
|
CANDIDATE_TRACE_ENV,
|
|
10
10
|
CANDIDATE_TRACE_TAGS,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
prepareAgentCandidateExecution,
|
|
16
16
|
sealAgentCandidateBundle,
|
|
17
17
|
verifyAgentCandidateBundle
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-OX3QRJOA.js";
|
|
19
19
|
import "../chunk-3D2RHC4K.js";
|
|
20
20
|
import "../chunk-3MDZX7YU.js";
|
|
21
21
|
import "../chunk-DGUM43GV.js";
|
|
@@ -4028,6 +4028,255 @@ import {
|
|
|
4028
4028
|
applyAgentCandidateWorkspacePlan,
|
|
4029
4029
|
materializeCandidateProfile
|
|
4030
4030
|
} 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
|
|
4031
4280
|
var MATERIALIZER_HARNESSES = /* @__PURE__ */ new Set([
|
|
4032
4281
|
"claude-code",
|
|
4033
4282
|
"claude",
|
|
@@ -4049,6 +4298,7 @@ async function prepareAgentCandidateExecution(candidate, task, ports, options =
|
|
|
4049
4298
|
const verifiedState = getVerifiedCandidateState(candidate);
|
|
4050
4299
|
assertSameVerificationPorts(verifiedState.ports, ports);
|
|
4051
4300
|
const bundle = candidate.bundle;
|
|
4301
|
+
assertCandidateProfileExecutionSupport(bundle.profile);
|
|
4052
4302
|
const harness = materializerHarness(bundle.execution.harness);
|
|
4053
4303
|
assertTaskInput(task, bundle.execution.instructionDelivery);
|
|
4054
4304
|
const resultTimeoutMs = candidateResultTimeout(options.resultTimeoutMs, task.limits.timeoutMs);
|
|
@@ -4753,241 +5003,6 @@ function errorMessage2(error) {
|
|
|
4753
5003
|
return error instanceof Error ? error.message : String(error);
|
|
4754
5004
|
}
|
|
4755
5005
|
|
|
4756
|
-
// src/candidate-execution/profile.ts
|
|
4757
|
-
import { agentCandidateProfileSchema, agentProfileSchema } from "@tangle-network/agent-interface";
|
|
4758
|
-
var CANDIDATE_PROFILE_DIRECT_FIELDS = [
|
|
4759
|
-
"name",
|
|
4760
|
-
"description",
|
|
4761
|
-
"version",
|
|
4762
|
-
"tags",
|
|
4763
|
-
"prompt",
|
|
4764
|
-
"harness",
|
|
4765
|
-
"permissions",
|
|
4766
|
-
"tools",
|
|
4767
|
-
"confidential"
|
|
4768
|
-
];
|
|
4769
|
-
function freezeGenericAgentCandidateProfile(input) {
|
|
4770
|
-
const profile = parseExactAgentProfile(input, "profile");
|
|
4771
|
-
if (profile.connections !== void 0) unsupportedProfileField("connections");
|
|
4772
|
-
if (profile.metadata !== void 0) unsupportedProfileField("metadata");
|
|
4773
|
-
if (profile.extensions !== void 0) unsupportedProfileField("extensions");
|
|
4774
|
-
if (profile.model?.metadata !== void 0) unsupportedProfileField("model.metadata");
|
|
4775
|
-
const candidate = {};
|
|
4776
|
-
copyDirectProfileFields(candidate, profile);
|
|
4777
|
-
if (profile.model) {
|
|
4778
|
-
const { metadata: _metadata, ...model } = profile.model;
|
|
4779
|
-
candidate.model = model;
|
|
4780
|
-
}
|
|
4781
|
-
if (profile.mcp) candidate.mcp = freezeMcpServers(profile.mcp);
|
|
4782
|
-
if (profile.subagents) {
|
|
4783
|
-
candidate.subagents = Object.fromEntries(
|
|
4784
|
-
Object.entries(profile.subagents).map(([name, subagent]) => {
|
|
4785
|
-
if (subagent.metadata !== void 0) unsupportedProfileField(`subagents.${name}.metadata`);
|
|
4786
|
-
const { metadata: _metadata, ...value } = subagent;
|
|
4787
|
-
return [name, value];
|
|
4788
|
-
})
|
|
4789
|
-
);
|
|
4790
|
-
}
|
|
4791
|
-
if (profile.resources) candidate.resources = freezeResources(profile.resources);
|
|
4792
|
-
if (profile.hooks && Object.values(profile.hooks).some((commands) => commands.length > 0)) {
|
|
4793
|
-
throw new Error(
|
|
4794
|
-
"generic AgentProfile hooks cannot be safely tokenized; use a candidate-profile source with executable/args"
|
|
4795
|
-
);
|
|
4796
|
-
}
|
|
4797
|
-
if (profile.hooks) candidate.hooks = profile.hooks;
|
|
4798
|
-
if (profile.modes) {
|
|
4799
|
-
candidate.modes = Object.fromEntries(
|
|
4800
|
-
Object.entries(profile.modes).map(([name, mode]) => {
|
|
4801
|
-
if (mode.metadata !== void 0) unsupportedProfileField(`modes.${name}.metadata`);
|
|
4802
|
-
const { metadata: _metadata, ...value } = mode;
|
|
4803
|
-
return [name, value];
|
|
4804
|
-
})
|
|
4805
|
-
);
|
|
4806
|
-
}
|
|
4807
|
-
const parsed = parseExactCandidateProfile(candidate);
|
|
4808
|
-
assertCandidateProfileBinding(profile, parsed);
|
|
4809
|
-
return parsed;
|
|
4810
|
-
}
|
|
4811
|
-
function assertCandidateProfileBinding(measuredInput, bundled) {
|
|
4812
|
-
const measured = parseExactAgentProfile(measuredInput, "proposal candidate profile");
|
|
4813
|
-
if (measured.connections || measured.metadata || measured.extensions) {
|
|
4814
|
-
throw new Error("proposal candidate profile contains fields unsupported by sealed candidates");
|
|
4815
|
-
}
|
|
4816
|
-
const normalized = candidateProfileAsAgentProfile(bundled);
|
|
4817
|
-
if (canonicalCandidateDigest(measured) !== canonicalCandidateDigest(normalized)) {
|
|
4818
|
-
throw new Error("proposal candidateProfile does not match candidateBundle.profile");
|
|
4819
|
-
}
|
|
4820
|
-
}
|
|
4821
|
-
function parseExactAgentProfile(input, label) {
|
|
4822
|
-
const parsed = agentProfileSchema.parse(input);
|
|
4823
|
-
assertCanonicalParse(input, parsed, label);
|
|
4824
|
-
return parsed;
|
|
4825
|
-
}
|
|
4826
|
-
function parseExactCandidateProfile(input) {
|
|
4827
|
-
const parsed = agentCandidateProfileSchema.parse(input);
|
|
4828
|
-
assertCanonicalParse(input, parsed, "candidate profile");
|
|
4829
|
-
return parsed;
|
|
4830
|
-
}
|
|
4831
|
-
function candidateProfileAsAgentProfile(candidate) {
|
|
4832
|
-
const output = {};
|
|
4833
|
-
copyDirectProfileFields(output, candidate);
|
|
4834
|
-
if (candidate.model) output.model = { ...candidate.model };
|
|
4835
|
-
if (candidate.mcp) {
|
|
4836
|
-
output.mcp = Object.fromEntries(
|
|
4837
|
-
Object.entries(candidate.mcp).map(([name, server]) => [
|
|
4838
|
-
name,
|
|
4839
|
-
{
|
|
4840
|
-
...server,
|
|
4841
|
-
...server.args ? { args: server.args.map(publicValue) } : {},
|
|
4842
|
-
...server.env ? { env: mapPublicValues(server.env) } : {}
|
|
4843
|
-
}
|
|
4844
|
-
])
|
|
4845
|
-
);
|
|
4846
|
-
}
|
|
4847
|
-
if (candidate.subagents) output.subagents = cloneRecord(candidate.subagents);
|
|
4848
|
-
if (candidate.modes) output.modes = cloneRecord(candidate.modes);
|
|
4849
|
-
if (candidate.hooks) {
|
|
4850
|
-
output.hooks = Object.fromEntries(
|
|
4851
|
-
Object.entries(candidate.hooks).map(([event, hooks]) => [
|
|
4852
|
-
event,
|
|
4853
|
-
hooks.map(({ executable, args, env, ...hook }) => ({
|
|
4854
|
-
...hook,
|
|
4855
|
-
command: [executable, ...(args ?? []).map(publicValue)].map(shellQuote).join(" "),
|
|
4856
|
-
...env ? { env: mapPublicValues(env) } : {}
|
|
4857
|
-
}))
|
|
4858
|
-
])
|
|
4859
|
-
);
|
|
4860
|
-
}
|
|
4861
|
-
if (candidate.resources) {
|
|
4862
|
-
if (candidate.resources.failOnError !== true) {
|
|
4863
|
-
throw new Error("proposal candidate profile contains fields unsupported by sealed candidates");
|
|
4864
|
-
}
|
|
4865
|
-
output.resources = {
|
|
4866
|
-
failOnError: true,
|
|
4867
|
-
...candidate.resources.files ? {
|
|
4868
|
-
files: candidate.resources.files.map((file) => ({
|
|
4869
|
-
...file,
|
|
4870
|
-
resource: publicResource(file.resource)
|
|
4871
|
-
}))
|
|
4872
|
-
} : {},
|
|
4873
|
-
...candidate.resources.tools ? { tools: candidate.resources.tools.map(publicResource) } : {},
|
|
4874
|
-
...candidate.resources.skills ? { skills: candidate.resources.skills.map(publicResource) } : {},
|
|
4875
|
-
...candidate.resources.agents ? { agents: candidate.resources.agents.map(publicResource) } : {},
|
|
4876
|
-
...candidate.resources.commands ? { commands: candidate.resources.commands.map(publicResource) } : {},
|
|
4877
|
-
...candidate.resources.instructions !== void 0 ? {
|
|
4878
|
-
instructions: typeof candidate.resources.instructions === "string" ? candidate.resources.instructions : publicResource(candidate.resources.instructions)
|
|
4879
|
-
} : {}
|
|
4880
|
-
};
|
|
4881
|
-
}
|
|
4882
|
-
return output;
|
|
4883
|
-
}
|
|
4884
|
-
function freezeMcpServers(servers) {
|
|
4885
|
-
return Object.fromEntries(
|
|
4886
|
-
Object.entries(servers).map(([name, server]) => {
|
|
4887
|
-
if (server.transport !== void 0 && server.transport !== "stdio") {
|
|
4888
|
-
unsupportedProfileField(`mcp.${name}.transport=${server.transport}`);
|
|
4889
|
-
}
|
|
4890
|
-
if (server.url !== void 0) unsupportedProfileField(`mcp.${name}.url`);
|
|
4891
|
-
if (server.headers !== void 0) unsupportedProfileField(`mcp.${name}.headers`);
|
|
4892
|
-
if (server.metadata !== void 0) unsupportedProfileField(`mcp.${name}.metadata`);
|
|
4893
|
-
return [
|
|
4894
|
-
name,
|
|
4895
|
-
{
|
|
4896
|
-
...server.transport ? { transport: server.transport } : {},
|
|
4897
|
-
...server.command ? { command: server.command } : {},
|
|
4898
|
-
...server.args ? { args: server.args.map(candidatePublicValue) } : {},
|
|
4899
|
-
...server.env ? { env: mapCandidatePublicValues(server.env) } : {},
|
|
4900
|
-
...server.cwd ? { cwd: server.cwd } : {},
|
|
4901
|
-
...server.enabled === void 0 ? {} : { enabled: server.enabled }
|
|
4902
|
-
}
|
|
4903
|
-
];
|
|
4904
|
-
})
|
|
4905
|
-
);
|
|
4906
|
-
}
|
|
4907
|
-
function freezeResources(resources) {
|
|
4908
|
-
if (resources.failOnError !== true) {
|
|
4909
|
-
throw new Error("candidate profile resources require failOnError: true");
|
|
4910
|
-
}
|
|
4911
|
-
return {
|
|
4912
|
-
failOnError: true,
|
|
4913
|
-
...resources.files ? {
|
|
4914
|
-
files: resources.files.map((file) => ({
|
|
4915
|
-
...file,
|
|
4916
|
-
resource: freezeResource(file.resource)
|
|
4917
|
-
}))
|
|
4918
|
-
} : {},
|
|
4919
|
-
...resources.tools ? { tools: resources.tools.map(freezeResource) } : {},
|
|
4920
|
-
...resources.skills ? { skills: resources.skills.map(freezeResource) } : {},
|
|
4921
|
-
...resources.agents ? { agents: resources.agents.map(freezeResource) } : {},
|
|
4922
|
-
...resources.commands ? { commands: resources.commands.map(freezeResource) } : {},
|
|
4923
|
-
...resources.instructions === void 0 ? {} : {
|
|
4924
|
-
instructions: typeof resources.instructions === "string" ? resources.instructions : freezeResource(resources.instructions)
|
|
4925
|
-
}
|
|
4926
|
-
};
|
|
4927
|
-
}
|
|
4928
|
-
function freezeResource(resource) {
|
|
4929
|
-
if (resource.kind === "github") {
|
|
4930
|
-
throw new Error(
|
|
4931
|
-
"generic GitHub profile resources do not carry byte identity; use a candidate-profile source with a pinned commit, digest, and byte length"
|
|
4932
|
-
);
|
|
4933
|
-
}
|
|
4934
|
-
const bytes = Buffer.from(resource.content, "utf8");
|
|
4935
|
-
return {
|
|
4936
|
-
...resource,
|
|
4937
|
-
sha256: embeddedCandidateArtifact(bytes).sha256,
|
|
4938
|
-
byteLength: bytes.byteLength
|
|
4939
|
-
};
|
|
4940
|
-
}
|
|
4941
|
-
function copyDirectProfileFields(target, source) {
|
|
4942
|
-
for (const key of CANDIDATE_PROFILE_DIRECT_FIELDS) {
|
|
4943
|
-
if (source[key] !== void 0) target[key] = source[key];
|
|
4944
|
-
}
|
|
4945
|
-
}
|
|
4946
|
-
function assertCanonicalParse(input, parsed, label) {
|
|
4947
|
-
if (!Buffer.from(canonicalCandidateBytes(input)).equals(canonicalCandidateBytes(parsed))) {
|
|
4948
|
-
throw new Error(`${label} contains unsupported or non-canonical fields`);
|
|
4949
|
-
}
|
|
4950
|
-
}
|
|
4951
|
-
function publicResource(resource) {
|
|
4952
|
-
if (resource.kind === "inline") {
|
|
4953
|
-
return { kind: "inline", name: resource.name, content: resource.content };
|
|
4954
|
-
}
|
|
4955
|
-
return {
|
|
4956
|
-
kind: "github",
|
|
4957
|
-
repository: `${resource.repository.owner}/${resource.repository.repo}`,
|
|
4958
|
-
path: resource.path,
|
|
4959
|
-
ref: resource.commit,
|
|
4960
|
-
...resource.name ? { name: resource.name } : {}
|
|
4961
|
-
};
|
|
4962
|
-
}
|
|
4963
|
-
function candidatePublicValue(value) {
|
|
4964
|
-
return { kind: "public", value };
|
|
4965
|
-
}
|
|
4966
|
-
function mapCandidatePublicValues(values) {
|
|
4967
|
-
return Object.fromEntries(
|
|
4968
|
-
Object.entries(values).map(([name, value]) => [name, candidatePublicValue(value)])
|
|
4969
|
-
);
|
|
4970
|
-
}
|
|
4971
|
-
function publicValue(value) {
|
|
4972
|
-
return value.value;
|
|
4973
|
-
}
|
|
4974
|
-
function mapPublicValues(values) {
|
|
4975
|
-
return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, publicValue(value)]));
|
|
4976
|
-
}
|
|
4977
|
-
function cloneRecord(values) {
|
|
4978
|
-
return Object.fromEntries(
|
|
4979
|
-
Object.entries(values).map(([key, value]) => [key, { ...value }])
|
|
4980
|
-
);
|
|
4981
|
-
}
|
|
4982
|
-
function shellQuote(value) {
|
|
4983
|
-
return /^[A-Za-z0-9_./:@%+=,-]+$/.test(value) ? value : `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
4984
|
-
}
|
|
4985
|
-
function unsupportedProfileField(path) {
|
|
4986
|
-
throw new Error(
|
|
4987
|
-
`generic AgentProfile field ${path} is not representable in a sealed candidate profile`
|
|
4988
|
-
);
|
|
4989
|
-
}
|
|
4990
|
-
|
|
4991
5006
|
export {
|
|
4992
5007
|
canonicalCandidateBytes,
|
|
4993
5008
|
canonicalCandidateDigest,
|
|
@@ -5036,4 +5051,4 @@ export {
|
|
|
5036
5051
|
verifyAgentCandidateBundle,
|
|
5037
5052
|
prepareAgentCandidateExecution
|
|
5038
5053
|
};
|
|
5039
|
-
//# sourceMappingURL=chunk-
|
|
5054
|
+
//# sourceMappingURL=chunk-OX3QRJOA.js.map
|