@karlorz/codexhost-cli-darwin-x64 0.22.0-6 → 0.22.0-7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,7 +7,7 @@ Run Pi and Claude Code as first-class external harnesses inside Codex Desktop.
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- npm install -g @karlorz/codexhost-cli@0.22.0-6
10
+ npm install -g @karlorz/codexhost-cli@0.22.0-7
11
11
  ```
12
12
 
13
13
  Do not install this package directly. npm selects it through the optional dependencies of `@karlorz/codexhost-cli`.
@@ -1 +1 @@
1
- {"schemaVersion":1,"version":"0.22.0-6","distribution":"npm","target":"macos-x64"}
1
+ {"schemaVersion":1,"version":"0.22.0-7","distribution":"npm","target":"macos-x64"}
@@ -18690,6 +18690,13 @@ var GROK_ACP_MODES = harnessPermissionModeCatalogSchema.parse({
18690
18690
  }
18691
18691
  ]
18692
18692
  });
18693
+ var HOST_RUN_EVERYTHING_MODE_ID = harnessPermissionModeIdSchema.parse("always-approve");
18694
+ var HOST_RUN_EVERYTHING_MODE = harnessPermissionModeSchema.parse({
18695
+ id: HOST_RUN_EVERYTHING_MODE_ID,
18696
+ label: "Run everything",
18697
+ description: "Auto-allow native tool approvals in this Host session. Does not change ACP session mode.",
18698
+ dangerous: true
18699
+ });
18693
18700
  function parsedPermissionModeId(value) {
18694
18701
  const parsed = harnessPermissionModeIdSchema.safeParse(value);
18695
18702
  return parsed.success ? parsed.data : void 0;
@@ -18697,6 +18704,27 @@ function parsedPermissionModeId(value) {
18697
18704
  function cursorUsesNativeSessionModes(info) {
18698
18705
  return cursorModes(info) !== CURSOR_MODES;
18699
18706
  }
18707
+ function cursorNativeModeIsWritable(modeId) {
18708
+ return modeId !== "plan" && modeId !== "ask";
18709
+ }
18710
+ function cursorRunnableNativeModeId(info) {
18711
+ const native = cursorModes(info);
18712
+ if (cursorUsesNativeSessionModes(info) && native.modes.some((mode) => mode.id === "default"))
18713
+ return "default";
18714
+ if (native.modes.some((mode) => mode.id === "agent"))
18715
+ return "agent";
18716
+ return native.modes.find((mode) => cursorNativeModeIsWritable(mode.id))?.id ?? native.defaultModeId;
18717
+ }
18718
+ function cursorHostPermissionModes(info, options = {}) {
18719
+ const native = cursorModes(info);
18720
+ const nativeOwnsHostId = native.modes.some((mode) => mode.id === HOST_RUN_EVERYTHING_MODE_ID);
18721
+ const modes = nativeOwnsHostId ? native.modes : [...native.modes, HOST_RUN_EVERYTHING_MODE];
18722
+ const nativeCurrent = cursorCurrentPermissionModeId(info);
18723
+ const writable = cursorNativeModeIsWritable(nativeCurrent);
18724
+ const preferred = options.effectiveHostModeId;
18725
+ const defaultModeId = preferred && modes.some((mode) => mode.id === preferred) && !(preferred === HOST_RUN_EVERYTHING_MODE_ID && !writable) ? preferred : !nativeOwnsHostId && options.unrestricted && writable ? HOST_RUN_EVERYTHING_MODE_ID : native.defaultModeId;
18726
+ return harnessPermissionModeCatalogSchema.parse({ modes, defaultModeId });
18727
+ }
18700
18728
  function cursorModes(info) {
18701
18729
  const available = (info.modes?.availableModes ?? []).flatMap((mode) => {
18702
18730
  const id = parsedPermissionModeId(mode.id);
@@ -23045,7 +23073,7 @@ var CursorTransport = class {
23045
23073
  return this.#preparation ??= this.#prepare();
23046
23074
  }
23047
23075
  async #prepare() {
23048
- const useForce = this.options.executionPolicy === "unattended-full-access" || cursorCliApprovalModeIsUnrestricted(this.options.environment, this.options.cwd);
23076
+ const useForce = this.options.executionPolicy === "unattended-full-access" || this.options.hostRunEverything === true || cursorCliApprovalModeIsUnrestricted(this.options.environment, this.options.cwd);
23049
23077
  const invocation = cursorInvocation(this.options.environment, this.options.command, useForce ? ["--force", "acp"] : ["acp"]);
23050
23078
  const child = spawn(invocation.command, invocation.arguments, {
23051
23079
  cwd: this.options.cwd,
@@ -24158,10 +24186,14 @@ import { randomUUID } from "node:crypto";
24158
24186
  var CursorInteractions = class {
24159
24187
  emit;
24160
24188
  refuseUnattendedApproval;
24189
+ autoAllowNativeToolApprovals;
24190
+ refuseMissingAllowOption;
24161
24191
  #pending = /* @__PURE__ */ new Map();
24162
- constructor(emit, refuseUnattendedApproval) {
24192
+ constructor(emit, refuseUnattendedApproval, autoAllowNativeToolApprovals, refuseMissingAllowOption) {
24163
24193
  this.emit = emit;
24164
24194
  this.refuseUnattendedApproval = refuseUnattendedApproval;
24195
+ this.autoAllowNativeToolApprovals = autoAllowNativeToolApprovals;
24196
+ this.refuseMissingAllowOption = refuseMissingAllowOption;
24165
24197
  }
24166
24198
  #ask(interaction) {
24167
24199
  return new Promise((resolve) => {
@@ -24174,6 +24206,14 @@ var CursorInteractions = class {
24174
24206
  await this.refuseUnattendedApproval();
24175
24207
  return { outcome: { outcome: "cancelled" } };
24176
24208
  }
24209
+ if (this.autoAllowNativeToolApprovals?.()) {
24210
+ const selected = request.options.find((option) => option.kind === "allow_always") ?? request.options.find((option) => option.kind === "allow_once");
24211
+ if (!selected) {
24212
+ await this.refuseMissingAllowOption?.();
24213
+ return { outcome: { outcome: "cancelled" } };
24214
+ }
24215
+ return { outcome: { outcome: "selected", optionId: selected.optionId } };
24216
+ }
24177
24217
  const response = await this.#ask({
24178
24218
  type: "approval",
24179
24219
  interactionId: hostInteractionIdSchema.parse(randomUUID()),
@@ -24701,7 +24741,10 @@ var CursorAdapter = class {
24701
24741
  status: "ready",
24702
24742
  catalog: cursorCatalog(match.info),
24703
24743
  capabilities: cursorCapabilities(match.info),
24704
- permissionModes: cursorModes(match.info)
24744
+ permissionModes: cursorHostPermissionModes(match.info, {
24745
+ ...match.initialState.effectivePermissionModeId ? { effectiveHostModeId: match.initialState.effectivePermissionModeId } : {},
24746
+ unrestricted: cursorCliApprovalModeIsUnrestricted(match.transport.options.environment, match.transport.options.cwd)
24747
+ })
24705
24748
  };
24706
24749
  }
24707
24750
  async inspect(input = {}) {
@@ -24732,7 +24775,9 @@ var CursorAdapter = class {
24732
24775
  status: "ready",
24733
24776
  catalog: cursorCatalog(info),
24734
24777
  capabilities: cursorCapabilities(info),
24735
- permissionModes: cursorModes(info)
24778
+ permissionModes: cursorHostPermissionModes(info, {
24779
+ unrestricted: cursorCliApprovalModeIsUnrestricted(transport.options.environment, transport.options.cwd)
24780
+ })
24736
24781
  };
24737
24782
  } catch (error51) {
24738
24783
  const failure = cursorError(error51);
@@ -24790,7 +24835,8 @@ var CursorAdapter = class {
24790
24835
  }
24791
24836
  const options = {
24792
24837
  ...this.transportOptions(input.cwd, input.environment),
24793
- executionPolicy
24838
+ executionPolicy,
24839
+ ...input.permissionModeId === HOST_RUN_EVERYTHING_MODE_ID ? { hostRunEverything: true } : {}
24794
24840
  };
24795
24841
  const transport = prepared ?? new CursorTransport(options);
24796
24842
  let session;
@@ -24851,7 +24897,7 @@ var CursorAdapter = class {
24851
24897
  type: "thinking.select",
24852
24898
  thinkingOptionId: input.thinkingOptionId
24853
24899
  }));
24854
- if (input.permissionModeId && cursorModes(info).modes.some((mode) => mode.id === input.permissionModeId))
24900
+ if (input.permissionModeId && cursorHostPermissionModes(info).modes.some((mode) => mode.id === input.permissionModeId))
24855
24901
  await restoreOrThrow(await session.execute({
24856
24902
  type: "permissionMode.select",
24857
24903
  permissionModeId: input.permissionModeId
@@ -24920,7 +24966,12 @@ var CursorAdapter = class {
24920
24966
  const sameEnvironment = sourceEnvironment && [
24921
24967
  .../* @__PURE__ */ new Set([...Object.keys(sourceEnvironment), ...Object.keys(options.environment)])
24922
24968
  ].every((key) => sourceEnvironment[key] === options.environment[key]);
24923
- transport = new CursorTransport({ ...options, executionPolicy }, sameEnvironment ? source?.info.nativeModels : void 0);
24969
+ const mode = input.kind === "rollbackLastTurn" ? input.permissionModeId ?? source?.initialState.effectivePermissionModeId : source?.initialState.effectivePermissionModeId;
24970
+ transport = new CursorTransport({
24971
+ ...options,
24972
+ executionPolicy,
24973
+ hostRunEverything: mode === HOST_RUN_EVERYTHING_MODE_ID
24974
+ }, sameEnvironment ? source?.info.nativeModels : void 0);
24924
24975
  const abort = (error51) => {
24925
24976
  controller.abort(error51);
24926
24977
  throw error51;
@@ -24940,7 +24991,6 @@ var CursorAdapter = class {
24940
24991
  throw new Error("Cursor native fork did not return a target");
24941
24992
  const model2 = input.kind === "rollbackLastTurn" ? input.model ?? source?.initialState.effectiveModel : source?.initialState.effectiveModel;
24942
24993
  const thinking = input.kind === "rollbackLastTurn" ? input.thinkingOptionId ?? source?.initialState.effectiveThinkingOptionId : source?.initialState.effectiveThinkingOptionId;
24943
- const mode = input.kind === "rollbackLastTurn" ? input.permissionModeId ?? source?.initialState.effectivePermissionModeId : source?.initialState.effectivePermissionModeId;
24944
24994
  const opened = await this.#openSession({
24945
24995
  kind: "resume",
24946
24996
  cwd: input.cwd,
@@ -25014,6 +25064,8 @@ var CursorSession = class {
25014
25064
  #submitted = /* @__PURE__ */ new Set();
25015
25065
  #active;
25016
25066
  #unattendedApproval = false;
25067
+ #missingAllowOption = false;
25068
+ #autoAllowNativeToolApprovals = false;
25017
25069
  #configuring = false;
25018
25070
  #closed = false;
25019
25071
  #fresh;
@@ -25053,14 +25105,47 @@ var CursorSession = class {
25053
25105
  this.#acpOnlyTurns = readCursorAcpOnlyTurns(this.#nativeSessionId, transport.options.environment);
25054
25106
  this.#snapshot = loadedSnapshot;
25055
25107
  this.#executionPolicy = transport.options.executionPolicy ?? "default";
25056
- this.#interactions = new CursorInteractions((output) => this.#channel.emit(output), this.#executionPolicy === "unattended-full-access" ? () => this.#refuseUnattendedApproval() : void 0);
25108
+ const nativeCurrent = cursorCurrentPermissionModeId(info);
25109
+ const unrestricted = cursorCliApprovalModeIsUnrestricted(transport.options.environment, transport.options.cwd);
25110
+ this.#autoAllowNativeToolApprovals = this.#executionPolicy !== "unattended-full-access" && cursorNativeModeIsWritable(nativeCurrent) && (transport.options.hostRunEverything === true || unrestricted);
25111
+ this.#interactions = new CursorInteractions((output) => this.#channel.emit(output), this.#executionPolicy === "unattended-full-access" ? () => this.#refuseUnattendedApproval() : void 0, () => this.#autoAllowNativeToolApprovals, () => this.#refuseMissingAllowOption());
25057
25112
  this.initialState = {
25058
25113
  nativeRef: cursorNativeSessionRef(this.#nativeSessionId, this.#executionPolicy),
25059
25114
  effectiveModel: cursorConfiguredModelRef(cursorModels(info).current, info.configOptions),
25060
25115
  ...cursorThinkingState(info),
25061
- effectivePermissionModeId: cursorCurrentPermissionModeId(info)
25116
+ effectivePermissionModeId: this.#autoAllowNativeToolApprovals ? HOST_RUN_EVERYTHING_MODE_ID : nativeCurrent
25062
25117
  };
25063
25118
  }
25119
+ #emitState() {
25120
+ this.#channel.emit({
25121
+ kind: "event",
25122
+ event: { type: "session.state.changed", state: structuredClone(this.initialState) }
25123
+ });
25124
+ }
25125
+ async #applyNativeMode(modeId) {
25126
+ if (cursorCurrentPermissionModeId(this.info) === modeId)
25127
+ return { ok: true, value: { completed: true } };
25128
+ if (!cursorModes(this.info).modes.some((mode) => mode.id === modeId))
25129
+ return rejected("invalidRequest", "Unknown Cursor execution mode");
25130
+ try {
25131
+ if (cursorUsesNativeSessionModes(this.info)) {
25132
+ await this.transport.setMode(modeId);
25133
+ this.info.modes = {
25134
+ currentModeId: modeId,
25135
+ availableModes: this.info.modes?.availableModes ?? []
25136
+ };
25137
+ return { ok: true, value: { completed: true } };
25138
+ }
25139
+ const result = await this.transport.configure("mode", modeId);
25140
+ const confirmed = result.configOptions.find((option) => option.id === "mode" && option.currentValue === modeId);
25141
+ if (!confirmed)
25142
+ throw new Error("Cursor did not confirm configuration selection");
25143
+ this.info.configOptions = result.configOptions.some((option) => option.id === "model") ? result.configOptions : [...(this.info.configOptions ?? []).filter((option) => option.id !== "mode"), confirmed];
25144
+ return { ok: true, value: { completed: true } };
25145
+ } catch (error51) {
25146
+ return { ok: false, error: cursorError(error51) };
25147
+ }
25148
+ }
25064
25149
  #native(allowMissing = false) {
25065
25150
  const missing = !cursorNativeStoreExists(this.transport.sessionId, this.transport.options.environment);
25066
25151
  try {
@@ -25111,6 +25196,10 @@ var CursorSession = class {
25111
25196
  this.#unattendedApproval = true;
25112
25197
  return this.transport.cancel();
25113
25198
  }
25199
+ #refuseMissingAllowOption() {
25200
+ this.#missingAllowOption = true;
25201
+ return this.transport.cancel();
25202
+ }
25114
25203
  #subagentConfiguration() {
25115
25204
  const state = this.initialState;
25116
25205
  const model2 = state.effectiveModel ? cursorModels(this.info).current : void 0;
@@ -25230,24 +25319,42 @@ var CursorSession = class {
25230
25319
  } else if (command.type === "model.select") {
25231
25320
  selections = cursorModelSelection(this.info, command.model.id);
25232
25321
  } else {
25233
- const catalog = cursorModes(this.info);
25322
+ const catalog = cursorHostPermissionModes(this.info, {
25323
+ ...this.initialState.effectivePermissionModeId ? { effectiveHostModeId: this.initialState.effectivePermissionModeId } : {}
25324
+ });
25234
25325
  if (!catalog.modes.some((mode) => mode.id === command.permissionModeId))
25235
25326
  return rejected("invalidRequest", "Unknown Cursor execution mode");
25327
+ const nativeOwnsHostId = cursorModes(this.info).modes.some((mode) => mode.id === HOST_RUN_EVERYTHING_MODE_ID);
25328
+ if (command.permissionModeId === HOST_RUN_EVERYTHING_MODE_ID && !nativeOwnsHostId) {
25329
+ if (!cursorNativeModeIsWritable(cursorCurrentPermissionModeId(this.info))) {
25330
+ const moved = await this.#applyNativeMode(cursorRunnableNativeModeId(this.info));
25331
+ if (!moved.ok)
25332
+ return moved;
25333
+ }
25334
+ this.#autoAllowNativeToolApprovals = this.#executionPolicy !== "unattended-full-access";
25335
+ this.initialState.effectivePermissionModeId = HOST_RUN_EVERYTHING_MODE_ID;
25336
+ this.#emitState();
25337
+ return { ok: true, value: { completed: true } };
25338
+ }
25236
25339
  if (cursorCurrentPermissionModeId(this.info) === command.permissionModeId) {
25340
+ this.#autoAllowNativeToolApprovals = false;
25237
25341
  this.initialState.effectivePermissionModeId = command.permissionModeId;
25342
+ this.#emitState();
25238
25343
  return { ok: true, value: { completed: true } };
25239
25344
  }
25240
25345
  if (cursorUsesNativeSessionModes(this.info)) {
25241
- await this.transport.setMode(command.permissionModeId);
25346
+ try {
25347
+ await this.transport.setMode(command.permissionModeId);
25348
+ } catch (error51) {
25349
+ return { ok: false, error: cursorError(error51) };
25350
+ }
25242
25351
  this.info.modes = {
25243
25352
  currentModeId: command.permissionModeId,
25244
25353
  availableModes: this.info.modes?.availableModes ?? []
25245
25354
  };
25355
+ this.#autoAllowNativeToolApprovals = false;
25246
25356
  this.initialState.effectivePermissionModeId = command.permissionModeId;
25247
- this.#channel.emit({
25248
- kind: "event",
25249
- event: { type: "session.state.changed", state: structuredClone(this.initialState) }
25250
- });
25357
+ this.#emitState();
25251
25358
  return { ok: true, value: { completed: true } };
25252
25359
  }
25253
25360
  selections = [["mode", command.permissionModeId]];
@@ -25263,14 +25370,20 @@ var CursorSession = class {
25263
25370
  if (model2?.type === "select")
25264
25371
  this.initialState.effectiveModel = cursorConfiguredModelRef(model2.currentValue, result.configOptions);
25265
25372
  const mode = result.configOptions.find((option) => option.id === "mode");
25266
- if (mode)
25267
- this.initialState.effectivePermissionModeId = harnessPermissionModeIdSchema.parse(mode.currentValue);
25373
+ if (mode) {
25374
+ const nativeId = harnessPermissionModeIdSchema.parse(mode.currentValue);
25375
+ if (command.type === "permissionMode.select" || !cursorNativeModeIsWritable(nativeId)) {
25376
+ this.#autoAllowNativeToolApprovals = false;
25377
+ this.initialState.effectivePermissionModeId = nativeId;
25378
+ } else if (this.#autoAllowNativeToolApprovals) {
25379
+ this.initialState.effectivePermissionModeId = HOST_RUN_EVERYTHING_MODE_ID;
25380
+ } else {
25381
+ this.initialState.effectivePermissionModeId = nativeId;
25382
+ }
25383
+ }
25268
25384
  delete this.initialState.effectiveThinkingOptionId;
25269
25385
  Object.assign(this.initialState, cursorThinkingState(this.info));
25270
- this.#channel.emit({
25271
- kind: "event",
25272
- event: { type: "session.state.changed", state: structuredClone(this.initialState) }
25273
- });
25386
+ this.#emitState();
25274
25387
  }
25275
25388
  return { ok: true, value: { completed: true } };
25276
25389
  } catch (error51) {
@@ -25287,6 +25400,7 @@ var CursorSession = class {
25287
25400
  }), before.length);
25288
25401
  this.#subagentOutput = output.subagents;
25289
25402
  this.#unattendedApproval = false;
25403
+ this.#missingAllowOption = false;
25290
25404
  this.#channel.emit({ kind: "event", event: { type: "turn.started", turnId: command.turnId } });
25291
25405
  let outcome = {
25292
25406
  status: "failed",
@@ -25331,6 +25445,15 @@ var CursorSession = class {
25331
25445
  retryable: false
25332
25446
  }
25333
25447
  };
25448
+ else if (!this.#active?.cancelled && this.#missingAllowOption)
25449
+ outcome = {
25450
+ status: "failed",
25451
+ error: {
25452
+ code: "nativeFailure",
25453
+ message: "Cursor requested approval without an allow option during Run everything",
25454
+ retryable: false
25455
+ }
25456
+ };
25334
25457
  try {
25335
25458
  const acpOnly = this.#acpOnlyNativeStore();
25336
25459
  const after = acpOnly ? [] : this.#native(this.#fresh);
@@ -30231,6 +30231,13 @@ var GrokHarnessSession = class {
30231
30231
  const prompt = grokGoalPrompt(command.arguments);
30232
30232
  if (!prompt.ok)
30233
30233
  return prompt;
30234
+ if (prompt.value === "/goal status") {
30235
+ return this.#startTurn({
30236
+ type: "turn.start",
30237
+ turnId: command.turnId,
30238
+ input: [{ type: "text", text: prompt.value }]
30239
+ }, true);
30240
+ }
30234
30241
  const goals = this.goals;
30235
30242
  const goalControl = this.#transport.goalControl?.bind(this.#transport);
30236
30243
  if (goals && goalControl) {
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.22.0-6",
3
+ "version": "0.22.0-7",
4
4
  "description": "Run Pi and Claude Code as first-class external harnesses inside Codex Desktop.",
5
5
  "type": "module",
6
6
  "files": [