@itsthelore/proofkeeper 2026.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 (156) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +10 -0
  3. package/README.md +207 -0
  4. package/dist/agent/adapters/claude.d.ts +93 -0
  5. package/dist/agent/adapters/claude.d.ts.map +1 -0
  6. package/dist/agent/adapters/claude.js +96 -0
  7. package/dist/agent/adapters/claude.js.map +1 -0
  8. package/dist/agent/drive.d.ts +53 -0
  9. package/dist/agent/drive.d.ts.map +1 -0
  10. package/dist/agent/drive.js +194 -0
  11. package/dist/agent/drive.js.map +1 -0
  12. package/dist/agent/loop.d.ts +40 -0
  13. package/dist/agent/loop.d.ts.map +1 -0
  14. package/dist/agent/loop.js +29 -0
  15. package/dist/agent/loop.js.map +1 -0
  16. package/dist/agent/model.d.ts +43 -0
  17. package/dist/agent/model.d.ts.map +1 -0
  18. package/dist/agent/model.js +10 -0
  19. package/dist/agent/model.js.map +1 -0
  20. package/dist/agent/observe.d.ts +48 -0
  21. package/dist/agent/observe.d.ts.map +1 -0
  22. package/dist/agent/observe.js +65 -0
  23. package/dist/agent/observe.js.map +1 -0
  24. package/dist/agent/tools.d.ts +74 -0
  25. package/dist/agent/tools.d.ts.map +1 -0
  26. package/dist/agent/tools.js +257 -0
  27. package/dist/agent/tools.js.map +1 -0
  28. package/dist/cli.d.ts +61 -0
  29. package/dist/cli.d.ts.map +1 -0
  30. package/dist/cli.js +648 -0
  31. package/dist/cli.js.map +1 -0
  32. package/dist/compiler/actions.d.ts +101 -0
  33. package/dist/compiler/actions.d.ts.map +1 -0
  34. package/dist/compiler/actions.js +13 -0
  35. package/dist/compiler/actions.js.map +1 -0
  36. package/dist/compiler/compiler.d.ts +25 -0
  37. package/dist/compiler/compiler.d.ts.map +1 -0
  38. package/dist/compiler/compiler.js +42 -0
  39. package/dist/compiler/compiler.js.map +1 -0
  40. package/dist/compiler/emit.d.ts +21 -0
  41. package/dist/compiler/emit.d.ts.map +1 -0
  42. package/dist/compiler/emit.js +164 -0
  43. package/dist/compiler/emit.js.map +1 -0
  44. package/dist/compiler/http.d.ts +30 -0
  45. package/dist/compiler/http.d.ts.map +1 -0
  46. package/dist/compiler/http.js +30 -0
  47. package/dist/compiler/http.js.map +1 -0
  48. package/dist/compiler/recorder.d.ts +62 -0
  49. package/dist/compiler/recorder.d.ts.map +1 -0
  50. package/dist/compiler/recorder.js +148 -0
  51. package/dist/compiler/recorder.js.map +1 -0
  52. package/dist/compiler/summary.d.ts +11 -0
  53. package/dist/compiler/summary.d.ts.map +1 -0
  54. package/dist/compiler/summary.js +56 -0
  55. package/dist/compiler/summary.js.map +1 -0
  56. package/dist/compiler/terminal.d.ts +42 -0
  57. package/dist/compiler/terminal.d.ts.map +1 -0
  58. package/dist/compiler/terminal.js +47 -0
  59. package/dist/compiler/terminal.js.map +1 -0
  60. package/dist/compiler/types.d.ts +25 -0
  61. package/dist/compiler/types.d.ts.map +1 -0
  62. package/dist/compiler/types.js +10 -0
  63. package/dist/compiler/types.js.map +1 -0
  64. package/dist/coverage/graph.d.ts +55 -0
  65. package/dist/coverage/graph.d.ts.map +1 -0
  66. package/dist/coverage/graph.js +87 -0
  67. package/dist/coverage/graph.js.map +1 -0
  68. package/dist/coverage/model.d.ts +36 -0
  69. package/dist/coverage/model.d.ts.map +1 -0
  70. package/dist/coverage/model.js +57 -0
  71. package/dist/coverage/model.js.map +1 -0
  72. package/dist/coverage/report.d.ts +27 -0
  73. package/dist/coverage/report.d.ts.map +1 -0
  74. package/dist/coverage/report.js +45 -0
  75. package/dist/coverage/report.js.map +1 -0
  76. package/dist/coverage/source.d.ts +23 -0
  77. package/dist/coverage/source.d.ts.map +1 -0
  78. package/dist/coverage/source.js +48 -0
  79. package/dist/coverage/source.js.map +1 -0
  80. package/dist/fidelity/gate.d.ts +34 -0
  81. package/dist/fidelity/gate.d.ts.map +1 -0
  82. package/dist/fidelity/gate.js +38 -0
  83. package/dist/fidelity/gate.js.map +1 -0
  84. package/dist/index.d.ts +69 -0
  85. package/dist/index.d.ts.map +1 -0
  86. package/dist/index.js +49 -0
  87. package/dist/index.js.map +1 -0
  88. package/dist/learning/store.d.ts +44 -0
  89. package/dist/learning/store.d.ts.map +1 -0
  90. package/dist/learning/store.js +64 -0
  91. package/dist/learning/store.js.map +1 -0
  92. package/dist/qa/concurrency.d.ts +7 -0
  93. package/dist/qa/concurrency.d.ts.map +1 -0
  94. package/dist/qa/concurrency.js +21 -0
  95. package/dist/qa/concurrency.js.map +1 -0
  96. package/dist/qa/run-qa.d.ts +87 -0
  97. package/dist/qa/run-qa.d.ts.map +1 -0
  98. package/dist/qa/run-qa.js +106 -0
  99. package/dist/qa/run-qa.js.map +1 -0
  100. package/dist/qa/run-scoped.d.ts +82 -0
  101. package/dist/qa/run-scoped.d.ts.map +1 -0
  102. package/dist/qa/run-scoped.js +96 -0
  103. package/dist/qa/run-scoped.js.map +1 -0
  104. package/dist/runner/playwright-report.d.ts +52 -0
  105. package/dist/runner/playwright-report.d.ts.map +1 -0
  106. package/dist/runner/playwright-report.js +90 -0
  107. package/dist/runner/playwright-report.js.map +1 -0
  108. package/dist/runner/playwright-runner.d.ts +38 -0
  109. package/dist/runner/playwright-runner.d.ts.map +1 -0
  110. package/dist/runner/playwright-runner.js +73 -0
  111. package/dist/runner/playwright-runner.js.map +1 -0
  112. package/dist/runner/types.d.ts +45 -0
  113. package/dist/runner/types.d.ts.map +1 -0
  114. package/dist/runner/types.js +10 -0
  115. package/dist/runner/types.js.map +1 -0
  116. package/dist/scaffold/scaffold.d.ts +22 -0
  117. package/dist/scaffold/scaffold.d.ts.map +1 -0
  118. package/dist/scaffold/scaffold.js +34 -0
  119. package/dist/scaffold/scaffold.js.map +1 -0
  120. package/dist/scope/config.d.ts +89 -0
  121. package/dist/scope/config.d.ts.map +1 -0
  122. package/dist/scope/config.js +172 -0
  123. package/dist/scope/config.js.map +1 -0
  124. package/dist/scope/diff-scope.d.ts +31 -0
  125. package/dist/scope/diff-scope.d.ts.map +1 -0
  126. package/dist/scope/diff-scope.js +42 -0
  127. package/dist/scope/diff-scope.js.map +1 -0
  128. package/dist/scope/glob.d.ts +17 -0
  129. package/dist/scope/glob.d.ts.map +1 -0
  130. package/dist/scope/glob.js +50 -0
  131. package/dist/scope/glob.js.map +1 -0
  132. package/dist/writeback/comment.d.ts +103 -0
  133. package/dist/writeback/comment.d.ts.map +1 -0
  134. package/dist/writeback/comment.js +150 -0
  135. package/dist/writeback/comment.js.map +1 -0
  136. package/dist/writeback/gateways/github-rest.d.ts +66 -0
  137. package/dist/writeback/gateways/github-rest.d.ts.map +1 -0
  138. package/dist/writeback/gateways/github-rest.js +107 -0
  139. package/dist/writeback/gateways/github-rest.js.map +1 -0
  140. package/dist/writeback/merge.d.ts +27 -0
  141. package/dist/writeback/merge.d.ts.map +1 -0
  142. package/dist/writeback/merge.js +89 -0
  143. package/dist/writeback/merge.js.map +1 -0
  144. package/dist/writeback/proposal.d.ts +52 -0
  145. package/dist/writeback/proposal.d.ts.map +1 -0
  146. package/dist/writeback/proposal.js +79 -0
  147. package/dist/writeback/proposal.js.map +1 -0
  148. package/dist/writeback/proposer.d.ts +94 -0
  149. package/dist/writeback/proposer.d.ts.map +1 -0
  150. package/dist/writeback/proposer.js +79 -0
  151. package/dist/writeback/proposer.js.map +1 -0
  152. package/dist/writeback/verified-by.d.ts +56 -0
  153. package/dist/writeback/verified-by.d.ts.map +1 -0
  154. package/dist/writeback/verified-by.js +60 -0
  155. package/dist/writeback/verified-by.js.map +1 -0
  156. package/package.json +62 -0
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The autonomous drive — Proofkeeper Initiative 2's drive phase.
3
+ *
4
+ * A bring-your-own-model agent loop: it navigates to the start URL, observes
5
+ * the live page, asks the {@link ModelClient} what to do next, dispatches the
6
+ * model's tool calls through the {@link Recorder}, observes the result, and
7
+ * repeats until the model finishes (or a step budget is hit). The Recorder
8
+ * records each action only after it succeeds, so the produced
9
+ * {@link RecordedSession} is — by construction — a faithful sequence that held,
10
+ * ready for the deterministic compiler and the fidelity gate.
11
+ *
12
+ * Proofkeeper bundles no model (ADR-035, ADR-002): the caller supplies the
13
+ * ModelClient. This loop is the autonomous runtime; the model is the brain.
14
+ */
15
+ import type { Page } from "@playwright/test";
16
+ import type { RecordedSession } from "../compiler/actions.js";
17
+ import type { ModelClient } from "./model.js";
18
+ export interface DriveOptions {
19
+ /** Capability under verification; threads into the recorded session. */
20
+ capabilityId?: string;
21
+ /** Human title for the emitted test. */
22
+ title: string;
23
+ /** Product entry point; the driver navigates here first. */
24
+ startUrl: string;
25
+ /** What the model should accomplish and assert on the product. */
26
+ goal: string;
27
+ /** Maximum model turns before the drive gives up. Defaults to 12. */
28
+ maxSteps?: number;
29
+ /** Reasons earlier attempts at this capability failed, to steer away from them. */
30
+ priorFailures?: string[];
31
+ /** When set, run a planning turn first and record a Markdown test plan. */
32
+ plan?: boolean;
33
+ }
34
+ export interface DriveResult {
35
+ /** The recorded session, ready to compile. */
36
+ session: RecordedSession;
37
+ /** True if the model signalled completion (vs hitting the step budget). */
38
+ finished: boolean;
39
+ /** Number of model turns taken. */
40
+ steps: number;
41
+ /** The Markdown test plan, when a planning turn ran. */
42
+ plan?: string;
43
+ }
44
+ export declare class AutonomousDriver {
45
+ private readonly page;
46
+ private readonly model;
47
+ private readonly options;
48
+ constructor(page: Page, model: ModelClient, options: DriveOptions);
49
+ drive(): Promise<DriveResult>;
50
+ }
51
+ /** Convenience wrapper: construct a driver and run it. */
52
+ export declare function runDrive(page: Page, model: ModelClient, options: DriveOptions): Promise<DriveResult>;
53
+ //# sourceMappingURL=drive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drive.d.ts","sourceRoot":"","sources":["../../src/agent/drive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D,OAAO,KAAK,EAAE,WAAW,EAA0B,MAAM,YAAY,CAAC;AAiBtE,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,2EAA2E;IAC3E,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,8CAA8C;IAC9C,OAAO,EAAE,eAAe,CAAC;IACzB,2EAA2E;IAC3E,QAAQ,EAAE,OAAO,CAAC;IAClB,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AA2GD,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAFP,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,YAAY;IAGlC,KAAK,IAAI,OAAO,CAAC,WAAW,CAAC;CAqFpC;AAED,0DAA0D;AAC1D,wBAAgB,QAAQ,CACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,WAAW,CAAC,CAEtB"}
@@ -0,0 +1,194 @@
1
+ /**
2
+ * The autonomous drive — Proofkeeper Initiative 2's drive phase.
3
+ *
4
+ * A bring-your-own-model agent loop: it navigates to the start URL, observes
5
+ * the live page, asks the {@link ModelClient} what to do next, dispatches the
6
+ * model's tool calls through the {@link Recorder}, observes the result, and
7
+ * repeats until the model finishes (or a step budget is hit). The Recorder
8
+ * records each action only after it succeeds, so the produced
9
+ * {@link RecordedSession} is — by construction — a faithful sequence that held,
10
+ * ready for the deterministic compiler and the fidelity gate.
11
+ *
12
+ * Proofkeeper bundles no model (ADR-035, ADR-002): the caller supplies the
13
+ * ModelClient. This loop is the autonomous runtime; the model is the brain.
14
+ */
15
+ import { Recorder } from "../compiler/recorder.js";
16
+ import { observePage, renderObservation, createPageMonitor } from "./observe.js";
17
+ import { DRIVE_TOOLS, LOCATOR_GUIDANCE, TERMINAL_GUIDANCE, HTTP_GUIDANCE, parseLocator, parseRunCommand, parseExpectOutput, parseExpectExit, parseRequest, parseExpectStatus, parseExpectJson, } from "./tools.js";
18
+ const DEFAULT_MAX_STEPS = 12;
19
+ /** Instruction for the optional planning turn (a no-tools text response). */
20
+ const PLAN_INSTRUCTION = "Before acting, write a short Markdown test plan: the steps you will take to verify " +
21
+ "this capability and the observable outcomes you will assert. Respond with the plan only — " +
22
+ "no tool calls.";
23
+ function systemPrompt(goal, priorFailures = []) {
24
+ const lines = [
25
+ "You are Proofkeeper's autonomous QA agent. You drive a product like a",
26
+ "developer to verify a capability, using only the provided tools — a browser",
27
+ "and a terminal. Work in small steps: observe, take an action, observe again.",
28
+ "Assert every observable outcome (expect_text / expect_visible for the page,",
29
+ "expect_output / expect_exit for the terminal) — those become the committed",
30
+ "test. When the capability is driven and asserted, call finish.",
31
+ "",
32
+ `Goal: ${goal}`,
33
+ ];
34
+ if (priorFailures.length > 0) {
35
+ lines.push("", "Earlier attempts at this capability failed for these reasons — do not", "repeat them; choose a more robust path or more stable assertions:", ...priorFailures.map((r) => `- ${r}`));
36
+ }
37
+ lines.push("", LOCATOR_GUIDANCE, "", TERMINAL_GUIDANCE, "", HTTP_GUIDANCE);
38
+ return lines.join("\n");
39
+ }
40
+ /** Dispatch one tool call to the recorder. Records only on success. */
41
+ async function dispatch(recorder, call) {
42
+ try {
43
+ switch (call.name) {
44
+ case "navigate":
45
+ await recorder.goto(String(call.arguments["url"]));
46
+ return { ok: true };
47
+ case "click":
48
+ await recorder.click(parseLocator(call.arguments));
49
+ return { ok: true };
50
+ case "fill":
51
+ await recorder.fill(parseLocator(call.arguments), String(call.arguments["value"]));
52
+ return { ok: true };
53
+ case "check":
54
+ await recorder.check(parseLocator(call.arguments));
55
+ return { ok: true };
56
+ case "press":
57
+ await recorder.press(parseLocator(call.arguments), String(call.arguments["key"]));
58
+ return { ok: true };
59
+ case "expect_text":
60
+ await recorder.expectText(parseLocator(call.arguments), String(call.arguments["text"]));
61
+ return { ok: true };
62
+ case "expect_visible":
63
+ await recorder.expectVisible(parseLocator(call.arguments));
64
+ return { ok: true };
65
+ case "run_command": {
66
+ const { command, cwd } = parseRunCommand(call.arguments);
67
+ const r = await recorder.run(command, cwd !== undefined ? { cwd } : {});
68
+ const parts = [
69
+ r.stdout.trim() && `stdout: ${r.stdout.trim()}`,
70
+ r.stderr.trim() && `stderr: ${r.stderr.trim()}`,
71
+ `exit: ${r.code}`,
72
+ ].filter(Boolean);
73
+ return { ok: true, detail: `$ ${command}\n${parts.join("\n")}` };
74
+ }
75
+ case "expect_output":
76
+ await recorder.expectOutput(parseExpectOutput(call.arguments));
77
+ return { ok: true };
78
+ case "expect_exit":
79
+ await recorder.expectExit(parseExpectExit(call.arguments));
80
+ return { ok: true };
81
+ case "request": {
82
+ const input = parseRequest(call.arguments);
83
+ const res = await recorder.request(input);
84
+ const snippet = res.body.length > 500 ? `${res.body.slice(0, 500)}…` : res.body;
85
+ return { ok: true, detail: `${input.method} ${input.url}\nstatus: ${res.status}\nbody: ${snippet}` };
86
+ }
87
+ case "expect_status":
88
+ await recorder.expectStatus(parseExpectStatus(call.arguments));
89
+ return { ok: true };
90
+ case "expect_json": {
91
+ const { path, equals } = parseExpectJson(call.arguments);
92
+ await recorder.expectJson(path, equals);
93
+ return { ok: true };
94
+ }
95
+ case "finish":
96
+ return { ok: true, finished: true };
97
+ default:
98
+ return { ok: false, error: `unknown tool '${call.name}'` };
99
+ }
100
+ }
101
+ catch (err) {
102
+ // The action failed against the real page, so the recorder did NOT record
103
+ // it. Report the failure back to the model so it can adapt.
104
+ return { ok: false, error: err.message };
105
+ }
106
+ }
107
+ export class AutonomousDriver {
108
+ page;
109
+ model;
110
+ options;
111
+ constructor(page, model, options) {
112
+ this.page = page;
113
+ this.model = model;
114
+ this.options = options;
115
+ }
116
+ async drive() {
117
+ const recorder = new Recorder(this.page, {
118
+ capabilityId: this.options.capabilityId,
119
+ title: this.options.title,
120
+ startUrl: this.options.startUrl,
121
+ });
122
+ // Seed the session at the known entry point, then let the model take over.
123
+ await recorder.goto(this.options.startUrl);
124
+ // Subscribe to console and network events; merge the recent window into each
125
+ // observation so the model sees execution feedback, not just the DOM.
126
+ const monitor = createPageMonitor(this.page);
127
+ const observe = async () => renderObservation({
128
+ ...(await observePage(this.page)),
129
+ console: [...monitor.console],
130
+ network: [...monitor.network],
131
+ });
132
+ const transcript = [
133
+ { role: "system", content: systemPrompt(this.options.goal, this.options.priorFailures) },
134
+ {
135
+ role: "user",
136
+ content: `You are on the start page.\n\n${await observe()}`,
137
+ },
138
+ ];
139
+ // Optional planning turn: ask for a Markdown test plan (no tools → text),
140
+ // record it, and feed it back as context so the drive follows its own plan.
141
+ let plan;
142
+ if (this.options.plan) {
143
+ const response = await this.model.complete({
144
+ transcript: [...transcript, { role: "user", content: PLAN_INSTRUCTION }],
145
+ tools: [],
146
+ });
147
+ const text = response.done?.trim();
148
+ if (text) {
149
+ plan = text;
150
+ transcript.push({ role: "assistant", content: `Test plan:\n${text}` });
151
+ }
152
+ }
153
+ const maxSteps = this.options.maxSteps ?? DEFAULT_MAX_STEPS;
154
+ let finished = false;
155
+ let steps = 0;
156
+ while (steps < maxSteps) {
157
+ steps++;
158
+ const response = await this.model.complete({ transcript, tools: [...DRIVE_TOOLS] });
159
+ const calls = response.toolCalls ?? [];
160
+ if (calls.length === 0) {
161
+ // The model stopped acting; treat a `done` message as completion.
162
+ finished = response.done !== undefined;
163
+ break;
164
+ }
165
+ transcript.push({ role: "assistant", content: JSON.stringify(calls) });
166
+ const outcomes = [];
167
+ let stop = false;
168
+ for (const call of calls) {
169
+ const result = await dispatch(recorder, call);
170
+ if (result.finished) {
171
+ finished = true;
172
+ stop = true;
173
+ break;
174
+ }
175
+ outcomes.push(result.ok
176
+ ? `ok: ${call.name}${result.detail ? `\n${result.detail}` : ""}`
177
+ : `ERROR ${call.name}: ${result.error}`);
178
+ }
179
+ if (stop)
180
+ break;
181
+ transcript.push({ role: "user", content: `Results:\n${outcomes.join("\n")}\n\n${await observe()}` });
182
+ }
183
+ monitor.dispose();
184
+ const session = recorder.recording();
185
+ if (plan !== undefined)
186
+ session.plan = plan;
187
+ return { session, finished, steps, ...(plan !== undefined ? { plan } : {}) };
188
+ }
189
+ }
190
+ /** Convenience wrapper: construct a driver and run it. */
191
+ export function runDrive(page, model, options) {
192
+ return new AutonomousDriver(page, model, options).drive();
193
+ }
194
+ //# sourceMappingURL=drive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drive.js","sourceRoot":"","sources":["../../src/agent/drive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjF,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,MAAM,iBAAiB,GAAG,EAAE,CAAC;AA8B7B,6EAA6E;AAC7E,MAAM,gBAAgB,GACpB,qFAAqF;IACrF,4FAA4F;IAC5F,gBAAgB,CAAC;AAW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BAChE,CAAC,CAAC,SAAS,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,KAAK,EAAE,CAC1C,CAAC;YACJ,CAAC;YACD,IAAI,IAAI;gBAAE,MAAM;YAEhB,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,MAAM,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;QACvG,CAAC;QAED,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC;QACrC,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QAC5C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAC/E,CAAC;CACF;AAED,0DAA0D;AAC1D,MAAM,UAAU,QAAQ,CACtB,IAAU,EACV,KAAkB,EAClB,OAAqB;IAErB,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The compile→fidelity→run pipeline — Proofkeeper Initiatives 2–4 wired.
3
+ *
4
+ * The DRIVE phase (a BYO-model agent calling the {@link Recorder} to produce a
5
+ * {@link RecordedSession}) is upstream and supplied by the caller; this keeps
6
+ * the loop honest about what is autonomous today and what is not. Given a
7
+ * recorded session, the loop compiles it ({@link Compiler}), gates the
8
+ * candidate on fidelity ({@link assessFidelity}), and runs the accepted test
9
+ * across targets ({@link Runner}).
10
+ */
11
+ import type { RecordedSession } from "../compiler/actions.js";
12
+ import type { CandidateTest, Compiler } from "../compiler/types.js";
13
+ import { type FidelityVerdict } from "../fidelity/gate.js";
14
+ import type { Runner, RunResult, RunTarget } from "../runner/types.js";
15
+ export interface AgentLoopDeps {
16
+ compiler: Compiler;
17
+ runner: Runner;
18
+ }
19
+ export interface AgentLoopOptions {
20
+ /** The recorded drive session to compile (produced upstream by a Recorder). */
21
+ session: RecordedSession;
22
+ /** Stability target and N for the fidelity gate. */
23
+ fidelity: {
24
+ n: number;
25
+ target: RunTarget;
26
+ };
27
+ /** Targets the accepted suite runs against. */
28
+ runTargets: RunTarget[];
29
+ }
30
+ export interface AgentLoopResult {
31
+ candidate: CandidateTest;
32
+ verdict: FidelityVerdict;
33
+ /** Only populated when the candidate passed the fidelity gate. */
34
+ runResults: RunResult[];
35
+ }
36
+ /**
37
+ * Compile a recorded session, gate it on fidelity, and run the accepted test.
38
+ */
39
+ export declare function runAgentLoop(deps: AgentLoopDeps, options: AgentLoopOptions): Promise<AgentLoopResult>;
40
+ //# sourceMappingURL=loop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/agent/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEvE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,+EAA+E;IAC/E,OAAO,EAAE,eAAe,CAAC;IACzB,oDAAoD;IACpD,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,SAAS,CAAA;KAAE,CAAC;IAC3C,+CAA+C;IAC/C,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,EAAE,eAAe,CAAC;IACzB,kEAAkE;IAClE,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,CAgB1B"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The compile→fidelity→run pipeline — Proofkeeper Initiatives 2–4 wired.
3
+ *
4
+ * The DRIVE phase (a BYO-model agent calling the {@link Recorder} to produce a
5
+ * {@link RecordedSession}) is upstream and supplied by the caller; this keeps
6
+ * the loop honest about what is autonomous today and what is not. Given a
7
+ * recorded session, the loop compiles it ({@link Compiler}), gates the
8
+ * candidate on fidelity ({@link assessFidelity}), and runs the accepted test
9
+ * across targets ({@link Runner}).
10
+ */
11
+ import { assessFidelity } from "../fidelity/gate.js";
12
+ /**
13
+ * Compile a recorded session, gate it on fidelity, and run the accepted test.
14
+ */
15
+ export async function runAgentLoop(deps, options) {
16
+ // 1. COMPILE — reduce the recorded session to a candidate test (the moat).
17
+ const candidate = await deps.compiler.compile(options.session);
18
+ // 2. FIDELITY — accept only if it re-runs green and stable N times.
19
+ const verdict = await assessFidelity(deps.runner, candidate, {
20
+ n: options.fidelity.n,
21
+ target: options.fidelity.target,
22
+ });
23
+ // 3. RUN — fan the accepted test across targets; quarantine if unstable.
24
+ const runResults = verdict.stable
25
+ ? await deps.runner.run([candidate], { targets: options.runTargets })
26
+ : [];
27
+ return { candidate, verdict, runResults };
28
+ }
29
+ //# sourceMappingURL=loop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/agent/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,cAAc,EAAwB,MAAM,qBAAqB,CAAC;AAwB3E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAmB,EACnB,OAAyB;IAEzB,2EAA2E;IAC3E,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAE/D,oEAAoE;IACpE,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE;QAC3D,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QACrB,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM;KAChC,CAAC,CAAC;IAEH,yEAAyE;IACzE,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM;QAC/B,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;QACrE,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The bring-your-own-model boundary — Proofkeeper Initiative 2.
3
+ *
4
+ * No model or inference ships with Proofkeeper (ADR-035, ADR-002): the agent
5
+ * runtime lives here, but the *model* is supplied by the caller. This is the
6
+ * minimal interface the drive loop needs. Adapters for specific providers live
7
+ * outside core and are the caller's choice.
8
+ */
9
+ /** A tool the agent may call while driving a product (browser/terminal action). */
10
+ export interface ToolCall {
11
+ name: string;
12
+ arguments: Record<string, unknown>;
13
+ }
14
+ /** A single turn's request to the model: the running transcript plus tools. */
15
+ export interface ModelRequest {
16
+ /** Prior transcript, oldest first. Free-form, provider-shaped by the adapter. */
17
+ transcript: {
18
+ role: "system" | "user" | "assistant";
19
+ content: string;
20
+ }[];
21
+ /**
22
+ * Tools the model may invoke this turn. `inputSchema` is a JSON Schema for
23
+ * the tool's arguments; adapters forward it to providers that require one
24
+ * (e.g. the Anthropic Messages API's `input_schema`).
25
+ */
26
+ tools: {
27
+ name: string;
28
+ description: string;
29
+ inputSchema?: Record<string, unknown>;
30
+ }[];
31
+ }
32
+ /** The model's decision for a turn: either act (tool calls) or stop (text). */
33
+ export interface ModelResponse {
34
+ /** Tool calls to execute, if any. */
35
+ toolCalls?: ToolCall[];
36
+ /** Terminal assistant message when the model decides the session is done. */
37
+ done?: string;
38
+ }
39
+ /** A caller-supplied model. Proofkeeper bundles none. */
40
+ export interface ModelClient {
41
+ complete(request: ModelRequest): Promise<ModelResponse>;
42
+ }
43
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/agent/model.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,mFAAmF;AACnF,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,iFAAiF;IACjF,UAAU,EAAE;QAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzE;;;;OAIG;IACH,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,EAAE,CAAC;CACvF;AAED,+EAA+E;AAC/E,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,yDAAyD;AACzD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACzD"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The bring-your-own-model boundary — Proofkeeper Initiative 2.
3
+ *
4
+ * No model or inference ships with Proofkeeper (ADR-035, ADR-002): the agent
5
+ * runtime lives here, but the *model* is supplied by the caller. This is the
6
+ * minimal interface the drive loop needs. Adapters for specific providers live
7
+ * outside core and are the caller's choice.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/agent/model.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Page observation — how the autonomous drive lets the model perceive state.
3
+ *
4
+ * Each turn the driver hands the model a compact snapshot of the live page: its
5
+ * URL and title, the visible text, and Playwright's accessibility (ARIA) tree —
6
+ * the same structure that makes role/name locators resilient. The model decides
7
+ * its next action from this; the driver never decides for it.
8
+ *
9
+ * Console messages and network responses are *events*, not snapshot state, so a
10
+ * {@link PageMonitor} subscribes to them during the drive and the driver merges
11
+ * the most recent of each into the observation (the Playwright-MCP execution-
12
+ * feedback context). This feedback is observation only — it is never recorded as
13
+ * a test action.
14
+ */
15
+ import type { Page } from "@playwright/test";
16
+ export interface PageObservation {
17
+ url: string;
18
+ title: string;
19
+ /** Body innerText — the visible text content. */
20
+ text: string;
21
+ /** Playwright ARIA snapshot of the body — roles and accessible names. */
22
+ aria: string;
23
+ /** Recent console messages (`[type] text`), most recent last. */
24
+ console?: string[];
25
+ /** Recent network responses (`status method url`), most recent last. */
26
+ network?: string[];
27
+ }
28
+ export declare function observePage(page: Page): Promise<PageObservation>;
29
+ /** Render an observation as the text block fed to the model. */
30
+ export declare function renderObservation(o: PageObservation): string;
31
+ /** A live subscription to a page's console and network events, bounded to a recent window. */
32
+ export interface PageMonitor {
33
+ /** Recent console messages (`[type] text`), most recent last. */
34
+ readonly console: string[];
35
+ /** Recent network responses (`status method url`), most recent last. */
36
+ readonly network: string[];
37
+ /** Remove the event listeners. */
38
+ dispose(): void;
39
+ }
40
+ /**
41
+ * Subscribe to a page's console and network events, keeping the most recent
42
+ * `limit` (default 20) of each. The driver creates one after navigating and
43
+ * disposes it when the drive ends.
44
+ */
45
+ export declare function createPageMonitor(page: Page, options?: {
46
+ limit?: number;
47
+ }): PageMonitor;
48
+ //# sourceMappingURL=observe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../src/agent/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAkB,IAAI,EAAY,MAAM,kBAAkB,CAAC;AAEvE,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC,CAQtE;AAED,gEAAgE;AAChE,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAU5D;AAED,8FAA8F;AAC9F,MAAM,WAAW,WAAW;IAC1B,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,kCAAkC;IAClC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,WAAW,CAoB3F"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Page observation — how the autonomous drive lets the model perceive state.
3
+ *
4
+ * Each turn the driver hands the model a compact snapshot of the live page: its
5
+ * URL and title, the visible text, and Playwright's accessibility (ARIA) tree —
6
+ * the same structure that makes role/name locators resilient. The model decides
7
+ * its next action from this; the driver never decides for it.
8
+ *
9
+ * Console messages and network responses are *events*, not snapshot state, so a
10
+ * {@link PageMonitor} subscribes to them during the drive and the driver merges
11
+ * the most recent of each into the observation (the Playwright-MCP execution-
12
+ * feedback context). This feedback is observation only — it is never recorded as
13
+ * a test action.
14
+ */
15
+ export async function observePage(page) {
16
+ const body = page.locator("body");
17
+ const [title, text, aria] = await Promise.all([
18
+ page.title().catch(() => ""),
19
+ body.innerText().catch(() => ""),
20
+ body.ariaSnapshot().catch(() => ""),
21
+ ]);
22
+ return { url: page.url(), title, text: text.trim(), aria: aria.trim() };
23
+ }
24
+ /** Render an observation as the text block fed to the model. */
25
+ export function renderObservation(o) {
26
+ const blocks = [
27
+ `URL: ${o.url}`,
28
+ `Title: ${o.title}`,
29
+ `Visible text:\n${o.text}`,
30
+ `Accessibility tree:\n${o.aria}`,
31
+ ];
32
+ if (o.console && o.console.length > 0)
33
+ blocks.push(`Console:\n${o.console.join("\n")}`);
34
+ if (o.network && o.network.length > 0)
35
+ blocks.push(`Network:\n${o.network.join("\n")}`);
36
+ return blocks.join("\n\n");
37
+ }
38
+ /**
39
+ * Subscribe to a page's console and network events, keeping the most recent
40
+ * `limit` (default 20) of each. The driver creates one after navigating and
41
+ * disposes it when the drive ends.
42
+ */
43
+ export function createPageMonitor(page, options = {}) {
44
+ const limit = options.limit ?? 20;
45
+ const consoleBuf = [];
46
+ const networkBuf = [];
47
+ const push = (buf, line) => {
48
+ buf.push(line);
49
+ if (buf.length > limit)
50
+ buf.shift();
51
+ };
52
+ const onConsole = (msg) => push(consoleBuf, `[${msg.type()}] ${msg.text()}`);
53
+ const onResponse = (res) => push(networkBuf, `${res.status()} ${res.request().method()} ${res.url()}`);
54
+ page.on("console", onConsole);
55
+ page.on("response", onResponse);
56
+ return {
57
+ console: consoleBuf,
58
+ network: networkBuf,
59
+ dispose() {
60
+ page.off("console", onConsole);
61
+ page.off("response", onResponse);
62
+ },
63
+ };
64
+ }
65
+ //# sourceMappingURL=observe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe.js","sourceRoot":"","sources":["../../src/agent/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAiBH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAU;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC5C,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;QAChC,IAAI,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;KACpC,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AAC1E,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,iBAAiB,CAAC,CAAkB;IAClD,MAAM,MAAM,GAAG;QACb,QAAQ,CAAC,CAAC,GAAG,EAAE;QACf,UAAU,CAAC,CAAC,KAAK,EAAE;QACnB,kBAAkB,CAAC,CAAC,IAAI,EAAE;QAC1B,wBAAwB,CAAC,CAAC,IAAI,EAAE;KACj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,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAChC,OAAO;QACL,OAAO,EAAE,UAAU;QACnB,OAAO,EAAE,UAAU;QACnB,OAAO;YACL,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YAC/B,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * The tool surface the autonomous drive exposes to the BYO model, and the
3
+ * parsing of a model's tool-call arguments back into the typed IR.
4
+ *
5
+ * Each tool maps one-to-one onto a {@link Recorder} action, so the model drives
6
+ * the product through exactly the vocabulary the compiler can emit — nothing
7
+ * the recorder cannot capture, and nothing the emitter cannot render.
8
+ */
9
+ import type { Locator } from "../compiler/actions.js";
10
+ /** A tool definition advertised to the model, carrying a JSON Schema for args. */
11
+ export interface DriveTool {
12
+ name: string;
13
+ description: string;
14
+ inputSchema: Record<string, unknown>;
15
+ }
16
+ /** The tools advertised to the model each turn. Names map to Recorder methods. */
17
+ export declare const DRIVE_TOOLS: readonly DriveTool[];
18
+ /**
19
+ * A locator is `{ strategy, ... }`. Prefer resilient strategies (role with a
20
+ * name, testId, or text) over css. This text is folded into the system prompt.
21
+ */
22
+ export declare const LOCATOR_GUIDANCE: string;
23
+ /** Guidance for the terminal tools, folded into the system prompt. */
24
+ export declare const TERMINAL_GUIDANCE: string;
25
+ /** Guidance for the HTTP tools, folded into the system prompt. */
26
+ export declare const HTTP_GUIDANCE: string;
27
+ /** Raised when a model's locator arguments are not a recognizable strategy. */
28
+ export declare class ToolArgumentError extends Error {
29
+ constructor(message: string);
30
+ }
31
+ /**
32
+ * Parse a model tool-call's arguments into a {@link Locator}.
33
+ *
34
+ * Accepts the locator nested under `locator` or inline on the arguments object.
35
+ *
36
+ * @throws {ToolArgumentError} on a missing or unrecognized strategy.
37
+ */
38
+ export declare function parseLocator(args: Record<string, unknown>): Locator;
39
+ /** Arguments for the `run_command` tool. */
40
+ export interface RunCommandArgs {
41
+ command: string;
42
+ cwd?: string;
43
+ }
44
+ /** Parse a `run_command` tool call's arguments. */
45
+ export declare function parseRunCommand(args: Record<string, unknown>): RunCommandArgs;
46
+ /** Arguments for the `expect_output` tool. */
47
+ export interface OutputAssertionArgs {
48
+ match: "exact" | "contains" | "regex";
49
+ stream: "stdout" | "stderr";
50
+ value: string;
51
+ }
52
+ /** Parse an `expect_output` tool call's arguments. */
53
+ export declare function parseExpectOutput(args: Record<string, unknown>): OutputAssertionArgs;
54
+ /** Parse an `expect_exit` tool call's arguments. */
55
+ export declare function parseExpectExit(args: Record<string, unknown>): number;
56
+ /** Arguments for the `request` tool. */
57
+ export interface RequestArgs {
58
+ method: string;
59
+ url: string;
60
+ headers?: Record<string, string>;
61
+ body?: string;
62
+ }
63
+ /** Parse a `request` tool call's arguments. */
64
+ export declare function parseRequest(args: Record<string, unknown>): RequestArgs;
65
+ /** Parse an `expect_status` tool call's arguments. */
66
+ export declare function parseExpectStatus(args: Record<string, unknown>): number;
67
+ /** Arguments for the `expect_json` tool. */
68
+ export interface ExpectJsonArgs {
69
+ path: string;
70
+ equals: string | number | boolean;
71
+ }
72
+ /** Parse an `expect_json` tool call's arguments. */
73
+ export declare function parseExpectJson(args: Record<string, unknown>): ExpectJsonArgs;
74
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/agent/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,kFAAkF;AAClF,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAA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