agentschat-mcp 0.36.25 → 0.36.27
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 +7 -0
- package/README.md +10 -10
- package/codex/README.md +4 -4
- package/codex/app-server.ts +101 -22
- package/codex/bots-config.ts +32 -11
- package/codex/bridge.ts +127 -28
- package/codex/config.ts +137 -21
- package/codex/gui-channel.ts +66 -9
- package/codex/inbox-sync.ts +77 -12
- package/codex/loop-grants.ts +49 -11
- package/codex/manager.ts +108 -27
- package/codex/owner.ts +106 -9
- package/codex/processes.ts +51 -7
- package/codex/run.ts +70 -17
- package/codex/runtime-home.ts +51 -11
- package/codex/thread-history.ts +87 -30
- package/codex/transport.ts +135 -22
- package/connector/README.md +1 -1
- package/connector/auth.ts +57 -5
- package/connector/backfill.ts +92 -10
- package/connector/descriptor.ts +27 -1
- package/connector/identities.ts +82 -14
- package/connector/ingest.ts +11 -2
- package/connector/normalize.ts +32 -12
- package/connector/run.ts +314 -67
- package/connector/server.ts +95 -26
- package/cordis.patch.yml +4 -2
- package/dist/codex-bots.js +437 -75
- package/dist/codex-bridge.js +2111 -582
- package/dist/connector.js +1300 -493
- package/dist/dsh.js +1789 -299
- package/dist/muse.js +967 -221
- package/dist/server.js +4410 -919
- package/dsh/README.md +1 -1
- package/dsh/client.js +7 -5
- package/dsh/identity-ui/client.js +7 -5
- package/dsh/identity-ui/index.js +43 -8
- package/dsh/inbound-bridge/index.js +677 -154
- package/dsh/src/cli.ts +430 -91
- package/dsh/src/patch.ts +295 -15
- package/dsh/tests/dsh-hardening-127.test.ts +207 -0
- package/dsh/tests/dsh.test.ts +1174 -3
- package/muse/scripts/ensure-muse-wakes.mjs +5 -3
- package/muse/scripts/muse-wake-receiver.mjs +4 -1
- package/muse/src/bridge.ts +54 -13
- package/muse/src/cli.ts +226 -41
- package/muse/src/client.ts +249 -34
- package/muse/src/config.ts +128 -12
- package/muse/src/policy.ts +28 -8
- package/muse/src/types.ts +1 -0
- package/muse/src/typing.ts +18 -1
- package/muse/src/wake.ts +237 -35
- package/muse/tests/bridge.test.mjs +131 -0
- package/muse/tests/client.test.mjs +327 -0
- package/muse/tests/config.test.mjs +78 -1
- package/muse/tests/hardening.test.mjs +199 -0
- package/muse/tests/hardening126.test.mjs +292 -0
- package/muse/tests/policy.test.mjs +83 -1
- package/muse/tests/wake.test.mjs +134 -6
- package/package.json +3 -3
- package/scripts/ensure-grok-wakes.mjs +93 -8
- package/scripts/example-url-wake-receiver.mjs +254 -61
- package/scripts/grok-bind-register.sh +38 -8
- package/skills/onboarding.md +15 -15
- package/src/argcheck.ts +113 -33
- package/src/cli.mjs +100 -16
- package/src/dedup.ts +57 -8
- package/src/grok-bind.ts +182 -33
- package/src/heartbeat.ts +39 -11
- package/src/identity-guard.ts +93 -20
- package/src/identity.ts +67 -11
- package/src/mentions.ts +26 -5
- package/src/onboarding-status.ts +134 -11
- package/src/profile-selection.ts +299 -18
- package/src/profile-store.ts +248 -30
- package/src/read-cursor.ts +280 -9
- package/src/reconnect.ts +98 -2
- package/src/redact.ts +34 -15
- package/src/rest-cli.ts +713 -159
- package/src/server.ts +286 -94
- package/src/session-bind.ts +777 -134
- package/src/session-route.ts +183 -12
- package/src/team-lead-skill.ts +3 -0
- package/src/timestamps.ts +56 -23
- package/src/tool-annotations.ts +10 -1
- package/src/wake.ts +510 -91
package/connector/ingest.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MessageDedup, messageDedupKey } from "../src/dedup.ts";
|
|
2
|
+
import { canonicalCursorTimestamp } from "./backfill.ts";
|
|
2
3
|
import { serverLoopTick, type AgentsChatMessage } from "./normalize.ts";
|
|
3
4
|
|
|
4
5
|
export type IngestIdentity = { botId: string; agentId: string };
|
|
@@ -24,11 +25,19 @@ export function ingestAgentsChatFrame(
|
|
|
24
25
|
dedup: MessageDedup;
|
|
25
26
|
},
|
|
26
27
|
): boolean {
|
|
27
|
-
if (
|
|
28
|
+
if (
|
|
29
|
+
!frame ||
|
|
30
|
+
typeof frame !== "object" ||
|
|
31
|
+
Array.isArray(frame) ||
|
|
32
|
+
Object.prototype.hasOwnProperty.call(frame, "__proto__")
|
|
33
|
+
) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (frame.content !== "__typing__" && canonicalCursorTimestamp(frame.timestamp) !== null) {
|
|
28
37
|
deps.advanceCursor(id, frame.channel_id, frame.timestamp);
|
|
29
38
|
}
|
|
30
39
|
const key = messageDedupKey(frame as { id?: string; channel_id?: string });
|
|
31
|
-
const isDm = frame.channel_id
|
|
40
|
+
const isDm = typeof frame.channel_id === "string" && /^dm[-:]/i.test(frame.channel_id);
|
|
32
41
|
const scopedKey = key && (isDm ? JSON.stringify([id.botId, frame.channel_id, frame.id]) : key);
|
|
33
42
|
if (scopedKey && deps.dedup.recordOrSkip(scopedKey)) return false;
|
|
34
43
|
// Group fanout must filter self per TARGET, not per arrival socket: A can
|
package/connector/normalize.ts
CHANGED
|
@@ -24,6 +24,7 @@ export interface AgentsChatMessage {
|
|
|
24
24
|
content?: string;
|
|
25
25
|
timestamp?: string;
|
|
26
26
|
reply_to?: string;
|
|
27
|
+
parent_id?: string;
|
|
27
28
|
mentions?: string[];
|
|
28
29
|
sender_type?: string;
|
|
29
30
|
content_type?: string;
|
|
@@ -60,26 +61,29 @@ export interface WireEvent {
|
|
|
60
61
|
* not become an agent turn (typing placeholder, or no channel to key a session on).
|
|
61
62
|
*/
|
|
62
63
|
export function toWireEvent(msg: AgentsChatMessage, platform = "agentschat"): WireEvent | null {
|
|
63
|
-
|
|
64
|
+
if (!msg || typeof msg !== "object") return null;
|
|
65
|
+
const content = typeof msg.content === "string" ? msg.content : "";
|
|
64
66
|
if (content === "__typing__") return null;
|
|
65
67
|
|
|
66
|
-
const
|
|
68
|
+
const metadata = (value: string | undefined) =>
|
|
69
|
+
typeof value === "string" ? value.replace(/[\x00-\x1f\x7f-\x9f\u2028\u2029]/g, "") : undefined;
|
|
70
|
+
const chatId = metadata(msg.channel_id) ?? "";
|
|
67
71
|
if (!chatId) return null;
|
|
68
72
|
|
|
69
|
-
const isDm =
|
|
73
|
+
const isDm = /^dm[-:]/i.test(chatId);
|
|
70
74
|
|
|
71
75
|
return {
|
|
72
76
|
text: content,
|
|
73
77
|
message_type: "text",
|
|
74
|
-
message_id: msg.id,
|
|
75
|
-
reply_to_message_id: msg.reply_to,
|
|
78
|
+
message_id: metadata(msg.id),
|
|
79
|
+
reply_to_message_id: metadata(msg.reply_to ?? msg.parent_id),
|
|
76
80
|
source: {
|
|
77
81
|
platform,
|
|
78
82
|
chat_id: chatId,
|
|
79
83
|
chat_type: isDm ? "dm" : "group",
|
|
80
|
-
chat_name:
|
|
81
|
-
user_id: msg.sender_id,
|
|
82
|
-
user_name: msg.sender_name ?? msg.sender_id,
|
|
84
|
+
chat_name: chatId,
|
|
85
|
+
user_id: metadata(msg.sender_id),
|
|
86
|
+
user_name: metadata(msg.sender_name ?? msg.sender_id),
|
|
83
87
|
thread_id: null,
|
|
84
88
|
// scope_id intentionally omitted: agentschat has no guild/scope concept.
|
|
85
89
|
},
|
|
@@ -96,12 +100,25 @@ export interface ServerLoopTick {
|
|
|
96
100
|
expires_at: null;
|
|
97
101
|
}
|
|
98
102
|
|
|
103
|
+
const LOOP_TICK_CTRL_RE = /[\x00-\x1f\x7f-\x9f\u2028\u2029]/;
|
|
104
|
+
|
|
105
|
+
function hasOwnProto(value: unknown): boolean {
|
|
106
|
+
return Boolean(
|
|
107
|
+
value &&
|
|
108
|
+
typeof value === "object" &&
|
|
109
|
+
Object.prototype.hasOwnProperty.call(value, "__proto__"),
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
99
113
|
/** Shape check only. Delivery must additionally verify the bot's live server record. */
|
|
100
114
|
export function serverLoopTick(msg: AgentsChatMessage): ServerLoopTick | null {
|
|
115
|
+
if (!msg || typeof msg !== "object" || hasOwnProto(msg)) return null;
|
|
101
116
|
const meta = msg.meta as Partial<ServerLoopTick> | undefined;
|
|
102
|
-
if (!meta || meta.kind !== "loop_tick" ||
|
|
103
|
-
typeof msg.id !== "string" || !msg.id ||
|
|
104
|
-
typeof msg.
|
|
117
|
+
if (!meta || typeof meta !== "object" || Array.isArray(meta) || hasOwnProto(meta) || meta.kind !== "loop_tick" ||
|
|
118
|
+
typeof msg.id !== "string" || !msg.id || LOOP_TICK_CTRL_RE.test(msg.id) ||
|
|
119
|
+
typeof msg.channel_id !== "string" || !msg.channel_id || LOOP_TICK_CTRL_RE.test(msg.channel_id) ||
|
|
120
|
+
typeof msg.sender_id !== "string" || !msg.sender_id || LOOP_TICK_CTRL_RE.test(msg.sender_id) ||
|
|
121
|
+
msg.sender_type !== "agent" || msg.content_type !== "text" ||
|
|
105
122
|
typeof msg.timestamp !== "string" || !Number.isFinite(Date.parse(msg.timestamp)) ||
|
|
106
123
|
typeof meta.loop_id !== "string" || !/^loop_[a-zA-Z0-9_-]+$/.test(meta.loop_id) ||
|
|
107
124
|
typeof meta.prompt !== "string" || !meta.prompt.trim() || meta.prompt.length > 4000 ||
|
|
@@ -115,9 +132,12 @@ export function serverLoopTick(msg: AgentsChatMessage): ServerLoopTick | null {
|
|
|
115
132
|
export function matchesLiveLoop(msg: AgentsChatMessage, agentId: string, response: unknown): boolean {
|
|
116
133
|
const tick = serverLoopTick(msg);
|
|
117
134
|
if (!tick || msg.sender_id !== agentId) return false;
|
|
135
|
+
if (!response || typeof response !== "object" || Array.isArray(response) || hasOwnProto(response)) return false;
|
|
118
136
|
const rows = (response as {loops?: any[]})?.loops;
|
|
119
137
|
if (!Array.isArray(rows)) return false;
|
|
120
|
-
const matches = rows.filter(
|
|
138
|
+
const matches = rows.filter(
|
|
139
|
+
row => row && typeof row === "object" && !Array.isArray(row) && !hasOwnProto(row) && row.loop_id === tick.loop_id,
|
|
140
|
+
);
|
|
121
141
|
if (matches.length !== 1) return false;
|
|
122
142
|
const row = matches[0];
|
|
123
143
|
return row.status === "active" && row.channel_id === msg.channel_id && row.prompt === tick.prompt &&
|