@ycodium-ai/agent-grok 0.2.3202 → 0.2.3208
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 +81 -19
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -27262,6 +27262,9 @@ function createAcpSessionRegistry(threads, stopBooked2) {
|
|
|
27262
27262
|
if (!booked) return Promise.resolve();
|
|
27263
27263
|
booked.closing ??= Promise.resolve().then(() => stopBooked2(booked)).then(() => {
|
|
27264
27264
|
if (threads.get(threadId) === booked) threads.delete(threadId);
|
|
27265
|
+
}).catch((cause) => {
|
|
27266
|
+
if (threads.get(threadId) === booked) delete booked.closing;
|
|
27267
|
+
throw cause;
|
|
27265
27268
|
});
|
|
27266
27269
|
return booked.closing;
|
|
27267
27270
|
};
|
|
@@ -27271,6 +27274,61 @@ function createAcpSessionRegistry(threads, stopBooked2) {
|
|
|
27271
27274
|
return { requireThread, stopSession, stopAll };
|
|
27272
27275
|
}
|
|
27273
27276
|
|
|
27277
|
+
// ../../packages/ycodium-acp-executor/src/session-cleanup.ts
|
|
27278
|
+
var reportedForwardingFailures = /* @__PURE__ */ new WeakSet();
|
|
27279
|
+
async function cleanupAcpSession(input2) {
|
|
27280
|
+
const failures = [];
|
|
27281
|
+
const forwarding = input2.forwarding.catch((cause) => {
|
|
27282
|
+
if (reportedForwardingFailures.has(input2.forwarding)) return;
|
|
27283
|
+
reportedForwardingFailures.add(input2.forwarding);
|
|
27284
|
+
failures.push(new Error(`forwarding failed: ${String(cause)}`, { cause }));
|
|
27285
|
+
});
|
|
27286
|
+
for (const [step, cleanup] of [
|
|
27287
|
+
["executor.dispose", () => input2.executor.dispose()],
|
|
27288
|
+
["stopProcess", input2.stopProcess],
|
|
27289
|
+
["forwarding", () => forwarding]
|
|
27290
|
+
]) {
|
|
27291
|
+
try {
|
|
27292
|
+
await cleanup();
|
|
27293
|
+
} catch (cause) {
|
|
27294
|
+
failures.push(new Error(`${step} failed: ${String(cause)}`, { cause }));
|
|
27295
|
+
}
|
|
27296
|
+
}
|
|
27297
|
+
if (failures.length > 0) {
|
|
27298
|
+
throw new AggregateError(failures, failures.map((error62) => error62.message).join("; "));
|
|
27299
|
+
}
|
|
27300
|
+
}
|
|
27301
|
+
async function cleanupAcpStartup(input2) {
|
|
27302
|
+
try {
|
|
27303
|
+
await cleanupAcpSession(input2);
|
|
27304
|
+
return true;
|
|
27305
|
+
} catch (cleanupError) {
|
|
27306
|
+
input2.log.warn("ACP session startup cleanup failed", {
|
|
27307
|
+
threadId: input2.threadId,
|
|
27308
|
+
error: String(cleanupError)
|
|
27309
|
+
});
|
|
27310
|
+
return false;
|
|
27311
|
+
}
|
|
27312
|
+
}
|
|
27313
|
+
function createRetryableClose(run) {
|
|
27314
|
+
let task;
|
|
27315
|
+
return () => {
|
|
27316
|
+
if (task) return task;
|
|
27317
|
+
const done = Promise.withResolvers();
|
|
27318
|
+
const current = done.promise;
|
|
27319
|
+
task = current;
|
|
27320
|
+
void current.catch(() => {
|
|
27321
|
+
if (task === current) task = void 0;
|
|
27322
|
+
});
|
|
27323
|
+
try {
|
|
27324
|
+
run().then(done.resolve, done.reject);
|
|
27325
|
+
} catch (cause) {
|
|
27326
|
+
done.reject(cause);
|
|
27327
|
+
}
|
|
27328
|
+
return current;
|
|
27329
|
+
};
|
|
27330
|
+
}
|
|
27331
|
+
|
|
27274
27332
|
// ../../packages/ycodium-acp-executor/src/sessionProcess.ts
|
|
27275
27333
|
var fileName = (path) => path.slice(path.lastIndexOf("/") + 1);
|
|
27276
27334
|
var withoutExe = (name) => name.replace(/\.exe$/, "");
|
|
@@ -28753,9 +28811,11 @@ function nowIso() {
|
|
|
28753
28811
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
28754
28812
|
}
|
|
28755
28813
|
async function stopBooked(booked) {
|
|
28756
|
-
await
|
|
28757
|
-
|
|
28758
|
-
|
|
28814
|
+
await cleanupAcpSession({
|
|
28815
|
+
executor: booked.executor,
|
|
28816
|
+
stopProcess: () => booked.handle.kill("SIGTERM"),
|
|
28817
|
+
forwarding: booked.forwarding
|
|
28818
|
+
});
|
|
28759
28819
|
}
|
|
28760
28820
|
function modelIdFromSelection(selection) {
|
|
28761
28821
|
if (typeof selection !== "object" || selection === null || Array.isArray(selection)) {
|
|
@@ -28770,8 +28830,16 @@ var createGrokInstance = (config2, host) => {
|
|
|
28770
28830
|
const threads = /* @__PURE__ */ new Map();
|
|
28771
28831
|
const signInOperations = /* @__PURE__ */ new Map();
|
|
28772
28832
|
let disposed = false;
|
|
28773
|
-
let disposeTask;
|
|
28774
28833
|
const { requireThread, stopSession, stopAll } = createAcpSessionRegistry(threads, stopBooked);
|
|
28834
|
+
const disposeOnce = createRetryableClose(async () => {
|
|
28835
|
+
const operations = [...signInOperations.values()];
|
|
28836
|
+
signInOperations.clear();
|
|
28837
|
+
for (const operation of operations) {
|
|
28838
|
+
await operation.handle.kill("SIGTERM").catch(() => void 0);
|
|
28839
|
+
}
|
|
28840
|
+
await stopAll();
|
|
28841
|
+
events.close();
|
|
28842
|
+
});
|
|
28775
28843
|
const probeAuth = () => {
|
|
28776
28844
|
if ((recipe.environment["XAI_API_KEY"] ?? "").trim().length > 0) {
|
|
28777
28845
|
return { status: "authenticated", type: "api-key", label: "XAI_API_KEY" };
|
|
@@ -29036,9 +29104,13 @@ var createGrokInstance = (config2, host) => {
|
|
|
29036
29104
|
}
|
|
29037
29105
|
return session;
|
|
29038
29106
|
} catch (error62) {
|
|
29039
|
-
await
|
|
29040
|
-
|
|
29041
|
-
|
|
29107
|
+
await cleanupAcpStartup({
|
|
29108
|
+
executor,
|
|
29109
|
+
stopProcess: () => handle.kill("SIGTERM"),
|
|
29110
|
+
forwarding,
|
|
29111
|
+
log: host.log,
|
|
29112
|
+
threadId: input2.threadId
|
|
29113
|
+
});
|
|
29042
29114
|
throw error62;
|
|
29043
29115
|
}
|
|
29044
29116
|
},
|
|
@@ -29118,18 +29190,8 @@ var createGrokInstance = (config2, host) => {
|
|
|
29118
29190
|
}),
|
|
29119
29191
|
continuationKey: grokContinuationKey(recipe),
|
|
29120
29192
|
dispose: () => {
|
|
29121
|
-
if (disposeTask) return disposeTask;
|
|
29122
29193
|
disposed = true;
|
|
29123
|
-
|
|
29124
|
-
const operations = [...signInOperations.values()];
|
|
29125
|
-
signInOperations.clear();
|
|
29126
|
-
for (const operation of operations) {
|
|
29127
|
-
await operation.handle.kill("SIGTERM").catch(() => void 0);
|
|
29128
|
-
}
|
|
29129
|
-
await stopAll();
|
|
29130
|
-
events.close();
|
|
29131
|
-
})();
|
|
29132
|
-
return disposeTask;
|
|
29194
|
+
return disposeOnce();
|
|
29133
29195
|
},
|
|
29134
29196
|
/**
|
|
29135
29197
|
* 设备码登录:`grok login --device-auth` 是 RFC 8628 流程,CLI 自己打印网址和
|
|
@@ -29186,7 +29248,7 @@ var executors = [
|
|
|
29186
29248
|
];
|
|
29187
29249
|
var index_default = definePlugin({
|
|
29188
29250
|
id: "agent-grok",
|
|
29189
|
-
apiVersion:
|
|
29251
|
+
apiVersion: 19,
|
|
29190
29252
|
executors,
|
|
29191
29253
|
activate(ctx) {
|
|
29192
29254
|
ctx.log.info("grok executor ready");
|
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.3208",
|
|
4
4
|
"description": "Grok executor: grok CLI over Agent Client Protocol stdio.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"@types/node": "24.12.4",
|
|
22
22
|
"esbuild": "0.28.1",
|
|
23
23
|
"vite-plus": "0.2.2",
|
|
24
|
-
"ycodium-
|
|
25
|
-
"
|
|
24
|
+
"@ycodium-ai/plugin-api": "0.2.3208",
|
|
25
|
+
"ycodium-acp-executor": "0.2.3208",
|
|
26
26
|
"ycodium-executor-testing": "0.0.0"
|
|
27
27
|
},
|
|
28
28
|
"ycodium": {
|