@computesdk/loops 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +34 -0
- package/README.md +45 -2
- package/bin/pi-rpc-startup.mjs +8 -0
- package/client.ts +27 -0
- package/dist/assets/{abnfDiagram-VCTEODGH-DCBDcsG9.js → abnfDiagram-VCTEODGH-D2bigoxc.js} +1 -1
- package/dist/assets/{arc-XHL_gOXE.js → arc-BZl7sgf7.js} +1 -1
- package/dist/assets/{architectureDiagram-5GKGNRK7-D2AZUwQa.js → architectureDiagram-5GKGNRK7-BEVh04as.js} +1 -1
- package/dist/assets/{blockDiagram-I7D4REHJ-B4gIbwtQ.js → blockDiagram-I7D4REHJ-BXHXs9X2.js} +1 -1
- package/dist/assets/{c4Diagram-7LVT6UL2-BVQsOVAp.js → c4Diagram-7LVT6UL2-BDJNDCcc.js} +1 -1
- package/dist/assets/channel-C47Lbhx6.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-JT4Vadns.js → chunk-2Q5K7J3B-BdUkLQYN.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-CDeArlJ5.js → chunk-5VM5RSS4-3N4vBacE.js} +1 -1
- package/dist/assets/{chunk-F27PBJKO-CCc4sEwP.js → chunk-F27PBJKO-ByjH2OJK.js} +1 -1
- package/dist/assets/{chunk-IMKFNOWR-CXd4ZLrB.js → chunk-IMKFNOWR-D8jAt4ka.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-DtGxXURA.js → chunk-JWPE2WC7-B7DWQYA4.js} +1 -1
- package/dist/assets/{chunk-POPQ4Y6H-TYAe-WXZ.js → chunk-POPQ4Y6H-D5nv_lqi.js} +1 -1
- package/dist/assets/{chunk-SVP7TREG-DmyN3wGH.js → chunk-SVP7TREG-CBg3GrIs.js} +1 -1
- package/dist/assets/{chunk-TICWLB2K-CoQRzD2R.js → chunk-TICWLB2K-BL_wE86-.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-Cdv4d7MB.js → chunk-XXDRQBXY-ipZwP-Tw.js} +1 -1
- package/dist/assets/classDiagram-ZZMXUADV-BkejU3Ym.js +1 -0
- package/dist/assets/classDiagram-v2-VYDZK3BY-BkejU3Ym.js +1 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-B_tFtaAU.js → cose-bilkent-JH36ORCC-tIdDJe7h.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-Cwqvcd49.js → cynefin-OW5HDTMX-C5BZ6yCh.js} +1 -1
- package/dist/assets/{cynefinDiagram-5FMLGOSQ-DABTV6Vb.js → cynefinDiagram-5FMLGOSQ-KZkQ_Fs5.js} +1 -1
- package/dist/assets/{dagre-GXQ25YYZ-TYrmYsuz.js → dagre-GXQ25YYZ-8g1xXz_z.js} +1 -1
- package/dist/assets/{diagram-S7CK7UJ4-DHSEu2H3.js → diagram-S7CK7UJ4-Civ7O2b1.js} +1 -1
- package/dist/assets/{diagram-UQ7AKVKN-C019YqL0.js → diagram-UQ7AKVKN-CsiklyIt.js} +1 -1
- package/dist/assets/{diagram-VSXAHHWV-D4MEzffI.js → diagram-VSXAHHWV-eXAMoOzJ.js} +1 -1
- package/dist/assets/{diagram-VX7I27RA-kFJ0JvUv.js → diagram-VX7I27RA-Bb913WNj.js} +1 -1
- package/dist/assets/{diagram-Z3DM3KII-BcO31l9N.js → diagram-Z3DM3KII-CiGD7-UB.js} +1 -1
- package/dist/assets/{ebnfDiagram-PWID7BFC-DZj4QQh4.js → ebnfDiagram-PWID7BFC-DFPxxkTf.js} +1 -1
- package/dist/assets/{erDiagram-RLTQ6QDP-CmJHu3yl.js → erDiagram-RLTQ6QDP-DkPhQteJ.js} +1 -1
- package/dist/assets/{flowDiagram-HODETNUW-Cs2i9PHj.js → flowDiagram-HODETNUW-B8DTvq1w.js} +1 -1
- package/dist/assets/{ganttDiagram-EL5Y4UJY-DeROwj00.js → ganttDiagram-EL5Y4UJY-DPfnHIkg.js} +1 -1
- package/dist/assets/{gitGraphDiagram-WWUBYQGX--qyeTDhG.js → gitGraphDiagram-WWUBYQGX-BzYuJVan.js} +1 -1
- package/dist/assets/{highlighted-body-JLMTFACH-ChXoKzQk.js → highlighted-body-JLMTFACH-D3y_nfFu.js} +1 -1
- package/dist/assets/index-DvyWv1zp.js +902 -0
- package/dist/assets/index-vH6Ei526.css +1 -0
- package/dist/assets/{infoDiagram-27XIBGKW-CL4TN3Oz.js → infoDiagram-27XIBGKW-BCF2o-MF.js} +1 -1
- package/dist/assets/{ishikawaDiagram-5VMMS53U-BOpnwC1K.js → ishikawaDiagram-5VMMS53U-CNe6ETgR.js} +1 -1
- package/dist/assets/{journeyDiagram-3NMN7TZE-B9WrcTg4.js → journeyDiagram-3NMN7TZE-BVF1wnNZ.js} +1 -1
- package/dist/assets/{kanban-definition-UXKFOSKX-k-zPWS3C.js → kanban-definition-UXKFOSKX-CiWrBpoV.js} +1 -1
- package/dist/assets/{layout-3kvHth78.js → layout-B2YGfZNT.js} +1 -1
- package/dist/assets/{linear-BWj_7-Qu.js → linear-CecQQcNl.js} +1 -1
- package/dist/assets/{mindmap-definition-YA3MSWOX-CHQiqXfo.js → mindmap-definition-YA3MSWOX-CTRfx8rM.js} +1 -1
- package/dist/assets/{pegDiagram-XKGWAZYB-CbU0Toll.js → pegDiagram-XKGWAZYB-BW5JUykP.js} +1 -1
- package/dist/assets/{pieDiagram-E7YTZNPT-DMet_oui.js → pieDiagram-E7YTZNPT-rtJftIcC.js} +1 -1
- package/dist/assets/{quadrantDiagram-AXDQQJYC-BebzO8sd.js → quadrantDiagram-AXDQQJYC-C2DaPj2w.js} +1 -1
- package/dist/assets/{railroadDiagram-O6MQD6OU-Bh8-vPzn.js → railroadDiagram-O6MQD6OU-CcPfXEFl.js} +1 -1
- package/dist/assets/{requirementDiagram-BXWQKSXE-BPUXWj9N.js → requirementDiagram-BXWQKSXE-ozaClcIW.js} +1 -1
- package/dist/assets/{sankeyDiagram-P5KCCOFB-py5UjYxE.js → sankeyDiagram-P5KCCOFB-74tHF7mP.js} +1 -1
- package/dist/assets/{sequenceDiagram-WJ2MYXX4-7dG5yYB3.js → sequenceDiagram-WJ2MYXX4-CTexKnGo.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-84MVWGh6.js → sizeCapture-INFHLROL-2kVX0pT9.js} +1 -1
- package/dist/assets/{stateDiagram-D77RDMKH-BI7nUn04.js → stateDiagram-D77RDMKH-CgAkifQk.js} +1 -1
- package/dist/assets/stateDiagram-v2-MP3YSRHH-CH_iWHXT.js +1 -0
- package/dist/assets/{swimlanes-42K2YHIH-kmjOxJ3M.js → swimlanes-42K2YHIH-B-p2fQK8.js} +1 -1
- package/dist/assets/swimlanesDiagram-VR7AAH4N-BVcRccxJ.js +8 -0
- package/dist/assets/{timeline-definition-24CTP7MA-x-0bw4L3.js → timeline-definition-24CTP7MA-DhfUmVud.js} +1 -1
- package/dist/assets/{vennDiagram-4TSXK5OY-CPpgLcl3.js → vennDiagram-4TSXK5OY-ubMqyg9F.js} +1 -1
- package/dist/assets/{wardleyDiagram-VM6X3IG4-B32JnOAm.js → wardleyDiagram-VM6X3IG4-DGDiyaT7.js} +1 -1
- package/dist/assets/{xychartDiagram-S5SC5T6Z-HnFQQ24s.js → xychartDiagram-S5SC5T6Z-Cj_dbVk_.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/server.mjs +691 -129
- package/package.json +4 -4
- package/src/shared/types.ts +40 -0
- package/dist/assets/channel-BflrI4kn.js +0 -1
- package/dist/assets/classDiagram-ZZMXUADV-hGKBk6GI.js +0 -1
- package/dist/assets/classDiagram-v2-VYDZK3BY-hGKBk6GI.js +0 -1
- package/dist/assets/index-C1H-VPU1.css +0 -1
- package/dist/assets/index-D-f-6Xq7.js +0 -902
- package/dist/assets/stateDiagram-v2-MP3YSRHH-C1raQMUd.js +0 -1
- package/dist/assets/swimlanesDiagram-VR7AAH4N-Du4mhJod.js +0 -8
package/API.md
CHANGED
|
@@ -49,6 +49,40 @@ await loops.prompt(chat, "make search() faster; bench is node bench.mjs");
|
|
|
49
49
|
| `GET /sheet?run=&f=` | `image/png` — the round's contact sheet |
|
|
50
50
|
| `GET /size?run=` | `{ bytes, dirs }` — what a run's worktrees hold (what `clean` would free) |
|
|
51
51
|
| `GET /ui?chat=` | `extension_ui_request[]` still waiting for an answer |
|
|
52
|
+
| `GET /commands?chat=` | `{ commands: [{ name, source, description? }], supported, setupBlocked, error? }` — this writer's extension/template/skill catalog, not terminal builtins |
|
|
53
|
+
| `GET /models?chat=` | `{ models: [{ provider, id, name?, input? }], current?: { provider, id }, setupBlocked, error?, requiresRestart?, warning? }` — sanitized Pi metadata; idle reads refresh public metadata without a model request |
|
|
54
|
+
| `GET /providers` | `{ providers: [{ id, name, oauth, apiKey, connected }], flow? }` — stored-presence metadata and the bounded current login interaction; never credentials |
|
|
55
|
+
|
|
56
|
+
### Pi session and provider actions
|
|
57
|
+
|
|
58
|
+
| Route | Body | Effect |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| `POST /commands/run` | `{ chat, name, args? }` | Validate the exact name against this writer's current catalog, then send the command; unknown/native-only commands never fall through to model text |
|
|
61
|
+
| `POST /models` | `{ chat, provider, modelId }` | Select the exact catalog model in this chat only; returns `{ ok, current: { provider, id } }` after Pi confirms |
|
|
62
|
+
| `POST /compact` | `{ chat, customInstructions? }` | Explicitly request a potentially paid compaction; returns `{ ok, result }` after completion |
|
|
63
|
+
| `POST /providers/login` | `{ provider }` | Start Pi's OAuth login; returns `{ flow }` |
|
|
64
|
+
| `POST /providers/key` | `{ provider, key }` | Submit a literal API key to Pi's login flow; returns `{ flow }`, which may still need prompts |
|
|
65
|
+
| `POST /providers/answer` | `{ id, promptId, value }` | Answer that exact current login prompt; selections use stable option IDs |
|
|
66
|
+
| `POST /providers/cancel` | `{ id }` | Cancel the exact pending login flow and release its callback resources |
|
|
67
|
+
|
|
68
|
+
All routes share the existing token/origin/Host guards under both API prefixes. Provider responses are
|
|
69
|
+
`Cache-Control: no-store`; API keys, OAuth credentials, and raw SDK model headers/base URLs are never returned.
|
|
70
|
+
Model IDs are separate `provider`/`modelId` fields, not guessed composite-ID parsing. Session model and compaction
|
|
71
|
+
mutations are idle-only and do not replace the writer. `ChatState.sessionActions` reports `setupBlocked`, `busy`,
|
|
72
|
+
and `compaction: { status, startedAt?, finishedAt?, result?, error? }`. Completion comes from actual Pi state.
|
|
73
|
+
A mutation deadline can return `504 { error, uncertain: true }` while Pi is still working; the completion observer
|
|
74
|
+
and lock remain active. Inspect streamed state and **never automatically retry** compaction.
|
|
75
|
+
|
|
76
|
+
Login is a separate, server-wide, in-memory interaction, not chat history. A flow has `id`, `provider`, and
|
|
77
|
+
`status` (`pending`, `succeeded`, `failed`, `cancelled`, `expired`). Pending flows can include an HTTPS
|
|
78
|
+
`authorizationUrl`, `instructions`, `deviceCode: { userCode, verificationUri, expiresInSeconds? }`, and
|
|
79
|
+
`prompt: { id, type, message, placeholder?, allowEmpty?, options?: [{ id, label, description? }] }`.
|
|
80
|
+
Prompt types are `text`, `secret`, `select`, or `manual_code`. Poll status only while needed; stale prompt IDs,
|
|
81
|
+
duplicate answers, overlapping flows, and command-style API keys are refused. The maximum login lifetime is
|
|
82
|
+
15 minutes (a provider can shorten it); terminal interactions briefly retain only status, never codes/URLs.
|
|
83
|
+
`succeeded` means Pi committed credentials, not a live account/plan verification. Credential changes refresh
|
|
84
|
+
idle writers' metadata; selecting a model remains explicit. Custom RPC implementations lacking refresh support
|
|
85
|
+
report `requiresRestart` rather than silently restarting a session.
|
|
52
86
|
|
|
53
87
|
### The event stream
|
|
54
88
|
|
package/README.md
CHANGED
|
@@ -18,8 +18,51 @@ Installed from npm it is one command, and that is the one to hand someone:
|
|
|
18
18
|
npx @computesdk/loops serve
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
It is a **client of a real Pi session**, not a re-implementation of one.
|
|
22
|
-
the session is the durable record, and `.pi/loops/` is a rebuildable index plus
|
|
21
|
+
It is a **client of a real Pi session**, not a re-implementation of one. Chat state uses RPC and SSE rather than
|
|
22
|
+
polling or another database: the session is the durable record, and `.pi/loops/` is a rebuildable index plus its worktrees.
|
|
23
|
+
|
|
24
|
+
## Commands, providers, and chat models
|
|
25
|
+
|
|
26
|
+
Open **Commands** or press **Cmd/Ctrl K**. Typing `/` in the composer opens the same keyboard-navigable menu.
|
|
27
|
+
Use **↑/↓** to browse and **Enter** to choose. Model/provider forms focus their controls when ready;
|
|
28
|
+
the model filter's arrows enter the model list, and Enter confirms the selected model. Pi choice forms
|
|
29
|
+
also support ↑/↓ (plus Home/End), then Enter/Space to answer. Browsing alone never submits a choice.
|
|
30
|
+
An incoming decision preserves focus if you have started a new, unsubmitted draft.
|
|
31
|
+
Pi discovers that chat's extension commands, prompt templates, and skills; their exact names and source are shown.
|
|
32
|
+
Choosing one inserts it into the composer—review its arguments and explicitly Send. Unknown slash commands are
|
|
33
|
+
rejected without sending them to the model. This is not an emulation of Pi's full terminal interface.
|
|
34
|
+
|
|
35
|
+
| App action | Behavior |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `/new` | Create a new app chat in the selected workspace; retain the old chat and its draft |
|
|
38
|
+
| `/model` | Choose an exact provider/model from this writer's available catalog |
|
|
39
|
+
| `/compact` | Confirm a potentially paid compaction; show Pi's progress/result without automatically retrying |
|
|
40
|
+
| `/login` | Connect a provider using Pi's OAuth/API-key flow |
|
|
41
|
+
|
|
42
|
+
Discovered Pi names win collisions. The corresponding app action moves to an available `app:` alias displayed
|
|
43
|
+
in the menu, instead of silently shadowing an extension, template, or skill. Model selection changes the parent
|
|
44
|
+
chat only; it does not rewrite loop role/attempt configuration or global defaults. Model changes and compaction require an idle
|
|
45
|
+
parent and no running background loops. Neither operation replaces the Pi session or creates another writer.
|
|
46
|
+
|
|
47
|
+
**Connect provider** also works before selecting a chat. Pi's public provider metadata determines the available
|
|
48
|
+
login methods. OAuth supports browser authorization, manual callback/code prompts for remote VMs, and device-code
|
|
49
|
+
flows when offered by the provider. Finish the provider's instructions in the dialog; on a remote VM, a localhost
|
|
50
|
+
redirect may fail on your laptop, in which case copy its full callback URL into Pi's manual prompt. Closing the
|
|
51
|
+
dialog cancels its pending flow. Expiry, cancellation, and server shutdown clean up callback listeners.
|
|
52
|
+
Cancellation cannot undo a credential already committed or revoke an account grant.
|
|
53
|
+
|
|
54
|
+
API keys and authorization responses go only in JSON to the dialog's pinned server with its pinned bearer.
|
|
55
|
+
They are not written to chat, URLs, logs, or browser storage. Pi owns credential persistence and OAuth refresh;
|
|
56
|
+
the UI does not copy or implement provider token storage. A submitted key can require follow-up prompts:
|
|
57
|
+
**Connected** means Pi confirmed persistence, not that a paid verification request succeeded. Merely opening
|
|
58
|
+
the dialog lists stored-presence metadata and does not execute configured credential commands or sign in.
|
|
59
|
+
There is one bounded, in-memory login flow per server; its status is polled only while the dialog is open/pending.
|
|
60
|
+
|
|
61
|
+
After login, idle writers refresh Pi's public model runtime without a model request or automatic model switch.
|
|
62
|
+
The bundled SHA-pinned RPC adapter adds this metadata refresh; custom Pi executables without it show a restart
|
|
63
|
+
warning and are never restarted automatically. Startup extension decisions remain separate and must be answered
|
|
64
|
+
before that writer's commands/models are available. Loop settings retain role configuration and checks, while
|
|
65
|
+
their former key-only panel now opens the shared provider dialog.
|
|
23
66
|
|
|
24
67
|
| What the UI shows | Where it comes from |
|
|
25
68
|
|---|---|
|
package/bin/pi-rpc-startup.mjs
CHANGED
|
@@ -21,6 +21,14 @@ export function patchRpcStartup(source) {
|
|
|
21
21
|
' timeoutId = setTimeout(() => {\n cleanup();\n if (!shuttingDown) output({ type: "extension_ui_request_cancelled", id });\n resolve(defaultValue);\n }, opts.timeout);');
|
|
22
22
|
replaceOnce(' const command = parsed;\n try {\n const response = await handleCommand(command);',
|
|
23
23
|
' const command = parsed;\n try {\n await initialization;\n if (shuttingDown) return;\n const response = await handleCommand(command);');
|
|
24
|
+
// Login happens in the browser-facing server. Refresh this writer's public
|
|
25
|
+
// runtime without restarting its session, selecting a model, or making a model request.
|
|
26
|
+
replaceOnce(' case "get_available_models": {',
|
|
27
|
+
` case "refresh_available_models": {
|
|
28
|
+
await session.modelRuntime.refresh({ allowNetwork: false });
|
|
29
|
+
return success(id, "refresh_available_models", { models: session.modelRuntime.getAvailableSnapshot() });
|
|
30
|
+
}
|
|
31
|
+
case "get_available_models": {`);
|
|
24
32
|
replaceOnce(' // Keep process alive forever\n return new Promise(() => { });',
|
|
25
33
|
` registerSignalHandlers();
|
|
26
34
|
// Start binding only after the input reader is attached. UI replies bypass
|
package/client.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
// reach into this package's internals.
|
|
6
6
|
import type { ChatInfo, ChatState, DoctorReport, ModelOption, ParentItem, Question, Run, Workspace } from "./src/shared/types.ts";
|
|
7
7
|
export type { ChatInfo, ChatState, DoctorReport, ModelOption, ParentItem, Question, Run, RunAttempt, RunRound, RunEvent, Workspace } from "./src/shared/types.ts";
|
|
8
|
+
import type { CommandCatalog, ModelIdentity, ProviderFlow, ProviderSnapshot, SessionModelCatalog } from "./src/shared/types.ts";
|
|
9
|
+
export type { CommandCatalog, ModelIdentity, ProviderFlow, ProviderSnapshot, ProviderSummary, SessionActions, SessionCommand, SessionModel, SessionModelCatalog } from "./src/shared/types.ts";
|
|
8
10
|
|
|
9
11
|
export type ClientOptions = {
|
|
10
12
|
/** `http://box:3000` — no trailing slash needed. */
|
|
@@ -111,6 +113,31 @@ export class LoopsClient {
|
|
|
111
113
|
|
|
112
114
|
abort(chat: string) { return this.call<{ ok: boolean }>("/abort", { method: "POST", json: { chat } }); }
|
|
113
115
|
|
|
116
|
+
/** This writer's dynamic extension/template/skill catalog, not Pi's terminal builtins. */
|
|
117
|
+
commands(chat: string) { return this.call<CommandCatalog>(`/commands?chat=${encodeURIComponent(chat)}`); }
|
|
118
|
+
runCommand(chat: string, name: string, args = "") {
|
|
119
|
+
return this.call<{ disposition: string }>("/commands/run", { method: "POST", json: { chat, name, args } });
|
|
120
|
+
}
|
|
121
|
+
sessionModels(chat: string) { return this.call<SessionModelCatalog>(`/models?chat=${encodeURIComponent(chat)}`); }
|
|
122
|
+
/** Changes this chat only; loop role/attempt models remain engine configuration. */
|
|
123
|
+
setSessionModel(chat: string, provider: string, modelId: string) {
|
|
124
|
+
return this.call<{ ok: boolean; current: ModelIdentity }>("/models", { method: "POST", json: { chat, provider, modelId } });
|
|
125
|
+
}
|
|
126
|
+
/** Explicit paid operation. A timeout is uncertain delivery, never a reason to retry automatically. */
|
|
127
|
+
compact(chat: string, customInstructions?: string) {
|
|
128
|
+
return this.call<{ ok: boolean; result: unknown }>("/compact", { method: "POST", json: { chat, customInstructions } });
|
|
129
|
+
}
|
|
130
|
+
providers() { return this.call<ProviderSnapshot>("/providers"); }
|
|
131
|
+
loginProvider(provider: string) { return this.call<{ flow: ProviderFlow }>("/providers/login", { method: "POST", json: { provider } }); }
|
|
132
|
+
/** Secret input is sent only in JSON to this client's fixed server. Completion is flow.status === succeeded. */
|
|
133
|
+
setProviderKey(provider: string, key: string) {
|
|
134
|
+
return this.call<{ flow: ProviderFlow }>("/providers/key", { method: "POST", json: { provider, key } });
|
|
135
|
+
}
|
|
136
|
+
answerProviderLogin(id: string, promptId: string, value: string) {
|
|
137
|
+
return this.call<{ flow: ProviderFlow }>("/providers/answer", { method: "POST", json: { id, promptId, value } });
|
|
138
|
+
}
|
|
139
|
+
cancelProviderLogin(id: string) { return this.call<{ flow: ProviderFlow }>("/providers/cancel", { method: "POST", json: { id } }); }
|
|
140
|
+
|
|
114
141
|
/** Answer a queued question (a needs-you card). */
|
|
115
142
|
answer(chat: string, question: string, choice: string) {
|
|
116
143
|
return this.call<{ ok: boolean }>("/answer", { method: "POST", json: { chat, question, choice } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as p,r as u,d as a}from"./chunk-SVP7TREG-
|
|
1
|
+
import{g as p,r as u,d as a}from"./chunk-SVP7TREG-CBg3GrIs.js";import{p as f}from"./chunk-JWPE2WC7-B7DWQYA4.js";import{_ as n,l as o}from"./index-DvyWv1zp.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-C5BZ6yCh.js";var v=d().RailroadAbnf.parser.LangiumParser,l=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("*"),i=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:i,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 l(e.element);case"AbnfOptionalGroup":return{type:"optional",element:l(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:l(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}},w={parser:R,db:a,renderer:u,styles:p};export{w as diagram};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as ln,L as an,M as y,N as tn,O as X,P as O,Q as _,S as un,T as rn,V as $,X as o,Y as M,Z as sn,$ as on,a0 as fn}from"./index-
|
|
1
|
+
import{K as ln,L as an,M as y,N as tn,O as X,P as O,Q as _,S as un,T as rn,V as $,X as o,Y as M,Z as sn,$ as on,a0 as fn}from"./index-DvyWv1zp.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,D,S,v,A,N,a){var E=D-l,i=S-h,n=N-v,d=a-A,u=d*E-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*E,h+u*i]}function G(l,h,D,S,v,A,N){var a=l-D,E=h-S,i=(N?A:-A)/$(a*a+E*E),n=i*E,d=-i*a,u=l+n,s=h+d,f=D+n,c=S+d,Q=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,I=(g<0?-1:1)*$(fn(0,T*T*R-P*P)),K=(P*g-m*I)/R,L=(-P*m-g*I)/R,w=(P*g+m*I)/R,p=(-P*m+g*I)/R,x=K-Q,e=L-t,r=w-Q,V=p-t;return x*x+e*e>r*r+V*V&&(K=w,L=p),{cx:K,cy:L,x01:-n,y01:-d,x11:K*(v/T-1),y11:L*(v/T-1)}}function hn(){var l=cn,h=yn,D=M(0),S=null,v=gn,A=dn,N=mn,a=null,E=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=A.apply(this,arguments)-an,Q=un(c-f),t=c>f;if(a||(a=n=E()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(Q>tn-y)a.moveTo(s*X(f),s*O(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*X(c),u*O(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=Q,I=Q,K=N.apply(this,arguments)/2,L=K>y&&(S?+S.apply(this,arguments):$(u*u+s*s)),w=_(un(s-u)/2,+D.apply(this,arguments)),p=w,x=w,e,r;if(L>y){var V=sn(L/u*O(K)),j=sn(L/s*O(K));(P-=V*2)>y?(V*=t?1:-1,R+=V,T-=V):(P=0,R=T=(f+c)/2),(I-=j*2)>y?(j*=t?1:-1,m+=j,g-=j):(I=0,m=g=(f+c)/2)}var Y=s*X(m),Z=s*O(m),z=u*X(T),B=u*O(T);if(w>y){var C=s*X(g),F=s*O(g),H=u*X(R),J=u*O(R),q;if(Q<rn)if(q=pn(Y,Z,H,J,C,F,z,B)){var U=Y-q[0],W=Z-q[1],k=C-q[0],b=F-q[1],nn=1/O(on((U*k+W*b)/($(U*U+W*W)*$(k*k+b*b)))/2),en=$(q[0]*q[0]+q[1]*q[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}I>y?x>y?(e=G(H,J,Y,Z,s,x,t),r=G(C,F,z,B,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(Y,Z),a.arc(0,0,s,m,g,!t)):a.moveTo(Y,Z),!(u>y)||!(P>y)?a.lineTo(z,B):p>y?(e=G(z,B,C,F,u,-p,t),r=G(Y,Z,H,J,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}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-rn/2;return[X(d)*n,O(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:M(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:M(+n),i):h},i.cornerRadius=function(n){return arguments.length?(D=typeof n=="function"?n:M(+n),i):D},i.padRadius=function(n){return arguments.length?(S=n==null?null:typeof n=="function"?n:M(+n),i):S},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:M(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:M(+n),i):A},i.padAngle=function(n){return arguments.length?(N=typeof n=="function"?n:M(+n),i):N},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
|