@animalabs/agent-framework 0.26.1 → 0.26.2
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/README.md +1 -1
- package/dist/src/framework.d.ts +70 -27
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +441 -97
- package/dist/src/framework.js.map +1 -1
- package/dist/src/mcpl/references.d.ts +4 -4
- package/dist/src/mcpl/references.js +5 -5
- package/dist/src/mcpl/references.js.map +1 -1
- package/dist/src/tool-result-history.d.ts +14 -1
- package/dist/src/tool-result-history.d.ts.map +1 -1
- package/dist/src/tool-result-history.js +22 -3
- package/dist/src/tool-result-history.js.map +1 -1
- package/dist/src/types/events.d.ts +4 -1
- package/dist/src/types/events.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/framework.ts +443 -99
- package/src/mcpl/references.ts +5 -5
- package/src/tool-result-history.ts +22 -3
- package/src/types/events.ts +4 -1
package/src/mcpl/references.ts
CHANGED
|
@@ -455,8 +455,8 @@ export function referenceStubOrNull(block: unknown, provenance?: string, serverI
|
|
|
455
455
|
* result, which carries blocks rather than text. It makes the decision
|
|
456
456
|
* referenceStubOrNull makes for the model's lanes, since what a script prints
|
|
457
457
|
* comes back to the model, except that a script reads every field, so inline
|
|
458
|
-
* data beside a uri of any
|
|
459
|
-
* show no uri, withhold it beside a string one. A reference becomes the stub's facts as data,
|
|
458
|
+
* data beside a uri of any type but null or absent is withheld, where the
|
|
459
|
+
* model's lanes, which show no uri, withhold it beside a string one. A reference becomes the stub's facts as data,
|
|
460
460
|
* without its URI: the host's reference id, what the server said about it in
|
|
461
461
|
* this block (its labels stripped and bounded as in the stub), and `savedTo`,
|
|
462
462
|
* the workspace path its payload was fetched to, or null when it wasn't
|
|
@@ -470,8 +470,8 @@ export function referenceStubOrNull(block: unknown, provenance?: string, serverI
|
|
|
470
470
|
* it arrived (a module's ctx.callTool registers an MCPL peer's references),
|
|
471
471
|
* or a new one bound to no server. A block the classifier
|
|
472
472
|
* rejects becomes the notice the model's lanes show, and inline data that
|
|
473
|
-
* also claims a bulk disposition, or a uri of any
|
|
474
|
-
* notice, each as a text block.
|
|
473
|
+
* also claims a bulk disposition, or a uri of any type but null or absent
|
|
474
|
+
* (an empty string included), the withheld notice, each as a text block.
|
|
475
475
|
* A text block, or inline data that claims nothing, is returned as sent.
|
|
476
476
|
*/
|
|
477
477
|
export function referenceBlockForScript(block: unknown, serverId?: string): unknown {
|
|
@@ -480,7 +480,7 @@ export function referenceBlockForScript(block: unknown, serverId?: string): unkn
|
|
|
480
480
|
case 'text': return block;
|
|
481
481
|
case 'inline': {
|
|
482
482
|
// A script reads every field, as history's JSON writes it, so inline
|
|
483
|
-
// data beside a uri of any
|
|
483
|
+
// data beside a uri of any type is withheld here, not only beside a
|
|
484
484
|
// string one as in the model's lanes, which show no uri: an object can
|
|
485
485
|
// carry a credential. An absent or null uri carries none; a string one,
|
|
486
486
|
// an empty one included, is already the classifier's contradiction.
|
|
@@ -229,9 +229,10 @@ function shownInHistory(value: unknown): unknown {
|
|
|
229
229
|
const b = value as Record<string, unknown>;
|
|
230
230
|
if (!governedByRfc005(b)) return value;
|
|
231
231
|
if ((b.type === 'image' || b.type === 'audio') && typeof b.data === 'string') {
|
|
232
|
-
// JSON writes every field, so here inline data beside a uri of any
|
|
232
|
+
// JSON writes every field, so here inline data beside a uri of any type
|
|
233
233
|
// is withheld, not only beside a string one as in the lanes, which show
|
|
234
|
-
// no uri: an object can carry a credential.
|
|
234
|
+
// no uri: an object can carry a credential. A null, absent or empty uri
|
|
235
|
+
// carries none (hasUri).
|
|
235
236
|
return hasUri(b.uri) || b.disposition !== undefined ? INLINE_WITHHELD_TEXT : value;
|
|
236
237
|
}
|
|
237
238
|
return referenceStubOrNull(b, 'from tool result') ?? value;
|
|
@@ -243,7 +244,9 @@ function shownInHistory(value: unknown): unknown {
|
|
|
243
244
|
* RFC-005 governs is shown as the script lane shows it, a reference as its
|
|
244
245
|
* stub's facts without its uri and an invalid one as the notice
|
|
245
246
|
* (referenceBlockForScript), and inline data that also claims a uri of any
|
|
246
|
-
*
|
|
247
|
+
* type or a disposition as the withheld notice, each as a text block. A
|
|
248
|
+
* null, absent or empty uri claims none (hasUri), so inline data beside one
|
|
249
|
+
* is itself. Any
|
|
247
250
|
* other value is itself. What it gives is either a stub or a notice, which
|
|
248
251
|
* RFC-005 doesn't govern, or the value itself, which it gives again, so
|
|
249
252
|
* applying it twice gives what applying it once gave.
|
|
@@ -258,6 +261,22 @@ export function shownToScript(value: unknown): unknown {
|
|
|
258
261
|
return referenceBlockForScript(b);
|
|
259
262
|
}
|
|
260
263
|
|
|
264
|
+
/**
|
|
265
|
+
* A value nested in an MCPL peer's content block as a script reads it, as a
|
|
266
|
+
* JSON replacer applies it inside the blocks: what RFC-005 governs
|
|
267
|
+
* (governedByRfc005, history's guard, since the classifier would make a
|
|
268
|
+
* notice of an object that isn't a content block, such as a peer's own
|
|
269
|
+
* nested data) gets the treatment the script lane gives a
|
|
270
|
+
* peer's block (referenceBlockForScript), its reference bound to the server
|
|
271
|
+
* that sent it, and any other value is itself. A stub or a notice isn't
|
|
272
|
+
* governed, so a block the top-level pass already treated is left as it is.
|
|
273
|
+
*/
|
|
274
|
+
export function shownToScriptFromServer(value: unknown, serverId: string): unknown {
|
|
275
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return value;
|
|
276
|
+
const b = value as Record<string, unknown>;
|
|
277
|
+
return governedByRfc005(b) ? referenceBlockForScript(b, serverId) : value;
|
|
278
|
+
}
|
|
279
|
+
|
|
261
280
|
/**
|
|
262
281
|
* The text RFC-005 shows a value of a tool result's data as, when it shows it
|
|
263
282
|
* as text rather than as its fields: a reference's stub, an invalid one's
|
package/src/types/events.ts
CHANGED
|
@@ -299,7 +299,10 @@ export interface ToolCall {
|
|
|
299
299
|
* leaves room for them; and a result nested past 2,000 levels, or whose parse
|
|
300
300
|
* needs more of the script's memory than is free, doesn't reach the script
|
|
301
301
|
* whatever its length. A result that doesn't reach it is answered
|
|
302
|
-
* ResultTooLarge, the call having taken effect.
|
|
302
|
+
* ResultTooLarge, the call having taken effect. One the host can't convert
|
|
303
|
+
* to JSON at all, such as one nested deeper than its runtime's
|
|
304
|
+
* JSON.stringify can take, is answered instead as a failure naming the
|
|
305
|
+
* tool and saying the call itself completed. Nothing is cut or saved to
|
|
303
306
|
* a file. A tool that pages or budgets its answer can stay under it. The
|
|
304
307
|
* framework sets it on a model's, a script's and the operator's puppet's
|
|
305
308
|
* call to a module, a utility run through `utils` included. A call
|