@rallycry/conveyor-agent 10.13.14 → 10.13.16

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 (33) hide show
  1. package/dist/boot-NMXFM4GK.js +1268 -0
  2. package/dist/boot-NMXFM4GK.js.map +1 -0
  3. package/dist/{server-TVIXWCAI.js → chunk-5UYMDSAE.js} +8 -3
  4. package/dist/chunk-5UYMDSAE.js.map +1 -0
  5. package/dist/chunk-6GS5ADIY.js +11 -0
  6. package/dist/chunk-6GS5ADIY.js.map +1 -0
  7. package/dist/{chunk-RSIW2UCR.js → chunk-JG54UJ6V.js} +2 -2
  8. package/dist/{chunk-VKZ5W2VO.js → chunk-JIGG755T.js} +1 -1
  9. package/dist/chunk-JIGG755T.js.map +1 -0
  10. package/dist/{chunk-J4UH5TOO.js → chunk-OW2TIDWZ.js} +71 -114
  11. package/dist/chunk-OW2TIDWZ.js.map +1 -0
  12. package/dist/{chunk-LZM5OKAC.js → chunk-UDSRAHKP.js} +19 -2
  13. package/dist/chunk-UDSRAHKP.js.map +1 -0
  14. package/dist/chunk-UZTJJD7Y.js +254 -0
  15. package/dist/chunk-UZTJJD7Y.js.map +1 -0
  16. package/dist/cli.js +30 -47
  17. package/dist/cli.js.map +1 -1
  18. package/dist/{client-VQIBGPE6.js → client-BU4XA7CV.js} +3 -3
  19. package/dist/index.d.ts +0 -1
  20. package/dist/index.js +5 -4
  21. package/dist/index.js.map +1 -1
  22. package/dist/{protocol-IHRTO5C4.js → protocol-QLVS5W6O.js} +2 -2
  23. package/dist/server-CO5O7G4U.js +9 -0
  24. package/dist/server-CO5O7G4U.js.map +1 -0
  25. package/package.json +1 -1
  26. package/runtime/entrypoint.sh +8 -975
  27. package/dist/chunk-J4UH5TOO.js.map +0 -1
  28. package/dist/chunk-LZM5OKAC.js.map +0 -1
  29. package/dist/chunk-VKZ5W2VO.js.map +0 -1
  30. package/dist/server-TVIXWCAI.js.map +0 -1
  31. /package/dist/{chunk-RSIW2UCR.js.map → chunk-JG54UJ6V.js.map} +0 -0
  32. /package/dist/{client-VQIBGPE6.js.map → client-BU4XA7CV.js.map} +0 -0
  33. /package/dist/{protocol-IHRTO5C4.js.map → protocol-QLVS5W6O.js.map} +0 -0
@@ -3,7 +3,15 @@ import {
3
3
  } from "./chunk-7TQO4ZF4.js";
4
4
  import {
5
5
  getWorkbenchClient
6
- } from "./chunk-LZM5OKAC.js";
6
+ } from "./chunk-UDSRAHKP.js";
7
+ import {
8
+ CLONE_TIMEOUT_MS,
9
+ DEFAULT_RETRY_DELAY_MS,
10
+ FETCH_TIMEOUT_MS,
11
+ GIT_PREP_MAX_RETRIES,
12
+ mapChatHistory,
13
+ readAgentVersion
14
+ } from "./chunk-UZTJJD7Y.js";
7
15
  import {
8
16
  workbenchEnabled
9
17
  } from "./chunk-4VUQ2NPF.js";
@@ -23,7 +31,7 @@ import {
23
31
  sleep,
24
32
  transcriptSize,
25
33
  turnOptionsFrom
26
- } from "./chunk-RSIW2UCR.js";
34
+ } from "./chunk-JG54UJ6V.js";
27
35
 
28
36
  // src/setup/bootstrap.ts
29
37
  var BOOTSTRAP_TIMEOUT_MS = 3e4;
@@ -271,8 +279,8 @@ var AgentConnection = class _AgentConnection {
271
279
  /** (Re)arm the recycle timer — called on every successful (re)connect. */
272
280
  scheduleSocketRecycle() {
273
281
  this.clearSocketRecycle();
274
- const delay = _AgentConnection.SOCKET_RECYCLE_BASE_MS + Math.random() * _AgentConnection.SOCKET_RECYCLE_JITTER_MS;
275
- this.armRecycleTimer(delay);
282
+ const delay2 = _AgentConnection.SOCKET_RECYCLE_BASE_MS + Math.random() * _AgentConnection.SOCKET_RECYCLE_JITTER_MS;
283
+ this.armRecycleTimer(delay2);
276
284
  }
277
285
  clearSocketRecycle() {
278
286
  if (this.recycleTimer) {
@@ -280,11 +288,11 @@ var AgentConnection = class _AgentConnection {
280
288
  this.recycleTimer = null;
281
289
  }
282
290
  }
283
- armRecycleTimer(delay) {
291
+ armRecycleTimer(delay2) {
284
292
  this.recycleTimer = setTimeout(() => {
285
293
  this.recycleTimer = null;
286
294
  this.attemptSocketRecycle();
287
- }, delay);
295
+ }, delay2);
288
296
  this.recycleTimer.unref?.();
289
297
  }
290
298
  attemptSocketRecycle() {
@@ -965,15 +973,6 @@ var AgentConnection = class _AgentConnection {
965
973
  updateStatus(status) {
966
974
  this.emitStatus(status);
967
975
  }
968
- emitCodeReviewResult(content, approved) {
969
- if (!this.socket) return;
970
- void this.call("submitCodeReviewResult", {
971
- sessionId: this.config.sessionId,
972
- content,
973
- approved
974
- }).catch(() => {
975
- });
976
- }
977
976
  /**
978
977
  * The session's key hit a hard usage cap — ask the server to stamp it
979
978
  * limited and hand back the best remaining key's credential env (or a
@@ -2049,9 +2048,10 @@ var SubmitCodeReviewResultRequestSchema = z3.object({
2049
2048
  sessionId: z3.string(),
2050
2049
  approved: z3.boolean(),
2051
2050
  content: z3.string(),
2052
- // Canonical risk derived by the reviewer (approve low; changes max issue
2053
- // severity). Applied raise-only server-side; never lowers an explicit value.
2054
- risk: riskLevelSchema.optional(),
2051
+ // Canonical risk level the reviewer assigned to this change. Required on every
2052
+ // verdict — the reviewer must judge it. Applied authoritatively server-side
2053
+ // (may raise OR lower an already-set value; the reviewer has that authority).
2054
+ risk: riskLevelSchema,
2055
2055
  // The commit SHA the reviewer actually reviewed. When present, the verdict is
2056
2056
  // rejected unless the task is still at this SHA (guards against a late
2057
2057
  // old-SHA verdict overwriting a newer review cycle).
@@ -2432,6 +2432,7 @@ var ListMyLiveSessionsRequestSchema = z4.object({
2432
2432
  var ListProjectSessionGroupsRequestSchema = z4.object({
2433
2433
  projectId: z4.string()
2434
2434
  });
2435
+ var ListMyLiveSessionsAcrossProjectsRequestSchema = z4.object({});
2435
2436
  var GetProjectAvailableTuisRequestSchema = z4.object({
2436
2437
  projectId: z4.string()
2437
2438
  });
@@ -3012,10 +3013,10 @@ var Lifecycle = class {
3012
3013
  * deadline regardless of message volume. */
3013
3014
  startDormantTimer(overrideMs) {
3014
3015
  this.cancelDormantTimer();
3015
- const delay = Math.max(0, overrideMs ?? this.config.dormantTimeoutMs);
3016
+ const delay2 = Math.max(0, overrideMs ?? this.config.dormantTimeoutMs);
3016
3017
  this.dormantTimer = setTimeout(() => {
3017
3018
  this.callbacks.onDormantTimeout();
3018
- }, delay);
3019
+ }, delay2);
3019
3020
  }
3020
3021
  cancelDormantTimer() {
3021
3022
  if (this.dormantTimer) {
@@ -6529,6 +6530,14 @@ function buildReviewPrompt(context) {
6529
6530
  `- Explain what's wrong and suggest fixes`,
6530
6531
  `- Focus on substantive issues, not style nitpicks (linting handles that)`,
6531
6532
  ``,
6533
+ `#### Risk level (required on BOTH tools):`,
6534
+ `Every verdict MUST include a \`risk\` level \u2014 judge it by the surface area the change touches:`,
6535
+ `- \`critical\`: touches critical/foundational surface (auth, billing, data integrity, migrations)`,
6536
+ `- \`high\`: touches important surface with broad blast radius`,
6537
+ `- \`medium\`: moderate, contained surface area`,
6538
+ `- \`low\`: small or isolated change`,
6539
+ `The task may already have a risk level set. If your review makes you disagree with it, set the level you believe is correct \u2014 you have the authority to override it in either direction.`,
6540
+ ``,
6532
6541
  `### Previous Review Feedback`,
6533
6542
  `If previous review feedback is present in the chat history, verify those specific issues were addressed before raising new concerns.`,
6534
6543
  ``,
@@ -8279,20 +8288,18 @@ async function endReviewSession(connection, reason) {
8279
8288
  reason
8280
8289
  });
8281
8290
  }
8282
- function riskFromIssues(issues) {
8283
- if (issues.some((i) => i.severity === "critical")) return "critical";
8284
- if (issues.some((i) => i.severity === "major")) return "high";
8285
- return "medium";
8286
- }
8291
+ var RISK_LEVELS2 = ["critical", "high", "medium", "low"];
8292
+ var riskDescription = "REQUIRED. The risk level this change carries, judged by the surface area it touches: critical = touches critical/foundational surface, high = important surface, medium = moderate, low = small/isolated. Set this on every verdict. You have authority to override a risk level already set on the task if you disagree with it.";
8287
8293
  function buildCodeReviewTools(connection) {
8288
8294
  return [
8289
8295
  defineTool(
8290
8296
  "approve_code_review",
8291
- "Approve the code review and exit. Use when the diff passes all review criteria. Takes only a summary \u2014 for changes, use request_code_changes with a structured issues[] list.",
8297
+ "Approve the code review and exit. Use when the diff passes all review criteria. Requires a summary and a risk level \u2014 for changes, use request_code_changes with a structured issues[] list.",
8292
8298
  {
8293
- summary: z14.string().describe("Brief summary of what was reviewed and why it looks good")
8299
+ summary: z14.string().describe("Brief summary of what was reviewed and why it looks good"),
8300
+ risk: z14.enum(RISK_LEVELS2).describe(riskDescription)
8294
8301
  },
8295
- async ({ summary }) => {
8302
+ async ({ summary, risk }) => {
8296
8303
  const content = `**Code Review: Approved** :white_check_mark:
8297
8304
 
8298
8305
  ${summary}`;
@@ -8300,7 +8307,7 @@ ${summary}`;
8300
8307
  sessionId: connection.sessionId,
8301
8308
  approved: true,
8302
8309
  content,
8303
- risk: "low"
8310
+ risk
8304
8311
  });
8305
8312
  connection.sendEvent({
8306
8313
  type: "code_review_complete",
@@ -8323,9 +8330,10 @@ ${summary}`;
8323
8330
  description: z14.string().describe("What is wrong and how to fix it")
8324
8331
  })
8325
8332
  ).describe("List of issues found during review"),
8326
- summary: z14.string().describe("Brief overall summary of the review findings")
8333
+ summary: z14.string().describe("Brief overall summary of the review findings"),
8334
+ risk: z14.enum(RISK_LEVELS2).describe(riskDescription)
8327
8335
  },
8328
- async ({ issues, summary }) => {
8336
+ async ({ issues, summary, risk }) => {
8329
8337
  const issueLines = issues.map((issue) => {
8330
8338
  const loc = issue.line ? `:${issue.line}` : "";
8331
8339
  return `- **[${issue.severity}]** \`${issue.file}${loc}\`: ${issue.description}`;
@@ -8339,7 +8347,7 @@ ${issueLines}`;
8339
8347
  sessionId: connection.sessionId,
8340
8348
  approved: false,
8341
8349
  content,
8342
- risk: riskFromIssues(issues)
8350
+ risk
8343
8351
  });
8344
8352
  connection.sendEvent({
8345
8353
  type: "code_review_complete",
@@ -10158,47 +10166,6 @@ var QueryBridge = class {
10158
10166
  }
10159
10167
  };
10160
10168
 
10161
- // src/runner/session-runner-helpers.ts
10162
- import { readFileSync as readFileSync2 } from "fs";
10163
- import { dirname as dirname2, join as join8 } from "path";
10164
- import { fileURLToPath as fileURLToPath2 } from "url";
10165
- function mapChatHistory(messages) {
10166
- if (!messages) return [];
10167
- return messages.map((m) => ({
10168
- id: m.id,
10169
- role: m.role ?? "user",
10170
- content: m.content ?? "",
10171
- userId: m.userId,
10172
- userName: m.user?.name ?? void 0,
10173
- createdAt: m.createdAt,
10174
- ...m.files && m.files.length > 0 ? {
10175
- files: m.files.map((f) => ({
10176
- fileId: f.id,
10177
- fileName: f.fileName,
10178
- mimeType: f.mimeType,
10179
- fileSize: f.fileSize,
10180
- downloadUrl: f.downloadUrl ?? "",
10181
- content: f.content,
10182
- contentEncoding: f.contentEncoding
10183
- }))
10184
- } : {}
10185
- }));
10186
- }
10187
- function readAgentVersion() {
10188
- try {
10189
- const here = dirname2(fileURLToPath2(import.meta.url));
10190
- for (const rel of ["../package.json", "../../package.json"]) {
10191
- try {
10192
- const pkg = JSON.parse(readFileSync2(join8(here, rel), "utf-8"));
10193
- if (pkg.version) return pkg.version;
10194
- } catch {
10195
- }
10196
- }
10197
- } catch {
10198
- }
10199
- return null;
10200
- }
10201
-
10202
10169
  // src/execution/usage-sampler.ts
10203
10170
  import { existsSync as existsSync3 } from "fs";
10204
10171
 
@@ -10488,72 +10455,62 @@ async function sampleKeyUsage(token, probe = () => runUsageProbe(), hasSubscript
10488
10455
  }
10489
10456
 
10490
10457
  // src/setup/git-ready.ts
10491
- import { access, stat as stat2 } from "fs/promises";
10492
- var DEFAULT_FAILED_PATH = "/workspaces/.conveyor-git-failed";
10493
- var DEFAULT_TIMEOUT_MS = 6e5;
10458
+ var GATE_MARGIN_MS = 5 * 6e4;
10459
+ var DEFAULT_TIMEOUT_MS = GIT_PREP_MAX_RETRIES * (CLONE_TIMEOUT_MS + FETCH_TIMEOUT_MS) + (GIT_PREP_MAX_RETRIES - 1) * DEFAULT_RETRY_DELAY_MS + GATE_MARGIN_MS;
10494
10460
  var DEFAULT_POLL_MS = 200;
10495
- async function fileExists(path2) {
10496
- try {
10497
- await access(path2);
10498
- const s = await stat2(path2);
10499
- return s.isFile();
10500
- } catch {
10501
- return false;
10502
- }
10503
- }
10504
10461
  function awaitGitReady(opts = {}) {
10505
- if (opts.signal?.aborted) return Promise.reject(abortError());
10506
- const markerPath = opts.markerPath ?? process.env.CONVEYOR_GIT_READY_MARKER;
10507
- if (!markerPath) {
10462
+ if (!workbenchEnabled()) {
10508
10463
  return Promise.resolve("not-gated");
10509
10464
  }
10510
- const failedPath = opts.failedPath ?? process.env.CONVEYOR_GIT_FAILED_MARKER ?? DEFAULT_FAILED_PATH;
10465
+ const clientFn = opts.clientFn ?? getWorkbenchClient;
10511
10466
  const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
10512
10467
  const pollMs = opts.pollMs ?? DEFAULT_POLL_MS;
10513
- opts.onLog?.(`waiting for workspace git (marker=${markerPath})`);
10514
- return pollForMarkers(markerPath, failedPath, timeoutMs, pollMs, opts.onLog, opts.signal);
10515
- }
10516
- function abortError() {
10517
- const error = new Error("Operation aborted");
10518
- error.name = "AbortError";
10519
- return error;
10468
+ opts.onLog?.("waiting for workspace git (workbench daemon)");
10469
+ return pollDaemon(clientFn, timeoutMs, pollMs, opts.onLog, opts.signal);
10520
10470
  }
10521
- function abortableDelay(ms, signal) {
10471
+ function delay(ms, signal) {
10522
10472
  if (!signal) {
10523
10473
  return new Promise((resolve) => {
10524
10474
  setTimeout(resolve, ms);
10525
10475
  });
10526
10476
  }
10527
- if (signal.aborted) return Promise.reject(abortError());
10528
- return new Promise((resolve, reject) => {
10477
+ if (signal.aborted) return Promise.resolve();
10478
+ return new Promise((resolve) => {
10529
10479
  const timer = setTimeout(() => {
10530
10480
  signal.removeEventListener("abort", onAbort);
10531
10481
  resolve();
10532
10482
  }, ms);
10533
10483
  const onAbort = () => {
10534
10484
  clearTimeout(timer);
10535
- reject(abortError());
10485
+ resolve();
10536
10486
  };
10537
10487
  signal.addEventListener("abort", onAbort, { once: true });
10538
10488
  });
10539
10489
  }
10540
- async function pollForMarkers(markerPath, failedPath, timeoutMs, pollMs, onLog, signal) {
10490
+ async function pollDaemon(clientFn, timeoutMs, pollMs, onLog, signal) {
10541
10491
  const deadline = Date.now() + timeoutMs;
10542
10492
  for (; ; ) {
10543
- if (signal?.aborted) throw abortError();
10544
- if (await fileExists(markerPath)) {
10545
- onLog?.("workspace git ready");
10546
- return "ready";
10493
+ if (signal?.aborted) {
10494
+ onLog?.("workspace git wait aborted \u2014 giving up");
10495
+ return "timeout";
10547
10496
  }
10548
- if (await fileExists(failedPath)) {
10549
- onLog?.("workspace git preparation failed (marker present)");
10550
- return "failed";
10497
+ try {
10498
+ const frame = await clientFn().gitStatus();
10499
+ if (frame.state === "ready") {
10500
+ onLog?.("workspace git ready");
10501
+ return "ready";
10502
+ }
10503
+ if (frame.state === "failed") {
10504
+ onLog?.(`workspace git preparation failed: ${frame.reason ?? "unknown reason"}`);
10505
+ return "failed";
10506
+ }
10507
+ } catch {
10551
10508
  }
10552
10509
  if (Date.now() >= deadline) {
10553
10510
  onLog?.(`workspace git not ready after ${timeoutMs}ms \u2014 giving up`);
10554
10511
  return "timeout";
10555
10512
  }
10556
- await abortableDelay(pollMs, signal);
10513
+ await delay(pollMs, signal);
10557
10514
  }
10558
10515
  }
10559
10516
 
@@ -10838,7 +10795,7 @@ async function handlePullBranch(workDir, branch) {
10838
10795
  }
10839
10796
 
10840
10797
  // src/runner/heavy-gate.ts
10841
- import { readFileSync as readFileSync3 } from "fs";
10798
+ import { readFileSync as readFileSync2 } from "fs";
10842
10799
  import path from "path";
10843
10800
  var GATE_KEYS = ["heavy", "test", "typecheck", "build"];
10844
10801
  function runDir() {
@@ -10855,7 +10812,7 @@ function pidAlive(pid) {
10855
10812
  function isHeavyGateActive() {
10856
10813
  for (const key of GATE_KEYS) {
10857
10814
  try {
10858
- const raw = readFileSync3(path.join(runDir(), `${key}.pid`), "utf8").trim();
10815
+ const raw = readFileSync2(path.join(runDir(), `${key}.pid`), "utf8").trim();
10859
10816
  const pid = Number.parseInt(raw, 10);
10860
10817
  if (Number.isInteger(pid) && pid > 0 && pidAlive(pid)) return true;
10861
10818
  } catch {
@@ -11754,12 +11711,12 @@ var SessionRunner = class _SessionRunner {
11754
11711
  };
11755
11712
 
11756
11713
  // src/setup/config.ts
11757
- import { join as join9 } from "path";
11714
+ import { join as join8 } from "path";
11758
11715
  var DEVCONTAINER_PATH = ".devcontainer/conveyor/devcontainer.json";
11759
11716
  var DEVCONTAINER_PORT_DENY_LIST = /* @__PURE__ */ new Set([5432, 6379, 9200]);
11760
11717
  async function loadForwardPorts(workspaceDir) {
11761
11718
  try {
11762
- const raw = await readWorkspaceFile(join9(workspaceDir, DEVCONTAINER_PATH));
11719
+ const raw = await readWorkspaceFile(join8(workspaceDir, DEVCONTAINER_PATH));
11763
11720
  const parsed = JSON.parse(raw);
11764
11721
  const ports = (parsed.forwardPorts ?? []).filter(
11765
11722
  (p) => typeof p === "number" && !DEVCONTAINER_PORT_DENY_LIST.has(p)
@@ -11853,4 +11810,4 @@ export {
11853
11810
  loadConveyorConfig,
11854
11811
  unshallowRepo
11855
11812
  };
11856
- //# sourceMappingURL=chunk-J4UH5TOO.js.map
11813
+ //# sourceMappingURL=chunk-OW2TIDWZ.js.map