@rcrsr/claude-code-runner 0.1.0 → 0.4.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/README.md +45 -17
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +58 -27
- package/dist/cli/args.js.map +1 -1
- package/dist/core/runner.d.ts +2 -1
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +27 -54
- package/dist/core/runner.js.map +1 -1
- package/dist/deaddrop/client.d.ts +23 -0
- package/dist/deaddrop/client.d.ts.map +1 -0
- package/dist/deaddrop/client.js +47 -0
- package/dist/deaddrop/client.js.map +1 -0
- package/dist/deaddrop/index.d.ts +2 -0
- package/dist/deaddrop/index.d.ts.map +1 -0
- package/dist/deaddrop/index.js +2 -0
- package/dist/deaddrop/index.js.map +1 -0
- package/dist/index.js +52 -47
- package/dist/index.js.map +1 -1
- package/dist/output/colors.d.ts +42 -0
- package/dist/output/colors.d.ts.map +1 -1
- package/dist/output/colors.js +106 -4
- package/dist/output/colors.js.map +1 -1
- package/dist/output/formatter.d.ts +1 -0
- package/dist/output/formatter.d.ts.map +1 -1
- package/dist/output/formatter.js +21 -37
- package/dist/output/formatter.js.map +1 -1
- package/dist/output/logger.d.ts.map +1 -1
- package/dist/output/logger.js +3 -2
- package/dist/output/logger.js.map +1 -1
- package/dist/parsers/signals.d.ts.map +1 -1
- package/dist/parsers/signals.js +2 -5
- package/dist/parsers/signals.js.map +1 -1
- package/dist/process/pty.d.ts +1 -0
- package/dist/process/pty.d.ts.map +1 -1
- package/dist/process/pty.js +7 -3
- package/dist/process/pty.js.map +1 -1
- package/dist/templates/command.d.ts +35 -4
- package/dist/templates/command.d.ts.map +1 -1
- package/dist/templates/command.js +95 -20
- package/dist/templates/command.js.map +1 -1
- package/dist/types/runner.d.ts +5 -3
- package/dist/types/runner.d.ts.map +1 -1
- package/dist/types/runner.js +3 -2
- package/dist/types/runner.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,7 +58,26 @@ Review the code in $1 for:
|
|
|
58
58
|
Output findings as a numbered list.
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
**Template variables:**
|
|
62
|
+
|
|
63
|
+
- `$1`, `$2`, `$3`... — Positional arguments
|
|
64
|
+
- `$ARGUMENTS` — All arguments joined with spaces
|
|
65
|
+
|
|
66
|
+
**Frontmatter support:**
|
|
67
|
+
|
|
68
|
+
```markdown
|
|
69
|
+
---
|
|
70
|
+
description: Review code for issues
|
|
71
|
+
argument-hint: <file> [severity]
|
|
72
|
+
model: claude-sonnet-4-20250514
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
Review $1 with severity level $2...
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- `argument-hint` — Defines required `<arg>` and optional `[arg]` arguments
|
|
79
|
+
- `model` — Default model for this command (CLI `--model` takes precedence)
|
|
80
|
+
- `description` — Command description
|
|
62
81
|
|
|
63
82
|
### script — Run multiple commands in sequence
|
|
64
83
|
|
|
@@ -81,28 +100,38 @@ Scripts stop on `BLOCKED` or `ERROR` signals, letting you catch issues before co
|
|
|
81
100
|
|
|
82
101
|
### Options
|
|
83
102
|
|
|
84
|
-
| Option
|
|
85
|
-
|
|
|
86
|
-
| `--
|
|
87
|
-
| `--
|
|
88
|
-
| `--
|
|
89
|
-
| `--
|
|
103
|
+
| Option | Description |
|
|
104
|
+
| ----------------- | ------------------------------------------------------ |
|
|
105
|
+
| `--version`, `-V` | Print version number |
|
|
106
|
+
| `--model`, `-m` | Specify Claude model (e.g., `sonnet`, `opus`, `haiku`) |
|
|
107
|
+
| `--quiet` | Minimal output (errors only) |
|
|
108
|
+
| `--normal` | Default output level |
|
|
109
|
+
| `--verbose` | Full output with details |
|
|
110
|
+
| `--no-log` | Disable file logging |
|
|
111
|
+
| `--deaddrop` | Enable [DeadDrop](https://deaddrop.sh) streaming |
|
|
112
|
+
|
|
113
|
+
**Example with model selection:**
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
claude-code-runner -m sonnet "Explain this codebase"
|
|
117
|
+
```
|
|
90
118
|
|
|
91
119
|
## Runner Signals
|
|
92
120
|
|
|
93
121
|
Signals give Claude a way to control execution flow. Instruct Claude to output these signals in your prompts or templates, and the runner will respond accordingly.
|
|
94
122
|
|
|
95
|
-
| Signal
|
|
96
|
-
|
|
|
97
|
-
| `:::RUNNER::
|
|
98
|
-
| `:::RUNNER::
|
|
99
|
-
| `:::RUNNER::
|
|
100
|
-
|
|
123
|
+
| Signal | Effect |
|
|
124
|
+
| --------------------------- | -------------------------------- |
|
|
125
|
+
| `:::RUNNER::REPEAT_STEP:::` | Run the same step again |
|
|
126
|
+
| `:::RUNNER::BLOCKED:::` | Exit with error (awaiting human) |
|
|
127
|
+
| `:::RUNNER::ERROR:::` | Exit with error |
|
|
128
|
+
|
|
129
|
+
No signal means success—the runner exits when Claude finishes without outputting a signal.
|
|
101
130
|
|
|
102
131
|
**Example prompt using signals:**
|
|
103
132
|
|
|
104
133
|
```bash
|
|
105
|
-
claude-code-runner "Fix all lint errors in src/. Output :::RUNNER::
|
|
134
|
+
claude-code-runner "Fix all lint errors in src/. Output :::RUNNER::BLOCKED::: if you need human input."
|
|
106
135
|
```
|
|
107
136
|
|
|
108
137
|
**Example template with signals** (`.claude/commands/fix-tests.md`):
|
|
@@ -110,12 +139,11 @@ claude-code-runner "Fix all lint errors in src/. Output :::RUNNER::DONE::: when
|
|
|
110
139
|
```markdown
|
|
111
140
|
Run the test suite for $1.
|
|
112
141
|
|
|
113
|
-
- If
|
|
114
|
-
- If tests fail and you can fix them, fix them and output :::RUNNER::CONTINUE::: to re-run
|
|
142
|
+
- If tests fail and you can fix them, fix them and output :::RUNNER::REPEAT_STEP::: to re-run
|
|
115
143
|
- If tests fail and you need help, output :::RUNNER::BLOCKED::: with an explanation
|
|
116
144
|
```
|
|
117
145
|
|
|
118
|
-
This pattern enables self-correcting loops: Claude attempts a fix, signals `
|
|
146
|
+
This pattern enables self-correcting loops: Claude attempts a fix, signals `REPEAT_STEP` to retry, and exits when done or stuck.
|
|
119
147
|
|
|
120
148
|
**Defaults:**
|
|
121
149
|
|
package/dist/cli/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,OAAO,KAAK,EACV,UAAU,EAIX,MAAM,mBAAmB,CAAC;AAkD3B;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAmBjE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAsEpD;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CA2BjC"}
|
package/dist/cli/args.js
CHANGED
|
@@ -2,33 +2,52 @@
|
|
|
2
2
|
* CLI argument parsing
|
|
3
3
|
*/
|
|
4
4
|
import * as fs from 'fs';
|
|
5
|
+
import { createRequire } from 'module';
|
|
5
6
|
import { loadCommandTemplate } from '../templates/command.js';
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const pkg = require('../../package.json');
|
|
6
9
|
/**
|
|
7
10
|
* Extract options from raw args, returning positional args and config
|
|
8
11
|
*/
|
|
9
12
|
function extractOptions(args) {
|
|
13
|
+
// Handle --version early
|
|
14
|
+
if (args.includes('--version') || args.includes('-V')) {
|
|
15
|
+
console.log(pkg.version);
|
|
16
|
+
process.exit(0);
|
|
17
|
+
}
|
|
10
18
|
let verbosity = 'normal';
|
|
11
19
|
let enableLog = true;
|
|
20
|
+
let model = null;
|
|
21
|
+
let deaddrop = false;
|
|
12
22
|
const positionalArgs = [];
|
|
13
|
-
for (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
for (let i = 0; i < args.length; i++) {
|
|
24
|
+
const arg = args[i];
|
|
25
|
+
if (arg === '--quiet') {
|
|
26
|
+
verbosity = 'quiet';
|
|
27
|
+
}
|
|
28
|
+
else if (arg === '--normal') {
|
|
29
|
+
verbosity = 'normal';
|
|
30
|
+
}
|
|
31
|
+
else if (arg === '--verbose') {
|
|
32
|
+
verbosity = 'verbose';
|
|
33
|
+
}
|
|
34
|
+
else if (arg === '--no-log') {
|
|
35
|
+
enableLog = false;
|
|
36
|
+
}
|
|
37
|
+
else if (arg === '--deaddrop') {
|
|
38
|
+
deaddrop = true;
|
|
39
|
+
}
|
|
40
|
+
else if (arg === '--model' || arg === '-m') {
|
|
41
|
+
model = args[++i] ?? null;
|
|
42
|
+
}
|
|
43
|
+
else if (arg?.startsWith('--model=')) {
|
|
44
|
+
model = arg.slice(8);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
positionalArgs.push(arg ?? '');
|
|
29
48
|
}
|
|
30
49
|
}
|
|
31
|
-
return { positionalArgs, verbosity, enableLog };
|
|
50
|
+
return { positionalArgs, verbosity, enableLog, model, deaddrop };
|
|
32
51
|
}
|
|
33
52
|
/**
|
|
34
53
|
* Parse a command line into a prompt
|
|
@@ -45,7 +64,8 @@ export function parseCommandLine(line) {
|
|
|
45
64
|
if (!cmdName) {
|
|
46
65
|
throw new Error('command requires a name');
|
|
47
66
|
}
|
|
48
|
-
|
|
67
|
+
const { prompt } = loadCommandTemplate(cmdName, parts.slice(2));
|
|
68
|
+
return { prompt };
|
|
49
69
|
}
|
|
50
70
|
else if (cmd === 'script') {
|
|
51
71
|
throw new Error('script cannot be nested');
|
|
@@ -59,11 +79,13 @@ export function parseCommandLine(line) {
|
|
|
59
79
|
* Parse CLI arguments
|
|
60
80
|
*/
|
|
61
81
|
export function parseArgs(args) {
|
|
62
|
-
const { positionalArgs, verbosity, enableLog } = extractOptions(args);
|
|
82
|
+
const { positionalArgs, verbosity, enableLog, model, deaddrop } = extractOptions(args);
|
|
63
83
|
const subcommand = (positionalArgs[0] ?? 'prompt');
|
|
64
84
|
let prompt = '';
|
|
85
|
+
let displayCommand = '';
|
|
65
86
|
let scriptMode = false;
|
|
66
87
|
let scriptLines = [];
|
|
88
|
+
let frontmatterModel = null;
|
|
67
89
|
switch (subcommand) {
|
|
68
90
|
case 'command': {
|
|
69
91
|
const commandName = positionalArgs[1];
|
|
@@ -72,7 +94,10 @@ export function parseArgs(args) {
|
|
|
72
94
|
console.error('Usage: claude-code-runner command <name> [args...]');
|
|
73
95
|
process.exit(1);
|
|
74
96
|
}
|
|
75
|
-
|
|
97
|
+
const template = loadCommandTemplate(commandName, positionalArgs.slice(2));
|
|
98
|
+
prompt = template.prompt;
|
|
99
|
+
frontmatterModel = template.frontmatter.model ?? null;
|
|
100
|
+
displayCommand = positionalArgs.slice(1).join(' ');
|
|
76
101
|
break;
|
|
77
102
|
}
|
|
78
103
|
case 'script': {
|
|
@@ -92,20 +117,25 @@ export function parseArgs(args) {
|
|
|
92
117
|
.map((l) => l.trim())
|
|
93
118
|
.filter((l) => l && !l.startsWith('#')); // Skip empty lines and comments
|
|
94
119
|
scriptMode = true;
|
|
120
|
+
displayCommand = `script ${scriptFile}`;
|
|
95
121
|
break;
|
|
96
122
|
}
|
|
97
123
|
case 'prompt':
|
|
98
124
|
prompt =
|
|
99
125
|
positionalArgs.slice(1).join(' ') || 'Tell me about this project';
|
|
126
|
+
displayCommand = `"${prompt}"`;
|
|
100
127
|
break;
|
|
101
128
|
}
|
|
102
129
|
const config = {
|
|
103
130
|
verbosity,
|
|
104
131
|
enableLog,
|
|
132
|
+
model: model ?? frontmatterModel,
|
|
133
|
+
deaddrop,
|
|
105
134
|
};
|
|
106
135
|
return {
|
|
107
136
|
subcommand: scriptMode ? 'script' : subcommand,
|
|
108
137
|
prompt,
|
|
138
|
+
displayCommand,
|
|
109
139
|
scriptLines,
|
|
110
140
|
scriptMode,
|
|
111
141
|
config,
|
|
@@ -128,17 +158,18 @@ Subcommands:
|
|
|
128
158
|
command <name> [args] Load .claude/commands/<name>.md (supports RUNNER signals)
|
|
129
159
|
script <file> Run commands from file, stop on ERROR/BLOCKED
|
|
130
160
|
|
|
131
|
-
Iteration
|
|
132
|
-
:::RUNNER::
|
|
133
|
-
:::RUNNER::CONTINUE::: Continue to next iteration
|
|
161
|
+
Iteration Signals (control runner execution):
|
|
162
|
+
:::RUNNER::REPEAT_STEP::: Run the same step again
|
|
134
163
|
:::RUNNER::BLOCKED::: Exit with error (awaiting human intervention)
|
|
135
164
|
:::RUNNER::ERROR::: Exit with error (something went wrong)
|
|
136
165
|
|
|
137
166
|
Options:
|
|
138
|
-
--quiet
|
|
139
|
-
--normal
|
|
140
|
-
--verbose
|
|
141
|
-
--no-log
|
|
167
|
+
--quiet Minimal output (errors only)
|
|
168
|
+
--normal Default output level
|
|
169
|
+
--verbose Full output with all details
|
|
170
|
+
--no-log Disable logging to file (enabled by default)
|
|
171
|
+
--model, -m <model> Specify Claude model (e.g., sonnet, opus, haiku)
|
|
172
|
+
--deaddrop Send messages to Deaddrop (requires DEADDROP_API_KEY env var)
|
|
142
173
|
`);
|
|
143
174
|
}
|
|
144
175
|
//# sourceMappingURL=args.js.map
|
package/dist/cli/args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE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AK,IAAI,gBAAgB;QAChC,QAAQ;KACT,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU;QAC9C,MAAM;QACN,cAAc;QACd,WAAW;QACX,UAAU;QACV,MAAM;KACP,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAyBb,CAAC,CAAC;AACH,CAAC"}
|
package/dist/core/runner.d.ts
CHANGED
|
@@ -9,10 +9,11 @@ export interface RunnerContext {
|
|
|
9
9
|
logger: Logger;
|
|
10
10
|
formatterState: FormatterState;
|
|
11
11
|
cwd: string;
|
|
12
|
+
runId: string | null;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* Run a command with RUNNER signal support
|
|
15
16
|
* Handles iteration loop and signal detection
|
|
16
17
|
*/
|
|
17
|
-
export declare function runWithSignals(promptText: string, startTime: number, context: RunnerContext): Promise<SignalResult>;
|
|
18
|
+
export declare function runWithSignals(promptText: string, displayCommand: string, startTime: number, context: RunnerContext): Promise<SignalResult>;
|
|
18
19
|
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAErE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,cAAc,CAAC;IAC/B,GAAG,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAErE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,cAAc,CAAC;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAwFvB"}
|
package/dist/core/runner.js
CHANGED
|
@@ -1,103 +1,76 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Core runner with iteration control and signal detection
|
|
3
3
|
*/
|
|
4
|
-
import { colors, formatDuration } from '../output/colors.js';
|
|
4
|
+
import { colors, formatDuration, printRunner } from '../output/colors.js';
|
|
5
5
|
import { detectRunnerSignal } from '../parsers/signals.js';
|
|
6
6
|
import { spawnClaude } from '../process/pty.js';
|
|
7
7
|
/**
|
|
8
8
|
* Run a command with RUNNER signal support
|
|
9
9
|
* Handles iteration loop and signal detection
|
|
10
10
|
*/
|
|
11
|
-
export async function runWithSignals(promptText, startTime, context) {
|
|
12
|
-
const { config, logger, formatterState, cwd } = context;
|
|
13
|
-
const { verbosity, maxIterations, parallelThresholdMs, iterationPauseMs } = config;
|
|
11
|
+
export async function runWithSignals(promptText, displayCommand, startTime, context) {
|
|
12
|
+
const { config, logger, formatterState, cwd, runId } = context;
|
|
13
|
+
const { verbosity, maxIterations, parallelThresholdMs, iterationPauseMs, model, } = config;
|
|
14
14
|
let iteration = 0;
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- intentional infinite loop with internal exits
|
|
16
16
|
while (true) {
|
|
17
17
|
iteration++;
|
|
18
18
|
// Check max iterations
|
|
19
19
|
if (iteration > maxIterations) {
|
|
20
|
-
const totalDuration =
|
|
21
|
-
|
|
22
|
-
printSeparator();
|
|
23
|
-
console.log(`${colors.red}MAX ITERATIONS (${maxIterations})${colors.reset} | Total: ${formatDuration(totalDuration * 1000)}`);
|
|
24
|
-
printSeparator();
|
|
20
|
+
const totalDuration = Date.now() - startTime;
|
|
21
|
+
printRunner(`${colors.red}Run stopped${colors.reset} max iterations (${maxIterations}) in ${formatDuration(totalDuration)}`);
|
|
25
22
|
logger.log(`\nMAX ITERATIONS reached after ${maxIterations}`);
|
|
26
23
|
return 'error';
|
|
27
24
|
}
|
|
28
|
-
//
|
|
25
|
+
// Log iteration for subsequent iterations
|
|
29
26
|
if (iteration > 1) {
|
|
30
|
-
console.log('');
|
|
31
|
-
printIterationHeader(iteration);
|
|
32
27
|
logger.log(`\n--- Iteration ${iteration} ---\n`);
|
|
33
28
|
}
|
|
29
|
+
// Print running message
|
|
30
|
+
if (verbosity !== 'quiet') {
|
|
31
|
+
printRunner(`Running step ${iteration}: ${displayCommand}`);
|
|
32
|
+
}
|
|
33
|
+
// Update formatter with current step
|
|
34
|
+
formatterState.currentStep = iteration;
|
|
34
35
|
// Run Claude
|
|
35
|
-
const { exitCode,
|
|
36
|
+
const { exitCode, claudeText } = await spawnClaude({
|
|
36
37
|
prompt: promptText,
|
|
37
38
|
cwd,
|
|
38
39
|
verbosity,
|
|
39
40
|
logger,
|
|
40
41
|
formatterState,
|
|
41
42
|
parallelThresholdMs,
|
|
43
|
+
model,
|
|
42
44
|
});
|
|
43
45
|
const status = detectRunnerSignal(claudeText);
|
|
44
|
-
const totalDuration =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
logger.log(`\
|
|
51
|
-
return 'ok';
|
|
52
|
-
}
|
|
53
|
-
else if (status === 'blocked') {
|
|
54
|
-
console.log(`${colors.red}BLOCKED${colors.reset} | Iterations: ${iteration} | Total: ${formatDuration(totalDuration * 1000)}`);
|
|
55
|
-
printSeparator();
|
|
56
|
-
logger.log(`\nBLOCKED after ${iteration} iterations, ${totalDuration}s total`);
|
|
46
|
+
const totalDuration = Date.now() - startTime;
|
|
47
|
+
const totalSeconds = Math.round(totalDuration / 1000);
|
|
48
|
+
const runLabel = runId ? ` ${runId}` : '';
|
|
49
|
+
const stepLabel = ` (${iteration} step${iteration > 1 ? 's' : ''})`;
|
|
50
|
+
if (status === 'blocked') {
|
|
51
|
+
printRunner(`${colors.red}Blocked run${runLabel}${colors.reset}${stepLabel} in ${formatDuration(totalDuration)}`);
|
|
52
|
+
logger.log(`\nBLOCKED after ${iteration} iterations, ${totalSeconds}s total`);
|
|
57
53
|
return 'blocked';
|
|
58
54
|
}
|
|
59
55
|
else if (status === 'error') {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
logger.log(`\nERROR after ${iteration} iterations, ${totalDuration}s total`);
|
|
56
|
+
printRunner(`${colors.red}Failed run${runLabel}${colors.reset}${stepLabel} in ${formatDuration(totalDuration)}`);
|
|
57
|
+
logger.log(`\nERROR after ${iteration} iterations, ${totalSeconds}s total`);
|
|
63
58
|
return 'error';
|
|
64
59
|
}
|
|
65
|
-
else if (status === '
|
|
66
|
-
|
|
67
|
-
printSeparator();
|
|
60
|
+
else if (status === 'repeat_step') {
|
|
61
|
+
printRunner(`Claude requested to repeat the step`);
|
|
68
62
|
logger.log(`Iteration ${iteration} complete, continuing...`);
|
|
69
63
|
await sleep(iterationPauseMs);
|
|
70
64
|
}
|
|
71
65
|
else {
|
|
72
66
|
// No status signal - treat as successful single run
|
|
73
67
|
const exitStatus = exitCode === 0 ? 'ok' : 'error';
|
|
74
|
-
|
|
75
|
-
console.log(`Exit: ${exitCode === 0 ? colors.green : colors.red}${exitCode}${colors.reset} | Duration: ${duration}s`);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
console.log(`${exitCode === 0 ? colors.green + 'COMPLETE' : colors.red + 'FAILED'}${colors.reset} | Iterations: ${iteration} | Total: ${formatDuration(totalDuration * 1000)}`);
|
|
79
|
-
}
|
|
80
|
-
printSeparator();
|
|
68
|
+
printRunner(`${exitCode === 0 ? colors.green + 'Completed run' : colors.red + 'Failed run'}${runLabel}${colors.reset}${stepLabel} in ${formatDuration(totalDuration)}`);
|
|
81
69
|
logger.log(`\nCompleted after ${iteration} iteration(s), exit=${exitCode}`);
|
|
82
70
|
return exitStatus;
|
|
83
71
|
}
|
|
84
72
|
}
|
|
85
73
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Print a separator line
|
|
88
|
-
*/
|
|
89
|
-
function printSeparator() {
|
|
90
|
-
console.log(`${colors.bold}════════════════════════════════════════════════════════════${colors.reset}`);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Print iteration header
|
|
94
|
-
*/
|
|
95
|
-
function printIterationHeader(iteration) {
|
|
96
|
-
console.log(`${colors.blue}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${colors.reset}`);
|
|
97
|
-
console.log(`${colors.blue}Iteration ${iteration}${colors.reset}`);
|
|
98
|
-
console.log(`${colors.blue}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${colors.reset}`);
|
|
99
|
-
console.log('');
|
|
100
|
-
}
|
|
101
74
|
/**
|
|
102
75
|
* Sleep for a given number of milliseconds
|
|
103
76
|
*/
|
package/dist/core/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAA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AAE,CACpG,CAAC;YACF,MAAM,CAAC,GAAG,CACR,iBAAiB,SAAS,gBAAgB,YAAY,SAAS,CAChE,CAAC;YACF,OAAO,OAAO,CAAC;QACjB,CAAC;aAAM,IAAI,MAAM,KAAK,aAAa,EAAE,CAAC;YACpC,WAAW,CAAC,qCAAqC,CAAC,CAAC;YACnD,MAAM,CAAC,GAAG,CAAC,aAAa,SAAS,0BAA0B,CAAC,CAAC;YAC7D,MAAM,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,oDAAoD;YACpD,MAAM,UAAU,GAAiB,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;YACjE,WAAW,CACT,GAAG,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,CAAC,KAAK,GAAG,SAAS,OAAO,cAAc,CAAC,aAAa,CAAC,EAAE,CAC3J,CAAC;YACF,MAAM,CAAC,GAAG,CACR,qBAAqB,SAAS,uBAAuB,QAAQ,EAAE,CAChE,CAAC;YACF,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeadDrop client for sending messages to a Deaddrop endpoint
|
|
3
|
+
* https://deaddrop.sh
|
|
4
|
+
*/
|
|
5
|
+
export interface DeadDropConfig {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
host: string;
|
|
8
|
+
runId: string;
|
|
9
|
+
}
|
|
10
|
+
export type DeadDropUser = 'Runner' | 'Claude Code';
|
|
11
|
+
export interface DeadDropClient {
|
|
12
|
+
send(content: string, user: DeadDropUser): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create a DeadDrop client from environment variables
|
|
16
|
+
* Returns null if DEADDROP_API_KEY is not set
|
|
17
|
+
*/
|
|
18
|
+
export declare function createDeadDropClientFromEnv(runId: string): DeadDropClient | null;
|
|
19
|
+
/**
|
|
20
|
+
* Create a DeadDrop client with the given configuration
|
|
21
|
+
*/
|
|
22
|
+
export declare function createDeadDropClient(config: DeadDropConfig): DeadDropClient;
|
|
23
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/deaddrop/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,aAAa,CAAC;AAEpD,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AAID;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,GACZ,cAAc,GAAG,IAAI,CAQvB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CA4B3E"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeadDrop client for sending messages to a Deaddrop endpoint
|
|
3
|
+
* https://deaddrop.sh
|
|
4
|
+
*/
|
|
5
|
+
const DEFAULT_HOST = 'https://deaddrop.bezoan.com';
|
|
6
|
+
/**
|
|
7
|
+
* Create a DeadDrop client from environment variables
|
|
8
|
+
* Returns null if DEADDROP_API_KEY is not set
|
|
9
|
+
*/
|
|
10
|
+
export function createDeadDropClientFromEnv(runId) {
|
|
11
|
+
const apiKey = process.env['DEADDROP_API_KEY'];
|
|
12
|
+
if (!apiKey) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const host = process.env['DEADDROP_HOST'] ?? DEFAULT_HOST;
|
|
16
|
+
return createDeadDropClient({ apiKey, host, runId });
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a DeadDrop client with the given configuration
|
|
20
|
+
*/
|
|
21
|
+
export function createDeadDropClient(config) {
|
|
22
|
+
const host = config.host.replace(/\/+$/, ''); // Remove trailing slashes
|
|
23
|
+
const url = `${host}/v1/messages`;
|
|
24
|
+
return {
|
|
25
|
+
async send(content, user) {
|
|
26
|
+
try {
|
|
27
|
+
const response = await fetch(url, {
|
|
28
|
+
method: 'POST',
|
|
29
|
+
headers: {
|
|
30
|
+
'Content-Type': 'text/markdown',
|
|
31
|
+
'X-API-Key': config.apiKey,
|
|
32
|
+
'X-DeadDrop-User': user,
|
|
33
|
+
'X-DeadDrop-Subject': config.runId,
|
|
34
|
+
},
|
|
35
|
+
body: content,
|
|
36
|
+
});
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
console.warn(`[DEADDROP] Warning: Failed to send message (${response.status})`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
console.warn(`[DEADDROP] Warning: ${err.message}`);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/deaddrop/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,MAAM,YAAY,GAAG,6BAA6B,CAAC;AAEnD;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAAa;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","sourceRoot":"","sources":["../../src/deaddrop/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/deaddrop/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|