@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.
- package/config.template.json +8 -4
- package/dist/agent/builtin-commands.d.ts +1 -1
- package/dist/agent/builtin-commands.d.ts.map +1 -1
- package/dist/agent/builtin-commands.js +5 -0
- package/dist/agent/builtin-commands.js.map +1 -1
- package/dist/agent/line-pure.d.ts +31 -0
- package/dist/agent/line-pure.d.ts.map +1 -0
- package/dist/agent/line-pure.js +99 -0
- package/dist/agent/line-pure.js.map +1 -0
- package/dist/agent/line-reply-manager.d.ts +68 -0
- package/dist/agent/line-reply-manager.d.ts.map +1 -0
- package/dist/agent/line-reply-manager.js +383 -0
- package/dist/agent/line-reply-manager.js.map +1 -0
- package/dist/agent/runner.d.ts +11 -2
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +106 -8
- package/dist/agent/runner.js.map +1 -1
- package/dist/api/gateway-router.d.ts.map +1 -1
- package/dist/api/gateway-router.js +4 -0
- package/dist/api/gateway-router.js.map +1 -1
- package/dist/api/line-access.d.ts +60 -0
- package/dist/api/line-access.d.ts.map +1 -0
- package/dist/api/line-access.js +69 -0
- package/dist/api/line-access.js.map +1 -0
- package/dist/api/line-mention.d.ts +35 -0
- package/dist/api/line-mention.d.ts.map +1 -0
- package/dist/api/line-mention.js +33 -0
- package/dist/api/line-mention.js.map +1 -0
- package/dist/api/line-pending-senders.d.ts +40 -0
- package/dist/api/line-pending-senders.d.ts.map +1 -0
- package/dist/api/line-pending-senders.js +107 -0
- package/dist/api/line-pending-senders.js.map +1 -0
- package/dist/api/line-webhook-router.d.ts +51 -0
- package/dist/api/line-webhook-router.d.ts.map +1 -0
- package/dist/api/line-webhook-router.js +416 -0
- package/dist/api/line-webhook-router.js.map +1 -0
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +244 -7
- package/dist/api/router.js.map +1 -1
- package/dist/history/types.d.ts +1 -1
- package/dist/history/types.d.ts.map +1 -1
- package/dist/session/compactor.d.ts +1 -1
- package/dist/session/compactor.d.ts.map +1 -1
- package/dist/session/compactor.js.map +1 -1
- package/dist/session/process.d.ts +2 -2
- package/dist/session/process.d.ts.map +1 -1
- package/dist/session/process.js +14 -3
- package/dist/session/process.js.map +1 -1
- package/dist/session/store.d.ts +13 -13
- package/dist/session/store.d.ts.map +1 -1
- package/dist/session/store.js.map +1 -1
- package/dist/types.d.ts +60 -0
- package/dist/types.d.ts.map +1 -1
- package/mcp/bun.lock +9 -2
- package/mcp/package.json +1 -0
- package/mcp/server.ts +2 -0
- package/mcp/tools/line/module.ts +127 -0
- package/mcp/tools/line/pure.ts +62 -0
- package/mcp/tools/telegram/receiver-server.ts +8 -5
- 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-
|
|
714
|
-
{ id: 'claude-opus-4-
|
|
715
|
-
{ id: 'claude-
|
|
716
|
-
{ id: 'claude-
|
|
717
|
-
{ id: 'claude-
|
|
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.
|
|
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",
|