@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.
- package/README.md +1 -0
- package/config.template.json +1 -1
- package/dist/agent/dreaming/index.d.ts +6 -0
- package/dist/agent/dreaming/index.d.ts.map +1 -1
- package/dist/agent/dreaming/index.js +3 -3
- package/dist/agent/dreaming/index.js.map +1 -1
- package/dist/agent/runner.d.ts +10 -1
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +23 -12
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/workspace-loader.d.ts +40 -1
- package/dist/agent/workspace-loader.d.ts.map +1 -1
- package/dist/agent/workspace-loader.js +100 -6
- package/dist/agent/workspace-loader.js.map +1 -1
- package/dist/api/cron-router.d.ts.map +1 -1
- package/dist/api/cron-router.js +3 -2
- package/dist/api/cron-router.js.map +1 -1
- package/dist/api/gateway-router.d.ts.map +1 -1
- package/dist/api/gateway-router.js +11 -2
- package/dist/api/gateway-router.js.map +1 -1
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +40 -5
- package/dist/api/router.js.map +1 -1
- package/dist/api/share-router.d.ts +1 -1
- package/dist/api/share-router.d.ts.map +1 -1
- package/dist/api/share-router.js +14 -5
- package/dist/api/share-router.js.map +1 -1
- package/dist/api/voice-call-router.d.ts.map +1 -1
- package/dist/api/voice-call-router.js +8 -5
- package/dist/api/voice-call-router.js.map +1 -1
- package/dist/api/voice-router.js +1 -1
- package/dist/api/voice-router.js.map +1 -1
- package/dist/api/voice-settings-router.d.ts.map +1 -1
- package/dist/api/voice-settings-router.js +15 -0
- package/dist/api/voice-settings-router.js.map +1 -1
- package/dist/apps/agent-manager.d.ts +9 -0
- package/dist/apps/agent-manager.d.ts.map +1 -1
- package/dist/apps/agent-manager.js +38 -0
- package/dist/apps/agent-manager.js.map +1 -1
- package/dist/apps/compose-generator.d.ts +8 -0
- package/dist/apps/compose-generator.d.ts.map +1 -1
- package/dist/apps/compose-generator.js +9 -3
- package/dist/apps/compose-generator.js.map +1 -1
- package/dist/apps/conversation-sandbox.d.ts +78 -0
- package/dist/apps/conversation-sandbox.d.ts.map +1 -0
- package/dist/apps/conversation-sandbox.js +357 -0
- package/dist/apps/conversation-sandbox.js.map +1 -0
- package/dist/apps/installer.d.ts +2 -0
- package/dist/apps/installer.d.ts.map +1 -1
- package/dist/apps/installer.js +5 -0
- package/dist/apps/installer.js.map +1 -1
- package/dist/apps/registry.d.ts +2 -0
- package/dist/apps/registry.d.ts.map +1 -1
- package/dist/build-provenance.json +4 -4
- package/dist/config/agent-lifecycle.d.ts +4 -2
- package/dist/config/agent-lifecycle.d.ts.map +1 -1
- package/dist/config/agent-lifecycle.js +11 -3
- package/dist/config/agent-lifecycle.js.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +13 -0
- package/dist/config/loader.js.map +1 -1
- package/dist/config/migrator.d.ts +2 -0
- package/dist/config/migrator.d.ts.map +1 -1
- package/dist/config/migrator.js +37 -1
- package/dist/config/migrator.js.map +1 -1
- package/dist/config/reload-policy.d.ts.map +1 -1
- package/dist/config/reload-policy.js +5 -0
- package/dist/config/reload-policy.js.map +1 -1
- package/dist/cron/manager.d.ts +15 -0
- package/dist/cron/manager.d.ts.map +1 -1
- package/dist/cron/manager.js +53 -1
- package/dist/cron/manager.js.map +1 -1
- package/dist/index.js +49 -9
- package/dist/index.js.map +1 -1
- package/dist/orchestration/bridge.d.ts +6 -0
- package/dist/orchestration/bridge.d.ts.map +1 -1
- package/dist/orchestration/bridge.js +32 -10
- package/dist/orchestration/bridge.js.map +1 -1
- package/dist/orchestration/capabilities.d.ts.map +1 -1
- package/dist/orchestration/capabilities.js +2 -0
- package/dist/orchestration/capabilities.js.map +1 -1
- package/dist/orchestration/config.js +1 -1
- package/dist/orchestration/config.js.map +1 -1
- package/dist/orchestration/container.d.ts.map +1 -1
- package/dist/orchestration/container.js +51 -2
- package/dist/orchestration/container.js.map +1 -1
- package/dist/orchestration/context-footprint.d.ts +8 -1
- package/dist/orchestration/context-footprint.d.ts.map +1 -1
- package/dist/orchestration/context-footprint.js +27 -9
- package/dist/orchestration/context-footprint.js.map +1 -1
- package/dist/orchestration/dashboard-reader-worker.js +1 -1
- package/dist/orchestration/dashboard-reader-worker.js.map +1 -1
- package/dist/orchestration/recovery.d.ts.map +1 -1
- package/dist/orchestration/recovery.js +30 -0
- package/dist/orchestration/recovery.js.map +1 -1
- package/dist/orchestration/report-promise.d.ts +9 -0
- package/dist/orchestration/report-promise.d.ts.map +1 -0
- package/dist/orchestration/report-promise.js +39 -0
- package/dist/orchestration/report-promise.js.map +1 -0
- package/dist/orchestration/restart-resume.d.ts +19 -0
- package/dist/orchestration/restart-resume.d.ts.map +1 -0
- package/dist/orchestration/restart-resume.js +53 -0
- package/dist/orchestration/restart-resume.js.map +1 -0
- package/dist/orchestration/runtime.d.ts +3 -0
- package/dist/orchestration/runtime.d.ts.map +1 -1
- package/dist/orchestration/runtime.js +35 -8
- package/dist/orchestration/runtime.js.map +1 -1
- package/dist/orchestration/source-policy.d.ts +2 -0
- package/dist/orchestration/source-policy.d.ts.map +1 -1
- package/dist/orchestration/source-policy.js +3 -1
- package/dist/orchestration/source-policy.js.map +1 -1
- package/dist/orchestration/task-files.d.ts +2 -0
- package/dist/orchestration/task-files.d.ts.map +1 -1
- package/dist/orchestration/task-files.js +17 -6
- package/dist/orchestration/task-files.js.map +1 -1
- package/dist/orchestration/tasks/driver.d.ts +1 -0
- package/dist/orchestration/tasks/driver.d.ts.map +1 -1
- package/dist/orchestration/tasks/driver.js +34 -4
- package/dist/orchestration/tasks/driver.js.map +1 -1
- package/dist/orchestration/tasks/failure.js +1 -1
- package/dist/orchestration/tasks/failure.js.map +1 -1
- package/dist/orchestration/tasks/scheduler.d.ts +2 -0
- package/dist/orchestration/tasks/scheduler.d.ts.map +1 -1
- package/dist/orchestration/tasks/scheduler.js +38 -27
- package/dist/orchestration/tasks/scheduler.js.map +1 -1
- package/dist/orchestration/tasks/service.d.ts +4 -0
- package/dist/orchestration/tasks/service.d.ts.map +1 -1
- package/dist/orchestration/tasks/service.js +53 -1
- package/dist/orchestration/tasks/service.js.map +1 -1
- package/dist/orchestration/types.d.ts +13 -0
- package/dist/orchestration/types.d.ts.map +1 -1
- package/dist/orchestration/types.js.map +1 -1
- package/dist/session/process.d.ts +37 -2
- package/dist/session/process.d.ts.map +1 -1
- package/dist/session/process.js +171 -31
- package/dist/session/process.js.map +1 -1
- package/dist/share/share-store.d.ts +10 -1
- package/dist/share/share-store.d.ts.map +1 -1
- package/dist/share/share-store.js +42 -1
- package/dist/share/share-store.js.map +1 -1
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/voice-call-client.d.ts +27 -14
- package/dist/ui/voice-call-client.d.ts.map +1 -1
- package/dist/ui/voice-call-client.js +80 -24
- package/dist/ui/voice-call-client.js.map +1 -1
- package/dist/ui/voice-call-ui.d.ts +4 -1
- package/dist/ui/voice-call-ui.d.ts.map +1 -1
- package/dist/ui/voice-call-ui.js +65 -21
- package/dist/ui/voice-call-ui.js.map +1 -1
- package/dist/voice/errors.js +1 -1
- package/dist/voice/errors.js.map +1 -1
- package/dist/voice/notes.d.ts +4 -3
- package/dist/voice/notes.d.ts.map +1 -1
- package/dist/voice/notes.js +14 -11
- package/dist/voice/notes.js.map +1 -1
- package/dist/voice/telegram-avatar.d.ts +6 -2
- package/dist/voice/telegram-avatar.d.ts.map +1 -1
- package/dist/voice/telegram-avatar.js +23 -10
- package/dist/voice/telegram-avatar.js.map +1 -1
- package/dist/voice/turn-manager.d.ts.map +1 -1
- package/dist/voice/turn-manager.js +1 -1
- package/dist/voice/turn-manager.js.map +1 -1
- package/dist/voice/types.d.ts +3 -0
- package/dist/voice/types.d.ts.map +1 -1
- package/dist/voice/types.js +4 -0
- package/dist/voice/types.js.map +1 -1
- package/mcp/modules.ts +13 -1
- package/mcp/tools/agent/module.ts +3 -1
- package/mcp/tools/api/module.ts +9 -1
- package/mcp/tools/apps/module.ts +4 -2
- package/mcp/tools/apps/skills/create-app-yaml/SKILL.md +1 -1
- package/mcp/tools/apps/skills/install-app/SKILL.md +2 -1
- package/mcp/tools/cron/module.ts +3 -0
- package/mcp/tools/discord/module.ts +44 -11
- package/mcp/tools/line/module.ts +11 -0
- package/mcp/tools/memory/disable-archive.test.ts +47 -0
- package/mcp/tools/memory/isolate-memory.test.ts +95 -0
- package/mcp/tools/memory/module.ts +4 -1
- package/mcp/tools/shared/isolate.ts +77 -0
- package/mcp/tools/shared/share-client.ts +15 -1
- package/mcp/tools/skills/module.ts +4 -2
- package/mcp/tools/slack/module.ts +12 -5
- package/mcp/tools/tasks/module.ts +1 -1
- package/mcp/tools/telegram/attachment-log.ts +39 -0
- package/mcp/tools/telegram/module.ts +27 -11
- package/mcp/tools/telegram/receiver-server.ts +8 -0
- package/mcp/tools/wechat/module.ts +2 -0
- package/mcp/tools/whatsapp/module.ts +8 -1
- package/mcp/tools/whatsapp-cloud/module.ts +14 -7
- 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
|
-
|
|
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
|
-
|
|
422
|
-
|
|
423
|
-
|
|
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: ${
|
|
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 <
|
|
458
|
-
const f =
|
|
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
|
|