agentschat-mcp 0.36.23 → 0.36.24
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/codex/README.md +14 -0
- package/codex/app-server.ts +28 -2
- package/codex/bridge.ts +2 -0
- package/codex/run.ts +7 -1
- package/dist/codex-bridge.js +33 -3
- package/dist/server.js +957 -65
- package/package.json +3 -2
- package/skills/onboarding.md +16 -1
- package/src/cli.mjs +42 -0
- package/src/rest-cli.ts +774 -0
- package/src/server.ts +159 -16
- package/src/session-bind.ts +22 -5
package/codex/README.md
CHANGED
|
@@ -510,3 +510,17 @@ same prompt in the local grant. Project context stays in channel docs and the
|
|
|
510
510
|
existing conversation. A no-change run can return `[[AGENTSCHAT_NO_UPDATE]]` alone:
|
|
511
511
|
only this recognized scheduled skill stores `skipped` and sends no reply. Ordinary
|
|
512
512
|
chat, unknown skills and other loops retain normal reply behavior.
|
|
513
|
+
|
|
514
|
+
### Tool identity and readiness
|
|
515
|
+
|
|
516
|
+
The bridge installs its own process-scoped agentschat MCP entry from the same
|
|
517
|
+
package. It passes only the private profile path, expected agent ID and service
|
|
518
|
+
URLs, never a bearer token in command arguments. This entry overrides inherited
|
|
519
|
+
selectors and refuses identity switching; change the bot registry and restart
|
|
520
|
+
the bot to select a different identity. Tool-only mode avoids a duplicate socket.
|
|
521
|
+
|
|
522
|
+
Full-access startup and --check verify the selected AgentsChat account; the MCP
|
|
523
|
+
child also verifies authentication before becoming available. Read-only mode
|
|
524
|
+
disables tools. Manager status connected means chat transport connected, not
|
|
525
|
+
proof that every MCP tool or downstream model is healthy. --check does not
|
|
526
|
+
generate a model response or establish production message/reply proof.
|
package/codex/app-server.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn, type ChildProcessWithoutNullStreams } from "node:child_process";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
2
3
|
import { createInterface } from "node:readline";
|
|
3
4
|
import type { ThreadHistory } from "./thread-history.ts";
|
|
4
5
|
import type { PermissionMode, ReasoningEffort } from "./config.ts";
|
|
@@ -22,15 +23,40 @@ export class AppServer {
|
|
|
22
23
|
private diagnosticTail = "";
|
|
23
24
|
private disabledMcp: Record<string, { enabled: boolean }> = {};
|
|
24
25
|
// Keep the legacy positional argument for callers; turns have no time limit.
|
|
25
|
-
constructor(private bin = "codex", private args = ["app-server", "--listen", "stdio://"], _legacyTurnTimeoutMs?: number, private permissions: PermissionMode = "full-access", private runtime?: {home: string; legacyHome?: string}, private effort?: ReasoningEffort, private model?: string) {}
|
|
26
|
+
constructor(private bin = "codex", private args = ["app-server", "--listen", "stdio://"], _legacyTurnTimeoutMs?: number, private permissions: PermissionMode = "full-access", private runtime?: {home: string; legacyHome?: string}, private effort?: ReasoningEffort, private model?: string, private toolIdentity?: { profileFile: string; agentId: string; apiUrl: string; wsUrl: string }) {}
|
|
26
27
|
get namespace() { return this.runtime?.home; }
|
|
27
28
|
async start() {
|
|
28
29
|
const env = Object.fromEntries(Object.entries(process.env).filter(([k]) => !/^AGENTS?CHAT_|^RELAY_/.test(k)));
|
|
29
30
|
env.AGENTSCHAT_LOCK_OWNER_PID = String(process.pid);
|
|
30
31
|
env.AGENTSCHAT_TOOL_ONLY = "1";
|
|
32
|
+
if (this.toolIdentity) {
|
|
33
|
+
env.AGENTSCHAT_CODEX_IDENTITY = JSON.stringify(this.toolIdentity);
|
|
34
|
+
env.AGENTSCHAT_EXPECT_AGENT_ID = this.toolIdentity.agentId;
|
|
35
|
+
}
|
|
31
36
|
if (this.runtime) { env.CODEX_HOME = this.runtime.home; env.CODEX_SQLITE_HOME = this.runtime.home; }
|
|
32
37
|
const args = this.runtime && this.args[0] === "app-server"
|
|
33
|
-
? [...this.args, "-c", `sqlite_home=${JSON.stringify(this.runtime.home)}`] : this.args;
|
|
38
|
+
? [...this.args, "-c", `sqlite_home=${JSON.stringify(this.runtime.home)}`] : [...this.args];
|
|
39
|
+
if (this.toolIdentity && this.args[0] === "app-server") {
|
|
40
|
+
// Codex filters child environment variables. Supply an explicit MCP entry
|
|
41
|
+
// instead of depending on parent env inheritance or a global plugin version.
|
|
42
|
+
const entry = {
|
|
43
|
+
command: process.execPath,
|
|
44
|
+
args: [fileURLToPath(new URL("../src/cli.mjs", import.meta.url))],
|
|
45
|
+
enabled: this.permissions !== "read-only",
|
|
46
|
+
env: {
|
|
47
|
+
AGENTSCHAT_CODEX_IDENTITY: JSON.stringify(this.toolIdentity),
|
|
48
|
+
AGENTSCHAT_EXPECT_AGENT_ID: this.toolIdentity.agentId,
|
|
49
|
+
AGENTSCHAT_TOOL_ONLY: "1",
|
|
50
|
+
AGENTSCHAT_LOCK_OWNER_PID: String(process.pid),
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
// Replace the complete entry, including stale url/bearer/env fields from
|
|
54
|
+
// operator config. JSON objects are not TOML inline tables.
|
|
55
|
+
const encode = (value: unknown): string => value && typeof value === "object" && !Array.isArray(value)
|
|
56
|
+
? `{ ${Object.entries(value).map(([k, v]) => `${JSON.stringify(k)} = ${encode(v)}`).join(", ")} }`
|
|
57
|
+
: JSON.stringify(value);
|
|
58
|
+
args.push("-c", `mcp_servers.agentschat=${encode(entry)}`);
|
|
59
|
+
}
|
|
34
60
|
this.child = spawn(this.bin, args, { env, stdio: "pipe" });
|
|
35
61
|
// Child diagnostics may contain account or MCP credentials; never relay raw stderr.
|
|
36
62
|
this.child.stderr.on("data", (chunk: Buffer) => {
|
package/codex/bridge.ts
CHANGED
|
@@ -82,6 +82,8 @@ export class Bridge {
|
|
|
82
82
|
// Only retain the wire fields used by this bridge; no protocol instructions.
|
|
83
83
|
const tick = raw.meta?.kind === "loop_tick" ? raw.meta : undefined;
|
|
84
84
|
const message: ChatMessage = { id: raw.id, channel_id: raw.channel_id, sender_id: raw.sender_id,
|
|
85
|
+
...(Array.isArray(raw.mentioned_ids) ? { mentioned_ids: raw.mentioned_ids.filter((id: unknown) => typeof id === "string") } : {}),
|
|
86
|
+
...(Array.isArray(raw.mentions) ? { mentions: raw.mentions.filter((id: unknown) => typeof id === "string") } : {}),
|
|
85
87
|
content: tick ? "Authorized scheduled loop" : this.redact(raw.content),
|
|
86
88
|
...(tick ? { meta: { kind: "loop_tick", loop_id: tick.loop_id, interval_ms: tick.interval_ms,
|
|
87
89
|
next_tick_ms: tick.next_tick_ms, prompt: tick.prompt } as LoopTick } : {}) };
|
package/codex/run.ts
CHANGED
|
@@ -70,7 +70,7 @@ async function main() {
|
|
|
70
70
|
}
|
|
71
71
|
console.log(JSON.stringify({ cwd: c.cwd, agent_id: c.agentId, profile: c.profileFile, source: c.source, stateDir: c.stateDir }));
|
|
72
72
|
const runtime = prepareRuntimeHome(c.stateDir, undefined, c.codexHomeMode, c.codexBin);
|
|
73
|
-
codex = new AppServer(c.codexBin, undefined, undefined, c.permissions, runtime, c.effort, c.model);
|
|
73
|
+
codex = new AppServer(c.codexBin, undefined, undefined, c.permissions, runtime, c.effort, c.model, { profileFile: c.profileFile, agentId: c.agentId, apiUrl: c.apiUrl, wsUrl: c.wsUrl });
|
|
74
74
|
if (values.conversations || values["read-conversation"]) {
|
|
75
75
|
const state = JSON.parse(readFileSync(join(c.stateDir, "state.json"), "utf8"));
|
|
76
76
|
const channels = state.channels ?? {};
|
|
@@ -83,6 +83,12 @@ async function main() {
|
|
|
83
83
|
console.log(redactSecrets(JSON.stringify(history).split(c.token).join("[REDACTED]")));
|
|
84
84
|
codex.close(); return;
|
|
85
85
|
}
|
|
86
|
+
if (c.permissions === "full-access") {
|
|
87
|
+
const identityStatus = await getOnboardingStatus(c.apiUrl, c.agentId, c.token);
|
|
88
|
+
if (identityStatus.authentication !== "ok")
|
|
89
|
+
throw new Error("AgentsChat authentication failed or unavailable; tool identity is not ready");
|
|
90
|
+
console.log("AgentsChat selected identity authentication: OK; MCP startup also verifies this identity");
|
|
91
|
+
}
|
|
86
92
|
if (values.check) {
|
|
87
93
|
await codex.start();
|
|
88
94
|
console.log("Official app-server initialization: OK (no chat connection or generation)");
|
package/dist/codex-bridge.js
CHANGED
|
@@ -1398,6 +1398,7 @@ import { parseArgs } from "node:util";
|
|
|
1398
1398
|
|
|
1399
1399
|
// codex/app-server.ts
|
|
1400
1400
|
import { spawn } from "node:child_process";
|
|
1401
|
+
import { fileURLToPath } from "node:url";
|
|
1401
1402
|
import { createInterface } from "node:readline";
|
|
1402
1403
|
|
|
1403
1404
|
class ThreadBusyError extends Error {
|
|
@@ -1414,6 +1415,7 @@ class AppServer {
|
|
|
1414
1415
|
runtime;
|
|
1415
1416
|
effort;
|
|
1416
1417
|
model;
|
|
1418
|
+
toolIdentity;
|
|
1417
1419
|
onFatal;
|
|
1418
1420
|
closed = false;
|
|
1419
1421
|
child;
|
|
@@ -1425,13 +1427,14 @@ class AppServer {
|
|
|
1425
1427
|
readonlyFilesystemReported = false;
|
|
1426
1428
|
diagnosticTail = "";
|
|
1427
1429
|
disabledMcp = {};
|
|
1428
|
-
constructor(bin = "codex", args = ["app-server", "--listen", "stdio://"], _legacyTurnTimeoutMs, permissions = "full-access", runtime, effort, model) {
|
|
1430
|
+
constructor(bin = "codex", args = ["app-server", "--listen", "stdio://"], _legacyTurnTimeoutMs, permissions = "full-access", runtime, effort, model, toolIdentity) {
|
|
1429
1431
|
this.bin = bin;
|
|
1430
1432
|
this.args = args;
|
|
1431
1433
|
this.permissions = permissions;
|
|
1432
1434
|
this.runtime = runtime;
|
|
1433
1435
|
this.effort = effort;
|
|
1434
1436
|
this.model = model;
|
|
1437
|
+
this.toolIdentity = toolIdentity;
|
|
1435
1438
|
}
|
|
1436
1439
|
get namespace() {
|
|
1437
1440
|
return this.runtime?.home;
|
|
@@ -1440,11 +1443,30 @@ class AppServer {
|
|
|
1440
1443
|
const env = Object.fromEntries(Object.entries(process.env).filter(([k]) => !/^AGENTS?CHAT_|^RELAY_/.test(k)));
|
|
1441
1444
|
env.AGENTSCHAT_LOCK_OWNER_PID = String(process.pid);
|
|
1442
1445
|
env.AGENTSCHAT_TOOL_ONLY = "1";
|
|
1446
|
+
if (this.toolIdentity) {
|
|
1447
|
+
env.AGENTSCHAT_CODEX_IDENTITY = JSON.stringify(this.toolIdentity);
|
|
1448
|
+
env.AGENTSCHAT_EXPECT_AGENT_ID = this.toolIdentity.agentId;
|
|
1449
|
+
}
|
|
1443
1450
|
if (this.runtime) {
|
|
1444
1451
|
env.CODEX_HOME = this.runtime.home;
|
|
1445
1452
|
env.CODEX_SQLITE_HOME = this.runtime.home;
|
|
1446
1453
|
}
|
|
1447
|
-
const args = this.runtime && this.args[0] === "app-server" ? [...this.args, "-c", `sqlite_home=${JSON.stringify(this.runtime.home)}`] : this.args;
|
|
1454
|
+
const args = this.runtime && this.args[0] === "app-server" ? [...this.args, "-c", `sqlite_home=${JSON.stringify(this.runtime.home)}`] : [...this.args];
|
|
1455
|
+
if (this.toolIdentity && this.args[0] === "app-server") {
|
|
1456
|
+
const entry = {
|
|
1457
|
+
command: process.execPath,
|
|
1458
|
+
args: [fileURLToPath(new URL("../src/cli.mjs", import.meta.url))],
|
|
1459
|
+
enabled: this.permissions !== "read-only",
|
|
1460
|
+
env: {
|
|
1461
|
+
AGENTSCHAT_CODEX_IDENTITY: JSON.stringify(this.toolIdentity),
|
|
1462
|
+
AGENTSCHAT_EXPECT_AGENT_ID: this.toolIdentity.agentId,
|
|
1463
|
+
AGENTSCHAT_TOOL_ONLY: "1",
|
|
1464
|
+
AGENTSCHAT_LOCK_OWNER_PID: String(process.pid)
|
|
1465
|
+
}
|
|
1466
|
+
};
|
|
1467
|
+
const encode = (value) => value && typeof value === "object" && !Array.isArray(value) ? `{ ${Object.entries(value).map(([k, v]) => `${JSON.stringify(k)} = ${encode(v)}`).join(", ")} }` : JSON.stringify(value);
|
|
1468
|
+
args.push("-c", `mcp_servers.agentschat=${encode(entry)}`);
|
|
1469
|
+
}
|
|
1448
1470
|
this.child = spawn(this.bin, args, { env, stdio: "pipe" });
|
|
1449
1471
|
this.child.stderr.on("data", (chunk) => {
|
|
1450
1472
|
if (this.initialized)
|
|
@@ -2017,6 +2039,8 @@ class Bridge {
|
|
|
2017
2039
|
id: raw.id,
|
|
2018
2040
|
channel_id: raw.channel_id,
|
|
2019
2041
|
sender_id: raw.sender_id,
|
|
2042
|
+
...Array.isArray(raw.mentioned_ids) ? { mentioned_ids: raw.mentioned_ids.filter((id) => typeof id === "string") } : {},
|
|
2043
|
+
...Array.isArray(raw.mentions) ? { mentions: raw.mentions.filter((id) => typeof id === "string") } : {},
|
|
2020
2044
|
content: tick ? "Authorized scheduled loop" : this.redact(raw.content),
|
|
2021
2045
|
...tick ? { meta: {
|
|
2022
2046
|
kind: "loop_tick",
|
|
@@ -2682,7 +2706,7 @@ async function main() {
|
|
|
2682
2706
|
}
|
|
2683
2707
|
console.log(JSON.stringify({ cwd: c.cwd, agent_id: c.agentId, profile: c.profileFile, source: c.source, stateDir: c.stateDir }));
|
|
2684
2708
|
const runtime = prepareRuntimeHome(c.stateDir, undefined, c.codexHomeMode, c.codexBin);
|
|
2685
|
-
codex = new AppServer(c.codexBin, undefined, undefined, c.permissions, runtime, c.effort, c.model);
|
|
2709
|
+
codex = new AppServer(c.codexBin, undefined, undefined, c.permissions, runtime, c.effort, c.model, { profileFile: c.profileFile, agentId: c.agentId, apiUrl: c.apiUrl, wsUrl: c.wsUrl });
|
|
2686
2710
|
if (values.conversations || values["read-conversation"]) {
|
|
2687
2711
|
const state = JSON.parse(readFileSync10(join10(c.stateDir, "state.json"), "utf8"));
|
|
2688
2712
|
const channels = state.channels ?? {};
|
|
@@ -2701,6 +2725,12 @@ async function main() {
|
|
|
2701
2725
|
codex.close();
|
|
2702
2726
|
return;
|
|
2703
2727
|
}
|
|
2728
|
+
if (c.permissions === "full-access") {
|
|
2729
|
+
const identityStatus = await getOnboardingStatus(c.apiUrl, c.agentId, c.token);
|
|
2730
|
+
if (identityStatus.authentication !== "ok")
|
|
2731
|
+
throw new Error("AgentsChat authentication failed or unavailable; tool identity is not ready");
|
|
2732
|
+
console.log("AgentsChat selected identity authentication: OK; MCP startup also verifies this identity");
|
|
2733
|
+
}
|
|
2704
2734
|
if (values.check) {
|
|
2705
2735
|
await codex.start();
|
|
2706
2736
|
console.log("Official app-server initialization: OK (no chat connection or generation)");
|