@lace-cloud/host 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,863 @@
1
+ import { Diagnostic as Diagnostic$1, NodeConfig, EdgeConfig, SettingsConfig, RenderError } from '@lace-cloud/proto';
2
+ export { CanvasView, Diagnostic, EdgeConfig, GeneratePhase, HostToWebview, NodeConfig, NodePin, RenderEdge, RenderError, RenderGroup, RenderInput, RenderNode, RenderOutput, SettingsConfig, convertCanvasView } from '@lace-cloud/proto';
3
+ import { ChildProcess } from 'node:child_process';
4
+ import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
5
+ import { EventEmitter } from 'node:events';
6
+ import * as grpc from '@grpc/grpc-js';
7
+ import { ClientReadableStream } from '@grpc/grpc-js';
8
+
9
+ type EngineHandshake = {
10
+ version: string;
11
+ protocolVersion: string;
12
+ port: number;
13
+ token: string;
14
+ };
15
+ type ServerState = 'stopped' | 'starting' | 'running' | 'error';
16
+ type WebviewToHost = {
17
+ command: 'webviewReady';
18
+ } | {
19
+ command: 'engineCall';
20
+ requestId: string;
21
+ method: string;
22
+ params?: unknown;
23
+ } | {
24
+ command: 'markDirty';
25
+ } | {
26
+ command: 'markClean';
27
+ } | {
28
+ command: 'openChat';
29
+ prompt: string;
30
+ } | {
31
+ command: 'openFile';
32
+ relativePath: string;
33
+ line?: number;
34
+ column?: number;
35
+ };
36
+ type RegistryModule = {
37
+ id: string;
38
+ name: string;
39
+ system: string;
40
+ version: string;
41
+ categories?: string[];
42
+ description?: string;
43
+ icon_url?: string;
44
+ };
45
+
46
+ /**
47
+ * Spawn `lace engine` and parse the 5-line handshake:
48
+ * LACE_ENGINE_VERSION=<semver>
49
+ * LACE_ENGINE_PROTOCOL_VERSION=<integer>
50
+ * LACE_ENGINE_PORT=<port>
51
+ * LACE_ENGINE_TOKEN=<64 hex chars>
52
+ * LACE_ENGINE_READY
53
+ */
54
+ declare function spawnEngine(binaryPath: string, log: (msg: string) => void): Promise<{
55
+ process: ChildProcess;
56
+ handshake: EngineHandshake;
57
+ }>;
58
+
59
+ interface Bundle {
60
+ schema_version: string;
61
+ kind: string;
62
+ entry: string;
63
+ modules: {
64
+ [key: string]: Module;
65
+ };
66
+ environments: {
67
+ [key: string]: {
68
+ [key: string]: any;
69
+ } | undefined;
70
+ };
71
+ environment_backends: {
72
+ [key: string]: BackendConfig;
73
+ };
74
+ }
75
+ declare const Bundle: MessageFns$1<Bundle>;
76
+ interface Module {
77
+ id: string;
78
+ version: string;
79
+ source: Source | undefined;
80
+ interface: Interface | undefined;
81
+ modules: Use[];
82
+ resources: Resource[];
83
+ locals: Local[];
84
+ exports: Exports | undefined;
85
+ terraform: TerraformBlock | undefined;
86
+ providers: ProviderConfig[];
87
+ }
88
+ declare const Module: MessageFns$1<Module>;
89
+ interface Interface {
90
+ inputs: InputDef$1[];
91
+ outputs: OutputDef$1[];
92
+ }
93
+ declare const Interface: MessageFns$1<Interface>;
94
+ interface InputDef$1 {
95
+ name: string;
96
+ type: string;
97
+ required: boolean;
98
+ description: string;
99
+ default_value: any | undefined;
100
+ validation: ValidationBlock$1 | undefined;
101
+ }
102
+ declare const InputDef$1: MessageFns$1<InputDef$1>;
103
+ interface ValidationBlock$1 {
104
+ condition: string;
105
+ error_message: string;
106
+ }
107
+ declare const ValidationBlock$1: MessageFns$1<ValidationBlock$1>;
108
+ interface OutputDef$1 {
109
+ name: string;
110
+ type: string;
111
+ description: string;
112
+ sensitive: boolean;
113
+ }
114
+ declare const OutputDef$1: MessageFns$1<OutputDef$1>;
115
+ interface Source {
116
+ kind: string;
117
+ repo: string;
118
+ subdir: string;
119
+ ref: string;
120
+ organization: string;
121
+ }
122
+ declare const Source: MessageFns$1<Source>;
123
+ interface Local {
124
+ name: string;
125
+ value: Binding | undefined;
126
+ }
127
+ declare const Local: MessageFns$1<Local>;
128
+ interface Use {
129
+ id: string;
130
+ module: string;
131
+ inputs: {
132
+ [key: string]: Binding;
133
+ };
134
+ depends_on: string[];
135
+ }
136
+ declare const Use: MessageFns$1<Use>;
137
+ interface Resource {
138
+ id: string;
139
+ kind: string;
140
+ type: string;
141
+ inputs: {
142
+ [key: string]: Binding;
143
+ };
144
+ depends_on: string[];
145
+ }
146
+ declare const Resource: MessageFns$1<Resource>;
147
+ interface Exports {
148
+ outputs: {
149
+ [key: string]: OutputExport;
150
+ };
151
+ }
152
+ declare const Exports: MessageFns$1<Exports>;
153
+ interface OutputExport {
154
+ out: OutputRef | undefined;
155
+ lit: any | undefined;
156
+ var: string;
157
+ expr: Expression | undefined;
158
+ }
159
+ declare const OutputExport: MessageFns$1<OutputExport>;
160
+ interface Binding {
161
+ lit?: any | undefined;
162
+ var?: string | undefined;
163
+ out?: OutputRef | undefined;
164
+ expr?: Expression | undefined;
165
+ }
166
+ declare const Binding: MessageFns$1<Binding>;
167
+ interface OutputRef {
168
+ module: string;
169
+ name: string;
170
+ }
171
+ declare const OutputRef: MessageFns$1<OutputRef>;
172
+ interface Expression {
173
+ lang: string;
174
+ value: string;
175
+ }
176
+ declare const Expression: MessageFns$1<Expression>;
177
+ interface TerraformBlock {
178
+ required_version: string;
179
+ required_providers: {
180
+ [key: string]: ProviderRequirement;
181
+ };
182
+ backend: BackendConfig | undefined;
183
+ }
184
+ declare const TerraformBlock: MessageFns$1<TerraformBlock>;
185
+ interface ProviderRequirement {
186
+ source: string;
187
+ version: string;
188
+ }
189
+ declare const ProviderRequirement: MessageFns$1<ProviderRequirement>;
190
+ interface BackendConfig {
191
+ type: string;
192
+ config: {
193
+ [key: string]: any | undefined;
194
+ };
195
+ }
196
+ declare const BackendConfig: MessageFns$1<BackendConfig>;
197
+ interface ProviderConfig {
198
+ name: string;
199
+ alias: string;
200
+ config: {
201
+ [key: string]: any | undefined;
202
+ };
203
+ }
204
+ declare const ProviderConfig: MessageFns$1<ProviderConfig>;
205
+ interface GraphLayout {
206
+ nodes: {
207
+ [key: string]: NodeLayout;
208
+ };
209
+ groups: {
210
+ [key: string]: NodeGroup;
211
+ };
212
+ }
213
+ declare const GraphLayout: MessageFns$1<GraphLayout>;
214
+ interface NodeGroup {
215
+ id: string;
216
+ label: string;
217
+ node_ids: string[];
218
+ collapsed: boolean;
219
+ }
220
+ declare const NodeGroup: MessageFns$1<NodeGroup>;
221
+ interface NodeLayout {
222
+ position: Position$1 | undefined;
223
+ }
224
+ declare const NodeLayout: MessageFns$1<NodeLayout>;
225
+ interface Position$1 {
226
+ x: number;
227
+ y: number;
228
+ }
229
+ declare const Position$1: MessageFns$1<Position$1>;
230
+ /**
231
+ * PolicyResolution is the wire-shape of a Lace policy evaluation result.
232
+ * Mirrors `apps/cli/internal/policy.Resolution` + relevant DecisionLog
233
+ * fields. Used both by the Subscribe stream's authoring-time preview
234
+ * and by the PreviewPolicyResolution RPC for counterfactual queries.
235
+ *
236
+ * `mode` is one of: auto_apply, lightweight_audit, awaiting_approval,
237
+ * policy_blocked. `runner_location` is local|managed (empty for
238
+ * awaiting_approval / policy_blocked, where no run will be dispatched).
239
+ */
240
+ interface PolicyResolution {
241
+ mode: string;
242
+ runner_location: string;
243
+ policy_id: string;
244
+ rules_fired: string[];
245
+ reason: string;
246
+ approval_mode: string;
247
+ condition_trace: PolicyConditionTrace[];
248
+ /**
249
+ * True when the resolution was computed against synthetic
250
+ * authoring-time input (no real terraform plan). Drives the
251
+ * "Preview" UI affordance in the canvas sidebar.
252
+ */
253
+ is_authoring_time_preview: boolean;
254
+ }
255
+ declare const PolicyResolution: MessageFns$1<PolicyResolution>;
256
+ /**
257
+ * PolicyConditionTrace is one rule's contribution to the resolution:
258
+ * whether it fired plus the per-predicate breakdown that produced the
259
+ * fire/no-fire outcome. Mirrors `apps/cli/internal/policy.ConditionTrace`.
260
+ */
261
+ interface PolicyConditionTrace {
262
+ policy_id: string;
263
+ label: string;
264
+ fired: boolean;
265
+ predicates: PolicyPredicateTrace[];
266
+ }
267
+ declare const PolicyConditionTrace: MessageFns$1<PolicyConditionTrace>;
268
+ /**
269
+ * PolicyPredicateTrace is one predicate within a condition. `predicate`
270
+ * names the predicate kind (resourceDestroyGte, attributePath,
271
+ * riskFormula, etc.). `evaluated` is a JSON-encoded scalar (Evaluated
272
+ * is `any` on the Go side; proto carries it as string for portability).
273
+ *
274
+ * `cannot_evaluate` distinguishes "predicate honestly evaluated false"
275
+ * (cannot_evaluate=false, fired=false) from "input did not contain the
276
+ * data this predicate needs" (cannot_evaluate=true, fired=false). The
277
+ * latter is the common case in canvas authoring-time preview where no
278
+ * real terraform plan exists, but it can also surface in authoritative
279
+ * eval if a plan is genuinely missing an expected attribute path —
280
+ * either way the audit log gains fidelity.
281
+ */
282
+ interface PolicyPredicateTrace {
283
+ predicate: string;
284
+ fired: boolean;
285
+ evaluated: string;
286
+ cannot_evaluate: boolean;
287
+ }
288
+ declare const PolicyPredicateTrace: MessageFns$1<PolicyPredicateTrace>;
289
+ type Builtin$1 = Date | Function | Uint8Array | string | number | boolean | undefined;
290
+ type DeepPartial$1<T> = T extends Builtin$1 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$1<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$1<U>> : T extends {} ? {
291
+ [K in keyof T]?: DeepPartial$1<T[K]>;
292
+ } : Partial<T>;
293
+ type KeysOfUnion$1<T> = T extends T ? keyof T : never;
294
+ type Exact$1<P, I extends P> = P extends Builtin$1 ? P : P & {
295
+ [K in keyof P]: Exact$1<P[K], I[K]>;
296
+ } & {
297
+ [K in Exclude<keyof I, KeysOfUnion$1<P>>]: never;
298
+ };
299
+ interface MessageFns$1<T> {
300
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
301
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
302
+ fromJSON(object: any): T;
303
+ toJSON(message: T): unknown;
304
+ create<I extends Exact$1<DeepPartial$1<T>, I>>(base?: I): T;
305
+ fromPartial<I extends Exact$1<DeepPartial$1<T>, I>>(object: I): T;
306
+ }
307
+
308
+ declare enum InputMode {
309
+ INPUT_MODE_UNSPECIFIED = 0,
310
+ INPUT_MODE_EMPTY = 1,
311
+ INPUT_MODE_LITERAL = 2,
312
+ INPUT_MODE_VARIABLE = 3,
313
+ INPUT_MODE_EXPRESSION = 4,
314
+ INPUT_MODE_WIRED = 5,
315
+ UNRECOGNIZED = -1
316
+ }
317
+ declare enum DiagnosticSeverity {
318
+ DIAGNOSTIC_SEVERITY_UNSPECIFIED = 0,
319
+ DIAGNOSTIC_SEVERITY_ERROR = 1,
320
+ DIAGNOSTIC_SEVERITY_WARNING = 2,
321
+ DIAGNOSTIC_SEVERITY_INFO = 3,
322
+ UNRECOGNIZED = -1
323
+ }
324
+ interface Diagnostic {
325
+ severity: DiagnosticSeverity;
326
+ message: string;
327
+ file: string;
328
+ line: number;
329
+ column: number;
330
+ }
331
+ declare const Diagnostic: MessageFns<Diagnostic>;
332
+ interface ConnectAction {
333
+ source: string;
334
+ target: string;
335
+ source_output: string;
336
+ target_input: string;
337
+ }
338
+ declare const ConnectAction: MessageFns<ConnectAction>;
339
+ interface AutoConnectAction {
340
+ source: string;
341
+ target: string;
342
+ }
343
+ declare const AutoConnectAction: MessageFns<AutoConnectAction>;
344
+ interface DisconnectAction {
345
+ target: string;
346
+ input_name: string;
347
+ }
348
+ declare const DisconnectAction: MessageFns<DisconnectAction>;
349
+ interface UpdateInputAction {
350
+ instance_id: string;
351
+ input_name: string;
352
+ mode: InputMode;
353
+ value: any | undefined;
354
+ variable: string;
355
+ expression: string;
356
+ }
357
+ declare const UpdateInputAction: MessageFns<UpdateInputAction>;
358
+ interface UpdateAllInputsAction {
359
+ instance_id: string;
360
+ inputs: InputEntry[];
361
+ }
362
+ declare const UpdateAllInputsAction: MessageFns<UpdateAllInputsAction>;
363
+ interface InputEntry {
364
+ name: string;
365
+ mode: InputMode;
366
+ value: any | undefined;
367
+ variable: string;
368
+ expression: string;
369
+ }
370
+ declare const InputEntry: MessageFns<InputEntry>;
371
+ interface RenameInstanceAction {
372
+ old_id: string;
373
+ new_id: string;
374
+ }
375
+ declare const RenameInstanceAction: MessageFns<RenameInstanceAction>;
376
+ interface DeleteInstanceAction {
377
+ instance_id: string;
378
+ }
379
+ declare const DeleteInstanceAction: MessageFns<DeleteInstanceAction>;
380
+ interface CopyInstancesAction {
381
+ instance_ids: string[];
382
+ }
383
+ declare const CopyInstancesAction: MessageFns<CopyInstancesAction>;
384
+ interface SyncLayoutAction {
385
+ positions: {
386
+ [key: string]: Position;
387
+ };
388
+ }
389
+ declare const SyncLayoutAction: MessageFns<SyncLayoutAction>;
390
+ interface CreateGroupAction {
391
+ label: string;
392
+ node_ids: string[];
393
+ }
394
+ declare const CreateGroupAction: MessageFns<CreateGroupAction>;
395
+ /**
396
+ * UpdateGroupAction uses proto3 `optional` field presence to express partial
397
+ * updates. `node_ids` is wrapped in a message because proto3 `optional` does
398
+ * not apply to `repeated`.
399
+ */
400
+ interface UpdateGroupAction {
401
+ group_id: string;
402
+ label?: string | undefined;
403
+ collapsed?: boolean | undefined;
404
+ node_ids?: UpdateGroupNodeIds | undefined;
405
+ }
406
+ declare const UpdateGroupAction: MessageFns<UpdateGroupAction>;
407
+ interface UpdateGroupNodeIds {
408
+ node_ids: string[];
409
+ }
410
+ declare const UpdateGroupNodeIds: MessageFns<UpdateGroupNodeIds>;
411
+ interface DeleteGroupAction {
412
+ group_id: string;
413
+ }
414
+ declare const DeleteGroupAction: MessageFns<DeleteGroupAction>;
415
+ interface SetVariablesAction {
416
+ variables: InputDef[];
417
+ }
418
+ declare const SetVariablesAction: MessageFns<SetVariablesAction>;
419
+ interface SetExportsAction {
420
+ outputs: OutputExportEntry[];
421
+ output_defs: OutputDef[];
422
+ }
423
+ declare const SetExportsAction: MessageFns<SetExportsAction>;
424
+ interface OutputExportEntry {
425
+ name: string;
426
+ source_instance: string;
427
+ source_output: string;
428
+ }
429
+ declare const OutputExportEntry: MessageFns<OutputExportEntry>;
430
+ interface SetTerraformAction {
431
+ required_version: string;
432
+ required_providers: ProviderReqView[];
433
+ backend: BackendView | undefined;
434
+ }
435
+ declare const SetTerraformAction: MessageFns<SetTerraformAction>;
436
+ interface SetProvidersAction {
437
+ providers: ProviderView[];
438
+ }
439
+ declare const SetProvidersAction: MessageFns<SetProvidersAction>;
440
+ interface SetLocalsAction {
441
+ locals: LocalEntry[];
442
+ }
443
+ declare const SetLocalsAction: MessageFns<SetLocalsAction>;
444
+ interface LocalEntry {
445
+ name: string;
446
+ mode: string;
447
+ value: any | undefined;
448
+ variable: string;
449
+ expression: string;
450
+ }
451
+ declare const LocalEntry: MessageFns<LocalEntry>;
452
+ interface SetDependsOnAction {
453
+ instance_id: string;
454
+ depends_on: string[];
455
+ }
456
+ declare const SetDependsOnAction: MessageFns<SetDependsOnAction>;
457
+ interface SetEnvironmentsAction {
458
+ environments: {
459
+ [key: string]: {
460
+ [key: string]: any;
461
+ } | undefined;
462
+ };
463
+ environment_backends: {
464
+ [key: string]: BackendView;
465
+ };
466
+ }
467
+ declare const SetEnvironmentsAction: MessageFns<SetEnvironmentsAction>;
468
+ /**
469
+ * Undo / Redo are zero-payload actions — the session's history stack
470
+ * carries the state. Modeled as Action oneof cases (empty messages) so
471
+ * the single ApplyAction RPC covers the full mutation surface.
472
+ */
473
+ interface UndoAction {
474
+ }
475
+ declare const UndoAction: MessageFns<UndoAction>;
476
+ interface RedoAction {
477
+ }
478
+ declare const RedoAction: MessageFns<RedoAction>;
479
+ /**
480
+ * PlaceModuleAction drops a registry module onto the canvas at a given
481
+ * position. Distinct from Connect/UpdateInput/etc. in that it names a
482
+ * *source* module (registry coordinates) rather than a sibling instance;
483
+ * the server orchestrates the registry fetch + module-key resolution
484
+ * before producing the Bundle mutation.
485
+ */
486
+ interface PlaceModuleAction {
487
+ name: string;
488
+ system: string;
489
+ version: string;
490
+ organization: string;
491
+ position: Position | undefined;
492
+ }
493
+ declare const PlaceModuleAction: MessageFns<PlaceModuleAction>;
494
+ /** The canonical Action type used inside ApplyActionRequest. */
495
+ interface Action {
496
+ connect?: ConnectAction | undefined;
497
+ auto_connect?: AutoConnectAction | undefined;
498
+ disconnect?: DisconnectAction | undefined;
499
+ update_input?: UpdateInputAction | undefined;
500
+ update_all_inputs?: UpdateAllInputsAction | undefined;
501
+ rename_instance?: RenameInstanceAction | undefined;
502
+ delete_instance?: DeleteInstanceAction | undefined;
503
+ copy_instances?: CopyInstancesAction | undefined;
504
+ sync_layout?: SyncLayoutAction | undefined;
505
+ create_group?: CreateGroupAction | undefined;
506
+ update_group?: UpdateGroupAction | undefined;
507
+ delete_group?: DeleteGroupAction | undefined;
508
+ set_variables?: SetVariablesAction | undefined;
509
+ set_exports?: SetExportsAction | undefined;
510
+ set_terraform?: SetTerraformAction | undefined;
511
+ set_providers?: SetProvidersAction | undefined;
512
+ set_locals?: SetLocalsAction | undefined;
513
+ set_depends_on?: SetDependsOnAction | undefined;
514
+ set_environments?: SetEnvironmentsAction | undefined;
515
+ undo?: UndoAction | undefined;
516
+ redo?: RedoAction | undefined;
517
+ place_module?: PlaceModuleAction | undefined;
518
+ }
519
+ declare const Action: MessageFns<Action>;
520
+ interface ApplyActionRequest {
521
+ session_id: string;
522
+ actions: Action[];
523
+ }
524
+ declare const ApplyActionRequest: MessageFns<ApplyActionRequest>;
525
+ interface GenerateProgress {
526
+ stage: string;
527
+ message: string;
528
+ }
529
+ declare const GenerateProgress: MessageFns<GenerateProgress>;
530
+ interface GenerateSuccess {
531
+ files_written: string[];
532
+ files: {
533
+ [key: string]: string;
534
+ };
535
+ }
536
+ declare const GenerateSuccess: MessageFns<GenerateSuccess>;
537
+ interface GenerateError {
538
+ message: string;
539
+ diagnostics: Diagnostic[];
540
+ }
541
+ declare const GenerateError: MessageFns<GenerateError>;
542
+ /**
543
+ * BundleStateEvent is the element yielded by the Subscribe stream.
544
+ * Every session-state change publishes a full BundleState; generate
545
+ * events pass through unchanged from the pre-P10 protocol.
546
+ */
547
+ interface BundleStateEvent {
548
+ state?: BundleState | undefined;
549
+ generate_progress?: GenerateProgress | undefined;
550
+ generate_success?: GenerateSuccess | undefined;
551
+ generate_error?: GenerateError | undefined;
552
+ /**
553
+ * Authoring-time policy preview. Emitted alongside BundleState
554
+ * changes (debounced ~100ms after each apply) and as a second
555
+ * frame on initial Subscribe connect. Always carries
556
+ * `is_authoring_time_preview = true`.
557
+ */
558
+ policy_resolution?: PolicyResolution | undefined;
559
+ }
560
+ declare const BundleStateEvent: MessageFns<BundleStateEvent>;
561
+ /**
562
+ * BundleState is the authoritative session state over the wire: the
563
+ * Bundle IR + per-scope layouts + session-undo metadata. Consumers
564
+ * (VS Code extension, portal, tests) project this locally via the
565
+ * canvas package's `projectCanvasView` to produce a renderable
566
+ * CanvasView.
567
+ *
568
+ * Not to be confused with the `bundle_snapshot` API entity, which is
569
+ * the content-addressed immutable archival form in D1 + R2. BundleState
570
+ * is a live, per-session wire shape.
571
+ */
572
+ interface BundleState {
573
+ bundle: Bundle | undefined;
574
+ layouts: {
575
+ [key: string]: GraphLayout;
576
+ };
577
+ can_undo: boolean;
578
+ can_redo: boolean;
579
+ is_dirty: boolean;
580
+ }
581
+ declare const BundleState: MessageFns<BundleState>;
582
+ /**
583
+ * BundleApplyResult is returned by action RPCs (Connect, UpdateInput,
584
+ * CreateGroup, ...) after an action is applied to the session. On
585
+ * success, the corresponding `BundleState` is delivered via Subscribe
586
+ * to all connected subscribers (including the action's caller).
587
+ * On failure, `errors` carries the reasons the mutation was rejected
588
+ * at the IR-validation boundary.
589
+ */
590
+ interface BundleApplyResult {
591
+ success: boolean;
592
+ errors: GraphError[];
593
+ }
594
+ declare const BundleApplyResult: MessageFns<BundleApplyResult>;
595
+ /**
596
+ * GraphError describes an IR-level validation failure that rejected an
597
+ * action. Distinct from `RenderError` (which surfaces view-level
598
+ * editing hints to the user via the CanvasView). Mutation-boundary
599
+ * errors never reach the canvas; they are returned synchronously to
600
+ * the action RPC caller.
601
+ */
602
+ interface GraphError {
603
+ module_key: string;
604
+ instance_id: string;
605
+ input_name: string;
606
+ message: string;
607
+ }
608
+ declare const GraphError: MessageFns<GraphError>;
609
+ interface ProviderReqView {
610
+ name: string;
611
+ source: string;
612
+ version: string;
613
+ }
614
+ declare const ProviderReqView: MessageFns<ProviderReqView>;
615
+ interface BackendView {
616
+ type: string;
617
+ config: {
618
+ [key: string]: any | undefined;
619
+ };
620
+ }
621
+ declare const BackendView: MessageFns<BackendView>;
622
+ interface ProviderView {
623
+ name: string;
624
+ alias: string;
625
+ config: {
626
+ [key: string]: any | undefined;
627
+ };
628
+ }
629
+ declare const ProviderView: MessageFns<ProviderView>;
630
+ interface Position {
631
+ x: number;
632
+ y: number;
633
+ }
634
+ declare const Position: MessageFns<Position>;
635
+ interface InputDef {
636
+ name: string;
637
+ type: string;
638
+ required: boolean;
639
+ description: string;
640
+ default_value: any | undefined;
641
+ validation: ValidationBlock | undefined;
642
+ }
643
+ declare const InputDef: MessageFns<InputDef>;
644
+ interface ValidationBlock {
645
+ condition: string;
646
+ error_message: string;
647
+ }
648
+ declare const ValidationBlock: MessageFns<ValidationBlock>;
649
+ interface OutputDef {
650
+ name: string;
651
+ type: string;
652
+ description: string;
653
+ sensitive: boolean;
654
+ }
655
+ declare const OutputDef: MessageFns<OutputDef>;
656
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
657
+ 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 {} ? {
658
+ [K in keyof T]?: DeepPartial<T[K]>;
659
+ } : Partial<T>;
660
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
661
+ type Exact<P, I extends P> = P extends Builtin ? P : P & {
662
+ [K in keyof P]: Exact<P[K], I[K]>;
663
+ } & {
664
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
665
+ };
666
+ interface MessageFns<T> {
667
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
668
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
669
+ fromJSON(object: any): T;
670
+ toJSON(message: T): unknown;
671
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
672
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
673
+ }
674
+
675
+ type RpcErrorCategory = 'engine_unavailable' | 'server_error' | 'timeout';
676
+ declare class RpcError extends Error {
677
+ readonly category: RpcErrorCategory;
678
+ readonly method: string;
679
+ readonly cause?: unknown | undefined;
680
+ constructor(message: string, category: RpcErrorCategory, method: string, cause?: unknown | undefined);
681
+ }
682
+ declare function classifyRpcError(err: unknown, method: string): RpcError;
683
+ declare function requireClient<T>(client: T | null | undefined, action: string): T;
684
+
685
+ declare class LaceTransport {
686
+ private inner;
687
+ private token;
688
+ private _sessionId;
689
+ constructor(port: number, token: string);
690
+ get sessionId(): string | null;
691
+ private makeMetadata;
692
+ private requireSessionId;
693
+ private unary;
694
+ initialize(clientVersion: string): Promise<{
695
+ serverVersion: string;
696
+ capabilities?: string[];
697
+ }>;
698
+ shutdown(): Promise<void>;
699
+ authStatus(): Promise<{
700
+ authenticated: boolean;
701
+ }>;
702
+ listRegistryModules(params?: {
703
+ system?: string;
704
+ search?: string;
705
+ category?: string;
706
+ kind?: string;
707
+ page?: number;
708
+ limit?: number;
709
+ organization?: string;
710
+ }): Promise<{
711
+ modules: RegistryModule[];
712
+ pagination?: {
713
+ page: number;
714
+ limit: number;
715
+ total: number;
716
+ };
717
+ }>;
718
+ registryGetVersions(params: {
719
+ name: string;
720
+ system: string;
721
+ organization?: string;
722
+ }): Promise<{
723
+ name: string;
724
+ system: string;
725
+ versions: Array<{
726
+ version: string;
727
+ description?: string;
728
+ }>;
729
+ }>;
730
+ inspectModule(params: {
731
+ name: string;
732
+ system: string;
733
+ version: string;
734
+ organization?: string;
735
+ }): Promise<{
736
+ name: string;
737
+ system: string;
738
+ version: string;
739
+ module_interface?: {
740
+ inputs: Array<{
741
+ name: string;
742
+ type: string;
743
+ required: boolean;
744
+ description: string;
745
+ default_value?: unknown;
746
+ sensitive: boolean;
747
+ }>;
748
+ outputs: Array<{
749
+ name: string;
750
+ type: string;
751
+ required: boolean;
752
+ description: string;
753
+ default_value?: unknown;
754
+ sensitive: boolean;
755
+ }>;
756
+ };
757
+ }>;
758
+ sessionOpen(params: {
759
+ file_path: string;
760
+ workspace_name: string;
761
+ }): Promise<{
762
+ session_id: string;
763
+ state: BundleState;
764
+ }>;
765
+ sessionSave(): Promise<{
766
+ saved: boolean;
767
+ }>;
768
+ sessionClose(): Promise<{
769
+ status: string;
770
+ }>;
771
+ sessionGenerate(params: {
772
+ output_dir: string;
773
+ options?: {
774
+ dry_run?: boolean;
775
+ format?: boolean;
776
+ validate?: boolean;
777
+ overwrite?: boolean;
778
+ };
779
+ }): Promise<{
780
+ files_written?: string[];
781
+ files?: Record<string, string>;
782
+ diagnostics: Diagnostic$1[];
783
+ }>;
784
+ applyAction(actions: Action[]): Promise<BundleApplyResult>;
785
+ queryNodeConfig(params: {
786
+ instance_id: string;
787
+ }): Promise<NodeConfig>;
788
+ queryEdgeConfig(params: {
789
+ source: string;
790
+ target: string;
791
+ }): Promise<EdgeConfig>;
792
+ querySettings(): Promise<SettingsConfig>;
793
+ queryGraphSummary(): Promise<{
794
+ text: string;
795
+ }>;
796
+ queryValidate(): Promise<{
797
+ errors: RenderError[];
798
+ }>;
799
+ previewPolicyResolution(params: {
800
+ remove_resource_instance_id?: string;
801
+ }): Promise<PolicyResolution>;
802
+ subscribeStream(sessionId: string): grpc.ClientReadableStream<BundleStateEvent>;
803
+ dispatch(method: string, params: unknown): Promise<unknown>;
804
+ dispose(): void;
805
+ }
806
+
807
+ type ServerManagerOpts = {
808
+ log: (msg: string) => void;
809
+ getBinaryPath: () => string;
810
+ getAutoRestart: () => boolean;
811
+ };
812
+ declare class ServerManager extends EventEmitter {
813
+ private process;
814
+ private _transport;
815
+ private state;
816
+ private restartCount;
817
+ private restartScheduled;
818
+ private readonly maxRestarts;
819
+ private readonly log;
820
+ private readonly getBinaryPath;
821
+ private readonly getAutoRestart;
822
+ constructor(opts: ServerManagerOpts);
823
+ get transport(): LaceTransport | null;
824
+ get currentState(): ServerState;
825
+ start(): Promise<void>;
826
+ stop(): Promise<void>;
827
+ restart(): Promise<void>;
828
+ dispose(): void;
829
+ private setState;
830
+ private maybeRestart;
831
+ }
832
+
833
+ type SubscribeCallbacks = {
834
+ /**
835
+ * Fires on every session-state change. The host forwards the raw
836
+ * BundleState (Bundle + Layouts + undo metadata) to the webview via
837
+ * postMessage; the webview's engine projects locally.
838
+ */
839
+ onStateUpdated: (state: BundleState) => void;
840
+ onGenerateProgress: (phase: string) => void;
841
+ onGenerateSuccess: (files: string[]) => void;
842
+ onGenerateError: (message: string, diagnostics: Diagnostic$1[]) => void;
843
+ /**
844
+ * Fires for every authoring-time policy preview emitted by the
845
+ * session (debounced ~100ms after each apply, plus once on initial
846
+ * Subscribe connect). Forwarded to the webview as a
847
+ * `policyResolution` host message.
848
+ */
849
+ onPolicyResolution: (resolution: PolicyResolution) => void;
850
+ onEnd: () => void;
851
+ onError: (err: Error) => void;
852
+ };
853
+ /**
854
+ * Wraps a gRPC server-streaming Subscribe call, dispatching typed
855
+ * BundleStateEvent fields to callbacks.
856
+ */
857
+ declare class SubscribeHandler {
858
+ private stream;
859
+ start(stream: ClientReadableStream<BundleStateEvent>, callbacks: SubscribeCallbacks): void;
860
+ stop(): void;
861
+ }
862
+
863
+ export { Action, ApplyActionRequest, BundleApplyResult, BundleState, BundleStateEvent, type EngineHandshake, LaceTransport, type RegistryModule, RpcError, type RpcErrorCategory, ServerManager, type ServerState, type SubscribeCallbacks, SubscribeHandler, type WebviewToHost, classifyRpcError, requireClient, spawnEngine };