@animalabs/agent-framework 0.22.4 → 0.23.1

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 (234) hide show
  1. package/README.md +105 -3
  2. package/dist/src/agent.d.ts +36 -10
  3. package/dist/src/agent.d.ts.map +1 -1
  4. package/dist/src/agent.js +76 -32
  5. package/dist/src/agent.js.map +1 -1
  6. package/dist/src/code-execution/index.d.ts +1 -1
  7. package/dist/src/code-execution/index.d.ts.map +1 -1
  8. package/dist/src/code-execution/index.js.map +1 -1
  9. package/dist/src/code-execution/py-runner.d.ts +34 -2
  10. package/dist/src/code-execution/py-runner.d.ts.map +1 -1
  11. package/dist/src/code-execution/py-runner.js +72 -16
  12. package/dist/src/code-execution/py-runner.js.map +1 -1
  13. package/dist/src/code-execution/runtime-py.d.ts +3 -2
  14. package/dist/src/code-execution/runtime-py.d.ts.map +1 -1
  15. package/dist/src/code-execution/runtime-py.js +47 -7
  16. package/dist/src/code-execution/runtime-py.js.map +1 -1
  17. package/dist/src/code-execution/tool-definition.d.ts +12 -7
  18. package/dist/src/code-execution/tool-definition.d.ts.map +1 -1
  19. package/dist/src/code-execution/tool-definition.js +59 -11
  20. package/dist/src/code-execution/tool-definition.js.map +1 -1
  21. package/dist/src/config-checks.d.ts +2 -2
  22. package/dist/src/config-checks.d.ts.map +1 -1
  23. package/dist/src/config-checks.js +6 -2
  24. package/dist/src/config-checks.js.map +1 -1
  25. package/dist/src/framework.d.ts +744 -120
  26. package/dist/src/framework.d.ts.map +1 -1
  27. package/dist/src/framework.js +3546 -906
  28. package/dist/src/framework.js.map +1 -1
  29. package/dist/src/gate/event-gate.d.ts.map +1 -1
  30. package/dist/src/gate/event-gate.js +13 -6
  31. package/dist/src/gate/event-gate.js.map +1 -1
  32. package/dist/src/held-writes.d.ts +16 -0
  33. package/dist/src/held-writes.d.ts.map +1 -0
  34. package/dist/src/held-writes.js +56 -0
  35. package/dist/src/held-writes.js.map +1 -0
  36. package/dist/src/index.d.ts +7 -3
  37. package/dist/src/index.d.ts.map +1 -1
  38. package/dist/src/index.js +8 -4
  39. package/dist/src/index.js.map +1 -1
  40. package/dist/src/mcpl/capability-grant.d.ts +4 -0
  41. package/dist/src/mcpl/capability-grant.d.ts.map +1 -1
  42. package/dist/src/mcpl/capability-grant.js +1 -1
  43. package/dist/src/mcpl/capability-grant.js.map +1 -1
  44. package/dist/src/mcpl/channel-registry.d.ts +95 -18
  45. package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
  46. package/dist/src/mcpl/channel-registry.js +578 -150
  47. package/dist/src/mcpl/channel-registry.js.map +1 -1
  48. package/dist/src/mcpl/convert-block.d.ts +2 -2
  49. package/dist/src/mcpl/convert-block.d.ts.map +1 -1
  50. package/dist/src/mcpl/convert-block.js +6 -7
  51. package/dist/src/mcpl/convert-block.js.map +1 -1
  52. package/dist/src/mcpl/index.d.ts +5 -1
  53. package/dist/src/mcpl/index.d.ts.map +1 -1
  54. package/dist/src/mcpl/index.js +3 -1
  55. package/dist/src/mcpl/index.js.map +1 -1
  56. package/dist/src/mcpl/inference-router.d.ts +4 -2
  57. package/dist/src/mcpl/inference-router.d.ts.map +1 -1
  58. package/dist/src/mcpl/inference-router.js +6 -7
  59. package/dist/src/mcpl/inference-router.js.map +1 -1
  60. package/dist/src/mcpl/log-value.d.ts +7 -0
  61. package/dist/src/mcpl/log-value.d.ts.map +1 -1
  62. package/dist/src/mcpl/log-value.js +9 -0
  63. package/dist/src/mcpl/log-value.js.map +1 -1
  64. package/dist/src/mcpl/modern-connection.d.ts +227 -0
  65. package/dist/src/mcpl/modern-connection.d.ts.map +1 -0
  66. package/dist/src/mcpl/modern-connection.js +1088 -0
  67. package/dist/src/mcpl/modern-connection.js.map +1 -0
  68. package/dist/src/mcpl/prefix-rule.d.ts +18 -0
  69. package/dist/src/mcpl/prefix-rule.d.ts.map +1 -0
  70. package/dist/src/mcpl/prefix-rule.js +25 -0
  71. package/dist/src/mcpl/prefix-rule.js.map +1 -0
  72. package/dist/src/mcpl/protocol-family.d.ts +179 -0
  73. package/dist/src/mcpl/protocol-family.d.ts.map +1 -0
  74. package/dist/src/mcpl/protocol-family.js +697 -0
  75. package/dist/src/mcpl/protocol-family.js.map +1 -0
  76. package/dist/src/mcpl/push-coalescer.d.ts +38 -19
  77. package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
  78. package/dist/src/mcpl/push-coalescer.js +52 -23
  79. package/dist/src/mcpl/push-coalescer.js.map +1 -1
  80. package/dist/src/mcpl/reference-fetcher.d.ts +66 -15
  81. package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -1
  82. package/dist/src/mcpl/reference-fetcher.js +243 -76
  83. package/dist/src/mcpl/reference-fetcher.js.map +1 -1
  84. package/dist/src/mcpl/references.d.ts +63 -18
  85. package/dist/src/mcpl/references.d.ts.map +1 -1
  86. package/dist/src/mcpl/references.js +117 -32
  87. package/dist/src/mcpl/references.js.map +1 -1
  88. package/dist/src/mcpl/server-connection.d.ts +326 -30
  89. package/dist/src/mcpl/server-connection.d.ts.map +1 -1
  90. package/dist/src/mcpl/server-connection.js +995 -212
  91. package/dist/src/mcpl/server-connection.js.map +1 -1
  92. package/dist/src/mcpl/server-registry.d.ts +25 -5
  93. package/dist/src/mcpl/server-registry.d.ts.map +1 -1
  94. package/dist/src/mcpl/server-registry.js +51 -12
  95. package/dist/src/mcpl/server-registry.js.map +1 -1
  96. package/dist/src/mcpl/tool-result-normalize.d.ts +54 -0
  97. package/dist/src/mcpl/tool-result-normalize.d.ts.map +1 -0
  98. package/dist/src/mcpl/tool-result-normalize.js +232 -0
  99. package/dist/src/mcpl/tool-result-normalize.js.map +1 -0
  100. package/dist/src/mcpl/transport.d.ts +56 -13
  101. package/dist/src/mcpl/transport.d.ts.map +1 -1
  102. package/dist/src/mcpl/transport.js +206 -70
  103. package/dist/src/mcpl/transport.js.map +1 -1
  104. package/dist/src/mcpl/types.d.ts +66 -20
  105. package/dist/src/mcpl/types.d.ts.map +1 -1
  106. package/dist/src/mcpl/types.js.map +1 -1
  107. package/dist/src/mcpl/visible-content.d.ts +2 -1
  108. package/dist/src/mcpl/visible-content.d.ts.map +1 -1
  109. package/dist/src/mcpl/visible-content.js +2 -1
  110. package/dist/src/mcpl/visible-content.js.map +1 -1
  111. package/dist/src/module-registry.d.ts +16 -6
  112. package/dist/src/module-registry.d.ts.map +1 -1
  113. package/dist/src/module-registry.js +65 -6
  114. package/dist/src/module-registry.js.map +1 -1
  115. package/dist/src/modules/api/index.d.ts +1 -1
  116. package/dist/src/modules/api/index.d.ts.map +1 -1
  117. package/dist/src/modules/api/index.js +3 -2
  118. package/dist/src/modules/api/index.js.map +1 -1
  119. package/dist/src/modules/discord/discord-js-client.d.ts +42 -2
  120. package/dist/src/modules/discord/discord-js-client.d.ts.map +1 -1
  121. package/dist/src/modules/discord/discord-js-client.js +268 -65
  122. package/dist/src/modules/discord/discord-js-client.js.map +1 -1
  123. package/dist/src/modules/discord/index.d.ts +27 -5
  124. package/dist/src/modules/discord/index.d.ts.map +1 -1
  125. package/dist/src/modules/discord/index.js +366 -76
  126. package/dist/src/modules/discord/index.js.map +1 -1
  127. package/dist/src/modules/discord/refusal.d.ts +14 -0
  128. package/dist/src/modules/discord/refusal.d.ts.map +1 -0
  129. package/dist/src/modules/discord/refusal.js +14 -0
  130. package/dist/src/modules/discord/refusal.js.map +1 -0
  131. package/dist/src/modules/discord/types.d.ts +17 -7
  132. package/dist/src/modules/discord/types.d.ts.map +1 -1
  133. package/dist/src/modules/health/index.d.ts.map +1 -1
  134. package/dist/src/modules/health/index.js +6 -2
  135. package/dist/src/modules/health/index.js.map +1 -1
  136. package/dist/src/modules/index.d.ts +1 -1
  137. package/dist/src/modules/index.d.ts.map +1 -1
  138. package/dist/src/modules/index.js +1 -1
  139. package/dist/src/modules/index.js.map +1 -1
  140. package/dist/src/modules/workspace/disk-agreement.d.ts +25 -2
  141. package/dist/src/modules/workspace/disk-agreement.d.ts.map +1 -1
  142. package/dist/src/modules/workspace/disk-agreement.js +45 -5
  143. package/dist/src/modules/workspace/disk-agreement.js.map +1 -1
  144. package/dist/src/modules/workspace/effects.d.ts +2 -1
  145. package/dist/src/modules/workspace/effects.d.ts.map +1 -1
  146. package/dist/src/modules/workspace/effects.js +19 -9
  147. package/dist/src/modules/workspace/effects.js.map +1 -1
  148. package/dist/src/modules/workspace/index.d.ts +214 -42
  149. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  150. package/dist/src/modules/workspace/index.js +667 -113
  151. package/dist/src/modules/workspace/index.js.map +1 -1
  152. package/dist/src/modules/workspace/observe.d.ts +240 -8
  153. package/dist/src/modules/workspace/observe.d.ts.map +1 -1
  154. package/dist/src/modules/workspace/observe.js +554 -24
  155. package/dist/src/modules/workspace/observe.js.map +1 -1
  156. package/dist/src/modules/workspace/types.d.ts +10 -1
  157. package/dist/src/modules/workspace/types.d.ts.map +1 -1
  158. package/dist/src/modules/workspace/types.js.map +1 -1
  159. package/dist/src/modules/workspace/watcher.d.ts +42 -0
  160. package/dist/src/modules/workspace/watcher.d.ts.map +1 -1
  161. package/dist/src/modules/workspace/watcher.js +130 -25
  162. package/dist/src/modules/workspace/watcher.js.map +1 -1
  163. package/dist/src/silent-heartbeat.d.ts +112 -39
  164. package/dist/src/silent-heartbeat.d.ts.map +1 -1
  165. package/dist/src/silent-heartbeat.js +100 -29
  166. package/dist/src/silent-heartbeat.js.map +1 -1
  167. package/dist/src/tool-args.d.ts +40 -0
  168. package/dist/src/tool-args.d.ts.map +1 -0
  169. package/dist/src/tool-args.js +207 -0
  170. package/dist/src/tool-args.js.map +1 -0
  171. package/dist/src/tool-presentation.d.ts.map +1 -1
  172. package/dist/src/tool-presentation.js +9 -2
  173. package/dist/src/tool-presentation.js.map +1 -1
  174. package/dist/src/types/agent.d.ts +27 -17
  175. package/dist/src/types/agent.d.ts.map +1 -1
  176. package/dist/src/types/events.d.ts +8 -0
  177. package/dist/src/types/events.d.ts.map +1 -1
  178. package/dist/src/types/framework.d.ts +17 -2
  179. package/dist/src/types/framework.d.ts.map +1 -1
  180. package/dist/src/types/module.d.ts +54 -10
  181. package/dist/src/types/module.d.ts.map +1 -1
  182. package/dist/src/types/trace.d.ts +2 -2
  183. package/dist/src/types/trace.d.ts.map +1 -1
  184. package/package.json +3 -4
  185. package/src/agent.ts +99 -36
  186. package/src/code-execution/index.ts +1 -0
  187. package/src/code-execution/py-runner.ts +104 -17
  188. package/src/code-execution/runtime-py.ts +47 -7
  189. package/src/code-execution/tool-definition.ts +65 -11
  190. package/src/config-checks.ts +4 -2
  191. package/src/framework.ts +3633 -956
  192. package/src/gate/event-gate.ts +14 -6
  193. package/src/held-writes.ts +59 -0
  194. package/src/index.ts +19 -4
  195. package/src/mcpl/capability-grant.ts +1 -1
  196. package/src/mcpl/channel-registry.ts +613 -160
  197. package/src/mcpl/convert-block.ts +15 -7
  198. package/src/mcpl/index.ts +14 -1
  199. package/src/mcpl/inference-router.ts +8 -7
  200. package/src/mcpl/log-value.ts +10 -0
  201. package/src/mcpl/modern-connection.ts +1182 -0
  202. package/src/mcpl/prefix-rule.ts +32 -0
  203. package/src/mcpl/protocol-family.ts +691 -0
  204. package/src/mcpl/push-coalescer.ts +67 -29
  205. package/src/mcpl/reference-fetcher.ts +288 -82
  206. package/src/mcpl/references.ts +123 -33
  207. package/src/mcpl/server-connection.ts +1050 -221
  208. package/src/mcpl/server-registry.ts +50 -12
  209. package/src/mcpl/tool-result-normalize.ts +294 -0
  210. package/src/mcpl/transport.ts +204 -62
  211. package/src/mcpl/types.ts +67 -20
  212. package/src/mcpl/visible-content.ts +2 -1
  213. package/src/module-registry.ts +68 -13
  214. package/src/modules/api/index.ts +3 -2
  215. package/src/modules/discord/discord-js-client.ts +288 -72
  216. package/src/modules/discord/index.ts +380 -77
  217. package/src/modules/discord/refusal.ts +13 -0
  218. package/src/modules/discord/types.ts +17 -9
  219. package/src/modules/health/index.ts +6 -2
  220. package/src/modules/index.ts +1 -1
  221. package/src/modules/workspace/disk-agreement.ts +46 -5
  222. package/src/modules/workspace/effects.ts +18 -7
  223. package/src/modules/workspace/index.ts +722 -124
  224. package/src/modules/workspace/observe.ts +591 -22
  225. package/src/modules/workspace/types.ts +10 -1
  226. package/src/modules/workspace/watcher.ts +126 -25
  227. package/src/silent-heartbeat.ts +184 -59
  228. package/src/tool-args.ts +213 -0
  229. package/src/tool-presentation.ts +9 -2
  230. package/src/types/agent.ts +27 -17
  231. package/src/types/events.ts +8 -0
  232. package/src/types/framework.ts +17 -2
  233. package/src/types/module.ts +55 -10
  234. package/src/types/trace.ts +2 -2
@@ -7,7 +7,8 @@
7
7
  *
8
8
  * - scripts run with top-level `await` (PyCF_ALLOW_TOP_LEVEL_AWAIT)
9
9
  * - host tools are injected as async functions taking a single dict and
10
- * returning a string (the tool_result text)
10
+ * returning the tool_result text as a str (ToolResult), which also
11
+ * carries .is_error and .structured
11
12
  * - a pending tool call that gets no response raises TimeoutError with the
12
13
  * same message shape the managed runtime produces
13
14
  * - interpreter globals persist across execs (container-reuse semantics)
@@ -29,7 +30,7 @@
29
30
  * host -> py : {op:"init", tools:[{py_name,tool_name}], call_timeout_s,
30
31
  * background?, log_path?, tail_chars?}
31
32
  * {op:"exec", id, code}
32
- * {op:"tool_result", id, result}
33
+ * {op:"tool_result", id, result, is_error?, structured_json?}
33
34
  * {op:"wake_ack", id, error?}
34
35
  * {op:"cancel", id, reason?}
35
36
  * py -> host : {op:"ready"}
@@ -48,10 +49,12 @@
48
49
  export const PYTHON_RUNTIME_SOURCE = String.raw `
49
50
  import ast
50
51
  import asyncio
52
+ import functools
51
53
  import inspect
52
54
  import io
53
55
  import json
54
56
  import os
57
+ import re
55
58
  import signal
56
59
  import sys
57
60
  import threading
@@ -69,9 +72,16 @@ TAIL_CHARS = 4000
69
72
 
70
73
  _send_lock = threading.Lock()
71
74
 
75
+ # A str can hold a lone surrogate, which UTF-8 can't encode: on POSIX,
76
+ # os.fsdecode makes one of each byte in a filename that doesn't decode as
77
+ # UTF-8, and json.loads makes one of a "\ud800" escape. PYTHONIOENCODING makes
78
+ # the protocol channel strict UTF-8, so writing one would fail the whole
79
+ # message, and a script's result would never arrive. Each goes as U+FFFD.
80
+ _LONE_SURROGATE = re.compile(r"[\ud800-\udfff]")
81
+
72
82
 
73
83
  def send(obj):
74
- line = json.dumps(obj, ensure_ascii=False, default=str)
84
+ line = _LONE_SURROGATE.sub("\ufffd", json.dumps(obj, ensure_ascii=False, default=str))
75
85
  with _send_lock:
76
86
  PROTO_OUT.write(line + "\n")
77
87
  PROTO_OUT.flush()
@@ -249,6 +259,31 @@ def _deliver_cancel(st):
249
259
  st.task.cancel()
250
260
 
251
261
 
262
+ class ToolResult(str):
263
+ """A tool's result: the string the tool gave, with two attributes.
264
+
265
+ is_error: True if the result is an error, False if not, None if the
266
+ host didn't say.
267
+ structured: the parsed structuredContent of a structured result's JSON
268
+ object, or None.
269
+ """
270
+
271
+ # Defaults, since pickle and copy rebuild a str subclass from its text
272
+ # alone and then restore the attributes.
273
+ def __new__(cls, text="", is_error=None, structured_json=False):
274
+ self = str.__new__(cls, text)
275
+ self.is_error = is_error
276
+ self._structured_json = structured_json
277
+ return self
278
+
279
+ # Read from the string itself, the one copy sent, on first use only.
280
+ @functools.cached_property
281
+ def structured(self):
282
+ if not self._structured_json:
283
+ return None
284
+ return json.loads(self).get("structuredContent")
285
+
286
+
252
287
  def _resolve(fut, value):
253
288
  # Defense in depth: the script may have been cancelled since the lookup.
254
289
  if fut is not None and not fut.done():
@@ -298,8 +333,9 @@ def _make_tool_fn(tool_name, py_name):
298
333
  meant.update(kwargs)
299
334
  # A key is what the agent has to write, so a str key is shown
300
335
  # whole up to 60 characters, as names are elsewhere; a longer one,
301
- # or any other key, is shown as a value is.
302
- shown = ", ".join((repr(k) if type(k) is str and len(k) <= 60 else _brief(k)) + ": " + _brief(v)
336
+ # or any other key, is shown as a value is. A tool's result counts
337
+ # as a str: ToolResult keeps str's repr, so no script code runs.
338
+ shown = ", ".join((repr(k) if (type(k) is str or type(k) is ToolResult) and len(k) <= 60 else _brief(k)) + ": " + _brief(v)
303
339
  for k, v in meant.items())
304
340
  raise TypeError(
305
341
  py_name + " wasn't called: a tool function takes one dict of "
@@ -338,7 +374,8 @@ def _make_tool_fn(tool_name, py_name):
338
374
  tool_fn.__qualname__ = py_name
339
375
  tool_fn.__doc__ = (
340
376
  "Host tool '" + tool_name + "'. Takes a single dict of arguments and "
341
- "returns the tool result as a string."
377
+ "returns the tool result as a string, with .is_error and .structured "
378
+ "beside it."
342
379
  )
343
380
  return tool_fn
344
381
 
@@ -528,7 +565,10 @@ def _dispatch(msg):
528
565
  )
529
566
  st.task = _current_exec_task
530
567
  elif op == "tool_result":
531
- _resolve(_pending_tool_futures.get(msg.get("id")), str(msg.get("result", "")))
568
+ _resolve(
569
+ _pending_tool_futures.get(msg.get("id")),
570
+ ToolResult(str(msg.get("result", "")), msg.get("is_error"), msg.get("structured_json") is True),
571
+ )
532
572
  elif op == "wake_ack":
533
573
  _resolve(_pending_wake_futures.get(msg.get("id")), msg.get("error") or None)
534
574
  elif op == "cancel":
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-py.js","sourceRoot":"","sources":["../../../src/code-execution/runtime-py.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAW,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmnBtD,CAAC"}
@@ -32,17 +32,22 @@ export declare function scriptTimeLimits(opts?: {
32
32
  /**
33
33
  * Refuse a codeExecution that isn't an object, or whose switch is set to
34
34
  * anything but true or false, and, once it's on, one whose time limits
35
- * contradict each other. A JSON config, or a `${VAR}` substituted as a string,
36
- * can carry a quoted "false" where the type says boolean, and only `true` turns
37
- * code execution on, so the quotes would hide what the value does; a bare
38
- * `codeExecution: true` would be read as off. A null or false codeExecution,
39
- * and a null switch, count as not set, as left-out ones do. The refusal names
40
- * the value's kind, not the value. A configuration that isn't on has nothing
41
- * else read.
35
+ * contradict each other or whose interpreter environment would be misread. A
36
+ * JSON config, or a `${VAR}` substituted as a string, can carry a quoted
37
+ * "false" where the type says boolean, and only `true` turns code execution
38
+ * on, so the quotes would hide what the value does; a bare
39
+ * `codeExecution: true` would be read as off. Likewise the runner passes the
40
+ * host's environment only for an `inheritEnv` of `true`, so a quoted "true"
41
+ * would quietly keep the allowlist. A null or false codeExecution, and a null
42
+ * setting, count as not set, as left-out ones do. The refusal names the
43
+ * value's kind, not the value. A configuration that isn't on has nothing else
44
+ * read.
42
45
  */
43
46
  export declare function validateCodeExecutionConfig(cfg: {
44
47
  enabled?: unknown;
45
48
  scriptTimeoutMs?: number;
46
49
  maxScriptTimeoutMs?: number;
50
+ env?: unknown;
51
+ inheritEnv?: unknown;
47
52
  }): void;
48
53
  //# sourceMappingURL=tool-definition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-definition.d.ts","sourceRoot":"","sources":["../../../src/code-execution/tool-definition.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIxD,eAAO,MAAM,wBAAwB,mBAAmB,CAAC;AAEzD,wBAAg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gB,gBAAgB,CAAC,IAAI,CAAC,EAAE;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAWhE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,IAAI,CA+CP"}
@@ -7,7 +7,7 @@
7
7
  * dict and returning a string, stdout as the return channel, persistent
8
8
  * interpreter state, asyncio.gather for fan-out.
9
9
  */
10
- import { assertBooleanSetting, holdsSettings } from '../config-checks.js';
10
+ import { assertBooleanSetting, holdsSettings, kindOf } from '../config-checks.js';
11
11
  import { formatLimit, MAX_TIMER_MS } from './py-runner.js';
12
12
  export const CODE_EXECUTION_TOOL_NAME = 'code_execution';
13
13
  export function buildCodeExecutionToolDefinition(opts) {
@@ -22,14 +22,26 @@ export function buildCodeExecutionToolDefinition(opts) {
22
22
  "non-identifier character replaced by '_' " +
23
23
  "(e.g. tool 'mcpl--discord--fetch_history' is the function mcpl__discord__fetch_history, " +
24
24
  "and tool 'mcpl--dog-events--status' is mcpl__dog_events__status). " +
25
- 'Each function takes a single dict of arguments and returns a string — the same text ' +
26
- 'the tool would have returned to you directly; parse structured results with json.loads. ' +
25
+ 'Each function takes a single dict of arguments and returns a string: the text the tool ' +
26
+ 'would have returned to you directly, or "Error: ..." if the call failed. For a result ' +
27
+ 'with structured content, the string is a JSON object to parse with json.loads: ' +
28
+ '{"content": [...], "structuredContent": ..., "isError": false}, with "error" added when ' +
29
+ `"isError" is true. "content" holds the server's content blocks. A reference to a payload ` +
30
+ 'appears there as {"type": ..., "refId": ..., "savedTo": ...}, where "savedTo" is the ' +
31
+ `workspace path the payload was saved to (null if it wasn't) and "refId" is fetch_reference's ` +
32
+ 'ref_id. A structured result over 5 MB is saved to the workspace instead, and the string is ' +
33
+ '{"isError": ..., "oversized": {"chars": ..., "savedTo": ...}}. ' +
34
+ 'Each string also carries .is_error (True if the result is an error, else False; test it ' +
35
+ 'rather than an "Error:" prefix) and .structured (the parsed "structuredContent" of the ' +
36
+ 'JSON object above, or None). ' +
27
37
  "An exact-name lookup dict is also available: tools['mcpl--discord--fetch_history']({...}). " +
28
38
  'Use top-level await; run independent calls in parallel with asyncio.gather. ' +
29
39
  'Only what you print() (plus stderr and the exit code) comes back to you — intermediate ' +
30
40
  'tool results stay in the script, so filter or aggregate large data there and print only ' +
31
41
  'what you need. Interpreter state (variables, imports) persists across code_execution ' +
32
- `calls but is reclaimed after ~${idleMinutes} minutes idle. A tool call that receives no ` +
42
+ `calls but is reclaimed after ~${idleMinutes} minutes idle. Relative paths resolve in a ` +
43
+ 'scratch directory of the interpreter\'s, which goes whenever it stops or is reclaimed, so a file meant to ' +
44
+ 'outlast the interpreter needs an absolute path. A tool call that receives no ' +
33
45
  `response within ~${callTimeoutSeconds}s raises TimeoutError inside the script. ` +
34
46
  `A foreground script is stopped after ${formatLimit(limits.defaultMs)}; pass time_limit_ms to set this call's limit ` +
35
47
  `(at most ${formatLimit(limits.maxMs)}; a background script runs up to ${formatLimit(limits.backgroundMaxMs)}). ` +
@@ -100,13 +112,16 @@ export function scriptTimeLimits(opts) {
100
112
  /**
101
113
  * Refuse a codeExecution that isn't an object, or whose switch is set to
102
114
  * anything but true or false, and, once it's on, one whose time limits
103
- * contradict each other. A JSON config, or a `${VAR}` substituted as a string,
104
- * can carry a quoted "false" where the type says boolean, and only `true` turns
105
- * code execution on, so the quotes would hide what the value does; a bare
106
- * `codeExecution: true` would be read as off. A null or false codeExecution,
107
- * and a null switch, count as not set, as left-out ones do. The refusal names
108
- * the value's kind, not the value. A configuration that isn't on has nothing
109
- * else read.
115
+ * contradict each other or whose interpreter environment would be misread. A
116
+ * JSON config, or a `${VAR}` substituted as a string, can carry a quoted
117
+ * "false" where the type says boolean, and only `true` turns code execution
118
+ * on, so the quotes would hide what the value does; a bare
119
+ * `codeExecution: true` would be read as off. Likewise the runner passes the
120
+ * host's environment only for an `inheritEnv` of `true`, so a quoted "true"
121
+ * would quietly keep the allowlist. A null or false codeExecution, and a null
122
+ * setting, count as not set, as left-out ones do. The refusal names the
123
+ * value's kind, not the value. A configuration that isn't on has nothing else
124
+ * read.
110
125
  */
111
126
  export function validateCodeExecutionConfig(cfg) {
112
127
  if (!holdsSettings('codeExecution', cfg, '{ enabled: true }'))
@@ -120,5 +135,38 @@ export function validateCodeExecutionConfig(cfg) {
120
135
  throw new Error(`codeExecution.maxScriptTimeoutMs (${cfg.maxScriptTimeoutMs}) must be at least scriptTimeoutMs (${defaultMs}): ` +
121
136
  'it is the most an agent may ask for, and the default is always allowed');
122
137
  }
138
+ // None of the environment's refusals below shows the value it refuses,
139
+ // at most its kind: a substituted value can be a credential. null counts
140
+ // as not set, so a generated config that writes an unset setting as null
141
+ // keeps working.
142
+ assertBooleanSetting('codeExecution.inheritEnv', cfg.inheritEnv, "true hands the interpreter the host's whole environment, and false or leaving it out keeps the allowlist");
143
+ if (cfg.env !== undefined && cfg.env !== null) {
144
+ if (!isPlainObject(cfg.env)) {
145
+ throw new Error(`codeExecution.env must be an object of variable names and string values, not ${kindOf(cfg.env)}`);
146
+ }
147
+ for (const [name, value] of Object.entries(cfg.env)) {
148
+ // spawn writes each variable as name=value: a name that is empty or
149
+ // holds '=' doesn't reach the interpreter as written, and a NUL in a
150
+ // name or a value makes spawn throw at every start.
151
+ // Only what comes before an '=' or NUL is shown: what follows can be a
152
+ // value pasted into the name.
153
+ if (name === '' || name.includes('=') || name.includes('\0')) {
154
+ const shown = name === '' ? 'that is empty' : `starting ${JSON.stringify(name.split(/[=\0]/, 1)[0])} that holds '=' or NUL`;
155
+ throw new Error(`codeExecution.env has a variable name ${shown}, and a name can't be empty or hold '=' or NUL`);
156
+ }
157
+ if (typeof value !== 'string') {
158
+ throw new Error(`codeExecution.env.${name} must be a string, not ${kindOf(value)}: give its value as a string, or leave ${name} out`);
159
+ }
160
+ if (value.includes('\0')) {
161
+ throw new Error(`codeExecution.env.${name} holds a NUL character, which no environment variable can carry`);
162
+ }
163
+ }
164
+ }
165
+ }
166
+ function isPlainObject(value) {
167
+ if (typeof value !== 'object' || value === null)
168
+ return false;
169
+ const proto = Object.getPrototypeOf(value);
170
+ return proto === Object.prototype || proto === null;
123
171
  }
124
172
  //# sourceMappingURL=tool-definition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-definition.js","sourceRoot":"","sources":["../../../src/code-execution/tool-definition.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE3D,MAAM,CAAC,MAAM,wBAAwB,GAAG,gBAAgB,CAAC;AAEzD,MAAM,UAAU,gCAAgC,CAAC,IAMhD;IACC,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,aAAa,IAAI,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IACvF,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,iBAAiB,IAAI,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IACnF,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO;QACL,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EACT,mEAAm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ted into the wrong field.
9
9
  */
10
- /** The kind of a value that isn't undefined, null or a boolean, as a refusal
11
- * names it in place of the value. */
10
+ /** The kind of a value, as a refusal names it in place of the value, which
11
+ * can be a credential. */
12
12
  export declare function kindOf(value: unknown): string;
13
13
  /**
14
14
  * Refuse a boolean setting that holds anything but true or false. null counts
@@ -1 +1 @@
1
- {"version":3,"file":"config-checks.d.ts","sourceRoot":"","sources":["../../src/config-checks.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;sCACsC;AACtC,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQ7C;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAI9F;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAMpG"}
1
+ {"version":3,"file":"config-checks.d.ts","sourceRoot":"","sources":["../../src/config-checks.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;2BAC2B;AAC3B,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAU7C;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAI9F;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAMpG"}
@@ -7,9 +7,13 @@
7
7
  * the setting and the value's kind, never the value, which could be a secret
8
8
  * pasted into the wrong field.
9
9
  */
10
- /** The kind of a value that isn't undefined, null or a boolean, as a refusal
11
- * names it in place of the value. */
10
+ /** The kind of a value, as a refusal names it in place of the value, which
11
+ * can be a credential. */
12
12
  export function kindOf(value) {
13
+ if (value === null)
14
+ return 'null';
15
+ if (value === undefined)
16
+ return 'undefined';
13
17
  if (Array.isArray(value))
14
18
  return 'an array';
15
19
  if (typeof value !== 'object')
@@ -1 +1 @@
1
- {"version":3,"file":"config-checks.js","sourceRoot":"","sources":["../../src/config-checks.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;sCACsC;AACtC,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,UAAU,CAAC;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,OAAO,KAAK,EAAE,CAAC;IAC1D,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAA+C,CAAC;IAC7F,IAAI,SAAS,KAAK,IAAI,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS;QAAE,OAAO,WAAW,CAAC;IAC7E,MAAM,IAAI,GAAG,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC;IACzC,IAAI,CAAC,IAAI;QAAE,OAAO,6BAA6B,CAAC;IAChD,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;AAC1D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe,EAAE,KAAc,EAAE,UAAkB;IACtF,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO;IAChF,MAAM,MAAM,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,gBAA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