@statewalker/ai-tasks 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +36 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/local.d.ts +4 -0
- package/dist/local.js +45 -0
- package/dist/local.js.map +1 -0
- package/dist/queue.d.ts +139 -0
- package/dist/queue.js +591 -0
- package/dist/queue.js.map +1 -0
- package/dist/runner.d.ts +26 -0
- package/dist/runner.js +96 -0
- package/dist/runner.js.map +1 -0
- package/dist/subjects.d.ts +9 -0
- package/dist/subjects.js +38 -0
- package/dist/subjects.js.map +1 -0
- package/dist/types.d.ts +194 -0
- package/package.json +41 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mikhail Kotelnikov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @statewalker/ai-tasks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## What it is
|
|
4
|
+
|
|
5
|
+
The task queue of the AI harness (statewalker/statewalker-root#160, built by #206): one queue per
|
|
6
|
+
project, where people, agents, webhooks and schedules publish tasks under subjects, and
|
|
7
|
+
subscriptions (filters on subject with NATS-style `*` and `>`, destination and sender) peek, take
|
|
8
|
+
or claim them with leases. A task is removed once every matching subscription has acked or taken
|
|
9
|
+
it, or when it expires; after `max_attempts` failed leases it goes to the subscription's dead
|
|
10
|
+
letters. A task with `reply_to` (an inbox of its sender) asks for a reply, which only a consumer
|
|
11
|
+
that took or claimed it may send. An `Executor` (`run(lease, {signal, progress})`) is served by
|
|
12
|
+
`serveSubscription`, which keeps the lease, logs progress in the job log and replies with a
|
|
13
|
+
reference to it.
|
|
14
|
+
|
|
15
|
+
The envelope and the API carry no harness types, so the contract can move to a lower layer
|
|
16
|
+
unchanged (statewalker/statewalker-root#204). `TaskQueue` is the implementation over SQLite (a
|
|
17
|
+
Durable Object's `SqlStorage`, or anything with its `exec` shape); rights, modes and limits are the
|
|
18
|
+
host's (`ai-host-do`'s Workspace DO).
|
|
19
|
+
|
|
20
|
+
Part of the AI harness (statewalker/statewalker-root#111): see the
|
|
21
|
+
[repository's README](https://github.com/statewalker/statewalker-ai#readme), its
|
|
22
|
+
[glossary](https://github.com/statewalker/statewalker-ai/blob/main/GLOSSARY.md) and its
|
|
23
|
+
[threat table](https://github.com/statewalker/statewalker-ai/blob/main/docs/security.md).
|
|
24
|
+
|
|
25
|
+
## How to use it
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm install @statewalker/ai-tasks
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { serveSubscription, TaskQueue, type TasksApi } from "@statewalker/ai-tasks";
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The harness is reached by clients through the session API of a running deployment (REST
|
|
36
|
+
`/v1/projects/{p}/tasks`, `/v1/projects/{p}/subscriptions`, `/v1/leases/{id}`, or RPC), not
|
|
37
|
+
through these packages; they are the deployment's parts.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { queueApi } from "./local.js";
|
|
2
|
+
import { DEFAULTS, QueueReader, SqlLike, TaskQueue, TaskQueueOptions, globMatches, taskError } from "./queue.js";
|
|
3
|
+
import { RunnerReply, ServeOptions, serveSubscription } from "./runner.js";
|
|
4
|
+
import { INBOX_PREFIX, isInbox, isPattern, isSubject, subjectMatches } from "./subjects.js";
|
|
5
|
+
import { Changed, ClaimOptions, DeadLetter, Executor, ExecutorContext, JobEntry, JobLog, Lease, ReadOptions, ReleaseOptions, RenewOptions, ReplyInput, Subscription, SubscriptionCounts, SubscriptionFilter, SubscriptionInput, Task, TaskInput, TasksApi } from "./types.js";
|
|
6
|
+
export { type Changed, type ClaimOptions, DEFAULTS, type DeadLetter, type Executor, type ExecutorContext, INBOX_PREFIX, type JobEntry, type JobLog, type Lease, QueueReader, type ReadOptions, type ReleaseOptions, type RenewOptions, type ReplyInput, RunnerReply, ServeOptions, SqlLike, type Subscription, type SubscriptionCounts, type SubscriptionFilter, type SubscriptionInput, type Task, type TaskInput, TaskQueue, TaskQueueOptions, type TasksApi, globMatches, isInbox, isPattern, isSubject, queueApi, serveSubscription, subjectMatches, taskError };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { queueApi } from "./local.js";
|
|
2
|
+
import { DEFAULTS, TaskQueue, globMatches, taskError } from "./queue.js";
|
|
3
|
+
import { serveSubscription } from "./runner.js";
|
|
4
|
+
import { INBOX_PREFIX, isInbox, isPattern, isSubject, subjectMatches } from "./subjects.js";
|
|
5
|
+
export { DEFAULTS, INBOX_PREFIX, TaskQueue, globMatches, isInbox, isPattern, isSubject, queueApi, serveSubscription, subjectMatches, taskError };
|
package/dist/local.d.ts
ADDED
package/dist/local.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/local.ts
|
|
2
|
+
const DEFAULT_WAIT_MS = 3e4;
|
|
3
|
+
const MAX_WAIT_MS = 6e4;
|
|
4
|
+
/** The task API of `reader` over `queue`; every call is the reader's. */
|
|
5
|
+
function queueApi(queue, reader) {
|
|
6
|
+
const run = async (f) => f();
|
|
7
|
+
return {
|
|
8
|
+
publish: (project, task) => run(() => queue.publish(project, task, reader.id)),
|
|
9
|
+
listTasks: (project, options) => run(() => ({ tasks: queue.listTasks(project, options) })),
|
|
10
|
+
subscribe: (project, sub) => run(() => queue.subscribe(project, sub, reader.id)),
|
|
11
|
+
listSubscriptions: (project) => run(() => ({ subscriptions: queue.listSubscriptions(project) })),
|
|
12
|
+
getSubscription: (project, name) => run(() => queue.getSubscription(project, name)),
|
|
13
|
+
unsubscribe: (project, name) => run(() => {
|
|
14
|
+
queue.unsubscribe(project, name);
|
|
15
|
+
return { deleted: true };
|
|
16
|
+
}),
|
|
17
|
+
peek: (project, name, options) => run(() => ({ tasks: queue.peek(project, name, reader, options) })),
|
|
18
|
+
take: (project, name, options) => run(() => ({ tasks: queue.take(project, name, reader, options) })),
|
|
19
|
+
claim: (project, name, options) => run(() => ({ leases: queue.claim(project, name, reader, options) })),
|
|
20
|
+
deadLetters: (project, name) => run(() => ({ dead_letters: queue.deadLetters(project, name) })),
|
|
21
|
+
async changes(project, name, options = {}) {
|
|
22
|
+
queue.getSubscription(project, name);
|
|
23
|
+
const wait = Math.min(Math.max(Number(options.wait_ms ?? DEFAULT_WAIT_MS), 0), MAX_WAIT_MS);
|
|
24
|
+
return { seq: await queue.waitChange(project, options.after, wait) };
|
|
25
|
+
},
|
|
26
|
+
createInbox: (project) => run(() => queue.createInbox(project, reader.id)),
|
|
27
|
+
reply: (project, task, reply) => run(() => queue.reply(project, task, reader.id, reply)),
|
|
28
|
+
ack: (lease) => run(() => {
|
|
29
|
+
queue.ack(lease, reader.id);
|
|
30
|
+
return { acked: true };
|
|
31
|
+
}),
|
|
32
|
+
release: (lease, options) => run(() => {
|
|
33
|
+
const { dead } = queue.release(lease, reader.id, options);
|
|
34
|
+
return {
|
|
35
|
+
released: true,
|
|
36
|
+
...dead ? { dead: true } : {}
|
|
37
|
+
};
|
|
38
|
+
}),
|
|
39
|
+
renew: (lease, options) => run(() => queue.renew(lease, reader.id, options)),
|
|
40
|
+
job: (project, id) => run(() => queue.job(project, id, reader.id))
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export { queueApi };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.js","names":[],"sources":["../src/local.ts"],"sourcesContent":["// The task API over a queue in the same process, for one reader: what tests and single-process\n// hosts use. It checks no rights: a host with rights wraps the queue itself.\nimport type { QueueReader, TaskQueue } from \"./queue.js\";\nimport type { TasksApi } from \"./types.js\";\n\nconst DEFAULT_WAIT_MS = 30_000;\nconst MAX_WAIT_MS = 60_000;\n\n/** The task API of `reader` over `queue`; every call is the reader's. */\nexport function queueApi(queue: TaskQueue, reader: QueueReader): TasksApi {\n const run = async <T>(f: () => T): Promise<T> => f();\n return {\n publish: (project, task) => run(() => queue.publish(project, task, reader.id)),\n listTasks: (project, options) => run(() => ({ tasks: queue.listTasks(project, options) })),\n subscribe: (project, sub) => run(() => queue.subscribe(project, sub, reader.id)),\n listSubscriptions: (project) =>\n run(() => ({ subscriptions: queue.listSubscriptions(project) })),\n getSubscription: (project, name) => run(() => queue.getSubscription(project, name)),\n unsubscribe: (project, name) =>\n run(() => {\n queue.unsubscribe(project, name);\n return { deleted: true as const };\n }),\n peek: (project, name, options) =>\n run(() => ({ tasks: queue.peek(project, name, reader, options) })),\n take: (project, name, options) =>\n run(() => ({ tasks: queue.take(project, name, reader, options) })),\n claim: (project, name, options) =>\n run(() => ({ leases: queue.claim(project, name, reader, options) })),\n deadLetters: (project, name) => run(() => ({ dead_letters: queue.deadLetters(project, name) })),\n async changes(project, name, options = {}) {\n queue.getSubscription(project, name);\n const wait = Math.min(Math.max(Number(options.wait_ms ?? DEFAULT_WAIT_MS), 0), MAX_WAIT_MS);\n return { seq: await queue.waitChange(project, options.after, wait) };\n },\n createInbox: (project) => run(() => queue.createInbox(project, reader.id)),\n reply: (project, task, reply) => run(() => queue.reply(project, task, reader.id, reply)),\n ack: (lease) =>\n run(() => {\n queue.ack(lease, reader.id);\n return { acked: true as const };\n }),\n release: (lease, options) =>\n run(() => {\n const { dead } = queue.release(lease, reader.id, options);\n return { released: true as const, ...(dead ? { dead: true as const } : {}) };\n }),\n renew: (lease, options) => run(() => queue.renew(lease, reader.id, options)),\n job: (project, id) => run(() => queue.job(project, id, reader.id)),\n };\n}\n"],"mappings":";AAKA,MAAM,kBAAkB;AACxB,MAAM,cAAc;;AAGpB,SAAgB,SAAS,OAAkB,QAA+B;CACxE,MAAM,MAAM,OAAU,MAA2B,EAAE;CACnD,OAAO;EACL,UAAU,SAAS,SAAS,UAAU,MAAM,QAAQ,SAAS,MAAM,OAAO,EAAE,CAAC;EAC7E,YAAY,SAAS,YAAY,WAAW,EAAE,OAAO,MAAM,UAAU,SAAS,OAAO,EAAE,EAAE;EACzF,YAAY,SAAS,QAAQ,UAAU,MAAM,UAAU,SAAS,KAAK,OAAO,EAAE,CAAC;EAC/E,oBAAoB,YAClB,WAAW,EAAE,eAAe,MAAM,kBAAkB,OAAO,EAAE,EAAE;EACjE,kBAAkB,SAAS,SAAS,UAAU,MAAM,gBAAgB,SAAS,IAAI,CAAC;EAClF,cAAc,SAAS,SACrB,UAAU;GACR,MAAM,YAAY,SAAS,IAAI;GAC/B,OAAO,EAAE,SAAS,KAAc;EAClC,CAAC;EACH,OAAO,SAAS,MAAM,YACpB,WAAW,EAAE,OAAO,MAAM,KAAK,SAAS,MAAM,QAAQ,OAAO,EAAE,EAAE;EACnE,OAAO,SAAS,MAAM,YACpB,WAAW,EAAE,OAAO,MAAM,KAAK,SAAS,MAAM,QAAQ,OAAO,EAAE,EAAE;EACnE,QAAQ,SAAS,MAAM,YACrB,WAAW,EAAE,QAAQ,MAAM,MAAM,SAAS,MAAM,QAAQ,OAAO,EAAE,EAAE;EACrE,cAAc,SAAS,SAAS,WAAW,EAAE,cAAc,MAAM,YAAY,SAAS,IAAI,EAAE,EAAE;EAC9F,MAAM,QAAQ,SAAS,MAAM,UAAU,CAAC,GAAG;GACzC,MAAM,gBAAgB,SAAS,IAAI;GACnC,MAAM,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,QAAQ,WAAW,eAAe,GAAG,CAAC,GAAG,WAAW;GAC1F,OAAO,EAAE,KAAK,MAAM,MAAM,WAAW,SAAS,QAAQ,OAAO,IAAI,EAAE;EACrE;EACA,cAAc,YAAY,UAAU,MAAM,YAAY,SAAS,OAAO,EAAE,CAAC;EACzE,QAAQ,SAAS,MAAM,UAAU,UAAU,MAAM,MAAM,SAAS,MAAM,OAAO,IAAI,KAAK,CAAC;EACvF,MAAM,UACJ,UAAU;GACR,MAAM,IAAI,OAAO,OAAO,EAAE;GAC1B,OAAO,EAAE,OAAO,KAAc;EAChC,CAAC;EACH,UAAU,OAAO,YACf,UAAU;GACR,MAAM,EAAE,SAAS,MAAM,QAAQ,OAAO,OAAO,IAAI,OAAO;GACxD,OAAO;IAAE,UAAU;IAAe,GAAI,OAAO,EAAE,MAAM,KAAc,IAAI,CAAC;GAAG;EAC7E,CAAC;EACH,QAAQ,OAAO,YAAY,UAAU,MAAM,MAAM,OAAO,OAAO,IAAI,OAAO,CAAC;EAC3E,MAAM,SAAS,OAAO,UAAU,MAAM,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;CACnE;AACF"}
|
package/dist/queue.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { DeadLetter, JobLog, Lease, Subscription, SubscriptionInput, Task, TaskInput } from "./types.js";
|
|
2
|
+
/** What the queue needs of SQLite: Durable Objects' `SqlStorage` has this shape. */
|
|
3
|
+
export interface SqlLike {
|
|
4
|
+
exec(query: string, ...bindings: unknown[]): {
|
|
5
|
+
toArray(): Record<string, unknown>[];
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export interface TaskQueueOptions {
|
|
9
|
+
now?: () => number;
|
|
10
|
+
newId?: () => string;
|
|
11
|
+
/** A payload's cap, as JSON in UTF-8: 64 KB. */
|
|
12
|
+
maxPayloadBytes?: number;
|
|
13
|
+
/** A task's life when the publisher names none: 7 days. */
|
|
14
|
+
defaultExpiryMs?: number;
|
|
15
|
+
/** The longest life a task may ask for: 30 days. */
|
|
16
|
+
maxExpiryMs?: number;
|
|
17
|
+
/** How long dead letters are kept: 14 days. */
|
|
18
|
+
deadLetterMs?: number;
|
|
19
|
+
/** Tasks a project holds at most (inboxes' included): 10,000. */
|
|
20
|
+
maxWaiting?: number;
|
|
21
|
+
/** A claim's lease when neither the claim nor the subscription names one: 5 minutes. */
|
|
22
|
+
defaultLeaseMs?: number;
|
|
23
|
+
defaultMaxAttempts?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Who reads: `id` is the principal leases and replies are held by, `destinations` the
|
|
27
|
+
* destinations it answers to, and `may` whether it may take a task of a subject now (the host's
|
|
28
|
+
* rights, checked for every task: one it may not take stays for others).
|
|
29
|
+
*/
|
|
30
|
+
export interface QueueReader {
|
|
31
|
+
id: string;
|
|
32
|
+
destinations: readonly string[];
|
|
33
|
+
may?: (subject: string) => boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare const DEFAULTS: {
|
|
36
|
+
readonly maxPayloadBytes: number;
|
|
37
|
+
readonly defaultExpiryMs: number;
|
|
38
|
+
readonly maxExpiryMs: number;
|
|
39
|
+
readonly deadLetterMs: number;
|
|
40
|
+
readonly maxWaiting: 10000;
|
|
41
|
+
readonly defaultLeaseMs: number;
|
|
42
|
+
readonly defaultMaxAttempts: 3;
|
|
43
|
+
};
|
|
44
|
+
/** An error whose message starts with its code, as the harness's errors do. */
|
|
45
|
+
export declare function taskError(code: string, message: string): Error & {
|
|
46
|
+
code: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Whether `text` matches `pattern`, where `*` is any run of characters: a linear two-pointer match
|
|
50
|
+
* (back to the last star on a mismatch), never a regular expression, so no filter can make a
|
|
51
|
+
* publish backtrack for ever.
|
|
52
|
+
*/
|
|
53
|
+
export declare function globMatches(pattern: string, text: string): boolean;
|
|
54
|
+
export declare class TaskQueue {
|
|
55
|
+
#private;
|
|
56
|
+
constructor(sql: SqlLike, options?: TaskQueueOptions);
|
|
57
|
+
/** The project's change counter: it grows whenever a subscription may have tasks to read. */
|
|
58
|
+
changeSeq(project: string): number;
|
|
59
|
+
/**
|
|
60
|
+
* Waits up to `waitMs` for the project's change counter to pass `after`: the current counter at
|
|
61
|
+
* once when it already has (or when `after` is undefined). In memory: one queue instance's
|
|
62
|
+
* waiters (a Durable Object's).
|
|
63
|
+
*/
|
|
64
|
+
waitChange(project: string, after: number | undefined, waitMs: number): Promise<number>;
|
|
65
|
+
/** Publishes a task from `sender`; an inbox's subject only through `reply`. */
|
|
66
|
+
publish(project: string, input: TaskInput, sender: string): Task;
|
|
67
|
+
/** Tasks the project holds now (those waiting for an inbox included). */
|
|
68
|
+
waitingCount(project: string): number;
|
|
69
|
+
/** The bytes the project's queue holds: waiting tasks' and dead letters' payloads. */
|
|
70
|
+
bytes(project: string): number;
|
|
71
|
+
/** The project's waiting tasks, oldest first. */
|
|
72
|
+
listTasks(project: string, options?: {
|
|
73
|
+
limit?: number;
|
|
74
|
+
}): Task[];
|
|
75
|
+
/** Creates a subscription owned by `owner`; it receives the matching tasks still waiting. */
|
|
76
|
+
subscribe(project: string, input: SubscriptionInput, owner: string): Subscription;
|
|
77
|
+
/** A new reply inbox of `owner`'s: a subscription named by its subject, read only by it. */
|
|
78
|
+
createInbox(project: string, owner: string): Subscription;
|
|
79
|
+
/** The project's subscriptions (inboxes left out unless `inboxes`), with their counts. */
|
|
80
|
+
listSubscriptions(project: string, options?: {
|
|
81
|
+
inboxes?: boolean;
|
|
82
|
+
}): Subscription[];
|
|
83
|
+
/** One subscription with its counts; ENOENT when there is none. */
|
|
84
|
+
getSubscription(project: string, name: string): Subscription;
|
|
85
|
+
/** Deletes a subscription: what waited for it is done for it, its dead letters dropped. */
|
|
86
|
+
unsubscribe(project: string, name: string): void;
|
|
87
|
+
/** Tasks waiting for the subscription that the reader may take, left in place. */
|
|
88
|
+
peek(project: string, name: string, reader: QueueReader, options?: {
|
|
89
|
+
limit?: number;
|
|
90
|
+
}): Task[];
|
|
91
|
+
/** Takes tasks: each is done for the subscription as it is read. */
|
|
92
|
+
take(project: string, name: string, reader: QueueReader, options?: {
|
|
93
|
+
limit?: number;
|
|
94
|
+
}): Task[];
|
|
95
|
+
/** Leases tasks to the reader: each is its until acked, released, or the lease runs out. */
|
|
96
|
+
claim(project: string, name: string, reader: QueueReader, options?: {
|
|
97
|
+
limit?: number;
|
|
98
|
+
lease_ms?: number;
|
|
99
|
+
}): Lease[];
|
|
100
|
+
/** Done: the task is done for the lease's subscription. */
|
|
101
|
+
ack(id: string, holder: string): void;
|
|
102
|
+
/** Not done: the task waits again, or goes to the dead letters once its attempts are used up. */
|
|
103
|
+
release(id: string, holder: string, options?: {
|
|
104
|
+
reason?: string;
|
|
105
|
+
}): {
|
|
106
|
+
dead: boolean;
|
|
107
|
+
};
|
|
108
|
+
/** Extends a live lease (by the subscription's lease, or `lease_ms`), logging progress. */
|
|
109
|
+
renew(id: string, holder: string, options?: {
|
|
110
|
+
lease_ms?: number;
|
|
111
|
+
progress?: unknown;
|
|
112
|
+
}): Lease;
|
|
113
|
+
/** A subscription's dead letters, oldest first. */
|
|
114
|
+
deadLetters(project: string, name: string): DeadLetter[];
|
|
115
|
+
/**
|
|
116
|
+
* Replies to a task `holder` took or claimed, once: a task in its `reply_to` inbox with its
|
|
117
|
+
* correlation id, sent by `holder`.
|
|
118
|
+
*/
|
|
119
|
+
reply(project: string, taskId: string, holder: string, input: {
|
|
120
|
+
payload?: unknown;
|
|
121
|
+
}): Task;
|
|
122
|
+
/** A job log, for its lease's holder and its task's sender; ENOENT for anyone else. */
|
|
123
|
+
job(project: string, id: string, reader: string): JobLog;
|
|
124
|
+
/** The project of a lease (live or not yet swept); undefined for an unknown one. */
|
|
125
|
+
leaseProject(id: string): string | undefined;
|
|
126
|
+
/** An inbox of `owner`'s in the project, if it has one (the oldest). */
|
|
127
|
+
inboxOf(project: string, owner: string): Subscription | undefined;
|
|
128
|
+
/** Where `holder`'s reply to a task would go; EACCES unless it took or claimed the task. */
|
|
129
|
+
replyTo(project: string, taskId: string, holder: string): string;
|
|
130
|
+
/** Forgets a project's queue: its tasks, subscriptions, dead letters and job logs. */
|
|
131
|
+
dropProject(project: string): void;
|
|
132
|
+
/** Expires what is due in a project: tasks, leases, dead letters, job logs. */
|
|
133
|
+
sweep(project: string): void;
|
|
134
|
+
/** The projects with something due by now (for an alarm's sweep). */
|
|
135
|
+
dueProjects(): string[];
|
|
136
|
+
/** When the next task, lease or dead letter is due, across projects (undefined: none). */
|
|
137
|
+
nextDue(): number | undefined;
|
|
138
|
+
}
|
|
139
|
+
export type { DeadLetter, JobLog, Lease };
|