@ironbee-ai/cli 0.5.3 → 0.6.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/CHANGELOG.md +12 -0
- package/dist/clients/claude/hooks/require-verification.d.ts.map +1 -1
- package/dist/clients/claude/hooks/require-verification.js +21 -2
- 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 +4 -0
- 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 +14 -4
- 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 +145 -25
- 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/require-verification.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/require-verification.js +18 -2
- 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 +4 -0
- 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 +4 -1
- 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 +179 -52
- 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/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 +73 -2
- package/dist/hooks/core/actions.d.ts.map +1 -1
- package/dist/hooks/core/actions.js +36 -2
- package/dist/hooks/core/actions.js.map +1 -1
- package/dist/hooks/core/session-state.d.ts +27 -0
- package/dist/hooks/core/session-state.d.ts.map +1 -1
- package/dist/hooks/core/session-state.js +97 -0
- package/dist/hooks/core/session-state.js.map +1 -1
- package/dist/hooks/core/verify-gate.d.ts.map +1 -1
- package/dist/hooks/core/verify-gate.js +13 -5
- 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 +62 -3
- package/dist/lib/collector.d.ts.map +1 -1
- package/dist/lib/collector.js +107 -35
- 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,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"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IronBee CLI — Queue submit()
|
|
4
|
+
*
|
|
5
|
+
* See docs/job-queue.md §5.1.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.submit = submit;
|
|
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
|
+
const flush_1 = require("./flush");
|
|
14
|
+
const config_1 = require("../lib/config");
|
|
15
|
+
const logger_1 = require("../lib/logger");
|
|
16
|
+
/**
|
|
17
|
+
* Append a job to `<projectDir>/.ironbee/sessions/<sessionId>/queue/jobs.jsonl`
|
|
18
|
+
* via a single O_APPEND write. Returns the job id.
|
|
19
|
+
*
|
|
20
|
+
* Throws:
|
|
21
|
+
* - InvalidSessionIdError if sessionId fails validation
|
|
22
|
+
* - JobTooLargeError if serialized line > 4 KB
|
|
23
|
+
* - IOError on filesystem errors (including short write)
|
|
24
|
+
*/
|
|
25
|
+
function submit(projectDir, sessionId, type, data, opts) {
|
|
26
|
+
(0, paths_1.validateSessionId)(sessionId);
|
|
27
|
+
// Defense-in-depth gate: when the queue is disabled (default), drop the
|
|
28
|
+
// job before touching the filesystem. Callers should already short-circuit
|
|
29
|
+
// before constructing a payload, but this guard stops a stray submit()
|
|
30
|
+
// from creating the queue dir or growing jobs.jsonl needlessly.
|
|
31
|
+
if (!(0, config_1.isJobQueueEnabled)(projectDir)) {
|
|
32
|
+
const id = opts?.id ?? (0, crypto_1.randomUUID)();
|
|
33
|
+
logger_1.logger.debug(`submit: jobQueue disabled, dropping job type=${type} id=${id}`);
|
|
34
|
+
return id;
|
|
35
|
+
}
|
|
36
|
+
const dir = (0, paths_1.queueDir)(projectDir, sessionId);
|
|
37
|
+
try {
|
|
38
|
+
(0, fs_1.mkdirSync)(dir, { recursive: true, mode: 0o700 });
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
throw new types_1.IOError(`failed to mkdir queue dir: ${dir}`, e);
|
|
42
|
+
}
|
|
43
|
+
const id = opts?.id ?? (0, crypto_1.randomUUID)();
|
|
44
|
+
const job = {
|
|
45
|
+
id,
|
|
46
|
+
type,
|
|
47
|
+
created_at: new Date().toISOString(),
|
|
48
|
+
data,
|
|
49
|
+
};
|
|
50
|
+
const line = JSON.stringify(job) + "\n";
|
|
51
|
+
const bytes = Buffer.from(line, "utf-8");
|
|
52
|
+
if (bytes.length > types_1.MAX_LINE_BYTES) {
|
|
53
|
+
throw new types_1.JobTooLargeError(bytes.length);
|
|
54
|
+
}
|
|
55
|
+
const filePath = (0, paths_1.liveQueueFile)(projectDir, sessionId);
|
|
56
|
+
const flags = fs_1.constants.O_CREAT
|
|
57
|
+
| fs_1.constants.O_WRONLY
|
|
58
|
+
| fs_1.constants.O_APPEND
|
|
59
|
+
| (typeof fs_1.constants.O_NOFOLLOW === "number" ? fs_1.constants.O_NOFOLLOW : 0);
|
|
60
|
+
let fd;
|
|
61
|
+
try {
|
|
62
|
+
fd = (0, fs_1.openSync)(filePath, flags, 0o600);
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
throw new types_1.IOError(`failed to open ${filePath}`, e);
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
let written;
|
|
69
|
+
try {
|
|
70
|
+
written = (0, fs_1.writeSync)(fd, bytes, 0, bytes.length);
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
// ENOSPC / EIO / etc — wrap to preserve spec §5.1 contract that
|
|
74
|
+
// submit() throws IOError with the underlying errno.
|
|
75
|
+
throw new types_1.IOError(`failed to write to ${filePath}`, e);
|
|
76
|
+
}
|
|
77
|
+
if (written !== bytes.length) {
|
|
78
|
+
throw new types_1.IOError(`short write on ${filePath}: wrote ${written} of ${bytes.length} bytes`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
try {
|
|
83
|
+
(0, fs_1.closeSync)(fd);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// ignore close errors — the write has already landed (or failed)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// size-based auto-flush trigger. Fail-safe: never propagates exceptions
|
|
90
|
+
// to submit()'s caller, the line has already been persisted.
|
|
91
|
+
(0, flush_1.maybeAutoFlush)(projectDir, sessionId);
|
|
92
|
+
return id;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=submit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submit.js","sourceRoot":"","sources":["../../src/queue/submit.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IronBee CLI — Queue Types & Errors
|
|
3
|
+
*
|
|
4
|
+
* See docs/job-queue.md §4 (job format), §6 (error classification).
|
|
5
|
+
*/
|
|
6
|
+
export declare class InvalidSessionIdError extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class JobTooLargeError extends Error {
|
|
10
|
+
readonly sizeBytes: number;
|
|
11
|
+
constructor(sizeBytes: number);
|
|
12
|
+
}
|
|
13
|
+
export declare class IOError extends Error {
|
|
14
|
+
readonly cause?: unknown;
|
|
15
|
+
constructor(message: string, cause?: unknown);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Handler throws this on transient failures (network timeout, 5xx, 429).
|
|
19
|
+
* Worker leaves the snapshot on disk for later retry.
|
|
20
|
+
*/
|
|
21
|
+
export declare class TransientError extends Error {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Handler throws this on auth failures (401, 403, expired credential).
|
|
26
|
+
* Worker leaves the snapshot on disk and logs an operator-actionable error.
|
|
27
|
+
*/
|
|
28
|
+
export declare class AuthError extends Error {
|
|
29
|
+
constructor(message: string);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Handler's batch `dispatch()` throws this when the downstream rejected the
|
|
33
|
+
* batch but we don't know which line caused it — worker falls back to
|
|
34
|
+
* per-job `dispatchSingle()`.
|
|
35
|
+
*/
|
|
36
|
+
export declare class BadRequestBatchError extends Error {
|
|
37
|
+
constructor(message: string);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Handler's `dispatchSingle()` throws this on a permanent per-job failure
|
|
41
|
+
* (400 for this specific job). Worker dead-letters the job and continues.
|
|
42
|
+
*/
|
|
43
|
+
export declare class BadRequestError extends Error {
|
|
44
|
+
constructor(message: string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Job envelope — exactly three queue-owned top-level fields plus the opaque
|
|
48
|
+
* `data` payload. Mirrors the spec's §4 schema.
|
|
49
|
+
*/
|
|
50
|
+
export interface Job<TData = unknown> {
|
|
51
|
+
id: string;
|
|
52
|
+
type: string;
|
|
53
|
+
created_at: string;
|
|
54
|
+
data: TData;
|
|
55
|
+
}
|
|
56
|
+
export interface DeadLetterParsed {
|
|
57
|
+
id: string;
|
|
58
|
+
received_at: string;
|
|
59
|
+
source_file: string;
|
|
60
|
+
category: string;
|
|
61
|
+
original: Job;
|
|
62
|
+
}
|
|
63
|
+
export interface DeadLetterParseError {
|
|
64
|
+
id: string;
|
|
65
|
+
received_at: string;
|
|
66
|
+
source_file: string;
|
|
67
|
+
category: string;
|
|
68
|
+
raw: string;
|
|
69
|
+
}
|
|
70
|
+
export type DeadLetterEntry = DeadLetterParsed | DeadLetterParseError;
|
|
71
|
+
export declare const MAX_LINE_BYTES: number;
|
|
72
|
+
export declare const DEAD_LETTER_ROTATE_BYTES: number;
|
|
73
|
+
export declare const DEAD_LETTER_RETAIN_COUNT: number;
|
|
74
|
+
export declare const WORKER_LOG_ROTATE_BYTES: number;
|
|
75
|
+
export declare const WORKER_LOG_RETAIN_COUNT: number;
|
|
76
|
+
export declare const DEAD_LETTER_RAW_MAX: number;
|
|
77
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/queue/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,qBAAa,qBAAsB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAI9B;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IACvC,SAAgB,SAAS,EAAE,MAAM,CAAC;gBACtB,SAAS,EAAE,MAAM;CAKhC;AAED,qBAAa,OAAQ,SAAQ,KAAK;IAC9B,SAAgB,KAAK,CAAC,EAAE,OAAO,CAAC;gBACpB,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAK/C;AAED;;;GAGG;AACH,qBAAa,cAAe,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI9B;AAED;;;GAGG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACpB,OAAO,EAAE,MAAM;CAI9B;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI9B;AAED;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI9B;AAED;;;GAGG;AACH,MAAM,WAAW,GAAG,CAAC,KAAK,GAAG,OAAO;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,GAAG,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,oBAAoB,CAAC;AAEtE,eAAO,MAAM,cAAc,EAAE,MAAa,CAAC;AAC3C,eAAO,MAAM,wBAAwB,EAAE,MAAyB,CAAC;AACjE,eAAO,MAAM,wBAAwB,EAAE,MAAU,CAAC;AAClD,eAAO,MAAM,uBAAuB,EAAE,MAAyB,CAAC;AAChE,eAAO,MAAM,uBAAuB,EAAE,MAAU,CAAC;AACjD,eAAO,MAAM,mBAAmB,EAAE,MAAY,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IronBee CLI — Queue Types & Errors
|
|
4
|
+
*
|
|
5
|
+
* See docs/job-queue.md §4 (job format), §6 (error classification).
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.DEAD_LETTER_RAW_MAX = exports.WORKER_LOG_RETAIN_COUNT = exports.WORKER_LOG_ROTATE_BYTES = exports.DEAD_LETTER_RETAIN_COUNT = exports.DEAD_LETTER_ROTATE_BYTES = exports.MAX_LINE_BYTES = exports.BadRequestError = exports.BadRequestBatchError = exports.AuthError = exports.TransientError = exports.IOError = exports.JobTooLargeError = exports.InvalidSessionIdError = void 0;
|
|
9
|
+
class InvalidSessionIdError extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "InvalidSessionIdError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.InvalidSessionIdError = InvalidSessionIdError;
|
|
16
|
+
class JobTooLargeError extends Error {
|
|
17
|
+
constructor(sizeBytes) {
|
|
18
|
+
super(`job line exceeds 4 KB limit (${sizeBytes} bytes)`);
|
|
19
|
+
this.name = "JobTooLargeError";
|
|
20
|
+
this.sizeBytes = sizeBytes;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.JobTooLargeError = JobTooLargeError;
|
|
24
|
+
class IOError extends Error {
|
|
25
|
+
constructor(message, cause) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = "IOError";
|
|
28
|
+
this.cause = cause;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.IOError = IOError;
|
|
32
|
+
/**
|
|
33
|
+
* Handler throws this on transient failures (network timeout, 5xx, 429).
|
|
34
|
+
* Worker leaves the snapshot on disk for later retry.
|
|
35
|
+
*/
|
|
36
|
+
class TransientError extends Error {
|
|
37
|
+
constructor(message) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.name = "TransientError";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.TransientError = TransientError;
|
|
43
|
+
/**
|
|
44
|
+
* Handler throws this on auth failures (401, 403, expired credential).
|
|
45
|
+
* Worker leaves the snapshot on disk and logs an operator-actionable error.
|
|
46
|
+
*/
|
|
47
|
+
class AuthError extends Error {
|
|
48
|
+
constructor(message) {
|
|
49
|
+
super(message);
|
|
50
|
+
this.name = "AuthError";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.AuthError = AuthError;
|
|
54
|
+
/**
|
|
55
|
+
* Handler's batch `dispatch()` throws this when the downstream rejected the
|
|
56
|
+
* batch but we don't know which line caused it — worker falls back to
|
|
57
|
+
* per-job `dispatchSingle()`.
|
|
58
|
+
*/
|
|
59
|
+
class BadRequestBatchError extends Error {
|
|
60
|
+
constructor(message) {
|
|
61
|
+
super(message);
|
|
62
|
+
this.name = "BadRequestBatchError";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.BadRequestBatchError = BadRequestBatchError;
|
|
66
|
+
/**
|
|
67
|
+
* Handler's `dispatchSingle()` throws this on a permanent per-job failure
|
|
68
|
+
* (400 for this specific job). Worker dead-letters the job and continues.
|
|
69
|
+
*/
|
|
70
|
+
class BadRequestError extends Error {
|
|
71
|
+
constructor(message) {
|
|
72
|
+
super(message);
|
|
73
|
+
this.name = "BadRequestError";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.BadRequestError = BadRequestError;
|
|
77
|
+
exports.MAX_LINE_BYTES = 4096;
|
|
78
|
+
exports.DEAD_LETTER_ROTATE_BYTES = 10 * 1024 * 1024;
|
|
79
|
+
exports.DEAD_LETTER_RETAIN_COUNT = 3;
|
|
80
|
+
exports.WORKER_LOG_ROTATE_BYTES = 10 * 1024 * 1024;
|
|
81
|
+
exports.WORKER_LOG_RETAIN_COUNT = 5;
|
|
82
|
+
exports.DEAD_LETTER_RAW_MAX = 512;
|
|
83
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/queue/types.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,MAAa,qBAAsB,SAAQ,KAAK;IAC5C,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACxC,CAAC;CACJ;AALD,sDAKC;AAED,MAAa,gBAAiB,SAAQ,KAAK;IAEvC,YAAY,SAAiB;QACzB,KAAK,CAAC,gCAAgC,SAAS,SAAS,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;CACJ;AAPD,4CAOC;AAED,MAAa,OAAQ,SAAQ,KAAK;IAE9B,YAAY,OAAe,EAAE,KAAe;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAPD,0BAOC;AAED;;;GAGG;AACH,MAAa,cAAe,SAAQ,KAAK;IACrC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IACjC,CAAC;CACJ;AALD,wCAKC;AAED;;;GAGG;AACH,MAAa,SAAU,SAAQ,KAAK;IAChC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC5B,CAAC;CACJ;AALD,8BAKC;AAED;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACvC,CAAC;CACJ;AALD,oDAKC;AAED;;;GAGG;AACH,MAAa,eAAgB,SAAQ,KAAK;IACtC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAClC,CAAC;CACJ;AALD,0CAKC;AA+BY,QAAA,cAAc,GAAW,IAAI,CAAC;AAC9B,QAAA,wBAAwB,GAAW,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AACpD,QAAA,wBAAwB,GAAW,CAAC,CAAC;AACrC,QAAA,uBAAuB,GAAW,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AACnD,QAAA,uBAAuB,GAAW,CAAC,CAAC;AACpC,QAAA,mBAAmB,GAAW,GAAG,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IronBee CLI — Worker Log + Rotation
|
|
3
|
+
*
|
|
4
|
+
* See docs/job-queue.md §8.1.
|
|
5
|
+
*/
|
|
6
|
+
export type WorkerLogLevel = "INFO" | "WARN" | "ERROR" | "DEBUG";
|
|
7
|
+
export declare class WorkerLog {
|
|
8
|
+
private readonly projectDir;
|
|
9
|
+
private readonly sessionId;
|
|
10
|
+
constructor(projectDir: string, sessionId: string);
|
|
11
|
+
info(msg: string): void;
|
|
12
|
+
warn(msg: string): void;
|
|
13
|
+
error(msg: string): void;
|
|
14
|
+
debug(msg: string): void;
|
|
15
|
+
private write;
|
|
16
|
+
private format;
|
|
17
|
+
private appendLine;
|
|
18
|
+
private rotateIfNeeded;
|
|
19
|
+
private enforceRetention;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=worker-log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-log.d.ts","sourceRoot":"","sources":["../../src/queue/worker-log.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuBH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAEjE,qBAAa,SAAS;IAClB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAK1C,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IACvB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IACvB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IACxB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAE/B,OAAO,CAAC,KAAK;IAUb,OAAO,CAAC,MAAM;IAqBd,OAAO,CAAC,UAAU;IAqBlB,OAAO,CAAC,cAAc;IA0BtB,OAAO,CAAC,gBAAgB;CAmC3B"}
|