@lobu/runtime-device 21.2.1 → 23.0.0

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 (233) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +91 -83
  3. package/npm-shrinkwrap.json +492 -438
  4. package/package.json +12 -2
  5. package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +1 -1
  6. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +5 -6
  7. package/vendor/cli/dist/commands/_lib/apply/client.d.ts +1 -0
  8. package/vendor/cli/dist/commands/_lib/apply/client.js +26 -7
  9. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +9 -1
  10. package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +1 -0
  11. package/vendor/cli/dist/commands/_lib/apply/diff.js +46 -4
  12. package/vendor/cli/dist/commands/_lib/apply/map-config.js +18 -38
  13. package/vendor/cli/dist/commands/_lib/init-from-org/bootstrap.js +5 -17
  14. package/vendor/cli/dist/commands/init.d.ts +0 -2
  15. package/vendor/cli/dist/commands/init.js +0 -27
  16. package/vendor/cli/dist/commands/login.d.ts +17 -0
  17. package/vendor/cli/dist/commands/login.js +43 -17
  18. package/vendor/cli/dist/commands/memory/_lib/errors.d.ts +0 -8
  19. package/vendor/cli/dist/commands/memory/_lib/errors.js +0 -12
  20. package/vendor/cli/dist/commands/memory/_lib/mcp.js +6 -6
  21. package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +4 -10
  22. package/vendor/cli/dist/config/define.d.ts +21 -15
  23. package/vendor/cli/dist/config/define.js +2 -2
  24. package/vendor/cli/dist/connectors/README.md +21 -6
  25. package/vendor/cli/dist/connectors/_google/actions.ts +270 -0
  26. package/vendor/cli/dist/connectors/_google/discovery/calendar_v3.json +1 -0
  27. package/vendor/cli/dist/connectors/_google/discovery/chat_v1.json +1 -0
  28. package/vendor/cli/dist/connectors/_google/discovery/docs_v1.json +1 -0
  29. package/vendor/cli/dist/connectors/_google/discovery/drive_v3.json +1 -0
  30. package/vendor/cli/dist/connectors/_google/discovery/gmail_v1.json +1 -0
  31. package/vendor/cli/dist/connectors/_google/discovery/people_v1.json +1 -0
  32. package/vendor/cli/dist/connectors/_google/discovery/sheets_v4.json +1 -0
  33. package/vendor/cli/dist/connectors/_google/discovery/tasks_v1.json +1 -0
  34. package/vendor/cli/dist/connectors/_google/discovery/youtube_v3.json +1 -0
  35. package/vendor/cli/dist/connectors/_google/discovery.ts +442 -0
  36. package/vendor/cli/dist/connectors/_google/errors.ts +91 -0
  37. package/vendor/cli/dist/connectors/_google/list-feed.ts +223 -0
  38. package/vendor/cli/dist/connectors/_google/policies.ts +127 -0
  39. package/vendor/cli/dist/connectors/agentid.ts +43 -0
  40. package/vendor/cli/dist/connectors/chat-user-identity.ts +2 -1
  41. package/vendor/cli/dist/connectors/github-automation-events.ts +9 -0
  42. package/vendor/cli/dist/connectors/github-identity.ts +28 -3
  43. package/vendor/cli/dist/connectors/github.ts +101 -59
  44. package/vendor/cli/dist/connectors/google_calendar.ts +207 -719
  45. package/vendor/cli/dist/connectors/google_drive.ts +16 -2
  46. package/vendor/cli/dist/connectors/google_gmail.ts +52 -33
  47. package/vendor/cli/dist/connectors/herdr.ts +406 -0
  48. package/vendor/cli/dist/connectors/jira-helpers.ts +313 -0
  49. package/vendor/cli/dist/connectors/jira.ts +35 -227
  50. package/vendor/cli/dist/connectors/linear.ts +7 -4
  51. package/vendor/cli/dist/connectors/linkedin-browser-script.ts +13 -0
  52. package/vendor/cli/dist/connectors/linkedin-draft-page.js +104 -0
  53. package/vendor/cli/dist/connectors/linkedin-drafts.ts +73 -0
  54. package/vendor/cli/dist/connectors/linkedin-identity.ts +32 -0
  55. package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +1185 -0
  56. package/vendor/cli/dist/connectors/linkedin-inbox.ts +156 -0
  57. package/vendor/cli/dist/connectors/linkedin-like.ts +114 -0
  58. package/vendor/cli/dist/connectors/linkedin-takeout.ts +577 -0
  59. package/vendor/cli/dist/connectors/linkedin.ts +3998 -0
  60. package/vendor/cli/dist/connectors/postgres.ts +27 -2
  61. package/vendor/cli/dist/connectors/takeout-utils.ts +240 -0
  62. package/vendor/cli/dist/connectors/tiktok-inbox-page.js +230 -0
  63. package/vendor/cli/dist/connectors/tiktok-web-page.js +217 -0
  64. package/vendor/cli/dist/connectors/tiktok_web.ts +319 -0
  65. package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +285 -567
  66. package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +74 -455
  67. package/vendor/cli/dist/connectors/whatsapp-web-identity.ts +135 -0
  68. package/vendor/cli/dist/connectors/whatsapp_web.ts +159 -618
  69. package/vendor/cli/dist/connectors/x-dm-adapter.js +556 -0
  70. package/vendor/cli/dist/connectors/x-identity.ts +31 -2
  71. package/vendor/cli/dist/connectors/x.ts +539 -253
  72. package/vendor/cli/dist/index.js +1 -37
  73. package/vendor/cli/dist/internal/context.d.ts +10 -0
  74. package/vendor/cli/dist/internal/context.js +26 -16
  75. package/vendor/cli/dist/internal/node-version.d.ts +1 -1
  76. package/vendor/cli/dist/internal/node-version.js +1 -1
  77. package/vendor/cli/dist/internal/oauth.d.ts +3 -1
  78. package/vendor/cli/dist/internal/oauth.js +4 -3
  79. package/vendor/cli/dist/internal/runtime-components.d.ts +9 -0
  80. package/vendor/cli/dist/internal/runtime-components.js +67 -2
  81. package/vendor/cli/dist/mac-auth.js +17 -1
  82. package/vendor/cli/dist/providers.json +1 -1
  83. package/vendor/cli/dist/runtime-components.json +4 -4
  84. package/vendor/cli/dist/templates/AGENTS.md.tmpl +12 -5
  85. package/vendor/cli/dist/templates/README.md.tmpl +1 -1
  86. package/vendor/cli/dist/vendor/ora/.bun-tag-fde20e9a6df212fa +0 -0
  87. package/vendor/cli/dist/vendor/ora/index.d.ts +332 -0
  88. package/vendor/cli/dist/vendor/ora/index.js +424 -0
  89. package/vendor/cli/dist/vendor/ora/license +9 -0
  90. package/vendor/cli/dist/vendor/ora/package.json +64 -0
  91. package/vendor/cli/dist/vendor/ora/readme.md +329 -0
  92. package/vendor/cli/package.json +2 -2
  93. package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
  94. package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
  95. package/vendor/connector-sdk/dist/browser-requirement.d.ts +36 -0
  96. package/vendor/connector-sdk/dist/browser-requirement.js +60 -0
  97. package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
  98. package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
  99. package/vendor/connector-sdk/dist/connector-runtime.d.ts +3 -1
  100. package/vendor/connector-sdk/dist/connector-runtime.js +10 -0
  101. package/vendor/connector-sdk/dist/connector-types.d.ts +169 -45
  102. package/vendor/connector-sdk/dist/define-connector.d.ts +4 -2
  103. package/vendor/connector-sdk/dist/define-connector.js +3 -0
  104. package/vendor/connector-sdk/dist/index.d.ts +8 -2
  105. package/vendor/connector-sdk/dist/index.js +3 -0
  106. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +16 -21
  107. package/vendor/connector-sdk/dist/reaction-client-types.typecheck.d.ts +5 -0
  108. package/vendor/connector-sdk/package.json +13 -1
  109. package/vendor/connector-worker/dist/agent-turn/guest-entry.js +43 -30
  110. package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +416 -330
  111. package/vendor/connector-worker/dist/agent-turn/memory.d.ts +3 -2
  112. package/vendor/connector-worker/dist/agent-turn/memory.js +3 -20
  113. package/vendor/connector-worker/dist/agent-turn/types.d.ts +3 -15
  114. package/vendor/connector-worker/dist/agent-turn/workspace.d.ts +2 -2
  115. package/vendor/connector-worker/dist/agent-turn/workspace.js +2 -4
  116. package/vendor/connector-worker/dist/daemon/action-monitor.d.ts +12 -0
  117. package/vendor/connector-worker/dist/daemon/action-monitor.js +25 -0
  118. package/vendor/connector-worker/dist/daemon/agent-turn.js +0 -9
  119. package/vendor/connector-worker/dist/daemon/automation.d.ts +4 -11
  120. package/vendor/connector-worker/dist/daemon/automation.js +6 -6
  121. package/vendor/connector-worker/dist/daemon/builtins/index.d.ts +12 -0
  122. package/vendor/connector-worker/dist/daemon/builtins/index.js +61 -1
  123. package/vendor/connector-worker/dist/daemon/builtins/os-shell.d.ts +2 -1
  124. package/vendor/connector-worker/dist/daemon/builtins/os-shell.js +40 -27
  125. package/vendor/connector-worker/dist/daemon/client.d.ts +6 -4
  126. package/vendor/connector-worker/dist/daemon/client.js +3 -3
  127. package/vendor/connector-worker/dist/daemon/device-concurrency.d.ts +8 -0
  128. package/vendor/connector-worker/dist/daemon/device-concurrency.js +13 -0
  129. package/vendor/connector-worker/dist/daemon/executor.d.ts +1 -1
  130. package/vendor/connector-worker/dist/daemon/executor.js +48 -120
  131. package/vendor/connector-worker/dist/daemon/log.d.ts +2 -0
  132. package/vendor/connector-worker/dist/daemon/log.js +23 -2
  133. package/vendor/connector-worker/dist/daemon/mac-device-daemon.d.ts +23 -6
  134. package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +57 -23
  135. package/vendor/connector-worker/dist/daemon/native-bridge/client.d.ts +6 -0
  136. package/vendor/connector-worker/dist/daemon/native-bridge/client.js +15 -0
  137. package/vendor/connector-worker/dist/daemon/native-bridge/executor.js +29 -25
  138. package/vendor/connector-worker/dist/daemon/native-bridge/protocol.d.ts +1 -1
  139. package/vendor/connector-worker/dist/daemon/native-bridge/protocol.js +1 -0
  140. package/vendor/connector-worker/dist/daemon/poll-loop.d.ts +3 -0
  141. package/vendor/connector-worker/dist/daemon/poll-loop.js +5 -1
  142. package/vendor/connector-worker/dist/daemon/start.d.ts +1 -0
  143. package/vendor/connector-worker/dist/daemon/start.js +15 -20
  144. package/vendor/connector-worker/dist/daemon/terminal-failure.js +0 -11
  145. package/vendor/connector-worker/dist/daemon/worker-id.d.ts +17 -0
  146. package/vendor/connector-worker/dist/daemon/worker-id.js +22 -0
  147. package/vendor/connector-worker/dist/executor/interface.d.ts +34 -2
  148. package/vendor/connector-worker/dist/executor/isolate.js +66 -15
  149. package/vendor/connector-worker/dist/executor/redact.d.ts +1 -0
  150. package/vendor/connector-worker/dist/executor/redact.js +97 -26
  151. package/vendor/connector-worker/dist/executor/runtime.d.ts +7 -0
  152. package/vendor/connector-worker/dist/executor/runtime.js +26 -0
  153. package/vendor/connector-worker/dist/isolate/bridge.js +3 -1
  154. package/vendor/connector-worker/dist/mac-device-daemon.js +24 -29
  155. package/vendor/connector-worker/package.json +2 -2
  156. package/vendor/core/dist/agent-policy.js +1 -1
  157. package/vendor/core/dist/agent-store.d.ts +2 -0
  158. package/vendor/core/dist/agent-tooling.d.ts +1 -1
  159. package/vendor/core/dist/agent-tooling.js +1 -1
  160. package/vendor/core/dist/capabilities.d.ts +1 -1
  161. package/vendor/core/dist/capabilities.js +2 -1
  162. package/vendor/core/dist/connector-query-errors.d.ts +32 -0
  163. package/vendor/core/dist/connector-query-errors.js +41 -1
  164. package/vendor/core/dist/contracts/agent-settings.d.ts +0 -11
  165. package/vendor/core/dist/contracts/agent-settings.js +1 -7
  166. package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +93 -0
  167. package/vendor/core/dist/contracts/tools/collection-presentation.js +88 -0
  168. package/vendor/core/dist/contracts/tools/collection-selection.d.ts +47 -0
  169. package/vendor/core/dist/contracts/tools/collection-selection.js +74 -0
  170. package/vendor/core/dist/contracts/tools/manage-agents.d.ts +10 -4
  171. package/vendor/core/dist/contracts/tools/manage-auth-profiles.d.ts +1 -1
  172. package/vendor/core/dist/contracts/tools/manage-auth-profiles.js +5 -1
  173. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +19 -4
  174. package/vendor/core/dist/contracts/tools/manage-automations.js +25 -8
  175. package/vendor/core/dist/contracts/tools/manage-connections.d.ts +1 -0
  176. package/vendor/core/dist/contracts/tools/manage-connections.js +3 -0
  177. package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
  178. package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +11 -0
  179. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +42 -3
  180. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +181 -152
  181. package/vendor/core/dist/contracts/tools/manage-entity.js +118 -162
  182. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
  183. package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
  184. package/vendor/core/dist/contracts/tools/manage-operations.d.ts +41 -3
  185. package/vendor/core/dist/contracts/tools/manage-operations.js +40 -2
  186. package/vendor/core/dist/contracts/tools/manage-views.d.ts +182 -7
  187. package/vendor/core/dist/contracts/tools/manage-views.js +49 -13
  188. package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +11 -2
  189. package/vendor/core/dist/contracts/tools/read-knowledge.js +23 -3
  190. package/vendor/core/dist/contracts/tools/save-memory.d.ts +3 -6
  191. package/vendor/core/dist/contracts/tools/save-memory.js +2 -6
  192. package/vendor/core/dist/contracts/tools/view-attach.d.ts +2 -1
  193. package/vendor/core/dist/contracts/tools/view-attach.js +7 -2
  194. package/vendor/core/dist/contracts/worker/protocol.d.ts +130 -159
  195. package/vendor/core/dist/contracts/worker/protocol.js +88 -76
  196. package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
  197. package/vendor/core/dist/device-pin-tombstones.js +57 -0
  198. package/vendor/core/dist/index.d.ts +5 -5
  199. package/vendor/core/dist/index.js +4 -6
  200. package/vendor/core/dist/json-template.d.ts +6 -10
  201. package/vendor/core/dist/json-template.js +5 -9
  202. package/vendor/core/dist/logger.js +17 -26
  203. package/vendor/core/dist/shell-safety.d.ts +9 -0
  204. package/vendor/core/dist/shell-safety.js +154 -0
  205. package/vendor/core/dist/suggestions.d.ts +1 -1
  206. package/vendor/core/dist/suggestions.js +1 -1
  207. package/vendor/core/dist/tool-trace-summary.d.ts +1 -1
  208. package/vendor/core/dist/tool-trace-summary.js +1 -1
  209. package/vendor/core/dist/types.d.ts +1 -3
  210. package/vendor/core/dist/utils/diagnostic-scrubber.d.ts +7 -0
  211. package/vendor/core/dist/utils/diagnostic-scrubber.js +437 -0
  212. package/vendor/core/dist/worker/auth.d.ts +44 -6
  213. package/vendor/core/dist/worker/auth.js +44 -11
  214. package/vendor/core/dist/worker/wire.d.ts +0 -10
  215. package/vendor/core/package.json +20 -11
  216. package/vendor/ora/.bun-tag-fde20e9a6df212fa +0 -0
  217. package/vendor/ora/index.d.ts +332 -0
  218. package/vendor/ora/index.js +424 -0
  219. package/vendor/ora/license +9 -0
  220. package/vendor/ora/package.json +53 -0
  221. package/vendor/ora/readme.md +329 -0
  222. package/vendor/cli/dist/commands/telemetry.d.ts +0 -10
  223. package/vendor/cli/dist/commands/telemetry.js +0 -66
  224. package/vendor/connector-worker/dist/daemon/device-chat.d.ts +0 -9
  225. package/vendor/connector-worker/dist/daemon/device-chat.js +0 -61
  226. package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
  227. package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
  228. package/vendor/core/dist/sentry.d.ts +0 -26
  229. package/vendor/core/dist/sentry.js +0 -133
  230. package/vendor/core/dist/tool-policy.d.ts +0 -74
  231. package/vendor/core/dist/tool-policy.js +0 -305
  232. package/vendor/core/dist/utils/sentry-scrubber.d.ts +0 -29
  233. package/vendor/core/dist/utils/sentry-scrubber.js +0 -228
@@ -4333,7 +4333,7 @@ var init_agent_policy = __esm({
4333
4333
  description: "Post a message to one of your conversations. Pass a conversation handle (from list_conversations) to post to the channel, or a thread handle (returned by a previous send_message) to reply in that thread. This is how an automated/scheduled run speaks in its channel."
4334
4334
  },
4335
4335
  present_event: {
4336
- description: "Render an existing Lobu event in the current conversation through its declared json_template. Use the event id returned by knowledge.save; do not hand-author platform card JSON or action ids."
4336
+ description: "Present an existing Lobu event as a summary and Open event link in the current conversation. Custom interactions open in its React view. Use the event id returned by knowledge.save; do not hand-author platform card JSON or action ids."
4337
4337
  },
4338
4338
  schedule_followup: {
4339
4339
  description: "Schedule one durable future wake-up for yourself in the current conversation. The server fixes the agent and destination from the signed turn; provide a stable idempotency key so retries do not duplicate the wake-up."
@@ -4501,6 +4501,271 @@ var init_agent_tooling = __esm({
4501
4501
  }
4502
4502
  });
4503
4503
 
4504
+ // ../plugin-toolkit/dist/mcp-content.js
4505
+ var require_mcp_content = __commonJS({
4506
+ "../plugin-toolkit/dist/mcp-content.js"(exports2) {
4507
+ "use strict";
4508
+ Object.defineProperty(exports2, "__esModule", { value: true });
4509
+ exports2.MAX_TOOL_IMAGES = exports2.MAX_TOOL_IMAGE_BYTES_TOTAL = exports2.MAX_TOOL_IMAGE_BYTES = void 0;
4510
+ exports2.toolImageBudget = toolImageBudget2;
4511
+ exports2.isToolImageMimeType = isToolImageMimeType;
4512
+ exports2.mcpToolResult = mcpToolResult2;
4513
+ exports2.MAX_TOOL_IMAGE_BYTES = 5 * 1024 * 1024;
4514
+ exports2.MAX_TOOL_IMAGE_BYTES_TOTAL = 10 * 1024 * 1024;
4515
+ exports2.MAX_TOOL_IMAGES = 8;
4516
+ function base64DecodedBytes(data) {
4517
+ return Math.ceil(data.length / 4) * 3 - (data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0);
4518
+ }
4519
+ function toolImageBudget2(content) {
4520
+ const budget = { bytes: 0 };
4521
+ for (const raw of content) {
4522
+ if (!raw || typeof raw !== "object")
4523
+ continue;
4524
+ const part = raw;
4525
+ if (part.type !== "image" || typeof part.data !== "string")
4526
+ continue;
4527
+ budget.bytes += base64DecodedBytes(part.data);
4528
+ }
4529
+ return budget;
4530
+ }
4531
+ var IMAGE_TYPES = /* @__PURE__ */ new Set([
4532
+ "image/png",
4533
+ "image/jpeg",
4534
+ "image/webp",
4535
+ "image/gif"
4536
+ ]);
4537
+ function isToolImageMimeType(value) {
4538
+ return typeof value === "string" && IMAGE_TYPES.has(value);
4539
+ }
4540
+ function imageBytes(data) {
4541
+ if (typeof data !== "string" || data.length === 0)
4542
+ return null;
4543
+ if (data.length > 4 * Math.ceil(exports2.MAX_TOOL_IMAGE_BYTES / 3))
4544
+ return null;
4545
+ if (data.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(data))
4546
+ return null;
4547
+ return base64DecodedBytes(data);
4548
+ }
4549
+ function hasImageSignature(data, mimeType) {
4550
+ const header = atob(data.slice(0, 16));
4551
+ if (mimeType === "image/png")
4552
+ return header.startsWith("\x89PNG\r\n\n");
4553
+ if (mimeType === "image/jpeg")
4554
+ return header.startsWith("\xFF\xD8\xFF");
4555
+ if (mimeType === "image/gif")
4556
+ return header.startsWith("GIF87a") || header.startsWith("GIF89a");
4557
+ return header.startsWith("RIFF") && header.slice(8, 12) === "WEBP";
4558
+ }
4559
+ function mcpToolResult2(content, fallback, supportsImages = true, budget) {
4560
+ const result = { content: [] };
4561
+ let count = 0;
4562
+ let total = 0;
4563
+ let hasImageLink = false;
4564
+ const diagnostics = /* @__PURE__ */ new Set();
4565
+ for (const raw of Array.isArray(content) ? content : []) {
4566
+ if (!raw || typeof raw !== "object")
4567
+ continue;
4568
+ const part = raw;
4569
+ if (part.type === "text" && typeof part.text === "string") {
4570
+ if (part.text)
4571
+ result.content.push({ type: "text", text: part.text });
4572
+ continue;
4573
+ }
4574
+ if (part.type === "resource_link") {
4575
+ hasImageLink ||= isToolImageMimeType(part.mimeType);
4576
+ continue;
4577
+ }
4578
+ const resource = part.type === "resource" && part.resource && typeof part.resource === "object" ? part.resource : void 0;
4579
+ if (resource && typeof resource.text === "string") {
4580
+ if (resource.text)
4581
+ result.content.push({ type: "text", text: resource.text });
4582
+ continue;
4583
+ }
4584
+ if (part.type !== "image" && !(resource && typeof resource.mimeType === "string" && resource.mimeType.startsWith("image/")))
4585
+ continue;
4586
+ const mimeType = resource ? resource.mimeType : part.mimeType;
4587
+ const data = resource ? resource.blob : part.data;
4588
+ const size = imageBytes(data);
4589
+ let reason;
4590
+ if (!supportsImages)
4591
+ reason = "the selected model does not declare image input support";
4592
+ else if (!isToolImageMimeType(mimeType) || size === null || !hasImageSignature(data, mimeType))
4593
+ reason = "unsupported MIME type, invalid image bytes, or image size limit";
4594
+ else if (size > exports2.MAX_TOOL_IMAGE_BYTES || count >= exports2.MAX_TOOL_IMAGES || total + size > exports2.MAX_TOOL_IMAGE_BYTES_TOTAL || budget && budget.bytes + size > exports2.MAX_TOOL_IMAGE_BYTES_TOTAL)
4595
+ reason = "tool image budget exhausted";
4596
+ if (reason) {
4597
+ diagnostics.add(`Image not delivered: ${reason}. Do not infer visual contents.`);
4598
+ continue;
4599
+ }
4600
+ result.content.push({
4601
+ type: "image",
4602
+ mimeType,
4603
+ data
4604
+ });
4605
+ count++;
4606
+ total += size;
4607
+ if (budget)
4608
+ budget.bytes += size;
4609
+ }
4610
+ if (hasImageLink && count === 0)
4611
+ diagnostics.add("Image bytes were not supplied. A resource link alone is not a visual observation.");
4612
+ for (const text2 of diagnostics)
4613
+ result.content.push({ type: "text", text: text2 });
4614
+ if (result.content.length === 0)
4615
+ result.content.push({ type: "text", text: fallback });
4616
+ return result;
4617
+ }
4618
+ }
4619
+ });
4620
+
4621
+ // ../plugin-toolkit/dist/index.js
4622
+ var require_dist = __commonJS({
4623
+ "../plugin-toolkit/dist/index.js"(exports2) {
4624
+ "use strict";
4625
+ Object.defineProperty(exports2, "__esModule", { value: true });
4626
+ exports2.toolLogger = exports2.MAX_TOOL_IMAGES = exports2.MAX_TOOL_IMAGE_BYTES_TOTAL = exports2.MAX_TOOL_IMAGE_BYTES = exports2.isToolImageMimeType = exports2.mcpToolResult = exports2.toolImageBudget = void 0;
4627
+ exports2.setToolLogger = setToolLogger;
4628
+ exports2.createGatewayClient = createGatewayClient;
4629
+ exports2.textResult = textResult;
4630
+ exports2.jsonResult = jsonResult;
4631
+ exports2.joinTextContent = joinTextContent;
4632
+ exports2.withErrorHandling = withErrorHandling;
4633
+ exports2.parseErrorBody = parseErrorBody;
4634
+ exports2.gatewayFetch = gatewayFetch;
4635
+ exports2.postLinkButton = postLinkButton;
4636
+ exports2.toToolResult = toToolResult;
4637
+ exports2.defineTool = defineTool2;
4638
+ exports2.defineGatewayTool = defineGatewayTool;
4639
+ var agent_tooling_1 = (init_agent_tooling(), __toCommonJS(agent_tooling_exports));
4640
+ var mcp_content_1 = require_mcp_content();
4641
+ Object.defineProperty(exports2, "toolImageBudget", { enumerable: true, get: function() {
4642
+ return mcp_content_1.toolImageBudget;
4643
+ } });
4644
+ Object.defineProperty(exports2, "mcpToolResult", { enumerable: true, get: function() {
4645
+ return mcp_content_1.mcpToolResult;
4646
+ } });
4647
+ Object.defineProperty(exports2, "isToolImageMimeType", { enumerable: true, get: function() {
4648
+ return mcp_content_1.isToolImageMimeType;
4649
+ } });
4650
+ Object.defineProperty(exports2, "MAX_TOOL_IMAGE_BYTES", { enumerable: true, get: function() {
4651
+ return mcp_content_1.MAX_TOOL_IMAGE_BYTES;
4652
+ } });
4653
+ Object.defineProperty(exports2, "MAX_TOOL_IMAGE_BYTES_TOTAL", { enumerable: true, get: function() {
4654
+ return mcp_content_1.MAX_TOOL_IMAGE_BYTES_TOTAL;
4655
+ } });
4656
+ Object.defineProperty(exports2, "MAX_TOOL_IMAGES", { enumerable: true, get: function() {
4657
+ return mcp_content_1.MAX_TOOL_IMAGES;
4658
+ } });
4659
+ var logger = {
4660
+ error: (message, ...args) => console.error(message, ...args),
4661
+ warn: (message, ...args) => console.warn(message, ...args),
4662
+ info: (message, ...args) => console.info(message, ...args),
4663
+ debug: (message, ...args) => console.debug(message, ...args)
4664
+ };
4665
+ function setToolLogger(next) {
4666
+ logger = next;
4667
+ }
4668
+ exports2.toolLogger = {
4669
+ error: (message, ...args) => logger.error(message, ...args),
4670
+ warn: (message, ...args) => logger.warn(message, ...args),
4671
+ info: (message, ...args) => logger.info(message, ...args),
4672
+ debug: (message, ...args) => logger.debug(message, ...args)
4673
+ };
4674
+ function createGatewayClient(config) {
4675
+ const fetchFn = config.fetchFn ?? fetch;
4676
+ return {
4677
+ request(path6, init = {}) {
4678
+ return fetchFn(`${config.baseUrl}${path6}`, {
4679
+ method: init.method,
4680
+ headers: {
4681
+ Authorization: `Bearer ${config.token}`,
4682
+ ...init.body !== void 0 ? { "Content-Type": "application/json" } : {},
4683
+ ...init.headers
4684
+ },
4685
+ body: init.body,
4686
+ signal: init.signal ?? (init.timeoutMs !== void 0 ? AbortSignal.timeout(init.timeoutMs) : void 0)
4687
+ });
4688
+ }
4689
+ };
4690
+ }
4691
+ function textResult(text2) {
4692
+ return { content: [{ type: "text", text: text2 }] };
4693
+ }
4694
+ function jsonResult(payload) {
4695
+ return textResult(JSON.stringify(payload));
4696
+ }
4697
+ function joinTextContent(content) {
4698
+ return (content ?? []).filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text).join("\n");
4699
+ }
4700
+ function withErrorHandling(label, fn2) {
4701
+ return fn2().catch((error) => {
4702
+ logger.error(`${label} error:`, error);
4703
+ return textResult(`Error: ${error instanceof Error ? error.message : String(error)}`);
4704
+ });
4705
+ }
4706
+ async function parseErrorBody(response) {
4707
+ return response.json().catch(() => ({ error: response.statusText }));
4708
+ }
4709
+ async function gatewayFetch(gateway, path6, options = {}, errorPrefix) {
4710
+ let response;
4711
+ try {
4712
+ response = await createGatewayClient({
4713
+ baseUrl: gateway.gatewayUrl,
4714
+ token: gateway.workerToken
4715
+ }).request(path6, {
4716
+ ...options,
4717
+ timeoutMs: options.timeoutMs ?? 6e4
4718
+ });
4719
+ } catch (error) {
4720
+ if (error instanceof Error && error.name === "TimeoutError") {
4721
+ logger.error(`${errorPrefix}: request timed out`);
4722
+ return { error: textResult(`Error: ${errorPrefix} (timed out)`) };
4723
+ }
4724
+ throw error;
4725
+ }
4726
+ if (!response.ok) {
4727
+ const body = await parseErrorBody(response);
4728
+ logger.error(`${errorPrefix}: ${response.status}`, body);
4729
+ return { error: textResult(`Error: ${body.error || errorPrefix}`) };
4730
+ }
4731
+ return { data: await response.json() };
4732
+ }
4733
+ async function postLinkButton(gateway, args) {
4734
+ const { error } = await gatewayFetch(gateway, "/internal/interactions/create", {
4735
+ method: "POST",
4736
+ body: JSON.stringify({
4737
+ interactionType: "link_button",
4738
+ url: args.url,
4739
+ label: args.label,
4740
+ linkType: args.linkType ?? "oauth",
4741
+ body: args.body
4742
+ })
4743
+ }, "Failed to post link button");
4744
+ if (error) {
4745
+ throw new Error(joinTextContent(error.content) || "Failed to post link button");
4746
+ }
4747
+ }
4748
+ function toToolResult(result) {
4749
+ return { content: result.content, details: {} };
4750
+ }
4751
+ function defineTool2(config) {
4752
+ return {
4753
+ name: config.name,
4754
+ label: config.name,
4755
+ description: config.description,
4756
+ parameters: config.parameters,
4757
+ execute: async (_toolCallId, args) => toToolResult(await config.run(args))
4758
+ };
4759
+ }
4760
+ function defineGatewayTool(config) {
4761
+ return defineTool2({
4762
+ ...config,
4763
+ description: (0, agent_tooling_1.getCustomToolDescription)(config.name)
4764
+ });
4765
+ }
4766
+ }
4767
+ });
4768
+
4504
4769
  // ../../node_modules/@sinclair/typebox/build/cjs/type/guard/value.js
4505
4770
  var require_value = __commonJS({
4506
4771
  "../../node_modules/@sinclair/typebox/build/cjs/type/guard/value.js"(exports2) {
@@ -16114,7 +16379,7 @@ var require_value5 = __commonJS({
16114
16379
  });
16115
16380
 
16116
16381
  // ../plugin-api/dist/index.js
16117
- var require_dist = __commonJS({
16382
+ var require_dist2 = __commonJS({
16118
16383
  "../plugin-api/dist/index.js"(exports2) {
16119
16384
  "use strict";
16120
16385
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -16144,135 +16409,6 @@ var require_dist = __commonJS({
16144
16409
  }
16145
16410
  });
16146
16411
 
16147
- // ../plugin-toolkit/dist/index.js
16148
- var require_dist2 = __commonJS({
16149
- "../plugin-toolkit/dist/index.js"(exports2) {
16150
- "use strict";
16151
- Object.defineProperty(exports2, "__esModule", { value: true });
16152
- exports2.toolLogger = void 0;
16153
- exports2.setToolLogger = setToolLogger;
16154
- exports2.createGatewayClient = createGatewayClient;
16155
- exports2.textResult = textResult;
16156
- exports2.jsonResult = jsonResult;
16157
- exports2.joinTextContent = joinTextContent;
16158
- exports2.withErrorHandling = withErrorHandling;
16159
- exports2.parseErrorBody = parseErrorBody;
16160
- exports2.gatewayFetch = gatewayFetch;
16161
- exports2.postLinkButton = postLinkButton;
16162
- exports2.toToolResult = toToolResult;
16163
- exports2.defineTool = defineTool2;
16164
- exports2.defineGatewayTool = defineGatewayTool;
16165
- var agent_tooling_1 = (init_agent_tooling(), __toCommonJS(agent_tooling_exports));
16166
- var logger = {
16167
- error: (message, ...args) => console.error(message, ...args),
16168
- warn: (message, ...args) => console.warn(message, ...args),
16169
- info: (message, ...args) => console.info(message, ...args),
16170
- debug: (message, ...args) => console.debug(message, ...args)
16171
- };
16172
- function setToolLogger(next) {
16173
- logger = next;
16174
- }
16175
- exports2.toolLogger = {
16176
- error: (message, ...args) => logger.error(message, ...args),
16177
- warn: (message, ...args) => logger.warn(message, ...args),
16178
- info: (message, ...args) => logger.info(message, ...args),
16179
- debug: (message, ...args) => logger.debug(message, ...args)
16180
- };
16181
- function createGatewayClient(config) {
16182
- const fetchFn = config.fetchFn ?? fetch;
16183
- return {
16184
- request(path6, init = {}) {
16185
- return fetchFn(`${config.baseUrl}${path6}`, {
16186
- method: init.method,
16187
- headers: {
16188
- Authorization: `Bearer ${config.token}`,
16189
- ...init.body !== void 0 ? { "Content-Type": "application/json" } : {},
16190
- ...init.headers
16191
- },
16192
- body: init.body,
16193
- signal: init.signal ?? (init.timeoutMs !== void 0 ? AbortSignal.timeout(init.timeoutMs) : void 0)
16194
- });
16195
- }
16196
- };
16197
- }
16198
- function textResult(text2) {
16199
- return { content: [{ type: "text", text: text2 }] };
16200
- }
16201
- function jsonResult(payload) {
16202
- return textResult(JSON.stringify(payload));
16203
- }
16204
- function joinTextContent(content) {
16205
- return (content ?? []).filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text).join("\n");
16206
- }
16207
- function withErrorHandling(label, fn2) {
16208
- return fn2().catch((error) => {
16209
- logger.error(`${label} error:`, error);
16210
- return textResult(`Error: ${error instanceof Error ? error.message : String(error)}`);
16211
- });
16212
- }
16213
- async function parseErrorBody(response) {
16214
- return response.json().catch(() => ({ error: response.statusText }));
16215
- }
16216
- async function gatewayFetch(gateway, path6, options = {}, errorPrefix) {
16217
- let response;
16218
- try {
16219
- response = await createGatewayClient({
16220
- baseUrl: gateway.gatewayUrl,
16221
- token: gateway.workerToken
16222
- }).request(path6, {
16223
- ...options,
16224
- timeoutMs: options.timeoutMs ?? 6e4
16225
- });
16226
- } catch (error) {
16227
- if (error instanceof Error && error.name === "TimeoutError") {
16228
- logger.error(`${errorPrefix}: request timed out`);
16229
- return { error: textResult(`Error: ${errorPrefix} (timed out)`) };
16230
- }
16231
- throw error;
16232
- }
16233
- if (!response.ok) {
16234
- const body = await parseErrorBody(response);
16235
- logger.error(`${errorPrefix}: ${response.status}`, body);
16236
- return { error: textResult(`Error: ${body.error || errorPrefix}`) };
16237
- }
16238
- return { data: await response.json() };
16239
- }
16240
- async function postLinkButton(gateway, args) {
16241
- const { error } = await gatewayFetch(gateway, "/internal/interactions/create", {
16242
- method: "POST",
16243
- body: JSON.stringify({
16244
- interactionType: "link_button",
16245
- url: args.url,
16246
- label: args.label,
16247
- linkType: args.linkType ?? "oauth",
16248
- body: args.body
16249
- })
16250
- }, "Failed to post link button");
16251
- if (error) {
16252
- throw new Error(joinTextContent(error.content) || "Failed to post link button");
16253
- }
16254
- }
16255
- function toToolResult(result) {
16256
- return { content: result.content, details: {} };
16257
- }
16258
- function defineTool2(config) {
16259
- return {
16260
- name: config.name,
16261
- label: config.name,
16262
- description: config.description,
16263
- parameters: config.parameters,
16264
- execute: async (_toolCallId, args) => toToolResult(await config.run(args))
16265
- };
16266
- }
16267
- function defineGatewayTool(config) {
16268
- return defineTool2({
16269
- ...config,
16270
- description: (0, agent_tooling_1.getCustomToolDescription)(config.name)
16271
- });
16272
- }
16273
- }
16274
- });
16275
-
16276
16412
  // ../plugin-conversations/dist/index.js
16277
16413
  var require_dist3 = __commonJS({
16278
16414
  "../plugin-conversations/dist/index.js"(exports2) {
@@ -16291,8 +16427,8 @@ var require_dist3 = __commonJS({
16291
16427
  exports2.createConversationTools = createConversationTools2;
16292
16428
  exports2.createConversationPlugin = createConversationPlugin;
16293
16429
  var agent_tooling_1 = (init_agent_tooling(), __toCommonJS(agent_tooling_exports));
16294
- var plugin_api_1 = require_dist();
16295
- var plugin_toolkit_1 = require_dist2();
16430
+ var plugin_api_1 = require_dist2();
16431
+ var plugin_toolkit_1 = require_dist();
16296
16432
  var typebox_1 = require_cjs();
16297
16433
  async function askUserQuestion(gateway, args, hooks) {
16298
16434
  return (0, plugin_toolkit_1.withErrorHandling)("ask_user", async () => {
@@ -16587,7 +16723,7 @@ var require_audio_provider_suggestions = __commonJS({
16587
16723
  Object.defineProperty(exports2, "__esModule", { value: true });
16588
16724
  exports2.normalizeAudioProviderSuggestions = normalizeAudioProviderSuggestions;
16589
16725
  exports2.fetchAudioProviderSuggestions = fetchAudioProviderSuggestions;
16590
- var plugin_toolkit_1 = require_dist2();
16726
+ var plugin_toolkit_1 = require_dist();
16591
16727
  var FALLBACK_PROVIDER_IDS = ["chatgpt"];
16592
16728
  var KNOWN_PROVIDER_LABELS = {
16593
16729
  chatgpt: "ChatGPT/OpenAI",
@@ -16691,7 +16827,7 @@ var require_multipart = __commonJS({
16691
16827
  Object.defineProperty(exports2, "__esModule", { value: true });
16692
16828
  exports2.uploadMultipart = uploadMultipart;
16693
16829
  exports2.uploadGeneratedFile = uploadGeneratedFile;
16694
- var plugin_toolkit_1 = require_dist2();
16830
+ var plugin_toolkit_1 = require_dist();
16695
16831
  var UPLOAD_TIMEOUT_MS = 3e5;
16696
16832
  async function uploadMultipart(gw2, options) {
16697
16833
  const form = new FormData();
@@ -16745,7 +16881,7 @@ var require_generation = __commonJS({
16745
16881
  Object.defineProperty(exports2, "__esModule", { value: true });
16746
16882
  exports2.generateImage = generateImage;
16747
16883
  exports2.generateAudio = generateAudio;
16748
- var plugin_toolkit_1 = require_dist2();
16884
+ var plugin_toolkit_1 = require_dist();
16749
16885
  var audio_provider_suggestions_1 = require_audio_provider_suggestions();
16750
16886
  var multipart_1 = require_multipart();
16751
16887
  async function generateAndUploadMedia(gw2, config) {
@@ -16905,7 +17041,7 @@ var require_file_port = __commonJS({
16905
17041
  exports2.maxUploadBytes = maxUploadBytes;
16906
17042
  exports2.contentTypeForName = contentTypeForName;
16907
17043
  exports2.uploadPortedFile = uploadPortedFile;
16908
- var plugin_toolkit_1 = require_dist2();
17044
+ var plugin_toolkit_1 = require_dist();
16909
17045
  var multipart_1 = require_multipart();
16910
17046
  function maxUploadBytes() {
16911
17047
  const env = globalThis.process?.env;
@@ -17005,8 +17141,8 @@ var require_tools = __commonJS({
17005
17141
  Object.defineProperty(exports2, "__esModule", { value: true });
17006
17142
  exports2.createMediaTools = createMediaTools2;
17007
17143
  exports2.createMediaPlugin = createMediaPlugin;
17008
- var plugin_api_1 = require_dist();
17009
- var plugin_toolkit_1 = require_dist2();
17144
+ var plugin_api_1 = require_dist2();
17145
+ var plugin_toolkit_1 = require_dist();
17010
17146
  var typebox_1 = require_cjs();
17011
17147
  var file_port_1 = require_file_port();
17012
17148
  var generation_1 = require_generation();
@@ -17146,7 +17282,7 @@ var require_agent_policy = __commonJS({
17146
17282
  description: "Post a message to one of your conversations. Pass a conversation handle (from list_conversations) to post to the channel, or a thread handle (returned by a previous send_message) to reply in that thread. This is how an automated/scheduled run speaks in its channel."
17147
17283
  },
17148
17284
  present_event: {
17149
- description: "Render an existing Lobu event in the current conversation through its declared json_template. Use the event id returned by knowledge.save; do not hand-author platform card JSON or action ids."
17285
+ description: "Present an existing Lobu event as a summary and Open event link in the current conversation. Custom interactions open in its React view. Use the event id returned by knowledge.save; do not hand-author platform card JSON or action ids."
17150
17286
  },
17151
17287
  schedule_followup: {
17152
17288
  description: "Schedule one durable future wake-up for yourself in the current conversation. The server fixes the agent and destination from the signed turn; provide a stable idempotency key so retries do not duplicate the wake-up."
@@ -18015,19 +18151,14 @@ var require_bash_command_parser = __commonJS({
18015
18151
  }
18016
18152
  });
18017
18153
 
18018
- // ../core/dist/tool-policy.js
18019
- var require_tool_policy = __commonJS({
18020
- "../core/dist/tool-policy.js"(exports2) {
18154
+ // ../core/dist/shell-safety.js
18155
+ var require_shell_safety = __commonJS({
18156
+ "../core/dist/shell-safety.js"(exports2) {
18021
18157
  "use strict";
18022
18158
  Object.defineProperty(exports2, "__esModule", { value: true });
18023
- exports2.DEFAULT_PACKAGE_MANAGER_DENY_PREFIXES = void 0;
18024
- exports2.normalizeToolList = normalizeToolList;
18025
- exports2.buildToolPolicy = buildToolPolicy;
18026
- exports2.isToolAllowedByPolicy = isToolAllowedByPolicy;
18027
18159
  exports2.isDirectPackageInstallCommand = isDirectPackageInstallCommand2;
18028
- exports2.enforceBashCommandPolicy = enforceBashCommandPolicy3;
18029
18160
  var bash_command_parser_1 = require_bash_command_parser();
18030
- exports2.DEFAULT_PACKAGE_MANAGER_DENY_PREFIXES = [
18161
+ var PACKAGE_MANAGER_DENY_PREFIXES = [
18031
18162
  "apt ",
18032
18163
  "apt-get ",
18033
18164
  "yum ",
@@ -18106,85 +18237,6 @@ var require_tool_policy = __commonJS({
18106
18237
  "poetry add ",
18107
18238
  "composer require "
18108
18239
  ];
18109
- function normalizeToolName(name) {
18110
- return name.trim().toLowerCase();
18111
- }
18112
- function normalizeToolList(value) {
18113
- if (!value) {
18114
- return [];
18115
- }
18116
- const rawList = Array.isArray(value) ? value : value.split(/[,\n]/);
18117
- return rawList.map((entry) => typeof entry === "string" ? entry.trim() : String(entry).trim()).filter((entry) => entry.length > 0);
18118
- }
18119
- function parseBashFilter(pattern) {
18120
- const match2 = pattern.match(/^Bash\(([^:]+):\*\)$/i);
18121
- const prefix = match2?.[1]?.trim();
18122
- return prefix || null;
18123
- }
18124
- function matchesToolPattern(toolName, pattern) {
18125
- const normalizedTool = normalizeToolName(toolName);
18126
- const normalizedPattern = pattern.trim();
18127
- const normalizedPatternLower = normalizedPattern.toLowerCase();
18128
- if (normalizedPattern === "*") {
18129
- return true;
18130
- }
18131
- if (normalizedPatternLower.endsWith("*")) {
18132
- const prefix = normalizedPatternLower.slice(0, -1);
18133
- return normalizedTool.startsWith(prefix);
18134
- }
18135
- return normalizedTool === normalizedPatternLower;
18136
- }
18137
- function buildToolPolicy(params) {
18138
- const allowedPatterns = normalizeToolList(params.allowedTools);
18139
- const deniedPatterns = normalizeToolList(params.disallowedTools);
18140
- const toolsConfig = params.toolsConfig;
18141
- const strictMode = toolsConfig?.strictMode === true;
18142
- const mergedAllowed = [
18143
- ...toolsConfig?.allowedTools ?? [],
18144
- ...allowedPatterns
18145
- ].map((p) => p.trim());
18146
- const mergedDenied = [
18147
- ...toolsConfig?.deniedTools ?? [],
18148
- ...deniedPatterns
18149
- ].map((p) => p.trim());
18150
- const bashAllowPrefixes = mergedAllowed.map((pattern) => parseBashFilter(pattern)).filter((prefix) => Boolean(prefix));
18151
- const bashDenyPrefixes = mergedDenied.map((pattern) => parseBashFilter(pattern)).filter((prefix) => Boolean(prefix));
18152
- const bashAllowAll = mergedAllowed.some((pattern) => matchesToolPattern("bash", pattern));
18153
- return {
18154
- toolsConfig,
18155
- allowedPatterns: mergedAllowed,
18156
- deniedPatterns: mergedDenied,
18157
- strictMode,
18158
- bashPolicy: {
18159
- allowAll: bashAllowAll,
18160
- allowPrefixes: bashAllowPrefixes,
18161
- denyPrefixes: [
18162
- ...exports2.DEFAULT_PACKAGE_MANAGER_DENY_PREFIXES,
18163
- ...bashDenyPrefixes
18164
- ]
18165
- }
18166
- };
18167
- }
18168
- function isToolAllowedByPolicy(toolName, policy) {
18169
- const normalizedName = normalizeToolName(toolName);
18170
- const { allowedPatterns, deniedPatterns, strictMode } = policy;
18171
- const explicitDenied = deniedPatterns.some((pattern) => !parseBashFilter(pattern) && matchesToolPattern(normalizedName, pattern));
18172
- if (explicitDenied) {
18173
- return false;
18174
- }
18175
- if (normalizedName === "bash") {
18176
- if (strictMode) {
18177
- const explicitlyAllowed = allowedPatterns.some((pattern) => matchesToolPattern(normalizedName, pattern));
18178
- const hasCommandAllowlist = policy.bashPolicy.allowPrefixes.length > 0;
18179
- return explicitlyAllowed || hasCommandAllowlist;
18180
- }
18181
- return true;
18182
- }
18183
- if (!strictMode) {
18184
- return true;
18185
- }
18186
- return allowedPatterns.some((pattern) => matchesToolPattern(normalizedName, pattern));
18187
- }
18188
18240
  var DIRECT_PACKAGE_INSTALL_PATTERNS = [
18189
18241
  /(^|[\s;|&()])(?:sudo\s+)?(?:apt|apt-get|yum|dnf|apk|pacman|zypper|brew)\s+(?:install|upgrade|add)\b/i,
18190
18242
  /(^|[\s;|&()])(?:sudo\s+)?(?:nix-shell|nix-env)\b/i,
@@ -18216,7 +18268,9 @@ var require_tool_policy = __commonJS({
18216
18268
  if (trimmed.length > MAX_SCANNED_COMMAND_LENGTH) {
18217
18269
  return true;
18218
18270
  }
18219
- const matches = (text2) => exports2.DEFAULT_PACKAGE_MANAGER_DENY_PREFIXES.some((prefix) => text2.startsWith(prefix.toLowerCase())) || DIRECT_PACKAGE_INSTALL_PATTERNS.some((pattern) => pattern.test(text2));
18271
+ if ((0, bash_command_parser_1.splitShellCommands)(command).some((segment) => PACKAGE_MANAGER_DENY_PREFIXES.some((prefix) => segment.toLowerCase().startsWith(prefix.toLowerCase()))))
18272
+ return true;
18273
+ const matches = (text2) => PACKAGE_MANAGER_DENY_PREFIXES.some((prefix) => text2.startsWith(prefix.toLowerCase())) || DIRECT_PACKAGE_INSTALL_PATTERNS.some((pattern) => pattern.test(text2));
18220
18274
  if ((0, bash_command_parser_1.matchesBeforeArgumentData)((0, bash_command_parser_1.blankQuotedSpans)(trimmed), matches)) {
18221
18275
  return true;
18222
18276
  }
@@ -18229,29 +18283,6 @@ var require_tool_policy = __commonJS({
18229
18283
  }
18230
18284
  return false;
18231
18285
  }
18232
- function enforceBashCommandPolicy3(command, policy) {
18233
- if (!command.trim()) {
18234
- return;
18235
- }
18236
- const segments = (0, bash_command_parser_1.splitShellCommands)(command);
18237
- if (segments.length === 0) {
18238
- return;
18239
- }
18240
- const hasAllowlist = !policy.allowAll && policy.allowPrefixes.length > 0;
18241
- for (const segment of segments) {
18242
- const normalizedSegment = segment.toLowerCase();
18243
- const denied = policy.denyPrefixes.some((prefix) => normalizedSegment.startsWith(prefix.toLowerCase()));
18244
- if (denied) {
18245
- throw new Error("Bash command denied by policy");
18246
- }
18247
- if (hasAllowlist) {
18248
- const allowed = policy.allowPrefixes.some((prefix) => normalizedSegment.startsWith(prefix.toLowerCase()));
18249
- if (!allowed) {
18250
- throw new Error("Bash command not allowed by policy");
18251
- }
18252
- }
18253
- }
18254
- }
18255
18286
  }
18256
18287
  });
18257
18288
 
@@ -35778,7 +35809,7 @@ var require_dist5 = __commonJS({
35778
35809
  "use strict";
35779
35810
  Object.defineProperty(exports2, "__esModule", { value: true });
35780
35811
  exports2.PluginHost = void 0;
35781
- var plugin_api_1 = require_dist();
35812
+ var plugin_api_1 = require_dist2();
35782
35813
  var PluginHost2 = class {
35783
35814
  plugins;
35784
35815
  constructor(plugins) {
@@ -35852,10 +35883,61 @@ var require_dist6 = __commonJS({
35852
35883
  "use strict";
35853
35884
  Object.defineProperty(exports2, "__esModule", { value: true });
35854
35885
  exports2.createMemoryPlugin = createMemoryPlugin2;
35855
- var plugin_api_1 = require_dist();
35856
- var plugin_toolkit_1 = require_dist2();
35886
+ var plugin_api_1 = require_dist2();
35887
+ var plugin_toolkit_1 = require_dist();
35857
35888
  var MEMORY_RECALL_LIMIT = 6;
35858
35889
  var MEMORY_TOOL_TIMEOUT_MS = 8e3;
35890
+ function withoutRecall(text2) {
35891
+ return text2.replace(/<lobu-memory\b[^>]*>[\s\S]*?(?:<\/lobu-memory\s*>|$)/gi, "").trim();
35892
+ }
35893
+ function quotedExcerpt(text2, budget) {
35894
+ const quoted = JSON.stringify(text2);
35895
+ if (quoted.length <= budget)
35896
+ return quoted;
35897
+ const marker = "\n[... excerpt truncated ...]\n";
35898
+ let keep = budget - JSON.stringify(marker).length - 2;
35899
+ while (keep > 0) {
35900
+ const head = Math.floor(keep / 3);
35901
+ const excerpt = JSON.stringify(text2.slice(0, head) + marker + text2.slice(-(keep - head)));
35902
+ if (excerpt.length <= budget)
35903
+ return excerpt;
35904
+ keep -= Math.max(1, Math.ceil((excerpt.length - budget) / 6));
35905
+ }
35906
+ return JSON.stringify(marker);
35907
+ }
35908
+ function recallQuery(prompt, messages) {
35909
+ if (prompt.length > 200 || !/^(?:(?:what|how) about (?:it|its|that|this|them|their|those|these)\b|(?:why|how|when|where) (?:is|was|does|did|will|would|can|should) (?:it|that|this|they|those|these)\b|(?:can you |please )?(?:explain|expand on|summarize) (?:that|this|it)[?.!]*$|(?:can you |please )?(?:draft|write|prepare|revise|update|fix) (?:it|that|this|them)(?:[?.!]*$| (?:using|with|based on|again|now|up)\b)|(?:what did we decide|go on|continue)[?.!]*$)/i.test(prompt))
35910
+ return prompt;
35911
+ const recent = messages.slice(-12);
35912
+ const current = lastMessage(recent, "user");
35913
+ if (current?.text === prompt && current.index === recent.length - 1)
35914
+ recent.pop();
35915
+ const user = lastMessage(recent, "user");
35916
+ if (!user)
35917
+ return prompt;
35918
+ const assistant = lastMessage(recent, "assistant");
35919
+ const context = [`user: ${quotedExcerpt(user.text, 700)}`];
35920
+ if (assistant && assistant.index > user.index) {
35921
+ context.push(`assistant (not user assertions): ${quotedExcerpt(assistant.text, 700)}`);
35922
+ }
35923
+ return `${prompt}
35924
+ Recent conversation excerpts (context only):
35925
+ ${context.join("\n")}`;
35926
+ }
35927
+ function resultText(result) {
35928
+ const text2 = (0, plugin_toolkit_1.joinTextContent)(result.content).trim();
35929
+ if (result.isError === true || result.isError === void 0 && /^error:/i.test(text2)) {
35930
+ throw new Error(text2 || "Memory tool failed");
35931
+ }
35932
+ return text2;
35933
+ }
35934
+ function checkReceipt(result) {
35935
+ const text2 = resultText(result);
35936
+ const receipt = result.structuredContent !== void 0 ? result.structuredContent : JSON.parse(text2);
35937
+ if (!receipt || typeof receipt !== "object" || !Number.isSafeInteger(receipt.id) || receipt.id <= 0 || typeof receipt.durable_at !== "string" || !Number.isFinite(Date.parse(receipt.durable_at))) {
35938
+ throw new Error("save_memory returned an invalid durable receipt");
35939
+ }
35940
+ }
35859
35941
  function messageText2(message) {
35860
35942
  if (typeof message !== "object" || message === null)
35861
35943
  return "";
@@ -35866,20 +35948,21 @@ var require_dist6 = __commonJS({
35866
35948
  return "";
35867
35949
  return content.filter((part) => typeof part === "object" && part !== null && part.type === "text" && typeof part.text === "string").map((part) => part.text).join("\n");
35868
35950
  }
35869
- function lastMessage(messages, role, before = messages.length) {
35870
- for (let index2 = Math.min(before, messages.length) - 1; index2 >= 0; index2--) {
35951
+ function lastMessage(messages, role) {
35952
+ for (let index2 = messages.length - 1; index2 >= 0; index2--) {
35871
35953
  const message = messages[index2];
35872
35954
  if (typeof message !== "object" || message === null || message.role !== role) {
35873
35955
  continue;
35874
35956
  }
35875
- const text2 = messageText2(message).trim();
35957
+ const text2 = withoutRecall(messageText2(message));
35876
35958
  if (text2)
35877
35959
  return { index: index2, text: text2 };
35960
+ if (role === "user")
35961
+ return null;
35878
35962
  }
35879
35963
  return null;
35880
35964
  }
35881
35965
  function createMemoryPlugin2(gateway, invokeTool) {
35882
- let promptForCapture = "";
35883
35966
  let capture = null;
35884
35967
  const plugin = (0, plugin_api_1.defineLobuPlugin)({
35885
35968
  manifest: {
@@ -35890,26 +35973,27 @@ var require_dist6 = __commonJS({
35890
35973
  },
35891
35974
  hooks: {
35892
35975
  beforeAgentStart: async (event, context) => {
35893
- const query = event.prompt.trim();
35894
- promptForCapture = query;
35895
- if (!query || /heartbeat|question:q_/i.test(query))
35976
+ const prompt = withoutRecall(event.prompt);
35977
+ if (!prompt)
35896
35978
  return;
35897
- const result = await invokeTool(gateway, "lobu", "search_memory", {
35898
- query,
35899
- include_content: true,
35900
- content_limit: MEMORY_RECALL_LIMIT,
35901
- include_connections: false,
35902
- limit: 3
35903
- }, { timeoutMs: MEMORY_TOOL_TIMEOUT_MS });
35904
- const recalled = (0, plugin_toolkit_1.joinTextContent)(result.content).trim();
35905
- if (!recalled || /^error:/i.test(recalled)) {
35906
- if (recalled) {
35907
- context.logger.warn("Plugin memory recall skipped", {
35908
- error: recalled
35909
- });
35910
- }
35979
+ let recalled;
35980
+ try {
35981
+ const result = await invokeTool(gateway, "lobu", "search_memory", {
35982
+ query: recallQuery(prompt, event.messages),
35983
+ include_content: true,
35984
+ content_limit: MEMORY_RECALL_LIMIT,
35985
+ include_connections: false,
35986
+ limit: 3
35987
+ }, { timeoutMs: MEMORY_TOOL_TIMEOUT_MS });
35988
+ recalled = resultText(result);
35989
+ } catch (error) {
35990
+ context.logger.warn("Plugin memory recall skipped", {
35991
+ error: error instanceof Error ? error.message : String(error)
35992
+ });
35911
35993
  return;
35912
35994
  }
35995
+ if (!recalled)
35996
+ return;
35913
35997
  return {
35914
35998
  prependContext: `<lobu-memory>
35915
35999
  Use these long-term memories only when directly relevant to the user's request.
@@ -35922,21 +36006,30 @@ ${recalled}
35922
36006
  agentEnd: (event, context) => {
35923
36007
  if (event.error)
35924
36008
  return;
36009
+ const user = lastMessage(event.messages, "user");
35925
36010
  const assistant = lastMessage(event.messages, "assistant");
35926
- if (!assistant)
35927
- return;
35928
- const user = lastMessage(event.messages, "user", assistant.index);
35929
- if (!user)
35930
- return;
35931
- const userText = promptForCapture && user.text.endsWith(promptForCapture) ? promptForCapture : user.text.replace(/<lobu-memory>[\s\S]*?<\/lobu-memory>/gi, "").trim();
35932
- const combined = `User: ${userText}
35933
- Assistant: ${assistant.text}`;
35934
- if (combined.length < 16)
36011
+ if (!user || !assistant || assistant.index <= user.index)
35935
36012
  return;
36013
+ const content = [
36014
+ "Conversation excerpts, not a full transcript. Use the original conversation transcript as primary evidence.",
36015
+ `User (verbatim excerpt): ${quotedExcerpt(user.text, 800)}`,
36016
+ `Assistant (generated response, not user assertions): ${quotedExcerpt(assistant.text, 800)}`
36017
+ ].join("\n");
35936
36018
  capture = invokeTool(gateway, "lobu", "save_memory", {
35937
- content: combined.slice(0, 2e3),
36019
+ content,
36020
+ // Existing extensible payload, with only references the host supplied.
36021
+ payload_data: {
36022
+ ...context.agentId ? { agent_id: context.agentId } : {},
36023
+ ...context.conversationId ? { conversation_id: context.conversationId } : {},
36024
+ ...context.actorId ? { actor_id: context.actorId } : {},
36025
+ ...context.runId > 0 ? { run_id: context.runId } : {},
36026
+ ...context.messageId ? { message_id: context.messageId } : {}
36027
+ },
35938
36028
  semantic_type: "observation"
35939
- }, { timeoutMs: MEMORY_TOOL_TIMEOUT_MS }).then(() => context.logger.info("Captured conversation observation")).catch((error) => context.logger.warn("Plugin memory capture failed", {
36029
+ }, { timeoutMs: MEMORY_TOOL_TIMEOUT_MS }).then((result) => {
36030
+ checkReceipt(result);
36031
+ context.logger.info("Captured conversation observation");
36032
+ }).catch((error) => context.logger.warn("Plugin memory capture failed", {
35940
36033
  error: error instanceof Error ? error.message : String(error)
35941
36034
  }));
35942
36035
  }
@@ -36801,6 +36894,7 @@ __export(guest_entry_exports, {
36801
36894
  runAgentTurn: () => runAgentTurn
36802
36895
  });
36803
36896
  module.exports = __toCommonJS(guest_entry_exports);
36897
+ var import_plugin_toolkit = __toESM(require_dist(), 1);
36804
36898
 
36805
36899
  // dist/agent-turn/gateway-tools.js
36806
36900
  var import_plugin_conversations = __toESM(require_dist3(), 1);
@@ -43724,7 +43818,7 @@ function createFindTool(cwd, options) {
43724
43818
  }
43725
43819
 
43726
43820
  // dist/agent-turn/workspace.js
43727
- var import_tool_policy = __toESM(require_tool_policy(), 1);
43821
+ var import_shell_safety = __toESM(require_shell_safety(), 1);
43728
43822
 
43729
43823
  // ../../node_modules/just-bash/dist/bundle/browser.js
43730
43824
  var import_sprintf_js = __toESM(require_sprintf(), 1);
@@ -79509,7 +79603,7 @@ Command exited with code 1`;
79509
79603
  Command exited with code ${exitCode}`;
79510
79604
  return rendered;
79511
79605
  }
79512
- function createWorkspace(names, bashPolicy, remote) {
79606
+ function createWorkspace(names, remote) {
79513
79607
  const fs2 = new Gn();
79514
79608
  const ready = fs2.mkdir(WORKSPACE_ROOT, { recursive: true });
79515
79609
  const shell = new rf({ fs: fs2, cwd: WORKSPACE_ROOT, executionLimits: BASH_LIMITS });
@@ -79651,9 +79745,7 @@ function createWorkspace(names, bashPolicy, remote) {
79651
79745
  execute: async (_id, args) => {
79652
79746
  const command = requireString(args, "command");
79653
79747
  const timeout = optionalNumber(args, "timeout");
79654
- if (bashPolicy)
79655
- (0, import_tool_policy.enforceBashCommandPolicy)(command, bashPolicy);
79656
- if ((0, import_tool_policy.isDirectPackageInstallCommand)(command)) {
79748
+ if ((0, import_shell_safety.isDirectPackageInstallCommand)(command)) {
79657
79749
  throw new Error(remote ? "DIRECT PACKAGE INSTALL BLOCKED. Use the sandbox packages configured by an admin." : "DIRECT PACKAGE INSTALL BLOCKED. This workspace has no package manager and no network; use your other tools to reach data instead.");
79658
79750
  }
79659
79751
  if (remote)
@@ -79850,18 +79942,7 @@ function createTurnMediaTools(allowed, args) {
79850
79942
  var import_plugin_host = __toESM(require_dist5(), 1);
79851
79943
  var import_plugin_memory = __toESM(require_dist6(), 1);
79852
79944
  function createTurnMemory(context) {
79853
- const invoke = async (_gateway, _mcpId, toolName, args, options) => {
79854
- try {
79855
- const text2 = await context.callTool(context.mcpId, toolName, args, options);
79856
- return { content: [{ type: "text", text: text2 }] };
79857
- } catch (error) {
79858
- return {
79859
- content: [
79860
- { type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }
79861
- ]
79862
- };
79863
- }
79864
- };
79945
+ const invoke = (_gateway, _mcpId, toolName, args, options) => context.callTool(context.mcpId, toolName, args, options);
79865
79946
  const plugin = (0, import_plugin_memory.createMemoryPlugin)({
79866
79947
  // The plugin passes these straight back to the invoker, which ignores
79867
79948
  // them: this lane addresses the MCP route itself. They are filled in
@@ -79921,7 +80002,6 @@ function createTurnMemoryHooks(context) {
79921
80002
 
79922
80003
  // dist/agent-turn/guest-entry.js
79923
80004
  var import_memory_flush = __toESM(require_memory_flush(), 1);
79924
- var import_tool_policy2 = __toESM(require_tool_policy(), 1);
79925
80005
  var import_tool_trace_summary = __toESM(require_tool_trace_summary(), 1);
79926
80006
 
79927
80007
  // ../../node_modules/@mariozechner/pi-ai/dist/api-registry.js
@@ -132266,7 +132346,7 @@ var TOOL_EVENT_OUTPUT_CHARS = 2e3;
132266
132346
  function joinText(content) {
132267
132347
  return (content ?? []).filter((part) => part && part.type === "text" && typeof part.text === "string").map((part) => part.text).join("\n");
132268
132348
  }
132269
- async function callMcpTool(gatewayUrl, credential, tool, args, timeoutMs = TOOL_CALL_TIMEOUT_MS) {
132349
+ async function callMcpTool(gatewayUrl, credential, tool, args, timeoutMs = TOOL_CALL_TIMEOUT_MS, supportsImages = true, imageBudget) {
132270
132350
  const url = `${gatewayUrl}/mcp/${encodeURIComponent(tool.mcpId)}/tools/${encodeURIComponent(tool.name)}`;
132271
132351
  let response;
132272
132352
  try {
@@ -132276,8 +132356,9 @@ async function callMcpTool(gatewayUrl, credential, tool, args, timeoutMs = TOOL_
132276
132356
  Authorization: `Bearer ${credential}`,
132277
132357
  "Content-Type": "application/json",
132278
132358
  // A retrieval result is summarised into the tool trace from its
132279
- // structured body; the gateway renders markdown unless asked.
132280
- ...(0, import_tool_trace_summary.isRetrievalTool)(tool.name) ? { "x-mcp-format": "json" } : {}
132359
+ // structured body; capture validates the save receipt. The gateway
132360
+ // renders markdown unless asked.
132361
+ ...(0, import_tool_trace_summary.isRetrievalTool)(tool.name) || tool.name === "save_memory" ? { "x-mcp-format": "json" } : {}
132281
132362
  },
132282
132363
  body: JSON.stringify(args ?? {}),
132283
132364
  signal: AbortSignal.timeout(timeoutMs)
@@ -132295,17 +132376,21 @@ async function callMcpTool(gatewayUrl, credential, tool, args, timeoutMs = TOOL_
132295
132376
  throw new Error(`${tool.name} returned a non-JSON response (status ${response.status}): ${error instanceof Error ? error.message : String(error)}`);
132296
132377
  }
132297
132378
  const text2 = joinText(reply.content);
132298
- if (!response.ok || reply.isError) {
132379
+ if (!response.ok) {
132299
132380
  throw new Error(reply.error || text2 || `${tool.name} failed (${response.status})`);
132300
132381
  }
132301
- return text2 || `${tool.name} completed.`;
132382
+ return {
132383
+ ...reply,
132384
+ ...(0, import_plugin_toolkit.mcpToolResult)(reply.isError === true ? reply.content?.filter((part) => part?.type === "text") : reply.content, reply.error || "", supportsImages, imageBudget)
132385
+ };
132302
132386
  }
132303
132387
  function buildTools(input, credential, onAskUserPosted, onInBandReplyDelivered, emit, runtimeExec) {
132388
+ const imageBudget = (0, import_plugin_toolkit.toolImageBudget)((input.images ?? []).map((image) => ({ type: "image", data: image.data })));
132304
132389
  const tools = input.tools;
132305
132390
  if (!tools)
132306
- return { tools: [], workspace: null, canReadFiles: false };
132391
+ return { tools: [], workspace: null, canReadFiles: false, imageBudget };
132307
132392
  const remote = tools.remoteRuntime && runtimeExec ? { exec: runtimeExec } : void 0;
132308
- const workspace = tools.builtin && tools.builtin.length > 0 ? createWorkspace(tools.builtin, tools.bashPolicy, remote) : null;
132393
+ const workspace = tools.builtin && tools.builtin.length > 0 ? createWorkspace(tools.builtin, remote) : null;
132309
132394
  const gateway = tools.gateway && tools.gateway.length > 0 && tools.conversation ? createGatewayTools(tools.gateway, {
132310
132395
  gatewayUrl: tools.gatewayUrl,
132311
132396
  credential,
@@ -132328,25 +132413,24 @@ function buildTools(input, credential, onAskUserPosted, onInBandReplyDelivered,
132328
132413
  description: tool.description,
132329
132414
  // A plain JSON schema: pi-ai validates arguments against it as-is.
132330
132415
  parameters: tool.inputSchema,
132331
- execute: async (_toolCallId, args) => ({
132332
- content: [{ type: "text", text: await callMcpTool(tools.gatewayUrl, credential, tool, args) }],
132333
- details: {}
132334
- })
132335
- }));
132336
- let bashCanRead = false;
132337
- if ((tools.builtin ?? []).includes("bash") && !tools.remoteRuntime) {
132338
- try {
132339
- if (tools.bashPolicy)
132340
- (0, import_tool_policy2.enforceBashCommandPolicy)("cat input/attachment", tools.bashPolicy);
132341
- bashCanRead = true;
132342
- } catch {
132416
+ execute: async (_toolCallId, args) => {
132417
+ const result = await callMcpTool(tools.gatewayUrl, credential, tool, args, TOOL_CALL_TIMEOUT_MS, input.provider.input?.includes("image") === true, imageBudget);
132418
+ const text2 = joinText(result.content);
132419
+ if (result.isError === true)
132420
+ throw new Error(String(result.error || text2 || `${tool.name} failed`));
132421
+ return {
132422
+ content: text2 || result.content.some((part) => part.type === "image") ? result.content : [{ type: "text", text: `${tool.name} completed.` }],
132423
+ details: {}
132424
+ };
132343
132425
  }
132344
- }
132426
+ }));
132427
+ const bashCanRead = (tools.builtin ?? []).includes("bash") && !tools.remoteRuntime;
132345
132428
  const canReadFiles = workspace !== null && ((tools.builtin ?? []).includes("read") || bashCanRead);
132346
132429
  return {
132347
132430
  tools: [...mcp, ...gateway, ...media, ...workspace?.tools ?? []],
132348
132431
  workspace,
132349
- canReadFiles
132432
+ canReadFiles,
132433
+ imageBudget
132350
132434
  };
132351
132435
  }
132352
132436
  var guestLogger = {
@@ -132434,7 +132518,7 @@ async function runAgentTurn(input, emit, takeSteering = () => [], runtimeExec) {
132434
132518
  agentId: input.memory.agentId,
132435
132519
  conversationId: input.tools.conversation?.conversationId ?? "",
132436
132520
  mcpId: input.memory.mcpId,
132437
- callTool: (mcpId, toolName, args, options) => callMcpTool(input.tools.gatewayUrl, credential, { mcpId, name: toolName, description: "", inputSchema: {} }, args, options?.timeoutMs),
132521
+ callTool: (mcpId, toolName, args, options) => callMcpTool(input.tools.gatewayUrl, credential, { mcpId, name: toolName, description: "", inputSchema: {} }, args, options?.timeoutMs).then((result) => ({ ...result, content: [{ type: "text", text: joinText(result.content) }] })),
132438
132522
  logger: guestLogger
132439
132523
  }) : null;
132440
132524
  let toolCalls = 0;
@@ -132480,6 +132564,7 @@ async function runAgentTurn(input, emit, takeSteering = () => [], runtimeExec) {
132480
132564
  const text2 = messageText(message);
132481
132565
  return text2 === void 0 ? void 0 : messageContext.get(text2);
132482
132566
  });
132567
+ built.imageBudget.bytes += (0, import_plugin_toolkit.toolImageBudget)(session.sessionManager.getEntries().flatMap((entry) => entry.type === "message" && "content" in entry.message && Array.isArray(entry.message.content) ? entry.message.content : [])).bytes;
132483
132568
  session.subscribe((event) => {
132484
132569
  if (event.type === "compaction_end" && event.errorMessage)
132485
132570
  console.warn(event.errorMessage);
@@ -132670,14 +132755,15 @@ ${flush.prompt}`);
132670
132755
  }
132671
132756
  }
132672
132757
  await promptNativeSession(session, input.userMessage, input.images);
132673
- const ended = guardStopped ? null : agent.state.errorMessage;
132758
+ settleAnswer();
132759
+ const finalText = ownerAnswer ?? ownerText;
132760
+ const ended = (guardStopped ? null : agent.state.errorMessage) || (!finalText.trim() && toolsUsed.size === 0 && steeredToolsUsed.size === 0 ? "The model returned no response. Please try again." : null);
132674
132761
  if (memory) {
132675
132762
  const messages = session.sessionManager.getBranch().flatMap((entry) => entry.type === "message" ? [entry.message] : []);
132676
132763
  await memory.capture(messages, ended ?? void 0);
132677
132764
  }
132678
132765
  if (ended)
132679
132766
  throw new Error(ended);
132680
- settleAnswer();
132681
132767
  return {
132682
132768
  // The answer is the last assistant message WITH TEXT after each user
132683
132769
  // message, not the accumulated stream: a model that narrates before a
@@ -132700,7 +132786,7 @@ ${flush.prompt}`);
132700
132786
  // aborted mid-answer still owes the user what it managed to say. The
132701
132787
  // fallback is the owner's only: a steered input without its own settled
132702
132788
  // answer fails below rather than borrowing a sibling's text.
132703
- text: ownerAnswer ?? ownerText,
132789
+ text: finalText,
132704
132790
  stopReason,
132705
132791
  usage,
132706
132792
  sessionJsonl: nativeSessionJsonl(session),