indusagi-coding-agent 0.2.5 → 0.2.9

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 (224) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +9 -5
  3. package/dist/entry.js +14267 -24282
  4. package/dist/guardrails.js +924 -7867
  5. package/dist/index.js +13706 -23775
  6. package/package.json +3 -2
  7. package/src/_decls/entry.ts +18 -0
  8. package/src/_decls/guardrails.ts +35 -0
  9. package/src/_decls/index.ts +26 -0
  10. package/src/addons/contract.ts +236 -0
  11. package/src/addons/dispatch/event-dispatcher.ts +164 -0
  12. package/src/addons/dispatch/index.ts +25 -0
  13. package/src/addons/dispatch/tool-interceptor.ts +208 -0
  14. package/src/addons/host.ts +225 -0
  15. package/src/addons/index.ts +112 -0
  16. package/src/addons/manifest.ts +158 -0
  17. package/src/addons/sandbox.ts +170 -0
  18. package/src/addons/surface.ts +78 -0
  19. package/src/boot/auth-vault.ts +195 -0
  20. package/src/boot/boot.ts +138 -0
  21. package/src/boot/contract.ts +238 -0
  22. package/src/boot/heap.ts +59 -0
  23. package/src/boot/index.ts +28 -0
  24. package/src/boot/invocation.ts +93 -0
  25. package/src/boot/runners/addon-wiring.ts +153 -0
  26. package/src/boot/runners/checkpoint.ts +169 -0
  27. package/src/boot/runners/delegate-runner.ts +294 -0
  28. package/src/boot/runners/index.ts +13 -0
  29. package/src/boot/runners/link-runner.ts +45 -0
  30. package/src/boot/runners/memdir.ts +168 -0
  31. package/src/boot/runners/oneshot-runner.ts +58 -0
  32. package/src/boot/runners/read-state.ts +90 -0
  33. package/src/boot/runners/registry.ts +42 -0
  34. package/src/boot/runners/repl-runner.ts +143 -0
  35. package/src/boot/runners/server-mode.ts +121 -0
  36. package/src/boot/runners/session.ts +641 -0
  37. package/src/boot/server-token.ts +148 -0
  38. package/src/boot/stages.ts +167 -0
  39. package/src/boot/upgrade/apply.ts +94 -0
  40. package/src/boot/upgrade/index.ts +13 -0
  41. package/src/boot/upgrade/upgrades.ts +289 -0
  42. package/src/briefing/compose.ts +150 -0
  43. package/src/briefing/context-docs.ts +19 -0
  44. package/src/briefing/contract.ts +717 -0
  45. package/src/briefing/index.ts +31 -0
  46. package/src/briefing/macros.ts +97 -0
  47. package/src/briefing/skills.ts +47 -0
  48. package/src/capability-deck/bridge-ledger/index.ts +27 -0
  49. package/src/capability-deck/bridge-ledger/key.ts +67 -0
  50. package/src/capability-deck/bridge-ledger/ledger.ts +131 -0
  51. package/src/capability-deck/bridge-ledger/network.ts +117 -0
  52. package/src/capability-deck/builtin-bridge.ts +312 -0
  53. package/src/capability-deck/cards/bg-process-card.ts +335 -0
  54. package/src/capability-deck/cards/index.ts +115 -0
  55. package/src/capability-deck/cards/memory-card.ts +146 -0
  56. package/src/capability-deck/cards/plan-file.ts +97 -0
  57. package/src/capability-deck/cards/plan-tools.ts +185 -0
  58. package/src/capability-deck/cards/saas-card.ts +183 -0
  59. package/src/capability-deck/cards/task-card.ts +207 -0
  60. package/src/capability-deck/cards/todo-card.ts +168 -0
  61. package/src/capability-deck/cards/workflow-card.ts +247 -0
  62. package/src/capability-deck/contract.ts +388 -0
  63. package/src/capability-deck/index.ts +48 -0
  64. package/src/capability-deck/manifest.ts +109 -0
  65. package/src/capability-deck/provision.ts +169 -0
  66. package/src/channels/contract.ts +191 -0
  67. package/src/channels/framer.ts +50 -0
  68. package/src/channels/index.ts +101 -0
  69. package/src/channels/link/dialog.ts +129 -0
  70. package/src/channels/link/driver.ts +190 -0
  71. package/src/channels/link/index.ts +34 -0
  72. package/src/channels/link/server.ts +134 -0
  73. package/src/channels/oneshot.ts +90 -0
  74. package/src/channels/ops.ts +65 -0
  75. package/src/channels/session-ops.ts +81 -0
  76. package/src/conductor/bash-guard.ts +599 -0
  77. package/src/conductor/catalog/catalog.ts +116 -0
  78. package/src/conductor/catalog/index.ts +8 -0
  79. package/src/conductor/catalog/matcher.ts +134 -0
  80. package/src/conductor/conductor.ts +234 -0
  81. package/src/conductor/contract.ts +842 -0
  82. package/src/conductor/diagnostics.ts +227 -0
  83. package/src/conductor/index.ts +33 -0
  84. package/src/conductor/permissions.ts +588 -0
  85. package/src/conductor/quota-error.ts +49 -0
  86. package/src/conductor/signal-hub/hub.ts +46 -0
  87. package/src/conductor/signal-hub/index.ts +2 -0
  88. package/src/conductor/signal-hub/translate.test.ts +81 -0
  89. package/src/conductor/signal-hub/translate.ts +74 -0
  90. package/src/conductor/skill-parse/index.ts +2 -0
  91. package/src/conductor/skill-parse/parse.ts +108 -0
  92. package/src/conductor/transcript-store/index.ts +22 -0
  93. package/src/conductor/transcript-store/serialize.ts +116 -0
  94. package/src/conductor/transcript-store/store.ts +205 -0
  95. package/src/console/auth-status.ts +56 -0
  96. package/src/console/components/AgentsView.ts +165 -0
  97. package/src/console/components/BackgroundAgents.ts +155 -0
  98. package/src/console/components/Banner.ts +334 -0
  99. package/src/console/components/Composer.ts +94 -0
  100. package/src/console/components/StatusBar.ts +49 -0
  101. package/src/console/components/TerminalConsole.ts +1090 -0
  102. package/src/console/components/WorkingIndicator.ts +98 -0
  103. package/src/console/components/banner-sweep.ts +24 -0
  104. package/src/console/components/welcome.ts +74 -0
  105. package/src/console/contract.ts +630 -0
  106. package/src/console/index.ts +34 -0
  107. package/src/console/input/complete.ts +127 -0
  108. package/src/console/input/dir-reader.ts +34 -0
  109. package/src/console/input/index.ts +23 -0
  110. package/src/console/input/keymap.ts +159 -0
  111. package/src/console/input/paste.ts +104 -0
  112. package/src/console/mount.ts +56 -0
  113. package/src/console/overlays/approval-queue.ts +57 -0
  114. package/src/console/overlays/approval.ts +130 -0
  115. package/src/console/overlays/auth.ts +342 -0
  116. package/src/console/overlays/boards.ts +308 -0
  117. package/src/console/overlays/host.ts +36 -0
  118. package/src/console/overlays/index.ts +26 -0
  119. package/src/console/overlays/pickers.ts +258 -0
  120. package/src/console/overlays/sessions.ts +190 -0
  121. package/src/console/reducer.ts +182 -0
  122. package/src/console/slash/builtins.ts +81 -0
  123. package/src/console/slash/commands/dynamic.ts +83 -0
  124. package/src/console/slash/commands/integrations.ts +695 -0
  125. package/src/console/slash/commands/shared.ts +75 -0
  126. package/src/console/slash/commands/transcript.ts +263 -0
  127. package/src/console/slash/commands/workbench.ts +246 -0
  128. package/src/console/slash/index.ts +15 -0
  129. package/src/console/slash/registry.ts +70 -0
  130. package/src/console/slash/resolve.ts +63 -0
  131. package/src/console/startup.ts +209 -0
  132. package/src/console/theme/adapter.ts +45 -0
  133. package/src/console/theme/index.ts +7 -0
  134. package/src/console/theme/palette.ts +68 -0
  135. package/src/console/theme/resolve.ts +39 -0
  136. package/src/console/theme/tokens.ts +71 -0
  137. package/src/entry.ts +55 -0
  138. package/src/guardrails.ts +37 -0
  139. package/src/index.ts +18 -0
  140. package/src/insight/channel.ts +88 -0
  141. package/src/insight/contract.ts +185 -0
  142. package/src/insight/index.ts +110 -0
  143. package/src/insight/recorder.ts +213 -0
  144. package/src/insight/redaction.ts +157 -0
  145. package/src/insight/replay.ts +158 -0
  146. package/src/insight/sampling.ts +70 -0
  147. package/src/insight/serialize.ts +50 -0
  148. package/src/insight/sinks/console.ts +64 -0
  149. package/src/insight/sinks/file.ts +40 -0
  150. package/src/insight/sinks/index.ts +24 -0
  151. package/src/insight/sinks/stream.ts +54 -0
  152. package/src/integrations/sarvam/attach.ts +239 -0
  153. package/src/integrations/sarvam/config.ts +156 -0
  154. package/src/integrations/sarvam/index.ts +25 -0
  155. package/src/integrations/sarvam/sarvam.test.ts +60 -0
  156. package/src/integrations/sarvam/types.ts +27 -0
  157. package/src/integrations/zoho/attach.ts +342 -0
  158. package/src/integrations/zoho/config.ts +125 -0
  159. package/src/integrations/zoho/index.ts +27 -0
  160. package/src/integrations/zoho/types.ts +21 -0
  161. package/src/integrations/zoho/zoho.test.ts +50 -0
  162. package/src/kit/clipboard-image.ts +107 -0
  163. package/src/kit/external-editor.ts +48 -0
  164. package/src/kit/image.ts +59 -0
  165. package/src/kit/index.ts +51 -0
  166. package/src/kit/shell.ts +19 -0
  167. package/src/kit/tool-fetch.ts +85 -0
  168. package/src/launch/catalog.ts +148 -0
  169. package/src/launch/contract.ts +187 -0
  170. package/src/launch/credentials.ts +625 -0
  171. package/src/launch/index.ts +98 -0
  172. package/src/launch/invocation/attachments.ts +179 -0
  173. package/src/launch/invocation/flags.ts +196 -0
  174. package/src/launch/invocation/index.ts +25 -0
  175. package/src/launch/invocation/read.ts +260 -0
  176. package/src/launch/invocation/usage.ts +67 -0
  177. package/src/launch/login.ts +324 -0
  178. package/src/launch/oauth.test.ts +18 -0
  179. package/src/launch/oauth.ts +203 -0
  180. package/src/launch/packages.ts +194 -0
  181. package/src/launch/pickers.ts +189 -0
  182. package/src/runtime-bridge/bridges/_drive.ts +96 -0
  183. package/src/runtime-bridge/bridges/builtins.ts +68 -0
  184. package/src/runtime-bridge/bridges/claude-cli.ts +123 -0
  185. package/src/runtime-bridge/bridges/codex-cli.ts +142 -0
  186. package/src/runtime-bridge/bridges/index.ts +33 -0
  187. package/src/runtime-bridge/bridges/indusagi-cli.ts +155 -0
  188. package/src/runtime-bridge/broker.ts +227 -0
  189. package/src/runtime-bridge/contract.ts +122 -0
  190. package/src/runtime-bridge/index.ts +79 -0
  191. package/src/runtime-bridge/sink.ts +180 -0
  192. package/src/sessions/contract.ts +81 -0
  193. package/src/sessions/index.ts +13 -0
  194. package/src/sessions/library.ts +229 -0
  195. package/src/settings/contract.ts +114 -0
  196. package/src/settings/index.ts +32 -0
  197. package/src/settings/manager.ts +117 -0
  198. package/src/transcript-export/index.ts +45 -0
  199. package/src/transcript-export/publish.ts +260 -0
  200. package/src/transcript-export/sgr.ts +315 -0
  201. package/src/transcript-export/template.ts +272 -0
  202. package/src/transcript-export/theme-bridge.ts +150 -0
  203. package/src/window-budget/budget/estimate.ts +135 -0
  204. package/src/window-budget/budget/gate.ts +33 -0
  205. package/src/window-budget/budget/index.ts +16 -0
  206. package/src/window-budget/budget/slice.ts +56 -0
  207. package/src/window-budget/condenser.ts +58 -0
  208. package/src/window-budget/contract.ts +184 -0
  209. package/src/window-budget/index.ts +19 -0
  210. package/src/window-budget/microcompact.ts +95 -0
  211. package/src/window-budget/rehydrate.ts +136 -0
  212. package/src/window-budget/summarize/condense.ts +103 -0
  213. package/src/window-budget/summarize/index.ts +14 -0
  214. package/src/window-budget/summarize/prompt.ts +149 -0
  215. package/src/workflow-engine/agent-runner.ts +181 -0
  216. package/src/workflow-engine/display.ts +224 -0
  217. package/src/workflow-engine/engine.ts +294 -0
  218. package/src/workflow-engine/index.ts +23 -0
  219. package/src/workflow-engine/parse.ts +172 -0
  220. package/src/workflow-engine/structured-output.ts +35 -0
  221. package/src/workspace/brand.ts +29 -0
  222. package/src/workspace/index.ts +18 -0
  223. package/src/workspace/locator.ts +103 -0
  224. package/src/workspace/runtime-detect.ts +64 -0
@@ -0,0 +1,227 @@
1
+ import * as path from "node:path";
2
+ import { existsSync } from "node:fs";
3
+
4
+ export type DiagnosticSeverity = "Error" | "Warning" | "Info" | "Hint";
5
+ export interface Position { readonly line: number; readonly character: number }
6
+ export interface Diagnostic {
7
+ readonly message: string;
8
+ readonly severity: DiagnosticSeverity;
9
+ readonly range: { readonly start: Position; readonly end: Position };
10
+ readonly source?: string;
11
+ readonly code?: string | number;
12
+ }
13
+ export interface DiagnosticFile { readonly uri: string; readonly diagnostics: Diagnostic[] }
14
+ export interface DedupOptions { readonly maxPerFile?: number; readonly maxTotal?: number }
15
+ export type DiagnosticRunner = (cwd: string, signal?: AbortSignal) => Promise<DiagnosticFile[]>;
16
+ export interface DiagnosticsConfig {
17
+ readonly enabled?: boolean;
18
+ readonly runners?: DiagnosticRunner[];
19
+ readonly timeoutMs?: number;
20
+ readonly maxPerFile?: number;
21
+ readonly maxTotal?: number;
22
+ }
23
+
24
+ export const MAX_PER_FILE = 10;
25
+ export const MAX_TOTAL = 30;
26
+ export const MAX_SUMMARY_CHARS = 4000;
27
+ const DELIVERED_KEYS_CAP = 500;
28
+ const DEFAULT_TIMEOUT_MS = 30000;
29
+ const SEVERITY_RANK: Record<DiagnosticSeverity, number> = { Error: 0, Warning: 1, Info: 2, Hint: 3 };
30
+ const TS_JS_EXTENSIONS = new Set([".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"]);
31
+
32
+ export function createDiagnosticKey(diagnostic: Diagnostic): string {
33
+ const { start, end } = diagnostic.range;
34
+ return `${start.line}:${start.character}:${end.line}:${end.character}:${diagnostic.severity}:${diagnostic.code ?? ""}:${diagnostic.message.trim()}`;
35
+ }
36
+ export function areDiagnosticsEqual(a: Diagnostic, b: Diagnostic): boolean { return createDiagnosticKey(a) === createDiagnosticKey(b); }
37
+ function compareDiagnostics(a: Diagnostic, b: Diagnostic): number {
38
+ return SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity]
39
+ || a.range.start.line - b.range.start.line
40
+ || a.range.start.character - b.range.start.character;
41
+ }
42
+ function recordDelivered(delivered: Map<string, Set<string>>, uri: string, key: string): void {
43
+ let set = delivered.get(uri);
44
+ if (!set) { set = new Set(); delivered.set(uri, set); }
45
+ if (set.has(key)) return;
46
+ if (set.size >= DELIVERED_KEYS_CAP) {
47
+ const oldest = set.values().next().value;
48
+ if (oldest !== undefined) set.delete(oldest);
49
+ }
50
+ set.add(key);
51
+ }
52
+
53
+ export function deduplicateAndCap(files: readonly DiagnosticFile[], delivered: Map<string, Set<string>>, opts: DedupOptions = {}): DiagnosticFile[] {
54
+ const candidates: { uri: string; diagnostic: Diagnostic; key: string }[] = [];
55
+ for (const file of files) {
56
+ const prior = delivered.get(file.uri) ?? new Set<string>();
57
+ const seen = new Set<string>();
58
+ const kept = file.diagnostics.filter((diagnostic) => {
59
+ const key = createDiagnosticKey(diagnostic);
60
+ if (prior.has(key) || seen.has(key)) return false;
61
+ seen.add(key);
62
+ return true;
63
+ }).sort(compareDiagnostics).slice(0, opts.maxPerFile ?? MAX_PER_FILE);
64
+ for (const diagnostic of kept) candidates.push({ uri: file.uri, diagnostic, key: createDiagnosticKey(diagnostic) });
65
+ }
66
+ candidates.sort((a, b) => compareDiagnostics(a.diagnostic, b.diagnostic));
67
+ const grouped = new Map<string, Diagnostic[]>();
68
+ for (const candidate of candidates.slice(0, opts.maxTotal ?? MAX_TOTAL)) {
69
+ const bucket = grouped.get(candidate.uri) ?? [];
70
+ bucket.push(candidate.diagnostic);
71
+ grouped.set(candidate.uri, bucket);
72
+ recordDelivered(delivered, candidate.uri, candidate.key);
73
+ }
74
+ return [...grouped].map(([uri, diagnostics]) => ({ uri, diagnostics: diagnostics.sort(compareDiagnostics) }));
75
+ }
76
+
77
+ export function getSeveritySymbol(severity: DiagnosticSeverity): string {
78
+ return severity === "Error" ? "x" : severity === "Warning" ? "!" : severity === "Info" ? "i" : "*";
79
+ }
80
+ export function formatDiagnosticsSummary(files: readonly DiagnosticFile[], maxChars = MAX_SUMMARY_CHARS): string {
81
+ const lines: string[] = [];
82
+ for (const file of files) {
83
+ lines.push(file.uri);
84
+ for (const diagnostic of file.diagnostics) {
85
+ const code = diagnostic.code !== undefined && diagnostic.code !== "" ? ` ${diagnostic.code}` : "";
86
+ lines.push(` ${getSeveritySymbol(diagnostic.severity)} [${diagnostic.severity}]${code} (${diagnostic.range.start.line + 1}:${diagnostic.range.start.character + 1}) ${diagnostic.message.trim()}`);
87
+ }
88
+ }
89
+ const text = lines.join("\n");
90
+ return text.length <= maxChars ? text : text.slice(0, maxChars - 1) + "…";
91
+ }
92
+
93
+ async function loadSpawn() {
94
+ try { return (await import("node:child_process")).spawn; } catch { return undefined; }
95
+ }
96
+ function captureOutput(spawn: any, bin: string, args: string[], cwd: string, signal?: AbortSignal): Promise<string | undefined> {
97
+ return new Promise((resolve) => {
98
+ let settled = false;
99
+ const finish = (value?: string) => { if (!settled) { settled = true; resolve(value); } };
100
+ let child: any;
101
+ try { child = spawn(bin, args, { cwd, shell: false }); } catch { finish(); return; }
102
+ let buffer = "";
103
+ const abort = () => { try { child.kill(); } catch {} finish(); };
104
+ if (signal?.aborted) { abort(); return; }
105
+ signal?.addEventListener("abort", abort, { once: true });
106
+ child.stdout?.on("data", (chunk: unknown) => { buffer += String(chunk); });
107
+ child.stderr?.on("data", (chunk: unknown) => { buffer += String(chunk); });
108
+ child.on("error", () => finish());
109
+ child.on("close", () => finish(buffer));
110
+ });
111
+ }
112
+
113
+ export async function runTscDiagnostics(cwd: string, signal?: AbortSignal): Promise<DiagnosticFile[]> {
114
+ const spawn = await loadSpawn();
115
+ if (!spawn || signal?.aborted) return [];
116
+ const output = await captureOutput(spawn, path.join(cwd, "node_modules", ".bin", "tsc"), ["--noEmit", "--pretty", "false"], cwd, signal);
117
+ return output === undefined ? [] : parseTscOutput(output, cwd);
118
+ }
119
+ export function parseTscOutput(output: string, cwd: string): DiagnosticFile[] {
120
+ const regexp = /^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+(TS\d+):\s+(.*)$/;
121
+ const grouped = new Map<string, Diagnostic[]>();
122
+ for (const raw of output.split(/\r?\n/)) {
123
+ const match = regexp.exec(raw);
124
+ if (!match) continue;
125
+ const [, file, lineText, columnText, severity, code, message] = match;
126
+ const uri = path.isAbsolute(file) ? file : path.resolve(cwd, file);
127
+ const line = Math.max(0, Number(lineText) - 1);
128
+ const character = Math.max(0, Number(columnText) - 1);
129
+ const diagnostic: Diagnostic = { message, severity: severity === "warning" ? "Warning" : "Error", range: { start: { line, character }, end: { line, character } }, source: "tsc", code };
130
+ grouped.set(uri, [...(grouped.get(uri) ?? []), diagnostic]);
131
+ }
132
+ return [...grouped].map(([uri, diagnostics]) => ({ uri, diagnostics }));
133
+ }
134
+
135
+ export async function runEslintDiagnostics(files: readonly string[], cwd: string, signal?: AbortSignal): Promise<DiagnosticFile[]> {
136
+ if (files.length === 0) return [];
137
+ const spawn = await loadSpawn();
138
+ if (!spawn || signal?.aborted) return [];
139
+ const output = await captureOutput(spawn, path.join(cwd, "node_modules", ".bin", "eslint"), ["--format", "json", ...files], cwd, signal);
140
+ return output === undefined ? [] : parseEslintOutput(output, cwd);
141
+ }
142
+ export function parseEslintOutput(output: string, cwd: string): DiagnosticFile[] {
143
+ const start = output.indexOf("[");
144
+ const end = output.lastIndexOf("]");
145
+ if (start < 0 || end < start) return [];
146
+ let parsed: any[];
147
+ try { parsed = JSON.parse(output.slice(start, end + 1)); } catch { return []; }
148
+ const result: DiagnosticFile[] = [];
149
+ for (const file of parsed) {
150
+ if (!Array.isArray(file.messages) || file.messages.length === 0) continue;
151
+ const uri = path.isAbsolute(file.filePath) ? file.filePath : path.resolve(cwd, file.filePath);
152
+ const diagnostics = file.messages.map((message: any): Diagnostic => ({
153
+ message: message.message,
154
+ severity: message.severity === 2 ? "Error" : "Warning",
155
+ range: {
156
+ start: { line: Math.max(0, (message.line ?? 1) - 1), character: Math.max(0, (message.column ?? 1) - 1) },
157
+ end: { line: Math.max(0, (message.endLine ?? message.line ?? 1) - 1), character: Math.max(0, (message.endColumn ?? message.column ?? 1) - 1) },
158
+ },
159
+ source: "eslint",
160
+ ...(message.ruleId ? { code: message.ruleId } : {}),
161
+ }));
162
+ result.push({ uri, diagnostics });
163
+ }
164
+ return result;
165
+ }
166
+
167
+ export class DiagnosticsEngine {
168
+ readonly #cwd: string;
169
+ readonly #enabled: boolean;
170
+ readonly #runners: DiagnosticRunner[];
171
+ readonly #timeoutMs: number;
172
+ readonly #maxPerFile: number;
173
+ readonly #maxTotal: number;
174
+ readonly #delivered = new Map<string, Set<string>>();
175
+ #baseline?: Map<string, Set<string>>;
176
+
177
+ constructor(cwd: string, config: DiagnosticsConfig = {}) {
178
+ this.#cwd = cwd;
179
+ this.#enabled = config.enabled ?? true;
180
+ this.#runners = config.runners ?? [runTscDiagnostics];
181
+ this.#timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;
182
+ this.#maxPerFile = config.maxPerFile ?? MAX_PER_FILE;
183
+ this.#maxTotal = config.maxTotal ?? MAX_TOTAL;
184
+ }
185
+ get enabled(): boolean { return this.#enabled; }
186
+ get hasBaseline(): boolean { return this.#baseline !== undefined; }
187
+ async seedBaseline(signal?: AbortSignal): Promise<void> {
188
+ if (!this.#enabled || this.#baseline !== undefined) return;
189
+ let files: DiagnosticFile[] = [];
190
+ try { files = await this.#runAll(signal); } catch {}
191
+ this.#baseline = new Map(files.map((file) => [file.uri, new Set(file.diagnostics.map(createDiagnosticKey))]));
192
+ }
193
+ async newDiagnostics(editedPaths: readonly string[], signal?: AbortSignal): Promise<DiagnosticFile[]> {
194
+ if (!this.#enabled || editedPaths.length === 0) return [];
195
+ const all = await this.#runAll(signal);
196
+ if (this.#baseline === undefined) {
197
+ this.#baseline = new Map(all.map((file) => [file.uri, new Set(file.diagnostics.map(createDiagnosticKey))]));
198
+ return [];
199
+ }
200
+ const edited = new Set(editedPaths.map((file) => path.resolve(this.#cwd, file)));
201
+ const candidates = all.filter((file) => edited.has(file.uri)).map((file) => ({ uri: file.uri, diagnostics: file.diagnostics.filter((diagnostic) => !(this.#baseline?.get(file.uri) ?? new Set()).has(createDiagnosticKey(diagnostic))) })).filter((file) => file.diagnostics.length > 0);
202
+ return deduplicateAndCap(candidates, this.#delivered, { maxPerFile: this.#maxPerFile, maxTotal: this.#maxTotal });
203
+ }
204
+ clearDeliveredForFile(uri: string): void { this.#delivered.delete(path.resolve(this.#cwd, uri)); }
205
+ reset(): void { this.#delivered.clear(); this.#baseline = undefined; }
206
+ async #runAll(signal?: AbortSignal): Promise<DiagnosticFile[]> {
207
+ const merged = new Map<string, Diagnostic[]>();
208
+ for (const runner of this.#runners) {
209
+ const controller = new AbortController();
210
+ const timer = setTimeout(() => controller.abort(), this.#timeoutMs);
211
+ const abort = () => controller.abort();
212
+ if (signal?.aborted) controller.abort(); else signal?.addEventListener("abort", abort, { once: true });
213
+ let files: DiagnosticFile[] = [];
214
+ try { files = await runner(this.#cwd, controller.signal); } catch {} finally { clearTimeout(timer); signal?.removeEventListener("abort", abort); }
215
+ for (const file of files) merged.set(file.uri, [...(merged.get(file.uri) ?? []), ...file.diagnostics]);
216
+ }
217
+ return [...merged].map(([uri, diagnostics]) => ({ uri, diagnostics }));
218
+ }
219
+ }
220
+
221
+ export function isTypeScriptOrJs(filePath: string): boolean { return TS_JS_EXTENSIONS.has(path.extname(filePath).toLowerCase()); }
222
+ export function hasTsConfig(cwd: string): boolean { try { return existsSync(path.join(cwd, "tsconfig.json")); } catch { return false; } }
223
+ export function hasEslintConfig(cwd: string): boolean {
224
+ try {
225
+ return ["eslint.config.js", "eslint.config.mjs", "eslint.config.cjs", ".eslintrc", ".eslintrc.js", ".eslintrc.cjs", ".eslintrc.json", ".eslintrc.yml", ".eslintrc.yaml"].some((name) => existsSync(path.join(cwd, name)));
226
+ } catch { return false; }
227
+ }
@@ -0,0 +1,33 @@
1
+ // @ts-nocheck
2
+ // Type declarations recovered from dist/types (no runtime body)
3
+ /**
4
+ * Conductor subsystem — public barrel.
5
+ *
6
+ * Re-exports the FROZEN Phase-2 contract: the product-level signal stream
7
+ * ({@link SessionSignal}), the typed fault model ({@link ConductorFault} +
8
+ * {@link conductorFault}), the on-disk transcript schema ({@link TranscriptEntry},
9
+ * {@link SessionHead}, {@link TRANSCRIPT_SCHEMA}), the model catalog/matcher
10
+ * reference types ({@link ModelCardRef}, {@link MatchQuery}), the immutable
11
+ * state snapshot ({@link ConductorState}), and the {@link SessionConductor}
12
+ * interface plus its {@link SessionConductorOptions}.
13
+ *
14
+ * Behavior modules (signal hub, transcript store, model catalog/matcher,
15
+ * conductor factory, the conductor itself) are added to this barrel as they
16
+ * land; consumers import the conductor surface from `src/conductor` rather than
17
+ * reaching into individual modules.
18
+ */
19
+ export type { FaultKind, ConductorFault, SessionSignal, SignalKind, SignalOf, SignalHandler, TranscriptSchema, TranscriptRole, TranscriptEntry, SessionHead, ModelCardRef, MatchQuery, ConductorPhase, ConductorState, QueueMode, QueuedInput, SessionStats, ExecuteBashOptions, BashOutcome, SessionConductor, SessionConductorOptions, CondenseOutcome, AgentMessage, AgentTool, CanUseToolFn, ThinkingLevel, Model, Usage, KnownProvider, PermissionMode, } from "./contract.js";
20
+ export { conductorFault, TRANSCRIPT_SCHEMA } from "./contract.js";
21
+ export { createSessionConductor, reduceState, noopCondense, withGatewayBaseUrl, type AgentLike, type ConductorDeps, type CondenseFn, type RetryPolicy, } from "./conductor.js";
22
+ export { SignalHub, translateAgentEvent, type SignalHubOptions } from "./signal-hub/index.js";
23
+ export { ModelCatalog, ModelMatcher, canonicalId, toCardRef, type CatalogCard, type CatalogSource, type ResolveInput, } from "./catalog/index.js";
24
+ export { TranscriptStore, memoryBackend, fsBackend, replay, type TranscriptBackend, type TranscriptState, type TranscriptClock, type TranscriptStoreOptions, } from "./transcript-store/index.js";
25
+ export { parseSkillInvocation, type SkillInvocation } from "./skill-parse/index.js";
26
+ export { resolveRuleDecision, parseRule, makeRule, toolMatchesRule, createPermissionGate, createSubagentPermissionGate, collectReadOnlyToolNames, allowAlwaysRuleStrings, isReadOnlyToolName, isEditToolName, READ_ONLY_TOOL_NAMES, EDIT_TOOL_NAMES, type PermissionBehavior, type PermissionRule, type PermissionDecision, type CanUseToolFn as PermissionCanUseToolFn, type ApprovalChoice, type ApprovalOutcome, type ApprovalResolver, type PermissionGateConfig, type SessionPermissionPolicy, } from "./permissions.js";
27
+ export { parseBashCommand, catastrophicReason, isCatastrophicCommand, evaluateCatastrophic, bashSubcommandSubjects, type ParsedCommand, } from "./bash-guard.js";
28
+ export { DiagnosticsEngine, createDiagnosticKey, deduplicateAndCap, formatDiagnosticsSummary, getSeveritySymbol, parseTscOutput, parseEslintOutput, runTscDiagnostics, runEslintDiagnostics, hasTsConfig, hasEslintConfig, isTypeScriptOrJs, areDiagnosticsEqual, MAX_PER_FILE, MAX_TOTAL, MAX_SUMMARY_CHARS, type Diagnostic, type DiagnosticFile, type DiagnosticSeverity, type DiagnosticsConfig, type DiagnosticRunner, type DedupOptions, type Position, } from "./diagnostics.js";
29
+ export { provisionDeck } from "../capability-deck/provision.js";
30
+ export { isPermissionMode } from "../settings/contract.js";
31
+ export { RESTORED_FILE_PREFIX } from "../window-budget/rehydrate.js";
32
+ export { readClipboardImage } from "../kit/clipboard-image.js";
33
+ export { openInExternalEditor } from "../kit/external-editor.js";