@positronic/core 0.0.76 → 0.0.78
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/dsl/brain-runner.js +37 -182
- package/dist/src/dsl/brain-state-machine.js +58 -112
- package/dist/src/dsl/brain.js +1 -0
- package/dist/src/dsl/builder/brain.js +250 -404
- package/dist/src/dsl/builder/continuation.js +67 -0
- package/dist/src/dsl/constants.js +16 -17
- package/dist/src/dsl/create-brain.js +29 -45
- package/dist/src/dsl/example-webhook.js +1 -1
- package/dist/src/dsl/execution/constants.js +0 -4
- package/dist/src/dsl/execution/event-channel.js +77 -0
- package/dist/src/dsl/execution/event-stream.js +1625 -1462
- package/dist/src/dsl/signal-validation.js +0 -1
- package/dist/src/dsl/webhook.js +4 -1
- package/dist/src/files/event-wrapper.js +268 -0
- package/dist/src/files/index.js +1 -0
- package/dist/src/files/mime.js +31 -0
- package/dist/src/files/types.js +13 -0
- package/dist/src/index.js +10 -3
- package/dist/src/jsx-runtime.js +49 -0
- package/dist/src/memory/{scoped-memory.js → create-memory.js} +5 -5
- package/dist/src/plugins/collect-webhooks.js +49 -0
- package/dist/src/plugins/define-plugin.js +15 -0
- package/dist/src/plugins/index.js +1 -0
- package/dist/src/plugins/types.js +4 -0
- package/dist/src/store/types.js +2 -3
- package/dist/src/template/render-html.js +282 -0
- package/dist/src/template/render.js +357 -0
- package/dist/src/tools/index.js +88 -27
- package/dist/src/ui/generate-page-html.js +6 -6
- package/dist/src/ui/{generate-ui.js → generate-page.js} +24 -12
- package/dist/src/ui/parse-form-data.js +1 -11
- package/dist/src/ui/types.js +0 -123
- package/dist/src/yaml/data-validator.js +0 -27
- package/dist/src/yaml/type-inference.js +10 -9
- package/dist/types/clients/types.d.ts +15 -5
- package/dist/types/clients/types.d.ts.map +1 -1
- package/dist/types/dsl/brain-runner.d.ts +9 -14
- package/dist/types/dsl/brain-runner.d.ts.map +1 -1
- package/dist/types/dsl/brain-state-machine.d.ts +18 -28
- package/dist/types/dsl/brain-state-machine.d.ts.map +1 -1
- package/dist/types/dsl/brain.d.ts +3 -2
- package/dist/types/dsl/brain.d.ts.map +1 -1
- package/dist/types/dsl/builder/brain.d.ts +87 -230
- package/dist/types/dsl/builder/brain.d.ts.map +1 -1
- package/dist/types/dsl/builder/continuation.d.ts +16 -0
- package/dist/types/dsl/builder/continuation.d.ts.map +1 -0
- package/dist/types/dsl/constants.d.ts +12 -12
- package/dist/types/dsl/constants.d.ts.map +1 -1
- package/dist/types/dsl/create-brain.d.ts +17 -57
- package/dist/types/dsl/create-brain.d.ts.map +1 -1
- package/dist/types/dsl/definitions/blocks.d.ts +67 -55
- package/dist/types/dsl/definitions/blocks.d.ts.map +1 -1
- package/dist/types/dsl/definitions/brain-types.d.ts +8 -11
- package/dist/types/dsl/definitions/brain-types.d.ts.map +1 -1
- package/dist/types/dsl/definitions/events.d.ts +61 -55
- package/dist/types/dsl/definitions/events.d.ts.map +1 -1
- package/dist/types/dsl/definitions/run-params.d.ts +20 -21
- package/dist/types/dsl/definitions/run-params.d.ts.map +1 -1
- package/dist/types/dsl/definitions/steps.d.ts +1 -1
- package/dist/types/dsl/definitions/steps.d.ts.map +1 -1
- package/dist/types/dsl/example-webhook.d.ts +3 -3
- package/dist/types/dsl/example-webhook.d.ts.map +1 -1
- package/dist/types/dsl/execution/constants.d.ts +0 -5
- package/dist/types/dsl/execution/constants.d.ts.map +1 -1
- package/dist/types/dsl/execution/event-channel.d.ts +16 -0
- package/dist/types/dsl/execution/event-channel.d.ts.map +1 -0
- package/dist/types/dsl/execution/event-stream.d.ts +46 -34
- package/dist/types/dsl/execution/event-stream.d.ts.map +1 -1
- package/dist/types/dsl/signal-validation.d.ts.map +1 -1
- package/dist/types/dsl/types.d.ts +21 -83
- package/dist/types/dsl/types.d.ts.map +1 -1
- package/dist/types/dsl/webhook.d.ts +12 -2
- package/dist/types/dsl/webhook.d.ts.map +1 -1
- package/dist/types/files/event-wrapper.d.ts +20 -0
- package/dist/types/files/event-wrapper.d.ts.map +1 -0
- package/dist/types/files/index.d.ts +2 -0
- package/dist/types/files/index.d.ts.map +1 -0
- package/dist/types/files/mime.d.ts +2 -0
- package/dist/types/files/mime.d.ts.map +1 -0
- package/dist/types/files/types.d.ts +88 -0
- package/dist/types/files/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +22 -12
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/jsx-runtime.d.ts +35 -0
- package/dist/types/jsx-runtime.d.ts.map +1 -0
- package/dist/types/memory/{scoped-memory.d.ts → create-memory.d.ts} +7 -7
- package/dist/types/memory/create-memory.d.ts.map +1 -0
- package/dist/types/memory/types.d.ts +4 -4
- package/dist/types/memory/types.d.ts.map +1 -1
- package/dist/types/plugins/collect-webhooks.d.ts +8 -0
- package/dist/types/plugins/collect-webhooks.d.ts.map +1 -0
- package/dist/types/plugins/define-plugin.d.ts +25 -0
- package/dist/types/plugins/define-plugin.d.ts.map +1 -0
- package/dist/types/plugins/index.d.ts +3 -0
- package/dist/types/plugins/index.d.ts.map +1 -0
- package/dist/types/plugins/types.d.ts +83 -0
- package/dist/types/plugins/types.d.ts.map +1 -0
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/index.d.ts.map +1 -1
- package/dist/types/store/types.d.ts +0 -8
- package/dist/types/store/types.d.ts.map +1 -1
- package/dist/types/template/render-html.d.ts +9 -0
- package/dist/types/template/render-html.d.ts.map +1 -0
- package/dist/types/template/render.d.ts +15 -0
- package/dist/types/template/render.d.ts.map +1 -0
- package/dist/types/tools/index.d.ts +39 -27
- package/dist/types/tools/index.d.ts.map +1 -1
- package/dist/types/ui/generate-page-html.d.ts +4 -6
- package/dist/types/ui/generate-page-html.d.ts.map +1 -1
- package/dist/types/ui/{generate-ui.d.ts → generate-page.d.ts} +6 -6
- package/dist/types/ui/generate-page.d.ts.map +1 -0
- package/dist/types/ui/parse-form-data.d.ts +1 -5
- package/dist/types/ui/parse-form-data.d.ts.map +1 -1
- package/dist/types/ui/types.d.ts +0 -49
- package/dist/types/ui/types.d.ts.map +1 -1
- package/dist/types/yaml/data-validator.d.ts +0 -5
- package/dist/types/yaml/data-validator.d.ts.map +1 -1
- package/dist/types/yaml/type-inference.d.ts +4 -2
- package/dist/types/yaml/type-inference.d.ts.map +1 -1
- package/dist/types/yaml/types.d.ts +0 -1
- package/dist/types/yaml/types.d.ts.map +1 -1
- package/package.json +5 -1
- package/dist/src/dsl/agent-messages.js +0 -5
- package/dist/src/ui/validate-form.js +0 -428
- package/dist/types/dsl/agent-messages.d.ts +0 -12
- package/dist/types/dsl/agent-messages.d.ts.map +0 -1
- package/dist/types/memory/scoped-memory.d.ts.map +0 -1
- package/dist/types/ui/generate-ui.d.ts.map +0 -1
- package/dist/types/ui/validate-form.d.ts +0 -45
- package/dist/types/ui/validate-form.d.ts.map +0 -1
|
@@ -1,3 +1,11 @@
|
|
|
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_without_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
8
|
+
}
|
|
1
9
|
function _async_generator(gen) {
|
|
2
10
|
var front, back;
|
|
3
11
|
function send(key, arg) {
|
|
@@ -216,6 +224,12 @@ function _define_property(obj, key, value) {
|
|
|
216
224
|
}
|
|
217
225
|
return obj;
|
|
218
226
|
}
|
|
227
|
+
function _iterable_to_array(iter) {
|
|
228
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
229
|
+
}
|
|
230
|
+
function _non_iterable_spread() {
|
|
231
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
232
|
+
}
|
|
219
233
|
function _object_spread(target) {
|
|
220
234
|
for(var i = 1; i < arguments.length; i++){
|
|
221
235
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -255,13 +269,47 @@ function _object_spread_props(target, source) {
|
|
|
255
269
|
}
|
|
256
270
|
return target;
|
|
257
271
|
}
|
|
272
|
+
function _object_without_properties(source, excluded) {
|
|
273
|
+
if (source == null) return {};
|
|
274
|
+
var target = _object_without_properties_loose(source, excluded);
|
|
275
|
+
var key, i;
|
|
276
|
+
if (Object.getOwnPropertySymbols) {
|
|
277
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
278
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
279
|
+
key = sourceSymbolKeys[i];
|
|
280
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
281
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
282
|
+
target[key] = source[key];
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return target;
|
|
286
|
+
}
|
|
287
|
+
function _object_without_properties_loose(source, excluded) {
|
|
288
|
+
if (source == null) return {};
|
|
289
|
+
var target = {};
|
|
290
|
+
var sourceKeys = Object.keys(source);
|
|
291
|
+
var key, i;
|
|
292
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
293
|
+
key = sourceKeys[i];
|
|
294
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
295
|
+
target[key] = source[key];
|
|
296
|
+
}
|
|
297
|
+
return target;
|
|
298
|
+
}
|
|
258
299
|
function _overload_yield(value, kind) {
|
|
259
300
|
this.v = value;
|
|
260
301
|
this.k = kind;
|
|
261
302
|
}
|
|
262
|
-
function
|
|
263
|
-
|
|
264
|
-
|
|
303
|
+
function _to_consumable_array(arr) {
|
|
304
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
305
|
+
}
|
|
306
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
307
|
+
if (!o) return;
|
|
308
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
309
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
310
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
311
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
312
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
265
313
|
}
|
|
266
314
|
function _wrap_async_generator(fn) {
|
|
267
315
|
return function() {
|
|
@@ -373,9 +421,59 @@ function _ts_values(o) {
|
|
|
373
421
|
};
|
|
374
422
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
375
423
|
}
|
|
376
|
-
import {
|
|
424
|
+
import { Continuation } from './continuation.js';
|
|
377
425
|
import { BrainEventStream } from '../execution/event-stream.js';
|
|
378
426
|
import { parseDuration } from '../duration.js';
|
|
427
|
+
/**
|
|
428
|
+
* Merge parent and own plugin configs, call create() for each, separate adapters from injections.
|
|
429
|
+
*/ function resolvePlugins(parentConfigs, ownConfigs, ctx) {
|
|
430
|
+
// Own configs override parent by plugin name
|
|
431
|
+
var merged = _to_consumable_array(parentConfigs.filter(function(p) {
|
|
432
|
+
return !ownConfigs.some(function(own) {
|
|
433
|
+
return own.__plugin.name === p.__plugin.name;
|
|
434
|
+
});
|
|
435
|
+
})).concat(_to_consumable_array(ownConfigs));
|
|
436
|
+
var injections = {};
|
|
437
|
+
var adapters = [];
|
|
438
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
439
|
+
try {
|
|
440
|
+
for(var _iterator = merged[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
441
|
+
var _ref = _step.value;
|
|
442
|
+
var configured = _ref;
|
|
443
|
+
var plugin = configured.__plugin, config = configured.__config;
|
|
444
|
+
var _plugin_create = plugin.create({
|
|
445
|
+
config: config,
|
|
446
|
+
brainTitle: ctx.brainTitle,
|
|
447
|
+
currentUser: ctx.currentUser,
|
|
448
|
+
brainRunId: ctx.brainRunId
|
|
449
|
+
}), adapter = _plugin_create.adapter, injection = _object_without_properties(_plugin_create, [
|
|
450
|
+
"adapter"
|
|
451
|
+
]);
|
|
452
|
+
injections[plugin.name] = injection;
|
|
453
|
+
if (adapter) {
|
|
454
|
+
adapters.push(adapter);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
} catch (err) {
|
|
458
|
+
_didIteratorError = true;
|
|
459
|
+
_iteratorError = err;
|
|
460
|
+
} finally{
|
|
461
|
+
try {
|
|
462
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
463
|
+
_iterator.return();
|
|
464
|
+
}
|
|
465
|
+
} finally{
|
|
466
|
+
if (_didIteratorError) {
|
|
467
|
+
throw _iteratorError;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return {
|
|
472
|
+
injections: injections,
|
|
473
|
+
adapters: adapters,
|
|
474
|
+
configs: merged
|
|
475
|
+
};
|
|
476
|
+
}
|
|
379
477
|
export var Brain = /*#__PURE__*/ function() {
|
|
380
478
|
"use strict";
|
|
381
479
|
function Brain(title, description) {
|
|
@@ -384,18 +482,15 @@ export var Brain = /*#__PURE__*/ function() {
|
|
|
384
482
|
_define_property(this, "description", void 0);
|
|
385
483
|
_define_property(this, "blocks", void 0);
|
|
386
484
|
_define_property(this, "type", void 0);
|
|
387
|
-
_define_property(this, "services", void 0);
|
|
388
485
|
_define_property(this, "optionsSchema", void 0);
|
|
389
486
|
_define_property(this, "components", void 0);
|
|
390
|
-
_define_property(this, "defaultTools", void 0);
|
|
391
|
-
_define_property(this, "extraTools", void 0);
|
|
392
|
-
_define_property(this, "memoryProvider", void 0);
|
|
393
487
|
_define_property(this, "storeSchema", void 0);
|
|
488
|
+
_define_property(this, "pluginConfigs", void 0);
|
|
394
489
|
this.title = title;
|
|
395
490
|
this.description = description;
|
|
396
491
|
this.blocks = [];
|
|
397
492
|
this.type = 'brain';
|
|
398
|
-
this.
|
|
493
|
+
this.pluginConfigs = [];
|
|
399
494
|
}
|
|
400
495
|
_create_class(Brain, [
|
|
401
496
|
{
|
|
@@ -410,11 +505,6 @@ export var Brain = /*#__PURE__*/ function() {
|
|
|
410
505
|
type: 'step',
|
|
411
506
|
title: block.title
|
|
412
507
|
};
|
|
413
|
-
} else if (block.type === 'agent') {
|
|
414
|
-
return {
|
|
415
|
-
type: 'agent',
|
|
416
|
-
title: block.title
|
|
417
|
-
};
|
|
418
508
|
} else if (block.type === 'guard') {
|
|
419
509
|
return {
|
|
420
510
|
type: 'guard',
|
|
@@ -425,6 +515,16 @@ export var Brain = /*#__PURE__*/ function() {
|
|
|
425
515
|
type: 'wait',
|
|
426
516
|
title: block.title
|
|
427
517
|
};
|
|
518
|
+
} else if (block.type === 'map') {
|
|
519
|
+
return {
|
|
520
|
+
type: 'map',
|
|
521
|
+
title: block.title
|
|
522
|
+
};
|
|
523
|
+
} else if (block.type === 'prompt') {
|
|
524
|
+
return {
|
|
525
|
+
type: 'prompt',
|
|
526
|
+
title: block.title
|
|
527
|
+
};
|
|
428
528
|
} else {
|
|
429
529
|
// block.type === 'brain'
|
|
430
530
|
return {
|
|
@@ -438,39 +538,17 @@ export var Brain = /*#__PURE__*/ function() {
|
|
|
438
538
|
}
|
|
439
539
|
},
|
|
440
540
|
{
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
value: function withServices(services) {
|
|
444
|
-
var nextBrain = new Brain(this.title, this.description).withBlocks(this.blocks);
|
|
445
|
-
// Set services
|
|
446
|
-
nextBrain.services = services;
|
|
447
|
-
// Copy optionsSchema to maintain it through the chain
|
|
448
|
-
nextBrain.optionsSchema = this.optionsSchema;
|
|
449
|
-
nextBrain.components = this.components;
|
|
450
|
-
nextBrain.defaultTools = this.defaultTools;
|
|
451
|
-
nextBrain.extraTools = this.extraTools;
|
|
452
|
-
nextBrain.memoryProvider = this.memoryProvider;
|
|
453
|
-
nextBrain.storeSchema = this.storeSchema;
|
|
454
|
-
return nextBrain;
|
|
455
|
-
}
|
|
456
|
-
},
|
|
457
|
-
{
|
|
458
|
-
key: "withOptionsSchema",
|
|
459
|
-
value: function withOptionsSchema(schema) {
|
|
541
|
+
key: "withOptions",
|
|
542
|
+
value: function withOptions(schema) {
|
|
460
543
|
var nextBrain = new Brain(this.title, this.description).withBlocks(this.blocks);
|
|
544
|
+
this.copyConfigTo(nextBrain);
|
|
461
545
|
nextBrain.optionsSchema = schema;
|
|
462
|
-
nextBrain.services = this.services;
|
|
463
|
-
nextBrain.components = this.components;
|
|
464
|
-
nextBrain.defaultTools = this.defaultTools;
|
|
465
|
-
nextBrain.extraTools = this.extraTools;
|
|
466
|
-
nextBrain.memoryProvider = this.memoryProvider;
|
|
467
|
-
nextBrain.storeSchema = this.storeSchema;
|
|
468
546
|
return nextBrain;
|
|
469
547
|
}
|
|
470
548
|
},
|
|
471
549
|
{
|
|
472
550
|
/**
|
|
473
|
-
* Configure UI components for
|
|
551
|
+
* Configure UI components for page generation steps.
|
|
474
552
|
*
|
|
475
553
|
* @param components - Record of component definitions
|
|
476
554
|
*
|
|
@@ -480,102 +558,18 @@ export var Brain = /*#__PURE__*/ function() {
|
|
|
480
558
|
*
|
|
481
559
|
* const myBrain = brain('my-brain')
|
|
482
560
|
* .withComponents(components)
|
|
483
|
-
* .
|
|
561
|
+
* .page('Show Form', ({ state }) => ({ prompt: `Create a form for ${state.userName}` }));
|
|
484
562
|
* ```
|
|
485
563
|
*/ key: "withComponents",
|
|
486
564
|
value: function withComponents(components) {
|
|
487
565
|
var nextBrain = new Brain(this.title, this.description).withBlocks(this.blocks);
|
|
488
|
-
|
|
489
|
-
nextBrain.services = this.services;
|
|
566
|
+
this.copyConfigTo(nextBrain);
|
|
490
567
|
nextBrain.components = components;
|
|
491
|
-
nextBrain.defaultTools = this.defaultTools;
|
|
492
|
-
nextBrain.extraTools = this.extraTools;
|
|
493
|
-
nextBrain.memoryProvider = this.memoryProvider;
|
|
494
|
-
nextBrain.storeSchema = this.storeSchema;
|
|
495
568
|
return nextBrain;
|
|
496
569
|
}
|
|
497
570
|
},
|
|
498
571
|
{
|
|
499
572
|
/**
|
|
500
|
-
* Configure default tools for agent steps.
|
|
501
|
-
* These tools will be automatically available in all agent steps and can be
|
|
502
|
-
* extended or overridden in individual step configurations.
|
|
503
|
-
*
|
|
504
|
-
* @param tools - Record of default tool definitions
|
|
505
|
-
*
|
|
506
|
-
* @example
|
|
507
|
-
* ```typescript
|
|
508
|
-
* import { defaultTools } from '@positronic/core';
|
|
509
|
-
*
|
|
510
|
-
* const myBrain = brain('my-brain')
|
|
511
|
-
* .withTools(defaultTools)
|
|
512
|
-
* .brain('agent', ({ tools }) => ({
|
|
513
|
-
* system: 'You are helpful',
|
|
514
|
-
* prompt: 'Do something',
|
|
515
|
-
* tools // uses defaults
|
|
516
|
-
* }));
|
|
517
|
-
* ```
|
|
518
|
-
*/ key: "withTools",
|
|
519
|
-
value: function withTools(tools) {
|
|
520
|
-
var next = this.nextBrain();
|
|
521
|
-
next.defaultTools = tools;
|
|
522
|
-
return next;
|
|
523
|
-
}
|
|
524
|
-
},
|
|
525
|
-
{
|
|
526
|
-
/**
|
|
527
|
-
* Add extra tools on top of whatever default tools are already configured.
|
|
528
|
-
* Unlike `withTools()` which replaces defaults, this merges additively.
|
|
529
|
-
*
|
|
530
|
-
* @param tools - Record of additional tool definitions
|
|
531
|
-
*
|
|
532
|
-
* @example
|
|
533
|
-
* ```typescript
|
|
534
|
-
* const myBrain = createBrain({ defaultTools })
|
|
535
|
-
* ('my-brain')
|
|
536
|
-
* .withExtraTools({ myCustomTool })
|
|
537
|
-
* .brain('agent', ({ tools }) => ({
|
|
538
|
-
* system: 'You are helpful',
|
|
539
|
-
* prompt: 'Do something',
|
|
540
|
-
* tools // includes both defaults and myCustomTool
|
|
541
|
-
* }));
|
|
542
|
-
* ```
|
|
543
|
-
*/ key: "withExtraTools",
|
|
544
|
-
value: function withExtraTools(tools) {
|
|
545
|
-
var next = this.nextBrain();
|
|
546
|
-
next.extraTools = tools;
|
|
547
|
-
return next;
|
|
548
|
-
}
|
|
549
|
-
},
|
|
550
|
-
{
|
|
551
|
-
/**
|
|
552
|
-
* Configure a memory provider for this brain.
|
|
553
|
-
* When configured, steps receive a scoped memory instance in their context.
|
|
554
|
-
*
|
|
555
|
-
* @param provider - The memory provider to use
|
|
556
|
-
*
|
|
557
|
-
* @example
|
|
558
|
-
* ```typescript
|
|
559
|
-
* import { createMem0Provider } from '@positronic/mem0';
|
|
560
|
-
*
|
|
561
|
-
* const memory = createMem0Provider({ apiKey: process.env.MEM0_API_KEY });
|
|
562
|
-
*
|
|
563
|
-
* const myBrain = brain('my-brain')
|
|
564
|
-
* .withMemory(memory)
|
|
565
|
-
* .brain('agent', async ({ memory }) => {
|
|
566
|
-
* const prefs = await memory.search('user preferences');
|
|
567
|
-
* return { system: `User preferences: ${prefs}`, prompt: 'Help me' };
|
|
568
|
-
* });
|
|
569
|
-
* ```
|
|
570
|
-
*/ key: "withMemory",
|
|
571
|
-
value: function withMemory(provider) {
|
|
572
|
-
var next = this.nextBrain();
|
|
573
|
-
next.memoryProvider = provider;
|
|
574
|
-
return next;
|
|
575
|
-
}
|
|
576
|
-
},
|
|
577
|
-
{
|
|
578
|
-
/**
|
|
579
573
|
* Configure a typed key-value store for this brain.
|
|
580
574
|
* When configured, steps receive a `store` object in their context with typed get/set/delete/has.
|
|
581
575
|
*
|
|
@@ -598,16 +592,29 @@ export var Brain = /*#__PURE__*/ function() {
|
|
|
598
592
|
*/ key: "withStore",
|
|
599
593
|
value: function withStore(storeSchema) {
|
|
600
594
|
var nextBrain = new Brain(this.title, this.description).withBlocks(this.blocks);
|
|
601
|
-
|
|
602
|
-
nextBrain.services = this.services;
|
|
603
|
-
nextBrain.components = this.components;
|
|
604
|
-
nextBrain.defaultTools = this.defaultTools;
|
|
605
|
-
nextBrain.extraTools = this.extraTools;
|
|
606
|
-
nextBrain.memoryProvider = this.memoryProvider;
|
|
595
|
+
this.copyConfigTo(nextBrain);
|
|
607
596
|
nextBrain.storeSchema = storeSchema;
|
|
608
597
|
return nextBrain;
|
|
609
598
|
}
|
|
610
599
|
},
|
|
600
|
+
{
|
|
601
|
+
/**
|
|
602
|
+
* Add a plugin to this brain. The plugin's create() is called per brain run,
|
|
603
|
+
* and its return value is placed on StepContext under the plugin name.
|
|
604
|
+
*
|
|
605
|
+
* Replaces any existing plugin with the same name.
|
|
606
|
+
*/ key: "withPlugin",
|
|
607
|
+
value: function withPlugin(plugin) {
|
|
608
|
+
var nextBrain = new Brain(this.title, this.description).withBlocks(this.blocks);
|
|
609
|
+
this.copyConfigTo(nextBrain);
|
|
610
|
+
nextBrain.pluginConfigs = _to_consumable_array(this.pluginConfigs.filter(function(p) {
|
|
611
|
+
return p.__plugin.name !== plugin.__plugin.name;
|
|
612
|
+
})).concat([
|
|
613
|
+
plugin
|
|
614
|
+
]);
|
|
615
|
+
return nextBrain;
|
|
616
|
+
}
|
|
617
|
+
},
|
|
611
618
|
{
|
|
612
619
|
key: "step",
|
|
613
620
|
value: function step(title, action) {
|
|
@@ -631,7 +638,7 @@ export var Brain = /*#__PURE__*/ function() {
|
|
|
631
638
|
timeout: parseDuration(options.timeout)
|
|
632
639
|
});
|
|
633
640
|
this.blocks.push(waitBlock);
|
|
634
|
-
return this.
|
|
641
|
+
return this.continuationCallbacks();
|
|
635
642
|
}
|
|
636
643
|
},
|
|
637
644
|
{
|
|
@@ -647,264 +654,65 @@ export var Brain = /*#__PURE__*/ function() {
|
|
|
647
654
|
}
|
|
648
655
|
},
|
|
649
656
|
{
|
|
650
|
-
//
|
|
657
|
+
// Nested brain — spreads inner brain's final state onto outer state
|
|
651
658
|
key: "brain",
|
|
652
|
-
value: function brain(title,
|
|
653
|
-
|
|
654
|
-
var
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
var nestedBlock = {
|
|
661
|
-
type: 'brain',
|
|
662
|
-
title: title,
|
|
663
|
-
innerBrain: innerBrainOrConfig,
|
|
664
|
-
initialState: function() {
|
|
665
|
-
return {};
|
|
666
|
-
},
|
|
667
|
-
action: function() {
|
|
668
|
-
return {};
|
|
669
|
-
},
|
|
670
|
-
iterateConfig: iterateConfig
|
|
671
|
-
};
|
|
672
|
-
this.blocks.push(nestedBlock);
|
|
673
|
-
return this.nextBrain();
|
|
674
|
-
}
|
|
675
|
-
// Case 1a: Single nested brain (existing behavior)
|
|
676
|
-
var action = actionOrIterateConfig;
|
|
677
|
-
var nestedBlock1 = {
|
|
678
|
-
type: 'brain',
|
|
679
|
-
title: title,
|
|
680
|
-
innerBrain: innerBrainOrConfig,
|
|
681
|
-
initialState: initialState || function() {
|
|
682
|
-
return {};
|
|
683
|
-
},
|
|
684
|
-
action: function(outerState, innerState, services) {
|
|
685
|
-
return action({
|
|
686
|
-
state: outerState,
|
|
687
|
-
brainState: innerState,
|
|
688
|
-
services: services
|
|
689
|
-
});
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
this.blocks.push(nestedBlock1);
|
|
693
|
-
return this.nextBrain();
|
|
694
|
-
}
|
|
695
|
-
// Case 2 & 3: Agent config (object or function)
|
|
696
|
-
if (isIterateConfig) {
|
|
697
|
-
// Agent config with iterate — configFn receives (item, params)
|
|
698
|
-
var iterateConfig1 = actionOrIterateConfig;
|
|
699
|
-
var configFn = innerBrainOrConfig;
|
|
700
|
-
var agentBlock = {
|
|
701
|
-
type: 'agent',
|
|
702
|
-
title: title,
|
|
703
|
-
configFn: configFn,
|
|
704
|
-
iterateConfig: iterateConfig1
|
|
705
|
-
};
|
|
706
|
-
this.blocks.push(agentBlock);
|
|
707
|
-
return this.nextBrain();
|
|
708
|
-
}
|
|
709
|
-
var configFn1 = typeof innerBrainOrConfig === 'function' ? innerBrainOrConfig : function() {
|
|
710
|
-
return innerBrainOrConfig;
|
|
659
|
+
value: function brain(title, innerBrain, config) {
|
|
660
|
+
var nestedConfig = config !== null && config !== void 0 ? config : {};
|
|
661
|
+
var nestedBlock = {
|
|
662
|
+
type: 'brain',
|
|
663
|
+
title: title,
|
|
664
|
+
innerBrain: innerBrain,
|
|
665
|
+
initialState: nestedConfig.initialState,
|
|
666
|
+
options: nestedConfig.options
|
|
711
667
|
};
|
|
712
|
-
|
|
713
|
-
|
|
668
|
+
this.blocks.push(nestedBlock);
|
|
669
|
+
return this.nextBrain();
|
|
670
|
+
}
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
key: "prompt",
|
|
674
|
+
value: function prompt(title, configFn) {
|
|
675
|
+
var promptBlock = {
|
|
676
|
+
type: 'prompt',
|
|
714
677
|
title: title,
|
|
715
|
-
configFn:
|
|
678
|
+
configFn: configFn
|
|
716
679
|
};
|
|
717
|
-
this.blocks.push(
|
|
680
|
+
this.blocks.push(promptBlock);
|
|
718
681
|
return this.nextBrain();
|
|
719
682
|
}
|
|
720
683
|
},
|
|
721
684
|
{
|
|
722
685
|
// Implementation
|
|
723
|
-
key: "
|
|
724
|
-
value: function
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
client: config.client,
|
|
734
|
-
action: function(param) {
|
|
735
|
-
var state = param.state, client = param.client, resources = param.resources;
|
|
736
|
-
return _async_to_generator(function() {
|
|
737
|
-
var prompt, result;
|
|
738
|
-
return _ts_generator(this, function(_state) {
|
|
739
|
-
switch(_state.label){
|
|
740
|
-
case 0:
|
|
741
|
-
return [
|
|
742
|
-
4,
|
|
743
|
-
config.template(state, resources)
|
|
744
|
-
];
|
|
745
|
-
case 1:
|
|
746
|
-
prompt = _state.sent();
|
|
747
|
-
return [
|
|
748
|
-
4,
|
|
749
|
-
client.generateObject({
|
|
750
|
-
schema: textSchema,
|
|
751
|
-
schemaName: 'TextResponse',
|
|
752
|
-
prompt: prompt
|
|
753
|
-
})
|
|
754
|
-
];
|
|
755
|
-
case 2:
|
|
756
|
-
result = _state.sent();
|
|
757
|
-
return [
|
|
758
|
-
2,
|
|
759
|
-
{
|
|
760
|
-
state: state,
|
|
761
|
-
promptResponse: result.object
|
|
762
|
-
}
|
|
763
|
-
];
|
|
764
|
-
}
|
|
765
|
-
});
|
|
766
|
-
})();
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
this.blocks.push(promptBlock);
|
|
770
|
-
return this.nextBrain();
|
|
771
|
-
}
|
|
772
|
-
// At this point, outputSchema is guaranteed to exist (schema-less case returned early)
|
|
773
|
-
var outputSchema = config.outputSchema;
|
|
774
|
-
if (iterateConfig) {
|
|
775
|
-
// Iterate mode - store config on block for event-stream to execute with per-item events
|
|
776
|
-
var promptBlock1 = {
|
|
777
|
-
type: 'step',
|
|
778
|
-
title: title,
|
|
779
|
-
action: function(param) {
|
|
780
|
-
var state = param.state;
|
|
781
|
-
return _async_to_generator(function() {
|
|
782
|
-
return _ts_generator(this, function(_state) {
|
|
783
|
-
return [
|
|
784
|
-
2,
|
|
785
|
-
state
|
|
786
|
-
];
|
|
787
|
-
});
|
|
788
|
-
})();
|
|
789
|
-
},
|
|
790
|
-
iterateConfig: {
|
|
791
|
-
over: iterateConfig.over,
|
|
792
|
-
error: iterateConfig.error,
|
|
793
|
-
template: config.template,
|
|
794
|
-
schema: outputSchema.schema,
|
|
795
|
-
schemaName: outputSchema.name,
|
|
796
|
-
client: config.client
|
|
797
|
-
}
|
|
798
|
-
};
|
|
799
|
-
this.blocks.push(promptBlock1);
|
|
800
|
-
return this.nextBrain();
|
|
801
|
-
} else {
|
|
802
|
-
// Single mode - run prompt once with current state
|
|
803
|
-
var promptBlock2 = {
|
|
804
|
-
type: 'step',
|
|
805
|
-
title: title,
|
|
806
|
-
client: config.client,
|
|
807
|
-
action: function(param) {
|
|
808
|
-
var state = param.state, client = param.client, resources = param.resources;
|
|
809
|
-
return _async_to_generator(function() {
|
|
810
|
-
var schema, schemaName, prompt, result;
|
|
811
|
-
return _ts_generator(this, function(_state) {
|
|
812
|
-
switch(_state.label){
|
|
813
|
-
case 0:
|
|
814
|
-
schema = outputSchema.schema, schemaName = outputSchema.name;
|
|
815
|
-
return [
|
|
816
|
-
4,
|
|
817
|
-
config.template(state, resources)
|
|
818
|
-
];
|
|
819
|
-
case 1:
|
|
820
|
-
prompt = _state.sent();
|
|
821
|
-
return [
|
|
822
|
-
4,
|
|
823
|
-
client.generateObject({
|
|
824
|
-
schema: schema,
|
|
825
|
-
schemaName: schemaName,
|
|
826
|
-
prompt: prompt
|
|
827
|
-
})
|
|
828
|
-
];
|
|
829
|
-
case 2:
|
|
830
|
-
result = _state.sent();
|
|
831
|
-
return [
|
|
832
|
-
2,
|
|
833
|
-
_object_spread_props(_object_spread({}, state), _define_property({}, outputSchema.name, result.object))
|
|
834
|
-
];
|
|
835
|
-
}
|
|
836
|
-
});
|
|
837
|
-
})();
|
|
838
|
-
}
|
|
839
|
-
};
|
|
840
|
-
this.blocks.push(promptBlock2);
|
|
841
|
-
return this.nextBrain();
|
|
842
|
-
}
|
|
686
|
+
key: "map",
|
|
687
|
+
value: function map(title, stateKey, configFn) {
|
|
688
|
+
var mapBlock = {
|
|
689
|
+
type: 'map',
|
|
690
|
+
title: title,
|
|
691
|
+
stateKey: stateKey,
|
|
692
|
+
configFn: configFn
|
|
693
|
+
};
|
|
694
|
+
this.blocks.push(mapBlock);
|
|
695
|
+
return this.nextBrain();
|
|
843
696
|
}
|
|
844
697
|
},
|
|
845
698
|
{
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
* 1. Calls an LLM agent to generate UI components based on the prompt
|
|
851
|
-
* 2. Renders the components to an HTML page
|
|
852
|
-
* 3. Stores the page and makes it available via URL
|
|
853
|
-
* 4. Creates a webhook for form submissions (typed based on responseSchema)
|
|
854
|
-
*
|
|
855
|
-
* The next step receives a `page` object with:
|
|
856
|
-
* - `url`: URL to the generated page
|
|
857
|
-
* - `webhook`: Pre-configured WebhookRegistration for form submissions
|
|
858
|
-
*
|
|
859
|
-
* The brain author is responsible for notifying users about the page (via Slack,
|
|
860
|
-
* email, etc.) and using `.wait()` to pause until the form is submitted.
|
|
861
|
-
* Form data arrives in the `response` parameter of the step after `.wait()`.
|
|
862
|
-
*
|
|
863
|
-
* @example
|
|
864
|
-
* ```typescript
|
|
865
|
-
* brain('feedback-form')
|
|
866
|
-
* .step('Initialize', () => ({ userName: 'John' }))
|
|
867
|
-
* .ui('Create Form', {
|
|
868
|
-
* template: (state) => `Create a feedback form for ${state.userName}`,
|
|
869
|
-
* responseSchema: z.object({
|
|
870
|
-
* rating: z.number().min(1).max(5),
|
|
871
|
-
* comments: z.string(),
|
|
872
|
-
* }),
|
|
873
|
-
* })
|
|
874
|
-
* .step('Notify', async ({ state, page, slack }) => {
|
|
875
|
-
* await slack.post('#general', `Please fill out: ${page.url}`);
|
|
876
|
-
* return state;
|
|
877
|
-
* })
|
|
878
|
-
* .wait('Wait for submission', ({ page }) => page.webhook)
|
|
879
|
-
* .step('Process Feedback', ({ state, response }) => ({
|
|
880
|
-
* ...state,
|
|
881
|
-
* // response is typed: { rating: number, comments: string }
|
|
882
|
-
* rating: response.rating,
|
|
883
|
-
* comments: response.comments,
|
|
884
|
-
* }))
|
|
885
|
-
* ```
|
|
886
|
-
*/ key: "ui",
|
|
887
|
-
value: function ui(title, config) {
|
|
888
|
-
var uiBlock = {
|
|
699
|
+
// Implementation
|
|
700
|
+
key: "page",
|
|
701
|
+
value: function page(title, configFn) {
|
|
702
|
+
var pageBlock = {
|
|
889
703
|
type: 'step',
|
|
890
704
|
title: title,
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
responseSchema: config.responseSchema
|
|
895
|
-
},
|
|
896
|
-
action: function(params) {
|
|
705
|
+
isPageStep: true,
|
|
706
|
+
pageConfigFn: configFn,
|
|
707
|
+
action: function() {
|
|
897
708
|
return _async_to_generator(function() {
|
|
898
709
|
return _ts_generator(this, function(_state) {
|
|
899
|
-
|
|
900
|
-
// This action is a placeholder that gets replaced during execution
|
|
901
|
-
// when the runner detects `isUIStep: true` and has components configured
|
|
902
|
-
throw new Error('UI step "'.concat(title, '" requires components to be configured via BrainRunner.withComponents(). ') + "The UI generation is handled by the runner, not the step action directly.");
|
|
710
|
+
throw new Error('Page step "'.concat(title, '" requires components to be configured via brain.withComponents(). ') + "Page generation is handled by the runner, not the step action directly.");
|
|
903
711
|
});
|
|
904
712
|
})();
|
|
905
713
|
}
|
|
906
714
|
};
|
|
907
|
-
this.blocks.push(
|
|
715
|
+
this.blocks.push(pageBlock);
|
|
908
716
|
return this.nextBrain();
|
|
909
717
|
}
|
|
910
718
|
},
|
|
@@ -913,17 +721,25 @@ export var Brain = /*#__PURE__*/ function() {
|
|
|
913
721
|
value: // Implementation signature
|
|
914
722
|
function run(params) {
|
|
915
723
|
return _wrap_async_generator(function() {
|
|
916
|
-
var _this, title, description, blocks, store, stream;
|
|
724
|
+
var _this, title, description, blocks, _params_brainRunId, brainRunId, files, pages, store, _params_pluginConfigs, _resolvePlugins, pluginInjections, pluginAdapters, mergedPluginConfigs, stream;
|
|
917
725
|
return _ts_generator(this, function(_state) {
|
|
918
726
|
switch(_state.label){
|
|
919
727
|
case 0:
|
|
920
728
|
_this = this, title = _this.title, description = _this.description, blocks = _this.blocks;
|
|
921
|
-
|
|
729
|
+
brainRunId = 'resume' in params && params.resume ? params.brainRunId : (_params_brainRunId = params.brainRunId) !== null && _params_brainRunId !== void 0 ? _params_brainRunId : '';
|
|
730
|
+
// Platform services
|
|
731
|
+
files = params.files;
|
|
732
|
+
pages = params.pages;
|
|
922
733
|
store = this.storeSchema && params.storeProvider ? params.storeProvider({
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
734
|
+
brainTitle: title,
|
|
735
|
+
currentUser: params.currentUser,
|
|
736
|
+
schema: this.storeSchema
|
|
926
737
|
}) : undefined;
|
|
738
|
+
_resolvePlugins = resolvePlugins((_params_pluginConfigs = params.pluginConfigs) !== null && _params_pluginConfigs !== void 0 ? _params_pluginConfigs : [], this.pluginConfigs, {
|
|
739
|
+
brainTitle: title,
|
|
740
|
+
currentUser: params.currentUser,
|
|
741
|
+
brainRunId: brainRunId
|
|
742
|
+
}), pluginInjections = _resolvePlugins.injections, pluginAdapters = _resolvePlugins.adapters, mergedPluginConfigs = _resolvePlugins.configs;
|
|
927
743
|
stream = new BrainEventStream(_object_spread_props(_object_spread({
|
|
928
744
|
title: title,
|
|
929
745
|
description: description,
|
|
@@ -931,12 +747,13 @@ export var Brain = /*#__PURE__*/ function() {
|
|
|
931
747
|
}, params), {
|
|
932
748
|
options: params.options || {},
|
|
933
749
|
optionsSchema: this.optionsSchema,
|
|
934
|
-
services: this.services,
|
|
935
750
|
components: this.components,
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
751
|
+
files: files,
|
|
752
|
+
pages: pages,
|
|
753
|
+
store: store,
|
|
754
|
+
pluginInjections: pluginInjections,
|
|
755
|
+
pluginAdapters: pluginAdapters,
|
|
756
|
+
pluginConfigs: mergedPluginConfigs
|
|
940
757
|
}));
|
|
941
758
|
return [
|
|
942
759
|
5,
|
|
@@ -959,27 +776,36 @@ export var Brain = /*#__PURE__*/ function() {
|
|
|
959
776
|
return this;
|
|
960
777
|
}
|
|
961
778
|
},
|
|
779
|
+
{
|
|
780
|
+
key: "copyConfigTo",
|
|
781
|
+
value: function copyConfigTo(target) {
|
|
782
|
+
target.optionsSchema = this.optionsSchema;
|
|
783
|
+
target.components = this.components;
|
|
784
|
+
target.storeSchema = this.storeSchema;
|
|
785
|
+
target.pluginConfigs = this.pluginConfigs;
|
|
786
|
+
}
|
|
787
|
+
},
|
|
962
788
|
{
|
|
963
789
|
key: "nextBrain",
|
|
964
790
|
value: function nextBrain() {
|
|
965
|
-
// Pass default options to the next brain
|
|
966
791
|
var nextBrain = new Brain(this.title, this.description).withBlocks(this.blocks);
|
|
967
|
-
|
|
968
|
-
nextBrain.services = this.services;
|
|
969
|
-
// Copy optionsSchema to the next brain
|
|
970
|
-
nextBrain.optionsSchema = this.optionsSchema;
|
|
971
|
-
// Copy components to the next brain
|
|
972
|
-
nextBrain.components = this.components;
|
|
973
|
-
// Copy defaultTools to the next brain
|
|
974
|
-
nextBrain.defaultTools = this.defaultTools;
|
|
975
|
-
// Copy extraTools to the next brain
|
|
976
|
-
nextBrain.extraTools = this.extraTools;
|
|
977
|
-
// Copy memoryProvider to the next brain
|
|
978
|
-
nextBrain.memoryProvider = this.memoryProvider;
|
|
979
|
-
// Copy store schema to the next brain
|
|
980
|
-
nextBrain.storeSchema = this.storeSchema;
|
|
792
|
+
this.copyConfigTo(nextBrain);
|
|
981
793
|
return nextBrain;
|
|
982
794
|
}
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
key: "continuationCallbacks",
|
|
798
|
+
value: function continuationCallbacks() {
|
|
799
|
+
var blocks = this.blocks;
|
|
800
|
+
var self = this;
|
|
801
|
+
return new Continuation(function(block) {
|
|
802
|
+
return blocks.push(block);
|
|
803
|
+
}, function() {
|
|
804
|
+
var next = new Brain(self.title, self.description).withBlocks(blocks);
|
|
805
|
+
self.copyConfigTo(next);
|
|
806
|
+
return next;
|
|
807
|
+
});
|
|
808
|
+
}
|
|
983
809
|
}
|
|
984
810
|
]);
|
|
985
811
|
return Brain;
|
|
@@ -997,14 +823,34 @@ var brainNames = new Set();
|
|
|
997
823
|
}
|
|
998
824
|
}
|
|
999
825
|
// Implementation
|
|
1000
|
-
export function brain(titleOrConfig
|
|
1001
|
-
var
|
|
1002
|
-
var
|
|
826
|
+
export function brain(titleOrConfig) {
|
|
827
|
+
var isString = typeof titleOrConfig === 'string';
|
|
828
|
+
var title = isString ? titleOrConfig : titleOrConfig.title;
|
|
829
|
+
var description = isString ? undefined : titleOrConfig.description;
|
|
830
|
+
var plugins = isString ? undefined : titleOrConfig.plugins;
|
|
1003
831
|
registerBrainName(title);
|
|
1004
|
-
var
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
832
|
+
var b = new Brain(title, description);
|
|
833
|
+
if (plugins) {
|
|
834
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
835
|
+
try {
|
|
836
|
+
for(var _iterator = Object.values(plugins)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
837
|
+
var plugin = _step.value;
|
|
838
|
+
b = b.withPlugin(plugin);
|
|
839
|
+
}
|
|
840
|
+
} catch (err) {
|
|
841
|
+
_didIteratorError = true;
|
|
842
|
+
_iteratorError = err;
|
|
843
|
+
} finally{
|
|
844
|
+
try {
|
|
845
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
846
|
+
_iterator.return();
|
|
847
|
+
}
|
|
848
|
+
} finally{
|
|
849
|
+
if (_didIteratorError) {
|
|
850
|
+
throw _iteratorError;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
}
|
|
1008
854
|
}
|
|
1009
|
-
return
|
|
855
|
+
return b;
|
|
1010
856
|
}
|