maqcli 0.2.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 (88) hide show
  1. package/README.md +223 -0
  2. package/dist/core/audit.d.ts +43 -0
  3. package/dist/core/audit.js +77 -0
  4. package/dist/core/board.d.ts +78 -0
  5. package/dist/core/board.js +256 -0
  6. package/dist/core/catalog.d.ts +50 -0
  7. package/dist/core/catalog.js +103 -0
  8. package/dist/core/command-catalog.d.ts +44 -0
  9. package/dist/core/command-catalog.js +86 -0
  10. package/dist/core/completion.d.ts +24 -0
  11. package/dist/core/completion.js +309 -0
  12. package/dist/core/complexity.d.ts +17 -0
  13. package/dist/core/complexity.js +87 -0
  14. package/dist/core/config-store.d.ts +33 -0
  15. package/dist/core/config-store.js +61 -0
  16. package/dist/core/connectivity.d.ts +34 -0
  17. package/dist/core/connectivity.js +49 -0
  18. package/dist/core/cost-tracker.d.ts +89 -0
  19. package/dist/core/cost-tracker.js +189 -0
  20. package/dist/core/cost.d.ts +35 -0
  21. package/dist/core/cost.js +89 -0
  22. package/dist/core/exec.d.ts +43 -0
  23. package/dist/core/exec.js +154 -0
  24. package/dist/core/flows.d.ts +36 -0
  25. package/dist/core/flows.js +96 -0
  26. package/dist/core/headroom.d.ts +36 -0
  27. package/dist/core/headroom.js +88 -0
  28. package/dist/core/help-topics.d.ts +26 -0
  29. package/dist/core/help-topics.js +294 -0
  30. package/dist/core/init-wizard.d.ts +26 -0
  31. package/dist/core/init-wizard.js +168 -0
  32. package/dist/core/interactive-registry.d.ts +50 -0
  33. package/dist/core/interactive-registry.js +86 -0
  34. package/dist/core/interactive.d.ts +48 -0
  35. package/dist/core/interactive.js +137 -0
  36. package/dist/core/logger.d.ts +16 -0
  37. package/dist/core/logger.js +46 -0
  38. package/dist/core/memory.d.ts +28 -0
  39. package/dist/core/memory.js +70 -0
  40. package/dist/core/metered.d.ts +9 -0
  41. package/dist/core/metered.js +16 -0
  42. package/dist/core/model.d.ts +74 -0
  43. package/dist/core/model.js +199 -0
  44. package/dist/core/pipeline.d.ts +33 -0
  45. package/dist/core/pipeline.js +223 -0
  46. package/dist/core/plugins.d.ts +21 -0
  47. package/dist/core/plugins.js +38 -0
  48. package/dist/core/probe.d.ts +48 -0
  49. package/dist/core/probe.js +156 -0
  50. package/dist/core/profiles.d.ts +42 -0
  51. package/dist/core/profiles.js +153 -0
  52. package/dist/core/providers.d.ts +84 -0
  53. package/dist/core/providers.js +275 -0
  54. package/dist/core/recall.d.ts +29 -0
  55. package/dist/core/recall.js +83 -0
  56. package/dist/core/registry.d.ts +41 -0
  57. package/dist/core/registry.js +162 -0
  58. package/dist/core/router.d.ts +33 -0
  59. package/dist/core/router.js +40 -0
  60. package/dist/core/sandbox.d.ts +78 -0
  61. package/dist/core/sandbox.js +268 -0
  62. package/dist/core/session.d.ts +105 -0
  63. package/dist/core/session.js +252 -0
  64. package/dist/core/skills.d.ts +56 -0
  65. package/dist/core/skills.js +289 -0
  66. package/dist/core/subagent.d.ts +40 -0
  67. package/dist/core/subagent.js +55 -0
  68. package/dist/core/supervisor.d.ts +37 -0
  69. package/dist/core/supervisor.js +40 -0
  70. package/dist/core/tools.d.ts +39 -0
  71. package/dist/core/tools.js +159 -0
  72. package/dist/core/types.d.ts +87 -0
  73. package/dist/core/types.js +10 -0
  74. package/dist/index.d.ts +11 -0
  75. package/dist/index.js +1032 -0
  76. package/dist/phases/execute.d.ts +39 -0
  77. package/dist/phases/execute.js +166 -0
  78. package/dist/phases/plan.d.ts +11 -0
  79. package/dist/phases/plan.js +118 -0
  80. package/dist/phases/scout.d.ts +10 -0
  81. package/dist/phases/scout.js +113 -0
  82. package/dist/phases/verify.d.ts +22 -0
  83. package/dist/phases/verify.js +81 -0
  84. package/dist/server/daemon.d.ts +50 -0
  85. package/dist/server/daemon.js +377 -0
  86. package/dist/server/relay-bridge.d.ts +44 -0
  87. package/dist/server/relay-bridge.js +175 -0
  88. package/package.json +39 -0
@@ -0,0 +1,33 @@
1
+ /**
2
+ * RouteLLM-style routing: pick a model tier for a sub-task, then resolve that
3
+ * tier to a concrete (provider, model) from config.
4
+ *
5
+ * The classifier here is deterministic and rule-based (task complexity ->
6
+ * tier), which is the cheap, zero-token version of RouteLLM's trained router.
7
+ * A trained classifier can slot in behind `tierFor` later without changing any
8
+ * caller. Routing cheap work to a cheap model and escalating only hard work is
9
+ * the documented lever for large cost reduction while holding quality.
10
+ */
11
+ import type { Complexity } from "./types.js";
12
+ import type { MaqConfig } from "./config-store.js";
13
+ import type { ModelProvider } from "./model.js";
14
+ export type Tier = "cheap" | "strong";
15
+ export interface Route {
16
+ tier: Tier;
17
+ provider: ModelProvider;
18
+ providerName: string;
19
+ model: string;
20
+ }
21
+ /** Map task complexity to a model tier. */
22
+ export declare function tierFor(complexity: Complexity): Tier;
23
+ /**
24
+ * Resolve a tier to a concrete provider+model using config. Both tiers use the
25
+ * same configured `provider`; only the model name differs (cheap vs strong).
26
+ * Falls back to `masterModel` when a tier model is unset.
27
+ */
28
+ export declare class Router {
29
+ private cfg;
30
+ constructor(cfg: MaqConfig);
31
+ route(tier: Tier): Route;
32
+ routeByComplexity(complexity: Complexity): Route;
33
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * RouteLLM-style routing: pick a model tier for a sub-task, then resolve that
3
+ * tier to a concrete (provider, model) from config.
4
+ *
5
+ * The classifier here is deterministic and rule-based (task complexity ->
6
+ * tier), which is the cheap, zero-token version of RouteLLM's trained router.
7
+ * A trained classifier can slot in behind `tierFor` later without changing any
8
+ * caller. Routing cheap work to a cheap model and escalating only hard work is
9
+ * the documented lever for large cost reduction while holding quality.
10
+ */
11
+ import { getProvider } from "./model.js";
12
+ /** Map task complexity to a model tier. */
13
+ export function tierFor(complexity) {
14
+ return complexity === "complex" ? "strong" : "cheap";
15
+ }
16
+ /**
17
+ * Resolve a tier to a concrete provider+model using config. Both tiers use the
18
+ * same configured `provider`; only the model name differs (cheap vs strong).
19
+ * Falls back to `masterModel` when a tier model is unset.
20
+ */
21
+ export class Router {
22
+ cfg;
23
+ constructor(cfg) {
24
+ this.cfg = cfg;
25
+ }
26
+ route(tier) {
27
+ const model = tier === "strong"
28
+ ? this.cfg.strongModel || this.cfg.masterModel
29
+ : this.cfg.cheapModel || this.cfg.masterModel;
30
+ return {
31
+ tier,
32
+ provider: getProvider(this.cfg.provider),
33
+ providerName: this.cfg.provider,
34
+ model,
35
+ };
36
+ }
37
+ routeByComplexity(complexity) {
38
+ return this.route(tierFor(complexity));
39
+ }
40
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @module sandbox
3
+ * @description Permission tier / safety boundary system for maqcli.
4
+ *
5
+ * Enforces a three-level permission model:
6
+ * Tier 1 (Scout) — read-only access
7
+ * Tier 2 (Execute) — scoped writes within allowed paths
8
+ * Tier 3 (Destructive) — all writes allowed, destructive ops flagged for confirmation
9
+ *
10
+ * Zero npm dependencies — Node built-ins only.
11
+ */
12
+ export type PermissionTier = 1 | 2 | 3;
13
+ export interface SandboxPolicy {
14
+ tier: PermissionTier;
15
+ allowedPaths: string[];
16
+ denyCommands: string[];
17
+ readOnlyCommands: string[];
18
+ }
19
+ export interface SandboxCheck {
20
+ allowed: boolean;
21
+ tier: PermissionTier;
22
+ reason: string;
23
+ }
24
+ /** Sentinel exit code returned when a sandbox violation terminates a phase. */
25
+ export declare const EXIT_SANDBOX = 4;
26
+ /**
27
+ * Create a {@link SandboxPolicy} anchored at `cwd`.
28
+ *
29
+ * @param cwd - Working directory that becomes the default allowed-path root.
30
+ * @param tier - Permission tier (defaults to **2** — scoped-write).
31
+ */
32
+ export declare function createPolicy(cwd: string, tier?: PermissionTier): SandboxPolicy;
33
+ /**
34
+ * Determine whether a **read** of `filePath` is permitted under `policy`.
35
+ *
36
+ * Reads are allowed at every tier — the check exists so callers get a
37
+ * uniform {@link SandboxCheck} shape.
38
+ */
39
+ export declare function checkRead(filePath: string, policy: SandboxPolicy): SandboxCheck;
40
+ /**
41
+ * Determine whether a **write** to `filePath` is permitted under `policy`.
42
+ *
43
+ * - Tier 1 — always denied (read-only).
44
+ * - Tier 2 — allowed only inside `allowedPaths` and outside system dirs.
45
+ * - Tier 3 — allowed everywhere, but destructive flag raised.
46
+ */
47
+ export declare function checkWrite(filePath: string, policy: SandboxPolicy): SandboxCheck;
48
+ /**
49
+ * Determine whether `command` is permitted under `policy`.
50
+ *
51
+ * Evaluation order:
52
+ * 1. Deny-list — unconditionally blocked regardless of tier.
53
+ * 2. Tier 1 — only read-only commands allowed.
54
+ * 3. Tier 2 — all non-denied commands allowed.
55
+ * 4. Tier 3 — all non-denied commands allowed, destructive ones flagged.
56
+ */
57
+ export declare function checkCommand(command: string | string[], policy: SandboxPolicy): SandboxCheck;
58
+ /**
59
+ * Returns `true` when `command` matches a known destructive pattern.
60
+ *
61
+ * Destructive patterns include `rm -rf`, `git push --force`,
62
+ * `git reset --hard`, `DROP TABLE`, `DROP DATABASE`, `format`,
63
+ * `shutdown`, and `reboot`.
64
+ */
65
+ export declare function isDestructive(command: string | string[]): boolean;
66
+ /**
67
+ * Map a pipeline phase name to its appropriate {@link PermissionTier}.
68
+ *
69
+ * | Phase | Tier |
70
+ * |-----------|------|
71
+ * | scout | 1 |
72
+ * | plan | 1 |
73
+ * | execute | 2 |
74
+ * | verify | 1 |
75
+ *
76
+ * Unknown phases default to tier **1** (safest).
77
+ */
78
+ export declare function tierForPhase(phase: string): PermissionTier;
@@ -0,0 +1,268 @@
1
+ /**
2
+ * @module sandbox
3
+ * @description Permission tier / safety boundary system for maqcli.
4
+ *
5
+ * Enforces a three-level permission model:
6
+ * Tier 1 (Scout) — read-only access
7
+ * Tier 2 (Execute) — scoped writes within allowed paths
8
+ * Tier 3 (Destructive) — all writes allowed, destructive ops flagged for confirmation
9
+ *
10
+ * Zero npm dependencies — Node built-ins only.
11
+ */
12
+ import { resolve, normalize } from "node:path";
13
+ import { platform } from "node:os";
14
+ // ─── Constants ───────────────────────────────────────────────────────────────
15
+ /** Sentinel exit code returned when a sandbox violation terminates a phase. */
16
+ export const EXIT_SANDBOX = 4;
17
+ const DENY_COMMANDS = [
18
+ "rm -rf /",
19
+ "mkfs",
20
+ "dd if=",
21
+ ":(){",
22
+ "chmod -R 777 /",
23
+ "eval",
24
+ ];
25
+ const READ_ONLY_COMMANDS = [
26
+ "cat",
27
+ "head",
28
+ "tail",
29
+ "less",
30
+ "ls",
31
+ "dir",
32
+ "find",
33
+ "grep",
34
+ "rg",
35
+ "tree",
36
+ "wc",
37
+ "file",
38
+ "stat",
39
+ "git log",
40
+ "git diff",
41
+ "git status",
42
+ "git show",
43
+ "git blame",
44
+ "type",
45
+ "Get-Content",
46
+ "Select-String",
47
+ ];
48
+ const DESTRUCTIVE_PATTERNS = [
49
+ "rm -rf",
50
+ "git push --force",
51
+ "git reset --hard",
52
+ "DROP TABLE",
53
+ "DROP DATABASE",
54
+ "format",
55
+ "shutdown",
56
+ "reboot",
57
+ ];
58
+ const SYSTEM_PATHS_POSIX = ["/usr", "/etc", "/bin"];
59
+ const SYSTEM_PATHS_WIN = ["C:\\Windows", "C:\\Program Files"];
60
+ // ─── Helpers ─────────────────────────────────────────────────────────────────
61
+ /**
62
+ * Normalise a command input (string or argv array) into a single string
63
+ * for pattern matching.
64
+ */
65
+ function normalizeCommand(command) {
66
+ return Array.isArray(command) ? command.join(" ") : command;
67
+ }
68
+ /**
69
+ * Returns the set of system paths that must never be written to,
70
+ * chosen based on the current platform.
71
+ */
72
+ function systemPaths() {
73
+ return platform() === "win32" ? SYSTEM_PATHS_WIN : SYSTEM_PATHS_POSIX;
74
+ }
75
+ /**
76
+ * Check whether `filePath` falls within at least one of the `allowed` roots.
77
+ */
78
+ function isWithinAllowed(filePath, allowed) {
79
+ const resolved = normalize(resolve(filePath));
80
+ return allowed.some((root) => {
81
+ const normalizedRoot = normalize(resolve(root));
82
+ return (resolved === normalizedRoot || resolved.startsWith(normalizedRoot + (platform() === "win32" ? "\\" : "/")));
83
+ });
84
+ }
85
+ /**
86
+ * Check whether `filePath` falls within a protected system directory.
87
+ */
88
+ function isSystemPath(filePath) {
89
+ const resolved = normalize(resolve(filePath)).toLowerCase();
90
+ return systemPaths().some((sp) => {
91
+ const normalizedSp = normalize(sp).toLowerCase();
92
+ return (resolved === normalizedSp || resolved.startsWith(normalizedSp + (platform() === "win32" ? "\\" : "/")));
93
+ });
94
+ }
95
+ // ─── Public API ──────────────────────────────────────────────────────────────
96
+ /**
97
+ * Create a {@link SandboxPolicy} anchored at `cwd`.
98
+ *
99
+ * @param cwd - Working directory that becomes the default allowed-path root.
100
+ * @param tier - Permission tier (defaults to **2** — scoped-write).
101
+ */
102
+ export function createPolicy(cwd, tier = 2) {
103
+ return {
104
+ tier,
105
+ allowedPaths: [resolve(cwd)],
106
+ denyCommands: [...DENY_COMMANDS],
107
+ readOnlyCommands: [...READ_ONLY_COMMANDS],
108
+ };
109
+ }
110
+ /**
111
+ * Determine whether a **read** of `filePath` is permitted under `policy`.
112
+ *
113
+ * Reads are allowed at every tier — the check exists so callers get a
114
+ * uniform {@link SandboxCheck} shape.
115
+ */
116
+ export function checkRead(filePath, policy) {
117
+ // Reads are universally permitted across all tiers.
118
+ return {
119
+ allowed: true,
120
+ tier: policy.tier,
121
+ reason: `Read access granted at tier ${policy.tier}`,
122
+ };
123
+ }
124
+ /**
125
+ * Determine whether a **write** to `filePath` is permitted under `policy`.
126
+ *
127
+ * - Tier 1 — always denied (read-only).
128
+ * - Tier 2 — allowed only inside `allowedPaths` and outside system dirs.
129
+ * - Tier 3 — allowed everywhere, but destructive flag raised.
130
+ */
131
+ export function checkWrite(filePath, policy) {
132
+ const resolved = normalize(resolve(filePath));
133
+ // Tier 1: read-only — no writes ever.
134
+ if (policy.tier === 1) {
135
+ return {
136
+ allowed: false,
137
+ tier: policy.tier,
138
+ reason: `Write denied: tier 1 (Scout) is read-only — ${resolved}`,
139
+ };
140
+ }
141
+ // Tier 2: scoped writes — within allowed paths, outside system dirs.
142
+ if (policy.tier === 2) {
143
+ if (isSystemPath(resolved)) {
144
+ return {
145
+ allowed: false,
146
+ tier: policy.tier,
147
+ reason: `Write denied: system path is protected — ${resolved}`,
148
+ };
149
+ }
150
+ if (!isWithinAllowed(resolved, policy.allowedPaths)) {
151
+ return {
152
+ allowed: false,
153
+ tier: policy.tier,
154
+ reason: `Write denied: path outside allowed roots — ${resolved}`,
155
+ };
156
+ }
157
+ return {
158
+ allowed: true,
159
+ tier: policy.tier,
160
+ reason: `Write allowed within scoped path — ${resolved}`,
161
+ };
162
+ }
163
+ // Tier 3: destructive — allow but flag.
164
+ return {
165
+ allowed: true,
166
+ tier: policy.tier,
167
+ reason: `Write allowed at tier 3 (destructive) — confirm before proceeding — ${resolved}`,
168
+ };
169
+ }
170
+ /**
171
+ * Determine whether `command` is permitted under `policy`.
172
+ *
173
+ * Evaluation order:
174
+ * 1. Deny-list — unconditionally blocked regardless of tier.
175
+ * 2. Tier 1 — only read-only commands allowed.
176
+ * 3. Tier 2 — all non-denied commands allowed.
177
+ * 4. Tier 3 — all non-denied commands allowed, destructive ones flagged.
178
+ */
179
+ export function checkCommand(command, policy) {
180
+ const cmd = normalizeCommand(command);
181
+ // 1. Deny-list — always blocked.
182
+ for (const denied of policy.denyCommands) {
183
+ if (cmd.includes(denied)) {
184
+ return {
185
+ allowed: false,
186
+ tier: policy.tier,
187
+ reason: `Command denied: matches deny-list entry "${denied}"`,
188
+ };
189
+ }
190
+ }
191
+ // 2. Tier 1 — read-only commands only.
192
+ if (policy.tier === 1) {
193
+ const isReadOnly = policy.readOnlyCommands.some((ro) => {
194
+ const trimmed = cmd.trimStart();
195
+ return trimmed === ro || trimmed.startsWith(ro + " ");
196
+ });
197
+ if (!isReadOnly) {
198
+ return {
199
+ allowed: false,
200
+ tier: policy.tier,
201
+ reason: `Command denied: tier 1 (Scout) permits only read-only commands`,
202
+ };
203
+ }
204
+ return {
205
+ allowed: true,
206
+ tier: policy.tier,
207
+ reason: `Command allowed: recognised read-only command at tier 1`,
208
+ };
209
+ }
210
+ // 3. Tier 2 — scoped-write, non-denied commands pass.
211
+ if (policy.tier === 2) {
212
+ return {
213
+ allowed: true,
214
+ tier: policy.tier,
215
+ reason: `Command allowed at tier 2 (Execute)`,
216
+ };
217
+ }
218
+ // 4. Tier 3 — allow, flag destructive.
219
+ if (isDestructive(cmd)) {
220
+ return {
221
+ allowed: true,
222
+ tier: policy.tier,
223
+ reason: `Command allowed at tier 3 (destructive) — confirm before proceeding`,
224
+ };
225
+ }
226
+ return {
227
+ allowed: true,
228
+ tier: policy.tier,
229
+ reason: `Command allowed at tier 3`,
230
+ };
231
+ }
232
+ /**
233
+ * Returns `true` when `command` matches a known destructive pattern.
234
+ *
235
+ * Destructive patterns include `rm -rf`, `git push --force`,
236
+ * `git reset --hard`, `DROP TABLE`, `DROP DATABASE`, `format`,
237
+ * `shutdown`, and `reboot`.
238
+ */
239
+ export function isDestructive(command) {
240
+ const cmd = normalizeCommand(command).toLowerCase();
241
+ return DESTRUCTIVE_PATTERNS.some((p) => cmd.includes(p.toLowerCase()));
242
+ }
243
+ /**
244
+ * Map a pipeline phase name to its appropriate {@link PermissionTier}.
245
+ *
246
+ * | Phase | Tier |
247
+ * |-----------|------|
248
+ * | scout | 1 |
249
+ * | plan | 1 |
250
+ * | execute | 2 |
251
+ * | verify | 1 |
252
+ *
253
+ * Unknown phases default to tier **1** (safest).
254
+ */
255
+ export function tierForPhase(phase) {
256
+ switch (phase.toLowerCase()) {
257
+ case "scout":
258
+ return 1;
259
+ case "plan":
260
+ return 1;
261
+ case "execute":
262
+ return 2;
263
+ case "verify":
264
+ return 1;
265
+ default:
266
+ return 1;
267
+ }
268
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Session registry + multi-agent management.
3
+ *
4
+ * Each session is one orchestrated task run (Scout->Plan->Execute->Verify)
5
+ * against one worker target. The registry runs many concurrently, keeps each
6
+ * session's normalized event history for replay, and exposes a live subscribe
7
+ * hook that the daemon turns into an SSE stream for the app.
8
+ *
9
+ * Coordination vocabulary borrowed from CAO (the vocabulary, not the tmux +
10
+ * Bedrock runtime):
11
+ * - assign(task) -> async, fire-and-forget; returns the session id now
12
+ * - handoff(task) -> sync, wait-for-completion; resolves with the result
13
+ * - sendMessage(id, m) -> deliver a message into a session's inbox
14
+ * Worker context stays isolated per session; the supervisor sees condensed
15
+ * events, never a raw shared transcript.
16
+ */
17
+ import type { MaqEvent, PipelineResult } from "./types.js";
18
+ export type SessionStatus = "running" | "paused" | "cancelled" | "done" | "error";
19
+ export interface InboxMessage {
20
+ ts: string;
21
+ from: string;
22
+ text: string;
23
+ }
24
+ export interface Session {
25
+ id: string;
26
+ task: string;
27
+ status: SessionStatus;
28
+ target?: string;
29
+ cwd: string;
30
+ createdAt: string;
31
+ updatedAt: string;
32
+ events: MaqEvent[];
33
+ inbox: InboxMessage[];
34
+ result?: PipelineResult;
35
+ error?: string;
36
+ }
37
+ export interface SessionSummary {
38
+ id: string;
39
+ task: string;
40
+ status: SessionStatus;
41
+ target?: string;
42
+ cwd: string;
43
+ createdAt: string;
44
+ updatedAt: string;
45
+ verified?: boolean;
46
+ eventCount: number;
47
+ }
48
+ export interface CreateOptions {
49
+ cwd?: string;
50
+ target?: string;
51
+ dryRun?: boolean;
52
+ timeoutMs?: number;
53
+ /** Named agent profile — resolves target/provider/model. */
54
+ profile?: string;
55
+ /** Provider override (else config). */
56
+ provider?: string;
57
+ /** Model override (else config tier models). */
58
+ model?: string;
59
+ }
60
+ type Listener = (e: MaqEvent) => void;
61
+ /** Thrown through the pipeline checkpoint when a session is cancelled. */
62
+ export declare class CancelError extends Error {
63
+ constructor();
64
+ }
65
+ export declare class SessionRegistry {
66
+ private sessions;
67
+ private controls;
68
+ private bus;
69
+ private maxSessions;
70
+ private maxEventsPerSession;
71
+ constructor(maxSessions?: number, maxEventsPerSession?: number);
72
+ /** Fire-and-forget: start a session and return its id immediately. */
73
+ assign(task: string, opts?: CreateOptions): Session;
74
+ /** Synchronous handoff: start a session and await its completion. */
75
+ handoff(task: string, opts?: CreateOptions): Promise<Session>;
76
+ /** Deliver a message into a session's inbox (records a normalized event). */
77
+ sendMessage(id: string, text: string, from?: string): boolean;
78
+ get(id: string): Session | undefined;
79
+ list(): SessionSummary[];
80
+ summarize(s: Session): SessionSummary;
81
+ /** Subscribe to live events for a session. Returns an unsubscribe fn. */
82
+ subscribe(id: string, listener: Listener): () => void;
83
+ /** Subscribe to ALL sessions' events (for plugins/webhooks). */
84
+ onAny(listener: (p: {
85
+ sessionId: string;
86
+ event: MaqEvent;
87
+ }) => void): void;
88
+ offAny(listener: (p: {
89
+ sessionId: string;
90
+ event: MaqEvent;
91
+ }) => void): void;
92
+ /** Remove finished sessions (housekeeping). */
93
+ prune(): number;
94
+ private spawn;
95
+ /** Pause a running session at its next phase boundary. */
96
+ pause(id: string): boolean;
97
+ /** Resume a paused session. */
98
+ resume(id: string): boolean;
99
+ /** Cancel a session; kills in-flight worker processes and aborts the run. */
100
+ cancel(id: string): boolean;
101
+ private push;
102
+ private waitFor;
103
+ private evictOldestDone;
104
+ }
105
+ export {};