@lace-cloud/canvas 0.0.1-bootstrap.0 → 0.6.4-next.25705814731

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.
@@ -0,0 +1,1026 @@
1
+ import { CanvasView, Diagnostic, NodeConfig, EdgeConfig, SettingsConfig, RenderError, ViewportIntent, GeneratePhase, RenderNode } from '@lace-cloud/proto';
2
+ export { CanvasView, Diagnostic, EdgeConfig, GeneratePhase, HostToWebview, NodeConfig, NodePin, ProjectionMeta, RenderEdge, RenderError, RenderGroup, RenderInput, RenderNode, RenderOutput, SettingsConfig, ViewportIntent, projectCanvasView } from '@lace-cloud/proto';
3
+ export { Toast } from '@lace-cloud/ui/feedback';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import * as React from 'react';
6
+ import React__default from 'react';
7
+ import { NodeProps, Node } from '@xyflow/react';
8
+ import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
9
+
10
+ /**
11
+ * Per-predicate trace shape that mirrors the Go `policy.ConditionPredicateTrace`.
12
+ * `evaluated` is JSON-stringified on the wire; consumers parse it lazily
13
+ * for display. `cannotEvaluate=true` flags predicates that had no input
14
+ * data to evaluate against — common during canvas authoring-time preview
15
+ * where no real terraform plan exists.
16
+ */
17
+ type PolicyPredicateTrace = {
18
+ predicate: string;
19
+ fired: boolean;
20
+ evaluated: string;
21
+ cannotEvaluate: boolean;
22
+ };
23
+ type PolicyConditionTrace = {
24
+ policyId: string;
25
+ label: string;
26
+ fired: boolean;
27
+ predicates: PolicyPredicateTrace[];
28
+ };
29
+ /**
30
+ * Wire-shape PolicyResolution emitted by the CLI session as a
31
+ * `policyResolution` engine event (debounced ~100ms after each apply,
32
+ * plus once after every Subscribe connect). Mirrors `lace.canvas.PolicyResolution`.
33
+ */
34
+ type PolicyResolution = {
35
+ mode: string;
36
+ runnerLocation: string;
37
+ policyId: string;
38
+ rulesFired: string[];
39
+ reason: string;
40
+ approvalMode: string;
41
+ conditionTrace: PolicyConditionTrace[];
42
+ isAuthoringTimePreview: boolean;
43
+ };
44
+ /**
45
+ * Hypothetical IR delta passed to `previewPolicyResolution`. v1 supports
46
+ * remove-resource only; setAttribute / addResource extend later without
47
+ * breaking the API.
48
+ */
49
+ type PreviewDelta = {
50
+ removeResourceInstanceId?: string;
51
+ };
52
+ /**
53
+ * Engine-emitted events. Both PostMessageEngine and ConnectWebEngine publish
54
+ * these through `onEvent` so UI layers subscribe once regardless of transport.
55
+ */
56
+ type EngineEvent = {
57
+ type: 'stateUpdated';
58
+ view: CanvasView;
59
+ viewportIntent?: ViewportIntent;
60
+ } | {
61
+ type: 'generateProgress';
62
+ phase: GeneratePhase;
63
+ toastDurationMs?: number;
64
+ } | {
65
+ type: 'generateSuccess';
66
+ files?: string[];
67
+ toastDurationMs?: number;
68
+ } | {
69
+ type: 'generateError';
70
+ message: string;
71
+ diagnostics?: Diagnostic[];
72
+ toastDurationMs?: number;
73
+ } | {
74
+ type: 'policyResolution';
75
+ resolution: PolicyResolution;
76
+ };
77
+ type EngineEventListener = (event: EngineEvent) => void;
78
+ type GenerateResult = {
79
+ files_written?: string[];
80
+ files?: Record<string, string>;
81
+ diagnostics: Diagnostic[];
82
+ };
83
+ type GraphSummary = {
84
+ text: string;
85
+ };
86
+ type InputUpdate = {
87
+ name: string;
88
+ mode: 'empty' | 'literal' | 'variable' | 'expression';
89
+ value?: unknown;
90
+ variable?: string;
91
+ expression?: string;
92
+ };
93
+ type VariableDef = {
94
+ name: string;
95
+ type: string;
96
+ required: boolean;
97
+ description?: string;
98
+ default?: unknown;
99
+ };
100
+ type OutputExportDef = {
101
+ name: string;
102
+ source_instance: string;
103
+ source_output: string;
104
+ };
105
+ type OutputDefEntry = {
106
+ name: string;
107
+ type: string;
108
+ description?: string;
109
+ sensitive?: boolean;
110
+ };
111
+ type ModuleAuthor = {
112
+ name: string;
113
+ email?: string;
114
+ };
115
+ type ModuleMetadata = {
116
+ id: string;
117
+ name: string;
118
+ system: 'aws' | 'gcp' | 'azure' | string;
119
+ version: string;
120
+ description?: string;
121
+ categories?: string[];
122
+ authors?: ModuleAuthor[];
123
+ example?: string;
124
+ };
125
+ type ProviderDef = {
126
+ name: string;
127
+ source: string;
128
+ version: string;
129
+ };
130
+ type ProviderConfigDef = {
131
+ name: string;
132
+ alias?: string;
133
+ config: Record<string, unknown>;
134
+ };
135
+ type LocalDef = {
136
+ name: string;
137
+ mode: string;
138
+ value?: unknown;
139
+ variable?: string;
140
+ expression?: string;
141
+ };
142
+ /**
143
+ * IR-level validation error reported by `ApplyAction`. Distinct from
144
+ * `RenderError` (which surfaces view-level editing hints). A failing
145
+ * `ApplyResult` carries one or more of these; consumers surface them
146
+ * as a toast and leave canvas state unchanged.
147
+ */
148
+ type GraphError = {
149
+ moduleKey: string;
150
+ instanceId: string;
151
+ inputName: string;
152
+ message: string;
153
+ };
154
+ /**
155
+ * Result of every mutation method. The CanvasView is NOT returned — it
156
+ * arrives via the `stateUpdated` event after the server publishes the
157
+ * new BundleState. Consumers that need the post-mutation view read it
158
+ * from `engine.getCurrentView()` after awaiting the ApplyResult.
159
+ */
160
+ type ApplyResult = {
161
+ success: boolean;
162
+ errors: GraphError[];
163
+ };
164
+ interface CanvasEngine {
165
+ sessionOpen(filePath: string, workspaceName: string): Promise<CanvasView>;
166
+ sessionSave(): Promise<{
167
+ saved: boolean;
168
+ }>;
169
+ sessionClose(): Promise<{
170
+ status: string;
171
+ }>;
172
+ sessionGenerate(outputDir: string, options: {
173
+ dry_run?: boolean;
174
+ format?: boolean;
175
+ validate?: boolean;
176
+ overwrite?: boolean;
177
+ }): Promise<GenerateResult>;
178
+ /**
179
+ * Returns the currently-projected CanvasView, or null if no session is
180
+ * open. Consumers that need the post-mutation view call this after
181
+ * awaiting a mutation's ApplyResult — the engine has already received
182
+ * the corresponding BundleStateEvent and re-projected by the time the
183
+ * awaited promise resolves.
184
+ */
185
+ getCurrentView(): CanvasView | null;
186
+ connect(source: string, target: string, sourceOutput: string, targetInput: string): Promise<ApplyResult>;
187
+ autoConnect(source: string, target: string): Promise<ApplyResult>;
188
+ disconnect(target: string, inputName: string): Promise<ApplyResult>;
189
+ updateInput(instanceId: string, inputName: string, mode: string, value?: unknown, variable?: string, expression?: string): Promise<ApplyResult>;
190
+ updateAllInputs(instanceId: string, inputs: InputUpdate[]): Promise<ApplyResult>;
191
+ renameInstance(oldId: string, newId: string): Promise<ApplyResult>;
192
+ deleteInstance(instanceId: string): Promise<ApplyResult>;
193
+ copyInstances(instanceIds: string[]): Promise<ApplyResult>;
194
+ syncLayout(positions: Record<string, {
195
+ x: number;
196
+ y: number;
197
+ }>): Promise<ApplyResult>;
198
+ setVariables(variables: VariableDef[]): Promise<ApplyResult>;
199
+ setExports(outputs: OutputExportDef[], outputDefs: OutputDefEntry[]): Promise<ApplyResult>;
200
+ setTerraform(requiredVersion?: string, requiredProviders?: ProviderDef[]): Promise<ApplyResult>;
201
+ setProviders(providers: ProviderConfigDef[]): Promise<ApplyResult>;
202
+ setLocals(locals: LocalDef[]): Promise<ApplyResult>;
203
+ setDependsOn(instanceId: string, dependsOn: string[]): Promise<ApplyResult>;
204
+ setEnvironments(environments: Record<string, Record<string, unknown>>): Promise<ApplyResult>;
205
+ undo(): Promise<ApplyResult>;
206
+ redo(): Promise<ApplyResult>;
207
+ createGroup(label: string, nodeIds: string[]): Promise<ApplyResult>;
208
+ updateGroup(groupId: string, updates: {
209
+ label?: string;
210
+ node_ids?: string[];
211
+ collapsed?: boolean;
212
+ }): Promise<ApplyResult>;
213
+ deleteGroup(groupId: string): Promise<ApplyResult>;
214
+ queryNodeConfig(instanceId: string): Promise<NodeConfig>;
215
+ queryEdgeConfig(source: string, target: string): Promise<EdgeConfig>;
216
+ querySettings(): Promise<SettingsConfig>;
217
+ queryGraphSummary(): Promise<GraphSummary>;
218
+ queryValidate(): Promise<{
219
+ errors: RenderError[];
220
+ }>;
221
+ /**
222
+ * Read the composition's `module.yaml` (sibling of `.lace/` at the
223
+ * composition's directory root). Returns `present: false` when the
224
+ * file doesn't exist yet — the panel renders the metadata form blank
225
+ * for the user to fill in.
226
+ */
227
+ getModuleMetadata(): Promise<{
228
+ metadata: ModuleMetadata | null;
229
+ present: boolean;
230
+ }>;
231
+ /**
232
+ * Write the composition's `module.yaml`. Creates the file if missing.
233
+ * Atomic write — concurrent reads see either the previous bytes or the
234
+ * new bytes, never partial.
235
+ */
236
+ setModuleMetadata(metadata: ModuleMetadata): Promise<void>;
237
+ /**
238
+ * Counterfactual policy evaluation: "if I applied this hypothetical
239
+ * delta, what would the resolution be?" Pure read RPC; never mutates
240
+ * session state. Pass an `AbortSignal` to cancel an in-flight
241
+ * request when a newer hover supersedes it. Snapshot engines that do
242
+ * not support live policy evaluation may return a default
243
+ * auto_apply resolution.
244
+ */
245
+ previewPolicyResolution(delta: PreviewDelta, signal?: AbortSignal): Promise<PolicyResolution>;
246
+ /**
247
+ * Subscribe to engine events. Returns an unsubscribe function. Called from
248
+ * App (for state updates) and useGenerationStatus (for generate progress).
249
+ */
250
+ onEvent(listener: EngineEventListener): () => void;
251
+ }
252
+
253
+ /**
254
+ * HostBridge is the narrow, typed surface for outbound signals to whatever is
255
+ * hosting the canvas. In VS Code mode this wraps `acquireVsCodeApi()`; in
256
+ * Storybook flow mode the decorator supplies a bridge that routes signals to
257
+ * the engine directly (e.g. triggerGenerate → engine.sessionGenerate).
258
+ */
259
+ type HostBridge = {
260
+ signalReady(): void;
261
+ markDirty(): void;
262
+ markClean(): void;
263
+ triggerGenerate(): void;
264
+ openFile(relativePath: string, line?: number, column?: number): void;
265
+ };
266
+ type AppProps = {
267
+ engine: CanvasEngine;
268
+ hostBridge: HostBridge;
269
+ /**
270
+ * When true, the canvas renders in read-only mode: pan/zoom/drag/inspect
271
+ * still work, but every IR-mutating affordance (save, delete, rename,
272
+ * wire, generate) is hidden or blocked. Defaults to `false`.
273
+ */
274
+ readOnly?: boolean;
275
+ };
276
+ declare function App({ engine, hostBridge, readOnly }: AppProps): react_jsx_runtime.JSX.Element;
277
+
278
+ type Props$9 = {
279
+ title: string;
280
+ defaultOpen?: boolean;
281
+ badge?: string;
282
+ children: React__default.ReactNode;
283
+ };
284
+ declare function AccordionSection({ title, defaultOpen, badge, children }: Props$9): react_jsx_runtime.JSX.Element;
285
+
286
+ type ActionBarProps = {
287
+ /**
288
+ * When true, only the MiniMap toggle + Settings gear render. Save,
289
+ * Clear, Undo, Redo, and Generate are IR-mutating and hidden; the
290
+ * Settings gear is kept because the settings panel has its own
291
+ * read-only flow for inspection. Defaults to `false`.
292
+ */
293
+ readOnly?: boolean;
294
+ isGenerating?: boolean;
295
+ onSave: () => void;
296
+ onUndo: () => void;
297
+ onRedo: () => void;
298
+ onClearGraph: () => void;
299
+ onGenerate: () => void;
300
+ onOpenSettings: () => void;
301
+ /**
302
+ * When provided, the policy shield button renders alongside the
303
+ * settings gear. Snapshot canvases pass undefined to suppress the
304
+ * button (no live policy session in read-only mode).
305
+ */
306
+ onOpenPolicy?: () => void;
307
+ showMiniMap: boolean;
308
+ onToggleMiniMap: () => void;
309
+ };
310
+ declare function ActionBar({ readOnly, isGenerating, onSave, onUndo, onRedo, onClearGraph, onGenerate, onOpenSettings, onOpenPolicy, showMiniMap, onToggleMiniMap, }: ActionBarProps): react_jsx_runtime.JSX.Element;
311
+
312
+ type ContextMenuState = {
313
+ x: number;
314
+ y: number;
315
+ nodeId: string | null;
316
+ groupId: string | null;
317
+ selectedCount: number;
318
+ } | null;
319
+
320
+ type Props$8 = {
321
+ contextMenu: ContextMenuState;
322
+ onCopy: () => void;
323
+ onCut: () => void;
324
+ onPaste: () => void;
325
+ onGroupSelected: () => void;
326
+ onUngroup: (groupId: string) => void;
327
+ onDismiss: () => void;
328
+ };
329
+ declare function ContextMenu({ contextMenu, onCopy, onCut, onPaste, onGroupSelected, onUngroup, onDismiss, }: Props$8): react_jsx_runtime.JSX.Element | null;
330
+
331
+ type ErrorStateProps = {
332
+ message: string;
333
+ };
334
+ declare function ErrorState({ message }: ErrorStateProps): react_jsx_runtime.JSX.Element;
335
+ declare class ErrorBoundary extends React__default.Component<{
336
+ children: React__default.ReactNode;
337
+ }, {
338
+ error: Error | null;
339
+ }> {
340
+ state: {
341
+ error: Error | null;
342
+ };
343
+ static getDerivedStateFromError(error: Error): {
344
+ error: Error;
345
+ };
346
+ render(): string | number | boolean | Iterable<React__default.ReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
347
+ }
348
+
349
+ type ExternalPin = {
350
+ handleId: string;
351
+ label: string;
352
+ side: 'input' | 'output';
353
+ color: {
354
+ fill: string;
355
+ stroke: string;
356
+ };
357
+ };
358
+ type GroupNodeData = {
359
+ groupId: string;
360
+ label: string;
361
+ memberCount: number;
362
+ collapsed: boolean;
363
+ hasErrors: boolean;
364
+ externalPins: ExternalPin[];
365
+ };
366
+ type GroupNodeNode = Node<GroupNodeData, 'groupNode'>;
367
+ declare const GroupNode: React__default.FC<NodeProps<GroupNodeNode>>;
368
+
369
+ type ModuleNodeData = RenderNode & {
370
+ hasValidationError?: boolean;
371
+ isNew?: boolean;
372
+ };
373
+ type ModuleNodeNode = Node<ModuleNodeData, 'moduleNode'>;
374
+ declare const ModuleNode: React__default.FC<NodeProps<ModuleNodeNode>>;
375
+
376
+ type Props$7 = {
377
+ source: string;
378
+ target: string;
379
+ sourceOutput: string;
380
+ targetInput: string;
381
+ onDelete: () => void;
382
+ onClose: () => void;
383
+ };
384
+ declare function EdgeInspectorPanel({ source, target, sourceOutput, targetInput, onDelete, onClose, }: Props$7): react_jsx_runtime.JSX.Element;
385
+
386
+ type ContentProps$3 = {
387
+ environments: Record<string, Record<string, unknown>> | undefined;
388
+ readOnly?: boolean;
389
+ onSave: (environments: Record<string, Record<string, unknown>>) => void | Promise<void>;
390
+ };
391
+ declare function EnvironmentsContent({ environments, readOnly, onSave }: ContentProps$3): react_jsx_runtime.JSX.Element;
392
+ type Props$6 = {
393
+ environments: Record<string, Record<string, unknown>> | undefined;
394
+ onSave: (environments: Record<string, Record<string, unknown>>) => void | Promise<void>;
395
+ onClose: () => void;
396
+ };
397
+ declare function EnvironmentsPanel({ environments, onSave, onClose }: Props$6): react_jsx_runtime.JSX.Element;
398
+
399
+ type LocalEntry = SettingsConfig['locals'][number];
400
+ type ContentProps$2 = {
401
+ locals: LocalEntry[] | undefined;
402
+ readOnly?: boolean;
403
+ onSave: (locals: LocalEntry[]) => void | Promise<void>;
404
+ };
405
+ declare function LocalsContent({ locals, readOnly, onSave }: ContentProps$2): react_jsx_runtime.JSX.Element;
406
+ type Props$5 = {
407
+ locals: LocalEntry[] | undefined;
408
+ onSave: (locals: LocalEntry[]) => void | Promise<void>;
409
+ onClose: () => void;
410
+ };
411
+ declare function LocalsPanel({ locals, onSave, onClose }: Props$5): react_jsx_runtime.JSX.Element;
412
+
413
+ type Props$4 = {
414
+ instance_id: string;
415
+ engine: CanvasEngine;
416
+ onClose: () => void;
417
+ onModified?: (instanceId: string) => void;
418
+ };
419
+ declare function ModuleConfigPanel({ instance_id, engine, onClose, onModified }: Props$4): react_jsx_runtime.JSX.Element;
420
+
421
+ type Props$3 = {
422
+ /**
423
+ * The current authoritative resolution emitted by the live session,
424
+ * or null when no resolution has arrived yet (initial connect, or
425
+ * non-extension canvases that never emit). The component renders a
426
+ * placeholder for null rather than hiding so the sidebar's presence
427
+ * is stable.
428
+ */
429
+ resolution: PolicyResolution | null;
430
+ /**
431
+ * Counterfactual RPC. Provided in extension canvas only — portal/
432
+ * snapshot canvases pass undefined to suppress the hover affordance.
433
+ */
434
+ onPreview?: (delta: PreviewDelta, signal?: AbortSignal) => Promise<PolicyResolution>;
435
+ onClose: () => void;
436
+ /**
437
+ * When true, the counterfactual hover handler is not installed. The
438
+ * sidebar still renders the resolution so read-only consumers see
439
+ * what the engine reported without being able to interact.
440
+ */
441
+ readOnly?: boolean;
442
+ };
443
+ declare function PolicySidebar({ resolution, onPreview, onClose, readOnly }: Props$3): react_jsx_runtime.JSX.Element;
444
+
445
+ type ProviderEntry = SettingsConfig['providers'][number];
446
+ type ContentProps$1 = {
447
+ providers: ProviderEntry[] | undefined;
448
+ readOnly?: boolean;
449
+ onSave: (providers: ProviderEntry[]) => void | Promise<void>;
450
+ };
451
+ declare function ProvidersContent({ providers, readOnly, onSave }: ContentProps$1): react_jsx_runtime.JSX.Element;
452
+ type Props$2 = {
453
+ providers: ProviderEntry[] | undefined;
454
+ onSave: (providers: ProviderEntry[]) => void | Promise<void>;
455
+ onClose: () => void;
456
+ };
457
+ declare function ProvidersPanel({ providers, onSave, onClose }: Props$2): react_jsx_runtime.JSX.Element;
458
+
459
+ type TerraformConfig = SettingsConfig['terraform'];
460
+ type ContentProps = {
461
+ terraform: TerraformConfig | undefined;
462
+ readOnly?: boolean;
463
+ onSave: (terraform: TerraformConfig) => void | Promise<void>;
464
+ };
465
+ declare function TerraformConfigContent({ terraform, readOnly, onSave }: ContentProps): react_jsx_runtime.JSX.Element;
466
+ type Props$1 = {
467
+ terraform: TerraformConfig | undefined;
468
+ onSave: (terraform: TerraformConfig) => void | Promise<void>;
469
+ onClose: () => void;
470
+ };
471
+ declare function TerraformConfigPanel({ terraform, onSave, onClose }: Props$1): react_jsx_runtime.JSX.Element;
472
+
473
+ type Props = {
474
+ engine: CanvasEngine;
475
+ onClose: () => void;
476
+ onSaved?: () => void;
477
+ };
478
+ declare function UnifiedSettingsPanel({ engine, onClose, onSaved }: Props): react_jsx_runtime.JSX.Element;
479
+
480
+ type SlidePanelProps = {
481
+ open: boolean;
482
+ zIndex?: number;
483
+ children: React__default.ReactNode;
484
+ };
485
+ declare function SlidePanel({ open, zIndex, children }: SlidePanelProps): react_jsx_runtime.JSX.Element | null;
486
+
487
+ type BannerProps = {
488
+ diagnostics: Diagnostic[];
489
+ nodeIds: Set<string>;
490
+ onGoToNode: (nodeId: string) => void;
491
+ onOpenFile: (relativePath: string, line?: number, column?: number) => void;
492
+ onDismiss: () => void;
493
+ };
494
+ declare function ValidationErrorBanner({ diagnostics, nodeIds, onGoToNode, onOpenFile, onDismiss, }: BannerProps): react_jsx_runtime.JSX.Element | null;
495
+
496
+ type ConnectWebEngineOptions = {
497
+ baseUrl: string;
498
+ token: string;
499
+ sessionId?: string;
500
+ /** Fetch impl override — used by tests. Defaults to globalThis.fetch. */
501
+ fetch?: typeof fetch;
502
+ };
503
+ declare class ConnectWebEngine implements CanvasEngine {
504
+ private readonly baseUrl;
505
+ private readonly token;
506
+ private _sessionId;
507
+ private readonly fetchImpl;
508
+ private subscribeAbort;
509
+ private readonly listeners;
510
+ private currentBundle;
511
+ private currentLayouts;
512
+ private currentCanUndo;
513
+ private currentCanRedo;
514
+ private currentIsDirty;
515
+ private currentView;
516
+ private stateUpdateWaiters;
517
+ constructor(options: ConnectWebEngineOptions);
518
+ onEvent(listener: EngineEventListener): () => void;
519
+ private emit;
520
+ get sessionId(): string | null;
521
+ getCurrentView(): CanvasView | null;
522
+ private requireSessionId;
523
+ private unary;
524
+ /** Replace local state from a BundleState snapshot and re-project. */
525
+ private adoptState;
526
+ private reproject;
527
+ private resolveStateWaiters;
528
+ /**
529
+ * Returns a promise that resolves on the next BundleState adoption. The
530
+ * engine awaits this inside `applyAction` so the caller's `await` doesn't
531
+ * return until the Subscribe stream has delivered the post-mutation
532
+ * BundleState and `currentView` reflects it.
533
+ */
534
+ private nextStateUpdate;
535
+ sessionOpen(filePath: string, workspaceName: string): Promise<CanvasView>;
536
+ /**
537
+ * Opens an ephemeral (memory-only) session that is not backed to disk and
538
+ * is evicted after 30 minutes of idle with zero subscribers. Used by
539
+ * Storybook flow stories so each story gets isolated state — backed
540
+ * sessions are keyed by file path and would be shared across stories.
541
+ */
542
+ openEphemeralSession(workspaceName: string): Promise<CanvasView>;
543
+ /**
544
+ * Opens an ephemeral session pre-populated from one of the CLI's embedded
545
+ * seed fixtures. Requires the CLI to be built with `-tags=test` — the
546
+ * release build returns Unimplemented. Used by Storybook flow stories +
547
+ * Playwright golden tests for deterministic canvas state without touching
548
+ * the registry (no network, no version drift, stable across environments).
549
+ */
550
+ testSessionOpen(fixtureName: string, workspaceName?: string): Promise<CanvasView>;
551
+ sessionSave(): Promise<{
552
+ saved: boolean;
553
+ }>;
554
+ sessionClose(): Promise<{
555
+ status: string;
556
+ }>;
557
+ sessionGenerate(outputDir: string, options: {
558
+ dry_run?: boolean;
559
+ format?: boolean;
560
+ validate?: boolean;
561
+ overwrite?: boolean;
562
+ }): Promise<GenerateResult>;
563
+ /**
564
+ * Single action dispatch seam. Every mutation method builds an Action
565
+ * oneof member, sends it through ApplyAction, and awaits the next
566
+ * BundleStateEvent before returning — so the caller's await resolves
567
+ * only after `currentView` reflects the mutation.
568
+ */
569
+ private applyAction;
570
+ connect(source: string, target: string, sourceOutput: string, targetInput: string): Promise<ApplyResult>;
571
+ autoConnect(source: string, target: string): Promise<ApplyResult>;
572
+ disconnect(target: string, inputName: string): Promise<ApplyResult>;
573
+ updateInput(instanceId: string, inputName: string, mode: string, value?: unknown, variable?: string, expression?: string): Promise<ApplyResult>;
574
+ updateAllInputs(instanceId: string, inputs: InputUpdate[]): Promise<ApplyResult>;
575
+ renameInstance(oldId: string, newId: string): Promise<ApplyResult>;
576
+ deleteInstance(instanceId: string): Promise<ApplyResult>;
577
+ copyInstances(instanceIds: string[]): Promise<ApplyResult>;
578
+ syncLayout(positions: Record<string, {
579
+ x: number;
580
+ y: number;
581
+ }>): Promise<ApplyResult>;
582
+ setVariables(variables: VariableDef[]): Promise<ApplyResult>;
583
+ setExports(outputs: OutputExportDef[], outputDefs: OutputDefEntry[]): Promise<ApplyResult>;
584
+ setTerraform(requiredVersion?: string, requiredProviders?: ProviderDef[]): Promise<ApplyResult>;
585
+ setProviders(providers: ProviderConfigDef[]): Promise<ApplyResult>;
586
+ setLocals(locals: LocalDef[]): Promise<ApplyResult>;
587
+ setDependsOn(instanceId: string, dependsOn: string[]): Promise<ApplyResult>;
588
+ setEnvironments(environments: Record<string, Record<string, unknown>>): Promise<ApplyResult>;
589
+ undo(): Promise<ApplyResult>;
590
+ redo(): Promise<ApplyResult>;
591
+ createGroup(label: string, nodeIds: string[]): Promise<ApplyResult>;
592
+ updateGroup(groupId: string, updates: {
593
+ label?: string;
594
+ node_ids?: string[];
595
+ collapsed?: boolean;
596
+ }): Promise<ApplyResult>;
597
+ deleteGroup(groupId: string): Promise<ApplyResult>;
598
+ queryNodeConfig(instanceId: string): Promise<NodeConfig>;
599
+ queryEdgeConfig(source: string, target: string): Promise<EdgeConfig>;
600
+ querySettings(): Promise<SettingsConfig>;
601
+ queryGraphSummary(): Promise<GraphSummary>;
602
+ queryValidate(): Promise<{
603
+ errors: RenderError[];
604
+ }>;
605
+ getModuleMetadata(): Promise<{
606
+ metadata: ModuleMetadata | null;
607
+ present: boolean;
608
+ }>;
609
+ setModuleMetadata(metadata: ModuleMetadata): Promise<void>;
610
+ placeModule(params: {
611
+ name: string;
612
+ system: string;
613
+ version: string;
614
+ organization?: string;
615
+ position?: {
616
+ x: number;
617
+ y: number;
618
+ };
619
+ }): Promise<ApplyResult>;
620
+ /**
621
+ * Starts a Subscribe stream for the active session. BundleStateEvents
622
+ * replace local state + re-project, surfacing via stateUpdated. Returns
623
+ * an unsubscribe function. Safe to call multiple times — a prior stream
624
+ * is aborted before a new one starts.
625
+ */
626
+ startSubscribe(): () => void;
627
+ stopSubscribe(): void;
628
+ private runSubscribe;
629
+ private dispatchSubscribeEvent;
630
+ /**
631
+ * Counterfactual policy evaluation against the active session. The
632
+ * `signal` is honoured by the underlying fetch, so callers that
633
+ * supersede a previous hover with `AbortController.abort()` get a
634
+ * clean cancellation rather than racing rendered responses. A
635
+ * cancelled fetch surfaces as an `AbortError` from the
636
+ * native-fetch path; callers should ignore it.
637
+ */
638
+ previewPolicyResolution(delta: PreviewDelta, signal?: AbortSignal): Promise<PolicyResolution>;
639
+ }
640
+
641
+ type VsCodeApi = {
642
+ postMessage(msg: unknown): void;
643
+ };
644
+ declare class PostMessageEngine implements CanvasEngine {
645
+ private vscode;
646
+ private pending;
647
+ private readonly listeners;
648
+ private readonly messageListener;
649
+ private currentBundle;
650
+ private currentLayouts;
651
+ private currentCanUndo;
652
+ private currentCanRedo;
653
+ private currentIsDirty;
654
+ private currentView;
655
+ private stateUpdateWaiters;
656
+ constructor(vscode: VsCodeApi);
657
+ /** Disposes the message listener. Called when the webview unmounts. */
658
+ dispose(): void;
659
+ onEvent(listener: EngineEventListener): () => void;
660
+ getCurrentView(): CanvasView | null;
661
+ private emit;
662
+ private adoptState;
663
+ private nextStateUpdate;
664
+ private resolvePending;
665
+ private call;
666
+ private applyAction;
667
+ sessionOpen(filePath: string, workspaceName: string): Promise<CanvasView>;
668
+ sessionSave(): Promise<{
669
+ saved: boolean;
670
+ }>;
671
+ sessionClose(): Promise<{
672
+ status: string;
673
+ }>;
674
+ sessionGenerate(outputDir: string, options: {
675
+ dry_run?: boolean;
676
+ format?: boolean;
677
+ validate?: boolean;
678
+ overwrite?: boolean;
679
+ }): Promise<GenerateResult>;
680
+ connect(source: string, target: string, sourceOutput: string, targetInput: string): Promise<ApplyResult>;
681
+ autoConnect(source: string, target: string): Promise<ApplyResult>;
682
+ disconnect(target: string, inputName: string): Promise<ApplyResult>;
683
+ updateInput(instanceId: string, inputName: string, mode: string, value?: unknown, variable?: string, expression?: string): Promise<ApplyResult>;
684
+ updateAllInputs(instanceId: string, inputs: InputUpdate[]): Promise<ApplyResult>;
685
+ renameInstance(oldId: string, newId: string): Promise<ApplyResult>;
686
+ deleteInstance(instanceId: string): Promise<ApplyResult>;
687
+ copyInstances(instanceIds: string[]): Promise<ApplyResult>;
688
+ syncLayout(positions: Record<string, {
689
+ x: number;
690
+ y: number;
691
+ }>): Promise<ApplyResult>;
692
+ setVariables(variables: VariableDef[]): Promise<ApplyResult>;
693
+ setExports(outputs: OutputExportDef[], outputDefs: OutputDefEntry[]): Promise<ApplyResult>;
694
+ setTerraform(requiredVersion?: string, requiredProviders?: ProviderDef[]): Promise<ApplyResult>;
695
+ setProviders(providers: ProviderConfigDef[]): Promise<ApplyResult>;
696
+ setLocals(locals: LocalDef[]): Promise<ApplyResult>;
697
+ setDependsOn(instanceId: string, dependsOn: string[]): Promise<ApplyResult>;
698
+ setEnvironments(environments: Record<string, Record<string, unknown>>): Promise<ApplyResult>;
699
+ undo(): Promise<ApplyResult>;
700
+ redo(): Promise<ApplyResult>;
701
+ createGroup(label: string, nodeIds: string[]): Promise<ApplyResult>;
702
+ updateGroup(groupId: string, updates: {
703
+ label?: string;
704
+ node_ids?: string[];
705
+ collapsed?: boolean;
706
+ }): Promise<ApplyResult>;
707
+ deleteGroup(groupId: string): Promise<ApplyResult>;
708
+ queryNodeConfig(instanceId: string): Promise<NodeConfig>;
709
+ queryEdgeConfig(source: string, target: string): Promise<EdgeConfig>;
710
+ querySettings(): Promise<SettingsConfig>;
711
+ queryGraphSummary(): Promise<GraphSummary>;
712
+ queryValidate(): Promise<{
713
+ errors: RenderError[];
714
+ }>;
715
+ getModuleMetadata(): Promise<{
716
+ metadata: ModuleMetadata | null;
717
+ present: boolean;
718
+ }>;
719
+ setModuleMetadata(metadata: ModuleMetadata): Promise<void>;
720
+ /**
721
+ * Counterfactual policy evaluation through the host bridge. The host
722
+ * forwards to the CLI's `PreviewPolicyResolution` RPC and returns the
723
+ * raw wire-shape PolicyResolution as the call result. AbortSignal
724
+ * cancellation rejects the promise without affecting the in-flight
725
+ * RPC — the host's response is discarded when it eventually arrives,
726
+ * since the pending entry has been removed.
727
+ */
728
+ previewPolicyResolution(delta: PreviewDelta, signal?: AbortSignal): Promise<PolicyResolution>;
729
+ }
730
+
731
+ interface Bundle {
732
+ schema_version: string;
733
+ kind: string;
734
+ entry: string;
735
+ modules: {
736
+ [key: string]: Module;
737
+ };
738
+ environments: {
739
+ [key: string]: {
740
+ [key: string]: any;
741
+ } | undefined;
742
+ };
743
+ environment_backends: {
744
+ [key: string]: BackendConfig;
745
+ };
746
+ }
747
+ declare const Bundle: MessageFns<Bundle>;
748
+ interface Module {
749
+ id: string;
750
+ version: string;
751
+ source: Source | undefined;
752
+ interface: Interface | undefined;
753
+ modules: Use[];
754
+ resources: Resource[];
755
+ locals: Local[];
756
+ exports: Exports | undefined;
757
+ terraform: TerraformBlock | undefined;
758
+ providers: ProviderConfig[];
759
+ }
760
+ declare const Module: MessageFns<Module>;
761
+ interface Interface {
762
+ inputs: InputDef[];
763
+ outputs: OutputDef[];
764
+ }
765
+ declare const Interface: MessageFns<Interface>;
766
+ interface InputDef {
767
+ name: string;
768
+ type: string;
769
+ required: boolean;
770
+ description: string;
771
+ default_value: any | undefined;
772
+ validation: ValidationBlock | undefined;
773
+ }
774
+ declare const InputDef: MessageFns<InputDef>;
775
+ interface ValidationBlock {
776
+ condition: string;
777
+ error_message: string;
778
+ }
779
+ declare const ValidationBlock: MessageFns<ValidationBlock>;
780
+ interface OutputDef {
781
+ name: string;
782
+ type: string;
783
+ description: string;
784
+ sensitive: boolean;
785
+ }
786
+ declare const OutputDef: MessageFns<OutputDef>;
787
+ interface Source {
788
+ kind: string;
789
+ repo: string;
790
+ subdir: string;
791
+ ref: string;
792
+ organization: string;
793
+ }
794
+ declare const Source: MessageFns<Source>;
795
+ interface Local {
796
+ name: string;
797
+ value: Binding | undefined;
798
+ }
799
+ declare const Local: MessageFns<Local>;
800
+ interface Use {
801
+ id: string;
802
+ module: string;
803
+ inputs: {
804
+ [key: string]: Binding;
805
+ };
806
+ depends_on: string[];
807
+ }
808
+ declare const Use: MessageFns<Use>;
809
+ interface Resource {
810
+ id: string;
811
+ kind: string;
812
+ type: string;
813
+ inputs: {
814
+ [key: string]: Binding;
815
+ };
816
+ depends_on: string[];
817
+ }
818
+ declare const Resource: MessageFns<Resource>;
819
+ interface Exports {
820
+ outputs: {
821
+ [key: string]: OutputExport;
822
+ };
823
+ }
824
+ declare const Exports: MessageFns<Exports>;
825
+ interface OutputExport {
826
+ out: OutputRef | undefined;
827
+ lit: any | undefined;
828
+ var: string;
829
+ expr: Expression | undefined;
830
+ }
831
+ declare const OutputExport: MessageFns<OutputExport>;
832
+ interface Binding {
833
+ lit?: any | undefined;
834
+ var?: string | undefined;
835
+ out?: OutputRef | undefined;
836
+ expr?: Expression | undefined;
837
+ }
838
+ declare const Binding: MessageFns<Binding>;
839
+ interface OutputRef {
840
+ module: string;
841
+ name: string;
842
+ }
843
+ declare const OutputRef: MessageFns<OutputRef>;
844
+ interface Expression {
845
+ lang: string;
846
+ value: string;
847
+ }
848
+ declare const Expression: MessageFns<Expression>;
849
+ interface TerraformBlock {
850
+ required_version: string;
851
+ required_providers: {
852
+ [key: string]: ProviderRequirement;
853
+ };
854
+ backend: BackendConfig | undefined;
855
+ }
856
+ declare const TerraformBlock: MessageFns<TerraformBlock>;
857
+ interface ProviderRequirement {
858
+ source: string;
859
+ version: string;
860
+ }
861
+ declare const ProviderRequirement: MessageFns<ProviderRequirement>;
862
+ interface BackendConfig {
863
+ type: string;
864
+ config: {
865
+ [key: string]: any | undefined;
866
+ };
867
+ }
868
+ declare const BackendConfig: MessageFns<BackendConfig>;
869
+ interface ProviderConfig {
870
+ name: string;
871
+ alias: string;
872
+ config: {
873
+ [key: string]: any | undefined;
874
+ };
875
+ }
876
+ declare const ProviderConfig: MessageFns<ProviderConfig>;
877
+ interface GraphLayout {
878
+ nodes: {
879
+ [key: string]: NodeLayout;
880
+ };
881
+ groups: {
882
+ [key: string]: NodeGroup;
883
+ };
884
+ }
885
+ declare const GraphLayout: MessageFns<GraphLayout>;
886
+ interface NodeGroup {
887
+ id: string;
888
+ label: string;
889
+ node_ids: string[];
890
+ collapsed: boolean;
891
+ }
892
+ declare const NodeGroup: MessageFns<NodeGroup>;
893
+ interface NodeLayout {
894
+ position: Position | undefined;
895
+ }
896
+ declare const NodeLayout: MessageFns<NodeLayout>;
897
+ interface Position {
898
+ x: number;
899
+ y: number;
900
+ }
901
+ declare const Position: MessageFns<Position>;
902
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
903
+ type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
904
+ [K in keyof T]?: DeepPartial<T[K]>;
905
+ } : Partial<T>;
906
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
907
+ type Exact<P, I extends P> = P extends Builtin ? P : P & {
908
+ [K in keyof P]: Exact<P[K], I[K]>;
909
+ } & {
910
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
911
+ };
912
+ interface MessageFns<T> {
913
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
914
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
915
+ fromJSON(object: any): T;
916
+ toJSON(message: T): unknown;
917
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
918
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
919
+ }
920
+
921
+ type SnapshotMeta = {
922
+ moduleName?: string;
923
+ canUndo?: boolean;
924
+ canRedo?: boolean;
925
+ isDirty?: boolean;
926
+ };
927
+ type SnapshotInProcess = {
928
+ bundle: Bundle;
929
+ layouts?: {
930
+ [key: string]: GraphLayout;
931
+ };
932
+ meta?: SnapshotMeta;
933
+ };
934
+ type SnapshotUrls = {
935
+ bundleUrl: string;
936
+ layoutsUrl: string;
937
+ fetch?: typeof fetch;
938
+ meta?: SnapshotMeta;
939
+ };
940
+ type SnapshotCanvasEngineInput = SnapshotInProcess | SnapshotUrls;
941
+ declare class SnapshotCanvasEngine implements CanvasEngine {
942
+ private readonly input;
943
+ private readonly fetchImpl;
944
+ private loadPromise;
945
+ private view;
946
+ constructor(input: SnapshotCanvasEngineInput);
947
+ private projectInput;
948
+ private loadView;
949
+ private fetchBytes;
950
+ getCurrentView(): CanvasView | null;
951
+ sessionOpen(): Promise<CanvasView>;
952
+ sessionSave(): Promise<{
953
+ saved: boolean;
954
+ }>;
955
+ sessionClose(): Promise<{
956
+ status: string;
957
+ }>;
958
+ sessionGenerate(_outputDir: string, _options: {
959
+ dry_run?: boolean;
960
+ format?: boolean;
961
+ validate?: boolean;
962
+ overwrite?: boolean;
963
+ }): Promise<GenerateResult>;
964
+ connect(_source: string, _target: string, _sourceOutput: string, _targetInput: string): Promise<ApplyResult>;
965
+ autoConnect(_source: string, _target: string): Promise<ApplyResult>;
966
+ disconnect(_target: string, _inputName: string): Promise<ApplyResult>;
967
+ updateInput(_instanceId: string, _inputName: string, _mode: string, _value?: unknown, _variable?: string, _expression?: string): Promise<ApplyResult>;
968
+ updateAllInputs(_instanceId: string, _inputs: InputUpdate[]): Promise<ApplyResult>;
969
+ renameInstance(_oldId: string, _newId: string): Promise<ApplyResult>;
970
+ deleteInstance(_instanceId: string): Promise<ApplyResult>;
971
+ copyInstances(_instanceIds: string[]): Promise<ApplyResult>;
972
+ syncLayout(_positions: Record<string, {
973
+ x: number;
974
+ y: number;
975
+ }>): Promise<ApplyResult>;
976
+ setVariables(_variables: VariableDef[]): Promise<ApplyResult>;
977
+ setExports(_outputs: OutputExportDef[], _outputDefs: OutputDefEntry[]): Promise<ApplyResult>;
978
+ setTerraform(_requiredVersion?: string, _requiredProviders?: ProviderDef[]): Promise<ApplyResult>;
979
+ setProviders(_providers: ProviderConfigDef[]): Promise<ApplyResult>;
980
+ setLocals(_locals: LocalDef[]): Promise<ApplyResult>;
981
+ setDependsOn(_instanceId: string, _dependsOn: string[]): Promise<ApplyResult>;
982
+ setEnvironments(_environments: Record<string, Record<string, unknown>>): Promise<ApplyResult>;
983
+ undo(): Promise<ApplyResult>;
984
+ redo(): Promise<ApplyResult>;
985
+ createGroup(_label: string, _nodeIds: string[]): Promise<ApplyResult>;
986
+ updateGroup(_groupId: string, _updates: {
987
+ label?: string;
988
+ node_ids?: string[];
989
+ collapsed?: boolean;
990
+ }): Promise<ApplyResult>;
991
+ deleteGroup(_groupId: string): Promise<ApplyResult>;
992
+ queryNodeConfig(instanceId: string): Promise<NodeConfig>;
993
+ queryEdgeConfig(source: string, target: string): Promise<EdgeConfig>;
994
+ querySettings(): Promise<SettingsConfig>;
995
+ queryGraphSummary(): Promise<GraphSummary>;
996
+ queryValidate(): Promise<{
997
+ errors: RenderError[];
998
+ }>;
999
+ getModuleMetadata(): Promise<{
1000
+ metadata: ModuleMetadata | null;
1001
+ present: boolean;
1002
+ }>;
1003
+ setModuleMetadata(_metadata: ModuleMetadata): Promise<void>;
1004
+ previewPolicyResolution(_delta: PreviewDelta, _signal?: AbortSignal): Promise<PolicyResolution>;
1005
+ onEvent(listener: EngineEventListener): () => void;
1006
+ }
1007
+
1008
+ type CanvasState = {
1009
+ view: CanvasView | null;
1010
+ loading: boolean;
1011
+ generation: number;
1012
+ viewportIntent: ViewportIntent | null;
1013
+ viewportIntentSeq: number;
1014
+ };
1015
+ type CanvasContextValue = {
1016
+ state: CanvasState;
1017
+ engine: CanvasEngine | null;
1018
+ readOnly: boolean;
1019
+ localGroupCollapseOverrides: Record<string, boolean>;
1020
+ toggleLocalGroupCollapse: (groupId: string, currentCollapsed: boolean) => void;
1021
+ };
1022
+ declare const CanvasContext: React.Context<CanvasContextValue>;
1023
+ declare function useCanvas(): CanvasContextValue;
1024
+ declare function useEngine(): CanvasEngine;
1025
+
1026
+ export { AccordionSection, ActionBar, App, type ApplyResult, CanvasContext, type CanvasContextValue, type CanvasEngine, type CanvasState, ConnectWebEngine, ContextMenu, EdgeInspectorPanel, type EngineEvent, type EngineEventListener, EnvironmentsContent, EnvironmentsPanel, ErrorBoundary, ErrorState, type ExternalPin, type GenerateResult, type GraphSummary, GroupNode, type GroupNodeData, type HostBridge, type InputUpdate, type LocalDef, LocalsContent, LocalsPanel, type ModuleAuthor, ModuleConfigPanel, type ModuleMetadata, ModuleNode, type ModuleNodeData, type OutputDefEntry, type OutputExportDef, type PolicyConditionTrace, type PolicyPredicateTrace, type PolicyResolution, PolicySidebar, PostMessageEngine, type PreviewDelta, type ProviderConfigDef, type ProviderDef, ProvidersContent, ProvidersPanel, SlidePanel, SnapshotCanvasEngine, type SnapshotCanvasEngineInput, type SnapshotInProcess, type SnapshotMeta, type SnapshotUrls, TerraformConfigContent, TerraformConfigPanel, UnifiedSettingsPanel, ValidationErrorBanner, type VariableDef, useCanvas, useEngine };