@plune-ai/cairn 0.5.0 → 0.6.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 (176) hide show
  1. package/README.md +10 -4
  2. package/dist/agent/graph.d.ts +17 -0
  3. package/dist/agent/graph.d.ts.map +1 -1
  4. package/dist/agent/graph.js +36 -6
  5. package/dist/agent/graph.js.map +1 -1
  6. package/dist/agent/index.d.ts +22 -0
  7. package/dist/agent/index.d.ts.map +1 -1
  8. package/dist/agent/index.js +137 -51
  9. package/dist/agent/index.js.map +1 -1
  10. package/dist/agent/summary.d.ts +11 -0
  11. package/dist/agent/summary.d.ts.map +1 -1
  12. package/dist/agent/summary.js +10 -0
  13. package/dist/agent/summary.js.map +1 -1
  14. package/dist/analyze/index.d.ts +2 -0
  15. package/dist/analyze/index.d.ts.map +1 -1
  16. package/dist/analyze/index.js +1 -0
  17. package/dist/analyze/index.js.map +1 -1
  18. package/dist/api/adversarial.d.ts +38 -0
  19. package/dist/api/adversarial.d.ts.map +1 -0
  20. package/dist/api/adversarial.js +175 -0
  21. package/dist/api/adversarial.js.map +1 -0
  22. package/dist/api/cases.d.ts +105 -0
  23. package/dist/api/cases.d.ts.map +1 -0
  24. package/dist/api/cases.js +256 -0
  25. package/dist/api/cases.js.map +1 -0
  26. package/dist/api/coverage.d.ts +51 -0
  27. package/dist/api/coverage.d.ts.map +1 -0
  28. package/dist/api/coverage.js +80 -0
  29. package/dist/api/coverage.js.map +1 -0
  30. package/dist/api/openapi.d.ts +84 -0
  31. package/dist/api/openapi.d.ts.map +1 -0
  32. package/dist/api/openapi.js +119 -0
  33. package/dist/api/openapi.js.map +1 -0
  34. package/dist/api/runner.d.ts +58 -0
  35. package/dist/api/runner.d.ts.map +1 -0
  36. package/dist/api/runner.js +285 -0
  37. package/dist/api/runner.js.map +1 -0
  38. package/dist/api/scenario-runner.d.ts +22 -0
  39. package/dist/api/scenario-runner.d.ts.map +1 -0
  40. package/dist/api/scenario-runner.js +132 -0
  41. package/dist/api/scenario-runner.js.map +1 -0
  42. package/dist/api/scenarios.d.ts +31 -0
  43. package/dist/api/scenarios.d.ts.map +1 -0
  44. package/dist/api/scenarios.js +71 -0
  45. package/dist/api/scenarios.js.map +1 -0
  46. package/dist/api/testcase-docs.d.ts +12 -0
  47. package/dist/api/testcase-docs.d.ts.map +1 -0
  48. package/dist/api/testcase-docs.js +22 -0
  49. package/dist/api/testcase-docs.js.map +1 -0
  50. package/dist/artifacts/index.d.ts +2 -0
  51. package/dist/artifacts/index.d.ts.map +1 -1
  52. package/dist/artifacts/index.js +3 -0
  53. package/dist/artifacts/index.js.map +1 -1
  54. package/dist/artifacts/report.d.ts +21 -0
  55. package/dist/artifacts/report.d.ts.map +1 -1
  56. package/dist/artifacts/report.js +49 -0
  57. package/dist/artifacts/report.js.map +1 -1
  58. package/dist/artifacts/testcase-md.d.ts +27 -0
  59. package/dist/artifacts/testcase-md.d.ts.map +1 -1
  60. package/dist/artifacts/testcase-md.js +61 -0
  61. package/dist/artifacts/testcase-md.js.map +1 -1
  62. package/dist/checklist/index.d.ts +7 -0
  63. package/dist/checklist/index.d.ts.map +1 -1
  64. package/dist/checklist/index.js +14 -0
  65. package/dist/checklist/index.js.map +1 -1
  66. package/dist/ci/github.d.ts +83 -0
  67. package/dist/ci/github.d.ts.map +1 -0
  68. package/dist/ci/github.js +104 -0
  69. package/dist/ci/github.js.map +1 -0
  70. package/dist/ci/index.d.ts +14 -0
  71. package/dist/ci/index.d.ts.map +1 -0
  72. package/dist/ci/index.js +35 -0
  73. package/dist/ci/index.js.map +1 -0
  74. package/dist/ci/inputs.d.ts +93 -0
  75. package/dist/ci/inputs.d.ts.map +1 -0
  76. package/dist/ci/inputs.js +100 -0
  77. package/dist/ci/inputs.js.map +1 -0
  78. package/dist/ci/run.d.ts +51 -0
  79. package/dist/ci/run.d.ts.map +1 -0
  80. package/dist/ci/run.js +207 -0
  81. package/dist/ci/run.js.map +1 -0
  82. package/dist/ci/summary.d.ts +42 -0
  83. package/dist/ci/summary.d.ts.map +1 -0
  84. package/dist/ci/summary.js +45 -0
  85. package/dist/ci/summary.js.map +1 -0
  86. package/dist/cli/index.d.ts.map +1 -1
  87. package/dist/cli/index.js +45 -4
  88. package/dist/cli/index.js.map +1 -1
  89. package/dist/codegen/index.d.ts +13 -1
  90. package/dist/codegen/index.d.ts.map +1 -1
  91. package/dist/codegen/index.js +75 -0
  92. package/dist/codegen/index.js.map +1 -1
  93. package/dist/config/index.d.ts.map +1 -1
  94. package/dist/config/index.js +9 -0
  95. package/dist/config/index.js.map +1 -1
  96. package/dist/config/profiles.d.ts +6 -0
  97. package/dist/config/profiles.d.ts.map +1 -1
  98. package/dist/config/profiles.js +13 -0
  99. package/dist/config/profiles.js.map +1 -1
  100. package/dist/config/schema.d.ts +6 -0
  101. package/dist/config/schema.d.ts.map +1 -1
  102. package/dist/core/modalities/api.d.ts +27 -0
  103. package/dist/core/modalities/api.d.ts.map +1 -0
  104. package/dist/core/modalities/api.js +321 -0
  105. package/dist/core/modalities/api.js.map +1 -0
  106. package/dist/core/modalities/explore.d.ts.map +1 -1
  107. package/dist/core/modalities/explore.js +9 -1
  108. package/dist/core/modalities/explore.js.map +1 -1
  109. package/dist/core/registry.d.ts.map +1 -1
  110. package/dist/core/registry.js +4 -1
  111. package/dist/core/registry.js.map +1 -1
  112. package/dist/design/index.d.ts +2 -0
  113. package/dist/design/index.d.ts.map +1 -1
  114. package/dist/design/index.js +1 -0
  115. package/dist/design/index.js.map +1 -1
  116. package/dist/documentarian/index.d.ts +53 -0
  117. package/dist/documentarian/index.d.ts.map +1 -0
  118. package/dist/documentarian/index.js +135 -0
  119. package/dist/documentarian/index.js.map +1 -0
  120. package/dist/index.d.ts +2 -1
  121. package/dist/index.d.ts.map +1 -1
  122. package/dist/knowledge/index.d.ts +30 -4
  123. package/dist/knowledge/index.d.ts.map +1 -1
  124. package/dist/knowledge/index.js +80 -22
  125. package/dist/knowledge/index.js.map +1 -1
  126. package/dist/llm/index.d.ts +2 -2
  127. package/dist/llm/index.d.ts.map +1 -1
  128. package/dist/llm/index.js +1 -1
  129. package/dist/llm/index.js.map +1 -1
  130. package/dist/llm/routing.d.ts.map +1 -1
  131. package/dist/llm/routing.js +8 -2
  132. package/dist/llm/routing.js.map +1 -1
  133. package/dist/llm/structured.d.ts +22 -0
  134. package/dist/llm/structured.d.ts.map +1 -1
  135. package/dist/llm/structured.js +42 -0
  136. package/dist/llm/structured.js.map +1 -1
  137. package/dist/mcp/server.d.ts +9 -0
  138. package/dist/mcp/server.d.ts.map +1 -0
  139. package/dist/mcp/server.js +49 -0
  140. package/dist/mcp/server.js.map +1 -0
  141. package/dist/mcp/tools.d.ts +149 -0
  142. package/dist/mcp/tools.d.ts.map +1 -0
  143. package/dist/mcp/tools.js +138 -0
  144. package/dist/mcp/tools.js.map +1 -0
  145. package/dist/project/index.d.ts +70 -0
  146. package/dist/project/index.d.ts.map +1 -0
  147. package/dist/project/index.js +173 -0
  148. package/dist/project/index.js.map +1 -0
  149. package/dist/prompts/local/identify-elements.d.ts +1 -1
  150. package/dist/prompts/local/identify-elements.d.ts.map +1 -1
  151. package/dist/prompts/local/identify-elements.js +5 -2
  152. package/dist/prompts/local/identify-elements.js.map +1 -1
  153. package/dist/prompts/local/qa-testcase-from-ui.d.ts +1 -1
  154. package/dist/prompts/local/qa-testcase-from-ui.d.ts.map +1 -1
  155. package/dist/prompts/local/qa-testcase-from-ui.js +2 -0
  156. package/dist/prompts/local/qa-testcase-from-ui.js.map +1 -1
  157. package/dist/tui/hooks/use-runs.d.ts.map +1 -1
  158. package/dist/tui/hooks/use-runs.js +4 -1
  159. package/dist/tui/hooks/use-runs.js.map +1 -1
  160. package/dist/tui/screens/runs-list-screen.d.ts.map +1 -1
  161. package/dist/tui/screens/runs-list-screen.js +3 -1
  162. package/dist/tui/screens/runs-list-screen.js.map +1 -1
  163. package/dist/tui/screens/summary-screen.d.ts.map +1 -1
  164. package/dist/tui/screens/summary-screen.js +1 -1
  165. package/dist/tui/screens/summary-screen.js.map +1 -1
  166. package/dist/tui/types.d.ts +7 -1
  167. package/dist/tui/types.d.ts.map +1 -1
  168. package/dist/validate/index.d.ts +7 -3
  169. package/dist/validate/index.d.ts.map +1 -1
  170. package/dist/validate/index.js +22 -3
  171. package/dist/validate/index.js.map +1 -1
  172. package/dist/validate/runner.d.ts +61 -1
  173. package/dist/validate/runner.d.ts.map +1 -1
  174. package/dist/validate/runner.js +67 -4
  175. package/dist/validate/runner.js.map +1 -1
  176. package/package.json +5 -1
@@ -0,0 +1,135 @@
1
+ /**
2
+ * BORROW-06 (#93) — Documentarian: a cached, reusable page-understanding artifact.
3
+ *
4
+ * Decouples "understand the page" from "generate tests": a run turns the live page into a strict-schema
5
+ * {@link InteractionMap} (element → locator + container + candidate actions) and caches it keyed by
6
+ * `url + page fingerprint`. A second run on the SAME page (identical ARIA → identical fingerprint) reuses
7
+ * the cached understanding and SKIPS the ground LLM call (`analyzePage`), so it makes fewer observe/ground
8
+ * LLM calls. The map is assembled DETERMINISTICALLY from what observe/verify/probe already produce — no
9
+ * extra LLM call is introduced (idea borrowed from explorbot's doc-collector; strict schema per #89).
10
+ *
11
+ * Cache invalidation is deliberate: the key embeds a fingerprint of the page's ARIA snapshot, so any
12
+ * structural change to the page misses the cache and re-grounds. Cross-run / per-app memory (semantic
13
+ * retrieval) is OUT of scope here — that is MEM-02 (#64).
14
+ */
15
+ import { createHash } from "node:crypto";
16
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
17
+ import { join } from "node:path";
18
+ import { z } from "zod";
19
+ import { locatorFor } from "../artifacts/report.js";
20
+ /** Bump when the artifact shape changes → older cached files are treated as a miss. */
21
+ export const UNDERSTANDING_SCHEMA_VERSION = 1;
22
+ /** One interactive element, distilled for reuse: a stable locator + how it can be driven. */
23
+ export const InteractionElementSchema = z.object({
24
+ ref: z.string(),
25
+ role: z.string(),
26
+ name: z.string().optional(),
27
+ /** Playwright locator expression (getByRole(...), `.first()` for repeated elements). */
28
+ locator: z.string(),
29
+ /** The view/tab this element lives behind, when known (multi-state pages). */
30
+ container: z.string().optional(),
31
+ /** Actions the element affords: click | fill | check | assertVisible. */
32
+ candidateActions: z.array(z.string()),
33
+ });
34
+ /** The cached page-understanding artifact: page semantics + the interaction map. */
35
+ export const InteractionMapSchema = z.object({
36
+ schemaVersion: z.number(),
37
+ url: z.string(),
38
+ /** Hash of the page's ARIA snapshot — the cache key for deliberate invalidation on page change. */
39
+ fingerprint: z.string(),
40
+ pageSemantics: z.string(),
41
+ primaryRefs: z.array(z.string()),
42
+ viewSwitchers: z.array(z.string()),
43
+ elements: z.array(InteractionElementSchema),
44
+ });
45
+ /** Page fingerprint = hash of the ARIA snapshot. Same ARIA ⇒ same refs ⇒ cached understanding is valid. */
46
+ export function fingerprintPage(study) {
47
+ return createHash("sha256").update(study.ariaYaml).digest("hex").slice(0, 16);
48
+ }
49
+ /** Actions an element affords — from its role, plus any observed act→observe transition. */
50
+ function candidateActionsFor(el, transitions) {
51
+ const acts = new Set();
52
+ const r = el.role.toLowerCase();
53
+ if (/button|link|tab|menuitem|option/.test(r))
54
+ acts.add("click");
55
+ if (/textbox|searchbox|combobox|spinbutton/.test(r))
56
+ acts.add("fill");
57
+ if (/checkbox|switch|radio/.test(r))
58
+ acts.add("check");
59
+ if (transitions.some((t) => t.ref === el.ref))
60
+ acts.add("click"); // a real observed transition
61
+ if (acts.size === 0)
62
+ acts.add("assertVisible"); // non-interactive → static check only
63
+ return [...acts];
64
+ }
65
+ /**
66
+ * Assemble the interaction map deterministically from this run's observe/ground/verify/probe outputs.
67
+ * No LLM call: locators come from {@link locatorFor}, actions from role + observed transitions, and the
68
+ * container from the element's tab/view switcher when present.
69
+ */
70
+ export function buildInteractionMap(study, analysis, verified, transitions, fingerprint) {
71
+ const elements = verified
72
+ .filter((v) => v.count >= 1)
73
+ .map((v) => ({
74
+ ref: v.ref,
75
+ role: v.role,
76
+ name: v.name,
77
+ locator: `${locatorFor(v)}${v.count > 1 ? ".first()" : ""}`,
78
+ // ponytail: container = the tab/view the element sits behind (known deterministically). Richer
79
+ // landmark/region inference from the ARIA tree is a follow-up if reviewers want it.
80
+ container: v.viaSwitcher ? `${v.viaSwitcher.role} "${v.viaSwitcher.name ?? ""}"` : undefined,
81
+ candidateActions: candidateActionsFor(v, transitions),
82
+ }));
83
+ return {
84
+ schemaVersion: UNDERSTANDING_SCHEMA_VERSION,
85
+ url: study.url,
86
+ fingerprint,
87
+ pageSemantics: analysis.pageSemantics,
88
+ primaryRefs: analysis.primaryRefs,
89
+ viewSwitchers: analysis.viewSwitchers,
90
+ elements,
91
+ };
92
+ }
93
+ /** Re-derive a {@link PageAnalysis} from a cached map (grounded against the current refs). */
94
+ export function analysisFromMap(map, currentRefs) {
95
+ return {
96
+ pageSemantics: map.pageSemantics,
97
+ primaryRefs: map.primaryRefs.filter((r) => currentRefs.has(r)),
98
+ viewSwitchers: map.viewSwitchers.filter((r) => currentRefs.has(r)),
99
+ };
100
+ }
101
+ /** Stable, filesystem-safe cache filename for a URL (the page is disambiguated by the fingerprint inside). */
102
+ function cacheFile(cacheDir, url) {
103
+ return join(cacheDir, `${createHash("sha256").update(url).digest("hex").slice(0, 16)}.json`);
104
+ }
105
+ /**
106
+ * Load a cached understanding for `url` IFF it matches the current page `fingerprint` and schema version.
107
+ * A miss (no file, stale fingerprint, old/corrupt shape) returns undefined → the caller re-grounds.
108
+ */
109
+ export async function loadUnderstanding(cacheDir, url, fingerprint) {
110
+ try {
111
+ const parsed = InteractionMapSchema.safeParse(JSON.parse(await readFile(cacheFile(cacheDir, url), "utf8")));
112
+ if (!parsed.success)
113
+ return undefined; // old/corrupt shape → miss
114
+ const map = parsed.data;
115
+ if (map.schemaVersion !== UNDERSTANDING_SCHEMA_VERSION)
116
+ return undefined;
117
+ if (map.url !== url || map.fingerprint !== fingerprint)
118
+ return undefined; // page changed → invalidate
119
+ return map;
120
+ }
121
+ catch {
122
+ return undefined; // no cache yet → miss
123
+ }
124
+ }
125
+ /** Persist the understanding to the cross-run cache. Best-effort: a write failure never breaks a run. */
126
+ export async function saveUnderstanding(cacheDir, map) {
127
+ try {
128
+ await mkdir(cacheDir, { recursive: true });
129
+ await writeFile(cacheFile(cacheDir, map.url), JSON.stringify(map, null, 2), "utf8");
130
+ }
131
+ catch {
132
+ // cache write is best-effort
133
+ }
134
+ }
135
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/documentarian/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,uFAAuF;AACvF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAE9C,6FAA6F;AAC7F,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,wFAAwF;IACxF,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,8EAA8E;IAC9E,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,yEAAyE;IACzE,gBAAgB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CACtC,CAAC,CAAC;AAGH,oFAAoF;AACpF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC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YAAE,OAAO,SAAS,CAAC,CAAC,4BAA4B;QACtG,OAAO,GAAG,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC,CAAC,sBAAsB;IAC1C,CAAC;AACH,CAAC;AAED,yGAAyG;AACzG,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,QAAgB,EAAE,GAAmB;IAC3E,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3C,MAAM,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACtF,CAAC;IAAC,MAAM,CAAC;QACP,6BAA6B;IAC/B,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -12,10 +12,11 @@ export { renderRunSummary } from "./agent/summary.js";
12
12
  export type { BudgetReport, RunSummaryInput } from "./agent/summary.js";
13
13
  export type { TestCase, DesignedCase } from "./design/index.js";
14
14
  export type { PageStudy } from "./observe/index.js";
15
+ export type { InteractionMap, InteractionElement } from "./documentarian/index.js";
15
16
  export type { GeneratedSuite } from "./codegen/index.js";
16
17
  export type { Score } from "./eval/scorers.js";
17
18
  export type { PilotVerdict } from "./eval/pilot.js";
18
- export type { ValidationReport } from "./validate/index.js";
19
+ export type { ValidationReport, ScreencastEntry, ScreencastChapter } from "./validate/index.js";
19
20
  export type { ChecklistItem } from "./checklist/index.js";
20
21
  export type { ElementRef, VerifiedElement, StorageState, BackendKind } from "./browser/index.js";
21
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,QAAQ,EAAG,iBAA0B,CAAC;AACnD,qFAAqF;AACrF,eAAO,MAAM,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which run kind it applies to. */
2
+ export type KnowledgeScope = "web" | "api" | "all";
3
+ /** Run scope — a web run injects web+all, an api run injects api+all. */
4
+ export type RunScope = "web" | "api";
5
+ /** What a knowledge run is looking for: its kind + the target it matches file keys against. */
6
+ export interface KnowledgeQuery {
7
+ /** Run scope. Default "web" (back-compat — existing `url:` files stay web-scoped). */
8
+ scope?: RunScope;
9
+ /** Web run target (page URL) — matched against a file's url/path/endpoint key. */
10
+ url?: string;
11
+ /** API run target (endpoint/path) — matched the same way for api-scoped files. #22 wires this. */
12
+ endpoint?: string;
13
+ }
1
14
  /**
2
- * Load domain knowledge (.md with credentials/validation rules/notes), URL-matched (idea from explorbot).
3
- * A file without `url:` is global (always applied); with `url:` only when the pattern is contained in the page URL.
4
- * Injected into the design prompt → the bot knows facts not visible in the snapshot (reduces the oracle gap).
15
+ * Load domain knowledge (.md with credentials/validation rules/notes), scope- and key-matched
16
+ * (idea from explorbot's `KnowledgeTracker`, #92). Directory convention: `dir/` = web (keyed by
17
+ * `url:`), `dir/api/` = api (keyed by `path:`/`endpoint:`); an explicit `scope:` front-matter
18
+ * (web | api | all) overrides the directory default. `scope: all` (e.g. shared credentials) is
19
+ * available to BOTH web and api runs.
20
+ *
21
+ * A file is injected when its scope matches the run (`run scope` or `all`) AND its key pattern is
22
+ * contained in the run target (web → url, api → endpoint); a file with no key is global within its
23
+ * scope. Back-compat: a base-dir file without `scope:` is web — existing `url:` files behave exactly
24
+ * as before. Injected into the design prompt → the bot knows facts not visible in the snapshot.
5
25
  */
6
- export declare function loadKnowledge(dir: string, url: string): Promise<string>;
26
+ export declare function loadKnowledge(dir: string, query?: KnowledgeQuery): Promise<string>;
27
+ /**
28
+ * Auth/headers for an API run, gathered from matching api/all-scope knowledge (#92) — the runner (#133)
29
+ * merges these under the user's config headers (config wins). `${ENV}` placeholders in a file resolve
30
+ * from `process.env`, so the credential itself lives in the environment, never in the committed file.
31
+ */
32
+ export declare function loadApiCreds(dir: string, query?: KnowledgeQuery): Promise<Record<string, string>>;
7
33
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/knowledge/index.ts"],"names":[],"mappings":"AAeA;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiB7E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/knowledge/index.ts"],"names":[],"mappings":"AAGA,+EAA+E;AAC/E,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAEnD,yEAAyE;AACzE,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC;AAErC,+FAA+F;AAC/F,MAAM,WAAW,cAAc;IAC7B,sFAAsF;IACtF,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,kFAAkF;IAClF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kGAAkG;IAClG,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAoDD;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,cAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAO5F;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,cAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAM3G"}
@@ -1,39 +1,97 @@
1
1
  import { readdir, readFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- /** url pattern from frontmatter (the `url: ...` line), if present. */
4
- function frontmatterUrl(raw) {
3
+ function parseFrontmatter(raw) {
5
4
  const fm = raw.match(/^---\r?\n([\s\S]*?)\r?\n---/);
6
5
  if (!fm?.[1])
7
- return undefined;
8
- const line = fm[1].split(/\r?\n/).find((l) => /^url:/.test(l.trim()));
9
- return line ? line.replace(/^\s*url:\s*/, "").trim() : undefined;
6
+ return { headers: {} };
7
+ const lines = fm[1].split(/\r?\n/).map((l) => l.trim());
8
+ const value = (key) => {
9
+ const line = lines.find((l) => new RegExp(`^${key}:`).test(l));
10
+ return line ? line.replace(new RegExp(`^${key}:\\s*`), "").trim() : undefined;
11
+ };
12
+ const rawScope = value("scope")?.toLowerCase();
13
+ // Only a recognized value counts; an empty/unknown scope falls back to the directory default.
14
+ const scope = rawScope === "web" || rawScope === "api" || rawScope === "all" ? rawScope : undefined;
15
+ // Key precedence: url || path || endpoint (a single file declares one of them).
16
+ const pattern = value("url") ?? value("path") ?? value("endpoint");
17
+ // `header.<Name>: <value>` — collect auth/headers; resolve `${ENV}` so secrets stay out of the file.
18
+ const headers = {};
19
+ for (const l of lines) {
20
+ const m = l.match(/^header\.([^:]+):\s*(.*)$/);
21
+ if (m)
22
+ headers[m[1].trim()] = expandEnv(m[2].trim());
23
+ }
24
+ return { scope, pattern, headers };
25
+ }
26
+ /** Replace `${VAR}` with `process.env.VAR` (empty if unset) so credentials live in env, not files. */
27
+ function expandEnv(v) {
28
+ return v.replace(/\$\{([^}]+)\}/g, (_, name) => process.env[name] ?? "");
10
29
  }
11
30
  function stripFrontmatter(raw) {
12
31
  return raw.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, "").trim();
13
32
  }
14
- /**
15
- * Load domain knowledge (.md with credentials/validation rules/notes), URL-matched (idea from explorbot).
16
- * A file without `url:` is global (always applied); with `url:` only when the pattern is contained in the page URL.
17
- * Injected into the design prompt → the bot knows facts not visible in the snapshot (reduces the oracle gap).
18
- */
19
- export async function loadKnowledge(dir, url) {
20
- let files = [];
33
+ /** List `*.md` under `dir` (non-recursive); missing dir → []. */
34
+ async function mdFiles(dir) {
21
35
  try {
22
- files = (await readdir(dir)).filter((f) => f.endsWith(".md"));
36
+ return (await readdir(dir)).filter((f) => f.endsWith(".md"));
23
37
  }
24
38
  catch {
25
- return "";
39
+ return [];
26
40
  }
41
+ }
42
+ /**
43
+ * Load domain knowledge (.md with credentials/validation rules/notes), scope- and key-matched
44
+ * (idea from explorbot's `KnowledgeTracker`, #92). Directory convention: `dir/` = web (keyed by
45
+ * `url:`), `dir/api/` = api (keyed by `path:`/`endpoint:`); an explicit `scope:` front-matter
46
+ * (web | api | all) overrides the directory default. `scope: all` (e.g. shared credentials) is
47
+ * available to BOTH web and api runs.
48
+ *
49
+ * A file is injected when its scope matches the run (`run scope` or `all`) AND its key pattern is
50
+ * contained in the run target (web → url, api → endpoint); a file with no key is global within its
51
+ * scope. Back-compat: a base-dir file without `scope:` is web — existing `url:` files behave exactly
52
+ * as before. Injected into the design prompt → the bot knows facts not visible in the snapshot.
53
+ */
54
+ export async function loadKnowledge(dir, query = {}) {
27
55
  const parts = [];
28
- for (const f of files) {
29
- const raw = await readFile(join(dir, f), "utf8");
30
- const pattern = frontmatterUrl(raw);
31
- if (!pattern || url.includes(pattern)) {
32
- const body = stripFrontmatter(raw);
33
- if (body.length > 0)
34
- parts.push(body);
35
- }
56
+ for (const { raw } of await matchingFiles(dir, query)) {
57
+ const body = stripFrontmatter(raw);
58
+ if (body.length > 0)
59
+ parts.push(body);
36
60
  }
37
61
  return parts.join("\n\n");
38
62
  }
63
+ /**
64
+ * Auth/headers for an API run, gathered from matching api/all-scope knowledge (#92) — the runner (#133)
65
+ * merges these under the user's config headers (config wins). `${ENV}` placeholders in a file resolve
66
+ * from `process.env`, so the credential itself lives in the environment, never in the committed file.
67
+ */
68
+ export async function loadApiCreds(dir, query = {}) {
69
+ const headers = {};
70
+ for (const { fm } of await matchingFiles(dir, { ...query, scope: "api" })) {
71
+ Object.assign(headers, fm.headers); // later files override earlier — deterministic dir order
72
+ }
73
+ return headers;
74
+ }
75
+ /** Scan base (web) + api subdir, return the files whose scope + key match this run, with parsed front-matter. */
76
+ async function matchingFiles(dir, query) {
77
+ const runScope = query.scope ?? "web";
78
+ const target = (runScope === "api" ? query.endpoint : query.url) ?? "";
79
+ // Candidates from the base dir (default web) and the api subdir (default api); scope: front-matter overrides.
80
+ const candidates = [
81
+ ...(await mdFiles(dir)).map((file) => ({ dir, file, dirDefault: "web" })),
82
+ ...(await mdFiles(join(dir, "api"))).map((file) => ({ dir: join(dir, "api"), file, dirDefault: "api" })),
83
+ ];
84
+ const out = [];
85
+ for (const c of candidates) {
86
+ const raw = await readFile(join(c.dir, c.file), "utf8");
87
+ const fm = parseFrontmatter(raw);
88
+ const fileScope = fm.scope ?? c.dirDefault;
89
+ if (fileScope !== "all" && fileScope !== runScope)
90
+ continue; // wrong scope for this run
91
+ if (fm.pattern && !target.includes(fm.pattern))
92
+ continue; // keyed file: target must contain the pattern
93
+ out.push({ raw, fm });
94
+ }
95
+ return out;
96
+ }
39
97
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/knowledge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,sEAAsE;AACtE,SAAS,cAAc,CAAC,GAAW;IACjC,MAAM,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACpD,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IAC/B,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACtE,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACnE,CAAC;AAED,SAAS,gB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,EAAE,KAAc,EAAE,CAAC,CAAC;KAClH,CAAC;IAEF,MAAM,GAAG,GAAuC,EAAE,CAAC;IACnD,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;QACxD,MAAM,EAAE,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,SAAS,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC,UAAU,CAAC;QAC3C,IAAI,SAAS,KAAK,KAAK,IAAI,SAAS,KAAK,QAAQ;YAAE,SAAS,CAAC,2BAA2B;QACxF,IAAI,EAAE,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC;YAAE,SAAS,CAAC,8CAA8C;QACxG,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -2,8 +2,8 @@ export { OPENROUTER_BASE_URL, GROQ_BASE_URL, resolveModelSpec, makeModel, struct
2
2
  export type { ModelSpec, ProviderKeys } from "./factory.js";
3
3
  export { imageBlock } from "./vision.js";
4
4
  export type { ImageBlock } from "./vision.js";
5
- export { structuredInvoker, meteredInvoker, retryInvoke, CallBudget, cappedInvoke } from "./structured.js";
6
- export type { StructuredInvoke, StructuredMethod } from "./structured.js";
5
+ export { structuredInvoker, meteredInvoker, retryInvoke, CallBudget, cappedInvoke, timeoutInvoke, DEFAULT_STEP_TIMEOUT_MS } from "./structured.js";
6
+ export type { StructuredInvoke, StructuredMethod, TimeoutOptions } from "./structured.js";
7
7
  export { RoleRouter, resolveRoleTier, KNOWN_ROLES } from "./routing.js";
8
8
  export { CostLedger, DEFAULT_PRICING, priceFor, extractUsage } from "./cost.js";
9
9
  export type { CostReport, RoleCost, TokenUsage, ModelPrice } from "./cost.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,gBAAgB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACpH,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC3G,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAChF,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,gBAAgB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACpH,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AACnJ,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAChF,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
package/dist/llm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { OPENROUTER_BASE_URL, GROQ_BASE_URL, resolveModelSpec, makeModel, structuredMethodFor } from "./factory.js";
2
2
  export { imageBlock } from "./vision.js";
3
3
  // L1-01 — per-role routing + cost/token accounting (ADR-0011).
4
- export { structuredInvoker, meteredInvoker, retryInvoke, CallBudget, cappedInvoke } from "./structured.js";
4
+ export { structuredInvoker, meteredInvoker, retryInvoke, CallBudget, cappedInvoke, timeoutInvoke, DEFAULT_STEP_TIMEOUT_MS } from "./structured.js";
5
5
  export { RoleRouter, resolveRoleTier, KNOWN_ROLES } from "./routing.js";
6
6
  export { CostLedger, DEFAULT_PRICING, priceFor, extractUsage } from "./cost.js";
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,gBAAgB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEpH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,+DAA+D;AAC/D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE3G,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,gBAAgB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEpH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,+DAA+D;AAC/D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAEnJ,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/llm/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAkC,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjF,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,WAAW,iCAAkC,CAAC;AAE3D,yGAAyG;AACzG,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,SAAS,EACnB,KAAK,EAAE,WAAW,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C,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,gBAAgB;CAcxD"}
@@ -1,5 +1,5 @@
1
1
  import { makeModel, structuredMethodFor } from "./factory.js";
2
- import { meteredInvoker, cappedInvoke, retryInvoke } from "./structured.js";
2
+ import { meteredInvoker, cappedInvoke, retryInvoke, timeoutInvoke } from "./structured.js";
3
3
  import { CostLedger } from "./cost.js";
4
4
  /**
5
5
  * Routable roles (L1-01, ADR-0011). The cheap LLM-as-judge scorer keeps the `judge`
@@ -51,7 +51,13 @@ export class RoleRouter {
51
51
  const method = structuredMethodFor(tier.provider);
52
52
  const config = this.callbacks ? { callbacks: this.callbacks } : undefined;
53
53
  const metered = meteredInvoker(model, (u, m) => this.ledger.record(role, m, u), tier.model, method, config);
54
- return cappedInvoke(retryInvoke(metered), this.budget, this.onCharge);
54
+ // #110: bound the whole step (incl. retries) so a slow provider fails with an actionable error
55
+ // instead of hanging. Layered OUTSIDE retryInvoke → the timeout error is never itself retried.
56
+ const guarded = timeoutInvoke(retryInvoke(metered), {
57
+ timeoutMs: this.cfg.stepTimeoutMs,
58
+ label: `role '${role}', model '${tier.model}'`,
59
+ });
60
+ return cappedInvoke(guarded, this.budget, this.onCharge);
55
61
  }
56
62
  }
57
63
  //# sourceMappingURL=routing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/llm/routing.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAqB,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE5E,OAAO,EAAE,UAAU,EAAmB,MAAM,WAAW,CAAC;AAExD;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAU,CAAC;AAE3D,yGAAyG;AACzG,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,QAAmB,EACnB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IAC/F,OAAO,CAAC,IAAY,EAAE,QAAmB;QACvC,OAAO,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACzD,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,IAAY,EAAE,IAAe;QAClC,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,2FAA2F;QAC3F,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1E,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC5G,+FAA+F;QAC/F,+FAA+F;QAC/F,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE;YAClD,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa;YACjC,KAAK,EAAE,SAAS,IAAI,aAAa,IAAI,CAAC,KAAK,GAAG;SAC/C,CAAC,CAAC;QACH,OAAO,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3D,CAAC;CACF"}
@@ -31,6 +31,28 @@ export interface RetryOptions {
31
31
  * with exponential backoff. Non-transient errors (schema validation, 4xx) are thrown immediately.
32
32
  */
33
33
  export declare function retryInvoke(inner: StructuredInvoke, opts?: RetryOptions): StructuredInvoke;
34
+ /**
35
+ * Default per-step LLM timeout (#110). Anthropic finishes a step in ~90s; OpenRouter `deepseek-r1`
36
+ * (reasoner) / `deepseek-chat` (codegen) can hang for minutes, overrunning interactive/MCP timeouts.
37
+ * 4 min lets a healthy Anthropic step through while cutting a pathological provider hang short with an
38
+ * actionable error. Overridable via `STEP_TIMEOUT_MS`; `0` disables the timeout entirely.
39
+ */
40
+ export declare const DEFAULT_STEP_TIMEOUT_MS = 240000;
41
+ export interface TimeoutOptions {
42
+ /** Wall-clock cap per step (ms). `0`/negative/undefined → no timeout (wrapper returns `inner` as-is). */
43
+ timeoutMs?: number;
44
+ /** Context for the error message, e.g. `role 'reasoner', model 'deepseek/deepseek-r1'`. */
45
+ label?: string;
46
+ }
47
+ /**
48
+ * Per-step timeout (#110): bounds the wall-clock of one structured call (incl. its retries when wrapped
49
+ * OUTSIDE {@link retryInvoke}) and, on overrun, throws ONE actionable error instead of hanging forever —
50
+ * critical for the MCP server, where the caller can't see progress. The losing inner call is left to
51
+ * settle in the background (its rejection is swallowed); we don't cancel the HTTP request, we just stop
52
+ * waiting. The actionable message points at the latency-safe escapes (a faster `--routing`/Anthropic),
53
+ * deliberately NOT Groq `fast`, which 400s on large codegen (`groq-fast-json-schema-bug`).
54
+ */
55
+ export declare function timeoutInvoke(inner: StructuredInvoke, opts?: TimeoutOptions): StructuredInvoke;
34
56
  /** Cost-guardrail (Sprint 6): shared LLM-call counter per run — a safeguard against runaway cost. */
35
57
  export declare class CallBudget {
36
58
  private readonly cap;
@@ -1 +1 @@
1
- {"version":3,"file":"structured.d.ts","sourceRoot":"","sources":["../../src/llm/structured.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAE1D;;;G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AAE,YAAiB,GAAG,gBAAgB,CAiB9F;AAED;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,SAAU,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,yGAAyG;IACzG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2FAA2F;IAC3F,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,GAAE,cAAmB,GAAG,gBAAgB,CA2BlG;AAED,qGAAqG;AACrG,qBAAa,UAAU;IAET,OAAO,CAAC,QAAQ,CAAC,GAAG;IADhC,OAAO,CAAC,CAAC,CAAK;gBACe,GAAG,EAAE,MAAM;IACxC,MAAM,IAAI,IAAI;IAQd,uEAAuE;IACvE,IAAI,KAAK,IAAI,MAAM,CAElB;IACD,qFAAqF;IACrF,IAAI,GAAG,IAAI,MAAM,CAEhB;IACD,wDAAwD;IACxD,IAAI,SAAS,IAAI,MAAM,CAEtB;CACF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,UAAU,EAClB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,GAC7C,gBAAgB,CAMlB"}
@@ -50,6 +50,48 @@ export function retryInvoke(inner, opts = {}) {
50
50
  throw lastErr;
51
51
  };
52
52
  }
53
+ /**
54
+ * Default per-step LLM timeout (#110). Anthropic finishes a step in ~90s; OpenRouter `deepseek-r1`
55
+ * (reasoner) / `deepseek-chat` (codegen) can hang for minutes, overrunning interactive/MCP timeouts.
56
+ * 4 min lets a healthy Anthropic step through while cutting a pathological provider hang short with an
57
+ * actionable error. Overridable via `STEP_TIMEOUT_MS`; `0` disables the timeout entirely.
58
+ */
59
+ export const DEFAULT_STEP_TIMEOUT_MS = 240_000;
60
+ /**
61
+ * Per-step timeout (#110): bounds the wall-clock of one structured call (incl. its retries when wrapped
62
+ * OUTSIDE {@link retryInvoke}) and, on overrun, throws ONE actionable error instead of hanging forever —
63
+ * critical for the MCP server, where the caller can't see progress. The losing inner call is left to
64
+ * settle in the background (its rejection is swallowed); we don't cancel the HTTP request, we just stop
65
+ * waiting. The actionable message points at the latency-safe escapes (a faster `--routing`/Anthropic),
66
+ * deliberately NOT Groq `fast`, which 400s on large codegen (`groq-fast-json-schema-bug`).
67
+ */
68
+ export function timeoutInvoke(inner, opts = {}) {
69
+ const timeoutMs = opts.timeoutMs ?? 0;
70
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0)
71
+ return inner; // disabled → no overhead, no behavior change
72
+ const where = opts.label ? ` (${opts.label})` : "";
73
+ return async (schema, messages) => {
74
+ const innerP = inner(schema, messages);
75
+ innerP.catch(() => undefined); // a losing race must not surface as an unhandledRejection
76
+ let timer;
77
+ const timeoutP = new Promise((_, reject) => {
78
+ timer = setTimeout(() => {
79
+ reject(new Error(`LLM step timed out after ${timeoutMs}ms${where} — the provider is too slow for this step. ` +
80
+ `Try a faster routing (e.g. --routing volume-fast) or the Anthropic profile ` +
81
+ `(LLM_PROFILE=anthropic), or raise STEP_TIMEOUT_MS.`));
82
+ }, timeoutMs);
83
+ // Never let a pending timer keep the process alive (e.g. after the call settles late).
84
+ timer.unref?.();
85
+ });
86
+ try {
87
+ return await Promise.race([innerP, timeoutP]);
88
+ }
89
+ finally {
90
+ if (timer)
91
+ clearTimeout(timer);
92
+ }
93
+ };
94
+ }
53
95
  /** Cost-guardrail (Sprint 6): shared LLM-call counter per run — a safeguard against runaway cost. */
54
96
  export class CallBudget {
55
97
  cap;
@@ -1 +1 @@
1
- {"version":3,"file":"structured.js","sourceRoot":"","sources":["../../src/llm/structured.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAmB,MAAM,WAAW,CAAC;AAgB1D,sEAAsE;AACtE,MAAM,UAAU,iBAAiB,CAAC,KAAoB,EAAE,MAAyB;IAC/E,O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CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ /**
3
+ * Build the Cairn MCP server (#49): exposes `explore` and `design` as tools over the shared core.
4
+ * Separated from {@link startMcpServer} so a smoke test can introspect tools without a transport.
5
+ */
6
+ export declare function buildMcpServer(): McpServer;
7
+ /** Start the Cairn MCP server over stdio — the entry point `cairn mcp` drives. */
8
+ export declare function startMcpServer(): Promise<void>;
9
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAapE;;;GAGG;AACH,wBAAgB,cAAc,IAAI,SAAS,CAoD1C;AAED,kFAAkF;AAClF,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAIpD"}
@@ -0,0 +1,49 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { BOT_VERSION } from "../index.js";
4
+ import { TOOL_INPUT_SHAPE, ToolInputSchema, AUTOMATE_INPUT_SHAPE, AutomateInputSchema, exploreTool, designTool, automateTool, } from "./tools.js";
5
+ /**
6
+ * Build the Cairn MCP server (#49): exposes `explore` and `design` as tools over the shared core.
7
+ * Separated from {@link startMcpServer} so a smoke test can introspect tools without a transport.
8
+ */
9
+ export function buildMcpServer() {
10
+ const server = new McpServer({ name: "cairn", version: BOT_VERSION });
11
+ server.registerTool("explore", {
12
+ title: "Generate UI test cases + code (explore)",
13
+ description: "Explore a web page and generate methodology-based UI test cases, @playwright/test code, and a " +
14
+ "validate⇄repair report. Returns the cases, validation summary, metrics, the Pilot verdict, cost, " +
15
+ "and the run directory. Use `flow`+`setup` for multi-page journeys; `session` for authenticated targets.",
16
+ inputSchema: TOOL_INPUT_SHAPE,
17
+ }, async (args) => {
18
+ const result = await exploreTool(ToolInputSchema.parse(args));
19
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
20
+ });
21
+ server.registerTool("design", {
22
+ title: "Design UI test cases, no code (design)",
23
+ description: "Explore a web page and design methodology-based UI test cases in ATC/MTC format (markdown + " +
24
+ "selectors) WITHOUT generating or running code. Returns the cases, metrics, cost, and the run " +
25
+ "directory. The cheaper first step before `explore`/automate.",
26
+ inputSchema: TOOL_INPUT_SHAPE,
27
+ }, async (args) => {
28
+ const result = await designTool(ToolInputSchema.parse(args));
29
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
30
+ });
31
+ server.registerTool("automate", {
32
+ title: "Generate @playwright/test from ready cases (automate)",
33
+ description: "Generate @playwright/test code from the ready ATC cases of a previous run (the second half of " +
34
+ "the decoupled design → automate flow). Pass `run` = the run id/dir returned by `design`; " +
35
+ "optionally `validate` (needs a `session`). Returns the spec files, validation summary, and cost.",
36
+ inputSchema: AUTOMATE_INPUT_SHAPE,
37
+ }, async (args) => {
38
+ const result = await automateTool(AutomateInputSchema.parse(args));
39
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
40
+ });
41
+ return server;
42
+ }
43
+ /** Start the Cairn MCP server over stdio — the entry point `cairn mcp` drives. */
44
+ export async function startMcpServer() {
45
+ const server = buildMcpServer();
46
+ const transport = new StdioServerTransport();
47
+ await server.connect(transport);
48
+ }
49
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,W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