@codexhost/cli-win32-x64 0.29.1 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +40 -15
  4. package/app/console-web.js +49 -24
  5. package/app/desktop-controller.mjs +53 -28
  6. package/app/host-runtime.mjs +2616 -1978
  7. package/app/plugins/antigravity/plugin.mjs +40 -15
  8. package/app/plugins/claude-code/plugin.mjs +40 -15
  9. package/app/plugins/codebuddy/plugin.mjs +514 -109
  10. package/app/plugins/codex-usage/plugin.mjs +58 -33
  11. package/app/plugins/copilot/plugin.mjs +40 -15
  12. package/app/plugins/cursor-cli/plugin.mjs +40 -15
  13. package/app/plugins/deepseek-harness/plugin.mjs +40 -15
  14. package/app/plugins/devin/plugin.mjs +40 -15
  15. package/app/plugins/grok/plugin.mjs +40 -15
  16. package/app/plugins/hermes/plugin.mjs +40 -15
  17. package/app/plugins/kimi-code/plugin.mjs +40 -15
  18. package/app/plugins/kiro-cli/plugin.mjs +40 -15
  19. package/app/plugins/omp/plugin.mjs +40 -15
  20. package/app/plugins/opencode/plugin.mjs +40 -15
  21. package/app/plugins/pi/plugin.mjs +40 -15
  22. package/app/plugins/qoder/plugin.mjs +40 -15
  23. package/app/plugins/qoder-cn/plugin.mjs +40 -15
  24. package/app/plugins/qwen-code/plugin.mjs +40 -15
  25. package/app/plugins/workbuddy/plugin.mjs +548 -112
  26. package/app/plugins/zcode/plugin.mjs +40 -15
  27. package/app/renderer-extension.js +52 -27
  28. package/app/web/assets/abnfDiagram-XWFEHMT6-BdinLox4.js +1 -0
  29. package/app/web/assets/architectureDiagram-CSQXQB3N-DgPBbtvP.js +36 -0
  30. package/app/web/assets/blockDiagram-BEDRHYPZ-B4ENdwtZ.js +140 -0
  31. package/app/web/assets/bpmnIcons-APHXDYXF-ByGoYv9M.js +1 -0
  32. package/app/web/assets/c4Diagram-M2UUVUY5-DA6Owfyu.js +38 -0
  33. package/app/web/assets/chunk-2Q5K7J3B-Dvh3qOmo.js +1 -0
  34. package/app/web/assets/chunk-3GCGMST5-VIkqueym.js +1 -0
  35. package/app/web/assets/chunk-5VM5RSS4-DTYof_OI.js +15 -0
  36. package/app/web/assets/chunk-7U7NFRK5-Dp7s2dg0.js +88 -0
  37. package/app/web/assets/chunk-CNRTWJTD-TKBKxZLU.js +1 -0
  38. package/app/web/assets/chunk-D5HYT7QG-BRZDovSS.js +1 -0
  39. package/app/web/assets/chunk-EBZ3SEQC-C9USZ3tT.js +2 -0
  40. package/app/web/assets/chunk-JWPE2WC7-BrdvVNVo.js +1 -0
  41. package/app/web/assets/chunk-KTR4FSNJ-C7qwjGba.js +1 -0
  42. package/app/web/assets/chunk-XXDRQBXY-DlSrRuwN.js +1 -0
  43. package/app/web/assets/classDiagram-v2-KXABOMEV-BFvB4kwX.js +217 -0
  44. package/app/web/assets/cose-bilkent-JH36ORCC-UyCAqNvj.js +1 -0
  45. package/app/web/assets/cynefin-EF2NZ3EQ-CwawUbjJ.js +141 -0
  46. package/app/web/assets/cynefinDiagram-NJNITYFG-BaWEIQJ0.js +62 -0
  47. package/app/web/assets/cytoscape.esm-Cm0uQArZ.js +332 -0
  48. package/app/web/assets/d3-scale-4DPf7zan.js +1 -0
  49. package/app/web/assets/dagre-KIHZ2IZ3-B7ENIjLG.js +4 -0
  50. package/app/web/assets/diagram-7YQZDPLS-CxRMU8xq.js +41 -0
  51. package/app/web/assets/diagram-QBROCOUO-qo7sxm4K.js +200 -0
  52. package/app/web/assets/diagram-RJJCUUZO-CQiGMCMe.js +30 -0
  53. package/app/web/assets/diagram-WERXNKYE-D0Jps1As.js +24 -0
  54. package/app/web/assets/diagram-YHHI257C-p4AB8cqK.js +3 -0
  55. package/app/web/assets/diagram-YR4HJLHV-Bh6JKT04.js +24 -0
  56. package/app/web/assets/ebnfDiagram-N527522P-DRac0k4W.js +1 -0
  57. package/app/web/assets/elk-O5DQBFGD-CWTz5SZP.js +27 -0
  58. package/app/web/assets/erDiagram-K3K3BIDK-DE3w4BEY.js +99 -0
  59. package/app/web/assets/flowDiagram-Z6JWZHQI-NYs8bi5t.js +213 -0
  60. package/app/web/assets/ganttDiagram-3PRQTZWP-Bspp9btW.js +292 -0
  61. package/app/web/assets/gitGraphDiagram-VXDFKS5L-ByGW1uvv.js +106 -0
  62. package/app/web/assets/graph-D8UmR1vK.js +1 -0
  63. package/app/web/assets/grid-E2QIVN74-CegebiIw.js +1 -0
  64. package/app/web/assets/{index-aSHN2MIG.css → index-BbmB5VLj.css} +1 -1
  65. package/app/web/assets/{index-0TnaYwHS.js → index-DFPOGLS4.js} +80 -80
  66. package/app/web/assets/infoDiagram-EZ3ZOAHP-CexmsdZx.js +2 -0
  67. package/app/web/assets/ishikawaDiagram-S3EKX5GW-BbWqKhg6.js +70 -0
  68. package/app/web/assets/journeyDiagram-POQNLL5X-27YlCe-1.js +139 -0
  69. package/app/web/assets/kanban-definition-BH5XI6FM-BAhOdeck.js +89 -0
  70. package/app/web/assets/langs/{graphql-ChAeyPkT.js → graphql-D6Z3qcRW.js} +1 -1
  71. package/app/web/assets/langs/{http-BvreBIbD.js → http-XiU9G9In.js} +1 -1
  72. package/app/web/assets/langs/{php-D8omCIuJ.js → php-DL3xwS-7.js} +1 -1
  73. package/app/web/assets/langs/{rst-Do7RLLCS.js → rst-DudRVJ9g.js} +1 -1
  74. package/app/web/assets/langs/{ruby-rH_O_vse.js → ruby-_FqsfqJi.js} +1 -1
  75. package/app/web/assets/langs/{svelte-xZy73wAj.js → svelte-ClsVJoBT.js} +1 -1
  76. package/app/web/assets/langs/{vue-C4DW8agZ.js → vue-BiKMXCyK.js} +1 -1
  77. package/app/web/assets/mermaid.core-sGgCbv5y.js +314 -0
  78. package/app/web/assets/mindmap-definition-WVAN44T4-CsMIX0Lj.js +98 -0
  79. package/app/web/assets/pegDiagram-D4NLKWP3-Cs3LXqn_.js +1 -0
  80. package/app/web/assets/pieDiagram-36ENHN4W-DdQsQX9I.js +39 -0
  81. package/app/web/assets/quadrantDiagram-ZQUDMS73-D1jOKqx_.js +7 -0
  82. package/app/web/assets/railroadDiagram-JIZHGYPL-XulrgX5n.js +1 -0
  83. package/app/web/assets/render-VIF2ZAQL-CSsGw-0I.js +2 -0
  84. package/app/web/assets/requirementDiagram-AXW2TVFA-CT66GXLN.js +84 -0
  85. package/app/web/assets/sankeyDiagram-FBCJTAIF-CNRKebNY.js +40 -0
  86. package/app/web/assets/sequenceDiagram-3LA2ROMG-DVl5y64e.js +169 -0
  87. package/app/web/assets/sizeCapture-2Q2CQKSF-Kg0XxSga.js +1 -0
  88. package/app/web/assets/stateDiagram-v2-ATKHQDJO-DYQnfMsS.js +291 -0
  89. package/app/web/assets/swimlanes-YQL5WMAO-Chqt7pxD.js +1 -0
  90. package/app/web/assets/swimlanesDiagram-UCCPES4V-BfREktNP.js +8 -0
  91. package/app/web/assets/timeline-definition-7Z437IG3-aHFxjIT6.js +120 -0
  92. package/app/web/assets/usecaseDiagram-RDK6N6HP-DsC5tFe4.js +370 -0
  93. package/app/web/assets/vendor-BKfNgqAm.js +666 -0
  94. package/app/web/assets/vennDiagram-SHRQU5PJ-C65oZxFn.js +34 -0
  95. package/app/web/assets/wardleyDiagram-F3OXNVQS-HTkq7DT0.js +78 -0
  96. package/app/web/assets/xychartDiagram-GDYJKCDI-p1LpQ9MH.js +7 -0
  97. package/app/web/codexhost-settings.js +39 -39
  98. package/app/web/index.html +3 -3
  99. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +65 -65
  100. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
  101. package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +1 -1
  102. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +17 -17
  103. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +16 -16
  104. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +16 -16
  105. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +3 -3
  106. package/app/web/plugins/deepseek-ai__dsh-client-ui-permission-presets/client.js +1 -1
  107. package/app/web/plugins/deepseek-ai__dsh-client-ui-plan/client.js +1 -1
  108. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  109. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  110. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
  111. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +14 -14
  112. package/app/web-modules/licenses/DSH-THIRD_PARTY_NOTICES.md +1 -1
  113. package/app/web-modules/server.mjs +641 -168
  114. package/bin/codexhost.exe +0 -0
  115. package/libexec/codexhost-node-repl.exe +0 -0
  116. package/libexec/codexhost-screenshot.exe +0 -0
  117. package/libexec/codexhost-shell.exe +0 -0
  118. package/libexec/codexhost-shim.exe +0 -0
  119. package/libexec/codexhost-updater.exe +0 -0
  120. package/package.json +1 -1
  121. 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, thread2] of threads.entries())
72535
- seen.has(thread2.threadId) && context.addIssue({
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(thread2.threadId);
72539
+ }), seen.add(thread3.threadId);
72540
72540
  }), threadSteeringInspectParamsSchema = external_exports.object({
72541
72541
  threadId: hostThreadIdSchema,
72542
72542
  /** The text about to be steered; a Harness command always stops and restarts. */
@@ -73140,6 +73140,25 @@ var productTelemetrySettingsSchema = external_exports.object({
73140
73140
  message: "Telemetry heartbeat must contain at least one countable field"
73141
73141
  });
73142
73142
 
73143
+ // packages/shared-contracts/dist/native-codex-goal.js
73144
+ var NATIVE_CODEX_GOAL_METHOD = "codexhost/thread/goal", nativeCodexGoalInvocation = /^\/goal(?:\s|$)/u, NATIVE_CODEX_GOAL_MAX_OBJECTIVE_CHARS = 4e3, thread = { threadId: hostThreadIdSchema }, nativeCodexGoalRequestSchema = external_exports.discriminatedUnion("action", [
73145
+ external_exports.strictObject({ ...thread, action: external_exports.enum(["get", "pause", "resume", "clear"]) }),
73146
+ external_exports.strictObject({
73147
+ ...thread,
73148
+ action: external_exports.enum(["create", "edit"]),
73149
+ objective: external_exports.string().trim().min(1).refine((objective) => Array.from(objective).length <= NATIVE_CODEX_GOAL_MAX_OBJECTIVE_CHARS, `A goal objective can have up to ${NATIVE_CODEX_GOAL_MAX_OBJECTIVE_CHARS} characters.`)
73150
+ })
73151
+ ]), nativeCodexGoalResultSchema = external_exports.object({
73152
+ goal: external_exports.object({
73153
+ threadId: hostThreadIdSchema,
73154
+ objective: external_exports.string(),
73155
+ status: external_exports.enum(["active", "paused", "blocked", "usageLimited", "budgetLimited", "complete"]),
73156
+ tokenBudget: external_exports.int().positive().nullable().default(null),
73157
+ tokensUsed: external_exports.int().nonnegative(),
73158
+ timeUsedSeconds: external_exports.int().nonnegative()
73159
+ }).nullable()
73160
+ });
73161
+
73143
73162
  // packages/shared-contracts/dist/client-channel.js
73144
73163
  var CLIENT_CHANNEL_VERSION = 1, CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
73145
73164
  var CLIENT_CHANNEL_METHODS = [
@@ -73151,10 +73170,12 @@ var CLIENT_CHANNEL_METHODS = [
73151
73170
  "codexhost/harness/display-settings/capabilities",
73152
73171
  "codexhost/harness/preferences/get",
73153
73172
  "codexhost/harness/preferences/patch",
73173
+ "experimentalFeature/list",
73154
73174
  "thread/list",
73155
73175
  "thread/metadata/update",
73156
73176
  "codexhost/thread/catalog/read",
73157
73177
  "thread/read",
73178
+ NATIVE_CODEX_GOAL_METHOD,
73158
73179
  "thread/resume",
73159
73180
  "thread/fork",
73160
73181
  "thread/turns/list",
@@ -74335,7 +74356,8 @@ var field = external_exports.discriminatedUnion("type", [
74335
74356
  var WEB_ACTIVE_TURN_PROJECTION = "codexhostActiveTurnId", WEB_FOLLOW_PROJECTION_KEYS = /* @__PURE__ */ new Set([
74336
74357
  WEB_ACTIVE_TURN_PROJECTION,
74337
74358
  "codexhostTurnChanges",
74338
- "codexhostToolOutput"
74359
+ "codexhostToolOutput",
74360
+ "codexGoal"
74339
74361
  ]), webFileDiffSchema = external_exports.object({
74340
74362
  path: external_exports.string(),
74341
74363
  oldText: external_exports.string().nullable(),
@@ -74899,7 +74921,7 @@ function remoteSessionRequestBytes(operation) {
74899
74921
  }
74900
74922
  var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(1).max(REMOTE_IDENTITY_MAX_LENGTH), target = {
74901
74923
  hostId: identity.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)
74902
- }, thread = { ...target, threadId: identity }, text = external_exports.string().min(1).max(8e3), input2 = { text, requestId: identity }, remoteDeliveryReplySchema = external_exports.discriminatedUnion("accepted", [
74924
+ }, thread2 = { ...target, threadId: identity }, text = external_exports.string().min(1).max(8e3), input2 = { text, requestId: identity }, remoteDeliveryReplySchema = external_exports.discriminatedUnion("accepted", [
74903
74925
  external_exports.object({ accepted: external_exports.literal(!0), startQueuedItemId: identity.optional() }),
74904
74926
  external_exports.object({
74905
74927
  accepted: external_exports.literal(!1),
@@ -74945,7 +74967,7 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
74945
74967
  serviceTier: external_exports.enum(["priority", "ultrafast"]).optional(),
74946
74968
  reasoningEffort: identity.optional()
74947
74969
  }),
74948
- external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
74970
+ external_exports.strictObject({ kind: external_exports.literal("status"), ...thread2 }),
74949
74971
  external_exports.strictObject({
74950
74972
  kind: external_exports.literal("list"),
74951
74973
  ...target,
@@ -74955,7 +74977,7 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
74955
74977
  }),
74956
74978
  external_exports.strictObject({
74957
74979
  kind: external_exports.literal("read"),
74958
- ...thread,
74980
+ ...thread2,
74959
74981
  page: external_exports.strictObject({
74960
74982
  cursor: external_exports.string().min(1).max(8192).nullable(),
74961
74983
  epoch: identity.optional(),
@@ -74965,10 +74987,10 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
74965
74987
  message: "A history continuation requires its connection epoch"
74966
74988
  }).optional()
74967
74989
  }),
74968
- external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
74990
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread2, epoch: identity }),
74969
74991
  external_exports.strictObject({
74970
74992
  kind: external_exports.literal("configure"),
74971
- ...thread,
74993
+ ...thread2,
74972
74994
  epoch: identity,
74973
74995
  modelId: identity.optional(),
74974
74996
  serviceTier: harnessModelServiceTierSchema.optional(),
@@ -74979,15 +75001,15 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
74979
75001
  }),
74980
75002
  external_exports.strictObject({
74981
75003
  kind: external_exports.literal("prompt"),
74982
- ...thread,
75004
+ ...thread2,
74983
75005
  epoch: identity,
74984
75006
  text,
74985
75007
  requestId: identity.optional()
74986
75008
  }),
74987
- external_exports.strictObject({ kind: external_exports.literal("queue"), ...thread, epoch: identity }),
75009
+ external_exports.strictObject({ kind: external_exports.literal("queue"), ...thread2, epoch: identity }),
74988
75010
  external_exports.strictObject({
74989
75011
  kind: external_exports.literal("delivery"),
74990
- ...thread,
75012
+ ...thread2,
74991
75013
  epoch: identity,
74992
75014
  action: external_exports.discriminatedUnion("kind", [
74993
75015
  external_exports.strictObject({ kind: external_exports.literal("enqueue"), ...input2 }),
@@ -75001,17 +75023,17 @@ var REMOTE_IDENTITY_MAX_LENGTH = 1024, identity = external_exports.string().min(
75001
75023
  external_exports.strictObject({ kind: external_exports.literal("sendNow"), itemId: identity })
75002
75024
  ])
75003
75025
  }),
75004
- external_exports.strictObject({ kind: external_exports.literal("interrupt"), ...thread, epoch: identity, turnId: identity }),
75026
+ external_exports.strictObject({ kind: external_exports.literal("interrupt"), ...thread2, epoch: identity, turnId: identity }),
75005
75027
  external_exports.strictObject({
75006
75028
  kind: external_exports.literal("rename"),
75007
- ...thread,
75029
+ ...thread2,
75008
75030
  epoch: identity,
75009
75031
  name: external_exports.string().min(1).max(512)
75010
75032
  }),
75011
- external_exports.strictObject({ kind: external_exports.literal("archive"), ...thread, epoch: identity, archived: external_exports.boolean() }),
75033
+ external_exports.strictObject({ kind: external_exports.literal("archive"), ...thread2, epoch: identity, archived: external_exports.boolean() }),
75012
75034
  external_exports.strictObject({
75013
75035
  kind: external_exports.literal("respond"),
75014
- ...thread,
75036
+ ...thread2,
75015
75037
  epoch: identity,
75016
75038
  requestId: external_exports.union([identity, external_exports.number().int()]),
75017
75039
  result: external_exports.record(external_exports.string(), external_exports.unknown())
@@ -77830,8 +77852,8 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
77830
77852
  knownTurns: this.knownTurnsForStatus(threadId),
77831
77853
  truncateToolOutput: !0
77832
77854
  })
77833
- ), thread2 = snapshot.thread, external = thread2.modelProvider === "codexhost" && thread2.cliVersion === "codexhost";
77834
- if (thread2.canAcceptDirectInput === !1)
77855
+ ), thread3 = snapshot.thread, external = thread3.modelProvider === "codexhost" && thread3.cliVersion === "codexhost";
77856
+ if (thread3.canAcceptDirectInput === !1)
77835
77857
  return { accepted: !1, code: "remote/send-rejected", message: "Thread is read-only" };
77836
77858
  if (a.kind === "sendNow")
77837
77859
  try {
@@ -77845,7 +77867,7 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
77845
77867
  if (error62 instanceof SessionRuntimeError && error62.code === "remote/request-failed") {
77846
77868
  let hostCode = "hostCode" in error62.details && typeof error62.details.hostCode == "number" ? error62.details.hostCode : void 0, message2 = error62.message;
77847
77869
  if (hostCode === -32601 || /unsupported client channel method|method not found/iu.test(message2)) {
77848
- if (thread2.status.type === "idle" || thread2.status.type === "notLoaded") {
77870
+ if (thread3.status.type === "idle" || thread3.status.type === "notLoaded") {
77849
77871
  if (!(await rpc2("thread/queue/start", {
77850
77872
  threadId,
77851
77873
  queuedSubmissionId: a.itemId
@@ -77875,7 +77897,7 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
77875
77897
  }
77876
77898
  throw error62;
77877
77899
  }
77878
- if (a.kind === "steer" && external && !thread2.codexhostSupportsStrictSteer)
77900
+ if (a.kind === "steer" && external && !thread3.codexhostSupportsStrictSteer)
77879
77901
  return {
77880
77902
  accepted: !1,
77881
77903
  code: "remote/steer-unavailable",
@@ -77903,13 +77925,13 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
77903
77925
  ...a.kind === "steer" ? {
77904
77926
  expectedTurnId: a.turnId,
77905
77927
  ...external ? { codexhostSteerStrictTarget: !0 } : {}
77906
- } : external && thread2.status.type === "idle" ? { codexhostQueueStartIfEmpty: !0 } : {}
77928
+ } : external && thread3.status.type === "idle" ? { codexhostQueueStartIfEmpty: !0 } : {}
77907
77929
  });
77908
77930
  if (a.kind === "enqueue") {
77909
77931
  let item = result.queuedSubmission;
77910
77932
  if (!item?.id || item.clientUserMessageId !== a.requestId)
77911
77933
  throw Error("Queue admission not confirmed");
77912
- if (!external && thread2.status.type === "idle" && snapshot.queue?.items.length === 0)
77934
+ if (!external && thread3.status.type === "idle" && snapshot.queue?.items.length === 0)
77913
77935
  return { accepted: !0, startQueuedItemId: item.id };
77914
77936
  } else if (result.turnId !== a.turnId && !(external && result.delivery === "newTurn" && result.turnId))
77915
77937
  throw Error("Steering not confirmed");
@@ -78590,9 +78612,9 @@ var ChHarnessCommands = class {
78590
78612
  resolve;
78591
78613
  pending = /* @__PURE__ */ new Set();
78592
78614
  async inspect(sessionId) {
78593
- let thread2 = await this.resolve(sessionId);
78615
+ let thread3 = await this.resolve(sessionId);
78594
78616
  return harnessCommandCatalogSchema.parse(
78595
- await this.host.request("codexhost/thread/commands/inspect", { threadId: thread2.id })
78617
+ await this.host.request("codexhost/thread/commands/inspect", { threadId: thread3.id })
78596
78618
  );
78597
78619
  }
78598
78620
  /** Draft catalog from its workspace; the Host reads it without creating a Thread. */
@@ -78605,20 +78627,20 @@ var ChHarnessCommands = class {
78605
78627
  );
78606
78628
  }
78607
78629
  async execute(sessionId, commandId) {
78608
- let thread2 = await this.resolve(sessionId);
78609
- if (this.pending.has(thread2.id) || thread2.status.type === "active")
78630
+ let thread3 = await this.resolve(sessionId);
78631
+ if (this.pending.has(thread3.id) || thread3.status.type === "active")
78610
78632
  throw new SessionRuntimeError("session/busy", "The Thread is busy. Direct commands cannot be queued.");
78611
- this.pending.add(thread2.id);
78633
+ this.pending.add(thread3.id);
78612
78634
  try {
78613
78635
  let command = requireDirectCommand(await this.inspect(sessionId), commandId);
78614
78636
  return threadCommandExecuteResultSchema.parse(
78615
78637
  await this.host.request("codexhost/thread/command/execute", {
78616
- threadId: thread2.id,
78638
+ threadId: thread3.id,
78617
78639
  commandId: command.id
78618
78640
  })
78619
78641
  );
78620
78642
  } finally {
78621
- this.pending.delete(thread2.id);
78643
+ this.pending.delete(thread3.id);
78622
78644
  }
78623
78645
  }
78624
78646
  };
@@ -79161,8 +79183,8 @@ function threadListTitle(row) {
79161
79183
  }
79162
79184
 
79163
79185
  // packages/web-server/src/ch-thread-time.ts
79164
- function threadRecencyMs(thread2) {
79165
- return (thread2.recencyAt ?? thread2.updatedAt) * 1e3;
79186
+ function threadRecencyMs(thread3) {
79187
+ return (thread3.recencyAt ?? thread3.updatedAt) * 1e3;
79166
79188
  }
79167
79189
 
79168
79190
  // packages/web-server/src/ch-turn-changes.ts
@@ -80366,9 +80388,9 @@ function compactTurnToolOutputs(turn) {
80366
80388
  return changed ? { ...turn, items } : turn;
80367
80389
  }
80368
80390
  var ChThreadView = class _ChThreadView {
80369
- constructor(thread2, harnessId, onProjection, turnStart = 0, sequenceStart = 0, hasEarlier = () => !1, projectInput = (content) => content, projectImage = () => {
80391
+ constructor(thread3, harnessId, onProjection, turnStart = 0, sequenceStart = 0, hasEarlier = () => !1, projectInput = (content) => content, projectImage = () => {
80370
80392
  }, options) {
80371
- this.thread = thread2;
80393
+ this.thread = thread3;
80372
80394
  this.harnessId = harnessId;
80373
80395
  this.turnStart = turnStart;
80374
80396
  this.projectInput = projectInput;
@@ -80378,9 +80400,9 @@ var ChThreadView = class _ChThreadView {
80378
80400
  this.log = new SessionLog(
80379
80401
  {
80380
80402
  version: 4,
80381
- id: thread2.id,
80382
- createdAt: thread2.createdAt * 1e3,
80383
- cwd: thread2.cwd,
80403
+ id: thread3.id,
80404
+ createdAt: thread3.createdAt * 1e3,
80405
+ cwd: thread3.cwd,
80384
80406
  isSeeded: !1,
80385
80407
  agentPreset: "standard"
80386
80408
  },
@@ -80508,10 +80530,10 @@ var ChThreadView = class _ChThreadView {
80508
80530
  let storedTurns = this.compactToolOutputs ? turns.map((turn) => compactTurnToolOutputs(turn)) : turns;
80509
80531
  this.thread.turns = [...storedTurns, ...this.thread.turns], this.compactToolOutputs && compactLogToolOutputs(this.log), this.publishMessageTimes(), this.publishFileChanges();
80510
80532
  }
80511
- update(thread2, activeTurnId) {
80533
+ update(thread3, activeTurnId) {
80512
80534
  this.ensureCurrent();
80513
80535
  let existingTurns = new Map(this.thread.turns.map((turn) => [turn.id, turn])), projectionsByTurn = /* @__PURE__ */ new Map();
80514
- for (let turn of thread2.turns) {
80536
+ for (let turn of thread3.turns) {
80515
80537
  let view = this.turns.get(turn.id);
80516
80538
  if (!view || view.done && turn === existingTurns.get(turn.id)) continue;
80517
80539
  let items = this.displayItems(turn), ids = new Set(items.map((item) => item.id)), users = items.filter((item) => item.type === "userMessage"), published = [...view.started], lastUser = published.findLastIndex((id2) => view.userMessages.has(id2)), reasoningPreviewIds = new Set(
@@ -80542,12 +80564,12 @@ var ChThreadView = class _ChThreadView {
80542
80564
  })) || firstNewUser !== -1 && items.slice(firstNewUser + 1).some((item) => view.started.has(item.id)))
80543
80565
  throw new SessionRuntimeError("host/items-replaced", "CH replaced already projected Items.");
80544
80566
  }
80545
- Object.assign(this.thread, thread2), this.log.setProjection("title", threadListTitle(thread2)), this.log.setProjection("codexhostImportSource", thread2.codexhostImportSource ?? null), this.log.setProjection("sessionListMetadata", {
80546
- blank: thread2.turns.length === 0,
80547
- lastPromptAt: threadRecencyMs(thread2)
80567
+ Object.assign(this.thread, thread3), this.log.setProjection("title", threadListTitle(thread3)), this.log.setProjection("codexhostImportSource", thread3.codexhostImportSource ?? null), this.log.setProjection("sessionListMetadata", {
80568
+ blank: thread3.turns.length === 0,
80569
+ lastPromptAt: threadRecencyMs(thread3)
80548
80570
  });
80549
80571
  try {
80550
- this.projectTurns(thread2, projectionsByTurn);
80572
+ this.projectTurns(thread3, projectionsByTurn);
80551
80573
  } finally {
80552
80574
  this.log.clock = void 0;
80553
80575
  }
@@ -80555,7 +80577,7 @@ var ChThreadView = class _ChThreadView {
80555
80577
  (turn) => this.turns.get(turn.id)?.done ? compactTurnToolOutputs(turn) : turn
80556
80578
  ), compactLogToolOutputs(this.log)), this.log.setProjection(
80557
80579
  WEB_ACTIVE_TURN_PROJECTION,
80558
- activeTurnId !== void 0 ? activeTurnId : thread2.status.type === "active" ? thread2.turns.findLast((turn) => !finished(turn.status))?.id ?? null : null
80580
+ activeTurnId !== void 0 ? activeTurnId : thread3.status.type === "active" ? thread3.turns.findLast((turn) => !finished(turn.status))?.id ?? null : null
80559
80581
  ), this.log.setProjection("codexhostToolOutput", Object.fromEntries(this.liveOutput)), this.publishMessageTimes(), this.publishFileChanges();
80560
80582
  }
80561
80583
  projectItem(turnId, item, view, reasoningPreviewIds) {
@@ -80624,9 +80646,9 @@ var ChThreadView = class _ChThreadView {
80624
80646
  )
80625
80647
  );
80626
80648
  }
80627
- projectTurns(thread2, projections) {
80628
- let previousEnd = thread2.createdAt * 1e3;
80629
- for (let turn of thread2.turns) {
80649
+ projectTurns(thread3, projections) {
80650
+ let previousEnd = thread3.createdAt * 1e3;
80651
+ for (let turn of thread3.turns) {
80630
80652
  let items = this.displayItems(turn), view = this.turns.get(turn.id), complete = finished(turn.status), start = nativeTime(turn.startedAt) ?? (complete ? previousEnd : Date.now()), end = Math.max(
80631
80653
  start,
80632
80654
  nativeTime(turn.completedAt) ?? (view && !view.done ? Date.now() : start)
@@ -80635,7 +80657,7 @@ var ChThreadView = class _ChThreadView {
80635
80657
  let projector2 = new TurnProjector(this.log, {
80636
80658
  live: !complete,
80637
80659
  turn: this.turnStart + this.turns.size + 1,
80638
- cwd: thread2.cwd,
80660
+ cwd: thread3.cwd,
80639
80661
  model: { provider: this.harnessId, model: "harness" },
80640
80662
  onToolOutput: (id2, output2) => {
80641
80663
  output2 === void 0 ? this.liveOutput.delete(id2) : this.liveOutput.set(id2, output2.slice(-8e3));
@@ -81857,10 +81879,10 @@ function isInvalidCursorError(error62) {
81857
81879
  return !(error62 instanceof SessionRuntimeError) || error62.code !== "host/rejected" && error62.code !== "remote/request-failed" ? !1 : error62.details?.hostCode === -32602;
81858
81880
  }
81859
81881
  var ChThreadHistory = class extends ChThreadView {
81860
- constructor(host, thread2, harnessId, onProjection, origin = RENDER_ORIGIN, projectInput, projectImage, options) {
81882
+ constructor(host, thread3, harnessId, onProjection, origin = RENDER_ORIGIN, projectInput, projectImage, options) {
81861
81883
  let pagination = { cursor: null };
81862
81884
  super(
81863
- { ...thread2, turns: [] },
81885
+ { ...thread3, turns: [] },
81864
81886
  harnessId,
81865
81887
  onProjection,
81866
81888
  origin,
@@ -81875,7 +81897,7 @@ var ChThreadHistory = class extends ChThreadView {
81875
81897
  }
81876
81898
  );
81877
81899
  this.host = host;
81878
- this.pagination = pagination, this.hasProjectInput = projectInput !== void 0, this.canEditQueueItem = options?.canEditQueueItem, this.hostThreadId = options?.hostThreadId ?? thread2.id, this.overrideThreadIdentity = options?.hostThreadId !== void 0, this.viewId = thread2.id, this.viewCwd = thread2.cwd, this.commands = new ChCommandPresentation(this.log);
81900
+ this.pagination = pagination, this.hasProjectInput = projectInput !== void 0, this.canEditQueueItem = options?.canEditQueueItem, this.hostThreadId = options?.hostThreadId ?? thread3.id, this.overrideThreadIdentity = options?.hostThreadId !== void 0, this.viewId = thread3.id, this.viewCwd = thread3.cwd, this.commands = new ChCommandPresentation(this.log);
81879
81901
  }
81880
81902
  host;
81881
81903
  loaded = !1;
@@ -81925,11 +81947,11 @@ var ChThreadHistory = class extends ChThreadView {
81925
81947
  }
81926
81948
  return walkFrom(null);
81927
81949
  }
81928
- viewThread(thread2) {
81929
- if (!this.overrideThreadIdentity) return thread2;
81930
- if (thread2.id !== this.hostThreadId)
81950
+ viewThread(thread3) {
81951
+ if (!this.overrideThreadIdentity) return thread3;
81952
+ if (thread3.id !== this.hostThreadId)
81931
81953
  throw new SessionRuntimeError("remote/read-failed", "Remote identity mismatch");
81932
- return { ...thread2, id: this.viewId, cwd: this.viewCwd };
81954
+ return { ...thread3, id: this.viewId, cwd: this.viewCwd };
81933
81955
  }
81934
81956
  async page(cursor) {
81935
81957
  let result = await this.host.request("thread/turns/list", {
@@ -81978,10 +82000,10 @@ var ChThreadHistory = class extends ChThreadView {
81978
82000
  let snapshot = this.host.realtime ? await this.snapshot(this.host.realtime) : void 0, { thread: rawThread } = snapshot ? { thread: snapshot.thread } : await this.host.request("thread/read", {
81979
82001
  threadId: this.hostThreadId,
81980
82002
  includeTurns: !1
81981
- }), thread2 = this.viewThread(rawThread);
82003
+ }), thread3 = this.viewThread(rawThread);
81982
82004
  if (this.ensureCurrent(), this.ownerSnapshot = snapshot, snapshot) {
81983
82005
  this.log.setProjection(WEB_HANDOFF_PROJECTION, snapshot.handoff ?? null);
81984
- let readOnly = thread2.canAcceptDirectInput === !1, allowsAttachments = !readOnly && !(thread2.parentThreadId ?? this.thread.parentThreadId), projectedQueue = this.queueProjection.project(snapshot.queue?.items ?? [], {
82006
+ let readOnly = thread3.canAcceptDirectInput === !1, allowsAttachments = !readOnly && !(thread3.parentThreadId ?? this.thread.parentThreadId), projectedQueue = this.queueProjection.project(snapshot.queue?.items ?? [], {
81985
82007
  ...this.hasProjectInput ? { projectInput: (content) => this.projectInput(content) } : {},
81986
82008
  ...this.canEditQueueItem ? { canEdit: this.canEditQueueItem } : {},
81987
82009
  allowsAttachments,
@@ -81995,8 +82017,8 @@ var ChThreadHistory = class extends ChThreadView {
81995
82017
  ...this.canEditQueueItem ? { editable: projectedQueue.editable } : {}
81996
82018
  });
81997
82019
  }
81998
- if (!snapshot && !force && this.loaded && Date.now() - this.lastHeadReadAt < 6e4 && thread2.updatedAt === this.thread.updatedAt && thread2.status.type !== "active" && this.thread.status.type !== "active") {
81999
- Object.assign(this.thread, { ...thread2, turns: this.thread.turns }), this.log.setProjection("title", threadListTitle(thread2)), this.log.setProjection("codexhostImportSource", thread2.codexhostImportSource ?? null), this.commands.update(void 0, this.thread.turns);
82020
+ if (!snapshot && !force && this.loaded && Date.now() - this.lastHeadReadAt < 6e4 && thread3.updatedAt === this.thread.updatedAt && thread3.status.type !== "active" && this.thread.status.type !== "active") {
82021
+ Object.assign(this.thread, { ...thread3, turns: this.thread.turns }), this.log.setProjection("title", threadListTitle(thread3)), this.log.setProjection("codexhostImportSource", thread3.codexhostImportSource ?? null), this.commands.update(void 0, this.thread.turns);
82000
82022
  return;
82001
82023
  }
82002
82024
  let recent = snapshot ? snapshot.turnsPage : await this.page(null);
@@ -82017,7 +82039,7 @@ var ChThreadHistory = class extends ChThreadView {
82017
82039
  "CH history was rewritten. Reload this page to reopen its current history."
82018
82040
  );
82019
82041
  if (!this.loaded)
82020
- this.pagination.cursor = recent.nextCursor, this.update({ ...thread2, turns: descending.reverse() }, snapshot?.activeTurnId), this.loaded = !0;
82042
+ this.pagination.cursor = recent.nextCursor, this.update({ ...thread3, turns: descending.reverse() }, snapshot?.activeTurnId), this.loaded = !0;
82021
82043
  else {
82022
82044
  newestKnown || (this.pagination.cursor = recent.nextCursor);
82023
82045
  let newTurns = newestKnown ? descending.slice(
@@ -82026,7 +82048,7 @@ var ChThreadHistory = class extends ChThreadView {
82026
82048
  ) : descending, incoming = new Map(descending.map((turn) => [turn.id, turn])), known = new Set(this.thread.turns.map((turn) => turn.id));
82027
82049
  this.update(
82028
82050
  {
82029
- ...thread2,
82051
+ ...thread3,
82030
82052
  turns: [
82031
82053
  ...this.thread.turns.map((turn) => incoming.get(turn.id) ?? turn),
82032
82054
  ...newTurns.reverse().filter((turn) => !known.has(turn.id))
@@ -82704,13 +82726,13 @@ var PeerThreadSource = class {
82704
82726
  let epoch = this.host.manifestEpoch();
82705
82727
  this.pendingCommands.add(threadId);
82706
82728
  try {
82707
- let { thread: thread2 } = await this.host.request("thread/read", {
82729
+ let { thread: thread3 } = await this.host.request("thread/read", {
82708
82730
  threadId,
82709
82731
  includeTurns: !1
82710
82732
  });
82711
- if (thread2.id !== threadId || thread2.parentThreadId || thread2.canAcceptDirectInput === !1)
82733
+ if (thread3.id !== threadId || thread3.parentThreadId || thread3.canAcceptDirectInput === !1)
82712
82734
  throw new SessionRuntimeError("command/unavailable", "Commands require an editable remote Thread.");
82713
- if (thread2.status.type === "active") throw busy();
82735
+ if (thread3.status.type === "active") throw busy();
82714
82736
  if (requireDirectCommand(await this.inspectThreadCommands(threadId), params.data.commandId), this.host.manifestEpoch() !== epoch)
82715
82737
  throw new SessionRuntimeError("remote/connection-changed", "Remote peer changed before dispatch.");
82716
82738
  if (this.knownArchived.get(threadId)?.archived)
@@ -102459,8 +102481,8 @@ var RemoteProjectDraft = class {
102459
102481
 
102460
102482
  // packages/web-server/src/remote-approval.ts
102461
102483
  var text2 = (value) => typeof value == "string" && value.trim() ? value : void 0;
102462
- function remoteApprovalPresentation(request3, thread2) {
102463
- let p = request3.params, items = (Array.isArray(thread2?.turns) ? thread2.turns : []).flatMap(
102484
+ function remoteApprovalPresentation(request3, thread3) {
102485
+ let p = request3.params, items = (Array.isArray(thread3?.turns) ? thread3.turns : []).flatMap(
102464
102486
  (turn) => Array.isArray(turn?.items) ? turn.items : []
102465
102487
  ), item = typeof p.itemId == "string" ? items.find((value) => value?.id === p.itemId) : void 0, changes = p.changes ?? item?.changes, command = text2(p.command) ?? text2(item?.command) ?? (Array.isArray(p.command) && p.command.every((v) => typeof v == "string") ? p.command.map((v) => JSON.stringify(v)).join(" ") : void 0), paths2 = [
102466
102488
  text2(p.grantRoot),
@@ -102733,11 +102755,11 @@ async function tryGenerateThreadTitle(host, row, prompt, external, isCurrent) {
102733
102755
  let title = generated ?? (external ? firstPromptTitle(input3) : null);
102734
102756
  if (!title || !isCurrent()) return !1;
102735
102757
  try {
102736
- let { thread: thread2 } = await host.request("thread/read", {
102758
+ let { thread: thread3 } = await host.request("thread/read", {
102737
102759
  threadId: row.id,
102738
102760
  includeTurns: !1
102739
102761
  });
102740
- return !isCurrent() || (thread2.name ?? "") !== expectedName ? !1 : (await host.request("thread/name/set", {
102762
+ return !isCurrent() || (thread3.name ?? "") !== expectedName ? !1 : (await host.request("thread/name/set", {
102741
102763
  threadId: row.id,
102742
102764
  name: title,
102743
102765
  ...external ? { [THREAD_NAME_AUTO_SOURCE_PARAM]: generated === null ? "fallback" : "generated" } : {}
@@ -103296,6 +103318,98 @@ function remoteWorkspaceGroups(hosts, threads) {
103296
103318
  });
103297
103319
  }
103298
103320
 
103321
+ // packages/web-server/src/remote-session-list.ts
103322
+ function encodeRemoteGlobalCursor(input3) {
103323
+ return JSON.stringify({
103324
+ codexhostRemoteCursor: 1,
103325
+ includeArchived: input3.includeArchived,
103326
+ localCursor: input3.localCursor,
103327
+ remoteOffset: input3.remoteOffset
103328
+ });
103329
+ }
103330
+ function encodeRemoteWorkspaceCursor(input3) {
103331
+ return JSON.stringify({
103332
+ codexhostRemoteWorkspaceCursor: 1,
103333
+ workspaceId: input3.workspaceId,
103334
+ includeArchived: input3.includeArchived,
103335
+ offset: input3.offset
103336
+ });
103337
+ }
103338
+ function parseRemoteListCursor(cursor) {
103339
+ let parsed;
103340
+ try {
103341
+ parsed = JSON.parse(cursor);
103342
+ } catch {
103343
+ return;
103344
+ }
103345
+ if (typeof parsed != "object" || parsed === null || Array.isArray(parsed)) return;
103346
+ let record6 = parsed;
103347
+ if (record6.codexhostRemoteCursor === 1)
103348
+ return typeof record6.includeArchived != "boolean" || record6.localCursor !== null && typeof record6.localCursor != "string" || typeof record6.remoteOffset != "number" || !Number.isSafeInteger(record6.remoteOffset) || record6.remoteOffset < 0 ? void 0 : {
103349
+ kind: "global",
103350
+ includeArchived: record6.includeArchived,
103351
+ localCursor: record6.localCursor,
103352
+ remoteOffset: record6.remoteOffset
103353
+ };
103354
+ if (record6.codexhostRemoteWorkspaceCursor === 1)
103355
+ return typeof record6.workspaceId != "string" || record6.workspaceId.length === 0 || typeof record6.includeArchived != "boolean" || typeof record6.offset != "number" || !Number.isSafeInteger(record6.offset) || record6.offset < 0 ? void 0 : {
103356
+ kind: "workspace",
103357
+ workspaceId: record6.workspaceId,
103358
+ includeArchived: record6.includeArchived,
103359
+ offset: record6.offset
103360
+ };
103361
+ }
103362
+ function appendWithAncestors(target2, id2, ancestorsOf) {
103363
+ target2.has(id2) || target2.add(id2);
103364
+ for (let ancestorId of ancestorsOf(id2))
103365
+ target2.has(ancestorId) || target2.add(ancestorId);
103366
+ }
103367
+ function selectRemoteHeadPage(options) {
103368
+ let {
103369
+ orderedIds,
103370
+ priorityIds,
103371
+ workspaceIdOf,
103372
+ ancestorsOf,
103373
+ pageSize = 50,
103374
+ workspaceHeadLimit = 6,
103375
+ maxHeadNonPriority = 150
103376
+ } = options, selected = /* @__PURE__ */ new Set(), workspaceCounts = /* @__PURE__ */ new Map();
103377
+ for (let id2 of priorityIds)
103378
+ appendWithAncestors(selected, id2, ancestorsOf);
103379
+ let nonPriorityCount = 0;
103380
+ for (let index = 0; index < orderedIds.length; index++) {
103381
+ let id2 = orderedIds[index], wsId = workspaceIdOf(id2);
103382
+ if (selected.has(id2)) {
103383
+ wsId !== void 0 && workspaceCounts.set(wsId, (workspaceCounts.get(wsId) ?? 0) + 1);
103384
+ continue;
103385
+ }
103386
+ let inHeadSlice = index < pageSize, wsCount = wsId === void 0 ? workspaceHeadLimit : workspaceCounts.get(wsId) ?? 0, inWorkspacePreview = wsId !== void 0 && wsCount < workspaceHeadLimit && nonPriorityCount < maxHeadNonPriority;
103387
+ !inHeadSlice && !inWorkspacePreview || (appendWithAncestors(selected, id2, ancestorsOf), nonPriorityCount += 1, wsId !== void 0 && workspaceCounts.set(wsId, wsCount + 1));
103388
+ }
103389
+ let hasMore = !1;
103390
+ for (let id2 of orderedIds)
103391
+ if (!selected.has(id2)) {
103392
+ hasMore = !0;
103393
+ break;
103394
+ }
103395
+ let nextRemoteOffset = hasMore ? Math.min(pageSize, orderedIds.length) : orderedIds.length;
103396
+ return {
103397
+ ids: [...selected],
103398
+ hasMore,
103399
+ nextRemoteOffset
103400
+ };
103401
+ }
103402
+ function selectRemoteSlicePage(options) {
103403
+ let { orderedIds, offset, pageSize, ancestorsOf } = options, start = Math.max(0, Math.min(offset, orderedIds.length)), end = Math.min(start + pageSize, orderedIds.length), selected = /* @__PURE__ */ new Set();
103404
+ for (let index = start; index < end; index++)
103405
+ appendWithAncestors(selected, orderedIds[index], ancestorsOf);
103406
+ return {
103407
+ ids: [...selected],
103408
+ hasMore: end < orderedIds.length,
103409
+ nextOffset: end
103410
+ };
103411
+ }
103412
+
103299
103413
  // packages/web-server/src/remote-sessions.ts
103300
103414
  var PREFIX = "web-remote:", PEER_CATALOG_REFRESH_MIN_INTERVAL_MS = 600, hostsSchema = external_exports.array(
103301
103415
  external_exports.object({
@@ -103383,6 +103497,7 @@ var RemoteSessions = class {
103383
103497
  attachments;
103384
103498
  drafts = /* @__PURE__ */ new Map();
103385
103499
  pendingFirstTurns = /* @__PURE__ */ new Map();
103500
+ remoteWorkspaceBySession = /* @__PURE__ */ new Map();
103386
103501
  titleRequests = /* @__PURE__ */ new Set();
103387
103502
  entries = /* @__PURE__ */ new Map();
103388
103503
  hosts = /* @__PURE__ */ new Map();
@@ -104290,9 +104405,9 @@ var RemoteSessions = class {
104290
104405
  "remote/outcome-unknown",
104291
104406
  "Remote Thread creation was not confirmed. Refresh the project before retrying."
104292
104407
  );
104293
- let thread2 = result2.data.thread, identity2 = { hostId: host.hostId, threadId: thread2.id }, id2 = remoteSessionId(identity2.hostId, identity2.threadId), entry = this.entries.get(id2) ?? {
104408
+ let thread3 = result2.data.thread, identity2 = { hostId: host.hostId, threadId: thread3.id }, id2 = remoteSessionId(identity2.hostId, identity2.threadId), entry = this.entries.get(id2) ?? {
104294
104409
  identity: identity2,
104295
- row: { ...thread2, turns: [] },
104410
+ row: { ...thread3, turns: [] },
104296
104411
  online: !0,
104297
104412
  configurationRevision: 0
104298
104413
  };
@@ -104308,7 +104423,7 @@ var RemoteSessions = class {
104308
104423
  try {
104309
104424
  if (this.syncGroups(), this.events.emit("api-session/added", this.summary(id2, entry)), this.events.emit("codexhost/session-bound", draft.id, id2), this.events.emit("api-session/removed", draft.id), usePeerAttachments && peerPromptContent !== void 0)
104310
104425
  await this.attachments.prompt(this.peerEndpoint(host.hostId), {
104311
- threadId: thread2.id,
104426
+ threadId: thread3.id,
104312
104427
  ...draftUploadScope !== void 0 ? { scope: draftUploadScope } : {},
104313
104428
  ...peerPromptRequestId !== void 0 ? { requestId: peerPromptRequestId } : {},
104314
104429
  ...peerPromptMode !== void 0 ? { mode: peerPromptMode } : {},
@@ -104316,7 +104431,7 @@ var RemoteSessions = class {
104316
104431
  }), draftUploadScope !== void 0 && entry.pendingUploadScope === draftUploadScope && delete entry.pendingUploadScope;
104317
104432
  else if (legacyPrompt !== void 0) {
104318
104433
  let text4 = this.translatePeerOutboundText(host.hostId, legacyPrompt.text);
104319
- await this.invoke({ ...legacyPrompt, text: text4, threadId: thread2.id });
104434
+ await this.invoke({ ...legacyPrompt, text: text4, threadId: thread3.id });
104320
104435
  }
104321
104436
  } finally {
104322
104437
  this.pendingFirstTurns.delete(id2);
@@ -104326,7 +104441,7 @@ var RemoteSessions = class {
104326
104441
  let titlePrompt = usePeerAttachments && peerPromptContent !== void 0 ? peerPromptContent.filter(
104327
104442
  (part) => part.type === "text"
104328
104443
  ).map((part) => part.text).join(`
104329
- `) : legacyPrompt?.text ?? "", external = operation.kind === "startSelected" && operation.harnessId !== "codex" || thread2.modelProvider === "codexhost";
104444
+ `) : legacyPrompt?.text ?? "", external = operation.kind === "startSelected" && operation.harnessId !== "codex" || thread3.modelProvider === "codexhost";
104330
104445
  this.titleRequests.add(id2), tryGenerateThreadTitle(
104331
104446
  peerSource.host,
104332
104447
  entry.row,
@@ -104350,24 +104465,205 @@ var RemoteSessions = class {
104350
104465
  })
104351
104466
  }, draft.submission.result;
104352
104467
  }
104468
+ remoteGroupsSnapshot() {
104469
+ return remoteWorkspaceGroups(this.hosts.values(), [
104470
+ ...[...this.entries].map(([sessionId, entry]) => ({
104471
+ sessionId,
104472
+ ...entry.identity,
104473
+ cwd: entry.row.cwd,
104474
+ projectId: this.workspaces?.remoteProjectId(sessionId)
104475
+ })),
104476
+ ...[...this.drafts.values()].filter((d) => !d.canonicalId).map((d) => ({
104477
+ sessionId: d.id,
104478
+ hostId: d.target.hostId,
104479
+ threadId: d.id,
104480
+ cwd: d.target.cwd,
104481
+ projectId: d.projectId
104482
+ }))
104483
+ ]);
104484
+ }
104353
104485
  syncGroups() {
104354
- this.workspaces?.setRemoteGroups(
104355
- remoteWorkspaceGroups(this.hosts.values(), [
104356
- ...[...this.entries].map(([sessionId, entry]) => ({
104357
- sessionId,
104358
- ...entry.identity,
104359
- cwd: entry.row.cwd,
104360
- projectId: this.workspaces?.remoteProjectId(sessionId)
104361
- })),
104362
- ...[...this.drafts.values()].filter((d) => !d.canonicalId).map((d) => ({
104363
- sessionId: d.id,
104364
- hostId: d.target.hostId,
104365
- threadId: d.id,
104366
- cwd: d.target.cwd,
104367
- projectId: d.projectId
104368
- }))
104369
- ])
104370
- );
104486
+ let groups = this.remoteGroupsSnapshot(), bySession = /* @__PURE__ */ new Map();
104487
+ for (let group of groups)
104488
+ for (let sessionId of group.sessionIds)
104489
+ bySession.set(sessionId, group.workspaceId);
104490
+ this.remoteWorkspaceBySession = bySession, this.workspaces?.setRemoteGroups(groups);
104491
+ }
104492
+ workspaceMapForListing() {
104493
+ if (this.remoteWorkspaceBySession.size > 0 || this.entries.size === 0)
104494
+ return this.remoteWorkspaceBySession;
104495
+ let groups = this.remoteGroupsSnapshot(), bySession = /* @__PURE__ */ new Map();
104496
+ for (let group of groups)
104497
+ for (let sessionId of group.sessionIds)
104498
+ bySession.set(sessionId, group.workspaceId);
104499
+ return this.remoteWorkspaceBySession = bySession, bySession;
104500
+ }
104501
+ remoteAncestors(id2) {
104502
+ let ancestors = [], seen = /* @__PURE__ */ new Set([id2]), current = this.entries.get(id2);
104503
+ for (; current; ) {
104504
+ let parentId = current.peerTreeParent ?? (current.row.parentThreadId ? remoteSessionId(current.identity.hostId, current.row.parentThreadId) : void 0);
104505
+ if (!parentId || seen.has(parentId)) break;
104506
+ let parentEntry = this.entries.get(parentId);
104507
+ if (!parentEntry) break;
104508
+ seen.add(parentId), ancestors.push(parentId), current = parentEntry;
104509
+ }
104510
+ return ancestors;
104511
+ }
104512
+ orderedRemoteIds(includeArchived, workspaceFilter) {
104513
+ let eligible = [];
104514
+ for (let [id2, entry] of this.entries)
104515
+ !includeArchived && entry.archived || workspaceFilter && workspaceFilter.bySession.get(id2) !== workspaceFilter.workspaceId || eligible.push({ id: id2, updatedAt: threadRecencyMs(entry.row) });
104516
+ return eligible.sort((left, right) => right.updatedAt - left.updatedAt), eligible.map((item) => item.id);
104517
+ }
104518
+ remotePriorityIds(includeArchived) {
104519
+ let priority = /* @__PURE__ */ new Set(), pinnedIds = this.workspaces?.pinnedSessionIds() ?? this.syncPins();
104520
+ for (let pinnedId of pinnedIds) {
104521
+ let entry = this.entries.get(pinnedId);
104522
+ entry && (includeArchived || !entry.archived) && priority.add(pinnedId);
104523
+ }
104524
+ for (let [id2, entry] of this.entries)
104525
+ !includeArchived && entry.archived || (entry.online && entry.row.status.type === "active" || entry.view !== void 0 || this.hasPendingInteraction(id2, entry)) && priority.add(id2);
104526
+ return priority;
104527
+ }
104528
+ async listRemoteSessions(args, next) {
104529
+ let request3 = requestOf(args);
104530
+ if (request3.sessionId !== void 0) {
104531
+ let id2 = request3.sessionId;
104532
+ if (typeof id2 != "string" || !id2.startsWith(PREFIX)) return next();
104533
+ if (request3.cursor !== void 0)
104534
+ throw new SessionRuntimeError("session/list-invalid", "Invalid direct-link identity.");
104535
+ let draft = this.drafts.get(id2);
104536
+ if (draft && !draft.canonicalId)
104537
+ return { items: [this.draftSummary(draft)], archivedSessionIds: this.syncArchives() };
104538
+ let canonicalId = draft?.canonicalId ?? id2;
104539
+ if (canonicalId.startsWith(`${PREFIX}draft-`))
104540
+ throw new SessionRuntimeError("session/not-found", "Remote draft Session is no longer available.");
104541
+ let identity2 = remoteSessionIdentity(canonicalId), entry;
104542
+ if (identity2?.hostId.startsWith(REMOTE_PEER_HOST_ID_PREFIX) ? entry = await this.lookupPeerSummary(canonicalId, identity2.hostId) : (this.entries.has(canonicalId) || await this.refresh(), entry = this.entries.get(canonicalId)), !entry) throw new SessionRuntimeError("remote/not-found", "Remote Thread not found");
104543
+ return {
104544
+ items: [this.summary(canonicalId, entry)],
104545
+ archivedSessionIds: this.syncArchives()
104546
+ };
104547
+ }
104548
+ let includeArchived = request3.includeArchived === !0, rawCursor = typeof request3.cursor == "string" ? request3.cursor : void 0, parsedCursor = rawCursor === void 0 ? void 0 : parseRemoteListCursor(rawCursor), workspaceId = typeof request3.workspaceId == "string" ? request3.workspaceId : void 0;
104549
+ if (workspaceId !== void 0 && workspaceId.startsWith("remote-workspace:")) {
104550
+ if (request3.cursor === void 0 || typeof request3.cursor != "string")
104551
+ throw new SessionRuntimeError("session/list-invalid", "workspaceId only continues a cursor page.");
104552
+ if (request3.includeArchived !== void 0 && typeof request3.includeArchived != "boolean")
104553
+ throw new SessionRuntimeError("session/list-invalid", "includeArchived must be a boolean.");
104554
+ let offset = 0;
104555
+ if (parsedCursor?.kind === "workspace") {
104556
+ if (parsedCursor.workspaceId !== workspaceId || parsedCursor.includeArchived !== includeArchived)
104557
+ throw new SessionRuntimeError(
104558
+ "session/list-invalid",
104559
+ "Invalid session list cursor or archive scope."
104560
+ );
104561
+ offset = parsedCursor.offset;
104562
+ } else if (parsedCursor?.kind === "global" && parsedCursor.includeArchived !== includeArchived)
104563
+ throw new SessionRuntimeError("session/list-invalid", "Invalid session list cursor or archive scope.");
104564
+ let bySession2 = this.workspaceMapForListing(), orderedIds2 = this.orderedRemoteIds(includeArchived, { workspaceId, bySession: bySession2 }), page = selectRemoteSlicePage({
104565
+ orderedIds: orderedIds2,
104566
+ offset,
104567
+ pageSize: 50,
104568
+ ancestorsOf: (id2) => this.remoteAncestors(id2)
104569
+ });
104570
+ return {
104571
+ items: [
104572
+ ...offset === 0 ? [...this.drafts.values()].filter((d) => !d.canonicalId && bySession2.get(d.id) === workspaceId).map((d) => this.draftSummary(d)) : [],
104573
+ ...page.ids.map((id2) => {
104574
+ let entry = this.entries.get(id2);
104575
+ return entry ? this.summary(id2, entry) : void 0;
104576
+ }).filter((item) => item !== void 0)
104577
+ ],
104578
+ archivedSessionIds: this.syncArchives(),
104579
+ nextCursor: page.hasMore ? encodeRemoteWorkspaceCursor({
104580
+ workspaceId,
104581
+ includeArchived,
104582
+ offset: page.nextOffset
104583
+ }) : null
104584
+ };
104585
+ }
104586
+ let callLocalWithCursor = async (localCursor) => {
104587
+ if (localCursor === null)
104588
+ return {
104589
+ items: [],
104590
+ archivedSessionIds: this.syncArchives(),
104591
+ nextCursor: null
104592
+ };
104593
+ let target2 = typeof args.request == "object" && args.request !== null && !Array.isArray(args.request) ? args.request : typeof args._request == "object" && args._request !== null && !Array.isArray(args._request) ? args._request : args, hadCursor = Object.hasOwn(target2, "cursor"), previousCursor = target2.cursor;
104594
+ target2.cursor = localCursor;
104595
+ try {
104596
+ return await next();
104597
+ } finally {
104598
+ hadCursor ? target2.cursor = previousCursor : delete target2.cursor;
104599
+ }
104600
+ };
104601
+ if (workspaceId !== void 0) {
104602
+ if (parsedCursor?.kind === "workspace")
104603
+ throw new SessionRuntimeError("session/list-invalid", "Invalid session list cursor or archive scope.");
104604
+ if (parsedCursor?.kind === "global") {
104605
+ if (parsedCursor.includeArchived !== includeArchived)
104606
+ throw new SessionRuntimeError(
104607
+ "session/list-invalid",
104608
+ "Invalid session list cursor or archive scope."
104609
+ );
104610
+ return callLocalWithCursor(parsedCursor.localCursor);
104611
+ }
104612
+ return next();
104613
+ }
104614
+ if (request3.cursor !== void 0) {
104615
+ if (parsedCursor?.kind === "workspace")
104616
+ throw new SessionRuntimeError("session/list-invalid", "Invalid session list cursor or archive scope.");
104617
+ if (parsedCursor?.kind === "global") {
104618
+ if (parsedCursor.includeArchived !== includeArchived)
104619
+ throw new SessionRuntimeError(
104620
+ "session/list-invalid",
104621
+ "Invalid session list cursor or archive scope."
104622
+ );
104623
+ let local2 = await callLocalWithCursor(parsedCursor.localCursor), orderedIds2 = this.orderedRemoteIds(includeArchived), page = selectRemoteSlicePage({
104624
+ orderedIds: orderedIds2,
104625
+ offset: parsedCursor.remoteOffset,
104626
+ pageSize: 50,
104627
+ ancestorsOf: (id2) => this.remoteAncestors(id2)
104628
+ }), remoteItems2 = page.ids.map((id2) => {
104629
+ let entry = this.entries.get(id2);
104630
+ return entry ? this.summary(id2, entry) : void 0;
104631
+ }).filter((item) => item !== void 0), localNextCursor = local2.nextCursor ?? null, nextCursor = page.hasMore ? encodeRemoteGlobalCursor({
104632
+ includeArchived,
104633
+ localCursor: localNextCursor,
104634
+ remoteOffset: page.nextOffset
104635
+ }) : localNextCursor;
104636
+ return {
104637
+ ...local2,
104638
+ items: [...local2.items, ...remoteItems2],
104639
+ nextCursor
104640
+ };
104641
+ }
104642
+ return next();
104643
+ }
104644
+ this.refreshBackground().catch(() => {
104645
+ });
104646
+ let local = await next(), draftItems = [...this.drafts.values()].filter((d) => !d.canonicalId).map((d) => this.draftSummary(d)), bySession = this.workspaceMapForListing(), orderedIds = this.orderedRemoteIds(includeArchived), head = selectRemoteHeadPage({
104647
+ orderedIds,
104648
+ priorityIds: this.remotePriorityIds(includeArchived),
104649
+ workspaceIdOf: (id2) => bySession.get(id2),
104650
+ ancestorsOf: (id2) => this.remoteAncestors(id2)
104651
+ }), remoteItems = head.ids.map((id2) => {
104652
+ let entry = this.entries.get(id2);
104653
+ return entry ? this.summary(id2, entry) : void 0;
104654
+ }).filter((item) => item !== void 0);
104655
+ return head.hasMore ? {
104656
+ ...local,
104657
+ items: [...local.items, ...draftItems, ...remoteItems],
104658
+ nextCursor: encodeRemoteGlobalCursor({
104659
+ includeArchived,
104660
+ localCursor: local.nextCursor ?? null,
104661
+ remoteOffset: head.nextRemoteOffset
104662
+ })
104663
+ } : {
104664
+ ...local,
104665
+ items: [...local.items, ...draftItems, ...remoteItems]
104666
+ };
104371
104667
  }
104372
104668
  reference(entry) {
104373
104669
  return { ...entry.identity };
@@ -104435,7 +104731,6 @@ var RemoteSessions = class {
104435
104731
  kind: "cached",
104436
104732
  asOfSeq: 0,
104437
104733
  values: {
104438
- ...defaultProjections(),
104439
104734
  title: threadListTitle({ ...entry.row, id: entry.identity.threadId }),
104440
104735
  remoteHost: {
104441
104736
  ...entry.identity,
@@ -104931,38 +105226,8 @@ var RemoteSessions = class {
104931
105226
  return this.createInProject(request4.workspaceId, request4.sessionId);
104932
105227
  }
104933
105228
  }
104934
- if (method2 === "session/list") {
104935
- let request4 = requestOf(args);
104936
- if (request4.sessionId !== void 0) {
104937
- let id3 = request4.sessionId;
104938
- if (typeof id3 != "string" || !id3.startsWith(PREFIX)) return next();
104939
- if (request4.cursor !== void 0)
104940
- throw new SessionRuntimeError("session/list-invalid", "Invalid direct-link identity.");
104941
- let draft2 = this.drafts.get(id3);
104942
- if (draft2 && !draft2.canonicalId)
104943
- return { items: [this.draftSummary(draft2)], archivedSessionIds: this.syncArchives() };
104944
- let canonicalId = draft2?.canonicalId ?? id3;
104945
- if (canonicalId.startsWith(`${PREFIX}draft-`))
104946
- throw new SessionRuntimeError("session/not-found", "Remote draft Session is no longer available.");
104947
- let identity2 = remoteSessionIdentity(canonicalId), entry;
104948
- if (identity2?.hostId.startsWith(REMOTE_PEER_HOST_ID_PREFIX) ? entry = await this.lookupPeerSummary(canonicalId, identity2.hostId) : (this.entries.has(canonicalId) || await this.refresh(), entry = this.entries.get(canonicalId)), !entry) throw new SessionRuntimeError("remote/not-found", "Remote Thread not found");
104949
- return {
104950
- items: [this.summary(canonicalId, entry)],
104951
- archivedSessionIds: this.syncArchives()
104952
- };
104953
- }
104954
- this.refreshBackground().catch(() => {
104955
- });
104956
- let local = await next();
104957
- return {
104958
- ...local,
104959
- items: [
104960
- ...local.items,
104961
- ...[...this.drafts.values()].filter((d) => !d.canonicalId).map((d) => this.draftSummary(d)),
104962
- ...[...this.entries].map(([id3, entry]) => this.summary(id3, entry))
104963
- ]
104964
- };
104965
- }
105229
+ if (method2 === "session/list")
105230
+ return this.listRemoteSessions(args, next);
104966
105231
  if (method2 === "session/search")
104967
105232
  return this.search(args, next);
104968
105233
  let request3 = requestOf(args), id2 = request3.sessionId ?? request3.address?.sessionId ?? request3.agentId ?? args.agentId;
@@ -138692,6 +138957,8 @@ var MAX_TABS = 12, DETACHED_TAB_MS = 5 * 6e4, IDLE_BROWSER_MS = 6e4, SWEEP_MS =
138692
138957
  alive = /* @__PURE__ */ new WeakSet();
138693
138958
  quality;
138694
138959
  context;
138960
+ /** Ordinary Chrome user agent learned by the last launch, so the next one starts with it. */
138961
+ userAgent;
138695
138962
  idleSince = Date.now();
138696
138963
  sweeper;
138697
138964
  closed = !1;
@@ -138738,8 +139005,9 @@ Connection: close\r
138738
139005
  if (this.closed) return Promise.reject(new Error("The Web server is stopping."));
138739
139006
  let pending = this.context ??= launch(
138740
139007
  this.options.profileDirectory,
138741
- this.quality.deviceScale
138742
- ).then((context) => (context.on("page", (page) => {
139008
+ this.quality.deviceScale,
139009
+ this.userAgent
139010
+ ).then(({ context, userAgent }) => (this.userAgent = userAgent, context.on("page", (page) => {
138743
139011
  this.popup(page);
138744
139012
  }), context.on("close", () => {
138745
139013
  this.context === pending && (this.context = void 0);
@@ -138782,26 +139050,38 @@ Connection: close\r
138782
139050
  });
138783
139051
  }
138784
139052
  };
138785
- async function launch(profileDirectory, deviceScale) {
139053
+ async function launch(profileDirectory, deviceScale, knownUserAgent) {
138786
139054
  let executable = process.env.CODEXHOST_BROWSER_EXECUTABLE, candidates = executable === void 0 || executable === "" ? [{ channel: "chrome" }, { channel: "msedge" }, {}] : [{ executablePath: executable }], failure3;
138787
- for (let candidate of candidates)
139055
+ for (let candidate of candidates) {
139056
+ let open13 = (userAgent) => chromium.launchPersistentContext(profileDirectory, {
139057
+ ...candidate,
139058
+ headless: !0,
139059
+ viewport: null,
139060
+ acceptDownloads: !1,
139061
+ ...userAgent === void 0 ? {} : { userAgent },
139062
+ args: [
139063
+ `--force-device-scale-factor=${String(deviceScale)}`,
139064
+ "--disable-blink-features=AutomationControlled"
139065
+ ]
139066
+ });
138788
139067
  try {
138789
- let context = await chromium.launchPersistentContext(profileDirectory, {
138790
- ...candidate,
138791
- headless: !0,
138792
- viewport: null,
138793
- acceptDownloads: !1,
138794
- args: [`--force-device-scale-factor=${String(deviceScale)}`]
138795
- });
138796
- return await Promise.all(context.pages().map((page) => page.close())), context;
139068
+ let context = await open13(knownUserAgent), userAgent = await ordinaryUserAgent(context);
139069
+ return userAgent !== knownUserAgent && (await context.close(), context = await open13(userAgent)), await Promise.all(context.pages().map((page) => page.close())), { context, userAgent };
138797
139070
  } catch (error62) {
138798
139071
  failure3 = error62;
138799
139072
  }
139073
+ }
138800
139074
  throw new Error(
138801
139075
  `No usable browser on the CodexHost machine: install Chrome or Edge, or set CODEXHOST_BROWSER_EXECUTABLE. (${failure3 instanceof Error ? failure3.message.split(`
138802
139076
  `)[0] ?? "" : String(failure3)})`
138803
139077
  );
138804
139078
  }
139079
+ async function ordinaryUserAgent(context) {
139080
+ let cdp = await context.browser()?.newBrowserCDPSession();
139081
+ if (cdp === void 0) return;
139082
+ let { userAgent } = await cdp.send("Browser.getVersion");
139083
+ return await cdp.detach(), userAgent.replace("HeadlessChrome/", "Chrome/");
139084
+ }
138805
139085
 
138806
139086
  // packages/web-server/src/misc.ts
138807
139087
  import { existsSync as existsSync11, mkdirSync as mkdirSync6, readdirSync as readdirSync3, statSync as statSync7 } from "node:fs";
@@ -140093,6 +140373,102 @@ var Workspaces = class {
140093
140373
  }
140094
140374
  };
140095
140375
 
140376
+ // packages/web-server/src/ch-native-goal.ts
140377
+ var goalUsage = "/goal [<objective> | edit <objective> | pause | resume | clear]", goalCommand = {
140378
+ definitionId: "@deepseek-ai/dsh-command-goal",
140379
+ name: "goal",
140380
+ description: "View or manage this thread's goal",
140381
+ input: { hint: goalUsage.slice(6) }
140382
+ };
140383
+ function parseGoalArguments(text4) {
140384
+ if (!text4) return { action: "get" };
140385
+ let [, verb, rest] = /^(\S+)(?:\s+([\s\S]*))?$/u.exec(text4) ?? [], action = verb?.toLowerCase(), value = rest?.trim() ?? "";
140386
+ switch (action) {
140387
+ case "pause":
140388
+ case "resume":
140389
+ case "clear":
140390
+ if (!value) return { action };
140391
+ break;
140392
+ case "edit":
140393
+ if (value) return { action: "edit", objective: value };
140394
+ throw new SessionRuntimeError(
140395
+ "goal/invalid-arguments",
140396
+ "Provide a new objective: /goal edit <objective>"
140397
+ );
140398
+ default:
140399
+ return { action: "create", objective: text4 };
140400
+ }
140401
+ throw new SessionRuntimeError("goal/invalid-arguments", `Usage: ${goalUsage}`);
140402
+ }
140403
+ var statusLabels = {
140404
+ active: "active",
140405
+ paused: "paused",
140406
+ blocked: "stalled",
140407
+ usageLimited: "usage limited",
140408
+ budgetLimited: "limited by budget",
140409
+ complete: "complete"
140410
+ };
140411
+ function goalReceipt(goal, cleared) {
140412
+ if (!goal)
140413
+ return cleared ? "Goal cleared." : "No goal set for this thread. Run /goal <objective> to create one.";
140414
+ let budget = goal.tokenBudget == null ? "" : ` / ${goal.tokenBudget}`;
140415
+ return `Goal ${statusLabels[goal.status]}
140416
+ ${goal.objective}
140417
+ Tokens: ${goal.tokensUsed}${budget} \xB7 Time: ${goal.timeUsedSeconds}s`;
140418
+ }
140419
+ var ChNativeGoals = class {
140420
+ constructor(host) {
140421
+ this.host = host;
140422
+ }
140423
+ host;
140424
+ states = /* @__PURE__ */ new WeakMap();
140425
+ state(view) {
140426
+ let state2 = this.states.get(view);
140427
+ return state2 || (state2 = { revision: 0, sequence: 0, loading: !1, dirty: !1 }, this.states.set(view, state2)), state2;
140428
+ }
140429
+ beginRead(view) {
140430
+ let state2 = this.state(view);
140431
+ return { revision: state2.revision, sequence: ++state2.sequence };
140432
+ }
140433
+ currentRead(view, read2) {
140434
+ let state2 = this.state(view);
140435
+ return read2.revision === state2.revision && read2.sequence === state2.sequence;
140436
+ }
140437
+ confirm(view, goal, read2) {
140438
+ read2 && !this.currentRead(view, read2) || (read2 || (this.state(view).revision += 1), view.log.setProjection("codexGoal", { goal, error: null }));
140439
+ }
140440
+ async refresh(view, current) {
140441
+ let state2 = this.state(view);
140442
+ if (state2.loading) {
140443
+ state2.dirty = !0;
140444
+ return;
140445
+ }
140446
+ state2.loading = !0, state2.dirty = !1;
140447
+ let read2 = this.beginRead(view);
140448
+ try {
140449
+ let { goal } = nativeCodexGoalResultSchema.parse(
140450
+ await this.host.request(NATIVE_CODEX_GOAL_METHOD, {
140451
+ threadId: view.thread.id,
140452
+ action: "get"
140453
+ })
140454
+ );
140455
+ if (goal && goal.threadId !== view.thread.id)
140456
+ throw new Error("Goal belongs to another Thread");
140457
+ current() && this.currentRead(view, read2) && view.log.setProjection("codexGoal", { goal, error: null });
140458
+ } catch (error62) {
140459
+ if (current() && this.currentRead(view, read2)) {
140460
+ let previous = view.log.projections.codexGoal;
140461
+ previous?.goal && view.log.setProjection("codexGoal", {
140462
+ goal: previous.goal,
140463
+ error: error62 instanceof Error ? error62.message : "Could not refresh the native goal"
140464
+ });
140465
+ }
140466
+ } finally {
140467
+ state2.loading = !1, state2.dirty && current() && this.refresh(view, current);
140468
+ }
140469
+ }
140470
+ };
140471
+
140096
140472
  // packages/web-server/src/skills.ts
140097
140473
  var WebSkills = class {
140098
140474
  constructor(host, events2, resolve26) {
@@ -140897,7 +141273,7 @@ var ChSessions = class {
140897
141273
  this.files = files2;
140898
141274
  this.preferences = preferences2;
140899
141275
  this.openFile = openFile;
140900
- this.catalog = new ChHarnessCatalog(host, events2, displayEntries2, preferences2, harnesses), this.attachments = images2 ? new ChAttachments(images2, files2) : void 0, this.fileInputs = files2 && images2 ? new ChFileInputs(files2, images2, async (id2) => {
141276
+ this.nativeGoals = new ChNativeGoals(host), this.catalog = new ChHarnessCatalog(host, events2, displayEntries2, preferences2, harnesses), this.attachments = images2 ? new ChAttachments(images2, files2) : void 0, this.fileInputs = files2 && images2 ? new ChFileInputs(files2, images2, async (id2) => {
140901
141277
  if (id2 = this.id(id2), this.closed) throw new SessionRuntimeError("host/offline", "The Web connection is closed.");
140902
141278
  if (this.drafts.has(id2)) return id2;
140903
141279
  await this.owner(id2), this.rows.has(id2) || await this.refresh();
@@ -140980,6 +141356,7 @@ var ChSessions = class {
140980
141356
  handoffs = /* @__PURE__ */ new Map();
140981
141357
  /** Loaded rows accumulate across partial official pages; drafts are not Host Threads. */
140982
141358
  threads = new WebThreadStates();
141359
+ nativeGoals;
140983
141360
  drafts = /* @__PURE__ */ new Map();
140984
141361
  controls = /* @__PURE__ */ new Set();
140985
141362
  refreshing;
@@ -141118,8 +141495,8 @@ var ChSessions = class {
141118
141495
  if (await this.tree.supplement(rows, async (id2) => {
141119
141496
  let scanned = indexed.get(id2);
141120
141497
  if (scanned && ownership.has(id2)) return scanned;
141121
- let { thread: thread2, harnessId } = await this.readThread(id2);
141122
- return ownership.set(id2, harnessId), thread2.archived === !0 && archived.add(id2), thread2;
141498
+ let { thread: thread3, harnessId } = await this.readThread(id2);
141499
+ return ownership.set(id2, harnessId), thread3.archived === !0 && archived.add(id2), thread3;
141123
141500
  }), this.closed || !this.workspaces.get(workspaceId)) return;
141124
141501
  for (let [id2, row] of members2) {
141125
141502
  if (deletedIds.has(id2)) {
@@ -141174,13 +141551,13 @@ var ChSessions = class {
141174
141551
  for (let id2 of found.keys()) snapshotArchives.has(id2) || archivedIds.delete(id2);
141175
141552
  let ownership = catalogOwnership(snapshot, found), pageSectionAdditions = cursor === void 0 ? void 0 : /* @__PURE__ */ new Set(), threadSections = sections?.map(({ id: id2, name: name2, threads }) => {
141176
141553
  let threadIds = [];
141177
- for (let thread2 of threads)
141178
- if (!(typeof thread2.id != "string" || thread2.archived === !0)) {
141179
- if (thread2.archived === !1 && !snapshotArchives.has(thread2.id) && archivedIds.delete(thread2.id), !found.has(thread2.id)) {
141180
- let row = thread2;
141181
- found.set(thread2.id, row), ownership.set(thread2.id, "codex"), (cursor === void 0 || !this.publishedCatalog?.has(row.id)) && snapshot.threads.push(row);
141554
+ for (let thread3 of threads)
141555
+ if (!(typeof thread3.id != "string" || thread3.archived === !0)) {
141556
+ if (thread3.archived === !1 && !snapshotArchives.has(thread3.id) && archivedIds.delete(thread3.id), !found.has(thread3.id)) {
141557
+ let row = thread3;
141558
+ found.set(thread3.id, row), ownership.set(thread3.id, "codex"), (cursor === void 0 || !this.publishedCatalog?.has(row.id)) && snapshot.threads.push(row);
141182
141559
  }
141183
- ownership.get(thread2.id) === "codex" && (threadIds.push(thread2.id), this.publishedCatalog?.has(thread2.id) || pageSectionAdditions?.add(thread2.id));
141560
+ ownership.get(thread3.id) === "codex" && (threadIds.push(thread3.id), this.publishedCatalog?.has(thread3.id) || pageSectionAdditions?.add(thread3.id));
141184
141561
  }
141185
141562
  return { id: id2, name: name2, threadIds };
141186
141563
  });
@@ -141197,8 +141574,8 @@ var ChSessions = class {
141197
141574
  found.has(id2) || !harnessId || deletedIds.has(id2) || cursor === void 0 && harnessId !== "codex" && known.has(id2) && !archiveChanges.has(id2) && (includeArchived || !archivedIds.has(id2)) || (rows.set(id2, row), ownership.set(id2, harnessId));
141198
141575
  }
141199
141576
  await this.tree.supplement(rows, async (id2) => {
141200
- let { thread: thread2, harnessId } = await this.readThread(id2);
141201
- return ownership.set(id2, harnessId), thread2.archived === !0 && archivedIds.add(id2), thread2;
141577
+ let { thread: thread3, harnessId } = await this.readThread(id2);
141578
+ return ownership.set(id2, harnessId), thread3.archived === !0 && archivedIds.add(id2), thread3;
141202
141579
  });
141203
141580
  for (let id2 of deletedIds)
141204
141581
  rows.delete(id2), ownership.delete(id2), archivedIds.delete(id2);
@@ -141421,7 +141798,7 @@ var ChSessions = class {
141421
141798
  let name2 = await this.catalog.name(harnessId);
141422
141799
  if (this.threads.view(id2) !== view)
141423
141800
  throw new SessionRuntimeError("host/resync", "Host snapshot was superseded by a new generation");
141424
- return view.log.setProjection("harnessIdentity", { id: harnessId, name: name2 }), this.loadControls(view, harnessId, force, configurationRevision), this.loadUsage(view, force), this.closed || this.events.emit("api-session/status", id2, view.thread.status.type === "active"), view;
141801
+ return view.log.setProjection("harnessIdentity", { id: harnessId, name: name2 }), this.currentGoalView(view) ? this.nativeGoals.refresh(view, () => this.currentGoalView(view)) : view.log.setProjection("codexGoal", null), this.loadControls(view, harnessId, force, configurationRevision), this.loadUsage(view, force), this.closed || this.events.emit("api-session/status", id2, view.thread.status.type === "active"), view;
141425
141802
  }
141426
141803
  loadUsage(view, force) {
141427
141804
  let id2 = view.thread.id, active3 = this.threads.get(id2)?.usage;
@@ -141648,10 +142025,10 @@ var ChSessions = class {
141648
142025
  );
141649
142026
  draft.started = { thread: result.thread, harnessId: owner.harnessId };
141650
142027
  }
141651
- let { thread: thread2, harnessId } = draft.started;
141652
- if (draft.projectId && thread2.projectId !== draft.projectId) {
142028
+ let { thread: thread3, harnessId } = draft.started;
142029
+ if (draft.projectId && thread3.projectId !== draft.projectId) {
141653
142030
  let updated = await this.host.request("thread/metadata/update", {
141654
- threadId: thread2.id,
142031
+ threadId: thread3.id,
141655
142032
  projectId: draft.projectId
141656
142033
  });
141657
142034
  if (updated.thread.projectId !== draft.projectId)
@@ -141659,9 +142036,9 @@ var ChSessions = class {
141659
142036
  "workspace/assignment-unconfirmed",
141660
142037
  "Codex did not confirm the conversation's project."
141661
142038
  );
141662
- thread2.projectId = updated.thread.projectId, this.refreshingProjectAssignments?.set(thread2.id, draft.projectId);
142039
+ thread3.projectId = updated.thread.projectId, this.refreshingProjectAssignments?.set(thread3.id, draft.projectId);
141663
142040
  }
141664
- return draft.canonicalId = thread2.id, this.files?.bind(draft.id, thread2.id), this.rows.set(thread2.id, thread2), this.threads.setHarness(thread2.id, harnessId), this.workspaces.detachSession(draft.id), this.workspaces.usesNativeProjects ? this.workspaces.updateNativeProjectMember(thread2.id, draft.projectId) : draft.cwd ? (this.workspaces.selectReferenceWorkspace(draft.cwd), this.workspaces.attachReferencedSession(thread2.id, thread2.cwd), this.workspaces.addDraftReference(thread2.id, draft.cwd)) : this.workspaces.addDraftReference(thread2.id, void 0), this.events.emit("api-session/added", await this.summary(thread2)), this.publishedCatalog?.set(thread2.id, this.catalogKey(thread2)), this.events.emit("codexhost/session-bound", draft.id, thread2.id), this.events.emit("api-session/removed", draft.id), thread2.id;
142041
+ return draft.canonicalId = thread3.id, this.files?.bind(draft.id, thread3.id), this.rows.set(thread3.id, thread3), this.threads.setHarness(thread3.id, harnessId), this.workspaces.detachSession(draft.id), this.workspaces.usesNativeProjects ? this.workspaces.updateNativeProjectMember(thread3.id, draft.projectId) : draft.cwd ? (this.workspaces.selectReferenceWorkspace(draft.cwd), this.workspaces.attachReferencedSession(thread3.id, thread3.cwd), this.workspaces.addDraftReference(thread3.id, draft.cwd)) : this.workspaces.addDraftReference(thread3.id, void 0), this.events.emit("api-session/added", await this.summary(thread3)), this.publishedCatalog?.set(thread3.id, this.catalogKey(thread3)), this.events.emit("codexhost/session-bound", draft.id, thread3.id), this.events.emit("api-session/removed", draft.id), thread3.id;
141665
142042
  }
141666
142043
  /**
141667
142044
  * Working directory of one Host-confirmed local Thread.
@@ -141690,8 +142067,8 @@ var ChSessions = class {
141690
142067
  let id2 = this.id(sessionId);
141691
142068
  if (!this.drafts.has(id2))
141692
142069
  try {
141693
- let { thread: thread2, harnessId } = await this.readThread(id2);
141694
- return this.closed || signal?.aborted ? void 0 : (this.rows.set(thread2.id, thread2), this.threads.setHarness(thread2.id, harnessId), thread2.cwd);
142070
+ let { thread: thread3, harnessId } = await this.readThread(id2);
142071
+ return this.closed || signal?.aborted ? void 0 : (this.rows.set(thread3.id, thread3), this.threads.setHarness(thread3.id, harnessId), thread3.cwd);
141695
142072
  } catch {
141696
142073
  return;
141697
142074
  }
@@ -141801,8 +142178,8 @@ var ChSessions = class {
141801
142178
  "Send the first message before archiving this Thread."
141802
142179
  );
141803
142180
  if (!this.threads.hasHarness(id2)) {
141804
- let { thread: thread2, harnessId } = await this.readThread(id2);
141805
- this.rows.set(id2, thread2), this.threads.setHarness(id2, harnessId);
142181
+ let { thread: thread3, harnessId } = await this.readThread(id2);
142182
+ this.rows.set(id2, thread3), this.threads.setHarness(id2, harnessId);
141806
142183
  }
141807
142184
  let owner = await this.owner(id2);
141808
142185
  if (this.archiveOperations.get(id2) !== operation) return;
@@ -141825,16 +142202,16 @@ var ChSessions = class {
141825
142202
  }
141826
142203
  }
141827
142204
  async readThread(id2) {
141828
- let owner = await this.owner(id2), { thread: thread2 } = await this.host.request(
142205
+ let owner = await this.owner(id2), { thread: thread3 } = await this.host.request(
141829
142206
  "thread/read",
141830
142207
  {
141831
142208
  threadId: id2,
141832
142209
  includeTurns: !1
141833
142210
  }
141834
142211
  );
141835
- if (thread2.id !== id2 || owner.owner === "external" && thread2.modelProvider !== "codexhost")
142212
+ if (thread3.id !== id2 || owner.owner === "external" && thread3.modelProvider !== "codexhost")
141836
142213
  throw new SessionRuntimeError("session/ownership-unconfirmed", "Thread identity was not confirmed.");
141837
- return { thread: thread2, harnessId: owner.harnessId };
142214
+ return { thread: thread3, harnessId: owner.harnessId };
141838
142215
  }
141839
142216
  register(rpc2, streams2) {
141840
142217
  this.fileReferences.register(rpc2), this.fileInputs?.register(rpc2), rpc2.register("codexhost/turnDiffs", async (args) => {
@@ -141916,9 +142293,9 @@ var ChSessions = class {
141916
142293
  if (id2.startsWith("draft-"))
141917
142294
  throw new SessionRuntimeError("session/not-found", "Draft Session is no longer available.");
141918
142295
  await Promise.all([this.tree.refresh(), this.refreshPins()]);
141919
- let { thread: thread2, harnessId } = await this.readThread(id2);
141920
- this.rows.set(thread2.id, thread2), this.threads.setHarness(thread2.id, harnessId);
141921
- let direct = /* @__PURE__ */ new Map([[thread2.id, thread2]]);
142296
+ let { thread: thread3, harnessId } = await this.readThread(id2);
142297
+ this.rows.set(thread3.id, thread3), this.threads.setHarness(thread3.id, harnessId);
142298
+ let direct = /* @__PURE__ */ new Map([[thread3.id, thread3]]);
141922
142299
  return await this.tree.supplement(direct, async (ancestorId) => {
141923
142300
  let ancestor = await this.readThread(ancestorId);
141924
142301
  return this.rows.set(ancestorId, ancestor.thread), this.threads.setHarness(ancestorId, ancestor.harnessId), ancestor.thread.archived === !0 && this.updateArchive(ancestorId, !0), ancestor.thread;
@@ -142085,7 +142462,16 @@ var ChSessions = class {
142085
142462
  "session/attachment-invalid",
142086
142463
  "Shared CH input currently accepts text only."
142087
142464
  );
142088
- let draft = this.drafts.get(request3.sessionId), existingOwner = !draft || draft.canonicalId ? await this.owner(request3.sessionId) : void 0, steerTurnId;
142465
+ let draft = this.drafts.get(request3.sessionId);
142466
+ if (nativeCodexGoalInvocation.test(
142467
+ request3.content.filter((part) => part.type === "text").map((part) => part.text ?? "").join(`
142468
+ `).trim()
142469
+ ) && await this.goalScope(request3.sessionId) !== "other")
142470
+ throw new SessionRuntimeError(
142471
+ "goal/command-required",
142472
+ "Submit /goal as a command on a local Codex Thread with native goals enabled."
142473
+ );
142474
+ let existingOwner = !draft || draft.canonicalId ? await this.owner(request3.sessionId) : void 0, steerTurnId;
142089
142475
  if (request3.mode === "steer") {
142090
142476
  let view = existingOwner && await this.view(request3.sessionId, !0), activeTurnId = view ? view.log.projections[WEB_ACTIVE_TURN_PROJECTION] : null;
142091
142477
  if (!existingOwner || !view || typeof activeTurnId != "string" || request3.expectedTurnId !== void 0 && request3.expectedTurnId !== activeTurnId)
@@ -142422,6 +142808,32 @@ var ChSessions = class {
142422
142808
  );
142423
142809
  }, 6e4), this.idleViewTimer.unref();
142424
142810
  }
142811
+ currentGoalView(view) {
142812
+ let id2 = view.thread.id, row = this.rows.get(id2) ?? view.thread;
142813
+ return !this.closed && this.hostOnline && this.threads.view(id2) === view && this.threads.harnessId(id2) === "codex" && !this.workspaces.isArchived(id2) && !row.archived && !row.parentThreadId && row.canAcceptDirectInput !== !1 && !view.thread.archived && !view.thread.parentThreadId && view.thread.canAcceptDirectInput !== !1;
142814
+ }
142815
+ async supportsDraftGoals() {
142816
+ return (await this.host.request(
142817
+ "experimentalFeature/list",
142818
+ {}
142819
+ )).data?.some((feature) => feature.name === "goals" && feature.enabled) === !0;
142820
+ }
142821
+ async goalScope(sessionId) {
142822
+ let draft = this.drafts.get(sessionId);
142823
+ if (draft && !draft.canonicalId)
142824
+ return draft.selection.provider !== "codex" ? "other" : this.closed || !this.hostOnline ? "unavailable" : "draft";
142825
+ let id2 = this.id(sessionId);
142826
+ if (!id2 || id2.startsWith("draft-") || id2.startsWith("web-remote:")) return "other";
142827
+ let harness2 = this.threads.harnessId(id2);
142828
+ if (!harness2 && this.hostOnline && !this.closed) {
142829
+ let reply = await this.host.request("codexhost/thread/ownership/list", { threadIds: [id2] }).catch(() => {
142830
+ }), owner = threadOwnershipSchema.safeParse(reply?.threads?.[0]);
142831
+ owner.success && owner.data.threadId === id2 && owner.data.owner === "codex" && (harness2 = "codex");
142832
+ }
142833
+ if (harness2 !== "codex") return "other";
142834
+ let row = this.rows.get(id2) ?? this.threads.view(id2)?.thread;
142835
+ return this.closed || !this.hostOnline || row?.parentThreadId || row?.archived || this.workspaces.isArchived(id2) || row?.canAcceptDirectInput === !1 ? "unavailable" : "local";
142836
+ }
142425
142837
  registerCommands(rpc2) {
142426
142838
  this.skills.register(rpc2);
142427
142839
  let native2 = new ChHarnessCommands(this.host, async (sessionId) => {
@@ -142431,13 +142843,13 @@ var ChSessions = class {
142431
142843
  if (this.closed || !this.hostOnline)
142432
142844
  throw new SessionRuntimeError("host/offline", "The Host is disconnected.");
142433
142845
  await this.owner(id2);
142434
- let { thread: thread2 } = await this.host.request("thread/read", {
142846
+ let { thread: thread3 } = await this.host.request("thread/read", {
142435
142847
  threadId: id2,
142436
142848
  includeTurns: !1
142437
142849
  });
142438
- if (thread2.id !== id2 || thread2.parentThreadId || thread2.canAcceptDirectInput === !1)
142850
+ if (thread3.id !== id2 || thread3.parentThreadId || thread3.canAcceptDirectInput === !1)
142439
142851
  throw new SessionRuntimeError("command/unavailable", "Commands require an editable local Thread.");
142440
- return thread2;
142852
+ return thread3;
142441
142853
  });
142442
142854
  rpc2.register("codexhost/threadCommands", (args) => {
142443
142855
  let { sessionId } = requestOf(args), draft = this.drafts.get(sessionId);
@@ -142454,8 +142866,69 @@ var ChSessions = class {
142454
142866
  options: [],
142455
142867
  defaultOptions: [],
142456
142868
  defaultPreset: ""
142457
- })), rpc2.register("commands/list", () => [permissionCommand]), rpc2.register("commands/execute", async (args) => {
142458
- let id2 = String(args.agentId ?? ""), match = /^\/permission\s+(.+)$/u.exec(String(args.line ?? ""));
142869
+ })), rpc2.register("commands/list", async (args) => {
142870
+ let id2 = String(args.agentId ?? "");
142871
+ try {
142872
+ let scope2 = await this.goalScope(id2);
142873
+ if (scope2 === "draft" && await this.supportsDraftGoals() && await this.goalScope(id2) === "draft")
142874
+ return [permissionCommand, goalCommand];
142875
+ if (scope2 === "local" && nativeCodexGoalResultSchema.safeParse(
142876
+ await this.host.request(NATIVE_CODEX_GOAL_METHOD, {
142877
+ threadId: this.id(id2),
142878
+ action: "get"
142879
+ })
142880
+ ).success)
142881
+ return [permissionCommand, goalCommand];
142882
+ } catch {
142883
+ }
142884
+ return [permissionCommand];
142885
+ }), rpc2.register("commands/execute", async (args) => {
142886
+ let id2 = String(args.agentId ?? ""), line = String(args.line ?? "").trim();
142887
+ if (nativeCodexGoalInvocation.test(line)) {
142888
+ let scope2 = await this.goalScope(id2);
142889
+ if (scope2 === "other") return;
142890
+ if (scope2 === "unavailable")
142891
+ throw new SessionRuntimeError("goal/unavailable", "Goals require an editable local Codex Thread.");
142892
+ if (Array.isArray(args.submittedAttachments) && args.submittedAttachments.length)
142893
+ throw new SessionRuntimeError("goal/attachments", "/goal only accepts text.");
142894
+ let operation = parseGoalArguments(line.slice(5).trim()), threadId = this.id(id2);
142895
+ if (scope2 === "draft") {
142896
+ let draft2 = this.drafts.get(id2);
142897
+ if (operation.action !== "create")
142898
+ throw new SessionRuntimeError("goal/objective-required", "Enter an objective: /goal <objective>.");
142899
+ let validated = nativeCodexGoalRequestSchema.safeParse({ threadId: id2, ...operation });
142900
+ if (!validated.success)
142901
+ throw new SessionRuntimeError(
142902
+ "goal/invalid-arguments",
142903
+ validated.error.issues[0]?.message ?? "Invalid goal objective."
142904
+ );
142905
+ if (!await this.supportsDraftGoals())
142906
+ throw new SessionRuntimeError(
142907
+ "goal/unavailable",
142908
+ "Native goals are not enabled in this Codex version."
142909
+ );
142910
+ if (!draft2 || this.drafts.get(id2) !== draft2 || draft2.selection.provider !== "codex" || this.closed || !this.hostOnline || draft2.creating || draft2.started)
142911
+ throw new SessionRuntimeError("session/busy", "Draft selection changed.");
142912
+ threadId = await this.commit(draft2, operation.objective);
142913
+ }
142914
+ let view = await this.view(threadId, !0), read2 = operation.action === "get" ? this.nativeGoals.beginRead(view) : void 0, { goal } = nativeCodexGoalResultSchema.parse(
142915
+ await this.host.request(NATIVE_CODEX_GOAL_METHOD, { threadId, ...operation }).catch((error62) => {
142916
+ throw error62 instanceof SessionRuntimeError && (error62.code === "host/method-unavailable" || "hostCode" in error62.details && error62.details.hostCode === -32601 || /goals feature is disabled|ephemeral thread does not support goals/iu.test(
142917
+ error62.message
142918
+ )) ? new SessionRuntimeError(
142919
+ "goal/unavailable",
142920
+ "This Codex Thread does not support native goals."
142921
+ ) : error62;
142922
+ })
142923
+ ), commandId = randomUUID23();
142924
+ this.currentGoalView(view) && this.nativeGoals.confirm(view, goal, read2);
142925
+ let visible = operation.action === "get" ? view.log.projections.codexGoal : void 0, text4 = goalReceipt(
142926
+ visible ? visible.goal : goal,
142927
+ operation.action === "clear"
142928
+ ), log46 = view?.log;
142929
+ return log46?.append("command/run", { commandId, name: "goal", source: { kind: "user" } }), log46?.append("command/done", { commandId, kind: "success", text: text4 }), { commandId, result: { kind: "success", text: text4 } };
142930
+ }
142931
+ let match = /^\/permission\s+(.+)$/u.exec(line);
142459
142932
  if (!match) return;
142460
142933
  let modeId = match[1] ?? "", draft = this.drafts.get(id2), harnessId = draft && !draft.canonicalId ? draft.selection.provider : (await this.owner(id2)).harnessId, inspection = await this.catalog.inspect(
142461
142934
  harnessId,
@@ -144466,7 +144939,7 @@ async function snapshotPackagedHost(distribution, data2) {
144466
144939
 
144467
144940
  // packages/web-server/src/main.ts
144468
144941
  var RELEASE_WEB = !0, DISTRIBUTION_ROOT = resolve25(import.meta.dirname, ".."), PACKED_WEB = join36(DISTRIBUTION_ROOT, "web"), PACKED = existsSync16(join36(PACKED_WEB, "plugins.json")), REPO_ROOT = resolve25(import.meta.dirname, "../../.."), SERVER_VERSION = resolveServerVersion(
144469
- "0.29.1",
144942
+ "0.30.0",
144470
144943
  [join36(DISTRIBUTION_ROOT, "package.json"), join36(REPO_ROOT, "package.json")]
144471
144944
  );
144472
144945
  if (PACKED) {