@ekanos/harness 0.26.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/README.md +6 -4
  2. package/dist/api-types.d.ts +4 -0
  3. package/dist/internal/components/approvals-tray.d.ts +44 -6
  4. package/dist/internal/components/approvals-tray.js +252 -30
  5. package/dist/internal/components/connect-controls.js +4 -2
  6. package/dist/internal/components/connect-dialog.d.ts +8 -1
  7. package/dist/internal/components/connect-dialog.js +23 -10
  8. package/dist/internal/components/connect-panel.d.ts +3 -2
  9. package/dist/internal/components/connect-panel.js +680 -340
  10. package/dist/internal/components/connect-steps.d.ts +72 -0
  11. package/dist/internal/components/connect-steps.js +341 -0
  12. package/dist/internal/components/console-not-found.d.ts +14 -0
  13. package/dist/internal/components/console-not-found.js +57 -0
  14. package/dist/internal/components/dashboard-grid.d.ts +10 -5
  15. package/dist/internal/components/dashboard-grid.js +8 -9
  16. package/dist/internal/components/dev-toolbar.d.ts +27 -5
  17. package/dist/internal/components/dev-toolbar.js +214 -176
  18. package/dist/internal/components/ekanos-logo.d.ts +18 -0
  19. package/dist/internal/components/ekanos-logo.js +74 -0
  20. package/dist/internal/components/events-panel.d.ts +13 -4
  21. package/dist/internal/components/events-panel.js +478 -81
  22. package/dist/internal/components/harness-widget-provider.d.ts +6 -8
  23. package/dist/internal/components/harness-widget-provider.js +5 -19
  24. package/dist/internal/components/health-panel.d.ts +8 -1
  25. package/dist/internal/components/health-panel.js +328 -31
  26. package/dist/internal/components/integration-badge.js +4 -2
  27. package/dist/internal/components/integration-tab-skeletons.d.ts +8 -0
  28. package/dist/internal/components/integration-tab-skeletons.js +76 -0
  29. package/dist/internal/components/not-found-state.d.ts +39 -0
  30. package/dist/internal/components/not-found-state.js +127 -0
  31. package/dist/internal/components/operation-runner-panel.d.ts +1 -1
  32. package/dist/internal/components/operation-runner-panel.js +624 -189
  33. package/dist/internal/components/operation-scope.d.ts +13 -0
  34. package/dist/internal/components/operation-scope.js +79 -0
  35. package/dist/internal/components/page-skeletons.d.ts +11 -0
  36. package/dist/internal/components/page-skeletons.js +61 -0
  37. package/dist/internal/components/provenance-banner.d.ts +13 -4
  38. package/dist/internal/components/provenance-banner.js +35 -10
  39. package/dist/internal/components/run-log-copy.d.ts +17 -0
  40. package/dist/internal/components/run-log-copy.js +67 -0
  41. package/dist/internal/components/run-log-detail.d.ts +22 -0
  42. package/dist/internal/components/run-log-detail.js +295 -0
  43. package/dist/internal/components/run-log-empty.d.ts +13 -0
  44. package/dist/internal/components/run-log-empty.js +46 -0
  45. package/dist/internal/components/run-log.d.ts +23 -3
  46. package/dist/internal/components/run-log.js +384 -130
  47. package/dist/internal/components/runtime-strip.d.ts +5 -1
  48. package/dist/internal/components/runtime-strip.js +115 -10
  49. package/dist/internal/components/schema-form.d.ts +2 -1
  50. package/dist/internal/components/schema-form.js +212 -79
  51. package/dist/internal/components/scrollable-nav.js +14 -2
  52. package/dist/internal/components/segmented-control.d.ts +19 -0
  53. package/dist/internal/components/segmented-control.js +46 -0
  54. package/dist/internal/components/shell-header.d.ts +25 -0
  55. package/dist/internal/components/shell-header.js +126 -0
  56. package/dist/internal/components/surface-nav.d.ts +12 -3
  57. package/dist/internal/components/surface-nav.js +72 -83
  58. package/dist/internal/components/widget-surface.d.ts +5 -1
  59. package/dist/internal/components/widget-surface.js +86 -14
  60. package/dist/internal/components/workflow-runner.d.ts +23 -10
  61. package/dist/internal/components/workflow-runner.js +451 -69
  62. package/dist/internal/lib/connect-model.d.ts +134 -0
  63. package/dist/internal/lib/connect-model.js +282 -0
  64. package/dist/internal/lib/connection-facts.js +2 -1
  65. package/dist/internal/lib/console-client.js +5 -2
  66. package/dist/internal/lib/console-hooks.d.ts +4 -1
  67. package/dist/internal/lib/console-hooks.js +3 -2
  68. package/dist/internal/lib/console-types.d.ts +6 -0
  69. package/dist/internal/lib/docs-links.d.ts +28 -0
  70. package/dist/internal/lib/docs-links.js +57 -1
  71. package/dist/internal/lib/event-delivery.d.ts +33 -0
  72. package/dist/internal/lib/event-delivery.js +66 -0
  73. package/dist/internal/lib/experience-runtime.d.ts +2 -1
  74. package/dist/internal/lib/experience-runtime.js +5 -3
  75. package/dist/internal/lib/font-files/OFL-BricolageGrotesque.txt +93 -0
  76. package/dist/internal/lib/font-files/OFL-Figtree.txt +93 -0
  77. package/dist/internal/lib/font-files/bricolage-grotesque-latin-variable.woff2 +0 -0
  78. package/dist/internal/lib/font-files/figtree-latin-variable.woff2 +0 -0
  79. package/dist/internal/lib/fonts.js +13 -12
  80. package/dist/internal/lib/health-model.d.ts +58 -0
  81. package/dist/internal/lib/health-model.js +140 -0
  82. package/dist/internal/lib/integration-console-href.d.ts +15 -0
  83. package/dist/internal/lib/integration-console-href.js +16 -0
  84. package/dist/internal/lib/oauth-setup-guide.d.ts +28 -0
  85. package/dist/internal/lib/oauth-setup-guide.js +35 -1
  86. package/dist/internal/lib/operation-catalog.d.ts +70 -0
  87. package/dist/internal/lib/operation-catalog.js +261 -0
  88. package/dist/internal/lib/overview-model.d.ts +34 -0
  89. package/dist/internal/lib/overview-model.js +91 -0
  90. package/dist/internal/lib/registry-entry.d.ts +8 -0
  91. package/dist/internal/lib/registry-entry.js +11 -0
  92. package/dist/internal/lib/repo-name.d.ts +9 -0
  93. package/dist/internal/lib/repo-name.js +21 -0
  94. package/dist/internal/lib/run-log-view.d.ts +66 -1
  95. package/dist/internal/lib/run-log-view.js +183 -4
  96. package/dist/internal/lib/runner-view.d.ts +15 -0
  97. package/dist/internal/lib/runner-view.js +18 -0
  98. package/dist/internal/lib/schema-form-model.d.ts +17 -0
  99. package/dist/internal/lib/schema-form-model.js +50 -0
  100. package/dist/internal/lib/setup-checklist.d.ts +34 -0
  101. package/dist/internal/lib/setup-checklist.js +79 -0
  102. package/dist/internal/lib/toolbar-context.d.ts +0 -1
  103. package/dist/internal/lib/toolbar-context.js +0 -2
  104. package/dist/internal/lib/toolbar-visibility.d.ts +9 -2
  105. package/dist/internal/lib/toolbar-visibility.js +5 -0
  106. package/dist/internal/lib/use-operation-effects.d.ts +7 -0
  107. package/dist/internal/lib/use-operation-effects.js +28 -0
  108. package/dist/internal/lib/use-run-log-query.d.ts +9 -0
  109. package/dist/internal/lib/use-run-log-query.js +35 -0
  110. package/dist/internal/lib/widget-grid-gaps.d.ts +18 -0
  111. package/dist/internal/lib/widget-grid-gaps.js +41 -0
  112. package/dist/internal/lib/workflow-summary.d.ts +54 -0
  113. package/dist/internal/lib/workflow-summary.js +147 -0
  114. package/dist/internal/routes/console-home-page.js +2 -1
  115. package/dist/internal/routes/experience-connect-page.js +51 -22
  116. package/dist/internal/routes/experience-layout-page.js +75 -26
  117. package/dist/internal/routes/experience-page-host.js +63 -5
  118. package/dist/internal/routes/experience-review-queue-page.d.ts +4 -1
  119. package/dist/internal/routes/experience-review-queue-page.js +108 -12
  120. package/dist/internal/routes/experience-runs-page.js +57 -4
  121. package/dist/internal/routes/experience-summary-page.d.ts +19 -0
  122. package/dist/internal/routes/experience-summary-page.js +219 -62
  123. package/dist/internal/routes/experience-widget-page.js +58 -7
  124. package/dist/internal/routes/experience-widgets-page.d.ts +2 -3
  125. package/dist/internal/routes/experience-widgets-page.js +29 -4
  126. package/dist/internal/routes/experience-workflow-page.js +81 -9
  127. package/dist/internal/routes/experience-workflows-page.js +85 -21
  128. package/dist/internal/routes/integration-layout.js +28 -3
  129. package/dist/internal/routes/integrations-connect-page.js +16 -6
  130. package/dist/internal/routes/integrations-events-page.js +22 -1
  131. package/dist/internal/routes/integrations-health-page.js +16 -1
  132. package/dist/internal/routes/integrations-layout.js +28 -4
  133. package/dist/internal/routes/integrations-list-page.d.ts +0 -1
  134. package/dist/internal/routes/integrations-list-page.js +11 -9
  135. package/dist/internal/routes/integrations-operation-page.js +53 -17
  136. package/dist/internal/routes/integrations-operations-page.js +539 -49
  137. package/dist/internal/routes/integrations-overview-page.js +332 -69
  138. package/dist/internal/routes/integrations-runs-page.js +53 -3
  139. package/dist/internal/routes/integrations-scope.d.ts +15 -2
  140. package/dist/internal/routes/integrations-scope.js +66 -18
  141. package/dist/internal/routes/preview-index-page.js +2 -2
  142. package/dist/internal/routes/repo-home-page.d.ts +2 -2
  143. package/dist/internal/routes/repo-home-page.js +428 -236
  144. package/dist/internal/routes/repo-layout.d.ts +12 -0
  145. package/dist/internal/routes/repo-layout.js +50 -38
  146. package/dist/internal/routes/repo-package-layouts.js +22 -8
  147. package/dist/internal/routes/single-widget-page.d.ts +1 -1
  148. package/dist/internal/routes/single-widget-page.js +28 -5
  149. package/dist/internal/routes/tile-page.d.ts +1 -1
  150. package/dist/internal/routes/tile-page.js +1 -2
  151. package/dist/internal/routes/widgets-page.d.ts +1 -1
  152. package/dist/internal/routes/widgets-page.js +5 -3
  153. package/dist/internal/server/ekanos-api-router.js +20 -5
  154. package/dist/internal/server/repo-api-router.js +20 -7
  155. package/dist/registry.d.ts +4 -5
  156. package/dist/registry.js +0 -1
  157. package/dist/routes.d.ts +5 -0
  158. package/dist/routes.js +2 -0
  159. package/package.json +8 -8
@@ -1,111 +1,508 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useState } from "react";
4
+ import Link from "next/link";
4
5
  import { Alert, AlertDescription, AlertTitle } from "@ekanos/ui/alert";
5
6
  import { Button } from "@ekanos/ui/button";
7
+ import { Card } from "@ekanos/ui/card";
8
+ import {
9
+ EmptyMedia,
10
+ EmptyState,
11
+ EmptyStateHeading,
12
+ EmptyStateText
13
+ } from "@ekanos/ui/empty-state";
14
+ import { Icon } from "@ekanos/ui/icon";
6
15
  import { Label } from "@ekanos/ui/label";
7
16
  import { StatusBadge } from "@ekanos/ui/status-badge";
8
17
  import { Textarea } from "@ekanos/ui/textarea";
9
- import { useConsoleMutation } from "../lib/console-hooks.js";
10
- import { formatJson, parseJsonText } from "../lib/schema-form-model.js";
18
+ import { cn } from "@ekanos/ui/utils";
19
+ import { useConsoleMutation, useRuns } from "../lib/console-hooks.js";
20
+ import {
21
+ eventDeliveries,
22
+ eventDescription,
23
+ parseDeliveryDetail,
24
+ payloadFields
25
+ } from "../lib/event-delivery.js";
26
+ import {
27
+ RUN_OUTCOME_LABELS,
28
+ runLogHref,
29
+ runOutcome
30
+ } from "../lib/run-log-view.js";
31
+ import {
32
+ formatJson,
33
+ parseJsonText,
34
+ validateValue
35
+ } from "../lib/schema-form-model.js";
36
+ import { OUTCOME_TONES } from "./run-log-detail.js";
37
+ function exampleText(event) {
38
+ return formatJson(event?.payloadExample ?? {});
39
+ }
40
+ function checkPayload(event, text) {
41
+ const parsed = parseJsonText(text);
42
+ if (!parsed.ok) return { kind: "json", error: parsed.error };
43
+ const value = parsed.value ?? {};
44
+ const issues = validateValue(event.payloadSchema, value);
45
+ return issues.length > 0 ? { kind: "schema", issues } : { kind: "ok", value };
46
+ }
47
+ function IssueList({ issues }) {
48
+ return /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-0.5 text-xs", children: issues.map((issue) => /* @__PURE__ */ jsxs("li", { children: [
49
+ issue.path ? /* @__PURE__ */ jsxs(Fragment, { children: [
50
+ /* @__PURE__ */ jsx("code", { className: "font-mono", children: issue.path }),
51
+ " "
52
+ ] }) : null,
53
+ issue.message
54
+ ] }, `${issue.path}:${issue.message}`)) });
55
+ }
56
+ function EventPicker({
57
+ events,
58
+ index,
59
+ base
60
+ }) {
61
+ return /* @__PURE__ */ jsxs("nav", { "aria-label": "Events", className: "flex min-w-0 flex-col gap-1", children: [
62
+ /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-xs font-medium lg:px-2", children: [
63
+ events.length,
64
+ " ",
65
+ events.length === 1 ? "event" : "events",
66
+ " in the contract"
67
+ ] }),
68
+ /* @__PURE__ */ jsx(
69
+ "ul",
70
+ {
71
+ className: "-mx-1 flex min-w-0 gap-1.5 overflow-x-auto px-1 py-1 lg:mx-0 lg:flex-col lg:gap-0.5 lg:overflow-visible lg:px-0",
72
+ "data-test": "event-list",
73
+ children: events.map((event, position) => {
74
+ const chosen = position === index;
75
+ const fields = payloadFields(event.payloadSchema).length;
76
+ return /* @__PURE__ */ jsx("li", { className: "shrink-0 lg:shrink", children: /* @__PURE__ */ jsxs(
77
+ Link,
78
+ {
79
+ href: `${base}/events?event=${encodeURIComponent(event.name)}`,
80
+ replace: true,
81
+ scroll: false,
82
+ "aria-current": chosen ? "true" : void 0,
83
+ className: cn(
84
+ "focus-visible:ring-ring/50 flex w-full flex-col items-start gap-0.5 rounded-full border px-3 py-1 outline-none focus-visible:ring-3 lg:rounded-md lg:border-0 lg:px-2 lg:py-1.5",
85
+ chosen ? "bg-muted border-ring" : "hover:bg-muted"
86
+ ),
87
+ "data-test": "event-option",
88
+ "data-event": event.name,
89
+ children: [
90
+ /* @__PURE__ */ jsx("span", { className: "font-mono text-sm whitespace-nowrap lg:break-all lg:whitespace-normal", children: event.name }),
91
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground hidden text-xs lg:block", children: eventDescription(event) ?? (fields > 0 ? `${fields} ${fields === 1 ? "field" : "fields"}` : "Payload not described") })
92
+ ]
93
+ }
94
+ ) }, event.name);
95
+ })
96
+ }
97
+ )
98
+ ] });
99
+ }
100
+ function PayloadShape({ event }) {
101
+ const fields = payloadFields(event.payloadSchema);
102
+ if (fields.length === 0) return null;
103
+ return /* @__PURE__ */ jsxs("details", { className: "group text-sm", "data-test": "event-payload-shape", children: [
104
+ /* @__PURE__ */ jsxs("summary", { className: "text-muted-foreground hover:text-foreground focus-visible:ring-ring/50 flex w-fit cursor-pointer list-none items-center gap-1 rounded-sm text-xs outline-none focus-visible:ring-3", children: [
105
+ /* @__PURE__ */ jsx(
106
+ Icon,
107
+ {
108
+ name: "caret-right",
109
+ className: "size-3 transition-transform duration-(--duration-colour) group-open:rotate-90"
110
+ }
111
+ ),
112
+ "What the payload carries (",
113
+ fields.length,
114
+ " ",
115
+ fields.length === 1 ? "field" : "fields",
116
+ ")"
117
+ ] }),
118
+ /* @__PURE__ */ jsx("dl", { className: "mt-2 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-xs", children: fields.map((field) => /* @__PURE__ */ jsxs("div", { className: "contents", children: [
119
+ /* @__PURE__ */ jsxs("dt", { className: "font-mono", children: [
120
+ field.key,
121
+ field.required ? null : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: " (optional)" })
122
+ ] }),
123
+ /* @__PURE__ */ jsxs("dd", { className: "text-muted-foreground min-w-0 font-mono break-words", children: [
124
+ field.type,
125
+ field.description ? /* @__PURE__ */ jsx("span", { className: "block font-sans", children: field.description }) : null
126
+ ] })
127
+ ] }, field.key)) })
128
+ ] });
129
+ }
130
+ function DeliveryResult({
131
+ result,
132
+ roundTripMs,
133
+ runsHref
134
+ }) {
135
+ const handler = parseDeliveryDetail(result.detail);
136
+ const failed = handler?.kind === "ran" && handler.status === "failed";
137
+ const accepted = result.valid && !failed;
138
+ return /* @__PURE__ */ jsxs(
139
+ Card,
140
+ {
141
+ size: "sm",
142
+ role: "status",
143
+ className: "gap-3 px-4",
144
+ "data-test": "event-result",
145
+ "data-accepted": accepted,
146
+ children: [
147
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1", children: [
148
+ /* @__PURE__ */ jsx(StatusBadge, { tone: accepted ? "success" : "destructive", children: accepted ? "Accepted" : failed ? "Handler failed" : "Refused" }),
149
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs tabular-nums", children: roundTripMs === null ? null : `Answered in ${Math.round(roundTripMs)} ms` }),
150
+ /* @__PURE__ */ jsx(
151
+ Link,
152
+ {
153
+ href: runsHref,
154
+ className: "text-primary ml-auto text-xs underline-offset-4 hover:underline",
155
+ "data-test": "event-result-runs",
156
+ children: "See it in the run log"
157
+ }
158
+ )
159
+ ] }),
160
+ !result.valid ? /* @__PURE__ */ jsxs("div", { className: "text-destructive flex flex-col gap-1", children: [
161
+ /* @__PURE__ */ jsx("p", { className: "text-sm", children: "The payload doesn't match the event's schema, so nothing was delivered." }),
162
+ /* @__PURE__ */ jsx(IssueList, { issues: result.issues })
163
+ ] }) : result.outcome === "ran" && handler?.kind === "ran" ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", "data-test": "handler-ran", children: [
164
+ /* @__PURE__ */ jsxs("p", { className: "text-sm", children: [
165
+ "Handled by the webhook",
166
+ " ",
167
+ /* @__PURE__ */ jsx("code", { className: "font-mono", children: handler.webhook }),
168
+ ", which answered",
169
+ " ",
170
+ /* @__PURE__ */ jsx("code", { className: "font-mono", children: handler.status }),
171
+ handler.events === void 0 ? "." : ` and raised ${handler.events} agent ${handler.events === 1 ? "event" : "events"}.`
172
+ ] }),
173
+ handler.detail ? /* @__PURE__ */ jsx("pre", { className: "bg-muted max-h-60 overflow-auto rounded-md p-2 font-mono text-xs whitespace-pre-wrap", children: handler.detail }) : null
174
+ ] }) : handler?.kind === "no_handler" ? /* @__PURE__ */ jsxs("p", { className: "text-sm", "data-test": "event-no-handler", children: [
175
+ "The payload is valid, but the integration declares no webhook handler for this event, so nothing ran.",
176
+ handler.webhooks.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
177
+ " ",
178
+ "Declared webhooks:",
179
+ " ",
180
+ handler.webhooks.map((id, position) => /* @__PURE__ */ jsxs("span", { children: [
181
+ position > 0 ? ", " : "",
182
+ /* @__PURE__ */ jsx("code", { className: "font-mono", children: id })
183
+ ] }, id)),
184
+ "."
185
+ ] }) : null
186
+ ] }) : /* @__PURE__ */ jsx("p", { className: "text-sm", "data-test": "event-validated-only", children: "The payload matches the contract. Fixtures mode only checks it: no handler ran." }),
187
+ /* @__PURE__ */ jsx(
188
+ "div",
189
+ {
190
+ className: "text-muted-foreground text-xs",
191
+ "data-test": "matched-triggers",
192
+ children: result.matchedTriggers.length === 0 ? "No workflow in this project starts on this event." : /* @__PURE__ */ jsxs(Fragment, { children: [
193
+ "Workflows that start on this event:",
194
+ " ",
195
+ result.matchedTriggers.map((trigger, position) => /* @__PURE__ */ jsxs("span", { children: [
196
+ position > 0 ? ", " : "",
197
+ /* @__PURE__ */ jsx("code", { className: "text-foreground font-mono", children: trigger })
198
+ ] }, trigger))
199
+ ] })
200
+ }
201
+ )
202
+ ]
203
+ }
204
+ );
205
+ }
206
+ function RecentDeliveries({
207
+ integration,
208
+ event,
209
+ base
210
+ }) {
211
+ const runs = useRuns();
212
+ const all = runs.data ?? [];
213
+ const recent = eventDeliveries(all, integration, event);
214
+ const total = eventDeliveries(all, integration, event, Infinity).length;
215
+ return /* @__PURE__ */ jsxs("section", { className: "flex flex-col gap-2", "data-test": "event-deliveries", children: [
216
+ /* @__PURE__ */ jsxs("div", { className: "flex items-baseline justify-between gap-3", children: [
217
+ /* @__PURE__ */ jsx("h3", { className: "text-sm font-medium", children: "Recent deliveries" }),
218
+ total > 0 ? /* @__PURE__ */ jsx(
219
+ Link,
220
+ {
221
+ href: runLogHref(base, { event }),
222
+ className: "text-primary text-xs underline-offset-4 hover:underline",
223
+ "data-test": "event-deliveries-all",
224
+ children: total > recent.length ? `All ${total} in the run log` : "Run log"
225
+ }
226
+ ) : null
227
+ ] }),
228
+ recent.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: "None yet. Each test event you send is listed here and in the run log." }) : /* @__PURE__ */ jsx("ul", { className: "divide-y rounded-lg border", children: recent.map((run) => {
229
+ const outcome = runOutcome(run);
230
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
231
+ Link,
232
+ {
233
+ href: runLogHref(base, { run: run.id }),
234
+ className: "hover:bg-muted focus-visible:ring-ring/50 flex items-center gap-3 px-3 py-2 text-xs outline-none focus-visible:ring-3 focus-visible:ring-inset",
235
+ "data-test": "event-delivery",
236
+ children: [
237
+ /* @__PURE__ */ jsx(StatusBadge, { tone: OUTCOME_TONES[outcome], children: outcome === "ok" ? "Accepted" : outcome === "refused" ? "Refused" : RUN_OUTCOME_LABELS[outcome] }),
238
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground capitalize", children: run.mode ?? "" }),
239
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground ml-auto tabular-nums", children: new Date(run.ts).toLocaleTimeString() }),
240
+ /* @__PURE__ */ jsx(
241
+ Icon,
242
+ {
243
+ name: "caret-right",
244
+ className: "text-muted-foreground size-3"
245
+ }
246
+ )
247
+ ]
248
+ }
249
+ ) }, run.id);
250
+ }) })
251
+ ] });
252
+ }
253
+ function NoEvents({
254
+ integration,
255
+ operationsHref
256
+ }) {
257
+ return /* @__PURE__ */ jsxs(EmptyState, { "data-test": "no-events", children: [
258
+ /* @__PURE__ */ jsx(EmptyMedia, { variant: "icon", children: /* @__PURE__ */ jsx(Icon, { name: "lightning" }) }),
259
+ /* @__PURE__ */ jsxs(EmptyStateHeading, { children: [
260
+ integration,
261
+ " declares no events"
262
+ ] }),
263
+ /* @__PURE__ */ jsxs(EmptyStateText, { className: "max-w-md", children: [
264
+ "Events are the webhooks a provider sends, declared under",
265
+ " ",
266
+ /* @__PURE__ */ jsx("code", { className: "font-mono", children: "events" }),
267
+ " in the integration's contract. Once ",
268
+ integration,
269
+ " declares one, you can send test deliveries from here."
270
+ ] }),
271
+ /* @__PURE__ */ jsx(
272
+ Button,
273
+ {
274
+ className: "mt-4",
275
+ variant: "outline",
276
+ nativeButton: false,
277
+ render: /* @__PURE__ */ jsx(Link, { href: operationsHref }),
278
+ "data-test": "no-events-operations",
279
+ children: "Browse operations instead"
280
+ }
281
+ )
282
+ ] });
283
+ }
11
284
  function EventsPanel({
12
285
  integration,
13
- events
286
+ events,
287
+ base,
288
+ initialEvent
14
289
  }) {
15
290
  const emit = useConsoleMutation(
16
291
  (c, request) => c.emitEvent(request)
17
292
  );
18
- const [state, setState] = useState(() => ({
19
- index: 0,
20
- text: formatJson(events[0]?.payloadExample ?? {}),
21
- parseError: null
22
- }));
293
+ const canChooseMode = integration.runModes.includes("fixtures") && integration.runModes.includes("live");
294
+ const [state, setState] = useState(() => {
295
+ const found = events.findIndex((event2) => event2.name === initialEvent);
296
+ const index = found === -1 ? 0 : found;
297
+ return {
298
+ index,
299
+ text: exampleText(events[index]),
300
+ mode: integration.defaultMode,
301
+ roundTripMs: null,
302
+ showJsonError: false
303
+ };
304
+ });
23
305
  if (events.length === 0) {
24
- return /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", "data-test": "no-events", children: "This contract declares no events." });
306
+ return /* @__PURE__ */ jsx(
307
+ NoEvents,
308
+ {
309
+ integration: integration.integration,
310
+ operationsHref: `${base}/operations`
311
+ }
312
+ );
25
313
  }
26
314
  const event = events[state.index] ?? events[0];
27
315
  if (!event) return null;
316
+ const check = checkPayload(event, state.text);
317
+ const example = exampleText(event);
318
+ const edited = state.text !== example;
28
319
  const submit = () => {
29
- const parsed = parseJsonText(state.text);
30
- if (!parsed.ok) {
31
- setState({ ...state, parseError: parsed.error });
320
+ if (check.kind === "json") {
321
+ setState({ ...state, showJsonError: true });
32
322
  return;
33
323
  }
34
- setState({ ...state, parseError: null });
35
- emit.mutate({
36
- integration: integration.integration,
37
- event: event.name,
38
- payload: parsed.value ?? {}
39
- });
324
+ const started = performance.now();
325
+ const parsed = parseJsonText(state.text);
326
+ emit.mutate(
327
+ {
328
+ integration: integration.integration,
329
+ event: event.name,
330
+ payload: parsed.ok ? parsed.value ?? {} : {},
331
+ mode: state.mode
332
+ },
333
+ {
334
+ onSettled: () => setState((previous) => ({
335
+ ...previous,
336
+ roundTripMs: performance.now() - started
337
+ }))
338
+ }
339
+ );
40
340
  };
41
341
  const result = emit.data;
42
- return /* @__PURE__ */ jsxs("div", { className: "flex max-w-2xl flex-col gap-4", "data-test": "events-panel", children: [
43
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
44
- /* @__PURE__ */ jsx(Label, { htmlFor: "event-name", className: "text-sm font-medium", children: "Event" }),
45
- /* @__PURE__ */ jsx(
46
- "select",
47
- {
48
- id: "event-name",
49
- className: "border-input bg-background h-control rounded-md border px-3 text-sm",
50
- value: state.index,
51
- onChange: (change) => {
52
- const index = Number(change.target.value);
53
- setState({
342
+ return /* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-col gap-6", "data-test": "events-panel", children: /* @__PURE__ */ jsxs("div", { className: "grid min-w-0 gap-6 lg:grid-cols-[16rem_minmax(0,1fr)]", children: [
343
+ /* @__PURE__ */ jsx(EventPicker, { events, index: state.index, base }),
344
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-5", children: [
345
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
346
+ /* @__PURE__ */ jsx(
347
+ "h3",
348
+ {
349
+ className: "font-mono text-base break-all",
350
+ "data-test": "event-name",
351
+ children: event.name
352
+ }
353
+ ),
354
+ eventDescription(event) ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: eventDescription(event) }) : null,
355
+ /* @__PURE__ */ jsx(PayloadShape, { event })
356
+ ] }),
357
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
358
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
359
+ /* @__PURE__ */ jsx(Label, { htmlFor: "event-payload", className: "text-sm font-medium", children: "Payload" }),
360
+ /* @__PURE__ */ jsxs(
361
+ Button,
362
+ {
363
+ type: "button",
364
+ variant: "ghost",
365
+ size: "xs",
366
+ disabled: !edited,
367
+ onClick: () => setState({ ...state, text: example, showJsonError: false }),
368
+ "data-test": "event-reset",
369
+ children: [
370
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-counter-clockwise" }),
371
+ "Reset to example"
372
+ ]
373
+ }
374
+ )
375
+ ] }),
376
+ /* @__PURE__ */ jsx(
377
+ Textarea,
378
+ {
379
+ id: "event-payload",
380
+ className: "min-h-64 font-mono text-xs leading-relaxed lg:min-h-80",
381
+ spellCheck: false,
382
+ value: state.text,
383
+ "aria-invalid": check.kind === "json" ? true : void 0,
384
+ "aria-describedby": "event-payload-check",
385
+ onChange: (change) => setState({
54
386
  ...state,
55
- index,
56
- text: formatJson(events[index]?.payloadExample ?? {}),
57
- parseError: null
58
- });
59
- },
60
- children: events.map((entry, index) => /* @__PURE__ */ jsx("option", { value: index, children: entry.name }, entry.name))
387
+ text: change.target.value,
388
+ showJsonError: false
389
+ }),
390
+ "data-test": "event-payload"
391
+ }
392
+ ),
393
+ /* @__PURE__ */ jsx(
394
+ "div",
395
+ {
396
+ id: "event-payload-check",
397
+ "aria-live": "polite",
398
+ "data-test": "event-payload-check",
399
+ "data-state": check.kind,
400
+ children: check.kind === "ok" ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground flex items-center gap-1 text-xs", children: [
401
+ /* @__PURE__ */ jsx(Icon, { name: "check", className: "text-success size-3.5" }),
402
+ "Matches the event's schema."
403
+ ] }) : check.kind === "json" ? /* @__PURE__ */ jsxs(
404
+ "p",
405
+ {
406
+ role: state.showJsonError ? "alert" : void 0,
407
+ className: cn(
408
+ "text-xs",
409
+ state.showJsonError ? "text-destructive" : "text-muted-foreground"
410
+ ),
411
+ children: [
412
+ "Not valid JSON yet: ",
413
+ check.error
414
+ ]
415
+ }
416
+ ) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
417
+ /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-1 text-xs", children: [
418
+ /* @__PURE__ */ jsx(Icon, { name: "warning", className: "text-warning size-3.5" }),
419
+ "Doesn't match the schema. Sending it records a rejected delivery, which is how you test that path."
420
+ ] }),
421
+ /* @__PURE__ */ jsx(IssueList, { issues: check.issues })
422
+ ] })
423
+ }
424
+ )
425
+ ] }),
426
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
427
+ canChooseMode ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
428
+ /* @__PURE__ */ jsx(
429
+ "span",
430
+ {
431
+ className: "text-muted-foreground text-xs",
432
+ id: "event-mode-label",
433
+ children: "Mode"
434
+ }
435
+ ),
436
+ /* @__PURE__ */ jsx(
437
+ "div",
438
+ {
439
+ role: "group",
440
+ "aria-labelledby": "event-mode-label",
441
+ className: "flex flex-wrap items-center gap-1",
442
+ "data-test": "event-mode",
443
+ children: ["fixtures", "live"].map((mode) => /* @__PURE__ */ jsx(
444
+ Button,
445
+ {
446
+ type: "button",
447
+ size: "xs",
448
+ variant: state.mode === mode ? "secondary" : "ghost",
449
+ "aria-pressed": state.mode === mode,
450
+ onClick: () => setState({ ...state, mode }),
451
+ "data-test": `event-mode-${mode}`,
452
+ children: mode === "fixtures" ? "Fixtures: check the payload" : "Live: also run the handler"
453
+ },
454
+ mode
455
+ ))
456
+ }
457
+ )
458
+ ] }) : null,
459
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
460
+ /* @__PURE__ */ jsxs(
461
+ Button,
462
+ {
463
+ type: "button",
464
+ onClick: submit,
465
+ loading: emit.isPending,
466
+ "data-test": "emit-event",
467
+ children: [
468
+ /* @__PURE__ */ jsx(Icon, { name: "paper-plane-tilt" }),
469
+ "Send test event"
470
+ ]
471
+ }
472
+ ),
473
+ canChooseMode ? null : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: state.mode === "live" ? "Live: the webhook handler runs" : "Fixtures: the payload is checked, no handler runs" })
474
+ ] })
475
+ ] }),
476
+ emit.isError ? /* @__PURE__ */ jsxs(Alert, { variant: "destructive", "data-test": "event-error", children: [
477
+ /* @__PURE__ */ jsx(Icon, { name: "warning-circle" }),
478
+ /* @__PURE__ */ jsx(AlertTitle, { children: "The harness could not take the event" }),
479
+ /* @__PURE__ */ jsxs(AlertDescription, { children: [
480
+ emit.error.message,
481
+ ". Check that ",
482
+ /* @__PURE__ */ jsx("code", { children: "ekanos dev" }),
483
+ " is still running, then send it again."
484
+ ] })
485
+ ] }) : null,
486
+ result ? /* @__PURE__ */ jsx(
487
+ DeliveryResult,
488
+ {
489
+ result,
490
+ roundTripMs: state.roundTripMs,
491
+ runsHref: runLogHref(base, { event: event.name })
61
492
  }
62
- ),
63
- event.description ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: event.description }) : null
64
- ] }),
65
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
66
- /* @__PURE__ */ jsx(Label, { htmlFor: "event-payload", className: "text-sm font-medium", children: "Payload" }),
493
+ ) : null,
67
494
  /* @__PURE__ */ jsx(
68
- Textarea,
495
+ RecentDeliveries,
69
496
  {
70
- id: "event-payload",
71
- className: "font-mono",
72
- spellCheck: false,
73
- value: state.text,
74
- "aria-invalid": state.parseError ? true : void 0,
75
- onChange: (change) => setState({ ...state, text: change.target.value, parseError: null })
497
+ integration: integration.integration,
498
+ event: event.name,
499
+ base
76
500
  }
77
- ),
78
- state.parseError ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-destructive text-xs", children: state.parseError }) : null
79
- ] }),
80
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-3", children: /* @__PURE__ */ jsx(
81
- Button,
82
- {
83
- type: "button",
84
- onClick: submit,
85
- disabled: emit.isPending,
86
- "data-test": "emit-event",
87
- children: emit.isPending ? "Emitting\u2026" : "Emit"
88
- }
89
- ) }),
90
- emit.isError ? /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: /* @__PURE__ */ jsx(AlertDescription, { children: emit.error.message }) }) : null,
91
- result ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", "data-test": "event-result", children: [
92
- /* @__PURE__ */ jsx(StatusBadge, { tone: result.valid ? "success" : "destructive", children: result.valid ? "Payload valid" : "Payload invalid" }),
93
- result.issues.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "text-destructive list-disc pl-5 text-xs", children: result.issues.map((issue) => /* @__PURE__ */ jsxs("li", { children: [
94
- /* @__PURE__ */ jsx("code", { children: issue.path || "(root)" }),
95
- " ",
96
- issue.message
97
- ] }, `${issue.path}:${issue.message}`)) }) : null,
98
- result.outcome === "ran" ? /* @__PURE__ */ jsxs(Alert, { variant: "success", "data-test": "handler-ran", children: [
99
- /* @__PURE__ */ jsx(AlertTitle, { children: "The integration's handler ran" }),
100
- /* @__PURE__ */ jsx(AlertDescription, { children: result.detail ? /* @__PURE__ */ jsx("pre", { className: "mt-1 overflow-auto text-xs", children: result.detail }) : null })
101
- ] }) : /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: "Validated only: this integration does not run the integration's code." }),
102
- /* @__PURE__ */ jsxs("div", { "data-test": "matched-triggers", children: [
103
- /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: "Workflow triggers that would match" }),
104
- result.matchedTriggers.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: "None." }) : /* @__PURE__ */ jsx("ul", { className: "list-disc pl-5 text-sm", children: result.matchedTriggers.map((trigger) => /* @__PURE__ */ jsx("li", { children: trigger }, trigger)) })
105
- ] })
106
- ] }) : null
107
- ] });
501
+ )
502
+ ] })
503
+ ] }) });
108
504
  }
109
505
  export {
110
- EventsPanel
506
+ EventsPanel,
507
+ NoEvents
111
508
  };
@@ -8,7 +8,7 @@ import { type WidgetHealth, type WidgetRenderState } from '@ekanos/sdk/component
8
8
  *
9
9
  * WHY THIS EXISTS — the one symbol the harness could not import.
10
10
  *
11
- * `Widget.*` reads everything (render state, collapse/pin, title, ask config)
11
+ * `Widget.*` reads everything (render state, pin, title, ask config)
12
12
  * from `WidgetContext`, and something has to PROVIDE it. In the real app that is
13
13
  * `DashboardWidgetProvider`, which lives in the host's own package and is not
14
14
  * part of the published `@ekanos/sdk` surface — on purpose. It is coupled to
@@ -26,16 +26,16 @@ import { type WidgetHealth, type WidgetRenderState } from '@ekanos/sdk/component
26
26
  * provider that implements the same `WidgetContextValue` interface but
27
27
  * stores state locally only."
28
28
  *
29
- * That is precisely the harness: no database, so nothing to persist. Collapse
30
- * and pin toggle locally and reset on reload, which is correct harness
29
+ * That is precisely the harness: no database, so nothing to persist. Pin
30
+ * toggles locally and reset on reload, which is correct harness
31
31
  * behaviour and is what the host provider did here anyway once its optional
32
32
  * callbacks were omitted.
33
33
  *
34
34
  * Kept deliberately faithful in one non-obvious respect: the `isEnabled` and
35
35
  * `health` downgrade rules below are the host's, verbatim, because a widget's
36
36
  * `disabled` state is reached through them and a harness that resolved state
37
- * differently would show a state the product never shows. `pendingCollapse` /
38
- * `pendingPin` are always false — with no persistence callback there is never
37
+ * differently would show a state the product never shows. `pendingPin` is
38
+ * always false — with no persistence callback there is never
39
39
  * anything in flight, exactly as in the real grid when it passes none.
40
40
  */
41
41
  export interface HarnessWidgetProviderProps {
@@ -46,9 +46,7 @@ export interface HarnessWidgetProviderProps {
46
46
  className?: string;
47
47
  state: WidgetRenderState;
48
48
  isEnabled?: boolean;
49
- isCollapsible?: boolean;
50
49
  isPinnable?: boolean;
51
- defaultCollapsed?: boolean;
52
50
  defaultPinned?: boolean;
53
51
  maxContentHeight?: string;
54
52
  askContext?: WidgetAskContext;
@@ -57,4 +55,4 @@ export interface HarnessWidgetProviderProps {
57
55
  health?: WidgetHealth;
58
56
  children: ReactNode;
59
57
  }
60
- export declare function HarnessWidgetProvider({ widgetId, title, subtitle, description, className, state: renderState, isEnabled, isCollapsible, isPinnable, defaultCollapsed, defaultPinned, maxContentHeight, askContext, aiFooterEnabled, health, children, }: HarnessWidgetProviderProps): import("react").JSX.Element;
58
+ export declare function HarnessWidgetProvider({ widgetId, title, subtitle, description, className, state: renderState, isEnabled, isPinnable, defaultPinned, maxContentHeight, askContext, aiFooterEnabled, health, children, }: HarnessWidgetProviderProps): import("react").JSX.Element;