@codex-app-sdk/core 0.16.9 → 0.18.0

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.
@@ -1,8 +1,11 @@
1
- function e(e) {
1
+ import { t as e } from "./prompt-content-BCcHFqCj.js";
2
+ //#region src/surface-state.ts
3
+ var t = 1e3;
4
+ function n(e) {
2
5
  let t = e;
3
6
  return typeof t?.getVersionedSnapshot == "function" && typeof t.onStatePatch == "function";
4
7
  }
5
- function t(e, t) {
8
+ function r(e, t) {
6
9
  let n = e, r = t, i = [];
7
10
  for (let e of /* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(r)])) {
8
11
  let t = e;
@@ -14,7 +17,7 @@ function t(e, t) {
14
17
  });
15
18
  continue;
16
19
  }
17
- i.push(a(t, n[e], r[e]) ?? {
20
+ i.push(s(t, n[e], r[e]) ?? {
18
21
  type: "set",
19
22
  key: t,
20
23
  value: r[e]
@@ -23,7 +26,7 @@ function t(e, t) {
23
26
  }
24
27
  return i;
25
28
  }
26
- function n(e, t) {
29
+ function i(e, t) {
27
30
  let n = e, r = { ...n };
28
31
  for (let e of t) if (e.type === "delete") delete r[e.key];
29
32
  else if (e.type === "set") r[e.key] = e.value;
@@ -40,71 +43,71 @@ function n(e, t) {
40
43
  }
41
44
  return r;
42
45
  }
43
- function r() {
44
- let e = null, t = -1, r = !0, i = [], a = (e) => (r = !0, i.push(e), i.length > 1e3 && i.shift(), { status: "resync" }), o = {
46
+ function a() {
47
+ let e = null, n = -1, r = !0, a = [], o = (e) => (r = !0, a.push(e), a.length > t && a.shift(), { status: "resync" }), s = {
45
48
  get snapshot() {
46
49
  return e;
47
50
  },
48
51
  get version() {
49
- return t;
52
+ return n;
50
53
  },
51
- reset(n) {
52
- e = n.snapshot, t = n.version, r = !1;
53
- let a = i.splice(0).sort((e, t) => e.version - t.version);
54
- for (let e of a) if (o.receive(e).status === "resync") break;
54
+ reset(t) {
55
+ e = t.snapshot, n = t.version, r = !1;
56
+ let i = a.splice(0).sort((e, t) => e.version - t.version);
57
+ for (let e of i) if (s.receive(e).status === "resync") break;
55
58
  return e;
56
59
  },
57
- receive(i) {
58
- if (r || !e) return a(i);
59
- if (i.version <= t) return { status: "ignored" };
60
- if (i.version !== t + 1) return a(i);
60
+ receive(t) {
61
+ if (r || !e) return o(t);
62
+ if (t.version <= n) return { status: "ignored" };
63
+ if (t.version !== n + 1) return o(t);
61
64
  try {
62
- e = n(e, i.changes);
65
+ e = i(e, t.changes);
63
66
  } catch {
64
- return a(i);
67
+ return o(t);
65
68
  }
66
- return t = i.version, {
69
+ return n = t.version, {
67
70
  status: "applied",
68
71
  snapshot: e
69
72
  };
70
73
  }
71
74
  };
72
- return o;
73
- }
74
- function i(t, n, i = {}) {
75
- let a = () => "onStateChange" in t && typeof t.onStateChange == "function" ? t.onStateChange(n) : () => void 0;
76
- if (!e(t)) return a();
77
- let s = r(), c = !0, l = !1, u = !1, d = () => void 0, f = () => {
78
- u || !c || (u = !0, Promise.resolve().then(() => t.getVersionedSnapshot()).then((e) => {
79
- if (u = !1, !c) return;
80
- if (!o(e)) {
75
+ return s;
76
+ }
77
+ function o(e, t, r = {}) {
78
+ let i = () => "onStateChange" in e && typeof e.onStateChange == "function" ? e.onStateChange(t) : () => void 0;
79
+ if (!n(e)) return i();
80
+ let o = a(), s = !0, l = !1, u = !1, d = () => void 0, f = () => {
81
+ u || !s || (u = !0, Promise.resolve().then(() => e.getVersionedSnapshot()).then((e) => {
82
+ if (u = !1, !s) return;
83
+ if (!c(e)) {
81
84
  if (l) return;
82
- d(), d = a();
85
+ d(), d = i();
83
86
  return;
84
87
  }
85
- let t = s.reset(e), r = l || i.emitInitialSnapshot !== !1 || s.version > e.version;
86
- l = !0, r && n(t);
88
+ let n = o.reset(e), a = l || r.emitInitialSnapshot !== !1 || o.version > e.version;
89
+ l = !0, a && t(n);
87
90
  }, () => {
88
91
  u = !1;
89
92
  }));
90
93
  };
91
- return d = t.onStatePatch((e) => {
92
- let t = s.receive(e);
93
- t.status === "applied" ? n(t.snapshot) : t.status === "resync" && f();
94
+ return d = e.onStatePatch((e) => {
95
+ let n = o.receive(e);
96
+ n.status === "applied" ? t(n.snapshot) : n.status === "resync" && f();
94
97
  }), f(), () => {
95
- c = !1, d();
98
+ s = !1, d();
96
99
  };
97
100
  }
98
- function a(e, t, n) {
101
+ function s(e, t, n) {
99
102
  if (!Array.isArray(t) || !Array.isArray(n)) return null;
100
103
  let r = /* @__PURE__ */ new Map();
101
104
  for (let e of t) {
102
- if (!s(e) || r.has(e.id)) return null;
105
+ if (!l(e) || r.has(e.id)) return null;
103
106
  r.set(e.id, e);
104
107
  }
105
108
  let i = [], a = [], o = /* @__PURE__ */ new Set();
106
109
  for (let e of n) {
107
- if (!s(e) || o.has(e.id)) return null;
110
+ if (!l(e) || o.has(e.id)) return null;
108
111
  o.add(e.id), i.push(e.id), r.get(e.id) !== e && a.push(e);
109
112
  }
110
113
  return a.length === n.length ? null : {
@@ -114,16 +117,16 @@ function a(e, t, n) {
114
117
  items: a
115
118
  };
116
119
  }
117
- function o(e) {
120
+ function c(e) {
118
121
  let t = e;
119
122
  return Number.isSafeInteger(t?.version) && !!t?.snapshot && typeof t?.snapshot == "object";
120
123
  }
121
- function s(e) {
124
+ function l(e) {
122
125
  return !!e && typeof e == "object" && typeof e.id == "string";
123
126
  }
124
127
  //#endregion
125
128
  //#region src/surface-bridge.ts
126
- var c = [
129
+ var u = [
127
130
  "clearGoal",
128
131
  "compactConversation",
129
132
  "continueInterruptedTurn",
@@ -147,17 +150,17 @@ var c = [
147
150
  "steerQueuedPrompt",
148
151
  "updateConversationSettings",
149
152
  "updateQueuedPrompt"
150
- ], l = new Set(c);
151
- function u(e) {
152
- return typeof e == "string" && l.has(e);
153
+ ], d = new Set(u);
154
+ function f(e) {
155
+ return typeof e == "string" && d.has(e);
153
156
  }
154
- async function d(e, t, n, r, i = {}) {
155
- let a = R(t, "Conversation id"), [o, s] = _[n];
157
+ async function p(e, t, n, r, i = {}) {
158
+ let a = B(t, "Conversation id"), [o, s] = y[n];
156
159
  if (r.length < o || r.length > s) throw TypeError(`${i.operationLabel ?? n} received an invalid number of arguments`);
157
- return await y(b(e.conversation(a)), n, r, i);
160
+ return await x(S(e.conversation(a)), n, r, i);
158
161
  }
159
- function f(e, t, n) {
160
- let r = R(t, "Conversation id"), i = e.conversation(r), a = (e) => {
162
+ function m(e, t, n) {
163
+ let r = B(t, "Conversation id"), i = e.conversation(r), a = (e) => {
161
164
  e.activeConversationId === r && n({
162
165
  type: "snapshot",
163
166
  conversationId: r,
@@ -179,8 +182,8 @@ function f(e, t, n) {
179
182
  c(), s();
180
183
  };
181
184
  }
182
- function p(e, t, n) {
183
- let r = R(t, "Conversation id"), i = e.conversation(r), a = [], o = !1, s = i.onEvent((e) => {
185
+ function h(e, t, n) {
186
+ let r = B(t, "Conversation id"), i = e.conversation(r), a = [], o = !1, s = i.onEvent((e) => {
184
187
  e.conversationId === r && (o ? n({
185
188
  type: "event",
186
189
  conversationId: r,
@@ -206,7 +209,7 @@ function p(e, t, n) {
206
209
  }
207
210
  return s;
208
211
  }
209
- var m = /* @__PURE__ */ "archiveConversation.cancelLogin.clearGoal.compactConversation.connect.continueInterruptedTurn.createConversation.deleteConversation.deleteTurn.deleteQueuedPrompt.editTurn.forkTurn.getSnapshot.interrupt.listConversations.listModels.loadOlderConversationHistory.logout.readConversationHistory.readConversationPromptHistory.refreshAccount.refreshConversations.renameConversation.respondToClientRequest.resolveApproval.retryTurn.selectConversation.sendMessage.setGoal.startChatGptDeviceCodeLogin.startChatGptLogin.startReview.steerMessage.steerQueuedPrompt.unarchiveConversation.updateConversationSettings.updateQueuedPrompt.startLiveChat.stopLiveChat.readRateLimits.readAccountUsage.consumeRateLimitResetCredit".split("."), h = new Set(m), g = {
212
+ var g = /* @__PURE__ */ "archiveConversation.cancelLogin.clearGoal.compactConversation.connect.continueInterruptedTurn.createConversation.deleteConversation.deleteTurn.deleteQueuedPrompt.editTurn.forkTurn.getSnapshot.interrupt.listConversations.listModels.loadOlderConversationHistory.logout.readConversationHistory.readConversationPromptHistory.refreshAccount.refreshConversations.renameConversation.respondToClientRequest.resolveApproval.retryTurn.selectConversation.sendMessage.setGoal.startChatGptDeviceCodeLogin.startChatGptLogin.startReview.steerMessage.steerQueuedPrompt.unarchiveConversation.updateConversationSettings.updateQueuedPrompt.startLiveChat.stopLiveChat.readRateLimits.readAccountUsage.consumeRateLimitResetCredit".split("."), _ = new Set(g), v = {
210
213
  startLiveChat: [2, 2],
211
214
  stopLiveChat: [1, 1],
212
215
  archiveConversation: [1, 1],
@@ -219,7 +222,7 @@ var m = /* @__PURE__ */ "archiveConversation.cancelLogin.clearGoal.compactConver
219
222
  deleteConversation: [1, 1],
220
223
  deleteTurn: [1, 1],
221
224
  deleteQueuedPrompt: [1, 1],
222
- editTurn: [2, 2],
225
+ editTurn: [2, 3],
223
226
  forkTurn: [1, 1],
224
227
  getSnapshot: [0, 0],
225
228
  interrupt: [0, 0],
@@ -245,17 +248,17 @@ var m = /* @__PURE__ */ "archiveConversation.cancelLogin.clearGoal.compactConver
245
248
  startChatGptLogin: [0, 0],
246
249
  startReview: [0, 1],
247
250
  steerMessage: [1, 2],
248
- steerQueuedPrompt: [1, 2],
251
+ steerQueuedPrompt: [1, 3],
249
252
  unarchiveConversation: [1, 1],
250
253
  updateConversationSettings: [1, 1],
251
- updateQueuedPrompt: [2, 2]
252
- }, _ = {
254
+ updateQueuedPrompt: [2, 3]
255
+ }, y = {
253
256
  clearGoal: [0, 0],
254
257
  compactConversation: [0, 0],
255
258
  continueInterruptedTurn: [0, 0],
256
259
  deleteTurn: [1, 1],
257
260
  deleteQueuedPrompt: [1, 1],
258
- editTurn: [2, 2],
261
+ editTurn: [2, 3],
259
262
  forkTurn: [1, 1],
260
263
  getSnapshot: [0, 0],
261
264
  interrupt: [0, 0],
@@ -270,26 +273,26 @@ var m = /* @__PURE__ */ "archiveConversation.cancelLogin.clearGoal.compactConver
270
273
  setGoal: [1, 2],
271
274
  startReview: [0, 1],
272
275
  steerMessage: [1, 2],
273
- steerQueuedPrompt: [1, 2],
276
+ steerQueuedPrompt: [1, 3],
274
277
  updateConversationSettings: [1, 1],
275
- updateQueuedPrompt: [2, 2]
278
+ updateQueuedPrompt: [2, 3]
276
279
  };
277
- function v(e) {
278
- return typeof e == "string" && h.has(e);
280
+ function b(e) {
281
+ return typeof e == "string" && _.has(e);
279
282
  }
280
- async function y(e, t, n, r = {}) {
281
- let [i, a] = g[t];
283
+ async function x(e, t, n, r = {}) {
284
+ let [i, a] = v[t];
282
285
  if (n.length < i || n.length > a) throw TypeError(`${r.operationLabel ?? t} received an invalid number of arguments`);
283
- return await x(e, t, n, r);
286
+ return await C(e, t, n, r);
284
287
  }
285
- function b(e) {
288
+ function S(e) {
286
289
  return {
287
290
  clearGoal: () => e.clearGoal(),
288
291
  compactConversation: () => e.compact(),
289
292
  continueInterruptedTurn: () => e.continueInterruptedTurn(),
290
293
  deleteTurn: (t) => e.deleteTurn(t),
291
294
  deleteQueuedPrompt: (t) => e.deleteQueuedPrompt(t),
292
- editTurn: (t, n) => e.editTurn(t, n),
295
+ editTurn: (t, n, r) => e.editTurn(t, n, r),
293
296
  forkTurn: async (t) => (await e.forkTurn(t)).snapshot,
294
297
  getSnapshot: () => e.getSnapshot(),
295
298
  interrupt: () => e.interrupt(),
@@ -304,38 +307,38 @@ function b(e) {
304
307
  setGoal: (t, n) => e.setGoal(t, n),
305
308
  startReview: (t) => e.startReview(t),
306
309
  steerMessage: (t, n) => e.steerMessage(t, n),
307
- steerQueuedPrompt: (t, n) => e.steerQueuedPrompt(t, n),
310
+ steerQueuedPrompt: (t, n, r) => e.steerQueuedPrompt(t, n, r),
308
311
  updateConversationSettings: (t) => e.updateSettings(t),
309
- updateQueuedPrompt: (t, n) => e.updateQueuedPrompt(t, n)
312
+ updateQueuedPrompt: (t, n, r) => e.updateQueuedPrompt(t, n, r)
310
313
  };
311
314
  }
312
- async function x(e, t, n, r) {
315
+ async function C(e, t, n, r) {
313
316
  switch (t) {
314
- case "startLiveChat": return e.startLiveChat(R(n[0], "Conversation id"), S(n[1]));
315
- case "stopLiveChat": return e.stopLiveChat(R(n[0], "Conversation id"));
316
- case "archiveConversation": return e.archiveConversation(R(n[0], "Conversation id"));
317
- case "cancelLogin": return e.cancelLogin(z(n[0], "Login id"));
317
+ case "startLiveChat": return e.startLiveChat(B(n[0], "Conversation id"), w(n[1]));
318
+ case "stopLiveChat": return e.stopLiveChat(B(n[0], "Conversation id"));
319
+ case "archiveConversation": return e.archiveConversation(B(n[0], "Conversation id"));
320
+ case "cancelLogin": return e.cancelLogin(V(n[0], "Login id"));
318
321
  case "clearGoal": return e.clearGoal();
319
322
  case "compactConversation": return e.compactConversation();
320
323
  case "connect": return e.connect();
321
324
  case "continueInterruptedTurn": return e.continueInterruptedTurn();
322
- case "createConversation": return e.createConversation(C(n[0]));
323
- case "deleteConversation": return e.deleteConversation(R(n[0], "Conversation id"));
324
- case "deleteTurn": return e.deleteTurn(R(n[0], "Turn id"));
325
- case "deleteQueuedPrompt": return e.deleteQueuedPrompt(R(n[0], "Queued prompt id"));
326
- case "editTurn": return e.editTurn(R(n[0], "Turn id"), R(n[1], "Turn content"));
327
- case "forkTurn": return e.forkTurn(R(n[0], "Turn id"));
325
+ case "createConversation": return e.createConversation(T(n[0]));
326
+ case "deleteConversation": return e.deleteConversation(B(n[0], "Conversation id"));
327
+ case "deleteTurn": return e.deleteTurn(B(n[0], "Turn id"));
328
+ case "deleteQueuedPrompt": return e.deleteQueuedPrompt(B(n[0], "Queued prompt id"));
329
+ case "editTurn": return e.editTurn(B(n[0], "Turn id"), B(n[1], "Turn content"), await N(n[2], r.resolveAttachment));
330
+ case "forkTurn": return e.forkTurn(B(n[0], "Turn id"));
328
331
  case "getSnapshot": return e.getSnapshot();
329
332
  case "interrupt": return e.interrupt();
330
- case "listConversations": return e.listConversations(w(n[0]));
331
- case "listModels": return e.listModels(D(n[0]));
332
- case "loadOlderConversationHistory": return e.loadOlderConversationHistory(z(n[0], "Conversation id"));
333
+ case "listConversations": return e.listConversations(E(n[0]));
334
+ case "listModels": return e.listModels(k(n[0]));
335
+ case "loadOlderConversationHistory": return e.loadOlderConversationHistory(V(n[0], "Conversation id"));
333
336
  case "logout": return e.logout();
334
- case "readConversationHistory": return e.readConversationHistory(z(n[0], "Conversation id"));
335
- case "readConversationPromptHistory": return e.readConversationPromptHistory(z(n[0], "Conversation id"));
337
+ case "readConversationHistory": return e.readConversationHistory(V(n[0], "Conversation id"));
338
+ case "readConversationPromptHistory": return e.readConversationPromptHistory(V(n[0], "Conversation id"));
336
339
  case "refreshAccount": return e.refreshAccount();
337
340
  case "readRateLimits": {
338
- let t = T(n[0]);
341
+ let t = D(n[0]);
339
342
  if (!e.readRateLimits) throw Error("Account rate-limit reads are not available.");
340
343
  return e.readRateLimits(t);
341
344
  }
@@ -343,31 +346,31 @@ async function x(e, t, n, r) {
343
346
  if (!e.readAccountUsage) throw Error("Account usage reads are not available.");
344
347
  return e.readAccountUsage();
345
348
  case "consumeRateLimitResetCredit": {
346
- let t = E(n[0]);
349
+ let t = O(n[0]);
347
350
  if (!e.consumeRateLimitResetCredit) throw Error("Rate-limit reset credits are not available.");
348
351
  return e.consumeRateLimitResetCredit(t);
349
352
  }
350
353
  case "refreshConversations": return e.refreshConversations();
351
- case "renameConversation": return e.renameConversation(R(n[0], "Conversation title"));
352
- case "respondToClientRequest": return e.respondToClientRequest(k(n[0]));
353
- case "resolveApproval": return e.resolveApproval(R(n[0], "Approval id"), H(n[1]), U(n[2]));
354
- case "retryTurn": return e.retryTurn(R(n[0], "Turn id"));
355
- case "selectConversation": return e.selectConversation(R(n[0], "Conversation id"));
356
- case "sendMessage": return e.sendMessage(R(n[0], "Message prompt"), await j(n[1], r.resolveAttachment));
357
- case "setGoal": return e.setGoal(R(n[0], "Goal objective"), G(n[1]));
354
+ case "renameConversation": return e.renameConversation(B(n[0], "Conversation title"));
355
+ case "respondToClientRequest": return e.respondToClientRequest(j(n[0]));
356
+ case "resolveApproval": return e.resolveApproval(B(n[0], "Approval id"), W(n[1]), G(n[2]));
357
+ case "retryTurn": return e.retryTurn(B(n[0], "Turn id"));
358
+ case "selectConversation": return e.selectConversation(B(n[0], "Conversation id"));
359
+ case "sendMessage": return e.sendMessage(B(n[0], "Message prompt"), await N(n[1], r.resolveAttachment));
360
+ case "setGoal": return e.setGoal(B(n[0], "Goal objective"), q(n[1]));
358
361
  case "startChatGptDeviceCodeLogin": return e.startChatGptDeviceCodeLogin();
359
362
  case "startChatGptLogin": return e.startChatGptLogin();
360
- case "startReview": return e.startReview(F(n[0]));
361
- case "steerMessage": return e.steerMessage(R(n[0], "Steer prompt"), await j(n[1], r.resolveAttachment));
362
- case "steerQueuedPrompt": return e.steerQueuedPrompt(R(n[0], "Queued prompt id"), z(n[1], "Queued prompt"));
363
- case "unarchiveConversation": return e.unarchiveConversation(R(n[0], "Conversation id"));
364
- case "updateConversationSettings": return e.updateConversationSettings(O(n[0]));
365
- case "updateQueuedPrompt": return e.updateQueuedPrompt(R(n[0], "Queued prompt id"), R(n[1], "Queued prompt"));
363
+ case "startReview": return e.startReview(L(n[0]));
364
+ case "steerMessage": return e.steerMessage(B(n[0], "Steer prompt"), await N(n[1], r.resolveAttachment));
365
+ case "steerQueuedPrompt": return e.steerQueuedPrompt(B(n[0], "Queued prompt id"), V(n[1], "Queued prompt"), await N(n[2], r.resolveAttachment));
366
+ case "unarchiveConversation": return e.unarchiveConversation(B(n[0], "Conversation id"));
367
+ case "updateConversationSettings": return e.updateConversationSettings(A(n[0]));
368
+ case "updateQueuedPrompt": return e.updateQueuedPrompt(B(n[0], "Queued prompt id"), B(n[1], "Queued prompt"), await N(n[2], r.resolveAttachment));
366
369
  }
367
370
  }
368
- function S(e) {
369
- let t = I(e, "Live chat options");
370
- L(t, [
371
+ function w(e) {
372
+ let t = R(e, "Live chat options");
373
+ z(t, [
371
374
  "sdp",
372
375
  "version",
373
376
  "voice",
@@ -376,12 +379,12 @@ function S(e) {
376
379
  "includeStartupContext",
377
380
  "flushTranscriptTailOnSessionEnd"
378
381
  ], "Live chat options");
379
- let n = { sdp: R(t.sdp, "SDP offer") };
382
+ let n = { sdp: B(t.sdp, "SDP offer") };
380
383
  if (t.version !== void 0) {
381
384
  if (t.version !== "v1" && t.version !== "v2" && t.version !== "v3") throw TypeError("Invalid realtime version");
382
385
  n.version = t.version;
383
386
  }
384
- for (let e of ["voice", "model"]) t[e] !== void 0 && (n[e] = R(t[e], e));
387
+ for (let e of ["voice", "model"]) t[e] !== void 0 && (n[e] = B(t[e], e));
385
388
  if (t.prompt !== void 0) {
386
389
  if (t.prompt !== null && typeof t.prompt != "string") throw TypeError("Prompt must be a string or null");
387
390
  n.prompt = t.prompt;
@@ -392,82 +395,82 @@ function S(e) {
392
395
  }
393
396
  return n;
394
397
  }
395
- function C(e) {
398
+ function T(e) {
396
399
  if (e === void 0) return;
397
- let t = I(e, "Conversation options");
398
- return L(t, [
400
+ let t = R(e, "Conversation options");
401
+ return z(t, [
399
402
  "model",
400
403
  "reasoningEffort",
401
404
  "serviceTier",
402
405
  "approvalPreset"
403
406
  ], "Conversation options"), {
404
- ...t.model === void 0 ? {} : { model: R(t.model, "Conversation model") },
405
- ...t.reasoningEffort === void 0 ? {} : { reasoningEffort: R(t.reasoningEffort, "Conversation reasoning effort") },
406
- ...t.serviceTier === void 0 ? {} : { serviceTier: B(t.serviceTier, "Conversation service tier") },
407
- ...t.approvalPreset === void 0 ? {} : { approvalPreset: W(t.approvalPreset) }
407
+ ...t.model === void 0 ? {} : { model: B(t.model, "Conversation model") },
408
+ ...t.reasoningEffort === void 0 ? {} : { reasoningEffort: B(t.reasoningEffort, "Conversation reasoning effort") },
409
+ ...t.serviceTier === void 0 ? {} : { serviceTier: H(t.serviceTier, "Conversation service tier") },
410
+ ...t.approvalPreset === void 0 ? {} : { approvalPreset: K(t.approvalPreset) }
408
411
  };
409
412
  }
410
- function w(e) {
413
+ function E(e) {
411
414
  if (e === void 0) return;
412
- let t = I(e, "Conversation list options");
413
- if (L(t, [
415
+ let t = R(e, "Conversation list options");
416
+ if (z(t, [
414
417
  "archived",
415
418
  "cwd",
416
419
  "limit",
417
420
  "searchTerm"
418
421
  ], "Conversation list options"), t.archived !== void 0 && typeof t.archived != "boolean") throw TypeError("Conversation list archived flag must be a boolean");
419
422
  if (t.limit !== void 0 && (!Number.isInteger(t.limit) || t.limit < 0)) throw TypeError("Conversation list limit must be a non-negative integer");
420
- let n = t.cwd === void 0 ? void 0 : Array.isArray(t.cwd) ? t.cwd.map((e) => R(e, "Conversation list cwd")) : R(t.cwd, "Conversation list cwd");
423
+ let n = t.cwd === void 0 ? void 0 : Array.isArray(t.cwd) ? t.cwd.map((e) => B(e, "Conversation list cwd")) : B(t.cwd, "Conversation list cwd");
421
424
  return {
422
425
  ...t.archived === void 0 ? {} : { archived: t.archived },
423
426
  ...n === void 0 ? {} : { cwd: n },
424
427
  ...t.limit === void 0 ? {} : { limit: t.limit },
425
- ...t.searchTerm === void 0 ? {} : { searchTerm: R(t.searchTerm, "Conversation list search term") }
428
+ ...t.searchTerm === void 0 ? {} : { searchTerm: B(t.searchTerm, "Conversation list search term") }
426
429
  };
427
430
  }
428
- function T(e) {
431
+ function D(e) {
429
432
  if (e === void 0) return;
430
- let t = I(e, "Rate-limit read options");
431
- return L(t, ["excludeResetCreditDetails"], "Rate-limit read options"), t.excludeResetCreditDetails === void 0 ? {} : { excludeResetCreditDetails: V(t.excludeResetCreditDetails, "Exclude reset credit details") };
433
+ let t = R(e, "Rate-limit read options");
434
+ return z(t, ["excludeResetCreditDetails"], "Rate-limit read options"), t.excludeResetCreditDetails === void 0 ? {} : { excludeResetCreditDetails: U(t.excludeResetCreditDetails, "Exclude reset credit details") };
432
435
  }
433
- function E(e) {
434
- let t = I(e, "Reset-credit options");
435
- return L(t, ["idempotencyKey", "creditId"], "Reset-credit options"), {
436
- idempotencyKey: R(t.idempotencyKey, "Reset-credit idempotency key"),
437
- ...t.creditId === void 0 ? {} : { creditId: R(t.creditId, "Reset credit id") }
436
+ function O(e) {
437
+ let t = R(e, "Reset-credit options");
438
+ return z(t, ["idempotencyKey", "creditId"], "Reset-credit options"), {
439
+ idempotencyKey: B(t.idempotencyKey, "Reset-credit idempotency key"),
440
+ ...t.creditId === void 0 ? {} : { creditId: B(t.creditId, "Reset credit id") }
438
441
  };
439
442
  }
440
- function D(e) {
443
+ function k(e) {
441
444
  if (e === void 0) return;
442
- let t = I(e, "Model list options");
443
- return L(t, ["includeHidden", "forceReload"], "Model list options"), {
444
- ...t.includeHidden === void 0 ? {} : { includeHidden: V(t.includeHidden, "Model list includeHidden") },
445
- ...t.forceReload === void 0 ? {} : { forceReload: V(t.forceReload, "Model list forceReload") }
445
+ let t = R(e, "Model list options");
446
+ return z(t, ["includeHidden", "forceReload"], "Model list options"), {
447
+ ...t.includeHidden === void 0 ? {} : { includeHidden: U(t.includeHidden, "Model list includeHidden") },
448
+ ...t.forceReload === void 0 ? {} : { forceReload: U(t.forceReload, "Model list forceReload") }
446
449
  };
447
450
  }
448
- function O(e) {
449
- let t = I(e, "Conversation settings");
450
- return L(t, [
451
+ function A(e) {
452
+ let t = R(e, "Conversation settings");
453
+ return z(t, [
451
454
  "modelId",
452
455
  "reasoningEffort",
453
456
  "serviceTier",
454
457
  "approvalPreset",
455
458
  "planMode"
456
459
  ], "Conversation settings"), {
457
- ...t.modelId === void 0 ? {} : { modelId: R(t.modelId, "Conversation model id") },
458
- ...t.reasoningEffort === void 0 ? {} : { reasoningEffort: R(t.reasoningEffort, "Conversation reasoning effort") },
459
- ...t.serviceTier === void 0 ? {} : { serviceTier: B(t.serviceTier, "Conversation service tier") },
460
- ...t.approvalPreset === void 0 ? {} : { approvalPreset: W(t.approvalPreset) },
461
- ...t.planMode === void 0 ? {} : { planMode: V(t.planMode, "Conversation plan mode") }
460
+ ...t.modelId === void 0 ? {} : { modelId: B(t.modelId, "Conversation model id") },
461
+ ...t.reasoningEffort === void 0 ? {} : { reasoningEffort: B(t.reasoningEffort, "Conversation reasoning effort") },
462
+ ...t.serviceTier === void 0 ? {} : { serviceTier: H(t.serviceTier, "Conversation service tier") },
463
+ ...t.approvalPreset === void 0 ? {} : { approvalPreset: K(t.approvalPreset) },
464
+ ...t.planMode === void 0 ? {} : { planMode: U(t.planMode, "Conversation plan mode") }
462
465
  };
463
466
  }
464
- function k(e) {
465
- let t = I(e, "Client request response");
466
- L(t, ["id", "payload"], "Client request response");
467
- let n = R(t.id, "Client request id");
467
+ function j(e) {
468
+ let t = R(e, "Client request response");
469
+ z(t, ["id", "payload"], "Client request response");
470
+ let n = B(t.id, "Client request id");
468
471
  if (t.payload === void 0) return { id: n };
469
- let r = I(t.payload, "Client request response payload");
470
- L(r, [
472
+ let r = R(t.payload, "Client request response payload");
473
+ z(r, [
471
474
  "answers",
472
475
  "cancelled",
473
476
  "decision"
@@ -480,30 +483,32 @@ function k(e) {
480
483
  "always_allow",
481
484
  "deny"
482
485
  ].includes(i)) throw TypeError("Client request decision is invalid");
483
- let a = r.answers === void 0 ? void 0 : A(r.answers);
486
+ let a = r.answers === void 0 ? void 0 : M(r.answers);
484
487
  return {
485
488
  id: n,
486
489
  payload: {
487
490
  ...a === void 0 ? {} : { answers: a },
488
- ...r.cancelled === void 0 ? {} : { cancelled: V(r.cancelled, "Client request cancelled flag") },
491
+ ...r.cancelled === void 0 ? {} : { cancelled: U(r.cancelled, "Client request cancelled flag") },
489
492
  ...i === void 0 ? {} : { decision: i }
490
493
  }
491
494
  };
492
495
  }
493
- function A(e) {
494
- let t = I(e, "Client request answers"), n = {};
496
+ function M(e) {
497
+ let t = R(e, "Client request answers"), n = {};
495
498
  for (let [e, r] of Object.entries(t)) {
496
499
  if (!e.trim()) throw TypeError("Client request question id must be non-empty");
497
- let t = I(r, "Client request answer");
498
- if (L(t, ["answers"], "Client request answer"), !Array.isArray(t.answers) || !t.answers.every((e) => typeof e == "string")) throw TypeError("Client request answer values must be an array of strings");
500
+ let t = R(r, "Client request answer");
501
+ if (z(t, ["answers"], "Client request answer"), !Array.isArray(t.answers) || !t.answers.every((e) => typeof e == "string")) throw TypeError("Client request answer values must be an array of strings");
499
502
  n[e] = { answers: [...t.answers] };
500
503
  }
501
504
  return n;
502
505
  }
503
- async function j(e, t) {
504
- if (e === void 0) return;
505
- let n = I(e, "Message options");
506
- L(n, [
506
+ async function N(t, n) {
507
+ if (t === void 0) return;
508
+ let r = R(t, "Message options");
509
+ z(r, [
510
+ "content",
511
+ "inputMethod",
507
512
  "attachments",
508
513
  "model",
509
514
  "reasoningEffort",
@@ -512,26 +517,29 @@ async function j(e, t) {
512
517
  "skills",
513
518
  "outputSchema"
514
519
  ], "Message options");
515
- let r = n.attachments === void 0 ? void 0 : await M(n.attachments, t), i = n.skills === void 0 ? void 0 : P(n.skills);
516
- if (n.outputSchema !== void 0 && !J(n.outputSchema)) throw TypeError("Message output schema must be JSON-serializable");
520
+ let i = r.attachments === void 0 ? void 0 : await P(r.attachments, n), a = r.skills === void 0 ? void 0 : I(r.skills), o = r.inputMethod;
521
+ if (o !== void 0 && o !== "typed" && o !== "dictated") throw TypeError("Message input method must be typed or dictated");
522
+ if (r.outputSchema !== void 0 && !X(r.outputSchema)) throw TypeError("Message output schema must be JSON-serializable");
517
523
  return {
518
- ...r === void 0 ? {} : { attachments: r },
519
- ...n.model === void 0 ? {} : { model: R(n.model, "Message model") },
520
- ...n.reasoningEffort === void 0 ? {} : { reasoningEffort: R(n.reasoningEffort, "Message reasoning effort") },
521
- ...n.serviceTier === void 0 ? {} : { serviceTier: B(n.serviceTier, "Message service tier") },
522
- ...n.planMode === void 0 ? {} : { planMode: V(n.planMode, "Message plan mode") },
523
- ...i === void 0 ? {} : { skills: i },
524
- ...n.outputSchema === void 0 ? {} : { outputSchema: n.outputSchema }
524
+ ...r.content === void 0 ? {} : { content: e(r.content) },
525
+ ...o === void 0 ? {} : { inputMethod: o },
526
+ ...i === void 0 ? {} : { attachments: i },
527
+ ...r.model === void 0 ? {} : { model: B(r.model, "Message model") },
528
+ ...r.reasoningEffort === void 0 ? {} : { reasoningEffort: B(r.reasoningEffort, "Message reasoning effort") },
529
+ ...r.serviceTier === void 0 ? {} : { serviceTier: H(r.serviceTier, "Message service tier") },
530
+ ...r.planMode === void 0 ? {} : { planMode: U(r.planMode, "Message plan mode") },
531
+ ...a === void 0 ? {} : { skills: a },
532
+ ...r.outputSchema === void 0 ? {} : { outputSchema: r.outputSchema }
525
533
  };
526
534
  }
527
- async function M(e, t) {
535
+ async function P(e, t) {
528
536
  if (!Array.isArray(e)) throw TypeError("Message attachments must be an array");
529
537
  if (e.length > 0 && !t) throw TypeError("Message attachment references are not supported by this host");
530
538
  return Promise.all(e.map(async (e) => {
531
- let n = I(e, "Message attachment");
539
+ let n = R(e, "Message attachment");
532
540
  if (n.type !== "image" && n.type !== "file") throw TypeError("Message attachment type is invalid");
533
541
  let r = n.type === "image";
534
- if (L(n, r ? [
542
+ if (z(n, r ? [
535
543
  "type",
536
544
  "reference",
537
545
  "detail"
@@ -543,107 +551,107 @@ async function M(e, t) {
543
551
  ].includes(String(n.detail))) throw TypeError("Message image detail is invalid");
544
552
  let i = r ? {
545
553
  type: "image",
546
- reference: R(n.reference, "Message attachment reference"),
554
+ reference: B(n.reference, "Message attachment reference"),
547
555
  ...n.detail === void 0 ? {} : { detail: n.detail }
548
556
  } : {
549
557
  type: "file",
550
- reference: R(n.reference, "Message attachment reference")
558
+ reference: B(n.reference, "Message attachment reference")
551
559
  };
552
- return N(await t(i), i);
560
+ return F(await t(i), i);
553
561
  }));
554
562
  }
555
- function N(e, t) {
556
- let n = I(e, "Resolved message attachment");
563
+ function F(e, t) {
564
+ let n = R(e, "Resolved message attachment");
557
565
  if (n.type !== t.type) throw TypeError("Resolved message attachment type does not match");
558
566
  let r = {
559
- path: R(n.path, "Resolved message attachment path"),
560
- ...n.name === void 0 ? {} : { name: K(n.name, "Resolved message attachment name") },
561
- ...n.mimeType === void 0 ? {} : { mimeType: K(n.mimeType, "Resolved message attachment MIME type") }
567
+ path: B(n.path, "Resolved message attachment path"),
568
+ ...n.name === void 0 ? {} : { name: J(n.name, "Resolved message attachment name") },
569
+ ...n.mimeType === void 0 ? {} : { mimeType: J(n.mimeType, "Resolved message attachment MIME type") }
562
570
  };
563
571
  return t.type === "image" ? {
564
572
  type: "image",
565
573
  ...r,
566
574
  ...t.detail === void 0 ? {} : { detail: t.detail },
567
- ...n.previewUrl === void 0 ? {} : { previewUrl: q(n.previewUrl) }
575
+ ...n.previewUrl === void 0 ? {} : { previewUrl: Y(n.previewUrl) }
568
576
  } : {
569
577
  type: "file",
570
578
  ...r
571
579
  };
572
580
  }
573
- function P(e) {
581
+ function I(e) {
574
582
  if (!Array.isArray(e)) throw TypeError("Message skills must be an array");
575
583
  return e.map((e) => {
576
- let t = I(e, "Message skill");
577
- return L(t, ["name", "path"], "Message skill"), {
578
- name: R(t.name, "Message skill name"),
579
- path: R(t.path, "Message skill path")
584
+ let t = R(e, "Message skill");
585
+ return z(t, ["name", "path"], "Message skill"), {
586
+ name: B(t.name, "Message skill name"),
587
+ path: B(t.path, "Message skill path")
580
588
  };
581
589
  });
582
590
  }
583
- function F(e) {
591
+ function L(e) {
584
592
  if (e === void 0) return;
585
- let t = I(e, "Review options");
586
- if (L(t, ["target"], "Review options"), t.target === void 0) return {};
587
- let n = I(t.target, "Review target");
588
- if (n.type === "uncommittedChanges") return L(n, ["type"], "Review target"), { target: { type: "uncommittedChanges" } };
589
- if (n.type === "baseBranch") return L(n, ["type", "branch"], "Review target"), { target: {
593
+ let t = R(e, "Review options");
594
+ if (z(t, ["target"], "Review options"), t.target === void 0) return {};
595
+ let n = R(t.target, "Review target");
596
+ if (n.type === "uncommittedChanges") return z(n, ["type"], "Review target"), { target: { type: "uncommittedChanges" } };
597
+ if (n.type === "baseBranch") return z(n, ["type", "branch"], "Review target"), { target: {
590
598
  type: "baseBranch",
591
- branch: R(n.branch, "Review branch")
599
+ branch: B(n.branch, "Review branch")
592
600
  } };
593
601
  if (n.type === "commit") {
594
- if (L(n, [
602
+ if (z(n, [
595
603
  "type",
596
604
  "sha",
597
605
  "title"
598
606
  ], "Review target"), n.title !== void 0 && n.title !== null && typeof n.title != "string") throw TypeError("Review commit title must be a string or null");
599
607
  return { target: {
600
608
  type: "commit",
601
- sha: R(n.sha, "Review commit SHA"),
609
+ sha: B(n.sha, "Review commit SHA"),
602
610
  ...n.title === void 0 ? {} : { title: n.title }
603
611
  } };
604
612
  }
605
- if (n.type === "custom") return L(n, ["type", "instructions"], "Review target"), { target: {
613
+ if (n.type === "custom") return z(n, ["type", "instructions"], "Review target"), { target: {
606
614
  type: "custom",
607
- instructions: R(n.instructions, "Review instructions")
615
+ instructions: B(n.instructions, "Review instructions")
608
616
  } };
609
617
  throw TypeError("Review target type is invalid");
610
618
  }
611
- function I(e, t) {
619
+ function R(e, t) {
612
620
  if (typeof e != "object" || !e || Array.isArray(e)) throw TypeError(`${t} must be an object`);
613
621
  let n = Object.getPrototypeOf(e);
614
622
  if (n !== Object.prototype && n !== null) throw TypeError(`${t} must be a plain object`);
615
623
  if (Reflect.ownKeys(e).some((e) => typeof e == "symbol")) throw TypeError(`${t} must not contain symbol properties`);
616
624
  return e;
617
625
  }
618
- function L(e, t, n) {
626
+ function z(e, t, n) {
619
627
  let r = new Set(t), i = Object.getOwnPropertyNames(e).find((e) => !r.has(e));
620
628
  if (i) throw TypeError(`${n} contains unsupported property "${i}"`);
621
629
  }
622
- function R(e, t) {
630
+ function B(e, t) {
623
631
  if (typeof e != "string" || !e.trim()) throw TypeError(`${t} must be a non-empty string`);
624
632
  return e;
625
633
  }
626
- function z(e, t) {
627
- return e === void 0 ? void 0 : R(e, t);
634
+ function V(e, t) {
635
+ return e === void 0 ? void 0 : B(e, t);
628
636
  }
629
- function B(e, t) {
630
- return e === null ? null : R(e, t);
637
+ function H(e, t) {
638
+ return e === null ? null : B(e, t);
631
639
  }
632
- function V(e, t) {
640
+ function U(e, t) {
633
641
  if (typeof e != "boolean") throw TypeError(`${t} must be a boolean`);
634
642
  return e;
635
643
  }
636
- function H(e) {
644
+ function W(e) {
637
645
  if (e !== "approve" && e !== "deny") throw TypeError("Approval decision is invalid");
638
646
  return e;
639
647
  }
640
- function U(e) {
648
+ function G(e) {
641
649
  if (e !== void 0) {
642
650
  if (e !== "once" && e !== "session") throw TypeError("Approval scope is invalid");
643
651
  return e;
644
652
  }
645
653
  }
646
- function W(e) {
654
+ function K(e) {
647
655
  if (![
648
656
  "ask-for-approval",
649
657
  "approve-for-me",
@@ -651,21 +659,21 @@ function W(e) {
651
659
  ].includes(String(e))) throw TypeError("Conversation approval preset is invalid");
652
660
  return e;
653
661
  }
654
- function G(e) {
662
+ function q(e) {
655
663
  if (e == null) return e;
656
664
  if (typeof e != "number" || !Number.isFinite(e) || e <= 0) throw TypeError("Goal token budget must be a positive number or null");
657
665
  return e;
658
666
  }
659
- function K(e, t) {
660
- let n = R(e, t);
667
+ function J(e, t) {
668
+ let n = B(e, t);
661
669
  if (n.length > 1024) throw RangeError(`${t} is too long`);
662
670
  return n;
663
671
  }
664
- function q(e) {
672
+ function Y(e) {
665
673
  if (typeof e != "string" || e.length > 16 * 1024 * 1024 || !/^data:image\/(?:avif|bmp|gif|heic|heif|jpe?g|png|webp);base64,[a-z\d+/]+={0,2}$/i.test(e)) throw TypeError("Resolved message attachment preview must be a bounded image data URL");
666
674
  return e;
667
675
  }
668
- function J(e, t = /* @__PURE__ */ new Set()) {
676
+ function X(e, t = /* @__PURE__ */ new Set()) {
669
677
  if (e === null || typeof e == "string" || typeof e == "boolean") return !0;
670
678
  if (typeof e == "number") return Number.isFinite(e);
671
679
  if (typeof e != "object" || t.has(e) || Reflect.ownKeys(e).some((e) => typeof e == "symbol")) return !1;
@@ -677,10 +685,10 @@ function J(e, t = /* @__PURE__ */ new Set()) {
677
685
  if (t !== Object.prototype && t !== null || Object.keys(e).length !== Object.getOwnPropertyNames(e).length) return !1;
678
686
  }
679
687
  t.add(e);
680
- let n = Array.isArray(e) ? e.every((e) => J(e, t)) : Object.values(e).every((e) => J(e, t));
688
+ let n = Array.isArray(e) ? e.every((e) => X(e, t)) : Object.values(e).every((e) => X(e, t));
681
689
  return t.delete(e), n;
682
690
  }
683
691
  //#endregion
684
- export { y as a, f as c, r as d, t as f, d as i, p as l, i as m, g as n, u as o, e as p, m as r, v as s, c as t, n as u };
692
+ export { x as a, m as c, a as d, r as f, p as i, h as l, o as m, v as n, f as o, n as p, g as r, b as s, u as t, i as u };
685
693
 
686
- //# sourceMappingURL=surface-bridge-CUuIfmG5.js.map
694
+ //# sourceMappingURL=surface-bridge-DThrFjJl.js.map