@hiai-gg/docsmint 0.4.2 → 0.4.4
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/dist/backend/index.js +146 -22
- package/dist/backend-pipeline-cancellation.d.ts +11 -0
- package/dist/backend-pipeline-cancellation.js +2669 -0
- package/dist/lifecycle-runtime.d.ts +35 -0
- package/dist/lifecycle-runtime.js +811 -0
- package/dist/pipeline-cancellation.d.ts +21 -0
- package/dist/pipeline-cancellation.js +34 -0
- package/package.json +21 -2
- package/packages/cli/src/index.ts +1 -1
- package/packages/mcp-server/src/index.ts +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type CancellablePipelineJob = Readonly<{
|
|
2
|
+
data?: Readonly<{
|
|
3
|
+
ownerId?: string;
|
|
4
|
+
}>;
|
|
5
|
+
getState(): Promise<string>;
|
|
6
|
+
remove(): Promise<void>;
|
|
7
|
+
}>;
|
|
8
|
+
export type AccountPipelineQueue = Readonly<{
|
|
9
|
+
getJobs(states?: string[]): Promise<readonly CancellablePipelineJob[]>;
|
|
10
|
+
}>;
|
|
11
|
+
export type AccountPipelineCancellationDependencies = Readonly<{
|
|
12
|
+
/** Atomically changes every non-terminal run owned by the actor to cancelled. */
|
|
13
|
+
cancelRuns(actorUserId: string, signal?: AbortSignal): Promise<number>;
|
|
14
|
+
queues: readonly AccountPipelineQueue[];
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Fence active work durably, then remove only queue entries whose payload has
|
|
18
|
+
* exact actor ownership metadata. BullMQ active jobs cannot be removed safely;
|
|
19
|
+
* workers observe the durable fence before every write instead.
|
|
20
|
+
*/
|
|
21
|
+
export declare function cancelAccountPipelineJobs(actorUserId: string, deps: AccountPipelineCancellationDependencies, signal?: AbortSignal): Promise<number>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const REMOVABLE_STATES = ["waiting", "delayed", "paused", "prioritized"];
|
|
2
|
+
/**
|
|
3
|
+
* Fence active work durably, then remove only queue entries whose payload has
|
|
4
|
+
* exact actor ownership metadata. BullMQ active jobs cannot be removed safely;
|
|
5
|
+
* workers observe the durable fence before every write instead.
|
|
6
|
+
*/
|
|
7
|
+
export async function cancelAccountPipelineJobs(actorUserId, deps, signal) {
|
|
8
|
+
if (signal?.aborted)
|
|
9
|
+
throw signal.reason ?? new DOMException("Aborted", "AbortError");
|
|
10
|
+
let affected = await deps.cancelRuns(actorUserId, signal);
|
|
11
|
+
for (const queue of deps.queues) {
|
|
12
|
+
const jobs = await queue.getJobs([...REMOVABLE_STATES]);
|
|
13
|
+
for (const job of jobs) {
|
|
14
|
+
if (job.data?.ownerId !== actorUserId)
|
|
15
|
+
continue;
|
|
16
|
+
const state = await job.getState();
|
|
17
|
+
if (!REMOVABLE_STATES.includes(state))
|
|
18
|
+
continue;
|
|
19
|
+
try {
|
|
20
|
+
await job.remove();
|
|
21
|
+
affected += 1;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
// A worker may claim/remove the job between state inspection and remove.
|
|
25
|
+
// The durable run fence still prevents any subsequent write. BullMQ
|
|
26
|
+
// reports these two expected claim/removal races as explicit messages.
|
|
27
|
+
const message = error instanceof Error ? error.message.toLowerCase() : "";
|
|
28
|
+
if (!message.includes("not found") && !message.includes("locked") && !message.includes("active"))
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return affected;
|
|
34
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hiai-gg/docsmint",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"browser": {
|
|
6
6
|
"./dist/backend-launcher.js": false,
|
|
7
7
|
"./dist/lifecycle.js": false,
|
|
8
8
|
"./dist/lifecycle-persistent.js": false,
|
|
9
|
+
"./dist/lifecycle-runtime.js": false,
|
|
10
|
+
"./dist/pipeline-cancellation.js": false,
|
|
9
11
|
"./dist/storage-quota.js": false,
|
|
10
|
-
"./dist/workspace.js": false
|
|
12
|
+
"./dist/workspace.js": false,
|
|
13
|
+
"./dist/backend-pipeline-cancellation.js": false
|
|
11
14
|
},
|
|
12
15
|
"license": "Apache-2.0",
|
|
13
16
|
"description": "The lightweight, AI-native self-hosted knowledge base — built-in RAG, hybrid semantic search, and a clean REST API for AI agents.",
|
|
@@ -59,6 +62,16 @@
|
|
|
59
62
|
"import": "./dist/lifecycle-persistent.js",
|
|
60
63
|
"types": "./dist/lifecycle-persistent.d.ts"
|
|
61
64
|
},
|
|
65
|
+
"./lifecycle/runtime": {
|
|
66
|
+
"browser": "./dist/server-only-browser-entry.js",
|
|
67
|
+
"import": "./dist/lifecycle-runtime.js",
|
|
68
|
+
"types": "./dist/lifecycle-runtime.d.ts"
|
|
69
|
+
},
|
|
70
|
+
"./pipeline/cancellation": {
|
|
71
|
+
"browser": "./dist/server-only-browser-entry.js",
|
|
72
|
+
"import": "./dist/pipeline-cancellation.js",
|
|
73
|
+
"types": "./dist/pipeline-cancellation.d.ts"
|
|
74
|
+
},
|
|
62
75
|
"./workspace": {
|
|
63
76
|
"browser": "./dist/server-only-browser-entry.js",
|
|
64
77
|
"import": "./dist/workspace.js",
|
|
@@ -288,6 +301,11 @@
|
|
|
288
301
|
"./backend/lib/logger": {
|
|
289
302
|
"import": "./backend/src/lib/logger.ts",
|
|
290
303
|
"types": "./backend/src/lib/logger.ts"
|
|
304
|
+
},
|
|
305
|
+
"./backend/pipeline-cancellation": {
|
|
306
|
+
"browser": "./dist/server-only-browser-entry.js",
|
|
307
|
+
"import": "./dist/backend-pipeline-cancellation.js",
|
|
308
|
+
"types": "./dist/backend-pipeline-cancellation.d.ts"
|
|
291
309
|
}
|
|
292
310
|
},
|
|
293
311
|
"bin": {
|
|
@@ -332,6 +350,7 @@
|
|
|
332
350
|
},
|
|
333
351
|
"dependencies": {
|
|
334
352
|
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
353
|
+
"bullmq": "^5.80.2",
|
|
335
354
|
"commander": "^13.1.0",
|
|
336
355
|
"zod": "^4.0.0"
|
|
337
356
|
},
|
|
@@ -24,7 +24,7 @@ import { registerSearch } from "./commands/search.js";
|
|
|
24
24
|
import { registerSnapshot } from "./commands/snapshot.js";
|
|
25
25
|
import { registerUpdate } from "./commands/update.js";
|
|
26
26
|
|
|
27
|
-
const VERSION = "0.4.
|
|
27
|
+
const VERSION = "0.4.4";
|
|
28
28
|
|
|
29
29
|
const program = new Command();
|
|
30
30
|
program
|