@codexhost/cli-linux-arm64 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +1 -0
- package/app/console-web.js +1 -0
- package/app/desktop-controller.mjs +4 -1
- package/app/host-runtime.mjs +86 -21
- package/app/plugins/antigravity/plugin.mjs +1144 -1254
- package/app/plugins/claude-code/plugin.mjs +389 -84
- package/app/plugins/codebuddy/plugin.mjs +1 -0
- package/app/plugins/codex-usage/plugin.mjs +1 -0
- package/app/plugins/copilot/plugin.mjs +1 -0
- package/app/plugins/cursor-cli/plugin.mjs +1 -0
- package/app/plugins/deepseek-harness/plugin.mjs +1 -0
- package/app/plugins/devin/plugin.mjs +1 -0
- package/app/plugins/grok/plugin.mjs +192 -177
- package/app/plugins/hermes/plugin.mjs +1 -0
- package/app/plugins/kimi-code/plugin.mjs +1 -0
- package/app/plugins/kiro-cli/plugin.mjs +1 -0
- package/app/plugins/omp/plugin.mjs +108 -22
- package/app/plugins/opencode/plugin.mjs +1 -0
- package/app/plugins/pi/plugin.mjs +119 -23
- package/app/plugins/qoder/plugin.mjs +1 -0
- package/app/plugins/qoder-cn/plugin.mjs +1 -0
- package/app/plugins/qwen-code/plugin.mjs +1 -0
- package/app/plugins/workbuddy/plugin.mjs +1 -0
- package/app/plugins/zcode/plugin.mjs +1 -0
- package/app/renderer-extension.js +1 -0
- package/app/web/assets/index-CN4a4sj0.js +201 -0
- package/app/web/codexhost-settings.js +1 -0
- package/app/web/index.html +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +6 -6
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +69 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +1 -1
- package/app/web-modules/server.mjs +130 -74
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-BdmZfTRW.js +0 -201
|
@@ -16867,6 +16867,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
16867
16867
|
message: "A history continuation requires its connection epoch"
|
|
16868
16868
|
}).optional()
|
|
16869
16869
|
}),
|
|
16870
|
+
external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
|
|
16870
16871
|
external_exports.strictObject({
|
|
16871
16872
|
kind: external_exports.literal("configure"),
|
|
16872
16873
|
...thread,
|
|
@@ -22220,6 +22221,107 @@ function grokLiveCommands(native) {
|
|
|
22220
22221
|
}));
|
|
22221
22222
|
}
|
|
22222
22223
|
|
|
22224
|
+
// dist/grok-models.js
|
|
22225
|
+
function isRecord5(value) {
|
|
22226
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22227
|
+
}
|
|
22228
|
+
function nonBlank(value) {
|
|
22229
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
22230
|
+
}
|
|
22231
|
+
function thinkingOptions(value) {
|
|
22232
|
+
if (!Array.isArray(value))
|
|
22233
|
+
return [];
|
|
22234
|
+
const seen = /* @__PURE__ */ new Set();
|
|
22235
|
+
const options = [];
|
|
22236
|
+
for (const candidate of value) {
|
|
22237
|
+
if (!isRecord5(candidate) || !nonBlank(candidate.label))
|
|
22238
|
+
continue;
|
|
22239
|
+
const id = harnessThinkingOptionIdSchema.safeParse(candidate.id ?? candidate.value);
|
|
22240
|
+
if (!id.success || seen.has(id.data))
|
|
22241
|
+
continue;
|
|
22242
|
+
seen.add(id.data);
|
|
22243
|
+
options.push({ id: id.data, label: candidate.label });
|
|
22244
|
+
}
|
|
22245
|
+
return options;
|
|
22246
|
+
}
|
|
22247
|
+
function parseGrokModelState(value) {
|
|
22248
|
+
if (!isRecord5(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
|
|
22249
|
+
return null;
|
|
22250
|
+
}
|
|
22251
|
+
const currentModel = harnessModelRefSchema.safeParse({ id: value.currentModelId });
|
|
22252
|
+
if (!currentModel.success)
|
|
22253
|
+
return null;
|
|
22254
|
+
const allThinking = /* @__PURE__ */ new Map();
|
|
22255
|
+
const contextWindowTokensByModel = /* @__PURE__ */ new Map();
|
|
22256
|
+
const defaultContextWindowTokensByModel = /* @__PURE__ */ new Map();
|
|
22257
|
+
const models = [];
|
|
22258
|
+
let currentThinkingOptionId;
|
|
22259
|
+
for (const candidate of value.availableModels) {
|
|
22260
|
+
if (!isRecord5(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
|
|
22261
|
+
continue;
|
|
22262
|
+
const ref = harnessModelRefSchema.safeParse({ id: candidate.modelId });
|
|
22263
|
+
if (!ref.success)
|
|
22264
|
+
continue;
|
|
22265
|
+
const metadata = isRecord5(candidate._meta) ? candidate._meta : {};
|
|
22266
|
+
const options2 = thinkingOptions(metadata.reasoningEfforts);
|
|
22267
|
+
if (Array.isArray(metadata.contextWindows) && metadata.contextWindows.includes(5e5)) {
|
|
22268
|
+
defaultContextWindowTokensByModel.set(ref.data.id, 5e5);
|
|
22269
|
+
}
|
|
22270
|
+
if (typeof metadata.totalContextTokens === "number" && Number.isSafeInteger(metadata.totalContextTokens) && metadata.totalContextTokens > 0) {
|
|
22271
|
+
contextWindowTokensByModel.set(ref.data.id, metadata.totalContextTokens);
|
|
22272
|
+
}
|
|
22273
|
+
for (const option of options2)
|
|
22274
|
+
allThinking.set(option.id, option);
|
|
22275
|
+
if (candidate.modelId === value.currentModelId && nonBlank(metadata.reasoningEffort)) {
|
|
22276
|
+
const parsed = harnessThinkingOptionIdSchema.safeParse(metadata.reasoningEffort);
|
|
22277
|
+
if (parsed.success && options2.some(({ id }) => id === parsed.data)) {
|
|
22278
|
+
currentThinkingOptionId = parsed.data;
|
|
22279
|
+
}
|
|
22280
|
+
}
|
|
22281
|
+
models.push({
|
|
22282
|
+
ref: ref.data,
|
|
22283
|
+
label: candidate.name,
|
|
22284
|
+
...options2.length > 0 ? { supportedThinkingOptionIds: options2.map(({ id }) => id) } : {}
|
|
22285
|
+
});
|
|
22286
|
+
}
|
|
22287
|
+
if (!models.some(({ ref }) => ref.id === currentModel.data.id))
|
|
22288
|
+
return null;
|
|
22289
|
+
const options = [...allThinking.values()];
|
|
22290
|
+
return {
|
|
22291
|
+
currentModel: currentModel.data,
|
|
22292
|
+
contextWindowTokensByModel,
|
|
22293
|
+
defaultContextWindowTokensByModel,
|
|
22294
|
+
...currentThinkingOptionId ? { currentThinkingOptionId } : {},
|
|
22295
|
+
catalog: {
|
|
22296
|
+
models,
|
|
22297
|
+
defaultModel: currentModel.data,
|
|
22298
|
+
thinkingOptions: options,
|
|
22299
|
+
...currentThinkingOptionId ? { defaultThinkingOptionId: currentThinkingOptionId } : {}
|
|
22300
|
+
}
|
|
22301
|
+
};
|
|
22302
|
+
}
|
|
22303
|
+
function modelStateFromInitialize(response) {
|
|
22304
|
+
return parseGrokModelState(isRecord5(response._meta) ? response._meta.modelState : void 0);
|
|
22305
|
+
}
|
|
22306
|
+
function modelStateFromSessionResponse(response) {
|
|
22307
|
+
return parseGrokModelState(isRecord5(response) ? response.models : void 0);
|
|
22308
|
+
}
|
|
22309
|
+
function stateForGrokModel(modelState, nativeState, model2 = modelState.currentModel, thinkingOptionId = modelState.currentThinkingOptionId, permissionModeId) {
|
|
22310
|
+
const selectedModel = model2;
|
|
22311
|
+
const catalogModel = modelState.catalog.models.find(({ ref }) => ref.id === selectedModel.id);
|
|
22312
|
+
const availableThinkingOptions = catalogModel?.supportedThinkingOptionIds?.flatMap((id) => {
|
|
22313
|
+
const option = modelState.catalog.thinkingOptions.find((candidate) => candidate.id === id);
|
|
22314
|
+
return option ? [option] : [];
|
|
22315
|
+
});
|
|
22316
|
+
return {
|
|
22317
|
+
...nativeState,
|
|
22318
|
+
effectiveModel: selectedModel,
|
|
22319
|
+
...thinkingOptionId ? { effectiveThinkingOptionId: thinkingOptionId } : {},
|
|
22320
|
+
...permissionModeId ? { effectivePermissionModeId: permissionModeId } : {},
|
|
22321
|
+
...availableThinkingOptions ? { availableThinkingOptions } : {}
|
|
22322
|
+
};
|
|
22323
|
+
}
|
|
22324
|
+
|
|
22223
22325
|
// dist/command.js
|
|
22224
22326
|
import path8 from "node:path";
|
|
22225
22327
|
var GrokExecutableError = class extends Error {
|
|
@@ -22687,7 +22789,7 @@ function splitLines(text) {
|
|
|
22687
22789
|
// dist/grok-file-change.js
|
|
22688
22790
|
var DEFAULT_GROK_FILE_CHANGE_TEXT_LIMIT = 4 * 1024 * 1024;
|
|
22689
22791
|
var MAX_GROK_FILE_CHANGES_PER_TOOL = 32;
|
|
22690
|
-
function
|
|
22792
|
+
function isRecord6(value) {
|
|
22691
22793
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22692
22794
|
}
|
|
22693
22795
|
function validAbsolutePath(value) {
|
|
@@ -22738,7 +22840,7 @@ function projectGrokFileChanges(content, cwd, textLimit = DEFAULT_GROK_FILE_CHAN
|
|
|
22738
22840
|
return null;
|
|
22739
22841
|
const candidates = [];
|
|
22740
22842
|
for (const entry of content) {
|
|
22741
|
-
if (
|
|
22843
|
+
if (isRecord6(entry) && entry.type === "diff")
|
|
22742
22844
|
candidates.push(entry);
|
|
22743
22845
|
}
|
|
22744
22846
|
if (candidates.length === 0 || candidates.length > MAX_GROK_FILE_CHANGES_PER_TOOL)
|
|
@@ -22775,14 +22877,14 @@ function grokMediaResolveRoots(cwd, sessionDirectory) {
|
|
|
22775
22877
|
// dist/grok-tool-output.js
|
|
22776
22878
|
var DEFAULT_GROK_TOOL_OUTPUT_LIMIT = 64e3;
|
|
22777
22879
|
var EXECUTE_TOOL_NAMES = /* @__PURE__ */ new Set(["bash", "run_terminal_command", "shell", "cursor_shell"]);
|
|
22778
|
-
function
|
|
22880
|
+
function isRecord7(value) {
|
|
22779
22881
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22780
22882
|
}
|
|
22781
22883
|
function stringField(value, key) {
|
|
22782
|
-
return
|
|
22884
|
+
return isRecord7(value) && typeof value[key] === "string" && value[key].length > 0 ? value[key] : void 0;
|
|
22783
22885
|
}
|
|
22784
22886
|
function numberField(value, key) {
|
|
22785
|
-
if (!
|
|
22887
|
+
if (!isRecord7(value))
|
|
22786
22888
|
return void 0;
|
|
22787
22889
|
const field2 = value[key];
|
|
22788
22890
|
if (field2 === null)
|
|
@@ -22805,7 +22907,7 @@ function firstReadableText(...candidates) {
|
|
|
22805
22907
|
for (const candidate of candidates) {
|
|
22806
22908
|
if (typeof candidate === "string" && candidate.length > 0)
|
|
22807
22909
|
return candidate;
|
|
22808
|
-
if (
|
|
22910
|
+
if (isRecord7(candidate)) {
|
|
22809
22911
|
const nested = stringField(candidate, "content") ?? stringField(candidate, "text") ?? stringField(candidate, "tool_result") ?? stringField(candidate, "raw_output");
|
|
22810
22912
|
if (nested)
|
|
22811
22913
|
return nested;
|
|
@@ -22828,7 +22930,7 @@ function grokToolArguments(rawInput) {
|
|
|
22828
22930
|
if (!parsed.success)
|
|
22829
22931
|
return {};
|
|
22830
22932
|
const argumentsValue = parsed.data;
|
|
22831
|
-
if (!
|
|
22933
|
+
if (!isRecord7(argumentsValue) || stringField(argumentsValue, "path"))
|
|
22832
22934
|
return argumentsValue;
|
|
22833
22935
|
const targetFile = stringField(argumentsValue, "target_file");
|
|
22834
22936
|
return targetFile ? { ...argumentsValue, path: targetFile } : argumentsValue;
|
|
@@ -22841,7 +22943,7 @@ function grokCommand(name, kind, rawInput) {
|
|
|
22841
22943
|
return command;
|
|
22842
22944
|
if (name && EXECUTE_TOOL_NAMES.has(name))
|
|
22843
22945
|
return command;
|
|
22844
|
-
return
|
|
22946
|
+
return isRecord7(rawInput) && rawInput.variant === "Bash" ? command : void 0;
|
|
22845
22947
|
}
|
|
22846
22948
|
function grokCommandCwd(rawInput, fallback) {
|
|
22847
22949
|
return stringField(rawInput, "cwd") ?? fallback;
|
|
@@ -22868,11 +22970,11 @@ function acpContentText(content) {
|
|
|
22868
22970
|
if (!Array.isArray(content))
|
|
22869
22971
|
return "";
|
|
22870
22972
|
return content.flatMap((entry) => {
|
|
22871
|
-
if (!
|
|
22973
|
+
if (!isRecord7(entry))
|
|
22872
22974
|
return [];
|
|
22873
22975
|
if (entry.type === "text" && typeof entry.text === "string")
|
|
22874
22976
|
return [entry.text];
|
|
22875
|
-
if (entry.type !== "content" || !
|
|
22977
|
+
if (entry.type !== "content" || !isRecord7(entry.content))
|
|
22876
22978
|
return [];
|
|
22877
22979
|
return entry.content.type === "text" && typeof entry.content.text === "string" ? [entry.content.text] : [];
|
|
22878
22980
|
}).join("\n");
|
|
@@ -22883,10 +22985,10 @@ function acpContentImages(content, remainingBytes) {
|
|
|
22883
22985
|
const images = [];
|
|
22884
22986
|
let remaining = remainingBytes;
|
|
22885
22987
|
for (const entry of content) {
|
|
22886
|
-
if (!
|
|
22988
|
+
if (!isRecord7(entry))
|
|
22887
22989
|
continue;
|
|
22888
22990
|
const image = entry.type === "image" ? entry : entry.type === "content" ? entry.content : null;
|
|
22889
|
-
if (!
|
|
22991
|
+
if (!isRecord7(image) || image.type !== "image")
|
|
22890
22992
|
continue;
|
|
22891
22993
|
const mimeType = stringField(image, "mimeType") ?? stringField(image, "mime_type");
|
|
22892
22994
|
const data = stringField(image, "data");
|
|
@@ -22909,14 +23011,14 @@ function bashOutput(rawOutput) {
|
|
|
22909
23011
|
function rawOutputProjection(rawOutput) {
|
|
22910
23012
|
if (typeof rawOutput === "string")
|
|
22911
23013
|
return rawOutput.length > 0 ? { text: rawOutput } : {};
|
|
22912
|
-
if (!
|
|
23014
|
+
if (!isRecord7(rawOutput))
|
|
22913
23015
|
return {};
|
|
22914
23016
|
if (rawOutput.type === "Bash" || rawOutput.variant === "Bash" || numberField(rawOutput, "exit_code") !== void 0 || numberField(rawOutput, "exitCode") !== void 0) {
|
|
22915
23017
|
const bash = bashOutput(rawOutput);
|
|
22916
23018
|
if (bash.text !== void 0 || bash.exitCode !== void 0)
|
|
22917
23019
|
return bash;
|
|
22918
23020
|
}
|
|
22919
|
-
const text = firstReadableText(rawOutput.content, rawOutput.text, rawOutput.tool_result, rawOutput.raw_output,
|
|
23021
|
+
const text = firstReadableText(rawOutput.content, rawOutput.text, rawOutput.tool_result, rawOutput.raw_output, isRecord7(rawOutput.FileContent) ? rawOutput.FileContent : void 0, isRecord7(rawOutput.Content) ? rawOutput.Content : void 0);
|
|
22920
23022
|
if (text)
|
|
22921
23023
|
return { text };
|
|
22922
23024
|
if (typeof rawOutput.match_count === "number" && Number.isFinite(rawOutput.match_count)) {
|
|
@@ -22980,11 +23082,11 @@ var WAIT_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
|
22980
23082
|
var KILL_TOOL_NAMES = /* @__PURE__ */ new Set(["kill_command_or_subagent", "kill_task"]);
|
|
22981
23083
|
var DESCRIPTION_LIMIT = 500;
|
|
22982
23084
|
var SUMMARY_LIMIT = 2e3;
|
|
22983
|
-
function
|
|
23085
|
+
function isRecord8(value) {
|
|
22984
23086
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22985
23087
|
}
|
|
22986
23088
|
function idField(value, key) {
|
|
22987
|
-
if (!
|
|
23089
|
+
if (!isRecord8(value))
|
|
22988
23090
|
return void 0;
|
|
22989
23091
|
const field2 = value[key];
|
|
22990
23092
|
if (typeof field2 === "string") {
|
|
@@ -22996,7 +23098,7 @@ function idField(value, key) {
|
|
|
22996
23098
|
return void 0;
|
|
22997
23099
|
}
|
|
22998
23100
|
function stringField2(value, key) {
|
|
22999
|
-
if (!
|
|
23101
|
+
if (!isRecord8(value) || typeof value[key] !== "string")
|
|
23000
23102
|
return void 0;
|
|
23001
23103
|
const trimmed = value[key].trim();
|
|
23002
23104
|
return trimmed.length > 0 ? trimmed : void 0;
|
|
@@ -23019,7 +23121,7 @@ function collectIds(value) {
|
|
|
23019
23121
|
};
|
|
23020
23122
|
push(idField(value, "task_id"));
|
|
23021
23123
|
push(idField(value, "subagent_id"));
|
|
23022
|
-
if (
|
|
23124
|
+
if (isRecord8(value)) {
|
|
23023
23125
|
const list = value.task_ids ?? value.subagent_ids;
|
|
23024
23126
|
if (Array.isArray(list)) {
|
|
23025
23127
|
for (const entry of list)
|
|
@@ -23038,7 +23140,7 @@ function grokSubagentOperation(name, title, rawInput) {
|
|
|
23038
23140
|
return "send";
|
|
23039
23141
|
if (SPAWN_TOOL_NAMES.has(id))
|
|
23040
23142
|
return "spawn";
|
|
23041
|
-
if (
|
|
23143
|
+
if (isRecord8(rawInput) && rawInput.variant === "Task")
|
|
23042
23144
|
return "spawn";
|
|
23043
23145
|
return null;
|
|
23044
23146
|
}
|
|
@@ -23061,7 +23163,7 @@ function grokSubagentRole(rawInput) {
|
|
|
23061
23163
|
return bounded(stringField2(rawInput, "subagent_type") ?? stringField2(rawInput, "agent_type") ?? stringField2(rawInput, "type"), DESCRIPTION_LIMIT);
|
|
23062
23164
|
}
|
|
23063
23165
|
function grokSubagentBackground(rawInput) {
|
|
23064
|
-
if (!
|
|
23166
|
+
if (!isRecord8(rawInput))
|
|
23065
23167
|
return true;
|
|
23066
23168
|
if (rawInput.background === false || rawInput.run_in_background === false)
|
|
23067
23169
|
return false;
|
|
@@ -23099,7 +23201,7 @@ function grokSubagentResultSummary(...candidates) {
|
|
|
23099
23201
|
return void 0;
|
|
23100
23202
|
}
|
|
23101
23203
|
function grokSubagentEventFromUpdate(update) {
|
|
23102
|
-
if (!
|
|
23204
|
+
if (!isRecord8(update) || typeof update.sessionUpdate !== "string")
|
|
23103
23205
|
return null;
|
|
23104
23206
|
const nativeSubagentId = idField(update, "subagent_id") ?? idField(update, "child_session_id");
|
|
23105
23207
|
if (!nativeSubagentId)
|
|
@@ -23160,14 +23262,14 @@ function grokSubagentWaitSettlements(input) {
|
|
|
23160
23262
|
return ids.map((id) => ({ id, status: overall }));
|
|
23161
23263
|
}
|
|
23162
23264
|
function taskOutputResults(rawOutput) {
|
|
23163
|
-
if (!
|
|
23265
|
+
if (!isRecord8(rawOutput))
|
|
23164
23266
|
return [];
|
|
23165
23267
|
if (Array.isArray(rawOutput.results)) {
|
|
23166
|
-
return rawOutput.results.filter(
|
|
23268
|
+
return rawOutput.results.filter(isRecord8);
|
|
23167
23269
|
}
|
|
23168
23270
|
const nested = firstRecord(rawOutput.MultiResult, rawOutput.multiResult, rawOutput.multi_result);
|
|
23169
23271
|
if (nested && Array.isArray(nested.results)) {
|
|
23170
|
-
return nested.results.filter(
|
|
23272
|
+
return nested.results.filter(isRecord8);
|
|
23171
23273
|
}
|
|
23172
23274
|
const single = firstRecord(rawOutput.Result, rawOutput.result);
|
|
23173
23275
|
if (single)
|
|
@@ -23178,7 +23280,7 @@ function taskOutputResults(rawOutput) {
|
|
|
23178
23280
|
}
|
|
23179
23281
|
function firstRecord(...values) {
|
|
23180
23282
|
for (const value of values) {
|
|
23181
|
-
if (
|
|
23283
|
+
if (isRecord8(value))
|
|
23182
23284
|
return value;
|
|
23183
23285
|
}
|
|
23184
23286
|
return void 0;
|
|
@@ -23201,7 +23303,7 @@ function taskOutputTextSettlements(rawOutput, content, ids) {
|
|
|
23201
23303
|
return settled;
|
|
23202
23304
|
}
|
|
23203
23305
|
function taskOutputStatus(rawOutput, content) {
|
|
23204
|
-
if (
|
|
23306
|
+
if (isRecord8(rawOutput) && typeof rawOutput.status === "string")
|
|
23205
23307
|
return rawOutput.status;
|
|
23206
23308
|
const text = extractText(content) ?? extractText(rawOutput);
|
|
23207
23309
|
if (!text)
|
|
@@ -23260,7 +23362,7 @@ function extractText(value, depth = 0) {
|
|
|
23260
23362
|
const joined = parts.join("\n").trim();
|
|
23261
23363
|
return joined.length > 0 ? joined : void 0;
|
|
23262
23364
|
}
|
|
23263
|
-
if (!
|
|
23365
|
+
if (!isRecord8(value))
|
|
23264
23366
|
return void 0;
|
|
23265
23367
|
if (typeof value.text === "string" && value.text.trim().length > 0)
|
|
23266
23368
|
return value.text.trim();
|
|
@@ -23731,11 +23833,11 @@ var GROK_SESSION_DELETE_METHOD = "_x.ai/session/delete";
|
|
|
23731
23833
|
function error51(code, message, retryable = false) {
|
|
23732
23834
|
return { code, message, retryable };
|
|
23733
23835
|
}
|
|
23734
|
-
function
|
|
23836
|
+
function isRecord9(value) {
|
|
23735
23837
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23736
23838
|
}
|
|
23737
23839
|
function isGrokMethodNotFound(error53) {
|
|
23738
|
-
if (
|
|
23840
|
+
if (isRecord9(error53) && error53.code === -32601)
|
|
23739
23841
|
return true;
|
|
23740
23842
|
const message = error53 instanceof Error ? error53.message : String(error53);
|
|
23741
23843
|
return /method not found/iu.test(message);
|
|
@@ -23753,10 +23855,10 @@ function buildGrokForkParams(input) {
|
|
|
23753
23855
|
};
|
|
23754
23856
|
}
|
|
23755
23857
|
function parseGrokForkResponse(value) {
|
|
23756
|
-
if (!
|
|
23858
|
+
if (!isRecord9(value) || value.error !== void 0)
|
|
23757
23859
|
return null;
|
|
23758
|
-
const payload = typeof value.newSessionId !== "string" &&
|
|
23759
|
-
if (!
|
|
23860
|
+
const payload = typeof value.newSessionId !== "string" && isRecord9(value.result) ? value.result : value;
|
|
23861
|
+
if (!isRecord9(payload) || payload.error !== void 0)
|
|
23760
23862
|
return null;
|
|
23761
23863
|
if (typeof payload.newSessionId !== "string" || payload.newSessionId.length === 0)
|
|
23762
23864
|
return null;
|
|
@@ -23920,7 +24022,7 @@ var GROK_SESSION_UPDATE_EXTENSION_METHODS = [
|
|
|
23920
24022
|
"x.ai/session_notification",
|
|
23921
24023
|
"_x.ai/session_notification"
|
|
23922
24024
|
];
|
|
23923
|
-
function
|
|
24025
|
+
function isRecord10(value) {
|
|
23924
24026
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23925
24027
|
}
|
|
23926
24028
|
function optionalNonNegativeInt(value) {
|
|
@@ -23941,7 +24043,7 @@ function isGrokExtensionSessionUpdateMethod(method) {
|
|
|
23941
24043
|
return GROK_SESSION_UPDATE_EXTENSION_METHODS.includes(method);
|
|
23942
24044
|
}
|
|
23943
24045
|
function grokCompactionEventFromUpdate(update) {
|
|
23944
|
-
if (!
|
|
24046
|
+
if (!isRecord10(update) || typeof update.sessionUpdate !== "string")
|
|
23945
24047
|
return null;
|
|
23946
24048
|
const tokensUsed = optionalNonNegativeInt(firstPresent(update, ["tokensUsed", "tokens_used"]));
|
|
23947
24049
|
const contextWindowTokens = optionalNonNegativeInt(firstPresent(update, ["contextWindowTokens", "contextWindow", "context_window"]));
|
|
@@ -23980,7 +24082,7 @@ function grokCompactionEventFromUpdate(update) {
|
|
|
23980
24082
|
// dist/grok-manual-compaction.js
|
|
23981
24083
|
var GROK_COMPACT_CONVERSATION_METHOD = "x.ai/compact_conversation";
|
|
23982
24084
|
var GROK_COMPACT_CONVERSATION_FALLBACK_METHOD = "_x.ai/compact_conversation";
|
|
23983
|
-
function
|
|
24085
|
+
function isRecord11(value) {
|
|
23984
24086
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23985
24087
|
}
|
|
23986
24088
|
function optionalNonNegativeInt2(value) {
|
|
@@ -23992,7 +24094,7 @@ function optionalErrorMessage2(value) {
|
|
|
23992
24094
|
function parseGrokCompactResult(value, cancelled = false) {
|
|
23993
24095
|
if (cancelled)
|
|
23994
24096
|
return { outcome: "cancelled" };
|
|
23995
|
-
if (!
|
|
24097
|
+
if (!isRecord11(value))
|
|
23996
24098
|
return { outcome: "succeeded" };
|
|
23997
24099
|
const tokensBefore = optionalNonNegativeInt2(value.tokensBefore ?? value.tokens_before);
|
|
23998
24100
|
const tokensAfter = optionalNonNegativeInt2(value.tokensAfter ?? value.tokens_after);
|
|
@@ -24030,7 +24132,7 @@ var GROK_REWIND_EXECUTE_METHOD = "_x.ai/rewind/execute";
|
|
|
24030
24132
|
function error52(code, message, retryable = false) {
|
|
24031
24133
|
return { code, message, retryable };
|
|
24032
24134
|
}
|
|
24033
|
-
function
|
|
24135
|
+
function isRecord12(value) {
|
|
24034
24136
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24035
24137
|
}
|
|
24036
24138
|
function buildGrokRewindParams(input) {
|
|
@@ -24042,10 +24144,10 @@ function buildGrokRewindParams(input) {
|
|
|
24042
24144
|
};
|
|
24043
24145
|
}
|
|
24044
24146
|
function parseGrokRewindResponse(value) {
|
|
24045
|
-
if (!
|
|
24147
|
+
if (!isRecord12(value))
|
|
24046
24148
|
return null;
|
|
24047
|
-
const payload = typeof value.success !== "boolean" &&
|
|
24048
|
-
if (!
|
|
24149
|
+
const payload = typeof value.success !== "boolean" && isRecord12(value.result) ? value.result : value;
|
|
24150
|
+
if (!isRecord12(payload) || typeof payload.success !== "boolean")
|
|
24049
24151
|
return null;
|
|
24050
24152
|
return rewindPayload(payload);
|
|
24051
24153
|
}
|
|
@@ -24247,25 +24349,25 @@ var GrokPermissionConfirmation = class {
|
|
|
24247
24349
|
|
|
24248
24350
|
// dist/grok-questions.js
|
|
24249
24351
|
var GROK_ASK_USER_QUESTION_METHOD = "_x.ai/ask_user_question";
|
|
24250
|
-
function
|
|
24352
|
+
function isRecord13(value) {
|
|
24251
24353
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24252
24354
|
}
|
|
24253
24355
|
function nonEmptyString(value) {
|
|
24254
24356
|
return typeof value === "string" && value.trim().length > 0;
|
|
24255
24357
|
}
|
|
24256
24358
|
function parseGrokQuestionRequest(value) {
|
|
24257
|
-
if (!
|
|
24359
|
+
if (!isRecord13(value) || !nonEmptyString(value.sessionId) || !nonEmptyString(value.toolCallId) || value.mode !== "default" && value.mode !== "plan" || !Array.isArray(value.questions) || value.questions.length === 0)
|
|
24258
24360
|
throw new Error("Grok question requires sessionId, toolCallId, mode and nonempty questions");
|
|
24259
24361
|
const seen = /* @__PURE__ */ new Set();
|
|
24260
24362
|
const questions = value.questions.map((question) => {
|
|
24261
|
-
if (!
|
|
24363
|
+
if (!isRecord13(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")
|
|
24262
24364
|
throw new Error("Grok question text must be unique and options/multiSelect must be valid");
|
|
24263
24365
|
if (question.multiSelect != null && question.multi_select != null && question.multiSelect !== question.multi_select)
|
|
24264
24366
|
throw new Error("Grok question contains conflicting multi-select flags");
|
|
24265
24367
|
seen.add(question.question);
|
|
24266
24368
|
const labels = /* @__PURE__ */ new Set();
|
|
24267
24369
|
const options = question.options.map((option) => {
|
|
24268
|
-
if (!
|
|
24370
|
+
if (!isRecord13(option) || !nonEmptyString(option.label) || labels.has(option.label) || typeof option.description !== "string" || option.preview != null && typeof option.preview !== "string")
|
|
24269
24371
|
throw new Error("Grok question options require unique labels and text descriptions/previews");
|
|
24270
24372
|
labels.add(option.label);
|
|
24271
24373
|
return {
|
|
@@ -24413,16 +24515,16 @@ var GrokTransportError = class extends Error {
|
|
|
24413
24515
|
this.name = "GrokTransportError";
|
|
24414
24516
|
}
|
|
24415
24517
|
};
|
|
24416
|
-
function
|
|
24518
|
+
function isRecord14(value) {
|
|
24417
24519
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24418
24520
|
}
|
|
24419
24521
|
function acpToolName(update, metadata) {
|
|
24420
|
-
if (!
|
|
24522
|
+
if (!isRecord14(update))
|
|
24421
24523
|
return void 0;
|
|
24422
24524
|
if (typeof update.name === "string" && update.name.length > 0)
|
|
24423
24525
|
return update.name;
|
|
24424
|
-
const meta3 =
|
|
24425
|
-
const tool = meta3 &&
|
|
24526
|
+
const meta3 = isRecord14(update._meta) ? update._meta : metadata;
|
|
24527
|
+
const tool = meta3 && isRecord14(meta3["x.ai/tool"]) ? meta3["x.ai/tool"] : void 0;
|
|
24426
24528
|
return tool && typeof tool.name === "string" && tool.name.length > 0 ? tool.name : void 0;
|
|
24427
24529
|
}
|
|
24428
24530
|
function errorText(error53) {
|
|
@@ -24478,12 +24580,12 @@ function signalProcessTree(child, signal) {
|
|
|
24478
24580
|
try {
|
|
24479
24581
|
process.kill(-child.pid, signal);
|
|
24480
24582
|
} catch (error53) {
|
|
24481
|
-
if (!
|
|
24583
|
+
if (!isRecord14(error53) || error53.code === "ESRCH")
|
|
24482
24584
|
return;
|
|
24483
24585
|
try {
|
|
24484
24586
|
child.kill(signal);
|
|
24485
24587
|
} catch (fallback) {
|
|
24486
|
-
if (!
|
|
24588
|
+
if (!isRecord14(fallback) || fallback.code !== "ESRCH")
|
|
24487
24589
|
throw fallback;
|
|
24488
24590
|
}
|
|
24489
24591
|
}
|
|
@@ -24598,7 +24700,7 @@ async function readNativeSignals(options, sessionId) {
|
|
|
24598
24700
|
}
|
|
24599
24701
|
}
|
|
24600
24702
|
function isMissingFile(error53) {
|
|
24601
|
-
return
|
|
24703
|
+
return isRecord14(error53) && error53.code === "ENOENT";
|
|
24602
24704
|
}
|
|
24603
24705
|
async function locateGrokNativeSession(options, sessionId) {
|
|
24604
24706
|
if (sessionId.length === 0)
|
|
@@ -24621,7 +24723,7 @@ async function locateGrokNativeSession(options, sessionId) {
|
|
|
24621
24723
|
try {
|
|
24622
24724
|
summaryRaw = await readFile3(path13.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
|
|
24623
24725
|
} catch (error53) {
|
|
24624
|
-
if (isMissingFile(error53) ||
|
|
24726
|
+
if (isMissingFile(error53) || isRecord14(error53) && error53.code === "ENOTDIR")
|
|
24625
24727
|
continue;
|
|
24626
24728
|
throw new GrokTransportError("unavailable", "Grok Native Session metadata could not be read", {
|
|
24627
24729
|
cause: error53
|
|
@@ -24633,10 +24735,10 @@ async function locateGrokNativeSession(options, sessionId) {
|
|
|
24633
24735
|
} catch {
|
|
24634
24736
|
continue;
|
|
24635
24737
|
}
|
|
24636
|
-
if (!
|
|
24738
|
+
if (!isRecord14(parsed))
|
|
24637
24739
|
continue;
|
|
24638
24740
|
const info = parsed.info;
|
|
24639
|
-
const cwd =
|
|
24741
|
+
const cwd = isRecord14(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path13.resolve(info.cwd) : path13.resolve(decodeURIComponent(entry.name));
|
|
24640
24742
|
const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path13.resolve(parsed.source_workspace_dir) : void 0;
|
|
24641
24743
|
matches.push({
|
|
24642
24744
|
cwd,
|
|
@@ -24669,12 +24771,12 @@ function parseNativeHistory(contents, sessionId) {
|
|
|
24669
24771
|
} catch {
|
|
24670
24772
|
throw new GrokTransportError("protocolError", "Grok Native history contains invalid JSON");
|
|
24671
24773
|
}
|
|
24672
|
-
if (!
|
|
24774
|
+
if (!isRecord14(record3) || !isRecord14(record3.params))
|
|
24673
24775
|
continue;
|
|
24674
24776
|
const params = record3.params;
|
|
24675
|
-
if (params.sessionId !== sessionId || !
|
|
24777
|
+
if (params.sessionId !== sessionId || !isRecord14(params.update))
|
|
24676
24778
|
continue;
|
|
24677
|
-
const metadata =
|
|
24779
|
+
const metadata = isRecord14(params._meta) ? params._meta : void 0;
|
|
24678
24780
|
const event = transportEvent(params.update, metadata);
|
|
24679
24781
|
if (event)
|
|
24680
24782
|
events.push(metadata ? { ...event, metadata } : event);
|
|
@@ -24717,13 +24819,23 @@ var GrokAcpTransport = class {
|
|
|
24717
24819
|
throw new Error("Grok ACP inspection cannot reuse an open Session");
|
|
24718
24820
|
try {
|
|
24719
24821
|
const initialize = await this.#ensureInitialized();
|
|
24822
|
+
const connection = this.#connection;
|
|
24823
|
+
if (!connection)
|
|
24824
|
+
throw new GrokTransportError("unavailable", "Grok ACP is unavailable");
|
|
24720
24825
|
if (initialize.agentCapabilities?.sessionCapabilities?.list) {
|
|
24721
|
-
const connection = this.#connection;
|
|
24722
|
-
if (!connection)
|
|
24723
|
-
throw new GrokTransportError("unavailable", "Grok ACP is unavailable");
|
|
24724
24826
|
await withTimeout(connection.listSessions({ cwd: this.#options.cwd }), this.#options.commandTimeoutMs, "Grok Session inspection");
|
|
24725
24827
|
}
|
|
24726
|
-
|
|
24828
|
+
try {
|
|
24829
|
+
const response = await withTimeout(connection.request("_x.ai/models/list", {}), this.#options.commandTimeoutMs, "Grok Model inspection");
|
|
24830
|
+
const modelState = isRecord14(response) ? response.result : void 0;
|
|
24831
|
+
if (!parseGrokModelState(modelState))
|
|
24832
|
+
throw new GrokTransportError("protocolError", "Grok returned an invalid Model catalog");
|
|
24833
|
+
return { ...initialize, _meta: { ...initialize._meta, modelState } };
|
|
24834
|
+
} catch (error53) {
|
|
24835
|
+
if (isGrokMethodNotFound(error53))
|
|
24836
|
+
return initialize;
|
|
24837
|
+
throw error53;
|
|
24838
|
+
}
|
|
24727
24839
|
} catch (error53) {
|
|
24728
24840
|
const classified = classifyStartupError(error53);
|
|
24729
24841
|
await this.close().catch(() => void 0);
|
|
@@ -24738,7 +24850,7 @@ var GrokAcpTransport = class {
|
|
|
24738
24850
|
if (!this.#connection)
|
|
24739
24851
|
throw new GrokTransportError("unavailable", "Grok ACP is unavailable");
|
|
24740
24852
|
const result = await withTimeout(this.#connection.request("_x.ai/session/usage", { sessionId: this.sessionId }), this.#options.commandTimeoutMs, "Grok Session usage");
|
|
24741
|
-
return
|
|
24853
|
+
return isRecord14(result) ? result.usage : void 0;
|
|
24742
24854
|
}
|
|
24743
24855
|
async readHistory(sessionId, cwd = this.#options.cwd) {
|
|
24744
24856
|
return readGrokNativeHistory({ ...this.#options, cwd }, sessionId);
|
|
@@ -25001,7 +25113,7 @@ var GrokAcpTransport = class {
|
|
|
25001
25113
|
...reasoningEffort ? { reasoningEffort } : {},
|
|
25002
25114
|
...contextWindowTokens !== void 0 ? { _meta: { contextWindow: contextWindowTokens } } : {}
|
|
25003
25115
|
});
|
|
25004
|
-
if (!
|
|
25116
|
+
if (!isRecord14(response) || !isRecord14(response._meta) || !isRecord14(response._meta.model)) {
|
|
25005
25117
|
throw new GrokTransportError("protocolError", "Grok rejected Model configuration");
|
|
25006
25118
|
}
|
|
25007
25119
|
const selected = response._meta.model.Ok;
|
|
@@ -25041,7 +25153,7 @@ var GrokAcpTransport = class {
|
|
|
25041
25153
|
permission_mode: mode
|
|
25042
25154
|
});
|
|
25043
25155
|
const response = await connection.request("_x.ai/session/info", { sessionId });
|
|
25044
|
-
if (!
|
|
25156
|
+
if (!isRecord14(response) || !isRecord14(response.result) || response.result.sessionId !== sessionId) {
|
|
25045
25157
|
throw new Error("Grok did not confirm the target Session");
|
|
25046
25158
|
}
|
|
25047
25159
|
})()
|
|
@@ -25096,7 +25208,7 @@ var GrokAcpTransport = class {
|
|
|
25096
25208
|
this.#availableCommands = parseGrokAvailableCommands(update.availableCommands);
|
|
25097
25209
|
return;
|
|
25098
25210
|
}
|
|
25099
|
-
const metadata =
|
|
25211
|
+
const metadata = isRecord14(notification._meta) ? notification._meta : void 0;
|
|
25100
25212
|
const event = transportEvent(notification.update, metadata);
|
|
25101
25213
|
if (!event)
|
|
25102
25214
|
return;
|
|
@@ -25111,7 +25223,7 @@ var GrokAcpTransport = class {
|
|
|
25111
25223
|
#handleExtensionNotification(method, params) {
|
|
25112
25224
|
if (!isGrokExtensionSessionUpdateMethod(method))
|
|
25113
25225
|
return;
|
|
25114
|
-
if (typeof params.sessionId !== "string" || !
|
|
25226
|
+
if (typeof params.sessionId !== "string" || !isRecord14(params.update))
|
|
25115
25227
|
return;
|
|
25116
25228
|
this.#handleUpdate(params);
|
|
25117
25229
|
}
|
|
@@ -25267,7 +25379,7 @@ var SessionImportScope = class {
|
|
|
25267
25379
|
// dist/session-import.js
|
|
25268
25380
|
var MAX_METADATA_BYTES = 4 * 1024 * 1024;
|
|
25269
25381
|
var SUBAGENT_SESSION_KINDS = /* @__PURE__ */ new Set(["subagent", "subagent_resume"]);
|
|
25270
|
-
function
|
|
25382
|
+
function isRecord15(value) {
|
|
25271
25383
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25272
25384
|
}
|
|
25273
25385
|
async function readJson(file2, signal) {
|
|
@@ -25280,7 +25392,7 @@ function processAlive(pid) {
|
|
|
25280
25392
|
process.kill(pid, 0);
|
|
25281
25393
|
return true;
|
|
25282
25394
|
} catch (error53) {
|
|
25283
|
-
return
|
|
25395
|
+
return isRecord15(error53) && error53.code === "EPERM";
|
|
25284
25396
|
}
|
|
25285
25397
|
}
|
|
25286
25398
|
async function firstUserText(file2, signal) {
|
|
@@ -25297,10 +25409,10 @@ async function firstUserText(file2, signal) {
|
|
|
25297
25409
|
} catch {
|
|
25298
25410
|
continue;
|
|
25299
25411
|
}
|
|
25300
|
-
const update =
|
|
25301
|
-
if (!
|
|
25412
|
+
const update = isRecord15(entry) && isRecord15(entry.params) ? entry.params.update : null;
|
|
25413
|
+
if (!isRecord15(update) || update.sessionUpdate !== "user_message_chunk")
|
|
25302
25414
|
continue;
|
|
25303
|
-
const text =
|
|
25415
|
+
const text = isRecord15(update.content) ? update.content.text : null;
|
|
25304
25416
|
return typeof text === "string" ? text : "";
|
|
25305
25417
|
}
|
|
25306
25418
|
return null;
|
|
@@ -25377,7 +25489,7 @@ var GrokSessionImport = class {
|
|
|
25377
25489
|
if (!Array.isArray(entries))
|
|
25378
25490
|
return active;
|
|
25379
25491
|
for (const entry of entries) {
|
|
25380
|
-
if (
|
|
25492
|
+
if (isRecord15(entry) && typeof entry.session_id === "string" && processAlive(entry.pid))
|
|
25381
25493
|
active.add(entry.session_id);
|
|
25382
25494
|
}
|
|
25383
25495
|
return active;
|
|
@@ -25426,7 +25538,7 @@ var GrokSessionImport = class {
|
|
|
25426
25538
|
return null;
|
|
25427
25539
|
try {
|
|
25428
25540
|
const summary = await readJson(files[0], signal);
|
|
25429
|
-
if (!
|
|
25541
|
+
if (!isRecord15(summary) || !isRecord15(summary.info) || summary.info.id !== nativeSessionId)
|
|
25430
25542
|
return null;
|
|
25431
25543
|
if (typeof summary.session_kind === "string" && SUBAGENT_SESSION_KINDS.has(summary.session_kind))
|
|
25432
25544
|
return null;
|
|
@@ -25652,107 +25764,6 @@ var GrokSubagentLifecycle = class {
|
|
|
25652
25764
|
}
|
|
25653
25765
|
};
|
|
25654
25766
|
|
|
25655
|
-
// dist/grok-models.js
|
|
25656
|
-
function isRecord15(value) {
|
|
25657
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25658
|
-
}
|
|
25659
|
-
function nonBlank(value) {
|
|
25660
|
-
return typeof value === "string" && value.trim().length > 0;
|
|
25661
|
-
}
|
|
25662
|
-
function thinkingOptions(value) {
|
|
25663
|
-
if (!Array.isArray(value))
|
|
25664
|
-
return [];
|
|
25665
|
-
const seen = /* @__PURE__ */ new Set();
|
|
25666
|
-
const options = [];
|
|
25667
|
-
for (const candidate of value) {
|
|
25668
|
-
if (!isRecord15(candidate) || !nonBlank(candidate.label))
|
|
25669
|
-
continue;
|
|
25670
|
-
const id = harnessThinkingOptionIdSchema.safeParse(candidate.id ?? candidate.value);
|
|
25671
|
-
if (!id.success || seen.has(id.data))
|
|
25672
|
-
continue;
|
|
25673
|
-
seen.add(id.data);
|
|
25674
|
-
options.push({ id: id.data, label: candidate.label });
|
|
25675
|
-
}
|
|
25676
|
-
return options;
|
|
25677
|
-
}
|
|
25678
|
-
function parseGrokModelState(value) {
|
|
25679
|
-
if (!isRecord15(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
|
|
25680
|
-
return null;
|
|
25681
|
-
}
|
|
25682
|
-
const currentModel = harnessModelRefSchema.safeParse({ id: value.currentModelId });
|
|
25683
|
-
if (!currentModel.success)
|
|
25684
|
-
return null;
|
|
25685
|
-
const allThinking = /* @__PURE__ */ new Map();
|
|
25686
|
-
const contextWindowTokensByModel = /* @__PURE__ */ new Map();
|
|
25687
|
-
const defaultContextWindowTokensByModel = /* @__PURE__ */ new Map();
|
|
25688
|
-
const models = [];
|
|
25689
|
-
let currentThinkingOptionId;
|
|
25690
|
-
for (const candidate of value.availableModels) {
|
|
25691
|
-
if (!isRecord15(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
|
|
25692
|
-
continue;
|
|
25693
|
-
const ref = harnessModelRefSchema.safeParse({ id: candidate.modelId });
|
|
25694
|
-
if (!ref.success)
|
|
25695
|
-
continue;
|
|
25696
|
-
const metadata = isRecord15(candidate._meta) ? candidate._meta : {};
|
|
25697
|
-
const options2 = thinkingOptions(metadata.reasoningEfforts);
|
|
25698
|
-
if (Array.isArray(metadata.contextWindows) && metadata.contextWindows.includes(5e5)) {
|
|
25699
|
-
defaultContextWindowTokensByModel.set(ref.data.id, 5e5);
|
|
25700
|
-
}
|
|
25701
|
-
if (typeof metadata.totalContextTokens === "number" && Number.isSafeInteger(metadata.totalContextTokens) && metadata.totalContextTokens > 0) {
|
|
25702
|
-
contextWindowTokensByModel.set(ref.data.id, metadata.totalContextTokens);
|
|
25703
|
-
}
|
|
25704
|
-
for (const option of options2)
|
|
25705
|
-
allThinking.set(option.id, option);
|
|
25706
|
-
if (candidate.modelId === value.currentModelId && nonBlank(metadata.reasoningEffort)) {
|
|
25707
|
-
const parsed = harnessThinkingOptionIdSchema.safeParse(metadata.reasoningEffort);
|
|
25708
|
-
if (parsed.success && options2.some(({ id }) => id === parsed.data)) {
|
|
25709
|
-
currentThinkingOptionId = parsed.data;
|
|
25710
|
-
}
|
|
25711
|
-
}
|
|
25712
|
-
models.push({
|
|
25713
|
-
ref: ref.data,
|
|
25714
|
-
label: candidate.name,
|
|
25715
|
-
...options2.length > 0 ? { supportedThinkingOptionIds: options2.map(({ id }) => id) } : {}
|
|
25716
|
-
});
|
|
25717
|
-
}
|
|
25718
|
-
if (!models.some(({ ref }) => ref.id === currentModel.data.id))
|
|
25719
|
-
return null;
|
|
25720
|
-
const options = [...allThinking.values()];
|
|
25721
|
-
return {
|
|
25722
|
-
currentModel: currentModel.data,
|
|
25723
|
-
contextWindowTokensByModel,
|
|
25724
|
-
defaultContextWindowTokensByModel,
|
|
25725
|
-
...currentThinkingOptionId ? { currentThinkingOptionId } : {},
|
|
25726
|
-
catalog: {
|
|
25727
|
-
models,
|
|
25728
|
-
defaultModel: currentModel.data,
|
|
25729
|
-
thinkingOptions: options,
|
|
25730
|
-
...currentThinkingOptionId ? { defaultThinkingOptionId: currentThinkingOptionId } : {}
|
|
25731
|
-
}
|
|
25732
|
-
};
|
|
25733
|
-
}
|
|
25734
|
-
function modelStateFromInitialize(response) {
|
|
25735
|
-
return parseGrokModelState(isRecord15(response._meta) ? response._meta.modelState : void 0);
|
|
25736
|
-
}
|
|
25737
|
-
function modelStateFromSessionResponse(response) {
|
|
25738
|
-
return parseGrokModelState(isRecord15(response) ? response.models : void 0);
|
|
25739
|
-
}
|
|
25740
|
-
function stateForGrokModel(modelState, nativeState, model2 = modelState.currentModel, thinkingOptionId = modelState.currentThinkingOptionId, permissionModeId) {
|
|
25741
|
-
const selectedModel = model2;
|
|
25742
|
-
const catalogModel = modelState.catalog.models.find(({ ref }) => ref.id === selectedModel.id);
|
|
25743
|
-
const availableThinkingOptions = catalogModel?.supportedThinkingOptionIds?.flatMap((id) => {
|
|
25744
|
-
const option = modelState.catalog.thinkingOptions.find((candidate) => candidate.id === id);
|
|
25745
|
-
return option ? [option] : [];
|
|
25746
|
-
});
|
|
25747
|
-
return {
|
|
25748
|
-
...nativeState,
|
|
25749
|
-
effectiveModel: selectedModel,
|
|
25750
|
-
...thinkingOptionId ? { effectiveThinkingOptionId: thinkingOptionId } : {},
|
|
25751
|
-
...permissionModeId ? { effectivePermissionModeId: permissionModeId } : {},
|
|
25752
|
-
...availableThinkingOptions ? { availableThinkingOptions } : {}
|
|
25753
|
-
};
|
|
25754
|
-
}
|
|
25755
|
-
|
|
25756
25767
|
// dist/grok-credits.js
|
|
25757
25768
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
25758
25769
|
import os6 from "node:os";
|
|
@@ -26257,6 +26268,7 @@ function capabilitiesForModels(modelState) {
|
|
|
26257
26268
|
};
|
|
26258
26269
|
}
|
|
26259
26270
|
var DEFAULT_CLOSE_TIMEOUT_MS = 2e3;
|
|
26271
|
+
var INSPECTION_CACHE_TTL_MS = 3e4;
|
|
26260
26272
|
function invalidState(message) {
|
|
26261
26273
|
return { code: "invalidState", message, retryable: false };
|
|
26262
26274
|
}
|
|
@@ -27398,8 +27410,8 @@ var GrokAdapter = class {
|
|
|
27398
27410
|
const cwd = path16.resolve(input.cwd ?? process.cwd());
|
|
27399
27411
|
if (!input.refresh) {
|
|
27400
27412
|
const cached2 = this.#inspectionCache.get(cwd);
|
|
27401
|
-
if (cached2)
|
|
27402
|
-
return cached2;
|
|
27413
|
+
if (cached2 && Date.now() < cached2.expiresAt)
|
|
27414
|
+
return cached2.inspection;
|
|
27403
27415
|
}
|
|
27404
27416
|
let transport = null;
|
|
27405
27417
|
const startedAt = Date.now();
|
|
@@ -27419,7 +27431,10 @@ var GrokAdapter = class {
|
|
|
27419
27431
|
permissionModes: GROK_PERMISSION_MODE_CATALOG,
|
|
27420
27432
|
capabilities: capabilitiesForModels(modelState)
|
|
27421
27433
|
};
|
|
27422
|
-
this.#inspectionCache.set(cwd,
|
|
27434
|
+
this.#inspectionCache.set(cwd, {
|
|
27435
|
+
inspection: ready,
|
|
27436
|
+
expiresAt: Date.now() + INSPECTION_CACHE_TTL_MS
|
|
27437
|
+
});
|
|
27423
27438
|
this.#scheduleCreditsRefresh();
|
|
27424
27439
|
return ready;
|
|
27425
27440
|
} catch (error53) {
|