@makaio/client-codex 1.0.0-dev-1786014320559 → 1.0.0-dev-1789609124644
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 +9 -4
- package/dist/{codex-client-session-service-epcEX-w5.mjs → codex-client-session-service-CsIoRrhH.mjs} +648 -106
- package/dist/index.mjs +2 -2
- package/dist/runtime/codex-client-session-service.d.ts +11 -0
- package/dist/runtime/fork-sniff.d.ts +101 -0
- package/dist/runtime/hook-normalizer.d.ts +55 -26
- package/dist/runtime/hook-response-contracts.d.ts +15 -1
- package/dist/runtime/package.mjs +1 -1
- package/dist/runtime/schemas.d.ts +21 -1
- package/dist/runtime/wiring.d.ts +9 -0
- package/dist/server.mjs +1 -1
- package/dist/{src-BMTPLcPK.mjs → src-osBCBvw6.mjs} +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as CodexConfigHooksAddResponseSchema, B as CodexScopeHookRecordSchema, D as CodexWiringSchemas, F as CodexConfigSchemas, I as CodexHookEntrySchema, L as CodexNativeCommandHookSchema, M as CodexConfigHooksListResponseSchema, N as CodexConfigHooksRemoveRequestSchema, O as AbsolutePathSchema, P as CodexConfigHooksRemoveResponseSchema, R as CodexNativeHookMatcherGroupSchema, U as clientDefinition, V as CodexScopeSchema, j as CodexConfigHooksListRequestSchema, k as CodexConfigHooksAddRequestSchema, o as CodexClientSubjects, t as CodexClientSessionService, z as CodexNativeHooksFileSchema } from "./codex-client-session-service-
|
|
2
|
-
import { t as codexPackage } from "./src-
|
|
1
|
+
import { A as CodexConfigHooksAddResponseSchema, B as CodexScopeHookRecordSchema, D as CodexWiringSchemas, F as CodexConfigSchemas, I as CodexHookEntrySchema, L as CodexNativeCommandHookSchema, M as CodexConfigHooksListResponseSchema, N as CodexConfigHooksRemoveRequestSchema, O as AbsolutePathSchema, P as CodexConfigHooksRemoveResponseSchema, R as CodexNativeHookMatcherGroupSchema, U as clientDefinition, V as CodexScopeSchema, j as CodexConfigHooksListRequestSchema, k as CodexConfigHooksAddRequestSchema, o as CodexClientSubjects, t as CodexClientSessionService, z as CodexNativeHooksFileSchema } from "./codex-client-session-service-CsIoRrhH.mjs";
|
|
2
|
+
import { t as codexPackage } from "./src-osBCBvw6.mjs";
|
|
3
3
|
|
|
4
4
|
export { AbsolutePathSchema, CodexClientSessionService, CodexClientSubjects, CodexConfigHooksAddRequestSchema, CodexConfigHooksAddResponseSchema, CodexConfigHooksListRequestSchema, CodexConfigHooksListResponseSchema, CodexConfigHooksRemoveRequestSchema, CodexConfigHooksRemoveResponseSchema, CodexConfigSchemas, CodexHookEntrySchema, CodexNativeCommandHookSchema, CodexNativeHookMatcherGroupSchema, CodexNativeHooksFileSchema, CodexScopeHookRecordSchema, CodexScopeSchema, CodexWiringSchemas, clientDefinition, codexPackage };
|
|
@@ -193,4 +193,15 @@ export declare class CodexClientSessionService extends BaseService {
|
|
|
193
193
|
* @returns True when the native hook should remain raw-only
|
|
194
194
|
*/
|
|
195
195
|
private isAdapterManagedSession;
|
|
196
|
+
/**
|
|
197
|
+
* Returns true when a normalized event should be suppressed by the
|
|
198
|
+
* adapter-managed gate — that is, when the session is adapter-managed AND the
|
|
199
|
+
* subject is one the adapter emits AND the event is not a compaction or clear
|
|
200
|
+
* restart start (which have no adapter counterpart and must always be forwarded).
|
|
201
|
+
* @param normalized - Normalized hook event to evaluate
|
|
202
|
+
* @param isManagedSession - Whether the originating session is adapter-managed
|
|
203
|
+
* @returns True when the event should be dropped from the native-hook path
|
|
204
|
+
*/
|
|
205
|
+
private shouldSuppressForManagedSession;
|
|
206
|
+
private enrichForkLineage;
|
|
196
207
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fork lineage sniff for Codex rollout files.
|
|
3
|
+
*
|
|
4
|
+
* Codex records every thread as a JSONL *rollout* file. The first line is the
|
|
5
|
+
* thread's own `session_meta` record; when the thread was created by forking
|
|
6
|
+
* another thread, that record carries `forked_from_id` — the parent thread id.
|
|
7
|
+
* Codex then copies the parent's persisted rollout items verbatim into the
|
|
8
|
+
* child file, so the parent's own `session_meta` line appears *later* in the
|
|
9
|
+
* same file.
|
|
10
|
+
*
|
|
11
|
+
* ## Why a sniff is needed
|
|
12
|
+
*
|
|
13
|
+
* The `SessionStart` hook payload has no lineage field at all: it carries
|
|
14
|
+
* `session_id`, `transcript_path`, `cwd`, `hook_event_name`, `model`,
|
|
15
|
+
* `permission_mode` and `source` — nothing else. A fork also reports
|
|
16
|
+
* `source: 'startup'`, exactly like a brand-new thread, so the hook alone
|
|
17
|
+
* cannot distinguish the two. `transcript_path` points at the rollout file
|
|
18
|
+
* the CLI has just materialized for the starting thread, which makes the
|
|
19
|
+
* rollout head the only lineage source available at session-start time.
|
|
20
|
+
*
|
|
21
|
+
* ## Detection invariant
|
|
22
|
+
*
|
|
23
|
+
* The **first** `session_meta` record in the file is the file's own. Any later
|
|
24
|
+
* `session_meta` record was copied from an ancestor and must be ignored, so the
|
|
25
|
+
* scan stops at the first one it can parse:
|
|
26
|
+
*
|
|
27
|
+
* - `forked_from_id` present and different from the starting thread's own id
|
|
28
|
+
* → fork child; that id is the direct parent.
|
|
29
|
+
* - `forked_from_id` absent (or equal to the own id, which would be a
|
|
30
|
+
* self-reference and is never a usable parent) → no fork signal.
|
|
31
|
+
* - No parseable `session_meta` inside the window → inconclusive; return
|
|
32
|
+
* `undefined`. Fork registration is fill-once on the ingestion side, so a
|
|
33
|
+
* guessed parent would be permanently wrong while deferring is safe.
|
|
34
|
+
*
|
|
35
|
+
* Anchoring the window at the start of the file is what makes the rule sound
|
|
36
|
+
* under a byte cap: the decisive record is the first one, so no earlier record
|
|
37
|
+
* can exist outside the window.
|
|
38
|
+
*
|
|
39
|
+
* ## Design principles
|
|
40
|
+
*
|
|
41
|
+
* - **Pure detection core**: {@link sniffRolloutForkLineage} operates on raw
|
|
42
|
+
* JSONL lines. No I/O, no bus, no dependencies beyond the language runtime.
|
|
43
|
+
* - **Bounded I/O wrapper**: {@link sniffRolloutFork} reads at most
|
|
44
|
+
* {@link SNIFF_MAX_BYTES} from the rollout head, so the hook path never
|
|
45
|
+
* blocks on a large rollout file.
|
|
46
|
+
* - **Fail-open**: any I/O or parse error yields `undefined` (no fork signal);
|
|
47
|
+
* hook processing is never blocked by a sniff failure.
|
|
48
|
+
* @packageDocumentation
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* Maximum number of bytes to read from the rollout head for fork detection.
|
|
52
|
+
*
|
|
53
|
+
* The decisive record is the first line, but that line embeds the thread's
|
|
54
|
+
* `base_instructions`, which can run to several kilobytes. 128 KiB leaves ample
|
|
55
|
+
* headroom for it while keeping the blocking window small. A `session_meta`
|
|
56
|
+
* line longer than the window yields a truncated, unparseable JSON fragment and
|
|
57
|
+
* therefore no signal — the fail-open outcome, not a wrong parent.
|
|
58
|
+
*/
|
|
59
|
+
export declare const SNIFF_MAX_BYTES: number;
|
|
60
|
+
/**
|
|
61
|
+
* Result of the fork lineage sniff.
|
|
62
|
+
*
|
|
63
|
+
* Returned only when the rollout's own `session_meta` names a foreign parent
|
|
64
|
+
* thread; `undefined` means no fork signal was found.
|
|
65
|
+
*/
|
|
66
|
+
export interface CodexForkSniffResult {
|
|
67
|
+
/** Adapter session id of the parent thread. */
|
|
68
|
+
readonly parentAdapterSessionId: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Detect fork lineage from raw rollout JSONL lines.
|
|
72
|
+
*
|
|
73
|
+
* Scans the provided window **forward** from the first line. The window must be
|
|
74
|
+
* anchored at the start of the rollout file (see {@link sniffRolloutFork});
|
|
75
|
+
* under that anchoring, the first `session_meta` record found is the file's own
|
|
76
|
+
* and decides the outcome. Later `session_meta` records belong to ancestors
|
|
77
|
+
* copied into the fork and are never consulted.
|
|
78
|
+
* @param lines - Raw JSONL lines from the rollout head (may include empty
|
|
79
|
+
* strings, partial lines, or non-JSON data)
|
|
80
|
+
* @param hookSessionId - Session id reported by the hook payload (the starting
|
|
81
|
+
* thread's own id)
|
|
82
|
+
* @returns Fork sniff result when the own `session_meta` names a foreign
|
|
83
|
+
* parent, or `undefined` for a plain start / no signal / inconclusive window
|
|
84
|
+
*/
|
|
85
|
+
export declare function sniffRolloutForkLineage(lines: readonly string[], hookSessionId: string): CodexForkSniffResult | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Sniff the rollout file at session-start time to detect fork lineage.
|
|
88
|
+
*
|
|
89
|
+
* Combines the bounded head read with the pure forward-scanning detection core.
|
|
90
|
+
* Because the window is anchored at the start of the file, a byte cap can never
|
|
91
|
+
* produce a wrong parent: the decisive record — the file's own `session_meta` —
|
|
92
|
+
* is either inside the window or the sniff returns `undefined`. Returns
|
|
93
|
+
* `undefined` (no fork signal) on any error; hook processing must never be
|
|
94
|
+
* blocked by a sniff failure.
|
|
95
|
+
* @param rolloutPath - Absolute path to the rollout JSONL file, as reported by
|
|
96
|
+
* the hook payload's `transcript_path`
|
|
97
|
+
* @param hookSessionId - Session id reported by the hook payload
|
|
98
|
+
* @returns Fork sniff result, or `undefined` when no fork is detected or the
|
|
99
|
+
* sniff cannot be performed
|
|
100
|
+
*/
|
|
101
|
+
export declare function sniffRolloutFork(rolloutPath: string, hookSessionId: string): Promise<CodexForkSniffResult | undefined>;
|
|
@@ -5,50 +5,60 @@
|
|
|
5
5
|
* `client:codex.hook.received` to their corresponding
|
|
6
6
|
* `client.session.*` observed-semantics subjects.
|
|
7
7
|
*
|
|
8
|
-
* **Mapping table** (Codex event → global subject):
|
|
8
|
+
* **Mapping table** (Codex event → global subject(s)):
|
|
9
9
|
*
|
|
10
|
-
* | Codex event name
|
|
11
|
-
*
|
|
12
|
-
* | `SessionStart`
|
|
13
|
-
* | `UserPromptSubmit`
|
|
14
|
-
* | `Stop`
|
|
15
|
-
* | `PreToolUse`
|
|
16
|
-
* | `PostToolUse`
|
|
10
|
+
* | Codex event name | Global subject(s) |
|
|
11
|
+
* |------------------|----------------------------------------------------------|
|
|
12
|
+
* | `SessionStart` | `client.session.started` |
|
|
13
|
+
* | `UserPromptSubmit` | `client.session.turn.started`, then `client.session.userPrompt.submitted` |
|
|
14
|
+
* | `Stop` | `client.session.turn.completed` |
|
|
15
|
+
* | `PreToolUse` | `client.session.tool.pre` |
|
|
16
|
+
* | `PostToolUse` | `client.session.tool.post` |
|
|
17
|
+
* | `SubagentStart` | `client.session.subagent.started` |
|
|
18
|
+
* | `SubagentStop` | `client.session.subagent.completed` |
|
|
19
|
+
* | `PreCompact` | `client.session.compaction.pre` |
|
|
20
|
+
* | `PostCompact` | _(raw-only — no global subject)_ |
|
|
17
21
|
*
|
|
18
|
-
* All other event names
|
|
22
|
+
* All other event names return an empty array — they are kept raw only and
|
|
19
23
|
* are never emitted into the global `client.*` namespace.
|
|
20
24
|
*
|
|
21
|
-
* **Source notes:**
|
|
22
|
-
* Codex
|
|
23
|
-
*
|
|
25
|
+
* **Source notes:** Event names are verified against the pinned
|
|
26
|
+
* `rust-v0.144.1` Codex source (`codex-rs/hooks/src/lib.rs`). Update this
|
|
27
|
+
* normalizer when a new binary version changes or adds hook names.
|
|
28
|
+
*
|
|
29
|
+
* **Subagent hooks:** On both `SubagentStart` and `SubagentStop`, the raw
|
|
30
|
+
* `session_id` is the PARENT session id. `adapterSessionId` on the base carries
|
|
31
|
+
* it directly (no stripping). `agentId` identifies the subagent. `turnId` is
|
|
32
|
+
* populated from `turn_id` when the Codex CLI includes it.
|
|
24
33
|
* @packageDocumentation
|
|
25
34
|
*/
|
|
26
35
|
import { ClientSubjects } from '@makaio/framework/clients';
|
|
27
|
-
import type { ClientSessionStarted, ClientSessionUserPromptSubmitted, ClientSessionTurnCompleted, ClientSessionToolPre, ClientSessionToolPost } from '@makaio/framework/contracts/client';
|
|
36
|
+
import type { ClientSessionStarted, ClientSessionUserPromptSubmitted, ClientSessionTurnStarted, ClientSessionTurnCompleted, ClientSessionToolPre, ClientSessionToolPost, ClientSessionSubagentStarted, ClientSessionSubagentCompleted, ClientSessionCompactionPre } from '@makaio/framework/contracts/client';
|
|
28
37
|
import type { RawClientHookPayload } from './schemas.js';
|
|
29
38
|
/**
|
|
30
39
|
* Union of all normalized subject definitions the Codex normalizer can emit.
|
|
31
40
|
*
|
|
32
|
-
* Used as the
|
|
33
|
-
* consumers type-safe without wide `SubjectDefinition` casts.
|
|
41
|
+
* Used as the element type of the array returned by {@link normalizeCodexHook}
|
|
42
|
+
* to keep downstream consumers type-safe without wide `SubjectDefinition` casts.
|
|
34
43
|
*/
|
|
35
|
-
export type CodexNormalizedSubject = typeof ClientSubjects.session.started | typeof ClientSubjects.session.userPrompt.submitted | typeof ClientSubjects.session.turn.completed | typeof ClientSubjects.session.tool.pre | typeof ClientSubjects.session.tool.post;
|
|
44
|
+
export type CodexNormalizedSubject = typeof ClientSubjects.session.started | typeof ClientSubjects.session.userPrompt.submitted | typeof ClientSubjects.session.turn.started | typeof ClientSubjects.session.turn.completed | typeof ClientSubjects.session.tool.pre | typeof ClientSubjects.session.tool.post | typeof ClientSubjects.session.subagent.started | typeof ClientSubjects.session.subagent.completed | typeof ClientSubjects.session.compaction.pre;
|
|
36
45
|
/**
|
|
37
46
|
* Union of all normalized payload types the Codex normalizer can produce.
|
|
38
47
|
*
|
|
39
48
|
* Mirrors the `client.session.*` schema union so callers do not need to
|
|
40
49
|
* import individual payload types from `@makaio/contracts`.
|
|
41
50
|
*/
|
|
42
|
-
export type CodexNormalizedPayload = ClientSessionStarted | ClientSessionUserPromptSubmitted | ClientSessionTurnCompleted | ClientSessionToolPre | ClientSessionToolPost;
|
|
51
|
+
export type CodexNormalizedPayload = ClientSessionStarted | ClientSessionUserPromptSubmitted | ClientSessionTurnStarted | ClientSessionTurnCompleted | ClientSessionToolPre | ClientSessionToolPost | ClientSessionSubagentStarted | ClientSessionSubagentCompleted | ClientSessionCompactionPre;
|
|
43
52
|
/**
|
|
44
53
|
* Discriminated union of normalized Codex hook event results.
|
|
45
54
|
*
|
|
46
55
|
* Each variant pairs a specific `client.session.*` subject with its
|
|
47
|
-
* corresponding strongly-typed payload.
|
|
56
|
+
* corresponding strongly-typed payload. The caller switches on `subject`
|
|
48
57
|
* to obtain a narrowed payload type and call `bus.emit` without casts.
|
|
49
58
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
59
|
+
* {@link normalizeCodexHook} returns an array of these — empty when the event
|
|
60
|
+
* name is unknown (raw-only), and potentially more than one entry for hooks
|
|
61
|
+
* that map to multiple bus events (e.g. `UserPromptSubmit` yields two).
|
|
52
62
|
*/
|
|
53
63
|
export type CodexNormalizedEvent = {
|
|
54
64
|
readonly subject: typeof ClientSubjects.session.started;
|
|
@@ -56,6 +66,9 @@ export type CodexNormalizedEvent = {
|
|
|
56
66
|
} | {
|
|
57
67
|
readonly subject: typeof ClientSubjects.session.userPrompt.submitted;
|
|
58
68
|
readonly payload: ClientSessionUserPromptSubmitted;
|
|
69
|
+
} | {
|
|
70
|
+
readonly subject: typeof ClientSubjects.session.turn.started;
|
|
71
|
+
readonly payload: ClientSessionTurnStarted;
|
|
59
72
|
} | {
|
|
60
73
|
readonly subject: typeof ClientSubjects.session.turn.completed;
|
|
61
74
|
readonly payload: ClientSessionTurnCompleted;
|
|
@@ -65,18 +78,34 @@ export type CodexNormalizedEvent = {
|
|
|
65
78
|
} | {
|
|
66
79
|
readonly subject: typeof ClientSubjects.session.tool.post;
|
|
67
80
|
readonly payload: ClientSessionToolPost;
|
|
81
|
+
} | {
|
|
82
|
+
readonly subject: typeof ClientSubjects.session.subagent.started;
|
|
83
|
+
readonly payload: ClientSessionSubagentStarted;
|
|
84
|
+
} | {
|
|
85
|
+
readonly subject: typeof ClientSubjects.session.subagent.completed;
|
|
86
|
+
readonly payload: ClientSessionSubagentCompleted;
|
|
87
|
+
} | {
|
|
88
|
+
readonly subject: typeof ClientSubjects.session.compaction.pre;
|
|
89
|
+
readonly payload: ClientSessionCompactionPre;
|
|
68
90
|
};
|
|
69
91
|
/**
|
|
70
|
-
* Normalize a raw Codex hook payload into
|
|
92
|
+
* Normalize a raw Codex hook payload into `client.session.*` events.
|
|
93
|
+
*
|
|
94
|
+
* Returns an empty array for unknown or not-yet-modeled event names so the
|
|
95
|
+
* caller skips global emission and keeps the event raw-only in
|
|
96
|
+
* `client:codex.*`. A single hook may map to more than one normalized event:
|
|
97
|
+
* `UserPromptSubmit` yields `turn.started` followed by `userPrompt.submitted`.
|
|
98
|
+
* Emission order within the array is significant and must be preserved by the
|
|
99
|
+
* caller.
|
|
71
100
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
101
|
+
* The `receivedAt` timestamp from the raw hook payload is used as `observedAt`
|
|
102
|
+
* to preserve the original wall-clock time of the observation.
|
|
74
103
|
* @param raw - Raw hook payload delivered on `client:codex.hook.received`
|
|
75
104
|
* @param machineId - Stable runtime identity of the observing machine,
|
|
76
105
|
* caller-supplied by the owning client runtime. Stamped onto
|
|
77
106
|
* `client.session.started` so downstream storage receives the owning
|
|
78
107
|
* machine's identity without deriving it from the writer process.
|
|
79
|
-
* @returns Normalized
|
|
80
|
-
* the event name is unknown
|
|
108
|
+
* @returns Normalized events with subject and typed payload, in emission
|
|
109
|
+
* order; empty when the event name is unknown (raw-only)
|
|
81
110
|
*/
|
|
82
|
-
export declare function normalizeCodexHook(raw: RawClientHookPayload, machineId?: string): CodexNormalizedEvent
|
|
111
|
+
export declare function normalizeCodexHook(raw: RawClientHookPayload, machineId?: string): CodexNormalizedEvent[];
|
|
@@ -2,7 +2,21 @@
|
|
|
2
2
|
import type { InteractionBlockability, ProviderContractCatalogEntry, ProviderContributionEnvelope } from '@makaio/framework/contracts/client';
|
|
3
3
|
export declare const CODEX_CLIENT_ID = "codex";
|
|
4
4
|
export declare const CODEX_CONTRACT_ID = "openai.codex-hook-response";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Semantic version of the Codex hook-response contract.
|
|
7
|
+
*
|
|
8
|
+
* Pinned to the proven capabilities of Codex CLI 0.144.1. Bump this version
|
|
9
|
+
* when a future CLI release expands the native response surface.
|
|
10
|
+
*
|
|
11
|
+
* `1.2.0` adds `SubagentStart` as a request-capable, non-blockable interaction
|
|
12
|
+
* carrying canonical `context.append`. The appended context lands in the
|
|
13
|
+
* *subagent's* context window, not the parent's — proven live, see
|
|
14
|
+
* `runtime/__tests__/fixtures/hook-contracts/probe/subagent-start-context-append.json`.
|
|
15
|
+
* Subagent creation cannot be refused (`continue: false` is parsed for
|
|
16
|
+
* compatibility but does not stop the subagent), so the interaction is
|
|
17
|
+
* non-blockable. Purely additive: every `1.1.0` contributor remains valid.
|
|
18
|
+
*/
|
|
19
|
+
export declare const CODEX_CONTRACT_VERSION = "1.2.0";
|
|
6
20
|
export type CodexBlockEffects = Readonly<{
|
|
7
21
|
decision: 'block';
|
|
8
22
|
reason: string;
|
package/dist/runtime/package.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as createCodexStopBlockEffect, E as normalizeCodexHook, H as CODEX_HOOK_RESPONSE_CAPABILITIES, S as createCodexSessionStartContextEffect, T as createCodexUserPromptSubmitContextEffect, _ as createCodexPreToolUseBlockEffect, a as CODEX_CLIENT_NAMESPACE, b as createCodexPreToolUseUpdateEffect, c as CODEX_CLIENT_ID, d as CODEX_INTERACTION_BLOCKABILITY, f as CODEX_RESPONSE_CAPABILITIES, g as createCodexPostToolUseContextEffect, h as createCodexPostToolUseBlockEffect, i as withCodexNativeAuthSourceLock, l as CODEX_CONTRACT_ID, m as codexProviderContractCatalog, n as buildCodexNativeAuthSourceLockPath, o as CodexClientSubjects, p as CODEX_SUPPORTED_INTERACTIONS, r as executeCodexNativeAuthSourceLock, s as composeCodexHookResponse, t as CodexClientSessionService, u as CODEX_CONTRACT_VERSION, v as createCodexPreToolUseContextEffect, w as createCodexUserPromptSubmitBlockEffect, x as createCodexSessionStartBlockEffect, y as createCodexPreToolUseDenyEffect } from "../codex-client-session-service-
|
|
1
|
+
import { C as createCodexStopBlockEffect, E as normalizeCodexHook, H as CODEX_HOOK_RESPONSE_CAPABILITIES, S as createCodexSessionStartContextEffect, T as createCodexUserPromptSubmitContextEffect, _ as createCodexPreToolUseBlockEffect, a as CODEX_CLIENT_NAMESPACE, b as createCodexPreToolUseUpdateEffect, c as CODEX_CLIENT_ID, d as CODEX_INTERACTION_BLOCKABILITY, f as CODEX_RESPONSE_CAPABILITIES, g as createCodexPostToolUseContextEffect, h as createCodexPostToolUseBlockEffect, i as withCodexNativeAuthSourceLock, l as CODEX_CONTRACT_ID, m as codexProviderContractCatalog, n as buildCodexNativeAuthSourceLockPath, o as CodexClientSubjects, p as CODEX_SUPPORTED_INTERACTIONS, r as executeCodexNativeAuthSourceLock, s as composeCodexHookResponse, t as CodexClientSessionService, u as CODEX_CONTRACT_VERSION, v as createCodexPreToolUseContextEffect, w as createCodexUserPromptSubmitBlockEffect, x as createCodexSessionStartBlockEffect, y as createCodexPreToolUseDenyEffect } from "../codex-client-session-service-CsIoRrhH.mjs";
|
|
2
2
|
import { dep } from "@makaio/framework/contracts";
|
|
3
3
|
import { ClientsCoreToken } from "@makaio/framework/clients";
|
|
4
4
|
|
|
@@ -7,7 +7,14 @@
|
|
|
7
7
|
*
|
|
8
8
|
* The hook name constants below are the canonical event names reported in the
|
|
9
9
|
* `eventName` field of {@link RawClientHookPayload} by the Codex CLI.
|
|
10
|
-
*
|
|
10
|
+
*
|
|
11
|
+
* Event names are verified against the pinned `rust-v0.144.1` Codex source
|
|
12
|
+
* (`codex-rs/hooks/src/lib.rs` — `HOOK_EVENT_NAMES` and
|
|
13
|
+
* `engine/output_parser.rs`). The full set present in 0.144.1 is:
|
|
14
|
+
* `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `Stop`,
|
|
15
|
+
* `SubagentStart`, `SubagentStop`, `PreCompact`, `PostCompact`,
|
|
16
|
+
* `PermissionRequest`. `SessionEnd` and `Interrupt` are NOT present.
|
|
17
|
+
* @see https://github.com/openai/codex/tree/rust-v0.144.1/codex-rs/hooks
|
|
11
18
|
* @packageDocumentation
|
|
12
19
|
*/
|
|
13
20
|
export { RawClientHookPayloadSchema, type RawClientHookPayload } from '@makaio/framework/clients';
|
|
@@ -17,9 +24,22 @@ export { RawClientHookPayloadSchema, type RawClientHookPayload } from '@makaio/f
|
|
|
17
24
|
* These are the events the normalizer translates into `client.session.*` bus
|
|
18
25
|
* emissions. Any event NOT listed here is left as raw `client:codex`
|
|
19
26
|
* namespace data only.
|
|
27
|
+
*
|
|
28
|
+
* Event names are verified against pinned source `rust-v0.144.1`
|
|
29
|
+
* (`codex-rs/hooks/src/lib.rs`).
|
|
20
30
|
*/
|
|
21
31
|
export declare const CODEX_HOOK_SESSION_START = "SessionStart";
|
|
22
32
|
export declare const CODEX_HOOK_USER_PROMPT_SUBMIT = "UserPromptSubmit";
|
|
23
33
|
export declare const CODEX_HOOK_PRE_TOOL_USE = "PreToolUse";
|
|
24
34
|
export declare const CODEX_HOOK_POST_TOOL_USE = "PostToolUse";
|
|
25
35
|
export declare const CODEX_HOOK_STOP = "Stop";
|
|
36
|
+
export declare const CODEX_HOOK_SUBAGENT_START = "SubagentStart";
|
|
37
|
+
export declare const CODEX_HOOK_SUBAGENT_STOP = "SubagentStop";
|
|
38
|
+
export declare const CODEX_HOOK_PRE_COMPACT = "PreCompact";
|
|
39
|
+
export declare const CODEX_HOOK_POST_COMPACT = "PostCompact";
|
|
40
|
+
/**
|
|
41
|
+
* Fires when Codex asks the user for tool permission. Raw ingress only —
|
|
42
|
+
* response surface not yet proven against the pinned CLI source, so no
|
|
43
|
+
* capability is declared for this event.
|
|
44
|
+
*/
|
|
45
|
+
export declare const CODEX_HOOK_PERMISSION_REQUEST = "PermissionRequest";
|
package/dist/runtime/wiring.d.ts
CHANGED
|
@@ -43,6 +43,15 @@ export interface CodexWiringSettings {
|
|
|
43
43
|
export declare const CODEX_HOOK_COMMAND_SENTINEL = "hook received codex";
|
|
44
44
|
/** Sentinel for synchronous Codex hook responses. */
|
|
45
45
|
export declare const CODEX_HOOK_HANDLE_COMMAND_SENTINEL = "hook handle codex";
|
|
46
|
+
/**
|
|
47
|
+
* Timeout for request-mode hooks on context-only (non-blockable) interactions.
|
|
48
|
+
*
|
|
49
|
+
* `hook handle` has no `--debounce-failure`, so a down server would stall every
|
|
50
|
+
* prompt and subagent spawn for the full timeout; context-only hooks fail fast.
|
|
51
|
+
* Blockable interactions retain {@link DEFAULT_HOOK_HANDLE_TIMEOUT_MS} because
|
|
52
|
+
* those must complete before the native client can proceed.
|
|
53
|
+
*/
|
|
54
|
+
export declare const CONTEXT_ONLY_HOOK_HANDLE_TIMEOUT_MS = 1000;
|
|
46
55
|
/**
|
|
47
56
|
* Build the wiring entry list, annotated with installation status, by
|
|
48
57
|
* comparing the expected entries against the currently installed Codex hooks.
|
package/dist/server.mjs
CHANGED