okengine 0.19.0 → 0.19.2

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 (110) hide show
  1. package/package.json +1 -1
  2. package/site/content/docs/ai/meta.json +1 -1
  3. package/site/content/docs/ai/skills.mdx +1 -1
  4. package/site/content/docs/client/index.mdx +1 -2
  5. package/site/content/docs/elements/ai/agents.mdx +5 -2
  6. package/site/content/docs/elements/ai/index.mdx +4 -3
  7. package/site/content/docs/elements/ai/prompts.mdx +3 -2
  8. package/site/content/docs/elements/channel/email.mdx +5 -2
  9. package/site/content/docs/elements/channel/index.mdx +1 -1
  10. package/site/content/docs/elements/clock/index.mdx +23 -12
  11. package/site/content/docs/elements/clock/schedules.mdx +6 -3
  12. package/site/content/docs/elements/clock/sleep.mdx +10 -7
  13. package/site/content/docs/elements/flow/consumers.mdx +96 -58
  14. package/site/content/docs/elements/flow/index.mdx +15 -15
  15. package/site/content/docs/elements/flow/routing.mdx +11 -2
  16. package/site/content/docs/elements/gate/tenancy.mdx +5 -2
  17. package/site/content/docs/elements/signal/broadcast.mdx +6 -4
  18. package/site/content/docs/elements/signal/index.mdx +14 -1
  19. package/site/content/docs/elements/signal/live.mdx +3 -2
  20. package/site/content/docs/elements/signal/once.mdx +3 -2
  21. package/site/content/docs/elements/store/files.mdx +24 -16
  22. package/site/content/docs/elements/store/index.mdx +11 -8
  23. package/site/content/docs/elements/store/kv.mdx +24 -16
  24. package/site/content/docs/elements/store/search.mdx +18 -14
  25. package/site/content/docs/elements/store/sql.mdx +16 -12
  26. package/site/content/docs/elements/vault/config.mdx +5 -2
  27. package/site/content/docs/elements/vault/rotation.mdx +5 -2
  28. package/site/content/docs/elements/vault/secrets.mdx +5 -2
  29. package/site/content/docs/index.mdx +4 -19
  30. package/site/content/docs/plugins/anonymous.mdx +1 -1
  31. package/site/content/docs/plugins/cors.mdx +1 -1
  32. package/site/content/docs/plugins/csrf.mdx +1 -1
  33. package/site/content/docs/plugins/headers.mdx +1 -1
  34. package/site/content/docs/plugins/ip-allowlist.mdx +1 -1
  35. package/site/content/docs/plugins/maintenance-mode.mdx +1 -1
  36. package/site/content/docs/reference/cli.mdx +1 -1
  37. package/site/content/docs/reference/errors.mdx +1 -0
  38. package/site/content/docs/reference/fx.mdx +9 -8
  39. package/site/content/docs/reference/okid.mdx +1 -1
  40. package/site/content/docs/reference/plugins.mdx +1 -1
  41. package/site/content/docs/reference/security.mdx +2 -2
  42. package/site/content/docs/understand/meta.json +1 -1
  43. package/site/content/docs/understand/the-architecture.mdx +264 -0
  44. package/src/bench/REPORT.md +48 -17
  45. package/src/bench/g17-hybrid-search.bench.ts +13 -13
  46. package/src/compiler/extract.test.ts +76 -1
  47. package/src/compiler/extract.ts +106 -7
  48. package/src/compiler/search-writer-isolation.test.ts +0 -1
  49. package/src/console/ui-next/dist/assets/{access-page-DFeymU07.js → access-page-DceEWH9u.js} +1 -1
  50. package/src/console/ui-next/dist/assets/{agent-disclosure-U1rdfblp.js → agent-disclosure-tC9s2VFd.js} +1 -1
  51. package/src/console/ui-next/dist/assets/{cache-glyph-BeFJeqBG.js → cache-glyph-C-naNQSR.js} +1 -1
  52. package/src/console/ui-next/dist/assets/{call-pii-button-CVAONPii.js → call-pii-button-DnZ_MlDn.js} +1 -1
  53. package/src/console/ui-next/dist/assets/{collapsible-D2A6NJ-3.js → collapsible-RekgR6Qz.js} +1 -1
  54. package/src/console/ui-next/dist/assets/{duration-tone-Cgk_h5ja.js → duration-tone-DugtWBS0.js} +1 -1
  55. package/src/console/ui-next/dist/assets/flows-page-DVmn1ZuQ.js +1 -0
  56. package/src/console/ui-next/dist/assets/{highlighted-json-MYZQtRnw.js → highlighted-json-CvBGaiSD.js} +1 -1
  57. package/src/console/ui-next/dist/assets/{http-method-Jrh39p7A.js → http-method-D7_OXbdC.js} +1 -1
  58. package/src/console/ui-next/dist/assets/{index-DXP2dBIF.js → index-DH0K2f6N.js} +3 -3
  59. package/src/console/ui-next/dist/assets/{observability-page-HvolXxTI.js → observability-page-qJzF2nSN.js} +1 -1
  60. package/src/console/ui-next/dist/assets/{replica-lag-CSh2dzrb.js → replica-lag-Vqk0pUBA.js} +1 -1
  61. package/src/console/ui-next/dist/assets/request-meta-BtShi4sG.js +1 -0
  62. package/src/console/ui-next/dist/assets/{store-page-eiKiHnNe.js → store-page-CMsYH_vH.js} +1 -1
  63. package/src/console/ui-next/dist/assets/{trace-detail-sheet-CZkMeKS-.js → trace-detail-sheet-ycFB2uua.js} +1 -1
  64. package/src/console/ui-next/dist/assets/{tree-expand-toggle-CW8y5A2h.js → tree-expand-toggle-iG1jcWgU.js} +1 -1
  65. package/src/console/ui-next/dist/assets/{units-page-B_RWJrEO.js → units-page-Bavchke4.js} +1 -1
  66. package/src/console/ui-next/dist/assets/{vault-page-CWrg-A68.js → vault-page-DxUFhiZI.js} +1 -1
  67. package/src/console/ui-next/dist/index.html +1 -1
  68. package/src/console/ui-next/src/features/flows/graph/element-map.test.ts +1 -1
  69. package/src/console/ui-next/src/features/flows/graph/element-map.ts +3 -3
  70. package/src/console/ui-next/src/features/flows/traces/trace-detail.test.ts +4 -5
  71. package/src/console/ui-next/src/features/flows/traces/trace-gates.ts +3 -6
  72. package/src/elements/gate/declare.ts +1 -1
  73. package/src/elements/gate.ts +1 -1
  74. package/src/elements/store/live-default.test.ts +8 -0
  75. package/src/elements/store/search-embed-flow.ts +2 -2
  76. package/src/elements/store/search-lsh.ts +35 -0
  77. package/src/elements/store/search-runtime.pglite.test.ts +186 -0
  78. package/src/elements/store/search-runtime.ts +30 -16
  79. package/src/elements/store/search.test.ts +83 -1
  80. package/src/elements/store.ts +2 -0
  81. package/src/full.ts +3 -0
  82. package/src/http.ts +3 -0
  83. package/src/index.ts +3 -0
  84. package/src/kernel/app.ts +30 -10
  85. package/src/kernel/boot.ts +1 -1
  86. package/src/kernel/cdc-payload.test.ts +224 -0
  87. package/src/kernel/cdc-payload.ts +146 -0
  88. package/src/kernel/errors-flow-name.ts +17 -0
  89. package/src/kernel/errors.registry.test.ts +6 -4
  90. package/src/kernel/flow-name.test.ts +104 -0
  91. package/src/kernel/flow.ts +3 -2
  92. package/src/kernel/fx-emit-types.test.ts +31 -0
  93. package/src/kernel/fx.test.ts +2 -1
  94. package/src/kernel/fx.ts +13 -3
  95. package/src/kernel/index.ts +2 -0
  96. package/src/kernel/on.ts +5 -0
  97. package/src/kernel/stamp-http.test.ts +13 -0
  98. package/src/kernel/stamp-http.ts +21 -3
  99. package/src/kernel/unit.ts +4 -2
  100. package/src/kernel-entry.ts +3 -0
  101. package/src/mcp/docs-index.ts +3 -3
  102. package/src/mcp/docs-mcp.test.ts +2 -2
  103. package/src/mcp/docs-tools.ts +2 -1
  104. package/site/content/docs/understand/the-anatomy.mdx +0 -132
  105. package/site/content/docs/understand/the-model.mdx +0 -32
  106. package/site/content/docs/understand/the-problem.mdx +0 -74
  107. package/site/content/docs/understand/the-vocabulary.mdx +0 -26
  108. package/src/console/ui-next/dist/assets/flows-page-Dss7941e.js +0 -1
  109. package/src/console/ui-next/dist/assets/request-meta-BatF8KrK.js +0 -1
  110. /package/site/content/docs/{ai → understand}/try-it.mdx +0 -0
@@ -1,132 +0,0 @@
1
- ---
2
- title: "The Anatomy"
3
- description: "The five pieces behind on(trigger, flow) — on, trigger, flow, do, and fx — explained one at a time, then combined."
4
- icon: "PenTool"
5
- ---
6
-
7
- Everything a Flow does reduces to one line:
8
-
9
- ```typescript
10
- on(
11
- trigger,
12
- flow({
13
- do: (input, fx) => {
14
- /* ... */
15
- },
16
- }),
17
- );
18
- ```
19
-
20
- If that line doesn't mean much yet, that's what this page is for. Five pieces make it up. We'll take them one at a time, then put them together using a complete signup example.
21
-
22
- ## `on(...)` — wires a trigger to a flow
23
-
24
- `on` does exactly one thing: it connects "something that can happen" to "code that should run when it does." Nothing executes until this connection exists.
25
-
26
- ```typescript
27
- on(someTrigger, someFlow);
28
- ```
29
-
30
- That's the whole job. The interesting parts are what goes in each slot.
31
-
32
- ## A trigger — the answer to "when"
33
-
34
- The first argument to `on` is the trigger: whatever wakes the code up. A trigger doesn't run any of your logic — it only answers one question: _when should this happen?_
35
-
36
- ```typescript
37
- http.post(); // path from the file tree — e.g. src/flows/users/signup.ts → POST /users/signup
38
- ```
39
-
40
- There are five kinds of trigger in total — the table at the end of this page lists them. For now: the trigger is the _when_, and it's the only thing that changes between an endpoint, a scheduled job, and everything else.
41
-
42
- ## `flow(...)` — the actual unit of work
43
-
44
- The second argument to `on` is a Flow — declared with the `flow()` function. It answers _what_: what work is this, and what does it promise about its inputs and outputs?
45
-
46
- ```typescript
47
- flow({
48
- do: /* the actual code — next */,
49
- });
50
- ```
51
-
52
- Omit the name on tree files — the compiler stamps `unit.export` (e.g. `users.signup`).
53
- Pass `flow("users.signup", { … })` only for control: barrels, stable names across
54
- moves, or call-only Flows you `fx.call` by name.
55
-
56
- ## `do` — the code that actually runs
57
-
58
- `do` is a function you write. It answers _how_. It receives two things: `input` (your data) and `fx` (next). Everything your Flow actually does lives here.
59
-
60
- ```typescript
61
- do: async (input, fx) => {
62
- return { ok: true };
63
- };
64
- ```
65
-
66
- ## `fx` — the only door to the outside world
67
-
68
- `fx` is the second argument to `do`, and it's the piece the other four exist to protect. The rule is simple and absolute: **your Flow is not allowed to read a database, send an email, check a clock, or touch anything outside itself except through `fx`.**
69
-
70
- ```typescript
71
- do: async (input, fx) => {
72
- const user = await fx.store(db).insert(users).values(input); // the database, through fx
73
- await fx.send(welcomeEmail, { to: user.email }); // another system, through fx
74
- return user;
75
- };
76
- ```
77
-
78
- This one rule is what made the Month 8 drift from The Problem avoidable: if `fx` is the only door, retries, auditing, and idempotency stop being separate systems teams build by hand, and become properties of the one boundary everything already passes through.
79
-
80
- ## Putting the five pieces together
81
-
82
- Here is the complete signup flow, with every piece labeled where it sits:
83
-
84
- ```typescript title="src/flows/users/signup.ts"
85
- export const signup = on(
86
- http.post(), // ← trigger: when (stamped POST /users/signup)
87
- flow({
88
- // ↑ flow: what (stamped users.signup)
89
- do: async (input, fx) => {
90
- // ← do: how
91
- const user = await fx.store(db).insert(users).values(input); // ← fx: the only way out
92
- await fx.send(welcomeEmail, { to: user.email, data: { name: user.name } });
93
- return user;
94
- },
95
- }),
96
- );
97
- ```
98
-
99
- <Callout title="Call-only flows">
100
- A `flow(...)` declared without `on(...)` around it is internal — nothing outside your code can
101
- start it. Other flows invoke it directly with `fx.call(flowRef, input)`.
102
- </Callout>
103
- ## Checking it against the timeline
104
-
105
- Nothing about the code above looks more complicated than the four lines that started the drift on The Problem — because it isn't. The difference only shows up when the same pressure from that timeline hits it.
106
-
107
- Every fork from that timeline was really the same question, asked at a different point: _is this thing that touches the outside world safe to retry, safe to audit, safe to run twice?_ On The Problem, each answer required a new system, because each system had to invent its own answer. Here, the question has one home:
108
-
109
- - **The traffic spike from Week 2** doesn't need a queue you build and wire up by hand — running this later, safely, is something you ask of the trigger or the effect itself, not infrastructure you assemble.
110
- - **The silent failure from Month 2** doesn't need a hand-picked retry count living in a worker nobody remembers the reasoning for. Retries are a property of the `fx` boundary every effect already passes through.
111
- - **The compliance question from Month 4** doesn't need a `sent_emails` table written by hand from inside a background job. What was sent, and when, is something the system already knows, because nothing was allowed to send anything outside of `fx` in the first place.
112
- - **The double-submit from Month 6** doesn't need dedup logic split across a queue and a database that never check each other. There's one call, through one door — there's no second path left for a duplicate to sneak through.
113
-
114
- None of that required new code beyond what's above. It required the four lines to already be the kind of thing where those questions have a fixed answer, instead of a new one invented per team, per incident.
115
-
116
- ## Five kinds of trigger
117
-
118
- `flow`, `do`, and `fx` never change shape. Only the trigger does — and there are exactly five kinds, one per element that can independently wake a Flow up:
119
-
120
- | Trigger | Element | Starts When |
121
- | --------------------------------------------------- | ------- | -------------------------------- |
122
- | `http.post()` (path from file tree) | Flow | A request arrives |
123
- | `clock("name", { every: "10m" })` | Clock | A time interval elapses |
124
- | `signal.once("name", {…})` / `.broadcast` / `.live` | Signal | Another flow announces something |
125
- | `db.table(users).changed("email")` | Store | A database row changes |
126
- | `mcp.tool("name")` | AI | An AI agent calls it |
127
-
128
- The next section walks through each element in depth — this is just enough to recognize them when you see them.
129
-
130
- ## Where this goes next
131
-
132
- You've seen the problem, the model, the vocabulary, and now the exact anatomy behind every Flow — proven against the timeline that motivated it. The next step is running it yourself: from an empty folder to this exact Flow answering a real request, in one sitting.
@@ -1,32 +0,0 @@
1
- ---
2
- title: "The Model"
3
- description: "The one rule that removes the disagreement between systems — stated plainly, in two parts."
4
- icon: "Compass"
5
- ---
6
-
7
- ## The fix, stated as a rule
8
-
9
- Every seam on the last page came from the same root cause: each system involved had its own idea of when it should run and what it was allowed to touch, and nothing forced those ideas to agree with each other.
10
-
11
- OKE removes the disagreement by removing the choice. It's one rule, in two parts.
12
-
13
- **First: every trigger reduces to the same shape.** An HTTP request, a scheduled tick, a queue message, a database change — whatever wakes the code up, what follows has one identical anatomy: `on(Trigger) → Effects`. Not four systems that happen to look similar. One system, with four ways to wake it up.
14
-
15
- **Second: every effect passes through one door.** Nothing is allowed to touch a database, send an email, check a permission, or read the clock on its own — all of it goes through a single surface. Not because that's tidier. Because it's the only way retries, auditing, idempotency, and permission checks stop being infrastructure every team reinvents at the exact moment they get burned by not having it. Build the door once, correctly, and every trigger that walks through it inherits the same guarantees automatically.
16
-
17
- That's the whole model. Not a bigger toolbox — a smaller number of things that are allowed to happen at all.
18
-
19
- ## Why the door has a fixed vocabulary
20
-
21
- A door that lets anything through isn't actually closed. So the door recognizes a fixed set of things it's willing to do, and nothing new gets added to that set unless it does something none of the existing ones can. What that set is, and why it stops at eight, is the next page.
22
-
23
- ## What this project is called
24
-
25
- One shape for every trigger, one door for every effect, a fixed vocabulary for what the door allows — that's what this project built. It's called **OKE**.
26
-
27
- ---
28
-
29
- <sub>
30
- *OKE isn't an acronym for anything in the code. It comes from Omq Khafi — the organization this
31
- engine grew out of — with "Engine" appended: **O**mq **K**hafi **E**ngine.*
32
- </sub>
@@ -1,74 +0,0 @@
1
- ---
2
- title: "The Problem"
3
- description: "Three unrelated features that hit the exact same wall, and the timeline that shows why."
4
- icon: "TriangleAlert"
5
- ---
6
-
7
- ## Three features, same wall
8
-
9
- **A signup flow.** A user registers. Send them a welcome email. Four lines of code — until traffic spikes, the mail provider starts rate-limiting, and "send an email" quietly needs a queue, a worker, and a retry policy nobody designed on purpose.
10
-
11
- **A payment webhook.** A provider confirms a charge. Mark the order paid. Simple — until the provider retries the same webhook twice during a network hiccup, and "mark the order paid" needs to somehow know it already ran.
12
-
13
- **A nightly report.** Summarize yesterday's activity and email it to managers. Trivial — until a manager's access gets revoked at 11:58pm and the report that runs at midnight has no idea the permission it checked when the feature was built isn't the permission that holds right now.
14
-
15
- Three teams. Three domains. Nobody on any of them talked to the other two. And all three land on the identical fork: **something has to happen later, exactly once, provably — and nothing in the original four lines said what "provably" would end up costing.**
16
-
17
- ## Follow one all the way through
18
-
19
- Take the first one. Just the signup flow, from the day it shipped.
20
-
21
- ```typescript
22
- app.post("/signup", async (req, res) => {
23
- const user = await db.users.create(req.body);
24
- await sendMail(user.email, "Welcome!", welcomeTemplate(user));
25
- res.json(user);
26
- });
27
- ```
28
-
29
- It works. It ships. Two weeks later, a launch drives a traffic spike, the mail provider starts returning `429`, and signups start failing because an unrelated email is slow. You move the send off the request path:
30
-
31
- ```typescript
32
- app.post("/signup", async (req, res) => {
33
- const user = await db.users.create(req.body);
34
- emailQueue.add("welcome", { userId: user.id });
35
- res.json(user);
36
- });
37
- ```
38
-
39
- The endpoint is fast again. It's also no longer one system — it's an endpoint, a queue, a worker, and a Redis connection nobody else on the team knew existed until a missing `REDIS_URL` broke staging.
40
-
41
- From here the same pattern repeats on a longer clock. A support ticket reveals a job failed silently — nobody had configured retries, so you add them, and now a specific number (3? 5? with what backoff?) lives in a file that nobody will remember the reasoning for in six weeks. Compliance asks for proof of every email sent — you add a table written to from inside the worker, and now that worker has two jobs instead of one, quietly capable of disagreeing with itself if the second write fails. Someone double-clicks submit — two jobs enqueue, two emails send, and idempotency becomes a fact that has to live in two systems that were never introduced to each other.
42
-
43
- <SixSystemsDrift />
44
-
45
- None of these were mistakes. Each one was the correct call, made by a competent engineer, in direct response to something that actually happened. That's what makes the drift invisible while it's happening — there's no bad decision anywhere in this story to point at.
46
-
47
- ## What's actually going on
48
-
49
- Look at what the six resulting files have in common: none of them agree with each other about the same three things. What counts as "done." What happens on failure. Who's allowed to do this at all.
50
-
51
- That's the real cost — not the number of tools, but what sits between them:
52
-
53
- - **Failure means something different in each one.** A queue retry, an HTTP 500, and a rejected promise from a mail SDK are three unrelated shapes that all happen to mean "this didn't work."
54
- - **Permission has no fixed address.** It lives wherever whoever wrote that file remembered to put it — which means a reviewer can't point at one place and ask "is this checked?"
55
- - **Two systems both think they own the same fact.** The database says an order is paid. The already-running webhook handler doesn't know that yet. Nothing keeps them honest with each other in the gap.
56
- - **Nobody can see the whole thing at once.** There is no file, diagram, or dashboard where "the signup flow" exists as one object — only as the sum of files that happen to call each other.
57
-
58
- ## If you've been doing this a while
59
-
60
- None of the three stories above are hypothetical to you. You've shipped at least one of them — maybe with a different provider, a different table name, a different Slack channel where the incident got triaged. You've sat in the postmortem. You've written the line in the retro doc that says "we should have thought about retries from the start," knowing full well that thinking about it from the start wouldn't have told you which of forty possible failure modes was going to be the one that mattered.
61
-
62
- That's not a criticism of your judgment. It's the actual shape of the problem: every decision in that timeline was locally correct and still added a system that doesn't speak the same language as the five before it. You didn't do this wrong. The tools you were given don't leave room to do it any other way.
63
-
64
- ## If you haven't yet
65
-
66
- If your code right now still looks like the four lines from Day 1 — on any feature, in any domain — this is the part that matters most: **you will hit this fork.** Not "might." Every one of the three stories above started as a sentence a product manager could say out loud in one breath. The traffic spike, the silent retry, the compliance question, the double-submit — these aren't edge cases that happen to unlucky teams. They're what happens to any trigger that lives long enough to matter, and right now you simply haven't reached that point in the timeline yet.
67
-
68
- The four lines were never wrong. They were just the first data point on a line that already knew where it was going.
69
-
70
- ## The actual question
71
-
72
- Nothing above was avoidable by writing cleaner code inside any single file. The problem was never inside a file — it was that several files had to agree on things none of them were ever designed to agree on.
73
-
74
- What would have to be true on day one for month eight to never happen?
@@ -1,26 +0,0 @@
1
- ---
2
- title: "The Vocabulary"
3
- description: "The eight things the door recognizes — what each one replaces, and why nothing else made the cut."
4
- icon: "Boxes"
5
- ---
6
-
7
- ## What the door recognizes
8
-
9
- The door from the last page isn't open-ended — it recognizes a fixed set of things it's willing to do. Each one made the cut because it has _irreducible physics_: behavior that breaks if you tried to fake it using one of the others. A queue's retry and lease semantics aren't a database's job. A secret's rotation lifecycle isn't a config value's job. Where that distinction is real, it gets a name. Where it isn't, it doesn't — which is why the list stops at eight instead of growing indefinitely.
10
-
11
- | Element | What it is | What it replaces |
12
- | ----------- | -------------------- | ----------------------------------------------------------------------- |
13
- | **Flow** | Execution & behavior | endpoint, handler, consumer, job, workflow, webhook |
14
- | **Signal** | Data in motion | queue, pub/sub, stream, websocket, SSE, event bus |
15
- | **Store** | Data at rest | relational database, cache, key-value store, file storage, search index |
16
- | **Clock** | Time & schedules | cron, delay, timeout, durable sleep, TTL |
17
- | **Gate** | Permission to act | auth, session, tenancy, RBAC, rate limit, quota |
18
- | **Vault** | Protected knowledge | secrets, encryption keys, rotation, environment variables |
19
- | **Channel** | Reaching a human | transactional email, SMS, push notifications, receipts |
20
- | **AI** | Machine intelligence | model calls, structured prompts, agents, MCP tools |
21
-
22
- Read the right column as the honest answer to "what would I have reached for before this?" Every item in it is a separate tool with its own configuration, its own failure modes, and its own place to go wrong. The left column is the same ground, covered by something with one shared door and one shared set of guarantees.
23
-
24
- ## Where this goes next
25
-
26
- The next step is breaking down the five pieces behind every Flow — the exact anatomy that connects a trigger to its effects.
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{r as t}from"./react-dom-Ddte4I-Q.js";import{A as n,a as r,c as i,d as a,o,p as s,r as c,s as l,t as u}from"./xyflow-yApv7D4e.js";import{Cr as d,Dr as f,E as p,Er as m,F as h,I as g,R as _,_r as v,br as y,cr as b,dr as x,ha as S,kr as C,vr as w,x as T,xr as E,yr as D}from"./shortcut-keys-3ILd8oGn.js";import{a as O,b as k,c as ee,d as te,f as ne,i as re,l as ie,n as ae,o as oe,p as se,r as ce,t as A,u as le}from"./element-icons-BI8cJgdh.js";import{s as ue}from"./collapsible-D2A6NJ-3.js";import{t as de}from"./duration-tone-Cgk_h5ja.js";import{a as fe,c as pe,i as me,l as he,o as ge,s as _e}from"./highlighted-json-MYZQtRnw.js";import{C as ve,S as ye,_ as j,b as be,d as xe,f as Se,g as M,h as Ce,p as we,v as N,y as P}from"./request-meta-BatF8KrK.js";import{n as Te}from"./dagre.esm-B1_XeuLP.js";import{a as Ee,i as De,n as Oe,o as ke,r as Ae,t as je}from"./trace-detail-sheet-CZkMeKS-.js";import{a as Me,c as Ne,l as Pe,o as Fe,vt as Ie}from"./index-DXP2dBIF.js";import{a as Le,c as F,i as Re,n as ze,o as Be,r as Ve,t as He}from"./cache-glyph-BeFJeqBG.js";import{t as Ue}from"./agent-disclosure-U1rdfblp.js";var We=[[`path`,{d:`M4 5L20 5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M4 12L20 12`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M4 19L20 19`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],I=e(t(),1),L=[`flow`,`signal`,`store`,`clock`,`gate`,`vault`,`channel`,`ai`];function R(e,t,n){return{x:j.cx+t*Math.cos(e)-n.width/2,y:j.cy+t*Math.sin(e)-n.height/2}}function Ge(e){if(e<=0)return[];let t=2*Math.PI/e;return Array.from({length:e},(e,n)=>-Math.PI/2+n*t)}var Ke=2*Math.PI/L.length;function z(e,t,n=j.typeRing){if(t<=0)return[];if(t===1)return[e];let r=(N.type.width+10)/n,i=Math.min(r*(t-1),Ke*.7);return Array.from({length:t},(n,r)=>e-i/2+r/(t-1)*i)}function qe(e,t){if(t<=0)return[];let n=j.typeRing,r=j.typeRing+j.typeRow;if(t===1)return[{angle:e,radius:n}];if(t===4)return Ye(e,n,r);if(t<=3)return z(e,t,n).map(e=>({angle:e,radius:n}));let i=Math.ceil(t/2),a=t-i;return[...z(e,i,n).map(e=>({angle:e,radius:n})),...z(e,a,r).map(e=>({angle:e,radius:r}))]}function Je(e){return Math.abs(Math.cos(e))*N.type.height+Math.abs(Math.sin(e))*N.type.width}function Ye(e,t,n){let r=(Je(e)+24)/t;return[{angle:e-r/2,radius:t},{angle:e+r/2,radius:t},{angle:e-r/2,radius:n},{angle:e+r/2,radius:n}]}function B(e){let t=new Set([`flow`]),n=e.trigger;(n?.cron||n?.every)&&t.add(`clock`),n?.signal&&t.add(`signal`),(e.gates?.length??0)>0&&t.add(`gate`);let r=e.effects;return((r?.reads?.length??0)>0||(r?.writes?.length??0)>0)&&t.add(`store`),(r?.emits?.length??0)>0&&t.add(`signal`),(r?.sends?.length??0)>0&&t.add(`channel`),(r?.asks?.length??0)>0&&t.add(`ai`),(r?.secrets?.length??0)>0&&t.add(`vault`),L.filter(e=>t.has(e))}function Xe(e){let t=new Set([`flow`]);(e.trigger===`cron`||e.trigger===`every`)&&t.add(`clock`),e.trigger===`signal`&&t.add(`signal`),e.gates.length>0&&t.add(`gate`);for(let n of e.effects)switch(n.kind){case`read`:case`write`:t.add(`store`);break;case`emit`:t.add(`signal`);break;case`send`:case`fetch`:t.add(`channel`);break;case`ask`:case`embed`:t.add(`ai`);break;case`secret`:t.add(`vault`)}return L.filter(e=>t.has(e))}function Ze(e,t){let n=new Map,r=(e,t,r)=>{n.has(e)||n.set(e,r===void 0?{id:e,label:t}:{id:e,label:t,badge:r})};switch(t){case`flow`:for(let t of Object.keys(e.flows??{}).sort())r(`flow:${t}`,Ve(t),F(t));break;case`signal`:for(let t of Object.keys(e.signals??{}).sort())r(`signal:${t}`,t,`signal`);for(let t of Object.values(e.flows??{})){t.trigger?.signal&&r(`signal:${t.trigger.signal}`,t.trigger.signal,`signal`);for(let e of t.effects?.emits??[])r(`signal:${e}`,e,`signal`)}break;case`store`:for(let[t,n]of Object.entries(e.stores??{})){let e=n.facet;for(let t of Object.keys(n.tables??{}).sort())r(`${e}:${t}`,t,e);let i=n.namespaces&&n.namespaces.length>0?n.namespaces:[];e===`kv`&&i.length===0&&r(`kv:${t}`,t,`kv`);for(let e of[...i].sort())r(`kv:${e}`,e,`kv`);for(let e of[...n.buckets??[]].sort())r(`files:${e}`,e,`files`);for(let e of[...n.indexes??[]].sort())r(`index:${e}`,e,`index`)}for(let t of Object.values(e.flows??{}))for(let e of[...t.effects?.reads??[],...t.effects?.writes??[]]){let t=Qe(e);t&&r(t.id,t.label,t.badge)}break;case`clock`:for(let[t,n]of Object.entries(e.clocks??{}).sort(([e],[t])=>e.localeCompare(t)))r(`clock:${t}`,t,n.cron?`cron`:n.every?`every`:`clock`);for(let[t,n]of Object.entries(e.flows??{}))n.trigger?.cron&&r(`clock:${t}`,n.trigger.cron,`cron`),n.trigger?.every&&r(`clock:${t}`,n.trigger.every,`every`);break;case`gate`:for(let t of Object.keys(e.gates??{}).sort())r(`gate:${t}`,t,`gate`);for(let t of Object.values(e.flows??{}))for(let e of t.gates??[])r(`gate:${e}`,e,`gate`);break;case`vault`:for(let t of Object.keys(e.vault??{}).sort())r(`vault:${t}`,t,`vault`);for(let t of Object.values(e.flows??{}))for(let e of t.effects?.secrets??[])r(`vault:${e}`,e,`vault`);break;case`channel`:for(let t of Object.keys(e.channels??{}).sort())r(`channel:${t}`,t,`channel`);for(let t of Object.values(e.flows??{}))for(let e of t.effects?.sends??[])r(`channel:${e}`,e,`channel`);break;case`ai`:for(let t of Object.keys(e.ai?.prompts??{}).sort())r(`ai:${t}`,t,`prompt`);for(let t of Object.keys(e.ai?.agents??{}).sort())r(`ai:${t}`,t,`agent`);for(let t of Object.values(e.flows??{}))for(let e of t.effects?.asks??[])r(`ai:${e}`,e,`prompt`)}return[...n.values()].sort((e,t)=>e.label.localeCompare(t.label))}function Qe(e){return e.startsWith(`sql:`)?{id:e,label:e.slice(4),badge:`sql`}:e.startsWith(`kv:`)?{id:e,label:e.slice(3),badge:`kv`}:e.startsWith(`files:`)?{id:e,label:e.slice(6),badge:`files`}:e.startsWith(`index:`)?{id:e,label:e.slice(6),badge:`index`}:null}var $e={flow:xe.map(e=>({kind:e,label:Se[e].label})),signal:[{kind:`once`,label:`once`},{kind:`broadcast`,label:`broadcast`},{kind:`live`,label:`live`}],store:[{kind:`sql`,label:`SQL`},{kind:`kv`,label:`KV`},{kind:`files`,label:`Files`},{kind:`index`,label:`Index`}],clock:[{kind:`cron`,label:`cron`},{kind:`every`,label:`every`}],gate:[{kind:`policy`,label:`policy`},{kind:`scope`,label:`scope`},{kind:`rate`,label:`rate`},{kind:`flag`,label:`flag`}],vault:[{kind:`secret`,label:`secret`},{kind:`config`,label:`config`},{kind:`env`,label:`env`}],channel:[{kind:`email`,label:`email`},{kind:`sms`,label:`SMS`},{kind:`whatsapp`,label:`WA`},{kind:`push`,label:`Push`}],ai:[{kind:`model`,label:`model`},{kind:`prompt`,label:`prompt`},{kind:`embed`,label:`embed`},{kind:`agent`,label:`agent`}]};function et(e,t){return $e[t].map(e=>({id:`type:${t}:${e.kind}`,label:e.label,badge:e.kind}))}function tt(e,t){return t?.kind===`rate`||e.startsWith(`rate:`)?`rate`:e.startsWith(`flag:`)?`flag`:(t?.scopes?.length??0)>0?`scope`:`policy`}function nt(e){return e?.sensitive===!1?`config`:`secret`}function rt(e,t){let n=t.split(`@`)[0]??t;return e.ai?.agents?.[n]?`agent`:e.ai?.models?.[n]?`model`:`prompt`}function it(e,t,n){let r=`type:${n}:`;switch(n){case`flow`:return[`${r}${we(t.trigger)}`];case`store`:{let e=new Set;for(let n of[...t.effects?.reads??[],...t.effects?.writes??[]]){let t=Qe(n);t?.badge&&e.add(t.badge)}return[...e].map(e=>`${r}${e}`)}case`signal`:{let n=[...t.trigger?.signal?[t.trigger.signal]:[],...t.effects?.emits??[]],i=new Set;for(let t of n){let n=e.signals?.[t]?.delivery;n&&i.add(n)}return[...i].map(e=>`${r}${e}`)}case`clock`:{let e=[];return t.trigger?.cron&&e.push(`${r}cron`),t.trigger?.every&&e.push(`${r}every`),e}case`gate`:return[...new Set((t.gates??[]).map(t=>tt(t,e.gates?.[t])))].map(e=>`${r}${e}`);case`vault`:return[...new Set((t.effects?.secrets??[]).map(t=>nt(e.vault?.[t])))].map(e=>`${r}${e}`);case`channel`:{let n=new Set;for(let r of t.effects?.sends??[]){let t=e.channels?.[r]?.medium;t&&t!==`any`&&n.add(t)}return[...n].map(e=>`${r}${e}`)}case`ai`:return[...new Set((t.effects?.asks??[]).map(t=>rt(e,t)))].map(e=>`${r}${e}`)}}function at(e){let t=e?.flows??{},n=new Map;for(let e of Object.keys(t).sort()){let t=F(e),r=n.get(t)??[];r.push(e),n.set(t,r)}let r=new Map,i=new Map,a=new Map;for(let[e,o]of n){let n=new Set;for(let i of o){let o=t[i];if(o)for(let t of B(o)){n.add(t);let o=`${e}\0${t}`;r.set(o,(r.get(o)??0)+1);let s=a.get(t)??new Set;s.add(i),a.set(t,s)}}i.set(e,n)}let o=[...n.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({unit:e,flowCount:t.length,elements:L.filter(t=>i.get(e)?.has(t)),live:0,errors:0})),s=L.map(t=>({element:t,resourceCount:e?Ze(e,t).length:0,flowCount:a.get(t)?.size??0,live:0,errors:0})),c=[];for(let e of o)for(let t of e.elements)c.push({unit:e.unit,element:t,flowCount:r.get(`${e.unit}\0${t}`)??0});return{units:o,hubs:s,couplings:c}}function ot(e,t){let n=new Map,r=new Map,i=new Map,a=new Map;for(let e of t){let t=e.unit??F(e.flow);n.set(t,(n.get(t)??0)+1),e.error&&r.set(t,(r.get(t)??0)+1);for(let t of Xe(e))i.set(t,(i.get(t)??0)+1),e.error&&a.set(t,(a.get(t)??0)+1)}return{couplings:e.couplings,units:e.units.map(e=>({...e,live:n.get(e.unit)??0,errors:r.get(e.unit)??0})),hubs:e.hubs.map(e=>({...e,live:i.get(e.element)??0,errors:a.get(e.element)??0}))}}function st(e,t=[],n=null){if(!e||Object.keys(e.flows??{}).length===0)return{nodes:[],edges:[],units:[],hubs:[]};let r=ot(at(e),t),i=n?.element,a=r.hubs.find(e=>e.element===`flow`)?.live??0,o=r.hubs.find(e=>e.element===`flow`)?.errors??0,s=[],c=[];s.push(V(`orbit:elements`,j.elementRing)),s.push(V(`orbit:types`,j.typeRing)),s.push(V(`orbit:spokes`,j.spokeRing)),s.push({id:`law:oke`,type:`law`,position:{x:j.cx-N.law.width/2,y:j.cy-N.law.height/2},data:{kind:`law`,label:e.app,refId:`oke`,badge:String(r.units.reduce((e,t)=>e+t.flowCount,0)),live:a,errors:o},selectable:!1,draggable:!1,zIndex:M.leaf,width:N.law.width,height:N.law.height,style:{width:N.law.width,height:N.law.height,overflow:`visible`}});let l=Ge(L.length);if(r.hubs.forEach((e,t)=>{let n=l[t]??0,r=N.hub;s.push({id:`element:${e.element}`,type:`element`,position:R(n,j.elementRing,r),data:{kind:`element`,label:A[e.element].symbol,refId:e.element,badge:String(e.resourceCount),live:e.live,errors:e.errors,dimmed:i!=null&&e.element!==i},draggable:!1,zIndex:M.leaf,width:r.width,height:r.height,style:{width:r.width,height:r.height}}),c.push(U(`element:${e.element}`,`law:oke`,e.element,1,!0))}),!i||i===`flow`){let t=N.type;r.hubs.forEach((n,r)=>{let i=l[r]??0,a=et(e,n.element),o=qe(i,a.length);a.forEach((e,r)=>{let a=o[r]??{angle:i,radius:j.typeRing};s.push({id:e.id,type:`typeChip`,position:R(a.angle,a.radius,t),data:{kind:n.element,label:e.label,refId:e.id,...e.badge===void 0?{}:{badge:e.badge,facet:e.badge}},draggable:!1,zIndex:M.leaf,width:t.width,height:t.height,style:{width:t.width,height:t.height}}),c.push(U(e.id,`element:${n.element}`,n.element,1))})})}if(i&&i!==`flow`){let t=Ze(e,i),n=be.store,r=Ge(t.length);t.forEach((e,t)=>{let a=r[t]??0;s.push({id:e.id,type:i,position:R(a,j.spokeRing,n),data:{kind:i,label:e.label,refId:e.id,...e.badge===void 0?{}:{badge:e.badge,facet:e.badge}},draggable:!1,zIndex:M.leaf,width:n.width,height:n.height,style:{width:n.width,height:n.height}}),c.push(U(e.id,`element:${i}`,i,1))})}else{let t=N.unit,n=Ge(r.units.length);r.units.forEach((e,r)=>{let i=n[r]??0;s.push({id:`unit:${e.unit}`,type:`unitChip`,position:R(i,j.spokeRing,t),data:{kind:`unit`,label:e.unit,refId:e.unit,badge:String(e.flowCount),elements:e.elements.filter(e=>e!==`flow`),live:e.live,errors:e.errors},draggable:!1,zIndex:M.leaf,width:t.width,height:t.height,style:{width:t.width,height:t.height}})});let a=new Map;for(let t of Object.keys(e.flows??{}).sort()){let e=F(t),n=a.get(e)??[];n.push(t),a.set(e,n)}for(let t of r.units){let n=new Map,r=new Set;for(let o of a.get(t.unit)??[]){let t=e.flows?.[o];if(t)for(let a of B(t)){if(i===`flow`&&a!==`flow`)continue;let o=it(e,t,a);o.length===0&&r.add(a);for(let e of o)n.set(e,(n.get(e)??0)+1)}}for(let[e,r]of n){let n=e.slice(5).split(`:`)[0];n&&n in P&&c.push(U(`unit:${t.unit}`,e,n,r))}for(let e of r)c.push(U(`unit:${t.unit}`,`element:${e}`,e,1))}}return{nodes:s,edges:c,units:r.units,hubs:r.hubs}}function V(e,t){let n=t*2;return{id:e,type:`orbit`,position:{x:j.cx-t,y:j.cy-t},data:{kind:`law`,label:``,refId:e},selectable:!1,draggable:!1,zIndex:M.edge,width:n,height:n,style:{width:n,height:n}}}function ct(e,t){return t===`law:oke`?`trunk`:e.startsWith(`type:`)&&t.startsWith(`element:`)?`bind`:`spoke`}function H(e){return e===`trunk`?.14:e===`bind`?.2:0}function U(e,t,n,r,i=!1){let a=i?`trunk`:ct(e,t),o=a===`trunk`?1.15:1+Math.min(1.25,Math.log2(1+r)*.45);return{id:`couple:${e}->${t}`,source:e,target:t,sourceHandle:`center`,targetHandle:`center`,type:`straight`,data:{kind:`couple`},style:{stroke:Ce.couple,strokeWidth:o,opacity:H(a)},zIndex:M.edge}}function lt(e){if(e.startsWith(`element:`)){let t=e.slice(8);return t in P?t:null}if(e.startsWith(`type:`)){let t=e.slice(5).split(`:`)[0];return t&&t in P?t:null}return null}function ut(e,t){for(let n of[t,e]){let e=lt(n);if(e)return P[e].accent}return Ce.couple}function dt(e,t){let n=new Set,r=new Set,i=(e,t)=>{r.add(`couple:${e}->${t}`)};if(!e)return{nodeIds:n,edgeIds:r};for(let r of t){let t=e.flows?.[r];if(!t)continue;let a=`unit:${F(r)}`;n.add(a);for(let r of B(t)){let o=`element:${r}`;n.add(o),n.add(`law:oke`),i(o,`law:oke`);let s=it(e,t,r);s.length===0&&i(a,o);for(let e of s)n.add(e),i(a,e),i(e,o)}}return{nodeIds:n,edgeIds:r}}function ft(e,t,n={}){let r=n.hoverNodeId??null,i=n.highlightedFlowIds??new Set,a=n.highlightedNodeIds??new Set,o=dt(n.manifest,i),s=o.nodeIds.size>0||a.size>0,c=r!=null,l=r==null?null:pt(r,t);return{nodes:e.map(e=>{if(e.type===`orbit`)return{...e,data:{...e.data,highlighted:!1,dimmed:!1}};let t=o.nodeIds.has(e.id)||a.has(e.id)||i.has(e.data.refId),n=l?.has(e.id)===!0;return{...e,data:{...e.data,highlighted:t||c&&e.id===r,dimmed:e.id===`law:oke`?!1:s&&!t||c&&!n}}}),edges:t.map(e=>{let t=l!=null&&l.has(e.source)&&l.has(e.target),n=s&&o.edgeIds.has(e.id),r=c?t:n,i=ct(e.source,e.target),a=c||s?r?1:H(i)*.35:H(i);return{...e,animated:r,style:{...e.style,stroke:r?ut(e.source,e.target):Ce.couple,opacity:a,strokeWidth:r?2.25:e.style?.strokeWidth}}})}}function W(e,t){let n=[];for(let r of e)r.source===t?n.push(r.target):r.target===t&&n.push(r.source);return n}function pt(e,t){let n=new Set([e]),r=e=>n.add(e);if(e.startsWith(`unit:`)){for(let n of W(t,e)){if(r(n),n.startsWith(`type:`)){for(let e of W(t,n))if(e.startsWith(`element:`)){r(e);for(let n of W(t,e))n===`law:oke`&&r(n)}}if(n.startsWith(`element:`))for(let e of W(t,n))e===`law:oke`&&r(e)}return n}if(e.startsWith(`type:`)){for(let n of W(t,e))r(n);let i=[...n].find(e=>e.startsWith(`element:`));if(i)for(let e of W(t,i))e===`law:oke`&&r(e);return n}if(e.startsWith(`element:`)||e===`law:oke`)for(let n of W(t,e))r(n);return n}var G=n(),mt={flow:A.flow.icon,signal:A.signal.icon,store:A.store.icon,clock:A.clock.icon,gate:A.gate.icon,vault:A.vault.icon,channel:A.channel.icon,ai:A.ai.icon},ht={flow:`rounded-xl`,store:`rounded-md`,signal:`rounded-full`,clock:`rounded-lg`,gate:`rounded-md`,vault:`rounded-md`,channel:`rounded-xl`,ai:`rounded-2xl`};function K(e,t){return m(`group relative flex h-full w-full items-center gap-2.5 border-2 px-2.5 text-xs transition-[opacity,filter,box-shadow,border-color] duration-200`,ht[t],e.dimmed&&`opacity-30 saturate-[0.35]`,e.highlighted&&`z-10`,e.focused&&`z-10`)}function q(e,t){let n=P[e],r=`color-mix(in oklab, ${n.accent} 20%, var(--card))`;return t.highlighted||t.focused?{borderColor:n.accent,background:`color-mix(in oklab, ${n.accent} 26%, var(--card))`,boxShadow:`0 0 0 1px ${n.accent}, 0 0 22px ${n.glow}`}:{borderColor:`color-mix(in oklab, ${n.accent} 78%, var(--border))`,background:r,boxShadow:`inset 3px 0 0 ${n.accent}`}}function J({data:e,kind:t,className:n,style:r,children:i,...a}){let o=Pe(),s=P[t];return(0,G.jsx)(Ne.div,{className:n,style:r,initial:!1,whileHover:o?void 0:{scale:1.04},whileTap:o?void 0:{scale:.97},animate:{scale:o?1:e.active?[1,1.08,1]:e.highlighted?1.02:1,boxShadow:e.active?`0 0 0 2px ${s.accent}, 0 0 30px ${s.glow}`:void 0},transition:e.active?{duration:.5,ease:`easeInOut`}:{type:`spring`,stiffness:400,damping:28},...a,children:i})}function gt({kind:e,size:t=`sm`}){let n=P[e];return(0,G.jsx)(`span`,{className:m(`flex shrink-0 items-center justify-center border`,t===`md`?`size-9`:`size-7`,e===`signal`?`rounded-full`:e===`store`||e===`gate`||e===`vault`?`rounded-md`:`rounded-full`),style:{color:n.accent,background:n.well,borderColor:`color-mix(in oklab, ${n.accent} 55%, transparent)`},"aria-hidden":!0,children:(0,G.jsx)(f,{icon:mt[e],size:t===`md`?17:15,strokeWidth:1.9})})}function _t({text:e}){return(0,G.jsx)(`span`,{className:`rounded border border-border/70 bg-background/50 px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:e})}function vt({type:e,kind:t}){let n=P[t];return(0,G.jsx)(r,{type:e,position:e===`source`?s.Right:s.Left,className:`!size-2 !border-0`,style:{background:n.accent}})}function Y({type:e}){return(0,G.jsx)(r,{id:`center`,type:e,position:e===`source`?s.Right:s.Left,isConnectable:!1,className:`oke-center-handle !top-1/2 !left-1/2 !size-px !-translate-x-1/2 !-translate-y-1/2 !border-0 !bg-transparent !opacity-0`})}function yt({live:e,errors:t}){return e<=0?null:(0,G.jsx)(`span`,{className:m(`size-2 shrink-0 rounded-full`,t>0?`bg-rose-400`:`bg-emerald-400`,e>0&&`animate-pulse`),title:t>0?`${e} live · ${t} failed`:`${e} live`})}function bt({elements:e}){return e.length===0?null:(0,G.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1`,"aria-hidden":!0,children:e.map(e=>(0,G.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:P[e].accent},title:A[e].label},e))})}function xt({data:e}){return(0,G.jsx)(`div`,{className:`h-full w-full rounded-xl border border-dashed border-foreground/25 bg-muted/35 px-3 pt-1.5`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:e.label}),e.badge?(0,G.jsx)(_t,{text:e.badge}):null]})})}function St({data:e}){let t=e.kind in P?e.kind:`flow`;return(0,G.jsxs)(J,{data:e,kind:t,className:m(K(e,t),`justify-center gap-0 rounded-full px-2`),style:q(t,e),"data-slot":`type-chip`,"data-type":e.refId,children:[(0,G.jsx)(Y,{type:`source`}),(0,G.jsx)(Y,{type:`target`}),(0,G.jsx)(`div`,{className:`min-w-0 truncate text-center text-[10px] leading-none font-medium tracking-wide text-foreground`,children:e.label})]})}function Ct({data:e}){return(0,G.jsxs)(J,{data:e,kind:`flow`,className:m(K(e,`flow`),`rounded-full px-2.5`),style:q(`flow`,e),"data-slot":`unit-chip`,"data-unit":e.refId,children:[(0,G.jsx)(Y,{type:`source`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`div`,{className:`truncate font-medium tracking-wide text-foreground uppercase`,children:e.label}),(0,G.jsx)(yt,{live:e.live??0,errors:e.errors??0})]}),(0,G.jsx)(bt,{elements:e.elements??[]})]}),e.badge?(0,G.jsx)(_t,{text:e.badge}):null]})}function wt({data:e}){let t=Ot(e.refId)??`flow`,n=P[t];return(0,G.jsxs)(J,{data:e,kind:t,className:m(K(e,t),`flex-col justify-center gap-0.5 rounded-full px-1.5 text-center`),style:{...q(t,e),boxShadow:e.highlighted?`0 0 0 1px ${n.accent}, 0 0 22px ${n.glow}`:`0 0 0 1px color-mix(in oklab, ${n.accent} 55%, transparent)`},"data-slot":`element-hub`,"data-element":t,children:[(0,G.jsx)(Y,{type:`target`}),(0,G.jsx)(Y,{type:`source`}),(0,G.jsx)(`span`,{className:`text-[18px] font-semibold tracking-tight text-foreground`,title:A[t].label,children:e.label})]})}function Tt(e){return e>=40?1.05:e>=12?1.55:2.2}function Et({data:e}){let t=Pe(),n=e.live??0,r=e.errors??0,[i,a]=(0,I.useState)(0),o=(0,I.useRef)(n);(0,I.useEffect)(()=>{n>o.current&&a(e=>e+1),o.current=n},[n]);let s=n>0,c=Tt(n),l=r>0?`var(--color-rose-400)`:`var(--foreground)`;return(0,G.jsxs)(`div`,{className:m(`relative flex h-full w-full items-center justify-center overflow-visible`,e.highlighted&&`z-10`),"data-slot":`law-hub`,"data-live":n,children:[(0,G.jsx)(Y,{type:`target`}),!t&&s?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-ripple`,style:{animationDuration:`${c}s`,color:l}}),(0,G.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-ripple`,style:{animationDuration:`${c}s`,animationDelay:`${c/2}s`,color:l}})]}):null,i>0&&!t?(0,G.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-hit`,style:{color:l}},i):null,(0,G.jsx)(Ne.div,{className:`flex h-full w-full items-center justify-center rounded-full border-4 bg-card px-4 text-center`,style:{borderColor:`color-mix(in oklab, var(--foreground) 82%, var(--border))`,boxShadow:e.highlighted?`0 0 0 1px ${l}, 0 0 36px color-mix(in oklab, ${l} 28%, transparent)`:`inset 0 0 28px color-mix(in oklab, var(--foreground) 7%, transparent), 0 0 22px color-mix(in oklab, ${l} ${s?16:6}%, transparent)`},animate:t||!s?{scale:1}:{scale:[1,1.045,1]},transition:t||!s?{duration:0}:{duration:c,repeat:1/0,ease:`easeInOut`},children:(0,G.jsx)(Me,{className:`h-7 w-auto text-foreground`})})]})}function Dt(){return(0,G.jsx)(`div`,{className:`pointer-events-none h-full w-full rounded-full border border-dashed border-foreground/15`,"data-slot":`orbit`})}function Ot(e){return e in P?e:null}function X({data:e,kind:t,slot:n}){return(0,G.jsxs)(J,{data:e,kind:t,className:K(e,t),style:q(t,e),"data-slot":n,"data-flow-id":t===`flow`?e.refId:void 0,"data-highlighted":e.highlighted?`true`:`false`,children:[(0,G.jsx)(vt,{type:`target`,kind:t}),(0,G.jsx)(Y,{type:`source`}),(0,G.jsx)(gt,{kind:t}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate font-medium text-foreground`,children:e.label}),(0,G.jsx)(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:(0,G.jsx)(_t,{text:e.badge??e.plane??e.facet??t})})]}),t===`flow`||t===`signal`?(0,G.jsx)(vt,{type:`source`,kind:t}):null]})}function kt({data:e}){return(0,G.jsx)(X,{data:e,kind:`flow`,slot:`flow-node`})}function At({data:e}){return(0,G.jsx)(X,{data:e,kind:`store`,slot:`store-node`})}function jt({data:e}){return(0,G.jsx)(X,{data:e,kind:`signal`,slot:`signal-node`})}function Mt({data:e}){return(0,G.jsx)(X,{data:e,kind:`ai`,slot:`ai-node`})}function Nt({data:e}){return(0,G.jsx)(X,{data:e,kind:`clock`,slot:`clock-node`})}function Pt({data:e}){return(0,G.jsx)(X,{data:e,kind:`gate`,slot:`gate-node`})}function Ft({data:e}){return(0,G.jsx)(X,{data:e,kind:`vault`,slot:`vault-node`})}function It({data:e}){return(0,G.jsx)(X,{data:e,kind:`channel`,slot:`channel-node`})}var Lt={unit:xt,unitChip:Ct,typeChip:St,element:wt,law:Et,orbit:Dt,flow:kt,store:At,signal:jt,ai:Mt,clock:Nt,gate:Pt,vault:Ft,channel:It};function Rt(e,t){let n=e.flows??{},r=new Set;if(t.kind===`unit`){for(let e of Object.keys(n))F(e)===t.unit&&r.add(e);let e=[];for(let t of r)for(let r of n[t]?.effects?.calls??[])ve(r)||e.push(r);for(let t of e)r.add(t)}else if(t.kind===`flow`){r.add(t.flowId);let e=n[t.flowId];for(let t of e?.effects?.calls??[])ve(t)||r.add(t);for(let[e,i]of Object.entries(n))i.effects?.calls?.includes(t.flowId)&&r.add(e)}else for(let[e,i]of Object.entries(n))zt(i,e,t.nodeId)&&r.add(e);let i={};for(let e of r){let t=n[e];t&&(i[e]=t)}return{...e,flows:i}}function zt(e,t,n){if(n===`flow:${t}`||n===`clock:${t}`&&(e.trigger?.cron||e.trigger?.every)||e.trigger?.signal&&n===`signal:${e.trigger.signal}`||e.gates?.some(e=>n===`gate:${e}`))return!0;let r=e.effects;return r?!!(r.reads?.some(e=>e===n)||r.writes?.some(e=>e===n)||r.emits?.some(e=>n===`signal:${e}`)||r.sends?.some(e=>n===`channel:${e}`)||r.asks?.some(e=>n===`ai:${e}`)||r.secrets?.some(e=>n===`vault:${e}`)||r.calls?.some(e=>{let t=ve(e);return t?n===ye(t.server):n===`flow:${e}`})):!1}var Bt=[`!=`,`>=`,`<=`,`=`,`>`,`<`],Vt={clauses:[]},Ht=[`flow`,`unit`,`trigger`,`plane`,`tenant`,`principal`,`cache`,`replica`,`error`,`buildVersion`,`promptVersion`,`duration`];function Ut(e){if(!e||!e.trim())return Vt;let t=e.split(/\s+AND\s+/i).map(e=>e.trim()).filter(Boolean),n=[];for(let e of t){let t=en(e);t&&n.push(t)}return{clauses:n}}function Z(e,t){return{clauses:[...e.clauses.filter(e=>e.dimension!==t.dimension),t]}}function Wt(e,t){return{clauses:e.clauses.filter(e=>e.dimension!==t)}}function Gt(e,t){return e.dimension===t.dimension&&e.op===t.op&&e.value===t.value}function Kt(e,t){return e.clauses.some(e=>Gt(e,t))}function qt(e,t){return Kt(e,t)?Wt(e,t.dimension):Z(e,t)}function Jt(e){let t=rn(e.dimension,e.value);return`${e.dimension} ${e.op} ${t}`}function Yt(e,t){for(let n of t.clauses)if(!an(e,n))return!1;return!0}function Xt(e,t){return t.clauses.length===0?[...e]:e.filter(e=>Yt(e,t))}function Zt(e){let t=/^(-?\d+(?:\.\d+)?)\s*(ms|s|m)?$/i.exec(e.trim());if(!t)return;let n=Number(t[1]),r=(t[2]??`ms`).toLowerCase();if(r===`ms`)return n;if(r===`s`)return n*1e3;if(r===`m`)return n*6e4}function Qt(e,t){switch(t){case`flow`:return e.flow;case`unit`:return e.unit??null;case`trigger`:return e.trigger;case`plane`:return e.plane;case`tenant`:return e.tenant??null;case`principal`:return e.principal??null;case`cache`:return e.cache;case`replica`:return e.replica??null;case`replicaLagMs`:case`replica_lag_ms`:return e.replicaLagMs??null;case`error`:case`error_code`:return e.error??null;case`buildVersion`:case`build_version`:return e.buildVersion??null;case`promptVersion`:case`prompt_version`:return e.promptVersion??null;case`cost`:return e.cost??null;case`duration`:case`duration_ms`:return e.durationMs;case`gates`:return e.gates.join(`,`);default:return e.dimensions[t]}}function $t(e){let t=new Set(Ht);for(let n of e)for(let e of Object.keys(n.dimensions))t.add(e);return[...t].sort()}function en(e){let t=null,n=-1;for(let r of Bt){let i=e.indexOf(` ${r} `);if(i!==-1){t=r,n=i;break}}if(t===null||n<0)return null;let r=e.slice(0,n).trim(),i=e.slice(n+t.length+2).trim();if(!r||!i)return null;let a=tn(r,i);return a===void 0?null:{dimension:r,op:t,value:a}}function tn(e,t){return e===`duration`||e===`duration_ms`?Zt(t):t===`true`?!0:t===`false`?!1:t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):/^-?\d+(\.\d+)?$/.test(t)?Number(t):t}function nn(e,t){return rn(e,t)}function rn(e,t){if(e===`duration`||e===`duration_ms`){let e=typeof t==`number`?t:Number(t);return Number.isFinite(e)?e>=6e4&&e%6e4==0?`${e/6e4}m`:e>=1e3&&e%1e3==0?`${e/1e3}s`:`${e}ms`:String(t)}return typeof t==`string`&&/\s/.test(t)?`"${t}"`:String(t)}function an(e,t){let n=Qt(e,t.dimension);if(n==null)return t.op===`!=`;let r=t.value;if(t.op===`=`)return on(n,r);if(t.op===`!=`)return!on(n,r);let i=Q(n),a=Q(r);return i===void 0||a===void 0?!1:t.op===`>`?i>a:t.op===`<`?i<a:t.op===`>=`?i>=a:t.op===`<=`&&i<=a}function on(e,t){if(typeof e==`number`||typeof t==`number`){let n=Q(e),r=Q(t);if(n!==void 0&&r!==void 0)return n===r}return String(e)===String(t)}function Q(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`boolean`)return;let t=Number(e);return Number.isFinite(t)?t:void 0}var sn=new Set(Object.keys(A));function cn(e){if(e.startsWith(`flow:`))return{kind:`flow`,flowId:e.slice(5)};if(e.startsWith(`signal:`))return{kind:`signal`,signal:e.slice(7)};if(e.startsWith(`unit:`))return{kind:`unit`,unit:e.slice(5)};if(e.startsWith(`element:`)){let t=e.slice(8);return sn.has(t)?{kind:`element`,element:t}:null}if(e.startsWith(`type:`)){let t=e.slice(5).split(`:`)[0];return t&&sn.has(t)?{kind:`element`,element:t}:null}return e.startsWith(`sql:`)||e.startsWith(`kv:`)||e.startsWith(`files:`)||e.startsWith(`index:`)||e.startsWith(`vault:`)||e.startsWith(`channel:`)||e.startsWith(`gate:`)||e.startsWith(`clock:`)||e.startsWith(`ai:`)?{kind:`resource`,nodeId:e}:null}function ln(e){switch(e.kind){case`flow`:return e.flowId;case`signal`:return`signal:${e.signal}`;case`unit`:return e.unit;case`element`:return A[e.element].label;case`resource`:return e.nodeId}}function un(e,t){return t?.kind===`flow`?Z(e,{dimension:`flow`,op:`=`,value:t.flowId}):t?.kind===`unit`?Z(e,{dimension:`unit`,op:`=`,value:t.unit}):e}function dn(e,t,n){if(t.kind===`flow`)return Yt(e,{clauses:[{dimension:`flow`,op:`=`,value:t.flowId}]});if(t.kind===`unit`)return(e.unit??F(e.flow))===t.unit;if(t.kind===`element`)return t.element===`flow`||Xe(e).includes(t.element);if(t.kind===`resource`)return fn(e,t.nodeId,n);let r=n?.flows??{};for(let[n,i]of Object.entries(r))if(n===e.flow&&(i.trigger?.signal===t.signal||i.effects?.emits?.includes(t.signal)))return!0;return!1}function fn(e,t,n){let r=t.includes(`:`)?t.slice(t.indexOf(`:`)+1):t;if(e.effects.some(e=>e.resource===t||e.resource===r)||e.gates.some(e=>t===`gate:${e}`))return!0;let i=n?.flows?.[e.flow];return!!(i&&zt(i,e.flow,t))}function pn(e,t,n){return t?e.filter(e=>dn(e,t,n)):[...e]}function mn(e){return e?e.kind===`unit`||e.kind===`flow`||e.kind===`resource`?e:e.kind===`signal`?{kind:`resource`,nodeId:`signal:${e.signal}`}:null:null}function hn({manifest:e,runs:t=[],graphFilter:n,highlightedFlowIds:r,highlightedNodeIds:s,follow:l,activeNodeId:d=null,focusedNodeId:f=null,orchestraLabel:p=null,onNodeClick:m,onPaneClick:h}){let{fitView:g}=a(),{theme:_}=Fe(),[v,y]=(0,I.useState)(null),b=_===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:_,x=mn(n),S=n?.kind===`element`?n.element:null,C=x===null,w=(0,I.useMemo)(()=>st(e,t,S?{kind:`element`,element:S}:null),[e,t,S]),T=(0,I.useMemo)(()=>Be(!x||!e?e:Rt(e,x)),[e,x]),E=(0,I.useMemo)(()=>ft(w.nodes,w.edges,{hoverNodeId:v,highlightedFlowIds:r,highlightedNodeIds:s,manifest:e}),[w.nodes,w.edges,v,r,s,e]),D=(0,I.useMemo)(()=>Re(T.nodes,r,s,{activeNodeId:d,focusedNodeId:f}),[T.nodes,r,s,d,f]),O=(0,I.useMemo)(()=>Le(T.edges,D),[T.edges,D]),k=C?E.nodes:D,ee=C?E.edges:O;return(0,I.useEffect)(()=>{g({duration:280,padding:.18})},[C,n,e,g]),(0,I.useEffect)(()=>{if(!l||C||r.size===0)return;let e=[...r].map(e=>`flow:${e}`);g({nodes:e.map(e=>({id:e})),duration:300,padding:.2})},[l,C,r,g]),(0,G.jsxs)(`div`,{className:`relative h-full w-full`,children:[n?(0,G.jsxs)(`button`,{type:`button`,"data-slot":`flow-graph-map`,onClick:()=>h?.(),className:`absolute top-2 left-2 z-10 inline-flex max-w-[min(100%-1rem,20rem)] items-center gap-1.5 truncate rounded-md border border-border/70 bg-card/90 px-2 py-1 text-[10px] font-medium text-muted-foreground shadow-sm backdrop-blur-sm transition-colors hover:border-border hover:text-foreground`,children:[(0,G.jsx)(`span`,{className:`text-foreground`,children:`Map`}),(0,G.jsx)(`span`,{"aria-hidden":!0,children:`/`}),(0,G.jsx)(`span`,{className:`truncate`,children:ln(n)})]}):(0,G.jsx)(`div`,{className:`pointer-events-none absolute top-2 left-2 z-10 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:p?(0,G.jsxs)(G.Fragment,{children:[`Orchestra `,(0,G.jsx)(`span`,{className:`text-foreground normal-case`,children:p})]}):`Hover a unit — spokes light the elements it touches`}),(0,G.jsxs)(i,{nodes:k,edges:ee,nodeTypes:Lt,colorMode:b,fitView:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,proOptions:{hideAttribution:!0},minZoom:.15,maxZoom:1.6,defaultEdgeOptions:{type:`smoothstep`,zIndex:M.edge},zIndexMode:`manual`,onNodeClick:(e,t)=>m?.(t.id),onPaneClick:()=>h?.(),onNodeMouseEnter:(e,t)=>y(t.id),onNodeMouseLeave:()=>y(null),children:[(0,G.jsx)(u,{gap:24,size:1,color:`color-mix(in oklab, var(--foreground) 14%, transparent)`}),(0,G.jsx)(c,{showInteractive:!1}),(0,G.jsx)(o,{pannable:!0,zoomable:!0,ariaLabel:`Flow graph overview`,bgColor:`var(--card)`,maskColor:`color-mix(in oklab, var(--background) 55%, transparent)`,nodeColor:gn,nodeStrokeColor:_n,nodeStrokeWidth:12,nodeBorderRadius:10})]})]})}function gn(e){if(e.type===`orbit`)return`transparent`;let t=e.data.kind;if(t===`law`)return`color-mix(in oklab, var(--foreground) 45%, transparent)`;if(t===`unit`)return`color-mix(in oklab, var(--foreground) 8%, transparent)`;if(t===`element`){let t=e.data.refId;return P[t]?.accent??`#64748B`}return t in P?P[t].accent:`#64748B`}function _n(e){return e.data.kind===`unit`?`color-mix(in oklab, var(--foreground) 32%, transparent)`:`transparent`}function vn(e){let{leading:t,...n}=e;return(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col`,"data-slot":`flow-graph`,children:[t?(0,G.jsxs)(`header`,{className:w,children:[t,(0,G.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0})]}):null,(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,G.jsx)(l,{children:(0,G.jsx)(hn,{...n})})})]})}var yn=`orch-`;function bn(e){return e.startsWith(yn)}function xn(e,t){return e&&t}function Sn(e,t=Math.random){let n=e.filter(e=>!bn(e.id)&&e.flow.length>0);return n.length===0?null:n[Math.floor(t()*n.length)]??null}function Cn(e,t,n){let r=t-e.startedAt,i=e.flow.replaceAll(`.`,`-`);return{...e,id:`${yn}${n}-${i}`,parentId:null,startedAt:t,endedAt:t+e.durationMs,effects:e.effects.map(e=>({...e,timestamp:e.timestamp+r})),logs:e.logs.map(e=>({...e,at:e.at+r}))}}function wn(e=Math.random){return 1800+Math.floor(e()*1600)}var Tn=1400;function En(e){let t=S(),[n,r]=(0,I.useState)(null),i=(0,I.useRef)(0),a=(0,I.useRef)(null),o=(0,I.useRef)(null),s=(0,I.useRef)(e.paused);return s.current=e.paused,(0,I.useEffect)(()=>{if(!xn(!1,e.enabled))return;let n=()=>{a.current&&=(clearTimeout(a.current),null)},c=()=>{if(s.current||document.hidden)return;let e=Sn(t.getQueryData(ge)??[]);if(!e)return;i.current+=1;let o=Cn(e,Date.now(),i.current);t.setQueryData(ge,e=>he(e??[],o)),r({flowId:o.flow,runId:o.id}),n(),a.current=setTimeout(()=>{r(null),a.current=null},Tn)},l=e=>{o.current=setTimeout(()=>{c(),l(wn())},e)};l(700);let u=()=>{document.hidden&&(r(null),n())};return document.addEventListener(`visibilitychange`,u),()=>{document.removeEventListener(`visibilitychange`,u),o.current&&clearTimeout(o.current),n(),r(null)}},[e.enabled,t]),e.paused?null:n}function Dn(e,t){let n=new Set;if(!t)return n;let r=new Map,i=new Map;for(let t of e)r.set(t.id,t);for(let t of e){if(!t.parentId)continue;let e=i.get(t.parentId)??[];e.push(t),i.set(t.parentId,e)}let a=r.get(t);if(!a)return n;let o=a,s=new Set;for(;o&&!s.has(o.id);)s.add(o.id),n.add(o.flow),o=o.parentId?r.get(o.parentId):void 0;let c=[a];for(;c.length>0;){let e=c.shift();if(!e)break;for(let t of i.get(e.id)??[])s.has(t.id)||(s.add(t.id),n.add(t.flow),c.push(t))}return n}var On=[{id:`signal`,label:`Signal`,expr:`trigger = signal`},{id:`clock`,label:`Clock`,expr:`trigger = cron`},{id:`cache-miss`,label:`Cache miss`,expr:`cache = miss`},{id:`slow`,label:`Slow`,expr:`duration > 100ms`}],kn=`h-7 min-w-0 rounded-none border-0 bg-transparent px-0 font-mono text-[11px] text-foreground shadow-none outline-none focus-visible:ring-0 dark:bg-transparent`,$=`rounded-none border-0 bg-transparent px-1.5 py-1 text-[11px] text-foreground/70 shadow-none transition-colors hover:bg-muted/50 hover:text-foreground`,An=`grid grid-cols-[minmax(0,1fr)_1.25rem_minmax(0,1fr)_1.25rem] items-center gap-x-1`;function jn({query:e,runs:t,onChange:n}){let r=(0,I.useMemo)(()=>$t(t),[t]),i=(0,I.useMemo)(()=>[...new Set([...Ht,...r])].sort(),[r]),[a,o]=(0,I.useState)(`trigger`),[s,c]=(0,I.useState)(`=`),[l,u]=(0,I.useState)(`signal`),[d,f]=(0,I.useState)(!1),h=()=>{let t=Ut(`${a} ${s} ${l}`).clauses[0];t&&(n(Z(e,t)),f(!1))};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-b border-border/60 px-2 py-1.5`,"data-slot":`traces-advanced-filters`,children:[e.clauses.length>0?(0,G.jsx)(`ul`,{"aria-label":`Active filters`,className:`flex flex-col gap-0.5`,children:e.clauses.map(t=>(0,G.jsx)(`li`,{children:(0,G.jsx)(Mn,{clause:t,onRemove:()=>n(Wt(e,t.dimension))})},t.dimension))}):null,d?(0,G.jsxs)(`div`,{className:An,"data-slot":`traces-advanced-composer`,children:[(0,G.jsx)(`select`,{"aria-label":`Filter dimension`,className:kn,value:a,onChange:e=>o(e.target.value),children:i.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsx)(`select`,{"aria-label":`Filter operator`,className:m(kn,`text-center text-foreground/70`),value:s,onChange:e=>c(e.target.value),children:[`=`,`!=`,`>`,`<`,`>=`,`<=`].map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsx)(p,{"aria-label":`Filter value`,flat:!0,className:`h-7 px-0 font-mono text-[11px]`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&h()}}),(0,G.jsx)(`button`,{type:`button`,className:$,onClick:h,children:`Add`})]}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[On.map(t=>{let r=Ut(t.expr).clauses[0],i=r!==void 0&&Kt(e,r);return(0,G.jsx)(`button`,{type:`button`,"aria-pressed":i,disabled:r===void 0,onClick:()=>{r&&n(qt(e,r))},className:m($,i?`font-medium text-foreground`:`text-foreground/70`),children:t.label},t.id)}),(0,G.jsx)(`button`,{type:`button`,"aria-expanded":d,className:m($,`ml-auto`,d&&`text-foreground`),onClick:()=>f(e=>!e),children:d?`Cancel`:`Add clause`}),e.clauses.length>0?(0,G.jsx)(`button`,{type:`button`,className:$,onClick:()=>n(Ut(``)),children:`Clear`}):null]})]})}function Mn({clause:e,onRemove:t}){let n=Jt(e);return(0,G.jsxs)(`div`,{className:An,"data-slot":`traces-advanced-clause`,children:[(0,G.jsx)(`span`,{className:`truncate font-mono text-[11px] text-foreground/80`,children:e.dimension}),(0,G.jsx)(`span`,{className:`text-center font-mono text-[11px] text-foreground/65`,"aria-hidden":!0,children:e.op}),(0,G.jsx)(`span`,{className:`truncate font-mono text-[11px] text-foreground`,children:nn(e.dimension,e.value)}),(0,G.jsx)(`button`,{type:`button`,className:m($,`flex size-5 items-center justify-center text-foreground/55 hover:text-destructive`),"aria-label":`Remove ${n}`,onClick:t,children:(0,G.jsx)(f,{icon:C,className:`size-3`})})]})}var Nn={query:``,status:`all`,advanced:Vt};function Pn(e,t){let n=t.trim().toLowerCase();return!n||[e.flow,e.unit??``,e.trigger,e.cache,e.id,e.error??``,e.errorMessage??``].some(e=>e.toLowerCase().includes(n))}function Fn(e,t){return Xt(e.filter(e=>!(!Pn(e,t.query)||t.status===`errors`&&e.error===null)),t.advanced)}function In(e,t=Date.now()){let n=t-e;return n<1e3?`just now`:n<6e4?`${Math.floor(n/1e3)}s ago`:n<36e5?`${Math.floor(n/6e4)}m ago`:`${Math.floor(n/36e5)}h ago`}function Ln(e,t=Date.now()){let n=In(e.startedAt,t),r=e.error!==null;return{text:n,title:r?e.errorMessage?`${e.error} — ${e.errorMessage}`:e.error??n:n,failed:r}}function Rn({run:e,selected:t,onSelect:n,copyText:r=async e=>{await navigator.clipboard.writeText(e)}}){let i=Ln(e),a=i.failed,o=Oe(e.trigger),s=e.cache,[c,l]=(0,I.useState)(null),u=async t=>{t.stopPropagation();try{await r(Ae(e)),l(`Copied run id`)}catch{l(`Copy failed`)}};return(0,G.jsxs)(`div`,{"data-slot":`trace-row`,"data-run-id":e.id,"data-selected":t?`true`:`false`,"data-failed":a?`true`:`false`,"data-cache":e.cache,className:m(`group relative flex w-full items-stretch border-b border-border/60 text-xs transition-colors`,`hover:bg-muted/50 focus-within:bg-muted/50`,t&&`bg-muted/70`,a&&`bg-destructive/[0.04]`),children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:m(`absolute inset-y-0 left-0 w-0.5`,t&&!a&&`bg-sky-500`,a&&`bg-destructive`)}),(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>n(e.id),className:`flex min-w-0 flex-1 items-center gap-2 py-1.5 pr-1 pl-0 text-left outline-none`,children:[(0,G.jsx)(`span`,{className:m(`ml-2.5 size-1.5 shrink-0 rounded-full`,a?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,title:o.label,"aria-hidden":!0,children:(0,G.jsx)(f,{icon:o.icon,className:`size-3.5`})}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.flow}),(0,G.jsx)(He,{cache:s,dataSlot:`trace-row-cache`}),(0,G.jsx)(`span`,{className:m(`w-10 shrink-0 text-right tabular-nums font-medium`,de(e.durationMs)),children:me(e.durationMs)}),(0,G.jsx)(`span`,{className:`w-14 shrink-0 truncate text-right tabular-nums text-muted-foreground`,title:i.title,"data-slot":`trace-row-meta`,children:i.text})]}),(0,G.jsx)(`div`,{className:m(`flex shrink-0 items-center gap-0.5 pr-1.5 opacity-0 transition-opacity`,`group-hover:opacity-100 group-focus-within:opacity-100`,c&&`opacity-100`),children:(0,G.jsxs)(h,{children:[(0,G.jsx)(_,{render:e=>(0,G.jsx)(T,{...e,type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Copy run ID`,"data-slot":`trace-copy-id`,onClick:t=>{e.onClick?.(t),u(t)},children:(0,G.jsx)(f,{icon:k,className:`size-3`})})}),(0,G.jsx)(g,{side:`top`,children:`Copy run ID`})]})}),c?(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,children:c}):null]})}var zn=[{value:`all`,label:`All`,icon:We},{value:`errors`,label:`Errors`,icon:ue}];function Bn({runs:e,selectedRunId:t,onSelect:n,liveStatus:r,manifest:i,graphFilter:a,onGraphFilterChange:o,focusEffectIndex:s,onFocusEffectChange:c,playbackKey:l,onReplayStart:u,selectedRun:p}){let[v,x]=(0,I.useState)(Nn),[S,C]=(0,I.useState)(!1);(0,I.useEffect)(()=>{(a?.kind===`flow`||a?.kind===`unit`)&&x(e=>({...e,advanced:un(e.advanced,a)}))},[a]);let T=(0,I.useMemo)(()=>pn(Fn(e,v),a,i),[e,v,a,i]),O=(0,I.useMemo)(()=>p===void 0?t?e.find(e=>e.id===t)??null:null:p,[p,e,t]),k=v.advanced.clauses.length>0,re=e=>{x(t=>({...t,query:e}))},ae=e=>{x(t=>({...t,status:e}))};return(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`traces-pane`,children:[(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-border/60`,children:[(0,G.jsxs)(`div`,{className:m(d,`border-b-0`),children:[(0,G.jsx)(ee,{value:v.query,onChange:e=>re(e.target.value),placeholder:`Search traces…`,"aria-label":`Search traces`,"data-slot":`traces-search`}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-stretch pr-0.5`,children:[e.length>0?(0,G.jsxs)(h,{children:[(0,G.jsx)(_,{render:e=>(0,G.jsxs)(`button`,{...e,type:`button`,"aria-expanded":S,"aria-controls":`traces-advanced-panel`,"aria-label":k?`Advanced filters, ${v.advanced.clauses.length} active`:`Advanced filters`,"data-slot":`traces-advanced-toggle`,onClick:t=>{e.onClick?.(t),C(e=>!e)},className:m(b,`relative`,(S||k)&&`text-foreground`),children:[(0,G.jsx)(f,{icon:Te,className:`size-3`,"aria-hidden":!0}),k?(0,G.jsx)(`span`,{className:`absolute -top-0.5 -inset-e-0.5 flex size-3.5 items-center justify-center rounded-full bg-foreground text-[8px] font-medium text-background`,"aria-hidden":!0,children:v.advanced.clauses.length}):null]})}),(0,G.jsx)(g,{side:`bottom`,children:`Advanced`})]}):null,e.length>0?(0,G.jsx)(`span`,{className:`mx-0.5 h-3 w-px bg-border/60`,"aria-hidden":!0}):null,(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-0.5 text-[10px] text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:r===`open`?`size-1.5 rounded-full bg-emerald-500`:`size-1.5 rounded-full bg-muted-foreground`,"aria-hidden":!0}),r===`open`?`live`:`polling`]})]})]}),e.length>0?(0,G.jsx)(`div`,{className:m(w,`border-t border-b-0`),"data-slot":`traces-filters`,children:(0,G.jsx)(`div`,{className:`flex shrink-0 items-stretch`,role:`group`,"aria-label":`Status filter`,children:zn.map(({value:e,label:t,icon:n})=>{let r=v.status===e;return(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>ae(e),className:m(y,`font-semibold tracking-[0.08em] uppercase`,r?e===`errors`?`text-destructive`:D:E),children:[(0,G.jsx)(f,{icon:n,className:`size-3`,"aria-hidden":!0}),t]},e)})})}):null,e.length>0&&a?(0,G.jsxs)(`button`,{type:`button`,"data-slot":`traces-graph-filter`,onClick:()=>o(null),title:`Clear graph filter`,className:`mx-2 mb-1.5 inline-flex max-w-full items-center gap-1 self-start truncate rounded-md border border-sky-500/40 bg-sky-500/10 px-2 py-0.5 text-[10px] font-medium text-sky-700 transition-colors hover:bg-sky-500/20 dark:text-sky-400`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:ln(a)}),(0,G.jsx)(`span`,{"aria-hidden":!0,children:`×`})]}):null]}),e.length>0?(0,G.jsx)(Ue,{id:`traces-advanced-panel`,role:`region`,"aria-label":`Advanced filters`,open:S,className:`shrink-0`,children:(0,G.jsx)(jn,{query:v.advanced,runs:e,onChange:e=>{x(t=>({...t,advanced:e}))}})}):null,(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:e.length===0?(0,G.jsx)(ie,{className:`border-none`,children:(0,G.jsxs)(te,{children:[(0,G.jsx)(ne,{variant:`icon`,children:(0,G.jsx)(f,{icon:A.flow.icon})}),(0,G.jsx)(se,{children:`No traces yet`}),(0,G.jsx)(le,{children:`No runs for the flows on this graph yet. Trigger a flow to see live activity here.`})]})}):T.length===0?(0,G.jsx)(ie,{className:`border-none`,children:(0,G.jsxs)(te,{children:[(0,G.jsx)(se,{children:`No matching traces`}),(0,G.jsx)(le,{children:`Nothing in this list matches the current search, status, or advanced filters.`})]})}):T.map(e=>(0,G.jsx)(Rn,{run:e,selected:e.id===t,onSelect:e=>n(e===t?null:e)},e.id))}),(0,G.jsx)(je,{run:O,onClose:()=>n(null),focusEffectIndex:s,onFocusEffectChange:c,playbackKey:l,onReplayStart:u})]})}function Vn(){let e=pe(),t=_e(),n=fe(!0),{selectedRunId:r,selectedFlowId:i,follow:a,setSelectedRun:o,setSelectedFlow:s}=Ie(),c=ae(),l=(0,G.jsx)(oe,{open:c.open,onToggle:c.toggle,noun:`traces`,controlsId:`overview-traces`,dataSlot:`overview-traces-toggle`}),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(0),[g,_]=(0,I.useState)(null),y=(0,I.useRef)(null),b=(0,I.useMemo)(()=>new Set(Object.keys(e.data?.flows??{})),[e.data]),S=(0,I.useMemo)(()=>ze(t.data??[],b),[t.data,b]),C=En({enabled:!!e.data&&S.length>0,paused:r!=null||u!=null});(0,I.useEffect)(()=>{i&&d(e=>e?.kind===`flow`&&e.flowId===i?e:{kind:`flow`,flowId:i})},[i]);let w=(0,I.useCallback)(e=>{d(e),e?.kind===`flow`?s(e.flowId):s(null)},[s]),T=(0,I.useMemo)(()=>{let e=Dn(t.data??[],r);return e.size>0?e:i?new Set([i]):C?.flowId?new Set([C.flowId]):e},[t.data,r,i,C?.flowId]),E=(0,I.useMemo)(()=>{let t=new Set,n=e.data?.flows??{};for(let e of T){let r=n[e];if(r){r.trigger?.signal&&t.add(`signal:${r.trigger.signal}`),(r.trigger?.cron||r.trigger?.every)&&t.add(`clock:${e}`);for(let e of r.gates??[])t.add(`gate:${e}`);for(let e of r.effects?.reads??[])t.add(e);for(let e of r.effects?.writes??[])t.add(e);for(let e of r.effects?.emits??[])t.add(`signal:${e}`);for(let e of r.effects?.sends??[])t.add(`channel:${e}`);for(let e of r.effects?.asks??[])t.add(`ai:${e}`);for(let e of r.effects?.secrets??[])t.add(`vault:${e}`)}}return t},[T,e.data]),D=(0,I.useMemo)(()=>r?t.data?.find(e=>e.id===r)??null:null,[t.data,r]),k=(0,I.useCallback)(e=>{let t=cn(e);t&&w(u&&u.kind===t.kind&&JSON.stringify(u)===JSON.stringify(t)?null:t)},[w,u]),ee=(0,I.useCallback)(()=>{w(null)},[w]),te=(0,I.useCallback)(()=>{h(e=>e+1)},[]);return(0,I.useEffect)(()=>{if(m===0||!D)return;let n=ke(Dn(t.data??[],D.id),e.data??null);if(n.length===0)return;let r=Ee(D.durationMs),i=performance.now();return _(n[0]??null),y.current=setInterval(()=>{let e=Math.min(1,(performance.now()-i)/r);_(De(n,e)),e>=1&&y.current&&(clearInterval(y.current),y.current=null,setTimeout(()=>_(null),400))},60),()=>{y.current&&=(clearInterval(y.current),null),_(null)}},[m,D,t.data,e.data]),(0,G.jsx)(`div`,{className:x,"data-slot":`flows-page`,children:(0,G.jsxs)(O,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,G.jsx)(re,{panelRef:c.panelRef,collapsible:!0,collapsedSize:0,defaultSize:v.start.defaultSize,minSize:v.start.minSize,maxSize:`50%`,onResize:c.onResize,className:`min-h-0`,children:(0,G.jsx)(`div`,{id:`overview-traces`,className:`h-full min-h-0 overflow-hidden`,"data-slot":`overview-traces`,children:(0,G.jsx)(Bn,{runs:S,selectedRunId:r,onSelect:o,liveStatus:n,manifest:e.data??null,graphFilter:u,onGraphFilterChange:w,focusEffectIndex:f,onFocusEffectChange:p,playbackKey:m,onReplayStart:te,selectedRun:D})})}),c.open?(0,G.jsx)(ce,{withHandle:!0}):null,(0,G.jsx)(re,{defaultSize:v.end.defaultSize,minSize:v.end.minSize,className:`min-h-0`,children:(0,G.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:(0,G.jsx)(vn,{manifest:e.data??null,runs:S,graphFilter:u,highlightedFlowIds:T,highlightedNodeIds:E,orchestraLabel:C?.flowId??null,follow:a,activeNodeId:g,onNodeClick:k,onPaneClick:ee,leading:l})})})]})})}export{Vn as FlowsPage};
@@ -1 +0,0 @@
1
- import{A as e}from"./xyflow-yApv7D4e.js";import{Dr as t,Er as n,ar as r,lr as i,mr as a,vr as o,wr as s}from"./shortcut-keys-3ILd8oGn.js";import{o as c}from"./http-method-Jrh39p7A.js";import{h as l,m as u,t as d}from"./element-icons-BI8cJgdh.js";import{d as f,i as p,u as m}from"./highlighted-json-MYZQtRnw.js";import{t as h}from"./UserIcon-DaE2PB5_.js";import{t as g}from"./UnavailableIcon-D9cvHVPr.js";var _=[[`path`,{d:`M13.5 13L17 9M14 15C14 16.1046 13.1046 17 12 17C10.8954 17 10 16.1046 10 15C10 13.8954 10.8954 13 12 13C13.1046 13 14 13.8954 14 15Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M6 12C6 8.68629 8.68629 6 12 6C13.0929 6 14.1175 6.29218 15 6.80269`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M2.50006 12.0001C2.50006 7.52172 2.50006 5.28255 3.8913 3.8913C5.28255 2.50006 7.52172 2.50006 12.0001 2.50006C16.4784 2.50006 18.7176 2.50006 20.1088 3.8913C21.5001 5.28255 21.5001 7.52172 21.5001 12.0001C21.5001 16.4784 21.5001 18.7176 20.1088 20.1088C18.7176 21.5001 16.4784 21.5001 12.0001 21.5001C7.52172 21.5001 5.28255 21.5001 3.8913 20.1088C2.50006 18.7176 2.50006 16.4784 2.50006 12.0001Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`2`}]],v=[[`path`,{d:`M5.0249 21C5.04385 19.2643 5.04366 17.5541 5.0366 15.9209M5.0366 15.9209C5.01301 10.4614 4.91276 5.86186 5.19475 4.04271C5.5611 1.67939 9.39301 3.82993 13.9703 5.59842L16.0328 6.48729C17.5508 7.1415 19.7187 8.30352 18.7662 9.66084C18.3738 10.22 17.56 10.8596 16.0575 11.567L5.0366 15.9209Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],y=[[`path`,{d:`M16 16L11.6667 21.6535C11.1282 22.356 10.1188 21.9188 10.1188 20.9829V14.0301C10.1188 13.4695 9.72302 13.015 9.23474 13.015H5.88582C5.12506 13.015 4.71954 11.9851 5.22212 11.3294L7.7741 8`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M10 5.72714L12.4969 2.35038C13.0221 1.63999 14.0067 2.08215 14.0067 3.02843V10.059C14.0067 10.6258 14.3928 11.0854 14.8691 11.0854H18.1359C18.878 11.0854 19.2736 12.1268 18.7833 12.7898L17.8885 14`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M2 2L22 22`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`2`}]],b=[[`path`,{d:`M5.22576 11.3294L12.224 2.34651C12.7713 1.64397 13.7972 2.08124 13.7972 3.01707V9.96994C13.7972 10.5305 14.1995 10.985 14.6958 10.985H18.0996C18.8729 10.985 19.2851 12.0149 18.7742 12.6706L11.776 21.6535C11.2287 22.356 10.2028 21.9188 10.2028 20.9829V14.0301C10.2028 13.4695 9.80048 13.015 9.3042 13.015H5.90035C5.12711 13.015 4.71494 11.9851 5.22576 11.3294Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],x=[[`path`,{d:`M8.5 15.5C8.63206 15.9782 8.89835 16.5 9.59365 16.5C10.7968 16.5 11.0976 15.5 12 12C12.9024 8.5 13.2032 7.5 14.4064 7.5C15.1016 7.5 15.3679 8.02179 15.5 8.5M10.5417 10.75H14.4064`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`1.5`,key:`1`}]],S=[[`path`,{d:`M2 11.4C2 10.2417 2.24173 10 3.4 10H20.6C21.7583 10 22 10.2417 22 11.4V12.6C22 13.7583 21.7583 14 20.6 14H3.4C2.24173 14 2 13.7583 2 12.6V11.4Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M2 3.4C2 2.24173 2.24173 2 3.4 2H20.6C21.7583 2 22 2.24173 22 3.4V4.6C22 5.75827 21.7583 6 20.6 6H3.4C2.24173 6 2 5.75827 2 4.6V3.4Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M2 19.4C2 18.2417 2.24173 18 3.4 18H20.6C21.7583 18 22 18.2417 22 19.4V20.6C22 21.7583 21.7583 22 20.6 22H3.4C2.24173 22 2 21.7583 2 20.6V19.4Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`2`}]],C=e();function w(e){if(!e.startsWith(`mcp:`))return null;let t=e.slice(4),n=t.indexOf(`/`);return n<=0||n===t.length-1?null:{server:t.slice(0,n),tool:t.slice(n+1)}}function T(e){return`mcp:${e}`}var E={flow:{accent:`#38BDF8`,glow:`rgba(56, 189, 248, 0.45)`,well:`rgba(56, 189, 248, 0.14)`},signal:{accent:`#FBBF24`,glow:`rgba(251, 191, 36, 0.4)`,well:`rgba(251, 191, 36, 0.14)`},store:{accent:`#34D399`,glow:`rgba(52, 211, 153, 0.45)`,well:`rgba(52, 211, 153, 0.14)`},clock:{accent:`#818CF8`,glow:`rgba(129, 140, 248, 0.45)`,well:`rgba(129, 140, 248, 0.14)`},gate:{accent:`#A78BFA`,glow:`rgba(167, 139, 250, 0.45)`,well:`rgba(167, 139, 250, 0.14)`},vault:{accent:`#94A3B8`,glow:`rgba(148, 163, 184, 0.4)`,well:`rgba(148, 163, 184, 0.14)`},channel:{accent:`#C084FC`,glow:`rgba(192, 132, 252, 0.45)`,well:`rgba(192, 132, 252, 0.14)`},ai:{accent:`#FB7185`,glow:`rgba(251, 113, 133, 0.45)`,well:`rgba(251, 113, 133, 0.14)`}},D={reads:`#2DD4BF`,writes:`#FB923C`,emits:`#FBBF24`,calls:`#60A5FA`,asks:`#FB7185`,sends:`#C084FC`,secrets:`#94A3B8`,gates:`#A78BFA`,trigger:`#FBBF24`,couple:`#64748B`},O={flow:{width:188,height:52},store:{width:168,height:48},signal:{width:168,height:48},ai:{width:168,height:48},clock:{width:168,height:48},gate:{width:168,height:48},vault:{width:168,height:48},channel:{width:168,height:48}},k={law:{width:140,height:140},hub:{width:56,height:56},type:{width:64,height:26},unit:{width:128,height:40}},A={cx:900,cy:900,elementRing:280,typeRing:418,typeRow:88,spokeRing:840},j={headerH:26,padX:10,padBottom:10},M={edge:0,unit:1,leaf:2},N=[`http`,`signal`,`cron`,`every`,`cdc`,`internal`],P={http:{icon:c,label:`HTTP`,wellClass:`border-sky-500/35 bg-sky-500/10 text-sky-600 dark:text-sky-400`},signal:{icon:d.signal.icon,label:`Signal`,wellClass:`border-amber-500/35 bg-amber-500/10 text-amber-700 dark:text-amber-400`},cron:{icon:f,label:`Cron`,wellClass:`border-violet-500/35 bg-violet-500/10 text-violet-700 dark:text-violet-400`},every:{icon:m,label:`Every`,wellClass:`border-teal-500/35 bg-teal-500/10 text-teal-700 dark:text-teal-400`},cdc:{icon:d.store.icon,label:`CDC`,wellClass:`border-emerald-500/35 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`},internal:{icon:x,label:`Call-only`,wellClass:`border-zinc-500/35 bg-zinc-500/10 text-zinc-600 dark:text-zinc-400`}};function F(e){return e?.http?`http`:e?.signal?`signal`:e?.cron?`cron`:e?.every?`every`:e?.cdc?`cdc`:`internal`}function ee(e){let t=F(e),n=P[t],r=null;return t===`http`&&e?.http?r=`${e.http.method} ${e.http.path}`:t===`signal`&&e?.signal?r=e.signal:t===`cron`&&e?.cron?r=e.cron:t===`every`&&e?.every?r=e.every:t===`cdc`&&e?.cdc&&(r=e.cdc.table),{kind:t,icon:n.icon,label:n.label,detail:r,wellClass:n.wellClass}}var I={policy:u,scope:l,rate:_,flag:v,public:h};function L(e,t,n){return t===`rate`||e.startsWith(`rate:`)?`rate`:e.startsWith(`flag:`)?`flag`:e===`public`?`public`:(n?.length??0)>0?`scope`:t===`policy`||t===`all`?`policy`:null}function R(e){return e?I[e]:u}function z(e,t){let n=t?.gates;return e.map(e=>{let t=n?.[e];return{name:e,kind:t?.kind??null,variant:L(e,t?.kind,t?.scopes),description:t?.description??null}})}var B=`#A78BFA`;function V({gate:e}){let n=e.variant??`undeclared`,r=[e.variant,e.description].filter(Boolean).join(` · `)||`undeclared`;return(0,C.jsxs)(`li`,{className:a,title:r,"data-slot":`trace-gate-row`,children:[(0,C.jsx)(t,{icon:R(e.variant),className:i,style:{color:B},"aria-hidden":!0}),(0,C.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:n}),(0,C.jsxs)(`span`,{className:`text-foreground/90`,children:[` `,e.name]})]})]})}function H({gates:e,heading:t=`Gates`}){return e.length===0?null:(0,C.jsxs)(`section`,{className:`flex flex-col`,"data-slot":`gate-list`,"aria-label":t,children:[(0,C.jsxs)(`div`,{className:o,children:[(0,C.jsx)(`h3`,{className:n(s,`flex items-center px-2`),children:t}),(0,C.jsx)(`span`,{className:n(r,`flex items-center`),children:e.length})]}),(0,C.jsx)(`ul`,{children:e.map(e=>(0,C.jsx)(V,{gate:e},e.name))})]})}var U={read:`Read`,write:`Write`,emit:`Emit`,send:`Send`,ask:`Ask`,embed:`Embed`,secret:`Secret`,call:`Call`,fetch:`Fetch`};function W(e,t){return`${t} ${t===1?{read:`read`,write:`write`,emit:`emit`,send:`send`,ask:`ask`,embed:`embed`,secret:`secret`,call:`call`,fetch:`fetch`}[e]:{read:`reads`,write:`writes`,emit:`emits`,send:`sends`,ask:`asks`,embed:`embeds`,secret:`secrets`,call:`calls`,fetch:`fetches`}[e]}`}function G(e){switch(e){case`read`:return D.reads;case`write`:return D.writes;case`emit`:return D.emits;case`call`:return D.calls;case`ask`:case`embed`:return D.asks;case`send`:case`fetch`:return D.sends;case`secret`:return D.secrets}}function K(e,t){if(t&&w(t))return d.ai.icon;switch(e){case`read`:case`write`:return d.store.icon;case`emit`:return d.signal.icon;case`call`:return d.flow.icon;case`ask`:case`embed`:return d.ai.icon;case`send`:case`fetch`:return d.channel.icon;case`secret`:return d.vault.icon}}var q=[`read`,`write`,`emit`,`call`,`ask`,`embed`,`send`,`fetch`,`secret`];function J(e){return e.startsWith(`sql:`)}function Y(e){return e.startsWith(`computed:`)}function X(e){let t=[{key:`duration`,label:p(e.durationMs),shortLabel:p(e.durationMs),variant:`duration`,detail:`Handler duration from the run ledger (${p(e.durationMs)}).`}];e.trigger===`http`&&t.push({key:`api`,label:`1 API call`,shortLabel:`1 API`,variant:`api`,detail:`HTTP trigger invocation for this run (not counted as an effect).`});let n=e.gates.length;n>0&&t.push({key:`gates`,label:`${n} ${n===1?`gate`:`gates`}`,shortLabel:`${n} gate${n===1?``:`s`}`,variant:`gate`,detail:`Evaluated on this run: ${e.gates.join(`, `)}.`});let r=e.effects.filter(e=>Y(e.resource)).length;r>0&&t.push({key:`cache`,label:`${r} cache ${r===1?`read`:`reads`}`,shortLabel:`${r} cache`,variant:`cache`,detail:`${r} effect${r===1?``:`s`} targeting computed:… cache keys.`});let i=e.effects.filter(e=>J(e.resource)).length;i>0&&t.push({key:`db`,label:`${i} DB ${i===1?`query`:`queries`}`,shortLabel:`${i} DB`,variant:`db`,detail:`${i} effect${i===1?``:`s`} targeting sql:… store resources.`});let a=te(e.effects);for(let e of q){let n=a.get(e)??0;n!==0&&t.push({key:e,label:W(e,n),shortLabel:W(e,n),variant:e,detail:`${n} non-SQL ${e} effect${n===1?``:`s`} on the run ledger.`})}let o=e.logs.length;return o>0&&t.push({key:`logs`,label:`${o} log ${o===1?`line`:`lines`}`,shortLabel:`${o} log${o===1?``:`s`}`,variant:`logs`,detail:`${o} ${o===1?`entry`:`entries`} in run.logs.`}),t}function Z(e){let t=w(e);return t?`Call ${t.server} → ${t.tool}`:null}function Q(e){return w(e)!==null}function $(e){return Y(e.resource)?`Cache read`:J(e.resource)?e.kind===`write`?`DB write`:`DB query`:e.kind===`call`&&Q(e.resource)?`MCP call`:{read:`Read`,write:`Write`,emit:`Emit`,send:`Send`,ask:`Ask`,embed:`Embed`,secret:`Secret`,call:`Call`,fetch:`Fetch`}[e.kind]}function te(e){let t=new Map;for(let n of e)J(n.resource)||Y(n.resource)||t.set(n.kind,(t.get(n.kind)??0)+1);return t}function ne(e){switch(e){case`hit`:return{icon:b,label:`Cache hit`,className:`text-sky-500 dark:text-sky-400`};case`miss`:return{icon:y,label:`Cache miss`,className:`text-amber-600 dark:text-amber-400`};case`none`:return{icon:g,label:`Cache not applicable`,className:`text-muted-foreground/40`}}}function re(e,t,n){let r=e?.flows?.[t],i=r?.trigger;return i?.http?{method:i.http.method,path:i.http.path,headline:`${i.http.method} ${i.http.path}`}:i?.signal?{method:null,path:null,headline:`Signal · ${i.signal}`}:i?.cron?{method:null,path:null,headline:`Cron · ${i.cron}`}:i?.every?{method:null,path:null,headline:`Every · ${i.every}`}:i?.cdc?{method:null,path:null,headline:`CDC · ${i.cdc.table}`}:n===`http`?{method:null,path:null,headline:`HTTP`}:n===`internal`||!r?.trigger?{method:null,path:null,headline:`Call-only`}:{method:null,path:null,headline:n}}export{w as C,T as S,b as T,A as _,Z as a,O as b,K as c,N as d,P as f,M as g,D as h,X as i,H as l,ee as m,ne as n,U as o,F as p,$ as r,G as s,re as t,z as u,k as v,S as w,j as x,E as y};
File without changes