@positronic/core 0.0.52 → 0.0.53
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/{loop-messages.js → agent-messages.js} +21 -21
- package/dist/src/dsl/brain-runner.js +6 -6
- package/dist/src/dsl/brain-state-machine.js +2 -2
- package/dist/src/dsl/brain.js +5 -1912
- package/dist/src/dsl/builder/brain.js +944 -0
- package/dist/src/dsl/builder/step.js +75 -0
- package/dist/src/dsl/constants.js +9 -10
- package/dist/src/dsl/create-brain.js +63 -0
- package/dist/src/dsl/definitions/blocks.js +1 -0
- package/dist/src/dsl/definitions/brain-types.js +4 -0
- package/dist/src/dsl/definitions/events.js +2 -0
- package/dist/src/dsl/definitions/run-params.js +1 -0
- package/dist/src/dsl/definitions/steps.js +2 -0
- package/dist/src/dsl/execution/constants.js +14 -0
- package/dist/src/dsl/execution/event-stream.js +1638 -0
- package/dist/src/dsl/execution/retry.js +298 -0
- package/dist/src/dsl/types.js +2 -2
- package/dist/src/index.js +5 -3
- package/dist/src/tools/index.js +181 -0
- package/dist/src/ui/component-utils.js +107 -0
- package/dist/src/ui/generate-page-html.js +36 -0
- package/dist/src/ui/generate-ui.js +601 -0
- package/dist/src/ui/types.js +165 -0
- package/dist/src/ui/validate-form.js +428 -0
- package/dist/src/yaml/data-validator.js +302 -0
- package/dist/src/yaml/index.js +9 -0
- package/dist/src/yaml/parser.js +224 -0
- package/dist/src/yaml/schema-extractor.js +330 -0
- package/dist/src/yaml/type-inference.js +210 -0
- package/dist/src/yaml/types.js +12 -0
- package/dist/types/clients/types.d.ts +42 -0
- package/dist/types/clients/types.d.ts.map +1 -1
- package/dist/types/dsl/agent-messages.d.ts +18 -0
- package/dist/types/dsl/agent-messages.d.ts.map +1 -0
- package/dist/types/dsl/brain-runner.d.ts +2 -2
- package/dist/types/dsl/brain-runner.d.ts.map +1 -1
- package/dist/types/dsl/brain-state-machine.d.ts.map +1 -1
- package/dist/types/dsl/brain.d.ts +7 -273
- package/dist/types/dsl/brain.d.ts.map +1 -1
- package/dist/types/dsl/builder/brain.d.ts +200 -0
- package/dist/types/dsl/builder/brain.d.ts.map +1 -0
- package/dist/types/dsl/builder/step.d.ts +15 -0
- package/dist/types/dsl/builder/step.d.ts.map +1 -0
- package/dist/types/dsl/constants.d.ts +8 -9
- package/dist/types/dsl/constants.d.ts.map +1 -1
- package/dist/types/dsl/create-brain.d.ts +80 -0
- package/dist/types/dsl/create-brain.d.ts.map +1 -0
- package/dist/types/dsl/definitions/blocks.d.ts +62 -0
- package/dist/types/dsl/definitions/blocks.d.ts.map +1 -0
- package/dist/types/dsl/definitions/brain-types.d.ts +33 -0
- package/dist/types/dsl/definitions/brain-types.d.ts.map +1 -0
- package/dist/types/dsl/definitions/events.d.ts +129 -0
- package/dist/types/dsl/definitions/events.d.ts.map +1 -0
- package/dist/types/dsl/definitions/run-params.d.ts +26 -0
- package/dist/types/dsl/definitions/run-params.d.ts.map +1 -0
- package/dist/types/dsl/definitions/steps.d.ts +20 -0
- package/dist/types/dsl/definitions/steps.d.ts.map +1 -0
- package/dist/types/dsl/example-webhook.d.ts +1 -1
- package/dist/types/dsl/example-webhook.d.ts.map +1 -1
- package/dist/types/dsl/execution/constants.d.ts +16 -0
- package/dist/types/dsl/execution/constants.d.ts.map +1 -0
- package/dist/types/dsl/execution/event-stream.d.ts +44 -0
- package/dist/types/dsl/execution/event-stream.d.ts.map +1 -0
- package/dist/types/dsl/execution/retry.d.ts +30 -0
- package/dist/types/dsl/execution/retry.d.ts.map +1 -0
- package/dist/types/dsl/types.d.ts +35 -14
- package/dist/types/dsl/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +9 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/tools/index.d.ts +33 -0
- package/dist/types/tools/index.d.ts.map +1 -0
- package/dist/types/ui/component-utils.d.ts +19 -0
- package/dist/types/ui/component-utils.d.ts.map +1 -0
- package/dist/types/ui/generate-page-html.d.ts +39 -0
- package/dist/types/ui/generate-page-html.d.ts.map +1 -0
- package/dist/types/ui/generate-ui.d.ts +47 -0
- package/dist/types/ui/generate-ui.d.ts.map +1 -0
- package/dist/types/ui/types.d.ts +138 -0
- package/dist/types/ui/types.d.ts.map +1 -0
- package/dist/types/ui/validate-form.d.ts +45 -0
- package/dist/types/ui/validate-form.d.ts.map +1 -0
- package/dist/types/yaml/data-validator.d.ts +35 -0
- package/dist/types/yaml/data-validator.d.ts.map +1 -0
- package/dist/types/yaml/index.d.ts +11 -0
- package/dist/types/yaml/index.d.ts.map +1 -0
- package/dist/types/yaml/parser.d.ts +20 -0
- package/dist/types/yaml/parser.d.ts.map +1 -0
- package/dist/types/yaml/schema-extractor.d.ts +29 -0
- package/dist/types/yaml/schema-extractor.d.ts.map +1 -0
- package/dist/types/yaml/type-inference.d.ts +50 -0
- package/dist/types/yaml/type-inference.d.ts.map +1 -0
- package/dist/types/yaml/types.d.ts +89 -0
- package/dist/types/yaml/types.d.ts.map +1 -0
- package/package.json +4 -2
- package/dist/types/dsl/loop-messages.d.ts +0 -18
- package/dist/types/dsl/loop-messages.d.ts.map +0 -1
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema extractor for YAML templates.
|
|
3
|
+
*
|
|
4
|
+
* Extracts the form schema that will be produced by the template's form fields.
|
|
5
|
+
* Also validates extracted schema against expected Zod schemas.
|
|
6
|
+
*/ function _array_like_to_array(arr, len) {
|
|
7
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
8
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
9
|
+
return arr2;
|
|
10
|
+
}
|
|
11
|
+
function _array_with_holes(arr) {
|
|
12
|
+
if (Array.isArray(arr)) return arr;
|
|
13
|
+
}
|
|
14
|
+
function _instanceof(left, right) {
|
|
15
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
16
|
+
return !!right[Symbol.hasInstance](left);
|
|
17
|
+
} else {
|
|
18
|
+
return left instanceof right;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function _iterable_to_array_limit(arr, i) {
|
|
22
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
23
|
+
if (_i == null) return;
|
|
24
|
+
var _arr = [];
|
|
25
|
+
var _n = true;
|
|
26
|
+
var _d = false;
|
|
27
|
+
var _s, _e;
|
|
28
|
+
try {
|
|
29
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
30
|
+
_arr.push(_s.value);
|
|
31
|
+
if (i && _arr.length === i) break;
|
|
32
|
+
}
|
|
33
|
+
} catch (err) {
|
|
34
|
+
_d = true;
|
|
35
|
+
_e = err;
|
|
36
|
+
} finally{
|
|
37
|
+
try {
|
|
38
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
39
|
+
} finally{
|
|
40
|
+
if (_d) throw _e;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return _arr;
|
|
44
|
+
}
|
|
45
|
+
function _non_iterable_rest() {
|
|
46
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
47
|
+
}
|
|
48
|
+
function _sliced_to_array(arr, i) {
|
|
49
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
50
|
+
}
|
|
51
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
52
|
+
if (!o) return;
|
|
53
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
54
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
55
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
56
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
57
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
58
|
+
}
|
|
59
|
+
import { z } from 'zod';
|
|
60
|
+
/**
|
|
61
|
+
* Map of component names to their form field types.
|
|
62
|
+
*/ var FORM_COMPONENTS = {
|
|
63
|
+
Input: 'string',
|
|
64
|
+
TextInput: 'string',
|
|
65
|
+
NumberInput: 'number',
|
|
66
|
+
Checkbox: 'boolean',
|
|
67
|
+
Select: 'string',
|
|
68
|
+
RadioGroup: 'string',
|
|
69
|
+
TextArea: 'string',
|
|
70
|
+
HiddenInput: 'string',
|
|
71
|
+
MultiTextInput: 'string[]'
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Extract form fields from a component tree.
|
|
75
|
+
*
|
|
76
|
+
* @param root - The root ComponentNode
|
|
77
|
+
* @returns ExtractedFormSchema with all form fields found
|
|
78
|
+
*/ export function extractFormSchema(root) {
|
|
79
|
+
var fields = [];
|
|
80
|
+
function extractFromNode(node, insideLoop) {
|
|
81
|
+
// Check if this is a form component
|
|
82
|
+
var fieldType = FORM_COMPONENTS[node.component];
|
|
83
|
+
// Special handling for Checkbox: if it has a value prop, it returns that string value
|
|
84
|
+
if (node.component === 'Checkbox') {
|
|
85
|
+
var valueProp = node.props.value;
|
|
86
|
+
fieldType = valueProp ? 'string' : 'boolean';
|
|
87
|
+
}
|
|
88
|
+
if (fieldType) {
|
|
89
|
+
var nameProp = node.props.name;
|
|
90
|
+
if ((nameProp === null || nameProp === void 0 ? void 0 : nameProp.type) === 'literal' && typeof nameProp.value === 'string') {
|
|
91
|
+
var name = nameProp.value;
|
|
92
|
+
// Determine final type - arrays if inside loop or already array type
|
|
93
|
+
var finalType = fieldType;
|
|
94
|
+
if (insideLoop && !fieldType.endsWith('[]')) {
|
|
95
|
+
finalType = "".concat(fieldType, "[]");
|
|
96
|
+
}
|
|
97
|
+
fields.push({
|
|
98
|
+
name: name,
|
|
99
|
+
type: finalType,
|
|
100
|
+
insideLoop: insideLoop
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Check if this is a loop component
|
|
105
|
+
var isLoopComponent = node.component === 'List' || node.component === 'Each';
|
|
106
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
107
|
+
try {
|
|
108
|
+
// Recurse into children
|
|
109
|
+
for(var _iterator = node.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
110
|
+
var child = _step.value;
|
|
111
|
+
extractFromNode(child, insideLoop || isLoopComponent);
|
|
112
|
+
}
|
|
113
|
+
} catch (err) {
|
|
114
|
+
_didIteratorError = true;
|
|
115
|
+
_iteratorError = err;
|
|
116
|
+
} finally{
|
|
117
|
+
try {
|
|
118
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
119
|
+
_iterator.return();
|
|
120
|
+
}
|
|
121
|
+
} finally{
|
|
122
|
+
if (_didIteratorError) {
|
|
123
|
+
throw _iteratorError;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
extractFromNode(root, false);
|
|
129
|
+
return {
|
|
130
|
+
fields: fields
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Convert extracted fields to a nested object shape.
|
|
135
|
+
* Handles dot notation like "user.email" -> { user: { email: ... } }
|
|
136
|
+
*/ export function fieldsToShape(fields) {
|
|
137
|
+
var shape = {};
|
|
138
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
139
|
+
try {
|
|
140
|
+
for(var _iterator = fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
141
|
+
var field = _step.value;
|
|
142
|
+
var parts = field.name.split('.');
|
|
143
|
+
var current = shape;
|
|
144
|
+
for(var i = 0; i < parts.length - 1; i++){
|
|
145
|
+
var part = parts[i];
|
|
146
|
+
if (!(part in current)) {
|
|
147
|
+
current[part] = {};
|
|
148
|
+
}
|
|
149
|
+
current = current[part];
|
|
150
|
+
}
|
|
151
|
+
var lastPart = parts[parts.length - 1];
|
|
152
|
+
current[lastPart] = field.type;
|
|
153
|
+
}
|
|
154
|
+
} catch (err) {
|
|
155
|
+
_didIteratorError = true;
|
|
156
|
+
_iteratorError = err;
|
|
157
|
+
} finally{
|
|
158
|
+
try {
|
|
159
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
160
|
+
_iterator.return();
|
|
161
|
+
}
|
|
162
|
+
} finally{
|
|
163
|
+
if (_didIteratorError) {
|
|
164
|
+
throw _iteratorError;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return shape;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Check if a Zod schema expects an array type.
|
|
172
|
+
*/ function isZodArray(schema) {
|
|
173
|
+
if (_instanceof(schema, z.ZodArray)) {
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
if (_instanceof(schema, z.ZodOptional) || _instanceof(schema, z.ZodNullable)) {
|
|
177
|
+
return isZodArray(schema.unwrap());
|
|
178
|
+
}
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Check if a Zod schema expects a string type.
|
|
183
|
+
*/ function isZodString(schema) {
|
|
184
|
+
if (_instanceof(schema, z.ZodString)) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
if (_instanceof(schema, z.ZodOptional) || _instanceof(schema, z.ZodNullable)) {
|
|
188
|
+
return isZodString(schema.unwrap());
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Check if a Zod schema expects a number type.
|
|
194
|
+
*/ function isZodNumber(schema) {
|
|
195
|
+
if (_instanceof(schema, z.ZodNumber)) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
if (_instanceof(schema, z.ZodOptional) || _instanceof(schema, z.ZodNullable)) {
|
|
199
|
+
return isZodNumber(schema.unwrap());
|
|
200
|
+
}
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Check if a Zod schema expects a boolean type.
|
|
205
|
+
*/ function isZodBoolean(schema) {
|
|
206
|
+
if (_instanceof(schema, z.ZodBoolean)) {
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
if (_instanceof(schema, z.ZodOptional) || _instanceof(schema, z.ZodNullable)) {
|
|
210
|
+
return isZodBoolean(schema.unwrap());
|
|
211
|
+
}
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Check if a field type matches a Zod schema.
|
|
216
|
+
*/ function fieldTypeMatchesSchema(fieldType, zodSchema) {
|
|
217
|
+
// Handle array types
|
|
218
|
+
if (fieldType === 'string[]' || fieldType === 'number[]') {
|
|
219
|
+
if (!isZodArray(zodSchema)) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
// Get the element schema
|
|
223
|
+
var elementSchema = zodSchema;
|
|
224
|
+
if (_instanceof(elementSchema, z.ZodOptional) || _instanceof(elementSchema, z.ZodNullable)) {
|
|
225
|
+
elementSchema = elementSchema.unwrap();
|
|
226
|
+
}
|
|
227
|
+
if (_instanceof(elementSchema, z.ZodArray)) {
|
|
228
|
+
var innerType = elementSchema.element;
|
|
229
|
+
if (fieldType === 'string[]') {
|
|
230
|
+
return isZodString(innerType);
|
|
231
|
+
}
|
|
232
|
+
if (fieldType === 'number[]') {
|
|
233
|
+
return isZodNumber(innerType);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
// Handle primitive types
|
|
239
|
+
switch(fieldType){
|
|
240
|
+
case 'string':
|
|
241
|
+
return isZodString(zodSchema);
|
|
242
|
+
case 'number':
|
|
243
|
+
return isZodNumber(zodSchema);
|
|
244
|
+
case 'boolean':
|
|
245
|
+
return isZodBoolean(zodSchema);
|
|
246
|
+
default:
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Validate an extracted schema against an expected Zod schema.
|
|
252
|
+
*
|
|
253
|
+
* @param extracted - The ExtractedFormSchema from the template
|
|
254
|
+
* @param zodSchema - The expected Zod schema (must be ZodObject)
|
|
255
|
+
* @returns Array of validation errors
|
|
256
|
+
*/ export function validateAgainstZod(extracted, zodSchema) {
|
|
257
|
+
var errors = [];
|
|
258
|
+
// Check that zodSchema is an object schema
|
|
259
|
+
if (!_instanceof(zodSchema, z.ZodObject)) {
|
|
260
|
+
errors.push({
|
|
261
|
+
type: 'form-schema-mismatch',
|
|
262
|
+
message: 'Expected schema must be a ZodObject'
|
|
263
|
+
});
|
|
264
|
+
return errors;
|
|
265
|
+
}
|
|
266
|
+
var expectedShape = zodSchema.shape;
|
|
267
|
+
var extractedFieldNames = new Set(extracted.fields.map(function(f) {
|
|
268
|
+
return f.name;
|
|
269
|
+
}));
|
|
270
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
271
|
+
try {
|
|
272
|
+
// Check for missing required fields
|
|
273
|
+
for(var _iterator = Object.entries(expectedShape)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
274
|
+
var _step_value = _sliced_to_array(_step.value, 2), fieldName = _step_value[0], fieldSchema = _step_value[1];
|
|
275
|
+
var isOptional = _instanceof(fieldSchema, z.ZodOptional) || _instanceof(fieldSchema, z.ZodNullable);
|
|
276
|
+
if (!isOptional && !extractedFieldNames.has(fieldName)) {
|
|
277
|
+
errors.push({
|
|
278
|
+
type: 'form-schema-mismatch',
|
|
279
|
+
message: 'Missing required form field: "'.concat(fieldName, '"'),
|
|
280
|
+
path: fieldName
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
} catch (err) {
|
|
285
|
+
_didIteratorError = true;
|
|
286
|
+
_iteratorError = err;
|
|
287
|
+
} finally{
|
|
288
|
+
try {
|
|
289
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
290
|
+
_iterator.return();
|
|
291
|
+
}
|
|
292
|
+
} finally{
|
|
293
|
+
if (_didIteratorError) {
|
|
294
|
+
throw _iteratorError;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
299
|
+
try {
|
|
300
|
+
// Check type compatibility for extracted fields
|
|
301
|
+
for(var _iterator1 = extracted.fields[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
302
|
+
var field = _step1.value;
|
|
303
|
+
var expectedFieldSchema = expectedShape[field.name];
|
|
304
|
+
if (!expectedFieldSchema) {
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
if (!fieldTypeMatchesSchema(field.type, expectedFieldSchema)) {
|
|
308
|
+
errors.push({
|
|
309
|
+
type: 'form-schema-mismatch',
|
|
310
|
+
message: 'Field "'.concat(field.name, '" has type "').concat(field.type, '" but expected schema requires different type'),
|
|
311
|
+
path: field.name
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
} catch (err) {
|
|
316
|
+
_didIteratorError1 = true;
|
|
317
|
+
_iteratorError1 = err;
|
|
318
|
+
} finally{
|
|
319
|
+
try {
|
|
320
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
321
|
+
_iterator1.return();
|
|
322
|
+
}
|
|
323
|
+
} finally{
|
|
324
|
+
if (_didIteratorError1) {
|
|
325
|
+
throw _iteratorError1;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return errors;
|
|
330
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type inference for generating readable data shape descriptions.
|
|
3
|
+
*
|
|
4
|
+
* Used to describe available data to the LLM in a TypeScript-like format
|
|
5
|
+
* with inline examples for better template generation.
|
|
6
|
+
*/ /**
|
|
7
|
+
* Infer a type description for a value.
|
|
8
|
+
* Returns a simple type string like "string", "number", etc.
|
|
9
|
+
*/ function _array_like_to_array(arr, len) {
|
|
10
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
11
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
12
|
+
return arr2;
|
|
13
|
+
}
|
|
14
|
+
function _array_with_holes(arr) {
|
|
15
|
+
if (Array.isArray(arr)) return arr;
|
|
16
|
+
}
|
|
17
|
+
function _iterable_to_array_limit(arr, i) {
|
|
18
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
19
|
+
if (_i == null) return;
|
|
20
|
+
var _arr = [];
|
|
21
|
+
var _n = true;
|
|
22
|
+
var _d = false;
|
|
23
|
+
var _s, _e;
|
|
24
|
+
try {
|
|
25
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
26
|
+
_arr.push(_s.value);
|
|
27
|
+
if (i && _arr.length === i) break;
|
|
28
|
+
}
|
|
29
|
+
} catch (err) {
|
|
30
|
+
_d = true;
|
|
31
|
+
_e = err;
|
|
32
|
+
} finally{
|
|
33
|
+
try {
|
|
34
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
35
|
+
} finally{
|
|
36
|
+
if (_d) throw _e;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return _arr;
|
|
40
|
+
}
|
|
41
|
+
function _non_iterable_rest() {
|
|
42
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
43
|
+
}
|
|
44
|
+
function _sliced_to_array(arr, i) {
|
|
45
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
46
|
+
}
|
|
47
|
+
function _type_of(obj) {
|
|
48
|
+
"@swc/helpers - typeof";
|
|
49
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
50
|
+
}
|
|
51
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
52
|
+
if (!o) return;
|
|
53
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
54
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
55
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
56
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
57
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
58
|
+
}
|
|
59
|
+
export function inferTypeDescription(value) {
|
|
60
|
+
if (value === null) {
|
|
61
|
+
return 'null';
|
|
62
|
+
}
|
|
63
|
+
if (value === undefined) {
|
|
64
|
+
return 'undefined';
|
|
65
|
+
}
|
|
66
|
+
if (typeof value === 'string') {
|
|
67
|
+
return 'string';
|
|
68
|
+
}
|
|
69
|
+
if (typeof value === 'number') {
|
|
70
|
+
return 'number';
|
|
71
|
+
}
|
|
72
|
+
if (typeof value === 'boolean') {
|
|
73
|
+
return 'boolean';
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(value)) {
|
|
76
|
+
if (value.length === 0) {
|
|
77
|
+
return 'unknown[]';
|
|
78
|
+
}
|
|
79
|
+
var elementType = inferTypeDescription(value[0]);
|
|
80
|
+
return "".concat(elementType, "[]");
|
|
81
|
+
}
|
|
82
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object') {
|
|
83
|
+
return 'object';
|
|
84
|
+
}
|
|
85
|
+
return 'unknown';
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Truncate a string to a maximum length with ellipsis.
|
|
89
|
+
*/ function truncate(str, maxLength) {
|
|
90
|
+
if (str.length <= maxLength) {
|
|
91
|
+
return str;
|
|
92
|
+
}
|
|
93
|
+
return str.slice(0, maxLength - 3) + '...';
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Format a value as an example (for inline comments).
|
|
97
|
+
*/ function formatExample(value) {
|
|
98
|
+
if (value === null) {
|
|
99
|
+
return 'null';
|
|
100
|
+
}
|
|
101
|
+
if (typeof value === 'string') {
|
|
102
|
+
return '"'.concat(truncate(value, 30), '"');
|
|
103
|
+
}
|
|
104
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
105
|
+
return String(value);
|
|
106
|
+
}
|
|
107
|
+
return '...';
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Infer a type description with inline examples.
|
|
111
|
+
* Makes it easier for the LLM to understand the data shape.
|
|
112
|
+
*
|
|
113
|
+
* @param value - The sample value to describe
|
|
114
|
+
* @param indent - Current indentation level
|
|
115
|
+
* @returns Multi-line string describing the type with examples
|
|
116
|
+
*/ export function inferTypeWithExamples(value) {
|
|
117
|
+
var indent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
118
|
+
var spaces = ' '.repeat(indent);
|
|
119
|
+
if (value === null) {
|
|
120
|
+
return 'null';
|
|
121
|
+
}
|
|
122
|
+
if (value === undefined) {
|
|
123
|
+
return 'undefined';
|
|
124
|
+
}
|
|
125
|
+
if (typeof value === 'string') {
|
|
126
|
+
return "string // e.g., ".concat(formatExample(value));
|
|
127
|
+
}
|
|
128
|
+
if (typeof value === 'number') {
|
|
129
|
+
return "number // e.g., ".concat(value);
|
|
130
|
+
}
|
|
131
|
+
if (typeof value === 'boolean') {
|
|
132
|
+
return "boolean // e.g., ".concat(value);
|
|
133
|
+
}
|
|
134
|
+
if (Array.isArray(value)) {
|
|
135
|
+
if (value.length === 0) {
|
|
136
|
+
return 'unknown[] // empty array';
|
|
137
|
+
}
|
|
138
|
+
var firstElement = value[0];
|
|
139
|
+
var elementType = inferTypeWithExamples(firstElement, indent + 1);
|
|
140
|
+
// For primitive arrays, keep it compact
|
|
141
|
+
if (typeof firstElement === 'string' || typeof firstElement === 'number' || typeof firstElement === 'boolean') {
|
|
142
|
+
return "Array<".concat(inferTypeDescription(firstElement), "> // ").concat(value.length, " items, e.g., ").concat(formatExample(firstElement));
|
|
143
|
+
}
|
|
144
|
+
// For object arrays, show the structure
|
|
145
|
+
return "Array<".concat(elementType, "> // ").concat(value.length, " items");
|
|
146
|
+
}
|
|
147
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object') {
|
|
148
|
+
var entries = Object.entries(value);
|
|
149
|
+
if (entries.length === 0) {
|
|
150
|
+
return '{}';
|
|
151
|
+
}
|
|
152
|
+
var lines = [
|
|
153
|
+
'{'
|
|
154
|
+
];
|
|
155
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
156
|
+
try {
|
|
157
|
+
for(var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
158
|
+
var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], val = _step_value[1];
|
|
159
|
+
var valType = inferTypeWithExamples(val, indent + 1);
|
|
160
|
+
lines.push("".concat(spaces, " ").concat(key, ": ").concat(valType));
|
|
161
|
+
}
|
|
162
|
+
} catch (err) {
|
|
163
|
+
_didIteratorError = true;
|
|
164
|
+
_iteratorError = err;
|
|
165
|
+
} finally{
|
|
166
|
+
try {
|
|
167
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
168
|
+
_iterator.return();
|
|
169
|
+
}
|
|
170
|
+
} finally{
|
|
171
|
+
if (_didIteratorError) {
|
|
172
|
+
throw _iteratorError;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
lines.push("".concat(spaces, "}"));
|
|
177
|
+
return lines.join('\n');
|
|
178
|
+
}
|
|
179
|
+
return 'unknown';
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Describe the shape of data in a readable TypeScript-like format.
|
|
183
|
+
* This is the main entry point for generating data descriptions for the LLM.
|
|
184
|
+
*
|
|
185
|
+
* @param data - The data object to describe
|
|
186
|
+
* @returns A multi-line string describing the data shape with examples
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* const data = {
|
|
191
|
+
* emails: [
|
|
192
|
+
* { id: "1", subject: "Hello", from: "alice@example.com" }
|
|
193
|
+
* ],
|
|
194
|
+
* sessionId: "abc123"
|
|
195
|
+
* };
|
|
196
|
+
*
|
|
197
|
+
* console.log(describeDataShape(data));
|
|
198
|
+
* // Output:
|
|
199
|
+
* // {
|
|
200
|
+
* // emails: Array<{
|
|
201
|
+
* // id: string // e.g., "1"
|
|
202
|
+
* // subject: string // e.g., "Hello"
|
|
203
|
+
* // from: string // e.g., "alice@example.com"
|
|
204
|
+
* // }> // 1 items
|
|
205
|
+
* // sessionId: string // e.g., "abc123"
|
|
206
|
+
* // }
|
|
207
|
+
* ```
|
|
208
|
+
*/ export function describeDataShape(data) {
|
|
209
|
+
return inferTypeWithExamples(data, 0);
|
|
210
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the YAML-based UI generation DSL.
|
|
3
|
+
*
|
|
4
|
+
* Templates are written in YAML and parsed into an AST of ComponentNodes.
|
|
5
|
+
* Props can be literal values or binding expressions ({{path}}) that are
|
|
6
|
+
* resolved at render time against provided data.
|
|
7
|
+
*/ /**
|
|
8
|
+
* A binding expression like {{emails}} or {{email.subject}}
|
|
9
|
+
* that references data to be resolved at render time.
|
|
10
|
+
*/ /**
|
|
11
|
+
* Data type inference for validating bindings.
|
|
12
|
+
*/ export { };
|
|
@@ -84,5 +84,47 @@ export interface ObjectGenerator {
|
|
|
84
84
|
totalTokens: number;
|
|
85
85
|
};
|
|
86
86
|
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Generates text with multi-step tool calling support.
|
|
89
|
+
* Used for agentic workflows that require multiple LLM iterations.
|
|
90
|
+
*
|
|
91
|
+
* Unlike generateText (single step), this method:
|
|
92
|
+
* - Executes tools and feeds results back to the LLM automatically
|
|
93
|
+
* - Continues until maxSteps reached or LLM stops calling tools
|
|
94
|
+
* - Returns all tool calls with their results
|
|
95
|
+
*
|
|
96
|
+
* This is a thin wrapper around the underlying SDK's multi-step capabilities
|
|
97
|
+
* (e.g., Vercel AI SDK's stopWhen: stepCountIs()).
|
|
98
|
+
*/
|
|
99
|
+
streamText(params: {
|
|
100
|
+
/** System prompt for the LLM */
|
|
101
|
+
system?: string;
|
|
102
|
+
/** Initial user prompt */
|
|
103
|
+
prompt: string;
|
|
104
|
+
/** Conversation messages (optional, for context) */
|
|
105
|
+
messages?: ToolMessage[];
|
|
106
|
+
/** Available tools for the LLM to call */
|
|
107
|
+
tools: Record<string, {
|
|
108
|
+
description: string;
|
|
109
|
+
inputSchema: z.ZodSchema;
|
|
110
|
+
execute?: (args: unknown) => Promise<unknown> | unknown;
|
|
111
|
+
}>;
|
|
112
|
+
/** Maximum number of LLM iterations (default: 10) */
|
|
113
|
+
maxSteps?: number;
|
|
114
|
+
}): Promise<{
|
|
115
|
+
/** All tool calls made across all steps, with their results */
|
|
116
|
+
toolCalls: Array<{
|
|
117
|
+
toolCallId: string;
|
|
118
|
+
toolName: string;
|
|
119
|
+
args: unknown;
|
|
120
|
+
result: unknown;
|
|
121
|
+
}>;
|
|
122
|
+
/** Final text response (if any) */
|
|
123
|
+
text?: string;
|
|
124
|
+
/** Token usage across all steps */
|
|
125
|
+
usage: {
|
|
126
|
+
totalTokens: number;
|
|
127
|
+
};
|
|
128
|
+
}>;
|
|
87
129
|
}
|
|
88
130
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/clients/types.ts"],"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AAM,CAAC;YACnB,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,OAAO,CAAC;YACd,MAAM,EAAE,OAAO,CAAC;SACjB,CAAC,CAAC;QACH,mCAAmC;QACnC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,mCAAmC;QACnC,KAAK,EAAE;YAAE,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC;KAChC,CAAC,CAAC;CACJ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BrainEvent } from './definitions/events.js';
|
|
2
|
+
import type { ToolMessage } from '../clients/types.js';
|
|
3
|
+
import type { JsonObject } from './types.js';
|
|
4
|
+
export interface AgentResumeContext {
|
|
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 agent context from stored events and a webhook response.
|
|
15
|
+
* Returns null if this is not an agent resume (no AGENT_WEBHOOK event found).
|
|
16
|
+
*/
|
|
17
|
+
export declare function reconstructAgentContext(events: BrainEvent[], webhookResponse: JsonObject): AgentResumeContext | null;
|
|
18
|
+
//# sourceMappingURL=agent-messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-messages.d.ts","sourceRoot":"","sources":["../../../src/dsl/agent-messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EAKX,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC,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,uBAAuB,CACrC,MAAM,EAAE,UAAU,EAAE,EACpB,eAAe,EAAE,UAAU,GAC1B,kBAAkB,GAAG,IAAI,CA2D3B"}
|
|
@@ -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, agentEvents, }?: {
|
|
22
22
|
initialState?: TState;
|
|
23
23
|
options?: TOptions;
|
|
24
24
|
initialCompletedSteps?: SerializedStep[] | never;
|
|
@@ -26,7 +26,7 @@ export declare class BrainRunner {
|
|
|
26
26
|
endAfter?: number;
|
|
27
27
|
signal?: AbortSignal;
|
|
28
28
|
response?: JsonObject;
|
|
29
|
-
|
|
29
|
+
agentEvents?: BrainEvent[];
|
|
30
30
|
}): Promise<TState>;
|
|
31
31
|
}
|
|
32
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":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAe,KAAK,cAAc,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;A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