@skillstate/codex 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,125 @@
1
+ import type { StatePathRef } from '@skillstate/core';
2
+ import type { ProceduralSpec } from '@skillstate/core';
3
+ /** Codex lifecycle hook events this adapter can generate scripted hooks for. */
4
+ export type CodexHookEvent = 'UserPromptSubmit' | 'PostToolUse' | 'SessionStart';
5
+ /**
6
+ * Canonical `.cjs` filename suffix per Codex hook event, used by
7
+ * {@link CodexAdapter.codexHookScriptPath} so `hooks.json` commands and the
8
+ * on-disk hook scripts always agree.
9
+ */
10
+ export declare const CODEX_HOOK_SCRIPT_SUFFIX: {
11
+ readonly UserPromptSubmit: 'user-prompt-submit';
12
+ readonly PostToolUse: 'post-tool-use';
13
+ readonly SessionStart: 'session-start-compact';
14
+ };
15
+ /** Executable hook-script suffix for a {@link CodexHookEvent}. */
16
+ export type CodexHookEventSuffix = (typeof CODEX_HOOK_SCRIPT_SUFFIX)[CodexHookEvent];
17
+ /** Options for {@link CodexAdapter.generateCodexAmendments}. */
18
+ export interface CodexAmendmentsOptions {
19
+ /** Fill a `## State schema` section from the provided spec. */
20
+ spec?: ProceduralSpec;
21
+ /** Append the hook setup note (default true). */
22
+ includeHooksNote?: boolean;
23
+ }
24
+ /** Options for {@link CodexAdapter.generateCodexHooksConfig}. */
25
+ export interface CodexHooksConfigOptions {
26
+ /** Command that runs the per-event hook scripts. Overrides the default. */
27
+ command?: string;
28
+ /** `matcher` for the `SessionStart` hook (default `compact`). */
29
+ sessionStartMatcher?: string;
30
+ }
31
+ /**
32
+ * OpenAI Codex platform adapter (@non-paper; see module doc).
33
+ *
34
+ * Codegen mirrors the Claude adapter's shape: every generator accepts a
35
+ * raw path (legacy) or a `{ root, name }` ref confined by
36
+ * `resolveStatePath` — `..` escapes throw instead of embedding an unsafe
37
+ * path into the generated artifact.
38
+ */
39
+ export declare class CodexAdapter {
40
+ readonly name = "codex";
41
+ /**
42
+ * Generate an `AGENTS.md`-compatible amendment that puts the agent in
43
+ * state-based execution mode: read `.skillstate.json` each step, treat
44
+ * reasoning as discarded, and emit a `state_patch` that the hooks merge
45
+ * back into the state file.
46
+ */
47
+ generateCodexAmendments(statePath: string | StatePathRef, options?: CodexAmendmentsOptions): string;
48
+ /**
49
+ * Generate a markdown "read the state file" instruction block — the
50
+ * standalone form of the state-read contract (the core line the model
51
+ * must follow), suitable for embedding in an AGENTS.md, a skill body, or
52
+ * a system prompt.
53
+ */
54
+ generateCodexStateRead(statePath: string | StatePathRef): string;
55
+ /**
56
+ * Generate a self-contained Node CommonJS hook script for a Codex
57
+ * lifecycle event. The script is invoked by the hook's `command`; the
58
+ * event config (matcher) lives in the hooks.json document.
59
+ *
60
+ * - `UserPromptSubmit`: read the state file and inject it as
61
+ * `additionalContext` (runs on every prompt submit).
62
+ * - `SessionStart`: same injection shape; combined with a `compact`
63
+ * matcher it re-injects state after Codex compacts the chat.
64
+ * - `PostToolUse`: read `tool_response` from stdin, extract
65
+ * `state_patch`, schema-validate (when a schema is provided) and merge
66
+ * it into the state file via the paper ⊕ operator. Malformed outputs
67
+ * are rejected and never persisted.
68
+ */
69
+ generateCodexHookScript(eventType: CodexHookEvent, statePath: string, schema?: ProceduralSpec['schema']): string;
70
+ generateCodexHookScript(eventType: CodexHookEvent, stateRef: StatePathRef, schema?: ProceduralSpec['schema']): string;
71
+ /**
72
+ * Generate a Codex `hooks.json` document that wires the state-injection /
73
+ * persistence hooks into the agent lifecycle:
74
+ *
75
+ * - `UserPromptSubmit` → inject current state (every prompt).
76
+ * - `SessionStart` (matcher `compact`) → re-inject state after compaction.
77
+ * - `PostToolUse` → extract `state_patch` and persist it.
78
+ */
79
+ generateCodexHooksConfig(statePath: string | StatePathRef, options?: CodexHooksConfigOptions): string;
80
+ /**
81
+ * Canonical absolute path of the generated hook script for a Codex event,
82
+ * derived from the state file name. Both {@link generateCodexHooksConfig}
83
+ * and {@link saveCodexHookScript} use this single convention so the
84
+ * `hooks.json` commands and the on-disk scripts always agree.
85
+ *
86
+ * For `./.skillstate.json`:
87
+ * - `UserPromptSubmit` → `.../.codex-.skillstate-user-prompt-submit.cjs`
88
+ * - `SessionStart` → `.../.codex-.skillstate-session-start-compact.cjs`
89
+ * - `PostToolUse` → `.../.codex-.skillstate-post-tool-use.cjs`
90
+ *
91
+ * Accepts a raw state path or a `{ root, name }` ref resolved via
92
+ * `resolveStatePath`.
93
+ */
94
+ codexHookScriptPath(statePath: string | StatePathRef, eventType: CodexHookEvent): string;
95
+ /**
96
+ * @non-paper additive helper: generate the AGENTS.md amendment and persist
97
+ * it via `atomicWriteFile` (tmp + fsync + rename). Both the destination and
98
+ * the embedded state path accept raw strings (legacy behavior) or
99
+ * `{ root, name }` refs confined by `resolveStatePath`. Returns the
100
+ * absolute destination path.
101
+ */
102
+ saveCodexAmendments(target: string | StatePathRef, statePath: string | StatePathRef, options?: CodexAmendmentsOptions): Promise<string>;
103
+ /**
104
+ * @non-paper additive helper: generate the hooks.json document and persist
105
+ * it via `atomicWriteFile`. Both the destination and the embedded state
106
+ * path accept raw strings or `{ root, name }` refs. Returns the absolute
107
+ * destination path.
108
+ */
109
+ saveCodexHooksConfig(target: string | StatePathRef, statePath: string | StatePathRef, options?: CodexHooksConfigOptions): Promise<string>;
110
+ /**
111
+ * @non-paper additive helper: generate a single hook script and persist it
112
+ * via `atomicWriteFile`. Accepts raw strings or `{ root, name }` refs for
113
+ * both the destination and the embedded state path. Returns the absolute
114
+ * destination path.
115
+ */
116
+ saveCodexHookScript(eventType: CodexHookEvent, statePath: string | StatePathRef, schema?: ProceduralSpec['schema']): Promise<string>;
117
+ saveCodexHookScript(target: string | StatePathRef, eventType: CodexHookEvent, statePath: string | StatePathRef, schema?: ProceduralSpec['schema']): Promise<string>;
118
+ /** Resolve a `string | StatePathRef` via `resolveStatePath` (throws on `..`). */
119
+ private resolve;
120
+ /** Shared injection body for injection-only hooks (read + emit context). */
121
+ private buildInjection;
122
+ /** PostToolUse body: extract, validate (if schema given), merge, persist. */
123
+ private buildPostToolUse;
124
+ }
125
+ //# sourceMappingURL=codex-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-adapter.d.ts","sourceRoot":"","sources":["../src/codex-adapter.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,gFAAgF;AAChF,MAAM,MAAM,cAAc,GACtB,kBAAkB,GAClB,aAAa,GACb,cAAc,CAAC;AAEnB;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;aACnC,gBAAgB,EAAE,oBAAoB;aACtC,WAAW,EAAE,eAAe;aAC5B,YAAY,EAAE,uBAAuB;CAC7B,CAAC;AAEX,kEAAkE;AAClE,MAAM,MAAM,oBAAoB,GAC9B,CAAC,OAAO,wBAAwB,CAAC,CAAC,cAAc,CAAC,CAAC;AAEpD,gEAAgE;AAChE,MAAM,WAAW,sBAAsB;IACrC,+DAA+D;IAC/D,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,iEAAiE;AACjE,MAAM,WAAW,uBAAuB;IACtC,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,qBAAa,YAAY;IACvB,QAAQ,CAAC,IAAI,WAAW;IAExB;;;;;OAKG;IACH,uBAAuB,CACrB,SAAS,EAAE,MAAM,GAAG,YAAY,EAChC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM,CAkDR;IAED;;;;;OAKG;IACH,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,GAAG,MAAM,CAa/D;IAED;;;;;;;;;;;;;OAaG;IAC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F,OAAO,CAAC,OAAO;IAMf,4EAA4E;IAC5E,OAAO,CAAC,cAAc;IAmBtB,6EAA6E;IAC7E,OAAO,CAAC,gBAAgB;CAgJzB"}
@@ -0,0 +1,433 @@
1
+ /**
2
+ * @non-paper adapter — no adapters exist in arXiv 2608.26263v3.
3
+ *
4
+ * This file bridges the paper-exact core (Algorithm 1 prompt, ⊕ merge,
5
+ * §7 rollback-retry rejection) into OpenAI Codex CLI sessions.
6
+ *
7
+ * RESEARCH (github.com/openai/codex, docs "Hooks" / "AGENTS.md"): Codex
8
+ * exposes a real hook system configured as `hooks.json` (or inline
9
+ * `[hooks]` tables) under `~/.codex/` and `<repo>/.codex/`, plus the
10
+ * `AGENTS.md` project-instructions file that Codex loads into the agent's
11
+ * context. Hooks relevant to skillstate:
12
+ *
13
+ * - `UserPromptSubmit` → `hookSpecificOutput.additionalContext` is added
14
+ * as extra developer context on every prompt submit (state injection).
15
+ * - `PostToolUse` → receives `tool_response` on stdin (JSON); a
16
+ * command hook can read it, extract `state_patch`, and write the state
17
+ * file (state persistence).
18
+ * - `SessionStart` → `matcher: "compact"` fires after compaction and
19
+ * can emit `additionalContext` (post-compaction re-injection).
20
+ * - `PreCompact` → Codex only honours the shared output fields
21
+ * (`continue`/`stopReason`/`systemMessage`) — it does NOT take
22
+ * `additionalContext` for this event, so compaction injection is done
23
+ * via `SessionStart(compact)` instead.
24
+ *
25
+ * LIMITATION: there is no `messages.transform` equivalent (unlike
26
+ * OpenCode). Codex hooks are additive — host history is never trimmed, so
27
+ * true O(1) is not possible. The best strategy is: `AGENTS.md` instructs
28
+ * the model to read `.skillstate.json` each step and patch it, while the
29
+ * hooks keep state injected/persisted around prompt submission and
30
+ * compaction. No host history is dropped, hence @non-paper best-effort.
31
+ */
32
+ import * as path from 'node:path';
33
+ import { atomicWriteFile, resolveStatePath, } from '@skillstate/core';
34
+ /**
35
+ * Canonical `.cjs` filename suffix per Codex hook event, used by
36
+ * {@link CodexAdapter.codexHookScriptPath} so `hooks.json` commands and the
37
+ * on-disk hook scripts always agree.
38
+ */
39
+ export const CODEX_HOOK_SCRIPT_SUFFIX = {
40
+ UserPromptSubmit: 'user-prompt-submit',
41
+ PostToolUse: 'post-tool-use',
42
+ SessionStart: 'session-start-compact',
43
+ };
44
+ /**
45
+ * OpenAI Codex platform adapter (@non-paper; see module doc).
46
+ *
47
+ * Codegen mirrors the Claude adapter's shape: every generator accepts a
48
+ * raw path (legacy) or a `{ root, name }` ref confined by
49
+ * `resolveStatePath` — `..` escapes throw instead of embedding an unsafe
50
+ * path into the generated artifact.
51
+ */
52
+ export class CodexAdapter {
53
+ name = 'codex';
54
+ /**
55
+ * Generate an `AGENTS.md`-compatible amendment that puts the agent in
56
+ * state-based execution mode: read `.skillstate.json` each step, treat
57
+ * reasoning as discarded, and emit a `state_patch` that the hooks merge
58
+ * back into the state file.
59
+ */
60
+ generateCodexAmendments(statePath, options) {
61
+ const resolved = this.resolve(statePath);
62
+ const spec = options?.spec;
63
+ const sections = [
64
+ `## State-based execution (skillstate)`,
65
+ ``,
66
+ `You are running in state-based execution mode. Your execution state is`,
67
+ `persisted in the JSON file at \\\`${resolved}\\\`.`,
68
+ ``,
69
+ `Read \\\`${resolved}\\\` at the start of EVERY step and trust it over`,
70
+ `this conversation; reasoning and history are discarded between steps.`,
71
+ ``,
72
+ `After each step, respond with a JSON block containing exactly two keys:`,
73
+ `\`state_patch\` and \`action\`.`,
74
+ ``,
75
+ '```json',
76
+ `{`,
77
+ ` "state_patch": { "field_to_update": "new_value", "obsolete_field": null },`,
78
+ ` "action": "next_action_name"`,
79
+ `}`,
80
+ '```',
81
+ ``,
82
+ `- In \`state_patch\`, set keys to \`null\` to delete them. Only include`,
83
+ ` fields you want to change. Omit fields to leave them unchanged.`,
84
+ `- Put anything you need to persist into \`state_patch\`; never rely on`,
85
+ ` the model remembering it from history.`,
86
+ `- \`action\` names what you will do next.`,
87
+ ];
88
+ if (spec) {
89
+ sections.push('', '## Skill state schema', '');
90
+ for (const [name, field] of Object.entries(spec.schema)) {
91
+ sections.push(`- \`${name}\` (${field.type}): ${field.description ?? 'no description'}`);
92
+ }
93
+ }
94
+ if (options?.includeHooksNote !== false) {
95
+ sections.push('', 'A Codex hooks config (`.codex/hooks.json`) keeps this state injected on', '`UserPromptSubmit` and re-injected after compaction, and persists your', '`state_patch` on `PostToolUse`. Generate one with', '`CodexAdapter.generateCodexHooksConfig`.');
96
+ }
97
+ return sections.join('\n') + '\n';
98
+ }
99
+ /**
100
+ * Generate a markdown "read the state file" instruction block — the
101
+ * standalone form of the state-read contract (the core line the model
102
+ * must follow), suitable for embedding in an AGENTS.md, a skill body, or
103
+ * a system prompt.
104
+ */
105
+ generateCodexStateRead(statePath) {
106
+ const resolved = this.resolve(statePath);
107
+ return [
108
+ `You operate in state-based execution mode.`,
109
+ ``,
110
+ `1. Read \\\`${resolved}\\\` at the start of every step.`,
111
+ `2. Trust it over conversation history — history is discarded between steps.`,
112
+ `3. Reason about the next step, then output a fenced JSON block with`,
113
+ ` exactly two keys: \`state_patch\` (sparse update) and \`action\`.`,
114
+ `4. Set any key in \`state_patch\` to \`null\` to delete it.`,
115
+ ``,
116
+ `Never persist reasoning in the state; keep it only in \`state_patch\`.`,
117
+ ].join('\n');
118
+ }
119
+ generateCodexHookScript(eventType, statePathOrRef, schema) {
120
+ const resolved = this.resolve(statePathOrRef);
121
+ const sp = JSON.stringify(resolved);
122
+ if (eventType === 'PostToolUse') {
123
+ return this.buildPostToolUse(sp, schema ?? {});
124
+ }
125
+ // UserPromptSubmit and SessionStart share the same injection body.
126
+ const context = this.buildInjection(sp);
127
+ return [
128
+ `// Codex hook: ${eventType === 'SessionStart'
129
+ ? 'SessionStart (matcher: compact)'
130
+ : 'UserPromptSubmit'}`,
131
+ `// Injects the current skill state as additionalContext so the model`,
132
+ `// never has to reconstruct execution context from history.`,
133
+ ...context,
134
+ ].join('\n');
135
+ }
136
+ /**
137
+ * Generate a Codex `hooks.json` document that wires the state-injection /
138
+ * persistence hooks into the agent lifecycle:
139
+ *
140
+ * - `UserPromptSubmit` → inject current state (every prompt).
141
+ * - `SessionStart` (matcher `compact`) → re-inject state after compaction.
142
+ * - `PostToolUse` → extract `state_patch` and persist it.
143
+ */
144
+ generateCodexHooksConfig(statePath, options) {
145
+ const resolved = this.resolve(statePath);
146
+ const defaultCommand = (eventType) => `node ${JSON.stringify(this.codexHookScriptPath(resolved, eventType))}`;
147
+ const sessionStartMatcher = options?.sessionStartMatcher ?? 'compact';
148
+ const command = options?.command;
149
+ const doc = {
150
+ description: 'Skillstate lifecycle hooks: inject state per prompt, re-inject after compaction, persist state_patch.',
151
+ hooks: {
152
+ UserPromptSubmit: [
153
+ {
154
+ hooks: [
155
+ {
156
+ type: 'command',
157
+ command: command ?? defaultCommand('UserPromptSubmit'),
158
+ statusMessage: 'Injecting skill state',
159
+ },
160
+ ],
161
+ },
162
+ ],
163
+ SessionStart: [
164
+ {
165
+ matcher: sessionStartMatcher,
166
+ hooks: [
167
+ {
168
+ type: 'command',
169
+ command: command ?? defaultCommand('SessionStart'),
170
+ statusMessage: 'Re-injecting skill state after compaction',
171
+ },
172
+ ],
173
+ },
174
+ ],
175
+ PostToolUse: [
176
+ {
177
+ hooks: [
178
+ {
179
+ type: 'command',
180
+ command: command ?? defaultCommand('PostToolUse'),
181
+ statusMessage: 'Persisting skill state patch',
182
+ },
183
+ ],
184
+ },
185
+ ],
186
+ },
187
+ };
188
+ return JSON.stringify(doc, null, 2) + '\n';
189
+ }
190
+ /**
191
+ * Canonical absolute path of the generated hook script for a Codex event,
192
+ * derived from the state file name. Both {@link generateCodexHooksConfig}
193
+ * and {@link saveCodexHookScript} use this single convention so the
194
+ * `hooks.json` commands and the on-disk scripts always agree.
195
+ *
196
+ * For `./.skillstate.json`:
197
+ * - `UserPromptSubmit` → `.../.codex-.skillstate-user-prompt-submit.cjs`
198
+ * - `SessionStart` → `.../.codex-.skillstate-session-start-compact.cjs`
199
+ * - `PostToolUse` → `.../.codex-.skillstate-post-tool-use.cjs`
200
+ *
201
+ * Accepts a raw state path or a `{ root, name }` ref resolved via
202
+ * `resolveStatePath`.
203
+ */
204
+ codexHookScriptPath(statePath, eventType) {
205
+ const resolved = this.resolve(statePath);
206
+ const dir = path.dirname(resolved);
207
+ const base = path.basename(resolved, '.json');
208
+ return path.join(dir, `.codex-${base}-${CODEX_HOOK_SCRIPT_SUFFIX[eventType]}.cjs`);
209
+ }
210
+ /**
211
+ * @non-paper additive helper: generate the AGENTS.md amendment and persist
212
+ * it via `atomicWriteFile` (tmp + fsync + rename). Both the destination and
213
+ * the embedded state path accept raw strings (legacy behavior) or
214
+ * `{ root, name }` refs confined by `resolveStatePath`. Returns the
215
+ * absolute destination path.
216
+ */
217
+ async saveCodexAmendments(target, statePath, options) {
218
+ const dest = this.resolve(target);
219
+ const resolved = this.resolve(statePath);
220
+ const content = this.generateCodexAmendments(resolved, options);
221
+ await atomicWriteFile(dest, content);
222
+ return dest;
223
+ }
224
+ /**
225
+ * @non-paper additive helper: generate the hooks.json document and persist
226
+ * it via `atomicWriteFile`. Both the destination and the embedded state
227
+ * path accept raw strings or `{ root, name }` refs. Returns the absolute
228
+ * destination path.
229
+ */
230
+ async saveCodexHooksConfig(target, statePath, options) {
231
+ const dest = this.resolve(target);
232
+ const resolved = this.resolve(statePath);
233
+ const content = this.generateCodexHooksConfig(resolved, options);
234
+ await atomicWriteFile(dest, content);
235
+ return dest;
236
+ }
237
+ async saveCodexHookScript(targetOrEvent, eventTypeOrPath, statePathOrSchema, schema) {
238
+ const refForm = typeof targetOrEvent === 'string' &&
239
+ (targetOrEvent === 'UserPromptSubmit' ||
240
+ targetOrEvent === 'PostToolUse' ||
241
+ targetOrEvent === 'SessionStart');
242
+ const target = refForm
243
+ ? this.codexHookScriptPath(eventTypeOrPath, targetOrEvent)
244
+ : targetOrEvent;
245
+ const eventType = refForm
246
+ ? targetOrEvent
247
+ : eventTypeOrPath;
248
+ const statePath = refForm
249
+ ? eventTypeOrPath
250
+ : statePathOrSchema;
251
+ const effectiveSchema = refForm
252
+ ? statePathOrSchema
253
+ : schema;
254
+ const dest = this.resolve(target);
255
+ const resolved = this.resolve(statePath);
256
+ const content = this.generateCodexHookScript(eventType, resolved, effectiveSchema);
257
+ await atomicWriteFile(dest, content);
258
+ return dest;
259
+ }
260
+ /* ------------------------------------------------------------------ */
261
+ /* Internal helpers */
262
+ /* ------------------------------------------------------------------ */
263
+ /** Resolve a `string | StatePathRef` via `resolveStatePath` (throws on `..`). */
264
+ resolve(target) {
265
+ return typeof target === 'string'
266
+ ? target
267
+ : resolveStatePath(target.root, target.name);
268
+ }
269
+ /** Shared injection body for injection-only hooks (read + emit context). */
270
+ buildInjection(sp) {
271
+ return [
272
+ 'const fs = require("fs");',
273
+ `const stateFilePath = ${sp};`,
274
+ 'let state = {};',
275
+ 'try {',
276
+ ' if (fs.existsSync(stateFilePath)) {',
277
+ ' state = JSON.parse(fs.readFileSync(stateFilePath, "utf-8"));',
278
+ ' }',
279
+ '} catch (e) { state = {}; }',
280
+ 'const output = {',
281
+ ' hookSpecificOutput: {',
282
+ ' additionalContext: "Current skill state (JSON): " + JSON.stringify(state)',
283
+ ' }',
284
+ '};',
285
+ 'process.stdout.write(JSON.stringify(output));',
286
+ ];
287
+ }
288
+ /** PostToolUse body: extract, validate (if schema given), merge, persist. */
289
+ buildPostToolUse(sp, schema) {
290
+ const fence = '`' + '`' + '`';
291
+ const schemaJson = JSON.stringify(schema);
292
+ return [
293
+ '// Codex hook: PostToolUse',
294
+ '// Extracts state_patch from the tool_response, validates it against the',
295
+ '// embedded schema (when provided), applies the null-deletion merge, and',
296
+ '// saves. Malformed output is rejected and never persisted.',
297
+ 'const fs = require("fs");',
298
+ `const stateFilePath = ${sp};`,
299
+ `const schema = ${schemaJson};`,
300
+ '',
301
+ 'function isPlainObject(v) {',
302
+ ' return typeof v === "object" && v !== null && !Array.isArray(v);',
303
+ '}',
304
+ '',
305
+ 'function mergePatch(base, patch) {',
306
+ ' function mergeInto(result, patchObj) {',
307
+ ' for (const key of Object.keys(patchObj)) {',
308
+ ' const value = patchObj[key];',
309
+ ' if (value === null) {',
310
+ ' delete result[key];',
311
+ ' } else if (isPlainObject(value) && isPlainObject(result[key])) {',
312
+ ' result[key] = mergeInto({ ...result[key] }, value);',
313
+ ' } else {',
314
+ ' result[key] = value;',
315
+ ' }',
316
+ ' }',
317
+ ' return result;',
318
+ ' }',
319
+ ' return mergeInto({ ...base }, patch);',
320
+ '}',
321
+ '',
322
+ 'function validatePatchAgainstSchema(patch) {',
323
+ ' for (const key of Object.keys(patch)) {',
324
+ ' const field = schema[key];',
325
+ ' if (!field) {',
326
+ ' return "Unknown key: " + key;',
327
+ ' }',
328
+ ' const value = patch[key];',
329
+ ' if (value === null) continue;',
330
+ ' const expected = field.type;',
331
+ ' let ok = false;',
332
+ ' if (expected === "string") ok = typeof value === "string";',
333
+ ' else if (expected === "number") ok = typeof value === "number";',
334
+ ' else if (expected === "boolean") ok = typeof value === "boolean";',
335
+ ' else if (expected === "array") ok = Array.isArray(value);',
336
+ ' else if (expected === "object") ok = isPlainObject(value);',
337
+ ' if (!ok) {',
338
+ ' return "Invalid type for field \'" + key + "\': expected " + expected +',
339
+ ' ", got " + (Array.isArray(value) ? "array" : typeof value);',
340
+ ' }',
341
+ ' }',
342
+ ' return null;',
343
+ '}',
344
+ '',
345
+ 'function isJsonObjectWithStatePatch(value) {',
346
+ ' return value !== null &&',
347
+ ' typeof value === "object" &&',
348
+ ' !Array.isArray(value) &&',
349
+ ' value.state_patch !== null &&',
350
+ ' typeof value.state_patch === "object" &&',
351
+ ' !Array.isArray(value.state_patch);',
352
+ '}',
353
+ '',
354
+ 'function tryParseStandaloneJson(text) {',
355
+ ' const trimmed = String(text).trim();',
356
+ ' try {',
357
+ ' const parsed = JSON.parse(trimmed);',
358
+ ' if (isJsonObjectWithStatePatch(parsed)) return parsed;',
359
+ ' } catch (e) {}',
360
+ ' const first = trimmed.indexOf("{");',
361
+ ' const last = trimmed.lastIndexOf("}");',
362
+ ' if (first !== -1 && last > first) {',
363
+ ' try {',
364
+ ' const parsed = JSON.parse(trimmed.slice(first, last + 1));',
365
+ ' if (isJsonObjectWithStatePatch(parsed)) return parsed;',
366
+ ' } catch (e) {}',
367
+ ' }',
368
+ ' return null;',
369
+ '}',
370
+ '',
371
+ 'function extractPatchString(content) {',
372
+ ' if (typeof content !== "string") return null;',
373
+ ' const match = content.match(/' + fence + 'json\\s*\\n?([\\s\\S]*?)\\n?\\s*' + fence + '/);',
374
+ ' if (match) {',
375
+ ' try {',
376
+ ' const parsed = JSON.parse(match[1]);',
377
+ ' if (isJsonObjectWithStatePatch(parsed)) return parsed;',
378
+ ' } catch (e) {}',
379
+ ' }',
380
+ ' return tryParseStandaloneJson(content);',
381
+ '}',
382
+ '',
383
+ 'function readResponseText(response) {',
384
+ ' if (response === null || response === undefined) return "";',
385
+ ' if (typeof response === "string") return response;',
386
+ ' if (isPlainObject(response)) {',
387
+ ' if (typeof response.content === "string") return response.content;',
388
+ ' if (typeof response.text === "string") return response.text;',
389
+ ' return JSON.stringify(response);',
390
+ ' }',
391
+ ' return JSON.stringify(response);',
392
+ '}',
393
+ '',
394
+ 'let state = {};',
395
+ 'try {',
396
+ ' if (fs.existsSync(stateFilePath)) {',
397
+ ' state = JSON.parse(fs.readFileSync(stateFilePath, "utf-8"));',
398
+ ' }',
399
+ '} catch (e) { state = {}; }',
400
+ 'let input = "";',
401
+ 'process.stdin.setEncoding("utf-8");',
402
+ 'process.stdin.on("data", (chunk) => { input += chunk; });',
403
+ 'process.stdin.on("end", () => {',
404
+ ' const output = {};',
405
+ ' try {',
406
+ ' const parsed = JSON.parse(input);',
407
+ ' const response = parsed.tool_response ?? parsed.content ?? "";',
408
+ ' const text = readResponseText(response);',
409
+ ' let json;',
410
+ ' if (isPlainObject(response) && isPlainObject(response.state_patch)) {',
411
+ ' json = response;',
412
+ ' } else {',
413
+ ' json = extractPatchString(text);',
414
+ ' }',
415
+ ' if (json && json.state_patch && typeof json.state_patch === "object" && !Array.isArray(json.state_patch)) {',
416
+ ' const validationError = validatePatchAgainstSchema(json.state_patch);',
417
+ ' if (validationError) {',
418
+ ' output.error = validationError;',
419
+ ' process.stdout.write(JSON.stringify(output));',
420
+ ' return;',
421
+ ' }',
422
+ ' state = mergePatch(state, json.state_patch);',
423
+ ' fs.writeFileSync(stateFilePath, JSON.stringify(state, null, 2));',
424
+ ' }',
425
+ ' } catch (e) {',
426
+ ' output.error = "Failed to process PostToolUse input: " + e.message;',
427
+ ' }',
428
+ ' process.stdout.write(JSON.stringify(output));',
429
+ '});',
430
+ ].join('\n');
431
+ }
432
+ }
433
+ //# sourceMappingURL=codex-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-adapter.js","sourceRoot":"","sources":["../src/codex-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,eAAe,EACf,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAU1B;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,gBAAgB,EAAE,oBAAoB;IACtC,WAAW,EAAE,eAAe;IAC5B,YAAY,EAAE,uBAAuB;CAC7B,CAAC;AAsBX;;;;;;;GAOG;AACH,MAAM,OAAO,YAAY;IACd,IAAI,GAAG,OAAO,CAAC;IAExB;;;;;OAKG;IACH,uBAAuB,CACrB,SAAgC,EAChC,OAAgC;QAEhC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,CAAC;QAE3B,MAAM,QAAQ,GAAa;YACzB,uCAAuC;YACvC,EAAE;YACF,wEAAwE;YACxE,qCAAqC,QAAQ,OAAO;YACpD,EAAE;YACF,YAAY,QAAQ,mDAAmD;YACvE,uEAAuE;YACvE,EAAE;YACF,yEAAy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YACvC,oEAAoE;YACpE,8CAA8C;YAC9C,eAAe;YACf,2EAA2E;YAC3E,wBAAwB;YACxB,cAAc;YACd,wCAAwC;YACxC,OAAO;YACP,iHAAiH;YACjH,6EAA6E;YAC7E,8BAA8B;YAC9B,yCAAyC;YACzC,uDAAuD;YACvD,iBAAiB;YACjB,SAAS;YACT,oDAAoD;YACpD,wEAAwE;YACxE,OAAO;YACP,iBAAiB;YACjB,yEAAyE;YACzE,KAAK;YACL,iDAAiD;YACjD,KAAK;SACN,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export * from './codex-adapter.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,oBAAoB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ // @skillstate/codex — OpenAI Codex platform adapter.
2
+ export * from './codex-adapter.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,cAAc,oBAAoB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@skillstate/codex",
3
+ "version": "2.0.0",
4
+ "description": "OpenAI Codex platform adapter for the skillstate runtime.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": ["dist"],
16
+ "sideEffects": false,
17
+ "engines": {
18
+ "node": ">=20"
19
+ },
20
+ "license": "MIT",
21
+ "dependencies": {
22
+ "@skillstate/core": "^2.0.0"
23
+ }
24
+ }