@ekanos/harness 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/dist/api-types.d.ts +490 -0
  2. package/dist/api-types.js +6 -0
  3. package/dist/api.d.ts +33 -0
  4. package/dist/api.js +36 -1
  5. package/dist/app.js +6 -1
  6. package/dist/internal/components/approvals-tray.d.ts +17 -0
  7. package/dist/internal/components/approvals-tray.js +116 -0
  8. package/dist/internal/components/ask-assistant-bridge.js +1 -1
  9. package/dist/internal/components/connect-controls.d.ts +12 -0
  10. package/dist/internal/components/connect-controls.js +69 -0
  11. package/dist/internal/components/connect-dialog.d.ts +19 -0
  12. package/dist/internal/components/connect-dialog.js +61 -0
  13. package/dist/internal/components/connect-panel.d.ts +25 -0
  14. package/dist/internal/components/connect-panel.js +292 -0
  15. package/dist/internal/components/connection-chip.d.ts +14 -0
  16. package/dist/internal/components/connection-chip.js +75 -0
  17. package/dist/internal/components/dashboard-grid.js +38 -24
  18. package/dist/internal/components/dev-toolbar.js +176 -103
  19. package/dist/internal/components/events-panel.d.ts +10 -0
  20. package/dist/internal/components/events-panel.js +111 -0
  21. package/dist/internal/components/health-panel.d.ts +4 -0
  22. package/dist/internal/components/health-panel.js +56 -0
  23. package/dist/internal/components/integration-badge.d.ts +29 -0
  24. package/dist/internal/components/integration-badge.js +105 -0
  25. package/dist/internal/components/local-oauth-panel.js +21 -1
  26. package/dist/internal/components/operation-runner-panel.d.ts +12 -0
  27. package/dist/internal/components/operation-runner-panel.js +331 -0
  28. package/dist/internal/components/provenance-banner.d.ts +12 -0
  29. package/dist/internal/components/provenance-banner.js +107 -0
  30. package/dist/internal/components/repo-connection.d.ts +10 -0
  31. package/dist/internal/components/repo-connection.js +32 -0
  32. package/dist/internal/components/run-log.d.ts +9 -0
  33. package/dist/internal/components/run-log.js +228 -0
  34. package/dist/internal/components/runtime-strip.d.ts +12 -0
  35. package/dist/internal/components/runtime-strip.js +158 -0
  36. package/dist/internal/components/schema-form.d.ts +13 -0
  37. package/dist/internal/components/schema-form.js +382 -0
  38. package/dist/internal/components/scrollable-nav.d.ts +12 -0
  39. package/dist/internal/components/scrollable-nav.js +68 -0
  40. package/dist/internal/components/surface-nav.d.ts +31 -1
  41. package/dist/internal/components/surface-nav.js +244 -31
  42. package/dist/internal/components/workflow-runner.d.ts +14 -0
  43. package/dist/internal/components/workflow-runner.js +104 -0
  44. package/dist/internal/lib/bundled-secrets.d.ts +9 -0
  45. package/dist/internal/lib/bundled-secrets.js +24 -0
  46. package/dist/internal/lib/chrome-slot.d.ts +2 -0
  47. package/dist/internal/lib/chrome-slot.js +25 -0
  48. package/dist/internal/lib/connection-facts.d.ts +44 -0
  49. package/dist/internal/lib/connection-facts.js +116 -0
  50. package/dist/internal/lib/console-client.d.ts +55 -0
  51. package/dist/internal/lib/console-client.js +295 -0
  52. package/dist/internal/lib/console-context.d.ts +56 -0
  53. package/dist/internal/lib/console-context.js +67 -0
  54. package/dist/internal/lib/console-hooks.d.ts +33 -0
  55. package/dist/internal/lib/console-hooks.js +118 -0
  56. package/dist/internal/lib/console-types.d.ts +279 -0
  57. package/dist/internal/lib/console-types.js +0 -0
  58. package/dist/internal/lib/experience-runtime.d.ts +8 -0
  59. package/dist/internal/lib/experience-runtime.js +22 -0
  60. package/dist/internal/lib/preview-sections.d.ts +13 -0
  61. package/dist/internal/lib/preview-sections.js +32 -0
  62. package/dist/internal/lib/repo-context.d.ts +20 -0
  63. package/dist/internal/lib/repo-context.js +64 -0
  64. package/dist/internal/lib/run-log-view.d.ts +24 -0
  65. package/dist/internal/lib/run-log-view.js +57 -0
  66. package/dist/internal/lib/schema-form-model.d.ts +34 -0
  67. package/dist/internal/lib/schema-form-model.js +272 -0
  68. package/dist/internal/lib/toolbar-context.d.ts +9 -1
  69. package/dist/internal/lib/toolbar-context.js +13 -3
  70. package/dist/internal/lib/toolbar-visibility.d.ts +16 -0
  71. package/dist/internal/lib/toolbar-visibility.js +31 -0
  72. package/dist/internal/registry-context.d.ts +2 -0
  73. package/dist/internal/registry-context.js +11 -9
  74. package/dist/internal/routes/activation-page.js +44 -20
  75. package/dist/internal/routes/console-home-page.d.ts +5 -0
  76. package/dist/internal/routes/console-home-page.js +18 -0
  77. package/dist/internal/routes/experience-connect-page.d.ts +6 -0
  78. package/dist/internal/routes/experience-connect-page.js +127 -0
  79. package/dist/internal/routes/experience-layout-page.d.ts +8 -0
  80. package/dist/internal/routes/experience-layout-page.js +126 -0
  81. package/dist/internal/routes/experience-page-host.d.ts +7 -0
  82. package/dist/internal/routes/experience-page-host.js +79 -0
  83. package/dist/internal/routes/experience-review-queue-page.d.ts +2 -0
  84. package/dist/internal/routes/experience-review-queue-page.js +60 -0
  85. package/dist/internal/routes/experience-runs-page.d.ts +1 -0
  86. package/dist/internal/routes/experience-runs-page.js +13 -0
  87. package/dist/internal/routes/experience-summary-page.d.ts +1 -0
  88. package/dist/internal/routes/experience-summary-page.js +101 -0
  89. package/dist/internal/routes/experience-widget-page.d.ts +1 -0
  90. package/dist/internal/routes/experience-widget-page.js +26 -0
  91. package/dist/internal/routes/experience-widgets-page.d.ts +6 -0
  92. package/dist/internal/routes/experience-widgets-page.js +22 -0
  93. package/dist/internal/routes/experience-workflow-page.d.ts +1 -0
  94. package/dist/internal/routes/experience-workflow-page.js +24 -0
  95. package/dist/internal/routes/experience-workflows-page.d.ts +1 -0
  96. package/dist/internal/routes/experience-workflows-page.js +44 -0
  97. package/dist/internal/routes/index-page.d.ts +10 -9
  98. package/dist/internal/routes/index-page.js +3 -68
  99. package/dist/internal/routes/integration-layout.d.ts +12 -1
  100. package/dist/internal/routes/integration-layout.js +20 -6
  101. package/dist/internal/routes/integrations-connect-page.d.ts +1 -0
  102. package/dist/internal/routes/integrations-connect-page.js +19 -0
  103. package/dist/internal/routes/integrations-events-page.d.ts +1 -0
  104. package/dist/internal/routes/integrations-events-page.js +10 -0
  105. package/dist/internal/routes/integrations-health-page.d.ts +1 -0
  106. package/dist/internal/routes/integrations-health-page.js +10 -0
  107. package/dist/internal/routes/integrations-layout.d.ts +17 -0
  108. package/dist/internal/routes/integrations-layout.js +106 -0
  109. package/dist/internal/routes/integrations-list-page.d.ts +2 -0
  110. package/dist/internal/routes/integrations-list-page.js +94 -0
  111. package/dist/internal/routes/integrations-operation-page.d.ts +1 -0
  112. package/dist/internal/routes/integrations-operation-page.js +29 -0
  113. package/dist/internal/routes/integrations-operations-page.d.ts +1 -0
  114. package/dist/internal/routes/integrations-operations-page.js +61 -0
  115. package/dist/internal/routes/integrations-overview-page.d.ts +1 -0
  116. package/dist/internal/routes/integrations-overview-page.js +90 -0
  117. package/dist/internal/routes/integrations-runs-page.d.ts +1 -0
  118. package/dist/internal/routes/integrations-runs-page.js +14 -0
  119. package/dist/internal/routes/integrations-scope.d.ts +12 -0
  120. package/dist/internal/routes/integrations-scope.js +39 -0
  121. package/dist/internal/routes/legacy-preview-redirect.d.ts +6 -0
  122. package/dist/internal/routes/legacy-preview-redirect.js +12 -0
  123. package/dist/internal/routes/preview-index-page.d.ts +2 -0
  124. package/dist/internal/routes/preview-index-page.js +14 -0
  125. package/dist/internal/routes/repo-connections-page.d.ts +6 -0
  126. package/dist/internal/routes/repo-connections-page.js +8 -0
  127. package/dist/internal/routes/repo-home-page.d.ts +2 -0
  128. package/dist/internal/routes/repo-home-page.js +320 -0
  129. package/dist/internal/routes/repo-layout.d.ts +7 -0
  130. package/dist/internal/routes/repo-layout.js +76 -0
  131. package/dist/internal/routes/repo-package-layouts.d.ts +20 -0
  132. package/dist/internal/routes/repo-package-layouts.js +104 -0
  133. package/dist/internal/routes/root-layout.d.ts +3 -1
  134. package/dist/internal/routes/root-layout.js +13 -3
  135. package/dist/internal/routes/single-widget-page.js +5 -12
  136. package/dist/internal/routes/tile-page.js +20 -41
  137. package/dist/internal/routes/triggers-page.js +55 -62
  138. package/dist/internal/routes/widgets-page.js +1 -1
  139. package/dist/internal/server/api-router.js +46 -4
  140. package/dist/internal/server/approvals.d.ts +44 -0
  141. package/dist/internal/server/approvals.js +76 -0
  142. package/dist/internal/server/contract-sources.d.ts +28 -0
  143. package/dist/internal/server/contract-sources.js +83 -0
  144. package/dist/internal/server/definition-loader.d.ts +22 -0
  145. package/dist/internal/server/definition-loader.js +125 -0
  146. package/dist/internal/server/ekanos-api-router.d.ts +34 -0
  147. package/dist/internal/server/ekanos-api-router.js +835 -0
  148. package/dist/internal/server/experience-loader.d.ts +57 -0
  149. package/dist/internal/server/experience-loader.js +146 -0
  150. package/dist/internal/server/integration-lookup.d.ts +29 -0
  151. package/dist/internal/server/integration-lookup.js +33 -0
  152. package/dist/internal/server/integration-resolver.d.ts +121 -0
  153. package/dist/internal/server/integration-resolver.js +605 -0
  154. package/dist/internal/server/live-invoker.d.ts +11 -0
  155. package/dist/internal/server/live-invoker.js +106 -0
  156. package/dist/internal/server/local-secrets.d.ts +82 -1
  157. package/dist/internal/server/local-secrets.js +112 -1
  158. package/dist/internal/server/local-state.d.ts +12 -0
  159. package/dist/internal/server/local-state.js +45 -0
  160. package/dist/internal/server/oauth-persistence.d.ts +19 -0
  161. package/dist/internal/server/oauth-persistence.js +76 -0
  162. package/dist/internal/server/operation-runner.d.ts +95 -0
  163. package/dist/internal/server/operation-runner.js +231 -0
  164. package/dist/internal/server/project-manifest.d.ts +71 -0
  165. package/dist/internal/server/project-manifest.js +215 -0
  166. package/dist/internal/server/registry-cache.d.ts +68 -0
  167. package/dist/internal/server/registry-cache.js +328 -0
  168. package/dist/internal/server/repo-api-router.d.ts +33 -0
  169. package/dist/internal/server/repo-api-router.js +391 -0
  170. package/dist/internal/server/run-log.d.ts +22 -0
  171. package/dist/internal/server/run-log.js +32 -0
  172. package/dist/internal/server/semantics.d.ts +28 -0
  173. package/dist/internal/server/semantics.js +67 -0
  174. package/dist/internal/server/session-catalog.d.ts +67 -0
  175. package/dist/internal/server/session-catalog.js +18 -0
  176. package/dist/internal/server/workflow-runner.d.ts +36 -0
  177. package/dist/internal/server/workflow-runner.js +183 -0
  178. package/dist/registry.d.ts +7 -0
  179. package/dist/resolver.d.ts +145 -0
  180. package/dist/resolver.js +211 -0
  181. package/dist/routes.d.ts +66 -2
  182. package/dist/routes.js +61 -3
  183. package/dist/runtime.d.ts +46 -0
  184. package/dist/runtime.js +60 -0
  185. package/package.json +23 -9
  186. package/dist/internal/routes/integration-index-page.d.ts +0 -13
  187. package/dist/internal/routes/integration-index-page.js +0 -17
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Loads an experience's `default` export (`defineExperience(...)`, lane B) and
3
+ * reduces it to the STATIC facts the harness needs: which widgets/pages use
4
+ * which integrations, the reads-only review queue, and the workflow templates as the
5
+ * host's flow DSL. No React component is kept — the harness UI renders the
6
+ * components itself from the same module.
7
+ *
8
+ * `normalizeExperience` is pure and tolerant: it reads the declared shape and
9
+ * ignores keys it does not know, so the lane B definition type can grow
10
+ * without breaking the harness.
11
+ */
12
+ export interface DslStep {
13
+ id: string;
14
+ type: string;
15
+ [key: string]: unknown;
16
+ }
17
+ export interface WorkflowDsl {
18
+ id: string;
19
+ name: string;
20
+ steps: DslStep[];
21
+ edges: Array<{
22
+ from: string;
23
+ to: string;
24
+ }>;
25
+ /** The template's trigger as declared (`{ type: 'fusion_event', event }`, a schedule, …). */
26
+ trigger?: unknown;
27
+ }
28
+ export interface LoadedExperience {
29
+ slug: string;
30
+ widgets: Array<{
31
+ id: string;
32
+ title: string;
33
+ integrations: string[];
34
+ }>;
35
+ pages: Array<{
36
+ id: string;
37
+ path: string;
38
+ title: string;
39
+ integrations: string[];
40
+ }>;
41
+ workflows: WorkflowDsl[];
42
+ reviewQueue: Array<{
43
+ id: string;
44
+ integration: string;
45
+ read: string;
46
+ }>;
47
+ }
48
+ export declare function normalizeExperience(raw: unknown): LoadedExperience | null;
49
+ export declare function loadExperience(projectRoot: string): Promise<LoadedExperience | null>;
50
+ /** Operation id -> where the experience uses it (static analysis, not of code). */
51
+ export declare function usedByIndex(experience: LoadedExperience, declaredIntegrations: ReadonlyMap<string, {
52
+ integration: string;
53
+ version: string;
54
+ }>): Record<string, Array<{
55
+ kind: 'widget' | 'page' | 'workflow' | 'review-queue';
56
+ id: string;
57
+ }>>;
@@ -0,0 +1,146 @@
1
+ import { importEntryFromSource } from "./definition-loader.js";
2
+ import { readProjectManifest } from "./project-manifest.js";
3
+ function isRecord(value) {
4
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5
+ }
6
+ function strings(value) {
7
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
8
+ }
9
+ function toDslStep(step) {
10
+ if (step.type === "tool") {
11
+ return {
12
+ id: String(step.id),
13
+ type: "fusion_tool",
14
+ tool: step.op,
15
+ slot: step.integration,
16
+ args: step.args ?? {}
17
+ };
18
+ }
19
+ if (step.type === "ai") {
20
+ return {
21
+ id: String(step.id),
22
+ type: "ai_step",
23
+ kind: step.kind,
24
+ instructions: step.instructions,
25
+ outputSchemaRef: step.outputSchemaRef
26
+ };
27
+ }
28
+ if (step.type === "approval") {
29
+ return {
30
+ id: String(step.id),
31
+ type: "approval_gate",
32
+ summaryTemplate: step.summary,
33
+ approverScope: step.approverScope
34
+ };
35
+ }
36
+ return step;
37
+ }
38
+ function normalizeWorkflow(raw, index) {
39
+ if (!isRecord(raw)) return null;
40
+ const id = typeof raw.id === "string" ? raw.id : typeof raw.name === "string" ? raw.name.toLowerCase().replace(/[^a-z0-9]+/g, "-") : `workflow-${index}`;
41
+ const name = typeof raw.name === "string" ? raw.name : id;
42
+ let rawSteps = raw.steps;
43
+ if (!Array.isArray(rawSteps) && typeof raw.build === "function") {
44
+ try {
45
+ rawSteps = raw.build();
46
+ } catch {
47
+ rawSteps = [];
48
+ }
49
+ }
50
+ if (!Array.isArray(rawSteps)) return null;
51
+ const steps = [];
52
+ const afterEdges = [];
53
+ for (const step of rawSteps) {
54
+ if (isRecord(step) && typeof step.id === "string" && typeof step.type === "string") {
55
+ steps.push(toDslStep(step));
56
+ for (const from of strings(step.after)) {
57
+ afterEdges.push({ from, to: step.id });
58
+ }
59
+ }
60
+ }
61
+ const edges = afterEdges.length > 0 && !Array.isArray(raw.edges) ? afterEdges : Array.isArray(raw.edges) ? raw.edges.filter(
62
+ (edge) => isRecord(edge) && typeof edge.from === "string" && typeof edge.to === "string"
63
+ ) : steps.slice(1).map((step, i) => ({ from: steps[i].id, to: step.id }));
64
+ return {
65
+ id,
66
+ name,
67
+ steps,
68
+ edges,
69
+ ...raw.trigger !== void 0 ? { trigger: raw.trigger } : {}
70
+ };
71
+ }
72
+ function normalizeExperience(raw) {
73
+ if (!isRecord(raw) || typeof raw.slug !== "string") return null;
74
+ const widgets = Array.isArray(raw.widgets) ? raw.widgets.flatMap(
75
+ (widget) => isRecord(widget) && typeof widget.id === "string" ? [
76
+ {
77
+ id: widget.id,
78
+ title: typeof widget.title === "string" ? widget.title : widget.id,
79
+ integrations: strings(widget.integrations)
80
+ }
81
+ ] : []
82
+ ) : [];
83
+ const pages = Array.isArray(raw.pages) ? raw.pages.flatMap(
84
+ (page) => isRecord(page) && typeof page.id === "string" ? [
85
+ {
86
+ id: page.id,
87
+ path: typeof page.path === "string" ? page.path : page.id,
88
+ title: typeof page.title === "string" ? page.title : page.id,
89
+ integrations: strings(page.integrations)
90
+ }
91
+ ] : []
92
+ ) : [];
93
+ const workflows = Array.isArray(raw.workflows) ? raw.workflows.flatMap((workflow, index) => {
94
+ const normalized = normalizeWorkflow(workflow, index);
95
+ return normalized ? [normalized] : [];
96
+ }) : [];
97
+ const reviewQueue = isRecord(raw.reviewQueue) && Array.isArray(raw.reviewQueue.sections) ? raw.reviewQueue.sections.flatMap(
98
+ (section) => isRecord(section) && typeof section.id === "string" && typeof section.integration === "string" && typeof section.read === "string" ? [
99
+ {
100
+ id: section.id,
101
+ integration: section.integration,
102
+ read: section.read
103
+ }
104
+ ] : []
105
+ ) : [];
106
+ return { slug: raw.slug, widgets, pages, workflows, reviewQueue };
107
+ }
108
+ async function loadExperience(projectRoot) {
109
+ const manifest = readProjectManifest(projectRoot);
110
+ if (manifest.kind !== "experience" || !manifest.entry) return null;
111
+ const mod = await importEntryFromSource(projectRoot, manifest.entry);
112
+ const loaded = normalizeExperience(mod.default);
113
+ if (!loaded) {
114
+ throw new Error(
115
+ `${manifest.entry} has no default export that looks like defineExperience(...) (an object with a string "slug").`
116
+ );
117
+ }
118
+ return loaded;
119
+ }
120
+ function usedByIndex(experience, declaredIntegrations) {
121
+ const index = {};
122
+ const add = (id, use) => {
123
+ (index[id] ??= []).push(use);
124
+ };
125
+ for (const section of experience.reviewQueue) {
126
+ add(section.read, { kind: "review-queue", id: section.id });
127
+ }
128
+ for (const workflow of experience.workflows) {
129
+ for (const step of workflow.steps) {
130
+ if (step.type !== "fusion_tool") continue;
131
+ const integration = typeof step.slot === "string" ? declaredIntegrations.get(step.slot) : void 0;
132
+ if (integration && typeof step.tool === "string") {
133
+ add(`${integration.integration}@${integration.version}/${step.tool}`, {
134
+ kind: "workflow",
135
+ id: workflow.id
136
+ });
137
+ }
138
+ }
139
+ }
140
+ return index;
141
+ }
142
+ export {
143
+ loadExperience,
144
+ normalizeExperience,
145
+ usedByIndex
146
+ };
@@ -0,0 +1,29 @@
1
+ import type { HarnessIntegration } from '../../registry.js';
2
+ import type { ResolvedIntegration } from './integration-resolver.js';
3
+ /**
4
+ * A process-wide hand-off from the `/__ekanos/api` router (which resolves
5
+ * integrations) to the legacy `/api/integrations/<slug>/…` router (which serves the
6
+ * OAuth loop, `local-setup` and storage for REGISTERED integrations).
7
+ *
8
+ * An integration-resolved integration — a local override, or a published package in
9
+ * the private cache — is not in the project's registered integrations, yet its Connect button
10
+ * and key form must work. The legacy router asks here when a slug is not in
11
+ * its registry, and gets a registry-shaped entry plus the project root its
12
+ * `.ekanos/local-secrets.json` lives under (the INTEGRATION's, not the
13
+ * experience's, for a local integration). Kept on `globalThis` under a `Symbol.for`
14
+ * key so the two route modules, bundled separately, share one lookup.
15
+ */
16
+ export interface IntegrationIntegration {
17
+ integration: HarnessIntegration;
18
+ definition: NonNullable<HarnessIntegration['definition']>;
19
+ projectRoot: string;
20
+ }
21
+ type Lookup = (slug: string) => Promise<ResolvedIntegration | null>;
22
+ /**
23
+ * Every router that resolves integrations publishes here. A repo root runs one
24
+ * router per package, each knowing its own integrations, so a lookup asks all
25
+ * of them rather than only the last to register.
26
+ */
27
+ export declare function publishIntegrationLookup(lookup: Lookup): void;
28
+ export declare function lookupIntegrationIntegration(slug: string): Promise<IntegrationIntegration | null>;
29
+ export {};
@@ -0,0 +1,33 @@
1
+ const KEY = /* @__PURE__ */ Symbol.for("ekanos.harness.integration-lookup");
2
+ function publishIntegrationLookup(lookup) {
3
+ const carrier = globalThis;
4
+ carrier[KEY] ??= /* @__PURE__ */ new Set();
5
+ carrier[KEY].add(lookup);
6
+ }
7
+ async function lookupIntegrationIntegration(slug) {
8
+ const lookups = globalThis[KEY];
9
+ if (!lookups) return null;
10
+ let integration = null;
11
+ for (const lookup of [...lookups].reverse()) {
12
+ integration = await lookup(slug);
13
+ if (integration) break;
14
+ }
15
+ if (!integration?.loadDefinition || !integration.runModes.includes("live"))
16
+ return null;
17
+ const definition = await integration.loadDefinition();
18
+ return {
19
+ integration: {
20
+ slug: definition.slug,
21
+ name: definition.name,
22
+ description: definition.description,
23
+ widgets: [],
24
+ definition
25
+ },
26
+ definition,
27
+ projectRoot: integration.credentialRoot
28
+ };
29
+ }
30
+ export {
31
+ lookupIntegrationIntegration,
32
+ publishIntegrationLookup
33
+ };
@@ -0,0 +1,121 @@
1
+ import { type Contract, type SourceCatalog, compatLine } from '@ekanos/integration-schema';
2
+ import { type RepoDiscovery, type RepoPackage } from '@ekanos/integration-schema/repo';
3
+ import type { IntegrationDefinition } from '@ekanos/sdk/integration';
4
+ import type { ActiveOverride, BindingMode, HarnessKind, RunMode, IntegrationProvenance } from '../../api-types.js';
5
+ import { type DefinitionLoader } from './definition-loader.js';
6
+ import { type ProjectManifest, type IntegrationEntry } from './project-manifest.js';
7
+ import { type EnsureResult } from './registry-cache.js';
8
+ /**
9
+ * ─────────────────────────────────────────────────────────────────────────────
10
+ * THE INTEGRATION RESOLVER
11
+ * ─────────────────────────────────────────────────────────────────────────────
12
+ *
13
+ * For each integration an experience depends on, per the design (§3.1) and the
14
+ * orchestrator decisions (O1, O3):
15
+ *
16
+ * 1. a local override (`ekanos.local.json` / `EKANOS_INTEGRATION_OVERRIDE_<INTEGRATION>`)
17
+ * -> provenance `local`; fixtures AND live;
18
+ * 2. otherwise the REGISTRY chain: the integration must be available
19
+ * to the dev's Source (CLI session catalog, when there is one); if the
20
+ * dev's Source owns it, the published package is installed into the
21
+ * harness-private cache and its shipped `contract.json` is the contract
22
+ * and the integration may run live; else the contracts directory; else the
23
+ * committed snapshot (marked STALE);
24
+ * 3. pin checks: the exact compat line and every declared operation must be
25
+ * in the resolved contract, or the integration is an ERROR and serves nothing.
26
+ *
27
+ * Nothing here throws for a per-integration problem — problems come back as
28
+ * `errors` so the harness can start, print them, and refuse only that integration.
29
+ */
30
+ export interface ResolvedIntegration {
31
+ integration: string;
32
+ version: string;
33
+ required: IntegrationEntry['required'];
34
+ /** Canonical operation ids from the experience's `integrations` entry (the allowlist). */
35
+ operations: string[];
36
+ modes: BindingMode[];
37
+ bindingMode: BindingMode;
38
+ provenance: IntegrationProvenance;
39
+ contract: Contract;
40
+ runModes: RunMode[];
41
+ defaultMode: RunMode;
42
+ canDevelop: boolean | 'unverified';
43
+ /** This project's own integration, not an override of an integration. */
44
+ self?: boolean;
45
+ /** Resolved to an integration package of the same repo (not an override). */
46
+ sameRepo?: boolean;
47
+ /**
48
+ * Where `.ekanos/local-secrets.json` for this integration lives: the
49
+ * override project itself for a local integration (so keys entered once serve both
50
+ * repos), else the experience project.
51
+ */
52
+ credentialRoot: string;
53
+ /** Loads the integration code for a live call. Absent when fixtures-only. */
54
+ loadDefinition?: () => Promise<IntegrationDefinition>;
55
+ }
56
+ export interface IntegrationResolution {
57
+ kind: HarnessKind;
58
+ integrations: ResolvedIntegration[];
59
+ overrides: ActiveOverride[];
60
+ notices: string[];
61
+ errors: Array<{
62
+ integration: string;
63
+ message: string;
64
+ }>;
65
+ }
66
+ export interface RegistryInstaller {
67
+ ensure: (args: {
68
+ projectRoot: string;
69
+ integration: string;
70
+ version: string;
71
+ }) => Promise<EnsureResult>;
72
+ }
73
+ export interface ResolveIntegrationsOptions {
74
+ projectRoot: string;
75
+ env?: Readonly<Record<string, string | undefined>>;
76
+ /** `--contracts-dir` / `EKANOS_CONTRACTS_DIR`: the offline registry stand-in. */
77
+ contractsDir?: string;
78
+ /** The CLI session's catalog. Absent/null = offline. */
79
+ catalog?: SourceCatalog | null;
80
+ /** Test seams. */
81
+ manifest?: ProjectManifest;
82
+ loadSourceDefinition?: DefinitionLoader;
83
+ loadPackageDefinition?: DefinitionLoader;
84
+ /**
85
+ * Derive a contract from a loaded definition (`deriveContract` from
86
+ * `@ekanos/sdk/contract`, lane A). When absent or it returns null, the
87
+ * override project's committed `contract.json` is used.
88
+ */
89
+ deriveContract?: (args: {
90
+ definition: IntegrationDefinition;
91
+ projectDir: string;
92
+ packageVersion: string;
93
+ }) => Contract | null;
94
+ /** `false` disables the published-package cache (fixtures-only registry integrations). */
95
+ registry?: RegistryInstaller | false;
96
+ /** Resolve as if no override existed (contract sources for `add`/`sync`). */
97
+ ignoreOverrides?: boolean;
98
+ /**
99
+ * The repo the project belongs to. Omitted: found by walking up from
100
+ * `projectRoot` for a `kind: "repo"` ekanos.json. `null`: resolve as a
101
+ * standalone project even inside a repo.
102
+ */
103
+ repo?: RepoDiscovery | null;
104
+ }
105
+ /**
106
+ * The repo around a project, or null. An unreadable repo manifest is reported
107
+ * by the caller through `notices`, never thrown: a broken root file must not
108
+ * stop a package from resolving.
109
+ */
110
+ export declare function repoOf(projectRoot: string, notices?: string[]): RepoDiscovery | null;
111
+ /**
112
+ * An integration package of the same repo as `projectRoot` with this name, other
113
+ * than the project itself. Same-repo is not an override: it needs no
114
+ * `ekanos.local.json` and never blocks publishing.
115
+ */
116
+ export declare function sameRepoPackage(repo: RepoDiscovery | null, projectRoot: string, name: string): RepoPackage | null;
117
+ export declare function resolveIntegrations(options: ResolveIntegrationsOptions): Promise<IntegrationResolution>;
118
+ /** The startup table, one row per integration. Printed by the CLI, served at /integrations. */
119
+ export declare function formatProvenanceLines(resolution: IntegrationResolution): string[];
120
+ /** Re-exported for callers that only need a compat line from a version. */
121
+ export { compatLine };