@rallycry/conveyor-agent 6.4.2 → 7.0.1
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-XHJ2Z4AD.js → chunk-HAU4E7IA.js} +3327 -4490
- package/dist/chunk-HAU4E7IA.js.map +1 -0
- package/dist/cli.js +53 -30
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +432 -393
- package/dist/index.js +290 -13
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/dist/chunk-XHJ2Z4AD.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1,91 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
AgentConnection,
|
|
3
|
+
CommitWatcher,
|
|
4
|
+
DEFAULT_LIFECYCLE_CONFIG,
|
|
5
|
+
Lifecycle,
|
|
6
|
+
ModeController,
|
|
7
|
+
PlanSync,
|
|
5
8
|
ProjectConnection,
|
|
6
9
|
ProjectRunner,
|
|
10
|
+
SessionRunner,
|
|
11
|
+
detachWorktreeBranch,
|
|
7
12
|
ensureWorktree,
|
|
13
|
+
getCurrentBranch,
|
|
14
|
+
hasUncommittedChanges,
|
|
15
|
+
hasUnpushedCommits,
|
|
8
16
|
injectTelemetry,
|
|
9
|
-
|
|
17
|
+
pushToOrigin,
|
|
10
18
|
removeWorktree,
|
|
19
|
+
runAuthTokenCommand,
|
|
11
20
|
runSetupCommand,
|
|
12
|
-
runStartCommand
|
|
13
|
-
|
|
21
|
+
runStartCommand,
|
|
22
|
+
stageAndCommit,
|
|
23
|
+
updateRemoteToken
|
|
24
|
+
} from "./chunk-HAU4E7IA.js";
|
|
25
|
+
|
|
26
|
+
// src/runner/file-cache.ts
|
|
27
|
+
var DEFAULT_MAX_SIZE_BYTES = 50 * 1024 * 1024;
|
|
28
|
+
var DEFAULT_TTL_MS = 60 * 60 * 1e3;
|
|
29
|
+
var FileCache = class {
|
|
30
|
+
cache = /* @__PURE__ */ new Map();
|
|
31
|
+
currentSize = 0;
|
|
32
|
+
maxSizeBytes;
|
|
33
|
+
ttlMs;
|
|
34
|
+
constructor(maxSizeBytes = DEFAULT_MAX_SIZE_BYTES, ttlMs = DEFAULT_TTL_MS) {
|
|
35
|
+
this.maxSizeBytes = maxSizeBytes;
|
|
36
|
+
this.ttlMs = ttlMs;
|
|
37
|
+
}
|
|
38
|
+
get(fileId) {
|
|
39
|
+
const entry = this.cache.get(fileId);
|
|
40
|
+
if (!entry) return null;
|
|
41
|
+
if (Date.now() - entry.createdAt > this.ttlMs) {
|
|
42
|
+
this.delete(fileId);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
this.cache.delete(fileId);
|
|
46
|
+
this.cache.set(fileId, entry);
|
|
47
|
+
return entry;
|
|
48
|
+
}
|
|
49
|
+
set(fileId, content, mimeType, fileName) {
|
|
50
|
+
if (this.cache.has(fileId)) {
|
|
51
|
+
this.delete(fileId);
|
|
52
|
+
}
|
|
53
|
+
const size = content.byteLength;
|
|
54
|
+
if (size > this.maxSizeBytes) return;
|
|
55
|
+
while (this.currentSize + size > this.maxSizeBytes && this.cache.size > 0) {
|
|
56
|
+
const oldestKey = this.cache.keys().next().value;
|
|
57
|
+
if (oldestKey !== void 0) {
|
|
58
|
+
this.delete(oldestKey);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
this.cache.set(fileId, {
|
|
62
|
+
content,
|
|
63
|
+
mimeType,
|
|
64
|
+
fileName,
|
|
65
|
+
createdAt: Date.now(),
|
|
66
|
+
size
|
|
67
|
+
});
|
|
68
|
+
this.currentSize += size;
|
|
69
|
+
}
|
|
70
|
+
delete(fileId) {
|
|
71
|
+
const entry = this.cache.get(fileId);
|
|
72
|
+
if (entry) {
|
|
73
|
+
this.currentSize -= entry.size;
|
|
74
|
+
this.cache.delete(fileId);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
clear() {
|
|
78
|
+
this.cache.clear();
|
|
79
|
+
this.currentSize = 0;
|
|
80
|
+
}
|
|
81
|
+
get stats() {
|
|
82
|
+
return {
|
|
83
|
+
entries: this.cache.size,
|
|
84
|
+
sizeBytes: this.currentSize,
|
|
85
|
+
maxSizeBytes: this.maxSizeBytes
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
};
|
|
14
89
|
|
|
15
90
|
// src/debug/cdp-client.ts
|
|
16
91
|
var MAX_VARIABLE_VALUE_BYTES = 2048;
|
|
@@ -1155,7 +1230,10 @@ var DebugLifecycleManager = class {
|
|
|
1155
1230
|
requestReproduce(hypothesis) {
|
|
1156
1231
|
this.reproduceRequested = true;
|
|
1157
1232
|
if (hypothesis) this.hypothesis = hypothesis;
|
|
1158
|
-
this.connection.
|
|
1233
|
+
this.connection.sendEvent({
|
|
1234
|
+
type: "debug_reproduce_requested",
|
|
1235
|
+
hypothesis: hypothesis ?? this.hypothesis
|
|
1236
|
+
});
|
|
1159
1237
|
this.broadcastState();
|
|
1160
1238
|
}
|
|
1161
1239
|
/** Add a telemetry event to the debug session */
|
|
@@ -1185,7 +1263,7 @@ var DebugLifecycleManager = class {
|
|
|
1185
1263
|
startedAt,
|
|
1186
1264
|
endedAt
|
|
1187
1265
|
};
|
|
1188
|
-
this.connection.
|
|
1266
|
+
this.connection.sendEvent({ type: "debug_session_complete", summary });
|
|
1189
1267
|
this._isActive = false;
|
|
1190
1268
|
this.hypothesis = void 0;
|
|
1191
1269
|
this.sessionStartedAt = void 0;
|
|
@@ -1263,22 +1341,221 @@ var DebugLifecycleManager = class {
|
|
|
1263
1341
|
};
|
|
1264
1342
|
}
|
|
1265
1343
|
broadcastState() {
|
|
1266
|
-
this.connection.
|
|
1344
|
+
this.connection.sendEvent({
|
|
1345
|
+
type: "debug_state_changed",
|
|
1346
|
+
state: this.buildState()
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1351
|
+
// src/debug/hypothesis-tracker.ts
|
|
1352
|
+
var MAX_ITERATIONS = 3;
|
|
1353
|
+
var HypothesisTracker = class {
|
|
1354
|
+
hypothesis = null;
|
|
1355
|
+
iteration = 0;
|
|
1356
|
+
observations = [];
|
|
1357
|
+
_active = false;
|
|
1358
|
+
conclusion = null;
|
|
1359
|
+
// ── Public API ─────────────────────────────────────────────────────────
|
|
1360
|
+
/**
|
|
1361
|
+
* Start or update the current debugging hypothesis.
|
|
1362
|
+
* Increments the iteration count if a hypothesis was already set.
|
|
1363
|
+
*/
|
|
1364
|
+
setHypothesis(text) {
|
|
1365
|
+
if (!this._active) {
|
|
1366
|
+
this._active = true;
|
|
1367
|
+
this.hypothesis = text;
|
|
1368
|
+
this.iteration = 1;
|
|
1369
|
+
this.observations = [];
|
|
1370
|
+
this.conclusion = null;
|
|
1371
|
+
return { accepted: true, message: `Hypothesis set (iteration 1/${MAX_ITERATIONS}): ${text}` };
|
|
1372
|
+
}
|
|
1373
|
+
if (this.iteration >= MAX_ITERATIONS) {
|
|
1374
|
+
return {
|
|
1375
|
+
accepted: false,
|
|
1376
|
+
message: `Max iterations (${MAX_ITERATIONS}) reached. You must make a decision based on what you've observed. Use concludeSession() to summarize findings and exit debug mode.`
|
|
1377
|
+
};
|
|
1378
|
+
}
|
|
1379
|
+
this.iteration++;
|
|
1380
|
+
this.hypothesis = text;
|
|
1381
|
+
return {
|
|
1382
|
+
accepted: true,
|
|
1383
|
+
message: `Hypothesis updated (iteration ${this.iteration}/${MAX_ITERATIONS}): ${text}`
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Record an observation from debug data (breakpoint hit, telemetry, etc.).
|
|
1388
|
+
*/
|
|
1389
|
+
recordObservation(description, confirmsHypothesis) {
|
|
1390
|
+
this.observations.push({
|
|
1391
|
+
description,
|
|
1392
|
+
confirmsHypothesis,
|
|
1393
|
+
iteration: this.iteration,
|
|
1394
|
+
timestamp: Date.now()
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* End the debug session with a conclusion.
|
|
1399
|
+
*/
|
|
1400
|
+
concludeSession(conclusion) {
|
|
1401
|
+
this.conclusion = conclusion;
|
|
1402
|
+
this._active = false;
|
|
1403
|
+
const summary = this.getSessionSummary();
|
|
1404
|
+
this.reset();
|
|
1405
|
+
return summary;
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Get formatted debug context for injection into the agent's system prompt.
|
|
1409
|
+
* Returns empty string if no active session.
|
|
1410
|
+
*/
|
|
1411
|
+
getDebugContext() {
|
|
1412
|
+
if (!this._active || !this.hypothesis) return "";
|
|
1413
|
+
const lines = [
|
|
1414
|
+
`Current debug session (iteration ${this.iteration}/${MAX_ITERATIONS}):`,
|
|
1415
|
+
`Hypothesis: "${this.hypothesis}"`
|
|
1416
|
+
];
|
|
1417
|
+
if (this.observations.length > 0) {
|
|
1418
|
+
const byIteration = /* @__PURE__ */ new Map();
|
|
1419
|
+
for (const obs of this.observations) {
|
|
1420
|
+
const group = byIteration.get(obs.iteration) ?? [];
|
|
1421
|
+
group.push(obs);
|
|
1422
|
+
byIteration.set(obs.iteration, group);
|
|
1423
|
+
}
|
|
1424
|
+
for (const [iter, iterObs] of byIteration) {
|
|
1425
|
+
for (const obs of iterObs) {
|
|
1426
|
+
const verdict = obs.confirmsHypothesis ? "SUPPORTS" : "CONTRADICTS";
|
|
1427
|
+
lines.push(`Iteration ${iter}: ${obs.description} \u2014 ${verdict} hypothesis`);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
if (this.iteration >= MAX_ITERATIONS) {
|
|
1432
|
+
lines.push(
|
|
1433
|
+
`\u26A0\uFE0F Final iteration reached. Analyze observations and make a decision \u2014 no more debug iterations available.`
|
|
1434
|
+
);
|
|
1435
|
+
}
|
|
1436
|
+
return lines.join("\n");
|
|
1437
|
+
}
|
|
1438
|
+
/**
|
|
1439
|
+
* Get the full state (for serialization/testing).
|
|
1440
|
+
*/
|
|
1441
|
+
getState() {
|
|
1442
|
+
return {
|
|
1443
|
+
hypothesis: this.hypothesis,
|
|
1444
|
+
iteration: this.iteration,
|
|
1445
|
+
observations: [...this.observations],
|
|
1446
|
+
active: this._active,
|
|
1447
|
+
conclusion: this.conclusion
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
1450
|
+
isActive() {
|
|
1451
|
+
return this._active;
|
|
1452
|
+
}
|
|
1453
|
+
getIteration() {
|
|
1454
|
+
return this.iteration;
|
|
1455
|
+
}
|
|
1456
|
+
getMaxIterations() {
|
|
1457
|
+
return MAX_ITERATIONS;
|
|
1458
|
+
}
|
|
1459
|
+
// ── Private ────────────────────────────────────────────────────────────
|
|
1460
|
+
getSessionSummary() {
|
|
1461
|
+
const parts = [`Debug session complete.`];
|
|
1462
|
+
if (this.hypothesis) {
|
|
1463
|
+
parts.push(`Final hypothesis: "${this.hypothesis}"`);
|
|
1464
|
+
}
|
|
1465
|
+
parts.push(`Total iterations: ${this.iteration}`);
|
|
1466
|
+
if (this.observations.length > 0) {
|
|
1467
|
+
parts.push("Observations:");
|
|
1468
|
+
for (const obs of this.observations) {
|
|
1469
|
+
const verdict = obs.confirmsHypothesis ? "\u2713" : "\u2717";
|
|
1470
|
+
parts.push(` ${verdict} [iter ${obs.iteration}] ${obs.description}`);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
const supporting = this.observations.filter((o) => o.confirmsHypothesis).length;
|
|
1474
|
+
const contradicting = this.observations.length - supporting;
|
|
1475
|
+
parts.push(`Evidence: ${supporting} supporting, ${contradicting} contradicting`);
|
|
1476
|
+
if (this.conclusion) {
|
|
1477
|
+
parts.push(`Conclusion: ${this.conclusion}`);
|
|
1478
|
+
}
|
|
1479
|
+
return parts.join("\n");
|
|
1480
|
+
}
|
|
1481
|
+
reset() {
|
|
1482
|
+
this.hypothesis = null;
|
|
1483
|
+
this.iteration = 0;
|
|
1484
|
+
this.observations = [];
|
|
1485
|
+
this._active = false;
|
|
1486
|
+
this.conclusion = null;
|
|
1267
1487
|
}
|
|
1268
1488
|
};
|
|
1489
|
+
|
|
1490
|
+
// src/setup/config.ts
|
|
1491
|
+
import { readFile } from "fs/promises";
|
|
1492
|
+
import { join } from "path";
|
|
1493
|
+
var DEVCONTAINER_PATH = ".devcontainer/conveyor/devcontainer.json";
|
|
1494
|
+
async function loadForwardPorts(workspaceDir) {
|
|
1495
|
+
try {
|
|
1496
|
+
const raw = await readFile(join(workspaceDir, DEVCONTAINER_PATH), "utf-8");
|
|
1497
|
+
const parsed = JSON.parse(raw);
|
|
1498
|
+
return parsed.forwardPorts ?? [];
|
|
1499
|
+
} catch {
|
|
1500
|
+
return [];
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
function loadConveyorConfig() {
|
|
1504
|
+
const envSetup = process.env.CONVEYOR_SETUP_COMMAND;
|
|
1505
|
+
const envStart = process.env.CONVEYOR_START_COMMAND;
|
|
1506
|
+
const envPort = process.env.CONVEYOR_PREVIEW_PORT;
|
|
1507
|
+
if (envSetup || envStart) {
|
|
1508
|
+
return {
|
|
1509
|
+
setupCommand: envSetup,
|
|
1510
|
+
startCommand: envStart,
|
|
1511
|
+
previewPort: envPort ? Number(envPort) : void 0
|
|
1512
|
+
};
|
|
1513
|
+
}
|
|
1514
|
+
return null;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
// src/setup/codespace.ts
|
|
1518
|
+
import { execSync as execSync2 } from "child_process";
|
|
1519
|
+
function unshallowRepo(workspaceDir) {
|
|
1520
|
+
try {
|
|
1521
|
+
execSync2("git fetch --unshallow", {
|
|
1522
|
+
cwd: workspaceDir,
|
|
1523
|
+
timeout: 6e4,
|
|
1524
|
+
stdio: "ignore"
|
|
1525
|
+
});
|
|
1526
|
+
} catch {
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1269
1529
|
export {
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1530
|
+
AgentConnection,
|
|
1531
|
+
CommitWatcher,
|
|
1532
|
+
DEFAULT_LIFECYCLE_CONFIG,
|
|
1273
1533
|
DebugLifecycleManager,
|
|
1274
1534
|
DebugManager,
|
|
1275
1535
|
FileCache,
|
|
1536
|
+
HypothesisTracker,
|
|
1537
|
+
Lifecycle,
|
|
1538
|
+
ModeController,
|
|
1539
|
+
PlanSync,
|
|
1276
1540
|
ProjectConnection,
|
|
1277
1541
|
ProjectRunner,
|
|
1542
|
+
SessionRunner,
|
|
1543
|
+
detachWorktreeBranch,
|
|
1544
|
+
detectRuntime,
|
|
1278
1545
|
ensureWorktree,
|
|
1546
|
+
getCurrentBranch,
|
|
1547
|
+
hasUncommittedChanges,
|
|
1548
|
+
hasUnpushedCommits,
|
|
1549
|
+
injectBunInspectFlag,
|
|
1279
1550
|
loadConveyorConfig,
|
|
1551
|
+
loadForwardPorts,
|
|
1552
|
+
pushToOrigin,
|
|
1280
1553
|
removeWorktree,
|
|
1554
|
+
runAuthTokenCommand,
|
|
1281
1555
|
runSetupCommand,
|
|
1282
|
-
runStartCommand
|
|
1556
|
+
runStartCommand,
|
|
1557
|
+
stageAndCommit,
|
|
1558
|
+
unshallowRepo,
|
|
1559
|
+
updateRemoteToken
|
|
1283
1560
|
};
|
|
1284
1561
|
//# sourceMappingURL=index.js.map
|