@tangle-network/agent-interface 0.20.0 → 0.21.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.
@@ -0,0 +1,267 @@
1
+ import { z } from "zod";
2
+ export declare const agentCandidateMcpServerSchema: z.ZodObject<{
3
+ transport: z.ZodOptional<z.ZodLiteral<"stdio">>;
4
+ command: z.ZodOptional<z.ZodString>;
5
+ args: z.ZodOptional<z.ZodArray<z.ZodObject<{
6
+ kind: z.ZodLiteral<"public">;
7
+ value: z.ZodString;
8
+ }, z.core.$strict>>>;
9
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
10
+ kind: z.ZodLiteral<"public">;
11
+ value: z.ZodString;
12
+ }, z.core.$strict>>>;
13
+ cwd: z.ZodOptional<z.ZodString>;
14
+ enabled: z.ZodOptional<z.ZodBoolean>;
15
+ }, z.core.$strict>;
16
+ export declare const agentCandidateHookCommandSchema: z.ZodObject<{
17
+ executable: z.ZodString;
18
+ args: z.ZodOptional<z.ZodArray<z.ZodObject<{
19
+ kind: z.ZodLiteral<"public">;
20
+ value: z.ZodString;
21
+ }, z.core.$strict>>>;
22
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
23
+ blocking: z.ZodOptional<z.ZodBoolean>;
24
+ matcher: z.ZodOptional<z.ZodString>;
25
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
26
+ kind: z.ZodLiteral<"public">;
27
+ value: z.ZodString;
28
+ }, z.core.$strict>>>;
29
+ }, z.core.$strict>;
30
+ export declare const agentCandidateProfileSchema: z.ZodObject<{
31
+ name: z.ZodOptional<z.ZodString>;
32
+ description: z.ZodOptional<z.ZodString>;
33
+ version: z.ZodOptional<z.ZodString>;
34
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
35
+ prompt: z.ZodOptional<z.ZodObject<{
36
+ systemPrompt: z.ZodOptional<z.ZodString>;
37
+ instructions: z.ZodOptional<z.ZodArray<z.ZodString>>;
38
+ }, z.core.$strict>>;
39
+ model: z.ZodOptional<z.ZodObject<{
40
+ reasoningEffort: z.ZodOptional<z.ZodEnum<{
41
+ none: "none";
42
+ minimal: "minimal";
43
+ low: "low";
44
+ medium: "medium";
45
+ high: "high";
46
+ xhigh: "xhigh";
47
+ ultracode: "ultracode";
48
+ }>>;
49
+ default: z.ZodOptional<z.ZodString>;
50
+ small: z.ZodOptional<z.ZodString>;
51
+ provider: z.ZodOptional<z.ZodString>;
52
+ }, z.core.$strict>>;
53
+ harness: z.ZodOptional<z.ZodEnum<{
54
+ "claude-code": "claude-code";
55
+ claude: "claude";
56
+ claudish: "claudish";
57
+ nanoclaw: "nanoclaw";
58
+ codex: "codex";
59
+ opencode: "opencode";
60
+ "kimi-code": "kimi-code";
61
+ kimi: "kimi";
62
+ pi: "pi";
63
+ gemini: "gemini";
64
+ hermes: "hermes";
65
+ openclaw: "openclaw";
66
+ amp: "amp";
67
+ "factory-droids": "factory-droids";
68
+ acp: "acp";
69
+ "cli-base": "cli-base";
70
+ }>>;
71
+ permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
72
+ allow: "allow";
73
+ ask: "ask";
74
+ deny: "deny";
75
+ }>, z.ZodRecord<z.ZodString, z.ZodEnum<{
76
+ allow: "allow";
77
+ ask: "ask";
78
+ deny: "deny";
79
+ }>>]>>>;
80
+ tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
81
+ mcp: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
82
+ transport: z.ZodOptional<z.ZodLiteral<"stdio">>;
83
+ command: z.ZodOptional<z.ZodString>;
84
+ args: z.ZodOptional<z.ZodArray<z.ZodObject<{
85
+ kind: z.ZodLiteral<"public">;
86
+ value: z.ZodString;
87
+ }, z.core.$strict>>>;
88
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
89
+ kind: z.ZodLiteral<"public">;
90
+ value: z.ZodString;
91
+ }, z.core.$strict>>>;
92
+ cwd: z.ZodOptional<z.ZodString>;
93
+ enabled: z.ZodOptional<z.ZodBoolean>;
94
+ }, z.core.$strict>>>;
95
+ subagents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
96
+ prompt: z.ZodOptional<z.ZodString>;
97
+ permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
98
+ allow: "allow";
99
+ ask: "ask";
100
+ deny: "deny";
101
+ }>, z.ZodRecord<z.ZodString, z.ZodEnum<{
102
+ allow: "allow";
103
+ ask: "ask";
104
+ deny: "deny";
105
+ }>>]>>>;
106
+ tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
107
+ description: z.ZodOptional<z.ZodString>;
108
+ model: z.ZodOptional<z.ZodString>;
109
+ maxSteps: z.ZodOptional<z.ZodNumber>;
110
+ }, z.core.$strict>>>;
111
+ resources: z.ZodOptional<z.ZodObject<{
112
+ files: z.ZodOptional<z.ZodArray<z.ZodObject<{
113
+ path: z.ZodString;
114
+ resource: z.ZodDiscriminatedUnion<[z.ZodObject<{
115
+ kind: z.ZodLiteral<"inline">;
116
+ name: z.ZodString;
117
+ content: z.ZodString;
118
+ sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
119
+ byteLength: z.ZodNumber;
120
+ }, z.core.$strict>, z.ZodObject<{
121
+ kind: z.ZodLiteral<"github">;
122
+ repository: z.ZodObject<{
123
+ kind: z.ZodLiteral<"github">;
124
+ owner: z.ZodString;
125
+ repo: z.ZodString;
126
+ }, z.core.$strict>;
127
+ path: z.ZodString;
128
+ commit: z.ZodString;
129
+ name: z.ZodOptional<z.ZodString>;
130
+ sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
131
+ byteLength: z.ZodNumber;
132
+ }, z.core.$strict>], "kind">;
133
+ executable: z.ZodOptional<z.ZodBoolean>;
134
+ }, z.core.$strict>>>;
135
+ tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
136
+ kind: z.ZodLiteral<"inline">;
137
+ name: z.ZodString;
138
+ content: z.ZodString;
139
+ sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
140
+ byteLength: z.ZodNumber;
141
+ }, z.core.$strict>, z.ZodObject<{
142
+ kind: z.ZodLiteral<"github">;
143
+ repository: z.ZodObject<{
144
+ kind: z.ZodLiteral<"github">;
145
+ owner: z.ZodString;
146
+ repo: z.ZodString;
147
+ }, z.core.$strict>;
148
+ path: z.ZodString;
149
+ commit: z.ZodString;
150
+ name: z.ZodOptional<z.ZodString>;
151
+ sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
152
+ byteLength: z.ZodNumber;
153
+ }, z.core.$strict>], "kind">>>;
154
+ skills: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
155
+ kind: z.ZodLiteral<"inline">;
156
+ name: z.ZodString;
157
+ content: z.ZodString;
158
+ sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
159
+ byteLength: z.ZodNumber;
160
+ }, z.core.$strict>, z.ZodObject<{
161
+ kind: z.ZodLiteral<"github">;
162
+ repository: z.ZodObject<{
163
+ kind: z.ZodLiteral<"github">;
164
+ owner: z.ZodString;
165
+ repo: z.ZodString;
166
+ }, z.core.$strict>;
167
+ path: z.ZodString;
168
+ commit: z.ZodString;
169
+ name: z.ZodOptional<z.ZodString>;
170
+ sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
171
+ byteLength: z.ZodNumber;
172
+ }, z.core.$strict>], "kind">>>;
173
+ agents: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
174
+ kind: z.ZodLiteral<"inline">;
175
+ name: z.ZodString;
176
+ content: z.ZodString;
177
+ sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
178
+ byteLength: z.ZodNumber;
179
+ }, z.core.$strict>, z.ZodObject<{
180
+ kind: z.ZodLiteral<"github">;
181
+ repository: z.ZodObject<{
182
+ kind: z.ZodLiteral<"github">;
183
+ owner: z.ZodString;
184
+ repo: z.ZodString;
185
+ }, z.core.$strict>;
186
+ path: z.ZodString;
187
+ commit: z.ZodString;
188
+ name: z.ZodOptional<z.ZodString>;
189
+ sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
190
+ byteLength: z.ZodNumber;
191
+ }, z.core.$strict>], "kind">>>;
192
+ commands: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
193
+ kind: z.ZodLiteral<"inline">;
194
+ name: z.ZodString;
195
+ content: z.ZodString;
196
+ sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
197
+ byteLength: z.ZodNumber;
198
+ }, z.core.$strict>, z.ZodObject<{
199
+ kind: z.ZodLiteral<"github">;
200
+ repository: z.ZodObject<{
201
+ kind: z.ZodLiteral<"github">;
202
+ owner: z.ZodString;
203
+ repo: z.ZodString;
204
+ }, z.core.$strict>;
205
+ path: z.ZodString;
206
+ commit: z.ZodString;
207
+ name: z.ZodOptional<z.ZodString>;
208
+ sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
209
+ byteLength: z.ZodNumber;
210
+ }, z.core.$strict>], "kind">>>;
211
+ instructions: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
212
+ kind: z.ZodLiteral<"inline">;
213
+ name: z.ZodString;
214
+ content: z.ZodString;
215
+ sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
216
+ byteLength: z.ZodNumber;
217
+ }, z.core.$strict>, z.ZodObject<{
218
+ kind: z.ZodLiteral<"github">;
219
+ repository: z.ZodObject<{
220
+ kind: z.ZodLiteral<"github">;
221
+ owner: z.ZodString;
222
+ repo: z.ZodString;
223
+ }, z.core.$strict>;
224
+ path: z.ZodString;
225
+ commit: z.ZodString;
226
+ name: z.ZodOptional<z.ZodString>;
227
+ sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
228
+ byteLength: z.ZodNumber;
229
+ }, z.core.$strict>], "kind">]>>;
230
+ failOnError: z.ZodLiteral<true>;
231
+ }, z.core.$strict>>;
232
+ hooks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
233
+ executable: z.ZodString;
234
+ args: z.ZodOptional<z.ZodArray<z.ZodObject<{
235
+ kind: z.ZodLiteral<"public">;
236
+ value: z.ZodString;
237
+ }, z.core.$strict>>>;
238
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
239
+ blocking: z.ZodOptional<z.ZodBoolean>;
240
+ matcher: z.ZodOptional<z.ZodString>;
241
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
242
+ kind: z.ZodLiteral<"public">;
243
+ value: z.ZodString;
244
+ }, z.core.$strict>>>;
245
+ }, z.core.$strict>>>>;
246
+ modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
247
+ prompt: z.ZodOptional<z.ZodString>;
248
+ permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
249
+ allow: "allow";
250
+ ask: "ask";
251
+ deny: "deny";
252
+ }>, z.ZodRecord<z.ZodString, z.ZodEnum<{
253
+ allow: "allow";
254
+ ask: "ask";
255
+ deny: "deny";
256
+ }>>]>>>;
257
+ tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
258
+ description: z.ZodOptional<z.ZodString>;
259
+ model: z.ZodOptional<z.ZodString>;
260
+ }, z.core.$strict>>>;
261
+ confidential: z.ZodOptional<z.ZodObject<{
262
+ tee: z.ZodOptional<z.ZodString>;
263
+ attestationNonce: z.ZodOptional<z.ZodString>;
264
+ sealed: z.ZodOptional<z.ZodBoolean>;
265
+ attestationRefresh: z.ZodOptional<z.ZodBoolean>;
266
+ }, z.core.$strict>>;
267
+ }, z.core.$strict>;
@@ -0,0 +1,125 @@
1
+ import { z } from "zod";
2
+ import { agentCandidateResourcesSchema } from "./agent-candidate-artifact-schema.js";
3
+ import { agentCandidateConfigValueSchema, environmentConfigSchema, isCanonicalJsonValue, isSafeExecutable, isSafeRelativePath, isWellFormedUnicode, } from "./agent-candidate-schema-common.js";
4
+ import { harnessTypeSchema } from "./harness.js";
5
+ import { agentProfileConfidentialSchema, agentProfileModeSchema, agentProfileModelHintsSchema, agentProfilePermissionSchema, agentProfilePromptSchema, agentSubagentProfileSchema, } from "./profile-schema.js";
6
+ const executableSchema = z
7
+ .string()
8
+ .refine(isSafeExecutable, "executable must be a canonical non-shell command");
9
+ export const agentCandidateMcpServerSchema = z
10
+ .object({
11
+ transport: z.literal("stdio").optional(),
12
+ command: executableSchema.optional(),
13
+ args: z.array(agentCandidateConfigValueSchema).optional(),
14
+ env: environmentConfigSchema.optional(),
15
+ cwd: z
16
+ .string()
17
+ .refine((value) => isSafeRelativePath(value, true), "MCP cwd must be a canonical workspace-relative path")
18
+ .optional(),
19
+ enabled: z.boolean().optional(),
20
+ })
21
+ .strict()
22
+ .superRefine((server, ctx) => {
23
+ if (server.enabled === false) {
24
+ if (server.transport !== undefined ||
25
+ server.command !== undefined ||
26
+ server.args !== undefined ||
27
+ server.env !== undefined ||
28
+ server.cwd !== undefined) {
29
+ ctx.addIssue({
30
+ code: "custom",
31
+ message: "disabled MCP servers cannot carry process fields",
32
+ });
33
+ }
34
+ return;
35
+ }
36
+ if (server.command === undefined) {
37
+ ctx.addIssue({
38
+ code: "custom",
39
+ path: ["command"],
40
+ message: "enabled stdio MCP servers require a command",
41
+ });
42
+ }
43
+ });
44
+ export const agentCandidateHookCommandSchema = z
45
+ .object({
46
+ executable: executableSchema,
47
+ args: z.array(agentCandidateConfigValueSchema).optional(),
48
+ timeoutMs: z.number().positive().optional(),
49
+ blocking: z.boolean().optional(),
50
+ matcher: z.string().refine(isWellFormedUnicode).optional(),
51
+ env: environmentConfigSchema.optional(),
52
+ })
53
+ .strict();
54
+ const candidateModelHintsSchema = agentProfileModelHintsSchema
55
+ .omit({ metadata: true })
56
+ .extend({
57
+ default: z.string().min(1).optional(),
58
+ small: z.string().min(1).optional(),
59
+ provider: z.string().min(1).optional(),
60
+ })
61
+ .strict();
62
+ const candidateSubagentSchema = agentSubagentProfileSchema
63
+ .omit({ metadata: true })
64
+ .extend({
65
+ model: z.string().min(1).optional(),
66
+ maxSteps: z.number().int().positive().optional(),
67
+ })
68
+ .strict();
69
+ const candidateModeSchema = agentProfileModeSchema
70
+ .omit({ metadata: true })
71
+ .extend({ model: z.string().min(1).optional() })
72
+ .strict();
73
+ export const agentCandidateProfileSchema = z
74
+ .object({
75
+ name: z.string().refine(isWellFormedUnicode).optional(),
76
+ description: z.string().refine(isWellFormedUnicode).optional(),
77
+ version: z.string().refine(isWellFormedUnicode).optional(),
78
+ tags: z.array(z.string().refine(isWellFormedUnicode)).optional(),
79
+ prompt: agentProfilePromptSchema.strict().optional(),
80
+ model: candidateModelHintsSchema.optional(),
81
+ harness: harnessTypeSchema.optional(),
82
+ permissions: z
83
+ .record(z.string(), agentProfilePermissionSchema)
84
+ .optional(),
85
+ tools: z.record(z.string(), z.boolean()).optional(),
86
+ mcp: z.record(z.string(), agentCandidateMcpServerSchema).optional(),
87
+ subagents: z.record(z.string(), candidateSubagentSchema).optional(),
88
+ resources: agentCandidateResourcesSchema.optional(),
89
+ hooks: z
90
+ .record(z.string(), z.array(agentCandidateHookCommandSchema))
91
+ .optional(),
92
+ modes: z.record(z.string(), candidateModeSchema).optional(),
93
+ confidential: agentProfileConfidentialSchema.strict().optional(),
94
+ })
95
+ .strict()
96
+ .superRefine((profile, ctx) => {
97
+ if (!isCanonicalJsonValue(profile)) {
98
+ ctx.addIssue({
99
+ code: "custom",
100
+ message: "candidate profile must contain only RFC 8785 JSON values",
101
+ });
102
+ }
103
+ const primaryModel = profile.model?.default;
104
+ const alternateRoutes = [
105
+ ...(profile.model?.small === undefined
106
+ ? []
107
+ : [["model", "small", profile.model.small]]),
108
+ ...Object.entries(profile.subagents ?? {}).flatMap(([name, subagent]) => subagent.model === undefined
109
+ ? []
110
+ : [["subagents", name, "model", subagent.model]]),
111
+ ...Object.entries(profile.modes ?? {}).flatMap(([name, mode]) => mode.model === undefined
112
+ ? []
113
+ : [["modes", name, "model", mode.model]]),
114
+ ];
115
+ for (const route of alternateRoutes) {
116
+ const routeModel = route.at(-1);
117
+ if (primaryModel === undefined || routeModel !== primaryModel) {
118
+ ctx.addIssue({
119
+ code: "custom",
120
+ path: route.slice(0, -1),
121
+ message: "sealed candidates require every model route to use the exact primary model",
122
+ });
123
+ }
124
+ }
125
+ });