@ekanos/harness 0.5.0 → 0.6.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.
- package/README.md +2 -0
- package/dist/internal/components/ask-assistant-bridge.js +4 -4
- package/dist/internal/components/dev-toolbar.js +5 -2
- package/dist/internal/components/docs-link.d.ts +11 -0
- package/dist/internal/components/docs-link.js +35 -0
- package/dist/internal/components/local-oauth-panel.js +13 -13
- package/dist/internal/components/surface-nav.js +41 -21
- package/dist/internal/components/viewport-frame.js +1 -1
- package/dist/internal/components/widget-boundary.js +2 -2
- package/dist/internal/lib/check-raised-agent-events.d.ts +13 -0
- package/dist/internal/lib/check-raised-agent-events.js +92 -0
- package/dist/internal/lib/docs-links.d.ts +5 -0
- package/dist/internal/lib/docs-links.js +13 -0
- package/dist/internal/lib/trigger-contract.d.ts +18 -0
- package/dist/internal/lib/trigger-runner.js +7 -1
- package/dist/internal/routes/activation-page.js +14 -14
- package/dist/internal/routes/index-page.js +8 -8
- package/dist/internal/routes/integration-layout.js +1 -1
- package/dist/internal/routes/tile-page.js +8 -8
- package/dist/internal/routes/triggers-page.js +104 -16
- package/dist/internal/routes/widgets-page.js +1 -1
- package/dist/internal/server/api-router.js +48 -22
- package/dist/internal/server/live-context.d.ts +2 -0
- package/dist/internal/server/live-context.js +1 -0
- package/dist/internal/server/local-secrets.d.ts +1 -1
- package/dist/internal/server/local-secrets.js +7 -3
- package/dist/internal/server/nonce-store.d.ts +2 -0
- package/dist/internal/server/oauth-loop.js +5 -0
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@ real Ekanos chrome — the actual dashboard grid, the actual `Widget.*` compound
|
|
|
5
5
|
components, the actual design tokens — from fixtures, with no Supabase, no auth
|
|
6
6
|
and no network.
|
|
7
7
|
|
|
8
|
+
**Docs:** [sdk.ekanos.dev/harness/overview](https://sdk.ekanos.dev/harness/overview).
|
|
9
|
+
|
|
8
10
|
**New here? Start with the `@ekanos/sdk` README** — it is the authoring
|
|
9
11
|
reference for everything you declare (widgets, tools, webhooks, schedules,
|
|
10
12
|
OAuth, storage, egress). This document covers only the local dev harness that
|
|
@@ -21,8 +21,8 @@ function AskAssistantBridge() {
|
|
|
21
21
|
}
|
|
22
22
|
),
|
|
23
23
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
24
|
-
/* @__PURE__ */ jsx("p", { className: "
|
|
25
|
-
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground
|
|
24
|
+
/* @__PURE__ */ jsx("p", { className: "text-label truncate", children: "Ask payload" }),
|
|
25
|
+
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-fine truncate", children: [
|
|
26
26
|
asked.title,
|
|
27
27
|
" \xB7 ",
|
|
28
28
|
asked.widgetId
|
|
@@ -40,8 +40,8 @@ function AskAssistantBridge() {
|
|
|
40
40
|
)
|
|
41
41
|
] }),
|
|
42
42
|
/* @__PURE__ */ jsxs("div", { className: "bg-card min-h-0 flex-1 overflow-auto p-5", children: [
|
|
43
|
-
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground mb-3
|
|
44
|
-
/* @__PURE__ */ jsx("pre", { className: "bg-muted overflow-x-auto rounded-md p-3
|
|
43
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta mb-3", children: asked.suggestedPrompt }),
|
|
44
|
+
/* @__PURE__ */ jsx("pre", { className: "bg-muted text-fine overflow-x-auto rounded-md p-3", children: JSON.stringify(asked.snapshot, null, 2) ?? "null" })
|
|
45
45
|
] })
|
|
46
46
|
] });
|
|
47
47
|
}
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
resolveEgress,
|
|
23
23
|
supportsLiveMode
|
|
24
24
|
} from "../../registry.js";
|
|
25
|
+
import { HARNESS_DOCS_URL } from "../lib/docs-links.js";
|
|
25
26
|
import { getThemeToggleAccessibleLabel } from "../lib/theme-toggle.js";
|
|
26
27
|
import {
|
|
27
28
|
RENDER_STATES,
|
|
@@ -29,12 +30,13 @@ import {
|
|
|
29
30
|
useToolbar
|
|
30
31
|
} from "../lib/toolbar-context.js";
|
|
31
32
|
import { useHarnessRegistry } from "../registry-context.js";
|
|
33
|
+
import { DocsLink } from "./docs-link.js";
|
|
32
34
|
function Field({
|
|
33
35
|
label,
|
|
34
36
|
children
|
|
35
37
|
}) {
|
|
36
38
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
37
|
-
/* @__PURE__ */ jsx(Label, { className: "text-muted-foreground text-
|
|
39
|
+
/* @__PURE__ */ jsx(Label, { className: "text-muted-foreground text-fine", children: label }),
|
|
38
40
|
children
|
|
39
41
|
] });
|
|
40
42
|
}
|
|
@@ -118,10 +120,11 @@ function DevToolbar() {
|
|
|
118
120
|
}
|
|
119
121
|
) }),
|
|
120
122
|
/* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-2", children: [
|
|
123
|
+
/* @__PURE__ */ jsx(DocsLink, { href: HARNESS_DOCS_URL, "data-test": "toolbar-docs-link", children: "Docs" }),
|
|
121
124
|
live ? /* @__PURE__ */ jsxs(
|
|
122
125
|
"span",
|
|
123
126
|
{
|
|
124
|
-
className: "text-primary flex items-center gap-2
|
|
127
|
+
className: "text-primary text-label flex items-center gap-2",
|
|
125
128
|
"data-test": "toolbar-live-badge",
|
|
126
129
|
children: [
|
|
127
130
|
/* @__PURE__ */ jsx(Icon, { name: "fa-solid fa-tower-broadcast", className: "h-4 w-4" }),
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An external link into the public SDK docs. Opens in a new tab: the harness
|
|
3
|
+
* holds unsaved local state (toolbar choices, an in-progress activation form)
|
|
4
|
+
* that navigating away in place would throw out.
|
|
5
|
+
*/
|
|
6
|
+
export declare function DocsLink({ href, children, className, ...rest }: {
|
|
7
|
+
href: string;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
'data-test'?: string;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from "@ekanos/ui/icon";
|
|
3
|
+
import { cn } from "@ekanos/ui/utils";
|
|
4
|
+
function DocsLink({
|
|
5
|
+
href,
|
|
6
|
+
children,
|
|
7
|
+
className,
|
|
8
|
+
...rest
|
|
9
|
+
}) {
|
|
10
|
+
return /* @__PURE__ */ jsxs(
|
|
11
|
+
"a",
|
|
12
|
+
{
|
|
13
|
+
href,
|
|
14
|
+
target: "_blank",
|
|
15
|
+
rel: "noopener noreferrer",
|
|
16
|
+
className: cn(
|
|
17
|
+
// `text-label`, not `text-meta`: this is an interactive link label,
|
|
18
|
+
// and the scale reserves Meta for tertiary metadata. The tier carries
|
|
19
|
+
// its own 500, so the only visual change is 400 -> 500 on one small
|
|
20
|
+
// link. Landed on `dev` as `text-sm` just before
|
|
21
|
+
// `design/no-raw-text-size` became an error here.
|
|
22
|
+
"text-muted-foreground hover:text-foreground text-label flex items-center gap-2 underline-offset-2 hover:underline",
|
|
23
|
+
className
|
|
24
|
+
),
|
|
25
|
+
...rest,
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsx(Icon, { name: "fa-solid fa-book", className: "h-4 w-4" }),
|
|
28
|
+
children
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
DocsLink
|
|
35
|
+
};
|
|
@@ -50,7 +50,7 @@ function LocalOAuthPanel({
|
|
|
50
50
|
/* @__PURE__ */ jsx(Badge, { variant: "outline", children: live ? "live" : "fixtures" }),
|
|
51
51
|
live && setup.data ? /* @__PURE__ */ jsx(Badge, { variant: setup.data.connected ? "default" : "secondary", children: setup.data.connected ? "connected" : "not connected" }) : null
|
|
52
52
|
] }),
|
|
53
|
-
setup.isPending ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-
|
|
53
|
+
setup.isPending ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: "Reading local setup\u2026" }) : setup.isError ? /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
|
|
54
54
|
/* @__PURE__ */ jsx(AlertTitle, { children: "The harness API did not answer" }),
|
|
55
55
|
/* @__PURE__ */ jsxs(AlertDescription, { children: [
|
|
56
56
|
/* @__PURE__ */ jsx("p", { children: setup.error.message }),
|
|
@@ -64,7 +64,7 @@ function LocalOAuthPanel({
|
|
|
64
64
|
] })
|
|
65
65
|
] })
|
|
66
66
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
67
|
-
/* @__PURE__ */ jsxs("ol", { className: "flex flex-col gap-5
|
|
67
|
+
/* @__PURE__ */ jsxs("ol", { className: "text-meta flex flex-col gap-5", children: [
|
|
68
68
|
/* @__PURE__ */ jsxs("li", { className: "flex flex-col gap-2", children: [
|
|
69
69
|
/* @__PURE__ */ jsx("span", { className: "font-medium", children: "1. Set up the OAuth app at your provider \u2014 this part is yours" }),
|
|
70
70
|
setup.data.redirectUri ? /* @__PURE__ */ jsx(
|
|
@@ -88,7 +88,7 @@ function LocalOAuthPanel({
|
|
|
88
88
|
onSaved: (next) => queryClient.setQueryData(queryKey, next)
|
|
89
89
|
}
|
|
90
90
|
),
|
|
91
|
-
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-
|
|
91
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-fine", children: [
|
|
92
92
|
"Saved to ",
|
|
93
93
|
/* @__PURE__ */ jsx("code", { children: setup.data.file }),
|
|
94
94
|
" in your project \u2014 gitignored, never packed, read on every request. A saved key shows as filled beside an empty field; leave a field blank to keep it. Saving forgets any current connection."
|
|
@@ -96,7 +96,7 @@ function LocalOAuthPanel({
|
|
|
96
96
|
] }),
|
|
97
97
|
/* @__PURE__ */ jsxs("li", { className: "flex flex-col gap-1", children: [
|
|
98
98
|
/* @__PURE__ */ jsx("span", { className: "font-medium", children: "3. Open the connect dialog (above) and click Connect" }),
|
|
99
|
-
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-
|
|
99
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-fine", children: [
|
|
100
100
|
"The browser goes to the provider, comes back to the redirect URI above, the shell exchanges the code through your declared egress and calls ",
|
|
101
101
|
/* @__PURE__ */ jsx("code", { children: "onTokens" }),
|
|
102
102
|
" on a server-held context. Widgets then read what your handlers wrote through the normal storage route."
|
|
@@ -106,7 +106,7 @@ function LocalOAuthPanel({
|
|
|
106
106
|
live ? /* @__PURE__ */ jsxs(
|
|
107
107
|
"p",
|
|
108
108
|
{
|
|
109
|
-
className: "text-muted-foreground text-
|
|
109
|
+
className: "text-muted-foreground text-fine",
|
|
110
110
|
"data-test": "local-oauth-connection",
|
|
111
111
|
children: [
|
|
112
112
|
setup.data.connection ? `Connected since ${setup.data.connection.obtainedAt}` + (setup.data.connection.expiresAt ? `; access token expires ${setup.data.connection.expiresAt}` : "") + ". " : "Not connected on this server. ",
|
|
@@ -131,7 +131,7 @@ function SetupChecklist({ guide }) {
|
|
|
131
131
|
return /* @__PURE__ */ jsxs(
|
|
132
132
|
"ul",
|
|
133
133
|
{
|
|
134
|
-
className: "text-muted-foreground flex flex-col gap-2
|
|
134
|
+
className: "text-muted-foreground text-meta flex flex-col gap-2",
|
|
135
135
|
"data-test": "local-oauth-checklist",
|
|
136
136
|
children: [
|
|
137
137
|
/* @__PURE__ */ jsx("li", { children: guide.console ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -168,7 +168,7 @@ function SetupChecklist({ guide }) {
|
|
|
168
168
|
guide.scopes.length > 0 ? /* @__PURE__ */ jsxs("li", { children: [
|
|
169
169
|
"Enable these scopes:",
|
|
170
170
|
" ",
|
|
171
|
-
guide.scopes.map((scope) => /* @__PURE__ */ jsx("code", { className: "mr-1
|
|
171
|
+
guide.scopes.map((scope) => /* @__PURE__ */ jsx("code", { className: "text-fine mr-1", children: scope }, scope))
|
|
172
172
|
] }) : null,
|
|
173
173
|
/* @__PURE__ */ jsx("li", { children: guide.pkce ? "The app must allow the Authorization Code grant with PKCE (S256) \u2014 the loop sends a code challenge." : "The app must allow the Authorization Code grant." }),
|
|
174
174
|
/* @__PURE__ */ jsxs("li", { children: [
|
|
@@ -191,7 +191,7 @@ function CopyableCode({ value, testId }) {
|
|
|
191
191
|
/* @__PURE__ */ jsx(
|
|
192
192
|
"code",
|
|
193
193
|
{
|
|
194
|
-
className: "bg-muted flex-1 rounded-md px-3 py-2
|
|
194
|
+
className: "bg-muted text-fine flex-1 rounded-md px-3 py-2 break-all",
|
|
195
195
|
"data-test": testId,
|
|
196
196
|
children: value
|
|
197
197
|
}
|
|
@@ -249,7 +249,7 @@ function CredentialsForm({
|
|
|
249
249
|
}
|
|
250
250
|
});
|
|
251
251
|
if (keys.length === 0) {
|
|
252
|
-
return /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-
|
|
252
|
+
return /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-fine", children: "This definition declares no secret names, so there is nothing to save." });
|
|
253
253
|
}
|
|
254
254
|
return /* @__PURE__ */ jsx(Form, { ...form, children: /* @__PURE__ */ jsxs(
|
|
255
255
|
"form",
|
|
@@ -266,7 +266,7 @@ function CredentialsForm({
|
|
|
266
266
|
name: key.name,
|
|
267
267
|
render: ({ field }) => /* @__PURE__ */ jsxs(FormItem, { children: [
|
|
268
268
|
/* @__PURE__ */ jsxs(FormLabel, { className: "flex items-center gap-2", children: [
|
|
269
|
-
/* @__PURE__ */ jsx("code", { className: "text-
|
|
269
|
+
/* @__PURE__ */ jsx("code", { className: "text-fine", children: key.name }),
|
|
270
270
|
/* @__PURE__ */ jsx(Badge, { variant: key.filled ? "secondary" : "destructive", children: key.filled ? "filled" : "missing" })
|
|
271
271
|
] }),
|
|
272
272
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
@@ -299,7 +299,7 @@ function CredentialsForm({
|
|
|
299
299
|
status.kind === "saved" ? /* @__PURE__ */ jsxs(
|
|
300
300
|
"span",
|
|
301
301
|
{
|
|
302
|
-
className: "text-muted-foreground text-
|
|
302
|
+
className: "text-muted-foreground text-fine",
|
|
303
303
|
"data-test": "local-oauth-saved",
|
|
304
304
|
children: [
|
|
305
305
|
"Saved ",
|
|
@@ -312,7 +312,7 @@ function CredentialsForm({
|
|
|
312
312
|
) : status.kind === "error" ? /* @__PURE__ */ jsx(
|
|
313
313
|
"span",
|
|
314
314
|
{
|
|
315
|
-
className: "text-destructive text-
|
|
315
|
+
className: "text-destructive text-fine",
|
|
316
316
|
"data-test": "local-oauth-error",
|
|
317
317
|
children: status.message
|
|
318
318
|
}
|
|
@@ -331,7 +331,7 @@ function FixturesModeNotice({
|
|
|
331
331
|
return /* @__PURE__ */ jsxs(
|
|
332
332
|
"p",
|
|
333
333
|
{
|
|
334
|
-
className: "text-muted-foreground text-
|
|
334
|
+
className: "text-muted-foreground text-fine",
|
|
335
335
|
"data-test": "local-oauth-fixtures",
|
|
336
336
|
children: [
|
|
337
337
|
"Fixtures mode: the status route is answered from",
|
|
@@ -4,18 +4,24 @@ import Link from "next/link";
|
|
|
4
4
|
import { usePathname } from "next/navigation";
|
|
5
5
|
import { Icon } from "@ekanos/ui/icon";
|
|
6
6
|
import { cn } from "@ekanos/ui/utils";
|
|
7
|
+
import { SURFACE_DOCS } from "../lib/docs-links.js";
|
|
7
8
|
import { HARNESS_SURFACES } from "../surfaces.js";
|
|
9
|
+
import { DocsLink } from "./docs-link.js";
|
|
8
10
|
function SurfaceNav({
|
|
9
11
|
integration
|
|
10
12
|
}) {
|
|
11
13
|
const pathname = usePathname();
|
|
14
|
+
const activeSurface = HARNESS_SURFACES.find(
|
|
15
|
+
(surface) => pathname.startsWith(`/${integration.slug}/${surface.segment}`)
|
|
16
|
+
);
|
|
17
|
+
const surfaceDocs = activeSurface ? SURFACE_DOCS[activeSurface.segment] : void 0;
|
|
12
18
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-5 border-b px-6 py-5", children: [
|
|
13
19
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-baseline gap-3", children: [
|
|
14
20
|
/* @__PURE__ */ jsxs(
|
|
15
21
|
Link,
|
|
16
22
|
{
|
|
17
23
|
href: "/",
|
|
18
|
-
className: "text-muted-foreground hover:text-foreground text-
|
|
24
|
+
className: "text-muted-foreground hover:text-foreground text-meta",
|
|
19
25
|
children: [
|
|
20
26
|
/* @__PURE__ */ jsx(Icon, { name: "fa-solid fa-arrow-left", className: "mr-2 h-4 w-4" }),
|
|
21
27
|
"All integrations"
|
|
@@ -23,29 +29,43 @@ function SurfaceNav({
|
|
|
23
29
|
}
|
|
24
30
|
),
|
|
25
31
|
/* @__PURE__ */ jsx("h1", { className: "font-heading text-2xl tracking-tight", children: integration.name }),
|
|
26
|
-
/* @__PURE__ */ jsx("code", { className: "text-muted-foreground text-
|
|
32
|
+
/* @__PURE__ */ jsx("code", { className: "text-muted-foreground text-fine", children: integration.slug })
|
|
27
33
|
] }),
|
|
28
|
-
/* @__PURE__ */
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
/* @__PURE__ */ jsxs("nav", { className: "flex flex-wrap items-center gap-1", children: [
|
|
35
|
+
HARNESS_SURFACES.map((surface) => {
|
|
36
|
+
const href = `/${integration.slug}/${surface.segment}`;
|
|
37
|
+
const active = pathname.startsWith(href);
|
|
38
|
+
return /* @__PURE__ */ jsxs(
|
|
39
|
+
Link,
|
|
40
|
+
{
|
|
41
|
+
href,
|
|
42
|
+
className: cn(
|
|
43
|
+
"flex items-center gap-2 rounded-md px-3 py-2 transition-colors",
|
|
44
|
+
active ? "bg-accent text-accent-foreground text-label" : "text-muted-foreground hover:bg-accent/50 text-meta"
|
|
45
|
+
),
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx(Icon, { name: surface.icon, className: "h-5 w-5" }),
|
|
48
|
+
surface.label
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
surface.segment
|
|
52
|
+
);
|
|
53
|
+
}),
|
|
54
|
+
activeSurface && surfaceDocs ? /* @__PURE__ */ jsxs(
|
|
55
|
+
DocsLink,
|
|
33
56
|
{
|
|
34
|
-
href,
|
|
35
|
-
className:
|
|
36
|
-
|
|
37
|
-
active ? "bg-accent text-accent-foreground font-medium" : "text-muted-foreground hover:bg-accent/50"
|
|
38
|
-
),
|
|
57
|
+
href: surfaceDocs,
|
|
58
|
+
className: "ml-auto px-3",
|
|
59
|
+
"data-test": "surface-docs-link",
|
|
39
60
|
children: [
|
|
40
|
-
|
|
41
|
-
|
|
61
|
+
activeSurface.label,
|
|
62
|
+
" docs"
|
|
42
63
|
]
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}) }),
|
|
64
|
+
}
|
|
65
|
+
) : null
|
|
66
|
+
] }),
|
|
47
67
|
integration.widgets.length > 0 ? /* @__PURE__ */ jsxs("nav", { className: "flex flex-wrap gap-1", children: [
|
|
48
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground px-3 py-2
|
|
68
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-fine px-3 py-2", children: "Focus one widget:" }),
|
|
49
69
|
integration.widgets.map((widget) => {
|
|
50
70
|
const href = `/${integration.slug}/widgets/${widget.id}`;
|
|
51
71
|
const active = pathname === href;
|
|
@@ -54,8 +74,8 @@ function SurfaceNav({
|
|
|
54
74
|
{
|
|
55
75
|
href,
|
|
56
76
|
className: cn(
|
|
57
|
-
"rounded-md px-3 py-2
|
|
58
|
-
active ? "bg-accent text-accent-foreground
|
|
77
|
+
"rounded-md px-3 py-2 transition-colors",
|
|
78
|
+
active ? "bg-accent text-accent-foreground text-label" : "text-muted-foreground hover:bg-accent/50 text-meta"
|
|
59
79
|
),
|
|
60
80
|
children: widget.title
|
|
61
81
|
},
|
|
@@ -6,7 +6,7 @@ function ViewportFrame({ children }) {
|
|
|
6
6
|
const { width, label } = VIEWPORTS[state.viewport];
|
|
7
7
|
if (width === null) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
8
8
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2", children: [
|
|
9
|
-
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-
|
|
9
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-fine", children: [
|
|
10
10
|
label,
|
|
11
11
|
" \xB7 ",
|
|
12
12
|
width,
|
|
@@ -30,12 +30,12 @@ class WidgetBoundary extends Component {
|
|
|
30
30
|
className: "text-destructive h-5 w-5"
|
|
31
31
|
}
|
|
32
32
|
),
|
|
33
|
-
/* @__PURE__ */ jsxs("p", { className: "text-
|
|
33
|
+
/* @__PURE__ */ jsxs("p", { className: "text-label", children: [
|
|
34
34
|
this.props.widgetId,
|
|
35
35
|
" threw during render"
|
|
36
36
|
] })
|
|
37
37
|
] }),
|
|
38
|
-
/* @__PURE__ */ jsx("pre", { className: "bg-muted text-destructive overflow-x-auto rounded-md p-3
|
|
38
|
+
/* @__PURE__ */ jsx("pre", { className: "bg-muted text-destructive text-fine overflow-x-auto rounded-md p-3 whitespace-pre-wrap", children: error.message })
|
|
39
39
|
] });
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type IntegrationDefinition } from '@ekanos/sdk/integration';
|
|
2
|
+
import type { RaisedAgentEventCheck } from './trigger-contract.js';
|
|
3
|
+
/**
|
|
4
|
+
* The agent events a webhook raised (plan 222), checked the way the host's
|
|
5
|
+
* ingress checks them before recording: declared by this integration, a
|
|
6
|
+
* payload its schema accepts, and not the integration's own activity. The
|
|
7
|
+
* harness starts no agents — it shows what the host would record, and why it
|
|
8
|
+
* would drop the rest.
|
|
9
|
+
*
|
|
10
|
+
* Directive-free: run by the browser runner (fixtures) and the trigger route
|
|
11
|
+
* (live).
|
|
12
|
+
*/
|
|
13
|
+
export declare function checkRaisedAgentEvents(definition: IntegrationDefinition, raised: unknown): Promise<RaisedAgentEventCheck[] | undefined>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MAX_AGENT_EVENT_DEDUPE_KEY_LENGTH,
|
|
3
|
+
MAX_RAISED_AGENT_EVENTS
|
|
4
|
+
} from "@ekanos/sdk/integration";
|
|
5
|
+
async function checkRaisedAgentEvents(definition, raised) {
|
|
6
|
+
if (raised === void 0) return void 0;
|
|
7
|
+
if (!Array.isArray(raised)) {
|
|
8
|
+
return [
|
|
9
|
+
{
|
|
10
|
+
id: "(not a list)",
|
|
11
|
+
dedupeKey: "",
|
|
12
|
+
payload: raised,
|
|
13
|
+
problem: "events must be a list \u2014 the host drops the whole value."
|
|
14
|
+
}
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
const declared = new Map(
|
|
18
|
+
(definition.agentEvents ?? []).map((event) => [event.id, event])
|
|
19
|
+
);
|
|
20
|
+
const checks = await Promise.all(
|
|
21
|
+
raised.slice(0, MAX_RAISED_AGENT_EVENTS).map(async (item) => {
|
|
22
|
+
const event = item ?? {};
|
|
23
|
+
const id = typeof event.id === "string" ? event.id : "(no id)";
|
|
24
|
+
const dedupeKey = typeof event.dedupeKey === "string" ? event.dedupeKey : "";
|
|
25
|
+
const base = { id, dedupeKey, payload: event.payload };
|
|
26
|
+
if (!dedupeKey) {
|
|
27
|
+
return {
|
|
28
|
+
...base,
|
|
29
|
+
problem: "dedupeKey is missing \u2014 the host drops it."
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (dedupeKey.length > MAX_AGENT_EVENT_DEDUPE_KEY_LENGTH) {
|
|
33
|
+
return {
|
|
34
|
+
...base,
|
|
35
|
+
problem: `dedupeKey is longer than ${MAX_AGENT_EVENT_DEDUPE_KEY_LENGTH} characters \u2014 the host drops it.`
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (!("payload" in event)) {
|
|
39
|
+
return {
|
|
40
|
+
...base,
|
|
41
|
+
problem: "payload is missing \u2014 the host drops it."
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const declaration = declared.get(id);
|
|
45
|
+
if (!declaration) {
|
|
46
|
+
return {
|
|
47
|
+
...base,
|
|
48
|
+
problem: `"${id}" is not one of this integration's agentEvents \u2014 the host drops it.`
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const validated = await declaration.payloadSchema["~standard"].validate(event.payload);
|
|
53
|
+
if (validated.issues) {
|
|
54
|
+
return {
|
|
55
|
+
...base,
|
|
56
|
+
problem: `The payload does not match ${id}'s payloadSchema: ${validated.issues.map((issue) => issue.message).join("; ")}`
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (declaration.isOwnActivity?.(validated.value)) {
|
|
60
|
+
return {
|
|
61
|
+
...base,
|
|
62
|
+
problem: "isOwnActivity() says this is the integration\u2019s own activity \u2014 the host drops it, so it never starts an agent."
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const conversation = declaration.conversation?.(validated.value) ?? null;
|
|
66
|
+
return {
|
|
67
|
+
...base,
|
|
68
|
+
payload: validated.value,
|
|
69
|
+
...conversation ? { conversation } : {}
|
|
70
|
+
};
|
|
71
|
+
} catch (error) {
|
|
72
|
+
return {
|
|
73
|
+
...base,
|
|
74
|
+
problem: `${id}'s declaration threw: ${error instanceof Error ? error.message : String(error)} \u2014 the host drops it.`
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
const dropped = raised.length - MAX_RAISED_AGENT_EVENTS;
|
|
80
|
+
return dropped > 0 ? [
|
|
81
|
+
...checks,
|
|
82
|
+
{
|
|
83
|
+
id: `(${dropped} more)`,
|
|
84
|
+
dedupeKey: "",
|
|
85
|
+
payload: null,
|
|
86
|
+
problem: `A delivery may raise at most ${MAX_RAISED_AGENT_EVENTS} agent events \u2014 the host drops the rest.`
|
|
87
|
+
}
|
|
88
|
+
] : checks;
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
checkRaisedAgentEvents
|
|
92
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The public Ekanos SDK docs. Every docs link the harness renders reads this. */
|
|
2
|
+
export declare const SDK_DOCS_URL = "https://sdk.ekanos.dev";
|
|
3
|
+
export declare const HARNESS_DOCS_URL = "https://sdk.ekanos.dev/harness/overview";
|
|
4
|
+
/** The docs page for each harness surface, keyed by `HarnessSurface.segment`. */
|
|
5
|
+
export declare const SURFACE_DOCS: Readonly<Record<string, string>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const SDK_DOCS_URL = "https://sdk.ekanos.dev";
|
|
2
|
+
const HARNESS_DOCS_URL = `${SDK_DOCS_URL}/harness/overview`;
|
|
3
|
+
const SURFACE_DOCS = {
|
|
4
|
+
widgets: `${SDK_DOCS_URL}/sdk/surfaces/widgets`,
|
|
5
|
+
tile: `${SDK_DOCS_URL}/sdk/surfaces/marketplace-tile`,
|
|
6
|
+
activation: `${SDK_DOCS_URL}/sdk/surfaces/activation-form`,
|
|
7
|
+
triggers: `${SDK_DOCS_URL}/harness/triggers`
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
HARNESS_DOCS_URL,
|
|
11
|
+
SDK_DOCS_URL,
|
|
12
|
+
SURFACE_DOCS
|
|
13
|
+
};
|
|
@@ -18,6 +18,22 @@ export interface StorageDump {
|
|
|
18
18
|
account: Record<string, unknown>;
|
|
19
19
|
user: Record<string, unknown>;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* One agent event a webhook raised (plan 222), as the host would treat it.
|
|
23
|
+
* `problem` says why the host would drop it; absent, it would be recorded
|
|
24
|
+
* and start every agent whose trigger matches.
|
|
25
|
+
*/
|
|
26
|
+
export interface RaisedAgentEventCheck {
|
|
27
|
+
id: string;
|
|
28
|
+
dedupeKey: string;
|
|
29
|
+
payload: unknown;
|
|
30
|
+
/** Where a run it starts would answer, when the event declares one. */
|
|
31
|
+
conversation?: {
|
|
32
|
+
key: string;
|
|
33
|
+
target: Record<string, unknown>;
|
|
34
|
+
};
|
|
35
|
+
problem?: string;
|
|
36
|
+
}
|
|
21
37
|
/** The outcome of one webhook delivery or schedule run. */
|
|
22
38
|
export interface InvocationOutcome {
|
|
23
39
|
ok: boolean;
|
|
@@ -30,6 +46,8 @@ export interface InvocationOutcome {
|
|
|
30
46
|
* looked like a handler that had written nothing.
|
|
31
47
|
*/
|
|
32
48
|
storage: StorageDump;
|
|
49
|
+
/** Agent events a webhook delivery raised, checked like the host does. */
|
|
50
|
+
agentEvents?: RaisedAgentEventCheck[];
|
|
33
51
|
}
|
|
34
52
|
/** The outcome of one `onActivate` run — see `run-activation-hook.ts`. */
|
|
35
53
|
export type OnActivateOutcome = {
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
invokeSchedule,
|
|
3
3
|
invokeWebhook
|
|
4
4
|
} from "@ekanos/sdk/testing";
|
|
5
|
+
import { checkRaisedAgentEvents } from "./check-raised-agent-events.js";
|
|
5
6
|
import { runOnActivateHook } from "./run-activation-hook.js";
|
|
6
7
|
function describeError(error) {
|
|
7
8
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -11,12 +12,17 @@ function createLocalTriggerRunner(definition, ctx) {
|
|
|
11
12
|
const logsBefore = ctx.logs.length;
|
|
12
13
|
try {
|
|
13
14
|
const result = await invoke();
|
|
15
|
+
const agentEvents = await checkRaisedAgentEvents(
|
|
16
|
+
definition,
|
|
17
|
+
result.events
|
|
18
|
+
);
|
|
14
19
|
return {
|
|
15
20
|
ok: true,
|
|
16
21
|
summary: result.status,
|
|
17
22
|
...result.detail ? { detail: result.detail } : {},
|
|
18
23
|
logs: ctx.logs.slice(logsBefore),
|
|
19
|
-
storage: ctx.dumpStorage()
|
|
24
|
+
storage: ctx.dumpStorage(),
|
|
25
|
+
...agentEvents ? { agentEvents } : {}
|
|
20
26
|
};
|
|
21
27
|
} catch (error) {
|
|
22
28
|
console.error("[harness] handler invocation failed:", error);
|
|
@@ -82,8 +82,8 @@ function ActivationPage() {
|
|
|
82
82
|
] }),
|
|
83
83
|
/* @__PURE__ */ jsxs("div", { className: "bg-card flex flex-wrap items-center justify-between gap-3 rounded-lg border p-5", children: [
|
|
84
84
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
85
|
-
/* @__PURE__ */ jsx("span", { className: "text-
|
|
86
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-
|
|
85
|
+
/* @__PURE__ */ jsx("span", { className: "text-label", children: flow.connected ? "Connected" : "Not connected" }),
|
|
86
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-meta", children: flow.connected ? "The dialog now shows the manage view, whose only action is Disconnect." : definition?.oauth ? "Save your local OAuth credentials below, then open the connect dialog and click Connect." : "The dialog shows the scope disclosure and your activation form." })
|
|
87
87
|
] }),
|
|
88
88
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
89
89
|
/* @__PURE__ */ jsx(
|
|
@@ -132,7 +132,7 @@ function ActivationPage() {
|
|
|
132
132
|
onOpenChange: (next) => setFlow((prev) => ({ ...prev, open: next })),
|
|
133
133
|
children: /* @__PURE__ */ jsxs(DialogContent, { "data-test": "integration-connect-dialog", children: [
|
|
134
134
|
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
135
|
-
/* @__PURE__ */ jsx("span", { className: "font-heading bg-muted text-muted-foreground flex h-10 w-10 shrink-0 items-center justify-center rounded-full
|
|
135
|
+
/* @__PURE__ */ jsx("span", { className: "font-heading bg-muted text-muted-foreground text-title flex h-10 w-10 shrink-0 items-center justify-center rounded-full", children: integration.name.trim().charAt(0).toUpperCase() || "?" }),
|
|
136
136
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
137
137
|
/* @__PURE__ */ jsx(DialogTitle, { children: integration.name }),
|
|
138
138
|
/* @__PURE__ */ jsx(DialogDescription, { children: summary })
|
|
@@ -187,7 +187,7 @@ function ActivationPage() {
|
|
|
187
187
|
] })
|
|
188
188
|
] })
|
|
189
189
|
}
|
|
190
|
-
) : /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-
|
|
190
|
+
) : /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: "This integration registers no activation form." }),
|
|
191
191
|
capabilities.length === 0 && permissions.length === 0 ? /* @__PURE__ */ jsxs(Alert, { children: [
|
|
192
192
|
/* @__PURE__ */ jsx(AlertTitle, { children: "No capabilities or permissions declared" }),
|
|
193
193
|
/* @__PURE__ */ jsx(AlertDescription, { children: /* @__PURE__ */ jsxs("p", { children: [
|
|
@@ -230,7 +230,7 @@ function ActivationPage() {
|
|
|
230
230
|
)
|
|
231
231
|
] })
|
|
232
232
|
] }),
|
|
233
|
-
/* @__PURE__ */ jsx("pre", { className: "bg-muted overflow-x-auto rounded-md p-3
|
|
233
|
+
/* @__PURE__ */ jsx("pre", { className: "bg-muted text-fine overflow-x-auto rounded-md p-3", children: JSON.stringify(
|
|
234
234
|
flow.revealed ? flow.result : redactSensitive(flow.result),
|
|
235
235
|
null,
|
|
236
236
|
2
|
|
@@ -256,16 +256,16 @@ function OnActivatePanel({
|
|
|
256
256
|
"data-test": "activation-onactivate-outcome",
|
|
257
257
|
children: [
|
|
258
258
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx(Badge, { variant: badge.variant, children: badge.label }) }),
|
|
259
|
-
outcome.status === "skipped" ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-
|
|
259
|
+
outcome.status === "skipped" ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-meta", children: [
|
|
260
260
|
"This integration declares no ",
|
|
261
261
|
/* @__PURE__ */ jsx("code", { children: "onActivate" }),
|
|
262
262
|
" hook \u2014 a perfectly good answer for one with nothing to seed at connect time. Add one to ",
|
|
263
263
|
/* @__PURE__ */ jsx("code", { children: "defineIntegration()" }),
|
|
264
264
|
" to warm a cache or sanity-check a credential the moment a user connects."
|
|
265
265
|
] }) : outcome.status === "threw" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
266
|
-
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-
|
|
267
|
-
/* @__PURE__ */ jsx("pre", { className: "bg-muted overflow-x-auto rounded-md p-3
|
|
268
|
-
] }) : /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-
|
|
266
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: "In production this is NON-FATAL: the throw is logged and shown to the user as a warning, and the activation stays connected \u2014 this hook is for cache seeding and eager validation, not a connect gate." }),
|
|
267
|
+
/* @__PURE__ */ jsx("pre", { className: "bg-muted text-fine overflow-x-auto rounded-md p-3", children: outcome.message })
|
|
268
|
+
] }) : /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: mode === "live" ? "Ran on the dev server against the live context \u2014 the same storage and secrets the OAuth loop and your schedules use, with ctx.fetch reaching your vendor under the declared egress." : "Ran against the same kind of capability context (storage, secrets, egress) your schedules and webhooks run against." })
|
|
269
269
|
]
|
|
270
270
|
}
|
|
271
271
|
);
|
|
@@ -276,7 +276,7 @@ function CapabilityList({
|
|
|
276
276
|
if (capabilities.length === 0) return null;
|
|
277
277
|
return /* @__PURE__ */ jsxs("section", { className: "flex flex-col gap-2", children: [
|
|
278
278
|
/* @__PURE__ */ jsx("h3", { className: "text-muted-foreground text-xs font-semibold tracking-wider uppercase", children: "What it does" }),
|
|
279
|
-
/* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-1.5", children: capabilities.map((capability) => /* @__PURE__ */ jsxs("li", { className: "text-foreground text-
|
|
279
|
+
/* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-1.5", children: capabilities.map((capability) => /* @__PURE__ */ jsxs("li", { className: "text-foreground text-meta", children: [
|
|
280
280
|
capability.label,
|
|
281
281
|
capability.description ? /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
282
282
|
" ",
|
|
@@ -294,7 +294,7 @@ function PermissionList({
|
|
|
294
294
|
/* @__PURE__ */ jsx("h3", { className: "text-muted-foreground text-xs font-semibold tracking-wider uppercase", children: "What it can access" }),
|
|
295
295
|
/* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-2", children: permissions.map((permission) => /* @__PURE__ */ jsxs("li", { className: "flex flex-col gap-0.5", children: [
|
|
296
296
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
297
|
-
/* @__PURE__ */ jsx("span", { className: "text-foreground text-
|
|
297
|
+
/* @__PURE__ */ jsx("span", { className: "text-foreground text-label", children: permission.label }),
|
|
298
298
|
/* @__PURE__ */ jsx(
|
|
299
299
|
StatusBadge,
|
|
300
300
|
{
|
|
@@ -303,7 +303,7 @@ function PermissionList({
|
|
|
303
303
|
}
|
|
304
304
|
)
|
|
305
305
|
] }),
|
|
306
|
-
permission.detail ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-
|
|
306
|
+
permission.detail ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-meta", children: permission.detail }) : null
|
|
307
307
|
] }, permission.label)) })
|
|
308
308
|
] });
|
|
309
309
|
}
|
|
@@ -314,14 +314,14 @@ function ConnectedState({
|
|
|
314
314
|
onDisconnect
|
|
315
315
|
}) {
|
|
316
316
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-5", children: [
|
|
317
|
-
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-
|
|
317
|
+
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-meta", children: [
|
|
318
318
|
name,
|
|
319
319
|
" is connected to your workspace."
|
|
320
320
|
] }),
|
|
321
321
|
/* @__PURE__ */ jsx(
|
|
322
322
|
"p",
|
|
323
323
|
{
|
|
324
|
-
className: "text-muted-foreground text-
|
|
324
|
+
className: "text-muted-foreground text-meta",
|
|
325
325
|
"data-test": "activation-mode-notice",
|
|
326
326
|
children: mode === "live" ? hasLiveActivationData ? "The toolbar is on Live API \u2014 this activation data is available to live-mode widgets on this visit." : "The toolbar is on Live API. This activation submitted no data of its own; an OAuth integration\u2019s credentials live on the dev server, where onTokens stored them." : "This surface is Ekanos-mocked; widgets read fixtures \u2014 switch the toolbar to Live API to exercise real requests."
|
|
327
327
|
}
|
|
@@ -7,8 +7,8 @@ function IndexPage({
|
|
|
7
7
|
}) {
|
|
8
8
|
return /* @__PURE__ */ jsxs("main", { className: "mx-auto flex w-full max-w-5xl flex-col gap-6 px-6 py-10", children: [
|
|
9
9
|
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-2", children: [
|
|
10
|
-
/* @__PURE__ */ jsx("h1", { className: "font-heading text-
|
|
11
|
-
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-
|
|
10
|
+
/* @__PURE__ */ jsx("h1", { className: "font-heading text-headline-lg font-normal tracking-tight", children: "Integration harness" }),
|
|
11
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: "Every registered integration, rendered in real Ekanos chrome from fixtures. No Supabase, no auth, no network." })
|
|
12
12
|
] }),
|
|
13
13
|
integrations.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "bg-card flex flex-col items-center gap-3 rounded-lg border p-6 text-center", children: [
|
|
14
14
|
/* @__PURE__ */ jsx(
|
|
@@ -18,7 +18,7 @@ function IndexPage({
|
|
|
18
18
|
className: "text-muted-foreground h-6 w-6"
|
|
19
19
|
}
|
|
20
20
|
),
|
|
21
|
-
/* @__PURE__ */ jsx("p", { className: "text-
|
|
21
|
+
/* @__PURE__ */ jsx("p", { className: "text-meta", children: "No integrations registered. Add one to your harness config at the project root." })
|
|
22
22
|
] }) : /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-5", "data-test": "integration-list", children: integrations.map((integration) => /* @__PURE__ */ jsxs(
|
|
23
23
|
"li",
|
|
24
24
|
{
|
|
@@ -26,21 +26,21 @@ function IndexPage({
|
|
|
26
26
|
children: [
|
|
27
27
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
28
28
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-baseline gap-3", children: [
|
|
29
|
-
/* @__PURE__ */ jsx("h2", { className: "font-heading text-
|
|
30
|
-
/* @__PURE__ */ jsx("code", { className: "text-muted-foreground text-
|
|
29
|
+
/* @__PURE__ */ jsx("h2", { className: "font-heading text-subhead-lg font-normal tracking-tight", children: integration.name }),
|
|
30
|
+
/* @__PURE__ */ jsx("code", { className: "text-muted-foreground text-fine", children: integration.slug })
|
|
31
31
|
] }),
|
|
32
|
-
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-
|
|
32
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: integration.description })
|
|
33
33
|
] }),
|
|
34
34
|
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: HARNESS_SURFACES.map((surface) => /* @__PURE__ */ jsx(
|
|
35
35
|
Link,
|
|
36
36
|
{
|
|
37
37
|
href: `/${integration.slug}/${surface.segment}`,
|
|
38
|
-
className: "bg-accent/50 hover:bg-accent rounded-md px-3 py-2
|
|
38
|
+
className: "bg-accent/50 hover:bg-accent text-meta rounded-md px-3 py-2 transition-colors",
|
|
39
39
|
children: surface.shortLabel
|
|
40
40
|
},
|
|
41
41
|
surface.segment
|
|
42
42
|
)) }),
|
|
43
|
-
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-
|
|
43
|
+
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-fine", children: [
|
|
44
44
|
integration.widgets.length,
|
|
45
45
|
" widget",
|
|
46
46
|
integration.widgets.length === 1 ? "" : "s",
|
|
@@ -79,7 +79,7 @@ function EgressMismatchNotice({ mismatch }) {
|
|
|
79
79
|
/* @__PURE__ */ jsx("code", { children: "defineIntegration({ egress })" }),
|
|
80
80
|
":"
|
|
81
81
|
] }),
|
|
82
|
-
/* @__PURE__ */ jsx("ul", { className: "mt-2 flex flex-col gap-1", children: mismatch.undeclared.map((origin) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("code", { className: "text-
|
|
82
|
+
/* @__PURE__ */ jsx("ul", { className: "mt-2 flex flex-col gap-1", children: mismatch.undeclared.map((origin) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("code", { className: "text-meta", children: origin }) }, origin)) }),
|
|
83
83
|
/* @__PURE__ */ jsx("p", { className: "mt-3", children: "The definition is what a reviewer reads and what production enforces, so running live against a wider list would prove nothing about the integration we actually ship. Import the same constant into both \u2014 never retype it \u2014 and this goes away." })
|
|
84
84
|
] })
|
|
85
85
|
] }) });
|
|
@@ -41,10 +41,10 @@ function TilePage() {
|
|
|
41
41
|
Tile ? /* @__PURE__ */ jsx(ViewportFrame, { children: /* @__PURE__ */ jsxs("section", { className: "flex flex-col gap-4", children: [
|
|
42
42
|
/* @__PURE__ */ jsxs("header", { children: [
|
|
43
43
|
/* @__PURE__ */ jsxs("div", { className: "flex items-baseline gap-2.5", children: [
|
|
44
|
-
/* @__PURE__ */ jsx("h2", { className: "font-heading text-foreground text-
|
|
45
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-
|
|
44
|
+
/* @__PURE__ */ jsx("h2", { className: "font-heading text-foreground text-subhead-lg tracking-tight", children: "Available integrations" }),
|
|
45
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-meta tabular-nums", children: "3" })
|
|
46
46
|
] }),
|
|
47
|
-
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-1 max-w-prose
|
|
47
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta mt-1 max-w-prose", children: "Your tile in the catalogue grid, with two inert neighbours for scale. Column width, gap and heading come from the real marketplace." })
|
|
48
48
|
] }),
|
|
49
49
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[repeat(auto-fill,minmax(17rem,1fr))] gap-4", children: [
|
|
50
50
|
/* @__PURE__ */ jsx(
|
|
@@ -57,7 +57,7 @@ function TilePage() {
|
|
|
57
57
|
),
|
|
58
58
|
NEIGHBOURS.map((neighbour) => /* @__PURE__ */ jsx(NeighbourCard, { ...neighbour }, neighbour.name))
|
|
59
59
|
] })
|
|
60
|
-
] }) }) : /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-
|
|
60
|
+
] }) }) : /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: "This integration registers no marketplace tile." })
|
|
61
61
|
]
|
|
62
62
|
}
|
|
63
63
|
);
|
|
@@ -74,11 +74,11 @@ function NeighbourCard({
|
|
|
74
74
|
className: "bg-card text-card-foreground shadow-card flex h-full flex-col gap-0 rounded-xl border p-5 opacity-60",
|
|
75
75
|
children: [
|
|
76
76
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
77
|
-
/* @__PURE__ */ jsx("span", { className: "font-heading bg-muted text-muted-foreground flex h-10 w-10 shrink-0 items-center justify-center rounded-lg
|
|
78
|
-
/* @__PURE__ */ jsx("span", { className: "font-heading
|
|
77
|
+
/* @__PURE__ */ jsx("span", { className: "font-heading bg-muted text-muted-foreground text-title flex h-10 w-10 shrink-0 items-center justify-center rounded-lg", children: name.charAt(0) }),
|
|
78
|
+
/* @__PURE__ */ jsx("span", { className: "font-heading text-title truncate tracking-tight", children: name })
|
|
79
79
|
] }),
|
|
80
|
-
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-3 line-clamp-2
|
|
81
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground mt-auto pt-4
|
|
80
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta mt-3 line-clamp-2", children: description }),
|
|
81
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-meta mt-auto pt-4", children: vendor })
|
|
82
82
|
]
|
|
83
83
|
}
|
|
84
84
|
);
|
|
@@ -39,22 +39,109 @@ function OutcomePanel({ outcome }) {
|
|
|
39
39
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", "data-test": "trigger-outcome", children: [
|
|
40
40
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
41
41
|
/* @__PURE__ */ jsx(Badge, { variant: outcome.ok ? "default" : "destructive", children: outcome.summary }),
|
|
42
|
-
outcome.detail ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-
|
|
42
|
+
outcome.detail ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-meta", children: outcome.detail }) : null
|
|
43
43
|
] }),
|
|
44
|
+
outcome.agentEvents ? /* @__PURE__ */ jsx(RaisedAgentEvents, { events: outcome.agentEvents }) : null,
|
|
44
45
|
outcome.logs.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
45
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-
|
|
46
|
-
/* @__PURE__ */ jsx("pre", { className: "bg-muted max-h-48 overflow-auto rounded-md p-3
|
|
46
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-fine", children: "Handler logs" }),
|
|
47
|
+
/* @__PURE__ */ jsx("pre", { className: "bg-muted text-fine max-h-48 overflow-auto rounded-md p-3", children: outcome.logs.map((log) => `[${log.level}] ${log.message}`).join("\n") })
|
|
47
48
|
] }) : null,
|
|
48
49
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3", children: ["account", "user"].map((scope) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
49
|
-
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-
|
|
50
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-fine", children: [
|
|
50
51
|
scope === "account" ? "Account" : "User",
|
|
51
52
|
" storage after this run",
|
|
52
53
|
Object.keys(outcome.storage[scope]).length === 0 ? " (empty)" : ""
|
|
53
54
|
] }),
|
|
54
|
-
/* @__PURE__ */ jsx("pre", { className: "bg-muted max-h-64 overflow-auto rounded-md p-3
|
|
55
|
+
/* @__PURE__ */ jsx("pre", { className: "bg-muted text-fine max-h-64 overflow-auto rounded-md p-3", children: JSON.stringify(outcome.storage[scope], null, 2) })
|
|
55
56
|
] }, scope)) })
|
|
56
57
|
] });
|
|
57
58
|
}
|
|
59
|
+
function RaisedAgentEvents({ events }) {
|
|
60
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", "data-test": "raised-agent-events", children: [
|
|
61
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-fine", children: [
|
|
62
|
+
"Agent events raised (",
|
|
63
|
+
events.length,
|
|
64
|
+
") \u2014 the host records these and starts every agent whose trigger matches"
|
|
65
|
+
] }),
|
|
66
|
+
events.map((event, index) => /* @__PURE__ */ jsxs(
|
|
67
|
+
"div",
|
|
68
|
+
{
|
|
69
|
+
className: "flex flex-col gap-1 rounded-md border p-3",
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
72
|
+
/* @__PURE__ */ jsx("code", { className: "text-meta", children: event.id }),
|
|
73
|
+
/* @__PURE__ */ jsx(Badge, { variant: event.problem ? "destructive" : "secondary", children: event.problem ? "dropped" : "would be recorded" }),
|
|
74
|
+
event.dedupeKey ? /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-fine", children: [
|
|
75
|
+
"dedupe ",
|
|
76
|
+
/* @__PURE__ */ jsx("code", { children: event.dedupeKey })
|
|
77
|
+
] }) : null
|
|
78
|
+
] }),
|
|
79
|
+
event.problem ? /* @__PURE__ */ jsx("p", { className: "text-destructive text-fine", children: event.problem }) : null,
|
|
80
|
+
event.conversation ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-fine", children: [
|
|
81
|
+
"A run it starts answers in ",
|
|
82
|
+
/* @__PURE__ */ jsx("code", { children: event.conversation.key })
|
|
83
|
+
] }) : null,
|
|
84
|
+
/* @__PURE__ */ jsx("pre", { className: "bg-muted text-fine max-h-40 overflow-auto rounded-md p-2", children: JSON.stringify(event.payload, null, 2) })
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
`${event.id}:${event.dedupeKey}:${index}`
|
|
88
|
+
))
|
|
89
|
+
] });
|
|
90
|
+
}
|
|
91
|
+
function AgentEventsCard({
|
|
92
|
+
definition
|
|
93
|
+
}) {
|
|
94
|
+
const events = definition.agentEvents ?? [];
|
|
95
|
+
const channel = definition.agentChannel;
|
|
96
|
+
if (events.length === 0 && !channel) return null;
|
|
97
|
+
return /* @__PURE__ */ jsxs(
|
|
98
|
+
"div",
|
|
99
|
+
{
|
|
100
|
+
className: "bg-card flex flex-col gap-5 rounded-lg border p-6",
|
|
101
|
+
"data-test": "agent-events",
|
|
102
|
+
children: [
|
|
103
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
104
|
+
/* @__PURE__ */ jsx("h3", { className: "font-heading text-subhead tracking-tight", children: "Agent events" }),
|
|
105
|
+
/* @__PURE__ */ jsx(Badge, { variant: "outline", children: "agents" }),
|
|
106
|
+
channel ? /* @__PURE__ */ jsxs(Badge, { variant: "secondary", children: [
|
|
107
|
+
"replies with ",
|
|
108
|
+
/* @__PURE__ */ jsx("code", { children: channel.replyTool.name })
|
|
109
|
+
] }) : /* @__PURE__ */ jsx(Badge, { variant: "secondary", children: "no channel \u2014 runs answer in Ekanos" })
|
|
110
|
+
] }),
|
|
111
|
+
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-meta", children: [
|
|
112
|
+
"A team picks one of these as an agent trigger and fills in its filter. Your webhooks raise them through ",
|
|
113
|
+
/* @__PURE__ */ jsx("code", { children: "WebhookResult.events" }),
|
|
114
|
+
"; deliver a webhook above to see what it raises."
|
|
115
|
+
] }),
|
|
116
|
+
events.map((event) => /* @__PURE__ */ jsxs(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
className: "flex flex-col gap-2 rounded-md border p-4",
|
|
120
|
+
"data-test": `agent-event-${event.id}`,
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
123
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: event.label }),
|
|
124
|
+
/* @__PURE__ */ jsx("code", { className: "text-muted-foreground text-fine", children: event.id }),
|
|
125
|
+
event.conversation ? /* @__PURE__ */ jsx(Badge, { variant: "outline", children: "answers in place" }) : null
|
|
126
|
+
] }),
|
|
127
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: event.description }),
|
|
128
|
+
event.filter?.fields.length ? /* @__PURE__ */ jsx("ul", { className: "text-muted-foreground text-fine list-disc pl-5", children: event.filter.fields.map((field) => /* @__PURE__ */ jsxs("li", { children: [
|
|
129
|
+
/* @__PURE__ */ jsx("code", { children: field.key }),
|
|
130
|
+
" \u2014 ",
|
|
131
|
+
field.label,
|
|
132
|
+
" (",
|
|
133
|
+
field.type,
|
|
134
|
+
field.required ? ", required" : "",
|
|
135
|
+
")"
|
|
136
|
+
] }, field.key)) }) : /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-fine", children: "No filter: every event of this kind starts the agent." })
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
event.id
|
|
140
|
+
))
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
}
|
|
58
145
|
function WebhookCard({
|
|
59
146
|
webhook,
|
|
60
147
|
runner
|
|
@@ -99,10 +186,10 @@ function WebhookCard({
|
|
|
99
186
|
] }),
|
|
100
187
|
webhook.signature !== "none" && webhook.signature.scheme ? /* @__PURE__ */ jsx(Badge, { variant: "outline", "data-test": `webhook-${webhook.id}-scheme`, children: describeSignatureScheme(webhook.signature.scheme) }) : null
|
|
101
188
|
] }),
|
|
102
|
-
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-
|
|
103
|
-
webhook.signature !== "none" ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-
|
|
189
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: webhook.description }),
|
|
190
|
+
webhook.signature !== "none" ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-fine", children: "Signature verification is the transport's job \u2014 the harness skips it (and says so in the handler logs); the host ingress will enforce it before your handler ever runs." }) : null,
|
|
104
191
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
105
|
-
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-
|
|
192
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-fine", children: [
|
|
106
193
|
"Payload (validated against ",
|
|
107
194
|
/* @__PURE__ */ jsx("code", { children: "payloadSchema" }),
|
|
108
195
|
" before the handler runs)"
|
|
@@ -113,7 +200,7 @@ function WebhookCard({
|
|
|
113
200
|
value: state.payload,
|
|
114
201
|
onChange: (event) => setState((s) => ({ ...s, payload: event.target.value })),
|
|
115
202
|
rows: 10,
|
|
116
|
-
className: "font-mono
|
|
203
|
+
className: "text-fine font-mono",
|
|
117
204
|
"data-test": `webhook-payload-${webhook.id}`
|
|
118
205
|
}
|
|
119
206
|
)
|
|
@@ -153,8 +240,8 @@ function ScheduleCard({
|
|
|
153
240
|
/* @__PURE__ */ jsx(Badge, { variant: "outline", children: "schedule" }),
|
|
154
241
|
/* @__PURE__ */ jsx(Badge, { variant: "secondary", children: /* @__PURE__ */ jsx("code", { children: schedule.cron }) })
|
|
155
242
|
] }),
|
|
156
|
-
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-
|
|
157
|
-
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-
|
|
243
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: schedule.description }),
|
|
244
|
+
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-fine", children: [
|
|
158
245
|
"The host scheduler fires this cron with",
|
|
159
246
|
" ",
|
|
160
247
|
/* @__PURE__ */ jsx("code", { children: "trigger: 'schedule'" }),
|
|
@@ -204,7 +291,7 @@ function OAuthCard({
|
|
|
204
291
|
/* @__PURE__ */ jsx("h3", { className: "font-heading text-lg tracking-tight", children: "OAuth declaration" }),
|
|
205
292
|
/* @__PURE__ */ jsx(Badge, { variant: "outline", children: "oauth" })
|
|
206
293
|
] }),
|
|
207
|
-
/* @__PURE__ */ jsxs("dl", { className: "grid grid-cols-1 gap-x-6 gap-y-2
|
|
294
|
+
/* @__PURE__ */ jsxs("dl", { className: "text-meta grid grid-cols-1 gap-x-6 gap-y-2 sm:grid-cols-[auto_1fr]", children: [
|
|
208
295
|
rows.map(([label, value]) => /* @__PURE__ */ jsxs("div", { className: "contents", children: [
|
|
209
296
|
/* @__PURE__ */ jsx("dt", { className: "text-muted-foreground", children: label }),
|
|
210
297
|
/* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx("code", { className: "break-all", children: value }) })
|
|
@@ -292,7 +379,7 @@ function TriggersPage() {
|
|
|
292
379
|
if (!integration) notFound();
|
|
293
380
|
const webhooks = definition?.webhooks ?? [];
|
|
294
381
|
const schedules = definition?.schedules ?? [];
|
|
295
|
-
const declaresAnything = webhooks.length > 0 || schedules.length > 0 || Boolean(definition?.oauth);
|
|
382
|
+
const declaresAnything = webhooks.length > 0 || schedules.length > 0 || Boolean(definition?.oauth) || (definition?.agentEvents?.length ?? 0) > 0;
|
|
296
383
|
return /* @__PURE__ */ jsxs(
|
|
297
384
|
"main",
|
|
298
385
|
{
|
|
@@ -316,14 +403,14 @@ function TriggersPage() {
|
|
|
316
403
|
] })
|
|
317
404
|
] })
|
|
318
405
|
] }),
|
|
319
|
-
!definition ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-
|
|
406
|
+
!definition ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-meta", children: [
|
|
320
407
|
"This harness entry does not link its ",
|
|
321
408
|
/* @__PURE__ */ jsx("code", { children: "defineIntegration()" }),
|
|
322
409
|
" ",
|
|
323
410
|
"output. Add ",
|
|
324
411
|
/* @__PURE__ */ jsx("code", { children: "definition: integration" }),
|
|
325
412
|
" to the entry in your harness config to light this surface up."
|
|
326
|
-
] }) : !declaresAnything ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-
|
|
413
|
+
] }) : !declaresAnything ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-meta", children: [
|
|
327
414
|
/* @__PURE__ */ jsx("code", { children: definition.slug }),
|
|
328
415
|
" declares no webhooks, schedules, or OAuth \u2014 which is a perfectly good answer for an integration that only reads. The ",
|
|
329
416
|
/* @__PURE__ */ jsx("code", { children: "@ekanos/sdk" }),
|
|
@@ -352,7 +439,8 @@ function TriggersPage() {
|
|
|
352
439
|
definition,
|
|
353
440
|
mode
|
|
354
441
|
}
|
|
355
|
-
)
|
|
442
|
+
),
|
|
443
|
+
/* @__PURE__ */ jsx(AgentEventsCard, { definition })
|
|
356
444
|
] })
|
|
357
445
|
]
|
|
358
446
|
}
|
|
@@ -6,7 +6,7 @@ import { useHarnessIntegration } from "../registry-context.js";
|
|
|
6
6
|
function WidgetsPage() {
|
|
7
7
|
const integration = useHarnessIntegration();
|
|
8
8
|
if (!integration) notFound();
|
|
9
|
-
return /* @__PURE__ */ jsx("main", { className: "mx-auto w-full max-w-5xl px-6 py-8", "data-test": "widgets", children: integration.widgets.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-
|
|
9
|
+
return /* @__PURE__ */ jsx("main", { className: "mx-auto w-full max-w-5xl px-6 py-8", "data-test": "widgets", children: integration.widgets.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-meta", children: "This integration registers no widgets." }) : /* @__PURE__ */ jsx(
|
|
10
10
|
WidgetSurface,
|
|
11
11
|
{
|
|
12
12
|
widgets: integration.widgets,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_OAUTH_CONNECTION_ID
|
|
3
|
+
} from "@ekanos/sdk/integration";
|
|
1
4
|
import { invokeSchedule, invokeWebhook } from "@ekanos/sdk/testing";
|
|
2
5
|
import {
|
|
3
6
|
DATA_MODES,
|
|
@@ -8,6 +11,7 @@ import {
|
|
|
8
11
|
HARNESS_ACTIONS_MODE_HEADER,
|
|
9
12
|
HARNESS_ACTIONS_VARIANT_HEADER
|
|
10
13
|
} from "../lib/actions-transport.js";
|
|
14
|
+
import { checkRaisedAgentEvents } from "../lib/check-raised-agent-events.js";
|
|
11
15
|
import { runOnActivateHook } from "../lib/run-activation-hook.js";
|
|
12
16
|
import {
|
|
13
17
|
isLocalSetupWriteRequest,
|
|
@@ -194,21 +198,31 @@ function oauthError(ctx, returnPath, code) {
|
|
|
194
198
|
})
|
|
195
199
|
);
|
|
196
200
|
}
|
|
197
|
-
|
|
198
|
-
|
|
201
|
+
const CONNECTION_ID = /^[a-z][a-z0-9-]{1,31}$/;
|
|
202
|
+
function oauthFor(ctx, connectionId) {
|
|
203
|
+
if (connectionId === DEFAULT_OAUTH_CONNECTION_ID) return ctx.definition.oauth;
|
|
204
|
+
const named = ctx.definition.oauthConnections ?? {};
|
|
205
|
+
return Object.hasOwn(named, connectionId) ? named[connectionId] : void 0;
|
|
206
|
+
}
|
|
207
|
+
function requestedConnection(ctx) {
|
|
208
|
+
const connectionId = ctx.url.searchParams.get("connection") ?? DEFAULT_OAUTH_CONNECTION_ID;
|
|
209
|
+
return CONNECTION_ID.test(connectionId) ? connectionId : null;
|
|
210
|
+
}
|
|
211
|
+
function clientCredentials(ctx, oauth) {
|
|
199
212
|
if (!oauth) return null;
|
|
200
213
|
const clientId = ctx.secrets.values[oauth.credentials.clientIdSecretName];
|
|
201
214
|
const clientSecret = ctx.secrets.values[oauth.credentials.clientSecretSecretName];
|
|
202
215
|
return clientId && clientSecret ? { clientId, clientSecret } : null;
|
|
203
216
|
}
|
|
204
217
|
function oauthConnect(ctx) {
|
|
205
|
-
const
|
|
206
|
-
|
|
218
|
+
const connectionId = requestedConnection(ctx);
|
|
219
|
+
const oauth = connectionId ? oauthFor(ctx, connectionId) : void 0;
|
|
220
|
+
if (!connectionId || !oauth) return notDeclared();
|
|
207
221
|
const returnPath = safeReturnPath(
|
|
208
222
|
ctx.url.searchParams.get("returnPath"),
|
|
209
223
|
defaultReturnPath(ctx.slug)
|
|
210
224
|
);
|
|
211
|
-
const credentials = clientCredentials(ctx);
|
|
225
|
+
const credentials = clientCredentials(ctx, oauth);
|
|
212
226
|
if (!credentials) {
|
|
213
227
|
console.error(
|
|
214
228
|
`[harness:${ctx.slug}] oauth/connect: client credentials missing in ${ctx.secrets.file} (${ctx.secrets.missing.join(", ")}).`
|
|
@@ -218,6 +232,7 @@ function oauthConnect(ctx) {
|
|
|
218
232
|
const codeVerifier = oauth.provider.pkce ? generateCodeVerifier() : void 0;
|
|
219
233
|
const nonce = ctx.state.nonces.issue({
|
|
220
234
|
returnPath,
|
|
235
|
+
connectionId,
|
|
221
236
|
...codeVerifier ? { codeVerifier } : {}
|
|
222
237
|
});
|
|
223
238
|
return redirect(
|
|
@@ -231,11 +246,12 @@ function oauthConnect(ctx) {
|
|
|
231
246
|
);
|
|
232
247
|
}
|
|
233
248
|
async function oauthCallback(ctx) {
|
|
234
|
-
const oauth = ctx.definition.oauth;
|
|
235
|
-
if (!oauth) return notDeclared();
|
|
236
249
|
const params = ctx.url.searchParams;
|
|
237
250
|
const stateParam = params.get("state");
|
|
238
251
|
const consumed = stateParam ? ctx.state.nonces.consume(stateParam) : { status: "unknown" };
|
|
252
|
+
const connectionId = consumed.status === "unknown" ? DEFAULT_OAUTH_CONNECTION_ID : consumed.entry.connectionId ?? DEFAULT_OAUTH_CONNECTION_ID;
|
|
253
|
+
const oauth = oauthFor(ctx, connectionId);
|
|
254
|
+
if (!oauth) return notDeclared();
|
|
239
255
|
const returnPath = consumed.status === "unknown" ? defaultReturnPath(ctx.slug) : consumed.entry.returnPath;
|
|
240
256
|
const providerError = params.get("error");
|
|
241
257
|
if (providerError) {
|
|
@@ -254,7 +270,7 @@ async function oauthCallback(ctx) {
|
|
|
254
270
|
return oauthError(ctx, returnPath, "expired");
|
|
255
271
|
const code = params.get("code");
|
|
256
272
|
if (!code) return oauthError(ctx, returnPath, "invalid");
|
|
257
|
-
const credentials = clientCredentials(ctx);
|
|
273
|
+
const credentials = clientCredentials(ctx, oauth);
|
|
258
274
|
if (!credentials) return oauthError(ctx, returnPath, "not_configured");
|
|
259
275
|
const exchange = await exchangeAuthorizationCode({
|
|
260
276
|
ctx: ctx.state.ctx,
|
|
@@ -280,15 +296,18 @@ async function oauthCallback(ctx) {
|
|
|
280
296
|
);
|
|
281
297
|
return oauthError(ctx, returnPath, "save_failed");
|
|
282
298
|
}
|
|
283
|
-
|
|
299
|
+
const fact = {
|
|
284
300
|
obtainedAt: ctx.now().toISOString(),
|
|
285
301
|
expiresAt: exchange.tokens.expiresAt ?? null,
|
|
286
302
|
scope: exchange.tokens.scope ?? null
|
|
287
303
|
};
|
|
304
|
+
if (connectionId === DEFAULT_OAUTH_CONNECTION_ID) ctx.state.connection = fact;
|
|
305
|
+
else ctx.state.connections[connectionId] = fact;
|
|
288
306
|
return redirect(successRedirectUrl({ origin: ctx.origin, returnPath }));
|
|
289
307
|
}
|
|
290
308
|
function oauthStatus(ctx) {
|
|
291
|
-
|
|
309
|
+
const connectionId = requestedConnection(ctx);
|
|
310
|
+
if (!connectionId || !oauthFor(ctx, connectionId)) return notDeclared();
|
|
292
311
|
const accountId = ctx.url.searchParams.get("accountId");
|
|
293
312
|
if (!accountId || !UUID_PATTERN.test(accountId)) {
|
|
294
313
|
return json(
|
|
@@ -296,7 +315,7 @@ function oauthStatus(ctx) {
|
|
|
296
315
|
{ status: 400 }
|
|
297
316
|
);
|
|
298
317
|
}
|
|
299
|
-
const connection = ctx.state.connection;
|
|
318
|
+
const connection = connectionId === DEFAULT_OAUTH_CONNECTION_ID ? ctx.state.connection : ctx.state.connections[connectionId] ?? null;
|
|
300
319
|
return connection ? json({ success: true, data: { obtainedAt: connection.obtainedAt } }) : json({ success: false, error: "Not connected" });
|
|
301
320
|
}
|
|
302
321
|
async function storage(ctx) {
|
|
@@ -348,17 +367,24 @@ async function trigger(ctx) {
|
|
|
348
367
|
const liveCtx = ctx.state.ctx;
|
|
349
368
|
const logsBefore = liveCtx.logs.length;
|
|
350
369
|
const secretNames = await liveCtx.secrets.names();
|
|
351
|
-
const finish = (request, run) => run().then((result) =>
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
370
|
+
const finish = (request, run) => run().then(async (result) => {
|
|
371
|
+
const agentEvents = await checkRaisedAgentEvents(
|
|
372
|
+
ctx.definition,
|
|
373
|
+
result.events
|
|
374
|
+
);
|
|
375
|
+
return {
|
|
376
|
+
kind: request.kind,
|
|
377
|
+
outcome: {
|
|
378
|
+
ok: true,
|
|
379
|
+
summary: result.status,
|
|
380
|
+
...result.detail ? { detail: result.detail } : {},
|
|
381
|
+
logs: liveCtx.logs.slice(logsBefore),
|
|
382
|
+
storage: liveCtx.dumpStorage(),
|
|
383
|
+
...agentEvents ? { agentEvents } : {}
|
|
384
|
+
},
|
|
385
|
+
secretNames
|
|
386
|
+
};
|
|
387
|
+
}).catch((error) => ({
|
|
362
388
|
kind: request.kind,
|
|
363
389
|
outcome: {
|
|
364
390
|
ok: false,
|
|
@@ -48,6 +48,8 @@ export interface LiveState {
|
|
|
48
48
|
slug: string;
|
|
49
49
|
ctx: MockIntegrationContext;
|
|
50
50
|
connection: LiveConnection | null;
|
|
51
|
+
/** Named connections' facts (`oauthConnections`), by id. */
|
|
52
|
+
connections: Record<string, LiveConnection>;
|
|
51
53
|
nonces: NonceStore;
|
|
52
54
|
/** The `local-secrets.json` fingerprint this context was built from. */
|
|
53
55
|
secretsFingerprint: string;
|
|
@@ -41,7 +41,7 @@ export declare const ACTIVATION_BLOCK_KEY = "activationData";
|
|
|
41
41
|
* client credentials and webhook signing keys. Activation-form fields are the
|
|
42
42
|
* account tier and are not declared anywhere; see `ACTIVATION_BLOCK_KEY`.
|
|
43
43
|
*/
|
|
44
|
-
export declare function declaredSecretNames(definition: Pick<IntegrationDefinition, 'oauth' | 'webhooks'>): string[];
|
|
44
|
+
export declare function declaredSecretNames(definition: Pick<IntegrationDefinition, 'oauth' | 'oauthConnections' | 'webhooks'>): string[];
|
|
45
45
|
export type LocalSecretsRead = {
|
|
46
46
|
ok: true;
|
|
47
47
|
/** Absolute path of the file. */
|
|
@@ -9,9 +9,13 @@ const HELP = 'Local dev credentials for `ekanos dev` live mode \u2014 one block
|
|
|
9
9
|
const ACTIVATION_BLOCK_KEY = "activationData";
|
|
10
10
|
function declaredSecretNames(definition) {
|
|
11
11
|
const names = /* @__PURE__ */ new Set();
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
for (const oauth of [
|
|
13
|
+
definition.oauth,
|
|
14
|
+
...Object.values(definition.oauthConnections ?? {})
|
|
15
|
+
]) {
|
|
16
|
+
if (!oauth) continue;
|
|
17
|
+
names.add(oauth.credentials.clientIdSecretName);
|
|
18
|
+
names.add(oauth.credentials.clientSecretSecretName);
|
|
15
19
|
}
|
|
16
20
|
for (const webhook of definition.webhooks ?? []) {
|
|
17
21
|
if (webhook.signature !== "none") {
|
|
@@ -46,6 +46,11 @@ function buildAuthorizeUrl(input) {
|
|
|
46
46
|
url.searchParams.set("code_challenge", input.codeChallenge);
|
|
47
47
|
url.searchParams.set("code_challenge_method", "S256");
|
|
48
48
|
}
|
|
49
|
+
for (const [key, value] of Object.entries(
|
|
50
|
+
input.provider.authorizationParams ?? {}
|
|
51
|
+
)) {
|
|
52
|
+
if (!url.searchParams.has(key)) url.searchParams.set(key, value);
|
|
53
|
+
}
|
|
49
54
|
return url.toString();
|
|
50
55
|
}
|
|
51
56
|
function optionalString(value) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekanos/harness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"private": false,
|
|
4
5
|
"description": "The Ekanos integration dev harness — every surface of an integration rendered in real Ekanos chrome, from fixtures, with no Supabase or auth; and, in live mode, a real localhost OAuth loop over your own dev-app credentials.",
|
|
6
|
+
"homepage": "https://sdk.ekanos.dev/harness/overview",
|
|
5
7
|
"bugs": {
|
|
6
8
|
"email": "npm@govastly.com"
|
|
7
9
|
},
|
|
@@ -63,15 +65,15 @@
|
|
|
63
65
|
"tw-animate-css": "1.4.0"
|
|
64
66
|
},
|
|
65
67
|
"devDependencies": {
|
|
66
|
-
"@ekanos/sdk": "0.
|
|
67
|
-
"@ekanos/ui": "0.
|
|
68
|
+
"@ekanos/sdk": "0.8.0",
|
|
69
|
+
"@ekanos/ui": "0.8.0",
|
|
68
70
|
"@kit/tsconfig": "0.1.0",
|
|
69
71
|
"@tailwindcss/postcss": "4.3.3",
|
|
70
72
|
"@tanstack/react-query": "5.103.2",
|
|
71
73
|
"@types/node": "25.0.1",
|
|
72
74
|
"@types/react": "19.2.18",
|
|
73
75
|
"@types/react-dom": "19.2.5",
|
|
74
|
-
"next": "16.4.
|
|
76
|
+
"next": "16.4.2",
|
|
75
77
|
"next-intl": "^4.14.7",
|
|
76
78
|
"react": "19.2.8",
|
|
77
79
|
"react-dom": "19.2.8",
|
|
@@ -83,8 +85,8 @@
|
|
|
83
85
|
"zod": "4.6.5"
|
|
84
86
|
},
|
|
85
87
|
"peerDependencies": {
|
|
86
|
-
"@ekanos/sdk": "^0.
|
|
87
|
-
"@ekanos/ui": "^0.
|
|
88
|
+
"@ekanos/sdk": "^0.8.0",
|
|
89
|
+
"@ekanos/ui": "^0.8.0",
|
|
88
90
|
"@tanstack/react-query": "^5.101.4",
|
|
89
91
|
"next": "^16.0.0",
|
|
90
92
|
"next-intl": "^4.14.7",
|