@codex-app-sdk/backend 0.18.1 → 0.18.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/dist/index.js CHANGED
@@ -3521,9 +3521,7 @@ var oi = class {
3521
3521
  }), this.host.emitConversationActivity(n.threadId, "action");
3522
3522
  }
3523
3523
  async respondToAsyncQuestion(e, t) {
3524
- let n = e ?? this.host.activeConversationId(), r = n === null ? null : this.host.requireRuntime(n), i = null;
3525
- for (let e of r?.messages ?? []) for (let n of e.parts) n.type === "question" && !n.historical && n.request.id === t.id && (i = n.request);
3526
- let a = r && i ? {
3524
+ let n = e ?? this.host.activeConversationId(), r = n === null ? null : this.host.requireRuntime(n), i = r && Ct(r, [], []).clientRequests.find((e) => e.kind === "ask_user" && e.id === t.id), a = r && i ? {
3527
3525
  request: i,
3528
3526
  runtime: r
3529
3527
  } : null;
@@ -6164,7 +6162,8 @@ var Ui = class {
6164
6162
  return [...this.require(e).messages].reverse().find((e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === t) ?? null;
6165
6163
  }
6166
6164
  markTurnActive(e, t) {
6167
- e.activeTurnId = t, e.busy = !0, e.turnStartPending = !1, e.turnIds.includes(t) || e.turnIds.push(t), e.turns = Z(e.turns, {
6165
+ let n = e.turnIds.includes(t) ? [] : this.projection(e).clientRequests.filter((e) => e.kind === "ask_user" && e.payload.request.delivery === "async" && e.turnId && e.turnId !== t);
6166
+ if (e.activeTurnId = t, e.busy = !0, e.turnStartPending = !1, e.turnIds.includes(t) || e.turnIds.push(t), e.turns = Z(e.turns, {
6168
6167
  id: t,
6169
6168
  status: "inProgress",
6170
6169
  error: null,
@@ -6172,7 +6171,19 @@ var Ui = class {
6172
6171
  startedAt: null,
6173
6172
  completedAt: null,
6174
6173
  durationMs: null
6175
- });
6174
+ }), n.length > 0) {
6175
+ this.patch(e.threadId, { answeredClientRequestIds: [.../* @__PURE__ */ new Set([...e.answeredClientRequestIds, ...n.map((e) => e.id)])] });
6176
+ for (let t of n) this.host.emitEvent("notification", {
6177
+ type: "clientRequest.resolved",
6178
+ conversationId: e.threadId,
6179
+ turnId: t.turnId ?? void 0,
6180
+ payload: {
6181
+ request: structuredClone(t),
6182
+ response: null,
6183
+ reason: "server"
6184
+ }
6185
+ });
6186
+ }
6176
6187
  }
6177
6188
  patchConversationStatus(e, t, n = "notification") {
6178
6189
  let r = this.host.getState();