@mininglamp-oss/cc-channel-octo 1.0.1-dev.60b73f3
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/CHANGELOG.md +349 -0
- package/LICENSE +191 -0
- package/README.md +577 -0
- package/config.bot.example.json +15 -0
- package/config.example.json +33 -0
- package/dist/agent-bridge.d.ts +79 -0
- package/dist/agent-bridge.js +392 -0
- package/dist/agent-bridge.js.map +1 -0
- package/dist/commands.d.ts +57 -0
- package/dist/commands.js +121 -0
- package/dist/commands.js.map +1 -0
- package/dist/config.d.ts +287 -0
- package/dist/config.js +332 -0
- package/dist/config.js.map +1 -0
- package/dist/cron-evaluator.d.ts +53 -0
- package/dist/cron-evaluator.js +191 -0
- package/dist/cron-evaluator.js.map +1 -0
- package/dist/cron-fire-marker.d.ts +24 -0
- package/dist/cron-fire-marker.js +25 -0
- package/dist/cron-fire-marker.js.map +1 -0
- package/dist/cron-scheduler.d.ts +46 -0
- package/dist/cron-scheduler.js +114 -0
- package/dist/cron-scheduler.js.map +1 -0
- package/dist/cron-store.d.ts +62 -0
- package/dist/cron-store.js +63 -0
- package/dist/cron-store.js.map +1 -0
- package/dist/cron-tool.d.ts +44 -0
- package/dist/cron-tool.js +151 -0
- package/dist/cron-tool.js.map +1 -0
- package/dist/cwd-resolver.d.ts +72 -0
- package/dist/cwd-resolver.js +166 -0
- package/dist/cwd-resolver.js.map +1 -0
- package/dist/db-adapter.d.ts +21 -0
- package/dist/db-adapter.js +64 -0
- package/dist/db-adapter.js.map +1 -0
- package/dist/file-inline-wrap.d.ts +94 -0
- package/dist/file-inline-wrap.js +243 -0
- package/dist/file-inline-wrap.js.map +1 -0
- package/dist/gateway.d.ts +100 -0
- package/dist/gateway.js +420 -0
- package/dist/gateway.js.map +1 -0
- package/dist/group-config.d.ts +41 -0
- package/dist/group-config.js +104 -0
- package/dist/group-config.js.map +1 -0
- package/dist/group-context.d.ts +81 -0
- package/dist/group-context.js +466 -0
- package/dist/group-context.js.map +1 -0
- package/dist/inbound.d.ts +136 -0
- package/dist/inbound.js +667 -0
- package/dist/inbound.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +932 -0
- package/dist/index.js.map +1 -0
- package/dist/media-inbound.d.ts +38 -0
- package/dist/media-inbound.js +131 -0
- package/dist/media-inbound.js.map +1 -0
- package/dist/mention-utils.d.ts +108 -0
- package/dist/mention-utils.js +199 -0
- package/dist/mention-utils.js.map +1 -0
- package/dist/octo/api.d.ts +148 -0
- package/dist/octo/api.js +320 -0
- package/dist/octo/api.js.map +1 -0
- package/dist/octo/socket.d.ts +102 -0
- package/dist/octo/socket.js +793 -0
- package/dist/octo/socket.js.map +1 -0
- package/dist/octo/types.d.ts +126 -0
- package/dist/octo/types.js +35 -0
- package/dist/octo/types.js.map +1 -0
- package/dist/prompt-safety.d.ts +78 -0
- package/dist/prompt-safety.js +148 -0
- package/dist/prompt-safety.js.map +1 -0
- package/dist/session-router.d.ts +144 -0
- package/dist/session-router.js +490 -0
- package/dist/session-router.js.map +1 -0
- package/dist/session-store.d.ts +89 -0
- package/dist/session-store.js +297 -0
- package/dist/session-store.js.map +1 -0
- package/dist/skill-linker.d.ts +31 -0
- package/dist/skill-linker.js +160 -0
- package/dist/skill-linker.js.map +1 -0
- package/dist/stream-relay.d.ts +42 -0
- package/dist/stream-relay.js +243 -0
- package/dist/stream-relay.js.map +1 -0
- package/dist/url-policy.d.ts +103 -0
- package/dist/url-policy.js +290 -0
- package/dist/url-policy.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../src/octo/socket.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,kEAAkE;AAClE,sEAAsE;AAEtE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,SAAS,MAAM,IAAI,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,SAAS,EAA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C,EAAE,CAAC,KAAK,EAAE,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;QAAC,CAAC;QAClE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;IAC/B,CAAC;CACF;AAED,+EAA+E;AAE/E,SAAS,gBAAgB;IACvB,OAAO,kCAAkC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;QAC/D,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;QAC1C,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/** Octo Bot API types. */
|
|
2
|
+
export interface BotRegisterResp {
|
|
3
|
+
robot_id: string;
|
|
4
|
+
im_token: string;
|
|
5
|
+
ws_url: string;
|
|
6
|
+
api_url: string;
|
|
7
|
+
owner_uid: string;
|
|
8
|
+
owner_channel_id: string;
|
|
9
|
+
}
|
|
10
|
+
export interface BotMessage {
|
|
11
|
+
message_id: string;
|
|
12
|
+
message_seq: number;
|
|
13
|
+
from_uid: string;
|
|
14
|
+
from_name?: string;
|
|
15
|
+
channel_id?: string;
|
|
16
|
+
channel_type?: ChannelType;
|
|
17
|
+
timestamp: number;
|
|
18
|
+
payload: MessagePayload;
|
|
19
|
+
/** True when this message is part of a streaming sequence (WuKongIM settingByte bit 1). */
|
|
20
|
+
streamOn?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 单个 mention 的精确位置描述。
|
|
24
|
+
* offset/length 的单位为 UTF-16 code units(与 JS string.length 一致)。
|
|
25
|
+
*/
|
|
26
|
+
export interface MentionEntity {
|
|
27
|
+
/** 被 @ 用户的唯一标识符 */
|
|
28
|
+
uid: string;
|
|
29
|
+
/** @name 在 content 中的起始位置(包括 @ 符号) */
|
|
30
|
+
offset: number;
|
|
31
|
+
/** @name 的完整长度(包括 @ 符号) */
|
|
32
|
+
length: number;
|
|
33
|
+
}
|
|
34
|
+
export interface MentionPayload {
|
|
35
|
+
uids?: string[];
|
|
36
|
+
entities?: MentionEntity[];
|
|
37
|
+
/**
|
|
38
|
+
* Legacy "@all" flag. Server outbound double-writes this for legacy clients
|
|
39
|
+
* even after the three-state split landed (server-side semantic: all=humans).
|
|
40
|
+
* Adapter treats `all=1` as a humans-only signal (NOT ais) to match the
|
|
41
|
+
* server's authoritative decision.
|
|
42
|
+
*/
|
|
43
|
+
all?: boolean | number;
|
|
44
|
+
/**
|
|
45
|
+
* Three-state mention (server-authoritative, PR-A landed on octo-server #94).
|
|
46
|
+
* `humans=1` → "@所有人", `ais=1` → "@所有AI". Both can co-exist.
|
|
47
|
+
* Adapter only reads these; it never decides semantics — server is the
|
|
48
|
+
* source of truth and rewrites legacy `all=1` into the canonical form
|
|
49
|
+
* before adapter sees it.
|
|
50
|
+
*/
|
|
51
|
+
humans?: boolean | number;
|
|
52
|
+
ais?: boolean | number;
|
|
53
|
+
}
|
|
54
|
+
export interface ReplyPayload {
|
|
55
|
+
payload?: MessagePayload;
|
|
56
|
+
from_uid?: string;
|
|
57
|
+
from_name?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface MessagePayload {
|
|
60
|
+
type: MessageType;
|
|
61
|
+
content?: string;
|
|
62
|
+
url?: string;
|
|
63
|
+
name?: string;
|
|
64
|
+
mention?: MentionPayload;
|
|
65
|
+
reply?: ReplyPayload;
|
|
66
|
+
event?: {
|
|
67
|
+
type: string;
|
|
68
|
+
version?: number;
|
|
69
|
+
updated_by?: string;
|
|
70
|
+
group_no?: string;
|
|
71
|
+
short_id?: string;
|
|
72
|
+
};
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}
|
|
75
|
+
export interface SendMessageResult {
|
|
76
|
+
message_id: string;
|
|
77
|
+
client_msg_no: string;
|
|
78
|
+
message_seq: number;
|
|
79
|
+
}
|
|
80
|
+
/** Channel types */
|
|
81
|
+
export declare enum ChannelType {
|
|
82
|
+
DM = 1,
|
|
83
|
+
Group = 2,
|
|
84
|
+
CommunityTopic = 5
|
|
85
|
+
}
|
|
86
|
+
/** Message content types */
|
|
87
|
+
export declare enum MessageType {
|
|
88
|
+
Text = 1,
|
|
89
|
+
Image = 2,
|
|
90
|
+
GIF = 3,
|
|
91
|
+
Voice = 4,
|
|
92
|
+
Video = 5,
|
|
93
|
+
Location = 6,
|
|
94
|
+
Card = 7,
|
|
95
|
+
File = 8,
|
|
96
|
+
MultipleForward = 11,
|
|
97
|
+
/** Rich text (text + inline images), introduced in upstream v1.0.x */
|
|
98
|
+
RichText = 14
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* RichText(=14) block type constants.
|
|
102
|
+
*
|
|
103
|
+
* Wire format from upstream uses strings ("text" / "image"), matching the
|
|
104
|
+
* server's RichTextBlockText / RichTextBlockImage tags from octo-lib.
|
|
105
|
+
*/
|
|
106
|
+
export declare const RICH_TEXT_BLOCK_TEXT = "text";
|
|
107
|
+
export declare const RICH_TEXT_BLOCK_IMAGE = "image";
|
|
108
|
+
/** Placeholder rendered for an inline image when assembling plain text. */
|
|
109
|
+
export declare const RICH_TEXT_IMAGE_PLACEHOLDER = "[\u56FE\u7247]";
|
|
110
|
+
export interface ForwardUser {
|
|
111
|
+
uid: string;
|
|
112
|
+
name: string;
|
|
113
|
+
}
|
|
114
|
+
export interface ForwardMessage {
|
|
115
|
+
message_id?: string;
|
|
116
|
+
from_uid: string;
|
|
117
|
+
timestamp?: number;
|
|
118
|
+
payload: {
|
|
119
|
+
type: number;
|
|
120
|
+
content?: string;
|
|
121
|
+
url?: string;
|
|
122
|
+
name?: string;
|
|
123
|
+
users?: ForwardUser[];
|
|
124
|
+
msgs?: ForwardMessage[];
|
|
125
|
+
};
|
|
126
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Forked from openclaw-channel-octo v1.0.13 (2026-06-04)
|
|
2
|
+
// Source: https://github.com/Mininglamp-OSS/openclaw-channel-octo
|
|
3
|
+
/** Channel types */
|
|
4
|
+
export var ChannelType;
|
|
5
|
+
(function (ChannelType) {
|
|
6
|
+
ChannelType[ChannelType["DM"] = 1] = "DM";
|
|
7
|
+
ChannelType[ChannelType["Group"] = 2] = "Group";
|
|
8
|
+
ChannelType[ChannelType["CommunityTopic"] = 5] = "CommunityTopic";
|
|
9
|
+
})(ChannelType || (ChannelType = {}));
|
|
10
|
+
/** Message content types */
|
|
11
|
+
export var MessageType;
|
|
12
|
+
(function (MessageType) {
|
|
13
|
+
MessageType[MessageType["Text"] = 1] = "Text";
|
|
14
|
+
MessageType[MessageType["Image"] = 2] = "Image";
|
|
15
|
+
MessageType[MessageType["GIF"] = 3] = "GIF";
|
|
16
|
+
MessageType[MessageType["Voice"] = 4] = "Voice";
|
|
17
|
+
MessageType[MessageType["Video"] = 5] = "Video";
|
|
18
|
+
MessageType[MessageType["Location"] = 6] = "Location";
|
|
19
|
+
MessageType[MessageType["Card"] = 7] = "Card";
|
|
20
|
+
MessageType[MessageType["File"] = 8] = "File";
|
|
21
|
+
MessageType[MessageType["MultipleForward"] = 11] = "MultipleForward";
|
|
22
|
+
/** Rich text (text + inline images), introduced in upstream v1.0.x */
|
|
23
|
+
MessageType[MessageType["RichText"] = 14] = "RichText";
|
|
24
|
+
})(MessageType || (MessageType = {}));
|
|
25
|
+
/**
|
|
26
|
+
* RichText(=14) block type constants.
|
|
27
|
+
*
|
|
28
|
+
* Wire format from upstream uses strings ("text" / "image"), matching the
|
|
29
|
+
* server's RichTextBlockText / RichTextBlockImage tags from octo-lib.
|
|
30
|
+
*/
|
|
31
|
+
export const RICH_TEXT_BLOCK_TEXT = "text";
|
|
32
|
+
export const RICH_TEXT_BLOCK_IMAGE = "image";
|
|
33
|
+
/** Placeholder rendered for an inline image when assembling plain text. */
|
|
34
|
+
export const RICH_TEXT_IMAGE_PLACEHOLDER = '[图片]';
|
|
35
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/octo/types.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,kEAAkE;AAyFlE,oBAAoB;AACpB,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,yCAAM,CAAA;IACN,+CAAS,CAAA;IACT,iEAAkB,CAAA;AACpB,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB;AAED,4BAA4B;AAC5B,MAAM,CAAN,IAAY,WAYX;AAZD,WAAY,WAAW;IACrB,6CAAQ,CAAA;IACR,+CAAS,CAAA;IACT,2CAAO,CAAA;IACP,+CAAS,CAAA;IACT,+CAAS,CAAA;IACT,qDAAY,CAAA;IACZ,6CAAQ,CAAA;IACR,6CAAQ,CAAA;IACR,oEAAoB,CAAA;IACpB,sEAAsE;IACtE,sDAAa,CAAA;AACf,CAAC,EAZW,WAAW,KAAX,WAAW,QAYtB;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAC3C,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAE7C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt-safety helpers — the SINGLE source of truth for neutralizing
|
|
3
|
+
* user-controlled text before it enters the agent system prompt.
|
|
4
|
+
*
|
|
5
|
+
* Threat: the system prompt is a flat string with structural markers —
|
|
6
|
+
* section headers (`[Group context]`, `[Conversation history]`, `[Quoted
|
|
7
|
+
* message from ...]`) and per-turn role labels (`[user <name>]:`,
|
|
8
|
+
* `[assistant <name>]:`). Every one of those is emitted by OUR renderers. If a
|
|
9
|
+
* user-controlled name or body reproduces one, it forges structure the model
|
|
10
|
+
* then trusts — and in shared-group mode the forged turn is seen by every
|
|
11
|
+
* member (cross-user context poisoning).
|
|
12
|
+
*
|
|
13
|
+
* Coherent policy (defined here, used everywhere):
|
|
14
|
+
* - Names that go INTO a label -> sanitizeDisplayName (strip the label
|
|
15
|
+
* delimiters `[` `]` and line breaks, cap length).
|
|
16
|
+
* - Bodies INSIDE a labeled line -> escapeRoleLabels (escape a line-leading
|
|
17
|
+
* role label so it is inert text, not a turn boundary).
|
|
18
|
+
* - Assembled blocks -> escapeSectionMarkers (escape a line-leading SECTION
|
|
19
|
+
* header). Orthogonal to the above; applied once per block.
|
|
20
|
+
*
|
|
21
|
+
* Escaping is per-FRAGMENT, before the fragment is wrapped in a label — you
|
|
22
|
+
* cannot escape the assembled block, because that would also clobber the
|
|
23
|
+
* legitimate labels our own renderers add.
|
|
24
|
+
*/
|
|
25
|
+
/** Max rendered length for a user display name in a prompt label. */
|
|
26
|
+
export declare const MAX_DISPLAY_NAME_LEN = 128;
|
|
27
|
+
/**
|
|
28
|
+
* The privileged "current message" anchor, emitted by assembleUserMessage
|
|
29
|
+
* (file-inline-wrap.ts) to demarcate the real request from read-only background,
|
|
30
|
+
* and named in SECURITY_PROMPT_PREFIX (agent-bridge.ts) so the model knows to
|
|
31
|
+
* respond only to text after it (#132). SINGLE SOURCE OF TRUTH: both the emitter
|
|
32
|
+
* and the system-prompt reference import this, so the literal (note the em-dash
|
|
33
|
+
* U+2014, not a hyphen) can never silently diverge between the three sites. The
|
|
34
|
+
* SECTION_MARKER_RE above is deliberately broad enough to always escape it even
|
|
35
|
+
* if the suffix is reworded; a unit test pins that invariant.
|
|
36
|
+
*/
|
|
37
|
+
export declare const CURRENT_MESSAGE_ANCHOR = "[Current message \u2014 respond to this ONLY]";
|
|
38
|
+
/**
|
|
39
|
+
* Sanitize a user-controlled display name for safe placement inside a prompt
|
|
40
|
+
* label such as `[user <name>]:` or `[Quoted message from <name>]:`. Strips the
|
|
41
|
+
* label delimiters and line terminators, caps length, and falls back to
|
|
42
|
+
* `fallback` if nothing survives.
|
|
43
|
+
*/
|
|
44
|
+
export declare function sanitizeDisplayName(name: unknown, fallback?: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Escape a line-leading role label in user-authored CONTENT so it renders as
|
|
47
|
+
* literal text inside its turn rather than forging a new turn boundary:
|
|
48
|
+
* `[assistant bot]: x` -> `\[assistant bot]: x`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function escapeRoleLabels(content: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Escape line-leading SECTION markers in an assembled, user-influenced block so
|
|
53
|
+
* a sender cannot inject a fake section boundary. (Formerly
|
|
54
|
+
* `sanitizeForSystemPrompt` in agent-bridge.)
|
|
55
|
+
*/
|
|
56
|
+
export declare function escapeSectionMarkers(text: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Full neutralization for a free-form user-authored BODY embedded in the prompt
|
|
59
|
+
* (reply quotes, forwarded transcripts): escape both role labels and section
|
|
60
|
+
* markers. For per-line-rendered history, the renderer escapes content itself.
|
|
61
|
+
*/
|
|
62
|
+
export declare function sanitizePromptBody(text: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* Branded string that has provably passed through a prompt-safety escaper. It is
|
|
65
|
+
* a plain string at runtime, but only the functions below can MINT one, so a
|
|
66
|
+
* system-prompt assembler that requires `SafeText` for its user-controlled
|
|
67
|
+
* fragments makes "raw user text reached the prompt" a compile error rather than
|
|
68
|
+
* a convention every call site must remember. (Finding #10 — choke-point depth.)
|
|
69
|
+
*/
|
|
70
|
+
export type SafeText = string & {
|
|
71
|
+
readonly __promptSafe: unique symbol;
|
|
72
|
+
};
|
|
73
|
+
/** Mint SafeText from a user-authored BODY (escapes role labels + section markers). */
|
|
74
|
+
export declare function safeBody(text: string): SafeText;
|
|
75
|
+
/** Mint SafeText from already-per-line-escaped content that only needs section-marker escaping (e.g. rendered history). */
|
|
76
|
+
export declare function safeSectioned(text: string): SafeText;
|
|
77
|
+
/** Mint SafeText from operator-TRUSTED text (GROUP.md, config systemPrompt, our own constants) — no escaping, but the brand documents the trust decision at the call site. */
|
|
78
|
+
export declare function trustedText(text: string): SafeText;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt-safety helpers — the SINGLE source of truth for neutralizing
|
|
3
|
+
* user-controlled text before it enters the agent system prompt.
|
|
4
|
+
*
|
|
5
|
+
* Threat: the system prompt is a flat string with structural markers —
|
|
6
|
+
* section headers (`[Group context]`, `[Conversation history]`, `[Quoted
|
|
7
|
+
* message from ...]`) and per-turn role labels (`[user <name>]:`,
|
|
8
|
+
* `[assistant <name>]:`). Every one of those is emitted by OUR renderers. If a
|
|
9
|
+
* user-controlled name or body reproduces one, it forges structure the model
|
|
10
|
+
* then trusts — and in shared-group mode the forged turn is seen by every
|
|
11
|
+
* member (cross-user context poisoning).
|
|
12
|
+
*
|
|
13
|
+
* Coherent policy (defined here, used everywhere):
|
|
14
|
+
* - Names that go INTO a label -> sanitizeDisplayName (strip the label
|
|
15
|
+
* delimiters `[` `]` and line breaks, cap length).
|
|
16
|
+
* - Bodies INSIDE a labeled line -> escapeRoleLabels (escape a line-leading
|
|
17
|
+
* role label so it is inert text, not a turn boundary).
|
|
18
|
+
* - Assembled blocks -> escapeSectionMarkers (escape a line-leading SECTION
|
|
19
|
+
* header). Orthogonal to the above; applied once per block.
|
|
20
|
+
*
|
|
21
|
+
* Escaping is per-FRAGMENT, before the fragment is wrapped in a label — you
|
|
22
|
+
* cannot escape the assembled block, because that would also clobber the
|
|
23
|
+
* legitimate labels our own renderers add.
|
|
24
|
+
*/
|
|
25
|
+
/** Max rendered length for a user display name in a prompt label. */
|
|
26
|
+
export const MAX_DISPLAY_NAME_LEN = 128;
|
|
27
|
+
/**
|
|
28
|
+
* Section markers that delimit structural sections of the system prompt. If
|
|
29
|
+
* these appear at the start of a line inside user-controlled text they are
|
|
30
|
+
* escaped so a sender cannot inject a fake structural boundary (S3 fix).
|
|
31
|
+
*
|
|
32
|
+
* Covers EVERY structural marker any renderer emits \u2014 including the G10
|
|
33
|
+
* segmentation markers (`[answered history]`, `[new messages]`), the group
|
|
34
|
+
* context header (`[Recent group messages]`), the trusted-instructions header
|
|
35
|
+
* (`[Group instructions]`), and the truncation notices \u2014 so user content cannot
|
|
36
|
+
* forge a boundary the model treats as real structure.
|
|
37
|
+
*
|
|
38
|
+
* `Current message[^\]]*` (not the bare `Current message`) matches the FULL
|
|
39
|
+
* anchor `[Current message \u2014 respond to this ONLY]` that assembleUserMessage
|
|
40
|
+
* (#132) prepends to the real request, the same way `Quoted message from [^\]]*`
|
|
41
|
+
* covers its variable suffix. The anchor is a PRIVILEGED marker \u2014 the system
|
|
42
|
+
* prompt tells the model to "respond ONLY to the text after it" \u2014 so a group
|
|
43
|
+
* member who typed it verbatim into a non-@ message (which lands in the
|
|
44
|
+
* [Recent group messages] read-only background) could otherwise forge a second
|
|
45
|
+
* "current message" and have their injected text treated as the request. The
|
|
46
|
+
* bare-`]` form alone left that gap open (#132 review).
|
|
47
|
+
*
|
|
48
|
+
* The exact emitted form is exported as CURRENT_MESSAGE_ANCHOR (single source of
|
|
49
|
+
* truth \u2014 see below). The branch here is intentionally BROADER than that constant
|
|
50
|
+
* (any `[Current message\u2026]` variant is escaped), so the two cannot drift into a
|
|
51
|
+
* gap; a drift-guard test asserts the constant is matched by this regex.
|
|
52
|
+
*
|
|
53
|
+
* The leading `([^\S\r\n]*)` group absorbs indentation (spaces/tabs) before the
|
|
54
|
+
* `[`, mirroring ROLE_LABEL_RE. Without it `^\[` only matched COLUMN-0 markers, so
|
|
55
|
+
* a forged marker preceded by a single space/tab slipped through unescaped \u2014 and
|
|
56
|
+
* group-delta content can contain newlines (group-context.ts), so an attacker can
|
|
57
|
+
* plant an indented line. escapeSectionMarkers preserves the captured whitespace
|
|
58
|
+
* and backslash-escapes the `[` (#133 review: yujiawei P0). `Prior conversation
|
|
59
|
+
* history[^\]]*` is included so the first-turn/fallback history header
|
|
60
|
+
* (index.ts) is covered too \u2014 making the "cannot drift into a gap" claim hold.
|
|
61
|
+
*/
|
|
62
|
+
const SECTION_MARKER_RE = /^([^\S\r\n]*)\[(Group context|Conversation history|Prior conversation history[^\]]*|Current message[^\]]*|Quoted message from [^\]]*|answered history|new messages|Recent group messages|Group instructions|older messages dropped|older turns dropped)\]/gim;
|
|
63
|
+
/**
|
|
64
|
+
* The privileged "current message" anchor, emitted by assembleUserMessage
|
|
65
|
+
* (file-inline-wrap.ts) to demarcate the real request from read-only background,
|
|
66
|
+
* and named in SECURITY_PROMPT_PREFIX (agent-bridge.ts) so the model knows to
|
|
67
|
+
* respond only to text after it (#132). SINGLE SOURCE OF TRUTH: both the emitter
|
|
68
|
+
* and the system-prompt reference import this, so the literal (note the em-dash
|
|
69
|
+
* U+2014, not a hyphen) can never silently diverge between the three sites. The
|
|
70
|
+
* SECTION_MARKER_RE above is deliberately broad enough to always escape it even
|
|
71
|
+
* if the suffix is reworded; a unit test pins that invariant.
|
|
72
|
+
*/
|
|
73
|
+
export const CURRENT_MESSAGE_ANCHOR = '[Current message \u2014 respond to this ONLY]';
|
|
74
|
+
/**
|
|
75
|
+
* Line-leading turn label (`[user ...]:` / `[assistant ...]:`),
|
|
76
|
+
* case-insensitive, multiline. Only line-leading labels are structural;
|
|
77
|
+
* incidental mid-sentence `[assistant ...]` is left alone to minimize false
|
|
78
|
+
* positives. The leading group `[^\S\r\n]*` matches in-line spaces/tabs (never
|
|
79
|
+
* line breaks, which `^` already anchors) so an indented forged label is caught.
|
|
80
|
+
*
|
|
81
|
+
* NOTE: callers must normalizeLineBreaks() the text first \u2014 JS `^`(m) only
|
|
82
|
+
* anchors after LF/CR/LS/PS, NOT NEL(U+0085)/VT(U+000B)/FF(U+000C), which a
|
|
83
|
+
* model may still treat as a new line.
|
|
84
|
+
*/
|
|
85
|
+
const ROLE_LABEL_RE = /^([^\S\r\n]*)(\[(?:user|assistant)\b[^\]\r\n]*\]:)/gim;
|
|
86
|
+
/** Bracket delimiters + all line/para separators that could forge a boundary. */
|
|
87
|
+
const NAME_UNSAFE_RE = /[[\]\r\n\v\f\u0085\u2028\u2029]/g;
|
|
88
|
+
/**
|
|
89
|
+
* Unicode line/paragraph separators that JS regex `^`(m) does NOT anchor on but
|
|
90
|
+
* a model may render as a new line: NEL, VT, FF. Normalized to `\n` before
|
|
91
|
+
* label/section escaping so a forged marker after one of them is still caught.
|
|
92
|
+
*/
|
|
93
|
+
const EXTRA_LINE_BREAKS_RE = /[\v\f\u0085]/g;
|
|
94
|
+
function normalizeLineBreaks(text) {
|
|
95
|
+
return text.replace(EXTRA_LINE_BREAKS_RE, '\n');
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Sanitize a user-controlled display name for safe placement inside a prompt
|
|
99
|
+
* label such as `[user <name>]:` or `[Quoted message from <name>]:`. Strips the
|
|
100
|
+
* label delimiters and line terminators, caps length, and falls back to
|
|
101
|
+
* `fallback` if nothing survives.
|
|
102
|
+
*/
|
|
103
|
+
export function sanitizeDisplayName(name, fallback = '') {
|
|
104
|
+
const cleaned = String(name ?? '')
|
|
105
|
+
.replace(NAME_UNSAFE_RE, ' ')
|
|
106
|
+
.slice(0, MAX_DISPLAY_NAME_LEN)
|
|
107
|
+
.trim();
|
|
108
|
+
return cleaned.length > 0 ? cleaned : fallback;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Escape a line-leading role label in user-authored CONTENT so it renders as
|
|
112
|
+
* literal text inside its turn rather than forging a new turn boundary:
|
|
113
|
+
* `[assistant bot]: x` -> `\[assistant bot]: x`.
|
|
114
|
+
*/
|
|
115
|
+
export function escapeRoleLabels(content) {
|
|
116
|
+
return normalizeLineBreaks(content).replace(ROLE_LABEL_RE, (_m, ws, label) => `${ws}\\${label}`);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Escape line-leading SECTION markers in an assembled, user-influenced block so
|
|
120
|
+
* a sender cannot inject a fake section boundary. (Formerly
|
|
121
|
+
* `sanitizeForSystemPrompt` in agent-bridge.)
|
|
122
|
+
*/
|
|
123
|
+
export function escapeSectionMarkers(text) {
|
|
124
|
+
// ws = captured leading indentation (preserved); inner = marker name. Escaping
|
|
125
|
+
// the `[` after the whitespace neutralizes both column-0 and indented forgeries.
|
|
126
|
+
return normalizeLineBreaks(text).replace(SECTION_MARKER_RE, (_m, ws, inner) => `${ws}\\[${inner}]`);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Full neutralization for a free-form user-authored BODY embedded in the prompt
|
|
130
|
+
* (reply quotes, forwarded transcripts): escape both role labels and section
|
|
131
|
+
* markers. For per-line-rendered history, the renderer escapes content itself.
|
|
132
|
+
*/
|
|
133
|
+
export function sanitizePromptBody(text) {
|
|
134
|
+
return escapeSectionMarkers(escapeRoleLabels(text));
|
|
135
|
+
}
|
|
136
|
+
/** Mint SafeText from a user-authored BODY (escapes role labels + section markers). */
|
|
137
|
+
export function safeBody(text) {
|
|
138
|
+
return sanitizePromptBody(text);
|
|
139
|
+
}
|
|
140
|
+
/** Mint SafeText from already-per-line-escaped content that only needs section-marker escaping (e.g. rendered history). */
|
|
141
|
+
export function safeSectioned(text) {
|
|
142
|
+
return escapeSectionMarkers(text);
|
|
143
|
+
}
|
|
144
|
+
/** Mint SafeText from operator-TRUSTED text (GROUP.md, config systemPrompt, our own constants) — no escaping, but the brand documents the trust decision at the call site. */
|
|
145
|
+
export function trustedText(text) {
|
|
146
|
+
return text;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=prompt-safety.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-safety.js","sourceRoot":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AAY;IAC/C,+EAA+E;IAC/E,iFAAiF;IACjF,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,OAAO,CACtC,iBAAiB,EACjB,CAAC,EAAE,EAAE,EAAU,EAAE,KAAa,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CACvD,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,oBAAoB,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;AACtD,CAAC;AAWD,uFAAuF;AACvF,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,OAAO,kBAAkB,CAAC,IAAI,CAAa,CAAC;AAC9C,CAAC;AAED,2HAA2H;AAC3H,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,oBAAoB,CAAC,IAAI,CAAa,CAAC;AAChD,CAAC;AAED,8KAA8K;AAC9K,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,IAAgB,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Router — routing + concurrency control + mention gate + rate limiting.
|
|
3
|
+
*/
|
|
4
|
+
import type { Config } from './config.js';
|
|
5
|
+
import type { BotMessage } from './octo/types.js';
|
|
6
|
+
export interface RouteResult {
|
|
7
|
+
sessionKey: string;
|
|
8
|
+
shouldProcess: boolean;
|
|
9
|
+
message: BotMessage;
|
|
10
|
+
/** User content with leading @botname stripped (for LLM input). */
|
|
11
|
+
cleanContent?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Reason for rejection when shouldProcess is false.
|
|
14
|
+
*
|
|
15
|
+
* Only emitted for cases where the caller should treat the message as
|
|
16
|
+
* 'do-not-cache-in-group-context' (rate-limited or oversized — these are
|
|
17
|
+
* actively-rejected messages from a flooder). Silent-drop cases (blocked
|
|
18
|
+
* bot, self message, system event, not mentioned) leave rejectionReason
|
|
19
|
+
* undefined: those messages are legitimate group chatter the agent
|
|
20
|
+
* should still see in [Group context].
|
|
21
|
+
*
|
|
22
|
+
* C1 / P2.5 (Stage 6): added to fix the channel where rate-limited or
|
|
23
|
+
* oversized messages still polluted the group context cache. C1 follow-up
|
|
24
|
+
* cleanup (齐静春 PR#41 review): trimmed to the 2 reasons actually emitted
|
|
25
|
+
* so the type doesn't suggest a wider contract than the code provides.
|
|
26
|
+
* Add more reasons here when corresponding emit sites land.
|
|
27
|
+
*/
|
|
28
|
+
rejectionReason?: 'rate_limited' | 'oversized';
|
|
29
|
+
}
|
|
30
|
+
export declare class SessionRouter {
|
|
31
|
+
private readonly config;
|
|
32
|
+
private readonly robotId;
|
|
33
|
+
/** G18: owner_uid from registerBot. Stored for future permission model. */
|
|
34
|
+
private readonly ownerUid;
|
|
35
|
+
private readonly inboundQueues;
|
|
36
|
+
private readonly tokenBuckets;
|
|
37
|
+
/** G20: per-user buckets keyed by from_uid alone (cross-channel rate limit). */
|
|
38
|
+
private readonly userBuckets;
|
|
39
|
+
private globalBucket;
|
|
40
|
+
/**
|
|
41
|
+
* G14: UIDs known to be bots. Initialized with this bot's robotId; can be
|
|
42
|
+
* extended via registerKnownBot() for future multi-bot deployments.
|
|
43
|
+
*/
|
|
44
|
+
private readonly knownBotUids;
|
|
45
|
+
constructor(config: Config, robotId: string, ownerUid?: string);
|
|
46
|
+
/** G14: register another known bot uid (future multi-bot support). */
|
|
47
|
+
registerKnownBot(uid: string): void;
|
|
48
|
+
/** G18: owner_uid stored from registerBot. Used by future permission model. */
|
|
49
|
+
getOwnerUid(): string;
|
|
50
|
+
/**
|
|
51
|
+
* Acquire a per-session lock for the full message handling pipeline.
|
|
52
|
+
* Callers (e.g. index.ts) use this to ensure the entire handleMessage
|
|
53
|
+
* chain — not just routing — runs serially per session key.
|
|
54
|
+
*/
|
|
55
|
+
withSessionLock<T>(key: string, fn: () => Promise<T>): Promise<T>;
|
|
56
|
+
/**
|
|
57
|
+
* Route a message and, if it should be processed, run the handler callback
|
|
58
|
+
* under the same per-session lock. This ensures no gap between route decision
|
|
59
|
+
* and pipeline execution — concurrent same-session messages cannot interleave.
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* Route a message and, if it should be processed, run the handler callback
|
|
63
|
+
* under the same per-session lock. This ensures no gap between route decision
|
|
64
|
+
* and pipeline execution — concurrent same-session messages cannot interleave.
|
|
65
|
+
*
|
|
66
|
+
* Returns the RouteResult (or `null` for silent-drop cases) so the caller
|
|
67
|
+
* can inspect `rejectionReason` to decide whether the message should still
|
|
68
|
+
* influence downstream side-effects like group context caching
|
|
69
|
+
* (C1 / P2.5 — stage 6).
|
|
70
|
+
*/
|
|
71
|
+
routeAndHandle(msg: BotMessage, handler: (result: RouteResult) => Promise<void>): Promise<RouteResult | null>;
|
|
72
|
+
/**
|
|
73
|
+
* #141: Run the handler under a dispatch timeout so a hung turn (a stuck SDK
|
|
74
|
+
* query, a wedged tool subprocess, a stalled stream) cannot block the session
|
|
75
|
+
* forever. The handler runs inside withSessionLock — if it never returns, the
|
|
76
|
+
* lock's gate never resolves and EVERY subsequent message for this session is
|
|
77
|
+
* stuck permanently (silent). Racing the handler against a timeout guarantees
|
|
78
|
+
* the lock releases.
|
|
79
|
+
*
|
|
80
|
+
* Scope (mirrors openclaw #75): we do NOT cancel the in-flight turn — the SDK
|
|
81
|
+
* query keeps running to completion in the background; we only unblock the
|
|
82
|
+
* queue. Worst case is a delayed real reply arriving after the apology.
|
|
83
|
+
*
|
|
84
|
+
* `timeoutError` is a per-invocation Error so the catch identifies OUR timeout
|
|
85
|
+
* by reference equality, never by string comparison (a same-text upstream
|
|
86
|
+
* error must not be misclassified).
|
|
87
|
+
*/
|
|
88
|
+
private runHandlerWithTimeout;
|
|
89
|
+
route(msg: BotMessage): Promise<RouteResult | null>;
|
|
90
|
+
sessionKey(msg: BotMessage): string;
|
|
91
|
+
/**
|
|
92
|
+
* Extract spaceId from channel_id.
|
|
93
|
+
* DM format: s{spaceId}_{uid1}@s{spaceId}_{uid2}
|
|
94
|
+
* Group format: s{spaceId}_{groupNo} (but groups already use channel_id in key)
|
|
95
|
+
*/
|
|
96
|
+
private extractSpaceId;
|
|
97
|
+
private isBlockedBot;
|
|
98
|
+
/**
|
|
99
|
+
* G14: Heuristic bot detection. Octo bot uids conventionally end in `_bot`.
|
|
100
|
+
* This is NOT a perfect check — a human could pick that suffix — but it
|
|
101
|
+
* catches the common case where a bot DMs another bot and triggers an
|
|
102
|
+
* uncontrolled response loop. Bots whitelisted in `allowedBotUids` bypass
|
|
103
|
+
* this gate.
|
|
104
|
+
*/
|
|
105
|
+
private looksLikeBot;
|
|
106
|
+
private isAllowedBot;
|
|
107
|
+
private isGroupLike;
|
|
108
|
+
/**
|
|
109
|
+
* Allowlist of channel types we actually converse on: DM, Group, and
|
|
110
|
+
* CommunityTopic. Octo also emits system/command channels (e.g. channel_type
|
|
111
|
+
* 8 "systemcmdonline" on connect) which are NOT user conversations — those
|
|
112
|
+
* must be dropped, otherwise they fall through the DM/group gates and get
|
|
113
|
+
* answered with an unsolicited LLM reply. Found in live deployment (#68).
|
|
114
|
+
*/
|
|
115
|
+
private isSupportedChannel;
|
|
116
|
+
private isMentioned;
|
|
117
|
+
/**
|
|
118
|
+
* #115: True for a GENUINE in-process cron fire — `payload._cronFire` AND a
|
|
119
|
+
* matching per-process nonce. Such messages bypass the group @mention gate
|
|
120
|
+
* (owner-gated at creation, bound to this session). A forged inbound payload
|
|
121
|
+
* can set `_cronFire` but not the secret nonce, so it does not pass. Real
|
|
122
|
+
* inbound messages never carry the marker.
|
|
123
|
+
*/
|
|
124
|
+
private isCronFire;
|
|
125
|
+
private processMessage;
|
|
126
|
+
/**
|
|
127
|
+
* G20 fix: Check all three rate limits (global, per-session, per-user) in
|
|
128
|
+
* one pass. Refills all three buckets, then either consumes 1 token from
|
|
129
|
+
* each (when all pass) or returns the blocking bucket (when any fails).
|
|
130
|
+
*
|
|
131
|
+
* Returns null on success (tokens consumed), or the blocking bucket on
|
|
132
|
+
* failure (no tokens consumed). The caller uses the blocking bucket's
|
|
133
|
+
* `notified` flag to debounce the "请稍后再试" reply per-bucket, so a user
|
|
134
|
+
* blocked by per-user limit doesn't get spammed when their per-session
|
|
135
|
+
* bucket still has tokens.
|
|
136
|
+
*/
|
|
137
|
+
private checkAllRateLimits;
|
|
138
|
+
private getOrCreateBucket;
|
|
139
|
+
private getOrCreateGlobalBucket;
|
|
140
|
+
private refillBucket;
|
|
141
|
+
/** Remove token buckets that haven't been used in 5 minutes. */
|
|
142
|
+
private cleanStaleBuckets;
|
|
143
|
+
private replySafe;
|
|
144
|
+
}
|