@hivemagnus/emberfold 0.0.0-stage → 0.2.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,556 @@
1
+ import { z } from 'zod';
2
+ export declare const ToolCallSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ type: z.ZodLiteral<"function">;
5
+ function: z.ZodObject<{
6
+ name: z.ZodString;
7
+ arguments: z.ZodString;
8
+ }, z.core.$strict>;
9
+ }, z.core.$strict>;
10
+ export declare const ChatMessageSchema: z.ZodObject<{
11
+ role: z.ZodEnum<{
12
+ system: "system";
13
+ user: "user";
14
+ assistant: "assistant";
15
+ tool: "tool";
16
+ }>;
17
+ content: z.ZodNullable<z.ZodString>;
18
+ tool_call_id: z.ZodOptional<z.ZodString>;
19
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
20
+ id: z.ZodString;
21
+ type: z.ZodLiteral<"function">;
22
+ function: z.ZodObject<{
23
+ name: z.ZodString;
24
+ arguments: z.ZodString;
25
+ }, z.core.$strict>;
26
+ }, z.core.$strict>>>;
27
+ }, z.core.$strict>;
28
+ export type ChatMessage = z.infer<typeof ChatMessageSchema>;
29
+ export declare const MessageSchema: z.ZodObject<{
30
+ role: z.ZodEnum<{
31
+ system: "system";
32
+ user: "user";
33
+ assistant: "assistant";
34
+ tool: "tool";
35
+ }>;
36
+ content: z.ZodNullable<z.ZodString>;
37
+ tool_call_id: z.ZodOptional<z.ZodString>;
38
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
39
+ id: z.ZodString;
40
+ type: z.ZodLiteral<"function">;
41
+ function: z.ZodObject<{
42
+ name: z.ZodString;
43
+ arguments: z.ZodString;
44
+ }, z.core.$strict>;
45
+ }, z.core.$strict>>>;
46
+ id: z.ZodString;
47
+ }, z.core.$strict>;
48
+ export type Message = z.infer<typeof MessageSchema>;
49
+ export declare const ExchangeSchema: z.ZodObject<{
50
+ id: z.ZodString;
51
+ message_ids: z.ZodArray<z.ZodString>;
52
+ completed: z.ZodBoolean;
53
+ }, z.core.$strict>;
54
+ export declare const ProtectedSpanSchema: z.ZodObject<{
55
+ message_id: z.ZodString;
56
+ source_sha256: z.ZodString;
57
+ start: z.ZodNumber;
58
+ end: z.ZodNumber;
59
+ text: z.ZodString;
60
+ }, z.core.$strict>;
61
+ export declare const ProfileSchema: z.ZodEnum<{
62
+ general: "general";
63
+ creative: "creative";
64
+ reflective: "reflective";
65
+ }>;
66
+ export declare const PolicySchema: z.ZodObject<{
67
+ profile: z.ZodDefault<z.ZodEnum<{
68
+ general: "general";
69
+ creative: "creative";
70
+ reflective: "reflective";
71
+ }>>;
72
+ revision: z.ZodDefault<z.ZodNumber>;
73
+ recent_exchanges: z.ZodDefault<z.ZodNumber>;
74
+ trigger_ratio: z.ZodDefault<z.ZodNumber>;
75
+ summary_max_tokens: z.ZodDefault<z.ZodNumber>;
76
+ summarizer_input_tokens: z.ZodDefault<z.ZodNumber>;
77
+ summarizer_output_tokens: z.ZodDefault<z.ZodNumber>;
78
+ max_passes: z.ZodDefault<z.ZodNumber>;
79
+ require_measured_tokens: z.ZodDefault<z.ZodBoolean>;
80
+ }, z.core.$strict>;
81
+ export type Policy = z.infer<typeof PolicySchema>;
82
+ export declare const SummaryItemSchema: z.ZodObject<{
83
+ id: z.ZodString;
84
+ kind: z.ZodEnum<{
85
+ decision: "decision";
86
+ observation: "observation";
87
+ open_item: "open_item";
88
+ correction: "correction";
89
+ status: "status";
90
+ canon: "canon";
91
+ hypothesis: "hypothesis";
92
+ behavior_change: "behavior_change";
93
+ }>;
94
+ text: z.ZodString;
95
+ source_message_ids: z.ZodArray<z.ZodString>;
96
+ historical_status: z.ZodLiteral<"historical_unverified">;
97
+ epistemic_status: z.ZodEnum<{
98
+ decision: "decision";
99
+ observation: "observation";
100
+ hypothesis: "hypothesis";
101
+ reported: "reported";
102
+ unresolved: "unresolved";
103
+ }>;
104
+ supersedes: z.ZodDefault<z.ZodArray<z.ZodString>>;
105
+ resolves: z.ZodDefault<z.ZodArray<z.ZodString>>;
106
+ }, z.core.$strict>;
107
+ export declare const SummarySchema: z.ZodObject<{
108
+ items: z.ZodArray<z.ZodObject<{
109
+ id: z.ZodString;
110
+ kind: z.ZodEnum<{
111
+ decision: "decision";
112
+ observation: "observation";
113
+ open_item: "open_item";
114
+ correction: "correction";
115
+ status: "status";
116
+ canon: "canon";
117
+ hypothesis: "hypothesis";
118
+ behavior_change: "behavior_change";
119
+ }>;
120
+ text: z.ZodString;
121
+ source_message_ids: z.ZodArray<z.ZodString>;
122
+ historical_status: z.ZodLiteral<"historical_unverified">;
123
+ epistemic_status: z.ZodEnum<{
124
+ decision: "decision";
125
+ observation: "observation";
126
+ hypothesis: "hypothesis";
127
+ reported: "reported";
128
+ unresolved: "unresolved";
129
+ }>;
130
+ supersedes: z.ZodDefault<z.ZodArray<z.ZodString>>;
131
+ resolves: z.ZodDefault<z.ZodArray<z.ZodString>>;
132
+ }, z.core.$strict>>;
133
+ }, z.core.$strict>;
134
+ export type Summary = z.infer<typeof SummarySchema>;
135
+ export declare const CheckpointSchema: z.ZodObject<{
136
+ schema_version: z.ZodLiteral<1>;
137
+ id: z.ZodString;
138
+ namespace: z.ZodString;
139
+ parent_id: z.ZodNullable<z.ZodString>;
140
+ source_message_ids: z.ZodArray<z.ZodString>;
141
+ source_sha256: z.ZodString;
142
+ summary: z.ZodObject<{
143
+ items: z.ZodArray<z.ZodObject<{
144
+ id: z.ZodString;
145
+ kind: z.ZodEnum<{
146
+ decision: "decision";
147
+ observation: "observation";
148
+ open_item: "open_item";
149
+ correction: "correction";
150
+ status: "status";
151
+ canon: "canon";
152
+ hypothesis: "hypothesis";
153
+ behavior_change: "behavior_change";
154
+ }>;
155
+ text: z.ZodString;
156
+ source_message_ids: z.ZodArray<z.ZodString>;
157
+ historical_status: z.ZodLiteral<"historical_unverified">;
158
+ epistemic_status: z.ZodEnum<{
159
+ decision: "decision";
160
+ observation: "observation";
161
+ hypothesis: "hypothesis";
162
+ reported: "reported";
163
+ unresolved: "unresolved";
164
+ }>;
165
+ supersedes: z.ZodDefault<z.ZodArray<z.ZodString>>;
166
+ resolves: z.ZodDefault<z.ZodArray<z.ZodString>>;
167
+ }, z.core.$strict>>;
168
+ }, z.core.$strict>;
169
+ protected: z.ZodArray<z.ZodObject<{
170
+ message_id: z.ZodString;
171
+ source_sha256: z.ZodString;
172
+ start: z.ZodNumber;
173
+ end: z.ZodNumber;
174
+ text: z.ZodString;
175
+ }, z.core.$strict>>;
176
+ policy_sha256: z.ZodString;
177
+ profile: z.ZodEnum<{
178
+ general: "general";
179
+ creative: "creative";
180
+ reflective: "reflective";
181
+ }>;
182
+ generation: z.ZodNumber;
183
+ provider: z.ZodString;
184
+ model: z.ZodString;
185
+ created_at: z.ZodString;
186
+ checkpoint_sha256: z.ZodString;
187
+ }, z.core.$strict>;
188
+ export type Checkpoint = z.infer<typeof CheckpointSchema>;
189
+ export declare const PrepareRequestSchema: z.ZodObject<{
190
+ schema_version: z.ZodLiteral<1>;
191
+ namespace: z.ZodString;
192
+ instructions: z.ZodString;
193
+ current: z.ZodArray<z.ZodObject<{
194
+ role: z.ZodEnum<{
195
+ system: "system";
196
+ user: "user";
197
+ assistant: "assistant";
198
+ tool: "tool";
199
+ }>;
200
+ content: z.ZodNullable<z.ZodString>;
201
+ tool_call_id: z.ZodOptional<z.ZodString>;
202
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
203
+ id: z.ZodString;
204
+ type: z.ZodLiteral<"function">;
205
+ function: z.ZodObject<{
206
+ name: z.ZodString;
207
+ arguments: z.ZodString;
208
+ }, z.core.$strict>;
209
+ }, z.core.$strict>>>;
210
+ id: z.ZodString;
211
+ }, z.core.$strict>>;
212
+ history: z.ZodArray<z.ZodObject<{
213
+ role: z.ZodEnum<{
214
+ system: "system";
215
+ user: "user";
216
+ assistant: "assistant";
217
+ tool: "tool";
218
+ }>;
219
+ content: z.ZodNullable<z.ZodString>;
220
+ tool_call_id: z.ZodOptional<z.ZodString>;
221
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
222
+ id: z.ZodString;
223
+ type: z.ZodLiteral<"function">;
224
+ function: z.ZodObject<{
225
+ name: z.ZodString;
226
+ arguments: z.ZodString;
227
+ }, z.core.$strict>;
228
+ }, z.core.$strict>>>;
229
+ id: z.ZodString;
230
+ }, z.core.$strict>>;
231
+ exchanges: z.ZodArray<z.ZodObject<{
232
+ id: z.ZodString;
233
+ message_ids: z.ZodArray<z.ZodString>;
234
+ completed: z.ZodBoolean;
235
+ }, z.core.$strict>>;
236
+ tools: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
237
+ protected: z.ZodDefault<z.ZodArray<z.ZodObject<{
238
+ message_id: z.ZodString;
239
+ source_sha256: z.ZodString;
240
+ start: z.ZodNumber;
241
+ end: z.ZodNumber;
242
+ text: z.ZodString;
243
+ }, z.core.$strict>>>;
244
+ checkpoint: z.ZodDefault<z.ZodNullable<z.ZodObject<{
245
+ schema_version: z.ZodLiteral<1>;
246
+ id: z.ZodString;
247
+ namespace: z.ZodString;
248
+ parent_id: z.ZodNullable<z.ZodString>;
249
+ source_message_ids: z.ZodArray<z.ZodString>;
250
+ source_sha256: z.ZodString;
251
+ summary: z.ZodObject<{
252
+ items: z.ZodArray<z.ZodObject<{
253
+ id: z.ZodString;
254
+ kind: z.ZodEnum<{
255
+ decision: "decision";
256
+ observation: "observation";
257
+ open_item: "open_item";
258
+ correction: "correction";
259
+ status: "status";
260
+ canon: "canon";
261
+ hypothesis: "hypothesis";
262
+ behavior_change: "behavior_change";
263
+ }>;
264
+ text: z.ZodString;
265
+ source_message_ids: z.ZodArray<z.ZodString>;
266
+ historical_status: z.ZodLiteral<"historical_unverified">;
267
+ epistemic_status: z.ZodEnum<{
268
+ decision: "decision";
269
+ observation: "observation";
270
+ hypothesis: "hypothesis";
271
+ reported: "reported";
272
+ unresolved: "unresolved";
273
+ }>;
274
+ supersedes: z.ZodDefault<z.ZodArray<z.ZodString>>;
275
+ resolves: z.ZodDefault<z.ZodArray<z.ZodString>>;
276
+ }, z.core.$strict>>;
277
+ }, z.core.$strict>;
278
+ protected: z.ZodArray<z.ZodObject<{
279
+ message_id: z.ZodString;
280
+ source_sha256: z.ZodString;
281
+ start: z.ZodNumber;
282
+ end: z.ZodNumber;
283
+ text: z.ZodString;
284
+ }, z.core.$strict>>;
285
+ policy_sha256: z.ZodString;
286
+ profile: z.ZodEnum<{
287
+ general: "general";
288
+ creative: "creative";
289
+ reflective: "reflective";
290
+ }>;
291
+ generation: z.ZodNumber;
292
+ provider: z.ZodString;
293
+ model: z.ZodString;
294
+ created_at: z.ZodString;
295
+ checkpoint_sha256: z.ZodString;
296
+ }, z.core.$strict>>>;
297
+ budget: z.ZodObject<{
298
+ context_tokens: z.ZodNumber;
299
+ output_reserve_tokens: z.ZodNumber;
300
+ safety_tokens: z.ZodDefault<z.ZodNumber>;
301
+ }, z.core.$strict>;
302
+ policy: z.ZodDefault<z.ZodObject<{
303
+ profile: z.ZodDefault<z.ZodEnum<{
304
+ general: "general";
305
+ creative: "creative";
306
+ reflective: "reflective";
307
+ }>>;
308
+ revision: z.ZodDefault<z.ZodNumber>;
309
+ recent_exchanges: z.ZodDefault<z.ZodNumber>;
310
+ trigger_ratio: z.ZodDefault<z.ZodNumber>;
311
+ summary_max_tokens: z.ZodDefault<z.ZodNumber>;
312
+ summarizer_input_tokens: z.ZodDefault<z.ZodNumber>;
313
+ summarizer_output_tokens: z.ZodDefault<z.ZodNumber>;
314
+ max_passes: z.ZodDefault<z.ZodNumber>;
315
+ require_measured_tokens: z.ZodDefault<z.ZodBoolean>;
316
+ }, z.core.$strict>>;
317
+ provider_id: z.ZodOptional<z.ZodString>;
318
+ tokenizer_id: z.ZodOptional<z.ZodString>;
319
+ force: z.ZodDefault<z.ZodBoolean>;
320
+ dry_run: z.ZodDefault<z.ZodBoolean>;
321
+ }, z.core.$strict>;
322
+ export type PrepareRequest = z.infer<typeof PrepareRequestSchema>;
323
+ export declare const TokenAccountingSchema: z.ZodObject<{
324
+ input_tokens: z.ZodNumber;
325
+ max_input_tokens: z.ZodNumber;
326
+ output_reserve_tokens: z.ZodNumber;
327
+ method: z.ZodEnum<{
328
+ provider: "provider";
329
+ estimate: "estimate";
330
+ }>;
331
+ }, z.core.$strict>;
332
+ export declare const ChangeSchema: z.ZodObject<{
333
+ action: z.ZodEnum<{
334
+ protected: "protected";
335
+ retained: "retained";
336
+ summarized: "summarized";
337
+ omitted: "omitted";
338
+ truncated: "truncated";
339
+ }>;
340
+ message_ids: z.ZodArray<z.ZodString>;
341
+ source_sha256: z.ZodOptional<z.ZodString>;
342
+ }, z.core.$strict>;
343
+ export declare const PrepareResultSchema: z.ZodObject<{
344
+ schema_version: z.ZodLiteral<1>;
345
+ messages: z.ZodArray<z.ZodObject<{
346
+ role: z.ZodEnum<{
347
+ system: "system";
348
+ user: "user";
349
+ assistant: "assistant";
350
+ tool: "tool";
351
+ }>;
352
+ content: z.ZodNullable<z.ZodString>;
353
+ tool_call_id: z.ZodOptional<z.ZodString>;
354
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
355
+ id: z.ZodString;
356
+ type: z.ZodLiteral<"function">;
357
+ function: z.ZodObject<{
358
+ name: z.ZodString;
359
+ arguments: z.ZodString;
360
+ }, z.core.$strict>;
361
+ }, z.core.$strict>>>;
362
+ }, z.core.$strict>>;
363
+ candidate_checkpoint: z.ZodNullable<z.ZodObject<{
364
+ schema_version: z.ZodLiteral<1>;
365
+ id: z.ZodString;
366
+ namespace: z.ZodString;
367
+ parent_id: z.ZodNullable<z.ZodString>;
368
+ source_message_ids: z.ZodArray<z.ZodString>;
369
+ source_sha256: z.ZodString;
370
+ summary: z.ZodObject<{
371
+ items: z.ZodArray<z.ZodObject<{
372
+ id: z.ZodString;
373
+ kind: z.ZodEnum<{
374
+ decision: "decision";
375
+ observation: "observation";
376
+ open_item: "open_item";
377
+ correction: "correction";
378
+ status: "status";
379
+ canon: "canon";
380
+ hypothesis: "hypothesis";
381
+ behavior_change: "behavior_change";
382
+ }>;
383
+ text: z.ZodString;
384
+ source_message_ids: z.ZodArray<z.ZodString>;
385
+ historical_status: z.ZodLiteral<"historical_unverified">;
386
+ epistemic_status: z.ZodEnum<{
387
+ decision: "decision";
388
+ observation: "observation";
389
+ hypothesis: "hypothesis";
390
+ reported: "reported";
391
+ unresolved: "unresolved";
392
+ }>;
393
+ supersedes: z.ZodDefault<z.ZodArray<z.ZodString>>;
394
+ resolves: z.ZodDefault<z.ZodArray<z.ZodString>>;
395
+ }, z.core.$strict>>;
396
+ }, z.core.$strict>;
397
+ protected: z.ZodArray<z.ZodObject<{
398
+ message_id: z.ZodString;
399
+ source_sha256: z.ZodString;
400
+ start: z.ZodNumber;
401
+ end: z.ZodNumber;
402
+ text: z.ZodString;
403
+ }, z.core.$strict>>;
404
+ policy_sha256: z.ZodString;
405
+ profile: z.ZodEnum<{
406
+ general: "general";
407
+ creative: "creative";
408
+ reflective: "reflective";
409
+ }>;
410
+ generation: z.ZodNumber;
411
+ provider: z.ZodString;
412
+ model: z.ZodString;
413
+ created_at: z.ZodString;
414
+ checkpoint_sha256: z.ZodString;
415
+ }, z.core.$strict>>;
416
+ tokens: z.ZodObject<{
417
+ input_tokens: z.ZodNumber;
418
+ max_input_tokens: z.ZodNumber;
419
+ output_reserve_tokens: z.ZodNumber;
420
+ method: z.ZodEnum<{
421
+ provider: "provider";
422
+ estimate: "estimate";
423
+ }>;
424
+ }, z.core.$strict>;
425
+ changes: z.ZodArray<z.ZodObject<{
426
+ action: z.ZodEnum<{
427
+ protected: "protected";
428
+ retained: "retained";
429
+ summarized: "summarized";
430
+ omitted: "omitted";
431
+ truncated: "truncated";
432
+ }>;
433
+ message_ids: z.ZodArray<z.ZodString>;
434
+ source_sha256: z.ZodOptional<z.ZodString>;
435
+ }, z.core.$strict>>;
436
+ protected_spans_verified: z.ZodNumber;
437
+ compacted: z.ZodBoolean;
438
+ fits: z.ZodBoolean;
439
+ limitations: z.ZodArray<z.ZodString>;
440
+ }, z.core.$strict>;
441
+ export type PrepareResult = z.infer<typeof PrepareResultSchema>;
442
+ export declare const ValidationRequestSchema: z.ZodObject<{
443
+ checkpoint: z.ZodObject<{
444
+ schema_version: z.ZodLiteral<1>;
445
+ id: z.ZodString;
446
+ namespace: z.ZodString;
447
+ parent_id: z.ZodNullable<z.ZodString>;
448
+ source_message_ids: z.ZodArray<z.ZodString>;
449
+ source_sha256: z.ZodString;
450
+ summary: z.ZodObject<{
451
+ items: z.ZodArray<z.ZodObject<{
452
+ id: z.ZodString;
453
+ kind: z.ZodEnum<{
454
+ decision: "decision";
455
+ observation: "observation";
456
+ open_item: "open_item";
457
+ correction: "correction";
458
+ status: "status";
459
+ canon: "canon";
460
+ hypothesis: "hypothesis";
461
+ behavior_change: "behavior_change";
462
+ }>;
463
+ text: z.ZodString;
464
+ source_message_ids: z.ZodArray<z.ZodString>;
465
+ historical_status: z.ZodLiteral<"historical_unverified">;
466
+ epistemic_status: z.ZodEnum<{
467
+ decision: "decision";
468
+ observation: "observation";
469
+ hypothesis: "hypothesis";
470
+ reported: "reported";
471
+ unresolved: "unresolved";
472
+ }>;
473
+ supersedes: z.ZodDefault<z.ZodArray<z.ZodString>>;
474
+ resolves: z.ZodDefault<z.ZodArray<z.ZodString>>;
475
+ }, z.core.$strict>>;
476
+ }, z.core.$strict>;
477
+ protected: z.ZodArray<z.ZodObject<{
478
+ message_id: z.ZodString;
479
+ source_sha256: z.ZodString;
480
+ start: z.ZodNumber;
481
+ end: z.ZodNumber;
482
+ text: z.ZodString;
483
+ }, z.core.$strict>>;
484
+ policy_sha256: z.ZodString;
485
+ profile: z.ZodEnum<{
486
+ general: "general";
487
+ creative: "creative";
488
+ reflective: "reflective";
489
+ }>;
490
+ generation: z.ZodNumber;
491
+ provider: z.ZodString;
492
+ model: z.ZodString;
493
+ created_at: z.ZodString;
494
+ checkpoint_sha256: z.ZodString;
495
+ }, z.core.$strict>;
496
+ history: z.ZodArray<z.ZodObject<{
497
+ role: z.ZodEnum<{
498
+ system: "system";
499
+ user: "user";
500
+ assistant: "assistant";
501
+ tool: "tool";
502
+ }>;
503
+ content: z.ZodNullable<z.ZodString>;
504
+ tool_call_id: z.ZodOptional<z.ZodString>;
505
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
506
+ id: z.ZodString;
507
+ type: z.ZodLiteral<"function">;
508
+ function: z.ZodObject<{
509
+ name: z.ZodString;
510
+ arguments: z.ZodString;
511
+ }, z.core.$strict>;
512
+ }, z.core.$strict>>>;
513
+ id: z.ZodString;
514
+ }, z.core.$strict>>;
515
+ namespace: z.ZodString;
516
+ }, z.core.$strict>;
517
+ export declare const RecallRequestSchema: z.ZodObject<{
518
+ history: z.ZodArray<z.ZodObject<{
519
+ role: z.ZodEnum<{
520
+ system: "system";
521
+ user: "user";
522
+ assistant: "assistant";
523
+ tool: "tool";
524
+ }>;
525
+ content: z.ZodNullable<z.ZodString>;
526
+ tool_call_id: z.ZodOptional<z.ZodString>;
527
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
528
+ id: z.ZodString;
529
+ type: z.ZodLiteral<"function">;
530
+ function: z.ZodObject<{
531
+ name: z.ZodString;
532
+ arguments: z.ZodString;
533
+ }, z.core.$strict>;
534
+ }, z.core.$strict>>>;
535
+ id: z.ZodString;
536
+ }, z.core.$strict>>;
537
+ message_ids: z.ZodArray<z.ZodString>;
538
+ }, z.core.$strict>;
539
+ export type TokenCounter = (messages: ChatMessage[], tools: object[], signal: AbortSignal) => Promise<number | null>;
540
+ export type SummarizationInput = {
541
+ prompt: string;
542
+ output_tokens: number;
543
+ signal: AbortSignal;
544
+ };
545
+ export type Summarizer = {
546
+ id: string;
547
+ model: string;
548
+ summarize: (input: SummarizationInput) => Promise<string>;
549
+ countTokens?: TokenCounter;
550
+ renderInput?: (prompt: string) => ChatMessage[];
551
+ };
552
+ export type Adapters = {
553
+ summarizer?: Summarizer;
554
+ countTokens?: TokenCounter;
555
+ signal?: AbortSignal;
556
+ };
@@ -0,0 +1,58 @@
1
+ import { z } from 'zod';
2
+ export const ToolCallSchema = z.object({ id: z.string().min(1), type: z.literal('function'),
3
+ function: z.object({ name: z.string().min(1), arguments: z.string() }).strict() }).strict();
4
+ export const ChatMessageSchema = z.object({ role: z.enum(['system', 'user', 'assistant', 'tool']),
5
+ content: z.string().nullable(), tool_call_id: z.string().optional(), tool_calls: z.array(ToolCallSchema).optional() }).strict();
6
+ export const MessageSchema = ChatMessageSchema.extend({ id: z.string().min(1).max(256) });
7
+ export const ExchangeSchema = z.object({ id: z.string().min(1), message_ids: z.array(z.string()).min(1),
8
+ completed: z.boolean() }).strict();
9
+ export const ProtectedSpanSchema = z.object({ message_id: z.string(), source_sha256: z.string().regex(/^[a-f0-9]{64}$/),
10
+ start: z.number().int().nonnegative(), end: z.number().int().nonnegative(), text: z.string().min(1) }).strict();
11
+ export const ProfileSchema = z.enum(['general', 'creative', 'reflective']);
12
+ export const PolicySchema = z.object({
13
+ profile: ProfileSchema.default('general'), revision: z.number().int().positive().default(1),
14
+ recent_exchanges: z.number().int().min(0).max(100).default(2),
15
+ trigger_ratio: z.number().min(0.1).max(1).default(0.7),
16
+ summary_max_tokens: z.number().int().min(128).default(4000),
17
+ summarizer_input_tokens: z.number().int().min(512).default(16000),
18
+ summarizer_output_tokens: z.number().int().min(128).default(4000),
19
+ max_passes: z.number().int().min(1).max(256).default(32),
20
+ require_measured_tokens: z.boolean().default(false)
21
+ }).strict();
22
+ export const SummaryItemSchema = z.object({
23
+ id: z.string().min(1).max(256),
24
+ kind: z.enum(['decision', 'observation', 'open_item', 'correction', 'status', 'canon', 'hypothesis', 'behavior_change']),
25
+ text: z.string().trim().min(1).max(4000), source_message_ids: z.array(z.string()).min(1).max(32),
26
+ historical_status: z.literal('historical_unverified'),
27
+ epistemic_status: z.enum(['reported', 'observation', 'hypothesis', 'decision', 'unresolved']),
28
+ supersedes: z.array(z.string()).default([]), resolves: z.array(z.string()).default([])
29
+ }).strict();
30
+ export const SummarySchema = z.object({ items: z.array(SummaryItemSchema).min(1).max(64) }).strict();
31
+ export const CheckpointSchema = z.object({
32
+ schema_version: z.literal(1), id: z.string().min(1), namespace: z.string().min(1), parent_id: z.string().nullable(),
33
+ source_message_ids: z.array(z.string()).min(1), source_sha256: z.string().regex(/^[a-f0-9]{64}$/),
34
+ summary: SummarySchema, protected: z.array(ProtectedSpanSchema), policy_sha256: z.string().regex(/^[a-f0-9]{64}$/),
35
+ profile: ProfileSchema, generation: z.number().int().positive(), provider: z.string(), model: z.string(),
36
+ created_at: z.string().datetime(), checkpoint_sha256: z.string().regex(/^[a-f0-9]{64}$/)
37
+ }).strict();
38
+ export const PrepareRequestSchema = z.object({
39
+ schema_version: z.literal(1), namespace: z.string().min(1).max(512),
40
+ instructions: z.string(), current: z.array(MessageSchema).min(1), history: z.array(MessageSchema),
41
+ exchanges: z.array(ExchangeSchema), tools: z.array(z.record(z.string(), z.unknown())).default([]),
42
+ protected: z.array(ProtectedSpanSchema).default([]), checkpoint: CheckpointSchema.nullable().default(null),
43
+ budget: z.object({ context_tokens: z.number().int().positive(), output_reserve_tokens: z.number().int().nonnegative(),
44
+ safety_tokens: z.number().int().nonnegative().default(0) }).strict(),
45
+ policy: PolicySchema.default(() => PolicySchema.parse({})),
46
+ provider_id: z.string().min(1).optional(), tokenizer_id: z.string().min(1).optional(),
47
+ force: z.boolean().default(false), dry_run: z.boolean().default(false)
48
+ }).strict();
49
+ export const TokenAccountingSchema = z.object({ input_tokens: z.number().int().nonnegative(), max_input_tokens: z.number().int(),
50
+ output_reserve_tokens: z.number().int().nonnegative(), method: z.enum(['provider', 'estimate']) }).strict();
51
+ export const ChangeSchema = z.object({ action: z.enum(['retained', 'summarized', 'omitted', 'truncated', 'protected']),
52
+ message_ids: z.array(z.string()), source_sha256: z.string().optional() }).strict();
53
+ export const PrepareResultSchema = z.object({ schema_version: z.literal(1), messages: z.array(ChatMessageSchema),
54
+ candidate_checkpoint: CheckpointSchema.nullable(), tokens: TokenAccountingSchema,
55
+ changes: z.array(ChangeSchema), protected_spans_verified: z.number().int().nonnegative(),
56
+ compacted: z.boolean(), fits: z.boolean(), limitations: z.array(z.string()) }).strict();
57
+ export const ValidationRequestSchema = z.object({ checkpoint: CheckpointSchema, history: z.array(MessageSchema), namespace: z.string() }).strict();
58
+ export const RecallRequestSchema = z.object({ history: z.array(MessageSchema), message_ids: z.array(z.string()) }).strict();
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ import { type PrepareResult, type Adapters, type ChatMessage, type Policy } from './contracts.js';
3
+ export declare const tokenEstimate: (value: unknown) => number;
4
+ export declare const profiles: Readonly<Record<Policy['profile'], string>>;
5
+ export declare function prepareContext(value: unknown, adapters?: Adapters): Promise<PrepareResult>;
6
+ export declare function rebuildCheckpoint(value: unknown, adapters?: Adapters): Promise<PrepareResult>;
7
+ export declare const FitRequestSchema: z.ZodObject<{
8
+ messages: z.ZodArray<z.ZodObject<{
9
+ role: z.ZodEnum<{
10
+ system: "system";
11
+ user: "user";
12
+ assistant: "assistant";
13
+ tool: "tool";
14
+ }>;
15
+ content: z.ZodNullable<z.ZodString>;
16
+ tool_call_id: z.ZodOptional<z.ZodString>;
17
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
18
+ id: z.ZodString;
19
+ type: z.ZodLiteral<"function">;
20
+ function: z.ZodObject<{
21
+ name: z.ZodString;
22
+ arguments: z.ZodString;
23
+ }, z.core.$strict>;
24
+ }, z.core.$strict>>>;
25
+ }, z.core.$strict>>;
26
+ tools: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
27
+ max_input_tokens: z.ZodNumber;
28
+ protected_indices: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
29
+ require_measured_tokens: z.ZodDefault<z.ZodBoolean>;
30
+ }, z.core.$strict>;
31
+ export declare function fitContext(value: unknown, adapters?: Adapters): Promise<{
32
+ messages: ChatMessage[];
33
+ tokens: {
34
+ input_tokens: number;
35
+ max_input_tokens: number;
36
+ method: 'provider' | 'estimate';
37
+ };
38
+ changes: PrepareResult['changes'];
39
+ }>;