@joeyshi12/casper 0.6.3 → 0.7.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 (69) hide show
  1. package/README.md +3 -3
  2. package/dist/agents/casper.json +5 -3
  3. package/dist/server.js +27 -9
  4. package/dist/web/assets/{abnfDiagram-N423BO3Z-D4dAP-1-.js → abnfDiagram-N423BO3Z-C2sqRoLM.js} +1 -1
  5. package/dist/web/assets/{arc-CicRYRW0.js → arc-DchRN0tG.js} +1 -1
  6. package/dist/web/assets/{architectureDiagram-T3A2C74G-C8_jIuYI.js → architectureDiagram-T3A2C74G-D1bLDs6z.js} +1 -1
  7. package/dist/web/assets/{blockDiagram-VBNYF7ZC-1z_qaXwF.js → blockDiagram-VBNYF7ZC-5JCzFUDY.js} +1 -1
  8. package/dist/web/assets/{c4Diagram-5PPSVZJV-DA2HxqMu.js → c4Diagram-5PPSVZJV-Bch8_H_x.js} +1 -1
  9. package/dist/web/assets/channel-B33LVukA.js +1 -0
  10. package/dist/web/assets/{chunk-2GRJ4B5K-R9Gd-FO9.js → chunk-2GRJ4B5K-C1crF1XC.js} +1 -1
  11. package/dist/web/assets/{chunk-2Q5K7J3B-DBVFWztp.js → chunk-2Q5K7J3B-eiwaIQGX.js} +1 -1
  12. package/dist/web/assets/{chunk-5RXB4S5H-bLTobZeO.js → chunk-5RXB4S5H-O-26bS_H.js} +1 -1
  13. package/dist/web/assets/{chunk-5VM5RSS4-Bn8X-QeG.js → chunk-5VM5RSS4-BuHKYI2d.js} +1 -1
  14. package/dist/web/assets/{chunk-6Q2QTUOP-CQtChnAA.js → chunk-6Q2QTUOP-BPVbqKRJ.js} +1 -1
  15. package/dist/web/assets/{chunk-GF5L2VYU-DUrrlayx.js → chunk-GF5L2VYU-DUi4_dhF.js} +1 -1
  16. package/dist/web/assets/{chunk-JWPE2WC7-BgI2ovD2.js → chunk-JWPE2WC7-_IVpzBML.js} +1 -1
  17. package/dist/web/assets/{chunk-KBJHAD2P-UMKTTxF1.js → chunk-KBJHAD2P-CFxxM7mS.js} +1 -1
  18. package/dist/web/assets/{chunk-RYQCIY6F-BOcO7eGL.js → chunk-RYQCIY6F-Cv2qLaUt.js} +1 -1
  19. package/dist/web/assets/{chunk-XXDRQBXY-DE8-7iM5.js → chunk-XXDRQBXY-oPWOq1YJ.js} +1 -1
  20. package/dist/web/assets/classDiagram-JCYQIIEL-BnHTSlBi.js +1 -0
  21. package/dist/web/assets/classDiagram-v2-OCEON4UE-BnHTSlBi.js +1 -0
  22. package/dist/web/assets/{cose-bilkent-JH36ORCC-BAygCVU2.js → cose-bilkent-JH36ORCC-D2yG_O2k.js} +1 -1
  23. package/dist/web/assets/{cynefin-VYW2F7L2-CSJk_SPs.js → cynefin-VYW2F7L2-DPNg8KG4.js} +1 -1
  24. package/dist/web/assets/{cynefinDiagram-MW4NZA55-C0yeigu-.js → cynefinDiagram-MW4NZA55-BTtwrraD.js} +1 -1
  25. package/dist/web/assets/{dagre-VZM6K2ZE-C7Wka8DN.js → dagre-VZM6K2ZE-DwJ5dumE.js} +1 -1
  26. package/dist/web/assets/{diagram-7IWD3JNH-D6dg2rEx.js → diagram-7IWD3JNH-Cb6etLM1.js} +1 -1
  27. package/dist/web/assets/{diagram-B4RE2ZJO-D4_nbLMB.js → diagram-B4RE2ZJO-C8aO8uex.js} +1 -1
  28. package/dist/web/assets/{diagram-LBJQPF4R-Nht6dUst.js → diagram-LBJQPF4R-CozxA_MB.js} +1 -1
  29. package/dist/web/assets/{diagram-Q27KOJAE-Dr47m9ou.js → diagram-Q27KOJAE-D3S4KfD1.js} +1 -1
  30. package/dist/web/assets/{diagram-UB23O5K3-wBr0ZbcL.js → diagram-UB23O5K3-B4mKxcgU.js} +1 -1
  31. package/dist/web/assets/{ebnfDiagram-BXEA7PRR-BLB0X9R-.js → ebnfDiagram-BXEA7PRR-BsyRV3BF.js} +1 -1
  32. package/dist/web/assets/{erDiagram-JOGREHBK-Dju9_T31.js → erDiagram-JOGREHBK-B10JqcCz.js} +1 -1
  33. package/dist/web/assets/{flowDiagram-UKHOOZJN-DGKxclCZ.js → flowDiagram-UKHOOZJN-sl7J1_Yo.js} +1 -1
  34. package/dist/web/assets/{ganttDiagram-PKOTCBZU-CO3GCXs9.js → ganttDiagram-PKOTCBZU-C7a8_zqr.js} +1 -1
  35. package/dist/web/assets/{gitGraphDiagram-DS77QQ5N-HJ2a9e8_.js → gitGraphDiagram-DS77QQ5N-DqVZhBog.js} +1 -1
  36. package/dist/web/assets/{index-56vlRQsM.js → index-Dl7AJt7X.js} +33 -33
  37. package/dist/web/assets/{index-CZ8H0616.css → index-mPTUxc3C.css} +1 -1
  38. package/dist/web/assets/{index-CguDTw5b.js → index-t6MNhQ9G.js} +1 -1
  39. package/dist/web/assets/{infoDiagram-6WML65LV-BaVcr3f7.js → infoDiagram-6WML65LV-BUTRYZqP.js} +1 -1
  40. package/dist/web/assets/{ishikawaDiagram-WSZJBQD7-CBW9kPX2.js → ishikawaDiagram-WSZJBQD7-B7-g0yt7.js} +1 -1
  41. package/dist/web/assets/{journeyDiagram-NVQOT4AX-ByxvAnge.js → journeyDiagram-NVQOT4AX-BGxY7864.js} +1 -1
  42. package/dist/web/assets/{kanban-definition-27J2QSJJ-Cax1fcgb.js → kanban-definition-27J2QSJJ-DCXqhbya.js} +1 -1
  43. package/dist/web/assets/{linear-CBgLWOFx.js → linear-CKH6mTEV.js} +1 -1
  44. package/dist/web/assets/{mermaid.core-B3afE_Bn.js → mermaid.core-ClSlWF4Q.js} +5 -5
  45. package/dist/web/assets/{mindmap-definition-FAOFIHXS-sS1s_igC.js → mindmap-definition-FAOFIHXS-CE2JzS5F.js} +1 -1
  46. package/dist/web/assets/{pegDiagram-VL7TDLO6-CCQpyXjO.js → pegDiagram-VL7TDLO6-CfnxbG0R.js} +1 -1
  47. package/dist/web/assets/{pieDiagram-7S7Q4E2Y-CZ_Lof4Z.js → pieDiagram-7S7Q4E2Y-RpoSDzRl.js} +1 -1
  48. package/dist/web/assets/{quadrantDiagram-CIZ2JOQS-hJaOjkKi.js → quadrantDiagram-CIZ2JOQS-BlFoJcDI.js} +1 -1
  49. package/dist/web/assets/{railroadDiagram-AXF67PYL-D9ueOsqF.js → railroadDiagram-AXF67PYL-DfO_98X4.js} +1 -1
  50. package/dist/web/assets/{requirementDiagram-LRYGKXZP-CmMkOQTX.js → requirementDiagram-LRYGKXZP-BquX7hB4.js} +1 -1
  51. package/dist/web/assets/{sankeyDiagram-W5VNT64P-CXMCYDJB.js → sankeyDiagram-W5VNT64P-NnA7F-tN.js} +1 -1
  52. package/dist/web/assets/{sequenceDiagram-SI44F4Z6-iT0A9JkH.js → sequenceDiagram-SI44F4Z6-KX0K1eTH.js} +1 -1
  53. package/dist/web/assets/{sizeCapture-X5ZJPWSS-mUYstuDe.js → sizeCapture-X5ZJPWSS-BZx7H-Oi.js} +1 -1
  54. package/dist/web/assets/{stateDiagram-OKZ733FA-B7jqZn_1.js → stateDiagram-OKZ733FA-CwRpd64f.js} +1 -1
  55. package/dist/web/assets/stateDiagram-v2-UEYNNEHI-OMaAe2Je.js +1 -0
  56. package/dist/web/assets/{swimlanes-SLNWSIFB-B3iAV6cM.js → swimlanes-SLNWSIFB-BmWGa0R6.js} +2 -2
  57. package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-BWUUE_KP.js +8 -0
  58. package/dist/web/assets/{timeline-definition-Z64GVDOM-KdcKK-sf.js → timeline-definition-Z64GVDOM-B38Wk-yk.js} +1 -1
  59. package/dist/web/assets/{vennDiagram-T6HMQDX7-rJqmKTgU.js → vennDiagram-T6HMQDX7-BUyWiY-4.js} +1 -1
  60. package/dist/web/assets/{wardleyDiagram-T6FBY63Y-CI33_pUs.js → wardleyDiagram-T6FBY63Y-CUWpBPW9.js} +1 -1
  61. package/dist/web/assets/{xychartDiagram-ELKLHX3M-C1TnCm9i.js → xychartDiagram-ELKLHX3M-BnCqC5dA.js} +1 -1
  62. package/dist/web/index.html +2 -2
  63. package/dist/web/sw.js +1 -1
  64. package/package.json +1 -1
  65. package/dist/web/assets/channel-DdA8Dcii.js +0 -1
  66. package/dist/web/assets/classDiagram-JCYQIIEL-Dxx1nEKY.js +0 -1
  67. package/dist/web/assets/classDiagram-v2-OCEON4UE-Dxx1nEKY.js +0 -1
  68. package/dist/web/assets/stateDiagram-v2-UEYNNEHI-5syMa302.js +0 -1
  69. package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-CwnN5SDz.js +0 -8
package/README.md CHANGED
@@ -20,8 +20,8 @@ exactly what it missed.
20
20
  - **Per-session model and agent**, from the live model list and kiro's agents.
21
21
  - **Rich rendering** of Markdown, Mermaid, syntax-highlighted code, and MCP tool
22
22
  calls with their status, input and output.
23
- - **File browser** for the session's workspace, with previews for text, images
24
- and PDFs.
23
+ - **File browser** for the session's workspace, previewing text, images and PDFs.
24
+ HTML renders as a live page, sandboxed, and either can go fullscreen.
25
25
  - **Observability** for credits spent, context-window usage and turn duration.
26
26
  - **PWA** that installs to a home screen and reconnects when the network returns.
27
27
 
@@ -104,7 +104,7 @@ inside it, and `CASPER_WEB_DIST`, which is install layout rather than a preferen
104
104
  | `DEFAULT_AGENT` | `defaultAgent` | `kiro_default` | Agent for new sessions |
105
105
  | `CASPER_FILE_ROOT` | `fileRoot` | `/` | Confines the file browser. Defaults to everything the server can read; narrow it to keep authenticated users out of system files |
106
106
  | `MAX_LIVE_SESSIONS` | `maxLiveSessions` | `6` | Concurrent live kiro processes |
107
- | `CASPER_DATA_DIR` | _(env only)_ | `~/.casper` | Where `casper.db` lives |
107
+ | `CASPER_DATA_DIR` | _(env only)_ | `~/.casper` | Where `casper.db` and uploaded files live |
108
108
  | `CASPER_WEB_DIST` | _(env only)_ | beside the bundle | Built web app to serve |
109
109
 
110
110
  Beyond your LAN, put a TLS-terminating reverse proxy in front of
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "casper",
3
- "description": "Casper a coding agent for developing from the chat web interface.",
4
- "prompt": "You are Casper, an AI coding agent. You help developers build, debug, and understand software directly from a chat-based web interface. Draw on your broad knowledge of programming languages, frameworks, and engineering practices to solve problems pragmatically and get real work done.\n\nCommunication\n- Be concise, direct, and friendly. Prioritize actionable guidance over narrating your work. Match detail to the task: brief for simple things, more context when it helps the user decide.\n- Ground every claim in the codebase, tool results, or reliable sources; never fabricate. State assumptions and label inferences.\n- Prioritize correctness over agreement. If something is wrong or risky, say so plainly and explain why.\n- Format responses in markdown: use backticks for file paths, commands, and code identifiers, and reference files by their project-relative path.\n\nTool use\n- Gather enough context before acting; do not guess file paths, arguments, or APIs. Read the relevant code before changing it.\n- Make independent tool calls in parallel and run dependent ones sequentially. Prefer the most direct tool for the job.\n- Do not re-read a file just to confirm a successful edit.\n\nTask execution\n- Keep working until the user's request is fully resolved before yielding. Resolve the task autonomously with the tools available rather than returning early.\n- Ask the user only when the information you need is genuinely unavailable from the project, or when an action is risky or irreversible.\n\nMaking code changes\n- Fix problems at the root cause; keep changes minimal, focused, and consistent with the existing style. Prefer dependencies and patterns already used in the project.\n- Update related tests, documentation, and call sites that are part of the change; mention unrelated issues rather than fixing them.\n- Do not commit or create branches unless asked. Never overwrite or revert work you did not make.\n\nValidation and safety\n- Verify with the project's own build, test, and lint commands. Never claim validation passed unless you ran it and saw it pass; otherwise report the failing command and the error.\n- Treat destructive or hard-to-reverse actions (data loss, production changes, force pushes) as requiring explicit confirmation. Never expose or hardcode secrets.\n\nFinal response\n- Summarize what changed, reference the affected files by path, and state what you verified. Offer a sensible next step as a question rather than doing it unprompted.",
3
+ "description": "Casper \u2014 a coding agent for developing from the chat web interface.",
4
+ "prompt": "You are Casper, an AI coding agent. You help developers build, debug, and understand software directly from a chat-based web interface. Draw on your broad knowledge of programming languages, frameworks, and engineering practices to solve problems pragmatically and get real work done.\n\nCommunication\n- Be concise, direct, and friendly. Prioritize actionable guidance over narrating your work. Match detail to the task: brief for simple things, more context when it helps the user decide.\n- Ground every claim in the codebase, tool results, or reliable sources; never fabricate. State assumptions and label inferences.\n- Prioritize correctness over agreement. If something is wrong or risky, say so plainly and explain why.\n- Format responses in markdown: use backticks for file paths, commands, and code identifiers, and reference files by their project-relative path.\n\nTool use\n- Gather enough context before acting; do not guess file paths, arguments, or APIs. Read the relevant code before changing it.\n- Make independent tool calls in parallel and run dependent ones sequentially. Prefer the most direct tool for the job.\n- Do not re-read a file just to confirm a successful edit.\n\nTask execution\n- Keep working until the user's request is fully resolved before yielding. Resolve the task autonomously with the tools available rather than returning early.\n- Ask the user only when the information you need is genuinely unavailable from the project, or when an action is risky or irreversible.\n\nMaking code changes\n- Fix problems at the root cause; keep changes minimal, focused, and consistent with the existing style. Prefer dependencies and patterns already used in the project.\n- Update related tests, documentation, and call sites that are part of the change; mention unrelated issues rather than fixing them.\n- Do not commit or create branches unless asked. Never overwrite or revert work you did not make.\n\nValidation and safety\n- Verify with the project's own build, test, and lint commands. Never claim validation passed unless you ran it and saw it pass; otherwise report the failing command and the error.\n- Treat destructive or hard-to-reverse actions (data loss, production changes, force pushes) as requiring explicit confirmation. Never expose or hardcode secrets.\n\nFiles and previews\n- Attachments arrive as an \"Attached files:\" line listing absolute paths under ~/.casper/sessions/<id>/uploads. Read them from there; they are outside the project, so never assume a path relative to the working directory.\n- Do not write into ~/.casper. It is Casper's own state directory. Put files you create in the working directory, where the user can see and version them.\n- HTML files render in Casper's preview panel, interactively and fullscreen, with scripts and forms working. So a self-contained .html file is a good deliverable for anything visual: a slideshow, a chart, a diagram, a small tool. Keep CSS and JS inline in the one file, since the preview is sandboxed and has no same-origin access.\n\nFinal response\n- Summarize what changed, reference the affected files by path, and state what you verified. Offer a sensible next step as a question rather than doing it unprompted.",
5
5
  "mcpServers": {},
6
- "tools": ["*"],
6
+ "tools": [
7
+ "*"
8
+ ],
7
9
  "toolAliases": {},
8
10
  "allowedTools": [],
9
11
  "resources": [],
package/dist/server.js CHANGED
@@ -2157,7 +2157,7 @@ import fs10 from "node:fs/promises";
2157
2157
  import { createReadStream } from "node:fs";
2158
2158
  import path11 from "node:path";
2159
2159
  function confinedPath(input) {
2160
- return confineToRoot(config.fileRoot, input);
2160
+ return confineToRoot(config.fileRoot, input) ?? confineToRoot(config.casperDataDir, input);
2161
2161
  }
2162
2162
  function registerFsRoutes(app) {
2163
2163
  app.get(
@@ -2720,6 +2720,7 @@ function registerWorkspaceRoutes(app, manager) {
2720
2720
  const mime = mimeForExt(ext);
2721
2721
  const isImage = mime.startsWith("image/");
2722
2722
  const isPdf = mime === "application/pdf";
2723
+ const isHtml = mime === "text/html" && req.query.raw === "1";
2723
2724
  const kind = classifyKind(realTarget);
2724
2725
  if (isImage || isPdf) {
2725
2726
  if (stat.size > MAX_IMAGE_PREVIEW_BYTES) {
@@ -2732,6 +2733,16 @@ function registerWorkspaceRoutes(app, manager) {
2732
2733
  return tooLargeForPreview(stat.size, MAX_TEXT_PREVIEW_BYTES);
2733
2734
  }
2734
2735
  }
2736
+ if (isHtml) {
2737
+ if (stat.size > MAX_TEXT_PREVIEW_BYTES) {
2738
+ reply.code(413);
2739
+ return tooLargeForPreview(stat.size, MAX_TEXT_PREVIEW_BYTES);
2740
+ }
2741
+ reply.header("Content-Security-Policy", "sandbox allow-scripts allow-forms");
2742
+ reply.header("Content-Type", "text/html; charset=utf-8");
2743
+ reply.header("Cache-Control", "no-store");
2744
+ return reply.send(createReadStream2(realTarget));
2745
+ }
2735
2746
  if (isImage || isPdf) {
2736
2747
  const etag = `W/"${stat.size}-${stat.mtimeMs}"`;
2737
2748
  reply.header("Cache-Control", "private, max-age=3600");
@@ -2805,6 +2816,9 @@ import path14 from "node:path";
2805
2816
  import crypto4 from "node:crypto";
2806
2817
  import { execFile as execFile3 } from "node:child_process";
2807
2818
  import { pipeline } from "node:stream/promises";
2819
+ function uploadDirFor(sessionId) {
2820
+ return path14.join(config.casperDataDir, "sessions", sessionId, "uploads");
2821
+ }
2808
2822
  function sanitizeName(raw) {
2809
2823
  const base = path14.basename(raw).replace(/[^\w.\- ]/g, "_").trim();
2810
2824
  if (!base || base === "." || base === "..") return `upload-${Date.now()}`;
@@ -2867,14 +2881,17 @@ function registerUploadRoutes(app, manager) {
2867
2881
  app.post(
2868
2882
  "/api/sessions/:id/uploads",
2869
2883
  async (req, reply) => {
2870
- let cwd;
2871
2884
  try {
2872
- cwd = await manager.getSessionCwd(req.params.id);
2885
+ await manager.getSessionCwd(req.params.id);
2873
2886
  } catch {
2874
2887
  reply.code(404);
2875
2888
  return { error: "Session not found" };
2876
2889
  }
2877
- const uploadDir = path14.join(cwd, UPLOAD_SUBDIR);
2890
+ if (!isValidSessionId(req.params.id)) {
2891
+ reply.code(400);
2892
+ return { error: "Invalid session id" };
2893
+ }
2894
+ const uploadDir = uploadDirFor(req.params.id);
2878
2895
  await fs12.mkdir(uploadDir, { recursive: true });
2879
2896
  const results = [];
2880
2897
  const parts = req.files();
@@ -2898,10 +2915,12 @@ function registerUploadRoutes(app, manager) {
2898
2915
  const stat = await fs12.stat(dest);
2899
2916
  const ext = path14.extname(dest);
2900
2917
  const kind = classifyKind(dest);
2901
- const relative = path14.relative(cwd, dest);
2902
2918
  const uploaded = {
2903
2919
  name: path14.basename(dest),
2904
- path: relative,
2920
+ // Absolute, because the file sits outside the session's workspace: a
2921
+ // relative path would resolve against the wrong root for both the agent
2922
+ // and the image endpoint.
2923
+ path: dest,
2905
2924
  size: stat.size,
2906
2925
  mimeType: mimeForExt(ext),
2907
2926
  kind
@@ -2925,14 +2944,13 @@ function registerUploadRoutes(app, manager) {
2925
2944
  }
2926
2945
  );
2927
2946
  }
2928
- var UPLOAD_SUBDIR, STRINGS_SCAN_BYTES;
2947
+ var STRINGS_SCAN_BYTES;
2929
2948
  var init_uploads = __esm({
2930
2949
  "server/src/routes/uploads.ts"() {
2931
2950
  "use strict";
2932
2951
  init_config();
2933
2952
  init_filekind();
2934
2953
  init_paths2();
2935
- UPLOAD_SUBDIR = path14.join(".casper", "uploads");
2936
2954
  STRINGS_SCAN_BYTES = 256 * 1024;
2937
2955
  }
2938
2956
  });
@@ -6746,7 +6764,7 @@ var program = new Command();
6746
6764
  // server/src/cli/program.ts
6747
6765
  init_paths();
6748
6766
  init_settings();
6749
- var VERSION = true ? "0.6.3" : "dev";
6767
+ var VERSION = true ? "0.7.0" : "dev";
6750
6768
  async function bootstrap() {
6751
6769
  const file = configFilePath();
6752
6770
  const settings = readSettings(file);
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-CQtChnAA.js";import{p as f}from"./chunk-JWPE2WC7-BgI2ovD2.js";import{_ as n,l as o}from"./mermaid.core-B3afE_Bn.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-CSJk_SPs.js";import"./index-56vlRQsM.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-BPVbqKRJ.js";import{p as f}from"./chunk-JWPE2WC7-_IVpzBML.js";import{_ as n,l as o}from"./mermaid.core-ClSlWF4Q.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-DPNg8KG4.js";import"./index-Dl7AJt7X.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
@@ -1 +1 @@
1
- import{G as ln,H as un,I as N,J as I,K as J,L as an,M as y,N as tn,O as j,P as _,Q as rn,R as o,S as on,T as sn,V as fn}from"./mermaid.core-B3afE_Bn.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,q,O,v,R,K,u){var D=q-l,i=O-h,n=K-v,d=u-R,a=d*D-n*i;if(!(a*a<y))return a=(n*(h-R)-d*(l-v))/a,[l+a*D,h+a*i]}function W(l,h,q,O,v,R,K){var u=l-q,D=h-O,i=(K?R:-R)/j(u*u+D*D),n=i*D,d=-i*u,a=l+n,s=h+d,f=q+n,c=O+d,L=(a+f)/2,t=(s+c)/2,m=f-a,g=c-s,A=m*m+g*g,T=v-R,P=a*c-f*s,E=(g<0?-1:1)*j(on(0,T*T*A-P*P)),G=(P*g-m*E)/A,H=(-P*m-g*E)/A,w=(P*g+m*E)/A,p=(-P*m+g*E)/A,x=G-L,e=H-t,r=w-L,M=p-t;return x*x+e*e>r*r+M*M&&(G=w,H=p),{cx:G,cy:H,x01:-n,y01:-d,x11:G*(v/T-1),y11:H*(v/T-1)}}function hn(){var l=cn,h=yn,q=J(0),O=null,v=gn,R=dn,K=mn,u=null,D=ln(i);function i(){var n,d,a=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=R.apply(this,arguments)-an,L=rn(c-f),t=c>f;if(u||(u=n=D()),s<a&&(d=s,s=a,a=d),!(s>y))u.moveTo(0,0);else if(L>tn-y)u.moveTo(s*N(f),s*I(f)),u.arc(0,0,s,f,c,!t),a>y&&(u.moveTo(a*N(c),a*I(c)),u.arc(0,0,a,c,f,t));else{var m=f,g=c,A=f,T=c,P=L,E=L,G=K.apply(this,arguments)/2,H=G>y&&(O?+O.apply(this,arguments):j(a*a+s*s)),w=_(rn(s-a)/2,+q.apply(this,arguments)),p=w,x=w,e,r;if(H>y){var M=sn(H/a*I(G)),z=sn(H/s*I(G));(P-=M*2)>y?(M*=t?1:-1,A+=M,T-=M):(P=0,A=T=(f+c)/2),(E-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(E=0,m=g=(f+c)/2)}var Q=s*N(m),V=s*I(m),B=a*N(T),C=a*I(T);if(w>y){var F=s*N(g),U=s*I(g),X=a*N(A),Y=a*I(A),S;if(L<un)if(S=pn(Q,V,X,Y,F,U,B,C)){var Z=Q-S[0],$=V-S[1],k=F-S[0],b=U-S[1],nn=1/I(fn((Z*k+$*b)/(j(Z*Z+$*$)*j(k*k+b*b)))/2),en=j(S[0]*S[0]+S[1]*S[1]);p=_(w,(a-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}E>y?x>y?(e=W(X,Y,Q,V,s,x,t),r=W(F,U,B,C,s,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(Q,V),u.arc(0,0,s,m,g,!t)):u.moveTo(Q,V),!(a>y)||!(P>y)?u.lineTo(B,C):p>y?(e=W(B,C,F,U,a,-p,t),r=W(Q,V,X,Y,a,-p,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,A,t)}if(u.closePath(),n)return u=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-un/2;return[N(d)*n,I(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:J(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:J(+n),i):h},i.cornerRadius=function(n){return arguments.length?(q=typeof n=="function"?n:J(+n),i):q},i.padRadius=function(n){return arguments.length?(O=n==null?null:typeof n=="function"?n:J(+n),i):O},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:J(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:J(+n),i):R},i.padAngle=function(n){return arguments.length?(K=typeof n=="function"?n:J(+n),i):K},i.context=function(n){return arguments.length?(u=n??null,i):u},i}export{hn as d};
1
+ import{G as ln,H as un,I as N,J as I,K as J,L as an,M as y,N as tn,O as j,P as _,Q as rn,R as o,S as on,T as sn,V as fn}from"./mermaid.core-ClSlWF4Q.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,q,O,v,R,K,u){var D=q-l,i=O-h,n=K-v,d=u-R,a=d*D-n*i;if(!(a*a<y))return a=(n*(h-R)-d*(l-v))/a,[l+a*D,h+a*i]}function W(l,h,q,O,v,R,K){var u=l-q,D=h-O,i=(K?R:-R)/j(u*u+D*D),n=i*D,d=-i*u,a=l+n,s=h+d,f=q+n,c=O+d,L=(a+f)/2,t=(s+c)/2,m=f-a,g=c-s,A=m*m+g*g,T=v-R,P=a*c-f*s,E=(g<0?-1:1)*j(on(0,T*T*A-P*P)),G=(P*g-m*E)/A,H=(-P*m-g*E)/A,w=(P*g+m*E)/A,p=(-P*m+g*E)/A,x=G-L,e=H-t,r=w-L,M=p-t;return x*x+e*e>r*r+M*M&&(G=w,H=p),{cx:G,cy:H,x01:-n,y01:-d,x11:G*(v/T-1),y11:H*(v/T-1)}}function hn(){var l=cn,h=yn,q=J(0),O=null,v=gn,R=dn,K=mn,u=null,D=ln(i);function i(){var n,d,a=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=R.apply(this,arguments)-an,L=rn(c-f),t=c>f;if(u||(u=n=D()),s<a&&(d=s,s=a,a=d),!(s>y))u.moveTo(0,0);else if(L>tn-y)u.moveTo(s*N(f),s*I(f)),u.arc(0,0,s,f,c,!t),a>y&&(u.moveTo(a*N(c),a*I(c)),u.arc(0,0,a,c,f,t));else{var m=f,g=c,A=f,T=c,P=L,E=L,G=K.apply(this,arguments)/2,H=G>y&&(O?+O.apply(this,arguments):j(a*a+s*s)),w=_(rn(s-a)/2,+q.apply(this,arguments)),p=w,x=w,e,r;if(H>y){var M=sn(H/a*I(G)),z=sn(H/s*I(G));(P-=M*2)>y?(M*=t?1:-1,A+=M,T-=M):(P=0,A=T=(f+c)/2),(E-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(E=0,m=g=(f+c)/2)}var Q=s*N(m),V=s*I(m),B=a*N(T),C=a*I(T);if(w>y){var F=s*N(g),U=s*I(g),X=a*N(A),Y=a*I(A),S;if(L<un)if(S=pn(Q,V,X,Y,F,U,B,C)){var Z=Q-S[0],$=V-S[1],k=F-S[0],b=U-S[1],nn=1/I(fn((Z*k+$*b)/(j(Z*Z+$*$)*j(k*k+b*b)))/2),en=j(S[0]*S[0]+S[1]*S[1]);p=_(w,(a-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}E>y?x>y?(e=W(X,Y,Q,V,s,x,t),r=W(F,U,B,C,s,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(Q,V),u.arc(0,0,s,m,g,!t)):u.moveTo(Q,V),!(a>y)||!(P>y)?u.lineTo(B,C):p>y?(e=W(B,C,F,U,a,-p,t),r=W(Q,V,X,Y,a,-p,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,A,t)}if(u.closePath(),n)return u=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-un/2;return[N(d)*n,I(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:J(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:J(+n),i):h},i.cornerRadius=function(n){return arguments.length?(q=typeof n=="function"?n:J(+n),i):q},i.padRadius=function(n){return arguments.length?(O=n==null?null:typeof n=="function"?n:J(+n),i):O},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:J(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:J(+n),i):R},i.padAngle=function(n){return arguments.length?(K=typeof n=="function"?n:J(+n),i):K},i.context=function(n){return arguments.length?(u=n??null,i):u},i}export{hn as d};