@aria-cli/types 1.0.19 → 1.0.31

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.
Files changed (46) hide show
  1. package/{dist-cjs/errors.d.ts → dist/errors.js} +20 -5
  2. package/dist/index.js +11 -1
  3. package/dist/logger.js +163 -0
  4. package/dist/memoria.js +10 -0
  5. package/dist/models.js +17 -0
  6. package/dist/native-tools.js +29 -0
  7. package/dist/relaunch.js +59 -0
  8. package/dist/stall-phase.js +14 -0
  9. package/dist/tool-outputs.js +4 -0
  10. package/dist-cjs/errors.js +49 -0
  11. package/dist-cjs/index.js +29 -1
  12. package/dist-cjs/logger.js +166 -0
  13. package/dist-cjs/memoria.js +11 -0
  14. package/dist-cjs/models.js +21 -0
  15. package/dist-cjs/native-tools.js +33 -0
  16. package/dist-cjs/relaunch.js +67 -0
  17. package/dist-cjs/stall-phase.js +18 -0
  18. package/dist-cjs/tool-outputs.js +5 -0
  19. package/package.json +4 -2
  20. package/dist/errors.d.ts +0 -29
  21. package/dist/index.d.ts +0 -11
  22. package/dist/logger.d.ts +0 -54
  23. package/dist/memoria.d.ts +0 -428
  24. package/dist/models.d.ts +0 -322
  25. package/dist/native-tools.d.ts +0 -57
  26. package/dist/relaunch.d.ts +0 -22
  27. package/dist/stall-phase.d.ts +0 -2
  28. package/dist/tool-outputs.d.ts +0 -37
  29. package/dist-cjs/index.d.ts +0 -11
  30. package/dist-cjs/logger.d.ts +0 -54
  31. package/dist-cjs/memoria.d.ts +0 -428
  32. package/dist-cjs/models.d.ts +0 -322
  33. package/dist-cjs/native-tools.d.ts +0 -57
  34. package/dist-cjs/relaunch.d.ts +0 -22
  35. package/dist-cjs/src/errors.d.ts +0 -29
  36. package/dist-cjs/src/index.d.ts +0 -10
  37. package/dist-cjs/src/logger.d.ts +0 -22
  38. package/dist-cjs/src/memoria.d.ts +0 -418
  39. package/dist-cjs/src/models.d.ts +0 -322
  40. package/dist-cjs/src/native-tools.d.ts +0 -57
  41. package/dist-cjs/src/relaunch.d.ts +0 -22
  42. package/dist-cjs/src/tool-outputs.d.ts +0 -37
  43. package/dist-cjs/stall-phase.d.ts +0 -2
  44. package/dist-cjs/tests/logger.test.d.ts +0 -1
  45. package/dist-cjs/tool-outputs.d.ts +0 -37
  46. package/dist-cjs/vitest.config.d.ts +0 -2
@@ -1,428 +0,0 @@
1
- /**
2
- * Minimal IMemoria interface for consumers that need memory capabilities
3
- * without depending on the concrete @aria/memoria package.
4
- *
5
- * Structural types (MemoryItem, ToolItem, RecallResult) replace bare
6
- * `unknown` returns so consumers get usable shapes without coupling to
7
- * the full Memoria domain model.
8
- */
9
- /** A single stored memory. */
10
- export interface MemoryItem {
11
- id: string;
12
- content: string;
13
- summary?: string;
14
- network?: string;
15
- importance?: number;
16
- confidence?: number;
17
- createdAt?: Date;
18
- metadata?: Record<string, unknown>;
19
- }
20
- /** A single tool-store entry. */
21
- export interface ToolItem {
22
- id: string;
23
- name: string;
24
- description: string;
25
- source?: ToolSourceItem;
26
- importance?: number;
27
- confidence?: number;
28
- tags?: string[];
29
- createdAt?: Date;
30
- updatedAt?: Date;
31
- accessedAt?: Date;
32
- accessCount?: number;
33
- evidenceIds?: string[];
34
- category?: "filesystem" | "code" | "shell" | "web" | "data" | "memory" | "meta" | "arion";
35
- parameters?: Record<string, unknown>;
36
- riskLevel?: "safe" | "moderate" | "dangerous";
37
- responseTemplate?: string;
38
- knowledge?: string;
39
- usageHint?: string;
40
- adoptedAt?: number;
41
- lastUsedAt?: number;
42
- usageCount?: number;
43
- schema?: Record<string, unknown>;
44
- capabilities?: string[];
45
- metrics?: Record<string, unknown>;
46
- }
47
- export type ToolSourceItem = {
48
- type: "built-in";
49
- } | {
50
- type: "external";
51
- ref: string;
52
- format: "skill-file" | "markdown" | "json" | "web-search";
53
- } | {
54
- type: "organic";
55
- method: "execution" | "observation" | "feedback";
56
- episodeId?: string;
57
- };
58
- /** Result shape returned by observation query primitives. */
59
- export interface ObservationQueryResult {
60
- observations: string;
61
- currentTask: string | null;
62
- suggestedResponse: string | null;
63
- sessionId: string;
64
- updatedAt: number;
65
- }
66
- /** Result envelope returned by the APR pipeline. */
67
- export interface RecallResult {
68
- memories: MemoryItem[];
69
- /** @deprecated Legacy alias retained for compatibility with older callers. */
70
- data?: MemoryItem[];
71
- query?: string;
72
- totalCount?: number;
73
- degradationLevel?: "full" | "reduced" | "minimal";
74
- skippedStages?: string[];
75
- warnings?: string[];
76
- }
77
- /** Result from lightweight FTS5-only recall. */
78
- export interface LightweightRecallResult {
79
- memories: MemoryItem[];
80
- formattedContext: {
81
- context: string;
82
- };
83
- query: string;
84
- }
85
- export interface ExtractedConversationMemoryItem {
86
- content: string;
87
- network: "world" | "episodes" | "beliefs" | "entities" | "procedures" | "strategies";
88
- /** Optional durability marker describing how the memory was routed */
89
- durability?: "permanent" | "session";
90
- }
91
- export interface ConversationExtractionResult {
92
- learned: ExtractedConversationMemoryItem[];
93
- error?: string;
94
- }
95
- export interface SkillTriggerItem {
96
- type: "keyword" | "intent" | "context" | "entity";
97
- pattern: string;
98
- confidence: number;
99
- }
100
- export interface SkillRequirementsItem {
101
- bins?: string[];
102
- env?: string[];
103
- os?: ("darwin" | "linux" | "win32")[];
104
- }
105
- export type SkillSourceItem = {
106
- type: "auto-learned";
107
- sequenceId: string;
108
- } | {
109
- type: "file";
110
- path: string;
111
- format: "skill-file";
112
- } | {
113
- type: "cli";
114
- command: string;
115
- } | {
116
- type: "web";
117
- url: string;
118
- } | {
119
- type: "user";
120
- ref?: string;
121
- };
122
- export interface SkillItem {
123
- id: string;
124
- name: string;
125
- description: string;
126
- content: string;
127
- toolIds: string[];
128
- triggers: SkillTriggerItem[];
129
- requires?: SkillRequirementsItem;
130
- tags: string[];
131
- source: SkillSourceItem;
132
- executionCount: number;
133
- successCount: number;
134
- lastExecuted: Date | null;
135
- averageDurationMs: number | null;
136
- confidence: number;
137
- importance: number;
138
- createdAt: Date;
139
- updatedAt: Date;
140
- accessedAt: Date;
141
- accessCount: number;
142
- archivedAt?: Date;
143
- }
144
- export interface SkillExecutionRecord {
145
- id: string;
146
- skillId: string;
147
- success: boolean;
148
- durationMs?: number;
149
- notes?: string;
150
- episodeId?: string;
151
- timestamp: Date;
152
- }
153
- export interface ToolUseSequenceRecord {
154
- tool: string;
155
- input?: Record<string, unknown>;
156
- output?: string;
157
- success: boolean;
158
- timestamp: Date;
159
- }
160
- /**
161
- * Minimal observation engine interface for consumers that need observation
162
- * capabilities without depending on the concrete @aria/memoria package.
163
- *
164
- * Matches the public surface of ObservationEngine from @aria/memoria.
165
- */
166
- export interface IObservationEngine {
167
- /** Prepare context before model call — may trigger observation and filter messages. */
168
- prepareContext(opts: {
169
- sessionId: string;
170
- messages: unknown[];
171
- originalSystemPrompt: string;
172
- readOnly?: boolean;
173
- signal?: AbortSignal;
174
- }): Promise<{
175
- messagesToSend: unknown[];
176
- filteredMessageIds: Set<string>;
177
- observationTriggered: boolean;
178
- }>;
179
- /** Track new message IDs added to the conversation since last observation. */
180
- trackNewMessages(messageIds: string[]): void;
181
- /** Force observation of remaining unobserved messages at session end. */
182
- finalObservation(sessionId: string, messages?: unknown[], signal?: AbortSignal): Promise<void>;
183
- /** Observe messages — used for explicit observation triggers. */
184
- observe(sessionId: string, messages: unknown[], signal?: AbortSignal, opts?: {
185
- force?: boolean;
186
- }): Promise<void>;
187
- /** Get the observation record for a session, or null. */
188
- getRecord(sessionId: string): unknown;
189
- /** Get the active observation text for a session. */
190
- getActiveObservations(sessionId: string): string;
191
- /** Drain pending observation work (wait for in-flight observations to complete). */
192
- drain(): Promise<void>;
193
- }
194
- export interface IMemoria {
195
- /** Store a memory. Returns an object with `id` on success, or null. */
196
- remember(content: string, options?: Record<string, unknown>): Promise<{
197
- id: string;
198
- } | null>;
199
- /**
200
- * Internal fast-path for storing execution-trace episodes without the full
201
- * entity extraction pipeline. Optional for backward compatibility.
202
- */
203
- storeEpisode?(content: string): Promise<{
204
- id: string;
205
- } | null>;
206
- /** Retrieve memories matching a query. Includes degradation metadata when available. */
207
- recall(query: string, options?: Record<string, unknown>): Promise<RecallResult>;
208
- /** Lightweight FTS5-only recall for session seeding. No LLM calls. */
209
- recallLightweight(query: string, options?: {
210
- limit?: number;
211
- networks?: string[];
212
- }): Promise<LightweightRecallResult>;
213
- /**
214
- * Planner-first unified recall: 1 LLM call for classification + plan + expansion.
215
- * Routes to direct lookup (skipping APR) or mixed APR + primitive execution.
216
- * This is the preferred recall path — recallWithAPR delegates to this.
217
- */
218
- recallUnified?(query: string, options?: {
219
- limit?: number;
220
- networks?: string[];
221
- }): Promise<{
222
- memories: MemoryItem[];
223
- formattedContext?: {
224
- context?: string;
225
- text?: string;
226
- tokenCount?: number;
227
- } | null;
228
- intent?: {
229
- type?: string;
230
- confidence?: number;
231
- entities?: string[];
232
- temporalFocus?: string | null;
233
- extractedEntities?: string[];
234
- extractedTimeframe?: Record<string, unknown>;
235
- };
236
- sourceStats?: unknown;
237
- plan?: Array<{
238
- primitive: string;
239
- args: Record<string, unknown>;
240
- }>;
241
- planReasoning?: string;
242
- primitiveResults?: Array<{
243
- source: string;
244
- data: unknown;
245
- }>;
246
- }>;
247
- /** Retrieve memories via the Adaptive Parallel Retrieval pipeline. */
248
- recallWithAPR(query: string, options?: {
249
- limit?: number;
250
- networks?: string[];
251
- }): Promise<{
252
- memories: MemoryItem[];
253
- formattedContext?: {
254
- context?: string;
255
- text?: string;
256
- tokenCount?: number;
257
- };
258
- intent?: {
259
- type?: string;
260
- confidence?: number;
261
- entities?: string[];
262
- temporalFocus?: string | null;
263
- extractedEntities?: string[];
264
- extractedTimeframe?: Record<string, unknown>;
265
- };
266
- sourceStats?: unknown;
267
- query?: string;
268
- totalCount?: number;
269
- degradationLevel?: "full" | "reduced" | "minimal";
270
- skippedStages?: string[];
271
- warnings?: string[];
272
- }>;
273
- /**
274
- * Lightweight vector-only recall with network filtering. Bypasses the full APR
275
- * pipeline (no classification, no multi-index fusion, no diversity). Designed
276
- * for time-critical paths like session bootstrap.
277
- */
278
- recallDirect(query: string, options: {
279
- networks: string[];
280
- limit: number;
281
- threshold?: number;
282
- }): Promise<MemoryItem[]>;
283
- /** Recall memories by network type. Direct SQL query, no LLM classification. */
284
- recallByNetwork(network: string, options?: {
285
- limit?: number;
286
- }): Promise<MemoryItem[]>;
287
- /** Recall recent memories, optionally filtered by network. Direct SQL query sorted by created_at DESC. */
288
- recallRecent(options?: {
289
- limit?: number;
290
- network?: string;
291
- }): Promise<MemoryItem[]>;
292
- /** Recall memories by vector similarity. Uses embedding model only (0 LLM calls). */
293
- recallSimilar(query: string, options?: {
294
- k?: number;
295
- threshold?: number;
296
- }): Promise<MemoryItem[]>;
297
- /** Store a tool with semantic indexing. Returns the generated id. */
298
- rememberTool(tool: {
299
- name: string;
300
- description: string;
301
- } & Record<string, unknown>): Promise<string>;
302
- /** Query the tool store. */
303
- recallTools(options: {
304
- query: string;
305
- limit?: number;
306
- /** Optional offset used for paged list retrieval (matchAll mode). */
307
- offset?: number;
308
- minConfidence?: number;
309
- /** When true, bypasses semantic/keyword matching and lists stored tools. */
310
- matchAll?: boolean;
311
- /** When false, recall becomes read-only and does not mutate access stats. */
312
- updateAccessStats?: boolean;
313
- }): Promise<ToolItem[]>;
314
- /** Retrieve a single tool entry by ID. */
315
- getToolById(id: string): Promise<ToolItem | null>;
316
- /** Delete a tool entry by ID. Returns true if deleted, false if not found. */
317
- forgetTool(id: string): Promise<boolean>;
318
- /** Store a skill directly. Returns the generated skill ID. */
319
- rememberSkill(skill: {
320
- name: string;
321
- description: string;
322
- content: string;
323
- toolIds?: string[];
324
- triggers?: SkillTriggerItem[];
325
- requires?: SkillRequirementsItem;
326
- tags?: string[];
327
- source: SkillSourceItem;
328
- importance?: number;
329
- confidence?: number;
330
- }): Promise<string>;
331
- /** Skill retrieval API. */
332
- recallSkills(options?: {
333
- query?: string;
334
- triggerType?: SkillTriggerItem["type"];
335
- limit?: number;
336
- }): Promise<SkillItem[]>;
337
- /** Skill lookup API. */
338
- getSkill(idOrName: string): Promise<SkillItem | null>;
339
- /** Record skill execution metrics. */
340
- recordSkillExecution(options: {
341
- skillId: string;
342
- success: boolean;
343
- durationMs?: number;
344
- notes?: string;
345
- episodeId?: string;
346
- }): Promise<SkillExecutionRecord>;
347
- /** Start recording a tool-use sequence for procedural learning. */
348
- startToolSequence?(task: string, options?: {
349
- sessionId?: string;
350
- }): void;
351
- /** Record a single tool execution within the active sequence. */
352
- recordToolUse?(record: ToolUseSequenceRecord, options?: {
353
- sessionId?: string;
354
- }): void;
355
- /** Finalize the active tool-use sequence and trigger learning. */
356
- endToolSequence?(success: boolean, options?: {
357
- sessionId?: string;
358
- }): Promise<void>;
359
- /** Delete a single memory by ID. */
360
- deleteMemory(id: string): Promise<boolean>;
361
- /** Merge a JSON patch into a memory's metadata. */
362
- updateMemoryMetadata(id: string, patch: Record<string, unknown>): void;
363
- /** Soft-invalidate a memory in place (sets confidence to 0, marks reason). Allows recovery. */
364
- invalidateMemoryInPlace(memoryId: string, reason?: string): Promise<void>;
365
- /** Requeue failed embedding jobs and return how many were scheduled. */
366
- retryFailedEmbeddings?(): Promise<number>;
367
- /** Extract memories from a user/assistant conversation turn. */
368
- extractFromConversation(userMessage: string, assistantResponse: string, options?: {
369
- signal?: AbortSignal;
370
- }): Promise<ConversationExtractionResult>;
371
- /** Observation engine for Mastra-style observation/reflection memory layer. */
372
- readonly observationEngine?: IObservationEngine;
373
- /**
374
- * Extract durable knowledge from observation text into the knowledge graph.
375
- * Optional for backward compatibility — always present on concrete Memoria instances.
376
- */
377
- extractFromObservations?(observations: string, options?: {
378
- sessionId?: string;
379
- signal?: AbortSignal;
380
- }): Promise<ConversationExtractionResult>;
381
- /**
382
- * Return the most recently updated observation session ID.
383
- * When `arionId` is provided, scope to that arion's observation records.
384
- */
385
- getMostRecentSessionId?(options?: {
386
- arionId?: string;
387
- }): Promise<string | null>;
388
- /**
389
- * Fetch persisted active observations for a session.
390
- * Returns null when no observation record exists for the session.
391
- */
392
- getSessionObservations?(sessionId: string): Promise<string | null>;
393
- /**
394
- * Full-text search across observation records (LIKE on observations, current_task, suggested_response).
395
- * Returns matching records ordered by recency.
396
- */
397
- searchObservations?(query: string, limit?: number): Promise<ObservationQueryResult[]>;
398
- /**
399
- * Retrieve a specific field from the most recent observation record.
400
- * Valid fields: "suggested_response", "current_task", "active_observations".
401
- */
402
- getObservationField?(field: "suggested_response" | "current_task" | "active_observations"): Promise<string | null>;
403
- /**
404
- * Retrieve the N most recent observation records, ordered by updated_at DESC.
405
- */
406
- getRecentObservations?(limit?: number): Promise<ObservationQueryResult[]>;
407
- /** Shut down the memory system and release resources. */
408
- close(): Promise<void>;
409
- /**
410
- * Entity-first recall — fast-path for entity/self queries.
411
- * Returns a formatted string when the query matches a known entity or
412
- * self-query pattern. Returns null to signal fallback to APR.
413
- */
414
- entityRecall(query: string): Promise<string | null>;
415
- /** Whether this instance has been closed. */
416
- readonly isClosed: boolean;
417
- /** Return the total number of stored memories. */
418
- count(): Promise<number>;
419
- /** List stored memories. */
420
- list(options?: {
421
- limit?: number;
422
- network?: string;
423
- }): Promise<MemoryItem[]>;
424
- /** Get a config value by key. Returns null if not found. */
425
- getConfig(key: string): Promise<string | null>;
426
- /** Set a config value by key. Creates or overwrites. */
427
- setConfig(key: string, value: string): Promise<void>;
428
- }