@ycodium-ai/agent-grok 0.2.2892 → 0.2.2898
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 +68 -43
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -26990,6 +26990,66 @@ function tokenizeLaunchArgs(value) {
|
|
|
26990
26990
|
return tokens;
|
|
26991
26991
|
}
|
|
26992
26992
|
|
|
26993
|
+
// src/deviceCodeOutput.ts
|
|
26994
|
+
var OUTPUT_QUIET_MS = 3e3;
|
|
26995
|
+
var SILENT_CAP_MS = 3e4;
|
|
26996
|
+
var DEVICE_CODE_URL = /https?:\/\/\S+/;
|
|
26997
|
+
var DEVICE_CODE_VALUE = /\b([A-Z0-9]{4,}(?:-[A-Z0-9]{4,})+)\b/;
|
|
26998
|
+
var deviceCodeUrl = (output2) => DEVICE_CODE_URL.exec(output2)?.[0];
|
|
26999
|
+
var deviceCodeValue = (output2) => DEVICE_CODE_VALUE.exec(output2)?.[1];
|
|
27000
|
+
var hasDeviceCode = (output2) => deviceCodeUrl(output2) !== void 0 && deviceCodeValue(output2) !== void 0;
|
|
27001
|
+
function readDeviceCodeOutput(stdout, onText) {
|
|
27002
|
+
const collected = [];
|
|
27003
|
+
let onCodeFound;
|
|
27004
|
+
const codeFound = new Promise((resolve2) => {
|
|
27005
|
+
onCodeFound = resolve2;
|
|
27006
|
+
});
|
|
27007
|
+
let quietTimer;
|
|
27008
|
+
let onQuiet;
|
|
27009
|
+
const outputWentQuiet = new Promise((resolve2) => {
|
|
27010
|
+
onQuiet = resolve2;
|
|
27011
|
+
});
|
|
27012
|
+
const text3 = (async () => {
|
|
27013
|
+
const decoder = new TextDecoder();
|
|
27014
|
+
for await (const chunk of stdout) {
|
|
27015
|
+
const piece = decoder.decode(chunk, { stream: true });
|
|
27016
|
+
collected.push(piece);
|
|
27017
|
+
onText(piece);
|
|
27018
|
+
if (onCodeFound !== void 0 && hasDeviceCode(collected.join(""))) {
|
|
27019
|
+
onCodeFound();
|
|
27020
|
+
onCodeFound = void 0;
|
|
27021
|
+
}
|
|
27022
|
+
if (onQuiet !== void 0) {
|
|
27023
|
+
clearTimeout(quietTimer);
|
|
27024
|
+
quietTimer = setTimeout(() => onQuiet?.(), OUTPUT_QUIET_MS);
|
|
27025
|
+
}
|
|
27026
|
+
}
|
|
27027
|
+
return collected.join("");
|
|
27028
|
+
})();
|
|
27029
|
+
const code = (async () => {
|
|
27030
|
+
let silentCap;
|
|
27031
|
+
await Promise.race([
|
|
27032
|
+
codeFound,
|
|
27033
|
+
text3.then(() => void 0),
|
|
27034
|
+
outputWentQuiet,
|
|
27035
|
+
new Promise((resolve2) => {
|
|
27036
|
+
silentCap = setTimeout(resolve2, SILENT_CAP_MS);
|
|
27037
|
+
})
|
|
27038
|
+
]);
|
|
27039
|
+
clearTimeout(silentCap);
|
|
27040
|
+
clearTimeout(quietTimer);
|
|
27041
|
+
onQuiet = void 0;
|
|
27042
|
+
const output2 = collected.join("");
|
|
27043
|
+
const verificationUrl = deviceCodeUrl(output2);
|
|
27044
|
+
const userCode = deviceCodeValue(output2);
|
|
27045
|
+
return {
|
|
27046
|
+
...userCode === void 0 ? {} : { userCode },
|
|
27047
|
+
...verificationUrl === void 0 ? {} : { verificationUrl }
|
|
27048
|
+
};
|
|
27049
|
+
})();
|
|
27050
|
+
return { text: text3, code };
|
|
27051
|
+
}
|
|
27052
|
+
|
|
26993
27053
|
// src/grokAccount.ts
|
|
26994
27054
|
import * as NodeFS from "node:fs";
|
|
26995
27055
|
import * as NodePath2 from "node:path";
|
|
@@ -28021,11 +28081,6 @@ var EventBus = class {
|
|
|
28021
28081
|
};
|
|
28022
28082
|
}
|
|
28023
28083
|
};
|
|
28024
|
-
var DEVICE_CODE_URL = /https?:\/\/\S+/;
|
|
28025
|
-
var DEVICE_CODE_VALUE = /\b([A-Z0-9]{4,}(?:-[A-Z0-9]{4,})+)\b/;
|
|
28026
|
-
var deviceCodeUrl = (output2) => DEVICE_CODE_URL.exec(output2)?.[0];
|
|
28027
|
-
var deviceCodeValue = (output2) => DEVICE_CODE_VALUE.exec(output2)?.[1];
|
|
28028
|
-
var hasDeviceCode = (output2) => deviceCodeUrl(output2) !== void 0 && deviceCodeValue(output2) !== void 0;
|
|
28029
28084
|
function expandHomePath(value) {
|
|
28030
28085
|
if (value === "~") return NodeOS2.homedir();
|
|
28031
28086
|
if (value.startsWith("~/") || value.startsWith("~\\")) {
|
|
@@ -28471,9 +28526,8 @@ var createGrokInstance = (config2, host) => {
|
|
|
28471
28526
|
},
|
|
28472
28527
|
/**
|
|
28473
28528
|
* 设备码登录:`grok login --device-auth` 是 RFC 8628 流程,CLI 自己打印网址和
|
|
28474
|
-
*
|
|
28475
|
-
*
|
|
28476
|
-
* stdout 里捞;捞不到就把原始输出留给用户看,流程本身不假造。
|
|
28529
|
+
* 验证码、轮询到批准,不开浏览器,所以服务器没有图形界面也跑得起来。怎么从
|
|
28530
|
+
* stdout 捞网址与验证码见 deviceCodeOutput.ts,流程本身不假造。
|
|
28477
28531
|
*/
|
|
28478
28532
|
signIn: {
|
|
28479
28533
|
start: async () => {
|
|
@@ -28487,46 +28541,17 @@ var createGrokInstance = (config2, host) => {
|
|
|
28487
28541
|
owner: { bindingId: host.bindingId },
|
|
28488
28542
|
...Object.keys(env).length > 0 ? { env } : {}
|
|
28489
28543
|
});
|
|
28490
|
-
const
|
|
28491
|
-
|
|
28492
|
-
|
|
28493
|
-
|
|
28494
|
-
|
|
28495
|
-
const stdoutText = (async () => {
|
|
28496
|
-
const decoder = new TextDecoder();
|
|
28497
|
-
for await (const chunk of handle.stdout) {
|
|
28498
|
-
const text3 = decoder.decode(chunk, { stream: true });
|
|
28499
|
-
collected.push(text3);
|
|
28500
|
-
host.log.info("sign-in output", { text: text3 });
|
|
28501
|
-
if (onCodeFound !== void 0 && hasDeviceCode(collected.join(""))) {
|
|
28502
|
-
onCodeFound();
|
|
28503
|
-
onCodeFound = void 0;
|
|
28504
|
-
}
|
|
28505
|
-
}
|
|
28506
|
-
return collected.join("");
|
|
28507
|
-
})();
|
|
28544
|
+
const output2 = readDeviceCodeOutput(
|
|
28545
|
+
handle.stdout,
|
|
28546
|
+
(text3) => host.log.info("sign-in output", { text: text3 })
|
|
28547
|
+
);
|
|
28548
|
+
const stdoutText = output2.text;
|
|
28508
28549
|
const operationId = `grok-sign-in-${Date.now().toString(36)}-${signInOperations.size}`;
|
|
28509
28550
|
signInOperations.set(operationId, { handle, stdoutText });
|
|
28510
28551
|
void stdoutText.finally(() => {
|
|
28511
28552
|
signInOperations.delete(operationId);
|
|
28512
28553
|
});
|
|
28513
|
-
|
|
28514
|
-
await Promise.race([
|
|
28515
|
-
codeFound,
|
|
28516
|
-
stdoutText.then(() => void 0),
|
|
28517
|
-
new Promise((resolve2) => {
|
|
28518
|
-
timer = setTimeout(resolve2, 3e3);
|
|
28519
|
-
})
|
|
28520
|
-
]);
|
|
28521
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
28522
|
-
const output2 = collected.join("");
|
|
28523
|
-
const verificationUrl = deviceCodeUrl(output2);
|
|
28524
|
-
const userCode = deviceCodeValue(output2);
|
|
28525
|
-
return {
|
|
28526
|
-
operationId,
|
|
28527
|
-
...userCode === void 0 ? {} : { userCode },
|
|
28528
|
-
...verificationUrl === void 0 ? {} : { verificationUrl }
|
|
28529
|
-
};
|
|
28554
|
+
return { operationId, ...await output2.code };
|
|
28530
28555
|
},
|
|
28531
28556
|
cancel: async (operationId) => {
|
|
28532
28557
|
const operation = signInOperations.get(operationId);
|
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.2898",
|
|
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-acp-executor": "0.2.
|
|
25
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
24
|
+
"ycodium-acp-executor": "0.2.2898",
|
|
25
|
+
"@ycodium-ai/plugin-api": "0.2.2898",
|
|
26
26
|
"ycodium-executor-testing": "0.0.0"
|
|
27
27
|
},
|
|
28
28
|
"ycodium": {
|