handmux 0.30.0 → 0.31.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 (108) hide show
  1. package/dist/connectors/claude/index.js +33 -562
  2. package/dist/connectors/codebuddy/index.js +49 -0
  3. package/dist/connectors/hookBridge.js +560 -0
  4. package/dist/hooks/handmux-codebuddy-notify.sh +116 -0
  5. package/dist/hooks/handmux-notify.sh +2 -0
  6. package/dist/hooks/handmux-write.cjs +72 -5
  7. package/dist/package.json +7 -7
  8. package/dist/public/assets/{abnfDiagram-O67JEVCF-CmVVGJqt.js → abnfDiagram-O67JEVCF-BsRDIQEB.js} +1 -1
  9. package/dist/public/assets/{arc-aYtCI03A.js → arc-DLtLfMnX.js} +1 -1
  10. package/dist/public/assets/{architectureDiagram-NJMV4G6O-CyZZDTaL.js → architectureDiagram-NJMV4G6O-DoIXhWqZ.js} +1 -1
  11. package/dist/public/assets/{blockDiagram-BEXU5L5S-D_ODtFS0.js → blockDiagram-BEXU5L5S-W0HiOcVA.js} +1 -1
  12. package/dist/public/assets/{c4Diagram-YGBWAQC7-C8qZFFmC.js → c4Diagram-YGBWAQC7-72uAUMvX.js} +1 -1
  13. package/dist/public/assets/channel-CzALSnb0.js +1 -0
  14. package/dist/public/assets/{chunk-2Q5K7J3B-Bo85fSxI.js → chunk-2Q5K7J3B-B9wSRFQ0.js} +1 -1
  15. package/dist/public/assets/{chunk-3FUC2YCW-BnET3fKr.js → chunk-3FUC2YCW-ryphp4s0.js} +2 -2
  16. package/dist/public/assets/{chunk-5VM5RSS4-DDw_KNv1.js → chunk-5VM5RSS4-Cm4KeKby.js} +1 -1
  17. package/dist/public/assets/{chunk-GTNCS2PH-B_K2164R.js → chunk-GTNCS2PH-Du4_i7r3.js} +1 -1
  18. package/dist/public/assets/{chunk-GWA4HPMP-1GA2Su8A.js → chunk-GWA4HPMP-CL1biVIA.js} +1 -1
  19. package/dist/public/assets/{chunk-JWPE2WC7-Cfc-8kSE.js → chunk-JWPE2WC7-B8eAVfuB.js} +1 -1
  20. package/dist/public/assets/{chunk-NETBCI7D-C7zyDFCq.js → chunk-NETBCI7D-D273GzYg.js} +1 -1
  21. package/dist/public/assets/{chunk-WEXAMYUT-BI2Zijn_.js → chunk-WEXAMYUT-DipTfRbc.js} +1 -1
  22. package/dist/public/assets/{chunk-XXDRQBXY-Bl50fDL9.js → chunk-XXDRQBXY-D4SqXrQ8.js} +1 -1
  23. package/dist/public/assets/{classDiagram-v2-NBCMYWYE-BMWMChZ4.js → classDiagram-v2-NBCMYWYE-PrpnIXcA.js} +1 -1
  24. package/dist/public/assets/{cose-bilkent-JH36ORCC-B_HUrBN4.js → cose-bilkent-JH36ORCC-BfcYMYTa.js} +1 -1
  25. package/dist/public/assets/{cynefin-OW5HDTMX-2jTRe-JA.js → cynefin-OW5HDTMX-Du659bmz.js} +1 -1
  26. package/dist/public/assets/{cynefinDiagram-VND7K2PF-ClDtZNOK.js → cynefinDiagram-VND7K2PF-DR_2Copy.js} +1 -1
  27. package/dist/public/assets/{dagre-6A5THRUB-CJS3bbcm.js → dagre-6A5THRUB-COsChaV5.js} +1 -1
  28. package/dist/public/assets/{diagram-22UHCM2B-BpRgaKhU.js → diagram-22UHCM2B-Cx2T1HvL.js} +1 -1
  29. package/dist/public/assets/{diagram-3UASUU5V-BNwvXb9K.js → diagram-3UASUU5V-Cp04LOka.js} +1 -1
  30. package/dist/public/assets/{diagram-ATOU4E4O-DyphKhOl.js → diagram-ATOU4E4O-DlqFSshY.js} +1 -1
  31. package/dist/public/assets/{diagram-CDSNMT55-BRazAxS2.js → diagram-CDSNMT55-goq40ctA.js} +1 -1
  32. package/dist/public/assets/{diagram-MLGK6HIB-NN_P6wZp.js → diagram-MLGK6HIB-Bdzjsy4r.js} +1 -1
  33. package/dist/public/assets/{diagram-MPIPVDR6-DHBe5DA4.js → diagram-MPIPVDR6-DtU7cM6P.js} +1 -1
  34. package/dist/public/assets/{ebnfDiagram-ZINNZB2B-BCTHXp7J.js → ebnfDiagram-ZINNZB2B-XyVCfmED.js} +1 -1
  35. package/dist/public/assets/{elk-276RUBZZ-yXNwrgXQ.js → elk-276RUBZZ-aHVIw-2x.js} +1 -1
  36. package/dist/public/assets/{erDiagram-OPXOYQCR-YsAJcCqg.js → erDiagram-OPXOYQCR-Bq_PhTIL.js} +1 -1
  37. package/dist/public/assets/{flowDiagram-KWPJA3E3-CyX8qF-3.js → flowDiagram-KWPJA3E3-WuqnDSiF.js} +1 -1
  38. package/dist/public/assets/{ganttDiagram-FUAMR5RP-BMFOvdDK.js → ganttDiagram-FUAMR5RP-DZ4lXzkC.js} +1 -1
  39. package/dist/public/assets/{gitGraphDiagram-X574FWY7-D1sZiiWD.js → gitGraphDiagram-X574FWY7-t6l07b9g.js} +1 -1
  40. package/dist/public/assets/index-DiYff8oR.css +32 -0
  41. package/dist/public/assets/index-YZNK723o.js +203 -0
  42. package/dist/public/assets/{infoDiagram-VRGFBTTK-CiayIr0f.js → infoDiagram-VRGFBTTK-iUGqoOFp.js} +1 -1
  43. package/dist/public/assets/{ishikawaDiagram-OU5B5YK6-Bf4mzvKk.js → ishikawaDiagram-OU5B5YK6-B0TmoUOK.js} +1 -1
  44. package/dist/public/assets/{journeyDiagram-ZHPQQLJL-mvwzOMZ7.js → journeyDiagram-ZHPQQLJL-CQE61MCu.js} +1 -1
  45. package/dist/public/assets/{kanban-definition-PNTS6WVX-CMFYAtvx.js → kanban-definition-PNTS6WVX-D2MWCUyS.js} +1 -1
  46. package/dist/public/assets/{linear-BcK1QK3e.js → linear-WKGxVNP1.js} +1 -1
  47. package/dist/public/assets/{mermaid.core-BmCR7le1.js → mermaid.core-DPEwUsaj.js} +4 -4
  48. package/dist/public/assets/{mindmap-definition-NLK3R4M7-hvUFWkg7.js → mindmap-definition-NLK3R4M7-DsYEsBsI.js} +1 -1
  49. package/dist/public/assets/{pegDiagram-GJSIUBJH-B8FGnth6.js → pegDiagram-GJSIUBJH-BS52Fbxt.js} +1 -1
  50. package/dist/public/assets/{pieDiagram-5QR66LMP-BdhppGvz.js → pieDiagram-5QR66LMP-D4o8g7nW.js} +1 -1
  51. package/dist/public/assets/{quadrantDiagram-O4NWA36T-i6XjZJ8W.js → quadrantDiagram-O4NWA36T-DnYUxWll.js} +1 -1
  52. package/dist/public/assets/{railroadDiagram-XR7U4H2S-C7XoA5kk.js → railroadDiagram-XR7U4H2S-BKy_7ULV.js} +1 -1
  53. package/dist/public/assets/{requirementDiagram-PLB6GJNP-tq6onssc.js → requirementDiagram-PLB6GJNP-Ce5F4u8K.js} +1 -1
  54. package/dist/public/assets/{sankeyDiagram-IPEJSGJF-DRW13BH8.js → sankeyDiagram-IPEJSGJF-CCJDrut_.js} +1 -1
  55. package/dist/public/assets/{sequenceDiagram-PO4LG4MO-BJqhIpnw.js → sequenceDiagram-PO4LG4MO-D5E8ISM1.js} +1 -1
  56. package/dist/public/assets/{sizeCapture-INFHLROL-BCpyNpYK.js → sizeCapture-INFHLROL-BW3KmxDN.js} +1 -1
  57. package/dist/public/assets/{stateDiagram-v2-GCMORJYK-Da3aSdeG.js → stateDiagram-v2-GCMORJYK-Bw2ZzQOE.js} +1 -1
  58. package/dist/public/assets/{swimlanes-2SLR337P-oT62nN2e.js → swimlanes-2SLR337P-CLJ-6Ex_.js} +1 -1
  59. package/dist/public/assets/swimlanesDiagram-TC7HE7FX-BD8rQfV7.js +8 -0
  60. package/dist/public/assets/{timeline-definition-EJHVYXUP-CQ9Q15bt.js → timeline-definition-EJHVYXUP-C_lFJ-4W.js} +1 -1
  61. package/dist/public/assets/{usecaseDiagram-POWQR4AR-De1gJb8v.js → usecaseDiagram-POWQR4AR-DWXawL2A.js} +1 -1
  62. package/dist/public/assets/{vennDiagram-UO4OBE2U-BusPyTiq.js → vennDiagram-UO4OBE2U-D4O5oZal.js} +1 -1
  63. package/dist/public/assets/{wardleyDiagram-VNRHLVJA-D-vaN_gJ.js → wardleyDiagram-VNRHLVJA-B6HElk__.js} +1 -1
  64. package/dist/public/assets/{xychartDiagram-PMCCYNJV-BcOmOj-j.js → xychartDiagram-PMCCYNJV-C5OAXnJy.js} +1 -1
  65. package/dist/public/index.html +2 -2
  66. package/dist/src/agent-runtime/adapter.js +54 -10
  67. package/dist/src/agent-runtime/builtinRuntime.js +67 -6
  68. package/dist/src/agent-runtime/conversation.js +49 -9
  69. package/dist/src/agent-runtime/interaction.js +26 -12
  70. package/dist/src/agent-runtime/interactionLiveHub.js +4 -0
  71. package/dist/src/agent-runtime/runtime.js +83 -27
  72. package/dist/src/agent-runtime/tmuxRuntime.js +36 -6
  73. package/dist/src/agents/claude.js +2 -19
  74. package/dist/src/agents/claudeInteraction.js +2 -132
  75. package/dist/src/agents/claudePaneInput.js +22 -22
  76. package/dist/src/agents/codebuddy.js +100 -0
  77. package/dist/src/agents/codebuddyConversation.js +414 -0
  78. package/dist/src/agents/codebuddyInteraction.js +4 -0
  79. package/dist/src/agents/codebuddyNativeTail.js +206 -0
  80. package/dist/src/agents/codebuddyPaneInput.js +76 -0
  81. package/dist/src/agents/codebuddyTranscriptParse.js +178 -0
  82. package/dist/src/agents/hookEvents.js +143 -0
  83. package/dist/src/agents/hookInteraction.js +178 -0
  84. package/dist/src/agents/index.js +2 -1
  85. package/dist/src/claudeEvents.js +4 -5
  86. package/dist/src/cli/agentIntegration.js +31 -2
  87. package/dist/src/cli/codebuddyHooks.js +286 -0
  88. package/dist/src/cli/hookScaffold.js +25 -12
  89. package/dist/src/cli/i18n/en.js +1 -1
  90. package/dist/src/cli/i18n/zh.js +1 -1
  91. package/dist/src/cli/state.js +4 -0
  92. package/dist/src/cli/supervisor.js +2 -1
  93. package/dist/src/codebuddyEvents.js +151 -0
  94. package/dist/src/docs.js +17 -6
  95. package/dist/src/logDetail.js +27 -0
  96. package/dist/src/paneInput.js +107 -10
  97. package/dist/src/pendingPrompt.js +21 -5
  98. package/dist/src/routes/system.js +12 -2
  99. package/dist/src/server.js +69 -8
  100. package/dist/src/workspace/checkpointer.js +48 -4
  101. package/dist/src/workspace/lock.js +54 -10
  102. package/dist/src/workspace/runtime.js +23 -8
  103. package/dist/src/workspaceProtocol.js +1 -0
  104. package/package.json +3 -3
  105. package/dist/public/assets/channel-kkiOw5AC.js +0 -1
  106. package/dist/public/assets/index-DqCUBYR8.css +0 -32
  107. package/dist/public/assets/index-OW7snGiD.js +0 -362
  108. package/dist/public/assets/swimlanesDiagram-TC7HE7FX-YHG5AQi4.js +0 -8
@@ -7,6 +7,8 @@
7
7
  # 只做本地落盘:更新 JSON latest state,并在启用时追加有界 Bridge event spool。不联网、
8
8
  # 不依赖服务进程是否在跑 → 永不阻塞 Claude(始终 exit 0)。服务端/Connector 稍后消费这些文件。
9
9
  # 真正的读-改-写交给同目录的 handmux-write.js(node:真 JSON 解析 + 文件锁,多 pane 并发 hook 不丢更新)。
10
+ HANDMUX_AGENT=claude
11
+ export HANDMUX_AGENT
10
12
  CFG="$(dirname "$0")/handmux-notify.env"
11
13
  [ -f "$CFG" ] && . "$CFG"
12
14
  PANE="${CLAUDE_PANE:-$TMUX_PANE}"
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // handmux hook writer. Updates one JSON latest-state file keyed by tmux pane and, when configured,
3
+ // reports the Agent named by HANDMUX_AGENT (its notify script sets it) — defaulting to claude so an
4
+ // already-deployed script keeps writing exactly what it wrote before.
3
5
  // appends the same effective lifecycle edge to a bounded durable Connector spool. Invoked by notify.sh:
4
6
  // node handmux-write.cjs <file> <pane> <src> <ts> <host> <event-dir>
5
7
  // [claude-pid] [claude-lstart] [claude-tty]
@@ -15,6 +17,10 @@
15
17
  // or corrupt the file. Best-effort throughout and silent — the hook is fire-and-forget and must never
16
18
  // fail Claude (the shell wrapper swallows errors and always exits 0).
17
19
  const fs = require('node:fs');
20
+
21
+ // Which Agent this state and spool belong to. This writer is shared by every Agent's notify script, so the
22
+ // marking comes from the caller instead of a literal here.
23
+ const AGENT = String(process.env.HANDMUX_AGENT || '').trim() || 'claude';
18
24
  const path = require('node:path');
19
25
 
20
26
  const crypto = require('node:crypto');
@@ -51,6 +57,51 @@ function sameSourceProcess(previous) {
51
57
  && prior.tty === sourceProcess.tty;
52
58
  }
53
59
 
60
+ // Same generation, but only on positive evidence. sameSourceProcess above answers "may I REVOKE what this row
61
+ // says?", and there an absent fingerprint is deliberately permissive — the Runtime independently verifies the
62
+ // process before anything is published. Carrying a pane's session forward is the opposite kind of claim: it
63
+ // ASSERTS "this pane is running that session", so an unproven match must not license it. Without that
64
+ // distinction a fingerprint that could not be determined (measured: a pane TTY carrying two rows) would let a
65
+ // brand-new process inherit a dead session's binding, and the phone's 对话 entry would open onto a stranger's
66
+ // transcript.
67
+ function sameKnownProcess(previous) {
68
+ const prior = previous?.process;
69
+ if (!sourceProcess || !prior) return false;
70
+ return prior.pid === sourceProcess.pid
71
+ && prior.startedAt === sourceProcess.startedAt
72
+ && prior.tty === sourceProcess.tty;
73
+ }
74
+
75
+ // A pane's SESSION is a property of the pane, not of whichever event happens to arrive next. Some
76
+ // Notifications carry no session_id at all — measured live: CodeBuddy fires `auth_success` for every running
77
+ // instance when its token refreshes, and two panes lost their binding in the same second — and this row is
78
+ // exactly where everything downstream reads that binding from: the Connector derives the run's session from
79
+ // it, and the phone's 对话 entry depends on it. Replacing the row wholesale with a session-less event erased
80
+ // the binding until that pane's next prompt, which for an idle pane can be a long time.
81
+ //
82
+ // Carry the identity forward when the event has none — but only while the same process owns the pane, so a
83
+ // replacement process can never inherit the session of a dead one. `cwd` is deliberately not carried: it can
84
+ // legitimately change between events, and the transcript is already identified by session (or by the pid
85
+ // registry, which knows the pane's own cwd).
86
+ // The only Notifications that say anything about the pane's turn — everything else is noise that must not
87
+ // overwrite the row (see the branch in update()). Both kinds are the same two the readers classify.
88
+ const PANE_STATE_NOTIFICATIONS = new Set(['permission_prompt', 'idle_prompt']);
89
+
90
+ const PANE_IDENTITY_FIELDS = ['session_id', 'transcript_path'];
91
+ function withPaneIdentity(payload, previous) {
92
+ if (!payload || typeof payload !== 'object' || Array.isArray(payload)) return payload;
93
+ const prior = previous && previous.payload;
94
+ if (!prior || typeof prior !== 'object' || Array.isArray(prior) || !sameKnownProcess(previous)) return payload;
95
+ const missing = PANE_IDENTITY_FIELDS.filter((field) => (
96
+ payload[field] === undefined && prior[field] !== undefined
97
+ ));
98
+ if (missing.length === 0) return payload;
99
+ return Object.fromEntries([
100
+ ...Object.entries(payload),
101
+ ...missing.map((field) => [field, prior[field]]),
102
+ ]);
103
+ }
104
+
54
105
  let payload = {};
55
106
  try { payload = JSON.parse(fs.readFileSync(0, 'utf8') || '{}'); } catch { /* unreadable stdin → {} */ }
56
107
 
@@ -129,8 +180,8 @@ function writeGapMarker(value) {
129
180
  fs.writeFileSync(temporary, JSON.stringify({
130
181
  version: 1,
131
182
  type: 'gap',
132
- agent: 'claude',
133
- eventId: `claude-gap-${Date.now()}-${process.pid}`,
183
+ agent: AGENT,
184
+ eventId: `${AGENT}-gap-${Date.now()}-${process.pid}`,
134
185
  paneId: value.paneId,
135
186
  sessionId: typeof value.sessionId === 'string' ? value.sessionId : undefined,
136
187
  ...(value.process ? { process: value.process } : {}),
@@ -172,8 +223,8 @@ function writeBridgeEvent(sequence, rawTs, payload) {
172
223
  const event = {
173
224
  version: 1,
174
225
  type: 'event',
175
- agent: 'claude',
176
- eventId: `claude-hook-${sequence}`,
226
+ agent: AGENT,
227
+ eventId: `${AGENT}-hook-${sequence}`,
177
228
  sequence,
178
229
  paneId: pane,
179
230
  src,
@@ -235,6 +286,22 @@ function update() {
235
286
  // PermissionRequest is the authoritative opening edge. Claude later emits a generic Notification for
236
287
  // the same blocked gate; retaining the earlier detailed row also prevents a second canonical unread.
237
288
  applied = false;
289
+ } else if (src === 'notify' && !PANE_STATE_NOTIFICATIONS.has(payload?.notification_type)) {
290
+ // A Notification this pipeline does not act on — measured live: `auth_success`, which CodeBuddy fires
291
+ // for every running instance when its token refreshes (CodeBuddy's vocabulary also has
292
+ // `elicitation_dialog`, which no reader maps either). It reports nothing about the pane's turn, yet
293
+ // recording it as the pane's `src` REPLACED what the pane was actually doing — and this row is the only
294
+ // place the Connector, the roster and the conversation Core read that from. The pane's state then
295
+ // resolved to nothing at all: measured on this machine, two panes sat at an unresolvable state for
296
+ // hours, and a message queued for one of them waited for `idle` for seventeen hours without ever being
297
+ // sent (the Core only dispatches a queue when the session reads idle). It also cleared a live card —
298
+ // including 需要你, when a token refresh happened while a gate was open — and erased the pane's session
299
+ // binding on the way, which is the other half of what this function guards.
300
+ //
301
+ // So ignore the noise rather than let it ratchet the pane's record to "nothing known". The pane keeps
302
+ // the last event that actually said something, exactly as the two branches above keep a richer or a
303
+ // resting row.
304
+ applied = false;
238
305
  } else if (src === 'end') {
239
306
  // SessionEnd drops the pane on a clean exit. But /clear (and /resume) END the old session AND START a
240
307
  // new one — SessionEnd(old) + SessionStart(new) fire as two async hooks, in either order. A late end for
@@ -249,7 +316,7 @@ function update() {
249
316
  // one durable source order. Existing readers ignore the additive field.
250
317
  const sequence = safeSequence(sequenceFloor);
251
318
  obj[pane] = {
252
- ts: Number(ts) || 0, src, host, payload, agent: 'claude',
319
+ ts: Number(ts) || 0, src, host, payload: withPaneIdentity(payload, previous), agent: AGENT,
253
320
  ...(sourceProcess ? { process: sourceProcess } : {}),
254
321
  ...(sequence === null ? {} : { sequence }),
255
322
  };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "handmux",
3
- "version": "0.30.0",
3
+ "version": "0.31.0",
4
4
  "description": "A mobile vibe-coding cockpit — built on tmux: drive your live session, Claude Code / Codex — anything a terminal can run — from your phone.",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",
@@ -75,6 +75,12 @@
75
75
  "vitest": "^2.0.0"
76
76
  },
77
77
  "whatsNew": [
78
+ {
79
+ "version": "0.31.0",
80
+ "date": "2026-09-22",
81
+ "zh": "CodeBuddy 对话接入 · Agent 状态更可靠",
82
+ "en": "CodeBuddy chat support · more reliable Agent state"
83
+ },
78
84
  {
79
85
  "version": "0.30.0",
80
86
  "date": "2026-09-19",
@@ -116,12 +122,6 @@
116
122
  "date": "2026-09-08",
117
123
  "zh": "腾讯语音 · 终端光标修复 · Codex 对话恢复",
118
124
  "en": "Tencent voice · terminal cursor fixes · Codex chat recovery"
119
- },
120
- {
121
- "version": "0.27.0",
122
- "date": "2026-09-05",
123
- "zh": "腾讯语音输入 · 终端输入更准确",
124
- "en": "Tencent voice input · more accurate terminal typing"
125
125
  }
126
126
  ]
127
127
  }
@@ -1 +1 @@
1
- import{g as p,r as u,d as n}from"./chunk-GTNCS2PH-B_K2164R.js";import{p as f}from"./chunk-JWPE2WC7-Cfc-8kSE.js";import{c as a,aH as o}from"./mermaid.core-BmCR7le1.js";import{M as c,c as d}from"./cynefin-OW5HDTMX-2jTRe-JA.js";import"./index-OW7snGiD.js";var v=d().RailroadAbnf.parser.LangiumParser,i=a(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=a(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=a(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=a(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=a(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=a(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=a(e=>{f(e,n),e.title&&n.setTitle(e.title),e.rules.map(r=>n.addRule(P(r)))},"populateDb"),R={parse:a(e=>{n.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:n}},B={parser:R,db:n,renderer:u,styles:p};export{B as diagram};
1
+ import{g as p,r as u,d as n}from"./chunk-GTNCS2PH-Du4_i7r3.js";import{p as f}from"./chunk-JWPE2WC7-B8eAVfuB.js";import{c as a,aH as o}from"./mermaid.core-DPEwUsaj.js";import{M as c,c as d}from"./cynefin-OW5HDTMX-Du659bmz.js";import"./index-YZNK723o.js";var v=d().RailroadAbnf.parser.LangiumParser,i=a(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=a(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=a(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=a(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=a(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=a(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=a(e=>{f(e,n),e.title&&n.setTitle(e.title),e.rules.map(r=>n.addRule(P(r)))},"populateDb"),R={parse:a(e=>{n.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:n}},B={parser:R,db:n,renderer:u,styles:p};export{B as diagram};
@@ -1 +1 @@
1
- import{bx as ln,aW as an,I as z,bi as w,G as N,af as un,W as y,bo as on,bj as F,aP as _,d as rn,n as t,aN as tn,k as sn,e as fn}from"./mermaid.core-BmCR7le1.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,j,I,v,A,O,a){var q=j-l,i=I-h,n=O-v,d=a-A,u=d*q-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*q,h+u*i]}function Q(l,h,j,I,v,A,O){var a=l-j,q=h-I,i=(O?A:-A)/F(a*a+q*q),n=i*q,d=-i*a,u=l+n,s=h+d,f=j+n,c=I+d,S=(u+f)/2,o=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,D=(g<0?-1:1)*F(tn(0,T*T*R-P*P)),E=(P*g-m*D)/R,G=(-P*m-g*D)/R,b=(P*g+m*D)/R,p=(-P*m+g*D)/R,x=E-S,e=G-o,r=b-S,k=p-o;return x*x+e*e>r*r+k*k&&(E=b,G=p),{cx:E,cy:G,x01:-n,y01:-d,x11:E*(v/T-1),y11:G*(v/T-1)}}function hn(){var l=cn,h=yn,j=N(0),I=null,v=gn,A=dn,O=mn,a=null,q=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,S=rn(c-f),o=c>f;if(a||(a=n=q()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(S>on-y)a.moveTo(s*z(f),s*w(f)),a.arc(0,0,s,f,c,!o),u>y&&(a.moveTo(u*z(c),u*w(c)),a.arc(0,0,u,c,f,o));else{var m=f,g=c,R=f,T=c,P=S,D=S,E=O.apply(this,arguments)/2,G=E>y&&(I?+I.apply(this,arguments):F(u*u+s*s)),b=_(rn(s-u)/2,+j.apply(this,arguments)),p=b,x=b,e,r;if(G>y){var k=sn(G/u*w(E)),H=sn(G/s*w(E));(P-=k*2)>y?(k*=o?1:-1,R+=k,T-=k):(P=0,R=T=(f+c)/2),(D-=H*2)>y?(H*=o?1:-1,m+=H,g-=H):(D=0,m=g=(f+c)/2)}var B=s*z(m),C=s*w(m),J=u*z(T),K=u*w(T);if(b>y){var L=s*z(g),M=s*w(g),U=u*z(R),V=u*w(R),W;if(S<an)if(W=pn(B,C,U,V,L,M,J,K)){var X=B-W[0],Y=C-W[1],Z=L-W[0],$=M-W[1],nn=1/w(fn((X*Z+Y*$)/(F(X*X+Y*Y)*F(Z*Z+$*$)))/2),en=F(W[0]*W[0]+W[1]*W[1]);p=_(b,(u-en)/(nn-1)),x=_(b,(s-en)/(nn+1))}else p=x=0}D>y?x>y?(e=Q(U,V,B,C,s,x,o),r=Q(L,M,J,K,s,x,o),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<b?a.arc(e.cx,e.cy,x,t(e.y01,e.x01),t(r.y01,r.x01),!o):(a.arc(e.cx,e.cy,x,t(e.y01,e.x01),t(e.y11,e.x11),!o),a.arc(0,0,s,t(e.cy+e.y11,e.cx+e.x11),t(r.cy+r.y11,r.cx+r.x11),!o),a.arc(r.cx,r.cy,x,t(r.y11,r.x11),t(r.y01,r.x01),!o))):(a.moveTo(B,C),a.arc(0,0,s,m,g,!o)):a.moveTo(B,C),!(u>y)||!(P>y)?a.lineTo(J,K):p>y?(e=Q(J,K,L,M,u,-p,o),r=Q(B,C,U,V,u,-p,o),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<b?a.arc(e.cx,e.cy,p,t(e.y01,e.x01),t(r.y01,r.x01),!o):(a.arc(e.cx,e.cy,p,t(e.y01,e.x01),t(e.y11,e.x11),!o),a.arc(0,0,u,t(e.cy+e.y11,e.cx+e.x11),t(r.cy+r.y11,r.cx+r.x11),o),a.arc(r.cx,r.cy,p,t(r.y11,r.x11),t(r.y01,r.x01),!o))):a.arc(0,0,u,T,R,o)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[z(d)*n,w(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:N(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:N(+n),i):h},i.cornerRadius=function(n){return arguments.length?(j=typeof n=="function"?n:N(+n),i):j},i.padRadius=function(n){return arguments.length?(I=n==null?null:typeof n=="function"?n:N(+n),i):I},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:N(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:N(+n),i):A},i.padAngle=function(n){return arguments.length?(O=typeof n=="function"?n:N(+n),i):O},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
1
+ import{bx as ln,aW as an,I as z,bi as w,G as N,af as un,W as y,bo as on,bj as F,aP as _,d as rn,n as t,aN as tn,k as sn,e as fn}from"./mermaid.core-DPEwUsaj.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,j,I,v,A,O,a){var q=j-l,i=I-h,n=O-v,d=a-A,u=d*q-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*q,h+u*i]}function Q(l,h,j,I,v,A,O){var a=l-j,q=h-I,i=(O?A:-A)/F(a*a+q*q),n=i*q,d=-i*a,u=l+n,s=h+d,f=j+n,c=I+d,S=(u+f)/2,o=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,D=(g<0?-1:1)*F(tn(0,T*T*R-P*P)),E=(P*g-m*D)/R,G=(-P*m-g*D)/R,b=(P*g+m*D)/R,p=(-P*m+g*D)/R,x=E-S,e=G-o,r=b-S,k=p-o;return x*x+e*e>r*r+k*k&&(E=b,G=p),{cx:E,cy:G,x01:-n,y01:-d,x11:E*(v/T-1),y11:G*(v/T-1)}}function hn(){var l=cn,h=yn,j=N(0),I=null,v=gn,A=dn,O=mn,a=null,q=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,S=rn(c-f),o=c>f;if(a||(a=n=q()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(S>on-y)a.moveTo(s*z(f),s*w(f)),a.arc(0,0,s,f,c,!o),u>y&&(a.moveTo(u*z(c),u*w(c)),a.arc(0,0,u,c,f,o));else{var m=f,g=c,R=f,T=c,P=S,D=S,E=O.apply(this,arguments)/2,G=E>y&&(I?+I.apply(this,arguments):F(u*u+s*s)),b=_(rn(s-u)/2,+j.apply(this,arguments)),p=b,x=b,e,r;if(G>y){var k=sn(G/u*w(E)),H=sn(G/s*w(E));(P-=k*2)>y?(k*=o?1:-1,R+=k,T-=k):(P=0,R=T=(f+c)/2),(D-=H*2)>y?(H*=o?1:-1,m+=H,g-=H):(D=0,m=g=(f+c)/2)}var B=s*z(m),C=s*w(m),J=u*z(T),K=u*w(T);if(b>y){var L=s*z(g),M=s*w(g),U=u*z(R),V=u*w(R),W;if(S<an)if(W=pn(B,C,U,V,L,M,J,K)){var X=B-W[0],Y=C-W[1],Z=L-W[0],$=M-W[1],nn=1/w(fn((X*Z+Y*$)/(F(X*X+Y*Y)*F(Z*Z+$*$)))/2),en=F(W[0]*W[0]+W[1]*W[1]);p=_(b,(u-en)/(nn-1)),x=_(b,(s-en)/(nn+1))}else p=x=0}D>y?x>y?(e=Q(U,V,B,C,s,x,o),r=Q(L,M,J,K,s,x,o),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<b?a.arc(e.cx,e.cy,x,t(e.y01,e.x01),t(r.y01,r.x01),!o):(a.arc(e.cx,e.cy,x,t(e.y01,e.x01),t(e.y11,e.x11),!o),a.arc(0,0,s,t(e.cy+e.y11,e.cx+e.x11),t(r.cy+r.y11,r.cx+r.x11),!o),a.arc(r.cx,r.cy,x,t(r.y11,r.x11),t(r.y01,r.x01),!o))):(a.moveTo(B,C),a.arc(0,0,s,m,g,!o)):a.moveTo(B,C),!(u>y)||!(P>y)?a.lineTo(J,K):p>y?(e=Q(J,K,L,M,u,-p,o),r=Q(B,C,U,V,u,-p,o),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<b?a.arc(e.cx,e.cy,p,t(e.y01,e.x01),t(r.y01,r.x01),!o):(a.arc(e.cx,e.cy,p,t(e.y01,e.x01),t(e.y11,e.x11),!o),a.arc(0,0,u,t(e.cy+e.y11,e.cx+e.x11),t(r.cy+r.y11,r.cx+r.x11),o),a.arc(r.cx,r.cy,p,t(r.y11,r.x11),t(r.y01,r.x01),!o))):a.arc(0,0,u,T,R,o)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[z(d)*n,w(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:N(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:N(+n),i):h},i.cornerRadius=function(n){return arguments.length?(j=typeof n=="function"?n:N(+n),i):j},i.padRadius=function(n){return arguments.length?(I=n==null?null:typeof n=="function"?n:N(+n),i):I},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:N(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:N(+n),i):A},i.padAngle=function(n){return arguments.length?(O=typeof n=="function"?n:N(+n),i):O},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};