@ycodium-ai/agent-grok 0.2.2984 → 0.2.2990

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 +72 -60
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -158,10 +158,7 @@ var GROK_CARD = {
158
158
  };
159
159
 
160
160
  // src/grokInstance.ts
161
- import * as NodeCrypto2 from "node:crypto";
162
- import * as NodeOS2 from "node:os";
163
- import * as NodePath5 from "node:path";
164
- import { mergeLaunchEnv } from "@ycodium-ai/plugin-api/executor";
161
+ import * as NodeCrypto3 from "node:crypto";
165
162
  import { nodeStreamsFromHandle as nodeStreamsFromHandle2 } from "@ycodium-ai/plugin-api/process-stdin";
166
163
 
167
164
  // ../../packages/ycodium-acp-executor/src/executor.ts
@@ -23570,6 +23567,12 @@ var AcpExecutorDisposedError = class extends AcpExecutorError {
23570
23567
  this.name = "AcpExecutorDisposedError";
23571
23568
  }
23572
23569
  };
23570
+ var AcpExecutorTurnEndedError = class extends AcpExecutorError {
23571
+ constructor(message = "The target turn has ended. The message was not sent.") {
23572
+ super("provider-rejected", message);
23573
+ this.name = "AcpExecutorTurnEndedError";
23574
+ }
23575
+ };
23573
23576
  var AcpExecutorNotStartedError = class extends AcpExecutorError {
23574
23577
  constructor(message = "ACP session has not been started") {
23575
23578
  super("not-started", message);
@@ -24335,6 +24338,12 @@ function asTrimmedString(value) {
24335
24338
  const trimmed3 = value.trim();
24336
24339
  return trimmed3.length > 0 ? trimmed3 : void 0;
24337
24340
  }
24341
+ var selectPromptTurnId = (input2, activeTurnId, freshTurnId) => {
24342
+ const target = input2.expectedActiveTurnId;
24343
+ if (target === void 0) return input2.turnId ?? activeTurnId ?? freshTurnId();
24344
+ if (activeTurnId !== target) throw new AcpExecutorTurnEndedError();
24345
+ return target;
24346
+ };
24338
24347
 
24339
24348
  // ../../packages/ycodium-acp-executor/src/tool-presentation.ts
24340
24349
  function normalizeCommandValue(value) {
@@ -26419,7 +26428,7 @@ function createAcpExecutor(options) {
26419
26428
  await threadMutex.acquire();
26420
26429
  try {
26421
26430
  failIfDisposed();
26422
- turnId = input2.turnId ?? (promptsInFlight > 0 ? activeTurnId : void 0) ?? randomId();
26431
+ turnId = selectPromptTurnId(input2, promptsInFlight > 0 ? activeTurnId : void 0, randomId);
26423
26432
  promptsInFlight += 1;
26424
26433
  activeTurnId = turnId;
26425
26434
  status = "running";
@@ -26441,20 +26450,20 @@ function createAcpExecutor(options) {
26441
26450
  let response;
26442
26451
  try {
26443
26452
  failIfDisposed();
26444
- if (interruptedTurnIds.has(turnId)) {
26453
+ const queuedTurnId = turnId;
26454
+ const isStale = () => interruptedTurnIds.has(queuedTurnId) || input2.expectedActiveTurnId !== void 0 && activeTurnId !== queuedTurnId;
26455
+ if (!isStale()) {
26456
+ modelSelectionState = await applyRequestedModel({
26457
+ state: modelSelectionState,
26458
+ acpSessionId: started.sessionId,
26459
+ requestedModelId: input2.requestedModelId,
26460
+ expectedGeneration: started.generation
26461
+ });
26462
+ }
26463
+ if (isStale()) {
26445
26464
  settle2({ turnId, stopReason: "cancelled", state: "cancelled" });
26446
- return {
26447
- threadId: options.threadId,
26448
- turnId,
26449
- stopReason: "cancelled"
26450
- };
26465
+ return { threadId: options.threadId, turnId, stopReason: "cancelled" };
26451
26466
  }
26452
- modelSelectionState = await applyRequestedModel({
26453
- state: modelSelectionState,
26454
- acpSessionId: started.sessionId,
26455
- requestedModelId: input2.requestedModelId,
26456
- expectedGeneration: started.generation
26457
- });
26458
26467
  closeActiveAssistantSegment(turnId);
26459
26468
  let written = false;
26460
26469
  try {
@@ -26584,10 +26593,7 @@ function createAcpExecutor(options) {
26584
26593
  provider: options.provider,
26585
26594
  threadId: options.threadId,
26586
26595
  turnId: targetTurnId,
26587
- payload: {
26588
- state: "cancelled",
26589
- stopReason: "cancelled"
26590
- }
26596
+ payload: { state: "cancelled", stopReason: "cancelled" }
26591
26597
  });
26592
26598
  interruptedTurnIds.delete(targetTurnId);
26593
26599
  }
@@ -28065,43 +28071,11 @@ async function probeGrokVersion(input2) {
28065
28071
  });
28066
28072
  }
28067
28073
 
28068
- // src/grokInstance.ts
28069
- var RESUME_SCHEMA_VERSION = 1;
28070
- var yieldTick = () => new Promise((resolve2) => {
28071
- setImmediate(resolve2);
28072
- });
28073
- var EventBus = class {
28074
- #queued = [];
28075
- #waiters = [];
28076
- #closed = false;
28077
- push(event) {
28078
- const waiter = this.#waiters.shift();
28079
- if (waiter) {
28080
- waiter({ done: false, value: event });
28081
- return;
28082
- }
28083
- this.#queued.push(event);
28084
- }
28085
- close() {
28086
- if (this.#closed) return;
28087
- this.#closed = true;
28088
- while (this.#waiters.length > 0) {
28089
- this.#waiters.shift()?.({ done: true, value: void 0 });
28090
- }
28091
- }
28092
- [Symbol.asyncIterator]() {
28093
- return {
28094
- next: () => {
28095
- const queued = this.#queued.shift();
28096
- if (queued !== void 0) return Promise.resolve({ done: false, value: queued });
28097
- if (this.#closed) return Promise.resolve({ done: true, value: void 0 });
28098
- return new Promise((resolve2) => {
28099
- this.#waiters.push(resolve2);
28100
- });
28101
- }
28102
- };
28103
- }
28104
- };
28074
+ // src/grokHome.ts
28075
+ import * as NodeCrypto2 from "node:crypto";
28076
+ import * as NodeOS2 from "node:os";
28077
+ import * as NodePath5 from "node:path";
28078
+ import { mergeLaunchEnv } from "@ycodium-ai/plugin-api/executor";
28105
28079
  function expandHomePath(value) {
28106
28080
  if (value === "~") return NodeOS2.homedir();
28107
28081
  if (value.startsWith("~/") || value.startsWith("~\\")) {
@@ -28169,6 +28143,44 @@ function buildSpawnEnv(recipe, resolvedHomePath, homeConfigured) {
28169
28143
  handOverrides: { GROK_OAUTH2_REFERRER: "ycodium" }
28170
28144
  });
28171
28145
  }
28146
+
28147
+ // src/grokInstance.ts
28148
+ var RESUME_SCHEMA_VERSION = 1;
28149
+ var yieldTick = () => new Promise((resolve2) => {
28150
+ setImmediate(resolve2);
28151
+ });
28152
+ var EventBus = class {
28153
+ #queued = [];
28154
+ #waiters = [];
28155
+ #closed = false;
28156
+ push(event) {
28157
+ const waiter = this.#waiters.shift();
28158
+ if (waiter) {
28159
+ waiter({ done: false, value: event });
28160
+ return;
28161
+ }
28162
+ this.#queued.push(event);
28163
+ }
28164
+ close() {
28165
+ if (this.#closed) return;
28166
+ this.#closed = true;
28167
+ while (this.#waiters.length > 0) {
28168
+ this.#waiters.shift()?.({ done: true, value: void 0 });
28169
+ }
28170
+ }
28171
+ [Symbol.asyncIterator]() {
28172
+ return {
28173
+ next: () => {
28174
+ const queued = this.#queued.shift();
28175
+ if (queued !== void 0) return Promise.resolve({ done: false, value: queued });
28176
+ if (this.#closed) return Promise.resolve({ done: true, value: void 0 });
28177
+ return new Promise((resolve2) => {
28178
+ this.#waiters.push(resolve2);
28179
+ });
28180
+ }
28181
+ };
28182
+ }
28183
+ };
28172
28184
  function nowIso() {
28173
28185
  return (/* @__PURE__ */ new Date()).toISOString();
28174
28186
  }
@@ -28436,7 +28448,7 @@ var createGrokInstance = (config2, host) => {
28436
28448
  if (caveat !== void 0) {
28437
28449
  events.push({
28438
28450
  type: "runtime.warning",
28439
- eventId: NodeCrypto2.randomUUID(),
28451
+ eventId: NodeCrypto3.randomUUID(),
28440
28452
  provider: GROK_DRIVER_KIND,
28441
28453
  providerInstanceId: host.instanceId,
28442
28454
  threadId: input2.threadId,
@@ -28473,7 +28485,7 @@ var createGrokInstance = (config2, host) => {
28473
28485
  const requestedModelId = modelIdFromSelection(input2.modelSelection);
28474
28486
  const turn = await dispatchAcpPrompt(booked.executor, {
28475
28487
  text: input2.input ?? "",
28476
- ...input2.expectedTurnId === void 0 ? {} : { turnId: input2.expectedTurnId },
28488
+ expectedActiveTurnId: input2.expectedTurnId,
28477
28489
  ...requestedModelId === void 0 ? {} : { requestedModelId }
28478
28490
  });
28479
28491
  booked.turns.push({ id: turn.turnId, items: [] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-grok",
3
- "version": "0.2.2984",
3
+ "version": "0.2.2990",
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-acp-executor": "0.2.2984",
25
- "ycodium-executor-testing": "0.0.0",
26
- "@ycodium-ai/plugin-api": "0.2.2984"
24
+ "@ycodium-ai/plugin-api": "0.2.2990",
25
+ "ycodium-acp-executor": "0.2.2990",
26
+ "ycodium-executor-testing": "0.0.0"
27
27
  },
28
28
  "ycodium": {
29
29
  "plugin": "./dist/index.js",