@hiai-gg/docsmint 0.4.3 → 0.4.5

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.
@@ -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,17 @@
1
1
  {
2
2
  "name": "@hiai-gg/docsmint",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
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,
14
+ "./dist/backend-account-runtime-cleanup.js": false
12
15
  },
13
16
  "license": "Apache-2.0",
14
17
  "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 +68,11 @@
65
68
  "import": "./dist/lifecycle-runtime.js",
66
69
  "types": "./dist/lifecycle-runtime.d.ts"
67
70
  },
71
+ "./pipeline/cancellation": {
72
+ "browser": "./dist/server-only-browser-entry.js",
73
+ "import": "./dist/pipeline-cancellation.js",
74
+ "types": "./dist/pipeline-cancellation.d.ts"
75
+ },
68
76
  "./workspace": {
69
77
  "browser": "./dist/server-only-browser-entry.js",
70
78
  "import": "./dist/workspace.js",
@@ -294,6 +302,16 @@
294
302
  "./backend/lib/logger": {
295
303
  "import": "./backend/src/lib/logger.ts",
296
304
  "types": "./backend/src/lib/logger.ts"
305
+ },
306
+ "./backend/pipeline-cancellation": {
307
+ "browser": "./dist/server-only-browser-entry.js",
308
+ "import": "./dist/backend-pipeline-cancellation.js",
309
+ "types": "./dist/backend-pipeline-cancellation.d.ts"
310
+ },
311
+ "./backend/account-runtime-cleanup": {
312
+ "browser": "./dist/server-only-browser-entry.js",
313
+ "import": "./dist/backend-account-runtime-cleanup.js",
314
+ "types": "./dist/backend-account-runtime-cleanup.d.ts"
297
315
  }
298
316
  },
299
317
  "bin": {
@@ -338,13 +356,14 @@
338
356
  },
339
357
  "dependencies": {
340
358
  "@modelcontextprotocol/sdk": "^1.12.1",
359
+ "bullmq": "^5.80.2",
341
360
  "commander": "^13.1.0",
361
+ "ioredis": "^5.11.1",
342
362
  "zod": "^4.0.0"
343
363
  },
344
364
  "peerDependencies": {
345
365
  "drizzle-orm": "^0.45.2",
346
366
  "postgres": "^3.4.9",
347
- "ioredis": "^5.4.0",
348
367
  "@aws-sdk/client-s3": "^3.0.0",
349
368
  "pino": "^10.0.0",
350
369
  "@sveltejs/kit": "^2.68.0",
@@ -357,9 +376,6 @@
357
376
  "postgres": {
358
377
  "optional": true
359
378
  },
360
- "ioredis": {
361
- "optional": true
362
- },
363
379
  "@aws-sdk/client-s3": {
364
380
  "optional": true
365
381
  },
@@ -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.3";
27
+ const VERSION = "0.4.5";
28
28
 
29
29
  const program = new Command();
30
30
  program
@@ -35,7 +35,7 @@ interface McpToolResult {
35
35
 
36
36
  const server = new McpServer({
37
37
  name: "hiai-docs",
38
- version: "0.4.3",
38
+ version: "0.4.5",
39
39
  });
40
40
 
41
41
  /**