@agiflowai/hooks-adapter 0.1.0 → 0.1.2

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/dist/index.cjs CHANGED
@@ -359,6 +359,34 @@ var GeminiCliAdapter = class extends BaseAdapter {
359
359
  }
360
360
  };
361
361
  //#endregion
362
+ //#region src/adapters/CodexAdapter.ts
363
+ /**
364
+ * CodexAdapter - Adapter for OpenAI Codex CLI hook format
365
+ *
366
+ * DESIGN PATTERNS:
367
+ * - Adapter pattern: Converts Codex CLI hook format to normalized format
368
+ * - Reuse over duplication: Codex's hook wire contract matches Claude Code's, so
369
+ * this extends ClaudeCodeAdapter rather than re-implementing the same I/O
370
+ *
371
+ * WHY THIS MIRRORS CLAUDE CODE:
372
+ * Codex CLI's hook system uses the same event names (PreToolUse, PostToolUse,
373
+ * Stop, UserPromptSubmit), the same stdin fields (cwd, session_id, tool_name,
374
+ * tool_input, tool_use_id, permission_mode, hook_event_name), and the same stdout
375
+ * shape (`hookSpecificOutput.permissionDecision: 'allow' | 'deny' | 'ask'`).
376
+ * The differences are payload-level, not wire-level: Codex adds turn_id/model and
377
+ * creates files via the `apply_patch` tool (the patch lives in tool_input.command),
378
+ * which the scaffold-mcp hook handles — not this adapter.
379
+ *
380
+ * AVOID:
381
+ * - Re-implementing parsing/formatting that ClaudeCodeAdapter already provides
382
+ */
383
+ /**
384
+ * Adapter for OpenAI Codex CLI hooks. Codex's hook stdin/stdout contract matches
385
+ * Claude Code's, so parsing and response formatting are inherited verbatim from
386
+ * {@link ClaudeCodeAdapter}.
387
+ */
388
+ var CodexAdapter = class extends ClaudeCodeAdapter {};
389
+ //#endregion
362
390
  //#region src/services/ExecutionLogService.ts
363
391
  /**
364
392
  * ExecutionLogService - Tracks hook executions to prevent duplicate actions
@@ -751,6 +779,7 @@ exports.BEFORE_TOOL_USE = BEFORE_TOOL_USE;
751
779
  exports.BaseAdapter = BaseAdapter;
752
780
  exports.ClaudeCodeAdapter = ClaudeCodeAdapter;
753
781
  exports.ClaudeCodeHookTypes = ClaudeCodeHookTypes;
782
+ exports.CodexAdapter = CodexAdapter;
754
783
  exports.DECISION_ALLOW = DECISION_ALLOW;
755
784
  exports.DECISION_ASK = DECISION_ASK;
756
785
  exports.DECISION_DENY = DECISION_DENY;
package/dist/index.d.cts CHANGED
@@ -363,6 +363,20 @@ declare class GeminiCliAdapter extends BaseAdapter<GeminiCliHookInput> {
363
363
  formatOutput(response: HookResponse): string;
364
364
  }
365
365
  //#endregion
366
+ //#region src/adapters/CodexAdapter.d.ts
367
+ /**
368
+ * Codex CLI hook input. Structurally identical to the Claude Code hook input on the
369
+ * wire (Codex additionally sends `turn_id`/`model`, which the scaffold hook does not
370
+ * read), so it reuses {@link ClaudeCodeHookInput}.
371
+ */
372
+ type CodexHookInput = ClaudeCodeHookInput;
373
+ /**
374
+ * Adapter for OpenAI Codex CLI hooks. Codex's hook stdin/stdout contract matches
375
+ * Claude Code's, so parsing and response formatting are inherited verbatim from
376
+ * {@link ClaudeCodeAdapter}.
377
+ */
378
+ declare class CodexAdapter extends ClaudeCodeAdapter {}
379
+ //#endregion
366
380
  //#region src/services/ExecutionLogService.d.ts
367
381
  /**
368
382
  * Log statistics returned by getStats method
@@ -590,4 +604,4 @@ interface ParsedHookType {
590
604
  */
591
605
  declare function parseHookType(hookType: string): ParsedHookType;
592
606
  //#endregion
593
- export { AFTER_TOOL_USE, BEFORE_TOOL_USE, BaseAdapter, ClaudeCodeAdapter, ClaudeCodeHookInput, ClaudeCodeHookType, ClaudeCodeHookTypes, ClaudeCodePostToolUseInput, ClaudeCodePreToolUseInput, ClaudeCodeStopInput, ClaudeCodeTaskCompletedInput, ClaudeCodeUserPromptSubmitInput, DECISION_ALLOW, DECISION_ASK, DECISION_DENY, DECISION_SKIP, Decision, ExecutionLogService, GeminiCliAdapter, GeminiCliHookInput, GeminiCliHookType, GeminiCliHookTypes, HasExecutedParams, HookContext, HookResponse, HookType, LogEntry, LogExecutionParams, LogStats, POST_TOOL_USE, PRE_TOOL_USE, PendingScaffoldLogEntry, STOP, ScaffoldExecution, TASK_COMPLETED, ToolResult, ToolResultContentItem, USER_PROMPT_SUBMIT, isHookContext, isHookResponse, parseHookType };
607
+ export { AFTER_TOOL_USE, BEFORE_TOOL_USE, BaseAdapter, ClaudeCodeAdapter, ClaudeCodeHookInput, ClaudeCodeHookType, ClaudeCodeHookTypes, ClaudeCodePostToolUseInput, ClaudeCodePreToolUseInput, ClaudeCodeStopInput, ClaudeCodeTaskCompletedInput, ClaudeCodeUserPromptSubmitInput, CodexAdapter, CodexHookInput, DECISION_ALLOW, DECISION_ASK, DECISION_DENY, DECISION_SKIP, Decision, ExecutionLogService, GeminiCliAdapter, GeminiCliHookInput, GeminiCliHookType, GeminiCliHookTypes, HasExecutedParams, HookContext, HookResponse, HookType, LogEntry, LogExecutionParams, LogStats, POST_TOOL_USE, PRE_TOOL_USE, PendingScaffoldLogEntry, STOP, ScaffoldExecution, TASK_COMPLETED, ToolResult, ToolResultContentItem, USER_PROMPT_SUBMIT, isHookContext, isHookResponse, parseHookType };
package/dist/index.d.mts CHANGED
@@ -363,6 +363,20 @@ declare class GeminiCliAdapter extends BaseAdapter<GeminiCliHookInput> {
363
363
  formatOutput(response: HookResponse): string;
364
364
  }
365
365
  //#endregion
366
+ //#region src/adapters/CodexAdapter.d.ts
367
+ /**
368
+ * Codex CLI hook input. Structurally identical to the Claude Code hook input on the
369
+ * wire (Codex additionally sends `turn_id`/`model`, which the scaffold hook does not
370
+ * read), so it reuses {@link ClaudeCodeHookInput}.
371
+ */
372
+ type CodexHookInput = ClaudeCodeHookInput;
373
+ /**
374
+ * Adapter for OpenAI Codex CLI hooks. Codex's hook stdin/stdout contract matches
375
+ * Claude Code's, so parsing and response formatting are inherited verbatim from
376
+ * {@link ClaudeCodeAdapter}.
377
+ */
378
+ declare class CodexAdapter extends ClaudeCodeAdapter {}
379
+ //#endregion
366
380
  //#region src/services/ExecutionLogService.d.ts
367
381
  /**
368
382
  * Log statistics returned by getStats method
@@ -590,4 +604,4 @@ interface ParsedHookType {
590
604
  */
591
605
  declare function parseHookType(hookType: string): ParsedHookType;
592
606
  //#endregion
593
- export { AFTER_TOOL_USE, BEFORE_TOOL_USE, BaseAdapter, ClaudeCodeAdapter, ClaudeCodeHookInput, ClaudeCodeHookType, ClaudeCodeHookTypes, ClaudeCodePostToolUseInput, ClaudeCodePreToolUseInput, ClaudeCodeStopInput, ClaudeCodeTaskCompletedInput, ClaudeCodeUserPromptSubmitInput, DECISION_ALLOW, DECISION_ASK, DECISION_DENY, DECISION_SKIP, Decision, ExecutionLogService, GeminiCliAdapter, GeminiCliHookInput, GeminiCliHookType, GeminiCliHookTypes, HasExecutedParams, HookContext, HookResponse, HookType, LogEntry, LogExecutionParams, LogStats, POST_TOOL_USE, PRE_TOOL_USE, PendingScaffoldLogEntry, STOP, ScaffoldExecution, TASK_COMPLETED, ToolResult, ToolResultContentItem, USER_PROMPT_SUBMIT, isHookContext, isHookResponse, parseHookType };
607
+ export { AFTER_TOOL_USE, BEFORE_TOOL_USE, BaseAdapter, ClaudeCodeAdapter, ClaudeCodeHookInput, ClaudeCodeHookType, ClaudeCodeHookTypes, ClaudeCodePostToolUseInput, ClaudeCodePreToolUseInput, ClaudeCodeStopInput, ClaudeCodeTaskCompletedInput, ClaudeCodeUserPromptSubmitInput, CodexAdapter, CodexHookInput, DECISION_ALLOW, DECISION_ASK, DECISION_DENY, DECISION_SKIP, Decision, ExecutionLogService, GeminiCliAdapter, GeminiCliHookInput, GeminiCliHookType, GeminiCliHookTypes, HasExecutedParams, HookContext, HookResponse, HookType, LogEntry, LogExecutionParams, LogStats, POST_TOOL_USE, PRE_TOOL_USE, PendingScaffoldLogEntry, STOP, ScaffoldExecution, TASK_COMPLETED, ToolResult, ToolResultContentItem, USER_PROMPT_SUBMIT, isHookContext, isHookResponse, parseHookType };
package/dist/index.mjs CHANGED
@@ -332,6 +332,34 @@ var GeminiCliAdapter = class extends BaseAdapter {
332
332
  }
333
333
  };
334
334
  //#endregion
335
+ //#region src/adapters/CodexAdapter.ts
336
+ /**
337
+ * CodexAdapter - Adapter for OpenAI Codex CLI hook format
338
+ *
339
+ * DESIGN PATTERNS:
340
+ * - Adapter pattern: Converts Codex CLI hook format to normalized format
341
+ * - Reuse over duplication: Codex's hook wire contract matches Claude Code's, so
342
+ * this extends ClaudeCodeAdapter rather than re-implementing the same I/O
343
+ *
344
+ * WHY THIS MIRRORS CLAUDE CODE:
345
+ * Codex CLI's hook system uses the same event names (PreToolUse, PostToolUse,
346
+ * Stop, UserPromptSubmit), the same stdin fields (cwd, session_id, tool_name,
347
+ * tool_input, tool_use_id, permission_mode, hook_event_name), and the same stdout
348
+ * shape (`hookSpecificOutput.permissionDecision: 'allow' | 'deny' | 'ask'`).
349
+ * The differences are payload-level, not wire-level: Codex adds turn_id/model and
350
+ * creates files via the `apply_patch` tool (the patch lives in tool_input.command),
351
+ * which the scaffold-mcp hook handles — not this adapter.
352
+ *
353
+ * AVOID:
354
+ * - Re-implementing parsing/formatting that ClaudeCodeAdapter already provides
355
+ */
356
+ /**
357
+ * Adapter for OpenAI Codex CLI hooks. Codex's hook stdin/stdout contract matches
358
+ * Claude Code's, so parsing and response formatting are inherited verbatim from
359
+ * {@link ClaudeCodeAdapter}.
360
+ */
361
+ var CodexAdapter = class extends ClaudeCodeAdapter {};
362
+ //#endregion
335
363
  //#region src/services/ExecutionLogService.ts
336
364
  /**
337
365
  * ExecutionLogService - Tracks hook executions to prevent duplicate actions
@@ -719,4 +747,4 @@ function parseHookType(hookType) {
719
747
  };
720
748
  }
721
749
  //#endregion
722
- export { AFTER_TOOL_USE, BEFORE_TOOL_USE, BaseAdapter, ClaudeCodeAdapter, ClaudeCodeHookTypes, DECISION_ALLOW, DECISION_ASK, DECISION_DENY, DECISION_SKIP, ExecutionLogService, GeminiCliAdapter, GeminiCliHookTypes, POST_TOOL_USE, PRE_TOOL_USE, STOP, TASK_COMPLETED, USER_PROMPT_SUBMIT, isHookContext, isHookResponse, parseHookType };
750
+ export { AFTER_TOOL_USE, BEFORE_TOOL_USE, BaseAdapter, ClaudeCodeAdapter, ClaudeCodeHookTypes, CodexAdapter, DECISION_ALLOW, DECISION_ASK, DECISION_DENY, DECISION_SKIP, ExecutionLogService, GeminiCliAdapter, GeminiCliHookTypes, POST_TOOL_USE, PRE_TOOL_USE, STOP, TASK_COMPLETED, USER_PROMPT_SUBMIT, isHookContext, isHookResponse, parseHookType };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agiflowai/hooks-adapter",
3
3
  "description": "Hook adapters for normalizing AI agent hook formats (Claude Code, Gemini, etc.)",
4
- "version": "0.1.0",
4
+ "version": "0.1.2",
5
5
  "license": "AGPL-3.0",
6
6
  "author": "AgiflowIO",
7
7
  "repository": {
@@ -25,8 +25,8 @@
25
25
  "README.md"
26
26
  ],
27
27
  "dependencies": {
28
- "@agiflowai/aicode-utils": "1.1.0",
29
- "@agiflowai/coding-agent-bridge": "1.1.0"
28
+ "@agiflowai/aicode-utils": "1.3.0",
29
+ "@agiflowai/coding-agent-bridge": "1.3.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "25.6.0",