@janole/ai-sdk-provider-codex-asp 0.4.1 → 0.4.3
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 +26 -3
- package/dist/index.cjs +29 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +113 -24
- package/dist/index.d.ts +113 -24
- package/dist/index.js +29 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,10 +15,20 @@ type JsonValue = number | string | boolean | Array<JsonValue> | {
|
|
|
15
15
|
[key in string]?: JsonValue;
|
|
16
16
|
} | null;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Configures who approval requests are routed to for review. Examples
|
|
20
|
+
* include sandbox escapes, blocked network access, MCP approval prompts, and
|
|
21
|
+
* ARC escalations. Defaults to `user`. `guardian_subagent` uses a carefully
|
|
22
|
+
* prompted subagent to gather relevant context and apply a risk-based
|
|
23
|
+
* decision framework before approving or denying the request.
|
|
24
|
+
*/
|
|
25
|
+
type ApprovalsReviewer = "user" | "guardian_subagent";
|
|
26
|
+
|
|
18
27
|
type AskForApproval = "untrusted" | "on-failure" | "on-request" | {
|
|
19
|
-
"
|
|
28
|
+
"granular": {
|
|
20
29
|
sandbox_approval: boolean;
|
|
21
30
|
rules: boolean;
|
|
31
|
+
skill_approval: boolean;
|
|
22
32
|
request_permissions: boolean;
|
|
23
33
|
mcp_elicitations: boolean;
|
|
24
34
|
};
|
|
@@ -63,13 +73,18 @@ type MacOsAutomationPermission = "none" | "all" | {
|
|
|
63
73
|
"bundle_ids": Array<string>;
|
|
64
74
|
};
|
|
65
75
|
|
|
76
|
+
type MacOsContactsPermission = "none" | "read_only" | "read_write";
|
|
77
|
+
|
|
66
78
|
type MacOsPreferencesPermission = "none" | "read_only" | "read_write";
|
|
67
79
|
|
|
68
80
|
type AdditionalMacOsPermissions = {
|
|
69
81
|
preferences: MacOsPreferencesPermission;
|
|
70
82
|
automations: MacOsAutomationPermission;
|
|
83
|
+
launchServices: boolean;
|
|
71
84
|
accessibility: boolean;
|
|
72
85
|
calendar: boolean;
|
|
86
|
+
reminders: boolean;
|
|
87
|
+
contacts: MacOsContactsPermission;
|
|
73
88
|
};
|
|
74
89
|
|
|
75
90
|
type AdditionalNetworkPermissions = {
|
|
@@ -231,7 +246,12 @@ type SandboxPolicy = {
|
|
|
231
246
|
*/
|
|
232
247
|
type MessagePhase = "commentary" | "final_answer";
|
|
233
248
|
|
|
234
|
-
|
|
249
|
+
/**
|
|
250
|
+
* See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning
|
|
251
|
+
*/
|
|
252
|
+
type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
253
|
+
|
|
254
|
+
type CollabAgentStatus = "pendingInit" | "running" | "interrupted" | "completed" | "errored" | "shutdown" | "notFound";
|
|
235
255
|
|
|
236
256
|
type CollabAgentState = {
|
|
237
257
|
status: CollabAgentStatus;
|
|
@@ -242,6 +262,8 @@ type CollabAgentTool = "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "cl
|
|
|
242
262
|
|
|
243
263
|
type CollabAgentToolCallStatus = "inProgress" | "completed" | "failed";
|
|
244
264
|
|
|
265
|
+
type CommandExecutionSource = "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
|
|
266
|
+
|
|
245
267
|
type CommandExecutionStatus = "inProgress" | "completed" | "failed" | "declined";
|
|
246
268
|
|
|
247
269
|
type DynamicToolCallOutputContentItem = {
|
|
@@ -269,6 +291,11 @@ type FileUpdateChange = {
|
|
|
269
291
|
diff: string;
|
|
270
292
|
};
|
|
271
293
|
|
|
294
|
+
type HookPromptFragment = {
|
|
295
|
+
text: string;
|
|
296
|
+
hookRunId: string;
|
|
297
|
+
};
|
|
298
|
+
|
|
272
299
|
type McpToolCallError = {
|
|
273
300
|
message: string;
|
|
274
301
|
};
|
|
@@ -280,6 +307,18 @@ type McpToolCallResult = {
|
|
|
280
307
|
|
|
281
308
|
type McpToolCallStatus = "inProgress" | "completed" | "failed";
|
|
282
309
|
|
|
310
|
+
type MemoryCitationEntry = {
|
|
311
|
+
path: string;
|
|
312
|
+
lineStart: number;
|
|
313
|
+
lineEnd: number;
|
|
314
|
+
note: string;
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
type MemoryCitation = {
|
|
318
|
+
entries: Array<MemoryCitationEntry>;
|
|
319
|
+
threadIds: Array<string>;
|
|
320
|
+
};
|
|
321
|
+
|
|
283
322
|
type PatchApplyStatus = "inProgress" | "completed" | "failed" | "declined";
|
|
284
323
|
|
|
285
324
|
type ByteRange = {
|
|
@@ -340,11 +379,16 @@ type ThreadItem = {
|
|
|
340
379
|
"type": "userMessage";
|
|
341
380
|
id: string;
|
|
342
381
|
content: Array<UserInput>;
|
|
382
|
+
} | {
|
|
383
|
+
"type": "hookPrompt";
|
|
384
|
+
id: string;
|
|
385
|
+
fragments: Array<HookPromptFragment>;
|
|
343
386
|
} | {
|
|
344
387
|
"type": "agentMessage";
|
|
345
388
|
id: string;
|
|
346
389
|
text: string;
|
|
347
390
|
phase: MessagePhase | null;
|
|
391
|
+
memoryCitation: MemoryCitation | null;
|
|
348
392
|
} | {
|
|
349
393
|
"type": "plan";
|
|
350
394
|
id: string;
|
|
@@ -369,6 +413,7 @@ type ThreadItem = {
|
|
|
369
413
|
* Identifier for the underlying PTY process (when available).
|
|
370
414
|
*/
|
|
371
415
|
processId: string | null;
|
|
416
|
+
source: CommandExecutionSource;
|
|
372
417
|
status: CommandExecutionStatus;
|
|
373
418
|
/**
|
|
374
419
|
* A best-effort parsing of the command to understand the action(s) it will perform.
|
|
@@ -445,6 +490,14 @@ type ThreadItem = {
|
|
|
445
490
|
* Prompt text sent as part of the collab tool call, when available.
|
|
446
491
|
*/
|
|
447
492
|
prompt: string | null;
|
|
493
|
+
/**
|
|
494
|
+
* Model requested for the spawned agent, when applicable.
|
|
495
|
+
*/
|
|
496
|
+
model: string | null;
|
|
497
|
+
/**
|
|
498
|
+
* Reasoning effort requested for the spawned agent, when applicable.
|
|
499
|
+
*/
|
|
500
|
+
reasoningEffort: ReasoningEffort | null;
|
|
448
501
|
/**
|
|
449
502
|
* Last known status of the target agents, when available.
|
|
450
503
|
*/
|
|
@@ -466,6 +519,7 @@ type ThreadItem = {
|
|
|
466
519
|
status: string;
|
|
467
520
|
revisedPrompt: string | null;
|
|
468
521
|
result: string;
|
|
522
|
+
savedPath?: string;
|
|
469
523
|
} | {
|
|
470
524
|
"type": "enteredReviewMode";
|
|
471
525
|
id: string;
|
|
@@ -509,17 +563,6 @@ type FunctionCallOutputContentItem = {
|
|
|
509
563
|
|
|
510
564
|
type FunctionCallOutputBody = string | Array<FunctionCallOutputContentItem>;
|
|
511
565
|
|
|
512
|
-
/**
|
|
513
|
-
* The payload we send back to OpenAI when reporting a tool call result.
|
|
514
|
-
*
|
|
515
|
-
* `body` serializes directly as the wire value for `function_call_output.output`.
|
|
516
|
-
* `success` remains internal metadata for downstream handling.
|
|
517
|
-
*/
|
|
518
|
-
type FunctionCallOutputPayload = {
|
|
519
|
-
body: FunctionCallOutputBody;
|
|
520
|
-
success: boolean | null;
|
|
521
|
-
};
|
|
522
|
-
|
|
523
566
|
/**
|
|
524
567
|
* Details of a ghost commit created from a repository state.
|
|
525
568
|
*/
|
|
@@ -596,12 +639,19 @@ type ResponseItem = {
|
|
|
596
639
|
} | {
|
|
597
640
|
"type": "function_call";
|
|
598
641
|
name: string;
|
|
642
|
+
namespace?: string;
|
|
599
643
|
arguments: string;
|
|
600
644
|
call_id: string;
|
|
645
|
+
} | {
|
|
646
|
+
"type": "tool_search_call";
|
|
647
|
+
call_id: string | null;
|
|
648
|
+
status?: string;
|
|
649
|
+
execution: string;
|
|
650
|
+
arguments: unknown;
|
|
601
651
|
} | {
|
|
602
652
|
"type": "function_call_output";
|
|
603
653
|
call_id: string;
|
|
604
|
-
output:
|
|
654
|
+
output: FunctionCallOutputBody;
|
|
605
655
|
} | {
|
|
606
656
|
"type": "custom_tool_call";
|
|
607
657
|
status?: string;
|
|
@@ -611,7 +661,14 @@ type ResponseItem = {
|
|
|
611
661
|
} | {
|
|
612
662
|
"type": "custom_tool_call_output";
|
|
613
663
|
call_id: string;
|
|
614
|
-
|
|
664
|
+
name?: string;
|
|
665
|
+
output: FunctionCallOutputBody;
|
|
666
|
+
} | {
|
|
667
|
+
"type": "tool_search_output";
|
|
668
|
+
call_id: string | null;
|
|
669
|
+
status: string;
|
|
670
|
+
execution: string;
|
|
671
|
+
tools: unknown[];
|
|
615
672
|
} | {
|
|
616
673
|
"type": "web_search_call";
|
|
617
674
|
status?: string;
|
|
@@ -666,6 +723,11 @@ type ThreadResumeParams = {
|
|
|
666
723
|
serviceTier?: ServiceTier | null | null;
|
|
667
724
|
cwd?: string | null;
|
|
668
725
|
approvalPolicy?: AskForApproval | null;
|
|
726
|
+
/**
|
|
727
|
+
* Override where approval requests are routed for review on this thread
|
|
728
|
+
* and subsequent turns.
|
|
729
|
+
*/
|
|
730
|
+
approvalsReviewer?: ApprovalsReviewer | null;
|
|
669
731
|
sandbox?: SandboxMode | null;
|
|
670
732
|
config?: {
|
|
671
733
|
[key in string]?: JsonValue;
|
|
@@ -680,23 +742,21 @@ type ThreadResumeParams = {
|
|
|
680
742
|
persistExtendedHistory: boolean;
|
|
681
743
|
};
|
|
682
744
|
|
|
683
|
-
/**
|
|
684
|
-
* See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning
|
|
685
|
-
*/
|
|
686
|
-
type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
687
|
-
|
|
688
745
|
type GitInfo = {
|
|
689
746
|
sha: string | null;
|
|
690
747
|
branch: string | null;
|
|
691
748
|
originUrl: string | null;
|
|
692
749
|
};
|
|
693
750
|
|
|
751
|
+
type AgentPath = string;
|
|
752
|
+
|
|
694
753
|
type ThreadId = string;
|
|
695
754
|
|
|
696
755
|
type SubAgentSource = "review" | "compact" | {
|
|
697
756
|
"thread_spawn": {
|
|
698
757
|
parent_thread_id: ThreadId;
|
|
699
758
|
depth: number;
|
|
759
|
+
agent_path: AgentPath | null;
|
|
700
760
|
agent_nickname: string | null;
|
|
701
761
|
agent_role: string | null;
|
|
702
762
|
};
|
|
@@ -705,6 +765,8 @@ type SubAgentSource = "review" | "compact" | {
|
|
|
705
765
|
};
|
|
706
766
|
|
|
707
767
|
type SessionSource = "cli" | "vscode" | "exec" | "appServer" | {
|
|
768
|
+
"custom": string;
|
|
769
|
+
} | {
|
|
708
770
|
"subAgent": SubAgentSource;
|
|
709
771
|
} | "unknown";
|
|
710
772
|
|
|
@@ -721,6 +783,8 @@ type ThreadStatus = {
|
|
|
721
783
|
activeFlags: Array<ThreadActiveFlag>;
|
|
722
784
|
};
|
|
723
785
|
|
|
786
|
+
type NonSteerableTurnKind = "review" | "compact";
|
|
787
|
+
|
|
724
788
|
/**
|
|
725
789
|
* This translation layer make sure that we expose codex error code in camel case.
|
|
726
790
|
*
|
|
@@ -743,6 +807,10 @@ type CodexErrorInfo = "contextWindowExceeded" | "usageLimitExceeded" | "serverOv
|
|
|
743
807
|
"responseTooManyFailedAttempts": {
|
|
744
808
|
httpStatusCode: number | null;
|
|
745
809
|
};
|
|
810
|
+
} | {
|
|
811
|
+
"activeTurnNotSteerable": {
|
|
812
|
+
turnKind: NonSteerableTurnKind;
|
|
813
|
+
};
|
|
746
814
|
} | "other";
|
|
747
815
|
|
|
748
816
|
type TurnError = {
|
|
@@ -842,6 +910,10 @@ type ThreadResumeResponse = {
|
|
|
842
910
|
serviceTier: ServiceTier | null;
|
|
843
911
|
cwd: string;
|
|
844
912
|
approvalPolicy: AskForApproval;
|
|
913
|
+
/**
|
|
914
|
+
* Reviewer currently used for approval requests on this thread.
|
|
915
|
+
*/
|
|
916
|
+
approvalsReviewer: ApprovalsReviewer;
|
|
845
917
|
sandbox: SandboxPolicy;
|
|
846
918
|
reasoningEffort: ReasoningEffort | null;
|
|
847
919
|
};
|
|
@@ -886,6 +958,11 @@ type TurnStartParams = {
|
|
|
886
958
|
* Override the approval policy for this turn and subsequent turns.
|
|
887
959
|
*/
|
|
888
960
|
approvalPolicy?: AskForApproval | null;
|
|
961
|
+
/**
|
|
962
|
+
* Override where approval requests are routed for review on this turn and
|
|
963
|
+
* subsequent turns.
|
|
964
|
+
*/
|
|
965
|
+
approvalsReviewer?: ApprovalsReviewer | null;
|
|
889
966
|
/**
|
|
890
967
|
* Override the sandbox policy for this turn and subsequent turns.
|
|
891
968
|
*/
|
|
@@ -1026,6 +1103,7 @@ interface CodexThreadStartParams {
|
|
|
1026
1103
|
model?: string;
|
|
1027
1104
|
cwd?: string;
|
|
1028
1105
|
approvalPolicy?: AskForApproval;
|
|
1106
|
+
approvalsReviewer?: ApprovalsReviewer;
|
|
1029
1107
|
sandbox?: SandboxMode;
|
|
1030
1108
|
config?: Record<string, JsonValue | undefined>;
|
|
1031
1109
|
dynamicTools?: CodexDynamicToolDefinition[];
|
|
@@ -1366,8 +1444,10 @@ interface TransportContext {
|
|
|
1366
1444
|
interface CodexThreadDefaults {
|
|
1367
1445
|
/** Working directory for the thread. */
|
|
1368
1446
|
cwd?: string;
|
|
1369
|
-
/** Tool-use approval policy — `"never"` | `"on-failure"` | `"on-request"` | `"untrusted"` | `{
|
|
1447
|
+
/** Tool-use approval policy — `"never"` | `"on-failure"` | `"on-request"` | `"untrusted"` | `{ granular: … }`. See {@link AskForApproval}. */
|
|
1370
1448
|
approvalPolicy?: AskForApproval;
|
|
1449
|
+
/** Routes approval requests for the thread to `"user"` or `"guardian_subagent"`. */
|
|
1450
|
+
approvalsReviewer?: ApprovalsReviewer;
|
|
1371
1451
|
/** Sandbox mode — `"read-only"` | `"workspace-write"` | `"danger-full-access"`. See {@link SandboxMode}. */
|
|
1372
1452
|
sandbox?: SandboxMode;
|
|
1373
1453
|
}
|
|
@@ -1377,6 +1457,8 @@ interface CodexTurnDefaults {
|
|
|
1377
1457
|
cwd?: string;
|
|
1378
1458
|
/** Tool-use approval policy for this turn. */
|
|
1379
1459
|
approvalPolicy?: AskForApproval;
|
|
1460
|
+
/** Routes approval requests for this turn to `"user"` or `"guardian_subagent"`. */
|
|
1461
|
+
approvalsReviewer?: ApprovalsReviewer;
|
|
1380
1462
|
/** Fine-grained sandbox policy — `{ type: "dangerFullAccess" }` | `{ type: "readOnly", … }` | `{ type: "workspaceWrite", … }` | `{ type: "externalSandbox", … }`. See {@link SandboxPolicy}. */
|
|
1381
1463
|
sandboxPolicy?: SandboxPolicy;
|
|
1382
1464
|
/** Model to use for this turn (overrides provider-level `defaultModel`). */
|
|
@@ -1394,8 +1476,10 @@ interface CodexTurnDefaults {
|
|
|
1394
1476
|
interface CodexCallOptions {
|
|
1395
1477
|
/** Working directory for this call. Also sent as turn-level `cwd`. */
|
|
1396
1478
|
cwd?: string;
|
|
1397
|
-
/** Tool-use approval policy — `"never"` | `"on-failure"` | `"on-request"` | `"untrusted"` | `{
|
|
1479
|
+
/** Tool-use approval policy — `"never"` | `"on-failure"` | `"on-request"` | `"untrusted"` | `{ granular: … }`. See {@link AskForApproval}. */
|
|
1398
1480
|
approvalPolicy?: AskForApproval;
|
|
1481
|
+
/** Routes approval requests to `"user"` or `"guardian_subagent"`. */
|
|
1482
|
+
approvalsReviewer?: ApprovalsReviewer;
|
|
1399
1483
|
/** Sandbox mode — `"read-only"` | `"workspace-write"` | `"danger-full-access"`. See {@link SandboxMode}. */
|
|
1400
1484
|
sandbox?: SandboxMode;
|
|
1401
1485
|
/** How much effort the model should spend on the response. */
|
|
@@ -1406,6 +1490,11 @@ interface CodexCallOptions {
|
|
|
1406
1490
|
sandboxPolicy?: SandboxPolicy;
|
|
1407
1491
|
/** Controls turn summary generation. */
|
|
1408
1492
|
summary?: "auto" | "concise" | "detailed" | "none";
|
|
1493
|
+
/** Approval callbacks for this call; falls back to provider-level `approvals`. */
|
|
1494
|
+
approvals?: {
|
|
1495
|
+
onCommandApproval?: CommandApprovalHandler;
|
|
1496
|
+
onFileChangeApproval?: FileChangeApprovalHandler;
|
|
1497
|
+
};
|
|
1409
1498
|
}
|
|
1410
1499
|
interface CodexCompactionSettings {
|
|
1411
1500
|
/**
|
|
@@ -1500,7 +1589,7 @@ interface CodexProviderSettings {
|
|
|
1500
1589
|
persistent?: {
|
|
1501
1590
|
/** Number of worker processes to keep in the pool. */
|
|
1502
1591
|
poolSize?: number;
|
|
1503
|
-
/** Time (ms) before an idle worker is shut down. */
|
|
1592
|
+
/** Time (ms) before an idle worker is shut down. Set to `0` to disable (worker stays alive indefinitely). */
|
|
1504
1593
|
idleTimeoutMs?: number;
|
|
1505
1594
|
/** `"provider"` = pool per provider instance; `"global"` = shared across all instances. */
|
|
1506
1595
|
scope?: "provider" | "global";
|
|
@@ -1752,4 +1841,4 @@ declare class PromptFileResolver {
|
|
|
1752
1841
|
private resolveFresh;
|
|
1753
1842
|
}
|
|
1754
1843
|
|
|
1755
|
-
export { type AgentMessageDeltaNotification, AppServerClient, type AppServerClientSettings, ApprovalsDispatcher, type ApprovalsDispatcherSettings, type AskForApproval, CODEX_PROVIDER_ID, type CodexCallOptions, type CodexCommandApprovalRequest, type CodexDynamicToolDefinition, CodexEventMapper, type CodexEventMapperInput, type CodexEventMapperOptions, type CodexFileChangeApprovalRequest, type CodexInitializeParams, type CodexInitializeResult, type CodexInitializedNotification, CodexLanguageModel, type CodexLanguageModelSettings, type Model as CodexModel, type CodexModelConfig, CodexNotImplementedError, type CodexNotification, type CodexProvider, CodexProviderError, type CodexProviderSettings, type CodexSession, type CodexThreadDefaults, type CodexThreadResumeParams, type CodexThreadResumeResult, type CodexThreadStartParams, type CodexThreadStartResult, type CodexToolCallDeltaNotification, type CodexToolCallFinishedNotification, type CodexToolCallRequestParams, type CodexToolCallResult, type CodexToolCallStartedNotification, type CodexToolResultContentItem, type CodexTransport, type CodexTransportEventMap, type CodexTurnInputImage, type CodexTurnInputItem, type CodexTurnInputLocalImage, type CodexTurnInputMention, type CodexTurnInputSkill, type CodexTurnInputText, type CodexTurnStartParams, type CodexTurnStartResult, CodexWorker, CodexWorkerPool, type CodexWorkerPoolSettings, type CodexWorkerSettings, type CommandApprovalHandler, type CommandExecutionApprovalDecision, type CommandExecutionRequestApprovalParams, type CommandExecutionRequestApprovalResponse, type DynamicToolDefinition, type DynamicToolExecutionContext, type DynamicToolHandler, DynamicToolsDispatcher, type DynamicToolsDispatcherSettings, type FileChangeApprovalDecision, type FileChangeApprovalHandler, type FileChangeRequestApprovalParams, type FileChangeRequestApprovalResponse, type FileWriter, type ItemCompletedNotification, type ItemStartedNotification, JsonRpcError, type JsonRpcErrorResponse, type JsonRpcId, type JsonRpcMessage, type JsonRpcMessageBase, type JsonRpcNotification, type JsonRpcRequest, type JsonRpcResponse, type JsonRpcSuccessResponse, LocalFileWriter, type McpServerConfig, PACKAGE_NAME, PACKAGE_VERSION, type PendingToolCall, PersistentTransport, type PersistentTransportSettings, PromptFileResolver, type SandboxMode, StdioTransport, type StdioTransportSettings, type ThreadItem, type ThreadTokenUsageUpdatedNotification, type TransportContext, type TurnCompletedNotification, type TurnStartedNotification, WebSocketTransport, type WebSocketTransportSettings, codexAppServer, codexCallOptions, codexProviderMetadata, createCodexAppServer, createCodexProvider, mapSystemPrompt, withProviderMetadata };
|
|
1844
|
+
export { type AgentMessageDeltaNotification, AppServerClient, type AppServerClientSettings, ApprovalsDispatcher, type ApprovalsDispatcherSettings, type ApprovalsReviewer, type AskForApproval, CODEX_PROVIDER_ID, type CodexCallOptions, type CodexCommandApprovalRequest, type CodexDynamicToolDefinition, CodexEventMapper, type CodexEventMapperInput, type CodexEventMapperOptions, type CodexFileChangeApprovalRequest, type CodexInitializeParams, type CodexInitializeResult, type CodexInitializedNotification, CodexLanguageModel, type CodexLanguageModelSettings, type Model as CodexModel, type CodexModelConfig, CodexNotImplementedError, type CodexNotification, type CodexProvider, CodexProviderError, type CodexProviderSettings, type CodexSession, type CodexThreadDefaults, type CodexThreadResumeParams, type CodexThreadResumeResult, type CodexThreadStartParams, type CodexThreadStartResult, type CodexToolCallDeltaNotification, type CodexToolCallFinishedNotification, type CodexToolCallRequestParams, type CodexToolCallResult, type CodexToolCallStartedNotification, type CodexToolResultContentItem, type CodexTransport, type CodexTransportEventMap, type CodexTurnInputImage, type CodexTurnInputItem, type CodexTurnInputLocalImage, type CodexTurnInputMention, type CodexTurnInputSkill, type CodexTurnInputText, type CodexTurnStartParams, type CodexTurnStartResult, CodexWorker, CodexWorkerPool, type CodexWorkerPoolSettings, type CodexWorkerSettings, type CommandApprovalHandler, type CommandExecutionApprovalDecision, type CommandExecutionRequestApprovalParams, type CommandExecutionRequestApprovalResponse, type DynamicToolDefinition, type DynamicToolExecutionContext, type DynamicToolHandler, DynamicToolsDispatcher, type DynamicToolsDispatcherSettings, type FileChangeApprovalDecision, type FileChangeApprovalHandler, type FileChangeRequestApprovalParams, type FileChangeRequestApprovalResponse, type FileWriter, type ItemCompletedNotification, type ItemStartedNotification, JsonRpcError, type JsonRpcErrorResponse, type JsonRpcId, type JsonRpcMessage, type JsonRpcMessageBase, type JsonRpcNotification, type JsonRpcRequest, type JsonRpcResponse, type JsonRpcSuccessResponse, LocalFileWriter, type McpServerConfig, PACKAGE_NAME, PACKAGE_VERSION, type PendingToolCall, PersistentTransport, type PersistentTransportSettings, PromptFileResolver, type SandboxMode, StdioTransport, type StdioTransportSettings, type ThreadItem, type ThreadTokenUsageUpdatedNotification, type TransportContext, type TurnCompletedNotification, type TurnStartedNotification, WebSocketTransport, type WebSocketTransportSettings, codexAppServer, codexCallOptions, codexProviderMetadata, createCodexAppServer, createCodexProvider, mapSystemPrompt, withProviderMetadata };
|
package/dist/index.js
CHANGED
|
@@ -933,7 +933,7 @@ var DynamicToolsDispatcher = class {
|
|
|
933
933
|
// package.json
|
|
934
934
|
var package_default = {
|
|
935
935
|
name: "@janole/ai-sdk-provider-codex-asp",
|
|
936
|
-
version: "0.4.
|
|
936
|
+
version: "0.4.3"};
|
|
937
937
|
|
|
938
938
|
// src/package-info.ts
|
|
939
939
|
var PACKAGE_NAME = package_default.name;
|
|
@@ -1767,6 +1767,12 @@ function sdkToolsToCodexDynamicTools(tools) {
|
|
|
1767
1767
|
inputSchema: t.inputSchema
|
|
1768
1768
|
}));
|
|
1769
1769
|
}
|
|
1770
|
+
function resolveApprovalHandlers(providerSettings, callOptions) {
|
|
1771
|
+
return stripUndefined({
|
|
1772
|
+
onCommandApproval: callOptions?.approvals?.onCommandApproval ?? providerSettings.approvals?.onCommandApproval,
|
|
1773
|
+
onFileChangeApproval: callOptions?.approvals?.onFileChangeApproval ?? providerSettings.approvals?.onFileChangeApproval
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1770
1776
|
function isPassThroughContentPart(part) {
|
|
1771
1777
|
switch (part.type) {
|
|
1772
1778
|
case "tool-call":
|
|
@@ -1922,6 +1928,8 @@ var CodexLanguageModel = class {
|
|
|
1922
1928
|
let activeThreadId;
|
|
1923
1929
|
let activeTurnId;
|
|
1924
1930
|
let session;
|
|
1931
|
+
let detachApprovals;
|
|
1932
|
+
let detachDynamicTools;
|
|
1925
1933
|
const interruptTimeoutMs = this.config.providerSettings.interruptTimeoutMs ?? 1e4;
|
|
1926
1934
|
const interruptTurnIfPossible = async () => {
|
|
1927
1935
|
if (!activeThreadId || !activeTurnId) {
|
|
@@ -1948,6 +1956,10 @@ var CodexLanguageModel = class {
|
|
|
1948
1956
|
try {
|
|
1949
1957
|
controller.close();
|
|
1950
1958
|
} finally {
|
|
1959
|
+
detachDynamicTools?.();
|
|
1960
|
+
detachDynamicTools = void 0;
|
|
1961
|
+
detachApprovals?.();
|
|
1962
|
+
detachApprovals = void 0;
|
|
1951
1963
|
await fileResolver.cleanup();
|
|
1952
1964
|
await client.disconnect();
|
|
1953
1965
|
}
|
|
@@ -1961,6 +1973,10 @@ var CodexLanguageModel = class {
|
|
|
1961
1973
|
try {
|
|
1962
1974
|
controller.close();
|
|
1963
1975
|
} finally {
|
|
1976
|
+
detachDynamicTools?.();
|
|
1977
|
+
detachDynamicTools = void 0;
|
|
1978
|
+
detachApprovals?.();
|
|
1979
|
+
detachApprovals = void 0;
|
|
1964
1980
|
await fileResolver.cleanup();
|
|
1965
1981
|
await client.disconnect();
|
|
1966
1982
|
}
|
|
@@ -2022,11 +2038,10 @@ var CodexLanguageModel = class {
|
|
|
2022
2038
|
pendingToolCall.threadId,
|
|
2023
2039
|
closeSuccessfully
|
|
2024
2040
|
);
|
|
2025
|
-
const approvalsDispatcher2 = new ApprovalsDispatcher(
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
approvalsDispatcher2.attach(client);
|
|
2041
|
+
const approvalsDispatcher2 = new ApprovalsDispatcher(
|
|
2042
|
+
resolveApprovalHandlers(this.config.providerSettings, callOptions)
|
|
2043
|
+
);
|
|
2044
|
+
detachApprovals = approvalsDispatcher2.attach(client);
|
|
2030
2045
|
const result = toolResult ?? {
|
|
2031
2046
|
success: false,
|
|
2032
2047
|
contentItems: [{
|
|
@@ -2054,13 +2069,12 @@ var CodexLanguageModel = class {
|
|
|
2054
2069
|
timeoutMs: this.config.providerSettings.toolTimeoutMs,
|
|
2055
2070
|
onDebugEvent: toolLogger
|
|
2056
2071
|
}));
|
|
2057
|
-
dispatcher.attach(client);
|
|
2072
|
+
detachDynamicTools = dispatcher.attach(client);
|
|
2058
2073
|
}
|
|
2059
|
-
const approvalsDispatcher = new ApprovalsDispatcher(
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
approvalsDispatcher.attach(client);
|
|
2074
|
+
const approvalsDispatcher = new ApprovalsDispatcher(
|
|
2075
|
+
resolveApprovalHandlers(this.config.providerSettings, callOptions)
|
|
2076
|
+
);
|
|
2077
|
+
detachApprovals = approvalsDispatcher.attach(client);
|
|
2064
2078
|
client.onAnyNotification((method, params) => {
|
|
2065
2079
|
const parts = mapper.map({ method, params });
|
|
2066
2080
|
const mappedTurnId = mapper.getTurnId();
|
|
@@ -2114,6 +2128,7 @@ var CodexLanguageModel = class {
|
|
|
2114
2128
|
developerInstructions,
|
|
2115
2129
|
cwd: callOptions?.cwd ?? this.config.providerSettings.defaultThreadSettings?.cwd,
|
|
2116
2130
|
approvalPolicy: callOptions?.approvalPolicy ?? this.config.providerSettings.defaultThreadSettings?.approvalPolicy,
|
|
2131
|
+
approvalsReviewer: callOptions?.approvalsReviewer ?? this.config.providerSettings.defaultThreadSettings?.approvalsReviewer,
|
|
2117
2132
|
sandbox: callOptions?.sandbox ?? this.config.providerSettings.defaultThreadSettings?.sandbox,
|
|
2118
2133
|
model: callOptions?.model ?? this.config.providerSettings.defaultModel
|
|
2119
2134
|
});
|
|
@@ -2177,6 +2192,7 @@ var CodexLanguageModel = class {
|
|
|
2177
2192
|
config,
|
|
2178
2193
|
cwd: callOptions?.cwd ?? this.config.providerSettings.defaultThreadSettings?.cwd,
|
|
2179
2194
|
approvalPolicy: callOptions?.approvalPolicy ?? this.config.providerSettings.defaultThreadSettings?.approvalPolicy,
|
|
2195
|
+
approvalsReviewer: callOptions?.approvalsReviewer ?? this.config.providerSettings.defaultThreadSettings?.approvalsReviewer,
|
|
2180
2196
|
sandbox: callOptions?.sandbox ?? this.config.providerSettings.defaultThreadSettings?.sandbox
|
|
2181
2197
|
});
|
|
2182
2198
|
debugLog?.("outbound", "thread/start", threadStartParams);
|
|
@@ -2203,6 +2219,7 @@ var CodexLanguageModel = class {
|
|
|
2203
2219
|
input: turnInput,
|
|
2204
2220
|
cwd: callOptions?.cwd ?? this.config.providerSettings.defaultTurnSettings?.cwd,
|
|
2205
2221
|
approvalPolicy: callOptions?.approvalPolicy ?? this.config.providerSettings.defaultTurnSettings?.approvalPolicy,
|
|
2222
|
+
approvalsReviewer: callOptions?.approvalsReviewer ?? this.config.providerSettings.defaultTurnSettings?.approvalsReviewer,
|
|
2206
2223
|
sandboxPolicy: callOptions?.sandboxPolicy ?? this.config.providerSettings.defaultTurnSettings?.sandboxPolicy,
|
|
2207
2224
|
model: callOptions?.model ?? this.config.providerSettings.defaultTurnSettings?.model,
|
|
2208
2225
|
effort: callOptions?.effort ?? this.config.providerSettings.defaultTurnSettings?.effort,
|