@codex-app-sdk/backend 0.18.0 → 0.18.1
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
|
@@ -2065,7 +2065,12 @@ function tr(e, t, n, r, i) {
|
|
|
2065
2065
|
summaryIndex: t
|
|
2066
2066
|
} : null;
|
|
2067
2067
|
}).filter((e) => e !== null);
|
|
2068
|
-
|
|
2068
|
+
a.length === 0 && a.push({
|
|
2069
|
+
type: "reasoning",
|
|
2070
|
+
summary: "",
|
|
2071
|
+
itemId: r,
|
|
2072
|
+
summaryIndex: 0
|
|
2073
|
+
});
|
|
2069
2074
|
let o = U(e, t, n), s = K(o, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), c = s >= 0 ? o[s] : void 0;
|
|
2070
2075
|
if (!c) return o;
|
|
2071
2076
|
let l = c.parts.findIndex((e) => e.type === "reasoning" && e.itemId === r), u = c.parts.filter((e) => e.type !== "reasoning" || e.itemId !== r);
|
|
@@ -2347,7 +2352,7 @@ function yr(e, t) {
|
|
|
2347
2352
|
});
|
|
2348
2353
|
}
|
|
2349
2354
|
function br(e, t) {
|
|
2350
|
-
let n = [], r = [], i = Rr(t.startedAt ?? t.completedAt), a = 0, o = !1, s = /* @__PURE__ */ new Set(),
|
|
2355
|
+
let n = [], r = [], i = Rr(t.startedAt ?? t.completedAt), a = 0, o = !1, s = !1, c = /* @__PURE__ */ new Set(), l = () => {
|
|
2351
2356
|
if (r.length === 0) return;
|
|
2352
2357
|
let o = a === 0 ? "" : `-segment-${a}`;
|
|
2353
2358
|
n.push({
|
|
@@ -2365,11 +2370,11 @@ function br(e, t) {
|
|
|
2365
2370
|
};
|
|
2366
2371
|
for (let a of Array.isArray(t.items) ? t.items : []) {
|
|
2367
2372
|
if (a.type === "userMessage") {
|
|
2368
|
-
let r = Tr(a),
|
|
2373
|
+
let r = Tr(a), s = Dr(a);
|
|
2369
2374
|
if (r.length > 0) {
|
|
2370
2375
|
let u = o, d = u ? null : JSON.stringify(r);
|
|
2371
|
-
if (d &&
|
|
2372
|
-
d &&
|
|
2376
|
+
if (d && c.has(d)) continue;
|
|
2377
|
+
d && c.add(d), l(), n.push({
|
|
2373
2378
|
id: a.clientId ?? `user-${e}-${t.id}-${a.id ?? n.length}`,
|
|
2374
2379
|
...u ? { kind: "steer" } : {},
|
|
2375
2380
|
role: "user",
|
|
@@ -2380,8 +2385,8 @@ function br(e, t) {
|
|
|
2380
2385
|
metadata: {
|
|
2381
2386
|
conversationId: e,
|
|
2382
2387
|
turnId: t.id,
|
|
2383
|
-
...
|
|
2384
|
-
asyncQuestionRequestIds:
|
|
2388
|
+
...s.length > 0 ? {
|
|
2389
|
+
asyncQuestionRequestIds: s,
|
|
2385
2390
|
asyncQuestionAnswers: Or(a)
|
|
2386
2391
|
} : {}
|
|
2387
2392
|
}
|
|
@@ -2390,7 +2395,7 @@ function br(e, t) {
|
|
|
2390
2395
|
continue;
|
|
2391
2396
|
}
|
|
2392
2397
|
if (a.type === "contextCompaction") {
|
|
2393
|
-
o = !0,
|
|
2398
|
+
o = !0, l();
|
|
2394
2399
|
let r = `compaction-${t.id}`;
|
|
2395
2400
|
n.some((e) => e.id === r) || n.push({
|
|
2396
2401
|
id: r,
|
|
@@ -2408,10 +2413,12 @@ function br(e, t) {
|
|
|
2408
2413
|
continue;
|
|
2409
2414
|
}
|
|
2410
2415
|
if (a.type === "agentMessage") {
|
|
2411
|
-
let n = typeof a.text == "string" ? a.text : ""
|
|
2412
|
-
|
|
2416
|
+
let n = typeof a.text == "string" ? a.text : "";
|
|
2417
|
+
a.phase === "final_answer" && n.trim() && (s = !0);
|
|
2418
|
+
let i = Sr(e, t.id, a, !0), c = a.phase === "final_answer" ? ir(n) : null;
|
|
2419
|
+
c && !i ? c.visibleText && (o = !0, r.push({
|
|
2413
2420
|
type: "text",
|
|
2414
|
-
text:
|
|
2421
|
+
text: c.visibleText,
|
|
2415
2422
|
itemId: a.id,
|
|
2416
2423
|
...a.phase ? { phase: a.phase } : {}
|
|
2417
2424
|
})) : n && !i && (o = !0, r.push({
|
|
@@ -2427,7 +2434,10 @@ function br(e, t) {
|
|
|
2427
2434
|
summary: e.trim(),
|
|
2428
2435
|
summaryIndex: t
|
|
2429
2436
|
})).filter(({ summary: e }) => e.length > 0);
|
|
2430
|
-
e.length
|
|
2437
|
+
e.length === 0 && s && e.push({
|
|
2438
|
+
summary: "",
|
|
2439
|
+
summaryIndex: 0
|
|
2440
|
+
}), e.length > 0 && (o = !0, r.push(...e.map(({ summary: e, summaryIndex: t }) => ({
|
|
2431
2441
|
type: "reasoning",
|
|
2432
2442
|
summary: e,
|
|
2433
2443
|
itemId: a.id,
|
|
@@ -2444,12 +2454,12 @@ function br(e, t) {
|
|
|
2444
2454
|
}));
|
|
2445
2455
|
continue;
|
|
2446
2456
|
}
|
|
2447
|
-
let
|
|
2448
|
-
|
|
2449
|
-
let
|
|
2450
|
-
|
|
2457
|
+
let u = R(a);
|
|
2458
|
+
u && (o = !0, r.push(u));
|
|
2459
|
+
let d = wr(a);
|
|
2460
|
+
d.length && (o = !0, r.push(...d));
|
|
2451
2461
|
}
|
|
2452
|
-
return
|
|
2462
|
+
return l(), t.status === "inProgress" ? n : ur(n, t.id, t.status);
|
|
2453
2463
|
}
|
|
2454
2464
|
function xr(e, t, n) {
|
|
2455
2465
|
let r = Rr(t.startedAt);
|
|
@@ -2694,7 +2704,7 @@ function kr(e) {
|
|
|
2694
2704
|
}
|
|
2695
2705
|
function Ar(e) {
|
|
2696
2706
|
if (!q(e) || typeof e.type != "string") return null;
|
|
2697
|
-
if (e.type === "mention" && typeof e.path == "string") {
|
|
2707
|
+
if (e.type === "mention" && typeof e.path == "string" && !e.path.startsWith("plugin://")) {
|
|
2698
2708
|
let t = typeof e.name == "string" && e.name.trim() ? e.name.trim() : jr(e.path, "File"), n = Mr(e.path);
|
|
2699
2709
|
return {
|
|
2700
2710
|
kind: "file",
|
|
@@ -3158,7 +3168,6 @@ var ri = class {
|
|
|
3158
3168
|
return;
|
|
3159
3169
|
}
|
|
3160
3170
|
if (e.item.type === "reasoning") {
|
|
3161
|
-
if (e.item.summary.filter((e) => e.trim().length > 0).length === 0) return;
|
|
3162
3171
|
let t = this.host.assistantMessageForTurn(e.threadId, e.turnId), r = t ? JSON.stringify(t.parts) : null;
|
|
3163
3172
|
this.host.patchRuntime(e.threadId, { messages: tr(n.messages, e.threadId, e.turnId, e.item.id, e.item.summary) });
|
|
3164
3173
|
let i = this.host.assistantMessageForTurn(e.threadId, e.turnId);
|
|
@@ -3201,7 +3210,7 @@ var ri = class {
|
|
|
3201
3210
|
if (e.item.type === "agentMessage" && this.reviewOutputByTurn.get(i) === t) return;
|
|
3202
3211
|
e.item.type === "exitedReviewMode" && this.reviewOutputByTurn.set(i, t);
|
|
3203
3212
|
let a = new Set(n.messages.map((e) => e.id)), o = this.host.assistantMessageForTurn(e.threadId, e.turnId), s = o ? JSON.stringify(o.parts) : null, c = new Set(o?.parts.flatMap((e) => e.type === "question" ? [e.request.id] : []) ?? []), l = n.messages.flatMap((e) => e.parts).find((t) => t.type === "text" && t.itemId === e.item.id)?.text ?? "", u = e.item.type === "agentMessage" ? Sr(e.threadId, e.turnId, e.item) : null, d = u ? "" : t, f = u ? rr(n.messages, e.threadId, e.turnId, e.item.id) : nr(n.messages, e.threadId, e.turnId, e.item.id, t, r);
|
|
3204
|
-
if (u && (f = or(f, e.threadId, e.turnId, u)), this.host.patchRuntime(e.threadId, { messages: f }), !d && !u) return;
|
|
3213
|
+
if (u && (f = or(f, e.threadId, e.turnId, u)), this.host.patchRuntime(e.threadId, { messages: f }), !d && !u && !r) return;
|
|
3205
3214
|
let p = this.host.assistantMessageForTurn(e.threadId, e.turnId);
|
|
3206
3215
|
if (p && !a.has(p.id)) this.host.emitEvent("notification", {
|
|
3207
3216
|
type: "message.appended",
|
|
@@ -3209,7 +3218,7 @@ var ri = class {
|
|
|
3209
3218
|
turnId: e.turnId,
|
|
3210
3219
|
payload: { message: structuredClone(p) }
|
|
3211
3220
|
});
|
|
3212
|
-
else if (p &&
|
|
3221
|
+
else if (p && JSON.stringify(p.parts) !== s && (u || d === l)) this.host.emitEvent("notification", {
|
|
3213
3222
|
type: "message.updated",
|
|
3214
3223
|
conversationId: e.threadId,
|
|
3215
3224
|
turnId: e.turnId,
|