@rallycry/conveyor-agent 10.4.0 → 10.4.4
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/{chunk-TZYEU4QE.js → chunk-VCXKVINO.js} +155 -91
- package/dist/chunk-VCXKVINO.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-TZYEU4QE.js.map +0 -1
|
@@ -719,13 +719,16 @@ var AgentConnection = class _AgentConnection {
|
|
|
719
719
|
};
|
|
720
720
|
}
|
|
721
721
|
// ── Convenience methods (thin wrappers around call / emit) ─────────
|
|
722
|
-
async emitStatus(status, reason) {
|
|
722
|
+
async emitStatus(status, reason, questionText) {
|
|
723
723
|
this.lastEmittedStatus = status;
|
|
724
724
|
await this.flushEvents();
|
|
725
725
|
const payload = {
|
|
726
726
|
sessionId: this.config.sessionId,
|
|
727
727
|
status,
|
|
728
|
-
...reason ? { reason } : {}
|
|
728
|
+
...reason ? { reason } : {},
|
|
729
|
+
// Only sent with a pending TUI questionnaire (reason "user_question") so
|
|
730
|
+
// the server can surface the real question text in the notification.
|
|
731
|
+
...questionText ? { questionText } : {}
|
|
729
732
|
};
|
|
730
733
|
const AWAIT_STATUSES = ["idle", "waiting_for_input", "connected"];
|
|
731
734
|
if (AWAIT_STATUSES.includes(status)) {
|
|
@@ -2046,7 +2049,14 @@ var ReportAgentStatusRequestSchema = z.object({
|
|
|
2046
2049
|
sessionId: z.string(),
|
|
2047
2050
|
status: z.string(),
|
|
2048
2051
|
/** Why the agent reports this status (e.g. "user_question" while an AskUserQuestion questionnaire is pending in the TUI). */
|
|
2049
|
-
reason: z.string().optional()
|
|
2052
|
+
reason: z.string().optional(),
|
|
2053
|
+
/**
|
|
2054
|
+
* The pending question text, sent only alongside `reason: "user_question"`
|
|
2055
|
+
* so the server can surface it in the user-question notification body (and
|
|
2056
|
+
* thus the Attention feed) instead of a generic string. Optional: older
|
|
2057
|
+
* agents omit it and the server falls back to the generic wording.
|
|
2058
|
+
*/
|
|
2059
|
+
questionText: z.string().optional()
|
|
2050
2060
|
});
|
|
2051
2061
|
var NotifyAgentVersionRequestSchema = z.object({
|
|
2052
2062
|
sessionId: z.string(),
|
|
@@ -2069,7 +2079,10 @@ var CreateSubtaskRequestSchema = z.object({
|
|
|
2069
2079
|
plan: z.string().optional(),
|
|
2070
2080
|
storyPointValue: z.number().int().positive().optional(),
|
|
2071
2081
|
ordinal: z.number().int().nonnegative().optional(),
|
|
2072
|
-
followParentStatus: z.boolean().optional()
|
|
2082
|
+
followParentStatus: z.boolean().optional(),
|
|
2083
|
+
/** Sibling subtask ids or slugs this subtask blocks on (explicit dependency
|
|
2084
|
+
* metadata — preferred over encoding order in plan text / ordinal). */
|
|
2085
|
+
dependsOn: z.array(z.string().min(1)).max(32).optional()
|
|
2073
2086
|
});
|
|
2074
2087
|
var UpdateSubtaskRequestSchema = z.object({
|
|
2075
2088
|
sessionId: z.string(),
|
|
@@ -2079,7 +2092,10 @@ var UpdateSubtaskRequestSchema = z.object({
|
|
|
2079
2092
|
plan: z.string().optional(),
|
|
2080
2093
|
status: z.string().optional(),
|
|
2081
2094
|
storyPointValue: z.number().int().positive().optional(),
|
|
2082
|
-
followParentStatus: z.boolean().optional()
|
|
2095
|
+
followParentStatus: z.boolean().optional(),
|
|
2096
|
+
/** Replace this subtask's dependency edges with these sibling ids/slugs.
|
|
2097
|
+
* Empty array clears all. Omit to leave dependencies unchanged. */
|
|
2098
|
+
dependsOn: z.array(z.string().min(1)).max(32).optional()
|
|
2083
2099
|
});
|
|
2084
2100
|
var DeleteSubtaskRequestSchema = z.object({
|
|
2085
2101
|
sessionId: z.string(),
|
|
@@ -2500,6 +2516,9 @@ var CreateProjectSubtaskRequestSchema = z2.object({
|
|
|
2500
2516
|
ordinal: z2.number().int().nonnegative().optional(),
|
|
2501
2517
|
storyPointValue: z2.number().int().positive().optional(),
|
|
2502
2518
|
followParentStatus: z2.boolean().optional(),
|
|
2519
|
+
/** Sibling subtask ids or slugs this subtask blocks on (explicit dependency
|
|
2520
|
+
* metadata — preferred over encoding order in plan text / ordinal). */
|
|
2521
|
+
dependsOn: z2.array(z2.string().min(1)).max(32).optional(),
|
|
2503
2522
|
requestingUserId: z2.string().optional()
|
|
2504
2523
|
});
|
|
2505
2524
|
var UpdateProjectSubtaskRequestSchema = z2.object({
|
|
@@ -3950,6 +3969,9 @@ async function startToolServers(mcpServers, tempDir) {
|
|
|
3950
3969
|
}
|
|
3951
3970
|
|
|
3952
3971
|
// src/harness/pty/spawn-args.ts
|
|
3972
|
+
function resolveClaudeBinary() {
|
|
3973
|
+
return process.env.CONVEYOR_CLAUDE_BIN ?? "claude";
|
|
3974
|
+
}
|
|
3953
3975
|
function buildSpawnArgs(input) {
|
|
3954
3976
|
const args = [];
|
|
3955
3977
|
if (input.resume) {
|
|
@@ -4239,9 +4261,9 @@ function extractSpawn(mod) {
|
|
|
4239
4261
|
}
|
|
4240
4262
|
async function loadPtySpawn() {
|
|
4241
4263
|
const mod = await import("node-pty");
|
|
4242
|
-
const
|
|
4243
|
-
if (!
|
|
4244
|
-
return
|
|
4264
|
+
const spawn3 = extractSpawn(mod);
|
|
4265
|
+
if (!spawn3) throw new Error("node-pty: spawn export not found");
|
|
4266
|
+
return spawn3;
|
|
4245
4267
|
}
|
|
4246
4268
|
function inheritedEnv(socketPath) {
|
|
4247
4269
|
const env = {};
|
|
@@ -4740,8 +4762,8 @@ var PtySession = class {
|
|
|
4740
4762
|
// server doesn't load).
|
|
4741
4763
|
...this.mcpConfigPath ? { mcpConfigPath: this.mcpConfigPath } : {}
|
|
4742
4764
|
});
|
|
4743
|
-
const
|
|
4744
|
-
const pty =
|
|
4765
|
+
const spawn3 = await loadPtySpawn();
|
|
4766
|
+
const pty = spawn3(spec.file, spec.args, {
|
|
4745
4767
|
name: "xterm-color",
|
|
4746
4768
|
cols: this.cols,
|
|
4747
4769
|
rows: this.rows,
|
|
@@ -5195,7 +5217,7 @@ function buildPackRunnerSystemPrompt(context, config, setupLog) {
|
|
|
5195
5217
|
``,
|
|
5196
5218
|
`## Important Rules`,
|
|
5197
5219
|
`- When dependencies are set on children, use them to determine execution order. Fire all ready tasks in parallel (up to the PACK_CHILD_LIMIT backpressure \u2014 see the loop above).`,
|
|
5198
|
-
`- When NO dependencies are set on any children, fall back to ordinal order (one at a time)
|
|
5220
|
+
`- Dependencies are explicit card metadata (set at creation via create_subtask's dependsOn, or rewired with update_subtask). Prefer them over reading order out of plan text. When NO dependencies are set on any children, fall back to ordinal order (one at a time) \u2014 this is legacy behavior; set dependsOn when a child truly blocks on another.`,
|
|
5199
5221
|
`- After firing builds OR when waiting on CI, explicitly state you are going idle. Go idle when waiting \u2014 the system wakes you (or relaunches this environment) when a child changes status.`,
|
|
5200
5222
|
`- Do NOT attempt to write code yourself. Your role is coordination only.`,
|
|
5201
5223
|
`- If a child is stuck in "InProgress" for an unusually long time, use get_execution_logs(childTaskId) to check its logs and escalate to the team if it appears stuck.`,
|
|
@@ -5816,7 +5838,8 @@ function buildDiscoveryPrompt(context, runnerMode) {
|
|
|
5816
5838
|
`### Parent Task Coordination`,
|
|
5817
5839
|
`You are a parent task with child tasks. Focus on breaking work into child tasks with detailed plans, not planning implementation for yourself.`,
|
|
5818
5840
|
`- Use \`list_subtasks\` to review existing children. Create or update child tasks using \`create_subtask\` / \`update_subtask\`.`,
|
|
5819
|
-
`- Each child task should be a self-contained unit of work with a clear plan
|
|
5841
|
+
`- Each child task should be a self-contained unit of work with a clear plan.`,
|
|
5842
|
+
`- Set ordering as explicit **card metadata**, not prose: pass \`dependsOn\` (sibling ids/slugs) on \`create_subtask\` for any child that blocks on another. Leave independent children with no dependencies so the pack runner fans them out in parallel. Do NOT encode "do X after Y" only in the plan text \u2014 the runner schedules off dependsOn, not narrative.`
|
|
5820
5843
|
] : [
|
|
5821
5844
|
`### Self-Update vs Subtasks`,
|
|
5822
5845
|
`- If the work fits in a single task (1-3 SP), update YOUR OWN plan and properties \u2014 do not create subtasks`,
|
|
@@ -5830,6 +5853,7 @@ function buildDiscoveryPrompt(context, runnerMode) {
|
|
|
5830
5853
|
`- Reference existing implementations when relevant (e.g., "follow the pattern in src/services/foo.ts")`,
|
|
5831
5854
|
`- Include testing requirements and acceptance criteria`,
|
|
5832
5855
|
`- Set \`storyPointValue\` based on estimated complexity`,
|
|
5856
|
+
`- Express cross-child ordering as \`dependsOn\` (sibling ids/slugs) on \`create_subtask\` \u2014 explicit dependency metadata, not "after task 2" phrasing in the plan. Independent children get no dependencies so they run in parallel.`,
|
|
5833
5857
|
``,
|
|
5834
5858
|
`### Plan Verification Requirements`,
|
|
5835
5859
|
`Every plan MUST include a **Testing / Verification** section so the build agent has a clear definition of "done". Enumerate:`,
|
|
@@ -5876,6 +5900,7 @@ function buildAutoPrompt(context, runnerMode) {
|
|
|
5876
5900
|
`- Reference existing implementations when relevant`,
|
|
5877
5901
|
`- Include testing requirements and acceptance criteria`,
|
|
5878
5902
|
`- Set \`storyPointValue\` based on estimated complexity`,
|
|
5903
|
+
`- Express cross-child ordering as \`dependsOn\` (sibling ids/slugs) on \`create_subtask\` \u2014 explicit dependency metadata, not "after task 2" phrasing in the plan. Independent children get no dependencies so they run in parallel.`,
|
|
5879
5904
|
``,
|
|
5880
5905
|
...buildPlanCitationFormat(),
|
|
5881
5906
|
``,
|
|
@@ -5884,7 +5909,8 @@ function buildAutoPrompt(context, runnerMode) {
|
|
|
5884
5909
|
`### Parent Task Guidance`,
|
|
5885
5910
|
`You are a parent task. Your plan should define child tasks with detailed plans, not direct implementation steps.`,
|
|
5886
5911
|
`After ExitPlanMode, you'll transition to Review mode to coordinate child task execution.`,
|
|
5887
|
-
`Child task status lifecycle: Open \u2192 InProgress \u2192 ReviewPR \u2192 ReviewDev \u2192 Complete
|
|
5912
|
+
`Child task status lifecycle: Open \u2192 InProgress \u2192 ReviewPR \u2192 ReviewDev \u2192 Complete.`,
|
|
5913
|
+
`Set child ordering with \`dependsOn\` (sibling ids/slugs) on \`create_subtask\` \u2014 explicit metadata the pack runner schedules off, not order described in plan text. Independent children get none and run in parallel.`
|
|
5888
5914
|
] : [],
|
|
5889
5915
|
``,
|
|
5890
5916
|
`### Autonomous Guidelines:`,
|
|
@@ -7359,6 +7385,7 @@ function buildCommonTools(connection, config) {
|
|
|
7359
7385
|
import { z as z9 } from "zod";
|
|
7360
7386
|
var SP_DESCRIPTION = "Story point value (1=Common, 2=Magic, 3=Rare, 5=Unique)";
|
|
7361
7387
|
var FOLLOW_PARENT_STATUS_DESCRIPTION = "Child mirrors the parent task's status automatically \u2014 for subtasks that ship on the parent's branch/PR with no build or PR of their own. Manual status writes on a follower stick only until the parent's next transition.";
|
|
7388
|
+
var DEPENDS_ON_DESCRIPTION = "Sibling subtask ids or slugs this subtask blocks on (it won't start until they merge to dev). Set explicit dependency metadata here instead of describing order in the plan text \u2014 the pack runner schedules children off these edges. Omit / leave empty for independent children so they run in parallel.";
|
|
7362
7389
|
function buildUpdateTaskTool(connection) {
|
|
7363
7390
|
return defineTool(
|
|
7364
7391
|
"update_task_plan",
|
|
@@ -7391,9 +7418,18 @@ function buildCreateSubtaskTool(connection) {
|
|
|
7391
7418
|
plan: z9.string().optional().describe("Implementation plan in markdown"),
|
|
7392
7419
|
ordinal: z9.number().optional().describe("Step/order number (0-based)"),
|
|
7393
7420
|
storyPointValue: z9.number().optional().describe(SP_DESCRIPTION),
|
|
7394
|
-
followParentStatus: z9.boolean().optional().describe(FOLLOW_PARENT_STATUS_DESCRIPTION)
|
|
7421
|
+
followParentStatus: z9.boolean().optional().describe(FOLLOW_PARENT_STATUS_DESCRIPTION),
|
|
7422
|
+
dependsOn: z9.array(z9.string()).optional().describe(DEPENDS_ON_DESCRIPTION)
|
|
7395
7423
|
},
|
|
7396
|
-
async ({
|
|
7424
|
+
async ({
|
|
7425
|
+
title,
|
|
7426
|
+
description,
|
|
7427
|
+
plan,
|
|
7428
|
+
ordinal,
|
|
7429
|
+
storyPointValue,
|
|
7430
|
+
followParentStatus,
|
|
7431
|
+
dependsOn
|
|
7432
|
+
}) => {
|
|
7397
7433
|
try {
|
|
7398
7434
|
const result = await connection.call("createSubtask", {
|
|
7399
7435
|
sessionId: connection.sessionId,
|
|
@@ -7402,9 +7438,10 @@ function buildCreateSubtaskTool(connection) {
|
|
|
7402
7438
|
...plan !== void 0 && { plan },
|
|
7403
7439
|
...storyPointValue !== void 0 && { storyPointValue },
|
|
7404
7440
|
...ordinal !== void 0 && { ordinal },
|
|
7405
|
-
...followParentStatus !== void 0 && { followParentStatus }
|
|
7441
|
+
...followParentStatus !== void 0 && { followParentStatus },
|
|
7442
|
+
...dependsOn !== void 0 && { dependsOn }
|
|
7406
7443
|
});
|
|
7407
|
-
return textResult(`Subtask created with ID: ${result.id}`);
|
|
7444
|
+
return textResult(`Subtask created with ID: ${result.id} (slug: ${result.slug})`);
|
|
7408
7445
|
} catch (error) {
|
|
7409
7446
|
return textResult(
|
|
7410
7447
|
`Failed to create subtask: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
@@ -7416,7 +7453,7 @@ function buildCreateSubtaskTool(connection) {
|
|
|
7416
7453
|
function buildUpdateSubtaskTool(connection) {
|
|
7417
7454
|
return defineTool(
|
|
7418
7455
|
"update_subtask",
|
|
7419
|
-
"Update an existing subtask's fields (title, description, plan, ordinal, storyPointValue). Use when refining a child's plan or
|
|
7456
|
+
"Update an existing subtask's fields (title, description, plan, ordinal, storyPointValue, dependsOn). Use when refining a child's plan, reordering, or rewiring dependencies. For the current task use update_task_plan.",
|
|
7420
7457
|
{
|
|
7421
7458
|
subtaskId: z9.string().describe("The subtask ID to update"),
|
|
7422
7459
|
title: z9.string().optional(),
|
|
@@ -7424,9 +7461,20 @@ function buildUpdateSubtaskTool(connection) {
|
|
|
7424
7461
|
plan: z9.string().optional(),
|
|
7425
7462
|
ordinal: z9.number().optional(),
|
|
7426
7463
|
storyPointValue: z9.number().optional().describe(SP_DESCRIPTION),
|
|
7427
|
-
followParentStatus: z9.boolean().optional().describe(FOLLOW_PARENT_STATUS_DESCRIPTION)
|
|
7464
|
+
followParentStatus: z9.boolean().optional().describe(FOLLOW_PARENT_STATUS_DESCRIPTION),
|
|
7465
|
+
dependsOn: z9.array(z9.string()).optional().describe(
|
|
7466
|
+
`${DEPENDS_ON_DESCRIPTION} Replaces the full dependency set \u2014 pass [] to clear all, omit to leave unchanged.`
|
|
7467
|
+
)
|
|
7428
7468
|
},
|
|
7429
|
-
async ({
|
|
7469
|
+
async ({
|
|
7470
|
+
subtaskId,
|
|
7471
|
+
title,
|
|
7472
|
+
description,
|
|
7473
|
+
plan,
|
|
7474
|
+
storyPointValue,
|
|
7475
|
+
followParentStatus,
|
|
7476
|
+
dependsOn
|
|
7477
|
+
}) => {
|
|
7430
7478
|
try {
|
|
7431
7479
|
await connection.call("updateSubtask", {
|
|
7432
7480
|
sessionId: connection.sessionId,
|
|
@@ -7435,7 +7483,8 @@ function buildUpdateSubtaskTool(connection) {
|
|
|
7435
7483
|
...description !== void 0 && { description },
|
|
7436
7484
|
...plan !== void 0 && { plan },
|
|
7437
7485
|
...storyPointValue !== void 0 && { storyPointValue },
|
|
7438
|
-
...followParentStatus !== void 0 && { followParentStatus }
|
|
7486
|
+
...followParentStatus !== void 0 && { followParentStatus },
|
|
7487
|
+
...dependsOn !== void 0 && { dependsOn }
|
|
7439
7488
|
});
|
|
7440
7489
|
return textResult("Subtask updated.");
|
|
7441
7490
|
} catch (error) {
|
|
@@ -8040,9 +8089,17 @@ async function handleResultCase(event, host, context, startTime, isTyping, lastA
|
|
|
8040
8089
|
function hasAskUserQuestionBlock(event) {
|
|
8041
8090
|
return event.message.content.some((b) => b.type === "tool_use" && b.name === "AskUserQuestion");
|
|
8042
8091
|
}
|
|
8043
|
-
|
|
8092
|
+
function questionTextFromEvent(event) {
|
|
8093
|
+
const text = event.questions.map((q) => q.question.trim()).filter((q) => q.length > 0).join("\n");
|
|
8094
|
+
return text.length > 0 ? text : void 0;
|
|
8095
|
+
}
|
|
8096
|
+
async function armQuestionPending(host, state, event) {
|
|
8044
8097
|
state.questionPending = true;
|
|
8045
|
-
await host.connection.emitStatus(
|
|
8098
|
+
await host.connection.emitStatus(
|
|
8099
|
+
"waiting_for_input",
|
|
8100
|
+
AGENT_STATUS_REASON_USER_QUESTION,
|
|
8101
|
+
questionTextFromEvent(event)
|
|
8102
|
+
);
|
|
8046
8103
|
await host.callbacks.onStatusChange("waiting_for_input");
|
|
8047
8104
|
}
|
|
8048
8105
|
async function clearQuestionPending(host, state, options) {
|
|
@@ -8056,7 +8113,7 @@ async function clearQuestionPending(host, state, options) {
|
|
|
8056
8113
|
async function applyQuestionTransitions(event, host, state) {
|
|
8057
8114
|
switch (event.type) {
|
|
8058
8115
|
case "user_question":
|
|
8059
|
-
await armQuestionPending(host, state);
|
|
8116
|
+
await armQuestionPending(host, state, event);
|
|
8060
8117
|
return;
|
|
8061
8118
|
case "assistant":
|
|
8062
8119
|
if (!hasAskUserQuestionBlock(event)) {
|
|
@@ -9493,74 +9550,77 @@ function readAgentVersion() {
|
|
|
9493
9550
|
return null;
|
|
9494
9551
|
}
|
|
9495
9552
|
|
|
9496
|
-
// src/
|
|
9497
|
-
|
|
9498
|
-
|
|
9499
|
-
|
|
9500
|
-
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
"seven_day_sonnet"
|
|
9505
|
-
];
|
|
9506
|
-
function normalizeUtilization(raw) {
|
|
9507
|
-
if (typeof raw !== "number" || !Number.isFinite(raw)) return null;
|
|
9508
|
-
const fraction = raw > 1 ? raw / 100 : raw;
|
|
9509
|
-
return Math.max(0, Math.min(1, fraction));
|
|
9510
|
-
}
|
|
9511
|
-
function extractBucket(value) {
|
|
9512
|
-
if (typeof value === "number") {
|
|
9513
|
-
const utilization = normalizeUtilization(value);
|
|
9514
|
-
return utilization === null ? null : { utilization, status: "allowed" };
|
|
9515
|
-
}
|
|
9516
|
-
if (value && typeof value === "object") {
|
|
9517
|
-
const obj = value;
|
|
9518
|
-
const utilization = normalizeUtilization(
|
|
9519
|
-
obj.utilization ?? obj.used ?? obj.percent ?? obj.percentage
|
|
9520
|
-
);
|
|
9521
|
-
if (utilization === null) return null;
|
|
9522
|
-
const status = typeof obj.status === "string" ? obj.status : "allowed";
|
|
9523
|
-
return { utilization, status };
|
|
9524
|
-
}
|
|
9525
|
-
return null;
|
|
9553
|
+
// src/usage/parse-usage.ts
|
|
9554
|
+
function parseUsageGauges(stdout) {
|
|
9555
|
+
const session = stdout.match(/Current session:\s*(\d+(?:\.\d+)?)%\s*used/i);
|
|
9556
|
+
const weekly = [...stdout.matchAll(/Current week[^:\n]*:\s*(\d+(?:\.\d+)?)%\s*used/gi)];
|
|
9557
|
+
return {
|
|
9558
|
+
sessionUsage: session ? Number(session[1]) / 100 : null,
|
|
9559
|
+
weeklyUsage: weekly.length ? Math.max(...weekly.map((m) => Number(m[1]))) / 100 : null
|
|
9560
|
+
};
|
|
9526
9561
|
}
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9562
|
+
|
|
9563
|
+
// src/usage/run-probe.ts
|
|
9564
|
+
import { spawn } from "child_process";
|
|
9565
|
+
var PROBE_TIMEOUT_MS = 15e3;
|
|
9566
|
+
function runUsageProbe(binary = resolveClaudeBinary(), args = ["-p", "/usage"]) {
|
|
9567
|
+
return new Promise((resolve) => {
|
|
9568
|
+
let stdout = "";
|
|
9569
|
+
let settled = false;
|
|
9570
|
+
const finish = (out) => {
|
|
9571
|
+
if (settled) return;
|
|
9572
|
+
settled = true;
|
|
9573
|
+
resolve(out);
|
|
9574
|
+
};
|
|
9575
|
+
let child;
|
|
9576
|
+
try {
|
|
9577
|
+
child = spawn(binary, args, { stdio: ["ignore", "pipe", "ignore"] });
|
|
9578
|
+
} catch {
|
|
9579
|
+
finish("");
|
|
9580
|
+
return;
|
|
9542
9581
|
}
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9582
|
+
const timer = setTimeout(() => {
|
|
9583
|
+
try {
|
|
9584
|
+
child.kill("SIGKILL");
|
|
9585
|
+
} catch {
|
|
9586
|
+
}
|
|
9587
|
+
finish("");
|
|
9588
|
+
}, PROBE_TIMEOUT_MS);
|
|
9589
|
+
timer.unref?.();
|
|
9590
|
+
child.stdout?.on("data", (d) => {
|
|
9591
|
+
stdout += d.toString();
|
|
9592
|
+
});
|
|
9593
|
+
child.on("error", () => {
|
|
9594
|
+
clearTimeout(timer);
|
|
9595
|
+
finish("");
|
|
9596
|
+
});
|
|
9597
|
+
child.on("close", (code) => {
|
|
9598
|
+
clearTimeout(timer);
|
|
9599
|
+
finish(code === 0 ? stdout : "");
|
|
9600
|
+
});
|
|
9601
|
+
});
|
|
9546
9602
|
}
|
|
9547
|
-
|
|
9603
|
+
|
|
9604
|
+
// src/execution/usage-sampler.ts
|
|
9605
|
+
var logger4 = createServiceLogger("usage-sampler");
|
|
9606
|
+
async function sampleKeyUsage(token, probe = runUsageProbe) {
|
|
9548
9607
|
if (!token) return [];
|
|
9549
9608
|
try {
|
|
9550
|
-
const
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
}
|
|
9555
|
-
}
|
|
9556
|
-
if (
|
|
9557
|
-
|
|
9558
|
-
return [];
|
|
9609
|
+
const stdout = await probe();
|
|
9610
|
+
const { sessionUsage, weeklyUsage } = parseUsageGauges(stdout);
|
|
9611
|
+
const samples = [];
|
|
9612
|
+
if (sessionUsage !== null) {
|
|
9613
|
+
samples.push({ rateLimitType: "five_hour", utilization: sessionUsage, status: "allowed" });
|
|
9614
|
+
}
|
|
9615
|
+
if (weeklyUsage !== null) {
|
|
9616
|
+
samples.push({ rateLimitType: "seven_day", utilization: weeklyUsage, status: "allowed" });
|
|
9559
9617
|
}
|
|
9560
|
-
|
|
9561
|
-
|
|
9618
|
+
if (samples.length === 0) {
|
|
9619
|
+
logger4.info("usage sample produced no gauges", { stdoutLength: stdout.length });
|
|
9620
|
+
}
|
|
9621
|
+
return samples;
|
|
9562
9622
|
} catch (error) {
|
|
9563
|
-
logger4.info("
|
|
9623
|
+
logger4.info("usage sample failed", {
|
|
9564
9624
|
error: error instanceof Error ? error.message : String(error)
|
|
9565
9625
|
});
|
|
9566
9626
|
return [];
|
|
@@ -10080,7 +10140,11 @@ var SessionRunner = class _SessionRunner {
|
|
|
10080
10140
|
const staleBatch = [...this.pendingMessages];
|
|
10081
10141
|
const didExecuteInitialQuery = await this.executeInitialMode();
|
|
10082
10142
|
if (staleBatch.length > 0 && didExecuteInitialQuery) {
|
|
10143
|
+
const historyContents = new Set(
|
|
10144
|
+
(this.fullContext?.chatHistory ?? []).filter((m) => m.role !== "assistant" && m.content.trim()).map((m) => m.content.trim())
|
|
10145
|
+
);
|
|
10083
10146
|
for (const stale of staleBatch) {
|
|
10147
|
+
if (stale.content.trim() && !historyContents.has(stale.content.trim())) continue;
|
|
10084
10148
|
const idx = this.pendingMessages.indexOf(stale);
|
|
10085
10149
|
if (idx !== -1) this.pendingMessages.splice(idx, 1);
|
|
10086
10150
|
}
|
|
@@ -10437,8 +10501,8 @@ var SessionRunner = class _SessionRunner {
|
|
|
10437
10501
|
this.periodicFlushInFlight = false;
|
|
10438
10502
|
}
|
|
10439
10503
|
}
|
|
10440
|
-
/** Sample the running Claude subscription key's rate-limit utilization from
|
|
10441
|
-
*
|
|
10504
|
+
/** Sample the running Claude subscription key's rate-limit utilization from
|
|
10505
|
+
* the Claude CLI `/usage` command and report it as `rate_limit_update` events.
|
|
10442
10506
|
* The API (`persistRateLimitSnapshot`) attributes them to the key this session
|
|
10443
10507
|
* launched under, keeping User Settings + the PtY-tab usage widget fresh and
|
|
10444
10508
|
* `selectBestKey` rotation honest. Best-effort — never throws, no-op when the
|
|
@@ -10933,10 +10997,10 @@ function loadConveyorConfig() {
|
|
|
10933
10997
|
}
|
|
10934
10998
|
|
|
10935
10999
|
// src/setup/commands.ts
|
|
10936
|
-
import { spawn, execSync } from "child_process";
|
|
11000
|
+
import { spawn as spawn2, execSync } from "child_process";
|
|
10937
11001
|
function runSetupCommand(cmd, cwd, onOutput) {
|
|
10938
11002
|
return new Promise((resolve, reject) => {
|
|
10939
|
-
const child =
|
|
11003
|
+
const child = spawn2("sh", ["-c", cmd], {
|
|
10940
11004
|
cwd,
|
|
10941
11005
|
stdio: ["ignore", "pipe", "pipe"],
|
|
10942
11006
|
env: { ...process.env }
|
|
@@ -10975,7 +11039,7 @@ function runAuthTokenCommand(cmd, userEmail, cwd) {
|
|
|
10975
11039
|
}
|
|
10976
11040
|
}
|
|
10977
11041
|
function runStartCommand(cmd, cwd, onOutput) {
|
|
10978
|
-
const child =
|
|
11042
|
+
const child = spawn2("sh", ["-c", cmd], {
|
|
10979
11043
|
cwd,
|
|
10980
11044
|
stdio: ["ignore", "pipe", "pipe"],
|
|
10981
11045
|
detached: true,
|
|
@@ -11046,4 +11110,4 @@ export {
|
|
|
11046
11110
|
runStartCommand,
|
|
11047
11111
|
unshallowRepo
|
|
11048
11112
|
};
|
|
11049
|
-
//# sourceMappingURL=chunk-
|
|
11113
|
+
//# sourceMappingURL=chunk-VCXKVINO.js.map
|