@kb-labs/core-platform 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 (56) hide show
  1. package/README.md +108 -0
  2. package/dist/adapters/index.cjs +26 -0
  3. package/dist/adapters/index.cjs.map +1 -0
  4. package/dist/adapters/index.d.cts +125 -0
  5. package/dist/adapters/index.d.ts +125 -0
  6. package/dist/adapters/index.js +21 -0
  7. package/dist/adapters/index.js.map +1 -0
  8. package/dist/artifacts-BUghvkUU.d.cts +273 -0
  9. package/dist/artifacts-Bd-1UVTw.d.ts +273 -0
  10. package/dist/artifacts-DrVnkLzu.d.cts +1374 -0
  11. package/dist/artifacts-DrVnkLzu.d.ts +1374 -0
  12. package/dist/core/index.cjs +4 -0
  13. package/dist/core/index.cjs.map +1 -0
  14. package/dist/core/index.d.cts +2 -0
  15. package/dist/core/index.d.ts +2 -0
  16. package/dist/core/index.js +3 -0
  17. package/dist/core/index.js.map +1 -0
  18. package/dist/database-DGV6a1nj.d.cts +427 -0
  19. package/dist/database-DGV6a1nj.d.ts +427 -0
  20. package/dist/index.cjs +1405 -0
  21. package/dist/index.cjs.map +1 -0
  22. package/dist/index.d.cts +579 -0
  23. package/dist/index.d.ts +579 -0
  24. package/dist/index.js +1381 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/log-reader-BVohbSMB.d.cts +314 -0
  27. package/dist/log-reader-uOHBLBax.d.ts +314 -0
  28. package/dist/noop/adapters/index.cjs +656 -0
  29. package/dist/noop/adapters/index.cjs.map +1 -0
  30. package/dist/noop/adapters/index.d.cts +71 -0
  31. package/dist/noop/adapters/index.d.ts +71 -0
  32. package/dist/noop/adapters/index.js +637 -0
  33. package/dist/noop/adapters/index.js.map +1 -0
  34. package/dist/noop/core/index.cjs +217 -0
  35. package/dist/noop/core/index.cjs.map +1 -0
  36. package/dist/noop/core/index.d.cts +94 -0
  37. package/dist/noop/core/index.d.ts +94 -0
  38. package/dist/noop/core/index.js +212 -0
  39. package/dist/noop/core/index.js.map +1 -0
  40. package/dist/noop/index.cjs +806 -0
  41. package/dist/noop/index.cjs.map +1 -0
  42. package/dist/noop/index.d.cts +36 -0
  43. package/dist/noop/index.d.ts +36 -0
  44. package/dist/noop/index.js +787 -0
  45. package/dist/noop/index.js.map +1 -0
  46. package/dist/resources-DaufJFad.d.cts +419 -0
  47. package/dist/resources-DaufJFad.d.ts +419 -0
  48. package/dist/serializable/index.cjs +162 -0
  49. package/dist/serializable/index.cjs.map +1 -0
  50. package/dist/serializable/index.d.cts +352 -0
  51. package/dist/serializable/index.d.ts +352 -0
  52. package/dist/serializable/index.js +152 -0
  53. package/dist/serializable/index.js.map +1 -0
  54. package/dist/snapshot-provider--COac4P-.d.ts +923 -0
  55. package/dist/snapshot-provider-nE9wuc1C.d.cts +923 -0
  56. package/package.json +92 -0
@@ -0,0 +1,787 @@
1
+ // src/noop/adapters/analytics.ts
2
+ var NoOpAnalytics = class {
3
+ async track(_event, _properties) {
4
+ }
5
+ async identify(_userId, _traits) {
6
+ }
7
+ async flush() {
8
+ }
9
+ };
10
+
11
+ // src/noop/adapters/vector-store.ts
12
+ function cosineSimilarity(a, b) {
13
+ if (a.length !== b.length) {
14
+ return 0;
15
+ }
16
+ let dotProduct = 0;
17
+ let normA = 0;
18
+ let normB = 0;
19
+ for (let i = 0; i < a.length; i++) {
20
+ const aVal = a[i] ?? 0;
21
+ const bVal = b[i] ?? 0;
22
+ dotProduct += aVal * bVal;
23
+ normA += aVal * aVal;
24
+ normB += bVal * bVal;
25
+ }
26
+ const denominator = Math.sqrt(normA) * Math.sqrt(normB);
27
+ return denominator === 0 ? 0 : dotProduct / denominator;
28
+ }
29
+ function matchesFilter(record, filter) {
30
+ const value = record.metadata?.[filter.field];
31
+ switch (filter.operator) {
32
+ case "eq":
33
+ return value === filter.value;
34
+ case "ne":
35
+ return value !== filter.value;
36
+ case "gt":
37
+ return typeof value === "number" && value > filter.value;
38
+ case "gte":
39
+ return typeof value === "number" && value >= filter.value;
40
+ case "lt":
41
+ return typeof value === "number" && value < filter.value;
42
+ case "lte":
43
+ return typeof value === "number" && value <= filter.value;
44
+ case "in":
45
+ return Array.isArray(filter.value) && filter.value.includes(value);
46
+ case "nin":
47
+ return Array.isArray(filter.value) && !filter.value.includes(value);
48
+ default:
49
+ return true;
50
+ }
51
+ }
52
+ var MemoryVectorStore = class {
53
+ vectors = /* @__PURE__ */ new Map();
54
+ async search(query, limit, filter) {
55
+ const results = [];
56
+ for (const record of this.vectors.values()) {
57
+ if (filter && !matchesFilter(record, filter)) {
58
+ continue;
59
+ }
60
+ const score = cosineSimilarity(query, record.vector);
61
+ results.push({
62
+ id: record.id,
63
+ score,
64
+ metadata: record.metadata
65
+ });
66
+ }
67
+ return results.sort((a, b) => b.score - a.score).slice(0, limit);
68
+ }
69
+ async upsert(vectors) {
70
+ for (const vector of vectors) {
71
+ this.vectors.set(vector.id, vector);
72
+ }
73
+ }
74
+ async delete(ids) {
75
+ for (const id of ids) {
76
+ this.vectors.delete(id);
77
+ }
78
+ }
79
+ async count() {
80
+ return this.vectors.size;
81
+ }
82
+ };
83
+
84
+ // src/noop/adapters/llm.ts
85
+ var MockLLM = class {
86
+ getProtocolCapabilities() {
87
+ return {
88
+ cache: { supported: false },
89
+ stream: { supported: true }
90
+ };
91
+ }
92
+ async complete(prompt, options) {
93
+ const content = `[Mock LLM Response] Received prompt of ${prompt.length} characters.`;
94
+ return {
95
+ content,
96
+ usage: {
97
+ promptTokens: Math.ceil(prompt.length / 4),
98
+ completionTokens: Math.ceil(content.length / 4)
99
+ },
100
+ model: options?.model ?? "mock-model"
101
+ };
102
+ }
103
+ async *stream(prompt, options) {
104
+ const response = `[Mock LLM Stream] Received prompt of ${prompt.length} characters.`;
105
+ const words = response.split(" ");
106
+ for (const word of words) {
107
+ yield word + " ";
108
+ await new Promise((resolve) => {
109
+ setTimeout(resolve, 50);
110
+ });
111
+ }
112
+ }
113
+ };
114
+
115
+ // src/noop/adapters/embeddings.ts
116
+ var MockEmbeddings = class {
117
+ dimensions = 1536;
118
+ /**
119
+ * Simple hash function for deterministic embedding generation.
120
+ */
121
+ hash(text) {
122
+ let hash = 0;
123
+ for (let i = 0; i < text.length; i++) {
124
+ const char = text.charCodeAt(i);
125
+ hash = (hash << 5) - hash + char;
126
+ hash = hash & hash;
127
+ }
128
+ return hash;
129
+ }
130
+ /**
131
+ * Generate a deterministic vector based on text.
132
+ */
133
+ generateVector(text) {
134
+ const seed = this.hash(text);
135
+ const vector = [];
136
+ for (let i = 0; i < this.dimensions; i++) {
137
+ const value = Math.sin(seed * (i + 1)) * 0.5;
138
+ vector.push(value);
139
+ }
140
+ const magnitude = Math.sqrt(vector.reduce((sum, v) => sum + v * v, 0));
141
+ return vector.map((v) => v / magnitude);
142
+ }
143
+ async embed(text) {
144
+ return this.generateVector(text);
145
+ }
146
+ async embedBatch(texts) {
147
+ return texts.map((text) => this.generateVector(text));
148
+ }
149
+ /**
150
+ * Get the dimensions of the embeddings.
151
+ * This method is needed for IPC/Unix Socket transport to access the dimensions property.
152
+ */
153
+ async getDimensions() {
154
+ return this.dimensions;
155
+ }
156
+ };
157
+
158
+ // src/noop/adapters/cache.ts
159
+ var MemoryCache = class {
160
+ store = /* @__PURE__ */ new Map();
161
+ sortedSets = /* @__PURE__ */ new Map();
162
+ async get(key) {
163
+ const entry = this.store.get(key);
164
+ if (!entry) {
165
+ return null;
166
+ }
167
+ if (entry.expiresAt !== null && Date.now() > entry.expiresAt) {
168
+ this.store.delete(key);
169
+ return null;
170
+ }
171
+ return entry.value;
172
+ }
173
+ async set(key, value, ttl) {
174
+ const expiresAt = ttl ? Date.now() + ttl : null;
175
+ this.store.set(key, { value, expiresAt });
176
+ }
177
+ async delete(key) {
178
+ this.store.delete(key);
179
+ }
180
+ async clear(pattern) {
181
+ if (!pattern) {
182
+ this.store.clear();
183
+ return;
184
+ }
185
+ const regex = new RegExp("^" + pattern.replace(/\*/g, ".*") + "$");
186
+ for (const key of this.store.keys()) {
187
+ if (regex.test(key)) {
188
+ this.store.delete(key);
189
+ }
190
+ }
191
+ }
192
+ // ═══════════════════════════════════════════════════════════════════════
193
+ // Sorted Set Operations
194
+ // ═══════════════════════════════════════════════════════════════════════
195
+ async zadd(key, score, member) {
196
+ let set = this.sortedSets.get(key);
197
+ if (!set) {
198
+ set = [];
199
+ this.sortedSets.set(key, set);
200
+ }
201
+ const existingIndex = set.findIndex((m) => m.member === member);
202
+ if (existingIndex !== -1) {
203
+ set.splice(existingIndex, 1);
204
+ }
205
+ set.push({ score, member });
206
+ set.sort((a, b) => a.score - b.score);
207
+ }
208
+ async zrangebyscore(key, min, max) {
209
+ const set = this.sortedSets.get(key);
210
+ if (!set) {
211
+ return [];
212
+ }
213
+ return set.filter((m) => m.score >= min && m.score <= max).map((m) => m.member);
214
+ }
215
+ async zrem(key, member) {
216
+ const set = this.sortedSets.get(key);
217
+ if (!set) {
218
+ return;
219
+ }
220
+ const index = set.findIndex((m) => m.member === member);
221
+ if (index !== -1) {
222
+ set.splice(index, 1);
223
+ }
224
+ if (set.length === 0) {
225
+ this.sortedSets.delete(key);
226
+ }
227
+ }
228
+ // ═══════════════════════════════════════════════════════════════════════
229
+ // Atomic Operations
230
+ // ═══════════════════════════════════════════════════════════════════════
231
+ async setIfNotExists(key, value, ttl) {
232
+ if (this.store.has(key)) {
233
+ return false;
234
+ }
235
+ await this.set(key, value, ttl);
236
+ return true;
237
+ }
238
+ /**
239
+ * Get the current number of entries (for testing).
240
+ */
241
+ get size() {
242
+ return this.store.size;
243
+ }
244
+ };
245
+
246
+ // src/noop/adapters/config.ts
247
+ var NoOpConfig = class {
248
+ async getConfig(_productId, _profileId) {
249
+ return void 0;
250
+ }
251
+ async getRawConfig() {
252
+ return void 0;
253
+ }
254
+ };
255
+
256
+ // src/noop/adapters/storage.ts
257
+ var MemoryStorage = class {
258
+ store = /* @__PURE__ */ new Map();
259
+ async read(path) {
260
+ return this.store.get(path) ?? null;
261
+ }
262
+ async write(path, data) {
263
+ this.store.set(path, data);
264
+ }
265
+ async delete(path) {
266
+ this.store.delete(path);
267
+ }
268
+ async list(prefix) {
269
+ const results = [];
270
+ for (const key of this.store.keys()) {
271
+ if (key.startsWith(prefix)) {
272
+ results.push(key);
273
+ }
274
+ }
275
+ return results.sort();
276
+ }
277
+ async exists(path) {
278
+ return this.store.has(path);
279
+ }
280
+ /**
281
+ * Get file metadata.
282
+ * Optional method - implements IStorage.stat().
283
+ */
284
+ async stat(path) {
285
+ const data = this.store.get(path);
286
+ if (!data) {
287
+ return null;
288
+ }
289
+ return {
290
+ path,
291
+ size: data.byteLength,
292
+ lastModified: (/* @__PURE__ */ new Date()).toISOString(),
293
+ contentType: "application/octet-stream"
294
+ };
295
+ }
296
+ /**
297
+ * Copy file.
298
+ * Optional method - implements IStorage.copy().
299
+ */
300
+ async copy(sourcePath, destPath) {
301
+ const data = this.store.get(sourcePath);
302
+ if (!data) {
303
+ throw new Error(`Source file not found: ${sourcePath}`);
304
+ }
305
+ this.store.set(destPath, Buffer.from(data));
306
+ }
307
+ /**
308
+ * Move file.
309
+ * Optional method - implements IStorage.move().
310
+ */
311
+ async move(sourcePath, destPath) {
312
+ const data = this.store.get(sourcePath);
313
+ if (!data) {
314
+ throw new Error(`Source file not found: ${sourcePath}`);
315
+ }
316
+ this.store.set(destPath, data);
317
+ this.store.delete(sourcePath);
318
+ }
319
+ /**
320
+ * List files with metadata.
321
+ * Optional method - implements IStorage.listWithMetadata().
322
+ */
323
+ async listWithMetadata(prefix) {
324
+ const results = [];
325
+ for (const [path, data] of this.store.entries()) {
326
+ if (path.startsWith(prefix)) {
327
+ results.push({
328
+ path,
329
+ size: data.byteLength,
330
+ lastModified: (/* @__PURE__ */ new Date()).toISOString(),
331
+ contentType: "application/octet-stream"
332
+ });
333
+ }
334
+ }
335
+ return results.sort((a, b) => a.path.localeCompare(b.path));
336
+ }
337
+ /**
338
+ * Get the current number of stored files (for testing).
339
+ */
340
+ get size() {
341
+ return this.store.size;
342
+ }
343
+ /**
344
+ * Clear all storage (for testing).
345
+ */
346
+ clear() {
347
+ this.store.clear();
348
+ }
349
+ };
350
+
351
+ // src/noop/adapters/logger.ts
352
+ var ConsoleLogger = class _ConsoleLogger {
353
+ bindings;
354
+ level;
355
+ constructor(bindings = {}, level) {
356
+ this.bindings = bindings;
357
+ this.level = level ?? process.env.KB_LOG_LEVEL ?? "info";
358
+ }
359
+ shouldLog(messageLevel) {
360
+ const levels = {
361
+ silent: 0,
362
+ error: 1,
363
+ warn: 2,
364
+ info: 3,
365
+ debug: 4,
366
+ trace: 5
367
+ };
368
+ const currentLevel = levels[this.level] ?? 3;
369
+ const targetLevel = levels[messageLevel] ?? 3;
370
+ return targetLevel <= currentLevel;
371
+ }
372
+ formatMeta(meta) {
373
+ const combined = { ...this.bindings, ...meta };
374
+ if (Object.keys(combined).length === 0) {
375
+ return "";
376
+ }
377
+ return " " + JSON.stringify(combined);
378
+ }
379
+ info(message, meta) {
380
+ if (this.shouldLog("info")) {
381
+ console.log(`[INFO] ${message}${this.formatMeta(meta)}`);
382
+ }
383
+ }
384
+ warn(message, meta) {
385
+ if (this.shouldLog("warn")) {
386
+ console.warn(`[WARN] ${message}${this.formatMeta(meta)}`);
387
+ }
388
+ }
389
+ error(message, error, meta) {
390
+ if (this.shouldLog("error")) {
391
+ const errorMeta = error ? { ...meta, error: { message: error.message, stack: error.stack } } : meta;
392
+ console.error(`[ERROR] ${message}${this.formatMeta(errorMeta)}`);
393
+ }
394
+ }
395
+ fatal(message, error, meta) {
396
+ if (this.shouldLog("error")) {
397
+ const errorMeta = error ? { ...meta, error: { message: error.message, stack: error.stack } } : meta;
398
+ console.error(`[FATAL] ${message}${this.formatMeta(errorMeta)}`);
399
+ }
400
+ }
401
+ debug(message, meta) {
402
+ if (this.shouldLog("debug")) {
403
+ console.debug(`[DEBUG] ${message}${this.formatMeta(meta)}`);
404
+ }
405
+ }
406
+ trace(message, meta) {
407
+ if (this.shouldLog("trace")) {
408
+ console.debug(`[TRACE] ${message}${this.formatMeta(meta)}`);
409
+ }
410
+ }
411
+ child(bindings) {
412
+ return new _ConsoleLogger({ ...this.bindings, ...bindings }, this.level);
413
+ }
414
+ };
415
+ var NoOpLogger = class {
416
+ info(_message, _meta) {
417
+ }
418
+ warn(_message, _meta) {
419
+ }
420
+ error(_message, _error, _meta) {
421
+ }
422
+ fatal(_message, _error, _meta) {
423
+ }
424
+ debug(_message, _meta) {
425
+ }
426
+ trace(_message, _meta) {
427
+ }
428
+ child(_bindings) {
429
+ return this;
430
+ }
431
+ };
432
+
433
+ // src/noop/adapters/event-bus.ts
434
+ var MemoryEventBus = class {
435
+ handlers = /* @__PURE__ */ new Map();
436
+ async publish(topic, event) {
437
+ const topicHandlers = this.handlers.get(topic);
438
+ if (!topicHandlers) {
439
+ return;
440
+ }
441
+ const promises = Array.from(topicHandlers).map(
442
+ (handler) => handler(event).catch((err) => {
443
+ console.error(`[EventBus] Handler error for topic "${topic}":`, err);
444
+ })
445
+ );
446
+ await Promise.all(promises);
447
+ }
448
+ subscribe(topic, handler) {
449
+ let topicHandlers = this.handlers.get(topic);
450
+ if (!topicHandlers) {
451
+ topicHandlers = /* @__PURE__ */ new Set();
452
+ this.handlers.set(topic, topicHandlers);
453
+ }
454
+ topicHandlers.add(handler);
455
+ return () => {
456
+ topicHandlers.delete(handler);
457
+ if (topicHandlers.size === 0) {
458
+ this.handlers.delete(topic);
459
+ }
460
+ };
461
+ }
462
+ /**
463
+ * Get the number of topics with subscribers (for testing).
464
+ */
465
+ get topicCount() {
466
+ return this.handlers.size;
467
+ }
468
+ /**
469
+ * Get the total number of handlers across all topics (for testing).
470
+ */
471
+ get handlerCount() {
472
+ let count = 0;
473
+ for (const handlers of this.handlers.values()) {
474
+ count += handlers.size;
475
+ }
476
+ return count;
477
+ }
478
+ /**
479
+ * Clear all subscriptions (for testing).
480
+ */
481
+ clear() {
482
+ this.handlers.clear();
483
+ }
484
+ };
485
+ var NoOpEventBus = class {
486
+ async publish(_topic, _event) {
487
+ }
488
+ subscribe(_topic, _handler) {
489
+ return () => {
490
+ };
491
+ }
492
+ };
493
+
494
+ // src/noop/adapters/invoke.ts
495
+ var NoOpInvoke = class {
496
+ async call(_request) {
497
+ return {
498
+ success: false,
499
+ error: "Invoke not configured. Inter-plugin calls are not available."
500
+ };
501
+ }
502
+ async isAvailable(_pluginId, _command) {
503
+ return false;
504
+ }
505
+ };
506
+
507
+ // src/noop/adapters/artifacts.ts
508
+ var MemoryArtifacts = class {
509
+ store = /* @__PURE__ */ new Map();
510
+ async write(key, data, options) {
511
+ const now = /* @__PURE__ */ new Date();
512
+ const meta = {
513
+ key,
514
+ contentType: options?.contentType ?? "application/json",
515
+ size: JSON.stringify(data).length,
516
+ createdAt: this.store.get(key)?.meta.createdAt ?? now,
517
+ updatedAt: now,
518
+ metadata: options?.metadata
519
+ };
520
+ this.store.set(key, { data, meta });
521
+ }
522
+ async read(key) {
523
+ const entry = this.store.get(key);
524
+ return entry ? entry.data : null;
525
+ }
526
+ async exists(key) {
527
+ return this.store.has(key);
528
+ }
529
+ async delete(key) {
530
+ this.store.delete(key);
531
+ }
532
+ async list(prefix) {
533
+ const results = [];
534
+ for (const [key, entry] of this.store) {
535
+ if (key.startsWith(prefix)) {
536
+ results.push(entry.meta);
537
+ }
538
+ }
539
+ return results;
540
+ }
541
+ async getMeta(key) {
542
+ const entry = this.store.get(key);
543
+ return entry?.meta ?? null;
544
+ }
545
+ };
546
+
547
+ // src/noop/noop-platform.ts
548
+ var noOpLogReader = {
549
+ query: async () => ({ logs: [], total: 0, hasMore: false, source: "buffer" }),
550
+ getById: async () => null,
551
+ search: async () => ({ logs: [], total: 0, hasMore: false }),
552
+ subscribe: () => () => {
553
+ },
554
+ getStats: async () => ({}),
555
+ getCapabilities: () => ({
556
+ hasBuffer: false,
557
+ hasPersistence: false,
558
+ hasSearch: false,
559
+ hasStreaming: false
560
+ })
561
+ };
562
+ function createNoOpPlatform() {
563
+ return {
564
+ logger: new NoOpLogger(),
565
+ llm: new MockLLM(),
566
+ cache: new MemoryCache(),
567
+ embeddings: new MockEmbeddings(),
568
+ vectorStore: new MemoryVectorStore(),
569
+ storage: new MemoryStorage(),
570
+ analytics: new NoOpAnalytics(),
571
+ eventBus: new NoOpEventBus(),
572
+ logs: noOpLogReader
573
+ };
574
+ }
575
+
576
+ // src/noop/core/workflow.ts
577
+ var NoOpWorkflowEngine = class {
578
+ async execute(_workflowId, _input, _options) {
579
+ throw new Error(
580
+ "Workflow engine not configured. Initialize platform with core-runtime."
581
+ );
582
+ }
583
+ async getStatus(_runId) {
584
+ throw new Error(
585
+ "Workflow engine not configured. Initialize platform with core-runtime."
586
+ );
587
+ }
588
+ async cancel(_runId) {
589
+ throw new Error(
590
+ "Workflow engine not configured. Initialize platform with core-runtime."
591
+ );
592
+ }
593
+ async retry(_runId, _fromStep) {
594
+ throw new Error(
595
+ "Workflow engine not configured. Initialize platform with core-runtime."
596
+ );
597
+ }
598
+ async list(_filter) {
599
+ throw new Error(
600
+ "Workflow engine not configured. Initialize platform with core-runtime."
601
+ );
602
+ }
603
+ };
604
+
605
+ // src/noop/core/jobs.ts
606
+ var NoOpJobScheduler = class {
607
+ jobs = /* @__PURE__ */ new Map();
608
+ idCounter = 0;
609
+ async submit(job) {
610
+ const id = `noop-job-${++this.idCounter}`;
611
+ const handle = {
612
+ id,
613
+ type: job.type,
614
+ tenantId: job.tenantId ?? "default",
615
+ status: "completed",
616
+ createdAt: /* @__PURE__ */ new Date(),
617
+ startedAt: /* @__PURE__ */ new Date(),
618
+ completedAt: /* @__PURE__ */ new Date()
619
+ };
620
+ this.jobs.set(id, handle);
621
+ return handle;
622
+ }
623
+ async schedule(job, _schedule) {
624
+ return this.submit(job);
625
+ }
626
+ async cancel(jobId) {
627
+ const job = this.jobs.get(jobId);
628
+ if (!job) {
629
+ return false;
630
+ }
631
+ job.status = "cancelled";
632
+ return true;
633
+ }
634
+ async getStatus(jobId) {
635
+ return this.jobs.get(jobId) ?? null;
636
+ }
637
+ async list(filter) {
638
+ let results = Array.from(this.jobs.values());
639
+ if (filter?.type) {
640
+ results = results.filter((j) => j.type === filter.type);
641
+ }
642
+ if (filter?.status) {
643
+ results = results.filter((j) => j.status === filter.status);
644
+ }
645
+ if (filter?.tenantId) {
646
+ results = results.filter((j) => j.tenantId === filter.tenantId);
647
+ }
648
+ return results;
649
+ }
650
+ /**
651
+ * Clear all jobs (for testing).
652
+ */
653
+ clear() {
654
+ this.jobs.clear();
655
+ this.idCounter = 0;
656
+ }
657
+ };
658
+
659
+ // src/noop/core/cron.ts
660
+ var NoOpCronManager = class {
661
+ cronJobs = /* @__PURE__ */ new Map();
662
+ register(id, schedule, handler) {
663
+ this.cronJobs.set(id, {
664
+ id,
665
+ schedule,
666
+ handler,
667
+ status: "active",
668
+ runCount: 0
669
+ });
670
+ }
671
+ unregister(id) {
672
+ this.cronJobs.delete(id);
673
+ }
674
+ list() {
675
+ return Array.from(this.cronJobs.values()).map((entry) => ({
676
+ id: entry.id,
677
+ schedule: entry.schedule,
678
+ status: entry.status,
679
+ lastRun: entry.lastRun,
680
+ nextRun: void 0,
681
+ // NoOp doesn't calculate next run
682
+ runCount: entry.runCount
683
+ }));
684
+ }
685
+ async trigger(id) {
686
+ const entry = this.cronJobs.get(id);
687
+ if (!entry) {
688
+ throw new Error(`Cron job not found: ${id}`);
689
+ }
690
+ if (entry.status === "paused") {
691
+ throw new Error(`Cron job is paused: ${id}`);
692
+ }
693
+ const now = /* @__PURE__ */ new Date();
694
+ await entry.handler({
695
+ jobId: id,
696
+ scheduledAt: now,
697
+ executedAt: now,
698
+ runCount: entry.runCount + 1
699
+ });
700
+ entry.lastRun = now;
701
+ entry.runCount++;
702
+ }
703
+ pause(id) {
704
+ const entry = this.cronJobs.get(id);
705
+ if (entry) {
706
+ entry.status = "paused";
707
+ }
708
+ }
709
+ resume(id) {
710
+ const entry = this.cronJobs.get(id);
711
+ if (entry) {
712
+ entry.status = "active";
713
+ }
714
+ }
715
+ /**
716
+ * Clear all cron jobs (for testing).
717
+ */
718
+ clear() {
719
+ this.cronJobs.clear();
720
+ }
721
+ };
722
+
723
+ // src/noop/core/resources.ts
724
+ var UNLIMITED_QUOTAS = {
725
+ maxConcurrentWorkflows: Number.MAX_SAFE_INTEGER,
726
+ maxConcurrentJobs: Number.MAX_SAFE_INTEGER,
727
+ maxQueuedJobs: Number.MAX_SAFE_INTEGER,
728
+ apiRequestsPerMinute: Number.MAX_SAFE_INTEGER,
729
+ llmTokensPerDay: Number.MAX_SAFE_INTEGER,
730
+ storageBytes: Number.MAX_SAFE_INTEGER
731
+ };
732
+ var NoOpResourceManager = class {
733
+ quotas = /* @__PURE__ */ new Map();
734
+ slots = /* @__PURE__ */ new Map();
735
+ idCounter = 0;
736
+ async acquireSlot(resource, tenantId, timeout) {
737
+ const slot = {
738
+ id: `noop-slot-${++this.idCounter}`,
739
+ resource,
740
+ tenantId,
741
+ acquiredAt: /* @__PURE__ */ new Date(),
742
+ expiresAt: timeout ? new Date(Date.now() + timeout) : void 0
743
+ };
744
+ this.slots.set(slot.id, slot);
745
+ return slot;
746
+ }
747
+ async releaseSlot(slot) {
748
+ this.slots.delete(slot.id);
749
+ }
750
+ async getAvailability(resource, tenantId) {
751
+ const usedSlots = Array.from(this.slots.values()).filter(
752
+ (s) => s.resource === resource && (!tenantId || s.tenantId === tenantId)
753
+ );
754
+ return {
755
+ resource,
756
+ total: Number.MAX_SAFE_INTEGER,
757
+ used: usedSlots.length,
758
+ available: Number.MAX_SAFE_INTEGER,
759
+ queueLength: 0
760
+ };
761
+ }
762
+ async setQuota(tenantId, quotas) {
763
+ const existing = this.quotas.get(tenantId) ?? { ...UNLIMITED_QUOTAS };
764
+ this.quotas.set(tenantId, { ...existing, ...quotas });
765
+ }
766
+ async getQuota(tenantId) {
767
+ return this.quotas.get(tenantId) ?? { ...UNLIMITED_QUOTAS };
768
+ }
769
+ /**
770
+ * Get the current number of active slots (for testing).
771
+ */
772
+ get activeSlotCount() {
773
+ return this.slots.size;
774
+ }
775
+ /**
776
+ * Clear all slots and quotas (for testing).
777
+ */
778
+ clear() {
779
+ this.slots.clear();
780
+ this.quotas.clear();
781
+ this.idCounter = 0;
782
+ }
783
+ };
784
+
785
+ export { ConsoleLogger, MemoryArtifacts, MemoryCache, MemoryEventBus, MemoryStorage, MemoryVectorStore, MockEmbeddings, MockLLM, NoOpAnalytics, NoOpConfig, NoOpCronManager, NoOpEventBus, NoOpInvoke, NoOpJobScheduler, NoOpLogger, NoOpResourceManager, NoOpWorkflowEngine, createNoOpPlatform };
786
+ //# sourceMappingURL=index.js.map
787
+ //# sourceMappingURL=index.js.map