@tangle-network/agent-interface 0.37.0 → 0.39.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/dist/agent-candidate-execution-plan-schema.d.ts +50 -27
- package/dist/agent-candidate-execution-plan-schema.js +4 -16
- package/dist/agent-candidate-profile-schema.d.ts +5 -25
- package/dist/agent-candidate-promotion-schema.d.ts +280 -285
- package/dist/agent-candidate-receipt-schema.d.ts +50 -27
- package/dist/agent-candidate-schema.d.ts +5 -25
- package/dist/agent-candidate.d.ts +2 -8
- package/dist/agent-execution-preparation.d.ts +366 -0
- package/dist/agent-execution-preparation.js +736 -0
- package/dist/agent-profile-activation.d.ts +41 -0
- package/dist/agent-profile-activation.js +24 -0
- package/dist/agent-profile-canonical.d.ts +12 -0
- package/dist/agent-profile-canonical.js +79 -0
- package/dist/agent-profile-improvement-schema.d.ts +3 -6
- package/dist/agent-profile-improvement-schema.js +94 -56
- package/dist/agent-profile-improvement.d.ts +3 -3
- package/dist/agent-profile-materialization.d.ts +34 -0
- package/dist/agent-profile-materialization.js +243 -0
- package/dist/agent-profile.d.ts +44 -7
- package/dist/agent-profile.js +39 -2
- package/dist/agent-workspace-lease.d.ts +138 -0
- package/dist/agent-workspace-lease.js +203 -0
- package/dist/harness-capabilities.d.ts +1 -1
- package/dist/harness-capabilities.js +2 -9
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/profile-diff.d.ts +11 -0
- package/dist/profile-diff.js +123 -3
- package/dist/profile-schema.d.ts +142 -84
- package/dist/profile-schema.js +152 -41
- package/package.json +1 -1
package/dist/profile-schema.js
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { REASONING_EFFORTS, } from "./agent-profile.js";
|
|
3
|
+
import { environmentNameSchema, headerNameSchema, isSafeExecutable, isSafeRelativePath, isWellFormedUnicode, looksLikeCredential, } from "./agent-candidate-schema-common.js";
|
|
2
4
|
import { harnessTypeSchema } from "./harness.js";
|
|
3
5
|
import { SANDBOX_SIZE_PRESET_NAMES, } from "./sandbox-size.js";
|
|
6
|
+
/**
|
|
7
|
+
* Zod records currently assign parsed values onto an ordinary object. The
|
|
8
|
+
* special own key `__proto__` therefore invokes the legacy prototype setter
|
|
9
|
+
* and disappears instead of being validated. Encode every own key before Zod
|
|
10
|
+
* sees it, then restore the exact UTF-16 key with defineProperty so all string
|
|
11
|
+
* keys allowed by `Record<string, ...>` remain data rather than object syntax.
|
|
12
|
+
*/
|
|
13
|
+
function ownPropertyRecordSchema(valueSchema) {
|
|
14
|
+
return z.preprocess(encodeOwnRecordKeys, z.record(z
|
|
15
|
+
.string()
|
|
16
|
+
.regex(/^u(?:[0-9a-f]{4})*$/, "record keys must contain valid Unicode"), valueSchema).transform((record) => {
|
|
17
|
+
const restored = {};
|
|
18
|
+
for (const [encodedKey, value] of Object.entries(record)) {
|
|
19
|
+
Object.defineProperty(restored, decodeRecordKey(encodedKey), {
|
|
20
|
+
value,
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return restored;
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
function encodeOwnRecordKeys(value) {
|
|
30
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
const encoded = Object.create(null);
|
|
34
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
35
|
+
encoded[encodeRecordKey(key)] = entry;
|
|
36
|
+
}
|
|
37
|
+
return encoded;
|
|
38
|
+
}
|
|
39
|
+
function encodeRecordKey(value) {
|
|
40
|
+
let encoded = isWellFormedUnicode(value) ? "u" : "i";
|
|
41
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
42
|
+
encoded += value.charCodeAt(index).toString(16).padStart(4, "0");
|
|
43
|
+
}
|
|
44
|
+
return encoded;
|
|
45
|
+
}
|
|
46
|
+
function decodeRecordKey(value) {
|
|
47
|
+
let decoded = "";
|
|
48
|
+
for (let index = 1; index < value.length; index += 4) {
|
|
49
|
+
decoded += String.fromCharCode(Number.parseInt(value.slice(index, index + 4), 16));
|
|
50
|
+
}
|
|
51
|
+
return decoded;
|
|
52
|
+
}
|
|
4
53
|
export const agentProfilePermissionValueSchema = z.enum([
|
|
5
54
|
"allow",
|
|
6
55
|
"deny",
|
|
@@ -8,7 +57,7 @@ export const agentProfilePermissionValueSchema = z.enum([
|
|
|
8
57
|
]);
|
|
9
58
|
export const agentProfilePermissionSchema = z.union([
|
|
10
59
|
agentProfilePermissionValueSchema,
|
|
11
|
-
|
|
60
|
+
ownPropertyRecordSchema(agentProfilePermissionValueSchema),
|
|
12
61
|
]);
|
|
13
62
|
// Mirrors the canonical AgentProfileResourceRef (inline | github), kind-discriminated.
|
|
14
63
|
export const agentProfileResourceRefSchema = z.union([
|
|
@@ -41,49 +90,93 @@ export const agentProfileResourcesSchema = z.strictObject({
|
|
|
41
90
|
.optional(),
|
|
42
91
|
failOnError: z.boolean().optional(),
|
|
43
92
|
});
|
|
44
|
-
export const reasoningEffortSchema = z.enum(
|
|
45
|
-
"none",
|
|
46
|
-
"minimal",
|
|
47
|
-
"low",
|
|
48
|
-
"medium",
|
|
49
|
-
"high",
|
|
50
|
-
"xhigh",
|
|
51
|
-
"ultracode",
|
|
52
|
-
]);
|
|
93
|
+
export const reasoningEffortSchema = z.enum(REASONING_EFFORTS);
|
|
53
94
|
export const agentProfileModelHintsSchema = z.strictObject({
|
|
54
95
|
default: z.string().optional(),
|
|
55
96
|
small: z.string().optional(),
|
|
56
97
|
provider: z.string().optional(),
|
|
57
98
|
reasoningEffort: reasoningEffortSchema.optional(),
|
|
58
|
-
metadata:
|
|
99
|
+
metadata: ownPropertyRecordSchema(z.unknown()).optional(),
|
|
59
100
|
});
|
|
60
101
|
export const agentProfilePromptSchema = z.strictObject({
|
|
61
102
|
systemPrompt: z.string().optional(),
|
|
62
103
|
instructions: z.array(z.string()).optional(),
|
|
63
104
|
});
|
|
105
|
+
const controlCharacterPattern = /[\u0000-\u001f\u007f]/;
|
|
106
|
+
const secretCapableNamePattern = /(?:^|[_-])(?:api[_-]?key|access[_-]?key|private[_-]?key|token|secret|password|credentials?|authorization|cookie|database[_-]?url|dsn|pat)(?:[_-]|$)/i;
|
|
107
|
+
const publicProfileConfigStringSchema = z
|
|
108
|
+
.string()
|
|
109
|
+
.refine((value) => isWellFormedUnicode(value) &&
|
|
110
|
+
!controlCharacterPattern.test(value) &&
|
|
111
|
+
!looksLikeCredential(value), "public profile config cannot carry credential-like material");
|
|
112
|
+
const secretReferenceKeySchema = z
|
|
113
|
+
.string()
|
|
114
|
+
.min(1)
|
|
115
|
+
.max(500)
|
|
116
|
+
.refine((value) => value.trim().length > 0 &&
|
|
117
|
+
isWellFormedUnicode(value) &&
|
|
118
|
+
!controlCharacterPattern.test(value) &&
|
|
119
|
+
!looksLikeCredential(value), "secret reference key must be a public non-credential identity");
|
|
120
|
+
export const agentProfilePublicConfigValueSchema = z.strictObject({
|
|
121
|
+
kind: z.literal("public"),
|
|
122
|
+
value: publicProfileConfigStringSchema,
|
|
123
|
+
});
|
|
124
|
+
export const agentProfileSecretRefSchema = z.strictObject({
|
|
125
|
+
kind: z.literal("secret-ref"),
|
|
126
|
+
key: secretReferenceKeySchema,
|
|
127
|
+
format: z.enum(["raw", "bearer"]).optional(),
|
|
128
|
+
});
|
|
129
|
+
export const agentProfileConfigValueSchema = z.discriminatedUnion("kind", [
|
|
130
|
+
agentProfilePublicConfigValueSchema,
|
|
131
|
+
agentProfileSecretRefSchema,
|
|
132
|
+
]);
|
|
133
|
+
function profileConfigRecordSchema(keySchema) {
|
|
134
|
+
return ownPropertyRecordSchema(agentProfileConfigValueSchema).superRefine((record, context) => {
|
|
135
|
+
for (const [name, value] of Object.entries(record)) {
|
|
136
|
+
const keyResult = keySchema.safeParse(name);
|
|
137
|
+
if (!keyResult.success) {
|
|
138
|
+
context.addIssue({
|
|
139
|
+
code: "custom",
|
|
140
|
+
path: [name],
|
|
141
|
+
message: "profile config key is invalid for this field",
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
if (value.kind === "public" &&
|
|
145
|
+
secretCapableNamePattern.test(name)) {
|
|
146
|
+
context.addIssue({
|
|
147
|
+
code: "custom",
|
|
148
|
+
path: [name],
|
|
149
|
+
message: "credential-bearing config names require a secret-ref",
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
export const agentProfileEnvironmentSchema = profileConfigRecordSchema(environmentNameSchema);
|
|
156
|
+
export const agentProfileHeaderSchema = profileConfigRecordSchema(headerNameSchema);
|
|
64
157
|
export const agentSubagentProfileSchema = z.strictObject({
|
|
65
158
|
description: z.string().optional(),
|
|
66
159
|
prompt: z.string().optional(),
|
|
67
160
|
model: z.string().optional(),
|
|
68
|
-
tools:
|
|
69
|
-
permissions:
|
|
161
|
+
tools: ownPropertyRecordSchema(z.boolean()).optional(),
|
|
162
|
+
permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional(),
|
|
70
163
|
maxSteps: z.number().optional(),
|
|
71
|
-
metadata:
|
|
164
|
+
metadata: ownPropertyRecordSchema(z.unknown()).optional(),
|
|
72
165
|
});
|
|
73
166
|
export const agentProfileHookCommandSchema = z.strictObject({
|
|
74
167
|
command: z.string(),
|
|
75
168
|
timeoutMs: z.number().positive().optional(),
|
|
76
169
|
blocking: z.boolean().optional(),
|
|
77
170
|
matcher: z.string().optional(),
|
|
78
|
-
env:
|
|
171
|
+
env: agentProfileEnvironmentSchema.optional(),
|
|
79
172
|
});
|
|
80
173
|
export const agentProfileModeSchema = z.strictObject({
|
|
81
174
|
description: z.string().optional(),
|
|
82
175
|
model: z.string().optional(),
|
|
83
176
|
prompt: z.string().optional(),
|
|
84
|
-
tools:
|
|
85
|
-
permissions:
|
|
86
|
-
metadata:
|
|
177
|
+
tools: ownPropertyRecordSchema(z.boolean()).optional(),
|
|
178
|
+
permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional(),
|
|
179
|
+
metadata: ownPropertyRecordSchema(z.unknown()).optional(),
|
|
87
180
|
});
|
|
88
181
|
export const agentProfileConfidentialSchema = z.strictObject({
|
|
89
182
|
tee: z.string().optional(),
|
|
@@ -102,17 +195,20 @@ const remoteMcpUrlSchema = nonBlankMcpValueSchema.refine((value) => {
|
|
|
102
195
|
catch {
|
|
103
196
|
return false;
|
|
104
197
|
}
|
|
105
|
-
}, "remote MCP url must be an absolute HTTP(S) URL");
|
|
198
|
+
}, "remote MCP url must be an absolute HTTP(S) URL").refine((value) => !looksLikeCredential(value), "remote MCP url cannot contain credentials or credential-named query parameters");
|
|
106
199
|
const agentProfileLocalMcpServerSchema = z.strictObject({
|
|
107
200
|
transport: z.literal("stdio").optional(),
|
|
108
|
-
command: nonBlankMcpValueSchema,
|
|
109
|
-
args: z.array(
|
|
110
|
-
env:
|
|
111
|
-
cwd: z
|
|
201
|
+
command: nonBlankMcpValueSchema.refine(isSafeExecutable, "local MCP command must be a canonical public executable"),
|
|
202
|
+
args: z.array(agentProfileConfigValueSchema).optional(),
|
|
203
|
+
env: agentProfileEnvironmentSchema.optional(),
|
|
204
|
+
cwd: z
|
|
205
|
+
.string()
|
|
206
|
+
.refine((value) => isSafeRelativePath(value, true), "local MCP cwd must be a canonical workspace-relative path")
|
|
207
|
+
.optional(),
|
|
112
208
|
url: z.undefined().optional(),
|
|
113
209
|
headers: z.undefined().optional(),
|
|
114
210
|
enabled: z.literal(true).optional(),
|
|
115
|
-
metadata:
|
|
211
|
+
metadata: ownPropertyRecordSchema(z.unknown()).optional(),
|
|
116
212
|
});
|
|
117
213
|
const agentProfileRemoteMcpServerSchema = z.strictObject({
|
|
118
214
|
transport: z.enum(["sse", "http"]).optional(),
|
|
@@ -121,9 +217,9 @@ const agentProfileRemoteMcpServerSchema = z.strictObject({
|
|
|
121
217
|
env: z.undefined().optional(),
|
|
122
218
|
cwd: z.undefined().optional(),
|
|
123
219
|
url: remoteMcpUrlSchema,
|
|
124
|
-
headers:
|
|
220
|
+
headers: agentProfileHeaderSchema.optional(),
|
|
125
221
|
enabled: z.literal(true).optional(),
|
|
126
|
-
metadata:
|
|
222
|
+
metadata: ownPropertyRecordSchema(z.unknown()).optional(),
|
|
127
223
|
});
|
|
128
224
|
const agentProfileDisabledMcpServerSchema = z.strictObject({
|
|
129
225
|
enabled: z.literal(false),
|
|
@@ -134,7 +230,7 @@ const agentProfileDisabledMcpServerSchema = z.strictObject({
|
|
|
134
230
|
cwd: z.undefined().optional(),
|
|
135
231
|
url: z.undefined().optional(),
|
|
136
232
|
headers: z.undefined().optional(),
|
|
137
|
-
metadata:
|
|
233
|
+
metadata: ownPropertyRecordSchema(z.unknown()).optional(),
|
|
138
234
|
});
|
|
139
235
|
export const agentProfileMcpServerSchema = z.union([
|
|
140
236
|
agentProfileLocalMcpServerSchema,
|
|
@@ -187,7 +283,8 @@ export const agentProfileDiffRemovalSchema = z.strictObject({
|
|
|
187
283
|
* the canonical {@link AgentProfile} TS contract. Kept structurally in lock-step
|
|
188
284
|
* with that interface by the compile-time guard at the bottom of this file.
|
|
189
285
|
*/
|
|
190
|
-
export const agentProfileSchema = z
|
|
286
|
+
export const agentProfileSchema = z
|
|
287
|
+
.strictObject({
|
|
191
288
|
name: z.string().optional(),
|
|
192
289
|
description: z.string().optional(),
|
|
193
290
|
version: z.string().optional(),
|
|
@@ -195,22 +292,36 @@ export const agentProfileSchema = z.strictObject({
|
|
|
195
292
|
prompt: agentProfilePromptSchema.optional(),
|
|
196
293
|
model: agentProfileModelHintsSchema.optional(),
|
|
197
294
|
harness: harnessTypeSchema.optional(),
|
|
198
|
-
permissions:
|
|
199
|
-
tools:
|
|
200
|
-
mcp:
|
|
295
|
+
permissions: ownPropertyRecordSchema(agentProfilePermissionSchema).optional(),
|
|
296
|
+
tools: ownPropertyRecordSchema(z.boolean()).optional(),
|
|
297
|
+
mcp: ownPropertyRecordSchema(agentProfileMcpServerSchema).optional(),
|
|
201
298
|
connections: z.array(agentProfileConnectionSchema).optional(),
|
|
202
|
-
subagents:
|
|
299
|
+
subagents: ownPropertyRecordSchema(agentSubagentProfileSchema).optional(),
|
|
203
300
|
resources: agentProfileResourcesSchema.optional(),
|
|
204
|
-
hooks: z
|
|
205
|
-
|
|
206
|
-
.optional(),
|
|
207
|
-
modes: z.record(z.string(), agentProfileModeSchema).optional(),
|
|
301
|
+
hooks: ownPropertyRecordSchema(z.array(agentProfileHookCommandSchema)).optional(),
|
|
302
|
+
modes: ownPropertyRecordSchema(agentProfileModeSchema).optional(),
|
|
208
303
|
confidential: agentProfileConfidentialSchema.optional(),
|
|
209
|
-
metadata:
|
|
210
|
-
extensions: z
|
|
211
|
-
|
|
212
|
-
|
|
304
|
+
metadata: ownPropertyRecordSchema(z.unknown()).optional(),
|
|
305
|
+
extensions: ownPropertyRecordSchema(z.union([ownPropertyRecordSchema(z.unknown()), z.undefined()])).optional(),
|
|
306
|
+
})
|
|
307
|
+
.superRefine((profile, context) => {
|
|
308
|
+
validateNestedRecordKeys(profile, context, [], new Set());
|
|
213
309
|
});
|
|
310
|
+
function validateNestedRecordKeys(value, context, path, seen) {
|
|
311
|
+
if (value === null || typeof value !== "object" || seen.has(value))
|
|
312
|
+
return;
|
|
313
|
+
seen.add(value);
|
|
314
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
315
|
+
if (!isWellFormedUnicode(key)) {
|
|
316
|
+
context.addIssue({
|
|
317
|
+
code: "custom",
|
|
318
|
+
path: [...path, key],
|
|
319
|
+
message: "record keys must contain valid Unicode",
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
validateNestedRecordKeys(entry, context, [...path, key], seen);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
214
325
|
export const agentProfileDiffSchema = z.strictObject({
|
|
215
326
|
kind: z.literal("agent-profile-diff"),
|
|
216
327
|
id: z.string().min(1).optional(),
|
|
@@ -232,7 +343,7 @@ export const agentProfileDiffSchema = z.strictObject({
|
|
|
232
343
|
.optional(),
|
|
233
344
|
set: agentProfileSchema.optional(),
|
|
234
345
|
remove: agentProfileDiffRemovalSchema.optional(),
|
|
235
|
-
metadata:
|
|
346
|
+
metadata: ownPropertyRecordSchema(z.unknown()).optional(),
|
|
236
347
|
});
|
|
237
348
|
const _agentProfileSchemaMatchesInterface = true;
|
|
238
349
|
void _agentProfileSchemaMatchesInterface;
|