@hasna/loops 0.3.60 → 0.4.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +247 -0
  2. package/LICENSE +197 -13
  3. package/README.md +24 -56
  4. package/dist/cli/index.js +7474 -6295
  5. package/dist/daemon/control.d.ts +21 -1
  6. package/dist/daemon/daemon.d.ts +5 -0
  7. package/dist/daemon/index.js +2808 -1209
  8. package/dist/daemon/install.d.ts +1 -1
  9. package/dist/index.d.ts +21 -8
  10. package/dist/index.js +5305 -4293
  11. package/dist/lib/accounts.d.ts +6 -1
  12. package/dist/lib/agent-adapter.d.ts +74 -0
  13. package/dist/lib/backup.d.ts +25 -0
  14. package/dist/lib/errors.d.ts +21 -0
  15. package/dist/lib/executor.d.ts +10 -1
  16. package/dist/lib/goal/metadata.d.ts +16 -0
  17. package/dist/lib/goal/model-factory.d.ts +1 -0
  18. package/dist/lib/goal/prompts.d.ts +3 -1
  19. package/dist/lib/goal/types.d.ts +3 -0
  20. package/dist/lib/health.d.ts +1 -1
  21. package/dist/lib/ids.d.ts +8 -1
  22. package/dist/lib/machines.d.ts +6 -0
  23. package/dist/lib/process-identity.d.ts +16 -0
  24. package/dist/lib/{schedule.d.ts → recurrence.d.ts} +1 -0
  25. package/dist/lib/redact.d.ts +21 -0
  26. package/dist/lib/route/cursors.d.ts +18 -0
  27. package/dist/lib/route/drain.d.ts +6 -0
  28. package/dist/lib/route/fields.d.ts +27 -0
  29. package/dist/lib/route/gates.d.ts +26 -0
  30. package/dist/lib/route/index.d.ts +18 -0
  31. package/dist/lib/route/options.d.ts +31 -0
  32. package/dist/lib/route/parse.d.ts +8 -0
  33. package/dist/lib/route/pr-review.d.ts +11 -0
  34. package/dist/lib/route/provider.d.ts +41 -0
  35. package/dist/lib/route/route-event.d.ts +23 -0
  36. package/dist/lib/route/route-tasks.d.ts +75 -0
  37. package/dist/lib/route/throttle.d.ts +47 -0
  38. package/dist/lib/route/todos-cli.d.ts +21 -0
  39. package/dist/lib/route/types.d.ts +88 -0
  40. package/dist/lib/run-artifacts.d.ts +17 -2
  41. package/dist/lib/run-envelope.d.ts +41 -0
  42. package/dist/lib/scheduler.d.ts +78 -2
  43. package/dist/lib/store.d.ts +63 -0
  44. package/dist/lib/store.js +1007 -287
  45. package/dist/lib/template-kit.d.ts +70 -0
  46. package/dist/lib/templates-custom.d.ts +34 -0
  47. package/dist/lib/templates.d.ts +13 -81
  48. package/dist/lib/workflow-runner.d.ts +2 -0
  49. package/dist/mcp/index.d.ts +3 -0
  50. package/dist/mcp/index.js +3216 -1382
  51. package/dist/sdk/index.d.ts +29 -3
  52. package/dist/sdk/index.js +2740 -1041
  53. package/dist/test-helpers.d.ts +37 -0
  54. package/dist/types.d.ts +2 -0
  55. package/docs/USAGE.md +36 -14
  56. package/package.json +6 -3
@@ -1,14 +1,32 @@
1
1
  import type { Store } from "../lib/store.js";
2
+ import type { LoopRun } from "../types.js";
3
+ export { processStartTimeMs, sameProcessStart, verifiedProcessStart, START_TIME_TOLERANCE_MS } from "../lib/process-identity.js";
4
+ export interface PidFileRecord {
5
+ pid: number;
6
+ startedAt?: number;
7
+ }
8
+ export declare function readPidRecord(path?: string): PidFileRecord | undefined;
2
9
  export declare function readPid(path?: string): number | undefined;
3
10
  export declare function writePid(pid?: number, path?: string): void;
4
11
  export declare function removePid(path?: string): void;
5
- export declare function isAlive(pid: number): boolean;
12
+ export declare function isAlive(pid: number, startedAt?: number): boolean;
6
13
  export interface DaemonProcessState {
7
14
  running: boolean;
8
15
  stale: boolean;
9
16
  pid?: number;
10
17
  }
11
18
  export declare function isDaemonRunning(path?: string): DaemonProcessState;
19
+ export interface ReapableProcess {
20
+ pid?: number;
21
+ pgid?: number;
22
+ processStartedAt?: string | number;
23
+ }
24
+ export declare function toReapableProcess(run: LoopRun): ReapableProcess;
25
+ export declare function reapProcessGroups(entries: ReapableProcess[], opts?: {
26
+ graceMs?: number;
27
+ sleep?: (ms: number) => Promise<void>;
28
+ log?: (message: string) => void;
29
+ }): Promise<number[]>;
12
30
  export interface DaemonStatus extends DaemonProcessState {
13
31
  lease?: ReturnType<Store["getDaemonLease"]>;
14
32
  host: string;
@@ -33,10 +51,12 @@ export declare function daemonStatus(store: Store, path?: string): DaemonStatus;
33
51
  export declare function stopDaemon(opts?: {
34
52
  path?: string;
35
53
  timeoutMs?: number;
54
+ reapGraceMs?: number;
36
55
  sleep?: (ms: number) => Promise<void>;
37
56
  }): Promise<{
38
57
  wasRunning: boolean;
39
58
  stopped: boolean;
40
59
  forced: boolean;
41
60
  pid?: number;
61
+ reapedPgids?: number[];
42
62
  }>;
@@ -11,7 +11,12 @@ export interface RunDaemonOptions {
11
11
  sleep?: (ms: number) => Promise<void>;
12
12
  log?: (message: string) => void;
13
13
  signal?: AbortSignal;
14
+ reapGraceMs?: number;
14
15
  }
16
+ export declare const DAEMON_LOG_MAX_BYTES: number;
17
+ export declare const DAEMON_LOG_KEEP = 2;
18
+ export declare function daemonLogLine(message: string): string;
19
+ export declare function rotateDaemonLog(path?: string, maxBytes?: number, keep?: number): boolean;
15
20
  export declare function runDaemon(opts?: RunDaemonOptions): Promise<void>;
16
21
  export interface StartDaemonResult {
17
22
  started: boolean;