@liberseek/boft-cli-win32-arm64 0.7.1 → 0.7.3
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/desktop-controller.mjs +49 -18
- package/app/host-runtime.mjs +1025 -671
- package/app/plugins/antigravity/plugin.mjs +18 -3
- package/app/plugins/claude-code/plugin.mjs +214 -7
- package/app/plugins/codebuddy/plugin.mjs +103 -5
- package/app/plugins/cursor-cli/plugin.mjs +152 -53
- package/app/plugins/deepseek-harness/plugin.mjs +34 -21
- package/app/plugins/enabled.json +2 -1
- package/app/plugins/grok/plugin.mjs +281 -88
- package/app/plugins/hermes/plugin.mjs +162 -63
- package/app/plugins/kimi-code/manifest.json +11 -0
- package/app/plugins/kimi-code/plugin.mjs +24259 -0
- package/app/plugins/kiro-cli/plugin.mjs +257 -65
- package/app/plugins/muse/plugin.mjs +18 -3
- package/app/plugins/omp/plugin.mjs +258 -67
- package/app/plugins/opencode/plugin.mjs +18 -3
- package/app/plugins/pi/plugin.mjs +211 -4
- package/app/plugins/qoder/plugin.mjs +285 -193
- package/app/plugins/qoder-cn/plugin.mjs +285 -193
- package/app/plugins/workbuddy/plugin.mjs +102 -5
- package/app/renderer-extension.js +1304 -468
- package/bin/boft.exe +0 -0
- package/libexec/boft-node-repl.exe +0 -0
- package/libexec/boft-shim.exe +0 -0
- package/libexec/boft-updater.exe +0 -0
- package/package.json +1 -1
|
@@ -19504,10 +19504,21 @@ var harnessCommandDescriptorSchema = external_exports.object({
|
|
|
19504
19504
|
invocation: commandInvocationSchema,
|
|
19505
19505
|
label: commandLabelSchema,
|
|
19506
19506
|
description: commandDescriptionSchema.optional(),
|
|
19507
|
-
argumentMode: external_exports.enum(["none", "text"])
|
|
19507
|
+
argumentMode: external_exports.enum(["none", "text"]),
|
|
19508
|
+
/**
|
|
19509
|
+
* Native distinction reported by the Harness. Omitted when the Harness does
|
|
19510
|
+
* not tell skills and commands apart; consumers treat that as "command".
|
|
19511
|
+
*/
|
|
19512
|
+
kind: external_exports.enum(["command", "skill"]).optional()
|
|
19508
19513
|
}).strict();
|
|
19509
19514
|
var harnessCommandCatalogSchema = external_exports.object({
|
|
19510
|
-
commands: external_exports.array(harnessCommandDescriptorSchema)
|
|
19515
|
+
commands: external_exports.array(harnessCommandDescriptorSchema),
|
|
19516
|
+
/**
|
|
19517
|
+
* `live` when the catalog includes what a native Session reports for its
|
|
19518
|
+
* workspace (custom commands, skills); `static` for Adapter built-ins only.
|
|
19519
|
+
* Omitted by Adapters; set by the Host on inspection results.
|
|
19520
|
+
*/
|
|
19521
|
+
source: external_exports.enum(["live", "static"]).optional()
|
|
19511
19522
|
}).strict().superRefine((catalog, context) => {
|
|
19512
19523
|
const ids = /* @__PURE__ */ new Set();
|
|
19513
19524
|
for (const [index, command] of catalog.commands.entries()) {
|
|
@@ -19521,7 +19532,11 @@ var harnessCommandCatalogSchema = external_exports.object({
|
|
|
19521
19532
|
ids.add(command.id);
|
|
19522
19533
|
}
|
|
19523
19534
|
});
|
|
19524
|
-
var harnessCommandsInspectParamsSchema = external_exports.object({
|
|
19535
|
+
var harnessCommandsInspectParamsSchema = external_exports.object({
|
|
19536
|
+
harnessId: harnessIdSchema,
|
|
19537
|
+
/** Workspace of a draft without a Thread, for its live catalog when known. */
|
|
19538
|
+
cwd: external_exports.string().min(1).optional()
|
|
19539
|
+
}).strict();
|
|
19525
19540
|
var threadCommandsInspectParamsSchema = external_exports.object({
|
|
19526
19541
|
threadId: hostThreadIdSchema
|
|
19527
19542
|
}).strict();
|
|
@@ -19866,6 +19881,124 @@ function parseHostUsage(value) {
|
|
|
19866
19881
|
return { ...value };
|
|
19867
19882
|
}
|
|
19868
19883
|
|
|
19884
|
+
// ../../harness-adapter/dist/live-command-catalog.js
|
|
19885
|
+
var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
|
|
19886
|
+
// Session lifecycle
|
|
19887
|
+
"branch",
|
|
19888
|
+
"clear",
|
|
19889
|
+
"exit",
|
|
19890
|
+
"fork",
|
|
19891
|
+
"fresh",
|
|
19892
|
+
"new",
|
|
19893
|
+
"quit",
|
|
19894
|
+
"rename",
|
|
19895
|
+
"rename-chat",
|
|
19896
|
+
"reset",
|
|
19897
|
+
"resume",
|
|
19898
|
+
"rewind",
|
|
19899
|
+
"session",
|
|
19900
|
+
"sessions",
|
|
19901
|
+
// Desktop-owned configuration
|
|
19902
|
+
"autocompact",
|
|
19903
|
+
"color",
|
|
19904
|
+
"config",
|
|
19905
|
+
"effort",
|
|
19906
|
+
"fast",
|
|
19907
|
+
"keybindings",
|
|
19908
|
+
"model",
|
|
19909
|
+
"models",
|
|
19910
|
+
"output-style",
|
|
19911
|
+
"permissions",
|
|
19912
|
+
"settings",
|
|
19913
|
+
"statusline",
|
|
19914
|
+
"terminal-setup",
|
|
19915
|
+
"theme",
|
|
19916
|
+
"vim",
|
|
19917
|
+
// Trust and approval policy
|
|
19918
|
+
"always-approve",
|
|
19919
|
+
"auto-mode-setup",
|
|
19920
|
+
// Native login
|
|
19921
|
+
"login",
|
|
19922
|
+
"logout",
|
|
19923
|
+
// Work outliving the Turn
|
|
19924
|
+
"autopilot",
|
|
19925
|
+
"background",
|
|
19926
|
+
"bg",
|
|
19927
|
+
"goal",
|
|
19928
|
+
"jobs",
|
|
19929
|
+
"loop",
|
|
19930
|
+
"multitask",
|
|
19931
|
+
"queue",
|
|
19932
|
+
"remote-control",
|
|
19933
|
+
"schedule",
|
|
19934
|
+
"steer",
|
|
19935
|
+
// Native terminal UI
|
|
19936
|
+
"copy",
|
|
19937
|
+
"debug",
|
|
19938
|
+
"feedback",
|
|
19939
|
+
"heapdump",
|
|
19940
|
+
"share",
|
|
19941
|
+
"shell",
|
|
19942
|
+
// Plugin and MCP management
|
|
19943
|
+
"marketplace",
|
|
19944
|
+
"mcp",
|
|
19945
|
+
"plugins",
|
|
19946
|
+
"reload-plugins"
|
|
19947
|
+
]);
|
|
19948
|
+
var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
|
|
19949
|
+
function isExcludedLiveCommand(name, kind, extra = {}) {
|
|
19950
|
+
const normalized = name.trim().replace(/^\//u, "");
|
|
19951
|
+
if (new Set(extra.names ?? []).has(normalized))
|
|
19952
|
+
return true;
|
|
19953
|
+
if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
|
|
19954
|
+
return true;
|
|
19955
|
+
if (kind === "skill")
|
|
19956
|
+
return false;
|
|
19957
|
+
return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
19958
|
+
}
|
|
19959
|
+
function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
|
|
19960
|
+
if (!commandId.startsWith(idPrefix))
|
|
19961
|
+
return null;
|
|
19962
|
+
const descriptor = catalog.commands.find(({ id }) => id === commandId);
|
|
19963
|
+
if (!descriptor)
|
|
19964
|
+
return null;
|
|
19965
|
+
const text = typeof argumentText === "string" ? argumentText.trim() : "";
|
|
19966
|
+
return text ? `${descriptor.invocation} ${text}` : descriptor.invocation;
|
|
19967
|
+
}
|
|
19968
|
+
function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
19969
|
+
if (!live)
|
|
19970
|
+
return builtIns;
|
|
19971
|
+
const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
|
|
19972
|
+
const ids = new Set(builtIns.commands.map(({ id }) => id));
|
|
19973
|
+
const dynamic = [];
|
|
19974
|
+
for (const command of live) {
|
|
19975
|
+
const name = command.name.trim().replace(/^\//u, "");
|
|
19976
|
+
if (!name || /\s/u.test(name))
|
|
19977
|
+
continue;
|
|
19978
|
+
if (isExcludedLiveCommand(name, command.kind, exclusions))
|
|
19979
|
+
continue;
|
|
19980
|
+
const invocation = `/${name}`;
|
|
19981
|
+
const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
|
|
19982
|
+
if (invocations.has(invocation) || ids.has(id))
|
|
19983
|
+
continue;
|
|
19984
|
+
const description = command.description?.trim().slice(0, 512);
|
|
19985
|
+
const parsed = harnessCommandDescriptorSchema.safeParse({
|
|
19986
|
+
id,
|
|
19987
|
+
invocation,
|
|
19988
|
+
label: name.slice(0, 128),
|
|
19989
|
+
...description ? { description } : {},
|
|
19990
|
+
argumentMode: "text",
|
|
19991
|
+
kind: command.kind
|
|
19992
|
+
});
|
|
19993
|
+
if (!parsed.success)
|
|
19994
|
+
continue;
|
|
19995
|
+
invocations.add(invocation);
|
|
19996
|
+
ids.add(id);
|
|
19997
|
+
dynamic.push(parsed.data);
|
|
19998
|
+
}
|
|
19999
|
+
return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
|
|
20000
|
+
}
|
|
20001
|
+
|
|
19869
20002
|
// dist/acp-transport.js
|
|
19870
20003
|
import { spawn, spawnSync } from "node:child_process";
|
|
19871
20004
|
import { readdir, readFile as readFile2 } from "node:fs/promises";
|
|
@@ -19873,6 +20006,41 @@ import os4 from "node:os";
|
|
|
19873
20006
|
import path9 from "node:path";
|
|
19874
20007
|
import { Readable, Writable } from "node:stream";
|
|
19875
20008
|
|
|
20009
|
+
// dist/grok-slash-commands.js
|
|
20010
|
+
var GROK_LIVE_COMMAND_ID_PREFIX = "grok.slash.";
|
|
20011
|
+
function isRecord3(value) {
|
|
20012
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20013
|
+
}
|
|
20014
|
+
function parseGrokAvailableCommands(value) {
|
|
20015
|
+
if (!Array.isArray(value))
|
|
20016
|
+
return [];
|
|
20017
|
+
return value.flatMap((entry) => {
|
|
20018
|
+
if (!isRecord3(entry))
|
|
20019
|
+
return [];
|
|
20020
|
+
const name = typeof entry.name === "string" ? entry.name.trim().replace(/^\//u, "") : "";
|
|
20021
|
+
if (!name)
|
|
20022
|
+
return [];
|
|
20023
|
+
return [
|
|
20024
|
+
{
|
|
20025
|
+
name,
|
|
20026
|
+
description: typeof entry.description === "string" ? entry.description : "",
|
|
20027
|
+
meta: isRecord3(entry._meta) ? entry._meta : null
|
|
20028
|
+
}
|
|
20029
|
+
];
|
|
20030
|
+
});
|
|
20031
|
+
}
|
|
20032
|
+
function isGrokSkill(command) {
|
|
20033
|
+
const path12 = command.meta?.path;
|
|
20034
|
+
return typeof path12 === "string" && /(^|[\\/])SKILL\.md$/u.test(path12) || typeof command.meta?.qualifiedName === "string";
|
|
20035
|
+
}
|
|
20036
|
+
function grokLiveCommands(native) {
|
|
20037
|
+
return native.map((command) => ({
|
|
20038
|
+
name: command.name,
|
|
20039
|
+
description: command.description,
|
|
20040
|
+
kind: isGrokSkill(command) ? "skill" : "command"
|
|
20041
|
+
}));
|
|
20042
|
+
}
|
|
20043
|
+
|
|
19876
20044
|
// dist/command.js
|
|
19877
20045
|
import path4 from "node:path";
|
|
19878
20046
|
|
|
@@ -20567,7 +20735,7 @@ function splitLines(text) {
|
|
|
20567
20735
|
// dist/grok-file-change.js
|
|
20568
20736
|
var DEFAULT_GROK_FILE_CHANGE_TEXT_LIMIT = 4 * 1024 * 1024;
|
|
20569
20737
|
var MAX_GROK_FILE_CHANGES_PER_TOOL = 32;
|
|
20570
|
-
function
|
|
20738
|
+
function isRecord4(value) {
|
|
20571
20739
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20572
20740
|
}
|
|
20573
20741
|
function validAbsolutePath(value) {
|
|
@@ -20618,7 +20786,7 @@ function projectGrokFileChanges(content, cwd, textLimit = DEFAULT_GROK_FILE_CHAN
|
|
|
20618
20786
|
return null;
|
|
20619
20787
|
const candidates = [];
|
|
20620
20788
|
for (const entry of content) {
|
|
20621
|
-
if (
|
|
20789
|
+
if (isRecord4(entry) && entry.type === "diff")
|
|
20622
20790
|
candidates.push(entry);
|
|
20623
20791
|
}
|
|
20624
20792
|
if (candidates.length === 0 || candidates.length > MAX_GROK_FILE_CHANGES_PER_TOOL)
|
|
@@ -20935,14 +21103,14 @@ function mediaFileExists(absolutePath) {
|
|
|
20935
21103
|
// dist/grok-tool-output.js
|
|
20936
21104
|
var DEFAULT_GROK_TOOL_OUTPUT_LIMIT = 64e3;
|
|
20937
21105
|
var EXECUTE_TOOL_NAMES = /* @__PURE__ */ new Set(["bash", "run_terminal_command", "shell", "cursor_shell"]);
|
|
20938
|
-
function
|
|
21106
|
+
function isRecord5(value) {
|
|
20939
21107
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20940
21108
|
}
|
|
20941
21109
|
function stringField(value, key) {
|
|
20942
|
-
return
|
|
21110
|
+
return isRecord5(value) && typeof value[key] === "string" && value[key].length > 0 ? value[key] : void 0;
|
|
20943
21111
|
}
|
|
20944
21112
|
function numberField(value, key) {
|
|
20945
|
-
if (!
|
|
21113
|
+
if (!isRecord5(value))
|
|
20946
21114
|
return void 0;
|
|
20947
21115
|
const field = value[key];
|
|
20948
21116
|
if (field === null)
|
|
@@ -20965,7 +21133,7 @@ function firstReadableText(...candidates) {
|
|
|
20965
21133
|
for (const candidate of candidates) {
|
|
20966
21134
|
if (typeof candidate === "string" && candidate.length > 0)
|
|
20967
21135
|
return candidate;
|
|
20968
|
-
if (
|
|
21136
|
+
if (isRecord5(candidate)) {
|
|
20969
21137
|
const nested = stringField(candidate, "content") ?? stringField(candidate, "text") ?? stringField(candidate, "tool_result") ?? stringField(candidate, "raw_output");
|
|
20970
21138
|
if (nested)
|
|
20971
21139
|
return nested;
|
|
@@ -20988,7 +21156,7 @@ function grokToolArguments(rawInput) {
|
|
|
20988
21156
|
if (!parsed.success)
|
|
20989
21157
|
return {};
|
|
20990
21158
|
const argumentsValue = parsed.data;
|
|
20991
|
-
if (!
|
|
21159
|
+
if (!isRecord5(argumentsValue) || stringField(argumentsValue, "path"))
|
|
20992
21160
|
return argumentsValue;
|
|
20993
21161
|
const targetFile = stringField(argumentsValue, "target_file");
|
|
20994
21162
|
return targetFile ? { ...argumentsValue, path: targetFile } : argumentsValue;
|
|
@@ -21001,7 +21169,7 @@ function grokCommand(name, kind, rawInput) {
|
|
|
21001
21169
|
return command;
|
|
21002
21170
|
if (name && EXECUTE_TOOL_NAMES.has(name))
|
|
21003
21171
|
return command;
|
|
21004
|
-
return
|
|
21172
|
+
return isRecord5(rawInput) && rawInput.variant === "Bash" ? command : void 0;
|
|
21005
21173
|
}
|
|
21006
21174
|
function grokCommandCwd(rawInput, fallback) {
|
|
21007
21175
|
return stringField(rawInput, "cwd") ?? fallback;
|
|
@@ -21028,11 +21196,11 @@ function acpContentText(content) {
|
|
|
21028
21196
|
if (!Array.isArray(content))
|
|
21029
21197
|
return "";
|
|
21030
21198
|
return content.flatMap((entry) => {
|
|
21031
|
-
if (!
|
|
21199
|
+
if (!isRecord5(entry))
|
|
21032
21200
|
return [];
|
|
21033
21201
|
if (entry.type === "text" && typeof entry.text === "string")
|
|
21034
21202
|
return [entry.text];
|
|
21035
|
-
if (entry.type !== "content" || !
|
|
21203
|
+
if (entry.type !== "content" || !isRecord5(entry.content))
|
|
21036
21204
|
return [];
|
|
21037
21205
|
return entry.content.type === "text" && typeof entry.content.text === "string" ? [entry.content.text] : [];
|
|
21038
21206
|
}).join("\n");
|
|
@@ -21043,10 +21211,10 @@ function acpContentImages(content, remainingBytes) {
|
|
|
21043
21211
|
const images = [];
|
|
21044
21212
|
let remaining = remainingBytes;
|
|
21045
21213
|
for (const entry of content) {
|
|
21046
|
-
if (!
|
|
21214
|
+
if (!isRecord5(entry))
|
|
21047
21215
|
continue;
|
|
21048
21216
|
const image = entry.type === "image" ? entry : entry.type === "content" ? entry.content : null;
|
|
21049
|
-
if (!
|
|
21217
|
+
if (!isRecord5(image) || image.type !== "image")
|
|
21050
21218
|
continue;
|
|
21051
21219
|
const mimeType = stringField(image, "mimeType") ?? stringField(image, "mime_type");
|
|
21052
21220
|
const data = stringField(image, "data");
|
|
@@ -21069,14 +21237,14 @@ function bashOutput(rawOutput) {
|
|
|
21069
21237
|
function rawOutputProjection(rawOutput) {
|
|
21070
21238
|
if (typeof rawOutput === "string")
|
|
21071
21239
|
return rawOutput.length > 0 ? { text: rawOutput } : {};
|
|
21072
|
-
if (!
|
|
21240
|
+
if (!isRecord5(rawOutput))
|
|
21073
21241
|
return {};
|
|
21074
21242
|
if (rawOutput.type === "Bash" || rawOutput.variant === "Bash" || numberField(rawOutput, "exit_code") !== void 0 || numberField(rawOutput, "exitCode") !== void 0) {
|
|
21075
21243
|
const bash = bashOutput(rawOutput);
|
|
21076
21244
|
if (bash.text !== void 0 || bash.exitCode !== void 0)
|
|
21077
21245
|
return bash;
|
|
21078
21246
|
}
|
|
21079
|
-
const text = firstReadableText(rawOutput.content, rawOutput.text, rawOutput.tool_result, rawOutput.raw_output,
|
|
21247
|
+
const text = firstReadableText(rawOutput.content, rawOutput.text, rawOutput.tool_result, rawOutput.raw_output, isRecord5(rawOutput.FileContent) ? rawOutput.FileContent : void 0, isRecord5(rawOutput.Content) ? rawOutput.Content : void 0);
|
|
21080
21248
|
if (text)
|
|
21081
21249
|
return { text };
|
|
21082
21250
|
if (typeof rawOutput.match_count === "number" && Number.isFinite(rawOutput.match_count)) {
|
|
@@ -21140,11 +21308,11 @@ var WAIT_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
|
21140
21308
|
var KILL_TOOL_NAMES = /* @__PURE__ */ new Set(["kill_command_or_subagent", "kill_task"]);
|
|
21141
21309
|
var DESCRIPTION_LIMIT = 500;
|
|
21142
21310
|
var SUMMARY_LIMIT = 2e3;
|
|
21143
|
-
function
|
|
21311
|
+
function isRecord6(value) {
|
|
21144
21312
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21145
21313
|
}
|
|
21146
21314
|
function idField(value, key) {
|
|
21147
|
-
if (!
|
|
21315
|
+
if (!isRecord6(value))
|
|
21148
21316
|
return void 0;
|
|
21149
21317
|
const field = value[key];
|
|
21150
21318
|
if (typeof field === "string") {
|
|
@@ -21156,7 +21324,7 @@ function idField(value, key) {
|
|
|
21156
21324
|
return void 0;
|
|
21157
21325
|
}
|
|
21158
21326
|
function stringField2(value, key) {
|
|
21159
|
-
if (!
|
|
21327
|
+
if (!isRecord6(value) || typeof value[key] !== "string")
|
|
21160
21328
|
return void 0;
|
|
21161
21329
|
const trimmed = value[key].trim();
|
|
21162
21330
|
return trimmed.length > 0 ? trimmed : void 0;
|
|
@@ -21179,7 +21347,7 @@ function collectIds(value) {
|
|
|
21179
21347
|
};
|
|
21180
21348
|
push(idField(value, "task_id"));
|
|
21181
21349
|
push(idField(value, "subagent_id"));
|
|
21182
|
-
if (
|
|
21350
|
+
if (isRecord6(value)) {
|
|
21183
21351
|
const list = value.task_ids ?? value.subagent_ids;
|
|
21184
21352
|
if (Array.isArray(list)) {
|
|
21185
21353
|
for (const entry of list)
|
|
@@ -21198,7 +21366,7 @@ function grokSubagentOperation(name, title, rawInput) {
|
|
|
21198
21366
|
return "send";
|
|
21199
21367
|
if (SPAWN_TOOL_NAMES.has(id))
|
|
21200
21368
|
return "spawn";
|
|
21201
|
-
if (
|
|
21369
|
+
if (isRecord6(rawInput) && rawInput.variant === "Task")
|
|
21202
21370
|
return "spawn";
|
|
21203
21371
|
return null;
|
|
21204
21372
|
}
|
|
@@ -21221,7 +21389,7 @@ function grokSubagentRole(rawInput) {
|
|
|
21221
21389
|
return bounded(stringField2(rawInput, "subagent_type") ?? stringField2(rawInput, "agent_type") ?? stringField2(rawInput, "type"), DESCRIPTION_LIMIT);
|
|
21222
21390
|
}
|
|
21223
21391
|
function grokSubagentBackground(rawInput) {
|
|
21224
|
-
if (!
|
|
21392
|
+
if (!isRecord6(rawInput))
|
|
21225
21393
|
return true;
|
|
21226
21394
|
if (rawInput.background === false || rawInput.run_in_background === false)
|
|
21227
21395
|
return false;
|
|
@@ -21259,7 +21427,7 @@ function grokSubagentResultSummary(...candidates) {
|
|
|
21259
21427
|
return void 0;
|
|
21260
21428
|
}
|
|
21261
21429
|
function grokSubagentEventFromUpdate(update) {
|
|
21262
|
-
if (!
|
|
21430
|
+
if (!isRecord6(update) || typeof update.sessionUpdate !== "string")
|
|
21263
21431
|
return null;
|
|
21264
21432
|
const nativeSubagentId = idField(update, "subagent_id") ?? idField(update, "child_session_id");
|
|
21265
21433
|
if (!nativeSubagentId)
|
|
@@ -21320,14 +21488,14 @@ function grokSubagentWaitSettlements(input) {
|
|
|
21320
21488
|
return ids.map((id) => ({ id, status: overall }));
|
|
21321
21489
|
}
|
|
21322
21490
|
function taskOutputResults(rawOutput) {
|
|
21323
|
-
if (!
|
|
21491
|
+
if (!isRecord6(rawOutput))
|
|
21324
21492
|
return [];
|
|
21325
21493
|
if (Array.isArray(rawOutput.results)) {
|
|
21326
|
-
return rawOutput.results.filter(
|
|
21494
|
+
return rawOutput.results.filter(isRecord6);
|
|
21327
21495
|
}
|
|
21328
21496
|
const nested = firstRecord(rawOutput.MultiResult, rawOutput.multiResult, rawOutput.multi_result);
|
|
21329
21497
|
if (nested && Array.isArray(nested.results)) {
|
|
21330
|
-
return nested.results.filter(
|
|
21498
|
+
return nested.results.filter(isRecord6);
|
|
21331
21499
|
}
|
|
21332
21500
|
const single = firstRecord(rawOutput.Result, rawOutput.result);
|
|
21333
21501
|
if (single)
|
|
@@ -21338,7 +21506,7 @@ function taskOutputResults(rawOutput) {
|
|
|
21338
21506
|
}
|
|
21339
21507
|
function firstRecord(...values) {
|
|
21340
21508
|
for (const value of values) {
|
|
21341
|
-
if (
|
|
21509
|
+
if (isRecord6(value))
|
|
21342
21510
|
return value;
|
|
21343
21511
|
}
|
|
21344
21512
|
return void 0;
|
|
@@ -21361,7 +21529,7 @@ function taskOutputTextSettlements(rawOutput, content, ids) {
|
|
|
21361
21529
|
return settled;
|
|
21362
21530
|
}
|
|
21363
21531
|
function taskOutputStatus(rawOutput, content) {
|
|
21364
|
-
if (
|
|
21532
|
+
if (isRecord6(rawOutput) && typeof rawOutput.status === "string")
|
|
21365
21533
|
return rawOutput.status;
|
|
21366
21534
|
const text = extractText(content) ?? extractText(rawOutput);
|
|
21367
21535
|
if (!text)
|
|
@@ -21420,7 +21588,7 @@ function extractText(value, depth = 0) {
|
|
|
21420
21588
|
const joined = parts.join("\n").trim();
|
|
21421
21589
|
return joined.length > 0 ? joined : void 0;
|
|
21422
21590
|
}
|
|
21423
|
-
if (!
|
|
21591
|
+
if (!isRecord6(value))
|
|
21424
21592
|
return void 0;
|
|
21425
21593
|
if (typeof value.text === "string" && value.text.trim().length > 0)
|
|
21426
21594
|
return value.text.trim();
|
|
@@ -21890,11 +22058,11 @@ var GROK_SESSION_DELETE_METHOD = "_x.ai/session/delete";
|
|
|
21890
22058
|
function error51(code, message, retryable = false) {
|
|
21891
22059
|
return { code, message, retryable };
|
|
21892
22060
|
}
|
|
21893
|
-
function
|
|
22061
|
+
function isRecord7(value) {
|
|
21894
22062
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21895
22063
|
}
|
|
21896
22064
|
function isGrokMethodNotFound(error53) {
|
|
21897
|
-
if (
|
|
22065
|
+
if (isRecord7(error53) && error53.code === -32601)
|
|
21898
22066
|
return true;
|
|
21899
22067
|
const message = error53 instanceof Error ? error53.message : String(error53);
|
|
21900
22068
|
return /method not found/iu.test(message);
|
|
@@ -21912,10 +22080,10 @@ function buildGrokForkParams(input) {
|
|
|
21912
22080
|
};
|
|
21913
22081
|
}
|
|
21914
22082
|
function parseGrokForkResponse(value) {
|
|
21915
|
-
if (!
|
|
22083
|
+
if (!isRecord7(value) || value.error !== void 0)
|
|
21916
22084
|
return null;
|
|
21917
|
-
const payload = typeof value.newSessionId !== "string" &&
|
|
21918
|
-
if (!
|
|
22085
|
+
const payload = typeof value.newSessionId !== "string" && isRecord7(value.result) ? value.result : value;
|
|
22086
|
+
if (!isRecord7(payload) || payload.error !== void 0)
|
|
21919
22087
|
return null;
|
|
21920
22088
|
if (typeof payload.newSessionId !== "string" || payload.newSessionId.length === 0)
|
|
21921
22089
|
return null;
|
|
@@ -22078,7 +22246,7 @@ var GROK_SESSION_UPDATE_EXTENSION_METHODS = [
|
|
|
22078
22246
|
"_x.ai/session/update",
|
|
22079
22247
|
"x.ai/session_notification"
|
|
22080
22248
|
];
|
|
22081
|
-
function
|
|
22249
|
+
function isRecord8(value) {
|
|
22082
22250
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22083
22251
|
}
|
|
22084
22252
|
function optionalNonNegativeInt(value) {
|
|
@@ -22099,7 +22267,7 @@ function isGrokExtensionSessionUpdateMethod(method) {
|
|
|
22099
22267
|
return GROK_SESSION_UPDATE_EXTENSION_METHODS.includes(method);
|
|
22100
22268
|
}
|
|
22101
22269
|
function grokCompactionEventFromUpdate(update) {
|
|
22102
|
-
if (!
|
|
22270
|
+
if (!isRecord8(update) || typeof update.sessionUpdate !== "string")
|
|
22103
22271
|
return null;
|
|
22104
22272
|
const tokensUsed = optionalNonNegativeInt(firstPresent(update, ["tokensUsed", "tokens_used"]));
|
|
22105
22273
|
const contextWindowTokens = optionalNonNegativeInt(firstPresent(update, ["contextWindowTokens", "contextWindow", "context_window"]));
|
|
@@ -22138,7 +22306,7 @@ function grokCompactionEventFromUpdate(update) {
|
|
|
22138
22306
|
// dist/grok-manual-compaction.js
|
|
22139
22307
|
var GROK_COMPACT_CONVERSATION_METHOD = "x.ai/compact_conversation";
|
|
22140
22308
|
var GROK_COMPACT_CONVERSATION_FALLBACK_METHOD = "_x.ai/compact_conversation";
|
|
22141
|
-
function
|
|
22309
|
+
function isRecord9(value) {
|
|
22142
22310
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22143
22311
|
}
|
|
22144
22312
|
function optionalNonNegativeInt2(value) {
|
|
@@ -22150,7 +22318,7 @@ function optionalErrorMessage2(value) {
|
|
|
22150
22318
|
function parseGrokCompactResult(value, cancelled = false) {
|
|
22151
22319
|
if (cancelled)
|
|
22152
22320
|
return { outcome: "cancelled" };
|
|
22153
|
-
if (!
|
|
22321
|
+
if (!isRecord9(value))
|
|
22154
22322
|
return { outcome: "succeeded" };
|
|
22155
22323
|
const tokensBefore = optionalNonNegativeInt2(value.tokensBefore ?? value.tokens_before);
|
|
22156
22324
|
const tokensAfter = optionalNonNegativeInt2(value.tokensAfter ?? value.tokens_after);
|
|
@@ -22188,7 +22356,7 @@ var GROK_REWIND_EXECUTE_METHOD = "_x.ai/rewind/execute";
|
|
|
22188
22356
|
function error52(code, message, retryable = false) {
|
|
22189
22357
|
return { code, message, retryable };
|
|
22190
22358
|
}
|
|
22191
|
-
function
|
|
22359
|
+
function isRecord10(value) {
|
|
22192
22360
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22193
22361
|
}
|
|
22194
22362
|
function buildGrokRewindParams(input) {
|
|
@@ -22200,10 +22368,10 @@ function buildGrokRewindParams(input) {
|
|
|
22200
22368
|
};
|
|
22201
22369
|
}
|
|
22202
22370
|
function parseGrokRewindResponse(value) {
|
|
22203
|
-
if (!
|
|
22371
|
+
if (!isRecord10(value))
|
|
22204
22372
|
return null;
|
|
22205
|
-
const payload = typeof value.success !== "boolean" &&
|
|
22206
|
-
if (!
|
|
22373
|
+
const payload = typeof value.success !== "boolean" && isRecord10(value.result) ? value.result : value;
|
|
22374
|
+
if (!isRecord10(payload) || typeof payload.success !== "boolean")
|
|
22207
22375
|
return null;
|
|
22208
22376
|
return rewindPayload(payload);
|
|
22209
22377
|
}
|
|
@@ -22319,7 +22487,7 @@ var GROK_PLAN_STAY_VALUE = "stay";
|
|
|
22319
22487
|
var GROK_PLAN_STAY_LABEL = "Stay in plan mode";
|
|
22320
22488
|
var GROK_PLAN_OUTCOME_APPROVED = "approved";
|
|
22321
22489
|
var GROK_PLAN_OUTCOME_CANCELLED = "cancelled";
|
|
22322
|
-
function
|
|
22490
|
+
function isRecord11(value) {
|
|
22323
22491
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22324
22492
|
}
|
|
22325
22493
|
function stringField3(value, ...keys) {
|
|
@@ -22331,9 +22499,9 @@ function stringField3(value, ...keys) {
|
|
|
22331
22499
|
return void 0;
|
|
22332
22500
|
}
|
|
22333
22501
|
function parseGrokExitPlanModeParams(params) {
|
|
22334
|
-
if (!
|
|
22502
|
+
if (!isRecord11(params))
|
|
22335
22503
|
return null;
|
|
22336
|
-
const nested =
|
|
22504
|
+
const nested = isRecord11(params.input) ? params.input : params;
|
|
22337
22505
|
const plan = stringField3(nested, "planContent", "plan_content", "plan") ?? stringField3(params, "planContent", "plan_content", "plan") ?? null;
|
|
22338
22506
|
const planFilePath = stringField3(nested, "planFilePath", "plan_file_path") ?? stringField3(params, "planFilePath", "plan_file_path");
|
|
22339
22507
|
const sessionId = stringField3(params, "sessionId", "session_id");
|
|
@@ -22405,7 +22573,7 @@ var GROK_ACP_CLIENT_CAPABILITIES = {
|
|
|
22405
22573
|
"x.ai/exit_plan_mode": true
|
|
22406
22574
|
}
|
|
22407
22575
|
};
|
|
22408
|
-
function
|
|
22576
|
+
function isRecord12(value) {
|
|
22409
22577
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22410
22578
|
}
|
|
22411
22579
|
function stringField4(value, ...keys) {
|
|
@@ -22434,15 +22602,15 @@ function isGrokExitPlanModeMethod(method) {
|
|
|
22434
22602
|
function questionsPayload(params) {
|
|
22435
22603
|
if (Array.isArray(params.questions))
|
|
22436
22604
|
return params.questions;
|
|
22437
|
-
if (
|
|
22605
|
+
if (isRecord12(params.input) && Array.isArray(params.input.questions))
|
|
22438
22606
|
return params.input.questions;
|
|
22439
|
-
if (
|
|
22607
|
+
if (isRecord12(params.askUserQuestion) && Array.isArray(params.askUserQuestion.questions)) {
|
|
22440
22608
|
return params.askUserQuestion.questions;
|
|
22441
22609
|
}
|
|
22442
22610
|
return void 0;
|
|
22443
22611
|
}
|
|
22444
22612
|
function parseOption(value, labels) {
|
|
22445
|
-
if (!
|
|
22613
|
+
if (!isRecord12(value))
|
|
22446
22614
|
return null;
|
|
22447
22615
|
const label = stringField4(value, "label");
|
|
22448
22616
|
if (!label || labels.has(label))
|
|
@@ -22457,7 +22625,7 @@ function parseOption(value, labels) {
|
|
|
22457
22625
|
};
|
|
22458
22626
|
}
|
|
22459
22627
|
function parseQuestion(value, questions) {
|
|
22460
|
-
if (!
|
|
22628
|
+
if (!isRecord12(value))
|
|
22461
22629
|
return null;
|
|
22462
22630
|
const question = stringField4(value, "question");
|
|
22463
22631
|
if (!question || questions.has(question))
|
|
@@ -22482,7 +22650,7 @@ function parseQuestion(value, questions) {
|
|
|
22482
22650
|
};
|
|
22483
22651
|
}
|
|
22484
22652
|
function parseGrokAskUserQuestionParams(params) {
|
|
22485
|
-
if (!
|
|
22653
|
+
if (!isRecord12(params))
|
|
22486
22654
|
return null;
|
|
22487
22655
|
const rawQuestions = questionsPayload(params);
|
|
22488
22656
|
if (!Array.isArray(rawQuestions) || rawQuestions.length === 0)
|
|
@@ -22597,16 +22765,16 @@ var GrokTransportError = class extends Error {
|
|
|
22597
22765
|
this.name = "GrokTransportError";
|
|
22598
22766
|
}
|
|
22599
22767
|
};
|
|
22600
|
-
function
|
|
22768
|
+
function isRecord13(value) {
|
|
22601
22769
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22602
22770
|
}
|
|
22603
22771
|
function acpToolName(update, metadata) {
|
|
22604
|
-
if (!
|
|
22772
|
+
if (!isRecord13(update))
|
|
22605
22773
|
return void 0;
|
|
22606
22774
|
if (typeof update.name === "string" && update.name.length > 0)
|
|
22607
22775
|
return update.name;
|
|
22608
|
-
const meta3 =
|
|
22609
|
-
const tool = meta3 &&
|
|
22776
|
+
const meta3 = isRecord13(update._meta) ? update._meta : metadata;
|
|
22777
|
+
const tool = meta3 && isRecord13(meta3["x.ai/tool"]) ? meta3["x.ai/tool"] : void 0;
|
|
22610
22778
|
return tool && typeof tool.name === "string" && tool.name.length > 0 ? tool.name : void 0;
|
|
22611
22779
|
}
|
|
22612
22780
|
function errorText(error53) {
|
|
@@ -22662,7 +22830,7 @@ function signalProcessTree(child, signal) {
|
|
|
22662
22830
|
try {
|
|
22663
22831
|
process.kill(-child.pid, signal);
|
|
22664
22832
|
} catch (error53) {
|
|
22665
|
-
if (!
|
|
22833
|
+
if (!isRecord13(error53) || error53.code !== "ESRCH")
|
|
22666
22834
|
throw error53;
|
|
22667
22835
|
}
|
|
22668
22836
|
}
|
|
@@ -22757,7 +22925,7 @@ async function readNativeSignals(options, sessionId) {
|
|
|
22757
22925
|
}
|
|
22758
22926
|
}
|
|
22759
22927
|
function isMissingFile(error53) {
|
|
22760
|
-
return
|
|
22928
|
+
return isRecord13(error53) && error53.code === "ENOENT";
|
|
22761
22929
|
}
|
|
22762
22930
|
async function locateGrokNativeSession(options, sessionId) {
|
|
22763
22931
|
if (sessionId.length === 0)
|
|
@@ -22780,7 +22948,7 @@ async function locateGrokNativeSession(options, sessionId) {
|
|
|
22780
22948
|
try {
|
|
22781
22949
|
summaryRaw = await readFile2(path9.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
|
|
22782
22950
|
} catch (error53) {
|
|
22783
|
-
if (isMissingFile(error53) ||
|
|
22951
|
+
if (isMissingFile(error53) || isRecord13(error53) && error53.code === "ENOTDIR")
|
|
22784
22952
|
continue;
|
|
22785
22953
|
throw new GrokTransportError("unavailable", "Grok Native Session metadata could not be read", {
|
|
22786
22954
|
cause: error53
|
|
@@ -22792,10 +22960,10 @@ async function locateGrokNativeSession(options, sessionId) {
|
|
|
22792
22960
|
} catch {
|
|
22793
22961
|
continue;
|
|
22794
22962
|
}
|
|
22795
|
-
if (!
|
|
22963
|
+
if (!isRecord13(parsed))
|
|
22796
22964
|
continue;
|
|
22797
22965
|
const info = parsed.info;
|
|
22798
|
-
const cwd =
|
|
22966
|
+
const cwd = isRecord13(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path9.resolve(info.cwd) : path9.resolve(decodeURIComponent(entry.name));
|
|
22799
22967
|
const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path9.resolve(parsed.source_workspace_dir) : void 0;
|
|
22800
22968
|
matches.push({
|
|
22801
22969
|
cwd,
|
|
@@ -22828,12 +22996,12 @@ function parseNativeHistory(contents, sessionId) {
|
|
|
22828
22996
|
} catch {
|
|
22829
22997
|
throw new GrokTransportError("protocolError", "Grok Native history contains invalid JSON");
|
|
22830
22998
|
}
|
|
22831
|
-
if (!
|
|
22999
|
+
if (!isRecord13(record2) || !isRecord13(record2.params))
|
|
22832
23000
|
continue;
|
|
22833
23001
|
const params = record2.params;
|
|
22834
|
-
if (params.sessionId !== sessionId || !
|
|
23002
|
+
if (params.sessionId !== sessionId || !isRecord13(params.update))
|
|
22835
23003
|
continue;
|
|
22836
|
-
const metadata =
|
|
23004
|
+
const metadata = isRecord13(params._meta) ? params._meta : void 0;
|
|
22837
23005
|
const event = transportEvent(params.update, metadata);
|
|
22838
23006
|
if (event)
|
|
22839
23007
|
events.push(metadata ? { ...event, metadata } : event);
|
|
@@ -22851,6 +23019,7 @@ var GrokAcpTransport = class {
|
|
|
22851
23019
|
#initialize = null;
|
|
22852
23020
|
#replay = null;
|
|
22853
23021
|
#sessionId = null;
|
|
23022
|
+
#availableCommands = null;
|
|
22854
23023
|
#startupModelId;
|
|
22855
23024
|
#stderrTail = "";
|
|
22856
23025
|
constructor(options) {
|
|
@@ -23139,7 +23308,7 @@ var GrokAcpTransport = class {
|
|
|
23139
23308
|
modelId,
|
|
23140
23309
|
...reasoningEffort ? { reasoningEffort } : {}
|
|
23141
23310
|
});
|
|
23142
|
-
if (!
|
|
23311
|
+
if (!isRecord13(response) || !isRecord13(response._meta) || !isRecord13(response._meta.model)) {
|
|
23143
23312
|
throw new GrokTransportError("protocolError", "Grok rejected Model configuration");
|
|
23144
23313
|
}
|
|
23145
23314
|
const selected = response._meta.model.Ok;
|
|
@@ -23179,10 +23348,19 @@ var GrokAcpTransport = class {
|
|
|
23179
23348
|
this.#activePrompt = null;
|
|
23180
23349
|
this.#activeCompact = null;
|
|
23181
23350
|
}
|
|
23351
|
+
/** Latest ACP `available_commands_update` of the open Session, if any. */
|
|
23352
|
+
get availableCommands() {
|
|
23353
|
+
return this.#availableCommands;
|
|
23354
|
+
}
|
|
23182
23355
|
#handleUpdate(notification) {
|
|
23183
23356
|
if (this.#sessionId && notification.sessionId !== this.#sessionId)
|
|
23184
23357
|
return;
|
|
23185
|
-
const
|
|
23358
|
+
const update = notification.update;
|
|
23359
|
+
if (update.sessionUpdate === "available_commands_update") {
|
|
23360
|
+
this.#availableCommands = parseGrokAvailableCommands(update.availableCommands);
|
|
23361
|
+
return;
|
|
23362
|
+
}
|
|
23363
|
+
const metadata = isRecord13(notification._meta) ? notification._meta : void 0;
|
|
23186
23364
|
const event = transportEvent(notification.update, metadata);
|
|
23187
23365
|
if (!event)
|
|
23188
23366
|
return;
|
|
@@ -23197,7 +23375,7 @@ var GrokAcpTransport = class {
|
|
|
23197
23375
|
#handleExtensionNotification(method, params) {
|
|
23198
23376
|
if (!isGrokExtensionSessionUpdateMethod(method))
|
|
23199
23377
|
return;
|
|
23200
|
-
if (typeof params.sessionId !== "string" || !
|
|
23378
|
+
if (typeof params.sessionId !== "string" || !isRecord13(params.update))
|
|
23201
23379
|
return;
|
|
23202
23380
|
this.#handleUpdate(params);
|
|
23203
23381
|
}
|
|
@@ -23417,7 +23595,7 @@ var GrokSubagentLifecycle = class {
|
|
|
23417
23595
|
};
|
|
23418
23596
|
|
|
23419
23597
|
// dist/grok-models.js
|
|
23420
|
-
function
|
|
23598
|
+
function isRecord14(value) {
|
|
23421
23599
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23422
23600
|
}
|
|
23423
23601
|
function nonBlank(value) {
|
|
@@ -23429,7 +23607,7 @@ function thinkingOptions(value) {
|
|
|
23429
23607
|
const seen = /* @__PURE__ */ new Set();
|
|
23430
23608
|
const options = [];
|
|
23431
23609
|
for (const candidate of value) {
|
|
23432
|
-
if (!
|
|
23610
|
+
if (!isRecord14(candidate) || !nonBlank(candidate.label))
|
|
23433
23611
|
continue;
|
|
23434
23612
|
const id = harnessThinkingOptionIdSchema.safeParse(candidate.id ?? candidate.value);
|
|
23435
23613
|
if (!id.success || seen.has(id.data))
|
|
@@ -23440,7 +23618,7 @@ function thinkingOptions(value) {
|
|
|
23440
23618
|
return options;
|
|
23441
23619
|
}
|
|
23442
23620
|
function parseGrokModelState(value) {
|
|
23443
|
-
if (!
|
|
23621
|
+
if (!isRecord14(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
|
|
23444
23622
|
return null;
|
|
23445
23623
|
}
|
|
23446
23624
|
const currentModel = harnessModelRefSchema.safeParse({ id: value.currentModelId });
|
|
@@ -23451,12 +23629,12 @@ function parseGrokModelState(value) {
|
|
|
23451
23629
|
const models = [];
|
|
23452
23630
|
let currentThinkingOptionId;
|
|
23453
23631
|
for (const candidate of value.availableModels) {
|
|
23454
|
-
if (!
|
|
23632
|
+
if (!isRecord14(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
|
|
23455
23633
|
continue;
|
|
23456
23634
|
const ref = harnessModelRefSchema.safeParse({ id: candidate.modelId });
|
|
23457
23635
|
if (!ref.success)
|
|
23458
23636
|
continue;
|
|
23459
|
-
const metadata =
|
|
23637
|
+
const metadata = isRecord14(candidate._meta) ? candidate._meta : {};
|
|
23460
23638
|
const options2 = thinkingOptions(metadata.reasoningEfforts);
|
|
23461
23639
|
if (typeof metadata.totalContextTokens === "number" && Number.isSafeInteger(metadata.totalContextTokens) && metadata.totalContextTokens > 0) {
|
|
23462
23640
|
contextWindowTokensByModel.set(ref.data.id, metadata.totalContextTokens);
|
|
@@ -23491,10 +23669,10 @@ function parseGrokModelState(value) {
|
|
|
23491
23669
|
};
|
|
23492
23670
|
}
|
|
23493
23671
|
function modelStateFromInitialize(response) {
|
|
23494
|
-
return parseGrokModelState(
|
|
23672
|
+
return parseGrokModelState(isRecord14(response._meta) ? response._meta.modelState : void 0);
|
|
23495
23673
|
}
|
|
23496
23674
|
function modelStateFromSessionResponse(response) {
|
|
23497
|
-
return parseGrokModelState(
|
|
23675
|
+
return parseGrokModelState(isRecord14(response) ? response.models : void 0);
|
|
23498
23676
|
}
|
|
23499
23677
|
function stateForGrokModel(modelState, nativeState, model = modelState.currentModel, thinkingOptionId = modelState.currentThinkingOptionId, permissionModeId) {
|
|
23500
23678
|
const selectedModel = model;
|
|
@@ -23518,7 +23696,7 @@ import os5 from "node:os";
|
|
|
23518
23696
|
import path10 from "node:path";
|
|
23519
23697
|
var GROK_CREDITS_ENDPOINT = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
|
|
23520
23698
|
var REQUEST_TIMEOUT_MS = 15e3;
|
|
23521
|
-
function
|
|
23699
|
+
function isRecord15(value) {
|
|
23522
23700
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23523
23701
|
}
|
|
23524
23702
|
function finitePercent(value) {
|
|
@@ -23527,7 +23705,7 @@ function finitePercent(value) {
|
|
|
23527
23705
|
return Math.min(100, Math.max(0, value));
|
|
23528
23706
|
}
|
|
23529
23707
|
function nonNegativeCentValue(value) {
|
|
23530
|
-
if (!
|
|
23708
|
+
if (!isRecord15(value))
|
|
23531
23709
|
return void 0;
|
|
23532
23710
|
const amount = value.val === void 0 ? 0 : value.val;
|
|
23533
23711
|
if (typeof amount !== "number" || !Number.isFinite(amount) || amount < 0)
|
|
@@ -23551,7 +23729,7 @@ function productUsageFrom(value) {
|
|
|
23551
23729
|
if (!Array.isArray(value))
|
|
23552
23730
|
return void 0;
|
|
23553
23731
|
const products = value.flatMap((entry) => {
|
|
23554
|
-
if (!
|
|
23732
|
+
if (!isRecord15(entry) || typeof entry.product !== "string")
|
|
23555
23733
|
return [];
|
|
23556
23734
|
const usagePercent = finitePercent(entry.usagePercent);
|
|
23557
23735
|
return usagePercent === void 0 ? [] : [{ product: entry.product, usagePercent }];
|
|
@@ -23559,10 +23737,10 @@ function productUsageFrom(value) {
|
|
|
23559
23737
|
return products.length > 0 ? products : void 0;
|
|
23560
23738
|
}
|
|
23561
23739
|
function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
23562
|
-
if (!
|
|
23740
|
+
if (!isRecord15(value) || !isRecord15(value.config))
|
|
23563
23741
|
return null;
|
|
23564
23742
|
const config2 = value.config;
|
|
23565
|
-
const period =
|
|
23743
|
+
const period = isRecord15(config2.currentPeriod) ? config2.currentPeriod : void 0;
|
|
23566
23744
|
const periodType = periodTypeFrom(period?.type);
|
|
23567
23745
|
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);
|
|
23568
23746
|
let usedPercent = finitePercent(config2.creditUsagePercent);
|
|
@@ -23589,11 +23767,11 @@ function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()
|
|
|
23589
23767
|
};
|
|
23590
23768
|
}
|
|
23591
23769
|
function selectAccessToken(auth, now) {
|
|
23592
|
-
if (!
|
|
23770
|
+
if (!isRecord15(auth))
|
|
23593
23771
|
return null;
|
|
23594
|
-
const entries = Object.entries(auth).filter(([issuer, value]) => (issuer === "https://auth.x.ai" || issuer.startsWith("https://auth.x.ai::")) &&
|
|
23772
|
+
const entries = Object.entries(auth).filter(([issuer, value]) => (issuer === "https://auth.x.ai" || issuer.startsWith("https://auth.x.ai::")) && isRecord15(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")));
|
|
23595
23773
|
for (const [, value] of entries) {
|
|
23596
|
-
if (!
|
|
23774
|
+
if (!isRecord15(value) || typeof value.key !== "string")
|
|
23597
23775
|
continue;
|
|
23598
23776
|
if (typeof value.expires_at === "string") {
|
|
23599
23777
|
const expiresAt = Date.parse(value.expires_at);
|
|
@@ -23665,7 +23843,7 @@ async function fetchGrokCredits(input = {}) {
|
|
|
23665
23843
|
|
|
23666
23844
|
// dist/grok-usage.js
|
|
23667
23845
|
var USD_TICKS_PER_DOLLAR = 1e10;
|
|
23668
|
-
function
|
|
23846
|
+
function isRecord16(value) {
|
|
23669
23847
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23670
23848
|
}
|
|
23671
23849
|
function optionalToken(value) {
|
|
@@ -23682,7 +23860,7 @@ function combineUsage(base, next) {
|
|
|
23682
23860
|
return base === null ? next : parseHostUsage({ ...base, ...next });
|
|
23683
23861
|
}
|
|
23684
23862
|
function usageFromNative(value) {
|
|
23685
|
-
if (!
|
|
23863
|
+
if (!isRecord16(value))
|
|
23686
23864
|
return null;
|
|
23687
23865
|
const nativeInputTokens = optionalToken(value.inputTokens);
|
|
23688
23866
|
const cachedRead = optionalToken(value.cachedReadTokens);
|
|
@@ -23711,7 +23889,7 @@ function usageFromPrompt(response) {
|
|
|
23711
23889
|
return response.usage ? usageFromNative(response.usage) : null;
|
|
23712
23890
|
}
|
|
23713
23891
|
function usageFromSignals(value) {
|
|
23714
|
-
if (!
|
|
23892
|
+
if (!isRecord16(value))
|
|
23715
23893
|
return null;
|
|
23716
23894
|
try {
|
|
23717
23895
|
return parseHostUsage({
|
|
@@ -23731,7 +23909,7 @@ var summedUsageFields = [
|
|
|
23731
23909
|
"totalTokens"
|
|
23732
23910
|
];
|
|
23733
23911
|
function nativeCostTicks(value) {
|
|
23734
|
-
if (!
|
|
23912
|
+
if (!isRecord16(value))
|
|
23735
23913
|
return void 0;
|
|
23736
23914
|
const ticks = value.costUsdTicks;
|
|
23737
23915
|
if (typeof ticks !== "number" || !Number.isSafeInteger(ticks) || ticks < 0)
|
|
@@ -23808,7 +23986,7 @@ function usageFromCompact(tokensAfter, contextWindowTokens) {
|
|
|
23808
23986
|
function usageFromUpdate(update, metadata, contextWindowTokens) {
|
|
23809
23987
|
try {
|
|
23810
23988
|
if (update?.sessionUpdate === "usage_update") {
|
|
23811
|
-
const cost =
|
|
23989
|
+
const cost = isRecord16(update.cost) ? update.cost : null;
|
|
23812
23990
|
return parseHostUsage({
|
|
23813
23991
|
contextUsedTokens: update.used,
|
|
23814
23992
|
contextWindowTokens: update.size,
|
|
@@ -23955,7 +24133,7 @@ var GrokHarnessSession = class {
|
|
|
23955
24133
|
this.#usage = this.initialUsage;
|
|
23956
24134
|
this.capabilities = capabilitiesForModels(modelState);
|
|
23957
24135
|
this.commands = {
|
|
23958
|
-
list: async () => ({ ok: true, value:
|
|
24136
|
+
list: async () => ({ ok: true, value: this.#liveCommandCatalog() }),
|
|
23959
24137
|
execute: (command) => this.#executeHarnessCommand(command)
|
|
23960
24138
|
};
|
|
23961
24139
|
this.#state = stateForGrokModel(modelState, { nativeRef: nativeRef(opened.sessionId) }, modelState.currentModel, modelState.currentThinkingOptionId, options.initialPermissionModeId);
|
|
@@ -24068,7 +24246,21 @@ var GrokHarnessSession = class {
|
|
|
24068
24246
|
}));
|
|
24069
24247
|
return { ok: true, value: { turnId: command.turnId } };
|
|
24070
24248
|
}
|
|
24249
|
+
/** Built-ins plus the commands, workflows and skills the open Session advertises. */
|
|
24250
|
+
#liveCommandCatalog() {
|
|
24251
|
+
const native = this.#transport.availableCommands ?? null;
|
|
24252
|
+
return mergeLiveHarnessCommands(grokCommandCatalog, GROK_LIVE_COMMAND_ID_PREFIX, native ? grokLiveCommands(native) : null);
|
|
24253
|
+
}
|
|
24071
24254
|
async #executeHarnessCommand(command) {
|
|
24255
|
+
const livePrompt = liveHarnessCommandPrompt(this.#liveCommandCatalog(), GROK_LIVE_COMMAND_ID_PREFIX, command.commandId, command.arguments?.text);
|
|
24256
|
+
if (livePrompt !== null) {
|
|
24257
|
+
const started = await this.execute({
|
|
24258
|
+
type: "turn.start",
|
|
24259
|
+
turnId: command.turnId,
|
|
24260
|
+
input: [{ type: "text", text: livePrompt }]
|
|
24261
|
+
});
|
|
24262
|
+
return started.ok ? { ok: true, value: { turnId: command.turnId } } : started;
|
|
24263
|
+
}
|
|
24072
24264
|
if (command.commandId !== "grok.compact") {
|
|
24073
24265
|
return {
|
|
24074
24266
|
ok: false,
|
|
@@ -24899,6 +25091,7 @@ var GrokAdapter = class {
|
|
|
24899
25091
|
read: () => this.#closePromise ? Promise.resolve([]) : readGrokCredentials(this.#environment ?? process.env)
|
|
24900
25092
|
};
|
|
24901
25093
|
commandCatalog = grokCommandCatalog;
|
|
25094
|
+
liveCommandCatalog = true;
|
|
24902
25095
|
harnessId = grokHarnessId;
|
|
24903
25096
|
subagents = {
|
|
24904
25097
|
readSnapshot: async (input) => {
|