@modexagents/core 0.3.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/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/index.d.ts +1230 -0
- package/dist/index.js +1979 -0
- package/dist/index.js.map +1 -0
- package/package.json +66 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1230 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
3
|
+
|
|
4
|
+
declare const SCHEMA_VERSION = 0;
|
|
5
|
+
declare const SkillSchema: z.ZodObject<{
|
|
6
|
+
slug: z.ZodString;
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
description: z.ZodString;
|
|
9
|
+
tags: z.ZodArray<z.ZodString, "many">;
|
|
10
|
+
source: z.ZodString;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
slug: string;
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
tags: string[];
|
|
16
|
+
source: string;
|
|
17
|
+
}, {
|
|
18
|
+
slug: string;
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
tags: string[];
|
|
22
|
+
source: string;
|
|
23
|
+
}>;
|
|
24
|
+
type Skill = z.infer<typeof SkillSchema>;
|
|
25
|
+
declare const SkillsDocSchema: z.ZodObject<{
|
|
26
|
+
schema_version: z.ZodLiteral<0>;
|
|
27
|
+
skills: z.ZodArray<z.ZodObject<{
|
|
28
|
+
slug: z.ZodString;
|
|
29
|
+
name: z.ZodString;
|
|
30
|
+
description: z.ZodString;
|
|
31
|
+
tags: z.ZodArray<z.ZodString, "many">;
|
|
32
|
+
source: z.ZodString;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
slug: string;
|
|
35
|
+
name: string;
|
|
36
|
+
description: string;
|
|
37
|
+
tags: string[];
|
|
38
|
+
source: string;
|
|
39
|
+
}, {
|
|
40
|
+
slug: string;
|
|
41
|
+
name: string;
|
|
42
|
+
description: string;
|
|
43
|
+
tags: string[];
|
|
44
|
+
source: string;
|
|
45
|
+
}>, "many">;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
schema_version: 0;
|
|
48
|
+
skills: {
|
|
49
|
+
slug: string;
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
tags: string[];
|
|
53
|
+
source: string;
|
|
54
|
+
}[];
|
|
55
|
+
}, {
|
|
56
|
+
schema_version: 0;
|
|
57
|
+
skills: {
|
|
58
|
+
slug: string;
|
|
59
|
+
name: string;
|
|
60
|
+
description: string;
|
|
61
|
+
tags: string[];
|
|
62
|
+
source: string;
|
|
63
|
+
}[];
|
|
64
|
+
}>;
|
|
65
|
+
type SkillsDoc = z.infer<typeof SkillsDocSchema>;
|
|
66
|
+
declare const ExtractedSkillSchema: z.ZodObject<Omit<{
|
|
67
|
+
slug: z.ZodString;
|
|
68
|
+
name: z.ZodString;
|
|
69
|
+
description: z.ZodString;
|
|
70
|
+
tags: z.ZodArray<z.ZodString, "many">;
|
|
71
|
+
source: z.ZodString;
|
|
72
|
+
}, "source">, "strip", z.ZodTypeAny, {
|
|
73
|
+
slug: string;
|
|
74
|
+
name: string;
|
|
75
|
+
description: string;
|
|
76
|
+
tags: string[];
|
|
77
|
+
}, {
|
|
78
|
+
slug: string;
|
|
79
|
+
name: string;
|
|
80
|
+
description: string;
|
|
81
|
+
tags: string[];
|
|
82
|
+
}>;
|
|
83
|
+
type ExtractedSkill = z.infer<typeof ExtractedSkillSchema>;
|
|
84
|
+
declare const ExtractionResultSchema: z.ZodObject<{
|
|
85
|
+
skills: z.ZodArray<z.ZodObject<Omit<{
|
|
86
|
+
slug: z.ZodString;
|
|
87
|
+
name: z.ZodString;
|
|
88
|
+
description: z.ZodString;
|
|
89
|
+
tags: z.ZodArray<z.ZodString, "many">;
|
|
90
|
+
source: z.ZodString;
|
|
91
|
+
}, "source">, "strip", z.ZodTypeAny, {
|
|
92
|
+
slug: string;
|
|
93
|
+
name: string;
|
|
94
|
+
description: string;
|
|
95
|
+
tags: string[];
|
|
96
|
+
}, {
|
|
97
|
+
slug: string;
|
|
98
|
+
name: string;
|
|
99
|
+
description: string;
|
|
100
|
+
tags: string[];
|
|
101
|
+
}>, "many">;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
skills: {
|
|
104
|
+
slug: string;
|
|
105
|
+
name: string;
|
|
106
|
+
description: string;
|
|
107
|
+
tags: string[];
|
|
108
|
+
}[];
|
|
109
|
+
}, {
|
|
110
|
+
skills: {
|
|
111
|
+
slug: string;
|
|
112
|
+
name: string;
|
|
113
|
+
description: string;
|
|
114
|
+
tags: string[];
|
|
115
|
+
}[];
|
|
116
|
+
}>;
|
|
117
|
+
type ExtractionResult = z.infer<typeof ExtractionResultSchema>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Serialize a SkillsDoc to canonical SKILLS.md.
|
|
121
|
+
*
|
|
122
|
+
* Stability rules (load-bearing — later phases hash this output):
|
|
123
|
+
* - LF line endings, single trailing newline
|
|
124
|
+
* - Skills sorted ascending by slug (UTF-16 code units)
|
|
125
|
+
* - Tags sorted ascending, joined by ", "
|
|
126
|
+
* - Field order fixed: Name, Description, Tags, Source
|
|
127
|
+
* - Frontmatter limited to schema_version
|
|
128
|
+
*/
|
|
129
|
+
declare function serialize(doc: SkillsDoc): string;
|
|
130
|
+
declare function buildDoc(skills: Skill[]): SkillsDoc;
|
|
131
|
+
|
|
132
|
+
declare class ExtractionError extends Error {
|
|
133
|
+
readonly cause?: unknown;
|
|
134
|
+
constructor(message: string, cause?: unknown);
|
|
135
|
+
}
|
|
136
|
+
interface ExtractOptions {
|
|
137
|
+
source: string;
|
|
138
|
+
apiKey?: string;
|
|
139
|
+
model?: string;
|
|
140
|
+
maxTokens?: number;
|
|
141
|
+
client?: Anthropic;
|
|
142
|
+
}
|
|
143
|
+
declare function extractSkills(corpus: string, opts: ExtractOptions): Promise<Skill[]>;
|
|
144
|
+
|
|
145
|
+
declare const DEFAULT_LOCK_TIMEOUT_MS = 10000;
|
|
146
|
+
declare const DEFAULT_STALE_MS = 30000;
|
|
147
|
+
declare class FileLockError extends Error {
|
|
148
|
+
constructor(message: string);
|
|
149
|
+
}
|
|
150
|
+
interface LockOptions {
|
|
151
|
+
timeoutMs?: number;
|
|
152
|
+
staleMs?: number;
|
|
153
|
+
now?: () => number;
|
|
154
|
+
}
|
|
155
|
+
declare function withFileLock<T>(targetPath: string, fn: () => Promise<T>, opts?: LockOptions): Promise<T>;
|
|
156
|
+
|
|
157
|
+
declare const PROVENANCE_SCHEMA_VERSION = 1;
|
|
158
|
+
declare const SOURCE_KINDS: readonly ["text", "markdown", "pdf", "epub", "web"];
|
|
159
|
+
type SourceKind = (typeof SOURCE_KINDS)[number];
|
|
160
|
+
declare const FeedInputSchema: z.ZodObject<{
|
|
161
|
+
source: z.ZodString;
|
|
162
|
+
source_url: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
163
|
+
source_kind: z.ZodEnum<["text", "markdown", "pdf", "epub", "web"]>;
|
|
164
|
+
source_sha256: z.ZodString;
|
|
165
|
+
source_bytes: z.ZodNumber;
|
|
166
|
+
model: z.ZodString;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
source: string;
|
|
169
|
+
model: string;
|
|
170
|
+
source_url: string | null;
|
|
171
|
+
source_kind: "text" | "markdown" | "pdf" | "epub" | "web";
|
|
172
|
+
source_sha256: string;
|
|
173
|
+
source_bytes: number;
|
|
174
|
+
}, {
|
|
175
|
+
source: string;
|
|
176
|
+
model: string;
|
|
177
|
+
source_url: string | null;
|
|
178
|
+
source_kind: "text" | "markdown" | "pdf" | "epub" | "web";
|
|
179
|
+
source_sha256: string;
|
|
180
|
+
source_bytes: number;
|
|
181
|
+
}>;
|
|
182
|
+
declare const FeedOutputSchema: z.ZodObject<{
|
|
183
|
+
skills_added: z.ZodArray<z.ZodString, "many">;
|
|
184
|
+
skills_updated: z.ZodArray<z.ZodString, "many">;
|
|
185
|
+
skills_removed: z.ZodArray<z.ZodString, "many">;
|
|
186
|
+
skills_md_sha256: z.ZodString;
|
|
187
|
+
skills_md_bytes: z.ZodNumber;
|
|
188
|
+
}, "strip", z.ZodTypeAny, {
|
|
189
|
+
skills_added: string[];
|
|
190
|
+
skills_updated: string[];
|
|
191
|
+
skills_removed: string[];
|
|
192
|
+
skills_md_sha256: string;
|
|
193
|
+
skills_md_bytes: number;
|
|
194
|
+
}, {
|
|
195
|
+
skills_added: string[];
|
|
196
|
+
skills_updated: string[];
|
|
197
|
+
skills_removed: string[];
|
|
198
|
+
skills_md_sha256: string;
|
|
199
|
+
skills_md_bytes: number;
|
|
200
|
+
}>;
|
|
201
|
+
declare const AgentCreatedInputSchema: z.ZodObject<{
|
|
202
|
+
name: z.ZodString;
|
|
203
|
+
}, "strip", z.ZodTypeAny, {
|
|
204
|
+
name: string;
|
|
205
|
+
}, {
|
|
206
|
+
name: string;
|
|
207
|
+
}>;
|
|
208
|
+
declare const AgentCreatedOutputSchema: z.ZodObject<{
|
|
209
|
+
agent_id: z.ZodString;
|
|
210
|
+
}, "strip", z.ZodTypeAny, {
|
|
211
|
+
agent_id: string;
|
|
212
|
+
}, {
|
|
213
|
+
agent_id: string;
|
|
214
|
+
}>;
|
|
215
|
+
declare const BoundInputSchema: z.ZodObject<{
|
|
216
|
+
skills_md_sha256: z.ZodString;
|
|
217
|
+
aspiration_sha256s: z.ZodArray<z.ZodString, "many">;
|
|
218
|
+
}, "strip", z.ZodTypeAny, {
|
|
219
|
+
skills_md_sha256: string;
|
|
220
|
+
aspiration_sha256s: string[];
|
|
221
|
+
}, {
|
|
222
|
+
skills_md_sha256: string;
|
|
223
|
+
aspiration_sha256s: string[];
|
|
224
|
+
}>;
|
|
225
|
+
declare const BoundOutputSchema: z.ZodObject<{
|
|
226
|
+
registry_url: z.ZodString;
|
|
227
|
+
bound_at: z.ZodString;
|
|
228
|
+
}, "strip", z.ZodTypeAny, {
|
|
229
|
+
registry_url: string;
|
|
230
|
+
bound_at: string;
|
|
231
|
+
}, {
|
|
232
|
+
registry_url: string;
|
|
233
|
+
bound_at: string;
|
|
234
|
+
}>;
|
|
235
|
+
declare const AspirationAddedInputSchema: z.ZodObject<{
|
|
236
|
+
aspiration_sha256: z.ZodString;
|
|
237
|
+
aspiration_bytes: z.ZodNumber;
|
|
238
|
+
source: z.ZodString;
|
|
239
|
+
}, "strip", z.ZodTypeAny, {
|
|
240
|
+
source: string;
|
|
241
|
+
aspiration_sha256: string;
|
|
242
|
+
aspiration_bytes: number;
|
|
243
|
+
}, {
|
|
244
|
+
source: string;
|
|
245
|
+
aspiration_sha256: string;
|
|
246
|
+
aspiration_bytes: number;
|
|
247
|
+
}>;
|
|
248
|
+
declare const AspirationAddedOutputSchema: z.ZodObject<{
|
|
249
|
+
registry_url: z.ZodString;
|
|
250
|
+
}, "strip", z.ZodTypeAny, {
|
|
251
|
+
registry_url: string;
|
|
252
|
+
}, {
|
|
253
|
+
registry_url: string;
|
|
254
|
+
}>;
|
|
255
|
+
declare const FeedEntrySchema: z.ZodObject<{
|
|
256
|
+
kind: z.ZodLiteral<"feed">;
|
|
257
|
+
input: z.ZodObject<{
|
|
258
|
+
source: z.ZodString;
|
|
259
|
+
source_url: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
260
|
+
source_kind: z.ZodEnum<["text", "markdown", "pdf", "epub", "web"]>;
|
|
261
|
+
source_sha256: z.ZodString;
|
|
262
|
+
source_bytes: z.ZodNumber;
|
|
263
|
+
model: z.ZodString;
|
|
264
|
+
}, "strip", z.ZodTypeAny, {
|
|
265
|
+
source: string;
|
|
266
|
+
model: string;
|
|
267
|
+
source_url: string | null;
|
|
268
|
+
source_kind: "text" | "markdown" | "pdf" | "epub" | "web";
|
|
269
|
+
source_sha256: string;
|
|
270
|
+
source_bytes: number;
|
|
271
|
+
}, {
|
|
272
|
+
source: string;
|
|
273
|
+
model: string;
|
|
274
|
+
source_url: string | null;
|
|
275
|
+
source_kind: "text" | "markdown" | "pdf" | "epub" | "web";
|
|
276
|
+
source_sha256: string;
|
|
277
|
+
source_bytes: number;
|
|
278
|
+
}>;
|
|
279
|
+
output: z.ZodObject<{
|
|
280
|
+
skills_added: z.ZodArray<z.ZodString, "many">;
|
|
281
|
+
skills_updated: z.ZodArray<z.ZodString, "many">;
|
|
282
|
+
skills_removed: z.ZodArray<z.ZodString, "many">;
|
|
283
|
+
skills_md_sha256: z.ZodString;
|
|
284
|
+
skills_md_bytes: z.ZodNumber;
|
|
285
|
+
}, "strip", z.ZodTypeAny, {
|
|
286
|
+
skills_added: string[];
|
|
287
|
+
skills_updated: string[];
|
|
288
|
+
skills_removed: string[];
|
|
289
|
+
skills_md_sha256: string;
|
|
290
|
+
skills_md_bytes: number;
|
|
291
|
+
}, {
|
|
292
|
+
skills_added: string[];
|
|
293
|
+
skills_updated: string[];
|
|
294
|
+
skills_removed: string[];
|
|
295
|
+
skills_md_sha256: string;
|
|
296
|
+
skills_md_bytes: number;
|
|
297
|
+
}>;
|
|
298
|
+
schema_version: z.ZodLiteral<1>;
|
|
299
|
+
seq: z.ZodNumber;
|
|
300
|
+
ts: z.ZodString;
|
|
301
|
+
prev: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
302
|
+
entry_sha256: z.ZodString;
|
|
303
|
+
}, "strip", z.ZodTypeAny, {
|
|
304
|
+
schema_version: 1;
|
|
305
|
+
kind: "feed";
|
|
306
|
+
input: {
|
|
307
|
+
source: string;
|
|
308
|
+
model: string;
|
|
309
|
+
source_url: string | null;
|
|
310
|
+
source_kind: "text" | "markdown" | "pdf" | "epub" | "web";
|
|
311
|
+
source_sha256: string;
|
|
312
|
+
source_bytes: number;
|
|
313
|
+
};
|
|
314
|
+
output: {
|
|
315
|
+
skills_added: string[];
|
|
316
|
+
skills_updated: string[];
|
|
317
|
+
skills_removed: string[];
|
|
318
|
+
skills_md_sha256: string;
|
|
319
|
+
skills_md_bytes: number;
|
|
320
|
+
};
|
|
321
|
+
seq: number;
|
|
322
|
+
ts: string;
|
|
323
|
+
prev: string | null;
|
|
324
|
+
entry_sha256: string;
|
|
325
|
+
}, {
|
|
326
|
+
schema_version: 1;
|
|
327
|
+
kind: "feed";
|
|
328
|
+
input: {
|
|
329
|
+
source: string;
|
|
330
|
+
model: string;
|
|
331
|
+
source_url: string | null;
|
|
332
|
+
source_kind: "text" | "markdown" | "pdf" | "epub" | "web";
|
|
333
|
+
source_sha256: string;
|
|
334
|
+
source_bytes: number;
|
|
335
|
+
};
|
|
336
|
+
output: {
|
|
337
|
+
skills_added: string[];
|
|
338
|
+
skills_updated: string[];
|
|
339
|
+
skills_removed: string[];
|
|
340
|
+
skills_md_sha256: string;
|
|
341
|
+
skills_md_bytes: number;
|
|
342
|
+
};
|
|
343
|
+
seq: number;
|
|
344
|
+
ts: string;
|
|
345
|
+
prev: string | null;
|
|
346
|
+
entry_sha256: string;
|
|
347
|
+
}>;
|
|
348
|
+
declare const AgentCreatedEntrySchema: z.ZodObject<{
|
|
349
|
+
kind: z.ZodLiteral<"agent_created">;
|
|
350
|
+
input: z.ZodObject<{
|
|
351
|
+
name: z.ZodString;
|
|
352
|
+
}, "strip", z.ZodTypeAny, {
|
|
353
|
+
name: string;
|
|
354
|
+
}, {
|
|
355
|
+
name: string;
|
|
356
|
+
}>;
|
|
357
|
+
output: z.ZodObject<{
|
|
358
|
+
agent_id: z.ZodString;
|
|
359
|
+
}, "strip", z.ZodTypeAny, {
|
|
360
|
+
agent_id: string;
|
|
361
|
+
}, {
|
|
362
|
+
agent_id: string;
|
|
363
|
+
}>;
|
|
364
|
+
schema_version: z.ZodLiteral<1>;
|
|
365
|
+
seq: z.ZodNumber;
|
|
366
|
+
ts: z.ZodString;
|
|
367
|
+
prev: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
368
|
+
entry_sha256: z.ZodString;
|
|
369
|
+
}, "strip", z.ZodTypeAny, {
|
|
370
|
+
schema_version: 1;
|
|
371
|
+
kind: "agent_created";
|
|
372
|
+
input: {
|
|
373
|
+
name: string;
|
|
374
|
+
};
|
|
375
|
+
output: {
|
|
376
|
+
agent_id: string;
|
|
377
|
+
};
|
|
378
|
+
seq: number;
|
|
379
|
+
ts: string;
|
|
380
|
+
prev: string | null;
|
|
381
|
+
entry_sha256: string;
|
|
382
|
+
}, {
|
|
383
|
+
schema_version: 1;
|
|
384
|
+
kind: "agent_created";
|
|
385
|
+
input: {
|
|
386
|
+
name: string;
|
|
387
|
+
};
|
|
388
|
+
output: {
|
|
389
|
+
agent_id: string;
|
|
390
|
+
};
|
|
391
|
+
seq: number;
|
|
392
|
+
ts: string;
|
|
393
|
+
prev: string | null;
|
|
394
|
+
entry_sha256: string;
|
|
395
|
+
}>;
|
|
396
|
+
declare const BoundEntrySchema: z.ZodObject<{
|
|
397
|
+
kind: z.ZodLiteral<"bound">;
|
|
398
|
+
input: z.ZodObject<{
|
|
399
|
+
skills_md_sha256: z.ZodString;
|
|
400
|
+
aspiration_sha256s: z.ZodArray<z.ZodString, "many">;
|
|
401
|
+
}, "strip", z.ZodTypeAny, {
|
|
402
|
+
skills_md_sha256: string;
|
|
403
|
+
aspiration_sha256s: string[];
|
|
404
|
+
}, {
|
|
405
|
+
skills_md_sha256: string;
|
|
406
|
+
aspiration_sha256s: string[];
|
|
407
|
+
}>;
|
|
408
|
+
output: z.ZodObject<{
|
|
409
|
+
registry_url: z.ZodString;
|
|
410
|
+
bound_at: z.ZodString;
|
|
411
|
+
}, "strip", z.ZodTypeAny, {
|
|
412
|
+
registry_url: string;
|
|
413
|
+
bound_at: string;
|
|
414
|
+
}, {
|
|
415
|
+
registry_url: string;
|
|
416
|
+
bound_at: string;
|
|
417
|
+
}>;
|
|
418
|
+
schema_version: z.ZodLiteral<1>;
|
|
419
|
+
seq: z.ZodNumber;
|
|
420
|
+
ts: z.ZodString;
|
|
421
|
+
prev: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
422
|
+
entry_sha256: z.ZodString;
|
|
423
|
+
}, "strip", z.ZodTypeAny, {
|
|
424
|
+
schema_version: 1;
|
|
425
|
+
kind: "bound";
|
|
426
|
+
input: {
|
|
427
|
+
skills_md_sha256: string;
|
|
428
|
+
aspiration_sha256s: string[];
|
|
429
|
+
};
|
|
430
|
+
output: {
|
|
431
|
+
registry_url: string;
|
|
432
|
+
bound_at: string;
|
|
433
|
+
};
|
|
434
|
+
seq: number;
|
|
435
|
+
ts: string;
|
|
436
|
+
prev: string | null;
|
|
437
|
+
entry_sha256: string;
|
|
438
|
+
}, {
|
|
439
|
+
schema_version: 1;
|
|
440
|
+
kind: "bound";
|
|
441
|
+
input: {
|
|
442
|
+
skills_md_sha256: string;
|
|
443
|
+
aspiration_sha256s: string[];
|
|
444
|
+
};
|
|
445
|
+
output: {
|
|
446
|
+
registry_url: string;
|
|
447
|
+
bound_at: string;
|
|
448
|
+
};
|
|
449
|
+
seq: number;
|
|
450
|
+
ts: string;
|
|
451
|
+
prev: string | null;
|
|
452
|
+
entry_sha256: string;
|
|
453
|
+
}>;
|
|
454
|
+
declare const AspirationAddedEntrySchema: z.ZodObject<{
|
|
455
|
+
kind: z.ZodLiteral<"aspiration_added">;
|
|
456
|
+
input: z.ZodObject<{
|
|
457
|
+
aspiration_sha256: z.ZodString;
|
|
458
|
+
aspiration_bytes: z.ZodNumber;
|
|
459
|
+
source: z.ZodString;
|
|
460
|
+
}, "strip", z.ZodTypeAny, {
|
|
461
|
+
source: string;
|
|
462
|
+
aspiration_sha256: string;
|
|
463
|
+
aspiration_bytes: number;
|
|
464
|
+
}, {
|
|
465
|
+
source: string;
|
|
466
|
+
aspiration_sha256: string;
|
|
467
|
+
aspiration_bytes: number;
|
|
468
|
+
}>;
|
|
469
|
+
output: z.ZodObject<{
|
|
470
|
+
registry_url: z.ZodString;
|
|
471
|
+
}, "strip", z.ZodTypeAny, {
|
|
472
|
+
registry_url: string;
|
|
473
|
+
}, {
|
|
474
|
+
registry_url: string;
|
|
475
|
+
}>;
|
|
476
|
+
schema_version: z.ZodLiteral<1>;
|
|
477
|
+
seq: z.ZodNumber;
|
|
478
|
+
ts: z.ZodString;
|
|
479
|
+
prev: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
480
|
+
entry_sha256: z.ZodString;
|
|
481
|
+
}, "strip", z.ZodTypeAny, {
|
|
482
|
+
schema_version: 1;
|
|
483
|
+
kind: "aspiration_added";
|
|
484
|
+
input: {
|
|
485
|
+
source: string;
|
|
486
|
+
aspiration_sha256: string;
|
|
487
|
+
aspiration_bytes: number;
|
|
488
|
+
};
|
|
489
|
+
output: {
|
|
490
|
+
registry_url: string;
|
|
491
|
+
};
|
|
492
|
+
seq: number;
|
|
493
|
+
ts: string;
|
|
494
|
+
prev: string | null;
|
|
495
|
+
entry_sha256: string;
|
|
496
|
+
}, {
|
|
497
|
+
schema_version: 1;
|
|
498
|
+
kind: "aspiration_added";
|
|
499
|
+
input: {
|
|
500
|
+
source: string;
|
|
501
|
+
aspiration_sha256: string;
|
|
502
|
+
aspiration_bytes: number;
|
|
503
|
+
};
|
|
504
|
+
output: {
|
|
505
|
+
registry_url: string;
|
|
506
|
+
};
|
|
507
|
+
seq: number;
|
|
508
|
+
ts: string;
|
|
509
|
+
prev: string | null;
|
|
510
|
+
entry_sha256: string;
|
|
511
|
+
}>;
|
|
512
|
+
declare const ProvenanceEntrySchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
513
|
+
kind: z.ZodLiteral<"feed">;
|
|
514
|
+
input: z.ZodObject<{
|
|
515
|
+
source: z.ZodString;
|
|
516
|
+
source_url: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
517
|
+
source_kind: z.ZodEnum<["text", "markdown", "pdf", "epub", "web"]>;
|
|
518
|
+
source_sha256: z.ZodString;
|
|
519
|
+
source_bytes: z.ZodNumber;
|
|
520
|
+
model: z.ZodString;
|
|
521
|
+
}, "strip", z.ZodTypeAny, {
|
|
522
|
+
source: string;
|
|
523
|
+
model: string;
|
|
524
|
+
source_url: string | null;
|
|
525
|
+
source_kind: "text" | "markdown" | "pdf" | "epub" | "web";
|
|
526
|
+
source_sha256: string;
|
|
527
|
+
source_bytes: number;
|
|
528
|
+
}, {
|
|
529
|
+
source: string;
|
|
530
|
+
model: string;
|
|
531
|
+
source_url: string | null;
|
|
532
|
+
source_kind: "text" | "markdown" | "pdf" | "epub" | "web";
|
|
533
|
+
source_sha256: string;
|
|
534
|
+
source_bytes: number;
|
|
535
|
+
}>;
|
|
536
|
+
output: z.ZodObject<{
|
|
537
|
+
skills_added: z.ZodArray<z.ZodString, "many">;
|
|
538
|
+
skills_updated: z.ZodArray<z.ZodString, "many">;
|
|
539
|
+
skills_removed: z.ZodArray<z.ZodString, "many">;
|
|
540
|
+
skills_md_sha256: z.ZodString;
|
|
541
|
+
skills_md_bytes: z.ZodNumber;
|
|
542
|
+
}, "strip", z.ZodTypeAny, {
|
|
543
|
+
skills_added: string[];
|
|
544
|
+
skills_updated: string[];
|
|
545
|
+
skills_removed: string[];
|
|
546
|
+
skills_md_sha256: string;
|
|
547
|
+
skills_md_bytes: number;
|
|
548
|
+
}, {
|
|
549
|
+
skills_added: string[];
|
|
550
|
+
skills_updated: string[];
|
|
551
|
+
skills_removed: string[];
|
|
552
|
+
skills_md_sha256: string;
|
|
553
|
+
skills_md_bytes: number;
|
|
554
|
+
}>;
|
|
555
|
+
schema_version: z.ZodLiteral<1>;
|
|
556
|
+
seq: z.ZodNumber;
|
|
557
|
+
ts: z.ZodString;
|
|
558
|
+
prev: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
559
|
+
entry_sha256: z.ZodString;
|
|
560
|
+
}, "strip", z.ZodTypeAny, {
|
|
561
|
+
schema_version: 1;
|
|
562
|
+
kind: "feed";
|
|
563
|
+
input: {
|
|
564
|
+
source: string;
|
|
565
|
+
model: string;
|
|
566
|
+
source_url: string | null;
|
|
567
|
+
source_kind: "text" | "markdown" | "pdf" | "epub" | "web";
|
|
568
|
+
source_sha256: string;
|
|
569
|
+
source_bytes: number;
|
|
570
|
+
};
|
|
571
|
+
output: {
|
|
572
|
+
skills_added: string[];
|
|
573
|
+
skills_updated: string[];
|
|
574
|
+
skills_removed: string[];
|
|
575
|
+
skills_md_sha256: string;
|
|
576
|
+
skills_md_bytes: number;
|
|
577
|
+
};
|
|
578
|
+
seq: number;
|
|
579
|
+
ts: string;
|
|
580
|
+
prev: string | null;
|
|
581
|
+
entry_sha256: string;
|
|
582
|
+
}, {
|
|
583
|
+
schema_version: 1;
|
|
584
|
+
kind: "feed";
|
|
585
|
+
input: {
|
|
586
|
+
source: string;
|
|
587
|
+
model: string;
|
|
588
|
+
source_url: string | null;
|
|
589
|
+
source_kind: "text" | "markdown" | "pdf" | "epub" | "web";
|
|
590
|
+
source_sha256: string;
|
|
591
|
+
source_bytes: number;
|
|
592
|
+
};
|
|
593
|
+
output: {
|
|
594
|
+
skills_added: string[];
|
|
595
|
+
skills_updated: string[];
|
|
596
|
+
skills_removed: string[];
|
|
597
|
+
skills_md_sha256: string;
|
|
598
|
+
skills_md_bytes: number;
|
|
599
|
+
};
|
|
600
|
+
seq: number;
|
|
601
|
+
ts: string;
|
|
602
|
+
prev: string | null;
|
|
603
|
+
entry_sha256: string;
|
|
604
|
+
}>, z.ZodObject<{
|
|
605
|
+
kind: z.ZodLiteral<"agent_created">;
|
|
606
|
+
input: z.ZodObject<{
|
|
607
|
+
name: z.ZodString;
|
|
608
|
+
}, "strip", z.ZodTypeAny, {
|
|
609
|
+
name: string;
|
|
610
|
+
}, {
|
|
611
|
+
name: string;
|
|
612
|
+
}>;
|
|
613
|
+
output: z.ZodObject<{
|
|
614
|
+
agent_id: z.ZodString;
|
|
615
|
+
}, "strip", z.ZodTypeAny, {
|
|
616
|
+
agent_id: string;
|
|
617
|
+
}, {
|
|
618
|
+
agent_id: string;
|
|
619
|
+
}>;
|
|
620
|
+
schema_version: z.ZodLiteral<1>;
|
|
621
|
+
seq: z.ZodNumber;
|
|
622
|
+
ts: z.ZodString;
|
|
623
|
+
prev: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
624
|
+
entry_sha256: z.ZodString;
|
|
625
|
+
}, "strip", z.ZodTypeAny, {
|
|
626
|
+
schema_version: 1;
|
|
627
|
+
kind: "agent_created";
|
|
628
|
+
input: {
|
|
629
|
+
name: string;
|
|
630
|
+
};
|
|
631
|
+
output: {
|
|
632
|
+
agent_id: string;
|
|
633
|
+
};
|
|
634
|
+
seq: number;
|
|
635
|
+
ts: string;
|
|
636
|
+
prev: string | null;
|
|
637
|
+
entry_sha256: string;
|
|
638
|
+
}, {
|
|
639
|
+
schema_version: 1;
|
|
640
|
+
kind: "agent_created";
|
|
641
|
+
input: {
|
|
642
|
+
name: string;
|
|
643
|
+
};
|
|
644
|
+
output: {
|
|
645
|
+
agent_id: string;
|
|
646
|
+
};
|
|
647
|
+
seq: number;
|
|
648
|
+
ts: string;
|
|
649
|
+
prev: string | null;
|
|
650
|
+
entry_sha256: string;
|
|
651
|
+
}>, z.ZodObject<{
|
|
652
|
+
kind: z.ZodLiteral<"bound">;
|
|
653
|
+
input: z.ZodObject<{
|
|
654
|
+
skills_md_sha256: z.ZodString;
|
|
655
|
+
aspiration_sha256s: z.ZodArray<z.ZodString, "many">;
|
|
656
|
+
}, "strip", z.ZodTypeAny, {
|
|
657
|
+
skills_md_sha256: string;
|
|
658
|
+
aspiration_sha256s: string[];
|
|
659
|
+
}, {
|
|
660
|
+
skills_md_sha256: string;
|
|
661
|
+
aspiration_sha256s: string[];
|
|
662
|
+
}>;
|
|
663
|
+
output: z.ZodObject<{
|
|
664
|
+
registry_url: z.ZodString;
|
|
665
|
+
bound_at: z.ZodString;
|
|
666
|
+
}, "strip", z.ZodTypeAny, {
|
|
667
|
+
registry_url: string;
|
|
668
|
+
bound_at: string;
|
|
669
|
+
}, {
|
|
670
|
+
registry_url: string;
|
|
671
|
+
bound_at: string;
|
|
672
|
+
}>;
|
|
673
|
+
schema_version: z.ZodLiteral<1>;
|
|
674
|
+
seq: z.ZodNumber;
|
|
675
|
+
ts: z.ZodString;
|
|
676
|
+
prev: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
677
|
+
entry_sha256: z.ZodString;
|
|
678
|
+
}, "strip", z.ZodTypeAny, {
|
|
679
|
+
schema_version: 1;
|
|
680
|
+
kind: "bound";
|
|
681
|
+
input: {
|
|
682
|
+
skills_md_sha256: string;
|
|
683
|
+
aspiration_sha256s: string[];
|
|
684
|
+
};
|
|
685
|
+
output: {
|
|
686
|
+
registry_url: string;
|
|
687
|
+
bound_at: string;
|
|
688
|
+
};
|
|
689
|
+
seq: number;
|
|
690
|
+
ts: string;
|
|
691
|
+
prev: string | null;
|
|
692
|
+
entry_sha256: string;
|
|
693
|
+
}, {
|
|
694
|
+
schema_version: 1;
|
|
695
|
+
kind: "bound";
|
|
696
|
+
input: {
|
|
697
|
+
skills_md_sha256: string;
|
|
698
|
+
aspiration_sha256s: string[];
|
|
699
|
+
};
|
|
700
|
+
output: {
|
|
701
|
+
registry_url: string;
|
|
702
|
+
bound_at: string;
|
|
703
|
+
};
|
|
704
|
+
seq: number;
|
|
705
|
+
ts: string;
|
|
706
|
+
prev: string | null;
|
|
707
|
+
entry_sha256: string;
|
|
708
|
+
}>, z.ZodObject<{
|
|
709
|
+
kind: z.ZodLiteral<"aspiration_added">;
|
|
710
|
+
input: z.ZodObject<{
|
|
711
|
+
aspiration_sha256: z.ZodString;
|
|
712
|
+
aspiration_bytes: z.ZodNumber;
|
|
713
|
+
source: z.ZodString;
|
|
714
|
+
}, "strip", z.ZodTypeAny, {
|
|
715
|
+
source: string;
|
|
716
|
+
aspiration_sha256: string;
|
|
717
|
+
aspiration_bytes: number;
|
|
718
|
+
}, {
|
|
719
|
+
source: string;
|
|
720
|
+
aspiration_sha256: string;
|
|
721
|
+
aspiration_bytes: number;
|
|
722
|
+
}>;
|
|
723
|
+
output: z.ZodObject<{
|
|
724
|
+
registry_url: z.ZodString;
|
|
725
|
+
}, "strip", z.ZodTypeAny, {
|
|
726
|
+
registry_url: string;
|
|
727
|
+
}, {
|
|
728
|
+
registry_url: string;
|
|
729
|
+
}>;
|
|
730
|
+
schema_version: z.ZodLiteral<1>;
|
|
731
|
+
seq: z.ZodNumber;
|
|
732
|
+
ts: z.ZodString;
|
|
733
|
+
prev: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
734
|
+
entry_sha256: z.ZodString;
|
|
735
|
+
}, "strip", z.ZodTypeAny, {
|
|
736
|
+
schema_version: 1;
|
|
737
|
+
kind: "aspiration_added";
|
|
738
|
+
input: {
|
|
739
|
+
source: string;
|
|
740
|
+
aspiration_sha256: string;
|
|
741
|
+
aspiration_bytes: number;
|
|
742
|
+
};
|
|
743
|
+
output: {
|
|
744
|
+
registry_url: string;
|
|
745
|
+
};
|
|
746
|
+
seq: number;
|
|
747
|
+
ts: string;
|
|
748
|
+
prev: string | null;
|
|
749
|
+
entry_sha256: string;
|
|
750
|
+
}, {
|
|
751
|
+
schema_version: 1;
|
|
752
|
+
kind: "aspiration_added";
|
|
753
|
+
input: {
|
|
754
|
+
source: string;
|
|
755
|
+
aspiration_sha256: string;
|
|
756
|
+
aspiration_bytes: number;
|
|
757
|
+
};
|
|
758
|
+
output: {
|
|
759
|
+
registry_url: string;
|
|
760
|
+
};
|
|
761
|
+
seq: number;
|
|
762
|
+
ts: string;
|
|
763
|
+
prev: string | null;
|
|
764
|
+
entry_sha256: string;
|
|
765
|
+
}>]>;
|
|
766
|
+
declare const KNOWN_ENTRY_KINDS: readonly ["feed", "agent_created", "bound", "aspiration_added"];
|
|
767
|
+
type FeedEntry = z.infer<typeof FeedEntrySchema>;
|
|
768
|
+
type AgentCreatedEntry = z.infer<typeof AgentCreatedEntrySchema>;
|
|
769
|
+
type BoundEntry = z.infer<typeof BoundEntrySchema>;
|
|
770
|
+
type AspirationAddedEntry = z.infer<typeof AspirationAddedEntrySchema>;
|
|
771
|
+
type ProvenanceEntry = z.infer<typeof ProvenanceEntrySchema>;
|
|
772
|
+
type EntryDraft = {
|
|
773
|
+
kind: 'feed';
|
|
774
|
+
input: z.input<typeof FeedInputSchema>;
|
|
775
|
+
output: z.input<typeof FeedOutputSchema>;
|
|
776
|
+
ts?: string;
|
|
777
|
+
} | {
|
|
778
|
+
kind: 'agent_created';
|
|
779
|
+
input: z.input<typeof AgentCreatedInputSchema>;
|
|
780
|
+
output: z.input<typeof AgentCreatedOutputSchema>;
|
|
781
|
+
ts?: string;
|
|
782
|
+
} | {
|
|
783
|
+
kind: 'bound';
|
|
784
|
+
input: z.input<typeof BoundInputSchema>;
|
|
785
|
+
output: z.input<typeof BoundOutputSchema>;
|
|
786
|
+
ts?: string;
|
|
787
|
+
} | {
|
|
788
|
+
kind: 'aspiration_added';
|
|
789
|
+
input: z.input<typeof AspirationAddedInputSchema>;
|
|
790
|
+
output: z.input<typeof AspirationAddedOutputSchema>;
|
|
791
|
+
ts?: string;
|
|
792
|
+
};
|
|
793
|
+
declare class ProvenanceError extends Error {
|
|
794
|
+
constructor(message: string);
|
|
795
|
+
}
|
|
796
|
+
declare function computeEntryHash(entry: Omit<ProvenanceEntry, 'entry_sha256'>): string;
|
|
797
|
+
declare function readChain(path: string): Promise<ProvenanceEntry[]>;
|
|
798
|
+
declare function verifyChain(entries: readonly ProvenanceEntry[]): void;
|
|
799
|
+
interface RecordEntryOptions {
|
|
800
|
+
path: string;
|
|
801
|
+
draft: EntryDraft;
|
|
802
|
+
ts?: string;
|
|
803
|
+
prev?: string | null;
|
|
804
|
+
seq?: number;
|
|
805
|
+
lock?: LockOptions;
|
|
806
|
+
}
|
|
807
|
+
declare function recordEntry(opts: RecordEntryOptions): Promise<ProvenanceEntry>;
|
|
808
|
+
|
|
809
|
+
interface LoadedSource {
|
|
810
|
+
source: string;
|
|
811
|
+
source_url: string | null;
|
|
812
|
+
source_kind: SourceKind;
|
|
813
|
+
content: string;
|
|
814
|
+
}
|
|
815
|
+
declare class SourceError extends Error {
|
|
816
|
+
constructor(message: string);
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
declare function isWebUrl(target: string): boolean;
|
|
820
|
+
declare function readSource(target: string): Promise<LoadedSource>;
|
|
821
|
+
|
|
822
|
+
declare function normalizeUrl(input: string): string;
|
|
823
|
+
|
|
824
|
+
interface ExpandOptions {
|
|
825
|
+
cwd?: string;
|
|
826
|
+
}
|
|
827
|
+
declare function expandPatterns(patterns: readonly string[], opts?: ExpandOptions): Promise<string[]>;
|
|
828
|
+
|
|
829
|
+
declare const MODEL_ID = "claude-haiku-4-5-20251001";
|
|
830
|
+
declare const EMIT_SKILLS_TOOL: {
|
|
831
|
+
name: string;
|
|
832
|
+
description: string;
|
|
833
|
+
input_schema: {
|
|
834
|
+
type: "object";
|
|
835
|
+
properties: {
|
|
836
|
+
skills: {
|
|
837
|
+
type: string;
|
|
838
|
+
items: {
|
|
839
|
+
type: string;
|
|
840
|
+
properties: {
|
|
841
|
+
slug: {
|
|
842
|
+
type: string;
|
|
843
|
+
pattern: string;
|
|
844
|
+
maxLength: number;
|
|
845
|
+
description: string;
|
|
846
|
+
};
|
|
847
|
+
name: {
|
|
848
|
+
type: string;
|
|
849
|
+
minLength: number;
|
|
850
|
+
maxLength: number;
|
|
851
|
+
description: string;
|
|
852
|
+
};
|
|
853
|
+
description: {
|
|
854
|
+
type: string;
|
|
855
|
+
minLength: number;
|
|
856
|
+
maxLength: number;
|
|
857
|
+
description: string;
|
|
858
|
+
};
|
|
859
|
+
tags: {
|
|
860
|
+
type: string;
|
|
861
|
+
minItems: number;
|
|
862
|
+
maxItems: number;
|
|
863
|
+
items: {
|
|
864
|
+
type: string;
|
|
865
|
+
pattern: string;
|
|
866
|
+
maxLength: number;
|
|
867
|
+
};
|
|
868
|
+
description: string;
|
|
869
|
+
};
|
|
870
|
+
};
|
|
871
|
+
required: string[];
|
|
872
|
+
additionalProperties: boolean;
|
|
873
|
+
};
|
|
874
|
+
};
|
|
875
|
+
};
|
|
876
|
+
required: string[];
|
|
877
|
+
additionalProperties: boolean;
|
|
878
|
+
};
|
|
879
|
+
};
|
|
880
|
+
declare const SYSTEM_PROMPT = "You are an extraction engine that reads a corpus and produces a structured set of distinct skills.\n\nA \"skill\" is a transferable, reusable practice or technique that a person could apply across contexts \u2014 not a fact, definition, story, or one-off opinion.\n\nFor every skill you identify, emit:\n- slug: kebab-case identifier matching ^[a-z0-9]+(-[a-z0-9]+)*$, unique within this output\n- name: short human-readable title (3-8 words; Title Case acceptable)\n- description: one paragraph (1-4 sentences), self-contained, written as a directly applicable instruction\n- tags: 1-6 kebab-case topical labels matching ^[a-z0-9]+(-[a-z0-9]+)*$\n\nQuality rules:\n- Only emit skills that are clearly supported by the corpus.\n- Do not invent skills to pad the list. Returning fewer high-quality skills is preferred to many vague ones.\n- Avoid near-duplicates. If two passages describe the same underlying technique, emit one skill.\n- Do not include source citations, page numbers, or quotes in the description.\n- The description must stand on its own; a reader who has not seen the corpus must be able to apply the skill.\n\nAlways respond by calling the emit_skills tool exactly once with the full result. Do not include any text outside the tool call.";
|
|
881
|
+
|
|
882
|
+
declare class ParseSkillsError extends Error {
|
|
883
|
+
constructor(message: string);
|
|
884
|
+
}
|
|
885
|
+
declare function parseSkills(input: string): SkillsDoc;
|
|
886
|
+
|
|
887
|
+
interface MergeResult {
|
|
888
|
+
merged: Skill[];
|
|
889
|
+
added: string[];
|
|
890
|
+
updated: string[];
|
|
891
|
+
}
|
|
892
|
+
declare function mergeSkills(existing: readonly Skill[], incoming: readonly Skill[]): MergeResult;
|
|
893
|
+
|
|
894
|
+
type CanonicalJson = string | number | boolean | null | CanonicalJson[] | {
|
|
895
|
+
[key: string]: CanonicalJson;
|
|
896
|
+
};
|
|
897
|
+
declare class CanonicalJsonError extends Error {
|
|
898
|
+
constructor(message: string);
|
|
899
|
+
}
|
|
900
|
+
declare function canonicalize(value: CanonicalJson): string;
|
|
901
|
+
|
|
902
|
+
interface FeedOptions {
|
|
903
|
+
model?: string;
|
|
904
|
+
baseDir?: string;
|
|
905
|
+
client?: unknown;
|
|
906
|
+
apiKey?: string;
|
|
907
|
+
ts?: string | (() => string);
|
|
908
|
+
loadSource?: (target: string) => Promise<LoadedSource>;
|
|
909
|
+
stdout?: NodeJS.WritableStream;
|
|
910
|
+
stderr?: NodeJS.WritableStream;
|
|
911
|
+
}
|
|
912
|
+
interface PerSourceResult {
|
|
913
|
+
target: string;
|
|
914
|
+
source: string;
|
|
915
|
+
added: string[];
|
|
916
|
+
updated: string[];
|
|
917
|
+
skillsMdSha256: string;
|
|
918
|
+
skillsMdBytes: number;
|
|
919
|
+
estimatedTokens: number;
|
|
920
|
+
warnedOverCap: boolean;
|
|
921
|
+
}
|
|
922
|
+
interface FeedResult {
|
|
923
|
+
agentId: string;
|
|
924
|
+
perSource: PerSourceResult[];
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Run a batch of feeds: expand patterns, then for each resolved source
|
|
928
|
+
* sequentially read → extract → merge → write skills.md → append a feed
|
|
929
|
+
* entry to provenance.jsonl.
|
|
930
|
+
*
|
|
931
|
+
* Sequential is load-bearing: the provenance chain depends on a single
|
|
932
|
+
* writer per agent (see provenance.ts). Stop-on-first-error is fine
|
|
933
|
+
* because each source's provenance entry lands before the next runs, so
|
|
934
|
+
* partial progress is always durable.
|
|
935
|
+
*
|
|
936
|
+
* Crash-window note: writeSkillsAtomic happens before recordEntry. A crash
|
|
937
|
+
* (or kill -9) between the two leaves skills.md ahead of the chain by one
|
|
938
|
+
* feed. Recovery is benign — the next feed of the same source produces an
|
|
939
|
+
* identical-content merge (no-op) and a new chain entry, or, if the source
|
|
940
|
+
* differs, an "updated" entry. The chain stays valid; the on-disk skills.md
|
|
941
|
+
* is just slightly more current than the chain's last feed entry claims.
|
|
942
|
+
*/
|
|
943
|
+
declare function runFeed(agentId: string, patterns: readonly string[], opts?: FeedOptions): Promise<FeedResult>;
|
|
944
|
+
declare function isFeedError(err: unknown): err is Error;
|
|
945
|
+
|
|
946
|
+
interface AgentsCreateOptions {
|
|
947
|
+
name?: string;
|
|
948
|
+
baseDir?: string;
|
|
949
|
+
stdout?: NodeJS.WritableStream;
|
|
950
|
+
}
|
|
951
|
+
declare function runAgentsCreate(opts?: AgentsCreateOptions): Promise<string>;
|
|
952
|
+
interface AgentsListOptions {
|
|
953
|
+
baseDir?: string;
|
|
954
|
+
stdout?: NodeJS.WritableStream;
|
|
955
|
+
}
|
|
956
|
+
declare function runAgentsList(opts?: AgentsListOptions): Promise<void>;
|
|
957
|
+
|
|
958
|
+
interface LoginOptions {
|
|
959
|
+
registry?: string;
|
|
960
|
+
configDir?: string;
|
|
961
|
+
fetch?: typeof globalThis.fetch;
|
|
962
|
+
sleep?: (ms: number) => Promise<void>;
|
|
963
|
+
now?: () => number;
|
|
964
|
+
stdout?: NodeJS.WritableStream;
|
|
965
|
+
stderr?: NodeJS.WritableStream;
|
|
966
|
+
}
|
|
967
|
+
interface LoginResult {
|
|
968
|
+
registryUrl: string;
|
|
969
|
+
}
|
|
970
|
+
declare function runLogin(opts?: LoginOptions): Promise<LoginResult>;
|
|
971
|
+
interface LogoutOptions {
|
|
972
|
+
configDir?: string;
|
|
973
|
+
stdout?: NodeJS.WritableStream;
|
|
974
|
+
}
|
|
975
|
+
declare function runLogout(opts?: LogoutOptions): Promise<void>;
|
|
976
|
+
declare function isLoginError(err: unknown): err is Error;
|
|
977
|
+
|
|
978
|
+
interface BindOptions {
|
|
979
|
+
baseDir?: string;
|
|
980
|
+
configDir?: string;
|
|
981
|
+
fetch?: typeof globalThis.fetch;
|
|
982
|
+
ts?: string;
|
|
983
|
+
stdout?: NodeJS.WritableStream;
|
|
984
|
+
stderr?: NodeJS.WritableStream;
|
|
985
|
+
}
|
|
986
|
+
interface BindResult {
|
|
987
|
+
agentId: string;
|
|
988
|
+
registryUrl: string;
|
|
989
|
+
skillsMdSha256: string;
|
|
990
|
+
boundAt: string;
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Bind a local agent to the registry it was logged into.
|
|
994
|
+
*
|
|
995
|
+
* Ordering: the registry POST happens first; the local `bound` provenance
|
|
996
|
+
* entry and registry.json are written only on a 2xx. This keeps the local
|
|
997
|
+
* chain a subset of registry truth — a crash after a successful POST but
|
|
998
|
+
* before the local write is benign, because a re-run is a same-user re-bind
|
|
999
|
+
* (allowed by the registry) and simply records the entry then.
|
|
1000
|
+
*/
|
|
1001
|
+
declare function runBind(agentId: string, opts?: BindOptions): Promise<BindResult>;
|
|
1002
|
+
declare function isBindError(err: unknown): err is Error;
|
|
1003
|
+
|
|
1004
|
+
interface AspirationsAddOptions {
|
|
1005
|
+
baseDir?: string;
|
|
1006
|
+
configDir?: string;
|
|
1007
|
+
fetch?: typeof globalThis.fetch;
|
|
1008
|
+
ts?: string;
|
|
1009
|
+
stdout?: NodeJS.WritableStream;
|
|
1010
|
+
stderr?: NodeJS.WritableStream;
|
|
1011
|
+
}
|
|
1012
|
+
interface AspirationsAddResult {
|
|
1013
|
+
agentId: string;
|
|
1014
|
+
registryUrl: string;
|
|
1015
|
+
aspirationSha256: string;
|
|
1016
|
+
source: string;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Append an aspiration to a bound agent.
|
|
1020
|
+
*
|
|
1021
|
+
* Append-only: there is deliberately no edit or delete operation — the
|
|
1022
|
+
* registry rejects mutation and so does this surface by omission.
|
|
1023
|
+
*
|
|
1024
|
+
* Requires a prior bind: we check the local registry.json and fail fast with
|
|
1025
|
+
* guidance rather than letting the registry return a 404.
|
|
1026
|
+
*
|
|
1027
|
+
* Ordering matches bind — POST first, record the `aspiration_added`
|
|
1028
|
+
* provenance entry only on a 2xx.
|
|
1029
|
+
*/
|
|
1030
|
+
declare function runAspirationsAdd(agentId: string, mdFile: string, opts?: AspirationsAddOptions): Promise<AspirationsAddResult>;
|
|
1031
|
+
declare function isAspirationsError(err: unknown): err is Error;
|
|
1032
|
+
|
|
1033
|
+
declare function isUserFacingError(err: unknown): err is Error;
|
|
1034
|
+
|
|
1035
|
+
declare function estimateTokens(text: string): number;
|
|
1036
|
+
|
|
1037
|
+
declare const CREDENTIALS_SCHEMA_VERSION = 1;
|
|
1038
|
+
declare const DEFAULT_REGISTRY_URL = "https://registry.modex.md";
|
|
1039
|
+
declare const CredentialsSchema: z.ZodObject<{
|
|
1040
|
+
schema_version: z.ZodLiteral<1>;
|
|
1041
|
+
access_token: z.ZodString;
|
|
1042
|
+
registry_url: z.ZodString;
|
|
1043
|
+
}, "strip", z.ZodTypeAny, {
|
|
1044
|
+
schema_version: 1;
|
|
1045
|
+
registry_url: string;
|
|
1046
|
+
access_token: string;
|
|
1047
|
+
}, {
|
|
1048
|
+
schema_version: 1;
|
|
1049
|
+
registry_url: string;
|
|
1050
|
+
access_token: string;
|
|
1051
|
+
}>;
|
|
1052
|
+
type Credentials = z.infer<typeof CredentialsSchema>;
|
|
1053
|
+
declare class CredentialsError extends Error {
|
|
1054
|
+
constructor(message: string);
|
|
1055
|
+
}
|
|
1056
|
+
declare function configDir(): string;
|
|
1057
|
+
declare function credentialsPath(dir?: string): string;
|
|
1058
|
+
declare function loadCredentials(dir?: string): Promise<Credentials | null>;
|
|
1059
|
+
declare function saveCredentials(credentials: Credentials, dir?: string): Promise<void>;
|
|
1060
|
+
declare function clearCredentials(dir?: string): Promise<void>;
|
|
1061
|
+
|
|
1062
|
+
declare const REGISTRY_STATE_SCHEMA_VERSION = 1;
|
|
1063
|
+
declare const RegistryStateSchema: z.ZodObject<{
|
|
1064
|
+
schema_version: z.ZodLiteral<1>;
|
|
1065
|
+
registry_url: z.ZodString;
|
|
1066
|
+
agent_id: z.ZodString;
|
|
1067
|
+
bound_at: z.ZodString;
|
|
1068
|
+
last_server_skills_md_sha256: z.ZodString;
|
|
1069
|
+
}, "strip", z.ZodTypeAny, {
|
|
1070
|
+
schema_version: 1;
|
|
1071
|
+
agent_id: string;
|
|
1072
|
+
registry_url: string;
|
|
1073
|
+
bound_at: string;
|
|
1074
|
+
last_server_skills_md_sha256: string;
|
|
1075
|
+
}, {
|
|
1076
|
+
schema_version: 1;
|
|
1077
|
+
agent_id: string;
|
|
1078
|
+
registry_url: string;
|
|
1079
|
+
bound_at: string;
|
|
1080
|
+
last_server_skills_md_sha256: string;
|
|
1081
|
+
}>;
|
|
1082
|
+
type RegistryState = z.infer<typeof RegistryStateSchema>;
|
|
1083
|
+
declare class RegistryStateError extends Error {
|
|
1084
|
+
constructor(message: string);
|
|
1085
|
+
}
|
|
1086
|
+
declare function readRegistryState(path: string): Promise<RegistryState | null>;
|
|
1087
|
+
declare function writeRegistryState(path: string, state: RegistryState): Promise<void>;
|
|
1088
|
+
|
|
1089
|
+
declare class RegistryError extends Error {
|
|
1090
|
+
readonly status: number | null;
|
|
1091
|
+
readonly code: string | null;
|
|
1092
|
+
constructor(message: string, opts?: {
|
|
1093
|
+
status?: number | null;
|
|
1094
|
+
code?: string | null;
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
declare const DeviceCodeStartSchema: z.ZodObject<{
|
|
1098
|
+
device_code: z.ZodString;
|
|
1099
|
+
user_code: z.ZodString;
|
|
1100
|
+
verify_url: z.ZodString;
|
|
1101
|
+
expires_in: z.ZodNumber;
|
|
1102
|
+
interval: z.ZodNumber;
|
|
1103
|
+
}, "strip", z.ZodTypeAny, {
|
|
1104
|
+
device_code: string;
|
|
1105
|
+
user_code: string;
|
|
1106
|
+
verify_url: string;
|
|
1107
|
+
expires_in: number;
|
|
1108
|
+
interval: number;
|
|
1109
|
+
}, {
|
|
1110
|
+
device_code: string;
|
|
1111
|
+
user_code: string;
|
|
1112
|
+
verify_url: string;
|
|
1113
|
+
expires_in: number;
|
|
1114
|
+
interval: number;
|
|
1115
|
+
}>;
|
|
1116
|
+
type DeviceCodeStart = z.infer<typeof DeviceCodeStartSchema>;
|
|
1117
|
+
declare const TokenResponseSchema: z.ZodUnion<[z.ZodObject<{
|
|
1118
|
+
access_token: z.ZodString;
|
|
1119
|
+
}, "strip", z.ZodTypeAny, {
|
|
1120
|
+
access_token: string;
|
|
1121
|
+
}, {
|
|
1122
|
+
access_token: string;
|
|
1123
|
+
}>, z.ZodObject<{
|
|
1124
|
+
error: z.ZodString;
|
|
1125
|
+
}, "strip", z.ZodTypeAny, {
|
|
1126
|
+
error: string;
|
|
1127
|
+
}, {
|
|
1128
|
+
error: string;
|
|
1129
|
+
}>]>;
|
|
1130
|
+
type TokenResponse = z.infer<typeof TokenResponseSchema>;
|
|
1131
|
+
interface BindRequest {
|
|
1132
|
+
skills_md: string;
|
|
1133
|
+
skills_md_sha256: string;
|
|
1134
|
+
provenance_head_sha256: string;
|
|
1135
|
+
aspiration_sha256s: string[];
|
|
1136
|
+
}
|
|
1137
|
+
declare const BindResponseSchema: z.ZodObject<{
|
|
1138
|
+
skills_md_sha256: z.ZodString;
|
|
1139
|
+
bound_at: z.ZodString;
|
|
1140
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1141
|
+
skills_md_sha256: z.ZodString;
|
|
1142
|
+
bound_at: z.ZodString;
|
|
1143
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1144
|
+
skills_md_sha256: z.ZodString;
|
|
1145
|
+
bound_at: z.ZodString;
|
|
1146
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
1147
|
+
type BindResponse = z.infer<typeof BindResponseSchema>;
|
|
1148
|
+
interface AspirationRequest {
|
|
1149
|
+
sha256: string;
|
|
1150
|
+
content: string;
|
|
1151
|
+
}
|
|
1152
|
+
declare const AspirationResponseSchema: z.ZodObject<{
|
|
1153
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
1154
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1155
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
1156
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1157
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
1158
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
1159
|
+
type AspirationResponse = z.infer<typeof AspirationResponseSchema>;
|
|
1160
|
+
|
|
1161
|
+
interface RegistryDeps {
|
|
1162
|
+
fetch?: typeof globalThis.fetch;
|
|
1163
|
+
sleep?: (ms: number) => Promise<void>;
|
|
1164
|
+
now?: () => number;
|
|
1165
|
+
}
|
|
1166
|
+
declare function startDeviceCode(registryUrl: string, deps?: RegistryDeps): Promise<DeviceCodeStart>;
|
|
1167
|
+
interface PollDeps extends RegistryDeps {
|
|
1168
|
+
onPending?: () => void;
|
|
1169
|
+
}
|
|
1170
|
+
declare function pollForToken(registryUrl: string, start: DeviceCodeStart, deps?: PollDeps): Promise<string>;
|
|
1171
|
+
declare function bindAgent(registryUrl: string, agentId: string, token: string, body: BindRequest, deps?: RegistryDeps): Promise<BindResponse>;
|
|
1172
|
+
declare function addAspiration(registryUrl: string, agentId: string, token: string, body: AspirationRequest, deps?: RegistryDeps): Promise<AspirationResponse>;
|
|
1173
|
+
|
|
1174
|
+
declare const AGENT_CONFIG_SCHEMA_VERSION = 0;
|
|
1175
|
+
declare const DEFAULT_TOKEN_CAP_WARN_AT = 32000;
|
|
1176
|
+
declare const MODEX_DIR_NAME = ".modex";
|
|
1177
|
+
declare const AgentConfigSchema: z.ZodObject<{
|
|
1178
|
+
schema_version: z.ZodLiteral<0>;
|
|
1179
|
+
id: z.ZodString;
|
|
1180
|
+
name: z.ZodString;
|
|
1181
|
+
created_at: z.ZodString;
|
|
1182
|
+
token_cap_warn_at: z.ZodNumber;
|
|
1183
|
+
}, "strip", z.ZodTypeAny, {
|
|
1184
|
+
name: string;
|
|
1185
|
+
schema_version: 0;
|
|
1186
|
+
id: string;
|
|
1187
|
+
created_at: string;
|
|
1188
|
+
token_cap_warn_at: number;
|
|
1189
|
+
}, {
|
|
1190
|
+
name: string;
|
|
1191
|
+
schema_version: 0;
|
|
1192
|
+
id: string;
|
|
1193
|
+
created_at: string;
|
|
1194
|
+
token_cap_warn_at: number;
|
|
1195
|
+
}>;
|
|
1196
|
+
type AgentConfig = z.infer<typeof AgentConfigSchema>;
|
|
1197
|
+
interface AgentPaths {
|
|
1198
|
+
dir: string;
|
|
1199
|
+
configFile: string;
|
|
1200
|
+
skillsFile: string;
|
|
1201
|
+
provenanceFile: string;
|
|
1202
|
+
registryFile: string;
|
|
1203
|
+
}
|
|
1204
|
+
interface AgentRecord {
|
|
1205
|
+
config: AgentConfig;
|
|
1206
|
+
paths: AgentPaths;
|
|
1207
|
+
}
|
|
1208
|
+
declare class AgentError extends Error {
|
|
1209
|
+
constructor(message: string);
|
|
1210
|
+
}
|
|
1211
|
+
declare function writeSkillsAtomic(path: string, content: string): Promise<void>;
|
|
1212
|
+
interface CreateAgentOptions {
|
|
1213
|
+
name?: string;
|
|
1214
|
+
baseDir?: string;
|
|
1215
|
+
id?: string;
|
|
1216
|
+
ts?: string;
|
|
1217
|
+
tokenCapWarnAt?: number;
|
|
1218
|
+
}
|
|
1219
|
+
declare function createAgent(opts?: CreateAgentOptions): Promise<AgentRecord>;
|
|
1220
|
+
declare function loadAgent(id: string, baseDir?: string): Promise<AgentRecord>;
|
|
1221
|
+
declare function listAgents(baseDir?: string): Promise<AgentRecord[]>;
|
|
1222
|
+
declare function readAgentSkills(skillsFile: string): Promise<{
|
|
1223
|
+
slug: string;
|
|
1224
|
+
name: string;
|
|
1225
|
+
description: string;
|
|
1226
|
+
tags: string[];
|
|
1227
|
+
source: string;
|
|
1228
|
+
}[]>;
|
|
1229
|
+
|
|
1230
|
+
export { AGENT_CONFIG_SCHEMA_VERSION, type AgentConfig, AgentConfigSchema, type AgentCreatedEntry, AgentCreatedEntrySchema, AgentError, type AgentPaths, type AgentRecord, type AgentsCreateOptions, type AgentsListOptions, type AspirationAddedEntry, AspirationAddedEntrySchema, type AspirationRequest, type AspirationResponse, type AspirationsAddOptions, type AspirationsAddResult, type BindOptions, type BindRequest, type BindResponse, type BindResult, type BoundEntry, BoundEntrySchema, CREDENTIALS_SCHEMA_VERSION, type CanonicalJson, CanonicalJsonError, type CreateAgentOptions, type Credentials, CredentialsError, CredentialsSchema, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_REGISTRY_URL, DEFAULT_STALE_MS, DEFAULT_TOKEN_CAP_WARN_AT, type DeviceCodeStart, EMIT_SKILLS_TOOL, type EntryDraft, type ExpandOptions, type ExtractOptions, type ExtractedSkill, ExtractedSkillSchema, ExtractionError, type ExtractionResult, ExtractionResultSchema, type FeedEntry, FeedEntrySchema, type FeedOptions, type FeedResult, FileLockError, KNOWN_ENTRY_KINDS, type LoadedSource, type LockOptions, type LoginOptions, type LoginResult, type LogoutOptions, MODEL_ID, MODEX_DIR_NAME, type MergeResult, PROVENANCE_SCHEMA_VERSION, ParseSkillsError, type PerSourceResult, type PollDeps, type ProvenanceEntry, ProvenanceEntrySchema, ProvenanceError, REGISTRY_STATE_SCHEMA_VERSION, type RecordEntryOptions, type RegistryDeps, RegistryError, type RegistryState, RegistryStateError, RegistryStateSchema, SCHEMA_VERSION, SOURCE_KINDS, SYSTEM_PROMPT, type Skill, SkillSchema, type SkillsDoc, SkillsDocSchema, SourceError, type SourceKind, type TokenResponse, addAspiration, bindAgent, buildDoc, canonicalize, clearCredentials, computeEntryHash, configDir, createAgent, credentialsPath, estimateTokens, expandPatterns, extractSkills, isAspirationsError, isBindError, isFeedError, isLoginError, isUserFacingError, isWebUrl, listAgents, loadAgent, loadCredentials, mergeSkills, normalizeUrl, parseSkills, pollForToken, readAgentSkills, readChain, readRegistryState, readSource, recordEntry, runAgentsCreate, runAgentsList, runAspirationsAdd, runBind, runFeed, runLogin, runLogout, saveCredentials, serialize, startDeviceCode, verifyChain, withFileLock, writeRegistryState, writeSkillsAtomic };
|