@karlorz/codexhost-cli-win32-x64 0.14.0-4 → 0.15.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.
@@ -25422,6 +25422,7 @@ var HARNESS_BROKER_PROTOCOL_VERSION = 1;
25422
25422
  var HARNESS_BROKER_MAX_FRAME_BYTES = 8 * 1024 * 1024;
25423
25423
  var HARNESS_BROKER_MAX_PENDING_REQUESTS = 32;
25424
25424
  var HARNESS_BROKER_REQUEST_TIMEOUT_MS = 15e3;
25425
+ var HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE = 100;
25425
25426
  var HARNESS_BROKER_IDLE_TIMEOUT_MS = 60 * 60 * 1e3;
25426
25427
  var HARNESS_BROKER_RETIRING_ERROR_CODE = "brokerRetiring";
25427
25428
  var harnessBrokerMethodSchema = external_exports.enum([
@@ -25429,6 +25430,8 @@ var harnessBrokerMethodSchema = external_exports.enum([
25429
25430
  "adapter.inspectAccount",
25430
25431
  "adapter.credits",
25431
25432
  "adapter.open",
25433
+ "adapter.sessionImport.list",
25434
+ "adapter.sessionImport.resolve",
25432
25435
  "adapter.subagent.readSnapshot",
25433
25436
  "session.readSnapshot",
25434
25437
  "session.readCapabilities",
@@ -25531,30 +25534,6 @@ function consumeBrokerFrames(socket, onFrame, onError) {
25531
25534
  });
25532
25535
  }
25533
25536
 
25534
- // ../../harness-broker/dist/paths.js
25535
- import os2 from "node:os";
25536
- import path11 from "node:path";
25537
- var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
25538
- var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
25539
- function defaultHarnessBrokerDirectory(environment = process.env) {
25540
- const home = environment.HOME || os2.homedir();
25541
- return path11.join(home, ".codexhost", "harness-broker");
25542
- }
25543
- function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
25544
- harnessPluginIdSchema.parse(harnessId);
25545
- if (harnessId !== "claude-code")
25546
- return path11.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
25547
- return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path11.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
25548
- }
25549
- function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
25550
- harnessPluginIdSchema.parse(harnessId);
25551
- return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
25552
- }
25553
- function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
25554
- const home = environment.HOME || os2.homedir();
25555
- return path11.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
25556
- }
25557
-
25558
25537
  // ../../harness-broker/dist/validation.js
25559
25538
  var cwdSchema = external_exports.string().min(1).max(16384);
25560
25539
  var brokerEnvironmentSchema = external_exports.object({
@@ -25605,7 +25584,31 @@ var brokerOpenInputSchema = external_exports.discriminatedUnion("kind", [
25605
25584
  forkSchema,
25606
25585
  rollbackSchema
25607
25586
  ]);
25608
- var brokerInspectInputSchema = external_exports.object({ cwd: cwdSchema.optional(), refresh: external_exports.boolean().optional() }).strict();
25587
+ var brokerInspectInputSchema = external_exports.object({
25588
+ cwd: cwdSchema.optional(),
25589
+ refresh: external_exports.boolean().optional(),
25590
+ purpose: external_exports.literal("availability").optional()
25591
+ }).strict();
25592
+ var brokerSessionImportListParamsSchema = external_exports.object({
25593
+ offset: external_exports.number().int().nonnegative().safe(),
25594
+ limit: external_exports.number().int().min(1).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE)
25595
+ }).strict();
25596
+ var brokerSessionImportResolveParamsSchema = external_exports.object({ nativeSessionId: harnessSessionImportIdSchema }).strict();
25597
+ var brokerSessionImportPageSchema = external_exports.object({
25598
+ candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE),
25599
+ total: external_exports.number().int().nonnegative().safe()
25600
+ }).strict();
25601
+ var brokerSessionImportSourceSchema = external_exports.object({
25602
+ candidate: harnessSessionImportCandidateSchema,
25603
+ nativeRef: nativeSessionRefSchema
25604
+ }).strict().superRefine((source, context) => {
25605
+ if (source.nativeRef.nativeSessionId !== source.candidate.nativeSessionId) {
25606
+ context.addIssue({
25607
+ code: "custom",
25608
+ message: "Session import source identity does not match"
25609
+ });
25610
+ }
25611
+ });
25609
25612
  var textInputSchema = external_exports.object({ type: external_exports.literal("text"), text: external_exports.string().max(4e6) }).strict();
25610
25613
  var turnStartSchema = external_exports.object({
25611
25614
  type: external_exports.literal("turn.start"),
@@ -25776,6 +25779,107 @@ var harnessOutputSchema = external_exports.custom((value) => {
25776
25779
  return false;
25777
25780
  });
25778
25781
 
25782
+ // ../../harness-broker/dist/session-import-client.js
25783
+ function createBrokerSessionImportCapability(input) {
25784
+ let listing = null;
25785
+ const closed = () => ({
25786
+ ok: false,
25787
+ error: { code: "invalidState", message: "Harness broker adapter is closed", retryable: false }
25788
+ });
25789
+ const invalid = () => ({
25790
+ ok: false,
25791
+ error: {
25792
+ code: "protocolError",
25793
+ message: "Harness broker returned invalid Session import metadata",
25794
+ retryable: false
25795
+ }
25796
+ });
25797
+ const list = async () => {
25798
+ try {
25799
+ const candidates = [];
25800
+ const identities = /* @__PURE__ */ new Set();
25801
+ let total;
25802
+ for (; ; ) {
25803
+ if (input.isClosed())
25804
+ return closed();
25805
+ const result = await input.request("adapter.sessionImport.list", {
25806
+ offset: candidates.length,
25807
+ limit: HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE
25808
+ });
25809
+ if (input.isClosed())
25810
+ return closed();
25811
+ if (!result.ok)
25812
+ return result;
25813
+ const page = brokerSessionImportPageSchema.safeParse(result.value);
25814
+ if (!page.success || total !== void 0 && total !== page.data.total || page.data.total < candidates.length + page.data.candidates.length || page.data.candidates.length === 0 && candidates.length < page.data.total)
25815
+ return invalid();
25816
+ total = page.data.total;
25817
+ for (const candidate of page.data.candidates) {
25818
+ if (identities.has(candidate.nativeSessionId))
25819
+ return invalid();
25820
+ identities.add(candidate.nativeSessionId);
25821
+ candidates.push(candidate);
25822
+ }
25823
+ if (candidates.length === total)
25824
+ return { ok: true, value: candidates };
25825
+ }
25826
+ } catch (error51) {
25827
+ return { ok: false, error: input.error(error51) };
25828
+ }
25829
+ };
25830
+ return {
25831
+ listCandidates() {
25832
+ if (input.isClosed())
25833
+ return Promise.resolve(closed());
25834
+ listing ??= list().finally(() => {
25835
+ listing = null;
25836
+ });
25837
+ return listing;
25838
+ },
25839
+ async resolveCandidate(nativeSessionId) {
25840
+ if (input.isClosed())
25841
+ return closed();
25842
+ try {
25843
+ const result = await input.request("adapter.sessionImport.resolve", { nativeSessionId });
25844
+ if (input.isClosed())
25845
+ return closed();
25846
+ if (!result.ok)
25847
+ return result;
25848
+ const source = brokerSessionImportSourceSchema.safeParse(result.value);
25849
+ if (!source.success || source.data.nativeRef.harnessId !== input.harnessId || source.data.candidate.nativeSessionId !== nativeSessionId)
25850
+ return invalid();
25851
+ return { ok: true, value: source.data };
25852
+ } catch (error51) {
25853
+ return { ok: false, error: input.error(error51) };
25854
+ }
25855
+ }
25856
+ };
25857
+ }
25858
+
25859
+ // ../../harness-broker/dist/paths.js
25860
+ import os2 from "node:os";
25861
+ import path11 from "node:path";
25862
+ var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
25863
+ var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
25864
+ function defaultHarnessBrokerDirectory(environment = process.env) {
25865
+ const home = environment.HOME || os2.homedir();
25866
+ return path11.join(home, ".codexhost", "harness-broker");
25867
+ }
25868
+ function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
25869
+ harnessPluginIdSchema.parse(harnessId);
25870
+ if (harnessId !== "claude-code")
25871
+ return path11.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
25872
+ return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path11.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
25873
+ }
25874
+ function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
25875
+ harnessPluginIdSchema.parse(harnessId);
25876
+ return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
25877
+ }
25878
+ function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
25879
+ const home = environment.HOME || os2.homedir();
25880
+ return path11.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
25881
+ }
25882
+
25779
25883
  // ../../harness-broker/dist/client.js
25780
25884
  function unavailable(message, retryable = true) {
25781
25885
  return { code: "unavailable", message, retryable, stage: "harnessBroker" };
@@ -26312,6 +26416,7 @@ var BrokeredHarnessAdapter = class {
26312
26416
  commandCatalog;
26313
26417
  liveCommandCatalog;
26314
26418
  harnessId;
26419
+ sessionImport;
26315
26420
  credits;
26316
26421
  refreshCredits;
26317
26422
  #descriptorPath;
@@ -26334,6 +26439,14 @@ var BrokeredHarnessAdapter = class {
26334
26439
  };
26335
26440
  constructor(input = {}) {
26336
26441
  this.harnessId = harnessPluginIdSchema.parse(input.harnessId ?? "claude-code");
26442
+ if (input.sessionImport) {
26443
+ this.sessionImport = createBrokerSessionImportCapability({
26444
+ harnessId: this.harnessId,
26445
+ request: async (method, params) => parseHarnessResult(await this.#request(method, params, method === "adapter.sessionImport.resolve")),
26446
+ isClosed: () => this.#closed,
26447
+ error: (error51) => this.#error(error51)
26448
+ });
26449
+ }
26337
26450
  if (input.accountCredits !== false) {
26338
26451
  this.credits = () => this.#credits;
26339
26452
  this.refreshCredits = () => this.#refreshAccountCredits();
@@ -26521,6 +26634,7 @@ function createHarnessAdapter(context) {
26521
26634
  if (context.platform === "darwin" && context.managedRemoteHost) {
26522
26635
  const environment2 = { ...context.environment };
26523
26636
  return new BrokeredHarnessAdapter({
26637
+ sessionImport: true,
26524
26638
  accountCredits: false,
26525
26639
  harnessId: "codebuddy",
26526
26640
  forwardDelegationEnvironment: true,
@@ -23977,6 +23977,7 @@ var HARNESS_BROKER_PROTOCOL_VERSION = 1;
23977
23977
  var HARNESS_BROKER_MAX_FRAME_BYTES = 8 * 1024 * 1024;
23978
23978
  var HARNESS_BROKER_MAX_PENDING_REQUESTS = 32;
23979
23979
  var HARNESS_BROKER_REQUEST_TIMEOUT_MS = 15e3;
23980
+ var HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE = 100;
23980
23981
  var HARNESS_BROKER_IDLE_TIMEOUT_MS = 60 * 60 * 1e3;
23981
23982
  var HARNESS_BROKER_RETIRING_ERROR_CODE = "brokerRetiring";
23982
23983
  var harnessBrokerMethodSchema = external_exports.enum([
@@ -23984,6 +23985,8 @@ var harnessBrokerMethodSchema = external_exports.enum([
23984
23985
  "adapter.inspectAccount",
23985
23986
  "adapter.credits",
23986
23987
  "adapter.open",
23988
+ "adapter.sessionImport.list",
23989
+ "adapter.sessionImport.resolve",
23987
23990
  "adapter.subagent.readSnapshot",
23988
23991
  "session.readSnapshot",
23989
23992
  "session.readCapabilities",
@@ -24086,30 +24089,6 @@ function consumeBrokerFrames(socket, onFrame, onError) {
24086
24089
  });
24087
24090
  }
24088
24091
 
24089
- // ../../harness-broker/dist/paths.js
24090
- import os4 from "node:os";
24091
- import path10 from "node:path";
24092
- var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
24093
- var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
24094
- function defaultHarnessBrokerDirectory(environment = process.env) {
24095
- const home = environment.HOME || os4.homedir();
24096
- return path10.join(home, ".codexhost", "harness-broker");
24097
- }
24098
- function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
24099
- harnessPluginIdSchema.parse(harnessId);
24100
- if (harnessId !== "claude-code")
24101
- return path10.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
24102
- return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path10.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
24103
- }
24104
- function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
24105
- harnessPluginIdSchema.parse(harnessId);
24106
- return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
24107
- }
24108
- function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
24109
- const home = environment.HOME || os4.homedir();
24110
- return path10.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
24111
- }
24112
-
24113
24092
  // ../../harness-broker/dist/validation.js
24114
24093
  var cwdSchema = external_exports.string().min(1).max(16384);
24115
24094
  var brokerEnvironmentSchema = external_exports.object({
@@ -24160,7 +24139,31 @@ var brokerOpenInputSchema = external_exports.discriminatedUnion("kind", [
24160
24139
  forkSchema,
24161
24140
  rollbackSchema
24162
24141
  ]);
24163
- var brokerInspectInputSchema = external_exports.object({ cwd: cwdSchema.optional(), refresh: external_exports.boolean().optional() }).strict();
24142
+ var brokerInspectInputSchema = external_exports.object({
24143
+ cwd: cwdSchema.optional(),
24144
+ refresh: external_exports.boolean().optional(),
24145
+ purpose: external_exports.literal("availability").optional()
24146
+ }).strict();
24147
+ var brokerSessionImportListParamsSchema = external_exports.object({
24148
+ offset: external_exports.number().int().nonnegative().safe(),
24149
+ limit: external_exports.number().int().min(1).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE)
24150
+ }).strict();
24151
+ var brokerSessionImportResolveParamsSchema = external_exports.object({ nativeSessionId: harnessSessionImportIdSchema }).strict();
24152
+ var brokerSessionImportPageSchema = external_exports.object({
24153
+ candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE),
24154
+ total: external_exports.number().int().nonnegative().safe()
24155
+ }).strict();
24156
+ var brokerSessionImportSourceSchema = external_exports.object({
24157
+ candidate: harnessSessionImportCandidateSchema,
24158
+ nativeRef: nativeSessionRefSchema
24159
+ }).strict().superRefine((source, context) => {
24160
+ if (source.nativeRef.nativeSessionId !== source.candidate.nativeSessionId) {
24161
+ context.addIssue({
24162
+ code: "custom",
24163
+ message: "Session import source identity does not match"
24164
+ });
24165
+ }
24166
+ });
24164
24167
  var textInputSchema = external_exports.object({ type: external_exports.literal("text"), text: external_exports.string().max(4e6) }).strict();
24165
24168
  var turnStartSchema = external_exports.object({
24166
24169
  type: external_exports.literal("turn.start"),
@@ -24331,6 +24334,107 @@ var harnessOutputSchema = external_exports.custom((value) => {
24331
24334
  return false;
24332
24335
  });
24333
24336
 
24337
+ // ../../harness-broker/dist/session-import-client.js
24338
+ function createBrokerSessionImportCapability(input) {
24339
+ let listing = null;
24340
+ const closed = () => ({
24341
+ ok: false,
24342
+ error: { code: "invalidState", message: "Harness broker adapter is closed", retryable: false }
24343
+ });
24344
+ const invalid = () => ({
24345
+ ok: false,
24346
+ error: {
24347
+ code: "protocolError",
24348
+ message: "Harness broker returned invalid Session import metadata",
24349
+ retryable: false
24350
+ }
24351
+ });
24352
+ const list = async () => {
24353
+ try {
24354
+ const candidates = [];
24355
+ const identities = /* @__PURE__ */ new Set();
24356
+ let total;
24357
+ for (; ; ) {
24358
+ if (input.isClosed())
24359
+ return closed();
24360
+ const result = await input.request("adapter.sessionImport.list", {
24361
+ offset: candidates.length,
24362
+ limit: HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE
24363
+ });
24364
+ if (input.isClosed())
24365
+ return closed();
24366
+ if (!result.ok)
24367
+ return result;
24368
+ const page = brokerSessionImportPageSchema.safeParse(result.value);
24369
+ if (!page.success || total !== void 0 && total !== page.data.total || page.data.total < candidates.length + page.data.candidates.length || page.data.candidates.length === 0 && candidates.length < page.data.total)
24370
+ return invalid();
24371
+ total = page.data.total;
24372
+ for (const candidate of page.data.candidates) {
24373
+ if (identities.has(candidate.nativeSessionId))
24374
+ return invalid();
24375
+ identities.add(candidate.nativeSessionId);
24376
+ candidates.push(candidate);
24377
+ }
24378
+ if (candidates.length === total)
24379
+ return { ok: true, value: candidates };
24380
+ }
24381
+ } catch (error51) {
24382
+ return { ok: false, error: input.error(error51) };
24383
+ }
24384
+ };
24385
+ return {
24386
+ listCandidates() {
24387
+ if (input.isClosed())
24388
+ return Promise.resolve(closed());
24389
+ listing ??= list().finally(() => {
24390
+ listing = null;
24391
+ });
24392
+ return listing;
24393
+ },
24394
+ async resolveCandidate(nativeSessionId) {
24395
+ if (input.isClosed())
24396
+ return closed();
24397
+ try {
24398
+ const result = await input.request("adapter.sessionImport.resolve", { nativeSessionId });
24399
+ if (input.isClosed())
24400
+ return closed();
24401
+ if (!result.ok)
24402
+ return result;
24403
+ const source = brokerSessionImportSourceSchema.safeParse(result.value);
24404
+ if (!source.success || source.data.nativeRef.harnessId !== input.harnessId || source.data.candidate.nativeSessionId !== nativeSessionId)
24405
+ return invalid();
24406
+ return { ok: true, value: source.data };
24407
+ } catch (error51) {
24408
+ return { ok: false, error: input.error(error51) };
24409
+ }
24410
+ }
24411
+ };
24412
+ }
24413
+
24414
+ // ../../harness-broker/dist/paths.js
24415
+ import os4 from "node:os";
24416
+ import path10 from "node:path";
24417
+ var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
24418
+ var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
24419
+ function defaultHarnessBrokerDirectory(environment = process.env) {
24420
+ const home = environment.HOME || os4.homedir();
24421
+ return path10.join(home, ".codexhost", "harness-broker");
24422
+ }
24423
+ function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
24424
+ harnessPluginIdSchema.parse(harnessId);
24425
+ if (harnessId !== "claude-code")
24426
+ return path10.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
24427
+ return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path10.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
24428
+ }
24429
+ function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
24430
+ harnessPluginIdSchema.parse(harnessId);
24431
+ return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
24432
+ }
24433
+ function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
24434
+ const home = environment.HOME || os4.homedir();
24435
+ return path10.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
24436
+ }
24437
+
24334
24438
  // ../../harness-broker/dist/client.js
24335
24439
  function unavailable(message, retryable = true) {
24336
24440
  return { code: "unavailable", message, retryable, stage: "harnessBroker" };
@@ -24867,6 +24971,7 @@ var BrokeredHarnessAdapter = class {
24867
24971
  commandCatalog;
24868
24972
  liveCommandCatalog;
24869
24973
  harnessId;
24974
+ sessionImport;
24870
24975
  credits;
24871
24976
  refreshCredits;
24872
24977
  #descriptorPath;
@@ -24889,6 +24994,14 @@ var BrokeredHarnessAdapter = class {
24889
24994
  };
24890
24995
  constructor(input = {}) {
24891
24996
  this.harnessId = harnessPluginIdSchema.parse(input.harnessId ?? "claude-code");
24997
+ if (input.sessionImport) {
24998
+ this.sessionImport = createBrokerSessionImportCapability({
24999
+ harnessId: this.harnessId,
25000
+ request: async (method, params) => parseHarnessResult(await this.#request(method, params, method === "adapter.sessionImport.resolve")),
25001
+ isClosed: () => this.#closed,
25002
+ error: (error51) => this.#error(error51)
25003
+ });
25004
+ }
24892
25005
  if (input.accountCredits !== false) {
24893
25006
  this.credits = () => this.#credits;
24894
25007
  this.refreshCredits = () => this.#refreshAccountCredits();
@@ -25076,6 +25189,7 @@ function createHarnessAdapter(context) {
25076
25189
  if (context.platform === "darwin" && context.managedRemoteHost) {
25077
25190
  const environment2 = { ...context.environment };
25078
25191
  return new BrokeredHarnessAdapter({
25192
+ sessionImport: true,
25079
25193
  accountCredits: false,
25080
25194
  harnessId: "cursor-cli",
25081
25195
  forwardDelegationEnvironment: true,
@@ -24309,6 +24309,7 @@ var GrokQuestions = class {
24309
24309
  emit;
24310
24310
  #pending = /* @__PURE__ */ new Map();
24311
24311
  #seenToolCalls = /* @__PURE__ */ new Set();
24312
+ #closed = false;
24312
24313
  constructor(turnId, randomUUID3, emit) {
24313
24314
  this.turnId = turnId;
24314
24315
  this.randomUUID = randomUUID3;
@@ -24327,7 +24328,7 @@ var GrokQuestions = class {
24327
24328
  return timeout;
24328
24329
  }
24329
24330
  ask(request) {
24330
- if (this.#seenToolCalls.has(request.toolCallId))
24331
+ if (this.#closed || this.#seenToolCalls.has(request.toolCallId))
24331
24332
  return Promise.resolve({ outcome: "cancelled" });
24332
24333
  this.#seenToolCalls.add(request.toolCallId);
24333
24334
  const interaction = {
@@ -24383,8 +24384,8 @@ var GrokQuestions = class {
24383
24384
  const values = response.answers[`q${index}`];
24384
24385
  if (!values?.length)
24385
24386
  continue;
24386
- if (values.some((answer) => !nonEmptyString2(answer)))
24387
- return this.#error("invalidRequest", "Grok answer must not be empty");
24387
+ if (values.some((answer) => !nonEmptyString2(answer)) || new Set(values).size !== values.length)
24388
+ return this.#error("invalidRequest", "Grok answers must be nonempty and unique");
24388
24389
  const selected = values.map((answer) => question.options.find(({ label }) => label === answer));
24389
24390
  const other = values.filter((_, position) => !selected[position]);
24390
24391
  if (other.length > 1)
@@ -24411,6 +24412,7 @@ var GrokQuestions = class {
24411
24412
  }
24412
24413
  }
24413
24414
  cancel() {
24415
+ this.#closed = true;
24414
24416
  for (const pending of this.#pending.values())
24415
24417
  this.#settle(pending, { outcome: "cancelled" }, "cancelled");
24416
24418
  }
@@ -25575,8 +25577,10 @@ var GrokSubagentLifecycle = class {
25575
25577
  ...input.prompt ? { prompt: input.prompt } : {},
25576
25578
  subagents: [subagent]
25577
25579
  };
25578
- this.#delegations.set(input.callId, { callId: input.callId, item });
25579
- this.#emit({ type: "item.started", turnId, item });
25580
+ const active = { callId: input.callId, item, published: false };
25581
+ this.#delegations.set(input.callId, active);
25582
+ if (input.nativeSubagentId)
25583
+ this.#publish(turnId, active);
25580
25584
  this.#emitState(subagent);
25581
25585
  return subagent;
25582
25586
  }
@@ -25620,12 +25624,8 @@ var GrokSubagentLifecycle = class {
25620
25624
  ...patch.status ? { status: patch.status } : {}
25621
25625
  };
25622
25626
  active.item = { ...active.item, subagents: [subagent] };
25623
- this.#emit({
25624
- type: "item.updated",
25625
- turnId,
25626
- itemId: active.item.itemId,
25627
- update: { type: "subagents.replace", subagents: active.item.subagents }
25628
- });
25627
+ if (nativeSubagentId || active.published)
25628
+ this.#publish(turnId, active);
25629
25629
  this.#emitState(subagent);
25630
25630
  return subagent;
25631
25631
  }
@@ -25675,12 +25675,8 @@ var GrokSubagentLifecycle = class {
25675
25675
  ...input.resultSummary ? { resultSummary: input.resultSummary } : {}
25676
25676
  };
25677
25677
  const item = { ...active.item, subagents: [subagent] };
25678
- this.#emit({
25679
- type: "item.updated",
25680
- turnId,
25681
- itemId: item.itemId,
25682
- update: { type: "subagents.replace", subagents: item.subagents }
25683
- });
25678
+ active.item = item;
25679
+ this.#publish(turnId, active);
25684
25680
  const outcome = input.cancellationRequested ? { status: "cancelled", reason: "Cancelled by user" } : input.failed ? { status: "failed", error: subagentFailure() } : { status: "succeeded" };
25685
25681
  this.#emit({ type: "item.completed", turnId, snapshot: { item, outcome } });
25686
25682
  this.#emitState(subagent);
@@ -25694,10 +25690,27 @@ var GrokSubagentLifecycle = class {
25694
25690
  continue;
25695
25691
  const status = outcome.status === "succeeded" ? current.status : outcome.status === "cancelled" ? "interrupted" : "failed";
25696
25692
  const item = { ...active.item, subagents: [{ ...current, status }] };
25693
+ if (!active.published) {
25694
+ active.item = item;
25695
+ this.#publish(turnId, active);
25696
+ }
25697
25697
  this.#emit({ type: "item.completed", turnId, snapshot: { item, outcome } });
25698
25698
  this.#emitState({ ...current, status });
25699
25699
  }
25700
25700
  }
25701
+ #publish(turnId, active) {
25702
+ if (!active.published) {
25703
+ active.published = true;
25704
+ this.#emit({ type: "item.started", turnId, item: active.item });
25705
+ return;
25706
+ }
25707
+ this.#emit({
25708
+ type: "item.updated",
25709
+ turnId,
25710
+ itemId: active.item.itemId,
25711
+ update: { type: "subagents.replace", subagents: active.item.subagents }
25712
+ });
25713
+ }
25701
25714
  #callIdForNative(nativeSubagentId) {
25702
25715
  for (const [callId, active] of this.#delegations) {
25703
25716
  if (active.item.subagents[0]?.nativeSubagentId === nativeSubagentId)
@@ -26511,7 +26524,7 @@ var GrokHarnessSession = class {
26511
26524
  };
26512
26525
  this.#active = active;
26513
26526
  this.#event({ type: "turn.started", turnId: command.turnId });
26514
- void this.#transport.runTurn(text, (event) => this.#handleEvent(active, event), (request) => this.#requestPermission(active, request), (request) => this.#requestElicitation(active, request), (request) => this.#active === active && this.#phase === "open" && !active.cancellationRequested ? active.questions.ask(request) : Promise.resolve({ outcome: "cancelled" })).then((response) => this.#settleFromHistory(active, terminalOutcome2(response, active.cancellationRequested), response), (error53) => this.#settleFromHistory(active, {
26527
+ void this.#transport.runTurn(text, (event) => this.#handleEvent(active, event), (request) => this.#requestPermission(active, request), (request) => this.#requestElicitation(active, request), (request) => this.#active === active && this.#phase === "open" && !active.cancellationRequested ? active.questions.ask(request) : Promise.resolve({ outcome: "cancelled" })).finally(() => active.questions.cancel()).then((response) => this.#settleFromHistory(active, terminalOutcome2(response, active.cancellationRequested), response), (error53) => this.#settleFromHistory(active, {
26515
26528
  status: "failed",
26516
26529
  error: normalizeError(error53, "nativeFailure")
26517
26530
  }));
@@ -20311,6 +20311,15 @@ var PiRpcUnsupportedCommandError = class extends Error {
20311
20311
  this.name = "PiRpcUnsupportedCommandError";
20312
20312
  }
20313
20313
  };
20314
+ var READ_ONLY_COMMANDS = /* @__PURE__ */ new Set([
20315
+ "get_state",
20316
+ "get_commands",
20317
+ "get_entries",
20318
+ "get_session_stats",
20319
+ "get_available_models",
20320
+ "get_available_thinking_levels"
20321
+ ]);
20322
+ var MAX_EXPIRED_IDS = 64;
20314
20323
  var textDecoder = new TextDecoder("utf-8", { fatal: true });
20315
20324
  function isRecord8(value) {
20316
20325
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -20533,7 +20542,11 @@ var PiRpcSession = class {
20533
20542
  #autonomousTurnHandler = null;
20534
20543
  #usageHandler = null;
20535
20544
  #usageRequestStartedAtMs = null;
20536
- #buffer = Buffer.alloc(0);
20545
+ // Pieces of the unterminated frame; joined once at its newline so a large frame (a long
20546
+ // Session's get_entries) costs linear rather than quadratic copying on the Host event loop.
20547
+ #buffer = [];
20548
+ // Ids whose read-only command timed out; Pi may still answer them late.
20549
+ #expired = /* @__PURE__ */ new Set();
20537
20550
  #child = null;
20538
20551
  #closed = false;
20539
20552
  #closePromise = null;
@@ -20946,11 +20959,13 @@ var PiRpcSession = class {
20946
20959
  }
20947
20960
  }
20948
20961
  #push(chunk) {
20949
- this.#buffer = this.#buffer.length === 0 ? chunk : Buffer.concat([this.#buffer, chunk]);
20950
- let newline = this.#buffer.indexOf(10);
20962
+ let rest = chunk;
20963
+ let newline = rest.indexOf(10);
20951
20964
  while (newline >= 0) {
20952
- const frame = this.#buffer.subarray(0, newline);
20953
- this.#buffer = this.#buffer.subarray(newline + 1);
20965
+ const tail = rest.subarray(0, newline);
20966
+ const frame = this.#buffer.length === 0 ? tail : Buffer.concat([...this.#buffer, tail]);
20967
+ this.#buffer = [];
20968
+ rest = rest.subarray(newline + 1);
20954
20969
  try {
20955
20970
  const value = JSON.parse(textDecoder.decode(frame));
20956
20971
  if (!isRecord8(value) || typeof value.type !== "string") {
@@ -20960,8 +20975,10 @@ var PiRpcSession = class {
20960
20975
  } catch (error51) {
20961
20976
  this.#fail(error51 instanceof PiRpcFaultError ? error51 : new PiRpcFaultError("protocolError", `Pi RPC returned invalid JSONL: ${message2(error51)}`));
20962
20977
  }
20963
- newline = this.#buffer.indexOf(10);
20978
+ newline = rest.indexOf(10);
20964
20979
  }
20980
+ if (rest.length !== 0)
20981
+ this.#buffer.push(rest);
20965
20982
  }
20966
20983
  #handle(value) {
20967
20984
  if (value.type === "extension_ui_request" && value.method === "notify" && typeof value.message === "string" && value.message.startsWith(PI_FAST_ACK)) {
@@ -21213,6 +21230,8 @@ var PiRpcSession = class {
21213
21230
  return;
21214
21231
  }
21215
21232
  const pending = this.#pending.get(id);
21233
+ if (!pending && this.#expired.delete(id))
21234
+ return;
21216
21235
  if (!pending) {
21217
21236
  this.#fail(new PiRpcFaultError("protocolError", "Pi RPC response id is not pending"));
21218
21237
  return;
@@ -21447,6 +21466,12 @@ var PiRpcSession = class {
21447
21466
  const error51 = new Error(`Pi RPC '${pending.command}' command timed out`);
21448
21467
  if (pending.command !== "prompt") {
21449
21468
  this.#pending.delete(id);
21469
+ if (READ_ONLY_COMMANDS.has(pending.command)) {
21470
+ this.#expired.add(id);
21471
+ if (this.#expired.size > MAX_EXPIRED_IDS) {
21472
+ this.#expired.delete(this.#expired.values().next().value);
21473
+ }
21474
+ }
21450
21475
  pending.reject(error51);
21451
21476
  return;
21452
21477
  }