@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.
@@ -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 value is withheld, where the model's lanes, which
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 value, the withheld
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 value is withheld here, not only beside a
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 value
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. An empty uri carries none.
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
- * value or a disposition as the withheld notice, each as a text block. Any
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
@@ -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. Nothing is cut or saved to
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