@ekanos/harness 0.18.0 → 0.20.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 (187) 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/ask-assistant-bridge.js +1 -1
  9. package/dist/internal/components/connect-controls.d.ts +12 -0
  10. package/dist/internal/components/connect-controls.js +69 -0
  11. package/dist/internal/components/connect-dialog.d.ts +19 -0
  12. package/dist/internal/components/connect-dialog.js +61 -0
  13. package/dist/internal/components/connect-panel.d.ts +25 -0
  14. package/dist/internal/components/connect-panel.js +292 -0
  15. package/dist/internal/components/connection-chip.d.ts +14 -0
  16. package/dist/internal/components/connection-chip.js +75 -0
  17. package/dist/internal/components/dashboard-grid.js +38 -24
  18. package/dist/internal/components/dev-toolbar.js +176 -103
  19. package/dist/internal/components/events-panel.d.ts +10 -0
  20. package/dist/internal/components/events-panel.js +111 -0
  21. package/dist/internal/components/health-panel.d.ts +4 -0
  22. package/dist/internal/components/health-panel.js +56 -0
  23. package/dist/internal/components/integration-badge.d.ts +29 -0
  24. package/dist/internal/components/integration-badge.js +105 -0
  25. package/dist/internal/components/local-oauth-panel.js +21 -1
  26. package/dist/internal/components/operation-runner-panel.d.ts +12 -0
  27. package/dist/internal/components/operation-runner-panel.js +331 -0
  28. package/dist/internal/components/provenance-banner.d.ts +12 -0
  29. package/dist/internal/components/provenance-banner.js +107 -0
  30. package/dist/internal/components/repo-connection.d.ts +10 -0
  31. package/dist/internal/components/repo-connection.js +32 -0
  32. package/dist/internal/components/run-log.d.ts +9 -0
  33. package/dist/internal/components/run-log.js +228 -0
  34. package/dist/internal/components/runtime-strip.d.ts +12 -0
  35. package/dist/internal/components/runtime-strip.js +158 -0
  36. package/dist/internal/components/schema-form.d.ts +13 -0
  37. package/dist/internal/components/schema-form.js +382 -0
  38. package/dist/internal/components/scrollable-nav.d.ts +12 -0
  39. package/dist/internal/components/scrollable-nav.js +68 -0
  40. package/dist/internal/components/surface-nav.d.ts +31 -1
  41. package/dist/internal/components/surface-nav.js +244 -31
  42. package/dist/internal/components/workflow-runner.d.ts +14 -0
  43. package/dist/internal/components/workflow-runner.js +104 -0
  44. package/dist/internal/lib/bundled-secrets.d.ts +9 -0
  45. package/dist/internal/lib/bundled-secrets.js +24 -0
  46. package/dist/internal/lib/chrome-slot.d.ts +2 -0
  47. package/dist/internal/lib/chrome-slot.js +25 -0
  48. package/dist/internal/lib/connection-facts.d.ts +44 -0
  49. package/dist/internal/lib/connection-facts.js +116 -0
  50. package/dist/internal/lib/console-client.d.ts +55 -0
  51. package/dist/internal/lib/console-client.js +295 -0
  52. package/dist/internal/lib/console-context.d.ts +56 -0
  53. package/dist/internal/lib/console-context.js +67 -0
  54. package/dist/internal/lib/console-hooks.d.ts +33 -0
  55. package/dist/internal/lib/console-hooks.js +118 -0
  56. package/dist/internal/lib/console-types.d.ts +279 -0
  57. package/dist/internal/lib/console-types.js +0 -0
  58. package/dist/internal/lib/experience-runtime.d.ts +8 -0
  59. package/dist/internal/lib/experience-runtime.js +22 -0
  60. package/dist/internal/lib/preview-sections.d.ts +13 -0
  61. package/dist/internal/lib/preview-sections.js +32 -0
  62. package/dist/internal/lib/repo-context.d.ts +20 -0
  63. package/dist/internal/lib/repo-context.js +64 -0
  64. package/dist/internal/lib/run-log-view.d.ts +24 -0
  65. package/dist/internal/lib/run-log-view.js +57 -0
  66. package/dist/internal/lib/schema-form-model.d.ts +34 -0
  67. package/dist/internal/lib/schema-form-model.js +272 -0
  68. package/dist/internal/lib/toolbar-context.d.ts +9 -1
  69. package/dist/internal/lib/toolbar-context.js +13 -3
  70. package/dist/internal/lib/toolbar-visibility.d.ts +16 -0
  71. package/dist/internal/lib/toolbar-visibility.js +31 -0
  72. package/dist/internal/registry-context.d.ts +2 -0
  73. package/dist/internal/registry-context.js +11 -9
  74. package/dist/internal/routes/activation-page.js +44 -20
  75. package/dist/internal/routes/console-home-page.d.ts +5 -0
  76. package/dist/internal/routes/console-home-page.js +18 -0
  77. package/dist/internal/routes/experience-connect-page.d.ts +6 -0
  78. package/dist/internal/routes/experience-connect-page.js +127 -0
  79. package/dist/internal/routes/experience-layout-page.d.ts +8 -0
  80. package/dist/internal/routes/experience-layout-page.js +126 -0
  81. package/dist/internal/routes/experience-page-host.d.ts +7 -0
  82. package/dist/internal/routes/experience-page-host.js +79 -0
  83. package/dist/internal/routes/experience-review-queue-page.d.ts +2 -0
  84. package/dist/internal/routes/experience-review-queue-page.js +60 -0
  85. package/dist/internal/routes/experience-runs-page.d.ts +1 -0
  86. package/dist/internal/routes/experience-runs-page.js +13 -0
  87. package/dist/internal/routes/experience-summary-page.d.ts +1 -0
  88. package/dist/internal/routes/experience-summary-page.js +101 -0
  89. package/dist/internal/routes/experience-widget-page.d.ts +1 -0
  90. package/dist/internal/routes/experience-widget-page.js +26 -0
  91. package/dist/internal/routes/experience-widgets-page.d.ts +6 -0
  92. package/dist/internal/routes/experience-widgets-page.js +22 -0
  93. package/dist/internal/routes/experience-workflow-page.d.ts +1 -0
  94. package/dist/internal/routes/experience-workflow-page.js +24 -0
  95. package/dist/internal/routes/experience-workflows-page.d.ts +1 -0
  96. package/dist/internal/routes/experience-workflows-page.js +44 -0
  97. package/dist/internal/routes/index-page.d.ts +10 -9
  98. package/dist/internal/routes/index-page.js +3 -68
  99. package/dist/internal/routes/integration-layout.d.ts +12 -1
  100. package/dist/internal/routes/integration-layout.js +20 -6
  101. package/dist/internal/routes/integrations-connect-page.d.ts +1 -0
  102. package/dist/internal/routes/integrations-connect-page.js +19 -0
  103. package/dist/internal/routes/integrations-events-page.d.ts +1 -0
  104. package/dist/internal/routes/integrations-events-page.js +10 -0
  105. package/dist/internal/routes/integrations-health-page.d.ts +1 -0
  106. package/dist/internal/routes/integrations-health-page.js +10 -0
  107. package/dist/internal/routes/integrations-layout.d.ts +17 -0
  108. package/dist/internal/routes/integrations-layout.js +106 -0
  109. package/dist/internal/routes/integrations-list-page.d.ts +2 -0
  110. package/dist/internal/routes/integrations-list-page.js +94 -0
  111. package/dist/internal/routes/integrations-operation-page.d.ts +1 -0
  112. package/dist/internal/routes/integrations-operation-page.js +29 -0
  113. package/dist/internal/routes/integrations-operations-page.d.ts +1 -0
  114. package/dist/internal/routes/integrations-operations-page.js +61 -0
  115. package/dist/internal/routes/integrations-overview-page.d.ts +1 -0
  116. package/dist/internal/routes/integrations-overview-page.js +90 -0
  117. package/dist/internal/routes/integrations-runs-page.d.ts +1 -0
  118. package/dist/internal/routes/integrations-runs-page.js +14 -0
  119. package/dist/internal/routes/integrations-scope.d.ts +12 -0
  120. package/dist/internal/routes/integrations-scope.js +39 -0
  121. package/dist/internal/routes/legacy-preview-redirect.d.ts +6 -0
  122. package/dist/internal/routes/legacy-preview-redirect.js +12 -0
  123. package/dist/internal/routes/preview-index-page.d.ts +2 -0
  124. package/dist/internal/routes/preview-index-page.js +14 -0
  125. package/dist/internal/routes/repo-connections-page.d.ts +6 -0
  126. package/dist/internal/routes/repo-connections-page.js +8 -0
  127. package/dist/internal/routes/repo-home-page.d.ts +2 -0
  128. package/dist/internal/routes/repo-home-page.js +320 -0
  129. package/dist/internal/routes/repo-layout.d.ts +7 -0
  130. package/dist/internal/routes/repo-layout.js +76 -0
  131. package/dist/internal/routes/repo-package-layouts.d.ts +20 -0
  132. package/dist/internal/routes/repo-package-layouts.js +104 -0
  133. package/dist/internal/routes/root-layout.d.ts +3 -1
  134. package/dist/internal/routes/root-layout.js +13 -3
  135. package/dist/internal/routes/single-widget-page.js +5 -12
  136. package/dist/internal/routes/tile-page.js +20 -41
  137. package/dist/internal/routes/triggers-page.js +55 -62
  138. package/dist/internal/routes/widgets-page.js +1 -1
  139. package/dist/internal/server/api-router.js +46 -4
  140. package/dist/internal/server/approvals.d.ts +44 -0
  141. package/dist/internal/server/approvals.js +76 -0
  142. package/dist/internal/server/contract-sources.d.ts +28 -0
  143. package/dist/internal/server/contract-sources.js +83 -0
  144. package/dist/internal/server/definition-loader.d.ts +22 -0
  145. package/dist/internal/server/definition-loader.js +125 -0
  146. package/dist/internal/server/ekanos-api-router.d.ts +34 -0
  147. package/dist/internal/server/ekanos-api-router.js +835 -0
  148. package/dist/internal/server/experience-loader.d.ts +57 -0
  149. package/dist/internal/server/experience-loader.js +146 -0
  150. package/dist/internal/server/integration-lookup.d.ts +29 -0
  151. package/dist/internal/server/integration-lookup.js +33 -0
  152. package/dist/internal/server/integration-resolver.d.ts +121 -0
  153. package/dist/internal/server/integration-resolver.js +605 -0
  154. package/dist/internal/server/live-invoker.d.ts +11 -0
  155. package/dist/internal/server/live-invoker.js +106 -0
  156. package/dist/internal/server/local-secrets.d.ts +82 -1
  157. package/dist/internal/server/local-secrets.js +112 -1
  158. package/dist/internal/server/local-state.d.ts +12 -0
  159. package/dist/internal/server/local-state.js +45 -0
  160. package/dist/internal/server/oauth-persistence.d.ts +19 -0
  161. package/dist/internal/server/oauth-persistence.js +76 -0
  162. package/dist/internal/server/operation-runner.d.ts +95 -0
  163. package/dist/internal/server/operation-runner.js +231 -0
  164. package/dist/internal/server/project-manifest.d.ts +71 -0
  165. package/dist/internal/server/project-manifest.js +215 -0
  166. package/dist/internal/server/registry-cache.d.ts +68 -0
  167. package/dist/internal/server/registry-cache.js +328 -0
  168. package/dist/internal/server/repo-api-router.d.ts +33 -0
  169. package/dist/internal/server/repo-api-router.js +391 -0
  170. package/dist/internal/server/run-log.d.ts +22 -0
  171. package/dist/internal/server/run-log.js +32 -0
  172. package/dist/internal/server/semantics.d.ts +28 -0
  173. package/dist/internal/server/semantics.js +67 -0
  174. package/dist/internal/server/session-catalog.d.ts +67 -0
  175. package/dist/internal/server/session-catalog.js +18 -0
  176. package/dist/internal/server/workflow-runner.d.ts +36 -0
  177. package/dist/internal/server/workflow-runner.js +183 -0
  178. package/dist/registry.d.ts +7 -0
  179. package/dist/resolver.d.ts +145 -0
  180. package/dist/resolver.js +211 -0
  181. package/dist/routes.d.ts +66 -2
  182. package/dist/routes.js +61 -3
  183. package/dist/runtime.d.ts +46 -0
  184. package/dist/runtime.js +60 -0
  185. package/package.json +23 -9
  186. package/dist/internal/routes/integration-index-page.d.ts +0 -13
  187. package/dist/internal/routes/integration-index-page.js +0 -17
@@ -0,0 +1,116 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { Alert, AlertDescription, AlertTitle } from "@ekanos/ui/alert";
5
+ import { Button } from "@ekanos/ui/button";
6
+ import { Card } from "@ekanos/ui/card";
7
+ import { Icon } from "@ekanos/ui/icon";
8
+ import { useApprovals, useDecideApproval } from "../lib/console-hooks.js";
9
+ function approvalOperationName(opKey) {
10
+ return opKey.split("/").pop() ?? opKey;
11
+ }
12
+ function approvalsSummary(approvals) {
13
+ const [only] = approvals;
14
+ const count = `${approvals.length} write${approvals.length === 1 ? "" : "s"} waiting for approval`;
15
+ return only && approvals.length === 1 ? `${count}: ${only.integration} ${approvalOperationName(only.opKey)}` : count;
16
+ }
17
+ function ApprovalCard({
18
+ approval,
19
+ pending,
20
+ onDecide
21
+ }) {
22
+ const [open, setOpen] = useState(false);
23
+ return /* @__PURE__ */ jsxs(
24
+ Card,
25
+ {
26
+ layout: "bleed",
27
+ className: "flex min-w-0 flex-col gap-3 p-4",
28
+ "data-test": "approval-card",
29
+ "data-approval-id": approval.id,
30
+ children: [
31
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [
32
+ /* @__PURE__ */ jsxs("code", { className: "text-label break-all", children: [
33
+ approval.integration,
34
+ "/",
35
+ approval.opKey
36
+ ] }),
37
+ /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-fine break-words", children: [
38
+ approval.channel,
39
+ " \xB7 ",
40
+ approval.mode
41
+ ] }),
42
+ approval.args === void 0 ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
43
+ /* @__PURE__ */ jsx(
44
+ Button,
45
+ {
46
+ type: "button",
47
+ variant: "ghost",
48
+ size: "sm",
49
+ className: "self-start",
50
+ "aria-expanded": open,
51
+ onClick: () => setOpen((value) => !value),
52
+ "data-test": "approval-details-toggle",
53
+ children: open ? "Hide details" : "Show details"
54
+ }
55
+ ),
56
+ open ? /* @__PURE__ */ jsxs("div", { className: "min-w-0", "data-test": "approval-details", children: [
57
+ /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-fine break-all", children: [
58
+ "args hash ",
59
+ /* @__PURE__ */ jsx("code", { children: approval.argsHash })
60
+ ] }),
61
+ /* @__PURE__ */ jsx("pre", { className: "bg-muted text-fine max-h-40 max-w-full overflow-auto rounded-md p-2 break-words whitespace-pre-wrap", children: JSON.stringify(approval.args, null, 2) })
62
+ ] }) : null
63
+ ] })
64
+ ] }),
65
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
66
+ /* @__PURE__ */ jsx(
67
+ Button,
68
+ {
69
+ type: "button",
70
+ disabled: pending,
71
+ onClick: () => onDecide("approve"),
72
+ "data-test": "approval-approve",
73
+ children: "Approve"
74
+ }
75
+ ),
76
+ /* @__PURE__ */ jsx(
77
+ Button,
78
+ {
79
+ type: "button",
80
+ variant: "outline",
81
+ disabled: pending,
82
+ onClick: () => onDecide("reject"),
83
+ "data-test": "approval-reject",
84
+ children: "Reject"
85
+ }
86
+ )
87
+ ] })
88
+ ]
89
+ }
90
+ );
91
+ }
92
+ function ApprovalsTray() {
93
+ const approvals = useApprovals();
94
+ const decide = useDecideApproval();
95
+ const list = approvals.data ?? [];
96
+ if (list.length === 0) return null;
97
+ return /* @__PURE__ */ jsxs(Alert, { variant: "warning", className: "*:min-w-0", "data-test": "approvals-tray", children: [
98
+ /* @__PURE__ */ jsx(Icon, { name: "fa-solid fa-hand", className: "h-4 w-4" }),
99
+ /* @__PURE__ */ jsx(AlertTitle, { "data-test": "approvals-summary", children: approvalsSummary(list) }),
100
+ /* @__PURE__ */ jsx(AlertDescription, { children: /* @__PURE__ */ jsx("div", { className: "mt-2 flex min-w-0 flex-col gap-3", children: list.map((approval) => /* @__PURE__ */ jsx(
101
+ ApprovalCard,
102
+ {
103
+ approval,
104
+ pending: decide.isPending,
105
+ onDecide: (decision) => decide.mutate({ id: approval.id, decision })
106
+ },
107
+ approval.id
108
+ )) }) })
109
+ ] });
110
+ }
111
+ export {
112
+ ApprovalCard,
113
+ ApprovalsTray,
114
+ approvalOperationName,
115
+ approvalsSummary
116
+ };
@@ -17,7 +17,7 @@ function AskAssistantBridge() {
17
17
  Icon,
18
18
  {
19
19
  name: "fa-solid fa-wand-magic-sparkles",
20
- className: "text-primary h-5 w-5"
20
+ className: "text-muted-foreground h-5 w-5"
21
21
  }
22
22
  ),
23
23
  /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
@@ -0,0 +1,12 @@
1
+ import type { RepoConnection } from '../../api-types.js';
2
+ /**
3
+ * Connect / Edit (the connect dialog) and Disconnect for one integration of
4
+ * this repo. Rendered from the connection's facts, so an integration that
5
+ * needs no connection, or is managed by Ekanos, gets no controls.
6
+ */
7
+ export declare function ConnectControls({ name, connection, returnPath, onChanged, }: {
8
+ name: string;
9
+ connection: RepoConnection | null;
10
+ returnPath: string;
11
+ onChanged?: () => void | Promise<unknown>;
12
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,69 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useMemo } from "react";
4
+ import { Button } from "@ekanos/ui/button";
5
+ import { ConfirmDialog } from "@ekanos/ui/confirm-dialog";
6
+ import { isConnectable } from "../lib/connection-facts.js";
7
+ import { createHttpConsoleClient, packageApiBase } from "../lib/console-client.js";
8
+ import { useDisconnect } from "../lib/repo-context.js";
9
+ import { ConnectDialog } from "./connect-dialog.js";
10
+ function ConnectControls({
11
+ name,
12
+ connection,
13
+ returnPath,
14
+ onChanged
15
+ }) {
16
+ const disconnect = useDisconnect();
17
+ const client = useMemo(
18
+ () => createHttpConsoleClient(void 0, packageApiBase("integration", name)),
19
+ [name]
20
+ );
21
+ const facts = connection?.facts ?? null;
22
+ if (!connection || !isConnectable(facts)) return null;
23
+ const connected = facts?.state === "connected";
24
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
25
+ /* @__PURE__ */ jsx(
26
+ ConnectDialog,
27
+ {
28
+ integration: name,
29
+ client,
30
+ oauth: connection.type === "oauth",
31
+ returnPath,
32
+ ...onChanged ? { onChanged: () => void onChanged() } : {},
33
+ label: connected ? "Edit" : "Connect",
34
+ connected
35
+ }
36
+ ),
37
+ connected ? /* @__PURE__ */ jsx(
38
+ ConfirmDialog,
39
+ {
40
+ trigger: /* @__PURE__ */ jsx(
41
+ Button,
42
+ {
43
+ variant: "ghost",
44
+ size: "sm",
45
+ disabled: disconnect.isPending,
46
+ "data-test": `disconnect-${name}`,
47
+ children: "Disconnect"
48
+ }
49
+ ),
50
+ title: `Disconnect ${name}?`,
51
+ description: "This removes the local credentials stored for this integration, in its own folder only. You can connect again afterwards.",
52
+ confirmLabel: "Disconnect",
53
+ onConfirm: async () => {
54
+ try {
55
+ await disconnect.mutateAsync(name);
56
+ await onChanged?.();
57
+ return true;
58
+ } catch (error) {
59
+ console.error("[harness] disconnect failed", error);
60
+ return false;
61
+ }
62
+ }
63
+ }
64
+ ) : null
65
+ ] });
66
+ }
67
+ export {
68
+ ConnectControls
69
+ };
@@ -0,0 +1,19 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type ConsoleClient } from '../lib/console-client.js';
3
+ /**
4
+ * Connect an integration without leaving the page: the integration's own
5
+ * form (activation fields, keys, or the OAuth start) in a dialog. It saves to
6
+ * that integration package's local credentials through `client`, and tells
7
+ * the page via `onChanged` so the status next to it flips.
8
+ */
9
+ export declare function ConnectDialog({ integration, client, oauth, returnPath, onChanged, label, connected, }: {
10
+ integration: string;
11
+ /** The API that serves this integration's credentials. */
12
+ client: ConsoleClient;
13
+ oauth?: boolean;
14
+ returnPath?: string;
15
+ onChanged?: () => void;
16
+ label?: ReactNode;
17
+ /** Already connected: the dialog edits the connection. */
18
+ connected?: boolean;
19
+ }): import("react").JSX.Element;
@@ -0,0 +1,61 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { Button } from "@ekanos/ui/button";
5
+ import {
6
+ Dialog,
7
+ DialogContent,
8
+ DialogDescription,
9
+ DialogHeader,
10
+ DialogTitle
11
+ } from "@ekanos/ui/dialog";
12
+ import { ConsoleProviders } from "../lib/console-context.js";
13
+ import { useOptionalHarnessRegistry } from "../registry-context.js";
14
+ import { ConnectPanel } from "./connect-panel.js";
15
+ function ConnectDialog({
16
+ integration,
17
+ client,
18
+ oauth = false,
19
+ returnPath,
20
+ onChanged,
21
+ label = "Connect",
22
+ connected = false
23
+ }) {
24
+ const [open, setOpen] = useState(false);
25
+ const registry = useOptionalHarnessRegistry();
26
+ const activationForm = registry.find(
27
+ (entry) => entry.slug === integration
28
+ )?.activationForm;
29
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
30
+ /* @__PURE__ */ jsx(
31
+ Button,
32
+ {
33
+ variant: "outline",
34
+ size: "sm",
35
+ onClick: () => setOpen(true),
36
+ "data-test": `connect-dialog-${integration}`,
37
+ children: label
38
+ }
39
+ ),
40
+ /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs(DialogContent, { "data-test": "connect-dialog", children: [
41
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
42
+ /* @__PURE__ */ jsx(DialogTitle, { children: connected ? `Edit ${integration} connection` : `Connect ${integration}` }),
43
+ /* @__PURE__ */ jsx(DialogDescription, { children: "Saved on this machine, in the integration's own folder." })
44
+ ] }),
45
+ /* @__PURE__ */ jsx("div", { className: "flex max-h-[70vh] flex-col gap-4 overflow-y-auto", children: /* @__PURE__ */ jsx(ConsoleProviders, { client, children: /* @__PURE__ */ jsx(
46
+ ConnectPanel,
47
+ {
48
+ surface: "dialog",
49
+ integration: { integration },
50
+ oauth,
51
+ ...activationForm ? { activationForm } : {},
52
+ ...returnPath ? { returnPath } : {},
53
+ ...onChanged ? { onChanged } : {}
54
+ }
55
+ ) }) })
56
+ ] }) })
57
+ ] });
58
+ }
59
+ export {
60
+ ConnectDialog
61
+ };
@@ -0,0 +1,25 @@
1
+ import { type ComponentType } from 'react';
2
+ import type { ActivationFormProps } from '@ekanos/sdk';
3
+ import type { ConsoleIntegration } from '../lib/console-types.js';
4
+ /**
5
+ * Keys and OAuth for one integration. A registry integration has no credential UI:
6
+ * its connection is managed by Ekanos. Values are write-only: the page shows
7
+ * which keys are set, never what they are.
8
+ */
9
+ export declare function ConnectPanel({ integration, oauth, activationForm, onChanged, returnPath, surface, }: {
10
+ integration: Pick<ConsoleIntegration, 'integration'>;
11
+ /** `dialog`: the dialog supplies its own description, and editing has no Disconnect. */
12
+ surface?: 'page' | 'dialog';
13
+ /** Called after credentials were saved or removed, for a host that shows the status elsewhere. */
14
+ onChanged?: () => void;
15
+ /** Where the OAuth loop returns to; defaults to this integration's console. */
16
+ returnPath?: string;
17
+ /** The contract declares OAuth and the integration runs local code. */
18
+ oauth?: boolean;
19
+ /**
20
+ * The integration's own activation form, from its harness entry: the same
21
+ * component the activation surface renders. Used when the integration
22
+ * declares no keys, so its credentials are whatever that form collects.
23
+ */
24
+ activationForm?: ComponentType<ActivationFormProps>;
25
+ }): import("react").JSX.Element;
@@ -0,0 +1,292 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { Suspense, useState } from "react";
4
+ import {
5
+ IntegrationActivationProvider
6
+ } from "@ekanos/sdk/hooks";
7
+ import { Alert, AlertDescription, AlertTitle } from "@ekanos/ui/alert";
8
+ import { Button } from "@ekanos/ui/button";
9
+ import { ConfirmDialog } from "@ekanos/ui/confirm-dialog";
10
+ import { Input } from "@ekanos/ui/input";
11
+ import { Label } from "@ekanos/ui/label";
12
+ import { StatusBadge } from "@ekanos/ui/status-badge";
13
+ import { useQueryClient } from "@tanstack/react-query";
14
+ import { NextIntlClientProvider } from "next-intl";
15
+ import { TeamAccountWorkspaceContextProvider } from "../../mocks/team-account-workspace.js";
16
+ import { HARNESS_ACCOUNT_ID } from "../../registry.js";
17
+ import { useConsoleClient } from "../lib/console-context.js";
18
+ import {
19
+ consoleKeys,
20
+ useConnection,
21
+ useConsoleMutation
22
+ } from "../lib/console-hooks.js";
23
+ import { ConnectionChip } from "./connection-chip.js";
24
+ function ConnectPanel({
25
+ integration,
26
+ oauth = false,
27
+ activationForm,
28
+ onChanged,
29
+ returnPath,
30
+ surface = "page"
31
+ }) {
32
+ const connection = useConnection(integration.integration);
33
+ const queryClient = useQueryClient();
34
+ const [drafts, setDrafts] = useState({});
35
+ const save = useConsoleMutation(
36
+ (c, values) => c.saveSecrets(integration.integration, values)
37
+ );
38
+ const disconnect = useConsoleMutation(
39
+ (c, clearKeys) => c.disconnect(integration.integration, clearKeys)
40
+ );
41
+ if (connection.isError) {
42
+ return /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: /* @__PURE__ */ jsxs(AlertDescription, { children: [
43
+ "Could not load the connection: ",
44
+ connection.error.message
45
+ ] }) });
46
+ }
47
+ if (!connection.data) {
48
+ return /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: "Loading\u2026" });
49
+ }
50
+ const state = connection.data;
51
+ if (state.managed) {
52
+ return /* @__PURE__ */ jsxs(Alert, { variant: "info", "data-test": "connect-managed", children: [
53
+ /* @__PURE__ */ jsx(AlertTitle, { children: "Connection managed by Ekanos" }),
54
+ /* @__PURE__ */ jsx(AlertDescription, { children: "This integration is resolved from the registry, so it runs from fixtures only. Override the integration locally to enter your own credentials." })
55
+ ] });
56
+ }
57
+ const noConnectionNeeded = state.facts.state === "no_connection_needed";
58
+ const inDialog = surface === "dialog";
59
+ const dirty = Object.values(drafts).some((value) => value !== "");
60
+ return /* @__PURE__ */ jsxs(
61
+ "div",
62
+ {
63
+ className: "flex w-full max-w-full min-w-0 flex-col gap-6",
64
+ "data-test": "connect-panel",
65
+ children: [
66
+ inDialog ? null : /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-fine", children: "Credentials are stored on this machine, in the integration repo. They never reach the browser, so a saved key shows as set, not its value." }),
67
+ /* @__PURE__ */ jsxs(
68
+ "div",
69
+ {
70
+ className: "flex max-w-xl flex-wrap items-center gap-x-3 gap-y-2",
71
+ "data-test": "connect-target",
72
+ children: [
73
+ /* @__PURE__ */ jsx(ConnectionChip, { facts: state.facts }),
74
+ noConnectionNeeded ? /* @__PURE__ */ jsx(
75
+ "span",
76
+ {
77
+ className: "text-muted-foreground text-fine",
78
+ "data-test": "connect-optional",
79
+ children: "Settings below are optional."
80
+ }
81
+ ) : null,
82
+ state.hasStored && !inDialog ? /* @__PURE__ */ jsx(
83
+ ConfirmDialog,
84
+ {
85
+ trigger: /* @__PURE__ */ jsx(
86
+ Button,
87
+ {
88
+ variant: "ghost",
89
+ size: "sm",
90
+ disabled: disconnect.isPending,
91
+ "data-test": "disconnect",
92
+ children: "Disconnect"
93
+ }
94
+ ),
95
+ title: `Disconnect ${integration.integration}?`,
96
+ description: oauth ? "This removes the stored connection data for this integration from this machine. The OAuth app keys stay; you can connect again afterwards." : "This removes the stored keys for this integration from this machine, in its own folder only. You can enter new values afterwards.",
97
+ confirmLabel: "Disconnect",
98
+ onConfirm: async () => {
99
+ try {
100
+ await disconnect.mutateAsync(!oauth);
101
+ setDrafts({});
102
+ await queryClient.invalidateQueries({
103
+ queryKey: consoleKeys.connection(integration.integration)
104
+ });
105
+ onChanged?.();
106
+ return true;
107
+ } catch (error) {
108
+ console.error("[harness] disconnect failed", error);
109
+ return false;
110
+ }
111
+ }
112
+ }
113
+ ) : null
114
+ ]
115
+ }
116
+ ),
117
+ disconnect.isError ? /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: /* @__PURE__ */ jsx(AlertDescription, { children: disconnect.error.message }) }) : null,
118
+ /* @__PURE__ */ jsxs(
119
+ "form",
120
+ {
121
+ className: "flex w-full max-w-xl min-w-0 flex-col gap-4",
122
+ onSubmit: (event) => {
123
+ event.preventDefault();
124
+ const values = Object.fromEntries(
125
+ Object.entries(drafts).filter(([, value]) => value !== "")
126
+ );
127
+ save.mutate(values, {
128
+ onSuccess: () => {
129
+ setDrafts({});
130
+ onChanged?.();
131
+ return queryClient.invalidateQueries({
132
+ queryKey: consoleKeys.connection(integration.integration)
133
+ });
134
+ }
135
+ });
136
+ },
137
+ children: [
138
+ state.root ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-fine", "data-test": "store-root", children: [
139
+ "Store:",
140
+ " ",
141
+ /* @__PURE__ */ jsx("code", { title: state.root, children: state.displayRoot ?? state.root })
142
+ ] }) : null,
143
+ state.fields.length === 0 && !activationForm ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: "This integration declares no keys." }) : null,
144
+ state.fields.map((field) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
145
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
146
+ /* @__PURE__ */ jsx(Label, { htmlFor: `connect-${field.key}`, className: "text-label", children: field.label }),
147
+ /* @__PURE__ */ jsx(StatusBadge, { tone: field.set ? "success" : "neutral", children: field.set ? "set" : "not set" })
148
+ ] }),
149
+ /* @__PURE__ */ jsx(
150
+ Input,
151
+ {
152
+ id: `connect-${field.key}`,
153
+ type: field.secret ? "password" : "text",
154
+ autoComplete: "off",
155
+ placeholder: field.set ? "Set" : "",
156
+ value: drafts[field.key] ?? "",
157
+ onChange: (event) => setDrafts({ ...drafts, [field.key]: event.target.value })
158
+ }
159
+ )
160
+ ] }, field.key)),
161
+ save.isError ? /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: /* @__PURE__ */ jsx(AlertDescription, { children: save.error.message }) }) : null,
162
+ state.fields.length > 0 ? /* @__PURE__ */ jsx(
163
+ Button,
164
+ {
165
+ type: "submit",
166
+ className: "self-start",
167
+ disabled: !dirty || save.isPending,
168
+ "data-test": "save-secrets",
169
+ children: save.isPending ? "Saving\u2026" : noConnectionNeeded ? "Save settings" : "Save keys"
170
+ }
171
+ ) : null
172
+ ]
173
+ }
174
+ ),
175
+ state.fields.length === 0 && activationForm ? /* @__PURE__ */ jsx(
176
+ ActivationConnect,
177
+ {
178
+ integration: integration.integration,
179
+ Form: activationForm,
180
+ saveLabel: noConnectionNeeded,
181
+ ...onChanged ? { onChanged } : {}
182
+ }
183
+ ) : null,
184
+ oauth ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", "data-test": "oauth-block", children: [
185
+ /* @__PURE__ */ jsx("h3", { className: "text-label", children: "OAuth" }),
186
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-fine", children: "Runs the real authorize and callback loop on localhost, with your own provider app credentials (save them above first)." }),
187
+ /* @__PURE__ */ jsx(
188
+ Button,
189
+ {
190
+ variant: "outline",
191
+ className: "self-start",
192
+ "data-test": "start-oauth",
193
+ nativeButton: false,
194
+ render: /* @__PURE__ */ jsx(
195
+ "a",
196
+ {
197
+ href: `/api/integrations/${integration.integration}/oauth/connect${returnPath ? `?returnPath=${encodeURIComponent(returnPath)}` : ""}`
198
+ }
199
+ ),
200
+ children: "Connect with OAuth"
201
+ }
202
+ )
203
+ ] }) : null
204
+ ]
205
+ }
206
+ );
207
+ }
208
+ function ActivationConnect({
209
+ integration,
210
+ Form,
211
+ saveLabel,
212
+ onChanged
213
+ }) {
214
+ const client = useConsoleClient();
215
+ const queryClient = useQueryClient();
216
+ const [attempt, setAttempt] = useState(0);
217
+ const actions = {
218
+ activate: async (input) => {
219
+ try {
220
+ const data = input.activationData;
221
+ await client.saveActivation(
222
+ integration,
223
+ typeof data === "object" && data !== null && !Array.isArray(data) ? Object.fromEntries(Object.entries(data)) : {}
224
+ );
225
+ onChanged?.();
226
+ return { success: true };
227
+ } catch (error) {
228
+ console.error("[harness] saving activation fields failed", error);
229
+ return {
230
+ success: false,
231
+ errorMessage: "The harness could not store these fields locally. Is the dev server still running?"
232
+ };
233
+ }
234
+ },
235
+ deactivate: async () => {
236
+ await client.disconnect(integration, false);
237
+ return { success: true };
238
+ }
239
+ };
240
+ const reset = () => setAttempt((count) => count + 1);
241
+ return /* @__PURE__ */ jsxs(
242
+ "div",
243
+ {
244
+ className: "flex w-full max-w-xl min-w-0 flex-col gap-3 [&_*]:min-w-0 [&_.grid]:grid-cols-[minmax(0,1fr)] [&_fieldset]:min-w-0 [&_form]:min-w-0 [&_input]:max-w-full [&_label]:[overflow-wrap:anywhere] [&_p]:[overflow-wrap:anywhere] [&_textarea]:max-w-full",
245
+ "data-test": "connect-activation",
246
+ children: [
247
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-fine", children: "This is the integration's own connect form. What you enter is stored on this machine as its local credentials, and live operations read it from there." }),
248
+ /* @__PURE__ */ jsx(IntegrationActivationProvider, { actions, children: /* @__PURE__ */ jsx(TeamAccountWorkspaceContextProvider, { children: /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(SettingsLabels, { enabled: saveLabel, children: /* @__PURE__ */ jsx(
249
+ Form,
250
+ {
251
+ accountId: HARNESS_ACCOUNT_ID,
252
+ productSlug: integration,
253
+ inline: true,
254
+ onSuccess: async () => {
255
+ await queryClient.invalidateQueries({
256
+ queryKey: consoleKeys.connection(integration)
257
+ });
258
+ reset();
259
+ },
260
+ onCancel: reset
261
+ },
262
+ attempt
263
+ ) }) }) }) })
264
+ ]
265
+ }
266
+ );
267
+ }
268
+ function SettingsLabels({
269
+ enabled,
270
+ children
271
+ }) {
272
+ if (!enabled) return /* @__PURE__ */ jsx(Fragment, { children });
273
+ return /* @__PURE__ */ jsx(
274
+ NextIntlClientProvider,
275
+ {
276
+ locale: "en",
277
+ timeZone: "UTC",
278
+ messages: {
279
+ common: {
280
+ integrationConnect: {
281
+ connect: "Save settings",
282
+ connecting: "Saving\u2026"
283
+ }
284
+ }
285
+ },
286
+ children
287
+ }
288
+ );
289
+ }
290
+ export {
291
+ ConnectPanel
292
+ };
@@ -0,0 +1,14 @@
1
+ import type { IntegrationConnectionFacts } from '../../api-types.js';
2
+ /**
3
+ * The one chip every screen uses for an integration's connection. It renders
4
+ * `IntegrationConnectionFacts`; nothing here decides status.
5
+ *
6
+ * `status` (default) reads Connected / Not connected / No connection needed /
7
+ * Managed by Ekanos, with what the credentials point at. `answer` reads Live or
8
+ * Fixtures with the reason as quiet secondary text.
9
+ */
10
+ export declare function ConnectionChip({ facts, variant, showTarget, }: {
11
+ facts: IntegrationConnectionFacts | null | undefined;
12
+ variant?: 'status' | 'answer';
13
+ showTarget?: boolean;
14
+ }): import("react").JSX.Element;