Skip to content

Commit 6f108e8

Browse files
fix(codex): accept hook event names newer than the pinned protocol (pingdotgg#35885)
1 parent 025942d commit 6f108e8

3 files changed

Lines changed: 47 additions & 135 deletions

File tree

‎packages/effect-codex-app-server/scripts/generate.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ const ManualSchemas: Record<string, Schema.Json> = {
145145
// `account/read` decode and take the provider down with it.
146146
const DefinitionOverrides: Record<string, Schema.Json> = {
147147
PlanType: { type: "string" },
148+
// Newer Codex releases add hook events (e.g. `preModelRequest`); a closed enum drops their notifications.
149+
HookEventName: { type: "string" },
148150
// Newer custom Codex binaries emit partial answers before additional tools or text.
149151
MessagePhase: {
150152
description:

‎packages/effect-codex-app-server/src/_generated/schema.gen.ts‎

Lines changed: 20 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,33 +2782,10 @@ export const ServerNotification__HookOutputEntryKind = Schema.Literals([
27822782
"error",
27832783
]).annotate({ identifier: "ServerNotification__HookOutputEntryKind" });
27842784

2785-
export type ServerNotification__HookEventName =
2786-
| "preToolUse"
2787-
| "permissionRequest"
2788-
| "postToolUse"
2789-
| "preCompact"
2790-
| "postCompact"
2791-
| "sessionStart"
2792-
| "sessionEnd"
2793-
| "userPromptSubmit"
2794-
| "subagentStart"
2795-
| "subagentStop"
2796-
| "stop"
2797-
| "interrupt";
2798-
export const ServerNotification__HookEventName = Schema.Literals([
2799-
"preToolUse",
2800-
"permissionRequest",
2801-
"postToolUse",
2802-
"preCompact",
2803-
"postCompact",
2804-
"sessionStart",
2805-
"sessionEnd",
2806-
"userPromptSubmit",
2807-
"subagentStart",
2808-
"subagentStop",
2809-
"stop",
2810-
"interrupt",
2811-
]).annotate({ identifier: "ServerNotification__HookEventName" });
2785+
export type ServerNotification__HookEventName = string;
2786+
export const ServerNotification__HookEventName = Schema.String.annotate({
2787+
identifier: "ServerNotification__HookEventName",
2788+
});
28122789

28132790
export type ServerNotification__HookExecutionMode = "sync" | "async";
28142791
export const ServerNotification__HookExecutionMode = Schema.Literals(["sync", "async"]).annotate({
@@ -5653,33 +5630,10 @@ export const V2HookCompletedNotification__HookOutputEntryKind = Schema.Literals(
56535630
"error",
56545631
]).annotate({ identifier: "V2HookCompletedNotification__HookOutputEntryKind" });
56555632

5656-
export type V2HookCompletedNotification__HookEventName =
5657-
| "preToolUse"
5658-
| "permissionRequest"
5659-
| "postToolUse"
5660-
| "preCompact"
5661-
| "postCompact"
5662-
| "sessionStart"
5663-
| "sessionEnd"
5664-
| "userPromptSubmit"
5665-
| "subagentStart"
5666-
| "subagentStop"
5667-
| "stop"
5668-
| "interrupt";
5669-
export const V2HookCompletedNotification__HookEventName = Schema.Literals([
5670-
"preToolUse",
5671-
"permissionRequest",
5672-
"postToolUse",
5673-
"preCompact",
5674-
"postCompact",
5675-
"sessionStart",
5676-
"sessionEnd",
5677-
"userPromptSubmit",
5678-
"subagentStart",
5679-
"subagentStop",
5680-
"stop",
5681-
"interrupt",
5682-
]).annotate({ identifier: "V2HookCompletedNotification__HookEventName" });
5633+
export type V2HookCompletedNotification__HookEventName = string;
5634+
export const V2HookCompletedNotification__HookEventName = Schema.String.annotate({
5635+
identifier: "V2HookCompletedNotification__HookEventName",
5636+
});
56835637

56845638
export type V2HookCompletedNotification__HookExecutionMode = "sync" | "async";
56855639
export const V2HookCompletedNotification__HookExecutionMode = Schema.Literals([
@@ -5760,33 +5714,10 @@ export const V2HooksListResponse__HookErrorInfo = Schema.Struct({
57605714
path: Schema.String,
57615715
}).annotate({ identifier: "V2HooksListResponse__HookErrorInfo" });
57625716

5763-
export type V2HooksListResponse__HookEventName =
5764-
| "preToolUse"
5765-
| "permissionRequest"
5766-
| "postToolUse"
5767-
| "preCompact"
5768-
| "postCompact"
5769-
| "sessionStart"
5770-
| "sessionEnd"
5771-
| "userPromptSubmit"
5772-
| "subagentStart"
5773-
| "subagentStop"
5774-
| "stop"
5775-
| "interrupt";
5776-
export const V2HooksListResponse__HookEventName = Schema.Literals([
5777-
"preToolUse",
5778-
"permissionRequest",
5779-
"postToolUse",
5780-
"preCompact",
5781-
"postCompact",
5782-
"sessionStart",
5783-
"sessionEnd",
5784-
"userPromptSubmit",
5785-
"subagentStart",
5786-
"subagentStop",
5787-
"stop",
5788-
"interrupt",
5789-
]).annotate({ identifier: "V2HooksListResponse__HookEventName" });
5717+
export type V2HooksListResponse__HookEventName = string;
5718+
export const V2HooksListResponse__HookEventName = Schema.String.annotate({
5719+
identifier: "V2HooksListResponse__HookEventName",
5720+
});
57905721

57915722
export type V2HooksListResponse__HookSource =
57925723
| "system"
@@ -5843,33 +5774,10 @@ export const V2HookStartedNotification__HookOutputEntryKind = Schema.Literals([
58435774
"error",
58445775
]).annotate({ identifier: "V2HookStartedNotification__HookOutputEntryKind" });
58455776

5846-
export type V2HookStartedNotification__HookEventName =
5847-
| "preToolUse"
5848-
| "permissionRequest"
5849-
| "postToolUse"
5850-
| "preCompact"
5851-
| "postCompact"
5852-
| "sessionStart"
5853-
| "sessionEnd"
5854-
| "userPromptSubmit"
5855-
| "subagentStart"
5856-
| "subagentStop"
5857-
| "stop"
5858-
| "interrupt";
5859-
export const V2HookStartedNotification__HookEventName = Schema.Literals([
5860-
"preToolUse",
5861-
"permissionRequest",
5862-
"postToolUse",
5863-
"preCompact",
5864-
"postCompact",
5865-
"sessionStart",
5866-
"sessionEnd",
5867-
"userPromptSubmit",
5868-
"subagentStart",
5869-
"subagentStop",
5870-
"stop",
5871-
"interrupt",
5872-
]).annotate({ identifier: "V2HookStartedNotification__HookEventName" });
5777+
export type V2HookStartedNotification__HookEventName = string;
5778+
export const V2HookStartedNotification__HookEventName = Schema.String.annotate({
5779+
identifier: "V2HookStartedNotification__HookEventName",
5780+
});
58735781

58745782
export type V2HookStartedNotification__HookExecutionMode = "sync" | "async";
58755783
export const V2HookStartedNotification__HookExecutionMode = Schema.Literals([
@@ -7530,33 +7438,10 @@ export const V2PluginReadResponse__AppSummary = Schema.Struct({
75307438
identifier: "V2PluginReadResponse__AppSummary",
75317439
});
75327440

7533-
export type V2PluginReadResponse__HookEventName =
7534-
| "preToolUse"
7535-
| "permissionRequest"
7536-
| "postToolUse"
7537-
| "preCompact"
7538-
| "postCompact"
7539-
| "sessionStart"
7540-
| "sessionEnd"
7541-
| "userPromptSubmit"
7542-
| "subagentStart"
7543-
| "subagentStop"
7544-
| "stop"
7545-
| "interrupt";
7546-
export const V2PluginReadResponse__HookEventName = Schema.Literals([
7547-
"preToolUse",
7548-
"permissionRequest",
7549-
"postToolUse",
7550-
"preCompact",
7551-
"postCompact",
7552-
"sessionStart",
7553-
"sessionEnd",
7554-
"userPromptSubmit",
7555-
"subagentStart",
7556-
"subagentStop",
7557-
"stop",
7558-
"interrupt",
7559-
]).annotate({ identifier: "V2PluginReadResponse__HookEventName" });
7441+
export type V2PluginReadResponse__HookEventName = string;
7442+
export const V2PluginReadResponse__HookEventName = Schema.String.annotate({
7443+
identifier: "V2PluginReadResponse__HookEventName",
7444+
});
75607445

75617446
export type V2PluginReadResponse__AbsolutePathBuf = string;
75627447
export const V2PluginReadResponse__AbsolutePathBuf = Schema.String.annotate({

‎packages/effect-codex-app-server/src/schema.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const isThreadReadResponse = Schema.is(CodexSchema.V2ThreadReadResponse);
88
const isThreadResumeResponse = Schema.is(CodexSchema.V2ThreadResumeResponse);
99
const isThreadForkResponse = Schema.is(CodexSchema.V2ThreadForkResponse);
1010
const isTurnCompletedNotification = Schema.is(CodexSchema.V2TurnCompletedNotification);
11+
const isHookStartedNotification = Schema.is(CodexSchema.V2HookStartedNotification);
12+
const isHookCompletedNotification = Schema.is(CodexSchema.V2HookCompletedNotification);
1113
const decodeThreadResumeResponse = Schema.decodeUnknownSync(CodexSchema.V2ThreadResumeResponse);
1214

1315
it("keeps async questions in live notifications and thread history", () => {
@@ -239,3 +241,26 @@ it("accepts account plan slugs newer than the pinned protocol", () => {
239241
assert.equal(isGetAccountResponse(accountResponse), true);
240242
}
241243
});
244+
245+
it("accepts Codex model-request hook runs", () => {
246+
for (const eventName of ["preModelRequest", "postModelRequest"]) {
247+
const notification = {
248+
threadId: "thread-1",
249+
turnId: "turn-1",
250+
run: {
251+
id: `hook-${eventName}`,
252+
eventName,
253+
executionMode: "sync",
254+
handlerType: "command",
255+
scope: "turn",
256+
sourcePath: "/tmp/project/.codex/hooks.json",
257+
startedAt: 1,
258+
status: "stopped",
259+
displayOrder: 0,
260+
entries: [{ kind: "stop", text: "Stop reason supplied by hook" }],
261+
},
262+
};
263+
assert.equal(isHookStartedNotification(notification), true);
264+
assert.equal(isHookCompletedNotification(notification), true);
265+
}
266+
});

0 commit comments

Comments
 (0)