@codexhost/cli-darwin-x64 0.13.3 → 0.14.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.
@@ -4209,10 +4209,13 @@ function usageSessionTitle(value) {
4209
4209
  return void 0;
4210
4210
  if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
4211
4211
  return normalized;
4212
- const characters = [...normalized];
4213
- if (characters.length <= MAX_SESSION_TITLE_LENGTH)
4214
- return normalized;
4215
- return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
4212
+ let title = "";
4213
+ for (const character of normalized) {
4214
+ if (title.length + character.length >= MAX_SESSION_TITLE_LENGTH)
4215
+ break;
4216
+ title += character;
4217
+ }
4218
+ return `${title.trimEnd()}…`;
4216
4219
  }
4217
4220
  function sessionIdOk(value) {
4218
4221
  return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
@@ -18900,10 +18903,19 @@ var model = external_exports.string().min(1).max(512);
18900
18903
  var project = external_exports.string().min(1).max(4096);
18901
18904
  var usageStatisticsParamsSchema = external_exports.strictObject({
18902
18905
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
18906
+ /** Display timezone for ranges, dates and hourly buckets; omitted means the Host's local zone. */
18907
+ timeZone: external_exports.string().min(1).max(128).refine((value) => {
18908
+ try {
18909
+ new Intl.DateTimeFormat("en", { timeZone: value });
18910
+ return true;
18911
+ } catch {
18912
+ return false;
18913
+ }
18914
+ }, "Unsupported usage statistics timezone").optional(),
18903
18915
  harness: harness.optional(),
18904
18916
  model: model.nullable().optional(),
18905
18917
  project: project.nullable().optional(),
18906
- /** One local date inside the range. */
18918
+ /** One date in the query timezone inside the range. */
18907
18919
  date: localDate.optional()
18908
18920
  });
18909
18921
  var usageStatisticsTotalsSchema = external_exports.strictObject({
@@ -18939,7 +18951,7 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
18939
18951
  });
18940
18952
  var usageStatisticsResultSchema = external_exports.strictObject({
18941
18953
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
18942
- /** First local date of the range; null for all time. */
18954
+ /** First date in the query timezone (Host local when omitted); null for all time. */
18943
18955
  from: localDate.nullable(),
18944
18956
  to: localDate,
18945
18957
  /** The filters these figures apply, echoed so a late answer to older filters is recognised. */
@@ -18979,7 +18991,7 @@ var usageStatisticsResultSchema = external_exports.strictObject({
18979
18991
  totals: usageStatisticsTotalsSchema,
18980
18992
  /** Each date and Harness of the range: every filter except the day. */
18981
18993
  daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
18982
- /** Local weekday (0 = Sunday) and hour, all filters applied. */
18994
+ /** Weekday (0 = Sunday) and hour in the query timezone, all filters applied. */
18983
18995
  hourly: external_exports.array(external_exports.strictObject({
18984
18996
  weekday: external_exports.number().int().min(0).max(6),
18985
18997
  hour: external_exports.number().int().min(0).max(23),
@@ -19039,6 +19051,8 @@ var CONSOLE_HOST_METHODS = Object.freeze([
19039
19051
  "codexhost/harness/display-settings/set",
19040
19052
  "codexhost/harness/inspect",
19041
19053
  "codexhost/harness/installation",
19054
+ "codexhost/harness/installation/start",
19055
+ "codexhost/harness/installation/status",
19042
19056
  "codexhost/harness/launch-settings/get",
19043
19057
  "codexhost/harness/launch-settings/set",
19044
19058
  "codexhost/harness/web-ui/open",
@@ -19114,7 +19128,18 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
19114
19128
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
19115
19129
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
19116
19130
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
19131
+ var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
19132
+ var composerIndicatorsSchema = external_exports.array(external_exports.object({
19133
+ kind: external_exports.literal("countdown"),
19134
+ id: external_exports.string().min(1).max(64),
19135
+ expiresAtUnix: nonNegativeSafeIntegerSchema,
19136
+ label: indicatorTextSchema(256).optional(),
19137
+ tooltip: indicatorTextSchema(1024).optional()
19138
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
19139
+ message: "Composer indicator IDs must be unique"
19140
+ });
19117
19141
  var threadUsageSnapshotSchema = external_exports.object({
19142
+ composerIndicators: composerIndicatorsSchema.optional(),
19118
19143
  inputTokens: nonNegativeSafeIntegerSchema.optional(),
19119
19144
  cachedInputTokens: nonNegativeSafeIntegerSchema.optional(),
19120
19145
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -19522,7 +19547,9 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
19522
19547
  }).strict().optional(),
19523
19548
  autonomousTurns: external_exports.object({
19524
19549
  observe: external_exports.boolean()
19525
- }).strict().optional()
19550
+ }).strict().optional(),
19551
+ /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
19552
+ steer: external_exports.boolean().optional()
19526
19553
  }).strict();
19527
19554
  var harnessConfigurationStateSchema = external_exports.object({
19528
19555
  effectiveModel: harnessModelRefSchema.optional(),
@@ -19569,7 +19596,9 @@ var harnessInspectionSchema = external_exports.union([
19569
19596
  var harnessInspectParamsSchema = external_exports.object({
19570
19597
  harnessId: harnessIdSchema,
19571
19598
  cwd: nonBlankTextSchema2.max(16384).optional(),
19572
- refresh: external_exports.boolean().optional()
19599
+ refresh: external_exports.boolean().optional(),
19600
+ /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
19601
+ purpose: external_exports.literal("availability").optional()
19573
19602
  }).strict();
19574
19603
  var harnessWebUiOpenParamsSchema = external_exports.object({
19575
19604
  harnessId: harnessIdSchema
@@ -19652,6 +19681,15 @@ var threadOwnershipListResultSchema = external_exports.object({
19652
19681
  seen.add(thread.threadId);
19653
19682
  }
19654
19683
  });
19684
+ var threadSteeringInspectParamsSchema = external_exports.object({
19685
+ threadId: hostThreadIdSchema,
19686
+ /** The text about to be steered; a Harness command always stops and restarts. */
19687
+ text: external_exports.string().optional()
19688
+ }).strict();
19689
+ var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
19690
+ var threadSteeringInspectResultSchema = external_exports.object({
19691
+ delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
19692
+ }).strict();
19655
19693
 
19656
19694
  // ../../shared-contracts/dist/harness-plugins.js
19657
19695
  var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
@@ -19753,6 +19791,10 @@ var harnessInstallationStateSchema = external_exports.object({
19753
19791
  latestVersion: external_exports.string().min(1).max(128),
19754
19792
  updateAvailable: external_exports.boolean(),
19755
19793
  canUpdate: external_exports.boolean(),
19794
+ /** Defaults to CLI; some Harnesses ship only inside a desktop application. */
19795
+ versionKind: external_exports.enum(["cli", "application"]).optional(),
19796
+ /** Official download opened by the user; does not imply an automatic installation. */
19797
+ manualUpdateUrl: external_exports.url().max(2048).refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Manual updates require a credential-free HTTPS URL").optional(),
19756
19798
  // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
19757
19799
  message: external_exports.string().max(2048).optional(),
19758
19800
  messageCode: external_exports.string().min(1).max(128).optional(),
@@ -19760,6 +19802,20 @@ var harnessInstallationStateSchema = external_exports.object({
19760
19802
  notice: harnessLocalizedTextSchema.optional(),
19761
19803
  latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
19762
19804
  }).strict();
19805
+ var harnessInstallationTaskParamsSchema = external_exports.object({ taskId: external_exports.string().uuid() }).strict();
19806
+ var harnessInstallationTaskSchema = external_exports.discriminatedUnion("status", [
19807
+ external_exports.object({ taskId: external_exports.string().uuid(), status: external_exports.literal("running") }).strict(),
19808
+ external_exports.object({
19809
+ taskId: external_exports.string().uuid(),
19810
+ status: external_exports.literal("succeeded"),
19811
+ result: harnessInstallationStateSchema
19812
+ }).strict(),
19813
+ external_exports.object({
19814
+ taskId: external_exports.string().uuid(),
19815
+ status: external_exports.literal("failed"),
19816
+ error: external_exports.object({ code: external_exports.number().int(), message: external_exports.string().min(1).max(2048) }).strict()
19817
+ }).strict()
19818
+ ]);
19763
19819
 
19764
19820
  // ../../shared-contracts/dist/codex-accounts.js
19765
19821
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
@@ -20271,6 +20327,18 @@ function sanitizeDiagnosticTail(value) {
20271
20327
  return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
20272
20328
  }
20273
20329
 
20330
+ // ../../harness-adapter/dist/steer.js
20331
+ function unsupportedSteer(harnessLabel) {
20332
+ return {
20333
+ ok: false,
20334
+ error: {
20335
+ code: "unsupported",
20336
+ message: `${harnessLabel} cannot steer an active Turn natively`,
20337
+ retryable: false
20338
+ }
20339
+ };
20340
+ }
20341
+
20274
20342
  // ../../harness-adapter/dist/usage.js
20275
20343
  var tokenFields = [
20276
20344
  "inputTokens",
@@ -20298,6 +20366,7 @@ var usageFields = /* @__PURE__ */ new Set([
20298
20366
  ...safeIntegerFields,
20299
20367
  ...percentFields,
20300
20368
  "sessionCacheUsage",
20369
+ "composerIndicators",
20301
20370
  "totalCostUsd",
20302
20371
  "totalCredits",
20303
20372
  "contextUsagePercent",
@@ -20320,6 +20389,7 @@ function parseHostUsage(value) {
20320
20389
  throw new Error(`Harness Usage contains unknown field '${key}'`);
20321
20390
  }
20322
20391
  }
20392
+ const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
20323
20393
  for (const field of [
20324
20394
  "totalCredits",
20325
20395
  "contextUsagePercent",
@@ -20390,9 +20460,9 @@ function parseHostUsage(value) {
20390
20460
  if (value.costSource !== "publicPrice") {
20391
20461
  throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
20392
20462
  }
20393
- return { ...value, unpricedModels: [...models] };
20463
+ return { ...value, ...indicators, unpricedModels: [...models] };
20394
20464
  }
20395
- return { ...value };
20465
+ return { ...value, ...indicators };
20396
20466
  }
20397
20467
  var requestTokenFields = [
20398
20468
  "inputTokens",
@@ -28774,6 +28844,8 @@ var ModernHarnessSession = class {
28774
28844
  switch (command.type) {
28775
28845
  case "turn.start":
28776
28846
  return this.#start(command);
28847
+ case "turn.steer":
28848
+ return Promise.resolve(unsupportedSteer("DeepSeek Harness"));
28777
28849
  case "turn.cancel":
28778
28850
  return this.#cancel(command);
28779
28851
  case "interaction.respond":
@@ -17,6 +17,7 @@
17
17
  "qoder-cn",
18
18
  "kimi-code",
19
19
  "zcode",
20
+ "copilot",
20
21
  "codex-usage"
21
22
  ]
22
23
  }
@@ -393,10 +393,13 @@ function usageSessionTitle(value) {
393
393
  return void 0;
394
394
  if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
395
395
  return normalized;
396
- const characters = [...normalized];
397
- if (characters.length <= MAX_SESSION_TITLE_LENGTH)
398
- return normalized;
399
- return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
396
+ let title = "";
397
+ for (const character of normalized) {
398
+ if (title.length + character.length >= MAX_SESSION_TITLE_LENGTH)
399
+ break;
400
+ title += character;
401
+ }
402
+ return `${title.trimEnd()}…`;
400
403
  }
401
404
  function sessionIdOk(value) {
402
405
  return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
@@ -15253,10 +15256,19 @@ var model = external_exports.string().min(1).max(512);
15253
15256
  var project = external_exports.string().min(1).max(4096);
15254
15257
  var usageStatisticsParamsSchema = external_exports.strictObject({
15255
15258
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
15259
+ /** Display timezone for ranges, dates and hourly buckets; omitted means the Host's local zone. */
15260
+ timeZone: external_exports.string().min(1).max(128).refine((value) => {
15261
+ try {
15262
+ new Intl.DateTimeFormat("en", { timeZone: value });
15263
+ return true;
15264
+ } catch {
15265
+ return false;
15266
+ }
15267
+ }, "Unsupported usage statistics timezone").optional(),
15256
15268
  harness: harness.optional(),
15257
15269
  model: model.nullable().optional(),
15258
15270
  project: project.nullable().optional(),
15259
- /** One local date inside the range. */
15271
+ /** One date in the query timezone inside the range. */
15260
15272
  date: localDate.optional()
15261
15273
  });
15262
15274
  var usageStatisticsTotalsSchema = external_exports.strictObject({
@@ -15292,7 +15304,7 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
15292
15304
  });
15293
15305
  var usageStatisticsResultSchema = external_exports.strictObject({
15294
15306
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
15295
- /** First local date of the range; null for all time. */
15307
+ /** First date in the query timezone (Host local when omitted); null for all time. */
15296
15308
  from: localDate.nullable(),
15297
15309
  to: localDate,
15298
15310
  /** The filters these figures apply, echoed so a late answer to older filters is recognised. */
@@ -15332,7 +15344,7 @@ var usageStatisticsResultSchema = external_exports.strictObject({
15332
15344
  totals: usageStatisticsTotalsSchema,
15333
15345
  /** Each date and Harness of the range: every filter except the day. */
15334
15346
  daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
15335
- /** Local weekday (0 = Sunday) and hour, all filters applied. */
15347
+ /** Weekday (0 = Sunday) and hour in the query timezone, all filters applied. */
15336
15348
  hourly: external_exports.array(external_exports.strictObject({
15337
15349
  weekday: external_exports.number().int().min(0).max(6),
15338
15350
  hour: external_exports.number().int().min(0).max(23),
@@ -15392,6 +15404,8 @@ var CONSOLE_HOST_METHODS = Object.freeze([
15392
15404
  "codexhost/harness/display-settings/set",
15393
15405
  "codexhost/harness/inspect",
15394
15406
  "codexhost/harness/installation",
15407
+ "codexhost/harness/installation/start",
15408
+ "codexhost/harness/installation/status",
15395
15409
  "codexhost/harness/launch-settings/get",
15396
15410
  "codexhost/harness/launch-settings/set",
15397
15411
  "codexhost/harness/web-ui/open",
@@ -15467,7 +15481,18 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
15467
15481
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
15468
15482
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
15469
15483
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
15484
+ var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
15485
+ var composerIndicatorsSchema = external_exports.array(external_exports.object({
15486
+ kind: external_exports.literal("countdown"),
15487
+ id: external_exports.string().min(1).max(64),
15488
+ expiresAtUnix: nonNegativeSafeIntegerSchema,
15489
+ label: indicatorTextSchema(256).optional(),
15490
+ tooltip: indicatorTextSchema(1024).optional()
15491
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
15492
+ message: "Composer indicator IDs must be unique"
15493
+ });
15470
15494
  var threadUsageSnapshotSchema = external_exports.object({
15495
+ composerIndicators: composerIndicatorsSchema.optional(),
15471
15496
  inputTokens: nonNegativeSafeIntegerSchema.optional(),
15472
15497
  cachedInputTokens: nonNegativeSafeIntegerSchema.optional(),
15473
15498
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15875,7 +15900,9 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
15875
15900
  }).strict().optional(),
15876
15901
  autonomousTurns: external_exports.object({
15877
15902
  observe: external_exports.boolean()
15878
- }).strict().optional()
15903
+ }).strict().optional(),
15904
+ /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
15905
+ steer: external_exports.boolean().optional()
15879
15906
  }).strict();
15880
15907
  var harnessConfigurationStateSchema = external_exports.object({
15881
15908
  effectiveModel: harnessModelRefSchema.optional(),
@@ -15922,7 +15949,9 @@ var harnessInspectionSchema = external_exports.union([
15922
15949
  var harnessInspectParamsSchema = external_exports.object({
15923
15950
  harnessId: harnessIdSchema,
15924
15951
  cwd: nonBlankTextSchema2.max(16384).optional(),
15925
- refresh: external_exports.boolean().optional()
15952
+ refresh: external_exports.boolean().optional(),
15953
+ /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15954
+ purpose: external_exports.literal("availability").optional()
15926
15955
  }).strict();
15927
15956
  var harnessWebUiOpenParamsSchema = external_exports.object({
15928
15957
  harnessId: harnessIdSchema
@@ -16005,6 +16034,15 @@ var threadOwnershipListResultSchema = external_exports.object({
16005
16034
  seen.add(thread.threadId);
16006
16035
  }
16007
16036
  });
16037
+ var threadSteeringInspectParamsSchema = external_exports.object({
16038
+ threadId: hostThreadIdSchema,
16039
+ /** The text about to be steered; a Harness command always stops and restarts. */
16040
+ text: external_exports.string().optional()
16041
+ }).strict();
16042
+ var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
16043
+ var threadSteeringInspectResultSchema = external_exports.object({
16044
+ delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
16045
+ }).strict();
16008
16046
 
16009
16047
  // ../../shared-contracts/dist/harness-plugins.js
16010
16048
  var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
@@ -16106,6 +16144,10 @@ var harnessInstallationStateSchema = external_exports.object({
16106
16144
  latestVersion: external_exports.string().min(1).max(128),
16107
16145
  updateAvailable: external_exports.boolean(),
16108
16146
  canUpdate: external_exports.boolean(),
16147
+ /** Defaults to CLI; some Harnesses ship only inside a desktop application. */
16148
+ versionKind: external_exports.enum(["cli", "application"]).optional(),
16149
+ /** Official download opened by the user; does not imply an automatic installation. */
16150
+ manualUpdateUrl: external_exports.url().max(2048).refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Manual updates require a credential-free HTTPS URL").optional(),
16109
16151
  // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
16110
16152
  message: external_exports.string().max(2048).optional(),
16111
16153
  messageCode: external_exports.string().min(1).max(128).optional(),
@@ -16113,6 +16155,20 @@ var harnessInstallationStateSchema = external_exports.object({
16113
16155
  notice: harnessLocalizedTextSchema.optional(),
16114
16156
  latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
16115
16157
  }).strict();
16158
+ var harnessInstallationTaskParamsSchema = external_exports.object({ taskId: external_exports.string().uuid() }).strict();
16159
+ var harnessInstallationTaskSchema = external_exports.discriminatedUnion("status", [
16160
+ external_exports.object({ taskId: external_exports.string().uuid(), status: external_exports.literal("running") }).strict(),
16161
+ external_exports.object({
16162
+ taskId: external_exports.string().uuid(),
16163
+ status: external_exports.literal("succeeded"),
16164
+ result: harnessInstallationStateSchema
16165
+ }).strict(),
16166
+ external_exports.object({
16167
+ taskId: external_exports.string().uuid(),
16168
+ status: external_exports.literal("failed"),
16169
+ error: external_exports.object({ code: external_exports.number().int(), message: external_exports.string().min(1).max(2048) }).strict()
16170
+ }).strict()
16171
+ ]);
16116
16172
 
16117
16173
  // ../../shared-contracts/dist/codex-accounts.js
16118
16174
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
@@ -16562,6 +16618,18 @@ function sanitizeDiagnosticTail(value) {
16562
16618
  return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
16563
16619
  }
16564
16620
 
16621
+ // ../../harness-adapter/dist/steer.js
16622
+ function unsupportedSteer(harnessLabel) {
16623
+ return {
16624
+ ok: false,
16625
+ error: {
16626
+ code: "unsupported",
16627
+ message: `${harnessLabel} cannot steer an active Turn natively`,
16628
+ retryable: false
16629
+ }
16630
+ };
16631
+ }
16632
+
16565
16633
  // ../../harness-adapter/dist/usage.js
16566
16634
  var tokenFields = [
16567
16635
  "inputTokens",
@@ -16589,6 +16657,7 @@ var usageFields = /* @__PURE__ */ new Set([
16589
16657
  ...safeIntegerFields,
16590
16658
  ...percentFields,
16591
16659
  "sessionCacheUsage",
16660
+ "composerIndicators",
16592
16661
  "totalCostUsd",
16593
16662
  "totalCredits",
16594
16663
  "contextUsagePercent",
@@ -16611,6 +16680,7 @@ function parseHostUsage(value) {
16611
16680
  throw new Error(`Harness Usage contains unknown field '${key}'`);
16612
16681
  }
16613
16682
  }
16683
+ const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
16614
16684
  for (const field of [
16615
16685
  "totalCredits",
16616
16686
  "contextUsagePercent",
@@ -16681,9 +16751,9 @@ function parseHostUsage(value) {
16681
16751
  if (value.costSource !== "publicPrice") {
16682
16752
  throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
16683
16753
  }
16684
- return { ...value, unpricedModels: [...models] };
16754
+ return { ...value, ...indicators, unpricedModels: [...models] };
16685
16755
  }
16686
- return { ...value };
16756
+ return { ...value, ...indicators };
16687
16757
  }
16688
16758
  var requestTokenFields = [
16689
16759
  "inputTokens",
@@ -23281,6 +23351,53 @@ function grokPermissionModeSessionMeta(permissionMode) {
23281
23351
  };
23282
23352
  }
23283
23353
 
23354
+ // dist/permission-confirmation.js
23355
+ import { stripVTControlCharacters } from "node:util";
23356
+ var GROK_PERMISSION_MODE_METHOD = "_x.ai/yolo_mode_changed";
23357
+ var permissionManagerLog = "xai_grok_workspace::permission::manager=info";
23358
+ function grokPermissionLogFilter(existing) {
23359
+ return existing ? `${existing},${permissionManagerLog}` : permissionManagerLog;
23360
+ }
23361
+ var GrokPermissionConfirmation = class {
23362
+ #expected;
23363
+ #completion = Promise.withResolvers();
23364
+ #yolo;
23365
+ #auto;
23366
+ #buffer = "";
23367
+ constructor(mode) {
23368
+ this.#expected = grokPermissionModeSessionMeta(mode);
23369
+ }
23370
+ get completed() {
23371
+ return this.#completion.promise;
23372
+ }
23373
+ accept(chunk) {
23374
+ this.#buffer += chunk;
23375
+ let newline2;
23376
+ while ((newline2 = this.#buffer.indexOf("\n")) !== -1) {
23377
+ const line = stripVTControlCharacters(this.#buffer.slice(0, newline2)).trimEnd();
23378
+ this.#buffer = this.#buffer.slice(newline2 + 1);
23379
+ const match = /^\d{4}-\d{2}-\d{2}T\S+\s+INFO\s+(?:.*?: )?(always-approve|auto permission mode) set to: (true|false)$/.exec(line);
23380
+ if (!match)
23381
+ continue;
23382
+ const value = match[2] === "true";
23383
+ if (match[1] === "always-approve")
23384
+ this.#yolo = value;
23385
+ else
23386
+ this.#auto = value;
23387
+ if (this.#yolo !== void 0 && this.#yolo !== this.#expected.yoloMode || this.#auto !== void 0 && this.#auto !== this.#expected.autoMode) {
23388
+ this.reject(new Error("Grok did not apply the requested Permission Mode"));
23389
+ } else if (this.#yolo !== void 0 && this.#auto !== void 0) {
23390
+ this.#completion.resolve(void 0);
23391
+ }
23392
+ }
23393
+ if (this.#buffer.length > 16384)
23394
+ this.#buffer = "";
23395
+ }
23396
+ reject(error53) {
23397
+ this.#completion.reject(error53);
23398
+ }
23399
+ };
23400
+
23284
23401
  // dist/acp-transport.js
23285
23402
  var GrokTransportError = class extends Error {
23286
23403
  kind;
@@ -23557,6 +23674,8 @@ var GrokAcpTransport = class {
23557
23674
  #child = null;
23558
23675
  #closed = false;
23559
23676
  #closing = false;
23677
+ #closePromise = null;
23678
+ #permissionConfirmation = null;
23560
23679
  #connection = null;
23561
23680
  #initialize = null;
23562
23681
  #replay = null;
@@ -23756,7 +23875,11 @@ var GrokAcpTransport = class {
23756
23875
  const invocation = grokInvocation(executable, process.platform, this.#startupModelId);
23757
23876
  const child = spawn(invocation.command, invocation.arguments, {
23758
23877
  cwd: this.#options.cwd,
23759
- env: { ...process.env, ...this.#options.environment },
23878
+ env: {
23879
+ ...process.env,
23880
+ ...this.#options.environment,
23881
+ RUST_LOG: grokPermissionLogFilter(this.#options.environment?.RUST_LOG ?? process.env.RUST_LOG)
23882
+ },
23760
23883
  detached: process.platform !== "win32",
23761
23884
  stdio: ["pipe", "pipe", "pipe"],
23762
23885
  windowsHide: true,
@@ -23765,6 +23888,7 @@ var GrokAcpTransport = class {
23765
23888
  this.#child = child;
23766
23889
  child.stderr.on("data", (chunk) => {
23767
23890
  this.#stderrTail = sanitizeDiagnosticTail(`${this.#stderrTail}${chunk.toString()}`);
23891
+ this.#permissionConfirmation?.accept(chunk.toString());
23768
23892
  });
23769
23893
  await withTimeout(new Promise((resolve, reject) => {
23770
23894
  child.once("spawn", resolve);
@@ -23801,6 +23925,8 @@ var GrokAcpTransport = class {
23801
23925
  }
23802
23926
  if (this.#activePrompt)
23803
23927
  throw new Error("Grok ACP Session already has an active Prompt");
23928
+ if (this.#permissionConfirmation)
23929
+ throw new GrokTransportError("unavailable", "Grok ACP Session has an active operation");
23804
23930
  const active = { onEvent, onPermission };
23805
23931
  this.#activePrompt = active;
23806
23932
  try {
@@ -23819,7 +23945,7 @@ var GrokAcpTransport = class {
23819
23945
  if (!connection || !this.#sessionId || this.#closed || this.#closing) {
23820
23946
  throw new GrokTransportError("unavailable", "Grok ACP Session is unavailable");
23821
23947
  }
23822
- if (this.#activePrompt || this.#activeCompact) {
23948
+ if (this.#activePrompt || this.#activeCompact || this.#permissionConfirmation) {
23823
23949
  throw new GrokTransportError("unavailable", "Grok ACP Session already has an active operation");
23824
23950
  }
23825
23951
  const active = { onEvent, cancellationRequested: false };
@@ -23852,6 +23978,8 @@ var GrokAcpTransport = class {
23852
23978
  const connection = this.#connection;
23853
23979
  if (!connection || !this.#sessionId)
23854
23980
  throw new Error("Grok ACP Session is unavailable");
23981
+ if (this.#permissionConfirmation)
23982
+ throw new GrokTransportError("unavailable", "Grok ACP Session has an active operation");
23855
23983
  const response = await connection.request("session/set_model", {
23856
23984
  sessionId: this.#sessionId,
23857
23985
  modelId,
@@ -23875,14 +24003,57 @@ var GrokAcpTransport = class {
23875
24003
  this.#activeCompact.cancellationRequested = true;
23876
24004
  return connection.cancel({ sessionId: this.#sessionId });
23877
24005
  }
23878
- async close() {
24006
+ async setPermissionMode(permissionModeId) {
24007
+ const mode = decodeGrokPermissionModeId(permissionModeId);
24008
+ const connection = this.#connection;
24009
+ const sessionId = this.#sessionId;
24010
+ if (!connection || !sessionId || this.#closed || this.#closing) {
24011
+ throw new GrokTransportError("unavailable", "Grok ACP Session is unavailable");
24012
+ }
24013
+ if (this.#activePrompt || this.#activeCompact || this.#permissionConfirmation) {
24014
+ throw new GrokTransportError("unavailable", "Grok ACP Session has an active operation");
24015
+ }
24016
+ const confirmation = new GrokPermissionConfirmation(mode);
24017
+ this.#permissionConfirmation = confirmation;
24018
+ try {
24019
+ await withTimeout(Promise.all([
24020
+ confirmation.completed,
24021
+ (async () => {
24022
+ const flags = grokPermissionModeSessionMeta(mode);
24023
+ await connection.notify(GROK_PERMISSION_MODE_METHOD, {
24024
+ yolo_mode: flags.yoloMode,
24025
+ auto_mode: flags.autoMode,
24026
+ permission_mode: mode
24027
+ });
24028
+ const response = await connection.request("_x.ai/session/info", { sessionId });
24029
+ if (!isRecord12(response) || !isRecord12(response.result) || response.result.sessionId !== sessionId) {
24030
+ throw new Error("Grok did not confirm the target Session");
24031
+ }
24032
+ })()
24033
+ ]), this.#options.commandTimeoutMs, "Grok Permission Mode confirmation");
24034
+ if (this.#closed || this.#closing)
24035
+ throw new Error("Grok Session closed during configuration");
24036
+ } catch (cause) {
24037
+ const error53 = new GrokTransportError("protocolError", "Grok Permission Mode could not be confirmed; reopen the Session to continue", { cause });
24038
+ this.#fault(error53);
24039
+ await this.close();
24040
+ throw error53;
24041
+ } finally {
24042
+ this.#permissionConfirmation = null;
24043
+ }
24044
+ }
24045
+ close() {
24046
+ return this.#closePromise ??= this.#close();
24047
+ }
24048
+ async #close() {
23879
24049
  if (this.#closed)
23880
24050
  return;
23881
24051
  this.#closing = true;
24052
+ this.#permissionConfirmation?.reject(new Error("Grok Session closed during configuration"));
23882
24053
  const child = this.#child;
23883
24054
  const connection = this.#connection;
23884
24055
  if (connection && this.#sessionId && this.#initialize?.agentCapabilities?.sessionCapabilities?.close) {
23885
- await connection.closeSession({ sessionId: this.#sessionId }).catch(() => void 0);
24056
+ await withTimeout(connection.closeSession({ sessionId: this.#sessionId }), this.#options.closeTimeoutMs, "Grok Session close").catch(() => void 0);
23886
24057
  }
23887
24058
  if (child?.stdin.writable)
23888
24059
  child.stdin.end();
@@ -23936,6 +24107,7 @@ var GrokAcpTransport = class {
23936
24107
  return this.#activePrompt.onPermission({ request: params, options: params.options });
23937
24108
  }
23938
24109
  #fault(error53) {
24110
+ this.#permissionConfirmation?.reject(error53);
23939
24111
  if (this.#closing || this.#closed)
23940
24112
  return;
23941
24113
  this.#options.onFault?.(error53);
@@ -25009,7 +25181,7 @@ function capabilitiesForModels(modelState) {
25009
25181
  selectModel: modelState.catalog.models.length > 0,
25010
25182
  selectThinkingOption: modelState.catalog.thinkingOptions.length > 0,
25011
25183
  selectPermissionMode: true,
25012
- permissionModeScope: "atCreate"
25184
+ permissionModeScope: "live"
25013
25185
  },
25014
25186
  history: { fork: true, forkAcrossCwd: true, rollbackLastTurn: true },
25015
25187
  subagents: { observe: true, readTranscript: true }
@@ -25163,6 +25335,8 @@ var GrokHarnessSession = class {
25163
25335
  return { ok: false, error: invalidState("Grok Session is not open") };
25164
25336
  if ("commandId" in command)
25165
25337
  return this.#executeHarnessCommand(command);
25338
+ if (command.type === "turn.steer")
25339
+ return unsupportedSteer("Grok");
25166
25340
  if (command.type === "turn.cancel")
25167
25341
  return this.#cancel(command);
25168
25342
  if (command.type === "interaction.respond")
@@ -25442,14 +25616,29 @@ var GrokHarnessSession = class {
25442
25616
  }
25443
25617
  };
25444
25618
  }
25445
- return {
25446
- ok: false,
25447
- error: {
25448
- code: "invalidRequest",
25449
- message: "Grok Permission Mode is fixed at Session creation",
25450
- retryable: false
25451
- }
25452
- };
25619
+ if (this.#active || this.#configuring) {
25620
+ return {
25621
+ ok: false,
25622
+ error: {
25623
+ code: "sessionBusy",
25624
+ message: "Grok Session cannot configure permissions during another operation",
25625
+ retryable: true
25626
+ }
25627
+ };
25628
+ }
25629
+ this.#configuring = true;
25630
+ try {
25631
+ await this.#transport.setPermissionMode(command.permissionModeId);
25632
+ if (this.#phase !== "open")
25633
+ return { ok: false, error: invalidState("Grok Session is closed") };
25634
+ this.#state = { ...this.#state, effectivePermissionModeId: command.permissionModeId };
25635
+ this.#event({ type: "session.state.changed", state: this.#state });
25636
+ return { ok: true, value: { completed: true } };
25637
+ } catch (error53) {
25638
+ return { ok: false, error: normalizeError(error53, "nativeFailure") };
25639
+ } finally {
25640
+ this.#configuring = false;
25641
+ }
25453
25642
  }
25454
25643
  async #cancel(command) {
25455
25644
  const active = this.#active;
@@ -26343,6 +26532,7 @@ var GrokAdapter = class {
26343
26532
  ]);
26344
26533
  }
26345
26534
  }
26535
+ await transport.setPermissionMode(initialPermissionModeId);
26346
26536
  const history = await transport.getHistory();
26347
26537
  let initialUsage = input.kind === "resume" || input.kind === "fork" || input.kind === "rollbackLastTurn" ? combineUsage(sessionUsageFromHistory(history), usageFromSignals(opened.signals)) : null;
26348
26538
  if (contextWindow !== void 0 && initialUsage?.contextUsedTokens !== void 0) {