@plune-ai/cairn 0.9.0 → 0.11.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.
- package/README.md +84 -8
- package/dist/agent/check-docs.d.ts +25 -0
- package/dist/agent/check-docs.d.ts.map +1 -0
- package/dist/agent/check-docs.js +57 -0
- package/dist/agent/check-docs.js.map +1 -0
- package/dist/agent/collect-docs.d.ts +94 -0
- package/dist/agent/collect-docs.d.ts.map +1 -0
- package/dist/agent/collect-docs.js +326 -0
- package/dist/agent/collect-docs.js.map +1 -0
- package/dist/agent/graph.d.ts +39 -2
- package/dist/agent/graph.d.ts.map +1 -1
- package/dist/agent/graph.js +113 -4
- package/dist/agent/graph.js.map +1 -1
- package/dist/agent/index.d.ts +14 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +114 -10
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/overlays.d.ts +88 -0
- package/dist/agent/overlays.d.ts.map +1 -0
- package/dist/agent/overlays.js +447 -0
- package/dist/agent/overlays.js.map +1 -0
- package/dist/agent/repair-loop.d.ts +8 -1
- package/dist/agent/repair-loop.d.ts.map +1 -1
- package/dist/agent/repair-loop.js +18 -3
- package/dist/agent/repair-loop.js.map +1 -1
- package/dist/analyze/index.d.ts +1 -1
- package/dist/analyze/index.d.ts.map +1 -1
- package/dist/analyze/index.js +3 -2
- package/dist/analyze/index.js.map +1 -1
- package/dist/api/adversarial.d.ts +1 -1
- package/dist/api/adversarial.js +1 -1
- package/dist/api/collection.d.ts +20 -0
- package/dist/api/collection.d.ts.map +1 -0
- package/dist/api/collection.js +357 -0
- package/dist/api/collection.js.map +1 -0
- package/dist/api/derived.d.ts +179 -0
- package/dist/api/derived.d.ts.map +1 -0
- package/dist/api/derived.js +852 -0
- package/dist/api/derived.js.map +1 -0
- package/dist/api/discover.d.ts +66 -0
- package/dist/api/discover.d.ts.map +1 -0
- package/dist/api/discover.js +125 -0
- package/dist/api/discover.js.map +1 -0
- package/dist/api/flows.d.ts +194 -0
- package/dist/api/flows.d.ts.map +1 -0
- package/dist/api/flows.js +663 -0
- package/dist/api/flows.js.map +1 -0
- package/dist/api/guard.d.ts +19 -0
- package/dist/api/guard.d.ts.map +1 -1
- package/dist/api/guard.js +18 -4
- package/dist/api/guard.js.map +1 -1
- package/dist/api/openapi.d.ts +17 -1
- package/dist/api/openapi.d.ts.map +1 -1
- package/dist/api/openapi.js +64 -3
- package/dist/api/openapi.js.map +1 -1
- package/dist/api/runner.d.ts.map +1 -1
- package/dist/api/runner.js +18 -14
- package/dist/api/runner.js.map +1 -1
- package/dist/api/two-actor.d.ts +165 -0
- package/dist/api/two-actor.d.ts.map +1 -0
- package/dist/api/two-actor.js +627 -0
- package/dist/api/two-actor.js.map +1 -0
- package/dist/artifacts/contract.d.ts +1 -1
- package/dist/artifacts/contract.d.ts.map +1 -1
- package/dist/artifacts/index.d.ts +5 -0
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +14 -10
- package/dist/artifacts/index.js.map +1 -1
- package/dist/artifacts/report.d.ts +29 -2
- package/dist/artifacts/report.d.ts.map +1 -1
- package/dist/artifacts/report.js +65 -1
- package/dist/artifacts/report.js.map +1 -1
- package/dist/artifacts/testcase-md.d.ts +18 -0
- package/dist/artifacts/testcase-md.d.ts.map +1 -1
- package/dist/artifacts/testcase-md.js +15 -1
- package/dist/artifacts/testcase-md.js.map +1 -1
- package/dist/browser/api-traffic.d.ts +85 -0
- package/dist/browser/api-traffic.d.ts.map +1 -0
- package/dist/browser/api-traffic.js +283 -0
- package/dist/browser/api-traffic.js.map +1 -0
- package/dist/browser/backends/playwright-cli.d.ts.map +1 -1
- package/dist/browser/backends/playwright-cli.js +3 -0
- package/dist/browser/backends/playwright-cli.js.map +1 -1
- package/dist/browser/backends/playwright-lib.d.ts +84 -1
- package/dist/browser/backends/playwright-lib.d.ts.map +1 -1
- package/dist/browser/backends/playwright-lib.js +677 -32
- package/dist/browser/backends/playwright-lib.js.map +1 -1
- package/dist/browser/click-effect.d.ts +84 -0
- package/dist/browser/click-effect.d.ts.map +1 -0
- package/dist/browser/click-effect.js +235 -0
- package/dist/browser/click-effect.js.map +1 -0
- package/dist/browser/gateway.d.ts +9 -1
- package/dist/browser/gateway.d.ts.map +1 -1
- package/dist/browser/index.d.ts +3 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +5 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/types.d.ts +196 -1
- package/dist/browser/types.d.ts.map +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +123 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/codegen/index.d.ts +10 -1
- package/dist/codegen/index.d.ts.map +1 -1
- package/dist/codegen/index.js +28 -7
- package/dist/codegen/index.js.map +1 -1
- package/dist/codegen/lint.d.ts +32 -1
- package/dist/codegen/lint.d.ts.map +1 -1
- package/dist/codegen/lint.js +286 -1
- package/dist/codegen/lint.js.map +1 -1
- package/dist/codegen/mailbox.d.ts +19 -0
- package/dist/codegen/mailbox.d.ts.map +1 -0
- package/dist/codegen/mailbox.js +78 -0
- package/dist/codegen/mailbox.js.map +1 -0
- package/dist/codegen/schema.d.ts.map +1 -1
- package/dist/codegen/schema.js +3 -2
- package/dist/codegen/schema.js.map +1 -1
- package/dist/config/profiles.d.ts +2 -0
- package/dist/config/profiles.d.ts.map +1 -1
- package/dist/config/profiles.js +2 -0
- package/dist/config/profiles.js.map +1 -1
- package/dist/core/modalities/api.d.ts.map +1 -1
- package/dist/core/modalities/api.js +265 -29
- package/dist/core/modalities/api.js.map +1 -1
- package/dist/core/modalities/check-docs.d.ts +3 -0
- package/dist/core/modalities/check-docs.d.ts.map +1 -0
- package/dist/core/modalities/check-docs.js +64 -0
- package/dist/core/modalities/check-docs.js.map +1 -0
- package/dist/core/modalities/collect-docs.d.ts +3 -0
- package/dist/core/modalities/collect-docs.d.ts.map +1 -0
- package/dist/core/modalities/collect-docs.js +48 -0
- package/dist/core/modalities/collect-docs.js.map +1 -0
- package/dist/core/modalities/explore.d.ts.map +1 -1
- package/dist/core/modalities/explore.js +2 -0
- package/dist/core/modalities/explore.js.map +1 -1
- package/dist/core/modalities/mcp-test.d.ts +3 -0
- package/dist/core/modalities/mcp-test.d.ts.map +1 -0
- package/dist/core/modalities/mcp-test.js +26 -0
- package/dist/core/modalities/mcp-test.js.map +1 -0
- package/dist/core/registry.d.ts.map +1 -1
- package/dist/core/registry.js +11 -3
- package/dist/core/registry.js.map +1 -1
- package/dist/decider/uses/repair-triage.d.ts +9 -0
- package/dist/decider/uses/repair-triage.d.ts.map +1 -1
- package/dist/decider/uses/repair-triage.js +20 -3
- package/dist/decider/uses/repair-triage.js.map +1 -1
- package/dist/design/critique.d.ts +1 -1
- package/dist/design/index.d.ts +7 -1
- package/dist/design/index.d.ts.map +1 -1
- package/dist/design/index.js +20 -2
- package/dist/design/index.js.map +1 -1
- package/dist/design/schema.d.ts +9 -3
- package/dist/design/schema.d.ts.map +1 -1
- package/dist/design/schema.js +4 -1
- package/dist/design/schema.js.map +1 -1
- package/dist/documentarian/check.d.ts +91 -0
- package/dist/documentarian/check.d.ts.map +1 -0
- package/dist/documentarian/check.js +230 -0
- package/dist/documentarian/check.js.map +1 -0
- package/dist/documentarian/docs.d.ts +103 -0
- package/dist/documentarian/docs.d.ts.map +1 -0
- package/dist/documentarian/docs.js +243 -0
- package/dist/documentarian/docs.js.map +1 -0
- package/dist/documentarian/index.d.ts +2 -0
- package/dist/documentarian/index.d.ts.map +1 -1
- package/dist/documentarian/index.js +5 -4
- package/dist/documentarian/index.js.map +1 -1
- package/dist/environment/apply.js +1 -1
- package/dist/environment/apply.js.map +1 -1
- package/dist/flow/crawl.d.ts +4 -0
- package/dist/flow/crawl.d.ts.map +1 -1
- package/dist/flow/crawl.js +9 -2
- package/dist/flow/crawl.js.map +1 -1
- package/dist/fs/inside-dir.d.ts +8 -0
- package/dist/fs/inside-dir.d.ts.map +1 -0
- package/dist/fs/inside-dir.js +15 -0
- package/dist/fs/inside-dir.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/llm/index.d.ts +1 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +1 -1
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/structured.d.ts +19 -0
- package/dist/llm/structured.d.ts.map +1 -1
- package/dist/llm/structured.js +61 -0
- package/dist/llm/structured.js.map +1 -1
- package/dist/mailbox/doctor.d.ts +10 -0
- package/dist/mailbox/doctor.d.ts.map +1 -0
- package/dist/mailbox/doctor.js +33 -0
- package/dist/mailbox/doctor.js.map +1 -0
- package/dist/mailbox/rule.d.ts +34 -0
- package/dist/mailbox/rule.d.ts.map +1 -0
- package/dist/mailbox/rule.js +47 -0
- package/dist/mailbox/rule.js.map +1 -0
- package/dist/mailbox/session.d.ts +5 -0
- package/dist/mailbox/session.d.ts.map +1 -1
- package/dist/mailbox/session.js +8 -0
- package/dist/mailbox/session.js.map +1 -1
- package/dist/mcp/server.d.ts +15 -5
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +75 -27
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts +194 -82
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +82 -8
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp-test/adversarial.d.ts +80 -0
- package/dist/mcp-test/adversarial.d.ts.map +1 -0
- package/dist/mcp-test/adversarial.js +99 -0
- package/dist/mcp-test/adversarial.js.map +1 -0
- package/dist/mcp-test/advice.d.ts +20 -0
- package/dist/mcp-test/advice.d.ts.map +1 -0
- package/dist/mcp-test/advice.js +22 -0
- package/dist/mcp-test/advice.js.map +1 -0
- package/dist/mcp-test/call.d.ts +76 -0
- package/dist/mcp-test/call.d.ts.map +1 -0
- package/dist/mcp-test/call.js +105 -0
- package/dist/mcp-test/call.js.map +1 -0
- package/dist/mcp-test/cases.d.ts +154 -0
- package/dist/mcp-test/cases.d.ts.map +1 -0
- package/dist/mcp-test/cases.js +643 -0
- package/dist/mcp-test/cases.js.map +1 -0
- package/dist/mcp-test/connect.d.ts +70 -0
- package/dist/mcp-test/connect.d.ts.map +1 -0
- package/dist/mcp-test/connect.js +426 -0
- package/dist/mcp-test/connect.js.map +1 -0
- package/dist/mcp-test/coverage.d.ts +61 -0
- package/dist/mcp-test/coverage.d.ts.map +1 -0
- package/dist/mcp-test/coverage.js +76 -0
- package/dist/mcp-test/coverage.js.map +1 -0
- package/dist/mcp-test/discover.d.ts +40 -0
- package/dist/mcp-test/discover.d.ts.map +1 -0
- package/dist/mcp-test/discover.js +149 -0
- package/dist/mcp-test/discover.js.map +1 -0
- package/dist/mcp-test/guard.d.ts +161 -0
- package/dist/mcp-test/guard.d.ts.map +1 -0
- package/dist/mcp-test/guard.js +363 -0
- package/dist/mcp-test/guard.js.map +1 -0
- package/dist/mcp-test/model.d.ts +89 -0
- package/dist/mcp-test/model.d.ts.map +1 -0
- package/dist/mcp-test/model.js +88 -0
- package/dist/mcp-test/model.js.map +1 -0
- package/dist/mcp-test/payloads.d.ts +20 -0
- package/dist/mcp-test/payloads.d.ts.map +1 -0
- package/dist/mcp-test/payloads.js +20 -0
- package/dist/mcp-test/payloads.js.map +1 -0
- package/dist/mcp-test/report.d.ts +55 -0
- package/dist/mcp-test/report.d.ts.map +1 -0
- package/dist/mcp-test/report.js +157 -0
- package/dist/mcp-test/report.js.map +1 -0
- package/dist/mcp-test/run.d.ts +68 -0
- package/dist/mcp-test/run.d.ts.map +1 -0
- package/dist/mcp-test/run.js +467 -0
- package/dist/mcp-test/run.js.map +1 -0
- package/dist/mcp-test/runner.d.ts +133 -0
- package/dist/mcp-test/runner.d.ts.map +1 -0
- package/dist/mcp-test/runner.js +412 -0
- package/dist/mcp-test/runner.js.map +1 -0
- package/dist/mcp-test/schema.d.ts +103 -0
- package/dist/mcp-test/schema.d.ts.map +1 -0
- package/dist/mcp-test/schema.js +513 -0
- package/dist/mcp-test/schema.js.map +1 -0
- package/dist/mcp-test/secrets.d.ts +25 -0
- package/dist/mcp-test/secrets.d.ts.map +1 -0
- package/dist/mcp-test/secrets.js +67 -0
- package/dist/mcp-test/secrets.js.map +1 -0
- package/dist/observe/index.d.ts +3 -1
- package/dist/observe/index.d.ts.map +1 -1
- package/dist/observe/index.js +1 -0
- package/dist/observe/index.js.map +1 -1
- package/dist/observe/locator-hints.d.ts +18 -0
- package/dist/observe/locator-hints.d.ts.map +1 -0
- package/dist/observe/locator-hints.js +36 -0
- package/dist/observe/locator-hints.js.map +1 -0
- package/dist/observe/overlays.d.ts +135 -0
- package/dist/observe/overlays.d.ts.map +1 -0
- package/dist/observe/overlays.js +242 -0
- package/dist/observe/overlays.js.map +1 -0
- package/dist/observe/parse-aria.d.ts +7 -1
- package/dist/observe/parse-aria.d.ts.map +1 -1
- package/dist/observe/parse-aria.js +79 -4
- package/dist/observe/parse-aria.js.map +1 -1
- package/dist/probe/index.d.ts +3 -1
- package/dist/probe/index.d.ts.map +1 -1
- package/dist/probe/index.js +3 -2
- package/dist/probe/index.js.map +1 -1
- package/dist/project/index.d.ts +2 -0
- package/dist/project/index.d.ts.map +1 -1
- package/dist/project/index.js +10 -2
- package/dist/project/index.js.map +1 -1
- package/dist/prompts/local/describe-screen.d.ts +7 -0
- package/dist/prompts/local/describe-screen.d.ts.map +1 -0
- package/dist/prompts/local/describe-screen.js +29 -0
- package/dist/prompts/local/describe-screen.js.map +1 -0
- package/dist/prompts/local/index.d.ts.map +1 -1
- package/dist/prompts/local/index.js +7 -0
- package/dist/prompts/local/index.js.map +1 -1
- package/dist/prompts/local/name-overlays.d.ts +6 -0
- package/dist/prompts/local/name-overlays.d.ts.map +1 -0
- package/dist/prompts/local/name-overlays.js +16 -0
- package/dist/prompts/local/name-overlays.js.map +1 -0
- package/dist/prompts/local/qa-api-flows.d.ts +8 -0
- package/dist/prompts/local/qa-api-flows.d.ts.map +1 -0
- package/dist/prompts/local/qa-api-flows.js +19 -0
- package/dist/prompts/local/qa-api-flows.js.map +1 -0
- package/dist/prompts/local/qa-playwright-ts-writer.d.ts +1 -1
- package/dist/prompts/local/qa-playwright-ts-writer.d.ts.map +1 -1
- package/dist/prompts/local/qa-playwright-ts-writer.js +5 -1
- package/dist/prompts/local/qa-playwright-ts-writer.js.map +1 -1
- package/dist/prompts/local/qa-testcase-from-ui.d.ts +1 -1
- package/dist/prompts/local/qa-testcase-from-ui.d.ts.map +1 -1
- package/dist/prompts/local/qa-testcase-from-ui.js +2 -0
- package/dist/prompts/local/qa-testcase-from-ui.js.map +1 -1
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +24 -2
- package/dist/session/index.js.map +1 -1
- package/dist/validate/index.d.ts +11 -0
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +21 -0
- package/dist/validate/index.js.map +1 -1
- package/dist/validate/runner.d.ts +15 -1
- package/dist/validate/runner.d.ts.map +1 -1
- package/dist/validate/runner.js +158 -25
- package/dist/validate/runner.js.map +1 -1
- package/dist/validate/write-guard.d.ts +24 -0
- package/dist/validate/write-guard.d.ts.map +1 -0
- package/dist/validate/write-guard.js +210 -0
- package/dist/validate/write-guard.js.map +1 -0
- package/dist/view/index.d.ts +9 -0
- package/dist/view/index.d.ts.map +1 -0
- package/dist/view/index.js +126 -0
- package/dist/view/index.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** The fixture module the specs import when a page needs e-mail or TOTP (ADR-0023). */
|
|
2
|
+
export const MAILBOX_FIXTURE_FILE = "mailbox.fixture.ts";
|
|
3
|
+
const VAR_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
4
|
+
/**
|
|
5
|
+
* The `mail` fixture: a `MailboxSession` per test, cleaned up after it (also when it fails). Mailsac is built from the
|
|
6
|
+
* environment on first use, so a TOTP-only test needs no MAILSAC_API_KEY. Nothing in it is a value.
|
|
7
|
+
*/
|
|
8
|
+
export const MAILBOX_FIXTURE = `// Playwright fixture for the test mailbox and TOTP (cairn, ADR-0023). Written by cairn.
|
|
9
|
+
// Read from the environment when a test runs, by name: MAILSAC_API_KEY (MAILSAC_ADDRESS, MAILSAC_DOMAIN optional)
|
|
10
|
+
// and the TOTP secret variable a step names. No value is stored here.
|
|
11
|
+
import { test as base, expect } from '@playwright/test';
|
|
12
|
+
import { MailboxSession, mailsacFromEnv, type MailboxProvider } from '@plune-ai/cairn';
|
|
13
|
+
|
|
14
|
+
let mailsac: MailboxProvider | undefined;
|
|
15
|
+
const provider = (): MailboxProvider => (mailsac ??= mailsacFromEnv());
|
|
16
|
+
const lazy: MailboxProvider = {
|
|
17
|
+
name: 'mailsac',
|
|
18
|
+
createAddress: (runId) => provider().createAddress(runId),
|
|
19
|
+
list: (address) => provider().list(address),
|
|
20
|
+
cleanup: (address) => provider().cleanup(address),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const test = base.extend<{ mail: MailboxSession }>({
|
|
24
|
+
// eslint-disable-next-line no-empty-pattern
|
|
25
|
+
mail: async ({}, use, testInfo) => {
|
|
26
|
+
const mail = new MailboxSession({ provider: lazy, runId: testInfo.testId });
|
|
27
|
+
try {
|
|
28
|
+
await use(mail);
|
|
29
|
+
} finally {
|
|
30
|
+
await mail.cleanup();
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export { expect };
|
|
36
|
+
`;
|
|
37
|
+
/** One step as test code. Values never appear: only filters and the TOTP variable's NAME; `resolve` reads them late. */
|
|
38
|
+
function renderStep(step) {
|
|
39
|
+
if (step.action === "totp.code" && !VAR_NAME.test(step.secretEnv)) {
|
|
40
|
+
throw new Error("codegen: totp.code secretEnv must be the NAME of an environment variable, not a value");
|
|
41
|
+
}
|
|
42
|
+
switch (step.action) {
|
|
43
|
+
case "mailbox.openLink":
|
|
44
|
+
return "await page.goto(mail.resolve('{{mailbox.link}}'));";
|
|
45
|
+
case "mailbox.create":
|
|
46
|
+
return `await mail.run(${JSON.stringify(step)}); // then fill the e-mail field with mail.resolve('{{mailbox.address}}')`;
|
|
47
|
+
case "mailbox.extractCode":
|
|
48
|
+
return `await mail.run(${JSON.stringify(step)}); // then fill the code field with mail.resolve('{{mailbox.code}}')`;
|
|
49
|
+
case "totp.code":
|
|
50
|
+
return `await mail.run(${JSON.stringify(step)}); // then fill the code field with mail.resolve('{{totp.code}}')`;
|
|
51
|
+
default:
|
|
52
|
+
return `await mail.run(${JSON.stringify(step)});`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function renderMailboxSteps(steps) {
|
|
56
|
+
return steps.map(renderStep).join("\n");
|
|
57
|
+
}
|
|
58
|
+
/** What codegen is told when the rule fired and the steps are on: use the fixture, emit these steps, no literals. */
|
|
59
|
+
export function mailboxPromptSection(need) {
|
|
60
|
+
return [
|
|
61
|
+
`E-MAIL / TOTP: ${need.reason}. Import { test, expect } from './${MAILBOX_FIXTURE_FILE.replace(/\.ts$/, "")}' (not from '@playwright/test') and take the \`mail\` fixture.`,
|
|
62
|
+
`Emit these steps where the flow needs them${need.signal === "totp" ? "" : " (create the address before the e-mail field is filled)"}:`,
|
|
63
|
+
renderMailboxSteps(need.steps ?? []),
|
|
64
|
+
"Never write an address, link, code or secret as a literal: read each one through mail.resolve('{{...}}') only.",
|
|
65
|
+
].join("\n");
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The suite with the fixture module in it (in place of any file of that name the model wrote). A file that holds a
|
|
69
|
+
* value from `secrets` (the session's addresses, links and codes, the key, the TOTP secret) is never written.
|
|
70
|
+
*/
|
|
71
|
+
export function withMailboxFixture(suite, secrets) {
|
|
72
|
+
const files = [...suite.files.filter((f) => f.path !== MAILBOX_FIXTURE_FILE), { path: MAILBOX_FIXTURE_FILE, content: MAILBOX_FIXTURE }];
|
|
73
|
+
const leak = files.find((f) => secrets.some((s) => s.length >= 4 && f.content.includes(s)));
|
|
74
|
+
if (leak)
|
|
75
|
+
throw new Error(`codegen: ${leak.path} contains a mailbox/TOTP secret value; nothing was written`);
|
|
76
|
+
return { files };
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=mailbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailbox.js","sourceRoot":"","sources":["../../src/codegen/mailbox.ts"],"names":[],"mappings":"AAIA,uFAAuF;AACvF,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AAEzD,MAAM,QAAQ,GAAG,0BAA0B,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4B9B,CAAC;AAEF,wHAAwH;AACxH,SAAS,UAAU,CAAC,IAAiB;IACnC,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,uFAAuF,CAAC,CAAC;IAC3G,CAAC;IACD,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,kBAAkB;YACrB,OAAO,oDAAoD,CAAC;QAC9D,KAAK,gBAAgB;YACnB,OAAO,kBAAkB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,2EAA2E,CAAC;QAC3H,KAAK,qBAAqB;YACxB,OAAO,kBAAkB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,sEAAsE,CAAC;QACtH,KAAK,WAAW;YACd,OAAO,kBAAkB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,mEAAmE,CAAC;QACnH;YACE,OAAO,kBAAkB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;IACtD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAA6B;I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.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/codegen/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,cAAc;;;iBAGzB,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,eAAO,MAAM,oBAAoB;;;;;iBAEZ,CAAC;AACtB,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/codegen/schema.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { nameSchema } from "../llm/structured.js";
|
|
2
3
|
export const FileBlobSchema = z.object({
|
|
3
4
|
path: z.string(),
|
|
4
5
|
content: z.string(),
|
|
5
6
|
});
|
|
6
|
-
export const GeneratedSuiteSchema = z.object({
|
|
7
|
+
export const GeneratedSuiteSchema = nameSchema(z.object({
|
|
7
8
|
files: z.array(FileBlobSchema).min(1),
|
|
8
|
-
});
|
|
9
|
+
}), "GeneratedSuite");
|
|
9
10
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/codegen/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/codegen/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;IACtD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CACtC,CAAC,EAAE,gBAAgB,CAAC,CAAC"}
|
|
@@ -4,6 +4,8 @@ import type { LlmProfile, ModelsConfig, RolesConfig } from "./schema.js";
|
|
|
4
4
|
* everything is overridable via custom configuration.
|
|
5
5
|
*/
|
|
6
6
|
export declare const PROFILES: Record<LlmProfile, ModelsConfig>;
|
|
7
|
+
/** The preset names as a tuple, so a schema (the MCP tools' `routing` enum) can list them; a test keeps it equal to the keys of `ROUTING_PRESETS` below. */
|
|
8
|
+
export declare const ROUTING_PRESET_NAMES: readonly ["volume", "volume-fast", "fast"];
|
|
7
9
|
/**
|
|
8
10
|
* Named role-routing presets (L1-01, ADR-0011). Layered OVER a profile's tier map:
|
|
9
11
|
* a preset only sets the routable roles (`worker`/`reasoner`); the cheap `judge`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../src/config/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,YAAY,CAuBrD,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAwBvD,CAAC"}
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../src/config/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,YAAY,CAuBrD,CAAC;AAEF,4JAA4J;AAC5J,eAAO,MAAM,oBAAoB,4CAA6C,CAAC;AAE/E;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAwBvD,CAAC"}
|
package/dist/config/profiles.js
CHANGED
|
@@ -26,6 +26,8 @@ export const PROFILES = {
|
|
|
26
26
|
vision: { provider: "anthropic", model: "claude-haiku-4-5", supportsVision: true },
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
|
+
/** The preset names as a tuple, so a schema (the MCP tools' `routing` enum) can list them; a test keeps it equal to the keys of `ROUTING_PRESETS` below. */
|
|
30
|
+
export const ROUTING_PRESET_NAMES = ["volume", "volume-fast", "fast"];
|
|
29
31
|
/**
|
|
30
32
|
* Named role-routing presets (L1-01, ADR-0011). Layered OVER a profile's tier map:
|
|
31
33
|
* a preset only sets the routable roles (`worker`/`reasoner`); the cheap `judge`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../src/config/profiles.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAqC;IACxD,2BAA2B;IAC3B,SAAS,EAAE;QACT,SAAS,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,IAAI,EAAE;QACpF,IAAI,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,KAAK,EAAE;QAClF,KAAK,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,KAAK,EAAE;QAClF,MAAM,EAAE,EAAE,QAAQ,EAAE,WAA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AAQ,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,KAAK,EAAE;KACrF;IACD,aAAa,EAAE;QACb,4FAA4F;QAC5F,+FAA+F;QAC/F,MAAM,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,KAAK,EAAE;QACpF,kGAAkG;QAClG,QAAQ,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,KAAK,EAAE;KACrF;IACD,IAAI,EAAE;QACJ,0FAA0F;QAC1F,mFAAmF;QACnF,uFAAuF;QACvF,mGAAmG;QACnG,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,KAAK,EAAE;QACrF,wFAAwF;QACxF,QAAQ,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,KAAK,EAAE;KACrF;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/core/modalities/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/core/modalities/api.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIpE,OAAO,EAA2C,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE3F,OAAO,EAA2B,KAAK,aAAa,EAAsB,MAAM,qBAAqB,CAAC;AAkBtG,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAavF,OAAO,EAML,KAAK,iBAAiB,EAEvB,MAAM,uBAAuB,CAAC;AAM/B,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,gBAAgB,CAAC;AAkEhE;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,MAAM,EAAE,CAsB/D;AAkCD,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAc1E;AAED,4GAA4G;AAC5G,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAuBzD;AAED,yGAAyG;AACzG,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE,CASrE;AAED,6FAA6F;AAC7F,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,MAAM,EAAE,CAe3E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAmBvE;AA4HD,eAAO,MAAM,WAAW,EAAE,QAqSzB,CAAC"}
|
|
@@ -11,11 +11,17 @@
|
|
|
11
11
|
* (e.g. create → read → delete), threading a captured response value through each step.
|
|
12
12
|
* BORROW-07 (#95): with `--adversarial`, also generate/run cases in one or more named styles —
|
|
13
13
|
* normal/curious/psycho/hacker (`src/api/adversarial.ts`) — alongside the existing cases.
|
|
14
|
+
* #227: without `--spec`, look for a spec the `--base-url` server serves (`src/api/discover.ts`).
|
|
15
|
+
* #228: `--spec` also takes a Postman collection or a HAR file; it is converted to OpenAPI 3.x
|
|
16
|
+
* (`src/api/collection.ts`), saved as `openapi.derived.json` in the run's directory and read from there.
|
|
14
17
|
*/
|
|
15
18
|
import { randomUUID } from "node:crypto";
|
|
16
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
17
|
-
import { basename, join, resolve } from "node:path";
|
|
19
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
20
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
18
21
|
import { ingestOpenApi } from "../../api/openapi.js";
|
|
22
|
+
import { discoverSpec, readSpecFromUrl } from "../../api/discover.js";
|
|
23
|
+
import { deriveSpec } from "../../api/collection.js";
|
|
24
|
+
import { DERIVED_KEY, writeDerivedSpec } from "../../api/derived.js";
|
|
19
25
|
import { generateApiCases, generateNegativeCases } from "../../api/cases.js";
|
|
20
26
|
import { generateAdversarialCases, ADVERSARIAL_STYLES } from "../../api/adversarial.js";
|
|
21
27
|
import { runApiCases, wasNotSent } from "../../api/runner.js";
|
|
@@ -23,6 +29,8 @@ import { RequestGuard, BUDGET_EXIT_CODE, NOTHING_SENT_EXIT_CODE, MIN_RPS, parseB
|
|
|
23
29
|
import { generateApiScenarios } from "../../api/scenarios.js";
|
|
24
30
|
import { runApiScenarios } from "../../api/scenario-runner.js";
|
|
25
31
|
import { buildApiTestCaseDocs } from "../../api/testcase-docs.js";
|
|
32
|
+
import { FLOW_FIXTURE_FILE, flowChangesData, flowsFromScenarios, formatFlowsForPrompt, loadApiFlows, mergeApiFlows, renderFlowFixture, } from "../../api/flows.js";
|
|
33
|
+
import { actorHeaders, loadTwoActorPlan, renderTwoActorReport, runTwoActorChecks, twoActorAnswered, twoActorFailed } from "../../api/two-actor.js";
|
|
26
34
|
import { computeApiCoverage, evaluateCoverageGate, renderCoverageGate, parseMinCoverage, COVERAGE_GATE_EXIT_CODE, } from "../../api/coverage.js";
|
|
27
35
|
import { loadApiCreds } from "../../knowledge/index.js";
|
|
28
36
|
import { defaultRunsBaseDir } from "../../fs/run-dir.js";
|
|
@@ -211,12 +219,150 @@ export function renderApiCoverage(coverage) {
|
|
|
211
219
|
}
|
|
212
220
|
return lines;
|
|
213
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* #230: save the chains that delete what they create as API flows, merged into `file` (flows already there are
|
|
224
|
+
* kept; one with the same name is replaced). Writes the file only; nothing is sent.
|
|
225
|
+
*/
|
|
226
|
+
async function saveFlows(file, scenarios, ctx) {
|
|
227
|
+
const path = resolve(file);
|
|
228
|
+
const { flows, notSaved } = flowsFromScenarios(scenarios);
|
|
229
|
+
let existing = { version: 1, flows: [] };
|
|
230
|
+
try {
|
|
231
|
+
existing = await loadApiFlows(path);
|
|
232
|
+
}
|
|
233
|
+
catch (e) {
|
|
234
|
+
if (e.message.startsWith("Cannot read"))
|
|
235
|
+
existing = { version: 1, flows: [] }; // a new file
|
|
236
|
+
else
|
|
237
|
+
throw e; // never overwrite a file that is there but is not a valid flow file
|
|
238
|
+
}
|
|
239
|
+
const merged = mergeApiFlows(existing, flows);
|
|
240
|
+
await mkdir(dirname(path), { recursive: true });
|
|
241
|
+
await writeFile(path, `${JSON.stringify(merged, null, 2)}\n`, "utf8");
|
|
242
|
+
ctx.out(`✓ Saved ${flows.length} API flow(s) to ${path}${flows.length ? `: ${flows.map((f) => f.name).join(", ")}` : ""}\n`);
|
|
243
|
+
for (const n of notSaved)
|
|
244
|
+
ctx.out(` ⊘ ${n.name} not saved — ${n.reason}\n`);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* #230: `cairn api --flows <file>` — write the Playwright fixture for the flows in `file` into `--out` (default
|
|
248
|
+
* runs/api-<id>/). No request is sent. A flow that changes data may run only against the `--base-url` origin, and
|
|
249
|
+
* only with `--allow-mutations`; otherwise its tests are skipped until CAIRN_ALLOW_MUTATIONS names the address.
|
|
250
|
+
*/
|
|
251
|
+
async function writeFlowFixture(opts, ctx) {
|
|
252
|
+
if (opts.spec !== undefined || opts.scenarios || opts.saveFlows !== undefined) {
|
|
253
|
+
throw new Error("--flows writes the fixture from a saved flow file: run it without --spec, --scenarios and --save-flows.");
|
|
254
|
+
}
|
|
255
|
+
const base = opts.baseUrl === undefined ? undefined : parseBaseUrl(opts.baseUrl);
|
|
256
|
+
const source = resolve(opts.flows);
|
|
257
|
+
let file;
|
|
258
|
+
try {
|
|
259
|
+
file = await loadApiFlows(source);
|
|
260
|
+
}
|
|
261
|
+
catch (e) {
|
|
262
|
+
ctx.err(`✗ ${e.message}\n`);
|
|
263
|
+
process.exitCode = 1;
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (opts.allowMutations && !base)
|
|
267
|
+
ctx.err("⚠ --allow-mutations has no effect with --flows without --base-url: it allows that address only.\n");
|
|
268
|
+
const allowFor = opts.allowMutations && base ? base.baseUrl : undefined;
|
|
269
|
+
const outDir = opts.out ? resolve(opts.out) : join(defaultRunsBaseDir(), `api-${randomUUID()}`);
|
|
270
|
+
await mkdir(outDir, { recursive: true });
|
|
271
|
+
const target = join(outDir, FLOW_FIXTURE_FILE);
|
|
272
|
+
await writeFile(target, renderFlowFixture(file, { baseUrl: base?.baseUrl, allowMutationsFor: allowFor, source: basename(source) }), "utf8");
|
|
273
|
+
ctx.out(`=== API flows (${file.flows.length}) from ${source} ===\n${formatFlowsForPrompt(file)}\n`);
|
|
274
|
+
const changing = file.flows.filter(flowChangesData).map((f) => f.name);
|
|
275
|
+
if (changing.length && allowFor)
|
|
276
|
+
ctx.out(`Flows that change data may run against ${new URL(allowFor).origin} (--allow-mutations).\n`);
|
|
277
|
+
else if (changing.length) {
|
|
278
|
+
ctx.out(`⚠ ${changing.join(", ")} change data: their tests are skipped until an address is allowed ` +
|
|
279
|
+
"(--base-url <url> --allow-mutations here, or CAIRN_ALLOW_MUTATIONS=<origin> when the tests run).\n");
|
|
280
|
+
}
|
|
281
|
+
ctx.out(`✓ Fixture → ${target}\n Use it in a spec: import { test, expect } from './${FLOW_FIXTURE_FILE.replace(/\.ts$/, "")}';\n`);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* #233: `cairn api --base-url <url> --actors <file> --allow-mutations` — the two-actor check (`src/api/two-actor.ts`).
|
|
285
|
+
* Every request goes through the same {@link RequestGuard} as the rest of `cairn api`: without `--allow-mutations`
|
|
286
|
+
* nothing is sent, and `--allowed-methods` / `--allowed-paths` / `--max-requests` / `--rps` hold as for any case.
|
|
287
|
+
*/
|
|
288
|
+
async function runActorsCheck(opts, ctx) {
|
|
289
|
+
if (opts.spec !== undefined || opts.scenarios || opts.saveFlows !== undefined || opts.flows !== undefined || opts.adversarial || opts.negative) {
|
|
290
|
+
throw new Error("--actors runs the two-actor check from its own file: run it without --spec, --scenarios, --save-flows, --flows, --negative and --adversarial.");
|
|
291
|
+
}
|
|
292
|
+
if (opts.baseUrl === undefined)
|
|
293
|
+
throw new Error("--actors needs --base-url <url>: the staging address the check may create data on.");
|
|
294
|
+
const maxRequests = opts.maxRequests === undefined ? DEFAULT_MAX_REQUESTS : parsePositiveInt("--max-requests", opts.maxRequests);
|
|
295
|
+
const rps = opts.rps === undefined ? DEFAULT_RPS : parsePositiveNumber("--rps", opts.rps, MIN_RPS);
|
|
296
|
+
const allowedMethods = opts.allowedMethods === undefined ? undefined : parseList(opts.allowedMethods);
|
|
297
|
+
const allowedPaths = opts.allowedPaths === undefined ? undefined : parseList(opts.allowedPaths);
|
|
298
|
+
if (allowedMethods && allowedMethods.length === 0)
|
|
299
|
+
throw new Error("--allowed-methods needs at least one method (e.g. GET,HEAD).");
|
|
300
|
+
if (allowedPaths && allowedPaths.length === 0)
|
|
301
|
+
throw new Error("--allowed-paths needs at least one path mask (e.g. /pets/*).");
|
|
302
|
+
const base = parseBaseUrl(opts.baseUrl);
|
|
303
|
+
const secrets = [...base.secrets];
|
|
304
|
+
const out = (s) => ctx.out(maskSecrets(s, secrets));
|
|
305
|
+
const err = (s) => ctx.err(maskSecrets(s, secrets));
|
|
306
|
+
const guard = new RequestGuard({ allowMutations: opts.allowMutations, allowedMethods, allowedPaths, maxRequests, rps });
|
|
307
|
+
let plan;
|
|
308
|
+
let owner;
|
|
309
|
+
let other;
|
|
310
|
+
try {
|
|
311
|
+
plan = await loadTwoActorPlan(resolve(opts.actors));
|
|
312
|
+
owner = await actorHeaders(plan.file.actors.owner, plan, base.baseUrl);
|
|
313
|
+
other = await actorHeaders(plan.file.actors.other, plan, base.baseUrl);
|
|
314
|
+
}
|
|
315
|
+
catch (e) {
|
|
316
|
+
err(`✗ ${e.message}\n`);
|
|
317
|
+
process.exitCode = 1;
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
for (const h of [owner, other]) {
|
|
321
|
+
if (base.basicAuth && !Object.keys(h).some((k) => k.toLowerCase() === "authorization"))
|
|
322
|
+
h["Authorization"] = base.basicAuth;
|
|
323
|
+
secrets.push(...collectSecrets(h));
|
|
324
|
+
}
|
|
325
|
+
if (!opts.allowMutations) {
|
|
326
|
+
err("⚠ The two-actor check creates data with the owner's flow: it needs --allow-mutations, for a staging address only. Nothing is sent.\n");
|
|
327
|
+
}
|
|
328
|
+
err(`▸ Two-actor check: ${plan.file.checks.length} check(s) against ${base.baseUrl}…\n`);
|
|
329
|
+
const report = await runTwoActorChecks(plan, { baseUrl: base.baseUrl, guard, owner, other, role: plan.file.actors.other.role });
|
|
330
|
+
const guardrails = guard.report();
|
|
331
|
+
const outDir = opts.out ? resolve(opts.out) : join(defaultRunsBaseDir(), `api-${randomUUID()}`);
|
|
332
|
+
await mkdir(outDir, { recursive: true });
|
|
333
|
+
const reportPath = join(outDir, "two-actor.json");
|
|
334
|
+
await writeFile(reportPath, maskSecrets(JSON.stringify({ schemaVersion: ARTIFACT_SCHEMA_VERSION, mode: "api-two-actor", ...report, guardrails }, null, 2), secrets), "utf8");
|
|
335
|
+
for (const line of renderTwoActorReport(report))
|
|
336
|
+
out(`${line}\n`);
|
|
337
|
+
for (const line of renderGuardrails(guardrails))
|
|
338
|
+
out(`${line}\n`);
|
|
339
|
+
out(` Report: ${displayPath(reportPath)}\n`);
|
|
340
|
+
// Same exit codes and order as the rest of `cairn api`: 1 a finding (or a check that could not finish) > 4 a check the
|
|
341
|
+
// budget could not cover > 5 no probe answered, whatever the owner's own requests got.
|
|
342
|
+
if (twoActorFailed(report))
|
|
343
|
+
process.exitCode = 1;
|
|
344
|
+
else if (guardrails.budgetExhausted)
|
|
345
|
+
process.exitCode = BUDGET_EXIT_CODE;
|
|
346
|
+
else if (!twoActorAnswered(report)) {
|
|
347
|
+
err("✗ No probe got an answer from the other actor (see the checks and Guardrails above), so nothing was tested.\n");
|
|
348
|
+
process.exitCode = NOTHING_SENT_EXIT_CODE;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
214
351
|
export const apiModality = {
|
|
215
352
|
name: "api",
|
|
216
353
|
gated: false,
|
|
217
354
|
summary: "Generate API / contract tests from an OpenAPI spec",
|
|
218
355
|
async run(rawCtx) {
|
|
219
356
|
const opts = rawCtx.flags;
|
|
357
|
+
// #230: --flows is its own mode — it writes the fixture and sends nothing.
|
|
358
|
+
// #233: --actors is its own mode — the two-actor check, through the same guardrails.
|
|
359
|
+
if (opts.actors !== undefined)
|
|
360
|
+
return runActorsCheck(opts, rawCtx);
|
|
361
|
+
if (opts.flows !== undefined)
|
|
362
|
+
return writeFlowFixture(opts, rawCtx);
|
|
363
|
+
if (opts.saveFlows !== undefined && !opts.scenarios) {
|
|
364
|
+
throw new Error("--save-flows saves the chains --scenarios makes: add --scenarios.");
|
|
365
|
+
}
|
|
220
366
|
// #196: every line the run prints passes through the secret scrubber (the list is filled once the headers are known).
|
|
221
367
|
const secrets = [];
|
|
222
368
|
const ctx = {
|
|
@@ -238,9 +384,8 @@ export const apiModality = {
|
|
|
238
384
|
if (allowedPaths && allowedPaths.length === 0)
|
|
239
385
|
throw new Error("--allowed-paths needs at least one path mask (e.g. /pets/*).");
|
|
240
386
|
const spec = opts.spec;
|
|
241
|
-
if (!spec) {
|
|
242
|
-
|
|
243
|
-
throw new Error("`cairn api` requires --spec <path|url> (an OpenAPI 3.x JSON/YAML spec).");
|
|
387
|
+
if (!spec && !base) {
|
|
388
|
+
throw new Error("`cairn api` needs --spec <path|url> (an OpenAPI 3.x JSON/YAML spec) or --base-url <url> (to look for a spec the server serves).");
|
|
244
389
|
}
|
|
245
390
|
// Validate before any work: a bad threshold must not look like a passing run.
|
|
246
391
|
const minCoverage = opts.minCoverage === undefined ? undefined : parseMinCoverage(opts.minCoverage);
|
|
@@ -257,17 +402,120 @@ export const apiModality = {
|
|
|
257
402
|
if (!gate.passed && !process.exitCode)
|
|
258
403
|
process.exitCode = COVERAGE_GATE_EXIT_CODE;
|
|
259
404
|
};
|
|
260
|
-
|
|
261
|
-
|
|
405
|
+
// Auth/headers: api-scope knowledge (#92) as the base, config --header flags on top (config wins).
|
|
406
|
+
// Built before the spec is read: a spec looked up on the base URL (#227) may sit behind the same sign-in.
|
|
407
|
+
const headers = {};
|
|
408
|
+
if (!base) {
|
|
409
|
+
// #234: --header also reaches a spec read from a URL when there is no --base-url
|
|
410
|
+
Object.assign(headers, parseHeaderFlags(opts.header));
|
|
411
|
+
secrets.push(...collectSecrets(headers));
|
|
412
|
+
}
|
|
413
|
+
if (base) {
|
|
414
|
+
const knowledgeDir = resolve(opts.knowledgeDir ?? "knowledge");
|
|
415
|
+
Object.assign(headers, await loadApiCreds(knowledgeDir, { scope: "api", endpoint: base.baseUrl }), parseHeaderFlags(opts.header));
|
|
416
|
+
if (base.basicAuth && !Object.keys(headers).some((h) => h.toLowerCase() === "authorization")) {
|
|
417
|
+
headers["Authorization"] = base.basicAuth;
|
|
418
|
+
}
|
|
419
|
+
const weak = tooShortSecrets(headers);
|
|
420
|
+
if (weak.length) {
|
|
421
|
+
ctx.err(`⚠ The secret in ${weak.join(", ")} is shorter than 4 characters and will NOT be masked in the output.\n`);
|
|
422
|
+
}
|
|
423
|
+
secrets.push(...collectSecrets(headers));
|
|
424
|
+
}
|
|
425
|
+
// One guard for the whole run: the spec lookup's tries and the cases share its budget and rate limit.
|
|
426
|
+
const guard = new RequestGuard({ allowMutations: opts.allowMutations, allowedMethods, allowedPaths, maxRequests, rps });
|
|
427
|
+
const outDir = opts.out ? resolve(opts.out) : join(defaultRunsBaseDir(), `api-${randomUUID()}`);
|
|
428
|
+
let source;
|
|
262
429
|
let model;
|
|
263
|
-
|
|
264
|
-
|
|
430
|
+
let specLookup; // #227: what the lookup on the server did, for the guardrails report
|
|
431
|
+
if (spec) {
|
|
432
|
+
source = isUrl(spec) ? spec : resolve(spec);
|
|
433
|
+
let ingestFrom = source;
|
|
434
|
+
// #228: a local Postman collection or HAR becomes an OpenAPI spec in the run's directory, read from there.
|
|
435
|
+
const text = isUrl(spec) ? undefined : await readFile(source, "utf8").catch(() => undefined);
|
|
436
|
+
let derived;
|
|
437
|
+
try {
|
|
438
|
+
derived = text === undefined ? undefined : deriveSpec(text, secrets);
|
|
439
|
+
}
|
|
440
|
+
catch (e) {
|
|
441
|
+
ctx.err(`✗ Could not read ${source}: ${e.message}\n`);
|
|
442
|
+
process.exitCode = 1;
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
if (derived) {
|
|
446
|
+
ctx.err(`▸ ${derived.format === "har" ? "HAR file" : "Postman collection"} detected: converting it to OpenAPI 3.x…\n`);
|
|
447
|
+
for (const note of derived.notes)
|
|
448
|
+
ctx.err(` ${note}\n`);
|
|
449
|
+
secrets.push(...derived.secrets);
|
|
450
|
+
ingestFrom = await writeDerivedSpec(outDir, derived.doc, secrets);
|
|
451
|
+
ctx.out(`✓ Derived OpenAPI spec saved to ${ingestFrom} — operations and schemas inferred from examples (${DERIVED_KEY})\n`);
|
|
452
|
+
}
|
|
453
|
+
ctx.err(`▸ Ingesting OpenAPI spec from ${ingestFrom}…\n`);
|
|
454
|
+
try {
|
|
455
|
+
if (isUrl(spec)) {
|
|
456
|
+
// #234: read the text like the lookup does (GET, no redirect, deadline, run headers, shared guard), so a
|
|
457
|
+
// local or private address works and a refusal says what happened. The parser gets the text, not the address.
|
|
458
|
+
const unreadable = (why) => new Error(`Could not read OpenAPI spec "${source}": ${why}`);
|
|
459
|
+
if (!guard.allowsMethod("GET"))
|
|
460
|
+
throw unreadable("--allowed-methods does not include GET, the only method the read sends.");
|
|
461
|
+
if (!(await guard.acquire()))
|
|
462
|
+
throw unreadable(`the request budget ran out (--max-requests ${guard.maxRequests}).`);
|
|
463
|
+
// The run's credentials (api-scope knowledge, Basic auth from --base-url, --header) belong to the target:
|
|
464
|
+
// they go with the read only when the spec sits on the --base-url origin, or when there is no --base-url.
|
|
465
|
+
const specOrigin = new URL(source).origin;
|
|
466
|
+
const credsGo = !base || new URL(base.baseUrl).origin === specOrigin;
|
|
467
|
+
const specHeaders = credsGo ? headers : {};
|
|
468
|
+
const withheld = credsGo
|
|
469
|
+
? ""
|
|
470
|
+
: ` The run's credentials are not sent to ${specOrigin}, because it is not the --base-url origin; download the spec and pass it as a file.`;
|
|
471
|
+
const got = await readSpecFromUrl(source, specHeaders);
|
|
472
|
+
if (!got.ok)
|
|
473
|
+
throw unreadable(`${got.message}${withheld}`);
|
|
474
|
+
// A $ref on the spec's origin is read the same way (one more request of the budget); any other is refused.
|
|
475
|
+
const readRef = async (url) => {
|
|
476
|
+
if (!(await guard.acquire()))
|
|
477
|
+
throw new Error(`the request budget ran out (--max-requests ${guard.maxRequests}) reading ${url}.`);
|
|
478
|
+
const ref = await readSpecFromUrl(url, specHeaders);
|
|
479
|
+
if (!ref.ok)
|
|
480
|
+
throw new Error(`could not read $ref ${url}: ${ref.message}`);
|
|
481
|
+
return ref.text;
|
|
482
|
+
};
|
|
483
|
+
model = await ingestOpenApi(source, got.text, { readRef });
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
model = await ingestOpenApi(ingestFrom);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
catch (e) {
|
|
490
|
+
// Clean, non-crashing failure (acceptance): clear message, exit non-zero.
|
|
491
|
+
ctx.err(`✗ ${e.message}\n`);
|
|
492
|
+
process.exitCode = 1;
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
265
495
|
}
|
|
266
|
-
|
|
267
|
-
//
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
496
|
+
else {
|
|
497
|
+
// #227: no --spec — try the addresses frameworks serve their spec at, then go on as if that spec had been given.
|
|
498
|
+
const baseUrl = base.baseUrl; // no --spec means --base-url was given (checked above)
|
|
499
|
+
ctx.err(`▸ No --spec given: looking for an OpenAPI spec served at ${baseUrl}…\n`);
|
|
500
|
+
const found = await discoverSpec({ baseUrl, headers, guard });
|
|
501
|
+
if (!found.found) {
|
|
502
|
+
const lines = [`✗ No OpenAPI 3.x spec found at ${baseUrl}.`];
|
|
503
|
+
if (found.tried.length)
|
|
504
|
+
lines.push(" Tried (GET):", ...found.tried.map((t) => ` ${t.url} — ${t.outcome}`));
|
|
505
|
+
if (found.skipped.length)
|
|
506
|
+
lines.push(" Skipped (not requested):", ...found.skipped.map((t) => ` ${t.url} — ${t.outcome}`));
|
|
507
|
+
if (found.stopped)
|
|
508
|
+
lines.push(` Stopped: ${found.stopped}.`);
|
|
509
|
+
lines.push(" Give the spec instead: --spec <path|url> (an OpenAPI 3.x JSON/YAML file or URL).");
|
|
510
|
+
ctx.err(`${lines.join("\n")}\n`);
|
|
511
|
+
// A budget spent on the lookup is the same outcome as one spent on the cases.
|
|
512
|
+
process.exitCode = guard.budgetExhausted ? BUDGET_EXIT_CODE : 1;
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
source = found.url;
|
|
516
|
+
model = found.model;
|
|
517
|
+
specLookup = { requests: found.tried.length + 1, foundAt: found.url, tried: found.tried, skipped: found.skipped };
|
|
518
|
+
ctx.out(`✓ OpenAPI spec found at ${source}\n`);
|
|
271
519
|
}
|
|
272
520
|
for (const line of renderApiSummary(model, source))
|
|
273
521
|
ctx.out(`${line}\n`);
|
|
@@ -295,6 +543,8 @@ export const apiModality = {
|
|
|
295
543
|
const scenarios = opts.scenarios ? generateApiScenarios(model) : [];
|
|
296
544
|
for (const line of renderApiScenarios(scenarios))
|
|
297
545
|
ctx.out(`${line}\n`);
|
|
546
|
+
if (opts.saveFlows !== undefined)
|
|
547
|
+
await saveFlows(opts.saveFlows, scenarios, ctx);
|
|
298
548
|
// API-3: without --base-url we stop at the generated cases (API-1/2 behaviour, unchanged).
|
|
299
549
|
if (!base) {
|
|
300
550
|
// API-6 (#136): coverage is meaningful even without a run — it's spec-vs-generated-cases.
|
|
@@ -305,23 +555,10 @@ export const apiModality = {
|
|
|
305
555
|
ctx.out("Note: cases only. Pass --base-url <url> to execute them and assert responses (API-3).\n");
|
|
306
556
|
return;
|
|
307
557
|
}
|
|
308
|
-
// Auth/headers: api-scope knowledge (#92) as the base, config --header flags on top (config wins).
|
|
309
|
-
const knowledgeDir = resolve(opts.knowledgeDir ?? "knowledge");
|
|
310
|
-
const fromKnowledge = await loadApiCreds(knowledgeDir, { scope: "api", endpoint: base.baseUrl });
|
|
311
|
-
const headers = { ...fromKnowledge, ...parseHeaderFlags(opts.header) };
|
|
312
|
-
if (base.basicAuth && !Object.keys(headers).some((h) => h.toLowerCase() === "authorization")) {
|
|
313
|
-
headers["Authorization"] = base.basicAuth;
|
|
314
|
-
}
|
|
315
|
-
const weak = tooShortSecrets(headers);
|
|
316
|
-
if (weak.length) {
|
|
317
|
-
ctx.err(`⚠ The secret in ${weak.join(", ")} is shorter than 4 characters and will NOT be masked in the output.\n`);
|
|
318
|
-
}
|
|
319
|
-
secrets.push(...collectSecrets(headers));
|
|
320
558
|
const adversarialNeedsMutations = adversarialStyles.some((s) => s === "psycho" || s === "hacker");
|
|
321
559
|
if (adversarialNeedsMutations && !opts.allowMutations) {
|
|
322
560
|
ctx.err("⚠ The psycho/hacker styles need --allow-mutations; their cases are listed but will not be sent.\n");
|
|
323
561
|
}
|
|
324
|
-
const guard = new RequestGuard({ allowMutations: opts.allowMutations, allowedMethods, allowedPaths, maxRequests, rps });
|
|
325
562
|
const runnerOpts = { baseUrl: base.baseUrl, auth: { headers }, guard, secrets };
|
|
326
563
|
ctx.err(`▸ Running ${cases.length} case(s) against ${base.baseUrl}…\n`);
|
|
327
564
|
const results = await runApiCases(cases, runnerOpts);
|
|
@@ -330,7 +567,6 @@ export const apiModality = {
|
|
|
330
567
|
const coverageGate = evalGate(coverage); // evaluated before the report files so they carry the verdict
|
|
331
568
|
// API-9 (#146): scenario chains run after the per-operation cases — independent of them.
|
|
332
569
|
const scenarioResults = scenarios.length ? await runApiScenarios(scenarios, runnerOpts) : [];
|
|
333
|
-
const outDir = opts.out ? resolve(opts.out) : join(defaultRunsBaseDir(), `api-${randomUUID()}`);
|
|
334
570
|
await mkdir(outDir, { recursive: true });
|
|
335
571
|
const evidencePath = join(outDir, "api-evidence.json");
|
|
336
572
|
// #196: nothing reaches disk with a secret in it, whatever field it ended up in.
|
|
@@ -340,7 +576,7 @@ export const apiModality = {
|
|
|
340
576
|
// past-run browser already read for web runs — no parallel reporting layer.
|
|
341
577
|
const sent = results.filter((r) => !wasNotSent(r));
|
|
342
578
|
const passed = sent.filter((r) => r.passed).length;
|
|
343
|
-
const guardrails = guard.report();
|
|
579
|
+
const guardrails = specLookup ? { ...guard.report(), specLookup } : guard.report();
|
|
344
580
|
const runId = basename(outDir);
|
|
345
581
|
await write(join(outDir, "report.json"), JSON.stringify({
|
|
346
582
|
schemaVersion: ARTIFACT_SCHEMA_VERSION,
|