grok-bot-cli 0.4.5 → 0.5.0
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/CHANGELOG.md +11 -0
- package/README.md +7 -7
- package/dist/.claude-plugin/marketplace.json +1 -1
- package/dist/.claude-plugin/plugin.json +1 -1
- package/dist/.codex-plugin/plugin.json +1 -1
- package/dist/.cursor-plugin/plugin.json +1 -1
- package/dist/INSTALL.md +1 -1
- package/dist/README.md +7 -7
- package/dist/agent-bundle.compile-evidence.json +1 -1
- package/dist/agent-bundle.manifest.json +1 -1
- package/dist/bin/gbot-flight.mjs +40 -57
- package/dist/bin/gbot.mjs +42 -61
- package/dist/install.mjs +1 -1
- package/dist/mcp/mcp-grok-bot-b8c2461e-flight.mjs +14 -22
- package/dist/mcp/mcp-grok-bot-b8c2461e.mjs +15 -23
- package/dist/package.json +2 -2
- package/dist/plugin.json +1 -1
- package/dist/skills/talk-to-grok-bot/SKILL.md +3 -1
- package/package.json +2 -2
package/dist/bin/gbot-flight.mjs
CHANGED
|
@@ -15422,9 +15422,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
15422
15422
|
|
|
15423
15423
|
|
|
15424
15424
|
const config = {
|
|
15425
|
-
aliases: [
|
|
15426
|
-
'chat'
|
|
15427
|
-
],
|
|
15428
15425
|
description: 'Read the most recent messages in a Grok Bot bot or group thread.',
|
|
15429
15426
|
inputJsonSchema: {
|
|
15430
15427
|
additionalProperties: false,
|
|
@@ -15574,7 +15571,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
15574
15571
|
|
|
15575
15572
|
// Hosts and the CLI print thrown error text (and stack), and a fetch or proxy failure can echo
|
|
15576
15573
|
// a credential. Rewrap with a redacted message; keep `name` and own fields such as `reason`,
|
|
15577
|
-
// `delivery`, `mode`, and
|
|
15574
|
+
// `delivery`, `mode`, and correlation ids so outcome documents still classify the failure.
|
|
15578
15575
|
const withRedactedErrors = async (run)=>{
|
|
15579
15576
|
try {
|
|
15580
15577
|
return await run();
|
|
@@ -26574,15 +26571,27 @@ class CodexRpcError extends Error {
|
|
|
26574
26571
|
}
|
|
26575
26572
|
}
|
|
26576
26573
|
class CodexSendError extends Error {
|
|
26577
|
-
constructor(message, { delivery,
|
|
26574
|
+
constructor(message, { correlationId, delivery, hop, messageId, reason, refused, threadId, turnId } = {}){
|
|
26578
26575
|
super(message);
|
|
26579
26576
|
this.name = "CodexSendError";
|
|
26580
26577
|
this.delivery = delivery;
|
|
26578
|
+
if (correlationId !== undefined) this.correlationId = correlationId;
|
|
26579
|
+
if (hop !== undefined) this.hop = hop;
|
|
26580
|
+
if (messageId !== undefined) this.messageId = messageId;
|
|
26581
26581
|
if (reason !== undefined) this.reason = reason;
|
|
26582
|
+
if (refused !== undefined) this.refused = refused;
|
|
26582
26583
|
if (threadId !== undefined) this.threadId = threadId;
|
|
26583
26584
|
if (turnId !== undefined) this.turnId = turnId;
|
|
26584
|
-
|
|
26585
|
-
|
|
26585
|
+
}
|
|
26586
|
+
}
|
|
26587
|
+
function attachEnvelope(error, envelope) {
|
|
26588
|
+
if (!error || typeof error !== "object") return;
|
|
26589
|
+
for (const key of [
|
|
26590
|
+
"messageId",
|
|
26591
|
+
"correlationId",
|
|
26592
|
+
"hop"
|
|
26593
|
+
]){
|
|
26594
|
+
if (error[key] === undefined && envelope[key] !== undefined) error[key] = envelope[key];
|
|
26586
26595
|
}
|
|
26587
26596
|
}
|
|
26588
26597
|
/** The route to the app-server is unavailable; `mode` is a stable machine-readable state. */ class CodexRouteError extends Error {
|
|
@@ -27237,7 +27246,7 @@ const ID_PATTERN = /^[A-Za-z0-9_.:-]{1,128}$/;
|
|
|
27237
27246
|
throw new CodexSendError("Refusing to send: hop " + hopCount + " reaches the relay bound " + bound + " (GROK_BOT_MAX_HOPS). " + "This message is an agent-to-agent relay that has already been forwarded too many times.", {
|
|
27238
27247
|
delivery: "rejected",
|
|
27239
27248
|
reason: "hop-limit",
|
|
27240
|
-
|
|
27249
|
+
...out
|
|
27241
27250
|
});
|
|
27242
27251
|
}
|
|
27243
27252
|
return out;
|
|
@@ -27325,20 +27334,20 @@ function unsupportedOrRpc(err, method, threadId, envelope) {
|
|
|
27325
27334
|
delivery: "rejected",
|
|
27326
27335
|
reason: "unsupported",
|
|
27327
27336
|
threadId,
|
|
27328
|
-
envelope
|
|
27337
|
+
...envelope
|
|
27329
27338
|
});
|
|
27330
27339
|
}
|
|
27331
27340
|
if (err instanceof CodexRpcError) return new CodexSendError(err.message, {
|
|
27332
27341
|
delivery: "rejected",
|
|
27333
27342
|
reason: "rejected",
|
|
27334
27343
|
threadId,
|
|
27335
|
-
envelope
|
|
27344
|
+
...envelope
|
|
27336
27345
|
});
|
|
27337
27346
|
return new CodexSendError("Lost the Codex " + method + " response for thread " + threadId + ": " + (err && err.message || err) + ". Delivery is unknown; list the queue before resending.", {
|
|
27338
27347
|
delivery: err && err.delivery || "unknown",
|
|
27339
27348
|
reason: "transport",
|
|
27340
27349
|
threadId,
|
|
27341
|
-
envelope
|
|
27350
|
+
...envelope
|
|
27342
27351
|
});
|
|
27343
27352
|
}
|
|
27344
27353
|
/** Read the daemon's queue for one thread (experimental `thread/queue/list`). */ async function listCodexQueue(threadId, { env = process.env, limit = 50, cursor } = {}) {
|
|
@@ -27389,7 +27398,7 @@ function unsupportedOrRpc(err, method, threadId, envelope) {
|
|
|
27389
27398
|
return (0,_codex_contract_js__rspack_import_7/* .outcomeFromReceipt */.Dz)(receipt);
|
|
27390
27399
|
} catch (err) {
|
|
27391
27400
|
// Every receipt names the message, including refusals that never reached the daemon.
|
|
27392
|
-
if (
|
|
27401
|
+
if (err instanceof CodexSendError || err instanceof CodexRouteError || err instanceof CodexProtocolError) attachEnvelope(err, envelope);
|
|
27393
27402
|
return (0,_codex_contract_js__rspack_import_7/* .outcomeFromError */.DG)(err);
|
|
27394
27403
|
}
|
|
27395
27404
|
}
|
|
@@ -27414,7 +27423,7 @@ async function sendToCodexThreadInner(threadId, text, { env, envelope, whenBusy
|
|
|
27414
27423
|
delivery: err instanceof CodexRpcError ? "rejected" : err && err.delivery || "unknown",
|
|
27415
27424
|
reason: err instanceof CodexRpcError ? /no rollout found|thread not found/i.test(String(err.rpc && err.rpc.message)) ? "unknown-thread" : /active writer/i.test(String(err.rpc && err.rpc.message)) ? "external-owner" : "rejected" : "transport",
|
|
27416
27425
|
threadId,
|
|
27417
|
-
envelope
|
|
27426
|
+
...envelope
|
|
27418
27427
|
});
|
|
27419
27428
|
}
|
|
27420
27429
|
if (!isObject(resumed) || !isObject(resumed.thread) || typeof resumed.thread.id !== "string") {
|
|
@@ -27441,7 +27450,7 @@ async function sendToCodexThreadInner(threadId, text, { env, envelope, whenBusy
|
|
|
27441
27450
|
delivery: "rejected",
|
|
27442
27451
|
reason: "busy",
|
|
27443
27452
|
threadId,
|
|
27444
|
-
envelope
|
|
27453
|
+
...envelope
|
|
27445
27454
|
});
|
|
27446
27455
|
}
|
|
27447
27456
|
if (state.busy) {
|
|
@@ -27466,7 +27475,7 @@ async function sendToCodexThreadInner(threadId, text, { env, envelope, whenBusy
|
|
|
27466
27475
|
delivery: "unknown",
|
|
27467
27476
|
reason: "bad-response",
|
|
27468
27477
|
threadId,
|
|
27469
|
-
envelope
|
|
27478
|
+
...envelope
|
|
27470
27479
|
});
|
|
27471
27480
|
}
|
|
27472
27481
|
return {
|
|
@@ -27512,7 +27521,7 @@ async function sendToCodexThreadInner(threadId, text, { env, envelope, whenBusy
|
|
|
27512
27521
|
delivery,
|
|
27513
27522
|
reason: delivery === "rejected" ? "rejected" : "transport",
|
|
27514
27523
|
threadId,
|
|
27515
|
-
envelope
|
|
27524
|
+
...envelope
|
|
27516
27525
|
});
|
|
27517
27526
|
}
|
|
27518
27527
|
const turnId = turn && turn.turn && typeof turn.turn.id === "string" && turn.turn.id ? turn.turn.id : null;
|
|
@@ -27521,7 +27530,7 @@ async function sendToCodexThreadInner(threadId, text, { env, envelope, whenBusy
|
|
|
27521
27530
|
delivery: "unknown",
|
|
27522
27531
|
reason: "bad-response",
|
|
27523
27532
|
threadId,
|
|
27524
|
-
envelope
|
|
27533
|
+
...envelope
|
|
27525
27534
|
});
|
|
27526
27535
|
}
|
|
27527
27536
|
client._adoptTurn(turnId);
|
|
@@ -27543,7 +27552,7 @@ async function sendToCodexThreadInner(threadId, text, { env, envelope, whenBusy
|
|
|
27543
27552
|
threadId,
|
|
27544
27553
|
turnId,
|
|
27545
27554
|
refused: freshRefused.map((r)=>r.method),
|
|
27546
|
-
envelope
|
|
27555
|
+
...envelope
|
|
27547
27556
|
});
|
|
27548
27557
|
}
|
|
27549
27558
|
return {
|
|
@@ -27629,8 +27638,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27629
27638
|
}
|
|
27630
27639
|
/**
|
|
27631
27640
|
* Flatten a thrown error into the #46 send/failure document (plus exitCode).
|
|
27632
|
-
* Preserves the legacy failure-document fields, then adds exitCode for the
|
|
27633
|
-
* generated CLI's `exitCode: 'result'` policy.
|
|
27634
27641
|
*
|
|
27635
27642
|
* @param {unknown} error
|
|
27636
27643
|
* @param {{ isUsage?: (err: unknown) => boolean }} [opts]
|
|
@@ -27657,12 +27664,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27657
27664
|
if (error[key] !== undefined) out[key] = error[key];
|
|
27658
27665
|
}
|
|
27659
27666
|
if (out.reason === undefined && isUsage(error)) out.reason = "usage";
|
|
27660
|
-
const envelope = /** @type {{ messageId?: string, correlationId?: string, hop?: number }} */ error.envelope;
|
|
27661
|
-
if (envelope && typeof envelope === "object") {
|
|
27662
|
-
if (envelope.messageId !== undefined) out.messageId = envelope.messageId;
|
|
27663
|
-
if (envelope.correlationId !== undefined) out.correlationId = envelope.correlationId;
|
|
27664
|
-
if (envelope.hop !== undefined) out.hop = envelope.hop;
|
|
27665
|
-
}
|
|
27666
27667
|
}
|
|
27667
27668
|
if (out.delivery === undefined) out.delivery = "rejected";
|
|
27668
27669
|
return /** @type {CodexSendOutcome & { error: string, exitCode: 1 }} */ {
|
|
@@ -27679,14 +27680,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27679
27680
|
...receipt
|
|
27680
27681
|
};
|
|
27681
27682
|
if (base.delivery === undefined) base.delivery = "accepted";
|
|
27682
|
-
// Flatten envelope onto the document when present (matches fail() + json print).
|
|
27683
|
-
const envelope = base.envelope;
|
|
27684
|
-
if (envelope && typeof envelope === "object") {
|
|
27685
|
-
const e = /** @type {Record<string, unknown>} */ envelope;
|
|
27686
|
-
if (base.messageId === undefined && e.messageId !== undefined) base.messageId = e.messageId;
|
|
27687
|
-
if (base.correlationId === undefined && e.correlationId !== undefined) base.correlationId = e.correlationId;
|
|
27688
|
-
if (base.hop === undefined && e.hop !== undefined) base.hop = e.hop;
|
|
27689
|
-
}
|
|
27690
27683
|
const exitCode = sendExitCode(/** @type {{ delivery: CodexDelivery, reason?: string, error?: string }} */ base);
|
|
27691
27684
|
if (exitCode === 1 && base.error === undefined && base.reason === "approval-refused") {
|
|
27692
27685
|
base.error = typeof base.message === "string" ? base.message : "Codex refused one or more approvals.";
|
|
@@ -27735,7 +27728,7 @@ async function openBackend(opts) {
|
|
|
27735
27728
|
setGroupMembers: (group, members)=>_gateway_js__rspack_import_1/* .setGroupMembers */.Td(session, group, members),
|
|
27736
27729
|
addGroupMember: (group, bot)=>_gateway_js__rspack_import_1/* .addGroupMember */.zr(session, group, bot),
|
|
27737
27730
|
removeGroupMember: (group, bot)=>_gateway_js__rspack_import_1/* .removeGroupMember */.A0(session, group, bot),
|
|
27738
|
-
send: (ref, prompt
|
|
27731
|
+
send: (ref, prompt)=>_gateway_js__rspack_import_1/* .sendPrompt */.LV(session, ref, prompt),
|
|
27739
27732
|
transcript: (ref, limit)=>_gateway_js__rspack_import_1/* .getTranscriptTail */.bA(session, ref, limit),
|
|
27740
27733
|
thread: (ref, rootId)=>_gateway_js__rspack_import_1/* .getThread */.fG(session, ref, rootId)
|
|
27741
27734
|
};
|
|
@@ -28371,7 +28364,7 @@ function formatTranscript(out, { full = false } = {}) {
|
|
|
28371
28364
|
for (const e of entries){
|
|
28372
28365
|
const role = e.role || e.kind || e.sender || e.type || "msg";
|
|
28373
28366
|
const text = (0,_transcript_js__rspack_import_0/* .entryText */.u0)(e);
|
|
28374
|
-
const id = e.id ||
|
|
28367
|
+
const id = e.id || "";
|
|
28375
28368
|
lines.push("[" + role + (id ? " " + id : "") + "] " + (full ? text : truncateCliText(text)));
|
|
28376
28369
|
}
|
|
28377
28370
|
return lines.join("\n");
|
|
@@ -28467,19 +28460,17 @@ class GatewayError extends Error {
|
|
|
28467
28460
|
const GATEWAY_TIMEOUT_MS = 30000;
|
|
28468
28461
|
const GATEWAY_MAX_RESPONSE_BYTES = 2 * 1024 * 1024;
|
|
28469
28462
|
function backendBase() {
|
|
28470
|
-
return (process.env.
|
|
28463
|
+
return (process.env.CURSOR_API_BASE_URL || "https://api2.cursor.sh").replace(/\/$/, "");
|
|
28471
28464
|
}
|
|
28472
28465
|
function accessTokenFromEnv() {
|
|
28473
|
-
return (process.env.CURSOR_ACCESS_TOKEN ||
|
|
28466
|
+
return (process.env.CURSOR_ACCESS_TOKEN || "").trim();
|
|
28474
28467
|
}
|
|
28475
28468
|
function gatewayTokenFromEnv() {
|
|
28476
|
-
return (process.env.GROK_BOT_GATEWAY_TOKEN ||
|
|
28469
|
+
return (process.env.GROK_BOT_GATEWAY_TOKEN || "").trim();
|
|
28477
28470
|
}
|
|
28478
28471
|
function gatewayOverride() {
|
|
28479
28472
|
const token = gatewayTokenFromEnv();
|
|
28480
|
-
const
|
|
28481
|
-
const localUrl = token ? "http://127.0.0.1:" + (process.env.SAND_HOST_PORT || "1340") : "";
|
|
28482
|
-
const url = explicitUrl || localUrl;
|
|
28473
|
+
const url = (process.env.GROK_BOT_GATEWAY_URL || "").trim();
|
|
28483
28474
|
if (url && token) {
|
|
28484
28475
|
return {
|
|
28485
28476
|
gatewayUrl: (0,_url_policy_js__rspack_import_3/* .assertAllowedCredentialUrl */.Re)(url.replace(/\/$/, ""), {
|
|
@@ -28799,14 +28790,13 @@ async function removeGroupMember(session, groupRef, memberRef) {
|
|
|
28799
28790
|
const next = group.memberIds.filter((id)=>id !== member.id);
|
|
28800
28791
|
return setGroupMembers(session, group.id, next);
|
|
28801
28792
|
}
|
|
28802
|
-
async function sendPrompt(session, ref, prompt
|
|
28793
|
+
async function sendPrompt(session, ref, prompt) {
|
|
28803
28794
|
const rec = await resolveRef(session, ref);
|
|
28804
28795
|
const body = {
|
|
28805
28796
|
agentId: rec.id,
|
|
28806
28797
|
prompt,
|
|
28807
|
-
clientNonce:
|
|
28798
|
+
clientNonce: (0,node_crypto__rspack_import_0.randomUUID)()
|
|
28808
28799
|
};
|
|
28809
|
-
if (extra.replyToId) body.replyToId = extra.replyToId;
|
|
28810
28800
|
let data;
|
|
28811
28801
|
try {
|
|
28812
28802
|
data = await gatewayCall(session, "sendPrompt", body);
|
|
@@ -28983,8 +28973,8 @@ function saveHistory(out, { dir, disabled, event, prompt, rootId } = {}) {
|
|
|
28983
28973
|
rootId
|
|
28984
28974
|
} : {},
|
|
28985
28975
|
role: String(entry.role || entry.kind || entry.sender || entry.type || "msg"),
|
|
28986
|
-
...entry.id
|
|
28987
|
-
messageId: String(entry.id
|
|
28976
|
+
...entry.id ? {
|
|
28977
|
+
messageId: String(entry.id)
|
|
28988
28978
|
} : {},
|
|
28989
28979
|
...entry.timestamp || entry.createdAt ? {
|
|
28990
28980
|
timestamp: String(entry.timestamp || entry.createdAt)
|
|
@@ -29128,10 +29118,7 @@ function isUuid(value) {
|
|
|
29128
29118
|
function defaultCandidateRoots() {
|
|
29129
29119
|
const home = (0,node_os__rspack_import_2.homedir)();
|
|
29130
29120
|
const env = [
|
|
29131
|
-
process.env.GROK_BOT_AGENTS_DIR
|
|
29132
|
-
process.env.SAND_AGENTS_DIR,
|
|
29133
|
-
process.env.SAND_DATA_ROOT && (0,node_path__rspack_import_3.join)(process.env.SAND_DATA_ROOT, "agents"),
|
|
29134
|
-
process.env.SAND_DATA_ROOT && (0,node_path__rspack_import_3.join)(process.env.SAND_DATA_ROOT, "agent-data", "agents")
|
|
29121
|
+
process.env.GROK_BOT_AGENTS_DIR
|
|
29135
29122
|
].filter(Boolean);
|
|
29136
29123
|
return [
|
|
29137
29124
|
...env,
|
|
@@ -29410,7 +29397,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29410
29397
|
|
|
29411
29398
|
},
|
|
29412
29399
|
"./src/core/transcript.js"(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
29413
|
-
// Shared by `gbot thread` and the grok-bot plugin's gbot_thread tool.
|
|
29414
29400
|
/** Coerce anything to a string without throwing (numbers, BigInt, unserializable objects). */ function toSafeText(value) {
|
|
29415
29401
|
if (typeof value === "string") return value;
|
|
29416
29402
|
if (value == null) return "";
|
|
@@ -29448,15 +29434,12 @@ function entryTextRaw(e) {
|
|
|
29448
29434
|
return typeof e.preview === "string" ? e.preview : "";
|
|
29449
29435
|
}
|
|
29450
29436
|
function transcriptEntries(payload) {
|
|
29451
|
-
if (Array.isArray(payload)) return payload;
|
|
29452
29437
|
if (!payload || typeof payload !== "object") return [];
|
|
29453
|
-
|
|
29454
|
-
return Array.isArray(entries) ? entries : [];
|
|
29438
|
+
return Array.isArray(payload.entries) ? payload.entries : [];
|
|
29455
29439
|
}
|
|
29456
29440
|
function sourceEntryId(entry) {
|
|
29457
29441
|
if (!entry || typeof entry !== "object") return "";
|
|
29458
|
-
|
|
29459
|
-
return typeof entry.messageId === "string" ? entry.messageId : "";
|
|
29442
|
+
return typeof entry.id === "string" ? entry.id : "";
|
|
29460
29443
|
}
|
|
29461
29444
|
function lastSourceId(entries, fallback = "") {
|
|
29462
29445
|
for(let index = entries.length - 1; index >= 0; index -= 1){
|
package/dist/bin/gbot.mjs
CHANGED
|
@@ -12994,9 +12994,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
12994
12994
|
|
|
12995
12995
|
|
|
12996
12996
|
const config = {
|
|
12997
|
-
aliases: [
|
|
12998
|
-
'chat'
|
|
12999
|
-
],
|
|
13000
12997
|
description: 'Read the most recent messages in a Grok Bot bot or group thread.',
|
|
13001
12998
|
inputJsonSchema: {
|
|
13002
12999
|
additionalProperties: false,
|
|
@@ -13146,7 +13143,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
13146
13143
|
|
|
13147
13144
|
// Hosts and the CLI print thrown error text (and stack), and a fetch or proxy failure can echo
|
|
13148
13145
|
// a credential. Rewrap with a redacted message; keep `name` and own fields such as `reason`,
|
|
13149
|
-
// `delivery`, `mode`, and
|
|
13146
|
+
// `delivery`, `mode`, and correlation ids so outcome documents still classify the failure.
|
|
13150
13147
|
const withRedactedErrors = async (run)=>{
|
|
13151
13148
|
try {
|
|
13152
13149
|
return await run();
|
|
@@ -84199,9 +84196,7 @@ const commands = Object.freeze([
|
|
|
84199
84196
|
"routeId": "cli:send"
|
|
84200
84197
|
},
|
|
84201
84198
|
{
|
|
84202
|
-
"aliases": [
|
|
84203
|
-
"chat"
|
|
84204
|
-
],
|
|
84199
|
+
"aliases": [],
|
|
84205
84200
|
"description": "Read the most recent messages in a Grok Bot bot or group thread.",
|
|
84206
84201
|
"exitCode": "zero",
|
|
84207
84202
|
"options": [
|
|
@@ -84503,7 +84498,7 @@ if (import.meta.main) {
|
|
|
84503
84498
|
execute,
|
|
84504
84499
|
name: "gbot",
|
|
84505
84500
|
render,
|
|
84506
|
-
version: "0.
|
|
84501
|
+
version: "0.5.0"
|
|
84507
84502
|
});
|
|
84508
84503
|
}
|
|
84509
84504
|
|
|
@@ -84905,15 +84900,27 @@ class CodexRpcError extends Error {
|
|
|
84905
84900
|
}
|
|
84906
84901
|
}
|
|
84907
84902
|
class CodexSendError extends Error {
|
|
84908
|
-
constructor(message, { delivery,
|
|
84903
|
+
constructor(message, { correlationId, delivery, hop, messageId, reason, refused, threadId, turnId } = {}){
|
|
84909
84904
|
super(message);
|
|
84910
84905
|
this.name = "CodexSendError";
|
|
84911
84906
|
this.delivery = delivery;
|
|
84907
|
+
if (correlationId !== undefined) this.correlationId = correlationId;
|
|
84908
|
+
if (hop !== undefined) this.hop = hop;
|
|
84909
|
+
if (messageId !== undefined) this.messageId = messageId;
|
|
84912
84910
|
if (reason !== undefined) this.reason = reason;
|
|
84911
|
+
if (refused !== undefined) this.refused = refused;
|
|
84913
84912
|
if (threadId !== undefined) this.threadId = threadId;
|
|
84914
84913
|
if (turnId !== undefined) this.turnId = turnId;
|
|
84915
|
-
|
|
84916
|
-
|
|
84914
|
+
}
|
|
84915
|
+
}
|
|
84916
|
+
function attachEnvelope(error, envelope) {
|
|
84917
|
+
if (!error || typeof error !== "object") return;
|
|
84918
|
+
for (const key of [
|
|
84919
|
+
"messageId",
|
|
84920
|
+
"correlationId",
|
|
84921
|
+
"hop"
|
|
84922
|
+
]){
|
|
84923
|
+
if (error[key] === undefined && envelope[key] !== undefined) error[key] = envelope[key];
|
|
84917
84924
|
}
|
|
84918
84925
|
}
|
|
84919
84926
|
/** The route to the app-server is unavailable; `mode` is a stable machine-readable state. */ class CodexRouteError extends Error {
|
|
@@ -85568,7 +85575,7 @@ const ID_PATTERN = /^[A-Za-z0-9_.:-]{1,128}$/;
|
|
|
85568
85575
|
throw new CodexSendError("Refusing to send: hop " + hopCount + " reaches the relay bound " + bound + " (GROK_BOT_MAX_HOPS). " + "This message is an agent-to-agent relay that has already been forwarded too many times.", {
|
|
85569
85576
|
delivery: "rejected",
|
|
85570
85577
|
reason: "hop-limit",
|
|
85571
|
-
|
|
85578
|
+
...out
|
|
85572
85579
|
});
|
|
85573
85580
|
}
|
|
85574
85581
|
return out;
|
|
@@ -85656,20 +85663,20 @@ function unsupportedOrRpc(err, method, threadId, envelope) {
|
|
|
85656
85663
|
delivery: "rejected",
|
|
85657
85664
|
reason: "unsupported",
|
|
85658
85665
|
threadId,
|
|
85659
|
-
envelope
|
|
85666
|
+
...envelope
|
|
85660
85667
|
});
|
|
85661
85668
|
}
|
|
85662
85669
|
if (err instanceof CodexRpcError) return new CodexSendError(err.message, {
|
|
85663
85670
|
delivery: "rejected",
|
|
85664
85671
|
reason: "rejected",
|
|
85665
85672
|
threadId,
|
|
85666
|
-
envelope
|
|
85673
|
+
...envelope
|
|
85667
85674
|
});
|
|
85668
85675
|
return new CodexSendError("Lost the Codex " + method + " response for thread " + threadId + ": " + (err && err.message || err) + ". Delivery is unknown; list the queue before resending.", {
|
|
85669
85676
|
delivery: err && err.delivery || "unknown",
|
|
85670
85677
|
reason: "transport",
|
|
85671
85678
|
threadId,
|
|
85672
|
-
envelope
|
|
85679
|
+
...envelope
|
|
85673
85680
|
});
|
|
85674
85681
|
}
|
|
85675
85682
|
/** Read the daemon's queue for one thread (experimental `thread/queue/list`). */ async function listCodexQueue(threadId, { env = process.env, limit = 50, cursor } = {}) {
|
|
@@ -85720,7 +85727,7 @@ function unsupportedOrRpc(err, method, threadId, envelope) {
|
|
|
85720
85727
|
return (0,_codex_contract_js__rspack_import_7/* .outcomeFromReceipt */.Dz)(receipt);
|
|
85721
85728
|
} catch (err) {
|
|
85722
85729
|
// Every receipt names the message, including refusals that never reached the daemon.
|
|
85723
|
-
if (
|
|
85730
|
+
if (err instanceof CodexSendError || err instanceof CodexRouteError || err instanceof CodexProtocolError) attachEnvelope(err, envelope);
|
|
85724
85731
|
return (0,_codex_contract_js__rspack_import_7/* .outcomeFromError */.DG)(err);
|
|
85725
85732
|
}
|
|
85726
85733
|
}
|
|
@@ -85745,7 +85752,7 @@ async function sendToCodexThreadInner(threadId, text, { env, envelope, whenBusy
|
|
|
85745
85752
|
delivery: err instanceof CodexRpcError ? "rejected" : err && err.delivery || "unknown",
|
|
85746
85753
|
reason: err instanceof CodexRpcError ? /no rollout found|thread not found/i.test(String(err.rpc && err.rpc.message)) ? "unknown-thread" : /active writer/i.test(String(err.rpc && err.rpc.message)) ? "external-owner" : "rejected" : "transport",
|
|
85747
85754
|
threadId,
|
|
85748
|
-
envelope
|
|
85755
|
+
...envelope
|
|
85749
85756
|
});
|
|
85750
85757
|
}
|
|
85751
85758
|
if (!isObject(resumed) || !isObject(resumed.thread) || typeof resumed.thread.id !== "string") {
|
|
@@ -85772,7 +85779,7 @@ async function sendToCodexThreadInner(threadId, text, { env, envelope, whenBusy
|
|
|
85772
85779
|
delivery: "rejected",
|
|
85773
85780
|
reason: "busy",
|
|
85774
85781
|
threadId,
|
|
85775
|
-
envelope
|
|
85782
|
+
...envelope
|
|
85776
85783
|
});
|
|
85777
85784
|
}
|
|
85778
85785
|
if (state.busy) {
|
|
@@ -85797,7 +85804,7 @@ async function sendToCodexThreadInner(threadId, text, { env, envelope, whenBusy
|
|
|
85797
85804
|
delivery: "unknown",
|
|
85798
85805
|
reason: "bad-response",
|
|
85799
85806
|
threadId,
|
|
85800
|
-
envelope
|
|
85807
|
+
...envelope
|
|
85801
85808
|
});
|
|
85802
85809
|
}
|
|
85803
85810
|
return {
|
|
@@ -85843,7 +85850,7 @@ async function sendToCodexThreadInner(threadId, text, { env, envelope, whenBusy
|
|
|
85843
85850
|
delivery,
|
|
85844
85851
|
reason: delivery === "rejected" ? "rejected" : "transport",
|
|
85845
85852
|
threadId,
|
|
85846
|
-
envelope
|
|
85853
|
+
...envelope
|
|
85847
85854
|
});
|
|
85848
85855
|
}
|
|
85849
85856
|
const turnId = turn && turn.turn && typeof turn.turn.id === "string" && turn.turn.id ? turn.turn.id : null;
|
|
@@ -85852,7 +85859,7 @@ async function sendToCodexThreadInner(threadId, text, { env, envelope, whenBusy
|
|
|
85852
85859
|
delivery: "unknown",
|
|
85853
85860
|
reason: "bad-response",
|
|
85854
85861
|
threadId,
|
|
85855
|
-
envelope
|
|
85862
|
+
...envelope
|
|
85856
85863
|
});
|
|
85857
85864
|
}
|
|
85858
85865
|
client._adoptTurn(turnId);
|
|
@@ -85874,7 +85881,7 @@ async function sendToCodexThreadInner(threadId, text, { env, envelope, whenBusy
|
|
|
85874
85881
|
threadId,
|
|
85875
85882
|
turnId,
|
|
85876
85883
|
refused: freshRefused.map((r)=>r.method),
|
|
85877
|
-
envelope
|
|
85884
|
+
...envelope
|
|
85878
85885
|
});
|
|
85879
85886
|
}
|
|
85880
85887
|
return {
|
|
@@ -85960,8 +85967,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
85960
85967
|
}
|
|
85961
85968
|
/**
|
|
85962
85969
|
* Flatten a thrown error into the #46 send/failure document (plus exitCode).
|
|
85963
|
-
* Preserves the legacy failure-document fields, then adds exitCode for the
|
|
85964
|
-
* generated CLI's `exitCode: 'result'` policy.
|
|
85965
85970
|
*
|
|
85966
85971
|
* @param {unknown} error
|
|
85967
85972
|
* @param {{ isUsage?: (err: unknown) => boolean }} [opts]
|
|
@@ -85988,12 +85993,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
85988
85993
|
if (error[key] !== undefined) out[key] = error[key];
|
|
85989
85994
|
}
|
|
85990
85995
|
if (out.reason === undefined && isUsage(error)) out.reason = "usage";
|
|
85991
|
-
const envelope = /** @type {{ messageId?: string, correlationId?: string, hop?: number }} */ error.envelope;
|
|
85992
|
-
if (envelope && typeof envelope === "object") {
|
|
85993
|
-
if (envelope.messageId !== undefined) out.messageId = envelope.messageId;
|
|
85994
|
-
if (envelope.correlationId !== undefined) out.correlationId = envelope.correlationId;
|
|
85995
|
-
if (envelope.hop !== undefined) out.hop = envelope.hop;
|
|
85996
|
-
}
|
|
85997
85996
|
}
|
|
85998
85997
|
if (out.delivery === undefined) out.delivery = "rejected";
|
|
85999
85998
|
return /** @type {CodexSendOutcome & { error: string, exitCode: 1 }} */ {
|
|
@@ -86010,14 +86009,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
86010
86009
|
...receipt
|
|
86011
86010
|
};
|
|
86012
86011
|
if (base.delivery === undefined) base.delivery = "accepted";
|
|
86013
|
-
// Flatten envelope onto the document when present (matches fail() + json print).
|
|
86014
|
-
const envelope = base.envelope;
|
|
86015
|
-
if (envelope && typeof envelope === "object") {
|
|
86016
|
-
const e = /** @type {Record<string, unknown>} */ envelope;
|
|
86017
|
-
if (base.messageId === undefined && e.messageId !== undefined) base.messageId = e.messageId;
|
|
86018
|
-
if (base.correlationId === undefined && e.correlationId !== undefined) base.correlationId = e.correlationId;
|
|
86019
|
-
if (base.hop === undefined && e.hop !== undefined) base.hop = e.hop;
|
|
86020
|
-
}
|
|
86021
86012
|
const exitCode = sendExitCode(/** @type {{ delivery: CodexDelivery, reason?: string, error?: string }} */ base);
|
|
86022
86013
|
if (exitCode === 1 && base.error === undefined && base.reason === "approval-refused") {
|
|
86023
86014
|
base.error = typeof base.message === "string" ? base.message : "Codex refused one or more approvals.";
|
|
@@ -86066,7 +86057,7 @@ async function openBackend(opts) {
|
|
|
86066
86057
|
setGroupMembers: (group, members)=>_gateway_js__rspack_import_1/* .setGroupMembers */.Td(session, group, members),
|
|
86067
86058
|
addGroupMember: (group, bot)=>_gateway_js__rspack_import_1/* .addGroupMember */.zr(session, group, bot),
|
|
86068
86059
|
removeGroupMember: (group, bot)=>_gateway_js__rspack_import_1/* .removeGroupMember */.A0(session, group, bot),
|
|
86069
|
-
send: (ref, prompt
|
|
86060
|
+
send: (ref, prompt)=>_gateway_js__rspack_import_1/* .sendPrompt */.LV(session, ref, prompt),
|
|
86070
86061
|
transcript: (ref, limit)=>_gateway_js__rspack_import_1/* .getTranscriptTail */.bA(session, ref, limit),
|
|
86071
86062
|
thread: (ref, rootId)=>_gateway_js__rspack_import_1/* .getThread */.fG(session, ref, rootId)
|
|
86072
86063
|
};
|
|
@@ -86702,7 +86693,7 @@ function formatTranscript(out, { full = false } = {}) {
|
|
|
86702
86693
|
for (const e of entries){
|
|
86703
86694
|
const role = e.role || e.kind || e.sender || e.type || "msg";
|
|
86704
86695
|
const text = (0,_transcript_js__rspack_import_0/* .entryText */.u0)(e);
|
|
86705
|
-
const id = e.id ||
|
|
86696
|
+
const id = e.id || "";
|
|
86706
86697
|
lines.push("[" + role + (id ? " " + id : "") + "] " + (full ? text : truncateCliText(text)));
|
|
86707
86698
|
}
|
|
86708
86699
|
return lines.join("\n");
|
|
@@ -86798,19 +86789,17 @@ class GatewayError extends Error {
|
|
|
86798
86789
|
const GATEWAY_TIMEOUT_MS = 30000;
|
|
86799
86790
|
const GATEWAY_MAX_RESPONSE_BYTES = 2 * 1024 * 1024;
|
|
86800
86791
|
function backendBase() {
|
|
86801
|
-
return (process.env.
|
|
86792
|
+
return (process.env.CURSOR_API_BASE_URL || "https://api2.cursor.sh").replace(/\/$/, "");
|
|
86802
86793
|
}
|
|
86803
86794
|
function accessTokenFromEnv() {
|
|
86804
|
-
return (process.env.CURSOR_ACCESS_TOKEN ||
|
|
86795
|
+
return (process.env.CURSOR_ACCESS_TOKEN || "").trim();
|
|
86805
86796
|
}
|
|
86806
86797
|
function gatewayTokenFromEnv() {
|
|
86807
|
-
return (process.env.GROK_BOT_GATEWAY_TOKEN ||
|
|
86798
|
+
return (process.env.GROK_BOT_GATEWAY_TOKEN || "").trim();
|
|
86808
86799
|
}
|
|
86809
86800
|
function gatewayOverride() {
|
|
86810
86801
|
const token = gatewayTokenFromEnv();
|
|
86811
|
-
const
|
|
86812
|
-
const localUrl = token ? "http://127.0.0.1:" + (process.env.SAND_HOST_PORT || "1340") : "";
|
|
86813
|
-
const url = explicitUrl || localUrl;
|
|
86802
|
+
const url = (process.env.GROK_BOT_GATEWAY_URL || "").trim();
|
|
86814
86803
|
if (url && token) {
|
|
86815
86804
|
return {
|
|
86816
86805
|
gatewayUrl: (0,_url_policy_js__rspack_import_3/* .assertAllowedCredentialUrl */.Re)(url.replace(/\/$/, ""), {
|
|
@@ -87130,14 +87119,13 @@ async function removeGroupMember(session, groupRef, memberRef) {
|
|
|
87130
87119
|
const next = group.memberIds.filter((id)=>id !== member.id);
|
|
87131
87120
|
return setGroupMembers(session, group.id, next);
|
|
87132
87121
|
}
|
|
87133
|
-
async function sendPrompt(session, ref, prompt
|
|
87122
|
+
async function sendPrompt(session, ref, prompt) {
|
|
87134
87123
|
const rec = await resolveRef(session, ref);
|
|
87135
87124
|
const body = {
|
|
87136
87125
|
agentId: rec.id,
|
|
87137
87126
|
prompt,
|
|
87138
|
-
clientNonce:
|
|
87127
|
+
clientNonce: (0,node_crypto__rspack_import_0.randomUUID)()
|
|
87139
87128
|
};
|
|
87140
|
-
if (extra.replyToId) body.replyToId = extra.replyToId;
|
|
87141
87129
|
let data;
|
|
87142
87130
|
try {
|
|
87143
87131
|
data = await gatewayCall(session, "sendPrompt", body);
|
|
@@ -87314,8 +87302,8 @@ function saveHistory(out, { dir, disabled, event, prompt, rootId } = {}) {
|
|
|
87314
87302
|
rootId
|
|
87315
87303
|
} : {},
|
|
87316
87304
|
role: String(entry.role || entry.kind || entry.sender || entry.type || "msg"),
|
|
87317
|
-
...entry.id
|
|
87318
|
-
messageId: String(entry.id
|
|
87305
|
+
...entry.id ? {
|
|
87306
|
+
messageId: String(entry.id)
|
|
87319
87307
|
} : {},
|
|
87320
87308
|
...entry.timestamp || entry.createdAt ? {
|
|
87321
87309
|
timestamp: String(entry.timestamp || entry.createdAt)
|
|
@@ -87459,10 +87447,7 @@ function isUuid(value) {
|
|
|
87459
87447
|
function defaultCandidateRoots() {
|
|
87460
87448
|
const home = (0,node_os__rspack_import_2.homedir)();
|
|
87461
87449
|
const env = [
|
|
87462
|
-
process.env.GROK_BOT_AGENTS_DIR
|
|
87463
|
-
process.env.SAND_AGENTS_DIR,
|
|
87464
|
-
process.env.SAND_DATA_ROOT && (0,node_path__rspack_import_3.join)(process.env.SAND_DATA_ROOT, "agents"),
|
|
87465
|
-
process.env.SAND_DATA_ROOT && (0,node_path__rspack_import_3.join)(process.env.SAND_DATA_ROOT, "agent-data", "agents")
|
|
87450
|
+
process.env.GROK_BOT_AGENTS_DIR
|
|
87466
87451
|
].filter(Boolean);
|
|
87467
87452
|
return [
|
|
87468
87453
|
...env,
|
|
@@ -87741,7 +87726,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
87741
87726
|
|
|
87742
87727
|
},
|
|
87743
87728
|
"./src/core/transcript.js"(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
87744
|
-
// Shared by `gbot thread` and the grok-bot plugin's gbot_thread tool.
|
|
87745
87729
|
/** Coerce anything to a string without throwing (numbers, BigInt, unserializable objects). */ function toSafeText(value) {
|
|
87746
87730
|
if (typeof value === "string") return value;
|
|
87747
87731
|
if (value == null) return "";
|
|
@@ -87779,15 +87763,12 @@ function entryTextRaw(e) {
|
|
|
87779
87763
|
return typeof e.preview === "string" ? e.preview : "";
|
|
87780
87764
|
}
|
|
87781
87765
|
function transcriptEntries(payload) {
|
|
87782
|
-
if (Array.isArray(payload)) return payload;
|
|
87783
87766
|
if (!payload || typeof payload !== "object") return [];
|
|
87784
|
-
|
|
87785
|
-
return Array.isArray(entries) ? entries : [];
|
|
87767
|
+
return Array.isArray(payload.entries) ? payload.entries : [];
|
|
87786
87768
|
}
|
|
87787
87769
|
function sourceEntryId(entry) {
|
|
87788
87770
|
if (!entry || typeof entry !== "object") return "";
|
|
87789
|
-
|
|
87790
|
-
return typeof entry.messageId === "string" ? entry.messageId : "";
|
|
87771
|
+
return typeof entry.id === "string" ? entry.id : "";
|
|
87791
87772
|
}
|
|
87792
87773
|
function lastSourceId(entries, fallback = "") {
|
|
87793
87774
|
for(let index = entries.length - 1; index >= 0; index -= 1){
|
package/dist/install.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'nod
|
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
8
|
|
|
9
9
|
const pluginName = "gbot";
|
|
10
|
-
const pluginVersion = "0.
|
|
10
|
+
const pluginVersion = "0.5.0";
|
|
11
11
|
const receiptFile = ".agent-bundle-install.json";
|
|
12
12
|
const receiptFormat = "agent-bundle-install-receipt/2";
|
|
13
13
|
const legacyReceiptFormat = "agent-bundle-install-receipt/1";
|