@ken-jo/agent-connector 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +176 -24
- package/dist/{amp-QSFH2V7Y.js → amp-YGV66GJT.js} +9 -2
- package/dist/amp-YGV66GJT.js.map +1 -0
- package/dist/{antigravity-CX2YLSY7.js → antigravity-7IBYFO6P.js} +4 -3
- package/dist/{antigravity-cli-YQDFVV4U.js → antigravity-cli-JEOUP2VN.js} +4 -3
- package/dist/{antigravity-cli-YQDFVV4U.js.map → antigravity-cli-JEOUP2VN.js.map} +1 -1
- package/dist/{chunk-LTT56GI3.js → chunk-3JCRUROU.js} +18 -5
- package/dist/chunk-3JCRUROU.js.map +1 -0
- package/dist/{chunk-YNZU6PAV.js → chunk-4ML7SZ7R.js} +69 -16
- package/dist/chunk-4ML7SZ7R.js.map +1 -0
- package/dist/{chunk-54EMKTTX.js → chunk-AKJGNTU3.js} +17 -17
- package/dist/chunk-AKJGNTU3.js.map +1 -0
- package/dist/chunk-GSGDG2BV.js +568 -0
- package/dist/chunk-GSGDG2BV.js.map +1 -0
- package/dist/{chunk-TRKWUNO4.js → chunk-KQSNDFBN.js} +13 -2
- package/dist/chunk-KQSNDFBN.js.map +1 -0
- package/dist/chunk-N6HH7K6P.js +494 -0
- package/dist/chunk-N6HH7K6P.js.map +1 -0
- package/dist/{chunk-XUCWLJY5.js → chunk-O2SBA5KR.js} +30 -30
- package/dist/{chunk-TIIP3RG2.js → chunk-PD4VFEBY.js} +342 -2
- package/dist/chunk-PD4VFEBY.js.map +1 -0
- package/dist/{chunk-WV63X7IK.js → chunk-SCVBYSF7.js} +2 -2
- package/dist/chunk-SCVBYSF7.js.map +1 -0
- package/dist/{chunk-7MSDGHJW.js → chunk-Z2BVYKZL.js} +60 -7
- package/dist/chunk-Z2BVYKZL.js.map +1 -0
- package/dist/claude-code-4275HQU4.js +1432 -0
- package/dist/claude-code-4275HQU4.js.map +1 -0
- package/dist/cli/sdk.js +4 -3
- package/dist/cli/sdk.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/{codebuff-QX57FJDN.js → codebuff-LE3KBZGM.js} +9 -2
- package/dist/codebuff-LE3KBZGM.js.map +1 -0
- package/dist/{codex-JFQTS6LU.js → codex-4BY2ZJIW.js} +148 -7
- package/dist/codex-4BY2ZJIW.js.map +1 -0
- package/dist/{copilot-cli-MTCGHZ2T.js → copilot-cli-IPISKO3V.js} +109 -2
- package/dist/copilot-cli-IPISKO3V.js.map +1 -0
- package/dist/{crush-I7PK3FGI.js → crush-X3E25EQG.js} +31 -3
- package/dist/crush-X3E25EQG.js.map +1 -0
- package/dist/{cursor-4TMXKJOZ.js → cursor-UH3W622V.js} +66 -5
- package/dist/cursor-UH3W622V.js.map +1 -0
- package/dist/{detect-WIAGVYS4.js → detect-JK7T46N6.js} +7 -3
- package/dist/detect-JK7T46N6.js.map +1 -0
- package/dist/{doctor-EZW2K4NI.js → doctor-62BHIXOR.js} +13 -5
- package/dist/doctor-62BHIXOR.js.map +1 -0
- package/dist/{droid-KN6VRMMT.js → droid-T5VBRXZF.js} +32 -3
- package/dist/droid-T5VBRXZF.js.map +1 -0
- package/dist/{gemini-cli-Y35FFK4M.js → gemini-cli-ZSUK55UA.js} +51 -3
- package/dist/gemini-cli-ZSUK55UA.js.map +1 -0
- package/dist/{goose-ZTGTSUFJ.js → goose-M3RR3CZG.js} +63 -4
- package/dist/goose-M3RR3CZG.js.map +1 -0
- package/dist/{hermes-H2KV44GK.js → hermes-CUNKIAR5.js} +76 -3
- package/dist/hermes-CUNKIAR5.js.map +1 -0
- package/dist/{hook-YVDILAMZ.js → hook-AC7APC66.js} +26 -11
- package/dist/hook-AC7APC66.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -1
- package/dist/{install-HQRYZOQ2.js → install-DMW2C7SV.js} +12 -7
- package/dist/install-DMW2C7SV.js.map +1 -0
- package/dist/{jetbrains-copilot-HWA3DMH7.js → jetbrains-copilot-C3HDGGML.js} +16 -2
- package/dist/jetbrains-copilot-C3HDGGML.js.map +1 -0
- package/dist/{kilo-QXJRCSLT.js → kilo-ISR5FBBJ.js} +26 -2
- package/dist/kilo-ISR5FBBJ.js.map +1 -0
- package/dist/{kilo-cli-EAQTHXUW.js → kilo-cli-2RNODHWY.js} +30 -2
- package/dist/kilo-cli-2RNODHWY.js.map +1 -0
- package/dist/{kimi-GQ7VXNYT.js → kimi-Q5RG7CYT.js} +89 -6
- package/dist/kimi-Q5RG7CYT.js.map +1 -0
- package/dist/{kiro-VQTT6LO2.js → kiro-EKTRW424.js} +31 -2
- package/dist/kiro-EKTRW424.js.map +1 -0
- package/dist/{leaderboard-K6ON3SWW.js → leaderboard-R5HRJHNU.js} +3 -3
- package/dist/{mux-T2TV4CIQ.js → mux-5CI5FP2W.js} +9 -2
- package/dist/mux-5CI5FP2W.js.map +1 -0
- package/dist/{omp-PB4VDKS6.js → omp-AXA7XY22.js} +13 -2
- package/dist/omp-AXA7XY22.js.map +1 -0
- package/dist/{openclaw-ETN2M63O.js → openclaw-UZ5BMCGQ.js} +101 -4
- package/dist/openclaw-UZ5BMCGQ.js.map +1 -0
- package/dist/{opencode-FZ33JKUZ.js → opencode-NZBRLJN3.js} +53 -7
- package/dist/opencode-NZBRLJN3.js.map +1 -0
- package/dist/{package-DLOVE2E4.js → package-O63K4S7T.js} +10 -5
- package/dist/package-O63K4S7T.js.map +1 -0
- package/dist/{pi-CIU2QHT4.js → pi-SJPIL4VE.js} +6 -2
- package/dist/pi-SJPIL4VE.js.map +1 -0
- package/dist/{qwen-code-5POCNU6P.js → qwen-code-IFCM6BJY.js} +110 -2
- package/dist/qwen-code-IFCM6BJY.js.map +1 -0
- package/dist/{roo-code-IOIUXRDE.js → roo-code-NI5UU6JB.js} +26 -2
- package/dist/roo-code-NI5UU6JB.js.map +1 -0
- package/dist/runtime/index.d.ts +38 -4
- package/dist/runtime/index.js +9 -4
- package/dist/{serve-HVWWY4B6.js → serve-LFOUSZAD.js} +7 -6
- package/dist/{serve-HVWWY4B6.js.map → serve-LFOUSZAD.js.map} +1 -1
- package/dist/{status-FE7TECZD.js → status-M7JLZVLC.js} +6 -5
- package/dist/{status-FE7TECZD.js.map → status-M7JLZVLC.js.map} +1 -1
- package/dist/{telemetry-36GESKQQ.js → telemetry-3NVEXPYX.js} +5 -4
- package/dist/{telemetry-36GESKQQ.js.map → telemetry-3NVEXPYX.js.map} +1 -1
- package/dist/{trae-JSNDZFKL.js → trae-CQC72RHH.js} +9 -2
- package/dist/trae-CQC72RHH.js.map +1 -0
- package/dist/types-CNigfEuR.d.ts +757 -0
- package/dist/{uninstall-IGCKNOSF.js → uninstall-H6FGMIHN.js} +7 -6
- package/dist/{uninstall-IGCKNOSF.js.map → uninstall-H6FGMIHN.js.map} +1 -1
- package/dist/{upgrade-JV2VK242.js → upgrade-76BQZBMA.js} +7 -6
- package/dist/{upgrade-JV2VK242.js.map → upgrade-76BQZBMA.js.map} +1 -1
- package/dist/{usage-6ER6EMEY.js → usage-G3GSCX23.js} +3 -3
- package/dist/{usage-event-JKBI6XCF.js → usage-event-QUTMNBS5.js} +6 -5
- package/dist/{usage-event-JKBI6XCF.js.map → usage-event-QUTMNBS5.js.map} +1 -1
- package/dist/{vscode-copilot-CK3NO54M.js → vscode-copilot-4RVRTCKV.js} +53 -4
- package/dist/vscode-copilot-4RVRTCKV.js.map +1 -0
- package/dist/{warp-QNVDXOG4.js → warp-LLOSXR7A.js} +30 -2
- package/dist/warp-LLOSXR7A.js.map +1 -0
- package/dist/{zed-VRJKWYUR.js → zed-HYOITK7F.js} +53 -3
- package/dist/zed-HYOITK7F.js.map +1 -0
- package/package.json +4 -3
- package/dist/amp-QSFH2V7Y.js.map +0 -1
- package/dist/chunk-54EMKTTX.js.map +0 -1
- package/dist/chunk-7MSDGHJW.js.map +0 -1
- package/dist/chunk-LTT56GI3.js.map +0 -1
- package/dist/chunk-TIIP3RG2.js.map +0 -1
- package/dist/chunk-TRKWUNO4.js.map +0 -1
- package/dist/chunk-WV63X7IK.js.map +0 -1
- package/dist/chunk-XNAM7F35.js +0 -276
- package/dist/chunk-XNAM7F35.js.map +0 -1
- package/dist/chunk-YNZU6PAV.js.map +0 -1
- package/dist/claude-code-HKDV7T32.js +0 -637
- package/dist/claude-code-HKDV7T32.js.map +0 -1
- package/dist/codebuff-QX57FJDN.js.map +0 -1
- package/dist/codex-JFQTS6LU.js.map +0 -1
- package/dist/copilot-cli-MTCGHZ2T.js.map +0 -1
- package/dist/crush-I7PK3FGI.js.map +0 -1
- package/dist/cursor-4TMXKJOZ.js.map +0 -1
- package/dist/detect-WIAGVYS4.js.map +0 -1
- package/dist/doctor-EZW2K4NI.js.map +0 -1
- package/dist/droid-KN6VRMMT.js.map +0 -1
- package/dist/gemini-cli-Y35FFK4M.js.map +0 -1
- package/dist/goose-ZTGTSUFJ.js.map +0 -1
- package/dist/hermes-H2KV44GK.js.map +0 -1
- package/dist/hook-YVDILAMZ.js.map +0 -1
- package/dist/install-HQRYZOQ2.js.map +0 -1
- package/dist/jetbrains-copilot-HWA3DMH7.js.map +0 -1
- package/dist/kilo-QXJRCSLT.js.map +0 -1
- package/dist/kilo-cli-EAQTHXUW.js.map +0 -1
- package/dist/kimi-GQ7VXNYT.js.map +0 -1
- package/dist/kiro-VQTT6LO2.js.map +0 -1
- package/dist/mux-T2TV4CIQ.js.map +0 -1
- package/dist/omp-PB4VDKS6.js.map +0 -1
- package/dist/openclaw-ETN2M63O.js.map +0 -1
- package/dist/opencode-FZ33JKUZ.js.map +0 -1
- package/dist/package-DLOVE2E4.js.map +0 -1
- package/dist/pi-CIU2QHT4.js.map +0 -1
- package/dist/qwen-code-5POCNU6P.js.map +0 -1
- package/dist/roo-code-IOIUXRDE.js.map +0 -1
- package/dist/trae-JSNDZFKL.js.map +0 -1
- package/dist/types-CYUB1OTr.d.ts +0 -427
- package/dist/vscode-copilot-CK3NO54M.js.map +0 -1
- package/dist/warp-QNVDXOG4.js.map +0 -1
- package/dist/zed-VRJKWYUR.js.map +0 -1
- /package/dist/{antigravity-CX2YLSY7.js.map → antigravity-7IBYFO6P.js.map} +0 -0
- /package/dist/{chunk-XUCWLJY5.js.map → chunk-O2SBA5KR.js.map} +0 -0
- /package/dist/{leaderboard-K6ON3SWW.js.map → leaderboard-R5HRJHNU.js.map} +0 -0
- /package/dist/{usage-6ER6EMEY.js.map → usage-G3GSCX23.js.map} +0 -0
|
@@ -7,13 +7,14 @@ import {
|
|
|
7
7
|
} from "./chunk-DBQMX75U.js";
|
|
8
8
|
import {
|
|
9
9
|
BaseAdapter
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-PD4VFEBY.js";
|
|
11
11
|
import "./chunk-7L6ITC4T.js";
|
|
12
12
|
import {
|
|
13
13
|
buildHomeBinHookCommand,
|
|
14
14
|
buildServeWrapperCommand,
|
|
15
15
|
shouldWrapForTelemetry
|
|
16
16
|
} from "./chunk-MEH7GC7R.js";
|
|
17
|
+
import "./chunk-N6HH7K6P.js";
|
|
17
18
|
import {
|
|
18
19
|
ensureDir
|
|
19
20
|
} from "./chunk-TRQKHP7D.js";
|
|
@@ -29,14 +30,21 @@ var CODEX_HOOK_EVENTS = [
|
|
|
29
30
|
"PostToolUse",
|
|
30
31
|
"PreCompact",
|
|
31
32
|
"UserPromptSubmit",
|
|
32
|
-
"Stop"
|
|
33
|
+
"Stop",
|
|
34
|
+
"PermissionRequest",
|
|
35
|
+
"SubagentStart",
|
|
36
|
+
"SubagentStop"
|
|
33
37
|
];
|
|
38
|
+
var WARN_SKIP_EVENTS = /* @__PURE__ */ new Set(["PostToolUseFailure"]);
|
|
34
39
|
var PRE_TOOL_USE_MATCHER = "local_shell|shell|shell_command|exec_command|Bash|Shell|apply_patch|Edit|Write|grep_files|mcp__";
|
|
35
40
|
var CodexAdapter = class extends BaseAdapter {
|
|
36
41
|
id = "codex";
|
|
37
42
|
name = "Codex CLI";
|
|
38
43
|
paradigm = "json-stdio";
|
|
39
44
|
capabilities = {
|
|
45
|
+
// Memory surface: AGENTS.md-first managed block. memoryTargets below probes
|
|
46
|
+
// AGENTS.override.md first (it shadows AGENTS.md per directory on codex).
|
|
47
|
+
supportsMemory: true,
|
|
40
48
|
preToolUse: true,
|
|
41
49
|
postToolUse: true,
|
|
42
50
|
preCompact: true,
|
|
@@ -45,6 +53,12 @@ var CodexAdapter = class extends BaseAdapter {
|
|
|
45
53
|
userPromptSubmit: true,
|
|
46
54
|
stop: true,
|
|
47
55
|
notification: false,
|
|
56
|
+
// E1 events: PermissionRequest (decision-capable) + SubagentStart/Stop are
|
|
57
|
+
// Codex-native. postToolUseFailure stays unset — Codex has no failure event,
|
|
58
|
+
// so a declared hook for it warn-skips at install.
|
|
59
|
+
permissionRequest: true,
|
|
60
|
+
subagentStart: true,
|
|
61
|
+
subagentStop: true,
|
|
48
62
|
canModifyArgs: false,
|
|
49
63
|
canModifyOutput: false,
|
|
50
64
|
canInjectSessionContext: true,
|
|
@@ -91,6 +105,34 @@ var CodexAdapter = class extends BaseAdapter {
|
|
|
91
105
|
getHookConfigPath(ctx) {
|
|
92
106
|
return join(this.getConfigDir(ctx), "hooks.json");
|
|
93
107
|
}
|
|
108
|
+
// ── Memory surface: AGENTS.override.md probe + 32 KiB doc-cap budget ─────
|
|
109
|
+
// Codex reads AGENTS.override.md > AGENTS.md per directory (one file per
|
|
110
|
+
// directory), so when the override file exists OUR block must live there or
|
|
111
|
+
// it is never loaded. Combined project docs are capped at 32 KiB
|
|
112
|
+
// (`project_doc_max_bytes`), hence the ~28 KiB per-file budget warn.
|
|
113
|
+
memoryTargets(ctx) {
|
|
114
|
+
if (this.memoryOverride(ctx)?.path) return super.memoryTargets(ctx);
|
|
115
|
+
if (ctx.scope !== "project" && ctx.scope !== "user") return [];
|
|
116
|
+
const budgetBytes = 28 * 1024;
|
|
117
|
+
const dir = ctx.scope === "project" ? ctx.projectDir : this.userConfigDir();
|
|
118
|
+
const overrideMd = join(dir, "AGENTS.override.md");
|
|
119
|
+
if (existsSync(overrideMd)) {
|
|
120
|
+
return [
|
|
121
|
+
{
|
|
122
|
+
path: overrideMd,
|
|
123
|
+
reason: "AGENTS.override.md shadows AGENTS.md on codex (one doc per directory)",
|
|
124
|
+
budgetBytes
|
|
125
|
+
}
|
|
126
|
+
];
|
|
127
|
+
}
|
|
128
|
+
return [
|
|
129
|
+
{
|
|
130
|
+
path: join(dir, "AGENTS.md"),
|
|
131
|
+
reason: ctx.scope === "project" ? "AGENTS.md standard (project root; codex is the format's originator)" : "codex global guidance ($CODEX_HOME/AGENTS.md)",
|
|
132
|
+
budgetBytes
|
|
133
|
+
}
|
|
134
|
+
];
|
|
135
|
+
}
|
|
94
136
|
/** `$CODEX_HOME` || `~/.codex` for user scope. */
|
|
95
137
|
userConfigDir() {
|
|
96
138
|
const env = process.env.CODEX_HOME;
|
|
@@ -173,12 +215,21 @@ var CodexAdapter = class extends BaseAdapter {
|
|
|
173
215
|
const { connector, dryRun } = ctx;
|
|
174
216
|
const path = this.getHookConfigPath(ctx);
|
|
175
217
|
const events = this.effectiveHookEvents(ctx);
|
|
176
|
-
|
|
218
|
+
const dropped = this.warnSkipHookEvents(ctx);
|
|
219
|
+
if (events.length === 0 && dropped.length === 0) {
|
|
177
220
|
return [{ platform: this.id, action: "skip", path, detail: "no hooks declared" }];
|
|
178
221
|
}
|
|
179
222
|
const file = this.readHooksFile(path);
|
|
180
223
|
const hooks = file.hooks ??= {};
|
|
181
224
|
const changes = [];
|
|
225
|
+
for (const event of dropped) {
|
|
226
|
+
changes.push({
|
|
227
|
+
platform: this.id,
|
|
228
|
+
action: "warn",
|
|
229
|
+
path,
|
|
230
|
+
detail: `${event} has no Codex hook equivalent \u2014 skipped`
|
|
231
|
+
});
|
|
232
|
+
}
|
|
182
233
|
for (const event of events) {
|
|
183
234
|
const desired = this.renderHookEntry(ctx, event);
|
|
184
235
|
const list = Array.isArray(hooks[event]) ? hooks[event] : hooks[event] = [];
|
|
@@ -193,7 +244,7 @@ var CodexAdapter = class extends BaseAdapter {
|
|
|
193
244
|
changes.push({ platform: this.id, action: "skip", path, detail: `hooks.${event}` });
|
|
194
245
|
}
|
|
195
246
|
}
|
|
196
|
-
if (changes.some((c) => c.action
|
|
247
|
+
if (changes.some((c) => c.action === "create" || c.action === "update")) {
|
|
197
248
|
this.writeJson(path, file, dryRun);
|
|
198
249
|
}
|
|
199
250
|
return changes;
|
|
@@ -235,6 +286,9 @@ var CodexAdapter = class extends BaseAdapter {
|
|
|
235
286
|
{
|
|
236
287
|
name: `${this.name}: mcp_servers.${id} registered`,
|
|
237
288
|
check: () => {
|
|
289
|
+
if (!ctx.connector.server) {
|
|
290
|
+
return { status: "OK", detail: "no MCP server declared" };
|
|
291
|
+
}
|
|
238
292
|
const cfg = this.readToml(path);
|
|
239
293
|
const bucket = cfg["mcp_servers"];
|
|
240
294
|
const present = typeof bucket === "object" && bucket !== null && id in bucket;
|
|
@@ -465,9 +519,80 @@ var CodexAdapter = class extends BaseAdapter {
|
|
|
465
519
|
return { ...base, stopHookActive: input.stop_hook_active ?? false };
|
|
466
520
|
case "Notification":
|
|
467
521
|
return { ...base, message: input.message ?? "" };
|
|
522
|
+
case "PermissionRequest":
|
|
523
|
+
return {
|
|
524
|
+
...base,
|
|
525
|
+
toolName: input.tool_name ?? "",
|
|
526
|
+
toolInput: input.tool_input ?? {}
|
|
527
|
+
};
|
|
528
|
+
case "PostToolUseFailure":
|
|
529
|
+
return {
|
|
530
|
+
...base,
|
|
531
|
+
toolName: input.tool_name ?? "",
|
|
532
|
+
toolInput: input.tool_input ?? {},
|
|
533
|
+
error: input.error ?? ""
|
|
534
|
+
};
|
|
535
|
+
case "SubagentStart":
|
|
536
|
+
return {
|
|
537
|
+
...base,
|
|
538
|
+
...typeof input.agent_id === "string" ? { agentId: input.agent_id } : {},
|
|
539
|
+
...typeof input.agent_type === "string" ? { agentType: input.agent_type } : {}
|
|
540
|
+
};
|
|
541
|
+
case "SubagentStop":
|
|
542
|
+
return {
|
|
543
|
+
...base,
|
|
544
|
+
...typeof input.agent_id === "string" ? { agentId: input.agent_id } : {},
|
|
545
|
+
...typeof input.agent_type === "string" ? { agentType: input.agent_type } : {},
|
|
546
|
+
...typeof input.agent_transcript_path === "string" ? { agentTranscriptPath: input.agent_transcript_path } : {},
|
|
547
|
+
...typeof input.last_assistant_message === "string" ? { lastAssistantMessage: input.last_assistant_message } : {},
|
|
548
|
+
...typeof input.stop_hook_active === "boolean" ? { stopHookActive: input.stop_hook_active } : {}
|
|
549
|
+
};
|
|
468
550
|
}
|
|
469
551
|
}
|
|
470
552
|
formatReply(event, response) {
|
|
553
|
+
if (event === "PermissionRequest") {
|
|
554
|
+
if (response.decision === "deny") {
|
|
555
|
+
return {
|
|
556
|
+
exitCode: 0,
|
|
557
|
+
stdout: JSON.stringify({
|
|
558
|
+
hookSpecificOutput: {
|
|
559
|
+
hookEventName: "PermissionRequest",
|
|
560
|
+
decision: {
|
|
561
|
+
behavior: "deny",
|
|
562
|
+
message: response.reason ?? "Blocked by hook"
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
})
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
if (response.decision === "allow") {
|
|
569
|
+
return {
|
|
570
|
+
exitCode: 0,
|
|
571
|
+
stdout: JSON.stringify({
|
|
572
|
+
hookSpecificOutput: {
|
|
573
|
+
hookEventName: "PermissionRequest",
|
|
574
|
+
decision: { behavior: "allow" }
|
|
575
|
+
}
|
|
576
|
+
})
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
return { exitCode: 0 };
|
|
580
|
+
}
|
|
581
|
+
if (event === "SubagentStart") {
|
|
582
|
+
const context = response.decision === "context" ? response.additionalContext : response.decision === "deny" ? response.reason ?? response.additionalContext : void 0;
|
|
583
|
+
if (context) {
|
|
584
|
+
return {
|
|
585
|
+
exitCode: 0,
|
|
586
|
+
stdout: JSON.stringify({
|
|
587
|
+
hookSpecificOutput: {
|
|
588
|
+
hookEventName: "SubagentStart",
|
|
589
|
+
additionalContext: context
|
|
590
|
+
}
|
|
591
|
+
})
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
return { exitCode: 0 };
|
|
595
|
+
}
|
|
471
596
|
if (response.decision === "deny") {
|
|
472
597
|
if (event === "PreToolUse") {
|
|
473
598
|
return {
|
|
@@ -481,6 +606,15 @@ var CodexAdapter = class extends BaseAdapter {
|
|
|
481
606
|
})
|
|
482
607
|
};
|
|
483
608
|
}
|
|
609
|
+
if (event === "SubagentStop") {
|
|
610
|
+
return {
|
|
611
|
+
exitCode: 0,
|
|
612
|
+
stdout: JSON.stringify({
|
|
613
|
+
decision: "block",
|
|
614
|
+
reason: response.reason ?? "Blocked by hook"
|
|
615
|
+
})
|
|
616
|
+
};
|
|
617
|
+
}
|
|
484
618
|
return { exitCode: 0 };
|
|
485
619
|
}
|
|
486
620
|
if (response.additionalContext && (event === "SessionStart" || event === "PostToolUse")) {
|
|
@@ -511,6 +645,12 @@ var CodexAdapter = class extends BaseAdapter {
|
|
|
511
645
|
if (override === false) return [];
|
|
512
646
|
return CODEX_HOOK_EVENTS.filter((e) => ctx.connector.hookEvents.includes(e));
|
|
513
647
|
}
|
|
648
|
+
/** Declared events Codex has no analog for — install reports a warn-skip. */
|
|
649
|
+
warnSkipHookEvents(ctx) {
|
|
650
|
+
const override = ctx.connector.platforms[this.id]?.hooks;
|
|
651
|
+
if (override === false) return [];
|
|
652
|
+
return ctx.connector.hookEvents.filter((e) => WARN_SKIP_EVENTS.has(e));
|
|
653
|
+
}
|
|
514
654
|
/**
|
|
515
655
|
* Render the `[mcp_servers.<id>]` table. TOML has NO interpolation, so every
|
|
516
656
|
* `${env:VAR}` is resolved to a literal at install time. The env table is a
|
|
@@ -546,8 +686,9 @@ var CodexAdapter = class extends BaseAdapter {
|
|
|
546
686
|
ctx.connector.id
|
|
547
687
|
);
|
|
548
688
|
const entry = { hooks: [{ type: "command", command }] };
|
|
549
|
-
if (event === "PreToolUse"
|
|
550
|
-
|
|
689
|
+
if (event === "PreToolUse" || event === "PermissionRequest") {
|
|
690
|
+
entry.matcher = PRE_TOOL_USE_MATCHER;
|
|
691
|
+
} else entry.matcher = "";
|
|
551
692
|
return entry;
|
|
552
693
|
}
|
|
553
694
|
/** Does this hooks.json entry belong to this connector (by home-bin command)? */
|
|
@@ -590,4 +731,4 @@ export {
|
|
|
590
731
|
adapter,
|
|
591
732
|
codex_default as default
|
|
592
733
|
};
|
|
593
|
-
//# sourceMappingURL=codex-
|
|
734
|
+
//# sourceMappingURL=codex-4BY2ZJIW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/codex/index.ts"],"sourcesContent":["/**\n * adapters/codex — Codex CLI platform adapter for agent-connector.\n *\n * Codex CLI hook paradigm is \"json-stdio\": the host pipes a JSON payload to a\n * command on stdin and reads JSON/exit-code back — the same wire protocol as\n * Claude Code (PascalCase fields, `hookSpecificOutput` reply wrapper).\n *\n * Two native config files live under the Codex config dir\n * (`$CODEX_HOME` || `~/.codex`, mirrored to `<projectDir>/.codex` for project\n * scope):\n * - config.toml → `[mcp_servers.<id>]` MCP registration (TOML, NO native\n * interpolation, so env-refs are resolved to literals at install time).\n * - hooks.json → Claude-compatible hook registration ({ matcher, hooks }).\n *\n * Grounded in context-mode's proven Codex adapter (configs/codex/{config.toml,\n * hooks.json}, src/adapters/codex/*) — exact TOML MCP shape + hook JSON schema.\n *\n * Known Codex limitations (upstream): PreToolUse deny works but updatedInput is\n * not yet honored (openai/codex#18491); PostToolUse updatedMCPToolOutput is\n * parsed-but-unsupported — hence canModifyArgs / canModifyOutput are false.\n *\n * E1 extension events (verified against developers.openai.com/codex/hooks):\n * - PermissionRequest — native, decision-capable via the nested\n * hookSpecificOutput.decision{behavior:\"allow\"|\"deny\", message?} envelope.\n * Codex docs: updatedInput / updatedPermissions / interrupt FAIL CLOSED on\n * this event, so they are never emitted here.\n * - SubagentStart — native; hookSpecificOutput.additionalContext is injected\n * as developer context for the subagent (not blockable).\n * - SubagentStop — native; the documented continuation shape is the TOP-LEVEL\n * {\"decision\":\"block\",\"reason\"} (Stop semantics: keeps the subagent going).\n * - PostToolUseFailure — NO Codex analog (PostToolUse only); declared hooks\n * for it warn-skip at install and the capability flag stays unset.\n */\n\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nimport TOML from \"@iarna/toml\";\n\nimport type {\n ChangeRecord,\n CommandDef,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n PlatformCapabilities,\n PlatformId,\n ServerDef,\n SkillDef,\n SubagentDef,\n} from \"../../core/types.js\";\nimport { ensureDir } from \"../../core/paths.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport { writeTomlString } from \"../../core/toml.js\";\nimport {\n buildHomeBinHookCommand,\n buildServeWrapperCommand,\n shouldWrapForTelemetry,\n} from \"../../core/spawn.js\";\nimport { BaseAdapter } from \"../base.js\";\nimport type {\n HookReply,\n InstallContext,\n MemoryTarget,\n NormalizedEvent,\n} from \"../spi.js\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// Native shapes\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Raw Codex hook payload (PascalCase event, snake_case fields — Claude-style). */\ninterface CodexHookInput {\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n tool_response?: string;\n session_id?: string;\n cwd?: string;\n hook_event_name?: string;\n source?: string;\n prompt?: string;\n is_error?: boolean;\n stop_hook_active?: boolean;\n trigger?: string;\n message?: string;\n // PostToolUseFailure-style failure field. Codex has NO failure event today;\n // parsed defensively only (the Claude-compatible wire would carry it).\n error?: string;\n // SubagentStart / SubagentStop (agent_type is the matcher subject).\n agent_id?: string;\n agent_type?: string;\n // SubagentStop only — the subagent's own transcript + final message.\n agent_transcript_path?: string;\n last_assistant_message?: string;\n}\n\n/** One hook entry inside hooks.json (Claude-compatible). */\ninterface CodexHookEntry {\n matcher?: string;\n hooks: Array<{ type: \"command\"; command: string }>;\n}\n\ninterface CodexHooksFile {\n hooks?: Record<string, CodexHookEntry[]>;\n [key: string]: unknown;\n}\n\n/** Rendered `[mcp_servers.<id>]` table — string env table, no interpolation. */\ninterface CodexMcpEntry {\n command: string;\n args?: string[];\n env?: Record<string, string>;\n}\n\n/**\n * Codex hook events agent-connector registers, in the canonical → native order.\n * Codex uses the same PascalCase event names as Claude Code; the home-binary\n * hook command receives the lowercased event token.\n */\nconst CODEX_HOOK_EVENTS = [\n \"SessionStart\",\n \"PreToolUse\",\n \"PostToolUse\",\n \"PreCompact\",\n \"UserPromptSubmit\",\n \"Stop\",\n \"PermissionRequest\",\n \"SubagentStart\",\n \"SubagentStop\",\n] as const;\n\ntype CodexHookEventName = (typeof CODEX_HOOK_EVENTS)[number];\n\n/**\n * Newer canonical events with NO Codex analog: Codex ships PostToolUse only —\n * there is no failure event on the live hooks page. Declared hooks for these\n * warn-skip at install so the degradation is reported, never silent. (The\n * legacy SessionEnd / Notification silent filter predates this convention and\n * is deliberately left untouched.)\n */\nconst WARN_SKIP_EVENTS: ReadonlySet<HookEventName> = new Set([\"PostToolUseFailure\"]);\n\n/**\n * PreToolUse matcher — canonical Codex tool names + bare MCP tool names +\n * external MCP catch-all literal. Charset-clean ([A-Za-z0-9_|] only) so Codex's\n * Rust `regex` exact-matcher short-circuits (no look-around, which Codex\n * rejects at boot). Copied from context-mode's proven matcher.\n */\nconst PRE_TOOL_USE_MATCHER =\n \"local_shell|shell|shell_command|exec_command|Bash|Shell|apply_patch|Edit|Write|grep_files|mcp__\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// Adapter\n// ─────────────────────────────────────────────────────────────────────────\n\nexport class CodexAdapter extends BaseAdapter {\n readonly id: PlatformId = \"codex\";\n readonly name = \"Codex CLI\";\n readonly paradigm: HookParadigm = \"json-stdio\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block. memoryTargets below probes\n // AGENTS.override.md first (it shadows AGENTS.md per directory on codex).\n supportsMemory: true,\n preToolUse: true,\n postToolUse: true,\n preCompact: true,\n sessionStart: true,\n sessionEnd: false,\n userPromptSubmit: true,\n stop: true,\n notification: false,\n // E1 events: PermissionRequest (decision-capable) + SubagentStart/Stop are\n // Codex-native. postToolUseFailure stays unset — Codex has no failure event,\n // so a declared hook for it warn-skips at install.\n permissionRequest: true,\n subagentStart: true,\n subagentStop: true,\n canModifyArgs: false,\n canModifyOutput: false,\n canInjectSessionContext: true,\n transports: [\"stdio\", \"http\"],\n // Content surfaces: Codex implements all three.\n // command → ~/.codex/prompts/<name>.md (md+frontmatter, USER SCOPE ONLY)\n // skill → <codexDir>/skills/<name>/SKILL.md (+ resources)\n // subagent → <codexDir>/agents/<name>.toml (TOML)\n supportsCommands: true,\n supportsSkills: true,\n supportsSubagents: true,\n };\n\n // ── Detection ──────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = this.userConfigDir();\n const projDir = join(projectDir, \".codex\");\n const userCfg = join(userDir, \"config.toml\");\n const projCfg = join(projDir, \"config.toml\");\n\n const userInstalled = existsSync(userDir) || existsSync(userCfg);\n const projInstalled = existsSync(projDir) || existsSync(projCfg);\n const installed = userInstalled || projInstalled;\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projCfg : userCfg;\n\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath,\n scope,\n reason: installed\n ? `Found Codex config dir (${scope})`\n : `No .codex config dir at ${userDir} or ${projDir}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Native paths ───────────────────────────────────────────────────────\n\n override getConfigDir(ctx: InstallContext): string {\n if (ctx.scope === \"project\") return join(ctx.projectDir, \".codex\");\n return this.userConfigDir();\n }\n\n override getServerConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"config.toml\");\n }\n\n override getHookConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"hooks.json\");\n }\n\n // ── Memory surface: AGENTS.override.md probe + 32 KiB doc-cap budget ─────\n // Codex reads AGENTS.override.md > AGENTS.md per directory (one file per\n // directory), so when the override file exists OUR block must live there or\n // it is never loaded. Combined project docs are capped at 32 KiB\n // (`project_doc_max_bytes`), hence the ~28 KiB per-file budget warn.\n protected override memoryTargets(ctx: InstallContext): MemoryTarget[] {\n // An explicit path override keeps the base resolution (escape hatch wins).\n if (this.memoryOverride(ctx)?.path) return super.memoryTargets(ctx);\n if (ctx.scope !== \"project\" && ctx.scope !== \"user\") return [];\n const budgetBytes = 28 * 1024;\n const dir = ctx.scope === \"project\" ? ctx.projectDir : this.userConfigDir();\n const overrideMd = join(dir, \"AGENTS.override.md\");\n if (existsSync(overrideMd)) {\n return [\n {\n path: overrideMd,\n reason: \"AGENTS.override.md shadows AGENTS.md on codex (one doc per directory)\",\n budgetBytes,\n },\n ];\n }\n return [\n {\n path: join(dir, \"AGENTS.md\"),\n reason:\n ctx.scope === \"project\"\n ? \"AGENTS.md standard (project root; codex is the format's originator)\"\n : \"codex global guidance ($CODEX_HOME/AGENTS.md)\",\n budgetBytes,\n },\n ];\n }\n\n /** `$CODEX_HOME` || `~/.codex` for user scope. */\n private userConfigDir(): string {\n const env = process.env.CODEX_HOME;\n if (env && env.trim() !== \"\") {\n if (env.startsWith(\"~\")) {\n return join(homedir(), env.replace(/^~[/\\\\]?/, \"\"));\n }\n return env;\n }\n return join(homedir(), \".codex\");\n }\n\n // ── TOML config IO (override JSON helpers — config.toml is TOML) ─────────\n\n private readToml(path: string): Record<string, unknown> {\n if (!existsSync(path)) return {};\n try {\n return TOML.parse(readFileSync(path, \"utf8\")) as Record<string, unknown>;\n } catch {\n return {};\n }\n }\n\n private writeToml(path: string, data: Record<string, unknown>, dryRun: boolean): void {\n if (dryRun) return;\n ensureDir(dirname(path));\n // @iarna/toml's stringify type wants its JsonMap; our object is structurally compatible.\n writeFileSync(path, TOML.stringify(data as never), \"utf8\");\n }\n\n // ── Install server (config.toml → [mcp_servers.<id>]) ───────────────────\n\n override installServer(ctx: InstallContext): ChangeRecord[] {\n const { connector, dryRun } = ctx;\n const server = this.effectiveServer(ctx);\n const path = this.getServerConfigPath(ctx);\n\n if (!server) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no server declared\" }];\n }\n if (server.transport !== \"stdio\" || !server.command) {\n // Codex config.toml [mcp_servers] is stdio-only; remote transports skip here.\n return [\n {\n platform: this.id,\n action: \"skip\",\n path,\n detail: `transport \"${server.transport}\" not registrable in config.toml (stdio only)`,\n },\n ];\n }\n\n const entry = this.renderMcpEntry(ctx, server);\n\n const cfg = this.readToml(path);\n const bucket = this.tomlBucket(cfg, \"mcp_servers\");\n const before = JSON.stringify(bucket[connector.id]);\n const after = JSON.stringify(entry);\n\n let action: ChangeRecord[\"action\"];\n if (before === undefined) action = \"create\";\n else if (before === after) action = \"skip\";\n else action = \"update\";\n\n if (action !== \"skip\") {\n bucket[connector.id] = entry as unknown as Record<string, unknown>;\n this.writeToml(path, cfg, dryRun);\n }\n return [{ platform: this.id, action, path, detail: `mcp_servers.${connector.id}` }];\n }\n\n override uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const { connector, dryRun } = ctx;\n const path = this.getServerConfigPath(ctx);\n const cfg = this.readToml(path);\n const bucket = cfg[\"mcp_servers\"];\n if (\n !existsSync(path) ||\n typeof bucket !== \"object\" ||\n bucket === null ||\n !(connector.id in (bucket as Record<string, unknown>))\n ) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path,\n detail: `mcp_servers.${connector.id} absent`,\n },\n ];\n }\n delete (bucket as Record<string, unknown>)[connector.id];\n this.writeToml(path, cfg, dryRun);\n return [{ platform: this.id, action: \"remove\", path, detail: `mcp_servers.${connector.id}` }];\n }\n\n // ── Install hooks (hooks.json) ──────────────────────────────────────────\n\n override installHooks(ctx: InstallContext): ChangeRecord[] {\n const { connector, dryRun } = ctx;\n const path = this.getHookConfigPath(ctx);\n const events = this.effectiveHookEvents(ctx);\n const dropped = this.warnSkipHookEvents(ctx);\n\n if (events.length === 0 && dropped.length === 0) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no hooks declared\" }];\n }\n\n const file = this.readHooksFile(path);\n const hooks = (file.hooks ??= {});\n const changes: ChangeRecord[] = [];\n\n // Declared events Codex cannot fire are reported, never silently dropped.\n for (const event of dropped) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n path,\n detail: `${event} has no Codex hook equivalent — skipped`,\n });\n }\n\n for (const event of events) {\n const desired = this.renderHookEntry(ctx, event);\n const list = Array.isArray(hooks[event]) ? hooks[event] : (hooks[event] = []);\n const idx = list.findIndex((e) => this.isOurEntry(ctx, event, e));\n if (idx < 0) {\n list.push(desired);\n changes.push({ platform: this.id, action: \"create\", path, detail: `hooks.${event}` });\n } else if (JSON.stringify(list[idx]) !== JSON.stringify(desired)) {\n list[idx] = desired;\n changes.push({ platform: this.id, action: \"update\", path, detail: `hooks.${event}` });\n } else {\n changes.push({ platform: this.id, action: \"skip\", path, detail: `hooks.${event}` });\n }\n }\n\n // Only a real entry mutation rewrites the file (a warn-skip must not\n // create/touch hooks.json by itself).\n if (changes.some((c) => c.action === \"create\" || c.action === \"update\")) {\n this.writeJson(path, file, dryRun);\n }\n return changes;\n }\n\n override uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n const path = this.getHookConfigPath(ctx);\n const file = this.readJson<CodexHooksFile>(path);\n const hooks = file?.hooks;\n if (!file || !hooks) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no hooks.json\" }];\n }\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n for (const event of CODEX_HOOK_EVENTS) {\n const list = hooks[event];\n if (!Array.isArray(list)) continue;\n const kept = list.filter((e) => !this.isOurEntry(ctx, event, e));\n if (kept.length === list.length) continue;\n mutated = true;\n if (kept.length > 0) hooks[event] = kept;\n else delete hooks[event];\n changes.push({ platform: this.id, action: \"remove\", path, detail: `hooks.${event}` });\n }\n\n if (mutated) this.writeJson(path, file, ctx.dryRun);\n if (changes.length === 0) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no agent-connector hooks present\" }];\n }\n return changes;\n }\n\n // ── Health checks (default doctor renders these) ────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const path = this.getServerConfigPath(ctx);\n const id = ctx.connector.id;\n const checks: HealthCheck[] = [\n {\n name: `${this.name}: config.toml exists`,\n check: () =>\n existsSync(path)\n ? { status: \"OK\", detail: path }\n : { status: \"FAIL\", detail: `not found: ${path}` },\n },\n {\n name: `${this.name}: mcp_servers.${id} registered`,\n check: () => {\n // Only assert what the connector declares (same rule as the\n // content-surface checks below): a server-less connector — e.g. a\n // catalog-only bundle of agents/skills/commands — never writes an\n // [mcp_servers.<id>] table, so its absence is healthy.\n if (!ctx.connector.server) {\n return { status: \"OK\", detail: \"no MCP server declared\" };\n }\n const cfg = this.readToml(path);\n const bucket = cfg[\"mcp_servers\"];\n const present =\n typeof bucket === \"object\" &&\n bucket !== null &&\n id in (bucket as Record<string, unknown>);\n return present\n ? { status: \"OK\", detail: `mcp_servers.${id}` }\n : { status: \"FAIL\", detail: `mcp_servers.${id} not found in ${path}` };\n },\n },\n ];\n\n // Content-surface checks: assert presence only for surfaces this connector\n // declares. Codex commands are user-scope only, so a project-scope install\n // won't have written them — only check command files in user scope.\n if (ctx.scope !== \"project\") {\n for (const cmd of ctx.connector.commands) {\n const p = this.commandPath(cmd.name);\n checks.push({\n name: `${this.name}: command ${cmd.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n }\n for (const skill of ctx.connector.skills) {\n const p = join(this.skillDir(ctx, skill.name), \"SKILL.md\");\n checks.push({\n name: `${this.name}: skill ${skill.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n for (const agent of ctx.connector.subagents) {\n const p = this.subagentPath(ctx, agent.name);\n checks.push({\n name: `${this.name}: subagent ${agent.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n return checks;\n }\n\n // ── Content surfaces: commands / skills / subagents ──────────────────────\n // CONTENT-ONLY: pure native-file writers. No runtime dispatch, no home-bin\n // pointer, no telemetry wrap. Each method is idempotent (byte-identical →\n // skip) via writeContentFile and reversible via removeContentFile. Honors\n // platforms[\"codex\"] per-surface false to skip.\n //\n // Native locations:\n // command → ~/.codex/prompts/<name>.md md+frontmatter(description,argument-hint)\n // USER SCOPE ONLY — project scope yields a single \"warn\".\n // skill → <codexDir>/skills/<name>/SKILL.md (+ resources)\n // subagent → <codexDir>/agents/<name>.toml TOML via writeTomlString\n\n /** Command files always live under the USER codex dir: ~/.codex/prompts. */\n private commandPath(name: string): string {\n return join(this.userConfigDir(), \"prompts\", `${name}.md`);\n }\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.getConfigDir(ctx), \"skills\", name);\n }\n private subagentPath(ctx: InstallContext, name: string): string {\n return join(this.getConfigDir(ctx), \"agents\", `${name}.toml`);\n }\n\n // ── Commands (USER SCOPE ONLY) ───────────────────────────────────────────\n\n override installCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[this.id]?.commands === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"commands disabled for codex\" }];\n }\n if (ctx.scope === \"project\") {\n return [{ platform: this.id, action: \"warn\", detail: \"codex commands are user-scope only\" }];\n }\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.writeContentFile(this.commandPath(cmd.name), this.renderCommand(cmd), ctx.dryRun),\n );\n }\n\n override uninstallCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (ctx.scope === \"project\") {\n return [{ platform: this.id, action: \"warn\", detail: \"codex commands are user-scope only\" }];\n }\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.removeContentFile(this.commandPath(cmd.name), ctx.dryRun),\n );\n }\n\n /** Render a command to md+frontmatter (description, argument-hint). */\n private renderCommand(cmd: CommandDef): string {\n const frontmatter: Record<string, unknown> = {};\n if (cmd.description !== undefined) frontmatter.description = cmd.description;\n if (cmd.argumentHint !== undefined) frontmatter[\"argument-hint\"] = cmd.argumentHint;\n if (cmd.extra) Object.assign(frontmatter, cmd.extra);\n return this.renderFrontmatterMd(frontmatter, cmd.prompt);\n }\n\n // ── Skills ───────────────────────────────────────────────────────────────\n\n override installSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[this.id]?.skills === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"skills disabled for codex\" }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), this.renderSkill(skill), ctx.dryRun),\n );\n // Bundle any resource files beside SKILL.md (relative path → contents).\n // Defense-in-depth: skip+warn on any key that escapes the skill dir\n // (config-time validation already rejects these, but never trust input).\n for (const [rel, contents] of Object.entries(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `skill resource \"${rel}\" escapes the skill dir; skipped`,\n });\n continue;\n }\n changes.push(this.writeContentFile(target, contents, ctx.dryRun));\n }\n }\n return changes;\n }\n\n override uninstallSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n // Remove only the files we wrote (SKILL.md + declared resources), then the\n // skill dir itself when we own its full contents.\n changes.push(this.removeContentFile(join(dir, \"SKILL.md\"), ctx.dryRun));\n for (const rel of Object.keys(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) continue; // never delete outside the skill dir\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n // Only remove the skill dir when WE own its full contents — never rm -rf a\n // dir that still holds user-added / sibling-tool / shared files.\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n /**\n * Render a skill's SKILL.md: frontmatter (name, description + optional model,\n * allowed-tools, disable-model-invocation) + body. UNIFORM with every other\n * skill-supporting platform — only the parent dir differs.\n */\n private renderSkill(skill: SkillDef): string {\n const frontmatter: Record<string, unknown> = {\n name: skill.name,\n description: skill.description,\n };\n if (skill.model !== undefined) frontmatter.model = skill.model;\n const allow = skill.tools?.allow;\n if (allow && allow.length > 0) frontmatter[\"allowed-tools\"] = allow.join(\", \");\n if (skill.disableModelInvocation !== undefined) {\n frontmatter[\"disable-model-invocation\"] = skill.disableModelInvocation;\n }\n if (skill.extra) Object.assign(frontmatter, skill.extra);\n return this.renderFrontmatterMd(frontmatter, skill.body);\n }\n\n // ── Subagents (TOML) ─────────────────────────────────────────────────────\n\n override installSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[this.id]?.subagents === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"subagents disabled for codex\" }];\n }\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n return connector.subagents.map((agent) =>\n this.writeContentFile(this.subagentPath(ctx, agent.name), this.renderSubagent(agent), ctx.dryRun),\n );\n }\n\n override uninstallSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n return connector.subagents.map((agent) =>\n this.removeContentFile(this.subagentPath(ctx, agent.name), ctx.dryRun),\n );\n }\n\n /**\n * Render a subagent to a Codex agent TOML file:\n * { name, description, developer_instructions: prompt, model }.\n * model is omitted when undefined so Codex applies its default.\n */\n private renderSubagent(agent: SubagentDef): string {\n const table: Record<string, unknown> = {\n name: agent.name,\n description: agent.description,\n developer_instructions: agent.prompt,\n };\n if (agent.model !== undefined) table.model = agent.model;\n if (agent.extra) Object.assign(table, agent.extra);\n return writeTomlString(table);\n }\n\n // ── Runtime dispatch ────────────────────────────────────────────────────\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as CodexHookInput;\n const base = {\n hostPlatform: this.id,\n connectorId: \"\",\n sessionId: input.session_id ?? `pid-${process.ppid}`,\n projectDir: input.cwd ?? process.env.CODEX_PROJECT_DIR ?? process.cwd(),\n raw,\n };\n\n switch (event) {\n case \"PreToolUse\":\n return {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n case \"PostToolUse\":\n return {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n toolOutput: input.tool_response,\n isError: input.is_error ?? false,\n };\n case \"SessionStart\":\n return { ...base, source: this.normalizeSource(input.source) };\n case \"SessionEnd\":\n return { ...base, reason: input.message };\n case \"UserPromptSubmit\":\n return { ...base, prompt: input.prompt ?? \"\" };\n case \"PreCompact\":\n return { ...base, trigger: input.trigger === \"manual\" ? \"manual\" : \"auto\" };\n case \"Stop\":\n return { ...base, stopHookActive: input.stop_hook_active ?? false };\n case \"Notification\":\n return { ...base, message: input.message ?? \"\" };\n case \"PermissionRequest\":\n // Codex documents tool_name/tool_input (+tool_input.description); it has\n // no permission_suggestions field, so the normalized optional stays unset.\n return {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n case \"PostToolUseFailure\":\n // No Codex analog — never fired natively. Parsed defensively (Claude-\n // compatible wire) so a manual `hook codex PostToolUseFailure` invocation\n // still normalizes instead of throwing.\n return {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n error: input.error ?? \"\",\n };\n case \"SubagentStart\":\n return {\n ...base,\n ...(typeof input.agent_id === \"string\" ? { agentId: input.agent_id } : {}),\n ...(typeof input.agent_type === \"string\" ? { agentType: input.agent_type } : {}),\n };\n case \"SubagentStop\":\n // agent_id/agent_type stay optional — never depend on hosts populating\n // them on stop (the Claude-family SDK quirk).\n return {\n ...base,\n ...(typeof input.agent_id === \"string\" ? { agentId: input.agent_id } : {}),\n ...(typeof input.agent_type === \"string\" ? { agentType: input.agent_type } : {}),\n ...(typeof input.agent_transcript_path === \"string\"\n ? { agentTranscriptPath: input.agent_transcript_path }\n : {}),\n ...(typeof input.last_assistant_message === \"string\"\n ? { lastAssistantMessage: input.last_assistant_message }\n : {}),\n ...(typeof input.stop_hook_active === \"boolean\"\n ? { stopHookActive: input.stop_hook_active }\n : {}),\n };\n }\n }\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n // Codex (like Claude Code) reads a `hookSpecificOutput` JSON wrapper from\n // stdout; exit code 0 = allow. Fields the host cannot honor are dropped.\n\n // PermissionRequest uses Codex's nested decision{behavior} envelope and is\n // the ONE event where an EXPLICIT \"allow\" is an ACTIVE grant (suppresses the\n // approval prompt). ask/context/void → NO decision output: fall through to\n // the normal approval flow (the prompt IS the ask). Codex docs: updatedInput\n // / updatedPermissions / interrupt FAIL CLOSED on this event, so \"modify\"\n // also falls through — emitting a bare allow would grant the ORIGINAL input\n // the handler wanted rewritten.\n if (event === \"PermissionRequest\") {\n if (response.decision === \"deny\") {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: \"PermissionRequest\",\n decision: {\n behavior: \"deny\",\n message: response.reason ?? \"Blocked by hook\",\n },\n },\n }),\n };\n }\n if (response.decision === \"allow\") {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: \"PermissionRequest\",\n decision: { behavior: \"allow\" },\n },\n }),\n };\n }\n return { exitCode: 0 };\n }\n\n // SubagentStart is observe/context-only on Codex (continue:false is parsed\n // but does not stop the subagent): \"context\" injects additionalContext as\n // developer context for the SUBAGENT, and a \"deny\" DEGRADES to the same\n // shape carrying the reason.\n if (event === \"SubagentStart\") {\n const context =\n response.decision === \"context\"\n ? response.additionalContext\n : response.decision === \"deny\"\n ? response.reason ?? response.additionalContext\n : undefined;\n if (context) {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: \"SubagentStart\",\n additionalContext: context,\n },\n }),\n };\n }\n return { exitCode: 0 };\n }\n\n if (response.decision === \"deny\") {\n // PreToolUse deny is honored; other events fail-open to allow.\n if (event === \"PreToolUse\") {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: \"PreToolUse\",\n permissionDecision: \"deny\",\n permissionDecisionReason: response.reason ?? \"Blocked by hook\",\n },\n }),\n };\n }\n // SubagentStop deny = Stop semantics: the documented continuation shape is\n // the TOP-LEVEL {\"decision\":\"block\",\"reason\"} (keeps the subagent going\n // with `reason` as its next instruction).\n if (event === \"SubagentStop\") {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n decision: \"block\",\n reason: response.reason ?? \"Blocked by hook\",\n }),\n };\n }\n return { exitCode: 0 };\n }\n\n // Context injection: honored on SessionStart and PostToolUse (additionalContext).\n // (SubagentStop accepts only the common output fields — no additionalContext.)\n if (response.additionalContext && (event === \"SessionStart\" || event === \"PostToolUse\")) {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: event,\n additionalContext: response.additionalContext,\n },\n }),\n };\n }\n\n // \"allow\" / unsupported-on-Codex (modify, ask) → passthrough.\n return { exitCode: 0 };\n }\n\n // ── Internal helpers ────────────────────────────────────────────────────\n\n /** Resolve the per-platform server override into an effective ServerDef. */\n private effectiveServer(ctx: InstallContext): ServerDef | undefined {\n const override = ctx.connector.platforms[this.id]?.server;\n if (override === false) return undefined;\n const base = ctx.connector.server;\n if (!base) return undefined;\n return override ? { ...base, ...override } : base;\n }\n\n /** Which canonical hook events to register for Codex, honoring overrides. */\n private effectiveHookEvents(ctx: InstallContext): CodexHookEventName[] {\n const override = ctx.connector.platforms[this.id]?.hooks;\n if (override === false) return [];\n return CODEX_HOOK_EVENTS.filter((e) => ctx.connector.hookEvents.includes(e));\n }\n\n /** Declared events Codex has no analog for — install reports a warn-skip. */\n private warnSkipHookEvents(ctx: InstallContext): HookEventName[] {\n const override = ctx.connector.platforms[this.id]?.hooks;\n if (override === false) return [];\n return ctx.connector.hookEvents.filter((e) => WARN_SKIP_EVENTS.has(e));\n }\n\n /**\n * Render the `[mcp_servers.<id>]` table. TOML has NO interpolation, so every\n * `${env:VAR}` is resolved to a literal at install time. The env table is a\n * plain string→string map. Honors the telemetry serve-wrapper.\n */\n private renderMcpEntry(ctx: InstallContext, server: ServerDef): CodexMcpEntry {\n let command = server.command as string;\n let args = [...(server.args ?? [])];\n\n if (shouldWrapForTelemetry(server, ctx.connector.telemetry)) {\n const wrapped = buildServeWrapperCommand(ctx.homeBinPath, ctx.connector.id, command, args, ctx.scope, this.id);\n command = wrapped.command;\n args = wrapped.args;\n }\n\n // Resolve env-refs to literals (TOML cannot interpolate).\n command = resolveEnvRefsDeep(command);\n args = resolveEnvRefsDeep(args);\n\n const entry: CodexMcpEntry = { command };\n if (args.length > 0) entry.args = args;\n\n if (server.env && Object.keys(server.env).length > 0) {\n const env: Record<string, string> = {};\n for (const [k, v] of Object.entries(resolveEnvRefsDeep(server.env))) {\n env[k] = String(v);\n }\n entry.env = env;\n }\n return entry;\n }\n\n /** Render one hooks.json entry pointing at the stable home binary. */\n private renderHookEntry(ctx: InstallContext, event: CodexHookEventName): CodexHookEntry {\n const command = buildHomeBinHookCommand(\n ctx.homeBinPath,\n \"codex\",\n event,\n ctx.connector.id,\n );\n const entry: CodexHookEntry = { hooks: [{ type: \"command\", command }] };\n // PermissionRequest matches tool names exactly like PreToolUse (Bash,\n // apply_patch aliases, mcp__* names), so it carries the same charset-clean\n // matcher. Subagent* match agent_type — register \"\" (all agents) and let the\n // universal entrypoint apply the connector's own matcher at runtime.\n if (event === \"PreToolUse\" || event === \"PermissionRequest\") {\n entry.matcher = PRE_TOOL_USE_MATCHER;\n } else entry.matcher = \"\";\n return entry;\n }\n\n /** Does this hooks.json entry belong to this connector (by home-bin command)? */\n private isOurEntry(ctx: InstallContext, event: CodexHookEventName, entry: CodexHookEntry): boolean {\n if (!entry || typeof entry !== \"object\" || !Array.isArray(entry.hooks)) return false;\n const ours = buildHomeBinHookCommand(ctx.homeBinPath, \"codex\", event, ctx.connector.id);\n const needle = ours.replace(/\\\\/g, \"/\");\n return entry.hooks.some((h) => (h.command ?? \"\").replace(/\\\\/g, \"/\") === needle);\n }\n\n private readHooksFile(path: string): CodexHooksFile {\n return this.readJson<CodexHooksFile>(path) ?? {};\n }\n\n /** Get-or-create a nested table inside a parsed TOML object. */\n private tomlBucket(cfg: Record<string, unknown>, key: string): Record<string, unknown> {\n const existing = cfg[key];\n if (existing && typeof existing === \"object\" && !Array.isArray(existing)) {\n return existing as Record<string, unknown>;\n }\n const fresh: Record<string, unknown> = {};\n cfg[key] = fresh;\n return fresh;\n }\n\n private normalizeSource(raw: string | undefined): \"startup\" | \"compact\" | \"resume\" | \"clear\" {\n switch (raw) {\n case \"compact\":\n return \"compact\";\n case \"resume\":\n return \"resume\";\n case \"clear\":\n return \"clear\";\n default:\n return \"startup\";\n }\n }\n}\n\nexport const adapter = new CodexAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAS,YAAY,cAAc,qBAAqB;AACxD,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY;AAE9B,OAAO,UAAU;AAoFjB,IAAM,oBAAoB;AAAA,EACxB;AAA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O;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF;AACF;AAEO,IAAM,UAAU,IAAI,aAAa;AACxC,IAAO,gBAAQ;","names":[]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-DBQMX75U.js";
|
|
5
5
|
import {
|
|
6
6
|
BaseAdapter
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-PD4VFEBY.js";
|
|
8
8
|
import "./chunk-7L6ITC4T.js";
|
|
9
9
|
import {
|
|
10
10
|
buildHomeBinHookCommand,
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
isHomeBinHookCommand,
|
|
13
13
|
shouldWrapForTelemetry
|
|
14
14
|
} from "./chunk-MEH7GC7R.js";
|
|
15
|
+
import "./chunk-N6HH7K6P.js";
|
|
15
16
|
import "./chunk-TRQKHP7D.js";
|
|
16
17
|
|
|
17
18
|
// src/adapters/copilot-cli/index.ts
|
|
@@ -26,6 +27,9 @@ var CopilotCliAdapter = class extends BaseAdapter {
|
|
|
26
27
|
name = "GitHub Copilot CLI";
|
|
27
28
|
paradigm = "json-stdio";
|
|
28
29
|
capabilities = {
|
|
30
|
+
// Memory surface: AGENTS.md-first managed block (project <projectDir>/AGENTS.md
|
|
31
|
+
// via the base default; user scope → ~/.copilot/copilot-instructions.md below).
|
|
32
|
+
supportsMemory: true,
|
|
29
33
|
// Copilot CLI delivers the full Claude-compatible lifecycle event set.
|
|
30
34
|
preToolUse: true,
|
|
31
35
|
postToolUse: true,
|
|
@@ -35,6 +39,13 @@ var CopilotCliAdapter = class extends BaseAdapter {
|
|
|
35
39
|
userPromptSubmit: true,
|
|
36
40
|
stop: true,
|
|
37
41
|
notification: true,
|
|
42
|
+
// Newer events — Copilot CLI has native analogs for all four:
|
|
43
|
+
// permissionRequest (decision control), postToolUseFailure (recovery
|
|
44
|
+
// guidance), subagentStart (context-only), subagentStop (blockable).
|
|
45
|
+
permissionRequest: true,
|
|
46
|
+
postToolUseFailure: true,
|
|
47
|
+
subagentStart: true,
|
|
48
|
+
subagentStop: true,
|
|
38
49
|
// PreToolUse is fail-closed and can rewrite tool input (updatedInput); a
|
|
39
50
|
// PostToolUse hook cannot rewrite already-emitted tool output.
|
|
40
51
|
canModifyArgs: true,
|
|
@@ -66,6 +77,22 @@ var CopilotCliAdapter = class extends BaseAdapter {
|
|
|
66
77
|
confidence: installed ? "high" : "low"
|
|
67
78
|
};
|
|
68
79
|
}
|
|
80
|
+
// ── Memory surface: user-scope global instructions file ─────────────────
|
|
81
|
+
// Project scope stays on the AGENTS.md base default (root AGENTS.md is the
|
|
82
|
+
// primary instructions file). User scope targets Copilot CLI's documented
|
|
83
|
+
// $HOME/.copilot/copilot-instructions.md — a markdown file shared with other
|
|
84
|
+
// writers, so the managed block (not whole-file ownership) applies as usual.
|
|
85
|
+
memoryTargets(ctx) {
|
|
86
|
+
if (this.memoryOverride(ctx)?.path || ctx.scope !== "user") {
|
|
87
|
+
return super.memoryTargets(ctx);
|
|
88
|
+
}
|
|
89
|
+
return [
|
|
90
|
+
{
|
|
91
|
+
path: join(homedir(), ".copilot", "copilot-instructions.md"),
|
|
92
|
+
reason: "copilot-cli global instructions (~/.copilot/copilot-instructions.md)"
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
}
|
|
69
96
|
// ── Native paths ─────────────────────────────────────────────────────────
|
|
70
97
|
/** Copilot CLI is user/global only — scope is ignored. */
|
|
71
98
|
getConfigDir(_ctx) {
|
|
@@ -535,6 +562,46 @@ var CopilotCliAdapter = class extends BaseAdapter {
|
|
|
535
562
|
};
|
|
536
563
|
return ev;
|
|
537
564
|
}
|
|
565
|
+
case "PermissionRequest": {
|
|
566
|
+
const ev = {
|
|
567
|
+
...base,
|
|
568
|
+
toolName: input.tool_name ?? "",
|
|
569
|
+
toolInput: input.tool_input ?? {},
|
|
570
|
+
...Array.isArray(input.permission_suggestions) ? { permissionSuggestions: input.permission_suggestions } : {}
|
|
571
|
+
};
|
|
572
|
+
return ev;
|
|
573
|
+
}
|
|
574
|
+
case "PostToolUseFailure": {
|
|
575
|
+
const ev = {
|
|
576
|
+
...base,
|
|
577
|
+
toolName: input.tool_name ?? "",
|
|
578
|
+
toolInput: input.tool_input ?? {},
|
|
579
|
+
error: typeof input.error === "string" ? input.error : "",
|
|
580
|
+
...typeof input.tool_use_id === "string" ? { toolUseId: input.tool_use_id } : {},
|
|
581
|
+
...typeof input.is_interrupt === "boolean" ? { isInterrupt: input.is_interrupt } : {},
|
|
582
|
+
...typeof input.duration_ms === "number" ? { durationMs: input.duration_ms } : {}
|
|
583
|
+
};
|
|
584
|
+
return ev;
|
|
585
|
+
}
|
|
586
|
+
case "SubagentStart": {
|
|
587
|
+
const ev = {
|
|
588
|
+
...base,
|
|
589
|
+
...typeof input.agent_id === "string" ? { agentId: input.agent_id } : {},
|
|
590
|
+
...typeof input.agent_type === "string" ? { agentType: input.agent_type } : {}
|
|
591
|
+
};
|
|
592
|
+
return ev;
|
|
593
|
+
}
|
|
594
|
+
case "SubagentStop": {
|
|
595
|
+
const ev = {
|
|
596
|
+
...base,
|
|
597
|
+
...typeof input.agent_id === "string" ? { agentId: input.agent_id } : {},
|
|
598
|
+
...typeof input.agent_type === "string" ? { agentType: input.agent_type } : {},
|
|
599
|
+
...typeof input.agent_transcript_path === "string" ? { agentTranscriptPath: input.agent_transcript_path } : {},
|
|
600
|
+
...typeof input.last_assistant_message === "string" ? { lastAssistantMessage: input.last_assistant_message } : {},
|
|
601
|
+
...typeof input.stop_hook_active === "boolean" ? { stopHookActive: input.stop_hook_active } : {}
|
|
602
|
+
};
|
|
603
|
+
return ev;
|
|
604
|
+
}
|
|
538
605
|
default: {
|
|
539
606
|
const _never = event;
|
|
540
607
|
throw new Error(`unsupported copilot-cli hook event: ${String(_never)}`);
|
|
@@ -545,7 +612,47 @@ var CopilotCliAdapter = class extends BaseAdapter {
|
|
|
545
612
|
formatReply(event, response) {
|
|
546
613
|
const hookEventName = event;
|
|
547
614
|
const decision = response.decision ?? "allow";
|
|
615
|
+
if (event === "PermissionRequest") {
|
|
616
|
+
if (response.decision === "deny") {
|
|
617
|
+
return this.stdout({
|
|
618
|
+
hookSpecificOutput: {
|
|
619
|
+
hookEventName,
|
|
620
|
+
decision: {
|
|
621
|
+
behavior: "deny",
|
|
622
|
+
message: response.reason ?? "Blocked by hook"
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
if (response.decision === "allow" || response.decision === "modify" && response.updatedInput) {
|
|
628
|
+
return this.stdout({
|
|
629
|
+
hookSpecificOutput: {
|
|
630
|
+
hookEventName,
|
|
631
|
+
decision: {
|
|
632
|
+
behavior: "allow",
|
|
633
|
+
...response.updatedInput ? { updatedInput: response.updatedInput } : {}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
return { exitCode: 0 };
|
|
639
|
+
}
|
|
640
|
+
if (event === "PostToolUseFailure" || event === "SubagentStart") {
|
|
641
|
+
const context = decision === "context" ? response.additionalContext : decision === "deny" ? response.reason ?? response.additionalContext : void 0;
|
|
642
|
+
if (context) {
|
|
643
|
+
return this.stdout({
|
|
644
|
+
hookSpecificOutput: { hookEventName, additionalContext: context }
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
return { exitCode: 0 };
|
|
648
|
+
}
|
|
548
649
|
if (decision === "deny") {
|
|
650
|
+
if (event === "SubagentStop") {
|
|
651
|
+
return this.stdout({
|
|
652
|
+
decision: "block",
|
|
653
|
+
reason: response.reason ?? "Blocked by hook"
|
|
654
|
+
});
|
|
655
|
+
}
|
|
549
656
|
return this.stdout({
|
|
550
657
|
hookSpecificOutput: {
|
|
551
658
|
hookEventName,
|
|
@@ -619,4 +726,4 @@ export {
|
|
|
619
726
|
adapter,
|
|
620
727
|
copilot_cli_default as default
|
|
621
728
|
};
|
|
622
|
-
//# sourceMappingURL=copilot-cli-
|
|
729
|
+
//# sourceMappingURL=copilot-cli-IPISKO3V.js.map
|