@framers/agentos 0.12.21 → 0.12.23

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.
Files changed (31) hide show
  1. package/README.md +2 -2
  2. package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts +4 -2
  3. package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts.map +1 -1
  4. package/dist/cognition/emergent/EmergentCapabilityEngine.js +20 -1
  5. package/dist/cognition/emergent/EmergentCapabilityEngine.js.map +1 -1
  6. package/dist/cognition/emergent/executor/QuickJSExecutor.d.ts +64 -0
  7. package/dist/cognition/emergent/executor/QuickJSExecutor.d.ts.map +1 -0
  8. package/dist/cognition/emergent/executor/QuickJSExecutor.js +655 -0
  9. package/dist/cognition/emergent/executor/QuickJSExecutor.js.map +1 -0
  10. package/dist/cognition/emergent/executor/guest-prelude.d.ts +22 -0
  11. package/dist/cognition/emergent/executor/guest-prelude.d.ts.map +1 -0
  12. package/dist/cognition/emergent/executor/guest-prelude.js +559 -0
  13. package/dist/cognition/emergent/executor/guest-prelude.js.map +1 -0
  14. package/dist/cognition/emergent/executor/guest-surface.d.ts +34 -0
  15. package/dist/cognition/emergent/executor/guest-surface.d.ts.map +1 -0
  16. package/dist/cognition/emergent/executor/guest-surface.js +218 -0
  17. package/dist/cognition/emergent/executor/guest-surface.js.map +1 -0
  18. package/dist/cognition/emergent/executor/types.d.ts +7 -0
  19. package/dist/cognition/emergent/executor/types.d.ts.map +1 -1
  20. package/dist/cognition/emergent/index.d.ts +1 -0
  21. package/dist/cognition/emergent/index.d.ts.map +1 -1
  22. package/dist/cognition/emergent/index.js +1 -0
  23. package/dist/cognition/emergent/index.js.map +1 -1
  24. package/dist/cognition/emergent/types.d.ts +11 -3
  25. package/dist/cognition/emergent/types.d.ts.map +1 -1
  26. package/dist/cognition/emergent/types.js.map +1 -1
  27. package/dist/io/channels/adapters/PlivoSmsChannelAdapter.d.ts +88 -23
  28. package/dist/io/channels/adapters/PlivoSmsChannelAdapter.d.ts.map +1 -1
  29. package/dist/io/channels/adapters/PlivoSmsChannelAdapter.js +245 -75
  30. package/dist/io/channels/adapters/PlivoSmsChannelAdapter.js.map +1 -1
  31. package/package.json +11 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuickJSExecutor.js","sourceRoot":"","sources":["../../../../src/cognition/emergent/executor/QuickJSExecutor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAQlC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAgB,MAAM,oBAAoB,CAAC;AAGjE,iEAAiE;AACjE,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC;AAExC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC,MAAM,YAAY,GAAG,yBAAyB,CAAC;AAC/C,MAAM,eAAe,GAAG,qCAAqC,CAAC;AAE9D,mEAAmE;AACnE,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;AAE9E,MAAM,UAAU,GAAG,KAAM,CAAC;AAC1B,MAAM,GAAG,GAAG,OAAS,CAAC;AACtB,0FAA0F;AAC1F,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,uFAAuF;AACvF,MAAM,aAAa,GAAG,KAAM,CAAC;AAC7B,2FAA2F;AAC3F,MAAM,WAAW,GAAG,GAAG,GAAG,IAAI,CAAC;AAC/B,gGAAgG;AAChG,MAAM,kBAAkB,GAAG,OAAS,CAAC;AACrC,yGAAyG;AACzG,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,CAAC;AAEpC;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AAE,CAAC;YACvC,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,eAAe,EAAE,CAAC;QACxD,CAAC;QACD,MAAM,IAAI,GAAG,OAAO,KAAK,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAoB,MAAM,GAAG,IAAI,EAAE,EAAE,eAAe,EAAE,CAAC;IAC1F,CAAC;CACF"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @fileoverview The guest prelude of {@link QuickJSExecutor}: JavaScript the
3
+ * executor evaluates inside each call's QuickJS context before the forged
4
+ * code. Node never runs it.
5
+ *
6
+ * It takes the host functions the executor installed as globals named
7
+ * `__host_<name>` (see guest-surface.ts), removes those globals, and builds
8
+ * what forged code is documented to have: the built-ins the in-process
9
+ * context hands it that QuickJS lacks (`TextEncoder`, `TextDecoder`, `URL`,
10
+ * `URLSearchParams`, `structuredClone`, `atob`, `btoa`, `Intl` and the
11
+ * locale methods, a console that discards) and the granted capabilities
12
+ * (`fetch`, `fs.readFile`, `crypto`). Names the in-process context sets to
13
+ * undefined are undefined here too, and string code generation is refused
14
+ * as the in-process context refuses it.
15
+ *
16
+ * The source is a string so that it ships inside the compiled package; it
17
+ * holds no template interpolation and no backslash.
18
+ *
19
+ * @module @framers/agentos/emergent/executor/guest-prelude
20
+ */
21
+ export declare const GUEST_PRELUDE: string;
22
+ //# sourceMappingURL=guest-prelude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guest-prelude.d.ts","sourceRoot":"","sources":["../../../../src/cognition/emergent/executor/guest-prelude.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,aAAa,QAyhBzB,CAAC"}
@@ -0,0 +1,559 @@
1
+ /**
2
+ * @fileoverview The guest prelude of {@link QuickJSExecutor}: JavaScript the
3
+ * executor evaluates inside each call's QuickJS context before the forged
4
+ * code. Node never runs it.
5
+ *
6
+ * It takes the host functions the executor installed as globals named
7
+ * `__host_<name>` (see guest-surface.ts), removes those globals, and builds
8
+ * what forged code is documented to have: the built-ins the in-process
9
+ * context hands it that QuickJS lacks (`TextEncoder`, `TextDecoder`, `URL`,
10
+ * `URLSearchParams`, `structuredClone`, `atob`, `btoa`, `Intl` and the
11
+ * locale methods, a console that discards) and the granted capabilities
12
+ * (`fetch`, `fs.readFile`, `crypto`). Names the in-process context sets to
13
+ * undefined are undefined here too, and string code generation is refused
14
+ * as the in-process context refuses it.
15
+ *
16
+ * The source is a string so that it ships inside the compiled package; it
17
+ * holds no template interpolation and no backslash.
18
+ *
19
+ * @module @framers/agentos/emergent/executor/guest-prelude
20
+ */
21
+ export const GUEST_PRELUDE = String.raw `(() => {
22
+ 'use strict';
23
+ const g = globalThis;
24
+ const host = {};
25
+ for (const name of Object.getOwnPropertyNames(g)) {
26
+ if (name.startsWith('__host_')) {
27
+ host[name.slice('__host_'.length)] = g[name];
28
+ delete g[name];
29
+ }
30
+ }
31
+
32
+ const toBytes = (data) => {
33
+ if (data instanceof Uint8Array) return data;
34
+ if (data instanceof ArrayBuffer) return new Uint8Array(data);
35
+ if (ArrayBuffer.isView(data)) return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
36
+ throw new TypeError('Expected a string, an ArrayBuffer or a typed array');
37
+ };
38
+ const bytesToLatin1 = (bytes) => {
39
+ let out = '';
40
+ for (let i = 0; i < bytes.length; i += 8192) {
41
+ out += String.fromCharCode.apply(null, bytes.subarray(i, i + 8192));
42
+ }
43
+ return out;
44
+ };
45
+ // What Node's digest() returns without an encoding is a Buffer; forged code
46
+ // calls toString('hex') on it. Bytes is the nearest the guest can hold.
47
+ class Bytes extends Uint8Array {
48
+ toString(encoding) {
49
+ return host.bytes_to_string(bytesToLatin1(this), encoding === undefined ? 'utf8' : String(encoding));
50
+ }
51
+ }
52
+
53
+ class TextEncoder {
54
+ get encoding() {
55
+ return 'utf-8';
56
+ }
57
+ encode(input = '') {
58
+ return new Uint8Array(host.utf8_encode(String(input)));
59
+ }
60
+ }
61
+
62
+ class TextDecoder {
63
+ constructor(label = 'utf-8', options = {}) {
64
+ this._label = String(label);
65
+ this._fatal = Boolean(options && options.fatal);
66
+ this._ignoreBOM = Boolean(options && options.ignoreBOM);
67
+ this._encoding = host.text_decoder_encoding(this._label);
68
+ }
69
+ get encoding() {
70
+ return this._encoding;
71
+ }
72
+ get fatal() {
73
+ return this._fatal;
74
+ }
75
+ get ignoreBOM() {
76
+ return this._ignoreBOM;
77
+ }
78
+ decode(input) {
79
+ if (input === undefined) return '';
80
+ return host.text_decode(this._label, this._fatal, this._ignoreBOM, bytesToLatin1(toBytes(input)));
81
+ }
82
+ }
83
+
84
+ class URLSearchParams {
85
+ constructor(init) {
86
+ this._pairs = [];
87
+ this._url = null;
88
+ if (init === undefined || init === null) return;
89
+ if (init instanceof URLSearchParams) {
90
+ this._pairs = init._pairs.map(([k, v]) => [k, v]);
91
+ } else if (typeof init === 'object' && typeof init[Symbol.iterator] === 'function') {
92
+ for (const pair of init) {
93
+ const items = Array.from(pair);
94
+ if (items.length !== 2) throw new TypeError('Each query pair must be an iterable [name, value] tuple');
95
+ this._pairs.push([String(items[0]), String(items[1])]);
96
+ }
97
+ } else if (typeof init === 'object') {
98
+ for (const key of Object.keys(init)) this._pairs.push([key, String(init[key])]);
99
+ } else {
100
+ this._pairs = host.usp_parse(String(init));
101
+ }
102
+ }
103
+ _changed() {
104
+ if (this._url) this._url._setSearch(this.toString());
105
+ }
106
+ get size() {
107
+ return this._pairs.length;
108
+ }
109
+ append(name, value) {
110
+ this._pairs.push([String(name), String(value)]);
111
+ this._changed();
112
+ }
113
+ delete(name, value) {
114
+ const n = String(name);
115
+ this._pairs = this._pairs.filter(([k, v]) => !(k === n && (value === undefined || v === String(value))));
116
+ this._changed();
117
+ }
118
+ get(name) {
119
+ const n = String(name);
120
+ const pair = this._pairs.find(([k]) => k === n);
121
+ return pair ? pair[1] : null;
122
+ }
123
+ getAll(name) {
124
+ const n = String(name);
125
+ return this._pairs.filter(([k]) => k === n).map(([, v]) => v);
126
+ }
127
+ has(name, value) {
128
+ const n = String(name);
129
+ return this._pairs.some(([k, v]) => k === n && (value === undefined || v === String(value)));
130
+ }
131
+ set(name, value) {
132
+ const n = String(name);
133
+ const v = String(value);
134
+ const first = this._pairs.findIndex(([k]) => k === n);
135
+ if (first < 0) {
136
+ this._pairs.push([n, v]);
137
+ } else {
138
+ this._pairs[first] = [n, v];
139
+ this._pairs = this._pairs.filter(([k], i) => k !== n || i === first);
140
+ }
141
+ this._changed();
142
+ }
143
+ sort() {
144
+ this._pairs = this._pairs
145
+ .map((pair, index) => ({ pair, index }))
146
+ .sort((a, b) => (a.pair[0] < b.pair[0] ? -1 : a.pair[0] > b.pair[0] ? 1 : a.index - b.index))
147
+ .map(({ pair }) => pair);
148
+ this._changed();
149
+ }
150
+ forEach(callback, thisArg) {
151
+ for (const [k, v] of this._pairs) callback.call(thisArg, v, k, this);
152
+ }
153
+ keys() {
154
+ return this._pairs.map(([k]) => k)[Symbol.iterator]();
155
+ }
156
+ values() {
157
+ return this._pairs.map(([, v]) => v)[Symbol.iterator]();
158
+ }
159
+ entries() {
160
+ return this._pairs.map(([k, v]) => [k, v])[Symbol.iterator]();
161
+ }
162
+ [Symbol.iterator]() {
163
+ return this.entries();
164
+ }
165
+ toString() {
166
+ return host.usp_serialize(this._pairs);
167
+ }
168
+ }
169
+
170
+ const URL_PARTS = ['href', 'origin', 'protocol', 'username', 'password', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'];
171
+ class URL {
172
+ constructor(input, base) {
173
+ this._parts = host.url_parse(String(input), base === undefined ? null : String(base));
174
+ this._params = new URLSearchParams(this._parts.search);
175
+ this._params._url = this;
176
+ }
177
+ _setSearch(search) {
178
+ this._parts = host.url_set(this._parts.href, 'search', search);
179
+ }
180
+ get searchParams() {
181
+ return this._params;
182
+ }
183
+ toString() {
184
+ return this._parts.href;
185
+ }
186
+ toJSON() {
187
+ return this._parts.href;
188
+ }
189
+ static canParse(input, base) {
190
+ try {
191
+ new URL(input, base);
192
+ return true;
193
+ } catch {
194
+ return false;
195
+ }
196
+ }
197
+ }
198
+ for (const part of URL_PARTS) {
199
+ Object.defineProperty(URL.prototype, part, {
200
+ configurable: true,
201
+ enumerable: true,
202
+ get() {
203
+ return this._parts[part];
204
+ },
205
+ set:
206
+ part === 'origin'
207
+ ? undefined
208
+ : function (value) {
209
+ this._parts = host.url_set(this._parts.href, part, String(value));
210
+ this._params._pairs = host.usp_parse(this._parts.search);
211
+ },
212
+ });
213
+ }
214
+
215
+ const cloneError = (text) => {
216
+ const error = new Error(text);
217
+ error.name = 'DataCloneError';
218
+ return error;
219
+ };
220
+ const structuredClone = (value) => {
221
+ const seen = new Map();
222
+ const clone = (v) => {
223
+ if (typeof v === 'function' || typeof v === 'symbol') throw cloneError(String(v) + ' could not be cloned.');
224
+ if (v === null || typeof v !== 'object') return v;
225
+ if (seen.has(v)) return seen.get(v);
226
+ let out;
227
+ if (Array.isArray(v)) {
228
+ out = [];
229
+ seen.set(v, out);
230
+ for (let i = 0; i < v.length; i++) out[i] = clone(v[i]);
231
+ return out;
232
+ }
233
+ if (v instanceof Date) {
234
+ out = new Date(v.getTime());
235
+ } else if (v instanceof RegExp) {
236
+ out = new RegExp(v.source, v.flags);
237
+ } else if (v instanceof Map) {
238
+ out = new Map();
239
+ seen.set(v, out);
240
+ for (const [k, x] of v) out.set(clone(k), clone(x));
241
+ return out;
242
+ } else if (v instanceof Set) {
243
+ out = new Set();
244
+ seen.set(v, out);
245
+ for (const x of v) out.add(clone(x));
246
+ return out;
247
+ } else if (v instanceof ArrayBuffer) {
248
+ out = v.slice(0);
249
+ } else if (v instanceof DataView) {
250
+ out = new DataView(v.buffer.slice(v.byteOffset, v.byteOffset + v.byteLength));
251
+ } else if (ArrayBuffer.isView(v)) {
252
+ out = v.slice();
253
+ } else if (v instanceof Error) {
254
+ out = new Error(v.message);
255
+ out.name = v.name;
256
+ } else {
257
+ out = {};
258
+ seen.set(v, out);
259
+ for (const key of Object.keys(v)) out[key] = clone(v[key]);
260
+ return out;
261
+ }
262
+ seen.set(v, out);
263
+ return out;
264
+ };
265
+ return clone(value);
266
+ };
267
+
268
+ const atob = (data) => host.atob(String(data));
269
+ const btoa = (data) => host.btoa(String(data));
270
+ const discard = () => undefined;
271
+ const console = Object.freeze({ log: discard, error: discard, warn: discard, info: discard });
272
+
273
+ // Intl. QuickJS has none: each service formats through the host's Intl,
274
+ // data in and data out, built on the host from the locales and options the
275
+ // guest gave (the host keeps the services it built for the call).
276
+ const INTL_SERVICES = {
277
+ DateTimeFormat: ['format', 'formatToParts', 'formatRange', 'formatRangeToParts'],
278
+ NumberFormat: ['format', 'formatToParts', 'formatRange', 'formatRangeToParts'],
279
+ Collator: ['compare'],
280
+ PluralRules: ['select', 'selectRange'],
281
+ RelativeTimeFormat: ['format', 'formatToParts'],
282
+ ListFormat: ['format', 'formatToParts'],
283
+ DisplayNames: ['of'],
284
+ };
285
+ // As the real ones, format and compare are getters that return a bound function.
286
+ const BOUND_METHODS = ['format', 'compare'];
287
+ const localesArg = (locales) =>
288
+ locales === undefined || locales === null
289
+ ? null
290
+ : typeof locales === 'string'
291
+ ? locales
292
+ : Array.from(locales, String);
293
+ const optionsArg = (options) => {
294
+ if (options === undefined || options === null) return null;
295
+ const out = {};
296
+ for (const key of Object.keys(options)) {
297
+ const value = options[key];
298
+ if (value === undefined) continue;
299
+ out[key] = typeof value === 'number' || typeof value === 'boolean' ? value : String(value);
300
+ }
301
+ return out;
302
+ };
303
+ const intlValue = (value) => {
304
+ if (value instanceof Date) return value.getTime();
305
+ if (typeof value === 'bigint') return String(value);
306
+ if (value !== null && typeof value === 'object' && typeof value[Symbol.iterator] === 'function') {
307
+ return Array.from(value, String);
308
+ }
309
+ return value;
310
+ };
311
+ const Intl = {};
312
+ for (const service of Object.keys(INTL_SERVICES)) {
313
+ const Service = class {
314
+ constructor(locales, options) {
315
+ this._locales = localesArg(locales);
316
+ this._options = optionsArg(options);
317
+ // The host builds the service here, so bad locales or options throw here, as they would there.
318
+ this._resolved = host.intl_call(service, this._locales, this._options, 'resolvedOptions');
319
+ this._bound = {};
320
+ }
321
+ resolvedOptions() {
322
+ return JSON.parse(JSON.stringify(this._resolved));
323
+ }
324
+ static supportedLocalesOf(locales, options) {
325
+ return host.intl_supported(service, localesArg(locales), optionsArg(options));
326
+ }
327
+ };
328
+ Object.defineProperty(Service, 'name', { value: service });
329
+ for (const method of INTL_SERVICES[service]) {
330
+ const call = function (a, b) {
331
+ return host.intl_call(service, this._locales, this._options, method, intlValue(a), intlValue(b));
332
+ };
333
+ if (BOUND_METHODS.includes(method)) {
334
+ Object.defineProperty(Service.prototype, method, {
335
+ configurable: true,
336
+ get() {
337
+ const self = this;
338
+ return self._bound[method] || (self._bound[method] = (a, b) => call.call(self, a, b));
339
+ },
340
+ });
341
+ } else {
342
+ Object.defineProperty(Service.prototype, method, { configurable: true, writable: true, value: call });
343
+ }
344
+ }
345
+ Intl[service] = Service;
346
+ }
347
+ Object.freeze(Intl);
348
+
349
+ const define = (target, name, value) =>
350
+ Object.defineProperty(target, name, { configurable: true, writable: true, enumerable: false, value });
351
+ for (const method of ['toLocaleString', 'toLocaleDateString', 'toLocaleTimeString']) {
352
+ define(Date.prototype, method, function (locales, options) {
353
+ return host.intl_date(method, this.getTime(), localesArg(locales), optionsArg(options));
354
+ });
355
+ }
356
+ define(Number.prototype, 'toLocaleString', function (locales, options) {
357
+ return host.intl_call('NumberFormat', localesArg(locales), optionsArg(options), 'format', Number(this));
358
+ });
359
+ if (typeof BigInt === 'function') {
360
+ define(BigInt.prototype, 'toLocaleString', function (locales, options) {
361
+ return host.intl_call('NumberFormat', localesArg(locales), optionsArg(options), 'format', String(this));
362
+ });
363
+ }
364
+ define(String.prototype, 'localeCompare', function (that, locales, options) {
365
+ return host.intl_compare(String(this), String(that), localesArg(locales), optionsArg(options));
366
+ });
367
+ // QuickJS calls each element's toLocaleString with no arguments; the
368
+ // in-process context passes the locales and options on.
369
+ define(Array.prototype, 'toLocaleString', function (locales, options) {
370
+ const parts = [];
371
+ for (let i = 0; i < this.length; i += 1) {
372
+ const item = this[i];
373
+ parts.push(item === undefined || item === null ? '' : String(item.toLocaleString(locales, options)));
374
+ }
375
+ return parts.join(',');
376
+ });
377
+
378
+ if (host.fetch) {
379
+ class Headers {
380
+ constructor(pairs) {
381
+ this._pairs = pairs.map(([k, v]) => [String(k).toLowerCase(), String(v)]);
382
+ }
383
+ get(name) {
384
+ const n = String(name).toLowerCase();
385
+ const values = this._pairs.filter(([k]) => k === n).map(([, v]) => v);
386
+ return values.length === 0 ? null : values.join(', ');
387
+ }
388
+ has(name) {
389
+ const n = String(name).toLowerCase();
390
+ return this._pairs.some(([k]) => k === n);
391
+ }
392
+ forEach(callback, thisArg) {
393
+ for (const [k, v] of this._pairs) callback.call(thisArg, v, k, this);
394
+ }
395
+ keys() {
396
+ return this._pairs.map(([k]) => k)[Symbol.iterator]();
397
+ }
398
+ values() {
399
+ return this._pairs.map(([, v]) => v)[Symbol.iterator]();
400
+ }
401
+ entries() {
402
+ return this._pairs.map(([k, v]) => [k, v])[Symbol.iterator]();
403
+ }
404
+ [Symbol.iterator]() {
405
+ return this.entries();
406
+ }
407
+ }
408
+ class Response {
409
+ constructor(data) {
410
+ this.status = data.status;
411
+ this.statusText = data.statusText;
412
+ this.ok = data.ok;
413
+ this.redirected = data.redirected;
414
+ this.url = data.url;
415
+ this.type = data.type;
416
+ this.headers = new Headers(data.headers);
417
+ this.bodyUsed = false;
418
+ this._body = new Uint8Array(data.body);
419
+ }
420
+ _take() {
421
+ if (this.bodyUsed) throw new TypeError('Body is unusable: Body has already been read');
422
+ this.bodyUsed = true;
423
+ return this._body;
424
+ }
425
+ async arrayBuffer() {
426
+ const body = this._take();
427
+ return body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
428
+ }
429
+ async bytes() {
430
+ return new Uint8Array(await this.arrayBuffer());
431
+ }
432
+ async text() {
433
+ return host.text_decode('utf-8', false, false, bytesToLatin1(this._take()));
434
+ }
435
+ async json() {
436
+ return JSON.parse(await this.text());
437
+ }
438
+ clone() {
439
+ if (this.bodyUsed) throw new TypeError('Response.clone: Body has already been consumed.');
440
+ return new Response({
441
+ status: this.status,
442
+ statusText: this.statusText,
443
+ ok: this.ok,
444
+ redirected: this.redirected,
445
+ url: this.url,
446
+ type: this.type,
447
+ headers: [...this.headers],
448
+ body: this._body.slice().buffer,
449
+ });
450
+ }
451
+ }
452
+ const headerPairs = (headers) => {
453
+ if (headers === undefined || headers === null) return undefined;
454
+ if (headers instanceof Headers) return [...headers];
455
+ if (typeof headers[Symbol.iterator] === 'function') return Array.from(headers, (pair) => Array.from(pair, String));
456
+ return Object.keys(headers).map((k) => [k, String(headers[k])]);
457
+ };
458
+ g.fetch = async (input, init) => {
459
+ const target =
460
+ typeof input === 'string'
461
+ ? input
462
+ : input instanceof URL
463
+ ? input.href
464
+ : input !== null && typeof input === 'object' && 'url' in input
465
+ ? { url: String(input.url) }
466
+ : String(input);
467
+ let options;
468
+ if (init !== undefined && init !== null) {
469
+ options = {};
470
+ if (init.method !== undefined) options.method = String(init.method);
471
+ const headers = headerPairs(init.headers);
472
+ if (headers !== undefined) options.headers = headers;
473
+ if (typeof init.body === 'string') options.body = init.body;
474
+ if (init.redirect !== undefined) options.redirect = String(init.redirect);
475
+ }
476
+ return new Response(await host.fetch(target, options));
477
+ };
478
+ }
479
+
480
+ if (host.fs_readFile) {
481
+ g.fs = Object.freeze({ readFile: (filePath) => host.fs_readFile(String(filePath)) });
482
+ }
483
+
484
+ if (host.crypto_randomUUID) {
485
+ class Digest {
486
+ constructor(id) {
487
+ this._id = id;
488
+ }
489
+ update(data, inputEncoding) {
490
+ host.crypto_update(
491
+ this._id,
492
+ typeof data === 'string'
493
+ ? { s: data, enc: inputEncoding === undefined ? 'utf8' : String(inputEncoding) }
494
+ : { b: bytesToLatin1(toBytes(data)) },
495
+ );
496
+ return this;
497
+ }
498
+ digest(encoding) {
499
+ const out = host.crypto_digest(this._id, encoding === undefined ? null : String(encoding));
500
+ return typeof out === 'string' ? out : new Bytes(out);
501
+ }
502
+ }
503
+ g.crypto = Object.freeze({
504
+ randomUUID: () => host.crypto_randomUUID(),
505
+ createHash: (algorithm) => new Digest(host.crypto_start('hash', String(algorithm), null)),
506
+ createHmac: (algorithm, key) =>
507
+ new Digest(
508
+ host.crypto_start('hmac', String(algorithm), typeof key === 'string' ? { s: key } : { b: bytesToLatin1(toBytes(key)) }),
509
+ ),
510
+ });
511
+ }
512
+
513
+ // String code generation is refused, as the in-process context refuses it
514
+ // (codeGeneration: { strings: false }): every Function constructor and eval
515
+ // throw EvalError for source text. The host evaluates the forged code itself.
516
+ const refusal = () => new EvalError('Code generation from strings disallowed for this context');
517
+ const refusingConstructor = (name, prototype) => {
518
+ const ctor = {
519
+ [name]: function () {
520
+ throw refusal();
521
+ },
522
+ }[name];
523
+ Object.defineProperty(ctor, 'prototype', { value: prototype });
524
+ Object.defineProperty(prototype, 'constructor', { value: ctor, writable: false, enumerable: false, configurable: false });
525
+ return ctor;
526
+ };
527
+ const SafeFunction = refusingConstructor('Function', Function.prototype);
528
+ refusingConstructor('AsyncFunction', Object.getPrototypeOf(async function () {}));
529
+ refusingConstructor('GeneratorFunction', Object.getPrototypeOf(function* () {}));
530
+ refusingConstructor('AsyncGeneratorFunction', Object.getPrototypeOf(async function* () {}));
531
+ const evalRefusing = function (source) {
532
+ if (typeof source === 'string') throw refusal();
533
+ return source;
534
+ };
535
+
536
+ const absent = [
537
+ 'process', 'global', 'require', 'setTimeout', 'setInterval', 'setImmediate', 'clearTimeout',
538
+ 'clearInterval', 'clearImmediate', 'queueMicrotask', 'Reflect', 'Proxy', 'WebAssembly',
539
+ 'SharedArrayBuffer', 'Atomics',
540
+ ];
541
+ if (!host.fetch) absent.push('fetch');
542
+ for (const name of absent) g[name] = undefined;
543
+ Object.assign(g, {
544
+ TextEncoder,
545
+ TextDecoder,
546
+ URL,
547
+ URLSearchParams,
548
+ structuredClone,
549
+ atob,
550
+ btoa,
551
+ console,
552
+ Intl,
553
+ Function: SafeFunction,
554
+ eval: evalRefusing,
555
+ });
556
+ g.globalThis = undefined;
557
+ })();
558
+ `;
559
+ //# sourceMappingURL=guest-prelude.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guest-prelude.js","sourceRoot":"","sources":["../../../../src/cognition/emergent/executor/guest-prelude.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyhBtC,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @fileoverview What crosses into a {@link QuickJSExecutor} guest: host
3
+ * functions that take data and return data (JSON values; bytes travel into
4
+ * the guest as `Uint8Array` and out of it as latin1 strings). The executor
5
+ * installs each as the guest global `__host_<name>`, and the guest prelude
6
+ * (guest-prelude.ts) builds the documented globals over them. Host values
7
+ * never cross.
8
+ *
9
+ * The bindings are built for one call and dropped with it. What they hold on
10
+ * the host is bounded per call: the response bodies of the call's fetches
11
+ * together by the call's memory budget, open hashes by
12
+ * {@link MAX_OPEN_DIGESTS}, built `Intl` services by {@link MAX_INTL_SERVICES}.
13
+ *
14
+ * @module @framers/agentos/emergent/executor/guest-surface
15
+ */
16
+ /** A host function the guest calls with data and gets data, or a promise of data, back from. */
17
+ export type Binding = (...args: unknown[]) => unknown;
18
+ /** The per-call bounds on what the bindings hold on the host. */
19
+ export interface GuestSurfaceLimits {
20
+ /** The bytes the response bodies of the call's fetches may hold, together. */
21
+ readonly bodyBytes: number;
22
+ /**
23
+ * Aborted when the call ends, where no broker ends the call's requests (the
24
+ * path without a ceiling): a request still running then is aborted.
25
+ */
26
+ readonly signal?: AbortSignal;
27
+ }
28
+ /** Hashes and HMACs a call may hold open (created and not yet digested) at once. */
29
+ export declare const MAX_OPEN_DIGESTS = 64;
30
+ /** `Intl` services the host keeps built for one call; the oldest is dropped past it. */
31
+ export declare const MAX_INTL_SERVICES = 64;
32
+ /** The host functions for one call, from the forge's `globals` for that call. */
33
+ export declare function guestBindings(globals: Readonly<Record<string, unknown>>, limits: GuestSurfaceLimits): Record<string, Binding>;
34
+ //# sourceMappingURL=guest-surface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guest-surface.d.ts","sourceRoot":"","sources":["../../../../src/cognition/emergent/executor/guest-surface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,gGAAgG;AAChG,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;AAEtD,iEAAiE;AACjE,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,wFAAwF;AACxF,eAAO,MAAM,iBAAiB,KAAK,CAAC;AA+GpC,iFAAiF;AACjF,wBAAgB,aAAa,CAC3B,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC1C,MAAM,EAAE,kBAAkB,GACzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoJzB"}