@ycodium-ai/agent-grok 0.2.6513 → 0.2.6551

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +5 -4
  2. package/dist/index.js +43 -20
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -44,10 +44,11 @@ Facts:
44
44
  - Credential order warning: setting `GROK_MODELS_BASE_URL` does not switch the CLI to
45
45
  API-key auth. Grok resolves `api_key` → `env_key` → the signed-in session token →
46
46
  `XAI_API_KEY`, so a signed-in instance would send its x.ai session token to the custom
47
- base URL. When the instance environment sets `GROK_MODELS_BASE_URL`, the plugin
48
- therefore spawns the CLI with `GROK_AUTH_PATH` pointing at a fresh path that does not
49
- exist (the card's `extraEnv` `$absentPath` entry), unless the instance sets
50
- `GROK_AUTH_PATH` itself. The login file in the account directory is left untouched.
47
+ base URL. When the CLI's effective environment (inherited host environment plus
48
+ instance overrides) sets `GROK_MODELS_BASE_URL`, the plugin therefore spawns the CLI
49
+ with `GROK_AUTH_PATH` pointing at a fresh path that does not exist (the card's
50
+ `extraEnv` `$absentPath` entry), unless the instance sets `GROK_AUTH_PATH` itself.
51
+ The login file in the account directory is left untouched.
51
52
  Settings also gives a new instance that sets these variables its own account directory.
52
53
  - Usage (ADR-0034), per instance, read only when the user asks:
53
54
  - Quota: `ExecutorInstance.usage.readQuota` reads the weekly credit window from
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 = 218;
11
+ var PLUGIN_API_VERSION = 219;
12
12
 
13
13
  // src/index.ts
14
14
  import { registerEffectiveHomeCommand } from "@ycodium-ai/plugin-api/instance-config";
@@ -160,8 +160,8 @@ var GROK_CARD = {
160
160
  // 那是平台语义(POSIX `/dev/null` 对 Windows `NUL`),而「读不到」两边只有一种行为。
161
161
  // 1.0.34 实测:`authMethods` 少掉 `cached_token`、两笔请求(推理与标题)都改带
162
162
  // `XAI_API_KEY`,账号目录里那份 `auth.json` 一个字节没动,也没在别处新建文件。
163
- // 宿主不注入它。插件在实例环境表设了 `GROK_MODELS_BASE_URL`、又没自己写
164
- // `GROK_AUTH_PATH` 时替换 `$absentPath` 并填上(`grokInstance.ts` 的
163
+ // 宿主不注入它。实际交给 CLI 的环境(继承环境 + 实例表)设了 `GROK_MODELS_BASE_URL`、
164
+ // 实例表又没自己写 `GROK_AUTH_PATH` 时,插件替换 `$absentPath` 并填上(`grokHome.ts` 的
165
165
  // `ownEndpointAuthGuard`);没换地址的实例照旧用用户自己的登录。
166
166
  extraEnv: [{ name: "GROK_AUTH_PATH", value: "$absentPath" }]
167
167
  }
@@ -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 { mergeLaunchEnv } from "@ycodium-ai/plugin-api/executor";
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["GROK_HOME"]?.trim();
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,31 +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
- if (baseUrlKey === void 0 || (recipe.environment[baseUrlKey]?.trim() ?? "") === "") return {};
265
+ if (baseUrlKey === void 0) return {};
266
+ const effectiveEnv = mergeLaunchEnv({
267
+ inherited: process.env,
268
+ instanceTable: recipe.environment,
269
+ platform
270
+ });
271
+ if ((readModelConnectionEnv(connectivity, effectiveEnv, platform)[baseUrlKey]?.trim() ?? "") === "") {
272
+ return {};
273
+ }
263
274
  const guard = {};
264
275
  for (const entry of connectivity.extraEnv ?? []) {
265
276
  if (entry.value === "$absentPath") guard[entry.name] = absentPath();
266
277
  }
267
278
  return guard;
268
279
  }
269
- function buildSignInEnv(recipe) {
280
+ function buildSignInEnv(recipe, platform) {
270
281
  const configuredHome = recipe.homePath;
271
282
  const homeInjection = configuredHome.trim().length > 0 ? { [GROK_CARD.homeEnvVar]: resolveGrokHomePath(configuredHome) } : {};
272
283
  return mergeLaunchEnv({
273
284
  accountHome: homeInjection,
274
285
  instanceTable: recipe.environment,
275
- handOverrides: { GROK_OAUTH2_REFERRER: "ycodium" }
286
+ handOverrides: { GROK_OAUTH2_REFERRER: "ycodium" },
287
+ platform
276
288
  });
277
289
  }
278
- function buildSpawnEnv(recipe, resolvedHomePath, homeConfigured) {
290
+ function buildSpawnEnv(recipe, resolvedHomePath, homeConfigured, platform) {
279
291
  const homeInjection = homeConfigured ? { [GROK_CARD.homeEnvVar]: resolvedHomePath } : {};
280
292
  return mergeLaunchEnv({
281
- accountHome: { ...homeInjection, ...ownEndpointAuthGuard(recipe) },
293
+ accountHome: { ...homeInjection, ...ownEndpointAuthGuard(recipe, platform) },
282
294
  instanceTable: recipe.environment,
283
- handOverrides: { GROK_OAUTH2_REFERRER: "ycodium" }
295
+ handOverrides: { GROK_OAUTH2_REFERRER: "ycodium" },
296
+ platform
284
297
  });
285
298
  }
286
299
 
@@ -288,7 +301,8 @@ function buildSpawnEnv(recipe, resolvedHomePath, homeConfigured) {
288
301
  import { sessionReadFromImport } from "@ycodium-ai/plugin-api/session-history";
289
302
  import * as NodeCrypto6 from "node:crypto";
290
303
  import {
291
- raceAbort as raceAbort2
304
+ raceAbort as raceAbort2,
305
+ readModelConnectionEnv as readModelConnectionEnv3
292
306
  } from "@ycodium-ai/plugin-api/executor";
293
307
  import { nodeStreamsFromHandle as nodeStreamsFromHandle2 } from "@ycodium-ai/plugin-api/process-stdin";
294
308
 
@@ -30196,8 +30210,8 @@ import {
30196
30210
  readLaunchInstanceRecipe
30197
30211
  } from "@ycodium-ai/plugin-api/instance-config";
30198
30212
  var GROK_DEFAULT_LAUNCH_ARGS = "agent stdio";
30199
- function parseGrokInstanceConfig(config2) {
30200
- return readLaunchInstanceRecipe(config2, GROK_DEFAULT_LAUNCH_ARGS);
30213
+ function parseGrokInstanceConfig(config2, platform) {
30214
+ return readLaunchInstanceRecipe(config2, GROK_DEFAULT_LAUNCH_ARGS, platform);
30201
30215
  }
30202
30216
 
30203
30217
  // src/grokSignIn.ts
@@ -30221,6 +30235,7 @@ function makeGrokSignIn(input2) {
30221
30235
  // src/grokQuota.ts
30222
30236
  import * as NodeFS2 from "node:fs";
30223
30237
  import * as NodePath5 from "node:path";
30238
+ import { readModelConnectionEnv as readModelConnectionEnv2 } from "@ycodium-ai/plugin-api/executor";
30224
30239
  import "@ycodium-ai/plugin-api/usage";
30225
30240
  import {
30226
30241
  requestQuotaJson,
@@ -30264,8 +30279,13 @@ var createGrokUsage = (input2) => {
30264
30279
  const now = input2.now ?? Date.now;
30265
30280
  const authPath = NodePath5.join(input2.homePath, AUTH_FILE_NAME2);
30266
30281
  const readQuota = async (request) => {
30282
+ const connectionEnv = readModelConnectionEnv2(
30283
+ GROK_CARD.modelConnectivity,
30284
+ input2.environment,
30285
+ input2.platform
30286
+ );
30267
30287
  const baseUrlKey = GROK_CARD.modelConnectivity.baseUrlEnvKey;
30268
- if (baseUrlKey !== void 0 && (input2.environment[baseUrlKey]?.trim() ?? "") !== "") {
30288
+ if (baseUrlKey !== void 0 && (connectionEnv[baseUrlKey]?.trim() ?? "") !== "") {
30269
30289
  return { status: "unavailable", reason: "customEndpoint" };
30270
30290
  }
30271
30291
  let token = null;
@@ -30275,7 +30295,8 @@ var createGrokUsage = (input2) => {
30275
30295
  token = null;
30276
30296
  }
30277
30297
  if (token === null) {
30278
- const apiKey = input2.environment["XAI_API_KEY"]?.trim() ?? "";
30298
+ const credentialKey = GROK_CARD.modelConnectivity.credentialEnvKey ?? "XAI_API_KEY";
30299
+ const apiKey = connectionEnv[credentialKey]?.trim() ?? "";
30279
30300
  return {
30280
30301
  status: "unavailable",
30281
30302
  reason: apiKey.length > 0 ? "unsupportedLogin" : "missingCredentials"
@@ -32314,8 +32335,9 @@ var createGrokInstance = (config2, host, deps) => {
32314
32335
  const table = createAcpThreadTable(host.log, () => signIn.close());
32315
32336
  const { threads, requireThread, registerSession, stopSession, disposeOnce } = table;
32316
32337
  const probeAuth = () => {
32317
- if ((recipe.environment["XAI_API_KEY"] ?? "").trim().length > 0) {
32318
- return { status: "authenticated", type: "api-key", label: "XAI_API_KEY" };
32338
+ const credentialKey = GROK_CARD.modelConnectivity.credentialEnvKey ?? "XAI_API_KEY";
32339
+ if ((readModelConnectionEnv3(GROK_CARD.modelConnectivity, recipe.environment)[credentialKey] ?? "").trim().length > 0) {
32340
+ return { status: "authenticated", type: "api-key", label: credentialKey };
32319
32341
  }
32320
32342
  const account = readGrokAccount(resolveAccountHomePath(recipe, recipe.homePath));
32321
32343
  switch (account.state) {
@@ -32419,7 +32441,8 @@ var createGrokInstance = (config2, host, deps) => {
32419
32441
  ...deps?.readAttachment === void 0 ? {} : { readAttachment: deps.readAttachment }
32420
32442
  });
32421
32443
  const sessionSkillNames = /* @__PURE__ */ new Map();
32422
- const sessionHome = (spawnEnv().GROK_HOME ?? process.env.GROK_HOME)?.trim();
32444
+ const sessionEnv = spawnEnv();
32445
+ const sessionHome = (Object.hasOwn(sessionEnv, GROK_CARD.homeEnvVar) ? sessionEnv[GROK_CARD.homeEnvVar] : process.env[GROK_CARD.homeEnvVar])?.trim();
32423
32446
  const sessions = createGrokNativeSessions(
32424
32447
  sessionHome || resolveGrokHomePath(""),
32425
32448
  RESUME_SCHEMA_VERSION
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-grok",
3
- "version": "0.2.6513",
3
+ "version": "0.2.6551",
4
4
  "description": "Grok executor: grok CLI over Agent Client Protocol stdio.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -21,10 +21,10 @@
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.6513",
25
- "ycodium-credential-account": "0.0.0",
24
+ "ycodium-acp-executor": "0.2.6551",
25
+ "@ycodium-ai/plugin-api": "0.2.6551",
26
26
  "ycodium-executor-testing": "0.0.0",
27
- "ycodium-acp-executor": "0.2.6513"
27
+ "ycodium-credential-account": "0.0.0"
28
28
  },
29
29
  "ycodium": {
30
30
  "plugin": "./dist/index.js",