@0xmaxma/claude-gateway 1.7.6 → 1.7.8
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 -1
- package/dist/agent/builtin-commands.d.ts +2 -1
- package/dist/agent/builtin-commands.d.ts.map +1 -1
- package/dist/agent/builtin-commands.js.map +1 -1
- package/dist/agent/incident.d.ts +1 -1
- package/dist/agent/incident.d.ts.map +1 -1
- package/dist/agent/runner.d.ts +7 -2
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +141 -9
- package/dist/agent/runner.js.map +1 -1
- package/dist/api/line-webhook-router.js +8 -8
- package/dist/api/line-webhook-router.js.map +1 -1
- package/dist/api/{line-pending-senders.d.ts → pending-senders.d.ts} +13 -13
- package/dist/api/pending-senders.d.ts.map +1 -0
- package/dist/api/pending-senders.js +128 -0
- package/dist/api/pending-senders.js.map +1 -0
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +296 -10
- package/dist/api/router.js.map +1 -1
- package/dist/api/slack-access.d.ts +74 -0
- package/dist/api/slack-access.d.ts.map +1 -0
- package/dist/api/slack-access.js +78 -0
- package/dist/api/slack-access.js.map +1 -0
- package/dist/api/slack-client.d.ts +68 -0
- package/dist/api/slack-client.d.ts.map +1 -0
- package/dist/api/slack-client.js +121 -0
- package/dist/api/slack-client.js.map +1 -0
- package/dist/api/slack-webhook-router.d.ts +34 -0
- package/dist/api/slack-webhook-router.d.ts.map +1 -0
- package/dist/api/slack-webhook-router.js +280 -0
- package/dist/api/slack-webhook-router.js.map +1 -0
- package/dist/api/webhooks-router.d.ts +18 -9
- package/dist/api/webhooks-router.d.ts.map +1 -1
- package/dist/api/webhooks-router.js +12 -7
- package/dist/api/webhooks-router.js.map +1 -1
- package/dist/cli-viewer/pairing-store.d.ts +3 -2
- package/dist/cli-viewer/pairing-store.d.ts.map +1 -1
- package/dist/cli-viewer/pairing-store.js +3 -5
- package/dist/cli-viewer/pairing-store.js.map +1 -1
- package/dist/history/types.d.ts +29 -1
- package/dist/history/types.d.ts.map +1 -1
- package/dist/history/types.js +32 -0
- package/dist/history/types.js.map +1 -1
- package/dist/session/compactor.d.ts +2 -1
- package/dist/session/compactor.d.ts.map +1 -1
- package/dist/session/compactor.js.map +1 -1
- package/dist/session/process.d.ts +17 -2
- package/dist/session/process.d.ts.map +1 -1
- package/dist/session/process.js +102 -9
- package/dist/session/process.js.map +1 -1
- package/dist/session/store.d.ts +14 -13
- package/dist/session/store.d.ts.map +1 -1
- package/dist/session/store.js +7 -2
- package/dist/session/store.js.map +1 -1
- package/dist/shell/claude-pty-shell.js +13 -0
- package/dist/shell/claude-pty-shell.js.map +1 -1
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/cli-viewer-ui.d.ts +2 -1
- package/dist/ui/cli-viewer-ui.d.ts.map +1 -1
- package/dist/ui/cli-viewer-ui.js.map +1 -1
- package/mcp/server.ts +2 -0
- package/mcp/tools/slack/module.ts +113 -0
- package/package.json +1 -1
- package/dist/api/line-pending-senders.d.ts.map +0 -1
- package/dist/api/line-pending-senders.js +0 -112
- package/dist/api/line-pending-senders.js.map +0 -1
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAX_PENDING_PER_AGENT = void 0;
|
|
4
|
-
exports.generatePairingCode = generatePairingCode;
|
|
5
|
-
exports.recordDeniedSender = recordDeniedSender;
|
|
6
|
-
exports.recordDeniedConversation = recordDeniedConversation;
|
|
7
|
-
exports.getPendingSenders = getPendingSenders;
|
|
8
|
-
exports.getPendingSender = getPendingSender;
|
|
9
|
-
exports.clearPendingSender = clearPendingSender;
|
|
10
|
-
exports._resetPendingSenders = _resetPendingSenders;
|
|
11
|
-
/**
|
|
12
|
-
* LINE "pending senders" — in-memory discovery aid for the Tier 1 allowlist.
|
|
13
|
-
* When the webhook access gate drops a sender that is not on the allowlist, we
|
|
14
|
-
* remember them here (with their LINE display name, best-effort) so the admin
|
|
15
|
-
* can see who is pending and one-click-add them from the UI instead of grepping
|
|
16
|
-
* `line-webhook.log`.
|
|
17
|
-
*
|
|
18
|
-
* Intentionally ephemeral: a process-lifetime Map, no persistence. Adding to the
|
|
19
|
-
* allowlist is the durable action (config.json via the agent PATCH API); this is
|
|
20
|
-
* just a transient "pending list". Bounded per agent so a flood can't grow it.
|
|
21
|
-
*/
|
|
22
|
-
const crypto_1 = require("crypto");
|
|
23
|
-
/** Mint a short visual-match pairing code (6 uppercase hex). */
|
|
24
|
-
function generatePairingCode() {
|
|
25
|
-
return (0, crypto_1.randomBytes)(3).toString('hex').toUpperCase();
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Max distinct senders retained per agent (oldest evicted first). Kept at 5 to
|
|
29
|
-
* match the per-kind pending cap in the Telegram/Discord gate (countPending ⇒ 5
|
|
30
|
-
* for each of DM and group), so every channel bounds unapproved knocks the same
|
|
31
|
-
* way and a flood can't exhaust memory.
|
|
32
|
-
*/
|
|
33
|
-
exports.MAX_PENDING_PER_AGENT = 5;
|
|
34
|
-
// agentId -> (id -> entry) (id = userId | groupId | roomId)
|
|
35
|
-
const store = new Map();
|
|
36
|
-
/**
|
|
37
|
-
* Record a denied knock (DM sender or group/room conversation). Dedups by id
|
|
38
|
-
* (bumps count + lastSeen, fills in a name/kind if newly resolved). Evicts the
|
|
39
|
-
* least-recently-seen entry when the per-agent cap is exceeded.
|
|
40
|
-
*
|
|
41
|
-
* `code` is set only when the entry is newly created (never overwritten on
|
|
42
|
-
* dedup), so a pairing code stays stable. Returns `true` when this call created
|
|
43
|
-
* a new entry (first contact) — the webhook uses this to send the pairing code
|
|
44
|
-
* exactly once.
|
|
45
|
-
*/
|
|
46
|
-
function recordDenied(agentId, id, kind, displayName, now, code) {
|
|
47
|
-
if (!agentId || !id)
|
|
48
|
-
return false;
|
|
49
|
-
let byId = store.get(agentId);
|
|
50
|
-
if (!byId) {
|
|
51
|
-
byId = new Map();
|
|
52
|
-
store.set(agentId, byId);
|
|
53
|
-
}
|
|
54
|
-
const existing = byId.get(id);
|
|
55
|
-
if (existing) {
|
|
56
|
-
existing.lastSeen = now;
|
|
57
|
-
existing.count += 1;
|
|
58
|
-
if (displayName && !existing.displayName)
|
|
59
|
-
existing.displayName = displayName;
|
|
60
|
-
if (!existing.kind)
|
|
61
|
-
existing.kind = kind;
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
byId.set(id, { userId: id, displayName, kind, code, firstSeen: now, lastSeen: now, count: 1 });
|
|
65
|
-
if (byId.size > exports.MAX_PENDING_PER_AGENT) {
|
|
66
|
-
let oldestId = null;
|
|
67
|
-
let oldestTs = Infinity;
|
|
68
|
-
for (const [eid, entry] of byId) {
|
|
69
|
-
if (entry.lastSeen < oldestTs) {
|
|
70
|
-
oldestTs = entry.lastSeen;
|
|
71
|
-
oldestId = eid;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (oldestId)
|
|
75
|
-
byId.delete(oldestId);
|
|
76
|
-
}
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Record a denied 1:1 DM sender (Tier 1 discovery). Returns true on first
|
|
81
|
-
* contact (entry newly created).
|
|
82
|
-
*/
|
|
83
|
-
function recordDeniedSender(agentId, userId, displayName, now = Date.now(), code) {
|
|
84
|
-
return recordDenied(agentId, userId, 'user', displayName, now, code);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Record a denied group/room conversation (Tier 3 discovery). Returns true on
|
|
88
|
-
* first contact (entry newly created).
|
|
89
|
-
*/
|
|
90
|
-
function recordDeniedConversation(agentId, conversationId, kind, name, now = Date.now(), code) {
|
|
91
|
-
return recordDenied(agentId, conversationId, kind, name, now, code);
|
|
92
|
-
}
|
|
93
|
-
/** Pending senders for an agent, most-recent first. */
|
|
94
|
-
function getPendingSenders(agentId) {
|
|
95
|
-
const byId = store.get(agentId);
|
|
96
|
-
if (!byId)
|
|
97
|
-
return [];
|
|
98
|
-
return [...byId.values()].sort((a, b) => b.lastSeen - a.lastSeen);
|
|
99
|
-
}
|
|
100
|
-
/** One pending-sender entry by id (used to reuse an already-minted pairing code). */
|
|
101
|
-
function getPendingSender(agentId, id) {
|
|
102
|
-
return store.get(agentId)?.get(id);
|
|
103
|
-
}
|
|
104
|
-
/** Drop an entry from the pending list (e.g. once added to an allowlist). */
|
|
105
|
-
function clearPendingSender(agentId, id) {
|
|
106
|
-
store.get(agentId)?.delete(id);
|
|
107
|
-
}
|
|
108
|
-
/** Test/maintenance helper — wipe all retained senders. */
|
|
109
|
-
function _resetPendingSenders() {
|
|
110
|
-
store.clear();
|
|
111
|
-
}
|
|
112
|
-
//# sourceMappingURL=line-pending-senders.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"line-pending-senders.js","sourceRoot":"","sources":["../../src/api/line-pending-senders.ts"],"names":[],"mappings":";;;AAgCA,kDAEC;AAmED,gDAQC;AAMD,4DASC;AAGD,8CAIC;AAGD,4CAEC;AAGD,gDAEC;AAGD,oDAEC;AAlJD;;;;;;;;;;GAUG;AACH,mCAAqC;AAoBrC,gEAAgE;AAChE,SAAgB,mBAAmB;IACjC,OAAO,IAAA,oBAAW,EAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACtD,CAAC;AAED;;;;;GAKG;AACU,QAAA,qBAAqB,GAAG,CAAC,CAAC;AAEvC,6DAA6D;AAC7D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsC,CAAC;AAE5D;;;;;;;;;GASG;AACH,SAAS,YAAY,CACnB,OAAe,EACf,EAAU,EACV,IAA+B,EAC/B,WAA+B,EAC/B,GAAW,EACX,IAAa;IAEb,IAAI,CAAC,OAAO,IAAI,CAAC,EAAE;QAAE,OAAO,KAAK,CAAC;IAClC,IAAI,IAAI,GAAG,KAAK,CAA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