@0xmaxma/claude-gateway 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/README.md +1 -0
  2. package/config.template.json +1 -1
  3. package/dist/agent/dreaming/index.d.ts +6 -0
  4. package/dist/agent/dreaming/index.d.ts.map +1 -1
  5. package/dist/agent/dreaming/index.js +3 -3
  6. package/dist/agent/dreaming/index.js.map +1 -1
  7. package/dist/agent/runner.d.ts +10 -1
  8. package/dist/agent/runner.d.ts.map +1 -1
  9. package/dist/agent/runner.js +23 -12
  10. package/dist/agent/runner.js.map +1 -1
  11. package/dist/agent/workspace-loader.d.ts +40 -1
  12. package/dist/agent/workspace-loader.d.ts.map +1 -1
  13. package/dist/agent/workspace-loader.js +100 -6
  14. package/dist/agent/workspace-loader.js.map +1 -1
  15. package/dist/api/cron-router.d.ts.map +1 -1
  16. package/dist/api/cron-router.js +3 -2
  17. package/dist/api/cron-router.js.map +1 -1
  18. package/dist/api/gateway-router.d.ts.map +1 -1
  19. package/dist/api/gateway-router.js +11 -2
  20. package/dist/api/gateway-router.js.map +1 -1
  21. package/dist/api/router.d.ts.map +1 -1
  22. package/dist/api/router.js +40 -5
  23. package/dist/api/router.js.map +1 -1
  24. package/dist/api/share-router.d.ts +1 -1
  25. package/dist/api/share-router.d.ts.map +1 -1
  26. package/dist/api/share-router.js +14 -5
  27. package/dist/api/share-router.js.map +1 -1
  28. package/dist/api/voice-call-router.d.ts.map +1 -1
  29. package/dist/api/voice-call-router.js +8 -5
  30. package/dist/api/voice-call-router.js.map +1 -1
  31. package/dist/api/voice-router.js +1 -1
  32. package/dist/api/voice-router.js.map +1 -1
  33. package/dist/api/voice-settings-router.d.ts.map +1 -1
  34. package/dist/api/voice-settings-router.js +15 -0
  35. package/dist/api/voice-settings-router.js.map +1 -1
  36. package/dist/apps/agent-manager.d.ts +9 -0
  37. package/dist/apps/agent-manager.d.ts.map +1 -1
  38. package/dist/apps/agent-manager.js +38 -0
  39. package/dist/apps/agent-manager.js.map +1 -1
  40. package/dist/apps/compose-generator.d.ts +8 -0
  41. package/dist/apps/compose-generator.d.ts.map +1 -1
  42. package/dist/apps/compose-generator.js +9 -3
  43. package/dist/apps/compose-generator.js.map +1 -1
  44. package/dist/apps/conversation-sandbox.d.ts +78 -0
  45. package/dist/apps/conversation-sandbox.d.ts.map +1 -0
  46. package/dist/apps/conversation-sandbox.js +357 -0
  47. package/dist/apps/conversation-sandbox.js.map +1 -0
  48. package/dist/apps/installer.d.ts +2 -0
  49. package/dist/apps/installer.d.ts.map +1 -1
  50. package/dist/apps/installer.js +5 -0
  51. package/dist/apps/installer.js.map +1 -1
  52. package/dist/apps/registry.d.ts +2 -0
  53. package/dist/apps/registry.d.ts.map +1 -1
  54. package/dist/build-provenance.json +4 -4
  55. package/dist/config/agent-lifecycle.d.ts +4 -2
  56. package/dist/config/agent-lifecycle.d.ts.map +1 -1
  57. package/dist/config/agent-lifecycle.js +11 -3
  58. package/dist/config/agent-lifecycle.js.map +1 -1
  59. package/dist/config/loader.d.ts.map +1 -1
  60. package/dist/config/loader.js +13 -0
  61. package/dist/config/loader.js.map +1 -1
  62. package/dist/config/migrator.d.ts +2 -0
  63. package/dist/config/migrator.d.ts.map +1 -1
  64. package/dist/config/migrator.js +37 -1
  65. package/dist/config/migrator.js.map +1 -1
  66. package/dist/config/reload-policy.d.ts.map +1 -1
  67. package/dist/config/reload-policy.js +5 -0
  68. package/dist/config/reload-policy.js.map +1 -1
  69. package/dist/cron/manager.d.ts +15 -0
  70. package/dist/cron/manager.d.ts.map +1 -1
  71. package/dist/cron/manager.js +53 -1
  72. package/dist/cron/manager.js.map +1 -1
  73. package/dist/index.js +49 -9
  74. package/dist/index.js.map +1 -1
  75. package/dist/orchestration/bridge.d.ts +6 -0
  76. package/dist/orchestration/bridge.d.ts.map +1 -1
  77. package/dist/orchestration/bridge.js +32 -10
  78. package/dist/orchestration/bridge.js.map +1 -1
  79. package/dist/orchestration/capabilities.d.ts.map +1 -1
  80. package/dist/orchestration/capabilities.js +2 -0
  81. package/dist/orchestration/capabilities.js.map +1 -1
  82. package/dist/orchestration/config.js +1 -1
  83. package/dist/orchestration/config.js.map +1 -1
  84. package/dist/orchestration/container.d.ts.map +1 -1
  85. package/dist/orchestration/container.js +51 -2
  86. package/dist/orchestration/container.js.map +1 -1
  87. package/dist/orchestration/context-footprint.d.ts +8 -1
  88. package/dist/orchestration/context-footprint.d.ts.map +1 -1
  89. package/dist/orchestration/context-footprint.js +27 -9
  90. package/dist/orchestration/context-footprint.js.map +1 -1
  91. package/dist/orchestration/dashboard-reader-worker.js +1 -1
  92. package/dist/orchestration/dashboard-reader-worker.js.map +1 -1
  93. package/dist/orchestration/recovery.d.ts.map +1 -1
  94. package/dist/orchestration/recovery.js +30 -0
  95. package/dist/orchestration/recovery.js.map +1 -1
  96. package/dist/orchestration/report-promise.d.ts +9 -0
  97. package/dist/orchestration/report-promise.d.ts.map +1 -0
  98. package/dist/orchestration/report-promise.js +39 -0
  99. package/dist/orchestration/report-promise.js.map +1 -0
  100. package/dist/orchestration/restart-resume.d.ts +19 -0
  101. package/dist/orchestration/restart-resume.d.ts.map +1 -0
  102. package/dist/orchestration/restart-resume.js +53 -0
  103. package/dist/orchestration/restart-resume.js.map +1 -0
  104. package/dist/orchestration/runtime.d.ts +3 -0
  105. package/dist/orchestration/runtime.d.ts.map +1 -1
  106. package/dist/orchestration/runtime.js +35 -8
  107. package/dist/orchestration/runtime.js.map +1 -1
  108. package/dist/orchestration/source-policy.d.ts +2 -0
  109. package/dist/orchestration/source-policy.d.ts.map +1 -1
  110. package/dist/orchestration/source-policy.js +3 -1
  111. package/dist/orchestration/source-policy.js.map +1 -1
  112. package/dist/orchestration/task-files.d.ts +2 -0
  113. package/dist/orchestration/task-files.d.ts.map +1 -1
  114. package/dist/orchestration/task-files.js +17 -6
  115. package/dist/orchestration/task-files.js.map +1 -1
  116. package/dist/orchestration/tasks/driver.d.ts +1 -0
  117. package/dist/orchestration/tasks/driver.d.ts.map +1 -1
  118. package/dist/orchestration/tasks/driver.js +34 -4
  119. package/dist/orchestration/tasks/driver.js.map +1 -1
  120. package/dist/orchestration/tasks/failure.js +1 -1
  121. package/dist/orchestration/tasks/failure.js.map +1 -1
  122. package/dist/orchestration/tasks/scheduler.d.ts +2 -0
  123. package/dist/orchestration/tasks/scheduler.d.ts.map +1 -1
  124. package/dist/orchestration/tasks/scheduler.js +38 -27
  125. package/dist/orchestration/tasks/scheduler.js.map +1 -1
  126. package/dist/orchestration/tasks/service.d.ts +4 -0
  127. package/dist/orchestration/tasks/service.d.ts.map +1 -1
  128. package/dist/orchestration/tasks/service.js +53 -1
  129. package/dist/orchestration/tasks/service.js.map +1 -1
  130. package/dist/orchestration/types.d.ts +13 -0
  131. package/dist/orchestration/types.d.ts.map +1 -1
  132. package/dist/orchestration/types.js.map +1 -1
  133. package/dist/session/process.d.ts +37 -2
  134. package/dist/session/process.d.ts.map +1 -1
  135. package/dist/session/process.js +171 -31
  136. package/dist/session/process.js.map +1 -1
  137. package/dist/share/share-store.d.ts +10 -1
  138. package/dist/share/share-store.d.ts.map +1 -1
  139. package/dist/share/share-store.js +42 -1
  140. package/dist/share/share-store.js.map +1 -1
  141. package/dist/types.d.ts +15 -0
  142. package/dist/types.d.ts.map +1 -1
  143. package/dist/ui/voice-call-client.d.ts +27 -14
  144. package/dist/ui/voice-call-client.d.ts.map +1 -1
  145. package/dist/ui/voice-call-client.js +80 -24
  146. package/dist/ui/voice-call-client.js.map +1 -1
  147. package/dist/ui/voice-call-ui.d.ts +4 -1
  148. package/dist/ui/voice-call-ui.d.ts.map +1 -1
  149. package/dist/ui/voice-call-ui.js +65 -21
  150. package/dist/ui/voice-call-ui.js.map +1 -1
  151. package/dist/voice/errors.js +1 -1
  152. package/dist/voice/errors.js.map +1 -1
  153. package/dist/voice/notes.d.ts +4 -3
  154. package/dist/voice/notes.d.ts.map +1 -1
  155. package/dist/voice/notes.js +14 -11
  156. package/dist/voice/notes.js.map +1 -1
  157. package/dist/voice/telegram-avatar.d.ts +6 -2
  158. package/dist/voice/telegram-avatar.d.ts.map +1 -1
  159. package/dist/voice/telegram-avatar.js +23 -10
  160. package/dist/voice/telegram-avatar.js.map +1 -1
  161. package/dist/voice/turn-manager.d.ts.map +1 -1
  162. package/dist/voice/turn-manager.js +1 -1
  163. package/dist/voice/turn-manager.js.map +1 -1
  164. package/dist/voice/types.d.ts +3 -0
  165. package/dist/voice/types.d.ts.map +1 -1
  166. package/dist/voice/types.js +4 -0
  167. package/dist/voice/types.js.map +1 -1
  168. package/mcp/modules.ts +13 -1
  169. package/mcp/tools/agent/module.ts +3 -1
  170. package/mcp/tools/api/module.ts +9 -1
  171. package/mcp/tools/apps/module.ts +4 -2
  172. package/mcp/tools/apps/skills/create-app-yaml/SKILL.md +1 -1
  173. package/mcp/tools/apps/skills/install-app/SKILL.md +2 -1
  174. package/mcp/tools/cron/module.ts +3 -0
  175. package/mcp/tools/discord/module.ts +44 -11
  176. package/mcp/tools/line/module.ts +11 -0
  177. package/mcp/tools/memory/disable-archive.test.ts +47 -0
  178. package/mcp/tools/memory/isolate-memory.test.ts +95 -0
  179. package/mcp/tools/memory/module.ts +4 -1
  180. package/mcp/tools/shared/isolate.ts +77 -0
  181. package/mcp/tools/shared/share-client.ts +15 -1
  182. package/mcp/tools/skills/module.ts +4 -2
  183. package/mcp/tools/slack/module.ts +12 -5
  184. package/mcp/tools/tasks/module.ts +1 -1
  185. package/mcp/tools/telegram/attachment-log.ts +39 -0
  186. package/mcp/tools/telegram/module.ts +27 -11
  187. package/mcp/tools/telegram/receiver-server.ts +8 -0
  188. package/mcp/tools/wechat/module.ts +2 -0
  189. package/mcp/tools/whatsapp/module.ts +8 -1
  190. package/mcp/tools/whatsapp-cloud/module.ts +14 -7
  191. package/package.json +1 -1
@@ -41,6 +41,7 @@ import { join, extname, sep } from 'path'
41
41
  import { execFileSync } from 'child_process'
42
42
  import { createWorkingStateManager, drainOrphanForwards, chunkText, htmlToPlain } from './typing'
43
43
  import { extractRepliedAttachment, safeName } from './reply-attachment'
44
+ import { recordChatAttachments } from './attachment-log'
44
45
  // Import compiled dist/, not raw src/ — src/ is not published (files: ["mcp/"]),
45
46
  // so a src/ import crashes this bun-run receiver on installed packages (the bug
46
47
  // that silenced every bot on systemd installs). Enforced by
@@ -1071,6 +1072,13 @@ async function handleInbound(
1071
1072
  // file_id so the agent can fetch it with download_attachment — without this a
1072
1073
  // quote-reply of e.g. a CSV dropped the file entirely.
1073
1074
  const repliedAttachment = extractRepliedAttachment(replyMsg)
1075
+ // Isolate mode downloads only the file_ids this chat was shown (#609).
1076
+ const repliedPhotoId = orchestrationSpool && replyMsg?.photo ? replyMsg.photo[replyMsg.photo.length - 1]!.file_id : undefined
1077
+ try {
1078
+ recordChatAttachments(STATE_DIR, chat_id, [attachment?.file_id, repliedPhotoId, repliedAttachment?.file_id].filter((id): id is string => Boolean(id)))
1079
+ } catch (err) {
1080
+ process.stderr.write(`telegram channel: failed to record attachment ids: ${err}\n`)
1081
+ }
1074
1082
 
1075
1083
  // image_path goes in meta only — an in-content "[image attached — read: PATH]"
1076
1084
  // annotation is forgeable by any allowlisted sender typing that string.
@@ -14,6 +14,7 @@
14
14
  */
15
15
  import type { ToolModule, McpToolDefinition, McpToolResult, ToolVisibility } from '../../types';
16
16
  import { WeChatClient } from './client';
17
+ import { assertOriginChat } from '../shared/isolate';
17
18
 
18
19
  export class WeChatModule implements ToolModule {
19
20
  id = 'wechat';
@@ -78,6 +79,7 @@ export class WeChatModule implements ToolModule {
78
79
  };
79
80
  }
80
81
  try {
82
+ assertOriginChat(chatId);
81
83
  await this.getClient().send(chatId, text);
82
84
  return { content: [{ type: 'text', text: 'sent' }] };
83
85
  } catch (err) {
@@ -16,6 +16,7 @@
16
16
  * port, not through this MCP subprocess at all.
17
17
  */
18
18
  import type { ToolModule, McpToolDefinition, McpToolResult, ToolVisibility } from '../../types';
19
+ import { assertOriginChat, resolveIsolateMediaPath } from '../shared/isolate';
19
20
 
20
21
  export class WhatsAppModule implements ToolModule {
21
22
  id = 'whatsapp';
@@ -95,7 +96,7 @@ export class WhatsAppModule implements ToolModule {
95
96
  private async handleReply(args: Record<string, unknown>): Promise<McpToolResult> {
96
97
  const chatId = typeof args.chat_id === 'string' ? args.chat_id : '';
97
98
  const text = typeof args.text === 'string' ? args.text : '';
98
- const imagePath = typeof args.image_path === 'string' ? args.image_path : undefined;
99
+ let imagePath = typeof args.image_path === 'string' ? args.image_path : undefined;
99
100
  const accountId = typeof args.account_id === 'string' && args.account_id ? args.account_id : undefined;
100
101
  const replyTo =
101
102
  typeof args.reply_to_message_id === 'string' && args.reply_to_message_id
@@ -110,6 +111,12 @@ export class WhatsAppModule implements ToolModule {
110
111
  if (!chatId) {
111
112
  return { content: [{ type: 'text', text: 'whatsapp_reply: missing chat_id' }], isError: true };
112
113
  }
114
+ try {
115
+ assertOriginChat(chatId);
116
+ if (imagePath) imagePath = resolveIsolateMediaPath(imagePath);
117
+ } catch (err) {
118
+ return { content: [{ type: 'text', text: `whatsapp_reply: ${(err as Error).message}` }], isError: true };
119
+ }
113
120
  if (!text && !imagePath) {
114
121
  return {
115
122
  content: [{ type: 'text', text: 'whatsapp_reply: text or image_path is required' }],
@@ -37,6 +37,7 @@ import { optimizeImageFile } from '../../../dist/shared/image-optimize.js';
37
37
  // dmPolicy/dmAllowlist semantics.
38
38
  import { isWhatsAppCloudSenderAllowed } from '../../../dist/api/whatsapp-cloud-access.js';
39
39
  import { MAX_ATTACHMENT_BYTES } from '../shared/limits';
40
+ import { assertOriginChat, resolveIsolateMediaPath } from '../shared/isolate';
40
41
 
41
42
  /**
42
43
  * Channel state-directory names that must never be reachable through
@@ -328,6 +329,11 @@ export class WhatsAppCloudModule implements ToolModule {
328
329
  if (!chatId) {
329
330
  return { content: [{ type: 'text', text: 'whatsapp_cloud_reply: missing chat_id' }], isError: true };
330
331
  }
332
+ try {
333
+ assertOriginChat(chatId);
334
+ } catch (err) {
335
+ return { content: [{ type: 'text', text: `whatsapp_cloud_reply: ${(err as Error).message}` }], isError: true };
336
+ }
331
337
 
332
338
  // chat_id allowlist: this channel has no gateway-side relay route to add
333
339
  // a second checkpoint to (it posts to Meta directly from this
@@ -418,13 +424,14 @@ export class WhatsAppCloudModule implements ToolModule {
418
424
  try {
419
425
  // Size-check before any upload starts, so an oversized file fails fast
420
426
  // instead of half-way through a multi-file batch.
421
- for (const f of files) {
422
- assertSendableWhatsAppCloudFile(f);
423
- const st = fs.statSync(f);
427
+ const paths = files.map(resolveIsolateMediaPath);
428
+ paths.forEach((p, i) => {
429
+ assertSendableWhatsAppCloudFile(p);
430
+ const st = fs.statSync(p);
424
431
  if (st.size > MAX_ATTACHMENT_BYTES) {
425
- throw new Error(`file too large: ${f} (${(st.size / 1024 / 1024).toFixed(1)}MB, max 50MB)`);
432
+ throw new Error(`file too large: ${files[i]} (${(st.size / 1024 / 1024).toFixed(1)}MB, max 50MB)`);
426
433
  }
427
- }
434
+ });
428
435
 
429
436
  // Send-mode precedence: template → buttons → list → files → plain text.
430
437
  // Template wins outright because it is the only mode that works outside
@@ -454,8 +461,8 @@ export class WhatsAppCloudModule implements ToolModule {
454
461
  } else if (files.length > 0) {
455
462
  // The Cloud API sends one message per media item (no Slack-style
456
463
  // batch-into-one-message) — the caption rides on the FIRST file only.
457
- for (let i = 0; i < files.length; i++) {
458
- const f = files[i]!;
464
+ for (let i = 0; i < paths.length; i++) {
465
+ const f = paths[i]!;
459
466
  const mime = guessMimeType(f);
460
467
  const isImage = mime.startsWith('image/');
461
468
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmaxma/claude-gateway",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "Multi-agent gateway for Claude",
5
5
  "repository": {
6
6
  "type": "git",