codexuse-cli 3.7.5 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +31 -13
- 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 +450 -369
- 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"];
|
|
@@ -24600,10 +24612,18 @@ function normalizeSpawnError(command, args, error) {
|
|
|
24600
24612
|
if (error.code === "ENOENT") return /* @__PURE__ */ new Error(`Command not found: ${command}`);
|
|
24601
24613
|
return /* @__PURE__ */ new Error(`Failed to run ${commandLabel$1(command, args)}: ${error.message}`);
|
|
24602
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
|
+
];
|
|
24603
24623
|
function isWindowsCommandNotFound(code, stderr) {
|
|
24604
24624
|
if (process.platform !== "win32") return false;
|
|
24605
24625
|
if (code === 9009) return true;
|
|
24606
|
-
return
|
|
24626
|
+
return WINDOWS_COMMAND_NOT_FOUND_PATTERNS.some((pattern) => pattern.test(stderr));
|
|
24607
24627
|
}
|
|
24608
24628
|
function normalizeExitError(command, args, result) {
|
|
24609
24629
|
if (isWindowsCommandNotFound(result.code, result.stderr)) return /* @__PURE__ */ new Error(`Command not found: ${command}`);
|
|
@@ -28738,6 +28758,14 @@ function rollback(db) {
|
|
|
28738
28758
|
db.exec("ROLLBACK");
|
|
28739
28759
|
} catch {}
|
|
28740
28760
|
}
|
|
28761
|
+
function useStatement(db, sql, task) {
|
|
28762
|
+
const statement = db.prepare(sql);
|
|
28763
|
+
try {
|
|
28764
|
+
return task(statement);
|
|
28765
|
+
} finally {
|
|
28766
|
+
statement.finalize?.();
|
|
28767
|
+
}
|
|
28768
|
+
}
|
|
28741
28769
|
async function withWriteQueue(dbPath, task) {
|
|
28742
28770
|
const previous = writeQueueByDbPath.get(dbPath) ?? Promise.resolve();
|
|
28743
28771
|
let release;
|
|
@@ -28807,7 +28835,7 @@ function resolveAppStorageDbPath(userDataDir) {
|
|
|
28807
28835
|
}
|
|
28808
28836
|
async function readDocument(dbPath, namespace, normalize) {
|
|
28809
28837
|
return withDatabase(dbPath, (db) => {
|
|
28810
|
-
const row = db
|
|
28838
|
+
const row = useStatement(db, `SELECT value_json AS valueJson FROM ${APP_STORAGE_TABLE} WHERE namespace = ?`, (statement) => statement.get(namespace));
|
|
28811
28839
|
const parsed = isRecord$8(row) ? safeParseJson(row.valueJson) : null;
|
|
28812
28840
|
if (parsed === null) return null;
|
|
28813
28841
|
return normalize(parsed);
|
|
@@ -28818,14 +28846,14 @@ async function writeDocument(dbPath, namespace, value) {
|
|
|
28818
28846
|
const normalizedValue = clone$1(value);
|
|
28819
28847
|
beginImmediate(db);
|
|
28820
28848
|
try {
|
|
28821
|
-
db
|
|
28849
|
+
useStatement(db, `
|
|
28822
28850
|
INSERT INTO ${APP_STORAGE_TABLE} (namespace, value_json, updated_at)
|
|
28823
28851
|
VALUES (?, ?, ?)
|
|
28824
28852
|
ON CONFLICT(namespace)
|
|
28825
28853
|
DO UPDATE SET
|
|
28826
28854
|
value_json = excluded.value_json,
|
|
28827
28855
|
updated_at = excluded.updated_at
|
|
28828
|
-
|
|
28856
|
+
`, (statement) => statement.run(namespace, JSON.stringify(normalizedValue), (/* @__PURE__ */ new Date()).toISOString()));
|
|
28829
28857
|
commit(db);
|
|
28830
28858
|
return normalizedValue;
|
|
28831
28859
|
} catch (error) {
|
|
@@ -28838,17 +28866,17 @@ async function updateDocument(input) {
|
|
|
28838
28866
|
return withWriteQueue(input.dbPath, async () => withDatabase(input.dbPath, (db) => {
|
|
28839
28867
|
beginImmediate(db);
|
|
28840
28868
|
try {
|
|
28841
|
-
const row = db
|
|
28869
|
+
const row = useStatement(db, `SELECT value_json AS valueJson FROM ${APP_STORAGE_TABLE} WHERE namespace = ?`, (statement) => statement.get(input.namespace));
|
|
28842
28870
|
const current = isRecord$8(row) ? input.normalize(safeParseJson(row.valueJson) ?? input.fallback()) : input.fallback();
|
|
28843
28871
|
const next = input.normalize(input.transform(clone$1(current)));
|
|
28844
|
-
db
|
|
28872
|
+
useStatement(db, `
|
|
28845
28873
|
INSERT INTO ${APP_STORAGE_TABLE} (namespace, value_json, updated_at)
|
|
28846
28874
|
VALUES (?, ?, ?)
|
|
28847
28875
|
ON CONFLICT(namespace)
|
|
28848
28876
|
DO UPDATE SET
|
|
28849
28877
|
value_json = excluded.value_json,
|
|
28850
28878
|
updated_at = excluded.updated_at
|
|
28851
|
-
|
|
28879
|
+
`, (statement) => statement.run(input.namespace, JSON.stringify(next), (/* @__PURE__ */ new Date()).toISOString()));
|
|
28852
28880
|
commit(db);
|
|
28853
28881
|
return clone$1(next);
|
|
28854
28882
|
} catch (error) {
|
|
@@ -28986,7 +29014,7 @@ function createDefaultAppState() {
|
|
|
28986
29014
|
}
|
|
28987
29015
|
};
|
|
28988
29016
|
}
|
|
28989
|
-
function asString$
|
|
29017
|
+
function asString$9(value) {
|
|
28990
29018
|
if (typeof value !== "string") return null;
|
|
28991
29019
|
const trimmed = value.trim();
|
|
28992
29020
|
return trimmed.length > 0 ? trimmed : null;
|
|
@@ -29001,19 +29029,19 @@ function normalizeAppState(raw) {
|
|
|
29001
29029
|
if (!Number.isFinite(merged.autoRoll.switchThreshold)) merged.autoRoll.switchThreshold = 95;
|
|
29002
29030
|
if (merged.autoRoll.warningThreshold < 50 || merged.autoRoll.warningThreshold > 99) merged.autoRoll.warningThreshold = 85;
|
|
29003
29031
|
if (merged.autoRoll.switchThreshold <= merged.autoRoll.warningThreshold || merged.autoRoll.switchThreshold > 100) merged.autoRoll.switchThreshold = Math.min(100, Math.max(merged.autoRoll.warningThreshold + 1, 95));
|
|
29004
|
-
merged.app.lastAppVersion = asString$
|
|
29005
|
-
merged.app.pendingUpdateVersion = asString$
|
|
29006
|
-
merged.app.lastProfileName = asString$
|
|
29032
|
+
merged.app.lastAppVersion = asString$9(merged.app.lastAppVersion);
|
|
29033
|
+
merged.app.pendingUpdateVersion = asString$9(merged.app.pendingUpdateVersion);
|
|
29034
|
+
merged.app.lastProfileName = asString$9(merged.app.lastProfileName);
|
|
29007
29035
|
{
|
|
29008
29036
|
const allowedAppKeys = new Set(Object.keys(defaults.app));
|
|
29009
29037
|
for (const key of Object.keys(merged.app)) if (!allowedAppKeys.has(key)) delete merged.app[key];
|
|
29010
29038
|
}
|
|
29011
|
-
merged.license.licenseKey = asString$
|
|
29012
|
-
merged.license.purchaseEmail = asString$
|
|
29013
|
-
merged.license.lastVerifiedAt = asString$
|
|
29014
|
-
merged.license.nextCheckAt = asString$
|
|
29015
|
-
merged.license.lastVerificationError = asString$
|
|
29016
|
-
merged.license.signature = asString$
|
|
29039
|
+
merged.license.licenseKey = asString$9(merged.license.licenseKey);
|
|
29040
|
+
merged.license.purchaseEmail = asString$9(merged.license.purchaseEmail);
|
|
29041
|
+
merged.license.lastVerifiedAt = asString$9(merged.license.lastVerifiedAt);
|
|
29042
|
+
merged.license.nextCheckAt = asString$9(merged.license.nextCheckAt);
|
|
29043
|
+
merged.license.lastVerificationError = asString$9(merged.license.lastVerificationError);
|
|
29044
|
+
merged.license.signature = asString$9(merged.license.signature);
|
|
29017
29045
|
if (![
|
|
29018
29046
|
"inactive",
|
|
29019
29047
|
"active",
|
|
@@ -29039,15 +29067,15 @@ function normalizeAppState(raw) {
|
|
|
29039
29067
|
if (typeof merged.ui.layout.sidebarCollapsed !== "boolean") merged.ui.layout.sidebarCollapsed = null;
|
|
29040
29068
|
if (!isRecord$7(merged.ui.profiles)) merged.ui.profiles = clone(defaults.ui.profiles);
|
|
29041
29069
|
merged.ui.profiles.viewMode = merged.ui.profiles.viewMode === "cards" || merged.ui.profiles.viewMode === "compact" ? merged.ui.profiles.viewMode : null;
|
|
29042
|
-
merged.ui.profiles.sortBy = asString$
|
|
29043
|
-
merged.ui.profiles.groupBy = asString$
|
|
29044
|
-
merged.ui.profiles.planFilter = asString$
|
|
29045
|
-
merged.ui.profiles.healthFilter = asString$
|
|
29046
|
-
merged.ui.profiles.customGroupFilter = asString$
|
|
29070
|
+
merged.ui.profiles.sortBy = asString$9(merged.ui.profiles.sortBy);
|
|
29071
|
+
merged.ui.profiles.groupBy = asString$9(merged.ui.profiles.groupBy);
|
|
29072
|
+
merged.ui.profiles.planFilter = asString$9(merged.ui.profiles.planFilter);
|
|
29073
|
+
merged.ui.profiles.healthFilter = asString$9(merged.ui.profiles.healthFilter);
|
|
29074
|
+
merged.ui.profiles.customGroupFilter = asString$9(merged.ui.profiles.customGroupFilter);
|
|
29047
29075
|
if (typeof merged.ui.profiles.toolbarOpen !== "boolean") merged.ui.profiles.toolbarOpen = null;
|
|
29048
29076
|
if (!isRecord$7(merged.ui.profiles.collapsedSections)) merged.ui.profiles.collapsedSections = {};
|
|
29049
29077
|
else merged.ui.profiles.collapsedSections = Object.fromEntries(Object.entries(merged.ui.profiles.collapsedSections).flatMap(([key, value]) => {
|
|
29050
|
-
const normalizedKey = asString$
|
|
29078
|
+
const normalizedKey = asString$9(key);
|
|
29051
29079
|
if (!normalizedKey || typeof value !== "boolean") return [];
|
|
29052
29080
|
return [[normalizedKey, value]];
|
|
29053
29081
|
}));
|
|
@@ -29061,24 +29089,24 @@ function normalizeAppState(raw) {
|
|
|
29061
29089
|
if (!Number.isFinite(merged.ui.onboarding.sessionCount)) merged.ui.onboarding.sessionCount = 0;
|
|
29062
29090
|
if (!isRecord$7(merged.ui.onboarding.nudgeCooldowns)) merged.ui.onboarding.nudgeCooldowns = {};
|
|
29063
29091
|
else merged.ui.onboarding.nudgeCooldowns = Object.fromEntries(Object.entries(merged.ui.onboarding.nudgeCooldowns).flatMap(([key, value]) => {
|
|
29064
|
-
const normalizedKey = asString$
|
|
29092
|
+
const normalizedKey = asString$9(key);
|
|
29065
29093
|
if (!normalizedKey || !Number.isFinite(value)) return [];
|
|
29066
29094
|
return [[normalizedKey, Number(value)]];
|
|
29067
29095
|
}));
|
|
29068
29096
|
if (!isRecord$7(merged.ui.onboarding.nudgeDismissCount)) merged.ui.onboarding.nudgeDismissCount = {};
|
|
29069
29097
|
else merged.ui.onboarding.nudgeDismissCount = Object.fromEntries(Object.entries(merged.ui.onboarding.nudgeDismissCount).flatMap(([key, value]) => {
|
|
29070
|
-
const normalizedKey = asString$
|
|
29098
|
+
const normalizedKey = asString$9(key);
|
|
29071
29099
|
if (!normalizedKey || !Number.isFinite(value)) return [];
|
|
29072
29100
|
return [[normalizedKey, Number(value)]];
|
|
29073
29101
|
}));
|
|
29074
29102
|
if (typeof merged.ui.onboarding.proUnlockedCelebrated !== "boolean") merged.ui.onboarding.proUnlockedCelebrated = false;
|
|
29075
29103
|
if (!isRecord$7(merged.ui.projectThreadSelections)) merged.ui.projectThreadSelections = {};
|
|
29076
29104
|
else merged.ui.projectThreadSelections = Object.fromEntries(Object.entries(merged.ui.projectThreadSelections).flatMap(([projectId, threadId]) => {
|
|
29077
|
-
const normalizedProjectId = asString$
|
|
29105
|
+
const normalizedProjectId = asString$9(projectId);
|
|
29078
29106
|
if (!normalizedProjectId) return [];
|
|
29079
29107
|
return [[normalizedProjectId, typeof threadId === "string" && threadId.trim().length > 0 ? threadId.trim() : null]];
|
|
29080
29108
|
}));
|
|
29081
|
-
merged.ui.duplicateWarningDismissedKey = asString$
|
|
29109
|
+
merged.ui.duplicateWarningDismissedKey = asString$9(merged.ui.duplicateWarningDismissedKey);
|
|
29082
29110
|
if (typeof merged.ui.pendingLicenseActivation !== "boolean") merged.ui.pendingLicenseActivation = false;
|
|
29083
29111
|
{
|
|
29084
29112
|
const allowedUiKeys = new Set(Object.keys(defaults.ui));
|
|
@@ -29087,8 +29115,8 @@ function normalizeAppState(raw) {
|
|
|
29087
29115
|
if (!isRecord$7(merged.profileDashboard)) merged.profileDashboard = clone(defaults.profileDashboard);
|
|
29088
29116
|
if (!isRecord$7(merged.profileDashboard.customGroupsByAccountKey)) merged.profileDashboard.customGroupsByAccountKey = {};
|
|
29089
29117
|
else merged.profileDashboard.customGroupsByAccountKey = Object.fromEntries(Object.entries(merged.profileDashboard.customGroupsByAccountKey).flatMap(([key, value]) => {
|
|
29090
|
-
const normalizedKey = asString$
|
|
29091
|
-
const normalizedValue = asString$
|
|
29118
|
+
const normalizedKey = asString$9(key);
|
|
29119
|
+
const normalizedValue = asString$9(value);
|
|
29092
29120
|
if (!normalizedKey || !normalizedValue) return [];
|
|
29093
29121
|
return [[normalizedKey, normalizedValue]];
|
|
29094
29122
|
}));
|
|
@@ -29115,19 +29143,19 @@ function normalizeAppState(raw) {
|
|
|
29115
29143
|
if (!Array.isArray(merged.skills.sources)) merged.skills.sources = [];
|
|
29116
29144
|
if (!isRecord$7(merged.skills.installsBySlug)) merged.skills.installsBySlug = {};
|
|
29117
29145
|
if (!isRecord$7(merged.sync)) merged.sync = clone(defaults.sync);
|
|
29118
|
-
merged.sync.lastPushAt = asString$
|
|
29119
|
-
merged.sync.lastPullAt = asString$
|
|
29120
|
-
merged.sync.lastError = asString$
|
|
29121
|
-
merged.sync.remoteUpdatedAt = asString$
|
|
29146
|
+
merged.sync.lastPushAt = asString$9(merged.sync.lastPushAt);
|
|
29147
|
+
merged.sync.lastPullAt = asString$9(merged.sync.lastPullAt);
|
|
29148
|
+
merged.sync.lastError = asString$9(merged.sync.lastError);
|
|
29149
|
+
merged.sync.remoteUpdatedAt = asString$9(merged.sync.remoteUpdatedAt);
|
|
29122
29150
|
if (!isRecord$7(merged.analytics)) merged.analytics = isRecord$7(merged.telemetry) ? clone(merged.telemetry) : clone(defaults.analytics);
|
|
29123
|
-
merged.analytics.anonymousId = asString$
|
|
29151
|
+
merged.analytics.anonymousId = asString$9(merged.analytics.anonymousId);
|
|
29124
29152
|
if (!merged.analytics.anonymousId) {
|
|
29125
|
-
const legacyInstallId = asString$
|
|
29153
|
+
const legacyInstallId = asString$9(merged.telemetry?.installId);
|
|
29126
29154
|
merged.analytics.anonymousId = legacyInstallId;
|
|
29127
29155
|
}
|
|
29128
29156
|
if (typeof merged.analytics.enabled !== "boolean") merged.analytics.enabled = true;
|
|
29129
|
-
merged.analytics.lastFlushAt = asString$
|
|
29130
|
-
merged.analytics.lastError = asString$
|
|
29157
|
+
merged.analytics.lastFlushAt = asString$9(merged.analytics.lastFlushAt);
|
|
29158
|
+
merged.analytics.lastError = asString$9(merged.analytics.lastError);
|
|
29131
29159
|
if ("telemetry" in merged) delete merged.telemetry;
|
|
29132
29160
|
if (!isRecord$7(merged.profilesByName)) merged.profilesByName = {};
|
|
29133
29161
|
if (!isRecord$7(merged.migration)) merged.migration = clone(defaults.migration);
|
|
@@ -29136,10 +29164,10 @@ function normalizeAppState(raw) {
|
|
|
29136
29164
|
"pending_local_storage",
|
|
29137
29165
|
"complete"
|
|
29138
29166
|
].includes(merged.migration.status)) merged.migration.status = "pending";
|
|
29139
|
-
merged.migration.startedAt = asString$
|
|
29140
|
-
merged.migration.completedAt = asString$
|
|
29141
|
-
merged.migration.localStorageImportedAt = asString$
|
|
29142
|
-
merged.migration.lastError = asString$
|
|
29167
|
+
merged.migration.startedAt = asString$9(merged.migration.startedAt);
|
|
29168
|
+
merged.migration.completedAt = asString$9(merged.migration.completedAt);
|
|
29169
|
+
merged.migration.localStorageImportedAt = asString$9(merged.migration.localStorageImportedAt);
|
|
29170
|
+
merged.migration.lastError = asString$9(merged.migration.lastError);
|
|
29143
29171
|
return merged;
|
|
29144
29172
|
}
|
|
29145
29173
|
function deepMerge(base, patch) {
|
|
@@ -29336,7 +29364,7 @@ function normalizeAutoRollSettings(raw) {
|
|
|
29336
29364
|
}
|
|
29337
29365
|
//#endregion
|
|
29338
29366
|
//#region ../../packages/runtime-codex/src/codex/settings.ts
|
|
29339
|
-
function asString$
|
|
29367
|
+
function asString$8(value) {
|
|
29340
29368
|
if (typeof value !== "string") return null;
|
|
29341
29369
|
const trimmed = value.trim();
|
|
29342
29370
|
return trimmed.length > 0 ? trimmed : null;
|
|
@@ -29354,7 +29382,7 @@ function parseAutoRoll(raw) {
|
|
|
29354
29382
|
}
|
|
29355
29383
|
function parseStoredLicense(raw) {
|
|
29356
29384
|
if (!isRecord$6(raw)) return null;
|
|
29357
|
-
const statusCandidate = asString$
|
|
29385
|
+
const statusCandidate = asString$8(raw.status);
|
|
29358
29386
|
const status = [
|
|
29359
29387
|
"inactive",
|
|
29360
29388
|
"active",
|
|
@@ -29362,21 +29390,21 @@ function parseStoredLicense(raw) {
|
|
|
29362
29390
|
"error"
|
|
29363
29391
|
].includes(statusCandidate ?? "") ? statusCandidate : void 0;
|
|
29364
29392
|
const license = {
|
|
29365
|
-
licenseKey: asString$
|
|
29366
|
-
purchaseEmail: asString$
|
|
29367
|
-
lastVerifiedAt: asString$
|
|
29368
|
-
nextCheckAt: asString$
|
|
29369
|
-
lastVerificationError: asString$
|
|
29393
|
+
licenseKey: asString$8(raw.licenseKey ?? raw.license_key),
|
|
29394
|
+
purchaseEmail: asString$8(raw.purchaseEmail ?? raw.purchase_email),
|
|
29395
|
+
lastVerifiedAt: asString$8(raw.lastVerifiedAt ?? raw.last_verified_at),
|
|
29396
|
+
nextCheckAt: asString$8(raw.nextCheckAt ?? raw.next_check_at),
|
|
29397
|
+
lastVerificationError: asString$8(raw.lastVerificationError ?? raw.last_verification_error),
|
|
29370
29398
|
status,
|
|
29371
|
-
signature: asString$
|
|
29399
|
+
signature: asString$8(raw.signature)
|
|
29372
29400
|
};
|
|
29373
29401
|
return Boolean(license.licenseKey || license.purchaseEmail || license.lastVerifiedAt || license.nextCheckAt || license.lastVerificationError || license.status) ? license : null;
|
|
29374
29402
|
}
|
|
29375
29403
|
async function getLastProfileName() {
|
|
29376
|
-
return asString$
|
|
29404
|
+
return asString$8((await getAppState()).app.lastProfileName);
|
|
29377
29405
|
}
|
|
29378
29406
|
async function persistLastProfileName(profileName) {
|
|
29379
|
-
await patchAppState({ app: { lastProfileName: asString$
|
|
29407
|
+
await patchAppState({ app: { lastProfileName: asString$8(profileName) } });
|
|
29380
29408
|
}
|
|
29381
29409
|
async function getStoredLicense() {
|
|
29382
29410
|
return parseStoredLicense((await getAppState()).license);
|
|
@@ -29441,9 +29469,9 @@ async function writeCodexSettingsJsonRaw(payload) {
|
|
|
29441
29469
|
const license = parseStoredLicense(payload.license);
|
|
29442
29470
|
await patchAppState({
|
|
29443
29471
|
app: {
|
|
29444
|
-
lastProfileName: asString$
|
|
29445
|
-
lastAppVersion: asString$
|
|
29446
|
-
pendingUpdateVersion: asString$
|
|
29472
|
+
lastProfileName: asString$8(payload.lastProfileName ?? payload.last_profile_name),
|
|
29473
|
+
lastAppVersion: asString$8(payload.lastAppVersion ?? payload.last_app_version),
|
|
29474
|
+
pendingUpdateVersion: asString$8(payload.pendingUpdateVersion ?? payload.pending_update_version)
|
|
29447
29475
|
},
|
|
29448
29476
|
autoRoll: autoRoll ? {
|
|
29449
29477
|
enabled: autoRoll.enabled,
|
|
@@ -30196,6 +30224,83 @@ function buildCodexCommand$1(binaryPath, args, env) {
|
|
|
30196
30224
|
};
|
|
30197
30225
|
}
|
|
30198
30226
|
//#endregion
|
|
30227
|
+
//#region ../../packages/runtime-codex/src/codex/home.ts
|
|
30228
|
+
function resolveHomeDir$1() {
|
|
30229
|
+
return process.env.HOME || process.env.USERPROFILE || os.homedir();
|
|
30230
|
+
}
|
|
30231
|
+
function expandHomePrefix(input, homeDir) {
|
|
30232
|
+
if (input === "~") return homeDir;
|
|
30233
|
+
if (input.startsWith("~/") || input.startsWith("~\\")) return path.join(homeDir, input.slice(2));
|
|
30234
|
+
return input;
|
|
30235
|
+
}
|
|
30236
|
+
function normalizePathCandidate(value) {
|
|
30237
|
+
if (typeof value !== "string") return null;
|
|
30238
|
+
const trimmed = value.trim();
|
|
30239
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
30240
|
+
}
|
|
30241
|
+
function normalizeCodexHomePath(input) {
|
|
30242
|
+
const configured = normalizePathCandidate(input);
|
|
30243
|
+
if (!configured) return null;
|
|
30244
|
+
return path.resolve(expandHomePrefix(configured, resolveHomeDir$1()));
|
|
30245
|
+
}
|
|
30246
|
+
function resolveDefaultCodexHomeDir() {
|
|
30247
|
+
return path.join(resolveHomeDir$1(), ".codex");
|
|
30248
|
+
}
|
|
30249
|
+
function resolveProfileCodexHomeDir(profileName) {
|
|
30250
|
+
return path.join(getUserDataDir(), "profile-homes", profileName);
|
|
30251
|
+
}
|
|
30252
|
+
function resolveCodexHomeDir(options) {
|
|
30253
|
+
return normalizeCodexHomePath(options?.codexHomePath) ?? resolveDefaultCodexHomeDir();
|
|
30254
|
+
}
|
|
30255
|
+
async function resolveCodexRuntimeContext(options) {
|
|
30256
|
+
const explicit = normalizeCodexHomePath(options?.codexHomePath);
|
|
30257
|
+
if (explicit) return {
|
|
30258
|
+
codexHomePath: explicit,
|
|
30259
|
+
profileName: null,
|
|
30260
|
+
source: "explicit"
|
|
30261
|
+
};
|
|
30262
|
+
const state = await getAppState();
|
|
30263
|
+
const profileName = normalizePathCandidate(state.app.lastProfileName);
|
|
30264
|
+
if (profileName && state.profilesByName[profileName]) return {
|
|
30265
|
+
codexHomePath: resolveProfileCodexHomeDir(profileName),
|
|
30266
|
+
profileName,
|
|
30267
|
+
source: "profile"
|
|
30268
|
+
};
|
|
30269
|
+
const configured = normalizeCodexHomePath(state.runtimeSettings?.codexHome);
|
|
30270
|
+
if (configured) return {
|
|
30271
|
+
codexHomePath: configured,
|
|
30272
|
+
profileName: null,
|
|
30273
|
+
source: "settings"
|
|
30274
|
+
};
|
|
30275
|
+
return {
|
|
30276
|
+
codexHomePath: resolveDefaultCodexHomeDir(),
|
|
30277
|
+
profileName: null,
|
|
30278
|
+
source: "default"
|
|
30279
|
+
};
|
|
30280
|
+
}
|
|
30281
|
+
async function resolveExternalCodexRuntimeContext(options) {
|
|
30282
|
+
const explicit = normalizeCodexHomePath(options?.codexHomePath);
|
|
30283
|
+
if (explicit) return {
|
|
30284
|
+
codexHomePath: explicit,
|
|
30285
|
+
profileName: null,
|
|
30286
|
+
source: "explicit"
|
|
30287
|
+
};
|
|
30288
|
+
const configured = normalizeCodexHomePath((await getAppState()).runtimeSettings?.codexHome);
|
|
30289
|
+
if (configured) return {
|
|
30290
|
+
codexHomePath: configured,
|
|
30291
|
+
profileName: null,
|
|
30292
|
+
source: "settings"
|
|
30293
|
+
};
|
|
30294
|
+
return {
|
|
30295
|
+
codexHomePath: resolveDefaultCodexHomeDir(),
|
|
30296
|
+
profileName: null,
|
|
30297
|
+
source: "default"
|
|
30298
|
+
};
|
|
30299
|
+
}
|
|
30300
|
+
async function resolveGlobalCodexRuntimeContext(options) {
|
|
30301
|
+
return resolveExternalCodexRuntimeContext(options);
|
|
30302
|
+
}
|
|
30303
|
+
//#endregion
|
|
30199
30304
|
//#region ../../packages/contracts/src/apps/rpc.ts
|
|
30200
30305
|
const APPS_LIST_METHODS = new Set([
|
|
30201
30306
|
"app/list",
|
|
@@ -30294,7 +30399,7 @@ function isThreadNotFoundError$1(error) {
|
|
|
30294
30399
|
const lower = message.toLowerCase();
|
|
30295
30400
|
return lower.includes("thread not found") || lower.includes("rollout");
|
|
30296
30401
|
}
|
|
30297
|
-
function asString$
|
|
30402
|
+
function asString$7(value) {
|
|
30298
30403
|
return typeof value === "string" ? value : value != null ? String(value) : "";
|
|
30299
30404
|
}
|
|
30300
30405
|
function isInlineImageValue(value) {
|
|
@@ -30303,11 +30408,11 @@ function isInlineImageValue(value) {
|
|
|
30303
30408
|
}
|
|
30304
30409
|
function normalizeSendUserMessageItem(value) {
|
|
30305
30410
|
if (!isRecord$5(value)) return null;
|
|
30306
|
-
const type = asString$
|
|
30411
|
+
const type = asString$7(value.type).trim();
|
|
30307
30412
|
if (!type) return null;
|
|
30308
30413
|
const data = isRecord$5(value.data) ? value.data : {};
|
|
30309
30414
|
if (type === "text") {
|
|
30310
|
-
const text = asString$
|
|
30415
|
+
const text = asString$7(data.text ?? value.text);
|
|
30311
30416
|
if (!text.trim()) return null;
|
|
30312
30417
|
return {
|
|
30313
30418
|
type: "text",
|
|
@@ -30315,7 +30420,7 @@ function normalizeSendUserMessageItem(value) {
|
|
|
30315
30420
|
};
|
|
30316
30421
|
}
|
|
30317
30422
|
if (type === "image") {
|
|
30318
|
-
const imageUrl = asString$
|
|
30423
|
+
const imageUrl = asString$7(data.image_url ?? data.imageUrl ?? data.url ?? value.image_url ?? value.imageUrl ?? value.url).trim();
|
|
30319
30424
|
if (!imageUrl) return null;
|
|
30320
30425
|
return {
|
|
30321
30426
|
type: "image",
|
|
@@ -30323,7 +30428,7 @@ function normalizeSendUserMessageItem(value) {
|
|
|
30323
30428
|
};
|
|
30324
30429
|
}
|
|
30325
30430
|
if (type === "localImage") {
|
|
30326
|
-
const path = asString$
|
|
30431
|
+
const path = asString$7(data.path ?? value.path).trim();
|
|
30327
30432
|
if (!path) return null;
|
|
30328
30433
|
return {
|
|
30329
30434
|
type: "localImage",
|
|
@@ -30334,12 +30439,12 @@ function normalizeSendUserMessageItem(value) {
|
|
|
30334
30439
|
}
|
|
30335
30440
|
function normalizeTurnInputParams(params) {
|
|
30336
30441
|
const normalized = { ...params };
|
|
30337
|
-
const threadId = asString$
|
|
30338
|
-
if (threadId && !asString$
|
|
30339
|
-
const expectedTurnId = asString$
|
|
30340
|
-
if (expectedTurnId && !asString$
|
|
30341
|
-
const turnId = asString$
|
|
30342
|
-
if (turnId && !asString$
|
|
30442
|
+
const threadId = asString$7(params.threadId ?? params.thread_id ?? params.conversationId ?? params.conversation_id ?? "").trim();
|
|
30443
|
+
if (threadId && !asString$7(params.threadId).trim()) normalized.threadId = threadId;
|
|
30444
|
+
const expectedTurnId = asString$7(params.expectedTurnId ?? params.expected_turn_id ?? params.turnId ?? params.turn_id ?? "").trim();
|
|
30445
|
+
if (expectedTurnId && !asString$7(params.expectedTurnId).trim()) normalized.expectedTurnId = expectedTurnId;
|
|
30446
|
+
const turnId = asString$7(params.turnId ?? params.turn_id ?? expectedTurnId).trim();
|
|
30447
|
+
if (turnId && !asString$7(params.turnId).trim()) normalized.turnId = turnId;
|
|
30343
30448
|
const providedInput = Array.isArray(params.input) ? params.input.filter((entry) => isRecord$5(entry)) : [];
|
|
30344
30449
|
if (providedInput.length > 0) {
|
|
30345
30450
|
normalized.input = providedInput;
|
|
@@ -30348,17 +30453,17 @@ function normalizeTurnInputParams(params) {
|
|
|
30348
30453
|
const providedItems = Array.isArray(params.items) ? params.items.map((item) => normalizeSendUserMessageItem(item)).filter((item) => item !== null) : [];
|
|
30349
30454
|
if (providedItems.length > 0) {
|
|
30350
30455
|
const input = providedItems.flatMap((item) => {
|
|
30351
|
-
const type = asString$
|
|
30456
|
+
const type = asString$7(item.type).trim();
|
|
30352
30457
|
const data = isRecord$5(item.data) ? item.data : item;
|
|
30353
30458
|
if (type === "text") {
|
|
30354
|
-
const text = asString$
|
|
30459
|
+
const text = asString$7(data.text).trim();
|
|
30355
30460
|
return text ? [{
|
|
30356
30461
|
type: "text",
|
|
30357
30462
|
text
|
|
30358
30463
|
}] : [];
|
|
30359
30464
|
}
|
|
30360
30465
|
if (type === "localImage") {
|
|
30361
|
-
const path = asString$
|
|
30466
|
+
const path = asString$7(data.path).trim();
|
|
30362
30467
|
return path ? [{
|
|
30363
30468
|
type: "localImage",
|
|
30364
30469
|
path
|
|
@@ -30372,13 +30477,13 @@ function normalizeTurnInputParams(params) {
|
|
|
30372
30477
|
}
|
|
30373
30478
|
}
|
|
30374
30479
|
const input = [];
|
|
30375
|
-
const text = asString$
|
|
30480
|
+
const text = asString$7(params.text);
|
|
30376
30481
|
if (text.trim()) input.push({
|
|
30377
30482
|
type: "text",
|
|
30378
30483
|
text
|
|
30379
30484
|
});
|
|
30380
30485
|
if (Array.isArray(params.images)) for (const candidate of params.images) {
|
|
30381
|
-
const image = asString$
|
|
30486
|
+
const image = asString$7(candidate).trim();
|
|
30382
30487
|
if (!image || isInlineImageValue(image)) continue;
|
|
30383
30488
|
input.push({
|
|
30384
30489
|
type: "localImage",
|
|
@@ -30429,7 +30534,7 @@ function getRequestTimeoutMs(method) {
|
|
|
30429
30534
|
return DEFAULT_REQUEST_TIMEOUT_MS;
|
|
30430
30535
|
}
|
|
30431
30536
|
function normalizeThreadLiveWorkspaceId(value) {
|
|
30432
|
-
return asString$
|
|
30537
|
+
return asString$7(value).trim() || DEFAULT_THREAD_LIVE_WORKSPACE_ID;
|
|
30433
30538
|
}
|
|
30434
30539
|
function threadLiveKey(workspaceId, threadId) {
|
|
30435
30540
|
return `${workspaceId}:${threadId}`;
|
|
@@ -30495,7 +30600,7 @@ var CodexAppServer = class extends EventEmitter {
|
|
|
30495
30600
|
this.threadLiveSubscriptionIdByKey = /* @__PURE__ */ new Map();
|
|
30496
30601
|
this.threadLiveModeByKey = /* @__PURE__ */ new Map();
|
|
30497
30602
|
this.addConversationListenerSupported = null;
|
|
30498
|
-
this.homePath = options?.homePath
|
|
30603
|
+
this.homePath = normalizeCodexHomePath(options?.homePath);
|
|
30499
30604
|
this.setMaxListeners(50);
|
|
30500
30605
|
}
|
|
30501
30606
|
async start() {
|
|
@@ -30633,8 +30738,8 @@ var CodexAppServer = class extends EventEmitter {
|
|
|
30633
30738
|
}
|
|
30634
30739
|
async addConversationListener(params) {
|
|
30635
30740
|
if (this.addConversationListenerSupported === false) return {};
|
|
30636
|
-
const conversationId = asString$
|
|
30637
|
-
const workspaceId = asString$
|
|
30741
|
+
const conversationId = asString$7(params.conversationId ?? params.threadId ?? params.thread_id ?? "").trim();
|
|
30742
|
+
const workspaceId = asString$7(params.workspaceId ?? params.workspace_id ?? "").trim();
|
|
30638
30743
|
if (!conversationId) try {
|
|
30639
30744
|
const response = await this.request("addConversationListener", params);
|
|
30640
30745
|
this.addConversationListenerSupported = true;
|
|
@@ -30662,7 +30767,7 @@ var CodexAppServer = class extends EventEmitter {
|
|
|
30662
30767
|
}
|
|
30663
30768
|
async threadLiveSubscribe(params) {
|
|
30664
30769
|
const workspaceId = normalizeThreadLiveWorkspaceId(params.workspaceId ?? params.workspace_id);
|
|
30665
|
-
const threadId = asString$
|
|
30770
|
+
const threadId = asString$7(params.threadId ?? params.thread_id ?? params.conversationId).trim();
|
|
30666
30771
|
if (!threadId) return {};
|
|
30667
30772
|
const key = threadLiveKey(workspaceId, threadId);
|
|
30668
30773
|
this.threadLiveModeByKey.set(key, "listener");
|
|
@@ -30671,7 +30776,7 @@ var CodexAppServer = class extends EventEmitter {
|
|
|
30671
30776
|
}
|
|
30672
30777
|
async threadLiveUnsubscribe(params) {
|
|
30673
30778
|
const workspaceId = normalizeThreadLiveWorkspaceId(params.workspaceId ?? params.workspace_id);
|
|
30674
|
-
const threadId = asString$
|
|
30779
|
+
const threadId = asString$7(params.threadId ?? params.thread_id ?? params.conversationId).trim();
|
|
30675
30780
|
if (!threadId) return {};
|
|
30676
30781
|
const key = threadLiveKey(workspaceId, threadId);
|
|
30677
30782
|
this.threadLiveModeByKey.delete(key);
|
|
@@ -31142,83 +31247,6 @@ var CodexAppServer = class extends EventEmitter {
|
|
|
31142
31247
|
}
|
|
31143
31248
|
};
|
|
31144
31249
|
//#endregion
|
|
31145
|
-
//#region ../../packages/runtime-codex/src/codex/home.ts
|
|
31146
|
-
function resolveHomeDir$1() {
|
|
31147
|
-
return process.env.HOME || process.env.USERPROFILE || os.homedir();
|
|
31148
|
-
}
|
|
31149
|
-
function expandHomePrefix(input, homeDir) {
|
|
31150
|
-
if (input === "~") return homeDir;
|
|
31151
|
-
if (input.startsWith("~/") || input.startsWith("~\\")) return path.join(homeDir, input.slice(2));
|
|
31152
|
-
return input;
|
|
31153
|
-
}
|
|
31154
|
-
function normalizePathCandidate(value) {
|
|
31155
|
-
if (typeof value !== "string") return null;
|
|
31156
|
-
const trimmed = value.trim();
|
|
31157
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
31158
|
-
}
|
|
31159
|
-
function normalizeCodexHomePath(input) {
|
|
31160
|
-
const configured = normalizePathCandidate(input);
|
|
31161
|
-
if (!configured) return null;
|
|
31162
|
-
return path.resolve(expandHomePrefix(configured, resolveHomeDir$1()));
|
|
31163
|
-
}
|
|
31164
|
-
function resolveDefaultCodexHomeDir() {
|
|
31165
|
-
return path.join(resolveHomeDir$1(), ".codex");
|
|
31166
|
-
}
|
|
31167
|
-
function resolveProfileCodexHomeDir(profileName) {
|
|
31168
|
-
return path.join(getUserDataDir(), "profile-homes", profileName);
|
|
31169
|
-
}
|
|
31170
|
-
function resolveCodexHomeDir(options) {
|
|
31171
|
-
return normalizeCodexHomePath(options?.codexHomePath) ?? resolveDefaultCodexHomeDir();
|
|
31172
|
-
}
|
|
31173
|
-
async function resolveCodexRuntimeContext(options) {
|
|
31174
|
-
const explicit = normalizeCodexHomePath(options?.codexHomePath);
|
|
31175
|
-
if (explicit) return {
|
|
31176
|
-
codexHomePath: explicit,
|
|
31177
|
-
profileName: null,
|
|
31178
|
-
source: "explicit"
|
|
31179
|
-
};
|
|
31180
|
-
const state = await getAppState();
|
|
31181
|
-
const profileName = normalizePathCandidate(state.app.lastProfileName);
|
|
31182
|
-
if (profileName && state.profilesByName[profileName]) return {
|
|
31183
|
-
codexHomePath: resolveProfileCodexHomeDir(profileName),
|
|
31184
|
-
profileName,
|
|
31185
|
-
source: "profile"
|
|
31186
|
-
};
|
|
31187
|
-
const configured = normalizeCodexHomePath(state.runtimeSettings?.codexHome);
|
|
31188
|
-
if (configured) return {
|
|
31189
|
-
codexHomePath: configured,
|
|
31190
|
-
profileName: null,
|
|
31191
|
-
source: "settings"
|
|
31192
|
-
};
|
|
31193
|
-
return {
|
|
31194
|
-
codexHomePath: resolveDefaultCodexHomeDir(),
|
|
31195
|
-
profileName: null,
|
|
31196
|
-
source: "default"
|
|
31197
|
-
};
|
|
31198
|
-
}
|
|
31199
|
-
async function resolveExternalCodexRuntimeContext(options) {
|
|
31200
|
-
const explicit = normalizeCodexHomePath(options?.codexHomePath);
|
|
31201
|
-
if (explicit) return {
|
|
31202
|
-
codexHomePath: explicit,
|
|
31203
|
-
profileName: null,
|
|
31204
|
-
source: "explicit"
|
|
31205
|
-
};
|
|
31206
|
-
const configured = normalizeCodexHomePath((await getAppState()).runtimeSettings?.codexHome);
|
|
31207
|
-
if (configured) return {
|
|
31208
|
-
codexHomePath: configured,
|
|
31209
|
-
profileName: null,
|
|
31210
|
-
source: "settings"
|
|
31211
|
-
};
|
|
31212
|
-
return {
|
|
31213
|
-
codexHomePath: resolveDefaultCodexHomeDir(),
|
|
31214
|
-
profileName: null,
|
|
31215
|
-
source: "default"
|
|
31216
|
-
};
|
|
31217
|
-
}
|
|
31218
|
-
async function resolveGlobalCodexRuntimeContext(options) {
|
|
31219
|
-
return resolveExternalCodexRuntimeContext(options);
|
|
31220
|
-
}
|
|
31221
|
-
//#endregion
|
|
31222
31250
|
//#region src/migrations/legacy-codexuse/parityStore.ts
|
|
31223
31251
|
const STORE_FILE = "workspace-parity.json";
|
|
31224
31252
|
const LEGACY_STORE_FILE = "workspace-parity.json";
|
|
@@ -31410,14 +31438,14 @@ async function listParityWorkspaces() {
|
|
|
31410
31438
|
//#region src/externalThreadOverrides.ts
|
|
31411
31439
|
const EXTERNAL_THREAD_OVERRIDES_DOCUMENT = "desktop.external-thread-overrides.v1";
|
|
31412
31440
|
const EXTERNAL_THREAD_OVERRIDES_VERSION = 1;
|
|
31413
|
-
function asRecord$
|
|
31441
|
+
function asRecord$4(value) {
|
|
31414
31442
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
31415
31443
|
}
|
|
31416
31444
|
function normalizeOptionalTitle(value) {
|
|
31417
31445
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
31418
31446
|
}
|
|
31419
31447
|
function sanitizeOverride(value) {
|
|
31420
|
-
const record = asRecord$
|
|
31448
|
+
const record = asRecord$4(value);
|
|
31421
31449
|
if (!record) return null;
|
|
31422
31450
|
const suppressed = record.suppressed === true ? true : void 0;
|
|
31423
31451
|
const localTitle = normalizeOptionalTitle(record.localTitle);
|
|
@@ -31458,8 +31486,8 @@ function resolveOverridesDbPath(stateDir) {
|
|
|
31458
31486
|
}
|
|
31459
31487
|
async function readExternalThreadOverrides(stateDir) {
|
|
31460
31488
|
return await readDocument(resolveOverridesDbPath(stateDir), EXTERNAL_THREAD_OVERRIDES_DOCUMENT, (value) => {
|
|
31461
|
-
const record = asRecord$
|
|
31462
|
-
const threadsRecord = asRecord$
|
|
31489
|
+
const record = asRecord$4(value);
|
|
31490
|
+
const threadsRecord = asRecord$4(record?.threads) ?? {};
|
|
31463
31491
|
const threads = {};
|
|
31464
31492
|
for (const [threadId, entry] of Object.entries(threadsRecord)) {
|
|
31465
31493
|
const sanitized = sanitizeOverride(entry);
|
|
@@ -31595,7 +31623,7 @@ let externalCodexThreadSyncWatcherSettleTimer = null;
|
|
|
31595
31623
|
let externalCodexThreadSyncWatcherPendingTrigger = null;
|
|
31596
31624
|
const externalSyncAppServerLeaseCount = /* @__PURE__ */ new Map();
|
|
31597
31625
|
let externalCodexThreadSyncRefreshQueue = null;
|
|
31598
|
-
function asRecord$
|
|
31626
|
+
function asRecord$3(value) {
|
|
31599
31627
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
31600
31628
|
}
|
|
31601
31629
|
function clearSharedExternalSyncAppServerIdleTimer() {
|
|
@@ -31802,11 +31830,11 @@ function startExternalCodexThreadSyncWatcher(homePath) {
|
|
|
31802
31830
|
function resolveStateDbPath(stateDir) {
|
|
31803
31831
|
return path.join(stateDir, "state.sqlite");
|
|
31804
31832
|
}
|
|
31805
|
-
function asString$
|
|
31833
|
+
function asString$6(value) {
|
|
31806
31834
|
return typeof value === "string" ? value : value == null ? "" : String(value);
|
|
31807
31835
|
}
|
|
31808
31836
|
function asTrimmedString$1(value) {
|
|
31809
|
-
return asString$
|
|
31837
|
+
return asString$6(value).trim();
|
|
31810
31838
|
}
|
|
31811
31839
|
function asFiniteNumber(value) {
|
|
31812
31840
|
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
@@ -31863,9 +31891,9 @@ async function readImportedVisibleMessageTimeline(thread) {
|
|
|
31863
31891
|
} catch {
|
|
31864
31892
|
continue;
|
|
31865
31893
|
}
|
|
31866
|
-
const record = asRecord$
|
|
31894
|
+
const record = asRecord$3(entry);
|
|
31867
31895
|
if (!record || asTrimmedString$1(record.type) !== "event_msg") continue;
|
|
31868
|
-
const payload = asRecord$
|
|
31896
|
+
const payload = asRecord$3(record.payload);
|
|
31869
31897
|
if (!payload) continue;
|
|
31870
31898
|
const timestamp = firstNonEmptyString(record.timestamp, payload.timestamp, payload.createdAt, payload.created_at);
|
|
31871
31899
|
if (!timestamp || !Number.isFinite(Date.parse(timestamp))) continue;
|
|
@@ -31892,16 +31920,16 @@ function takeImportedVisibleMessageTimestamp(timeline, role) {
|
|
|
31892
31920
|
return nextTimestamp;
|
|
31893
31921
|
}
|
|
31894
31922
|
function listThreadSummariesFromResponse(payload) {
|
|
31895
|
-
const root = asRecord$
|
|
31896
|
-
const result = asRecord$
|
|
31923
|
+
const root = asRecord$3(payload);
|
|
31924
|
+
const result = asRecord$3(root?.result) ?? root;
|
|
31897
31925
|
return {
|
|
31898
|
-
threads: (Array.isArray(result?.data) ? result.data : []).map((entry) => asRecord$
|
|
31926
|
+
threads: (Array.isArray(result?.data) ? result.data : []).map((entry) => asRecord$3(entry)).filter((entry) => Boolean(asTrimmedString$1(entry?.id))),
|
|
31899
31927
|
nextCursor: firstNonEmptyString(result?.nextCursor, result?.next_cursor)
|
|
31900
31928
|
};
|
|
31901
31929
|
}
|
|
31902
31930
|
function extractLegacyThread(payload) {
|
|
31903
|
-
const root = asRecord$
|
|
31904
|
-
const thread = asRecord$
|
|
31931
|
+
const root = asRecord$3(payload);
|
|
31932
|
+
const thread = asRecord$3((asRecord$3(root?.result) ?? root)?.thread) ?? asRecord$3(root?.thread);
|
|
31905
31933
|
return thread && asTrimmedString$1(thread.id) ? thread : null;
|
|
31906
31934
|
}
|
|
31907
31935
|
function normalizeProjectScriptIcon(value) {
|
|
@@ -32018,19 +32046,19 @@ const MODEL_KEYS = [
|
|
|
32018
32046
|
"model_name"
|
|
32019
32047
|
];
|
|
32020
32048
|
function extractModelFromRecord(record) {
|
|
32021
|
-
const payload = asRecord$
|
|
32049
|
+
const payload = asRecord$3(record.payload);
|
|
32022
32050
|
const containers = [
|
|
32023
32051
|
record,
|
|
32024
32052
|
payload,
|
|
32025
|
-
asRecord$
|
|
32026
|
-
asRecord$
|
|
32027
|
-
asRecord$
|
|
32028
|
-
asRecord$
|
|
32029
|
-
asRecord$
|
|
32030
|
-
asRecord$
|
|
32031
|
-
asRecord$
|
|
32032
|
-
asRecord$
|
|
32033
|
-
asRecord$
|
|
32053
|
+
asRecord$3(payload?.info),
|
|
32054
|
+
asRecord$3(record.info),
|
|
32055
|
+
asRecord$3(record.metadata),
|
|
32056
|
+
asRecord$3(record.context),
|
|
32057
|
+
asRecord$3(record.turnContext),
|
|
32058
|
+
asRecord$3(record.turn_context),
|
|
32059
|
+
asRecord$3(record.params),
|
|
32060
|
+
asRecord$3(record.settings),
|
|
32061
|
+
asRecord$3(record.config)
|
|
32034
32062
|
].filter((value) => value !== null);
|
|
32035
32063
|
for (const container of containers) {
|
|
32036
32064
|
const value = pickString(container, MODEL_KEYS);
|
|
@@ -32041,13 +32069,13 @@ function extractModelFromRecord(record) {
|
|
|
32041
32069
|
function resolveImportedModel(thread) {
|
|
32042
32070
|
const turns = Array.isArray(thread.turns) ? thread.turns : [];
|
|
32043
32071
|
for (let turnIndex = turns.length - 1; turnIndex >= 0; turnIndex -= 1) {
|
|
32044
|
-
const turn = asRecord$
|
|
32072
|
+
const turn = asRecord$3(turns[turnIndex]);
|
|
32045
32073
|
if (!turn) continue;
|
|
32046
32074
|
const turnLevel = extractModelFromRecord(turn);
|
|
32047
32075
|
if (turnLevel) return turnLevel;
|
|
32048
32076
|
const items = Array.isArray(turn.items) ? turn.items : [];
|
|
32049
32077
|
for (let itemIndex = items.length - 1; itemIndex >= 0; itemIndex -= 1) {
|
|
32050
|
-
const item = asRecord$
|
|
32078
|
+
const item = asRecord$3(items[itemIndex]);
|
|
32051
32079
|
if (!item) continue;
|
|
32052
32080
|
const model = extractModelFromRecord(item);
|
|
32053
32081
|
if (model) return model;
|
|
@@ -32062,7 +32090,7 @@ function resolveThreadTitle(thread) {
|
|
|
32062
32090
|
return firstNonEmptyString(thread.name, thread.preview, thread.title)?.split(/\r?\n/, 1)[0]?.trim()?.slice(0, 140) || "Imported thread";
|
|
32063
32091
|
}
|
|
32064
32092
|
function readLegacyContentRecord(value) {
|
|
32065
|
-
return asRecord$
|
|
32093
|
+
return asRecord$3(value);
|
|
32066
32094
|
}
|
|
32067
32095
|
function readLegacyContentText(item) {
|
|
32068
32096
|
const data = readLegacyContentRecord(item.data);
|
|
@@ -32154,7 +32182,7 @@ async function parseUserMessageContent(input) {
|
|
|
32154
32182
|
const attachments = [];
|
|
32155
32183
|
let imageIndex = 0;
|
|
32156
32184
|
for (const entry of content) {
|
|
32157
|
-
const item = asRecord$
|
|
32185
|
+
const item = asRecord$3(entry);
|
|
32158
32186
|
if (!item) continue;
|
|
32159
32187
|
const type = asTrimmedString$1(item.type);
|
|
32160
32188
|
if (type === "text") {
|
|
@@ -32225,13 +32253,13 @@ async function buildThreadImportArtifacts(input) {
|
|
|
32225
32253
|
let latestArtifactUpdatedAt = createdAt;
|
|
32226
32254
|
let latestUpdatedAt = summaryUpdatedAt;
|
|
32227
32255
|
for (const [turnIndex, turnEntry] of turns.entries()) {
|
|
32228
|
-
const turn = asRecord$
|
|
32256
|
+
const turn = asRecord$3(turnEntry);
|
|
32229
32257
|
if (!turn) continue;
|
|
32230
32258
|
const turnIdRaw = firstNonEmptyString(turn.id, turn.turnId, turn.turn_id);
|
|
32231
32259
|
const turnId = turnIdRaw ? TurnId.makeUnsafe(turnIdRaw) : null;
|
|
32232
32260
|
const items = Array.isArray(turn.items) ? turn.items : [];
|
|
32233
32261
|
for (const [itemIndex, itemEntry] of items.entries()) {
|
|
32234
|
-
const item = asRecord$
|
|
32262
|
+
const item = asRecord$3(itemEntry);
|
|
32235
32263
|
if (!item) continue;
|
|
32236
32264
|
const itemId = firstNonEmptyString(item.id) ?? `${turnIndex + 1}-${itemIndex + 1}`;
|
|
32237
32265
|
const type = asTrimmedString$1(item.type);
|
|
@@ -32454,7 +32482,7 @@ async function isDirectory(targetPath) {
|
|
|
32454
32482
|
async function readImportMarker(stateDir) {
|
|
32455
32483
|
const dbPath = resolveStateDbPath(stateDir);
|
|
32456
32484
|
const stored = await readDocument(dbPath, EXTERNAL_SYNC_MARKER_DOCUMENT, (value) => {
|
|
32457
|
-
const version = asFiniteNumber(asRecord$
|
|
32485
|
+
const version = asFiniteNumber(asRecord$3(value)?.version);
|
|
32458
32486
|
if (version === null || version <= 0) return null;
|
|
32459
32487
|
return { version };
|
|
32460
32488
|
});
|
|
@@ -32462,7 +32490,7 @@ async function readImportMarker(stateDir) {
|
|
|
32462
32490
|
const markerPath = path.join(stateDir, EXTERNAL_SYNC_MARKER_FILE);
|
|
32463
32491
|
try {
|
|
32464
32492
|
const raw = await fs$1.readFile(markerPath, "utf8");
|
|
32465
|
-
const version = asFiniteNumber(asRecord$
|
|
32493
|
+
const version = asFiniteNumber(asRecord$3(JSON.parse(raw))?.version);
|
|
32466
32494
|
if (version === null || version <= 0) return null;
|
|
32467
32495
|
const marker = { version };
|
|
32468
32496
|
await writeDocument(dbPath, EXTERNAL_SYNC_MARKER_DOCUMENT, marker);
|
|
@@ -32542,7 +32570,7 @@ function hasImportedThreadArtifacts(state) {
|
|
|
32542
32570
|
return state.messageIds.size > 0 || state.activityIds.size > 0 || state.planIds.size > 0;
|
|
32543
32571
|
}
|
|
32544
32572
|
function readProviderThreadIdFromResumeCursor(resumeCursor) {
|
|
32545
|
-
const cursor = asRecord$
|
|
32573
|
+
const cursor = asRecord$3(resumeCursor);
|
|
32546
32574
|
return firstNonEmptyString(cursor?.threadId, cursor?.thread_id, cursor?.conversationId, cursor?.conversation_id) ?? null;
|
|
32547
32575
|
}
|
|
32548
32576
|
function resolveLegacyThreadReadIds(input) {
|
|
@@ -33373,7 +33401,7 @@ function proposedPlanIdFromEvent(event, threadId) {
|
|
|
33373
33401
|
if (event.itemId) return `plan:${threadId}:item:${event.itemId}`;
|
|
33374
33402
|
return `plan:${threadId}:event:${event.eventId}`;
|
|
33375
33403
|
}
|
|
33376
|
-
function asString$
|
|
33404
|
+
function asString$5(value) {
|
|
33377
33405
|
return typeof value === "string" ? value : void 0;
|
|
33378
33406
|
}
|
|
33379
33407
|
function runtimePayloadRecord(event) {
|
|
@@ -33391,13 +33419,13 @@ function normalizeRuntimeTurnState(value) {
|
|
|
33391
33419
|
}
|
|
33392
33420
|
}
|
|
33393
33421
|
function runtimeTurnState(event) {
|
|
33394
|
-
return normalizeRuntimeTurnState(asString$
|
|
33422
|
+
return normalizeRuntimeTurnState(asString$5(runtimePayloadRecord(event)?.state));
|
|
33395
33423
|
}
|
|
33396
33424
|
function runtimeTurnErrorMessage(event) {
|
|
33397
|
-
return asString$
|
|
33425
|
+
return asString$5(runtimePayloadRecord(event)?.errorMessage);
|
|
33398
33426
|
}
|
|
33399
33427
|
function runtimeErrorMessageFromEvent(event) {
|
|
33400
|
-
return asString$
|
|
33428
|
+
return asString$5(runtimePayloadRecord(event)?.message);
|
|
33401
33429
|
}
|
|
33402
33430
|
function shouldTriggerPassiveImportedThreadRecovery(event) {
|
|
33403
33431
|
switch (event.type) {
|
|
@@ -34148,13 +34176,13 @@ function asObject$1(value) {
|
|
|
34148
34176
|
if (!value || typeof value !== "object") return;
|
|
34149
34177
|
return value;
|
|
34150
34178
|
}
|
|
34151
|
-
function asString$
|
|
34179
|
+
function asString$4(value) {
|
|
34152
34180
|
return typeof value === "string" ? value : void 0;
|
|
34153
34181
|
}
|
|
34154
34182
|
function readCodexAccountSnapshot(response) {
|
|
34155
34183
|
const record = asObject$1(response);
|
|
34156
34184
|
const account = asObject$1(record?.account) ?? record;
|
|
34157
|
-
const accountType = asString$
|
|
34185
|
+
const accountType = asString$4(account?.type);
|
|
34158
34186
|
if (accountType === "apiKey") return {
|
|
34159
34187
|
type: "apiKey",
|
|
34160
34188
|
planType: null,
|
|
@@ -34523,7 +34551,7 @@ var CodexAppServerManager = class extends EventEmitter {
|
|
|
34523
34551
|
};
|
|
34524
34552
|
const codexOptions = readCodexProviderOptions(input);
|
|
34525
34553
|
const codexBinaryPath = codexOptions.binaryPath ?? "codex";
|
|
34526
|
-
const codexHomePath = codexOptions.homePath;
|
|
34554
|
+
const codexHomePath = normalizeCodexHomePath(codexOptions.homePath);
|
|
34527
34555
|
this.assertSupportedCodexCliVersion({
|
|
34528
34556
|
binaryPath: codexBinaryPath,
|
|
34529
34557
|
cwd: resolvedCwd,
|
|
@@ -35284,7 +35312,7 @@ function readCodexProviderOptions(input) {
|
|
|
35284
35312
|
if (!options) return {};
|
|
35285
35313
|
return {
|
|
35286
35314
|
...options.binaryPath ? { binaryPath: options.binaryPath } : {},
|
|
35287
|
-
...options.homePath ? { homePath: options.homePath } : {}
|
|
35315
|
+
...options.homePath ? { homePath: normalizeCodexHomePath(options.homePath) ?? options.homePath } : {}
|
|
35288
35316
|
};
|
|
35289
35317
|
}
|
|
35290
35318
|
function assertSupportedCodexCliVersion(input) {
|
|
@@ -35698,7 +35726,7 @@ function asObject(value) {
|
|
|
35698
35726
|
if (!value || typeof value !== "object") return;
|
|
35699
35727
|
return value;
|
|
35700
35728
|
}
|
|
35701
|
-
function asString$
|
|
35729
|
+
function asString$3(value) {
|
|
35702
35730
|
return typeof value === "string" ? value : void 0;
|
|
35703
35731
|
}
|
|
35704
35732
|
function asArray(value) {
|
|
@@ -35717,7 +35745,7 @@ function toTurnStatus(value) {
|
|
|
35717
35745
|
}
|
|
35718
35746
|
}
|
|
35719
35747
|
function normalizeItemType(raw) {
|
|
35720
|
-
const type = asString$
|
|
35748
|
+
const type = asString$3(raw);
|
|
35721
35749
|
if (!type) return "item";
|
|
35722
35750
|
return type.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[._/-]/g, " ").replace(/\s+/g, " ").trim().toLowerCase();
|
|
35723
35751
|
}
|
|
@@ -35759,16 +35787,16 @@ function itemTitle(itemType) {
|
|
|
35759
35787
|
function itemDetail(item, payload) {
|
|
35760
35788
|
const nestedResult = asObject(item.result);
|
|
35761
35789
|
const candidates = [
|
|
35762
|
-
asString$
|
|
35763
|
-
asString$
|
|
35764
|
-
asString$
|
|
35765
|
-
asString$
|
|
35766
|
-
asString$
|
|
35767
|
-
asString$
|
|
35768
|
-
asString$
|
|
35769
|
-
asString$
|
|
35770
|
-
asString$
|
|
35771
|
-
asString$
|
|
35790
|
+
asString$3(item.command),
|
|
35791
|
+
asString$3(item.title),
|
|
35792
|
+
asString$3(item.summary),
|
|
35793
|
+
asString$3(item.text),
|
|
35794
|
+
asString$3(item.path),
|
|
35795
|
+
asString$3(item.prompt),
|
|
35796
|
+
asString$3(nestedResult?.command),
|
|
35797
|
+
asString$3(payload.command),
|
|
35798
|
+
asString$3(payload.message),
|
|
35799
|
+
asString$3(payload.prompt)
|
|
35772
35800
|
];
|
|
35773
35801
|
for (const candidate of candidates) {
|
|
35774
35802
|
if (!candidate) continue;
|
|
@@ -35800,9 +35828,9 @@ function toRequestTypeFromKind(kind) {
|
|
|
35800
35828
|
}
|
|
35801
35829
|
function toRequestTypeFromResolvedPayload(payload) {
|
|
35802
35830
|
const request = asObject(payload?.request);
|
|
35803
|
-
const method = asString$
|
|
35831
|
+
const method = asString$3(request?.method) ?? asString$3(payload?.method);
|
|
35804
35832
|
if (method) return toRequestTypeFromMethod(method);
|
|
35805
|
-
const requestKind = asString$
|
|
35833
|
+
const requestKind = asString$3(request?.kind) ?? asString$3(payload?.requestKind);
|
|
35806
35834
|
if (requestKind) return toRequestTypeFromKind(requestKind);
|
|
35807
35835
|
return "unknown";
|
|
35808
35836
|
}
|
|
@@ -35828,17 +35856,17 @@ function toUserInputQuestions(payload) {
|
|
|
35828
35856
|
const options = asArray(question.options)?.map((option) => {
|
|
35829
35857
|
const optionRecord = asObject(option);
|
|
35830
35858
|
if (!optionRecord) return void 0;
|
|
35831
|
-
const label = asString$
|
|
35832
|
-
const description = asString$
|
|
35859
|
+
const label = asString$3(optionRecord.label)?.trim();
|
|
35860
|
+
const description = asString$3(optionRecord.description)?.trim();
|
|
35833
35861
|
if (!label || !description) return;
|
|
35834
35862
|
return {
|
|
35835
35863
|
label,
|
|
35836
35864
|
description
|
|
35837
35865
|
};
|
|
35838
35866
|
}).filter((option) => option !== void 0);
|
|
35839
|
-
const id = asString$
|
|
35840
|
-
const header = asString$
|
|
35841
|
-
const prompt = asString$
|
|
35867
|
+
const id = asString$3(question.id)?.trim();
|
|
35868
|
+
const header = asString$3(question.header)?.trim();
|
|
35869
|
+
const prompt = asString$3(question.question)?.trim();
|
|
35842
35870
|
if (!id || !header || !prompt || !options || options.length === 0) return;
|
|
35843
35871
|
return {
|
|
35844
35872
|
id,
|
|
@@ -35889,9 +35917,9 @@ function codexEventMessage(payload) {
|
|
|
35889
35917
|
}
|
|
35890
35918
|
function codexEventBase(event, canonicalThreadId) {
|
|
35891
35919
|
const msg = codexEventMessage(asObject(event.payload));
|
|
35892
|
-
const turnId = asString$
|
|
35893
|
-
const itemId = asString$
|
|
35894
|
-
const requestId = asString$
|
|
35920
|
+
const turnId = asString$3(msg?.turn_id) ?? asString$3(msg?.turnId);
|
|
35921
|
+
const itemId = asString$3(msg?.item_id) ?? asString$3(msg?.itemId);
|
|
35922
|
+
const requestId = asString$3(msg?.request_id) ?? asString$3(msg?.requestId);
|
|
35895
35923
|
const base = runtimeEventBase(event, canonicalThreadId);
|
|
35896
35924
|
const providerRefs = base.providerRefs ? {
|
|
35897
35925
|
...base.providerRefs,
|
|
@@ -35984,7 +36012,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
35984
36012
|
payload: { questions }
|
|
35985
36013
|
}];
|
|
35986
36014
|
}
|
|
35987
|
-
const detail = asString$
|
|
36015
|
+
const detail = asString$3(payload?.command) ?? asString$3(payload?.reason) ?? asString$3(payload?.prompt);
|
|
35988
36016
|
return [{
|
|
35989
36017
|
...runtimeEventBase(event, canonicalThreadId),
|
|
35990
36018
|
type: "request.opened",
|
|
@@ -36041,7 +36069,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36041
36069
|
}
|
|
36042
36070
|
}];
|
|
36043
36071
|
if (event.method === "thread/started") {
|
|
36044
|
-
const providerThreadId = asString$
|
|
36072
|
+
const providerThreadId = asString$3(asObject(payload?.thread)?.id) ?? asString$3(payload?.threadId);
|
|
36045
36073
|
if (!providerThreadId) return [];
|
|
36046
36074
|
return [{
|
|
36047
36075
|
...runtimeEventBase(event, canonicalThreadId),
|
|
@@ -36057,7 +36085,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36057
36085
|
type: "thread.state.changed",
|
|
36058
36086
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36059
36087
|
payload: {
|
|
36060
|
-
state: event.method === "thread/archived" ? "archived" : event.method === "thread/closed" ? "closed" : event.method === "thread/compacted" ? "compacted" : toThreadState(asString$
|
|
36088
|
+
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),
|
|
36061
36089
|
...event.payload !== void 0 ? { detail: event.payload } : {}
|
|
36062
36090
|
}
|
|
36063
36091
|
}];
|
|
@@ -36066,7 +36094,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36066
36094
|
type: "thread.metadata.updated",
|
|
36067
36095
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36068
36096
|
payload: {
|
|
36069
|
-
...asString$
|
|
36097
|
+
...asString$3(payload?.threadName) ? { name: asString$3(payload?.threadName) } : {},
|
|
36070
36098
|
...event.payload !== void 0 ? { metadata: asObject(event.payload) } : {}
|
|
36071
36099
|
}
|
|
36072
36100
|
}];
|
|
@@ -36083,19 +36111,19 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36083
36111
|
turnId,
|
|
36084
36112
|
type: "turn.started",
|
|
36085
36113
|
payload: {
|
|
36086
|
-
...asString$
|
|
36087
|
-
...asString$
|
|
36114
|
+
...asString$3(turn?.model) ? { model: asString$3(turn?.model) } : {},
|
|
36115
|
+
...asString$3(turn?.effort) ? { effort: asString$3(turn?.effort) } : {}
|
|
36088
36116
|
}
|
|
36089
36117
|
}];
|
|
36090
36118
|
}
|
|
36091
36119
|
if (event.method === "turn/completed") {
|
|
36092
|
-
const errorMessage = asString$
|
|
36120
|
+
const errorMessage = asString$3(asObject(turn?.error)?.message);
|
|
36093
36121
|
return [{
|
|
36094
36122
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36095
36123
|
type: "turn.completed",
|
|
36096
36124
|
payload: {
|
|
36097
36125
|
state: toTurnStatus(turn?.status),
|
|
36098
|
-
...asString$
|
|
36126
|
+
...asString$3(turn?.stopReason) ? { stopReason: asString$3(turn?.stopReason) } : {},
|
|
36099
36127
|
...turn?.usage !== void 0 ? { usage: turn.usage } : {},
|
|
36100
36128
|
...asObject(turn?.modelUsage) ? { modelUsage: asObject(turn?.modelUsage) } : {},
|
|
36101
36129
|
...asNumber$2(turn?.totalCostUsd) !== void 0 ? { totalCostUsd: asNumber$2(turn?.totalCostUsd) } : {},
|
|
@@ -36114,9 +36142,9 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36114
36142
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36115
36143
|
type: "turn.plan.updated",
|
|
36116
36144
|
payload: {
|
|
36117
|
-
...asString$
|
|
36145
|
+
...asString$3(payload?.explanation) ? { explanation: asString$3(payload?.explanation) } : {},
|
|
36118
36146
|
plan: steps.map((entry) => asObject(entry)).filter((entry) => entry !== void 0).map((entry) => ({
|
|
36119
|
-
step: asString$
|
|
36147
|
+
step: asString$3(entry.step) ?? "step",
|
|
36120
36148
|
status: entry.status === "completed" || entry.status === "inProgress" ? entry.status : "pending"
|
|
36121
36149
|
}))
|
|
36122
36150
|
}
|
|
@@ -36125,7 +36153,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36125
36153
|
if (event.method === "turn/diff/updated") return [{
|
|
36126
36154
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36127
36155
|
type: "turn.diff.updated",
|
|
36128
|
-
payload: { unifiedDiff: asString$
|
|
36156
|
+
payload: { unifiedDiff: asString$3(payload?.unifiedDiff) ?? asString$3(payload?.diff) ?? asString$3(payload?.patch) ?? "" }
|
|
36129
36157
|
}];
|
|
36130
36158
|
if (event.method === "item/started") {
|
|
36131
36159
|
const started = mapItemLifecycle(event, canonicalThreadId, "item.started");
|
|
@@ -36152,7 +36180,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36152
36180
|
return updated ? [updated] : [];
|
|
36153
36181
|
}
|
|
36154
36182
|
if (event.method === "item/plan/delta") {
|
|
36155
|
-
const delta = event.textDelta ?? asString$
|
|
36183
|
+
const delta = event.textDelta ?? asString$3(payload?.delta) ?? asString$3(payload?.text) ?? asString$3(asObject(payload?.content)?.text);
|
|
36156
36184
|
if (!delta || delta.length === 0) return [];
|
|
36157
36185
|
return [{
|
|
36158
36186
|
...runtimeEventBase(event, canonicalThreadId),
|
|
@@ -36161,7 +36189,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36161
36189
|
}];
|
|
36162
36190
|
}
|
|
36163
36191
|
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") {
|
|
36164
|
-
const delta = event.textDelta ?? asString$
|
|
36192
|
+
const delta = event.textDelta ?? asString$3(payload?.delta) ?? asString$3(payload?.text) ?? asString$3(asObject(payload?.content)?.text);
|
|
36165
36193
|
if (!delta || delta.length === 0) return [];
|
|
36166
36194
|
return [{
|
|
36167
36195
|
...runtimeEventBase(event, canonicalThreadId),
|
|
@@ -36178,9 +36206,9 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36178
36206
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36179
36207
|
type: "tool.progress",
|
|
36180
36208
|
payload: {
|
|
36181
|
-
...asString$
|
|
36182
|
-
...asString$
|
|
36183
|
-
...asString$
|
|
36209
|
+
...asString$3(payload?.toolUseId) ? { toolUseId: asString$3(payload?.toolUseId) } : {},
|
|
36210
|
+
...asString$3(payload?.toolName) ? { toolName: asString$3(payload?.toolName) } : {},
|
|
36211
|
+
...asString$3(payload?.summary) ? { summary: asString$3(payload?.summary) } : {},
|
|
36184
36212
|
...asNumber$2(payload?.elapsedSeconds) !== void 0 ? { elapsedSeconds: asNumber$2(payload?.elapsedSeconds) } : {}
|
|
36185
36213
|
}
|
|
36186
36214
|
}];
|
|
@@ -36202,21 +36230,21 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36202
36230
|
}];
|
|
36203
36231
|
if (event.method === "codex/event/task_started") {
|
|
36204
36232
|
const msg = codexEventMessage(payload);
|
|
36205
|
-
const taskId = asString$
|
|
36233
|
+
const taskId = asString$3(payload?.id) ?? asString$3(msg?.turn_id);
|
|
36206
36234
|
if (!taskId) return [];
|
|
36207
36235
|
return [{
|
|
36208
36236
|
...codexEventBase(event, canonicalThreadId),
|
|
36209
36237
|
type: "task.started",
|
|
36210
36238
|
payload: {
|
|
36211
36239
|
taskId: asRuntimeTaskId(taskId),
|
|
36212
|
-
...asString$
|
|
36240
|
+
...asString$3(msg?.collaboration_mode_kind) ? { taskType: asString$3(msg?.collaboration_mode_kind) } : {}
|
|
36213
36241
|
}
|
|
36214
36242
|
}];
|
|
36215
36243
|
}
|
|
36216
36244
|
if (event.method === "codex/event/task_complete") {
|
|
36217
36245
|
const msg = codexEventMessage(payload);
|
|
36218
|
-
const taskId = asString$
|
|
36219
|
-
const proposedPlanMarkdown = extractProposedPlanMarkdown(asString$
|
|
36246
|
+
const taskId = asString$3(payload?.id) ?? asString$3(msg?.turn_id);
|
|
36247
|
+
const proposedPlanMarkdown = extractProposedPlanMarkdown(asString$3(msg?.last_agent_message));
|
|
36220
36248
|
if (!taskId) {
|
|
36221
36249
|
if (!proposedPlanMarkdown) return [];
|
|
36222
36250
|
return [{
|
|
@@ -36231,7 +36259,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36231
36259
|
payload: {
|
|
36232
36260
|
taskId: asRuntimeTaskId(taskId),
|
|
36233
36261
|
status: "completed",
|
|
36234
|
-
...asString$
|
|
36262
|
+
...asString$3(msg?.last_agent_message) ? { summary: asString$3(msg?.last_agent_message) } : {}
|
|
36235
36263
|
}
|
|
36236
36264
|
}];
|
|
36237
36265
|
if (proposedPlanMarkdown) events.push({
|
|
@@ -36243,8 +36271,8 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36243
36271
|
}
|
|
36244
36272
|
if (event.method === "codex/event/agent_reasoning") {
|
|
36245
36273
|
const msg = codexEventMessage(payload);
|
|
36246
|
-
const taskId = asString$
|
|
36247
|
-
const description = asString$
|
|
36274
|
+
const taskId = asString$3(payload?.id);
|
|
36275
|
+
const description = asString$3(msg?.text);
|
|
36248
36276
|
if (!taskId || !description) return [];
|
|
36249
36277
|
return [{
|
|
36250
36278
|
...codexEventBase(event, canonicalThreadId),
|
|
@@ -36257,7 +36285,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36257
36285
|
}
|
|
36258
36286
|
if (event.method === "codex/event/reasoning_content_delta") {
|
|
36259
36287
|
const msg = codexEventMessage(payload);
|
|
36260
|
-
const delta = asString$
|
|
36288
|
+
const delta = asString$3(msg?.delta);
|
|
36261
36289
|
if (!delta) return [];
|
|
36262
36290
|
return [{
|
|
36263
36291
|
...codexEventBase(event, canonicalThreadId),
|
|
@@ -36273,26 +36301,26 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36273
36301
|
type: "model.rerouted",
|
|
36274
36302
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36275
36303
|
payload: {
|
|
36276
|
-
fromModel: asString$
|
|
36277
|
-
toModel: asString$
|
|
36278
|
-
reason: asString$
|
|
36304
|
+
fromModel: asString$3(payload?.fromModel) ?? "unknown",
|
|
36305
|
+
toModel: asString$3(payload?.toModel) ?? "unknown",
|
|
36306
|
+
reason: asString$3(payload?.reason) ?? "unknown"
|
|
36279
36307
|
}
|
|
36280
36308
|
}];
|
|
36281
36309
|
if (event.method === "deprecationNotice") return [{
|
|
36282
36310
|
type: "deprecation.notice",
|
|
36283
36311
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36284
36312
|
payload: {
|
|
36285
|
-
summary: asString$
|
|
36286
|
-
...asString$
|
|
36313
|
+
summary: asString$3(payload?.summary) ?? "Deprecation notice",
|
|
36314
|
+
...asString$3(payload?.details) ? { details: asString$3(payload?.details) } : {}
|
|
36287
36315
|
}
|
|
36288
36316
|
}];
|
|
36289
36317
|
if (event.method === "configWarning") return [{
|
|
36290
36318
|
type: "config.warning",
|
|
36291
36319
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36292
36320
|
payload: {
|
|
36293
|
-
summary: asString$
|
|
36294
|
-
...asString$
|
|
36295
|
-
...asString$
|
|
36321
|
+
summary: asString$3(payload?.summary) ?? "Configuration warning",
|
|
36322
|
+
...asString$3(payload?.details) ? { details: asString$3(payload?.details) } : {},
|
|
36323
|
+
...asString$3(payload?.path) ? { path: asString$3(payload?.path) } : {},
|
|
36296
36324
|
...payload?.range !== void 0 ? { range: payload.range } : {}
|
|
36297
36325
|
}
|
|
36298
36326
|
}];
|
|
@@ -36311,12 +36339,12 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36311
36339
|
...runtimeEventBase(event, canonicalThreadId),
|
|
36312
36340
|
payload: {
|
|
36313
36341
|
success: payload?.success === true,
|
|
36314
|
-
...asString$
|
|
36315
|
-
...asString$
|
|
36342
|
+
...asString$3(payload?.name) ? { name: asString$3(payload?.name) } : {},
|
|
36343
|
+
...asString$3(payload?.error) ? { error: asString$3(payload?.error) } : {}
|
|
36316
36344
|
}
|
|
36317
36345
|
}];
|
|
36318
36346
|
if (event.method === "thread/realtime/started") {
|
|
36319
|
-
const realtimeSessionId = asString$
|
|
36347
|
+
const realtimeSessionId = asString$3(payload?.realtimeSessionId);
|
|
36320
36348
|
return [{
|
|
36321
36349
|
type: "thread.realtime.started",
|
|
36322
36350
|
...runtimeEventBase(event, canonicalThreadId),
|
|
@@ -36334,7 +36362,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36334
36362
|
payload: { audio: event.payload ?? {} }
|
|
36335
36363
|
}];
|
|
36336
36364
|
if (event.method === "thread/realtime/error") {
|
|
36337
|
-
const message = asString$
|
|
36365
|
+
const message = asString$3(payload?.message) ?? event.message ?? "Realtime error";
|
|
36338
36366
|
return [{
|
|
36339
36367
|
type: "thread.realtime.error",
|
|
36340
36368
|
...runtimeEventBase(event, canonicalThreadId),
|
|
@@ -36347,7 +36375,7 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
36347
36375
|
payload: { reason: event.message }
|
|
36348
36376
|
}];
|
|
36349
36377
|
if (event.method === "error") {
|
|
36350
|
-
const message = asString$
|
|
36378
|
+
const message = asString$3(asObject(payload?.error)?.message) ?? event.message ?? "Provider runtime error";
|
|
36351
36379
|
const willRetry = payload?.willRetry === true;
|
|
36352
36380
|
return [{
|
|
36353
36381
|
type: willRetry ? "runtime.warning" : "runtime.error",
|
|
@@ -41225,6 +41253,7 @@ const ProviderHealthLive = effect(ProviderHealth, gen(function* () {
|
|
|
41225
41253
|
//#endregion
|
|
41226
41254
|
//#region ../../packages/contracts/src/settings/types.ts
|
|
41227
41255
|
const DEFAULT_ACCOUNT_POOL_EXPOSED_MODELS = [
|
|
41256
|
+
"gpt-5.5",
|
|
41228
41257
|
"gpt-5.4",
|
|
41229
41258
|
"gpt-5.4-mini",
|
|
41230
41259
|
"gpt-5.4-nano"
|
|
@@ -41272,7 +41301,7 @@ const LEGACY_APP_SETTINGS_KEYS = new Set([
|
|
|
41272
41301
|
"activeRemoteBackendId",
|
|
41273
41302
|
"keepDaemonRunningAfterAppClose"
|
|
41274
41303
|
]);
|
|
41275
|
-
function asRecord$
|
|
41304
|
+
function asRecord$2(value) {
|
|
41276
41305
|
return value && typeof value === "object" ? value : {};
|
|
41277
41306
|
}
|
|
41278
41307
|
function stripLegacyAppSettingsKeys(settings) {
|
|
@@ -41286,10 +41315,10 @@ function stripLegacyAppSettingsKeys(settings) {
|
|
|
41286
41315
|
return changed ? next : settings;
|
|
41287
41316
|
}
|
|
41288
41317
|
async function readAppSettings() {
|
|
41289
|
-
return stripLegacyAppSettingsKeys(asRecord$
|
|
41318
|
+
return stripLegacyAppSettingsKeys(asRecord$2((await getAppState()).runtimeSettings));
|
|
41290
41319
|
}
|
|
41291
41320
|
async function writeAppSettings(settings, onUpdated) {
|
|
41292
|
-
const nextSettings = stripLegacyAppSettingsKeys(asRecord$
|
|
41321
|
+
const nextSettings = stripLegacyAppSettingsKeys(asRecord$2(settings));
|
|
41293
41322
|
await updateAppState((current) => ({
|
|
41294
41323
|
...current,
|
|
41295
41324
|
runtimeSettings: nextSettings
|
|
@@ -45946,7 +45975,7 @@ var AccountPoolTurnFailure = class extends Error {
|
|
|
45946
45975
|
function isRecord$2(value) {
|
|
45947
45976
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
45948
45977
|
}
|
|
45949
|
-
function asString$
|
|
45978
|
+
function asString$2(value) {
|
|
45950
45979
|
if (typeof value !== "string") return null;
|
|
45951
45980
|
const trimmed = value.trim();
|
|
45952
45981
|
return trimmed.length > 0 ? trimmed : null;
|
|
@@ -45955,7 +45984,7 @@ function asNumber$1(value) {
|
|
|
45955
45984
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
45956
45985
|
}
|
|
45957
45986
|
function normalizeIsoString(value) {
|
|
45958
|
-
const normalized = asString$
|
|
45987
|
+
const normalized = asString$2(value);
|
|
45959
45988
|
if (!normalized) return null;
|
|
45960
45989
|
const parsed = Date.parse(normalized);
|
|
45961
45990
|
return Number.isNaN(parsed) ? null : new Date(parsed).toISOString();
|
|
@@ -45965,7 +45994,7 @@ function normalizeStringArray(value) {
|
|
|
45965
45994
|
const result = [];
|
|
45966
45995
|
const seen = /* @__PURE__ */ new Set();
|
|
45967
45996
|
for (const entry of input) {
|
|
45968
|
-
const normalized = asString$
|
|
45997
|
+
const normalized = asString$2(entry);
|
|
45969
45998
|
if (!normalized || seen.has(normalized)) continue;
|
|
45970
45999
|
seen.add(normalized);
|
|
45971
46000
|
result.push(normalized);
|
|
@@ -45973,11 +46002,11 @@ function normalizeStringArray(value) {
|
|
|
45973
46002
|
return result;
|
|
45974
46003
|
}
|
|
45975
46004
|
function normalizeReasoningEffort(value) {
|
|
45976
|
-
const normalized = asString$
|
|
46005
|
+
const normalized = asString$2(value)?.toLowerCase() ?? null;
|
|
45977
46006
|
return normalized && normalized.length > 0 ? normalized : null;
|
|
45978
46007
|
}
|
|
45979
46008
|
function normalizeServiceTier(value) {
|
|
45980
|
-
const normalized = asString$
|
|
46009
|
+
const normalized = asString$2(value)?.toLowerCase() ?? null;
|
|
45981
46010
|
return normalized && normalized.length > 0 ? normalized : null;
|
|
45982
46011
|
}
|
|
45983
46012
|
function normalizeConfiguredAccountPoolModels(value) {
|
|
@@ -46013,7 +46042,7 @@ const SHORTCUT_SETTINGS_KEYS = [
|
|
|
46013
46042
|
];
|
|
46014
46043
|
function normalizeShortcutFields(raw) {
|
|
46015
46044
|
const result = {};
|
|
46016
|
-
for (const key of SHORTCUT_SETTINGS_KEYS) result[key] = asString$
|
|
46045
|
+
for (const key of SHORTCUT_SETTINGS_KEYS) result[key] = asString$2(raw[key]) ?? null;
|
|
46017
46046
|
return result;
|
|
46018
46047
|
}
|
|
46019
46048
|
function normalizeStringArrayField(raw, key) {
|
|
@@ -46078,8 +46107,8 @@ function createDefaultStore() {
|
|
|
46078
46107
|
}
|
|
46079
46108
|
function normalizeApiKeyRecord(id, value) {
|
|
46080
46109
|
const record = isRecord$2(value) ? value : null;
|
|
46081
|
-
const tokenHash = asString$
|
|
46082
|
-
const tokenPreview = asString$
|
|
46110
|
+
const tokenHash = asString$2(record?.tokenHash);
|
|
46111
|
+
const tokenPreview = asString$2(record?.tokenPreview);
|
|
46083
46112
|
const createdAt = normalizeIsoString(record?.createdAt);
|
|
46084
46113
|
if (!tokenHash || !tokenPreview || !createdAt) return null;
|
|
46085
46114
|
return {
|
|
@@ -46093,25 +46122,25 @@ function normalizeApiKeyRecord(id, value) {
|
|
|
46093
46122
|
}
|
|
46094
46123
|
function normalizeLegacySessionRecord(id, value) {
|
|
46095
46124
|
const record = isRecord$2(value) ? value : null;
|
|
46096
|
-
const profileName = asString$
|
|
46097
|
-
const threadId = asString$
|
|
46125
|
+
const profileName = asString$2(record?.profileName);
|
|
46126
|
+
const threadId = asString$2(record?.threadId);
|
|
46098
46127
|
const createdAt = normalizeIsoString(record?.createdAt);
|
|
46099
46128
|
const lastUsedAt = normalizeIsoString(record?.lastUsedAt);
|
|
46100
46129
|
if (!profileName || !threadId || !createdAt || !lastUsedAt) return null;
|
|
46101
46130
|
return {
|
|
46102
46131
|
id,
|
|
46103
46132
|
affinityKind: normalizeLegacyAffinityKind(record?.affinityKind),
|
|
46104
|
-
affinityKey: asString$
|
|
46133
|
+
affinityKey: asString$2(record?.affinityKey),
|
|
46105
46134
|
profileName,
|
|
46106
46135
|
threadId,
|
|
46107
|
-
providerThreadId: asString$
|
|
46108
|
-
model: asString$
|
|
46136
|
+
providerThreadId: asString$2(record?.providerThreadId),
|
|
46137
|
+
model: asString$2(record?.model),
|
|
46109
46138
|
status: normalizeSessionStatus(record?.status),
|
|
46110
|
-
lastError: asString$
|
|
46139
|
+
lastError: asString$2(record?.lastError),
|
|
46111
46140
|
createdAt,
|
|
46112
46141
|
lastUsedAt,
|
|
46113
46142
|
expiresAt: normalizeIsoString(record?.expiresAt),
|
|
46114
|
-
lastResponseId: asString$
|
|
46143
|
+
lastResponseId: asString$2(record?.lastResponseId),
|
|
46115
46144
|
responseIds: normalizeStringArray(record?.responseIds).slice(0, MAX_RESPONSE_IDS_PER_SESSION)
|
|
46116
46145
|
};
|
|
46117
46146
|
}
|
|
@@ -46129,7 +46158,7 @@ function normalizeLegacyStore(value) {
|
|
|
46129
46158
|
}
|
|
46130
46159
|
const responseIndex = {};
|
|
46131
46160
|
for (const [responseId, sessionId] of Object.entries(isRecord$2(record?.responseIndex) ? record.responseIndex : {})) {
|
|
46132
|
-
const normalizedSessionId = asString$
|
|
46161
|
+
const normalizedSessionId = asString$2(sessionId);
|
|
46133
46162
|
if (normalizedSessionId) responseIndex[responseId] = normalizedSessionId;
|
|
46134
46163
|
}
|
|
46135
46164
|
return {
|
|
@@ -46142,58 +46171,58 @@ function normalizeLegacyStore(value) {
|
|
|
46142
46171
|
}
|
|
46143
46172
|
function normalizeTranscriptEntry(value) {
|
|
46144
46173
|
const record = isRecord$2(value) ? value : null;
|
|
46145
|
-
const role = asString$
|
|
46174
|
+
const role = asString$2(record?.role);
|
|
46146
46175
|
const createdAt = normalizeIsoString(record?.createdAt);
|
|
46147
46176
|
if (role !== "user" && role !== "assistant" || !createdAt) return null;
|
|
46148
46177
|
return {
|
|
46149
46178
|
role,
|
|
46150
|
-
text: asString$
|
|
46179
|
+
text: asString$2(record?.text),
|
|
46151
46180
|
images: normalizeStringArray(record?.images),
|
|
46152
46181
|
createdAt
|
|
46153
46182
|
};
|
|
46154
46183
|
}
|
|
46155
46184
|
function normalizeSessionRecord(id, value) {
|
|
46156
46185
|
const record = isRecord$2(value) ? value : null;
|
|
46157
|
-
const activeSegmentId = asString$
|
|
46186
|
+
const activeSegmentId = asString$2(record?.activeSegmentId);
|
|
46158
46187
|
const createdAt = normalizeIsoString(record?.createdAt);
|
|
46159
46188
|
const lastUsedAt = normalizeIsoString(record?.lastUsedAt);
|
|
46160
46189
|
if (!activeSegmentId || !createdAt || !lastUsedAt) return null;
|
|
46161
46190
|
const transcript = Array.isArray(record?.transcript) ? record.transcript.map(normalizeTranscriptEntry).filter((entry) => entry !== null) : [];
|
|
46162
|
-
const legacyExposedModel = asString$
|
|
46191
|
+
const legacyExposedModel = asString$2(record?.exposedModel);
|
|
46163
46192
|
const parsedLegacyExposedModel = legacyExposedModel ? parseAccountPoolReasoningVariantModelId(legacyExposedModel) : null;
|
|
46164
46193
|
const forcedServiceTier = normalizeServiceTier(record?.forcedServiceTier);
|
|
46165
46194
|
const forcedReasoningEffort = normalizeReasoningEffort(record?.forcedReasoningEffort) ?? parsedLegacyExposedModel?.reasoningEffort ?? null;
|
|
46166
46195
|
return {
|
|
46167
46196
|
id,
|
|
46168
46197
|
affinityKind: normalizeSessionAffinityKind(record?.affinityKind),
|
|
46169
|
-
affinityKey: asString$
|
|
46198
|
+
affinityKey: asString$2(record?.affinityKey),
|
|
46170
46199
|
activeSegmentId,
|
|
46171
46200
|
segmentIds: normalizeStringArray(record?.segmentIds),
|
|
46172
|
-
model: asString$
|
|
46201
|
+
model: asString$2(record?.model),
|
|
46173
46202
|
exposedModel: parsedLegacyExposedModel ? buildAccountPoolVariantModelId({
|
|
46174
46203
|
modelId: parsedLegacyExposedModel.modelId,
|
|
46175
46204
|
reasoningEffort: parsedLegacyExposedModel.reasoningEffort,
|
|
46176
46205
|
fastMode: forcedServiceTier === "fast"
|
|
46177
|
-
}) : legacyExposedModel ?? asString$
|
|
46206
|
+
}) : legacyExposedModel ?? asString$2(record?.model),
|
|
46178
46207
|
forcedReasoningEffort,
|
|
46179
46208
|
forcedServiceTier,
|
|
46180
46209
|
status: normalizeSessionStatus(record?.status),
|
|
46181
|
-
lastError: asString$
|
|
46210
|
+
lastError: asString$2(record?.lastError),
|
|
46182
46211
|
createdAt,
|
|
46183
46212
|
lastUsedAt,
|
|
46184
46213
|
expiresAt: normalizeIsoString(record?.expiresAt),
|
|
46185
|
-
lastResponseId: asString$
|
|
46214
|
+
lastResponseId: asString$2(record?.lastResponseId),
|
|
46186
46215
|
responseIds: normalizeStringArray(record?.responseIds).slice(0, MAX_RESPONSE_IDS_PER_SESSION),
|
|
46187
46216
|
rolloverCount: asNumber$1(record?.rolloverCount) ?? 0,
|
|
46188
|
-
lastRolloverReason: asString$
|
|
46217
|
+
lastRolloverReason: asString$2(record?.lastRolloverReason),
|
|
46189
46218
|
transcript: transcript.slice(-MAX_TRANSCRIPT_ENTRIES_PER_SESSION)
|
|
46190
46219
|
};
|
|
46191
46220
|
}
|
|
46192
46221
|
function normalizeSegmentRecord(id, value) {
|
|
46193
46222
|
const record = isRecord$2(value) ? value : null;
|
|
46194
|
-
const sessionId = asString$
|
|
46195
|
-
const profileName = asString$
|
|
46196
|
-
const threadId = asString$
|
|
46223
|
+
const sessionId = asString$2(record?.sessionId);
|
|
46224
|
+
const profileName = asString$2(record?.profileName);
|
|
46225
|
+
const threadId = asString$2(record?.threadId);
|
|
46197
46226
|
const createdAt = normalizeIsoString(record?.createdAt);
|
|
46198
46227
|
const lastUsedAt = normalizeIsoString(record?.lastUsedAt);
|
|
46199
46228
|
if (!sessionId || !profileName || !threadId || !createdAt || !lastUsedAt) return null;
|
|
@@ -46202,11 +46231,11 @@ function normalizeSegmentRecord(id, value) {
|
|
|
46202
46231
|
sessionId,
|
|
46203
46232
|
profileName,
|
|
46204
46233
|
threadId,
|
|
46205
|
-
providerThreadId: asString$
|
|
46234
|
+
providerThreadId: asString$2(record?.providerThreadId),
|
|
46206
46235
|
createdAt,
|
|
46207
46236
|
lastUsedAt,
|
|
46208
46237
|
closedAt: normalizeIsoString(record?.closedAt),
|
|
46209
|
-
closeReason: asString$
|
|
46238
|
+
closeReason: asString$2(record?.closeReason),
|
|
46210
46239
|
failureClass: normalizeFailureClass(record?.failureClass)
|
|
46211
46240
|
};
|
|
46212
46241
|
}
|
|
@@ -46216,13 +46245,13 @@ function normalizeProfileStateRecord(value) {
|
|
|
46216
46245
|
cooldownUntil: normalizeIsoString(record?.cooldownUntil),
|
|
46217
46246
|
lastFailureClass: normalizeFailureClass(record?.lastFailureClass),
|
|
46218
46247
|
lastFailureAt: normalizeIsoString(record?.lastFailureAt),
|
|
46219
|
-
lastFailureMessage: asString$
|
|
46248
|
+
lastFailureMessage: asString$2(record?.lastFailureMessage)
|
|
46220
46249
|
};
|
|
46221
46250
|
}
|
|
46222
46251
|
function normalizeResponseIndexRecord(value) {
|
|
46223
46252
|
const record = isRecord$2(value) ? value : null;
|
|
46224
|
-
const sessionId = asString$
|
|
46225
|
-
const segmentId = asString$
|
|
46253
|
+
const sessionId = asString$2(record?.sessionId);
|
|
46254
|
+
const segmentId = asString$2(record?.segmentId);
|
|
46226
46255
|
const createdAt = normalizeIsoString(record?.createdAt) ?? (/* @__PURE__ */ new Date(0)).toISOString();
|
|
46227
46256
|
if (!sessionId || !segmentId) return null;
|
|
46228
46257
|
return {
|
|
@@ -46250,7 +46279,7 @@ function normalizeStore(value) {
|
|
|
46250
46279
|
}
|
|
46251
46280
|
const profilesByName = {};
|
|
46252
46281
|
for (const [name, profileValue] of Object.entries(isRecord$2(record?.profilesByName) ? record.profilesByName : {})) {
|
|
46253
|
-
const normalizedName = asString$
|
|
46282
|
+
const normalizedName = asString$2(name);
|
|
46254
46283
|
if (!normalizedName) continue;
|
|
46255
46284
|
profilesByName[normalizedName] = normalizeProfileStateRecord(profileValue);
|
|
46256
46285
|
}
|
|
@@ -46382,8 +46411,8 @@ function extractTextAndImages(value) {
|
|
|
46382
46411
|
};
|
|
46383
46412
|
const record = isRecord$2(value) ? value : null;
|
|
46384
46413
|
const arrayValue = Array.isArray(value) ? value : Array.isArray(record?.content) ? record?.content : null;
|
|
46385
|
-
const directText = asString$
|
|
46386
|
-
const directImage = asString$
|
|
46414
|
+
const directText = asString$2(record?.text) ?? asString$2(record?.content);
|
|
46415
|
+
const directImage = asString$2(record?.image_url) ?? asString$2(record?.url) ?? asString$2(record?.imageUrl);
|
|
46387
46416
|
if (!arrayValue) return {
|
|
46388
46417
|
text: directText,
|
|
46389
46418
|
images: directImage ? [directImage] : []
|
|
@@ -46397,9 +46426,9 @@ function extractTextAndImages(value) {
|
|
|
46397
46426
|
}
|
|
46398
46427
|
const part = isRecord$2(entry) ? entry : null;
|
|
46399
46428
|
if (!part) continue;
|
|
46400
|
-
const partType = asString$
|
|
46401
|
-
const text = asString$
|
|
46402
|
-
const image = asString$
|
|
46429
|
+
const partType = asString$2(part.type) ?? "text";
|
|
46430
|
+
const text = asString$2(part.text) ?? asString$2(part.content) ?? asString$2(part.value);
|
|
46431
|
+
const image = asString$2(part.image_url) ?? asString$2(part.url) ?? asString$2(part.imageUrl);
|
|
46403
46432
|
if ((partType === "text" || partType === "input_text" || partType === "output_text" || partType === "refusal") && text) {
|
|
46404
46433
|
texts.push(text);
|
|
46405
46434
|
continue;
|
|
@@ -46412,7 +46441,7 @@ function extractTextAndImages(value) {
|
|
|
46412
46441
|
};
|
|
46413
46442
|
}
|
|
46414
46443
|
function assistantLabel(value) {
|
|
46415
|
-
const normalized = asString$
|
|
46444
|
+
const normalized = asString$2(value)?.toLowerCase();
|
|
46416
46445
|
return normalized && normalized.length > 0 ? normalized : null;
|
|
46417
46446
|
}
|
|
46418
46447
|
function isAssistantLikeRecord(value) {
|
|
@@ -46432,8 +46461,8 @@ function collectTextFragments(value, depth = 0) {
|
|
|
46432
46461
|
const record = isRecord$2(value) ? value : null;
|
|
46433
46462
|
if (!record) return [];
|
|
46434
46463
|
return [
|
|
46435
|
-
asString$
|
|
46436
|
-
asString$
|
|
46464
|
+
asString$2(record.text),
|
|
46465
|
+
asString$2(record.output_text),
|
|
46437
46466
|
...collectTextFragments(record.content, depth + 1),
|
|
46438
46467
|
...collectTextFragments(record.parts, depth + 1),
|
|
46439
46468
|
...collectTextFragments(record.output, depth + 1),
|
|
@@ -46467,7 +46496,7 @@ function extractAssistantTextSnapshot(value, depth = 0) {
|
|
|
46467
46496
|
}
|
|
46468
46497
|
function prepareTurnInput(body, fallbackModel) {
|
|
46469
46498
|
const input = body.input;
|
|
46470
|
-
const instructions = asString$
|
|
46499
|
+
const instructions = asString$2(body.instructions);
|
|
46471
46500
|
const messages = [];
|
|
46472
46501
|
const looseImages = [];
|
|
46473
46502
|
let looseText = null;
|
|
@@ -46479,8 +46508,8 @@ function prepareTurnInput(body, fallbackModel) {
|
|
|
46479
46508
|
}
|
|
46480
46509
|
const record = isRecord$2(entry) ? entry : null;
|
|
46481
46510
|
if (!record) continue;
|
|
46482
|
-
const entryRole = asString$
|
|
46483
|
-
const entryType = asString$
|
|
46511
|
+
const entryRole = asString$2(record.role);
|
|
46512
|
+
const entryType = asString$2(record.type);
|
|
46484
46513
|
if (entryRole || entryType === "message") {
|
|
46485
46514
|
const { text, images } = extractTextAndImages(record.content ?? record);
|
|
46486
46515
|
messages.push({
|
|
@@ -46522,8 +46551,8 @@ function prepareTurnInput(body, fallbackModel) {
|
|
|
46522
46551
|
if (instructions) promptParts.push(`Instructions:\n${instructions}`);
|
|
46523
46552
|
if (transcriptParts.length > 0) promptParts.push(`Conversation so far:\n${transcriptParts.join("\n\n")}`);
|
|
46524
46553
|
if (finalPrompt) promptParts.push(finalPrompt);
|
|
46525
|
-
const normalizedModel = normalizeModelSlug(asString$
|
|
46526
|
-
const effort = asString$
|
|
46554
|
+
const normalizedModel = normalizeModelSlug(asString$2(body.model) ?? fallbackModel, "codex") ?? fallbackModel;
|
|
46555
|
+
const effort = asString$2((isRecord$2(body.reasoning) ? body.reasoning : null)?.effort) ?? asString$2(body.effort) ?? void 0;
|
|
46527
46556
|
return {
|
|
46528
46557
|
prompt: promptParts.join("\n\n").trim() || null,
|
|
46529
46558
|
attachments: [...looseImages, ...finalUserImages].map((url) => ({
|
|
@@ -46532,27 +46561,27 @@ function prepareTurnInput(body, fallbackModel) {
|
|
|
46532
46561
|
})),
|
|
46533
46562
|
model: normalizedModel,
|
|
46534
46563
|
effort,
|
|
46535
|
-
serviceTier: asString$
|
|
46564
|
+
serviceTier: asString$2(body.service_tier),
|
|
46536
46565
|
userText: finalPrompt ?? looseText,
|
|
46537
46566
|
userImages: [...looseImages, ...finalUserImages],
|
|
46538
46567
|
includesConversationHistory: transcriptParts.length > 0
|
|
46539
46568
|
};
|
|
46540
46569
|
}
|
|
46541
46570
|
function resolveResponseContinuationKey(body, headers) {
|
|
46542
|
-
const previousResponseId = asString$
|
|
46543
|
-
const conversation = asString$
|
|
46571
|
+
const previousResponseId = asString$2(body.previous_response_id);
|
|
46572
|
+
const conversation = asString$2(body.conversation) ?? (isRecord$2(body.conversation) ? asString$2(body.conversation.id) : null);
|
|
46544
46573
|
if (conversation && previousResponseId) throw new AccountPoolRequestError({
|
|
46545
46574
|
statusCode: 400,
|
|
46546
46575
|
code: "invalid_request_error",
|
|
46547
46576
|
message: "Provide either 'conversation' or 'previous_response_id', not both."
|
|
46548
46577
|
});
|
|
46549
|
-
const durableKey = asString$
|
|
46578
|
+
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;
|
|
46550
46579
|
if (durableKey) return {
|
|
46551
46580
|
previousResponseId,
|
|
46552
46581
|
affinityKind: "pool_session",
|
|
46553
46582
|
affinityKey: durableKey
|
|
46554
46583
|
};
|
|
46555
|
-
const promptCacheKey = asString$
|
|
46584
|
+
const promptCacheKey = asString$2(body.prompt_cache_key);
|
|
46556
46585
|
if (promptCacheKey) return {
|
|
46557
46586
|
previousResponseId,
|
|
46558
46587
|
affinityKind: "prompt_cache",
|
|
@@ -46629,48 +46658,25 @@ function buildAccountPoolExposedModel(id) {
|
|
|
46629
46658
|
const normalizedId = normalizeModelSlug(id, "codex") ?? id.trim();
|
|
46630
46659
|
if (normalizedId.length === 0) return null;
|
|
46631
46660
|
const architecture = inferAccountPoolModelArchitecture(normalizedId);
|
|
46632
|
-
const
|
|
46633
|
-
if (lowerId.startsWith("gpt-5.4-mini")) return {
|
|
46634
|
-
id: normalizedId,
|
|
46635
|
-
actualModelId: normalizedId,
|
|
46636
|
-
name: "GPT-5.4 Mini",
|
|
46637
|
-
description: "GPT-5.4 Mini exposed through the local accounts pool.",
|
|
46638
|
-
architecture,
|
|
46639
|
-
supportedParameters: ACCOUNT_POOL_MODEL_SUPPORTED_PARAMETERS,
|
|
46640
|
-
forcedReasoningEffort: null,
|
|
46641
|
-
forcedServiceTier: null
|
|
46642
|
-
};
|
|
46643
|
-
if (lowerId.startsWith("gpt-5.4-nano")) return {
|
|
46644
|
-
id: normalizedId,
|
|
46645
|
-
actualModelId: normalizedId,
|
|
46646
|
-
name: "GPT-5.4 Nano",
|
|
46647
|
-
description: "GPT-5.4 Nano exposed through the local accounts pool.",
|
|
46648
|
-
architecture,
|
|
46649
|
-
supportedParameters: ACCOUNT_POOL_MODEL_SUPPORTED_PARAMETERS,
|
|
46650
|
-
forcedReasoningEffort: null,
|
|
46651
|
-
forcedServiceTier: null
|
|
46652
|
-
};
|
|
46653
|
-
if (lowerId.startsWith("gpt-5.4-pro")) return {
|
|
46654
|
-
id: normalizedId,
|
|
46655
|
-
actualModelId: normalizedId,
|
|
46656
|
-
name: "GPT-5.4 Pro",
|
|
46657
|
-
description: "GPT-5.4 Pro exposed through the local accounts pool.",
|
|
46658
|
-
architecture,
|
|
46659
|
-
supportedParameters: ACCOUNT_POOL_MODEL_SUPPORTED_PARAMETERS,
|
|
46660
|
-
forcedReasoningEffort: null,
|
|
46661
|
-
forcedServiceTier: null
|
|
46662
|
-
};
|
|
46661
|
+
const displayName = formatAccountPoolModelName(normalizedId);
|
|
46663
46662
|
return {
|
|
46664
46663
|
id: normalizedId,
|
|
46665
46664
|
actualModelId: normalizedId,
|
|
46666
|
-
name:
|
|
46667
|
-
description:
|
|
46665
|
+
name: displayName ?? normalizedId,
|
|
46666
|
+
description: displayName ? `${displayName} exposed through the local accounts pool.` : `${normalizedId} exposed through the local accounts pool.`,
|
|
46668
46667
|
architecture,
|
|
46669
46668
|
supportedParameters: ACCOUNT_POOL_MODEL_SUPPORTED_PARAMETERS,
|
|
46670
46669
|
forcedReasoningEffort: null,
|
|
46671
46670
|
forcedServiceTier: null
|
|
46672
46671
|
};
|
|
46673
46672
|
}
|
|
46673
|
+
function formatAccountPoolModelName(modelId) {
|
|
46674
|
+
const match = /^gpt-(\d+(?:\.\d+)?)(?:-(mini|nano|pro))?$/i.exec(modelId.trim());
|
|
46675
|
+
if (!match) return null;
|
|
46676
|
+
const variant = match[2];
|
|
46677
|
+
const suffix = variant ? ` ${variant.charAt(0).toUpperCase()}${variant.slice(1)}` : "";
|
|
46678
|
+
return `GPT-${match[1]}${suffix}`;
|
|
46679
|
+
}
|
|
46674
46680
|
function inferAccountPoolModelArchitecture(modelId) {
|
|
46675
46681
|
return modelId.trim().toLowerCase().startsWith("gpt-5") ? ACCOUNT_POOL_MULTIMODAL_ARCHITECTURE : ACCOUNT_POOL_TEXT_ONLY_ARCHITECTURE;
|
|
46676
46682
|
}
|
|
@@ -47030,7 +47036,7 @@ var LocalAccountPool = class LocalAccountPool {
|
|
|
47030
47036
|
const responseItemId = `msg_${responseId}`;
|
|
47031
47037
|
let streamOpened = false;
|
|
47032
47038
|
let sequenceNumber = 1;
|
|
47033
|
-
const requestedModel = asString$
|
|
47039
|
+
const requestedModel = asString$2(body.model);
|
|
47034
47040
|
const defaultSelection = this.defaultModelSelection(settings);
|
|
47035
47041
|
const requestedSelection = requestedModel ? this.resolveConfiguredModelSelection(settings, requestedModel) : null;
|
|
47036
47042
|
let responseModel = requestedModel ?? defaultSelection.exposedModelId;
|
|
@@ -47778,8 +47784,8 @@ var LocalAccountPool = class LocalAccountPool {
|
|
|
47778
47784
|
if (event.method === "turn/completed") {
|
|
47779
47785
|
const payload = isRecord$2(event.payload) ? event.payload : null;
|
|
47780
47786
|
const turn = isRecord$2(payload?.turn) ? payload?.turn : payload;
|
|
47781
|
-
const turnStatus = asString$
|
|
47782
|
-
const errorMessage = asString$
|
|
47787
|
+
const turnStatus = asString$2(turn?.status);
|
|
47788
|
+
const errorMessage = asString$2(isRecord$2(turn?.error) ? turn.error.message : void 0) ?? asString$2(payload?.message);
|
|
47783
47789
|
if (turnStatus === "failed" || errorMessage) {
|
|
47784
47790
|
observer.done = true;
|
|
47785
47791
|
observer.reject(new Error(errorMessage ?? "Provider turn failed."));
|
|
@@ -47829,7 +47835,7 @@ var LocalAccountPool = class LocalAccountPool {
|
|
|
47829
47835
|
}
|
|
47830
47836
|
extractEventErrorMessage(payload) {
|
|
47831
47837
|
if (!isRecord$2(payload)) return null;
|
|
47832
|
-
return asString$
|
|
47838
|
+
return asString$2((isRecord$2(payload.error) ? payload.error : payload).message) ?? null;
|
|
47833
47839
|
}
|
|
47834
47840
|
readLiveProviderThreadId(threadId) {
|
|
47835
47841
|
const active = this.manager.listSessions().find((session) => session.threadId === ThreadId.makeUnsafe(threadId));
|
|
@@ -47837,7 +47843,7 @@ var LocalAccountPool = class LocalAccountPool {
|
|
|
47837
47843
|
}
|
|
47838
47844
|
readResumeCursorThreadId(resumeCursor) {
|
|
47839
47845
|
if (!isRecord$2(resumeCursor)) return null;
|
|
47840
|
-
return asString$
|
|
47846
|
+
return asString$2(resumeCursor.threadId);
|
|
47841
47847
|
}
|
|
47842
47848
|
async closeLiveSegment(segmentId) {
|
|
47843
47849
|
const liveSegment = this.liveSegments.get(segmentId);
|
|
@@ -48029,13 +48035,13 @@ var LocalAccountPool = class LocalAccountPool {
|
|
|
48029
48035
|
if (this.settingsCache && this.settingsCache.expiresAt > now) return this.settingsCache.settings;
|
|
48030
48036
|
const raw = await readAppSettings();
|
|
48031
48037
|
const settings = {
|
|
48032
|
-
codexBin: asString$
|
|
48033
|
-
codexArgs: asString$
|
|
48034
|
-
codexHome: asString$
|
|
48038
|
+
codexBin: asString$2(raw.codexBin) ?? null,
|
|
48039
|
+
codexArgs: asString$2(raw.codexArgs) ?? null,
|
|
48040
|
+
codexHome: asString$2(raw.codexHome) ?? null,
|
|
48035
48041
|
automaticAppUpdateChecksEnabled: raw.automaticAppUpdateChecksEnabled !== false,
|
|
48036
48042
|
keepAppRunningAfterWindowClose: raw.keepAppRunningAfterWindowClose === true,
|
|
48037
48043
|
telegramBridgeEnabled: raw.telegramBridgeEnabled === true,
|
|
48038
|
-
telegramBotToken: asString$
|
|
48044
|
+
telegramBotToken: asString$2(raw.telegramBotToken) ?? null,
|
|
48039
48045
|
telegramAllowedChatIds: normalizeStringArrayField(raw, "telegramAllowedChatIds"),
|
|
48040
48046
|
defaultAccessMode: "current",
|
|
48041
48047
|
reviewDeliveryMode: "inline",
|
|
@@ -48046,6 +48052,7 @@ var LocalAccountPool = class LocalAccountPool {
|
|
|
48046
48052
|
projectsDefaultThreadEnvMode: raw.projectsDefaultThreadEnvMode === "worktree" ? "worktree" : "local",
|
|
48047
48053
|
projectsAssistantStreamingEnabled: false,
|
|
48048
48054
|
projectsConfirmThreadDelete: true,
|
|
48055
|
+
projectsAddProjectBaseDirectory: asString$2(raw.projectsAddProjectBaseDirectory) ?? null,
|
|
48049
48056
|
projectsCustomCodexModels: normalizeStringArrayField(raw, "projectsCustomCodexModels"),
|
|
48050
48057
|
...normalizeAccountPoolFields(raw)
|
|
48051
48058
|
};
|
|
@@ -48139,7 +48146,8 @@ const FAVICON_CANDIDATES = [
|
|
|
48139
48146
|
"assets/icon.svg",
|
|
48140
48147
|
"assets/icon.png",
|
|
48141
48148
|
"assets/logo.svg",
|
|
48142
|
-
"assets/logo.png"
|
|
48149
|
+
"assets/logo.png",
|
|
48150
|
+
".idea/icon.svg"
|
|
48143
48151
|
];
|
|
48144
48152
|
const ICON_SOURCE_FILES = [
|
|
48145
48153
|
"index.html",
|
|
@@ -49455,6 +49463,8 @@ const COMMAND_TIMEOUT_MS = 5e3;
|
|
|
49455
49463
|
const AUTH_STATUS_TIMEOUT_MS = 8e3;
|
|
49456
49464
|
const APP_SERVER_TIMEOUT_MS = 8e3;
|
|
49457
49465
|
const MODEL_LIST_TIMEOUT_MS = 5e3;
|
|
49466
|
+
const CODEX_NPM_PACKAGE = "@openai/codex";
|
|
49467
|
+
const CODEX_INSTALL_TIMEOUT_MS = 12e4;
|
|
49458
49468
|
function tokenizeArgs(rawArgs) {
|
|
49459
49469
|
const input = rawArgs?.trim();
|
|
49460
49470
|
if (!input) return [];
|
|
@@ -49542,16 +49552,26 @@ function runCommand(command, args, options) {
|
|
|
49542
49552
|
globalThis.clearTimeout(timeout);
|
|
49543
49553
|
reject(error);
|
|
49544
49554
|
});
|
|
49545
|
-
child.on("close", (code) => {
|
|
49555
|
+
child.on("close", (code, signal) => {
|
|
49546
49556
|
globalThis.clearTimeout(timeout);
|
|
49547
49557
|
resolve({
|
|
49548
49558
|
stdout,
|
|
49549
49559
|
stderr,
|
|
49550
|
-
code
|
|
49560
|
+
code,
|
|
49561
|
+
signal
|
|
49551
49562
|
});
|
|
49552
49563
|
});
|
|
49553
49564
|
});
|
|
49554
49565
|
}
|
|
49566
|
+
function describeCommandFailure(result, fallback) {
|
|
49567
|
+
const stderr = result.stderr.trim();
|
|
49568
|
+
if (stderr) return stderr;
|
|
49569
|
+
const stdout = result.stdout.trim();
|
|
49570
|
+
if (stdout) return stdout;
|
|
49571
|
+
if (result.signal) return `Codex CLI was found but was terminated by ${result.signal}.`;
|
|
49572
|
+
if (result.code !== null) return `Codex CLI exited with code ${result.code}.`;
|
|
49573
|
+
return fallback;
|
|
49574
|
+
}
|
|
49555
49575
|
function coerceModelListItems(response) {
|
|
49556
49576
|
if (!response || typeof response !== "object") return [];
|
|
49557
49577
|
const record = response;
|
|
@@ -49593,6 +49613,26 @@ function parseModelListResponse(response) {
|
|
|
49593
49613
|
};
|
|
49594
49614
|
}).filter((model) => model !== null);
|
|
49595
49615
|
}
|
|
49616
|
+
function asRecord$1(value) {
|
|
49617
|
+
return value && typeof value === "object" ? value : null;
|
|
49618
|
+
}
|
|
49619
|
+
function asString$1(value) {
|
|
49620
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
49621
|
+
}
|
|
49622
|
+
function formatCodexAccountLabel(response) {
|
|
49623
|
+
const record = asRecord$1(response);
|
|
49624
|
+
const account = asRecord$1(record?.account) ?? record;
|
|
49625
|
+
if (!account) return null;
|
|
49626
|
+
const type = asString$1(account.type);
|
|
49627
|
+
const email = asString$1(account.email) ?? asString$1(account.login) ?? asString$1(account.accountEmail) ?? asString$1(account.account_email);
|
|
49628
|
+
const plan = asString$1(account.planType) ?? asString$1(account.plan_type) ?? asString$1(account.plan);
|
|
49629
|
+
if (email && plan) return `${email} (${plan})`;
|
|
49630
|
+
if (email) return email;
|
|
49631
|
+
if (type === "apiKey") return "API key";
|
|
49632
|
+
if (type === "chatgpt" && plan) return `ChatGPT ${plan}`;
|
|
49633
|
+
if (type === "chatgpt") return "ChatGPT";
|
|
49634
|
+
return null;
|
|
49635
|
+
}
|
|
49596
49636
|
function compareModelsByLatest(left, right) {
|
|
49597
49637
|
const parseVersionScore = (model) => {
|
|
49598
49638
|
const match = /^gpt-(\d+)(?:\.(\d+))?(?:\.(\d+))?/i.exec(model.trim());
|
|
@@ -49710,10 +49750,13 @@ async function inspectAppServer(input) {
|
|
|
49710
49750
|
params: {}
|
|
49711
49751
|
})}\n`);
|
|
49712
49752
|
try {
|
|
49753
|
+
const modelListResponse = await request("model/list", {}, MODEL_LIST_TIMEOUT_MS);
|
|
49754
|
+
const accountResponse = await request("account/read", {}, MODEL_LIST_TIMEOUT_MS).catch(() => null);
|
|
49713
49755
|
return {
|
|
49714
49756
|
appServerOk: true,
|
|
49715
|
-
models: parseModelListResponse(
|
|
49757
|
+
models: parseModelListResponse(modelListResponse).sort(compareModelsByLatest),
|
|
49716
49758
|
modelsError: null,
|
|
49759
|
+
accountLabel: formatCodexAccountLabel(accountResponse),
|
|
49717
49760
|
details: null
|
|
49718
49761
|
};
|
|
49719
49762
|
} catch (error) {
|
|
@@ -49721,6 +49764,7 @@ async function inspectAppServer(input) {
|
|
|
49721
49764
|
appServerOk: true,
|
|
49722
49765
|
models: [],
|
|
49723
49766
|
modelsError: error instanceof Error ? error.message : "Unable to read model list.",
|
|
49767
|
+
accountLabel: null,
|
|
49724
49768
|
details: stderr.trim() || null
|
|
49725
49769
|
};
|
|
49726
49770
|
}
|
|
@@ -49729,6 +49773,7 @@ async function inspectAppServer(input) {
|
|
|
49729
49773
|
appServerOk: false,
|
|
49730
49774
|
models: [],
|
|
49731
49775
|
modelsError: null,
|
|
49776
|
+
accountLabel: null,
|
|
49732
49777
|
details: error instanceof Error ? error.message : stderr.trim() || "Unable to start codex app-server."
|
|
49733
49778
|
};
|
|
49734
49779
|
} finally {
|
|
@@ -49754,7 +49799,7 @@ async function inspectCodexRuntime(input) {
|
|
|
49754
49799
|
});
|
|
49755
49800
|
const parsedVersion = parseCodexCliVersion(`${versionResult.stdout}\n${versionResult.stderr}`);
|
|
49756
49801
|
version = parsedVersion ?? (versionResult.stdout.trim() || null);
|
|
49757
|
-
if (versionResult.code !== 0) details =
|
|
49802
|
+
if (versionResult.code !== 0) details = describeCommandFailure(versionResult, "Codex CLI failed to run `--version`.");
|
|
49758
49803
|
else if (parsedVersion && !isCodexCliVersionSupported(parsedVersion)) details = formatCodexCliUpgradeMessage(parsedVersion);
|
|
49759
49804
|
} catch (error) {
|
|
49760
49805
|
details = error instanceof Error ? error.message : "Unable to run Codex CLI.";
|
|
@@ -49799,6 +49844,7 @@ async function inspectCodexRuntime(input) {
|
|
|
49799
49844
|
appServerOk: false,
|
|
49800
49845
|
models: [],
|
|
49801
49846
|
modelsError: null,
|
|
49847
|
+
accountLabel: null,
|
|
49802
49848
|
details: null
|
|
49803
49849
|
};
|
|
49804
49850
|
return {
|
|
@@ -49809,6 +49855,7 @@ async function inspectCodexRuntime(input) {
|
|
|
49809
49855
|
appServerOk: appServerInspection.appServerOk,
|
|
49810
49856
|
authStatus,
|
|
49811
49857
|
authMessage,
|
|
49858
|
+
accountLabel: appServerInspection.accountLabel,
|
|
49812
49859
|
details: details ?? appServerInspection.details,
|
|
49813
49860
|
path: binaryPath,
|
|
49814
49861
|
nodeOk,
|
|
@@ -49819,6 +49866,39 @@ async function inspectCodexRuntime(input) {
|
|
|
49819
49866
|
modelsError: appServerInspection.modelsError
|
|
49820
49867
|
};
|
|
49821
49868
|
}
|
|
49869
|
+
function compactCommandOutput(output) {
|
|
49870
|
+
const trimmed = output.trim();
|
|
49871
|
+
if (!trimmed) return null;
|
|
49872
|
+
return trimmed.length > 4e3 ? `${trimmed.slice(-4e3)}` : trimmed;
|
|
49873
|
+
}
|
|
49874
|
+
async function updateCodexRuntime() {
|
|
49875
|
+
const beforeVersion = (await inspectCodexRuntime({}).catch(() => null))?.doctor.version ?? null;
|
|
49876
|
+
const result = await runCommand("npm", [
|
|
49877
|
+
"install",
|
|
49878
|
+
"-g",
|
|
49879
|
+
CODEX_NPM_PACKAGE
|
|
49880
|
+
], {
|
|
49881
|
+
timeoutMs: CODEX_INSTALL_TIMEOUT_MS,
|
|
49882
|
+
env: process.env
|
|
49883
|
+
}).catch((error) => ({
|
|
49884
|
+
stdout: "",
|
|
49885
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
49886
|
+
code: 1
|
|
49887
|
+
}));
|
|
49888
|
+
const afterVersion = (await inspectCodexRuntime({}).catch(() => null))?.doctor.version ?? null;
|
|
49889
|
+
const ok = result.code === 0 && Boolean(afterVersion);
|
|
49890
|
+
const output = compactCommandOutput(`${result.stdout}\n${result.stderr}`);
|
|
49891
|
+
return {
|
|
49892
|
+
ok,
|
|
49893
|
+
method: "npm",
|
|
49894
|
+
package: CODEX_NPM_PACKAGE,
|
|
49895
|
+
beforeVersion,
|
|
49896
|
+
afterVersion,
|
|
49897
|
+
upgraded: Boolean(ok && afterVersion && (!beforeVersion || beforeVersion !== afterVersion)),
|
|
49898
|
+
output,
|
|
49899
|
+
details: ok ? null : output ?? `Failed to run npm install -g ${CODEX_NPM_PACKAGE}.`
|
|
49900
|
+
};
|
|
49901
|
+
}
|
|
49822
49902
|
//#endregion
|
|
49823
49903
|
//#region src/agentChat.ts
|
|
49824
49904
|
const AGENT_CHAT_AGENTS_CONTENT = `# AGENTS.md — Agent
|
|
@@ -52923,6 +53003,7 @@ const createServer = fn(function* () {
|
|
|
52923
53003
|
codexHomePath: runtimeContext.codexHomePath
|
|
52924
53004
|
}));
|
|
52925
53005
|
}
|
|
53006
|
+
case WS_METHODS.codexRuntimeUpdate: return yield* promise(() => updateCodexRuntime());
|
|
52926
53007
|
case WS_METHODS.telegramStatus: return telegramBridge.getStatus();
|
|
52927
53008
|
case WS_METHODS.telegramTestToken: {
|
|
52928
53009
|
const body = stripRequestTag(request.body);
|