@positronic/core 0.0.77 → 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 -412
- 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 -1474
- 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 +85 -228
- 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 -66
- 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 -56
- 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 -13
- 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
|
@@ -65,7 +65,6 @@ import { BRAIN_EVENTS, STATUS } from './constants.js';
|
|
|
65
65
|
KILL: BRAIN_EVENTS.CANCELLED,
|
|
66
66
|
PAUSE: BRAIN_EVENTS.PAUSED,
|
|
67
67
|
RESUME: BRAIN_EVENTS.RESUMED,
|
|
68
|
-
USER_MESSAGE: BRAIN_EVENTS.AGENT_USER_MESSAGE,
|
|
69
68
|
WEBHOOK_RESPONSE: BRAIN_EVENTS.WEBHOOK_RESPONSE
|
|
70
69
|
};
|
|
71
70
|
var _obj;
|
package/dist/src/dsl/webhook.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Factory function to create webhooks
|
|
2
|
-
export function createWebhook(slug, schema, handler) {
|
|
2
|
+
export function createWebhook(slug, schema, handler, triggers) {
|
|
3
3
|
// Create the registration function
|
|
4
4
|
var webhookFn = function(identifier, token) {
|
|
5
5
|
return {
|
|
@@ -13,5 +13,8 @@ export function createWebhook(slug, schema, handler) {
|
|
|
13
13
|
webhookFn.handler = handler;
|
|
14
14
|
webhookFn.slug = slug;
|
|
15
15
|
webhookFn.schema = schema;
|
|
16
|
+
if (triggers) {
|
|
17
|
+
webhookFn.triggers = triggers;
|
|
18
|
+
}
|
|
16
19
|
return webhookFn;
|
|
17
20
|
}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _ts_generator(thisArg, body) {
|
|
31
|
+
var f, y, t, _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function() {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
40
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
41
|
+
return this;
|
|
42
|
+
}), g;
|
|
43
|
+
function verb(n) {
|
|
44
|
+
return function(v) {
|
|
45
|
+
return step([
|
|
46
|
+
n,
|
|
47
|
+
v
|
|
48
|
+
]);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function step(op) {
|
|
52
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
53
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
54
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
55
|
+
if (y = 0, t) op = [
|
|
56
|
+
op[0] & 2,
|
|
57
|
+
t.value
|
|
58
|
+
];
|
|
59
|
+
switch(op[0]){
|
|
60
|
+
case 0:
|
|
61
|
+
case 1:
|
|
62
|
+
t = op;
|
|
63
|
+
break;
|
|
64
|
+
case 4:
|
|
65
|
+
_.label++;
|
|
66
|
+
return {
|
|
67
|
+
value: op[1],
|
|
68
|
+
done: false
|
|
69
|
+
};
|
|
70
|
+
case 5:
|
|
71
|
+
_.label++;
|
|
72
|
+
y = op[1];
|
|
73
|
+
op = [
|
|
74
|
+
0
|
|
75
|
+
];
|
|
76
|
+
continue;
|
|
77
|
+
case 7:
|
|
78
|
+
op = _.ops.pop();
|
|
79
|
+
_.trys.pop();
|
|
80
|
+
continue;
|
|
81
|
+
default:
|
|
82
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
+
_ = 0;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
+
_.label = op[1];
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
+
_.label = t[1];
|
|
92
|
+
t = op;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (t && _.label < t[2]) {
|
|
96
|
+
_.label = t[2];
|
|
97
|
+
_.ops.push(op);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (t[2]) _.ops.pop();
|
|
101
|
+
_.trys.pop();
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
op = body.call(thisArg, _);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
op = [
|
|
107
|
+
6,
|
|
108
|
+
e
|
|
109
|
+
];
|
|
110
|
+
y = 0;
|
|
111
|
+
} finally{
|
|
112
|
+
f = t = 0;
|
|
113
|
+
}
|
|
114
|
+
if (op[0] & 5) throw op[1];
|
|
115
|
+
return {
|
|
116
|
+
value: op[0] ? op[1] : void 0,
|
|
117
|
+
done: true
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
import { BRAIN_EVENTS } from '../dsl/constants.js';
|
|
122
|
+
function startEvent(ctx, fileName) {
|
|
123
|
+
return {
|
|
124
|
+
type: BRAIN_EVENTS.FILE_WRITE_START,
|
|
125
|
+
fileName: fileName,
|
|
126
|
+
stepTitle: ctx.stepTitle,
|
|
127
|
+
options: ctx.options,
|
|
128
|
+
brainRunId: ctx.brainRunId
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function completeEvent(ctx, fileName) {
|
|
132
|
+
return {
|
|
133
|
+
type: BRAIN_EVENTS.FILE_WRITE_COMPLETE,
|
|
134
|
+
fileName: fileName,
|
|
135
|
+
stepTitle: ctx.stepTitle,
|
|
136
|
+
options: ctx.options,
|
|
137
|
+
brainRunId: ctx.brainRunId
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function wrapFileHandle(handle, channel, ctx) {
|
|
141
|
+
return {
|
|
142
|
+
name: handle.name,
|
|
143
|
+
get url () {
|
|
144
|
+
return handle.url;
|
|
145
|
+
},
|
|
146
|
+
read: function() {
|
|
147
|
+
return handle.read();
|
|
148
|
+
},
|
|
149
|
+
readBytes: function() {
|
|
150
|
+
return handle.readBytes();
|
|
151
|
+
},
|
|
152
|
+
write: function write(content) {
|
|
153
|
+
return _async_to_generator(function() {
|
|
154
|
+
var ref;
|
|
155
|
+
return _ts_generator(this, function(_state) {
|
|
156
|
+
switch(_state.label){
|
|
157
|
+
case 0:
|
|
158
|
+
channel.push(startEvent(ctx, handle.name));
|
|
159
|
+
return [
|
|
160
|
+
4,
|
|
161
|
+
handle.write(content)
|
|
162
|
+
];
|
|
163
|
+
case 1:
|
|
164
|
+
ref = _state.sent();
|
|
165
|
+
channel.push(completeEvent(ctx, handle.name));
|
|
166
|
+
return [
|
|
167
|
+
2,
|
|
168
|
+
ref
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
})();
|
|
173
|
+
},
|
|
174
|
+
exists: function() {
|
|
175
|
+
return handle.exists();
|
|
176
|
+
},
|
|
177
|
+
delete: function() {
|
|
178
|
+
return handle.delete();
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function wrapZipBuilder(zip, channel, ctx, zipName) {
|
|
183
|
+
return {
|
|
184
|
+
write: function write(name, content) {
|
|
185
|
+
return _async_to_generator(function() {
|
|
186
|
+
return _ts_generator(this, function(_state) {
|
|
187
|
+
switch(_state.label){
|
|
188
|
+
case 0:
|
|
189
|
+
channel.push(startEvent(ctx, name));
|
|
190
|
+
return [
|
|
191
|
+
4,
|
|
192
|
+
zip.write(name, content)
|
|
193
|
+
];
|
|
194
|
+
case 1:
|
|
195
|
+
_state.sent();
|
|
196
|
+
channel.push(completeEvent(ctx, name));
|
|
197
|
+
return [
|
|
198
|
+
2
|
|
199
|
+
];
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
})();
|
|
203
|
+
},
|
|
204
|
+
finalize: function finalize() {
|
|
205
|
+
return _async_to_generator(function() {
|
|
206
|
+
var ref;
|
|
207
|
+
return _ts_generator(this, function(_state) {
|
|
208
|
+
switch(_state.label){
|
|
209
|
+
case 0:
|
|
210
|
+
channel.push(startEvent(ctx, zipName));
|
|
211
|
+
return [
|
|
212
|
+
4,
|
|
213
|
+
zip.finalize()
|
|
214
|
+
];
|
|
215
|
+
case 1:
|
|
216
|
+
ref = _state.sent();
|
|
217
|
+
channel.push(completeEvent(ctx, zipName));
|
|
218
|
+
return [
|
|
219
|
+
2,
|
|
220
|
+
ref
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
})();
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Wraps a FilesService to push events onto a channel during write operations.
|
|
230
|
+
* The wrapper is transparent — same interface, brain authors see no change.
|
|
231
|
+
*/ export function wrapFilesWithEvents(files, channel, ctx) {
|
|
232
|
+
return {
|
|
233
|
+
open: function open(name, options) {
|
|
234
|
+
return wrapFileHandle(files.open(name, options), channel, ctx);
|
|
235
|
+
},
|
|
236
|
+
write: function write(name, content, options) {
|
|
237
|
+
return _async_to_generator(function() {
|
|
238
|
+
var ref;
|
|
239
|
+
return _ts_generator(this, function(_state) {
|
|
240
|
+
switch(_state.label){
|
|
241
|
+
case 0:
|
|
242
|
+
channel.push(startEvent(ctx, name));
|
|
243
|
+
return [
|
|
244
|
+
4,
|
|
245
|
+
files.write(name, content, options)
|
|
246
|
+
];
|
|
247
|
+
case 1:
|
|
248
|
+
ref = _state.sent();
|
|
249
|
+
channel.push(completeEvent(ctx, name));
|
|
250
|
+
return [
|
|
251
|
+
2,
|
|
252
|
+
ref
|
|
253
|
+
];
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
})();
|
|
257
|
+
},
|
|
258
|
+
list: function() {
|
|
259
|
+
return files.list();
|
|
260
|
+
},
|
|
261
|
+
delete: function(name) {
|
|
262
|
+
return files.delete(name);
|
|
263
|
+
},
|
|
264
|
+
zip: function zip(name, options) {
|
|
265
|
+
return wrapZipBuilder(files.zip(name, options), channel, ctx, name);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var MIME_TYPES = {
|
|
2
|
+
txt: 'text/plain',
|
|
3
|
+
json: 'application/json',
|
|
4
|
+
html: 'text/html',
|
|
5
|
+
css: 'text/css',
|
|
6
|
+
js: 'application/javascript',
|
|
7
|
+
xml: 'application/xml',
|
|
8
|
+
csv: 'text/csv',
|
|
9
|
+
mp3: 'audio/mpeg',
|
|
10
|
+
m4a: 'audio/mp4',
|
|
11
|
+
wav: 'audio/wav',
|
|
12
|
+
ogg: 'audio/ogg',
|
|
13
|
+
mp4: 'video/mp4',
|
|
14
|
+
webm: 'video/webm',
|
|
15
|
+
png: 'image/png',
|
|
16
|
+
jpg: 'image/jpeg',
|
|
17
|
+
jpeg: 'image/jpeg',
|
|
18
|
+
gif: 'image/gif',
|
|
19
|
+
webp: 'image/webp',
|
|
20
|
+
svg: 'image/svg+xml',
|
|
21
|
+
pdf: 'application/pdf',
|
|
22
|
+
zip: 'application/zip',
|
|
23
|
+
gz: 'application/gzip',
|
|
24
|
+
tar: 'application/x-tar'
|
|
25
|
+
};
|
|
26
|
+
export function guessMimeType(name) {
|
|
27
|
+
var _name_split_pop;
|
|
28
|
+
var ext = (_name_split_pop = name.split('.').pop()) === null || _name_split_pop === void 0 ? void 0 : _name_split_pop.toLowerCase();
|
|
29
|
+
var _MIME_TYPES_;
|
|
30
|
+
return (_MIME_TYPES_ = MIME_TYPES[ext !== null && ext !== void 0 ? ext : '']) !== null && _MIME_TYPES_ !== void 0 ? _MIME_TYPES_ : 'application/octet-stream';
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accepted input types for file write operations.
|
|
3
|
+
* - string: text content, written as UTF-8
|
|
4
|
+
* - Uint8Array: binary content
|
|
5
|
+
* - Response: fetch response — body is streamed, never fully buffered
|
|
6
|
+
* - ReadableStream: streamed directly to storage
|
|
7
|
+
* - FileHandle: another file — content is streamed from storage to storage
|
|
8
|
+
*/ /**
|
|
9
|
+
* Service for creating and managing files during brain execution.
|
|
10
|
+
* Available on the step context as `files`.
|
|
11
|
+
*
|
|
12
|
+
* Files are always scoped per-user. Default scope is 'brain' (persists across runs).
|
|
13
|
+
*/ export { };
|
package/dist/src/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
export { Brain, brain } from './dsl/brain.js';
|
|
1
|
+
export { Brain, brain, Continuation } from './dsl/brain.js';
|
|
2
2
|
export { BrainRunner } from './dsl/brain-runner.js';
|
|
3
3
|
export { createBrain } from './dsl/create-brain.js';
|
|
4
4
|
export { STATUS, BRAIN_EVENTS } from './dsl/constants.js';
|
|
5
|
+
export { Fragment, File, Resource, Form } from './jsx-runtime.js';
|
|
6
|
+
export { renderTemplate, isTemplateNode, resolveTemplate, buildTemplateContext } from './template/render.js';
|
|
7
|
+
export { renderHtml } from './template/render-html.js';
|
|
5
8
|
export { applyPatches } from './dsl/json-patch.js';
|
|
6
9
|
export { IterateResult } from './dsl/iterate-result.js';
|
|
7
10
|
export { parseDuration } from './dsl/duration.js';
|
|
@@ -14,8 +17,12 @@ export { createResources } from './resources/resources.js';
|
|
|
14
17
|
export { createWebhook } from './dsl/webhook.js';
|
|
15
18
|
export { RESOURCE_TYPES } from './resources/resources.js';
|
|
16
19
|
// Default tools
|
|
17
|
-
export { createTool, defaultTools,
|
|
18
|
-
|
|
20
|
+
export { createTool, defaultTools, generatePage, waitForWebhook, print, consoleLog, readFile, writeFile } from './tools/index.js';
|
|
21
|
+
// Files
|
|
22
|
+
export { guessMimeType } from './files/mime.js';
|
|
23
|
+
// Plugin system
|
|
24
|
+
export { definePlugin } from './plugins/index.js';
|
|
25
|
+
export { collectPluginWebhooks } from './plugins/collect-webhooks.js';
|
|
19
26
|
// UI utilities
|
|
20
27
|
export { generateFormToken } from './ui/generate-page-html.js';
|
|
21
28
|
export { parseFormData } from './ui/parse-form-data.js';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Custom JSX runtime for Positronic template authoring.
|
|
2
|
+
// This module is imported automatically by the JSX transform when
|
|
3
|
+
// jsxImportSource is set to "@positronic/core".
|
|
4
|
+
function _object_without_properties(source, excluded) {
|
|
5
|
+
if (source == null) return {};
|
|
6
|
+
var target = _object_without_properties_loose(source, excluded);
|
|
7
|
+
var key, i;
|
|
8
|
+
if (Object.getOwnPropertySymbols) {
|
|
9
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
10
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
11
|
+
key = sourceSymbolKeys[i];
|
|
12
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
13
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
14
|
+
target[key] = source[key];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return target;
|
|
18
|
+
}
|
|
19
|
+
function _object_without_properties_loose(source, excluded) {
|
|
20
|
+
if (source == null) return {};
|
|
21
|
+
var target = {};
|
|
22
|
+
var sourceKeys = Object.keys(source);
|
|
23
|
+
var key, i;
|
|
24
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
25
|
+
key = sourceKeys[i];
|
|
26
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
27
|
+
target[key] = source[key];
|
|
28
|
+
}
|
|
29
|
+
return target;
|
|
30
|
+
}
|
|
31
|
+
export var Fragment = Symbol.for('positronic.fragment');
|
|
32
|
+
export var File = Symbol.for('positronic.file');
|
|
33
|
+
export var Resource = Symbol.for('positronic.resource');
|
|
34
|
+
export var Form = Symbol.for('positronic.form');
|
|
35
|
+
// Called by the automatic JSX transform for elements with a single child
|
|
36
|
+
export function jsx(type, props) {
|
|
37
|
+
var children = props.children, rest = _object_without_properties(props, [
|
|
38
|
+
"children"
|
|
39
|
+
]);
|
|
40
|
+
return {
|
|
41
|
+
type: type,
|
|
42
|
+
props: rest,
|
|
43
|
+
children: children == null ? [] : [
|
|
44
|
+
children
|
|
45
|
+
]
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// Called by the automatic JSX transform for elements with multiple children
|
|
49
|
+
export var jsxs = jsx;
|
|
@@ -119,7 +119,7 @@ function _ts_generator(thisArg, body) {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
|
-
* Creates a
|
|
122
|
+
* Creates a Memory instance with agentId and userId pre-bound.
|
|
123
123
|
*
|
|
124
124
|
* This wraps a MemoryProvider and automatically includes the agentId
|
|
125
125
|
* and userId in all calls, so brain steps don't need to pass them explicitly.
|
|
@@ -127,17 +127,17 @@ function _ts_generator(thisArg, body) {
|
|
|
127
127
|
* @param provider - The underlying memory provider
|
|
128
128
|
* @param agentId - The agent/brain ID to scope memories to
|
|
129
129
|
* @param userId - The user name to scope memories to (from currentUser.name)
|
|
130
|
-
* @returns A
|
|
130
|
+
* @returns A Memory instance
|
|
131
131
|
*
|
|
132
132
|
* @example
|
|
133
133
|
* ```typescript
|
|
134
134
|
* const provider = createMem0Provider({ apiKey: '...' });
|
|
135
|
-
* const
|
|
135
|
+
* const memory = createMemory(provider, 'my-brain', 'user-123');
|
|
136
136
|
*
|
|
137
137
|
* // Now search without passing agentId or userId
|
|
138
|
-
* const memories = await
|
|
138
|
+
* const memories = await memory.search('user preferences');
|
|
139
139
|
* ```
|
|
140
|
-
*/ export function
|
|
140
|
+
*/ export function createMemory(provider, agentId, userId) {
|
|
141
141
|
return {
|
|
142
142
|
search: function search(query, options) {
|
|
143
143
|
return _async_to_generator(function() {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collect webhook declarations from all plugins.
|
|
3
|
+
* Returns a manifest-compatible record mapping slug -> WebhookFunction.
|
|
4
|
+
*/ export function collectPluginWebhooks(plugins) {
|
|
5
|
+
var result = {};
|
|
6
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
7
|
+
try {
|
|
8
|
+
for(var _iterator = plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
9
|
+
var plugin = _step.value;
|
|
10
|
+
var webhooks = plugin.__plugin.webhooks;
|
|
11
|
+
if (webhooks) {
|
|
12
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
13
|
+
try {
|
|
14
|
+
for(var _iterator1 = Object.values(webhooks)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
15
|
+
var wh = _step1.value;
|
|
16
|
+
result[wh.slug] = wh;
|
|
17
|
+
}
|
|
18
|
+
} catch (err) {
|
|
19
|
+
_didIteratorError1 = true;
|
|
20
|
+
_iteratorError1 = err;
|
|
21
|
+
} finally{
|
|
22
|
+
try {
|
|
23
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
24
|
+
_iterator1.return();
|
|
25
|
+
}
|
|
26
|
+
} finally{
|
|
27
|
+
if (_didIteratorError1) {
|
|
28
|
+
throw _iteratorError1;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
_didIteratorError = true;
|
|
36
|
+
_iteratorError = err;
|
|
37
|
+
} finally{
|
|
38
|
+
try {
|
|
39
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
40
|
+
_iterator.return();
|
|
41
|
+
}
|
|
42
|
+
} finally{
|
|
43
|
+
if (_didIteratorError) {
|
|
44
|
+
throw _iteratorError;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function definePlugin(definition) {
|
|
2
|
+
var plugin = {
|
|
3
|
+
__plugin: definition,
|
|
4
|
+
__config: undefined
|
|
5
|
+
};
|
|
6
|
+
if (definition.setup) {
|
|
7
|
+
plugin.setup = function(config) {
|
|
8
|
+
return {
|
|
9
|
+
__plugin: definition,
|
|
10
|
+
__config: definition.setup(config)
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return plugin;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { definePlugin } from './define-plugin.js';
|
package/dist/src/store/types.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* When TStore is a record type, this adds `{ store: Store<TStore> }`.
|
|
2
|
+
* Factory function that creates a typed Store from a schema and runtime context.
|
|
3
|
+
* Backends implement this to handle persistence and key resolution.
|
|
5
4
|
*/ export { };
|