@framers/agentos 0.1.181 → 0.1.183

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 (60) hide show
  1. package/README.md +101 -0
  2. package/dist/api/agent.d.ts +24 -0
  3. package/dist/api/agent.d.ts.map +1 -1
  4. package/dist/api/agent.js.map +1 -1
  5. package/dist/core/validation/ValidatedLlmInvoker.d.ts +80 -0
  6. package/dist/core/validation/ValidatedLlmInvoker.d.ts.map +1 -0
  7. package/dist/core/validation/ValidatedLlmInvoker.js +176 -0
  8. package/dist/core/validation/ValidatedLlmInvoker.js.map +1 -0
  9. package/dist/core/validation/errors.d.ts +53 -0
  10. package/dist/core/validation/errors.d.ts.map +1 -0
  11. package/dist/core/validation/errors.js +42 -0
  12. package/dist/core/validation/errors.js.map +1 -0
  13. package/dist/core/validation/extractJson.d.ts +35 -0
  14. package/dist/core/validation/extractJson.d.ts.map +1 -0
  15. package/dist/core/validation/extractJson.js +179 -0
  16. package/dist/core/validation/extractJson.js.map +1 -0
  17. package/dist/core/validation/index.d.ts +14 -0
  18. package/dist/core/validation/index.d.ts.map +1 -0
  19. package/dist/core/validation/index.js +14 -0
  20. package/dist/core/validation/index.js.map +1 -0
  21. package/dist/core/validation/schema-primitives.d.ts +132 -0
  22. package/dist/core/validation/schema-primitives.d.ts.map +1 -0
  23. package/dist/core/validation/schema-primitives.js +141 -0
  24. package/dist/core/validation/schema-primitives.js.map +1 -0
  25. package/dist/memory/AgentMemory.d.ts +118 -1
  26. package/dist/memory/AgentMemory.d.ts.map +1 -1
  27. package/dist/memory/AgentMemory.js +388 -0
  28. package/dist/memory/AgentMemory.js.map +1 -1
  29. package/dist/memory/CognitiveMemoryManager.d.ts +44 -0
  30. package/dist/memory/CognitiveMemoryManager.d.ts.map +1 -1
  31. package/dist/memory/CognitiveMemoryManager.js +131 -5
  32. package/dist/memory/CognitiveMemoryManager.js.map +1 -1
  33. package/dist/memory/core/config.d.ts +49 -9
  34. package/dist/memory/core/config.d.ts.map +1 -1
  35. package/dist/memory/core/config.js +13 -0
  36. package/dist/memory/core/config.js.map +1 -1
  37. package/dist/memory/core/prompt/MemoryPromptAssembler.d.ts.map +1 -1
  38. package/dist/memory/core/prompt/MemoryPromptAssembler.js +59 -5
  39. package/dist/memory/core/prompt/MemoryPromptAssembler.js.map +1 -1
  40. package/dist/memory/core/types.d.ts +97 -0
  41. package/dist/memory/core/types.d.ts.map +1 -1
  42. package/dist/memory/pipeline/observation/MemoryReflector.d.ts +28 -1
  43. package/dist/memory/pipeline/observation/MemoryReflector.d.ts.map +1 -1
  44. package/dist/memory/pipeline/observation/MemoryReflector.js +80 -8
  45. package/dist/memory/pipeline/observation/MemoryReflector.js.map +1 -1
  46. package/dist/memory/retrieval/hyde/MemoryHydeRetriever.d.ts +69 -0
  47. package/dist/memory/retrieval/hyde/MemoryHydeRetriever.d.ts.map +1 -0
  48. package/dist/memory/retrieval/hyde/MemoryHydeRetriever.js +97 -0
  49. package/dist/memory/retrieval/hyde/MemoryHydeRetriever.js.map +1 -0
  50. package/dist/memory/retrieval/store/MemoryStore.d.ts +15 -0
  51. package/dist/memory/retrieval/store/MemoryStore.d.ts.map +1 -1
  52. package/dist/memory/retrieval/store/MemoryStore.js +67 -0
  53. package/dist/memory/retrieval/store/MemoryStore.js.map +1 -1
  54. package/dist/memory/retrieval/store/SqliteBrain.d.ts +7 -0
  55. package/dist/memory/retrieval/store/SqliteBrain.d.ts.map +1 -1
  56. package/dist/memory/retrieval/store/SqliteBrain.js +39 -0
  57. package/dist/memory/retrieval/store/SqliteBrain.js.map +1 -1
  58. package/dist/voice-pipeline/types.d.ts +44 -0
  59. package/dist/voice-pipeline/types.d.ts.map +1 -1
  60. package/package.json +1 -1
@@ -0,0 +1,179 @@
1
+ /**
2
+ * @fileoverview Centralized JSON extraction from messy LLM output.
3
+ *
4
+ * LLMs return structured data in many formats: raw JSON, markdown-fenced
5
+ * blocks, JSON wrapped in prose, JSONL, or JSON preceded by chain-of-thought
6
+ * `<thinking>` blocks. This module handles all of them with a priority-ordered
7
+ * extraction pipeline.
8
+ *
9
+ * Replaces the ad-hoc `JSON.parse` + `match()` + `split('\n')` patterns
10
+ * duplicated across 30+ files in AgentOS and wilds-ai.
11
+ *
12
+ * @module agentos/core/validation/extractJson
13
+ */
14
+ /**
15
+ * Extract JSON from raw LLM output text.
16
+ *
17
+ * Tries multiple extraction strategies in priority order:
18
+ * 1. Raw JSON (entire string is valid JSON)
19
+ * 2. Markdown fenced blocks (```json ... ``` or ``` ... ```)
20
+ * 3. Strip `<thinking>` blocks, then retry
21
+ * 4. First `{...}` or `[...]` via greedy brace/bracket matching
22
+ * 5. JSONL (multiple JSON objects on separate lines → array)
23
+ *
24
+ * @param rawText - Raw LLM output that may contain JSON
25
+ * @returns Extracted JSON string, or null if no valid JSON found
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * extractJson('```json\n{"key": "value"}\n```') // '{"key": "value"}'
30
+ * extractJson('<thinking>hmm</thinking>\n{"a":1}') // '{"a":1}'
31
+ * extractJson('no json here') // null
32
+ * ```
33
+ */
34
+ export function extractJson(rawText) {
35
+ if (!rawText || rawText.trim().length === 0)
36
+ return null;
37
+ const trimmed = rawText.trim();
38
+ // Strategy 1: Raw JSON — entire string is valid JSON
39
+ if ((trimmed.startsWith('{') && trimmed.endsWith('}')) ||
40
+ (trimmed.startsWith('[') && trimmed.endsWith(']'))) {
41
+ try {
42
+ JSON.parse(trimmed);
43
+ return trimmed;
44
+ }
45
+ catch {
46
+ // Not valid raw JSON — fall through to other strategies
47
+ }
48
+ }
49
+ // Strategy 2: Markdown fenced blocks — ```json ... ``` or ``` ... ```
50
+ const fencedMatch = trimmed.match(/```(?:json)?\s*\n([\s\S]*?)\n\s*```/);
51
+ if (fencedMatch) {
52
+ const content = fencedMatch[1].trim();
53
+ try {
54
+ JSON.parse(content);
55
+ return content;
56
+ }
57
+ catch {
58
+ // Fenced block wasn't valid JSON — fall through
59
+ }
60
+ }
61
+ // Strategy 3: Strip <thinking>...</thinking> blocks, then retry.
62
+ // Chain-of-thought reasoning often precedes the actual JSON output.
63
+ if (trimmed.includes('<thinking>')) {
64
+ const stripped = trimmed.replace(/<thinking>[\s\S]*?<\/thinking>/gi, '').trim();
65
+ if (stripped.length > 0 && stripped !== trimmed) {
66
+ const result = extractJson(stripped);
67
+ if (result)
68
+ return result;
69
+ }
70
+ }
71
+ // Strategy 4: JSONL — multiple JSON objects on separate lines.
72
+ // Common in MemoryObserver and MemoryReflector output where the LLM
73
+ // outputs one JSON object per observation/trace on its own line.
74
+ // Checked BEFORE brace matching so multi-line output isn't truncated
75
+ // to just the first object.
76
+ const lines = trimmed.split('\n').filter((l) => l.trim());
77
+ if (lines.length >= 2) {
78
+ const jsonObjects = [];
79
+ for (const line of lines) {
80
+ const clean = line.trim();
81
+ try {
82
+ const parsed = JSON.parse(clean);
83
+ if (typeof parsed === 'object' && parsed !== null) {
84
+ jsonObjects.push(parsed);
85
+ }
86
+ }
87
+ catch {
88
+ // Skip non-JSON lines (common in LLM output with commentary)
89
+ }
90
+ }
91
+ if (jsonObjects.length >= 2) {
92
+ return JSON.stringify(jsonObjects);
93
+ }
94
+ }
95
+ // Strategy 5: First {...} or [...] via greedy brace/bracket matching.
96
+ // Handles JSON embedded in prose like "Here is the result: {...} done."
97
+ const braceResult = extractByBraceMatching(trimmed);
98
+ if (braceResult)
99
+ return braceResult;
100
+ return null;
101
+ }
102
+ /**
103
+ * Extract the first balanced JSON object or array from text using
104
+ * brace/bracket depth counting. Handles nested structures and
105
+ * string escaping correctly.
106
+ *
107
+ * @param text - Text that may contain embedded JSON
108
+ * @returns Extracted JSON string, or null if no balanced structure found
109
+ */
110
+ function extractByBraceMatching(text) {
111
+ // Find the first { or [
112
+ const objectStart = text.indexOf('{');
113
+ const arrayStart = text.indexOf('[');
114
+ // Pick whichever comes first
115
+ let start;
116
+ let openChar;
117
+ let closeChar;
118
+ if (objectStart === -1 && arrayStart === -1)
119
+ return null;
120
+ if (objectStart === -1) {
121
+ start = arrayStart;
122
+ openChar = '[';
123
+ closeChar = ']';
124
+ }
125
+ else if (arrayStart === -1) {
126
+ start = objectStart;
127
+ openChar = '{';
128
+ closeChar = '}';
129
+ }
130
+ else if (objectStart <= arrayStart) {
131
+ start = objectStart;
132
+ openChar = '{';
133
+ closeChar = '}';
134
+ }
135
+ else {
136
+ start = arrayStart;
137
+ openChar = '[';
138
+ closeChar = ']';
139
+ }
140
+ // Walk forward counting depth, handling string escaping.
141
+ // This correctly handles nested {"a": {"b": [1, 2]}} structures
142
+ // and escaped quotes inside strings like {"content": "she said \"hello\""}.
143
+ let depth = 0;
144
+ let inString = false;
145
+ let escaped = false;
146
+ for (let i = start; i < text.length; i++) {
147
+ const ch = text[i];
148
+ if (escaped) {
149
+ escaped = false;
150
+ continue;
151
+ }
152
+ if (ch === '\\' && inString) {
153
+ escaped = true;
154
+ continue;
155
+ }
156
+ if (ch === '"') {
157
+ inString = !inString;
158
+ continue;
159
+ }
160
+ if (inString)
161
+ continue;
162
+ if (ch === openChar)
163
+ depth++;
164
+ if (ch === closeChar)
165
+ depth--;
166
+ if (depth === 0) {
167
+ const candidate = text.slice(start, i + 1);
168
+ try {
169
+ JSON.parse(candidate);
170
+ return candidate;
171
+ }
172
+ catch {
173
+ return null;
174
+ }
175
+ }
176
+ }
177
+ return null;
178
+ }
179
+ //# sourceMappingURL=extractJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractJson.js","sourceRoot":"","sources":["../../../src/core/validation/extractJson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEzD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAE/B,qDAA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QAAQ;YAAE,KAAK,EAAE,CAAC;QAC7B,IAAI,EAAE,KAAK,SAAS;YAAE,KAAK,EAAE,CAAC;QAE9B,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YAChB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3C,IAAI,CAAC;gBACH,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;gBACtB,OAAO,SAAS,CAAC;YACnB,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @fileoverview LLM output validation layer for AgentOS.
3
+ *
4
+ * Provides Zod-based validation, retry, and JSON extraction for
5
+ * structured LLM outputs. Use `createValidatedInvoker()` to wrap
6
+ * any LLM invoker with automatic validation and retry.
7
+ *
8
+ * @module agentos/core/validation
9
+ */
10
+ export { extractJson } from './extractJson.js';
11
+ export { LlmOutputValidationError, type ValidationRetryRecord } from './errors.js';
12
+ export { createValidatedInvoker, type LlmInvokerWithCapabilities, type ValidatedInvokerOptions, } from './ValidatedLlmInvoker.js';
13
+ export * from './schema-primitives.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/validation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACnF,OAAO,EACL,sBAAsB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,GAC7B,MAAM,0BAA0B,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @fileoverview LLM output validation layer for AgentOS.
3
+ *
4
+ * Provides Zod-based validation, retry, and JSON extraction for
5
+ * structured LLM outputs. Use `createValidatedInvoker()` to wrap
6
+ * any LLM invoker with automatic validation and retry.
7
+ *
8
+ * @module agentos/core/validation
9
+ */
10
+ export { extractJson } from './extractJson.js';
11
+ export { LlmOutputValidationError } from './errors.js';
12
+ export { createValidatedInvoker, } from './ValidatedLlmInvoker.js';
13
+ export * from './schema-primitives.js';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/validation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAA8B,MAAM,aAAa,CAAC;AACnF,OAAO,EACL,sBAAsB,GAGvB,MAAM,0BAA0B,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * @fileoverview Shared Zod building blocks for LLM output schemas.
3
+ *
4
+ * Call sites compose domain-specific schemas from these primitives
5
+ * rather than duplicating enum definitions and field validators.
6
+ * The primitives file is intentionally small — it provides reusable
7
+ * atoms, not complete schemas for every use case.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { MemoryTypeEnum, ConfidenceScore, EntityArray } from '../../core/validation';
12
+ *
13
+ * const MySchema = z.object({
14
+ * type: MemoryTypeEnum,
15
+ * confidence: ConfidenceScore,
16
+ * entities: EntityArray,
17
+ * myCustomField: z.string(),
18
+ * });
19
+ * ```
20
+ *
21
+ * @module agentos/core/validation/schema-primitives
22
+ */
23
+ import { z } from 'zod';
24
+ /**
25
+ * Tulving's LTM taxonomy extended with relational memory.
26
+ * - episodic: autobiographical events and experiences
27
+ * - semantic: general knowledge and facts
28
+ * - procedural: how-to knowledge and behavioral patterns
29
+ * - prospective: future intentions and triggered reminders
30
+ * - relational: trust signals, boundary events, emotional bonds
31
+ */
32
+ export declare const MemoryTypeEnum: z.ZodEnum<{
33
+ semantic: "semantic";
34
+ episodic: "episodic";
35
+ procedural: "procedural";
36
+ prospective: "prospective";
37
+ relational: "relational";
38
+ }>;
39
+ /**
40
+ * Memory visibility/ownership scope.
41
+ * - user: about the user (persists across conversations)
42
+ * - thread: conversation-specific (ephemeral)
43
+ * - persona: about the agent itself
44
+ * - organization: shared across agents
45
+ */
46
+ export declare const MemoryScopeEnum: z.ZodEnum<{
47
+ user: "user";
48
+ organization: "organization";
49
+ thread: "thread";
50
+ persona: "persona";
51
+ }>;
52
+ /** Confidence or strength score, clamped to [0, 1]. */
53
+ export declare const ConfidenceScore: z.ZodNumber;
54
+ /** Array of entity name strings, defaults to empty. */
55
+ export declare const EntityArray: z.ZodDefault<z.ZodArray<z.ZodString>>;
56
+ /** Array of tag strings, defaults to empty. */
57
+ export declare const TagArray: z.ZodDefault<z.ZodArray<z.ZodString>>;
58
+ /** Importance score, clamped to [0, 1], defaults to 0.5. */
59
+ export declare const ImportanceScore: z.ZodDefault<z.ZodNumber>;
60
+ /**
61
+ * Schema for a single observation note extracted by MemoryObserver.
62
+ * The Observer LLM produces these as JSONL (one per line).
63
+ */
64
+ export declare const ObservationNoteOutput: z.ZodObject<{
65
+ type: z.ZodEnum<{
66
+ preference: "preference";
67
+ factual: "factual";
68
+ emotional: "emotional";
69
+ commitment: "commitment";
70
+ creative: "creative";
71
+ correction: "correction";
72
+ }>;
73
+ content: z.ZodString;
74
+ importance: z.ZodDefault<z.ZodNumber>;
75
+ entities: z.ZodDefault<z.ZodArray<z.ZodString>>;
76
+ }, z.core.$strip>;
77
+ /**
78
+ * Schema for a single reflection trace produced by MemoryReflector.
79
+ * The Reflector consolidates observation notes into typed long-term traces.
80
+ */
81
+ export declare const ReflectionTraceOutput: z.ZodObject<{
82
+ reasoning: z.ZodOptional<z.ZodString>;
83
+ type: z.ZodEnum<{
84
+ semantic: "semantic";
85
+ episodic: "episodic";
86
+ procedural: "procedural";
87
+ prospective: "prospective";
88
+ relational: "relational";
89
+ }>;
90
+ scope: z.ZodEnum<{
91
+ user: "user";
92
+ organization: "organization";
93
+ thread: "thread";
94
+ persona: "persona";
95
+ }>;
96
+ scopeId: z.ZodDefault<z.ZodString>;
97
+ content: z.ZodString;
98
+ entities: z.ZodDefault<z.ZodArray<z.ZodString>>;
99
+ tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
100
+ confidence: z.ZodNumber;
101
+ sourceType: z.ZodDefault<z.ZodEnum<{
102
+ observation: "observation";
103
+ reflection: "reflection";
104
+ }>>;
105
+ supersedes: z.ZodDefault<z.ZodArray<z.ZodString>>;
106
+ consumedNotes: z.ZodDefault<z.ZodArray<z.ZodString>>;
107
+ }, z.core.$strip>;
108
+ /**
109
+ * Schema for a compressed observation from ObservationCompressor.
110
+ * Compresses N raw notes into a dense summary.
111
+ */
112
+ export declare const CompressedObservationOutput: z.ZodObject<{
113
+ summary: z.ZodString;
114
+ importance: z.ZodDefault<z.ZodNumber>;
115
+ entities: z.ZodDefault<z.ZodArray<z.ZodString>>;
116
+ noteIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
117
+ }, z.core.$strip>;
118
+ /**
119
+ * Schema for content feature detection (LLM strategy).
120
+ * Used by ContentFeatureDetector when `featureDetectionStrategy === 'llm'`.
121
+ */
122
+ export declare const ContentFeaturesOutput: z.ZodObject<{
123
+ hasNovelty: z.ZodDefault<z.ZodBoolean>;
124
+ hasProcedure: z.ZodDefault<z.ZodBoolean>;
125
+ hasEmotion: z.ZodDefault<z.ZodBoolean>;
126
+ hasSocialContent: z.ZodDefault<z.ZodBoolean>;
127
+ hasCooperation: z.ZodDefault<z.ZodBoolean>;
128
+ hasEthicalContent: z.ZodDefault<z.ZodBoolean>;
129
+ hasContradiction: z.ZodDefault<z.ZodBoolean>;
130
+ topicRelevance: z.ZodDefault<z.ZodNumber>;
131
+ }, z.core.$strip>;
132
+ //# sourceMappingURL=schema-primitives.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-primitives.d.ts","sourceRoot":"","sources":["../../../src/core/validation/schema-primitives.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;;;;EAMzB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;;;;;EAK1B,CAAC;AAIH,uDAAuD;AACvD,eAAO,MAAM,eAAe,aAA2B,CAAC;AAExD,uDAAuD;AACvD,eAAO,MAAM,WAAW,uCAAkC,CAAC;AAE3D,+CAA+C;AAC/C,eAAO,MAAM,QAAQ,uCAAkC,CAAC;AAExD,4DAA4D;AAC5D,eAAO,MAAM,eAAe,2BAAwC,CAAC;AAIrE;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;iBAShC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBhC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,2BAA2B;;;;;iBAStC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;iBAiBhC,CAAC"}
@@ -0,0 +1,141 @@
1
+ /**
2
+ * @fileoverview Shared Zod building blocks for LLM output schemas.
3
+ *
4
+ * Call sites compose domain-specific schemas from these primitives
5
+ * rather than duplicating enum definitions and field validators.
6
+ * The primitives file is intentionally small — it provides reusable
7
+ * atoms, not complete schemas for every use case.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { MemoryTypeEnum, ConfidenceScore, EntityArray } from '../../core/validation/index.js';
12
+ *
13
+ * const MySchema = z.object({
14
+ * type: MemoryTypeEnum,
15
+ * confidence: ConfidenceScore,
16
+ * entities: EntityArray,
17
+ * myCustomField: z.string(),
18
+ * });
19
+ * ```
20
+ *
21
+ * @module agentos/core/validation/schema-primitives
22
+ */
23
+ import { z } from 'zod';
24
+ // ── Memory type enums ────────────────────────────────────────────────────
25
+ /**
26
+ * Tulving's LTM taxonomy extended with relational memory.
27
+ * - episodic: autobiographical events and experiences
28
+ * - semantic: general knowledge and facts
29
+ * - procedural: how-to knowledge and behavioral patterns
30
+ * - prospective: future intentions and triggered reminders
31
+ * - relational: trust signals, boundary events, emotional bonds
32
+ */
33
+ export const MemoryTypeEnum = z.enum([
34
+ 'episodic',
35
+ 'semantic',
36
+ 'procedural',
37
+ 'prospective',
38
+ 'relational',
39
+ ]);
40
+ /**
41
+ * Memory visibility/ownership scope.
42
+ * - user: about the user (persists across conversations)
43
+ * - thread: conversation-specific (ephemeral)
44
+ * - persona: about the agent itself
45
+ * - organization: shared across agents
46
+ */
47
+ export const MemoryScopeEnum = z.enum([
48
+ 'user',
49
+ 'thread',
50
+ 'persona',
51
+ 'organization',
52
+ ]);
53
+ // ── Common field validators ──────────────────────────────────────────────
54
+ /** Confidence or strength score, clamped to [0, 1]. */
55
+ export const ConfidenceScore = z.number().min(0).max(1);
56
+ /** Array of entity name strings, defaults to empty. */
57
+ export const EntityArray = z.array(z.string()).default([]);
58
+ /** Array of tag strings, defaults to empty. */
59
+ export const TagArray = z.array(z.string()).default([]);
60
+ /** Importance score, clamped to [0, 1], defaults to 0.5. */
61
+ export const ImportanceScore = z.number().min(0).max(1).default(0.5);
62
+ // ── Composite schemas for AgentOS memory pipeline ────────────────────────
63
+ /**
64
+ * Schema for a single observation note extracted by MemoryObserver.
65
+ * The Observer LLM produces these as JSONL (one per line).
66
+ */
67
+ export const ObservationNoteOutput = z.object({
68
+ /** Observation category. */
69
+ type: z.enum(['factual', 'emotional', 'commitment', 'preference', 'creative', 'correction']),
70
+ /** Brief summary of the observation (1-2 sentences max). */
71
+ content: z.string().min(1),
72
+ /** How important this observation is for future recall (0-1). */
73
+ importance: ImportanceScore,
74
+ /** Key entities mentioned in the observation. */
75
+ entities: EntityArray,
76
+ });
77
+ /**
78
+ * Schema for a single reflection trace produced by MemoryReflector.
79
+ * The Reflector consolidates observation notes into typed long-term traces.
80
+ */
81
+ export const ReflectionTraceOutput = z.object({
82
+ /** Chain-of-thought reasoning for why this trace matters (devtools only). */
83
+ reasoning: z.string().optional(),
84
+ /** Memory type classification (Tulving's taxonomy + relational). */
85
+ type: MemoryTypeEnum,
86
+ /** Memory scope for access control. */
87
+ scope: MemoryScopeEnum,
88
+ /** Scope identifier (e.g., user ID, thread ID). */
89
+ scopeId: z.string().default(''),
90
+ /** Consolidated memory content. */
91
+ content: z.string().min(1),
92
+ /** Entities referenced in this memory. */
93
+ entities: EntityArray,
94
+ /** Descriptive tags for retrieval filtering. */
95
+ tags: TagArray,
96
+ /** Confidence in this memory's accuracy (0-1). */
97
+ confidence: ConfidenceScore,
98
+ /** How this trace was produced. */
99
+ sourceType: z.enum(['observation', 'reflection']).default('reflection'),
100
+ /** IDs of existing traces that this trace supersedes (conflict resolution). */
101
+ supersedes: z.array(z.string()).default([]),
102
+ /** IDs of observation notes consumed to produce this trace. */
103
+ consumedNotes: z.array(z.string()).default([]),
104
+ });
105
+ /**
106
+ * Schema for a compressed observation from ObservationCompressor.
107
+ * Compresses N raw notes into a dense summary.
108
+ */
109
+ export const CompressedObservationOutput = z.object({
110
+ /** Dense summary of multiple observation notes. */
111
+ summary: z.string().min(1),
112
+ /** Aggregate importance of the compressed observations. */
113
+ importance: ImportanceScore,
114
+ /** Entities across all compressed notes. */
115
+ entities: EntityArray,
116
+ /** IDs of the raw notes that were compressed. */
117
+ noteIds: z.array(z.string()).default([]),
118
+ });
119
+ /**
120
+ * Schema for content feature detection (LLM strategy).
121
+ * Used by ContentFeatureDetector when `featureDetectionStrategy === 'llm'`.
122
+ */
123
+ export const ContentFeaturesOutput = z.object({
124
+ /** Content contains novel or surprising information. */
125
+ hasNovelty: z.boolean().default(false),
126
+ /** Content contains procedural/how-to knowledge. */
127
+ hasProcedure: z.boolean().default(false),
128
+ /** Content has emotional charge or sentiment. */
129
+ hasEmotion: z.boolean().default(false),
130
+ /** Content involves social interactions or relationships. */
131
+ hasSocialContent: z.boolean().default(false),
132
+ /** Content involves cooperative or collaborative themes. */
133
+ hasCooperation: z.boolean().default(false),
134
+ /** Content involves ethical or moral considerations. */
135
+ hasEthicalContent: z.boolean().default(false),
136
+ /** Content contradicts previously known information. */
137
+ hasContradiction: z.boolean().default(false),
138
+ /** Relevance to current task or conversation (0-1). */
139
+ topicRelevance: z.number().min(0).max(1).default(0.5),
140
+ });
141
+ //# sourceMappingURL=schema-primitives.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-primitives.js","sourceRoot":"","sources":["../../../src/core/validation/schema-primitives.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,4EAA4E;AAE5E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC;IACnC,UAAU;IACV,UAAU;IACV,YAAY;IACZ,aAAa;IACb,YAAY;CACb,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC;IACpC,MAAM;IACN,QAAQ;IACR,SAAS;IACT,cAAc;CACf,CAAC,CAAC;AAEH,4EAA4E;AAE5E,uDAAuD;AACvD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAExD,uDAAuD;AACvD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAE3D,+CAA+C;AAC/C,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAA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CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAC7C,wDAAwD;IACxD,gBAAgB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAC5C,uDAAuD;IACvD,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;CACtD,CAAC,CAAC"}
@@ -30,7 +30,7 @@
30
30
  *
31
31
  * @module agentos/memory/AgentMemory
32
32
  */
33
- import type { MemoryTrace, MemoryType, MemoryScope, MemorySourceType, ScoredMemoryTrace, AssembledMemoryContext, MemoryHealthReport, CognitiveRetrievalResult } from './core/types.js';
33
+ import type { MemoryTrace, MemoryType, MemoryScope, MemorySourceType, ScoredMemoryTrace, AssembledMemoryContext, MemoryHealthReport, CognitiveRetrievalResult, WorkingMemorySlot, MemoryGraphSnapshot, ObservationPipelineStats, CognitiveMemorySnapshot, MemoryTypeStats } from './core/types.js';
34
34
  import type { CognitiveMemoryConfig } from './core/config.js';
35
35
  import type { ICognitiveMemoryManager } from './CognitiveMemoryManager.js';
36
36
  import type { ObservationNote } from './pipeline/observation/MemoryObserver.js';
@@ -171,6 +171,123 @@ export declare class AgentMemory {
171
171
  * standalone SQLite-first Memory facade.
172
172
  */
173
173
  feedback(traceId: string, signal: 'used' | 'ignored', query?: string): void;
174
+ /**
175
+ * Get a serializable snapshot of the memory graph for visualization.
176
+ * Returns nodes (traces), edges (associations), clusters, and aggregate stats.
177
+ *
178
+ * @throws When backed by standalone SQLite (requires CognitiveMemoryManager)
179
+ * @returns Graph snapshot suitable for JSON serialization
180
+ */
181
+ getGraph(): Promise<MemoryGraphSnapshot>;
182
+ /**
183
+ * Get spreading activation results from seed memories.
184
+ * Returns memories that are associatively connected to the seeds.
185
+ *
186
+ * @param seedTraceIds - IDs of seed traces to activate from
187
+ * @param opts - Optional depth and limit controls
188
+ * @throws When backed by standalone SQLite
189
+ */
190
+ getAssociations(seedTraceIds: string[], opts?: {
191
+ maxDepth?: number;
192
+ limit?: number;
193
+ }): Promise<Array<{
194
+ memoryId: string;
195
+ activation: number;
196
+ }>>;
197
+ /**
198
+ * Get all traces filtered by memory type.
199
+ *
200
+ * @param type - Memory type to filter by (episodic, semantic, procedural, prospective, relational)
201
+ * @param opts - Optional limit and minimum strength filter
202
+ * @throws When backed by standalone SQLite
203
+ */
204
+ getTracesByType(type: MemoryType, opts?: {
205
+ limit?: number;
206
+ minStrength?: number;
207
+ }): Promise<ScoredMemoryTrace[]>;
208
+ /**
209
+ * Get relational memory traces (trust signals, boundaries, emotional bonds).
210
+ * Convenience wrapper around getTracesByType('relational').
211
+ */
212
+ getRelationalMemories(opts?: {
213
+ limit?: number;
214
+ }): Promise<ScoredMemoryTrace[]>;
215
+ /**
216
+ * Get memory strength distribution by type.
217
+ * Returns count, average strength, decaying count, and flashbulb count per type.
218
+ *
219
+ * @throws When backed by standalone SQLite
220
+ */
221
+ getStrengthDistribution(): Promise<Record<MemoryType, MemoryTypeStats>>;
222
+ /**
223
+ * Get pairs of contradicting memory traces.
224
+ *
225
+ * @throws When backed by standalone SQLite
226
+ */
227
+ getConflicts(): Promise<Array<{
228
+ traceA: string;
229
+ traceB: string;
230
+ type: string;
231
+ }>>;
232
+ /**
233
+ * Get clusters of strongly associated memories.
234
+ *
235
+ * @param minSize - Minimum cluster size (default 3)
236
+ * @throws When backed by standalone SQLite
237
+ */
238
+ getClusters(minSize?: number): Promise<Array<{
239
+ clusterId: string;
240
+ memberIds: string[];
241
+ density: number;
242
+ }>>;
243
+ /**
244
+ * Get working memory slots — what's currently "in focus".
245
+ *
246
+ * @throws When backed by standalone SQLite
247
+ */
248
+ getWorkingMemory(): Promise<WorkingMemorySlot[]>;
249
+ /**
250
+ * Get observation pipeline stats (pending notes, compression ratio, reflection count).
251
+ *
252
+ * @throws When backed by standalone SQLite
253
+ */
254
+ getObservationStats(): Promise<ObservationPipelineStats>;
255
+ /**
256
+ * Get active prospective memory items (reminders/intentions).
257
+ * Alias for `reminders()` with a more descriptive name.
258
+ */
259
+ getProspectiveItems(): Promise<ProspectiveMemoryItem[]>;
260
+ /**
261
+ * Force a reflection cycle (useful for testing / devtools).
262
+ * Triggers the Observer's note extraction and the Reflector's consolidation
263
+ * regardless of token thresholds.
264
+ *
265
+ * @throws When backed by standalone SQLite
266
+ * @returns Reflection result with typed traces, or empty result if no observer
267
+ */
268
+ forceReflection(): Promise<{
269
+ traces: number;
270
+ superseded: number;
271
+ }>;
272
+ /**
273
+ * Export full memory state as a serializable snapshot.
274
+ * Used for companion portability across worlds in wilds-ai.
275
+ *
276
+ * @throws When backed by standalone SQLite
277
+ */
278
+ exportSnapshot(): Promise<CognitiveMemorySnapshot>;
279
+ /**
280
+ * Import a memory snapshot (for character portability across worlds).
281
+ * Encodes each trace and registers prospective items.
282
+ *
283
+ * @param snapshot - Previously exported snapshot
284
+ * @throws When backed by standalone SQLite
285
+ * @returns Count of imported traces and conflicts detected
286
+ */
287
+ importSnapshot(snapshot: CognitiveMemorySnapshot): Promise<{
288
+ imported: number;
289
+ conflicts: number;
290
+ }>;
174
291
  get isInitialized(): boolean;
175
292
  /** Access the underlying manager for advanced usage. */
176
293
  get raw(): ICognitiveMemoryManager;
@@ -1 +1 @@
1
- {"version":3,"file":"AgentMemory.d.ts","sourceRoot":"","sources":["../../src/memory/AgentMemory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAY,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,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