@liberseek/boft-cli-linux-x64 0.8.3 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +117 -13
- package/app/console-web.js +713 -129
- package/app/desktop-controller.mjs +713 -42
- package/app/host-runtime.mjs +2535 -855
- package/app/plugins/antigravity/plugin.mjs +437 -67
- package/app/plugins/claude-code/plugin.mjs +758 -248
- package/app/plugins/codebuddy/plugin.mjs +348 -156
- package/app/plugins/codex-usage/plugin.mjs +258 -106
- package/app/plugins/copilot/assets/icon.png +0 -0
- package/app/plugins/copilot/manifest.json +26 -0
- package/app/plugins/copilot/plugin.mjs +34651 -0
- package/app/plugins/cursor-cli/plugin.mjs +20905 -44961
- package/app/plugins/deepseek-harness/plugin.mjs +195 -53
- package/app/plugins/enabled.json +1 -0
- package/app/plugins/grok/plugin.mjs +584 -138
- package/app/plugins/hermes/plugin.mjs +134 -13
- package/app/plugins/kimi-code/plugin.mjs +145 -26
- package/app/plugins/kiro-cli/plugin.mjs +145 -26
- package/app/plugins/muse/plugin.mjs +132 -14
- package/app/plugins/omp/plugin.mjs +2245 -2040
- package/app/plugins/opencode/plugin.mjs +196 -72
- package/app/plugins/pi/plugin.mjs +2643 -2309
- package/app/plugins/qoder/plugin.mjs +162 -40
- package/app/plugins/qoder-cn/plugin.mjs +162 -40
- package/app/plugins/workbuddy/plugin.mjs +609 -180
- package/app/plugins/zcode/plugin.mjs +192 -44
- package/app/renderer-extension.js +3405 -429
- package/bin/boft +0 -0
- package/libexec/boft-shim +0 -0
- package/libexec/boft-updater +0 -0
- package/package.json +1 -1
|
@@ -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
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
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;
|
|
@@ -3683,10 +3686,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
3683
3686
|
const shape = def.shape;
|
|
3684
3687
|
const propValues = {};
|
|
3685
3688
|
for (const key in shape) {
|
|
3686
|
-
const
|
|
3687
|
-
if (
|
|
3689
|
+
const field2 = shape[key]._zod;
|
|
3690
|
+
if (field2.values) {
|
|
3688
3691
|
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
3689
|
-
for (const v of
|
|
3692
|
+
for (const v of field2.values)
|
|
3690
3693
|
propValues[key].add(v);
|
|
3691
3694
|
}
|
|
3692
3695
|
}
|
|
@@ -19414,10 +19417,19 @@ var model = external_exports.string().min(1).max(512);
|
|
|
19414
19417
|
var project = external_exports.string().min(1).max(4096);
|
|
19415
19418
|
var usageStatisticsParamsSchema = external_exports.strictObject({
|
|
19416
19419
|
range: external_exports.enum(USAGE_STATISTICS_RANGES),
|
|
19420
|
+
/** Display timezone for ranges, dates and hourly buckets; omitted means the Host's local zone. */
|
|
19421
|
+
timeZone: external_exports.string().min(1).max(128).refine((value) => {
|
|
19422
|
+
try {
|
|
19423
|
+
new Intl.DateTimeFormat("en", { timeZone: value });
|
|
19424
|
+
return true;
|
|
19425
|
+
} catch {
|
|
19426
|
+
return false;
|
|
19427
|
+
}
|
|
19428
|
+
}, "Unsupported usage statistics timezone").optional(),
|
|
19417
19429
|
harness: harness.optional(),
|
|
19418
19430
|
model: model.nullable().optional(),
|
|
19419
19431
|
project: project.nullable().optional(),
|
|
19420
|
-
/** One
|
|
19432
|
+
/** One date in the query timezone inside the range. */
|
|
19421
19433
|
date: localDate.optional()
|
|
19422
19434
|
});
|
|
19423
19435
|
var usageStatisticsTotalsSchema = external_exports.strictObject({
|
|
@@ -19426,6 +19438,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
|
|
|
19426
19438
|
cachedInputTokens: count2,
|
|
19427
19439
|
cacheWriteInputTokens: count2,
|
|
19428
19440
|
cacheKnownInputTokens: count2,
|
|
19441
|
+
cacheHitCachedInputTokens: count2,
|
|
19442
|
+
cacheHitInputTokens: count2,
|
|
19429
19443
|
outputTokens: count2,
|
|
19430
19444
|
reasoningOutputTokens: count2,
|
|
19431
19445
|
/** USD at the public price, summed over the priced requests only. */
|
|
@@ -19453,7 +19467,7 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
|
|
|
19453
19467
|
});
|
|
19454
19468
|
var usageStatisticsResultSchema = external_exports.strictObject({
|
|
19455
19469
|
range: external_exports.enum(USAGE_STATISTICS_RANGES),
|
|
19456
|
-
/** First
|
|
19470
|
+
/** First date in the query timezone (Host local when omitted); null for all time. */
|
|
19457
19471
|
from: localDate.nullable(),
|
|
19458
19472
|
to: localDate,
|
|
19459
19473
|
/** The filters these figures apply, echoed so a late answer to older filters is recognised. */
|
|
@@ -19493,7 +19507,7 @@ var usageStatisticsResultSchema = external_exports.strictObject({
|
|
|
19493
19507
|
totals: usageStatisticsTotalsSchema,
|
|
19494
19508
|
/** Each date and Harness of the range: every filter except the day. */
|
|
19495
19509
|
daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
|
|
19496
|
-
/**
|
|
19510
|
+
/** Weekday (0 = Sunday) and hour in the query timezone, all filters applied. */
|
|
19497
19511
|
hourly: external_exports.array(external_exports.strictObject({
|
|
19498
19512
|
weekday: external_exports.number().int().min(0).max(6),
|
|
19499
19513
|
hour: external_exports.number().int().min(0).max(23),
|
|
@@ -19533,6 +19547,51 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
|
19533
19547
|
var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
|
|
19534
19548
|
var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
|
|
19535
19549
|
|
|
19550
|
+
// ../../shared-contracts/dist/thread-questions.js
|
|
19551
|
+
var field = external_exports.discriminatedUnion("type", [
|
|
19552
|
+
external_exports.object({
|
|
19553
|
+
id: external_exports.string().min(1),
|
|
19554
|
+
type: external_exports.literal("choice"),
|
|
19555
|
+
prompt: external_exports.string(),
|
|
19556
|
+
options: external_exports.array(external_exports.object({
|
|
19557
|
+
value: external_exports.string().min(1),
|
|
19558
|
+
label: external_exports.string(),
|
|
19559
|
+
description: external_exports.string().optional()
|
|
19560
|
+
})).min(1),
|
|
19561
|
+
multiple: external_exports.boolean(),
|
|
19562
|
+
allowOther: external_exports.boolean(),
|
|
19563
|
+
optional: external_exports.boolean()
|
|
19564
|
+
}),
|
|
19565
|
+
external_exports.object({
|
|
19566
|
+
id: external_exports.string().min(1),
|
|
19567
|
+
type: external_exports.literal("text"),
|
|
19568
|
+
prompt: external_exports.string(),
|
|
19569
|
+
multiline: external_exports.boolean(),
|
|
19570
|
+
secret: external_exports.literal(false),
|
|
19571
|
+
optional: external_exports.boolean(),
|
|
19572
|
+
placeholder: external_exports.string().optional(),
|
|
19573
|
+
prefill: external_exports.string().optional()
|
|
19574
|
+
})
|
|
19575
|
+
]);
|
|
19576
|
+
var threadQuestionSchema = external_exports.object({
|
|
19577
|
+
interactionId: external_exports.string().min(1),
|
|
19578
|
+
turnId: external_exports.string().min(1),
|
|
19579
|
+
title: external_exports.string().optional(),
|
|
19580
|
+
questions: external_exports.array(field).min(1)
|
|
19581
|
+
}).refine(({ questions }) => questions.some((q) => q.type === "choice" && q.multiple), {
|
|
19582
|
+
message: "Shared cards require at least one multi-select question"
|
|
19583
|
+
});
|
|
19584
|
+
var threadQuestionsListParamsSchema = external_exports.strictObject({ threadId: external_exports.string().min(1) });
|
|
19585
|
+
var threadQuestionsResultSchema = external_exports.object({ questions: external_exports.array(threadQuestionSchema) });
|
|
19586
|
+
var threadQuestionRespondParamsSchema = external_exports.strictObject({
|
|
19587
|
+
threadId: external_exports.string().min(1),
|
|
19588
|
+
turnId: external_exports.string().min(1),
|
|
19589
|
+
interactionId: external_exports.string().min(1),
|
|
19590
|
+
answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
|
|
19591
|
+
cancelled: external_exports.boolean().default(false)
|
|
19592
|
+
});
|
|
19593
|
+
var threadQuestionRespondResultSchema = external_exports.object({ accepted: external_exports.literal(true) });
|
|
19594
|
+
|
|
19536
19595
|
// ../../shared-contracts/dist/harness-plugins.js
|
|
19537
19596
|
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
19538
19597
|
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
@@ -19635,6 +19694,8 @@ var CONSOLE_HOST_METHODS = Object.freeze([
|
|
|
19635
19694
|
"codexhost/harness/display-settings/set",
|
|
19636
19695
|
"codexhost/harness/inspect",
|
|
19637
19696
|
"codexhost/harness/installation",
|
|
19697
|
+
"codexhost/harness/installation/start",
|
|
19698
|
+
"codexhost/harness/installation/status",
|
|
19638
19699
|
"codexhost/harness/launch-settings/get",
|
|
19639
19700
|
"codexhost/harness/launch-settings/set",
|
|
19640
19701
|
HARNESS_LONG_CONTEXT_GET_METHOD,
|
|
@@ -19712,7 +19773,18 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
|
19712
19773
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
19713
19774
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
19714
19775
|
var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
|
|
19776
|
+
var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
|
|
19777
|
+
var composerIndicatorsSchema = external_exports.array(external_exports.object({
|
|
19778
|
+
kind: external_exports.literal("countdown"),
|
|
19779
|
+
id: external_exports.string().min(1).max(64),
|
|
19780
|
+
expiresAtUnix: nonNegativeSafeIntegerSchema,
|
|
19781
|
+
label: indicatorTextSchema(256).optional(),
|
|
19782
|
+
tooltip: indicatorTextSchema(1024).optional()
|
|
19783
|
+
}).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
|
|
19784
|
+
message: "Composer indicator IDs must be unique"
|
|
19785
|
+
});
|
|
19715
19786
|
var threadUsageSnapshotSchema = external_exports.object({
|
|
19787
|
+
composerIndicators: composerIndicatorsSchema.optional(),
|
|
19716
19788
|
inputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
19717
19789
|
cachedInputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
19718
19790
|
cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
@@ -20138,7 +20210,9 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
|
|
|
20138
20210
|
}).strict().optional(),
|
|
20139
20211
|
input: external_exports.object({
|
|
20140
20212
|
image: external_exports.boolean()
|
|
20141
|
-
}).strict().optional()
|
|
20213
|
+
}).strict().optional(),
|
|
20214
|
+
/** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
|
|
20215
|
+
steer: external_exports.boolean().optional()
|
|
20142
20216
|
}).strict();
|
|
20143
20217
|
var harnessConfigurationStateSchema = external_exports.object({
|
|
20144
20218
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
@@ -20185,7 +20259,9 @@ var harnessInspectionSchema = external_exports.union([
|
|
|
20185
20259
|
var harnessInspectParamsSchema = external_exports.object({
|
|
20186
20260
|
harnessId: harnessIdSchema,
|
|
20187
20261
|
cwd: nonBlankTextSchema2.max(16384).optional(),
|
|
20188
|
-
refresh: external_exports.boolean().optional()
|
|
20262
|
+
refresh: external_exports.boolean().optional(),
|
|
20263
|
+
/** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
|
|
20264
|
+
purpose: external_exports.literal("availability").optional()
|
|
20189
20265
|
}).strict();
|
|
20190
20266
|
var harnessWebUiOpenParamsSchema = external_exports.object({
|
|
20191
20267
|
harnessId: harnessIdSchema
|
|
@@ -20270,13 +20346,25 @@ var threadOwnershipListResultSchema = external_exports.object({
|
|
|
20270
20346
|
seen.add(thread.threadId);
|
|
20271
20347
|
}
|
|
20272
20348
|
});
|
|
20349
|
+
var threadSteeringInspectParamsSchema = external_exports.object({
|
|
20350
|
+
threadId: hostThreadIdSchema,
|
|
20351
|
+
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
20352
|
+
text: external_exports.string().optional()
|
|
20353
|
+
}).strict();
|
|
20354
|
+
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
20355
|
+
var threadSteeringInspectResultSchema = external_exports.object({
|
|
20356
|
+
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
20357
|
+
}).strict();
|
|
20273
20358
|
|
|
20274
20359
|
// ../../shared-contracts/dist/harness-route.js
|
|
20275
20360
|
var harnessPluginRouteSchema = external_exports.object({
|
|
20276
20361
|
harnessId: harnessPluginIdSchema,
|
|
20277
20362
|
model: harnessModelRefSchema.optional(),
|
|
20278
20363
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
20279
|
-
permissionModeId: harnessPermissionModeIdSchema.optional()
|
|
20364
|
+
permissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
20365
|
+
/** A draft prewarm create: stays unsubmitted until the user's first Turn.
|
|
20366
|
+
* Desktop forwards only the Model of a main-process prewarm to thread/start. */
|
|
20367
|
+
prewarm: external_exports.literal(true).optional()
|
|
20280
20368
|
}).strict();
|
|
20281
20369
|
|
|
20282
20370
|
// ../../shared-contracts/dist/harness-launch-settings.js
|
|
@@ -20302,6 +20390,10 @@ var harnessInstallationStateSchema = external_exports.object({
|
|
|
20302
20390
|
latestVersion: external_exports.string().min(1).max(128),
|
|
20303
20391
|
updateAvailable: external_exports.boolean(),
|
|
20304
20392
|
canUpdate: external_exports.boolean(),
|
|
20393
|
+
/** Defaults to CLI; some Harnesses ship only inside a desktop application. */
|
|
20394
|
+
versionKind: external_exports.enum(["cli", "application"]).optional(),
|
|
20395
|
+
/** Official download opened by the user; does not imply an automatic installation. */
|
|
20396
|
+
manualUpdateUrl: external_exports.url().max(2048).refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Manual updates require a credential-free HTTPS URL").optional(),
|
|
20305
20397
|
// Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
|
|
20306
20398
|
message: external_exports.string().max(2048).optional(),
|
|
20307
20399
|
messageCode: external_exports.string().min(1).max(128).optional(),
|
|
@@ -20309,6 +20401,20 @@ var harnessInstallationStateSchema = external_exports.object({
|
|
|
20309
20401
|
notice: harnessLocalizedTextSchema.optional(),
|
|
20310
20402
|
latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
|
|
20311
20403
|
}).strict();
|
|
20404
|
+
var harnessInstallationTaskParamsSchema = external_exports.object({ taskId: external_exports.string().uuid() }).strict();
|
|
20405
|
+
var harnessInstallationTaskSchema = external_exports.discriminatedUnion("status", [
|
|
20406
|
+
external_exports.object({ taskId: external_exports.string().uuid(), status: external_exports.literal("running") }).strict(),
|
|
20407
|
+
external_exports.object({
|
|
20408
|
+
taskId: external_exports.string().uuid(),
|
|
20409
|
+
status: external_exports.literal("succeeded"),
|
|
20410
|
+
result: harnessInstallationStateSchema
|
|
20411
|
+
}).strict(),
|
|
20412
|
+
external_exports.object({
|
|
20413
|
+
taskId: external_exports.string().uuid(),
|
|
20414
|
+
status: external_exports.literal("failed"),
|
|
20415
|
+
error: external_exports.object({ code: external_exports.number().int(), message: external_exports.string().min(1).max(2048) }).strict()
|
|
20416
|
+
}).strict()
|
|
20417
|
+
]);
|
|
20312
20418
|
|
|
20313
20419
|
// ../../shared-contracts/dist/codex-accounts.js
|
|
20314
20420
|
var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
|
|
@@ -20806,6 +20912,18 @@ function sanitizeDiagnosticTail(value) {
|
|
|
20806
20912
|
return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
|
|
20807
20913
|
}
|
|
20808
20914
|
|
|
20915
|
+
// ../../harness-adapter/dist/steer.js
|
|
20916
|
+
function unsupportedSteer(harnessLabel) {
|
|
20917
|
+
return {
|
|
20918
|
+
ok: false,
|
|
20919
|
+
error: {
|
|
20920
|
+
code: "unsupported",
|
|
20921
|
+
message: `${harnessLabel} cannot steer an active Turn natively`,
|
|
20922
|
+
retryable: false
|
|
20923
|
+
}
|
|
20924
|
+
};
|
|
20925
|
+
}
|
|
20926
|
+
|
|
20809
20927
|
// ../../harness-adapter/dist/usage.js
|
|
20810
20928
|
var tokenFields = [
|
|
20811
20929
|
"inputTokens",
|
|
@@ -20833,6 +20951,7 @@ var usageFields = /* @__PURE__ */ new Set([
|
|
|
20833
20951
|
...safeIntegerFields,
|
|
20834
20952
|
...percentFields,
|
|
20835
20953
|
"sessionCacheUsage",
|
|
20954
|
+
"composerIndicators",
|
|
20836
20955
|
"totalCostUsd",
|
|
20837
20956
|
"totalCredits",
|
|
20838
20957
|
"contextUsagePercent",
|
|
@@ -20855,26 +20974,27 @@ function parseHostUsage(value) {
|
|
|
20855
20974
|
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
20856
20975
|
}
|
|
20857
20976
|
}
|
|
20858
|
-
|
|
20977
|
+
const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
|
|
20978
|
+
for (const field2 of [
|
|
20859
20979
|
"totalCredits",
|
|
20860
20980
|
"contextUsagePercent",
|
|
20861
20981
|
"apiOutputTokensPerSecond"
|
|
20862
20982
|
]) {
|
|
20863
|
-
const candidate = value[
|
|
20983
|
+
const candidate = value[field2];
|
|
20864
20984
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
20865
|
-
throw new Error(`Harness Usage '${
|
|
20985
|
+
throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
|
|
20866
20986
|
}
|
|
20867
20987
|
}
|
|
20868
|
-
for (const
|
|
20869
|
-
const candidate = value[
|
|
20988
|
+
for (const field2 of tokenFields) {
|
|
20989
|
+
const candidate = value[field2];
|
|
20870
20990
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
20871
|
-
throw new Error(`Harness Usage '${
|
|
20991
|
+
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
20872
20992
|
}
|
|
20873
20993
|
}
|
|
20874
|
-
for (const
|
|
20875
|
-
const candidate = value[
|
|
20994
|
+
for (const field2 of safeIntegerFields) {
|
|
20995
|
+
const candidate = value[field2];
|
|
20876
20996
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
20877
|
-
throw new Error(`Harness Usage '${
|
|
20997
|
+
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
20878
20998
|
}
|
|
20879
20999
|
}
|
|
20880
21000
|
if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
|
|
@@ -20883,16 +21003,16 @@ function parseHostUsage(value) {
|
|
|
20883
21003
|
if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
|
|
20884
21004
|
throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
|
|
20885
21005
|
}
|
|
20886
|
-
for (const
|
|
20887
|
-
const candidate = value[
|
|
21006
|
+
for (const field2 of ["totalCredits", "contextUsagePercent"]) {
|
|
21007
|
+
const candidate = value[field2];
|
|
20888
21008
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
20889
|
-
throw new Error(`Harness Usage '${
|
|
21009
|
+
throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
|
|
20890
21010
|
}
|
|
20891
21011
|
}
|
|
20892
|
-
for (const
|
|
20893
|
-
const candidate = value[
|
|
21012
|
+
for (const field2 of percentFields) {
|
|
21013
|
+
const candidate = value[field2];
|
|
20894
21014
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
|
|
20895
|
-
throw new Error(`Harness Usage '${
|
|
21015
|
+
throw new Error(`Harness Usage '${field2}' must be between 0 and 100`);
|
|
20896
21016
|
}
|
|
20897
21017
|
}
|
|
20898
21018
|
if (value.sessionCacheUsage !== void 0) {
|
|
@@ -20931,9 +21051,9 @@ function parseHostUsage(value) {
|
|
|
20931
21051
|
if (value.costSource !== "publicPrice") {
|
|
20932
21052
|
throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
|
|
20933
21053
|
}
|
|
20934
|
-
return { ...value, unpricedModels: [...models] };
|
|
21054
|
+
return { ...value, ...indicators, unpricedModels: [...models] };
|
|
20935
21055
|
}
|
|
20936
|
-
return { ...value };
|
|
21056
|
+
return { ...value, ...indicators };
|
|
20937
21057
|
}
|
|
20938
21058
|
var requestTokenFields = [
|
|
20939
21059
|
"inputTokens",
|
|
@@ -21956,10 +22076,10 @@ function stringField(value, key) {
|
|
|
21956
22076
|
function numberField(value, key) {
|
|
21957
22077
|
if (!isRecord6(value))
|
|
21958
22078
|
return void 0;
|
|
21959
|
-
const
|
|
21960
|
-
if (
|
|
22079
|
+
const field2 = value[key];
|
|
22080
|
+
if (field2 === null)
|
|
21961
22081
|
return null;
|
|
21962
|
-
return typeof
|
|
22082
|
+
return typeof field2 === "number" && Number.isFinite(field2) ? field2 : void 0;
|
|
21963
22083
|
}
|
|
21964
22084
|
function decodeBytes(value) {
|
|
21965
22085
|
if (!Array.isArray(value) || value.length === 0)
|
|
@@ -22158,13 +22278,13 @@ function isRecord7(value) {
|
|
|
22158
22278
|
function idField(value, key) {
|
|
22159
22279
|
if (!isRecord7(value))
|
|
22160
22280
|
return void 0;
|
|
22161
|
-
const
|
|
22162
|
-
if (typeof
|
|
22163
|
-
const trimmed =
|
|
22281
|
+
const field2 = value[key];
|
|
22282
|
+
if (typeof field2 === "string") {
|
|
22283
|
+
const trimmed = field2.trim();
|
|
22164
22284
|
return trimmed.length > 0 ? trimmed : void 0;
|
|
22165
22285
|
}
|
|
22166
|
-
if (typeof
|
|
22167
|
-
return String(
|
|
22286
|
+
if (typeof field2 === "number" && Number.isFinite(field2))
|
|
22287
|
+
return String(field2);
|
|
22168
22288
|
return void 0;
|
|
22169
22289
|
}
|
|
22170
22290
|
function stringField2(value, key) {
|
|
@@ -23337,9 +23457,9 @@ function isRecord12(value) {
|
|
|
23337
23457
|
}
|
|
23338
23458
|
function stringField3(value, ...keys) {
|
|
23339
23459
|
for (const key of keys) {
|
|
23340
|
-
const
|
|
23341
|
-
if (typeof
|
|
23342
|
-
return
|
|
23460
|
+
const field2 = value[key];
|
|
23461
|
+
if (typeof field2 === "string" && field2.length > 0)
|
|
23462
|
+
return field2;
|
|
23343
23463
|
}
|
|
23344
23464
|
return void 0;
|
|
23345
23465
|
}
|
|
@@ -23423,17 +23543,17 @@ function isRecord13(value) {
|
|
|
23423
23543
|
}
|
|
23424
23544
|
function stringField4(value, ...keys) {
|
|
23425
23545
|
for (const key of keys) {
|
|
23426
|
-
const
|
|
23427
|
-
if (typeof
|
|
23428
|
-
return
|
|
23546
|
+
const field2 = value[key];
|
|
23547
|
+
if (typeof field2 === "string" && field2.length > 0)
|
|
23548
|
+
return field2;
|
|
23429
23549
|
}
|
|
23430
23550
|
return void 0;
|
|
23431
23551
|
}
|
|
23432
23552
|
function optionalTimeoutMs(value) {
|
|
23433
23553
|
for (const key of ["timeoutMs", "timeout_ms", "timeoutSecs", "timeout_secs"]) {
|
|
23434
|
-
const
|
|
23435
|
-
if (typeof
|
|
23436
|
-
return key.endsWith("secs") || key.endsWith("Secs") ?
|
|
23554
|
+
const field2 = value[key];
|
|
23555
|
+
if (typeof field2 === "number" && Number.isFinite(field2) && field2 > 0) {
|
|
23556
|
+
return key.endsWith("secs") || key.endsWith("Secs") ? field2 * 1e3 : field2;
|
|
23437
23557
|
}
|
|
23438
23558
|
}
|
|
23439
23559
|
return void 0;
|
|
@@ -23606,6 +23726,210 @@ function grokPermissionModeSessionMeta(permissionMode) {
|
|
|
23606
23726
|
};
|
|
23607
23727
|
}
|
|
23608
23728
|
|
|
23729
|
+
// dist/permission-confirmation.js
|
|
23730
|
+
import { stripVTControlCharacters } from "node:util";
|
|
23731
|
+
var GROK_PERMISSION_MODE_METHOD = "_x.ai/yolo_mode_changed";
|
|
23732
|
+
var permissionManagerLog = "xai_grok_workspace::permission::manager=info";
|
|
23733
|
+
function grokPermissionLogFilter(existing) {
|
|
23734
|
+
return existing ? `${existing},${permissionManagerLog}` : permissionManagerLog;
|
|
23735
|
+
}
|
|
23736
|
+
var GrokPermissionConfirmation = class {
|
|
23737
|
+
#expected;
|
|
23738
|
+
#completion = Promise.withResolvers();
|
|
23739
|
+
#yolo;
|
|
23740
|
+
#auto;
|
|
23741
|
+
#buffer = "";
|
|
23742
|
+
constructor(mode) {
|
|
23743
|
+
this.#expected = grokPermissionModeSessionMeta(mode);
|
|
23744
|
+
}
|
|
23745
|
+
get completed() {
|
|
23746
|
+
return this.#completion.promise;
|
|
23747
|
+
}
|
|
23748
|
+
accept(chunk) {
|
|
23749
|
+
this.#buffer += chunk;
|
|
23750
|
+
let newline2;
|
|
23751
|
+
while ((newline2 = this.#buffer.indexOf("\n")) !== -1) {
|
|
23752
|
+
const line = stripVTControlCharacters(this.#buffer.slice(0, newline2)).trimEnd();
|
|
23753
|
+
this.#buffer = this.#buffer.slice(newline2 + 1);
|
|
23754
|
+
const match = /^\d{4}-\d{2}-\d{2}T\S+\s+INFO\s+(?:.*?: )?(always-approve|auto permission mode) set to: (true|false)$/.exec(line);
|
|
23755
|
+
if (!match)
|
|
23756
|
+
continue;
|
|
23757
|
+
const value = match[2] === "true";
|
|
23758
|
+
if (match[1] === "always-approve")
|
|
23759
|
+
this.#yolo = value;
|
|
23760
|
+
else
|
|
23761
|
+
this.#auto = value;
|
|
23762
|
+
if (this.#yolo !== void 0 && this.#yolo !== this.#expected.yoloMode || this.#auto !== void 0 && this.#auto !== this.#expected.autoMode) {
|
|
23763
|
+
this.reject(new Error("Grok did not apply the requested Permission Mode"));
|
|
23764
|
+
} else if (this.#yolo !== void 0 && this.#auto !== void 0) {
|
|
23765
|
+
this.#completion.resolve(void 0);
|
|
23766
|
+
}
|
|
23767
|
+
}
|
|
23768
|
+
if (this.#buffer.length > 16384)
|
|
23769
|
+
this.#buffer = "";
|
|
23770
|
+
}
|
|
23771
|
+
reject(error53) {
|
|
23772
|
+
this.#completion.reject(error53);
|
|
23773
|
+
}
|
|
23774
|
+
};
|
|
23775
|
+
|
|
23776
|
+
// dist/grok-questions.js
|
|
23777
|
+
var GROK_ASK_USER_QUESTION_METHOD = "_x.ai/ask_user_question";
|
|
23778
|
+
function isRecord14(value) {
|
|
23779
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23780
|
+
}
|
|
23781
|
+
function nonEmptyString(value) {
|
|
23782
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
23783
|
+
}
|
|
23784
|
+
function parseGrokQuestionRequest(value) {
|
|
23785
|
+
if (!isRecord14(value) || !nonEmptyString(value.sessionId) || !nonEmptyString(value.toolCallId) || value.mode !== "default" && value.mode !== "plan" || !Array.isArray(value.questions) || value.questions.length === 0)
|
|
23786
|
+
throw new Error("Grok question requires sessionId, toolCallId, mode and nonempty questions");
|
|
23787
|
+
const seen = /* @__PURE__ */ new Set();
|
|
23788
|
+
const questions = value.questions.map((question) => {
|
|
23789
|
+
if (!isRecord14(question) || !nonEmptyString(question.question) || seen.has(question.question) || !Array.isArray(question.options) || question.multiSelect != null && typeof question.multiSelect !== "boolean" || question.multi_select != null && typeof question.multi_select !== "boolean")
|
|
23790
|
+
throw new Error("Grok question text must be unique and options/multiSelect must be valid");
|
|
23791
|
+
if (question.multiSelect != null && question.multi_select != null && question.multiSelect !== question.multi_select)
|
|
23792
|
+
throw new Error("Grok question contains conflicting multi-select flags");
|
|
23793
|
+
seen.add(question.question);
|
|
23794
|
+
const labels = /* @__PURE__ */ new Set();
|
|
23795
|
+
const options = question.options.map((option) => {
|
|
23796
|
+
if (!isRecord14(option) || !nonEmptyString(option.label) || labels.has(option.label) || typeof option.description !== "string" || option.preview != null && typeof option.preview !== "string")
|
|
23797
|
+
throw new Error("Grok question options require unique labels and text descriptions/previews");
|
|
23798
|
+
labels.add(option.label);
|
|
23799
|
+
return {
|
|
23800
|
+
label: option.label,
|
|
23801
|
+
description: option.description,
|
|
23802
|
+
...typeof option.preview === "string" ? { preview: option.preview } : {}
|
|
23803
|
+
};
|
|
23804
|
+
});
|
|
23805
|
+
return {
|
|
23806
|
+
question: question.question,
|
|
23807
|
+
options,
|
|
23808
|
+
multiple: question.multiSelect === true || question.multi_select === true
|
|
23809
|
+
};
|
|
23810
|
+
});
|
|
23811
|
+
return { sessionId: value.sessionId, toolCallId: value.toolCallId, mode: value.mode, questions };
|
|
23812
|
+
}
|
|
23813
|
+
var GrokQuestions = class {
|
|
23814
|
+
turnId;
|
|
23815
|
+
randomUUID;
|
|
23816
|
+
emit;
|
|
23817
|
+
#pending = /* @__PURE__ */ new Map();
|
|
23818
|
+
#seenToolCalls = /* @__PURE__ */ new Set();
|
|
23819
|
+
#closed = false;
|
|
23820
|
+
constructor(turnId, randomUUID2, emit) {
|
|
23821
|
+
this.turnId = turnId;
|
|
23822
|
+
this.randomUUID = randomUUID2;
|
|
23823
|
+
this.emit = emit;
|
|
23824
|
+
}
|
|
23825
|
+
has(interactionId) {
|
|
23826
|
+
return this.#pending.has(interactionId);
|
|
23827
|
+
}
|
|
23828
|
+
ask(request) {
|
|
23829
|
+
if (this.#closed || this.#seenToolCalls.has(request.toolCallId))
|
|
23830
|
+
return Promise.resolve({ outcome: "cancelled" });
|
|
23831
|
+
this.#seenToolCalls.add(request.toolCallId);
|
|
23832
|
+
const interaction = {
|
|
23833
|
+
type: "question",
|
|
23834
|
+
interactionId: hostInteractionIdSchema.parse(this.randomUUID()),
|
|
23835
|
+
turnId: this.turnId,
|
|
23836
|
+
title: "Grok",
|
|
23837
|
+
questions: request.questions.map((question, index) => question.options.length ? {
|
|
23838
|
+
id: `q${index}`,
|
|
23839
|
+
type: "choice",
|
|
23840
|
+
prompt: question.question,
|
|
23841
|
+
options: question.options.map(({ label, description, preview }) => ({
|
|
23842
|
+
value: label,
|
|
23843
|
+
label,
|
|
23844
|
+
description: [description, preview].filter(Boolean).join("\n\n")
|
|
23845
|
+
})),
|
|
23846
|
+
multiple: question.multiple,
|
|
23847
|
+
allowOther: true,
|
|
23848
|
+
optional: true
|
|
23849
|
+
} : {
|
|
23850
|
+
id: `q${index}`,
|
|
23851
|
+
type: "text",
|
|
23852
|
+
prompt: question.question,
|
|
23853
|
+
multiline: true,
|
|
23854
|
+
secret: false,
|
|
23855
|
+
optional: true
|
|
23856
|
+
})
|
|
23857
|
+
};
|
|
23858
|
+
return new Promise((resolve) => {
|
|
23859
|
+
this.#pending.set(interaction.interactionId, { request, interaction, resolve });
|
|
23860
|
+
this.emit({ kind: "interaction", interaction });
|
|
23861
|
+
});
|
|
23862
|
+
}
|
|
23863
|
+
respond(command) {
|
|
23864
|
+
const pending = this.#pending.get(command.interactionId);
|
|
23865
|
+
if (!pending)
|
|
23866
|
+
return this.#error("invalidState", "Grok Question is not pending");
|
|
23867
|
+
if (command.response.type !== "question")
|
|
23868
|
+
return this.#error("invalidRequest", "Grok Question requires a Question Response");
|
|
23869
|
+
const response = command.response;
|
|
23870
|
+
const error53 = validateHostQuestionResponse(pending.interaction, response);
|
|
23871
|
+
if (error53)
|
|
23872
|
+
return { ok: false, error: error53 };
|
|
23873
|
+
if (response.cancelled) {
|
|
23874
|
+
this.#settle(pending, { outcome: "cancelled" }, "cancelled");
|
|
23875
|
+
return { ok: true, value: { accepted: true } };
|
|
23876
|
+
}
|
|
23877
|
+
const answers = /* @__PURE__ */ new Map();
|
|
23878
|
+
const annotations = /* @__PURE__ */ new Map();
|
|
23879
|
+
for (const [index, question] of pending.request.questions.entries()) {
|
|
23880
|
+
const values = response.answers[`q${index}`];
|
|
23881
|
+
if (!values?.length)
|
|
23882
|
+
continue;
|
|
23883
|
+
if (values.some((answer) => !nonEmptyString(answer)) || new Set(values).size !== values.length)
|
|
23884
|
+
return this.#error("invalidRequest", "Grok answers must be nonempty and unique");
|
|
23885
|
+
const selected = values.map((answer) => question.options.find(({ label }) => label === answer));
|
|
23886
|
+
const other = values.filter((_, position) => !selected[position]);
|
|
23887
|
+
if (other.length > 1)
|
|
23888
|
+
return this.#error("invalidRequest", "Grok question accepts only one Other response");
|
|
23889
|
+
answers.set(question.question, selected.map((option) => option?.label ?? "Other"));
|
|
23890
|
+
const previews = selected.flatMap((option) => option?.preview !== void 0 ? [option.preview] : []);
|
|
23891
|
+
if (previews.length || other.length)
|
|
23892
|
+
annotations.set(question.question, {
|
|
23893
|
+
...previews.length ? { preview: previews.join("\n\n") } : {},
|
|
23894
|
+
...other.length ? { notes: other[0] } : {}
|
|
23895
|
+
});
|
|
23896
|
+
}
|
|
23897
|
+
this.#settle(pending, {
|
|
23898
|
+
outcome: "accepted",
|
|
23899
|
+
answers: Object.fromEntries(answers),
|
|
23900
|
+
...annotations.size ? { annotations: Object.fromEntries(annotations) } : {}
|
|
23901
|
+
}, "responded");
|
|
23902
|
+
return { ok: true, value: { accepted: true } };
|
|
23903
|
+
}
|
|
23904
|
+
withdraw(toolCallId) {
|
|
23905
|
+
for (const pending of this.#pending.values()) {
|
|
23906
|
+
if (pending.request.toolCallId === toolCallId)
|
|
23907
|
+
this.#settle(pending, { outcome: "cancelled" }, "cancelled");
|
|
23908
|
+
}
|
|
23909
|
+
}
|
|
23910
|
+
cancel() {
|
|
23911
|
+
this.#closed = true;
|
|
23912
|
+
for (const pending of this.#pending.values())
|
|
23913
|
+
this.#settle(pending, { outcome: "cancelled" }, "cancelled");
|
|
23914
|
+
}
|
|
23915
|
+
#settle(pending, response, reason) {
|
|
23916
|
+
this.#pending.delete(pending.interaction.interactionId);
|
|
23917
|
+
pending.resolve(response);
|
|
23918
|
+
this.emit({
|
|
23919
|
+
kind: "event",
|
|
23920
|
+
event: {
|
|
23921
|
+
type: "interaction.closed",
|
|
23922
|
+
interactionId: pending.interaction.interactionId,
|
|
23923
|
+
turnId: this.turnId,
|
|
23924
|
+
reason
|
|
23925
|
+
}
|
|
23926
|
+
});
|
|
23927
|
+
}
|
|
23928
|
+
#error(code, message) {
|
|
23929
|
+
return { ok: false, error: { code, message, retryable: false } };
|
|
23930
|
+
}
|
|
23931
|
+
};
|
|
23932
|
+
|
|
23609
23933
|
// dist/acp-transport.js
|
|
23610
23934
|
var GrokTransportError = class extends Error {
|
|
23611
23935
|
kind;
|
|
@@ -23617,16 +23941,16 @@ var GrokTransportError = class extends Error {
|
|
|
23617
23941
|
this.name = "GrokTransportError";
|
|
23618
23942
|
}
|
|
23619
23943
|
};
|
|
23620
|
-
function
|
|
23944
|
+
function isRecord15(value) {
|
|
23621
23945
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23622
23946
|
}
|
|
23623
23947
|
function acpToolName(update, metadata) {
|
|
23624
|
-
if (!
|
|
23948
|
+
if (!isRecord15(update))
|
|
23625
23949
|
return void 0;
|
|
23626
23950
|
if (typeof update.name === "string" && update.name.length > 0)
|
|
23627
23951
|
return update.name;
|
|
23628
|
-
const meta3 =
|
|
23629
|
-
const tool = meta3 &&
|
|
23952
|
+
const meta3 = isRecord15(update._meta) ? update._meta : metadata;
|
|
23953
|
+
const tool = meta3 && isRecord15(meta3["x.ai/tool"]) ? meta3["x.ai/tool"] : void 0;
|
|
23630
23954
|
return tool && typeof tool.name === "string" && tool.name.length > 0 ? tool.name : void 0;
|
|
23631
23955
|
}
|
|
23632
23956
|
function errorText(error53) {
|
|
@@ -23682,7 +24006,7 @@ function signalProcessTree(child, signal) {
|
|
|
23682
24006
|
try {
|
|
23683
24007
|
process.kill(-child.pid, signal);
|
|
23684
24008
|
} catch (error53) {
|
|
23685
|
-
if (!
|
|
24009
|
+
if (!isRecord15(error53) || error53.code !== "ESRCH")
|
|
23686
24010
|
throw error53;
|
|
23687
24011
|
}
|
|
23688
24012
|
}
|
|
@@ -23725,6 +24049,10 @@ function transportEvent(update, metadata) {
|
|
|
23725
24049
|
const subagent = grokSubagentEventFromUpdate(extension);
|
|
23726
24050
|
if (subagent)
|
|
23727
24051
|
return subagent;
|
|
24052
|
+
if (extension.sessionUpdate === "interaction_resolved") {
|
|
24053
|
+
const toolCallId = extension.tool_call_id ?? extension.toolCallId;
|
|
24054
|
+
return typeof toolCallId === "string" && toolCallId.trim().length > 0 ? { type: "interaction.resolved", toolCallId, ...metadata ? { metadata } : {} } : null;
|
|
24055
|
+
}
|
|
23728
24056
|
switch (update.sessionUpdate) {
|
|
23729
24057
|
case "user_message_chunk":
|
|
23730
24058
|
case "agent_message_chunk":
|
|
@@ -23792,7 +24120,7 @@ async function readNativeSignals(options, sessionId) {
|
|
|
23792
24120
|
}
|
|
23793
24121
|
}
|
|
23794
24122
|
function isMissingFile(error53) {
|
|
23795
|
-
return
|
|
24123
|
+
return isRecord15(error53) && error53.code === "ENOENT";
|
|
23796
24124
|
}
|
|
23797
24125
|
async function locateGrokNativeSession(options, sessionId) {
|
|
23798
24126
|
if (sessionId.length === 0)
|
|
@@ -23815,7 +24143,7 @@ async function locateGrokNativeSession(options, sessionId) {
|
|
|
23815
24143
|
try {
|
|
23816
24144
|
summaryRaw = await readFile3(path12.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
|
|
23817
24145
|
} catch (error53) {
|
|
23818
|
-
if (isMissingFile(error53) ||
|
|
24146
|
+
if (isMissingFile(error53) || isRecord15(error53) && error53.code === "ENOTDIR")
|
|
23819
24147
|
continue;
|
|
23820
24148
|
throw new GrokTransportError("unavailable", "Grok Native Session metadata could not be read", {
|
|
23821
24149
|
cause: error53
|
|
@@ -23827,10 +24155,10 @@ async function locateGrokNativeSession(options, sessionId) {
|
|
|
23827
24155
|
} catch {
|
|
23828
24156
|
continue;
|
|
23829
24157
|
}
|
|
23830
|
-
if (!
|
|
24158
|
+
if (!isRecord15(parsed))
|
|
23831
24159
|
continue;
|
|
23832
24160
|
const info = parsed.info;
|
|
23833
|
-
const cwd =
|
|
24161
|
+
const cwd = isRecord15(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path12.resolve(info.cwd) : path12.resolve(decodeURIComponent(entry.name));
|
|
23834
24162
|
const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path12.resolve(parsed.source_workspace_dir) : void 0;
|
|
23835
24163
|
matches.push({
|
|
23836
24164
|
cwd,
|
|
@@ -23863,12 +24191,12 @@ function parseNativeHistory(contents, sessionId) {
|
|
|
23863
24191
|
} catch {
|
|
23864
24192
|
throw new GrokTransportError("protocolError", "Grok Native history contains invalid JSON");
|
|
23865
24193
|
}
|
|
23866
|
-
if (!
|
|
24194
|
+
if (!isRecord15(record2) || !isRecord15(record2.params))
|
|
23867
24195
|
continue;
|
|
23868
24196
|
const params = record2.params;
|
|
23869
|
-
if (params.sessionId !== sessionId || !
|
|
24197
|
+
if (params.sessionId !== sessionId || !isRecord15(params.update))
|
|
23870
24198
|
continue;
|
|
23871
|
-
const metadata =
|
|
24199
|
+
const metadata = isRecord15(params._meta) ? params._meta : void 0;
|
|
23872
24200
|
const event = transportEvent(params.update, metadata);
|
|
23873
24201
|
if (event)
|
|
23874
24202
|
events.push(metadata ? { ...event, metadata } : event);
|
|
@@ -23882,6 +24210,8 @@ var GrokAcpTransport = class {
|
|
|
23882
24210
|
#child = null;
|
|
23883
24211
|
#closed = false;
|
|
23884
24212
|
#closing = false;
|
|
24213
|
+
#closePromise = null;
|
|
24214
|
+
#permissionConfirmation = null;
|
|
23885
24215
|
#connection = null;
|
|
23886
24216
|
#initialize = null;
|
|
23887
24217
|
#replay = null;
|
|
@@ -23930,7 +24260,7 @@ var GrokAcpTransport = class {
|
|
|
23930
24260
|
if (!this.#connection)
|
|
23931
24261
|
throw new GrokTransportError("unavailable", "Grok ACP is unavailable");
|
|
23932
24262
|
const result = await withTimeout(this.#connection.request("_x.ai/session/usage", { sessionId: this.sessionId }), this.#options.commandTimeoutMs, "Grok Session usage");
|
|
23933
|
-
return
|
|
24263
|
+
return isRecord15(result) ? result.usage : void 0;
|
|
23934
24264
|
}
|
|
23935
24265
|
async readHistory(sessionId, cwd = this.#options.cwd) {
|
|
23936
24266
|
return readGrokNativeHistory({ ...this.#options, cwd }, sessionId);
|
|
@@ -24081,7 +24411,11 @@ var GrokAcpTransport = class {
|
|
|
24081
24411
|
const invocation = grokInvocation(executable, process.platform, this.#startupModelId);
|
|
24082
24412
|
const child = spawn(invocation.command, invocation.arguments, {
|
|
24083
24413
|
cwd: this.#options.cwd,
|
|
24084
|
-
env: {
|
|
24414
|
+
env: {
|
|
24415
|
+
...process.env,
|
|
24416
|
+
...this.#options.environment,
|
|
24417
|
+
RUST_LOG: grokPermissionLogFilter(this.#options.environment?.RUST_LOG ?? process.env.RUST_LOG)
|
|
24418
|
+
},
|
|
24085
24419
|
detached: process.platform !== "win32",
|
|
24086
24420
|
stdio: ["pipe", "pipe", "pipe"],
|
|
24087
24421
|
windowsHide: true,
|
|
@@ -24090,6 +24424,7 @@ var GrokAcpTransport = class {
|
|
|
24090
24424
|
this.#child = child;
|
|
24091
24425
|
child.stderr.on("data", (chunk) => {
|
|
24092
24426
|
this.#stderrTail = sanitizeDiagnosticTail(`${this.#stderrTail}${chunk.toString()}`);
|
|
24427
|
+
this.#permissionConfirmation?.accept(chunk.toString());
|
|
24093
24428
|
});
|
|
24094
24429
|
await withTimeout(new Promise((resolve, reject) => {
|
|
24095
24430
|
child.once("spawn", resolve);
|
|
@@ -24120,14 +24455,16 @@ var GrokAcpTransport = class {
|
|
|
24120
24455
|
this.#initialize = initialize;
|
|
24121
24456
|
return initialize;
|
|
24122
24457
|
}
|
|
24123
|
-
async runTurn(text, onEvent, onPermission, onExtension) {
|
|
24458
|
+
async runTurn(text, onEvent, onPermission, onQuestion, onExtension = async ({ method }) => isGrokExitPlanModeMethod(method) ? grokPlanRejectedResponse() : grokSkipInterviewResponse()) {
|
|
24124
24459
|
const connection = this.#connection;
|
|
24125
24460
|
if (!connection || !this.#sessionId || this.#closed || this.#closing) {
|
|
24126
24461
|
throw new GrokTransportError("unavailable", "Grok ACP Session is unavailable");
|
|
24127
24462
|
}
|
|
24128
24463
|
if (this.#activePrompt)
|
|
24129
24464
|
throw new Error("Grok ACP Session already has an active Prompt");
|
|
24130
|
-
|
|
24465
|
+
if (this.#permissionConfirmation)
|
|
24466
|
+
throw new GrokTransportError("unavailable", "Grok ACP Session has an active operation");
|
|
24467
|
+
const active = { onEvent, onPermission, onExtension, onQuestion };
|
|
24131
24468
|
this.#activePrompt = active;
|
|
24132
24469
|
try {
|
|
24133
24470
|
return await connection.prompt({
|
|
@@ -24145,7 +24482,7 @@ var GrokAcpTransport = class {
|
|
|
24145
24482
|
if (!connection || !this.#sessionId || this.#closed || this.#closing) {
|
|
24146
24483
|
throw new GrokTransportError("unavailable", "Grok ACP Session is unavailable");
|
|
24147
24484
|
}
|
|
24148
|
-
if (this.#activePrompt || this.#activeCompact) {
|
|
24485
|
+
if (this.#activePrompt || this.#activeCompact || this.#permissionConfirmation) {
|
|
24149
24486
|
throw new GrokTransportError("unavailable", "Grok ACP Session already has an active operation");
|
|
24150
24487
|
}
|
|
24151
24488
|
const active = { onEvent, cancellationRequested: false };
|
|
@@ -24178,13 +24515,15 @@ var GrokAcpTransport = class {
|
|
|
24178
24515
|
const connection = this.#connection;
|
|
24179
24516
|
if (!connection || !this.#sessionId)
|
|
24180
24517
|
throw new Error("Grok ACP Session is unavailable");
|
|
24518
|
+
if (this.#permissionConfirmation)
|
|
24519
|
+
throw new GrokTransportError("unavailable", "Grok ACP Session has an active operation");
|
|
24181
24520
|
const response = await connection.request("session/set_model", {
|
|
24182
24521
|
sessionId: this.#sessionId,
|
|
24183
24522
|
modelId,
|
|
24184
24523
|
...reasoningEffort ? { reasoningEffort } : {},
|
|
24185
24524
|
...contextWindowTokens !== void 0 ? { _meta: { contextWindow: contextWindowTokens } } : {}
|
|
24186
24525
|
});
|
|
24187
|
-
if (!
|
|
24526
|
+
if (!isRecord15(response) || !isRecord15(response._meta) || !isRecord15(response._meta.model)) {
|
|
24188
24527
|
throw new GrokTransportError("protocolError", "Grok rejected Model configuration");
|
|
24189
24528
|
}
|
|
24190
24529
|
const selected = response._meta.model.Ok;
|
|
@@ -24201,14 +24540,57 @@ var GrokAcpTransport = class {
|
|
|
24201
24540
|
this.#activeCompact.cancellationRequested = true;
|
|
24202
24541
|
return connection.cancel({ sessionId: this.#sessionId });
|
|
24203
24542
|
}
|
|
24204
|
-
async
|
|
24543
|
+
async setPermissionMode(permissionModeId) {
|
|
24544
|
+
const mode = decodeGrokPermissionModeId(permissionModeId);
|
|
24545
|
+
const connection = this.#connection;
|
|
24546
|
+
const sessionId = this.#sessionId;
|
|
24547
|
+
if (!connection || !sessionId || this.#closed || this.#closing) {
|
|
24548
|
+
throw new GrokTransportError("unavailable", "Grok ACP Session is unavailable");
|
|
24549
|
+
}
|
|
24550
|
+
if (this.#activePrompt || this.#activeCompact || this.#permissionConfirmation) {
|
|
24551
|
+
throw new GrokTransportError("unavailable", "Grok ACP Session has an active operation");
|
|
24552
|
+
}
|
|
24553
|
+
const confirmation = new GrokPermissionConfirmation(mode);
|
|
24554
|
+
this.#permissionConfirmation = confirmation;
|
|
24555
|
+
try {
|
|
24556
|
+
await withTimeout(Promise.all([
|
|
24557
|
+
confirmation.completed,
|
|
24558
|
+
(async () => {
|
|
24559
|
+
const flags = grokPermissionModeSessionMeta(mode);
|
|
24560
|
+
await connection.notify(GROK_PERMISSION_MODE_METHOD, {
|
|
24561
|
+
yolo_mode: flags.yoloMode,
|
|
24562
|
+
auto_mode: flags.autoMode,
|
|
24563
|
+
permission_mode: mode
|
|
24564
|
+
});
|
|
24565
|
+
const response = await connection.request("_x.ai/session/info", { sessionId });
|
|
24566
|
+
if (!isRecord15(response) || !isRecord15(response.result) || response.result.sessionId !== sessionId) {
|
|
24567
|
+
throw new Error("Grok did not confirm the target Session");
|
|
24568
|
+
}
|
|
24569
|
+
})()
|
|
24570
|
+
]), this.#options.commandTimeoutMs, "Grok Permission Mode confirmation");
|
|
24571
|
+
if (this.#closed || this.#closing)
|
|
24572
|
+
throw new Error("Grok Session closed during configuration");
|
|
24573
|
+
} catch (cause) {
|
|
24574
|
+
const error53 = new GrokTransportError("protocolError", "Grok Permission Mode could not be confirmed; reopen the Session to continue", { cause });
|
|
24575
|
+
this.#fault(error53);
|
|
24576
|
+
await this.close();
|
|
24577
|
+
throw error53;
|
|
24578
|
+
} finally {
|
|
24579
|
+
this.#permissionConfirmation = null;
|
|
24580
|
+
}
|
|
24581
|
+
}
|
|
24582
|
+
close() {
|
|
24583
|
+
return this.#closePromise ??= this.#close();
|
|
24584
|
+
}
|
|
24585
|
+
async #close() {
|
|
24205
24586
|
if (this.#closed)
|
|
24206
24587
|
return;
|
|
24207
24588
|
this.#closing = true;
|
|
24589
|
+
this.#permissionConfirmation?.reject(new Error("Grok Session closed during configuration"));
|
|
24208
24590
|
const child = this.#child;
|
|
24209
24591
|
const connection = this.#connection;
|
|
24210
24592
|
if (connection && this.#sessionId && this.#initialize?.agentCapabilities?.sessionCapabilities?.close) {
|
|
24211
|
-
await connection.closeSession({ sessionId: this.#sessionId }).catch(() => void 0);
|
|
24593
|
+
await withTimeout(connection.closeSession({ sessionId: this.#sessionId }), this.#options.closeTimeoutMs, "Grok Session close").catch(() => void 0);
|
|
24212
24594
|
}
|
|
24213
24595
|
if (child?.stdin.writable)
|
|
24214
24596
|
child.stdin.end();
|
|
@@ -24236,7 +24618,7 @@ var GrokAcpTransport = class {
|
|
|
24236
24618
|
this.#availableCommands = parseGrokAvailableCommands(update.availableCommands);
|
|
24237
24619
|
return;
|
|
24238
24620
|
}
|
|
24239
|
-
const metadata =
|
|
24621
|
+
const metadata = isRecord15(notification._meta) ? notification._meta : void 0;
|
|
24240
24622
|
const event = transportEvent(notification.update, metadata);
|
|
24241
24623
|
if (!event)
|
|
24242
24624
|
return;
|
|
@@ -24251,7 +24633,7 @@ var GrokAcpTransport = class {
|
|
|
24251
24633
|
#handleExtensionNotification(method, params) {
|
|
24252
24634
|
if (!isGrokExtensionSessionUpdateMethod(method))
|
|
24253
24635
|
return;
|
|
24254
|
-
if (typeof params.sessionId !== "string" || !
|
|
24636
|
+
if (typeof params.sessionId !== "string" || !isRecord15(params.update))
|
|
24255
24637
|
return;
|
|
24256
24638
|
this.#handleUpdate(params);
|
|
24257
24639
|
}
|
|
@@ -24261,8 +24643,34 @@ var GrokAcpTransport = class {
|
|
|
24261
24643
|
}
|
|
24262
24644
|
return this.#activePrompt.onPermission({ request: params, options: params.options });
|
|
24263
24645
|
}
|
|
24264
|
-
#handleExtensionRequest(method, params) {
|
|
24265
|
-
if (
|
|
24646
|
+
async #handleExtensionRequest(method, params) {
|
|
24647
|
+
if (method === GROK_ASK_USER_QUESTION_METHOD) {
|
|
24648
|
+
const active = this.#activePrompt;
|
|
24649
|
+
let request = null;
|
|
24650
|
+
let parseError;
|
|
24651
|
+
try {
|
|
24652
|
+
request = parseGrokQuestionRequest(params);
|
|
24653
|
+
} catch (error53) {
|
|
24654
|
+
parseError = error53;
|
|
24655
|
+
}
|
|
24656
|
+
if (request) {
|
|
24657
|
+
if (!active || this.#closed || this.#closing || this.#replay !== null || this.#activeCompact !== null || request.sessionId !== this.#sessionId)
|
|
24658
|
+
return { outcome: "cancelled" };
|
|
24659
|
+
return { ...await active.onQuestion(request) };
|
|
24660
|
+
}
|
|
24661
|
+
if (!isRecord15(params) || "toolCallId" in params && "mode" in params) {
|
|
24662
|
+
throw RequestError.invalidParams(void 0, errorText(parseError));
|
|
24663
|
+
}
|
|
24664
|
+
const legacy = parseGrokAskUserQuestionParams(params);
|
|
24665
|
+
if (!legacy)
|
|
24666
|
+
throw RequestError.invalidParams(params, "Grok Question is invalid");
|
|
24667
|
+
if (legacy.sessionId && legacy.sessionId !== this.#sessionId)
|
|
24668
|
+
return { outcome: "cancelled" };
|
|
24669
|
+
if (active && !this.#closed && !this.#closing && this.#replay === null)
|
|
24670
|
+
return active.onExtension({ method, params });
|
|
24671
|
+
return grokSkipInterviewResponse();
|
|
24672
|
+
}
|
|
24673
|
+
if (this.#activePrompt && (isGrokAskUserQuestionMethod(method) || isGrokExitPlanModeMethod(method))) {
|
|
24266
24674
|
return this.#activePrompt.onExtension({ method, params });
|
|
24267
24675
|
}
|
|
24268
24676
|
if (isGrokAskUserQuestionMethod(method))
|
|
@@ -24272,6 +24680,7 @@ var GrokAcpTransport = class {
|
|
|
24272
24680
|
throw RequestError.methodNotFound(method);
|
|
24273
24681
|
}
|
|
24274
24682
|
#fault(error53) {
|
|
24683
|
+
this.#permissionConfirmation?.reject(error53);
|
|
24275
24684
|
if (this.#closing || this.#closed)
|
|
24276
24685
|
return;
|
|
24277
24686
|
this.#options.onFault?.(error53);
|
|
@@ -24402,7 +24811,7 @@ var SessionImportScope = class {
|
|
|
24402
24811
|
// dist/session-import.js
|
|
24403
24812
|
var MAX_METADATA_BYTES = 4 * 1024 * 1024;
|
|
24404
24813
|
var SUBAGENT_SESSION_KINDS = /* @__PURE__ */ new Set(["subagent", "subagent_resume"]);
|
|
24405
|
-
function
|
|
24814
|
+
function isRecord16(value) {
|
|
24406
24815
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24407
24816
|
}
|
|
24408
24817
|
async function readJson(file2, signal) {
|
|
@@ -24415,7 +24824,7 @@ function processAlive(pid) {
|
|
|
24415
24824
|
process.kill(pid, 0);
|
|
24416
24825
|
return true;
|
|
24417
24826
|
} catch (error53) {
|
|
24418
|
-
return
|
|
24827
|
+
return isRecord16(error53) && error53.code === "EPERM";
|
|
24419
24828
|
}
|
|
24420
24829
|
}
|
|
24421
24830
|
async function firstUserText(file2, signal) {
|
|
@@ -24432,10 +24841,10 @@ async function firstUserText(file2, signal) {
|
|
|
24432
24841
|
} catch {
|
|
24433
24842
|
continue;
|
|
24434
24843
|
}
|
|
24435
|
-
const update =
|
|
24436
|
-
if (!
|
|
24844
|
+
const update = isRecord16(entry) && isRecord16(entry.params) ? entry.params.update : null;
|
|
24845
|
+
if (!isRecord16(update) || update.sessionUpdate !== "user_message_chunk")
|
|
24437
24846
|
continue;
|
|
24438
|
-
const text =
|
|
24847
|
+
const text = isRecord16(update.content) ? update.content.text : null;
|
|
24439
24848
|
return typeof text === "string" ? text : "";
|
|
24440
24849
|
}
|
|
24441
24850
|
return null;
|
|
@@ -24512,7 +24921,7 @@ var GrokSessionImport = class {
|
|
|
24512
24921
|
if (!Array.isArray(entries))
|
|
24513
24922
|
return active;
|
|
24514
24923
|
for (const entry of entries) {
|
|
24515
|
-
if (
|
|
24924
|
+
if (isRecord16(entry) && typeof entry.session_id === "string" && processAlive(entry.pid))
|
|
24516
24925
|
active.add(entry.session_id);
|
|
24517
24926
|
}
|
|
24518
24927
|
return active;
|
|
@@ -24561,7 +24970,7 @@ var GrokSessionImport = class {
|
|
|
24561
24970
|
return null;
|
|
24562
24971
|
try {
|
|
24563
24972
|
const summary = await readJson(files[0], signal);
|
|
24564
|
-
if (!
|
|
24973
|
+
if (!isRecord16(summary) || !isRecord16(summary.info) || summary.info.id !== nativeSessionId)
|
|
24565
24974
|
return null;
|
|
24566
24975
|
if (typeof summary.session_kind === "string" && SUBAGENT_SESSION_KINDS.has(summary.session_kind))
|
|
24567
24976
|
return null;
|
|
@@ -24788,7 +25197,7 @@ var GrokSubagentLifecycle = class {
|
|
|
24788
25197
|
};
|
|
24789
25198
|
|
|
24790
25199
|
// dist/grok-models.js
|
|
24791
|
-
function
|
|
25200
|
+
function isRecord17(value) {
|
|
24792
25201
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24793
25202
|
}
|
|
24794
25203
|
function nonBlank(value) {
|
|
@@ -24821,7 +25230,7 @@ function thinkingOptions(value) {
|
|
|
24821
25230
|
const seen = /* @__PURE__ */ new Set();
|
|
24822
25231
|
const options = [];
|
|
24823
25232
|
for (const candidate of value) {
|
|
24824
|
-
if (!
|
|
25233
|
+
if (!isRecord17(candidate) || !nonBlank(candidate.label))
|
|
24825
25234
|
continue;
|
|
24826
25235
|
const id = harnessThinkingOptionIdSchema.safeParse(candidate.id ?? candidate.value);
|
|
24827
25236
|
if (!id.success || seen.has(id.data))
|
|
@@ -24832,7 +25241,7 @@ function thinkingOptions(value) {
|
|
|
24832
25241
|
return options;
|
|
24833
25242
|
}
|
|
24834
25243
|
function parseGrokModelState(value) {
|
|
24835
|
-
if (!
|
|
25244
|
+
if (!isRecord17(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
|
|
24836
25245
|
return null;
|
|
24837
25246
|
}
|
|
24838
25247
|
const currentModel = encodeGrokModelRef(value.currentModelId);
|
|
@@ -24844,12 +25253,12 @@ function parseGrokModelState(value) {
|
|
|
24844
25253
|
const models = [];
|
|
24845
25254
|
let currentThinkingOptionId;
|
|
24846
25255
|
for (const candidate of value.availableModels) {
|
|
24847
|
-
if (!
|
|
25256
|
+
if (!isRecord17(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
|
|
24848
25257
|
continue;
|
|
24849
25258
|
const ref = encodeGrokModelRef(candidate.modelId);
|
|
24850
25259
|
if (!ref)
|
|
24851
25260
|
continue;
|
|
24852
|
-
const metadata =
|
|
25261
|
+
const metadata = isRecord17(candidate._meta) ? candidate._meta : {};
|
|
24853
25262
|
const options2 = thinkingOptions(metadata.reasoningEfforts);
|
|
24854
25263
|
if (Array.isArray(metadata.contextWindows) && metadata.contextWindows.includes(5e5)) {
|
|
24855
25264
|
defaultContextWindowTokensByModel.set(ref.id, 5e5);
|
|
@@ -24888,10 +25297,10 @@ function parseGrokModelState(value) {
|
|
|
24888
25297
|
};
|
|
24889
25298
|
}
|
|
24890
25299
|
function modelStateFromInitialize(response) {
|
|
24891
|
-
return parseGrokModelState(
|
|
25300
|
+
return parseGrokModelState(isRecord17(response._meta) ? response._meta.modelState : void 0);
|
|
24892
25301
|
}
|
|
24893
25302
|
function modelStateFromSessionResponse(response) {
|
|
24894
|
-
return parseGrokModelState(
|
|
25303
|
+
return parseGrokModelState(isRecord17(response) ? response.models : void 0);
|
|
24895
25304
|
}
|
|
24896
25305
|
function stateForGrokModel(modelState, nativeState, model2 = modelState.currentModel, thinkingOptionId = modelState.currentThinkingOptionId, permissionModeId) {
|
|
24897
25306
|
const selectedModel = model2;
|
|
@@ -24914,8 +25323,16 @@ import { readFile as readFile5 } from "node:fs/promises";
|
|
|
24914
25323
|
import os6 from "node:os";
|
|
24915
25324
|
import path14 from "node:path";
|
|
24916
25325
|
var GROK_CREDITS_ENDPOINT = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
|
|
25326
|
+
var GROK_SETTINGS_ENDPOINT = "https://cli-chat-proxy.grok.com/v1/settings";
|
|
24917
25327
|
var REQUEST_TIMEOUT_MS = 15e3;
|
|
24918
|
-
|
|
25328
|
+
var PLAN_TIMEOUT_MS = 2e3;
|
|
25329
|
+
function parseGrokPlan(value) {
|
|
25330
|
+
if (!isRecord18(value) || typeof value.subscription_tier_display !== "string")
|
|
25331
|
+
return void 0;
|
|
25332
|
+
const plan = value.subscription_tier_display.trim();
|
|
25333
|
+
return plan && plan.length <= 128 && !/[\u0000-\u001f\u007f]/u.test(plan) ? plan : void 0;
|
|
25334
|
+
}
|
|
25335
|
+
function isRecord18(value) {
|
|
24919
25336
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24920
25337
|
}
|
|
24921
25338
|
function finitePercent(value) {
|
|
@@ -24924,7 +25341,7 @@ function finitePercent(value) {
|
|
|
24924
25341
|
return Math.min(100, Math.max(0, value));
|
|
24925
25342
|
}
|
|
24926
25343
|
function nonNegativeCentValue(value) {
|
|
24927
|
-
if (!
|
|
25344
|
+
if (!isRecord18(value))
|
|
24928
25345
|
return void 0;
|
|
24929
25346
|
const amount = value.val === void 0 ? 0 : value.val;
|
|
24930
25347
|
if (typeof amount !== "number" || !Number.isFinite(amount) || amount < 0)
|
|
@@ -24948,7 +25365,7 @@ function productUsageFrom(value) {
|
|
|
24948
25365
|
if (!Array.isArray(value))
|
|
24949
25366
|
return void 0;
|
|
24950
25367
|
const products = value.flatMap((entry) => {
|
|
24951
|
-
if (!
|
|
25368
|
+
if (!isRecord18(entry) || typeof entry.product !== "string")
|
|
24952
25369
|
return [];
|
|
24953
25370
|
const usagePercent = finitePercent(entry.usagePercent);
|
|
24954
25371
|
const labels = {
|
|
@@ -24969,10 +25386,10 @@ function productUsageFrom(value) {
|
|
|
24969
25386
|
return products.length > 0 ? products : void 0;
|
|
24970
25387
|
}
|
|
24971
25388
|
function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
24972
|
-
if (!
|
|
25389
|
+
if (!isRecord18(value) || !isRecord18(value.config))
|
|
24973
25390
|
return null;
|
|
24974
25391
|
const config2 = value.config;
|
|
24975
|
-
const period =
|
|
25392
|
+
const period = isRecord18(config2.currentPeriod) ? config2.currentPeriod : void 0;
|
|
24976
25393
|
const periodType = periodTypeFrom(period?.type);
|
|
24977
25394
|
const resetsAt = (typeof period?.end === "string" && period.end.length > 0 ? period.end : void 0) ?? (typeof config2.billingPeriodEnd === "string" && config2.billingPeriodEnd.length > 0 ? config2.billingPeriodEnd : void 0);
|
|
24978
25395
|
let usedPercent = finitePercent(config2.creditUsagePercent);
|
|
@@ -24999,11 +25416,11 @@ function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()
|
|
|
24999
25416
|
};
|
|
25000
25417
|
}
|
|
25001
25418
|
function selectAccessToken(auth, now) {
|
|
25002
|
-
if (!
|
|
25419
|
+
if (!isRecord18(auth))
|
|
25003
25420
|
return null;
|
|
25004
|
-
const entries = Object.entries(auth).filter(([issuer, value]) => (issuer === "https://auth.x.ai" || issuer.startsWith("https://auth.x.ai::")) &&
|
|
25421
|
+
const entries = Object.entries(auth).filter(([issuer, value]) => (issuer === "https://auth.x.ai" || issuer.startsWith("https://auth.x.ai::")) && isRecord18(value) && typeof value.key === "string" && value.key.length > 0).sort(([left], [right]) => Number(right.startsWith("https://auth.x.ai")) - Number(left.startsWith("https://auth.x.ai")));
|
|
25005
25422
|
for (const [, value] of entries) {
|
|
25006
|
-
if (!
|
|
25423
|
+
if (!isRecord18(value) || typeof value.key !== "string")
|
|
25007
25424
|
continue;
|
|
25008
25425
|
if (typeof value.expires_at === "string") {
|
|
25009
25426
|
const expiresAt = Date.parse(value.expires_at);
|
|
@@ -25030,20 +25447,24 @@ async function fetchGrokAccount(input = {}) {
|
|
|
25030
25447
|
if (!token)
|
|
25031
25448
|
return null;
|
|
25032
25449
|
const fetchImpl = input.fetch ?? fetch;
|
|
25033
|
-
const
|
|
25450
|
+
const request = (url2, timeoutMs) => fetchImpl(url2, {
|
|
25034
25451
|
method: "GET",
|
|
25035
25452
|
headers: {
|
|
25036
25453
|
Authorization: `Bearer ${token.key}`,
|
|
25037
25454
|
"x-xai-token-auth": "xai-grok-cli",
|
|
25038
25455
|
Accept: "application/json"
|
|
25039
25456
|
},
|
|
25040
|
-
signal: input.signal ? AbortSignal.any([input.signal, AbortSignal.timeout(
|
|
25457
|
+
signal: input.signal ? AbortSignal.any([input.signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs)
|
|
25041
25458
|
});
|
|
25459
|
+
const credits = request(GROK_CREDITS_ENDPOINT, REQUEST_TIMEOUT_MS);
|
|
25460
|
+
const plan = input.includePlan === false ? Promise.resolve(void 0) : request(GROK_SETTINGS_ENDPOINT, input.planTimeoutMs ?? PLAN_TIMEOUT_MS).then(async (response2) => response2.ok ? parseGrokPlan(await response2.json()) : void 0).catch(() => void 0);
|
|
25461
|
+
const response = await credits;
|
|
25042
25462
|
if (!response.ok)
|
|
25043
25463
|
return null;
|
|
25044
25464
|
const snapshot = parseGrokCreditsResponse(await response.json(), now.toISOString());
|
|
25045
25465
|
if (!snapshot)
|
|
25046
25466
|
return null;
|
|
25467
|
+
const planName = await plan;
|
|
25047
25468
|
return {
|
|
25048
25469
|
credits: {
|
|
25049
25470
|
usedPercent: snapshot.usedPercent,
|
|
@@ -25052,14 +25473,15 @@ async function fetchGrokAccount(input = {}) {
|
|
|
25052
25473
|
...snapshot.productUsage ? { productUsage: [...snapshot.productUsage] } : {}
|
|
25053
25474
|
},
|
|
25054
25475
|
...token.email ? { email: token.email } : {},
|
|
25055
|
-
...token.label ? { label: token.label } : {}
|
|
25476
|
+
...token.label ? { label: token.label } : {},
|
|
25477
|
+
...planName ? { plan: planName } : {}
|
|
25056
25478
|
};
|
|
25057
25479
|
} catch {
|
|
25058
25480
|
return null;
|
|
25059
25481
|
}
|
|
25060
25482
|
}
|
|
25061
25483
|
async function fetchGrokCredits(input = {}) {
|
|
25062
|
-
const account = await fetchGrokAccount(input);
|
|
25484
|
+
const account = await fetchGrokAccount({ ...input, includePlan: false });
|
|
25063
25485
|
const usedPercent = account?.credits?.usedPercent;
|
|
25064
25486
|
if (!account?.credits || usedPercent === void 0)
|
|
25065
25487
|
return null;
|
|
@@ -25075,7 +25497,7 @@ async function fetchGrokCredits(input = {}) {
|
|
|
25075
25497
|
|
|
25076
25498
|
// dist/grok-usage.js
|
|
25077
25499
|
var USD_TICKS_PER_DOLLAR = 1e10;
|
|
25078
|
-
function
|
|
25500
|
+
function isRecord19(value) {
|
|
25079
25501
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25080
25502
|
}
|
|
25081
25503
|
function optionalToken(value) {
|
|
@@ -25092,7 +25514,7 @@ function combineUsage(base, next) {
|
|
|
25092
25514
|
return base === null ? next : parseHostUsage({ ...base, ...next });
|
|
25093
25515
|
}
|
|
25094
25516
|
function usageFromNative(value) {
|
|
25095
|
-
if (!
|
|
25517
|
+
if (!isRecord19(value))
|
|
25096
25518
|
return null;
|
|
25097
25519
|
const nativeInputTokens = optionalToken(value.inputTokens);
|
|
25098
25520
|
const cachedRead = optionalToken(value.cachedReadTokens);
|
|
@@ -25118,7 +25540,7 @@ function usageFromNative(value) {
|
|
|
25118
25540
|
}
|
|
25119
25541
|
}
|
|
25120
25542
|
function usageFromResponse(value) {
|
|
25121
|
-
if (!
|
|
25543
|
+
if (!isRecord19(value))
|
|
25122
25544
|
return null;
|
|
25123
25545
|
const buckets = [
|
|
25124
25546
|
value.input_tokens,
|
|
@@ -25148,10 +25570,10 @@ var GrokTurnUsage = class {
|
|
|
25148
25570
|
#latestCacheHit;
|
|
25149
25571
|
#sessionInputTokens = 0;
|
|
25150
25572
|
constructor(base, emptySession = false) {
|
|
25151
|
-
for (const
|
|
25152
|
-
const value = base?.[
|
|
25573
|
+
for (const field2 of summedUsageFields) {
|
|
25574
|
+
const value = base?.[field2];
|
|
25153
25575
|
if (value !== void 0)
|
|
25154
|
-
this.#totals[
|
|
25576
|
+
this.#totals[field2] = value;
|
|
25155
25577
|
}
|
|
25156
25578
|
this.#cacheComplete = base?.sessionCacheUsage !== void 0 || emptySession;
|
|
25157
25579
|
this.#sessionInputTokens = base?.sessionCacheUsage?.inputTokens ?? 0;
|
|
@@ -25192,10 +25614,10 @@ var GrokTurnUsage = class {
|
|
|
25192
25614
|
this.#cacheComplete = false;
|
|
25193
25615
|
if (usage) {
|
|
25194
25616
|
this.#sessionInputTokens += (usage.inputTokens ?? 0) + (usage.cachedInputTokens ?? 0) + (usage.cacheWriteInputTokens ?? 0);
|
|
25195
|
-
for (const
|
|
25196
|
-
const value = usage[
|
|
25617
|
+
for (const field2 of summedUsageFields) {
|
|
25618
|
+
const value = usage[field2];
|
|
25197
25619
|
if (value !== void 0)
|
|
25198
|
-
this.#totals[
|
|
25620
|
+
this.#totals[field2] = (this.#totals[field2] ?? 0) + value;
|
|
25199
25621
|
}
|
|
25200
25622
|
if (duration3 > 0 && usage.outputTokens !== void 0) {
|
|
25201
25623
|
this.#outputTokens += usage.outputTokens;
|
|
@@ -25221,7 +25643,7 @@ var GrokTurnUsage = class {
|
|
|
25221
25643
|
}
|
|
25222
25644
|
};
|
|
25223
25645
|
function usageFromSignals(value) {
|
|
25224
|
-
if (!
|
|
25646
|
+
if (!isRecord19(value))
|
|
25225
25647
|
return null;
|
|
25226
25648
|
try {
|
|
25227
25649
|
return parseHostUsage({
|
|
@@ -25241,7 +25663,7 @@ var summedUsageFields = [
|
|
|
25241
25663
|
"totalTokens"
|
|
25242
25664
|
];
|
|
25243
25665
|
function nativeCostTicks(value) {
|
|
25244
|
-
if (!
|
|
25666
|
+
if (!isRecord19(value))
|
|
25245
25667
|
return void 0;
|
|
25246
25668
|
const ticks = value.costUsdTicks;
|
|
25247
25669
|
if (typeof ticks !== "number" || !Number.isSafeInteger(ticks) || ticks < 0)
|
|
@@ -25249,7 +25671,7 @@ function nativeCostTicks(value) {
|
|
|
25249
25671
|
return ticks;
|
|
25250
25672
|
}
|
|
25251
25673
|
function sessionCostFromNative(value, initialCostUsd) {
|
|
25252
|
-
if (!
|
|
25674
|
+
if (!isRecord19(value))
|
|
25253
25675
|
return void 0;
|
|
25254
25676
|
if (value.costIsPartial !== void 0 && value.costIsPartial !== false)
|
|
25255
25677
|
return void 0;
|
|
@@ -25278,7 +25700,7 @@ function sessionUsageFromHistory(events) {
|
|
|
25278
25700
|
continue;
|
|
25279
25701
|
const usage = usageFromNative(event.usage);
|
|
25280
25702
|
const ticks2 = nativeCostTicks(event.usage);
|
|
25281
|
-
const complete =
|
|
25703
|
+
const complete = isRecord19(event.usage) && (event.usage.usageIsIncomplete === void 0 || event.usage.usageIsIncomplete === false) && usage?.inputTokens !== void 0 && usage.cachedInputTokens !== void 0 && typeof event.usage.inputTokens === "number" && usage.cachedInputTokens + (usage.cacheWriteInputTokens ?? 0) <= event.usage.inputTokens;
|
|
25282
25704
|
latestByKey.set(key, { usage, complete, ...ticks2 !== void 0 ? { ticks: ticks2 } : {} });
|
|
25283
25705
|
}
|
|
25284
25706
|
if (latestByKey.size === 0)
|
|
@@ -25290,11 +25712,11 @@ function sessionUsageFromHistory(events) {
|
|
|
25290
25712
|
for (const entry of latestByKey.values()) {
|
|
25291
25713
|
if (!entry.usage)
|
|
25292
25714
|
continue;
|
|
25293
|
-
for (const
|
|
25294
|
-
const value = entry.usage[
|
|
25715
|
+
for (const field2 of summedUsageFields) {
|
|
25716
|
+
const value = entry.usage[field2];
|
|
25295
25717
|
if (value === void 0)
|
|
25296
25718
|
continue;
|
|
25297
|
-
totals2[
|
|
25719
|
+
totals2[field2] = (totals2[field2] ?? 0) + value;
|
|
25298
25720
|
}
|
|
25299
25721
|
sessionInputTokens += (entry.usage.inputTokens ?? 0) + (entry.usage.cachedInputTokens ?? 0) + (entry.usage.cacheWriteInputTokens ?? 0);
|
|
25300
25722
|
if (entry.ticks === void 0)
|
|
@@ -25334,7 +25756,7 @@ function usageFromCompact(tokensAfter, contextWindowTokens) {
|
|
|
25334
25756
|
function usageFromUpdate(update, metadata, contextWindowTokens) {
|
|
25335
25757
|
try {
|
|
25336
25758
|
if (update?.sessionUpdate === "usage_update") {
|
|
25337
|
-
const cost =
|
|
25759
|
+
const cost = isRecord19(update.cost) ? update.cost : null;
|
|
25338
25760
|
return parseHostUsage({
|
|
25339
25761
|
contextUsedTokens: update.used,
|
|
25340
25762
|
contextWindowTokens: update.size,
|
|
@@ -25374,7 +25796,7 @@ function capabilitiesForModels(modelState) {
|
|
|
25374
25796
|
selectModel: modelState.catalog.models.length > 0,
|
|
25375
25797
|
selectThinkingOption: modelState.catalog.thinkingOptions.length > 0,
|
|
25376
25798
|
selectPermissionMode: true,
|
|
25377
|
-
permissionModeScope: "
|
|
25799
|
+
permissionModeScope: "live"
|
|
25378
25800
|
},
|
|
25379
25801
|
history: { fork: true, forkAcrossCwd: true, rollbackLastTurn: true },
|
|
25380
25802
|
subagents: { observe: true, readTranscript: true }
|
|
@@ -25529,6 +25951,8 @@ var GrokHarnessSession = class {
|
|
|
25529
25951
|
return { ok: false, error: invalidState("Grok Session is not open") };
|
|
25530
25952
|
if ("commandId" in command)
|
|
25531
25953
|
return this.#executeHarnessCommand(command);
|
|
25954
|
+
if (command.type === "turn.steer")
|
|
25955
|
+
return unsupportedSteer("Grok");
|
|
25532
25956
|
if (command.type === "turn.cancel")
|
|
25533
25957
|
return this.#cancel(command);
|
|
25534
25958
|
if (command.type === "interaction.respond")
|
|
@@ -25571,6 +25995,7 @@ var GrokHarnessSession = class {
|
|
|
25571
25995
|
});
|
|
25572
25996
|
const active = {
|
|
25573
25997
|
command,
|
|
25998
|
+
questions: new GrokQuestions(command.turnId, this.#randomUUID, (output) => this.#channel.emit(output)),
|
|
25574
25999
|
usage: new GrokTurnUsage(this.#usage, this.#snapshot.turns.length === 0),
|
|
25575
26000
|
agent: null,
|
|
25576
26001
|
agentMessageId: null,
|
|
@@ -25585,7 +26010,7 @@ var GrokHarnessSession = class {
|
|
|
25585
26010
|
subagents: this.#createSubagents(),
|
|
25586
26011
|
completedItems: [],
|
|
25587
26012
|
approvals: /* @__PURE__ */ new Map(),
|
|
25588
|
-
|
|
26013
|
+
legacyQuestions: /* @__PURE__ */ new Map(),
|
|
25589
26014
|
cancellationRequested: false,
|
|
25590
26015
|
beforeNativeTurnKeys: new Set(this.#snapshot.turns.map((turn) => turn.nativeTurnRef.nativeTurnKey)),
|
|
25591
26016
|
completion,
|
|
@@ -25593,7 +26018,7 @@ var GrokHarnessSession = class {
|
|
|
25593
26018
|
};
|
|
25594
26019
|
this.#active = active;
|
|
25595
26020
|
this.#event({ type: "turn.started", turnId: command.turnId });
|
|
25596
|
-
void this.#transport.runTurn(text, (event) => this.#handleEvent(active, event), (request) => this.#requestPermission(active, request), (request) => this.#requestExtension(active, request)).then((response) => this.#settleFromHistory(active, terminalOutcome2(response, active.cancellationRequested), response), (error53) => this.#settleFromHistory(active, {
|
|
26021
|
+
void this.#transport.runTurn(text, (event) => this.#handleEvent(active, event), (request) => this.#requestPermission(active, request), (request) => this.#active === active && this.#phase === "open" && !active.cancellationRequested ? active.questions.ask(request) : Promise.resolve({ outcome: "cancelled" }), (request) => this.#requestExtension(active, request)).finally(() => active.questions.cancel()).then((response) => this.#settleFromHistory(active, terminalOutcome2(response, active.cancellationRequested), response), (error53) => this.#settleFromHistory(active, {
|
|
25597
26022
|
status: "failed",
|
|
25598
26023
|
error: normalizeError(error53, "nativeFailure")
|
|
25599
26024
|
}));
|
|
@@ -25662,6 +26087,7 @@ var GrokHarnessSession = class {
|
|
|
25662
26087
|
});
|
|
25663
26088
|
const active = {
|
|
25664
26089
|
command: { type: "turn.start", turnId: command.turnId, input: [] },
|
|
26090
|
+
questions: new GrokQuestions(command.turnId, this.#randomUUID, (output) => this.#channel.emit(output)),
|
|
25665
26091
|
agent: null,
|
|
25666
26092
|
agentMessageId: null,
|
|
25667
26093
|
rawAgentText: "",
|
|
@@ -25675,7 +26101,7 @@ var GrokHarnessSession = class {
|
|
|
25675
26101
|
subagents: this.#createSubagents(),
|
|
25676
26102
|
completedItems: [],
|
|
25677
26103
|
approvals: /* @__PURE__ */ new Map(),
|
|
25678
|
-
|
|
26104
|
+
legacyQuestions: /* @__PURE__ */ new Map(),
|
|
25679
26105
|
cancellationRequested: false,
|
|
25680
26106
|
beforeNativeTurnKeys: /* @__PURE__ */ new Set(),
|
|
25681
26107
|
completion,
|
|
@@ -25810,14 +26236,29 @@ var GrokHarnessSession = class {
|
|
|
25810
26236
|
}
|
|
25811
26237
|
};
|
|
25812
26238
|
}
|
|
25813
|
-
|
|
25814
|
-
|
|
25815
|
-
|
|
25816
|
-
|
|
25817
|
-
|
|
25818
|
-
|
|
25819
|
-
|
|
25820
|
-
|
|
26239
|
+
if (this.#active || this.#configuring) {
|
|
26240
|
+
return {
|
|
26241
|
+
ok: false,
|
|
26242
|
+
error: {
|
|
26243
|
+
code: "sessionBusy",
|
|
26244
|
+
message: "Grok Session cannot configure permissions during another operation",
|
|
26245
|
+
retryable: true
|
|
26246
|
+
}
|
|
26247
|
+
};
|
|
26248
|
+
}
|
|
26249
|
+
this.#configuring = true;
|
|
26250
|
+
try {
|
|
26251
|
+
await this.#transport.setPermissionMode(command.permissionModeId);
|
|
26252
|
+
if (this.#phase !== "open")
|
|
26253
|
+
return { ok: false, error: invalidState("Grok Session is closed") };
|
|
26254
|
+
this.#state = { ...this.#state, effectivePermissionModeId: command.permissionModeId };
|
|
26255
|
+
this.#event({ type: "session.state.changed", state: this.#state });
|
|
26256
|
+
return { ok: true, value: { completed: true } };
|
|
26257
|
+
} catch (error53) {
|
|
26258
|
+
return { ok: false, error: normalizeError(error53, "nativeFailure") };
|
|
26259
|
+
} finally {
|
|
26260
|
+
this.#configuring = false;
|
|
26261
|
+
}
|
|
25821
26262
|
}
|
|
25822
26263
|
async #cancel(command) {
|
|
25823
26264
|
const active = this.#active;
|
|
@@ -25827,6 +26268,7 @@ var GrokHarnessSession = class {
|
|
|
25827
26268
|
if (active.cancellationRequested)
|
|
25828
26269
|
return { ok: true, value: { cancellationRequested: true } };
|
|
25829
26270
|
active.cancellationRequested = true;
|
|
26271
|
+
active.questions.cancel();
|
|
25830
26272
|
this.#closePendingInteractions(active, "cancelled");
|
|
25831
26273
|
try {
|
|
25832
26274
|
await this.#transport.cancel();
|
|
@@ -25837,10 +26279,12 @@ var GrokHarnessSession = class {
|
|
|
25837
26279
|
}
|
|
25838
26280
|
async #respond(command) {
|
|
25839
26281
|
const active = this.#active;
|
|
26282
|
+
if (active?.questions.has(command.interactionId))
|
|
26283
|
+
return active.questions.respond(command);
|
|
25840
26284
|
const approval = active?.approvals.get(command.interactionId);
|
|
25841
26285
|
if (active && approval)
|
|
25842
26286
|
return this.#respondApproval(active, approval, command);
|
|
25843
|
-
const question = active?.
|
|
26287
|
+
const question = active?.legacyQuestions.get(command.interactionId);
|
|
25844
26288
|
if (active && question)
|
|
25845
26289
|
return this.#respondQuestion(active, question, command);
|
|
25846
26290
|
return { ok: false, error: invalidState("Grok Interaction is not pending") };
|
|
@@ -25894,7 +26338,7 @@ var GrokHarnessSession = class {
|
|
|
25894
26338
|
if (validation)
|
|
25895
26339
|
return { ok: false, error: validation };
|
|
25896
26340
|
const native = pending.type === "planApproval" ? grokExitPlanModeResponse(pending.request, command.response) : grokAskUserQuestionResponse(pending.request, command.response);
|
|
25897
|
-
active.
|
|
26341
|
+
active.legacyQuestions.delete(command.interactionId);
|
|
25898
26342
|
pending.resolve(native);
|
|
25899
26343
|
this.#event({
|
|
25900
26344
|
type: "interaction.closed",
|
|
@@ -25952,7 +26396,7 @@ var GrokHarnessSession = class {
|
|
|
25952
26396
|
const interactionId = hostInteractionIdSchema.parse(this.#randomUUID());
|
|
25953
26397
|
const interaction = createGrokQuestionInteraction(request, interactionId, active.command.turnId);
|
|
25954
26398
|
return new Promise((resolve) => {
|
|
25955
|
-
active.
|
|
26399
|
+
active.legacyQuestions.set(interactionId, {
|
|
25956
26400
|
type: "question",
|
|
25957
26401
|
interaction,
|
|
25958
26402
|
request,
|
|
@@ -25968,7 +26412,7 @@ var GrokHarnessSession = class {
|
|
|
25968
26412
|
const interactionId = hostInteractionIdSchema.parse(this.#randomUUID());
|
|
25969
26413
|
const interaction = createGrokPlanReview(request, interactionId, active.command.turnId);
|
|
25970
26414
|
return new Promise((resolve) => {
|
|
25971
|
-
active.
|
|
26415
|
+
active.legacyQuestions.set(interactionId, {
|
|
25972
26416
|
type: "planApproval",
|
|
25973
26417
|
interaction,
|
|
25974
26418
|
request,
|
|
@@ -25988,8 +26432,8 @@ var GrokHarnessSession = class {
|
|
|
25988
26432
|
reason
|
|
25989
26433
|
});
|
|
25990
26434
|
}
|
|
25991
|
-
for (const [interactionId, pending] of active.
|
|
25992
|
-
active.
|
|
26435
|
+
for (const [interactionId, pending] of active.legacyQuestions) {
|
|
26436
|
+
active.legacyQuestions.delete(interactionId);
|
|
25993
26437
|
pending.resolve(pending.type === "planApproval" ? grokPlanRejectedResponse() : grokSkipInterviewResponse());
|
|
25994
26438
|
this.#event({
|
|
25995
26439
|
type: "interaction.closed",
|
|
@@ -26002,6 +26446,10 @@ var GrokHarnessSession = class {
|
|
|
26002
26446
|
#handleEvent(active, event) {
|
|
26003
26447
|
if (this.#active !== active || this.#phase !== "open")
|
|
26004
26448
|
return;
|
|
26449
|
+
if (event.type === "interaction.resolved") {
|
|
26450
|
+
active.questions.withdraw(event.toolCallId);
|
|
26451
|
+
return;
|
|
26452
|
+
}
|
|
26005
26453
|
const requestUsage = active.usage?.observe(event);
|
|
26006
26454
|
if (requestUsage) {
|
|
26007
26455
|
this.#publishUsage(requestUsage, active.command.turnId, true);
|
|
@@ -26398,6 +26846,7 @@ var GrokHarnessSession = class {
|
|
|
26398
26846
|
#finish(active, outcome, usage = null, nativeTurnRef) {
|
|
26399
26847
|
if (this.#active !== active)
|
|
26400
26848
|
return;
|
|
26849
|
+
active.questions.cancel();
|
|
26401
26850
|
const itemOutcome = outcome;
|
|
26402
26851
|
this.#completeReasoning(active, itemOutcome);
|
|
26403
26852
|
this.#completeAgent(active, itemOutcome);
|
|
@@ -26445,12 +26894,8 @@ var GrokHarnessSession = class {
|
|
|
26445
26894
|
const active = this.#active;
|
|
26446
26895
|
if (active) {
|
|
26447
26896
|
active.cancellationRequested = true;
|
|
26448
|
-
|
|
26449
|
-
|
|
26450
|
-
}
|
|
26451
|
-
for (const question of active.questions.values()) {
|
|
26452
|
-
question.resolve(question.type === "planApproval" ? grokPlanRejectedResponse() : grokSkipInterviewResponse());
|
|
26453
|
-
}
|
|
26897
|
+
active.questions.cancel();
|
|
26898
|
+
this.#closePendingInteractions(active, "cancelled");
|
|
26454
26899
|
await this.#transport.cancel().catch(() => void 0);
|
|
26455
26900
|
await Promise.race([
|
|
26456
26901
|
active.completion,
|
|
@@ -26809,6 +27254,7 @@ var GrokAdapter = class {
|
|
|
26809
27254
|
]);
|
|
26810
27255
|
}
|
|
26811
27256
|
}
|
|
27257
|
+
await transport.setPermissionMode(initialPermissionModeId);
|
|
26812
27258
|
const history = await transport.getHistory();
|
|
26813
27259
|
let initialUsage = input.kind === "resume" || input.kind === "fork" || input.kind === "rollbackLastTurn" ? combineUsage(sessionUsageFromHistory(history), usageFromSignals(opened.signals)) : null;
|
|
26814
27260
|
if (contextWindow !== void 0 && initialUsage?.contextUsedTokens !== void 0) {
|