codexuse-cli 3.7.4 → 3.7.6
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 +3 -1
- package/dist/index.js.map +1 -1
- package/dist/server/{NodeSqliteClient-BPNNnMBz.mjs → NodeSqliteClient-8mlwim6r.mjs} +3 -3
- package/dist/server/{SqlClient-B-Bb00hw.mjs → SqlClient-8hJa5MAm.mjs} +2 -1
- package/dist/server/{SqlError-3S4KD3xN.mjs → SqlError-4YSIrGT4.mjs} +2 -2
- package/dist/server/{SqliteClient-9lnXlJby.mjs → SqliteClient-DkbUL5wr.mjs} +3 -3
- package/dist/server/index.mjs +470 -368
- package/package.json +1 -1
package/dist/server/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
-
import { $ as is, $a as fromInputUnsafe, $i as succeed$1, $n as cached, $o as structure, $r as serviceOption, $t as splitLines, A as Record, Aa as scope, Ai as mergeAll, An as makeUnsafe$1, Ao as isNone, Ar as logError$1, At as make$21, B as Void, Ba as void_$2, Bi as provide$2, Bn as InvalidValue$1, Bo as PipeInspectableProto, Br as orElseSucceed, Bt as fromIterable$1, C as Literal, Ca as forkDetach, Ci as Class, Cn as shutdown, Co as isFailure$1, Cr as gen, Ct as Path$1, D as Null, Da as ignore$1, Di as effectDiscard, Dn as unbounded$1, Do as getOrElse, Dr as isEffect, Dt as FileTypeId, E as NonEmptyString, Ea as gen$1, Ei as effect, En as publish, Eo as fromNullishOr, Er as interrupt, Et as FileSystem, F as Trim, Fa as succeedNone, Fi as unwrap$1, Fn as nominal, Fo as some, Fr as matchCauseEffect, Ft as empty$4, G as decodeTo, Ga as Reference, Gi as isDone, Gn as acquireUseRelease, Go as BaseProto, Gr as result, Gt as make$30, H as declare, Ha as CurrentLogSpans, Hi as doneUnsafe, Hn as make$31, Ho as exitSucceed, Hr as provide, Ht as fromQueue, I as Tuple, Ia as suspend$1, Ii as Scope, In as transform$1, Io as Number$2, Ir as matchEffect, It as fail$5, J as decodeUnknownSync, Ja as empty$5, Ji as succeed$5, Jn as andThen, Jo as format$1, Jr as runPromiseWith, Jt as onExit$1, K as decodeUnknownEffect, Ka as Service, Ki as make$27, Kn as addFinalizer$1, Ko as Class$1, Kr as runFork, Kt as merge$1, L as URLFromString, La as sync$1, Li as addFinalizer, Ln as transformOrFail, Lo as make$26, Lr as never, Lt as flatMap$2, M as Struct, Ma as servicesWith, Mi as provideMerge, Mn as BadArgument, Mo as map$4, Mr as logWarning$1, Mt as concat, N as TaggedErrorClass, Na as sleep$1, Ni as succeed$2, Nn as badArgument, No as match, Nr as map$2, Nt as decodeText, O as NullOr, Oa as loggerMake, On as make$20, Oo as getOrNull, Or as log$1, Ot as Size, P as TemplateLiteral, Pa as succeed$3, Pi as sync$2, Pn as systemError, Po as none, Pr as mapError, Q as fromJsonString, Qa as merge$2, Qi as isSuccess, Qn as asVoid, Qo as array, Qr as service, Qt as runForEach, R as Union, Ra as uninterruptibleMask, Ri as close, Rn as parseJson, Ro as make$32, Rr as onInterrupt, Rt as fromChannel$1, S as Int, Sa as forever$1, Si as clamp, Sn as offerUnsafe, So as failVoid, Sr as forkScoped, St as omit, T as NonEmptyArray, Ta as formatLogSpan, Ti as TaggedError, Tn as unbounded, To as filter$1, Tr as ignoreCause, Tt as FileDescriptor, U as decodeEffect, Ua as MinimumLogLevel, Ui as fail$4, Un as encodeBase64Url, Uo as isEffect$1, Ur as provideService, Ut as fromReadableStream, V as brand, Va as CurrentLogAnnotations, Vi as _await, Vn as makeFormatterDefault, Vo as YieldableProto, Vr as promise, Vt as fromPubSub, W as decodeExit, Wa as DisablePropagation, Wi as failCause$1, Wn as acquireRelease, Wo as withFiber, Wr as provideServices, Wt as isStream, X as encodeEffect, Xi as hasInterrupts$1, Xn as as, Xo as symbolRedactable, Xt as runCollect, Y as encode, Ya as get$4, Yi as fail, Yn as annotateLogs, Yo as redact$1, Yr as runSync, Yt as run$2, Z as encodeUnknownEffect, Za as make$25, Zi as isFailure, Zn as asSome$1, Zo as symbol, Zr as scoped, Zt as runFold, _ as url, _a as causePretty, _i as withFiber$1, _n as endUnsafe, _o as makeEquivalence, _r as forEach, _t as toJsonSchemaDocument, aa as fail$2, ai as sync, an as make$22, ao as toMillis, ar as catchTags, as as isUndefined, at as isMaxProperties, b as Defect, ba as flatMap$1, bi as zipWith, bn as offer$1, bo as makeEquivalence$2, br as forkDetach$1, bt as withDecodingDefault, c as FalseValues, ca as pretty, ci as timeoutOption, cn as isSink, co as filter, cr as effectify, cs as constVoid, ct as isPattern, d as boolean$3, da as ConsoleRef, di as try_, dn as make$29, do as isArray, dr as fail$1, ds as pipe, dt as makeFilter, ea as void_$3, ei as services, en as suspend$3, eo as infinity, er as callback, es as symbol$1, et as isBetween, f as map$5, fa as CurrentLoggers$1, fi as uninterruptible, fn as get$3, fo as isReadonlyArrayNonEmpty, fr as failCause, fs as pipeArguments, ft as mutable, ga as asSome, gi as void_$1, gn as size, go as sort, gr as fnUntraced, gt as toCodecStringTree, h as string$3, ha as as$1, hi as useSpan, hn as set$3, ho as of, hr as fn, ht as tag, ia as done, ii as suspend, in as get$2, io as seconds, ir as catchTag, is as isNullish, it as isMaxLength, j as String$1, ja as scopeAddFinalizerExit, ji as provide$1, jo as isSome, jr as logInfo$1, jt as callback$1, k as Number$1, ka as onExit, ki as empty$6, kn as set$4, ko as getOrUndefined, kr as logDebug, kt as WatchBackend, l as TrueValues, la as squash, li as timeoutOrElse, ln as fromTransform, lo as flatMapNullishOr, lr as ensuring, ls as dual, lt as isSchemaError, m as port, ma as andThen$1, mi as updateServices$1, mn as remove$2, mo as map$3, mr as flatMap, mt as suspend$2, n as SqlClient, na as NoSuchElementError, ni as succeed, nn as transduce, no as isZero, nr as catchDefect, ns as isNotNull, nt as isGreaterThanOrEqualTo, oa as hasInterrupts, oi as tap, on as drain, oo as zero, or as catch_, os as constFalse, ot as isMinLength, p as option, pa as addFinalizer$2, pi as uninterruptibleMask$1, pn as make$24, po as makeEquivalence$1, pr as filterOrFail, pt as optional$2, q as decodeUnknownExit, qi as makeUnsafe$2, qn as all, qo as NodeInspectSymbol, qr as runPromise, qt as mkString, ra as UnknownError, ri as succeedNone$1, rn as unwrap, ro as minutes, rr as catchFilter, rs as isNotUndefined, rt as isLessThanOrEqualTo, s as Boolean$1, sa as hasInterruptsOnly, si as tapCause, sn as fromChannel, so as ensure, sr as die, ss as constTrue, st as isNonEmpty, ta as Done, ti as servicesWith$1, tn as toReadableStreamEffect, to as isFinite$1, tr as catchCause, ts as hasProperty, tt as isGreaterThan, u as all$1, ua as ClockRef, ui as tryPromise, un as mapDone, uo as fromIterable$2, ur as exit, us as identity, ut as link$1, v as Array$1, va as defaultLogger$1, vi as withParentSpan, vn as failCauseUnsafe, vo as map$6, vr as forever, vt as toType, w as Literals, wa as formatLabel, wi as Error$1, wn as take, wo as succeed$4, wr as ignore, wt as TypeId$17, x as ErrorClass, xa as fnUntraced$1, xi as catchDone, xn as offerAll, xo as fail$3, xr as forkIn, xt as assign, y as Boolean$2, ya as fiberInterrupt, yi as withSpan, yn as make$23, yo as filterMap, yr as forkChild, yt as withConstructorDefault, z as Unknown, za as updateServices, zi as make$28, zn as stringifyJson, zo as strictEqual, zr as orDie, zt as fromEffect } from "./SqlClient-
|
|
3
|
+
import { $ as is, $a as fromInputUnsafe, $i as succeed$1, $n as cached, $o as structure, $r as serviceOption, $t as splitLines, A as Record, Aa as scope, Ai as mergeAll, An as makeUnsafe$1, Ao as isNone, Ar as logError$1, At as make$21, B as Void, Ba as void_$2, Bi as provide$2, Bn as InvalidValue$1, Bo as PipeInspectableProto, Br as orElseSucceed, Bt as fromIterable$1, C as Literal, Ca as forkDetach, Ci as Class, Cn as shutdown, Co as isFailure$1, Cr as gen, Ct as Path$1, D as Null, Da as ignore$1, Di as effectDiscard, Dn as unbounded$1, Do as getOrElse, Dr as isEffect, Dt as FileTypeId, E as NonEmptyString, Ea as gen$1, Ei as effect, En as publish, Eo as fromNullishOr, Er as interrupt, Et as FileSystem, F as Trim, Fa as succeedNone, Fi as unwrap$1, Fn as nominal, Fo as some, Fr as matchCauseEffect, Ft as empty$4, G as decodeTo, Ga as Reference, Gi as isDone, Gn as acquireUseRelease, Go as BaseProto, Gr as result, Gt as make$30, H as declare, Ha as CurrentLogSpans, Hi as doneUnsafe, Hn as make$31, Ho as exitSucceed, Hr as provide, Ht as fromQueue, I as Tuple, Ia as suspend$1, Ii as Scope, In as transform$1, Io as Number$2, Ir as matchEffect, It as fail$5, J as decodeUnknownSync, Ja as empty$5, Ji as succeed$5, Jn as andThen, Jo as format$1, Jr as runPromiseWith, Jt as onExit$1, K as decodeUnknownEffect, Ka as Service, Ki as make$27, Kn as addFinalizer$1, Ko as Class$1, Kr as runFork, Kt as merge$1, L as URLFromString, La as sync$1, Li as addFinalizer, Ln as transformOrFail, Lo as make$26, Lr as never, Lt as flatMap$2, M as Struct, Ma as servicesWith, Mi as provideMerge, Mn as BadArgument, Mo as map$4, Mr as logWarning$1, Mt as concat, N as TaggedErrorClass, Na as sleep$1, Ni as succeed$2, Nn as badArgument, No as match, Nr as map$2, Nt as decodeText, O as NullOr, Oa as loggerMake, On as make$20, Oo as getOrNull, Or as log$1, Ot as Size, P as TemplateLiteral, Pa as succeed$3, Pi as sync$2, Pn as systemError, Po as none, Pr as mapError, Q as fromJsonString, Qa as merge$2, Qi as isSuccess, Qn as asVoid, Qo as array, Qr as service, Qt as runForEach, R as Union, Ra as uninterruptibleMask, Ri as close, Rn as parseJson, Ro as make$32, Rr as onInterrupt, Rt as fromChannel$1, S as Int, Sa as forever$1, Si as clamp, Sn as offerUnsafe, So as failVoid, Sr as forkScoped, St as omit, T as NonEmptyArray, Ta as formatLogSpan, Ti as TaggedError, Tn as unbounded, To as filter$1, Tr as ignoreCause, Tt as FileDescriptor, U as decodeEffect, Ua as MinimumLogLevel, Ui as fail$4, Un as encodeBase64Url, Uo as isEffect$1, Ur as provideService, Ut as fromReadableStream, V as brand, Va as CurrentLogAnnotations, Vi as _await, Vn as makeFormatterDefault, Vo as YieldableProto, Vr as promise, Vt as fromPubSub, W as decodeExit, Wa as DisablePropagation, Wi as failCause$1, Wn as acquireRelease, Wo as withFiber, Wr as provideServices, Wt as isStream, X as encodeEffect, Xi as hasInterrupts$1, Xn as as, Xo as symbolRedactable, Xt as runCollect, Y as encode, Ya as get$4, Yi as fail, Yn as annotateLogs, Yo as redact$1, Yr as runSync, Yt as run$2, Z as encodeUnknownEffect, Za as make$25, Zi as isFailure, Zn as asSome$1, Zo as symbol, Zr as scoped, Zt as runFold, _ as url, _a as causePretty, _i as withFiber$1, _n as endUnsafe, _o as makeEquivalence, _r as forEach, _t as toJsonSchemaDocument, aa as fail$2, ai as sync, an as make$22, ao as toMillis, ar as catchTags, as as isUndefined, at as isMaxProperties, b as Defect, ba as flatMap$1, bi as zipWith, bn as offer$1, bo as makeEquivalence$2, br as forkDetach$1, bt as withDecodingDefault, c as FalseValues, ca as pretty, ci as timeoutOption, cn as isSink, co as filter, cr as effectify, cs as constVoid, ct as isPattern, d as boolean$3, da as ConsoleRef, di as try_, dn as make$29, do as isArray, dr as fail$1, ds as pipe, dt as makeFilter, ea as void_$3, ei as services, en as suspend$3, eo as infinity, er as callback, es as symbol$1, et as isBetween, f as map$5, fa as CurrentLoggers$1, fi as uninterruptible, fn as get$3, fo as isReadonlyArrayNonEmpty, fr as failCause, fs as pipeArguments, ft as mutable, ga as asSome, gi as void_$1, gn as size, go as sort, gr as fnUntraced, gt as toCodecStringTree, h as string$3, ha as as$1, hi as useSpan, hn as set$3, ho as of, hr as fn, ht as tag, ia as done, ii as suspend, in as get$2, io as seconds, ir as catchTag, is as isNullish, it as isMaxLength, j as String$1, ja as scopeAddFinalizerExit, ji as provide$1, jo as isSome, jr as logInfo$1, jt as callback$1, k as Number$1, ka as onExit, ki as empty$6, kn as set$4, ko as getOrUndefined, kr as logDebug, kt as WatchBackend, l as TrueValues, la as squash, li as timeoutOrElse, ln as fromTransform, lo as flatMapNullishOr, lr as ensuring, ls as dual, lt as isSchemaError, m as port, ma as andThen$1, mi as updateServices$1, mn as remove$2, mo as map$3, mr as flatMap, mt as suspend$2, n as SqlClient, na as NoSuchElementError, ni as succeed, nn as transduce, no as isZero, nr as catchDefect, ns as isNotNull, nt as isGreaterThanOrEqualTo, oa as hasInterrupts, oi as tap, on as drain, oo as zero, or as catch_, os as constFalse, ot as isMinLength, p as option, pa as addFinalizer$2, pi as uninterruptibleMask$1, pn as make$24, po as makeEquivalence$1, pr as filterOrFail, pt as optional$2, q as decodeUnknownExit, qi as makeUnsafe$2, qn as all, qo as NodeInspectSymbol, qr as runPromise, qt as mkString, ra as UnknownError, ri as succeedNone$1, rn as unwrap, ro as minutes, rr as catchFilter, rs as isNotUndefined, rt as isLessThanOrEqualTo, s as Boolean$1, sa as hasInterruptsOnly, si as tapCause, sn as fromChannel, so as ensure, sr as die, ss as constTrue, st as isNonEmpty, ta as Done, ti as servicesWith$1, tn as toReadableStreamEffect, to as isFinite$1, tr as catchCause, ts as hasProperty, tt as isGreaterThan, u as all$1, ua as ClockRef, ui as tryPromise, un as mapDone, uo as fromIterable$2, ur as exit, us as identity, ut as link$1, v as Array$1, va as defaultLogger$1, vi as withParentSpan, vn as failCauseUnsafe, vo as map$6, vr as forever, vt as toType, w as Literals, wa as formatLabel, wi as Error$1, wn as take, wo as succeed$4, wr as ignore, wt as TypeId$17, x as ErrorClass, xa as fnUntraced$1, xi as catchDone, xn as offerAll, xo as fail$3, xr as forkIn, xt as assign, y as Boolean$2, ya as fiberInterrupt, yi as withSpan, yn as make$23, yo as filterMap, yr as forkChild, yt as withConstructorDefault, z as Unknown, za as updateServices, zi as make$28, zn as stringifyJson, zo as strictEqual, zr as orDie, zt as fromEffect } from "./SqlClient-8hJa5MAm.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import * as NodeChildProcess from "node:child_process";
|
|
6
6
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
@@ -7773,6 +7773,11 @@ var require_anchors = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
7773
7773
|
prevAnchors.add(anchor);
|
|
7774
7774
|
return anchor;
|
|
7775
7775
|
},
|
|
7776
|
+
/**
|
|
7777
|
+
* With circular references, the source node is only resolved after all
|
|
7778
|
+
* of its child nodes are. This is why anchors are set only after all of
|
|
7779
|
+
* the nodes have been created.
|
|
7780
|
+
*/
|
|
7776
7781
|
setAnchors: () => {
|
|
7777
7782
|
for (const source of aliasObjects) {
|
|
7778
7783
|
const ref = sourceObjects.get(source);
|
|
@@ -9520,6 +9525,14 @@ var require_binary = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
9520
9525
|
identify: (value) => value instanceof Uint8Array,
|
|
9521
9526
|
default: false,
|
|
9522
9527
|
tag: "tag:yaml.org,2002:binary",
|
|
9528
|
+
/**
|
|
9529
|
+
* Returns a Buffer in node and an Uint8Array in browsers
|
|
9530
|
+
*
|
|
9531
|
+
* To use the resulting buffer as an image, you'll want to do something like:
|
|
9532
|
+
*
|
|
9533
|
+
* const blob = new Blob([buffer], { type: 'image/jpeg' })
|
|
9534
|
+
* document.querySelector('#photo').src = URL.createObjectURL(blob)
|
|
9535
|
+
*/
|
|
9523
9536
|
resolve(src, onError) {
|
|
9524
9537
|
if (typeof node_buffer.Buffer === "function") return node_buffer.Buffer.from(src, "base64");
|
|
9525
9538
|
else if (typeof atob === "function") {
|
|
@@ -17076,6 +17089,10 @@ const CodexModelOptions = Struct({
|
|
|
17076
17089
|
});
|
|
17077
17090
|
const ProviderModelOptions = Struct({ codex: optional$2(CodexModelOptions) });
|
|
17078
17091
|
const MODEL_OPTIONS_BY_PROVIDER = { codex: [
|
|
17092
|
+
{
|
|
17093
|
+
slug: "gpt-5.5",
|
|
17094
|
+
name: "GPT-5.5"
|
|
17095
|
+
},
|
|
17079
17096
|
{
|
|
17080
17097
|
slug: "gpt-5.4",
|
|
17081
17098
|
name: "GPT-5.4"
|
|
@@ -17091,19 +17108,12 @@ const MODEL_OPTIONS_BY_PROVIDER = { codex: [
|
|
|
17091
17108
|
{
|
|
17092
17109
|
slug: "gpt-5.3-codex-spark",
|
|
17093
17110
|
name: "GPT-5.3 Codex Spark"
|
|
17094
|
-
},
|
|
17095
|
-
{
|
|
17096
|
-
slug: "gpt-5.2-codex",
|
|
17097
|
-
name: "GPT-5.2 Codex"
|
|
17098
|
-
},
|
|
17099
|
-
{
|
|
17100
|
-
slug: "gpt-5.2",
|
|
17101
|
-
name: "GPT-5.2"
|
|
17102
17111
|
}
|
|
17103
17112
|
] };
|
|
17104
|
-
const DEFAULT_MODEL_BY_PROVIDER = { codex: "gpt-5.
|
|
17113
|
+
const DEFAULT_MODEL_BY_PROVIDER = { codex: "gpt-5.5" };
|
|
17105
17114
|
const DEFAULT_GIT_TEXT_GENERATION_MODEL = "gpt-5.4-mini";
|
|
17106
17115
|
const MODEL_SLUG_ALIASES_BY_PROVIDER = { codex: {
|
|
17116
|
+
"5.5": "gpt-5.5",
|
|
17107
17117
|
"5.4": "gpt-5.4",
|
|
17108
17118
|
"5.3": "gpt-5.3-codex",
|
|
17109
17119
|
"gpt-5.3": "gpt-5.3-codex",
|
|
@@ -19305,6 +19315,7 @@ const WS_METHODS = {
|
|
|
19305
19315
|
agentsReadFile: "agents.readFile",
|
|
19306
19316
|
agentsSaveFile: "agents.saveFile",
|
|
19307
19317
|
codexRuntimeInspect: "codexRuntime.inspect",
|
|
19318
|
+
codexRuntimeUpdate: "codexRuntime.update",
|
|
19308
19319
|
telegramStatus: "telegram.status",
|
|
19309
19320
|
telegramTestToken: "telegram.testToken",
|
|
19310
19321
|
profilesFetch: "profiles.fetch",
|
|
@@ -19426,6 +19437,7 @@ const WebSocketRequestBody = Union([
|
|
|
19426
19437
|
args: optional$2(Union([String$1, Null])),
|
|
19427
19438
|
codexHomePath: optional$2(Union([String$1, Null]))
|
|
19428
19439
|
})),
|
|
19440
|
+
tagRequestBody(WS_METHODS.codexRuntimeUpdate, Struct({})),
|
|
19429
19441
|
tagRequestBody(WS_METHODS.telegramStatus, Struct({})),
|
|
19430
19442
|
tagRequestBody(WS_METHODS.telegramTestToken, Struct({ token: optional$2(Unknown) })),
|
|
19431
19443
|
tagRequestBody(WS_METHODS.accountPoolGetStatus, Struct({})),
|
|
@@ -20360,7 +20372,7 @@ var _018_CanonicalizeModelSelections_default = gen(function* () {
|
|
|
20360
20372
|
SET payload_json = json_set(
|
|
20361
20373
|
payload_json,
|
|
20362
20374
|
'$.modelSelection',
|
|
20363
|
-
json(json_object('provider', 'codex', 'model', 'gpt-5.
|
|
20375
|
+
json(json_object('provider', 'codex', 'model', 'gpt-5.5'))
|
|
20364
20376
|
)
|
|
20365
20377
|
WHERE event_type = 'thread.created'
|
|
20366
20378
|
AND json_type(payload_json, '$.modelSelection') IS NULL
|
|
@@ -20551,8 +20563,8 @@ const runMigrations = gen(function* () {
|
|
|
20551
20563
|
//#endregion
|
|
20552
20564
|
//#region src/persistence/Layers/Sqlite.ts
|
|
20553
20565
|
const defaultSqliteClientLoaders = {
|
|
20554
|
-
bun: () => import("./SqliteClient-
|
|
20555
|
-
node: () => import("./NodeSqliteClient-
|
|
20566
|
+
bun: () => import("./SqliteClient-DkbUL5wr.mjs"),
|
|
20567
|
+
node: () => import("./NodeSqliteClient-8mlwim6r.mjs")
|
|
20556
20568
|
};
|
|
20557
20569
|
const makeRuntimeSqliteLayer = (config) => gen(function* () {
|
|
20558
20570
|
const loader = defaultSqliteClientLoaders[process.versions.bun !== void 0 ? "bun" : "node"];
|
|
@@ -24353,7 +24365,13 @@ const loadProjectedReadModelSummaryFromRepositories = (repositories) => gen(func
|
|
|
24353
24365
|
activities: [],
|
|
24354
24366
|
checkpoints: []
|
|
24355
24367
|
})));
|
|
24356
|
-
const
|
|
24368
|
+
const eagerlyHydratedThreadIds = threadSummaries.filter((thread) => thread.session !== null && thread.session.status !== "idle" && thread.session.status !== "stopped" && thread.session.status !== "ready").map((thread) => thread.id);
|
|
24369
|
+
yield* logInfo$1("Bootstrapping projected read model from projection tables", {
|
|
24370
|
+
projectCount: projects.length,
|
|
24371
|
+
threadCount: threadSummaries.length,
|
|
24372
|
+
eagerlyHydratedThreadCount: eagerlyHydratedThreadIds.length
|
|
24373
|
+
});
|
|
24374
|
+
const activeThreads = yield* forEach(eagerlyHydratedThreadIds, (threadId) => loadProjectedThreadFromRepositories(repositories, threadId), { concurrency: 4 });
|
|
24357
24375
|
const activeThreadById = new Map(activeThreads.filter((thread) => thread !== null).map((thread) => [thread.id, thread]));
|
|
24358
24376
|
const threads = threadSummaries.map((thread) => activeThreadById.get(thread.id) ?? thread);
|
|
24359
24377
|
const projectedProjects = projects.map(toOrchestrationProject);
|
|
@@ -24594,10 +24612,18 @@ function normalizeSpawnError(command, args, error) {
|
|
|
24594
24612
|
if (error.code === "ENOENT") return /* @__PURE__ */ new Error(`Command not found: ${command}`);
|
|
24595
24613
|
return /* @__PURE__ */ new Error(`Failed to run ${commandLabel$1(command, args)}: ${error.message}`);
|
|
24596
24614
|
}
|
|
24615
|
+
const WINDOWS_COMMAND_NOT_FOUND_PATTERNS = [
|
|
24616
|
+
/is not recognized as an internal or external command/i,
|
|
24617
|
+
/n.o . reconhecido como um comando interno/i,
|
|
24618
|
+
/non . riconosciuto come comando interno o esterno/i,
|
|
24619
|
+
/n.est pas reconnu en tant que commande interne/i,
|
|
24620
|
+
/no se reconoce como un comando interno o externo/i,
|
|
24621
|
+
/wird nicht als interner oder externer befehl/i
|
|
24622
|
+
];
|
|
24597
24623
|
function isWindowsCommandNotFound(code, stderr) {
|
|
24598
24624
|
if (process.platform !== "win32") return false;
|
|
24599
24625
|
if (code === 9009) return true;
|
|
24600
|
-
return
|
|
24626
|
+
return WINDOWS_COMMAND_NOT_FOUND_PATTERNS.some((pattern) => pattern.test(stderr));
|
|
24601
24627
|
}
|
|
24602
24628
|
function normalizeExitError(command, args, result) {
|
|
24603
24629
|
if (isWindowsCommandNotFound(result.code, result.stderr)) return /* @__PURE__ */ new Error(`Command not found: ${command}`);
|
|
@@ -28980,7 +29006,7 @@ function createDefaultAppState() {
|
|
|
28980
29006
|
}
|
|
28981
29007
|
};
|
|
28982
29008
|
}
|
|
28983
|
-
function asString$
|
|
29009
|
+
function asString$9(value) {
|
|
28984
29010
|
if (typeof value !== "string") return null;
|
|
28985
29011
|
const trimmed = value.trim();
|
|
28986
29012
|
return trimmed.length > 0 ? trimmed : null;
|
|
@@ -28995,19 +29021,19 @@ function normalizeAppState(raw) {
|
|
|
28995
29021
|
if (!Number.isFinite(merged.autoRoll.switchThreshold)) merged.autoRoll.switchThreshold = 95;
|
|
28996
29022
|
if (merged.autoRoll.warningThreshold < 50 || merged.autoRoll.warningThreshold > 99) merged.autoRoll.warningThreshold = 85;
|
|
28997
29023
|
if (merged.autoRoll.switchThreshold <= merged.autoRoll.warningThreshold || merged.autoRoll.switchThreshold > 100) merged.autoRoll.switchThreshold = Math.min(100, Math.max(merged.autoRoll.warningThreshold + 1, 95));
|
|
28998
|
-
merged.app.lastAppVersion = asString$
|
|
28999
|
-
merged.app.pendingUpdateVersion = asString$
|
|
29000
|
-
merged.app.lastProfileName = asString$
|
|
29024
|
+
merged.app.lastAppVersion = asString$9(merged.app.lastAppVersion);
|
|
29025
|
+
merged.app.pendingUpdateVersion = asString$9(merged.app.pendingUpdateVersion);
|
|
29026
|
+
merged.app.lastProfileName = asString$9(merged.app.lastProfileName);
|
|
29001
29027
|
{
|
|
29002
29028
|
const allowedAppKeys = new Set(Object.keys(defaults.app));
|
|
29003
29029
|
for (const key of Object.keys(merged.app)) if (!allowedAppKeys.has(key)) delete merged.app[key];
|
|
29004
29030
|
}
|
|
29005
|
-
merged.license.licenseKey = asString$
|
|
29006
|
-
merged.license.purchaseEmail = asString$
|
|
29007
|
-
merged.license.lastVerifiedAt = asString$
|
|
29008
|
-
merged.license.nextCheckAt = asString$
|
|
29009
|
-
merged.license.lastVerificationError = asString$
|
|
29010
|
-
merged.license.signature = asString$
|
|
29031
|
+
merged.license.licenseKey = asString$9(merged.license.licenseKey);
|
|
29032
|
+
merged.license.purchaseEmail = asString$9(merged.license.purchaseEmail);
|
|
29033
|
+
merged.license.lastVerifiedAt = asString$9(merged.license.lastVerifiedAt);
|
|
29034
|
+
merged.license.nextCheckAt = asString$9(merged.license.nextCheckAt);
|
|
29035
|
+
merged.license.lastVerificationError = asString$9(merged.license.lastVerificationError);
|
|
29036
|
+
merged.license.signature = asString$9(merged.license.signature);
|
|
29011
29037
|
if (![
|
|
29012
29038
|
"inactive",
|
|
29013
29039
|
"active",
|
|
@@ -29033,15 +29059,15 @@ function normalizeAppState(raw) {
|
|
|
29033
29059
|
if (typeof merged.ui.layout.sidebarCollapsed !== "boolean") merged.ui.layout.sidebarCollapsed = null;
|
|
29034
29060
|
if (!isRecord$7(merged.ui.profiles)) merged.ui.profiles = clone(defaults.ui.profiles);
|
|
29035
29061
|
merged.ui.profiles.viewMode = merged.ui.profiles.viewMode === "cards" || merged.ui.profiles.viewMode === "compact" ? merged.ui.profiles.viewMode : null;
|
|
29036
|
-
merged.ui.profiles.sortBy = asString$
|
|
29037
|
-
merged.ui.profiles.groupBy = asString$
|
|
29038
|
-
merged.ui.profiles.planFilter = asString$
|
|
29039
|
-
merged.ui.profiles.healthFilter = asString$
|
|
29040
|
-
merged.ui.profiles.customGroupFilter = asString$
|
|
29062
|
+
merged.ui.profiles.sortBy = asString$9(merged.ui.profiles.sortBy);
|
|
29063
|
+
merged.ui.profiles.groupBy = asString$9(merged.ui.profiles.groupBy);
|
|
29064
|
+
merged.ui.profiles.planFilter = asString$9(merged.ui.profiles.planFilter);
|
|
29065
|
+
merged.ui.profiles.healthFilter = asString$9(merged.ui.profiles.healthFilter);
|
|
29066
|
+
merged.ui.profiles.customGroupFilter = asString$9(merged.ui.profiles.customGroupFilter);
|
|
29041
29067
|
if (typeof merged.ui.profiles.toolbarOpen !== "boolean") merged.ui.profiles.toolbarOpen = null;
|
|
29042
29068
|
if (!isRecord$7(merged.ui.profiles.collapsedSections)) merged.ui.profiles.collapsedSections = {};
|
|
29043
29069
|
else merged.ui.profiles.collapsedSections = Object.fromEntries(Object.entries(merged.ui.profiles.collapsedSections).flatMap(([key, value]) => {
|
|
29044
|
-
const normalizedKey = asString$
|
|
29070
|
+
const normalizedKey = asString$9(key);
|
|
29045
29071
|
if (!normalizedKey || typeof value !== "boolean") return [];
|
|
29046
29072
|
return [[normalizedKey, value]];
|
|
29047
29073
|
}));
|
|
@@ -29055,24 +29081,24 @@ function normalizeAppState(raw) {
|
|
|
29055
29081
|
if (!Number.isFinite(merged.ui.onboarding.sessionCount)) merged.ui.onboarding.sessionCount = 0;
|
|
29056
29082
|
if (!isRecord$7(merged.ui.onboarding.nudgeCooldowns)) merged.ui.onboarding.nudgeCooldowns = {};
|
|
29057
29083
|
else merged.ui.onboarding.nudgeCooldowns = Object.fromEntries(Object.entries(merged.ui.onboarding.nudgeCooldowns).flatMap(([key, value]) => {
|
|
29058
|
-
const normalizedKey = asString$
|
|
29084
|
+
const normalizedKey = asString$9(key);
|
|
29059
29085
|
if (!normalizedKey || !Number.isFinite(value)) return [];
|
|
29060
29086
|
return [[normalizedKey, Number(value)]];
|
|
29061
29087
|
}));
|
|
29062
29088
|
if (!isRecord$7(merged.ui.onboarding.nudgeDismissCount)) merged.ui.onboarding.nudgeDismissCount = {};
|
|
29063
29089
|
else merged.ui.onboarding.nudgeDismissCount = Object.fromEntries(Object.entries(merged.ui.onboarding.nudgeDismissCount).flatMap(([key, value]) => {
|
|
29064
|
-
const normalizedKey = asString$
|
|
29090
|
+
const normalizedKey = asString$9(key);
|
|
29065
29091
|
if (!normalizedKey || !Number.isFinite(value)) return [];
|
|
29066
29092
|
return [[normalizedKey, Number(value)]];
|
|
29067
29093
|
}));
|
|
29068
29094
|
if (typeof merged.ui.onboarding.proUnlockedCelebrated !== "boolean") merged.ui.onboarding.proUnlockedCelebrated = false;
|
|
29069
29095
|
if (!isRecord$7(merged.ui.projectThreadSelections)) merged.ui.projectThreadSelections = {};
|
|
29070
29096
|
else merged.ui.projectThreadSelections = Object.fromEntries(Object.entries(merged.ui.projectThreadSelections).flatMap(([projectId, threadId]) => {
|
|
29071
|
-
const normalizedProjectId = asString$
|
|
29097
|
+
const normalizedProjectId = asString$9(projectId);
|
|
29072
29098
|
if (!normalizedProjectId) return [];
|
|
29073
29099
|
return [[normalizedProjectId, typeof threadId === "string" && threadId.trim().length > 0 ? threadId.trim() : null]];
|
|
29074
29100
|
}));
|
|
29075
|
-
merged.ui.duplicateWarningDismissedKey = asString$
|
|
29101
|
+
merged.ui.duplicateWarningDismissedKey = asString$9(merged.ui.duplicateWarningDismissedKey);
|
|
29076
29102
|
if (typeof merged.ui.pendingLicenseActivation !== "boolean") merged.ui.pendingLicenseActivation = false;
|
|
29077
29103
|
{
|
|
29078
29104
|
const allowedUiKeys = new Set(Object.keys(defaults.ui));
|
|
@@ -29081,8 +29107,8 @@ function normalizeAppState(raw) {
|
|
|
29081
29107
|
if (!isRecord$7(merged.profileDashboard)) merged.profileDashboard = clone(defaults.profileDashboard);
|
|
29082
29108
|
if (!isRecord$7(merged.profileDashboard.customGroupsByAccountKey)) merged.profileDashboard.customGroupsByAccountKey = {};
|
|
29083
29109
|
else merged.profileDashboard.customGroupsByAccountKey = Object.fromEntries(Object.entries(merged.profileDashboard.customGroupsByAccountKey).flatMap(([key, value]) => {
|
|
29084
|
-
const normalizedKey = asString$
|
|
29085
|
-
const normalizedValue = asString$
|
|
29110
|
+
const normalizedKey = asString$9(key);
|
|
29111
|
+
const normalizedValue = asString$9(value);
|
|
29086
29112
|
if (!normalizedKey || !normalizedValue) return [];
|
|
29087
29113
|
return [[normalizedKey, normalizedValue]];
|
|
29088
29114
|
}));
|
|
@@ -29109,19 +29135,19 @@ function normalizeAppState(raw) {
|
|
|
29109
29135
|
if (!Array.isArray(merged.skills.sources)) merged.skills.sources = [];
|
|
29110
29136
|
if (!isRecord$7(merged.skills.installsBySlug)) merged.skills.installsBySlug = {};
|
|
29111
29137
|
if (!isRecord$7(merged.sync)) merged.sync = clone(defaults.sync);
|
|
29112
|
-
merged.sync.lastPushAt = asString$
|
|
29113
|
-
merged.sync.lastPullAt = asString$
|
|
29114
|
-
merged.sync.lastError = asString$
|
|
29115
|
-
merged.sync.remoteUpdatedAt = asString$
|
|
29138
|
+
merged.sync.lastPushAt = asString$9(merged.sync.lastPushAt);
|
|
29139
|
+
merged.sync.lastPullAt = asString$9(merged.sync.lastPullAt);
|
|
29140
|
+
merged.sync.lastError = asString$9(merged.sync.lastError);
|
|
29141
|
+
merged.sync.remoteUpdatedAt = asString$9(merged.sync.remoteUpdatedAt);
|
|
29116
29142
|
if (!isRecord$7(merged.analytics)) merged.analytics = isRecord$7(merged.telemetry) ? clone(merged.telemetry) : clone(defaults.analytics);
|
|
29117
|
-
merged.analytics.anonymousId = asString$
|
|
29143
|
+
merged.analytics.anonymousId = asString$9(merged.analytics.anonymousId);
|
|
29118
29144
|
if (!merged.analytics.anonymousId) {
|
|
29119
|
-
const legacyInstallId = asString$
|
|
29145
|
+
const legacyInstallId = asString$9(merged.telemetry?.installId);
|
|
29120
29146
|
merged.analytics.anonymousId = legacyInstallId;
|
|
29121
29147
|
}
|
|
29122
29148
|
if (typeof merged.analytics.enabled !== "boolean") merged.analytics.enabled = true;
|
|
29123
|
-
merged.analytics.lastFlushAt = asString$
|
|
29124
|
-
merged.analytics.lastError = asString$
|
|
29149
|
+
merged.analytics.lastFlushAt = asString$9(merged.analytics.lastFlushAt);
|
|
29150
|
+
merged.analytics.lastError = asString$9(merged.analytics.lastError);
|
|
29125
29151
|
if ("telemetry" in merged) delete merged.telemetry;
|
|
29126
29152
|
if (!isRecord$7(merged.profilesByName)) merged.profilesByName = {};
|
|
29127
29153
|
if (!isRecord$7(merged.migration)) merged.migration = clone(defaults.migration);
|
|
@@ -29130,10 +29156,10 @@ function normalizeAppState(raw) {
|
|
|
29130
29156
|
"pending_local_storage",
|
|
29131
29157
|
"complete"
|
|
29132
29158
|
].includes(merged.migration.status)) merged.migration.status = "pending";
|
|
29133
|
-
merged.migration.startedAt = asString$
|
|
29134
|
-
merged.migration.completedAt = asString$
|
|
29135
|
-
merged.migration.localStorageImportedAt = asString$
|
|
29136
|
-
merged.migration.lastError = asString$
|
|
29159
|
+
merged.migration.startedAt = asString$9(merged.migration.startedAt);
|
|
29160
|
+
merged.migration.completedAt = asString$9(merged.migration.completedAt);
|
|
29161
|
+
merged.migration.localStorageImportedAt = asString$9(merged.migration.localStorageImportedAt);
|
|
29162
|
+
merged.migration.lastError = asString$9(merged.migration.lastError);
|
|
29137
29163
|
return merged;
|
|
29138
29164
|
}
|
|
29139
29165
|
function deepMerge(base, patch) {
|
|
@@ -29330,7 +29356,7 @@ function normalizeAutoRollSettings(raw) {
|
|
|
29330
29356
|
}
|
|
29331
29357
|
//#endregion
|
|
29332
29358
|
//#region ../../packages/runtime-codex/src/codex/settings.ts
|
|
29333
|
-
function asString$
|
|
29359
|
+
function asString$8(value) {
|
|
29334
29360
|
if (typeof value !== "string") return null;
|
|
29335
29361
|
const trimmed = value.trim();
|
|
29336
29362
|
return trimmed.length > 0 ? trimmed : null;
|
|
@@ -29348,7 +29374,7 @@ function parseAutoRoll(raw) {
|
|
|
29348
29374
|
}
|
|
29349
29375
|
function parseStoredLicense(raw) {
|
|
29350
29376
|
if (!isRecord$6(raw)) return null;
|
|
29351
|
-
const statusCandidate = asString$
|
|
29377
|
+
const statusCandidate = asString$8(raw.status);
|
|
29352
29378
|
const status = [
|
|
29353
29379
|
"inactive",
|
|
29354
29380
|
"active",
|
|
@@ -29356,21 +29382,21 @@ function parseStoredLicense(raw) {
|
|
|
29356
29382
|
"error"
|
|
29357
29383
|
].includes(statusCandidate ?? "") ? statusCandidate : void 0;
|
|
29358
29384
|
const license = {
|
|
29359
|
-
licenseKey: asString$
|
|
29360
|
-
purchaseEmail: asString$
|
|
29361
|
-
lastVerifiedAt: asString$
|
|
29362
|
-
nextCheckAt: asString$
|
|
29363
|
-
lastVerificationError: asString$
|
|
29385
|
+
licenseKey: asString$8(raw.licenseKey ?? raw.license_key),
|
|
29386
|
+
purchaseEmail: asString$8(raw.purchaseEmail ?? raw.purchase_email),
|
|
29387
|
+
lastVerifiedAt: asString$8(raw.lastVerifiedAt ?? raw.last_verified_at),
|
|
29388
|
+
nextCheckAt: asString$8(raw.nextCheckAt ?? raw.next_check_at),
|
|
29389
|
+
lastVerificationError: asString$8(raw.lastVerificationError ?? raw.last_verification_error),
|
|
29364
29390
|
status,
|
|
29365
|
-
signature: asString$
|
|
29391
|
+
signature: asString$8(raw.signature)
|
|
29366
29392
|
};
|
|
29367
29393
|
return Boolean(license.licenseKey || license.purchaseEmail || license.lastVerifiedAt || license.nextCheckAt || license.lastVerificationError || license.status) ? license : null;
|
|
29368
29394
|
}
|
|
29369
29395
|
async function getLastProfileName() {
|
|
29370
|
-
return asString$
|
|
29396
|
+
return asString$8((await getAppState()).app.lastProfileName);
|
|
29371
29397
|
}
|
|
29372
29398
|
async function persistLastProfileName(profileName) {
|
|
29373
|
-
await patchAppState({ app: { lastProfileName: asString$
|
|
29399
|
+
await patchAppState({ app: { lastProfileName: asString$8(profileName) } });
|
|
29374
29400
|
}
|
|
29375
29401
|
async function getStoredLicense() {
|
|
29376
29402
|
return parseStoredLicense((await getAppState()).license);
|
|
@@ -29435,9 +29461,9 @@ async function writeCodexSettingsJsonRaw(payload) {
|
|
|
29435
29461
|
const license = parseStoredLicense(payload.license);
|
|
29436
29462
|
await patchAppState({
|
|
29437
29463
|
app: {
|
|
29438
|
-
lastProfileName: asString$
|
|
29439
|
-
lastAppVersion: asString$
|
|
29440
|
-
pendingUpdateVersion: asString$
|
|
29464
|
+
lastProfileName: asString$8(payload.lastProfileName ?? payload.last_profile_name),
|
|
29465
|
+
lastAppVersion: asString$8(payload.lastAppVersion ?? payload.last_app_version),
|
|
29466
|
+
pendingUpdateVersion: asString$8(payload.pendingUpdateVersion ?? payload.pending_update_version)
|
|
29441
29467
|
},
|
|
29442
29468
|
autoRoll: autoRoll ? {
|
|
29443
29469
|
enabled: autoRoll.enabled,
|
|
@@ -30190,6 +30216,83 @@ function buildCodexCommand$1(binaryPath, args, env) {
|
|
|
30190
30216
|
};
|
|
30191
30217
|
}
|
|
30192
30218
|
//#endregion
|
|
30219
|
+
//#region ../../packages/runtime-codex/src/codex/home.ts
|
|
30220
|
+
function resolveHomeDir$1() {
|
|
30221
|
+
return process.env.HOME || process.env.USERPROFILE || os.homedir();
|
|
30222
|
+
}
|
|
30223
|
+
function expandHomePrefix(input, homeDir) {
|
|
30224
|
+
if (input === "~") return homeDir;
|
|
30225
|
+
if (input.startsWith("~/") || input.startsWith("~\\")) return path.join(homeDir, input.slice(2));
|
|
30226
|
+
return input;
|
|
30227
|
+
}
|
|
30228
|
+
function normalizePathCandidate(value) {
|
|
30229
|
+
if (typeof value !== "string") return null;
|
|
30230
|
+
const trimmed = value.trim();
|
|
30231
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
30232
|
+
}
|
|
30233
|
+
function normalizeCodexHomePath(input) {
|
|
30234
|
+
const configured = normalizePathCandidate(input);
|
|
30235
|
+
if (!configured) return null;
|
|
30236
|
+
return path.resolve(expandHomePrefix(configured, resolveHomeDir$1()));
|
|
30237
|
+
}
|
|
30238
|
+
function resolveDefaultCodexHomeDir() {
|
|
30239
|
+
return path.join(resolveHomeDir$1(), ".codex");
|
|
30240
|
+
}
|
|
30241
|
+
function resolveProfileCodexHomeDir(profileName) {
|
|
30242
|
+
return path.join(getUserDataDir(), "profile-homes", profileName);
|
|
30243
|
+
}
|
|
30244
|
+
function resolveCodexHomeDir(options) {
|
|
30245
|
+
return normalizeCodexHomePath(options?.codexHomePath) ?? resolveDefaultCodexHomeDir();
|
|
30246
|
+
}
|
|
30247
|
+
async function resolveCodexRuntimeContext(options) {
|
|
30248
|
+
const explicit = normalizeCodexHomePath(options?.codexHomePath);
|
|
30249
|
+
if (explicit) return {
|
|
30250
|
+
codexHomePath: explicit,
|
|
30251
|
+
profileName: null,
|
|
30252
|
+
source: "explicit"
|
|
30253
|
+
};
|
|
30254
|
+
const state = await getAppState();
|
|
30255
|
+
const profileName = normalizePathCandidate(state.app.lastProfileName);
|
|
30256
|
+
if (profileName && state.profilesByName[profileName]) return {
|
|
30257
|
+
codexHomePath: resolveProfileCodexHomeDir(profileName),
|
|
30258
|
+
profileName,
|
|
30259
|
+
source: "profile"
|
|
30260
|
+
};
|
|
30261
|
+
const configured = normalizeCodexHomePath(state.runtimeSettings?.codexHome);
|
|
30262
|
+
if (configured) return {
|
|
30263
|
+
codexHomePath: configured,
|
|
30264
|
+
profileName: null,
|
|
30265
|
+
source: "settings"
|
|
30266
|
+
};
|
|
30267
|
+
return {
|
|
30268
|
+
codexHomePath: resolveDefaultCodexHomeDir(),
|
|
30269
|
+
profileName: null,
|
|
30270
|
+
source: "default"
|
|
30271
|
+
};
|
|
30272
|
+
}
|
|
30273
|
+
async function resolveExternalCodexRuntimeContext(options) {
|
|
30274
|
+
const explicit = normalizeCodexHomePath(options?.codexHomePath);
|
|
30275
|
+
if (explicit) return {
|
|
30276
|
+
codexHomePath: explicit,
|
|
30277
|
+
profileName: null,
|
|
30278
|
+
source: "explicit"
|
|
30279
|
+
};
|
|
30280
|
+
const configured = normalizeCodexHomePath((await getAppState()).runtimeSettings?.codexHome);
|
|
30281
|
+
if (configured) return {
|
|
30282
|
+
codexHomePath: configured,
|
|
30283
|
+
profileName: null,
|
|
30284
|
+
source: "settings"
|
|
30285
|
+
};
|
|
30286
|
+
return {
|
|
30287
|
+
codexHomePath: resolveDefaultCodexHomeDir(),
|
|
30288
|
+
profileName: null,
|
|
30289
|
+
source: "default"
|
|
30290
|
+
};
|
|
30291
|
+
}
|
|
30292
|
+
async function resolveGlobalCodexRuntimeContext(options) {
|
|
30293
|
+
return resolveExternalCodexRuntimeContext(options);
|
|
30294
|
+
}
|
|
30295
|
+
//#endregion
|
|
30193
30296
|
//#region ../../packages/contracts/src/apps/rpc.ts
|
|
30194
30297
|
const APPS_LIST_METHODS = new Set([
|
|
30195
30298
|
"app/list",
|
|
@@ -30288,7 +30391,7 @@ function isThreadNotFoundError$1(error) {
|
|
|
30288
30391
|
const lower = message.toLowerCase();
|
|
30289
30392
|
return lower.includes("thread not found") || lower.includes("rollout");
|
|
30290
30393
|
}
|
|
30291
|
-
function asString$
|
|
30394
|
+
function asString$7(value) {
|
|
30292
30395
|
return typeof value === "string" ? value : value != null ? String(value) : "";
|
|
30293
30396
|
}
|
|
30294
30397
|
function isInlineImageValue(value) {
|
|
@@ -30297,11 +30400,11 @@ function isInlineImageValue(value) {
|
|
|
30297
30400
|
}
|
|
30298
30401
|
function normalizeSendUserMessageItem(value) {
|
|
30299
30402
|
if (!isRecord$5(value)) return null;
|
|
30300
|
-
const type = asString$
|
|
30403
|
+
const type = asString$7(value.type).trim();
|
|
30301
30404
|
if (!type) return null;
|
|
30302
30405
|
const data = isRecord$5(value.data) ? value.data : {};
|
|
30303
30406
|
if (type === "text") {
|
|
30304
|
-
const text = asString$
|
|
30407
|
+
const text = asString$7(data.text ?? value.text);
|
|
30305
30408
|
if (!text.trim()) return null;
|
|
30306
30409
|
return {
|
|
30307
30410
|
type: "text",
|
|
@@ -30309,7 +30412,7 @@ function normalizeSendUserMessageItem(value) {
|
|
|
30309
30412
|
};
|
|
30310
30413
|
}
|
|
30311
30414
|
if (type === "image") {
|
|
30312
|
-
const imageUrl = asString$
|
|
30415
|
+
const imageUrl = asString$7(data.image_url ?? data.imageUrl ?? data.url ?? value.image_url ?? value.imageUrl ?? value.url).trim();
|
|
30313
30416
|
if (!imageUrl) return null;
|
|
30314
30417
|
return {
|
|
30315
30418
|
type: "image",
|
|
@@ -30317,7 +30420,7 @@ function normalizeSendUserMessageItem(value) {
|
|
|
30317
30420
|
};
|
|
30318
30421
|
}
|
|
30319
30422
|
if (type === "localImage") {
|
|
30320
|
-
const path = asString$
|
|
30423
|
+
const path = asString$7(data.path ?? value.path).trim();
|
|
30321
30424
|
if (!path) return null;
|
|
30322
30425
|
return {
|
|
30323
30426
|
type: "localImage",
|
|
@@ -30328,12 +30431,12 @@ function normalizeSendUserMessageItem(value) {
|
|
|
30328
30431
|
}
|
|
30329
30432
|
function normalizeTurnInputParams(params) {
|
|
30330
30433
|
const normalized = { ...params };
|
|
30331
|
-
const threadId = asString$
|
|
30332
|
-
if (threadId && !asString$
|
|
30333
|
-
const expectedTurnId = asString$
|
|
30334
|
-
if (expectedTurnId && !asString$
|
|
30335
|
-
const turnId = asString$
|
|
30336
|
-
if (turnId && !asString$
|
|
30434
|
+
const threadId = asString$7(params.threadId ?? params.thread_id ?? params.conversationId ?? params.conversation_id ?? "").trim();
|
|
30435
|
+
if (threadId && !asString$7(params.threadId).trim()) normalized.threadId = threadId;
|
|
30436
|
+
const expectedTurnId = asString$7(params.expectedTurnId ?? params.expected_turn_id ?? params.turnId ?? params.turn_id ?? "").trim();
|
|
30437
|
+
if (expectedTurnId && !asString$7(params.expectedTurnId).trim()) normalized.expectedTurnId = expectedTurnId;
|
|
30438
|
+
const turnId = asString$7(params.turnId ?? params.turn_id ?? expectedTurnId).trim();
|
|
30439
|
+
if (turnId && !asString$7(params.turnId).trim()) normalized.turnId = turnId;
|
|
30337
30440
|
const providedInput = Array.isArray(params.input) ? params.input.filter((entry) => isRecord$5(entry)) : [];
|
|
30338
30441
|
if (providedInput.length > 0) {
|
|
30339
30442
|
normalized.input = providedInput;
|
|
@@ -30342,17 +30445,17 @@ function normalizeTurnInputParams(params) {
|
|
|
30342
30445
|
const providedItems = Array.isArray(params.items) ? params.items.map((item) => normalizeSendUserMessageItem(item)).filter((item) => item !== null) : [];
|
|
30343
30446
|
if (providedItems.length > 0) {
|
|
30344
30447
|
const input = providedItems.flatMap((item) => {
|
|
30345
|
-
const type = asString$
|
|
30448
|
+
const type = asString$7(item.type).trim();
|
|
30346
30449
|
const data = isRecord$5(item.data) ? item.data : item;
|
|
30347
30450
|
if (type === "text") {
|
|
30348
|
-
const text = asString$
|
|
30451
|
+
const text = asString$7(data.text).trim();
|
|
30349
30452
|
return text ? [{
|
|
30350
30453
|
type: "text",
|
|
30351
30454
|
text
|
|
30352
30455
|
}] : [];
|
|
30353
30456
|
}
|
|
30354
30457
|
if (type === "localImage") {
|
|
30355
|
-
const path = asString$
|
|
30458
|
+
const path = asString$7(data.path).trim();
|
|
30356
30459
|
return path ? [{
|
|
30357
30460
|
type: "localImage",
|
|
30358
30461
|
path
|
|
@@ -30366,13 +30469,13 @@ function normalizeTurnInputParams(params) {
|
|
|
30366
30469
|
}
|
|
30367
30470
|
}
|
|
30368
30471
|
const input = [];
|
|
30369
|
-
const text = asString$
|
|
30472
|
+
const text = asString$7(params.text);
|
|
30370
30473
|
if (text.trim()) input.push({
|
|
30371
30474
|
type: "text",
|
|
30372
30475
|
text
|
|
30373
30476
|
});
|
|
30374
30477
|
if (Array.isArray(params.images)) for (const candidate of params.images) {
|
|
30375
|
-
const image = asString$
|
|
30478
|
+
const image = asString$7(candidate).trim();
|
|
30376
30479
|
if (!image || isInlineImageValue(image)) continue;
|
|
30377
30480
|
input.push({
|
|
30378
30481
|
type: "localImage",
|
|
@@ -30423,7 +30526,7 @@ function getRequestTimeoutMs(method) {
|
|
|
30423
30526
|
return DEFAULT_REQUEST_TIMEOUT_MS;
|
|
30424
30527
|
}
|
|
30425
30528
|
function normalizeThreadLiveWorkspaceId(value) {
|
|
30426
|
-
return asString$
|
|
30529
|
+
return asString$7(value).trim() || DEFAULT_THREAD_LIVE_WORKSPACE_ID;
|
|
30427
30530
|
}
|
|
30428
30531
|
function threadLiveKey(workspaceId, threadId) {
|
|
30429
30532
|
return `${workspaceId}:${threadId}`;
|
|
@@ -30489,7 +30592,7 @@ var CodexAppServer = class extends EventEmitter {
|
|
|
30489
30592
|
this.threadLiveSubscriptionIdByKey = /* @__PURE__ */ new Map();
|
|
30490
30593
|
this.threadLiveModeByKey = /* @__PURE__ */ new Map();
|
|
30491
30594
|
this.addConversationListenerSupported = null;
|
|
30492
|
-
this.homePath = options?.homePath
|
|
30595
|
+
this.homePath = normalizeCodexHomePath(options?.homePath);
|
|
30493
30596
|
this.setMaxListeners(50);
|
|
30494
30597
|
}
|
|
30495
30598
|
async start() {
|
|
@@ -30627,8 +30730,8 @@ var CodexAppServer = class extends EventEmitter {
|
|
|
30627
30730
|
}
|
|
30628
30731
|
async addConversationListener(params) {
|
|
30629
30732
|
if (this.addConversationListenerSupported === false) return {};
|
|
30630
|
-
const conversationId = asString$
|
|
30631
|
-
const workspaceId = asString$
|
|
30733
|
+
const conversationId = asString$7(params.conversationId ?? params.threadId ?? params.thread_id ?? "").trim();
|
|
30734
|
+
const workspaceId = asString$7(params.workspaceId ?? params.workspace_id ?? "").trim();
|
|
30632
30735
|
if (!conversationId) try {
|
|
30633
30736
|
const response = await this.request("addConversationListener", params);
|
|
30634
30737
|
this.addConversationListenerSupported = true;
|
|
@@ -30656,7 +30759,7 @@ var CodexAppServer = class extends EventEmitter {
|
|
|
30656
30759
|
}
|
|
30657
30760
|
async threadLiveSubscribe(params) {
|
|
30658
30761
|
const workspaceId = normalizeThreadLiveWorkspaceId(params.workspaceId ?? params.workspace_id);
|
|
30659
|
-
const threadId = asString$
|
|
30762
|
+
const threadId = asString$7(params.threadId ?? params.thread_id ?? params.conversationId).trim();
|
|
30660
30763
|
if (!threadId) return {};
|
|
30661
30764
|
const key = threadLiveKey(workspaceId, threadId);
|
|
30662
30765
|
this.threadLiveModeByKey.set(key, "listener");
|
|
@@ -30665,7 +30768,7 @@ var CodexAppServer = class extends EventEmitter {
|
|
|
30665
30768
|
}
|
|
30666
30769
|
async threadLiveUnsubscribe(params) {
|
|
30667
30770
|
const workspaceId = normalizeThreadLiveWorkspaceId(params.workspaceId ?? params.workspace_id);
|
|
30668
|
-
const threadId = asString$
|
|
30771
|
+
const threadId = asString$7(params.threadId ?? params.thread_id ?? params.conversationId).trim();
|
|
30669
30772
|
if (!threadId) return {};
|
|
30670
30773
|
const key = threadLiveKey(workspaceId, threadId);
|
|
30671
30774
|
this.threadLiveModeByKey.delete(key);
|
|
@@ -31136,83 +31239,6 @@ var CodexAppServer = class extends EventEmitter {
|
|
|
31136
31239
|
}
|
|
31137
31240
|
};
|
|
31138
31241
|
//#endregion
|
|
31139
|
-
//#region ../../packages/runtime-codex/src/codex/home.ts
|
|
31140
|
-
function resolveHomeDir$1() {
|
|
31141
|
-
return process.env.HOME || process.env.USERPROFILE || os.homedir();
|
|
31142
|
-
}
|
|
31143
|
-
function expandHomePrefix(input, homeDir) {
|
|
31144
|
-
if (input === "~") return homeDir;
|
|
31145
|
-
if (input.startsWith("~/") || input.startsWith("~\\")) return path.join(homeDir, input.slice(2));
|
|
31146
|
-
return input;
|
|
31147
|
-
}
|
|
31148
|
-
function normalizePathCandidate(value) {
|
|
31149
|
-
if (typeof value !== "string") return null;
|
|
31150
|
-
const trimmed = value.trim();
|
|
31151
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
31152
|
-
}
|
|
31153
|
-
function normalizeCodexHomePath(input) {
|
|
31154
|
-
const configured = normalizePathCandidate(input);
|
|
31155
|
-
if (!configured) return null;
|
|
31156
|
-
return path.resolve(expandHomePrefix(configured, resolveHomeDir$1()));
|
|
31157
|
-
}
|
|
31158
|
-
function resolveDefaultCodexHomeDir() {
|
|
31159
|
-
return path.join(resolveHomeDir$1(), ".codex");
|
|
31160
|
-
}
|
|
31161
|
-
function resolveProfileCodexHomeDir(profileName) {
|
|
31162
|
-
return path.join(getUserDataDir(), "profile-homes", profileName);
|
|
31163
|
-
}
|
|
31164
|
-
function resolveCodexHomeDir(options) {
|
|
31165
|
-
return normalizeCodexHomePath(options?.codexHomePath) ?? resolveDefaultCodexHomeDir();
|
|
31166
|
-
}
|
|
31167
|
-
async function resolveCodexRuntimeContext(options) {
|
|
31168
|
-
const explicit = normalizeCodexHomePath(options?.codexHomePath);
|
|
31169
|
-
if (explicit) return {
|
|
31170
|
-
codexHomePath: explicit,
|
|
31171
|
-
profileName: null,
|
|
31172
|
-
source: "explicit"
|
|
31173
|
-
};
|
|
31174
|
-
const state = await getAppState();
|
|
31175
|
-
const profileName = normalizePathCandidate(state.app.lastProfileName);
|
|
31176
|
-
if (profileName && state.profilesByName[profileName]) return {
|
|
31177
|
-
codexHomePath: resolveProfileCodexHomeDir(profileName),
|
|
31178
|
-
profileName,
|
|
31179
|
-
source: "profile"
|
|
31180
|
-
};
|
|
31181
|
-
const configured = normalizeCodexHomePath(state.runtimeSettings?.codexHome);
|
|
31182
|
-
if (configured) return {
|
|
31183
|
-
codexHomePath: configured,
|
|
31184
|
-
profileName: null,
|
|
31185
|
-
source: "settings"
|
|
31186
|
-
};
|
|
31187
|
-
return {
|
|
31188
|
-
codexHomePath: resolveDefaultCodexHomeDir(),
|
|
31189
|
-
profileName: null,
|
|
31190
|
-
source: "default"
|
|
31191
|
-
};
|
|
31192
|
-
}
|
|
31193
|
-
async function resolveExternalCodexRuntimeContext(options) {
|
|
31194
|
-
const explicit = normalizeCodexHomePath(options?.codexHomePath);
|
|
31195
|
-
if (explicit) return {
|
|
31196
|
-
codexHomePath: explicit,
|
|
31197
|
-
profileName: null,
|
|
31198
|
-
source: "explicit"
|
|
31199
|
-
};
|
|
31200
|
-
const configured = normalizeCodexHomePath((await getAppState()).runtimeSettings?.codexHome);
|
|
31201
|
-
if (configured) return {
|
|
31202
|
-
codexHomePath: configured,
|
|
31203
|
-
profileName: null,
|
|
31204
|
-
source: "settings"
|
|
31205
|
-
};
|
|
31206
|
-
return {
|
|
31207
|
-
codexHomePath: resolveDefaultCodexHomeDir(),
|
|
31208
|
-
profileName: null,
|
|
31209
|
-
source: "default"
|
|
31210
|
-
};
|
|
31211
|
-
}
|
|
31212
|
-
async function resolveGlobalCodexRuntimeContext(options) {
|
|
31213
|
-
return resolveExternalCodexRuntimeContext(options);
|
|
31214
|
-
}
|
|
31215
|
-
//#endregion
|
|
31216
31242
|
//#region src/migrations/legacy-codexuse/parityStore.ts
|
|
31217
31243
|
const STORE_FILE = "workspace-parity.json";
|
|
31218
31244
|
const LEGACY_STORE_FILE = "workspace-parity.json";
|
|
@@ -31404,14 +31430,14 @@ async function listParityWorkspaces() {
|
|
|
31404
31430
|
//#region src/externalThreadOverrides.ts
|
|
31405
31431
|
const EXTERNAL_THREAD_OVERRIDES_DOCUMENT = "desktop.external-thread-overrides.v1";
|
|
31406
31432
|
const EXTERNAL_THREAD_OVERRIDES_VERSION = 1;
|
|
31407
|
-
function asRecord$
|
|
31433
|
+
function asRecord$4(value) {
|
|
31408
31434
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
31409
31435
|
}
|
|
31410
31436
|
function normalizeOptionalTitle(value) {
|
|
31411
31437
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
31412
31438
|
}
|
|
31413
31439
|
function sanitizeOverride(value) {
|
|
31414
|
-
const record = asRecord$
|
|
31440
|
+
const record = asRecord$4(value);
|
|
31415
31441
|
if (!record) return null;
|
|
31416
31442
|
const suppressed = record.suppressed === true ? true : void 0;
|
|
31417
31443
|
const localTitle = normalizeOptionalTitle(record.localTitle);
|
|
@@ -31452,8 +31478,8 @@ function resolveOverridesDbPath(stateDir) {
|
|
|
31452
31478
|
}
|
|
31453
31479
|
async function readExternalThreadOverrides(stateDir) {
|
|
31454
31480
|
return await readDocument(resolveOverridesDbPath(stateDir), EXTERNAL_THREAD_OVERRIDES_DOCUMENT, (value) => {
|
|
31455
|
-
const record = asRecord$
|
|
31456
|
-
const threadsRecord = asRecord$
|
|
31481
|
+
const record = asRecord$4(value);
|
|
31482
|
+
const threadsRecord = asRecord$4(record?.threads) ?? {};
|
|
31457
31483
|
const threads = {};
|
|
31458
31484
|
for (const [threadId, entry] of Object.entries(threadsRecord)) {
|
|
31459
31485
|
const sanitized = sanitizeOverride(entry);
|
|
@@ -31589,7 +31615,7 @@ let externalCodexThreadSyncWatcherSettleTimer = null;
|
|
|
31589
31615
|
let externalCodexThreadSyncWatcherPendingTrigger = null;
|
|
31590
31616
|
const externalSyncAppServerLeaseCount = /* @__PURE__ */ new Map();
|
|
31591
31617
|
let externalCodexThreadSyncRefreshQueue = null;
|
|
31592
|
-
function asRecord$
|
|
31618
|
+
function asRecord$3(value) {
|
|
31593
31619
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
31594
31620
|
}
|
|
31595
31621
|
function clearSharedExternalSyncAppServerIdleTimer() {
|
|
@@ -31796,11 +31822,11 @@ function startExternalCodexThreadSyncWatcher(homePath) {
|
|
|
31796
31822
|
function resolveStateDbPath(stateDir) {
|
|
31797
31823
|
return path.join(stateDir, "state.sqlite");
|
|
31798
31824
|
}
|
|
31799
|
-
function asString$
|
|
31825
|
+
function asString$6(value) {
|
|
31800
31826
|
return typeof value === "string" ? value : value == null ? "" : String(value);
|
|
31801
31827
|
}
|
|
31802
31828
|
function asTrimmedString$1(value) {
|
|
31803
|
-
return asString$
|
|
31829
|
+
return asString$6(value).trim();
|
|
31804
31830
|
}
|
|
31805
31831
|
function asFiniteNumber(value) {
|
|
31806
31832
|
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
@@ -31857,9 +31883,9 @@ async function readImportedVisibleMessageTimeline(thread) {
|
|
|
31857
31883
|
} catch {
|
|
31858
31884
|
continue;
|
|
31859
31885
|
}
|
|
31860
|
-
const record = asRecord$
|
|
31886
|
+
const record = asRecord$3(entry);
|
|
31861
31887
|
if (!record || asTrimmedString$1(record.type) !== "event_msg") continue;
|
|
31862
|
-
const payload = asRecord$
|
|
31888
|
+
const payload = asRecord$3(record.payload);
|
|
31863
31889
|
if (!payload) continue;
|
|
31864
31890
|
const timestamp = firstNonEmptyString(record.timestamp, payload.timestamp, payload.createdAt, payload.created_at);
|
|
31865
31891
|
if (!timestamp || !Number.isFinite(Date.parse(timestamp))) continue;
|
|
@@ -31886,16 +31912,16 @@ function takeImportedVisibleMessageTimestamp(timeline, role) {
|
|
|
31886
31912
|
return nextTimestamp;
|
|
31887
31913
|
}
|
|
31888
31914
|
function listThreadSummariesFromResponse(payload) {
|
|
31889
|
-
const root = asRecord$
|
|
31890
|
-
const result = asRecord$
|
|
31915
|
+
const root = asRecord$3(payload);
|
|
31916
|
+
const result = asRecord$3(root?.result) ?? root;
|
|
31891
31917
|
return {
|
|
31892
|
-
threads: (Array.isArray(result?.data) ? result.data : []).map((entry) => asRecord$
|
|
31918
|
+
threads: (Array.isArray(result?.data) ? result.data : []).map((entry) => asRecord$3(entry)).filter((entry) => Boolean(asTrimmedString$1(entry?.id))),
|
|
31893
31919
|
nextCursor: firstNonEmptyString(result?.nextCursor, result?.next_cursor)
|
|
31894
31920
|
};
|
|
31895
31921
|
}
|
|
31896
31922
|
function extractLegacyThread(payload) {
|
|
31897
|
-
const root = asRecord$
|
|
31898
|
-
const thread = asRecord$
|
|
31923
|
+
const root = asRecord$3(payload);
|
|
31924
|
+
const thread = asRecord$3((asRecord$3(root?.result) ?? root)?.thread) ?? asRecord$3(root?.thread);
|
|
31899
31925
|
return thread && asTrimmedString$1(thread.id) ? thread : null;
|
|
31900
31926
|
}
|
|
31901
31927
|
function normalizeProjectScriptIcon(value) {
|
|
@@ -32012,19 +32038,19 @@ const MODEL_KEYS = [
|
|
|
32012
32038
|
"model_name"
|
|
32013
32039
|
];
|
|
32014
32040
|
function extractModelFromRecord(record) {
|
|
32015
|
-
const payload = asRecord$
|
|
32041
|
+
const payload = asRecord$3(record.payload);
|
|
32016
32042
|
const containers = [
|
|
32017
32043
|
record,
|
|
32018
32044
|
payload,
|
|
32019
|
-
asRecord$
|
|
32020
|
-
asRecord$
|
|
32021
|
-
asRecord$
|
|
32022
|
-
asRecord$
|
|
32023
|
-
asRecord$
|
|
32024
|
-
asRecord$
|
|
32025
|
-
asRecord$
|
|
32026
|
-
asRecord$
|
|
32027
|
-
asRecord$
|
|
32045
|
+
asRecord$3(payload?.info),
|
|
32046
|
+
asRecord$3(record.info),
|
|
32047
|
+
asRecord$3(record.metadata),
|
|
32048
|
+
asRecord$3(record.context),
|
|
32049
|
+
asRecord$3(record.turnContext),
|
|
32050
|
+
asRecord$3(record.turn_context),
|
|
32051
|
+
asRecord$3(record.params),
|
|
32052
|
+
asRecord$3(record.settings),
|
|
32053
|
+
asRecord$3(record.config)
|
|
32028
32054
|
].filter((value) => value !== null);
|
|
32029
32055
|
for (const container of containers) {
|
|
32030
32056
|
const value = pickString(container, MODEL_KEYS);
|
|
@@ -32035,13 +32061,13 @@ function extractModelFromRecord(record) {
|
|
|
32035
32061
|
function resolveImportedModel(thread) {
|
|
32036
32062
|
const turns = Array.isArray(thread.turns) ? thread.turns : [];
|
|
32037
32063
|
for (let turnIndex = turns.length - 1; turnIndex >= 0; turnIndex -= 1) {
|
|
32038
|
-
const turn = asRecord$
|
|
32064
|
+
const turn = asRecord$3(turns[turnIndex]);
|
|
32039
32065
|
if (!turn) continue;
|
|
32040
32066
|
const turnLevel = extractModelFromRecord(turn);
|
|
32041
32067
|
if (turnLevel) return turnLevel;
|
|
32042
32068
|
const items = Array.isArray(turn.items) ? turn.items : [];
|
|
32043
32069
|
for (let itemIndex = items.length - 1; itemIndex >= 0; itemIndex -= 1) {
|
|
32044
|
-
const item = asRecord$
|
|
32070
|
+
const item = asRecord$3(items[itemIndex]);
|
|
32045
32071
|
if (!item) continue;
|
|
32046
32072
|
const model = extractModelFromRecord(item);
|
|
32047
32073
|
if (model) return model;
|
|
@@ -32056,7 +32082,7 @@ function resolveThreadTitle(thread) {
|
|
|
32056
32082
|
return firstNonEmptyString(thread.name, thread.preview, thread.title)?.split(/\r?\n/, 1)[0]?.trim()?.slice(0, 140) || "Imported thread";
|
|
32057
32083
|
}
|
|
32058
32084
|
function readLegacyContentRecord(value) {
|
|
32059
|
-
return asRecord$
|
|
32085
|
+
return asRecord$3(value);
|
|
32060
32086
|
}
|
|
32061
32087
|
function readLegacyContentText(item) {
|
|
32062
32088
|
const data = readLegacyContentRecord(item.data);
|
|
@@ -32148,7 +32174,7 @@ async function parseUserMessageContent(input) {
|
|
|
32148
32174
|
const attachments = [];
|
|
32149
32175
|
let imageIndex = 0;
|
|
32150
32176
|
for (const entry of content) {
|
|
32151
|
-
const item = asRecord$
|
|
32177
|
+
const item = asRecord$3(entry);
|
|
32152
32178
|
if (!item) continue;
|
|
32153
32179
|
const type = asTrimmedString$1(item.type);
|
|
32154
32180
|
if (type === "text") {
|
|
@@ -32219,13 +32245,13 @@ async function buildThreadImportArtifacts(input) {
|
|
|
32219
32245
|
let latestArtifactUpdatedAt = createdAt;
|
|
32220
32246
|
let latestUpdatedAt = summaryUpdatedAt;
|
|
32221
32247
|
for (const [turnIndex, turnEntry] of turns.entries()) {
|
|
32222
|
-
const turn = asRecord$
|
|
32248
|
+
const turn = asRecord$3(turnEntry);
|
|
32223
32249
|
if (!turn) continue;
|
|
32224
32250
|
const turnIdRaw = firstNonEmptyString(turn.id, turn.turnId, turn.turn_id);
|
|
32225
32251
|
const turnId = turnIdRaw ? TurnId.makeUnsafe(turnIdRaw) : null;
|
|
32226
32252
|
const items = Array.isArray(turn.items) ? turn.items : [];
|
|
32227
32253
|
for (const [itemIndex, itemEntry] of items.entries()) {
|
|
32228
|
-
const item = asRecord$
|
|
32254
|
+
const item = asRecord$3(itemEntry);
|
|
32229
32255
|
if (!item) continue;
|
|
32230
32256
|
const itemId = firstNonEmptyString(item.id) ?? `${turnIndex + 1}-${itemIndex + 1}`;
|
|
32231
32257
|
const type = asTrimmedString$1(item.type);
|
|
@@ -32448,7 +32474,7 @@ async function isDirectory(targetPath) {
|
|
|
32448
32474
|
async function readImportMarker(stateDir) {
|
|
32449
32475
|
const dbPath = resolveStateDbPath(stateDir);
|
|
32450
32476
|
const stored = await readDocument(dbPath, EXTERNAL_SYNC_MARKER_DOCUMENT, (value) => {
|
|
32451
|
-
const version = asFiniteNumber(asRecord$
|
|
32477
|
+
const version = asFiniteNumber(asRecord$3(value)?.version);
|
|
32452
32478
|
if (version === null || version <= 0) return null;
|
|
32453
32479
|
return { version };
|
|
32454
32480
|
});
|
|
@@ -32456,7 +32482,7 @@ async function readImportMarker(stateDir) {
|
|
|
32456
32482
|
const markerPath = path.join(stateDir, EXTERNAL_SYNC_MARKER_FILE);
|
|
32457
32483
|
try {
|
|
32458
32484
|
const raw = await fs$1.readFile(markerPath, "utf8");
|
|
32459
|
-
const version = asFiniteNumber(asRecord$
|
|
32485
|
+
const version = asFiniteNumber(asRecord$3(JSON.parse(raw))?.version);
|
|
32460
32486
|
if (version === null || version <= 0) return null;
|
|
32461
32487
|
const marker = { version };
|
|
32462
32488
|
await writeDocument(dbPath, EXTERNAL_SYNC_MARKER_DOCUMENT, marker);
|
|
@@ -32536,7 +32562,7 @@ function hasImportedThreadArtifacts(state) {
|
|
|
32536
32562
|
return state.messageIds.size > 0 || state.activityIds.size > 0 || state.planIds.size > 0;
|
|
32537
32563
|
}
|
|
32538
32564
|
function readProviderThreadIdFromResumeCursor(resumeCursor) {
|
|
32539
|
-
const cursor = asRecord$
|
|
32565
|
+
const cursor = asRecord$3(resumeCursor);
|
|
32540
32566
|
return firstNonEmptyString(cursor?.threadId, cursor?.thread_id, cursor?.conversationId, cursor?.conversation_id) ?? null;
|
|
32541
32567
|
}
|
|
32542
32568
|
function resolveLegacyThreadReadIds(input) {
|
|
@@ -33367,7 +33393,7 @@ function proposedPlanIdFromEvent(event, threadId) {
|
|
|
33367
33393
|
if (event.itemId) return `plan:${threadId}:item:${event.itemId}`;
|
|
33368
33394
|
return `plan:${threadId}:event:${event.eventId}`;
|
|
33369
33395
|
}
|
|
33370
|
-
function asString$
|
|
33396
|
+
function asString$5(value) {
|
|
33371
33397
|
return typeof value === "string" ? value : void 0;
|
|
33372
33398
|
}
|
|
33373
33399
|
function runtimePayloadRecord(event) {
|
|
@@ -33385,13 +33411,13 @@ function normalizeRuntimeTurnState(value) {
|
|
|
33385
33411
|
}
|
|
33386
33412
|
}
|
|
33387
33413
|
function runtimeTurnState(event) {
|
|
33388
|
-
return normalizeRuntimeTurnState(asString$
|
|
33414
|
+
return normalizeRuntimeTurnState(asString$5(runtimePayloadRecord(event)?.state));
|
|
33389
33415
|
}
|
|
33390
33416
|
function runtimeTurnErrorMessage(event) {
|
|
33391
|
-
return asString$
|
|
33417
|
+
return asString$5(runtimePayloadRecord(event)?.errorMessage);
|
|
33392
33418
|
}
|
|
33393
33419
|
function runtimeErrorMessageFromEvent(event) {
|
|
33394
|
-
return asString$
|
|
33420
|
+
return asString$5(runtimePayloadRecord(event)?.message);
|
|
33395
33421
|
}
|
|
33396
33422
|
function shouldTriggerPassiveImportedThreadRecovery(event) {
|
|
33397
33423
|
switch (event.type) {
|
|
@@ -34142,13 +34168,13 @@ function asObject$1(value) {
|
|
|
34142
34168
|
if (!value || typeof value !== "object") return;
|
|
34143
34169
|
return value;
|
|
34144
34170
|
}
|
|
34145
|
-
function asString$
|
|
34171
|
+
function asString$4(value) {
|
|
34146
34172
|
return typeof value === "string" ? value : void 0;
|
|
34147
34173
|
}
|
|
34148
34174
|
function readCodexAccountSnapshot(response) {
|
|
34149
34175
|
const record = asObject$1(response);
|
|
34150
34176
|
const account = asObject$1(record?.account) ?? record;
|
|
34151
|
-
const accountType = asString$
|
|
34177
|
+
const accountType = asString$4(account?.type);
|
|
34152
34178
|
if (accountType === "apiKey") return {
|
|
34153
34179
|
type: "apiKey",
|
|
34154
34180
|
planType: null,
|
|
@@ -34517,7 +34543,7 @@ var CodexAppServerManager = class extends EventEmitter {
|
|
|
34517
34543
|
};
|
|
34518
34544
|
const codexOptions = readCodexProviderOptions(input);
|
|
34519
34545
|
const codexBinaryPath = codexOptions.binaryPath ?? "codex";
|
|
34520
|
-
const codexHomePath = codexOptions.homePath;
|
|
34546
|
+
const codexHomePath = normalizeCodexHomePath(codexOptions.homePath);
|
|
34521
34547
|
this.assertSupportedCodexCliVersion({
|
|
34522
34548
|
binaryPath: codexBinaryPath,
|
|
34523
34549
|
cwd: resolvedCwd,
|
|
@@ -35278,7 +35304,7 @@ function readCodexProviderOptions(input) {
|
|
|
35278
35304
|
if (!options) return {};
|
|
35279
35305
|
return {
|
|
35280
35306
|
...options.binaryPath ? { binaryPath: options.binaryPath } : {},
|
|
35281
|
-
...options.homePath ? { homePath: options.homePath } : {}
|
|
35307
|
+
...options.homePath ? { homePath: normalizeCodexHomePath(options.homePath) ?? options.homePath } : {}
|
|
35282
35308
|
};
|
|
35283
35309
|
}
|
|
35284
35310
|
function assertSupportedCodexCliVersion(input) {
|
|
@@ -35692,7 +35718,7 @@ function asObject(value) {
|
|
|
35692
35718
|
if (!value || typeof value !== "object") return;
|
|
35693
35719
|
return value;
|
|
35694
35720
|
}
|
|
35695
|
-
function asString$
|
|
35721
|
+
function asString$3(value) {
|
|
35696
35722
|
return typeof value === "string" ? value : void 0;
|
|
35697
35723
|
}
|
|
35698
35724
|
function asArray(value) {
|
|
@@ -35711,7 +35737,7 @@ function toTurnStatus(value) {
|
|
|
35711
35737
|
}
|
|
35712
35738
|
}
|
|
35713
35739
|
function normalizeItemType(raw) {
|
|
35714
|
-
const type = asString$
|
|
35740
|
+
const type = asString$3(raw);
|
|
35715
35741
|
if (!type) return "item";
|
|
35716
35742
|
return type.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[._/-]/g, " ").replace(/\s+/g, " ").trim().toLowerCase();
|
|
35717
35743
|
}
|
|
@@ -35753,16 +35779,16 @@ function itemTitle(itemType) {
|
|
|
35753
35779
|
function itemDetail(item, payload) {
|
|
35754
35780
|
const nestedResult = asObject(item.result);
|
|
35755
35781
|
const candidates = [
|
|
35756
|
-
asString$
|
|
35757
|
-
asString$
|
|
35758
|
-
asString$
|
|
35759
|
-
asString$
|
|
35760
|
-
asString$
|
|
35761
|
-
asString$
|
|
35762
|
-
asString$
|
|
35763
|
-
asString$
|
|
35764
|
-
asString$
|
|
35765
|
-
asString$
|
|
35782
|
+
asString$3(item.command),
|
|
35783
|
+
asString$3(item.title),
|
|
35784
|
+
asString$3(item.summary),
|
|
35785
|
+
asString$3(item.text),
|
|
35786
|
+
asString$3(item.path),
|
|
35787
|
+
asString$3(item.prompt),
|
|
35788
|
+
asString$3(nestedResult?.command),
|
|
35789
|
+
asString$3(payload.command),
|
|
35790
|
+
asString$3(payload.message),
|
|
35791
|
+
asString$3(payload.prompt)
|
|
35766
35792
|
];
|
|
35767
35793
|
for (const candidate of candidates) {
|
|
35768
35794
|
if (!candidate) continue;
|
|
@@ -35794,9 +35820,9 @@ function toRequestTypeFromKind(kind) {
|
|
|
35794
35820
|
}
|
|
35795
35821
|
function toRequestTypeFromResolvedPayload(payload) {
|
|
35796
35822
|
const request = asObject(payload?.request);
|
|
35797
|
-
const method = asString$
|
|
35823
|
+
const method = asString$3(request?.method) ?? asString$3(payload?.method);
|
|
35798
35824
|
if (method) return toRequestTypeFromMethod(method);
|
|
35799
|
-
const requestKind = asString$
|
|
35825
|
+
const requestKind = asString$3(request?.kind) ?? asString$3(payload?.requestKind);
|
|
35800
35826
|
if (requestKind) return toRequestTypeFromKind(requestKind);
|
|
35801
35827
|
return "unknown";
|
|
35802
35828
|
}
|
|
@@ -35822,17 +35848,17 @@ function toUserInputQuestions(payload) {
|
|
|
35822
35848
|
const options = asArray(question.options)?.map((option) => {
|
|
35823
35849
|
const optionRecord = asObject(option);
|
|
35824
35850
|
if (!optionRecord) return void 0;
|
|
35825
|
-
const label = asString$
|
|
35826
|
-
const description = asString$
|
|
35851
|
+
const label = asString$3(optionRecord.label)?.trim();
|
|
35852
|
+
const description = asString$3(optionRecord.description)?.trim();
|
|
35827
35853
|
if (!label || !description) return;
|
|
35828
35854
|
return {
|
|
35829
35855
|
label,
|
|
35830
35856
|
description
|
|
35831
35857
|
};
|
|
35832
35858
|
}).filter((option) => option !== void 0);
|
|
35833
|
-
const id = asString$
|
|
35834
|
-
const header = asString$
|
|
35835
|
-
const prompt = asString$
|
|
35859
|
+
const id = asString$3(question.id)?.trim();
|
|
35860
|
+
const header = asString$3(question.header)?.trim();
|
|
35861
|
+
const prompt = asString$3(question.question)?.trim();
|
|
35836
35862
|
if (!id || !header || !prompt || !options || options.length === 0) return;
|
|
35837
35863
|
return {
|
|
35838
35864
|
id,
|
|
@@ -35883,9 +35909,9 @@ function codexEventMessage(payload) {
|
|
|
35883
35909
|
}
|
|
35884
35910
|
function codexEventBase(event, canonicalThreadId) {
|
|
35885
35911
|
const msg = codexEventMessage(asObject(event.payload));
|
|
35886
|
-
const turnId = asString$
|
|
35887
|
-
const itemId = asString$
|
|
35888
|
-
const requestId = asString$
|
|
35912
|
+
const turnId = asString$3(msg?.turn_id) ?? asString$3(msg?.turnId);
|
|
35913
|
+
const itemId = asString$3(msg?.item_id) ?? asString$3(msg?.itemId);
|
|
35914
|
+
const requestId = asString$3(msg?.request_id) ?? asString$3(msg?.requestId);
|
|
35889
35915
|
const base = runtimeEventBase(event, canonicalThreadId);
|
|
35890
35916
|
const providerRefs = base.providerRefs ? {
|
|
35891
35917
|
...base.providerRefs,
|
|
@@ -35978,7 +36004,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
35978
36004
|
payload: { questions }
|
|
35979
36005
|
}];
|
|
35980
36006
|
}
|
|
35981
|
-
const detail = asString$
|
|
36007
|
+
const detail = asString$3(payload?.command) ?? asString$3(payload?.reason) ?? asString$3(payload?.prompt);
|
|
35982
36008
|
return [{
|
|
35983
36009
|
...runtimeEventBase(event, canonicalThreadId),
|
|
35984
36010
|
type: "request.opened",
|
|
@@ -36035,7 +36061,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36035
36061
|
}
|
|
36036
36062
|
}];
|
|
36037
36063
|
if (event.method === "thread/started") {
|
|
36038
|
-
const providerThreadId = asString$
|
|
36064
|
+
const providerThreadId = asString$3(asObject(payload?.thread)?.id) ?? asString$3(payload?.threadId);
|
|
36039
36065
|
if (!providerThreadId) return [];
|
|
36040
36066
|
return [{
|
|
36041
36067
|
...runtimeEventBase(event, canonicalThreadId),
|
|
@@ -36051,7 +36077,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36051
36077
|
type: "thread.state.changed",
|
|
36052
36078
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36053
36079
|
payload: {
|
|
36054
|
-
state: event.method === "thread/archived" ? "archived" : event.method === "thread/closed" ? "closed" : event.method === "thread/compacted" ? "compacted" : toThreadState(asString$
|
|
36080
|
+
state: event.method === "thread/archived" ? "archived" : event.method === "thread/closed" ? "closed" : event.method === "thread/compacted" ? "compacted" : toThreadState(asString$3(statusRecord?.type) ?? asString$3(threadStatusRecord?.type) ?? asString$3(threadRecord?.state) ?? payload?.state),
|
|
36055
36081
|
...event.payload !== void 0 ? { detail: event.payload } : {}
|
|
36056
36082
|
}
|
|
36057
36083
|
}];
|
|
@@ -36060,7 +36086,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36060
36086
|
type: "thread.metadata.updated",
|
|
36061
36087
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36062
36088
|
payload: {
|
|
36063
|
-
...asString$
|
|
36089
|
+
...asString$3(payload?.threadName) ? { name: asString$3(payload?.threadName) } : {},
|
|
36064
36090
|
...event.payload !== void 0 ? { metadata: asObject(event.payload) } : {}
|
|
36065
36091
|
}
|
|
36066
36092
|
}];
|
|
@@ -36077,19 +36103,19 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36077
36103
|
turnId,
|
|
36078
36104
|
type: "turn.started",
|
|
36079
36105
|
payload: {
|
|
36080
|
-
...asString$
|
|
36081
|
-
...asString$
|
|
36106
|
+
...asString$3(turn?.model) ? { model: asString$3(turn?.model) } : {},
|
|
36107
|
+
...asString$3(turn?.effort) ? { effort: asString$3(turn?.effort) } : {}
|
|
36082
36108
|
}
|
|
36083
36109
|
}];
|
|
36084
36110
|
}
|
|
36085
36111
|
if (event.method === "turn/completed") {
|
|
36086
|
-
const errorMessage = asString$
|
|
36112
|
+
const errorMessage = asString$3(asObject(turn?.error)?.message);
|
|
36087
36113
|
return [{
|
|
36088
36114
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36089
36115
|
type: "turn.completed",
|
|
36090
36116
|
payload: {
|
|
36091
36117
|
state: toTurnStatus(turn?.status),
|
|
36092
|
-
...asString$
|
|
36118
|
+
...asString$3(turn?.stopReason) ? { stopReason: asString$3(turn?.stopReason) } : {},
|
|
36093
36119
|
...turn?.usage !== void 0 ? { usage: turn.usage } : {},
|
|
36094
36120
|
...asObject(turn?.modelUsage) ? { modelUsage: asObject(turn?.modelUsage) } : {},
|
|
36095
36121
|
...asNumber$2(turn?.totalCostUsd) !== void 0 ? { totalCostUsd: asNumber$2(turn?.totalCostUsd) } : {},
|
|
@@ -36108,9 +36134,9 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36108
36134
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36109
36135
|
type: "turn.plan.updated",
|
|
36110
36136
|
payload: {
|
|
36111
|
-
...asString$
|
|
36137
|
+
...asString$3(payload?.explanation) ? { explanation: asString$3(payload?.explanation) } : {},
|
|
36112
36138
|
plan: steps.map((entry) => asObject(entry)).filter((entry) => entry !== void 0).map((entry) => ({
|
|
36113
|
-
step: asString$
|
|
36139
|
+
step: asString$3(entry.step) ?? "step",
|
|
36114
36140
|
status: entry.status === "completed" || entry.status === "inProgress" ? entry.status : "pending"
|
|
36115
36141
|
}))
|
|
36116
36142
|
}
|
|
@@ -36119,7 +36145,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36119
36145
|
if (event.method === "turn/diff/updated") return [{
|
|
36120
36146
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36121
36147
|
type: "turn.diff.updated",
|
|
36122
|
-
payload: { unifiedDiff: asString$
|
|
36148
|
+
payload: { unifiedDiff: asString$3(payload?.unifiedDiff) ?? asString$3(payload?.diff) ?? asString$3(payload?.patch) ?? "" }
|
|
36123
36149
|
}];
|
|
36124
36150
|
if (event.method === "item/started") {
|
|
36125
36151
|
const started = mapItemLifecycle(event, canonicalThreadId, "item.started");
|
|
@@ -36146,7 +36172,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36146
36172
|
return updated ? [updated] : [];
|
|
36147
36173
|
}
|
|
36148
36174
|
if (event.method === "item/plan/delta") {
|
|
36149
|
-
const delta = event.textDelta ?? asString$
|
|
36175
|
+
const delta = event.textDelta ?? asString$3(payload?.delta) ?? asString$3(payload?.text) ?? asString$3(asObject(payload?.content)?.text);
|
|
36150
36176
|
if (!delta || delta.length === 0) return [];
|
|
36151
36177
|
return [{
|
|
36152
36178
|
...runtimeEventBase(event, canonicalThreadId),
|
|
@@ -36155,7 +36181,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36155
36181
|
}];
|
|
36156
36182
|
}
|
|
36157
36183
|
if (event.method === "item/agentMessage/delta" || event.method === "item/commandExecution/outputDelta" || event.method === "item/fileChange/outputDelta" || event.method === "item/reasoning/summaryTextDelta" || event.method === "item/reasoning/textDelta") {
|
|
36158
|
-
const delta = event.textDelta ?? asString$
|
|
36184
|
+
const delta = event.textDelta ?? asString$3(payload?.delta) ?? asString$3(payload?.text) ?? asString$3(asObject(payload?.content)?.text);
|
|
36159
36185
|
if (!delta || delta.length === 0) return [];
|
|
36160
36186
|
return [{
|
|
36161
36187
|
...runtimeEventBase(event, canonicalThreadId),
|
|
@@ -36172,9 +36198,9 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36172
36198
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36173
36199
|
type: "tool.progress",
|
|
36174
36200
|
payload: {
|
|
36175
|
-
...asString$
|
|
36176
|
-
...asString$
|
|
36177
|
-
...asString$
|
|
36201
|
+
...asString$3(payload?.toolUseId) ? { toolUseId: asString$3(payload?.toolUseId) } : {},
|
|
36202
|
+
...asString$3(payload?.toolName) ? { toolName: asString$3(payload?.toolName) } : {},
|
|
36203
|
+
...asString$3(payload?.summary) ? { summary: asString$3(payload?.summary) } : {},
|
|
36178
36204
|
...asNumber$2(payload?.elapsedSeconds) !== void 0 ? { elapsedSeconds: asNumber$2(payload?.elapsedSeconds) } : {}
|
|
36179
36205
|
}
|
|
36180
36206
|
}];
|
|
@@ -36196,21 +36222,21 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36196
36222
|
}];
|
|
36197
36223
|
if (event.method === "codex/event/task_started") {
|
|
36198
36224
|
const msg = codexEventMessage(payload);
|
|
36199
|
-
const taskId = asString$
|
|
36225
|
+
const taskId = asString$3(payload?.id) ?? asString$3(msg?.turn_id);
|
|
36200
36226
|
if (!taskId) return [];
|
|
36201
36227
|
return [{
|
|
36202
36228
|
...codexEventBase(event, canonicalThreadId),
|
|
36203
36229
|
type: "task.started",
|
|
36204
36230
|
payload: {
|
|
36205
36231
|
taskId: asRuntimeTaskId(taskId),
|
|
36206
|
-
...asString$
|
|
36232
|
+
...asString$3(msg?.collaboration_mode_kind) ? { taskType: asString$3(msg?.collaboration_mode_kind) } : {}
|
|
36207
36233
|
}
|
|
36208
36234
|
}];
|
|
36209
36235
|
}
|
|
36210
36236
|
if (event.method === "codex/event/task_complete") {
|
|
36211
36237
|
const msg = codexEventMessage(payload);
|
|
36212
|
-
const taskId = asString$
|
|
36213
|
-
const proposedPlanMarkdown = extractProposedPlanMarkdown(asString$
|
|
36238
|
+
const taskId = asString$3(payload?.id) ?? asString$3(msg?.turn_id);
|
|
36239
|
+
const proposedPlanMarkdown = extractProposedPlanMarkdown(asString$3(msg?.last_agent_message));
|
|
36214
36240
|
if (!taskId) {
|
|
36215
36241
|
if (!proposedPlanMarkdown) return [];
|
|
36216
36242
|
return [{
|
|
@@ -36225,7 +36251,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36225
36251
|
payload: {
|
|
36226
36252
|
taskId: asRuntimeTaskId(taskId),
|
|
36227
36253
|
status: "completed",
|
|
36228
|
-
...asString$
|
|
36254
|
+
...asString$3(msg?.last_agent_message) ? { summary: asString$3(msg?.last_agent_message) } : {}
|
|
36229
36255
|
}
|
|
36230
36256
|
}];
|
|
36231
36257
|
if (proposedPlanMarkdown) events.push({
|
|
@@ -36237,8 +36263,8 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36237
36263
|
}
|
|
36238
36264
|
if (event.method === "codex/event/agent_reasoning") {
|
|
36239
36265
|
const msg = codexEventMessage(payload);
|
|
36240
|
-
const taskId = asString$
|
|
36241
|
-
const description = asString$
|
|
36266
|
+
const taskId = asString$3(payload?.id);
|
|
36267
|
+
const description = asString$3(msg?.text);
|
|
36242
36268
|
if (!taskId || !description) return [];
|
|
36243
36269
|
return [{
|
|
36244
36270
|
...codexEventBase(event, canonicalThreadId),
|
|
@@ -36251,7 +36277,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36251
36277
|
}
|
|
36252
36278
|
if (event.method === "codex/event/reasoning_content_delta") {
|
|
36253
36279
|
const msg = codexEventMessage(payload);
|
|
36254
|
-
const delta = asString$
|
|
36280
|
+
const delta = asString$3(msg?.delta);
|
|
36255
36281
|
if (!delta) return [];
|
|
36256
36282
|
return [{
|
|
36257
36283
|
...codexEventBase(event, canonicalThreadId),
|
|
@@ -36267,26 +36293,26 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36267
36293
|
type: "model.rerouted",
|
|
36268
36294
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36269
36295
|
payload: {
|
|
36270
|
-
fromModel: asString$
|
|
36271
|
-
toModel: asString$
|
|
36272
|
-
reason: asString$
|
|
36296
|
+
fromModel: asString$3(payload?.fromModel) ?? "unknown",
|
|
36297
|
+
toModel: asString$3(payload?.toModel) ?? "unknown",
|
|
36298
|
+
reason: asString$3(payload?.reason) ?? "unknown"
|
|
36273
36299
|
}
|
|
36274
36300
|
}];
|
|
36275
36301
|
if (event.method === "deprecationNotice") return [{
|
|
36276
36302
|
type: "deprecation.notice",
|
|
36277
36303
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36278
36304
|
payload: {
|
|
36279
|
-
summary: asString$
|
|
36280
|
-
...asString$
|
|
36305
|
+
summary: asString$3(payload?.summary) ?? "Deprecation notice",
|
|
36306
|
+
...asString$3(payload?.details) ? { details: asString$3(payload?.details) } : {}
|
|
36281
36307
|
}
|
|
36282
36308
|
}];
|
|
36283
36309
|
if (event.method === "configWarning") return [{
|
|
36284
36310
|
type: "config.warning",
|
|
36285
36311
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36286
36312
|
payload: {
|
|
36287
|
-
summary: asString$
|
|
36288
|
-
...asString$
|
|
36289
|
-
...asString$
|
|
36313
|
+
summary: asString$3(payload?.summary) ?? "Configuration warning",
|
|
36314
|
+
...asString$3(payload?.details) ? { details: asString$3(payload?.details) } : {},
|
|
36315
|
+
...asString$3(payload?.path) ? { path: asString$3(payload?.path) } : {},
|
|
36290
36316
|
...payload?.range !== void 0 ? { range: payload.range } : {}
|
|
36291
36317
|
}
|
|
36292
36318
|
}];
|
|
@@ -36305,12 +36331,12 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36305
36331
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36306
36332
|
payload: {
|
|
36307
36333
|
success: payload?.success === true,
|
|
36308
|
-
...asString$
|
|
36309
|
-
...asString$
|
|
36334
|
+
...asString$3(payload?.name) ? { name: asString$3(payload?.name) } : {},
|
|
36335
|
+
...asString$3(payload?.error) ? { error: asString$3(payload?.error) } : {}
|
|
36310
36336
|
}
|
|
36311
36337
|
}];
|
|
36312
36338
|
if (event.method === "thread/realtime/started") {
|
|
36313
|
-
const realtimeSessionId = asString$
|
|
36339
|
+
const realtimeSessionId = asString$3(payload?.realtimeSessionId);
|
|
36314
36340
|
return [{
|
|
36315
36341
|
type: "thread.realtime.started",
|
|
36316
36342
|
...runtimeEventBase(event, canonicalThreadId),
|
|
@@ -36328,7 +36354,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36328
36354
|
payload: { audio: event.payload ?? {} }
|
|
36329
36355
|
}];
|
|
36330
36356
|
if (event.method === "thread/realtime/error") {
|
|
36331
|
-
const message = asString$
|
|
36357
|
+
const message = asString$3(payload?.message) ?? event.message ?? "Realtime error";
|
|
36332
36358
|
return [{
|
|
36333
36359
|
type: "thread.realtime.error",
|
|
36334
36360
|
...runtimeEventBase(event, canonicalThreadId),
|
|
@@ -36341,7 +36367,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36341
36367
|
payload: { reason: event.message }
|
|
36342
36368
|
}];
|
|
36343
36369
|
if (event.method === "error") {
|
|
36344
|
-
const message = asString$
|
|
36370
|
+
const message = asString$3(asObject(payload?.error)?.message) ?? event.message ?? "Provider runtime error";
|
|
36345
36371
|
const willRetry = payload?.willRetry === true;
|
|
36346
36372
|
return [{
|
|
36347
36373
|
type: willRetry ? "runtime.warning" : "runtime.error",
|
|
@@ -40936,6 +40962,7 @@ var ProviderHealth = class extends Service()("t3/provider/Services/ProviderHealt
|
|
|
40936
40962
|
//#endregion
|
|
40937
40963
|
//#region src/provider/Layers/ProviderHealth.ts
|
|
40938
40964
|
const DEFAULT_TIMEOUT_MS = 4e3;
|
|
40965
|
+
const AUTH_STATUS_TIMEOUT_MS$1 = 8e3;
|
|
40939
40966
|
const CODEX_PROVIDER = "codex";
|
|
40940
40967
|
function nonEmptyTrimmed(value) {
|
|
40941
40968
|
if (!value) return void 0;
|
|
@@ -40955,6 +40982,15 @@ function detailFromResult(result) {
|
|
|
40955
40982
|
if (stdout) return stdout;
|
|
40956
40983
|
if (result.code !== 0) return `Command exited with code ${result.code}.`;
|
|
40957
40984
|
}
|
|
40985
|
+
function createPendingCodexStatus() {
|
|
40986
|
+
return {
|
|
40987
|
+
provider: CODEX_PROVIDER,
|
|
40988
|
+
status: "ready",
|
|
40989
|
+
available: true,
|
|
40990
|
+
authStatus: "unknown",
|
|
40991
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
40992
|
+
};
|
|
40993
|
+
}
|
|
40958
40994
|
function extractAuthBoolean(value) {
|
|
40959
40995
|
if (isArray(value)) {
|
|
40960
40996
|
for (const entry of value) {
|
|
@@ -41165,7 +41201,7 @@ const checkCodexProviderStatus = gen(function* () {
|
|
|
41165
41201
|
checkedAt,
|
|
41166
41202
|
message: "Using a custom Codex model provider; OpenAI login check skipped."
|
|
41167
41203
|
};
|
|
41168
|
-
const authProbe = yield* runCodexCommand$1(["login", "status"], runtimeEnv).pipe(timeoutOption(
|
|
41204
|
+
const authProbe = yield* runCodexCommand$1(["login", "status"], runtimeEnv).pipe(timeoutOption(AUTH_STATUS_TIMEOUT_MS$1), result);
|
|
41169
41205
|
if (isFailure$1(authProbe)) {
|
|
41170
41206
|
const error = authProbe.failure;
|
|
41171
41207
|
return {
|
|
@@ -41200,7 +41236,7 @@ const ProviderHealthLive = effect(ProviderHealth, gen(function* () {
|
|
|
41200
41236
|
const path = yield* Path$1;
|
|
41201
41237
|
const childProcessSpawner = yield* ChildProcessSpawner;
|
|
41202
41238
|
const loadStatuses = checkCodexProviderStatus.pipe(map$2(of), provideService(FileSystem, fileSystem), provideService(Path$1, path), provideService(ChildProcessSpawner, childProcessSpawner));
|
|
41203
|
-
const statusesRef = yield* make$11(
|
|
41239
|
+
const statusesRef = yield* make$11([createPendingCodexStatus()]);
|
|
41204
41240
|
return {
|
|
41205
41241
|
getStatuses: get(statusesRef),
|
|
41206
41242
|
refreshStatuses: loadStatuses.pipe(tap((statuses) => set$1(statusesRef, statuses)))
|
|
@@ -41209,6 +41245,7 @@ const ProviderHealthLive = effect(ProviderHealth, gen(function* () {
|
|
|
41209
41245
|
//#endregion
|
|
41210
41246
|
//#region ../../packages/contracts/src/settings/types.ts
|
|
41211
41247
|
const DEFAULT_ACCOUNT_POOL_EXPOSED_MODELS = [
|
|
41248
|
+
"gpt-5.5",
|
|
41212
41249
|
"gpt-5.4",
|
|
41213
41250
|
"gpt-5.4-mini",
|
|
41214
41251
|
"gpt-5.4-nano"
|
|
@@ -41256,7 +41293,7 @@ const LEGACY_APP_SETTINGS_KEYS = new Set([
|
|
|
41256
41293
|
"activeRemoteBackendId",
|
|
41257
41294
|
"keepDaemonRunningAfterAppClose"
|
|
41258
41295
|
]);
|
|
41259
|
-
function asRecord$
|
|
41296
|
+
function asRecord$2(value) {
|
|
41260
41297
|
return value && typeof value === "object" ? value : {};
|
|
41261
41298
|
}
|
|
41262
41299
|
function stripLegacyAppSettingsKeys(settings) {
|
|
@@ -41270,10 +41307,10 @@ function stripLegacyAppSettingsKeys(settings) {
|
|
|
41270
41307
|
return changed ? next : settings;
|
|
41271
41308
|
}
|
|
41272
41309
|
async function readAppSettings() {
|
|
41273
|
-
return stripLegacyAppSettingsKeys(asRecord$
|
|
41310
|
+
return stripLegacyAppSettingsKeys(asRecord$2((await getAppState()).runtimeSettings));
|
|
41274
41311
|
}
|
|
41275
41312
|
async function writeAppSettings(settings, onUpdated) {
|
|
41276
|
-
const nextSettings = stripLegacyAppSettingsKeys(asRecord$
|
|
41313
|
+
const nextSettings = stripLegacyAppSettingsKeys(asRecord$2(settings));
|
|
41277
41314
|
await updateAppState((current) => ({
|
|
41278
41315
|
...current,
|
|
41279
41316
|
runtimeSettings: nextSettings
|
|
@@ -45516,6 +45553,12 @@ function classifyRefreshFailure(error) {
|
|
|
45516
45553
|
retryable: false,
|
|
45517
45554
|
tokenIssue: "account-deactivated"
|
|
45518
45555
|
};
|
|
45556
|
+
if (normalized.includes("deactivated_workspace") || normalized.includes("workspace deactivated") || normalized.includes("402 payment required") && normalized.includes("/backend-api/wham/usage")) return {
|
|
45557
|
+
code: "workspace-deactivated",
|
|
45558
|
+
message: "Workspace deactivated. Restore workspace billing/access or remove this profile.",
|
|
45559
|
+
retryable: false,
|
|
45560
|
+
tokenIssue: "workspace-deactivated"
|
|
45561
|
+
};
|
|
45519
45562
|
if (normalized.includes("token_invalidated") || normalized.includes("authentication token has been invalidated")) return {
|
|
45520
45563
|
code: "token-expired",
|
|
45521
45564
|
message: "Session invalidated. Re-login this profile.",
|
|
@@ -45570,7 +45613,9 @@ async function performAccountRefresh(accountKeyValue, state) {
|
|
|
45570
45613
|
} catch (flagError) {
|
|
45571
45614
|
logError(`Failed to persist auth issue '${classification.tokenIssue}' for profile '${state.profileName}':`, flagError);
|
|
45572
45615
|
}
|
|
45573
|
-
|
|
45616
|
+
const message = `Failed to refresh rate-limit telemetry for account '${accountKeyValue}' using profile '${state.profileName}':`;
|
|
45617
|
+
if (classification.retryable) logError(message, error);
|
|
45618
|
+
else logWarn(message, classification.message);
|
|
45574
45619
|
return {
|
|
45575
45620
|
outcome: classification.retryable ? "retry" : "hold",
|
|
45576
45621
|
snapshot: null
|
|
@@ -45922,7 +45967,7 @@ var AccountPoolTurnFailure = class extends Error {
|
|
|
45922
45967
|
function isRecord$2(value) {
|
|
45923
45968
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
45924
45969
|
}
|
|
45925
|
-
function asString$
|
|
45970
|
+
function asString$2(value) {
|
|
45926
45971
|
if (typeof value !== "string") return null;
|
|
45927
45972
|
const trimmed = value.trim();
|
|
45928
45973
|
return trimmed.length > 0 ? trimmed : null;
|
|
@@ -45931,7 +45976,7 @@ function asNumber$1(value) {
|
|
|
45931
45976
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
45932
45977
|
}
|
|
45933
45978
|
function normalizeIsoString(value) {
|
|
45934
|
-
const normalized = asString$
|
|
45979
|
+
const normalized = asString$2(value);
|
|
45935
45980
|
if (!normalized) return null;
|
|
45936
45981
|
const parsed = Date.parse(normalized);
|
|
45937
45982
|
return Number.isNaN(parsed) ? null : new Date(parsed).toISOString();
|
|
@@ -45941,7 +45986,7 @@ function normalizeStringArray(value) {
|
|
|
45941
45986
|
const result = [];
|
|
45942
45987
|
const seen = /* @__PURE__ */ new Set();
|
|
45943
45988
|
for (const entry of input) {
|
|
45944
|
-
const normalized = asString$
|
|
45989
|
+
const normalized = asString$2(entry);
|
|
45945
45990
|
if (!normalized || seen.has(normalized)) continue;
|
|
45946
45991
|
seen.add(normalized);
|
|
45947
45992
|
result.push(normalized);
|
|
@@ -45949,11 +45994,11 @@ function normalizeStringArray(value) {
|
|
|
45949
45994
|
return result;
|
|
45950
45995
|
}
|
|
45951
45996
|
function normalizeReasoningEffort(value) {
|
|
45952
|
-
const normalized = asString$
|
|
45997
|
+
const normalized = asString$2(value)?.toLowerCase() ?? null;
|
|
45953
45998
|
return normalized && normalized.length > 0 ? normalized : null;
|
|
45954
45999
|
}
|
|
45955
46000
|
function normalizeServiceTier(value) {
|
|
45956
|
-
const normalized = asString$
|
|
46001
|
+
const normalized = asString$2(value)?.toLowerCase() ?? null;
|
|
45957
46002
|
return normalized && normalized.length > 0 ? normalized : null;
|
|
45958
46003
|
}
|
|
45959
46004
|
function normalizeConfiguredAccountPoolModels(value) {
|
|
@@ -45989,7 +46034,7 @@ const SHORTCUT_SETTINGS_KEYS = [
|
|
|
45989
46034
|
];
|
|
45990
46035
|
function normalizeShortcutFields(raw) {
|
|
45991
46036
|
const result = {};
|
|
45992
|
-
for (const key of SHORTCUT_SETTINGS_KEYS) result[key] = asString$
|
|
46037
|
+
for (const key of SHORTCUT_SETTINGS_KEYS) result[key] = asString$2(raw[key]) ?? null;
|
|
45993
46038
|
return result;
|
|
45994
46039
|
}
|
|
45995
46040
|
function normalizeStringArrayField(raw, key) {
|
|
@@ -46054,8 +46099,8 @@ function createDefaultStore() {
|
|
|
46054
46099
|
}
|
|
46055
46100
|
function normalizeApiKeyRecord(id, value) {
|
|
46056
46101
|
const record = isRecord$2(value) ? value : null;
|
|
46057
|
-
const tokenHash = asString$
|
|
46058
|
-
const tokenPreview = asString$
|
|
46102
|
+
const tokenHash = asString$2(record?.tokenHash);
|
|
46103
|
+
const tokenPreview = asString$2(record?.tokenPreview);
|
|
46059
46104
|
const createdAt = normalizeIsoString(record?.createdAt);
|
|
46060
46105
|
if (!tokenHash || !tokenPreview || !createdAt) return null;
|
|
46061
46106
|
return {
|
|
@@ -46069,25 +46114,25 @@ function normalizeApiKeyRecord(id, value) {
|
|
|
46069
46114
|
}
|
|
46070
46115
|
function normalizeLegacySessionRecord(id, value) {
|
|
46071
46116
|
const record = isRecord$2(value) ? value : null;
|
|
46072
|
-
const profileName = asString$
|
|
46073
|
-
const threadId = asString$
|
|
46117
|
+
const profileName = asString$2(record?.profileName);
|
|
46118
|
+
const threadId = asString$2(record?.threadId);
|
|
46074
46119
|
const createdAt = normalizeIsoString(record?.createdAt);
|
|
46075
46120
|
const lastUsedAt = normalizeIsoString(record?.lastUsedAt);
|
|
46076
46121
|
if (!profileName || !threadId || !createdAt || !lastUsedAt) return null;
|
|
46077
46122
|
return {
|
|
46078
46123
|
id,
|
|
46079
46124
|
affinityKind: normalizeLegacyAffinityKind(record?.affinityKind),
|
|
46080
|
-
affinityKey: asString$
|
|
46125
|
+
affinityKey: asString$2(record?.affinityKey),
|
|
46081
46126
|
profileName,
|
|
46082
46127
|
threadId,
|
|
46083
|
-
providerThreadId: asString$
|
|
46084
|
-
model: asString$
|
|
46128
|
+
providerThreadId: asString$2(record?.providerThreadId),
|
|
46129
|
+
model: asString$2(record?.model),
|
|
46085
46130
|
status: normalizeSessionStatus(record?.status),
|
|
46086
|
-
lastError: asString$
|
|
46131
|
+
lastError: asString$2(record?.lastError),
|
|
46087
46132
|
createdAt,
|
|
46088
46133
|
lastUsedAt,
|
|
46089
46134
|
expiresAt: normalizeIsoString(record?.expiresAt),
|
|
46090
|
-
lastResponseId: asString$
|
|
46135
|
+
lastResponseId: asString$2(record?.lastResponseId),
|
|
46091
46136
|
responseIds: normalizeStringArray(record?.responseIds).slice(0, MAX_RESPONSE_IDS_PER_SESSION)
|
|
46092
46137
|
};
|
|
46093
46138
|
}
|
|
@@ -46105,7 +46150,7 @@ function normalizeLegacyStore(value) {
|
|
|
46105
46150
|
}
|
|
46106
46151
|
const responseIndex = {};
|
|
46107
46152
|
for (const [responseId, sessionId] of Object.entries(isRecord$2(record?.responseIndex) ? record.responseIndex : {})) {
|
|
46108
|
-
const normalizedSessionId = asString$
|
|
46153
|
+
const normalizedSessionId = asString$2(sessionId);
|
|
46109
46154
|
if (normalizedSessionId) responseIndex[responseId] = normalizedSessionId;
|
|
46110
46155
|
}
|
|
46111
46156
|
return {
|
|
@@ -46118,58 +46163,58 @@ function normalizeLegacyStore(value) {
|
|
|
46118
46163
|
}
|
|
46119
46164
|
function normalizeTranscriptEntry(value) {
|
|
46120
46165
|
const record = isRecord$2(value) ? value : null;
|
|
46121
|
-
const role = asString$
|
|
46166
|
+
const role = asString$2(record?.role);
|
|
46122
46167
|
const createdAt = normalizeIsoString(record?.createdAt);
|
|
46123
46168
|
if (role !== "user" && role !== "assistant" || !createdAt) return null;
|
|
46124
46169
|
return {
|
|
46125
46170
|
role,
|
|
46126
|
-
text: asString$
|
|
46171
|
+
text: asString$2(record?.text),
|
|
46127
46172
|
images: normalizeStringArray(record?.images),
|
|
46128
46173
|
createdAt
|
|
46129
46174
|
};
|
|
46130
46175
|
}
|
|
46131
46176
|
function normalizeSessionRecord(id, value) {
|
|
46132
46177
|
const record = isRecord$2(value) ? value : null;
|
|
46133
|
-
const activeSegmentId = asString$
|
|
46178
|
+
const activeSegmentId = asString$2(record?.activeSegmentId);
|
|
46134
46179
|
const createdAt = normalizeIsoString(record?.createdAt);
|
|
46135
46180
|
const lastUsedAt = normalizeIsoString(record?.lastUsedAt);
|
|
46136
46181
|
if (!activeSegmentId || !createdAt || !lastUsedAt) return null;
|
|
46137
46182
|
const transcript = Array.isArray(record?.transcript) ? record.transcript.map(normalizeTranscriptEntry).filter((entry) => entry !== null) : [];
|
|
46138
|
-
const legacyExposedModel = asString$
|
|
46183
|
+
const legacyExposedModel = asString$2(record?.exposedModel);
|
|
46139
46184
|
const parsedLegacyExposedModel = legacyExposedModel ? parseAccountPoolReasoningVariantModelId(legacyExposedModel) : null;
|
|
46140
46185
|
const forcedServiceTier = normalizeServiceTier(record?.forcedServiceTier);
|
|
46141
46186
|
const forcedReasoningEffort = normalizeReasoningEffort(record?.forcedReasoningEffort) ?? parsedLegacyExposedModel?.reasoningEffort ?? null;
|
|
46142
46187
|
return {
|
|
46143
46188
|
id,
|
|
46144
46189
|
affinityKind: normalizeSessionAffinityKind(record?.affinityKind),
|
|
46145
|
-
affinityKey: asString$
|
|
46190
|
+
affinityKey: asString$2(record?.affinityKey),
|
|
46146
46191
|
activeSegmentId,
|
|
46147
46192
|
segmentIds: normalizeStringArray(record?.segmentIds),
|
|
46148
|
-
model: asString$
|
|
46193
|
+
model: asString$2(record?.model),
|
|
46149
46194
|
exposedModel: parsedLegacyExposedModel ? buildAccountPoolVariantModelId({
|
|
46150
46195
|
modelId: parsedLegacyExposedModel.modelId,
|
|
46151
46196
|
reasoningEffort: parsedLegacyExposedModel.reasoningEffort,
|
|
46152
46197
|
fastMode: forcedServiceTier === "fast"
|
|
46153
|
-
}) : legacyExposedModel ?? asString$
|
|
46198
|
+
}) : legacyExposedModel ?? asString$2(record?.model),
|
|
46154
46199
|
forcedReasoningEffort,
|
|
46155
46200
|
forcedServiceTier,
|
|
46156
46201
|
status: normalizeSessionStatus(record?.status),
|
|
46157
|
-
lastError: asString$
|
|
46202
|
+
lastError: asString$2(record?.lastError),
|
|
46158
46203
|
createdAt,
|
|
46159
46204
|
lastUsedAt,
|
|
46160
46205
|
expiresAt: normalizeIsoString(record?.expiresAt),
|
|
46161
|
-
lastResponseId: asString$
|
|
46206
|
+
lastResponseId: asString$2(record?.lastResponseId),
|
|
46162
46207
|
responseIds: normalizeStringArray(record?.responseIds).slice(0, MAX_RESPONSE_IDS_PER_SESSION),
|
|
46163
46208
|
rolloverCount: asNumber$1(record?.rolloverCount) ?? 0,
|
|
46164
|
-
lastRolloverReason: asString$
|
|
46209
|
+
lastRolloverReason: asString$2(record?.lastRolloverReason),
|
|
46165
46210
|
transcript: transcript.slice(-MAX_TRANSCRIPT_ENTRIES_PER_SESSION)
|
|
46166
46211
|
};
|
|
46167
46212
|
}
|
|
46168
46213
|
function normalizeSegmentRecord(id, value) {
|
|
46169
46214
|
const record = isRecord$2(value) ? value : null;
|
|
46170
|
-
const sessionId = asString$
|
|
46171
|
-
const profileName = asString$
|
|
46172
|
-
const threadId = asString$
|
|
46215
|
+
const sessionId = asString$2(record?.sessionId);
|
|
46216
|
+
const profileName = asString$2(record?.profileName);
|
|
46217
|
+
const threadId = asString$2(record?.threadId);
|
|
46173
46218
|
const createdAt = normalizeIsoString(record?.createdAt);
|
|
46174
46219
|
const lastUsedAt = normalizeIsoString(record?.lastUsedAt);
|
|
46175
46220
|
if (!sessionId || !profileName || !threadId || !createdAt || !lastUsedAt) return null;
|
|
@@ -46178,11 +46223,11 @@ function normalizeSegmentRecord(id, value) {
|
|
|
46178
46223
|
sessionId,
|
|
46179
46224
|
profileName,
|
|
46180
46225
|
threadId,
|
|
46181
|
-
providerThreadId: asString$
|
|
46226
|
+
providerThreadId: asString$2(record?.providerThreadId),
|
|
46182
46227
|
createdAt,
|
|
46183
46228
|
lastUsedAt,
|
|
46184
46229
|
closedAt: normalizeIsoString(record?.closedAt),
|
|
46185
|
-
closeReason: asString$
|
|
46230
|
+
closeReason: asString$2(record?.closeReason),
|
|
46186
46231
|
failureClass: normalizeFailureClass(record?.failureClass)
|
|
46187
46232
|
};
|
|
46188
46233
|
}
|
|
@@ -46192,13 +46237,13 @@ function normalizeProfileStateRecord(value) {
|
|
|
46192
46237
|
cooldownUntil: normalizeIsoString(record?.cooldownUntil),
|
|
46193
46238
|
lastFailureClass: normalizeFailureClass(record?.lastFailureClass),
|
|
46194
46239
|
lastFailureAt: normalizeIsoString(record?.lastFailureAt),
|
|
46195
|
-
lastFailureMessage: asString$
|
|
46240
|
+
lastFailureMessage: asString$2(record?.lastFailureMessage)
|
|
46196
46241
|
};
|
|
46197
46242
|
}
|
|
46198
46243
|
function normalizeResponseIndexRecord(value) {
|
|
46199
46244
|
const record = isRecord$2(value) ? value : null;
|
|
46200
|
-
const sessionId = asString$
|
|
46201
|
-
const segmentId = asString$
|
|
46245
|
+
const sessionId = asString$2(record?.sessionId);
|
|
46246
|
+
const segmentId = asString$2(record?.segmentId);
|
|
46202
46247
|
const createdAt = normalizeIsoString(record?.createdAt) ?? (/* @__PURE__ */ new Date(0)).toISOString();
|
|
46203
46248
|
if (!sessionId || !segmentId) return null;
|
|
46204
46249
|
return {
|
|
@@ -46226,7 +46271,7 @@ function normalizeStore(value) {
|
|
|
46226
46271
|
}
|
|
46227
46272
|
const profilesByName = {};
|
|
46228
46273
|
for (const [name, profileValue] of Object.entries(isRecord$2(record?.profilesByName) ? record.profilesByName : {})) {
|
|
46229
|
-
const normalizedName = asString$
|
|
46274
|
+
const normalizedName = asString$2(name);
|
|
46230
46275
|
if (!normalizedName) continue;
|
|
46231
46276
|
profilesByName[normalizedName] = normalizeProfileStateRecord(profileValue);
|
|
46232
46277
|
}
|
|
@@ -46358,8 +46403,8 @@ function extractTextAndImages(value) {
|
|
|
46358
46403
|
};
|
|
46359
46404
|
const record = isRecord$2(value) ? value : null;
|
|
46360
46405
|
const arrayValue = Array.isArray(value) ? value : Array.isArray(record?.content) ? record?.content : null;
|
|
46361
|
-
const directText = asString$
|
|
46362
|
-
const directImage = asString$
|
|
46406
|
+
const directText = asString$2(record?.text) ?? asString$2(record?.content);
|
|
46407
|
+
const directImage = asString$2(record?.image_url) ?? asString$2(record?.url) ?? asString$2(record?.imageUrl);
|
|
46363
46408
|
if (!arrayValue) return {
|
|
46364
46409
|
text: directText,
|
|
46365
46410
|
images: directImage ? [directImage] : []
|
|
@@ -46373,9 +46418,9 @@ function extractTextAndImages(value) {
|
|
|
46373
46418
|
}
|
|
46374
46419
|
const part = isRecord$2(entry) ? entry : null;
|
|
46375
46420
|
if (!part) continue;
|
|
46376
|
-
const partType = asString$
|
|
46377
|
-
const text = asString$
|
|
46378
|
-
const image = asString$
|
|
46421
|
+
const partType = asString$2(part.type) ?? "text";
|
|
46422
|
+
const text = asString$2(part.text) ?? asString$2(part.content) ?? asString$2(part.value);
|
|
46423
|
+
const image = asString$2(part.image_url) ?? asString$2(part.url) ?? asString$2(part.imageUrl);
|
|
46379
46424
|
if ((partType === "text" || partType === "input_text" || partType === "output_text" || partType === "refusal") && text) {
|
|
46380
46425
|
texts.push(text);
|
|
46381
46426
|
continue;
|
|
@@ -46388,7 +46433,7 @@ function extractTextAndImages(value) {
|
|
|
46388
46433
|
};
|
|
46389
46434
|
}
|
|
46390
46435
|
function assistantLabel(value) {
|
|
46391
|
-
const normalized = asString$
|
|
46436
|
+
const normalized = asString$2(value)?.toLowerCase();
|
|
46392
46437
|
return normalized && normalized.length > 0 ? normalized : null;
|
|
46393
46438
|
}
|
|
46394
46439
|
function isAssistantLikeRecord(value) {
|
|
@@ -46408,8 +46453,8 @@ function collectTextFragments(value, depth = 0) {
|
|
|
46408
46453
|
const record = isRecord$2(value) ? value : null;
|
|
46409
46454
|
if (!record) return [];
|
|
46410
46455
|
return [
|
|
46411
|
-
asString$
|
|
46412
|
-
asString$
|
|
46456
|
+
asString$2(record.text),
|
|
46457
|
+
asString$2(record.output_text),
|
|
46413
46458
|
...collectTextFragments(record.content, depth + 1),
|
|
46414
46459
|
...collectTextFragments(record.parts, depth + 1),
|
|
46415
46460
|
...collectTextFragments(record.output, depth + 1),
|
|
@@ -46443,7 +46488,7 @@ function extractAssistantTextSnapshot(value, depth = 0) {
|
|
|
46443
46488
|
}
|
|
46444
46489
|
function prepareTurnInput(body, fallbackModel) {
|
|
46445
46490
|
const input = body.input;
|
|
46446
|
-
const instructions = asString$
|
|
46491
|
+
const instructions = asString$2(body.instructions);
|
|
46447
46492
|
const messages = [];
|
|
46448
46493
|
const looseImages = [];
|
|
46449
46494
|
let looseText = null;
|
|
@@ -46455,8 +46500,8 @@ function prepareTurnInput(body, fallbackModel) {
|
|
|
46455
46500
|
}
|
|
46456
46501
|
const record = isRecord$2(entry) ? entry : null;
|
|
46457
46502
|
if (!record) continue;
|
|
46458
|
-
const entryRole = asString$
|
|
46459
|
-
const entryType = asString$
|
|
46503
|
+
const entryRole = asString$2(record.role);
|
|
46504
|
+
const entryType = asString$2(record.type);
|
|
46460
46505
|
if (entryRole || entryType === "message") {
|
|
46461
46506
|
const { text, images } = extractTextAndImages(record.content ?? record);
|
|
46462
46507
|
messages.push({
|
|
@@ -46498,8 +46543,8 @@ function prepareTurnInput(body, fallbackModel) {
|
|
|
46498
46543
|
if (instructions) promptParts.push(`Instructions:\n${instructions}`);
|
|
46499
46544
|
if (transcriptParts.length > 0) promptParts.push(`Conversation so far:\n${transcriptParts.join("\n\n")}`);
|
|
46500
46545
|
if (finalPrompt) promptParts.push(finalPrompt);
|
|
46501
|
-
const normalizedModel = normalizeModelSlug(asString$
|
|
46502
|
-
const effort = asString$
|
|
46546
|
+
const normalizedModel = normalizeModelSlug(asString$2(body.model) ?? fallbackModel, "codex") ?? fallbackModel;
|
|
46547
|
+
const effort = asString$2((isRecord$2(body.reasoning) ? body.reasoning : null)?.effort) ?? asString$2(body.effort) ?? void 0;
|
|
46503
46548
|
return {
|
|
46504
46549
|
prompt: promptParts.join("\n\n").trim() || null,
|
|
46505
46550
|
attachments: [...looseImages, ...finalUserImages].map((url) => ({
|
|
@@ -46508,27 +46553,27 @@ function prepareTurnInput(body, fallbackModel) {
|
|
|
46508
46553
|
})),
|
|
46509
46554
|
model: normalizedModel,
|
|
46510
46555
|
effort,
|
|
46511
|
-
serviceTier: asString$
|
|
46556
|
+
serviceTier: asString$2(body.service_tier),
|
|
46512
46557
|
userText: finalPrompt ?? looseText,
|
|
46513
46558
|
userImages: [...looseImages, ...finalUserImages],
|
|
46514
46559
|
includesConversationHistory: transcriptParts.length > 0
|
|
46515
46560
|
};
|
|
46516
46561
|
}
|
|
46517
46562
|
function resolveResponseContinuationKey(body, headers) {
|
|
46518
|
-
const previousResponseId = asString$
|
|
46519
|
-
const conversation = asString$
|
|
46563
|
+
const previousResponseId = asString$2(body.previous_response_id);
|
|
46564
|
+
const conversation = asString$2(body.conversation) ?? (isRecord$2(body.conversation) ? asString$2(body.conversation.id) : null);
|
|
46520
46565
|
if (conversation && previousResponseId) throw new AccountPoolRequestError({
|
|
46521
46566
|
statusCode: 400,
|
|
46522
46567
|
code: "invalid_request_error",
|
|
46523
46568
|
message: "Provide either 'conversation' or 'previous_response_id', not both."
|
|
46524
46569
|
});
|
|
46525
|
-
const durableKey = asString$
|
|
46570
|
+
const durableKey = asString$2(headers["x-codex-turn-state"]) ?? asString$2(body.session_id) ?? asString$2(headers["x-session-id"]) ?? asString$2(headers["x-codex-session-id"]) ?? asString$2(headers["x-conversation-id"]) ?? conversation;
|
|
46526
46571
|
if (durableKey) return {
|
|
46527
46572
|
previousResponseId,
|
|
46528
46573
|
affinityKind: "pool_session",
|
|
46529
46574
|
affinityKey: durableKey
|
|
46530
46575
|
};
|
|
46531
|
-
const promptCacheKey = asString$
|
|
46576
|
+
const promptCacheKey = asString$2(body.prompt_cache_key);
|
|
46532
46577
|
if (promptCacheKey) return {
|
|
46533
46578
|
previousResponseId,
|
|
46534
46579
|
affinityKind: "prompt_cache",
|
|
@@ -46605,48 +46650,25 @@ function buildAccountPoolExposedModel(id) {
|
|
|
46605
46650
|
const normalizedId = normalizeModelSlug(id, "codex") ?? id.trim();
|
|
46606
46651
|
if (normalizedId.length === 0) return null;
|
|
46607
46652
|
const architecture = inferAccountPoolModelArchitecture(normalizedId);
|
|
46608
|
-
const
|
|
46609
|
-
if (lowerId.startsWith("gpt-5.4-mini")) return {
|
|
46610
|
-
id: normalizedId,
|
|
46611
|
-
actualModelId: normalizedId,
|
|
46612
|
-
name: "GPT-5.4 Mini",
|
|
46613
|
-
description: "GPT-5.4 Mini exposed through the local accounts pool.",
|
|
46614
|
-
architecture,
|
|
46615
|
-
supportedParameters: ACCOUNT_POOL_MODEL_SUPPORTED_PARAMETERS,
|
|
46616
|
-
forcedReasoningEffort: null,
|
|
46617
|
-
forcedServiceTier: null
|
|
46618
|
-
};
|
|
46619
|
-
if (lowerId.startsWith("gpt-5.4-nano")) return {
|
|
46620
|
-
id: normalizedId,
|
|
46621
|
-
actualModelId: normalizedId,
|
|
46622
|
-
name: "GPT-5.4 Nano",
|
|
46623
|
-
description: "GPT-5.4 Nano exposed through the local accounts pool.",
|
|
46624
|
-
architecture,
|
|
46625
|
-
supportedParameters: ACCOUNT_POOL_MODEL_SUPPORTED_PARAMETERS,
|
|
46626
|
-
forcedReasoningEffort: null,
|
|
46627
|
-
forcedServiceTier: null
|
|
46628
|
-
};
|
|
46629
|
-
if (lowerId.startsWith("gpt-5.4-pro")) return {
|
|
46630
|
-
id: normalizedId,
|
|
46631
|
-
actualModelId: normalizedId,
|
|
46632
|
-
name: "GPT-5.4 Pro",
|
|
46633
|
-
description: "GPT-5.4 Pro exposed through the local accounts pool.",
|
|
46634
|
-
architecture,
|
|
46635
|
-
supportedParameters: ACCOUNT_POOL_MODEL_SUPPORTED_PARAMETERS,
|
|
46636
|
-
forcedReasoningEffort: null,
|
|
46637
|
-
forcedServiceTier: null
|
|
46638
|
-
};
|
|
46653
|
+
const displayName = formatAccountPoolModelName(normalizedId);
|
|
46639
46654
|
return {
|
|
46640
46655
|
id: normalizedId,
|
|
46641
46656
|
actualModelId: normalizedId,
|
|
46642
|
-
name:
|
|
46643
|
-
description:
|
|
46657
|
+
name: displayName ?? normalizedId,
|
|
46658
|
+
description: displayName ? `${displayName} exposed through the local accounts pool.` : `${normalizedId} exposed through the local accounts pool.`,
|
|
46644
46659
|
architecture,
|
|
46645
46660
|
supportedParameters: ACCOUNT_POOL_MODEL_SUPPORTED_PARAMETERS,
|
|
46646
46661
|
forcedReasoningEffort: null,
|
|
46647
46662
|
forcedServiceTier: null
|
|
46648
46663
|
};
|
|
46649
46664
|
}
|
|
46665
|
+
function formatAccountPoolModelName(modelId) {
|
|
46666
|
+
const match = /^gpt-(\d+(?:\.\d+)?)(?:-(mini|nano|pro))?$/i.exec(modelId.trim());
|
|
46667
|
+
if (!match) return null;
|
|
46668
|
+
const variant = match[2];
|
|
46669
|
+
const suffix = variant ? ` ${variant.charAt(0).toUpperCase()}${variant.slice(1)}` : "";
|
|
46670
|
+
return `GPT-${match[1]}${suffix}`;
|
|
46671
|
+
}
|
|
46650
46672
|
function inferAccountPoolModelArchitecture(modelId) {
|
|
46651
46673
|
return modelId.trim().toLowerCase().startsWith("gpt-5") ? ACCOUNT_POOL_MULTIMODAL_ARCHITECTURE : ACCOUNT_POOL_TEXT_ONLY_ARCHITECTURE;
|
|
46652
46674
|
}
|
|
@@ -47006,7 +47028,7 @@ var LocalAccountPool = class LocalAccountPool {
|
|
|
47006
47028
|
const responseItemId = `msg_${responseId}`;
|
|
47007
47029
|
let streamOpened = false;
|
|
47008
47030
|
let sequenceNumber = 1;
|
|
47009
|
-
const requestedModel = asString$
|
|
47031
|
+
const requestedModel = asString$2(body.model);
|
|
47010
47032
|
const defaultSelection = this.defaultModelSelection(settings);
|
|
47011
47033
|
const requestedSelection = requestedModel ? this.resolveConfiguredModelSelection(settings, requestedModel) : null;
|
|
47012
47034
|
let responseModel = requestedModel ?? defaultSelection.exposedModelId;
|
|
@@ -47754,8 +47776,8 @@ var LocalAccountPool = class LocalAccountPool {
|
|
|
47754
47776
|
if (event.method === "turn/completed") {
|
|
47755
47777
|
const payload = isRecord$2(event.payload) ? event.payload : null;
|
|
47756
47778
|
const turn = isRecord$2(payload?.turn) ? payload?.turn : payload;
|
|
47757
|
-
const turnStatus = asString$
|
|
47758
|
-
const errorMessage = asString$
|
|
47779
|
+
const turnStatus = asString$2(turn?.status);
|
|
47780
|
+
const errorMessage = asString$2(isRecord$2(turn?.error) ? turn.error.message : void 0) ?? asString$2(payload?.message);
|
|
47759
47781
|
if (turnStatus === "failed" || errorMessage) {
|
|
47760
47782
|
observer.done = true;
|
|
47761
47783
|
observer.reject(new Error(errorMessage ?? "Provider turn failed."));
|
|
@@ -47805,7 +47827,7 @@ var LocalAccountPool = class LocalAccountPool {
|
|
|
47805
47827
|
}
|
|
47806
47828
|
extractEventErrorMessage(payload) {
|
|
47807
47829
|
if (!isRecord$2(payload)) return null;
|
|
47808
|
-
return asString$
|
|
47830
|
+
return asString$2((isRecord$2(payload.error) ? payload.error : payload).message) ?? null;
|
|
47809
47831
|
}
|
|
47810
47832
|
readLiveProviderThreadId(threadId) {
|
|
47811
47833
|
const active = this.manager.listSessions().find((session) => session.threadId === ThreadId.makeUnsafe(threadId));
|
|
@@ -47813,7 +47835,7 @@ var LocalAccountPool = class LocalAccountPool {
|
|
|
47813
47835
|
}
|
|
47814
47836
|
readResumeCursorThreadId(resumeCursor) {
|
|
47815
47837
|
if (!isRecord$2(resumeCursor)) return null;
|
|
47816
|
-
return asString$
|
|
47838
|
+
return asString$2(resumeCursor.threadId);
|
|
47817
47839
|
}
|
|
47818
47840
|
async closeLiveSegment(segmentId) {
|
|
47819
47841
|
const liveSegment = this.liveSegments.get(segmentId);
|
|
@@ -48005,13 +48027,13 @@ var LocalAccountPool = class LocalAccountPool {
|
|
|
48005
48027
|
if (this.settingsCache && this.settingsCache.expiresAt > now) return this.settingsCache.settings;
|
|
48006
48028
|
const raw = await readAppSettings();
|
|
48007
48029
|
const settings = {
|
|
48008
|
-
codexBin: asString$
|
|
48009
|
-
codexArgs: asString$
|
|
48010
|
-
codexHome: asString$
|
|
48030
|
+
codexBin: asString$2(raw.codexBin) ?? null,
|
|
48031
|
+
codexArgs: asString$2(raw.codexArgs) ?? null,
|
|
48032
|
+
codexHome: asString$2(raw.codexHome) ?? null,
|
|
48011
48033
|
automaticAppUpdateChecksEnabled: raw.automaticAppUpdateChecksEnabled !== false,
|
|
48012
48034
|
keepAppRunningAfterWindowClose: raw.keepAppRunningAfterWindowClose === true,
|
|
48013
48035
|
telegramBridgeEnabled: raw.telegramBridgeEnabled === true,
|
|
48014
|
-
telegramBotToken: asString$
|
|
48036
|
+
telegramBotToken: asString$2(raw.telegramBotToken) ?? null,
|
|
48015
48037
|
telegramAllowedChatIds: normalizeStringArrayField(raw, "telegramAllowedChatIds"),
|
|
48016
48038
|
defaultAccessMode: "current",
|
|
48017
48039
|
reviewDeliveryMode: "inline",
|
|
@@ -48022,6 +48044,7 @@ var LocalAccountPool = class LocalAccountPool {
|
|
|
48022
48044
|
projectsDefaultThreadEnvMode: raw.projectsDefaultThreadEnvMode === "worktree" ? "worktree" : "local",
|
|
48023
48045
|
projectsAssistantStreamingEnabled: false,
|
|
48024
48046
|
projectsConfirmThreadDelete: true,
|
|
48047
|
+
projectsAddProjectBaseDirectory: asString$2(raw.projectsAddProjectBaseDirectory) ?? null,
|
|
48025
48048
|
projectsCustomCodexModels: normalizeStringArrayField(raw, "projectsCustomCodexModels"),
|
|
48026
48049
|
...normalizeAccountPoolFields(raw)
|
|
48027
48050
|
};
|
|
@@ -48115,7 +48138,8 @@ const FAVICON_CANDIDATES = [
|
|
|
48115
48138
|
"assets/icon.svg",
|
|
48116
48139
|
"assets/icon.png",
|
|
48117
48140
|
"assets/logo.svg",
|
|
48118
|
-
"assets/logo.png"
|
|
48141
|
+
"assets/logo.png",
|
|
48142
|
+
".idea/icon.svg"
|
|
48119
48143
|
];
|
|
48120
48144
|
const ICON_SOURCE_FILES = [
|
|
48121
48145
|
"index.html",
|
|
@@ -49428,8 +49452,11 @@ async function assertProfileCreationAllowed(profileManager) {
|
|
|
49428
49452
|
//#endregion
|
|
49429
49453
|
//#region src/codex/runtimeInspection.ts
|
|
49430
49454
|
const COMMAND_TIMEOUT_MS = 5e3;
|
|
49455
|
+
const AUTH_STATUS_TIMEOUT_MS = 8e3;
|
|
49431
49456
|
const APP_SERVER_TIMEOUT_MS = 8e3;
|
|
49432
49457
|
const MODEL_LIST_TIMEOUT_MS = 5e3;
|
|
49458
|
+
const CODEX_NPM_PACKAGE = "@openai/codex";
|
|
49459
|
+
const CODEX_INSTALL_TIMEOUT_MS = 12e4;
|
|
49433
49460
|
function tokenizeArgs(rawArgs) {
|
|
49434
49461
|
const input = rawArgs?.trim();
|
|
49435
49462
|
if (!input) return [];
|
|
@@ -49517,16 +49544,26 @@ function runCommand(command, args, options) {
|
|
|
49517
49544
|
globalThis.clearTimeout(timeout);
|
|
49518
49545
|
reject(error);
|
|
49519
49546
|
});
|
|
49520
|
-
child.on("close", (code) => {
|
|
49547
|
+
child.on("close", (code, signal) => {
|
|
49521
49548
|
globalThis.clearTimeout(timeout);
|
|
49522
49549
|
resolve({
|
|
49523
49550
|
stdout,
|
|
49524
49551
|
stderr,
|
|
49525
|
-
code
|
|
49552
|
+
code,
|
|
49553
|
+
signal
|
|
49526
49554
|
});
|
|
49527
49555
|
});
|
|
49528
49556
|
});
|
|
49529
49557
|
}
|
|
49558
|
+
function describeCommandFailure(result, fallback) {
|
|
49559
|
+
const stderr = result.stderr.trim();
|
|
49560
|
+
if (stderr) return stderr;
|
|
49561
|
+
const stdout = result.stdout.trim();
|
|
49562
|
+
if (stdout) return stdout;
|
|
49563
|
+
if (result.signal) return `Codex CLI was found but was terminated by ${result.signal}.`;
|
|
49564
|
+
if (result.code !== null) return `Codex CLI exited with code ${result.code}.`;
|
|
49565
|
+
return fallback;
|
|
49566
|
+
}
|
|
49530
49567
|
function coerceModelListItems(response) {
|
|
49531
49568
|
if (!response || typeof response !== "object") return [];
|
|
49532
49569
|
const record = response;
|
|
@@ -49568,6 +49605,26 @@ function parseModelListResponse(response) {
|
|
|
49568
49605
|
};
|
|
49569
49606
|
}).filter((model) => model !== null);
|
|
49570
49607
|
}
|
|
49608
|
+
function asRecord$1(value) {
|
|
49609
|
+
return value && typeof value === "object" ? value : null;
|
|
49610
|
+
}
|
|
49611
|
+
function asString$1(value) {
|
|
49612
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
49613
|
+
}
|
|
49614
|
+
function formatCodexAccountLabel(response) {
|
|
49615
|
+
const record = asRecord$1(response);
|
|
49616
|
+
const account = asRecord$1(record?.account) ?? record;
|
|
49617
|
+
if (!account) return null;
|
|
49618
|
+
const type = asString$1(account.type);
|
|
49619
|
+
const email = asString$1(account.email) ?? asString$1(account.login) ?? asString$1(account.accountEmail) ?? asString$1(account.account_email);
|
|
49620
|
+
const plan = asString$1(account.planType) ?? asString$1(account.plan_type) ?? asString$1(account.plan);
|
|
49621
|
+
if (email && plan) return `${email} (${plan})`;
|
|
49622
|
+
if (email) return email;
|
|
49623
|
+
if (type === "apiKey") return "API key";
|
|
49624
|
+
if (type === "chatgpt" && plan) return `ChatGPT ${plan}`;
|
|
49625
|
+
if (type === "chatgpt") return "ChatGPT";
|
|
49626
|
+
return null;
|
|
49627
|
+
}
|
|
49571
49628
|
function compareModelsByLatest(left, right) {
|
|
49572
49629
|
const parseVersionScore = (model) => {
|
|
49573
49630
|
const match = /^gpt-(\d+)(?:\.(\d+))?(?:\.(\d+))?/i.exec(model.trim());
|
|
@@ -49685,10 +49742,13 @@ async function inspectAppServer(input) {
|
|
|
49685
49742
|
params: {}
|
|
49686
49743
|
})}\n`);
|
|
49687
49744
|
try {
|
|
49745
|
+
const modelListResponse = await request("model/list", {}, MODEL_LIST_TIMEOUT_MS);
|
|
49746
|
+
const accountResponse = await request("account/read", {}, MODEL_LIST_TIMEOUT_MS).catch(() => null);
|
|
49688
49747
|
return {
|
|
49689
49748
|
appServerOk: true,
|
|
49690
|
-
models: parseModelListResponse(
|
|
49749
|
+
models: parseModelListResponse(modelListResponse).sort(compareModelsByLatest),
|
|
49691
49750
|
modelsError: null,
|
|
49751
|
+
accountLabel: formatCodexAccountLabel(accountResponse),
|
|
49692
49752
|
details: null
|
|
49693
49753
|
};
|
|
49694
49754
|
} catch (error) {
|
|
@@ -49696,6 +49756,7 @@ async function inspectAppServer(input) {
|
|
|
49696
49756
|
appServerOk: true,
|
|
49697
49757
|
models: [],
|
|
49698
49758
|
modelsError: error instanceof Error ? error.message : "Unable to read model list.",
|
|
49759
|
+
accountLabel: null,
|
|
49699
49760
|
details: stderr.trim() || null
|
|
49700
49761
|
};
|
|
49701
49762
|
}
|
|
@@ -49704,6 +49765,7 @@ async function inspectAppServer(input) {
|
|
|
49704
49765
|
appServerOk: false,
|
|
49705
49766
|
models: [],
|
|
49706
49767
|
modelsError: null,
|
|
49768
|
+
accountLabel: null,
|
|
49707
49769
|
details: error instanceof Error ? error.message : stderr.trim() || "Unable to start codex app-server."
|
|
49708
49770
|
};
|
|
49709
49771
|
} finally {
|
|
@@ -49729,7 +49791,7 @@ async function inspectCodexRuntime(input) {
|
|
|
49729
49791
|
});
|
|
49730
49792
|
const parsedVersion = parseCodexCliVersion(`${versionResult.stdout}\n${versionResult.stderr}`);
|
|
49731
49793
|
version = parsedVersion ?? (versionResult.stdout.trim() || null);
|
|
49732
|
-
if (versionResult.code !== 0) details =
|
|
49794
|
+
if (versionResult.code !== 0) details = describeCommandFailure(versionResult, "Codex CLI failed to run `--version`.");
|
|
49733
49795
|
else if (parsedVersion && !isCodexCliVersionSupported(parsedVersion)) details = formatCodexCliUpgradeMessage(parsedVersion);
|
|
49734
49796
|
} catch (error) {
|
|
49735
49797
|
details = error instanceof Error ? error.message : "Unable to run Codex CLI.";
|
|
@@ -49741,7 +49803,7 @@ async function inspectCodexRuntime(input) {
|
|
|
49741
49803
|
"status"
|
|
49742
49804
|
]);
|
|
49743
49805
|
const authResult = await runCommand(authCommand.command, authCommand.args, {
|
|
49744
|
-
timeoutMs:
|
|
49806
|
+
timeoutMs: AUTH_STATUS_TIMEOUT_MS,
|
|
49745
49807
|
env
|
|
49746
49808
|
});
|
|
49747
49809
|
const parsedAuth = parseAuthStatusFromOutput({
|
|
@@ -49774,6 +49836,7 @@ async function inspectCodexRuntime(input) {
|
|
|
49774
49836
|
appServerOk: false,
|
|
49775
49837
|
models: [],
|
|
49776
49838
|
modelsError: null,
|
|
49839
|
+
accountLabel: null,
|
|
49777
49840
|
details: null
|
|
49778
49841
|
};
|
|
49779
49842
|
return {
|
|
@@ -49784,6 +49847,7 @@ async function inspectCodexRuntime(input) {
|
|
|
49784
49847
|
appServerOk: appServerInspection.appServerOk,
|
|
49785
49848
|
authStatus,
|
|
49786
49849
|
authMessage,
|
|
49850
|
+
accountLabel: appServerInspection.accountLabel,
|
|
49787
49851
|
details: details ?? appServerInspection.details,
|
|
49788
49852
|
path: binaryPath,
|
|
49789
49853
|
nodeOk,
|
|
@@ -49794,6 +49858,39 @@ async function inspectCodexRuntime(input) {
|
|
|
49794
49858
|
modelsError: appServerInspection.modelsError
|
|
49795
49859
|
};
|
|
49796
49860
|
}
|
|
49861
|
+
function compactCommandOutput(output) {
|
|
49862
|
+
const trimmed = output.trim();
|
|
49863
|
+
if (!trimmed) return null;
|
|
49864
|
+
return trimmed.length > 4e3 ? `${trimmed.slice(-4e3)}` : trimmed;
|
|
49865
|
+
}
|
|
49866
|
+
async function updateCodexRuntime() {
|
|
49867
|
+
const beforeVersion = (await inspectCodexRuntime({}).catch(() => null))?.doctor.version ?? null;
|
|
49868
|
+
const result = await runCommand("npm", [
|
|
49869
|
+
"install",
|
|
49870
|
+
"-g",
|
|
49871
|
+
CODEX_NPM_PACKAGE
|
|
49872
|
+
], {
|
|
49873
|
+
timeoutMs: CODEX_INSTALL_TIMEOUT_MS,
|
|
49874
|
+
env: process.env
|
|
49875
|
+
}).catch((error) => ({
|
|
49876
|
+
stdout: "",
|
|
49877
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
49878
|
+
code: 1
|
|
49879
|
+
}));
|
|
49880
|
+
const afterVersion = (await inspectCodexRuntime({}).catch(() => null))?.doctor.version ?? null;
|
|
49881
|
+
const ok = result.code === 0 && Boolean(afterVersion);
|
|
49882
|
+
const output = compactCommandOutput(`${result.stdout}\n${result.stderr}`);
|
|
49883
|
+
return {
|
|
49884
|
+
ok,
|
|
49885
|
+
method: "npm",
|
|
49886
|
+
package: CODEX_NPM_PACKAGE,
|
|
49887
|
+
beforeVersion,
|
|
49888
|
+
afterVersion,
|
|
49889
|
+
upgraded: Boolean(ok && afterVersion && (!beforeVersion || beforeVersion !== afterVersion)),
|
|
49890
|
+
output,
|
|
49891
|
+
details: ok ? null : output ?? `Failed to run npm install -g ${CODEX_NPM_PACKAGE}.`
|
|
49892
|
+
};
|
|
49893
|
+
}
|
|
49797
49894
|
//#endregion
|
|
49798
49895
|
//#region src/agentChat.ts
|
|
49799
49896
|
const AGENT_CHAT_AGENTS_CONTENT = `# AGENTS.md — Agent
|
|
@@ -51865,6 +51962,10 @@ const createServer = fn(function* () {
|
|
|
51865
51962
|
const agentChatConfig = getAgentChatConfig();
|
|
51866
51963
|
const generalChatConfig = getGeneralChatConfig();
|
|
51867
51964
|
yield* readiness.markPushBusReady;
|
|
51965
|
+
yield* forkScoped(providerHealth.refreshStatuses.pipe(tap((providers) => gen(function* () {
|
|
51966
|
+
yield* set$1(providersRef, providers);
|
|
51967
|
+
yield* pushBus.publishAll(WS_CHANNELS.serverProvidersUpdated, { providers });
|
|
51968
|
+
})), catch_((cause) => logWarning$1("failed to refresh provider health after server startup", { cause }))));
|
|
51868
51969
|
yield* keybindingsManager.start.pipe(mapError((cause) => new ServerLifecycleError({
|
|
51869
51970
|
operation: "keybindingsRuntimeStart",
|
|
51870
51971
|
cause
|
|
@@ -52894,6 +52995,7 @@ const createServer = fn(function* () {
|
|
|
52894
52995
|
codexHomePath: runtimeContext.codexHomePath
|
|
52895
52996
|
}));
|
|
52896
52997
|
}
|
|
52998
|
+
case WS_METHODS.codexRuntimeUpdate: return yield* promise(() => updateCodexRuntime());
|
|
52897
52999
|
case WS_METHODS.telegramStatus: return telegramBridge.getStatus();
|
|
52898
53000
|
case WS_METHODS.telegramTestToken: {
|
|
52899
53001
|
const body = stripRequestTag(request.body);
|