@makaio/client-codex 1.0.0-dev-1789609124644 → 1.0.0-dev-1790087128488

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.
@@ -1,6 +1,6 @@
1
1
  import { codexCapabilityMap, createClientDefinition } from "@makaio/framework/contracts";
2
2
  import { z } from "zod";
3
- import { AbsolutePathSchema, BinaryNotFoundError, ClientSubjects, ClientWiringApplyResponseSchema, ClientWiringListResponseSchema, ClientWiringRemoveResponseSchema, DEFAULT_HOOK_HANDLE_TIMEOUT_MS, NOOP_HOOK_HANDLE_RESPONSE, assertAbsoluteProjectDir, atomicModifyFile, buildClientCommand, buildHookCommand, collectContributions, createClientNamespace, deriveSessionEventDescriptors, pickNonEmptyString } from "@makaio/framework/clients";
3
+ import { AbsolutePathSchema, BinaryNotFoundError, ClientSubjects, ClientWiringApplyResponseSchema, ClientWiringListResponseSchema, ClientWiringRemoveResponseSchema, DEFAULT_HOOK_HANDLE_TIMEOUT_MS, NOOP_HOOK_HANDLE_RESPONSE, assertAbsoluteProjectDir, atomicModifyFile, buildClientCommand, buildHookCommand, collectContributions, createClientNamespace, deriveSessionEventDescriptors, pickNonEmptyString, pickNonEmptyStringValue } from "@makaio/framework/clients";
4
4
  import { MakaioBus, RequestError } from "@makaio/framework/bus";
5
5
  import { BaseService } from "@makaio/framework/service-base";
6
6
  import * as fs$1 from "node:fs/promises";
@@ -10,7 +10,7 @@ import path from "node:path";
10
10
  import * as os$1 from "node:os";
11
11
  import os from "node:os";
12
12
  import { createHash, randomUUID } from "node:crypto";
13
- import { CLIENT_SESSION_COMPACTION_TRIGGERS, ClientConfigPrimeSchema, SessionConfigSetupRequestSchema, SessionConfigSetupResponseSchema, SessionConfigTeardownRequestSchema, SessionConfigTeardownResponseSchema } from "@makaio/framework/contracts/client";
13
+ import { CANONICAL_HOOK_RESPONSE_CAPABILITIES, CLIENT_SESSION_COMPACTION_TRIGGERS, ClientConfigPrimeSchema, SessionConfigSetupRequestSchema, SessionConfigSetupResponseSchema, SessionConfigTeardownRequestSchema, SessionConfigTeardownResponseSchema } from "@makaio/framework/contracts/client";
14
14
  import { isDeepStrictEqual } from "node:util";
15
15
  import { parse } from "smol-toml";
16
16
  import { lock } from "proper-lockfile";
@@ -1490,6 +1490,7 @@ function normalizeCodexHook(raw, machineId) {
1490
1490
 
1491
1491
  //#endregion
1492
1492
  //#region src/runtime/hook-response-contracts.ts
1493
+ /** Codex 0.144.1 synchronous hook-response contract. @packageDocumentation */
1493
1494
  const CODEX_CLIENT_ID = "codex";
1494
1495
  const CODEX_CONTRACT_ID = "openai.codex-hook-response";
1495
1496
  /**
@@ -1505,8 +1506,15 @@ const CODEX_CONTRACT_ID = "openai.codex-hook-response";
1505
1506
  * Subagent creation cannot be refused (`continue: false` is parsed for
1506
1507
  * compatibility but does not stop the subagent), so the interaction is
1507
1508
  * non-blockable. Purely additive: every `1.1.0` contributor remains valid.
1509
+ *
1510
+ * `1.3.0` adds the canonical `session.token` interaction to the catalog. The
1511
+ * definition does not declare it on any Codex event yet (Codex hands its MCP
1512
+ * subprocesses no session id). When declared, the composer collects the token
1513
+ * and hands it to the in-process token sink of the client runtime; it is never
1514
+ * rendered to the client binary's stdout. Purely additive: every `1.2.0`
1515
+ * contributor remains valid.
1508
1516
  */
1509
- const CODEX_CONTRACT_VERSION = "1.2.0";
1517
+ const CODEX_CONTRACT_VERSION = "1.3.0";
1510
1518
  /**
1511
1519
  * Build a frozen Codex provider envelope.
1512
1520
  * @param effects - Provider-native effect record.
@@ -1630,6 +1638,7 @@ function createCodexStopBlockEffect(reason) {
1630
1638
  }
1631
1639
  const CODEX_RESPONSE_CAPABILITIES = Object.freeze([
1632
1640
  "context.append",
1641
+ CANONICAL_HOOK_RESPONSE_CAPABILITIES.sessionToken,
1633
1642
  CODEX_HOOK_RESPONSE_CAPABILITIES.block,
1634
1643
  CODEX_HOOK_RESPONSE_CAPABILITIES.permissionDeny,
1635
1644
  CODEX_HOOK_RESPONSE_CAPABILITIES.inputUpdate
@@ -1742,6 +1751,22 @@ const codexProviderContractCatalog = Object.freeze({
1742
1751
  function capabilities(eventName) {
1743
1752
  return clientDefinition.runtimeCapabilities.hookEvents.find((event) => event.name === eventName)?.responseCapabilities ?? [];
1744
1753
  }
1754
+ /**
1755
+ * Extract the winning `session.token` value from the ordered effects array.
1756
+ *
1757
+ * Effects arrive in priority-descending order (highest-priority contributor
1758
+ * first), so the first matching `session.token` effect is the winner. When the
1759
+ * event does not declare the `session.token` capability the effect is dropped
1760
+ * and `undefined` is returned — this ensures the token is only collected when
1761
+ * the contributor explicitly targeted an event that supports it.
1762
+ * @param eventName - Native Codex hook event name.
1763
+ * @param effects - Deterministically ordered effects (priority-desc).
1764
+ * @returns The winning token value, or `undefined` when absent or not supported.
1765
+ */
1766
+ function extractSessionToken(eventName, effects) {
1767
+ if (!capabilities(eventName).includes(CANONICAL_HOOK_RESPONSE_CAPABILITIES.sessionToken)) return void 0;
1768
+ for (const effect of effects) if ("kind" in effect && effect.kind === "session.token") return effect.value;
1769
+ }
1745
1770
  const FIRST_BLOCK_EVENTS = new Set([
1746
1771
  CODEX_HOOK_SESSION_START,
1747
1772
  CODEX_HOOK_USER_PROMPT_SUBMIT,
@@ -1869,10 +1894,44 @@ function renderCodexNativeResponse(eventName, effects) {
1869
1894
  return serialize({ hookSpecificOutput });
1870
1895
  }
1871
1896
  /**
1897
+ * Derive the session-token storage scope for a Codex hook event.
1898
+ *
1899
+ * `SubagentStart` requires a non-empty `agent_id` in the payload. The hook
1900
+ * normalizers that feed this composer reject subagent events without an id,
1901
+ * so a missing id signals a malformed event. Forwarding without an `agentId`
1902
+ * would store the token under the parent session key and overwrite it; the
1903
+ * sink is skipped instead (returns `undefined`).
1904
+ *
1905
+ * `SessionStart` and every other event are always session-scoped. Even when
1906
+ * a stray `agent_id` appears in the payload it is never adopted — doing so
1907
+ * would create a spurious subagent-scoped entry.
1908
+ * @param eventName - Codex hook event name.
1909
+ * @param rawPayload - The inner `payload` object from the hook envelope.
1910
+ * @returns Scope to forward to the token sink, or `undefined` to skip it.
1911
+ */
1912
+ function resolveSessionTokenScope(eventName, rawPayload) {
1913
+ const adapterSessionId = pickNonEmptyString(rawPayload, "session_id") ?? pickNonEmptyString(rawPayload, "thread_id");
1914
+ if (adapterSessionId === void 0) return void 0;
1915
+ if (eventName === "SubagentStart") {
1916
+ const agentId = pickNonEmptyString(rawPayload, "agent_id");
1917
+ if (agentId === void 0) return void 0;
1918
+ return {
1919
+ clientId: "codex",
1920
+ adapterSessionId,
1921
+ agentId
1922
+ };
1923
+ }
1924
+ return {
1925
+ clientId: "codex",
1926
+ adapterSessionId
1927
+ };
1928
+ }
1929
+ /**
1872
1930
  * Compose one terminal Codex native hook response.
1873
1931
  * @param registry - Active response contributor registry.
1874
1932
  * @param payload - Normalized native hook payload.
1875
- * @param options - Request deadline, cancellation, and diagnostics hooks.
1933
+ * @param options - Request deadline, cancellation, diagnostics hooks, and
1934
+ * optional session-token sink.
1876
1935
  * @returns The composed native response envelope.
1877
1936
  */
1878
1937
  async function composeCodexHookResponse(registry, payload, options) {
@@ -1888,7 +1947,13 @@ async function composeCodexHookResponse(registry, payload, options) {
1888
1947
  reason: result.closedFailure.detail
1889
1948
  }
1890
1949
  }]);
1891
- return renderCodexNativeResponse(payload.eventName, result.outcomes.flatMap((outcome) => outcome.effects ?? []));
1950
+ const effects = result.outcomes.flatMap((outcome) => outcome.effects ?? []);
1951
+ const token = extractSessionToken(payload.eventName, effects);
1952
+ if (token !== void 0 && options?.onSessionToken !== void 0) {
1953
+ const scope = resolveSessionTokenScope(payload.eventName, payload.payload);
1954
+ if (scope !== void 0) await options.onSessionToken(token, scope);
1955
+ }
1956
+ return renderCodexNativeResponse(payload.eventName, effects);
1892
1957
  }
1893
1958
 
1894
1959
  //#endregion
@@ -2987,8 +3052,10 @@ const CODEX_HOOK_HANDLE_COMMAND_SENTINEL = "hook handle codex";
2987
3052
  /**
2988
3053
  * Timeout for request-mode hooks on context-only (non-blockable) interactions.
2989
3054
  *
2990
- * `hook handle` has no `--debounce-failure`, so a down server would stall every
2991
- * prompt and subagent spawn for the full timeout; context-only hooks fail fast.
3055
+ * Request-mode hooks carry `--debounce-failure`, so a down server is detected
3056
+ * quickly and cool-down suppression kicks in for subsequent invocations.
3057
+ * Context-only hooks still fail fast (1 s) to bound the overhead on each prompt
3058
+ * or subagent spawn when the bus is genuinely unreachable.
2992
3059
  * Blockable interactions retain {@link DEFAULT_HOOK_HANDLE_TIMEOUT_MS} because
2993
3060
  * those must complete before the native client can proceed.
2994
3061
  */
@@ -3118,6 +3185,7 @@ function buildModeCommand(makaioCommand, eventName, mode) {
3118
3185
  const timeoutMs = CODEX_INTERACTION_BLOCKABILITY.some((entry) => entry.interaction === eventName && entry.blockable) ? DEFAULT_HOOK_HANDLE_TIMEOUT_MS : CONTEXT_ONLY_HOOK_HANDLE_TIMEOUT_MS;
3119
3186
  return buildClientCommand(makaioCommand, [
3120
3187
  "--no-launch",
3188
+ "--debounce-failure",
3121
3189
  ...CODEX_HOOK_HANDLE_COMMAND_SENTINEL.split(" "),
3122
3190
  eventName,
3123
3191
  "--timeout",
@@ -3226,6 +3294,15 @@ var CodexClientSessionService = class extends BaseService {
3226
3294
  providerContractRegistry;
3227
3295
  hookResponseRegistry;
3228
3296
  /**
3297
+ * In-process sink for session correlation tokens.
3298
+ *
3299
+ * When non-undefined, the {@link onSessionToken} callback hands the token
3300
+ * directly to this sink so no bus payload (and no `MAKAIO_DEBUG` bus logger)
3301
+ * ever sees the token value. Codex declares no session-token capability, so
3302
+ * this will typically remain `undefined`.
3303
+ */
3304
+ sessionTokens;
3305
+ /**
3229
3306
  * Creates a new Codex client session service.
3230
3307
  * @param bus - Bus instance used for subscribing and emitting events
3231
3308
  * @param settings - Optional {@link CodexClientSettings} instance for tests
@@ -3239,14 +3316,20 @@ var CodexClientSessionService = class extends BaseService {
3239
3316
  * from clients-core for registering the Codex hook response contract.
3240
3317
  * Omit in tests that do not exercise the response pipeline.
3241
3318
  * @param hookResponseRegistry - Optional contributor registry used by the terminal composer.
3319
+ * @param sessionTokens - In-process token sink from clients-core. When
3320
+ * supplied, the {@link onSessionToken} callback hands the token directly
3321
+ * to the sink — no bus payload (and no `MAKAIO_DEBUG` bus logger) ever
3322
+ * sees the token value. Codex declares no session-token capability, so
3323
+ * this will typically be `undefined`.
3242
3324
  */
3243
- constructor(bus = MakaioBus, settings, machineId, sessionConfigHandler = new CodexSessionConfigHandler(), providerContractRegistry, hookResponseRegistry) {
3325
+ constructor(bus = MakaioBus, settings, machineId, sessionConfigHandler = new CodexSessionConfigHandler(), providerContractRegistry, hookResponseRegistry, sessionTokens) {
3244
3326
  super(bus);
3245
3327
  this.settingsOverride = settings;
3246
3328
  this.machineId = machineId;
3247
3329
  this.sessionConfigHandler = sessionConfigHandler;
3248
3330
  this.providerContractRegistry = providerContractRegistry;
3249
3331
  this.hookResponseRegistry = hookResponseRegistry;
3332
+ this.sessionTokens = sessionTokens;
3250
3333
  }
3251
3334
  /**
3252
3335
  * Register the raw hook ingress handler, the `hook.handle` request handler,
@@ -3343,7 +3426,10 @@ var CodexClientSessionService = class extends BaseService {
3343
3426
  return composeCodexHookResponse(this.hookResponseRegistry, ctx.payload, {
3344
3427
  deadline: ctx.deadline,
3345
3428
  signal: ctx.signal,
3346
- onDiagnostics: (diagnostics) => diagnostics.forEach((diagnostic) => console.warn(`[CodexClientSessionService] Hook contributor '${diagnostic.contributorId}': ${diagnostic.message}`))
3429
+ onDiagnostics: (diagnostics) => diagnostics.forEach((diagnostic) => console.warn(`[CodexClientSessionService] Hook contributor '${diagnostic.contributorId}': ${diagnostic.message}`)),
3430
+ onSessionToken: (token, scope) => {
3431
+ this.sessionTokens?.record(scope, token);
3432
+ }
3347
3433
  }).then((response) => ctx.setResult(response));
3348
3434
  });
3349
3435
  }
@@ -3433,6 +3519,7 @@ var CodexClientSessionService = class extends BaseService {
3433
3519
  */
3434
3520
  async handleHookReceived(raw) {
3435
3521
  const events = normalizeCodexHook(raw, this.machineId);
3522
+ await this.observeRootRuntime(raw, events);
3436
3523
  if (events.length === 0 && (raw.eventName === "SubagentStart" || raw.eventName === "SubagentStop")) console.warn(`[CodexClientSessionService] ${raw.eventName} hook produced no normalized events — agent_id is likely absent. The hook remains raw-only on client:codex.*.`);
3437
3524
  const sharedAdapterSessionId = events[0]?.payload.adapterSessionId;
3438
3525
  const isManagedSession = this.isAdapterManagedSession(sharedAdapterSessionId);
@@ -3484,6 +3571,38 @@ var CodexClientSessionService = class extends BaseService {
3484
3571
  if (firstError !== void 0) throw firstError;
3485
3572
  }
3486
3573
  /**
3574
+ * Enrich a supervisor-owned Codex runtime with the native session ID observed
3575
+ * on its root `SessionStart` hook.
3576
+ *
3577
+ * Subagent hooks never produce `client.session.started`, so they cannot bind
3578
+ * a root runtime. The supervisor correlation key joins observations; it does
3579
+ * not grant ownership of an arbitrary native session.
3580
+ * @param raw - Raw hook payload delivered on `client:codex.hook.received`.
3581
+ * @param events - Normalized events derived from the raw hook.
3582
+ */
3583
+ async observeRootRuntime(raw, events) {
3584
+ if (raw.eventName !== "SessionStart") return;
3585
+ const supervisorSessionId = pickNonEmptyStringValue(raw.metadata?.supervisorSessionId);
3586
+ const rootStart = events.find((event) => event.subject === ClientSubjects.session.started);
3587
+ const adapterSessionId = rootStart?.payload.adapterSessionId;
3588
+ if (supervisorSessionId === void 0 || rootStart === void 0 || adapterSessionId === void 0) return;
3589
+ try {
3590
+ if (!(await this.bus.requestOptional(ClientSubjects.runtime.observe, {
3591
+ clientId: CLIENT_ID,
3592
+ source: {
3593
+ layer: "client-hook",
3594
+ producer: "codex-client-session-service"
3595
+ },
3596
+ observedAt: raw.receivedAt,
3597
+ supervisorSessionId,
3598
+ adapterSessionId,
3599
+ ...rootStart.payload.startMode === "clear" && { adapterSessionTransition: "root-clear" }
3600
+ })).handled) console.warn("[CodexClientSessionService] Runtime identity join is unavailable.");
3601
+ } catch {
3602
+ console.warn("[CodexClientSessionService] Runtime identity join is unavailable.");
3603
+ }
3604
+ }
3605
+ /**
3487
3606
  * Determine whether a normalized native hook belongs to an adapter-managed
3488
3607
  * session whose global observed-semantics events are already emitted by the
3489
3608
  * adapter layer.
@@ -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-CsIoRrhH.mjs";
2
- import { t as codexPackage } from "./src-osBCBvw6.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-uk6l5Kri.mjs";
2
+ import { t as codexPackage } from "./src-CoiDO0ce.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,
@@ -185,6 +199,7 @@ export declare class CodexClientSessionService extends BaseService {
185
199
  */
186
200
  private handleRuntimeStarted;
187
201
  private handleHookReceived;
202
+ private observeRootRuntime;
188
203
  /**
189
204
  * Determine whether a normalized native hook belongs to an adapter-managed
190
205
  * session whose global observed-semantics events are already emitted by the
@@ -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,4 +1,3 @@
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";
@@ -15,8 +14,15 @@ export declare const CODEX_CONTRACT_ID = "openai.codex-hook-response";
15
14
  * Subagent creation cannot be refused (`continue: false` is parsed for
16
15
  * compatibility but does not stop the subagent), so the interaction is
17
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.
18
24
  */
19
- export declare const CODEX_CONTRACT_VERSION = "1.2.0";
25
+ export declare const CODEX_CONTRACT_VERSION = "1.3.0";
20
26
  export type CodexBlockEffects = Readonly<{
21
27
  decision: 'block';
22
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-CsIoRrhH.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-uk6l5Kri.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
 
@@ -46,8 +46,10 @@ export declare const CODEX_HOOK_HANDLE_COMMAND_SENTINEL = "hook handle codex";
46
46
  /**
47
47
  * Timeout for request-mode hooks on context-only (non-blockable) interactions.
48
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.
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.
51
53
  * Blockable interactions retain {@link DEFAULT_HOOK_HANDLE_TIMEOUT_MS} because
52
54
  * those must complete before the native client can proceed.
53
55
  */
package/dist/server.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as codexPackage } from "./src-osBCBvw6.mjs";
1
+ import { t as codexPackage } from "./src-CoiDO0ce.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-CsIoRrhH.mjs";
1
+ import { U as clientDefinition } from "./codex-client-session-service-uk6l5Kri.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-1789609124644",
3
+ "version": "1.0.0-dev-1790087128488",
4
4
  "type": "module",
5
5
  "main": "dist/index.mjs",
6
6
  "exports": {