@positronic/cloudflare 0.0.14 → 0.0.16
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/dist/src/api.js +222 -92
- package/dist/src/brain-resolver.js +232 -0
- package/dist/src/brain-runner-do.js +28 -8
- package/dist/src/dev-server.js +7 -2
- package/dist/src/manifest.js +42 -12
- package/dist/src/schedule-do.js +16 -16
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/brain-resolver.d.ts +32 -0
- package/dist/types/brain-resolver.d.ts.map +1 -0
- package/dist/types/brain-runner-do.d.ts +1 -1
- package/dist/types/brain-runner-do.d.ts.map +1 -1
- package/dist/types/dev-server.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/manifest.d.ts +5 -2
- package/dist/types/manifest.d.ts.map +1 -1
- package/dist/types/node-index.d.ts +1 -1
- package/dist/types/node-index.d.ts.map +1 -1
- package/dist/types/schedule-do.d.ts +2 -2
- package/dist/types/schedule-do.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/src/api.js
CHANGED
|
@@ -186,7 +186,7 @@ import { RESOURCE_TYPES } from '@positronic/core';
|
|
|
186
186
|
var app = new Hono();
|
|
187
187
|
app.post('/brains/runs', function(context) {
|
|
188
188
|
return _async_to_generator(function() {
|
|
189
|
-
var
|
|
189
|
+
var requestBody, options, identifier, manifest, resolution, brain, brainRunId, namespace, doId, stub, initialData, brainTitle, response;
|
|
190
190
|
return _ts_generator(this, function(_state) {
|
|
191
191
|
switch(_state.label){
|
|
192
192
|
case 0:
|
|
@@ -195,12 +195,15 @@ app.post('/brains/runs', function(context) {
|
|
|
195
195
|
context.req.json()
|
|
196
196
|
];
|
|
197
197
|
case 1:
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
requestBody = _state.sent();
|
|
199
|
+
options = requestBody.options;
|
|
200
|
+
// Support both identifier and brainTitle for backward compatibility
|
|
201
|
+
identifier = requestBody.identifier || requestBody.brainTitle;
|
|
202
|
+
if (!identifier) {
|
|
200
203
|
return [
|
|
201
204
|
2,
|
|
202
205
|
context.json({
|
|
203
|
-
error: 'Missing
|
|
206
|
+
error: 'Missing identifier or brainTitle in request body'
|
|
204
207
|
}, 400)
|
|
205
208
|
];
|
|
206
209
|
}
|
|
@@ -214,29 +217,42 @@ app.post('/brains/runs', function(context) {
|
|
|
214
217
|
}, 500)
|
|
215
218
|
];
|
|
216
219
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
];
|
|
221
|
-
case 2:
|
|
222
|
-
brain = _state.sent();
|
|
223
|
-
if (!brain) {
|
|
220
|
+
// Resolve the identifier to find the brain
|
|
221
|
+
resolution = manifest.resolve(identifier);
|
|
222
|
+
if (resolution.matchType === 'none') {
|
|
224
223
|
return [
|
|
225
224
|
2,
|
|
226
225
|
context.json({
|
|
227
|
-
error: "Brain '".concat(
|
|
226
|
+
error: "Brain '".concat(identifier, "' not found")
|
|
228
227
|
}, 404)
|
|
229
228
|
];
|
|
230
229
|
}
|
|
230
|
+
if (resolution.matchType === 'multiple') {
|
|
231
|
+
return [
|
|
232
|
+
2,
|
|
233
|
+
context.json({
|
|
234
|
+
error: 'Multiple brains match the identifier',
|
|
235
|
+
matchType: 'multiple',
|
|
236
|
+
candidates: resolution.candidates
|
|
237
|
+
}, 409)
|
|
238
|
+
];
|
|
239
|
+
}
|
|
240
|
+
brain = resolution.brain;
|
|
231
241
|
brainRunId = uuidv4();
|
|
232
242
|
namespace = context.env.BRAIN_RUNNER_DO;
|
|
233
243
|
doId = namespace.idFromName(brainRunId);
|
|
234
244
|
stub = namespace.get(doId);
|
|
245
|
+
// Pass options to the brain runner if provided
|
|
246
|
+
initialData = options ? {
|
|
247
|
+
options: options
|
|
248
|
+
} : undefined;
|
|
249
|
+
// Get the actual brain title from the resolved brain
|
|
250
|
+
brainTitle = brain.title || identifier;
|
|
235
251
|
return [
|
|
236
252
|
4,
|
|
237
|
-
stub.start(
|
|
253
|
+
stub.start(brainTitle, brainRunId, initialData)
|
|
238
254
|
];
|
|
239
|
-
case
|
|
255
|
+
case 2:
|
|
240
256
|
_state.sent();
|
|
241
257
|
response = {
|
|
242
258
|
brainRunId: brainRunId
|
|
@@ -251,7 +267,7 @@ app.post('/brains/runs', function(context) {
|
|
|
251
267
|
});
|
|
252
268
|
app.post('/brains/runs/rerun', function(context) {
|
|
253
269
|
return _async_to_generator(function() {
|
|
254
|
-
var
|
|
270
|
+
var requestBody, runId, startsAt, stopsAfter, identifier, manifest, resolution, brain, monitorId, monitorStub, existingRun, newBrainRunId, namespace, doId, stub, rerunOptions, brainTitle, response;
|
|
255
271
|
return _ts_generator(this, function(_state) {
|
|
256
272
|
switch(_state.label){
|
|
257
273
|
case 0:
|
|
@@ -260,12 +276,15 @@ app.post('/brains/runs/rerun', function(context) {
|
|
|
260
276
|
context.req.json()
|
|
261
277
|
];
|
|
262
278
|
case 1:
|
|
263
|
-
|
|
264
|
-
|
|
279
|
+
requestBody = _state.sent();
|
|
280
|
+
runId = requestBody.runId, startsAt = requestBody.startsAt, stopsAfter = requestBody.stopsAfter;
|
|
281
|
+
// Support both identifier and brainTitle for backward compatibility
|
|
282
|
+
identifier = requestBody.identifier || requestBody.brainTitle;
|
|
283
|
+
if (!identifier) {
|
|
265
284
|
return [
|
|
266
285
|
2,
|
|
267
286
|
context.json({
|
|
268
|
-
error: 'Missing
|
|
287
|
+
error: 'Missing identifier or brainTitle in request body'
|
|
269
288
|
}, 400)
|
|
270
289
|
];
|
|
271
290
|
}
|
|
@@ -279,23 +298,30 @@ app.post('/brains/runs/rerun', function(context) {
|
|
|
279
298
|
}, 500)
|
|
280
299
|
];
|
|
281
300
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
];
|
|
286
|
-
case 2:
|
|
287
|
-
brain = _state.sent();
|
|
288
|
-
if (!brain) {
|
|
301
|
+
// Resolve the identifier to find the brain
|
|
302
|
+
resolution = manifest.resolve(identifier);
|
|
303
|
+
if (resolution.matchType === 'none') {
|
|
289
304
|
return [
|
|
290
305
|
2,
|
|
291
306
|
context.json({
|
|
292
|
-
error: "Brain '".concat(
|
|
307
|
+
error: "Brain '".concat(identifier, "' not found")
|
|
293
308
|
}, 404)
|
|
294
309
|
];
|
|
295
310
|
}
|
|
311
|
+
if (resolution.matchType === 'multiple') {
|
|
312
|
+
return [
|
|
313
|
+
2,
|
|
314
|
+
context.json({
|
|
315
|
+
error: 'Multiple brains match the identifier',
|
|
316
|
+
matchType: 'multiple',
|
|
317
|
+
candidates: resolution.candidates
|
|
318
|
+
}, 409)
|
|
319
|
+
];
|
|
320
|
+
}
|
|
321
|
+
brain = resolution.brain;
|
|
296
322
|
if (!runId) return [
|
|
297
323
|
3,
|
|
298
|
-
|
|
324
|
+
3
|
|
299
325
|
];
|
|
300
326
|
monitorId = context.env.MONITOR_DO.idFromName('singleton');
|
|
301
327
|
monitorStub = context.env.MONITOR_DO.get(monitorId);
|
|
@@ -303,7 +329,7 @@ app.post('/brains/runs/rerun', function(context) {
|
|
|
303
329
|
4,
|
|
304
330
|
monitorStub.getLastEvent(runId)
|
|
305
331
|
];
|
|
306
|
-
case
|
|
332
|
+
case 2:
|
|
307
333
|
existingRun = _state.sent();
|
|
308
334
|
if (!existingRun) {
|
|
309
335
|
return [
|
|
@@ -313,8 +339,8 @@ app.post('/brains/runs/rerun', function(context) {
|
|
|
313
339
|
}, 404)
|
|
314
340
|
];
|
|
315
341
|
}
|
|
316
|
-
_state.label =
|
|
317
|
-
case
|
|
342
|
+
_state.label = 3;
|
|
343
|
+
case 3:
|
|
318
344
|
// Create a new brain run with rerun parameters
|
|
319
345
|
newBrainRunId = uuidv4();
|
|
320
346
|
namespace = context.env.BRAIN_RUNNER_DO;
|
|
@@ -328,11 +354,13 @@ app.post('/brains/runs/rerun', function(context) {
|
|
|
328
354
|
}, stopsAfter !== undefined && {
|
|
329
355
|
stopsAfter: stopsAfter
|
|
330
356
|
});
|
|
357
|
+
// Get the actual brain title from the resolved brain
|
|
358
|
+
brainTitle = brain.title || identifier;
|
|
331
359
|
return [
|
|
332
360
|
4,
|
|
333
|
-
stub.start(
|
|
361
|
+
stub.start(brainTitle, newBrainRunId, rerunOptions)
|
|
334
362
|
];
|
|
335
|
-
case
|
|
363
|
+
case 4:
|
|
336
364
|
_state.sent();
|
|
337
365
|
response = {
|
|
338
366
|
brainRunId: newBrainRunId
|
|
@@ -369,20 +397,52 @@ app.get('/brains/runs/:runId/watch', function(context) {
|
|
|
369
397
|
});
|
|
370
398
|
})();
|
|
371
399
|
});
|
|
372
|
-
app.get('/brains/:
|
|
400
|
+
app.get('/brains/:identifier/history', function(context) {
|
|
373
401
|
return _async_to_generator(function() {
|
|
374
|
-
var
|
|
402
|
+
var identifier, limit, manifest, resolution, brain, brainTitle, monitorId, monitorStub, runs;
|
|
375
403
|
return _ts_generator(this, function(_state) {
|
|
376
404
|
switch(_state.label){
|
|
377
405
|
case 0:
|
|
378
|
-
|
|
406
|
+
identifier = context.req.param('identifier');
|
|
379
407
|
limit = Number(context.req.query('limit') || '10');
|
|
408
|
+
// Resolve the identifier to get the actual brain title
|
|
409
|
+
manifest = getManifest();
|
|
410
|
+
if (!manifest) {
|
|
411
|
+
return [
|
|
412
|
+
2,
|
|
413
|
+
context.json({
|
|
414
|
+
error: 'Manifest not initialized'
|
|
415
|
+
}, 500)
|
|
416
|
+
];
|
|
417
|
+
}
|
|
418
|
+
resolution = manifest.resolve(identifier);
|
|
419
|
+
if (resolution.matchType === 'none') {
|
|
420
|
+
return [
|
|
421
|
+
2,
|
|
422
|
+
context.json({
|
|
423
|
+
error: "Brain '".concat(identifier, "' not found")
|
|
424
|
+
}, 404)
|
|
425
|
+
];
|
|
426
|
+
}
|
|
427
|
+
if (resolution.matchType === 'multiple') {
|
|
428
|
+
return [
|
|
429
|
+
2,
|
|
430
|
+
context.json({
|
|
431
|
+
error: 'Multiple brains match the identifier',
|
|
432
|
+
matchType: 'multiple',
|
|
433
|
+
candidates: resolution.candidates
|
|
434
|
+
}, 300)
|
|
435
|
+
];
|
|
436
|
+
}
|
|
437
|
+
// Get the actual brain title
|
|
438
|
+
brain = resolution.brain;
|
|
439
|
+
brainTitle = brain.title || identifier;
|
|
380
440
|
// Get the monitor singleton instance
|
|
381
441
|
monitorId = context.env.MONITOR_DO.idFromName('singleton');
|
|
382
442
|
monitorStub = context.env.MONITOR_DO.get(monitorId);
|
|
383
443
|
return [
|
|
384
444
|
4,
|
|
385
|
-
monitorStub.history(
|
|
445
|
+
monitorStub.history(brainTitle, limit)
|
|
386
446
|
];
|
|
387
447
|
case 1:
|
|
388
448
|
runs = _state.sent();
|
|
@@ -396,19 +456,51 @@ app.get('/brains/:brainName/history', function(context) {
|
|
|
396
456
|
});
|
|
397
457
|
})();
|
|
398
458
|
});
|
|
399
|
-
app.get('/brains/:
|
|
459
|
+
app.get('/brains/:identifier/active-runs', function(context) {
|
|
400
460
|
return _async_to_generator(function() {
|
|
401
|
-
var
|
|
461
|
+
var identifier, manifest, resolution, brain, brainTitle, monitorId, monitorStub, runs;
|
|
402
462
|
return _ts_generator(this, function(_state) {
|
|
403
463
|
switch(_state.label){
|
|
404
464
|
case 0:
|
|
405
|
-
|
|
465
|
+
identifier = context.req.param('identifier');
|
|
466
|
+
// Resolve the identifier to get the actual brain title
|
|
467
|
+
manifest = getManifest();
|
|
468
|
+
if (!manifest) {
|
|
469
|
+
return [
|
|
470
|
+
2,
|
|
471
|
+
context.json({
|
|
472
|
+
error: 'Manifest not initialized'
|
|
473
|
+
}, 500)
|
|
474
|
+
];
|
|
475
|
+
}
|
|
476
|
+
resolution = manifest.resolve(identifier);
|
|
477
|
+
if (resolution.matchType === 'none') {
|
|
478
|
+
return [
|
|
479
|
+
2,
|
|
480
|
+
context.json({
|
|
481
|
+
error: "Brain '".concat(identifier, "' not found")
|
|
482
|
+
}, 404)
|
|
483
|
+
];
|
|
484
|
+
}
|
|
485
|
+
if (resolution.matchType === 'multiple') {
|
|
486
|
+
return [
|
|
487
|
+
2,
|
|
488
|
+
context.json({
|
|
489
|
+
error: 'Multiple brains match the identifier',
|
|
490
|
+
matchType: 'multiple',
|
|
491
|
+
candidates: resolution.candidates
|
|
492
|
+
}, 300)
|
|
493
|
+
];
|
|
494
|
+
}
|
|
495
|
+
// Get the actual brain title
|
|
496
|
+
brain = resolution.brain;
|
|
497
|
+
brainTitle = brain.title || identifier;
|
|
406
498
|
// Get the monitor singleton instance
|
|
407
499
|
monitorId = context.env.MONITOR_DO.idFromName('singleton');
|
|
408
500
|
monitorStub = context.env.MONITOR_DO.get(monitorId);
|
|
409
501
|
return [
|
|
410
502
|
4,
|
|
411
|
-
monitorStub.activeRuns(
|
|
503
|
+
monitorStub.activeRuns(brainTitle)
|
|
412
504
|
];
|
|
413
505
|
case 1:
|
|
414
506
|
runs = _state.sent();
|
|
@@ -446,7 +538,7 @@ app.get('/brains/watch', function(context) {
|
|
|
446
538
|
});
|
|
447
539
|
app.get('/brains', function(context) {
|
|
448
540
|
return _async_to_generator(function() {
|
|
449
|
-
var manifest,
|
|
541
|
+
var manifest, brainFilenames, brains, validBrains;
|
|
450
542
|
return _ts_generator(this, function(_state) {
|
|
451
543
|
switch(_state.label){
|
|
452
544
|
case 0:
|
|
@@ -459,18 +551,18 @@ app.get('/brains', function(context) {
|
|
|
459
551
|
}, 500)
|
|
460
552
|
];
|
|
461
553
|
}
|
|
462
|
-
|
|
554
|
+
brainFilenames = manifest.list();
|
|
463
555
|
return [
|
|
464
556
|
4,
|
|
465
|
-
Promise.all(
|
|
557
|
+
Promise.all(brainFilenames.map(function(filename) {
|
|
466
558
|
return _async_to_generator(function() {
|
|
467
|
-
var brain;
|
|
559
|
+
var brain, structure;
|
|
468
560
|
return _ts_generator(this, function(_state) {
|
|
469
561
|
switch(_state.label){
|
|
470
562
|
case 0:
|
|
471
563
|
return [
|
|
472
564
|
4,
|
|
473
|
-
manifest.import(
|
|
565
|
+
manifest.import(filename)
|
|
474
566
|
];
|
|
475
567
|
case 1:
|
|
476
568
|
brain = _state.sent();
|
|
@@ -480,12 +572,13 @@ app.get('/brains', function(context) {
|
|
|
480
572
|
null
|
|
481
573
|
];
|
|
482
574
|
}
|
|
575
|
+
structure = brain.structure;
|
|
483
576
|
return [
|
|
484
577
|
2,
|
|
485
578
|
{
|
|
486
|
-
|
|
487
|
-
title:
|
|
488
|
-
description: "".concat(
|
|
579
|
+
filename: filename,
|
|
580
|
+
title: structure.title,
|
|
581
|
+
description: structure.description || "".concat(structure.title, " brain")
|
|
489
582
|
}
|
|
490
583
|
];
|
|
491
584
|
}
|
|
@@ -514,7 +607,7 @@ app.get('/brains', function(context) {
|
|
|
514
607
|
// Create a new schedule
|
|
515
608
|
app.post('/brains/schedules', function(context) {
|
|
516
609
|
return _async_to_generator(function() {
|
|
517
|
-
var body,
|
|
610
|
+
var body, cronExpression, identifier, manifest, resolution, brain, brainTitle, scheduleId, scheduleStub, schedule, error, errorMessage;
|
|
518
611
|
return _ts_generator(this, function(_state) {
|
|
519
612
|
switch(_state.label){
|
|
520
613
|
case 0:
|
|
@@ -530,12 +623,14 @@ app.post('/brains/schedules', function(context) {
|
|
|
530
623
|
];
|
|
531
624
|
case 1:
|
|
532
625
|
body = _state.sent();
|
|
533
|
-
|
|
534
|
-
|
|
626
|
+
cronExpression = body.cronExpression;
|
|
627
|
+
// Support both identifier and brainTitle for backward compatibility
|
|
628
|
+
identifier = body.identifier || body.brainTitle;
|
|
629
|
+
if (!identifier) {
|
|
535
630
|
return [
|
|
536
631
|
2,
|
|
537
632
|
context.json({
|
|
538
|
-
error: 'Missing required field "
|
|
633
|
+
error: 'Missing required field "identifier" or "brainTitle"'
|
|
539
634
|
}, 400)
|
|
540
635
|
];
|
|
541
636
|
}
|
|
@@ -558,12 +653,44 @@ app.post('/brains/schedules', function(context) {
|
|
|
558
653
|
}, 400)
|
|
559
654
|
];
|
|
560
655
|
}
|
|
656
|
+
// Resolve the identifier to get the actual brain title
|
|
657
|
+
manifest = getManifest();
|
|
658
|
+
if (!manifest) {
|
|
659
|
+
return [
|
|
660
|
+
2,
|
|
661
|
+
context.json({
|
|
662
|
+
error: 'Manifest not initialized'
|
|
663
|
+
}, 500)
|
|
664
|
+
];
|
|
665
|
+
}
|
|
666
|
+
resolution = manifest.resolve(identifier);
|
|
667
|
+
if (resolution.matchType === 'none') {
|
|
668
|
+
return [
|
|
669
|
+
2,
|
|
670
|
+
context.json({
|
|
671
|
+
error: "Brain '".concat(identifier, "' not found")
|
|
672
|
+
}, 404)
|
|
673
|
+
];
|
|
674
|
+
}
|
|
675
|
+
if (resolution.matchType === 'multiple') {
|
|
676
|
+
return [
|
|
677
|
+
2,
|
|
678
|
+
context.json({
|
|
679
|
+
error: 'Multiple brains match the identifier',
|
|
680
|
+
matchType: 'multiple',
|
|
681
|
+
candidates: resolution.candidates
|
|
682
|
+
}, 409)
|
|
683
|
+
];
|
|
684
|
+
}
|
|
685
|
+
// Get the actual brain title
|
|
686
|
+
brain = resolution.brain;
|
|
687
|
+
brainTitle = brain.title || identifier;
|
|
561
688
|
// Get the schedule singleton instance
|
|
562
689
|
scheduleId = context.env.SCHEDULE_DO.idFromName('singleton');
|
|
563
690
|
scheduleStub = context.env.SCHEDULE_DO.get(scheduleId);
|
|
564
691
|
return [
|
|
565
692
|
4,
|
|
566
|
-
scheduleStub.createSchedule(
|
|
693
|
+
scheduleStub.createSchedule(brainTitle, cronExpression)
|
|
567
694
|
];
|
|
568
695
|
case 2:
|
|
569
696
|
schedule = _state.sent();
|
|
@@ -670,48 +797,51 @@ app.delete('/brains/schedules/:scheduleId', function(context) {
|
|
|
670
797
|
});
|
|
671
798
|
})();
|
|
672
799
|
});
|
|
673
|
-
app.get('/brains/:
|
|
800
|
+
app.get('/brains/:identifier', function(context) {
|
|
674
801
|
return _async_to_generator(function() {
|
|
675
|
-
var
|
|
802
|
+
var identifier, manifest, resolution, brain, structure;
|
|
676
803
|
return _ts_generator(this, function(_state) {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
}, 500)
|
|
687
|
-
];
|
|
688
|
-
}
|
|
689
|
-
return [
|
|
690
|
-
4,
|
|
691
|
-
manifest.import(brainName)
|
|
692
|
-
];
|
|
693
|
-
case 1:
|
|
694
|
-
brain = _state.sent();
|
|
695
|
-
if (!brain) {
|
|
696
|
-
return [
|
|
697
|
-
2,
|
|
698
|
-
context.json({
|
|
699
|
-
error: "Brain '".concat(brainName, "' not found")
|
|
700
|
-
}, 404)
|
|
701
|
-
];
|
|
702
|
-
}
|
|
703
|
-
// Get the brain structure
|
|
704
|
-
structure = brain.structure;
|
|
705
|
-
return [
|
|
706
|
-
2,
|
|
707
|
-
context.json({
|
|
708
|
-
name: brainName,
|
|
709
|
-
title: structure.title,
|
|
710
|
-
description: structure.description || "".concat(structure.title, " brain"),
|
|
711
|
-
steps: structure.steps
|
|
712
|
-
})
|
|
713
|
-
];
|
|
804
|
+
identifier = context.req.param('identifier');
|
|
805
|
+
manifest = getManifest();
|
|
806
|
+
if (!manifest) {
|
|
807
|
+
return [
|
|
808
|
+
2,
|
|
809
|
+
context.json({
|
|
810
|
+
error: 'Manifest not initialized'
|
|
811
|
+
}, 500)
|
|
812
|
+
];
|
|
714
813
|
}
|
|
814
|
+
// Resolve the identifier to find the brain
|
|
815
|
+
resolution = manifest.resolve(identifier);
|
|
816
|
+
if (resolution.matchType === 'none') {
|
|
817
|
+
return [
|
|
818
|
+
2,
|
|
819
|
+
context.json({
|
|
820
|
+
error: "Brain '".concat(identifier, "' not found")
|
|
821
|
+
}, 404)
|
|
822
|
+
];
|
|
823
|
+
}
|
|
824
|
+
if (resolution.matchType === 'multiple') {
|
|
825
|
+
return [
|
|
826
|
+
2,
|
|
827
|
+
context.json({
|
|
828
|
+
error: 'Multiple brains match the identifier',
|
|
829
|
+
matchType: 'multiple',
|
|
830
|
+
candidates: resolution.candidates
|
|
831
|
+
}, 300)
|
|
832
|
+
];
|
|
833
|
+
}
|
|
834
|
+
brain = resolution.brain;
|
|
835
|
+
// Get the brain structure
|
|
836
|
+
structure = brain.structure;
|
|
837
|
+
return [
|
|
838
|
+
2,
|
|
839
|
+
context.json({
|
|
840
|
+
title: structure.title,
|
|
841
|
+
description: structure.description || "".concat(structure.title, " brain"),
|
|
842
|
+
steps: structure.steps
|
|
843
|
+
})
|
|
844
|
+
];
|
|
715
845
|
});
|
|
716
846
|
})();
|
|
717
847
|
});
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _class_call_check(instance, Constructor) {
|
|
10
|
+
if (!(instance instanceof Constructor)) {
|
|
11
|
+
throw new TypeError("Cannot call a class as a function");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function _defineProperties(target, props) {
|
|
15
|
+
for(var i = 0; i < props.length; i++){
|
|
16
|
+
var descriptor = props[i];
|
|
17
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
18
|
+
descriptor.configurable = true;
|
|
19
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
20
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
24
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
25
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
26
|
+
return Constructor;
|
|
27
|
+
}
|
|
28
|
+
function _define_property(obj, key, value) {
|
|
29
|
+
if (key in obj) {
|
|
30
|
+
Object.defineProperty(obj, key, {
|
|
31
|
+
value: value,
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
obj[key] = value;
|
|
38
|
+
}
|
|
39
|
+
return obj;
|
|
40
|
+
}
|
|
41
|
+
function _iterable_to_array_limit(arr, i) {
|
|
42
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
43
|
+
if (_i == null) return;
|
|
44
|
+
var _arr = [];
|
|
45
|
+
var _n = true;
|
|
46
|
+
var _d = false;
|
|
47
|
+
var _s, _e;
|
|
48
|
+
try {
|
|
49
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
50
|
+
_arr.push(_s.value);
|
|
51
|
+
if (i && _arr.length === i) break;
|
|
52
|
+
}
|
|
53
|
+
} catch (err) {
|
|
54
|
+
_d = true;
|
|
55
|
+
_e = err;
|
|
56
|
+
} finally{
|
|
57
|
+
try {
|
|
58
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
59
|
+
} finally{
|
|
60
|
+
if (_d) throw _e;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return _arr;
|
|
64
|
+
}
|
|
65
|
+
function _non_iterable_rest() {
|
|
66
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
67
|
+
}
|
|
68
|
+
function _sliced_to_array(arr, i) {
|
|
69
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
70
|
+
}
|
|
71
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
72
|
+
if (!o) return;
|
|
73
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
74
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
75
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
76
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
77
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
78
|
+
}
|
|
79
|
+
export var BrainResolver = /*#__PURE__*/ function() {
|
|
80
|
+
"use strict";
|
|
81
|
+
function BrainResolver(enhancedManifest) {
|
|
82
|
+
_class_call_check(this, BrainResolver);
|
|
83
|
+
_define_property(this, "enhancedManifest", void 0);
|
|
84
|
+
_define_property(this, "metadataCache", void 0);
|
|
85
|
+
this.enhancedManifest = enhancedManifest;
|
|
86
|
+
this.metadataCache = new Map();
|
|
87
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
88
|
+
try {
|
|
89
|
+
// Pre-cache brain titles and descriptions
|
|
90
|
+
for(var _iterator = Object.entries(enhancedManifest)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
91
|
+
var _step_value = _sliced_to_array(_step.value, 2), filename = _step_value[0], metadata = _step_value[1];
|
|
92
|
+
var brain = metadata.brain;
|
|
93
|
+
// Access brain structure to get title and description
|
|
94
|
+
var structure = brain.structure;
|
|
95
|
+
this.metadataCache.set(filename, {
|
|
96
|
+
title: structure.title || filename,
|
|
97
|
+
description: structure.description
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
} catch (err) {
|
|
101
|
+
_didIteratorError = true;
|
|
102
|
+
_iteratorError = err;
|
|
103
|
+
} finally{
|
|
104
|
+
try {
|
|
105
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
106
|
+
_iterator.return();
|
|
107
|
+
}
|
|
108
|
+
} finally{
|
|
109
|
+
if (_didIteratorError) {
|
|
110
|
+
throw _iteratorError;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
_create_class(BrainResolver, [
|
|
116
|
+
{
|
|
117
|
+
key: "resolve",
|
|
118
|
+
value: function resolve(identifier) {
|
|
119
|
+
var candidates = [];
|
|
120
|
+
// Normalize identifier for comparison
|
|
121
|
+
var normalizedIdentifier = identifier.toLowerCase().trim();
|
|
122
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
123
|
+
try {
|
|
124
|
+
// Check each brain in the manifest
|
|
125
|
+
for(var _iterator = Object.entries(this.enhancedManifest)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
126
|
+
var _step_value = _sliced_to_array(_step.value, 2), filename = _step_value[0], metadata = _step_value[1];
|
|
127
|
+
var cached = this.metadataCache.get(filename);
|
|
128
|
+
var title = cached.title;
|
|
129
|
+
var description = cached.description;
|
|
130
|
+
// 1. Exact title match (case-insensitive)
|
|
131
|
+
if (title.toLowerCase() === normalizedIdentifier) {
|
|
132
|
+
return {
|
|
133
|
+
matchType: 'exact',
|
|
134
|
+
brain: metadata.brain
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// 2. Exact filename match (case-insensitive)
|
|
138
|
+
if (filename.toLowerCase() === normalizedIdentifier) {
|
|
139
|
+
return {
|
|
140
|
+
matchType: 'exact',
|
|
141
|
+
brain: metadata.brain
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// 3. Exact path match (case-insensitive)
|
|
145
|
+
if (metadata.path.toLowerCase() === normalizedIdentifier) {
|
|
146
|
+
return {
|
|
147
|
+
matchType: 'exact',
|
|
148
|
+
brain: metadata.brain
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
// Collect candidates for partial matching
|
|
152
|
+
var candidate = {
|
|
153
|
+
title: title,
|
|
154
|
+
filename: filename,
|
|
155
|
+
path: metadata.path,
|
|
156
|
+
description: description
|
|
157
|
+
};
|
|
158
|
+
// 4. Partial path match
|
|
159
|
+
if (metadata.path.toLowerCase().includes(normalizedIdentifier)) {
|
|
160
|
+
candidates.push(candidate);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
// 5. Title contains identifier
|
|
164
|
+
if (title.toLowerCase().includes(normalizedIdentifier)) {
|
|
165
|
+
candidates.push(candidate);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
// 6. Filename contains identifier
|
|
169
|
+
if (filename.toLowerCase().includes(normalizedIdentifier)) {
|
|
170
|
+
candidates.push(candidate);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
// 7. Description contains identifier (if exists)
|
|
174
|
+
if (description && description.toLowerCase().includes(normalizedIdentifier)) {
|
|
175
|
+
candidates.push(candidate);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
} catch (err) {
|
|
179
|
+
_didIteratorError = true;
|
|
180
|
+
_iteratorError = err;
|
|
181
|
+
} finally{
|
|
182
|
+
try {
|
|
183
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
184
|
+
_iterator.return();
|
|
185
|
+
}
|
|
186
|
+
} finally{
|
|
187
|
+
if (_didIteratorError) {
|
|
188
|
+
throw _iteratorError;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// Handle results
|
|
193
|
+
if (candidates.length === 0) {
|
|
194
|
+
return {
|
|
195
|
+
matchType: 'none'
|
|
196
|
+
};
|
|
197
|
+
} else if (candidates.length === 1) {
|
|
198
|
+
// Single match found through partial matching
|
|
199
|
+
var match = this.enhancedManifest[candidates[0].filename];
|
|
200
|
+
return {
|
|
201
|
+
matchType: 'exact',
|
|
202
|
+
brain: match.brain
|
|
203
|
+
};
|
|
204
|
+
} else {
|
|
205
|
+
// Multiple matches found
|
|
206
|
+
return {
|
|
207
|
+
matchType: 'multiple',
|
|
208
|
+
candidates: candidates
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
/**
|
|
215
|
+
* Get a brain by exact filename (used for backward compatibility)
|
|
216
|
+
*/ key: "getByFilename",
|
|
217
|
+
value: function getByFilename(filename) {
|
|
218
|
+
var metadata = this.enhancedManifest[filename];
|
|
219
|
+
return metadata === null || metadata === void 0 ? void 0 : metadata.brain;
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
/**
|
|
224
|
+
* List all available brains
|
|
225
|
+
*/ key: "list",
|
|
226
|
+
value: function list() {
|
|
227
|
+
return Object.keys(this.enhancedManifest);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
]);
|
|
231
|
+
return BrainResolver;
|
|
232
|
+
}();
|
|
@@ -88,6 +88,21 @@ function _inherits(subClass, superClass) {
|
|
|
88
88
|
});
|
|
89
89
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
90
90
|
}
|
|
91
|
+
function _object_spread(target) {
|
|
92
|
+
for(var i = 1; i < arguments.length; i++){
|
|
93
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
94
|
+
var ownKeys = Object.keys(source);
|
|
95
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
96
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
97
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
ownKeys.forEach(function(key) {
|
|
101
|
+
_define_property(target, key, source[key]);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return target;
|
|
105
|
+
}
|
|
91
106
|
function _possible_constructor_return(self, call) {
|
|
92
107
|
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
93
108
|
return call;
|
|
@@ -489,9 +504,9 @@ export var BrainRunnerDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
489
504
|
},
|
|
490
505
|
{
|
|
491
506
|
key: "start",
|
|
492
|
-
value: function start(
|
|
507
|
+
value: function start(brainTitle, brainRunId, initialData) {
|
|
493
508
|
return _async_to_generator(function() {
|
|
494
|
-
var sql, brainToRun, sqliteAdapter, eventStreamAdapter, monitorAdapter, scheduleAdapter, r2Resources, runnerWithResources;
|
|
509
|
+
var sql, brainToRun, sqliteAdapter, eventStreamAdapter, monitorAdapter, scheduleAdapter, r2Resources, runnerWithResources, options, initialState;
|
|
495
510
|
return _ts_generator(this, function(_state) {
|
|
496
511
|
switch(_state.label){
|
|
497
512
|
case 0:
|
|
@@ -501,14 +516,14 @@ export var BrainRunnerDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
501
516
|
}
|
|
502
517
|
return [
|
|
503
518
|
4,
|
|
504
|
-
manifest.import(
|
|
519
|
+
manifest.import(brainTitle)
|
|
505
520
|
];
|
|
506
521
|
case 1:
|
|
507
522
|
brainToRun = _state.sent();
|
|
508
523
|
if (!brainToRun) {
|
|
509
|
-
console.error("[DO ".concat(brainRunId, "] Brain ").concat(
|
|
524
|
+
console.error("[DO ".concat(brainRunId, "] Brain ").concat(brainTitle, " not found in manifest."));
|
|
510
525
|
console.error(JSON.stringify(manifest, null, 2));
|
|
511
|
-
throw new Error("Brain ".concat(
|
|
526
|
+
throw new Error("Brain ".concat(brainTitle, " not found"));
|
|
512
527
|
}
|
|
513
528
|
sqliteAdapter = new BrainRunSQLiteAdapter(sql);
|
|
514
529
|
eventStreamAdapter = this.eventStreamAdapter;
|
|
@@ -529,15 +544,20 @@ export var BrainRunnerDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
529
544
|
if (r2Resources) {
|
|
530
545
|
runnerWithResources = brainRunner.withResources(r2Resources);
|
|
531
546
|
}
|
|
547
|
+
// Extract options from initialData if present
|
|
548
|
+
options = initialData === null || initialData === void 0 ? void 0 : initialData.options;
|
|
549
|
+
initialState = initialData && !initialData.options ? initialData : {};
|
|
532
550
|
runnerWithResources.withAdapters([
|
|
533
551
|
sqliteAdapter,
|
|
534
552
|
eventStreamAdapter,
|
|
535
553
|
monitorAdapter,
|
|
536
554
|
scheduleAdapter
|
|
537
|
-
]).run(brainToRun, {
|
|
538
|
-
initialState:
|
|
555
|
+
]).run(brainToRun, _object_spread({
|
|
556
|
+
initialState: initialState,
|
|
539
557
|
brainRunId: brainRunId
|
|
540
|
-
}
|
|
558
|
+
}, options && {
|
|
559
|
+
options: options
|
|
560
|
+
})).catch(function(err) {
|
|
541
561
|
console.error("[DO ".concat(brainRunId, "] BrainRunner run failed:"), err);
|
|
542
562
|
});
|
|
543
563
|
return [
|
package/dist/src/dev-server.js
CHANGED
|
@@ -527,7 +527,12 @@ function regenerateManifestFile(projectRootPath, targetSrcDir) {
|
|
|
527
527
|
importPath = "../../brains/".concat(brainName, ".js");
|
|
528
528
|
importAlias = "brain_".concat(brainName.replace(/[^a-zA-Z0-9_]/g, '_'));
|
|
529
529
|
importStatements += "import * as ".concat(importAlias, " from '").concat(importPath, "';\n");
|
|
530
|
-
|
|
530
|
+
// Create manifest entry with metadata
|
|
531
|
+
manifestEntries += " ".concat(JSON.stringify(brainName), ": {\n");
|
|
532
|
+
manifestEntries += " filename: ".concat(JSON.stringify(brainName), ",\n");
|
|
533
|
+
manifestEntries += " path: ".concat(JSON.stringify("brains/".concat(file)), ",\n");
|
|
534
|
+
manifestEntries += " brain: ".concat(importAlias, ".default as Brain,\n");
|
|
535
|
+
manifestEntries += " },\n";
|
|
531
536
|
}
|
|
532
537
|
} catch (err) {
|
|
533
538
|
_didIteratorError = true;
|
|
@@ -545,7 +550,7 @@ function regenerateManifestFile(projectRootPath, targetSrcDir) {
|
|
|
545
550
|
}
|
|
546
551
|
_state.label = 3;
|
|
547
552
|
case 3:
|
|
548
|
-
manifestContent = "// This file is generated automatically. Do not edit directly.\n".concat(importStatements, "\nexport const
|
|
553
|
+
manifestContent = "// This file is generated automatically. Do not edit directly.\n".concat(importStatements, "\nimport type { BrainMetadata } from '@positronic/cloudflare';\n\nexport const manifest: Record<string, BrainMetadata> = {\n").concat(manifestEntries, "};\n");
|
|
549
554
|
return [
|
|
550
555
|
4,
|
|
551
556
|
fsPromises.readFile(runnerPath, 'utf-8')
|
package/dist/src/manifest.js
CHANGED
|
@@ -150,27 +150,37 @@ function _ts_generator(thisArg, body) {
|
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
+
import { BrainResolver } from './brain-resolver.js';
|
|
153
154
|
var StaticManifestStrategy = /*#__PURE__*/ function() {
|
|
154
155
|
"use strict";
|
|
155
156
|
function StaticManifestStrategy(manifest) {
|
|
156
157
|
_class_call_check(this, StaticManifestStrategy);
|
|
157
158
|
_define_property(this, "manifest", void 0);
|
|
159
|
+
_define_property(this, "resolver", void 0);
|
|
158
160
|
this.manifest = manifest;
|
|
161
|
+
this.resolver = new BrainResolver(manifest);
|
|
159
162
|
}
|
|
160
163
|
_create_class(StaticManifestStrategy, [
|
|
161
164
|
{
|
|
162
165
|
key: "import",
|
|
163
|
-
value: function _import(
|
|
166
|
+
value: function _import(filename) {
|
|
164
167
|
return _async_to_generator(function() {
|
|
168
|
+
var _this_manifest_filename;
|
|
165
169
|
return _ts_generator(this, function(_state) {
|
|
166
170
|
return [
|
|
167
171
|
2,
|
|
168
|
-
this.manifest[
|
|
172
|
+
(_this_manifest_filename = this.manifest[filename]) === null || _this_manifest_filename === void 0 ? void 0 : _this_manifest_filename.brain
|
|
169
173
|
];
|
|
170
174
|
});
|
|
171
175
|
}).call(this);
|
|
172
176
|
}
|
|
173
177
|
},
|
|
178
|
+
{
|
|
179
|
+
key: "resolve",
|
|
180
|
+
value: function resolve(identifier) {
|
|
181
|
+
return this.resolver.resolve(identifier);
|
|
182
|
+
}
|
|
183
|
+
},
|
|
174
184
|
{
|
|
175
185
|
key: "list",
|
|
176
186
|
value: function list() {
|
|
@@ -190,7 +200,7 @@ var DynamicImportStrategy = /*#__PURE__*/ function() {
|
|
|
190
200
|
_create_class(DynamicImportStrategy, [
|
|
191
201
|
{
|
|
192
202
|
key: "import",
|
|
193
|
-
value: function _import(
|
|
203
|
+
value: function _import(filename) {
|
|
194
204
|
return _async_to_generator(function() {
|
|
195
205
|
var module, e;
|
|
196
206
|
return _ts_generator(this, function(_state) {
|
|
@@ -204,7 +214,7 @@ var DynamicImportStrategy = /*#__PURE__*/ function() {
|
|
|
204
214
|
]);
|
|
205
215
|
return [
|
|
206
216
|
4,
|
|
207
|
-
import("".concat(this.brainsDir, "/").concat(
|
|
217
|
+
import("".concat(this.brainsDir, "/").concat(filename, ".ts"))
|
|
208
218
|
];
|
|
209
219
|
case 1:
|
|
210
220
|
module = _state.sent();
|
|
@@ -214,7 +224,7 @@ var DynamicImportStrategy = /*#__PURE__*/ function() {
|
|
|
214
224
|
];
|
|
215
225
|
case 2:
|
|
216
226
|
e = _state.sent();
|
|
217
|
-
console.error("Failed to import brain ".concat(
|
|
227
|
+
console.error("Failed to import brain ".concat(filename, ":"), e);
|
|
218
228
|
return [
|
|
219
229
|
2,
|
|
220
230
|
undefined
|
|
@@ -228,6 +238,20 @@ var DynamicImportStrategy = /*#__PURE__*/ function() {
|
|
|
228
238
|
}).call(this);
|
|
229
239
|
}
|
|
230
240
|
},
|
|
241
|
+
{
|
|
242
|
+
key: "resolve",
|
|
243
|
+
value: function resolve(identifier) {
|
|
244
|
+
// For dynamic imports, we can only do simple filename matching
|
|
245
|
+
return this.import(identifier).then(function(brain) {
|
|
246
|
+
return brain ? {
|
|
247
|
+
matchType: 'exact',
|
|
248
|
+
brain: brain
|
|
249
|
+
} : {
|
|
250
|
+
matchType: 'none'
|
|
251
|
+
};
|
|
252
|
+
}); // Type assertion needed due to async
|
|
253
|
+
}
|
|
254
|
+
},
|
|
231
255
|
{
|
|
232
256
|
key: "list",
|
|
233
257
|
value: function list() {
|
|
@@ -245,28 +269,34 @@ export var PositronicManifest = /*#__PURE__*/ function() {
|
|
|
245
269
|
function PositronicManifest(options) {
|
|
246
270
|
_class_call_check(this, PositronicManifest);
|
|
247
271
|
_define_property(this, "importStrategy", void 0);
|
|
248
|
-
if (options.
|
|
249
|
-
throw new Error('Cannot provide both
|
|
272
|
+
if (options.manifest && options.brainsDir) {
|
|
273
|
+
throw new Error('Cannot provide both manifest and brainsDir - choose one import strategy');
|
|
250
274
|
}
|
|
251
|
-
if (!options.
|
|
252
|
-
throw new Error('Must provide either
|
|
275
|
+
if (!options.manifest && !options.brainsDir) {
|
|
276
|
+
throw new Error('Must provide either manifest or brainsDir');
|
|
253
277
|
}
|
|
254
|
-
this.importStrategy = options.
|
|
278
|
+
this.importStrategy = options.manifest ? new StaticManifestStrategy(options.manifest) : new DynamicImportStrategy(options.brainsDir);
|
|
255
279
|
}
|
|
256
280
|
_create_class(PositronicManifest, [
|
|
257
281
|
{
|
|
258
282
|
key: "import",
|
|
259
|
-
value: function _import(
|
|
283
|
+
value: function _import(filename) {
|
|
260
284
|
return _async_to_generator(function() {
|
|
261
285
|
return _ts_generator(this, function(_state) {
|
|
262
286
|
return [
|
|
263
287
|
2,
|
|
264
|
-
this.importStrategy.import(
|
|
288
|
+
this.importStrategy.import(filename)
|
|
265
289
|
];
|
|
266
290
|
});
|
|
267
291
|
}).call(this);
|
|
268
292
|
}
|
|
269
293
|
},
|
|
294
|
+
{
|
|
295
|
+
key: "resolve",
|
|
296
|
+
value: function resolve(identifier) {
|
|
297
|
+
return this.importStrategy.resolve(identifier);
|
|
298
|
+
}
|
|
299
|
+
},
|
|
270
300
|
{
|
|
271
301
|
key: "list",
|
|
272
302
|
value: function list() {
|
package/dist/src/schedule-do.js
CHANGED
|
@@ -253,13 +253,13 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
253
253
|
]), _define_property(_this, "storage", void 0);
|
|
254
254
|
_this.storage = state.storage.sql;
|
|
255
255
|
// Initialize database schema
|
|
256
|
-
_this.storage.exec("\n CREATE TABLE IF NOT EXISTS schedules (\n id TEXT PRIMARY KEY,\n
|
|
256
|
+
_this.storage.exec("\n CREATE TABLE IF NOT EXISTS schedules (\n id TEXT PRIMARY KEY,\n brain_title TEXT NOT NULL,\n cron_expression TEXT NOT NULL,\n enabled INTEGER NOT NULL DEFAULT 1,\n created_at INTEGER NOT NULL,\n next_run_at INTEGER\n );\n\n CREATE INDEX IF NOT EXISTS idx_schedules_brain\n ON schedules(brain_title);\n\n CREATE INDEX IF NOT EXISTS idx_schedules_enabled\n ON schedules(enabled);\n\n CREATE TABLE IF NOT EXISTS scheduled_runs (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n schedule_id TEXT NOT NULL,\n brain_run_id TEXT UNIQUE,\n status TEXT NOT NULL CHECK(status IN ('triggered', 'failed', 'complete')),\n ran_at INTEGER NOT NULL,\n completed_at INTEGER,\n error TEXT,\n FOREIGN KEY (schedule_id) REFERENCES schedules(id) ON DELETE CASCADE\n );\n\n CREATE INDEX IF NOT EXISTS idx_runs_schedule\n ON scheduled_runs(schedule_id, ran_at DESC);\n ");
|
|
257
257
|
return _this;
|
|
258
258
|
}
|
|
259
259
|
_create_class(ScheduleDO, [
|
|
260
260
|
{
|
|
261
261
|
key: "createSchedule",
|
|
262
|
-
value: function createSchedule(
|
|
262
|
+
value: function createSchedule(brainTitle, cronExpression) {
|
|
263
263
|
return _async_to_generator(function() {
|
|
264
264
|
var id, createdAt, alarm, cron, nextRunAt;
|
|
265
265
|
return _ts_generator(this, function(_state) {
|
|
@@ -293,12 +293,12 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
293
293
|
// Calculate next run time
|
|
294
294
|
cron = parseCronExpression(cronExpression);
|
|
295
295
|
nextRunAt = this.calculateNextRunTime(cron, createdAt);
|
|
296
|
-
this.storage.exec("INSERT INTO schedules (id,
|
|
296
|
+
this.storage.exec("INSERT INTO schedules (id, brain_title, cron_expression, enabled, created_at, next_run_at)\n VALUES (?, ?, ?, 1, ?, ?)", id, brainTitle, cronExpression, createdAt, nextRunAt);
|
|
297
297
|
return [
|
|
298
298
|
2,
|
|
299
299
|
{
|
|
300
300
|
id: id,
|
|
301
|
-
|
|
301
|
+
brainTitle: brainTitle,
|
|
302
302
|
cronExpression: cronExpression,
|
|
303
303
|
enabled: true,
|
|
304
304
|
createdAt: createdAt,
|
|
@@ -316,7 +316,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
316
316
|
return _async_to_generator(function() {
|
|
317
317
|
var results, result;
|
|
318
318
|
return _ts_generator(this, function(_state) {
|
|
319
|
-
results = this.storage.exec("SELECT id,
|
|
319
|
+
results = this.storage.exec("SELECT id, brain_title, cron_expression, enabled, created_at, next_run_at\n FROM schedules WHERE id = ?", scheduleId).toArray();
|
|
320
320
|
if (results.length === 0) {
|
|
321
321
|
return [
|
|
322
322
|
2,
|
|
@@ -328,7 +328,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
328
328
|
2,
|
|
329
329
|
{
|
|
330
330
|
id: result.id,
|
|
331
|
-
|
|
331
|
+
brainTitle: result.brain_title,
|
|
332
332
|
cronExpression: result.cron_expression,
|
|
333
333
|
enabled: result.enabled === 1,
|
|
334
334
|
createdAt: result.created_at,
|
|
@@ -408,10 +408,10 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
408
408
|
_state.sent();
|
|
409
409
|
_state.label = 4;
|
|
410
410
|
case 4:
|
|
411
|
-
schedules = this.storage.exec("SELECT id,
|
|
411
|
+
schedules = this.storage.exec("SELECT id, brain_title, cron_expression, enabled, created_at, next_run_at\n FROM schedules\n ORDER BY created_at DESC").toArray().map(function(row) {
|
|
412
412
|
return {
|
|
413
413
|
id: row.id,
|
|
414
|
-
|
|
414
|
+
brainTitle: row.brain_title,
|
|
415
415
|
cronExpression: row.cron_expression,
|
|
416
416
|
enabled: row.enabled === 1,
|
|
417
417
|
createdAt: row.created_at,
|
|
@@ -485,7 +485,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
485
485
|
value: // Handle the alarm trigger - runs every minute in a perpetual cycle
|
|
486
486
|
function alarm() {
|
|
487
487
|
return _async_to_generator(function() {
|
|
488
|
-
var now, dueSchedules, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, schedule, scheduleId,
|
|
488
|
+
var now, dueSchedules, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, schedule, scheduleId, brainTitle, cronExpression, brainRunId, error, errorMessage, cron, nextRunAt, err;
|
|
489
489
|
return _ts_generator(this, function(_state) {
|
|
490
490
|
switch(_state.label){
|
|
491
491
|
case 0:
|
|
@@ -500,7 +500,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
500
500
|
// checking every minute ensures we never miss a scheduled run.
|
|
501
501
|
// Get all enabled schedules that are due
|
|
502
502
|
now = Date.now();
|
|
503
|
-
dueSchedules = this.storage.exec("SELECT id,
|
|
503
|
+
dueSchedules = this.storage.exec("SELECT id, brain_title, cron_expression\n FROM schedules\n WHERE enabled = 1 AND next_run_at <= ?", now).toArray();
|
|
504
504
|
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
505
505
|
_state.label = 1;
|
|
506
506
|
case 1:
|
|
@@ -519,7 +519,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
519
519
|
];
|
|
520
520
|
schedule = _step.value;
|
|
521
521
|
scheduleId = schedule.id;
|
|
522
|
-
|
|
522
|
+
brainTitle = schedule.brain_title;
|
|
523
523
|
cronExpression = schedule.cron_expression;
|
|
524
524
|
_state.label = 3;
|
|
525
525
|
case 3:
|
|
@@ -531,7 +531,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
531
531
|
]);
|
|
532
532
|
return [
|
|
533
533
|
4,
|
|
534
|
-
this.triggerBrainRun(
|
|
534
|
+
this.triggerBrainRun(brainTitle)
|
|
535
535
|
];
|
|
536
536
|
case 4:
|
|
537
537
|
brainRunId = _state.sent();
|
|
@@ -546,7 +546,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
546
546
|
// Record failed run
|
|
547
547
|
errorMessage = _instanceof(error, Error) ? error.message : 'Unknown error';
|
|
548
548
|
this.storage.exec("INSERT INTO scheduled_runs (schedule_id, status, ran_at, error)\n VALUES (?, 'failed', ?, ?)", scheduleId, now, errorMessage);
|
|
549
|
-
console.error("[ScheduleDO] Failed to trigger brain ".concat(
|
|
549
|
+
console.error("[ScheduleDO] Failed to trigger brain ".concat(brainTitle, ":"), error);
|
|
550
550
|
return [
|
|
551
551
|
3,
|
|
552
552
|
6
|
|
@@ -621,7 +621,7 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
621
621
|
},
|
|
622
622
|
{
|
|
623
623
|
key: "triggerBrainRun",
|
|
624
|
-
value: function triggerBrainRun(
|
|
624
|
+
value: function triggerBrainRun(brainTitle) {
|
|
625
625
|
return _async_to_generator(function() {
|
|
626
626
|
var brainRunId, namespace, doId, stub;
|
|
627
627
|
return _ts_generator(this, function(_state) {
|
|
@@ -631,10 +631,10 @@ export var ScheduleDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
631
631
|
namespace = this.env.BRAIN_RUNNER_DO;
|
|
632
632
|
doId = namespace.idFromName(brainRunId);
|
|
633
633
|
stub = namespace.get(doId);
|
|
634
|
-
console.log("[ScheduleDO] Triggering brain run ".concat(
|
|
634
|
+
console.log("[ScheduleDO] Triggering brain run ".concat(brainTitle, " with id ").concat(brainRunId));
|
|
635
635
|
return [
|
|
636
636
|
4,
|
|
637
|
-
stub.start(
|
|
637
|
+
stub.start(brainTitle, brainRunId)
|
|
638
638
|
];
|
|
639
639
|
case 1:
|
|
640
640
|
_state.sent();
|
package/dist/types/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgB,MAAM,MAAM,CAAC;AAI1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAA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CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAmBF,QAAA,MAAM,GAAG;cAAwB,QAAQ;yCAAK,CAAC;AAupB/C,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Brain } from '@positronic/core';
|
|
2
|
+
export interface BrainMetadata {
|
|
3
|
+
filename: string;
|
|
4
|
+
path: string;
|
|
5
|
+
brain: Brain;
|
|
6
|
+
}
|
|
7
|
+
export interface BrainCandidate {
|
|
8
|
+
title: string;
|
|
9
|
+
filename: string;
|
|
10
|
+
path: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ResolutionResult {
|
|
14
|
+
matchType: 'exact' | 'multiple' | 'none';
|
|
15
|
+
brain?: Brain;
|
|
16
|
+
candidates?: BrainCandidate[];
|
|
17
|
+
}
|
|
18
|
+
export declare class BrainResolver {
|
|
19
|
+
private enhancedManifest;
|
|
20
|
+
private metadataCache;
|
|
21
|
+
constructor(enhancedManifest: Record<string, BrainMetadata>);
|
|
22
|
+
resolve(identifier: string): ResolutionResult;
|
|
23
|
+
/**
|
|
24
|
+
* Get a brain by exact filename (used for backward compatibility)
|
|
25
|
+
*/
|
|
26
|
+
getByFilename(filename: string): Brain | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* List all available brains
|
|
29
|
+
*/
|
|
30
|
+
list(): string[];
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=brain-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brain-resolver.d.ts","sourceRoot":"","sources":["../../src/brain-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;IACzC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;CAC/B;AAED,qBAAa,aAAa;IAGZ,OAAO,CAAC,gBAAgB;IAFpC,OAAO,CAAC,aAAa,CAAmE;gBAEpE,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAanE,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB;IAuF7C;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS;IAKlD;;OAEG;IACH,IAAI,IAAI,MAAM,EAAE;CAGjB"}
|
|
@@ -19,7 +19,7 @@ export declare class BrainRunnerDO extends DurableObject<Env> {
|
|
|
19
19
|
private eventStreamAdapter;
|
|
20
20
|
constructor(state: DurableObjectState, env: Env);
|
|
21
21
|
private loadResourcesFromR2;
|
|
22
|
-
start(
|
|
22
|
+
start(brainTitle: string, brainRunId: string, initialData?: Record<string, any>): Promise<void>;
|
|
23
23
|
fetch(request: Request): Promise<Response>;
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=brain-runner-do.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brain-runner-do.d.ts","sourceRoot":"","sources":["../../src/brain-runner-do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,UAA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kBAAkB,GAAG,IAAI,CAEvD;AAGD,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,QAEjD;AAED,MAAM,WAAW,GAAG;IAClB,eAAe,EAAE,sBAAsB,CAAC;IACxC,UAAU,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAC9C,WAAW,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAChD,gBAAgB,EAAE,QAAQ,CAAC;CAC5B;AAwDD,qBAAa,aAAc,SAAQ,aAAa,CAAC,GAAG,CAAC;IACnD,OAAO,CAAC,GAAG,CAAa;IACxB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,kBAAkB,CAA4B;gBAE1C,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG;YAOjC,mBAAmB;IA0E3B,KAAK,CACT,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAgE7B,KAAK,CAAC,OAAO,EAAE,OAAO;CA4E7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/dev-server.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/dev-server.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA8L1E,qBAAa,mBAAoB,YAAW,mBAAmB;IAyB1C,cAAc,EAAE,MAAM;IAjBzC;;;;;;;;;;;OAWG;IAEH,OAAO,CAAC,YAAY,CAAwC;IAC5D,OAAO,CAAC,cAAc,CAAwC;IAC9D,OAAO,CAAC,gBAAgB,CAAwC;gBAE7C,cAAc,EAAE,MAAM;IAEnC,KAAK,CAAC,KAAK,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ain-runner-do.js';
|
|
2
2
|
export { MonitorDO } from './monitor-do.js';
|
|
3
3
|
export { ScheduleDO } from './schedule-do.js';
|
|
4
|
-
export { PositronicManifest } from './manifest.js';
|
|
4
|
+
export { PositronicManifest, type BrainMetadata, type ResolutionResult } from './manifest.js';
|
|
5
5
|
export { default as api } from './api.js';
|
|
6
6
|
export { CloudflareR2Loader } from './r2-loader.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,WAAW,EACX,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,WAAW,EACX,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/types/manifest.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { Brain } from '@positronic/core';
|
|
2
|
+
import { type BrainMetadata, type ResolutionResult } from './brain-resolver.js';
|
|
3
|
+
export type { BrainMetadata, ResolutionResult } from './brain-resolver.js';
|
|
2
4
|
export declare class PositronicManifest {
|
|
3
5
|
private importStrategy;
|
|
4
6
|
constructor(options: {
|
|
5
|
-
|
|
7
|
+
manifest?: Record<string, BrainMetadata>;
|
|
6
8
|
brainsDir?: string;
|
|
7
9
|
});
|
|
8
|
-
import(
|
|
10
|
+
import(filename: string): Promise<Brain | undefined>;
|
|
11
|
+
resolve(identifier: string): ResolutionResult;
|
|
9
12
|
list(): string[];
|
|
10
13
|
}
|
|
11
14
|
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAiB,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE/F,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAwD3E,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,cAAc,CAAsB;gBAEhC,OAAO,EAAE;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;QACzC,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB;IAeK,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC;IAI1D,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB;IAI7C,IAAI,IAAI,MAAM,EAAE;CAGjB"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* This file is used when importing from Node.js environments (like the CLI)
|
|
4
4
|
* and excludes any Cloudflare Workers-specific modules.
|
|
5
5
|
*/
|
|
6
|
-
export { PositronicManifest } from './manifest.js';
|
|
6
|
+
export { PositronicManifest, type BrainMetadata, type ResolutionResult } from './manifest.js';
|
|
7
7
|
export { CloudflareR2Loader } from './r2-loader.js';
|
|
8
8
|
export { CloudflareDevServer } from './dev-server.js';
|
|
9
9
|
export { CloudflareDevServer as DevServer } from './dev-server.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-index.d.ts","sourceRoot":"","sources":["../../src/node-index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"node-index.d.ts","sourceRoot":"","sources":["../../src/node-index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,mBAAmB,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -8,7 +8,7 @@ export interface Env {
|
|
|
8
8
|
}
|
|
9
9
|
interface Schedule {
|
|
10
10
|
id: string;
|
|
11
|
-
|
|
11
|
+
brainTitle: string;
|
|
12
12
|
cronExpression: string;
|
|
13
13
|
enabled: boolean;
|
|
14
14
|
createdAt: number;
|
|
@@ -26,7 +26,7 @@ interface ScheduledRun {
|
|
|
26
26
|
export declare class ScheduleDO extends DurableObject<Env> {
|
|
27
27
|
private readonly storage;
|
|
28
28
|
constructor(state: DurableObjectState, env: Env);
|
|
29
|
-
createSchedule(
|
|
29
|
+
createSchedule(brainTitle: string, cronExpression: string): Promise<Schedule>;
|
|
30
30
|
getSchedule(scheduleId: string): Promise<Schedule | null>;
|
|
31
31
|
deleteSchedule(scheduleId: string): Promise<boolean>;
|
|
32
32
|
listSchedules(): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule-do.d.ts","sourceRoot":"","sources":["../../src/schedule-do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,WAAW,GAAG;IAClB,eAAe,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,
|
|
1
|
+
{"version":3,"file":"schedule-do.d.ts","sourceRoot":"","sources":["../../src/schedule-do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,WAAW,GAAG;IAClB,eAAe,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAA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{
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"clean": "rm -rf tsconfig.tsbuildinfo dist"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@positronic/core": "^0.0.
|
|
35
|
-
"@positronic/spec": "^0.0.
|
|
36
|
-
"@positronic/template-new-project": "^0.0.
|
|
34
|
+
"@positronic/core": "^0.0.16",
|
|
35
|
+
"@positronic/spec": "^0.0.16",
|
|
36
|
+
"@positronic/template-new-project": "^0.0.16",
|
|
37
37
|
"aws4fetch": "^1.0.18",
|
|
38
38
|
"caz": "^2.0.0",
|
|
39
39
|
"cron-schedule": "^5.0.4",
|