@luckydraw/cumulus 1.0.39 → 1.0.41

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/gateway/adapters/webchat.d.ts +3 -0
  3. package/dist/gateway/adapters/webchat.d.ts.map +1 -1
  4. package/dist/gateway/adapters/webchat.js +70 -0
  5. package/dist/gateway/adapters/webchat.js.map +1 -1
  6. package/dist/gateway/config.d.ts +16 -2
  7. package/dist/gateway/config.d.ts.map +1 -1
  8. package/dist/gateway/config.js +12 -6
  9. package/dist/gateway/config.js.map +1 -1
  10. package/dist/gateway/daemon.d.ts +1 -0
  11. package/dist/gateway/daemon.d.ts.map +1 -1
  12. package/dist/gateway/daemon.js +4 -0
  13. package/dist/gateway/daemon.js.map +1 -1
  14. package/dist/gateway/one-shot-model.d.ts +92 -0
  15. package/dist/gateway/one-shot-model.d.ts.map +1 -0
  16. package/dist/gateway/one-shot-model.js +191 -0
  17. package/dist/gateway/one-shot-model.js.map +1 -0
  18. package/dist/gateway/server.d.ts +3 -0
  19. package/dist/gateway/server.d.ts.map +1 -1
  20. package/dist/gateway/server.js +4 -0
  21. package/dist/gateway/server.js.map +1 -1
  22. package/dist/gateway/stall-detection.d.ts +19 -50
  23. package/dist/gateway/stall-detection.d.ts.map +1 -1
  24. package/dist/gateway/stall-detection.js +27 -190
  25. package/dist/gateway/stall-detection.js.map +1 -1
  26. package/dist/gateway/static/widget.js +139 -18
  27. package/dist/gateway/tasks-refresh.d.ts +115 -0
  28. package/dist/gateway/tasks-refresh.d.ts.map +1 -0
  29. package/dist/gateway/tasks-refresh.js +333 -0
  30. package/dist/gateway/tasks-refresh.js.map +1 -0
  31. package/dist/gateway/tasks.d.ts +18 -0
  32. package/dist/gateway/tasks.d.ts.map +1 -1
  33. package/dist/gateway/tasks.js +42 -7
  34. package/dist/gateway/tasks.js.map +1 -1
  35. package/dist/gateway/worker.d.ts +86 -0
  36. package/dist/gateway/worker.d.ts.map +1 -0
  37. package/dist/gateway/worker.js +0 -0
  38. package/dist/gateway/worker.js.map +1 -0
  39. package/package.json +1 -1
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Task 179 — the invisible background worker.
3
+ *
4
+ * Karl asked whether every thread should have "some kind of system co-thread for
5
+ * doing this kind of work, but that it wouldn't necessarily be visible in the
6
+ * threads UI", and answered his own poll with "yes — build it as a general
7
+ * facility, Refresh is just the first user."
8
+ *
9
+ * A co-thread is the wrong engine for it, on four grounded counts: its writes
10
+ * land in its own git worktree on its own branch (task 143 P4), it is drawn in
11
+ * the sidebar under its master, it shares the master's stored content in BOTH
12
+ * directions — so a worker that reads a whole file pours it into the master's
13
+ * memory — and only a thread already mid-turn can create one, which a button
14
+ * click is not.
15
+ *
16
+ * So this is not a chat thread at all. It is a gateway-owned one-shot model call
17
+ * with no conversation, no history and no sidebar row — `runOneShotModel` plus
18
+ * the two things that make it a *facility* rather than a bare call:
19
+ *
20
+ * 1. **One job per `{thread, kind}` at a time.** A second request while one is
21
+ * in flight is REFUSED, not queued. Two Refreshes racing on one `Tasks.md`
22
+ * is the exact failure the whole task exists to prevent, and a queue would
23
+ * merely delay it.
24
+ * 2. **A status push** (`running | done | failed`) to whoever is watching, so a
25
+ * button can spin without the UI inventing a second notion of "busy".
26
+ *
27
+ * It deliberately never touches `threadBusy`. That flag drives the sidebar dots
28
+ * (task 146), the stall check (task 164) and the deferred-message drain (task
29
+ * 144); a worker that set it would make the sidebar claim a turn was running,
30
+ * suppress a real stall check, and drain a user's queued message into nothing.
31
+ */
32
+ import { type OneShotModelContext } from './one-shot-model.js';
33
+ /**
34
+ * What a worker run is for. A closed union, not a free string: the key is half of
35
+ * the in-flight identity, so a typo would silently buy a second concurrent slot
36
+ * on the same thread — the one thing this module exists to deny.
37
+ */
38
+ export type WorkerKind = 'tasks-refresh';
39
+ export type WorkerState = 'running' | 'done' | 'failed';
40
+ export interface WorkerStatus {
41
+ threadName: string;
42
+ kind: WorkerKind;
43
+ state: WorkerState;
44
+ /** Present on `failed`, and on `done` when there is something worth saying. */
45
+ detail?: string;
46
+ }
47
+ /** Thrown by {@link runWorker} when this `{thread, kind}` is already working. */
48
+ export declare class WorkerBusyError extends Error {
49
+ constructor(kind: WorkerKind);
50
+ }
51
+ /** Thrown when the model produced no answer at all (spawn failure, timeout, empty). */
52
+ export declare class WorkerNoAnswerError extends Error {
53
+ constructor();
54
+ }
55
+ export declare function isWorkerRunning(threadName: string, kind: WorkerKind): boolean;
56
+ /**
57
+ * Where worker progress goes. Registered by the webchat adapter at startup for
58
+ * the same reason `setThreadActivityListener` and `setUserQueueDelivery` are:
59
+ * only the adapter can reach the sockets, and this module must not know they
60
+ * exist.
61
+ */
62
+ type WorkerStatusListener = (status: WorkerStatus) => void;
63
+ export declare function setWorkerStatusListener(fn: WorkerStatusListener | undefined): void;
64
+ export interface RunWorkerOptions {
65
+ /** Configured worker model id (`workerModel`), resolved against both catalogs. */
66
+ model?: string;
67
+ context?: OneShotModelContext;
68
+ timeoutMs?: number;
69
+ maxTokens?: number;
70
+ }
71
+ /**
72
+ * Run one prompt as this thread's `kind` worker and return the model's raw text.
73
+ *
74
+ * Throws {@link WorkerBusyError} if that slot is taken and
75
+ * {@link WorkerNoAnswerError} if the model produced nothing — both before any
76
+ * caller-visible side effect, so a refused run leaves no trace.
77
+ *
78
+ * The slot is released in a `finally`, so a caller that throws while INTERPRETING
79
+ * the answer (which is where task 179's guard rails live) still frees the button.
80
+ */
81
+ export declare function runWorker(threadName: string, kind: WorkerKind, prompt: string, opts?: RunWorkerOptions): Promise<string>;
82
+ /** Announce the end of a worker run. Separate from {@link runWorker} because the
83
+ * caller — not this module — knows whether interpreting the answer succeeded. */
84
+ export declare function reportWorkerResult(threadName: string, kind: WorkerKind, state: 'done' | 'failed', detail?: string): void;
85
+ export {};
86
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRo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AAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED;iFACiF;AACjF,MAAM,UAAU,kBAAkB,CAChC,UAAkB,EAClB,IAAgB,EAChB,KAAwB,EACxB,MAAe;IAEf,MAAM,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AAC9C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luckydraw/cumulus",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "RLM-based CLI chat wrapper for Claude with external history context management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",