@ycodium-ai/agent-grok 0.2.5557 → 0.2.5634

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 (2) hide show
  1. package/dist/index.js +439 -313
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -8,43 +8,102 @@ 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 = 175;
11
+ var PLUGIN_API_VERSION = 178;
12
12
 
13
- // src/index.ts
13
+ // ../../packages/ycodium-instance-config/src/homePath.ts
14
+ import * as NodeCrypto from "node:crypto";
15
+ import * as NodeOS from "node:os";
16
+ import * as NodePath from "node:path";
14
17
  import {
15
18
  EXECUTOR_EFFECTIVE_PAYLOAD_SCHEMA,
16
19
  executorHomeEffectiveValue,
17
- readExecutorEffectiveRequest
20
+ readExecutorEffectiveRequest,
21
+ mergeLaunchEnv
18
22
  } from "@ycodium-ai/plugin-api/executor";
23
+ function instanceAccountDirectory(pluginDataDir, instanceId) {
24
+ return NodePath.join(
25
+ pluginDataDir,
26
+ "profiles",
27
+ NodeCrypto.createHash("sha256").update(instanceId).digest("hex")
28
+ );
29
+ }
30
+ function privateHomeFor(config2, env, variable, dataDir, id) {
31
+ if (config2.privateAccount !== true || typeof config2.homePath === "string" && config2.homePath.trim() || env[variable]?.trim() || !id)
32
+ return void 0;
33
+ if (!dataDir) throw new Error("Executor plugin data directory unavailable");
34
+ return instanceAccountDirectory(dataDir, id);
35
+ }
36
+ function expandHomePath(value) {
37
+ if (value === "~") return NodeOS.homedir();
38
+ if (value.startsWith("~/") || value.startsWith("~\\")) {
39
+ return NodePath.join(NodeOS.homedir(), value.slice(2));
40
+ }
41
+ return value;
42
+ }
43
+ function registerEffectiveHomeCommand(ctx, homeEnvVar, resolve4, profileDataDir) {
44
+ ctx.command({
45
+ name: "effectiveConfig",
46
+ description: "Settings form: the account directory an empty path resolves to on this machine.",
47
+ scope: "read",
48
+ payloadSchema: EXECUTOR_EFFECTIVE_PAYLOAD_SCHEMA,
49
+ handle: async (payload) => {
50
+ const req = readExecutorEffectiveRequest(payload);
51
+ if (profileDataDir && req.config.privateAccount === true && !req.instanceId && !req.environment[homeEnvVar]?.trim() && !req.config.homePath)
52
+ return {};
53
+ const home = profileDataDir && privateHomeFor(req.config, req.environment, homeEnvVar, profileDataDir, req.instanceId);
54
+ return {
55
+ homePath: home ? { value: home, detailKey: "form.effective.default" } : executorHomeEffectiveValue(homeEnvVar, req, process.env, resolve4)
56
+ };
57
+ }
58
+ });
59
+ }
19
60
 
20
61
  // ../../packages/ycodium-instance-config/src/programHomeSchema.ts
21
- function programAndHomeConfigSchema(binaryPath) {
22
- const binaryForm = {
23
- titleKey: "form.binaryPath.title",
24
- descriptionKey: "form.binaryPath.description",
25
- placeholderKey: "form.binaryPath.placeholder",
26
- control: binaryPath.control
62
+ var executorEnvelopeFields = {
63
+ enabled: { type: "boolean" },
64
+ customModels: { type: "array" },
65
+ driver: { type: "string" },
66
+ config: { type: "object" },
67
+ environment: { type: "array" }
68
+ };
69
+ function executorProgramField(name, options = {}) {
70
+ return {
71
+ type: "string",
72
+ "x-ycodium-form": {
73
+ titleKey: `form.${name}.title`,
74
+ ...options.description === false ? {} : { descriptionKey: `form.${name}.description` },
75
+ ...options.placeholder === false ? {} : { placeholderKey: `form.${name}.placeholder` },
76
+ ...name === "binaryPath" ? { control: options.control ?? "executable-path" } : {},
77
+ ...name === "homePath" || options.machineLocal ? { machineLocal: true } : {}
78
+ }
27
79
  };
28
- if (binaryPath.machineLocal === true) binaryForm["machineLocal"] = true;
80
+ }
81
+ function programAndHomeConfigSchema(binaryPath) {
29
82
  return {
30
83
  type: "object",
31
- "x-ycodium-form-order": ["binaryPath", "homePath"],
84
+ ...binaryPath.privateAccountOption ? { "x-ycodium-new-instance-defaults": { privateAccount: true } } : {},
85
+ "x-ycodium-form-order": [
86
+ "binaryPath",
87
+ "homePath",
88
+ ...binaryPath.privateAccountOption ? ["privateAccount"] : []
89
+ ],
32
90
  properties: {
33
- binaryPath: { type: "string", "x-ycodium-form": binaryForm },
34
- homePath: {
35
- type: "string",
36
- "x-ycodium-form": {
37
- titleKey: "form.homePath.title",
38
- machineLocal: true,
39
- descriptionKey: "form.homePath.description",
40
- placeholderKey: "form.homePath.placeholder"
91
+ ...executorEnvelopeFields,
92
+ binaryPath: executorProgramField("binaryPath", {
93
+ control: binaryPath.control,
94
+ machineLocal: binaryPath.machineLocal === true
95
+ }),
96
+ homePath: executorProgramField("homePath"),
97
+ ...binaryPath.privateAccountOption ? {
98
+ privateAccount: {
99
+ type: "boolean",
100
+ default: false,
101
+ "x-ycodium-form": {
102
+ titleKey: "form.privateAccount.title",
103
+ descriptionKey: "form.privateAccount.description"
104
+ }
41
105
  }
42
- },
43
- enabled: { type: "boolean" },
44
- customModels: { type: "array" },
45
- driver: { type: "string" },
46
- config: { type: "object" },
47
- environment: { type: "array" }
106
+ } : {}
48
107
  },
49
108
  additionalProperties: true
50
109
  };
@@ -185,23 +244,11 @@ var GROK_CARD = {
185
244
  };
186
245
 
187
246
  // src/grokHome.ts
188
- import * as NodeCrypto from "node:crypto";
247
+ import * as NodeCrypto2 from "node:crypto";
189
248
  import * as NodeOS2 from "node:os";
190
249
  import * as NodePath3 from "node:path";
191
250
  import { mergeLaunchEnv as mergeLaunchEnv2 } from "@ycodium-ai/plugin-api/executor";
192
251
 
193
- // ../../packages/ycodium-instance-config/src/homePath.ts
194
- import * as NodeOS from "node:os";
195
- import * as NodePath from "node:path";
196
- import { mergeLaunchEnv } from "@ycodium-ai/plugin-api/executor";
197
- function expandHomePath(value) {
198
- if (value === "~") return NodeOS.homedir();
199
- if (value.startsWith("~/") || value.startsWith("~\\")) {
200
- return NodePath.join(NodeOS.homedir(), value.slice(2));
201
- }
202
- return value;
203
- }
204
-
205
252
  // src/grokAccount.ts
206
253
  import * as NodePath2 from "node:path";
207
254
 
@@ -314,7 +361,7 @@ function resolveAccountHomePath(recipe, configuredHome) {
314
361
  function absentPath() {
315
362
  return NodePath3.join(
316
363
  NodeOS2.tmpdir(),
317
- `ycodium-grok-no-auth-${NodeCrypto.randomUUID()}`,
364
+ `ycodium-grok-no-auth-${NodeCrypto2.randomUUID()}`,
318
365
  "auth.json"
319
366
  );
320
367
  }
@@ -346,15 +393,51 @@ function buildSpawnEnv(recipe, resolvedHomePath, homeConfigured) {
346
393
  });
347
394
  }
348
395
 
396
+ // ../../packages/ycodium-jsonl-stream/src/sessionTranscript.ts
397
+ var SESSION_IMPORT_ACTIVITY_TEXT_LIMIT = 32e3;
398
+ function bounded(value, tail = false) {
399
+ if (value.length <= SESSION_IMPORT_ACTIVITY_TEXT_LIMIT) return { text: value, truncated: false };
400
+ const offset = tail ? value.length - SESSION_IMPORT_ACTIVITY_TEXT_LIMIT : SESSION_IMPORT_ACTIVITY_TEXT_LIMIT;
401
+ const character = value.charCodeAt(offset);
402
+ const previous = value.charCodeAt(offset - 1);
403
+ const splitPair = character >= 56320 && character <= 57343 && previous >= 55296 && previous <= 56319;
404
+ return {
405
+ text: tail ? value.slice(offset + (splitPair ? 1 : 0)) : value.slice(0, offset - (splitPair ? 1 : 0)),
406
+ truncated: true
407
+ };
408
+ }
409
+ function inputPayload(input2) {
410
+ if (input2 === void 0) return {};
411
+ const result = bounded(input2);
412
+ return { input: result.text, ...result.truncated ? { inputTruncated: true } : {} };
413
+ }
414
+ function outputPayload(output2) {
415
+ if (output2 === void 0) return {};
416
+ const result = bounded(output2, true);
417
+ return { output: result.text, ...result.truncated ? { outputTruncated: true } : {} };
418
+ }
419
+ function sessionReadFromImport(nativeSessionId, imported) {
420
+ return {
421
+ nativeSessionId,
422
+ model: imported.model,
423
+ resumeCursor: imported.resumeCursor,
424
+ messages: imported.messages.map(({ role, text: text4, createdAt }) => ({
425
+ role,
426
+ text: text4,
427
+ createdAt: Date.parse(createdAt)
428
+ }))
429
+ };
430
+ }
431
+
349
432
  // src/grokInstance.ts
350
- import * as NodeCrypto3 from "node:crypto";
433
+ import * as NodeCrypto4 from "node:crypto";
351
434
  import {
352
- raceAbort as raceAbort4
435
+ raceAbort as raceAbort2
353
436
  } from "@ycodium-ai/plugin-api/executor";
354
- import { nodeStreamsFromHandle as nodeStreamsFromHandle3 } from "@ycodium-ai/plugin-api/process-stdin";
437
+ import { nodeStreamsFromHandle as nodeStreamsFromHandle2 } from "@ycodium-ai/plugin-api/process-stdin";
355
438
 
356
439
  // ../../packages/ycodium-acp-executor/src/executor.ts
357
- import * as NodeCrypto2 from "node:crypto";
440
+ import * as NodeCrypto3 from "node:crypto";
358
441
 
359
442
  // ../../packages/ycodium-acp-executor/src/approvals.ts
360
443
  function createApprovalGate(input2) {
@@ -1459,6 +1542,14 @@ function parseSessionUpdateEvent(params) {
1459
1542
  }
1460
1543
  break;
1461
1544
  }
1545
+ case "usage_update": {
1546
+ const used = upd["used"];
1547
+ const size = upd["size"];
1548
+ if (typeof used === "number" && Number.isSafeInteger(used) && used >= 0 && typeof size === "number" && Number.isSafeInteger(size) && size > 0) {
1549
+ events.push({ _tag: "ContextWindowUpdated", usedTokens: used, maxTokens: size });
1550
+ }
1551
+ break;
1552
+ }
1462
1553
  case "compaction_update": {
1463
1554
  const compactionId = readAcpText(upd, "compactionId");
1464
1555
  const status = readAcpText(upd, "status");
@@ -28224,6 +28315,17 @@ function createExecutorUpdates({
28224
28315
  emitArtifacts(resourceLinkArtifacts(event.content));
28225
28316
  continue;
28226
28317
  }
28318
+ if (event._tag === "ContextWindowUpdated") {
28319
+ emit({
28320
+ type: "thread.token-usage.updated",
28321
+ ...stamp(),
28322
+ provider: options.provider,
28323
+ threadId: options.threadId,
28324
+ ...shared.activeTurnId === void 0 ? {} : { turnId: shared.activeTurnId },
28325
+ payload: { usage: { usedTokens: event.usedTokens, maxTokens: event.maxTokens } }
28326
+ });
28327
+ continue;
28328
+ }
28227
28329
  if (event._tag === "CompactionUpdated") {
28228
28330
  applyCompactionUpdate(event);
28229
28331
  continue;
@@ -28431,7 +28533,7 @@ function defaultNowIso() {
28431
28533
  return (/* @__PURE__ */ new Date()).toISOString();
28432
28534
  }
28433
28535
  function defaultRandomId() {
28434
- return NodeCrypto2.randomUUID();
28536
+ return NodeCrypto3.randomUUID();
28435
28537
  }
28436
28538
  function createAcpExecutor(options) {
28437
28539
  const hooks = { ...defaultVendorHooks, ...options.hooks };
@@ -28946,6 +29048,133 @@ function createAcpThreadOperations(options) {
28946
29048
  };
28947
29049
  }
28948
29050
 
29051
+ // ../../packages/ycodium-executor-common/src/nodeStreams.ts
29052
+ import * as NodeOS4 from "node:os";
29053
+ import * as NodeStream2 from "node:stream";
29054
+ var PEER_CLOSED_STDIN_CODES = /* @__PURE__ */ new Set([
29055
+ "EPIPE",
29056
+ "ECONNRESET",
29057
+ "EOF",
29058
+ "ERR_STREAM_DESTROYED",
29059
+ "ERR_STREAM_WRITE_AFTER_END",
29060
+ "ERR_STREAM_ALREADY_FINISHED"
29061
+ ]);
29062
+ function errorCode(value) {
29063
+ if (typeof value !== "object" || value === null) return void 0;
29064
+ const code = value.code;
29065
+ return typeof code === "string" ? code : void 0;
29066
+ }
29067
+ function asError(value) {
29068
+ return value instanceof Error ? value : new Error(String(value));
29069
+ }
29070
+ function isPeerClosedStdinError(error62) {
29071
+ const code = errorCode(error62);
29072
+ return code !== void 0 && PEER_CLOSED_STDIN_CODES.has(code);
29073
+ }
29074
+ var PeerClosedStdinError = class extends Error {
29075
+ name = "PeerClosedStdinError";
29076
+ code;
29077
+ constructor(operation, cause) {
29078
+ super(
29079
+ `Child process stdin is closed; the ${operation} did not reach the peer.`,
29080
+ cause === void 0 ? void 0 : { cause }
29081
+ );
29082
+ this.code = errorCode(cause) ?? "ERR_STREAM_DESTROYED";
29083
+ }
29084
+ };
29085
+ var ownErrors = {
29086
+ isPeerClosed: isPeerClosedStdinError,
29087
+ peerClosed: (operation, cause) => new PeerClosedStdinError(operation, cause)
29088
+ };
29089
+ function toStreamError(errors, operation, error62) {
29090
+ if (errors.isPeerClosed(error62)) return errors.peerClosed(operation, error62);
29091
+ return asError(error62);
29092
+ }
29093
+ function nodeWritableFromHandle(handle, errors = ownErrors) {
29094
+ return new NodeStream2.Writable({
29095
+ write(chunk, _encoding, callback) {
29096
+ const bytes = typeof chunk === "string" ? new TextEncoder().encode(chunk) : chunk;
29097
+ handle.writeStdin(bytes).then(
29098
+ () => callback(),
29099
+ (error62) => callback(toStreamError(errors, "write", error62))
29100
+ );
29101
+ },
29102
+ final(callback) {
29103
+ handle.closeStdin().then(
29104
+ () => callback(),
29105
+ // 关一条对端已经没了的流是正常收尾,不是失败;真异常照旧交出去。
29106
+ (error62) => callback(errors.isPeerClosed(error62) ? void 0 : toStreamError(errors, "close", error62))
29107
+ );
29108
+ }
29109
+ });
29110
+ }
29111
+ var STDERR_TAIL_MAX_CHARS = 4096;
29112
+ var STDERR_SETTLE_MS = 500;
29113
+ var PAIRING_URL_PATTERN = /https?:\/\/[^\s]*\/pair#[^\s]*/gi;
29114
+ var BEARER_TOKEN_PATTERN = /\bBearer\s+[A-Za-z0-9._\-+=/]+/gi;
29115
+ var BASIC_AUTH_PATTERN = /\bAuthorization:\s*Basic\s+\S+/gi;
29116
+ var API_KEY_HEADER_PATTERN = /\bx-api-key:\s*\S+/gi;
29117
+ var SECRET_TOKEN_PATTERN = /\b(?:sk-[A-Za-z0-9][A-Za-z0-9-]{7,}|ghp_[A-Za-z0-9]+|xox[a-zA-Z]-[A-Za-z0-9-]+)\b/g;
29118
+ function redactStderrExcerpt(text4, environment = process.env) {
29119
+ let result = text4.replaceAll("\0", "");
29120
+ const homes = [environment["HOME"], environment["USERPROFILE"], NodeOS4.homedir()].filter(
29121
+ (value) => typeof value === "string" && value.length > 1
29122
+ );
29123
+ for (const home of new Set(homes)) {
29124
+ result = result.split(home).join("~");
29125
+ }
29126
+ return result.replace(PAIRING_URL_PATTERN, "[pairing-url]").replace(BEARER_TOKEN_PATTERN, "Bearer [redacted]").replace(BASIC_AUTH_PATTERN, "Authorization: Basic [redacted]").replace(API_KEY_HEADER_PATTERN, "x-api-key: [redacted]").replace(SECRET_TOKEN_PATTERN, "[redacted]").trim();
29127
+ }
29128
+ function drainStderrTail(stderr) {
29129
+ let tail = "";
29130
+ const decoder = new TextDecoder();
29131
+ const drained = (async () => {
29132
+ for await (const chunk of stderr) {
29133
+ const next = tail + decoder.decode(chunk, { stream: true });
29134
+ tail = next.length <= STDERR_TAIL_MAX_CHARS ? next : next.slice(-STDERR_TAIL_MAX_CHARS);
29135
+ }
29136
+ })().catch(() => void 0);
29137
+ return async () => {
29138
+ let timer;
29139
+ await Promise.race([
29140
+ drained,
29141
+ new Promise((resolve4) => {
29142
+ timer = setTimeout(resolve4, STDERR_SETTLE_MS);
29143
+ })
29144
+ ]);
29145
+ clearTimeout(timer);
29146
+ return redactStderrExcerpt(tail);
29147
+ };
29148
+ }
29149
+ function nodeStreamsFromHandle(handle, errors = ownErrors) {
29150
+ const readable = new NodeStream2.PassThrough();
29151
+ void (async () => {
29152
+ try {
29153
+ for await (const chunk of handle.stdout) {
29154
+ if (!readable.writable) return;
29155
+ if (!readable.write(chunk)) {
29156
+ await new Promise((resolve4) => {
29157
+ const onDone = () => {
29158
+ readable.off("drain", onDone);
29159
+ readable.off("close", onDone);
29160
+ resolve4();
29161
+ };
29162
+ readable.once("drain", onDone);
29163
+ readable.once("close", onDone);
29164
+ });
29165
+ }
29166
+ }
29167
+ } catch (error62) {
29168
+ readable.destroy(asError(error62));
29169
+ return;
29170
+ }
29171
+ if (readable.writable) readable.end();
29172
+ })();
29173
+ const settledStderrTail = drainStderrTail(handle.stderr);
29174
+ const writable = nodeWritableFromHandle(handle, errors);
29175
+ return { readable, writable, stderrTail: settledStderrTail };
29176
+ }
29177
+
28949
29178
  // ../../packages/ycodium-acp-executor/src/mcp-servers.ts
28950
29179
  function toAcpMcpServers(entries) {
28951
29180
  return (entries ?? []).map(
@@ -29223,28 +29452,53 @@ async function collectProbeProcess(child, input2) {
29223
29452
  }
29224
29453
  var MAX_VERSION_OUTPUT_BYTES = 64 * 1024;
29225
29454
 
29226
- // ../../packages/ycodium-jsonl-stream/src/sessionTranscript.ts
29227
- var SESSION_IMPORT_ACTIVITY_TEXT_LIMIT = 32e3;
29228
- function bounded(value, tail = false) {
29229
- if (value.length <= SESSION_IMPORT_ACTIVITY_TEXT_LIMIT) return { text: value, truncated: false };
29230
- const offset = tail ? value.length - SESSION_IMPORT_ACTIVITY_TEXT_LIMIT : SESSION_IMPORT_ACTIVITY_TEXT_LIMIT;
29231
- const character = value.charCodeAt(offset);
29232
- const previous = value.charCodeAt(offset - 1);
29233
- const splitPair = character >= 56320 && character <= 57343 && previous >= 55296 && previous <= 56319;
29234
- return {
29235
- text: tail ? value.slice(offset + (splitPair ? 1 : 0)) : value.slice(0, offset - (splitPair ? 1 : 0)),
29236
- truncated: true
29237
- };
29238
- }
29239
- function inputPayload(input2) {
29240
- if (input2 === void 0) return {};
29241
- const result = bounded(input2);
29242
- return { input: result.text, ...result.truncated ? { inputTruncated: true } : {} };
29455
+ // ../../packages/ycodium-executor-common/src/raceAbort.ts
29456
+ async function raceAbort(pending, signal) {
29457
+ if (signal === void 0) return pending;
29458
+ void pending.catch(() => void 0);
29459
+ if (signal.aborted) throw new Error("aborted");
29460
+ let onAbort;
29461
+ const aborted2 = new Promise((_resolve, reject) => {
29462
+ onAbort = () => reject(new Error("aborted"));
29463
+ signal.addEventListener("abort", onAbort, { once: true });
29464
+ });
29465
+ try {
29466
+ return await Promise.race([pending, aborted2]);
29467
+ } finally {
29468
+ signal.removeEventListener("abort", onAbort);
29469
+ }
29243
29470
  }
29244
- function outputPayload(output2) {
29245
- if (output2 === void 0) return {};
29246
- const result = bounded(output2, true);
29247
- return { output: result.text, ...result.truncated ? { outputTruncated: true } : {} };
29471
+
29472
+ // ../../packages/ycodium-acp-executor/src/probe-process.ts
29473
+ async function runAcpProbeProcess(input2) {
29474
+ const spawned = await input2.spawn(input2.cwd);
29475
+ if (spawned.kind !== "spawned") return spawned;
29476
+ const handle = spawned.handle;
29477
+ let handshake;
29478
+ try {
29479
+ const streams = nodeStreamsFromHandle(handle);
29480
+ handshake = await raceAbort(
29481
+ openAcpProbeHandshake({
29482
+ readable: streams.readable,
29483
+ writable: streams.writable,
29484
+ clientInfo: input2.clientInfo,
29485
+ requestTimeoutMs: input2.requestTimeoutMs,
29486
+ ...input2.subagentSessions === void 0 ? {} : { subagentSessions: input2.subagentSessions }
29487
+ }),
29488
+ input2.signal
29489
+ );
29490
+ return { kind: "ok", value: await input2.run(handshake) };
29491
+ } catch (error62) {
29492
+ return {
29493
+ kind: "threw",
29494
+ error: error62,
29495
+ handshakeOpened: handshake !== void 0,
29496
+ initializeResult: handshake?.initializeResult
29497
+ };
29498
+ } finally {
29499
+ await handshake?.close().catch(() => void 0);
29500
+ await handle.kill("SIGTERM").catch(() => void 0);
29501
+ }
29248
29502
  }
29249
29503
 
29250
29504
  // ../../packages/ycodium-instance-config/src/launchArgs.ts
@@ -29326,14 +29580,14 @@ function readTurnSelection(selection, effortOptionId) {
29326
29580
  }
29327
29581
  function readEnvironment(value) {
29328
29582
  if (!Array.isArray(value)) return {};
29329
- const env = {};
29583
+ const entries = [];
29330
29584
  for (const entry of value) {
29331
29585
  if (!isRecord8(entry)) continue;
29332
29586
  const name = readTrimmed(entry["name"]);
29333
29587
  if (name.length === 0) continue;
29334
- env[name] = readString(entry["value"]);
29588
+ entries.push([name, readString(entry["value"])]);
29335
29589
  }
29336
- return env;
29590
+ return Object.fromEntries(entries);
29337
29591
  }
29338
29592
  function instanceSettings(config2) {
29339
29593
  if (!isRecord8(config2)) return {};
@@ -29368,132 +29622,21 @@ function parseGrokInstanceConfig(config2) {
29368
29622
  }
29369
29623
 
29370
29624
  // src/grokSignIn.ts
29371
- import {
29372
- raceAbort as raceAbort2
29373
- } from "@ycodium-ai/plugin-api/executor";
29374
-
29375
- // src/deviceCodeOutput.ts
29376
- var OUTPUT_QUIET_MS = 3e3;
29377
- var SILENT_CAP_MS = 3e4;
29378
- var DEVICE_CODE_URL = /https?:\/\/\S+/;
29379
- var DEVICE_CODE_VALUE = /\b([A-Z0-9]{4,}(?:-[A-Z0-9]{4,})+)\b/;
29380
- var deviceCodeUrl = (output2) => DEVICE_CODE_URL.exec(output2)?.[0];
29381
- var deviceCodeValue = (output2) => DEVICE_CODE_VALUE.exec(output2)?.[1];
29382
- var hasDeviceCode = (output2) => deviceCodeUrl(output2) !== void 0 && deviceCodeValue(output2) !== void 0;
29383
- function readDeviceCodeOutput(stdout, onText) {
29384
- const collected = [];
29385
- let onCodeFound;
29386
- const codeFound = new Promise((resolve4) => {
29387
- onCodeFound = resolve4;
29388
- });
29389
- let quietTimer;
29390
- let onQuiet;
29391
- const outputWentQuiet = new Promise((resolve4) => {
29392
- onQuiet = resolve4;
29393
- });
29394
- const text4 = (async () => {
29395
- const decoder = new TextDecoder();
29396
- for await (const chunk of stdout) {
29397
- const piece = decoder.decode(chunk, { stream: true });
29398
- collected.push(piece);
29399
- onText(piece);
29400
- if (onCodeFound !== void 0 && hasDeviceCode(collected.join(""))) {
29401
- onCodeFound();
29402
- onCodeFound = void 0;
29403
- }
29404
- if (onQuiet !== void 0) {
29405
- clearTimeout(quietTimer);
29406
- quietTimer = setTimeout(() => onQuiet?.(), OUTPUT_QUIET_MS);
29407
- }
29408
- }
29409
- return collected.join("");
29410
- })();
29411
- const code = (async () => {
29412
- let silentCap;
29413
- await Promise.race([
29414
- codeFound,
29415
- text4.then(() => void 0),
29416
- outputWentQuiet,
29417
- new Promise((resolve4) => {
29418
- silentCap = setTimeout(resolve4, SILENT_CAP_MS);
29419
- })
29420
- ]);
29421
- clearTimeout(silentCap);
29422
- clearTimeout(quietTimer);
29423
- onQuiet = void 0;
29424
- const output2 = collected.join("");
29425
- const verificationUrl = deviceCodeUrl(output2);
29426
- const userCode = deviceCodeValue(output2);
29427
- return {
29428
- ...userCode === void 0 ? {} : { userCode },
29429
- ...verificationUrl === void 0 ? {} : { verificationUrl }
29430
- };
29431
- })();
29432
- return { text: text4, code };
29433
- }
29434
-
29435
- // src/grokSignIn.ts
29625
+ import { createCliDeviceSignIn } from "@ycodium-ai/plugin-api/runtime-maintenance";
29436
29626
  function makeGrokSignIn(input2) {
29437
- const { host, recipe } = input2;
29438
- const operations = /* @__PURE__ */ new Map();
29439
- const signIn = {
29440
- start: async (signal) => {
29441
- if (recipe.binaryPath.length === 0) throw new Error("Grok program path is not configured");
29442
- const env = buildSignInEnv(recipe);
29443
- const handle = await host.process.spawn({
29444
- program: recipe.binaryPath,
29445
- args: [...GROK_CARD.deviceCodeSignInArgs],
29446
- owner: { bindingId: host.bindingId },
29447
- ...Object.keys(env).length > 0 ? { env } : {},
29448
- ...signal === void 0 ? {} : { signal }
29449
- });
29450
- const output2 = readDeviceCodeOutput(
29451
- handle.stdout,
29452
- (text4) => host.log.info("sign-in output", { text: text4 })
29453
- );
29454
- const operationId = `grok-sign-in-${Date.now().toString(36)}-${operations.size}`;
29455
- let closing;
29456
- const operation = {
29457
- handle,
29458
- close: () => closing ??= Promise.resolve().then(async () => {
29459
- await handle.kill("SIGTERM").catch(() => void 0);
29460
- await Promise.allSettled([handle.exited, output2.text]);
29461
- }).finally(() => {
29462
- if (operations.get(operationId) === operation) operations.delete(operationId);
29463
- })
29464
- };
29465
- operations.set(operationId, operation);
29466
- try {
29467
- const code = await raceAbort2(output2.code, signal);
29468
- if (signal?.aborted || input2.isDisposed()) throw new Error("Grok sign-in cancelled");
29469
- return { operationId, ...code };
29470
- } catch (error62) {
29471
- await operation.close();
29472
- throw error62;
29473
- }
29474
- },
29475
- cancel: async (operationId) => {
29476
- await operations.get(operationId)?.close();
29477
- },
29478
- verify: async (signal) => {
29479
- const active2 = [...operations.values()];
29480
- try {
29481
- for (const operation of active2) {
29482
- const code = await raceAbort2(operation.handle.exited, signal);
29483
- if (code !== 0) throw new Error(`Grok sign-in exited with code ${String(code)}`);
29484
- }
29485
- return await input2.probe(signal);
29486
- } finally {
29487
- await Promise.all(active2.map((operation) => operation.close()));
29488
- }
29489
- }
29490
- };
29491
- return {
29492
- signIn,
29493
- close: async () => {
29494
- await Promise.all([...operations.values()].map((operation) => operation.close()));
29627
+ return createCliDeviceSignIn({
29628
+ ...input2,
29629
+ name: "Grok",
29630
+ program: input2.recipe.binaryPath,
29631
+ args: GROK_CARD.deviceCodeSignInArgs,
29632
+ env: buildSignInEnv(input2.recipe),
29633
+ stream: "stdout",
29634
+ parse: (text4) => {
29635
+ const verificationUrl = /https?:\/\/\S+/.exec(text4)?.[0];
29636
+ const userCode = /\b([A-Z0-9]{4,}(?:-[A-Z0-9]{4,})+)\b/.exec(text4)?.[1];
29637
+ return verificationUrl && userCode ? { verificationUrl, userCode } : void 0;
29495
29638
  }
29496
- };
29639
+ });
29497
29640
  }
29498
29641
 
29499
29642
  // src/grokQuota.ts
@@ -29503,39 +29646,47 @@ import "@ycodium-ai/plugin-api/usage";
29503
29646
 
29504
29647
  // ../../packages/ycodium-credential-account/src/quotaRequest.ts
29505
29648
  import { parseRetryAfterMs } from "@ycodium-ai/plugin-api/usage";
29506
- async function requestQuotaJson(input2) {
29649
+ async function requestQuotaJsonValue(input2) {
29507
29650
  let response;
29508
29651
  try {
29509
29652
  response = await input2.fetch(input2.url, {
29510
29653
  headers: input2.headers,
29654
+ ...input2.method === void 0 ? {} : { method: input2.method },
29655
+ ...input2.body === void 0 ? {} : { body: input2.body },
29656
+ ...input2.redirect === void 0 ? {} : { redirect: input2.redirect },
29511
29657
  signal: AbortSignal.any([
29512
29658
  ...input2.signal === void 0 ? [] : [input2.signal],
29513
29659
  AbortSignal.timeout(input2.timeoutMs)
29514
29660
  ])
29515
29661
  });
29516
- } catch {
29662
+ } catch (cause) {
29663
+ if (input2.propagateCallerAbort && input2.signal?.aborted) throw cause;
29517
29664
  return { status: "unavailable", reason: "unreachable" };
29518
29665
  }
29519
- if (response.status === 401 || response.status === 403) {
29520
- return { status: "unavailable", reason: "authRejected" };
29521
- }
29522
- if (response.status === 429) {
29523
- const retryAfterMs = parseRetryAfterMs(response.headers.get("retry-after"), input2.now());
29524
- return {
29525
- status: "unavailable",
29526
- reason: "rateLimited",
29527
- ...retryAfterMs === null ? {} : { retryAfterMs }
29528
- };
29666
+ if (!response.ok) {
29667
+ void response.body?.cancel().catch(() => void 0);
29668
+ if (response.status === 429) {
29669
+ const retryAfterMs = parseRetryAfterMs(response.headers.get("retry-after"), input2.now());
29670
+ return {
29671
+ status: "unavailable",
29672
+ reason: "rateLimited",
29673
+ ...retryAfterMs === null ? {} : { retryAfterMs }
29674
+ };
29675
+ }
29676
+ const reason = input2.statusReasons?.[response.status] ?? (response.status === 401 || response.status === 403 ? "authRejected" : "unreachable");
29677
+ return { status: "unavailable", reason };
29529
29678
  }
29530
- if (!response.ok) return { status: "unavailable", reason: "unreachable" };
29531
- let body;
29532
29679
  try {
29533
- body = JSON.parse(await response.text());
29534
- } catch {
29680
+ return { body: JSON.parse(await response.text()) };
29681
+ } catch (cause) {
29682
+ if (input2.propagateCallerAbort && input2.signal?.aborted) throw cause;
29535
29683
  return { status: "unavailable", reason: "unreachable" };
29536
29684
  }
29537
- if (!isRecord(body)) return { status: "unavailable", reason: "unreachable" };
29538
- return { body };
29685
+ }
29686
+ async function requestQuotaJson(input2) {
29687
+ const answer = await requestQuotaJsonValue(input2);
29688
+ if (!("body" in answer)) return answer;
29689
+ return isRecord(answer.body) ? { body: answer.body } : { status: "unavailable", reason: "unreachable" };
29539
29690
  }
29540
29691
 
29541
29692
  // ../../packages/ycodium-credential-account/src/quotaJson.ts
@@ -29549,6 +29700,7 @@ var parseJson = (raw) => {
29549
29700
  return null;
29550
29701
  }
29551
29702
  };
29703
+ var clampPercent = (value) => Math.min(100, Math.max(0, value));
29552
29704
 
29553
29705
  // src/grokQuota.ts
29554
29706
  var GROK_USAGE_URL = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
@@ -29565,7 +29717,6 @@ var extractGrokToken = (auth) => {
29565
29717
  }
29566
29718
  return null;
29567
29719
  };
29568
- var clampPercent = (value) => Math.min(100, Math.max(0, value));
29569
29720
  var grokQuotaWindows = (body) => {
29570
29721
  const config2 = asObject(asObject(body)?.["config"]);
29571
29722
  const productUsage = config2?.["productUsage"];
@@ -30668,7 +30819,7 @@ var grokPromptSettlement = {
30668
30819
  };
30669
30820
 
30670
30821
  // src/grokSkills.ts
30671
- import * as NodeOS4 from "node:os";
30822
+ import * as NodeOS5 from "node:os";
30672
30823
  import * as NodePath7 from "node:path";
30673
30824
  var INSPECT_TIMEOUT_MS = 15e3;
30674
30825
  var MAX_INSPECT_OUTPUT_BYTES = 4 * 1024 * 1024;
@@ -30729,7 +30880,7 @@ var runGrokInspect = async (input2) => {
30729
30880
  };
30730
30881
  async function probeGrokSkills(input2) {
30731
30882
  try {
30732
- return await runGrokInspect({ ...input2, cwd: NodeOS4.homedir() });
30883
+ return await runGrokInspect({ ...input2, cwd: NodeOS5.homedir() });
30733
30884
  } catch {
30734
30885
  return [];
30735
30886
  }
@@ -30800,7 +30951,7 @@ function grokOpenCommands(session) {
30800
30951
  // src/modelCacheRefresh.ts
30801
30952
  import {
30802
30953
  runProcessOperation as runProcessOperation2,
30803
- OperationCleanupError as OperationCleanupError2
30954
+ isOperationCleanupError as isOperationCleanupError2
30804
30955
  } from "@ycodium-ai/plugin-api/process-operation";
30805
30956
  import * as NodeFS4 from "node:fs";
30806
30957
  import * as NodePath8 from "node:path";
@@ -30810,12 +30961,6 @@ import {
30810
30961
  throwIfExecutorSpawnAborted
30811
30962
  } from "@ycodium-ai/plugin-api/executor";
30812
30963
 
30813
- // src/probeModels.ts
30814
- import {
30815
- raceAbort as raceAbort3
30816
- } from "@ycodium-ai/plugin-api/executor";
30817
- import { nodeStreamsFromHandle as nodeStreamsFromHandle2 } from "@ycodium-ai/plugin-api/process-stdin";
30818
-
30819
30964
  // ../../packages/ycodium-instance-config/src/probeProcess.ts
30820
30965
  import {
30821
30966
  describeExecutorSpawnFailure,
@@ -30823,7 +30968,7 @@ import {
30823
30968
  ExecutorSpawnRefusedError
30824
30969
  } from "@ycodium-ai/plugin-api/executor";
30825
30970
  import {
30826
- OperationCleanupError,
30971
+ isOperationCleanupError,
30827
30972
  runProcessOperation
30828
30973
  } from "@ycodium-ai/plugin-api/process-operation";
30829
30974
  async function spawnProbeProcess(host, launch) {
@@ -30855,10 +31000,10 @@ async function readCliVersionCommand(host, input2) {
30855
31000
  timeoutMs: input2.timeoutMs,
30856
31001
  maxOutputBytes: 64 * 1024
30857
31002
  });
30858
- if (run.exitCode !== 0) return null;
31003
+ if (run.exitCode !== 0 && !input2.acceptNonzeroExit) return null;
30859
31004
  return input2.parse(run.stdout) ?? input2.parse(run.stderr);
30860
31005
  } catch (error62) {
30861
- if (error62 instanceof OperationCleanupError || input2.signal?.aborted) throw error62;
31006
+ if (isOperationCleanupError(error62) || input2.signal?.aborted) throw error62;
30862
31007
  return null;
30863
31008
  }
30864
31009
  }
@@ -30881,34 +31026,24 @@ function grokProbeModels(initializeResult) {
30881
31026
  }
30882
31027
  async function probeGrokModels(input2) {
30883
31028
  const { recipe, host, env } = input2;
30884
- const spawned = await spawnProbeProcess(host, {
30885
- program: recipe.binaryPath,
30886
- args: tokenizeShellWords(recipe.launchArgs),
31029
+ const attempt = await runAcpProbeProcess({
30887
31030
  cwd: process.cwd(),
30888
- env,
30889
- ...input2.signal === void 0 ? {} : { signal: input2.signal }
31031
+ signal: input2.signal,
31032
+ clientInfo: GROK_CLIENT_INFO,
31033
+ requestTimeoutMs: PROBE_REQUEST_TIMEOUT_MS,
31034
+ spawn: (cwd) => spawnProbeProcess(host, {
31035
+ program: recipe.binaryPath,
31036
+ args: tokenizeShellWords(recipe.launchArgs),
31037
+ cwd,
31038
+ env,
31039
+ ...input2.signal === void 0 ? {} : { signal: input2.signal }
31040
+ }),
31041
+ run: async (handshake) => grokProbeModels(handshake.initializeResult)
30890
31042
  });
30891
- if (spawned.kind === "not-started") return spawned;
30892
- const { handle } = spawned;
30893
- let handshake;
30894
- try {
30895
- const { readable, writable } = nodeStreamsFromHandle2(handle);
30896
- handshake = await raceAbort3(
30897
- openAcpProbeHandshake({
30898
- readable,
30899
- writable,
30900
- clientInfo: GROK_CLIENT_INFO,
30901
- requestTimeoutMs: PROBE_REQUEST_TIMEOUT_MS
30902
- }),
30903
- input2.signal
30904
- );
30905
- return { kind: "answered", models: grokProbeModels(handshake.initializeResult) };
30906
- } catch (error62) {
30907
- return { kind: "failed", detail: acpProbeFailureDetail(error62) };
30908
- } finally {
30909
- await handshake?.close().catch(() => void 0);
30910
- await handle.kill("SIGTERM").catch(() => void 0);
30911
- }
31043
+ if (attempt.kind === "not-started") return attempt;
31044
+ if (attempt.kind === "threw")
31045
+ return { kind: "failed", detail: acpProbeFailureDetail(attempt.error) };
31046
+ return { kind: "answered", models: attempt.value };
30912
31047
  }
30913
31048
  async function probeGrokVersion(input2) {
30914
31049
  const { recipe, host, env, signal } = input2;
@@ -30962,7 +31097,7 @@ async function runGrokModelsCommand(input2) {
30962
31097
  }
30963
31098
  return true;
30964
31099
  } catch (error62) {
30965
- if (error62 instanceof ExecutorSpawnAbortedError2 || error62 instanceof OperationCleanupError2 || input2.signal?.aborted)
31100
+ if (error62 instanceof ExecutorSpawnAbortedError2 || isOperationCleanupError2(error62) || input2.signal?.aborted)
30966
31101
  throw error62;
30967
31102
  host.log.warn("grok models failed; keeping the previous model list", {
30968
31103
  detail: error62 instanceof ExecutorSpawnRefusedError2 ? "process limit" : String(error62)
@@ -30984,6 +31119,7 @@ function runCoalescedModelsCommand(cachePath, force, run) {
30984
31119
  if (modelsCommandSlots.get(cachePath)?.followUp === followUp) {
30985
31120
  modelsCommandSlots.delete(cachePath);
30986
31121
  }
31122
+ }).catch(() => {
30987
31123
  });
30988
31124
  return followUp;
30989
31125
  }
@@ -30995,6 +31131,7 @@ function runCoalescedModelsCommand(cachePath, force, run) {
30995
31131
  void current.finally(() => {
30996
31132
  if (slot.followUp !== void 0) return;
30997
31133
  if (modelsCommandSlots.get(cachePath) === slot) modelsCommandSlots.delete(cachePath);
31134
+ }).catch(() => {
30998
31135
  });
30999
31136
  return current;
31000
31137
  }
@@ -31045,7 +31182,7 @@ function createGrokModelCatalog(input2) {
31045
31182
  throw new Error("grok models failed");
31046
31183
  }
31047
31184
  } catch (error62) {
31048
- if (error62 instanceof ExecutorSpawnAbortedError2 || error62 instanceof OperationCleanupError2 || request.signal?.aborted)
31185
+ if (error62 instanceof ExecutorSpawnAbortedError2 || isOperationCleanupError2(error62) || request.signal?.aborted)
31049
31186
  throw error62;
31050
31187
  if (request.surfaceErrors === true) throw error62;
31051
31188
  input2.host.log.warn("grok model cache refresh failed; keeping the previous model list", {
@@ -31123,10 +31260,37 @@ var grokPermissionStatement = ({
31123
31260
  };
31124
31261
 
31125
31262
  // src/nativeSessions.ts
31126
- import * as NodeFS6 from "node:fs";
31263
+ import * as NodeFS7 from "node:fs";
31127
31264
  import * as NodeFSP from "node:fs/promises";
31128
- import * as NodePath10 from "node:path";
31265
+ import * as NodePath11 from "node:path";
31129
31266
  import * as NodeReadline from "node:readline";
31267
+
31268
+ // ../../packages/ycodium-jsonl-stream/src/sessionDirectory.ts
31269
+ import * as NodeFS6 from "node:fs";
31270
+ import * as NodePath10 from "node:path";
31271
+ function readableStoragePath(home) {
31272
+ try {
31273
+ return NodeFS6.realpathSync.native(home);
31274
+ } catch {
31275
+ return home;
31276
+ }
31277
+ }
31278
+ function isAbsoluteDirectory(path) {
31279
+ if (!NodePath10.isAbsolute(path)) return false;
31280
+ if (NodePath10.sep !== "\\") return true;
31281
+ const { root } = NodePath10.parse(path);
31282
+ return root.length > 1;
31283
+ }
31284
+ var directoryKey = (directory) => {
31285
+ const resolved = NodePath10.resolve(directory);
31286
+ return NodePath10.sep === "\\" ? resolved.toLowerCase() : resolved;
31287
+ };
31288
+ function matchesSessionDirectory(rootKey, cwd, mode) {
31289
+ const relative2 = NodePath10.relative(rootKey, directoryKey(cwd));
31290
+ return relative2 === "" || mode === "scan" && relative2 !== ".." && !relative2.startsWith(`..${NodePath10.sep}`) && !NodePath10.isAbsolute(relative2);
31291
+ }
31292
+
31293
+ // src/nativeSessions.ts
31130
31294
  var sessionIdPattern = /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/iu;
31131
31295
  function parseRecord(raw) {
31132
31296
  try {
@@ -31147,36 +31311,19 @@ async function directories(path) {
31147
31311
  throw error62;
31148
31312
  }
31149
31313
  }
31150
- function readableStoragePath(home) {
31151
- try {
31152
- return NodeFS6.realpathSync.native(home);
31153
- } catch {
31154
- return home;
31155
- }
31156
- }
31157
- function isAbsoluteDirectory(path) {
31158
- if (!NodePath10.isAbsolute(path)) return false;
31159
- if (NodePath10.sep !== "\\") return true;
31160
- const { root } = NodePath10.parse(path);
31161
- return root.length > 1;
31162
- }
31163
- var directoryKey = (directory) => {
31164
- const resolved = NodePath10.resolve(directory);
31165
- return NodePath10.sep === "\\" ? resolved.toLowerCase() : resolved;
31166
- };
31167
31314
  async function findSessions(home, cwd, signal, nativeSessionId) {
31168
31315
  signal?.throwIfAborted();
31169
31316
  const expectedCwd = directoryKey(cwd);
31170
31317
  const result = [];
31171
- const root = NodePath10.join(home, "sessions");
31318
+ const root = NodePath11.join(home, "sessions");
31172
31319
  for (const workspace of await directories(root)) {
31173
- const workspacePath = NodePath10.join(root, workspace);
31320
+ const workspacePath = NodePath11.join(root, workspace);
31174
31321
  for (const id of await directories(workspacePath)) {
31175
31322
  signal?.throwIfAborted();
31176
31323
  if (!sessionIdPattern.test(id) || nativeSessionId !== void 0 && nativeSessionId !== id)
31177
31324
  continue;
31178
- const sessionPath = NodePath10.join(workspacePath, id);
31179
- const summaryPath = NodePath10.join(sessionPath, "summary.json");
31325
+ const sessionPath = NodePath11.join(workspacePath, id);
31326
+ const summaryPath = NodePath11.join(sessionPath, "summary.json");
31180
31327
  try {
31181
31328
  if (!(await NodeFSP.lstat(summaryPath)).isFile()) continue;
31182
31329
  const summary = parseRecord(
@@ -31185,10 +31332,13 @@ async function findSessions(home, cwd, signal, nativeSessionId) {
31185
31332
  const info = summary?.info;
31186
31333
  if (!summary || !isRecord11(info) || info.id !== id || typeof info.cwd !== "string" || !isAbsoluteDirectory(info.cwd))
31187
31334
  continue;
31188
- const relative2 = NodePath10.relative(expectedCwd, directoryKey(info.cwd));
31189
- if (relative2 !== "" && (nativeSessionId !== void 0 || relative2 === ".." || relative2.startsWith(`..${NodePath10.sep}`) || NodePath10.isAbsolute(relative2)))
31335
+ if (!matchesSessionDirectory(
31336
+ expectedCwd,
31337
+ info.cwd,
31338
+ nativeSessionId === void 0 ? "scan" : "read"
31339
+ ))
31190
31340
  continue;
31191
- const updates = NodePath10.join(sessionPath, "updates.jsonl");
31341
+ const updates = NodePath11.join(sessionPath, "updates.jsonl");
31192
31342
  if (!(await NodeFSP.lstat(updates)).isFile()) continue;
31193
31343
  const updatedAt = Date.parse(trimmed2(summary.updated_at) ?? "");
31194
31344
  result.push({
@@ -31216,7 +31366,7 @@ function toolOutput(content) {
31216
31366
  return output2.length === 0 ? void 0 : output2;
31217
31367
  }
31218
31368
  async function readTranscript(session, signal, summaryOnly = false) {
31219
- const stream = NodeFS6.createReadStream(session.updates, { signal });
31369
+ const stream = NodeFS7.createReadStream(session.updates, { signal });
31220
31370
  const lines = NodeReadline.createInterface({ input: stream, crlfDelay: Infinity });
31221
31371
  const messages = [];
31222
31372
  const activities = [];
@@ -31451,9 +31601,9 @@ var createGrokInstance = (config2, host) => {
31451
31601
  }
31452
31602
  prepareGrokFollowUpSteer(resolveAccountHomePath(recipe, recipe.homePath), host.log);
31453
31603
  const env = spawnEnv();
31454
- const version2 = await raceAbort4(modelCatalog.readCliVersion(signal), signal);
31604
+ const version2 = await raceAbort2(modelCatalog.readCliVersion(signal), signal);
31455
31605
  if (signal?.aborted) throw new Error("aborted");
31456
- await raceAbort4(
31606
+ await raceAbort2(
31457
31607
  modelCatalog.refreshModelCatalog({
31458
31608
  force: false,
31459
31609
  cliVersion: version2,
@@ -31462,7 +31612,7 @@ var createGrokInstance = (config2, host) => {
31462
31612
  signal
31463
31613
  );
31464
31614
  if (signal?.aborted) throw new Error("aborted");
31465
- const [outcome, skills] = await raceAbort4(
31615
+ const [outcome, skills] = await raceAbort2(
31466
31616
  Promise.all([
31467
31617
  probeGrokModels({
31468
31618
  recipe,
@@ -31518,19 +31668,7 @@ var createGrokInstance = (config2, host) => {
31518
31668
  sessions: {
31519
31669
  ...sessions,
31520
31670
  scan: ({ projectId, directory, signal }) => sessions.scan({ directory: directory ?? host.workspacePath(projectId), signal }),
31521
- read: async (input2) => {
31522
- const imported = await sessions.readImport(input2);
31523
- return {
31524
- nativeSessionId: input2.nativeSessionId,
31525
- model: imported.model,
31526
- resumeCursor: imported.resumeCursor,
31527
- messages: imported.messages.map(({ role, text: text4, createdAt }) => ({
31528
- role,
31529
- text: text4,
31530
- createdAt: Date.parse(createdAt)
31531
- }))
31532
- };
31533
- }
31671
+ read: async (input2) => sessionReadFromImport(input2.nativeSessionId, await sessions.readImport(input2))
31534
31672
  },
31535
31673
  probe,
31536
31674
  readCliVersion: (signal) => modelCatalog.readCliVersion(signal),
@@ -31586,7 +31724,7 @@ var createGrokInstance = (config2, host) => {
31586
31724
  owner: { bindingId: host.bindingId },
31587
31725
  ...Object.keys(env).length > 0 ? { env } : {}
31588
31726
  });
31589
- const { readable, writable, stderrTail } = nodeStreamsFromHandle3(handle);
31727
+ const { readable, writable, stderrTail } = nodeStreamsFromHandle2(handle);
31590
31728
  const resume = acpResumeFrom(input2, RESUME_SCHEMA_VERSION);
31591
31729
  const requestedModelId = modelIdFromSelection(input2.modelSelection);
31592
31730
  let initializeResult;
@@ -31703,7 +31841,7 @@ var createGrokInstance = (config2, host) => {
31703
31841
  if (caveat !== void 0) {
31704
31842
  input2.events.emit({
31705
31843
  type: "runtime.warning",
31706
- eventId: NodeCrypto3.randomUUID(),
31844
+ eventId: NodeCrypto4.randomUUID(),
31707
31845
  provider: GROK_DRIVER_KIND,
31708
31846
  providerInstanceId: host.instanceId,
31709
31847
  threadId: input2.threadId,
@@ -31780,23 +31918,11 @@ var index_default = definePlugin({
31780
31918
  apiVersion: PLUGIN_API_VERSION,
31781
31919
  executors,
31782
31920
  activate(ctx) {
31783
- ctx.command({
31784
- name: "effectiveConfig",
31785
- description: "Settings form: the account directory an empty path resolves to on this machine.",
31786
- scope: "read",
31787
- payloadSchema: EXECUTOR_EFFECTIVE_PAYLOAD_SCHEMA,
31788
- handle: async (payload) => {
31789
- const request = readExecutorEffectiveRequest(payload);
31790
- return {
31791
- homePath: executorHomeEffectiveValue(
31792
- "GROK_HOME",
31793
- request,
31794
- process.env,
31795
- (value) => resolveGrokHomePath(value ?? "")
31796
- )
31797
- };
31798
- }
31799
- });
31921
+ registerEffectiveHomeCommand(
31922
+ ctx,
31923
+ GROK_CARD.homeEnvVar,
31924
+ (value) => resolveGrokHomePath(value ?? "")
31925
+ );
31800
31926
  ctx.log.info("grok executor ready");
31801
31927
  }
31802
31928
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-grok",
3
- "version": "0.2.5557",
3
+ "version": "0.2.5634",
4
4
  "description": "Grok executor: grok CLI over Agent Client Protocol stdio.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -21,12 +21,12 @@
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.5557",
24
+ "@ycodium-ai/plugin-api": "0.2.0",
25
+ "ycodium-acp-executor": "0.2.5634",
25
26
  "ycodium-credential-account": "0.0.0",
26
- "ycodium-instance-config": "0.0.0",
27
27
  "ycodium-jsonl-stream": "0.0.0",
28
28
  "ycodium-executor-testing": "0.0.0",
29
- "ycodium-acp-executor": "0.2.0"
29
+ "ycodium-instance-config": "0.0.0"
30
30
  },
31
31
  "ycodium": {
32
32
  "plugin": "./dist/index.js",