@positronic/core 0.0.37 → 0.0.39
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 +7 -3
- package/dist/src/dsl/brain.js +529 -25
- package/dist/src/dsl/constants.js +11 -1
- package/dist/src/dsl/loop-messages.js +76 -0
- package/dist/src/dsl/types.js +4 -1
- package/dist/src/index.js +1 -0
- package/dist/types/clients/types.d.ts +38 -0
- package/dist/types/clients/types.d.ts.map +1 -1
- package/dist/types/dsl/brain-runner.d.ts +3 -2
- package/dist/types/dsl/brain-runner.d.ts.map +1 -1
- package/dist/types/dsl/brain.d.ts +81 -3
- package/dist/types/dsl/brain.d.ts.map +1 -1
- package/dist/types/dsl/constants.d.ts +9 -0
- package/dist/types/dsl/constants.d.ts.map +1 -1
- package/dist/types/dsl/loop-messages.d.ts +18 -0
- package/dist/types/dsl/loop-messages.d.ts.map +1 -0
- package/dist/types/dsl/types.d.ts +63 -0
- package/dist/types/dsl/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -275,6 +275,7 @@ function _ts_values(o) {
|
|
|
275
275
|
}
|
|
276
276
|
import { BRAIN_EVENTS, STATUS } from './constants.js';
|
|
277
277
|
import { applyPatches } from './json-patch.js';
|
|
278
|
+
import { reconstructLoopContext } from './loop-messages.js';
|
|
278
279
|
import { DEFAULT_ENV } from './brain.js';
|
|
279
280
|
export var BrainRunner = /*#__PURE__*/ function() {
|
|
280
281
|
"use strict";
|
|
@@ -329,12 +330,12 @@ export var BrainRunner = /*#__PURE__*/ function() {
|
|
|
329
330
|
key: "run",
|
|
330
331
|
value: function run(_0) {
|
|
331
332
|
return _async_to_generator(function(brain) {
|
|
332
|
-
var _ref, _ref_initialState, initialState, options, initialCompletedSteps, brainRunId, endAfter, signal, response, _this_options, adapters, client, resources, pages, env, resolvedEnv, currentState, stepNumber, brainRun, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step, _ret, err, error, cancelledEvent;
|
|
333
|
+
var _ref, _ref_initialState, initialState, options, initialCompletedSteps, brainRunId, endAfter, signal, response, loopEvents, _this_options, adapters, client, resources, pages, env, resolvedEnv, currentState, stepNumber, loopResumeContext, brainRun, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step, _ret, err, error, cancelledEvent;
|
|
333
334
|
var _arguments = arguments;
|
|
334
335
|
return _ts_generator(this, function(_state) {
|
|
335
336
|
switch(_state.label){
|
|
336
337
|
case 0:
|
|
337
|
-
_ref = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, _ref_initialState = _ref.initialState, initialState = _ref_initialState === void 0 ? {} : _ref_initialState, options = _ref.options, initialCompletedSteps = _ref.initialCompletedSteps, brainRunId = _ref.brainRunId, endAfter = _ref.endAfter, signal = _ref.signal, response = _ref.response;
|
|
338
|
+
_ref = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, _ref_initialState = _ref.initialState, initialState = _ref_initialState === void 0 ? {} : _ref_initialState, options = _ref.options, initialCompletedSteps = _ref.initialCompletedSteps, brainRunId = _ref.brainRunId, endAfter = _ref.endAfter, signal = _ref.signal, response = _ref.response, loopEvents = _ref.loopEvents;
|
|
338
339
|
_this_options = this.options, adapters = _this_options.adapters, client = _this_options.client, resources = _this_options.resources, pages = _this_options.pages, env = _this_options.env;
|
|
339
340
|
resolvedEnv = env !== null && env !== void 0 ? env : DEFAULT_ENV;
|
|
340
341
|
currentState = initialState !== null && initialState !== void 0 ? initialState : {};
|
|
@@ -351,6 +352,8 @@ export var BrainRunner = /*#__PURE__*/ function() {
|
|
|
351
352
|
stepNumber++;
|
|
352
353
|
}
|
|
353
354
|
});
|
|
355
|
+
// If loopEvents and response are provided, reconstruct loop context
|
|
356
|
+
loopResumeContext = loopEvents && response ? reconstructLoopContext(loopEvents, response) : null;
|
|
354
357
|
brainRun = brainRunId && initialCompletedSteps ? brain.run({
|
|
355
358
|
initialState: initialState,
|
|
356
359
|
initialCompletedSteps: initialCompletedSteps,
|
|
@@ -360,7 +363,8 @@ export var BrainRunner = /*#__PURE__*/ function() {
|
|
|
360
363
|
resources: resources !== null && resources !== void 0 ? resources : {},
|
|
361
364
|
pages: pages,
|
|
362
365
|
env: resolvedEnv,
|
|
363
|
-
response: response
|
|
366
|
+
response: response,
|
|
367
|
+
loopResumeContext: loopResumeContext
|
|
364
368
|
}) : brain.run({
|
|
365
369
|
initialState: initialState,
|
|
366
370
|
options: options,
|
package/dist/src/dsl/brain.js
CHANGED
|
@@ -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_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
1
9
|
function _async_generator(gen) {
|
|
2
10
|
var front, back;
|
|
3
11
|
function send(key, arg) {
|
|
@@ -219,6 +227,33 @@ function _define_property(obj, key, value) {
|
|
|
219
227
|
}
|
|
220
228
|
return obj;
|
|
221
229
|
}
|
|
230
|
+
function _iterable_to_array_limit(arr, i) {
|
|
231
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
232
|
+
if (_i == null) return;
|
|
233
|
+
var _arr = [];
|
|
234
|
+
var _n = true;
|
|
235
|
+
var _d = false;
|
|
236
|
+
var _s, _e;
|
|
237
|
+
try {
|
|
238
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
239
|
+
_arr.push(_s.value);
|
|
240
|
+
if (i && _arr.length === i) break;
|
|
241
|
+
}
|
|
242
|
+
} catch (err) {
|
|
243
|
+
_d = true;
|
|
244
|
+
_e = err;
|
|
245
|
+
} finally{
|
|
246
|
+
try {
|
|
247
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
248
|
+
} finally{
|
|
249
|
+
if (_d) throw _e;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return _arr;
|
|
253
|
+
}
|
|
254
|
+
function _non_iterable_rest() {
|
|
255
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
256
|
+
}
|
|
222
257
|
function _object_spread(target) {
|
|
223
258
|
for(var i = 1; i < arguments.length; i++){
|
|
224
259
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -289,10 +324,21 @@ function _overload_yield(value, kind) {
|
|
|
289
324
|
this.v = value;
|
|
290
325
|
this.k = kind;
|
|
291
326
|
}
|
|
327
|
+
function _sliced_to_array(arr, i) {
|
|
328
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
329
|
+
}
|
|
292
330
|
function _type_of(obj) {
|
|
293
331
|
"@swc/helpers - typeof";
|
|
294
332
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
295
333
|
}
|
|
334
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
335
|
+
if (!o) return;
|
|
336
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
337
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
338
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
339
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
340
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
341
|
+
}
|
|
296
342
|
function _wrap_async_generator(fn) {
|
|
297
343
|
return function() {
|
|
298
344
|
return new _async_generator(fn.apply(this, arguments));
|
|
@@ -442,6 +488,11 @@ export var Brain = /*#__PURE__*/ function() {
|
|
|
442
488
|
type: 'step',
|
|
443
489
|
title: block.title
|
|
444
490
|
};
|
|
491
|
+
} else if (block.type === 'loop') {
|
|
492
|
+
return {
|
|
493
|
+
type: 'loop',
|
|
494
|
+
title: block.title
|
|
495
|
+
};
|
|
445
496
|
} else {
|
|
446
497
|
// block.type === 'brain'
|
|
447
498
|
return {
|
|
@@ -513,6 +564,25 @@ export var Brain = /*#__PURE__*/ function() {
|
|
|
513
564
|
return this.nextBrain();
|
|
514
565
|
}
|
|
515
566
|
},
|
|
567
|
+
{
|
|
568
|
+
/**
|
|
569
|
+
* Add an agentic loop step that runs an LLM with tools.
|
|
570
|
+
* The loop continues until a terminal tool is called, no tool calls are returned,
|
|
571
|
+
* or maxTokens is exceeded.
|
|
572
|
+
*/ key: "loop",
|
|
573
|
+
value: function loop(title, configFn) {
|
|
574
|
+
var loopBlock = {
|
|
575
|
+
type: 'loop',
|
|
576
|
+
title: title,
|
|
577
|
+
configFn: configFn
|
|
578
|
+
};
|
|
579
|
+
this.blocks.push(loopBlock);
|
|
580
|
+
var nextBrain = new Brain(this.title, this.description).withBlocks(this.blocks);
|
|
581
|
+
nextBrain.services = this.services;
|
|
582
|
+
nextBrain.optionsSchema = this.optionsSchema;
|
|
583
|
+
return nextBrain;
|
|
584
|
+
}
|
|
585
|
+
},
|
|
516
586
|
{
|
|
517
587
|
// TResponseKey:
|
|
518
588
|
// The response key must be a string literal, so if defining a response model
|
|
@@ -699,7 +769,8 @@ var BrainEventStream = /*#__PURE__*/ function() {
|
|
|
699
769
|
_define_property(this, "pages", void 0);
|
|
700
770
|
_define_property(this, "env", void 0);
|
|
701
771
|
_define_property(this, "currentResponse", undefined);
|
|
702
|
-
|
|
772
|
+
_define_property(this, "loopResumeContext", undefined);
|
|
773
|
+
var _params_initialState = params.initialState, initialState = _params_initialState === void 0 ? {} : _params_initialState, initialCompletedSteps = params.initialCompletedSteps, blocks = params.blocks, title = params.title, description = params.description, providedBrainRunId = params.brainRunId, _params_options = params.options, options = _params_options === void 0 ? {} : _params_options, client = params.client, services = params.services, _params_resources = params.resources, resources = _params_resources === void 0 ? {} : _params_resources, pages = params.pages, env = params.env, response = params.response, loopResumeContext = params.loopResumeContext;
|
|
703
774
|
this.initialState = initialState;
|
|
704
775
|
this.title = title;
|
|
705
776
|
this.description = description;
|
|
@@ -744,8 +815,16 @@ var BrainEventStream = /*#__PURE__*/ function() {
|
|
|
744
815
|
}
|
|
745
816
|
// Use provided ID if available, otherwise generate one
|
|
746
817
|
this.brainRunId = providedBrainRunId !== null && providedBrainRunId !== void 0 ? providedBrainRunId : uuidv4();
|
|
747
|
-
// Set
|
|
748
|
-
if (
|
|
818
|
+
// Set loop resume context if provided (for loop webhook restarts)
|
|
819
|
+
if (loopResumeContext) {
|
|
820
|
+
this.loopResumeContext = loopResumeContext;
|
|
821
|
+
// Note: We intentionally do NOT set currentResponse here.
|
|
822
|
+
// For loop resumption, the webhook response should flow through
|
|
823
|
+
// the messages array (via loopResumeContext), not through the
|
|
824
|
+
// config function's response parameter. The config function is
|
|
825
|
+
// for loop setup, not for processing webhook responses.
|
|
826
|
+
} else if (response) {
|
|
827
|
+
// Set initial response only for non-loop webhook restarts
|
|
749
828
|
this.currentResponse = response;
|
|
750
829
|
}
|
|
751
830
|
}
|
|
@@ -1076,27 +1155,42 @@ var BrainEventStream = /*#__PURE__*/ function() {
|
|
|
1076
1155
|
_state.sent();
|
|
1077
1156
|
return [
|
|
1078
1157
|
3,
|
|
1079
|
-
|
|
1158
|
+
30
|
|
1080
1159
|
];
|
|
1081
1160
|
case 16:
|
|
1161
|
+
if (!(block.type === 'loop')) return [
|
|
1162
|
+
3,
|
|
1163
|
+
18
|
|
1164
|
+
];
|
|
1165
|
+
return [
|
|
1166
|
+
5,
|
|
1167
|
+
_ts_values(_async_generator_delegate(_async_iterator(this.executeLoop(step))))
|
|
1168
|
+
];
|
|
1169
|
+
case 17:
|
|
1170
|
+
_state.sent();
|
|
1171
|
+
return [
|
|
1172
|
+
3,
|
|
1173
|
+
30
|
|
1174
|
+
];
|
|
1175
|
+
case 18:
|
|
1082
1176
|
// Get previous state before action
|
|
1083
1177
|
prevState1 = this.currentState;
|
|
1084
1178
|
stepBlock = block;
|
|
1085
1179
|
// Execute step with automatic retry on failure
|
|
1086
1180
|
retries = 0;
|
|
1087
|
-
_state.label =
|
|
1088
|
-
case
|
|
1181
|
+
_state.label = 19;
|
|
1182
|
+
case 19:
|
|
1089
1183
|
if (!true) return [
|
|
1090
1184
|
3,
|
|
1091
|
-
|
|
1185
|
+
27
|
|
1092
1186
|
];
|
|
1093
|
-
_state.label =
|
|
1094
|
-
case
|
|
1187
|
+
_state.label = 20;
|
|
1188
|
+
case 20:
|
|
1095
1189
|
_state.trys.push([
|
|
1096
|
-
18,
|
|
1097
1190
|
20,
|
|
1191
|
+
22,
|
|
1098
1192
|
,
|
|
1099
|
-
|
|
1193
|
+
26
|
|
1100
1194
|
]);
|
|
1101
1195
|
actionPromise = Promise.resolve(stepBlock.action(_object_spread({
|
|
1102
1196
|
state: this.currentState,
|
|
@@ -1111,17 +1205,17 @@ var BrainEventStream = /*#__PURE__*/ function() {
|
|
|
1111
1205
|
4,
|
|
1112
1206
|
_await_async_generator(actionPromise)
|
|
1113
1207
|
];
|
|
1114
|
-
case
|
|
1208
|
+
case 21:
|
|
1115
1209
|
result = _state.sent();
|
|
1116
1210
|
return [
|
|
1117
1211
|
3,
|
|
1118
|
-
|
|
1212
|
+
27
|
|
1119
1213
|
]; // Success
|
|
1120
|
-
case
|
|
1214
|
+
case 22:
|
|
1121
1215
|
error = _state.sent();
|
|
1122
1216
|
if (!(retries < MAX_RETRIES)) return [
|
|
1123
1217
|
3,
|
|
1124
|
-
|
|
1218
|
+
24
|
|
1125
1219
|
];
|
|
1126
1220
|
retries++;
|
|
1127
1221
|
return [
|
|
@@ -1140,35 +1234,35 @@ var BrainEventStream = /*#__PURE__*/ function() {
|
|
|
1140
1234
|
brainRunId: this.brainRunId
|
|
1141
1235
|
}
|
|
1142
1236
|
];
|
|
1143
|
-
case
|
|
1237
|
+
case 23:
|
|
1144
1238
|
_state.sent();
|
|
1145
1239
|
return [
|
|
1146
1240
|
3,
|
|
1147
|
-
|
|
1241
|
+
25
|
|
1148
1242
|
];
|
|
1149
|
-
case
|
|
1243
|
+
case 24:
|
|
1150
1244
|
throw error;
|
|
1151
|
-
case
|
|
1245
|
+
case 25:
|
|
1152
1246
|
return [
|
|
1153
1247
|
3,
|
|
1154
|
-
|
|
1248
|
+
26
|
|
1155
1249
|
];
|
|
1156
|
-
case
|
|
1250
|
+
case 26:
|
|
1157
1251
|
return [
|
|
1158
1252
|
3,
|
|
1159
|
-
|
|
1253
|
+
19
|
|
1160
1254
|
];
|
|
1161
|
-
case
|
|
1255
|
+
case 27:
|
|
1162
1256
|
this.currentState = result && (typeof result === "undefined" ? "undefined" : _type_of(result)) === 'object' && 'waitFor' in result ? result.state : result;
|
|
1163
1257
|
return [
|
|
1164
1258
|
5,
|
|
1165
1259
|
_ts_values(_async_generator_delegate(_async_iterator(this.completeStep(step, prevState1))))
|
|
1166
1260
|
];
|
|
1167
|
-
case
|
|
1261
|
+
case 28:
|
|
1168
1262
|
_state.sent();
|
|
1169
1263
|
if (!(result && (typeof result === "undefined" ? "undefined" : _type_of(result)) === 'object' && 'waitFor' in result)) return [
|
|
1170
1264
|
3,
|
|
1171
|
-
|
|
1265
|
+
30
|
|
1172
1266
|
];
|
|
1173
1267
|
// Serialize webhook registrations (remove Zod schemas for event serializability)
|
|
1174
1268
|
serializedWaitFor = result.waitFor.map(function(registration) {
|
|
@@ -1187,10 +1281,420 @@ var BrainEventStream = /*#__PURE__*/ function() {
|
|
|
1187
1281
|
brainRunId: this.brainRunId
|
|
1188
1282
|
}
|
|
1189
1283
|
];
|
|
1284
|
+
case 29:
|
|
1285
|
+
_state.sent();
|
|
1286
|
+
_state.label = 30;
|
|
1287
|
+
case 30:
|
|
1288
|
+
return [
|
|
1289
|
+
2
|
|
1290
|
+
];
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
}).call(this);
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
{
|
|
1297
|
+
key: "executeLoop",
|
|
1298
|
+
value: function executeLoop(step) {
|
|
1299
|
+
return _wrap_async_generator(function() {
|
|
1300
|
+
var block, prevState, _this_options, config, messages, resumeContext, _this_options1, _this_options2, _this_options3, totalTokens, iteration, _this_options4, toolsForClient, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, toolDef, tool, response, _this_options5, _this_options6, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, toolCall, _this_options7, tool1, _this_options8, toolResult, waitForResult, _this_options9, _this_options10, _this_options11, err;
|
|
1301
|
+
return _ts_generator(this, function(_state) {
|
|
1302
|
+
switch(_state.label){
|
|
1303
|
+
case 0:
|
|
1304
|
+
block = step.block;
|
|
1305
|
+
prevState = this.currentState;
|
|
1306
|
+
return [
|
|
1307
|
+
4,
|
|
1308
|
+
_await_async_generator(block.configFn(_object_spread({
|
|
1309
|
+
state: this.currentState,
|
|
1310
|
+
options: (_this_options = this.options) !== null && _this_options !== void 0 ? _this_options : {},
|
|
1311
|
+
client: this.client,
|
|
1312
|
+
resources: this.resources,
|
|
1313
|
+
response: this.currentResponse,
|
|
1314
|
+
pages: this.pages,
|
|
1315
|
+
env: this.env
|
|
1316
|
+
}, this.services)))
|
|
1317
|
+
];
|
|
1318
|
+
case 1:
|
|
1319
|
+
config = _state.sent();
|
|
1320
|
+
if (!this.loopResumeContext) return [
|
|
1321
|
+
3,
|
|
1322
|
+
4
|
|
1323
|
+
];
|
|
1324
|
+
resumeContext = this.loopResumeContext;
|
|
1325
|
+
// Emit WEBHOOK_RESPONSE event to record the response
|
|
1326
|
+
return [
|
|
1327
|
+
4,
|
|
1328
|
+
{
|
|
1329
|
+
type: BRAIN_EVENTS.WEBHOOK_RESPONSE,
|
|
1330
|
+
response: resumeContext.webhookResponse,
|
|
1331
|
+
options: (_this_options1 = this.options) !== null && _this_options1 !== void 0 ? _this_options1 : {},
|
|
1332
|
+
brainRunId: this.brainRunId
|
|
1333
|
+
}
|
|
1334
|
+
];
|
|
1335
|
+
case 2:
|
|
1336
|
+
_state.sent();
|
|
1337
|
+
// Emit LOOP_TOOL_RESULT for the pending tool (webhook response injected as tool result)
|
|
1338
|
+
return [
|
|
1339
|
+
4,
|
|
1340
|
+
{
|
|
1341
|
+
type: BRAIN_EVENTS.LOOP_TOOL_RESULT,
|
|
1342
|
+
stepTitle: step.block.title,
|
|
1343
|
+
stepId: step.id,
|
|
1344
|
+
toolCallId: resumeContext.pendingToolCallId,
|
|
1345
|
+
toolName: resumeContext.pendingToolName,
|
|
1346
|
+
result: resumeContext.webhookResponse,
|
|
1347
|
+
options: (_this_options2 = this.options) !== null && _this_options2 !== void 0 ? _this_options2 : {},
|
|
1348
|
+
brainRunId: this.brainRunId
|
|
1349
|
+
}
|
|
1350
|
+
];
|
|
1351
|
+
case 3:
|
|
1352
|
+
_state.sent();
|
|
1353
|
+
// Use restored messages from the resume context
|
|
1354
|
+
messages = resumeContext.messages;
|
|
1355
|
+
// Clear the context so it's only used once
|
|
1356
|
+
this.loopResumeContext = undefined;
|
|
1357
|
+
return [
|
|
1358
|
+
3,
|
|
1359
|
+
6
|
|
1360
|
+
];
|
|
1361
|
+
case 4:
|
|
1362
|
+
// Emit loop start event (only for fresh starts)
|
|
1363
|
+
return [
|
|
1364
|
+
4,
|
|
1365
|
+
{
|
|
1366
|
+
type: BRAIN_EVENTS.LOOP_START,
|
|
1367
|
+
stepTitle: step.block.title,
|
|
1368
|
+
stepId: step.id,
|
|
1369
|
+
prompt: config.prompt,
|
|
1370
|
+
system: config.system,
|
|
1371
|
+
options: (_this_options3 = this.options) !== null && _this_options3 !== void 0 ? _this_options3 : {},
|
|
1372
|
+
brainRunId: this.brainRunId
|
|
1373
|
+
}
|
|
1374
|
+
];
|
|
1375
|
+
case 5:
|
|
1376
|
+
_state.sent();
|
|
1377
|
+
// Initialize messages for fresh start
|
|
1378
|
+
messages = [
|
|
1379
|
+
{
|
|
1380
|
+
role: 'user',
|
|
1381
|
+
content: config.prompt
|
|
1382
|
+
}
|
|
1383
|
+
];
|
|
1384
|
+
_state.label = 6;
|
|
1385
|
+
case 6:
|
|
1386
|
+
// Initialize token tracking
|
|
1387
|
+
totalTokens = 0;
|
|
1388
|
+
iteration = 0;
|
|
1389
|
+
_state.label = 7;
|
|
1390
|
+
case 7:
|
|
1391
|
+
if (!true) return [
|
|
1392
|
+
3,
|
|
1393
|
+
33
|
|
1394
|
+
];
|
|
1395
|
+
iteration++;
|
|
1396
|
+
// Emit iteration event
|
|
1397
|
+
return [
|
|
1398
|
+
4,
|
|
1399
|
+
{
|
|
1400
|
+
type: BRAIN_EVENTS.LOOP_ITERATION,
|
|
1401
|
+
stepTitle: step.block.title,
|
|
1402
|
+
stepId: step.id,
|
|
1403
|
+
iteration: iteration,
|
|
1404
|
+
options: (_this_options4 = this.options) !== null && _this_options4 !== void 0 ? _this_options4 : {},
|
|
1405
|
+
brainRunId: this.brainRunId
|
|
1406
|
+
}
|
|
1407
|
+
];
|
|
1408
|
+
case 8:
|
|
1409
|
+
_state.sent();
|
|
1410
|
+
// Check if client supports generateText
|
|
1411
|
+
if (!this.client.generateText) {
|
|
1412
|
+
throw new Error('Client does not support generateText. Use a client that implements generateText for loop steps.');
|
|
1413
|
+
}
|
|
1414
|
+
// Build tools object for the client (description and inputSchema only)
|
|
1415
|
+
toolsForClient = {};
|
|
1416
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1417
|
+
try {
|
|
1418
|
+
for(_iterator = Object.entries(config.tools)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1419
|
+
_step_value = _sliced_to_array(_step.value, 2), name = _step_value[0], toolDef = _step_value[1];
|
|
1420
|
+
tool = toolDef;
|
|
1421
|
+
toolsForClient[name] = {
|
|
1422
|
+
description: tool.description,
|
|
1423
|
+
inputSchema: tool.inputSchema
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
} catch (err) {
|
|
1427
|
+
_didIteratorError = true;
|
|
1428
|
+
_iteratorError = err;
|
|
1429
|
+
} finally{
|
|
1430
|
+
try {
|
|
1431
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1432
|
+
_iterator.return();
|
|
1433
|
+
}
|
|
1434
|
+
} finally{
|
|
1435
|
+
if (_didIteratorError) {
|
|
1436
|
+
throw _iteratorError;
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
return [
|
|
1441
|
+
4,
|
|
1442
|
+
_await_async_generator(this.client.generateText({
|
|
1443
|
+
system: config.system,
|
|
1444
|
+
messages: messages,
|
|
1445
|
+
tools: toolsForClient
|
|
1446
|
+
}))
|
|
1447
|
+
];
|
|
1448
|
+
case 9:
|
|
1449
|
+
response = _state.sent();
|
|
1450
|
+
// Track tokens
|
|
1451
|
+
totalTokens += response.usage.totalTokens;
|
|
1452
|
+
if (!(config.maxTokens && totalTokens > config.maxTokens)) return [
|
|
1453
|
+
3,
|
|
1454
|
+
12
|
|
1455
|
+
];
|
|
1456
|
+
return [
|
|
1457
|
+
4,
|
|
1458
|
+
{
|
|
1459
|
+
type: BRAIN_EVENTS.LOOP_TOKEN_LIMIT,
|
|
1460
|
+
stepTitle: step.block.title,
|
|
1461
|
+
stepId: step.id,
|
|
1462
|
+
totalTokens: totalTokens,
|
|
1463
|
+
maxTokens: config.maxTokens,
|
|
1464
|
+
options: (_this_options5 = this.options) !== null && _this_options5 !== void 0 ? _this_options5 : {},
|
|
1465
|
+
brainRunId: this.brainRunId
|
|
1466
|
+
}
|
|
1467
|
+
];
|
|
1468
|
+
case 10:
|
|
1469
|
+
_state.sent();
|
|
1470
|
+
return [
|
|
1471
|
+
5,
|
|
1472
|
+
_ts_values(_async_generator_delegate(_async_iterator(this.completeStep(step, prevState))))
|
|
1473
|
+
];
|
|
1474
|
+
case 11:
|
|
1475
|
+
_state.sent();
|
|
1476
|
+
return [
|
|
1477
|
+
2
|
|
1478
|
+
];
|
|
1479
|
+
case 12:
|
|
1480
|
+
if (!response.text) return [
|
|
1481
|
+
3,
|
|
1482
|
+
14
|
|
1483
|
+
];
|
|
1484
|
+
return [
|
|
1485
|
+
4,
|
|
1486
|
+
{
|
|
1487
|
+
type: BRAIN_EVENTS.LOOP_ASSISTANT_MESSAGE,
|
|
1488
|
+
stepTitle: step.block.title,
|
|
1489
|
+
stepId: step.id,
|
|
1490
|
+
content: response.text,
|
|
1491
|
+
options: (_this_options6 = this.options) !== null && _this_options6 !== void 0 ? _this_options6 : {},
|
|
1492
|
+
brainRunId: this.brainRunId
|
|
1493
|
+
}
|
|
1494
|
+
];
|
|
1495
|
+
case 13:
|
|
1496
|
+
_state.sent();
|
|
1497
|
+
messages.push({
|
|
1498
|
+
role: 'assistant',
|
|
1499
|
+
content: response.text
|
|
1500
|
+
});
|
|
1501
|
+
_state.label = 14;
|
|
1502
|
+
case 14:
|
|
1503
|
+
if (!(!response.toolCalls || response.toolCalls.length === 0)) return [
|
|
1504
|
+
3,
|
|
1505
|
+
16
|
|
1506
|
+
];
|
|
1507
|
+
return [
|
|
1508
|
+
5,
|
|
1509
|
+
_ts_values(_async_generator_delegate(_async_iterator(this.completeStep(step, prevState))))
|
|
1510
|
+
];
|
|
1511
|
+
case 15:
|
|
1512
|
+
_state.sent();
|
|
1513
|
+
return [
|
|
1514
|
+
2
|
|
1515
|
+
];
|
|
1516
|
+
case 16:
|
|
1517
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
1518
|
+
_state.label = 17;
|
|
1519
|
+
case 17:
|
|
1520
|
+
_state.trys.push([
|
|
1521
|
+
17,
|
|
1522
|
+
30,
|
|
1523
|
+
31,
|
|
1524
|
+
32
|
|
1525
|
+
]);
|
|
1526
|
+
_iterator1 = response.toolCalls[Symbol.iterator]();
|
|
1527
|
+
_state.label = 18;
|
|
1528
|
+
case 18:
|
|
1529
|
+
if (!!(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done)) return [
|
|
1530
|
+
3,
|
|
1531
|
+
29
|
|
1532
|
+
];
|
|
1533
|
+
toolCall = _step1.value;
|
|
1534
|
+
return [
|
|
1535
|
+
4,
|
|
1536
|
+
{
|
|
1537
|
+
type: BRAIN_EVENTS.LOOP_TOOL_CALL,
|
|
1538
|
+
stepTitle: step.block.title,
|
|
1539
|
+
stepId: step.id,
|
|
1540
|
+
toolName: toolCall.toolName,
|
|
1541
|
+
toolCallId: toolCall.toolCallId,
|
|
1542
|
+
input: toolCall.args,
|
|
1543
|
+
options: (_this_options7 = this.options) !== null && _this_options7 !== void 0 ? _this_options7 : {},
|
|
1544
|
+
brainRunId: this.brainRunId
|
|
1545
|
+
}
|
|
1546
|
+
];
|
|
1547
|
+
case 19:
|
|
1548
|
+
_state.sent();
|
|
1549
|
+
tool1 = config.tools[toolCall.toolName];
|
|
1550
|
+
if (!tool1) {
|
|
1551
|
+
throw new Error("Unknown tool: ".concat(toolCall.toolName));
|
|
1552
|
+
}
|
|
1553
|
+
if (!tool1.terminal) return [
|
|
1554
|
+
3,
|
|
1555
|
+
22
|
|
1556
|
+
];
|
|
1557
|
+
return [
|
|
1558
|
+
4,
|
|
1559
|
+
{
|
|
1560
|
+
type: BRAIN_EVENTS.LOOP_COMPLETE,
|
|
1561
|
+
stepTitle: step.block.title,
|
|
1562
|
+
stepId: step.id,
|
|
1563
|
+
terminalToolName: toolCall.toolName,
|
|
1564
|
+
result: toolCall.args,
|
|
1565
|
+
totalIterations: iteration,
|
|
1566
|
+
options: (_this_options8 = this.options) !== null && _this_options8 !== void 0 ? _this_options8 : {},
|
|
1567
|
+
brainRunId: this.brainRunId
|
|
1568
|
+
}
|
|
1569
|
+
];
|
|
1570
|
+
case 20:
|
|
1571
|
+
_state.sent();
|
|
1572
|
+
// Merge terminal result into state
|
|
1573
|
+
this.currentState = _object_spread({}, this.currentState, toolCall.args);
|
|
1574
|
+
return [
|
|
1575
|
+
5,
|
|
1576
|
+
_ts_values(_async_generator_delegate(_async_iterator(this.completeStep(step, prevState))))
|
|
1577
|
+
];
|
|
1578
|
+
case 21:
|
|
1579
|
+
_state.sent();
|
|
1580
|
+
return [
|
|
1581
|
+
2
|
|
1582
|
+
];
|
|
1583
|
+
case 22:
|
|
1584
|
+
if (!tool1.execute) return [
|
|
1585
|
+
3,
|
|
1586
|
+
28
|
|
1587
|
+
];
|
|
1588
|
+
return [
|
|
1589
|
+
4,
|
|
1590
|
+
_await_async_generator(Promise.resolve(tool1.execute(toolCall.args)))
|
|
1591
|
+
];
|
|
1592
|
+
case 23:
|
|
1593
|
+
toolResult = _state.sent();
|
|
1594
|
+
if (!(toolResult && (typeof toolResult === "undefined" ? "undefined" : _type_of(toolResult)) === 'object' && 'waitFor' in toolResult)) return [
|
|
1595
|
+
3,
|
|
1596
|
+
26
|
|
1597
|
+
];
|
|
1598
|
+
waitForResult = toolResult;
|
|
1599
|
+
// Emit loop webhook event first (captures pending tool context)
|
|
1600
|
+
return [
|
|
1601
|
+
4,
|
|
1602
|
+
{
|
|
1603
|
+
type: BRAIN_EVENTS.LOOP_WEBHOOK,
|
|
1604
|
+
stepTitle: step.block.title,
|
|
1605
|
+
stepId: step.id,
|
|
1606
|
+
toolCallId: toolCall.toolCallId,
|
|
1607
|
+
toolName: toolCall.toolName,
|
|
1608
|
+
input: toolCall.args,
|
|
1609
|
+
options: (_this_options9 = this.options) !== null && _this_options9 !== void 0 ? _this_options9 : {},
|
|
1610
|
+
brainRunId: this.brainRunId
|
|
1611
|
+
}
|
|
1612
|
+
];
|
|
1613
|
+
case 24:
|
|
1614
|
+
_state.sent();
|
|
1615
|
+
// Then emit webhook event
|
|
1616
|
+
return [
|
|
1617
|
+
4,
|
|
1618
|
+
{
|
|
1619
|
+
type: BRAIN_EVENTS.WEBHOOK,
|
|
1620
|
+
waitFor: [
|
|
1621
|
+
{
|
|
1622
|
+
slug: waitForResult.waitFor.slug,
|
|
1623
|
+
identifier: waitForResult.waitFor.identifier
|
|
1624
|
+
}
|
|
1625
|
+
],
|
|
1626
|
+
state: this.currentState,
|
|
1627
|
+
options: (_this_options10 = this.options) !== null && _this_options10 !== void 0 ? _this_options10 : {},
|
|
1628
|
+
brainRunId: this.brainRunId
|
|
1629
|
+
}
|
|
1630
|
+
];
|
|
1631
|
+
case 25:
|
|
1632
|
+
_state.sent();
|
|
1633
|
+
return [
|
|
1634
|
+
2
|
|
1635
|
+
];
|
|
1636
|
+
case 26:
|
|
1637
|
+
// Normal tool result
|
|
1638
|
+
return [
|
|
1639
|
+
4,
|
|
1640
|
+
{
|
|
1641
|
+
type: BRAIN_EVENTS.LOOP_TOOL_RESULT,
|
|
1642
|
+
stepTitle: step.block.title,
|
|
1643
|
+
stepId: step.id,
|
|
1644
|
+
toolName: toolCall.toolName,
|
|
1645
|
+
toolCallId: toolCall.toolCallId,
|
|
1646
|
+
result: toolResult,
|
|
1647
|
+
options: (_this_options11 = this.options) !== null && _this_options11 !== void 0 ? _this_options11 : {},
|
|
1648
|
+
brainRunId: this.brainRunId
|
|
1649
|
+
}
|
|
1650
|
+
];
|
|
1190
1651
|
case 27:
|
|
1191
1652
|
_state.sent();
|
|
1653
|
+
messages.push({
|
|
1654
|
+
role: 'tool',
|
|
1655
|
+
content: JSON.stringify(toolResult),
|
|
1656
|
+
toolCallId: toolCall.toolCallId,
|
|
1657
|
+
toolName: toolCall.toolName
|
|
1658
|
+
});
|
|
1192
1659
|
_state.label = 28;
|
|
1193
1660
|
case 28:
|
|
1661
|
+
_iteratorNormalCompletion1 = true;
|
|
1662
|
+
return [
|
|
1663
|
+
3,
|
|
1664
|
+
18
|
|
1665
|
+
];
|
|
1666
|
+
case 29:
|
|
1667
|
+
return [
|
|
1668
|
+
3,
|
|
1669
|
+
32
|
|
1670
|
+
];
|
|
1671
|
+
case 30:
|
|
1672
|
+
err = _state.sent();
|
|
1673
|
+
_didIteratorError1 = true;
|
|
1674
|
+
_iteratorError1 = err;
|
|
1675
|
+
return [
|
|
1676
|
+
3,
|
|
1677
|
+
32
|
|
1678
|
+
];
|
|
1679
|
+
case 31:
|
|
1680
|
+
try {
|
|
1681
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1682
|
+
_iterator1.return();
|
|
1683
|
+
}
|
|
1684
|
+
} finally{
|
|
1685
|
+
if (_didIteratorError1) {
|
|
1686
|
+
throw _iteratorError1;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
return [
|
|
1690
|
+
7
|
|
1691
|
+
];
|
|
1692
|
+
case 32:
|
|
1693
|
+
return [
|
|
1694
|
+
3,
|
|
1695
|
+
7
|
|
1696
|
+
];
|
|
1697
|
+
case 33:
|
|
1194
1698
|
return [
|
|
1195
1699
|
2
|
|
1196
1700
|
];
|
|
@@ -8,7 +8,17 @@ export var BRAIN_EVENTS = {
|
|
|
8
8
|
ERROR: 'brain:error',
|
|
9
9
|
COMPLETE: 'brain:complete',
|
|
10
10
|
CANCELLED: 'brain:cancelled',
|
|
11
|
-
WEBHOOK: 'brain:webhook'
|
|
11
|
+
WEBHOOK: 'brain:webhook',
|
|
12
|
+
WEBHOOK_RESPONSE: 'brain:webhook_response',
|
|
13
|
+
// Loop step events
|
|
14
|
+
LOOP_START: 'loop:start',
|
|
15
|
+
LOOP_ITERATION: 'loop:iteration',
|
|
16
|
+
LOOP_TOOL_CALL: 'loop:tool_call',
|
|
17
|
+
LOOP_TOOL_RESULT: 'loop:tool_result',
|
|
18
|
+
LOOP_ASSISTANT_MESSAGE: 'loop:assistant_message',
|
|
19
|
+
LOOP_COMPLETE: 'loop:complete',
|
|
20
|
+
LOOP_TOKEN_LIMIT: 'loop:token_limit',
|
|
21
|
+
LOOP_WEBHOOK: 'loop:webhook'
|
|
12
22
|
};
|
|
13
23
|
export var STATUS = {
|
|
14
24
|
PENDING: 'pending',
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { BRAIN_EVENTS } from './constants.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reconstructs the loop context from stored events and a webhook response.
|
|
4
|
+
* Returns null if this is not a loop resume (no LOOP_WEBHOOK event found).
|
|
5
|
+
*/ export function reconstructLoopContext(events, webhookResponse) {
|
|
6
|
+
// Find LOOP_WEBHOOK event - if not present, this is not a loop resume
|
|
7
|
+
var loopWebhookEvent = events.find(function(e) {
|
|
8
|
+
return e.type === BRAIN_EVENTS.LOOP_WEBHOOK;
|
|
9
|
+
});
|
|
10
|
+
if (!loopWebhookEvent) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
// Find LOOP_START to get the initial prompt and system
|
|
14
|
+
var loopStartEvent = events.find(function(e) {
|
|
15
|
+
return e.type === BRAIN_EVENTS.LOOP_START;
|
|
16
|
+
});
|
|
17
|
+
if (!loopStartEvent) {
|
|
18
|
+
throw new Error('LOOP_START event not found but LOOP_WEBHOOK exists - invalid event sequence');
|
|
19
|
+
}
|
|
20
|
+
var messages = [];
|
|
21
|
+
// Add initial user message from the prompt
|
|
22
|
+
messages.push({
|
|
23
|
+
role: 'user',
|
|
24
|
+
content: loopStartEvent.prompt
|
|
25
|
+
});
|
|
26
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
27
|
+
try {
|
|
28
|
+
// Process events in order to rebuild conversation
|
|
29
|
+
for(var _iterator = events[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
30
|
+
var event = _step.value;
|
|
31
|
+
if (event.type === BRAIN_EVENTS.LOOP_ASSISTANT_MESSAGE) {
|
|
32
|
+
var assistantEvent = event;
|
|
33
|
+
messages.push({
|
|
34
|
+
role: 'assistant',
|
|
35
|
+
content: assistantEvent.content
|
|
36
|
+
});
|
|
37
|
+
} else if (event.type === BRAIN_EVENTS.LOOP_TOOL_RESULT) {
|
|
38
|
+
var toolResultEvent = event;
|
|
39
|
+
messages.push({
|
|
40
|
+
role: 'tool',
|
|
41
|
+
content: JSON.stringify(toolResultEvent.result),
|
|
42
|
+
toolCallId: toolResultEvent.toolCallId,
|
|
43
|
+
toolName: toolResultEvent.toolName
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
} catch (err) {
|
|
48
|
+
_didIteratorError = true;
|
|
49
|
+
_iteratorError = err;
|
|
50
|
+
} finally{
|
|
51
|
+
try {
|
|
52
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
53
|
+
_iterator.return();
|
|
54
|
+
}
|
|
55
|
+
} finally{
|
|
56
|
+
if (_didIteratorError) {
|
|
57
|
+
throw _iteratorError;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Add the webhook response as the pending tool's result
|
|
62
|
+
messages.push({
|
|
63
|
+
role: 'tool',
|
|
64
|
+
content: JSON.stringify(webhookResponse),
|
|
65
|
+
toolCallId: loopWebhookEvent.toolCallId,
|
|
66
|
+
toolName: loopWebhookEvent.toolName
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
messages: messages,
|
|
70
|
+
pendingToolCallId: loopWebhookEvent.toolCallId,
|
|
71
|
+
pendingToolName: loopWebhookEvent.toolName,
|
|
72
|
+
prompt: loopStartEvent.prompt,
|
|
73
|
+
system: loopStartEvent.system,
|
|
74
|
+
webhookResponse: webhookResponse
|
|
75
|
+
};
|
|
76
|
+
}
|
package/dist/src/dsl/types.js
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -6,6 +6,16 @@ export type Message = {
|
|
|
6
6
|
role: 'user' | 'assistant' | 'system';
|
|
7
7
|
content: string;
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Represents a message in a tool-calling conversation.
|
|
11
|
+
* Extends Message to include tool messages.
|
|
12
|
+
*/
|
|
13
|
+
export type ToolMessage = {
|
|
14
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
15
|
+
content: string;
|
|
16
|
+
toolCallId?: string;
|
|
17
|
+
toolName?: string;
|
|
18
|
+
};
|
|
9
19
|
/**
|
|
10
20
|
* Interface for AI model interactions, focused on generating structured objects
|
|
11
21
|
* and potentially other types of content in the future.
|
|
@@ -46,5 +56,33 @@ export interface ObjectGenerator {
|
|
|
46
56
|
*/
|
|
47
57
|
system?: string;
|
|
48
58
|
}): Promise<z.infer<T>>;
|
|
59
|
+
/**
|
|
60
|
+
* Generates text with optional tool calling support.
|
|
61
|
+
* Used by loop steps for agentic workflows.
|
|
62
|
+
*/
|
|
63
|
+
generateText?(params: {
|
|
64
|
+
/** System prompt for the LLM */
|
|
65
|
+
system?: string;
|
|
66
|
+
/** Conversation messages (including tool messages) */
|
|
67
|
+
messages: ToolMessage[];
|
|
68
|
+
/** Available tools for the LLM to call */
|
|
69
|
+
tools: Record<string, {
|
|
70
|
+
description: string;
|
|
71
|
+
inputSchema: z.ZodSchema;
|
|
72
|
+
}>;
|
|
73
|
+
}): Promise<{
|
|
74
|
+
/** Text response from the LLM */
|
|
75
|
+
text?: string;
|
|
76
|
+
/** Tool calls made by the LLM */
|
|
77
|
+
toolCalls?: Array<{
|
|
78
|
+
toolCallId: string;
|
|
79
|
+
toolName: string;
|
|
80
|
+
args: unknown;
|
|
81
|
+
}>;
|
|
82
|
+
/** Token usage information */
|
|
83
|
+
usage: {
|
|
84
|
+
totalTokens: number;
|
|
85
|
+
};
|
|
86
|
+
}>;
|
|
49
87
|
}
|
|
50
88
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/clients/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAA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,CAAC;QAE3B;;;;;WAKG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;QAEhB;;;;;WAKG;QACH,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;QAErB;;;;WAIG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAExB;;;OAGG;IACH,YAAY,CAAC,CAAC,MAAM,EAAE;QACpB,gCAAgC;QAChC,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,sDAAsD;QACtD,QAAQ,EAAE,WAAW,EAAE,CAAC;QACxB,0CAA0C;QAC1C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,WAAW,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,CAAC,CAAC,SAAS,CAAA;SAAE,CAAC,CAAC;KAC1E,GAAG,OAAO,CAAC;QACV,iCAAiC;QACjC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,iCAAiC;QACjC,SAAS,CAAC,EAAE,KAAK,CAAC;YAChB,UAAU,EAAE,MAAM,CAAC;YACnB,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,OAAO,CAAC;SACf,CAAC,CAAC;QACH,8BAA8B;QAC9B,KAAK,EAAE;YAAE,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC;KAChC,CAAC,CAAC;CACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Adapter } from '../adapters/types.js';
|
|
2
|
-
import { type SerializedStep, type Brain } from './brain.js';
|
|
2
|
+
import { type SerializedStep, type Brain, type BrainEvent } from './brain.js';
|
|
3
3
|
import type { State, JsonObject, RuntimeEnv } from './types.js';
|
|
4
4
|
import type { ObjectGenerator } from '../clients/types.js';
|
|
5
5
|
import type { Resources } from '../resources/resources.js';
|
|
@@ -18,7 +18,7 @@ export declare class BrainRunner {
|
|
|
18
18
|
withResources(resources: Resources): BrainRunner;
|
|
19
19
|
withPages(pages: PagesService): BrainRunner;
|
|
20
20
|
withEnv(env: RuntimeEnv): BrainRunner;
|
|
21
|
-
run<TOptions extends JsonObject = {}, TState extends State = {}>(brain: Brain<TOptions, TState, any>, { initialState, options, initialCompletedSteps, brainRunId, endAfter, signal, response, }?: {
|
|
21
|
+
run<TOptions extends JsonObject = {}, TState extends State = {}>(brain: Brain<TOptions, TState, any>, { initialState, options, initialCompletedSteps, brainRunId, endAfter, signal, response, loopEvents, }?: {
|
|
22
22
|
initialState?: TState;
|
|
23
23
|
options?: TOptions;
|
|
24
24
|
initialCompletedSteps?: SerializedStep[] | never;
|
|
@@ -26,6 +26,7 @@ export declare class BrainRunner {
|
|
|
26
26
|
endAfter?: number;
|
|
27
27
|
signal?: AbortSignal;
|
|
28
28
|
response?: JsonObject;
|
|
29
|
+
loopEvents?: BrainEvent[];
|
|
29
30
|
}): Promise<TState>;
|
|
30
31
|
}
|
|
31
32
|
//# sourceMappingURL=brain-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brain-runner.d.ts","sourceRoot":"","sources":["../../../src/dsl/brain-runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"brain-runner.d.ts","sourceRoot":"","sources":["../../../src/dsl/brain-runner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAe,KAAK,cAAc,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC3F,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,qBAAa,WAAW;IAEp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atch, JsonObject, RuntimeEnv } from './types.js';
|
|
3
|
+
import type { State, JsonPatch, JsonObject, RuntimeEnv, LoopTool, LoopConfig } from './types.js';
|
|
4
4
|
import { STATUS, BRAIN_EVENTS } from './constants.js';
|
|
5
5
|
import type { Resources } from '../resources/resources.js';
|
|
6
6
|
import type { ExtractWebhookResponses, SerializedWebhookRegistration } from './webhook.js';
|
|
7
7
|
import type { PagesService } from './pages.js';
|
|
8
|
+
import type { LoopResumeContext } from './loop-messages.js';
|
|
8
9
|
export type SerializedError = {
|
|
9
10
|
name: string;
|
|
10
11
|
message: string;
|
|
@@ -86,7 +87,69 @@ export interface WebhookEvent<TOptions extends JsonObject = JsonObject> extends
|
|
|
86
87
|
waitFor: SerializedWebhookRegistration[];
|
|
87
88
|
state: State;
|
|
88
89
|
}
|
|
89
|
-
export
|
|
90
|
+
export interface LoopStartEvent<TOptions extends JsonObject = JsonObject> extends BaseEvent<TOptions> {
|
|
91
|
+
type: typeof BRAIN_EVENTS.LOOP_START;
|
|
92
|
+
stepTitle: string;
|
|
93
|
+
stepId: string;
|
|
94
|
+
prompt: string;
|
|
95
|
+
system?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface LoopIterationEvent<TOptions extends JsonObject = JsonObject> extends BaseEvent<TOptions> {
|
|
98
|
+
type: typeof BRAIN_EVENTS.LOOP_ITERATION;
|
|
99
|
+
stepTitle: string;
|
|
100
|
+
stepId: string;
|
|
101
|
+
iteration: number;
|
|
102
|
+
}
|
|
103
|
+
export interface LoopToolCallEvent<TOptions extends JsonObject = JsonObject> extends BaseEvent<TOptions> {
|
|
104
|
+
type: typeof BRAIN_EVENTS.LOOP_TOOL_CALL;
|
|
105
|
+
stepTitle: string;
|
|
106
|
+
stepId: string;
|
|
107
|
+
toolName: string;
|
|
108
|
+
toolCallId: string;
|
|
109
|
+
input: JsonObject;
|
|
110
|
+
}
|
|
111
|
+
export interface LoopToolResultEvent<TOptions extends JsonObject = JsonObject> extends BaseEvent<TOptions> {
|
|
112
|
+
type: typeof BRAIN_EVENTS.LOOP_TOOL_RESULT;
|
|
113
|
+
stepTitle: string;
|
|
114
|
+
stepId: string;
|
|
115
|
+
toolName: string;
|
|
116
|
+
toolCallId: string;
|
|
117
|
+
result: unknown;
|
|
118
|
+
}
|
|
119
|
+
export interface LoopAssistantMessageEvent<TOptions extends JsonObject = JsonObject> extends BaseEvent<TOptions> {
|
|
120
|
+
type: typeof BRAIN_EVENTS.LOOP_ASSISTANT_MESSAGE;
|
|
121
|
+
stepTitle: string;
|
|
122
|
+
stepId: string;
|
|
123
|
+
content: string;
|
|
124
|
+
}
|
|
125
|
+
export interface LoopCompleteEvent<TOptions extends JsonObject = JsonObject> extends BaseEvent<TOptions> {
|
|
126
|
+
type: typeof BRAIN_EVENTS.LOOP_COMPLETE;
|
|
127
|
+
stepTitle: string;
|
|
128
|
+
stepId: string;
|
|
129
|
+
terminalToolName: string;
|
|
130
|
+
result: JsonObject;
|
|
131
|
+
totalIterations: number;
|
|
132
|
+
}
|
|
133
|
+
export interface LoopTokenLimitEvent<TOptions extends JsonObject = JsonObject> extends BaseEvent<TOptions> {
|
|
134
|
+
type: typeof BRAIN_EVENTS.LOOP_TOKEN_LIMIT;
|
|
135
|
+
stepTitle: string;
|
|
136
|
+
stepId: string;
|
|
137
|
+
totalTokens: number;
|
|
138
|
+
maxTokens: number;
|
|
139
|
+
}
|
|
140
|
+
export interface LoopWebhookEvent<TOptions extends JsonObject = JsonObject> extends BaseEvent<TOptions> {
|
|
141
|
+
type: typeof BRAIN_EVENTS.LOOP_WEBHOOK;
|
|
142
|
+
stepTitle: string;
|
|
143
|
+
stepId: string;
|
|
144
|
+
toolCallId: string;
|
|
145
|
+
toolName: string;
|
|
146
|
+
input: JsonObject;
|
|
147
|
+
}
|
|
148
|
+
export interface WebhookResponseEvent<TOptions extends JsonObject = JsonObject> extends BaseEvent<TOptions> {
|
|
149
|
+
type: typeof BRAIN_EVENTS.WEBHOOK_RESPONSE;
|
|
150
|
+
response: JsonObject;
|
|
151
|
+
}
|
|
152
|
+
export type BrainEvent<TOptions extends JsonObject = JsonObject> = BrainStartEvent<TOptions> | BrainCompleteEvent<TOptions> | BrainErrorEvent<TOptions> | BrainCancelledEvent<TOptions> | StepStatusEvent<TOptions> | StepStartedEvent<TOptions> | StepCompletedEvent<TOptions> | StepRetryEvent<TOptions> | WebhookEvent<TOptions> | WebhookResponseEvent<TOptions> | LoopStartEvent<TOptions> | LoopIterationEvent<TOptions> | LoopToolCallEvent<TOptions> | LoopToolResultEvent<TOptions> | LoopAssistantMessageEvent<TOptions> | LoopCompleteEvent<TOptions> | LoopTokenLimitEvent<TOptions> | LoopWebhookEvent<TOptions>;
|
|
90
153
|
export interface SerializedStep {
|
|
91
154
|
title: string;
|
|
92
155
|
status: (typeof STATUS)[keyof typeof STATUS];
|
|
@@ -98,7 +161,7 @@ export interface BrainStructure {
|
|
|
98
161
|
title: string;
|
|
99
162
|
description?: string;
|
|
100
163
|
steps: Array<{
|
|
101
|
-
type: 'step' | 'brain';
|
|
164
|
+
type: 'step' | 'brain' | 'loop';
|
|
102
165
|
title: string;
|
|
103
166
|
innerBrain?: BrainStructure;
|
|
104
167
|
}>;
|
|
@@ -126,6 +189,7 @@ export interface RerunParams<TOptions extends JsonObject = JsonObject> extends B
|
|
|
126
189
|
initialCompletedSteps: SerializedStep[];
|
|
127
190
|
brainRunId: string;
|
|
128
191
|
response?: JsonObject;
|
|
192
|
+
loopResumeContext?: LoopResumeContext | null;
|
|
129
193
|
}
|
|
130
194
|
export declare class Brain<TOptions extends JsonObject = JsonObject, TState extends State = object, TServices extends object = object, TResponse extends JsonObject | undefined = undefined> {
|
|
131
195
|
readonly title: string;
|
|
@@ -158,6 +222,20 @@ export declare class Brain<TOptions extends JsonObject = JsonObject, TState exte
|
|
|
158
222
|
brainState: TInnerState;
|
|
159
223
|
services: TServices;
|
|
160
224
|
}) => TNewState, initialState?: State | ((state: TState) => State)): Brain<TOptions, TNewState, TServices, undefined>;
|
|
225
|
+
/**
|
|
226
|
+
* Add an agentic loop step that runs an LLM with tools.
|
|
227
|
+
* The loop continues until a terminal tool is called, no tool calls are returned,
|
|
228
|
+
* or maxTokens is exceeded.
|
|
229
|
+
*/
|
|
230
|
+
loop<TTools extends Record<string, LoopTool> = Record<string, LoopTool>, TNewState extends State = TState>(title: string, configFn: (params: {
|
|
231
|
+
state: TState;
|
|
232
|
+
options: TOptions;
|
|
233
|
+
client: ObjectGenerator;
|
|
234
|
+
resources: Resources;
|
|
235
|
+
response: TResponse;
|
|
236
|
+
pages?: PagesService;
|
|
237
|
+
env: RuntimeEnv;
|
|
238
|
+
} & TServices) => LoopConfig<TTools> | Promise<LoopConfig<TTools>>): Brain<TOptions, TNewState, TServices, TResponse>;
|
|
161
239
|
prompt<TResponseKey extends string & {
|
|
162
240
|
readonly brand?: unique symbol;
|
|
163
241
|
}, TSchema extends z.ZodObject<any>, TNewState extends State = TState & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brain.d.ts","sourceRoot":"","sources":["../../../src/dsl/brain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAuB,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAChH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,E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M,GAAG;SAChC,CAAC,IAAI,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;KACtC,EAED,KAAK,EAAE,MAAM,EACb,MAAM,EAAE;QACN,QAAQ,EAAE,CACR,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,SAAS,KACjB,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9B,YAAY,EAAE;YACZ,MAAM,EAAE,OAAO,CAAC;YAChB,IAAI,EAAE,YAAY,GAAG,CAAC,MAAM,SAAS,YAAY,GAAG,KAAK,GAAG,OAAO,CAAC,CAAC;SACtE,CAAC;QACF,MAAM,CAAC,EAAE,eAAe,CAAC;KAC1B,EACD,MAAM,CAAC,EAAE,CACP,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,OAAO,EAAE,QAAQ,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,SAAS,CAAC;KACtB,GAAG,SAAS,KACV,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAmDrC,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC7E,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAqCxE,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,SAAS;CAkBlB;AAioBD,eAAO,MAAM,KAAK,EAAE,YAkBnB,CAAC"}
|
|
@@ -9,6 +9,15 @@ export declare const BRAIN_EVENTS: {
|
|
|
9
9
|
readonly COMPLETE: "brain:complete";
|
|
10
10
|
readonly CANCELLED: "brain:cancelled";
|
|
11
11
|
readonly WEBHOOK: "brain:webhook";
|
|
12
|
+
readonly WEBHOOK_RESPONSE: "brain:webhook_response";
|
|
13
|
+
readonly LOOP_START: "loop:start";
|
|
14
|
+
readonly LOOP_ITERATION: "loop:iteration";
|
|
15
|
+
readonly LOOP_TOOL_CALL: "loop:tool_call";
|
|
16
|
+
readonly LOOP_TOOL_RESULT: "loop:tool_result";
|
|
17
|
+
readonly LOOP_ASSISTANT_MESSAGE: "loop:assistant_message";
|
|
18
|
+
readonly LOOP_COMPLETE: "loop:complete";
|
|
19
|
+
readonly LOOP_TOKEN_LIMIT: "loop:token_limit";
|
|
20
|
+
readonly LOOP_WEBHOOK: "loop:webhook";
|
|
12
21
|
};
|
|
13
22
|
export declare const STATUS: {
|
|
14
23
|
readonly PENDING: "pending";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/dsl/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/dsl/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;CAqBf,CAAC;AAEX,eAAO,MAAM,MAAM;;;;;;CAMT,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BrainEvent } from './brain.js';
|
|
2
|
+
import type { ToolMessage } from '../clients/types.js';
|
|
3
|
+
import type { JsonObject } from './types.js';
|
|
4
|
+
export interface LoopResumeContext {
|
|
5
|
+
messages: ToolMessage[];
|
|
6
|
+
pendingToolCallId: string;
|
|
7
|
+
pendingToolName: string;
|
|
8
|
+
prompt: string;
|
|
9
|
+
system?: string;
|
|
10
|
+
/** The raw webhook response for event emission */
|
|
11
|
+
webhookResponse: JsonObject;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Reconstructs the loop context from stored events and a webhook response.
|
|
15
|
+
* Returns null if this is not a loop resume (no LOOP_WEBHOOK event found).
|
|
16
|
+
*/
|
|
17
|
+
export declare function reconstructLoopContext(events: BrainEvent[], webhookResponse: JsonObject): LoopResumeContext | null;
|
|
18
|
+
//# sourceMappingURL=loop-messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-messages.d.ts","sourceRoot":"","sources":["../../../src/dsl/loop-messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EAKX,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,eAAe,EAAE,UAAU,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,UAAU,EAAE,EACpB,eAAe,EAAE,UAAU,GAC1B,iBAAiB,GAAG,IAAI,CA2D1B"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { WebhookRegistration } from './webhook.js';
|
|
1
3
|
export type JsonPrimitive = string | number | boolean | null;
|
|
2
4
|
export type JsonArray = JsonValue[];
|
|
3
5
|
export type JsonObject = {
|
|
@@ -37,4 +39,65 @@ export type JsonPatch = {
|
|
|
37
39
|
value?: JsonValue;
|
|
38
40
|
from?: string;
|
|
39
41
|
}[];
|
|
42
|
+
/**
|
|
43
|
+
* Return type for tools that need to suspend execution and wait for an external event.
|
|
44
|
+
*/
|
|
45
|
+
export interface LoopToolWaitFor {
|
|
46
|
+
waitFor: WebhookRegistration<z.ZodSchema>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A tool definition for use in loop steps.
|
|
50
|
+
* Compatible with Vercel AI SDK tool format, extended with Positronic-specific properties.
|
|
51
|
+
*/
|
|
52
|
+
export interface LoopTool<TInput extends z.ZodSchema = z.ZodSchema> {
|
|
53
|
+
/** Description of what this tool does, helps the LLM understand when to use it */
|
|
54
|
+
description: string;
|
|
55
|
+
/** Zod schema defining the input parameters for this tool */
|
|
56
|
+
inputSchema: TInput;
|
|
57
|
+
/**
|
|
58
|
+
* Execute function for the tool.
|
|
59
|
+
* Can return a result directly, or { waitFor: webhook(...) } to suspend execution.
|
|
60
|
+
* Not required for terminal tools.
|
|
61
|
+
*/
|
|
62
|
+
execute?: (input: z.infer<TInput>) => Promise<unknown | LoopToolWaitFor> | unknown | LoopToolWaitFor;
|
|
63
|
+
/**
|
|
64
|
+
* If true, calling this tool ends the loop.
|
|
65
|
+
* The tool's input becomes the loop result (merged into state).
|
|
66
|
+
*/
|
|
67
|
+
terminal?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Configuration for a loop step.
|
|
71
|
+
*/
|
|
72
|
+
export interface LoopConfig<TTools extends Record<string, LoopTool> = Record<string, LoopTool>> {
|
|
73
|
+
/** System prompt for the LLM */
|
|
74
|
+
system?: string;
|
|
75
|
+
/** Initial user prompt to start the conversation */
|
|
76
|
+
prompt: string;
|
|
77
|
+
/** Tools available to the LLM */
|
|
78
|
+
tools: TTools;
|
|
79
|
+
/** Safety valve - exit if cumulative tokens exceed this limit */
|
|
80
|
+
maxTokens?: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Represents a single message in the loop conversation.
|
|
84
|
+
*/
|
|
85
|
+
export interface LoopMessage {
|
|
86
|
+
role: 'user' | 'assistant' | 'tool';
|
|
87
|
+
content: string;
|
|
88
|
+
/** For tool messages, the ID of the tool call this is responding to */
|
|
89
|
+
toolCallId?: string;
|
|
90
|
+
/** For tool messages, the name of the tool */
|
|
91
|
+
toolName?: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Helper type to extract the terminal tool's input type from a tools object.
|
|
95
|
+
* Used for typing the result that gets merged into state.
|
|
96
|
+
*/
|
|
97
|
+
export type ExtractTerminalInput<TTools extends Record<string, LoopTool>> = {
|
|
98
|
+
[K in keyof TTools]: TTools[K] extends {
|
|
99
|
+
terminal: true;
|
|
100
|
+
inputSchema: infer S;
|
|
101
|
+
} ? S extends z.ZodSchema ? z.infer<S> : never : never;
|
|
102
|
+
}[keyof TTools];
|
|
40
103
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/dsl/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AACpC,MAAM,MAAM,UAAU,GAAG;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,SAAS;CAAE,CAAC;AACzD,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC;AAE/D,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;CAEvB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/dsl/types.ts"],"names":[],"mappings":"A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AAC,KACnB,OAAO,CAAC,OAAO,GAAG,eAAe,CAAC,GAAG,OAAO,GAAG,eAAe,CAAC;IACpE;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CACzB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC;IAElE,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI;KACzE,CAAC,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS;QAAE,QAAQ,EAAE,IAAI,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC,CAAA;KAAE,GAC3E,CAAC,SAAS,CAAC,CAAC,SAAS,GACnB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GACV,KAAK,GACP,KAAK;CACV,CAAC,MAAM,MAAM,CAAC,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export { BrainRunner } from './dsl/brain-runner.js';
|
|
|
3
3
|
export { STATUS, BRAIN_EVENTS } from './dsl/constants.js';
|
|
4
4
|
export type { Adapter } from './adapters/types.js';
|
|
5
5
|
export type { BrainEvent, SerializedStep, InitialRunParams, RerunParams, BrainStartEvent, BrainCompleteEvent, BrainErrorEvent, StepStatusEvent, StepStartedEvent, StepCompletedEvent, StepRetryEvent, BrainStructure, BrainFactory, } from './dsl/brain.js';
|
|
6
|
-
export type { ObjectGenerator, Message } from './clients/types.js';
|
|
7
|
-
export type { State, RuntimeEnv, Secrets } from './dsl/types.js';
|
|
6
|
+
export type { ObjectGenerator, Message, ToolMessage } from './clients/types.js';
|
|
7
|
+
export type { State, RuntimeEnv, Secrets, LoopTool, LoopConfig, LoopMessage, LoopToolWaitFor, ExtractTerminalInput, } from './dsl/types.js';
|
|
8
8
|
export { createPatch, applyPatches } from './dsl/json-patch.js';
|
|
9
9
|
export { z } from 'zod';
|
|
10
10
|
export type { ResourceLoader } from './resources/resource-loader.js';
|
|
@@ -14,4 +14,7 @@ export type { WebhookFunction, WebhookRegistration } from './dsl/webhook.js';
|
|
|
14
14
|
export type { PagesService, Page, PageCreateOptions } from './dsl/pages.js';
|
|
15
15
|
export type { Manifest as ResourceManifest, Entry as ResourceEntry, ResourceType, } from './resources/resources.js';
|
|
16
16
|
export { RESOURCE_TYPES } from './resources/resources.js';
|
|
17
|
+
export type { LoopStartEvent, LoopIterationEvent, LoopToolCallEvent, LoopToolResultEvent, LoopAssistantMessageEvent, LoopCompleteEvent, LoopTokenLimitEvent, LoopWebhookEvent, WebhookResponseEvent, } from './dsl/brain.js';
|
|
18
|
+
export type { LoopResumeContext } from './dsl/loop-messages.js';
|
|
19
|
+
export { reconstructLoopContext } from './dsl/loop-messages.js';
|
|
17
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAu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