@janole/ai-sdk-provider-codex-asp 0.2.2 → 0.2.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/dist/index.d.cts CHANGED
@@ -132,6 +132,10 @@ type CommandExecutionRequestApprovalParams = {
132
132
  * Optional proposed network policy amendments (allow/deny host) for future requests.
133
133
  */
134
134
  proposedNetworkPolicyAmendments?: Array<NetworkPolicyAmendment> | null;
135
+ /**
136
+ * Ordered list of decisions the client may present for this prompt.
137
+ */
138
+ availableDecisions?: Array<CommandExecutionApprovalDecision> | null;
135
139
  };
136
140
 
137
141
  type CommandExecutionRequestApprovalResponse = {
@@ -454,6 +458,16 @@ type CollabAgentToolCallStatus = "inProgress" | "completed" | "failed";
454
458
 
455
459
  type CommandExecutionStatus = "inProgress" | "completed" | "failed" | "declined";
456
460
 
461
+ type DynamicToolCallOutputContentItem = {
462
+ "type": "inputText";
463
+ text: string;
464
+ } | {
465
+ "type": "inputImage";
466
+ imageUrl: string;
467
+ };
468
+
469
+ type DynamicToolCallStatus = "inProgress" | "completed" | "failed";
470
+
457
471
  type PatchChangeKind = {
458
472
  "type": "add";
459
473
  } | {
@@ -606,6 +620,18 @@ type ThreadItem = {
606
620
  * The duration of the MCP tool call in milliseconds.
607
621
  */
608
622
  durationMs: number | null;
623
+ } | {
624
+ "type": "dynamicToolCall";
625
+ id: string;
626
+ tool: string;
627
+ arguments: JsonValue;
628
+ status: DynamicToolCallStatus;
629
+ contentItems: Array<DynamicToolCallOutputContentItem> | null;
630
+ success: boolean | null;
631
+ /**
632
+ * The duration of the dynamic tool call in milliseconds.
633
+ */
634
+ durationMs: number | null;
609
635
  } | {
610
636
  "type": "collabAgentToolCall";
611
637
  /**
@@ -1129,20 +1155,29 @@ interface CodexWorkerPoolSettings {
1129
1155
  transportFactory: () => CodexTransport;
1130
1156
  idleTimeoutMs?: number;
1131
1157
  }
1158
+ interface AcquireOptions {
1159
+ signal?: AbortSignal;
1160
+ }
1132
1161
  declare class CodexWorkerPool {
1133
1162
  private readonly workers;
1134
1163
  private shutdownCalled;
1164
+ private readonly waiters;
1135
1165
  constructor(settings: CodexWorkerPoolSettings);
1136
- acquire(): CodexWorker;
1166
+ acquire(options?: AcquireOptions): Promise<CodexWorker>;
1137
1167
  release(worker: CodexWorker): void;
1138
1168
  shutdown(): Promise<void>;
1169
+ private removeWaiter;
1170
+ /** Remove the abort listener so it doesn't fire after the waiter is already served. */
1171
+ private clearWaiterAbortHandler;
1139
1172
  }
1140
1173
 
1141
1174
  interface PersistentTransportSettings {
1142
1175
  pool: CodexWorkerPool;
1176
+ signal?: AbortSignal;
1143
1177
  }
1144
1178
  declare class PersistentTransport implements CodexTransport {
1145
1179
  private readonly pool;
1180
+ private readonly signal;
1146
1181
  private worker;
1147
1182
  private pendingInitializeId;
1148
1183
  private initializeIntercepted;
@@ -1281,7 +1316,7 @@ interface CodexProviderSettings {
1281
1316
  defaultThreadSettings?: CodexThreadDefaults;
1282
1317
  defaultTurnSettings?: CodexTurnDefaults;
1283
1318
  compaction?: CodexCompactionSettings;
1284
- transportFactory?: () => CodexTransport;
1319
+ transportFactory?: (signal?: AbortSignal) => CodexTransport;
1285
1320
  /** Tools with schema (description + inputSchema) advertised to Codex + local handlers. */
1286
1321
  tools?: Record<string, DynamicToolDefinition>;
1287
1322
  /** Legacy: handler-only tools, not advertised to Codex. Use `tools` for full schema support. */
package/dist/index.d.ts CHANGED
@@ -132,6 +132,10 @@ type CommandExecutionRequestApprovalParams = {
132
132
  * Optional proposed network policy amendments (allow/deny host) for future requests.
133
133
  */
134
134
  proposedNetworkPolicyAmendments?: Array<NetworkPolicyAmendment> | null;
135
+ /**
136
+ * Ordered list of decisions the client may present for this prompt.
137
+ */
138
+ availableDecisions?: Array<CommandExecutionApprovalDecision> | null;
135
139
  };
136
140
 
137
141
  type CommandExecutionRequestApprovalResponse = {
@@ -454,6 +458,16 @@ type CollabAgentToolCallStatus = "inProgress" | "completed" | "failed";
454
458
 
455
459
  type CommandExecutionStatus = "inProgress" | "completed" | "failed" | "declined";
456
460
 
461
+ type DynamicToolCallOutputContentItem = {
462
+ "type": "inputText";
463
+ text: string;
464
+ } | {
465
+ "type": "inputImage";
466
+ imageUrl: string;
467
+ };
468
+
469
+ type DynamicToolCallStatus = "inProgress" | "completed" | "failed";
470
+
457
471
  type PatchChangeKind = {
458
472
  "type": "add";
459
473
  } | {
@@ -606,6 +620,18 @@ type ThreadItem = {
606
620
  * The duration of the MCP tool call in milliseconds.
607
621
  */
608
622
  durationMs: number | null;
623
+ } | {
624
+ "type": "dynamicToolCall";
625
+ id: string;
626
+ tool: string;
627
+ arguments: JsonValue;
628
+ status: DynamicToolCallStatus;
629
+ contentItems: Array<DynamicToolCallOutputContentItem> | null;
630
+ success: boolean | null;
631
+ /**
632
+ * The duration of the dynamic tool call in milliseconds.
633
+ */
634
+ durationMs: number | null;
609
635
  } | {
610
636
  "type": "collabAgentToolCall";
611
637
  /**
@@ -1129,20 +1155,29 @@ interface CodexWorkerPoolSettings {
1129
1155
  transportFactory: () => CodexTransport;
1130
1156
  idleTimeoutMs?: number;
1131
1157
  }
1158
+ interface AcquireOptions {
1159
+ signal?: AbortSignal;
1160
+ }
1132
1161
  declare class CodexWorkerPool {
1133
1162
  private readonly workers;
1134
1163
  private shutdownCalled;
1164
+ private readonly waiters;
1135
1165
  constructor(settings: CodexWorkerPoolSettings);
1136
- acquire(): CodexWorker;
1166
+ acquire(options?: AcquireOptions): Promise<CodexWorker>;
1137
1167
  release(worker: CodexWorker): void;
1138
1168
  shutdown(): Promise<void>;
1169
+ private removeWaiter;
1170
+ /** Remove the abort listener so it doesn't fire after the waiter is already served. */
1171
+ private clearWaiterAbortHandler;
1139
1172
  }
1140
1173
 
1141
1174
  interface PersistentTransportSettings {
1142
1175
  pool: CodexWorkerPool;
1176
+ signal?: AbortSignal;
1143
1177
  }
1144
1178
  declare class PersistentTransport implements CodexTransport {
1145
1179
  private readonly pool;
1180
+ private readonly signal;
1146
1181
  private worker;
1147
1182
  private pendingInitializeId;
1148
1183
  private initializeIntercepted;
@@ -1281,7 +1316,7 @@ interface CodexProviderSettings {
1281
1316
  defaultThreadSettings?: CodexThreadDefaults;
1282
1317
  defaultTurnSettings?: CodexTurnDefaults;
1283
1318
  compaction?: CodexCompactionSettings;
1284
- transportFactory?: () => CodexTransport;
1319
+ transportFactory?: (signal?: AbortSignal) => CodexTransport;
1285
1320
  /** Tools with schema (description + inputSchema) advertised to Codex + local handlers. */
1286
1321
  tools?: Record<string, DynamicToolDefinition>;
1287
1322
  /** Legacy: handler-only tools, not advertised to Codex. Use `tools` for full schema support. */
package/dist/index.js CHANGED
@@ -272,6 +272,7 @@ var AppServerClient = class {
272
272
  // src/client/transport-persistent.ts
273
273
  var PersistentTransport = class {
274
274
  pool;
275
+ signal;
275
276
  worker = null;
276
277
  pendingInitializeId = null;
277
278
  initializeIntercepted = false;
@@ -280,9 +281,10 @@ var PersistentTransport = class {
280
281
  closeListeners = /* @__PURE__ */ new Set();
281
282
  constructor(settings) {
282
283
  this.pool = settings.pool;
284
+ this.signal = settings.signal;
283
285
  }
284
286
  async connect() {
285
- this.worker = this.pool.acquire();
287
+ this.worker = await this.pool.acquire(stripUndefined({ signal: this.signal }));
286
288
  await this.worker.ensureConnected();
287
289
  }
288
290
  disconnect() {
@@ -722,6 +724,7 @@ var CodexWorker = class {
722
724
  var CodexWorkerPool = class {
723
725
  workers;
724
726
  shutdownCalled = false;
727
+ waiters = [];
725
728
  constructor(settings) {
726
729
  const size = settings.poolSize ?? 1;
727
730
  const idleTimeoutMs = settings.idleTimeoutMs ?? 3e5;
@@ -733,7 +736,7 @@ var CodexWorkerPool = class {
733
736
  })
734
737
  );
735
738
  }
736
- acquire() {
739
+ async acquire(options) {
737
740
  if (this.shutdownCalled) {
738
741
  throw new CodexProviderError("Worker pool has been shut down.");
739
742
  }
@@ -741,20 +744,61 @@ var CodexWorkerPool = class {
741
744
  (w) => w.state === "idle" || w.state === "disconnected"
742
745
  );
743
746
  if (!worker) {
744
- throw new CodexProviderError(
745
- "All workers are busy. Try again later or increase poolSize."
746
- );
747
+ if (options?.signal?.aborted) {
748
+ throw new CodexProviderError("Worker acquisition aborted while waiting.");
749
+ }
750
+ return new Promise((resolve, reject) => {
751
+ const waiter = {
752
+ resolve,
753
+ reject,
754
+ signal: options?.signal,
755
+ abortHandler: void 0
756
+ };
757
+ if (waiter.signal) {
758
+ waiter.abortHandler = () => {
759
+ this.removeWaiter(waiter);
760
+ waiter.reject(new CodexProviderError("Worker acquisition aborted while waiting."));
761
+ };
762
+ waiter.signal.addEventListener("abort", waiter.abortHandler, { once: true });
763
+ }
764
+ this.waiters.push(waiter);
765
+ });
747
766
  }
748
767
  worker.acquire();
749
768
  return worker;
750
769
  }
751
770
  release(worker) {
752
- worker.release();
771
+ const waiter = this.waiters.shift();
772
+ if (waiter) {
773
+ this.clearWaiterAbortHandler(waiter);
774
+ waiter.resolve(worker);
775
+ } else {
776
+ worker.release();
777
+ }
753
778
  }
754
779
  async shutdown() {
755
780
  this.shutdownCalled = true;
781
+ while (this.waiters.length > 0) {
782
+ const waiter = this.waiters.shift();
783
+ this.clearWaiterAbortHandler(waiter);
784
+ waiter.reject(new CodexProviderError("Worker pool has been shut down."));
785
+ }
756
786
  await Promise.all(this.workers.map((w) => w.shutdown()));
757
787
  }
788
+ removeWaiter(target) {
789
+ const index = this.waiters.indexOf(target);
790
+ if (index >= 0) {
791
+ this.waiters.splice(index, 1);
792
+ }
793
+ }
794
+ /** Remove the abort listener so it doesn't fire after the waiter is already served. */
795
+ clearWaiterAbortHandler(waiter) {
796
+ if (!waiter.signal || !waiter.abortHandler) {
797
+ return;
798
+ }
799
+ waiter.signal.removeEventListener("abort", waiter.abortHandler);
800
+ waiter.abortHandler = void 0;
801
+ }
758
802
  };
759
803
 
760
804
  // src/dynamic-tools.ts
@@ -884,7 +928,7 @@ var DynamicToolsDispatcher = class {
884
928
  // package.json
885
929
  var package_default = {
886
930
  name: "@janole/ai-sdk-provider-codex-asp",
887
- version: "0.2.2"};
931
+ version: "0.2.3"};
888
932
 
889
933
  // src/package-info.ts
890
934
  var PACKAGE_NAME = package_default.name;
@@ -1553,7 +1597,7 @@ var CodexLanguageModel = class {
1553
1597
  });
1554
1598
  }
1555
1599
  doStream(options) {
1556
- const transport = this.config.providerSettings.transportFactory ? this.config.providerSettings.transportFactory() : this.config.providerSettings.transport?.type === "websocket" ? new WebSocketTransport(this.config.providerSettings.transport.websocket) : new StdioTransport(this.config.providerSettings.transport?.stdio);
1600
+ const transport = this.config.providerSettings.transportFactory ? this.config.providerSettings.transportFactory(options.abortSignal) : this.config.providerSettings.transport?.type === "websocket" ? new WebSocketTransport(this.config.providerSettings.transport.websocket) : new StdioTransport(this.config.providerSettings.transport?.stdio);
1557
1601
  const packetLogger = this.config.providerSettings.debug?.logPackets === true ? this.config.providerSettings.debug.logger ?? ((packet) => {
1558
1602
  if (packet.direction === "inbound") {
1559
1603
  console.debug("[codex packet]", packet.message);
@@ -1967,7 +2011,7 @@ function createCodexAppServer(settings = {}) {
1967
2011
  });
1968
2012
  }
1969
2013
  const persistentPool = persistentPoolHandle?.pool ?? null;
1970
- const effectiveTransportFactory = persistentPool ? () => new PersistentTransport({ pool: persistentPool }) : baseTransportFactory;
2014
+ const effectiveTransportFactory = persistentPool ? (signal) => new PersistentTransport(stripUndefined({ pool: persistentPool, signal })) : baseTransportFactory;
1971
2015
  const resolvedSettings = Object.freeze(stripUndefined({
1972
2016
  defaultModel: settings.defaultModel,
1973
2017
  experimentalApi: settings.experimentalApi,