@codexhost/cli-win32-x64 0.29.2 → 0.31.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 +94 -20
- package/app/console-web.js +123 -31
- package/app/desktop-controller.mjs +113 -37
- package/app/host-runtime.mjs +3963 -2280
- package/app/plugins/antigravity/plugin.mjs +94 -20
- package/app/plugins/claude-code/plugin.mjs +105 -28
- package/app/plugins/codebuddy/plugin.mjs +767 -202
- package/app/plugins/codex-usage/plugin.mjs +112 -38
- package/app/plugins/copilot/plugin.mjs +94 -20
- package/app/plugins/cursor-cli/plugin.mjs +94 -20
- package/app/plugins/deepseek-harness/plugin.mjs +94 -20
- package/app/plugins/devin/plugin.mjs +94 -20
- package/app/plugins/grok/plugin.mjs +94 -20
- package/app/plugins/hermes/plugin.mjs +94 -20
- package/app/plugins/kimi-code/plugin.mjs +94 -20
- package/app/plugins/kiro-cli/plugin.mjs +94 -20
- package/app/plugins/omp/plugin.mjs +94 -20
- package/app/plugins/opencode/plugin.mjs +94 -20
- package/app/plugins/pi/plugin.mjs +94 -20
- package/app/plugins/qoder/plugin.mjs +94 -20
- package/app/plugins/qoder-cn/plugin.mjs +94 -20
- package/app/plugins/qwen-code/plugin.mjs +94 -20
- package/app/plugins/workbuddy/plugin.mjs +798 -202
- package/app/plugins/zcode/plugin.mjs +94 -20
- package/app/renderer-extension.js +702 -440
- package/app/web/assets/abnfDiagram-XWFEHMT6-Bqy7uOSy.js +1 -0
- package/app/web/assets/architectureDiagram-CSQXQB3N-6aaP1YoM.js +36 -0
- package/app/web/assets/blockDiagram-BEDRHYPZ-B4QSFXe0.js +140 -0
- package/app/web/assets/bpmnIcons-APHXDYXF-ByGoYv9M.js +1 -0
- package/app/web/assets/c4Diagram-M2UUVUY5-BYE-C8Gq.js +38 -0
- package/app/web/assets/chunk-2Q5K7J3B-CiEM-GTd.js +1 -0
- package/app/web/assets/chunk-3GCGMST5-hzY9BiB1.js +1 -0
- package/app/web/assets/chunk-5VM5RSS4-DYXznY0H.js +15 -0
- package/app/web/assets/chunk-7U7NFRK5-Bzw5MDPr.js +88 -0
- package/app/web/assets/chunk-CNRTWJTD-DMbxMfi3.js +1 -0
- package/app/web/assets/chunk-D5HYT7QG-By0ZVBtD.js +1 -0
- package/app/web/assets/chunk-EBZ3SEQC-Yyu_sMV7.js +2 -0
- package/app/web/assets/chunk-JWPE2WC7-DDzqxIPT.js +1 -0
- package/app/web/assets/chunk-KTR4FSNJ-GlKqhtpl.js +1 -0
- package/app/web/assets/chunk-XXDRQBXY-DNc-CvYu.js +1 -0
- package/app/web/assets/classDiagram-v2-KXABOMEV-4_PFS2N_.js +217 -0
- package/app/web/assets/cose-bilkent-JH36ORCC-BE3foHUY.js +1 -0
- package/app/web/assets/cynefin-EF2NZ3EQ-D2PqrYZ3.js +141 -0
- package/app/web/assets/cynefinDiagram-NJNITYFG-DOObpTbq.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-Znm2jin9.js +4 -0
- package/app/web/assets/diagram-7YQZDPLS-ByZMD-uA.js +41 -0
- package/app/web/assets/diagram-QBROCOUO-BiRShpnN.js +200 -0
- package/app/web/assets/diagram-RJJCUUZO-D9wLVoK2.js +30 -0
- package/app/web/assets/diagram-WERXNKYE-BSbIh-yC.js +24 -0
- package/app/web/assets/diagram-YHHI257C-DMWrHMc8.js +3 -0
- package/app/web/assets/diagram-YR4HJLHV-C4sBAFb1.js +24 -0
- package/app/web/assets/ebnfDiagram-N527522P-BZLloaoQ.js +1 -0
- package/app/web/assets/elk-O5DQBFGD-Da3e5tn5.js +27 -0
- package/app/web/assets/erDiagram-K3K3BIDK-B2lKAIZF.js +99 -0
- package/app/web/assets/flowDiagram-Z6JWZHQI-q2EY_kmB.js +213 -0
- package/app/web/assets/ganttDiagram-3PRQTZWP-BGrNZ20b.js +292 -0
- package/app/web/assets/gitGraphDiagram-VXDFKS5L-DIZNXREy.js +106 -0
- package/app/web/assets/graph-D8UmR1vK.js +1 -0
- package/app/web/assets/grid-E2QIVN74-0cUkPG69.js +1 -0
- package/app/web/assets/{index-aSHN2MIG.css → index-BbmB5VLj.css} +1 -1
- package/app/web/assets/{index-0TnaYwHS.js → index-PN7K-15_.js} +78 -78
- package/app/web/assets/infoDiagram-EZ3ZOAHP-BHhUTQCn.js +2 -0
- package/app/web/assets/ishikawaDiagram-S3EKX5GW-DPOxtl4c.js +70 -0
- package/app/web/assets/journeyDiagram-POQNLL5X-D8RyXckG.js +139 -0
- package/app/web/assets/kanban-definition-BH5XI6FM-COJv3Hyh.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-DYdcDKIt.js +314 -0
- package/app/web/assets/mindmap-definition-WVAN44T4-DnYIM4ja.js +98 -0
- package/app/web/assets/pegDiagram-D4NLKWP3-Ds3GAEJ6.js +1 -0
- package/app/web/assets/pieDiagram-36ENHN4W-BhLUJGEB.js +39 -0
- package/app/web/assets/quadrantDiagram-ZQUDMS73-DwtX-IxK.js +7 -0
- package/app/web/assets/railroadDiagram-JIZHGYPL-D2vmTTnJ.js +1 -0
- package/app/web/assets/render-VIF2ZAQL-DGU1ql-Z.js +2 -0
- package/app/web/assets/requirementDiagram-AXW2TVFA-u3j1sKkI.js +84 -0
- package/app/web/assets/sankeyDiagram-FBCJTAIF-k-An9VHW.js +40 -0
- package/app/web/assets/sequenceDiagram-3LA2ROMG-DUjbYb4R.js +169 -0
- package/app/web/assets/sizeCapture-2Q2CQKSF-DATTL7FZ.js +1 -0
- package/app/web/assets/stateDiagram-v2-ATKHQDJO-cCJX5M2u.js +291 -0
- package/app/web/assets/swimlanes-YQL5WMAO-B7grWEWt.js +1 -0
- package/app/web/assets/swimlanesDiagram-UCCPES4V-B8Jem9gq.js +8 -0
- package/app/web/assets/timeline-definition-7Z437IG3-BhsLa6l1.js +120 -0
- package/app/web/assets/usecaseDiagram-RDK6N6HP-CkPQYmQw.js +370 -0
- package/app/web/assets/vendor-BKfNgqAm.js +666 -0
- package/app/web/assets/vennDiagram-SHRQU5PJ-CufZSwvw.js +34 -0
- package/app/web/assets/wardleyDiagram-F3OXNVQS-CSkfpFOA.js +78 -0
- package/app/web/assets/xychartDiagram-GDYJKCDI-BhZf9scK.js +7 -0
- package/app/web/codexhost-settings.js +57 -57
- 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-api-workspace-controller/client.js +3 -3
- 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 +75 -75
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +12 -12
- 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 +70 -72
- package/app/web-modules/licenses/DSH-THIRD_PARTY_NOTICES.md +1 -1
- package/app/web-modules/server.mjs +724 -259
- 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,9 +73140,60 @@ 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
|
-
var
|
|
73164
|
+
var THREAD_SECTION_CAPABILITY = "threadSectionsV1", threadSectionName = external_exports.string().trim().min(1), threadSectionId = external_exports.string().min(1), threadSectionAppearance = external_exports.object({
|
|
73165
|
+
icon: external_exports.string().nullable(),
|
|
73166
|
+
color: external_exports.string().nullable()
|
|
73167
|
+
}), clientThreadSectionAppearanceSchema = threadSectionAppearance.nullable(), CLIENT_THREAD_SECTION_MUTATIONS = {
|
|
73168
|
+
create: {
|
|
73169
|
+
method: "codexhost/thread/sections/create",
|
|
73170
|
+
params: external_exports.object({ name: threadSectionName }).strict()
|
|
73171
|
+
},
|
|
73172
|
+
update: {
|
|
73173
|
+
method: "codexhost/thread/sections/update",
|
|
73174
|
+
params: external_exports.object({
|
|
73175
|
+
sectionId: threadSectionId,
|
|
73176
|
+
name: threadSectionName,
|
|
73177
|
+
appearance: threadSectionAppearance.strict().nullable().optional()
|
|
73178
|
+
}).strict()
|
|
73179
|
+
},
|
|
73180
|
+
delete: {
|
|
73181
|
+
method: "codexhost/thread/sections/delete",
|
|
73182
|
+
params: external_exports.object({ sectionId: threadSectionId }).strict()
|
|
73183
|
+
}
|
|
73184
|
+
}, clientThreadSectionMutationResultSchema = external_exports.discriminatedUnion("status", [
|
|
73185
|
+
external_exports.object({ status: external_exports.literal("unknown") }),
|
|
73186
|
+
external_exports.object({
|
|
73187
|
+
status: external_exports.literal("confirmed"),
|
|
73188
|
+
sectionId: threadSectionId,
|
|
73189
|
+
section: external_exports.object({
|
|
73190
|
+
id: threadSectionId,
|
|
73191
|
+
name: external_exports.string().min(1),
|
|
73192
|
+
appearance: clientThreadSectionAppearanceSchema
|
|
73193
|
+
}).nullable(),
|
|
73194
|
+
syncPending: external_exports.boolean()
|
|
73195
|
+
})
|
|
73196
|
+
]), CLIENT_CHANNEL_METHODS = [
|
|
73146
73197
|
"codexhost/skills/list",
|
|
73147
73198
|
"codexhost/voice/status",
|
|
73148
73199
|
"codexhost/voice/transcribe",
|
|
@@ -73151,10 +73202,12 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
73151
73202
|
"codexhost/harness/display-settings/capabilities",
|
|
73152
73203
|
"codexhost/harness/preferences/get",
|
|
73153
73204
|
"codexhost/harness/preferences/patch",
|
|
73205
|
+
"experimentalFeature/list",
|
|
73154
73206
|
"thread/list",
|
|
73155
73207
|
"thread/metadata/update",
|
|
73156
73208
|
"codexhost/thread/catalog/read",
|
|
73157
73209
|
"thread/read",
|
|
73210
|
+
NATIVE_CODEX_GOAL_METHOD,
|
|
73158
73211
|
"thread/resume",
|
|
73159
73212
|
"thread/fork",
|
|
73160
73213
|
"thread/turns/list",
|
|
@@ -73186,6 +73239,9 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
73186
73239
|
"codexhost/thread/pins/list",
|
|
73187
73240
|
"codexhost/thread/sections/list",
|
|
73188
73241
|
"codexhost/thread/sections/move",
|
|
73242
|
+
CLIENT_THREAD_SECTION_MUTATIONS.create.method,
|
|
73243
|
+
CLIENT_THREAD_SECTION_MUTATIONS.update.method,
|
|
73244
|
+
CLIENT_THREAD_SECTION_MUTATIONS.delete.method,
|
|
73189
73245
|
"codexhost/thread/pins/set",
|
|
73190
73246
|
"codexhost/harness/plugins/list",
|
|
73191
73247
|
"codexhost/harness/inspect",
|
|
@@ -73235,15 +73291,20 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
73235
73291
|
PRODUCT_TELEMETRY_SIGNAL_METHOD,
|
|
73236
73292
|
"codexhost/sessions/loaded/list"
|
|
73237
73293
|
], clientThreadSectionsSchema = external_exports.object({
|
|
73294
|
+
[THREAD_SECTION_CAPABILITY]: external_exports.literal(!0).optional(),
|
|
73295
|
+
complete: external_exports.literal(!1).optional(),
|
|
73238
73296
|
sections: external_exports.array(external_exports.object({
|
|
73239
73297
|
id: external_exports.string().min(1),
|
|
73240
73298
|
name: external_exports.string().min(1),
|
|
73299
|
+
appearance: clientThreadSectionAppearanceSchema.optional(),
|
|
73241
73300
|
threads: external_exports.array(jsonObjectSchema)
|
|
73242
|
-
})
|
|
73243
|
-
})
|
|
73301
|
+
}))
|
|
73302
|
+
}), clientThreadSectionMoveSchema = external_exports.object({
|
|
73244
73303
|
threadId: external_exports.string().min(1).max(1024),
|
|
73245
|
-
sectionId: external_exports.string().min(1).max(1024).nullable()
|
|
73246
|
-
|
|
73304
|
+
sectionId: external_exports.string().min(1).max(1024).nullable(),
|
|
73305
|
+
beforeThreadId: external_exports.string().min(1).max(1024).nullable().optional(),
|
|
73306
|
+
expectedSourceSectionId: external_exports.string().min(1).max(1024).optional()
|
|
73307
|
+
}).refine((move) => move.expectedSourceSectionId === void 0 || move.sectionId === null), clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict(), clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict(), clientThreadTreeReadParamsSchema = external_exports.object({}).strict(), clientThreadTreeSchema = external_exports.object({
|
|
73247
73308
|
parents: external_exports.record(external_exports.string().min(1), external_exports.string().min(1))
|
|
73248
73309
|
}).strict(), clientProjectlessWorkspaceSchema = external_exports.object({
|
|
73249
73310
|
prompt: external_exports.string().max(16384).optional()
|
|
@@ -73281,6 +73342,7 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
73281
73342
|
harnessId: external_exports.string().min(1)
|
|
73282
73343
|
}),
|
|
73283
73344
|
external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
|
|
73345
|
+
external_exports.object({ type: external_exports.literal("sections-changed"), cursor: clientChannelCursorSchema }),
|
|
73284
73346
|
external_exports.object({
|
|
73285
73347
|
type: external_exports.literal("preferences-changed"),
|
|
73286
73348
|
cursor: clientChannelCursorSchema,
|
|
@@ -73435,7 +73497,8 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
73435
73497
|
startedAt: external_exports.number(),
|
|
73436
73498
|
epoch: external_exports.string().uuid(),
|
|
73437
73499
|
capabilities: external_exports.object({
|
|
73438
|
-
peerDelegation: external_exports.literal(1).optional()
|
|
73500
|
+
peerDelegation: external_exports.literal(1).optional(),
|
|
73501
|
+
threadReferenceContext: external_exports.literal(1).optional()
|
|
73439
73502
|
}).optional()
|
|
73440
73503
|
}), clientChannelResponseSchema = external_exports.object({
|
|
73441
73504
|
epoch: external_exports.string().uuid(),
|
|
@@ -74335,7 +74398,8 @@ var field = external_exports.discriminatedUnion("type", [
|
|
|
74335
74398
|
var WEB_ACTIVE_TURN_PROJECTION = "codexhostActiveTurnId", WEB_FOLLOW_PROJECTION_KEYS = /* @__PURE__ */ new Set([
|
|
74336
74399
|
WEB_ACTIVE_TURN_PROJECTION,
|
|
74337
74400
|
"codexhostTurnChanges",
|
|
74338
|
-
"codexhostToolOutput"
|
|
74401
|
+
"codexhostToolOutput",
|
|
74402
|
+
"codexGoal"
|
|
74339
74403
|
]), webFileDiffSchema = external_exports.object({
|
|
74340
74404
|
path: external_exports.string(),
|
|
74341
74405
|
oldText: external_exports.string().nullable(),
|
|
@@ -74899,7 +74963,7 @@ function remoteSessionRequestBytes(operation) {
|
|
|
74899
74963
|
}
|
|
74900
74964
|
var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(1).max(REMOTE_IDENTITY_MAX_LENGTH), target = {
|
|
74901
74965
|
hostId: identity.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)
|
|
74902
|
-
},
|
|
74966
|
+
}, thread2 = { ...target, threadId: identity }, text = external_exports.string().min(1).max(8e3), input2 = { text, requestId: identity }, remoteDeliveryReplySchema = external_exports.discriminatedUnion("accepted", [
|
|
74903
74967
|
external_exports.object({ accepted: external_exports.literal(!0), startQueuedItemId: identity.optional() }),
|
|
74904
74968
|
external_exports.object({
|
|
74905
74969
|
accepted: external_exports.literal(!1),
|
|
@@ -74945,7 +75009,7 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
|
|
|
74945
75009
|
serviceTier: external_exports.enum(["priority", "ultrafast"]).optional(),
|
|
74946
75010
|
reasoningEffort: identity.optional()
|
|
74947
75011
|
}),
|
|
74948
|
-
external_exports.strictObject({ kind: external_exports.literal("status"), ...
|
|
75012
|
+
external_exports.strictObject({ kind: external_exports.literal("status"), ...thread2 }),
|
|
74949
75013
|
external_exports.strictObject({
|
|
74950
75014
|
kind: external_exports.literal("list"),
|
|
74951
75015
|
...target,
|
|
@@ -74955,7 +75019,7 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
|
|
|
74955
75019
|
}),
|
|
74956
75020
|
external_exports.strictObject({
|
|
74957
75021
|
kind: external_exports.literal("read"),
|
|
74958
|
-
...
|
|
75022
|
+
...thread2,
|
|
74959
75023
|
page: external_exports.strictObject({
|
|
74960
75024
|
cursor: external_exports.string().min(1).max(8192).nullable(),
|
|
74961
75025
|
epoch: identity.optional(),
|
|
@@ -74965,10 +75029,10 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
|
|
|
74965
75029
|
message: "A history continuation requires its connection epoch"
|
|
74966
75030
|
}).optional()
|
|
74967
75031
|
}),
|
|
74968
|
-
external_exports.strictObject({ kind: external_exports.literal("usage"), ...
|
|
75032
|
+
external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread2, epoch: identity }),
|
|
74969
75033
|
external_exports.strictObject({
|
|
74970
75034
|
kind: external_exports.literal("configure"),
|
|
74971
|
-
...
|
|
75035
|
+
...thread2,
|
|
74972
75036
|
epoch: identity,
|
|
74973
75037
|
modelId: identity.optional(),
|
|
74974
75038
|
serviceTier: harnessModelServiceTierSchema.optional(),
|
|
@@ -74979,15 +75043,15 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
|
|
|
74979
75043
|
}),
|
|
74980
75044
|
external_exports.strictObject({
|
|
74981
75045
|
kind: external_exports.literal("prompt"),
|
|
74982
|
-
...
|
|
75046
|
+
...thread2,
|
|
74983
75047
|
epoch: identity,
|
|
74984
75048
|
text,
|
|
74985
75049
|
requestId: identity.optional()
|
|
74986
75050
|
}),
|
|
74987
|
-
external_exports.strictObject({ kind: external_exports.literal("queue"), ...
|
|
75051
|
+
external_exports.strictObject({ kind: external_exports.literal("queue"), ...thread2, epoch: identity }),
|
|
74988
75052
|
external_exports.strictObject({
|
|
74989
75053
|
kind: external_exports.literal("delivery"),
|
|
74990
|
-
...
|
|
75054
|
+
...thread2,
|
|
74991
75055
|
epoch: identity,
|
|
74992
75056
|
action: external_exports.discriminatedUnion("kind", [
|
|
74993
75057
|
external_exports.strictObject({ kind: external_exports.literal("enqueue"), ...input2 }),
|
|
@@ -75001,17 +75065,17 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
|
|
|
75001
75065
|
external_exports.strictObject({ kind: external_exports.literal("sendNow"), itemId: identity })
|
|
75002
75066
|
])
|
|
75003
75067
|
}),
|
|
75004
|
-
external_exports.strictObject({ kind: external_exports.literal("interrupt"), ...
|
|
75068
|
+
external_exports.strictObject({ kind: external_exports.literal("interrupt"), ...thread2, epoch: identity, turnId: identity }),
|
|
75005
75069
|
external_exports.strictObject({
|
|
75006
75070
|
kind: external_exports.literal("rename"),
|
|
75007
|
-
...
|
|
75071
|
+
...thread2,
|
|
75008
75072
|
epoch: identity,
|
|
75009
75073
|
name: external_exports.string().min(1).max(512)
|
|
75010
75074
|
}),
|
|
75011
|
-
external_exports.strictObject({ kind: external_exports.literal("archive"), ...
|
|
75075
|
+
external_exports.strictObject({ kind: external_exports.literal("archive"), ...thread2, epoch: identity, archived: external_exports.boolean() }),
|
|
75012
75076
|
external_exports.strictObject({
|
|
75013
75077
|
kind: external_exports.literal("respond"),
|
|
75014
|
-
...
|
|
75078
|
+
...thread2,
|
|
75015
75079
|
epoch: identity,
|
|
75016
75080
|
requestId: external_exports.union([identity, external_exports.number().int()]),
|
|
75017
75081
|
result: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
@@ -75265,7 +75329,7 @@ var HostClientChannel = class {
|
|
|
75265
75329
|
throw new Error("Host unavailable");
|
|
75266
75330
|
this.descriptor = descriptor;
|
|
75267
75331
|
let url2 = new URL(`http://127.0.0.1:${descriptor.port}/v1/events`);
|
|
75268
|
-
this.cursor && (url2.searchParams.set("epoch", this.cursor.epoch), url2.searchParams.set("after", String(this.cursor.sequence)));
|
|
75332
|
+
url2.searchParams.set(THREAD_SECTION_CAPABILITY, "1"), this.cursor && (url2.searchParams.set("epoch", this.cursor.epoch), url2.searchParams.set("after", String(this.cursor.sequence)));
|
|
75269
75333
|
let response = await fetch(url2, {
|
|
75270
75334
|
redirect: "error",
|
|
75271
75335
|
headers: { authorization: `Bearer ${descriptor.token}` },
|
|
@@ -75332,12 +75396,15 @@ var HostClientChannel = class {
|
|
|
75332
75396
|
throw Object.assign(new Error("Obsolete Host reply; resynchronize after reconnecting"), {
|
|
75333
75397
|
code: -32094
|
|
75334
75398
|
});
|
|
75335
|
-
if (value
|
|
75336
|
-
|
|
75337
|
-
|
|
75399
|
+
if (Object.hasOwn(value, "error") && !Object.hasOwn(value, "result")) {
|
|
75400
|
+
let error62 = jsonRpcErrorSchema.safeParse(value.error);
|
|
75401
|
+
if (error62.success)
|
|
75402
|
+
throw Object.assign(new Error(error62.data.message), { code: error62.data.code });
|
|
75403
|
+
}
|
|
75404
|
+
if (!response.ok || Object.hasOwn(value, "error") || !Object.hasOwn(value, "result"))
|
|
75405
|
+
throw Object.assign(new Error("Invalid Host reply; operation outcome may be unknown"), {
|
|
75406
|
+
code: -32093
|
|
75338
75407
|
});
|
|
75339
|
-
if (!Object.hasOwn(value, "result"))
|
|
75340
|
-
throw new Error("Invalid Host reply; operation outcome may be unknown");
|
|
75341
75408
|
return value.result;
|
|
75342
75409
|
}
|
|
75343
75410
|
request(method2, params, timeoutMs) {
|
|
@@ -77629,8 +77696,10 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77629
77696
|
this.changed(this.hostId);
|
|
77630
77697
|
}
|
|
77631
77698
|
if (this.life.signal.aborted) return;
|
|
77632
|
-
let query =
|
|
77633
|
-
|
|
77699
|
+
let query = new URLSearchParams({ [THREAD_SECTION_CAPABILITY]: "1" });
|
|
77700
|
+
this.cursor && (query.set("epoch", this.cursor.epoch), query.set("after", String(this.cursor.sequence)));
|
|
77701
|
+
let response = await this.fetch(
|
|
77702
|
+
`/api/ch/v1/events?${query}`,
|
|
77634
77703
|
"GET",
|
|
77635
77704
|
void 0,
|
|
77636
77705
|
streamAbort.signal
|
|
@@ -77830,8 +77899,8 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77830
77899
|
knownTurns: this.knownTurnsForStatus(threadId),
|
|
77831
77900
|
truncateToolOutput: !0
|
|
77832
77901
|
})
|
|
77833
|
-
),
|
|
77834
|
-
if (
|
|
77902
|
+
), thread3 = snapshot.thread, external = thread3.modelProvider === "codexhost" && thread3.cliVersion === "codexhost";
|
|
77903
|
+
if (thread3.canAcceptDirectInput === !1)
|
|
77835
77904
|
return { accepted: !1, code: "remote/send-rejected", message: "Thread is read-only" };
|
|
77836
77905
|
if (a.kind === "sendNow")
|
|
77837
77906
|
try {
|
|
@@ -77845,7 +77914,7 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77845
77914
|
if (error62 instanceof SessionRuntimeError && error62.code === "remote/request-failed") {
|
|
77846
77915
|
let hostCode = "hostCode" in error62.details && typeof error62.details.hostCode == "number" ? error62.details.hostCode : void 0, message2 = error62.message;
|
|
77847
77916
|
if (hostCode === -32601 || /unsupported client channel method|method not found/iu.test(message2)) {
|
|
77848
|
-
if (
|
|
77917
|
+
if (thread3.status.type === "idle" || thread3.status.type === "notLoaded") {
|
|
77849
77918
|
if (!(await rpc2("thread/queue/start", {
|
|
77850
77919
|
threadId,
|
|
77851
77920
|
queuedSubmissionId: a.itemId
|
|
@@ -77875,7 +77944,7 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77875
77944
|
}
|
|
77876
77945
|
throw error62;
|
|
77877
77946
|
}
|
|
77878
|
-
if (a.kind === "steer" && external && !
|
|
77947
|
+
if (a.kind === "steer" && external && !thread3.codexhostSupportsStrictSteer)
|
|
77879
77948
|
return {
|
|
77880
77949
|
accepted: !1,
|
|
77881
77950
|
code: "remote/steer-unavailable",
|
|
@@ -77903,13 +77972,13 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
77903
77972
|
...a.kind === "steer" ? {
|
|
77904
77973
|
expectedTurnId: a.turnId,
|
|
77905
77974
|
...external ? { codexhostSteerStrictTarget: !0 } : {}
|
|
77906
|
-
} : external &&
|
|
77975
|
+
} : external && thread3.status.type === "idle" ? { codexhostQueueStartIfEmpty: !0 } : {}
|
|
77907
77976
|
});
|
|
77908
77977
|
if (a.kind === "enqueue") {
|
|
77909
77978
|
let item = result.queuedSubmission;
|
|
77910
77979
|
if (!item?.id || item.clientUserMessageId !== a.requestId)
|
|
77911
77980
|
throw Error("Queue admission not confirmed");
|
|
77912
|
-
if (!external &&
|
|
77981
|
+
if (!external && thread3.status.type === "idle" && snapshot.queue?.items.length === 0)
|
|
77913
77982
|
return { accepted: !0, startQueuedItemId: item.id };
|
|
77914
77983
|
} else if (result.turnId !== a.turnId && !(external && result.delivery === "newTurn" && result.turnId))
|
|
77915
77984
|
throw Error("Steering not confirmed");
|
|
@@ -78590,9 +78659,9 @@ var ChHarnessCommands = class {
|
|
|
78590
78659
|
resolve;
|
|
78591
78660
|
pending = /* @__PURE__ */ new Set();
|
|
78592
78661
|
async inspect(sessionId) {
|
|
78593
|
-
let
|
|
78662
|
+
let thread3 = await this.resolve(sessionId);
|
|
78594
78663
|
return harnessCommandCatalogSchema.parse(
|
|
78595
|
-
await this.host.request("codexhost/thread/commands/inspect", { threadId:
|
|
78664
|
+
await this.host.request("codexhost/thread/commands/inspect", { threadId: thread3.id })
|
|
78596
78665
|
);
|
|
78597
78666
|
}
|
|
78598
78667
|
/** Draft catalog from its workspace; the Host reads it without creating a Thread. */
|
|
@@ -78605,20 +78674,20 @@ var ChHarnessCommands = class {
|
|
|
78605
78674
|
);
|
|
78606
78675
|
}
|
|
78607
78676
|
async execute(sessionId, commandId) {
|
|
78608
|
-
let
|
|
78609
|
-
if (this.pending.has(
|
|
78677
|
+
let thread3 = await this.resolve(sessionId);
|
|
78678
|
+
if (this.pending.has(thread3.id) || thread3.status.type === "active")
|
|
78610
78679
|
throw new SessionRuntimeError("session/busy", "The Thread is busy. Direct commands cannot be queued.");
|
|
78611
|
-
this.pending.add(
|
|
78680
|
+
this.pending.add(thread3.id);
|
|
78612
78681
|
try {
|
|
78613
78682
|
let command = requireDirectCommand(await this.inspect(sessionId), commandId);
|
|
78614
78683
|
return threadCommandExecuteResultSchema.parse(
|
|
78615
78684
|
await this.host.request("codexhost/thread/command/execute", {
|
|
78616
|
-
threadId:
|
|
78685
|
+
threadId: thread3.id,
|
|
78617
78686
|
commandId: command.id
|
|
78618
78687
|
})
|
|
78619
78688
|
);
|
|
78620
78689
|
} finally {
|
|
78621
|
-
this.pending.delete(
|
|
78690
|
+
this.pending.delete(thread3.id);
|
|
78622
78691
|
}
|
|
78623
78692
|
}
|
|
78624
78693
|
};
|
|
@@ -78644,9 +78713,10 @@ var ChRealtime = class {
|
|
|
78644
78713
|
urgent = /* @__PURE__ */ new Set();
|
|
78645
78714
|
running = /* @__PURE__ */ new Set();
|
|
78646
78715
|
timers = /* @__PURE__ */ new Map();
|
|
78647
|
-
catalogReason
|
|
78716
|
+
catalogReason;
|
|
78648
78717
|
threadDebounceMs;
|
|
78649
78718
|
closed = !1;
|
|
78719
|
+
sectionsDirty = !1;
|
|
78650
78720
|
online = !1;
|
|
78651
78721
|
unsubscribe;
|
|
78652
78722
|
invalidate(id2) {
|
|
@@ -78670,9 +78740,11 @@ var ChRealtime = class {
|
|
|
78670
78740
|
if (event.type === "hello") {
|
|
78671
78741
|
this.callbacks.reset(event.cursor.epoch, event.reset);
|
|
78672
78742
|
for (let id2 of this.watched.keys()) this.schedule(id2, 100);
|
|
78673
|
-
this.
|
|
78743
|
+
this.catalogReason ??= "hello", this.schedule("", 100);
|
|
78674
78744
|
} else if (event.type === "projects-changed")
|
|
78675
|
-
this.schedule("", 100);
|
|
78745
|
+
this.catalogReason = "changed", this.schedule("", 100);
|
|
78746
|
+
else if (event.type === "sections-changed" && this.callbacks.sections)
|
|
78747
|
+
this.sectionsDirty = !0, this.schedule("", 100);
|
|
78676
78748
|
else if (event.type === "changed") {
|
|
78677
78749
|
if (event.method === "codexhost/thread/usage/updated" || event.method === "thread/tokenUsage/updated") {
|
|
78678
78750
|
this.online && this.watched.has(event.threadId) && this.callbacks.usage(event.threadId);
|
|
@@ -78711,12 +78783,14 @@ var ChRealtime = class {
|
|
|
78711
78783
|
if (this.dirty.delete(id2), this.urgent.delete(id2), this.closed || !this.online || id2 && !this.watched.has(id2)) return;
|
|
78712
78784
|
this.running.add(id2);
|
|
78713
78785
|
let catalogReason = id2 ? void 0 : this.catalogReason;
|
|
78714
|
-
id2 || (this.catalogReason =
|
|
78786
|
+
id2 || (this.catalogReason = void 0);
|
|
78787
|
+
let sections = !id2 && this.sectionsDirty ? this.callbacks.sections : void 0;
|
|
78788
|
+
sections && (this.sectionsDirty = !1);
|
|
78715
78789
|
let retryDelay2;
|
|
78716
78790
|
try {
|
|
78717
|
-
id2 ? await this.callbacks.thread(id2) : await this.callbacks.catalog(catalogReason);
|
|
78791
|
+
id2 ? await this.callbacks.thread(id2) : catalogReason ? await this.callbacks.catalog(catalogReason, !!sections) : sections && await sections();
|
|
78718
78792
|
} catch (error62) {
|
|
78719
|
-
this.callbacks.error(id2, error62), this.dirty.add(id2),
|
|
78793
|
+
sections && (this.sectionsDirty = !0), this.callbacks.error(id2, error62), this.dirty.add(id2), catalogReason && (this.catalogReason ??= catalogReason), retryDelay2 = 1e3;
|
|
78720
78794
|
} finally {
|
|
78721
78795
|
if (this.running.delete(id2), this.dirty.has(id2)) {
|
|
78722
78796
|
let nextDelay = retryDelay2 ?? (id2 ? this.urgent.has(id2) ? 100 : this.threadDebounceMs : 100);
|
|
@@ -79161,8 +79235,8 @@ function threadListTitle(row) {
|
|
|
79161
79235
|
}
|
|
79162
79236
|
|
|
79163
79237
|
// packages/web-server/src/ch-thread-time.ts
|
|
79164
|
-
function threadRecencyMs(
|
|
79165
|
-
return (
|
|
79238
|
+
function threadRecencyMs(thread3) {
|
|
79239
|
+
return (thread3.recencyAt ?? thread3.updatedAt) * 1e3;
|
|
79166
79240
|
}
|
|
79167
79241
|
|
|
79168
79242
|
// packages/web-server/src/ch-turn-changes.ts
|
|
@@ -80366,9 +80440,9 @@ function compactTurnToolOutputs(turn) {
|
|
|
80366
80440
|
return changed ? { ...turn, items } : turn;
|
|
80367
80441
|
}
|
|
80368
80442
|
var ChThreadView = class _ChThreadView {
|
|
80369
|
-
constructor(
|
|
80443
|
+
constructor(thread3, harnessId, onProjection, turnStart = 0, sequenceStart = 0, hasEarlier = () => !1, projectInput = (content) => content, projectImage = () => {
|
|
80370
80444
|
}, options) {
|
|
80371
|
-
this.thread =
|
|
80445
|
+
this.thread = thread3;
|
|
80372
80446
|
this.harnessId = harnessId;
|
|
80373
80447
|
this.turnStart = turnStart;
|
|
80374
80448
|
this.projectInput = projectInput;
|
|
@@ -80378,9 +80452,9 @@ var ChThreadView = class _ChThreadView {
|
|
|
80378
80452
|
this.log = new SessionLog(
|
|
80379
80453
|
{
|
|
80380
80454
|
version: 4,
|
|
80381
|
-
id:
|
|
80382
|
-
createdAt:
|
|
80383
|
-
cwd:
|
|
80455
|
+
id: thread3.id,
|
|
80456
|
+
createdAt: thread3.createdAt * 1e3,
|
|
80457
|
+
cwd: thread3.cwd,
|
|
80384
80458
|
isSeeded: !1,
|
|
80385
80459
|
agentPreset: "standard"
|
|
80386
80460
|
},
|
|
@@ -80508,10 +80582,10 @@ var ChThreadView = class _ChThreadView {
|
|
|
80508
80582
|
let storedTurns = this.compactToolOutputs ? turns.map((turn) => compactTurnToolOutputs(turn)) : turns;
|
|
80509
80583
|
this.thread.turns = [...storedTurns, ...this.thread.turns], this.compactToolOutputs && compactLogToolOutputs(this.log), this.publishMessageTimes(), this.publishFileChanges();
|
|
80510
80584
|
}
|
|
80511
|
-
update(
|
|
80585
|
+
update(thread3, activeTurnId) {
|
|
80512
80586
|
this.ensureCurrent();
|
|
80513
80587
|
let existingTurns = new Map(this.thread.turns.map((turn) => [turn.id, turn])), projectionsByTurn = /* @__PURE__ */ new Map();
|
|
80514
|
-
for (let turn of
|
|
80588
|
+
for (let turn of thread3.turns) {
|
|
80515
80589
|
let view = this.turns.get(turn.id);
|
|
80516
80590
|
if (!view || view.done && turn === existingTurns.get(turn.id)) continue;
|
|
80517
80591
|
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 +80616,12 @@ var ChThreadView = class _ChThreadView {
|
|
|
80542
80616
|
})) || firstNewUser !== -1 && items.slice(firstNewUser + 1).some((item) => view.started.has(item.id)))
|
|
80543
80617
|
throw new SessionRuntimeError("host/items-replaced", "CH replaced already projected Items.");
|
|
80544
80618
|
}
|
|
80545
|
-
Object.assign(this.thread,
|
|
80546
|
-
blank:
|
|
80547
|
-
lastPromptAt: threadRecencyMs(
|
|
80619
|
+
Object.assign(this.thread, thread3), this.log.setProjection("title", threadListTitle(thread3)), this.log.setProjection("codexhostImportSource", thread3.codexhostImportSource ?? null), this.log.setProjection("sessionListMetadata", {
|
|
80620
|
+
blank: thread3.turns.length === 0,
|
|
80621
|
+
lastPromptAt: threadRecencyMs(thread3)
|
|
80548
80622
|
});
|
|
80549
80623
|
try {
|
|
80550
|
-
this.projectTurns(
|
|
80624
|
+
this.projectTurns(thread3, projectionsByTurn);
|
|
80551
80625
|
} finally {
|
|
80552
80626
|
this.log.clock = void 0;
|
|
80553
80627
|
}
|
|
@@ -80555,7 +80629,7 @@ var ChThreadView = class _ChThreadView {
|
|
|
80555
80629
|
(turn) => this.turns.get(turn.id)?.done ? compactTurnToolOutputs(turn) : turn
|
|
80556
80630
|
), compactLogToolOutputs(this.log)), this.log.setProjection(
|
|
80557
80631
|
WEB_ACTIVE_TURN_PROJECTION,
|
|
80558
|
-
activeTurnId !== void 0 ? activeTurnId :
|
|
80632
|
+
activeTurnId !== void 0 ? activeTurnId : thread3.status.type === "active" ? thread3.turns.findLast((turn) => !finished(turn.status))?.id ?? null : null
|
|
80559
80633
|
), this.log.setProjection("codexhostToolOutput", Object.fromEntries(this.liveOutput)), this.publishMessageTimes(), this.publishFileChanges();
|
|
80560
80634
|
}
|
|
80561
80635
|
projectItem(turnId, item, view, reasoningPreviewIds) {
|
|
@@ -80624,9 +80698,9 @@ var ChThreadView = class _ChThreadView {
|
|
|
80624
80698
|
)
|
|
80625
80699
|
);
|
|
80626
80700
|
}
|
|
80627
|
-
projectTurns(
|
|
80628
|
-
let previousEnd =
|
|
80629
|
-
for (let turn of
|
|
80701
|
+
projectTurns(thread3, projections) {
|
|
80702
|
+
let previousEnd = thread3.createdAt * 1e3;
|
|
80703
|
+
for (let turn of thread3.turns) {
|
|
80630
80704
|
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
80705
|
start,
|
|
80632
80706
|
nativeTime(turn.completedAt) ?? (view && !view.done ? Date.now() : start)
|
|
@@ -80635,7 +80709,7 @@ var ChThreadView = class _ChThreadView {
|
|
|
80635
80709
|
let projector2 = new TurnProjector(this.log, {
|
|
80636
80710
|
live: !complete,
|
|
80637
80711
|
turn: this.turnStart + this.turns.size + 1,
|
|
80638
|
-
cwd:
|
|
80712
|
+
cwd: thread3.cwd,
|
|
80639
80713
|
model: { provider: this.harnessId, model: "harness" },
|
|
80640
80714
|
onToolOutput: (id2, output2) => {
|
|
80641
80715
|
output2 === void 0 ? this.liveOutput.delete(id2) : this.liveOutput.set(id2, output2.slice(-8e3));
|
|
@@ -81857,10 +81931,10 @@ function isInvalidCursorError(error62) {
|
|
|
81857
81931
|
return !(error62 instanceof SessionRuntimeError) || error62.code !== "host/rejected" && error62.code !== "remote/request-failed" ? !1 : error62.details?.hostCode === -32602;
|
|
81858
81932
|
}
|
|
81859
81933
|
var ChThreadHistory = class extends ChThreadView {
|
|
81860
|
-
constructor(host,
|
|
81934
|
+
constructor(host, thread3, harnessId, onProjection, origin = RENDER_ORIGIN, projectInput, projectImage, options) {
|
|
81861
81935
|
let pagination = { cursor: null };
|
|
81862
81936
|
super(
|
|
81863
|
-
{ ...
|
|
81937
|
+
{ ...thread3, turns: [] },
|
|
81864
81938
|
harnessId,
|
|
81865
81939
|
onProjection,
|
|
81866
81940
|
origin,
|
|
@@ -81875,7 +81949,7 @@ var ChThreadHistory = class extends ChThreadView {
|
|
|
81875
81949
|
}
|
|
81876
81950
|
);
|
|
81877
81951
|
this.host = host;
|
|
81878
|
-
this.pagination = pagination, this.hasProjectInput = projectInput !== void 0, this.canEditQueueItem = options?.canEditQueueItem, this.hostThreadId = options?.hostThreadId ??
|
|
81952
|
+
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
81953
|
}
|
|
81880
81954
|
host;
|
|
81881
81955
|
loaded = !1;
|
|
@@ -81925,11 +81999,11 @@ var ChThreadHistory = class extends ChThreadView {
|
|
|
81925
81999
|
}
|
|
81926
82000
|
return walkFrom(null);
|
|
81927
82001
|
}
|
|
81928
|
-
viewThread(
|
|
81929
|
-
if (!this.overrideThreadIdentity) return
|
|
81930
|
-
if (
|
|
82002
|
+
viewThread(thread3) {
|
|
82003
|
+
if (!this.overrideThreadIdentity) return thread3;
|
|
82004
|
+
if (thread3.id !== this.hostThreadId)
|
|
81931
82005
|
throw new SessionRuntimeError("remote/read-failed", "Remote identity mismatch");
|
|
81932
|
-
return { ...
|
|
82006
|
+
return { ...thread3, id: this.viewId, cwd: this.viewCwd };
|
|
81933
82007
|
}
|
|
81934
82008
|
async page(cursor) {
|
|
81935
82009
|
let result = await this.host.request("thread/turns/list", {
|
|
@@ -81978,10 +82052,10 @@ var ChThreadHistory = class extends ChThreadView {
|
|
|
81978
82052
|
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
82053
|
threadId: this.hostThreadId,
|
|
81980
82054
|
includeTurns: !1
|
|
81981
|
-
}),
|
|
82055
|
+
}), thread3 = this.viewThread(rawThread);
|
|
81982
82056
|
if (this.ensureCurrent(), this.ownerSnapshot = snapshot, snapshot) {
|
|
81983
82057
|
this.log.setProjection(WEB_HANDOFF_PROJECTION, snapshot.handoff ?? null);
|
|
81984
|
-
let readOnly =
|
|
82058
|
+
let readOnly = thread3.canAcceptDirectInput === !1, allowsAttachments = !readOnly && !(thread3.parentThreadId ?? this.thread.parentThreadId), projectedQueue = this.queueProjection.project(snapshot.queue?.items ?? [], {
|
|
81985
82059
|
...this.hasProjectInput ? { projectInput: (content) => this.projectInput(content) } : {},
|
|
81986
82060
|
...this.canEditQueueItem ? { canEdit: this.canEditQueueItem } : {},
|
|
81987
82061
|
allowsAttachments,
|
|
@@ -81995,8 +82069,8 @@ var ChThreadHistory = class extends ChThreadView {
|
|
|
81995
82069
|
...this.canEditQueueItem ? { editable: projectedQueue.editable } : {}
|
|
81996
82070
|
});
|
|
81997
82071
|
}
|
|
81998
|
-
if (!snapshot && !force && this.loaded && Date.now() - this.lastHeadReadAt < 6e4 &&
|
|
81999
|
-
Object.assign(this.thread, { ...
|
|
82072
|
+
if (!snapshot && !force && this.loaded && Date.now() - this.lastHeadReadAt < 6e4 && thread3.updatedAt === this.thread.updatedAt && thread3.status.type !== "active" && this.thread.status.type !== "active") {
|
|
82073
|
+
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
82074
|
return;
|
|
82001
82075
|
}
|
|
82002
82076
|
let recent = snapshot ? snapshot.turnsPage : await this.page(null);
|
|
@@ -82017,7 +82091,7 @@ var ChThreadHistory = class extends ChThreadView {
|
|
|
82017
82091
|
"CH history was rewritten. Reload this page to reopen its current history."
|
|
82018
82092
|
);
|
|
82019
82093
|
if (!this.loaded)
|
|
82020
|
-
this.pagination.cursor = recent.nextCursor, this.update({ ...
|
|
82094
|
+
this.pagination.cursor = recent.nextCursor, this.update({ ...thread3, turns: descending.reverse() }, snapshot?.activeTurnId), this.loaded = !0;
|
|
82021
82095
|
else {
|
|
82022
82096
|
newestKnown || (this.pagination.cursor = recent.nextCursor);
|
|
82023
82097
|
let newTurns = newestKnown ? descending.slice(
|
|
@@ -82026,7 +82100,7 @@ var ChThreadHistory = class extends ChThreadView {
|
|
|
82026
82100
|
) : descending, incoming = new Map(descending.map((turn) => [turn.id, turn])), known = new Set(this.thread.turns.map((turn) => turn.id));
|
|
82027
82101
|
this.update(
|
|
82028
82102
|
{
|
|
82029
|
-
...
|
|
82103
|
+
...thread3,
|
|
82030
82104
|
turns: [
|
|
82031
82105
|
...this.thread.turns.map((turn) => incoming.get(turn.id) ?? turn),
|
|
82032
82106
|
...newTurns.reverse().filter((turn) => !known.has(turn.id))
|
|
@@ -82704,13 +82778,13 @@ var PeerThreadSource = class {
|
|
|
82704
82778
|
let epoch = this.host.manifestEpoch();
|
|
82705
82779
|
this.pendingCommands.add(threadId);
|
|
82706
82780
|
try {
|
|
82707
|
-
let { thread:
|
|
82781
|
+
let { thread: thread3 } = await this.host.request("thread/read", {
|
|
82708
82782
|
threadId,
|
|
82709
82783
|
includeTurns: !1
|
|
82710
82784
|
});
|
|
82711
|
-
if (
|
|
82785
|
+
if (thread3.id !== threadId || thread3.parentThreadId || thread3.canAcceptDirectInput === !1)
|
|
82712
82786
|
throw new SessionRuntimeError("command/unavailable", "Commands require an editable remote Thread.");
|
|
82713
|
-
if (
|
|
82787
|
+
if (thread3.status.type === "active") throw busy();
|
|
82714
82788
|
if (requireDirectCommand(await this.inspectThreadCommands(threadId), params.data.commandId), this.host.manifestEpoch() !== epoch)
|
|
82715
82789
|
throw new SessionRuntimeError("remote/connection-changed", "Remote peer changed before dispatch.");
|
|
82716
82790
|
if (this.knownArchived.get(threadId)?.archived)
|
|
@@ -102459,8 +102533,8 @@ var RemoteProjectDraft = class {
|
|
|
102459
102533
|
|
|
102460
102534
|
// packages/web-server/src/remote-approval.ts
|
|
102461
102535
|
var text2 = (value) => typeof value == "string" && value.trim() ? value : void 0;
|
|
102462
|
-
function remoteApprovalPresentation(request3,
|
|
102463
|
-
let p = request3.params, items = (Array.isArray(
|
|
102536
|
+
function remoteApprovalPresentation(request3, thread3) {
|
|
102537
|
+
let p = request3.params, items = (Array.isArray(thread3?.turns) ? thread3.turns : []).flatMap(
|
|
102464
102538
|
(turn) => Array.isArray(turn?.items) ? turn.items : []
|
|
102465
102539
|
), 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
102540
|
text2(p.grantRoot),
|
|
@@ -102733,11 +102807,11 @@ async function tryGenerateThreadTitle(host, row, prompt, external, isCurrent) {
|
|
|
102733
102807
|
let title = generated ?? (external ? firstPromptTitle(input3) : null);
|
|
102734
102808
|
if (!title || !isCurrent()) return !1;
|
|
102735
102809
|
try {
|
|
102736
|
-
let { thread:
|
|
102810
|
+
let { thread: thread3 } = await host.request("thread/read", {
|
|
102737
102811
|
threadId: row.id,
|
|
102738
102812
|
includeTurns: !1
|
|
102739
102813
|
});
|
|
102740
|
-
return !isCurrent() || (
|
|
102814
|
+
return !isCurrent() || (thread3.name ?? "") !== expectedName ? !1 : (await host.request("thread/name/set", {
|
|
102741
102815
|
threadId: row.id,
|
|
102742
102816
|
name: title,
|
|
102743
102817
|
...external ? { [THREAD_NAME_AUTO_SOURCE_PARAM]: generated === null ? "fallback" : "generated" } : {}
|
|
@@ -104383,9 +104457,9 @@ var RemoteSessions = class {
|
|
|
104383
104457
|
"remote/outcome-unknown",
|
|
104384
104458
|
"Remote Thread creation was not confirmed. Refresh the project before retrying."
|
|
104385
104459
|
);
|
|
104386
|
-
let
|
|
104460
|
+
let thread3 = result2.data.thread, identity2 = { hostId: host.hostId, threadId: thread3.id }, id2 = remoteSessionId(identity2.hostId, identity2.threadId), entry = this.entries.get(id2) ?? {
|
|
104387
104461
|
identity: identity2,
|
|
104388
|
-
row: { ...
|
|
104462
|
+
row: { ...thread3, turns: [] },
|
|
104389
104463
|
online: !0,
|
|
104390
104464
|
configurationRevision: 0
|
|
104391
104465
|
};
|
|
@@ -104401,7 +104475,7 @@ var RemoteSessions = class {
|
|
|
104401
104475
|
try {
|
|
104402
104476
|
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
104477
|
await this.attachments.prompt(this.peerEndpoint(host.hostId), {
|
|
104404
|
-
threadId:
|
|
104478
|
+
threadId: thread3.id,
|
|
104405
104479
|
...draftUploadScope !== void 0 ? { scope: draftUploadScope } : {},
|
|
104406
104480
|
...peerPromptRequestId !== void 0 ? { requestId: peerPromptRequestId } : {},
|
|
104407
104481
|
...peerPromptMode !== void 0 ? { mode: peerPromptMode } : {},
|
|
@@ -104409,7 +104483,7 @@ var RemoteSessions = class {
|
|
|
104409
104483
|
}), draftUploadScope !== void 0 && entry.pendingUploadScope === draftUploadScope && delete entry.pendingUploadScope;
|
|
104410
104484
|
else if (legacyPrompt !== void 0) {
|
|
104411
104485
|
let text4 = this.translatePeerOutboundText(host.hostId, legacyPrompt.text);
|
|
104412
|
-
await this.invoke({ ...legacyPrompt, text: text4, threadId:
|
|
104486
|
+
await this.invoke({ ...legacyPrompt, text: text4, threadId: thread3.id });
|
|
104413
104487
|
}
|
|
104414
104488
|
} finally {
|
|
104415
104489
|
this.pendingFirstTurns.delete(id2);
|
|
@@ -104419,7 +104493,7 @@ var RemoteSessions = class {
|
|
|
104419
104493
|
let titlePrompt = usePeerAttachments && peerPromptContent !== void 0 ? peerPromptContent.filter(
|
|
104420
104494
|
(part) => part.type === "text"
|
|
104421
104495
|
).map((part) => part.text).join(`
|
|
104422
|
-
`) : legacyPrompt?.text ?? "", external = operation.kind === "startSelected" && operation.harnessId !== "codex" ||
|
|
104496
|
+
`) : legacyPrompt?.text ?? "", external = operation.kind === "startSelected" && operation.harnessId !== "codex" || thread3.modelProvider === "codexhost";
|
|
104423
104497
|
this.titleRequests.add(id2), tryGenerateThreadTitle(
|
|
104424
104498
|
peerSource.host,
|
|
104425
104499
|
entry.row,
|
|
@@ -138935,6 +139009,8 @@ var MAX_TABS = 12, DETACHED_TAB_MS = 5 * 6e4, IDLE_BROWSER_MS = 6e4, SWEEP_MS =
|
|
|
138935
139009
|
alive = /* @__PURE__ */ new WeakSet();
|
|
138936
139010
|
quality;
|
|
138937
139011
|
context;
|
|
139012
|
+
/** Ordinary Chrome user agent learned by the last launch, so the next one starts with it. */
|
|
139013
|
+
userAgent;
|
|
138938
139014
|
idleSince = Date.now();
|
|
138939
139015
|
sweeper;
|
|
138940
139016
|
closed = !1;
|
|
@@ -138981,8 +139057,9 @@ Connection: close\r
|
|
|
138981
139057
|
if (this.closed) return Promise.reject(new Error("The Web server is stopping."));
|
|
138982
139058
|
let pending = this.context ??= launch(
|
|
138983
139059
|
this.options.profileDirectory,
|
|
138984
|
-
this.quality.deviceScale
|
|
138985
|
-
|
|
139060
|
+
this.quality.deviceScale,
|
|
139061
|
+
this.userAgent
|
|
139062
|
+
).then(({ context, userAgent }) => (this.userAgent = userAgent, context.on("page", (page) => {
|
|
138986
139063
|
this.popup(page);
|
|
138987
139064
|
}), context.on("close", () => {
|
|
138988
139065
|
this.context === pending && (this.context = void 0);
|
|
@@ -139025,26 +139102,38 @@ Connection: close\r
|
|
|
139025
139102
|
});
|
|
139026
139103
|
}
|
|
139027
139104
|
};
|
|
139028
|
-
async function launch(profileDirectory, deviceScale) {
|
|
139105
|
+
async function launch(profileDirectory, deviceScale, knownUserAgent) {
|
|
139029
139106
|
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)
|
|
139107
|
+
for (let candidate of candidates) {
|
|
139108
|
+
let open13 = (userAgent) => chromium.launchPersistentContext(profileDirectory, {
|
|
139109
|
+
...candidate,
|
|
139110
|
+
headless: !0,
|
|
139111
|
+
viewport: null,
|
|
139112
|
+
acceptDownloads: !1,
|
|
139113
|
+
...userAgent === void 0 ? {} : { userAgent },
|
|
139114
|
+
args: [
|
|
139115
|
+
`--force-device-scale-factor=${String(deviceScale)}`,
|
|
139116
|
+
"--disable-blink-features=AutomationControlled"
|
|
139117
|
+
]
|
|
139118
|
+
});
|
|
139031
139119
|
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;
|
|
139120
|
+
let context = await open13(knownUserAgent), userAgent = await ordinaryUserAgent(context);
|
|
139121
|
+
return userAgent !== knownUserAgent && (await context.close(), context = await open13(userAgent)), await Promise.all(context.pages().map((page) => page.close())), { context, userAgent };
|
|
139040
139122
|
} catch (error62) {
|
|
139041
139123
|
failure3 = error62;
|
|
139042
139124
|
}
|
|
139125
|
+
}
|
|
139043
139126
|
throw new Error(
|
|
139044
139127
|
`No usable browser on the CodexHost machine: install Chrome or Edge, or set CODEXHOST_BROWSER_EXECUTABLE. (${failure3 instanceof Error ? failure3.message.split(`
|
|
139045
139128
|
`)[0] ?? "" : String(failure3)})`
|
|
139046
139129
|
);
|
|
139047
139130
|
}
|
|
139131
|
+
async function ordinaryUserAgent(context) {
|
|
139132
|
+
let cdp = await context.browser()?.newBrowserCDPSession();
|
|
139133
|
+
if (cdp === void 0) return;
|
|
139134
|
+
let { userAgent } = await cdp.send("Browser.getVersion");
|
|
139135
|
+
return await cdp.detach(), userAgent.replace("HeadlessChrome/", "Chrome/");
|
|
139136
|
+
}
|
|
139048
139137
|
|
|
139049
139138
|
// packages/web-server/src/misc.ts
|
|
139050
139139
|
import { existsSync as existsSync11, mkdirSync as mkdirSync6, readdirSync as readdirSync3, statSync as statSync7 } from "node:fs";
|
|
@@ -139596,7 +139685,7 @@ var Workspaces = class {
|
|
|
139596
139685
|
nativeRoots = /* @__PURE__ */ new Map();
|
|
139597
139686
|
nativeRootOwners = /* @__PURE__ */ new Map();
|
|
139598
139687
|
legacyAssignments = {};
|
|
139599
|
-
followers = /* @__PURE__ */ new
|
|
139688
|
+
followers = /* @__PURE__ */ new Map();
|
|
139600
139689
|
referenceGroups;
|
|
139601
139690
|
referenceProjectless = /* @__PURE__ */ new Set();
|
|
139602
139691
|
referencePins;
|
|
@@ -139647,8 +139736,9 @@ var Workspaces = class {
|
|
|
139647
139736
|
remoteProjectId(sessionId) {
|
|
139648
139737
|
return this.state.remoteProjectIds?.[sessionId];
|
|
139649
139738
|
}
|
|
139650
|
-
broadcast(frame) {
|
|
139651
|
-
for (let sink of this.followers)
|
|
139739
|
+
broadcast(frame, sectionCapability) {
|
|
139740
|
+
for (let [sink, capable] of this.followers)
|
|
139741
|
+
(sectionCapability === void 0 || capable === sectionCapability) && sink.push(frame);
|
|
139652
139742
|
}
|
|
139653
139743
|
touch(workspace) {
|
|
139654
139744
|
workspace.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), this.save();
|
|
@@ -139836,44 +139926,44 @@ var Workspaces = class {
|
|
|
139836
139926
|
}
|
|
139837
139927
|
/** Unmodified official snapshot and the projection delivered to Web clients. */
|
|
139838
139928
|
officialThreadSections;
|
|
139839
|
-
|
|
139840
|
-
projectSectionCoverage = /* @__PURE__ */ new Map();
|
|
139929
|
+
officialThreadSectionsV1;
|
|
139841
139930
|
referenceThreadSections = [];
|
|
139931
|
+
legacyThreadSections = [];
|
|
139932
|
+
referenceThreadSectionsV1;
|
|
139933
|
+
referenceSectionWorkspaceIdsDirty = !1;
|
|
139842
139934
|
hasThreadSection(id2) {
|
|
139843
139935
|
return this.referenceThreadSections.some((section) => section.id === id2);
|
|
139844
139936
|
}
|
|
139937
|
+
sectionMemberIds() {
|
|
139938
|
+
return new Set(this.referenceThreadSections.flatMap(({ threadIds }) => threadIds));
|
|
139939
|
+
}
|
|
139845
139940
|
/**
|
|
139846
139941
|
* Publish native sections. Desktop's project members become the Workspaces of their root
|
|
139847
139942
|
* folders, so call this after the project roots are synced into Workspaces.
|
|
139848
139943
|
*/
|
|
139849
|
-
setReferenceThreadSections(sections, projects = [], sectionProjects = {}) {
|
|
139850
|
-
|
|
139944
|
+
setReferenceThreadSections(sections, projects = [], sectionProjects = {}, threadSectionsV1) {
|
|
139945
|
+
if (!sections) {
|
|
139946
|
+
this.officialThreadSectionsV1 = void 0, this.publishProjectSections();
|
|
139947
|
+
return;
|
|
139948
|
+
}
|
|
139949
|
+
let paths2 = this.nativeWorkspaces ? void 0 : sectionRootPaths(
|
|
139851
139950
|
projects,
|
|
139852
139951
|
sectionProjects,
|
|
139853
139952
|
sections.map((section) => section.id)
|
|
139854
139953
|
), next = sections.map((section) => {
|
|
139855
|
-
|
|
139856
|
-
let
|
|
139857
|
-
|
|
139858
|
-
|
|
139859
|
-
});
|
|
139860
|
-
return workspaceIds2.length > 0 ? { ...section, workspaceIds: workspaceIds2 } : { ...section };
|
|
139861
|
-
}
|
|
139862
|
-
let workspaceIds = (paths2.get(section.id) ?? []).flatMap((path7) => {
|
|
139954
|
+
let workspaceIds = this.nativeWorkspaces ? (sectionProjects[section.id] ?? []).flatMap((id2) => {
|
|
139955
|
+
let workspace = this.nativeWorkspaces?.find((item) => item.projectId === id2);
|
|
139956
|
+
return workspace ? [workspace.workspaceId] : [];
|
|
139957
|
+
}) : (paths2?.get(section.id) ?? []).flatMap((path7) => {
|
|
139863
139958
|
let workspace = this.byPath(path7);
|
|
139864
139959
|
return workspace ? [workspace.workspaceId] : [];
|
|
139865
139960
|
});
|
|
139866
139961
|
return workspaceIds.length > 0 ? { ...section, workspaceIds } : { ...section };
|
|
139867
|
-
}), saved = this.state.projectSectionOverrides, registered = this.nativeWorkspaces && new Set(this.nativeWorkspaces.map((item) => item.workspaceId))
|
|
139962
|
+
}), saved = this.state.projectSectionOverrides, registered = this.nativeWorkspaces && new Set(this.nativeWorkspaces.map((item) => item.workspaceId));
|
|
139868
139963
|
if (registered) {
|
|
139869
139964
|
let located = new Set(next.flatMap((section) => section.workspaceIds ?? []));
|
|
139870
139965
|
for (let section of next) {
|
|
139871
|
-
if (Object.hasOwn(sectionProjects, section.id))
|
|
139872
|
-
coverage.set(section.id, registered);
|
|
139873
|
-
continue;
|
|
139874
|
-
}
|
|
139875
|
-
let lastRead = this.projectSectionCoverage.get(section.id);
|
|
139876
|
-
lastRead && coverage.set(section.id, lastRead);
|
|
139966
|
+
if (Object.hasOwn(sectionProjects, section.id)) continue;
|
|
139877
139967
|
let previous = this.officialThreadSections?.find((item) => item.id === section.id)?.workspaceIds ?? [], anchors = Object.entries(saved ?? {}).flatMap(
|
|
139878
139968
|
([id2, placement]) => placement.official === section.id ? [id2] : []
|
|
139879
139969
|
), retained = [.../* @__PURE__ */ new Set([...previous, ...anchors])].filter(
|
|
@@ -139893,7 +139983,7 @@ var Workspaces = class {
|
|
|
139893
139983
|
);
|
|
139894
139984
|
Object.keys(valid2).length !== Object.keys(saved).length && this.saveProjectSections(valid2);
|
|
139895
139985
|
}
|
|
139896
|
-
this.officialThreadSections = next, this.
|
|
139986
|
+
this.officialThreadSections = next, this.referenceSectionWorkspaceIdsDirty = !1, this.officialThreadSectionsV1 = threadSectionsV1, this.publishProjectSections();
|
|
139897
139987
|
}
|
|
139898
139988
|
projectSection(sections, workspaceId) {
|
|
139899
139989
|
return sections.find((section) => section.workspaceIds?.includes(workspaceId))?.id ?? null;
|
|
@@ -139902,26 +139992,56 @@ var Workspaces = class {
|
|
|
139902
139992
|
let state2 = { ...this.state };
|
|
139903
139993
|
Object.keys(overrides).length ? state2.projectSectionOverrides = overrides : delete state2.projectSectionOverrides, this.data.writeJson(FILE2, state2), this.state = state2;
|
|
139904
139994
|
}
|
|
139995
|
+
/** A move cannot change definitions or project membership. */
|
|
139996
|
+
applyThreadSectionMove(sections, threadSectionsV1, movedId) {
|
|
139997
|
+
let current = this.officialThreadSections ?? [];
|
|
139998
|
+
if (this.referenceSectionWorkspaceIdsDirty || threadSectionsV1 !== this.officialThreadSectionsV1 || sections.length !== current.length || !sections.every((section, i) => {
|
|
139999
|
+
let previous = current[i];
|
|
140000
|
+
return previous?.id === section.id && previous.name === section.name && JSON.stringify(previous.appearance) === JSON.stringify(section.appearance);
|
|
140001
|
+
}))
|
|
140002
|
+
return !1;
|
|
140003
|
+
let remaining = /* @__PURE__ */ new Set();
|
|
140004
|
+
if (movedId !== void 0)
|
|
140005
|
+
for (let { threadIds } of current)
|
|
140006
|
+
for (let id2 of threadIds) id2 !== movedId && remaining.add(id2);
|
|
140007
|
+
let seen = /* @__PURE__ */ new Set();
|
|
140008
|
+
for (let { threadIds } of sections)
|
|
140009
|
+
for (let id2 of threadIds) {
|
|
140010
|
+
if (seen.has(id2) || movedId !== void 0 && id2 !== movedId && !remaining.delete(id2))
|
|
140011
|
+
return !1;
|
|
140012
|
+
seen.add(id2);
|
|
140013
|
+
}
|
|
140014
|
+
return remaining.size !== 0 ? !1 : (this.officialThreadSections = sections.map((section, i) => {
|
|
140015
|
+
let workspaceIds = current[i]?.workspaceIds;
|
|
140016
|
+
return workspaceIds === void 0 ? section : { ...section, workspaceIds };
|
|
140017
|
+
}), this.publishProjectSections(), !0);
|
|
140018
|
+
}
|
|
139905
140019
|
publishProjectSections() {
|
|
139906
140020
|
let official = this.officialThreadSections ?? [], overrides = this.nativeWorkspaces ? this.state.projectSectionOverrides : void 0, next = overrides ? official.map(({ workspaceIds, ...section }) => {
|
|
139907
140021
|
let ids = (workspaceIds ?? []).filter((id2) => !Object.hasOwn(overrides, id2));
|
|
139908
140022
|
for (let [id2, placement] of Object.entries(overrides))
|
|
139909
140023
|
placement.target === section.id && ids.push(id2);
|
|
139910
140024
|
return ids.length ? { ...section, workspaceIds: ids } : section;
|
|
139911
|
-
}) : official
|
|
139912
|
-
|
|
140025
|
+
}) : official, threadSectionsV1 = this.officialThreadSectionsV1, legacy2 = next.some((section) => section.appearance !== void 0) ? next.map((section) => {
|
|
140026
|
+
let legacySection = { ...section };
|
|
140027
|
+
return delete legacySection.appearance, legacySection;
|
|
140028
|
+
}) : next, projected = threadSectionsV1 ? next : legacy2;
|
|
140029
|
+
if (threadSectionsV1 === this.referenceThreadSectionsV1 && JSON.stringify(projected) === JSON.stringify(this.referenceThreadSections))
|
|
140030
|
+
return;
|
|
140031
|
+
let legacyChanged = JSON.stringify(legacy2) !== JSON.stringify(this.legacyThreadSections);
|
|
140032
|
+
this.referenceThreadSections = projected, this.referenceThreadSectionsV1 = threadSectionsV1, this.legacyThreadSections = legacy2, this.broadcast(
|
|
140033
|
+
{
|
|
140034
|
+
type: "threadSections",
|
|
140035
|
+
threadSections: projected,
|
|
140036
|
+
...threadSectionsV1 ? { [THREAD_SECTION_CAPABILITY]: !0 } : {}
|
|
140037
|
+
},
|
|
140038
|
+
!0
|
|
140039
|
+
), legacyChanged && this.broadcast({ type: "threadSections", threadSections: legacy2 }, !1);
|
|
139913
140040
|
}
|
|
139914
140041
|
moveWorkspaceToSection(workspaceId, sectionId) {
|
|
139915
140042
|
if (typeof workspaceId != "string" || !this.officialThreadSections || !this.nativeWorkspaces?.some((workspace) => workspace.workspaceId === workspaceId) || !(sectionId === null || typeof sectionId == "string" && this.hasThreadSection(sectionId)))
|
|
139916
140043
|
throw new SessionRuntimeError("workspace/section-invalid", "Unknown local project or sidebar section.");
|
|
139917
140044
|
let official = this.projectSection(this.officialThreadSections, workspaceId);
|
|
139918
|
-
if (official === null && !this.state.projectSectionOverrides?.[workspaceId] && this.officialThreadSections.some(
|
|
139919
|
-
(section) => !this.projectSectionCoverage.get(section.id)?.has(workspaceId)
|
|
139920
|
-
))
|
|
139921
|
-
throw new SessionRuntimeError(
|
|
139922
|
-
"workspace/section-invalid",
|
|
139923
|
-
"The project's current sidebar section is unknown. Refresh the sidebar and try again."
|
|
139924
|
-
);
|
|
139925
140045
|
if (this.projectSection(this.referenceThreadSections, workspaceId) !== sectionId) {
|
|
139926
140046
|
let overrides = Object.fromEntries(
|
|
139927
140047
|
Object.entries(this.state.projectSectionOverrides ?? {}).filter(
|
|
@@ -140119,7 +140239,7 @@ var Workspaces = class {
|
|
|
140119
140239
|
),
|
|
140120
140240
|
...displayOrder !== void 0 ? { displayOrder } : {}
|
|
140121
140241
|
};
|
|
140122
|
-
return this.data.writeJson(FILE2, state2), this.state = state2, this.broadcast({ type: "upsert", workspace }), this.broadcast({
|
|
140242
|
+
return this.data.writeJson(FILE2, state2), this.state = state2, this.referenceProjectRoots.has(absolute2) && (this.referenceSectionWorkspaceIdsDirty = !0), this.broadcast({ type: "upsert", workspace }), this.broadcast({
|
|
140123
140243
|
type: "order",
|
|
140124
140244
|
workspaceIds: this.list().map((item) => item.workspaceId)
|
|
140125
140245
|
}), { workspace, created: !0 };
|
|
@@ -140274,7 +140394,13 @@ var Workspaces = class {
|
|
|
140274
140394
|
...nextDisplayOrder && nextDisplayOrder.length > 0 ? { displayOrder: nextDisplayOrder } : {},
|
|
140275
140395
|
...Object.keys(nextPinnedOverrides).length > 0 ? { pinnedWorkspaceOverrides: nextPinnedOverrides } : {}
|
|
140276
140396
|
};
|
|
140277
|
-
return this.data.writeJson(FILE2, state2), this.state = state2, this.broadcast({ type: "remove", workspaceId: request3.workspaceId }), this.publishPinnedWorkspaces(),
|
|
140397
|
+
return this.data.writeJson(FILE2, state2), this.state = state2, this.broadcast({ type: "remove", workspaceId: request3.workspaceId }), this.publishPinnedWorkspaces(), this.officialThreadSections?.some(
|
|
140398
|
+
({ workspaceIds }) => workspaceIds?.includes(workspace.workspaceId)
|
|
140399
|
+
) && (this.officialThreadSections = this.officialThreadSections.map((section) => {
|
|
140400
|
+
if (!section.workspaceIds?.includes(workspace.workspaceId)) return section;
|
|
140401
|
+
let { workspaceIds, ...rest } = section, remaining = workspaceIds.filter((id2) => id2 !== workspace.workspaceId);
|
|
140402
|
+
return remaining.length ? { ...rest, workspaceIds: remaining } : rest;
|
|
140403
|
+
}), this.publishProjectSections()), { deleted: !0 };
|
|
140278
140404
|
}), rpc2.register("workspace/moveWorkspaceToSection", async (args) => {
|
|
140279
140405
|
let request3 = requestOf(args);
|
|
140280
140406
|
return this.moveWorkspaceToSection(request3?.workspaceId, request3?.sectionId);
|
|
@@ -140312,14 +140438,16 @@ var Workspaces = class {
|
|
|
140312
140438
|
), rpc2.register("workspace/deleteSession", (args) => {
|
|
140313
140439
|
let sessionId = String(requestOf(args).sessionId ?? "");
|
|
140314
140440
|
return sessionId && this.forgetSession(sessionId), {};
|
|
140315
|
-
}), rpc2.register("workspace/pinSession", setMembership("pinnedSessionIds", "pinned", !0)), rpc2.register("workspace/unpinSession", setMembership("pinnedSessionIds", "pinned", !1)), streams2.register("workspace/follow", (
|
|
140316
|
-
|
|
140441
|
+
}), rpc2.register("workspace/pinSession", setMembership("pinnedSessionIds", "pinned", !0)), rpc2.register("workspace/unpinSession", setMembership("pinnedSessionIds", "pinned", !1)), streams2.register("workspace/follow", (args, sink) => {
|
|
140442
|
+
let capable = Object.hasOwn(args, THREAD_SECTION_CAPABILITY) && args[THREAD_SECTION_CAPABILITY] === !0;
|
|
140443
|
+
this.followers.set(sink, capable), sink.onClose(() => this.followers.delete(sink)), sink.push({
|
|
140317
140444
|
type: "baseline",
|
|
140318
140445
|
value: {
|
|
140319
140446
|
items: this.list(),
|
|
140320
140447
|
pinnedSessionIds: this.pinnedSessionIds(),
|
|
140321
140448
|
pinnedWorkspaceIds: this.pinnedWorkspaceIds(),
|
|
140322
|
-
threadSections: this.referenceThreadSections,
|
|
140449
|
+
threadSections: capable ? this.referenceThreadSections : this.legacyThreadSections,
|
|
140450
|
+
...capable && this.referenceThreadSectionsV1 ? { [THREAD_SECTION_CAPABILITY]: !0 } : {},
|
|
140323
140451
|
archivedSessionIds: this.archivedSessionIds(),
|
|
140324
140452
|
...this.referenceOnlyDefault ? { canStartProjectless: !0 } : {}
|
|
140325
140453
|
}
|
|
@@ -140336,6 +140464,102 @@ var Workspaces = class {
|
|
|
140336
140464
|
}
|
|
140337
140465
|
};
|
|
140338
140466
|
|
|
140467
|
+
// packages/web-server/src/ch-native-goal.ts
|
|
140468
|
+
var goalUsage = "/goal [<objective> | edit <objective> | pause | resume | clear]", goalCommand = {
|
|
140469
|
+
definitionId: "@deepseek-ai/dsh-command-goal",
|
|
140470
|
+
name: "goal",
|
|
140471
|
+
description: "View or manage this thread's goal",
|
|
140472
|
+
input: { hint: goalUsage.slice(6) }
|
|
140473
|
+
};
|
|
140474
|
+
function parseGoalArguments(text4) {
|
|
140475
|
+
if (!text4) return { action: "get" };
|
|
140476
|
+
let [, verb, rest] = /^(\S+)(?:\s+([\s\S]*))?$/u.exec(text4) ?? [], action = verb?.toLowerCase(), value = rest?.trim() ?? "";
|
|
140477
|
+
switch (action) {
|
|
140478
|
+
case "pause":
|
|
140479
|
+
case "resume":
|
|
140480
|
+
case "clear":
|
|
140481
|
+
if (!value) return { action };
|
|
140482
|
+
break;
|
|
140483
|
+
case "edit":
|
|
140484
|
+
if (value) return { action: "edit", objective: value };
|
|
140485
|
+
throw new SessionRuntimeError(
|
|
140486
|
+
"goal/invalid-arguments",
|
|
140487
|
+
"Provide a new objective: /goal edit <objective>"
|
|
140488
|
+
);
|
|
140489
|
+
default:
|
|
140490
|
+
return { action: "create", objective: text4 };
|
|
140491
|
+
}
|
|
140492
|
+
throw new SessionRuntimeError("goal/invalid-arguments", `Usage: ${goalUsage}`);
|
|
140493
|
+
}
|
|
140494
|
+
var statusLabels = {
|
|
140495
|
+
active: "active",
|
|
140496
|
+
paused: "paused",
|
|
140497
|
+
blocked: "stalled",
|
|
140498
|
+
usageLimited: "usage limited",
|
|
140499
|
+
budgetLimited: "limited by budget",
|
|
140500
|
+
complete: "complete"
|
|
140501
|
+
};
|
|
140502
|
+
function goalReceipt(goal, cleared) {
|
|
140503
|
+
if (!goal)
|
|
140504
|
+
return cleared ? "Goal cleared." : "No goal set for this thread. Run /goal <objective> to create one.";
|
|
140505
|
+
let budget = goal.tokenBudget == null ? "" : ` / ${goal.tokenBudget}`;
|
|
140506
|
+
return `Goal ${statusLabels[goal.status]}
|
|
140507
|
+
${goal.objective}
|
|
140508
|
+
Tokens: ${goal.tokensUsed}${budget} \xB7 Time: ${goal.timeUsedSeconds}s`;
|
|
140509
|
+
}
|
|
140510
|
+
var ChNativeGoals = class {
|
|
140511
|
+
constructor(host) {
|
|
140512
|
+
this.host = host;
|
|
140513
|
+
}
|
|
140514
|
+
host;
|
|
140515
|
+
states = /* @__PURE__ */ new WeakMap();
|
|
140516
|
+
state(view) {
|
|
140517
|
+
let state2 = this.states.get(view);
|
|
140518
|
+
return state2 || (state2 = { revision: 0, sequence: 0, loading: !1, dirty: !1 }, this.states.set(view, state2)), state2;
|
|
140519
|
+
}
|
|
140520
|
+
beginRead(view) {
|
|
140521
|
+
let state2 = this.state(view);
|
|
140522
|
+
return { revision: state2.revision, sequence: ++state2.sequence };
|
|
140523
|
+
}
|
|
140524
|
+
currentRead(view, read2) {
|
|
140525
|
+
let state2 = this.state(view);
|
|
140526
|
+
return read2.revision === state2.revision && read2.sequence === state2.sequence;
|
|
140527
|
+
}
|
|
140528
|
+
confirm(view, goal, read2) {
|
|
140529
|
+
read2 && !this.currentRead(view, read2) || (read2 || (this.state(view).revision += 1), view.log.setProjection("codexGoal", { goal, error: null }));
|
|
140530
|
+
}
|
|
140531
|
+
async refresh(view, current) {
|
|
140532
|
+
let state2 = this.state(view);
|
|
140533
|
+
if (state2.loading) {
|
|
140534
|
+
state2.dirty = !0;
|
|
140535
|
+
return;
|
|
140536
|
+
}
|
|
140537
|
+
state2.loading = !0, state2.dirty = !1;
|
|
140538
|
+
let read2 = this.beginRead(view);
|
|
140539
|
+
try {
|
|
140540
|
+
let { goal } = nativeCodexGoalResultSchema.parse(
|
|
140541
|
+
await this.host.request(NATIVE_CODEX_GOAL_METHOD, {
|
|
140542
|
+
threadId: view.thread.id,
|
|
140543
|
+
action: "get"
|
|
140544
|
+
})
|
|
140545
|
+
);
|
|
140546
|
+
if (goal && goal.threadId !== view.thread.id)
|
|
140547
|
+
throw new Error("Goal belongs to another Thread");
|
|
140548
|
+
current() && this.currentRead(view, read2) && view.log.setProjection("codexGoal", { goal, error: null });
|
|
140549
|
+
} catch (error62) {
|
|
140550
|
+
if (current() && this.currentRead(view, read2)) {
|
|
140551
|
+
let previous = view.log.projections.codexGoal;
|
|
140552
|
+
previous?.goal && view.log.setProjection("codexGoal", {
|
|
140553
|
+
goal: previous.goal,
|
|
140554
|
+
error: error62 instanceof Error ? error62.message : "Could not refresh the native goal"
|
|
140555
|
+
});
|
|
140556
|
+
}
|
|
140557
|
+
} finally {
|
|
140558
|
+
state2.loading = !1, state2.dirty && current() && this.refresh(view, current);
|
|
140559
|
+
}
|
|
140560
|
+
}
|
|
140561
|
+
};
|
|
140562
|
+
|
|
140339
140563
|
// packages/web-server/src/skills.ts
|
|
140340
140564
|
var WebSkills = class {
|
|
140341
140565
|
constructor(host, events2, resolve26) {
|
|
@@ -141140,7 +141364,7 @@ var ChSessions = class {
|
|
|
141140
141364
|
this.files = files2;
|
|
141141
141365
|
this.preferences = preferences2;
|
|
141142
141366
|
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) => {
|
|
141367
|
+
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
141368
|
if (id2 = this.id(id2), this.closed) throw new SessionRuntimeError("host/offline", "The Web connection is closed.");
|
|
141145
141369
|
if (this.drafts.has(id2)) return id2;
|
|
141146
141370
|
await this.owner(id2), this.rows.has(id2) || await this.refresh();
|
|
@@ -141172,9 +141396,11 @@ var ChSessions = class {
|
|
|
141172
141396
|
let view = this.threads.view(id2);
|
|
141173
141397
|
view && this.loadUsage(view, !0);
|
|
141174
141398
|
},
|
|
141175
|
-
catalog: async () => {
|
|
141176
|
-
await this.
|
|
141399
|
+
catalog: async (_reason, requireSections) => {
|
|
141400
|
+
await this.refreshing?.catch(() => {
|
|
141401
|
+
}), await this.refresh(void 0, !1, void 0, void 0, requireSections);
|
|
141177
141402
|
},
|
|
141403
|
+
sections: () => this.refreshSectionMove(),
|
|
141178
141404
|
archived: (id2, archived) => {
|
|
141179
141405
|
this.archiveOperations.delete(id2), this.updateArchive(id2, archived);
|
|
141180
141406
|
},
|
|
@@ -141218,11 +141444,11 @@ var ChSessions = class {
|
|
|
141218
141444
|
attachments;
|
|
141219
141445
|
fileInputs;
|
|
141220
141446
|
rows = /* @__PURE__ */ new Map();
|
|
141221
|
-
workspacePageRows = /* @__PURE__ */ new Set();
|
|
141222
141447
|
publishedCatalog;
|
|
141223
141448
|
handoffs = /* @__PURE__ */ new Map();
|
|
141224
141449
|
/** Loaded rows accumulate across partial official pages; drafts are not Host Threads. */
|
|
141225
141450
|
threads = new WebThreadStates();
|
|
141451
|
+
nativeGoals;
|
|
141226
141452
|
drafts = /* @__PURE__ */ new Map();
|
|
141227
141453
|
controls = /* @__PURE__ */ new Set();
|
|
141228
141454
|
refreshing;
|
|
@@ -141230,6 +141456,7 @@ var ChSessions = class {
|
|
|
141230
141456
|
refreshingArchives = !1;
|
|
141231
141457
|
refreshingArchiveChanges;
|
|
141232
141458
|
refreshingDeletedIds;
|
|
141459
|
+
archiveRevision = 0;
|
|
141233
141460
|
refreshingProjectAssignments;
|
|
141234
141461
|
archiveOperations = /* @__PURE__ */ new Map();
|
|
141235
141462
|
queueOperations = /* @__PURE__ */ new Map();
|
|
@@ -141296,12 +141523,12 @@ var ChSessions = class {
|
|
|
141296
141523
|
row && (row.projectId = projectId);
|
|
141297
141524
|
}
|
|
141298
141525
|
/** A `scope` reads an explicit page on until it reaches a Thread of that folder. */
|
|
141299
|
-
async refresh(timing, includeArchived = !1, cursor, workspace) {
|
|
141526
|
+
async refresh(timing, includeArchived = !1, cursor, workspace, requireSections = !1, sectionSnapshot) {
|
|
141300
141527
|
if (this.closed) return;
|
|
141301
141528
|
if (this.refreshing && (cursor !== void 0 || !this.refreshingCatalog || includeArchived !== this.refreshingArchives)) {
|
|
141302
141529
|
let stage = this.refreshingCatalog ? "catalog_wait" : "workspace_wait", pending2 = this.refreshing.catch(() => {
|
|
141303
141530
|
});
|
|
141304
|
-
return await (timing ? timing.measure(stage, () => pending2) : pending2), this.refresh(timing, includeArchived, cursor, workspace);
|
|
141531
|
+
return await (timing ? timing.measure(stage, () => pending2) : pending2), this.refresh(timing, includeArchived, cursor, workspace, requireSections);
|
|
141305
141532
|
}
|
|
141306
141533
|
let mode = this.refreshing ? "joined" : "started";
|
|
141307
141534
|
if (!this.refreshing) {
|
|
@@ -141317,18 +141544,83 @@ var ChSessions = class {
|
|
|
141317
141544
|
deletedIds,
|
|
141318
141545
|
cursor,
|
|
141319
141546
|
workspace
|
|
141320
|
-
) : this.listAll(
|
|
141547
|
+
) : this.listAll(
|
|
141548
|
+
this.refreshingTiming,
|
|
141549
|
+
includeArchived,
|
|
141550
|
+
archiveChanges,
|
|
141551
|
+
deletedIds,
|
|
141552
|
+
cursor,
|
|
141553
|
+
sectionSnapshot
|
|
141554
|
+
);
|
|
141321
141555
|
this.refreshing = load2.finally(() => {
|
|
141322
141556
|
this.refreshing = void 0, this.refreshingCatalog = !1, this.refreshingArchives = !1, this.refreshingArchiveChanges = void 0, this.refreshingDeletedIds = void 0, this.refreshingProjectAssignments = void 0, this.refreshingTiming = void 0;
|
|
141323
141557
|
});
|
|
141324
141558
|
}
|
|
141325
141559
|
let pending = this.refreshing, catalogTiming = this.refreshingTiming;
|
|
141326
141560
|
try {
|
|
141327
|
-
|
|
141561
|
+
let result = await (timing ? timing.measure("catalog_wait", () => pending) : pending);
|
|
141562
|
+
if (requireSections && result?.sectionFailure) throw result.sectionFailure.error;
|
|
141563
|
+
return result;
|
|
141328
141564
|
} finally {
|
|
141329
141565
|
timing && catalogTiming && (timing.catalog = { mode, ...catalogTiming.snapshot() });
|
|
141330
141566
|
}
|
|
141331
141567
|
}
|
|
141568
|
+
/** An invalidation cannot join a catalog read that began before it. */
|
|
141569
|
+
async refreshAfterCurrent() {
|
|
141570
|
+
await this.refreshing?.catch(() => {
|
|
141571
|
+
}), await this.refresh();
|
|
141572
|
+
}
|
|
141573
|
+
async readThreadSections() {
|
|
141574
|
+
let snapshot = clientThreadSectionsSchema.parse(
|
|
141575
|
+
await this.host.request("codexhost/thread/sections/list", {
|
|
141576
|
+
[THREAD_SECTION_CAPABILITY]: !0,
|
|
141577
|
+
requireComplete: !0
|
|
141578
|
+
})
|
|
141579
|
+
);
|
|
141580
|
+
if (snapshot.complete === !1)
|
|
141581
|
+
throw new SessionRuntimeError("host/sections-incomplete", "Complete Thread sections are unavailable.");
|
|
141582
|
+
return snapshot;
|
|
141583
|
+
}
|
|
141584
|
+
async refreshSectionMove(move) {
|
|
141585
|
+
for (; this.refreshing; ) await this.refreshing.catch(() => {
|
|
141586
|
+
});
|
|
141587
|
+
if (this.closed) return;
|
|
141588
|
+
let archiveRevision = this.archiveRevision, read2 = this.readThreadSections();
|
|
141589
|
+
this.refreshing = read2.then(
|
|
141590
|
+
() => {
|
|
141591
|
+
},
|
|
141592
|
+
() => {
|
|
141593
|
+
}
|
|
141594
|
+
);
|
|
141595
|
+
let snapshot;
|
|
141596
|
+
try {
|
|
141597
|
+
if (snapshot = await read2, this.closed) return;
|
|
141598
|
+
if (this.archiveRevision !== archiveRevision) snapshot = void 0;
|
|
141599
|
+
else if (this.applySectionMove(snapshot, move)) return;
|
|
141600
|
+
} catch (error62) {
|
|
141601
|
+
if (error62 instanceof SessionRuntimeError && (error62.code === "host/method-unavailable" || "hostCode" in error62.details && error62.details.hostCode === -32601)) snapshot = null;
|
|
141602
|
+
else if (!move) throw error62;
|
|
141603
|
+
} finally {
|
|
141604
|
+
this.refreshing = void 0;
|
|
141605
|
+
}
|
|
141606
|
+
await this.refresh(void 0, !1, void 0, void 0, !move, snapshot);
|
|
141607
|
+
}
|
|
141608
|
+
applySectionMove(snapshot, move) {
|
|
141609
|
+
let archived = new Set(this.workspaces.localArchivedSessionIds()), sections = [], capability = snapshot[THREAD_SECTION_CAPABILITY], referenced = this.workspaces.sectionMemberIds(), destination = null;
|
|
141610
|
+
for (let { id: id2, name: name2, appearance, threads } of snapshot.sections) {
|
|
141611
|
+
let threadIds = [];
|
|
141612
|
+
for (let thread3 of threads)
|
|
141613
|
+
if (thread3.archived !== !0) {
|
|
141614
|
+
if (typeof thread3.id != "string" || archived.has(thread3.id) || !referenced.has(thread3.id) || !this.publishedCatalog?.has(thread3.id) || !this.threads.hasHarness(thread3.id))
|
|
141615
|
+
return !1;
|
|
141616
|
+
threadIds.push(thread3.id), thread3.id === move?.threadId && (destination = id2);
|
|
141617
|
+
}
|
|
141618
|
+
sections.push(
|
|
141619
|
+
capability && appearance !== void 0 ? { id: id2, name: name2, appearance, threadIds } : { id: id2, name: name2, threadIds }
|
|
141620
|
+
);
|
|
141621
|
+
}
|
|
141622
|
+
return (!move || destination === move.sectionId) && this.workspaces.applyThreadSectionMove(sections, capability, move?.threadId);
|
|
141623
|
+
}
|
|
141332
141624
|
refreshPins() {
|
|
141333
141625
|
return this.pins.refresh().catch((error62) => (console.error("[session/list] native pins unavailable", error62), this.workspaces.localPinnedSessionIds()));
|
|
141334
141626
|
}
|
|
@@ -141361,8 +141653,8 @@ var ChSessions = class {
|
|
|
141361
141653
|
if (await this.tree.supplement(rows, async (id2) => {
|
|
141362
141654
|
let scanned = indexed.get(id2);
|
|
141363
141655
|
if (scanned && ownership.has(id2)) return scanned;
|
|
141364
|
-
let { thread:
|
|
141365
|
-
return ownership.set(id2, harnessId),
|
|
141656
|
+
let { thread: thread3, harnessId } = await this.readThread(id2);
|
|
141657
|
+
return ownership.set(id2, harnessId), thread3.archived === !0 && archived.add(id2), thread3;
|
|
141366
141658
|
}), this.closed || !this.workspaces.get(workspaceId)) return;
|
|
141367
141659
|
for (let [id2, row] of members2) {
|
|
141368
141660
|
if (deletedIds.has(id2)) {
|
|
@@ -141375,7 +141667,7 @@ var ChSessions = class {
|
|
|
141375
141667
|
continue;
|
|
141376
141668
|
}
|
|
141377
141669
|
let harnessId = ownership.get(id2);
|
|
141378
|
-
harnessId && (this.rows.
|
|
141670
|
+
harnessId && (this.rows.set(id2, row), this.threads.setHarness(id2, harnessId));
|
|
141379
141671
|
}
|
|
141380
141672
|
this.workspaces.addCatalogMembers(workspaceId, [...members2.keys()]);
|
|
141381
141673
|
let localArchives = new Set(this.workspaces.localArchivedSessionIds()), included = this.tree.withAncestors(members2.keys());
|
|
@@ -141396,36 +141688,46 @@ var ChSessions = class {
|
|
|
141396
141688
|
);
|
|
141397
141689
|
return { ...page, workspaceItems };
|
|
141398
141690
|
}
|
|
141399
|
-
async listAll(timing, includeArchived, archiveChanges, deletedIds, cursor) {
|
|
141400
|
-
let known = new Set(this.rows.keys()), [{ page: snapshot }, definitions, , sections] = await Promise.all([
|
|
141691
|
+
async listAll(timing, includeArchived, archiveChanges, deletedIds, cursor, sectionSnapshot) {
|
|
141692
|
+
let known = new Set(this.rows.keys()), sectionFailure, sectionsUnsupported = !1, [{ page: snapshot }, definitions, , sections] = await Promise.all([
|
|
141401
141693
|
readSessionPage(this.host, timing, includeArchived, cursor, () => this.refreshPins()),
|
|
141402
141694
|
timing.measure("project_definitions", () => this.host.projects([])),
|
|
141403
141695
|
timing.measure("thread_tree", () => this.tree.refresh()),
|
|
141404
141696
|
timing.measure("thread_sections", async () => {
|
|
141697
|
+
if (sectionSnapshot === null) {
|
|
141698
|
+
sectionsUnsupported = !0;
|
|
141699
|
+
return;
|
|
141700
|
+
}
|
|
141405
141701
|
try {
|
|
141406
|
-
return
|
|
141407
|
-
|
|
141408
|
-
)
|
|
141409
|
-
} catch {
|
|
141702
|
+
return sectionSnapshot ?? await this.readThreadSections();
|
|
141703
|
+
} catch (error62) {
|
|
141704
|
+
sectionsUnsupported = error62 instanceof SessionRuntimeError && (error62.code === "host/method-unavailable" || "hostCode" in error62.details && error62.details.hostCode === -32601), sectionsUnsupported || (sectionFailure = { error: error62 });
|
|
141410
141705
|
return;
|
|
141411
141706
|
}
|
|
141412
141707
|
})
|
|
141413
141708
|
]);
|
|
141414
141709
|
if (this.closed) return;
|
|
141415
|
-
let found = new Map(snapshot.threads.map((row) => [row.id, row])), snapshotArchives = new Set(snapshot.archivedThreadIds), archivedIds = new Set(this.workspaces.localArchivedSessionIds());
|
|
141710
|
+
let found = new Map(snapshot.threads.map((row) => [row.id, row])), headIds = cursor === void 0 && !includeArchived ? this.tree.withAncestors(found.keys()) : null, snapshotArchives = new Set(snapshot.archivedThreadIds), archivedIds = new Set(this.workspaces.localArchivedSessionIds());
|
|
141416
141711
|
for (let id2 of snapshotArchives) archivedIds.add(id2);
|
|
141417
141712
|
for (let id2 of found.keys()) snapshotArchives.has(id2) || archivedIds.delete(id2);
|
|
141418
|
-
let ownership = catalogOwnership(snapshot, found),
|
|
141713
|
+
let ownership = catalogOwnership(snapshot, found), threadSectionsV1 = sections?.[THREAD_SECTION_CAPABILITY], threadSections = sections?.sections.map(({ id: id2, name: name2, appearance, threads }) => {
|
|
141419
141714
|
let threadIds = [];
|
|
141420
|
-
for (let
|
|
141421
|
-
|
|
141422
|
-
|
|
141423
|
-
|
|
141424
|
-
|
|
141715
|
+
for (let thread3 of threads) {
|
|
141716
|
+
let threadId = thread3.id;
|
|
141717
|
+
if (!(typeof threadId != "string" || thread3.archived === !0)) {
|
|
141718
|
+
if (found.has(threadId)) {
|
|
141719
|
+
if (!ownership.has(threadId)) continue;
|
|
141720
|
+
} else if (thread3.modelProvider === "codexhost") {
|
|
141721
|
+
let harnessId = cursor === void 0 ? void 0 : this.threads.harnessId(threadId);
|
|
141722
|
+
if (!harnessId || harnessId === "codex") continue;
|
|
141723
|
+
} else {
|
|
141724
|
+
let row = thread3;
|
|
141725
|
+
found.set(threadId, row), ownership.set(threadId, "codex");
|
|
141425
141726
|
}
|
|
141426
|
-
|
|
141727
|
+
thread3.archived === !1 && !snapshotArchives.has(threadId) && archivedIds.delete(threadId), threadIds.push(threadId);
|
|
141427
141728
|
}
|
|
141428
|
-
|
|
141729
|
+
}
|
|
141730
|
+
return threadSectionsV1 && appearance !== void 0 ? { id: id2, name: name2, threadIds, appearance } : { id: id2, name: name2, threadIds };
|
|
141429
141731
|
});
|
|
141430
141732
|
timing.count("ownershipIds", ownership.size), timing.count(
|
|
141431
141733
|
"archivedRows",
|
|
@@ -141440,11 +141742,9 @@ var ChSessions = class {
|
|
|
141440
141742
|
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
141743
|
}
|
|
141442
141744
|
await this.tree.supplement(rows, async (id2) => {
|
|
141443
|
-
let { thread:
|
|
141444
|
-
return ownership.set(id2, harnessId),
|
|
141745
|
+
let { thread: thread3, harnessId } = await this.readThread(id2);
|
|
141746
|
+
return ownership.set(id2, harnessId), thread3.archived === !0 && archivedIds.add(id2), thread3;
|
|
141445
141747
|
});
|
|
141446
|
-
for (let id2 of deletedIds)
|
|
141447
|
-
rows.delete(id2), ownership.delete(id2), archivedIds.delete(id2);
|
|
141448
141748
|
let assignments = await timing.measure(
|
|
141449
141749
|
"projects",
|
|
141450
141750
|
() => this.host.projects([...rows.keys()])
|
|
@@ -141453,28 +141753,48 @@ var ChSessions = class {
|
|
|
141453
141753
|
projects: definitions.projects,
|
|
141454
141754
|
...pinnedProjects !== void 0 ? { pinnedProjects } : {}
|
|
141455
141755
|
};
|
|
141456
|
-
if (
|
|
141457
|
-
|
|
141458
|
-
|
|
141459
|
-
|
|
141460
|
-
|
|
141461
|
-
|
|
141462
|
-
|
|
141463
|
-
|
|
141464
|
-
|
|
141465
|
-
|
|
141466
|
-
|
|
141467
|
-
|
|
141468
|
-
|
|
141469
|
-
|
|
141470
|
-
timing
|
|
141471
|
-
|
|
141472
|
-
|
|
141473
|
-
|
|
141474
|
-
|
|
141475
|
-
|
|
141476
|
-
|
|
141756
|
+
if (this.closed) return;
|
|
141757
|
+
for (let id2 of deletedIds)
|
|
141758
|
+
rows.delete(id2), ownership.delete(id2), archivedIds.delete(id2);
|
|
141759
|
+
for (let [id2, projectId] of this.refreshingProjectAssignments ?? []) {
|
|
141760
|
+
let row = rows.get(id2);
|
|
141761
|
+
row && (row.projectId = projectId);
|
|
141762
|
+
}
|
|
141763
|
+
if (this.threads.replaceHarnesses(ownership), this.rows = rows, this.host.realtime && this.hostOnline && !this.closed && this.syncBackgroundRunningInteractions(), timing.count("visibleRows", rows.size), await this.syncWorkspace(timing, projects), this.closed) return;
|
|
141764
|
+
let projectedSections = threadSections && (!this.workspaces.usesNativeProjects || projects.nativeProjects) ? threadSections : void 0, before = this.publishedCatalog, sectionIds = projectedSections ? new Set(projectedSections.flatMap(({ threadIds }) => threadIds)) : this.workspaces.sectionMemberIds();
|
|
141765
|
+
if (!projectedSections)
|
|
141766
|
+
for (let id2 of sectionIds) before?.has(id2) || sectionIds.delete(id2);
|
|
141767
|
+
if (await timing.measure(
|
|
141768
|
+
"catalog_publish",
|
|
141769
|
+
() => this.publishCatalogChanges(
|
|
141770
|
+
timing,
|
|
141771
|
+
headIds,
|
|
141772
|
+
sectionIds,
|
|
141773
|
+
archivedIds,
|
|
141774
|
+
archiveChanges,
|
|
141775
|
+
deletedIds
|
|
141776
|
+
)
|
|
141777
|
+
), this.closed) return;
|
|
141778
|
+
if (projectedSections) {
|
|
141779
|
+
let archived = new Set(this.workspaces.localArchivedSessionIds());
|
|
141780
|
+
this.workspaces.setReferenceThreadSections(
|
|
141781
|
+
projectedSections.map((section) => ({
|
|
141782
|
+
...section,
|
|
141783
|
+
threadIds: section.threadIds.filter(
|
|
141784
|
+
(id2) => !archived.has(id2) && !deletedIds.has(id2) && this.publishedCatalog?.has(id2)
|
|
141785
|
+
)
|
|
141786
|
+
})),
|
|
141787
|
+
definitions.projects,
|
|
141788
|
+
definitions.sectionProjects,
|
|
141789
|
+
threadSectionsV1
|
|
141790
|
+
);
|
|
141791
|
+
} else (sectionsUnsupported || threadSections && !threadSectionsV1) && this.workspaces.setReferenceThreadSections(void 0);
|
|
141792
|
+
let pageIds = new Set(snapshot.threads.map(({ id: id2 }) => id2));
|
|
141793
|
+
for (let id2 of sectionIds) {
|
|
141794
|
+
let row = rows.get(id2);
|
|
141795
|
+
row && this.publishedCatalog?.has(id2) && (cursor === void 0 || !before?.has(id2)) && !pageIds.has(id2) && snapshot.threads.push(row);
|
|
141477
141796
|
}
|
|
141797
|
+
return this.catalogReadAt = Date.now(), { ...snapshot, sectionFailure };
|
|
141478
141798
|
}
|
|
141479
141799
|
async syncWorkspace(timing = new SessionListTiming(), snapshot) {
|
|
141480
141800
|
let projects = snapshot ?? await timing.measure("projects", () => this.host.projects([...this.rows.keys()]));
|
|
@@ -141545,33 +141865,51 @@ var ChSessions = class {
|
|
|
141545
141865
|
codexhostImportSource: row.codexhostImportSource ?? null
|
|
141546
141866
|
};
|
|
141547
141867
|
}
|
|
141548
|
-
async publishCatalogChanges(
|
|
141549
|
-
let before = this.publishedCatalog, next = new Map(
|
|
141550
|
-
|
|
141551
|
-
|
|
141552
|
-
|
|
141553
|
-
|
|
141554
|
-
|
|
141555
|
-
|
|
141556
|
-
|
|
141557
|
-
|
|
141558
|
-
let
|
|
141559
|
-
|
|
141560
|
-
|
|
141561
|
-
|
|
141562
|
-
|
|
141563
|
-
|
|
141564
|
-
|
|
141565
|
-
|
|
141566
|
-
|
|
141868
|
+
async publishCatalogChanges(timing, headIds, sectionIds, archivedIds, archiveChanges, deletedIds) {
|
|
141869
|
+
let before = this.publishedCatalog, next = /* @__PURE__ */ new Map(), changed = [];
|
|
141870
|
+
for (let row of this.rows.values()) {
|
|
141871
|
+
let priorKey = before?.get(row.id), sectionMember = sectionIds.has(row.id);
|
|
141872
|
+
if (!sectionMember) {
|
|
141873
|
+
if (headIds === null) {
|
|
141874
|
+
if (priorKey === void 0) continue;
|
|
141875
|
+
} else if (!headIds.has(row.id))
|
|
141876
|
+
continue;
|
|
141877
|
+
}
|
|
141878
|
+
let key = this.catalogKey(row);
|
|
141879
|
+
next.set(row.id, key), priorKey !== key && (before || sectionMember) && changed.push(row);
|
|
141880
|
+
}
|
|
141881
|
+
let summaries = await Promise.all(changed.map((row) => this.summary(row)));
|
|
141882
|
+
if (!this.closed) {
|
|
141883
|
+
for (let [id2, archived] of archiveChanges)
|
|
141884
|
+
archived ? archivedIds.add(id2) : archivedIds.delete(id2);
|
|
141885
|
+
for (let id2 of deletedIds)
|
|
141886
|
+
archivedIds.delete(id2), next.delete(id2);
|
|
141887
|
+
for (let id2 of archivedIds) next.delete(id2);
|
|
141888
|
+
timing.measureSync(
|
|
141889
|
+
"archive_sync",
|
|
141890
|
+
() => this.workspaces.setReferenceArchives([...archivedIds].sort())
|
|
141891
|
+
), this.publishedCatalog = next;
|
|
141892
|
+
for (let [id2, row] of this.rows) {
|
|
141893
|
+
let log46 = this.threads.view(id2)?.log;
|
|
141894
|
+
if (log46)
|
|
141567
141895
|
for (let [key, value] of Object.entries(this.catalogProjections(row)))
|
|
141568
|
-
|
|
141569
|
-
sink.push({ type: "projection", sessionId, key, value, seq: seq2 });
|
|
141896
|
+
log46.setProjection(key, value);
|
|
141570
141897
|
}
|
|
141571
|
-
|
|
141572
|
-
|
|
141573
|
-
|
|
141574
|
-
|
|
141898
|
+
if (this.controls.size > 0)
|
|
141899
|
+
for (let { sessionId } of summaries) {
|
|
141900
|
+
if (!next.has(sessionId)) continue;
|
|
141901
|
+
let row = this.rows.get(sessionId), seq2 = row ? this.threads.reserveDroppedProjectionSeq(sessionId) : void 0;
|
|
141902
|
+
if (!(!row || seq2 === void 0))
|
|
141903
|
+
for (let [key, value] of Object.entries(this.catalogProjections(row)))
|
|
141904
|
+
for (let sink of this.controls)
|
|
141905
|
+
sink.push({ type: "projection", sessionId, key, value, seq: seq2 });
|
|
141906
|
+
}
|
|
141907
|
+
for (let row of summaries)
|
|
141908
|
+
next.has(row.sessionId) && this.events.emit("api-session/added", row);
|
|
141909
|
+
if (before)
|
|
141910
|
+
for (let id2 of before.keys())
|
|
141911
|
+
this.rows.has(id2) || (this.handoffs.delete(id2), this.events.emit("api-session/removed", id2));
|
|
141912
|
+
}
|
|
141575
141913
|
}
|
|
141576
141914
|
async owner(id2) {
|
|
141577
141915
|
let resolved = this.id(id2);
|
|
@@ -141664,7 +142002,7 @@ var ChSessions = class {
|
|
|
141664
142002
|
let name2 = await this.catalog.name(harnessId);
|
|
141665
142003
|
if (this.threads.view(id2) !== view)
|
|
141666
142004
|
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;
|
|
142005
|
+
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
142006
|
}
|
|
141669
142007
|
loadUsage(view, force) {
|
|
141670
142008
|
let id2 = view.thread.id, active3 = this.threads.get(id2)?.usage;
|
|
@@ -141891,10 +142229,10 @@ var ChSessions = class {
|
|
|
141891
142229
|
);
|
|
141892
142230
|
draft.started = { thread: result.thread, harnessId: owner.harnessId };
|
|
141893
142231
|
}
|
|
141894
|
-
let { thread:
|
|
141895
|
-
if (draft.projectId &&
|
|
142232
|
+
let { thread: thread3, harnessId } = draft.started;
|
|
142233
|
+
if (draft.projectId && thread3.projectId !== draft.projectId) {
|
|
141896
142234
|
let updated = await this.host.request("thread/metadata/update", {
|
|
141897
|
-
threadId:
|
|
142235
|
+
threadId: thread3.id,
|
|
141898
142236
|
projectId: draft.projectId
|
|
141899
142237
|
});
|
|
141900
142238
|
if (updated.thread.projectId !== draft.projectId)
|
|
@@ -141902,9 +142240,9 @@ var ChSessions = class {
|
|
|
141902
142240
|
"workspace/assignment-unconfirmed",
|
|
141903
142241
|
"Codex did not confirm the conversation's project."
|
|
141904
142242
|
);
|
|
141905
|
-
|
|
142243
|
+
thread3.projectId = updated.thread.projectId, this.refreshingProjectAssignments?.set(thread3.id, draft.projectId);
|
|
141906
142244
|
}
|
|
141907
|
-
return draft.canonicalId =
|
|
142245
|
+
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.workspaces.isArchived(thread3.id) || 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
142246
|
}
|
|
141909
142247
|
/**
|
|
141910
142248
|
* Working directory of one Host-confirmed local Thread.
|
|
@@ -141933,8 +142271,8 @@ var ChSessions = class {
|
|
|
141933
142271
|
let id2 = this.id(sessionId);
|
|
141934
142272
|
if (!this.drafts.has(id2))
|
|
141935
142273
|
try {
|
|
141936
|
-
let { thread:
|
|
141937
|
-
return this.closed || signal?.aborted ? void 0 : (this.rows.set(
|
|
142274
|
+
let { thread: thread3, harnessId } = await this.readThread(id2);
|
|
142275
|
+
return this.closed || signal?.aborted ? void 0 : (this.rows.set(thread3.id, thread3), this.threads.setHarness(thread3.id, harnessId), thread3.cwd);
|
|
141938
142276
|
} catch {
|
|
141939
142277
|
return;
|
|
141940
142278
|
}
|
|
@@ -142013,7 +142351,7 @@ var ChSessions = class {
|
|
|
142013
142351
|
forgetDeleted(id2) {
|
|
142014
142352
|
this.refreshingDeletedIds?.add(id2), this.archiveOperations.delete(id2), this.queueOperations.delete(id2), this.titleRequests.delete(id2), this.syncedRunningInteractions.delete(id2);
|
|
142015
142353
|
let activeRead = this.interactionReads.get(id2);
|
|
142016
|
-
activeRead && (activeRead.cancelled = !0, activeRead.dirty = !1, this.interactionReads.delete(id2)), this.interactions?.clearSession(id2), this.
|
|
142354
|
+
activeRead && (activeRead.cancelled = !0, activeRead.dirty = !1, this.interactionReads.delete(id2)), this.interactions?.clearSession(id2), this.rows.delete(id2), this.handoffs.delete(id2), this.threads.delete(id2), this.tree.forget(id2);
|
|
142017
142355
|
let archived = this.workspaces.localArchivedSessionIds();
|
|
142018
142356
|
archived.includes(id2) && this.workspaces.setReferenceArchives(archived.filter((item) => item !== id2));
|
|
142019
142357
|
let pinned = this.workspaces.localPinnedSessionIds();
|
|
@@ -142030,9 +142368,9 @@ var ChSessions = class {
|
|
|
142030
142368
|
});
|
|
142031
142369
|
}
|
|
142032
142370
|
updateArchive(id2, archived) {
|
|
142033
|
-
this.refreshingArchiveChanges?.set(id2, archived);
|
|
142371
|
+
this.archiveRevision++, this.refreshingArchiveChanges?.set(id2, archived);
|
|
142034
142372
|
let ids = new Set(this.workspaces.localArchivedSessionIds());
|
|
142035
|
-
archived ? ids.add(id2) : ids.delete(id2), this.workspaces.setReferenceArchives([...ids].sort());
|
|
142373
|
+
archived ? (ids.add(id2), this.publishedCatalog?.delete(id2)) : ids.delete(id2), this.workspaces.setReferenceArchives([...ids].sort());
|
|
142036
142374
|
}
|
|
142037
142375
|
async setArchived(sessionId, archived) {
|
|
142038
142376
|
let id2 = this.id(sessionId), operation = /* @__PURE__ */ Symbol();
|
|
@@ -142044,8 +142382,8 @@ var ChSessions = class {
|
|
|
142044
142382
|
"Send the first message before archiving this Thread."
|
|
142045
142383
|
);
|
|
142046
142384
|
if (!this.threads.hasHarness(id2)) {
|
|
142047
|
-
let { thread:
|
|
142048
|
-
this.rows.set(id2,
|
|
142385
|
+
let { thread: thread3, harnessId } = await this.readThread(id2);
|
|
142386
|
+
this.rows.set(id2, thread3), this.threads.setHarness(id2, harnessId);
|
|
142049
142387
|
}
|
|
142050
142388
|
let owner = await this.owner(id2);
|
|
142051
142389
|
if (this.archiveOperations.get(id2) !== operation) return;
|
|
@@ -142068,16 +142406,16 @@ var ChSessions = class {
|
|
|
142068
142406
|
}
|
|
142069
142407
|
}
|
|
142070
142408
|
async readThread(id2) {
|
|
142071
|
-
let owner = await this.owner(id2), { thread:
|
|
142409
|
+
let owner = await this.owner(id2), { thread: thread3 } = await this.host.request(
|
|
142072
142410
|
"thread/read",
|
|
142073
142411
|
{
|
|
142074
142412
|
threadId: id2,
|
|
142075
142413
|
includeTurns: !1
|
|
142076
142414
|
}
|
|
142077
142415
|
);
|
|
142078
|
-
if (
|
|
142416
|
+
if (thread3.id !== id2 || owner.owner === "external" && thread3.modelProvider !== "codexhost")
|
|
142079
142417
|
throw new SessionRuntimeError("session/ownership-unconfirmed", "Thread identity was not confirmed.");
|
|
142080
|
-
return { thread:
|
|
142418
|
+
return { thread: thread3, harnessId: owner.harnessId };
|
|
142081
142419
|
}
|
|
142082
142420
|
register(rpc2, streams2) {
|
|
142083
142421
|
this.fileReferences.register(rpc2), this.fileInputs?.register(rpc2), rpc2.register("codexhost/turnDiffs", async (args) => {
|
|
@@ -142121,21 +142459,49 @@ var ChSessions = class {
|
|
|
142121
142459
|
return await this.pins.sync({ threadId: id2, pinned }), await this.refresh().catch(() => {
|
|
142122
142460
|
}), { pinnedSessionIds: this.workspaces.pinnedSessionIds() };
|
|
142123
142461
|
});
|
|
142462
|
+
for (let [method2, mutation] of [
|
|
142463
|
+
["workspace/createThreadSection", CLIENT_THREAD_SECTION_MUTATIONS.create],
|
|
142464
|
+
["workspace/updateThreadSection", CLIENT_THREAD_SECTION_MUTATIONS.update],
|
|
142465
|
+
["workspace/deleteThreadSection", CLIENT_THREAD_SECTION_MUTATIONS.delete]
|
|
142466
|
+
])
|
|
142467
|
+
rpc2.register(method2, async (args) => {
|
|
142468
|
+
let params = mutation.params.safeParse(requestOf(args));
|
|
142469
|
+
if (!params.success)
|
|
142470
|
+
throw new SessionRuntimeError("workspace/section-invalid", "Invalid Thread section request.");
|
|
142471
|
+
let value = await this.host.request(mutation.method, params.data).catch((error62) => {
|
|
142472
|
+
if (error62 instanceof SessionRuntimeError) {
|
|
142473
|
+
let { code, details } = error62, hostCode = "hostCode" in details ? details.hostCode : void 0;
|
|
142474
|
+
if (code === "host/disconnected" || code === "host/resync" || code === "remote/offline" || code === "host/rejected" && (hostCode === -32093 || hostCode === -32094))
|
|
142475
|
+
return { status: "unknown" };
|
|
142476
|
+
}
|
|
142477
|
+
throw error62;
|
|
142478
|
+
}), result = clientThreadSectionMutationResultSchema.safeParse(value);
|
|
142479
|
+
return await this.refreshAfterCurrent().catch(() => {
|
|
142480
|
+
}), result.success ? result.data : { status: "unknown" };
|
|
142481
|
+
});
|
|
142124
142482
|
rpc2.register("workspace/moveSessionToSection", async (args) => {
|
|
142125
142483
|
let input3 = requestOf(args), move = clientThreadSectionMoveSchema.safeParse({
|
|
142126
142484
|
threadId: input3.sessionId,
|
|
142127
|
-
sectionId: input3.sectionId
|
|
142485
|
+
sectionId: input3.sectionId,
|
|
142486
|
+
beforeThreadId: input3.beforeSessionId,
|
|
142487
|
+
expectedSourceSectionId: input3.expectedSourceSectionId
|
|
142128
142488
|
});
|
|
142129
142489
|
if (!move.success)
|
|
142130
142490
|
throw new SessionRuntimeError("workspace/section-invalid", "Invalid Thread section move.");
|
|
142131
|
-
let {
|
|
142132
|
-
if (
|
|
142491
|
+
let { sectionId, beforeThreadId, expectedSourceSectionId } = move.data, id2 = this.id(move.data.threadId), before = typeof beforeThreadId == "string" ? this.id(beforeThreadId) : beforeThreadId;
|
|
142492
|
+
if (typeof before == "string" && (sectionId === null || before === id2))
|
|
142493
|
+
throw new SessionRuntimeError("workspace/section-invalid", "Invalid Thread section anchor.");
|
|
142494
|
+
if (this.drafts.has(id2) || !this.threads.hasHarness(id2) || this.rows.get(id2)?.parentThreadId || this.workspaces.isArchived(id2) || this.workspaces.pinnedSessionIds().includes(id2) || sectionId !== null && !this.workspaces.hasThreadSection(sectionId))
|
|
142133
142495
|
throw new SessionRuntimeError(
|
|
142134
142496
|
"workspace/section-unavailable",
|
|
142135
142497
|
"This Thread or section is unavailable for a move."
|
|
142136
142498
|
);
|
|
142137
|
-
return await this.host.request("codexhost/thread/sections/move",
|
|
142138
|
-
|
|
142499
|
+
return await this.host.request("codexhost/thread/sections/move", {
|
|
142500
|
+
threadId: id2,
|
|
142501
|
+
sectionId,
|
|
142502
|
+
...before === void 0 ? {} : { beforeThreadId: before },
|
|
142503
|
+
...expectedSourceSectionId === void 0 ? {} : { expectedSourceSectionId }
|
|
142504
|
+
}), await this.refreshSectionMove({ threadId: id2, sectionId }).catch(() => {
|
|
142139
142505
|
}), { sectionId };
|
|
142140
142506
|
}), rpc2.register("session/list", async (args, context) => {
|
|
142141
142507
|
let {
|
|
@@ -142159,9 +142525,9 @@ var ChSessions = class {
|
|
|
142159
142525
|
if (id2.startsWith("draft-"))
|
|
142160
142526
|
throw new SessionRuntimeError("session/not-found", "Draft Session is no longer available.");
|
|
142161
142527
|
await Promise.all([this.tree.refresh(), this.refreshPins()]);
|
|
142162
|
-
let { thread:
|
|
142163
|
-
this.rows.set(
|
|
142164
|
-
let direct = /* @__PURE__ */ new Map([[
|
|
142528
|
+
let { thread: thread3, harnessId } = await this.readThread(id2);
|
|
142529
|
+
this.rows.set(thread3.id, thread3), this.threads.setHarness(thread3.id, harnessId);
|
|
142530
|
+
let direct = /* @__PURE__ */ new Map([[thread3.id, thread3]]);
|
|
142165
142531
|
return await this.tree.supplement(direct, async (ancestorId) => {
|
|
142166
142532
|
let ancestor = await this.readThread(ancestorId);
|
|
142167
142533
|
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 +142694,16 @@ var ChSessions = class {
|
|
|
142328
142694
|
"session/attachment-invalid",
|
|
142329
142695
|
"Shared CH input currently accepts text only."
|
|
142330
142696
|
);
|
|
142331
|
-
let draft = this.drafts.get(request3.sessionId)
|
|
142697
|
+
let draft = this.drafts.get(request3.sessionId);
|
|
142698
|
+
if (nativeCodexGoalInvocation.test(
|
|
142699
|
+
request3.content.filter((part) => part.type === "text").map((part) => part.text ?? "").join(`
|
|
142700
|
+
`).trim()
|
|
142701
|
+
) && await this.goalScope(request3.sessionId) !== "other")
|
|
142702
|
+
throw new SessionRuntimeError(
|
|
142703
|
+
"goal/command-required",
|
|
142704
|
+
"Submit /goal as a command on a local Codex Thread with native goals enabled."
|
|
142705
|
+
);
|
|
142706
|
+
let existingOwner = !draft || draft.canonicalId ? await this.owner(request3.sessionId) : void 0, steerTurnId;
|
|
142332
142707
|
if (request3.mode === "steer") {
|
|
142333
142708
|
let view = existingOwner && await this.view(request3.sessionId, !0), activeTurnId = view ? view.log.projections[WEB_ACTIVE_TURN_PROJECTION] : null;
|
|
142334
142709
|
if (!existingOwner || !view || typeof activeTurnId != "string" || request3.expectedTurnId !== void 0 && request3.expectedTurnId !== activeTurnId)
|
|
@@ -142665,6 +143040,32 @@ var ChSessions = class {
|
|
|
142665
143040
|
);
|
|
142666
143041
|
}, 6e4), this.idleViewTimer.unref();
|
|
142667
143042
|
}
|
|
143043
|
+
currentGoalView(view) {
|
|
143044
|
+
let id2 = view.thread.id, row = this.rows.get(id2) ?? view.thread;
|
|
143045
|
+
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;
|
|
143046
|
+
}
|
|
143047
|
+
async supportsDraftGoals() {
|
|
143048
|
+
return (await this.host.request(
|
|
143049
|
+
"experimentalFeature/list",
|
|
143050
|
+
{}
|
|
143051
|
+
)).data?.some((feature) => feature.name === "goals" && feature.enabled) === !0;
|
|
143052
|
+
}
|
|
143053
|
+
async goalScope(sessionId) {
|
|
143054
|
+
let draft = this.drafts.get(sessionId);
|
|
143055
|
+
if (draft && !draft.canonicalId)
|
|
143056
|
+
return draft.selection.provider !== "codex" ? "other" : this.closed || !this.hostOnline ? "unavailable" : "draft";
|
|
143057
|
+
let id2 = this.id(sessionId);
|
|
143058
|
+
if (!id2 || id2.startsWith("draft-") || id2.startsWith("web-remote:")) return "other";
|
|
143059
|
+
let harness2 = this.threads.harnessId(id2);
|
|
143060
|
+
if (!harness2 && this.hostOnline && !this.closed) {
|
|
143061
|
+
let reply = await this.host.request("codexhost/thread/ownership/list", { threadIds: [id2] }).catch(() => {
|
|
143062
|
+
}), owner = threadOwnershipSchema.safeParse(reply?.threads?.[0]);
|
|
143063
|
+
owner.success && owner.data.threadId === id2 && owner.data.owner === "codex" && (harness2 = "codex");
|
|
143064
|
+
}
|
|
143065
|
+
if (harness2 !== "codex") return "other";
|
|
143066
|
+
let row = this.rows.get(id2) ?? this.threads.view(id2)?.thread;
|
|
143067
|
+
return this.closed || !this.hostOnline || row?.parentThreadId || row?.archived || this.workspaces.isArchived(id2) || row?.canAcceptDirectInput === !1 ? "unavailable" : "local";
|
|
143068
|
+
}
|
|
142668
143069
|
registerCommands(rpc2) {
|
|
142669
143070
|
this.skills.register(rpc2);
|
|
142670
143071
|
let native2 = new ChHarnessCommands(this.host, async (sessionId) => {
|
|
@@ -142674,13 +143075,13 @@ var ChSessions = class {
|
|
|
142674
143075
|
if (this.closed || !this.hostOnline)
|
|
142675
143076
|
throw new SessionRuntimeError("host/offline", "The Host is disconnected.");
|
|
142676
143077
|
await this.owner(id2);
|
|
142677
|
-
let { thread:
|
|
143078
|
+
let { thread: thread3 } = await this.host.request("thread/read", {
|
|
142678
143079
|
threadId: id2,
|
|
142679
143080
|
includeTurns: !1
|
|
142680
143081
|
});
|
|
142681
|
-
if (
|
|
143082
|
+
if (thread3.id !== id2 || thread3.parentThreadId || thread3.canAcceptDirectInput === !1)
|
|
142682
143083
|
throw new SessionRuntimeError("command/unavailable", "Commands require an editable local Thread.");
|
|
142683
|
-
return
|
|
143084
|
+
return thread3;
|
|
142684
143085
|
});
|
|
142685
143086
|
rpc2.register("codexhost/threadCommands", (args) => {
|
|
142686
143087
|
let { sessionId } = requestOf(args), draft = this.drafts.get(sessionId);
|
|
@@ -142697,8 +143098,69 @@ var ChSessions = class {
|
|
|
142697
143098
|
options: [],
|
|
142698
143099
|
defaultOptions: [],
|
|
142699
143100
|
defaultPreset: ""
|
|
142700
|
-
})), rpc2.register("commands/list",
|
|
142701
|
-
let id2 = String(args.agentId ?? "")
|
|
143101
|
+
})), rpc2.register("commands/list", async (args) => {
|
|
143102
|
+
let id2 = String(args.agentId ?? "");
|
|
143103
|
+
try {
|
|
143104
|
+
let scope2 = await this.goalScope(id2);
|
|
143105
|
+
if (scope2 === "draft" && await this.supportsDraftGoals() && await this.goalScope(id2) === "draft")
|
|
143106
|
+
return [permissionCommand, goalCommand];
|
|
143107
|
+
if (scope2 === "local" && nativeCodexGoalResultSchema.safeParse(
|
|
143108
|
+
await this.host.request(NATIVE_CODEX_GOAL_METHOD, {
|
|
143109
|
+
threadId: this.id(id2),
|
|
143110
|
+
action: "get"
|
|
143111
|
+
})
|
|
143112
|
+
).success)
|
|
143113
|
+
return [permissionCommand, goalCommand];
|
|
143114
|
+
} catch {
|
|
143115
|
+
}
|
|
143116
|
+
return [permissionCommand];
|
|
143117
|
+
}), rpc2.register("commands/execute", async (args) => {
|
|
143118
|
+
let id2 = String(args.agentId ?? ""), line = String(args.line ?? "").trim();
|
|
143119
|
+
if (nativeCodexGoalInvocation.test(line)) {
|
|
143120
|
+
let scope2 = await this.goalScope(id2);
|
|
143121
|
+
if (scope2 === "other") return;
|
|
143122
|
+
if (scope2 === "unavailable")
|
|
143123
|
+
throw new SessionRuntimeError("goal/unavailable", "Goals require an editable local Codex Thread.");
|
|
143124
|
+
if (Array.isArray(args.submittedAttachments) && args.submittedAttachments.length)
|
|
143125
|
+
throw new SessionRuntimeError("goal/attachments", "/goal only accepts text.");
|
|
143126
|
+
let operation = parseGoalArguments(line.slice(5).trim()), threadId = this.id(id2);
|
|
143127
|
+
if (scope2 === "draft") {
|
|
143128
|
+
let draft2 = this.drafts.get(id2);
|
|
143129
|
+
if (operation.action !== "create")
|
|
143130
|
+
throw new SessionRuntimeError("goal/objective-required", "Enter an objective: /goal <objective>.");
|
|
143131
|
+
let validated = nativeCodexGoalRequestSchema.safeParse({ threadId: id2, ...operation });
|
|
143132
|
+
if (!validated.success)
|
|
143133
|
+
throw new SessionRuntimeError(
|
|
143134
|
+
"goal/invalid-arguments",
|
|
143135
|
+
validated.error.issues[0]?.message ?? "Invalid goal objective."
|
|
143136
|
+
);
|
|
143137
|
+
if (!await this.supportsDraftGoals())
|
|
143138
|
+
throw new SessionRuntimeError(
|
|
143139
|
+
"goal/unavailable",
|
|
143140
|
+
"Native goals are not enabled in this Codex version."
|
|
143141
|
+
);
|
|
143142
|
+
if (!draft2 || this.drafts.get(id2) !== draft2 || draft2.selection.provider !== "codex" || this.closed || !this.hostOnline || draft2.creating || draft2.started)
|
|
143143
|
+
throw new SessionRuntimeError("session/busy", "Draft selection changed.");
|
|
143144
|
+
threadId = await this.commit(draft2, operation.objective);
|
|
143145
|
+
}
|
|
143146
|
+
let view = await this.view(threadId, !0), read2 = operation.action === "get" ? this.nativeGoals.beginRead(view) : void 0, { goal } = nativeCodexGoalResultSchema.parse(
|
|
143147
|
+
await this.host.request(NATIVE_CODEX_GOAL_METHOD, { threadId, ...operation }).catch((error62) => {
|
|
143148
|
+
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(
|
|
143149
|
+
error62.message
|
|
143150
|
+
)) ? new SessionRuntimeError(
|
|
143151
|
+
"goal/unavailable",
|
|
143152
|
+
"This Codex Thread does not support native goals."
|
|
143153
|
+
) : error62;
|
|
143154
|
+
})
|
|
143155
|
+
), commandId = randomUUID23();
|
|
143156
|
+
this.currentGoalView(view) && this.nativeGoals.confirm(view, goal, read2);
|
|
143157
|
+
let visible = operation.action === "get" ? view.log.projections.codexGoal : void 0, text4 = goalReceipt(
|
|
143158
|
+
visible ? visible.goal : goal,
|
|
143159
|
+
operation.action === "clear"
|
|
143160
|
+
), log46 = view?.log;
|
|
143161
|
+
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 } };
|
|
143162
|
+
}
|
|
143163
|
+
let match = /^\/permission\s+(.+)$/u.exec(line);
|
|
142702
143164
|
if (!match) return;
|
|
142703
143165
|
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
143166
|
harnessId,
|
|
@@ -143020,6 +143482,9 @@ var exec3 = promisify7(execFile6), METHODS = /* @__PURE__ */ new Set([
|
|
|
143020
143482
|
"codexhost/thread/pins/list",
|
|
143021
143483
|
"codexhost/thread/sections/list",
|
|
143022
143484
|
"codexhost/thread/sections/move",
|
|
143485
|
+
CLIENT_THREAD_SECTION_MUTATIONS.create.method,
|
|
143486
|
+
CLIENT_THREAD_SECTION_MUTATIONS.update.method,
|
|
143487
|
+
CLIENT_THREAD_SECTION_MUTATIONS.delete.method,
|
|
143023
143488
|
"codexhost/thread/pins/set",
|
|
143024
143489
|
"codexhost/harness/display-settings/get",
|
|
143025
143490
|
"codexhost/harness/display-settings/set",
|
|
@@ -143272,7 +143737,7 @@ async function serveChClientGateway(host, request3, response, { authenticated =
|
|
|
143272
143737
|
let after = url2.searchParams.has("epoch") ? clientChannelCursorSchema.parse({
|
|
143273
143738
|
epoch: url2.searchParams.get("epoch"),
|
|
143274
143739
|
sequence: Number(url2.searchParams.get("after"))
|
|
143275
|
-
}) : void 0, stop = channel.subscribe((event) => {
|
|
143740
|
+
}) : void 0, supportsSections = url2.searchParams.get(THREAD_SECTION_CAPABILITY) === "1", stop = channel.subscribe((event) => {
|
|
143276
143741
|
if (event.type === "connection") {
|
|
143277
143742
|
!event.online && !response.writableEnded && !response.destroyed && (response.headersSent ? response.end() : response.writeHead(503, {
|
|
143278
143743
|
"content-type": "application/json; charset=utf-8",
|
|
@@ -143280,17 +143745,17 @@ async function serveChClientGateway(host, request3, response, { authenticated =
|
|
|
143280
143745
|
}).end(JSON.stringify({ error: { code: -32090, message: "CH is reconnecting" } })));
|
|
143281
143746
|
return;
|
|
143282
143747
|
}
|
|
143283
|
-
if (
|
|
143284
|
-
|
|
143285
|
-
|
|
143286
|
-
|
|
143287
|
-
|
|
143288
|
-
|
|
143289
|
-
|
|
143290
|
-
}
|
|
143291
|
-
response.write(JSON.stringify(event) + `
|
|
143292
|
-
`);
|
|
143748
|
+
if (response.destroyed || response.writableEnded) return;
|
|
143749
|
+
if (response.headersSent || response.writeHead(200, {
|
|
143750
|
+
"content-type": "application/x-ndjson",
|
|
143751
|
+
"cache-control": "no-store"
|
|
143752
|
+
}), response.writableLength > 256 * 1024) {
|
|
143753
|
+
response.destroy();
|
|
143754
|
+
return;
|
|
143293
143755
|
}
|
|
143756
|
+
let frame = event.type === "sections-changed" && !supportsSections ? { type: "hello", version: 1, cursor: event.cursor, reset: !0 } : event;
|
|
143757
|
+
response.write(JSON.stringify(frame) + `
|
|
143758
|
+
`);
|
|
143294
143759
|
}, after), heartbeat = setInterval(() => {
|
|
143295
143760
|
response.headersSent && !response.writableEnded && response.write(`
|
|
143296
143761
|
`);
|
|
@@ -144709,7 +145174,7 @@ async function snapshotPackagedHost(distribution, data2) {
|
|
|
144709
145174
|
|
|
144710
145175
|
// packages/web-server/src/main.ts
|
|
144711
145176
|
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.
|
|
145177
|
+
"0.31.0",
|
|
144713
145178
|
[join36(DISTRIBUTION_ROOT, "package.json"), join36(REPO_ROOT, "package.json")]
|
|
144714
145179
|
);
|
|
144715
145180
|
if (PACKED) {
|