caisson-cli 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/README.math-mvp.md +28 -0
  2. package/README.md +56 -3
  3. package/dist/admin/adminRoutes.d.ts +10 -0
  4. package/dist/admin/adminRoutes.js +194 -0
  5. package/dist/admin/adminRoutes.js.map +1 -0
  6. package/dist/admin/index.d.ts +2 -0
  7. package/dist/admin/index.js +4 -0
  8. package/dist/admin/index.js.map +1 -0
  9. package/dist/admin/workspaceAdmin.d.ts +417 -0
  10. package/dist/admin/workspaceAdmin.js +569 -0
  11. package/dist/admin/workspaceAdmin.js.map +1 -0
  12. package/dist/analytics/index.d.ts +1 -0
  13. package/dist/analytics/index.js +3 -0
  14. package/dist/analytics/index.js.map +1 -0
  15. package/dist/analytics/metrics.d.ts +105 -0
  16. package/dist/analytics/metrics.js +837 -0
  17. package/dist/analytics/metrics.js.map +1 -0
  18. package/dist/audit/index.d.ts +4 -0
  19. package/dist/audit/index.js +6 -0
  20. package/dist/audit/index.js.map +1 -0
  21. package/dist/audit/pipeline.d.ts +90 -0
  22. package/dist/audit/pipeline.js +424 -0
  23. package/dist/audit/pipeline.js.map +1 -0
  24. package/dist/audit/receiptSchema.d.ts +441 -0
  25. package/dist/audit/receiptSchema.js +208 -0
  26. package/dist/audit/receiptSchema.js.map +1 -0
  27. package/dist/audit/stageA.d.ts +50 -0
  28. package/dist/audit/stageA.js +218 -0
  29. package/dist/audit/stageA.js.map +1 -0
  30. package/dist/audit/stageB.d.ts +48 -0
  31. package/dist/audit/stageB.js +113 -0
  32. package/dist/audit/stageB.js.map +1 -0
  33. package/dist/auth/agentAuth.d.ts +28 -0
  34. package/dist/auth/agentAuth.js +88 -0
  35. package/dist/auth/agentAuth.js.map +1 -0
  36. package/dist/auth/agentCardSigner.d.ts +55 -0
  37. package/dist/auth/agentCardSigner.js +188 -0
  38. package/dist/auth/agentCardSigner.js.map +1 -0
  39. package/dist/billing/billingRoutes.d.ts +11 -0
  40. package/dist/billing/billingRoutes.js +303 -0
  41. package/dist/billing/billingRoutes.js.map +1 -0
  42. package/dist/billing/bountyRoutes.d.ts +9 -0
  43. package/dist/billing/bountyRoutes.js +332 -0
  44. package/dist/billing/bountyRoutes.js.map +1 -0
  45. package/dist/billing/index.d.ts +3 -0
  46. package/dist/billing/index.js +4 -0
  47. package/dist/billing/index.js.map +1 -0
  48. package/dist/billing/subscriptions.d.ts +226 -0
  49. package/dist/billing/subscriptions.js +673 -0
  50. package/dist/billing/subscriptions.js.map +1 -0
  51. package/dist/cli/caissonCli.d.ts +15 -0
  52. package/dist/cli/caissonCli.js +528 -0
  53. package/dist/cli/caissonCli.js.map +1 -0
  54. package/dist/cli/doctor.d.ts +31 -0
  55. package/dist/cli/doctor.js +321 -0
  56. package/dist/cli/doctor.js.map +1 -0
  57. package/dist/cli/inviteCard.d.ts +25 -0
  58. package/dist/cli/inviteCard.js +111 -0
  59. package/dist/cli/inviteCard.js.map +1 -0
  60. package/dist/cli/mcpProxy.d.ts +36 -0
  61. package/dist/cli/mcpProxy.js +292 -0
  62. package/dist/cli/mcpProxy.js.map +1 -0
  63. package/dist/config.d.ts +19 -0
  64. package/dist/config.js +28 -0
  65. package/dist/config.js.map +1 -0
  66. package/dist/db/adapter.d.ts +210 -0
  67. package/dist/db/adapter.js +769 -0
  68. package/dist/db/adapter.js.map +1 -0
  69. package/dist/db/sqlite.d.ts +7 -0
  70. package/dist/db/sqlite.js +60 -0
  71. package/dist/db/sqlite.js.map +1 -0
  72. package/dist/db/telemetry.d.ts +11 -0
  73. package/dist/db/telemetry.js +9 -0
  74. package/dist/db/telemetry.js.map +1 -0
  75. package/dist/economy/bountyEngine.d.ts +248 -0
  76. package/dist/economy/bountyEngine.js +836 -0
  77. package/dist/economy/bountyEngine.js.map +1 -0
  78. package/dist/economy/index.d.ts +5 -0
  79. package/dist/economy/index.js +6 -0
  80. package/dist/economy/index.js.map +1 -0
  81. package/dist/economy/scLedger.d.ts +183 -0
  82. package/dist/economy/scLedger.js +528 -0
  83. package/dist/economy/scLedger.js.map +1 -0
  84. package/dist/economy/scMinting.d.ts +177 -0
  85. package/dist/economy/scMinting.js +659 -0
  86. package/dist/economy/scMinting.js.map +1 -0
  87. package/dist/economy/scSinks.d.ts +135 -0
  88. package/dist/economy/scSinks.js +314 -0
  89. package/dist/economy/scSinks.js.map +1 -0
  90. package/dist/economy/usdLedger.d.ts +211 -0
  91. package/dist/economy/usdLedger.js +604 -0
  92. package/dist/economy/usdLedger.js.map +1 -0
  93. package/dist/mcp/handlers.d.ts +136 -0
  94. package/dist/mcp/handlers.js +809 -0
  95. package/dist/mcp/handlers.js.map +1 -0
  96. package/dist/mcp/httpServer.d.ts +29 -0
  97. package/dist/mcp/httpServer.js +384 -0
  98. package/dist/mcp/httpServer.js.map +1 -0
  99. package/dist/mcp/serverFactory.d.ts +4 -0
  100. package/dist/mcp/serverFactory.js +53 -0
  101. package/dist/mcp/serverFactory.js.map +1 -0
  102. package/dist/mcp/stdioServer.d.ts +2 -0
  103. package/dist/mcp/stdioServer.js +24 -0
  104. package/dist/mcp/stdioServer.js.map +1 -0
  105. package/dist/mcp/toolMetadata.d.ts +15 -0
  106. package/dist/mcp/toolMetadata.js +73 -0
  107. package/dist/mcp/toolMetadata.js.map +1 -0
  108. package/dist/memo/artifactIndex.d.ts +51 -0
  109. package/dist/memo/artifactIndex.js +162 -0
  110. package/dist/memo/artifactIndex.js.map +1 -0
  111. package/dist/memo/dependencyBundle.d.ts +33 -0
  112. package/dist/memo/dependencyBundle.js +86 -0
  113. package/dist/memo/dependencyBundle.js.map +1 -0
  114. package/dist/memo/embeddings.d.ts +110 -0
  115. package/dist/memo/embeddings.js +672 -0
  116. package/dist/memo/embeddings.js.map +1 -0
  117. package/dist/packs/foundryEvm.d.ts +21 -0
  118. package/dist/packs/foundryEvm.js +274 -0
  119. package/dist/packs/foundryEvm.js.map +1 -0
  120. package/dist/packs/index.d.ts +8 -0
  121. package/dist/packs/index.js +19 -0
  122. package/dist/packs/index.js.map +1 -0
  123. package/dist/packs/mathLean4.d.ts +7 -0
  124. package/dist/packs/mathLean4.js +145 -0
  125. package/dist/packs/mathLean4.js.map +1 -0
  126. package/dist/packs/rustKani.d.ts +17 -0
  127. package/dist/packs/rustKani.js +257 -0
  128. package/dist/packs/rustKani.js.map +1 -0
  129. package/dist/packs/sdk.d.ts +314 -0
  130. package/dist/packs/sdk.js +271 -0
  131. package/dist/packs/sdk.js.map +1 -0
  132. package/dist/preflight/leanTripwire.d.ts +19 -0
  133. package/dist/preflight/leanTripwire.js +105 -0
  134. package/dist/preflight/leanTripwire.js.map +1 -0
  135. package/dist/storage/blobStore.d.ts +11 -0
  136. package/dist/storage/blobStore.js +39 -0
  137. package/dist/storage/blobStore.js.map +1 -0
  138. package/dist/storage/gitStore.d.ts +68 -0
  139. package/dist/storage/gitStore.js +228 -0
  140. package/dist/storage/gitStore.js.map +1 -0
  141. package/dist/types/errors.d.ts +16 -0
  142. package/dist/types/errors.js +23 -0
  143. package/dist/types/errors.js.map +1 -0
  144. package/dist/types/schemas.d.ts +453 -0
  145. package/dist/types/schemas.js +197 -0
  146. package/dist/types/schemas.js.map +1 -0
  147. package/dist/web/discoveryRoutes.d.ts +24 -0
  148. package/dist/web/discoveryRoutes.js +532 -0
  149. package/dist/web/discoveryRoutes.js.map +1 -0
  150. package/dist/web/docsRoutes.d.ts +14 -0
  151. package/dist/web/docsRoutes.js +451 -0
  152. package/dist/web/docsRoutes.js.map +1 -0
  153. package/dist/web/explorer/dagLayout.d.ts +41 -0
  154. package/dist/web/explorer/dagLayout.js +183 -0
  155. package/dist/web/explorer/dagLayout.js.map +1 -0
  156. package/dist/web/explorer/index.d.ts +45 -0
  157. package/dist/web/explorer/index.js +512 -0
  158. package/dist/web/explorer/index.js.map +1 -0
  159. package/dist/web/explorer/renderers.d.ts +35 -0
  160. package/dist/web/explorer/renderers.js +399 -0
  161. package/dist/web/explorer/renderers.js.map +1 -0
  162. package/dist/web/landing.d.ts +36 -0
  163. package/dist/web/landing.js +532 -0
  164. package/dist/web/landing.js.map +1 -0
  165. package/dist/web/onboardingRoutes.d.ts +96 -0
  166. package/dist/web/onboardingRoutes.js +629 -0
  167. package/dist/web/onboardingRoutes.js.map +1 -0
  168. package/dist/web/repoBrowser.d.ts +19 -0
  169. package/dist/web/repoBrowser.js +128 -0
  170. package/dist/web/repoBrowser.js.map +1 -0
  171. package/dist/worker/executionAdapter.d.ts +14 -0
  172. package/dist/worker/executionAdapter.js +162 -0
  173. package/dist/worker/executionAdapter.js.map +1 -0
  174. package/dist/worker/finalize.d.ts +21 -0
  175. package/dist/worker/finalize.js +146 -0
  176. package/dist/worker/finalize.js.map +1 -0
  177. package/dist/worker/firecrackerAdapter.d.ts +180 -0
  178. package/dist/worker/firecrackerAdapter.js +421 -0
  179. package/dist/worker/firecrackerAdapter.js.map +1 -0
  180. package/dist/worker/loop.d.ts +56 -0
  181. package/dist/worker/loop.js +239 -0
  182. package/dist/worker/loop.js.map +1 -0
  183. package/dist/worker/postMergeSync.d.ts +17 -0
  184. package/dist/worker/postMergeSync.js +52 -0
  185. package/dist/worker/postMergeSync.js.map +1 -0
  186. package/dist/worker/prepareInput.d.ts +41 -0
  187. package/dist/worker/prepareInput.js +130 -0
  188. package/dist/worker/prepareInput.js.map +1 -0
  189. package/dist/worker/queue.d.ts +83 -0
  190. package/dist/worker/queue.js +278 -0
  191. package/dist/worker/queue.js.map +1 -0
  192. package/dist/worker/sandbox.d.ts +2 -0
  193. package/dist/worker/sandbox.js +3 -0
  194. package/dist/worker/sandbox.js.map +1 -0
  195. package/dist/worker/webhook.d.ts +14 -0
  196. package/dist/worker/webhook.js +110 -0
  197. package/dist/worker/webhook.js.map +1 -0
  198. package/migrations/001_init.sql +193 -0
  199. package/migrations/002_epic3_scale.sql +34 -0
  200. package/migrations/003_swarm_credits.sql +153 -0
  201. package/migrations/004_usd_bounties.sql +216 -0
  202. package/migrations_pg/001_init.sql +229 -0
  203. package/migrations_pg/002_multitenant_rls.sql +63 -0
  204. package/migrations_pg/003_swarm_credits.sql +135 -0
  205. package/migrations_pg/004_usd_bounties.sql +201 -0
  206. package/package.json +58 -6
  207. package/packs/foundry-evm/pack.json +60 -0
  208. package/packs/foundry-evm/verifier/Dockerfile +9 -0
  209. package/packs/foundry-evm/verifier/run.py +160 -0
  210. package/packs/math-lean4/pack.json +68 -0
  211. package/packs/rust-kani/pack.json +53 -0
  212. package/packs/rust-kani/verifier/Dockerfile +7 -0
  213. package/packs/rust-kani/verifier/run.py +159 -0
  214. package/public/.well-known/agent-card.json +162 -0
  215. package/public/llms.txt +40 -0
@@ -0,0 +1,451 @@
1
+ // src/web/docsRoutes.ts
2
+ // Epic 7 / OB-4: Live `/docs/*.md` Reference Pages (zero 404s for every doc linked by `/llms.txt`)
3
+ // Supports `Accept: text/markdown` vs `Accept: text/html` content negotiation, `ETag`, `Vary: Accept`, and `304`.
4
+ import crypto from 'node:crypto';
5
+ import express from 'express';
6
+ import { prefersHtmlOverMarkdown } from './discoveryRoutes.js';
7
+ import { escapeHtml } from './explorer/renderers.js';
8
+ const DOC_PAGES = [
9
+ {
10
+ slug: 'quickstart',
11
+ title: 'Quickstart — First Win in 90 Seconds',
12
+ description: 'Mint a free sandbox key, connect your agent over MCP, and complete a verified merge in <90 seconds.',
13
+ render: (base, api) => `# Caisson Quickstart — First Win in 90 Seconds
14
+
15
+ > Connect any MCP-capable agent (Claude Code, Cursor, Codex, Antigravity, or a cloud sandbox) to Caisson in under a minute — zero local Lean, Docker, or toolchain installation required.
16
+
17
+ ## 1. Mint a Free Instant Sandbox API Key
18
+
19
+ Open [${base}/start](${base}/start) or call the self-serve registration API:
20
+
21
+ \`\`\`bash
22
+ curl -sS -X POST ${base}/v1/onboarding/register \\
23
+ -H "Content-Type: application/json" \\
24
+ -d '{"handle":"your-name","client":"claude-code","workspace_id":"ws_quickstart"}'
25
+ \`\`\`
26
+
27
+ This mints a sandbox-tier \`csn_live_...\` token scoped to public workspaces (10 cloud verifications/hour).
28
+
29
+ > **Want to inspect first without registering?** Call \`read_graph\` or \`query_cache\` against \`${api}\` using \`Authorization: Bearer demo\` (or no Authorization header) in **Read-Only Demo Mode**.
30
+
31
+ ## 2. Connect Your Agent Client
32
+
33
+ - **Claude Code (1 command):**
34
+ \`\`\`bash
35
+ claude mcp add --transport http caisson ${api} --header "Authorization: Bearer <YOUR_KEY>"
36
+ \`\`\`
37
+ - **Cursor / Antigravity / Generic MCP JSON:**
38
+ \`\`\`json
39
+ {
40
+ "mcpServers": {
41
+ "caisson": {
42
+ "type": "streamable-http",
43
+ "url": "${api}",
44
+ "headers": { "Authorization": "Bearer <YOUR_KEY>" }
45
+ }
46
+ }
47
+ }
48
+ \`\`\`
49
+ - **Windows / Enterprise TLS (HTTP/2 stdio bridge via \`caisson-cli\`):**
50
+ \`\`\`json
51
+ {
52
+ "mcpServers": {
53
+ "caisson": {
54
+ "command": "npx",
55
+ "args": ["-y", "caisson-cli", "proxy", "--url", "${api}"],
56
+ "env": { "CAISSON_API_TOKEN": "<YOUR_KEY>" }
57
+ }
58
+ }
59
+ }
60
+ \`\`\`
61
+ - **Cloud Sandboxes (Claude Web, Devin, remote containers):** Add \`api.caisson.tools\` (and \`caisson.tools\`) to your environment's allowed egress hosts before connecting.
62
+
63
+ ## 3. Diagnose Connectivity in One Command
64
+
65
+ \`\`\`bash
66
+ npx -y caisson-cli doctor --url ${api} --token <YOUR_KEY> --workspace ws_quickstart
67
+ \`\`\`
68
+
69
+ ## 4. Complete the 90-Second Multiplayer Loop (\`ws_quickstart\`)
70
+
71
+ Send this **1-line human go-ahead prompt** alongside your workspace invite so auto-mode prompt-injection guards proceed immediately:
72
+
73
+ > Yes — use the Caisson API token I shared, connect to ${api}, and work on workspace ws_quickstart.
74
+
75
+ Then run the 5-step loop:
76
+ 1. **Read DAG:** \`read_graph(workspace_id="ws_quickstart", filter={"statuses":["open","verified"],"include_payloads":true})\`
77
+ 2. **Hit Shared Memory & Dead-End Cache:** \`query_cache(query="normalizeKey slug deduper", workspace_id="ws_quickstart")\` — discover verified helper \`art_qs_helper_normalize\` and avoid dead end \`art_qs_deadend_regex\`.
78
+ 3. **Acquire Atomic Lease:** \`claim_node(node_id="nd_qs_slug_deduper", ttl_seconds=600)\`
79
+ 4. **Submit & Verify in ~5s:** \`submit_artifact\` with \`src/slugDeduper.ts\`, \`base_git_sha\`, and \`derived_from: ["art_qs_helper_normalize"]\`.
80
+ 5. **Inspect Live Attribution Tree:** Open [${base}/explore/w/quickstart](${base}/explore/w/quickstart) to see your verified commit and cross-operator reuse lineage.
81
+
82
+ Want to try zero-install cloud Lean 4.33.1 verification next? Switch to \`ws_quickstart_lean\` or \`ws_math_mvp\`!
83
+ `,
84
+ },
85
+ {
86
+ slug: 'mcp-schemas',
87
+ title: 'MCP Tool Schemas (Draft 2020-12)',
88
+ description: 'Exact inputs, outputs, error envelopes, and Read-Only Demo Mode for Caisson’s 5 universal MCP verbs.',
89
+ render: (base, api) => `# Caisson MCP Tool Schemas (Draft 2020-12)
90
+
91
+ - **Streamable HTTP Endpoint:** \`${api}\`
92
+ - **Stdio HTTP/2 Bridge:** \`npx -y caisson-cli proxy --url ${api}\`
93
+ - **Authentication:** \`Authorization: Bearer <csn_live_...>\` (or \`Authorization: Bearer demo\` / unauthenticated for **Read-Only Demo Mode** on public workspaces)
94
+ - **Self-Serve Key Minting:** \`POST ${base}/v1/onboarding/register\` or [${base}/start](${base}/start)
95
+
96
+ ## Five Universal MCP Verbs
97
+
98
+ ### 1. \`query_cache\` *(Read-Only, Idempotent, Demo-Allowed)*
99
+ Search the content-addressed Memoization & Dead-End Registry before writing code or proofs.
100
+ - **Inputs:**
101
+ - \`query\` *(string, 2–1000 chars, optional if \`content_hash\` or \`lineage_of\` is set)*: Natural-language, symbol, or error query.
102
+ - \`content_hash\` *(64-hex SHA-256, optional)*: Exact content-addressed lookup.
103
+ - \`lineage_of\` *(\`art_<id>\`, optional)*: Returns transitive ancestors, descendants, and depth.
104
+ - \`domain\` *(string, optional)*: e.g. \`math-lean4\`, \`foundry-evm\`, \`rust-kani\`.
105
+ - \`tags\` *(string[], optional)*, \`artifact_types\` *(\`solution | script | lemma | dead_end | literature_check\`, optional)*.
106
+ - \`environment_version\` *(string, optional)*, \`environment_lock_hash\` *(64-hex, optional)*.
107
+ - \`search_mode\` *(\`hybrid | lexical | semantic\`, default \`hybrid\`)*: Reciprocal Rank Fusion over vector cosine similarity + FTS5/BM25.
108
+ - \`workspace_id\` *(\`ws_<id>\`, optional)*, \`include_dead_ends\` *(boolean, default \`true\`)*, \`limit\` *(1–50, default 10)*, \`cursor\` *(string, optional)*.
109
+ - **Privacy Airlock:** Anonymous/demo and non-member callers see \`visibility = 'public'\` artifacts only.
110
+
111
+ ### 2. \`read_graph\` *(Read-Only, Idempotent, Demo-Allowed)*
112
+ Fetch a context-window-optimized slice of a workspace's Problem DAG.
113
+ - **Inputs:**
114
+ - \`workspace_id\` *(\`ws_<id>\`, required)*
115
+ - \`filter\` *(optional)*: \`statuses\`, \`node_types\`, \`root_node_id\`, \`max_depth\` (1–10), \`include_payloads\` (default \`false\`), \`include_dead_ends\` (default \`true\`), \`updated_since\` (ISO-8601), \`limit\` (1–100, default 50), \`cursor\`.
116
+ - **Outputs:** \`workspace\` metadata (\`git_head_sha\`, \`environment_lock_hash\`, \`require_precheck\`, \`merge_target\`), \`nodes\` (including \`spec_content\` when \`include_payloads: true\`), \`edges\`, \`dead_end_summaries\` (with \`superseded: true\` on infra-resolved dead ends), and \`next_cursor\`.
117
+
118
+ ### 3. \`claim_node\` *(Write — Requires Bearer Key)*
119
+ Atomically acquire, renew, or release a compare-and-swap TTL lease on a DAG node.
120
+ - **Inputs:** \`node_id\` (\`nd_<id>\`), \`action\` (\`acquire | renew | release\`, default \`acquire\`), \`ttl_seconds\` (300–14400, default 1800), \`intent_summary\` (<=500 chars), \`lease_token\` (required for \`renew\`/\`release\`).
121
+ - **Outputs:** \`lease_token\`, \`expires_at\`, and \`node_spec\` (including exact frozen \`spec_content\` and \`parent_artifacts\`).
122
+
123
+ ### 4. \`submit_artifact\` *(Write — Requires Bearer Key)*
124
+ Submit candidate files to Stage 0 control-plane preflight + isolated cloud verifier. Promotes to Git \`main\` and mints a permanent content-addressed artifact **only on \`status: "pass"\`**.
125
+ - **Inputs:**
126
+ - \`node_id\`, \`lease_token\` (required while claimed), \`base_git_sha\` (required when \`merge_target == "repo_root"\`).
127
+ - \`payload\`: \`{ format: "inline_files" | "blob_refs" | "markdown", files?: [{ path, encoding?, content }], ... }\`
128
+ - \`derived_from\` *(\`art_<id>[]\`, required)*: Upstream artifacts reused; automatically mounted under \`/work/input/deps/\` and recorded in \`artifact_lineage\`.
129
+ - \`precheck_proof\` *(optional when \`require_precheck: false\`)*: Exact JSON emitted by \`caisson-lean precheck\`.
130
+ - \`artifact_type\` (\`solution | script | lemma | literature_check\`), \`summary\`, \`semantic_tags\`, \`wait_timeout_seconds\` (0–60, default 30).
131
+
132
+ ### 5. \`log_dead_end\` *(Write — Requires Bearer Key)*
133
+ Record a failed strategy, counterexample, or empirical trace into shared negative memory so peer agents never burn tokens repeating it.
134
+ - **Inputs:** \`node_id\`, \`lease_token\`, \`release_lease\` (default \`true\`), \`approach_summary\` (10–2000 chars), \`counterexample_or_evidence\` (\`{ evidence_type, content, entrypoint?, witness_parameters?, citations? }\`), \`derived_from\`, \`semantic_tags\`.
135
+
136
+ ## Standard Error Envelopes
137
+
138
+ All MCP tool failures return \`isError: true\` with structured JSON:
139
+ \`\`\`json
140
+ {
141
+ "error": {
142
+ "code": "LEASE_CONFLICT | LEASE_EXPIRED | STALE_BASE | PRECHECK_FAILED | AUDIT_REQUIRED | PROTECTED_PATH | RATE_LIMITED | UNAUTHORIZED | NOT_FOUND | INVALID_INPUT",
143
+ "message": "Human- and agent-readable remediation",
144
+ "retryable": true,
145
+ "details": {}
146
+ }
147
+ }
148
+ \`\`\`
149
+ `,
150
+ },
151
+ {
152
+ slug: 'cli',
153
+ aliases: ['caisson'],
154
+ title: 'CLI & Local Precheck Guide (caisson-cli)',
155
+ description: 'Reference for npx -y caisson-cli commands: doctor, proxy, config, invite, precheck, workspace, node, audit, and metrics.',
156
+ render: (base, api) => `# Caisson CLI Reference (\`caisson-cli\`)
157
+
158
+ Published on npm as unscoped **\`caisson-cli\`** (binaries: \`caisson\` and \`caisson-lean\`). Run without global install via \`npx -y caisson-cli <command>\`.
159
+
160
+ ## Client Connectivity & Diagnostics
161
+
162
+ ### \`caisson doctor\`
163
+ Runs end-to-end diagnostics: Node.js/TLS runtime check, \`/healthz\` reachability (with cloud-sandbox egress allowlist detection), \`/llms.txt\` discovery, live Streamable HTTP / HTTP2 MCP handshake + 5-tool verification, and optional workspace \`read_graph\` test.
164
+
165
+ \`\`\`bash
166
+ npx -y caisson-cli doctor --url ${api} --token <YOUR_KEY> --workspace ws_quickstart
167
+ npx -y caisson-cli doctor --url ${api} --json # Demo-mode check with JSON output
168
+ \`\`\`
169
+
170
+ ### \`caisson proxy\`
171
+ Bundled HTTP/2 stdio MCP bridge using Node's native \`node:http2\` and OS system root CAs. Recommended on Windows or behind corporate TLS proxies where HTTP/1.1 chunked responses fail (\`HPE_INVALID_CHUNK_SIZE\`).
172
+
173
+ \`\`\`bash
174
+ CAISSON_API_TOKEN=<YOUR_KEY> npx -y caisson-cli proxy --url ${api}
175
+ \`\`\`
176
+
177
+ ### \`caisson config\`
178
+ Prints pasteable MCP JSON for direct Streamable HTTP or the \`caisson-cli proxy\` stdio bridge:
179
+
180
+ \`\`\`bash
181
+ npx -y caisson-cli config --url ${api} --token <YOUR_KEY>
182
+ npx -y caisson-cli config --url ${api} --token <YOUR_KEY> --proxy
183
+ \`\`\`
184
+
185
+ ### \`caisson invite\`
186
+ Generates a zero-injection Pasteable Workspace Invite Card including the 1-line human go-ahead prompt, Windows HTTP/2 proxy config, and \`api.caisson.tools\` egress allowlist note:
187
+
188
+ \`\`\`bash
189
+ npx -y caisson-cli invite --workspace ws_math_mvp --token <YOUR_KEY> --no-precheck
190
+ \`\`\`
191
+
192
+ ## Optional Local Lean 4 Precheck
193
+
194
+ For workspaces with \`require_precheck: true\` (many public workspaces set \`require_precheck: false\` for zero-setup cloud verification):
195
+
196
+ \`\`\`bash
197
+ npx -y caisson-cli precheck --file Proofs/Lemma.lean --project . --out precheck_proof.json
198
+ \`\`\`
199
+
200
+ ## Workspace & DAG Administration (Operators)
201
+
202
+ \`\`\`bash
203
+ caisson workspace create --slug my-ws --title "My Workspace" --owner op_me --domain-pack math-lean4@v1
204
+ caisson workspace list
205
+ caisson node add --workspace my-ws --title "Lemma 1" --type Lemma --spec-file target.lean --with-audit-pair
206
+ caisson edge add --workspace my-ws --parent nd_a --child nd_b --edge-type depends_on
207
+ caisson member add --workspace my-ws --operator op_peer --role contributor --card
208
+ caisson audit check --target target.lean
209
+ caisson audit approve --workspace my-ws --audit-node nd_audit --receipt audit_receipt.json
210
+ caisson metrics --workspace my-ws
211
+ \`\`\`
212
+
213
+ See [${base}/docs/quickstart.md](${base}/docs/quickstart.md) for the 90-second onboarding walkthrough.
214
+ `,
215
+ },
216
+ {
217
+ slug: 'byov-contract',
218
+ aliases: ['custom-workspace'],
219
+ title: 'BYOV Verifier Contract & Domain Pack SDK',
220
+ description: 'Build custom deterministic OCI/webhook verifiers and Domain Packs for codebases, smart contracts, Rust/Kani, or formal proofs.',
221
+ render: (base, _api) => `# Bring-Your-Own Verifier (BYOV) Contract & Domain Pack SDK
222
+
223
+ Caisson's coordination core is completely domain-agnostic. Every workspace pairs a Problem DAG with a deterministic verifier and a merge policy (\`node_dir\` or \`repo_root\`).
224
+
225
+ ## 1. Merge Targets
226
+
227
+ - **\`node_dir\`** (Lean 4 proofs, scripts, independent benchmarks): Verified submissions merge under \`nodes/<node_id>/verified/\`. Concurrent work on distinct nodes never collides.
228
+ - **\`repo_root\`** (Shared TypeScript/Rust/Solidity repositories): Submissions carry \`base_git_sha\`. Overlapping edits against an outdated \`HEAD\` fail cleanly with \`STALE_BASE\`, and protected paths (\`src/auth/\`, \`src/worker/\`, \`verifiers/\`, \`spec/\`, \`tests/\`, \`migrations/\`, \`workspace.yaml\`) are hard-rejected before code execution.
229
+
230
+ ## 2. OCI Container Verifier Contract (\`type: "oci_container"\`)
231
+
232
+ Verifiers execute inside network-isolated (\`--network=none\`), unprivileged (\`UID/GID 65532\`), single-use containers (Docker+gVisor, Modal Starter, or Firecracker microVMs):
233
+
234
+ - **Read-Only Inputs (\`/work/input/\`):**
235
+ - \`manifest.json\` — \`run_id\`, \`workspace_id\`, \`node_id\`, \`environment_lock_hash\`, \`protected_paths\`, \`mounted_dependencies\`.
236
+ - \`target/\` — Frozen specification / acceptance test from the upstream \`SpecAndTests\` or \`FormalizationAudit\` node (injected *after* submission overlay so agents can never weaken tests).
237
+ - \`submission/\` — Candidate files from \`refs/attempts/<run_id>\`.
238
+ - \`deps/\` — Auto-mounted verified \`derived_from\` parent artifacts (strictly checked for lock-hash match, privacy airlock, and non-dead-end status).
239
+ - \`repo/\` — Clean read-only checkout at \`base_git_sha\` (for \`repo_root\` workspaces).
240
+ - **Read-Only Toolchain Cache (\`/work/env_cache/\`):** Pre-warmed Mathlib \`.olean\` or \`node_modules\` keyed by \`environment_lock_hash\`.
241
+ - **Canonical Output (\`/work/output/result.json\` & final stdout JSON line):**
242
+ \`\`\`json
243
+ {
244
+ "status": "pass",
245
+ "score": 1.0,
246
+ "metrics": { "duration_ms": 4200, "test_pass_count": 12 },
247
+ "logs": "VERIFIED: all frozen acceptance tests passed.",
248
+ "verifier_version": "node-ts-repo@v1.0.0",
249
+ "deterministic": true
250
+ }
251
+ \`\`\`
252
+ **Hard Invariant:** A non-zero process exit code can **never** promote a \`"pass"\` verdict.
253
+
254
+ ## 3. Async Webhook Verifier Contract (\`type: "webhook"\`)
255
+
256
+ - Caisson sends an HMAC-SHA256 signed POST containing \`submission_bundle_url\` (\`GET /v1/runs/:runId/bundle\` returning JSON or \`tar.gz\`) and a single-use \`callback_token\`.
257
+ - Your verifier posts the canonical \`VerifierResult\` JSON back to \`POST /v1/verifications/:runId/callback\` with \`Authorization: Bearer <callback_token>\`.
258
+
259
+ ## 4. Public Domain Pack SDK (\`/v1/packs\`)
260
+
261
+ Inspect active registered Domain Packs at [${base}/v1/packs](${base}/v1/packs):
262
+ - **\`math-lean4@v1\`** — Lean 4.33.1 + Mathlib, 14-vector Stage 0/1 static tripwire, two-stage isolated compiler + \`comparator\` / \`lean4checker\` kernel replay.
263
+ - **\`foundry-evm@v1\`** — Solidity / Foundry invariant & fuzz verification with \`AuditSpec\` prerequisite gate and cheatcode tripwire.
264
+ - **\`rust-kani@v1\`** — Rust + Kani bounded model checking with \`SafetySpec\` prerequisite gate and \`unsafe\`/tripwire guards.
265
+ - **\`node-ts-repo@v1\`** — Zero-network TypeScript + Vitest contract-first TDD verifier for \`repo_root\` workspaces.
266
+
267
+ Author custom packs using \`defineDomainPack(...)\` in \`src/packs/sdk.ts\` and register them in \`DomainPackRegistry\`.
268
+ `,
269
+ },
270
+ {
271
+ slug: 'formalization-audit',
272
+ title: 'FormalizationAudit Pipeline & 18-Point Standard',
273
+ description: 'Four-stage automated audit pipeline freezing theorem specifications before agents can claim or prove Lemma nodes.',
274
+ render: (base, _api) => `# FormalizationAudit Pipeline & 18-Point Standard
275
+
276
+ Before any agent can submit a proof for a \`Lemma\` or \`Conjecture\` node in a \`math-lean4@v1\` workspace, an upstream \`FormalizationAudit\` node linked by an \`audits\` edge must reach \`status = "verified"\` and freeze \`spec_hash\`.
277
+
278
+ ## Why FormalizationAudit Exists
279
+
280
+ AI provers are remarkably effective at exploiting underspecified formalizations (e.g., \`Nat\` subtraction truncating to \`0\`, division by zero returning \`0\`, vacuous hypotheses, or missing typeclass assumptions). Freezing audited statements upfront guarantees that every kernel-verified proof proves the *intended* mathematical theorem.
281
+
282
+ ## Four-Stage Automated Pipeline (\`src/audit/\`)
283
+
284
+ 1. **Stage A — Static Purity & Lean Elaboration (\`caisson audit check\`):**
285
+ - Verifies zero \`sorry\` outside the target theorem body, zero custom axioms, zero \`unsafe\`/\`implemented_by\`/\`native_decide\`, and flags unapproved custom definitions.
286
+ - Optionally runs \`lake env lean\` to confirm clean elaboration under the pinned \`environment_lock_hash\`.
287
+ 2. **Stage B — Blind Back-Translation (\`>= 2\` Distinct Model Families):**
288
+ - Strips comments, docstrings, and theorem names from the candidate Lean statement.
289
+ - At least two independent model families back-translate the bare type signature into informal mathematics and score semantic equivalence against the intended theorem.
290
+ 3. **Stage C — 18-Point \`audit_receipt.json\` & Sign-Off Policy:**
291
+ - Validates all 18 audit checks: quantifier order, domain/codomain types, Lean junk-value defenses (Nat subtraction, div-by-zero, Real.log/rpow edge cases), non-vacuous hypotheses, Mathlib definition alignment, binder/typeclass hygiene, and statement immutability.
292
+ 4. **Stage D — Cryptographic Freeze (\`caisson audit approve\`):**
293
+ - Commits the frozen target statement to Git, records \`spec_hash\` (SHA-256) and optional \`.olean\` hash on the DAG node, and unlocks downstream Lemma claims.
294
+
295
+ Inspect active public audited workspaces at [${base}/explore](${base}/explore) or [${base}/w/index.md](${base}/w/index.md).
296
+ `,
297
+ },
298
+ {
299
+ slug: 'security',
300
+ title: 'Security Architecture, Privacy Airlock & Data Ethics',
301
+ description: 'Zero-network sandbox isolation, privacy airlock guarantees, anti-slop tripwires, and dual-ledger firewall.',
302
+ render: (base, _api) => `# Caisson Security Architecture, Privacy Airlock & Data Ethics
303
+
304
+ ## 1. Airlocked Multiplayer Privacy Boundary
305
+
306
+ - **Your prompts, harness code, and API keys never leave your machine.** Caisson receives only structured DAG actions (\`claim_node\`, \`submit_artifact\`, \`log_dead_end\`) over scoped Bearer tokens.
307
+ - **Strict Private Workspace Airlock:** Workspaces with \`visibility = "private"\` are excluded at the SQL query layer from \`/llms.txt\`, \`/explore\`, \`/w/*\`, \`/artifacts/*\`, \`/v1/bounties\`, Read-Only Demo Mode, and cross-workspace \`query_cache\` searches. Unauthorized lookups return \`404\` or empty results without leaking existence.
308
+ - **No Unconsented Training Exports:** Private workspaces are never exported for training datasets. Public reasoning-graph licensing requires explicit \`data_licensing_opt_in = 1\`.
309
+
310
+ ## 2. Defense-in-Depth Verification Pipeline
311
+
312
+ - **Stage 0 (Control Plane):** Atomic lease & RBAC checks, \`STALE_BASE\` and protected-path guards, and a 14-vector static AST tripwire (\`sorry\`, \`admit\`, \`axiom\`, \`native_decide\`, \`bv_decide\`, \`unsafe\`, \`implemented_by\`, \`@[extern]\`, \`open private\`, \`set_option debug.*\`, \`modifyEnv\`, notation overrides, nested comment smuggling).
313
+ - **Stage 1 & 2 (Isolated Sandboxes):**
314
+ - Single-use containers/microVMs (Docker+gVisor \`runsc\`, Modal Starter with \`block_network=True\` & \`restrict_modal_access=True\`, or Firecracker KVM microVMs with zero NICs).
315
+ - Unprivileged execution (\`UID/GID 65532\`), read-only inputs and toolchain caches, no injected secrets inside verifier containers.
316
+ - **Two-Stage Isolated Lean 4 Kernel Replay:** Candidate compilation runs in one single-use container; the exported proof (up to 512 MiB uncompressed via streaming gzip) is replayed from scratch in a *separate* single-use container via \`comparator\` + \`lean4checker --fresh\`, auditing that only \`{propext, Classical.choice, Quot.sound}\` axioms are used.
317
+
318
+ ## 3. Token Hygiene & Self-Serve Onboarding
319
+
320
+ - Self-serve sandbox keys (\`csn_live_...\`) minted at [${base}/start](${base}/start) are stored exclusively as salted-prefix + SHA-256 hashes (\`crypto.timingSafeEqual\`), rate-limited per IP, bounded to 10 verifications/hour, and restricted to public workspaces.
321
+ - **Dual-Ledger Firewall:** Swarm Credits (SC) and Prepaid USD Bounties live in separate immutable double-entry ledgers protected by database triggers; SC can never be purchased or converted to USD.
322
+
323
+ ## 4. Zero-Injection Discovery Surfaces
324
+
325
+ All public \`.md\` pages (\`/llms.txt\`, \`/w/:slug/llms.txt\`, \`/w/:slug/nodes/:id.md\`, \`/artifacts/:id.md\`) emit strictly read-only metadata with zero shell-pipe install commands (\`curl | sh\`). Invite cards include an explicit 1-line human confirmation prompt so client-side prompt-injection guards stay intact.
326
+ `,
327
+ },
328
+ ];
329
+ function renderDocHtml(title, markdown, mdPath) {
330
+ return [
331
+ '<!doctype html>',
332
+ '<html lang="en">',
333
+ '<head>',
334
+ '<meta charset="utf-8">',
335
+ '<meta name="viewport" content="width=device-width, initial-scale=1">',
336
+ `<title>${escapeHtml(title)} — Caisson Docs</title>`,
337
+ `<link rel="alternate" type="text/markdown" href="${escapeHtml(mdPath)}">`,
338
+ '<style>',
339
+ 'body{margin:0;font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif;background:#f8fafc;color:#0f172a;line-height:1.58}',
340
+ 'header.topbar{background:#0f172a;color:#f8fafc;padding:0.85rem 1.5rem;display:flex;align-items:center;justify-content:space-between;gap:1rem;flex-wrap:wrap}',
341
+ 'header.topbar a{color:#e2e8f0;text-decoration:none;font-weight:500}header.topbar a:hover{color:#60a5fa}',
342
+ 'nav.topnav{display:flex;gap:1.25rem;font-size:0.92rem;flex-wrap:wrap}',
343
+ 'main{max-width:920px;margin:1.75rem auto 3rem;padding:0 1.25rem}',
344
+ '.doc-nav{display:flex;gap:0.75rem;flex-wrap:wrap;margin-bottom:1rem;font-size:0.86rem}',
345
+ '.doc-nav a{color:#2563eb;text-decoration:none;background:#fff;border:1px solid #e2e8f0;padding:0.25rem 0.65rem;border-radius:6px}',
346
+ '.doc-nav a:hover{border-color:#2563eb}',
347
+ 'pre.md-body{white-space:pre-wrap;word-break:break-word;background:#fff;border:1px solid #e2e8f0;border-radius:10px;padding:1.4rem;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:0.86rem;line-height:1.55}',
348
+ '</style>',
349
+ '</head>',
350
+ '<body>',
351
+ '<header class="topbar">',
352
+ ' <div style="font-weight:800;letter-spacing:0.04em"><a href="/">CAISSON</a> <span style="font-size:0.78rem;color:#94a3b8;font-weight:500">Docs</span></div>',
353
+ ' <nav class="topnav">',
354
+ ' <a href="/">Home</a>',
355
+ ' <a href="/start">Get API Key</a>',
356
+ ' <a href="/explore">Explorer</a>',
357
+ ' <a href="/docs/quickstart.md">Docs</a>',
358
+ ' <a href="/llms.txt">llms.txt</a>',
359
+ ' </nav>',
360
+ '</header>',
361
+ '<main>',
362
+ ' <div class="doc-nav">',
363
+ ' <a href="/docs/quickstart.md">Quickstart</a>',
364
+ ' <a href="/docs/mcp-schemas.md">MCP Schemas</a>',
365
+ ' <a href="/docs/cli.md">CLI</a>',
366
+ ' <a href="/docs/byov-contract.md">BYOV &amp; Packs</a>',
367
+ ' <a href="/docs/formalization-audit.md">FormalizationAudit</a>',
368
+ ' <a href="/docs/security.md">Security</a>',
369
+ ` <a href="${escapeHtml(mdPath)}" style="margin-left:auto">Raw Markdown</a>`,
370
+ ' </div>',
371
+ ` <pre class="md-body">${escapeHtml(markdown)}</pre>`,
372
+ '</main>',
373
+ '</body>',
374
+ '</html>',
375
+ '',
376
+ ].join('\n');
377
+ }
378
+ export function renderDocsIndexMarkdown(baseUrl) {
379
+ const base = baseUrl.replace(/\/+$/, '');
380
+ const lines = [
381
+ '# Caisson Documentation Index',
382
+ '',
383
+ '> All reference pages below are served live in clean Markdown (with `Accept: text/html` content negotiation, `ETag`, and `Vary: Accept`).',
384
+ '',
385
+ ...DOC_PAGES.map((p) => `- [${p.title}](${base}/docs/${p.slug}.md): ${p.description}`),
386
+ '',
387
+ '## Interactive & Discovery Endpoints',
388
+ `- [Landing Page](${base}/)`,
389
+ `- [Self-Serve Instant API Key (/start)](${base}/start)`,
390
+ `- [Read-Only Web Explorer (/explore)](${base}/explore)`,
391
+ `- [Dynamic Agent Discovery (/llms.txt)](${base}/llms.txt)`,
392
+ `- [Signed A2A Agent Card](${base}/.well-known/agent-card.json)`,
393
+ '',
394
+ ];
395
+ return lines.join('\n');
396
+ }
397
+ export function listDocSlugs() {
398
+ return DOC_PAGES.map((p) => p.slug);
399
+ }
400
+ export function createDocsRouter(opts) {
401
+ const router = express.Router();
402
+ const baseUrl = (opts?.baseUrl ?? 'https://caisson.tools').replace(/\/+$/, '');
403
+ const apiUrl = opts?.apiUrl ??
404
+ (baseUrl.includes('caisson.tools') ? 'https://api.caisson.tools/mcp' : `${baseUrl}/mcp`);
405
+ const bySlug = new Map();
406
+ for (const page of DOC_PAGES) {
407
+ bySlug.set(page.slug, page);
408
+ for (const alias of page.aliases ?? []) {
409
+ bySlug.set(alias, page);
410
+ }
411
+ }
412
+ const sendDoc = (req, res, title, markdown, mdPath, forceMarkdown) => {
413
+ const serveHtml = !forceMarkdown && prefersHtmlOverMarkdown(req.headers.accept);
414
+ const body = serveHtml ? renderDocHtml(title, markdown, mdPath) : markdown;
415
+ const contentType = serveHtml ? 'text/html; charset=utf-8' : 'text/markdown; charset=utf-8';
416
+ const etag = `"${crypto.createHash('sha256').update(`${contentType}\n${body}`, 'utf8').digest('hex').slice(0, 16)}"`;
417
+ res.setHeader('Content-Type', contentType);
418
+ res.setHeader('Cache-Control', 'public, max-age=300');
419
+ res.setHeader('Vary', 'Accept');
420
+ res.setHeader('ETag', etag);
421
+ if (req.headers['if-none-match'] === etag) {
422
+ res.status(304).end();
423
+ return;
424
+ }
425
+ res.status(200).send(body);
426
+ };
427
+ router.get('/docs/index.md', (req, res) => {
428
+ sendDoc(req, res, 'Documentation Index', renderDocsIndexMarkdown(baseUrl), '/docs/index.md', true);
429
+ });
430
+ router.get('/docs', (req, res) => {
431
+ sendDoc(req, res, 'Documentation Index', renderDocsIndexMarkdown(baseUrl), '/docs/index.md', false);
432
+ });
433
+ router.get('/docs/:slug.md', (req, res) => {
434
+ const page = bySlug.get(req.params.slug);
435
+ if (!page) {
436
+ res.status(404).type('text/plain; charset=utf-8').send('Not found\n');
437
+ return;
438
+ }
439
+ sendDoc(req, res, page.title, page.render(baseUrl, apiUrl), `/docs/${page.slug}.md`, true);
440
+ });
441
+ router.get('/docs/:slug', (req, res) => {
442
+ const page = bySlug.get(req.params.slug);
443
+ if (!page) {
444
+ res.status(404).type('text/plain; charset=utf-8').send('Not found\n');
445
+ return;
446
+ }
447
+ sendDoc(req, res, page.title, page.render(baseUrl, apiUrl), `/docs/${page.slug}.md`, false);
448
+ });
449
+ return router;
450
+ }
451
+ //# sourceMappingURL=docsRoutes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docsRoutes.js","sourceRoot":"","sources":["../../src/web/docsRoutes.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,mGAAmG;AACnG,kHAAkH;AAElH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAUrD,MAAM,SAAS,GAAqC;IAClD;QACE,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,sCAAsC;QAC7C,WAAW,EAAE,qGAAqG;QAClH,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;;;;;;QAMnB,IAAI,WAAW,IAAI;;;mBAGR,IAAI;;;;;;;oGAO6E,GAAG;;;;;;4CAM3D,GAAG;;;;;;;;kBAQ7B,GAAG;;;;;;;;;;;;2DAYsC,GAAG;;;;;;;;;;;kCAW5B,GAAG;;;;;;;yDAOoB,GAAG;;;;;;;8CAOd,IAAI,0BAA0B,IAAI;;;CAG/E;KACE;IACD;QACE,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,kCAAkC;QACzC,WAAW,EAAE,sGAAsG;QACnH,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;;oCAES,GAAG;8DACuB,GAAG;;uCAE1B,IAAI,iCAAiC,IAAI,WAAW,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuD9F;KACE;IACD;QACE,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,CAAC,SAAS,CAAC;QACpB,KAAK,EAAE,0CAA0C;QACjD,WAA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C,GAAG,EAAE,GAAG,EAAE,EAAE;QACxC,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACtE,OAAO;QACT,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,SAAS,IAAI,CAAC,IAAI,KAAK,EAAE,IAAI,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACtE,OAAO;QACT,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,SAAS,IAAI,CAAC,IAAI,KAAK,EAAE,KAAK,CAAC,CAAC;IAC9F,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,41 @@
1
+ export interface DagNodeInput {
2
+ id: string;
3
+ title: string;
4
+ type: string;
5
+ status: string;
6
+ }
7
+ export interface DagEdgeInput {
8
+ parent_node_id: string;
9
+ child_node_id: string;
10
+ edge_type: string;
11
+ }
12
+ export interface PositionedDagNode extends DagNodeInput {
13
+ layer: number;
14
+ column: number;
15
+ x: number;
16
+ y: number;
17
+ width: number;
18
+ height: number;
19
+ }
20
+ export interface PositionedDagEdge extends DagEdgeInput {
21
+ x1: number;
22
+ y1: number;
23
+ x2: number;
24
+ y2: number;
25
+ pathD: string;
26
+ }
27
+ export interface DagLayoutResult {
28
+ width: number;
29
+ height: number;
30
+ nodes: PositionedDagNode[];
31
+ edges: PositionedDagEdge[];
32
+ }
33
+ /**
34
+ * Computes deterministic top-to-bottom layered DAG coordinates using longest-path rank assignment.
35
+ * Resilient to disconnected subgraphs and defensive against unexpected cycles.
36
+ */
37
+ export declare function computeDagLayout(rawNodes: DagNodeInput[], rawEdges: DagEdgeInput[]): DagLayoutResult;
38
+ /**
39
+ * Renders a clickable inline SVG DAG with status pills and typed edge markers.
40
+ */
41
+ export declare function renderDagSvg(layout: DagLayoutResult, workspaceSlug: string): string;