@codexhost/cli-darwin-x64 0.14.0 → 0.16.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.
@@ -7091,10 +7091,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
7091
7091
  const shape = def.shape;
7092
7092
  const propValues = {};
7093
7093
  for (const key in shape) {
7094
- const field = shape[key]._zod;
7095
- if (field.values) {
7094
+ const field2 = shape[key]._zod;
7095
+ if (field2.values) {
7096
7096
  propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
7097
- for (const v of field.values)
7097
+ for (const v of field2.values)
7098
7098
  propValues[key].add(v);
7099
7099
  }
7100
7100
  }
@@ -18734,6 +18734,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
18734
18734
  cachedInputTokens: count,
18735
18735
  cacheWriteInputTokens: count,
18736
18736
  cacheKnownInputTokens: count,
18737
+ cacheHitCachedInputTokens: count,
18738
+ cacheHitInputTokens: count,
18737
18739
  outputTokens: count,
18738
18740
  reasoningOutputTokens: count,
18739
18741
  /** USD at the public price, summed over the priced requests only. */
@@ -18841,6 +18843,51 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
18841
18843
  var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
18842
18844
  var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
18843
18845
 
18846
+ // ../../shared-contracts/dist/thread-questions.js
18847
+ var field = external_exports.discriminatedUnion("type", [
18848
+ external_exports.object({
18849
+ id: external_exports.string().min(1),
18850
+ type: external_exports.literal("choice"),
18851
+ prompt: external_exports.string(),
18852
+ options: external_exports.array(external_exports.object({
18853
+ value: external_exports.string().min(1),
18854
+ label: external_exports.string(),
18855
+ description: external_exports.string().optional()
18856
+ })).min(1),
18857
+ multiple: external_exports.boolean(),
18858
+ allowOther: external_exports.boolean(),
18859
+ optional: external_exports.boolean()
18860
+ }),
18861
+ external_exports.object({
18862
+ id: external_exports.string().min(1),
18863
+ type: external_exports.literal("text"),
18864
+ prompt: external_exports.string(),
18865
+ multiline: external_exports.boolean(),
18866
+ secret: external_exports.literal(false),
18867
+ optional: external_exports.boolean(),
18868
+ placeholder: external_exports.string().optional(),
18869
+ prefill: external_exports.string().optional()
18870
+ })
18871
+ ]);
18872
+ var threadQuestionSchema = external_exports.object({
18873
+ interactionId: external_exports.string().min(1),
18874
+ turnId: external_exports.string().min(1),
18875
+ title: external_exports.string().optional(),
18876
+ questions: external_exports.array(field).min(1)
18877
+ }).refine(({ questions }) => questions.some((q) => q.type === "choice" && q.multiple), {
18878
+ message: "Shared cards require at least one multi-select question"
18879
+ });
18880
+ var threadQuestionsListParamsSchema = external_exports.strictObject({ threadId: external_exports.string().min(1) });
18881
+ var threadQuestionsResultSchema = external_exports.object({ questions: external_exports.array(threadQuestionSchema) });
18882
+ var threadQuestionRespondParamsSchema = external_exports.strictObject({
18883
+ threadId: external_exports.string().min(1),
18884
+ turnId: external_exports.string().min(1),
18885
+ interactionId: external_exports.string().min(1),
18886
+ answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
18887
+ cancelled: external_exports.boolean().default(false)
18888
+ });
18889
+ var threadQuestionRespondResultSchema = external_exports.object({ accepted: external_exports.literal(true) });
18890
+
18844
18891
  // ../../shared-contracts/dist/console.js
18845
18892
  var consoleAnnouncementSchema = external_exports.strictObject({
18846
18893
  title: external_exports.string().trim().min(1).max(200),
@@ -27558,19 +27605,19 @@ var CopilotSession = class {
27558
27605
  }
27559
27606
  async _input(message, options2) {
27560
27607
  this.assertElicitation();
27561
- const field = { type: "string" };
27562
- if (options2?.title) field.title = options2.title;
27563
- if (options2?.description) field.description = options2.description;
27564
- if (options2?.minLength != null) field.minLength = options2.minLength;
27565
- if (options2?.maxLength != null) field.maxLength = options2.maxLength;
27566
- if (options2?.format) field.format = options2.format;
27567
- if (options2?.default != null) field.default = options2.default;
27608
+ const field2 = { type: "string" };
27609
+ if (options2?.title) field2.title = options2.title;
27610
+ if (options2?.description) field2.description = options2.description;
27611
+ if (options2?.minLength != null) field2.minLength = options2.minLength;
27612
+ if (options2?.maxLength != null) field2.maxLength = options2.maxLength;
27613
+ if (options2?.format) field2.format = options2.format;
27614
+ if (options2?.default != null) field2.default = options2.default;
27568
27615
  const result = await this.rpc.ui.elicitation({
27569
27616
  message,
27570
27617
  requestedSchema: {
27571
27618
  type: "object",
27572
27619
  properties: {
27573
- value: field
27620
+ value: field2
27574
27621
  },
27575
27622
  required: ["value"]
27576
27623
  }
@@ -28745,14 +28792,14 @@ function toolFilterListToArray(value) {
28745
28792
  }
28746
28793
  return value instanceof ToolSet ? value.toArray() : value;
28747
28794
  }
28748
- function validateToolFilterList(field, list) {
28795
+ function validateToolFilterList(field2, list) {
28749
28796
  if (!list) {
28750
28797
  return;
28751
28798
  }
28752
28799
  for (const entry of list) {
28753
28800
  if (entry === "*") {
28754
28801
  throw new Error(
28755
- `Invalid ${field} entry '*': there is no bare wildcard. Use one or more of \`new ToolSet().addBuiltIn('*')\`, \`.addMcp('*')\`, or \`.addCustom('*')\` to target a specific source.`
28802
+ `Invalid ${field2} entry '*': there is no bare wildcard. Use one or more of \`new ToolSet().addBuiltIn('*')\`, \`.addMcp('*')\`, or \`.addCustom('*')\` to target a specific source.`
28756
28803
  );
28757
28804
  }
28758
28805
  }
@@ -32163,26 +32210,26 @@ function parseHostUsage(value) {
32163
32210
  }
32164
32211
  }
32165
32212
  const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
32166
- for (const field of [
32213
+ for (const field2 of [
32167
32214
  "totalCredits",
32168
32215
  "contextUsagePercent",
32169
32216
  "apiOutputTokensPerSecond"
32170
32217
  ]) {
32171
- const candidate = value[field];
32218
+ const candidate = value[field2];
32172
32219
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
32173
- throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
32220
+ throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
32174
32221
  }
32175
32222
  }
32176
- for (const field of tokenFields) {
32177
- const candidate = value[field];
32223
+ for (const field2 of tokenFields) {
32224
+ const candidate = value[field2];
32178
32225
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
32179
- throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
32226
+ throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
32180
32227
  }
32181
32228
  }
32182
- for (const field of safeIntegerFields) {
32183
- const candidate = value[field];
32229
+ for (const field2 of safeIntegerFields) {
32230
+ const candidate = value[field2];
32184
32231
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
32185
- throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
32232
+ throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
32186
32233
  }
32187
32234
  }
32188
32235
  if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
@@ -32191,10 +32238,10 @@ function parseHostUsage(value) {
32191
32238
  if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
32192
32239
  throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
32193
32240
  }
32194
- for (const field of percentFields) {
32195
- const candidate = value[field];
32241
+ for (const field2 of percentFields) {
32242
+ const candidate = value[field2];
32196
32243
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
32197
- throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
32244
+ throw new Error(`Harness Usage '${field2}' must be between 0 and 100`);
32198
32245
  }
32199
32246
  }
32200
32247
  if (value.sessionCacheUsage !== void 0) {
@@ -32534,18 +32581,18 @@ function calendarDate(value) {
32534
32581
  const timestamp = Date.parse(value);
32535
32582
  return /^\d{4}-\d{2}-\d{2}$/u.test(value) && Number.isFinite(timestamp) && new Date(timestamp).toISOString().slice(0, 10) === value;
32536
32583
  }
32537
- function options(field) {
32538
- if (field.type === "boolean")
32584
+ function options(field2) {
32585
+ if (field2.type === "boolean")
32539
32586
  return [
32540
32587
  { value: "true", label: "Yes" },
32541
32588
  { value: "false", label: "No" }
32542
32589
  ];
32543
- if (field.type === "string" && "enum" in field)
32544
- return field.enum.map((value, index) => ({ value, label: field.enumNames?.[index] ?? value }));
32545
- if (field.type === "string" && "oneOf" in field)
32546
- return field.oneOf.map((option) => ({ value: option.const, label: option.title }));
32547
- if (field.type === "array") {
32548
- return "enum" in field.items ? field.items.enum.map((value) => ({ value, label: value })) : field.items.anyOf.map((option) => ({ value: option.const, label: option.title }));
32590
+ if (field2.type === "string" && "enum" in field2)
32591
+ return field2.enum.map((value, index) => ({ value, label: field2.enumNames?.[index] ?? value }));
32592
+ if (field2.type === "string" && "oneOf" in field2)
32593
+ return field2.oneOf.map((option) => ({ value: option.const, label: option.title }));
32594
+ if (field2.type === "array") {
32595
+ return "enum" in field2.items ? field2.items.enum.map((value) => ({ value, label: value })) : field2.items.anyOf.map((option) => ({ value: option.const, label: option.title }));
32549
32596
  }
32550
32597
  }
32551
32598
  function elicitationForm(context) {
@@ -32554,22 +32601,22 @@ function elicitationForm(context) {
32554
32601
  throw new CopilotOperationError("unsupported", "Copilot elicitation requires a supported primitive form; browser URL flows are unavailable.");
32555
32602
  if (schema.required?.some((id) => !Object.hasOwn(schema.properties, id)))
32556
32603
  throw new Error("Copilot form refers to an unknown required field");
32557
- const questions = Object.entries(schema.properties).map(([id, field]) => {
32604
+ const questions = Object.entries(schema.properties).map(([id, field2]) => {
32558
32605
  const allowed = /* @__PURE__ */ new Set([
32559
32606
  "type",
32560
32607
  "title",
32561
32608
  "description",
32562
32609
  "default",
32563
- ...field.type === "string" ? ["enum", "enumNames", "oneOf", "minLength", "maxLength", "format"] : field.type === "array" ? ["items", "minItems", "maxItems"] : field.type === "number" || field.type === "integer" ? ["minimum", "maximum"] : []
32610
+ ...field2.type === "string" ? ["enum", "enumNames", "oneOf", "minLength", "maxLength", "format"] : field2.type === "array" ? ["items", "minItems", "maxItems"] : field2.type === "number" || field2.type === "integer" ? ["minimum", "maximum"] : []
32564
32611
  ]);
32565
- if (Object.keys(field).some((key) => !allowed.has(key)))
32612
+ if (Object.keys(field2).some((key) => !allowed.has(key)))
32566
32613
  throw new CopilotOperationError("unsupported", "Copilot form contains an unsupported constraint.");
32567
- if ("format" in field && field.format && !["email", "uri", "date", "date-time"].includes(field.format))
32614
+ if ("format" in field2 && field2.format && !["email", "uri", "date", "date-time"].includes(field2.format))
32568
32615
  throw new CopilotOperationError("unsupported", "Copilot form contains an unsupported text format.");
32569
- if (!["string", "number", "integer", "boolean", "array"].includes(field.type))
32616
+ if (!["string", "number", "integer", "boolean", "array"].includes(field2.type))
32570
32617
  throw new CopilotOperationError("unsupported", "Copilot form field cannot be represented");
32571
- const prompt = [field.title ?? id, field.description].filter(Boolean).join("\n");
32572
- const choices = options(field);
32618
+ const prompt = [field2.title ?? id, field2.description].filter(Boolean).join("\n");
32619
+ const choices = options(field2);
32573
32620
  const optional2 = !schema.required?.includes(id);
32574
32621
  if (choices)
32575
32622
  return {
@@ -32577,7 +32624,7 @@ function elicitationForm(context) {
32577
32624
  type: "choice",
32578
32625
  prompt,
32579
32626
  options: choices,
32580
- multiple: field.type === "array",
32627
+ multiple: field2.type === "array",
32581
32628
  allowOther: false,
32582
32629
  optional: optional2
32583
32630
  };
@@ -32585,43 +32632,43 @@ function elicitationForm(context) {
32585
32632
  id,
32586
32633
  type: "text",
32587
32634
  prompt,
32588
- multiline: field.type === "string",
32635
+ multiline: field2.type === "string",
32589
32636
  secret: false,
32590
32637
  optional: optional2,
32591
- ...field.default === void 0 ? {} : { prefill: String(field.default) }
32638
+ ...field2.default === void 0 ? {} : { prefill: String(field2.default) }
32592
32639
  };
32593
32640
  });
32594
32641
  const decode3 = (response) => {
32595
32642
  if (response.cancelled)
32596
32643
  return { action: "cancel" };
32597
32644
  const content = /* @__PURE__ */ Object.create(null);
32598
- for (const [id, field] of Object.entries(schema.properties)) {
32645
+ for (const [id, field2] of Object.entries(schema.properties)) {
32599
32646
  const values = Object.hasOwn(response.answers, id) ? response.answers[id] ?? [] : [];
32600
32647
  if (!values.length)
32601
32648
  continue;
32602
32649
  const value = values[0] ?? "";
32603
- if (field.type === "array") {
32604
- if (field.minItems !== void 0 && values.length < field.minItems || field.maxItems !== void 0 && values.length > field.maxItems)
32650
+ if (field2.type === "array") {
32651
+ if (field2.minItems !== void 0 && values.length < field2.minItems || field2.maxItems !== void 0 && values.length > field2.maxItems)
32605
32652
  throw new Error("The number of choices is outside the native form's limits.");
32606
32653
  content[id] = values;
32607
32654
  continue;
32608
32655
  }
32609
- if (field.type === "boolean") {
32656
+ if (field2.type === "boolean") {
32610
32657
  content[id] = value === "true";
32611
32658
  continue;
32612
32659
  }
32613
- if (field.type === "number" || field.type === "integer") {
32660
+ if (field2.type === "number" || field2.type === "integer") {
32614
32661
  const number4 = Number(value);
32615
- if (!value.trim() || !Number.isFinite(number4) || field.type === "integer" && !Number.isSafeInteger(number4) || field.minimum !== void 0 && number4 < field.minimum || field.maximum !== void 0 && number4 > field.maximum)
32662
+ if (!value.trim() || !Number.isFinite(number4) || field2.type === "integer" && !Number.isSafeInteger(number4) || field2.minimum !== void 0 && number4 < field2.minimum || field2.maximum !== void 0 && number4 > field2.maximum)
32616
32663
  throw new Error("The number is outside the native form's limits.");
32617
32664
  content[id] = number4;
32618
32665
  continue;
32619
32666
  }
32620
- if (field.type === "string") {
32621
- if ("minLength" in field && field.minLength !== void 0 && Array.from(value).length < field.minLength || "maxLength" in field && field.maxLength !== void 0 && Array.from(value).length > field.maxLength)
32667
+ if (field2.type === "string") {
32668
+ if ("minLength" in field2 && field2.minLength !== void 0 && Array.from(value).length < field2.minLength || "maxLength" in field2 && field2.maxLength !== void 0 && Array.from(value).length > field2.maxLength)
32622
32669
  throw new Error("The text length is outside the native form's limits.");
32623
- if ("format" in field && field.format) {
32624
- const valid = field.format === "email" ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/u.test(value) : field.format === "uri" ? URL.canParse(value) : field.format === "date" ? calendarDate(value) : calendarDate(value.slice(0, 10)) && /^\d{4}-\d{2}-\d{2}T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/iu.test(value) && !Number.isNaN(Date.parse(value));
32670
+ if ("format" in field2 && field2.format) {
32671
+ const valid = field2.format === "email" ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/u.test(value) : field2.format === "uri" ? URL.canParse(value) : field2.format === "date" ? calendarDate(value) : calendarDate(value.slice(0, 10)) && /^\d{4}-\d{2}-\d{2}T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/iu.test(value) && !Number.isNaN(Date.parse(value));
32625
32672
  if (!valid)
32626
32673
  throw new Error("The text does not match the native form's format.");
32627
32674
  }
@@ -3401,10 +3401,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
3401
3401
  const shape = def.shape;
3402
3402
  const propValues = {};
3403
3403
  for (const key in shape) {
3404
- const field = shape[key]._zod;
3405
- if (field.values) {
3404
+ const field2 = shape[key]._zod;
3405
+ if (field2.values) {
3406
3406
  propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
3407
- for (const v of field.values)
3407
+ for (const v of field2.values)
3408
3408
  propValues[key].add(v);
3409
3409
  }
3410
3410
  }
@@ -15044,6 +15044,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
15044
15044
  cachedInputTokens: count,
15045
15045
  cacheWriteInputTokens: count,
15046
15046
  cacheKnownInputTokens: count,
15047
+ cacheHitCachedInputTokens: count,
15048
+ cacheHitInputTokens: count,
15047
15049
  outputTokens: count,
15048
15050
  reasoningOutputTokens: count,
15049
15051
  /** USD at the public price, summed over the priced requests only. */
@@ -15151,6 +15153,51 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
15151
15153
  var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
15152
15154
  var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
15153
15155
 
15156
+ // ../../shared-contracts/dist/thread-questions.js
15157
+ var field = external_exports.discriminatedUnion("type", [
15158
+ external_exports.object({
15159
+ id: external_exports.string().min(1),
15160
+ type: external_exports.literal("choice"),
15161
+ prompt: external_exports.string(),
15162
+ options: external_exports.array(external_exports.object({
15163
+ value: external_exports.string().min(1),
15164
+ label: external_exports.string(),
15165
+ description: external_exports.string().optional()
15166
+ })).min(1),
15167
+ multiple: external_exports.boolean(),
15168
+ allowOther: external_exports.boolean(),
15169
+ optional: external_exports.boolean()
15170
+ }),
15171
+ external_exports.object({
15172
+ id: external_exports.string().min(1),
15173
+ type: external_exports.literal("text"),
15174
+ prompt: external_exports.string(),
15175
+ multiline: external_exports.boolean(),
15176
+ secret: external_exports.literal(false),
15177
+ optional: external_exports.boolean(),
15178
+ placeholder: external_exports.string().optional(),
15179
+ prefill: external_exports.string().optional()
15180
+ })
15181
+ ]);
15182
+ var threadQuestionSchema = external_exports.object({
15183
+ interactionId: external_exports.string().min(1),
15184
+ turnId: external_exports.string().min(1),
15185
+ title: external_exports.string().optional(),
15186
+ questions: external_exports.array(field).min(1)
15187
+ }).refine(({ questions }) => questions.some((q) => q.type === "choice" && q.multiple), {
15188
+ message: "Shared cards require at least one multi-select question"
15189
+ });
15190
+ var threadQuestionsListParamsSchema = external_exports.strictObject({ threadId: external_exports.string().min(1) });
15191
+ var threadQuestionsResultSchema = external_exports.object({ questions: external_exports.array(threadQuestionSchema) });
15192
+ var threadQuestionRespondParamsSchema = external_exports.strictObject({
15193
+ threadId: external_exports.string().min(1),
15194
+ turnId: external_exports.string().min(1),
15195
+ interactionId: external_exports.string().min(1),
15196
+ answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
15197
+ cancelled: external_exports.boolean().default(false)
15198
+ });
15199
+ var threadQuestionRespondResultSchema = external_exports.object({ accepted: external_exports.literal(true) });
15200
+
15154
15201
  // ../../shared-contracts/dist/console.js
15155
15202
  var consoleAnnouncementSchema = external_exports.strictObject({
15156
15203
  title: external_exports.string().trim().min(1).max(200),
@@ -16501,26 +16548,26 @@ function parseHostUsage(value) {
16501
16548
  }
16502
16549
  }
16503
16550
  const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
16504
- for (const field of [
16551
+ for (const field2 of [
16505
16552
  "totalCredits",
16506
16553
  "contextUsagePercent",
16507
16554
  "apiOutputTokensPerSecond"
16508
16555
  ]) {
16509
- const candidate = value[field];
16556
+ const candidate = value[field2];
16510
16557
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
16511
- throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
16558
+ throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
16512
16559
  }
16513
16560
  }
16514
- for (const field of tokenFields) {
16515
- const candidate = value[field];
16561
+ for (const field2 of tokenFields) {
16562
+ const candidate = value[field2];
16516
16563
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
16517
- throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
16564
+ throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
16518
16565
  }
16519
16566
  }
16520
- for (const field of safeIntegerFields) {
16521
- const candidate = value[field];
16567
+ for (const field2 of safeIntegerFields) {
16568
+ const candidate = value[field2];
16522
16569
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
16523
- throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
16570
+ throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
16524
16571
  }
16525
16572
  }
16526
16573
  if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
@@ -16529,10 +16576,10 @@ function parseHostUsage(value) {
16529
16576
  if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
16530
16577
  throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
16531
16578
  }
16532
- for (const field of percentFields) {
16533
- const candidate = value[field];
16579
+ for (const field2 of percentFields) {
16580
+ const candidate = value[field2];
16534
16581
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
16535
- throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
16582
+ throw new Error(`Harness Usage '${field2}' must be between 0 and 100`);
16536
16583
  }
16537
16584
  }
16538
16585
  if (value.sessionCacheUsage !== void 0) {
@@ -17019,8 +17066,8 @@ function protobufBytes(data) {
17019
17066
  const fields = /* @__PURE__ */ new Map();
17020
17067
  while (offset < data.length) {
17021
17068
  const tag = varint();
17022
- const field = Math.floor(tag / 8), wire = tag % 8;
17023
- if (!Number.isSafeInteger(tag) || field === 0)
17069
+ const field2 = Math.floor(tag / 8), wire = tag % 8;
17070
+ if (!Number.isSafeInteger(tag) || field2 === 0)
17024
17071
  throw new Error("Invalid Cursor native field");
17025
17072
  if (wire === 0) {
17026
17073
  varint();
@@ -17030,16 +17077,16 @@ function protobufBytes(data) {
17030
17077
  if (!Number.isSafeInteger(length) || length < 0 || offset + length > data.length)
17031
17078
  throw new Error("Unsupported Cursor native record");
17032
17079
  if (wire === 2) {
17033
- const values = fields.get(field) ?? [];
17080
+ const values = fields.get(field2) ?? [];
17034
17081
  values.push(Buffer.from(data.subarray(offset, offset + length)));
17035
- fields.set(field, values);
17082
+ fields.set(field2, values);
17036
17083
  }
17037
17084
  offset += length;
17038
17085
  }
17039
17086
  return fields;
17040
17087
  }
17041
- function one(fields, field) {
17042
- const values = fields.get(field);
17088
+ function one(fields, field2) {
17089
+ const values = fields.get(field2);
17043
17090
  if (values?.length !== 1 || !values[0])
17044
17091
  throw new Error("Cursor native history identity is missing or ambiguous");
17045
17092
  return values[0];
@@ -23819,6 +23866,7 @@ var HARNESS_BROKER_PROTOCOL_VERSION = 1;
23819
23866
  var HARNESS_BROKER_MAX_FRAME_BYTES = 8 * 1024 * 1024;
23820
23867
  var HARNESS_BROKER_MAX_PENDING_REQUESTS = 32;
23821
23868
  var HARNESS_BROKER_REQUEST_TIMEOUT_MS = 15e3;
23869
+ var HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE = 100;
23822
23870
  var HARNESS_BROKER_IDLE_TIMEOUT_MS = 60 * 60 * 1e3;
23823
23871
  var HARNESS_BROKER_RETIRING_ERROR_CODE = "brokerRetiring";
23824
23872
  var harnessBrokerMethodSchema = external_exports.enum([
@@ -23826,6 +23874,8 @@ var harnessBrokerMethodSchema = external_exports.enum([
23826
23874
  "adapter.inspectAccount",
23827
23875
  "adapter.credits",
23828
23876
  "adapter.open",
23877
+ "adapter.sessionImport.list",
23878
+ "adapter.sessionImport.resolve",
23829
23879
  "adapter.subagent.readSnapshot",
23830
23880
  "session.readSnapshot",
23831
23881
  "session.readCapabilities",
@@ -23928,30 +23978,6 @@ function consumeBrokerFrames(socket, onFrame, onError) {
23928
23978
  });
23929
23979
  }
23930
23980
 
23931
- // ../../harness-broker/dist/paths.js
23932
- import os4 from "node:os";
23933
- import path10 from "node:path";
23934
- var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
23935
- var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
23936
- function defaultHarnessBrokerDirectory(environment = process.env) {
23937
- const home = environment.HOME || os4.homedir();
23938
- return path10.join(home, ".codexhost", "harness-broker");
23939
- }
23940
- function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
23941
- harnessPluginIdSchema.parse(harnessId);
23942
- if (harnessId !== "claude-code")
23943
- return path10.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
23944
- return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path10.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
23945
- }
23946
- function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
23947
- harnessPluginIdSchema.parse(harnessId);
23948
- return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
23949
- }
23950
- function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
23951
- const home = environment.HOME || os4.homedir();
23952
- return path10.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
23953
- }
23954
-
23955
23981
  // ../../harness-broker/dist/validation.js
23956
23982
  var cwdSchema = external_exports.string().min(1).max(16384);
23957
23983
  var brokerEnvironmentSchema = external_exports.object({
@@ -24002,7 +24028,31 @@ var brokerOpenInputSchema = external_exports.discriminatedUnion("kind", [
24002
24028
  forkSchema,
24003
24029
  rollbackSchema
24004
24030
  ]);
24005
- var brokerInspectInputSchema = external_exports.object({ cwd: cwdSchema.optional(), refresh: external_exports.boolean().optional() }).strict();
24031
+ var brokerInspectInputSchema = external_exports.object({
24032
+ cwd: cwdSchema.optional(),
24033
+ refresh: external_exports.boolean().optional(),
24034
+ purpose: external_exports.literal("availability").optional()
24035
+ }).strict();
24036
+ var brokerSessionImportListParamsSchema = external_exports.object({
24037
+ offset: external_exports.number().int().nonnegative().safe(),
24038
+ limit: external_exports.number().int().min(1).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE)
24039
+ }).strict();
24040
+ var brokerSessionImportResolveParamsSchema = external_exports.object({ nativeSessionId: harnessSessionImportIdSchema }).strict();
24041
+ var brokerSessionImportPageSchema = external_exports.object({
24042
+ candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE),
24043
+ total: external_exports.number().int().nonnegative().safe()
24044
+ }).strict();
24045
+ var brokerSessionImportSourceSchema = external_exports.object({
24046
+ candidate: harnessSessionImportCandidateSchema,
24047
+ nativeRef: nativeSessionRefSchema
24048
+ }).strict().superRefine((source, context) => {
24049
+ if (source.nativeRef.nativeSessionId !== source.candidate.nativeSessionId) {
24050
+ context.addIssue({
24051
+ code: "custom",
24052
+ message: "Session import source identity does not match"
24053
+ });
24054
+ }
24055
+ });
24006
24056
  var textInputSchema = external_exports.object({ type: external_exports.literal("text"), text: external_exports.string().max(4e6) }).strict();
24007
24057
  var turnStartSchema = external_exports.object({
24008
24058
  type: external_exports.literal("turn.start"),
@@ -24173,6 +24223,107 @@ var harnessOutputSchema = external_exports.custom((value) => {
24173
24223
  return false;
24174
24224
  });
24175
24225
 
24226
+ // ../../harness-broker/dist/session-import-client.js
24227
+ function createBrokerSessionImportCapability(input) {
24228
+ let listing = null;
24229
+ const closed = () => ({
24230
+ ok: false,
24231
+ error: { code: "invalidState", message: "Harness broker adapter is closed", retryable: false }
24232
+ });
24233
+ const invalid = () => ({
24234
+ ok: false,
24235
+ error: {
24236
+ code: "protocolError",
24237
+ message: "Harness broker returned invalid Session import metadata",
24238
+ retryable: false
24239
+ }
24240
+ });
24241
+ const list = async () => {
24242
+ try {
24243
+ const candidates = [];
24244
+ const identities = /* @__PURE__ */ new Set();
24245
+ let total;
24246
+ for (; ; ) {
24247
+ if (input.isClosed())
24248
+ return closed();
24249
+ const result = await input.request("adapter.sessionImport.list", {
24250
+ offset: candidates.length,
24251
+ limit: HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE
24252
+ });
24253
+ if (input.isClosed())
24254
+ return closed();
24255
+ if (!result.ok)
24256
+ return result;
24257
+ const page = brokerSessionImportPageSchema.safeParse(result.value);
24258
+ 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)
24259
+ return invalid();
24260
+ total = page.data.total;
24261
+ for (const candidate of page.data.candidates) {
24262
+ if (identities.has(candidate.nativeSessionId))
24263
+ return invalid();
24264
+ identities.add(candidate.nativeSessionId);
24265
+ candidates.push(candidate);
24266
+ }
24267
+ if (candidates.length === total)
24268
+ return { ok: true, value: candidates };
24269
+ }
24270
+ } catch (error51) {
24271
+ return { ok: false, error: input.error(error51) };
24272
+ }
24273
+ };
24274
+ return {
24275
+ listCandidates() {
24276
+ if (input.isClosed())
24277
+ return Promise.resolve(closed());
24278
+ listing ??= list().finally(() => {
24279
+ listing = null;
24280
+ });
24281
+ return listing;
24282
+ },
24283
+ async resolveCandidate(nativeSessionId) {
24284
+ if (input.isClosed())
24285
+ return closed();
24286
+ try {
24287
+ const result = await input.request("adapter.sessionImport.resolve", { nativeSessionId });
24288
+ if (input.isClosed())
24289
+ return closed();
24290
+ if (!result.ok)
24291
+ return result;
24292
+ const source = brokerSessionImportSourceSchema.safeParse(result.value);
24293
+ if (!source.success || source.data.nativeRef.harnessId !== input.harnessId || source.data.candidate.nativeSessionId !== nativeSessionId)
24294
+ return invalid();
24295
+ return { ok: true, value: source.data };
24296
+ } catch (error51) {
24297
+ return { ok: false, error: input.error(error51) };
24298
+ }
24299
+ }
24300
+ };
24301
+ }
24302
+
24303
+ // ../../harness-broker/dist/paths.js
24304
+ import os4 from "node:os";
24305
+ import path10 from "node:path";
24306
+ var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
24307
+ var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
24308
+ function defaultHarnessBrokerDirectory(environment = process.env) {
24309
+ const home = environment.HOME || os4.homedir();
24310
+ return path10.join(home, ".codexhost", "harness-broker");
24311
+ }
24312
+ function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
24313
+ harnessPluginIdSchema.parse(harnessId);
24314
+ if (harnessId !== "claude-code")
24315
+ return path10.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
24316
+ return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path10.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
24317
+ }
24318
+ function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
24319
+ harnessPluginIdSchema.parse(harnessId);
24320
+ return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
24321
+ }
24322
+ function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
24323
+ const home = environment.HOME || os4.homedir();
24324
+ return path10.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
24325
+ }
24326
+
24176
24327
  // ../../harness-broker/dist/client.js
24177
24328
  function unavailable(message, retryable = true) {
24178
24329
  return { code: "unavailable", message, retryable, stage: "harnessBroker" };
@@ -24709,6 +24860,7 @@ var BrokeredHarnessAdapter = class {
24709
24860
  commandCatalog;
24710
24861
  liveCommandCatalog;
24711
24862
  harnessId;
24863
+ sessionImport;
24712
24864
  credits;
24713
24865
  refreshCredits;
24714
24866
  #descriptorPath;
@@ -24731,6 +24883,14 @@ var BrokeredHarnessAdapter = class {
24731
24883
  };
24732
24884
  constructor(input = {}) {
24733
24885
  this.harnessId = harnessPluginIdSchema.parse(input.harnessId ?? "claude-code");
24886
+ if (input.sessionImport) {
24887
+ this.sessionImport = createBrokerSessionImportCapability({
24888
+ harnessId: this.harnessId,
24889
+ request: async (method, params) => parseHarnessResult(await this.#request(method, params, method === "adapter.sessionImport.resolve")),
24890
+ isClosed: () => this.#closed,
24891
+ error: (error51) => this.#error(error51)
24892
+ });
24893
+ }
24734
24894
  if (input.accountCredits !== false) {
24735
24895
  this.credits = () => this.#credits;
24736
24896
  this.refreshCredits = () => this.#refreshAccountCredits();
@@ -24918,6 +25078,7 @@ function createHarnessAdapter(context) {
24918
25078
  if (context.platform === "darwin" && context.managedRemoteHost) {
24919
25079
  const environment2 = { ...context.environment };
24920
25080
  return new BrokeredHarnessAdapter({
25081
+ sessionImport: true,
24921
25082
  accountCredits: false,
24922
25083
  harnessId: "cursor-cli",
24923
25084
  forwardDelegationEnvironment: true,