@backendkit-labs/agent-flow-queue 0.0.0-stage → 0.1.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/README.md +53 -3
- package/dist/index.d.ts +60 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +116 -0
- package/dist/index.js.map +1 -0
- package/dist/redis-journal.d.ts +34 -0
- package/dist/redis-journal.d.ts.map +1 -0
- package/dist/redis-journal.js +101 -0
- package/dist/redis-journal.js.map +1 -0
- package/package.json +50 -6
package/README.md
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# @backendkit-labs/agent-flow-queue
|
|
2
|
+
|
|
3
|
+
Run [`agent-core` flows](../core/README.md#flows--declarative-and-durable) across processes: a BullMQ `StepExecutor` (each step runs on a worker, maybe on another machine) and a Redis `RunJournal` (a run survives the process and any process can resume it).
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @backendkit-labs/agent-flow-queue @backendkit-labs/agent-core
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Needs a Redis. The flow engine stays in one process; only the steps travel.
|
|
10
|
+
|
|
11
|
+
## Run steps on workers
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// orchestrator process
|
|
15
|
+
import { loadFlow, runFlow } from '@backendkit-labs/agent-core';
|
|
16
|
+
import { QueueStepExecutor } from '@backendkit-labs/agent-flow-queue';
|
|
17
|
+
|
|
18
|
+
const executor = new QueueStepExecutor({ redis: process.env.REDIS_URL!, timeoutMs: 15 * 60_000 });
|
|
19
|
+
const result = await runFlow(await loadFlow('flows/close-month.yaml'), { executor, payload: { month: '2026-10' } });
|
|
20
|
+
await executor.close();
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// worker process: one queue `flow.<agent>` each, `concurrency` steps at a time
|
|
25
|
+
import { createStepWorker } from '@backendkit-labs/agent-flow-queue';
|
|
26
|
+
|
|
27
|
+
const workers = createStepWorker({
|
|
28
|
+
redis: process.env.REDIS_URL!,
|
|
29
|
+
agents: ['sales', 'finance'],
|
|
30
|
+
concurrency: 4,
|
|
31
|
+
executor: { run: async (step, input) => ({ content: await localAgent(step.agent).run(input.prompt) }) },
|
|
32
|
+
});
|
|
33
|
+
// on shutdown: await workers.close();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- **At least once.** The job id is the step's idempotency key (`runId:stepId:attempt`), so enqueuing the same step twice is one job. A step with an external effect (payment, email) must use `input.idempotencyKey` in the worker too.
|
|
37
|
+
- **Retries belong to the engine.** `attempts` is 1 by default; BullMQ retries of the same job keep the same key.
|
|
38
|
+
- **Cancel.** Aborting the run removes a step no worker has taken yet; one already running finishes (the worker's signal never aborts).
|
|
39
|
+
- **Deadline.** `timeoutMs` (default 900 s) per step; on expiry the step fails and the flow handles it like any failed step.
|
|
40
|
+
- **Names.** `prefix` (default `flow`) lets several environments share a Redis.
|
|
41
|
+
|
|
42
|
+
## A run that survives the process
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { RedisRunJournal } from '@backendkit-labs/agent-flow-queue';
|
|
46
|
+
|
|
47
|
+
const journal = new RedisRunJournal({ redis: process.env.REDIS_URL!, prefix: 'flow' });
|
|
48
|
+
await runFlow(flow, { executor, journal, runId: 'close-2026-10', payload }); // run again with the same runId to resume
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
One Lua script per mutation makes "create only if absent", "append only if it exists" and "take the claim only if free or mine" atomic. The claim expires by Redis TTL, and releasing with an old token never frees a renewed claim. Logs do not expire on their own: delete finished runs with your own retention job.
|
|
52
|
+
|
|
53
|
+
> The scripts are covered by a contract suite that runs against a real Redis when `localhost:6379` answers (`REDIS_HOST`, `REDIS_PORT`) and against an in-memory stand-in otherwise.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Redis as IORedis } from 'ioredis';
|
|
2
|
+
import type { FlowStep, StepExecutor, StepInput, StepOutput } from '@backendkit-labs/agent-core';
|
|
3
|
+
export { RedisRunJournal } from './redis-journal';
|
|
4
|
+
export type { RedisRunJournalOptions } from './redis-journal';
|
|
5
|
+
/**
|
|
6
|
+
* BullMQ adapter for `StepExecutor` (SPEC-0023 D5). The flow engine stays in one process; each step travels through a
|
|
7
|
+
* queue `<prefix>.<agent>` to a worker, possibly on another machine. Semantics are at-least-once: the job id is the
|
|
8
|
+
* step's idempotency key (`runId:stepId:attempt`), so a step enqueued twice is one job, and a step with an external
|
|
9
|
+
* effect must use `input.idempotencyKey` in the worker too.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_QUEUE_PREFIX = "flow";
|
|
12
|
+
/** How long the executor waits for a worker to finish one step. */
|
|
13
|
+
export declare const DEFAULT_STEP_TIMEOUT_MS = 900000;
|
|
14
|
+
export interface StepJobData {
|
|
15
|
+
step: FlowStep;
|
|
16
|
+
prompt: string;
|
|
17
|
+
context?: string;
|
|
18
|
+
idempotencyKey: string;
|
|
19
|
+
}
|
|
20
|
+
export type RedisConnection = string | IORedis;
|
|
21
|
+
export interface QueueStepExecutorOptions {
|
|
22
|
+
/** Redis URL or an ioredis instance (with `maxRetriesPerRequest: null`). A URL is owned and closed by `close()`. */
|
|
23
|
+
redis: RedisConnection;
|
|
24
|
+
/** Queue name prefix. Default `flow`. */
|
|
25
|
+
prefix?: string;
|
|
26
|
+
/** Wait for a worker per step; on expiry the step fails. Default 900 000. */
|
|
27
|
+
timeoutMs?: number;
|
|
28
|
+
/** BullMQ retries of the same job (same idempotency key). Default 1: no retry, the engine owns retries. */
|
|
29
|
+
attempts?: number;
|
|
30
|
+
}
|
|
31
|
+
export declare function queueName(prefix: string, agentId: string): string;
|
|
32
|
+
export declare class QueueStepExecutor implements StepExecutor {
|
|
33
|
+
private readonly connection;
|
|
34
|
+
private readonly owned;
|
|
35
|
+
private readonly prefix;
|
|
36
|
+
private readonly timeoutMs;
|
|
37
|
+
private readonly attempts;
|
|
38
|
+
private readonly queues;
|
|
39
|
+
constructor(opts: QueueStepExecutorOptions);
|
|
40
|
+
private ensure;
|
|
41
|
+
run(step: FlowStep, input: StepInput): Promise<StepOutput>;
|
|
42
|
+
close(): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
export interface StepWorkerOptions {
|
|
45
|
+
redis: RedisConnection;
|
|
46
|
+
/** Agent ids this process serves, one queue each. */
|
|
47
|
+
agents: string[];
|
|
48
|
+
/** Runs a step in this process (a local agent executor). A throw fails the job and so the step. */
|
|
49
|
+
executor: StepExecutor;
|
|
50
|
+
prefix?: string;
|
|
51
|
+
/** Steps at the same time per agent. Default 4. */
|
|
52
|
+
concurrency?: number;
|
|
53
|
+
onError?: (agentId: string, err: Error) => void;
|
|
54
|
+
}
|
|
55
|
+
export interface StepWorkers {
|
|
56
|
+
close(): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/** Serves `agents` queues with `executor`. The worker-side signal never aborts: a job runs to its end once taken. */
|
|
59
|
+
export declare function createStepWorker(opts: StepWorkerOptions): StepWorkers;
|
|
60
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEjG,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,YAAY,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;;;;GAKG;AAEH,eAAO,MAAM,oBAAoB,SAAS,CAAC;AAC3C,mEAAmE;AACnE,eAAO,MAAM,uBAAuB,SAAU,CAAC;AAE/C,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,QA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AC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;CACnD;AAED,MAAM,WAAW,WAAW;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,qHAAqH;AACrH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,GAAG,WAAW,CAuBrE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueueStepExecutor = exports.DEFAULT_STEP_TIMEOUT_MS = exports.DEFAULT_QUEUE_PREFIX = exports.RedisRunJournal = void 0;
|
|
4
|
+
exports.queueName = queueName;
|
|
5
|
+
exports.createStepWorker = createStepWorker;
|
|
6
|
+
const bullmq_1 = require("bullmq");
|
|
7
|
+
const ioredis_1 = require("ioredis");
|
|
8
|
+
var redis_journal_1 = require("./redis-journal");
|
|
9
|
+
Object.defineProperty(exports, "RedisRunJournal", { enumerable: true, get: function () { return redis_journal_1.RedisRunJournal; } });
|
|
10
|
+
/**
|
|
11
|
+
* BullMQ adapter for `StepExecutor` (SPEC-0023 D5). The flow engine stays in one process; each step travels through a
|
|
12
|
+
* queue `<prefix>.<agent>` to a worker, possibly on another machine. Semantics are at-least-once: the job id is the
|
|
13
|
+
* step's idempotency key (`runId:stepId:attempt`), so a step enqueued twice is one job, and a step with an external
|
|
14
|
+
* effect must use `input.idempotencyKey` in the worker too.
|
|
15
|
+
*/
|
|
16
|
+
exports.DEFAULT_QUEUE_PREFIX = 'flow';
|
|
17
|
+
/** How long the executor waits for a worker to finish one step. */
|
|
18
|
+
exports.DEFAULT_STEP_TIMEOUT_MS = 900_000;
|
|
19
|
+
function connect(redis) {
|
|
20
|
+
return typeof redis === 'string'
|
|
21
|
+
? { connection: new ioredis_1.Redis(redis, { maxRetriesPerRequest: null }), owned: true }
|
|
22
|
+
: { connection: redis, owned: false };
|
|
23
|
+
}
|
|
24
|
+
function queueName(prefix, agentId) {
|
|
25
|
+
return `${prefix}.${agentId}`;
|
|
26
|
+
}
|
|
27
|
+
class QueueStepExecutor {
|
|
28
|
+
connection;
|
|
29
|
+
owned;
|
|
30
|
+
prefix;
|
|
31
|
+
timeoutMs;
|
|
32
|
+
attempts;
|
|
33
|
+
queues = new Map();
|
|
34
|
+
constructor(opts) {
|
|
35
|
+
const c = connect(opts.redis);
|
|
36
|
+
this.connection = c.connection;
|
|
37
|
+
this.owned = c.owned;
|
|
38
|
+
this.prefix = opts.prefix ?? exports.DEFAULT_QUEUE_PREFIX;
|
|
39
|
+
this.timeoutMs = opts.timeoutMs ?? exports.DEFAULT_STEP_TIMEOUT_MS;
|
|
40
|
+
this.attempts = opts.attempts ?? 1;
|
|
41
|
+
}
|
|
42
|
+
ensure(agentId) {
|
|
43
|
+
let entry = this.queues.get(agentId);
|
|
44
|
+
if (!entry) {
|
|
45
|
+
const name = queueName(this.prefix, agentId);
|
|
46
|
+
entry = {
|
|
47
|
+
queue: new bullmq_1.Queue(name, { connection: this.connection }),
|
|
48
|
+
events: new bullmq_1.QueueEvents(name, { connection: this.connection }),
|
|
49
|
+
};
|
|
50
|
+
this.queues.set(agentId, entry);
|
|
51
|
+
}
|
|
52
|
+
return entry;
|
|
53
|
+
}
|
|
54
|
+
async run(step, input) {
|
|
55
|
+
if (input.signal.aborted)
|
|
56
|
+
throw new Error('step cancelled before it was queued');
|
|
57
|
+
const { queue, events } = this.ensure(step.agent);
|
|
58
|
+
const job = await queue.add('run', {
|
|
59
|
+
step,
|
|
60
|
+
prompt: input.prompt,
|
|
61
|
+
context: input.context,
|
|
62
|
+
idempotencyKey: input.idempotencyKey,
|
|
63
|
+
}, {
|
|
64
|
+
jobId: input.idempotencyKey.replace(/:/g, '_'),
|
|
65
|
+
attempts: this.attempts,
|
|
66
|
+
removeOnComplete: 100,
|
|
67
|
+
removeOnFail: 50,
|
|
68
|
+
});
|
|
69
|
+
// A cancelled run must not leave its step waiting for a worker: drop it if no worker took it yet.
|
|
70
|
+
let onAbort;
|
|
71
|
+
const aborted = new Promise((_, reject) => {
|
|
72
|
+
onAbort = () => {
|
|
73
|
+
job.remove().catch(() => undefined);
|
|
74
|
+
reject(new Error('step cancelled'));
|
|
75
|
+
};
|
|
76
|
+
input.signal.addEventListener('abort', onAbort, { once: true });
|
|
77
|
+
});
|
|
78
|
+
try {
|
|
79
|
+
return await Promise.race([job.waitUntilFinished(events, this.timeoutMs), aborted]);
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
if (onAbort)
|
|
83
|
+
input.signal.removeEventListener('abort', onAbort);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async close() {
|
|
87
|
+
await Promise.all([...this.queues.values()].flatMap(e => [e.queue.close(), e.events.close()]));
|
|
88
|
+
this.queues.clear();
|
|
89
|
+
if (this.owned)
|
|
90
|
+
this.connection.disconnect();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.QueueStepExecutor = QueueStepExecutor;
|
|
94
|
+
/** Serves `agents` queues with `executor`. The worker-side signal never aborts: a job runs to its end once taken. */
|
|
95
|
+
function createStepWorker(opts) {
|
|
96
|
+
const { connection, owned } = connect(opts.redis);
|
|
97
|
+
const prefix = opts.prefix ?? exports.DEFAULT_QUEUE_PREFIX;
|
|
98
|
+
const workers = opts.agents.map(agentId => {
|
|
99
|
+
const worker = new bullmq_1.Worker(queueName(prefix, agentId), job => opts.executor.run(job.data.step, {
|
|
100
|
+
prompt: job.data.prompt,
|
|
101
|
+
context: job.data.context,
|
|
102
|
+
idempotencyKey: job.data.idempotencyKey,
|
|
103
|
+
signal: new AbortController().signal,
|
|
104
|
+
}), { connection, concurrency: opts.concurrency ?? 4 });
|
|
105
|
+
worker.on('error', err => opts.onError?.(agentId, err));
|
|
106
|
+
return worker;
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
async close() {
|
|
110
|
+
await Promise.all(workers.map(w => w.close()));
|
|
111
|
+
if (owned)
|
|
112
|
+
connection.disconnect();
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA4CA,8BAEC;AAuFD,4CAuBC;AA5JD,mCAAoD;AACpD,qCAA2C;AAG3C,iDAAkD;AAAzC,gHAAA,eAAe,OAAA;AAGxB;;;;;GAKG;AAEU,QAAA,oBAAoB,GAAG,MAAM,CAAC;AAC3C,mEAAmE;AACtD,QAAA,uBAAuB,GAAG,OAAO,CAAC;AAsB/C,SAAS,OAAO,CAAC,KAAsB;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ;QAC5B,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,eAAO,CAAC,KAAK,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE;QACjF,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC9C,CAAC;AAED,SAAgB,SAAS,CAAC,MAAc,EAAE,OAAe;IACrD,OAAO,GAAG,MAAM,IAAI,OAAO,EAAE,CAAC;AAClC,CAAC;AAED,MAAa,iBAAiB;IACT,UAAU,CAAU;IACpB,KAAK,CAAU;IACf,MAAM,CAAS;IACf,SAAS,CAAS;IAClB,QAAQ,CAAS;IACjB,MAAM,GAAG,IAAI,GAAG,EAA0E,CAAC;IAE5G,YAAY,IAA8B;QACtC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAA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ACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { JournalRun, JournalRunStatus, NewJournalRun, RunJournal, RunPatch, StepPatch } from '@backendkit-labs/agent-core';
|
|
2
|
+
import { Redis as IORedis } from 'ioredis';
|
|
3
|
+
export declare const BEGIN_SCRIPT = "\nif redis.call('EXISTS', KEYS[1]) == 1 then return 0 end\nredis.call('RPUSH', KEYS[1], ARGV[2])\nredis.call('SADD', KEYS[2], ARGV[1])\nreturn 1";
|
|
4
|
+
export declare const APPEND_SCRIPT = "\nif redis.call('EXISTS', KEYS[1]) == 0 then return 0 end\nredis.call('RPUSH', KEYS[1], ARGV[1])\nreturn 1";
|
|
5
|
+
export declare const CLAIM_SCRIPT = "\nlocal cur = redis.call('GET', KEYS[1])\nif cur and string.sub(cur, 1, #ARGV[1] + 1) ~= ARGV[1] .. '\\n' then return 0 end\nredis.call('SET', KEYS[1], ARGV[1] .. '\\n' .. ARGV[2], 'PX', ARGV[3])\nreturn 1";
|
|
6
|
+
export declare const RELEASE_SCRIPT = "\nif redis.call('GET', KEYS[1]) == ARGV[1] then return redis.call('DEL', KEYS[1]) end\nreturn 0";
|
|
7
|
+
export interface RedisRunJournalOptions {
|
|
8
|
+
/** Redis URL or an ioredis instance. A URL is owned and closed by `close()`. */
|
|
9
|
+
redis: string | IORedis;
|
|
10
|
+
/** Key prefix. Default `flow`. */
|
|
11
|
+
prefix?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class RedisRunJournal implements RunJournal {
|
|
14
|
+
private readonly redis;
|
|
15
|
+
private readonly owned;
|
|
16
|
+
private readonly prefix;
|
|
17
|
+
constructor(opts: RedisRunJournalOptions);
|
|
18
|
+
begin(run: NewJournalRun): Promise<void>;
|
|
19
|
+
step(runId: string, stepId: string, patch: StepPatch): Promise<void>;
|
|
20
|
+
update(runId: string, patch: RunPatch): Promise<void>;
|
|
21
|
+
claim(runId: string, owner: string, ttlMs: number): Promise<(() => Promise<void>) | null>;
|
|
22
|
+
get(runId: string): Promise<JournalRun | undefined>;
|
|
23
|
+
list(filter?: {
|
|
24
|
+
status?: JournalRunStatus[];
|
|
25
|
+
flow?: string;
|
|
26
|
+
tenantId?: string;
|
|
27
|
+
}): Promise<JournalRun[]>;
|
|
28
|
+
close(): Promise<void>;
|
|
29
|
+
private append;
|
|
30
|
+
private checkId;
|
|
31
|
+
private logKey;
|
|
32
|
+
private claimKey;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=redis-journal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-journal.d.ts","sourceRoot":"","sources":["../src/redis-journal.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACM,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAC7F,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AAgB3C,eAAO,MAAM,YAAY,qJAIhB,CAAC;AAEV,eAAO,MAAM,aAAa,+GAGjB,CAAC;AAEV,eAAO,MAAM,YAAY,kNAIhB,CAAC;AAEV,eAAO,MAAM,cAAc,oGAElB,CAAC;AAEV,MAAM,WAAW,sBAAsB;IACnC,gFAAgF;IAChF,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IACxB,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,eAAgB,YAAW,UAAU;IAC9C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,IAAI,EAAE,sBAAsB;IAMlC,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAOxC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;IAUzF,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAMnD,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAUvG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAId,MAAM;IAMpB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,QAAQ;CACnB"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisRunJournal = exports.RELEASE_SCRIPT = exports.CLAIM_SCRIPT = exports.APPEND_SCRIPT = exports.BEGIN_SCRIPT = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const agent_core_1 = require("@backendkit-labs/agent-core");
|
|
6
|
+
const ioredis_1 = require("ioredis");
|
|
7
|
+
/**
|
|
8
|
+
* `RunJournal` on Redis (SPEC-0023): the same event log the file and memory journals keep, so a run survives the process
|
|
9
|
+
* and any process sharing the Redis can resume it.
|
|
10
|
+
*
|
|
11
|
+
* - `<prefix>:run:<id>:log`: a list with one JSON event per entry, append-only; the run is rebuilt by folding them.
|
|
12
|
+
* - `<prefix>:run:<id>:claim`: `owner\ntoken` with a TTL (`SET PX`): one owner per run, expiry is Redis's own.
|
|
13
|
+
* - `<prefix>:runs`: the set of run ids, for `list`.
|
|
14
|
+
*
|
|
15
|
+
* Each mutation is one Lua script, so "create only if absent", "append only if it exists" and "take the claim only if free or
|
|
16
|
+
* mine" are atomic. Nothing expires on its own except claims: delete finished runs with your own retention job.
|
|
17
|
+
*/
|
|
18
|
+
const ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
|
|
19
|
+
exports.BEGIN_SCRIPT = `
|
|
20
|
+
if redis.call('EXISTS', KEYS[1]) == 1 then return 0 end
|
|
21
|
+
redis.call('RPUSH', KEYS[1], ARGV[2])
|
|
22
|
+
redis.call('SADD', KEYS[2], ARGV[1])
|
|
23
|
+
return 1`;
|
|
24
|
+
exports.APPEND_SCRIPT = `
|
|
25
|
+
if redis.call('EXISTS', KEYS[1]) == 0 then return 0 end
|
|
26
|
+
redis.call('RPUSH', KEYS[1], ARGV[1])
|
|
27
|
+
return 1`;
|
|
28
|
+
exports.CLAIM_SCRIPT = `
|
|
29
|
+
local cur = redis.call('GET', KEYS[1])
|
|
30
|
+
if cur and string.sub(cur, 1, #ARGV[1] + 1) ~= ARGV[1] .. '\\n' then return 0 end
|
|
31
|
+
redis.call('SET', KEYS[1], ARGV[1] .. '\\n' .. ARGV[2], 'PX', ARGV[3])
|
|
32
|
+
return 1`;
|
|
33
|
+
exports.RELEASE_SCRIPT = `
|
|
34
|
+
if redis.call('GET', KEYS[1]) == ARGV[1] then return redis.call('DEL', KEYS[1]) end
|
|
35
|
+
return 0`;
|
|
36
|
+
class RedisRunJournal {
|
|
37
|
+
redis;
|
|
38
|
+
owned;
|
|
39
|
+
prefix;
|
|
40
|
+
constructor(opts) {
|
|
41
|
+
this.owned = typeof opts.redis === 'string';
|
|
42
|
+
this.redis = typeof opts.redis === 'string' ? new ioredis_1.Redis(opts.redis) : opts.redis;
|
|
43
|
+
this.prefix = opts.prefix ?? 'flow';
|
|
44
|
+
}
|
|
45
|
+
async begin(run) {
|
|
46
|
+
this.checkId(run.runId);
|
|
47
|
+
const ev = { kind: 'begin', at: new Date().toISOString(), run };
|
|
48
|
+
const ok = await this.redis.eval(exports.BEGIN_SCRIPT, 2, this.logKey(run.runId), `${this.prefix}:runs`, run.runId, JSON.stringify(ev));
|
|
49
|
+
if (ok !== 1)
|
|
50
|
+
throw new Error(`run "${run.runId}" already exists`);
|
|
51
|
+
}
|
|
52
|
+
async step(runId, stepId, patch) {
|
|
53
|
+
await this.append(runId, { kind: 'step', at: new Date().toISOString(), stepId, patch });
|
|
54
|
+
}
|
|
55
|
+
async update(runId, patch) {
|
|
56
|
+
await this.append(runId, { kind: 'update', at: new Date().toISOString(), patch });
|
|
57
|
+
}
|
|
58
|
+
async claim(runId, owner, ttlMs) {
|
|
59
|
+
this.checkId(runId);
|
|
60
|
+
const token = (0, node_crypto_1.randomBytes)(8).toString('hex');
|
|
61
|
+
const ok = await this.redis.eval(exports.CLAIM_SCRIPT, 1, this.claimKey(runId), owner, token, String(Math.max(1, Math.ceil(ttlMs))));
|
|
62
|
+
if (ok !== 1)
|
|
63
|
+
return null;
|
|
64
|
+
return async () => {
|
|
65
|
+
await this.redis.eval(exports.RELEASE_SCRIPT, 1, this.claimKey(runId), `${owner}\n${token}`);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
async get(runId) {
|
|
69
|
+
this.checkId(runId);
|
|
70
|
+
const raw = await this.redis.lrange(this.logKey(runId), 0, -1);
|
|
71
|
+
return (0, agent_core_1.foldEvents)(raw.map(r => JSON.parse(r)));
|
|
72
|
+
}
|
|
73
|
+
async list(filter) {
|
|
74
|
+
const ids = await this.redis.smembers(`${this.prefix}:runs`);
|
|
75
|
+
const out = [];
|
|
76
|
+
for (const id of ids) {
|
|
77
|
+
const r = await this.get(id);
|
|
78
|
+
if (r && (0, agent_core_1.journalMatches)(r, filter))
|
|
79
|
+
out.push(r);
|
|
80
|
+
}
|
|
81
|
+
return out.sort((a, b) => a.startedAt.localeCompare(b.startedAt));
|
|
82
|
+
}
|
|
83
|
+
async close() {
|
|
84
|
+
if (this.owned)
|
|
85
|
+
this.redis.disconnect();
|
|
86
|
+
}
|
|
87
|
+
async append(runId, ev) {
|
|
88
|
+
this.checkId(runId);
|
|
89
|
+
const ok = await this.redis.eval(exports.APPEND_SCRIPT, 1, this.logKey(runId), JSON.stringify(ev));
|
|
90
|
+
if (ok !== 1)
|
|
91
|
+
throw new Error(`run "${runId}" does not exist`);
|
|
92
|
+
}
|
|
93
|
+
checkId(id) {
|
|
94
|
+
if (!ID.test(id))
|
|
95
|
+
throw new Error(`invalid run id "${id}"`);
|
|
96
|
+
}
|
|
97
|
+
logKey(runId) { return `${this.prefix}:run:${runId}:log`; }
|
|
98
|
+
claimKey(runId) { return `${this.prefix}:run:${runId}:claim`; }
|
|
99
|
+
}
|
|
100
|
+
exports.RedisRunJournal = RedisRunJournal;
|
|
101
|
+
//# sourceMappingURL=redis-journal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-journal.js","sourceRoot":"","sources":["../src/redis-journal.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAC1C,4DAAyE;AAIzE,qCAA2C;AAE3C;;;;;;;;;;GAUG;AAEH,MAAM,EAAE,GAAG,mCAAmC,CAAC;AAElC,QAAA,YAAY,GAAG;;;;SAInB,CAAC;AAEG,QAAA,aAAa,GAAG;;;SAGpB,CAAC;AAEG,QAAA,YAAY,GAAG;;;;SAInB,CAAC;AAEG,QAAA,cAAc,GAAG;;SAErB,CAAC;AASV,MAAa,eAAe;IACP,KAAK,CAAU;IACf,KAAK,CAAU;IACf,MAAM,CAAS;IAEhC,YAAY,IAA4B;QACpC,IAAI,CAAC,KAAK,GAAG,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC;QAC5C,IAAI,CAAC,KAAK,GAAG,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,C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3E,QAAQ,CAAC,KAAa,IAAY,OAAO,GAAG,IAAI,CAAC,MAAM,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC;CAC1F;AApED,0CAoEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@backendkit-labs/agent-flow-queue",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@backendkit-labs/agent-flow-queue",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "BullMQ StepExecutor for @backendkit-labs/agent-core flows: run each step on a worker in another process",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist/",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"dev": "tsc --watch",
|
|
20
|
+
"typecheck": "tsc --noEmit",
|
|
21
|
+
"prepublishOnly": "npm run build",
|
|
22
|
+
"test": "jest"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"bullmq": "^5.0.0",
|
|
26
|
+
"ioredis": "^5.0.0"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@backendkit-labs/agent-core": ">=0.42.0 <0.45.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/jest": "^29.0.0",
|
|
33
|
+
"@types/node": "^20.0.0",
|
|
34
|
+
"jest": "^29.0.0",
|
|
35
|
+
"ts-jest": "^29.0.0",
|
|
36
|
+
"typescript": "^5.4.0"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=20.0.0"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/BackendKit-labs/backendkit-agent-framework.git",
|
|
44
|
+
"directory": "packages/flow-queue"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"license": "MIT"
|
|
50
|
+
}
|