@karlorz/codexhost-cli-darwin-x64 0.19.0-2 → 0.20.0-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 (57) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +24 -3
  4. package/app/console-web.js +1280 -826
  5. package/app/cpa-live-voice-hook.js +24 -3
  6. package/app/desktop-controller.mjs +24 -3
  7. package/app/host-runtime.mjs +1586 -1189
  8. package/app/plugins/antigravity/plugin.mjs +8782 -4311
  9. package/app/plugins/claude-code/plugin.mjs +26 -3
  10. package/app/plugins/codebuddy/plugin.mjs +41 -5
  11. package/app/plugins/codex-usage/plugin.mjs +26 -3
  12. package/app/plugins/copilot/plugin.mjs +26 -3
  13. package/app/plugins/cursor-cli/plugin.mjs +26 -3
  14. package/app/plugins/deepseek-harness/plugin.mjs +26 -3
  15. package/app/plugins/devin/plugin.mjs +25 -3
  16. package/app/plugins/grok/plugin.mjs +26 -3
  17. package/app/plugins/hermes/plugin.mjs +25 -3
  18. package/app/plugins/kimi-code/plugin.mjs +26 -3
  19. package/app/plugins/kiro-cli/plugin.mjs +26 -3
  20. package/app/plugins/omp/plugin.mjs +43 -5
  21. package/app/plugins/opencode/plugin.mjs +26 -3
  22. package/app/plugins/pi/plugin.mjs +45 -6
  23. package/app/plugins/qoder/plugin.mjs +48 -4
  24. package/app/plugins/qoder-cn/plugin.mjs +48 -4
  25. package/app/plugins/qwen-code/plugin.mjs +26 -3
  26. package/app/plugins/workbuddy/plugin.mjs +45 -8
  27. package/app/plugins/zcode/plugin.mjs +26 -3
  28. package/app/renderer-extension.js +1698 -983
  29. package/app/web/assets/index-B5OfOGb8.js +201 -0
  30. package/app/web/assets/index-D6-hvggd.css +1 -0
  31. package/app/web/assets/langs/{graphql-B8vkg11W.js → graphql-ChAeyPkT.js} +1 -1
  32. package/app/web/assets/langs/{http-DmoDEjMt.js → http-BvreBIbD.js} +1 -1
  33. package/app/web/assets/langs/{php-DJ5ovfAM.js → php-D8omCIuJ.js} +1 -1
  34. package/app/web/assets/langs/{rst-U5-R5x3p.js → rst-Do7RLLCS.js} +1 -1
  35. package/app/web/assets/langs/{ruby-VKVsnS0H.js → ruby-rH_O_vse.js} +1 -1
  36. package/app/web/assets/langs/{svelte-C20lOv9V.js → svelte-xZy73wAj.js} +1 -1
  37. package/app/web/assets/langs/{vue-z6Y-lzP-.js → vue-C4DW8agZ.js} +1 -1
  38. package/app/web/assets/{vendor-dSL872WO.js → vendor-C9g2bw8s.js} +3 -3
  39. package/app/web/codexhost-settings.js +1285 -827
  40. package/app/web/index.html +4 -3
  41. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +2 -2
  42. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  43. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +68 -68
  44. package/app/web/plugins/deepseek-ai__dsh-client-connection/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -69
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +3 -3
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +13 -13
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
  51. package/app/web-modules/server.mjs +135 -69
  52. package/bin/codexhost +0 -0
  53. package/libexec/codexhost-shim +0 -0
  54. package/libexec/codexhost-updater +0 -0
  55. package/package.json +1 -1
  56. package/app/web/assets/index-BCyiiDDL.js +0 -199
  57. package/app/web/assets/index-BNQIOOHE.css +0 -1
@@ -67583,28 +67583,23 @@ var RpcRegistry = class {
67583
67583
  };
67584
67584
 
67585
67585
  // packages/web-server/src/access-token-rpc.ts
67586
- function localAccessTokens(tokens, auth2, port) {
67586
+ function managedAccessTokens(tokens) {
67587
67587
  if (tokens === void 0)
67588
67588
  throw new SessionRuntimeError("auth/disabled", "Authentication is not enabled", {});
67589
- if (auth2?.local !== !0)
67590
- throw new SessionRuntimeError(
67591
- "auth/local-access-required",
67592
- "This operation is only available on this computer",
67593
- { url: `http://127.0.0.1:${String(port)}` }
67594
- );
67595
67589
  return tokens;
67596
67590
  }
67597
67591
  function registerAccessTokenRpc(rpc2, tokens, listener) {
67598
- let managed = (context) => localAccessTokens(tokens, context.auth, listener.port());
67599
- rpc2.register("codexhost/tailscaleServeSet", async (args, context) => {
67600
- managed(context);
67592
+ rpc2.register("codexhost/tailscaleServeSet", async (args) => {
67593
+ managedAccessTokens(tokens);
67601
67594
  let { enabled } = external_exports.object({ enabled: external_exports.boolean() }).strict().parse(args);
67602
67595
  return setTailscaleServe(listener.port(), enabled);
67603
- }), rpc2.register("codexhost/accessTokenGet", async (_args, context) => ({ ...managed(context).current(), ...await listener.access() })), rpc2.register(
67596
+ }), rpc2.register("codexhost/accessTokenGet", async () => ({ ...managedAccessTokens(tokens).current(), ...await listener.access() })), rpc2.register(
67604
67597
  "codexhost/accessTokenRegenerate",
67605
67598
  async (_args, context) => {
67606
- let store = managed(context);
67607
- return context.auth?.release(), { ...store.regenerate(), ...await listener.access() };
67599
+ let store = managedAccessTokens(tokens);
67600
+ context.auth?.release();
67601
+ let next = store.regenerate();
67602
+ return context.auth?.renewCookie?.(next.secret), { ...next, ...await listener.access() };
67608
67603
  }
67609
67604
  );
67610
67605
  }
@@ -67795,15 +67790,15 @@ function registerBackgroundControls(rpc2, tokens, options) {
67795
67790
  throw new SessionRuntimeError("web/background-required", "Web is not running in background mode", {});
67796
67791
  };
67797
67792
  rpc2.register("codexhost/lanSet", (args, context) => {
67798
- localAccessTokens(tokens, context.auth, options.port()), requireBackground();
67793
+ managedAccessTokens(tokens), requireBackground();
67799
67794
  let input = enabled.parse(args), changed = saveServiceOptions(options.data, {
67800
67795
  host: input.enabled ? "0.0.0.0" : "127.0.0.1"
67801
67796
  });
67802
67797
  return changed && context.afterResponse?.(() => {
67803
67798
  options.shutdown(SETTINGS_CHANGED_EXIT_CODE);
67804
67799
  }), { changed };
67805
- }), rpc2.register("codexhost/autostartSet", async (args, context) => {
67806
- localAccessTokens(tokens, context.auth, options.port()), requireBackground();
67800
+ }), rpc2.register("codexhost/autostartSet", async (args) => {
67801
+ managedAccessTokens(tokens), requireBackground();
67807
67802
  let input = enabled.parse(args);
67808
67803
  return await autostart(options.launcher, input.enabled ? "on" : "off", options.npmEntrypoint), autostartState(options.launcher);
67809
67804
  });
@@ -68246,12 +68241,24 @@ var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128, HARNESS_PERMISSION_MODE_LABEL_M
68246
68241
  }).strict();
68247
68242
 
68248
68243
  // packages/shared-contracts/dist/thread-usage.js
68249
- var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative(), finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative(), cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100), usageMeasurementSchema = external_exports.object({
68244
+ var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative(), finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative(), cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100), usageOutputTimingSchema = external_exports.object({
68245
+ version: external_exports.literal(3).optional(),
68246
+ requestId: external_exports.string().min(1),
68247
+ turnId: external_exports.string().min(1).max(1024),
68248
+ outputTokens: nonNegativeSafeIntegerSchema,
68249
+ startedAtMs: nonNegativeSafeIntegerSchema,
68250
+ completedAtMs: nonNegativeSafeIntegerSchema
68251
+ }).strict().refine((value) => value.completedAtMs > value.startedAtMs);
68252
+ var usageMeasurementSchema = external_exports.object({
68253
+ version: external_exports.union([external_exports.literal(2), external_exports.literal(3)]).optional(),
68250
68254
  value: finiteNonNegativeNumberSchema,
68251
68255
  turnId: external_exports.string().min(1).max(1024),
68252
68256
  at: nonNegativeSafeIntegerSchema
68253
68257
  }).strict(), usageMeasurementsSchema = external_exports.object({
68254
- outputTokensPerSecond: usageMeasurementSchema.optional(),
68258
+ // Unversioned intervals can omit hidden thinking time; do not restore them into averages.
68259
+ outputTimings: external_exports.array(usageOutputTimingSchema).transform((values2) => values2.filter((value) => value.version === 3)).optional(),
68260
+ // Retain independent TTFT facts when dropping incompatible speed measurements.
68261
+ outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 3).optional().catch(void 0),
68255
68262
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
68256
68263
  }).strict(), indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text3) => text3.length <= maximum)), composerIndicatorsSchema = external_exports.array(external_exports.object({
68257
68264
  kind: external_exports.literal("countdown"),
@@ -68268,6 +68275,7 @@ var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonneg
68268
68275
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
68269
68276
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
68270
68277
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
68278
+ sessionOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
68271
68279
  apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
68272
68280
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
68273
68281
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -68621,6 +68629,9 @@ var VOICE_SETTINGS_METHOD = "codexhost/voice/settings", VOICE_GATEWAY_STATUS_MET
68621
68629
  })
68622
68630
  });
68623
68631
 
68632
+ // packages/shared-contracts/dist/thread-archive-confirm.js
68633
+ var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm", threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict(), threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
68634
+
68624
68635
  // packages/shared-contracts/dist/client-channel.js
68625
68636
  var CLIENT_CHANNEL_VERSION = 1, CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
68626
68637
  var 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({
@@ -68740,7 +68751,12 @@ var clientThreadPinsSchema = external_exports.object({ threadIds: external_expor
68740
68751
  /** Current interruptible Host Turn, including command Turns omitted from client history. */
68741
68752
  activeTurnId: external_exports.string().min(1).nullable().optional(),
68742
68753
  /** Most recent explicit command in this Host process; not native conversation history. */
68743
- command: external_exports.object({ name: external_exports.string().min(1), turn: clientTurnSchema }).optional(),
68754
+ command: external_exports.object({
68755
+ name: external_exports.string().min(1),
68756
+ turn: clientTurnSchema,
68757
+ /** First ordinary Turn started after this command; its retained result is not a new event. */
68758
+ subsequentTurnId: external_exports.string().min(1).optional()
68759
+ }).optional(),
68744
68760
  thread: external_exports.object({
68745
68761
  id: external_exports.string().min(1),
68746
68762
  cwd: external_exports.string(),
@@ -68929,7 +68945,7 @@ var webNetworkAccessUrlSchema = external_exports.object({
68929
68945
  customHostname: external_exports.string().optional(),
68930
68946
  quotaUntil: external_exports.string().optional()
68931
68947
  }).strict().optional()
68932
- }).strict(), webLocalAccessRequiredDetailsSchema = external_exports.object({ url: external_exports.string() }).strict();
68948
+ }).strict();
68933
68949
 
68934
68950
  // packages/shared-contracts/dist/delegation-read.js
68935
68951
  var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
@@ -70044,16 +70060,16 @@ function encodeOfficialCodexModelRef(nativeModelId, serviceTier) {
70044
70060
  var workspaceContractVersionSchema = external_exports.literal(1);
70045
70061
 
70046
70062
  // packages/web-server/src/ui-extension-rpc.ts
70047
- function registerUiExtensionRpc(rpc2, extensions3, options) {
70048
- let local = (context) => {
70049
- if (context.auth?.local !== !0)
70063
+ function registerUiExtensionRpc(rpc2, extensions3) {
70064
+ let authenticated = (context) => {
70065
+ if (context.auth === void 0)
70050
70066
  throw new SessionRuntimeError(
70051
- "auth/local-access-required",
70052
- "Web extensions can only be managed on this computer.",
70053
- { url: `http://127.0.0.1:${String(options.port())}` }
70067
+ "auth/disabled",
70068
+ "Authentication must be enabled to manage Web extensions.",
70069
+ {}
70054
70070
  );
70055
70071
  }, mutate = async (context, operation) => {
70056
- local(context);
70072
+ authenticated(context);
70057
70073
  try {
70058
70074
  return await operation();
70059
70075
  } catch (error51) {
@@ -70064,7 +70080,7 @@ function registerUiExtensionRpc(rpc2, extensions3, options) {
70064
70080
  );
70065
70081
  }
70066
70082
  };
70067
- rpc2.register("codexhost/uiExtensions/list", (_args, context) => (local(context), extensions3.state())), rpc2.register(
70083
+ rpc2.register("codexhost/uiExtensions/list", (_args, context) => (authenticated(context), extensions3.state())), rpc2.register(
70068
70084
  "codexhost/uiExtensions/install",
70069
70085
  (args, context) => mutate(context, () => {
70070
70086
  let { spec, registry: registry2 } = webUiExtensionInstallSchema.parse(args);
@@ -70102,7 +70118,7 @@ var UI_EXTENSION_PAGE = `<!doctype html>
70102
70118
  <script>
70103
70119
  const list=document.getElementById('list'),error=document.getElementById('error'),status=document.getElementById('status');
70104
70120
  function text(tag,value,parent){const node=document.createElement(tag);node.textContent=value;parent.appendChild(node);return node}
70105
- async function rpc(action,args={}){const response=await fetch('api/codexhost/uiExtensions/'+action,{method:'POST',credentials:'same-origin',headers:{'content-type':'application/json'},body:JSON.stringify({type:'client-request',rpcId:'extensions-'+Date.now(),method:'codexhost/uiExtensions/'+action,payload:{args}})});if(!response.ok)throw new Error('HTTP '+response.status);const reply=await response.json();if(!reply.result.ok)throw new Error(reply.result.error.code==='auth/local-access-required'?'\u8BF7\u5728\u672C\u673A\u767B\u5F55\u540E\u7BA1\u7406\u3002Sign in locally to manage extensions.':reply.result.error.message);return reply.result.value}
70121
+ async function rpc(action,args={}){const response=await fetch('api/codexhost/uiExtensions/'+action,{method:'POST',credentials:'same-origin',headers:{'content-type':'application/json'},body:JSON.stringify({type:'client-request',rpcId:'extensions-'+Date.now(),method:'codexhost/uiExtensions/'+action,payload:{args}})});if(!response.ok)throw new Error('HTTP '+response.status);const reply=await response.json();if(!reply.result.ok)throw new Error(reply.result.error.code==='auth/disabled'?'\u672A\u542F\u7528\u8BBF\u95EE\u8BA4\u8BC1\u65F6\u4E0D\u80FD\u7BA1\u7406\u754C\u9762\u6269\u5C55\u3002Enable authentication to manage extensions.':reply.result.error.message);return reply.result.value}
70106
70122
  function render(state){list.replaceChildren();status.textContent=state.safeMode?'\u5F53\u524D\u4EE5\u4EC5\u5185\u7F6E\u6A21\u5F0F\u8FD0\u884C / Built-in-only mode':state.extensions.length+' \u4E2A\u5DF2\u5B89\u88C5\u6269\u5C55 / installed extensions';if(state.storeError)error.textContent=state.storeError;for(const item of state.extensions){const row=document.createElement('article');list.appendChild(row);text('h2',item.name+' '+item.version,row);const enabled=item.enabledTargets.includes('web');text('p',(enabled?'\u5DF2\u542F\u7528 Web / Web enabled':'\u5DF2\u7981\u7528 / Disabled')+' \xB7 '+(state.loadedIds.includes(item.id)?'\u670D\u52A1\u7AEF\u5DF2\u52A0\u8F7D / Loaded on server':'\u670D\u52A1\u7AEF\u672A\u52A0\u8F7D / Not loaded on server'),row);if(item.loadError)text('p',item.loadError,row);const actions=text('div','',row);actions.className='actions';const toggle=text('button',enabled?'\u7981\u7528 / Disable':'\u542F\u7528 / Enable',actions);toggle.onclick=()=>run('setEnabled',{id:item.id,enabled:!enabled});const remove=text('button','\u5378\u8F7D / Remove',actions);remove.onclick=()=>run('remove',{id:item.id})}}
70107
70123
  let busy=false;
70108
70124
  async function run(action,args){if(busy)return;busy=true;error.textContent='';document.querySelectorAll('button,input,select').forEach(b=>b.disabled=true);try{render(await rpc(action,args))}catch(e){error.textContent=e.message}finally{busy=false;document.querySelectorAll('button,input,select').forEach(b=>b.disabled=false)}}
@@ -72132,8 +72148,8 @@ var AccessAuth = class {
72132
72148
  if ((pathname === "/" || pathname === "/index.html") && this.exchange(request3, response))
72133
72149
  return { handled: !0 };
72134
72150
  let presented = presentedToken(request3, this.trust.secure(request3)), credential = presented === void 0 ? void 0 : this.credentialFor(presented.token, request3);
72135
- if (credential !== void 0) {
72136
- let auth2 = this.admit(request3, response, credential);
72151
+ if (presented !== void 0 && credential !== void 0) {
72152
+ let auth2 = this.admit(request3, response, credential, presented.source);
72137
72153
  return pathname !== "/api/auth/status" ? { handled: !1, auth: auth2 } : (response.writeHead(200, { "content-type": "application/json", "cache-control": "no-store" }).end(JSON.stringify({ authenticated: !0, local: auth2.local })), { handled: !0 });
72138
72154
  }
72139
72155
  if (PUBLIC_ASSET.test(pathname)) return { handled: !1, auth: void 0 };
@@ -72162,11 +72178,19 @@ Connection: close\r
72162
72178
  `
72163
72179
  ), socket.destroy(), !1;
72164
72180
  }
72165
- admit(request3, response, credential) {
72181
+ admit(request3, response, credential, source) {
72166
72182
  return this.trust.authenticated(request3), {
72167
72183
  credential,
72168
72184
  local: isLocalConnection(request3),
72169
- release: this.connections.track(credential, response)
72185
+ release: this.connections.track(credential, response),
72186
+ ...source === "cookie" && credential !== LOCAL_CREDENTIAL ? {
72187
+ renewCookie: (secret) => {
72188
+ response.setHeader(
72189
+ "set-cookie",
72190
+ this.cookie(request3, secret, COOKIE_MAX_AGE_SECONDS)
72191
+ );
72192
+ }
72193
+ } : {}
72170
72194
  };
72171
72195
  }
72172
72196
  /** Count an invalid token unless the address is already blocked. */
@@ -73250,9 +73274,9 @@ var RemoteRelay = class {
73250
73274
  };
73251
73275
 
73252
73276
  // packages/web-server/src/remote-relay/rpc.ts
73253
- function registerRelayRpc(rpc2, tokens, port, relay2) {
73254
- rpc2.register("codexhost/relaySet", (args, context) => {
73255
- localAccessTokens(tokens, context.auth, port());
73277
+ function registerRelayRpc(rpc2, tokens, relay2) {
73278
+ rpc2.register("codexhost/relaySet", (args) => {
73279
+ managedAccessTokens(tokens);
73256
73280
  let { enabled, name: name2, invite, kind, host } = external_exports.object({
73257
73281
  enabled: external_exports.boolean(),
73258
73282
  kind: webRelayKindSchema.optional(),
@@ -77232,15 +77256,19 @@ var ChCommandPresentation = class {
77232
77256
  );
77233
77257
  if (compacting !== this.compacting && (this.log.setProjection("compacting", compacting), this.compacting = compacting), !command) return;
77234
77258
  let { turn, name: name2 } = command;
77235
- if (this.current?.id !== turn.id && (this.current && !this.current.done && this.log.append("command/done", {
77236
- commandId: this.current.id,
77237
- kind: "error",
77238
- text: "The Host no longer reports the outcome of this command."
77239
- }), this.log.append("command/run", {
77240
- commandId: turn.id,
77241
- name: name2,
77242
- source: { kind: "user" }
77243
- }), this.current = { id: turn.id, done: !1 }), commandRunning || this.current.done) return;
77259
+ if (this.current?.id !== turn.id) {
77260
+ if (this.current && !this.current.done && (this.log.append("command/done", {
77261
+ commandId: this.current.id,
77262
+ kind: "error",
77263
+ text: "The Host no longer reports the outcome of this command."
77264
+ }), this.current.done = !0), !commandRunning && command.subsequentTurnId !== void 0) return;
77265
+ this.log.append("command/run", {
77266
+ commandId: turn.id,
77267
+ name: name2,
77268
+ source: { kind: "user" }
77269
+ }), this.current = { id: turn.id, done: !1 };
77270
+ }
77271
+ if (commandRunning || this.current.done) return;
77244
77272
  let success2 = turn.status === "completed", text3 = success2 ? turn.items.filter((item) => item.type === "agentMessage" && typeof item.text == "string").map((item) => item.text).join(`
77245
77273
  `) || void 0 : turn.error?.message ?? (turn.status === "interrupted" ? "Command cancelled." : "Command failed.");
77246
77274
  this.log.append("command/done", {
@@ -77811,6 +77839,21 @@ var THREAD_TREE_ANCESTOR_LIMIT = 64, ChThreadTree = class {
77811
77839
  } catch {
77812
77840
  }
77813
77841
  }
77842
+ async readArchivedIds() {
77843
+ let ids = /* @__PURE__ */ new Set(), seen = /* @__PURE__ */ new Set(), archived;
77844
+ for (; ; ) {
77845
+ let page = await this.host.request(THREAD_CATALOG_READ_METHOD, {
77846
+ includeArchived: !0,
77847
+ officialCursor: { live: null, ...archived === void 0 ? {} : { archived } }
77848
+ });
77849
+ for (let id of page.archivedThreadIds) ids.add(id);
77850
+ let next = page.officialCursor?.archived;
77851
+ if (next == null) return ids;
77852
+ if (seen.has(next))
77853
+ throw new SessionRuntimeError("host/catalog-invalid", "Host archive cursor did not advance.");
77854
+ seen.add(next), archived = next;
77855
+ }
77856
+ }
77814
77857
  async archive(id, archived, archivedIds, setArchived) {
77815
77858
  await this.refresh();
77816
77859
  let children = /* @__PURE__ */ new Map();
@@ -77818,10 +77861,12 @@ var THREAD_TREE_ANCESTOR_LIMIT = 64, ChThreadTree = class {
77818
77861
  let list = children.get(parent) ?? [];
77819
77862
  list.push(child), children.set(parent, list);
77820
77863
  }
77821
- let queue = [id], visited = /* @__PURE__ */ new Set(), failedSessionIds = [];
77864
+ let queue = [id], visited = /* @__PURE__ */ new Set(), failedSessionIds = [], confirmedArchiveIds;
77822
77865
  for (let next of queue)
77823
- if (!visited.has(next) && (visited.add(next), queue.push(...children.get(next) ?? []), !(next !== id && archivedIds.has(next) === archived)))
77866
+ if (!visited.has(next) && (visited.add(next), queue.push(...children.get(next) ?? []), !(next !== id && archived && archivedIds.has(next))))
77824
77867
  try {
77868
+ if (next !== id && !archived && !archivedIds.has(next) && (confirmedArchiveIds ??= this.readArchivedIds(), !(await confirmedArchiveIds).has(next)))
77869
+ continue;
77825
77870
  await setArchived(next);
77826
77871
  } catch (error51) {
77827
77872
  if (next === id) throw error51;
@@ -78929,16 +78974,18 @@ var ChSessions = class {
78929
78974
  catalog: async () => {
78930
78975
  await this.refresh();
78931
78976
  },
78932
- archived: (id, archived) => this.updateArchive(id, archived),
78977
+ archived: (id, archived) => {
78978
+ this.archiveOperations.delete(id), this.updateArchive(id, archived);
78979
+ },
78933
78980
  connection: (online) => {
78934
- this.hostOnline = online, online || this.interactions?.clear();
78981
+ this.hostOnline = online, online || (this.archiveOperations.clear(), this.interactions?.clear());
78935
78982
  for (let [, view] of this.threads.views())
78936
78983
  view.log.setProjection("nativeConnection", {
78937
78984
  state: online ? "connected" : "reconnecting"
78938
78985
  });
78939
78986
  },
78940
78987
  reset: (epoch, full) => {
78941
- if (full && this.hostEpoch === epoch && this.threads.forgetKnownTurns(), this.hostEpoch && this.hostEpoch !== epoch) {
78988
+ if (this.archiveOperations.clear(), full && this.hostEpoch === epoch && this.threads.forgetKnownTurns(), this.hostEpoch && this.hostEpoch !== epoch) {
78942
78989
  this.interactions?.clear();
78943
78990
  for (let view of this.threads.newHostGeneration()) view.log.reconnectFollowers();
78944
78991
  }
@@ -78975,6 +79022,7 @@ var ChSessions = class {
78975
79022
  refreshingCatalog = !1;
78976
79023
  refreshingArchives = !1;
78977
79024
  refreshingArchiveChanges;
79025
+ archiveOperations = /* @__PURE__ */ new Map();
78978
79026
  refreshingTiming;
78979
79027
  catalogReadAt = -1 / 0;
78980
79028
  timer;
@@ -79450,18 +79498,37 @@ var ChSessions = class {
79450
79498
  archived ? ids.add(id) : ids.delete(id), this.workspaces.setReferenceArchives([...ids].sort());
79451
79499
  }
79452
79500
  async setArchived(sessionId, archived) {
79453
- let id = this.id(sessionId);
79454
- if (this.drafts.has(id))
79455
- throw new SessionRuntimeError(
79456
- "session/not-started",
79457
- "Send the first message before archiving this Thread."
79458
- );
79459
- if (!this.threads.hasHarness(id)) {
79460
- let { thread: thread2, harnessId } = await this.readThread(id);
79461
- this.rows.set(id, thread2), this.threads.setHarness(id, harnessId);
79501
+ let id = this.id(sessionId), operation = /* @__PURE__ */ Symbol();
79502
+ this.archiveOperations.set(id, operation);
79503
+ try {
79504
+ if (this.drafts.has(id))
79505
+ throw new SessionRuntimeError(
79506
+ "session/not-started",
79507
+ "Send the first message before archiving this Thread."
79508
+ );
79509
+ if (!this.threads.hasHarness(id)) {
79510
+ let { thread: thread2, harnessId } = await this.readThread(id);
79511
+ this.rows.set(id, thread2), this.threads.setHarness(id, harnessId);
79512
+ }
79513
+ let owner = await this.owner(id);
79514
+ if (this.archiveOperations.get(id) !== operation) return;
79515
+ try {
79516
+ await this.host.request(archived ? "thread/archive" : "thread/unarchive", { threadId: id });
79517
+ } catch (error51) {
79518
+ if (!archived || owner.owner !== "codex" || !(error51 instanceof SessionRuntimeError) || error51.code !== "host/rejected" || !("hostCode" in error51.details) || error51.details.hostCode !== -32600 || error51.message !== `no rollout found for thread id ${id}` || (await this.refreshing?.catch(() => {
79519
+ }), this.archiveOperations.get(id) !== operation)) throw error51;
79520
+ let confirmation = await this.host.request(THREAD_ARCHIVE_CONFIRM_METHOD, { threadId: id }).then((value) => threadArchiveConfirmResultSchema.safeParse(value)).catch(() => {
79521
+ });
79522
+ if (!confirmation?.success || !confirmation.data.confirmed || this.archiveOperations.get(id) !== operation)
79523
+ throw error51;
79524
+ this.updateArchive(id, !0);
79525
+ return;
79526
+ }
79527
+ await this.refreshing?.catch(() => {
79528
+ }), this.archiveOperations.get(id) === operation && this.updateArchive(id, archived);
79529
+ } finally {
79530
+ this.archiveOperations.get(id) === operation && this.archiveOperations.delete(id);
79462
79531
  }
79463
- await this.owner(id), await this.host.request(archived ? "thread/archive" : "thread/unarchive", { threadId: id }), await this.refreshing?.catch(() => {
79464
- }), this.updateArchive(id, archived);
79465
79532
  }
79466
79533
  async readThread(id) {
79467
79534
  let owner = await this.owner(id), { thread: thread2 } = await this.host.request(
@@ -79816,6 +79883,7 @@ var ChSessions = class {
79816
79883
  ])
79817
79884
  rpc2.register(method2, async (args) => {
79818
79885
  let { sessionId } = requestOf(args);
79886
+ this.archiveOperations.delete(this.id(sessionId));
79819
79887
  try {
79820
79888
  await this.tree.archive(
79821
79889
  this.id(sessionId),
@@ -79991,7 +80059,7 @@ var ChSessions = class {
79991
80059
  throw new SessionRuntimeError("host/import-explicit", "CH imports must be explicitly selected.");
79992
80060
  }
79993
80061
  async close() {
79994
- this.fileReferences.close(), this.skills.close(), this.closed = !0, this.titleRequests.clear(), this.pins.close(), this.realtime?.close(), this.interactions?.clear(), clearInterval(this.timer), this.host.close();
80062
+ this.fileReferences.close(), this.skills.close(), this.closed = !0, this.archiveOperations.clear(), this.titleRequests.clear(), this.pins.close(), this.realtime?.close(), this.interactions?.clear(), clearInterval(this.timer), this.host.close();
79995
80063
  for (let sink of this.controls) sink.end();
79996
80064
  }
79997
80065
  };
@@ -84062,6 +84130,7 @@ async function readDescriptor(path8) {
84062
84130
  import { homedir as homedir7 } from "node:os";
84063
84131
  import { join as join16, resolve as resolve11 } from "node:path";
84064
84132
  var exec3 = promisify5(execFile5), METHODS = /* @__PURE__ */ new Set([
84133
+ THREAD_ARCHIVE_CONFIRM_METHOD,
84065
84134
  "codexhost/thread/tree/read",
84066
84135
  "codexhost/thread/pins/list",
84067
84136
  "codexhost/thread/pins/set",
@@ -100623,8 +100692,8 @@ function formatWebStartup(options) {
100623
100692
  options.qrCode.trimEnd()
100624
100693
  ), options.localManagementUnavailable === !0 && lines.push(
100625
100694
  "",
100626
- "This address is not this computer's local address, so the access token cannot be viewed here.",
100627
- "Listen on 127.0.0.1 or 0.0.0.0 to view it."
100695
+ "This address is not this computer's local address, so automatic local sign-in via ?token= is unavailable.",
100696
+ "Listen on 127.0.0.1 or 0.0.0.0 for an automatic local sign-in link."
100628
100697
  ), lines.push("", "Keep access links private.", ""), lines.join(`
100629
100698
  `);
100630
100699
  }
@@ -101588,16 +101657,13 @@ registerAccessTokenRpc(rpc, accessTokens, {
101588
101657
  });
101589
101658
  registerBackgroundControls(rpc, accessTokens, {
101590
101659
  background: background !== void 0,
101591
- port: () => listeningPort,
101592
101660
  data,
101593
101661
  launcher,
101594
101662
  npmEntrypoint,
101595
101663
  shutdown
101596
101664
  });
101597
101665
  registerMisc(rpc, { events });
101598
- registerUiExtensionRpc(rpc, extensions2, {
101599
- port: () => server.address().port
101600
- });
101666
+ registerUiExtensionRpc(rpc, extensions2);
101601
101667
  registerVoiceStatus(rpc, chHost);
101602
101668
  var IMMUTABLE_CACHE = "public, max-age=31536000, immutable", HARNESS_ICON_CACHE = devWebUi === void 0 ? "private, max-age=86400, stale-while-revalidate=604800" : "no-cache";
101603
101669
  async function send(request3, response, asset, cacheControl = "no-cache") {
@@ -101791,7 +101857,7 @@ var server = createWebServer((request3, response) => {
101791
101857
  console.error("[http] request failed", error51), response.headersSent ? response.destroy() : response.writeHead(500).end("internal error");
101792
101858
  });
101793
101859
  }), relay = new RemoteRelay(data, accessTokens !== void 0, server, trust);
101794
- registerRelayRpc(rpc, accessTokens, () => listeningPort, relay);
101860
+ registerRelayRpc(rpc, accessTokens, relay);
101795
101861
  serviceOptions.relayEnabled && relay.start();
101796
101862
  var wss = createBrowserWebSocketServer(), sidebarBrowser = new SidebarBrowser({ profileDirectory: join31(dataRoot, "sidebar-browser") });
101797
101863
  server.on("upgrade", (request3, socket, head) => {
package/bin/codexhost CHANGED
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karlorz/codexhost-cli-darwin-x64",
3
- "version": "0.19.0-2",
3
+ "version": "0.20.0-0",
4
4
  "description": "Run Pi and Claude Code as first-class external harnesses inside Codex Desktop.",
5
5
  "type": "module",
6
6
  "files": [