Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix(codex): keep app-server protocol decode current (#209)

Leo9f93b844efdc
diff --git a/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts b/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts
index e791594dd..8865121ed 100644
--- a/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts
+++ b/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts
@@ -3791,15 +3791,15 @@ describe("ProviderCommandReactor", () => {
});
});
- it("surfaces stale provider approval request failures without faking approval resolution", async () => {
+ it("normalizes stale Codex approval callbacks without faking approval resolution", async () => {
const harness = await createHarness();
const now = "2026-01-01T00:00:00.000Z";
harness.respondToRequest.mockImplementation(() =>
Effect.fail(
new ProviderAdapterRequestError({
provider: ProviderDriverKind.make("codex"),
- method: "session/request_permission",
- detail: "Unknown pending permission request: approval-request-1",
+ method: "item/requestApproval/decision",
+ detail: "Unknown pending Codex approval request: approval-request-1",
}),
),
);
diff --git a/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts b/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
index 532aa8eae..bf6d4aa1d 100644
--- a/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
+++ b/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
@@ -286,13 +286,15 @@ function isUnknownPendingApprovalRequestError(cause: Cause.Cause<AgentController
const detail = error.detail.toLowerCase();
return (
detail.includes("unknown pending approval request") ||
- detail.includes("unknown pending permission request")
+ detail.includes("unknown pending permission request") ||
+ detail.includes("unknown pending codex approval request")
);
}
- const message = Cause.pretty(cause);
+ const message = Cause.pretty(cause).toLowerCase();
return (
message.includes("unknown pending approval request") ||
- message.includes("unknown pending permission request")
+ message.includes("unknown pending permission request") ||
+ message.includes("unknown pending codex approval request")
);
}
diff --git a/apps/server/src/provider/Layers/CodexProvider.ts b/apps/server/src/provider/Layers/CodexProvider.ts
index 4b76b2ac2..000623da7 100644
--- a/apps/server/src/provider/Layers/CodexProvider.ts
+++ b/apps/server/src/provider/Layers/CodexProvider.ts
@@ -86,13 +86,18 @@ function codexAccountAuthLabel(account: CodexSchema.V2GetAccountResponse["accoun
return "ChatGPT Pro 5x Subscription";
case "team":
return "ChatGPT Team Subscription";
+ case "self_serve_business_prolite":
case "self_serve_business_usage_based":
case "business":
return "ChatGPT Business Subscription";
+ case "ent26":
+ case "enterprise_cbp_automation":
case "enterprise_cbp_usage_based":
case "enterprise":
return "ChatGPT Enterprise Subscription";
case "edu":
+ case "edu_plus":
+ case "edu_pro":
return "ChatGPT Edu Subscription";
case "unknown":
return "ChatGPT Subscription";
diff --git a/docs/internals/providers.md b/docs/internals/providers.md
index df093b09a..7680fb26a 100644
--- a/docs/internals/providers.md
+++ b/docs/internals/providers.md
@@ -71,7 +71,8 @@ OpenCode Go stays on the Mastra controller and does not use this CLI probe path.
The [ACP protocol](../../packages/effect-acp/src/protocol.ts) and
[Codex app-server protocol](../../packages/effect-codex-app-server/src/protocol.ts) retain raw
-observations only when configured before connection. `AcpClientOptions` and `AcpAgentOptions` expose
+observations only when configured before connection. Incoming Codex JSONL is framed from
+per-chunk fragments so large messages are scanned once. `AcpClientOptions` and `AcpAgentOptions` expose
`rawNotificationBufferSize` for `raw.notifications`. `CodexAppServerClientOptions` exposes that option
and `rawRequestBufferSize` for `raw.requests`. Pass them to the package's `make` or layer constructor.
diff --git a/packages/effect-codex-app-server/scripts/generate.ts b/packages/effect-codex-app-server/scripts/generate.ts
index 9f23a1445..f14b75047 100644
--- a/packages/effect-codex-app-server/scripts/generate.ts
+++ b/packages/effect-codex-app-server/scripts/generate.ts
@@ -145,6 +145,113 @@ const ManualSchemas: Record<string, Schema.Json> = {
},
};
+// Codex 0.150 added these multi-agent values before our next full protocol
+// refresh. Keep every generated response namespace compatible with them.
+const Codex0150DefinitionSchemas: Record<string, Schema.Json> = {
+ CollabAgentTool: {
+ type: "string",
+ enum: [
+ "spawnAgent",
+ "sendInput",
+ "resumeAgent",
+ "wait",
+ "closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
+ ],
+ },
+ CollabAgentToolCallStatus: {
+ type: "string",
+ enum: ["inProgress", "completed", "failed", "interrupted"],
+ },
+ PlanType: {
+ type: "string",
+ enum: [
+ "free",
+ "go",
+ "plus",
+ "pro",
+ "prolite",
+ "team",
+ "self_serve_business_prolite",
+ "self_serve_business_usage_based",
+ "business",
+ "ent26",
+ "enterprise_cbp_automation",
+ "enterprise_cbp_usage_based",
+ "enterprise",
+ "edu",
+ "edu_plus",
+ "edu_pro",
+ "unknown",
+ ],
+ },
+ SubAgentActivityKind: {
+ type: "string",
+ enum: ["started", "interacted", "interrupted", "completed"],
+ },
+};
+
+// Pinned protocol JSON omits later CodexErrorInfo variants. Keep historical
+// thread payloads decodable; do not fold unknown values into "other".
+const CodexErrorInfoCompatibilityValues = [
+ "rateLimitExceeded",
+ "misalignmentPolicyViolation",
+] as const;
+
+const CodexErrorInfoCompatibilityExports = new Set([
+ "V2ThreadReadResponse",
+ "V2ThreadResumeResponse",
+ "V2ThreadRollbackResponse",
+ "V2ThreadForkResponse",
+ "V2ThreadListResponse",
+ "V2TurnCompletedNotification",
+]);
+
+function applyCodex0151DefinitionCompatibility(
+ exportName: string,
+ definitionName: string,
+ definitionSchema: Schema.Json,
+): Schema.Json {
+ if (
+ !CodexErrorInfoCompatibilityExports.has(exportName) ||
+ definitionName !== "CodexErrorInfo" ||
+ typeof definitionSchema !== "object"
+ ) {
+ return definitionSchema;
+ }
+
+ const schema = definitionSchema as {
+ readonly oneOf?: ReadonlyArray<{ readonly enum?: ReadonlyArray<string> }>;
+ };
+ const [firstVariant, ...remainingVariants] = schema.oneOf ?? [];
+ const currentEnum = firstVariant?.enum;
+ if (!currentEnum) {
+ return definitionSchema;
+ }
+
+ const missingValues = CodexErrorInfoCompatibilityValues.filter(
+ (value) => !currentEnum.includes(value),
+ );
+ if (missingValues.length === 0) {
+ return definitionSchema;
+ }
+
+ const enumValues = [...currentEnum];
+ const otherIndex = enumValues.indexOf("other");
+ const nextEnum =
+ otherIndex === -1
+ ? [...enumValues, ...missingValues]
+ : [...enumValues.slice(0, otherIndex), ...missingValues, ...enumValues.slice(otherIndex)];
+
+ return {
+ ...definitionSchema,
+ oneOf: [{ ...firstVariant, enum: nextEnum }, ...remainingVariants],
+ };
+}
+
const getGeneratedPaths = Effect.fn("getGeneratedPaths")(function* () {
const path = yield* Path.Path;
const generatedDir = path.join(import.meta.dirname, "..", "src", "_generated");
@@ -556,10 +663,13 @@ const generateFiles = Effect.fn("generateFiles")(function* () {
);
for (const [definitionName, definitionSchema] of Object.entries(parsed.definitions ?? {})) {
+ const compatibleDefinitionSchema =
+ Codex0150DefinitionSchemas[definitionName] ??
+ applyCodex0151DefinitionCompatibility(file.exportName, definitionName, definitionSchema);
aggregateSchemas[localDefinitionNames.get(definitionName)!] = stripNullDefaults(
normalizeNullableTypes(
rewriteExternalRefs(
- definitionSchema,
+ compatibleDefinitionSchema,
localDefinitionNames,
file.namespace,
exportNameByQualifiedName,
diff --git a/packages/effect-codex-app-server/src/_generated/schema.gen.ts b/packages/effect-codex-app-server/src/_generated/schema.gen.ts
index d826df60f..0f9af7887 100644
--- a/packages/effect-codex-app-server/src/_generated/schema.gen.ts
+++ b/packages/effect-codex-app-server/src/_generated/schema.gen.ts
@@ -2411,11 +2411,16 @@ export type ServerNotification__PlanType =
| "pro"
| "prolite"
| "team"
+ | "self_serve_business_prolite"
| "self_serve_business_usage_based"
| "business"
+ | "ent26"
+ | "enterprise_cbp_automation"
| "enterprise_cbp_usage_based"
| "enterprise"
| "edu"
+ | "edu_plus"
+ | "edu_pro"
| "unknown";
export const ServerNotification__PlanType = Schema.Literals([
"free",
@@ -2424,11 +2429,16 @@ export const ServerNotification__PlanType = Schema.Literals([
"pro",
"prolite",
"team",
+ "self_serve_business_prolite",
"self_serve_business_usage_based",
"business",
+ "ent26",
+ "enterprise_cbp_automation",
"enterprise_cbp_usage_based",
"enterprise",
"edu",
+ "edu_plus",
+ "edu_pro",
"unknown",
]);
@@ -2616,11 +2626,16 @@ export const ServerNotification__SpendControlLimitSnapshot = Schema.Struct({
used: Schema.String,
});
-export type ServerNotification__SubAgentActivityKind = "started" | "interacted" | "interrupted";
+export type ServerNotification__SubAgentActivityKind =
+ | "started"
+ | "interacted"
+ | "interrupted"
+ | "completed";
export const ServerNotification__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type ServerNotification__TerminalInteractionNotification = {
@@ -3243,11 +3258,16 @@ export type V2AccountRateLimitsUpdatedNotification__PlanType =
| "pro"
| "prolite"
| "team"
+ | "self_serve_business_prolite"
| "self_serve_business_usage_based"
| "business"
+ | "ent26"
+ | "enterprise_cbp_automation"
| "enterprise_cbp_usage_based"
| "enterprise"
| "edu"
+ | "edu_plus"
+ | "edu_pro"
| "unknown";
export const V2AccountRateLimitsUpdatedNotification__PlanType = Schema.Literals([
"free",
@@ -3256,11 +3276,16 @@ export const V2AccountRateLimitsUpdatedNotification__PlanType = Schema.Literals(
"pro",
"prolite",
"team",
+ "self_serve_business_prolite",
"self_serve_business_usage_based",
"business",
+ "ent26",
+ "enterprise_cbp_automation",
"enterprise_cbp_usage_based",
"enterprise",
"edu",
+ "edu_plus",
+ "edu_pro",
"unknown",
]);
@@ -3331,11 +3356,16 @@ export type V2AccountUpdatedNotification__PlanType =
| "pro"
| "prolite"
| "team"
+ | "self_serve_business_prolite"
| "self_serve_business_usage_based"
| "business"
+ | "ent26"
+ | "enterprise_cbp_automation"
| "enterprise_cbp_usage_based"
| "enterprise"
| "edu"
+ | "edu_plus"
+ | "edu_pro"
| "unknown";
export const V2AccountUpdatedNotification__PlanType = Schema.Literals([
"free",
@@ -3344,11 +3374,16 @@ export const V2AccountUpdatedNotification__PlanType = Schema.Literals([
"pro",
"prolite",
"team",
+ "self_serve_business_prolite",
"self_serve_business_usage_based",
"business",
+ "ent26",
+ "enterprise_cbp_automation",
"enterprise_cbp_usage_based",
"enterprise",
"edu",
+ "edu_plus",
+ "edu_pro",
"unknown",
]);
@@ -4135,11 +4170,16 @@ export type V2GetAccountRateLimitsResponse__PlanType =
| "pro"
| "prolite"
| "team"
+ | "self_serve_business_prolite"
| "self_serve_business_usage_based"
| "business"
+ | "ent26"
+ | "enterprise_cbp_automation"
| "enterprise_cbp_usage_based"
| "enterprise"
| "edu"
+ | "edu_plus"
+ | "edu_pro"
| "unknown";
export const V2GetAccountRateLimitsResponse__PlanType = Schema.Literals([
"free",
@@ -4148,11 +4188,16 @@ export const V2GetAccountRateLimitsResponse__PlanType = Schema.Literals([
"pro",
"prolite",
"team",
+ "self_serve_business_prolite",
"self_serve_business_usage_based",
"business",
+ "ent26",
+ "enterprise_cbp_automation",
"enterprise_cbp_usage_based",
"enterprise",
"edu",
+ "edu_plus",
+ "edu_pro",
"unknown",
]);
@@ -4223,11 +4268,16 @@ export type V2GetAccountResponse__PlanType =
| "pro"
| "prolite"
| "team"
+ | "self_serve_business_prolite"
| "self_serve_business_usage_based"
| "business"
+ | "ent26"
+ | "enterprise_cbp_automation"
| "enterprise_cbp_usage_based"
| "enterprise"
| "edu"
+ | "edu_plus"
+ | "edu_pro"
| "unknown";
export const V2GetAccountResponse__PlanType = Schema.Literals([
"free",
@@ -4236,11 +4286,16 @@ export const V2GetAccountResponse__PlanType = Schema.Literals([
"pro",
"prolite",
"team",
+ "self_serve_business_prolite",
"self_serve_business_usage_based",
"business",
+ "ent26",
+ "enterprise_cbp_automation",
"enterprise_cbp_usage_based",
"enterprise",
"edu",
+ "edu_plus",
+ "edu_pro",
"unknown",
]);
@@ -4710,11 +4765,13 @@ export const V2ItemCompletedNotification__ReasoningEffort = Schema.String.annota
export type V2ItemCompletedNotification__SubAgentActivityKind =
| "started"
| "interacted"
- | "interrupted";
+ | "interrupted"
+ | "completed";
export const V2ItemCompletedNotification__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2ItemCompletedNotification__TextElement = {
@@ -5115,11 +5172,13 @@ export const V2ItemStartedNotification__ReasoningEffort = Schema.String.annotate
export type V2ItemStartedNotification__SubAgentActivityKind =
| "started"
| "interacted"
- | "interrupted";
+ | "interrupted"
+ | "completed";
export const V2ItemStartedNotification__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2ItemStartedNotification__TextElement = {
@@ -6284,11 +6343,16 @@ export const V2ReviewStartResponse__ReasoningEffort = Schema.String.annotate({
description: "A non-empty reasoning effort value advertised by the model.",
}).check(Schema.isMinLength(1));
-export type V2ReviewStartResponse__SubAgentActivityKind = "started" | "interacted" | "interrupted";
+export type V2ReviewStartResponse__SubAgentActivityKind =
+ | "started"
+ | "interacted"
+ | "interrupted"
+ | "completed";
export const V2ReviewStartResponse__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2ReviewStartResponse__TextElement = {
@@ -6720,11 +6784,16 @@ export const V2ThreadForkResponse__ReasoningEffort = Schema.String.annotate({
description: "A non-empty reasoning effort value advertised by the model.",
}).check(Schema.isMinLength(1));
-export type V2ThreadForkResponse__SubAgentActivityKind = "started" | "interacted" | "interrupted";
+export type V2ThreadForkResponse__SubAgentActivityKind =
+ | "started"
+ | "interacted"
+ | "interrupted"
+ | "completed";
export const V2ThreadForkResponse__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2ThreadForkResponse__TextElement = {
@@ -7119,11 +7188,16 @@ export const V2ThreadListResponse__ReasoningEffort = Schema.String.annotate({
description: "A non-empty reasoning effort value advertised by the model.",
}).check(Schema.isMinLength(1));
-export type V2ThreadListResponse__SubAgentActivityKind = "started" | "interacted" | "interrupted";
+export type V2ThreadListResponse__SubAgentActivityKind =
+ | "started"
+ | "interacted"
+ | "interrupted"
+ | "completed";
export const V2ThreadListResponse__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2ThreadListResponse__TextElement = {
@@ -7463,11 +7537,13 @@ export const V2ThreadMetadataUpdateResponse__ReasoningEffort = Schema.String.ann
export type V2ThreadMetadataUpdateResponse__SubAgentActivityKind =
| "started"
| "interacted"
- | "interrupted";
+ | "interrupted"
+ | "completed";
export const V2ThreadMetadataUpdateResponse__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2ThreadMetadataUpdateResponse__TextElement = {
@@ -7760,11 +7836,16 @@ export const V2ThreadReadResponse__ReasoningEffort = Schema.String.annotate({
description: "A non-empty reasoning effort value advertised by the model.",
}).check(Schema.isMinLength(1));
-export type V2ThreadReadResponse__SubAgentActivityKind = "started" | "interacted" | "interrupted";
+export type V2ThreadReadResponse__SubAgentActivityKind =
+ | "started"
+ | "interacted"
+ | "interrupted"
+ | "completed";
export const V2ThreadReadResponse__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2ThreadReadResponse__TextElement = {
@@ -8342,11 +8423,16 @@ export const V2ThreadResumeResponse__ReasoningEffort = Schema.String.annotate({
description: "A non-empty reasoning effort value advertised by the model.",
}).check(Schema.isMinLength(1));
-export type V2ThreadResumeResponse__SubAgentActivityKind = "started" | "interacted" | "interrupted";
+export type V2ThreadResumeResponse__SubAgentActivityKind =
+ | "started"
+ | "interacted"
+ | "interrupted"
+ | "completed";
export const V2ThreadResumeResponse__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2ThreadResumeResponse__TextElement = {
@@ -8643,11 +8729,13 @@ export const V2ThreadRollbackResponse__ReasoningEffort = Schema.String.annotate(
export type V2ThreadRollbackResponse__SubAgentActivityKind =
| "started"
| "interacted"
- | "interrupted";
+ | "interrupted"
+ | "completed";
export const V2ThreadRollbackResponse__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2ThreadRollbackResponse__TextElement = {
@@ -9051,11 +9139,13 @@ export const V2ThreadStartedNotification__ReasoningEffort = Schema.String.annota
export type V2ThreadStartedNotification__SubAgentActivityKind =
| "started"
| "interacted"
- | "interrupted";
+ | "interrupted"
+ | "completed";
export const V2ThreadStartedNotification__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2ThreadStartedNotification__TextElement = {
@@ -9458,11 +9548,16 @@ export const V2ThreadStartResponse__ReasoningEffort = Schema.String.annotate({
description: "A non-empty reasoning effort value advertised by the model.",
}).check(Schema.isMinLength(1));
-export type V2ThreadStartResponse__SubAgentActivityKind = "started" | "interacted" | "interrupted";
+export type V2ThreadStartResponse__SubAgentActivityKind =
+ | "started"
+ | "interacted"
+ | "interrupted"
+ | "completed";
export const V2ThreadStartResponse__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2ThreadStartResponse__TextElement = {
@@ -9791,11 +9886,13 @@ export const V2ThreadUnarchiveResponse__ReasoningEffort = Schema.String.annotate
export type V2ThreadUnarchiveResponse__SubAgentActivityKind =
| "started"
| "interacted"
- | "interrupted";
+ | "interrupted"
+ | "completed";
export const V2ThreadUnarchiveResponse__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2ThreadUnarchiveResponse__TextElement = {
@@ -10095,11 +10192,13 @@ export const V2TurnCompletedNotification__ReasoningEffort = Schema.String.annota
export type V2TurnCompletedNotification__SubAgentActivityKind =
| "started"
| "interacted"
- | "interrupted";
+ | "interrupted"
+ | "completed";
export const V2TurnCompletedNotification__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2TurnCompletedNotification__TextElement = {
@@ -10385,11 +10484,13 @@ export const V2TurnStartedNotification__ReasoningEffort = Schema.String.annotate
export type V2TurnStartedNotification__SubAgentActivityKind =
| "started"
| "interacted"
- | "interrupted";
+ | "interrupted"
+ | "completed";
export const V2TurnStartedNotification__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2TurnStartedNotification__TextElement = {
@@ -10761,11 +10862,16 @@ export const V2TurnStartResponse__ReasoningEffort = Schema.String.annotate({
description: "A non-empty reasoning effort value advertised by the model.",
}).check(Schema.isMinLength(1));
-export type V2TurnStartResponse__SubAgentActivityKind = "started" | "interacted" | "interrupted";
+export type V2TurnStartResponse__SubAgentActivityKind =
+ | "started"
+ | "interacted"
+ | "interrupted"
+ | "completed";
export const V2TurnStartResponse__SubAgentActivityKind = Schema.Literals([
"started",
"interacted",
"interrupted",
+ "completed",
]);
export type V2TurnStartResponse__TextElement = {
@@ -15838,6 +15944,8 @@ export type V2ThreadForkResponse__CodexErrorInfo =
| "badRequest"
| "threadRollbackFailed"
| "sandboxError"
+ | "rateLimitExceeded"
+ | "misalignmentPolicyViolation"
| "other"
| { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
| { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
@@ -15861,6 +15969,8 @@ export const V2ThreadForkResponse__CodexErrorInfo = Schema.Union(
"badRequest",
"threadRollbackFailed",
"sandboxError",
+ "rateLimitExceeded",
+ "misalignmentPolicyViolation",
"other",
]),
Schema.Struct({
@@ -16185,6 +16295,8 @@ export type V2ThreadListResponse__CodexErrorInfo =
| "badRequest"
| "threadRollbackFailed"
| "sandboxError"
+ | "rateLimitExceeded"
+ | "misalignmentPolicyViolation"
| "other"
| { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
| { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
@@ -16208,6 +16320,8 @@ export const V2ThreadListResponse__CodexErrorInfo = Schema.Union(
"badRequest",
"threadRollbackFailed",
"sandboxError",
+ "rateLimitExceeded",
+ "misalignmentPolicyViolation",
"other",
]),
Schema.Struct({
@@ -16745,6 +16859,8 @@ export type V2ThreadReadResponse__CodexErrorInfo =
| "badRequest"
| "threadRollbackFailed"
| "sandboxError"
+ | "rateLimitExceeded"
+ | "misalignmentPolicyViolation"
| "other"
| { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
| { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
@@ -16768,6 +16884,8 @@ export const V2ThreadReadResponse__CodexErrorInfo = Schema.Union(
"badRequest",
"threadRollbackFailed",
"sandboxError",
+ "rateLimitExceeded",
+ "misalignmentPolicyViolation",
"other",
]),
Schema.Struct({
@@ -17098,6 +17216,8 @@ export type V2ThreadResumeResponse__CodexErrorInfo =
| "badRequest"
| "threadRollbackFailed"
| "sandboxError"
+ | "rateLimitExceeded"
+ | "misalignmentPolicyViolation"
| "other"
| { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
| { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
@@ -17121,6 +17241,8 @@ export const V2ThreadResumeResponse__CodexErrorInfo = Schema.Union(
"badRequest",
"threadRollbackFailed",
"sandboxError",
+ "rateLimitExceeded",
+ "misalignmentPolicyViolation",
"other",
]),
Schema.Struct({
@@ -17376,6 +17498,8 @@ export type V2ThreadRollbackResponse__CodexErrorInfo =
| "badRequest"
| "threadRollbackFailed"
| "sandboxError"
+ | "rateLimitExceeded"
+ | "misalignmentPolicyViolation"
| "other"
| { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
| { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
@@ -17399,6 +17523,8 @@ export const V2ThreadRollbackResponse__CodexErrorInfo = Schema.Union(
"badRequest",
"threadRollbackFailed",
"sandboxError",
+ "rateLimitExceeded",
+ "misalignmentPolicyViolation",
"other",
]),
Schema.Struct({
@@ -18598,6 +18724,8 @@ export type V2TurnCompletedNotification__CodexErrorInfo =
| "badRequest"
| "threadRollbackFailed"
| "sandboxError"
+ | "rateLimitExceeded"
+ | "misalignmentPolicyViolation"
| "other"
| { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
| { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
@@ -18621,6 +18749,8 @@ export const V2TurnCompletedNotification__CodexErrorInfo = Schema.Union(
"badRequest",
"threadRollbackFailed",
"sandboxError",
+ "rateLimitExceeded",
+ "misalignmentPolicyViolation",
"other",
]),
Schema.Struct({
@@ -20357,8 +20487,17 @@ export type ServerNotification__ThreadItem =
readonly reasoningEffort?: ServerNotification__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -20580,7 +20719,7 @@ export const ServerNotification__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -20589,6 +20728,10 @@ export const ServerNotification__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -21440,8 +21583,17 @@ export type V2ItemCompletedNotification__ThreadItem =
readonly reasoningEffort?: V2ItemCompletedNotification__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -21668,7 +21820,7 @@ export const V2ItemCompletedNotification__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -21677,6 +21829,10 @@ export const V2ItemCompletedNotification__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -21891,8 +22047,17 @@ export type V2ItemStartedNotification__ThreadItem =
readonly reasoningEffort?: V2ItemStartedNotification__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -22119,7 +22284,7 @@ export const V2ItemStartedNotification__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -22128,6 +22293,10 @@ export const V2ItemStartedNotification__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -22514,8 +22683,17 @@ export type V2ReviewStartResponse__ThreadItem =
readonly reasoningEffort?: V2ReviewStartResponse__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -22739,7 +22917,7 @@ export const V2ReviewStartResponse__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -22748,6 +22926,10 @@ export const V2ReviewStartResponse__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -22950,8 +23132,17 @@ export type V2ThreadForkResponse__ThreadItem =
readonly reasoningEffort?: V2ThreadForkResponse__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -23175,7 +23366,7 @@ export const V2ThreadForkResponse__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -23184,6 +23375,10 @@ export const V2ThreadForkResponse__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -23355,8 +23550,17 @@ export type V2ThreadListResponse__ThreadItem =
readonly reasoningEffort?: V2ThreadListResponse__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -23580,7 +23784,7 @@ export const V2ThreadListResponse__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -23589,6 +23793,10 @@ export const V2ThreadListResponse__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -23762,8 +23970,17 @@ export type V2ThreadMetadataUpdateResponse__ThreadItem =
readonly reasoningEffort?: V2ThreadMetadataUpdateResponse__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -23990,7 +24207,7 @@ export const V2ThreadMetadataUpdateResponse__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -23999,6 +24216,10 @@ export const V2ThreadMetadataUpdateResponse__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -24170,8 +24391,17 @@ export type V2ThreadReadResponse__ThreadItem =
readonly reasoningEffort?: V2ThreadReadResponse__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -24395,7 +24625,7 @@ export const V2ThreadReadResponse__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -24404,6 +24634,10 @@ export const V2ThreadReadResponse__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -24583,8 +24817,17 @@ export type V2ThreadResumeResponse__ThreadItem =
readonly reasoningEffort?: V2ThreadResumeResponse__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -24808,7 +25051,7 @@ export const V2ThreadResumeResponse__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -24817,6 +25060,10 @@ export const V2ThreadResumeResponse__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -24988,8 +25235,17 @@ export type V2ThreadRollbackResponse__ThreadItem =
readonly reasoningEffort?: V2ThreadRollbackResponse__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -25216,7 +25472,7 @@ export const V2ThreadRollbackResponse__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -25225,6 +25481,10 @@ export const V2ThreadRollbackResponse__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -25407,8 +25667,17 @@ export type V2ThreadStartedNotification__ThreadItem =
readonly reasoningEffort?: V2ThreadStartedNotification__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -25635,7 +25904,7 @@ export const V2ThreadStartedNotification__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -25644,6 +25913,10 @@ export const V2ThreadStartedNotification__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -25815,8 +26088,17 @@ export type V2ThreadStartResponse__ThreadItem =
readonly reasoningEffort?: V2ThreadStartResponse__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -26040,7 +26322,7 @@ export const V2ThreadStartResponse__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -26049,6 +26331,10 @@ export const V2ThreadStartResponse__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -26220,8 +26506,17 @@ export type V2ThreadUnarchiveResponse__ThreadItem =
readonly reasoningEffort?: V2ThreadUnarchiveResponse__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -26448,7 +26743,7 @@ export const V2ThreadUnarchiveResponse__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -26457,6 +26752,10 @@ export const V2ThreadUnarchiveResponse__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -26630,8 +26929,17 @@ export type V2TurnCompletedNotification__ThreadItem =
readonly reasoningEffort?: V2TurnCompletedNotification__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -26858,7 +27166,7 @@ export const V2TurnCompletedNotification__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -26867,6 +27175,10 @@ export const V2TurnCompletedNotification__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -27038,8 +27350,17 @@ export type V2TurnStartedNotification__ThreadItem =
readonly reasoningEffort?: V2TurnStartedNotification__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -27266,7 +27587,7 @@ export const V2TurnStartedNotification__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -27275,6 +27596,10 @@ export const V2TurnStartedNotification__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -27446,8 +27771,17 @@ export type V2TurnStartResponse__ThreadItem =
readonly reasoningEffort?: V2TurnStartResponse__ReasoningEffort | null;
readonly receiverThreadIds: ReadonlyArray<string>;
readonly senderThreadId: string;
- readonly status: "inProgress" | "completed" | "failed";
- readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
+ readonly status: "inProgress" | "completed" | "failed" | "interrupted";
+ readonly tool:
+ | "spawnAgent"
+ | "sendInput"
+ | "resumeAgent"
+ | "wait"
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
readonly type: "collabAgentToolCall";
}
| {
@@ -27669,7 +28003,7 @@ export const V2TurnStartResponse__ThreadItem = Schema.Union(
senderThreadId: Schema.String.annotate({
description: "Thread ID of the agent issuing the collab request.",
}),
- status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
+ status: Schema.Literals(["inProgress", "completed", "failed", "interrupted"]).annotate({
description: "Current status of the collab tool call.",
}),
tool: Schema.Literals([
@@ -27678,6 +28012,10 @@ export const V2TurnStartResponse__ThreadItem = Schema.Union(
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]).annotate({ description: "Name of the collab tool that was invoked." }),
type: Schema.Literal("collabAgentToolCall").annotate({
title: "CollabAgentToolCallThreadItemType",
@@ -35971,20 +36309,33 @@ export type ServerNotification__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const ServerNotification__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
-export type ServerNotification__CollabAgentToolCallStatus = "inProgress" | "completed" | "failed";
+export type ServerNotification__CollabAgentToolCallStatus =
+ | "inProgress"
+ | "completed"
+ | "failed"
+ | "interrupted";
export const ServerNotification__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type ServerNotification__CommandExecOutputStream = "stdout" | "stderr";
@@ -38046,23 +38397,33 @@ export type V2ItemCompletedNotification__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2ItemCompletedNotification__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
export type V2ItemCompletedNotification__CollabAgentToolCallStatus =
| "inProgress"
| "completed"
- | "failed";
+ | "failed"
+ | "interrupted";
export const V2ItemCompletedNotification__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2ItemCompletedNotification__CommandExecutionSource =
@@ -38183,23 +38544,33 @@ export type V2ItemStartedNotification__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2ItemStartedNotification__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
export type V2ItemStartedNotification__CollabAgentToolCallStatus =
| "inProgress"
| "completed"
- | "failed";
+ | "failed"
+ | "interrupted";
export const V2ItemStartedNotification__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2ItemStartedNotification__CommandExecutionSource =
@@ -39200,23 +39571,33 @@ export type V2ReviewStartResponse__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2ReviewStartResponse__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
export type V2ReviewStartResponse__CollabAgentToolCallStatus =
| "inProgress"
| "completed"
- | "failed";
+ | "failed"
+ | "interrupted";
export const V2ReviewStartResponse__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2ReviewStartResponse__CommandExecutionSource =
@@ -39598,20 +39979,33 @@ export type V2ThreadForkResponse__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2ThreadForkResponse__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
-export type V2ThreadForkResponse__CollabAgentToolCallStatus = "inProgress" | "completed" | "failed";
+export type V2ThreadForkResponse__CollabAgentToolCallStatus =
+ | "inProgress"
+ | "completed"
+ | "failed"
+ | "interrupted";
export const V2ThreadForkResponse__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2ThreadForkResponse__CommandExecutionSource =
@@ -39955,20 +40349,33 @@ export type V2ThreadListResponse__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2ThreadListResponse__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
-export type V2ThreadListResponse__CollabAgentToolCallStatus = "inProgress" | "completed" | "failed";
+export type V2ThreadListResponse__CollabAgentToolCallStatus =
+ | "inProgress"
+ | "completed"
+ | "failed"
+ | "interrupted";
export const V2ThreadListResponse__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2ThreadListResponse__CommandExecutionSource =
@@ -40131,23 +40538,33 @@ export type V2ThreadMetadataUpdateResponse__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2ThreadMetadataUpdateResponse__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
export type V2ThreadMetadataUpdateResponse__CollabAgentToolCallStatus =
| "inProgress"
| "completed"
- | "failed";
+ | "failed"
+ | "interrupted";
export const V2ThreadMetadataUpdateResponse__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2ThreadMetadataUpdateResponse__CommandExecutionSource =
@@ -40265,20 +40682,33 @@ export type V2ThreadReadResponse__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2ThreadReadResponse__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
-export type V2ThreadReadResponse__CollabAgentToolCallStatus = "inProgress" | "completed" | "failed";
+export type V2ThreadReadResponse__CollabAgentToolCallStatus =
+ | "inProgress"
+ | "completed"
+ | "failed"
+ | "interrupted";
export const V2ThreadReadResponse__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2ThreadReadResponse__CommandExecutionSource =
@@ -40964,23 +41394,33 @@ export type V2ThreadResumeResponse__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2ThreadResumeResponse__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
export type V2ThreadResumeResponse__CollabAgentToolCallStatus =
| "inProgress"
| "completed"
- | "failed";
+ | "failed"
+ | "interrupted";
export const V2ThreadResumeResponse__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2ThreadResumeResponse__CommandExecutionSource =
@@ -41334,23 +41774,33 @@ export type V2ThreadRollbackResponse__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2ThreadRollbackResponse__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
export type V2ThreadRollbackResponse__CollabAgentToolCallStatus =
| "inProgress"
| "completed"
- | "failed";
+ | "failed"
+ | "interrupted";
export const V2ThreadRollbackResponse__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2ThreadRollbackResponse__CommandExecutionSource =
@@ -41673,23 +42123,33 @@ export type V2ThreadStartedNotification__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2ThreadStartedNotification__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
export type V2ThreadStartedNotification__CollabAgentToolCallStatus =
| "inProgress"
| "completed"
- | "failed";
+ | "failed"
+ | "interrupted";
export const V2ThreadStartedNotification__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2ThreadStartedNotification__CommandExecutionSource =
@@ -42075,23 +42535,33 @@ export type V2ThreadStartResponse__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2ThreadStartResponse__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
export type V2ThreadStartResponse__CollabAgentToolCallStatus =
| "inProgress"
| "completed"
- | "failed";
+ | "failed"
+ | "interrupted";
export const V2ThreadStartResponse__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2ThreadStartResponse__CommandExecutionSource =
@@ -42278,23 +42748,33 @@ export type V2ThreadUnarchiveResponse__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2ThreadUnarchiveResponse__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
export type V2ThreadUnarchiveResponse__CollabAgentToolCallStatus =
| "inProgress"
| "completed"
- | "failed";
+ | "failed"
+ | "interrupted";
export const V2ThreadUnarchiveResponse__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2ThreadUnarchiveResponse__CommandExecutionSource =
@@ -42412,23 +42892,33 @@ export type V2TurnCompletedNotification__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2TurnCompletedNotification__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
export type V2TurnCompletedNotification__CollabAgentToolCallStatus =
| "inProgress"
| "completed"
- | "failed";
+ | "failed"
+ | "interrupted";
export const V2TurnCompletedNotification__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2TurnCompletedNotification__CommandExecutionSource =
@@ -42524,23 +43014,33 @@ export type V2TurnStartedNotification__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2TurnStartedNotification__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
export type V2TurnStartedNotification__CollabAgentToolCallStatus =
| "inProgress"
| "completed"
- | "failed";
+ | "failed"
+ | "interrupted";
export const V2TurnStartedNotification__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2TurnStartedNotification__CommandExecutionSource =
@@ -42728,20 +43228,33 @@ export type V2TurnStartResponse__CollabAgentTool =
| "sendInput"
| "resumeAgent"
| "wait"
- | "closeAgent";
+ | "closeAgent"
+ | "sendMessage"
+ | "followupTask"
+ | "interruptAgent"
+ | "listAgents";
export const V2TurnStartResponse__CollabAgentTool = Schema.Literals([
"spawnAgent",
"sendInput",
"resumeAgent",
"wait",
"closeAgent",
+ "sendMessage",
+ "followupTask",
+ "interruptAgent",
+ "listAgents",
]);
-export type V2TurnStartResponse__CollabAgentToolCallStatus = "inProgress" | "completed" | "failed";
+export type V2TurnStartResponse__CollabAgentToolCallStatus =
+ | "inProgress"
+ | "completed"
+ | "failed"
+ | "interrupted";
export const V2TurnStartResponse__CollabAgentToolCallStatus = Schema.Literals([
"inProgress",
"completed",
"failed",
+ "interrupted",
]);
export type V2TurnStartResponse__CommandExecutionSource =
diff --git a/packages/effect-codex-app-server/src/protocol.test.ts b/packages/effect-codex-app-server/src/protocol.test.ts
index fd3cfb1f7..c742d4eb5 100644
--- a/packages/effect-codex-app-server/src/protocol.test.ts
+++ b/packages/effect-codex-app-server/src/protocol.test.ts
@@ -167,6 +167,114 @@ it.layer(NodeServices.layer)("effect-codex-app-server protocol", (it) => {
}),
);
+ it.effect("routes a large notification fragmented across thousands of input chunks", () =>
+ Effect.gen(function* () {
+ const { stdio, input, output } = yield* makeInMemoryStdio();
+ const notifications: Array<CodexProtocol.CodexAppServerIncomingNotification> = [];
+ const transport = yield* CodexProtocol.makeCodexAppServerPatchedProtocol({
+ stdio,
+ onNotification: (notification) =>
+ Effect.sync(() => {
+ notifications.push(notification);
+ }),
+ });
+ const response = yield* transport.request("thread/read", {}).pipe(Effect.forkScoped);
+ yield* Queue.take(output);
+
+ const notification = {
+ method: "turn/diff/updated",
+ params: {
+ threadId: "thread-1",
+ turnId: "turn-1",
+ diff: "x".repeat(4 * 1024 * 1024),
+ },
+ };
+ const bytes = encoder.encode(
+ `${encodeUnknownJsonString(notification)}\n${encodeUnknownJsonString({ id: 1, result: { ok: true } })}\n`,
+ );
+ for (let offset = 0; offset < bytes.length; offset += 1024) {
+ yield* Queue.offer(input, bytes.subarray(offset, offset + 1024));
+ }
+
+ assert.deepEqual(yield* Fiber.join(response), { ok: true });
+ assert.deepEqual(notifications, [notification]);
+ }),
+ );
+
+ it.effect.each([1, 7, 1024])(
+ "preserves JSONL framing and UTF-8 across %i-byte input chunks",
+ (chunkSize) =>
+ Effect.gen(function* () {
+ const { stdio, input } = yield* makeInMemoryStdio();
+ const notifications: Array<CodexProtocol.CodexAppServerIncomingNotification> = [];
+ const rawLines: Array<unknown> = [];
+ const termination = yield* Deferred.make<CodexError.CodexAppServerError>();
+ yield* CodexProtocol.makeCodexAppServerPatchedProtocol({
+ stdio,
+ logIncoming: true,
+ logger: (event) =>
+ Effect.sync(() => {
+ if (event.stage === "raw") {
+ rawLines.push(event.payload);
+ }
+ }),
+ onNotification: (notification) =>
+ Effect.sync(() => {
+ notifications.push(notification);
+ }),
+ onTermination: (error) => Deferred.succeed(termination, error).pipe(Effect.asVoid),
+ });
+
+ const firstLine = '{"method":"x/first",\r"params":{"text":"hé🙂"}}';
+ const secondLine = '{"method":"x/second","params":{"value":2}}';
+ const finalLine = '{"method":"x/final","params":{"text":"最後"}}\r';
+ const bytes = encoder.encode(`\n \t\r\n${firstLine}\r\n\n${secondLine}\n${finalLine}`);
+ for (let offset = 0; offset < bytes.length; offset += chunkSize) {
+ yield* Queue.offer(input, bytes.subarray(offset, offset + chunkSize));
+ }
+ yield* Queue.end(input);
+
+ assert.instanceOf(
+ yield* Deferred.await(termination),
+ CodexError.CodexAppServerInputStreamEndedError,
+ );
+ assert.deepEqual(notifications, [
+ { method: "x/first", params: { text: "hé🙂" } },
+ { method: "x/second", params: { value: 2 } },
+ { method: "x/final", params: { text: "最後" } },
+ ]);
+ assert.deepEqual(rawLines, [firstLine, secondLine, finalLine]);
+ }),
+ );
+
+ it.effect("reports a malformed fragmented final line before input stream termination", () =>
+ Effect.gen(function* () {
+ const { stdio, input, output } = yield* makeInMemoryStdio();
+ const termination = yield* Deferred.make<CodexError.CodexAppServerError>();
+ const transport = yield* CodexProtocol.makeCodexAppServerPatchedProtocol({
+ stdio,
+ onTermination: (error) => Deferred.succeed(termination, error).pipe(Effect.asVoid),
+ });
+ const response = yield* transport.request("thread/read", {}).pipe(Effect.forkScoped);
+ yield* Queue.take(output);
+
+ yield* Queue.offer(input, encoder.encode('{"id":1,'));
+ yield* Queue.offer(input, encoder.encode('"result":'));
+ yield* Queue.end(input);
+
+ const error = yield* Deferred.await(termination);
+ assert.instanceOf(error, CodexError.CodexAppServerProtocolParseError);
+ assert.equal(error.operation, "decode-wire-message");
+ const responseError = yield* Fiber.join(response).pipe(
+ Effect.match({
+ onFailure: (failure) => failure,
+ onSuccess: () => assert.fail("Expected the malformed response to fail the request"),
+ }),
+ );
+ assert.strictEqual(responseError, error);
+ }),
+ );
+
it.effect("drains raw observations and completes waiting readers on decode failure", () =>
Effect.gen(function* () {
const { stdio, input } = yield* makeInMemoryStdio();
diff --git a/packages/effect-codex-app-server/src/protocol.ts b/packages/effect-codex-app-server/src/protocol.ts
index c420a73db..91297ba8e 100644
--- a/packages/effect-codex-app-server/src/protocol.ts
+++ b/packages/effect-codex-app-server/src/protocol.ts
@@ -198,7 +198,7 @@ export const makeCodexAppServerPatchedProtocol = Effect.fn("makeCodexAppServerPa
);
const pending = yield* Ref.make(new Map<string, CodexAppServerPendingRequest>());
const nextRequestId = yield* Ref.make(1);
- const remainder = yield* Ref.make("");
+ const remainder: Array<string> = [];
const terminationHandled = yield* Ref.make(false);
const logProtocol = (event: CodexAppServerProtocolLogEvent) => {
@@ -401,11 +401,24 @@ export const makeCodexAppServerPatchedProtocol = Effect.fn("makeCodexAppServerPa
yield* options.stdio.stdin.pipe(
Stream.decodeText(),
Stream.runForEach((chunk) =>
- Ref.modify(remainder, (current) => {
- const combined = current + chunk;
- const lines = combined.split("\n");
- const nextRemainder = lines.pop() ?? "";
- return [lines.map((line) => line.replace(/\r$/, "")), nextRemainder] as const;
+ Effect.sync(() => {
+ const lines: Array<string> = [];
+ let start = 0;
+ for (
+ let newline = chunk.indexOf("\n");
+ newline !== -1;
+ newline = chunk.indexOf("\n", start)
+ ) {
+ remainder.push(chunk.slice(start, newline));
+ lines.push(remainder.join("").replace(/\r$/, ""));
+ remainder.length = 0;
+ start = newline + 1;
+ }
+ // Keep unfinished lines in fragments so each chunk is scanned only once.
+ if (start < chunk.length) {
+ remainder.push(chunk.slice(start));
+ }
+ return lines;
}).pipe(Effect.flatMap((lines) => Effect.forEach(lines, handleLine, { discard: true }))),
),
Effect.matchEffect({
@@ -414,8 +427,12 @@ export const makeCodexAppServerPatchedProtocol = Effect.fn("makeCodexAppServerPa
Effect.succeed(normalizeIncomingError(error, "read-input-stream")),
),
onSuccess: () =>
- Ref.get(remainder).pipe(
- Effect.flatMap((line) => (line.trim().length === 0 ? Effect.void : handleLine(line))),
+ Effect.sync(() => {
+ const line = remainder.join("");
+ remainder.length = 0;
+ return line;
+ }).pipe(
+ Effect.flatMap(handleLine),
Effect.matchEffect({
onFailure: (error) => handleTermination(() => Effect.succeed(error)),
onSuccess: () =>
diff --git a/packages/effect-codex-app-server/src/schema.test.ts b/packages/effect-codex-app-server/src/schema.test.ts
new file mode 100644
index 000000000..ff373afeb
--- /dev/null
+++ b/packages/effect-codex-app-server/src/schema.test.ts
@@ -0,0 +1,174 @@
+import { assert, it } from "@effect/vitest";
+import * as Schema from "effect/Schema";
+
+import * as CodexSchema from "./schema.ts";
+
+const isGetAccountResponse = Schema.is(CodexSchema.V2GetAccountResponse);
+const isThreadReadResponse = Schema.is(CodexSchema.V2ThreadReadResponse);
+const isThreadResumeResponse = Schema.is(CodexSchema.V2ThreadResumeResponse);
+const isThreadRollbackResponse = Schema.is(CodexSchema.V2ThreadRollbackResponse);
+const isThreadForkResponse = Schema.is(CodexSchema.V2ThreadForkResponse);
+const isThreadListResponse = Schema.is(CodexSchema.V2ThreadListResponse);
+const isTurnCompletedNotification = Schema.is(CodexSchema.V2TurnCompletedNotification);
+const isServerCollabTool = Schema.is(CodexSchema.ServerNotification__CollabAgentTool);
+const isResumeCollabTool = Schema.is(CodexSchema.V2ThreadResumeResponse__CollabAgentTool);
+const isServerCollabStatus = Schema.is(CodexSchema.ServerNotification__CollabAgentToolCallStatus);
+const isResumeCollabStatus = Schema.is(
+ CodexSchema.V2ThreadResumeResponse__CollabAgentToolCallStatus,
+);
+const decodeThreadResumeResponse = Schema.decodeUnknownSync(CodexSchema.V2ThreadResumeResponse);
+const isSubAgentActivityKindCompleted = [
+ Schema.is(CodexSchema.ServerNotification__SubAgentActivityKind),
+ Schema.is(CodexSchema.V2ItemStartedNotification__SubAgentActivityKind),
+ Schema.is(CodexSchema.V2ItemCompletedNotification__SubAgentActivityKind),
+ Schema.is(CodexSchema.V2ThreadReadResponse__SubAgentActivityKind),
+ Schema.is(CodexSchema.V2ThreadResumeResponse__SubAgentActivityKind),
+];
+
+it("accepts Codex 0.150 multi-agent values", () => {
+ for (const isKind of isSubAgentActivityKindCompleted) {
+ assert.equal(isKind("completed"), true);
+ }
+
+ for (const tool of ["sendMessage", "followupTask", "interruptAgent", "listAgents"]) {
+ assert.equal(isServerCollabTool(tool), true);
+ assert.equal(isResumeCollabTool(tool), true);
+ }
+
+ assert.equal(isServerCollabStatus("interrupted"), true);
+ assert.equal(isResumeCollabStatus("interrupted"), true);
+
+ const resumeResponse = {
+ approvalPolicy: "never",
+ approvalsReviewer: "user",
+ cwd: "/tmp/project",
+ model: "gpt-5.6-sol",
+ modelProvider: "openai",
+ sandbox: { type: "dangerFullAccess" },
+ thread: {
+ cliVersion: "0.150.0",
+ createdAt: 0,
+ cwd: "/tmp/project",
+ ephemeral: false,
+ id: "root-thread",
+ modelProvider: "openai",
+ preview: "",
+ sessionId: "session-1",
+ source: "cli",
+ status: { type: "idle" },
+ turns: [
+ {
+ id: "turn-1",
+ status: "completed",
+ items: [
+ {
+ agentsStates: {},
+ id: "item-1",
+ receiverThreadIds: ["child-thread"],
+ senderThreadId: "root-thread",
+ status: "interrupted",
+ tool: "followupTask",
+ type: "collabAgentToolCall",
+ },
+ ],
+ },
+ ],
+ updatedAt: 0,
+ },
+ };
+
+ assert.equal(isThreadResumeResponse(resumeResponse), true);
+});
+
+it("accepts Codex 0.150 account plan values", () => {
+ const planTypes = [
+ "self_serve_business_prolite",
+ "ent26",
+ "enterprise_cbp_automation",
+ "edu_plus",
+ "edu_pro",
+ ];
+
+ for (const planType of planTypes) {
+ const accountResponse = {
+ account: {
+ email: "[email protected]",
+ planType,
+ type: "chatgpt",
+ },
+ requiresOpenaiAuth: true,
+ };
+
+ assert.equal(isGetAccountResponse(accountResponse), true);
+ }
+});
+
+const failedThread = (codexErrorInfo: string, message: string) => ({
+ cliVersion: "0.150.0",
+ createdAt: 0,
+ cwd: "/tmp/project",
+ ephemeral: false,
+ id: "thread-1",
+ modelProvider: "openai",
+ preview: "",
+ sessionId: "session-1",
+ source: "cli",
+ status: { type: "idle" },
+ turns: [
+ {
+ error: {
+ codexErrorInfo,
+ message,
+ },
+ id: "turn-1",
+ items: [],
+ status: "failed",
+ },
+ ],
+ updatedAt: 0,
+});
+
+const resumeLikeResponse = (thread: ReturnType<typeof failedThread>) => ({
+ approvalPolicy: "never",
+ approvalsReviewer: "user",
+ cwd: "/tmp/project",
+ model: "gpt-5.6-sol",
+ modelProvider: "openai",
+ sandbox: { type: "dangerFullAccess" },
+ thread,
+});
+
+it("accepts Codex rate limit errors for thread responses", () => {
+ const thread = failedThread("rateLimitExceeded", "Rate limit exceeded");
+ assert.equal(isThreadReadResponse({ thread }), true);
+ assert.equal(isThreadResumeResponse(resumeLikeResponse(thread)), true);
+ assert.equal(isThreadRollbackResponse({ thread }), true);
+ assert.equal(isThreadListResponse({ data: [thread] }), true);
+});
+
+it("accepts Codex misalignment policy errors for thread responses", () => {
+ const thread = failedThread("misalignmentPolicyViolation", "Misalignment policy violation");
+ const resumeResponse = resumeLikeResponse(thread);
+ assert.equal(isThreadReadResponse({ thread }), true);
+ assert.equal(isThreadResumeResponse(resumeResponse), true);
+ assert.equal(isThreadRollbackResponse({ thread }), true);
+ assert.equal(isThreadForkResponse(resumeResponse), true);
+ assert.equal(isThreadListResponse({ data: [thread] }), true);
+ const decodedResume = decodeThreadResumeResponse(resumeResponse);
+ assert.equal(decodedResume.thread.turns[0]?.error?.codexErrorInfo, "misalignmentPolicyViolation");
+ assert.equal(
+ isTurnCompletedNotification({
+ threadId: "thread-1",
+ turn: {
+ error: {
+ codexErrorInfo: "misalignmentPolicyViolation",
+ message: "Misalignment policy violation",
+ },
+ id: "turn-1",
+ items: [],
+ status: "failed",
+ },
+ }),
+ true,
+ );
+});