@codexhost/cli-win32-x64 0.29.2 → 0.30.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/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +40 -15
- package/app/console-web.js +49 -24
- package/app/desktop-controller.mjs +53 -28
- package/app/host-runtime.mjs +2616 -1978
- package/app/plugins/antigravity/plugin.mjs +40 -15
- package/app/plugins/claude-code/plugin.mjs +40 -15
- package/app/plugins/codebuddy/plugin.mjs +514 -109
- package/app/plugins/codex-usage/plugin.mjs +58 -33
- package/app/plugins/copilot/plugin.mjs +40 -15
- package/app/plugins/cursor-cli/plugin.mjs +40 -15
- package/app/plugins/deepseek-harness/plugin.mjs +40 -15
- package/app/plugins/devin/plugin.mjs +40 -15
- package/app/plugins/grok/plugin.mjs +40 -15
- package/app/plugins/hermes/plugin.mjs +40 -15
- package/app/plugins/kimi-code/plugin.mjs +40 -15
- package/app/plugins/kiro-cli/plugin.mjs +40 -15
- package/app/plugins/omp/plugin.mjs +40 -15
- package/app/plugins/opencode/plugin.mjs +40 -15
- package/app/plugins/pi/plugin.mjs +40 -15
- package/app/plugins/qoder/plugin.mjs +40 -15
- package/app/plugins/qoder-cn/plugin.mjs +40 -15
- package/app/plugins/qwen-code/plugin.mjs +40 -15
- package/app/plugins/workbuddy/plugin.mjs +548 -112
- package/app/plugins/zcode/plugin.mjs +40 -15
- package/app/renderer-extension.js +52 -27
- package/app/web/assets/abnfDiagram-XWFEHMT6-BdinLox4.js +1 -0
- package/app/web/assets/architectureDiagram-CSQXQB3N-DgPBbtvP.js +36 -0
- package/app/web/assets/blockDiagram-BEDRHYPZ-B4ENdwtZ.js +140 -0
- package/app/web/assets/bpmnIcons-APHXDYXF-ByGoYv9M.js +1 -0
- package/app/web/assets/c4Diagram-M2UUVUY5-DA6Owfyu.js +38 -0
- package/app/web/assets/chunk-2Q5K7J3B-Dvh3qOmo.js +1 -0
- package/app/web/assets/chunk-3GCGMST5-VIkqueym.js +1 -0
- package/app/web/assets/chunk-5VM5RSS4-DTYof_OI.js +15 -0
- package/app/web/assets/chunk-7U7NFRK5-Dp7s2dg0.js +88 -0
- package/app/web/assets/chunk-CNRTWJTD-TKBKxZLU.js +1 -0
- package/app/web/assets/chunk-D5HYT7QG-BRZDovSS.js +1 -0
- package/app/web/assets/chunk-EBZ3SEQC-C9USZ3tT.js +2 -0
- package/app/web/assets/chunk-JWPE2WC7-BrdvVNVo.js +1 -0
- package/app/web/assets/chunk-KTR4FSNJ-C7qwjGba.js +1 -0
- package/app/web/assets/chunk-XXDRQBXY-DlSrRuwN.js +1 -0
- package/app/web/assets/classDiagram-v2-KXABOMEV-BFvB4kwX.js +217 -0
- package/app/web/assets/cose-bilkent-JH36ORCC-UyCAqNvj.js +1 -0
- package/app/web/assets/cynefin-EF2NZ3EQ-CwawUbjJ.js +141 -0
- package/app/web/assets/cynefinDiagram-NJNITYFG-BaWEIQJ0.js +62 -0
- package/app/web/assets/cytoscape.esm-Cm0uQArZ.js +332 -0
- package/app/web/assets/d3-scale-4DPf7zan.js +1 -0
- package/app/web/assets/dagre-KIHZ2IZ3-B7ENIjLG.js +4 -0
- package/app/web/assets/diagram-7YQZDPLS-CxRMU8xq.js +41 -0
- package/app/web/assets/diagram-QBROCOUO-qo7sxm4K.js +200 -0
- package/app/web/assets/diagram-RJJCUUZO-CQiGMCMe.js +30 -0
- package/app/web/assets/diagram-WERXNKYE-D0Jps1As.js +24 -0
- package/app/web/assets/diagram-YHHI257C-p4AB8cqK.js +3 -0
- package/app/web/assets/diagram-YR4HJLHV-Bh6JKT04.js +24 -0
- package/app/web/assets/ebnfDiagram-N527522P-DRac0k4W.js +1 -0
- package/app/web/assets/elk-O5DQBFGD-CWTz5SZP.js +27 -0
- package/app/web/assets/erDiagram-K3K3BIDK-DE3w4BEY.js +99 -0
- package/app/web/assets/flowDiagram-Z6JWZHQI-NYs8bi5t.js +213 -0
- package/app/web/assets/ganttDiagram-3PRQTZWP-Bspp9btW.js +292 -0
- package/app/web/assets/gitGraphDiagram-VXDFKS5L-ByGW1uvv.js +106 -0
- package/app/web/assets/graph-D8UmR1vK.js +1 -0
- package/app/web/assets/grid-E2QIVN74-CegebiIw.js +1 -0
- package/app/web/assets/{index-aSHN2MIG.css → index-BbmB5VLj.css} +1 -1
- package/app/web/assets/{index-0TnaYwHS.js → index-DFPOGLS4.js} +80 -80
- package/app/web/assets/infoDiagram-EZ3ZOAHP-CexmsdZx.js +2 -0
- package/app/web/assets/ishikawaDiagram-S3EKX5GW-BbWqKhg6.js +70 -0
- package/app/web/assets/journeyDiagram-POQNLL5X-27YlCe-1.js +139 -0
- package/app/web/assets/kanban-definition-BH5XI6FM-BAhOdeck.js +89 -0
- package/app/web/assets/langs/{graphql-ChAeyPkT.js → graphql-D6Z3qcRW.js} +1 -1
- package/app/web/assets/langs/{http-BvreBIbD.js → http-XiU9G9In.js} +1 -1
- package/app/web/assets/langs/{php-D8omCIuJ.js → php-DL3xwS-7.js} +1 -1
- package/app/web/assets/langs/{rst-Do7RLLCS.js → rst-DudRVJ9g.js} +1 -1
- package/app/web/assets/langs/{ruby-rH_O_vse.js → ruby-_FqsfqJi.js} +1 -1
- package/app/web/assets/langs/{svelte-xZy73wAj.js → svelte-ClsVJoBT.js} +1 -1
- package/app/web/assets/langs/{vue-C4DW8agZ.js → vue-BiKMXCyK.js} +1 -1
- package/app/web/assets/mermaid.core-sGgCbv5y.js +314 -0
- package/app/web/assets/mindmap-definition-WVAN44T4-CsMIX0Lj.js +98 -0
- package/app/web/assets/pegDiagram-D4NLKWP3-Cs3LXqn_.js +1 -0
- package/app/web/assets/pieDiagram-36ENHN4W-DdQsQX9I.js +39 -0
- package/app/web/assets/quadrantDiagram-ZQUDMS73-D1jOKqx_.js +7 -0
- package/app/web/assets/railroadDiagram-JIZHGYPL-XulrgX5n.js +1 -0
- package/app/web/assets/render-VIF2ZAQL-CSsGw-0I.js +2 -0
- package/app/web/assets/requirementDiagram-AXW2TVFA-CT66GXLN.js +84 -0
- package/app/web/assets/sankeyDiagram-FBCJTAIF-CNRKebNY.js +40 -0
- package/app/web/assets/sequenceDiagram-3LA2ROMG-DVl5y64e.js +169 -0
- package/app/web/assets/sizeCapture-2Q2CQKSF-Kg0XxSga.js +1 -0
- package/app/web/assets/stateDiagram-v2-ATKHQDJO-DYQnfMsS.js +291 -0
- package/app/web/assets/swimlanes-YQL5WMAO-Chqt7pxD.js +1 -0
- package/app/web/assets/swimlanesDiagram-UCCPES4V-BfREktNP.js +8 -0
- package/app/web/assets/timeline-definition-7Z437IG3-aHFxjIT6.js +120 -0
- package/app/web/assets/usecaseDiagram-RDK6N6HP-DsC5tFe4.js +370 -0
- package/app/web/assets/vendor-BKfNgqAm.js +666 -0
- package/app/web/assets/vennDiagram-SHRQU5PJ-C65oZxFn.js +34 -0
- package/app/web/assets/wardleyDiagram-F3OXNVQS-HTkq7DT0.js +78 -0
- package/app/web/assets/xychartDiagram-GDYJKCDI-p1LpQ9MH.js +7 -0
- package/app/web/codexhost-settings.js +39 -39
- package/app/web/index.html +3 -3
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +65 -65
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
- package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +17 -17
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +16 -16
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +16 -16
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +3 -3
- package/app/web/plugins/deepseek-ai__dsh-client-ui-permission-presets/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-plan/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
- package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +14 -14
- package/app/web-modules/licenses/DSH-THIRD_PARTY_NOTICES.md +1 -1
- package/app/web-modules/server.mjs +348 -118
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-screenshot.exe +0 -0
- package/libexec/codexhost-shell.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
- package/app/web/assets/vendor-C9g2bw8s.js +0 -410
|
@@ -72531,12 +72531,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
|
|
|
72531
72531
|
threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
|
|
72532
72532
|
}).strict().superRefine(({ threads }, context) => {
|
|
72533
72533
|
let seen = /* @__PURE__ */ new Set();
|
|
72534
|
-
for (let [index,
|
|
72535
|
-
seen.has(
|
|
72534
|
+
for (let [index, thread3] of threads.entries())
|
|
72535
|
+
seen.has(thread3.threadId) && context.addIssue({
|
|
72536
72536
|
code: "custom",
|
|
72537
72537
|
message: "Thread ownership-list results must be unique",
|
|
72538
72538
|
path: ["threads", index, "threadId"]
|
|
72539
|
-
}), seen.add(
|
|
72539
|
+
}), seen.add(thread3.threadId);
|
|
72540
72540
|
}), threadSteeringInspectParamsSchema = external_exports.object({
|
|
72541
72541
|
threadId: hostThreadIdSchema,
|
|
72542
72542
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
@@ -73140,6 +73140,25 @@ var productTelemetrySettingsSchema = external_exports.object({
|
|
|
73140
73140
|
message: "Telemetry heartbeat must contain at least one countable field"
|
|
73141
73141
|
});
|
|
73142
73142
|
|
|
73143
|
+
// packages/shared-contracts/dist/native-codex-goal.js
|
|
73144
|
+
var NATIVE_CODEX_GOAL_METHOD = "codexhost/thread/goal", nativeCodexGoalInvocation = /^\/goal(?:\s|$)/u, NATIVE_CODEX_GOAL_MAX_OBJECTIVE_CHARS = 4e3, thread = { threadId: hostThreadIdSchema }, nativeCodexGoalRequestSchema = external_exports.discriminatedUnion("action", [
|
|
73145
|
+
external_exports.strictObject({ ...thread, action: external_exports.enum(["get", "pause", "resume", "clear"]) }),
|
|
73146
|
+
external_exports.strictObject({
|
|
73147
|
+
...thread,
|
|
73148
|
+
action: external_exports.enum(["create", "edit"]),
|
|
73149
|
+
objective: external_exports.string().trim().min(1).refine((objective) => Array.from(objective).length <= NATIVE_CODEX_GOAL_MAX_OBJECTIVE_CHARS, `A goal objective can have up to ${NATIVE_CODEX_GOAL_MAX_OBJECTIVE_CHARS} characters.`)
|
|
73150
|
+
})
|
|
73151
|
+
]), nativeCodexGoalResultSchema = external_exports.object({
|
|
73152
|
+
goal: external_exports.object({
|
|
73153
|
+
threadId: hostThreadIdSchema,
|
|
73154
|
+
objective: external_exports.string(),
|
|
73155
|
+
status: external_exports.enum(["active", "paused", "blocked", "usageLimited", "budgetLimited", "complete"]),
|
|
73156
|
+
tokenBudget: external_exports.int().positive().nullable().default(null),
|
|
73157
|
+
tokensUsed: external_exports.int().nonnegative(),
|
|
73158
|
+
timeUsedSeconds: external_exports.int().nonnegative()
|
|
73159
|
+
}).nullable()
|
|
73160
|
+
});
|
|
73161
|
+
|
|
73143
73162
|
// packages/shared-contracts/dist/client-channel.js
|
|
73144
73163
|
var CLIENT_CHANNEL_VERSION = 1, CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
73145
73164
|
var CLIENT_CHANNEL_METHODS = [
|
|
@@ -73151,10 +73170,12 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
73151
73170
|
"codexhost/harness/display-settings/capabilities",
|
|
73152
73171
|
"codexhost/harness/preferences/get",
|
|
73153
73172
|
"codexhost/harness/preferences/patch",
|
|
73173
|
+
"experimentalFeature/list",
|
|
73154
73174
|
"thread/list",
|
|
73155
73175
|
"thread/metadata/update",
|
|
73156
73176
|
"codexhost/thread/catalog/read",
|
|
73157
73177
|
"thread/read",
|
|
73178
|
+
NATIVE_CODEX_GOAL_METHOD,
|
|
73158
73179
|
"thread/resume",
|
|
73159
73180
|
"thread/fork",
|
|
73160
73181
|
"thread/turns/list",
|
|
@@ -74335,7 +74356,8 @@ var field = external_exports.discriminatedUnion("type", [
|
|
|
74335
74356
|
var WEB_ACTIVE_TURN_PROJECTION = "codexhostActiveTurnId", WEB_FOLLOW_PROJECTION_KEYS = /* @__PURE__ */ new Set([
|
|
74336
74357
|
WEB_ACTIVE_TURN_PROJECTION,
|
|
74337
74358
|
"codexhostTurnChanges",
|
|
74338
|
-
"codexhostToolOutput"
|
|
74359
|
+
"codexhostToolOutput",
|
|
74360
|
+
"codexGoal"
|
|
74339
74361
|
]), webFileDiffSchema = external_exports.object({
|
|
74340
74362
|
path: external_exports.string(),
|
|
74341
74363
|
oldText: external_exports.string().nullable(),
|
|
@@ -74899,7 +74921,7 @@ function remoteSessionRequestBytes(operation) {
|
|
|
74899
74921
|
}
|
|
74900
74922
|
var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(1).max(REMOTE_IDENTITY_MAX_LENGTH), target = {
|
|
74901
74923
|
hostId: identity.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)
|
|
74902
|
-
},
|
|
74924
|
+
}, thread2 = { ...target, threadId: identity }, text = external_exports.string().min(1).max(8e3), input2 = { text, requestId: identity }, remoteDeliveryReplySchema = external_exports.discriminatedUnion("accepted", [
|
|
74903
74925
|
external_exports.object({ accepted: external_exports.literal(!0), startQueuedItemId: identity.optional() }),
|
|
74904
74926
|
external_exports.object({
|
|
74905
74927
|
accepted: external_exports.literal(!1),
|
|
@@ -74945,7 +74967,7 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
|
|
|
74945
74967
|
serviceTier: external_exports.enum(["priority", "ultrafast"]).optional(),
|
|
74946
74968
|
reasoningEffort: identity.optional()
|
|
74947
74969
|
}),
|
|
74948
|
-
external_exports.strictObject({ kind: external_exports.literal("status"), ...
|
|
74970
|
+
external_exports.strictObject({ kind: external_exports.literal("status"), ...thread2 }),
|
|
74949
74971
|
external_exports.strictObject({
|
|
74950
74972
|
kind: external_exports.literal("list"),
|
|
74951
74973
|
...target,
|
|
@@ -74955,7 +74977,7 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
|
|
|
74955
74977
|
}),
|
|
74956
74978
|
external_exports.strictObject({
|
|
74957
74979
|
kind: external_exports.literal("read"),
|
|
74958
|
-
...
|
|
74980
|
+
...thread2,
|
|
74959
74981
|
page: external_exports.strictObject({
|
|
74960
74982
|
cursor: external_exports.string().min(1).max(8192).nullable(),
|
|
74961
74983
|
epoch: identity.optional(),
|
|
@@ -74965,10 +74987,10 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
|
|
|
74965
74987
|
message: "A history continuation requires its connection epoch"
|
|
74966
74988
|
}).optional()
|
|
74967
74989
|
}),
|
|
74968
|
-
external_exports.strictObject({ kind: external_exports.literal("usage"), ...
|
|
74990
|
+
external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread2, epoch: identity }),
|
|
74969
74991
|
external_exports.strictObject({
|
|
74970
74992
|
kind: external_exports.literal("configure"),
|
|
74971
|
-
...
|
|
74993
|
+
...thread2,
|
|
74972
74994
|
epoch: identity,
|
|
74973
74995
|
modelId: identity.optional(),
|
|
74974
74996
|
serviceTier: harnessModelServiceTierSchema.optional(),
|
|
@@ -74979,15 +75001,15 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
|
|
|
74979
75001
|
}),
|
|
74980
75002
|
external_exports.strictObject({
|
|
74981
75003
|
kind: external_exports.literal("prompt"),
|
|
74982
|
-
...
|
|
75004
|
+
...thread2,
|
|
74983
75005
|
epoch: identity,
|
|
74984
75006
|
text,
|
|
74985
75007
|
requestId: identity.optional()
|
|
74986
75008
|
}),
|
|
74987
|
-
external_exports.strictObject({ kind: external_exports.literal("queue"), ...
|
|
75009
|
+
external_exports.strictObject({ kind: external_exports.literal("queue"), ...thread2, epoch: identity }),
|
|
74988
75010
|
external_exports.strictObject({
|
|
74989
75011
|
kind: external_exports.literal("delivery"),
|
|
74990
|
-
...
|
|
75012
|
+
...thread2,
|
|
74991
75013
|
epoch: identity,
|
|
74992
75014
|
action: external_exports.discriminatedUnion("kind", [
|
|
74993
75015
|
external_exports.strictObject({ kind: external_exports.literal("enqueue"), ...input2 }),
|
|
@@ -75001,17 +75023,17 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
|
|
|
75001
75023
|
external_exports.strictObject({ kind: external_exports.literal("sendNow"), itemId: identity })
|
|
75002
75024
|
])
|
|
75003
75025
|
}),
|
|
75004
|
-
external_exports.strictObject({ kind: external_exports.literal("interrupt"), ...
|
|
75026
|
+
external_exports.strictObject({ kind: external_exports.literal("interrupt"), ...thread2, epoch: identity, turnId: identity }),
|
|
75005
75027
|
external_exports.strictObject({
|
|
75006
75028
|
kind: external_exports.literal("rename"),
|
|
75007
|
-
...
|
|
75029
|
+
...thread2,
|
|
75008
75030
|
epoch: identity,
|
|
75009
75031
|
name: external_exports.string().min(1).max(512)
|
|
75010
75032
|
}),
|
|
75011
|
-
external_exports.strictObject({ kind: external_exports.literal("archive"), ...
|
|
75033
|
+
external_exports.strictObject({ kind: external_exports.literal("archive"), ...thread2, epoch: identity, archived: external_exports.boolean() }),
|
|
75012
75034
|
external_exports.strictObject({
|
|
75013
75035
|
kind: external_exports.literal("respond"),
|
|
75014
|
-
...
|
|
75036
|
+
...thread2,
|
|
75015
75037
|
epoch: identity,
|
|
75016
75038
|
requestId: external_exports.union([identity, external_exports.number().int()]),
|
|
75017
75039
|
result: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
@@ -77830,8 +77852,8 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77830
77852
|
knownTurns: this.knownTurnsForStatus(threadId),
|
|
77831
77853
|
truncateToolOutput: !0
|
|
77832
77854
|
})
|
|
77833
|
-
),
|
|
77834
|
-
if (
|
|
77855
|
+
), thread3 = snapshot.thread, external = thread3.modelProvider === "codexhost" && thread3.cliVersion === "codexhost";
|
|
77856
|
+
if (thread3.canAcceptDirectInput === !1)
|
|
77835
77857
|
return { accepted: !1, code: "remote/send-rejected", message: "Thread is read-only" };
|
|
77836
77858
|
if (a.kind === "sendNow")
|
|
77837
77859
|
try {
|
|
@@ -77845,7 +77867,7 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77845
77867
|
if (error62 instanceof SessionRuntimeError && error62.code === "remote/request-failed") {
|
|
77846
77868
|
let hostCode = "hostCode" in error62.details && typeof error62.details.hostCode == "number" ? error62.details.hostCode : void 0, message2 = error62.message;
|
|
77847
77869
|
if (hostCode === -32601 || /unsupported client channel method|method not found/iu.test(message2)) {
|
|
77848
|
-
if (
|
|
77870
|
+
if (thread3.status.type === "idle" || thread3.status.type === "notLoaded") {
|
|
77849
77871
|
if (!(await rpc2("thread/queue/start", {
|
|
77850
77872
|
threadId,
|
|
77851
77873
|
queuedSubmissionId: a.itemId
|
|
@@ -77875,7 +77897,7 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77875
77897
|
}
|
|
77876
77898
|
throw error62;
|
|
77877
77899
|
}
|
|
77878
|
-
if (a.kind === "steer" && external && !
|
|
77900
|
+
if (a.kind === "steer" && external && !thread3.codexhostSupportsStrictSteer)
|
|
77879
77901
|
return {
|
|
77880
77902
|
accepted: !1,
|
|
77881
77903
|
code: "remote/steer-unavailable",
|
|
@@ -77903,13 +77925,13 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77903
77925
|
...a.kind === "steer" ? {
|
|
77904
77926
|
expectedTurnId: a.turnId,
|
|
77905
77927
|
...external ? { codexhostSteerStrictTarget: !0 } : {}
|
|
77906
|
-
} : external &&
|
|
77928
|
+
} : external && thread3.status.type === "idle" ? { codexhostQueueStartIfEmpty: !0 } : {}
|
|
77907
77929
|
});
|
|
77908
77930
|
if (a.kind === "enqueue") {
|
|
77909
77931
|
let item = result.queuedSubmission;
|
|
77910
77932
|
if (!item?.id || item.clientUserMessageId !== a.requestId)
|
|
77911
77933
|
throw Error("Queue admission not confirmed");
|
|
77912
|
-
if (!external &&
|
|
77934
|
+
if (!external && thread3.status.type === "idle" && snapshot.queue?.items.length === 0)
|
|
77913
77935
|
return { accepted: !0, startQueuedItemId: item.id };
|
|
77914
77936
|
} else if (result.turnId !== a.turnId && !(external && result.delivery === "newTurn" && result.turnId))
|
|
77915
77937
|
throw Error("Steering not confirmed");
|
|
@@ -78590,9 +78612,9 @@ var ChHarnessCommands = class {
|
|
|
78590
78612
|
resolve;
|
|
78591
78613
|
pending = /* @__PURE__ */ new Set();
|
|
78592
78614
|
async inspect(sessionId) {
|
|
78593
|
-
let
|
|
78615
|
+
let thread3 = await this.resolve(sessionId);
|
|
78594
78616
|
return harnessCommandCatalogSchema.parse(
|
|
78595
|
-
await this.host.request("codexhost/thread/commands/inspect", { threadId:
|
|
78617
|
+
await this.host.request("codexhost/thread/commands/inspect", { threadId: thread3.id })
|
|
78596
78618
|
);
|
|
78597
78619
|
}
|
|
78598
78620
|
/** Draft catalog from its workspace; the Host reads it without creating a Thread. */
|
|
@@ -78605,20 +78627,20 @@ var ChHarnessCommands = class {
|
|
|
78605
78627
|
);
|
|
78606
78628
|
}
|
|
78607
78629
|
async execute(sessionId, commandId) {
|
|
78608
|
-
let
|
|
78609
|
-
if (this.pending.has(
|
|
78630
|
+
let thread3 = await this.resolve(sessionId);
|
|
78631
|
+
if (this.pending.has(thread3.id) || thread3.status.type === "active")
|
|
78610
78632
|
throw new SessionRuntimeError("session/busy", "The Thread is busy. Direct commands cannot be queued.");
|
|
78611
|
-
this.pending.add(
|
|
78633
|
+
this.pending.add(thread3.id);
|
|
78612
78634
|
try {
|
|
78613
78635
|
let command = requireDirectCommand(await this.inspect(sessionId), commandId);
|
|
78614
78636
|
return threadCommandExecuteResultSchema.parse(
|
|
78615
78637
|
await this.host.request("codexhost/thread/command/execute", {
|
|
78616
|
-
threadId:
|
|
78638
|
+
threadId: thread3.id,
|
|
78617
78639
|
commandId: command.id
|
|
78618
78640
|
})
|
|
78619
78641
|
);
|
|
78620
78642
|
} finally {
|
|
78621
|
-
this.pending.delete(
|
|
78643
|
+
this.pending.delete(thread3.id);
|
|
78622
78644
|
}
|
|
78623
78645
|
}
|
|
78624
78646
|
};
|
|
@@ -79161,8 +79183,8 @@ function threadListTitle(row) {
|
|
|
79161
79183
|
}
|
|
79162
79184
|
|
|
79163
79185
|
// packages/web-server/src/ch-thread-time.ts
|
|
79164
|
-
function threadRecencyMs(
|
|
79165
|
-
return (
|
|
79186
|
+
function threadRecencyMs(thread3) {
|
|
79187
|
+
return (thread3.recencyAt ?? thread3.updatedAt) * 1e3;
|
|
79166
79188
|
}
|
|
79167
79189
|
|
|
79168
79190
|
// packages/web-server/src/ch-turn-changes.ts
|
|
@@ -80366,9 +80388,9 @@ function compactTurnToolOutputs(turn) {
|
|
|
80366
80388
|
return changed ? { ...turn, items } : turn;
|
|
80367
80389
|
}
|
|
80368
80390
|
var ChThreadView = class _ChThreadView {
|
|
80369
|
-
constructor(
|
|
80391
|
+
constructor(thread3, harnessId, onProjection, turnStart = 0, sequenceStart = 0, hasEarlier = () => !1, projectInput = (content) => content, projectImage = () => {
|
|
80370
80392
|
}, options) {
|
|
80371
|
-
this.thread =
|
|
80393
|
+
this.thread = thread3;
|
|
80372
80394
|
this.harnessId = harnessId;
|
|
80373
80395
|
this.turnStart = turnStart;
|
|
80374
80396
|
this.projectInput = projectInput;
|
|
@@ -80378,9 +80400,9 @@ var ChThreadView = class _ChThreadView {
|
|
|
80378
80400
|
this.log = new SessionLog(
|
|
80379
80401
|
{
|
|
80380
80402
|
version: 4,
|
|
80381
|
-
id:
|
|
80382
|
-
createdAt:
|
|
80383
|
-
cwd:
|
|
80403
|
+
id: thread3.id,
|
|
80404
|
+
createdAt: thread3.createdAt * 1e3,
|
|
80405
|
+
cwd: thread3.cwd,
|
|
80384
80406
|
isSeeded: !1,
|
|
80385
80407
|
agentPreset: "standard"
|
|
80386
80408
|
},
|
|
@@ -80508,10 +80530,10 @@ var ChThreadView = class _ChThreadView {
|
|
|
80508
80530
|
let storedTurns = this.compactToolOutputs ? turns.map((turn) => compactTurnToolOutputs(turn)) : turns;
|
|
80509
80531
|
this.thread.turns = [...storedTurns, ...this.thread.turns], this.compactToolOutputs && compactLogToolOutputs(this.log), this.publishMessageTimes(), this.publishFileChanges();
|
|
80510
80532
|
}
|
|
80511
|
-
update(
|
|
80533
|
+
update(thread3, activeTurnId) {
|
|
80512
80534
|
this.ensureCurrent();
|
|
80513
80535
|
let existingTurns = new Map(this.thread.turns.map((turn) => [turn.id, turn])), projectionsByTurn = /* @__PURE__ */ new Map();
|
|
80514
|
-
for (let turn of
|
|
80536
|
+
for (let turn of thread3.turns) {
|
|
80515
80537
|
let view = this.turns.get(turn.id);
|
|
80516
80538
|
if (!view || view.done && turn === existingTurns.get(turn.id)) continue;
|
|
80517
80539
|
let items = this.displayItems(turn), ids = new Set(items.map((item) => item.id)), users = items.filter((item) => item.type === "userMessage"), published = [...view.started], lastUser = published.findLastIndex((id2) => view.userMessages.has(id2)), reasoningPreviewIds = new Set(
|
|
@@ -80542,12 +80564,12 @@ var ChThreadView = class _ChThreadView {
|
|
|
80542
80564
|
})) || firstNewUser !== -1 && items.slice(firstNewUser + 1).some((item) => view.started.has(item.id)))
|
|
80543
80565
|
throw new SessionRuntimeError("host/items-replaced", "CH replaced already projected Items.");
|
|
80544
80566
|
}
|
|
80545
|
-
Object.assign(this.thread,
|
|
80546
|
-
blank:
|
|
80547
|
-
lastPromptAt: threadRecencyMs(
|
|
80567
|
+
Object.assign(this.thread, thread3), this.log.setProjection("title", threadListTitle(thread3)), this.log.setProjection("codexhostImportSource", thread3.codexhostImportSource ?? null), this.log.setProjection("sessionListMetadata", {
|
|
80568
|
+
blank: thread3.turns.length === 0,
|
|
80569
|
+
lastPromptAt: threadRecencyMs(thread3)
|
|
80548
80570
|
});
|
|
80549
80571
|
try {
|
|
80550
|
-
this.projectTurns(
|
|
80572
|
+
this.projectTurns(thread3, projectionsByTurn);
|
|
80551
80573
|
} finally {
|
|
80552
80574
|
this.log.clock = void 0;
|
|
80553
80575
|
}
|
|
@@ -80555,7 +80577,7 @@ var ChThreadView = class _ChThreadView {
|
|
|
80555
80577
|
(turn) => this.turns.get(turn.id)?.done ? compactTurnToolOutputs(turn) : turn
|
|
80556
80578
|
), compactLogToolOutputs(this.log)), this.log.setProjection(
|
|
80557
80579
|
WEB_ACTIVE_TURN_PROJECTION,
|
|
80558
|
-
activeTurnId !== void 0 ? activeTurnId :
|
|
80580
|
+
activeTurnId !== void 0 ? activeTurnId : thread3.status.type === "active" ? thread3.turns.findLast((turn) => !finished(turn.status))?.id ?? null : null
|
|
80559
80581
|
), this.log.setProjection("codexhostToolOutput", Object.fromEntries(this.liveOutput)), this.publishMessageTimes(), this.publishFileChanges();
|
|
80560
80582
|
}
|
|
80561
80583
|
projectItem(turnId, item, view, reasoningPreviewIds) {
|
|
@@ -80624,9 +80646,9 @@ var ChThreadView = class _ChThreadView {
|
|
|
80624
80646
|
)
|
|
80625
80647
|
);
|
|
80626
80648
|
}
|
|
80627
|
-
projectTurns(
|
|
80628
|
-
let previousEnd =
|
|
80629
|
-
for (let turn of
|
|
80649
|
+
projectTurns(thread3, projections) {
|
|
80650
|
+
let previousEnd = thread3.createdAt * 1e3;
|
|
80651
|
+
for (let turn of thread3.turns) {
|
|
80630
80652
|
let items = this.displayItems(turn), view = this.turns.get(turn.id), complete = finished(turn.status), start = nativeTime(turn.startedAt) ?? (complete ? previousEnd : Date.now()), end = Math.max(
|
|
80631
80653
|
start,
|
|
80632
80654
|
nativeTime(turn.completedAt) ?? (view && !view.done ? Date.now() : start)
|
|
@@ -80635,7 +80657,7 @@ var ChThreadView = class _ChThreadView {
|
|
|
80635
80657
|
let projector2 = new TurnProjector(this.log, {
|
|
80636
80658
|
live: !complete,
|
|
80637
80659
|
turn: this.turnStart + this.turns.size + 1,
|
|
80638
|
-
cwd:
|
|
80660
|
+
cwd: thread3.cwd,
|
|
80639
80661
|
model: { provider: this.harnessId, model: "harness" },
|
|
80640
80662
|
onToolOutput: (id2, output2) => {
|
|
80641
80663
|
output2 === void 0 ? this.liveOutput.delete(id2) : this.liveOutput.set(id2, output2.slice(-8e3));
|
|
@@ -81857,10 +81879,10 @@ function isInvalidCursorError(error62) {
|
|
|
81857
81879
|
return !(error62 instanceof SessionRuntimeError) || error62.code !== "host/rejected" && error62.code !== "remote/request-failed" ? !1 : error62.details?.hostCode === -32602;
|
|
81858
81880
|
}
|
|
81859
81881
|
var ChThreadHistory = class extends ChThreadView {
|
|
81860
|
-
constructor(host,
|
|
81882
|
+
constructor(host, thread3, harnessId, onProjection, origin = RENDER_ORIGIN, projectInput, projectImage, options) {
|
|
81861
81883
|
let pagination = { cursor: null };
|
|
81862
81884
|
super(
|
|
81863
|
-
{ ...
|
|
81885
|
+
{ ...thread3, turns: [] },
|
|
81864
81886
|
harnessId,
|
|
81865
81887
|
onProjection,
|
|
81866
81888
|
origin,
|
|
@@ -81875,7 +81897,7 @@ var ChThreadHistory = class extends ChThreadView {
|
|
|
81875
81897
|
}
|
|
81876
81898
|
);
|
|
81877
81899
|
this.host = host;
|
|
81878
|
-
this.pagination = pagination, this.hasProjectInput = projectInput !== void 0, this.canEditQueueItem = options?.canEditQueueItem, this.hostThreadId = options?.hostThreadId ??
|
|
81900
|
+
this.pagination = pagination, this.hasProjectInput = projectInput !== void 0, this.canEditQueueItem = options?.canEditQueueItem, this.hostThreadId = options?.hostThreadId ?? thread3.id, this.overrideThreadIdentity = options?.hostThreadId !== void 0, this.viewId = thread3.id, this.viewCwd = thread3.cwd, this.commands = new ChCommandPresentation(this.log);
|
|
81879
81901
|
}
|
|
81880
81902
|
host;
|
|
81881
81903
|
loaded = !1;
|
|
@@ -81925,11 +81947,11 @@ var ChThreadHistory = class extends ChThreadView {
|
|
|
81925
81947
|
}
|
|
81926
81948
|
return walkFrom(null);
|
|
81927
81949
|
}
|
|
81928
|
-
viewThread(
|
|
81929
|
-
if (!this.overrideThreadIdentity) return
|
|
81930
|
-
if (
|
|
81950
|
+
viewThread(thread3) {
|
|
81951
|
+
if (!this.overrideThreadIdentity) return thread3;
|
|
81952
|
+
if (thread3.id !== this.hostThreadId)
|
|
81931
81953
|
throw new SessionRuntimeError("remote/read-failed", "Remote identity mismatch");
|
|
81932
|
-
return { ...
|
|
81954
|
+
return { ...thread3, id: this.viewId, cwd: this.viewCwd };
|
|
81933
81955
|
}
|
|
81934
81956
|
async page(cursor) {
|
|
81935
81957
|
let result = await this.host.request("thread/turns/list", {
|
|
@@ -81978,10 +82000,10 @@ var ChThreadHistory = class extends ChThreadView {
|
|
|
81978
82000
|
let snapshot = this.host.realtime ? await this.snapshot(this.host.realtime) : void 0, { thread: rawThread } = snapshot ? { thread: snapshot.thread } : await this.host.request("thread/read", {
|
|
81979
82001
|
threadId: this.hostThreadId,
|
|
81980
82002
|
includeTurns: !1
|
|
81981
|
-
}),
|
|
82003
|
+
}), thread3 = this.viewThread(rawThread);
|
|
81982
82004
|
if (this.ensureCurrent(), this.ownerSnapshot = snapshot, snapshot) {
|
|
81983
82005
|
this.log.setProjection(WEB_HANDOFF_PROJECTION, snapshot.handoff ?? null);
|
|
81984
|
-
let readOnly =
|
|
82006
|
+
let readOnly = thread3.canAcceptDirectInput === !1, allowsAttachments = !readOnly && !(thread3.parentThreadId ?? this.thread.parentThreadId), projectedQueue = this.queueProjection.project(snapshot.queue?.items ?? [], {
|
|
81985
82007
|
...this.hasProjectInput ? { projectInput: (content) => this.projectInput(content) } : {},
|
|
81986
82008
|
...this.canEditQueueItem ? { canEdit: this.canEditQueueItem } : {},
|
|
81987
82009
|
allowsAttachments,
|
|
@@ -81995,8 +82017,8 @@ var ChThreadHistory = class extends ChThreadView {
|
|
|
81995
82017
|
...this.canEditQueueItem ? { editable: projectedQueue.editable } : {}
|
|
81996
82018
|
});
|
|
81997
82019
|
}
|
|
81998
|
-
if (!snapshot && !force && this.loaded && Date.now() - this.lastHeadReadAt < 6e4 &&
|
|
81999
|
-
Object.assign(this.thread, { ...
|
|
82020
|
+
if (!snapshot && !force && this.loaded && Date.now() - this.lastHeadReadAt < 6e4 && thread3.updatedAt === this.thread.updatedAt && thread3.status.type !== "active" && this.thread.status.type !== "active") {
|
|
82021
|
+
Object.assign(this.thread, { ...thread3, turns: this.thread.turns }), this.log.setProjection("title", threadListTitle(thread3)), this.log.setProjection("codexhostImportSource", thread3.codexhostImportSource ?? null), this.commands.update(void 0, this.thread.turns);
|
|
82000
82022
|
return;
|
|
82001
82023
|
}
|
|
82002
82024
|
let recent = snapshot ? snapshot.turnsPage : await this.page(null);
|
|
@@ -82017,7 +82039,7 @@ var ChThreadHistory = class extends ChThreadView {
|
|
|
82017
82039
|
"CH history was rewritten. Reload this page to reopen its current history."
|
|
82018
82040
|
);
|
|
82019
82041
|
if (!this.loaded)
|
|
82020
|
-
this.pagination.cursor = recent.nextCursor, this.update({ ...
|
|
82042
|
+
this.pagination.cursor = recent.nextCursor, this.update({ ...thread3, turns: descending.reverse() }, snapshot?.activeTurnId), this.loaded = !0;
|
|
82021
82043
|
else {
|
|
82022
82044
|
newestKnown || (this.pagination.cursor = recent.nextCursor);
|
|
82023
82045
|
let newTurns = newestKnown ? descending.slice(
|
|
@@ -82026,7 +82048,7 @@ var ChThreadHistory = class extends ChThreadView {
|
|
|
82026
82048
|
) : descending, incoming = new Map(descending.map((turn) => [turn.id, turn])), known = new Set(this.thread.turns.map((turn) => turn.id));
|
|
82027
82049
|
this.update(
|
|
82028
82050
|
{
|
|
82029
|
-
...
|
|
82051
|
+
...thread3,
|
|
82030
82052
|
turns: [
|
|
82031
82053
|
...this.thread.turns.map((turn) => incoming.get(turn.id) ?? turn),
|
|
82032
82054
|
...newTurns.reverse().filter((turn) => !known.has(turn.id))
|
|
@@ -82704,13 +82726,13 @@ var PeerThreadSource = class {
|
|
|
82704
82726
|
let epoch = this.host.manifestEpoch();
|
|
82705
82727
|
this.pendingCommands.add(threadId);
|
|
82706
82728
|
try {
|
|
82707
|
-
let { thread:
|
|
82729
|
+
let { thread: thread3 } = await this.host.request("thread/read", {
|
|
82708
82730
|
threadId,
|
|
82709
82731
|
includeTurns: !1
|
|
82710
82732
|
});
|
|
82711
|
-
if (
|
|
82733
|
+
if (thread3.id !== threadId || thread3.parentThreadId || thread3.canAcceptDirectInput === !1)
|
|
82712
82734
|
throw new SessionRuntimeError("command/unavailable", "Commands require an editable remote Thread.");
|
|
82713
|
-
if (
|
|
82735
|
+
if (thread3.status.type === "active") throw busy();
|
|
82714
82736
|
if (requireDirectCommand(await this.inspectThreadCommands(threadId), params.data.commandId), this.host.manifestEpoch() !== epoch)
|
|
82715
82737
|
throw new SessionRuntimeError("remote/connection-changed", "Remote peer changed before dispatch.");
|
|
82716
82738
|
if (this.knownArchived.get(threadId)?.archived)
|
|
@@ -102459,8 +102481,8 @@ var RemoteProjectDraft = class {
|
|
|
102459
102481
|
|
|
102460
102482
|
// packages/web-server/src/remote-approval.ts
|
|
102461
102483
|
var text2 = (value) => typeof value == "string" && value.trim() ? value : void 0;
|
|
102462
|
-
function remoteApprovalPresentation(request3,
|
|
102463
|
-
let p = request3.params, items = (Array.isArray(
|
|
102484
|
+
function remoteApprovalPresentation(request3, thread3) {
|
|
102485
|
+
let p = request3.params, items = (Array.isArray(thread3?.turns) ? thread3.turns : []).flatMap(
|
|
102464
102486
|
(turn) => Array.isArray(turn?.items) ? turn.items : []
|
|
102465
102487
|
), item = typeof p.itemId == "string" ? items.find((value) => value?.id === p.itemId) : void 0, changes = p.changes ?? item?.changes, command = text2(p.command) ?? text2(item?.command) ?? (Array.isArray(p.command) && p.command.every((v) => typeof v == "string") ? p.command.map((v) => JSON.stringify(v)).join(" ") : void 0), paths2 = [
|
|
102466
102488
|
text2(p.grantRoot),
|
|
@@ -102733,11 +102755,11 @@ async function tryGenerateThreadTitle(host, row, prompt, external, isCurrent) {
|
|
|
102733
102755
|
let title = generated ?? (external ? firstPromptTitle(input3) : null);
|
|
102734
102756
|
if (!title || !isCurrent()) return !1;
|
|
102735
102757
|
try {
|
|
102736
|
-
let { thread:
|
|
102758
|
+
let { thread: thread3 } = await host.request("thread/read", {
|
|
102737
102759
|
threadId: row.id,
|
|
102738
102760
|
includeTurns: !1
|
|
102739
102761
|
});
|
|
102740
|
-
return !isCurrent() || (
|
|
102762
|
+
return !isCurrent() || (thread3.name ?? "") !== expectedName ? !1 : (await host.request("thread/name/set", {
|
|
102741
102763
|
threadId: row.id,
|
|
102742
102764
|
name: title,
|
|
102743
102765
|
...external ? { [THREAD_NAME_AUTO_SOURCE_PARAM]: generated === null ? "fallback" : "generated" } : {}
|
|
@@ -104383,9 +104405,9 @@ var RemoteSessions = class {
|
|
|
104383
104405
|
"remote/outcome-unknown",
|
|
104384
104406
|
"Remote Thread creation was not confirmed. Refresh the project before retrying."
|
|
104385
104407
|
);
|
|
104386
|
-
let
|
|
104408
|
+
let thread3 = result2.data.thread, identity2 = { hostId: host.hostId, threadId: thread3.id }, id2 = remoteSessionId(identity2.hostId, identity2.threadId), entry = this.entries.get(id2) ?? {
|
|
104387
104409
|
identity: identity2,
|
|
104388
|
-
row: { ...
|
|
104410
|
+
row: { ...thread3, turns: [] },
|
|
104389
104411
|
online: !0,
|
|
104390
104412
|
configurationRevision: 0
|
|
104391
104413
|
};
|
|
@@ -104401,7 +104423,7 @@ var RemoteSessions = class {
|
|
|
104401
104423
|
try {
|
|
104402
104424
|
if (this.syncGroups(), this.events.emit("api-session/added", this.summary(id2, entry)), this.events.emit("codexhost/session-bound", draft.id, id2), this.events.emit("api-session/removed", draft.id), usePeerAttachments && peerPromptContent !== void 0)
|
|
104403
104425
|
await this.attachments.prompt(this.peerEndpoint(host.hostId), {
|
|
104404
|
-
threadId:
|
|
104426
|
+
threadId: thread3.id,
|
|
104405
104427
|
...draftUploadScope !== void 0 ? { scope: draftUploadScope } : {},
|
|
104406
104428
|
...peerPromptRequestId !== void 0 ? { requestId: peerPromptRequestId } : {},
|
|
104407
104429
|
...peerPromptMode !== void 0 ? { mode: peerPromptMode } : {},
|
|
@@ -104409,7 +104431,7 @@ var RemoteSessions = class {
|
|
|
104409
104431
|
}), draftUploadScope !== void 0 && entry.pendingUploadScope === draftUploadScope && delete entry.pendingUploadScope;
|
|
104410
104432
|
else if (legacyPrompt !== void 0) {
|
|
104411
104433
|
let text4 = this.translatePeerOutboundText(host.hostId, legacyPrompt.text);
|
|
104412
|
-
await this.invoke({ ...legacyPrompt, text: text4, threadId:
|
|
104434
|
+
await this.invoke({ ...legacyPrompt, text: text4, threadId: thread3.id });
|
|
104413
104435
|
}
|
|
104414
104436
|
} finally {
|
|
104415
104437
|
this.pendingFirstTurns.delete(id2);
|
|
@@ -104419,7 +104441,7 @@ var RemoteSessions = class {
|
|
|
104419
104441
|
let titlePrompt = usePeerAttachments && peerPromptContent !== void 0 ? peerPromptContent.filter(
|
|
104420
104442
|
(part) => part.type === "text"
|
|
104421
104443
|
).map((part) => part.text).join(`
|
|
104422
|
-
`) : legacyPrompt?.text ?? "", external = operation.kind === "startSelected" && operation.harnessId !== "codex" ||
|
|
104444
|
+
`) : legacyPrompt?.text ?? "", external = operation.kind === "startSelected" && operation.harnessId !== "codex" || thread3.modelProvider === "codexhost";
|
|
104423
104445
|
this.titleRequests.add(id2), tryGenerateThreadTitle(
|
|
104424
104446
|
peerSource.host,
|
|
104425
104447
|
entry.row,
|
|
@@ -138935,6 +138957,8 @@ var MAX_TABS = 12, DETACHED_TAB_MS = 5 * 6e4, IDLE_BROWSER_MS = 6e4, SWEEP_MS =
|
|
|
138935
138957
|
alive = /* @__PURE__ */ new WeakSet();
|
|
138936
138958
|
quality;
|
|
138937
138959
|
context;
|
|
138960
|
+
/** Ordinary Chrome user agent learned by the last launch, so the next one starts with it. */
|
|
138961
|
+
userAgent;
|
|
138938
138962
|
idleSince = Date.now();
|
|
138939
138963
|
sweeper;
|
|
138940
138964
|
closed = !1;
|
|
@@ -138981,8 +139005,9 @@ Connection: close\r
|
|
|
138981
139005
|
if (this.closed) return Promise.reject(new Error("The Web server is stopping."));
|
|
138982
139006
|
let pending = this.context ??= launch(
|
|
138983
139007
|
this.options.profileDirectory,
|
|
138984
|
-
this.quality.deviceScale
|
|
138985
|
-
|
|
139008
|
+
this.quality.deviceScale,
|
|
139009
|
+
this.userAgent
|
|
139010
|
+
).then(({ context, userAgent }) => (this.userAgent = userAgent, context.on("page", (page) => {
|
|
138986
139011
|
this.popup(page);
|
|
138987
139012
|
}), context.on("close", () => {
|
|
138988
139013
|
this.context === pending && (this.context = void 0);
|
|
@@ -139025,26 +139050,38 @@ Connection: close\r
|
|
|
139025
139050
|
});
|
|
139026
139051
|
}
|
|
139027
139052
|
};
|
|
139028
|
-
async function launch(profileDirectory, deviceScale) {
|
|
139053
|
+
async function launch(profileDirectory, deviceScale, knownUserAgent) {
|
|
139029
139054
|
let executable = process.env.CODEXHOST_BROWSER_EXECUTABLE, candidates = executable === void 0 || executable === "" ? [{ channel: "chrome" }, { channel: "msedge" }, {}] : [{ executablePath: executable }], failure3;
|
|
139030
|
-
for (let candidate of candidates)
|
|
139055
|
+
for (let candidate of candidates) {
|
|
139056
|
+
let open13 = (userAgent) => chromium.launchPersistentContext(profileDirectory, {
|
|
139057
|
+
...candidate,
|
|
139058
|
+
headless: !0,
|
|
139059
|
+
viewport: null,
|
|
139060
|
+
acceptDownloads: !1,
|
|
139061
|
+
...userAgent === void 0 ? {} : { userAgent },
|
|
139062
|
+
args: [
|
|
139063
|
+
`--force-device-scale-factor=${String(deviceScale)}`,
|
|
139064
|
+
"--disable-blink-features=AutomationControlled"
|
|
139065
|
+
]
|
|
139066
|
+
});
|
|
139031
139067
|
try {
|
|
139032
|
-
let context = await
|
|
139033
|
-
|
|
139034
|
-
headless: !0,
|
|
139035
|
-
viewport: null,
|
|
139036
|
-
acceptDownloads: !1,
|
|
139037
|
-
args: [`--force-device-scale-factor=${String(deviceScale)}`]
|
|
139038
|
-
});
|
|
139039
|
-
return await Promise.all(context.pages().map((page) => page.close())), context;
|
|
139068
|
+
let context = await open13(knownUserAgent), userAgent = await ordinaryUserAgent(context);
|
|
139069
|
+
return userAgent !== knownUserAgent && (await context.close(), context = await open13(userAgent)), await Promise.all(context.pages().map((page) => page.close())), { context, userAgent };
|
|
139040
139070
|
} catch (error62) {
|
|
139041
139071
|
failure3 = error62;
|
|
139042
139072
|
}
|
|
139073
|
+
}
|
|
139043
139074
|
throw new Error(
|
|
139044
139075
|
`No usable browser on the CodexHost machine: install Chrome or Edge, or set CODEXHOST_BROWSER_EXECUTABLE. (${failure3 instanceof Error ? failure3.message.split(`
|
|
139045
139076
|
`)[0] ?? "" : String(failure3)})`
|
|
139046
139077
|
);
|
|
139047
139078
|
}
|
|
139079
|
+
async function ordinaryUserAgent(context) {
|
|
139080
|
+
let cdp = await context.browser()?.newBrowserCDPSession();
|
|
139081
|
+
if (cdp === void 0) return;
|
|
139082
|
+
let { userAgent } = await cdp.send("Browser.getVersion");
|
|
139083
|
+
return await cdp.detach(), userAgent.replace("HeadlessChrome/", "Chrome/");
|
|
139084
|
+
}
|
|
139048
139085
|
|
|
139049
139086
|
// packages/web-server/src/misc.ts
|
|
139050
139087
|
import { existsSync as existsSync11, mkdirSync as mkdirSync6, readdirSync as readdirSync3, statSync as statSync7 } from "node:fs";
|
|
@@ -140336,6 +140373,102 @@ var Workspaces = class {
|
|
|
140336
140373
|
}
|
|
140337
140374
|
};
|
|
140338
140375
|
|
|
140376
|
+
// packages/web-server/src/ch-native-goal.ts
|
|
140377
|
+
var goalUsage = "/goal [<objective> | edit <objective> | pause | resume | clear]", goalCommand = {
|
|
140378
|
+
definitionId: "@deepseek-ai/dsh-command-goal",
|
|
140379
|
+
name: "goal",
|
|
140380
|
+
description: "View or manage this thread's goal",
|
|
140381
|
+
input: { hint: goalUsage.slice(6) }
|
|
140382
|
+
};
|
|
140383
|
+
function parseGoalArguments(text4) {
|
|
140384
|
+
if (!text4) return { action: "get" };
|
|
140385
|
+
let [, verb, rest] = /^(\S+)(?:\s+([\s\S]*))?$/u.exec(text4) ?? [], action = verb?.toLowerCase(), value = rest?.trim() ?? "";
|
|
140386
|
+
switch (action) {
|
|
140387
|
+
case "pause":
|
|
140388
|
+
case "resume":
|
|
140389
|
+
case "clear":
|
|
140390
|
+
if (!value) return { action };
|
|
140391
|
+
break;
|
|
140392
|
+
case "edit":
|
|
140393
|
+
if (value) return { action: "edit", objective: value };
|
|
140394
|
+
throw new SessionRuntimeError(
|
|
140395
|
+
"goal/invalid-arguments",
|
|
140396
|
+
"Provide a new objective: /goal edit <objective>"
|
|
140397
|
+
);
|
|
140398
|
+
default:
|
|
140399
|
+
return { action: "create", objective: text4 };
|
|
140400
|
+
}
|
|
140401
|
+
throw new SessionRuntimeError("goal/invalid-arguments", `Usage: ${goalUsage}`);
|
|
140402
|
+
}
|
|
140403
|
+
var statusLabels = {
|
|
140404
|
+
active: "active",
|
|
140405
|
+
paused: "paused",
|
|
140406
|
+
blocked: "stalled",
|
|
140407
|
+
usageLimited: "usage limited",
|
|
140408
|
+
budgetLimited: "limited by budget",
|
|
140409
|
+
complete: "complete"
|
|
140410
|
+
};
|
|
140411
|
+
function goalReceipt(goal, cleared) {
|
|
140412
|
+
if (!goal)
|
|
140413
|
+
return cleared ? "Goal cleared." : "No goal set for this thread. Run /goal <objective> to create one.";
|
|
140414
|
+
let budget = goal.tokenBudget == null ? "" : ` / ${goal.tokenBudget}`;
|
|
140415
|
+
return `Goal ${statusLabels[goal.status]}
|
|
140416
|
+
${goal.objective}
|
|
140417
|
+
Tokens: ${goal.tokensUsed}${budget} \xB7 Time: ${goal.timeUsedSeconds}s`;
|
|
140418
|
+
}
|
|
140419
|
+
var ChNativeGoals = class {
|
|
140420
|
+
constructor(host) {
|
|
140421
|
+
this.host = host;
|
|
140422
|
+
}
|
|
140423
|
+
host;
|
|
140424
|
+
states = /* @__PURE__ */ new WeakMap();
|
|
140425
|
+
state(view) {
|
|
140426
|
+
let state2 = this.states.get(view);
|
|
140427
|
+
return state2 || (state2 = { revision: 0, sequence: 0, loading: !1, dirty: !1 }, this.states.set(view, state2)), state2;
|
|
140428
|
+
}
|
|
140429
|
+
beginRead(view) {
|
|
140430
|
+
let state2 = this.state(view);
|
|
140431
|
+
return { revision: state2.revision, sequence: ++state2.sequence };
|
|
140432
|
+
}
|
|
140433
|
+
currentRead(view, read2) {
|
|
140434
|
+
let state2 = this.state(view);
|
|
140435
|
+
return read2.revision === state2.revision && read2.sequence === state2.sequence;
|
|
140436
|
+
}
|
|
140437
|
+
confirm(view, goal, read2) {
|
|
140438
|
+
read2 && !this.currentRead(view, read2) || (read2 || (this.state(view).revision += 1), view.log.setProjection("codexGoal", { goal, error: null }));
|
|
140439
|
+
}
|
|
140440
|
+
async refresh(view, current) {
|
|
140441
|
+
let state2 = this.state(view);
|
|
140442
|
+
if (state2.loading) {
|
|
140443
|
+
state2.dirty = !0;
|
|
140444
|
+
return;
|
|
140445
|
+
}
|
|
140446
|
+
state2.loading = !0, state2.dirty = !1;
|
|
140447
|
+
let read2 = this.beginRead(view);
|
|
140448
|
+
try {
|
|
140449
|
+
let { goal } = nativeCodexGoalResultSchema.parse(
|
|
140450
|
+
await this.host.request(NATIVE_CODEX_GOAL_METHOD, {
|
|
140451
|
+
threadId: view.thread.id,
|
|
140452
|
+
action: "get"
|
|
140453
|
+
})
|
|
140454
|
+
);
|
|
140455
|
+
if (goal && goal.threadId !== view.thread.id)
|
|
140456
|
+
throw new Error("Goal belongs to another Thread");
|
|
140457
|
+
current() && this.currentRead(view, read2) && view.log.setProjection("codexGoal", { goal, error: null });
|
|
140458
|
+
} catch (error62) {
|
|
140459
|
+
if (current() && this.currentRead(view, read2)) {
|
|
140460
|
+
let previous = view.log.projections.codexGoal;
|
|
140461
|
+
previous?.goal && view.log.setProjection("codexGoal", {
|
|
140462
|
+
goal: previous.goal,
|
|
140463
|
+
error: error62 instanceof Error ? error62.message : "Could not refresh the native goal"
|
|
140464
|
+
});
|
|
140465
|
+
}
|
|
140466
|
+
} finally {
|
|
140467
|
+
state2.loading = !1, state2.dirty && current() && this.refresh(view, current);
|
|
140468
|
+
}
|
|
140469
|
+
}
|
|
140470
|
+
};
|
|
140471
|
+
|
|
140339
140472
|
// packages/web-server/src/skills.ts
|
|
140340
140473
|
var WebSkills = class {
|
|
140341
140474
|
constructor(host, events2, resolve26) {
|
|
@@ -141140,7 +141273,7 @@ var ChSessions = class {
|
|
|
141140
141273
|
this.files = files2;
|
|
141141
141274
|
this.preferences = preferences2;
|
|
141142
141275
|
this.openFile = openFile;
|
|
141143
|
-
this.catalog = new ChHarnessCatalog(host, events2, displayEntries2, preferences2, harnesses), this.attachments = images2 ? new ChAttachments(images2, files2) : void 0, this.fileInputs = files2 && images2 ? new ChFileInputs(files2, images2, async (id2) => {
|
|
141276
|
+
this.nativeGoals = new ChNativeGoals(host), this.catalog = new ChHarnessCatalog(host, events2, displayEntries2, preferences2, harnesses), this.attachments = images2 ? new ChAttachments(images2, files2) : void 0, this.fileInputs = files2 && images2 ? new ChFileInputs(files2, images2, async (id2) => {
|
|
141144
141277
|
if (id2 = this.id(id2), this.closed) throw new SessionRuntimeError("host/offline", "The Web connection is closed.");
|
|
141145
141278
|
if (this.drafts.has(id2)) return id2;
|
|
141146
141279
|
await this.owner(id2), this.rows.has(id2) || await this.refresh();
|
|
@@ -141223,6 +141356,7 @@ var ChSessions = class {
|
|
|
141223
141356
|
handoffs = /* @__PURE__ */ new Map();
|
|
141224
141357
|
/** Loaded rows accumulate across partial official pages; drafts are not Host Threads. */
|
|
141225
141358
|
threads = new WebThreadStates();
|
|
141359
|
+
nativeGoals;
|
|
141226
141360
|
drafts = /* @__PURE__ */ new Map();
|
|
141227
141361
|
controls = /* @__PURE__ */ new Set();
|
|
141228
141362
|
refreshing;
|
|
@@ -141361,8 +141495,8 @@ var ChSessions = class {
|
|
|
141361
141495
|
if (await this.tree.supplement(rows, async (id2) => {
|
|
141362
141496
|
let scanned = indexed.get(id2);
|
|
141363
141497
|
if (scanned && ownership.has(id2)) return scanned;
|
|
141364
|
-
let { thread:
|
|
141365
|
-
return ownership.set(id2, harnessId),
|
|
141498
|
+
let { thread: thread3, harnessId } = await this.readThread(id2);
|
|
141499
|
+
return ownership.set(id2, harnessId), thread3.archived === !0 && archived.add(id2), thread3;
|
|
141366
141500
|
}), this.closed || !this.workspaces.get(workspaceId)) return;
|
|
141367
141501
|
for (let [id2, row] of members2) {
|
|
141368
141502
|
if (deletedIds.has(id2)) {
|
|
@@ -141417,13 +141551,13 @@ var ChSessions = class {
|
|
|
141417
141551
|
for (let id2 of found.keys()) snapshotArchives.has(id2) || archivedIds.delete(id2);
|
|
141418
141552
|
let ownership = catalogOwnership(snapshot, found), pageSectionAdditions = cursor === void 0 ? void 0 : /* @__PURE__ */ new Set(), threadSections = sections?.map(({ id: id2, name: name2, threads }) => {
|
|
141419
141553
|
let threadIds = [];
|
|
141420
|
-
for (let
|
|
141421
|
-
if (!(typeof
|
|
141422
|
-
if (
|
|
141423
|
-
let row =
|
|
141424
|
-
found.set(
|
|
141554
|
+
for (let thread3 of threads)
|
|
141555
|
+
if (!(typeof thread3.id != "string" || thread3.archived === !0)) {
|
|
141556
|
+
if (thread3.archived === !1 && !snapshotArchives.has(thread3.id) && archivedIds.delete(thread3.id), !found.has(thread3.id)) {
|
|
141557
|
+
let row = thread3;
|
|
141558
|
+
found.set(thread3.id, row), ownership.set(thread3.id, "codex"), (cursor === void 0 || !this.publishedCatalog?.has(row.id)) && snapshot.threads.push(row);
|
|
141425
141559
|
}
|
|
141426
|
-
ownership.get(
|
|
141560
|
+
ownership.get(thread3.id) === "codex" && (threadIds.push(thread3.id), this.publishedCatalog?.has(thread3.id) || pageSectionAdditions?.add(thread3.id));
|
|
141427
141561
|
}
|
|
141428
141562
|
return { id: id2, name: name2, threadIds };
|
|
141429
141563
|
});
|
|
@@ -141440,8 +141574,8 @@ var ChSessions = class {
|
|
|
141440
141574
|
found.has(id2) || !harnessId || deletedIds.has(id2) || cursor === void 0 && harnessId !== "codex" && known.has(id2) && !archiveChanges.has(id2) && (includeArchived || !archivedIds.has(id2)) || (rows.set(id2, row), ownership.set(id2, harnessId));
|
|
141441
141575
|
}
|
|
141442
141576
|
await this.tree.supplement(rows, async (id2) => {
|
|
141443
|
-
let { thread:
|
|
141444
|
-
return ownership.set(id2, harnessId),
|
|
141577
|
+
let { thread: thread3, harnessId } = await this.readThread(id2);
|
|
141578
|
+
return ownership.set(id2, harnessId), thread3.archived === !0 && archivedIds.add(id2), thread3;
|
|
141445
141579
|
});
|
|
141446
141580
|
for (let id2 of deletedIds)
|
|
141447
141581
|
rows.delete(id2), ownership.delete(id2), archivedIds.delete(id2);
|
|
@@ -141664,7 +141798,7 @@ var ChSessions = class {
|
|
|
141664
141798
|
let name2 = await this.catalog.name(harnessId);
|
|
141665
141799
|
if (this.threads.view(id2) !== view)
|
|
141666
141800
|
throw new SessionRuntimeError("host/resync", "Host snapshot was superseded by a new generation");
|
|
141667
|
-
return view.log.setProjection("harnessIdentity", { id: harnessId, name: name2 }), this.loadControls(view, harnessId, force, configurationRevision), this.loadUsage(view, force), this.closed || this.events.emit("api-session/status", id2, view.thread.status.type === "active"), view;
|
|
141801
|
+
return view.log.setProjection("harnessIdentity", { id: harnessId, name: name2 }), this.currentGoalView(view) ? this.nativeGoals.refresh(view, () => this.currentGoalView(view)) : view.log.setProjection("codexGoal", null), this.loadControls(view, harnessId, force, configurationRevision), this.loadUsage(view, force), this.closed || this.events.emit("api-session/status", id2, view.thread.status.type === "active"), view;
|
|
141668
141802
|
}
|
|
141669
141803
|
loadUsage(view, force) {
|
|
141670
141804
|
let id2 = view.thread.id, active3 = this.threads.get(id2)?.usage;
|
|
@@ -141891,10 +142025,10 @@ var ChSessions = class {
|
|
|
141891
142025
|
);
|
|
141892
142026
|
draft.started = { thread: result.thread, harnessId: owner.harnessId };
|
|
141893
142027
|
}
|
|
141894
|
-
let { thread:
|
|
141895
|
-
if (draft.projectId &&
|
|
142028
|
+
let { thread: thread3, harnessId } = draft.started;
|
|
142029
|
+
if (draft.projectId && thread3.projectId !== draft.projectId) {
|
|
141896
142030
|
let updated = await this.host.request("thread/metadata/update", {
|
|
141897
|
-
threadId:
|
|
142031
|
+
threadId: thread3.id,
|
|
141898
142032
|
projectId: draft.projectId
|
|
141899
142033
|
});
|
|
141900
142034
|
if (updated.thread.projectId !== draft.projectId)
|
|
@@ -141902,9 +142036,9 @@ var ChSessions = class {
|
|
|
141902
142036
|
"workspace/assignment-unconfirmed",
|
|
141903
142037
|
"Codex did not confirm the conversation's project."
|
|
141904
142038
|
);
|
|
141905
|
-
|
|
142039
|
+
thread3.projectId = updated.thread.projectId, this.refreshingProjectAssignments?.set(thread3.id, draft.projectId);
|
|
141906
142040
|
}
|
|
141907
|
-
return draft.canonicalId =
|
|
142041
|
+
return draft.canonicalId = thread3.id, this.files?.bind(draft.id, thread3.id), this.rows.set(thread3.id, thread3), this.threads.setHarness(thread3.id, harnessId), this.workspaces.detachSession(draft.id), this.workspaces.usesNativeProjects ? this.workspaces.updateNativeProjectMember(thread3.id, draft.projectId) : draft.cwd ? (this.workspaces.selectReferenceWorkspace(draft.cwd), this.workspaces.attachReferencedSession(thread3.id, thread3.cwd), this.workspaces.addDraftReference(thread3.id, draft.cwd)) : this.workspaces.addDraftReference(thread3.id, void 0), this.events.emit("api-session/added", await this.summary(thread3)), this.publishedCatalog?.set(thread3.id, this.catalogKey(thread3)), this.events.emit("codexhost/session-bound", draft.id, thread3.id), this.events.emit("api-session/removed", draft.id), thread3.id;
|
|
141908
142042
|
}
|
|
141909
142043
|
/**
|
|
141910
142044
|
* Working directory of one Host-confirmed local Thread.
|
|
@@ -141933,8 +142067,8 @@ var ChSessions = class {
|
|
|
141933
142067
|
let id2 = this.id(sessionId);
|
|
141934
142068
|
if (!this.drafts.has(id2))
|
|
141935
142069
|
try {
|
|
141936
|
-
let { thread:
|
|
141937
|
-
return this.closed || signal?.aborted ? void 0 : (this.rows.set(
|
|
142070
|
+
let { thread: thread3, harnessId } = await this.readThread(id2);
|
|
142071
|
+
return this.closed || signal?.aborted ? void 0 : (this.rows.set(thread3.id, thread3), this.threads.setHarness(thread3.id, harnessId), thread3.cwd);
|
|
141938
142072
|
} catch {
|
|
141939
142073
|
return;
|
|
141940
142074
|
}
|
|
@@ -142044,8 +142178,8 @@ var ChSessions = class {
|
|
|
142044
142178
|
"Send the first message before archiving this Thread."
|
|
142045
142179
|
);
|
|
142046
142180
|
if (!this.threads.hasHarness(id2)) {
|
|
142047
|
-
let { thread:
|
|
142048
|
-
this.rows.set(id2,
|
|
142181
|
+
let { thread: thread3, harnessId } = await this.readThread(id2);
|
|
142182
|
+
this.rows.set(id2, thread3), this.threads.setHarness(id2, harnessId);
|
|
142049
142183
|
}
|
|
142050
142184
|
let owner = await this.owner(id2);
|
|
142051
142185
|
if (this.archiveOperations.get(id2) !== operation) return;
|
|
@@ -142068,16 +142202,16 @@ var ChSessions = class {
|
|
|
142068
142202
|
}
|
|
142069
142203
|
}
|
|
142070
142204
|
async readThread(id2) {
|
|
142071
|
-
let owner = await this.owner(id2), { thread:
|
|
142205
|
+
let owner = await this.owner(id2), { thread: thread3 } = await this.host.request(
|
|
142072
142206
|
"thread/read",
|
|
142073
142207
|
{
|
|
142074
142208
|
threadId: id2,
|
|
142075
142209
|
includeTurns: !1
|
|
142076
142210
|
}
|
|
142077
142211
|
);
|
|
142078
|
-
if (
|
|
142212
|
+
if (thread3.id !== id2 || owner.owner === "external" && thread3.modelProvider !== "codexhost")
|
|
142079
142213
|
throw new SessionRuntimeError("session/ownership-unconfirmed", "Thread identity was not confirmed.");
|
|
142080
|
-
return { thread:
|
|
142214
|
+
return { thread: thread3, harnessId: owner.harnessId };
|
|
142081
142215
|
}
|
|
142082
142216
|
register(rpc2, streams2) {
|
|
142083
142217
|
this.fileReferences.register(rpc2), this.fileInputs?.register(rpc2), rpc2.register("codexhost/turnDiffs", async (args) => {
|
|
@@ -142159,9 +142293,9 @@ var ChSessions = class {
|
|
|
142159
142293
|
if (id2.startsWith("draft-"))
|
|
142160
142294
|
throw new SessionRuntimeError("session/not-found", "Draft Session is no longer available.");
|
|
142161
142295
|
await Promise.all([this.tree.refresh(), this.refreshPins()]);
|
|
142162
|
-
let { thread:
|
|
142163
|
-
this.rows.set(
|
|
142164
|
-
let direct = /* @__PURE__ */ new Map([[
|
|
142296
|
+
let { thread: thread3, harnessId } = await this.readThread(id2);
|
|
142297
|
+
this.rows.set(thread3.id, thread3), this.threads.setHarness(thread3.id, harnessId);
|
|
142298
|
+
let direct = /* @__PURE__ */ new Map([[thread3.id, thread3]]);
|
|
142165
142299
|
return await this.tree.supplement(direct, async (ancestorId) => {
|
|
142166
142300
|
let ancestor = await this.readThread(ancestorId);
|
|
142167
142301
|
return this.rows.set(ancestorId, ancestor.thread), this.threads.setHarness(ancestorId, ancestor.harnessId), ancestor.thread.archived === !0 && this.updateArchive(ancestorId, !0), ancestor.thread;
|
|
@@ -142328,7 +142462,16 @@ var ChSessions = class {
|
|
|
142328
142462
|
"session/attachment-invalid",
|
|
142329
142463
|
"Shared CH input currently accepts text only."
|
|
142330
142464
|
);
|
|
142331
|
-
let draft = this.drafts.get(request3.sessionId)
|
|
142465
|
+
let draft = this.drafts.get(request3.sessionId);
|
|
142466
|
+
if (nativeCodexGoalInvocation.test(
|
|
142467
|
+
request3.content.filter((part) => part.type === "text").map((part) => part.text ?? "").join(`
|
|
142468
|
+
`).trim()
|
|
142469
|
+
) && await this.goalScope(request3.sessionId) !== "other")
|
|
142470
|
+
throw new SessionRuntimeError(
|
|
142471
|
+
"goal/command-required",
|
|
142472
|
+
"Submit /goal as a command on a local Codex Thread with native goals enabled."
|
|
142473
|
+
);
|
|
142474
|
+
let existingOwner = !draft || draft.canonicalId ? await this.owner(request3.sessionId) : void 0, steerTurnId;
|
|
142332
142475
|
if (request3.mode === "steer") {
|
|
142333
142476
|
let view = existingOwner && await this.view(request3.sessionId, !0), activeTurnId = view ? view.log.projections[WEB_ACTIVE_TURN_PROJECTION] : null;
|
|
142334
142477
|
if (!existingOwner || !view || typeof activeTurnId != "string" || request3.expectedTurnId !== void 0 && request3.expectedTurnId !== activeTurnId)
|
|
@@ -142665,6 +142808,32 @@ var ChSessions = class {
|
|
|
142665
142808
|
);
|
|
142666
142809
|
}, 6e4), this.idleViewTimer.unref();
|
|
142667
142810
|
}
|
|
142811
|
+
currentGoalView(view) {
|
|
142812
|
+
let id2 = view.thread.id, row = this.rows.get(id2) ?? view.thread;
|
|
142813
|
+
return !this.closed && this.hostOnline && this.threads.view(id2) === view && this.threads.harnessId(id2) === "codex" && !this.workspaces.isArchived(id2) && !row.archived && !row.parentThreadId && row.canAcceptDirectInput !== !1 && !view.thread.archived && !view.thread.parentThreadId && view.thread.canAcceptDirectInput !== !1;
|
|
142814
|
+
}
|
|
142815
|
+
async supportsDraftGoals() {
|
|
142816
|
+
return (await this.host.request(
|
|
142817
|
+
"experimentalFeature/list",
|
|
142818
|
+
{}
|
|
142819
|
+
)).data?.some((feature) => feature.name === "goals" && feature.enabled) === !0;
|
|
142820
|
+
}
|
|
142821
|
+
async goalScope(sessionId) {
|
|
142822
|
+
let draft = this.drafts.get(sessionId);
|
|
142823
|
+
if (draft && !draft.canonicalId)
|
|
142824
|
+
return draft.selection.provider !== "codex" ? "other" : this.closed || !this.hostOnline ? "unavailable" : "draft";
|
|
142825
|
+
let id2 = this.id(sessionId);
|
|
142826
|
+
if (!id2 || id2.startsWith("draft-") || id2.startsWith("web-remote:")) return "other";
|
|
142827
|
+
let harness2 = this.threads.harnessId(id2);
|
|
142828
|
+
if (!harness2 && this.hostOnline && !this.closed) {
|
|
142829
|
+
let reply = await this.host.request("codexhost/thread/ownership/list", { threadIds: [id2] }).catch(() => {
|
|
142830
|
+
}), owner = threadOwnershipSchema.safeParse(reply?.threads?.[0]);
|
|
142831
|
+
owner.success && owner.data.threadId === id2 && owner.data.owner === "codex" && (harness2 = "codex");
|
|
142832
|
+
}
|
|
142833
|
+
if (harness2 !== "codex") return "other";
|
|
142834
|
+
let row = this.rows.get(id2) ?? this.threads.view(id2)?.thread;
|
|
142835
|
+
return this.closed || !this.hostOnline || row?.parentThreadId || row?.archived || this.workspaces.isArchived(id2) || row?.canAcceptDirectInput === !1 ? "unavailable" : "local";
|
|
142836
|
+
}
|
|
142668
142837
|
registerCommands(rpc2) {
|
|
142669
142838
|
this.skills.register(rpc2);
|
|
142670
142839
|
let native2 = new ChHarnessCommands(this.host, async (sessionId) => {
|
|
@@ -142674,13 +142843,13 @@ var ChSessions = class {
|
|
|
142674
142843
|
if (this.closed || !this.hostOnline)
|
|
142675
142844
|
throw new SessionRuntimeError("host/offline", "The Host is disconnected.");
|
|
142676
142845
|
await this.owner(id2);
|
|
142677
|
-
let { thread:
|
|
142846
|
+
let { thread: thread3 } = await this.host.request("thread/read", {
|
|
142678
142847
|
threadId: id2,
|
|
142679
142848
|
includeTurns: !1
|
|
142680
142849
|
});
|
|
142681
|
-
if (
|
|
142850
|
+
if (thread3.id !== id2 || thread3.parentThreadId || thread3.canAcceptDirectInput === !1)
|
|
142682
142851
|
throw new SessionRuntimeError("command/unavailable", "Commands require an editable local Thread.");
|
|
142683
|
-
return
|
|
142852
|
+
return thread3;
|
|
142684
142853
|
});
|
|
142685
142854
|
rpc2.register("codexhost/threadCommands", (args) => {
|
|
142686
142855
|
let { sessionId } = requestOf(args), draft = this.drafts.get(sessionId);
|
|
@@ -142697,8 +142866,69 @@ var ChSessions = class {
|
|
|
142697
142866
|
options: [],
|
|
142698
142867
|
defaultOptions: [],
|
|
142699
142868
|
defaultPreset: ""
|
|
142700
|
-
})), rpc2.register("commands/list",
|
|
142701
|
-
let id2 = String(args.agentId ?? "")
|
|
142869
|
+
})), rpc2.register("commands/list", async (args) => {
|
|
142870
|
+
let id2 = String(args.agentId ?? "");
|
|
142871
|
+
try {
|
|
142872
|
+
let scope2 = await this.goalScope(id2);
|
|
142873
|
+
if (scope2 === "draft" && await this.supportsDraftGoals() && await this.goalScope(id2) === "draft")
|
|
142874
|
+
return [permissionCommand, goalCommand];
|
|
142875
|
+
if (scope2 === "local" && nativeCodexGoalResultSchema.safeParse(
|
|
142876
|
+
await this.host.request(NATIVE_CODEX_GOAL_METHOD, {
|
|
142877
|
+
threadId: this.id(id2),
|
|
142878
|
+
action: "get"
|
|
142879
|
+
})
|
|
142880
|
+
).success)
|
|
142881
|
+
return [permissionCommand, goalCommand];
|
|
142882
|
+
} catch {
|
|
142883
|
+
}
|
|
142884
|
+
return [permissionCommand];
|
|
142885
|
+
}), rpc2.register("commands/execute", async (args) => {
|
|
142886
|
+
let id2 = String(args.agentId ?? ""), line = String(args.line ?? "").trim();
|
|
142887
|
+
if (nativeCodexGoalInvocation.test(line)) {
|
|
142888
|
+
let scope2 = await this.goalScope(id2);
|
|
142889
|
+
if (scope2 === "other") return;
|
|
142890
|
+
if (scope2 === "unavailable")
|
|
142891
|
+
throw new SessionRuntimeError("goal/unavailable", "Goals require an editable local Codex Thread.");
|
|
142892
|
+
if (Array.isArray(args.submittedAttachments) && args.submittedAttachments.length)
|
|
142893
|
+
throw new SessionRuntimeError("goal/attachments", "/goal only accepts text.");
|
|
142894
|
+
let operation = parseGoalArguments(line.slice(5).trim()), threadId = this.id(id2);
|
|
142895
|
+
if (scope2 === "draft") {
|
|
142896
|
+
let draft2 = this.drafts.get(id2);
|
|
142897
|
+
if (operation.action !== "create")
|
|
142898
|
+
throw new SessionRuntimeError("goal/objective-required", "Enter an objective: /goal <objective>.");
|
|
142899
|
+
let validated = nativeCodexGoalRequestSchema.safeParse({ threadId: id2, ...operation });
|
|
142900
|
+
if (!validated.success)
|
|
142901
|
+
throw new SessionRuntimeError(
|
|
142902
|
+
"goal/invalid-arguments",
|
|
142903
|
+
validated.error.issues[0]?.message ?? "Invalid goal objective."
|
|
142904
|
+
);
|
|
142905
|
+
if (!await this.supportsDraftGoals())
|
|
142906
|
+
throw new SessionRuntimeError(
|
|
142907
|
+
"goal/unavailable",
|
|
142908
|
+
"Native goals are not enabled in this Codex version."
|
|
142909
|
+
);
|
|
142910
|
+
if (!draft2 || this.drafts.get(id2) !== draft2 || draft2.selection.provider !== "codex" || this.closed || !this.hostOnline || draft2.creating || draft2.started)
|
|
142911
|
+
throw new SessionRuntimeError("session/busy", "Draft selection changed.");
|
|
142912
|
+
threadId = await this.commit(draft2, operation.objective);
|
|
142913
|
+
}
|
|
142914
|
+
let view = await this.view(threadId, !0), read2 = operation.action === "get" ? this.nativeGoals.beginRead(view) : void 0, { goal } = nativeCodexGoalResultSchema.parse(
|
|
142915
|
+
await this.host.request(NATIVE_CODEX_GOAL_METHOD, { threadId, ...operation }).catch((error62) => {
|
|
142916
|
+
throw error62 instanceof SessionRuntimeError && (error62.code === "host/method-unavailable" || "hostCode" in error62.details && error62.details.hostCode === -32601 || /goals feature is disabled|ephemeral thread does not support goals/iu.test(
|
|
142917
|
+
error62.message
|
|
142918
|
+
)) ? new SessionRuntimeError(
|
|
142919
|
+
"goal/unavailable",
|
|
142920
|
+
"This Codex Thread does not support native goals."
|
|
142921
|
+
) : error62;
|
|
142922
|
+
})
|
|
142923
|
+
), commandId = randomUUID23();
|
|
142924
|
+
this.currentGoalView(view) && this.nativeGoals.confirm(view, goal, read2);
|
|
142925
|
+
let visible = operation.action === "get" ? view.log.projections.codexGoal : void 0, text4 = goalReceipt(
|
|
142926
|
+
visible ? visible.goal : goal,
|
|
142927
|
+
operation.action === "clear"
|
|
142928
|
+
), log46 = view?.log;
|
|
142929
|
+
return log46?.append("command/run", { commandId, name: "goal", source: { kind: "user" } }), log46?.append("command/done", { commandId, kind: "success", text: text4 }), { commandId, result: { kind: "success", text: text4 } };
|
|
142930
|
+
}
|
|
142931
|
+
let match = /^\/permission\s+(.+)$/u.exec(line);
|
|
142702
142932
|
if (!match) return;
|
|
142703
142933
|
let modeId = match[1] ?? "", draft = this.drafts.get(id2), harnessId = draft && !draft.canonicalId ? draft.selection.provider : (await this.owner(id2)).harnessId, inspection = await this.catalog.inspect(
|
|
142704
142934
|
harnessId,
|
|
@@ -144709,7 +144939,7 @@ async function snapshotPackagedHost(distribution, data2) {
|
|
|
144709
144939
|
|
|
144710
144940
|
// packages/web-server/src/main.ts
|
|
144711
144941
|
var RELEASE_WEB = !0, DISTRIBUTION_ROOT = resolve25(import.meta.dirname, ".."), PACKED_WEB = join36(DISTRIBUTION_ROOT, "web"), PACKED = existsSync16(join36(PACKED_WEB, "plugins.json")), REPO_ROOT = resolve25(import.meta.dirname, "../../.."), SERVER_VERSION = resolveServerVersion(
|
|
144712
|
-
"0.
|
|
144942
|
+
"0.30.0",
|
|
144713
144943
|
[join36(DISTRIBUTION_ROOT, "package.json"), join36(REPO_ROOT, "package.json")]
|
|
144714
144944
|
);
|
|
144715
144945
|
if (PACKED) {
|