@joshski/dust 0.1.16 → 0.1.17
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/dust.js +33 -12
- package/package.json +1 -1
package/dist/dust.js
CHANGED
|
@@ -1445,9 +1445,10 @@ function appendOtherArgs(lines, others) {
|
|
|
1445
1445
|
|
|
1446
1446
|
// lib/claude/streamer.ts
|
|
1447
1447
|
var DIVIDER2 = "────────────────────────────────";
|
|
1448
|
-
async function streamEvents(events, sink) {
|
|
1448
|
+
async function streamEvents(events, sink, onRawEvent) {
|
|
1449
1449
|
let hadTextOutput = false;
|
|
1450
1450
|
for await (const raw of events) {
|
|
1451
|
+
onRawEvent?.(raw);
|
|
1451
1452
|
for (const event of parseRawEvent(raw)) {
|
|
1452
1453
|
processEvent(event, sink, { hadTextOutput });
|
|
1453
1454
|
if (event.type === "text_delta") {
|
|
@@ -1501,9 +1502,12 @@ var defaultRunnerDependencies = {
|
|
|
1501
1502
|
streamEvents
|
|
1502
1503
|
};
|
|
1503
1504
|
async function run(prompt, options = {}, dependencies = defaultRunnerDependencies) {
|
|
1504
|
-
const
|
|
1505
|
+
const isRunOptions = (opt) => ("spawnOptions" in opt) || ("onRawEvent" in opt);
|
|
1506
|
+
const spawnOptions = isRunOptions(options) ? options.spawnOptions ?? {} : options;
|
|
1507
|
+
const onRawEvent = isRunOptions(options) ? options.onRawEvent : undefined;
|
|
1508
|
+
const events = dependencies.spawnClaudeCode(prompt, spawnOptions);
|
|
1505
1509
|
const sink = dependencies.createStdoutSink();
|
|
1506
|
-
await dependencies.streamEvents(events, sink);
|
|
1510
|
+
await dependencies.streamEvents(events, sink, onRawEvent);
|
|
1507
1511
|
}
|
|
1508
1512
|
|
|
1509
1513
|
// lib/cli/commands/next.ts
|
|
@@ -1596,6 +1600,8 @@ function formatEvent(event) {
|
|
|
1596
1600
|
return "\uD83E\uDD16 Claude session started";
|
|
1597
1601
|
case "claude.ended":
|
|
1598
1602
|
return event.success ? "\uD83E\uDD16 Claude session ended (success)" : `\uD83E\uDD16 Claude session ended (error: ${event.error})`;
|
|
1603
|
+
case "claude.raw_event":
|
|
1604
|
+
return null;
|
|
1599
1605
|
case "loop.iteration_complete":
|
|
1600
1606
|
return `\uD83D\uDCCB Completed iteration ${event.iteration}/${event.maxIterations}`;
|
|
1601
1607
|
case "loop.ended":
|
|
@@ -1678,9 +1684,12 @@ async function hasAvailableTasks(dependencies) {
|
|
|
1678
1684
|
await next({ ...dependencies, context: captureContext });
|
|
1679
1685
|
return hasOutput;
|
|
1680
1686
|
}
|
|
1681
|
-
async function runOneIteration(dependencies, loopDependencies, emit) {
|
|
1687
|
+
async function runOneIteration(dependencies, loopDependencies, emit, options = {}) {
|
|
1682
1688
|
const { context } = dependencies;
|
|
1683
1689
|
const { spawn: spawn2, run: run2 } = loopDependencies;
|
|
1690
|
+
const onRawEvent = options.emitRawEvents ? (rawEvent) => {
|
|
1691
|
+
emit({ type: "claude.raw_event", rawEvent });
|
|
1692
|
+
} : undefined;
|
|
1684
1693
|
emit({ type: "loop.syncing" });
|
|
1685
1694
|
const pullResult = await gitPull(context.cwd, spawn2);
|
|
1686
1695
|
if (!pullResult.success) {
|
|
@@ -1701,9 +1710,12 @@ Please resolve this issue. Common approaches:
|
|
|
1701
1710
|
Make sure the repository is in a clean state and synced with remote before finishing.`;
|
|
1702
1711
|
try {
|
|
1703
1712
|
await run2(prompt, {
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1713
|
+
spawnOptions: {
|
|
1714
|
+
cwd: context.cwd,
|
|
1715
|
+
dangerouslySkipPermissions: true,
|
|
1716
|
+
env: { DUST_UNATTENDED: "1" }
|
|
1717
|
+
},
|
|
1718
|
+
onRawEvent
|
|
1707
1719
|
});
|
|
1708
1720
|
emit({ type: "claude.ended", success: true });
|
|
1709
1721
|
return "resolved_pull_conflict";
|
|
@@ -1723,9 +1735,12 @@ Make sure the repository is in a clean state and synced with remote before finis
|
|
|
1723
1735
|
emit({ type: "claude.started" });
|
|
1724
1736
|
try {
|
|
1725
1737
|
await run2("go", {
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1738
|
+
spawnOptions: {
|
|
1739
|
+
cwd: context.cwd,
|
|
1740
|
+
dangerouslySkipPermissions: true,
|
|
1741
|
+
env: { DUST_UNATTENDED: "1" }
|
|
1742
|
+
},
|
|
1743
|
+
onRawEvent
|
|
1729
1744
|
});
|
|
1730
1745
|
emit({ type: "claude.ended", success: true });
|
|
1731
1746
|
return "ran_claude";
|
|
@@ -1757,7 +1772,10 @@ async function loopClaude(dependencies, loopDependencies = createDefaultDependen
|
|
|
1757
1772
|
context.stderr(`Event POST failed: ${message}`);
|
|
1758
1773
|
});
|
|
1759
1774
|
const emit = (event) => {
|
|
1760
|
-
|
|
1775
|
+
const formatted = formatEvent(event);
|
|
1776
|
+
if (formatted !== null) {
|
|
1777
|
+
context.stdout(formatted);
|
|
1778
|
+
}
|
|
1761
1779
|
postTypedEvent(event);
|
|
1762
1780
|
};
|
|
1763
1781
|
emit({ type: "loop.warning" });
|
|
@@ -1765,8 +1783,11 @@ async function loopClaude(dependencies, loopDependencies = createDefaultDependen
|
|
|
1765
1783
|
context.stdout(" Press Ctrl+C to stop");
|
|
1766
1784
|
context.stdout("");
|
|
1767
1785
|
let completedIterations = 0;
|
|
1786
|
+
const iterationOptions = {
|
|
1787
|
+
emitRawEvents: settings.emitRawEvents
|
|
1788
|
+
};
|
|
1768
1789
|
while (completedIterations < maxIterations) {
|
|
1769
|
-
const result = await runOneIteration(dependencies, loopDependencies, emit);
|
|
1790
|
+
const result = await runOneIteration(dependencies, loopDependencies, emit, iterationOptions);
|
|
1770
1791
|
if (result === "no_tasks") {
|
|
1771
1792
|
await loopDependencies.sleep(SLEEP_INTERVAL_MS);
|
|
1772
1793
|
} else {
|