@ekanos/harness 0.24.0 → 0.26.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 (61) hide show
  1. package/README.md +3 -4
  2. package/dist/api-types.d.ts +98 -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 +3 -3
  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/schema-form.js +1 -1
  12. package/dist/internal/components/surface-nav.js +20 -20
  13. package/dist/internal/components/widget-boundary.js +1 -7
  14. package/dist/internal/lib/console-client.d.ts +22 -5
  15. package/dist/internal/lib/console-client.js +32 -6
  16. package/dist/internal/lib/console-context.js +14 -2
  17. package/dist/internal/lib/console-types.d.ts +11 -1
  18. package/dist/internal/lib/experience-runtime.d.ts +20 -0
  19. package/dist/internal/lib/experience-runtime.js +16 -1
  20. package/dist/internal/lib/oauth-connect-href.d.ts +9 -0
  21. package/dist/internal/lib/oauth-connect-href.js +14 -0
  22. package/dist/internal/lib/run-log-view.js +1 -0
  23. package/dist/internal/lib/trigger-contract.d.ts +19 -0
  24. package/dist/internal/lib/trigger-runner.js +4 -1
  25. package/dist/internal/routes/experience-page-host.d.ts +5 -1
  26. package/dist/internal/routes/experience-page-host.js +9 -8
  27. package/dist/internal/routes/repo-home-page.js +1 -1
  28. package/dist/internal/routes/repo-layout.js +3 -5
  29. package/dist/internal/routes/root-layout.d.ts +0 -1
  30. package/dist/internal/routes/root-layout.js +2 -4
  31. package/dist/internal/routes/tile-page.js +1 -1
  32. package/dist/internal/routes/triggers-page.js +30 -2
  33. package/dist/internal/server/activation-credentials.d.ts +26 -0
  34. package/dist/internal/server/activation-credentials.js +56 -0
  35. package/dist/internal/server/api-router.js +63 -5
  36. package/dist/internal/server/console-state.d.ts +25 -0
  37. package/dist/internal/server/console-state.js +44 -0
  38. package/dist/internal/server/ekanos-api-router.js +168 -4
  39. package/dist/internal/server/live-context.js +2 -1
  40. package/dist/internal/server/live-invoker.js +10 -2
  41. package/dist/internal/server/local-secrets.d.ts +47 -0
  42. package/dist/internal/server/local-secrets.js +111 -2
  43. package/dist/internal/server/local-state.d.ts +8 -2
  44. package/dist/internal/server/local-state.js +26 -9
  45. package/dist/internal/server/nonce-store.d.ts +2 -0
  46. package/dist/internal/server/oauth-connections.d.ts +45 -0
  47. package/dist/internal/server/oauth-connections.js +69 -0
  48. package/dist/internal/server/oauth-loop.d.ts +1 -1
  49. package/dist/internal/server/oauth-loop.js +4 -1
  50. package/dist/internal/server/oauth-persistence.d.ts +13 -0
  51. package/dist/internal/server/oauth-persistence.js +28 -0
  52. package/dist/internal/server/operation-runner.js +21 -1
  53. package/dist/internal/server/person-context.d.ts +35 -0
  54. package/dist/internal/server/person-context.js +115 -0
  55. package/dist/internal/server/semantics.d.ts +1 -1
  56. package/dist/internal/surfaces.d.ts +1 -1
  57. package/dist/internal/surfaces.js +4 -4
  58. package/dist/registry.d.ts +7 -0
  59. package/dist/registry.js +4 -0
  60. package/dist/styles.css +3 -168
  61. package/package.json +13 -13
@@ -197,7 +197,7 @@ function DevToolbar() {
197
197
  className: "text-primary flex items-center gap-2 text-sm font-medium",
198
198
  "data-test": "toolbar-live-badge",
199
199
  children: [
200
- /* @__PURE__ */ jsx(Icon, { name: "fa-tower-broadcast", className: "h-4 w-4" }),
200
+ /* @__PURE__ */ jsx(Icon, { name: "broadcast", className: "h-4 w-4" }),
201
201
  "Reaching ",
202
202
  resolveEgress(integration).join(", ")
203
203
  ]
@@ -217,7 +217,7 @@ function DevToolbar() {
217
217
  "aria-hidden": "true",
218
218
  className: cn("flex items-center dark:hidden"),
219
219
  children: [
220
- /* @__PURE__ */ jsx(Icon, { name: "fa-moon", className: "mr-2 h-4 w-4" }),
220
+ /* @__PURE__ */ jsx(Icon, { name: "moon", className: "mr-2 h-4 w-4" }),
221
221
  "Dark"
222
222
  ]
223
223
  }
@@ -228,7 +228,7 @@ function DevToolbar() {
228
228
  "aria-hidden": "true",
229
229
  className: cn("hidden items-center dark:flex"),
230
230
  children: [
231
- /* @__PURE__ */ jsx(Icon, { name: "fa-sun", className: "mr-2 h-4 w-4" }),
231
+ /* @__PURE__ */ jsx(Icon, { name: "sun", className: "mr-2 h-4 w-4" }),
232
232
  "Light"
233
233
  ]
234
234
  }
@@ -24,7 +24,7 @@ function DocsLink({
24
24
  ),
25
25
  ...rest,
26
26
  children: [
27
- /* @__PURE__ */ jsx(Icon, { name: "fa-book", className: "h-4 w-4" }),
27
+ /* @__PURE__ */ jsx(Icon, { name: "book", className: "h-4 w-4" }),
28
28
  children
29
29
  ]
30
30
  }
@@ -46,7 +46,7 @@ function ProvenanceBadge({
46
46
  /* @__PURE__ */ jsx(
47
47
  Icon,
48
48
  {
49
- name: override ? "fa-triangle-exclamation" : thisRepo || own ? "fa-code-branch" : "fa-cloud",
49
+ name: override ? "warning" : thisRepo || own ? "git-branch" : "cloud",
50
50
  className: "h-3 w-3"
51
51
  }
52
52
  ),
@@ -60,10 +60,10 @@ function RunModeBadge({ mode }) {
60
60
  return /* @__PURE__ */ jsx(
61
61
  Badge,
62
62
  {
63
+ size: "lg",
63
64
  variant: "secondary",
64
65
  "data-test": "run-mode-badge",
65
66
  "data-mode": mode,
66
- className: "h-6",
67
67
  children: mode === "live" ? "Live" : "Fixtures"
68
68
  }
69
69
  );
@@ -89,7 +89,7 @@ function IntegrationBadge({
89
89
  {
90
90
  href: `/integrations/${integration.integration}`,
91
91
  "data-test": `integration-badge-${integration.integration}`,
92
- className: "hover:bg-accent/50 -mx-1 inline-flex rounded-md px-1 py-0.5 transition-colors",
92
+ className: "hover:bg-accent -mx-1 inline-flex rounded-md px-1 py-0.5 transition-colors",
93
93
  children: label
94
94
  }
95
95
  );
@@ -117,7 +117,10 @@ function LocalOAuthPanel({
117
117
  ] })
118
118
  ] }),
119
119
  /* @__PURE__ */ jsxs("li", { className: "flex flex-col gap-1", children: [
120
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: "3. Open the connect dialog (above) and click Connect" }),
120
+ /* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
121
+ "3. Open the connect dialog (above) and click Connect",
122
+ setup.data.connections && setup.data.connections.length > 1 ? " for each connection" : ""
123
+ ] }),
121
124
  /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-xs", children: [
122
125
  "The browser goes to the provider, comes back to the redirect URI above, the shell exchanges the code through your declared egress and calls ",
123
126
  /* @__PURE__ */ jsx("code", { children: "onTokens" }),
@@ -135,7 +138,30 @@ function LocalOAuthPanel({
135
138
  "The connection lives in the dev server's memory only \u2014 a restart forgets it, and you Connect again."
136
139
  ]
137
140
  }
138
- ) : /* @__PURE__ */ jsx(
141
+ ) : null,
142
+ live && setup.data.connections && setup.data.connections.length > 1 ? /* @__PURE__ */ jsx(
143
+ "ul",
144
+ {
145
+ className: "text-muted-foreground flex flex-col gap-1 text-xs",
146
+ "data-test": "local-oauth-connections",
147
+ children: setup.data.connections.map((connection) => /* @__PURE__ */ jsxs(
148
+ "li",
149
+ {
150
+ "data-test": `local-oauth-connection-${connection.id}`,
151
+ children: [
152
+ connection.label,
153
+ " (",
154
+ /* @__PURE__ */ jsx("code", { children: connection.id }),
155
+ "):",
156
+ " ",
157
+ connection.connected && connection.obtainedAt ? `connected since ${connection.obtainedAt}` : "not connected"
158
+ ]
159
+ },
160
+ connection.id
161
+ ))
162
+ }
163
+ ) : null,
164
+ live ? null : /* @__PURE__ */ jsx(
139
165
  FixturesModeNotice,
140
166
  {
141
167
  integration,
@@ -42,7 +42,7 @@ function BannerBody({
42
42
  "data-test": "provenance-banner",
43
43
  "data-state": "published",
44
44
  children: [
45
- /* @__PURE__ */ jsx(Icon, { name: "fa-cloud", className: "h-3 w-3" }),
45
+ /* @__PURE__ */ jsx(Icon, { name: "cloud", className: "h-3 w-3" }),
46
46
  publishedSummary(integrations)
47
47
  ]
48
48
  }
@@ -56,7 +56,7 @@ function BannerBody({
56
56
  "data-test": "provenance-banner",
57
57
  "data-state": "unpublishable",
58
58
  children: [
59
- /* @__PURE__ */ jsx(Icon, { name: "fa-triangle-exclamation", className: "h-4 w-4" }),
59
+ /* @__PURE__ */ jsx(Icon, { name: "warning", className: "h-4 w-4" }),
60
60
  /* @__PURE__ */ jsxs(AlertTitle, { children: [
61
61
  locals.length,
62
62
  " local override",
@@ -249,7 +249,7 @@ function Field({
249
249
  /* @__PURE__ */ jsxs(
250
250
  "div",
251
251
  {
252
- className: "bg-muted/40 flex flex-col gap-2 rounded-md border p-3",
252
+ className: "bg-muted/50 flex flex-col gap-2 rounded-md border p-3",
253
253
  children: [
254
254
  /* @__PURE__ */ jsx(
255
255
  Field,
@@ -42,7 +42,7 @@ function PreviewNav({
42
42
  className: cn(
43
43
  "flex items-center gap-2 rounded-md px-3 py-2 whitespace-nowrap transition-colors",
44
44
  FOCUS_RING,
45
- active ? "bg-accent text-accent-foreground text-sm font-medium" : "text-muted-foreground hover:bg-accent/50 text-sm"
45
+ active ? "bg-accent text-accent-foreground text-sm font-medium" : "text-muted-foreground hover:bg-accent text-sm"
46
46
  ),
47
47
  children: [
48
48
  /* @__PURE__ */ jsx(Icon, { name: surface.icon, className: "h-5 w-5" }),
@@ -77,7 +77,7 @@ function PreviewNav({
77
77
  className: cn(
78
78
  "rounded-md px-3 py-2 whitespace-nowrap transition-colors",
79
79
  FOCUS_RING,
80
- active ? "bg-accent text-accent-foreground text-sm font-medium" : "text-muted-foreground hover:bg-accent/50 text-sm"
80
+ active ? "bg-accent text-accent-foreground text-sm font-medium" : "text-muted-foreground hover:bg-accent text-sm"
81
81
  ),
82
82
  children: widget.title
83
83
  },
@@ -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
  ] : []
@@ -189,7 +189,7 @@ function TabLink({ tab, pathname }) {
189
189
  className: cn(
190
190
  "flex items-center gap-2 rounded-md px-3 py-2 whitespace-nowrap transition-colors",
191
191
  FOCUS_RING,
192
- tabActive(pathname, tab) ? "bg-accent text-accent-foreground text-sm font-medium" : "text-muted-foreground hover:bg-accent/50 text-sm"
192
+ tabActive(pathname, tab) ? "bg-accent text-accent-foreground text-sm font-medium" : "text-muted-foreground hover:bg-accent text-sm"
193
193
  ),
194
194
  children: [
195
195
  /* @__PURE__ */ jsx(Icon, { name: tab.icon, className: "h-4 w-4" }),
@@ -213,7 +213,7 @@ function IntegrationTab({
213
213
  className: cn(
214
214
  "flex items-center gap-2 rounded-md px-3 py-2 whitespace-nowrap transition-colors",
215
215
  FOCUS_RING,
216
- active ? "bg-accent text-accent-foreground text-sm font-medium" : "text-muted-foreground hover:bg-accent/50 text-sm"
216
+ active ? "bg-accent text-accent-foreground text-sm font-medium" : "text-muted-foreground hover:bg-accent text-sm"
217
217
  ),
218
218
  children: [
219
219
  integration.integration,
@@ -242,13 +242,13 @@ function ConsoleNav({
242
242
  className: "text-muted-foreground hover:text-foreground w-fit text-sm",
243
243
  "data-test": "back-to-repo",
244
244
  children: [
245
- /* @__PURE__ */ jsx(Icon, { name: "fa-arrow-left", className: "mr-2 h-4 w-4" }),
245
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-left", className: "mr-2 h-4 w-4" }),
246
246
  "This repo"
247
247
  ]
248
248
  }
249
249
  ) : null,
250
250
  /* @__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 }),
251
+ /* @__PURE__ */ jsx("h1", { className: "font-heading font-heading-semibold text-2xl tracking-tight", children: project.name }),
252
252
  /* @__PURE__ */ jsx(
253
253
  "code",
254
254
  {
@@ -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,23 @@ 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`). `navigate` is injectable for tests.
30
+ */
31
+ export declare function withExperienceLinks(runtime: ExperienceRuntime, options: {
32
+ links: ExperienceRuntimeLinks;
33
+ pageIds: readonly string[];
34
+ integrationNames: () => readonly string[];
35
+ navigate?: (href: string) => void;
36
+ }): ExperienceRuntime;
@@ -45,6 +45,21 @@ function createExperienceRuntime(apiPrefix, options = {}) {
45
45
  }))
46
46
  };
47
47
  }
48
+ function withExperienceLinks(runtime, options) {
49
+ const navigate = options.navigate ?? ((href) => globalThis.location.assign(href));
50
+ return {
51
+ ...runtime,
52
+ pageHref: (page) => options.pageIds.includes(page) ? `${options.links.experience}/pages/${encodeURIComponent(page)}` : null,
53
+ connect: (integration) => {
54
+ if (!options.integrationNames().includes(integration)) return false;
55
+ navigate(
56
+ options.links.repoHome === null ? `/integrations/${encodeURIComponent(integration)}/connect` : `${options.links.experience}/connect`
57
+ );
58
+ return true;
59
+ }
60
+ };
61
+ }
48
62
  export {
49
- createExperienceRuntime
63
+ createExperienceRuntime,
64
+ withExperienceLinks
50
65
  };
@@ -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);
@@ -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.