@codexhost/cli-linux-arm64 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +83 -5
  4. package/app/console-web.js +1172 -687
  5. package/app/desktop-controller.mjs +314 -15
  6. package/app/host-runtime.mjs +13158 -2853
  7. package/app/plugins/antigravity/plugin.mjs +8861 -3944
  8. package/app/plugins/claude-code/plugin.mjs +164 -14
  9. package/app/plugins/codebuddy/plugin.mjs +193 -25
  10. package/app/plugins/codex-usage/plugin.mjs +85 -5
  11. package/app/plugins/copilot/plugin.mjs +85 -5
  12. package/app/plugins/cursor-cli/plugin.mjs +160 -15
  13. package/app/plugins/deepseek-harness/manifest.json +2 -2
  14. package/app/plugins/deepseek-harness/plugin.mjs +112 -10
  15. package/app/plugins/devin/plugin.mjs +84 -5
  16. package/app/plugins/grok/plugin.mjs +418 -272
  17. package/app/plugins/hermes/plugin.mjs +163 -17
  18. package/app/plugins/kimi-code/plugin.mjs +85 -5
  19. package/app/plugins/kiro-cli/plugin.mjs +313 -21
  20. package/app/plugins/omp/plugin.mjs +1018 -819
  21. package/app/plugins/opencode/plugin.mjs +85 -5
  22. package/app/plugins/pi/plugin.mjs +828 -663
  23. package/app/plugins/qoder/plugin.mjs +109 -10
  24. package/app/plugins/qoder-cn/plugin.mjs +109 -10
  25. package/app/plugins/qwen-code/plugin.mjs +194 -97
  26. package/app/plugins/workbuddy/plugin.mjs +197 -28
  27. package/app/plugins/zcode/plugin.mjs +158 -8
  28. package/app/renderer-extension.js +2065 -1004
  29. package/app/web/assets/index-D6-hvggd.css +1 -0
  30. package/app/web/assets/index-D85gPBbQ.js +201 -0
  31. package/app/web/assets/langs/{graphql-B8vkg11W.js → graphql-ChAeyPkT.js} +1 -1
  32. package/app/web/assets/langs/{http-DmoDEjMt.js → http-BvreBIbD.js} +1 -1
  33. package/app/web/assets/langs/{php-DJ5ovfAM.js → php-D8omCIuJ.js} +1 -1
  34. package/app/web/assets/langs/{rst-U5-R5x3p.js → rst-Do7RLLCS.js} +1 -1
  35. package/app/web/assets/langs/{ruby-VKVsnS0H.js → ruby-rH_O_vse.js} +1 -1
  36. package/app/web/assets/langs/{svelte-C20lOv9V.js → svelte-xZy73wAj.js} +1 -1
  37. package/app/web/assets/langs/{vue-z6Y-lzP-.js → vue-C4DW8agZ.js} +1 -1
  38. package/app/web/assets/{vendor-dSL872WO.js → vendor-C9g2bw8s.js} +3 -3
  39. package/app/web/codexhost-settings.js +1178 -689
  40. package/app/web/index.html +4 -3
  41. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +2 -2
  42. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  43. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
  44. package/app/web/plugins/deepseek-ai__dsh-client-connection/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-file-upload/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +3 -3
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +134 -8
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +65 -63
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +95 -93
  51. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  52. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  53. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
  54. package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
  55. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  56. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.excel.js +1 -1
  57. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  58. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  59. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
  60. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +11 -11
  61. package/app/web-modules/server.mjs +2468 -1575
  62. package/bin/codexhost +0 -0
  63. package/libexec/codexhost-shim +0 -0
  64. package/libexec/codexhost-updater +0 -0
  65. package/package.json +1 -1
  66. package/app/web/assets/index-C0aXz2jD.js +0 -199
  67. package/app/web/assets/index-C3lniEH1.css +0 -1
@@ -372,239 +372,6 @@ function createHarnessInstaller(environment, source) {
372
372
  };
373
373
  }
374
374
 
375
- // dist/usage-statistics.js
376
- import os2 from "node:os";
377
- import path5 from "node:path";
378
- import { readFile } from "node:fs/promises";
379
-
380
- // ../../harness-adapter/dist/usage-statistics.js
381
- import { createReadStream } from "node:fs";
382
- import { lstat, opendir } from "node:fs/promises";
383
- import path4 from "node:path";
384
- import { createInterface } from "node:readline";
385
- var MAX_SESSION_ID_LENGTH = 512;
386
- var MAX_CWD_LENGTH = 4096;
387
- var MAX_SESSION_TITLE_LENGTH = 200;
388
- function usageSessionTitle(value) {
389
- if (typeof value !== "string")
390
- return void 0;
391
- const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
392
- if (!normalized)
393
- return void 0;
394
- if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
395
- return normalized;
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()}…`;
403
- }
404
- function sessionIdOk(value) {
405
- return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
406
- }
407
- function cwdOk(value) {
408
- return typeof value === "string" && value.length > 0 && value.length <= MAX_CWD_LENGTH && !value.includes("\0") && (value.startsWith("/") || /^[A-Za-z]:[\\/]/u.test(value) || value.startsWith("\\\\"));
409
- }
410
- function withUsageSession(entry, session) {
411
- const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
412
- const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
413
- const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
414
- if (sessionId === void 0 && cwd === void 0)
415
- return entry;
416
- return {
417
- ...entry,
418
- ...sessionId !== void 0 ? { sessionId } : {},
419
- ...cwd !== void 0 ? { cwd } : {},
420
- ...sessionTitle !== void 0 ? { sessionTitle } : {}
421
- };
422
- }
423
- async function jsonlUsageSources(root, maxDepth, signal) {
424
- const sources = [];
425
- const visit = async (directory, depth) => {
426
- signal.throwIfAborted();
427
- const entries = await opendir(directory).catch((error53) => {
428
- if (error53.code === "ENOENT")
429
- return null;
430
- throw error53;
431
- });
432
- if (!entries)
433
- return;
434
- for await (const entry of entries) {
435
- signal.throwIfAborted();
436
- const file2 = path4.join(directory, entry.name);
437
- if (entry.isDirectory()) {
438
- if (depth < maxDepth)
439
- await visit(file2, depth + 1);
440
- } else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
441
- const info = await lstat(file2).catch(() => null);
442
- if (info?.isFile() && info.size > 0) {
443
- sources.push({ id: file2, fingerprint: `${info.ino}:${info.size}:${info.mtimeMs}` });
444
- }
445
- }
446
- }
447
- };
448
- await visit(root, 0);
449
- return sources;
450
- }
451
- async function* jsonlRecords(file2, marker, signal) {
452
- const lines = createInterface({
453
- input: createReadStream(file2, { encoding: "utf8", signal }),
454
- crlfDelay: Infinity
455
- });
456
- for await (const line of lines) {
457
- if (!line.includes(marker))
458
- continue;
459
- let value;
460
- try {
461
- value = JSON.parse(line);
462
- } catch {
463
- continue;
464
- }
465
- if (typeof value === "object" && value !== null && !Array.isArray(value)) {
466
- yield value;
467
- }
468
- }
469
- }
470
- function nativeTimeMs(value) {
471
- const time3 = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
472
- return Number.isFinite(time3) && time3 > 0 ? Math.floor(time3) : null;
473
- }
474
-
475
- // dist/usage-statistics.js
476
- function isRecord(value) {
477
- return typeof value === "object" && value !== null && !Array.isArray(value);
478
- }
479
- var USD_TICKS = 1e10;
480
- function count(value) {
481
- return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
482
- }
483
- function grokHome(environment) {
484
- return environment.GROK_HOME || path5.join(environment.HOME || os2.homedir(), ".grok");
485
- }
486
- async function grokSummary(directory) {
487
- try {
488
- const summary = JSON.parse(await readFile(path5.join(directory, "summary.json"), "utf8"));
489
- if (!isRecord(summary))
490
- return { forkedAt: null };
491
- const title = usageSessionTitle(summary.generated_title) ?? usageSessionTitle(summary.session_summary);
492
- return {
493
- forkedAt: typeof summary.parent_session_id === "string" ? nativeTimeMs(summary.created_at) : null,
494
- ...title ? { title } : {}
495
- };
496
- } catch {
497
- return { forkedAt: null };
498
- }
499
- }
500
- function grokSession(file2) {
501
- const directory = path5.dirname(file2);
502
- let cwd;
503
- try {
504
- cwd = decodeURIComponent(path5.basename(path5.dirname(directory)));
505
- } catch {
506
- cwd = void 0;
507
- }
508
- return { sessionId: path5.basename(directory), cwd };
509
- }
510
- async function readGrokUsage(file2, signal) {
511
- const summary = await grokSummary(path5.dirname(file2));
512
- const forkedAt = summary.forkedAt;
513
- let title = summary.title;
514
- const session = grokSession(file2);
515
- const entries = [];
516
- for await (const line of jsonlRecords(file2, '"sessionUpdate"', signal)) {
517
- const params = isRecord(line.params) ? line.params : {};
518
- const update = isRecord(params.update) ? params.update : {};
519
- if (!title && update.sessionUpdate === "user_message_chunk") {
520
- title = usageSessionTitle(isRecord(update.content) ? update.content.text : void 0);
521
- continue;
522
- }
523
- const usage = isRecord(update.usage) ? update.usage : {};
524
- if (update.sessionUpdate !== "turn_completed" || typeof update.prompt_id !== "string")
525
- continue;
526
- const meta3 = isRecord(params._meta) ? params._meta : {};
527
- const at = nativeTimeMs(meta3.agentTimestampMs) ?? (typeof line.timestamp === "number" ? nativeTimeMs(line.timestamp * 1e3) : null);
528
- if (at === null || forkedAt !== null && at <= forkedAt)
529
- continue;
530
- for (const [model2, value] of Object.entries(isRecord(usage.modelUsage) ? usage.modelUsage : {})) {
531
- if (!isRecord(value))
532
- continue;
533
- const input = count(value.inputTokens);
534
- const output = count(value.outputTokens);
535
- const cached2 = count(value.cachedReadTokens);
536
- const written = count(value.cacheCreationTokens ?? 0);
537
- const reasoning = count(value.reasoningTokens);
538
- const ticks = count(value.costUsdTicks);
539
- if (input === null || output === null || value.totalTokens !== input + output)
540
- continue;
541
- const cacheKnown = cached2 !== null && cached2 <= input && written === 0;
542
- entries.push(withUsageSession({
543
- id: `${update.prompt_id}:${model2}`,
544
- occurredAtMs: at,
545
- model: model2,
546
- inputTokens: input,
547
- ...cacheKnown ? { cachedInputTokens: cached2, cacheWriteInputTokens: 0 } : {},
548
- outputTokens: output,
549
- ...reasoning !== null && reasoning <= output ? { reasoningOutputTokens: reasoning } : {},
550
- // A turn Grok marks incomplete has no cost of its own; it counts as free rather
551
- // than as a model without a price.
552
- ...ticks !== null ? { costUsd: ticks / USD_TICKS } : usage.usageIsIncomplete === true ? { costUsd: 0 } : {}
553
- }, { ...session, ...title ? { title } : {} }));
554
- }
555
- }
556
- return entries;
557
- }
558
- function createGrokUsageStatistics(environment) {
559
- return Object.freeze({
560
- // sessions/<url-encoded cwd>/<session>/updates.jsonl; subagents are sessions of their own.
561
- listSources: async (signal) => (await jsonlUsageSources(path5.join(grokHome(environment), "sessions"), 2, signal)).filter((source) => path5.basename(source.id) === "updates.jsonl"),
562
- readSource: (id, signal) => readGrokUsage(id, signal)
563
- });
564
- }
565
-
566
- // dist/grok-adapter.js
567
- import { randomUUID } from "node:crypto";
568
-
569
- // dist/grok-credential-export.js
570
- import { createHash } from "node:crypto";
571
- import { readFile as readFile2 } from "node:fs/promises";
572
- import os3 from "node:os";
573
- import path6 from "node:path";
574
- async function readGrokCredentials(environment) {
575
- if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((v) => v?.trim()))
576
- return [];
577
- try {
578
- const home = environment.GROK_HOME ?? path6.join(environment.HOME ?? os3.homedir(), ".grok");
579
- const auth = JSON.parse(await readFile2(path6.join(home, "auth.json"), "utf8"));
580
- const client2 = "b1a00492-073a-47ea-816f-4c329264a828";
581
- const entry = auth[`https://auth.x.ai::${client2}`] ?? auth["https://auth.x.ai"];
582
- if (!entry || entry.oidc_issuer !== "https://auth.x.ai" || entry.oidc_client_id !== client2)
583
- return [];
584
- if (![entry.key, entry.refresh_token, entry.user_id].every((v) => typeof v === "string" && v.length))
585
- return [];
586
- const expires = Date.parse(entry.expires_at);
587
- if (!Number.isFinite(expires))
588
- return [];
589
- return [
590
- {
591
- source: {
592
- id: `grok:${createHash("sha256").update(entry.user_id).digest("hex")}`,
593
- harnessId: "grok",
594
- provider: "xai",
595
- label: typeof entry.email === "string" && entry.email ? entry.email : "Grok"
596
- },
597
- oauth: { access: entry.key, refresh: entry.refresh_token, expires: expires - 3e5 }
598
- }
599
- ];
600
- } catch {
601
- return [];
602
- }
603
- }
604
-
605
- // dist/grok-adapter.js
606
- import path16 from "node:path";
607
-
608
375
  // ../../../node_modules/zod/v4/classic/external.js
609
376
  var external_exports = {};
610
377
  __export(external_exports, {
@@ -15256,13 +15023,25 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
15256
15023
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
15257
15024
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
15258
15025
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
15026
+ var usageOutputTimingSchema = external_exports.object({
15027
+ version: external_exports.literal(3).optional(),
15028
+ requestId: external_exports.string().min(1),
15029
+ turnId: external_exports.string().min(1).max(1024),
15030
+ outputTokens: nonNegativeSafeIntegerSchema,
15031
+ startedAtMs: nonNegativeSafeIntegerSchema,
15032
+ completedAtMs: nonNegativeSafeIntegerSchema
15033
+ }).strict().refine((value) => value.completedAtMs > value.startedAtMs);
15259
15034
  var usageMeasurementSchema = external_exports.object({
15035
+ version: external_exports.union([external_exports.literal(2), external_exports.literal(3)]).optional(),
15260
15036
  value: finiteNonNegativeNumberSchema,
15261
15037
  turnId: external_exports.string().min(1).max(1024),
15262
15038
  at: nonNegativeSafeIntegerSchema
15263
15039
  }).strict();
15264
15040
  var usageMeasurementsSchema = external_exports.object({
15265
- outputTokensPerSecond: usageMeasurementSchema.optional(),
15041
+ // Unversioned intervals can omit hidden thinking time; do not restore them into averages.
15042
+ outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 3)).optional(),
15043
+ // Retain independent TTFT facts when dropping incompatible speed measurements.
15044
+ outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 3).optional().catch(void 0),
15266
15045
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
15267
15046
  }).strict();
15268
15047
  var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
@@ -15282,6 +15061,7 @@ var threadUsageSnapshotSchema = external_exports.object({
15282
15061
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
15283
15062
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
15284
15063
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
15064
+ sessionOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
15285
15065
  apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
15286
15066
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
15287
15067
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15693,11 +15473,19 @@ var threadSteeringInspectResultSchema = external_exports.object({
15693
15473
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15694
15474
  }).strict();
15695
15475
 
15476
+ // ../../shared-contracts/dist/thread-archive-confirm.js
15477
+ var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
15478
+ var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
15479
+
15696
15480
  // ../../shared-contracts/dist/client-channel.js
15697
15481
  var CLIENT_CHANNEL_VERSION = 1;
15698
15482
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
15699
15483
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
15700
15484
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
15485
+ var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
15486
+ var clientThreadTreeSchema = external_exports.object({
15487
+ parents: external_exports.record(external_exports.string().min(1), external_exports.string().min(1))
15488
+ }).strict();
15701
15489
  var clientProjectlessWorkspaceSchema = external_exports.object({
15702
15490
  prompt: external_exports.string().max(16384).optional()
15703
15491
  }).strict();
@@ -15714,6 +15502,11 @@ var clientChannelCursorSchema = external_exports.object({
15714
15502
  sequence: external_exports.number().int().nonnegative()
15715
15503
  });
15716
15504
  var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
15505
+ external_exports.object({
15506
+ type: external_exports.literal("skills-changed"),
15507
+ cursor: clientChannelCursorSchema,
15508
+ cwd: external_exports.string().optional()
15509
+ }),
15717
15510
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15718
15511
  external_exports.object({
15719
15512
  type: external_exports.literal("preferences-changed"),
@@ -15823,7 +15616,12 @@ var clientThreadSnapshotSchema = external_exports.object({
15823
15616
  /** Current interruptible Host Turn, including command Turns omitted from client history. */
15824
15617
  activeTurnId: external_exports.string().min(1).nullable().optional(),
15825
15618
  /** Most recent explicit command in this Host process; not native conversation history. */
15826
- command: external_exports.object({ name: external_exports.string().min(1), turn: clientTurnSchema }).optional(),
15619
+ command: external_exports.object({
15620
+ name: external_exports.string().min(1),
15621
+ turn: clientTurnSchema,
15622
+ /** First ordinary Turn started after this command; its retained result is not a new event. */
15623
+ subsequentTurnId: external_exports.string().min(1).optional()
15624
+ }).optional(),
15827
15625
  thread: external_exports.object({
15828
15626
  id: external_exports.string().min(1),
15829
15627
  cwd: external_exports.string(),
@@ -15911,6 +15709,28 @@ var voiceTranscribeResultSchema = external_exports.discriminatedUnion("ok", [
15911
15709
  external_exports.object({ ok: external_exports.literal(false), error: external_exports.object({ code: voiceErrorCodeSchema }).strict() }).strict()
15912
15710
  ]);
15913
15711
 
15712
+ // ../../shared-contracts/dist/skills.js
15713
+ var skillsListParamsSchema = external_exports.object({
15714
+ threadId: hostThreadIdSchema.optional(),
15715
+ cwd: external_exports.string().min(1).optional()
15716
+ }).strict().refine((params) => !(params.threadId && params.cwd), {
15717
+ message: "Specify threadId or cwd, not both"
15718
+ });
15719
+ var librarySkillSchema = external_exports.object({
15720
+ name: external_exports.string().min(1).regex(/^[^\s[\]]+$/u),
15721
+ description: external_exports.string().optional(),
15722
+ path: external_exports.string().min(1),
15723
+ scope: external_exports.enum(["project", "global"]),
15724
+ source: external_exports.string().min(1)
15725
+ }).strict();
15726
+ var skillsListResultSchema = external_exports.object({
15727
+ revision: external_exports.number().int().nonnegative(),
15728
+ complete: external_exports.boolean(),
15729
+ skills: external_exports.array(librarySkillSchema),
15730
+ warnings: external_exports.array(external_exports.string()).optional()
15731
+ }).strict();
15732
+ var skillsChangedParamsSchema = external_exports.object({ cwd: external_exports.string().min(1).optional() }).strict();
15733
+
15914
15734
  // ../../shared-contracts/dist/web-access-tokens.js
15915
15735
  var webNetworkAccessUrlSchema = external_exports.object({
15916
15736
  /**
@@ -16009,15 +15829,14 @@ var webAccessStateSchema = external_exports.object({
16009
15829
  quotaUntil: external_exports.string().optional()
16010
15830
  }).strict().optional()
16011
15831
  }).strict();
16012
- var webLocalAccessRequiredDetailsSchema = external_exports.object({ url: external_exports.string() }).strict();
16013
15832
 
16014
15833
  // ../../shared-contracts/dist/delegation-read.js
16015
15834
  var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
16016
15835
  var delegationReadParamsSchema = external_exports.strictObject({
16017
15836
  threadId: external_exports.string().min(1).max(1024),
16018
15837
  view: external_exports.enum(["result", "messages"]),
16019
- cursor: external_exports.string().min(1).max(8192).optional(),
16020
- limit: external_exports.number().int().min(1).max(100).optional()
15838
+ from: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional(),
15839
+ to: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional()
16021
15840
  });
16022
15841
 
16023
15842
  // ../../shared-contracts/dist/credential-imports.js
@@ -16211,7 +16030,7 @@ var modelPriceDefaultResultSchema = external_exports.strictObject({
16211
16030
 
16212
16031
  // ../../shared-contracts/dist/usage-statistics.js
16213
16032
  var USAGE_STATISTICS_RANGES = ["today", "7d", "30d", "90d", "all"];
16214
- var count2 = external_exports.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
16033
+ var count = external_exports.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
16215
16034
  var localDate = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/u);
16216
16035
  var harness = external_exports.string().min(1).max(128);
16217
16036
  var model = external_exports.string().min(1).max(512);
@@ -16234,24 +16053,24 @@ var usageStatisticsParamsSchema = external_exports.strictObject({
16234
16053
  date: localDate.optional()
16235
16054
  });
16236
16055
  var usageStatisticsTotalsSchema = external_exports.strictObject({
16237
- requests: count2,
16238
- inputTokens: count2,
16239
- cachedInputTokens: count2,
16240
- cacheWriteInputTokens: count2,
16241
- cacheKnownInputTokens: count2,
16242
- cacheHitCachedInputTokens: count2,
16243
- cacheHitInputTokens: count2,
16244
- outputTokens: count2,
16245
- reasoningOutputTokens: count2,
16056
+ requests: count,
16057
+ inputTokens: count,
16058
+ cachedInputTokens: count,
16059
+ cacheWriteInputTokens: count,
16060
+ cacheKnownInputTokens: count,
16061
+ cacheHitCachedInputTokens: count,
16062
+ cacheHitInputTokens: count,
16063
+ outputTokens: count,
16064
+ reasoningOutputTokens: count,
16246
16065
  /** USD at the public price, summed over the priced requests only. */
16247
16066
  costUsd: external_exports.number().finite().min(0),
16248
16067
  /** Requests without a price (or the cache data the price needs); not in `costUsd`. */
16249
- unpricedRequests: count2,
16068
+ unpricedRequests: count,
16250
16069
  /**
16251
16070
  * Requests whose storage gave no token counts: counted as requests, with neither tokens nor
16252
16071
  * cost, and not as unpriced.
16253
16072
  */
16254
- unmeteredRequests: count2
16073
+ unmeteredRequests: count
16255
16074
  });
16256
16075
  var totals = usageStatisticsTotalsSchema.shape;
16257
16076
  var usageStatisticsSessionSchema = external_exports.strictObject({
@@ -16262,8 +16081,8 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
16262
16081
  title: external_exports.string().min(1).max(200).optional(),
16263
16082
  /** Models the session used, most requests first. */
16264
16083
  models: external_exports.array(model).max(16),
16265
- firstAtMs: count2,
16266
- lastAtMs: count2,
16084
+ firstAtMs: count,
16085
+ lastAtMs: count,
16267
16086
  ...totals
16268
16087
  });
16269
16088
  var usageStatisticsResultSchema = external_exports.strictObject({
@@ -16281,7 +16100,7 @@ var usageStatisticsResultSchema = external_exports.strictObject({
16281
16100
  date: localDate.nullable()
16282
16101
  }),
16283
16102
  /** Reading of native storage: incomplete while the first read, or a refresh, is under way. */
16284
- reading: external_exports.strictObject({ complete: external_exports.boolean(), sources: count2, read: count2 }),
16103
+ reading: external_exports.strictObject({ complete: external_exports.boolean(), sources: count, read: count }),
16285
16104
  /** Harnesses whose storage could not be read; their part is missing, the rest is complete. */
16286
16105
  failures: external_exports.array(external_exports.strictObject({ harness, message: external_exports.string().max(2048) })).max(256),
16287
16106
  /** Every value seen in the range, ignoring the filters, to choose filters from. */
@@ -16301,8 +16120,8 @@ var usageStatisticsResultSchema = external_exports.strictObject({
16301
16120
  harness,
16302
16121
  model: model.nullable(),
16303
16122
  credits: external_exports.number().finite().min(0),
16304
- reportedRequests: count2,
16305
- requests: count2
16123
+ reportedRequests: count,
16124
+ requests: count
16306
16125
  })).max(4096).optional(),
16307
16126
  /** All filters applied. */
16308
16127
  totals: usageStatisticsTotalsSchema,
@@ -16319,7 +16138,7 @@ var usageStatisticsResultSchema = external_exports.strictObject({
16319
16138
  model: model.nullable(),
16320
16139
  ...totals,
16321
16140
  /** Requests priced by what the Harness recorded they cost, not by a price list. */
16322
- harnessPricedRequests: count2
16141
+ harnessPricedRequests: count
16323
16142
  })).max(4096),
16324
16143
  byProject: external_exports.array(external_exports.strictObject({ project: project.nullable(), ...totals })).max(4096),
16325
16144
  /**
@@ -16970,6 +16789,17 @@ var updateStatusResultSchema = external_exports.strictObject({
16970
16789
  status: updateStatusSchema.nullable()
16971
16790
  });
16972
16791
 
16792
+ // ../../shared-contracts/dist/thread-watch-notice.js
16793
+ var THREAD_WATCH_NOTICE_OUTCOMES = [
16794
+ "completed",
16795
+ "failed",
16796
+ "interrupted",
16797
+ "timedOut",
16798
+ "unreadable",
16799
+ "notFound"
16800
+ ];
16801
+ var ENTRY_PATTERN = new RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): ` + `(${THREAD_WATCH_NOTICE_OUTCOMES.join("|")})(?:. (.+))?$`, "u");
16802
+
16973
16803
  // ../../shared-contracts/dist/remote-runtime.js
16974
16804
  var remoteUpdatePhaseSchema = external_exports.enum([
16975
16805
  "idle",
@@ -17017,6 +16847,14 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17017
16847
  archived: external_exports.boolean()
17018
16848
  }),
17019
16849
  external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
16850
+ external_exports.strictObject({
16851
+ kind: external_exports.literal("configure"),
16852
+ ...thread,
16853
+ epoch: identity,
16854
+ modelId: identity.optional(),
16855
+ thinkingOptionId: identity.optional(),
16856
+ permissionModeId: identity.optional()
16857
+ }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
17020
16858
  external_exports.strictObject({
17021
16859
  kind: external_exports.literal("prompt"),
17022
16860
  ...thread,
@@ -17089,6 +16927,13 @@ var remoteConnectionsReplySchema = external_exports.union([
17089
16927
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
17090
16928
  ]);
17091
16929
 
16930
+ // ../../shared-contracts/dist/thread-title.js
16931
+ var threadTitleInputSchema = external_exports.strictObject({
16932
+ prompt: external_exports.string().trim().min(1).max(2e3),
16933
+ cwd: external_exports.string().max(4096).nullable()
16934
+ });
16935
+ var threadTitleResultSchema = external_exports.string().trim().min(1).max(60).nullable();
16936
+
17092
16937
  // ../../shared-contracts/dist/web-ui-extensions.js
17093
16938
  var webUiExtensionIdSchema = external_exports.string().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u);
17094
16939
  var localizedTextSchema2 = external_exports.union([
@@ -17278,15 +17123,16 @@ var usageFields = /* @__PURE__ */ new Set([
17278
17123
  "totalCredits",
17279
17124
  "contextUsagePercent",
17280
17125
  "outputTokensPerSecond",
17126
+ "sessionOutputTokensPerSecond",
17281
17127
  "apiOutputTokensPerSecond",
17282
17128
  "costSource",
17283
17129
  "unpricedModels"
17284
17130
  ]);
17285
- function isRecord2(value) {
17131
+ function isRecord(value) {
17286
17132
  return typeof value === "object" && value !== null && !Array.isArray(value);
17287
17133
  }
17288
17134
  function parseHostUsage(value) {
17289
- if (!isRecord2(value))
17135
+ if (!isRecord(value))
17290
17136
  throw new Error("Harness Usage must be an object");
17291
17137
  const keys = Object.keys(value);
17292
17138
  if (keys.length === 0)
@@ -17300,6 +17146,7 @@ function parseHostUsage(value) {
17300
17146
  for (const field2 of [
17301
17147
  "totalCredits",
17302
17148
  "contextUsagePercent",
17149
+ "sessionOutputTokensPerSecond",
17303
17150
  "apiOutputTokensPerSecond"
17304
17151
  ]) {
17305
17152
  const candidate = value[field2];
@@ -17333,7 +17180,7 @@ function parseHostUsage(value) {
17333
17180
  }
17334
17181
  if (value.sessionCacheUsage !== void 0) {
17335
17182
  const totals2 = value.sessionCacheUsage;
17336
- if (!isRecord2(totals2) || Object.keys(totals2).some((key) => key !== "inputTokens" && key !== "cachedInputTokens") || typeof totals2.inputTokens !== "number" || !Number.isSafeInteger(totals2.inputTokens) || totals2.inputTokens < 0 || typeof totals2.cachedInputTokens !== "number" || !Number.isSafeInteger(totals2.cachedInputTokens) || totals2.cachedInputTokens < 0 || totals2.cachedInputTokens > totals2.inputTokens) {
17183
+ if (!isRecord(totals2) || Object.keys(totals2).some((key) => key !== "inputTokens" && key !== "cachedInputTokens") || typeof totals2.inputTokens !== "number" || !Number.isSafeInteger(totals2.inputTokens) || totals2.inputTokens < 0 || typeof totals2.cachedInputTokens !== "number" || !Number.isSafeInteger(totals2.cachedInputTokens) || totals2.cachedInputTokens < 0 || totals2.cachedInputTokens > totals2.inputTokens) {
17337
17184
  throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
17338
17185
  }
17339
17186
  }
@@ -17454,14 +17301,12 @@ var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
17454
17301
  "reload-plugins"
17455
17302
  ]);
17456
17303
  var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
17457
- function isExcludedLiveCommand(name, kind, extra = {}) {
17304
+ function isExcludedLiveCommand(name, extra = {}) {
17458
17305
  const normalized = name.trim().replace(/^\//u, "");
17459
17306
  if (new Set(extra.names ?? []).has(normalized))
17460
17307
  return true;
17461
17308
  if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
17462
17309
  return true;
17463
- if (kind === "skill")
17464
- return false;
17465
17310
  return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
17466
17311
  }
17467
17312
  function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
@@ -17483,7 +17328,7 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
17483
17328
  const name = command.name.trim().replace(/^\//u, "");
17484
17329
  if (!name || /\s/u.test(name))
17485
17330
  continue;
17486
- if (isExcludedLiveCommand(name, command.kind, exclusions))
17331
+ if (isExcludedLiveCommand(name, exclusions))
17487
17332
  continue;
17488
17333
  const invocation = `/${name}`;
17489
17334
  const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
@@ -17495,8 +17340,7 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
17495
17340
  invocation,
17496
17341
  label: name.slice(0, 128),
17497
17342
  ...description ? { description } : {},
17498
- argumentMode: "text",
17499
- kind: command.kind
17343
+ argumentMode: "text"
17500
17344
  });
17501
17345
  if (!parsed.success)
17502
17346
  continue;
@@ -17507,6 +17351,293 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
17507
17351
  return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
17508
17352
  }
17509
17353
 
17354
+ // ../../harness-adapter/dist/subagent-configuration.js
17355
+ function subagentConfiguration(value) {
17356
+ if (typeof value !== "object" || value === null || Array.isArray(value))
17357
+ return {};
17358
+ const row = value;
17359
+ const text = (value2) => typeof value2 === "string" && value2.trim() ? value2 : void 0;
17360
+ const model2 = row.model === "inherit" ? void 0 : text(row.model);
17361
+ const reasoningEffort = text(row.reasoningEffort) ?? text(row.reasoning_effort) ?? text(row.thinking);
17362
+ return { ...model2 ? { model: model2 } : {}, ...reasoningEffort ? { reasoningEffort } : {} };
17363
+ }
17364
+ function inheritSubagentConfiguration(child, parent) {
17365
+ const native = subagentConfiguration(child);
17366
+ const model2 = native.model ?? parent.model;
17367
+ const reasoningEffort = native.reasoningEffort ?? parent.reasoningEffort;
17368
+ const next = { ...child };
17369
+ delete next.model;
17370
+ delete next.reasoningEffort;
17371
+ return { ...next, ...model2 ? { model: model2 } : {}, ...reasoningEffort ? { reasoningEffort } : {} };
17372
+ }
17373
+ function configureSubagentEvent(event, parent) {
17374
+ const children = (states) => states.map((child) => inheritSubagentConfiguration(child, parent));
17375
+ if (event.type === "item.started" && event.item.type === "subagentDelegation")
17376
+ return { ...event, item: { ...event.item, subagents: children(event.item.subagents) } };
17377
+ if (event.type === "item.updated" && event.update.type === "subagents.replace")
17378
+ return { ...event, update: { ...event.update, subagents: children(event.update.subagents) } };
17379
+ if (event.type === "item.completed" && event.snapshot.item.type === "subagentDelegation")
17380
+ return {
17381
+ ...event,
17382
+ snapshot: {
17383
+ ...event.snapshot,
17384
+ item: {
17385
+ ...event.snapshot.item,
17386
+ subagents: children(event.snapshot.item.subagents)
17387
+ }
17388
+ }
17389
+ };
17390
+ return event;
17391
+ }
17392
+ function configureSubagentSnapshot(snapshot, parent) {
17393
+ return {
17394
+ ...snapshot,
17395
+ turns: snapshot.turns.map((turn) => ({
17396
+ ...turn,
17397
+ items: turn.items.map((entry) => entry.item.type === "subagentDelegation" ? {
17398
+ ...entry,
17399
+ item: {
17400
+ ...entry.item,
17401
+ subagents: entry.item.subagents.map((child) => inheritSubagentConfiguration(child, parent))
17402
+ }
17403
+ } : entry)
17404
+ }))
17405
+ };
17406
+ }
17407
+
17408
+ // dist/usage-statistics.js
17409
+ import os2 from "node:os";
17410
+ import path5 from "node:path";
17411
+ import { readFile } from "node:fs/promises";
17412
+
17413
+ // ../../harness-adapter/dist/usage-statistics.js
17414
+ import { createReadStream } from "node:fs";
17415
+ import { lstat, opendir } from "node:fs/promises";
17416
+ import path4 from "node:path";
17417
+ import { createInterface } from "node:readline";
17418
+ var MAX_SESSION_ID_LENGTH = 512;
17419
+ var MAX_CWD_LENGTH = 4096;
17420
+ var MAX_SESSION_TITLE_LENGTH = 200;
17421
+ function usageSessionTitle(value) {
17422
+ if (typeof value !== "string")
17423
+ return void 0;
17424
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
17425
+ if (!normalized)
17426
+ return void 0;
17427
+ if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
17428
+ return normalized;
17429
+ let title = "";
17430
+ for (const character of normalized) {
17431
+ if (title.length + character.length >= MAX_SESSION_TITLE_LENGTH)
17432
+ break;
17433
+ title += character;
17434
+ }
17435
+ return `${title.trimEnd()}…`;
17436
+ }
17437
+ function sessionIdOk(value) {
17438
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
17439
+ }
17440
+ function cwdOk(value) {
17441
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_CWD_LENGTH && !value.includes("\0") && (value.startsWith("/") || /^[A-Za-z]:[\\/]/u.test(value) || value.startsWith("\\\\"));
17442
+ }
17443
+ function withUsageSession(entry, session) {
17444
+ const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
17445
+ const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
17446
+ const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
17447
+ if (sessionId === void 0 && cwd === void 0)
17448
+ return entry;
17449
+ return {
17450
+ ...entry,
17451
+ ...sessionId !== void 0 ? { sessionId } : {},
17452
+ ...cwd !== void 0 ? { cwd } : {},
17453
+ ...sessionTitle !== void 0 ? { sessionTitle } : {}
17454
+ };
17455
+ }
17456
+ async function jsonlUsageSources(root, maxDepth, signal) {
17457
+ const sources = [];
17458
+ const visit = async (directory, depth) => {
17459
+ signal.throwIfAborted();
17460
+ const entries = await opendir(directory).catch((error53) => {
17461
+ if (error53.code === "ENOENT")
17462
+ return null;
17463
+ throw error53;
17464
+ });
17465
+ if (!entries)
17466
+ return;
17467
+ for await (const entry of entries) {
17468
+ signal.throwIfAborted();
17469
+ const file2 = path4.join(directory, entry.name);
17470
+ if (entry.isDirectory()) {
17471
+ if (depth < maxDepth)
17472
+ await visit(file2, depth + 1);
17473
+ } else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
17474
+ const info = await lstat(file2).catch(() => null);
17475
+ if (info?.isFile() && info.size > 0) {
17476
+ sources.push({ id: file2, fingerprint: `${info.ino}:${info.size}:${info.mtimeMs}` });
17477
+ }
17478
+ }
17479
+ }
17480
+ };
17481
+ await visit(root, 0);
17482
+ return sources;
17483
+ }
17484
+ async function* jsonlRecords(file2, marker, signal) {
17485
+ const lines = createInterface({
17486
+ input: createReadStream(file2, { encoding: "utf8", signal }),
17487
+ crlfDelay: Infinity
17488
+ });
17489
+ for await (const line of lines) {
17490
+ if (!line.includes(marker))
17491
+ continue;
17492
+ let value;
17493
+ try {
17494
+ value = JSON.parse(line);
17495
+ } catch {
17496
+ continue;
17497
+ }
17498
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
17499
+ yield value;
17500
+ }
17501
+ }
17502
+ }
17503
+ function nativeTimeMs(value) {
17504
+ const time3 = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
17505
+ return Number.isFinite(time3) && time3 > 0 ? Math.floor(time3) : null;
17506
+ }
17507
+
17508
+ // dist/usage-statistics.js
17509
+ function isRecord2(value) {
17510
+ return typeof value === "object" && value !== null && !Array.isArray(value);
17511
+ }
17512
+ var USD_TICKS = 1e10;
17513
+ function count2(value) {
17514
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
17515
+ }
17516
+ function grokHome(environment) {
17517
+ return environment.GROK_HOME || path5.join(environment.HOME || os2.homedir(), ".grok");
17518
+ }
17519
+ async function grokSummary(directory) {
17520
+ try {
17521
+ const summary = JSON.parse(await readFile(path5.join(directory, "summary.json"), "utf8"));
17522
+ if (!isRecord2(summary))
17523
+ return { forkedAt: null };
17524
+ const title = usageSessionTitle(summary.generated_title) ?? usageSessionTitle(summary.session_summary);
17525
+ return {
17526
+ forkedAt: typeof summary.parent_session_id === "string" ? nativeTimeMs(summary.created_at) : null,
17527
+ ...title ? { title } : {}
17528
+ };
17529
+ } catch {
17530
+ return { forkedAt: null };
17531
+ }
17532
+ }
17533
+ function grokSession(file2) {
17534
+ const directory = path5.dirname(file2);
17535
+ let cwd;
17536
+ try {
17537
+ cwd = decodeURIComponent(path5.basename(path5.dirname(directory)));
17538
+ } catch {
17539
+ cwd = void 0;
17540
+ }
17541
+ return { sessionId: path5.basename(directory), cwd };
17542
+ }
17543
+ async function readGrokUsage(file2, signal) {
17544
+ const summary = await grokSummary(path5.dirname(file2));
17545
+ const forkedAt = summary.forkedAt;
17546
+ let title = summary.title;
17547
+ const session = grokSession(file2);
17548
+ const entries = [];
17549
+ for await (const line of jsonlRecords(file2, '"sessionUpdate"', signal)) {
17550
+ const params = isRecord2(line.params) ? line.params : {};
17551
+ const update = isRecord2(params.update) ? params.update : {};
17552
+ if (!title && update.sessionUpdate === "user_message_chunk") {
17553
+ title = usageSessionTitle(isRecord2(update.content) ? update.content.text : void 0);
17554
+ continue;
17555
+ }
17556
+ const usage = isRecord2(update.usage) ? update.usage : {};
17557
+ if (update.sessionUpdate !== "turn_completed" || typeof update.prompt_id !== "string")
17558
+ continue;
17559
+ const meta3 = isRecord2(params._meta) ? params._meta : {};
17560
+ const at = nativeTimeMs(meta3.agentTimestampMs) ?? (typeof line.timestamp === "number" ? nativeTimeMs(line.timestamp * 1e3) : null);
17561
+ if (at === null || forkedAt !== null && at <= forkedAt)
17562
+ continue;
17563
+ for (const [model2, value] of Object.entries(isRecord2(usage.modelUsage) ? usage.modelUsage : {})) {
17564
+ if (!isRecord2(value))
17565
+ continue;
17566
+ const input = count2(value.inputTokens);
17567
+ const output = count2(value.outputTokens);
17568
+ const cached2 = count2(value.cachedReadTokens);
17569
+ const written = count2(value.cacheCreationTokens ?? 0);
17570
+ const reasoning = count2(value.reasoningTokens);
17571
+ const ticks = count2(value.costUsdTicks);
17572
+ if (input === null || output === null || value.totalTokens !== input + output)
17573
+ continue;
17574
+ const cacheKnown = cached2 !== null && cached2 <= input && written === 0;
17575
+ entries.push(withUsageSession({
17576
+ id: `${update.prompt_id}:${model2}`,
17577
+ occurredAtMs: at,
17578
+ model: model2,
17579
+ inputTokens: input,
17580
+ ...cacheKnown ? { cachedInputTokens: cached2, cacheWriteInputTokens: 0 } : {},
17581
+ outputTokens: output,
17582
+ ...reasoning !== null && reasoning <= output ? { reasoningOutputTokens: reasoning } : {},
17583
+ // A turn Grok marks incomplete has no cost of its own; it counts as free rather
17584
+ // than as a model without a price.
17585
+ ...ticks !== null ? { costUsd: ticks / USD_TICKS } : usage.usageIsIncomplete === true ? { costUsd: 0 } : {}
17586
+ }, { ...session, ...title ? { title } : {} }));
17587
+ }
17588
+ }
17589
+ return entries;
17590
+ }
17591
+ function createGrokUsageStatistics(environment) {
17592
+ return Object.freeze({
17593
+ // sessions/<url-encoded cwd>/<session>/updates.jsonl; subagents are sessions of their own.
17594
+ listSources: async (signal) => (await jsonlUsageSources(path5.join(grokHome(environment), "sessions"), 2, signal)).filter((source) => path5.basename(source.id) === "updates.jsonl"),
17595
+ readSource: (id, signal) => readGrokUsage(id, signal)
17596
+ });
17597
+ }
17598
+
17599
+ // dist/grok-adapter.js
17600
+ import { randomUUID } from "node:crypto";
17601
+
17602
+ // dist/grok-credential-export.js
17603
+ import { createHash } from "node:crypto";
17604
+ import { readFile as readFile2 } from "node:fs/promises";
17605
+ import os3 from "node:os";
17606
+ import path6 from "node:path";
17607
+ async function readGrokCredentials(environment) {
17608
+ if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((v) => v?.trim()))
17609
+ return [];
17610
+ try {
17611
+ const home = environment.GROK_HOME ?? path6.join(environment.HOME ?? os3.homedir(), ".grok");
17612
+ const auth = JSON.parse(await readFile2(path6.join(home, "auth.json"), "utf8"));
17613
+ const client2 = "b1a00492-073a-47ea-816f-4c329264a828";
17614
+ const entry = auth[`https://auth.x.ai::${client2}`] ?? auth["https://auth.x.ai"];
17615
+ if (!entry || entry.oidc_issuer !== "https://auth.x.ai" || entry.oidc_client_id !== client2)
17616
+ return [];
17617
+ if (![entry.key, entry.refresh_token, entry.user_id].every((v) => typeof v === "string" && v.length))
17618
+ return [];
17619
+ const expires = Date.parse(entry.expires_at);
17620
+ if (!Number.isFinite(expires))
17621
+ return [];
17622
+ return [
17623
+ {
17624
+ source: {
17625
+ id: `grok:${createHash("sha256").update(entry.user_id).digest("hex")}`,
17626
+ harnessId: "grok",
17627
+ provider: "xai",
17628
+ label: typeof entry.email === "string" && entry.email ? entry.email : "Grok"
17629
+ },
17630
+ oauth: { access: entry.key, refresh: entry.refresh_token, expires: expires - 3e5 }
17631
+ }
17632
+ ];
17633
+ } catch {
17634
+ return [];
17635
+ }
17636
+ }
17637
+
17638
+ // dist/grok-adapter.js
17639
+ import path16 from "node:path";
17640
+
17510
17641
  // ../../harness-adapter/dist/local-media-markdown.js
17511
17642
  import { existsSync, statSync } from "node:fs";
17512
17643
  import path7 from "node:path";
@@ -22058,15 +22189,13 @@ function parseGrokAvailableCommands(value) {
22058
22189
  ];
22059
22190
  });
22060
22191
  }
22061
- function isGrokSkill(command) {
22062
- const path17 = command.meta?.path;
22063
- return typeof path17 === "string" && /(^|[\\/])SKILL\.md$/u.test(path17) || typeof command.meta?.qualifiedName === "string";
22064
- }
22065
22192
  function grokLiveCommands(native) {
22066
- return native.map((command) => ({
22193
+ return native.filter(({ meta: meta3 }) => {
22194
+ const path17 = meta3?.path;
22195
+ return !(typeof path17 === "string" && /(^|[\\/])SKILL\.md$/u.test(path17) || typeof meta3?.qualifiedName === "string");
22196
+ }).map((command) => ({
22067
22197
  name: command.name,
22068
- description: command.description,
22069
- kind: isGrokSkill(command) ? "skill" : "command"
22198
+ description: command.description
22070
22199
  }));
22071
22200
  }
22072
22201
 
@@ -23482,6 +23611,7 @@ function mapGrokReplay(replay, harnessId, sessionId, cwd, knownTurnRefs = [], to
23482
23611
  description: grokSubagentDescription(event.rawInput, event.title),
23483
23612
  ...role ? { role } : {},
23484
23613
  ...model2 ? { model: model2 } : {},
23614
+ ...subagentConfiguration(event.rawInput),
23485
23615
  background: grokSubagentBackground(event.rawInput),
23486
23616
  status: "running"
23487
23617
  }
@@ -26200,7 +26330,19 @@ var GrokHarnessSession = class {
26200
26330
  ...this.#state.effectivePermissionModeId ? { permissionModeId: this.#state.effectivePermissionModeId } : {}
26201
26331
  };
26202
26332
  }
26333
+ #subagentConfiguration() {
26334
+ const state = this.#state;
26335
+ const model2 = state.effectiveModel ? state.effectiveModel.id : void 0;
26336
+ return {
26337
+ ...model2 ? { model: model2 } : {},
26338
+ ...state.effectiveThinkingOptionId ? { reasoningEffort: state.effectiveThinkingOptionId } : {}
26339
+ };
26340
+ }
26203
26341
  async readSnapshot() {
26342
+ const result = await this.#readSnapshot();
26343
+ return result.ok ? { ok: true, value: configureSubagentSnapshot(result.value, this.#subagentConfiguration()) } : result;
26344
+ }
26345
+ async #readSnapshot() {
26204
26346
  if (this.#phase !== "open") {
26205
26347
  return { ok: false, error: invalidState("Grok Session is not open") };
26206
26348
  }
@@ -26777,6 +26919,7 @@ var GrokHarnessSession = class {
26777
26919
  ...prompt ? { prompt } : {},
26778
26920
  ...role ? { role } : {},
26779
26921
  ...model2 ? { model: model2 } : {},
26922
+ ...subagentConfiguration(event.rawInput),
26780
26923
  background: grokSubagentBackground(event.rawInput),
26781
26924
  ...nativeSubagentId ? { nativeSubagentId } : {}
26782
26925
  });
@@ -26825,6 +26968,8 @@ var GrokHarnessSession = class {
26825
26968
  const role = grokSubagentRole(event.rawInput);
26826
26969
  const nativeSubagentId = grokNativeSubagentId(event.rawInput, event.rawOutput, event.content);
26827
26970
  active.subagents.update(active.command.turnId, event.callId, {
26971
+ ...subagentConfiguration(event.rawInput),
26972
+ ...subagentConfiguration(event.rawOutput),
26828
26973
  ...event.title ? { description: grokSubagentDescription(event.rawInput, event.title) } : {},
26829
26974
  ...role ? { role } : {},
26830
26975
  ...nativeSubagentId ? { nativeSubagentId } : {}
@@ -27092,6 +27237,7 @@ var GrokHarnessSession = class {
27092
27237
  this.#onClosed();
27093
27238
  }
27094
27239
  #event(event) {
27240
+ event = configureSubagentEvent(event, this.#subagentConfiguration());
27095
27241
  this.#channel.emit({ kind: "event", event });
27096
27242
  }
27097
27243
  };