@makaio/client-codex 1.0.0-dev-1789404058608 → 1.0.0-dev-1789642522820

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.
@@ -86,6 +86,7 @@ export declare const clientDefinition: {
86
86
  name: string;
87
87
  frameworkSubject?: string | undefined;
88
88
  responseCapabilities: readonly string[];
89
+ minimumVersion?: string | undefined;
89
90
  }[];
90
91
  };
91
92
  managedInstall?: {
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-epcEX-w5.mjs";
2
- import { t as codexPackage } from "./src-BMTPLcPK.mjs";
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-BrCcbB06.mjs";
2
+ import { t as codexPackage } from "./src-D25LSa6Y.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 };
@@ -39,7 +39,7 @@
39
39
  * @packageDocumentation
40
40
  */
41
41
  import type { IMakaioBus } from '@makaio/framework/bus';
42
- import type { ClientHookProviderContractRegistry, ClientHookResponseRegistry } from '@makaio/framework/clients';
42
+ import type { ClientHookProviderContractRegistry, ClientHookResponseRegistry, ClientSessionTokenSink } from '@makaio/framework/clients';
43
43
  import { BaseService } from '@makaio/framework/service-base';
44
44
  import { CodexClientSettings } from './client-settings.js';
45
45
  import { CodexSessionConfigHandler } from './session-config-handler.js';
@@ -108,6 +108,15 @@ export declare class CodexClientSessionService extends BaseService {
108
108
  */
109
109
  private readonly providerContractRegistry;
110
110
  private readonly hookResponseRegistry;
111
+ /**
112
+ * In-process sink for session correlation tokens.
113
+ *
114
+ * When non-undefined, the {@link onSessionToken} callback hands the token
115
+ * directly to this sink so no bus payload (and no `MAKAIO_DEBUG` bus logger)
116
+ * ever sees the token value. Codex declares no session-token capability, so
117
+ * this will typically remain `undefined`.
118
+ */
119
+ private readonly sessionTokens;
111
120
  /**
112
121
  * Creates a new Codex client session service.
113
122
  * @param bus - Bus instance used for subscribing and emitting events
@@ -122,8 +131,13 @@ export declare class CodexClientSessionService extends BaseService {
122
131
  * from clients-core for registering the Codex hook response contract.
123
132
  * Omit in tests that do not exercise the response pipeline.
124
133
  * @param hookResponseRegistry - Optional contributor registry used by the terminal composer.
134
+ * @param sessionTokens - In-process token sink from clients-core. When
135
+ * supplied, the {@link onSessionToken} callback hands the token directly
136
+ * to the sink — no bus payload (and no `MAKAIO_DEBUG` bus logger) ever
137
+ * sees the token value. Codex declares no session-token capability, so
138
+ * this will typically be `undefined`.
125
139
  */
126
- constructor(bus?: IMakaioBus, settings?: CodexClientSettings, machineId?: string, sessionConfigHandler?: CodexSessionConfigHandler, providerContractRegistry?: ClientHookProviderContractRegistry, hookResponseRegistry?: ClientHookResponseRegistry);
140
+ constructor(bus?: IMakaioBus, settings?: CodexClientSettings, machineId?: string, sessionConfigHandler?: CodexSessionConfigHandler, providerContractRegistry?: ClientHookProviderContractRegistry, hookResponseRegistry?: ClientHookResponseRegistry, sessionTokens?: ClientSessionTokenSink);
127
141
  /**
128
142
  * Register the raw hook ingress handler, the `hook.handle` request handler,
129
143
  * config management request handlers, wiring management request handlers,
@@ -193,4 +207,15 @@ export declare class CodexClientSessionService extends BaseService {
193
207
  * @returns True when the native hook should remain raw-only
194
208
  */
195
209
  private isAdapterManagedSession;
210
+ /**
211
+ * Returns true when a normalized event should be suppressed by the
212
+ * adapter-managed gate — that is, when the session is adapter-managed AND the
213
+ * subject is one the adapter emits AND the event is not a compaction or clear
214
+ * restart start (which have no adapter counterpart and must always be forwarded).
215
+ * @param normalized - Normalized hook event to evaluate
216
+ * @param isManagedSession - Whether the originating session is adapter-managed
217
+ * @returns True when the event should be dropped from the native-hook path
218
+ */
219
+ private shouldSuppressForManagedSession;
220
+ private enrichForkLineage;
196
221
  }
@@ -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 | Global subject |
11
- * |--------------------------|------------------------------------------|
12
- * | `SessionStart` | `client.session.started` |
13
- * | `UserPromptSubmit` | `client.session.userPrompt.submitted` |
14
- * | `Stop` | `client.session.turn.completed` |
15
- * | `PreToolUse` | `client.session.tool.pre` |
16
- * | `PostToolUse` | `client.session.tool.post` |
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 are returned as `null` — they are kept raw only and
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:** The Codex CLI hook event names above reflect the OpenAI
22
- * Codex CLI hook system as documented at the time of authoring. If the binary
23
- * changes its hook names, update {@link CODEX_EVENT_MAP} accordingly.
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 return type of {@link normalizeCodexHook} to keep downstream
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. The caller switches on `subject`
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
- * When the event name is unknown, {@link normalizeCodexHook} returns `null`
51
- * to signal that the event must stay raw-only.
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 a `client.session.*` event.
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
- * Returns `null` for unknown or not-yet-modeled event names so the caller
73
- * skips global emission and keeps the event raw-only in `client:codex.*`.
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 event with subject and typed payload, or `null` when
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 | null;
111
+ export declare function normalizeCodexHook(raw: RawClientHookPayload, machineId?: string): CodexNormalizedEvent[];
@@ -5,6 +5,29 @@ export interface ComposeCodexHookResponseOptions {
5
5
  readonly deadline?: number;
6
6
  readonly signal?: AbortSignal;
7
7
  readonly onDiagnostics?: (diagnostics: readonly CollectionDiagnostic[]) => void;
8
+ /**
9
+ * Receives a `session.token` effect for the runtime to record; never
10
+ * rendered to the client binary's stdout. When several contributors deliver
11
+ * a token, the highest-priority contributor wins (first in the
12
+ * deterministically ordered effects array). Omit when token recording is not
13
+ * required.
14
+ *
15
+ * The sink is skipped (not called) when:
16
+ * - Both `session_id` and `thread_id` are absent from the payload.
17
+ * - The event is `SubagentStart` and `agent_id` is absent or empty —
18
+ * forwarding without an agent id would overwrite the parent session entry.
19
+ *
20
+ * For `SessionStart` and all other events, `agent_id` is ignored even when
21
+ * present in the payload.
22
+ * @param token - Opaque correlation token value.
23
+ * @param scope - Client id, adapter session id, and optional agent id for
24
+ * SubagentStart. The client id is always `'codex'` from this composer.
25
+ */
26
+ readonly onSessionToken?: (token: string, scope: {
27
+ clientId: string;
28
+ adapterSessionId: string;
29
+ agentId?: string;
30
+ }) => void | Promise<void>;
8
31
  }
9
32
  /**
10
33
  * Reduce ordered effects into one provider-valid Codex response.
@@ -22,7 +45,8 @@ export declare function renderCodexNativeResponse(eventName: string, effects: re
22
45
  * Compose one terminal Codex native hook response.
23
46
  * @param registry - Active response contributor registry.
24
47
  * @param payload - Normalized native hook payload.
25
- * @param options - Request deadline, cancellation, and diagnostics hooks.
48
+ * @param options - Request deadline, cancellation, diagnostics hooks, and
49
+ * optional session-token sink.
26
50
  * @returns The composed native response envelope.
27
51
  */
28
52
  export declare function composeCodexHookResponse(registry: ClientHookResponseRegistry, payload: RawClientHookPayload, options?: ComposeCodexHookResponseOptions): Promise<ClientHookHandleResponse>;
@@ -1,8 +1,28 @@
1
- /** Codex 0.144.1 synchronous hook-response contract. @packageDocumentation */
2
1
  import type { InteractionBlockability, ProviderContractCatalogEntry, ProviderContributionEnvelope } from '@makaio/framework/contracts/client';
3
2
  export declare const CODEX_CLIENT_ID = "codex";
4
3
  export declare const CODEX_CONTRACT_ID = "openai.codex-hook-response";
5
- export declare const CODEX_CONTRACT_VERSION = "1.1.0";
4
+ /**
5
+ * Semantic version of the Codex hook-response contract.
6
+ *
7
+ * Pinned to the proven capabilities of Codex CLI 0.144.1. Bump this version
8
+ * when a future CLI release expands the native response surface.
9
+ *
10
+ * `1.2.0` adds `SubagentStart` as a request-capable, non-blockable interaction
11
+ * carrying canonical `context.append`. The appended context lands in the
12
+ * *subagent's* context window, not the parent's — proven live, see
13
+ * `runtime/__tests__/fixtures/hook-contracts/probe/subagent-start-context-append.json`.
14
+ * Subagent creation cannot be refused (`continue: false` is parsed for
15
+ * compatibility but does not stop the subagent), so the interaction is
16
+ * non-blockable. Purely additive: every `1.1.0` contributor remains valid.
17
+ *
18
+ * `1.3.0` adds the canonical `session.token` interaction to the catalog. The
19
+ * definition does not declare it on any Codex event yet (Codex hands its MCP
20
+ * subprocesses no session id). When declared, the composer collects the token
21
+ * and hands it to the in-process token sink of the client runtime; it is never
22
+ * rendered to the client binary's stdout. Purely additive: every `1.2.0`
23
+ * contributor remains valid.
24
+ */
25
+ export declare const CODEX_CONTRACT_VERSION = "1.3.0";
6
26
  export type CodexBlockEffects = Readonly<{
7
27
  decision: 'block';
8
28
  reason: string;
@@ -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-epcEX-w5.mjs";
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-BrCcbB06.mjs";
2
2
  import { dep } from "@makaio/framework/contracts";
3
3
  import { ClientsCoreToken } from "@makaio/framework/clients";
4
4
 
@@ -44,7 +44,7 @@ const codexClientRuntimePackage = {
44
44
  create: (ctx) => {
45
45
  const clientsCore = ctx.getService(ClientsCoreToken);
46
46
  if (!clientsCore) throw new Error("codex.runtime requires makaio.clients-core");
47
- return new CodexClientSessionService(ctx.bus, void 0, ctx.machineId, void 0, clientsCore.providerContractRegistry, clientsCore.hookResponseRegistry);
47
+ return new CodexClientSessionService(ctx.bus, void 0, ctx.machineId, void 0, clientsCore.providerContractRegistry, clientsCore.hookResponseRegistry, clientsCore.sessionTokens);
48
48
  }
49
49
  };
50
50
 
@@ -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
- * @see https://github.com/openai/codex
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";
@@ -43,6 +43,17 @@ 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
+ * Request-mode hooks carry `--debounce-failure`, so a down server is detected
50
+ * quickly and cool-down suppression kicks in for subsequent invocations.
51
+ * Context-only hooks still fail fast (1 s) to bound the overhead on each prompt
52
+ * or subagent spawn when the bus is genuinely unreachable.
53
+ * Blockable interactions retain {@link DEFAULT_HOOK_HANDLE_TIMEOUT_MS} because
54
+ * those must complete before the native client can proceed.
55
+ */
56
+ export declare const CONTEXT_ONLY_HOOK_HANDLE_TIMEOUT_MS = 1000;
46
57
  /**
47
58
  * Build the wiring entry list, annotated with installation status, by
48
59
  * comparing the expected entries against the currently installed Codex hooks.
package/dist/server.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as codexPackage } from "./src-BMTPLcPK.mjs";
1
+ import { t as codexPackage } from "./src-D25LSa6Y.mjs";
2
2
  import { codexClientRuntimePackage } from "./runtime/package.mjs";
3
3
 
4
4
  //#region src/server.ts
@@ -1,4 +1,4 @@
1
- import { U as clientDefinition } from "./codex-client-session-service-epcEX-w5.mjs";
1
+ import { U as clientDefinition } from "./codex-client-session-service-BrCcbB06.mjs";
2
2
 
3
3
  //#region src/package.ts
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makaio/client-codex",
3
- "version": "1.0.0-dev-1789404058608",
3
+ "version": "1.0.0-dev-1789642522820",
4
4
  "type": "module",
5
5
  "main": "dist/index.mjs",
6
6
  "exports": {