@mininglamp-oss/cc-channel-octo 1.0.3-dev.660b13a → 1.0.3-dev.688f404
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.bot.example.json +2 -1
- package/config.example.json +8 -1
- package/dist/agent-bridge.js +6 -1
- package/dist/agent-bridge.js.map +1 -1
- package/dist/config.d.ts +57 -0
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -1
- package/dist/group-config.d.ts +18 -9
- package/dist/group-config.js +47 -10
- package/dist/group-config.js.map +1 -1
- package/dist/group-context.d.ts +18 -0
- package/dist/group-context.js +86 -7
- package/dist/group-context.js.map +1 -1
- package/dist/group-md-cache.d.ts +69 -0
- package/dist/group-md-cache.js +93 -0
- package/dist/group-md-cache.js.map +1 -0
- package/dist/group-md-events.d.ts +43 -0
- package/dist/group-md-events.js +43 -0
- package/dist/group-md-events.js.map +1 -0
- package/dist/group-md-tool.d.ts +49 -0
- package/dist/group-md-tool.js +95 -0
- package/dist/group-md-tool.js.map +1 -0
- package/dist/group-md-writeback.d.ts +97 -0
- package/dist/group-md-writeback.js +118 -0
- package/dist/group-md-writeback.js.map +1 -0
- package/dist/group-md.d.ts +53 -0
- package/dist/group-md.js +98 -0
- package/dist/group-md.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +92 -15
- package/dist/index.js.map +1 -1
- package/dist/octo/api.d.ts +98 -1
- package/dist/octo/api.js +136 -1
- package/dist/octo/api.js.map +1 -1
- package/dist/octo/channel-id.d.ts +36 -0
- package/dist/octo/channel-id.js +52 -0
- package/dist/octo/channel-id.js.map +1 -0
- package/dist/octo/types.d.ts +22 -0
- package/dist/octo/types.js.map +1 -1
- package/dist/prompt-safety.d.ts +20 -0
- package/dist/prompt-safety.js +24 -0
- package/dist/prompt-safety.js.map +1 -1
- package/dist/session-router.d.ts +35 -1
- package/dist/session-router.js +66 -3
- package/dist/session-router.js.map +1 -1
- package/dist/session-store.d.ts +26 -0
- package/dist/session-store.js +64 -1
- package/dist/session-store.js.map +1 -1
- package/package.json +1 -1
package/config.bot.example.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"_comment_systemPrompt": "Inline personality string. A ./SOUL.md file next to this config overrides it.",
|
|
11
11
|
"_comment_skills": "Per-bot skill selection: 'all' or a string[] of skill names from the shared library (~/.cc-channel-octo/skills + this bot's ./skills).",
|
|
12
12
|
"_comment_env": "Extra env injected into the agent's tool subprocess, e.g. {\"OCTO_BOT_ID\":\"<robotId>\"} so a shared CLI acts as this bot.",
|
|
13
|
-
"_comment_cron": "Set cron=true to let the agent schedule tasks (cron_create/list/delete → ./cron.json, owner-gated)."
|
|
13
|
+
"_comment_cron": "Set cron=true to let the agent schedule tasks (cron_create/list/delete → ./cron.json, owner-gated).",
|
|
14
|
+
"_comment_mcp_servers": "Per-bot external MCP servers (mcp__<name>__<tool>), same shape as the global sdk.mcpServers. A per-bot map fully REPLACES the global one (sdk blocks merge shallowly), so list every server this bot needs. http header values are secrets — keep this file non-world-readable (chmod 600). Omit to inherit the global map."
|
|
14
15
|
}
|
|
15
16
|
}
|
package/config.example.json
CHANGED
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
|
|
10
10
|
"_comment_group_config_dir": "v1.0: optional directory of per-group instruction files (<groupId>.md), injected as trusted custom instructions. Operator-controlled — keep it OUTSIDE every bot's workspace (the agent can write there) AND non-writable by the gateway user. Omit to disable.",
|
|
11
11
|
|
|
12
|
+
"_comment_server_md": "P2-A: set serverMd=true to fetch each group's instructions from the server GROUP.md API (GET /v1/bot/groups/{groupNo}/md) first, falling back to the local groupConfigDir file on any failure (404 / network / no content). The fetched copy is cached IN MEMORY ONLY (never on disk — it is injected as a trusted system prompt, and a disk cache the gateway user could write would be a poisoning vector). serverMdTtlMs (default 300000 = 5 min) bounds how stale a cached entry may get before re-fetch. Default serverMd=false = pure local-file behavior (flip off to roll back).",
|
|
13
|
+
|
|
14
|
+
"_comment_md_writeback": "P2-C: set mdWriteback=true to give the agent an in-process MCP tool (mcp__group_md__update_group_md) that writes GROUP.md back to the server (PUT /v1/bot/groups/{groupNo}/md). Invocation is owner-gated (only the bot owner uid may call it); content is capped at 10240 bytes UTF-8 locally; write-backs to the same group are serialized in-process (the server has no compare-and-swap, so this prevents this gateway from racing itself — cross-source last-write-wins still applies). Default false = no write-back tool (GROUP.md is read-only from the gateway). Independent of serverMd.",
|
|
15
|
+
|
|
16
|
+
|
|
12
17
|
"sdk": {
|
|
13
18
|
"_comment_anthropic_base_url": "Q1: Optional self-hosted Claude API gateway base URL. Forwarded to the SDK subprocess (scoped). Must be https:// (or http://localhost for dev) — SSRF-validated at boot. Omit to use Anthropic's public endpoint.",
|
|
14
19
|
"_comment_allowed_tools": "Q2: either '*' (allow every tool the SDK exposes) or an explicit string[] whitelist.",
|
|
@@ -16,7 +21,9 @@
|
|
|
16
21
|
"permissionMode": "bypassPermissions",
|
|
17
22
|
"_comment_tool_progress": "v0.3: set toolProgress=true to post '🔧 Running <tool>(<params>)…' notices (params truncated). Off by default.",
|
|
18
23
|
"_comment_setting_sources": "#100: which host filesystem settings the SDK loads (user=~/.claude, project=.claude, local=.claude/*.local). Default [\"project\"] so the SDK discovers skills symlinked into each session sandbox's .claude/skills/. Memory stays isolated regardless (the auto-memory dir is pinned via inline settings, ranked above projectSettings). Add \"user\" only to deliberately load the operator's real ~/.claude.",
|
|
19
|
-
"settingSources": ["project"]
|
|
24
|
+
"settingSources": ["project"],
|
|
25
|
+
"_comment_mcp_servers": "External MCP servers exposed to the agent, keyed by name (tools surface as mcp__<name>__<tool>). Because settingSources is ['project'], servers in the operator's ~/.claude.json are NOT inherited — declare them here to opt a bot in. Merged with cc's in-process servers (cron, GROUP.md write-back); those win a name clash. Forwarded VERBATIM to the SDK subprocess (same trust model as env — config.json is operator-controlled). A per-bot sdk.mcpServers fully REPLACES this global map (sdk blocks merge shallowly). SECURITY: http header values (e.g. x-api-key / Authorization) are secrets stored in this file — keep config.json non-world-readable (chmod 600); the startup file-permission warning applies here too. Left EMPTY by default so copying this template enables NO external processes; add entries to opt in. Example shapes — stdio (local command): {\"chrome-devtools\": {\"type\": \"stdio\", \"command\": \"npx\", \"args\": [\"-y\", \"chrome-devtools-mcp@latest\", \"--isolated\"]}} — http (remote): {\"exa\": {\"type\": \"http\", \"url\": \"https://mcp.exa.ai/mcp\", \"headers\": {\"x-api-key\": \"<secret>\"}}}.",
|
|
26
|
+
"mcpServers": {}
|
|
20
27
|
},
|
|
21
28
|
|
|
22
29
|
"rateLimit": {
|
package/dist/agent-bridge.js
CHANGED
|
@@ -269,9 +269,14 @@ export async function* queryAgent(userMessage, config, sessionCtx, onToolUse, op
|
|
|
269
269
|
});
|
|
270
270
|
// Detect the SDK's stale/invalid-resume signal (verified via spike): it throws
|
|
271
271
|
// an Error whose message names the missing/invalid session id.
|
|
272
|
+
// Also catches Bedrock ValidationException for orphaned tool_use blocks left
|
|
273
|
+
// by an interrupted turn (no corresponding tool_result), which surfaces as:
|
|
274
|
+
// ValidationException: messages.N: `tool_use` ids were found without `tool_result` blocks
|
|
275
|
+
// Matching this here causes onResumeFailed() to clear the corrupt sdk_session_id
|
|
276
|
+
// and the turn to retry with fallbackRetryPrompt — same recovery path as stale sessions.
|
|
272
277
|
const isResumeError = (err) => {
|
|
273
278
|
const m = err instanceof Error ? err.message : String(err);
|
|
274
|
-
return /No conversation found with session ID|--resume requires a valid session/i.test(m);
|
|
279
|
+
return /No conversation found with session ID|--resume requires a valid session|tool_use.*ids were found without.*tool_result|tool_result.*blocks.*immediately after/i.test(m);
|
|
275
280
|
};
|
|
276
281
|
const stream = runStream(opts?.resume, userMessage);
|
|
277
282
|
// Drain one SDK stream, yielding assistant text. Reports the SDK session id once
|
package/dist/agent-bridge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-bridge.js","sourceRoot":"","sources":["../src/agent-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OA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HANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* env overrides still apply to the shared/global layer.
|
|
15
15
|
*/
|
|
16
|
+
import type { McpServerConfig } from '@anthropic-ai/claude-agent-sdk';
|
|
16
17
|
/**
|
|
17
18
|
* Default global config path: `~/.cc-channel-octo/config.json`. This is the
|
|
18
19
|
* single, fixed production location (no env/CLI override). Tests pass an
|
|
@@ -81,6 +82,44 @@ export interface Config {
|
|
|
81
82
|
* per-session cwd sandbox (which the agent can write). Unset = feature off.
|
|
82
83
|
*/
|
|
83
84
|
groupConfigDir?: string;
|
|
85
|
+
/**
|
|
86
|
+
* P2-A feature flag: when true, per-group instructions are fetched from the
|
|
87
|
+
* server GROUP.md API (`GET /v1/bot/groups/{groupNo}/md`) first, falling back
|
|
88
|
+
* to the local `groupConfigDir` file on any failure (404 / network / no
|
|
89
|
+
* content). When false/unset (default) only the local file is used — flip it
|
|
90
|
+
* off to roll back to pure local-file behavior. The fetched copy is cached
|
|
91
|
+
* IN MEMORY ONLY (never on disk — the content is injected as a trusted system
|
|
92
|
+
* prompt and a disk cache the gateway user can write would be a poisoning
|
|
93
|
+
* vector), with a TTL staleness backstop (`serverMdTtlMs`).
|
|
94
|
+
*/
|
|
95
|
+
serverMd?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* P2-A: TTL in ms for the in-memory server GROUP.md cache — a cached entry is
|
|
98
|
+
* re-fetched once it is this old, so an operator's server-side edit eventually
|
|
99
|
+
* takes effect even before item B's event-driven refresh lands. Defaults to
|
|
100
|
+
* `DEFAULT_GROUP_MD_TTL_MS` (5 min). Only meaningful when `serverMd` is true.
|
|
101
|
+
*/
|
|
102
|
+
serverMdTtlMs?: number;
|
|
103
|
+
/**
|
|
104
|
+
* P2-B: `event.type` literal(s) the server emits when a group's GROUP.md
|
|
105
|
+
* changes. On such an event the in-memory GROUP.md cache for that group is
|
|
106
|
+
* invalidated so the next turn re-fetches the authoritative copy (never
|
|
107
|
+
* trusting the event payload — see group-md-events.ts). PROVISIONAL: the
|
|
108
|
+
* exact literal is not yet confirmed from a real captured event, so this is
|
|
109
|
+
* overridable here to calibrate without a code change. Defaults to
|
|
110
|
+
* `DEFAULT_GROUP_MD_EVENT_TYPES`. Only meaningful when `serverMd` is true.
|
|
111
|
+
*/
|
|
112
|
+
serverMdEventTypes?: string[];
|
|
113
|
+
/**
|
|
114
|
+
* P2-C feature flag: when true, the agent gets an in-process MCP tool
|
|
115
|
+
* (`mcp__group_md__update_group_md`) that writes GROUP.md back to the server
|
|
116
|
+
* (PUT /v1/bot/groups/{groupNo}/md). Off (default) → no write-back tool is
|
|
117
|
+
* registered, so GROUP.md is read-only from the gateway's side — flip it off
|
|
118
|
+
* to roll back. Invocation is owner-gated regardless; this flag is the
|
|
119
|
+
* coarse on/off switch. Independent of `serverMd` (which only governs the
|
|
120
|
+
* server-first READ path), so an operator can enable reads without writes.
|
|
121
|
+
*/
|
|
122
|
+
mdWriteback?: boolean;
|
|
84
123
|
sdk: {
|
|
85
124
|
model?: string;
|
|
86
125
|
/**
|
|
@@ -163,6 +202,24 @@ export interface Config {
|
|
|
163
202
|
* is gated to the bot owner uid (registerBot.owner_uid). Default off. Per-bot.
|
|
164
203
|
*/
|
|
165
204
|
cron?: boolean;
|
|
205
|
+
/**
|
|
206
|
+
* External MCP servers exposed to the agent, keyed by server name (tools
|
|
207
|
+
* surface as `mcp__<name>__<tool>`). Merged with any in-process servers cc
|
|
208
|
+
* injects per turn (cron, GROUP.md write-back) — a name clash lets those
|
|
209
|
+
* built-ins win, since they are bound to per-turn session coords. This is
|
|
210
|
+
* how bots reach browser / search / other MCP backends: the gateway loads
|
|
211
|
+
* only `settingSources: ['project']`, so servers declared in the operator's
|
|
212
|
+
* `~/.claude.json` are deliberately NOT inherited — declare them here to opt
|
|
213
|
+
* a bot in explicitly.
|
|
214
|
+
*
|
|
215
|
+
* Trust model mirrors `env` (#107): the value is forwarded VERBATIM to the
|
|
216
|
+
* SDK subprocess with no validation — config.json is operator-controlled and
|
|
217
|
+
* outside the agent-writable sandbox, so declaring a server is an explicit
|
|
218
|
+
* operator grant. Can be set at the global layer (all bots) or per-bot in
|
|
219
|
+
* `<baseDir>/<id>/config.json` (a per-bot `sdk.mcpServers` fully REPLACES the
|
|
220
|
+
* global map — sdk blocks merge shallowly, so list every server the bot needs).
|
|
221
|
+
*/
|
|
222
|
+
mcpServers?: Record<string, McpServerConfig>;
|
|
166
223
|
};
|
|
167
224
|
rateLimit: {
|
|
168
225
|
maxPerMinute: number;
|
package/dist/config.js
CHANGED
|
@@ -100,6 +100,10 @@ function mergeConfig(base, override) {
|
|
|
100
100
|
dataDir: base.dataDir,
|
|
101
101
|
memoryBase: base.memoryBase,
|
|
102
102
|
groupConfigDir: override.groupConfigDir ?? base.groupConfigDir,
|
|
103
|
+
serverMd: override.serverMd ?? base.serverMd,
|
|
104
|
+
serverMdTtlMs: override.serverMdTtlMs ?? base.serverMdTtlMs,
|
|
105
|
+
serverMdEventTypes: override.serverMdEventTypes ?? base.serverMdEventTypes,
|
|
106
|
+
mdWriteback: override.mdWriteback ?? base.mdWriteback,
|
|
103
107
|
sdk: {
|
|
104
108
|
...base.sdk,
|
|
105
109
|
...(override.sdk ?? {}),
|
|
@@ -304,6 +308,10 @@ export function resolveBotConfigs(config) {
|
|
|
304
308
|
allowedBotUids: perBotFile.allowedBotUids ?? bot.allowedBotUids ?? config.allowedBotUids,
|
|
305
309
|
mentionFreeGroups: perBotFile.mentionFreeGroups ?? bot.mentionFreeGroups ?? config.mentionFreeGroups,
|
|
306
310
|
groupConfigDir: perBotFile.groupConfigDir ?? config.groupConfigDir,
|
|
311
|
+
serverMd: perBotFile.serverMd ?? config.serverMd,
|
|
312
|
+
serverMdTtlMs: perBotFile.serverMdTtlMs ?? config.serverMdTtlMs,
|
|
313
|
+
serverMdEventTypes: perBotFile.serverMdEventTypes ?? config.serverMdEventTypes,
|
|
314
|
+
mdWriteback: perBotFile.mdWriteback ?? config.mdWriteback,
|
|
307
315
|
sdk: {
|
|
308
316
|
...config.sdk,
|
|
309
317
|
...(perBotFile.sdk ?? {}),
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,kBAAkB,EAAE,aAAa,CAAC,CAAC;AAkT1F,SAAS,QAAQ;IACf,OAAO;QACL,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,EAAE;QACV,uEAAuE;QACvE,2DAA2D;QAC3D,8DAA8D;QAC9D,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,EAAE;QACX,GAAG,EAAE,EAAE;QACP,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,EAAE;QACd,GAAG,EAAE;YACH,sEAAsE;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;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC1C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IACxC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;QACnD,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IAClD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CACV,6CAA6C,IAAI,KAAK,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACzG,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/group-config.d.ts
CHANGED
|
@@ -27,15 +27,24 @@
|
|
|
27
27
|
/** Max bytes of an instruction file we will inject (keeps the prompt bounded). */
|
|
28
28
|
export declare const MAX_GROUP_CONFIG_BYTES = 16384;
|
|
29
29
|
/**
|
|
30
|
-
* Load the instruction file for a
|
|
30
|
+
* Load the instruction file for a channel, or undefined when none applies.
|
|
31
31
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* -
|
|
36
|
-
*
|
|
32
|
+
* Routing by channel-id shape:
|
|
33
|
+
* - Plain group (`<groupNo>`, no separator): looks for `<groupNo>.md`.
|
|
34
|
+
* Byte-identical to the pre-thread behavior.
|
|
35
|
+
* - Thread (`<groupNo>____<shortId>`, CommunityTopic): a thread carries its
|
|
36
|
+
* OWN instructions, not the parent group's, so the NEW semantics looks for
|
|
37
|
+
* `<shortId>.md` (the thread's own slug). To avoid breaking deployments
|
|
38
|
+
* that dropped a whole-composite `<groupNo>____<shortId>.md` file under the
|
|
39
|
+
* old "channel_id as filename" behavior, it then falls back to that legacy
|
|
40
|
+
* name when the short-id file is absent (compat lookup — see #88 redline 5).
|
|
37
41
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
42
|
+
* ⚠️ Path-semantics change (redline 5): before this change a thread channel_id
|
|
43
|
+
* was used verbatim as the filename; now the short id is the primary slug and
|
|
44
|
+
* the whole-composite name is only a fallback. A thread no longer inherits its
|
|
45
|
+
* parent group's `<groupNo>.md` (decision A: thread injects its own file only).
|
|
46
|
+
*
|
|
47
|
+
* Returns the trimmed contents, truncated to MAX_GROUP_CONFIG_BYTES, or
|
|
48
|
+
* undefined when no file applies. Never throws.
|
|
40
49
|
*/
|
|
41
|
-
export declare function loadGroupConfig(groupConfigDir: string | undefined,
|
|
50
|
+
export declare function loadGroupConfig(groupConfigDir: string | undefined, channelId: string): string | undefined;
|
package/dist/group-config.js
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import { closeSync, existsSync, openSync, readSync, statSync } from 'node:fs';
|
|
28
28
|
import { join } from 'node:path';
|
|
29
|
+
import { extractThreadShortId, isThreadChannelId } from './octo/channel-id.js';
|
|
29
30
|
/** Max bytes of an instruction file we will inject (keeps the prompt bounded). */
|
|
30
31
|
export const MAX_GROUP_CONFIG_BYTES = 16_384; // 16 KiB
|
|
31
32
|
/**
|
|
@@ -37,23 +38,59 @@ function isSafeId(id) {
|
|
|
37
38
|
return /^[a-zA-Z0-9._-]+$/.test(id) && id !== '.' && id !== '..';
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
|
-
* Load the instruction file for a
|
|
41
|
+
* Load the instruction file for a channel, or undefined when none applies.
|
|
41
42
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* -
|
|
43
|
+
* Routing by channel-id shape:
|
|
44
|
+
* - Plain group (`<groupNo>`, no separator): looks for `<groupNo>.md`.
|
|
45
|
+
* Byte-identical to the pre-thread behavior.
|
|
46
|
+
* - Thread (`<groupNo>____<shortId>`, CommunityTopic): a thread carries its
|
|
47
|
+
* OWN instructions, not the parent group's, so the NEW semantics looks for
|
|
48
|
+
* `<shortId>.md` (the thread's own slug). To avoid breaking deployments
|
|
49
|
+
* that dropped a whole-composite `<groupNo>____<shortId>.md` file under the
|
|
50
|
+
* old "channel_id as filename" behavior, it then falls back to that legacy
|
|
51
|
+
* name when the short-id file is absent (compat lookup — see #88 redline 5).
|
|
52
|
+
*
|
|
53
|
+
* ⚠️ Path-semantics change (redline 5): before this change a thread channel_id
|
|
54
|
+
* was used verbatim as the filename; now the short id is the primary slug and
|
|
55
|
+
* the whole-composite name is only a fallback. A thread no longer inherits its
|
|
56
|
+
* parent group's `<groupNo>.md` (decision A: thread injects its own file only).
|
|
57
|
+
*
|
|
58
|
+
* Returns the trimmed contents, truncated to MAX_GROUP_CONFIG_BYTES, or
|
|
59
|
+
* undefined when no file applies. Never throws.
|
|
60
|
+
*/
|
|
61
|
+
export function loadGroupConfig(groupConfigDir, channelId) {
|
|
62
|
+
if (!groupConfigDir)
|
|
63
|
+
return undefined;
|
|
64
|
+
if (!channelId)
|
|
65
|
+
return undefined;
|
|
66
|
+
if (isThreadChannelId(channelId)) {
|
|
67
|
+
// New semantics: the thread's own short-id file first…
|
|
68
|
+
const shortId = extractThreadShortId(channelId);
|
|
69
|
+
if (shortId) {
|
|
70
|
+
const byShortId = loadConfigFile(groupConfigDir, shortId);
|
|
71
|
+
if (byShortId !== undefined)
|
|
72
|
+
return byShortId;
|
|
73
|
+
}
|
|
74
|
+
// …then the legacy whole-composite filename for backward compatibility.
|
|
75
|
+
return loadConfigFile(groupConfigDir, channelId);
|
|
76
|
+
}
|
|
77
|
+
return loadConfigFile(groupConfigDir, channelId);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Read a single instruction file `<groupConfigDir>/<slug>.md`, or undefined.
|
|
81
|
+
*
|
|
82
|
+
* Returns the trimmed contents, truncated to MAX_GROUP_CONFIG_BYTES. Returns
|
|
83
|
+
* undefined when:
|
|
84
|
+
* - slug is empty or unsafe as a path segment,
|
|
46
85
|
* - the file does not exist or is unreadable.
|
|
47
86
|
*
|
|
48
87
|
* Never throws — a misconfigured dir or unreadable file degrades to "no custom
|
|
49
88
|
* instructions" rather than failing the turn.
|
|
50
89
|
*/
|
|
51
|
-
|
|
52
|
-
if (!
|
|
53
|
-
return undefined;
|
|
54
|
-
if (!groupId || !isSafeId(groupId))
|
|
90
|
+
function loadConfigFile(groupConfigDir, slug) {
|
|
91
|
+
if (!slug || !isSafeId(slug))
|
|
55
92
|
return undefined;
|
|
56
|
-
const path = join(groupConfigDir, `${
|
|
93
|
+
const path = join(groupConfigDir, `${slug}.md`);
|
|
57
94
|
try {
|
|
58
95
|
if (!existsSync(path))
|
|
59
96
|
return undefined;
|
package/dist/group-config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-config.js","sourceRoot":"","sources":["../src/group-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"group-config.js","sourceRoot":"","sources":["../src/group-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE/E,kFAAkF;AAClF,MAAM,CAAC,MAAM,s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,CAAC;QAC5C,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC/B,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IAClD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,kDAAkD,IAAI,KAAK,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACxF,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/group-context.d.ts
CHANGED
|
@@ -25,6 +25,24 @@ export declare class GroupContext {
|
|
|
25
25
|
private initStatements;
|
|
26
26
|
private getMemberMap;
|
|
27
27
|
private getNameToUid;
|
|
28
|
+
/**
|
|
29
|
+
* Resolve the best-known human-readable display name for a uid in a channel.
|
|
30
|
+
*
|
|
31
|
+
* Priority (most trusted first):
|
|
32
|
+
* 1. Member roster (memberMap) — populated by refreshMembers from the
|
|
33
|
+
* authoritative /groups/<id>/members API, so this is the current
|
|
34
|
+
* displayName even after a rename.
|
|
35
|
+
* 2. wire-provided fallback name, when it is non-empty AND not just the
|
|
36
|
+
* uid echoed back. Some IM payloads omit from_name entirely, others
|
|
37
|
+
* echo the uid; both look useless as a displayName.
|
|
38
|
+
* 3. undefined — caller decides whether to fall back to bare uid or a
|
|
39
|
+
* literal 'unknown'.
|
|
40
|
+
*
|
|
41
|
+
* Read-only: callers that want to also LEARN the name should invoke
|
|
42
|
+
* learnMember separately (renderer paths intentionally do not learn, to
|
|
43
|
+
* keep render a pure read).
|
|
44
|
+
*/
|
|
45
|
+
resolveDisplayName(channelId: string, fromUid: string, fromName?: string | null): string | undefined;
|
|
28
46
|
pushMessage(channelId: string, fromUid: string, fromName: string, content: string, timestamp: number): void;
|
|
29
47
|
learnMember(channelId: string, uid: string, name: string): void;
|
|
30
48
|
refreshMembers(channelId: string, apiUrl: string, botToken: string): Promise<void>;
|
package/dist/group-context.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Group Context — group chat message cache + maxContextChars budget + mention mapping.
|
|
3
3
|
*/
|
|
4
4
|
import { getGroupMembers, fetchUserInfo } from './octo/api.js';
|
|
5
|
-
import {
|
|
5
|
+
import { extractParentGroupNo } from './octo/channel-id.js';
|
|
6
|
+
import { sanitizeDisplayName, formatSenderLabel } from './prompt-safety.js';
|
|
6
7
|
const REFRESH_INTERVAL_MS = 60 * 60 * 1000;
|
|
7
8
|
export class GroupContext {
|
|
8
9
|
messageCache = new Map();
|
|
@@ -73,7 +74,7 @@ export class GroupContext {
|
|
|
73
74
|
// deleteOldMessages' retained 200, so every fetchable row survives trimming.
|
|
74
75
|
// buildContextSince re-sorts the budget-selected slice into chronological
|
|
75
76
|
// order for display. Mirrors the in-memory buildContext rolling-window.
|
|
76
|
-
this.selectMessagesSince = this.adapter.prepare('SELECT id, from_name, content FROM group_messages WHERE channel_id = ? AND id > ? ORDER BY id DESC LIMIT ?');
|
|
77
|
+
this.selectMessagesSince = this.adapter.prepare('SELECT id, from_uid, from_name, content FROM group_messages WHERE channel_id = ? AND id > ? ORDER BY id DESC LIMIT ?');
|
|
77
78
|
this.selectMaxId = this.adapter.prepare('SELECT MAX(id) AS maxId FROM group_messages WHERE channel_id = ?');
|
|
78
79
|
this.upsertCursor = this.adapter.prepare('INSERT INTO group_context_cursors (channel_id, last_id, updated_at) VALUES (?, ?, ?) ' +
|
|
79
80
|
'ON CONFLICT(channel_id) DO UPDATE SET last_id = excluded.last_id, updated_at = excluded.updated_at ' +
|
|
@@ -96,6 +97,39 @@ export class GroupContext {
|
|
|
96
97
|
}
|
|
97
98
|
return m;
|
|
98
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Resolve the best-known human-readable display name for a uid in a channel.
|
|
102
|
+
*
|
|
103
|
+
* Priority (most trusted first):
|
|
104
|
+
* 1. Member roster (memberMap) — populated by refreshMembers from the
|
|
105
|
+
* authoritative /groups/<id>/members API, so this is the current
|
|
106
|
+
* displayName even after a rename.
|
|
107
|
+
* 2. wire-provided fallback name, when it is non-empty AND not just the
|
|
108
|
+
* uid echoed back. Some IM payloads omit from_name entirely, others
|
|
109
|
+
* echo the uid; both look useless as a displayName.
|
|
110
|
+
* 3. undefined — caller decides whether to fall back to bare uid or a
|
|
111
|
+
* literal 'unknown'.
|
|
112
|
+
*
|
|
113
|
+
* Read-only: callers that want to also LEARN the name should invoke
|
|
114
|
+
* learnMember separately (renderer paths intentionally do not learn, to
|
|
115
|
+
* keep render a pure read).
|
|
116
|
+
*/
|
|
117
|
+
resolveDisplayName(channelId, fromUid, fromName) {
|
|
118
|
+
// Roster is priority 1 ONLY when it carries a genuine displayName. A roster
|
|
119
|
+
// entry that echoes the uid is a poisoned cache (an earlier pushMessage
|
|
120
|
+
// learned the uid because wire from_name was missing) and must NOT win over
|
|
121
|
+
// a subsequent real wire name — otherwise the roster locks in `uid(uid):`
|
|
122
|
+
// rendering until an external refresh overwrites the entry.
|
|
123
|
+
const rosterName = this.getMemberMap(channelId).get(fromUid);
|
|
124
|
+
if (rosterName && rosterName.length > 0 && rosterName !== fromUid)
|
|
125
|
+
return rosterName;
|
|
126
|
+
if (fromName && fromName.length > 0 && fromName !== fromUid) {
|
|
127
|
+
const safe = sanitizeDisplayName(fromName);
|
|
128
|
+
if (safe.length > 0 && safe !== fromUid)
|
|
129
|
+
return safe;
|
|
130
|
+
}
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
99
133
|
pushMessage(channelId, fromUid, fromName, content, timestamp) {
|
|
100
134
|
// SECURITY: fromName is the user-controlled IM display name and is rendered
|
|
101
135
|
// into the [Group context] block as `<name>:<content>`. Bound + strip it at
|
|
@@ -103,7 +137,18 @@ export class GroupContext {
|
|
|
103
137
|
// is ALSO user-controlled, and sanitizeDisplayName returns its fallback
|
|
104
138
|
// verbatim — so sanitize the uid fallback too rather than passing it raw
|
|
105
139
|
// (PR #128 review: raw-uid-as-fallback re-introduces the injection).
|
|
106
|
-
|
|
140
|
+
//
|
|
141
|
+
// Prefer the member roster's displayName over the wire from_name: wire can
|
|
142
|
+
// be undefined (some IM payloads omit it) or echo the uid back, both of
|
|
143
|
+
// which render as an unhelpful `uid(uid)` in the recent-messages block.
|
|
144
|
+
// resolveDisplayName returns undefined when neither roster nor a real wire
|
|
145
|
+
// name is available; fall back to sanitized uid then 'unknown' — same
|
|
146
|
+
// final-fallback chain as before, but with a shot at the human name first.
|
|
147
|
+
const resolvedName = this.resolveDisplayName(channelId, fromUid, fromName);
|
|
148
|
+
const safeName = (resolvedName && sanitizeDisplayName(resolvedName)) ||
|
|
149
|
+
sanitizeDisplayName(fromName) ||
|
|
150
|
+
sanitizeDisplayName(fromUid) ||
|
|
151
|
+
'unknown';
|
|
107
152
|
let window = this.messageCache.get(channelId);
|
|
108
153
|
if (!window) {
|
|
109
154
|
window = [];
|
|
@@ -113,7 +158,13 @@ export class GroupContext {
|
|
|
113
158
|
while (window.length > this.maxWindowSize) {
|
|
114
159
|
window.shift();
|
|
115
160
|
}
|
|
116
|
-
|
|
161
|
+
// Do NOT learn a uid-echo as an authoritative roster name — if we did, a
|
|
162
|
+
// later message that DOES carry a real wire name would be blocked by the
|
|
163
|
+
// roster (priority 1) and render as `uid(uid):` forever. Only learn when
|
|
164
|
+
// safeName is a genuine displayName distinct from the uid.
|
|
165
|
+
if (safeName !== fromUid && safeName !== 'unknown') {
|
|
166
|
+
this.learnMember(channelId, fromUid, safeName);
|
|
167
|
+
}
|
|
117
168
|
try {
|
|
118
169
|
this.insertMessage.run(channelId, fromUid, safeName, content, timestamp);
|
|
119
170
|
// Trim old messages to keep DB bounded (keep 2x window for safety)
|
|
@@ -152,7 +203,14 @@ export class GroupContext {
|
|
|
152
203
|
return;
|
|
153
204
|
// Don't set lastRefresh here — only on success
|
|
154
205
|
try {
|
|
155
|
-
|
|
206
|
+
// Redline 6 (#88): the roster endpoint is keyed by the PARENT group number.
|
|
207
|
+
// A thread channelId is the composite `<groupNo>____<shortId>`; hitting
|
|
208
|
+
// `/groups/<groupNo>____<shortId>/members` 404s. Resolve the parent group
|
|
209
|
+
// number for the API call while keeping every cache (memory + DB + robot
|
|
210
|
+
// flags) keyed by the full channelId, so a thread keeps its own isolated
|
|
211
|
+
// roster view. For a plain group channelId extractParentGroupNo is identity.
|
|
212
|
+
const groupNo = extractParentGroupNo(channelId);
|
|
213
|
+
const members = await getGroupMembers({ apiUrl, botToken, groupNo });
|
|
156
214
|
this.lastRefresh.set(channelId, now); // Record only on success
|
|
157
215
|
const memberMap = this.getMemberMap(channelId);
|
|
158
216
|
const nameMap = this.getNameToUid(channelId);
|
|
@@ -265,7 +323,19 @@ export class GroupContext {
|
|
|
265
323
|
let used = 0;
|
|
266
324
|
for (let i = window.length - 1; i >= 0; i--) {
|
|
267
325
|
const m = window[i];
|
|
268
|
-
|
|
326
|
+
// Same `name(uid):content` format as buildContextSince (DB path) — see
|
|
327
|
+
// that method's comment for rationale (uniform identity semantics between
|
|
328
|
+
// the current-message anchor and the recent-messages block). Consult
|
|
329
|
+
// resolveDisplayName so a row whose cached fromName was written before
|
|
330
|
+
// the roster caught the real displayName (or wire only supplied the uid)
|
|
331
|
+
// still renders with the current human name.
|
|
332
|
+
// resolveDisplayName returns undefined precisely to mean "no real name
|
|
333
|
+
// known, emit bare uid" — do NOT fall back to m.fromName, which is often
|
|
334
|
+
// the uid itself (write-time echo) and would re-create the `uid(uid):`
|
|
335
|
+
// rendering this feature exists to eliminate. formatSenderLabel handles
|
|
336
|
+
// the undefined case by emitting the bare uid.
|
|
337
|
+
const displayName = this.resolveDisplayName(channelId, m.fromUid, m.fromName);
|
|
338
|
+
const line = `${formatSenderLabel(m.fromUid, displayName)}:${m.content}`;
|
|
269
339
|
const cost = line.length + (selected.length > 0 ? 1 : 0);
|
|
270
340
|
if (used + cost > budget)
|
|
271
341
|
break;
|
|
@@ -342,10 +412,19 @@ export class GroupContext {
|
|
|
342
412
|
if (budget <= 0)
|
|
343
413
|
return { text: '', lastId };
|
|
344
414
|
// Walk newest→oldest (rows[0] is newest) keeping lines within budget.
|
|
415
|
+
// Each line renders as `name(uid):content` (or `uid:content` when the name
|
|
416
|
+
// is missing) via formatSenderLabel — the same shape used at the current-
|
|
417
|
+
// message anchor (index.ts) so identity semantics are uniform across the
|
|
418
|
+
// whole prompt. Historically this rendered as `from_name:content` and any
|
|
419
|
+
// downstream reader that pattern-matched had to guess uid from the name.
|
|
420
|
+
// resolveDisplayName lets an old row whose fromName was the uid (wire lacked
|
|
421
|
+
// it at write time) still render with the currently-known displayName once
|
|
422
|
+
// refreshMembers populates the roster.
|
|
345
423
|
const selected = [];
|
|
346
424
|
let used = 0;
|
|
347
425
|
for (let i = 0; i < rows.length; i++) {
|
|
348
|
-
const
|
|
426
|
+
const displayName = this.resolveDisplayName(channelId, rows[i].from_uid, rows[i].from_name);
|
|
427
|
+
const line = `${formatSenderLabel(rows[i].from_uid, displayName)}:${rows[i].content}`;
|
|
349
428
|
const cost = line.length + (selected.length > 0 ? 1 : 0);
|
|
350
429
|
if (used + cost > budget)
|
|
351
430
|
break;
|