flowscript-core 1.0.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.
Files changed (97) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +386 -0
  3. package/bin/flowscript +12 -0
  4. package/dist/cli.d.ts +12 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +463 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/errors/indentation-error.d.ts +11 -0
  9. package/dist/errors/indentation-error.d.ts.map +1 -0
  10. package/dist/errors/indentation-error.js +22 -0
  11. package/dist/errors/indentation-error.js.map +1 -0
  12. package/dist/grammar.ohm +132 -0
  13. package/dist/hash.d.ts +21 -0
  14. package/dist/hash.d.ts.map +1 -0
  15. package/dist/hash.js +82 -0
  16. package/dist/hash.js.map +1 -0
  17. package/dist/indentation-scanner.d.ts +81 -0
  18. package/dist/indentation-scanner.d.ts.map +1 -0
  19. package/dist/indentation-scanner.js +290 -0
  20. package/dist/indentation-scanner.js.map +1 -0
  21. package/dist/index.d.ts +15 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +49 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/linter.d.ts +71 -0
  26. package/dist/linter.d.ts.map +1 -0
  27. package/dist/linter.js +122 -0
  28. package/dist/linter.js.map +1 -0
  29. package/dist/memory.d.ts +506 -0
  30. package/dist/memory.d.ts.map +1 -0
  31. package/dist/memory.js +1802 -0
  32. package/dist/memory.js.map +1 -0
  33. package/dist/parser.d.ts +53 -0
  34. package/dist/parser.d.ts.map +1 -0
  35. package/dist/parser.js +1184 -0
  36. package/dist/parser.js.map +1 -0
  37. package/dist/query-engine.d.ts +320 -0
  38. package/dist/query-engine.d.ts.map +1 -0
  39. package/dist/query-engine.js +884 -0
  40. package/dist/query-engine.js.map +1 -0
  41. package/dist/rules/alternatives-without-decision.d.ts +24 -0
  42. package/dist/rules/alternatives-without-decision.d.ts.map +1 -0
  43. package/dist/rules/alternatives-without-decision.js +58 -0
  44. package/dist/rules/alternatives-without-decision.js.map +1 -0
  45. package/dist/rules/causal-cycles.d.ts +23 -0
  46. package/dist/rules/causal-cycles.d.ts.map +1 -0
  47. package/dist/rules/causal-cycles.js +83 -0
  48. package/dist/rules/causal-cycles.js.map +1 -0
  49. package/dist/rules/deep-nesting.d.ts +23 -0
  50. package/dist/rules/deep-nesting.d.ts.map +1 -0
  51. package/dist/rules/deep-nesting.js +55 -0
  52. package/dist/rules/deep-nesting.js.map +1 -0
  53. package/dist/rules/index.d.ts +15 -0
  54. package/dist/rules/index.d.ts.map +1 -0
  55. package/dist/rules/index.js +29 -0
  56. package/dist/rules/index.js.map +1 -0
  57. package/dist/rules/invalid-syntax.d.ts +22 -0
  58. package/dist/rules/invalid-syntax.d.ts.map +1 -0
  59. package/dist/rules/invalid-syntax.js +52 -0
  60. package/dist/rules/invalid-syntax.js.map +1 -0
  61. package/dist/rules/long-causal-chains.d.ts +25 -0
  62. package/dist/rules/long-causal-chains.d.ts.map +1 -0
  63. package/dist/rules/long-causal-chains.js +75 -0
  64. package/dist/rules/long-causal-chains.js.map +1 -0
  65. package/dist/rules/missing-recommended-fields.d.ts +21 -0
  66. package/dist/rules/missing-recommended-fields.d.ts.map +1 -0
  67. package/dist/rules/missing-recommended-fields.js +45 -0
  68. package/dist/rules/missing-recommended-fields.js.map +1 -0
  69. package/dist/rules/missing-required-fields.d.ts +22 -0
  70. package/dist/rules/missing-required-fields.d.ts.map +1 -0
  71. package/dist/rules/missing-required-fields.js +46 -0
  72. package/dist/rules/missing-required-fields.js.map +1 -0
  73. package/dist/rules/orphaned-nodes.d.ts +22 -0
  74. package/dist/rules/orphaned-nodes.d.ts.map +1 -0
  75. package/dist/rules/orphaned-nodes.js +76 -0
  76. package/dist/rules/orphaned-nodes.js.map +1 -0
  77. package/dist/rules/unlabeled-tension.d.ts +20 -0
  78. package/dist/rules/unlabeled-tension.d.ts.map +1 -0
  79. package/dist/rules/unlabeled-tension.js +37 -0
  80. package/dist/rules/unlabeled-tension.js.map +1 -0
  81. package/dist/serializer.d.ts +40 -0
  82. package/dist/serializer.d.ts.map +1 -0
  83. package/dist/serializer.js +368 -0
  84. package/dist/serializer.js.map +1 -0
  85. package/dist/tokenizer.d.ts +26 -0
  86. package/dist/tokenizer.d.ts.map +1 -0
  87. package/dist/tokenizer.js +213 -0
  88. package/dist/tokenizer.js.map +1 -0
  89. package/dist/types.d.ts +96 -0
  90. package/dist/types.d.ts.map +1 -0
  91. package/dist/types.js +50 -0
  92. package/dist/types.js.map +1 -0
  93. package/dist/validate.d.ts +18 -0
  94. package/dist/validate.d.ts.map +1 -0
  95. package/dist/validate.js +68 -0
  96. package/dist/validate.js.map +1 -0
  97. package/package.json +69 -0
package/dist/linter.js ADDED
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ /**
3
+ * FlowScript Semantic Linter
4
+ *
5
+ * Enforces semantic correctness beyond syntax validation.
6
+ * Implements 6 ERROR + 3 WARNING rules from spec/linter-rules.md
7
+ *
8
+ * Architecture: Two-pass validation
9
+ * - Pass 1: Syntax validation (handled by parser)
10
+ * - Pass 2: Semantic validation (this linter)
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.Linter = exports.BaseLintRule = void 0;
14
+ /**
15
+ * Base class for lint rules - provides helper methods
16
+ */
17
+ class BaseLintRule {
18
+ createResult(message, location, suggestion) {
19
+ return {
20
+ severity: this.severity,
21
+ rule: this.code,
22
+ message,
23
+ location,
24
+ suggestion
25
+ };
26
+ }
27
+ }
28
+ exports.BaseLintRule = BaseLintRule;
29
+ /**
30
+ * Main linter class - orchestrates all validation rules
31
+ */
32
+ class Linter {
33
+ constructor() {
34
+ this.rules = [];
35
+ this.registerRules();
36
+ }
37
+ registerRules() {
38
+ // Import all rules
39
+ const { UnlabeledTensionRule, MissingRequiredFieldsRule, InvalidSyntaxRule, OrphanedNodesRule, CausalCyclesRule, AlternativesWithoutDecisionRule, MissingRecommendedFieldsRule, DeepNestingRule, LongCausalChainsRule } = require('./rules');
40
+ // ERROR rules (6 total)
41
+ this.rules.push(new UnlabeledTensionRule());
42
+ this.rules.push(new MissingRequiredFieldsRule());
43
+ this.rules.push(new InvalidSyntaxRule());
44
+ this.rules.push(new OrphanedNodesRule());
45
+ this.rules.push(new CausalCyclesRule());
46
+ this.rules.push(new AlternativesWithoutDecisionRule());
47
+ // WARNING rules (3 total)
48
+ this.rules.push(new MissingRecommendedFieldsRule());
49
+ this.rules.push(new DeepNestingRule());
50
+ this.rules.push(new LongCausalChainsRule());
51
+ }
52
+ /**
53
+ * Register a single rule (for testing or custom rules)
54
+ */
55
+ addRule(rule) {
56
+ this.rules.push(rule);
57
+ }
58
+ /**
59
+ * Main linting entry point
60
+ */
61
+ lint(ir) {
62
+ const results = [];
63
+ for (const rule of this.rules) {
64
+ try {
65
+ const ruleResults = rule.check(ir);
66
+ results.push(...ruleResults);
67
+ }
68
+ catch (error) {
69
+ // Rule execution failed - log but continue with other rules
70
+ console.error(`Rule ${rule.code} failed:`, error);
71
+ }
72
+ }
73
+ // Sort: ERRORs first, then by line number
74
+ results.sort((a, b) => {
75
+ if (a.severity !== b.severity) {
76
+ return a.severity === 'ERROR' ? -1 : 1;
77
+ }
78
+ const aLine = a.location?.line || 0;
79
+ const bLine = b.location?.line || 0;
80
+ return aLine - bLine;
81
+ });
82
+ return results;
83
+ }
84
+ /**
85
+ * Filter results by severity
86
+ */
87
+ getErrors(results) {
88
+ return results.filter(r => r.severity === 'ERROR');
89
+ }
90
+ getWarnings(results) {
91
+ return results.filter(r => r.severity === 'WARNING');
92
+ }
93
+ /**
94
+ * Check if linting passed (no errors)
95
+ */
96
+ hasErrors(results) {
97
+ return this.getErrors(results).length > 0;
98
+ }
99
+ /**
100
+ * Format results for display
101
+ */
102
+ formatResults(results) {
103
+ if (results.length === 0) {
104
+ return 'No issues found ✓';
105
+ }
106
+ const lines = [];
107
+ for (const result of results) {
108
+ const location = result.location
109
+ ? `${result.location.file}:${result.location.line}`
110
+ : 'unknown';
111
+ lines.push(`${result.severity}: ${result.rule} - ${result.message}`);
112
+ lines.push(` at ${location}`);
113
+ if (result.suggestion) {
114
+ lines.push(` Suggestion: ${result.suggestion}`);
115
+ }
116
+ lines.push(''); // blank line between results
117
+ }
118
+ return lines.join('\n');
119
+ }
120
+ }
121
+ exports.Linter = Linter;
122
+ //# sourceMappingURL=linter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linter.js","sourceRoot":"","sources":["../src/linter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAwBH;;GAEG;AACH,MAAsB,YAAY;IAOtB,YAAY,CACpB,OAAe,EACf,QAAyC,EACzC,UAAmB;QAEnB,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO;YACP,QAAQ;YACR,UAAU;SACX,CAAC;IACJ,CAAC;CACF;AApBD,oCAoBC;AAED;;GAEG;AACH,MAAa,MAAM;IAGjB;QAFQ,UAAK,GAAe,EAAE,CAAC;QAG7B,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAEO,aAAa;QACnB,mBAAmB;QACnB,MAAM,EACJ,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,+BAA+B,EAC/B,4BAA4B,EAC5B,eAAe,EACf,oBAAoB,EACrB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;QAEvB,wBAAwB;QACxB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,yBAAyB,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,iBAAiB,EAAE,CAA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;YAE/B,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBACtB,KAAK,CAAC,IAAI,CAAC,iBAAiB,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;YACnD,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,6BAA6B;QAC/C,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AApHD,wBAoHC"}
@@ -0,0 +1,506 @@
1
+ /**
2
+ * FlowScript Memory Class + NodeRef
3
+ *
4
+ * Programmatic builder for FlowScript IR graphs with temporal intelligence.
5
+ * The developer-facing API for "decision intelligence that gets smarter over time."
6
+ *
7
+ * Memory = the graph owner. Creates nodes, relationships, states.
8
+ * NodeRef = fluent reference handle. Enables chaining: mem.thought("X").causes(mem.thought("Y"))
9
+ *
10
+ * Design:
11
+ * - IR is the internal representation (same as parser produces)
12
+ * - Temporal metadata (tiers, frequency, garden) stored separately from IR
13
+ * - Content-hash deduplication drives frequency tracking
14
+ * - Query engine lazy-refreshes when IR changes
15
+ * - JSON is canonical persistence (.fs is human-readable projection)
16
+ */
17
+ import { SerializeOptions } from './serializer';
18
+ import { FlowScriptQueryEngine } from './query-engine';
19
+ import type { IR, Node, NodeType, Relationship, RelationType, State, StateType } from './types';
20
+ export interface TemporalTierConfig {
21
+ maxAge: string | null;
22
+ graduationThreshold?: number;
23
+ }
24
+ export interface DormancyConfig {
25
+ resting: string;
26
+ dormant: string;
27
+ archive: string;
28
+ }
29
+ export interface TemporalConfig {
30
+ tiers?: {
31
+ current?: TemporalTierConfig;
32
+ developing?: TemporalTierConfig;
33
+ proven?: TemporalTierConfig;
34
+ foundation?: TemporalTierConfig;
35
+ };
36
+ dormancy?: Partial<DormancyConfig>;
37
+ }
38
+ export interface MemoryOptions {
39
+ temporal?: TemporalConfig;
40
+ sourceFile?: string;
41
+ author?: {
42
+ agent: string;
43
+ role: 'human' | 'ai';
44
+ };
45
+ autoSnapshot?: boolean;
46
+ }
47
+ export type TemporalTier = 'current' | 'developing' | 'proven' | 'foundation';
48
+ export interface TemporalMeta {
49
+ createdAt: string;
50
+ lastTouched: string;
51
+ frequency: number;
52
+ tier: TemporalTier;
53
+ }
54
+ export interface GardenReport {
55
+ growing: NodeRef[];
56
+ resting: NodeRef[];
57
+ dormant: NodeRef[];
58
+ stats: {
59
+ total: number;
60
+ growing: number;
61
+ resting: number;
62
+ dormant: number;
63
+ };
64
+ }
65
+ export interface PruneReport {
66
+ archived: NodeRef[];
67
+ count: number;
68
+ }
69
+ /** A single entry in the append-only audit log. Captures full objects including provenance. */
70
+ export interface AuditEntry {
71
+ timestamp: string;
72
+ event: 'prune';
73
+ nodes: Node[];
74
+ relationships: Relationship[];
75
+ states: State[];
76
+ temporal: Record<string, TemporalMeta>;
77
+ reason: string;
78
+ }
79
+ export interface SnapshotEntry {
80
+ id: string;
81
+ reason: string;
82
+ timestamp: string;
83
+ ir: IR;
84
+ temporal: Record<string, TemporalMeta>;
85
+ }
86
+ export interface SnapshotInfo {
87
+ id: string;
88
+ reason: string;
89
+ timestamp: string;
90
+ nodeCount: number;
91
+ }
92
+ export interface GraduationCandidate {
93
+ node: NodeRef;
94
+ frequency: number;
95
+ tier: TemporalTier;
96
+ relatedNodes: NodeRef[];
97
+ }
98
+ export interface GraduationResult {
99
+ graduate: boolean;
100
+ destination?: TemporalTier;
101
+ compressed?: string;
102
+ reason?: string;
103
+ }
104
+ /** Graduation event handler. Must return synchronously (async not yet supported). */
105
+ export type GraduationHandler = (candidate: GraduationCandidate) => GraduationResult | void;
106
+ type EventHandler = (...args: any[]) => void;
107
+ export interface MemoryJSON {
108
+ flowscript_memory: '1.0.0';
109
+ ir: IR;
110
+ temporal: Record<string, TemporalMeta>;
111
+ snapshots: SnapshotEntry[];
112
+ config: MemoryOptions;
113
+ }
114
+ export interface BudgetedSerializeOptions extends SerializeOptions {
115
+ /** Maximum token budget. When set, enables intelligent node selection. */
116
+ maxTokens?: number;
117
+ /**
118
+ * Priority strategy for selecting nodes within budget.
119
+ * - 'tier-priority' (default): foundation → proven → developing → current, frequency tiebreaker
120
+ * - 'recency': newest lastTouched first
121
+ * - 'frequency': most-touched first
122
+ * - 'relevance': word-overlap scoring against relevanceQuery
123
+ */
124
+ strategy?: 'tier-priority' | 'recency' | 'frequency' | 'relevance';
125
+ /** Tiers that are always included regardless of budget. Default: ['proven', 'foundation'] */
126
+ preserveTiers?: TemporalTier[];
127
+ /** Exclude dormant nodes from budget consideration. Default: true */
128
+ excludeDormant?: boolean;
129
+ /** Query string for 'relevance' strategy (word-overlap matching). */
130
+ relevanceQuery?: string;
131
+ /** Custom token estimator. Default: Math.ceil(text.length / 4) */
132
+ tokenEstimator?: (text: string) => number;
133
+ }
134
+ export interface ToolSchema {
135
+ type: 'function';
136
+ function: {
137
+ name: string;
138
+ description: string;
139
+ parameters: {
140
+ type: 'object';
141
+ properties: Record<string, unknown>;
142
+ required?: string[];
143
+ };
144
+ };
145
+ }
146
+ export type ToolResult = {
147
+ success: true;
148
+ data: Record<string, any>;
149
+ } | {
150
+ success: false;
151
+ error: string;
152
+ };
153
+ export interface MemoryTool extends ToolSchema {
154
+ /** Execute this tool with the given arguments. Returns structured JSON result. */
155
+ handler: (args: Record<string, any>) => ToolResult;
156
+ }
157
+ export interface AsToolsOptions {
158
+ /** Which tool categories to include. Default: all categories. */
159
+ include?: Array<'core' | 'query' | 'memory'>;
160
+ /** Prefix for tool names (e.g., 'memory_' → 'memory_add_node'). Default: '' */
161
+ prefix?: string;
162
+ }
163
+ /** Function that sends a prompt to any LLM and returns the response text. */
164
+ export type ExtractFn = (prompt: string) => Promise<string>;
165
+ /** Options for Memory.fromTranscript() */
166
+ export interface FromTranscriptOptions {
167
+ /** Function that sends a prompt to any LLM and returns the text response. Required. */
168
+ extract: ExtractFn;
169
+ /** Memory options applied to the created Memory instance. */
170
+ memoryOptions?: MemoryOptions;
171
+ }
172
+ /** Shape of the JSON the LLM is asked to produce. Exported for testing custom extract functions. */
173
+ export interface TranscriptExtraction {
174
+ nodes: Array<{
175
+ id: string;
176
+ type: 'statement' | 'thought' | 'question' | 'action' | 'insight' | 'completion';
177
+ content: string;
178
+ modifiers?: Array<'urgent' | 'positive' | 'confident' | 'uncertain'>;
179
+ }>;
180
+ relationships: Array<{
181
+ source: string;
182
+ target: string;
183
+ type: 'causes' | 'temporal' | 'derives_from' | 'bidirectional' | 'tension' | 'equivalent' | 'different';
184
+ axis?: string;
185
+ }>;
186
+ states: Array<{
187
+ node: string;
188
+ type: 'decided' | 'exploring' | 'blocked' | 'parking';
189
+ fields: Record<string, string>;
190
+ }>;
191
+ }
192
+ /**
193
+ * Lightweight reference to a node in a Memory graph.
194
+ * All mutation methods delegate to the owning Memory instance.
195
+ * Returns NodeRef for fluent chaining.
196
+ */
197
+ export declare class NodeRef {
198
+ private readonly memory;
199
+ private readonly _id;
200
+ constructor(memory: Memory, _id: string);
201
+ /** Node ID (content-hash) */
202
+ get id(): string;
203
+ /** The underlying Node object */
204
+ get node(): Node;
205
+ /** Node type */
206
+ get type(): NodeType;
207
+ /** Node content text */
208
+ get content(): string;
209
+ /** Create a thought node as a child of this node */
210
+ thought(content: string): NodeRef;
211
+ /** Create a statement node as a child of this node */
212
+ statement(content: string): NodeRef;
213
+ /** Create an action node as a child of this node */
214
+ action(content: string): NodeRef;
215
+ /** Create a question node as a child of this node */
216
+ question(content: string): NodeRef;
217
+ /** Create an insight node as a child of this node */
218
+ insight(content: string): NodeRef;
219
+ /** This node causes the target. Returns target for chaining. */
220
+ causes(target: NodeRef | string): NodeRef;
221
+ /** This node is temporally followed by target. Returns target. */
222
+ then(target: NodeRef | string): NodeRef;
223
+ /** This node derives from source. Returns this for chaining. */
224
+ derivesFrom(source: NodeRef | string): NodeRef;
225
+ /** Create a tension between this node and target. Returns this. */
226
+ vs(target: NodeRef | string, axis: string): NodeRef;
227
+ /** Bidirectional relationship with target. Returns this. */
228
+ bidirectional(target: NodeRef | string): NodeRef;
229
+ /** Mark this node as decided. Returns this. */
230
+ decide(fields: {
231
+ rationale: string;
232
+ on?: string;
233
+ }): NodeRef;
234
+ /** Mark this node as blocked. Returns this. */
235
+ block(fields: {
236
+ reason: string;
237
+ since?: string;
238
+ }): NodeRef;
239
+ /** Mark this node as parked. Returns this. */
240
+ park(fields: {
241
+ why: string;
242
+ until?: string;
243
+ }): NodeRef;
244
+ /** Mark this node as exploring. Returns this. */
245
+ explore(): NodeRef;
246
+ /** Remove a specific state type from this node. Returns this. */
247
+ unblock(): NodeRef;
248
+ /** Remove all states from this node. Returns this. */
249
+ clearStates(): NodeRef;
250
+ /** Add ! (urgent) modifier. Returns this. */
251
+ urgent(): NodeRef;
252
+ /** Add ++ (strong positive) modifier. Returns this. */
253
+ positive(): NodeRef;
254
+ /** Add * (high confidence) modifier. Returns this. */
255
+ confident(): NodeRef;
256
+ /** Add ~ (low confidence / uncertain) modifier. Returns this. */
257
+ uncertain(): NodeRef;
258
+ }
259
+ /**
260
+ * Programmatic builder for FlowScript IR graphs with temporal intelligence.
261
+ *
262
+ * Usage:
263
+ * const mem = new Memory();
264
+ * const q = mem.question("Which database?");
265
+ * const redis = mem.alternative(q, "Redis");
266
+ * redis.decide({ rationale: "speed critical" });
267
+ * mem.query.blocked();
268
+ * mem.save("./memory.json");
269
+ */
270
+ export declare class Memory {
271
+ private ir;
272
+ private nodeMap;
273
+ private temporalMap;
274
+ private _snapshots;
275
+ private _queryEngine;
276
+ private _dirty;
277
+ private _lineCounter;
278
+ private _handlers;
279
+ private _config;
280
+ private _defaultDormancy;
281
+ private _filePath;
282
+ constructor(options?: MemoryOptions);
283
+ /** Create Memory from an existing IR. filePath will be null — save() requires an explicit path. */
284
+ static fromIR(ir: IR, options?: MemoryOptions): Memory;
285
+ /** Parse .fs text into Memory. filePath will be null — save() requires an explicit path. */
286
+ static parse(text: string, filename?: string): Memory;
287
+ /** Load from JSON persistence format (accepts string or pre-parsed object). filePath will be null — save() requires an explicit path. */
288
+ static fromJSON(json: string | MemoryJSON): Memory;
289
+ /** Load from file (.fs or .json, detected by extension) */
290
+ static load(filePath: string): Memory;
291
+ /**
292
+ * Load from file if it exists, otherwise create empty Memory.
293
+ * Stores the path for no-arg save().
294
+ *
295
+ * @param filePath - Path to load from or save to. Parent directories are created on save() if needed.
296
+ * @param options - Applied only when creating a new Memory. Ignored when loading from existing file
297
+ * (the persisted config from the file takes precedence).
298
+ *
299
+ * Note: `.fs` format is lossy — temporal metadata, snapshots, and config are not preserved.
300
+ * Use `.json` extension for the full operational loop (loadOrCreate → modify → save → loadOrCreate).
301
+ */
302
+ static loadOrCreate(filePath: string, options?: MemoryOptions): Memory;
303
+ /**
304
+ * Extract structured reasoning memory from a conversation transcript.
305
+ *
306
+ * LLM-agnostic: you provide any function that takes a prompt string and returns the LLM's
307
+ * response string. FlowScript provides the extraction prompt and parses the result.
308
+ *
309
+ * @param transcript - The conversation text to analyze (any format: chat logs, meeting notes, etc.)
310
+ * @param options - Must include `extract`: an async function `(prompt: string) => Promise<string>`
311
+ * @returns A Memory populated with the extracted nodes, relationships, and states (flat graph, no parent-child nesting)
312
+ *
313
+ * Note: The transcript is embedded in the extraction prompt with XML delimiters for basic injection
314
+ * mitigation, but this is not a structural guarantee. If processing untrusted user-submitted content,
315
+ * consider sanitizing the transcript before passing it. Invalid extraction results (bad types,
316
+ * dangling references) are filtered with a console.warn diagnostic — not thrown.
317
+ *
318
+ * @example
319
+ * ```typescript
320
+ * const mem = await Memory.fromTranscript(chatLog, {
321
+ * extract: async (prompt) => {
322
+ * const res = await openai.chat.completions.create({
323
+ * model: 'gpt-4o',
324
+ * messages: [{ role: 'user', content: prompt }],
325
+ * response_format: { type: 'json_object' }
326
+ * });
327
+ * return res.choices[0].message.content!;
328
+ * }
329
+ * });
330
+ * ```
331
+ */
332
+ static fromTranscript(transcript: string, options: FromTranscriptOptions): Promise<Memory>;
333
+ /** @internal Build the extraction prompt for the LLM */
334
+ static _buildExtractionPrompt(transcript: string): string;
335
+ /** @internal Parse and validate the LLM's extraction response */
336
+ static _parseExtractionResponse(response: string): TranscriptExtraction;
337
+ /** @internal Build a Memory instance from validated extraction data */
338
+ static _buildFromExtraction(extraction: TranscriptExtraction, memoryOptions?: MemoryOptions): Memory;
339
+ /**
340
+ * Read the audit log for a memory file. Returns all audit entries (pruned nodes, relationships, states).
341
+ * The audit log is an append-only .jsonl file created automatically when prune() is called.
342
+ *
343
+ * @param auditPath - Path to the .audit.jsonl file. If a .json memory path is passed, derives the audit path.
344
+ * @returns Array of AuditEntry objects, oldest first
345
+ */
346
+ static readAuditLog(auditPath: string): AuditEntry[];
347
+ /** Create a statement node */
348
+ statement(content: string): NodeRef;
349
+ /** Create a thought node */
350
+ thought(content: string): NodeRef;
351
+ /** Create a question node */
352
+ question(content: string): NodeRef;
353
+ /** Create an action node */
354
+ action(content: string): NodeRef;
355
+ /** Create an insight node */
356
+ insight(content: string): NodeRef;
357
+ /** Create a completion node */
358
+ completion(content: string): NodeRef;
359
+ /** Create a block node (structural container) */
360
+ block(content: string): NodeRef;
361
+ /**
362
+ * Create an alternative node linked to a question.
363
+ * Automatically creates the alternative relationship and adds as child.
364
+ */
365
+ alternative(question: NodeRef | string, content: string): NodeRef;
366
+ /** Create a tension between two nodes */
367
+ tension(a: NodeRef | string, b: NodeRef | string, axis: string): void;
368
+ /** Create a typed relationship between two nodes */
369
+ relate(source: NodeRef | string, target: NodeRef | string, type: RelationType, options?: {
370
+ axis?: string;
371
+ feedback?: boolean;
372
+ }): void;
373
+ /** Access the query engine. Lazy-refreshes when IR has changed. */
374
+ get query(): {
375
+ why: FlowScriptQueryEngine['why'];
376
+ whatIf: FlowScriptQueryEngine['whatIf'];
377
+ tensions: FlowScriptQueryEngine['tensions'];
378
+ blocked: FlowScriptQueryEngine['blocked'];
379
+ alternatives: FlowScriptQueryEngine['alternatives'];
380
+ };
381
+ /** Get the raw IR graph */
382
+ toIR(): IR;
383
+ /**
384
+ * Serialize to FlowScript .fs text, optionally within a token budget.
385
+ *
386
+ * Without maxTokens: serializes the full graph.
387
+ * With maxTokens: intelligently selects nodes by strategy to fit within budget.
388
+ * Preserved tiers (default: proven + foundation) are always included.
389
+ */
390
+ toFlowScript(options?: BudgetedSerializeOptions): string;
391
+ /**
392
+ * Get the lossless JSON representation (object form).
393
+ * Includes IR + temporal metadata + snapshots + config.
394
+ * Use toJSONString() for a serialized string.
395
+ *
396
+ * Note: This is intentionally NOT named to conflict with JSON.stringify's
397
+ * automatic toJSON() call. Use toJSONString() for string output.
398
+ */
399
+ toMemoryJSON(): MemoryJSON;
400
+ /** Serialize to JSON string (lossless, includes temporal + snapshots) */
401
+ toJSONString(): string;
402
+ /** Save to file (.fs or .json, detected by extension). Creates parent directories if needed.
403
+ * Note: not atomic. For multi-agent scenarios (v1.2+), use temp+rename pattern. */
404
+ save(filePath?: string): void;
405
+ /**
406
+ * Auto-generate function calling tool definitions from the Memory API.
407
+ *
408
+ * Returns tool schemas (OpenAI function calling format) paired with
409
+ * handler functions. Compatible with Claude, GPT, LangChain, AutoGen,
410
+ * CrewAI, and any framework using standard function calling.
411
+ *
412
+ * Categories:
413
+ * - 'core': add_node, add_alternative, relate_nodes, set_state
414
+ * - 'query': query_why, query_what_if, query_tensions, query_blocked, query_alternatives
415
+ * - 'memory': get_memory, search_nodes
416
+ */
417
+ asTools(options?: AsToolsOptions): MemoryTool[];
418
+ /** Get a raw Node by ID */
419
+ getNode(id: string): Node | undefined;
420
+ /** Create a NodeRef for an existing node ID */
421
+ ref(id: string): NodeRef;
422
+ /** Find nodes matching a predicate */
423
+ findNodes(predicate: (node: Node) => boolean): NodeRef[];
424
+ /** All nodes as NodeRefs */
425
+ get nodes(): NodeRef[];
426
+ /** Number of nodes in the graph */
427
+ get size(): number;
428
+ /** The file path associated with this Memory (set by load/loadOrCreate/save) */
429
+ get filePath(): string | null;
430
+ /** The audit log path derived from filePath (e.g., memory.json → memory.audit.jsonl). Null if no filePath. */
431
+ get auditPath(): string | null;
432
+ /** @internal Derive audit path from any file path. Handles extensionless files. */
433
+ static _deriveAuditPath(filePath: string): string;
434
+ /** Get temporal metadata for a node */
435
+ getTemporalMeta(id: string): TemporalMeta | undefined;
436
+ /**
437
+ * Garden report: classify nodes by activity level.
438
+ * Growing = touched recently, has momentum.
439
+ * Resting = a few days quiet, might need revisiting.
440
+ * Dormant = untouched long enough to consider archiving.
441
+ */
442
+ garden(): GardenReport;
443
+ /**
444
+ * Prune dormant nodes: remove them from the active graph.
445
+ * Automatically appends pruned data to the audit log (.audit.jsonl) if a filePath is set.
446
+ * Returns the pruned nodes for archival.
447
+ */
448
+ prune(): PruneReport;
449
+ /** Create an immutable snapshot of current state. Returns snapshot ID. */
450
+ snapshot(reason?: string): string;
451
+ /** List all snapshots (metadata only) */
452
+ snapshots(): SnapshotInfo[];
453
+ /** Restore to a previous snapshot (time-travel) */
454
+ restore(snapshotId: string): void;
455
+ /** Register a graduation event handler */
456
+ on(event: 'graduation-candidate', handler: GraduationHandler): void;
457
+ /** Register a generic event handler */
458
+ on(event: string, handler: EventHandler): void;
459
+ /** Remove an event handler */
460
+ off(event: string, handler: EventHandler | GraduationHandler): void;
461
+ /** @internal Add a node to the graph. Handles dedup + temporal tracking. */
462
+ _addNode(type: NodeType, content: string, parentId?: string): NodeRef;
463
+ /** @internal Add a relationship to the graph */
464
+ _addRelationship(sourceId: string, targetId: string, type: RelationType, options?: {
465
+ axis?: string;
466
+ feedback?: boolean;
467
+ }): void;
468
+ /** @internal Add a state to a node */
469
+ _addState(nodeId: string, type: StateType, fields: Record<string, string>): void;
470
+ /**
471
+ * Remove states from a node. If type is specified, only removes states of that type.
472
+ * Without type, removes ALL states from the node.
473
+ * Returns the number of states removed.
474
+ */
475
+ removeStates(nodeId: string, type?: StateType): number;
476
+ /** @internal Add a modifier to a node */
477
+ _addModifier(nodeId: string, modifier: string): void;
478
+ /**
479
+ * Estimate token cost for a single node's serialized output.
480
+ * Rough but fast — accounts for type prefix, modifiers, states, and content.
481
+ */
482
+ private _estimateNodeTokenCost;
483
+ /**
484
+ * Sort node IDs in-place by the given strategy.
485
+ */
486
+ private _sortByStrategy;
487
+ /**
488
+ * Build a pruned IR containing only the specified nodes and their
489
+ * inter-relationships and states.
490
+ */
491
+ private _buildPrunedIR;
492
+ /** Touch a node: update lastTouched, increment frequency, check graduation */
493
+ private _touchNode;
494
+ /** Add a child ID to a parent node's children array */
495
+ private _addChild;
496
+ /** Create provenance for a programmatically created entity */
497
+ private _createProvenance;
498
+ /** Get graduation threshold for a tier */
499
+ private _getGraduationThreshold;
500
+ /** Emit graduation-candidate event */
501
+ private _emitGraduation;
502
+ /** Get the next tier up from current */
503
+ private _nextTier;
504
+ }
505
+ export {};
506
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,EAAa,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EACV,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAC9C,KAAK,EAAE,SAAS,EACjB,MAAM,SAAS,CAAC;AAMjB,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE;QACN,OAAO,CAAC,EAAE,kBAAkB,CAAC;QAC7B,UAAU,CAAC,EAAE,kBAAkB,CAAC;QAChC,MAAM,CAAC,EAAE,kBAAkB,CAAC;QAC5B,UAAU,CAAC,EAAE,kBAAkB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