@ekanos/harness 0.17.0 → 0.19.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 (184) hide show
  1. package/dist/api-types.d.ts +490 -0
  2. package/dist/api-types.js +6 -0
  3. package/dist/api.d.ts +33 -0
  4. package/dist/api.js +36 -1
  5. package/dist/app.js +6 -1
  6. package/dist/internal/components/approvals-tray.d.ts +17 -0
  7. package/dist/internal/components/approvals-tray.js +116 -0
  8. package/dist/internal/components/connect-controls.d.ts +12 -0
  9. package/dist/internal/components/connect-controls.js +69 -0
  10. package/dist/internal/components/connect-dialog.d.ts +19 -0
  11. package/dist/internal/components/connect-dialog.js +61 -0
  12. package/dist/internal/components/connect-panel.d.ts +25 -0
  13. package/dist/internal/components/connect-panel.js +292 -0
  14. package/dist/internal/components/connection-chip.d.ts +14 -0
  15. package/dist/internal/components/connection-chip.js +75 -0
  16. package/dist/internal/components/dashboard-grid.js +38 -24
  17. package/dist/internal/components/dev-toolbar.js +176 -103
  18. package/dist/internal/components/events-panel.d.ts +10 -0
  19. package/dist/internal/components/events-panel.js +111 -0
  20. package/dist/internal/components/health-panel.d.ts +4 -0
  21. package/dist/internal/components/health-panel.js +56 -0
  22. package/dist/internal/components/integration-badge.d.ts +29 -0
  23. package/dist/internal/components/integration-badge.js +105 -0
  24. package/dist/internal/components/local-oauth-panel.js +21 -1
  25. package/dist/internal/components/operation-runner-panel.d.ts +12 -0
  26. package/dist/internal/components/operation-runner-panel.js +331 -0
  27. package/dist/internal/components/provenance-banner.d.ts +12 -0
  28. package/dist/internal/components/provenance-banner.js +107 -0
  29. package/dist/internal/components/repo-connection.d.ts +10 -0
  30. package/dist/internal/components/repo-connection.js +32 -0
  31. package/dist/internal/components/run-log.d.ts +9 -0
  32. package/dist/internal/components/run-log.js +228 -0
  33. package/dist/internal/components/runtime-strip.d.ts +12 -0
  34. package/dist/internal/components/runtime-strip.js +158 -0
  35. package/dist/internal/components/schema-form.d.ts +13 -0
  36. package/dist/internal/components/schema-form.js +382 -0
  37. package/dist/internal/components/scrollable-nav.d.ts +12 -0
  38. package/dist/internal/components/scrollable-nav.js +68 -0
  39. package/dist/internal/components/surface-nav.d.ts +31 -1
  40. package/dist/internal/components/surface-nav.js +238 -31
  41. package/dist/internal/components/workflow-runner.d.ts +14 -0
  42. package/dist/internal/components/workflow-runner.js +104 -0
  43. package/dist/internal/lib/bundled-secrets.d.ts +9 -0
  44. package/dist/internal/lib/bundled-secrets.js +24 -0
  45. package/dist/internal/lib/chrome-slot.d.ts +2 -0
  46. package/dist/internal/lib/chrome-slot.js +25 -0
  47. package/dist/internal/lib/connection-facts.d.ts +44 -0
  48. package/dist/internal/lib/connection-facts.js +116 -0
  49. package/dist/internal/lib/console-client.d.ts +55 -0
  50. package/dist/internal/lib/console-client.js +295 -0
  51. package/dist/internal/lib/console-context.d.ts +40 -0
  52. package/dist/internal/lib/console-context.js +67 -0
  53. package/dist/internal/lib/console-hooks.d.ts +33 -0
  54. package/dist/internal/lib/console-hooks.js +118 -0
  55. package/dist/internal/lib/console-types.d.ts +279 -0
  56. package/dist/internal/lib/console-types.js +0 -0
  57. package/dist/internal/lib/experience-runtime.d.ts +8 -0
  58. package/dist/internal/lib/experience-runtime.js +22 -0
  59. package/dist/internal/lib/preview-sections.d.ts +13 -0
  60. package/dist/internal/lib/preview-sections.js +32 -0
  61. package/dist/internal/lib/repo-context.d.ts +20 -0
  62. package/dist/internal/lib/repo-context.js +64 -0
  63. package/dist/internal/lib/run-log-view.d.ts +24 -0
  64. package/dist/internal/lib/run-log-view.js +57 -0
  65. package/dist/internal/lib/schema-form-model.d.ts +34 -0
  66. package/dist/internal/lib/schema-form-model.js +272 -0
  67. package/dist/internal/lib/toolbar-context.d.ts +9 -1
  68. package/dist/internal/lib/toolbar-context.js +13 -3
  69. package/dist/internal/lib/toolbar-visibility.d.ts +16 -0
  70. package/dist/internal/lib/toolbar-visibility.js +31 -0
  71. package/dist/internal/registry-context.d.ts +2 -0
  72. package/dist/internal/registry-context.js +11 -9
  73. package/dist/internal/routes/activation-page.js +44 -20
  74. package/dist/internal/routes/console-home-page.d.ts +5 -0
  75. package/dist/internal/routes/console-home-page.js +18 -0
  76. package/dist/internal/routes/experience-connect-page.d.ts +6 -0
  77. package/dist/internal/routes/experience-connect-page.js +127 -0
  78. package/dist/internal/routes/experience-page-host.d.ts +2 -0
  79. package/dist/internal/routes/experience-page-host.js +18 -0
  80. package/dist/internal/routes/experience-review-queue-page.d.ts +2 -0
  81. package/dist/internal/routes/experience-review-queue-page.js +60 -0
  82. package/dist/internal/routes/experience-runs-page.d.ts +1 -0
  83. package/dist/internal/routes/experience-runs-page.js +13 -0
  84. package/dist/internal/routes/experience-summary-page.d.ts +1 -0
  85. package/dist/internal/routes/experience-summary-page.js +101 -0
  86. package/dist/internal/routes/experience-widget-page.d.ts +1 -0
  87. package/dist/internal/routes/experience-widget-page.js +26 -0
  88. package/dist/internal/routes/experience-widgets-page.d.ts +6 -0
  89. package/dist/internal/routes/experience-widgets-page.js +22 -0
  90. package/dist/internal/routes/experience-workflow-page.d.ts +1 -0
  91. package/dist/internal/routes/experience-workflow-page.js +24 -0
  92. package/dist/internal/routes/experience-workflows-page.d.ts +1 -0
  93. package/dist/internal/routes/experience-workflows-page.js +44 -0
  94. package/dist/internal/routes/index-page.d.ts +10 -9
  95. package/dist/internal/routes/index-page.js +3 -68
  96. package/dist/internal/routes/integration-layout.d.ts +12 -1
  97. package/dist/internal/routes/integration-layout.js +20 -6
  98. package/dist/internal/routes/integrations-connect-page.d.ts +1 -0
  99. package/dist/internal/routes/integrations-connect-page.js +19 -0
  100. package/dist/internal/routes/integrations-events-page.d.ts +1 -0
  101. package/dist/internal/routes/integrations-events-page.js +10 -0
  102. package/dist/internal/routes/integrations-health-page.d.ts +1 -0
  103. package/dist/internal/routes/integrations-health-page.js +10 -0
  104. package/dist/internal/routes/integrations-layout.d.ts +17 -0
  105. package/dist/internal/routes/integrations-layout.js +106 -0
  106. package/dist/internal/routes/integrations-list-page.d.ts +2 -0
  107. package/dist/internal/routes/integrations-list-page.js +94 -0
  108. package/dist/internal/routes/integrations-operation-page.d.ts +1 -0
  109. package/dist/internal/routes/integrations-operation-page.js +29 -0
  110. package/dist/internal/routes/integrations-operations-page.d.ts +1 -0
  111. package/dist/internal/routes/integrations-operations-page.js +61 -0
  112. package/dist/internal/routes/integrations-overview-page.d.ts +1 -0
  113. package/dist/internal/routes/integrations-overview-page.js +90 -0
  114. package/dist/internal/routes/integrations-runs-page.d.ts +1 -0
  115. package/dist/internal/routes/integrations-runs-page.js +14 -0
  116. package/dist/internal/routes/integrations-scope.d.ts +12 -0
  117. package/dist/internal/routes/integrations-scope.js +39 -0
  118. package/dist/internal/routes/legacy-preview-redirect.d.ts +6 -0
  119. package/dist/internal/routes/legacy-preview-redirect.js +12 -0
  120. package/dist/internal/routes/preview-index-page.d.ts +2 -0
  121. package/dist/internal/routes/preview-index-page.js +14 -0
  122. package/dist/internal/routes/repo-connections-page.d.ts +6 -0
  123. package/dist/internal/routes/repo-connections-page.js +8 -0
  124. package/dist/internal/routes/repo-home-page.d.ts +2 -0
  125. package/dist/internal/routes/repo-home-page.js +320 -0
  126. package/dist/internal/routes/repo-layout.d.ts +7 -0
  127. package/dist/internal/routes/repo-layout.js +76 -0
  128. package/dist/internal/routes/repo-package-layouts.d.ts +20 -0
  129. package/dist/internal/routes/repo-package-layouts.js +104 -0
  130. package/dist/internal/routes/root-layout.d.ts +3 -1
  131. package/dist/internal/routes/root-layout.js +13 -3
  132. package/dist/internal/routes/single-widget-page.js +5 -12
  133. package/dist/internal/routes/tile-page.js +20 -41
  134. package/dist/internal/routes/triggers-page.js +55 -62
  135. package/dist/internal/routes/widgets-page.js +1 -1
  136. package/dist/internal/server/api-router.js +46 -4
  137. package/dist/internal/server/approvals.d.ts +44 -0
  138. package/dist/internal/server/approvals.js +76 -0
  139. package/dist/internal/server/contract-sources.d.ts +28 -0
  140. package/dist/internal/server/contract-sources.js +83 -0
  141. package/dist/internal/server/definition-loader.d.ts +22 -0
  142. package/dist/internal/server/definition-loader.js +125 -0
  143. package/dist/internal/server/ekanos-api-router.d.ts +34 -0
  144. package/dist/internal/server/ekanos-api-router.js +835 -0
  145. package/dist/internal/server/experience-loader.d.ts +57 -0
  146. package/dist/internal/server/experience-loader.js +146 -0
  147. package/dist/internal/server/integration-lookup.d.ts +29 -0
  148. package/dist/internal/server/integration-lookup.js +33 -0
  149. package/dist/internal/server/integration-resolver.d.ts +121 -0
  150. package/dist/internal/server/integration-resolver.js +605 -0
  151. package/dist/internal/server/live-invoker.d.ts +11 -0
  152. package/dist/internal/server/live-invoker.js +106 -0
  153. package/dist/internal/server/local-secrets.d.ts +82 -1
  154. package/dist/internal/server/local-secrets.js +112 -1
  155. package/dist/internal/server/local-state.d.ts +12 -0
  156. package/dist/internal/server/local-state.js +45 -0
  157. package/dist/internal/server/oauth-persistence.d.ts +19 -0
  158. package/dist/internal/server/oauth-persistence.js +76 -0
  159. package/dist/internal/server/operation-runner.d.ts +95 -0
  160. package/dist/internal/server/operation-runner.js +231 -0
  161. package/dist/internal/server/project-manifest.d.ts +71 -0
  162. package/dist/internal/server/project-manifest.js +215 -0
  163. package/dist/internal/server/registry-cache.d.ts +68 -0
  164. package/dist/internal/server/registry-cache.js +328 -0
  165. package/dist/internal/server/repo-api-router.d.ts +33 -0
  166. package/dist/internal/server/repo-api-router.js +391 -0
  167. package/dist/internal/server/run-log.d.ts +22 -0
  168. package/dist/internal/server/run-log.js +32 -0
  169. package/dist/internal/server/semantics.d.ts +28 -0
  170. package/dist/internal/server/semantics.js +67 -0
  171. package/dist/internal/server/session-catalog.d.ts +67 -0
  172. package/dist/internal/server/session-catalog.js +18 -0
  173. package/dist/internal/server/workflow-runner.d.ts +36 -0
  174. package/dist/internal/server/workflow-runner.js +183 -0
  175. package/dist/registry.d.ts +7 -0
  176. package/dist/resolver.d.ts +145 -0
  177. package/dist/resolver.js +211 -0
  178. package/dist/routes.d.ts +64 -2
  179. package/dist/routes.js +59 -3
  180. package/dist/runtime.d.ts +46 -0
  181. package/dist/runtime.js +60 -0
  182. package/package.json +30 -16
  183. package/dist/internal/routes/integration-index-page.d.ts +0 -13
  184. package/dist/internal/routes/integration-index-page.js +0 -17
@@ -0,0 +1,29 @@
1
+ import type { ConsoleIntegration, RunMode, IntegrationProvenance } from '../lib/console-types.js';
2
+ export declare function shortDigest(digest: string): string;
3
+ /** A local provenance path as the UI shows it: repo-relative when inside the repo. */
4
+ export declare function provenanceDisplayPath(provenance: IntegrationProvenance): string;
5
+ /** The one-line "resolved from" text; the absolute path rides in a tooltip. */
6
+ export declare function describeProvenance(provenance: IntegrationProvenance): string;
7
+ /** The absolute path behind a local provenance, for a `title` tooltip. */
8
+ export declare function provenanceTitle(provenance: IntegrationProvenance): string;
9
+ /**
10
+ * The provenance badge. Only a real override of a registry version is a
11
+ * warning; running from this repo, and the registry, are quiet outlines.
12
+ */
13
+ export declare function ProvenanceBadge({ provenance, own, className, }: {
14
+ provenance: IntegrationProvenance;
15
+ /** This project's own integration: local, but nothing is overridden. */
16
+ own?: boolean;
17
+ className?: string;
18
+ }): import("react").JSX.Element;
19
+ export declare function RunModeBadge({ mode }: {
20
+ mode: RunMode;
21
+ }): import("react").JSX.Element;
22
+ /**
23
+ * An integration reference everywhere it appears: integration name, provenance badge, and a
24
+ * link to that integration's console.
25
+ */
26
+ export declare function IntegrationBadge({ integration, linked, }: {
27
+ integration: ConsoleIntegration;
28
+ linked?: boolean;
29
+ }): import("react").JSX.Element;
@@ -0,0 +1,105 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import Link from "next/link";
4
+ import { Badge } from "@ekanos/ui/badge";
5
+ import { Icon } from "@ekanos/ui/icon";
6
+ import { cn } from "@ekanos/ui/utils";
7
+ function shortDigest(digest) {
8
+ return `${digest.replace(/^sha256:/, "").slice(0, 6)}\u2026`;
9
+ }
10
+ function provenanceDisplayPath(provenance) {
11
+ return provenance.kind === "local" ? provenance.relPath ?? provenance.path : "";
12
+ }
13
+ function describeProvenance(provenance) {
14
+ if (provenance.kind === "local" && provenance.scope === "repo") {
15
+ return `Local \xB7 this repo \xB7 ${provenanceDisplayPath(provenance)} (v${provenance.packageVersion})`;
16
+ }
17
+ if (provenance.kind === "local") {
18
+ return `Local override \xB7 ${provenanceDisplayPath(provenance)} (v${provenance.packageVersion})`;
19
+ }
20
+ const where = `${provenance.source} ${provenance.origin}`;
21
+ return provenance.stale ? `Registry (${where}) \xB7 stale snapshot` : `Registry (${where})`;
22
+ }
23
+ function provenanceTitle(provenance) {
24
+ return provenance.kind === "local" ? `${describeProvenance(provenance)}
25
+ ${provenance.path}` : describeProvenance(provenance);
26
+ }
27
+ function ProvenanceBadge({
28
+ provenance,
29
+ own = false,
30
+ className
31
+ }) {
32
+ const thisRepo = provenance.kind === "local" && provenance.scope === "repo";
33
+ const override = provenance.kind === "local" && !thisRepo && !own;
34
+ return /* @__PURE__ */ jsxs(
35
+ "span",
36
+ {
37
+ "data-test": "provenance-badge",
38
+ "data-provenance": thisRepo ? "repo" : provenance.kind,
39
+ title: provenanceTitle(provenance),
40
+ className: cn(
41
+ "text-fine inline-flex h-6 w-fit shrink-0 items-center gap-1 rounded-full px-2 font-semibold tracking-wide whitespace-nowrap",
42
+ override ? "bg-warning text-warning-foreground" : "text-foreground border",
43
+ className
44
+ ),
45
+ children: [
46
+ /* @__PURE__ */ jsx(
47
+ Icon,
48
+ {
49
+ name: override ? "fa-solid fa-triangle-exclamation" : thisRepo || own ? "fa-solid fa-code-branch" : "fa-solid fa-cloud",
50
+ className: "h-3 w-3"
51
+ }
52
+ ),
53
+ thisRepo ? "Local \xB7 this repo" : provenance.kind === "local" ? "Local" : "Registry",
54
+ provenance.kind === "registry" && provenance.stale ? " \xB7 stale" : ""
55
+ ]
56
+ }
57
+ );
58
+ }
59
+ function RunModeBadge({ mode }) {
60
+ return /* @__PURE__ */ jsx(
61
+ Badge,
62
+ {
63
+ variant: "secondary",
64
+ "data-test": "run-mode-badge",
65
+ "data-mode": mode,
66
+ className: "h-6",
67
+ children: mode === "live" ? "Live" : "Fixtures"
68
+ }
69
+ );
70
+ }
71
+ function IntegrationBadge({
72
+ integration,
73
+ linked = true
74
+ }) {
75
+ const label = /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
76
+ /* @__PURE__ */ jsx("code", { className: "text-label", children: integration.integration }),
77
+ /* @__PURE__ */ jsx(
78
+ ProvenanceBadge,
79
+ {
80
+ provenance: integration.provenance,
81
+ own: integration.own === true
82
+ }
83
+ )
84
+ ] });
85
+ if (!linked)
86
+ return /* @__PURE__ */ jsx("span", { "data-test": `integration-badge-${integration.integration}`, children: label });
87
+ return /* @__PURE__ */ jsx(
88
+ Link,
89
+ {
90
+ href: `/integrations/${integration.integration}`,
91
+ "data-test": `integration-badge-${integration.integration}`,
92
+ className: "hover:bg-accent/50 -mx-1 inline-flex rounded-md px-1 py-0.5 transition-colors",
93
+ children: label
94
+ }
95
+ );
96
+ }
97
+ export {
98
+ IntegrationBadge,
99
+ ProvenanceBadge,
100
+ RunModeBadge,
101
+ describeProvenance,
102
+ provenanceDisplayPath,
103
+ provenanceTitle,
104
+ shortDigest
105
+ };
@@ -19,10 +19,12 @@ import { useForm } from "react-hook-form";
19
19
  import {
20
20
  resolveOAuthConnected
21
21
  } from "../../registry.js";
22
+ import { deriveConnectionFacts } from "../lib/connection-facts.js";
22
23
  import {
23
24
  buildOAuthSetupGuide
24
25
  } from "../lib/oauth-setup-guide.js";
25
26
  import { fetchLocalSetup, saveLocalSetup } from "../lib/trigger-runner.js";
27
+ import { ConnectionChip } from "./connection-chip.js";
26
28
  function LocalOAuthPanel({
27
29
  integration,
28
30
  definition,
@@ -50,7 +52,25 @@ function LocalOAuthPanel({
50
52
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
51
53
  /* @__PURE__ */ jsx("h3", { className: "text-subhead", children: "Local OAuth" }),
52
54
  /* @__PURE__ */ jsx(Badge, { variant: "outline", children: live ? "live" : "fixtures" }),
53
- live && setup.data ? /* @__PURE__ */ jsx(Badge, { variant: setup.data.connected ? "default" : "secondary", children: setup.data.connected ? "connected" : "not connected" }) : null
55
+ live && setup.data ? /* @__PURE__ */ jsx(
56
+ ConnectionChip,
57
+ {
58
+ facts: deriveConnectionFacts({
59
+ contractAuth: "oauth2",
60
+ usesOauth: true,
61
+ declared: [],
62
+ missing: [],
63
+ activationFieldsSet: [],
64
+ oauthHeld: setup.data.connected,
65
+ manageable: true,
66
+ target: [],
67
+ supportsLive: true,
68
+ forced: false,
69
+ defaultMode: "live"
70
+ }),
71
+ showTarget: false
72
+ }
73
+ ) : null
54
74
  ] }),
55
75
  setup.isPending ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: "Reading local setup\u2026" }) : setup.isError ? /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
56
76
  /* @__PURE__ */ jsx(AlertTitle, { children: "The harness API did not answer" }),
@@ -0,0 +1,12 @@
1
+ import type { ConsoleOperation, ConsoleIntegration, UsedBy } from '../lib/console-types.js';
2
+ export declare function operationKey(operation: ConsoleOperation): string;
3
+ /**
4
+ * Run one contract operation: a schema-driven form (or raw JSON), a
5
+ * fixtures/live choice where the integration allows it, and the result with its
6
+ * validation badge. A write returns an approval request that is decided here.
7
+ */
8
+ export declare function OperationRunnerPanel({ integration, operation, usedBy, }: {
9
+ integration: ConsoleIntegration;
10
+ operation: ConsoleOperation;
11
+ usedBy?: UsedBy[];
12
+ }): import("react").JSX.Element;
@@ -0,0 +1,331 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { Alert, AlertDescription, AlertTitle } from "@ekanos/ui/alert";
5
+ import { Badge } from "@ekanos/ui/badge";
6
+ import { Button } from "@ekanos/ui/button";
7
+ import { StatusBadge } from "@ekanos/ui/status-badge";
8
+ import { Switch } from "@ekanos/ui/switch";
9
+ import { Textarea } from "@ekanos/ui/textarea";
10
+ import { useRunOperation, useRuns } from "../lib/console-hooks.js";
11
+ import {
12
+ formatJson,
13
+ initialValue,
14
+ parseJsonText,
15
+ validateValue
16
+ } from "../lib/schema-form-model.js";
17
+ import { RunModeBadge } from "./integration-badge.js";
18
+ import { SchemaForm } from "./schema-form.js";
19
+ const VARIANTS = ["default", "empty", "error"];
20
+ function operationKey(operation) {
21
+ return `${operation.kind}/${operation.name}`;
22
+ }
23
+ function Segmented({
24
+ label,
25
+ options,
26
+ value,
27
+ onChange,
28
+ disabledReason
29
+ }) {
30
+ return /* @__PURE__ */ jsx(
31
+ "div",
32
+ {
33
+ role: "group",
34
+ "aria-label": label,
35
+ className: "inline-flex gap-0.5 rounded-md border p-0.5",
36
+ children: options.map((option) => {
37
+ const reason = disabledReason?.(option) ?? null;
38
+ const active = option === value;
39
+ return /* @__PURE__ */ jsx(
40
+ Button,
41
+ {
42
+ type: "button",
43
+ size: "sm",
44
+ variant: active ? "default" : "ghost",
45
+ disabled: reason !== null,
46
+ title: reason ?? void 0,
47
+ "aria-pressed": active,
48
+ "data-test": `${label.toLowerCase()}-${option}`,
49
+ onClick: () => onChange(option),
50
+ className: "capitalize",
51
+ children: option
52
+ },
53
+ option
54
+ );
55
+ })
56
+ }
57
+ );
58
+ }
59
+ function ResultPane({
60
+ response,
61
+ operation
62
+ }) {
63
+ const runs = useRuns();
64
+ const record = runs.data?.find((entry) => entry.id === response.runId);
65
+ const refused = response.status === "refused";
66
+ const validated = !operation.opaque.output;
67
+ return /* @__PURE__ */ jsxs(
68
+ "div",
69
+ {
70
+ className: "flex flex-col gap-3",
71
+ "data-test": "run-result",
72
+ "data-status": response.status,
73
+ children: [
74
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
75
+ /* @__PURE__ */ jsx(StatusBadge, { tone: refused ? "destructive" : "success", children: refused ? `Refused \xB7 ${response.reason}` : "OK" }),
76
+ refused ? null : /* @__PURE__ */ jsx(
77
+ Badge,
78
+ {
79
+ variant: "outline",
80
+ "data-test": "output-validated",
81
+ "data-validated": validated,
82
+ children: validated ? "Output validated against contract" : "Output not validated (opaque)"
83
+ }
84
+ ),
85
+ record?.mode ? /* @__PURE__ */ jsx(RunModeBadge, { mode: record.mode }) : null,
86
+ record ? /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-fine", children: [
87
+ record.durationMs,
88
+ " ms \xB7 in ",
89
+ record.inputBytes,
90
+ " B \xB7 out",
91
+ " ",
92
+ record.outputBytes,
93
+ " B"
94
+ ] }) : null,
95
+ /* @__PURE__ */ jsxs(
96
+ "span",
97
+ {
98
+ className: "text-muted-foreground text-fine",
99
+ "data-test": "run-record-id",
100
+ children: [
101
+ "run ",
102
+ response.runId
103
+ ]
104
+ }
105
+ )
106
+ ] }),
107
+ refused ? /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
108
+ /* @__PURE__ */ jsx(AlertTitle, { children: response.reason }),
109
+ /* @__PURE__ */ jsxs(AlertDescription, { children: [
110
+ /* @__PURE__ */ jsx("p", { children: response.message }),
111
+ response.issues && response.issues.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "mt-2 list-disc pl-5", "data-test": "server-issues", children: response.issues.map((issue) => /* @__PURE__ */ jsxs("li", { children: [
112
+ /* @__PURE__ */ jsx("code", { children: issue.path || "(root)" }),
113
+ " ",
114
+ issue.message
115
+ ] }, `${issue.path}:${issue.message}`)) }) : null
116
+ ] })
117
+ ] }) : /* @__PURE__ */ jsx(
118
+ "pre",
119
+ {
120
+ className: "bg-muted text-fine max-h-96 overflow-auto rounded-md p-3",
121
+ "data-test": "run-output",
122
+ children: JSON.stringify(response.output, null, 2)
123
+ }
124
+ )
125
+ ]
126
+ }
127
+ );
128
+ }
129
+ function startMode(integration, effect) {
130
+ const facts = integration.runtime?.facts;
131
+ if (facts?.forced) return "fixtures";
132
+ return effect === "read" && facts?.answers === "live" ? "live" : integration.defaultMode;
133
+ }
134
+ function OperationRunnerPanel({
135
+ integration,
136
+ operation,
137
+ usedBy = []
138
+ }) {
139
+ const run = useRunOperation();
140
+ const [state, setState] = useState(() => {
141
+ const value = initialValue(operation.input);
142
+ return {
143
+ // Reads start on what the connection facts say a call that names no mode
144
+ // answers from (live for a connected integration, or one that needs no
145
+ // connection); everything else starts as configured.
146
+ mode: startMode(integration, operation.effect),
147
+ variant: "default",
148
+ raw: false,
149
+ value,
150
+ rawText: formatJson(value),
151
+ rawError: null,
152
+ attempted: false,
153
+ response: null,
154
+ runError: null
155
+ };
156
+ });
157
+ const patch = (next) => setState((current) => ({ ...current, ...next }));
158
+ const response = state.response;
159
+ const awaiting = run.isPending && operation.effect === "write";
160
+ const clientIssues = state.attempted ? validateValue(operation.input, state.value) : [];
161
+ const serverIssues = response?.status === "refused" ? response.issues ?? [] : [];
162
+ const issues = serverIssues.length > 0 ? serverIssues : clientIssues;
163
+ const execute = () => {
164
+ if (state.rawError) return;
165
+ patch({ attempted: true, response: null, runError: null });
166
+ run.mutate(
167
+ {
168
+ integration: integration.integration,
169
+ opKey: operationKey(operation),
170
+ args: state.value,
171
+ mode: state.mode,
172
+ ...state.mode === "fixtures" ? { variant: state.variant } : {},
173
+ channel: "http",
174
+ origin: "console"
175
+ },
176
+ {
177
+ onSuccess: (next) => patch({ response: next }),
178
+ onError: (error) => patch({ runError: error.message })
179
+ }
180
+ );
181
+ };
182
+ const liveReason = (option) => option === "live" && !integration.runModes.includes("live") ? integration.fixturesOnlyReason ?? "This integration is fixtures-only." : null;
183
+ return /* @__PURE__ */ jsxs("section", { className: "flex flex-col gap-6", "data-test": "operation-runner", children: [
184
+ /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-2", children: [
185
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
186
+ /* @__PURE__ */ jsx("h2", { className: "heading-subhead-lg font-normal", children: /* @__PURE__ */ jsx("code", { children: operationKey(operation) }) }),
187
+ /* @__PURE__ */ jsx(StatusBadge, { tone: operation.effect === "write" ? "warning" : "info", children: operation.effect })
188
+ ] }),
189
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: operation.description }),
190
+ usedBy.length > 0 ? /* @__PURE__ */ jsxs("p", { className: "text-fine", "data-test": "used-by", children: [
191
+ "Used by:",
192
+ " ",
193
+ usedBy.map((use) => `${use.title} (${use.kind})`).join(", ")
194
+ ] }) : null,
195
+ operation.opaque.input || operation.opaque.output ? /* @__PURE__ */ jsxs(
196
+ "p",
197
+ {
198
+ className: "text-muted-foreground text-fine",
199
+ "data-test": "opaque-note",
200
+ children: [
201
+ "Opaque ",
202
+ operation.opaque.input ? "input" : "",
203
+ operation.opaque.input && operation.opaque.output ? " and " : "",
204
+ operation.opaque.output ? "output" : "",
205
+ operation.opaqueReason ? `: ${operation.opaqueReason}` : ""
206
+ ]
207
+ }
208
+ ) : null
209
+ ] }),
210
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-4", children: [
211
+ /* @__PURE__ */ jsx(
212
+ Segmented,
213
+ {
214
+ label: "Mode",
215
+ options: ["fixtures", "live"],
216
+ value: state.mode,
217
+ onChange: (mode) => patch({ mode }),
218
+ disabledReason: liveReason
219
+ }
220
+ ),
221
+ state.mode === "fixtures" ? /* @__PURE__ */ jsx(
222
+ Segmented,
223
+ {
224
+ label: "Variant",
225
+ options: VARIANTS,
226
+ value: state.variant,
227
+ onChange: (variant) => patch({ variant })
228
+ }
229
+ ) : null,
230
+ /* @__PURE__ */ jsxs("label", { className: "text-label flex items-center gap-2", children: [
231
+ /* @__PURE__ */ jsx(
232
+ Switch,
233
+ {
234
+ checked: state.raw,
235
+ "data-test": "raw-json-toggle",
236
+ onCheckedChange: (raw) => patch({
237
+ raw,
238
+ rawText: formatJson(state.value),
239
+ rawError: null
240
+ })
241
+ }
242
+ ),
243
+ "Raw JSON"
244
+ ] })
245
+ ] }),
246
+ integration.runtime?.facts.forced ? /* @__PURE__ */ jsx(
247
+ "p",
248
+ {
249
+ className: "text-muted-foreground text-fine",
250
+ "data-test": "fixtures-pinned",
251
+ children: "Fixtures \xB7 pinned. Saved for this repo; unpin it from the integrations strip to read live again."
252
+ }
253
+ ) : null,
254
+ integration.runModes.includes("live") ? null : /* @__PURE__ */ jsx(
255
+ "p",
256
+ {
257
+ className: "text-muted-foreground text-fine",
258
+ "data-test": "fixtures-only",
259
+ children: integration.fixturesOnlyReason ?? "This integration is fixtures-only: it answers from the contract example and scenario fixtures."
260
+ }
261
+ ),
262
+ state.raw ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", "data-test": "raw-editor", children: [
263
+ /* @__PURE__ */ jsx(
264
+ Textarea,
265
+ {
266
+ className: "font-mono",
267
+ spellCheck: false,
268
+ "aria-label": "Raw JSON input",
269
+ value: state.rawText,
270
+ "aria-invalid": state.rawError ? true : void 0,
271
+ onChange: (event) => {
272
+ const rawText = event.target.value;
273
+ const parsed = parseJsonText(rawText);
274
+ patch(
275
+ parsed.ok ? { rawText, rawError: null, value: parsed.value } : { rawText, rawError: parsed.error }
276
+ );
277
+ }
278
+ }
279
+ ),
280
+ state.rawError ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-destructive-strong text-fine", children: state.rawError }) : null,
281
+ issues.map((issue) => /* @__PURE__ */ jsxs(
282
+ "p",
283
+ {
284
+ className: "text-destructive-strong text-fine",
285
+ children: [
286
+ /* @__PURE__ */ jsx("code", { children: issue.path || "(root)" }),
287
+ " ",
288
+ issue.message
289
+ ]
290
+ },
291
+ `${issue.path}:${issue.message}`
292
+ ))
293
+ ] }) : /* @__PURE__ */ jsx(
294
+ SchemaForm,
295
+ {
296
+ schema: operation.input,
297
+ value: state.value,
298
+ onChange: (value) => patch({ value }),
299
+ issues
300
+ }
301
+ ),
302
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-3", children: /* @__PURE__ */ jsx(
303
+ Button,
304
+ {
305
+ type: "button",
306
+ onClick: execute,
307
+ disabled: run.isPending || state.rawError !== null,
308
+ "data-test": "run-operation",
309
+ children: run.isPending ? "Running\u2026" : operation.effect === "write" ? "Run (needs approval)" : "Run"
310
+ }
311
+ ) }),
312
+ state.runError ? /* @__PURE__ */ jsx(Alert, { variant: "destructive", "data-test": "run-error", children: /* @__PURE__ */ jsx(AlertDescription, { children: state.runError }) }) : null,
313
+ awaiting ? /* @__PURE__ */ jsxs(Alert, { variant: "warning", "data-test": "inline-approval", children: [
314
+ /* @__PURE__ */ jsx(AlertTitle, { children: "Awaiting approval" }),
315
+ /* @__PURE__ */ jsx(AlertDescription, { children: /* @__PURE__ */ jsxs("p", { children: [
316
+ "This is a write. Approve ",
317
+ /* @__PURE__ */ jsx("code", { children: operationKey(operation) }),
318
+ " in the approvals tray above to run it."
319
+ ] }) })
320
+ ] }) : null,
321
+ response ? /* @__PURE__ */ jsx(ResultPane, { response, operation }) : null,
322
+ response === null && operation.outputExample !== void 0 ? /* @__PURE__ */ jsxs("details", { className: "text-fine", "data-test": "example-output", children: [
323
+ /* @__PURE__ */ jsx("summary", { className: "text-muted-foreground cursor-pointer", children: "Contract example output" }),
324
+ /* @__PURE__ */ jsx("pre", { className: "bg-muted mt-2 max-h-60 overflow-auto rounded-md p-3", children: JSON.stringify(operation.outputExample, null, 2) })
325
+ ] }) : null
326
+ ] });
327
+ }
328
+ export {
329
+ OperationRunnerPanel,
330
+ operationKey
331
+ };
@@ -0,0 +1,12 @@
1
+ import type { ConsoleIntegration } from '../lib/console-types.js';
2
+ export declare function localIntegrations(integrations: readonly ConsoleIntegration[]): ConsoleIntegration[];
3
+ /** What the unblocked banner says: how many integrations run from this repo, how many from the registry. */
4
+ export declare function publishedSummary(integrations: readonly ConsoleIntegration[]): string;
5
+ /**
6
+ * Portals into the toolbar's sticky strip when one is mounted, so the banner
7
+ * sits above the toolbar inside the same sticky box; renders in place when
8
+ * there is no toolbar (tests, an embedded console).
9
+ */
10
+ export declare function ProvenanceBanner({ integrations, }: {
11
+ integrations: readonly ConsoleIntegration[];
12
+ }): import("react").JSX.Element;
@@ -0,0 +1,107 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { createPortal } from "react-dom";
4
+ import { Alert, AlertDescription, AlertTitle } from "@ekanos/ui/alert";
5
+ import { Icon } from "@ekanos/ui/icon";
6
+ import { useChromeSlot } from "../lib/chrome-slot.js";
7
+ import { describeProvenance, shortDigest } from "./integration-badge.js";
8
+ function localIntegrations(integrations) {
9
+ return integrations.filter(
10
+ (integration) => integration.provenance.kind === "local" && integration.provenance.scope !== "repo" && !integration.own
11
+ );
12
+ }
13
+ function plural(count) {
14
+ return `${count} integration${count === 1 ? "" : "s"}`;
15
+ }
16
+ function publishedSummary(integrations) {
17
+ if (integrations.length === 0) return "No integrations.";
18
+ if (integrations.every((integration) => integration.own)) {
19
+ return "Running from this repo.";
20
+ }
21
+ const inRepo = integrations.filter(
22
+ (integration) => integration.provenance.kind === "local" && integration.provenance.scope === "repo"
23
+ ).length;
24
+ const fromRegistry = integrations.length - inRepo;
25
+ if (inRepo === 0) {
26
+ return `All ${plural(integrations.length)} resolved from the registry.`;
27
+ }
28
+ if (fromRegistry === 0) {
29
+ return "Running from this repo.";
30
+ }
31
+ return `${plural(inRepo)} run from this repo, ${fromRegistry} resolved from the registry.`;
32
+ }
33
+ function BannerBody({
34
+ integrations
35
+ }) {
36
+ const locals = localIntegrations(integrations);
37
+ if (locals.length === 0) {
38
+ return /* @__PURE__ */ jsxs(
39
+ "p",
40
+ {
41
+ className: "text-muted-foreground text-fine flex items-center gap-2 border-b px-6 py-2",
42
+ "data-test": "provenance-banner",
43
+ "data-state": "published",
44
+ children: [
45
+ /* @__PURE__ */ jsx(Icon, { name: "fa-solid fa-cloud", className: "h-3 w-3" }),
46
+ publishedSummary(integrations)
47
+ ]
48
+ }
49
+ );
50
+ }
51
+ return /* @__PURE__ */ jsxs(
52
+ Alert,
53
+ {
54
+ variant: "warning",
55
+ className: "rounded-none border-x-0 border-t-0",
56
+ "data-test": "provenance-banner",
57
+ "data-state": "unpublishable",
58
+ children: [
59
+ /* @__PURE__ */ jsx(Icon, { name: "fa-solid fa-triangle-exclamation", className: "h-4 w-4" }),
60
+ /* @__PURE__ */ jsxs(AlertTitle, { children: [
61
+ locals.length,
62
+ " local override",
63
+ locals.length === 1 ? "" : "s",
64
+ " active: publish is blocked"
65
+ ] }),
66
+ /* @__PURE__ */ jsxs(AlertDescription, { children: [
67
+ /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-1", children: locals.map((integration) => /* @__PURE__ */ jsxs(
68
+ "li",
69
+ {
70
+ "data-test": `override-${integration.integration}`,
71
+ children: [
72
+ /* @__PURE__ */ jsx("code", { children: integration.integration }),
73
+ " ",
74
+ "->",
75
+ " ",
76
+ describeProvenance(integration.provenance),
77
+ " \xB7 contract",
78
+ " ",
79
+ integration.provenance.contractVersion,
80
+ " ",
81
+ shortDigest(integration.provenance.digest)
82
+ ]
83
+ },
84
+ integration.integration
85
+ )) }),
86
+ /* @__PURE__ */ jsxs("p", { className: "mt-1", children: [
87
+ "Delete ",
88
+ /* @__PURE__ */ jsx("code", { children: "ekanos.local.json" }),
89
+ " to publish against the registry."
90
+ ] })
91
+ ] })
92
+ ]
93
+ }
94
+ );
95
+ }
96
+ function ProvenanceBanner({
97
+ integrations
98
+ }) {
99
+ const integration = useChromeSlot();
100
+ const body = /* @__PURE__ */ jsx(BannerBody, { integrations });
101
+ return integration ? createPortal(body, integration) : body;
102
+ }
103
+ export {
104
+ ProvenanceBanner,
105
+ localIntegrations,
106
+ publishedSummary
107
+ };
@@ -0,0 +1,10 @@
1
+ import type { RepoConnectLevel, RepoConnection, RepoConnectionType } from '../../api-types.js';
2
+ export declare const CONNECTION_TYPE: Record<RepoConnectionType, string>;
3
+ export declare const LEVEL_LABEL: Record<RepoConnectLevel, string>;
4
+ export declare function levelList(levels: readonly RepoConnectLevel[]): string;
5
+ /** The repo-level chip: the shared one, fed by the connection's facts. */
6
+ export declare function ConnectionStatusChip({ connection, }: {
7
+ connection: RepoConnection | null;
8
+ }): import("react").JSX.Element;
9
+ /** What a connection's local credentials are, in one line of words. */
10
+ export declare function connectionTargetText(connection: RepoConnection): string | null;