@hiai-gg/docsmint 0.4.3 → 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/pipeline-cancellation.d.ts +21 -0
- package/dist/pipeline-cancellation.js +34 -0
- package/package.json +15 -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,14 +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
9
|
"./dist/lifecycle-runtime.js": false,
|
|
10
|
+
"./dist/pipeline-cancellation.js": false,
|
|
10
11
|
"./dist/storage-quota.js": false,
|
|
11
|
-
"./dist/workspace.js": false
|
|
12
|
+
"./dist/workspace.js": false,
|
|
13
|
+
"./dist/backend-pipeline-cancellation.js": false
|
|
12
14
|
},
|
|
13
15
|
"license": "Apache-2.0",
|
|
14
16
|
"description": "The lightweight, AI-native self-hosted knowledge base — built-in RAG, hybrid semantic search, and a clean REST API for AI agents.",
|
|
@@ -65,6 +67,11 @@
|
|
|
65
67
|
"import": "./dist/lifecycle-runtime.js",
|
|
66
68
|
"types": "./dist/lifecycle-runtime.d.ts"
|
|
67
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
|
+
},
|
|
68
75
|
"./workspace": {
|
|
69
76
|
"browser": "./dist/server-only-browser-entry.js",
|
|
70
77
|
"import": "./dist/workspace.js",
|
|
@@ -294,6 +301,11 @@
|
|
|
294
301
|
"./backend/lib/logger": {
|
|
295
302
|
"import": "./backend/src/lib/logger.ts",
|
|
296
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"
|
|
297
309
|
}
|
|
298
310
|
},
|
|
299
311
|
"bin": {
|
|
@@ -338,6 +350,7 @@
|
|
|
338
350
|
},
|
|
339
351
|
"dependencies": {
|
|
340
352
|
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
353
|
+
"bullmq": "^5.80.2",
|
|
341
354
|
"commander": "^13.1.0",
|
|
342
355
|
"zod": "^4.0.0"
|
|
343
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
|