@lobu/runtime-device 22.0.0 → 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 (77) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +3 -3
  3. package/npm-shrinkwrap.json +15 -15
  4. package/package.json +1 -1
  5. package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +1 -1
  6. package/vendor/cli/dist/connectors/README.md +14 -1
  7. package/vendor/cli/dist/connectors/google_gmail.ts +1 -0
  8. package/vendor/cli/dist/connectors/jira-helpers.ts +313 -0
  9. package/vendor/cli/dist/connectors/jira.ts +29 -221
  10. package/vendor/cli/dist/connectors/linkedin-browser-script.ts +13 -0
  11. package/vendor/cli/dist/connectors/linkedin-draft-page.js +104 -0
  12. package/vendor/cli/dist/connectors/linkedin-drafts.ts +73 -0
  13. package/vendor/cli/dist/connectors/linkedin-identity.ts +32 -0
  14. package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +1185 -0
  15. package/vendor/cli/dist/connectors/linkedin-inbox.ts +156 -0
  16. package/vendor/cli/dist/connectors/linkedin-like.ts +114 -0
  17. package/vendor/cli/dist/connectors/linkedin-takeout.ts +577 -0
  18. package/vendor/cli/dist/connectors/linkedin.ts +3998 -0
  19. package/vendor/cli/dist/connectors/takeout-utils.ts +240 -0
  20. package/vendor/cli/dist/connectors/tiktok-inbox-page.js +9 -9
  21. package/vendor/cli/dist/connectors/tiktok-web-page.js +21 -15
  22. package/vendor/cli/dist/connectors/tiktok_web.ts +63 -30
  23. package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +64 -564
  24. package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +30 -444
  25. package/vendor/cli/dist/connectors/whatsapp-web-identity.ts +20 -6
  26. package/vendor/cli/dist/connectors/whatsapp_web.ts +45 -645
  27. package/vendor/cli/dist/connectors/x-dm-adapter.js +556 -0
  28. package/vendor/cli/dist/connectors/x-identity.ts +31 -2
  29. package/vendor/cli/dist/connectors/x.ts +266 -120
  30. package/vendor/cli/dist/runtime-components.json +4 -4
  31. package/vendor/cli/dist/templates/AGENTS.md.tmpl +2 -2
  32. package/vendor/cli/package.json +1 -1
  33. package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
  34. package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
  35. package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
  36. package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
  37. package/vendor/connector-sdk/dist/connector-types.d.ts +10 -0
  38. package/vendor/connector-sdk/dist/index.d.ts +3 -0
  39. package/vendor/connector-sdk/dist/index.js +2 -0
  40. package/vendor/connector-sdk/package.json +9 -1
  41. package/vendor/connector-worker/dist/agent-turn/guest-entry.js +15 -6
  42. package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +288 -148
  43. package/vendor/connector-worker/dist/daemon/automation.d.ts +4 -11
  44. package/vendor/connector-worker/dist/daemon/automation.js +6 -6
  45. package/vendor/connector-worker/dist/daemon/client.d.ts +2 -4
  46. package/vendor/connector-worker/dist/daemon/client.js +0 -3
  47. package/vendor/connector-worker/dist/daemon/executor.js +0 -3
  48. package/vendor/connector-worker/dist/daemon/mac-device-daemon.d.ts +4 -3
  49. package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +4 -10
  50. package/vendor/connector-worker/dist/daemon/native-bridge/executor.js +27 -25
  51. package/vendor/connector-worker/dist/daemon/start.js +3 -15
  52. package/vendor/connector-worker/dist/daemon/terminal-failure.js +0 -11
  53. package/vendor/connector-worker/dist/daemon/worker-id.d.ts +17 -0
  54. package/vendor/connector-worker/dist/daemon/worker-id.js +22 -0
  55. package/vendor/connector-worker/dist/mac-device-daemon.js +14 -26
  56. package/vendor/connector-worker/package.json +1 -1
  57. package/vendor/core/dist/capabilities.d.ts +1 -1
  58. package/vendor/core/dist/capabilities.js +0 -1
  59. package/vendor/core/dist/connector-query-errors.d.ts +32 -0
  60. package/vendor/core/dist/connector-query-errors.js +41 -1
  61. package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
  62. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
  63. package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
  64. package/vendor/core/dist/contracts/worker/protocol.d.ts +8 -131
  65. package/vendor/core/dist/contracts/worker/protocol.js +9 -61
  66. package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
  67. package/vendor/core/dist/device-pin-tombstones.js +57 -0
  68. package/vendor/core/dist/index.d.ts +2 -1
  69. package/vendor/core/dist/index.js +1 -0
  70. package/vendor/core/dist/logger.js +10 -25
  71. package/vendor/core/dist/utils/diagnostic-scrubber.js +258 -21
  72. package/vendor/core/dist/worker/wire.d.ts +0 -10
  73. package/vendor/core/package.json +6 -6
  74. package/vendor/connector-worker/dist/daemon/device-chat.d.ts +0 -9
  75. package/vendor/connector-worker/dist/daemon/device-chat.js +0 -61
  76. package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
  77. package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
@@ -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();
@@ -35673,7 +35809,7 @@ var require_dist5 = __commonJS({
35673
35809
  "use strict";
35674
35810
  Object.defineProperty(exports2, "__esModule", { value: true });
35675
35811
  exports2.PluginHost = void 0;
35676
- var plugin_api_1 = require_dist();
35812
+ var plugin_api_1 = require_dist2();
35677
35813
  var PluginHost2 = class {
35678
35814
  plugins;
35679
35815
  constructor(plugins) {
@@ -35747,8 +35883,8 @@ var require_dist6 = __commonJS({
35747
35883
  "use strict";
35748
35884
  Object.defineProperty(exports2, "__esModule", { value: true });
35749
35885
  exports2.createMemoryPlugin = createMemoryPlugin2;
35750
- var plugin_api_1 = require_dist();
35751
- var plugin_toolkit_1 = require_dist2();
35886
+ var plugin_api_1 = require_dist2();
35887
+ var plugin_toolkit_1 = require_dist();
35752
35888
  var MEMORY_RECALL_LIMIT = 6;
35753
35889
  var MEMORY_TOOL_TIMEOUT_MS = 8e3;
35754
35890
  function withoutRecall(text2) {
@@ -36758,6 +36894,7 @@ __export(guest_entry_exports, {
36758
36894
  runAgentTurn: () => runAgentTurn
36759
36895
  });
36760
36896
  module.exports = __toCommonJS(guest_entry_exports);
36897
+ var import_plugin_toolkit = __toESM(require_dist(), 1);
36761
36898
 
36762
36899
  // dist/agent-turn/gateway-tools.js
36763
36900
  var import_plugin_conversations = __toESM(require_dist3(), 1);
@@ -132209,7 +132346,7 @@ var TOOL_EVENT_OUTPUT_CHARS = 2e3;
132209
132346
  function joinText(content) {
132210
132347
  return (content ?? []).filter((part) => part && part.type === "text" && typeof part.text === "string").map((part) => part.text).join("\n");
132211
132348
  }
132212
- 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) {
132213
132350
  const url = `${gatewayUrl}/mcp/${encodeURIComponent(tool.mcpId)}/tools/${encodeURIComponent(tool.name)}`;
132214
132351
  let response;
132215
132352
  try {
@@ -132244,13 +132381,14 @@ async function callMcpTool(gatewayUrl, credential, tool, args, timeoutMs = TOOL_
132244
132381
  }
132245
132382
  return {
132246
132383
  ...reply,
132247
- content: [{ type: "text", text: text2 || reply.error || "" }]
132384
+ ...(0, import_plugin_toolkit.mcpToolResult)(reply.isError === true ? reply.content?.filter((part) => part?.type === "text") : reply.content, reply.error || "", supportsImages, imageBudget)
132248
132385
  };
132249
132386
  }
132250
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 })));
132251
132389
  const tools = input.tools;
132252
132390
  if (!tools)
132253
- return { tools: [], workspace: null, canReadFiles: false };
132391
+ return { tools: [], workspace: null, canReadFiles: false, imageBudget };
132254
132392
  const remote = tools.remoteRuntime && runtimeExec ? { exec: runtimeExec } : void 0;
132255
132393
  const workspace = tools.builtin && tools.builtin.length > 0 ? createWorkspace(tools.builtin, remote) : null;
132256
132394
  const gateway = tools.gateway && tools.gateway.length > 0 && tools.conversation ? createGatewayTools(tools.gateway, {
@@ -132276,12 +132414,12 @@ function buildTools(input, credential, onAskUserPosted, onInBandReplyDelivered,
132276
132414
  // A plain JSON schema: pi-ai validates arguments against it as-is.
132277
132415
  parameters: tool.inputSchema,
132278
132416
  execute: async (_toolCallId, args) => {
132279
- const result = await callMcpTool(tools.gatewayUrl, credential, tool, args);
132417
+ const result = await callMcpTool(tools.gatewayUrl, credential, tool, args, TOOL_CALL_TIMEOUT_MS, input.provider.input?.includes("image") === true, imageBudget);
132280
132418
  const text2 = joinText(result.content);
132281
132419
  if (result.isError === true)
132282
132420
  throw new Error(String(result.error || text2 || `${tool.name} failed`));
132283
132421
  return {
132284
- content: [{ type: "text", text: text2 || `${tool.name} completed.` }],
132422
+ content: text2 || result.content.some((part) => part.type === "image") ? result.content : [{ type: "text", text: `${tool.name} completed.` }],
132285
132423
  details: {}
132286
132424
  };
132287
132425
  }
@@ -132291,7 +132429,8 @@ function buildTools(input, credential, onAskUserPosted, onInBandReplyDelivered,
132291
132429
  return {
132292
132430
  tools: [...mcp, ...gateway, ...media, ...workspace?.tools ?? []],
132293
132431
  workspace,
132294
- canReadFiles
132432
+ canReadFiles,
132433
+ imageBudget
132295
132434
  };
132296
132435
  }
132297
132436
  var guestLogger = {
@@ -132379,7 +132518,7 @@ async function runAgentTurn(input, emit, takeSteering = () => [], runtimeExec) {
132379
132518
  agentId: input.memory.agentId,
132380
132519
  conversationId: input.tools.conversation?.conversationId ?? "",
132381
132520
  mcpId: input.memory.mcpId,
132382
- 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) }] })),
132383
132522
  logger: guestLogger
132384
132523
  }) : null;
132385
132524
  let toolCalls = 0;
@@ -132425,6 +132564,7 @@ async function runAgentTurn(input, emit, takeSteering = () => [], runtimeExec) {
132425
132564
  const text2 = messageText(message);
132426
132565
  return text2 === void 0 ? void 0 : messageContext.get(text2);
132427
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;
132428
132568
  session.subscribe((event) => {
132429
132569
  if (event.type === "compaction_end" && event.errorMessage)
132430
132570
  console.warn(event.errorMessage);
@@ -67,13 +67,6 @@ export interface AutomationExecutorConfig {
67
67
  /** Maintained ACP entrypoints keyed by the local agent kind they drive. */
68
68
  acpAdapters?: AutomationAcpAdapters;
69
69
  }
70
- /** Shared liveness/cancellation control for every device-local agent run. */
71
- export declare function monitorDeviceAgentRun(client: ExecutorClient, runId: number, cfg: AutomationExecutorConfig, label: string): {
72
- abortController: AbortController;
73
- terminalSignal: AbortSignal;
74
- shutdownRequested: () => boolean;
75
- stop: () => void;
76
- };
77
70
  /** Local-CLI run result, mirrored from the Mac app's `ExecutorResult`. */
78
71
  export interface ExecutorResult {
79
72
  output: string;
@@ -100,10 +93,10 @@ export interface DeviceAgentRunAccess {
100
93
  env: Record<string, string>;
101
94
  }
102
95
  /**
103
- * Resolve what credential the spawned CLI runs with — the boundary shared by
104
- * Automation and device-chat CLIs. When the poll envelope carries a per-run
105
- * `agent_session`, the CLI authenticates as the run's assigned agent for
106
- * exactly this run: the session token goes into the MCP wiring AND into
96
+ * Resolve what credential the spawned Automation CLI runs with. When the poll
97
+ * envelope carries a per-run `agent_session`, the CLI authenticates as the
98
+ * run's assigned agent for exactly this run: the session token goes into the
99
+ * MCP wiring AND into
107
100
  * LOBU_API_TOKEN/LOBU_MEMORY_URL, which `lobu memory` prefers
108
101
  * over the device's ambient CLI session — so an unattended run never acts as
109
102
  * the human user or the daemon. Without a session (older server, or a run with
@@ -36,8 +36,8 @@ import { WorkerDecodeError, WorkerHttpError } from './client.js';
36
36
  import { log } from './log.js';
37
37
  import { attachedInteractiveSession, handoffToInteractiveSession, } from './interactive-session.js';
38
38
  import { AcpTranscript, runAcpTurn, } from './automation-acp.js';
39
- /** Shared liveness/cancellation control for every device-local agent run. */
40
- export function monitorDeviceAgentRun(client, runId, cfg, label) {
39
+ /** Liveness and cancellation control for a device Automation run. */
40
+ function monitorDeviceAgentRun(client, runId, cfg, label) {
41
41
  const abortController = new AbortController();
42
42
  const terminalController = new AbortController();
43
43
  let shutdownRequested = false;
@@ -292,10 +292,10 @@ function claudeSessionMeta(base, maxBudgetUsd) {
292
292
  };
293
293
  }
294
294
  /**
295
- * Resolve what credential the spawned CLI runs with — the boundary shared by
296
- * Automation and device-chat CLIs. When the poll envelope carries a per-run
297
- * `agent_session`, the CLI authenticates as the run's assigned agent for
298
- * exactly this run: the session token goes into the MCP wiring AND into
295
+ * Resolve what credential the spawned Automation CLI runs with. When the poll
296
+ * envelope carries a per-run `agent_session`, the CLI authenticates as the
297
+ * run's assigned agent for exactly this run: the session token goes into the
298
+ * MCP wiring AND into
299
299
  * LOBU_API_TOKEN/LOBU_MEMORY_URL, which `lobu memory` prefers
300
300
  * over the device's ambient CLI session — so an unattended run never acts as
301
301
  * the human user or the daemon. Without a session (older server, or a run with
@@ -50,7 +50,6 @@ export interface ExecutorClient {
50
50
  * re-spawn with the returned nudge.
51
51
  */
52
52
  completeAutomation(runId: number, req: CompleteAutomationRequest): Promise<CompleteAutomationResponse>;
53
- completeDeviceChat(runId: number, req: CompleteDeviceChatRequest): Promise<CompleteDeviceChatResponse>;
54
53
  /**
55
54
  * Report an agent turn. Fleet-only, so it posts to the shared worker route
56
55
  * rather than the device-scoped `/me/runs/...` family.
@@ -70,8 +69,8 @@ export interface ExecutorClient {
70
69
  * module's public surface is unchanged for importers, while the server annotates
71
70
  * its request-body reads with the same shapes from that file.
72
71
  */
73
- export type { CompleteActionRequest, CompleteAgentTurnRequest, CompleteAgentTurnResponse, CompleteAuthRequest, CompleteAutomationRequest, CompleteAutomationResponse, CompleteDeviceChatRequest, CompleteDeviceChatResponse, CompleteEmbeddingsRequest, CompleteRequest, ContentItem, DispatchChromeActionRequest, DispatchChromeActionResponse, EmbedEvent, EmitAuthArtifactRequest, HeartbeatRequest, HeartbeatResponse, OAuthCredentials, PollAuthSignalRequest, PollAuthSignalResponse, PollResponse, StreamBatch, } from "@lobu/core/contracts/worker/protocol";
74
- import type { ConnectorHttpRequest, ConnectorHttpResponse, CompleteActionRequest, CompleteAgentTurnRequest, CompleteAgentTurnResponse, CompleteAuthRequest, CompleteAutomationRequest, CompleteAutomationResponse, CompleteDeviceChatRequest, CompleteDeviceChatResponse, CompleteEmbeddingsRequest, CompleteRequest, DispatchChromeActionRequest, EmbedEvent, EmitAuthArtifactRequest, ExecuteConnectorOperationRequest, HeartbeatRequest, HeartbeatResponse, PollAuthSignalRequest, PollAuthSignalResponse, PollResponse, StreamBatch } from "@lobu/core/contracts/worker/protocol";
72
+ export type { CompleteActionRequest, CompleteAgentTurnRequest, CompleteAgentTurnResponse, CompleteAuthRequest, CompleteAutomationRequest, CompleteAutomationResponse, CompleteEmbeddingsRequest, CompleteRequest, ContentItem, DispatchChromeActionRequest, DispatchChromeActionResponse, EmbedEvent, EmitAuthArtifactRequest, HeartbeatRequest, HeartbeatResponse, OAuthCredentials, PollAuthSignalRequest, PollAuthSignalResponse, PollResponse, StreamBatch, } from "@lobu/core/contracts/worker/protocol";
73
+ import type { ConnectorHttpRequest, ConnectorHttpResponse, CompleteActionRequest, CompleteAgentTurnRequest, CompleteAgentTurnResponse, CompleteAuthRequest, CompleteAutomationRequest, CompleteAutomationResponse, CompleteEmbeddingsRequest, CompleteRequest, DispatchChromeActionRequest, EmbedEvent, EmitAuthArtifactRequest, ExecuteConnectorOperationRequest, HeartbeatRequest, HeartbeatResponse, PollAuthSignalRequest, PollAuthSignalResponse, PollResponse, StreamBatch } from "@lobu/core/contracts/worker/protocol";
75
74
  import type { ConnectorOperationResult } from "@lobu/core/contracts/tools/manage-operations";
76
75
  import type { AgentKind } from "@lobu/core/contracts/worker/device-automation";
77
76
  /** Capability strings the worker advertises, keyed by name (e.g. `browser.debugger`). */
@@ -246,7 +245,6 @@ export declare class WorkerClient implements ExecutorClient {
246
245
  */
247
246
  completeAutomation(runId: number, req: CompleteAutomationRequest): Promise<CompleteAutomationResponse>;
248
247
  completeAgentTurn(req: CompleteAgentTurnRequest): Promise<CompleteAgentTurnResponse>;
249
- completeDeviceChat(runId: number, req: CompleteDeviceChatRequest): Promise<CompleteDeviceChatResponse>;
250
248
  get mcpWiring(): {
251
249
  url: string;
252
250
  bearer?: string;
@@ -363,9 +363,6 @@ export class WorkerClient {
363
363
  async completeAgentTurn(req) {
364
364
  return this.requestJson('/api/workers/complete-agent-turn', req);
365
365
  }
366
- async completeDeviceChat(runId, req) {
367
- return this.requestJson(`/api/workers/me/runs/${runId}/complete-chat`, req);
368
- }
369
366
  get mcpWiring() {
370
367
  if (!this.authToken)
371
368
  return undefined;