@ironbee-ai/cli 0.5.2 → 0.6.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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/analysis/cross-session.d.ts +1 -1
- package/dist/analysis/cross-session.js +1 -1
- package/dist/analysis/cross-session.js.map +1 -1
- package/dist/analysis/time-analysis.js +3 -3
- package/dist/analysis/time-analysis.js.map +1 -1
- package/dist/analysis/verdict-details.d.ts +1 -1
- package/dist/clients/claude/hooks/clear-verdict.d.ts.map +1 -1
- package/dist/clients/claude/hooks/clear-verdict.js +17 -9
- package/dist/clients/claude/hooks/clear-verdict.js.map +1 -1
- package/dist/clients/claude/hooks/require-verification.d.ts.map +1 -1
- package/dist/clients/claude/hooks/require-verification.js +31 -4
- package/dist/clients/claude/hooks/require-verification.js.map +1 -1
- package/dist/clients/claude/hooks/session-end.d.ts.map +1 -1
- package/dist/clients/claude/hooks/session-end.js +6 -1
- package/dist/clients/claude/hooks/session-end.js.map +1 -1
- package/dist/clients/claude/hooks/session-start.d.ts.map +1 -1
- package/dist/clients/claude/hooks/session-start.js +9 -3
- package/dist/clients/claude/hooks/session-start.js.map +1 -1
- package/dist/clients/claude/hooks/track-action.d.ts +25 -4
- package/dist/clients/claude/hooks/track-action.d.ts.map +1 -1
- package/dist/clients/claude/hooks/track-action.js +160 -29
- package/dist/clients/claude/hooks/track-action.js.map +1 -1
- package/dist/clients/claude/hooks/verify-gate.d.ts.map +1 -1
- package/dist/clients/claude/hooks/verify-gate.js +5 -0
- package/dist/clients/claude/hooks/verify-gate.js.map +1 -1
- package/dist/clients/claude/index.d.ts.map +1 -1
- package/dist/clients/claude/index.js +18 -1
- package/dist/clients/claude/index.js.map +1 -1
- package/dist/clients/claude/util.d.ts +74 -0
- package/dist/clients/claude/util.d.ts.map +1 -0
- package/dist/clients/claude/util.js +352 -0
- package/dist/clients/claude/util.js.map +1 -0
- package/dist/clients/cursor/hooks/clear-verdict.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/clear-verdict.js +19 -10
- package/dist/clients/cursor/hooks/clear-verdict.js.map +1 -1
- package/dist/clients/cursor/hooks/require-verification.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/require-verification.js +28 -4
- package/dist/clients/cursor/hooks/require-verification.js.map +1 -1
- package/dist/clients/cursor/hooks/session-end.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/session-end.js +6 -1
- package/dist/clients/cursor/hooks/session-end.js.map +1 -1
- package/dist/clients/cursor/hooks/session-start.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/session-start.js +7 -2
- package/dist/clients/cursor/hooks/session-start.js.map +1 -1
- package/dist/clients/cursor/hooks/track-action.d.ts +30 -8
- package/dist/clients/cursor/hooks/track-action.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/track-action.js +192 -54
- package/dist/clients/cursor/hooks/track-action.js.map +1 -1
- package/dist/clients/cursor/hooks/verify-gate.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/verify-gate.js +4 -0
- package/dist/clients/cursor/hooks/verify-gate.js.map +1 -1
- package/dist/clients/cursor/index.d.ts.map +1 -1
- package/dist/clients/cursor/index.js +13 -2
- package/dist/clients/cursor/index.js.map +1 -1
- package/dist/clients/cursor/util.d.ts +52 -0
- package/dist/clients/cursor/util.d.ts.map +1 -0
- package/dist/clients/cursor/util.js +264 -0
- package/dist/clients/cursor/util.js.map +1 -0
- package/dist/commands/analyze.js +3 -3
- package/dist/commands/analyze.js.map +1 -1
- package/dist/commands/hook.js +1 -2
- package/dist/commands/hook.js.map +1 -1
- package/dist/commands/process-job-file.d.ts +10 -0
- package/dist/commands/process-job-file.d.ts.map +1 -0
- package/dist/commands/process-job-file.js +19 -0
- package/dist/commands/process-job-file.js.map +1 -0
- package/dist/commands/queue.d.ts +12 -0
- package/dist/commands/queue.d.ts.map +1 -0
- package/dist/commands/queue.js +495 -0
- package/dist/commands/queue.js.map +1 -0
- package/dist/hooks/core/actions.d.ts +168 -27
- package/dist/hooks/core/actions.d.ts.map +1 -1
- package/dist/hooks/core/actions.js +81 -4
- package/dist/hooks/core/actions.js.map +1 -1
- package/dist/hooks/core/activity.d.ts.map +1 -1
- package/dist/hooks/core/activity.js +13 -6
- package/dist/hooks/core/activity.js.map +1 -1
- package/dist/hooks/core/session-state.d.ts +19 -7
- package/dist/hooks/core/session-state.d.ts.map +1 -1
- package/dist/hooks/core/session-state.js +66 -12
- package/dist/hooks/core/session-state.js.map +1 -1
- package/dist/hooks/core/submit-verdict.d.ts.map +1 -1
- package/dist/hooks/core/submit-verdict.js +13 -4
- package/dist/hooks/core/submit-verdict.js.map +1 -1
- package/dist/hooks/core/verification-lifecycle.d.ts.map +1 -1
- package/dist/hooks/core/verification-lifecycle.js +14 -4
- package/dist/hooks/core/verification-lifecycle.js.map +1 -1
- package/dist/hooks/core/verify-gate.d.ts.map +1 -1
- package/dist/hooks/core/verify-gate.js +31 -19
- package/dist/hooks/core/verify-gate.js.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/collector.d.ts +64 -5
- package/dist/lib/collector.d.ts.map +1 -1
- package/dist/lib/collector.js +107 -44
- package/dist/lib/collector.js.map +1 -1
- package/dist/lib/config.d.ts +72 -8
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +40 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/queue/dead-letter.d.ts +26 -0
- package/dist/queue/dead-letter.d.ts.map +1 -0
- package/dist/queue/dead-letter.js +233 -0
- package/dist/queue/dead-letter.js.map +1 -0
- package/dist/queue/drain.d.ts +36 -0
- package/dist/queue/drain.d.ts.map +1 -0
- package/dist/queue/drain.js +170 -0
- package/dist/queue/drain.js.map +1 -0
- package/dist/queue/flush.d.ts +64 -0
- package/dist/queue/flush.d.ts.map +1 -0
- package/dist/queue/flush.js +119 -0
- package/dist/queue/flush.js.map +1 -0
- package/dist/queue/handlers/send-event.d.ts +23 -0
- package/dist/queue/handlers/send-event.d.ts.map +1 -0
- package/dist/queue/handlers/send-event.js +131 -0
- package/dist/queue/handlers/send-event.js.map +1 -0
- package/dist/queue/index.d.ts +30 -0
- package/dist/queue/index.d.ts.map +1 -0
- package/dist/queue/index.js +71 -0
- package/dist/queue/index.js.map +1 -0
- package/dist/queue/paths.d.ts +40 -0
- package/dist/queue/paths.d.ts.map +1 -0
- package/dist/queue/paths.js +107 -0
- package/dist/queue/paths.js.map +1 -0
- package/dist/queue/process-file.d.ts +22 -0
- package/dist/queue/process-file.d.ts.map +1 -0
- package/dist/queue/process-file.js +257 -0
- package/dist/queue/process-file.js.map +1 -0
- package/dist/queue/register-handlers.d.ts +26 -0
- package/dist/queue/register-handlers.d.ts.map +1 -0
- package/dist/queue/register-handlers.js +36 -0
- package/dist/queue/register-handlers.js.map +1 -0
- package/dist/queue/registry.d.ts +42 -0
- package/dist/queue/registry.d.ts.map +1 -0
- package/dist/queue/registry.js +36 -0
- package/dist/queue/registry.js.map +1 -0
- package/dist/queue/snapshot.d.ts +16 -0
- package/dist/queue/snapshot.d.ts.map +1 -0
- package/dist/queue/snapshot.js +39 -0
- package/dist/queue/snapshot.js.map +1 -0
- package/dist/queue/spawn.d.ts +15 -0
- package/dist/queue/spawn.d.ts.map +1 -0
- package/dist/queue/spawn.js +45 -0
- package/dist/queue/spawn.js.map +1 -0
- package/dist/queue/submit.d.ts +19 -0
- package/dist/queue/submit.d.ts.map +1 -0
- package/dist/queue/submit.js +94 -0
- package/dist/queue/submit.js.map +1 -0
- package/dist/queue/types.d.ts +77 -0
- package/dist/queue/types.d.ts.map +1 -0
- package/dist/queue/types.js +83 -0
- package/dist/queue/types.js.map +1 -0
- package/dist/queue/worker-log.d.ts +21 -0
- package/dist/queue/worker-log.d.ts.map +1 -0
- package/dist/queue/worker-log.js +140 -0
- package/dist/queue/worker-log.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IronBee CLI — Queue processFile() worker
|
|
4
|
+
*
|
|
5
|
+
* See docs/job-queue.md §5.3.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.processFile = processFile;
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const path_1 = require("path");
|
|
11
|
+
const readline_1 = require("readline");
|
|
12
|
+
const types_1 = require("./types");
|
|
13
|
+
const paths_1 = require("./paths");
|
|
14
|
+
const registry_1 = require("./registry");
|
|
15
|
+
const dead_letter_1 = require("./dead-letter");
|
|
16
|
+
const worker_log_1 = require("./worker-log");
|
|
17
|
+
/**
|
|
18
|
+
* Process one snapshot file end-to-end.
|
|
19
|
+
*
|
|
20
|
+
* Deletes the file only when every line has reached a terminal state
|
|
21
|
+
* (delivered OR dead-lettered). On transient/auth failure or a transient
|
|
22
|
+
* during per-job fallback, the file is left on disk for later retry.
|
|
23
|
+
*
|
|
24
|
+
* Never throws — all errors are logged to worker.log and classified
|
|
25
|
+
* per §5.3.
|
|
26
|
+
*/
|
|
27
|
+
async function processFile(path, opts) {
|
|
28
|
+
if (!(0, fs_1.existsSync)(path)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const { projectDir, sessionId } = (0, paths_1.parseSnapshotPath)(path);
|
|
32
|
+
const log = new worker_log_1.WorkerLog(projectDir, sessionId);
|
|
33
|
+
const registry = opts?.registry ?? (0, registry_1.snapshotRegistry)();
|
|
34
|
+
// Phase 1: streaming read + parse
|
|
35
|
+
const parsed = [];
|
|
36
|
+
const parseErrors = [];
|
|
37
|
+
try {
|
|
38
|
+
await readLinesStreaming(path, (line) => {
|
|
39
|
+
if (line.length === 0) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const obj = JSON.parse(line);
|
|
44
|
+
if (!isJob(obj)) {
|
|
45
|
+
parseErrors.push({ raw: line, message: "not a valid job envelope" });
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
parsed.push(obj);
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
52
|
+
parseErrors.push({ raw: line, message: msg });
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
58
|
+
log.error(`failed to read ${path}: ${msg}; leaving file`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
log.info(`START path=${path} lines=${parsed.length + parseErrors.length} parse_errors=${parseErrors.length}`);
|
|
62
|
+
// Empty registry + non-empty snapshot is almost always a wiring bug (the
|
|
63
|
+
// CLI entry point forgot to call registerQueueHandlers). Every job is
|
|
64
|
+
// about to be dead-lettered as `no-handler-registered:<type>`. Surface a
|
|
65
|
+
// loud warning so it's not mistaken for a silent success. This matches
|
|
66
|
+
// spec §7.9 (no-handler dead-letters are a legitimate path for obsolete
|
|
67
|
+
// types) but flags the common mistake path.
|
|
68
|
+
if (registry.size === 0 && parsed.length > 0) {
|
|
69
|
+
const msg = `registry is empty but snapshot has ${parsed.length} job(s) — every job will be dead-lettered. Did registerQueueHandlers() fail to wire handlers?`;
|
|
70
|
+
log.warn(msg);
|
|
71
|
+
try {
|
|
72
|
+
process.stderr.write(`ironbee queue WARN: ${msg}\n`);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// ignore — worker.log already has it
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Phase 2: flush parse errors to dead-letter
|
|
79
|
+
for (const err of parseErrors) {
|
|
80
|
+
try {
|
|
81
|
+
(0, dead_letter_1.deadLetterParseError)({ projectDir, sessionId, sourceFile: path }, err.raw, `parse-error: ${err.message}`);
|
|
82
|
+
log.info(`DEAD_LETTER parse-error from=${(0, path_1.basename)(path)}`);
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
86
|
+
log.error(`failed to dead-letter parse-error: ${msg}; leaving file`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Phase 3: group by type, iterate sorted for determinism
|
|
91
|
+
const groups = new Map();
|
|
92
|
+
for (const job of parsed) {
|
|
93
|
+
const existing = groups.get(job.type);
|
|
94
|
+
if (existing) {
|
|
95
|
+
existing.push(job);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
groups.set(job.type, [job]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const types = [...groups.keys()].sort();
|
|
102
|
+
let deadCount = parseErrors.length;
|
|
103
|
+
let okCount = 0;
|
|
104
|
+
for (const type of types) {
|
|
105
|
+
const jobs = groups.get(type);
|
|
106
|
+
const handler = registry.get(type);
|
|
107
|
+
if (!handler) {
|
|
108
|
+
for (const job of jobs) {
|
|
109
|
+
try {
|
|
110
|
+
(0, dead_letter_1.deadLetterParsed)({ projectDir, sessionId, sourceFile: path }, job, `no-handler-registered:${type}`);
|
|
111
|
+
deadCount++;
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
115
|
+
log.error(`failed to dead-letter unhandled job ${job.id}: ${msg}; leaving file`);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
log.info(`NO_HANDLER type=${type} count=${jobs.length}`);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
await handler.dispatch(jobs);
|
|
124
|
+
okCount += jobs.length;
|
|
125
|
+
log.info(`BATCH_OK type=${type} count=${jobs.length}`);
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
if (e instanceof types_1.TransientError) {
|
|
129
|
+
log.warn(`TRANSIENT type=${type}: ${e.message}; leaving file for retry`);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (e instanceof types_1.AuthError) {
|
|
133
|
+
log.error(`AUTH type=${type}: ${e.message}; leaving file; operator must fix credentials`);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (e instanceof types_1.BadRequestBatchError) {
|
|
137
|
+
log.warn(`BATCH_400 type=${type}: ${e.message}; falling back to per-job dispatch`);
|
|
138
|
+
const result = await fallbackPerJob(handler, jobs, path, projectDir, sessionId, log);
|
|
139
|
+
if (result.bailed) {
|
|
140
|
+
return; // file left on disk
|
|
141
|
+
}
|
|
142
|
+
okCount += result.ok;
|
|
143
|
+
deadCount += result.dead;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
// Unexpected batch-level error: dead-letter every job in the batch and keep going.
|
|
147
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
148
|
+
log.error(`BATCH_UNEXPECTED type=${type}: ${msg}`);
|
|
149
|
+
for (const job of jobs) {
|
|
150
|
+
try {
|
|
151
|
+
(0, dead_letter_1.deadLetterParsed)({ projectDir, sessionId, sourceFile: path }, job, `unexpected:${msg}`);
|
|
152
|
+
deadCount++;
|
|
153
|
+
}
|
|
154
|
+
catch (e2) {
|
|
155
|
+
const msg2 = e2 instanceof Error ? e2.message : String(e2);
|
|
156
|
+
log.error(`failed to dead-letter unexpected-batch job ${job.id}: ${msg2}; leaving file`);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Phase 4: every line is terminal → delete the snapshot
|
|
163
|
+
try {
|
|
164
|
+
(0, fs_1.unlinkSync)(path);
|
|
165
|
+
log.info(`DONE path=${(0, path_1.basename)(path)} lines_ok=${okCount} lines_dead=${deadCount}`);
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
169
|
+
// §7.14 — next drain will re-process; downstream dedupes on id
|
|
170
|
+
log.warn(`UNLINK_FAILED path=${path}: ${msg}; leaving file for re-processing`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async function fallbackPerJob(handler, jobs, sourcePath, projectDir, sessionId, log) {
|
|
174
|
+
let ok = 0;
|
|
175
|
+
let dead = 0;
|
|
176
|
+
for (const job of jobs) {
|
|
177
|
+
try {
|
|
178
|
+
await handler.dispatchSingle(job);
|
|
179
|
+
ok++;
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
if (e instanceof types_1.BadRequestError) {
|
|
183
|
+
try {
|
|
184
|
+
(0, dead_letter_1.deadLetterParsed)({ projectDir, sessionId, sourceFile: sourcePath }, job, e.message);
|
|
185
|
+
dead++;
|
|
186
|
+
}
|
|
187
|
+
catch (e2) {
|
|
188
|
+
const msg = e2 instanceof Error ? e2.message : String(e2);
|
|
189
|
+
log.error(`failed to dead-letter bad-request job ${job.id}: ${msg}; leaving file`);
|
|
190
|
+
return { ok, dead, bailed: true };
|
|
191
|
+
}
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
if (e instanceof types_1.TransientError) {
|
|
195
|
+
log.warn(`TRANSIENT_DURING_FALLBACK job=${job.id}: ${e.message}; leaving file`);
|
|
196
|
+
return { ok, dead, bailed: true };
|
|
197
|
+
}
|
|
198
|
+
if (e instanceof types_1.AuthError) {
|
|
199
|
+
log.error(`AUTH_DURING_FALLBACK job=${job.id}: ${e.message}; leaving file`);
|
|
200
|
+
return { ok, dead, bailed: true };
|
|
201
|
+
}
|
|
202
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
203
|
+
try {
|
|
204
|
+
(0, dead_letter_1.deadLetterParsed)({ projectDir, sessionId, sourceFile: sourcePath }, job, `unexpected:${msg}`);
|
|
205
|
+
dead++;
|
|
206
|
+
}
|
|
207
|
+
catch (e2) {
|
|
208
|
+
const msg2 = e2 instanceof Error ? e2.message : String(e2);
|
|
209
|
+
log.error(`failed to dead-letter unexpected job ${job.id}: ${msg2}; leaving file`);
|
|
210
|
+
return { ok, dead, bailed: true };
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return { ok, dead, bailed: false };
|
|
215
|
+
}
|
|
216
|
+
function readLinesStreaming(path, onLine) {
|
|
217
|
+
return new Promise((resolve, reject) => {
|
|
218
|
+
const stream = (0, fs_1.createReadStream)(path, { encoding: "utf-8" });
|
|
219
|
+
const rl = (0, readline_1.createInterface)({ input: stream, crlfDelay: Infinity });
|
|
220
|
+
let inlineErr = null;
|
|
221
|
+
rl.on("line", (line) => {
|
|
222
|
+
if (inlineErr) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
try {
|
|
226
|
+
onLine(line);
|
|
227
|
+
}
|
|
228
|
+
catch (e) {
|
|
229
|
+
inlineErr = e instanceof Error ? e : new Error(String(e));
|
|
230
|
+
rl.close();
|
|
231
|
+
stream.destroy();
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
rl.on("close", () => {
|
|
235
|
+
if (inlineErr) {
|
|
236
|
+
reject(inlineErr);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
resolve();
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
stream.on("error", (err) => {
|
|
243
|
+
reject(err);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
function isJob(obj) {
|
|
248
|
+
if (typeof obj !== "object" || obj === null) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
const o = obj;
|
|
252
|
+
return typeof o.id === "string"
|
|
253
|
+
&& typeof o.type === "string"
|
|
254
|
+
&& typeof o.created_at === "string"
|
|
255
|
+
&& "data" in o;
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=process-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-file.js","sourceRoot":"","sources":["../../src/queue/process-file.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAqCH,kCA8JC;AAjMD,2BAA8D;AAC9D,+BAAgC;AAChC,uCAA2E;AAC3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AAE,CAAC;QAC1C,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,CAAC,GAA4B,GAA8B,CAAC;IAClE,OAAO,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ;WACxB,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ;WAC1B,OAAO,CAAC,CAAC,UAAU,KAAK,QAAQ;WAChC,MAAM,IAAI,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IronBee CLI — Queue Handler Bootstrap
|
|
3
|
+
*
|
|
4
|
+
* Single wiring point for all queue job-type handlers. Imported and invoked
|
|
5
|
+
* by `src/index.ts` before `program.parse()` so that any CLI entry point
|
|
6
|
+
* (`ironbee queue drain`, `ironbee process-job-file`, or a hook-driven
|
|
7
|
+
* flushSynchronously) sees a fully-populated global registry.
|
|
8
|
+
*
|
|
9
|
+
* Currently empty — no concrete consumer exists yet. When a producer is
|
|
10
|
+
* added (e.g. a `send_event` producer on top of the tool_call hook), its
|
|
11
|
+
* handler MUST be registered here. Forgetting to do so means every job of
|
|
12
|
+
* that type will silently be written to dead-letter as
|
|
13
|
+
* `no-handler-registered:<type>` (§7.9).
|
|
14
|
+
*
|
|
15
|
+
* Why not register inside each producer module's top-level code?
|
|
16
|
+
* - Side-effectful top-level imports are hard to reason about.
|
|
17
|
+
* - A detached worker spawned via `spawnDetachedWorker` starts a fresh
|
|
18
|
+
* Node process and imports the CLI entry point — it will only see
|
|
19
|
+
* handlers registered via this bootstrap.
|
|
20
|
+
*
|
|
21
|
+
* Keep registrations idempotent — this function may be called more than
|
|
22
|
+
* once in tests.
|
|
23
|
+
*/
|
|
24
|
+
export declare const SEND_EVENT_TYPE: string;
|
|
25
|
+
export declare function registerQueueHandlers(): void;
|
|
26
|
+
//# sourceMappingURL=register-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-handlers.d.ts","sourceRoot":"","sources":["../../src/queue/register-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,eAAO,MAAM,eAAe,EAAE,MAAqB,CAAC;AAEpD,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IronBee CLI — Queue Handler Bootstrap
|
|
4
|
+
*
|
|
5
|
+
* Single wiring point for all queue job-type handlers. Imported and invoked
|
|
6
|
+
* by `src/index.ts` before `program.parse()` so that any CLI entry point
|
|
7
|
+
* (`ironbee queue drain`, `ironbee process-job-file`, or a hook-driven
|
|
8
|
+
* flushSynchronously) sees a fully-populated global registry.
|
|
9
|
+
*
|
|
10
|
+
* Currently empty — no concrete consumer exists yet. When a producer is
|
|
11
|
+
* added (e.g. a `send_event` producer on top of the tool_call hook), its
|
|
12
|
+
* handler MUST be registered here. Forgetting to do so means every job of
|
|
13
|
+
* that type will silently be written to dead-letter as
|
|
14
|
+
* `no-handler-registered:<type>` (§7.9).
|
|
15
|
+
*
|
|
16
|
+
* Why not register inside each producer module's top-level code?
|
|
17
|
+
* - Side-effectful top-level imports are hard to reason about.
|
|
18
|
+
* - A detached worker spawned via `spawnDetachedWorker` starts a fresh
|
|
19
|
+
* Node process and imports the CLI entry point — it will only see
|
|
20
|
+
* handlers registered via this bootstrap.
|
|
21
|
+
*
|
|
22
|
+
* Keep registrations idempotent — this function may be called more than
|
|
23
|
+
* once in tests.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.SEND_EVENT_TYPE = void 0;
|
|
27
|
+
exports.registerQueueHandlers = registerQueueHandlers;
|
|
28
|
+
const registry_1 = require("./registry");
|
|
29
|
+
const send_event_1 = require("./handlers/send-event");
|
|
30
|
+
exports.SEND_EVENT_TYPE = "send_event";
|
|
31
|
+
function registerQueueHandlers() {
|
|
32
|
+
// send_event — POST event envelopes (tool_call, session_start, …) to
|
|
33
|
+
// the IronBee Collector. See src/queue/handlers/send-event.ts.
|
|
34
|
+
(0, registry_1.register)(exports.SEND_EVENT_TYPE, send_event_1.sendEventHandler);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=register-handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-handlers.js","sourceRoot":"","sources":["../../src/queue/register-handlers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAOH,sDAIC;AATD,yCAAsC;AACtC,sDAAyD;AAE5C,QAAA,eAAe,GAAW,YAAY,CAAC;AAEpD,SAAgB,qBAAqB;IACjC,qEAAqE;IACrE,+DAA+D;IAC/D,IAAA,mBAAQ,EAAC,uBAAe,EAAE,6BAAgB,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IronBee CLI — Queue Handler Registry
|
|
3
|
+
*
|
|
4
|
+
* Handlers are registered per job `type`. The worker captures a snapshot of
|
|
5
|
+
* the registry at the top of processFile() (§5.3 "Handler registry" note) so
|
|
6
|
+
* mid-run registration changes cannot confuse dispatch.
|
|
7
|
+
*/
|
|
8
|
+
import { Job } from "./types";
|
|
9
|
+
export interface Handler<TData = unknown> {
|
|
10
|
+
/**
|
|
11
|
+
* Batch dispatch. Must throw:
|
|
12
|
+
* - TransientError on retriable failures (5xx, network)
|
|
13
|
+
* - AuthError on auth failures (401/403)
|
|
14
|
+
* - BadRequestBatchError when the batch was rejected but the specific
|
|
15
|
+
* offending line is unknown (worker will fall back
|
|
16
|
+
* to per-job dispatchSingle)
|
|
17
|
+
* Other thrown errors bubble up as `unexpected:` and per-job-dead-letter
|
|
18
|
+
* via the fallback path.
|
|
19
|
+
*/
|
|
20
|
+
dispatch(jobs: Job<TData>[]): Promise<void> | void;
|
|
21
|
+
/**
|
|
22
|
+
* Per-job fallback. Must throw:
|
|
23
|
+
* - BadRequestError for a permanent per-job failure (worker dead-letters
|
|
24
|
+
* this job and continues with the next)
|
|
25
|
+
* - TransientError to bail out of the fallback and leave the snapshot
|
|
26
|
+
* for a full-file retry
|
|
27
|
+
* - AuthError same as transient but signals auth needs fixing
|
|
28
|
+
*/
|
|
29
|
+
dispatchSingle(job: Job<TData>): Promise<void> | void;
|
|
30
|
+
}
|
|
31
|
+
export type HandlerRegistry = Map<string, Handler>;
|
|
32
|
+
export declare function register<TData>(type: string, handler: Handler<TData>): void;
|
|
33
|
+
export declare function unregister(type: string): void;
|
|
34
|
+
export declare function get(type: string): Handler | undefined;
|
|
35
|
+
export declare function clear(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Return an immutable snapshot of the registry. Callers should capture this
|
|
38
|
+
* once per processFile() invocation and use it for the entire pass — see
|
|
39
|
+
* §7.18 (registry snapshot consistency).
|
|
40
|
+
*/
|
|
41
|
+
export declare function snapshotRegistry(): HandlerRegistry;
|
|
42
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/queue/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,MAAM,WAAW,OAAO,CAAC,KAAK,GAAG,OAAO;IACpC;;;;;;;;;OASG;IACH,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAEnD;;;;;;;OAOG;IACH,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACzD;AAED,MAAM,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAInD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAE3E;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAErD;AAED,wBAAgB,KAAK,IAAI,IAAI,CAE5B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,eAAe,CAElD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IronBee CLI — Queue Handler Registry
|
|
4
|
+
*
|
|
5
|
+
* Handlers are registered per job `type`. The worker captures a snapshot of
|
|
6
|
+
* the registry at the top of processFile() (§5.3 "Handler registry" note) so
|
|
7
|
+
* mid-run registration changes cannot confuse dispatch.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.register = register;
|
|
11
|
+
exports.unregister = unregister;
|
|
12
|
+
exports.get = get;
|
|
13
|
+
exports.clear = clear;
|
|
14
|
+
exports.snapshotRegistry = snapshotRegistry;
|
|
15
|
+
const globalRegistry = new Map();
|
|
16
|
+
function register(type, handler) {
|
|
17
|
+
globalRegistry.set(type, handler);
|
|
18
|
+
}
|
|
19
|
+
function unregister(type) {
|
|
20
|
+
globalRegistry.delete(type);
|
|
21
|
+
}
|
|
22
|
+
function get(type) {
|
|
23
|
+
return globalRegistry.get(type);
|
|
24
|
+
}
|
|
25
|
+
function clear() {
|
|
26
|
+
globalRegistry.clear();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Return an immutable snapshot of the registry. Callers should capture this
|
|
30
|
+
* once per processFile() invocation and use it for the entire pass — see
|
|
31
|
+
* §7.18 (registry snapshot consistency).
|
|
32
|
+
*/
|
|
33
|
+
function snapshotRegistry() {
|
|
34
|
+
return new Map(globalRegistry);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/queue/registry.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAgCH,4BAEC;AAED,gCAEC;AAED,kBAEC;AAED,sBAEC;AAOD,4CAEC;AAzBD,MAAM,cAAc,GAAoB,IAAI,GAAG,EAAmB,CAAC;AAEnE,SAAgB,QAAQ,CAAQ,IAAY,EAAE,OAAuB;IACjE,cAAc,CAAC,GAAG,CAAC,IAAI,EAAE,OAAkB,CAAC,CAAC;AACjD,CAAC;AAED,SAAgB,UAAU,CAAC,IAAY;IACnC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,SAAgB,GAAG,CAAC,IAAY;IAC5B,OAAO,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC;AAED,SAAgB,KAAK;IACjB,cAAc,CAAC,KAAK,EAAE,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB;IAC5B,OAAO,IAAI,GAAG,CAAkB,cAAc,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IronBee CLI — Queue snapshot()
|
|
3
|
+
*
|
|
4
|
+
* See docs/job-queue.md §5.2.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Atomically freeze the live queue file into a snapshot.
|
|
8
|
+
* Success → returns absolute snapshot path
|
|
9
|
+
* Live file missing (ENOENT) → returns null
|
|
10
|
+
*
|
|
11
|
+
* Throws:
|
|
12
|
+
* - InvalidSessionIdError if sessionId fails validation
|
|
13
|
+
* - IOError on filesystem errors other than ENOENT
|
|
14
|
+
*/
|
|
15
|
+
export declare function snapshot(projectDir: string, sessionId: string): string | null;
|
|
16
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/queue/snapshot.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiB7E"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IronBee CLI — Queue snapshot()
|
|
4
|
+
*
|
|
5
|
+
* See docs/job-queue.md §5.2.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.snapshot = snapshot;
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const crypto_1 = require("crypto");
|
|
11
|
+
const types_1 = require("./types");
|
|
12
|
+
const paths_1 = require("./paths");
|
|
13
|
+
/**
|
|
14
|
+
* Atomically freeze the live queue file into a snapshot.
|
|
15
|
+
* Success → returns absolute snapshot path
|
|
16
|
+
* Live file missing (ENOENT) → returns null
|
|
17
|
+
*
|
|
18
|
+
* Throws:
|
|
19
|
+
* - InvalidSessionIdError if sessionId fails validation
|
|
20
|
+
* - IOError on filesystem errors other than ENOENT
|
|
21
|
+
*/
|
|
22
|
+
function snapshot(projectDir, sessionId) {
|
|
23
|
+
(0, paths_1.validateSessionId)(sessionId);
|
|
24
|
+
const snapshotId = (0, crypto_1.randomUUID)();
|
|
25
|
+
const src = (0, paths_1.liveQueueFile)(projectDir, sessionId);
|
|
26
|
+
const dst = (0, paths_1.snapshotFile)(projectDir, sessionId, snapshotId);
|
|
27
|
+
try {
|
|
28
|
+
(0, fs_1.renameSync)(src, dst);
|
|
29
|
+
return dst;
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
const err = e;
|
|
33
|
+
if (err.code === "ENOENT") {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
throw new types_1.IOError(`failed to rename ${src} -> ${dst}`, e);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/queue/snapshot.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAgBH,4BAiBC;AA/BD,2BAAgC;AAChC,mCAAoC;AACpC,mCAAkC;AAClC,mCAAyE;AAEzE;;;;;;;;GAQG;AACH,SAAgB,QAAQ,CAAC,UAAkB,EAAE,SAAiB;IAC1D,IAAA,yBAAiB,EAAC,SAAS,CAAC,CAAC;IAE7B,MAAM,UAAU,GAAW,IAAA,mBAAU,GAAE,CAAC;IACxC,MAAM,GAAG,GAAW,IAAA,qBAAa,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IACzD,MAAM,GAAG,GAAW,IAAA,oBAAY,EAAC,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;IAEpE,IAAI,CAAC;QACD,IAAA,eAAU,EAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACrB,OAAO,GAAG,CAAC;IACf,CAAC;IAAC,OAAO,CAAU,EAAE,CAAC;QAClB,MAAM,GAAG,GAA0B,CAA0B,CAAC;QAC9D,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,MAAM,IAAI,eAAO,CAAC,oBAAoB,GAAG,OAAO,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;IAC9D,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IronBee CLI — Detached Worker Spawn
|
|
3
|
+
*
|
|
4
|
+
* See docs/job-queue.md §5.6 (when to use), §9.1 (platform primitives).
|
|
5
|
+
*
|
|
6
|
+
* Callers on the active-use path use this helper to fire-and-forget a worker
|
|
7
|
+
* on a freshly-minted snapshot. The trigger returns in <10 ms; the worker
|
|
8
|
+
* survives the trigger's exit.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Spawn a detached worker on the given snapshot path. Returns immediately.
|
|
12
|
+
* The parent process may exit without killing the child.
|
|
13
|
+
*/
|
|
14
|
+
export declare function spawnDetachedWorker(snapshotPath: string): void;
|
|
15
|
+
//# sourceMappingURL=spawn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/queue/spawn.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAsBH;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAU9D"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IronBee CLI — Detached Worker Spawn
|
|
4
|
+
*
|
|
5
|
+
* See docs/job-queue.md §5.6 (when to use), §9.1 (platform primitives).
|
|
6
|
+
*
|
|
7
|
+
* Callers on the active-use path use this helper to fire-and-forget a worker
|
|
8
|
+
* on a freshly-minted snapshot. The trigger returns in <10 ms; the worker
|
|
9
|
+
* survives the trigger's exit.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.spawnDetachedWorker = spawnDetachedWorker;
|
|
13
|
+
const child_process_1 = require("child_process");
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the `ironbee` binary to invoke. Falls back to `node <currentEntry>`
|
|
16
|
+
* if the CLI was launched via `node dist/index.js` (common in tests / dev).
|
|
17
|
+
*/
|
|
18
|
+
function resolveInvocation() {
|
|
19
|
+
const override = process.env.IRONBEE_BIN;
|
|
20
|
+
if (override) {
|
|
21
|
+
return { command: override, args: [] };
|
|
22
|
+
}
|
|
23
|
+
const argv0 = process.argv[0];
|
|
24
|
+
const argv1 = process.argv[1] ?? "";
|
|
25
|
+
// when launched via `ironbee` bin, argv[1] is the dist/index.js path — re-run it via node
|
|
26
|
+
if (argv1.endsWith("index.js") || argv1.endsWith("index.ts")) {
|
|
27
|
+
return { command: argv0, args: [argv1] };
|
|
28
|
+
}
|
|
29
|
+
return { command: "ironbee", args: [] };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Spawn a detached worker on the given snapshot path. Returns immediately.
|
|
33
|
+
* The parent process may exit without killing the child.
|
|
34
|
+
*/
|
|
35
|
+
function spawnDetachedWorker(snapshotPath) {
|
|
36
|
+
const { command, args } = resolveInvocation();
|
|
37
|
+
const fullArgs = [...args, "process-job-file", snapshotPath];
|
|
38
|
+
const child = (0, child_process_1.spawn)(command, fullArgs, {
|
|
39
|
+
detached: true,
|
|
40
|
+
stdio: "ignore",
|
|
41
|
+
env: process.env,
|
|
42
|
+
});
|
|
43
|
+
child.unref();
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=spawn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../src/queue/spawn.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AA0BH,kDAUC;AAlCD,iDAAoD;AAEpD;;;GAGG;AACH,SAAS,iBAAiB;IACtB,MAAM,QAAQ,GAAuB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IAC7D,IAAI,QAAQ,EAAE,CAAC;QACX,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC3C,CAAC;IACD,MAAM,KAAK,GAAW,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,KAAK,GAAW,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5C,0FAA0F;IAC1F,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;IAC7C,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,YAAoB;IACpD,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAAa,CAAC,GAAG,IAAI,EAAE,kBAAkB,EAAE,YAAY,CAAC,CAAC;IAEvE,MAAM,KAAK,GAAiB,IAAA,qBAAK,EAAC,OAAO,EAAE,QAAQ,EAAE;QACjD,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,QAAQ;QACf,GAAG,EAAE,OAAO,CAAC,GAAG;KACnB,CAAC,CAAC;IACH,KAAK,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IronBee CLI — Queue submit()
|
|
3
|
+
*
|
|
4
|
+
* See docs/job-queue.md §5.1.
|
|
5
|
+
*/
|
|
6
|
+
export interface SubmitOptions {
|
|
7
|
+
id?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Append a job to `<projectDir>/.ironbee/sessions/<sessionId>/queue/jobs.jsonl`
|
|
11
|
+
* via a single O_APPEND write. Returns the job id.
|
|
12
|
+
*
|
|
13
|
+
* Throws:
|
|
14
|
+
* - InvalidSessionIdError if sessionId fails validation
|
|
15
|
+
* - JobTooLargeError if serialized line > 4 KB
|
|
16
|
+
* - IOError on filesystem errors (including short write)
|
|
17
|
+
*/
|
|
18
|
+
export declare function submit<TData>(projectDir: string, sessionId: string, type: string, data: TData, opts?: SubmitOptions): string;
|
|
19
|
+
//# sourceMappingURL=submit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submit.d.ts","sourceRoot":"","sources":["../../src/queue/submit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH,MAAM,WAAW,aAAa;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,KAAK,EACxB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,KAAK,EACX,IAAI,CAAC,EAAE,aAAa,GACrB,MAAM,CAwER"}
|