@inf-minds/kernel 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/condition-evaluator.d.ts +69 -0
  2. package/dist/condition-evaluator.d.ts.map +1 -0
  3. package/dist/condition-evaluator.js +120 -0
  4. package/dist/condition-evaluator.js.map +1 -0
  5. package/dist/graph-executor.d.ts +63 -0
  6. package/dist/graph-executor.d.ts.map +1 -0
  7. package/dist/graph-executor.js +245 -0
  8. package/dist/graph-executor.js.map +1 -0
  9. package/dist/index.d.ts +7 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +13 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/kernel.d.ts +45 -0
  14. package/dist/kernel.d.ts.map +1 -0
  15. package/dist/kernel.js +202 -0
  16. package/dist/kernel.js.map +1 -0
  17. package/dist/registries/index.d.ts +3 -0
  18. package/dist/registries/index.d.ts.map +1 -0
  19. package/dist/registries/index.js +5 -0
  20. package/dist/registries/index.js.map +1 -0
  21. package/dist/registries/mind-registry.d.ts +11 -0
  22. package/dist/registries/mind-registry.d.ts.map +1 -0
  23. package/dist/registries/mind-registry.js +31 -0
  24. package/dist/registries/mind-registry.js.map +1 -0
  25. package/dist/registries/mode-registry.d.ts +11 -0
  26. package/dist/registries/mode-registry.d.ts.map +1 -0
  27. package/dist/registries/mode-registry.js +31 -0
  28. package/dist/registries/mode-registry.js.map +1 -0
  29. package/dist/session.d.ts +123 -0
  30. package/dist/session.d.ts.map +1 -0
  31. package/dist/session.js +403 -0
  32. package/dist/session.js.map +1 -0
  33. package/dist/types.d.ts +288 -0
  34. package/dist/types.d.ts.map +1 -0
  35. package/dist/types.js +14 -0
  36. package/dist/types.js.map +1 -0
  37. package/package.json +37 -0
  38. package/src/condition-evaluator.ts +168 -0
  39. package/src/graph-executor.ts +315 -0
  40. package/src/index.ts +50 -0
  41. package/src/kernel.ts +242 -0
  42. package/src/registries/index.ts +5 -0
  43. package/src/registries/mind-registry.ts +38 -0
  44. package/src/registries/mode-registry.ts +38 -0
  45. package/src/session.ts +541 -0
  46. package/src/types.ts +280 -0
@@ -0,0 +1,403 @@
1
+ // ABOUTME: KernelSession implementation
2
+ // ABOUTME: Wraps a kernel-session job and manages graph execution
3
+ import { JOB_TYPE } from '@inf-minds/jobs';
4
+ import { SESSION_STATUS } from './types.js';
5
+ import { determineNextNodes, updateStateForNodeStart, updateStateForNodeComplete, updateStateForNodeFailure, updateStateForNodeSkipped, markGraphComplete, markGraphFailed, } from './graph-executor.js';
6
+ /**
7
+ * Implementation of KernelSession.
8
+ *
9
+ * Manages the lifecycle of a kernel session, including:
10
+ * - Graph execution state
11
+ * - Node scheduling
12
+ * - Artifact routing
13
+ * - Event emission
14
+ */
15
+ export class KernelSessionImpl {
16
+ _job;
17
+ _mode;
18
+ _modeName;
19
+ _jobManager;
20
+ _eventAppender;
21
+ _artifactManager;
22
+ _artifactRouter;
23
+ _mindRegistry;
24
+ _subscribers;
25
+ _currentGraphState;
26
+ constructor(options) {
27
+ this._job = options.job;
28
+ this._mode = options.mode;
29
+ this._modeName = options.modeName;
30
+ this._jobManager = options.jobManager;
31
+ this._eventAppender = options.eventAppender;
32
+ this._artifactManager = options.artifactManager;
33
+ this._artifactRouter = options.artifactRouter;
34
+ this._mindRegistry = options.mindRegistry;
35
+ this._subscribers = new Set();
36
+ this._currentGraphState = options.job.graphState ?? {
37
+ nodes: {},
38
+ activeNodes: [],
39
+ completedNodes: [],
40
+ failedNodes: [],
41
+ skippedNodes: [],
42
+ startedAt: new Date().toISOString(),
43
+ status: 'running',
44
+ };
45
+ }
46
+ get id() {
47
+ return this._job.id;
48
+ }
49
+ get mode() {
50
+ return this._modeName;
51
+ }
52
+ get status() {
53
+ // Map job status to session status
54
+ switch (this._job.status) {
55
+ case 'pending':
56
+ return SESSION_STATUS.PENDING;
57
+ case 'running':
58
+ return SESSION_STATUS.RUNNING;
59
+ case 'completed':
60
+ return SESSION_STATUS.COMPLETED;
61
+ case 'failed':
62
+ return SESSION_STATUS.FAILED;
63
+ case 'cancelled':
64
+ return SESSION_STATUS.CANCELLED;
65
+ default:
66
+ return SESSION_STATUS.PENDING;
67
+ }
68
+ }
69
+ get graphState() {
70
+ return this._currentGraphState;
71
+ }
72
+ get artifactBasePath() {
73
+ return this._job.artifactBasePath ?? `/sessions/${this._job.id}`;
74
+ }
75
+ get accountId() {
76
+ return this._job.accountId;
77
+ }
78
+ /**
79
+ * Get the coordination mode for this session.
80
+ * May be undefined if the session was restored from a job without the mode.
81
+ */
82
+ get coordinationMode() {
83
+ return this._mode;
84
+ }
85
+ /**
86
+ * Get the artifact router for this session.
87
+ */
88
+ get artifactRouter() {
89
+ return this._artifactRouter;
90
+ }
91
+ /**
92
+ * Get the mind registry for resolving mind configs.
93
+ */
94
+ get mindRegistryRef() {
95
+ return this._mindRegistry;
96
+ }
97
+ async pause() {
98
+ // Pause the session by updating the job
99
+ // Active nodes will complete but no new nodes will start
100
+ await this._emitEvent({ type: 'session_paused', timestamp: new Date() });
101
+ // In a full implementation, this would update the job status
102
+ // and prevent new node executions
103
+ throw new Error('pause() not yet implemented');
104
+ }
105
+ async resume() {
106
+ // Resume a paused session
107
+ await this._emitEvent({ type: 'session_resumed', timestamp: new Date() });
108
+ // In a full implementation, this would restart graph traversal
109
+ throw new Error('resume() not yet implemented');
110
+ }
111
+ async cancel() {
112
+ // Cancel the session
113
+ await this._jobManager.cancel(this._job.id);
114
+ await this._emitEvent({ type: 'session_cancelled', timestamp: new Date() });
115
+ }
116
+ subscribe(handler) {
117
+ this._subscribers.add(handler);
118
+ return () => {
119
+ this._subscribers.delete(handler);
120
+ };
121
+ }
122
+ async getArtifacts(path) {
123
+ // List artifacts for this session
124
+ const artifacts = await this._artifactManager.listBySession(this._job.id);
125
+ if (path) {
126
+ // Filter by path prefix
127
+ return artifacts.filter((a) => a.name.startsWith(path));
128
+ }
129
+ return artifacts;
130
+ }
131
+ getNodeOutput(nodeId) {
132
+ const nodeState = this.graphState.nodes[nodeId];
133
+ if (nodeState?.status === 'completed') {
134
+ return nodeState.output ?? null;
135
+ }
136
+ return null;
137
+ }
138
+ async waitForCompletion() {
139
+ // Poll for completion
140
+ // In a real implementation, this would use events or long polling
141
+ const maxAttempts = 1000;
142
+ const pollInterval = 100;
143
+ for (let i = 0; i < maxAttempts; i++) {
144
+ const job = await this._jobManager.get(this._job.id);
145
+ if (!job) {
146
+ throw new Error(`Session ${this._job.id} not found`);
147
+ }
148
+ if (job.status === 'completed') {
149
+ return job.output;
150
+ }
151
+ if (job.status === 'failed') {
152
+ throw new Error(`Session failed: ${job.error ?? 'Unknown error'}`);
153
+ }
154
+ if (job.status === 'cancelled') {
155
+ throw new Error('Session was cancelled');
156
+ }
157
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
158
+ }
159
+ throw new Error('Session timed out waiting for completion');
160
+ }
161
+ /**
162
+ * Emit a session event to all subscribers.
163
+ */
164
+ async _emitEvent(event) {
165
+ // Persist to event stream
166
+ await this._eventAppender.append({
167
+ jobId: this._job.id,
168
+ type: event.type,
169
+ payload: event,
170
+ });
171
+ // Notify subscribers
172
+ for (const handler of this._subscribers) {
173
+ try {
174
+ handler(event);
175
+ }
176
+ catch (error) {
177
+ console.error('Error in session event handler:', error);
178
+ }
179
+ }
180
+ }
181
+ /**
182
+ * Start the session by executing the entry node.
183
+ */
184
+ async start() {
185
+ if (!this._mode) {
186
+ throw new Error('Cannot start session without coordination mode');
187
+ }
188
+ // Emit session started event
189
+ await this._emitEvent({
190
+ type: 'session_started',
191
+ sessionId: this.id,
192
+ mode: this._modeName,
193
+ timestamp: new Date(),
194
+ });
195
+ // Determine first nodes to execute (entry node)
196
+ const nextNodes = determineNextNodes({
197
+ mode: this._mode,
198
+ graphState: this._currentGraphState,
199
+ completedNodeId: null,
200
+ completedOutput: null,
201
+ });
202
+ // Start each node
203
+ for (const nodeId of nextNodes.nodesToStart) {
204
+ await this._startNode(nodeId, this._getUserInput());
205
+ }
206
+ }
207
+ /**
208
+ * Handle completion of a node execution.
209
+ * Called by the coordinator when a mind-execution job completes.
210
+ */
211
+ async handleNodeComplete(nodeId, output, artifacts) {
212
+ if (!this._mode) {
213
+ throw new Error('Cannot handle node completion without coordination mode');
214
+ }
215
+ // Update graph state
216
+ this._currentGraphState = updateStateForNodeComplete(this._currentGraphState, nodeId, output);
217
+ // Route artifacts if present
218
+ if (artifacts && this._artifactRouter) {
219
+ const routingContext = {
220
+ sessionId: this.id,
221
+ nodeId,
222
+ mindId: this._getNodeMindType(nodeId),
223
+ graphState: this._currentGraphState,
224
+ accountId: this.accountId,
225
+ };
226
+ await this._artifactRouter.routeOutputArtifacts(artifacts.map((a) => ({ artifact: a.ref, hints: a.hints })), routingContext);
227
+ }
228
+ // Emit node completed event
229
+ await this._emitEvent({
230
+ type: 'node_completed',
231
+ nodeId,
232
+ output,
233
+ timestamp: new Date(),
234
+ });
235
+ // Determine next nodes
236
+ const nextNodes = determineNextNodes({
237
+ mode: this._mode,
238
+ graphState: this._currentGraphState,
239
+ completedNodeId: nodeId,
240
+ completedOutput: output,
241
+ });
242
+ // Handle skipped nodes
243
+ for (const skippedId of nextNodes.skippedNodes) {
244
+ this._currentGraphState = updateStateForNodeSkipped(this._currentGraphState, skippedId, 'Condition not met');
245
+ await this._emitEvent({
246
+ type: 'node_skipped',
247
+ nodeId: skippedId,
248
+ reason: 'Condition not met',
249
+ timestamp: new Date(),
250
+ });
251
+ }
252
+ // Check if session should complete
253
+ if (nextNodes.shouldComplete) {
254
+ await this._completeSession(nextNodes.finalOutput);
255
+ return;
256
+ }
257
+ // Start next nodes
258
+ for (const nextNodeId of nextNodes.nodesToStart) {
259
+ // Emit graph advanced event
260
+ await this._emitEvent({
261
+ type: 'graph_advanced',
262
+ fromNode: nodeId,
263
+ toNode: nextNodeId,
264
+ timestamp: new Date(),
265
+ });
266
+ await this._startNode(nextNodeId, output);
267
+ }
268
+ }
269
+ /**
270
+ * Handle failure of a node execution.
271
+ * Called by the coordinator when a mind-execution job fails.
272
+ */
273
+ async handleNodeFailure(nodeId, error) {
274
+ // Update graph state
275
+ this._currentGraphState = updateStateForNodeFailure(this._currentGraphState, nodeId, error);
276
+ // Emit node failed event
277
+ await this._emitEvent({
278
+ type: 'node_failed',
279
+ nodeId,
280
+ error,
281
+ timestamp: new Date(),
282
+ });
283
+ // For now, fail the entire session on any node failure
284
+ // A more sophisticated implementation could support error handling modes
285
+ await this._failSession(error);
286
+ }
287
+ /**
288
+ * Start execution of a specific node.
289
+ */
290
+ async _startNode(nodeId, input) {
291
+ if (!this._mode) {
292
+ throw new Error('Cannot start node without coordination mode');
293
+ }
294
+ const node = this._mode.graph.nodes[nodeId];
295
+ if (!node) {
296
+ throw new Error(`Node ${nodeId} not found in graph`);
297
+ }
298
+ // Resolve mind config
299
+ const mindConfig = this._resolveMindConfig(node);
300
+ // Get input artifacts if router is available
301
+ let inputArtifacts = [];
302
+ if (this._artifactRouter) {
303
+ const routingContext = {
304
+ sessionId: this.id,
305
+ nodeId,
306
+ mindId: node.mind.mindType ?? nodeId,
307
+ graphState: this._currentGraphState,
308
+ accountId: this.accountId,
309
+ };
310
+ inputArtifacts = await this._artifactRouter.resolveInputArtifacts(routingContext);
311
+ }
312
+ // Create child job for mind execution
313
+ const childJob = await this._jobManager.create({
314
+ type: JOB_TYPE.MIND_EXECUTION,
315
+ accountId: this.accountId,
316
+ parentJobId: this.id,
317
+ nodeId,
318
+ input: {
319
+ nodeId,
320
+ mindConfig,
321
+ task: input,
322
+ artifacts: inputArtifacts,
323
+ iteration: this._getNodeIteration(nodeId),
324
+ },
325
+ });
326
+ // Update graph state
327
+ this._currentGraphState = updateStateForNodeStart(this._currentGraphState, nodeId, childJob.id);
328
+ // Emit node started event
329
+ await this._emitEvent({
330
+ type: 'node_started',
331
+ nodeId,
332
+ mindType: node.mind.mindType ?? nodeId,
333
+ jobId: childJob.id,
334
+ timestamp: new Date(),
335
+ });
336
+ }
337
+ /**
338
+ * Complete the session with final output.
339
+ */
340
+ async _completeSession(output) {
341
+ this._currentGraphState = markGraphComplete(this._currentGraphState);
342
+ await this._jobManager.complete(this.id, output);
343
+ await this._emitEvent({
344
+ type: 'session_completed',
345
+ output,
346
+ timestamp: new Date(),
347
+ });
348
+ }
349
+ /**
350
+ * Fail the session with error.
351
+ */
352
+ async _failSession(error) {
353
+ this._currentGraphState = markGraphFailed(this._currentGraphState);
354
+ await this._jobManager.fail(this.id, error);
355
+ await this._emitEvent({
356
+ type: 'session_failed',
357
+ error,
358
+ timestamp: new Date(),
359
+ });
360
+ }
361
+ /**
362
+ * Get the user input from the job.
363
+ */
364
+ _getUserInput() {
365
+ const jobInput = this._job.input;
366
+ return jobInput?.userInput;
367
+ }
368
+ /**
369
+ * Get the mind type for a node.
370
+ */
371
+ _getNodeMindType(nodeId) {
372
+ if (!this._mode) {
373
+ return nodeId;
374
+ }
375
+ const node = this._mode.graph.nodes[nodeId];
376
+ return node?.mind.mindType ?? nodeId;
377
+ }
378
+ /**
379
+ * Get the current iteration count for a node.
380
+ */
381
+ _getNodeIteration(nodeId) {
382
+ // Count how many times this node has been started
383
+ const completedCount = this._currentGraphState.completedNodes.filter((id) => id === nodeId).length;
384
+ return completedCount + 1;
385
+ }
386
+ /**
387
+ * Resolve mind config from a node's mind reference.
388
+ */
389
+ _resolveMindConfig(node) {
390
+ if (node.mind.type === 'inline') {
391
+ return node.mind.config;
392
+ }
393
+ if (node.mind.type === 'registered' && node.mind.mindType) {
394
+ const config = this._mindRegistry.get(node.mind.mindType);
395
+ if (!config) {
396
+ throw new Error(`Mind type '${node.mind.mindType}' not found in registry`);
397
+ }
398
+ return config;
399
+ }
400
+ throw new Error(`Invalid mind reference type: ${node.mind.type}`);
401
+ }
402
+ }
403
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,kEAAkE;AAYlE,OAAO,E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