ai-database 2.0.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/LICENSE +21 -0
- package/README.md +667 -1
- package/dist/actions.d.ts +247 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +260 -0
- package/dist/actions.js.map +1 -0
- package/dist/ai-promise-db.d.ts +37 -2
- package/dist/ai-promise-db.d.ts.map +1 -1
- package/dist/ai-promise-db.js +530 -92
- package/dist/ai-promise-db.js.map +1 -1
- package/dist/constants.d.ts +16 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +16 -0
- package/dist/constants.js.map +1 -0
- package/dist/events.d.ts +153 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +154 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -2
- package/dist/index.js.map +1 -1
- package/dist/memory-provider.d.ts +145 -2
- package/dist/memory-provider.d.ts.map +1 -1
- package/dist/memory-provider.js +569 -13
- package/dist/memory-provider.js.map +1 -1
- package/dist/schema/cascade.d.ts +104 -0
- package/dist/schema/cascade.d.ts.map +1 -0
- package/dist/schema/cascade.js +547 -0
- package/dist/schema/cascade.js.map +1 -0
- package/dist/schema/dependency-graph.d.ts +133 -0
- package/dist/schema/dependency-graph.d.ts.map +1 -0
- package/dist/schema/dependency-graph.js +355 -0
- package/dist/schema/dependency-graph.js.map +1 -0
- package/dist/schema/generation-context.d.ts +202 -0
- package/dist/schema/generation-context.d.ts.map +1 -0
- package/dist/schema/generation-context.js +393 -0
- package/dist/schema/generation-context.js.map +1 -0
- package/dist/schema/index.d.ts +201 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +1221 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/parse.d.ts +225 -0
- package/dist/schema/parse.d.ts.map +1 -0
- package/dist/schema/parse.js +740 -0
- package/dist/schema/parse.js.map +1 -0
- package/dist/schema/provider.d.ts +177 -0
- package/dist/schema/provider.d.ts.map +1 -0
- package/dist/schema/provider.js +258 -0
- package/dist/schema/provider.js.map +1 -0
- package/dist/schema/resolve.d.ts +87 -0
- package/dist/schema/resolve.d.ts.map +1 -0
- package/dist/schema/resolve.js +549 -0
- package/dist/schema/resolve.js.map +1 -0
- package/dist/schema/semantic.d.ts +54 -0
- package/dist/schema/semantic.d.ts.map +1 -0
- package/dist/schema/semantic.js +335 -0
- package/dist/schema/semantic.js.map +1 -0
- package/dist/schema/types.d.ts +528 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/types.js +9 -0
- package/dist/schema/types.js.map +1 -0
- package/dist/schema/union-fallback.d.ts +219 -0
- package/dist/schema/union-fallback.d.ts.map +1 -0
- package/dist/schema/union-fallback.js +325 -0
- package/dist/schema/union-fallback.js.map +1 -0
- package/dist/schema/verb-derivation.d.ts +167 -0
- package/dist/schema/verb-derivation.d.ts.map +1 -0
- package/dist/schema/verb-derivation.js +281 -0
- package/dist/schema/verb-derivation.js.map +1 -0
- package/dist/schema.d.ts +25 -867
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +45 -1124
- package/dist/schema.js.map +1 -1
- package/dist/semantic.d.ts +175 -0
- package/dist/semantic.d.ts.map +1 -0
- package/dist/semantic.js +338 -0
- package/dist/semantic.js.map +1 -0
- package/dist/type-guards.d.ts +167 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/type-guards.js +247 -0
- package/dist/type-guards.js.map +1 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validation.d.ts +168 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +667 -0
- package/dist/validation.js.map +1 -0
- package/package.json +21 -12
- package/.turbo/turbo-build.log +0 -5
- package/TESTING.md +0 -410
- package/TEST_SUMMARY.md +0 -250
- package/TODO.md +0 -128
- package/src/ai-promise-db.ts +0 -1243
- package/src/authorization.ts +0 -1102
- package/src/durable-clickhouse.ts +0 -596
- package/src/durable-promise.ts +0 -582
- package/src/execution-queue.ts +0 -608
- package/src/index.test.ts +0 -868
- package/src/index.ts +0 -337
- package/src/linguistic.ts +0 -404
- package/src/memory-provider.test.ts +0 -1036
- package/src/memory-provider.ts +0 -1119
- package/src/schema.test.ts +0 -1254
- package/src/schema.ts +0 -2296
- package/src/tests.ts +0 -725
- package/src/types.ts +0 -1177
- package/test/README.md +0 -153
- package/test/edge-cases.test.ts +0 -646
- package/test/provider-resolution.test.ts +0 -402
- package/tsconfig.json +0 -9
- package/vitest.config.ts +0 -19
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GenerationContext - Manages state and context during cascade generation
|
|
3
|
+
*
|
|
4
|
+
* Provides context accumulation across cascading generations:
|
|
5
|
+
* - Parent stack tracking for nested entity context
|
|
6
|
+
* - Generated entities accumulation across a session
|
|
7
|
+
* - generatedByType index for efficient type-based lookup
|
|
8
|
+
* - Token counting for monitoring context size
|
|
9
|
+
* - Auto-compaction when exceeding token limits
|
|
10
|
+
* - Array generation context (previousInArray)
|
|
11
|
+
* - Relationship tracking between generated entities
|
|
12
|
+
* - Snapshot/branching for speculative generation
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Entity type representing a generated entity
|
|
18
|
+
*/
|
|
19
|
+
export interface Entity {
|
|
20
|
+
/** Unique identifier */
|
|
21
|
+
$id: string;
|
|
22
|
+
/** Entity type */
|
|
23
|
+
$type: string;
|
|
24
|
+
/** Additional data fields */
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Options for creating a GenerationContext
|
|
29
|
+
*/
|
|
30
|
+
export interface GenerationContextOptions {
|
|
31
|
+
/** Maximum tokens allowed in context (default: Infinity) */
|
|
32
|
+
maxContextTokens?: number;
|
|
33
|
+
/** Auto-compact when exceeding limit (default: false) */
|
|
34
|
+
autoCompact?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Snapshot of context state for restore/branching
|
|
38
|
+
*/
|
|
39
|
+
export interface ContextSnapshot {
|
|
40
|
+
/** Number of generated entities at snapshot time */
|
|
41
|
+
generatedCount: number;
|
|
42
|
+
/** Depth of parent stack at snapshot time */
|
|
43
|
+
parentDepth: number;
|
|
44
|
+
/** When the snapshot was created */
|
|
45
|
+
timestamp: Date;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Context for a specific field (used in array generation)
|
|
49
|
+
*/
|
|
50
|
+
export interface FieldContext {
|
|
51
|
+
/** Previously generated items in this array field */
|
|
52
|
+
previousInArray: Entity[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Options for building context string
|
|
56
|
+
*/
|
|
57
|
+
export interface BuildContextOptions {
|
|
58
|
+
/** Maximum tokens for the context string */
|
|
59
|
+
maxTokens?: number;
|
|
60
|
+
/** Types to prioritize in context */
|
|
61
|
+
relevantTypes?: string[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Error thrown when context exceeds token limit without auto-compact
|
|
65
|
+
*/
|
|
66
|
+
export declare class ContextOverflowError extends Error {
|
|
67
|
+
constructor(message: string);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Context for managing state during entity generation
|
|
71
|
+
*/
|
|
72
|
+
export declare class GenerationContext {
|
|
73
|
+
private generated;
|
|
74
|
+
private generatedByType;
|
|
75
|
+
private parentStack;
|
|
76
|
+
private relationships;
|
|
77
|
+
private generationOrder;
|
|
78
|
+
private maxContextTokens;
|
|
79
|
+
private autoCompact;
|
|
80
|
+
private arrayContexts;
|
|
81
|
+
constructor(options?: GenerationContextOptions);
|
|
82
|
+
/**
|
|
83
|
+
* Push a parent entity onto the stack
|
|
84
|
+
*/
|
|
85
|
+
pushParent(entity: Entity): void;
|
|
86
|
+
/**
|
|
87
|
+
* Pop the top parent from the stack
|
|
88
|
+
*/
|
|
89
|
+
popParent(): Entity | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Get parent at specific depth (0 = immediate parent)
|
|
92
|
+
*/
|
|
93
|
+
getParent(depth?: number): Entity | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Get the entire parent chain (nearest first)
|
|
96
|
+
*/
|
|
97
|
+
getParentChain(): Entity[];
|
|
98
|
+
/**
|
|
99
|
+
* Get the entire parent stack (oldest first)
|
|
100
|
+
*/
|
|
101
|
+
getParentStack(): Entity[];
|
|
102
|
+
/**
|
|
103
|
+
* Add a generated entity to the context
|
|
104
|
+
*/
|
|
105
|
+
addGenerated(entity: Entity): void;
|
|
106
|
+
/**
|
|
107
|
+
* Get entity by ID
|
|
108
|
+
*/
|
|
109
|
+
getById(id: string): Entity | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Get all entities of a specific type
|
|
112
|
+
*/
|
|
113
|
+
getByType(type: string): Entity[];
|
|
114
|
+
/**
|
|
115
|
+
* Get all generated entities
|
|
116
|
+
*/
|
|
117
|
+
getAllGenerated(): Entity[];
|
|
118
|
+
/**
|
|
119
|
+
* Get entities in generation order
|
|
120
|
+
*/
|
|
121
|
+
getGenerationOrder(): Entity[];
|
|
122
|
+
/**
|
|
123
|
+
* Start tracking an array field generation
|
|
124
|
+
*/
|
|
125
|
+
startArrayGeneration(fieldName: string): void;
|
|
126
|
+
/**
|
|
127
|
+
* Add an item to an array generation context
|
|
128
|
+
*/
|
|
129
|
+
addArrayItem(fieldName: string, entity: Entity): void;
|
|
130
|
+
/**
|
|
131
|
+
* Get previously generated items in an array field
|
|
132
|
+
*/
|
|
133
|
+
getPreviousInArray(fieldName: string): Entity[];
|
|
134
|
+
/**
|
|
135
|
+
* Get context for a specific field (includes previousInArray)
|
|
136
|
+
*/
|
|
137
|
+
getContextForField(fieldName: string): FieldContext;
|
|
138
|
+
/**
|
|
139
|
+
* End tracking an array field generation
|
|
140
|
+
*/
|
|
141
|
+
endArrayGeneration(fieldName: string): void;
|
|
142
|
+
/**
|
|
143
|
+
* Add a relationship between entities
|
|
144
|
+
*/
|
|
145
|
+
addRelationship(fromId: string, toId: string, verb: string): void;
|
|
146
|
+
/**
|
|
147
|
+
* Get relationships for an entity
|
|
148
|
+
*/
|
|
149
|
+
getRelationships(entityId: string): Array<{
|
|
150
|
+
to: string;
|
|
151
|
+
verb: string;
|
|
152
|
+
}>;
|
|
153
|
+
/**
|
|
154
|
+
* Estimate total tokens in context
|
|
155
|
+
*/
|
|
156
|
+
estimateTokens(): number;
|
|
157
|
+
/**
|
|
158
|
+
* Estimate tokens for a single entity
|
|
159
|
+
*/
|
|
160
|
+
estimateEntityTokens(entity: Entity): number;
|
|
161
|
+
/**
|
|
162
|
+
* Get remaining token budget
|
|
163
|
+
*/
|
|
164
|
+
getRemainingTokenBudget(): number;
|
|
165
|
+
/**
|
|
166
|
+
* Compact oldest entries to free up space
|
|
167
|
+
*/
|
|
168
|
+
private compactOldest;
|
|
169
|
+
/**
|
|
170
|
+
* Build context string for AI generation
|
|
171
|
+
*/
|
|
172
|
+
buildContextString(options?: BuildContextOptions): string;
|
|
173
|
+
/**
|
|
174
|
+
* Create a snapshot of current state
|
|
175
|
+
*/
|
|
176
|
+
createSnapshot(): ContextSnapshot;
|
|
177
|
+
/**
|
|
178
|
+
* Restore from a snapshot (clears additions after snapshot)
|
|
179
|
+
*/
|
|
180
|
+
restoreSnapshot(snapshot: ContextSnapshot): void;
|
|
181
|
+
/**
|
|
182
|
+
* Create a branch (copy) of this context
|
|
183
|
+
*/
|
|
184
|
+
branch(): GenerationContext;
|
|
185
|
+
/**
|
|
186
|
+
* Merge a branch back into this context
|
|
187
|
+
*/
|
|
188
|
+
merge(branch: GenerationContext): void;
|
|
189
|
+
/**
|
|
190
|
+
* Serialize context to JSON
|
|
191
|
+
*/
|
|
192
|
+
toJSON(): string;
|
|
193
|
+
/**
|
|
194
|
+
* Deserialize context from JSON
|
|
195
|
+
*/
|
|
196
|
+
static fromJSON(json: string, options?: GenerationContextOptions): GenerationContext;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Create a new GenerationContext with the given options
|
|
200
|
+
*/
|
|
201
|
+
export declare function createGenerationContext(options?: GenerationContextOptions): GenerationContext;
|
|
202
|
+
//# sourceMappingURL=generation-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation-context.d.ts","sourceRoot":"","sources":["../../src/schema/generation-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,6BAA6B;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,yDAAyD;IACzD,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,oDAAoD;IACpD,cAAc,EAAE,MAAM,CAAA;IACtB,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAA;IACnB,oCAAoC;IACpC,SAAS,EAAE,IAAI,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,qDAAqD;IACrD,eAAe,EAAE,MAAM,EAAE,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CACzB;AAMD;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAI5B;AAYD;;GA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eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAIjE;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAUvE;;OAEG;IACH,cAAc,IAAI,MAAM;IAYxB;;OAEG;IACH,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAI5C;;OAEG;IACH,uBAAuB,IAAI,MAAM;IAIjC;;OAEG;IACH,OAAO,CAAC,aAAa;IAqBrB;;OAEG;IACH,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM;IA0C7D;;OAEG;IACH,cAAc,IAAI,eAAe;IAQjC;;OAEG;IACH,eAAe,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAiBhD;;OAEG;IACH,MAAM,IAAI,iBAAiB;IA4B3B;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAqBtC;;OAEG;IACH,MAAM,IAAI,MAAM;IAShB;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,iBAAiB;CAoBrF;AAMD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,iBAAiB,CAE7F"}
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GenerationContext - Manages state and context during cascade generation
|
|
3
|
+
*
|
|
4
|
+
* Provides context accumulation across cascading generations:
|
|
5
|
+
* - Parent stack tracking for nested entity context
|
|
6
|
+
* - Generated entities accumulation across a session
|
|
7
|
+
* - generatedByType index for efficient type-based lookup
|
|
8
|
+
* - Token counting for monitoring context size
|
|
9
|
+
* - Auto-compaction when exceeding token limits
|
|
10
|
+
* - Array generation context (previousInArray)
|
|
11
|
+
* - Relationship tracking between generated entities
|
|
12
|
+
* - Snapshot/branching for speculative generation
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
// =============================================================================
|
|
17
|
+
// Errors
|
|
18
|
+
// =============================================================================
|
|
19
|
+
/**
|
|
20
|
+
* Error thrown when context exceeds token limit without auto-compact
|
|
21
|
+
*/
|
|
22
|
+
export class ContextOverflowError extends Error {
|
|
23
|
+
constructor(message) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = 'ContextOverflowError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// =============================================================================
|
|
29
|
+
// Constants
|
|
30
|
+
// =============================================================================
|
|
31
|
+
const CHARS_PER_TOKEN = 4;
|
|
32
|
+
// =============================================================================
|
|
33
|
+
// GenerationContext Class
|
|
34
|
+
// =============================================================================
|
|
35
|
+
/**
|
|
36
|
+
* Context for managing state during entity generation
|
|
37
|
+
*/
|
|
38
|
+
export class GenerationContext {
|
|
39
|
+
generated = new Map();
|
|
40
|
+
generatedByType = new Map();
|
|
41
|
+
parentStack = [];
|
|
42
|
+
relationships = [];
|
|
43
|
+
generationOrder = [];
|
|
44
|
+
maxContextTokens;
|
|
45
|
+
autoCompact;
|
|
46
|
+
// Array generation tracking
|
|
47
|
+
arrayContexts = new Map();
|
|
48
|
+
constructor(options = {}) {
|
|
49
|
+
this.maxContextTokens = options.maxContextTokens ?? Infinity;
|
|
50
|
+
this.autoCompact = options.autoCompact ?? false;
|
|
51
|
+
}
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// PARENT MANAGEMENT
|
|
54
|
+
// ============================================================================
|
|
55
|
+
/**
|
|
56
|
+
* Push a parent entity onto the stack
|
|
57
|
+
*/
|
|
58
|
+
pushParent(entity) {
|
|
59
|
+
this.parentStack.push(entity);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Pop the top parent from the stack
|
|
63
|
+
*/
|
|
64
|
+
popParent() {
|
|
65
|
+
return this.parentStack.pop();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get parent at specific depth (0 = immediate parent)
|
|
69
|
+
*/
|
|
70
|
+
getParent(depth = 0) {
|
|
71
|
+
const index = this.parentStack.length - 1 - depth;
|
|
72
|
+
return index >= 0 ? this.parentStack[index] : undefined;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the entire parent chain (nearest first)
|
|
76
|
+
*/
|
|
77
|
+
getParentChain() {
|
|
78
|
+
return [...this.parentStack].reverse();
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get the entire parent stack (oldest first)
|
|
82
|
+
*/
|
|
83
|
+
getParentStack() {
|
|
84
|
+
return [...this.parentStack];
|
|
85
|
+
}
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// GENERATED ENTITY MANAGEMENT
|
|
88
|
+
// ============================================================================
|
|
89
|
+
/**
|
|
90
|
+
* Add a generated entity to the context
|
|
91
|
+
*/
|
|
92
|
+
addGenerated(entity) {
|
|
93
|
+
// Check token limit before adding
|
|
94
|
+
if (this.maxContextTokens !== Infinity) {
|
|
95
|
+
const currentTokens = this.estimateTokens();
|
|
96
|
+
const entityTokens = this.estimateEntityTokens(entity);
|
|
97
|
+
if (currentTokens + entityTokens > this.maxContextTokens) {
|
|
98
|
+
if (this.autoCompact) {
|
|
99
|
+
this.compactOldest();
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
throw new ContextOverflowError(`Adding entity would exceed token limit (${currentTokens + entityTokens} > ${this.maxContextTokens})`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
this.generated.set(entity.$id, entity);
|
|
107
|
+
this.generationOrder.push(entity);
|
|
108
|
+
const byType = this.generatedByType.get(entity.$type) ?? [];
|
|
109
|
+
byType.push(entity);
|
|
110
|
+
this.generatedByType.set(entity.$type, byType);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get entity by ID
|
|
114
|
+
*/
|
|
115
|
+
getById(id) {
|
|
116
|
+
return this.generated.get(id);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get all entities of a specific type
|
|
120
|
+
*/
|
|
121
|
+
getByType(type) {
|
|
122
|
+
return this.generatedByType.get(type) ?? [];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get all generated entities
|
|
126
|
+
*/
|
|
127
|
+
getAllGenerated() {
|
|
128
|
+
return Array.from(this.generated.values());
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Get entities in generation order
|
|
132
|
+
*/
|
|
133
|
+
getGenerationOrder() {
|
|
134
|
+
return [...this.generationOrder];
|
|
135
|
+
}
|
|
136
|
+
// ============================================================================
|
|
137
|
+
// ARRAY GENERATION CONTEXT
|
|
138
|
+
// ============================================================================
|
|
139
|
+
/**
|
|
140
|
+
* Start tracking an array field generation
|
|
141
|
+
*/
|
|
142
|
+
startArrayGeneration(fieldName) {
|
|
143
|
+
this.arrayContexts.set(fieldName, []);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Add an item to an array generation context
|
|
147
|
+
*/
|
|
148
|
+
addArrayItem(fieldName, entity) {
|
|
149
|
+
const items = this.arrayContexts.get(fieldName) ?? [];
|
|
150
|
+
items.push(entity);
|
|
151
|
+
this.arrayContexts.set(fieldName, items);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get previously generated items in an array field
|
|
155
|
+
*/
|
|
156
|
+
getPreviousInArray(fieldName) {
|
|
157
|
+
return this.arrayContexts.get(fieldName) ?? [];
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Get context for a specific field (includes previousInArray)
|
|
161
|
+
*/
|
|
162
|
+
getContextForField(fieldName) {
|
|
163
|
+
return {
|
|
164
|
+
previousInArray: this.getPreviousInArray(fieldName),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* End tracking an array field generation
|
|
169
|
+
*/
|
|
170
|
+
endArrayGeneration(fieldName) {
|
|
171
|
+
this.arrayContexts.delete(fieldName);
|
|
172
|
+
}
|
|
173
|
+
// ============================================================================
|
|
174
|
+
// RELATIONSHIP MANAGEMENT
|
|
175
|
+
// ============================================================================
|
|
176
|
+
/**
|
|
177
|
+
* Add a relationship between entities
|
|
178
|
+
*/
|
|
179
|
+
addRelationship(fromId, toId, verb) {
|
|
180
|
+
this.relationships.push({ from: fromId, to: toId, verb });
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get relationships for an entity
|
|
184
|
+
*/
|
|
185
|
+
getRelationships(entityId) {
|
|
186
|
+
return this.relationships
|
|
187
|
+
.filter((r) => r.from === entityId)
|
|
188
|
+
.map((r) => ({ to: r.to, verb: r.verb }));
|
|
189
|
+
}
|
|
190
|
+
// ============================================================================
|
|
191
|
+
// TOKEN MANAGEMENT
|
|
192
|
+
// ============================================================================
|
|
193
|
+
/**
|
|
194
|
+
* Estimate total tokens in context
|
|
195
|
+
*/
|
|
196
|
+
estimateTokens() {
|
|
197
|
+
let chars = 0;
|
|
198
|
+
const entities = Array.from(this.generated.values());
|
|
199
|
+
for (const entity of entities) {
|
|
200
|
+
chars += JSON.stringify(entity).length;
|
|
201
|
+
}
|
|
202
|
+
for (const parent of this.parentStack) {
|
|
203
|
+
chars += JSON.stringify(parent).length;
|
|
204
|
+
}
|
|
205
|
+
return Math.ceil(chars / CHARS_PER_TOKEN);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Estimate tokens for a single entity
|
|
209
|
+
*/
|
|
210
|
+
estimateEntityTokens(entity) {
|
|
211
|
+
return Math.ceil(JSON.stringify(entity).length / CHARS_PER_TOKEN);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Get remaining token budget
|
|
215
|
+
*/
|
|
216
|
+
getRemainingTokenBudget() {
|
|
217
|
+
return Math.max(0, this.maxContextTokens - this.estimateTokens());
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Compact oldest entries to free up space
|
|
221
|
+
*/
|
|
222
|
+
compactOldest() {
|
|
223
|
+
// Remove oldest entries until we have room (target 50% of max)
|
|
224
|
+
const targetTokens = Math.floor(this.maxContextTokens * 0.5);
|
|
225
|
+
while (this.estimateTokens() > targetTokens && this.generationOrder.length > 0) {
|
|
226
|
+
const oldest = this.generationOrder.shift();
|
|
227
|
+
if (oldest) {
|
|
228
|
+
this.generated.delete(oldest.$id);
|
|
229
|
+
const byType = this.generatedByType.get(oldest.$type);
|
|
230
|
+
if (byType) {
|
|
231
|
+
const idx = byType.findIndex((e) => e.$id === oldest.$id);
|
|
232
|
+
if (idx !== -1)
|
|
233
|
+
byType.splice(idx, 1);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// ============================================================================
|
|
239
|
+
// CONTEXT BUILDING
|
|
240
|
+
// ============================================================================
|
|
241
|
+
/**
|
|
242
|
+
* Build context string for AI generation
|
|
243
|
+
*/
|
|
244
|
+
buildContextString(options = {}) {
|
|
245
|
+
const parts = [];
|
|
246
|
+
// 1. Parent context
|
|
247
|
+
if (this.parentStack.length > 0) {
|
|
248
|
+
const parentInfo = this.parentStack
|
|
249
|
+
.map((p) => `${p.$type}: ${JSON.stringify(p)}`)
|
|
250
|
+
.join('\n');
|
|
251
|
+
parts.push(`parent entities:\n${parentInfo}`);
|
|
252
|
+
}
|
|
253
|
+
// 2. Previously generated entities (prioritize relevant types)
|
|
254
|
+
let entities = this.getAllGenerated();
|
|
255
|
+
if (options.relevantTypes && options.relevantTypes.length > 0) {
|
|
256
|
+
const relevant = entities.filter((e) => options.relevantTypes.includes(e.$type));
|
|
257
|
+
const other = entities.filter((e) => !options.relevantTypes.includes(e.$type));
|
|
258
|
+
entities = [...relevant, ...other];
|
|
259
|
+
}
|
|
260
|
+
if (entities.length > 0) {
|
|
261
|
+
const entitiesJson = JSON.stringify(entities);
|
|
262
|
+
parts.push(`Previously generated:\n${entitiesJson}`);
|
|
263
|
+
}
|
|
264
|
+
let result = parts.join('\n\n');
|
|
265
|
+
// Truncate if needed
|
|
266
|
+
if (options.maxTokens) {
|
|
267
|
+
const maxChars = options.maxTokens * CHARS_PER_TOKEN;
|
|
268
|
+
if (result.length > maxChars) {
|
|
269
|
+
result = result.slice(0, maxChars - 3) + '...';
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
// ============================================================================
|
|
275
|
+
// SNAPSHOTS AND BRANCHING
|
|
276
|
+
// ============================================================================
|
|
277
|
+
/**
|
|
278
|
+
* Create a snapshot of current state
|
|
279
|
+
*/
|
|
280
|
+
createSnapshot() {
|
|
281
|
+
return {
|
|
282
|
+
generatedCount: this.generated.size,
|
|
283
|
+
parentDepth: this.parentStack.length,
|
|
284
|
+
timestamp: new Date(),
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Restore from a snapshot (clears additions after snapshot)
|
|
289
|
+
*/
|
|
290
|
+
restoreSnapshot(snapshot) {
|
|
291
|
+
// Trim generated to match snapshot count
|
|
292
|
+
while (this.generated.size > snapshot.generatedCount) {
|
|
293
|
+
const lastEntity = this.generationOrder.pop();
|
|
294
|
+
if (lastEntity) {
|
|
295
|
+
this.generated.delete(lastEntity.$id);
|
|
296
|
+
const byType = this.generatedByType.get(lastEntity.$type);
|
|
297
|
+
if (byType)
|
|
298
|
+
byType.pop();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// Trim parent stack
|
|
302
|
+
while (this.parentStack.length > snapshot.parentDepth) {
|
|
303
|
+
this.parentStack.pop();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Create a branch (copy) of this context
|
|
308
|
+
*/
|
|
309
|
+
branch() {
|
|
310
|
+
const branched = new GenerationContext({
|
|
311
|
+
maxContextTokens: this.maxContextTokens,
|
|
312
|
+
autoCompact: this.autoCompact,
|
|
313
|
+
});
|
|
314
|
+
// Copy state
|
|
315
|
+
const generatedEntries = Array.from(this.generated.entries());
|
|
316
|
+
for (const [id, entity] of generatedEntries) {
|
|
317
|
+
branched.generated.set(id, { ...entity });
|
|
318
|
+
}
|
|
319
|
+
const byTypeEntries = Array.from(this.generatedByType.entries());
|
|
320
|
+
for (const [type, entities] of byTypeEntries) {
|
|
321
|
+
branched.generatedByType.set(type, [...entities]);
|
|
322
|
+
}
|
|
323
|
+
branched.parentStack = [...this.parentStack];
|
|
324
|
+
branched.generationOrder = [...this.generationOrder];
|
|
325
|
+
branched.relationships = [...this.relationships];
|
|
326
|
+
// Copy array contexts
|
|
327
|
+
const arrayContextEntries = Array.from(this.arrayContexts.entries());
|
|
328
|
+
for (const [field, items] of arrayContextEntries) {
|
|
329
|
+
branched.arrayContexts.set(field, [...items]);
|
|
330
|
+
}
|
|
331
|
+
return branched;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Merge a branch back into this context
|
|
335
|
+
*/
|
|
336
|
+
merge(branch) {
|
|
337
|
+
const branchEntities = Array.from(branch.generated.values());
|
|
338
|
+
for (const entity of branchEntities) {
|
|
339
|
+
if (!this.generated.has(entity.$id)) {
|
|
340
|
+
this.addGenerated(entity);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
for (const rel of branch.relationships) {
|
|
344
|
+
const exists = this.relationships.some((r) => r.from === rel.from && r.to === rel.to && r.verb === rel.verb);
|
|
345
|
+
if (!exists) {
|
|
346
|
+
this.relationships.push(rel);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
// ============================================================================
|
|
351
|
+
// SERIALIZATION
|
|
352
|
+
// ============================================================================
|
|
353
|
+
/**
|
|
354
|
+
* Serialize context to JSON
|
|
355
|
+
*/
|
|
356
|
+
toJSON() {
|
|
357
|
+
return JSON.stringify({
|
|
358
|
+
generated: Array.from(this.generated.values()),
|
|
359
|
+
parents: this.parentStack,
|
|
360
|
+
relationships: this.relationships,
|
|
361
|
+
generationOrder: this.generationOrder.map((e) => e.$id),
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Deserialize context from JSON
|
|
366
|
+
*/
|
|
367
|
+
static fromJSON(json, options) {
|
|
368
|
+
const data = JSON.parse(json);
|
|
369
|
+
const context = new GenerationContext(options);
|
|
370
|
+
for (const entity of data.generated) {
|
|
371
|
+
context.generated.set(entity.$id, entity);
|
|
372
|
+
context.generationOrder.push(entity);
|
|
373
|
+
const byType = context.generatedByType.get(entity.$type) ?? [];
|
|
374
|
+
byType.push(entity);
|
|
375
|
+
context.generatedByType.set(entity.$type, byType);
|
|
376
|
+
}
|
|
377
|
+
for (const parent of data.parents) {
|
|
378
|
+
context.pushParent(parent);
|
|
379
|
+
}
|
|
380
|
+
context.relationships = data.relationships ?? [];
|
|
381
|
+
return context;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
// =============================================================================
|
|
385
|
+
// Factory Function
|
|
386
|
+
// =============================================================================
|
|
387
|
+
/**
|
|
388
|
+
* Create a new GenerationContext with the given options
|
|
389
|
+
*/
|
|
390
|
+
export function createGenerationContext(options) {
|
|
391
|
+
return new GenerationContext(options);
|
|
392
|
+
}
|
|
393
|
+
//# sourceMappingURL=generation-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation-context.js","sourceRoot":"","sources":["../../src/schema/generation-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA0DH,gFAAgF;AAChF,SAAS;AACT,gFAAgF;AAEhF;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAA;IACpC,CAAC;CACF;AAED,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,MAAM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