ai-sdk-provider-codex-cli 1.2.1 → 1.2.2
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.
- package/README.md +1 -1
- package/dist/index.cjs +44 -0
- package/dist/index.d.cts +35 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +44 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -363,7 +363,7 @@ See [docs/ai-sdk-v5/configuration.md](docs/ai-sdk-v5/configuration.md) for the f
|
|
|
363
363
|
- `minCodexVersion`: minimum supported app-server version (semver)
|
|
364
364
|
- `includeRawChunks`: emit raw JSON-RPC notifications as `raw` stream parts by default
|
|
365
365
|
- `serverRequests`: typed handlers for server-initiated JSON-RPC requests
|
|
366
|
-
- `autoApprove`: default approval response when no custom handler is provided
|
|
366
|
+
- `autoApprove`: default approval response when no custom handler is provided (covers command execution, file changes, skills, and MCP tool call approvals via `mcpServer/elicitation/request` on Codex >= 0.139)
|
|
367
367
|
- `persistExtendedHistory`: request extended thread history persistence
|
|
368
368
|
- `threadMode`: `stateless` (default) or `persistent` automatic thread reuse
|
|
369
369
|
- `resume`: shorthand to resume an existing thread id
|
package/dist/index.cjs
CHANGED
|
@@ -203,6 +203,9 @@ var serverRequestsSchema = zod.z.object({
|
|
|
203
203
|
onSkillApproval: zod.z.any().refine((val) => val === void 0 || typeof val === "function", {
|
|
204
204
|
message: "onSkillApproval must be a function"
|
|
205
205
|
}).optional(),
|
|
206
|
+
onMcpElicitation: zod.z.any().refine((val) => val === void 0 || typeof val === "function", {
|
|
207
|
+
message: "onMcpElicitation must be a function"
|
|
208
|
+
}).optional(),
|
|
206
209
|
onToolRequestUserInput: zod.z.any().refine((val) => val === void 0 || typeof val === "function", {
|
|
207
210
|
message: "onToolRequestUserInput must be a function"
|
|
208
211
|
}).optional(),
|
|
@@ -4385,6 +4388,17 @@ var skillRequestApprovalParamsSchema = zod.z.object({
|
|
|
4385
4388
|
itemId: zod.z.string(),
|
|
4386
4389
|
skillName: zod.z.string()
|
|
4387
4390
|
}).passthrough();
|
|
4391
|
+
var mcpServerElicitationRequestParamsSchema = zod.z.object({
|
|
4392
|
+
threadId: zod.z.string(),
|
|
4393
|
+
turnId: zod.z.string().nullable().optional(),
|
|
4394
|
+
serverName: zod.z.string(),
|
|
4395
|
+
mode: zod.z.string().optional(),
|
|
4396
|
+
message: zod.z.string().optional(),
|
|
4397
|
+
requestedSchema: zod.z.unknown().optional(),
|
|
4398
|
+
url: zod.z.string().optional(),
|
|
4399
|
+
elicitationId: zod.z.string().optional(),
|
|
4400
|
+
_meta: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional()
|
|
4401
|
+
}).passthrough();
|
|
4388
4402
|
var dynamicToolCallParamsSchema = zod.z.object({
|
|
4389
4403
|
threadId: zod.z.string(),
|
|
4390
4404
|
turnId: zod.z.string(),
|
|
@@ -4400,6 +4414,7 @@ var serverRequestParamSchemas = {
|
|
|
4400
4414
|
"item/commandExecution/requestApproval": commandExecutionRequestApprovalParamsSchema,
|
|
4401
4415
|
"item/fileChange/requestApproval": fileChangeRequestApprovalParamsSchema,
|
|
4402
4416
|
"item/tool/requestUserInput": toolRequestUserInputParamsSchema,
|
|
4417
|
+
"mcpServer/elicitation/request": mcpServerElicitationRequestParamsSchema,
|
|
4403
4418
|
"skill/requestApproval": skillRequestApprovalParamsSchema,
|
|
4404
4419
|
"item/tool/call": dynamicToolCallParamsSchema,
|
|
4405
4420
|
"account/chatgptAuthTokens/refresh": chatgptAuthTokensRefreshParamsSchema
|
|
@@ -4423,6 +4438,11 @@ var serverRequestSchema = zod.z.discriminatedUnion("method", [
|
|
|
4423
4438
|
method: zod.z.literal("item/tool/requestUserInput"),
|
|
4424
4439
|
params: toolRequestUserInputParamsSchema
|
|
4425
4440
|
}).passthrough(),
|
|
4441
|
+
zod.z.object({
|
|
4442
|
+
id: jsonRpcIdSchema,
|
|
4443
|
+
method: zod.z.literal("mcpServer/elicitation/request"),
|
|
4444
|
+
params: mcpServerElicitationRequestParamsSchema
|
|
4445
|
+
}).passthrough(),
|
|
4426
4446
|
zod.z.object({
|
|
4427
4447
|
id: jsonRpcIdSchema,
|
|
4428
4448
|
method: zod.z.literal("skill/requestApproval"),
|
|
@@ -5108,6 +5128,30 @@ var AppServerRpcClient = class extends events.EventEmitter {
|
|
|
5108
5128
|
await sendResult({ decision: autoApprove ? "approve" : "decline" });
|
|
5109
5129
|
return;
|
|
5110
5130
|
}
|
|
5131
|
+
case "mcpServer/elicitation/request": {
|
|
5132
|
+
const handled = await runHandler(
|
|
5133
|
+
() => handlers.onMcpElicitation?.(normalized)
|
|
5134
|
+
);
|
|
5135
|
+
if (handled !== void 0) {
|
|
5136
|
+
await sendResult(handled);
|
|
5137
|
+
return;
|
|
5138
|
+
}
|
|
5139
|
+
const fallback = await runHandler(
|
|
5140
|
+
() => handlers.onUnhandled?.(normalized)
|
|
5141
|
+
);
|
|
5142
|
+
if (fallback !== void 0) {
|
|
5143
|
+
await sendResult(fallback);
|
|
5144
|
+
return;
|
|
5145
|
+
}
|
|
5146
|
+
const meta = normalized.params._meta;
|
|
5147
|
+
const isToolCallApproval = meta?.codex_approval_kind === "mcp_tool_call";
|
|
5148
|
+
if (isToolCallApproval && autoApprove) {
|
|
5149
|
+
await sendResult({ action: "accept", content: {} });
|
|
5150
|
+
} else {
|
|
5151
|
+
await sendResult({ action: "decline", content: null });
|
|
5152
|
+
}
|
|
5153
|
+
return;
|
|
5154
|
+
}
|
|
5111
5155
|
case "item/tool/requestUserInput": {
|
|
5112
5156
|
const handled = await runHandler(
|
|
5113
5157
|
() => handlers.onToolRequestUserInput?.(
|
package/dist/index.d.cts
CHANGED
|
@@ -407,6 +407,29 @@ interface ToolRequestUserInputParams {
|
|
|
407
407
|
interface ToolRequestUserInputResponse {
|
|
408
408
|
answers: Record<string, unknown>;
|
|
409
409
|
}
|
|
410
|
+
type McpServerElicitationAction = 'accept' | 'decline' | 'cancel';
|
|
411
|
+
interface McpServerElicitationRequestParams {
|
|
412
|
+
threadId: string;
|
|
413
|
+
/** Nullable: the elicitation may arrive outside of an active turn. */
|
|
414
|
+
turnId?: string | null;
|
|
415
|
+
serverName: string;
|
|
416
|
+
/** 'form' requests carry message/requestedSchema; 'url' requests carry url/elicitationId. */
|
|
417
|
+
mode?: string;
|
|
418
|
+
message?: string;
|
|
419
|
+
requestedSchema?: unknown;
|
|
420
|
+
url?: string;
|
|
421
|
+
elicitationId?: string;
|
|
422
|
+
/**
|
|
423
|
+
* For MCP tool approval elicitations, Codex sets
|
|
424
|
+
* `codex_approval_kind: 'mcp_tool_call'` and may include `persist` hints.
|
|
425
|
+
*/
|
|
426
|
+
_meta?: Record<string, unknown> | null;
|
|
427
|
+
}
|
|
428
|
+
interface McpServerElicitationRequestResponse {
|
|
429
|
+
action: McpServerElicitationAction;
|
|
430
|
+
/** Structured user input for accepted elicitations; null for decline/cancel. */
|
|
431
|
+
content?: Record<string, unknown> | null;
|
|
432
|
+
}
|
|
410
433
|
interface DynamicToolCallParams {
|
|
411
434
|
threadId: string;
|
|
412
435
|
turnId: string;
|
|
@@ -547,6 +570,11 @@ interface AppServerSkillApprovalRequest {
|
|
|
547
570
|
method: 'skill/requestApproval';
|
|
548
571
|
params: SkillRequestApprovalParams;
|
|
549
572
|
}
|
|
573
|
+
interface AppServerMcpElicitationRequest {
|
|
574
|
+
id: JsonRpcId;
|
|
575
|
+
method: 'mcpServer/elicitation/request';
|
|
576
|
+
params: McpServerElicitationRequestParams;
|
|
577
|
+
}
|
|
550
578
|
interface AppServerToolRequestUserInputRequest {
|
|
551
579
|
id: JsonRpcId;
|
|
552
580
|
method: 'item/tool/requestUserInput';
|
|
@@ -580,6 +608,13 @@ interface CodexAppServerRequestHandlers {
|
|
|
580
608
|
onCommandExecutionApproval?: (request: AppServerCommandExecutionApprovalRequest) => Promise<CommandExecutionRequestApprovalResponse | undefined>;
|
|
581
609
|
onFileChangeApproval?: (request: AppServerFileChangeApprovalRequest) => Promise<FileChangeRequestApprovalResponse | undefined>;
|
|
582
610
|
onSkillApproval?: (request: AppServerSkillApprovalRequest) => Promise<SkillRequestApprovalResponse | undefined>;
|
|
611
|
+
/**
|
|
612
|
+
* Handles `mcpServer/elicitation/request` (Codex >= 0.139), which includes
|
|
613
|
+
* MCP tool call approvals (`params._meta.codex_approval_kind === 'mcp_tool_call'`).
|
|
614
|
+
* Built-in default: accept tool call approvals when `autoApprove` is true,
|
|
615
|
+
* decline all other elicitations.
|
|
616
|
+
*/
|
|
617
|
+
onMcpElicitation?: (request: AppServerMcpElicitationRequest) => Promise<McpServerElicitationRequestResponse | undefined>;
|
|
583
618
|
onToolRequestUserInput?: (request: AppServerToolRequestUserInputRequest) => Promise<ToolRequestUserInputResponse | undefined>;
|
|
584
619
|
onDynamicToolCall?: (request: AppServerDynamicToolCallRequest) => Promise<DynamicToolCallResponse | undefined>;
|
|
585
620
|
onAuthRefresh?: (request: AppServerAuthRefreshRequest) => Promise<ChatgptAuthTokensRefreshResponse | undefined>;
|
package/dist/index.d.ts
CHANGED
|
@@ -407,6 +407,29 @@ interface ToolRequestUserInputParams {
|
|
|
407
407
|
interface ToolRequestUserInputResponse {
|
|
408
408
|
answers: Record<string, unknown>;
|
|
409
409
|
}
|
|
410
|
+
type McpServerElicitationAction = 'accept' | 'decline' | 'cancel';
|
|
411
|
+
interface McpServerElicitationRequestParams {
|
|
412
|
+
threadId: string;
|
|
413
|
+
/** Nullable: the elicitation may arrive outside of an active turn. */
|
|
414
|
+
turnId?: string | null;
|
|
415
|
+
serverName: string;
|
|
416
|
+
/** 'form' requests carry message/requestedSchema; 'url' requests carry url/elicitationId. */
|
|
417
|
+
mode?: string;
|
|
418
|
+
message?: string;
|
|
419
|
+
requestedSchema?: unknown;
|
|
420
|
+
url?: string;
|
|
421
|
+
elicitationId?: string;
|
|
422
|
+
/**
|
|
423
|
+
* For MCP tool approval elicitations, Codex sets
|
|
424
|
+
* `codex_approval_kind: 'mcp_tool_call'` and may include `persist` hints.
|
|
425
|
+
*/
|
|
426
|
+
_meta?: Record<string, unknown> | null;
|
|
427
|
+
}
|
|
428
|
+
interface McpServerElicitationRequestResponse {
|
|
429
|
+
action: McpServerElicitationAction;
|
|
430
|
+
/** Structured user input for accepted elicitations; null for decline/cancel. */
|
|
431
|
+
content?: Record<string, unknown> | null;
|
|
432
|
+
}
|
|
410
433
|
interface DynamicToolCallParams {
|
|
411
434
|
threadId: string;
|
|
412
435
|
turnId: string;
|
|
@@ -547,6 +570,11 @@ interface AppServerSkillApprovalRequest {
|
|
|
547
570
|
method: 'skill/requestApproval';
|
|
548
571
|
params: SkillRequestApprovalParams;
|
|
549
572
|
}
|
|
573
|
+
interface AppServerMcpElicitationRequest {
|
|
574
|
+
id: JsonRpcId;
|
|
575
|
+
method: 'mcpServer/elicitation/request';
|
|
576
|
+
params: McpServerElicitationRequestParams;
|
|
577
|
+
}
|
|
550
578
|
interface AppServerToolRequestUserInputRequest {
|
|
551
579
|
id: JsonRpcId;
|
|
552
580
|
method: 'item/tool/requestUserInput';
|
|
@@ -580,6 +608,13 @@ interface CodexAppServerRequestHandlers {
|
|
|
580
608
|
onCommandExecutionApproval?: (request: AppServerCommandExecutionApprovalRequest) => Promise<CommandExecutionRequestApprovalResponse | undefined>;
|
|
581
609
|
onFileChangeApproval?: (request: AppServerFileChangeApprovalRequest) => Promise<FileChangeRequestApprovalResponse | undefined>;
|
|
582
610
|
onSkillApproval?: (request: AppServerSkillApprovalRequest) => Promise<SkillRequestApprovalResponse | undefined>;
|
|
611
|
+
/**
|
|
612
|
+
* Handles `mcpServer/elicitation/request` (Codex >= 0.139), which includes
|
|
613
|
+
* MCP tool call approvals (`params._meta.codex_approval_kind === 'mcp_tool_call'`).
|
|
614
|
+
* Built-in default: accept tool call approvals when `autoApprove` is true,
|
|
615
|
+
* decline all other elicitations.
|
|
616
|
+
*/
|
|
617
|
+
onMcpElicitation?: (request: AppServerMcpElicitationRequest) => Promise<McpServerElicitationRequestResponse | undefined>;
|
|
583
618
|
onToolRequestUserInput?: (request: AppServerToolRequestUserInputRequest) => Promise<ToolRequestUserInputResponse | undefined>;
|
|
584
619
|
onDynamicToolCall?: (request: AppServerDynamicToolCallRequest) => Promise<DynamicToolCallResponse | undefined>;
|
|
585
620
|
onAuthRefresh?: (request: AppServerAuthRefreshRequest) => Promise<ChatgptAuthTokensRefreshResponse | undefined>;
|
package/dist/index.js
CHANGED
|
@@ -195,6 +195,9 @@ var serverRequestsSchema = z.object({
|
|
|
195
195
|
onSkillApproval: z.any().refine((val) => val === void 0 || typeof val === "function", {
|
|
196
196
|
message: "onSkillApproval must be a function"
|
|
197
197
|
}).optional(),
|
|
198
|
+
onMcpElicitation: z.any().refine((val) => val === void 0 || typeof val === "function", {
|
|
199
|
+
message: "onMcpElicitation must be a function"
|
|
200
|
+
}).optional(),
|
|
198
201
|
onToolRequestUserInput: z.any().refine((val) => val === void 0 || typeof val === "function", {
|
|
199
202
|
message: "onToolRequestUserInput must be a function"
|
|
200
203
|
}).optional(),
|
|
@@ -4377,6 +4380,17 @@ var skillRequestApprovalParamsSchema = z.object({
|
|
|
4377
4380
|
itemId: z.string(),
|
|
4378
4381
|
skillName: z.string()
|
|
4379
4382
|
}).passthrough();
|
|
4383
|
+
var mcpServerElicitationRequestParamsSchema = z.object({
|
|
4384
|
+
threadId: z.string(),
|
|
4385
|
+
turnId: z.string().nullable().optional(),
|
|
4386
|
+
serverName: z.string(),
|
|
4387
|
+
mode: z.string().optional(),
|
|
4388
|
+
message: z.string().optional(),
|
|
4389
|
+
requestedSchema: z.unknown().optional(),
|
|
4390
|
+
url: z.string().optional(),
|
|
4391
|
+
elicitationId: z.string().optional(),
|
|
4392
|
+
_meta: z.record(z.string(), z.unknown()).nullable().optional()
|
|
4393
|
+
}).passthrough();
|
|
4380
4394
|
var dynamicToolCallParamsSchema = z.object({
|
|
4381
4395
|
threadId: z.string(),
|
|
4382
4396
|
turnId: z.string(),
|
|
@@ -4392,6 +4406,7 @@ var serverRequestParamSchemas = {
|
|
|
4392
4406
|
"item/commandExecution/requestApproval": commandExecutionRequestApprovalParamsSchema,
|
|
4393
4407
|
"item/fileChange/requestApproval": fileChangeRequestApprovalParamsSchema,
|
|
4394
4408
|
"item/tool/requestUserInput": toolRequestUserInputParamsSchema,
|
|
4409
|
+
"mcpServer/elicitation/request": mcpServerElicitationRequestParamsSchema,
|
|
4395
4410
|
"skill/requestApproval": skillRequestApprovalParamsSchema,
|
|
4396
4411
|
"item/tool/call": dynamicToolCallParamsSchema,
|
|
4397
4412
|
"account/chatgptAuthTokens/refresh": chatgptAuthTokensRefreshParamsSchema
|
|
@@ -4415,6 +4430,11 @@ var serverRequestSchema = z.discriminatedUnion("method", [
|
|
|
4415
4430
|
method: z.literal("item/tool/requestUserInput"),
|
|
4416
4431
|
params: toolRequestUserInputParamsSchema
|
|
4417
4432
|
}).passthrough(),
|
|
4433
|
+
z.object({
|
|
4434
|
+
id: jsonRpcIdSchema,
|
|
4435
|
+
method: z.literal("mcpServer/elicitation/request"),
|
|
4436
|
+
params: mcpServerElicitationRequestParamsSchema
|
|
4437
|
+
}).passthrough(),
|
|
4418
4438
|
z.object({
|
|
4419
4439
|
id: jsonRpcIdSchema,
|
|
4420
4440
|
method: z.literal("skill/requestApproval"),
|
|
@@ -5100,6 +5120,30 @@ var AppServerRpcClient = class extends EventEmitter {
|
|
|
5100
5120
|
await sendResult({ decision: autoApprove ? "approve" : "decline" });
|
|
5101
5121
|
return;
|
|
5102
5122
|
}
|
|
5123
|
+
case "mcpServer/elicitation/request": {
|
|
5124
|
+
const handled = await runHandler(
|
|
5125
|
+
() => handlers.onMcpElicitation?.(normalized)
|
|
5126
|
+
);
|
|
5127
|
+
if (handled !== void 0) {
|
|
5128
|
+
await sendResult(handled);
|
|
5129
|
+
return;
|
|
5130
|
+
}
|
|
5131
|
+
const fallback = await runHandler(
|
|
5132
|
+
() => handlers.onUnhandled?.(normalized)
|
|
5133
|
+
);
|
|
5134
|
+
if (fallback !== void 0) {
|
|
5135
|
+
await sendResult(fallback);
|
|
5136
|
+
return;
|
|
5137
|
+
}
|
|
5138
|
+
const meta = normalized.params._meta;
|
|
5139
|
+
const isToolCallApproval = meta?.codex_approval_kind === "mcp_tool_call";
|
|
5140
|
+
if (isToolCallApproval && autoApprove) {
|
|
5141
|
+
await sendResult({ action: "accept", content: {} });
|
|
5142
|
+
} else {
|
|
5143
|
+
await sendResult({ action: "decline", content: null });
|
|
5144
|
+
}
|
|
5145
|
+
return;
|
|
5146
|
+
}
|
|
5103
5147
|
case "item/tool/requestUserInput": {
|
|
5104
5148
|
const handled = await runHandler(
|
|
5105
5149
|
() => handlers.onToolRequestUserInput?.(
|