@ycodium-ai/agent-grok 0.2.6520 → 0.2.6596
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/dist/index.js +53 -23
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var __export = (target, all) => {
|
|
|
8
8
|
import { definePlugin } from "@ycodium-ai/plugin-api";
|
|
9
9
|
|
|
10
10
|
// ../../packages/plugin-api/src/version.ts
|
|
11
|
-
var PLUGIN_API_VERSION =
|
|
11
|
+
var PLUGIN_API_VERSION = 221;
|
|
12
12
|
|
|
13
13
|
// src/index.ts
|
|
14
14
|
import { registerEffectiveHomeCommand } from "@ycodium-ai/plugin-api/instance-config";
|
|
@@ -171,7 +171,10 @@ var GROK_CARD = {
|
|
|
171
171
|
import * as NodeCrypto from "node:crypto";
|
|
172
172
|
import * as NodeOS from "node:os";
|
|
173
173
|
import * as NodePath2 from "node:path";
|
|
174
|
-
import {
|
|
174
|
+
import {
|
|
175
|
+
mergeLaunchEnv,
|
|
176
|
+
readModelConnectionEnv
|
|
177
|
+
} from "@ycodium-ai/plugin-api/executor";
|
|
175
178
|
import { expandHomePath } from "@ycodium-ai/plugin-api/instance-config";
|
|
176
179
|
|
|
177
180
|
// src/grokAccount.ts
|
|
@@ -243,7 +246,7 @@ function grokContinuationKey(recipe) {
|
|
|
243
246
|
return `grok:home:${resolveGrokHomePath(recipe.homePath)}`;
|
|
244
247
|
}
|
|
245
248
|
function resolveAccountHomePath(recipe, configuredHome) {
|
|
246
|
-
const fromEnvironment = recipe.environment[
|
|
249
|
+
const fromEnvironment = recipe.environment[GROK_CARD.homeEnvVar]?.trim();
|
|
247
250
|
if (fromEnvironment !== void 0 && fromEnvironment.length > 0) {
|
|
248
251
|
return NodePath2.resolve(expandHomePath(fromEnvironment));
|
|
249
252
|
}
|
|
@@ -256,36 +259,41 @@ function absentPath() {
|
|
|
256
259
|
"auth.json"
|
|
257
260
|
);
|
|
258
261
|
}
|
|
259
|
-
function ownEndpointAuthGuard(recipe) {
|
|
262
|
+
function ownEndpointAuthGuard(recipe, platform) {
|
|
260
263
|
const connectivity = GROK_CARD.modelConnectivity;
|
|
261
264
|
const baseUrlKey = connectivity.baseUrlEnvKey;
|
|
262
265
|
if (baseUrlKey === void 0) return {};
|
|
263
266
|
const effectiveEnv = mergeLaunchEnv({
|
|
264
267
|
inherited: process.env,
|
|
265
|
-
instanceTable: recipe.environment
|
|
268
|
+
instanceTable: recipe.environment,
|
|
269
|
+
platform
|
|
266
270
|
});
|
|
267
|
-
if ((effectiveEnv[baseUrlKey]?.trim() ?? "") === "")
|
|
271
|
+
if ((readModelConnectionEnv(connectivity, effectiveEnv, platform)[baseUrlKey]?.trim() ?? "") === "") {
|
|
272
|
+
return {};
|
|
273
|
+
}
|
|
268
274
|
const guard = {};
|
|
269
275
|
for (const entry of connectivity.extraEnv ?? []) {
|
|
270
276
|
if (entry.value === "$absentPath") guard[entry.name] = absentPath();
|
|
271
277
|
}
|
|
272
278
|
return guard;
|
|
273
279
|
}
|
|
274
|
-
function buildSignInEnv(recipe) {
|
|
280
|
+
function buildSignInEnv(recipe, platform) {
|
|
275
281
|
const configuredHome = recipe.homePath;
|
|
276
282
|
const homeInjection = configuredHome.trim().length > 0 ? { [GROK_CARD.homeEnvVar]: resolveGrokHomePath(configuredHome) } : {};
|
|
277
283
|
return mergeLaunchEnv({
|
|
278
284
|
accountHome: homeInjection,
|
|
279
285
|
instanceTable: recipe.environment,
|
|
280
|
-
handOverrides: { GROK_OAUTH2_REFERRER: "ycodium" }
|
|
286
|
+
handOverrides: { GROK_OAUTH2_REFERRER: "ycodium" },
|
|
287
|
+
platform
|
|
281
288
|
});
|
|
282
289
|
}
|
|
283
|
-
function buildSpawnEnv(recipe, resolvedHomePath, homeConfigured) {
|
|
290
|
+
function buildSpawnEnv(recipe, resolvedHomePath, homeConfigured, platform) {
|
|
284
291
|
const homeInjection = homeConfigured ? { [GROK_CARD.homeEnvVar]: resolvedHomePath } : {};
|
|
285
292
|
return mergeLaunchEnv({
|
|
286
|
-
accountHome: { ...homeInjection, ...ownEndpointAuthGuard(recipe) },
|
|
293
|
+
accountHome: { ...homeInjection, ...ownEndpointAuthGuard(recipe, platform) },
|
|
287
294
|
instanceTable: recipe.environment,
|
|
288
|
-
handOverrides: { GROK_OAUTH2_REFERRER: "ycodium" }
|
|
295
|
+
handOverrides: { GROK_OAUTH2_REFERRER: "ycodium" },
|
|
296
|
+
platform
|
|
289
297
|
});
|
|
290
298
|
}
|
|
291
299
|
|
|
@@ -293,7 +301,8 @@ function buildSpawnEnv(recipe, resolvedHomePath, homeConfigured) {
|
|
|
293
301
|
import { sessionReadFromImport } from "@ycodium-ai/plugin-api/session-history";
|
|
294
302
|
import * as NodeCrypto6 from "node:crypto";
|
|
295
303
|
import {
|
|
296
|
-
raceAbort as raceAbort2
|
|
304
|
+
raceAbort as raceAbort2,
|
|
305
|
+
readModelConnectionEnv as readModelConnectionEnv3
|
|
297
306
|
} from "@ycodium-ai/plugin-api/executor";
|
|
298
307
|
import { nodeStreamsFromHandle as nodeStreamsFromHandle2 } from "@ycodium-ai/plugin-api/process-stdin";
|
|
299
308
|
|
|
@@ -30200,9 +30209,10 @@ import {
|
|
|
30200
30209
|
import {
|
|
30201
30210
|
readLaunchInstanceRecipe
|
|
30202
30211
|
} from "@ycodium-ai/plugin-api/instance-config";
|
|
30212
|
+
var GROK_PROGRAM_NOT_CONFIGURED = "Grok program path is not configured";
|
|
30203
30213
|
var GROK_DEFAULT_LAUNCH_ARGS = "agent stdio";
|
|
30204
|
-
function parseGrokInstanceConfig(config2) {
|
|
30205
|
-
return readLaunchInstanceRecipe(config2, GROK_DEFAULT_LAUNCH_ARGS);
|
|
30214
|
+
function parseGrokInstanceConfig(config2, platform) {
|
|
30215
|
+
return readLaunchInstanceRecipe(config2, GROK_DEFAULT_LAUNCH_ARGS, platform);
|
|
30206
30216
|
}
|
|
30207
30217
|
|
|
30208
30218
|
// src/grokSignIn.ts
|
|
@@ -30226,6 +30236,7 @@ function makeGrokSignIn(input2) {
|
|
|
30226
30236
|
// src/grokQuota.ts
|
|
30227
30237
|
import * as NodeFS2 from "node:fs";
|
|
30228
30238
|
import * as NodePath5 from "node:path";
|
|
30239
|
+
import { readModelConnectionEnv as readModelConnectionEnv2 } from "@ycodium-ai/plugin-api/executor";
|
|
30229
30240
|
import "@ycodium-ai/plugin-api/usage";
|
|
30230
30241
|
import {
|
|
30231
30242
|
requestQuotaJson,
|
|
@@ -30269,8 +30280,13 @@ var createGrokUsage = (input2) => {
|
|
|
30269
30280
|
const now = input2.now ?? Date.now;
|
|
30270
30281
|
const authPath = NodePath5.join(input2.homePath, AUTH_FILE_NAME2);
|
|
30271
30282
|
const readQuota = async (request) => {
|
|
30283
|
+
const connectionEnv = readModelConnectionEnv2(
|
|
30284
|
+
GROK_CARD.modelConnectivity,
|
|
30285
|
+
input2.environment,
|
|
30286
|
+
input2.platform
|
|
30287
|
+
);
|
|
30272
30288
|
const baseUrlKey = GROK_CARD.modelConnectivity.baseUrlEnvKey;
|
|
30273
|
-
if (baseUrlKey !== void 0 && (
|
|
30289
|
+
if (baseUrlKey !== void 0 && (connectionEnv[baseUrlKey]?.trim() ?? "") !== "") {
|
|
30274
30290
|
return { status: "unavailable", reason: "customEndpoint" };
|
|
30275
30291
|
}
|
|
30276
30292
|
let token = null;
|
|
@@ -30280,7 +30296,8 @@ var createGrokUsage = (input2) => {
|
|
|
30280
30296
|
token = null;
|
|
30281
30297
|
}
|
|
30282
30298
|
if (token === null) {
|
|
30283
|
-
const
|
|
30299
|
+
const credentialKey = GROK_CARD.modelConnectivity.credentialEnvKey ?? "XAI_API_KEY";
|
|
30300
|
+
const apiKey = connectionEnv[credentialKey]?.trim() ?? "";
|
|
30284
30301
|
return {
|
|
30285
30302
|
status: "unavailable",
|
|
30286
30303
|
reason: apiKey.length > 0 ? "unsupportedLogin" : "missingCredentials"
|
|
@@ -31837,7 +31854,14 @@ function createGrokModelCatalog(input2) {
|
|
|
31837
31854
|
let skipUnforced = false;
|
|
31838
31855
|
const nowMs = input2.nowMs ?? (() => Date.now());
|
|
31839
31856
|
const readCliVersion = (signal) => {
|
|
31840
|
-
if (input2.recipe.binaryPath.length === 0)
|
|
31857
|
+
if (input2.recipe.binaryPath.trim().length === 0) {
|
|
31858
|
+
try {
|
|
31859
|
+
throwIfExecutorSpawnAborted(signal);
|
|
31860
|
+
} catch (error62) {
|
|
31861
|
+
return Promise.reject(error62);
|
|
31862
|
+
}
|
|
31863
|
+
return Promise.resolve(null);
|
|
31864
|
+
}
|
|
31841
31865
|
return probeGrokVersion({
|
|
31842
31866
|
recipe: input2.recipe,
|
|
31843
31867
|
host: input2.host,
|
|
@@ -31847,6 +31871,10 @@ function createGrokModelCatalog(input2) {
|
|
|
31847
31871
|
};
|
|
31848
31872
|
const refreshModelCatalog = async (request) => {
|
|
31849
31873
|
try {
|
|
31874
|
+
throwIfExecutorSpawnAborted(request.signal);
|
|
31875
|
+
if (input2.recipe.binaryPath.trim().length === 0) {
|
|
31876
|
+
throw new Error(GROK_PROGRAM_NOT_CONFIGURED);
|
|
31877
|
+
}
|
|
31850
31878
|
const cliVersion = request.cliVersion !== void 0 ? request.cliVersion : await readCliVersion(request.signal);
|
|
31851
31879
|
if (!request.force && skipUnforced) {
|
|
31852
31880
|
skipUnforced = false;
|
|
@@ -32319,8 +32347,9 @@ var createGrokInstance = (config2, host, deps) => {
|
|
|
32319
32347
|
const table = createAcpThreadTable(host.log, () => signIn.close());
|
|
32320
32348
|
const { threads, requireThread, registerSession, stopSession, disposeOnce } = table;
|
|
32321
32349
|
const probeAuth = () => {
|
|
32322
|
-
|
|
32323
|
-
|
|
32350
|
+
const credentialKey = GROK_CARD.modelConnectivity.credentialEnvKey ?? "XAI_API_KEY";
|
|
32351
|
+
if ((readModelConnectionEnv3(GROK_CARD.modelConnectivity, recipe.environment)[credentialKey] ?? "").trim().length > 0) {
|
|
32352
|
+
return { status: "authenticated", type: "api-key", label: credentialKey };
|
|
32324
32353
|
}
|
|
32325
32354
|
const account = readGrokAccount(resolveAccountHomePath(recipe, recipe.homePath));
|
|
32326
32355
|
switch (account.state) {
|
|
@@ -32359,7 +32388,7 @@ var createGrokInstance = (config2, host, deps) => {
|
|
|
32359
32388
|
version: null,
|
|
32360
32389
|
readiness: "not-installed",
|
|
32361
32390
|
auth: { status: "unknown" },
|
|
32362
|
-
detail:
|
|
32391
|
+
detail: GROK_PROGRAM_NOT_CONFIGURED
|
|
32363
32392
|
};
|
|
32364
32393
|
}
|
|
32365
32394
|
prepareGrokFollowUpSteer(resolveAccountHomePath(recipe, recipe.homePath), host.log);
|
|
@@ -32424,7 +32453,8 @@ var createGrokInstance = (config2, host, deps) => {
|
|
|
32424
32453
|
...deps?.readAttachment === void 0 ? {} : { readAttachment: deps.readAttachment }
|
|
32425
32454
|
});
|
|
32426
32455
|
const sessionSkillNames = /* @__PURE__ */ new Map();
|
|
32427
|
-
const
|
|
32456
|
+
const sessionEnv = spawnEnv();
|
|
32457
|
+
const sessionHome = (Object.hasOwn(sessionEnv, GROK_CARD.homeEnvVar) ? sessionEnv[GROK_CARD.homeEnvVar] : process.env[GROK_CARD.homeEnvVar])?.trim();
|
|
32428
32458
|
const sessions = createGrokNativeSessions(
|
|
32429
32459
|
sessionHome || resolveGrokHomePath(""),
|
|
32430
32460
|
RESUME_SCHEMA_VERSION
|
|
@@ -32445,7 +32475,7 @@ var createGrokInstance = (config2, host, deps) => {
|
|
|
32445
32475
|
// 项目里的技能:探测在 home 下跑 inspect 只看得到整机的;这里在项目目录里再跑一次。
|
|
32446
32476
|
workspaceInventory: ({ cwd }) => {
|
|
32447
32477
|
if (recipe.binaryPath.length === 0) {
|
|
32448
|
-
return Promise.reject(new Error(
|
|
32478
|
+
return Promise.reject(new Error(GROK_PROGRAM_NOT_CONFIGURED));
|
|
32449
32479
|
}
|
|
32450
32480
|
return inspectGrokWorkspace({
|
|
32451
32481
|
recipe,
|
|
@@ -32460,7 +32490,7 @@ var createGrokInstance = (config2, host, deps) => {
|
|
|
32460
32490
|
if (disposed) throw new Error("instance disposed");
|
|
32461
32491
|
throwIfStartAborted(signal);
|
|
32462
32492
|
if (recipe.binaryPath.length === 0) {
|
|
32463
|
-
throw new Error(
|
|
32493
|
+
throw new Error(GROK_PROGRAM_NOT_CONFIGURED);
|
|
32464
32494
|
}
|
|
32465
32495
|
const cwd = input2.cwd ?? host.workspacePath(input2.threadId);
|
|
32466
32496
|
if (cwd.trim() === "") throw new Error("workspace path missing");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-grok",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6596",
|
|
4
4
|
"description": "Grok executor: grok CLI over Agent Client Protocol stdio.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"@types/node": "24.12.4",
|
|
22
22
|
"esbuild": "0.28.1",
|
|
23
23
|
"vite-plus": "0.2.2",
|
|
24
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
25
|
-
"ycodium-acp-executor": "0.2.0",
|
|
24
|
+
"@ycodium-ai/plugin-api": "0.2.6596",
|
|
26
25
|
"ycodium-credential-account": "0.0.0",
|
|
26
|
+
"ycodium-acp-executor": "0.2.6596",
|
|
27
27
|
"ycodium-executor-testing": "0.0.0"
|
|
28
28
|
},
|
|
29
29
|
"ycodium": {
|