@ekanos/harness 0.25.0 → 0.27.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 (68) hide show
  1. package/README.md +3 -4
  2. package/dist/api-types.d.ts +102 -0
  3. package/dist/internal/components/approvals-tray.js +1 -1
  4. package/dist/internal/components/ask-assistant-bridge.js +2 -8
  5. package/dist/internal/components/connect-panel.js +414 -20
  6. package/dist/internal/components/dev-toolbar.js +3 -3
  7. package/dist/internal/components/docs-link.js +1 -1
  8. package/dist/internal/components/integration-badge.js +2 -2
  9. package/dist/internal/components/local-oauth-panel.js +28 -2
  10. package/dist/internal/components/provenance-banner.js +2 -2
  11. package/dist/internal/components/runtime-strip.js +33 -5
  12. package/dist/internal/components/schema-form.js +1 -1
  13. package/dist/internal/components/surface-nav.d.ts +3 -2
  14. package/dist/internal/components/surface-nav.js +41 -52
  15. package/dist/internal/components/widget-boundary.js +1 -7
  16. package/dist/internal/lib/console-client.d.ts +22 -5
  17. package/dist/internal/lib/console-client.js +32 -6
  18. package/dist/internal/lib/console-context.js +14 -2
  19. package/dist/internal/lib/console-types.d.ts +11 -1
  20. package/dist/internal/lib/experience-runtime.d.ts +21 -0
  21. package/dist/internal/lib/experience-runtime.js +18 -1
  22. package/dist/internal/lib/integration-console-href.d.ts +10 -0
  23. package/dist/internal/lib/integration-console-href.js +10 -0
  24. package/dist/internal/lib/oauth-connect-href.d.ts +9 -0
  25. package/dist/internal/lib/oauth-connect-href.js +14 -0
  26. package/dist/internal/lib/run-log-view.js +1 -0
  27. package/dist/internal/lib/trigger-contract.d.ts +19 -0
  28. package/dist/internal/lib/trigger-runner.js +4 -1
  29. package/dist/internal/routes/experience-connect-page.js +5 -5
  30. package/dist/internal/routes/experience-page-host.d.ts +5 -1
  31. package/dist/internal/routes/experience-page-host.js +8 -7
  32. package/dist/internal/routes/experience-summary-page.js +9 -12
  33. package/dist/internal/routes/repo-home-page.js +1 -1
  34. package/dist/internal/routes/repo-layout.js +2 -4
  35. package/dist/internal/routes/root-layout.d.ts +0 -1
  36. package/dist/internal/routes/root-layout.js +2 -4
  37. package/dist/internal/routes/tile-page.js +1 -1
  38. package/dist/internal/routes/triggers-page.js +30 -2
  39. package/dist/internal/server/activation-credentials.d.ts +26 -0
  40. package/dist/internal/server/activation-credentials.js +56 -0
  41. package/dist/internal/server/api-router.js +63 -5
  42. package/dist/internal/server/console-state.d.ts +25 -0
  43. package/dist/internal/server/console-state.js +44 -0
  44. package/dist/internal/server/ekanos-api-router.js +188 -9
  45. package/dist/internal/server/live-context.js +2 -1
  46. package/dist/internal/server/live-invoker.js +10 -2
  47. package/dist/internal/server/local-secrets.d.ts +47 -0
  48. package/dist/internal/server/local-secrets.js +111 -2
  49. package/dist/internal/server/local-state.d.ts +8 -2
  50. package/dist/internal/server/local-state.js +26 -9
  51. package/dist/internal/server/nonce-store.d.ts +2 -0
  52. package/dist/internal/server/oauth-connections.d.ts +45 -0
  53. package/dist/internal/server/oauth-connections.js +69 -0
  54. package/dist/internal/server/oauth-loop.d.ts +1 -1
  55. package/dist/internal/server/oauth-loop.js +4 -1
  56. package/dist/internal/server/oauth-persistence.d.ts +13 -0
  57. package/dist/internal/server/oauth-persistence.js +28 -0
  58. package/dist/internal/server/operation-runner.js +21 -1
  59. package/dist/internal/server/person-context.d.ts +35 -0
  60. package/dist/internal/server/person-context.js +115 -0
  61. package/dist/internal/server/repo-api-router.js +20 -7
  62. package/dist/internal/server/semantics.d.ts +1 -1
  63. package/dist/internal/surfaces.d.ts +1 -1
  64. package/dist/internal/surfaces.js +4 -4
  65. package/dist/registry.d.ts +7 -0
  66. package/dist/registry.js +4 -0
  67. package/dist/styles.css +3 -8
  68. package/package.json +11 -11
@@ -249,7 +249,7 @@ function Field({
249
249
  /* @__PURE__ */ jsxs(
250
250
  "div",
251
251
  {
252
- className: "bg-muted/50 flex flex-col gap-2 rounded-md border p-3",
252
+ className: "bg-secondary flex flex-col gap-2 rounded-md border p-3",
253
253
  children: [
254
254
  /* @__PURE__ */ jsx(
255
255
  Field,
@@ -24,8 +24,9 @@ export declare function experienceTabs(base?: string, repo?: boolean): ConsoleTa
24
24
  export declare const EXPERIENCE_TABS: readonly ConsoleTab[];
25
25
  /**
26
26
  * The mode-aware console nav. An integration repo gets the console as home:
27
- * one integration, six tabs. An experience repo gets the experience tabs plus
28
- * a console tab for every integration, each carrying its provenance badge.
27
+ * one integration, six tabs. An experience gets the experience tabs; the
28
+ * runtime strip under the nav lists its integrations and links each console.
29
+ * Inside one of those consoles, that integration's own tabs follow.
29
30
  */
30
31
  export declare function ConsoleNav({ project, pendingApprovals, }: {
31
32
  project: ConsoleProject;
@@ -6,9 +6,9 @@ import { Icon } from "@ekanos/ui/icon";
6
6
  import { cn } from "@ekanos/ui/utils";
7
7
  import { useConsoleLinks } from "../lib/console-context.js";
8
8
  import { SURFACE_DOCS } from "../lib/docs-links.js";
9
+ import { integrationConsoleHref } from "../lib/integration-console-href.js";
9
10
  import { previewHref, previewSections } from "../lib/preview-sections.js";
10
11
  import { DocsLink } from "./docs-link.js";
11
- import { ProvenanceBadge } from "./integration-badge.js";
12
12
  import { FOCUS_RING, ScrollableNav } from "./scrollable-nav.js";
13
13
  function PreviewNav({
14
14
  integration
@@ -90,35 +90,35 @@ function PreviewNav({
90
90
  function integrationTabs(slug) {
91
91
  const base = `/integrations/${slug}`;
92
92
  return [
93
- { href: base, label: "Overview", icon: "fa-circle-info" },
93
+ { href: base, label: "Overview", icon: "info" },
94
94
  {
95
95
  href: `${base}/connect`,
96
96
  label: "Connect",
97
- icon: "fa-key",
97
+ icon: "key",
98
98
  prefix: true
99
99
  },
100
100
  {
101
101
  href: `${base}/operations`,
102
102
  label: "Operations",
103
- icon: "fa-list",
103
+ icon: "list",
104
104
  prefix: true
105
105
  },
106
106
  {
107
107
  href: `${base}/events`,
108
108
  label: "Events",
109
- icon: "fa-bolt",
109
+ icon: "lightning",
110
110
  prefix: true
111
111
  },
112
112
  {
113
113
  href: `${base}/health`,
114
114
  label: "Health",
115
- icon: "fa-heart-pulse",
115
+ icon: "heartbeat",
116
116
  prefix: true
117
117
  },
118
118
  {
119
119
  href: `${base}/runs`,
120
120
  label: "Run log",
121
- icon: "fa-clock-rotate-left",
121
+ icon: "clock-counter-clockwise",
122
122
  prefix: true
123
123
  }
124
124
  ];
@@ -127,49 +127,49 @@ function previewTab(slug) {
127
127
  return {
128
128
  href: previewHref(slug),
129
129
  label: "Preview",
130
- icon: "fa-table-cells-large",
130
+ icon: "grid-four",
131
131
  prefix: true,
132
132
  testId: "preview-tab"
133
133
  };
134
134
  }
135
135
  function experienceTabs(base = "/experience", repo = false) {
136
136
  return [
137
- { href: base, label: "Summary", icon: "fa-table-list" },
137
+ { href: base, label: "Summary", icon: "columns" },
138
138
  {
139
139
  href: `${base}/widgets`,
140
140
  label: "Widgets",
141
- icon: "fa-table-cells-large",
141
+ icon: "grid-four",
142
142
  prefix: true
143
143
  },
144
144
  {
145
145
  href: `${base}/layout`,
146
146
  label: "Layout",
147
- icon: "fa-table-columns",
147
+ icon: "columns",
148
148
  prefix: true
149
149
  },
150
150
  {
151
151
  href: `${base}/workflows`,
152
152
  label: "Workflows",
153
- icon: "fa-diagram-project",
153
+ icon: "flow-arrow",
154
154
  prefix: true
155
155
  },
156
156
  {
157
157
  href: `${base}/review-queue`,
158
158
  label: "Review queue",
159
- icon: "fa-inbox",
159
+ icon: "tray",
160
160
  prefix: true
161
161
  },
162
162
  {
163
163
  href: `${base}/runs`,
164
164
  label: "Run log",
165
- icon: "fa-clock-rotate-left",
165
+ icon: "clock-counter-clockwise",
166
166
  prefix: true
167
167
  },
168
168
  ...repo ? [
169
169
  {
170
170
  href: `${base}/connect`,
171
171
  label: "Connect",
172
- icon: "fa-plug",
172
+ icon: "plug",
173
173
  prefix: true
174
174
  }
175
175
  ] : []
@@ -198,30 +198,6 @@ function TabLink({ tab, pathname }) {
198
198
  }
199
199
  );
200
200
  }
201
- function IntegrationTab({
202
- integration,
203
- pathname
204
- }) {
205
- const href = `/integrations/${integration.integration}`;
206
- const active = pathname === href || pathname.startsWith(`${href}/`);
207
- return /* @__PURE__ */ jsxs(
208
- Link,
209
- {
210
- href,
211
- "aria-current": active ? "page" : void 0,
212
- "data-test": `integration-tab-${integration.integration}`,
213
- className: cn(
214
- "flex items-center gap-2 rounded-md px-3 py-2 whitespace-nowrap transition-colors",
215
- FOCUS_RING,
216
- active ? "bg-accent text-accent-foreground text-sm font-medium" : "text-muted-foreground hover:bg-accent text-sm"
217
- ),
218
- children: [
219
- integration.integration,
220
- /* @__PURE__ */ jsx(ProvenanceBadge, { provenance: integration.provenance })
221
- ]
222
- }
223
- );
224
- }
225
201
  function ConsoleNav({
226
202
  project,
227
203
  pendingApprovals = 0
@@ -229,6 +205,10 @@ function ConsoleNav({
229
205
  const pathname = usePathname();
230
206
  const links = useConsoleLinks();
231
207
  const own = project.integrations[0];
208
+ const current = project.integrations.flatMap((integration) => {
209
+ const href = integrationConsoleHref(integration);
210
+ return href ? [{ integration, href }] : [];
211
+ }).find(({ href }) => pathname === href || pathname.startsWith(`${href}/`));
232
212
  return /* @__PURE__ */ jsxs(
233
213
  "div",
234
214
  {
@@ -242,13 +222,13 @@ function ConsoleNav({
242
222
  className: "text-muted-foreground hover:text-foreground w-fit text-sm",
243
223
  "data-test": "back-to-repo",
244
224
  children: [
245
- /* @__PURE__ */ jsx(Icon, { name: "fa-arrow-left", className: "mr-2 h-4 w-4" }),
225
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-left", className: "mr-2 h-4 w-4" }),
246
226
  "This repo"
247
227
  ]
248
228
  }
249
229
  ) : null,
250
230
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-baseline gap-3", children: [
251
- /* @__PURE__ */ jsx("h1", { className: "font-heading text-2xl font-semibold tracking-tight", children: project.name }),
231
+ /* @__PURE__ */ jsx("h1", { className: "font-heading font-heading-semibold text-2xl tracking-tight", children: project.name }),
252
232
  /* @__PURE__ */ jsx(
253
233
  "code",
254
234
  {
@@ -277,17 +257,26 @@ function ConsoleNav({
277
257
  /* @__PURE__ */ jsx(ScrollableNav, { label: "Experience", children: experienceTabs(links.experience, links.repoHome !== null).map(
278
258
  (tab) => /* @__PURE__ */ jsx(TabLink, { tab, pathname }, tab.href)
279
259
  ) }),
280
- /* @__PURE__ */ jsxs(ScrollableNav, { label: "Integration consoles", className: "items-center", children: [
281
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground px-1 text-xs whitespace-nowrap", children: "Integrations:" }),
282
- project.integrations.map((integration) => /* @__PURE__ */ jsx(
283
- IntegrationTab,
284
- {
285
- integration,
286
- pathname
287
- },
288
- integration.integration
289
- ))
290
- ] })
260
+ current ? /* @__PURE__ */ jsxs(
261
+ ScrollableNav,
262
+ {
263
+ label: `${current.integration.integration} console`,
264
+ className: "items-center",
265
+ children: [
266
+ /* @__PURE__ */ jsx(
267
+ "code",
268
+ {
269
+ className: "px-1 text-sm font-medium whitespace-nowrap",
270
+ "data-test": "current-integration",
271
+ children: current.integration.integration
272
+ }
273
+ ),
274
+ integrationTabs(current.href.slice("/integrations/".length)).map(
275
+ (tab) => /* @__PURE__ */ jsx(TabLink, { tab, pathname }, tab.href)
276
+ )
277
+ ]
278
+ }
279
+ ) : null
291
280
  ] })
292
281
  ]
293
282
  }
@@ -24,13 +24,7 @@ class WidgetBoundary extends Component {
24
24
  if (!error) return this.props.children;
25
25
  return /* @__PURE__ */ jsxs(Card, { layout: "bleed", className: "flex flex-col gap-3 p-6", children: [
26
26
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
27
- /* @__PURE__ */ jsx(
28
- Icon,
29
- {
30
- name: "fa-triangle-exclamation",
31
- className: "text-destructive h-5 w-5"
32
- }
33
- ),
27
+ /* @__PURE__ */ jsx(Icon, { name: "warning", className: "text-destructive h-5 w-5" }),
34
28
  /* @__PURE__ */ jsxs("p", { className: "text-sm font-medium", children: [
35
29
  this.props.widgetId,
36
30
  " threw during render"
@@ -1,5 +1,5 @@
1
1
  import type { IntegrationRuntime, RepoDisconnectResponse, RepoResponse } from '../../api-types.js';
2
- import type { ApprovalDecision, ConnectionState, ConsoleContract, ConsoleProject, EmitEventRequest, EmitEventResponse, ExperienceInfo, HealthResult, PendingApproval, RunRecord, RunRequest, RunResponse, WorkflowRunState } from './console-types.js';
2
+ import type { ApprovalDecision, ConnectionState, ConsoleContract, ConsoleProject, EmitEventRequest, HarnessConnectAs, HarnessRunAs, EmitEventResponse, ExperienceInfo, HealthResult, PendingApproval, RunRecord, RunRequest, RunResponse, WorkflowRunState } from './console-types.js';
3
3
  export declare const CONSOLE_API_BASE = "/__ekanos/api";
4
4
  /**
5
5
  * The console's whole view of the harness server. Components depend on this
@@ -18,15 +18,32 @@ export interface ConsoleClient {
18
18
  saveSecrets(integration: string, values: Record<string, string>): Promise<void>;
19
19
  /**
20
20
  * Store what the integration's activation form submitted, as this
21
- * integration's local credentials. Replaces what was stored before.
21
+ * integration's local credentials. Replaces what was stored before, unless
22
+ * `merge` keeps it and sets only the non-empty fields given.
22
23
  */
23
- saveActivation(integration: string, activationData: Record<string, unknown>): Promise<void>;
24
+ saveActivation(integration: string, activationData: Record<string, unknown>, options?: {
25
+ merge?: boolean;
26
+ as?: HarnessConnectAs;
27
+ }): Promise<void>;
24
28
  /**
25
29
  * Remove this integration's stored local credentials, from its own package
26
30
  * store only. `clearKeys` also blanks the declared keys (an API-key
27
- * integration); an OAuth integration keeps its app keys.
31
+ * integration); an OAuth integration keeps its app keys. `connection`
32
+ * forgets only that OAuth connection's tokens (`default` or an
33
+ * `oauthConnections` id) and keeps everything else.
28
34
  */
29
- disconnect(integration: string, clearKeys: boolean): Promise<void>;
35
+ disconnect(integration: string, clearKeys: boolean, connection?: string, as?: HarnessConnectAs): Promise<void>;
36
+ /**
37
+ * The Run-as and Connect-as switches (plan 261 R6): who calls act as, and
38
+ * which tier one credential (`oauth:<id>` / `activation:<id>`) connects into.
39
+ */
40
+ setSwitches(integration: string, switches: {
41
+ runAs?: HarnessRunAs;
42
+ connectAs?: {
43
+ credential: string;
44
+ as: HarnessConnectAs;
45
+ };
46
+ }): Promise<void>;
30
47
  /** `fixtures` forces this integration to fixtures; `auto` follows its connection. */
31
48
  setRuntimeMode(integration: string, mode: 'auto' | 'fixtures'): Promise<IntegrationRuntime>;
32
49
  emitEvent(request: EmitEventRequest): Promise<EmitEventResponse>;
@@ -178,26 +178,37 @@ function createHttpConsoleClient(fetcher = (input, init) => globalThis.fetch(inp
178
178
  const wire = await get(
179
179
  `/credentials/${enc(integration)}`
180
180
  );
181
+ const declaredKeys = new Map(
182
+ (wire.oauthConnections ?? []).flatMap(
183
+ (connection) => connection.keys.map((key) => [key.name, key])
184
+ )
185
+ );
181
186
  return {
182
187
  managed: !wire.manageable,
183
188
  root: wire.root,
184
189
  fields: wire.declared.map((key) => ({
185
190
  key,
186
- label: key,
187
- secret: true,
191
+ label: declaredKeys.get(key)?.label ?? key,
192
+ secret: declaredKeys.get(key)?.secret ?? true,
188
193
  set: wire.set.includes(key)
189
194
  })),
195
+ ...wire.oauthConnections ? { oauthConnections: wire.oauthConnections } : {},
196
+ ...wire.activationCredentials ? { activationCredentials: wire.activationCredentials } : {},
197
+ ...wire.runAs ? { runAs: wire.runAs } : {},
190
198
  target: wire.target,
191
199
  hasStored: wire.set.length > 0 || wire.activationFieldsSet.length > 0,
192
200
  ...wire.displayRoot ? { displayRoot: wire.displayRoot } : {},
193
201
  facts: wire.facts
194
202
  };
195
203
  },
196
- disconnect: async (integration, clearKeys) => {
204
+ disconnect: async (integration, clearKeys, connection, as) => {
197
205
  await request(
198
206
  fetcher,
199
207
  `/credentials/${enc(integration)}/disconnect`,
200
- { method: "POST", body: { clearKeys } },
208
+ {
209
+ method: "POST",
210
+ body: connection === void 0 ? { clearKeys } : { connection, ...as ? { as } : {} }
211
+ },
201
212
  base
202
213
  );
203
214
  },
@@ -212,11 +223,26 @@ function createHttpConsoleClient(fetcher = (input, init) => globalThis.fetch(inp
212
223
  base
213
224
  );
214
225
  },
215
- saveActivation: async (integration, activationData) => {
226
+ saveActivation: async (integration, activationData, options) => {
216
227
  await request(
217
228
  fetcher,
218
229
  `/credentials/${enc(integration)}/activation`,
219
- { method: "PUT", body: { activationData } },
230
+ {
231
+ method: "PUT",
232
+ body: {
233
+ activationData,
234
+ ...options?.merge ? { merge: true } : {},
235
+ ...options?.as ? { as: options.as } : {}
236
+ }
237
+ },
238
+ base
239
+ );
240
+ },
241
+ setSwitches: async (integration, switches) => {
242
+ await request(
243
+ fetcher,
244
+ `/credentials/${enc(integration)}/switches`,
245
+ { method: "PUT", body: switches },
220
246
  base
221
247
  );
222
248
  },
@@ -3,13 +3,17 @@ import { jsx } from "react/jsx-runtime";
3
3
  import {
4
4
  createContext,
5
5
  use,
6
+ useMemo,
6
7
  useState
7
8
  } from "react";
8
9
  import { ExperienceRuntimeProvider } from "@ekanos/sdk/experience/client";
9
10
  import { WidgetEventProvider } from "@ekanos/sdk/hooks";
10
11
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
11
12
  import { createHttpConsoleClient } from "./console-client.js";
12
- import { createExperienceRuntime } from "./experience-runtime.js";
13
+ import {
14
+ createExperienceRuntime,
15
+ withExperienceLinks
16
+ } from "./experience-runtime.js";
13
17
  const EMPTY_SURFACES = { widgets: [], pages: [] };
14
18
  const DEFAULT_LINKS = {
15
19
  experience: "/experience",
@@ -38,7 +42,15 @@ function ConsoleProviders({
38
42
  defaultOptions: { queries: { retry: false, staleTime: 2e3 } }
39
43
  })
40
44
  }));
41
- return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient ?? defaults.queryClient, children: /* @__PURE__ */ jsx(ClientContext, { value: client ?? defaults.client, children: /* @__PURE__ */ jsx(LinksContext, { value: links, children: /* @__PURE__ */ jsx(PollContext, { value: pollMs, children: /* @__PURE__ */ jsx(SurfacesContext, { value: experience, children: /* @__PURE__ */ jsx(ExperienceRuntimeProvider, { runtime: defaults.runtime, children: /* @__PURE__ */ jsx(WidgetEventProvider, { children }) }) }) }) }) }) });
45
+ const runtime = useMemo(
46
+ () => withExperienceLinks(defaults.runtime, {
47
+ links,
48
+ pageIds: experience.pages.map((page) => page.id),
49
+ integrationNames: () => defaults.runtime.integrations().map((item) => item.name)
50
+ }),
51
+ [defaults.runtime, links, experience.pages]
52
+ );
53
+ return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient ?? defaults.queryClient, children: /* @__PURE__ */ jsx(ClientContext, { value: client ?? defaults.client, children: /* @__PURE__ */ jsx(LinksContext, { value: links, children: /* @__PURE__ */ jsx(PollContext, { value: pollMs, children: /* @__PURE__ */ jsx(SurfacesContext, { value: experience, children: /* @__PURE__ */ jsx(ExperienceRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx(WidgetEventProvider, { children }) }) }) }) }) }) });
42
54
  }
43
55
  function useConsoleClient() {
44
56
  const client = use(ClientContext);
@@ -6,7 +6,8 @@
6
6
  * so the UI builds and is tested against fakes; once `src/api.ts` publishes
7
7
  * the real types, this file is the one place to re-point.
8
8
  */
9
- import type { IntegrationConnectionFacts, IntegrationRuntime } from '../../api-types.js';
9
+ import type { ActivationCredentialStatus, HarnessConnectAs, HarnessRunAs, IntegrationConnectionFacts, IntegrationRuntime, OAuthConnectionStatus } from '../../api-types.js';
10
+ export type { ActivationCredentialStatus, HarnessConnectAs, HarnessRunAs, OAuthConnectionStatus, };
10
11
  export type JsonSchema = {
11
12
  [key: string]: unknown;
12
13
  };
@@ -206,6 +207,15 @@ export interface ConnectionState {
206
207
  target: ConnectionTargetField[];
207
208
  /** Any local credential is stored for this integration (declared keys or activation fields). */
208
209
  hasStored: boolean;
210
+ /**
211
+ * Every declared OAuth connection (main first), each with its own Connect,
212
+ * status and Disconnect. Absent for an integration with no OAuth.
213
+ */
214
+ oauthConnections?: OAuthConnectionStatus[];
215
+ /** The secret activation fields, by the credential (and level) each belongs to. */
216
+ activationCredentials?: ActivationCredentialStatus[];
217
+ /** Who calls the harness runs act as. */
218
+ runAs?: HarnessRunAs;
209
219
  /** Where the store lives, relative to the repo when inside one. */
210
220
  displayRoot?: string;
211
221
  /** The one source of truth for status and live/fixtures. */
@@ -14,3 +14,24 @@ import type { ExperienceRuntime } from '@ekanos/sdk/experience/runtime';
14
14
  export declare function createExperienceRuntime(apiPrefix?: string, options?: {
15
15
  confirm?: (message: string) => boolean | Promise<boolean>;
16
16
  }): ExperienceRuntime;
17
+ /** Where the harness console's own routes live; `ConsoleLinks` carries both. */
18
+ export interface ExperienceRuntimeLinks {
19
+ /** `/experience`, or `/experiences/<name>` in a repo shell. */
20
+ experience: string;
21
+ /** Set in a repo shell, where the experience has its own Connect tab. */
22
+ repoHome: string | null;
23
+ }
24
+ /**
25
+ * The same runtime plus the two answers only the console's routes know: a page
26
+ * of this experience by `id` (`<experience>/pages/<id>`, the route
27
+ * `ExperiencePageHost` serves) and where to connect an integration (a repo
28
+ * shell's `<experience>/connect` tab; a single project's
29
+ * `/integrations/<name>/connect`, or the experience view for a namespaced
30
+ * one). `navigate` is injectable for tests.
31
+ */
32
+ export declare function withExperienceLinks(runtime: ExperienceRuntime, options: {
33
+ links: ExperienceRuntimeLinks;
34
+ pageIds: readonly string[];
35
+ integrationNames: () => readonly string[];
36
+ navigate?: (href: string) => void;
37
+ }): ExperienceRuntime;
@@ -45,6 +45,23 @@ function createExperienceRuntime(apiPrefix, options = {}) {
45
45
  }))
46
46
  };
47
47
  }
48
+ function connectHref(integration, links) {
49
+ if (links.repoHome !== null) return `${links.experience}/connect`;
50
+ return integration.includes("/") ? links.experience : `/integrations/${encodeURIComponent(integration)}/connect`;
51
+ }
52
+ function withExperienceLinks(runtime, options) {
53
+ const navigate = options.navigate ?? ((href) => globalThis.location.assign(href));
54
+ return {
55
+ ...runtime,
56
+ pageHref: (page) => options.pageIds.includes(page) ? `${options.links.experience}/pages/${encodeURIComponent(page)}` : null,
57
+ connect: (integration) => {
58
+ if (!options.integrationNames().includes(integration)) return false;
59
+ navigate(connectHref(integration, options.links));
60
+ return true;
61
+ }
62
+ };
63
+ }
48
64
  export {
49
- createExperienceRuntime
65
+ createExperienceRuntime,
66
+ withExperienceLinks
50
67
  };
@@ -0,0 +1,10 @@
1
+ import type { ConsoleIntegration } from './console-types.js';
2
+ /**
3
+ * Where an integration's console lives, or null when this harness serves none.
4
+ *
5
+ * The console route is one `[slug]` segment, so a namespaced id
6
+ * (`vastly-internal/news`) never routes as written. A package of this same repo
7
+ * is served under its bare slug; a bare id is served as itself; anything else
8
+ * (a registry or published integration) has no console here.
9
+ */
10
+ export declare function integrationConsoleHref(integration: Pick<ConsoleIntegration, 'integration' | 'provenance'>): string | null;
@@ -0,0 +1,10 @@
1
+ function integrationConsoleHref(integration) {
2
+ const id = integration.integration;
3
+ const slash = id.lastIndexOf("/");
4
+ if (slash === -1) return `/integrations/${id}`;
5
+ const { provenance } = integration;
6
+ return provenance.kind === "local" && provenance.scope === "repo" ? `/integrations/${id.slice(slash + 1)}` : null;
7
+ }
8
+ export {
9
+ integrationConsoleHref
10
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The harness connect URL for one declared OAuth connection, in the shape the
3
+ * host's route takes: the main connection carries no `connection` param, a
4
+ * named one carries its id (`?connection=agent`).
5
+ *
6
+ * Directive-free and dependency-free: the Connect surfaces import it in the
7
+ * browser.
8
+ */
9
+ export declare function oauthConnectHref(slug: string, connectionId: string, returnPath?: string, as?: 'me' | 'team'): string;
@@ -0,0 +1,14 @@
1
+ const MAIN_CONNECTION_ID = "default";
2
+ function oauthConnectHref(slug, connectionId, returnPath, as) {
3
+ const query = new URLSearchParams();
4
+ if (connectionId !== MAIN_CONNECTION_ID) {
5
+ query.set("connection", connectionId);
6
+ }
7
+ if (returnPath) query.set("returnPath", returnPath);
8
+ if (as) query.set("as", as);
9
+ const search = query.toString();
10
+ return `/api/integrations/${encodeURIComponent(slug)}/oauth/connect${search ? `?${search}` : ""}`;
11
+ }
12
+ export {
13
+ oauthConnectHref
14
+ };
@@ -24,6 +24,7 @@ const REASON_EXPLANATIONS = {
24
24
  confirmation_required: "This operation requires `confirmed: true` in its input: a person must confirm it with a second click.",
25
25
  mode_not_permitted: "The integration doesn't allow that run mode (live or fixtures) for this call.",
26
26
  binding_missing: "The integration is not connected.",
27
+ not_connected: "The integration is declared and bound, but this team (or person) has not connected it yet.",
27
28
  invalid_input: "The input didn't match the operation's schema.",
28
29
  input_too_large: "The input was larger than the executor allows.",
29
30
  deadline_exceeded: "The operation took longer than the executor allows.",
@@ -10,6 +10,8 @@
10
10
  *
11
11
  * Directive-free: imported by client pages and by the server route.
12
12
  */
13
+ import type { AgentRunCancelCheck } from '@ekanos/integration-schema';
14
+ export type { AgentRunCancelCheck };
13
15
  export interface HandlerLog {
14
16
  level: string;
15
17
  message: string;
@@ -62,6 +64,12 @@ export interface InvocationOutcome {
62
64
  storage: StorageDump;
63
65
  /** Agent events a webhook delivery raised, checked like the host does. */
64
66
  agentEvents?: RaisedAgentEventCheck[];
67
+ /**
68
+ * Conversations a webhook delivery stopped (`WebhookResult.cancel`),
69
+ * checked like the host does. The harness starts no runs, so it stops
70
+ * none: this shows what the host would cancel.
71
+ */
72
+ cancels?: AgentRunCancelCheck[];
65
73
  }
66
74
  /** The outcome of one `onActivate` run — see `run-activation-hook.ts`. */
67
75
  export type OnActivateOutcome = {
@@ -115,6 +123,17 @@ export interface LocalSetupResponse {
115
123
  expiresAt: string | null;
116
124
  scope: string | null;
117
125
  } | null;
126
+ /**
127
+ * Every declared OAuth connection beside the main one — the main `oauth`
128
+ * (`default`) first, then each `oauthConnections` id — and whether this
129
+ * server holds it. `connected` / `connection` above are the main one's.
130
+ */
131
+ connections?: {
132
+ id: string;
133
+ label: string;
134
+ connected: boolean;
135
+ obtainedAt: string | null;
136
+ }[];
118
137
  /** Always true today: the connection lives in server memory only. */
119
138
  volatile: true;
120
139
  }
@@ -1,3 +1,4 @@
1
+ import { checkAgentRunCancels } from "@ekanos/integration-schema";
1
2
  import {
2
3
  invokeSchedule,
3
4
  invokeWebhook
@@ -16,13 +17,15 @@ function createLocalTriggerRunner(definition, ctx) {
16
17
  definition,
17
18
  result.events
18
19
  );
20
+ const cancels = checkAgentRunCancels(result.cancel);
19
21
  return {
20
22
  ok: true,
21
23
  summary: result.status,
22
24
  ...result.detail ? { detail: result.detail } : {},
23
25
  logs: ctx.logs.slice(logsBefore),
24
26
  storage: ctx.dumpStorage(),
25
- ...agentEvents ? { agentEvents } : {}
27
+ ...agentEvents ? { agentEvents } : {},
28
+ ...cancels ? { cancels } : {}
26
29
  };
27
30
  } catch (error) {
28
31
  console.error("[harness] handler invocation failed:", error);
@@ -73,14 +73,14 @@ function Checklist({
73
73
  index + 1,
74
74
  "."
75
75
  ] }),
76
- /* @__PURE__ */ jsx(
76
+ used.consoleHref ? /* @__PURE__ */ jsx(
77
77
  Link,
78
78
  {
79
- href: `/integrations/${used.name}`,
79
+ href: used.consoleHref,
80
80
  className: "text-sm font-medium hover:underline",
81
81
  children: used.name
82
82
  }
83
- ),
83
+ ) : /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: used.name }),
84
84
  /* @__PURE__ */ jsx(ConnectionStatusChip, { connection: used.connection }),
85
85
  used.connection && used.connection.facts.kind !== "none" && used.connection.facts.state !== "connected" ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: CONNECTION_TYPE[used.connection.type] }) : null,
86
86
  !used.sameRepo ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: "from the registry" }) : null
@@ -92,10 +92,10 @@ function Checklist({
92
92
  ] }),
93
93
  used.levelProblem ? /* @__PURE__ */ jsx("p", { className: "text-warning-foreground bg-warning rounded-md px-3 py-2 text-xs", children: used.levelProblem }) : null,
94
94
  used.connection?.detail ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: used.connection.detail }) : null,
95
- used.sameRepo ? /* @__PURE__ */ jsx(
95
+ used.packageName ? /* @__PURE__ */ jsx(
96
96
  ConnectControls,
97
97
  {
98
- name: used.name,
98
+ name: used.packageName,
99
99
  connection: used.connection,
100
100
  returnPath: `/experiences/${experience.name}/connect`,
101
101
  onChanged: refresh
@@ -1,5 +1,9 @@
1
1
  /**
2
- * A page host: the experience page in a sidebar-less frame. A canvas shows its
2
+ * A page host: the experience page in a sidebar-less frame. Like the real
3
+ * host, a custom page is mounted bare inside `PageBody`, with no
4
+ * border or padding of the harness's own; the page title, which the real host
5
+ * shows in the page rail, is the one line of chrome standing in for the rail
6
+ * here. A canvas shows its
3
7
  * own widgets in the dashboard grid; a custom page mounts its component with
4
8
  * the route below its path (`path` prop); an overview without a component gets
5
9
  * the host's default, every widget of the experience.