@0xmaxma/claude-gateway 1.3.16 → 1.3.17

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 (60) hide show
  1. package/config.template.json +8 -4
  2. package/dist/agent/builtin-commands.d.ts +1 -1
  3. package/dist/agent/builtin-commands.d.ts.map +1 -1
  4. package/dist/agent/builtin-commands.js +5 -0
  5. package/dist/agent/builtin-commands.js.map +1 -1
  6. package/dist/agent/line-pure.d.ts +31 -0
  7. package/dist/agent/line-pure.d.ts.map +1 -0
  8. package/dist/agent/line-pure.js +99 -0
  9. package/dist/agent/line-pure.js.map +1 -0
  10. package/dist/agent/line-reply-manager.d.ts +68 -0
  11. package/dist/agent/line-reply-manager.d.ts.map +1 -0
  12. package/dist/agent/line-reply-manager.js +383 -0
  13. package/dist/agent/line-reply-manager.js.map +1 -0
  14. package/dist/agent/runner.d.ts +11 -2
  15. package/dist/agent/runner.d.ts.map +1 -1
  16. package/dist/agent/runner.js +106 -8
  17. package/dist/agent/runner.js.map +1 -1
  18. package/dist/api/gateway-router.d.ts.map +1 -1
  19. package/dist/api/gateway-router.js +4 -0
  20. package/dist/api/gateway-router.js.map +1 -1
  21. package/dist/api/line-access.d.ts +60 -0
  22. package/dist/api/line-access.d.ts.map +1 -0
  23. package/dist/api/line-access.js +69 -0
  24. package/dist/api/line-access.js.map +1 -0
  25. package/dist/api/line-mention.d.ts +35 -0
  26. package/dist/api/line-mention.d.ts.map +1 -0
  27. package/dist/api/line-mention.js +33 -0
  28. package/dist/api/line-mention.js.map +1 -0
  29. package/dist/api/line-pending-senders.d.ts +40 -0
  30. package/dist/api/line-pending-senders.d.ts.map +1 -0
  31. package/dist/api/line-pending-senders.js +107 -0
  32. package/dist/api/line-pending-senders.js.map +1 -0
  33. package/dist/api/line-webhook-router.d.ts +51 -0
  34. package/dist/api/line-webhook-router.d.ts.map +1 -0
  35. package/dist/api/line-webhook-router.js +416 -0
  36. package/dist/api/line-webhook-router.js.map +1 -0
  37. package/dist/api/router.d.ts.map +1 -1
  38. package/dist/api/router.js +244 -7
  39. package/dist/api/router.js.map +1 -1
  40. package/dist/history/types.d.ts +1 -1
  41. package/dist/history/types.d.ts.map +1 -1
  42. package/dist/session/compactor.d.ts +1 -1
  43. package/dist/session/compactor.d.ts.map +1 -1
  44. package/dist/session/compactor.js.map +1 -1
  45. package/dist/session/process.d.ts +2 -2
  46. package/dist/session/process.d.ts.map +1 -1
  47. package/dist/session/process.js +14 -3
  48. package/dist/session/process.js.map +1 -1
  49. package/dist/session/store.d.ts +13 -13
  50. package/dist/session/store.d.ts.map +1 -1
  51. package/dist/session/store.js.map +1 -1
  52. package/dist/types.d.ts +60 -0
  53. package/dist/types.d.ts.map +1 -1
  54. package/mcp/bun.lock +9 -2
  55. package/mcp/package.json +1 -0
  56. package/mcp/server.ts +2 -0
  57. package/mcp/tools/line/module.ts +127 -0
  58. package/mcp/tools/line/pure.ts +62 -0
  59. package/mcp/tools/telegram/receiver-server.ts +8 -5
  60. package/package.json +2 -1
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Pure, dependency-free helpers for the LINE channel — unit-tested in isolation
3
+ * (mirrors mcp/tools/telegram/pure.ts and mcp/tools/discord/outbound.ts chunkText).
4
+ */
5
+
6
+ /** LINE hard limit: max characters in a single text message object. */
7
+ export const LINE_TEXT_LIMIT = 5000;
8
+ /** LINE hard limit: max message objects per push/reply request. */
9
+ export const LINE_MAX_MESSAGES_PER_REQUEST = 5;
10
+
11
+ /**
12
+ * Split text into chunks each <= limit chars. Prefers to break on a newline
13
+ * within the limit; falls back to a hard cut. Always returns at least one chunk
14
+ * (an empty string in → [''], so callers always have something to send).
15
+ */
16
+ export function chunkText(text: string, limit = LINE_TEXT_LIMIT): string[] {
17
+ if (limit <= 0) return [text];
18
+ if (text.length === 0) return [''];
19
+ const out: string[] = [];
20
+ let rest = text;
21
+ while (rest.length > limit) {
22
+ let cut = rest.lastIndexOf('\n', limit);
23
+ if (cut < 0) cut = limit; // not found — hard cut
24
+ else if (cut === 0) { rest = rest.slice(1); continue; } // leading newline — skip, retry
25
+ out.push(rest.slice(0, cut));
26
+ rest = rest.slice(cut).replace(/^\n/, '');
27
+ }
28
+ if (rest.length > 0) out.push(rest);
29
+ return out.length > 0 ? out : [''];
30
+ }
31
+
32
+ /** Group items into batches of <= size (default = LINE per-request message cap). */
33
+ export function batch<T>(items: T[], size = LINE_MAX_MESSAGES_PER_REQUEST): T[][] {
34
+ const out: T[][] = [];
35
+ for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
36
+ return out;
37
+ }
38
+
39
+ export interface LineSendPlan {
40
+ /** First batch (<=5 objects) to send via the FREE reply API, or null when no usable reply token. */
41
+ replyBatch: string[] | null;
42
+ /** Remaining batches to send via the metered push API. */
43
+ pushBatches: string[][];
44
+ }
45
+
46
+ /**
47
+ * Decide how to deliver chunked text given whether a usable reply token exists.
48
+ *
49
+ * Reply-token-first to save push quota: LINE counts push/broadcast against the OA
50
+ * monthly message quota but **reply-token messages are free**. The single-use token
51
+ * can carry one reply call of up to LINE_MAX_MESSAGES_PER_REQUEST objects, so it
52
+ * takes the FIRST batch; anything beyond one batch must push. With no token,
53
+ * everything pushes. The runtime falls back to push if the reply call fails (token
54
+ * expired/invalid/already used) — that fallback lives in module.ts, not here.
55
+ */
56
+ export function planLineSend(chunks: string[], hasReplyToken: boolean): LineSendPlan {
57
+ const batches = batch(chunks);
58
+ if (!hasReplyToken || batches.length === 0) {
59
+ return { replyBatch: null, pushBatches: batches };
60
+ }
61
+ return { replyBatch: batches[0], pushBatches: batches.slice(1) };
62
+ }
@@ -710,11 +710,14 @@ const BOT_COMMANDS = [
710
710
 
711
711
  // Available AI models for /models command
712
712
  const AVAILABLE_MODELS = [
713
- { id: 'claude-opus-4-8', label: 'Opus 4.8', alias: 'opus' },
714
- { id: 'claude-opus-4-7', label: 'Opus 4.7', alias: 'opus47' },
715
- { id: 'claude-opus-4-6', label: 'Opus 4.6', alias: 'opus46' },
716
- { id: 'claude-sonnet-4-6', label: 'Sonnet 4.6', alias: 'sonnet' },
717
- { id: 'claude-haiku-4-5-20251001', label: 'Haiku 4.5', alias: 'haiku' },
713
+ { id: 'claude-fable-5', label: 'Fable 5', alias: 'fable' },
714
+ { id: 'claude-opus-4-8[1m]', label: 'Opus 4.8 (1M)', alias: 'opus[1m]' },
715
+ { id: 'claude-sonnet-5[1m]', label: 'Sonnet 5 (1M)', alias: 'sonnet[1m]' },
716
+ { id: 'claude-opus-4-8', label: 'Opus 4.8', alias: 'opus' },
717
+ { id: 'claude-opus-4-6', label: 'Opus 4.6', alias: 'opus46' },
718
+ { id: 'claude-sonnet-5', label: 'Sonnet 5', alias: 'sonnet' },
719
+ { id: 'claude-sonnet-4-6', label: 'Sonnet 4.6', alias: 'sonnet46' },
720
+ { id: 'claude-haiku-4-5-20251001', label: 'Haiku 4.5', alias: 'haiku' },
718
721
  ]
719
722
 
720
723
  // Base URL for command API calls to the AgentRunner callback server.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmaxma/claude-gateway",
3
- "version": "1.3.16",
3
+ "version": "1.3.17",
4
4
  "description": "Multi-agent gateway for Claude",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,6 +39,7 @@
39
39
  "typecheck": "tsc --noEmit"
40
40
  },
41
41
  "dependencies": {
42
+ "@line/bot-sdk": "^11.0.2",
42
43
  "@xterm/headless": "^6.0.0",
43
44
  "chokidar": "^3.5.0",
44
45
  "cron-parser": "^5.5.0",