@collective-intelligence/extensions-sdk-frontend-react 0.0.0-stage → 0.1.1

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 (55) hide show
  1. package/README.md +163 -2
  2. package/dist/dashboard.d.ts +1 -0
  3. package/dist/dashboard.js +0 -0
  4. package/dist/frontend/diagnostics.d.ts +30 -0
  5. package/dist/frontend/index.d.ts +27 -0
  6. package/dist/frontend/index.js +1 -0
  7. package/dist/index.d.ts +4 -0
  8. package/dist/index.js +1 -0
  9. package/dist/load-state.d.ts +42 -0
  10. package/dist/runtime/sort-values.d.ts +1 -0
  11. package/dist/runtime/type-guards.d.ts +10 -0
  12. package/dist/studio-declarations.d.ts +71 -0
  13. package/dist/studio.d.ts +4 -0
  14. package/dist/studio.js +1 -0
  15. package/dist/ui-react.d.ts +1 -0
  16. package/dist/ui-react.js +0 -0
  17. package/dist/workflow.d.ts +1 -0
  18. package/dist/workflow.js +1 -0
  19. package/dist/workflows/catalog.d.ts +39 -0
  20. package/dist/workflows/contracts.d.ts +358 -0
  21. package/dist/workflows/default-template-ui/actions/catalog-node-chart-block.d.ts +7 -0
  22. package/dist/workflows/default-template-ui/actions/catalog-node-details-editor.d.ts +4 -0
  23. package/dist/workflows/default-template-ui/actions/catalog-text.d.ts +4 -0
  24. package/dist/workflows/default-template-ui/actions/translations.d.ts +3 -0
  25. package/dist/workflows/default-template-ui/declarations.d.ts +33 -0
  26. package/dist/workflows/default-template-ui/renderers.d.ts +9 -0
  27. package/dist/workflows/default-template-ui/triggers/translations.d.ts +4 -0
  28. package/dist/workflows/default-template-ui/triggers/trigger-details-editor.d.ts +4 -0
  29. package/dist/workflows/default-template-ui/triggers/trigger-expression-environment.d.ts +4 -0
  30. package/dist/workflows/expression-editor/expression-editor.d.ts +15 -0
  31. package/dist/workflows/expression-editor/index.d.ts +3 -0
  32. package/dist/workflows/expression-editor/source-browser.d.ts +29 -0
  33. package/dist/workflows/expression-editor/syntax-help-drawer.d.ts +5 -0
  34. package/dist/workflows/expression-editor/translations.d.ts +8 -0
  35. package/dist/workflows/expressions/domain.d.ts +59 -0
  36. package/dist/workflows/expressions/typing.d.ts +28 -0
  37. package/dist/workflows/field-configuration-resolver.d.ts +5 -0
  38. package/dist/workflows/field-editor/expression-slots.d.ts +35 -0
  39. package/dist/workflows/field-editor/index.d.ts +2 -0
  40. package/dist/workflows/field-editor/translations.d.ts +7 -0
  41. package/dist/workflows/field-editor/workflow-field-frame.d.ts +53 -0
  42. package/dist/workflows/field-resolver.d.ts +5 -0
  43. package/dist/workflows/field-type-select/catalog.d.ts +22 -0
  44. package/dist/workflows/field-type-select/field-type-select.d.ts +18 -0
  45. package/dist/workflows/index.d.ts +26 -0
  46. package/dist/workflows/node-presentation/node-presentation.d.ts +9 -0
  47. package/dist/workflows/options.d.ts +28 -0
  48. package/dist/workflows/runtime/field-bindings.d.ts +21 -0
  49. package/dist/workflows/runtime/field-visibility.d.ts +7 -0
  50. package/dist/workflows/runtime/load-workflow-module.d.ts +4 -0
  51. package/dist/workflows/runtime/workflow-template-details.d.ts +4 -0
  52. package/dist/workflows/workflow-runtime/remote-options-select-field.d.ts +4 -0
  53. package/dist/workflows/workflow-runtime/translations.d.ts +5 -0
  54. package/dist/workflows/workflow-types.d.ts +156 -0
  55. package/package.json +101 -4
package/README.md CHANGED
@@ -1,3 +1,164 @@
1
- # Temporary Holding Version
1
+ # `@collective-intelligence/extensions-sdk-frontend-react`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Public, host-neutral contracts for React contributions rendered by Collective
4
+ Intelligence Studio or Dashboard.
5
+
6
+ React and React DOM are host-provided peers. The optional
7
+ `@collective-intelligence/ui-react` peer is required when importing the
8
+ `/workflow` or `/ui-react` subpaths; declaration-only consumers do not need it.
9
+
10
+ ```tsx
11
+ import { declareFrontendCatalogContribution } from "@collective-intelligence/extensions-sdk-frontend"
12
+ import { declareStudioComponent } from "@collective-intelligence/extensions-sdk-frontend-react/studio"
13
+ import { customerPageProps } from "./schemas"
14
+
15
+ const sourceRef = "com.acme.crm.studio.customer-view"
16
+
17
+ export const studioCatalog = declareFrontendCatalogContribution({
18
+ fqn: sourceRef,
19
+ host: "studio",
20
+ load: () => import("./studio-catalog")
21
+ })
22
+
23
+ export const customerPage = declareStudioComponent({
24
+ definition: {
25
+ category: "page",
26
+ propsSchema: customerPageProps,
27
+ sourceRef
28
+ },
29
+ manifest: {
30
+ fqn: "com.acme.crm.studio.customer-page",
31
+ version: "1.0.0"
32
+ },
33
+ presentation: { displayName: "Customer" }
34
+ })
35
+ ```
36
+
37
+ Declarations are data: they do not register with Studio or Dashboard and do
38
+ not own module delivery, host resolution, or error-boundary rendering. Catalog
39
+ Hosted Contributions come from the React-free frontend SDK and can be passed to
40
+ `declarePackage({ hostedContributions: [...] })`; their lazy `load` functions
41
+ never enter the serialized package manifest. This React package intentionally
42
+ does not expose the retired leaf `declareStudioView` or
43
+ `declareDashboardWorkflowField` helpers.
44
+
45
+ `sourceRef` is required on every Studio component render leaf and remains in
46
+ the serialized package manifest. It identifies the same package's hosted
47
+ Studio contribution; it is not a source path or an alternate runtime URL.
48
+
49
+ ## Frontend runtime
50
+
51
+ The `frontend` entrypoint provides the shared React execution boundary for
52
+ declarations from `@collective-intelligence/extensions-sdk-frontend`:
53
+
54
+ ```tsx
55
+ import {
56
+ createHostedDiagnostic,
57
+ HostedExtensionRender,
58
+ loadDeclarationModule
59
+ } from "@collective-intelligence/extensions-sdk-frontend-react/frontend"
60
+
61
+ ;<HostedExtensionRender
62
+ declaration={declaration}
63
+ componentProps={{ customerId: "customer-1" }}
64
+ load={() => loadDeclarationModule(declaration)}
65
+ />
66
+ ```
67
+
68
+ The frontend entrypoint owns module loading, React component validation, and
69
+ error-boundary diagnostics. It also exports `createHostedDiagnostic` and the
70
+ `HostedDiagnostic`, `HostedDiagnosticPhase`, and `SourceMapLocation` types for
71
+ hosts that report failures outside the provided render boundary. Host
72
+ applications still own catalog activation, routing, and product-specific
73
+ fallback UI.
74
+
75
+ Wrap the Host tree in `HostedExtensionFailureProvider` to replace the plain
76
+ failure message with the Host's own design-system UI. Its `render` callback
77
+ receives the `HostedDiagnostic`. Load failures are also logged with
78
+ `console.error` together with their original cause; React logs render failures.
79
+
80
+ `HostedExtensionRender` keeps the mounted component when props or callback
81
+ identities change, preserving local edits and focus. Loading restarts when the
82
+ declaration object or `implementationRole` changes; hosts should keep declarations
83
+ stable until the contribution changes. Pending load failures use the latest
84
+ `onDiagnostic` callback.
85
+
86
+ ## Workflow UI
87
+
88
+ The `workflow` entrypoint provides host-neutral workflow field and node
89
+ renderers, catalog activation, and query helpers:
90
+
91
+ ```tsx
92
+ import {
93
+ WorkflowFieldResolver,
94
+ activateWorkflowCatalog,
95
+ workflowFieldOptions
96
+ } from "@collective-intelligence/extensions-sdk-frontend-react/workflow"
97
+ ```
98
+
99
+ Field bindings use `inputBinding` for node `inputs` and `parameter` for node
100
+ `config`. The exported read and patch helpers preserve sibling values and store
101
+ field display labels under the same canonical binding key in metadata. Stored
102
+ `{mode: "fixed"}` envelopes and compiled literals are unwrapped at every path
103
+ segment when a field renderer or a `visibleWhen` rule reads a binding;
104
+ expression values pass through unchanged. Visibility `equals` compares JSON
105
+ structurally, and `in` matches a scalar value or any member of a multi-value
106
+ field. `CatalogNodeDetailsEditor` renders sections and fields by ascending
107
+ `order` (default 0, ties keep declaration order). `resource_selector` and
108
+ `credential_selector` fields that resolve only to a widget fallback render as
109
+ the remote-options select, which shows the field's declared `placeholder`.
110
+
111
+ `WorkflowFieldFrame` and `ExpressionSlot` accept optional `help` text, shown below the field label. Custom fixed and expression controls should forward the render prop’s `describedBy` to their input’s `aria-describedby`, preserving any existing description IDs. The built-in expression editor combines this contextual help with validation descriptions. Read-only fields show the saved Fixed or Expression mode as text.
112
+
113
+ Opening expression suggestions preserves focus in the expression input or textarea,
114
+ so typing continues in the authored value. The suggestion search remains explicitly
115
+ focusable for filtering and inserting available values.
116
+
117
+ Hosts provide remote workflow-field options through
118
+ `configureWorkflowFieldOptionsProvider`. The SDK keeps that adapter outside
119
+ the public package so the same workflow UI can be used with different backend
120
+ clients and host applications.
121
+
122
+ Hosts can provide `context.chart.presentation` with an `icon` React component
123
+ (accepting an optional `className`) and a `tone` CSS class string. Use the node
124
+ type’s semantic icon and its category’s styling consistently in the catalog and
125
+ canvas. `CatalogNodeChartBlock` applies the supplied tone to the card and icon
126
+ badge, ahead of the renderer’s legacy `accent`. The default charts and built-in
127
+ chart overrides that delegate to this component share this behavior. Without
128
+ presentation, standalone consumers retain the kind-based icon and accent.
129
+ The host owns identity resolution; the public SDK does not import host catalogs
130
+ or private presentation registries.
131
+
132
+ The chart exposes every declared input and output with its port name, direction,
133
+ connection limit, and allowed peer constraints. Port targets are 20 pixels wide;
134
+ the card grows to keep dense port lists and contextual add controls separated.
135
+
136
+ ## Building in the workspace
137
+
138
+ This package needs the built `@collective-intelligence/ui-react` declarations
139
+ to compile its own declarations. From the repository root, run
140
+ `bunx turbo run build --filter=@collective-intelligence/extensions-sdk-frontend-react`
141
+ to build this package and its dependencies in order. The workspace development
142
+ dependency on `ui-react` supplies that build ordering; it remains an optional
143
+ peer for consumers of the published package.
144
+
145
+ Hosted module references may supply a `load` callback alongside `module` and
146
+ `exportName`. `loadDeclarationModule` prefers that callback for the requested
147
+ implementation role, falling back to the `render` role when absent. Without a
148
+ callback it imports the module locator. Keep actual renderer functions reachable
149
+ through the callback so bundlers retain them in catalog-only entrypoints. The
150
+ callback is a runtime sidecar and is excluded from canonical package metadata.
151
+
152
+ Hosted workflow field, configuration, and template declarations require a `load`
153
+ callback. Their render paths reject locator-only implementations so hosted
154
+ bundles contain no computed imports outside the declared module graph. The
155
+ general `loadDeclarationModule` API retains its locator fallback for host-owned
156
+ loading outside those workflow render paths.
157
+
158
+ The package build emits production JSX while keeping React and React DOM external.
159
+ The built `/frontend` renderer is tested with both production and development
160
+ consumer React peers, including its loading state and loaded component props.
161
+
162
+ ## Enum value spelling
163
+
164
+ Repository-owned enum values use lower `snake_case`. This includes component kinds, dataset statuses, schema consumer profiles, and hosted contribution identity. Notification enum values retain their existing spelling. External protocol values, including HTTP methods and JSON Schema keywords and formats, retain the protocol spelling.
@@ -0,0 +1 @@
1
+ export type { HostedContributionErrorBoundaryProps, HostedContributionLoadFailure, HostedContributionLoadState, HostedContributionUnavailableProps } from "./load-state.js";
File without changes
@@ -0,0 +1,30 @@
1
+ import type { FrontendComponentDeclaration } from "@collective-intelligence/extensions-sdk-frontend";
2
+ export declare const hostedDiagnosticPhases: readonly ["admission", "resolve", "load", "render"];
3
+ export type HostedDiagnosticPhase = (typeof hostedDiagnosticPhases)[number];
4
+ export type SourceMapLocation = Readonly<{
5
+ source: string;
6
+ line: number;
7
+ column: number;
8
+ }>;
9
+ export type HostedDiagnostic = Readonly<{
10
+ diagnosticId: string;
11
+ phase: HostedDiagnosticPhase;
12
+ packageFqn: string;
13
+ componentFqn: string;
14
+ version: string;
15
+ role: string;
16
+ source: Readonly<{
17
+ module: string;
18
+ exportName: string;
19
+ }>;
20
+ sourceMap?: SourceMapLocation;
21
+ message: string;
22
+ cause?: string;
23
+ }>;
24
+ export declare const createHostedDiagnostic: (input: {
25
+ declaration: FrontendComponentDeclaration;
26
+ phase: HostedDiagnosticPhase;
27
+ message: string;
28
+ cause?: unknown;
29
+ sourceMap?: SourceMapLocation;
30
+ }) => HostedDiagnostic;
@@ -0,0 +1,27 @@
1
+ import type { FrontendComponentDeclaration } from "@collective-intelligence/extensions-sdk-frontend";
2
+ import type { ComponentType, ReactNode } from "react";
3
+ import * as React from "react";
4
+ import type { HostedDiagnostic } from "./diagnostics";
5
+ export { createHostedDiagnostic, hostedDiagnosticPhases } from "./diagnostics";
6
+ export type { HostedDiagnostic, HostedDiagnosticPhase, SourceMapLocation } from "./diagnostics";
7
+ export type HostedComponentModule<Props extends object = Record<string, never>> = Readonly<Record<string, ComponentType<Props> | undefined>>;
8
+ export type HostedComponentLoader<Props extends object> = () => Promise<HostedComponentModule<Props>>;
9
+ type HostedExtensionRenderProps<Props extends object> = Readonly<{
10
+ declaration: FrontendComponentDeclaration;
11
+ componentProps: Props;
12
+ load: HostedComponentLoader<Props>;
13
+ implementationRole?: string;
14
+ onDiagnostic?: (diagnostic: HostedDiagnostic) => void;
15
+ /** Rendered while the module loads; size it like the component to avoid layout shift. */
16
+ fallback?: ReactNode;
17
+ }>;
18
+ /** Loads the build module selected by a declaration without exposing its locator in UI code. */
19
+ export declare const loadDeclarationModule: <Props extends object = Record<string, never>>(declaration: FrontendComponentDeclaration, implementationRole?: string) => Promise<HostedComponentModule<Props>>;
20
+ /** Renders the Host's fallback UI for a hosted component that failed to load or render. */
21
+ export type HostedExtensionFailureRenderer = (diagnostic: HostedDiagnostic) => ReactNode;
22
+ /** Lets a Host replace the plain failure message with its own design-system UI. */
23
+ export declare const HostedExtensionFailureProvider: ({ children, render }: Readonly<{
24
+ children: ReactNode;
25
+ render: HostedExtensionFailureRenderer;
26
+ }>) => React.JSX.Element;
27
+ export declare const HostedExtensionRender: <Props extends object>({ componentProps, declaration, fallback, implementationRole, load, onDiagnostic }: HostedExtensionRenderProps<Props>) => ReactNode;
@@ -0,0 +1 @@
1
+ import{Component as E,createContext as k,createElement as H,useContext as y,useEffect as C,useLayoutEffect as F,useRef as L,useState as b}from"react";import"react";var v=["admission","resolve","load","render"],h=(q)=>q.trim().replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase(),S=(q)=>{if(typeof q.module==="string")return{exportName:q.exportName,module:q.module};return{exportName:q.exportName,module:q.module.pathname.split("/").pop()??"unknown-module"}},Z=(q)=>{let{declaration:w,phase:Q,message:V,cause:W,sourceMap:X}=q,{target:J}=w,$=["FE",Q.toUpperCase(),J.packageFqn,J.fqn,J.version,J.role].map(h).join("-");return{componentFqn:J.fqn,diagnosticId:$,message:V,packageFqn:J.packageFqn,phase:Q,role:J.role,source:S(w.implementation.render),version:J.version,...X===void 0?void 0:{sourceMap:X},...W===void 0?void 0:{cause:String(W instanceof Error?W.message:W)}}};import{jsx as z,jsxs as x}from"react/jsx-runtime";var d=async(q,w="render")=>{let Q=q.implementation[w]??q.implementation.render;if(Q.load!==void 0)return await Q.load();return await import(/* @vite-ignore */ String(Q.module))},D=(q)=>x("div",{role:"alert","data-diagnostic-id":q.diagnosticId,children:["Hosted extension failed. Diagnostic ID: ",q.diagnosticId]}),P=Symbol.for("@collective-intelligence/extensions-sdk-frontend-react/hosted-extension-failure"),U=globalThis,_=U[P]??k(D);U[P]=_;var s=({children:q,render:w})=>z(_.Provider,{value:w,children:q}),A=({diagnostic:q})=>y(_)(q),K=(q,w)=>{console.error(`Hosted extension ${q.diagnosticId}: ${q.message}`,w)};class M extends E{constructor(q){super(q);this.state={error:null}}static getDerivedStateFromError(q){return{error:q}}componentDidCatch(q,w){let Q=Z({cause:q,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});this.props.onDiagnostic?.(Q)}render(){if(this.state.error!==null){let q=Z({cause:this.state.error,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});return z(A,{diagnostic:q})}return this.props.children}}var R=z("output",{children:"Loading extension…"}),l=({componentProps:q,declaration:w,fallback:Q=R,implementationRole:V="render",load:W,onDiagnostic:X})=>{let[J,$]=b(null),G=L({load:W,onDiagnostic:X});F(()=>{G.current={load:W,onDiagnostic:X}},[W,X]),C(()=>{let I=!0;return(async()=>{try{let O=await G.current.load();if(!I)return;let Y=w.implementation[V]??w.implementation.render,B=O[Y.exportName];if(B===void 0){let T=Z({declaration:w,message:`Export "${Y.exportName}" was not a React component.`,phase:"load"});K(T,T),G.current.onDiagnostic?.(T),$({declaration:w,diagnostic:T,implementationRole:V,kind:"failed"});return}$({component:B,declaration:w,implementationRole:V,kind:"ready"})}catch(O){if(!I)return;let Y=Z({cause:O,declaration:w,message:"The hosted component could not be loaded.",phase:"load"});K(Y,O),G.current.onDiagnostic?.(Y),$({declaration:w,diagnostic:Y,implementationRole:V,kind:"failed"})}})(),()=>{I=!1}},[w,V]);let N=J?.declaration===w&&J.implementationRole===V?J:null;if(N===null)return Q;if(N.kind==="failed")return z(A,{diagnostic:N.diagnostic});let j={children:H(N.component,q),declaration:w,...X===void 0?void 0:{onDiagnostic:X}};return z(M,{...j})};export{d as loadDeclarationModule,v as hostedDiagnosticPhases,Z as createHostedDiagnostic,l as HostedExtensionRender,s as HostedExtensionFailureProvider};
@@ -0,0 +1,4 @@
1
+ export declare const declareStudioApp: (input: import("./studio-declarations").StudioAppDeclarationInput) => import("@collective-intelligence/extensions-sdk").DeclaredComponent<import("./studio-declarations").StudioAppDeclaration>;
2
+ export declare const declareStudioComponent: (input: import("./studio-declarations").StudioComponentDeclarationInput) => import("@collective-intelligence/extensions-sdk").DeclaredComponent<import("./studio-declarations").StudioComponentDeclaration>;
3
+ export type { LocalizedStudioText, StudioAppDeclaration, StudioAppDeclarationInput, StudioAppDefinition, StudioAppPageDefinition, StudioAppSectionDefinition, StudioComponentComposition, StudioComponentDeclaration, StudioComponentDeclarationInput } from "./studio-declarations.js";
4
+ export type { HostedContributionErrorBoundaryProps, HostedContributionLoadFailure, HostedContributionLoadState, HostedContributionUnavailableProps } from "./load-state.js";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{assertConsumerProfile as F,canonicalJson as G,normalizePackageSchemaProjection as H}from"@collective-intelligence/extensions-sdk";var B=(q)=>{try{G(q)}catch(w){let x=w instanceof Error?w.message:String(w);throw TypeError(`Studio declaration must be serializable JSON: ${x}`,{cause:w})}},D=(q)=>{let w={...q.definition,...q.presentation,...q.manifest,kind:"studioApp"};return B(w),{manifest:w,schemaSidecars:[]}},E=(q)=>{let w=q.definition.propsSchema,x=`studio_component:${q.manifest.fqn}.propsSchema`,y=H(w.project("input"));F(y,"studio_props",x);let A={category:q.definition.category,...q.definition.composition===void 0?void 0:{composition:q.definition.composition},...q.presentation,...q.manifest,kind:"studioComponent",propsSchema:y,sourceRef:q.definition.sourceRef};return B(A),{manifest:A,schemaSidecars:[{direction:"input",location:x,profile:"studio_props",source:w}]}};var O=D,Q=E;export{Q as declareStudioComponent,O as declareStudioApp};
@@ -0,0 +1,42 @@
1
+ import type { ComponentType, ReactNode } from "react";
2
+ export type HostedContributionLoadFailure = Readonly<{
3
+ code: "module_load_failed";
4
+ cause?: unknown;
5
+ message: string;
6
+ }> | Readonly<{
7
+ code: "export_missing";
8
+ exportName: string;
9
+ message: string;
10
+ }> | Readonly<{
11
+ code: "incompatible_host";
12
+ actualVersion: string;
13
+ expectedVersion: string;
14
+ message: string;
15
+ }> | Readonly<{
16
+ code: "render_failed";
17
+ cause?: unknown;
18
+ componentStack?: string;
19
+ message: string;
20
+ }>;
21
+ export type HostedContributionLoadState<Props> = Readonly<{
22
+ status: "loading";
23
+ }> | Readonly<{
24
+ component: ComponentType<Props>;
25
+ status: "ready";
26
+ }> | Readonly<{
27
+ reason: string;
28
+ status: "unavailable";
29
+ }> | Readonly<{
30
+ failure: HostedContributionLoadFailure;
31
+ status: "error";
32
+ }>;
33
+ export type HostedContributionErrorBoundaryProps = Readonly<{
34
+ children: ReactNode;
35
+ contributionFqn: string;
36
+ failure: HostedContributionLoadFailure;
37
+ retry: () => void;
38
+ }>;
39
+ export type HostedContributionUnavailableProps = Readonly<{
40
+ contributionFqn: string;
41
+ reason: string;
42
+ }>;
@@ -0,0 +1 @@
1
+ export declare const sortValues: <Value>(values: readonly Value[], compare: (left: Value, right: Value) => number) => Value[];
@@ -0,0 +1,10 @@
1
+ import type { JsonObject, JsonValue } from "../workflows/contracts";
2
+ export declare const isBoolean: <Value>(value: Value) => value is Value & boolean;
3
+ export declare const isFunction: <Value>(value: Value) => value is Value & ((...arguments_: never[]) => JsonValue);
4
+ export declare const isNumber: <Value>(value: Value) => value is Value & number;
5
+ export declare const isObject: <Value>(value: Value) => value is Value & object;
6
+ export declare const isJsonValue: <Value>(value: Value) => value is Value & JsonValue;
7
+ export declare const isRecord: <Value>(value: Value) => value is Value & JsonObject;
8
+ export declare const isString: <Value>(value: Value) => value is Value & string;
9
+ export declare const isUndefined: <Value>(value: Value) => value is Value & undefined;
10
+ export declare const toDisplayString: (value: JsonValue) => string;
@@ -0,0 +1,71 @@
1
+ import type { ComponentManifest, ComponentPresentation, DeclaredComponent, JsonObject, PackageDecoderSource, PackageSchemaProjection } from "@collective-intelligence/extensions-sdk";
2
+ export type LocalizedStudioText = Readonly<{
3
+ fallbackLocale: string;
4
+ values: Readonly<Record<string, string>>;
5
+ }>;
6
+ export type StudioAppPageDefinition = Readonly<{
7
+ fullWidth?: boolean;
8
+ icon?: string;
9
+ kind: "predefined";
10
+ label: string;
11
+ orderIndex: number;
12
+ predefinedPageRef: string;
13
+ routeSegment: string;
14
+ slug: string;
15
+ }>;
16
+ export type StudioAppSectionDefinition = Readonly<{
17
+ description?: string;
18
+ icon?: string;
19
+ label: string;
20
+ orderIndex: number;
21
+ pages: readonly StudioAppPageDefinition[];
22
+ slug: string;
23
+ }>;
24
+ export type StudioAppDefinition = Readonly<{
25
+ color?: string;
26
+ description?: string;
27
+ icon?: string;
28
+ isDefaultTemplate?: boolean;
29
+ name: string;
30
+ sections: readonly StudioAppSectionDefinition[];
31
+ slug: string;
32
+ }>;
33
+ export type StudioAppDeclaration = ComponentManifest & ComponentPresentation & Readonly<{
34
+ definition: StudioAppDefinition;
35
+ kind: "studioApp";
36
+ }>;
37
+ export type StudioComponentComposition = Readonly<{
38
+ extensions?: JsonObject;
39
+ slotSource: "props" | "static";
40
+ slots: readonly Readonly<{
41
+ extensions?: JsonObject;
42
+ key: string;
43
+ label?: LocalizedStudioText;
44
+ }>[];
45
+ }>;
46
+ export type StudioComponentDeclaration = ComponentManifest & ComponentPresentation & Readonly<{
47
+ category: "layout" | "page" | "primitive" | "view" | "widget";
48
+ composition?: StudioComponentComposition;
49
+ kind: "studioComponent";
50
+ propsSchema: PackageSchemaProjection;
51
+ sourceRef: string;
52
+ }>;
53
+ export type StudioAppDeclarationInput = Readonly<{
54
+ definition: Readonly<{
55
+ definition: StudioAppDefinition;
56
+ }>;
57
+ manifest: ComponentManifest;
58
+ presentation: ComponentPresentation;
59
+ }>;
60
+ export type StudioComponentDeclarationInput<Schema extends PackageDecoderSource = PackageDecoderSource> = Readonly<{
61
+ definition: Readonly<{
62
+ category: StudioComponentDeclaration["category"];
63
+ composition?: StudioComponentComposition;
64
+ propsSchema: Schema;
65
+ sourceRef: string;
66
+ }>;
67
+ manifest: ComponentManifest;
68
+ presentation: ComponentPresentation;
69
+ }>;
70
+ export declare const declareStudioApp: (input: StudioAppDeclarationInput) => DeclaredComponent<StudioAppDeclaration>;
71
+ export declare const declareStudioComponent: (input: StudioComponentDeclarationInput) => DeclaredComponent<StudioComponentDeclaration>;
@@ -0,0 +1,4 @@
1
+ export declare const declareStudioApp: (input: import("./studio-declarations").StudioAppDeclarationInput) => import("@collective-intelligence/extensions-sdk").DeclaredComponent<import("./studio-declarations").StudioAppDeclaration>;
2
+ export declare const declareStudioComponent: (input: import("./studio-declarations").StudioComponentDeclarationInput) => import("@collective-intelligence/extensions-sdk").DeclaredComponent<import("./studio-declarations").StudioComponentDeclaration>;
3
+ export type { HostedContributionErrorBoundaryProps, HostedContributionLoadFailure, HostedContributionLoadState, HostedContributionUnavailableProps } from "./load-state.js";
4
+ export type { LocalizedStudioText, StudioAppDeclaration, StudioAppDeclarationInput, StudioAppDefinition, StudioAppPageDefinition, StudioAppSectionDefinition, StudioComponentComposition, StudioComponentDeclaration, StudioComponentDeclarationInput } from "./studio-declarations.js";
package/dist/studio.js ADDED
@@ -0,0 +1 @@
1
+ import{assertConsumerProfile as F,canonicalJson as G,normalizePackageSchemaProjection as H}from"@collective-intelligence/extensions-sdk";var B=(q)=>{try{G(q)}catch(w){let x=w instanceof Error?w.message:String(w);throw TypeError(`Studio declaration must be serializable JSON: ${x}`,{cause:w})}},D=(q)=>{let w={...q.definition,...q.presentation,...q.manifest,kind:"studioApp"};return B(w),{manifest:w,schemaSidecars:[]}},E=(q)=>{let w=q.definition.propsSchema,x=`studio_component:${q.manifest.fqn}.propsSchema`,y=H(w.project("input"));F(y,"studio_props",x);let A={category:q.definition.category,...q.definition.composition===void 0?void 0:{composition:q.definition.composition},...q.presentation,...q.manifest,kind:"studioComponent",propsSchema:y,sourceRef:q.definition.sourceRef};return B(A),{manifest:A,schemaSidecars:[{direction:"input",location:x,profile:"studio_props",source:w}]}};var O=D,Q=E;export{Q as declareStudioComponent,O as declareStudioApp};
@@ -0,0 +1 @@
1
+ export type { ResourceActionPrimitiveProps, ResourceColumn, ResourceDialogPrimitiveProps, ResourceFilterPrimitiveProps, ResourceListPrimitiveProps, ResourcePaginationPrimitiveProps, ResourceTablePrimitiveProps } from "@collective-intelligence/ui-react/resources";
File without changes
@@ -0,0 +1 @@
1
+ export * from "./workflows/index.js";
@@ -0,0 +1 @@
1
+ var m0=Object.defineProperty;var v0=(Z)=>Z;function x0(Z,$){this[Z]=v0.bind(null,$)}var p0=(Z,$)=>{for(var U in $)m0(Z,U,{get:$[U],enumerable:!0,configurable:!0,set:x0.bind($,U)})};var A=(Z,$)=>()=>(Z&&($=Z(Z=0)),$);var Y$=(Z)=>Boolean(Z)===Z,d0=(Z)=>Object.prototype.toString.call(Z)==="[object Function]",k=(Z)=>Number(Z)===Z,D=(Z)=>Z!==null&&Object(Z)===Z&&!d0(Z),b=(Z)=>{let $=Object.prototype.toString.call(Z);if(Z===null||$==="[object Boolean]"||$==="[object Number]"||$==="[object String]")return!0;if(Array.isArray(Z))return Z.every(b);return D(Z)&&Object.values(Z).every(b)},I=(Z)=>b(Z)&&D(Z)&&!Array.isArray(Z),Q=(Z)=>String(Z)===Z,D6=(Z)=>Z===void 0,T6=(Z)=>{let $=Z;if(Q($))return $;if(Y$($)||k($))return String($);return""};import{ArrowRight as u0,CheckCircle2 as c0,Wrench as r0,Zap as l0}from"@collective-intelligence/ui-react/icons";var F1=function($){switch($){case"trigger":case"trigger_node":return{icon:l0,label:"Trigger",tone:"bg-violet-500/12 text-violet-600 dark:text-violet-400"};case"input_node":return{icon:u0,label:"Input",tone:"bg-sky-500/12 text-sky-600 dark:text-sky-400"};case"output_node":return{icon:c0,label:"Output",tone:"bg-emerald-500/12 text-emerald-600 dark:text-emerald-400"};default:return{icon:r0,label:"Action",tone:"bg-slate-500/12 text-slate-600 dark:text-slate-400"}}};var L1=()=>{};import{AlertTriangle as o0,Plus as s0}from"@collective-intelligence/ui-react/icons";import{Tooltip as i0,TooltipContent as n0,TooltipTrigger as a0}from"@collective-intelligence/ui-react/ui";import{Handle as t0,Position as R1,useNodeId as e0,useUpdateNodeInternals as $4}from"@xyflow/react";import{useEffect as Z4}from"react";import{jsx as F,jsxs as j,Fragment as Y4}from"react/jsx-runtime";var U4,D1=function($){if(Q($))return $;if(D($)&&"kind"in $&&"text"in $){let U=$;if(U.kind==="literal"&&Q(U.text))return U.text}if(D($)&&"en"in $){let U=$.en;return Q(U)?U:""}return""},W4=({issues:Z,title:$})=>{let U=`${Z.length} ${Z.length===1?"issue":"issues"} on ${$}`;return j(i0,{children:[F(a0,{asChild:!0,children:F("button",{type:"button","aria-label":U,className:"nodrag nopan absolute -right-2 -top-2 z-20 flex size-7 items-center justify-center rounded-full border border-[color-mix(in_oklab,var(--warning)_45%,var(--border))] bg-[color-mix(in_oklab,var(--warning)_16%,var(--card))] text-[color-mix(in_oklab,var(--warning)_80%,var(--foreground))] shadow-sm transition hover:bg-[color-mix(in_oklab,var(--warning)_24%,var(--card))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",onClick:(W)=>{W.stopPropagation()},onPointerDown:(W)=>{W.stopPropagation()},children:F(o0,{"aria-hidden":"true",className:"size-4"})})}),j(n0,{side:"top",sideOffset:6,className:"max-w-72 p-3",children:[F("p",{className:"font-semibold",children:U}),F("ul",{className:"mt-1.5 space-y-1",children:Z.map((W)=>F("li",{className:"leading-snug",children:W.message},`${W.code}:${W.message}`))})]})]})},T1=({port:Z,side:$,index:U=0,count:W=1})=>{let X=$==="left"?R1.Left:R1.Right,Y={top:`${(U+1)/(W+1)*100}%`},z=Z.maxConnections===null?"unlimited connections":`maximum ${Z.maxConnections??1} connections`,G=[...Array.isArray(Z.allowedTemplateKinds)?Z.allowedTemplateKinds.filter(Q):[],...Array.isArray(Z.allowedTemplateFqns)?Z.allowedTemplateFqns.filter(Q):[]],J=`${Z.key} — ${Z.direction}, ${z}${G.length?`; accepts ${G.join(", ")}`:""}`;return j(Y4,{children:[F(t0,{id:Z.key,type:Z.direction==="input"?"target":"source",position:X,title:J,"aria-label":J,style:Y,className:Z.direction==="input"?"!h-5 !w-5 !rounded-sm !border-2 !border-background !bg-primary":"!h-5 !w-5 !border-2 !border-background !bg-primary"}),F("span",{style:Y,className:`pointer-events-none absolute z-10 -translate-y-full whitespace-nowrap rounded bg-card px-1 text-[10px] text-muted-foreground ${$==="left"?"right-full mr-2":"left-full ml-2"}`,children:Z.key})]})},X4=({signature:Z})=>{let $=e0(),U=$4();return Z4(()=>{if($!==null)U($)},[$,Z,U]),null},$$=({context:Z,accent:$})=>{let U=Z.ports.filter((w)=>w.direction==="input"),W=Z.ports.filter((w)=>w.direction==="output"),X=new Set(Z.chart.connectedOutputPortKeys),Y=Z.chart.fields??[],z=D1(Z.template.label),G=Z.chart.title??z,J=Z.chart.subtitle??(G===z?void 0:z),_=Z.chart.description??D1(Z.template.description),{icon:K}=Z.chart.presentation??F1(Z.template.kind),B=Z.chart.presentation?.tone??U4[$],N=Z.diagnostics.filter((w)=>w.severity!=="info");return j("div",{className:"relative w-[262px]",children:[N.length?F(W4,{issues:N,title:G}):null,j("button",{type:"button","aria-label":`Edit ${G}`,style:{minHeight:(Math.max(U.length,W.length)+1)*28},onDoubleClick:()=>{Z.chart.onOpenDetails()},className:`workflow-node-drag group relative z-10 w-full cursor-pointer rounded-2xl border bg-card p-4 text-left shadow-[0_2px_10px_-4px_rgba(30,29,26,0.12)] transition-[border-color,box-shadow] hover:shadow-[0_8px_24px_-14px_rgba(30,29,26,0.24)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${B}`,children:[Z.ports.length>0?F(X4,{signature:Z.ports.map((w)=>`${w.direction}:${w.key}`).join("|")}):null,U.map((w,H)=>F(T1,{port:w,side:"left",index:H,count:U.length},w.key)),W.map((w,H)=>F(T1,{port:w,side:"right",index:H,count:W.length},w.key)),j("div",{className:"flex items-start gap-3",children:[F("div",{className:`flex size-10 shrink-0 items-center justify-center rounded-xl ${B}`,children:F(K,{className:"size-5"})}),j("div",{className:"min-w-0",children:[F("div",{className:"truncate text-sm font-semibold text-foreground",children:G}),Q(J)&&J.length>0?F("p",{className:"truncate font-mono text-[11px] text-muted-foreground",children:J}):null]})]}),(()=>{if(Q(_)&&_.length>0)return j("div",{className:"mt-3 space-y-1 border-t border-border/70 pt-3",children:[Q(_)&&_.length>0?F("p",{className:"text-xs leading-snug text-muted-foreground",children:_}):null,Q(Z.chart.summary)&&Z.chart.summary.length>0?F("p",{className:"text-xs text-muted-foreground",children:Z.chart.summary}):null]});return null})(),Y.length?F("div",{className:"mt-3 space-y-1.5 border-t border-border/70 pt-3",children:Y.slice(0,4).map((w)=>F("div",{className:"truncate rounded-md bg-muted px-2.5 py-1.5 font-mono text-[11px] text-foreground",children:w},w))}):null]}),(()=>{if(W.length)return F("div",{className:`absolute left-full top-0 h-full ${W.length===1?"w-24":"w-36"}`,children:W.map((w,H)=>X.has(w.key)?null:j("div",{className:"absolute left-0 right-0 flex -translate-y-1/2 items-center gap-1.5",style:{top:`${(H+1)/(W.length+1)*100}%`},children:[F("div",{className:"h-px min-w-8 flex-1 bg-foreground/40"}),X.has(w.key)?null:F("button",{type:"button",className:"flex size-6 shrink-0 items-center justify-center rounded-md border border-border-strong bg-card text-muted-foreground shadow-sm transition hover:border-primary hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40","aria-label":`Add after ${G} ${w.key}`,title:`Add after ${w.key}`,onClick:(V)=>{V.stopPropagation(),Z.chart.onAddFromPort?.(w)},children:F(s0,{className:"size-3.5"})})]},w.key))});return null})()]})};var g$=A(()=>{L1();U4={emerald:"bg-[color-mix(in_oklab,var(--chart-2)_12%,var(--card))] text-emerald-600 border-emerald-500/30",sky:"bg-[color-mix(in_oklab,var(--chart-4)_12%,var(--card))] text-sky-600 border-sky-500/30",slate:"bg-[color-mix(in_oklab,var(--bg-surface-alt)_55%,var(--card))] text-slate-600 border-slate-500/30",violet:"bg-[color-mix(in_oklab,var(--chart-5)_12%,var(--card))] text-violet-600 border-violet-500/30"}});var z4=(Z)=>Z.trim().replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase(),G4=(Z)=>{if(typeof Z.module==="string")return{exportName:Z.exportName,module:Z.module};return{exportName:Z.exportName,module:Z.module.pathname.split("/").pop()??"unknown-module"}},z$=(Z)=>{let{declaration:$,phase:U,message:W,cause:X,sourceMap:Y}=Z,{target:z}=$,G=["FE",U.toUpperCase(),z.packageFqn,z.fqn,z.version,z.role].map(z4).join("-");return{componentFqn:z.fqn,diagnosticId:G,message:W,packageFqn:z.packageFqn,phase:U,role:z.role,source:G4($.implementation.render),version:z.version,...Y===void 0?void 0:{sourceMap:Y},...X===void 0?void 0:{cause:String(X instanceof Error?X.message:X)}}};var P1=()=>{};import{Component as J4,createContext as _4,createElement as K4,useContext as V4,useEffect as Q4,useLayoutEffect as w4,useRef as H4,useState as q4}from"react";import"react";import{jsx as M$,jsxs as A4}from"react/jsx-runtime";var B4=(Z)=>A4("div",{role:"alert","data-diagnostic-id":Z.diagnosticId,children:["Hosted extension failed. Diagnostic ID: ",Z.diagnosticId]}),E1,O1,I1,S1=({diagnostic:Z})=>V4(I1)(Z),C1=(Z,$)=>{console.error(`Hosted extension ${Z.diagnosticId}: ${Z.message}`,$)},k1,M4,Z$=({componentProps:Z,declaration:$,fallback:U=M4,implementationRole:W="render",load:X,onDiagnostic:Y})=>{let[z,G]=q4(null),J=H4({load:X,onDiagnostic:Y});w4(()=>{J.current={load:X,onDiagnostic:Y}},[X,Y]),Q4(()=>{let B=!0;return(async()=>{try{let w=await J.current.load();if(!B)return;let H=$.implementation[W]??$.implementation.render,V=w[H.exportName];if(V===void 0){let L=z$({declaration:$,message:`Export "${H.exportName}" was not a React component.`,phase:"load"});C1(L,L),J.current.onDiagnostic?.(L),G({declaration:$,diagnostic:L,implementationRole:W,kind:"failed"});return}G({component:V,declaration:$,implementationRole:W,kind:"ready"})}catch(w){if(!B)return;let H=z$({cause:w,declaration:$,message:"The hosted component could not be loaded.",phase:"load"});C1(H,w),J.current.onDiagnostic?.(H),G({declaration:$,diagnostic:H,implementationRole:W,kind:"failed"})}})(),()=>{B=!1}},[$,W]);let _=z?.declaration===$&&z.implementationRole===W?z:null;if(_===null)return U;if(_.kind==="failed")return M$(S1,{diagnostic:_.diagnostic});let K={children:K4(_.component,Z),declaration:$,...Y===void 0?void 0:{onDiagnostic:Y}};return M$(k1,{...K})};var A$=A(()=>{P1();E1=Symbol.for("@collective-intelligence/extensions-sdk-frontend-react/hosted-extension-failure"),O1=globalThis,I1=O1[E1]??_4(B4);O1[E1]=I1;k1=class k1 extends J4{constructor(Z){super(Z);this.state={error:null}}static getDerivedStateFromError(Z){return{error:Z}}componentDidCatch(Z,$){let U=z$({cause:Z,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});this.props.onDiagnostic?.(U)}render(){if(this.state.error!==null){let Z=z$({cause:this.state.error,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});return M$(S1,{diagnostic:Z})}return this.props.children}};M4=M$("output",{children:"Loading extension…"})});var U$=async(Z,$="render")=>{let U=Z.implementation[$]??Z.implementation.render;if(U.load===void 0)throw Error(`Workflow contribution "${Z.target.fqn}" requires a retained module loader for "${$}".`);return await U.load()};import{infiniteQueryOptions as N4,queryOptions as F4}from"@tanstack/react-query";var b1,c6=(Z)=>{b1=Z},j1=(Z)=>{let{optionsProvider:$,...U}=Z;return U},f1=(Z)=>["workflow-field-options",j1(Z)],y1=(Z,$)=>{let U=Z.optionsProvider??b1;return U===void 0?Promise.resolve({options:[]}):U(j1(Z),$.signal)},G$=(Z)=>F4({queryFn:async($)=>await y1(Z,$),queryKey:f1(Z)}),r6=(Z)=>N4({getNextPageParam:($)=>$.nextCursor,initialPageParam:null,queryFn:async({pageParam:$,signal:U})=>await y1({...Z,cursor:$},{signal:U}),queryKey:f1({...Z,cursor:null})});var m$=()=>{};import{Combobox as L4,Label as R4}from"@collective-intelligence/ui-react/ui";import{useQuery as D4}from"@tanstack/react-query";import{jsx as h1,jsxs as P4}from"react/jsx-runtime";var T4=(Z)=>{if(Z?.kind==="literal")return Z.text;return Z?.kind==="translation"?Z.default:void 0},g1=({context:Z})=>{let{remoteOptions:$}=Z,U={catalogTemplateId:$?.catalogTemplateId??"",dependencies:$?.dependencies??{},limit:50,organizationId:$?.organizationId??""},W=$?.config===void 0?G$(U):G$({...U,config:$.config}),X=(()=>{if($?.optionsProvider===void 0)return W;if($.config===void 0)return G$({...U,optionsProvider:$.optionsProvider});return G$({...U,config:$.config,optionsProvider:$.optionsProvider})})(),Y=D4({...X,enabled:Boolean($)}),z=Y.data?.options??Z.options,G=T4(Z.field.placeholder);return P4("div",{className:"space-y-2",children:[h1(R4,{htmlFor:`workflow-field-${Z.field.key}`,children:Z.field.label.kind==="literal"?Z.field.label.text:Z.field.label.default}),h1(L4,{className:"w-full",disabled:Z.readOnly||Boolean($&&Y.isPending),emptyMessage:"No options are available.",id:`workflow-field-${Z.field.key}`,modal:!0,onChange:(J)=>Z.onValueChange(J),options:z.map((J)=>({label:J.label,value:String(J.value)})),placeholder:G??"Select an option",searchPlaceholder:"Search options...",value:Z.value===null||!Q(Z.value)&&!k(Z.value)?"":String(Z.value),width:"100%"})]})};var m1=A(()=>{m$()});var d;var v$=A(()=>{d={field:"Field",unavailableConfiguration:(Z)=>`${Z} has configuration that this Dashboard cannot edit. Its saved configuration is preserved.`,unavailableControl:(Z,$)=>`${Z} uses an unavailable ${$} control. Its saved value is preserved.`}});import{Alert as C4,AlertDescription as E4}from"@collective-intelligence/ui-react/ui";import{jsx as f,jsxs as p$,Fragment as I4}from"react/jsx-runtime";var x$=({diagnostics:Z})=>f(I4,{children:Z.map(($)=>f(C4,{variant:"destructive",children:f(E4,{children:$.message})},`${$.code}:${$.message}`))}),O4=(Z)=>{if(Q(Z))return Z;if(Z!==null&&D(Z)&&"text"in Z){let{text:$}=Z;return Q($)?$:d.field}if(Z!==null&&D(Z)&&"default"in Z){let{default:$}=Z;return Q($)?$:d.field}return d.field},d$=({context:Z})=>{let $={widget:Z.field.widget};if(Z.field.fieldFqn!==void 0&&Z.field.fieldFqn!==null)$.fqn=Z.field.fieldFqn;if(Z.field.fieldVersion!==void 0&&Z.field.fieldVersion!==null)$.version=Z.field.fieldVersion;let U=J$($),W=Z.mode??(Z.readOnly?"read_only":"value"),X={...Z,readOnly:W==="read_only"||Z.readOnly};if(U.kind==="resolved"&&U.source==="fallback"&&Z.field.optionSource?.kind==="remote")return p$("div",{className:"space-y-2",children:[f(g1,{context:X}),f(x$,{diagnostics:Z.diagnostics})]});if(U.kind==="resolved")return p$("div",{className:"space-y-2",children:[f(Z$,{componentProps:X,declaration:U.entry.declaration,load:()=>U$(U.entry.declaration)}),v1(U.entry).handlesDiagnostics===!0?null:f(x$,{diagnostics:Z.diagnostics})]});return p$("div",{className:"space-y-2",children:[f("div",{className:"rounded-lg border border-dashed border-border px-3 py-2 text-sm text-muted-foreground",children:d.unavailableControl(O4(Z.field.label),Z.field.fieldFqn??Z.field.widget)}),f(x$,{diagnostics:Z.diagnostics})]})};var u$=A(()=>{A$();_$();m1();v$()});var x1;var p1=A(()=>{x1={noEditableFields:"This template does not expose editable fields."}});import{jsx as c$,jsxs as u1}from"react/jsx-runtime";var S4=function($){if(Q($))return $;if(D($)&&!Array.isArray($)&&"en"in $){let U=$.en;return Q(U)?U:""}return""},d1=function($){return[...$].sort((U,W)=>(U.order??0)-(W.order??0))},k4=function($){return d1($).map((U)=>({...U,fields:d1(U.fields??[])}))},u=({context:Z})=>{let $=k4("editor"in Z.template.contract?Z.template.contract.editor?.form?.sections??[]:[]);return u1("div",{className:"space-y-5",children:[$.map((U)=>u1("section",{className:"space-y-3 rounded-xl border border-border p-4",children:[c$("h3",{className:"text-sm font-semibold text-foreground",children:S4(U.label)}),(U.fields??[]).filter((W)=>Z.isFieldVisible?.(W)??!0).map((W)=>Z.getFieldContext?c$(d$,{context:Z.getFieldContext(W)},W.key):null)]},U.key)),$.length?null:c$("p",{className:"rounded-xl border border-dashed border-border p-4 text-sm text-muted-foreground",children:x1.noEditableFields})]})};var N$=A(()=>{u$();p1()});var b4,c1=(Z)=>b4.has(Z),c=(Z)=>I(Z)?Z:void 0,L$=(Z)=>{let $=Z.anyOf??Z.oneOf;return Array.isArray($)?$.flatMap((U)=>{let W=c(U);return W===void 0?[]:L$(W)}):[Z]},r1=(Z)=>{if(Z===null)return"null";if(Array.isArray(Z))return"array";if(I(Z))return"object";if(Q(Z))return"string";if(k(Z))return Number.isInteger(Z)?"integer":"number";return"boolean"},o1=(Z)=>{let{type:$}=Z;if(Q($))return c1($)?new Set([$]):void 0;if(Array.isArray($))return new Set($.filter(Q).filter(c1));if(Z.const!==void 0)return new Set([r1(Z.const)]);if(Array.isArray(Z.enum))return new Set(Z.enum.map(r1));if(Z.properties!==void 0)return new Set(["object"]);if(Z.items!==void 0)return new Set(["array"]);return},y=(Z)=>{let $=new Set;for(let U of L$(Z)){let W=o1(U);if(W===void 0)return;for(let X of W)$.add(X)}return $},s1=(Z)=>{let[$]=Z;if($===void 0)return{};return Z.length===1?$:{anyOf:[...Z]}},K$=(Z,$)=>L$(Z).filter((U)=>{let W=o1(U);return W===void 0||W.has($)}),F$=(Z)=>s1(K$(Z,"array").map(($)=>c($.items)??{})),j4=(Z,$)=>Z.has($)||$==="integer"&&Z.has("number"),f4=(Z,$)=>{let[U]=K$(Z,"object"),W=c(U?.properties);if(W===void 0)return!0;let X=Array.isArray(U?.required)?U.required.filter(Q):[];return K$($,"object").every((Y)=>{let z=c(Y.properties);if(z===void 0)return!0;return X.every((G)=>(G in z))&&Object.entries(W).every(([G,J])=>{let _=c(z[G]),K=c(J);return _===void 0||K===void 0?!0:r(K,_)})})},r=(Z,$)=>{let U=y(Z),W=y($);if(U===void 0||W===void 0)return!0;for(let X of W)if(!j4(U,X))return!1;if(W.has("array")&&!r(F$(Z),F$($)))return!1;return!W.has("object")||f4(Z,$)},y4=(Z)=>s1(L$(Z).flatMap(($)=>{let{type:U}=$;if(U==="null")return[];if(Array.isArray(U)){let W=U.filter((X)=>X!=="null");return W.length===0?[]:[{...$,type:W}]}return[$]})),h4=(Z)=>{let $=y(Z);if($?.has("string")===!0)return'""';if($?.has("number")===!0||$?.has("integer")===!0)return"0";if($?.has("boolean")===!0)return"false";return},g4=(Z)=>{let $=K$(Z,"array").every((W)=>k(W.minItems)&&W.minItems>=1),U=F$(Z);return $||y(U)?.has("null")===!0?U:{anyOf:[U,{type:"null"}]}},r$=(Z,$)=>{if($===void 0||y($)===void 0||y(Z)===void 0)return{status:"unknown"};if(r($,Z))return{status:"compatible"};let U=h4($),W=(J,_)=>{if(r($,J))return _;return U!==void 0&&r($,y4(J))?[..._,`coalesce(${U})`]:void 0},X=W(Z,[]),Y=y(Z),z=X===void 0&&Y?.has("array")===!0?W(g4(Z),["first"]):void 0,G=X??z;return G===void 0||G.length===0?{status:"incompatible"}:{pipes:G.map((J)=>`| ${J}`).join(" "),status:"fixable"}},l1=4,m4=(Z)=>{let $=K$(Z,"object").flatMap((W)=>Object.keys(c(W.properties)??{}));if($.length===0)return"object";return`{${$.slice(0,l1).join(", ")}${$.length>l1?", …":""}}`},l$=(Z)=>{let $=y(Z);if($===void 0)return"any";return["string","integer","number","boolean","object","array","null"].filter((W)=>$.has(W)).map((W)=>{if(W==="array"){let X=F$(Z),Y=y(X);return`array of ${Y?.size===1&&Y.has("object")?m4(X):l$(X)}`}return W}).join(" | ")};var R$=A(()=>{b4=new Set(["array","boolean","integer","null","number","object","string"])});var A7=function($){let U=$.mode==="fixed"?$.value:null;return{expression:$.mode==="expression"?$.source:"",fixed:U,mode:$.mode}},N7=function($){return $.mode==="fixed"?{mode:"fixed",value:$.fixed}:{languageVersion:1,mode:"expression",source:$.expression}},i1=function($,U){return{availability:U.availability,id:U.id,label:U.label,path:U.path??[],schema:U.schema,sourceId:$}},v4=(Z,$)=>Z.length===$.length&&Z.every((U,W)=>U===$[W]),x4=function($,U,W){let X=W.path??[];if(X.length===0){$.children.push(i1(U,W));return}let Y=$;for(let[z,G]of X.entries()){let J=X.slice(0,z+1),_=Y.children.findIndex((N)=>v4(N.path,J)),K=Y.children[_];if(z===X.length-1){if(!K)Y.children.push(i1(U,W));return}if(K&&"children"in K){Y=K;continue}let B=K?{...K,children:[],conditional:K.availability==="conditional",selectors:[]}:{availability:W.availability,children:[],conditional:W.availability==="conditional",id:`${U}:${J.join(".")}`,label:String(G),path:J,schema:{},selectors:[],sourceId:U};if(K)Y.children[_]=B;else Y.children.push(B);Y=B}},p4=function Z($){return $.flatMap((U)=>[U,...Z(U.children??[])])},d4=function($){let U=$.availability??"guaranteed",W={availability:U,children:[],conditional:U==="conditional",id:$.id,label:$.label,path:[],schema:$.schema,selectors:($.selectors??[]).map((X)=>X.kind),sourceId:$.id};if($.nodeKey!==void 0&&$.nodeKey!==null)W.nodeKey=$.nodeKey;for(let X of p4($.fields??[]))x4(W,$.id,X);return W},u4=function($){return{compatibility:$.targetCompatibility??[],language:$.languageManifest,sources:($.availableSources??[]).map(d4)}},c4=function($){return{canonicalSource:$.canonicalSource??null,diagnostics:($.diagnostics??[]).map((U)=>({actualSchema:U.actualSchema,code:U.code,expectedSchema:U.expectedSchema,message:U.message,remediation:U.remediation,severity:U.severity,span:U.span})),inferredSchema:$.inferredSchema,references:$.references??[]}},F7=function($,U){return r(U,$)},n1=function($,U,W){let X=Math.max(0,Math.min(U,$.length));return{cursor:X+W.length,source:`${$.slice(0,X)}${W}${$.slice(X)}`}};var D$=A(()=>{R$()});var r4=function($){if($.id==="trigger")return"trigger";if($.id==="workflow_input")return"input";let[,U]=$.id.split(":port:");return`nodes[${JSON.stringify($.nodeKey??$.label)}]${U?`.${U}`:""}`},l4=function($){return $.map((U)=>(()=>{if(k(U))return`[${U}]`;if(/^[A-Za-z_$][\w$]*$/u.test(U))return`.${U}`;return`[${JSON.stringify(U)}]`})()).join("")},o4=function($){if($.id==="trigger")return{id:"trigger",label:"Trigger data"};if($.id==="workflow_input")return{id:"workflow_input",label:"Workflow input"};return{id:$.id,label:$.label}},s4=function Z($){let{source:U}=$;return $.nodes.flatMap((W)=>{let X=`${U.id}:${W.id}`,Y=[...$.parentLabels,W.label],z="children"in W?W.children:[],G=`${r4(U)}${l4(W.path)}`;return[{conditional:W.availability==="conditional",depth:$.depth,expandable:z.length>0,group:$.group,id:X,insertion:`{{ ${G} }}`,label:`${U.label} · ${Y.join(".")}`,name:W.label,parentId:$.parentId,pathLabel:Y.join("."),reference:G,schema:W.schema,selectors:U.selectors},...Z({depth:$.depth+1,group:$.group,nodes:z,parentId:X,parentLabels:Y,source:U})]})},i4=function($){let U=$.children.length?$.children:[{availability:$.availability,id:$.id,label:"Output",path:[],schema:$.schema,sourceId:$.id}];return s4({depth:0,group:o4($),nodes:U,parentId:null,parentLabels:[],source:$})},o$=function($){return $.sources.flatMap((U)=>i4(U))},l=function($){return l$($)};var T$=A(()=>{R$()});import{jsx as P,jsxs as t1,Fragment as n4}from"react/jsx-runtime";var O=({title:Z,values:$})=>t1("section",{"aria-label":Z,children:[P("h3",{className:"font-medium",children:Z}),$.length>0?P("ul",{className:"mt-1 list-disc pl-5 font-mono text-xs",children:$.map((U,W)=>P("li",{children:U},`${U}-${W}`))}):P("p",{className:"text-muted-foreground",children:"No entries in this language manifest."})]}),a1=function($){return $.map((U)=>U.example??U.name)},s$=({manifest:Z})=>t1(n4,{children:[P(O,{title:"Syntax overview",values:[Z.grammar]}),P(O,{title:"Interpolation",values:[`Whole value preserves type: ${Z.interpolation.wholeValuePreservesType}`,`Mixed text returns: ${Z.interpolation.mixedTextReturns}`]}),P(O,{title:"References",values:[Z.grammar]}),P(O,{title:"Selectors",values:Z.selectors.map(({kind:$})=>$)}),P(O,{title:"Unavailable-value policies",values:Z.availabilityPolicies}),P(O,{title:"Operators",values:Z.operators}),P(O,{title:"Functions",values:a1(Z.functions)}),P(O,{title:"Casts and pipes",values:Z.pipes}),P(O,{title:"Strings",values:Z.pipes}),P(O,{title:"Collections",values:Z.pipes}),P(O,{title:"Objects",values:Z.pipes}),P(O,{title:"Dates",values:Z.pipes}),P(O,{title:"If conditions",values:Z.ifExamples}),P(O,{title:"Comparators",values:a1(Z.comparators)})]});var i$=()=>{};var o;var e1=A(()=>{o={applyPipes:(Z)=>`Append ${Z}`,expectedType:"Field expects",incompatibleType:"Incompatible type",insertWithPipes:"Insert with the pipes that make this value fit the field",validationFailed:(Z)=>`We couldn't validate this expression: ${Z}`,validationUnavailable:"We couldn't validate this expression right now. Check its syntax and referenced values, then try again."}});import{ChevronRight as a4}from"@collective-intelligence/ui-react/icons";import{Badge as t4,Button as i,Input as $0,Popover as e4,PopoverAnchor as $5,PopoverContent as Z5,Textarea as U5}from"@collective-intelligence/ui-react/ui";import{Fragment as W5,useEffect as X5,useRef as Y5,useState as s}from"react";import{jsx as M,jsxs as C}from"react/jsx-runtime";var Z0=(Z)=>Z!==null&&D(Z)&&!Array.isArray(Z),h=(Z)=>Z!==null&&Z!==void 0&&Z!=="",z5=function Z($){if(Q($))return $;if(Array.isArray($)){let U=$.map(Z).filter((W)=>h(W));return U.length?U.join("; "):void 0}if(!Z0($))return;if(Q($.msg))return $.msg;if(Q($.message))return $.message;if(Q($.detail))return $.detail;return},G5=function($){if($ instanceof Error&&h($.message))return $.message;if(!b($))return;if(!Z0($))return;return[$.detail,$.body,$.error,$.message].map(z5).find((U)=>h(U))},J5=function($){let U=G5($);return h(U)?o.validationFailed(U):o.validationUnavailable},U0,_5,W0=function($,U){return _5.flatMap((W)=>$.filter((X)=>U(X)===W))},K5=function($){let U=new Map;for(let Y of $){let z=U.get(Y.option.parentId)??[];z.push(Y),U.set(Y.option.parentId,z)}let W=new Map,X=(Y)=>{let z=W.get(Y.option.id);if(z!==void 0)return z;let G=Math.min(U0[Y.compatibility.status],...(U.get(Y.option.id)??[]).map(X));return W.set(Y.option.id,G),G};for(let[Y,z]of U)U.set(Y,W0(z,X));return U},X0=({entry:Z,expanded:$,onInsert:U,onToggle:W})=>{let{compatibility:X,option:Y}=Z,z=W===void 0,G=X.status==="incompatible";return C("div",{className:"mt-1 flex items-start gap-1",style:{paddingInlineStart:z?0:`${Y.depth*1.25}rem`},children:[!z&&Y.expandable?M(i,{"aria-expanded":$,"aria-label":`${$?"Collapse":"Expand"} ${Y.label}`,className:"mt-1 size-7 shrink-0",onClick:W,size:"icon",type:"button",variant:"ghost",children:M(a4,{"aria-hidden":!0,className:$?"size-4 rotate-90":"size-4"})}):M("span",{"aria-hidden":!0,className:"size-7 shrink-0"}),C(i,{"aria-label":`Insert ${Y.label}`,className:`block h-auto min-w-0 flex-1 whitespace-normal px-2 py-1.5 text-left ${G?"opacity-60":""}`,onClick:()=>{U(Y.insertion)},type:"button",variant:"ghost",children:[M("span",{className:"block text-sm",children:z?Y.pathLabel:Y.name}),C("span",{className:"flex flex-wrap items-center gap-1.5 font-mono text-xs text-muted-foreground",children:[l(Y.schema),G?M(t4,{className:"font-sans",variant:"outline",children:o.incompatibleType}):null]})]}),X.status==="fixable"?M(i,{"aria-label":`Insert ${Y.label} with ${X.pipes}`,className:"mt-1 h-auto shrink-0 px-1.5 py-0.5 font-mono text-xs",onClick:()=>{U(`{{ ${Y.reference} ${X.pipes} }}`)},size:"sm",title:o.insertWithPipes,type:"button",variant:"outline",children:X.pipes}):null]})},Y0=({tree:Z,expanded:$,onInsert:U,onToggle:W,parentId:X})=>(Z.get(X)??[]).map((Y)=>{let z=$.has(Y.option.id);return C(W5,{children:[M(X0,{entry:Y,expanded:z,onInsert:U,onToggle:()=>{W(Y.option.id)}}),z?M(Y0,{expanded:$,onInsert:U,onToggle:W,parentId:Y.option.id,tree:Z}):null]},Y.option.id)}),V5=({environment:Z,onInsert:$,onQueryChange:U,options:W,query:X,targetSchema:Y})=>{let[z,G]=s(new Set),J=new Map(W.map(({group:V})=>[V.id,V])),_=["trigger","workflow_input"],K=[..._.flatMap((V)=>J.get(V)??[]),...[...J.values()].filter(({id:V})=>!_.includes(V))],B=W.map((V)=>({compatibility:r$(V.schema,Y),option:V})),N=X.trim()!=="",w=B.filter(({option:V})=>[V.label,V.insertion,l(V.schema)].join(" ").toLowerCase().includes(X.trim().toLowerCase())),H=(V)=>{G((L)=>{let R=new Set(L);if(R.has(V))R.delete(V);else R.add(V);return R})};return C("div",{className:"grid h-96 max-h-[calc(100dvh-3rem)] grid-cols-[minmax(0,1fr)_14rem] overflow-hidden",children:[C("div",{className:"min-h-0 touch-pan-y overflow-y-auto overscroll-y-contain border-r p-2",onWheel:(V)=>{V.stopPropagation()},children:[M($0,{"aria-label":"Search expression suggestions",onChange:(V)=>{U(V.target.value)},placeholder:"Search available values",value:X}),K.map((V)=>{let L=(N?w:B).filter(({option:R})=>R.group.id===V.id);if(L.length===0)return null;return C("section",{"aria-label":V.label,className:"mt-3",children:[M("h3",{className:"px-2 text-xs font-semibold text-muted-foreground",children:V.label}),N?W0(L,(R)=>U0[R.compatibility.status]).map((R)=>M(X0,{entry:R,expanded:!1,onInsert:$},R.option.id)):M(Y0,{expanded:z,onInsert:$,onToggle:H,parentId:null,tree:K5(L)})]},V.id)}),(N?w:B).length===0?M("p",{className:"p-3 text-sm text-muted-foreground",children:"No matching workflow sources."}):null]}),C("aside",{className:"space-y-3 p-3","aria-label":"Expression helper",children:[Y===void 0?null:C("p",{className:"text-xs",children:[C("span",{className:"text-muted-foreground",children:[o.expectedType," "]}),M("span",{className:"font-mono",children:l(Y)})]}),M("p",{className:"text-xs text-muted-foreground",children:"Select a typed source. Expand an object to pick one of its fields, or insert the whole object."}),M("h3",{className:"text-xs font-semibold",children:"Pipes"}),Z.language.pipes.map((V)=>C(i,{className:"mr-1 mb-1 h-auto px-1.5 py-0.5 font-mono text-xs",onClick:()=>{$(` | ${V}`)},size:"sm",type:"button",variant:"outline",children:["| ",V]},V))]})]})},Q5,w5=function($,U){let W=Q5.exec($)?.groups?.body;return W===void 0||W.includes("{{")?void 0:`{{ ${W.trim()} ${U} }}`},H5=({diagnostic:Z,onApplyFix:$,source:U,targetSchema:W})=>{let X=Z.expectedSchema??W,Y=Z.code==="incompatible_expression_type"&&Z.actualSchema!==null?r$(Z.actualSchema,X??void 0):void 0,z=Y?.status==="fixable"?w5(U,Y.pipes):void 0;return C("div",{className:"space-y-1 text-sm text-destructive",role:"alert",children:[C("p",{children:[Z.message," (characters ",Z.span.start,"–",Z.span.end,")"]}),h(Z.remediation)?M("p",{className:"text-xs text-muted-foreground",children:Z.remediation}):null,Y?.status==="fixable"&&z!==void 0&&$!==void 0?M(i,{className:"h-auto px-1.5 py-0.5 font-mono text-xs",onClick:()=>{$(z)},size:"sm",type:"button",variant:"outline",children:o.applyPipes(Y.pipes)}):null]})},n$=({describedBy:Z,environment:$,inputLabel:U="Expression",source:W,onChange:X,validate:Y,multiline:z=!1,readOnly:G=!1,targetSchema:J})=>{let _=Y5(null),K=(q)=>{_.current=q},[B,N]=s(W.length),[w,H]=s(!1),[V,L]=s("suggestions"),[R,n]=s(""),[b$,j$]=s(null),[p,a]=s(null),X$=Y===void 0||W===""?null:b$,T=Y===void 0||W===""?null:p,S=[Z,h(T)?"expression-validation":void 0].filter(Boolean).join(" ")||void 0;X5(()=>{let q=new AbortController;if(!Y||W==="");else{let f$=async()=>{try{let y$=await Y(W,q.signal);if(!q.signal.aborted)j$(y$),a(null)}catch(y$){if(!q.signal.aborted)a(J5(y$))}},e=window.setTimeout(()=>{f$()},300);return()=>{q.abort(),window.clearTimeout(e)}}return()=>{q.abort()}},[W,Y]);let m=o$($),t=(q)=>{let f$=_.current?.selectionStart??B,e=n1(W,f$,q);N(e.cursor),X(e.source),queueMicrotask(()=>{_.current?.focus(),_.current?.setSelectionRange(e.cursor,e.cursor)})};return C("div",{className:"space-y-2",children:[C(e4,{onOpenChange:(q)=>{if(H(q),!q)n(""),L("suggestions")},open:w,children:[M($5,{asChild:!0,children:M("div",{children:(()=>{if(z)return M(U5,{"aria-describedby":S,"aria-invalid":h(T)||(X$?.diagnostics.length??0)>0,"aria-label":U,className:"min-h-24 text-sm",disabled:G,onChange:(q)=>{X(q.target.value),N(q.currentTarget.selectionStart??W.length)},onFocus:()=>{H(!0)},onKeyDown:(q)=>{if(q.key==="Escape")H(!1)},onSelect:(q)=>{N(q.currentTarget.selectionStart??W.length)},placeholder:"Choose a source or start typing",ref:K,value:W});return M($0,{"aria-describedby":S,"aria-invalid":h(T)||(X$?.diagnostics.length??0)>0,"aria-label":U,className:"text-sm",disabled:G,onChange:(q)=>{X(q.target.value),N(q.currentTarget.selectionStart??W.length)},onFocus:()=>{H(!0)},onKeyDown:(q)=>{if(q.key==="Escape")H(!1)},onSelect:(q)=>{N(q.currentTarget.selectionStart??W.length)},placeholder:"Choose a source or start typing",ref:K,value:W})})()})}),C(Z5,{align:"start",className:"w-[min(48rem,calc(100vw-3rem))] p-0",onOpenAutoFocus:(q)=>{q.preventDefault()},children:[C("div",{className:"flex border-b p-1",role:"tablist",children:[M(i,{"aria-selected":V==="suggestions",onClick:()=>{L("suggestions")},role:"tab",size:"sm",type:"button",variant:V==="suggestions"?"secondary":"ghost",children:"Suggestions"}),M(i,{"aria-selected":V==="syntax",onClick:()=>{L("syntax")},role:"tab",size:"sm",type:"button",variant:V==="syntax"?"secondary":"ghost",children:"Syntax reference"})]}),V==="suggestions"?M(V5,{environment:$,onInsert:t,onQueryChange:n,options:m,query:R,targetSchema:J}):M("div",{className:"max-h-96 touch-pan-y overflow-y-auto overscroll-y-contain p-4 text-sm",onWheel:(q)=>{q.stopPropagation()},children:M(s$,{manifest:$.language})})]})]}),h(T)?M("p",{id:"expression-validation",role:"alert",children:T}):null,X$?.diagnostics.map((q)=>M(H5,{diagnostic:q,onApplyFix:G?void 0:X,source:W,targetSchema:J},`${q.code}-${q.span.start}`))]})};var z0=A(()=>{D$();R$();T$();i$();e1();U0={compatible:0,fixable:1,incompatible:3,unknown:2},_5=[0,1,2,3],Q5=/^\s*\{\{(?<body>[\s\S]*?)\}\}\s*$/u});var P$=A(()=>{z0();i$();T$()});var g;var G0=A(()=>{g={expression:"Expression",expressionHelp:"Calculates a value from the data available when this step runs.",fixed:"Fixed",fixedHelp:"Uses the saved value as written.",modesHelp:"Fixed uses the saved value as written. Expression calculates a value from the data available when the step runs."}});import{Alert as q5,AlertDescription as B5,Label as M5,ToggleGroup as A5,ToggleGroupItem as J0}from"@collective-intelligence/ui-react/ui";import{useId as N5,useState as _0}from"react";import{jsx as E,jsxs as C$}from"react/jsx-runtime";var F5,K0=function($){return $.mode==="expression"?{expression:$.source,fixed:null,mode:"expression"}:{expression:"",fixed:$.value,mode:"fixed"}},L5=({mode:Z})=>E("span",{className:"shrink-0 text-xs text-muted-foreground",title:Z==="expression"?g.expressionHelp:g.fixedHelp,children:Z==="expression"?g.expression:g.fixed}),V$=({allowExpression:Z=!1,allowFixed:$=!0,controlId:U,diagnostics:W=F5,expressionEditor:X,expressionMultiline:Y=!1,help:z,label:G,onValueChange:J,readOnly:_=!1,renderExpression:K,renderFixed:B,required:N=!1,sensitive:w=!1,value:H})=>{let V=N5(),[L,R]=_0(()=>K0(H)),n=JSON.stringify(H),[b$,j$]=_0(n),p=U===void 0?void 0:`${U}-label`;if(n!==b$)j$(n),R(K0(H));let a=(()=>{if(Z&&!$)return"expression";if($&&!Z)return"fixed";return L.mode})(),X$=_;return C$("section",{className:"space-y-2",children:[C$("div",{className:"flex items-center justify-between gap-3",children:[E("div",{className:"min-w-0",children:C$("div",{className:"flex items-center gap-1",children:[E(M5,{htmlFor:U,id:p,children:G}),N?E("span",{"aria-label":"Required",children:"*"}):null,w?E("span",{className:"ml-1 text-xs text-muted-foreground",children:"Sensitive"}):null]})}),Z&&_?E(L5,{mode:a}):null,Z&&$&&!_?E("div",{"aria-label":`${G} mode controls`,className:"flex shrink-0 items-center gap-1",children:C$(A5,{"aria-label":`${G} mode`,className:"gap-0",disabled:X$,onValueChange:(T)=>{if(T==="fixed"||T==="expression")R((S)=>({...S,mode:T}))},size:"sm",type:"single",value:a,variant:"outline",children:[E(J0,{className:"h-7 px-4 text-xs",title:g.fixedHelp,value:"fixed",children:g.fixed}),E(J0,{className:"h-7 px-4 text-xs",title:g.expressionHelp,value:"expression",children:g.expression})]})}):null]}),z!==void 0&&z!==""?E("p",{id:V,className:"text-xs leading-relaxed text-muted-foreground",children:z}):null,(()=>{if(a==="expression"){if(X?.environment){let m=X.validate===void 0?{}:{validate:X.validate};return E(n$,{...z?{describedBy:V}:{},environment:X.environment,multiline:Y,onChange:(t)=>{R((q)=>({...q,expression:t})),J({languageVersion:1,mode:"expression",source:t})},readOnly:_,source:L.expression,targetSchema:X.targetSchema,...m})}if(X?.loading===!0)return E("output",{children:"Loading expression editor…"});if(X?.error!==void 0&&X.error!=="")return E("p",{role:"alert",children:X.error});let S={disabled:_,onChange:(m)=>{R((t)=>({...t,expression:m})),J({languageVersion:1,mode:"expression",source:m})},value:L.expression};if(z)S.describedBy=V;if(U!==void 0)S.controlId=`${U}-expression`;if(p!==void 0)S.labelledBy=p;return K?.(S)}let T={disabled:_,onChange:(S)=>{R((m)=>({...m,fixed:S})),J({mode:"fixed",value:S})},value:L.fixed};if(z)T.describedBy=V;if(U!==void 0)T.controlId=U;if(p!==void 0)T.labelledBy=p;return B(T)})(),W.map((T)=>E(q5,{variant:"destructive",children:E(B5,{children:T.message})},`${T.code}:${T.message}`))]})};var a$=A(()=>{P$();G0();F5=[]});var t$=A(()=>{a$()});var e$;var V0=A(()=>{e$={inputBindingsDescription:"Map workflow input field names to literal or dynamic expressions.",inputBindingsTitle:"Input adapter bindings"}});var Q$=function($){return I($)?$:{}},$1=function($){return Q$($)},R5=function($,U,W){let X=$.anyOf;if(!Array.isArray(X))return;let Y=X.filter((_)=>Q$(_).type!=="null");if(Y.length!==1||Y.length===X.length)return;let z=$1(W(Y[0],U)),{type:G}=z,J={...z,...Object.fromEntries(Object.entries($).filter(([_])=>_!=="anyOf"&&_!=="$defs"))};if(Q(G))J.type=[G,"null"];return J},D5=function($){let U=Q$($.$defs),W=(X,Y=new Set)=>{if(Array.isArray(X))return X.map((K)=>W(K,Y));if(!I(X))return X;let z=Q$(X),G=z.$ref,J=Q(G)?G:void 0;if(J!==void 0&&J.startsWith("#/$defs/")){let K=J.slice(8),B=U[K];if(B!==void 0&&!Y.has(K))return W(B,new Set(Y).add(K))}let _=R5(z,Y,W);if(_)return _;return Object.fromEntries(Object.entries(z).filter(([K])=>K!=="$defs").map(([K,B])=>[K,W(B,Y)]))};return $1(W($))},T5=function($){let{type:U}=$;return U==="null"||Array.isArray(U)&&U.includes("null")},P5=function($){let{type:U}=$;if(Q(U))return U==="null"?$:{...$,type:[U,"null"]};if(Array.isArray(U))return U.includes("null")?$:{...$,type:[...U,"null"]};return $},C5=function Z($,U=[],W=!1){return Object.entries(Q$($.properties)).map(([X,Y])=>{let z=$1(Y),G=W?P5(z):z,J=[...U,X],_=Z(z,J,W||T5(z)),K={availability:"guaranteed",id:`trigger:${J.join(".")}`,label:X,path:J,schema:G,sourceId:"trigger"};return _.length?{...K,children:_,conditional:!1,selectors:[]}:K})},Q0=function($){let{triggerInput:U}=$;if(!U)return;let W=D5(U.schema);return{compatibility:[],language:U.languageManifest,sources:[{availability:"guaranteed",children:C5(W),conditional:!1,id:"trigger",label:"Trigger data",path:[],schema:W,selectors:[],sourceId:"trigger"}]}};var w0=()=>{};import{Input as E5,Label as O5}from"@collective-intelligence/ui-react/ui";import{jsx as H$,jsxs as H0}from"react/jsx-runtime";var I5=(Z)=>{if(Z===null||Z===void 0||Q(Z)||k(Z)||Y$(Z))return String(Z??"");return JSON.stringify(Z)??""},w$=function($){return I($)?$:{}},S5=function($,U){return $?.length===U.length&&$.every((W,X)=>W===U[X])},k5=function($,U){if(U==="number"||U==="integer"){let W=Number($);return Number.isFinite(W)?W:$}if(U==="boolean")return $==="true";return $},b5=function($){if(!I($))return{mode:"fixed",value:$??null};if($.mode==="expression"&&Q($.source))return{languageVersion:1,mode:"expression",source:$.source};if($.mode==="fixed"&&b($.value))return{mode:"fixed",value:$.value};return{mode:"fixed",value:$}},q0=({context:Z})=>{let $=w$(Z.workflowContracts?.inputContract.jsonSchema.properties),U=Z.trigger?.inputBindings??{},W=Q0(Z.template.contract);return H0("div",{className:"space-y-5",children:[H$(u,{context:Z}),H0("section",{className:"space-y-2 rounded-xl border border-border p-4",children:[H$(O5,{htmlFor:"workflow-trigger-input-bindings",children:e$.inputBindingsTitle}),H$("p",{className:"text-xs text-muted-foreground",children:e$.inputBindingsDescription}),Object.entries($).map(([X,Y])=>{let z=w$(U[X]),G=b5(z?.value),J=Z.triggerInputExpressionValidator?.(X),_=W===void 0?void 0:{environment:W,targetSchema:w$(Y)};if(_!==void 0&&J!==void 0)_.validate=J;return H$(V$,{allowExpression:!0,..._===void 0?{}:{expressionEditor:_},diagnostics:Z.diagnostics.filter((K)=>S5(K.path,["inputBindings",X])),label:`${X} (${l(w$(Y))})`,readOnly:Z.readOnly,value:G,onValueChange:(K)=>Z.commands.updateTriggerConfiguration?.({inputBindings:{...U,[X]:{overridePolicy:"locked",value:K}}}),renderFixed:({value:K,onChange:B})=>H$(E5,{value:I5(K),onChange:(N)=>{B(k5(N.target.value,w$(Y)?.type))}})},X)})]})]})};var B0=A(()=>{P$();t$();N$();V0();w0()});var P0={};p0(P0,{renderDefaultTriggerDetails:()=>F0,renderDefaultTriggerChart:()=>N0,renderDefaultOutputDetails:()=>T0,renderDefaultOutputChart:()=>D0,renderDefaultInputDetails:()=>R0,renderDefaultInputChart:()=>L0,renderDefaultActionDetails:()=>A0,renderDefaultActionChart:()=>M0});import{jsx as v}from"react/jsx-runtime";var M0=(Z)=>v($$,{context:Z,accent:"slate"}),A0=(Z)=>v(u,{context:Z}),N0=(Z)=>v($$,{context:Z,accent:"violet"}),F0=(Z)=>v(q0,{context:Z}),L0=(Z)=>v($$,{context:Z,accent:"sky"}),R0=(Z)=>v(u,{context:Z}),D0=(Z)=>v($$,{context:Z,accent:"emerald"}),T0=(Z)=>v(u,{context:Z});var Z1=A(()=>{g$();N$();B0()});import{declareFrontendComponent as j5}from"@collective-intelligence/extensions-sdk-frontend";var U1=(Z)=>({exportName:Z,load:()=>Promise.resolve().then(() => (Z1(),P0)),module:import.meta.url}),E$=(Z,$,U)=>j5({implementation:{chart:U1($),details:U1(U),render:U1(U)},metadata:{kind:Z,mode:"default"},target:{fqn:`builtin.core.workflows.nodes.${Z.replace(/_node$/u,"")}`,packageFqn:"builtin.core",role:"workflow_template_default",version:"1.0.0"}}),W1;var X1=A(()=>{W1=[E$("action_node","renderDefaultActionChart","renderDefaultActionDetails"),E$("trigger_node","renderDefaultTriggerChart","renderDefaultTriggerDetails"),E$("input_node","renderDefaultInputChart","renderDefaultInputDetails"),E$("output_node","renderDefaultOutputChart","renderDefaultOutputDetails")]});import{WorkflowTemplateKinds as f5}from"@collective-intelligence/extensions-sdk";var q$=(Z)=>f5.find(($)=>$===Z);var Y1=()=>{};import{createFrontendCatalog as y5,declareFrontendPackage as h5}from"@collective-intelligence/extensions-sdk-frontend";var J1,O$,_1=(Z)=>{let{declaration:{metadata:$}}=Z;if(!I($))return{};let U=Q($.kind)?q$($.kind):void 0,W;if(Q($.mode)){if($.mode==="default")W="default";else if($.mode==="override")W="override"}let X={};if(Q($.fqn))X.fqn=$.fqn;if(Y$($.handlesDiagnostics))X.handlesDiagnostics=$.handlesDiagnostics;if(U!==void 0)X.kind=U;if(W!==void 0)X.mode=W;if(Q($.widget))X.widget=$.widget;return X},I$=(Z)=>{let $=Z?.trim().toLowerCase();return $===void 0||$===""?void 0:$},C0=()=>J1.snapshot().entries,E0=(Z,$,U)=>{let W=I$(Z),X=I$($);if(W===void 0||X===void 0)return;return C0().find((Y)=>Y.target.toLowerCase()===W&&Y.version.toLowerCase()===X&&Y.role===U)},z1=(Z,$,U)=>{let W=I$($);return C0().find((X)=>{let Y=_1(X);return I$(Y[Z])===W&&X.role===U})},O0=(Z)=>{O$=[...O$.filter((W)=>!Z.some((X)=>X.manifest.fqn===W.manifest.fqn)),...Z];let U=J1.activate(O$);if(U.kind==="invalid")throw Error(U.errors.map((W)=>W.message).join("; "));if(U.kind!=="activated")throw Error(`Workflow catalog activation became stale (${U.reason}).`)},G1,g5=()=>{if(O$.some((Z)=>Z.manifest.fqn===G1.manifest.fqn))return;O0([G1])},m5=()=>J1.snapshot(),J$=(Z)=>{let $=Q(Z)?{widget:Z}:Z,U=$.fqn??void 0,W=$.version??void 0,X=E0(U,W,"workflow_field");if(X!==void 0)return{entry:X,kind:"resolved",source:"exact"};if(U!==void 0&&W!==void 0){let G=z1("widget",$.widget??"","workflow_field_fallback");if(G!==void 0&&U.toLowerCase().startsWith("builtin."))return{entry:G,kind:"resolved",source:"fallback"};let J={fqn:U,kind:"unavailable"};if($.widget!==void 0)J.widget=$.widget;return J}let Y=z1("widget",$.widget??"","workflow_field_fallback");if(Y!==void 0)return{entry:Y,kind:"resolved",source:"fallback"};let z={kind:"unavailable"};if($.fqn!==void 0&&$.fqn!==null)z.fqn=$.fqn;if($.widget!==void 0)z.widget=$.widget;return z},K1=(Z)=>{let $=q$(Z.kind);if($===void 0)return{fqn:Z.fqn,kind:"unavailable",templateKind:Z.kind};let U=E0(Z.fqn,Z.version??"1.0.0","workflow_template_override");if(U!==void 0&&_1(U).kind===$)return{entry:U,kind:"resolved",source:"override"};let W=z1("kind",$,"workflow_template_default");if(W!==void 0)return{entry:W,kind:"resolved",source:"default"};return{fqn:Z.fqn,kind:"unavailable",templateKind:Z.kind}},v1;var _$=A(()=>{X1();Y1();Y1();J1=y5(),O$=[],G1=h5({components:W1,manifest:{fqn:"builtin.core",name:"Dashboard Workflow UI",version:"1.0.0"}}),v1=_1});_$();A$();_$();v$();import{jsx as I0}from"react/jsx-runtime";var v5=({context:Z})=>{let $=J$(Z.field);if($.kind==="resolved"&&$.entry.declaration.implementation.configuration!==void 0)return I0(Z$,{componentProps:Z,declaration:$.entry.declaration,implementationRole:"configuration",load:()=>U$($.entry.declaration,"configuration")});return I0("div",{className:"rounded-md border border-dashed border-border p-2 text-xs text-muted-foreground",children:d.unavailableConfiguration(Z.field.label)})};u$();D$();t$();a$();import{Textarea as x5}from"@collective-intelligence/ui-react/ui";import{jsx as S0}from"react/jsx-runtime";import{createElement as d5}from"react";var j8=({help:Z,label:$,onValueChange:U,expressionEditor:W,readOnly:X,renderFixed:Y,resetKey:z,slotId:G,value:J})=>S0("div",{"data-expression-slot":G,children:d5(V$,{allowExpression:!0,...Z===void 0?{}:{help:Z},...W===void 0?{}:{expressionEditor:W},key:`${G}:${z??"current"}`,label:$,onValueChange:U,...X===void 0?{}:{readOnly:X},renderExpression:({describedBy:_,disabled:K,onChange:B,value:N})=>S0(x5,{"aria-describedby":_,"aria-label":`${$} expression`,disabled:K,onChange:(w)=>{B(w.target.value)},placeholder:"{{ input.value }}",value:N}),renderFixed:Y,value:J})}),p5=function($){if(!I($))return!1;if($.mode==="fixed")return b($.value);return $.mode==="expression"&&k($.languageVersion)&&$.languageVersion===1&&Q($.source)},f8=function($){if(p5($))return $;return{mode:"fixed",value:$}};var V1=function($,U){let W=[...$];for(let X=0;X<W.length;X+=1)for(let Y=X+1;Y<W.length;Y+=1){let z=W[X],G=W[Y];if(z!==void 0&&G!==void 0&&U(z,G)>0)W[X]=G,W[Y]=z}return W};var b0=function($){return D($)&&!Array.isArray($)},u5=function Z($){return $.flatMap((U)=>[...U.templates??[],...Z(U.children??[])])},Q1=function($){return $.kind==="field_collection"&&"collection"in $.contract},w1=function($){return`${$.fqn}@${$.version}`},k0=function($){return $.kind==="literal"?$.text:$.default},c5=function($){return $.kind==="field"&&"field"in $.contract},r5=function($,U){if(!$.enabled||$.state!=="available")return!1;return U==="input"?$.contract.field.availableForInput!==!1:$.contract.field.availableForOutput!==!1},l5=function($,U){let W=$.find((X)=>Q1(X)&&w1(X.contract.collection)===U);return W&&Q1(W)?W.contract.collection.weight??0:0},S$=function($){return $!==void 0&&b0($)?$:{}},p8=function($,U){let W=u5($?.categories??[]),X=new Map;for(let z of W){if(!Q1(z))continue;X.set(w1(z.contract.collection),k0(z.label))}let Y=new Map;for(let z of W){if(!c5(z)||!r5(z,U))continue;let G=z.contract.field,J=w1({fqn:G.collectionFqn,version:G.collectionVersion}),_=Y.get(J)??{fields:[],key:J,label:X.get(J)??G.collectionFqn,weight:l5(W,J)};_.fields.push({catalogTemplateId:z.id,collectionKey:J,configSchema:S$(G.configSchema),fqn:G.fqn,label:k0(z.label),schema:S$(G.valueSchema),version:G.version}),Y.set(J,_)}return V1([...Y.values()].map((z)=>({...z,fields:V1(z.fields,(G,J)=>G.label.localeCompare(J.label)||G.fqn.localeCompare(J.fqn))})),(z,G)=>z.weight-G.weight||z.label.localeCompare(G.label)||z.key.localeCompare(G.key))},d8=function($){return{key:$.key,label:$.label,options:$.fields.map((U)=>({fqn:U.fqn,label:U.label,searchTerms:[U.fqn],version:U.version}))}},o5=function($){let U=S$($.$defs),W=(X,Y=new Set)=>{if(Array.isArray(X))return X.map((_)=>W(_,Y));if(X===null||!b0(X))return X;let z=X,G=z.$ref,J=Q(G)?G:void 0;if(J!==void 0&&J.startsWith("#/$defs/")){let _=J.slice(8),K=U[_];if(K!==void 0&&K!==null&&!Y.has(_))return W(K,new Set(Y).add(_))}return Object.fromEntries(Object.entries(z).filter(([_])=>_!=="$defs").map(([_,K])=>[_,W(K,Y)]))};return S$(W($))},u8=function($,U){let{title:W,...X}=o5(U.schema),Y={...X};if(Q($.title))Y.title=$.title;return Y};import{useDebouncedCallback as s5}from"@collective-intelligence/ui-react/hooks";import{Check as i5,ChevronsUpDown as n5}from"@collective-intelligence/ui-react/icons";import{Button as a5,Command as t5,CommandGroup as e5,CommandInput as $6,CommandItem as Z6,CommandList as U6,Popover as W6,PopoverContent as X6,PopoverTrigger as Y6}from"@collective-intelligence/ui-react/ui";import{useMemo as z6,useState as H1}from"react";import{jsx as x,jsxs as B$}from"react/jsx-runtime";var G6=250,q1=function($){return`${$.fqn}@${$.version}`},J6=function($,U){let W=U.trim().toLocaleLowerCase();if(!W)return $;return $.flatMap((X)=>{let Y=X.options.filter((z)=>[z.label,z.fqn,...z.searchTerms??[]].join(" ").toLocaleLowerCase().includes(W));return Y.length?[{...X,options:Y}]:[]})},i8=({collections:Z,value:$,onChange:U,ariaLabel:W="Field type"})=>{let[X,Y]=H1(!1),[z,G]=H1(""),[J,_]=H1(""),K=s5(_,G6),B=Z.flatMap((H)=>H.options).find((H)=>q1(H)===$),N=z6(()=>J6(Z,J),[Z,J]),w=N.some((H)=>H.options.length>0);return B$(W6,{modal:!0,open:X,onOpenChange:(H)=>{if(Y(H),!H)K.cancel(),G(""),_("")},children:[x(Y6,{asChild:!0,children:B$(a5,{type:"button",variant:"outline","aria-label":W,"aria-expanded":X,className:"mt-1 w-full justify-between font-normal",children:[x("span",{className:"truncate",children:B?.label??"Select a field type"}),x(n5,{className:"ml-2 size-4 shrink-0 opacity-50"})]})}),x(X6,{align:"start",className:"w-[var(--radix-popover-trigger-width)] p-0",children:B$(t5,{shouldFilter:!1,children:[x($6,{placeholder:"Search field types...",value:z,onValueChange:(H)=>{G(H),K(H)}}),B$(U6,{children:[w?null:x("p",{className:"py-6 text-center text-sm",children:"No field type found."}),N.map((H)=>x(e5,{heading:H.label,children:H.options.map((V)=>{let L=q1(V);return B$(Z6,{value:q1(V),onSelect:()=>{U(V),Y(!1)},children:[x(i5,{className:$===L?"mr-2 size-4 opacity-100":"mr-2 size-4 opacity-0"}),V.label]},L)})},H.key))]})]})})]})};g$();N$();X1();Z1();A$();_$();import{jsx as j0,jsxs as K6}from"react/jsx-runtime";var _6=({context:Z})=>{let $=K1(Z.template);if($.kind==="resolved")return j0(Z$,{componentProps:Z,declaration:$.entry.declaration,implementationRole:"details",load:()=>U$($.entry.declaration,"details")});return K6("div",{className:"rounded-xl border border-dashed border-border p-4 text-sm text-muted-foreground",children:["No dashboard editor is available for template kind"," ",j0("code",{children:$.templateKind}),". The workflow draft has not been changed."]})};var B1=(Z)=>Z!==void 0&&Z!==null&&D(Z)&&!Array.isArray(Z),f0=function($,U){return Object.fromEntries(Object.entries($).filter(([W])=>W!==U))},y0=function($){if($==="input_binding")return"inputs";if($==="setting")return"settings";if($==="metadata")return"metadata";return"config"},W$=function($){return B1($)?$:void 0},M1=function($){let U=W$($);if(U===void 0||!("value"in U))return $;return U.mode==="fixed"||U.kind==="literal"?U.value:$},k$=function($,U){let W=$[y0(U.target)];for(let X of U.path){let Y=W$(M1(W));if(Y===void 0)return;W=Y[X]}return M1(W)},V6=function($,U){return k$($,U.binding)},Q6=function Z($,U,W){let[X,...Y]=U;if(X===void 0)return $??{};let z=$??{};if(!Y.length)return{...z,[X]:W};let G=W$(z[X]),J=W$(M1(G));if(G?.mode==="fixed")return{...z,[X]:{...G,value:Z(J,Y,W)}};return{...z,[X]:Z(J,Y,W)}},A1=function($,U){return[$==="input_binding"?"inputBinding":$,...U].map((W)=>encodeURIComponent(String(W))).join("/")},w6=function($,U,W){let X={...W$($?.fieldDisplayValues)},Y=A1(U.binding.target,U.binding.path);if(W)X[Y]=W;else return{...$,fieldDisplayValues:f0(X,Y)};return{...$,fieldDisplayValues:X}},H6=function($,U,W,X){let Y=y0(U.binding.target),z={[Y]:Q6($[Y],U.binding.path,W)};if(X!==void 0)z.metadata=w6(Y==="metadata"?z.metadata:$.metadata,U,X);return z},h0=function($,U,W){let X=$.metadata?.fieldDisplayValues;if(X===void 0||X===null||!B1(X))return;let Y=X[A1(U.binding.target,W)];if(Y===void 0||Y===null||!B1(Y))return;return Q(Y.label)&&"value"in Y?{label:Y.label,value:Y.value}:void 0},q6=function($,U){return h0($,U,U.binding.path)},B6=function($,U,W){return h0($,U,[...U.binding.path,...W])},M6=function($,U,W,X){let Y={...W$($?.fieldDisplayValues)},z=A1(U,W);if(X)Y[z]=X;else return{...$,fieldDisplayValues:f0(Y,z)};return{...$,fieldDisplayValues:Y}},A6=function($,U,W,X){return{metadata:M6($.metadata,U.binding.target,[...U.binding.path,...W],X)}};var N1=function Z($,U){if(Array.isArray($)||Array.isArray(U))return Array.isArray($)&&Array.isArray(U)&&$.length===U.length&&$.every((W,X)=>Z(W,U[X]));if($!==null&&U!==null&&$!==void 0&&U!==void 0&&D($)&&D(U)){let W=Object.keys($);return W.length===Object.keys(U).length&&W.every((X)=>Z($[X],U[X]))}return $===U},g0=function($){return $!==void 0&&$!==null&&$!==""},N6=function($,U){if(!Array.isArray(U)||$===void 0)return!1;return(Array.isArray($)?$:[$]).some((X)=>U.some((Y)=>N1(X,Y)))},F6=function($,U){return($.visibleWhen??[]).every((W)=>{let X=k$(U,W.binding);switch(W.operator){case"equals":return N1(X,W.value);case"not_equals":return!N1(X,W.value);case"is_set":return g0(X);case"is_not_set":return!g0(X);case"in":return N6(X,W.value);default:return!1}})};var L6=function($){if(!$)return"";return $.kind==="literal"?$.text:$.default};D$();P$();T$();m$();export{r6 as workflowFieldOptionsInfinite,G$ as workflowFieldOptions,m5 as workflowCatalogSnapshot,d8 as toFieldTypeCollection,T6 as toDisplayString,N7 as serializeExpressionDraft,l as schemaLabel,u8 as schemaForWorkflowField,K1 as resolveWorkflowTemplate,J$ as resolveWorkflowField,F0 as renderDefaultTriggerDetails,N0 as renderDefaultTriggerChart,T0 as renderDefaultOutputDetails,D0 as renderDefaultOutputChart,R0 as renderDefaultInputDetails,L0 as renderDefaultInputChart,A0 as renderDefaultActionDetails,M0 as renderDefaultActionChart,V6 as readWorkflowFieldValue,B6 as readWorkflowFieldPartDisplayValue,q6 as readWorkflowFieldDisplayValue,k$ as readWorkflowBindingValue,H6 as patchWorkflowFieldValue,A6 as patchWorkflowFieldPartDisplayValue,q$ as parseWorkflowTemplateKind,c4 as normalizeExpressionValidation,u4 as normalizeExpressionEnvironment,F6 as isWorkflowFieldVisible,D6 as isUndefined,Q as isString,F7 as isSchemaCompatible,I as isRecord,D as isObject,k as isNumber,b as isJsonValue,d0 as isFunction,Y$ as isBoolean,n1 as insertExpressionAtCursor,q1 as fieldTypeIdentity,p8 as fieldCollectionsFromCatalog,o$ as expressionSourceOptions,W1 as defaultWorkflowTemplateDeclarations,G1 as dashboardWorkflowPackage,A7 as createExpressionDraft,c6 as configureWorkflowFieldOptionsProvider,L6 as catalogText,f8 as asExpressionSlotValue,O0 as activateWorkflowCatalog,g5 as activateDashboardWorkflowCatalog,_6 as WorkflowTemplateDetails,d$ as WorkflowFieldResolver,V$ as WorkflowFieldFrame,v5 as WorkflowFieldConfigurationResolver,i8 as FieldTypeSelect,s$ as ExpressionSyntaxReference,j8 as ExpressionSlot,n$ as ExpressionEditor,u as CatalogNodeDetailsEditor,$$ as CatalogNodeChartBlock};
@@ -0,0 +1,39 @@
1
+ import type { CatalogEntry, CatalogSnapshot, FrontendPackageDeclaration } from "@collective-intelligence/extensions-sdk-frontend";
2
+ import type { WorkflowFieldComponentContext, WorkflowFieldConfigurationContext, WorkflowTemplateKind, WorkflowTemplateReference, WorkflowTemplateUiContext } from "./workflow-types";
3
+ export { parseWorkflowTemplateKind } from "./workflow-types";
4
+ export type WorkflowDeclarationMetadata = Readonly<{
5
+ fqn?: string | undefined;
6
+ handlesDiagnostics?: boolean | undefined;
7
+ kind?: WorkflowTemplateKind | undefined;
8
+ mode?: "default" | "override" | undefined;
9
+ widget?: string | undefined;
10
+ }>;
11
+ export type WorkflowCatalogResolution = Readonly<{
12
+ entry: CatalogEntry;
13
+ kind: "resolved";
14
+ source: "default" | "exact" | "fallback" | "override";
15
+ }> | Readonly<{
16
+ fqn?: string | undefined;
17
+ kind: "unavailable";
18
+ templateKind?: string | undefined;
19
+ widget?: string | undefined;
20
+ }>;
21
+ /** Publishes the complete package set used by the Workflow UI host. */
22
+ export declare const activateWorkflowCatalog: (packages: readonly FrontendPackageDeclaration[]) => void;
23
+ export declare const dashboardWorkflowPackage: Readonly<{
24
+ kind: "package";
25
+ manifest: import("@collective-intelligence/extensions-sdk-frontend").FrontendPackageManifest;
26
+ components: readonly import("@collective-intelligence/extensions-sdk-frontend").FrontendComponentDeclaration[];
27
+ }>;
28
+ export declare const activateDashboardWorkflowCatalog: () => void;
29
+ export declare const workflowCatalogSnapshot: () => CatalogSnapshot;
30
+ export declare const resolveWorkflowField: (reference: string | Readonly<{
31
+ fqn?: string | null;
32
+ version?: string | null;
33
+ widget?: string;
34
+ }>) => WorkflowCatalogResolution;
35
+ export declare const resolveWorkflowTemplate: (template: WorkflowTemplateReference) => WorkflowCatalogResolution;
36
+ export declare const workflowDeclarationMetadata: (entry: CatalogEntry) => WorkflowDeclarationMetadata;
37
+ export type WorkflowFieldRenderProps = WorkflowFieldComponentContext;
38
+ export type WorkflowFieldConfigurationRenderProps = WorkflowFieldConfigurationContext;
39
+ export type WorkflowTemplateRenderProps = WorkflowTemplateUiContext;