@lace-cloud/host 0.16.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,10 +1,38 @@
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';
1
+ import * as grpc from '@grpc/grpc-js';
2
+ import { Metadata, Client, ServiceError, ClientUnaryCall, CallOptions, ClientReadableStream, ChannelCredentials, ClientOptions } from '@grpc/grpc-js';
3
+ import { MessageBridge, Diagnostic as Diagnostic$1 } from '@lace-cloud/proto';
4
+ export { Diagnostic } from '@lace-cloud/proto';
3
5
  import { ChildProcess } from 'node:child_process';
4
6
  import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
5
7
  import { EventEmitter } from 'node:events';
6
- import * as grpc from '@grpc/grpc-js';
7
- import { ClientReadableStream } from '@grpc/grpc-js';
8
+
9
+ type LiveCall = {
10
+ cancel(): void;
11
+ };
12
+ /** The subset of grpc-js's `ClientReadableStream` the bridge reads from. */
13
+ type EngineStreamCall = LiveCall & {
14
+ on(event: 'data', listener: (event: unknown) => void): unknown;
15
+ on(event: 'end', listener: () => void): unknown;
16
+ on(event: 'error', listener: (err: Error) => void): unknown;
17
+ };
18
+ /**
19
+ * The subset of `LaceTransport` the bridge forwards through: the two
20
+ * generic gRPC-JS call methods every `ENGINE_RPCS` row is dispatched
21
+ * through, plus the auth metadata. A fake client satisfies this
22
+ * structurally without implementing the rest of grpc-js's `Client`.
23
+ */
24
+ type EngineTransport = {
25
+ readonly client: {
26
+ makeUnaryRequest(method: string, serialize: (value: unknown) => Buffer, deserialize: (value: Buffer) => unknown, argument: unknown, metadata: Metadata, callback: (error: Error | null, response?: unknown) => void): unknown;
27
+ makeServerStreamRequest(method: string, serialize: (value: unknown) => Buffer, deserialize: (value: Buffer) => unknown, argument: unknown, metadata: Metadata): EngineStreamCall;
28
+ };
29
+ metadata(): Metadata;
30
+ };
31
+ /**
32
+ * Serves `bridge` over `transport`'s engine connection until the returned
33
+ * `dispose` is called. `dispose` cancels every live call.
34
+ */
35
+ declare function serveEngineBridge(bridge: MessageBridge, transport: EngineTransport): () => void;
8
36
 
9
37
  type EngineHandshake = {
10
38
  version: string;
@@ -13,35 +41,6 @@ type EngineHandshake = {
13
41
  token: string;
14
42
  };
15
43
  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
44
 
46
45
  /**
47
46
  * Spawn `lace engine` and parse the 5-line handshake:
@@ -56,6 +55,37 @@ declare function spawnEngine(binaryPath: string, log: (msg: string) => void): Pr
56
55
  handshake: EngineHandshake;
57
56
  }>;
58
57
 
58
+ /**
59
+ * A generic empty message that you can re-use to avoid defining duplicated
60
+ * empty messages in your APIs. A typical example is to use it as the request
61
+ * or the response type of an API method. For instance:
62
+ *
63
+ * service Foo {
64
+ * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
65
+ * }
66
+ */
67
+ interface Empty {
68
+ }
69
+ declare const Empty: MessageFns$2<Empty>;
70
+ type Builtin$2 = Date | Function | Uint8Array | string | number | boolean | undefined;
71
+ type DeepPartial$2<T> = T extends Builtin$2 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$2<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$2<U>> : T extends {} ? {
72
+ [K in keyof T]?: DeepPartial$2<T[K]>;
73
+ } : Partial<T>;
74
+ type KeysOfUnion$2<T> = T extends T ? keyof T : never;
75
+ type Exact$2<P, I extends P> = P extends Builtin$2 ? P : P & {
76
+ [K in keyof P]: Exact$2<P[K], I[K]>;
77
+ } & {
78
+ [K in Exclude<keyof I, KeysOfUnion$2<P>>]: never;
79
+ };
80
+ interface MessageFns$2<T> {
81
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
82
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
83
+ fromJSON(object: any): T;
84
+ toJSON(message: T): unknown;
85
+ create<I extends Exact$2<DeepPartial$2<T>, I>>(base?: I): T;
86
+ fromPartial<I extends Exact$2<DeepPartial$2<T>, I>>(object: I): T;
87
+ }
88
+
59
89
  interface Bundle {
60
90
  schema_version: string;
61
91
  kind: string;
@@ -63,14 +93,6 @@ interface Bundle {
63
93
  modules: {
64
94
  [key: string]: Module;
65
95
  };
66
- environments: {
67
- [key: string]: {
68
- [key: string]: any;
69
- } | undefined;
70
- };
71
- environment_backends: {
72
- [key: string]: BackendConfig;
73
- };
74
96
  }
75
97
  declare const Bundle: MessageFns$1<Bundle>;
76
98
  interface Module {
@@ -125,7 +147,6 @@ interface Source {
125
147
  repo: string;
126
148
  subdir: string;
127
149
  ref: string;
128
- organization: string;
129
150
  }
130
151
  declare const Source: MessageFns$1<Source>;
131
152
  interface Local {
@@ -251,63 +272,6 @@ interface ProviderConfig {
251
272
  blocks: Block[];
252
273
  }
253
274
  declare const ProviderConfig: MessageFns$1<ProviderConfig>;
254
- /**
255
- * PolicyResolution is the wire-shape of a Lace policy evaluation result.
256
- * Mirrors `apps/cli/internal/policy.Resolution` + relevant DecisionLog
257
- * fields. Used both by the Subscribe stream's authoring-time preview
258
- * and by the PreviewPolicyResolution RPC for counterfactual queries.
259
- *
260
- * `mode` is one of: auto_apply, lightweight_audit, awaiting_approval,
261
- * policy_blocked.
262
- */
263
- interface PolicyResolution {
264
- mode: string;
265
- policy_id: string;
266
- rules_fired: string[];
267
- reason: string;
268
- approval_mode: string;
269
- condition_trace: PolicyConditionTrace[];
270
- /**
271
- * True when the resolution was computed against synthetic
272
- * authoring-time input (no real terraform plan). Drives the
273
- * "Preview" UI affordance in the canvas sidebar.
274
- */
275
- is_authoring_time_preview: boolean;
276
- }
277
- declare const PolicyResolution: MessageFns$1<PolicyResolution>;
278
- /**
279
- * PolicyConditionTrace is one rule's contribution to the resolution:
280
- * whether it fired plus the per-predicate breakdown that produced the
281
- * fire/no-fire outcome. Mirrors `apps/cli/internal/policy.ConditionTrace`.
282
- */
283
- interface PolicyConditionTrace {
284
- policy_id: string;
285
- label: string;
286
- fired: boolean;
287
- predicates: PolicyPredicateTrace[];
288
- }
289
- declare const PolicyConditionTrace: MessageFns$1<PolicyConditionTrace>;
290
- /**
291
- * PolicyPredicateTrace is one predicate within a condition. `predicate`
292
- * names the predicate kind (resourceDestroyGte, attributePath,
293
- * riskFormula, etc.). `evaluated` is a JSON-encoded scalar (Evaluated
294
- * is `any` on the Go side; proto carries it as string for portability).
295
- *
296
- * `cannot_evaluate` distinguishes "predicate honestly evaluated false"
297
- * (cannot_evaluate=false, fired=false) from "input did not contain the
298
- * data this predicate needs" (cannot_evaluate=true, fired=false). The
299
- * latter is the common case in canvas authoring-time preview where no
300
- * real terraform plan exists, but it can also surface in authoritative
301
- * eval if a plan is genuinely missing an expected attribute path —
302
- * either way the audit log gains fidelity.
303
- */
304
- interface PolicyPredicateTrace {
305
- predicate: string;
306
- fired: boolean;
307
- evaluated: string;
308
- cannot_evaluate: boolean;
309
- }
310
- declare const PolicyPredicateTrace: MessageFns$1<PolicyPredicateTrace>;
311
275
  type Builtin$1 = Date | Function | Uint8Array | string | number | boolean | undefined;
312
276
  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 {} ? {
313
277
  [K in keyof T]?: DeepPartial$1<T[K]>;
@@ -343,12 +307,101 @@ declare enum DiagnosticSeverity {
343
307
  DIAGNOSTIC_SEVERITY_INFO = 3,
344
308
  UNRECOGNIZED = -1
345
309
  }
310
+ declare enum ConflictChoice {
311
+ CONFLICT_CHOICE_UNSPECIFIED = 0,
312
+ CONFLICT_CHOICE_KEEP = 1,
313
+ CONFLICT_CHOICE_RELOAD = 2,
314
+ UNRECOGNIZED = -1
315
+ }
316
+ interface InitializeRequest {
317
+ client_version: string;
318
+ protocol_version: string;
319
+ }
320
+ declare const InitializeRequest: MessageFns<InitializeRequest>;
321
+ interface InitializeResponse {
322
+ server_version: string;
323
+ protocol_version: string;
324
+ supported_protocols: string[];
325
+ /** space-joined paths of the non-hidden command tree */
326
+ command_paths: string[];
327
+ }
328
+ declare const InitializeResponse: MessageFns<InitializeResponse>;
329
+ interface ShutdownResponse {
330
+ status: string;
331
+ }
332
+ declare const ShutdownResponse: MessageFns<ShutdownResponse>;
333
+ interface SessionOpenRequest {
334
+ ephemeral?: EphemeralSession | undefined;
335
+ root?: RootSession | undefined;
336
+ /** ephemeral only */
337
+ workspace_name: string;
338
+ }
339
+ declare const SessionOpenRequest: MessageFns<SessionOpenRequest>;
340
+ interface EphemeralSession {
341
+ }
342
+ declare const EphemeralSession: MessageFns<EphemeralSession>;
343
+ interface RootSession {
344
+ /** absolute authoring root */
345
+ path: string;
346
+ }
347
+ declare const RootSession: MessageFns<RootSession>;
348
+ interface SessionOpenResponse {
349
+ session_id: string;
350
+ state: BundleState | undefined;
351
+ }
352
+ declare const SessionOpenResponse: MessageFns<SessionOpenResponse>;
353
+ interface TestSessionOpenRequest {
354
+ fixture_name: string;
355
+ workspace_name: string;
356
+ }
357
+ declare const TestSessionOpenRequest: MessageFns<TestSessionOpenRequest>;
358
+ interface SessionSaveRequest {
359
+ session_id: string;
360
+ }
361
+ declare const SessionSaveRequest: MessageFns<SessionSaveRequest>;
362
+ interface SessionSaveResponse {
363
+ }
364
+ declare const SessionSaveResponse: MessageFns<SessionSaveResponse>;
365
+ interface SessionCloseRequest {
366
+ session_id: string;
367
+ }
368
+ declare const SessionCloseRequest: MessageFns<SessionCloseRequest>;
369
+ interface SessionCloseResponse {
370
+ status: string;
371
+ }
372
+ declare const SessionCloseResponse: MessageFns<SessionCloseResponse>;
373
+ interface SessionGenerateRequest {
374
+ session_id: string;
375
+ }
376
+ declare const SessionGenerateRequest: MessageFns<SessionGenerateRequest>;
377
+ interface SessionGenerateResponse {
378
+ files_written: string[];
379
+ /** the `module validate -o json` document for the written tree */
380
+ validate_json: string;
381
+ }
382
+ declare const SessionGenerateResponse: MessageFns<SessionGenerateResponse>;
383
+ interface SessionResolveConflictRequest {
384
+ session_id: string;
385
+ choice: ConflictChoice;
386
+ tree_hash: string;
387
+ }
388
+ declare const SessionResolveConflictRequest: MessageFns<SessionResolveConflictRequest>;
389
+ interface SessionResolveConflictResponse {
390
+ }
391
+ declare const SessionResolveConflictResponse: MessageFns<SessionResolveConflictResponse>;
346
392
  interface Diagnostic {
347
393
  severity: DiagnosticSeverity;
348
394
  message: string;
349
395
  file: string;
350
396
  line: number;
351
397
  column: number;
398
+ /**
399
+ * Locates an engine-validator finding within the graph. Empty when
400
+ * the diagnostic has no graph location (file/line/column instead).
401
+ */
402
+ module_key: string;
403
+ instance_id: string;
404
+ input_name: string;
352
405
  }
353
406
  declare const Diagnostic: MessageFns<Diagnostic>;
354
407
  interface ConnectAction {
@@ -477,17 +530,6 @@ interface SetUseProvidersAction {
477
530
  };
478
531
  }
479
532
  declare const SetUseProvidersAction: MessageFns<SetUseProvidersAction>;
480
- interface SetEnvironmentsAction {
481
- environments: {
482
- [key: string]: {
483
- [key: string]: any;
484
- } | undefined;
485
- };
486
- environment_backends: {
487
- [key: string]: BackendView;
488
- };
489
- }
490
- declare const SetEnvironmentsAction: MessageFns<SetEnvironmentsAction>;
491
533
  /**
492
534
  * Undo / Redo are zero-payload actions — the session's history stack
493
535
  * carries the state. Modeled as Action oneof cases (empty messages) so
@@ -508,10 +550,9 @@ declare const RedoAction: MessageFns<RedoAction>;
508
550
  * client-side from `BundleApplyResult.created` after this action lands.
509
551
  */
510
552
  interface PlaceModuleAction {
553
+ author: string;
511
554
  name: string;
512
- system: string;
513
555
  version: string;
514
- organization: string;
515
556
  }
516
557
  declare const PlaceModuleAction: MessageFns<PlaceModuleAction>;
517
558
  /** The canonical Action type used inside ApplyActionRequest. */
@@ -531,7 +572,6 @@ interface Action {
531
572
  set_providers?: SetProvidersAction | undefined;
532
573
  set_locals?: SetLocalsAction | undefined;
533
574
  set_depends_on?: SetDependsOnAction | undefined;
534
- set_environments?: SetEnvironmentsAction | undefined;
535
575
  undo?: UndoAction | undefined;
536
576
  redo?: RedoAction | undefined;
537
577
  place_module?: PlaceModuleAction | undefined;
@@ -544,6 +584,40 @@ interface ApplyActionRequest {
544
584
  actions: Action[];
545
585
  }
546
586
  declare const ApplyActionRequest: MessageFns<ApplyActionRequest>;
587
+ interface InvokeRequest {
588
+ /** client-chosen, unique per engine connection */
589
+ invoke_id: string;
590
+ /** empty ⇒ sessionless: Workspace commands exit 2 "requires a canvas session" */
591
+ session_id: string;
592
+ /** e.g. ["stack","preview"] */
593
+ path: string[];
594
+ /** positionals + flags from toArgv; never -o/--output */
595
+ argv: string[];
596
+ }
597
+ declare const InvokeRequest: MessageFns<InvokeRequest>;
598
+ interface InvokeEvent {
599
+ json?: string | undefined;
600
+ exit?: InvokeExit | undefined;
601
+ }
602
+ declare const InvokeEvent: MessageFns<InvokeEvent>;
603
+ interface InvokeExit {
604
+ code: number;
605
+ /** tail ≤ 8 KiB */
606
+ stderr_tail: string;
607
+ }
608
+ declare const InvokeExit: MessageFns<InvokeExit>;
609
+ interface CancelInvokeRequest {
610
+ invoke_id: string;
611
+ }
612
+ declare const CancelInvokeRequest: MessageFns<CancelInvokeRequest>;
613
+ interface CancelInvokeResponse {
614
+ found: boolean;
615
+ }
616
+ declare const CancelInvokeResponse: MessageFns<CancelInvokeResponse>;
617
+ interface SubscribeRequest {
618
+ session_id: string;
619
+ }
620
+ declare const SubscribeRequest: MessageFns<SubscribeRequest>;
547
621
  interface GenerateProgress {
548
622
  stage: string;
549
623
  message: string;
@@ -551,52 +625,82 @@ interface GenerateProgress {
551
625
  declare const GenerateProgress: MessageFns<GenerateProgress>;
552
626
  interface GenerateSuccess {
553
627
  files_written: string[];
554
- files: {
555
- [key: string]: string;
556
- };
628
+ /** the `module validate -o json` document for the written tree */
629
+ validate_json: string;
557
630
  }
558
631
  declare const GenerateSuccess: MessageFns<GenerateSuccess>;
559
632
  interface GenerateError {
560
633
  message: string;
561
634
  diagnostics: Diagnostic[];
635
+ /**
636
+ * Set when Generate refused because a conflict opened during its
637
+ * precondition check or its pre-write re-walk.
638
+ */
639
+ conflict: Conflict | undefined;
562
640
  }
563
641
  declare const GenerateError: MessageFns<GenerateError>;
642
+ interface Conflict {
643
+ base_tree_hash: string;
644
+ tree_hash: string;
645
+ }
646
+ declare const Conflict: MessageFns<Conflict>;
564
647
  /**
565
- * BundleStateEvent is the element yielded by the Subscribe stream.
566
- * Every session-state change publishes a full BundleState; generate
567
- * events pass through unchanged from the pre-P10 protocol.
648
+ * BundleStateEvent is the element yielded by the Subscribe stream. Every
649
+ * session-state change publishes a full BundleState; generate events pass
650
+ * through as their own cases.
568
651
  */
569
652
  interface BundleStateEvent {
570
653
  state?: BundleState | undefined;
571
654
  generate_progress?: GenerateProgress | undefined;
572
655
  generate_success?: GenerateSuccess | undefined;
573
656
  generate_error?: GenerateError | undefined;
574
- /**
575
- * Authoring-time policy preview. Emitted alongside BundleState
576
- * changes (debounced ~100ms after each apply) and as a second
577
- * frame on initial Subscribe connect. Always carries
578
- * `is_authoring_time_preview = true`.
579
- */
580
- policy_resolution?: PolicyResolution | undefined;
581
657
  }
582
658
  declare const BundleStateEvent: MessageFns<BundleStateEvent>;
583
659
  /**
584
660
  * BundleState is the authoritative session state over the wire: the
585
- * Bundle IR + session-undo metadata. Consumers (VS Code extension,
586
- * portal, tests) project this locally via the canvas package's
587
- * `projectCanvasView(bundle, arrangement?, meta)` to produce a
588
- * renderable CanvasView — `arrangement` (node positions, group
589
- * collapse/label) is consumer-owned view state and never travels here.
661
+ * Bundle IR + session-undo metadata + the engine validator's findings
662
+ * for that Bundle, plus the session's standing against its source tf
663
+ * tree. Consumers (VS Code extension, portal, tests) project this
664
+ * locally via the proto package's `projectCanvasView(bundle,
665
+ * arrangement?, meta)` to produce a renderable CanvasView —
666
+ * `arrangement` (node positions, group collapse/label) is
667
+ * consumer-owned view state and never travels here.
590
668
  *
591
669
  * Not to be confused with the `bundle_snapshot` API entity, which is
592
670
  * the content-addressed immutable archival form in D1 + R2. BundleState
593
671
  * is a live, per-session wire shape.
594
672
  */
595
673
  interface BundleState {
674
+ /** Unset when the session is source-refused with no accepted tree. */
596
675
  bundle: Bundle | undefined;
597
676
  can_undo: boolean;
598
677
  can_redo: boolean;
599
- is_dirty: boolean;
678
+ /** True when the working IR differs from the saved IR in `state.lace`. */
679
+ unsaved: boolean;
680
+ /**
681
+ * The engine validator's findings for this state, in the validator's
682
+ * order. Empty when the state has none, so a subscriber sees errors
683
+ * clear.
684
+ */
685
+ diagnostics: Diagnostic[];
686
+ /**
687
+ * Set when a tf change diverges from the session's base tree hash and
688
+ * needs Keep or Reload. Unset when there is no open conflict.
689
+ */
690
+ conflict: Conflict | undefined;
691
+ /**
692
+ * True when the saved IR in `state.lace` carries edits no Generate
693
+ * has written to the source tf.
694
+ */
695
+ ungenerated: boolean;
696
+ /**
697
+ * True when the source tf this session opened, or last observed live,
698
+ * is refused (unparsable or a Lossless refusal). The engine refuses
699
+ * every mutation while this holds — edit, undo, redo, save, generate,
700
+ * and SessionResolveConflict's Keep/Reload alike — until a live tf
701
+ * change parses and clears it.
702
+ */
703
+ source_refused: boolean;
600
704
  }
601
705
  declare const BundleState: MessageFns<BundleState>;
602
706
  /**
@@ -643,10 +747,9 @@ interface CreatedRef {
643
747
  declare const CreatedRef: MessageFns<CreatedRef>;
644
748
  /**
645
749
  * GraphError describes an IR-level validation failure that rejected an
646
- * action. Distinct from `RenderError` (which surfaces view-level
647
- * editing hints to the user via the CanvasView). Mutation-boundary
648
- * errors never reach the canvas; they are returned synchronously to
649
- * the action RPC caller.
750
+ * action. Mutation-boundary errors never reach the canvas; they are
751
+ * returned synchronously to the action RPC caller. The canvas renders
752
+ * no validator of its own — it surfaces BundleState.diagnostics.
650
753
  */
651
754
  interface GraphError {
652
755
  module_key: string;
@@ -718,6 +821,248 @@ interface OutputDef {
718
821
  depends_on: string[];
719
822
  }
720
823
  declare const OutputDef: MessageFns<OutputDef>;
824
+ type LaceEngineService = typeof LaceEngineService;
825
+ declare const LaceEngineService: {
826
+ /** Lifecycle (global; no session_id) */
827
+ readonly initialize: {
828
+ readonly path: "/lace.engine.LaceEngine/Initialize";
829
+ readonly requestStream: false;
830
+ readonly responseStream: false;
831
+ readonly requestSerialize: (value: InitializeRequest) => Buffer;
832
+ readonly requestDeserialize: (value: Buffer) => InitializeRequest;
833
+ readonly responseSerialize: (value: InitializeResponse) => Buffer;
834
+ readonly responseDeserialize: (value: Buffer) => InitializeResponse;
835
+ };
836
+ readonly shutdown: {
837
+ readonly path: "/lace.engine.LaceEngine/Shutdown";
838
+ readonly requestStream: false;
839
+ readonly responseStream: false;
840
+ readonly requestSerialize: (value: Empty) => Buffer;
841
+ readonly requestDeserialize: (value: Buffer) => Empty;
842
+ readonly responseSerialize: (value: ShutdownResponse) => Buffer;
843
+ readonly responseDeserialize: (value: Buffer) => ShutdownResponse;
844
+ };
845
+ /**
846
+ * Session lifecycle. Never fails on a refused source tf — a refused tf
847
+ * opens the session source-refused (`BundleState.source_refused`) with
848
+ * its diagnostics, rather than returning an RPC error.
849
+ */
850
+ readonly sessionOpen: {
851
+ readonly path: "/lace.engine.LaceEngine/SessionOpen";
852
+ readonly requestStream: false;
853
+ readonly responseStream: false;
854
+ readonly requestSerialize: (value: SessionOpenRequest) => Buffer;
855
+ readonly requestDeserialize: (value: Buffer) => SessionOpenRequest;
856
+ readonly responseSerialize: (value: SessionOpenResponse) => Buffer;
857
+ readonly responseDeserialize: (value: Buffer) => SessionOpenResponse;
858
+ };
859
+ readonly testSessionOpen: {
860
+ readonly path: "/lace.engine.LaceEngine/TestSessionOpen";
861
+ readonly requestStream: false;
862
+ readonly responseStream: false;
863
+ readonly requestSerialize: (value: TestSessionOpenRequest) => Buffer;
864
+ readonly requestDeserialize: (value: Buffer) => TestSessionOpenRequest;
865
+ readonly responseSerialize: (value: SessionOpenResponse) => Buffer;
866
+ readonly responseDeserialize: (value: Buffer) => SessionOpenResponse;
867
+ };
868
+ /**
869
+ * Writes the session's working IR to `state.lace`. The one RPC that
870
+ * writes `state.lace`; never writes the source tf.
871
+ */
872
+ readonly sessionSave: {
873
+ readonly path: "/lace.engine.LaceEngine/SessionSave";
874
+ readonly requestStream: false;
875
+ readonly responseStream: false;
876
+ readonly requestSerialize: (value: SessionSaveRequest) => Buffer;
877
+ readonly requestDeserialize: (value: Buffer) => SessionSaveRequest;
878
+ readonly responseSerialize: (value: SessionSaveResponse) => Buffer;
879
+ readonly responseDeserialize: (value: Buffer) => SessionSaveResponse;
880
+ };
881
+ readonly sessionClose: {
882
+ readonly path: "/lace.engine.LaceEngine/SessionClose";
883
+ readonly requestStream: false;
884
+ readonly responseStream: false;
885
+ readonly requestSerialize: (value: SessionCloseRequest) => Buffer;
886
+ readonly requestDeserialize: (value: Buffer) => SessionCloseRequest;
887
+ readonly responseSerialize: (value: SessionCloseResponse) => Buffer;
888
+ readonly responseDeserialize: (value: Buffer) => SessionCloseResponse;
889
+ };
890
+ /**
891
+ * Writes the session's saved Bundle to HCL and re-bases the session
892
+ * onto the written tree's hash. Refuses (FailedPrecondition) while the
893
+ * session is ephemeral, holds the git guard, is source-refused, has an
894
+ * open conflict, or has unsaved edits.
895
+ */
896
+ readonly sessionGenerate: {
897
+ readonly path: "/lace.engine.LaceEngine/SessionGenerate";
898
+ readonly requestStream: false;
899
+ readonly responseStream: false;
900
+ readonly requestSerialize: (value: SessionGenerateRequest) => Buffer;
901
+ readonly requestDeserialize: (value: Buffer) => SessionGenerateRequest;
902
+ readonly responseSerialize: (value: SessionGenerateResponse) => Buffer;
903
+ readonly responseDeserialize: (value: Buffer) => SessionGenerateResponse;
904
+ };
905
+ /**
906
+ * Resolves an open conflict: keep the session's IR for this tree hash,
907
+ * or reload the session from the tree.
908
+ */
909
+ readonly sessionResolveConflict: {
910
+ readonly path: "/lace.engine.LaceEngine/SessionResolveConflict";
911
+ readonly requestStream: false;
912
+ readonly responseStream: false;
913
+ readonly requestSerialize: (value: SessionResolveConflictRequest) => Buffer;
914
+ readonly requestDeserialize: (value: Buffer) => SessionResolveConflictRequest;
915
+ readonly responseSerialize: (value: SessionResolveConflictResponse) => Buffer;
916
+ readonly responseDeserialize: (value: Buffer) => SessionResolveConflictResponse;
917
+ };
918
+ /**
919
+ * Single unified mutation RPC. Every canvas mutation (connect, update
920
+ * input, create group, undo, redo, place module from registry, ...)
921
+ * travels through ApplyAction carrying one or more `Action` oneof
922
+ * cases. Returns `BundleApplyResult { success, errors }`; on success
923
+ * the corresponding `BundleState` snapshot is published to every
924
+ * Subscribe stream on this session (including the caller's). Refused
925
+ * (FailedPrecondition) while the session is source-refused.
926
+ */
927
+ readonly applyAction: {
928
+ readonly path: "/lace.engine.LaceEngine/ApplyAction";
929
+ readonly requestStream: false;
930
+ readonly responseStream: false;
931
+ readonly requestSerialize: (value: ApplyActionRequest) => Buffer;
932
+ readonly requestDeserialize: (value: Buffer) => ApplyActionRequest;
933
+ readonly responseSerialize: (value: BundleApplyResult) => Buffer;
934
+ readonly responseDeserialize: (value: Buffer) => BundleApplyResult;
935
+ };
936
+ /**
937
+ * Runs one CLI command in-process against a fresh command tree. The command's `-o json` output is the stream:
938
+ * each top-level JSON value on stdout is one `json` event; `exit` is always last.
939
+ */
940
+ readonly invoke: {
941
+ readonly path: "/lace.engine.LaceEngine/Invoke";
942
+ readonly requestStream: false;
943
+ readonly responseStream: true;
944
+ readonly requestSerialize: (value: InvokeRequest) => Buffer;
945
+ readonly requestDeserialize: (value: Buffer) => InvokeRequest;
946
+ readonly responseSerialize: (value: InvokeEvent) => Buffer;
947
+ readonly responseDeserialize: (value: Buffer) => InvokeEvent;
948
+ };
949
+ /** Cancels a live Invoke as an explicit user cancel (errUserCancel). A stream closed without this detaches. */
950
+ readonly cancelInvoke: {
951
+ readonly path: "/lace.engine.LaceEngine/CancelInvoke";
952
+ readonly requestStream: false;
953
+ readonly responseStream: false;
954
+ readonly requestSerialize: (value: CancelInvokeRequest) => Buffer;
955
+ readonly requestDeserialize: (value: Buffer) => CancelInvokeRequest;
956
+ readonly responseSerialize: (value: CancelInvokeResponse) => Buffer;
957
+ readonly responseDeserialize: (value: Buffer) => CancelInvokeResponse;
958
+ };
959
+ /**
960
+ * Server-push events scoped to one session. Yields `BundleStateEvent`
961
+ * — full `BundleState` snapshots per session-state change, plus
962
+ * generate-phase pass-throughs. Initial emission is the current
963
+ * BundleState, which acts as the "subscribed" ready signal.
964
+ *
965
+ * Consumers (portal + extension canvas engines) project locally via
966
+ * `@lace-cloud/proto`'s `projectCanvasView(bundle, arrangement?, meta)`.
967
+ * `arrangement` (node positions, group collapse/label) is consumer-owned
968
+ * view state — it never travels over this RPC.
969
+ */
970
+ readonly subscribe: {
971
+ readonly path: "/lace.engine.LaceEngine/Subscribe";
972
+ readonly requestStream: false;
973
+ readonly responseStream: true;
974
+ readonly requestSerialize: (value: SubscribeRequest) => Buffer;
975
+ readonly requestDeserialize: (value: Buffer) => SubscribeRequest;
976
+ readonly responseSerialize: (value: BundleStateEvent) => Buffer;
977
+ readonly responseDeserialize: (value: Buffer) => BundleStateEvent;
978
+ };
979
+ };
980
+ interface LaceEngineClient extends Client {
981
+ /** Lifecycle (global; no session_id) */
982
+ initialize(request: InitializeRequest, callback: (error: ServiceError | null, response: InitializeResponse) => void): ClientUnaryCall;
983
+ initialize(request: InitializeRequest, metadata: Metadata, callback: (error: ServiceError | null, response: InitializeResponse) => void): ClientUnaryCall;
984
+ initialize(request: InitializeRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: InitializeResponse) => void): ClientUnaryCall;
985
+ shutdown(request: Empty, callback: (error: ServiceError | null, response: ShutdownResponse) => void): ClientUnaryCall;
986
+ shutdown(request: Empty, metadata: Metadata, callback: (error: ServiceError | null, response: ShutdownResponse) => void): ClientUnaryCall;
987
+ shutdown(request: Empty, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: ShutdownResponse) => void): ClientUnaryCall;
988
+ /**
989
+ * Session lifecycle. Never fails on a refused source tf — a refused tf
990
+ * opens the session source-refused (`BundleState.source_refused`) with
991
+ * its diagnostics, rather than returning an RPC error.
992
+ */
993
+ sessionOpen(request: SessionOpenRequest, callback: (error: ServiceError | null, response: SessionOpenResponse) => void): ClientUnaryCall;
994
+ sessionOpen(request: SessionOpenRequest, metadata: Metadata, callback: (error: ServiceError | null, response: SessionOpenResponse) => void): ClientUnaryCall;
995
+ sessionOpen(request: SessionOpenRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: SessionOpenResponse) => void): ClientUnaryCall;
996
+ testSessionOpen(request: TestSessionOpenRequest, callback: (error: ServiceError | null, response: SessionOpenResponse) => void): ClientUnaryCall;
997
+ testSessionOpen(request: TestSessionOpenRequest, metadata: Metadata, callback: (error: ServiceError | null, response: SessionOpenResponse) => void): ClientUnaryCall;
998
+ testSessionOpen(request: TestSessionOpenRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: SessionOpenResponse) => void): ClientUnaryCall;
999
+ /**
1000
+ * Writes the session's working IR to `state.lace`. The one RPC that
1001
+ * writes `state.lace`; never writes the source tf.
1002
+ */
1003
+ sessionSave(request: SessionSaveRequest, callback: (error: ServiceError | null, response: SessionSaveResponse) => void): ClientUnaryCall;
1004
+ sessionSave(request: SessionSaveRequest, metadata: Metadata, callback: (error: ServiceError | null, response: SessionSaveResponse) => void): ClientUnaryCall;
1005
+ sessionSave(request: SessionSaveRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: SessionSaveResponse) => void): ClientUnaryCall;
1006
+ sessionClose(request: SessionCloseRequest, callback: (error: ServiceError | null, response: SessionCloseResponse) => void): ClientUnaryCall;
1007
+ sessionClose(request: SessionCloseRequest, metadata: Metadata, callback: (error: ServiceError | null, response: SessionCloseResponse) => void): ClientUnaryCall;
1008
+ sessionClose(request: SessionCloseRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: SessionCloseResponse) => void): ClientUnaryCall;
1009
+ /**
1010
+ * Writes the session's saved Bundle to HCL and re-bases the session
1011
+ * onto the written tree's hash. Refuses (FailedPrecondition) while the
1012
+ * session is ephemeral, holds the git guard, is source-refused, has an
1013
+ * open conflict, or has unsaved edits.
1014
+ */
1015
+ sessionGenerate(request: SessionGenerateRequest, callback: (error: ServiceError | null, response: SessionGenerateResponse) => void): ClientUnaryCall;
1016
+ sessionGenerate(request: SessionGenerateRequest, metadata: Metadata, callback: (error: ServiceError | null, response: SessionGenerateResponse) => void): ClientUnaryCall;
1017
+ sessionGenerate(request: SessionGenerateRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: SessionGenerateResponse) => void): ClientUnaryCall;
1018
+ /**
1019
+ * Resolves an open conflict: keep the session's IR for this tree hash,
1020
+ * or reload the session from the tree.
1021
+ */
1022
+ sessionResolveConflict(request: SessionResolveConflictRequest, callback: (error: ServiceError | null, response: SessionResolveConflictResponse) => void): ClientUnaryCall;
1023
+ sessionResolveConflict(request: SessionResolveConflictRequest, metadata: Metadata, callback: (error: ServiceError | null, response: SessionResolveConflictResponse) => void): ClientUnaryCall;
1024
+ sessionResolveConflict(request: SessionResolveConflictRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: SessionResolveConflictResponse) => void): ClientUnaryCall;
1025
+ /**
1026
+ * Single unified mutation RPC. Every canvas mutation (connect, update
1027
+ * input, create group, undo, redo, place module from registry, ...)
1028
+ * travels through ApplyAction carrying one or more `Action` oneof
1029
+ * cases. Returns `BundleApplyResult { success, errors }`; on success
1030
+ * the corresponding `BundleState` snapshot is published to every
1031
+ * Subscribe stream on this session (including the caller's). Refused
1032
+ * (FailedPrecondition) while the session is source-refused.
1033
+ */
1034
+ applyAction(request: ApplyActionRequest, callback: (error: ServiceError | null, response: BundleApplyResult) => void): ClientUnaryCall;
1035
+ applyAction(request: ApplyActionRequest, metadata: Metadata, callback: (error: ServiceError | null, response: BundleApplyResult) => void): ClientUnaryCall;
1036
+ applyAction(request: ApplyActionRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: BundleApplyResult) => void): ClientUnaryCall;
1037
+ /**
1038
+ * Runs one CLI command in-process against a fresh command tree. The command's `-o json` output is the stream:
1039
+ * each top-level JSON value on stdout is one `json` event; `exit` is always last.
1040
+ */
1041
+ invoke(request: InvokeRequest, options?: Partial<CallOptions>): ClientReadableStream<InvokeEvent>;
1042
+ invoke(request: InvokeRequest, metadata?: Metadata, options?: Partial<CallOptions>): ClientReadableStream<InvokeEvent>;
1043
+ /** Cancels a live Invoke as an explicit user cancel (errUserCancel). A stream closed without this detaches. */
1044
+ cancelInvoke(request: CancelInvokeRequest, callback: (error: ServiceError | null, response: CancelInvokeResponse) => void): ClientUnaryCall;
1045
+ cancelInvoke(request: CancelInvokeRequest, metadata: Metadata, callback: (error: ServiceError | null, response: CancelInvokeResponse) => void): ClientUnaryCall;
1046
+ cancelInvoke(request: CancelInvokeRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: CancelInvokeResponse) => void): ClientUnaryCall;
1047
+ /**
1048
+ * Server-push events scoped to one session. Yields `BundleStateEvent`
1049
+ * — full `BundleState` snapshots per session-state change, plus
1050
+ * generate-phase pass-throughs. Initial emission is the current
1051
+ * BundleState, which acts as the "subscribed" ready signal.
1052
+ *
1053
+ * Consumers (portal + extension canvas engines) project locally via
1054
+ * `@lace-cloud/proto`'s `projectCanvasView(bundle, arrangement?, meta)`.
1055
+ * `arrangement` (node positions, group collapse/label) is consumer-owned
1056
+ * view state — it never travels over this RPC.
1057
+ */
1058
+ subscribe(request: SubscribeRequest, options?: Partial<CallOptions>): ClientReadableStream<BundleStateEvent>;
1059
+ subscribe(request: SubscribeRequest, metadata?: Metadata, options?: Partial<CallOptions>): ClientReadableStream<BundleStateEvent>;
1060
+ }
1061
+ declare const LaceEngineClient: {
1062
+ new (address: string, credentials: ChannelCredentials, options?: Partial<ClientOptions>): LaceEngineClient;
1063
+ service: typeof LaceEngineService;
1064
+ serviceName: string;
1065
+ };
721
1066
  type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
722
1067
  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 {} ? {
723
1068
  [K in keyof T]?: DeepPartial<T[K]>;
@@ -737,138 +1082,50 @@ interface MessageFns<T> {
737
1082
  fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
738
1083
  }
739
1084
 
740
- type RpcErrorCategory = 'engine_unavailable' | 'server_error' | 'timeout';
741
- declare class RpcError extends Error {
742
- readonly category: RpcErrorCategory;
743
- readonly method: string;
744
- readonly cause?: unknown | undefined;
745
- constructor(message: string, category: RpcErrorCategory, method: string, cause?: unknown | undefined);
746
- }
747
- declare function classifyRpcError(err: unknown, method: string): RpcError;
748
- declare function requireClient<T>(client: T | null | undefined, action: string): T;
749
-
750
1085
  declare class LaceTransport {
751
1086
  private inner;
752
1087
  private token;
753
- private _sessionId;
754
1088
  constructor(port: number, token: string);
755
- get sessionId(): string | null;
756
- private makeMetadata;
757
- private requireSessionId;
1089
+ /** The generic engine RPCs `serveEngineBridge` forwards through. */
1090
+ get client(): LaceEngineClient;
1091
+ metadata(): grpc.Metadata;
758
1092
  private unary;
759
1093
  initialize(clientVersion: string): Promise<{
760
1094
  serverVersion: string;
761
- capabilities?: string[];
762
1095
  }>;
763
1096
  shutdown(): Promise<void>;
764
- authStatus(): Promise<{
765
- authenticated: boolean;
766
- }>;
767
- listRegistryModules(params?: {
768
- system?: string;
769
- search?: string;
770
- category?: string;
771
- kind?: string;
772
- page?: number;
773
- limit?: number;
774
- organization?: string;
775
- }): Promise<{
776
- modules: RegistryModule[];
777
- pagination?: {
778
- page: number;
779
- limit: number;
780
- total: number;
781
- };
782
- }>;
783
- registryGetVersions(params: {
784
- name: string;
785
- system: string;
786
- organization?: string;
787
- }): Promise<{
788
- name: string;
789
- system: string;
790
- versions: Array<{
791
- version: string;
792
- description?: string;
793
- }>;
794
- }>;
795
- inspectModule(params: {
796
- name: string;
797
- system: string;
798
- version: string;
799
- organization?: string;
800
- }): Promise<{
801
- name: string;
802
- system: string;
803
- version: string;
804
- module_interface?: {
805
- inputs: Array<{
806
- name: string;
807
- type: string;
808
- required: boolean;
809
- description: string;
810
- default_value?: unknown;
811
- sensitive: boolean;
812
- }>;
813
- outputs: Array<{
814
- name: string;
815
- type: string;
816
- required: boolean;
817
- description: string;
818
- default_value?: unknown;
819
- sensitive: boolean;
820
- }>;
821
- };
822
- }>;
823
- sessionOpen(params: {
824
- file_path: string;
825
- workspace_name: string;
826
- }): Promise<{
827
- session_id: string;
828
- state: BundleState;
829
- }>;
830
- sessionSave(): Promise<{
831
- saved: boolean;
832
- }>;
833
- sessionClose(): Promise<{
834
- status: string;
835
- }>;
836
- sessionGenerate(params: {
837
- output_dir: string;
838
- options?: {
839
- dry_run?: boolean;
840
- format?: boolean;
841
- validate?: boolean;
842
- overwrite?: boolean;
843
- };
844
- }): Promise<{
845
- files_written?: string[];
846
- files?: Record<string, string>;
847
- diagnostics: Diagnostic$1[];
848
- }>;
849
- applyAction(actions: Action[]): Promise<BundleApplyResult>;
850
- queryNodeConfig(params: {
851
- instance_id: string;
852
- }): Promise<NodeConfig>;
853
- queryEdgeConfig(params: {
854
- source: string;
855
- target: string;
856
- }): Promise<EdgeConfig>;
857
- querySettings(): Promise<SettingsConfig>;
858
- queryGraphSummary(): Promise<{
859
- text: string;
860
- }>;
861
- queryValidate(): Promise<{
862
- errors: RenderError[];
863
- }>;
864
- previewPolicyResolution(params: {
865
- remove_resource_instance_id?: string;
866
- }): Promise<PolicyResolution>;
867
1097
  subscribeStream(sessionId: string): grpc.ClientReadableStream<BundleStateEvent>;
868
- dispatch(method: string, params: unknown): Promise<unknown>;
1098
+ /** The Subscribe stream narrowed to the engine facts chat reads. */
1099
+ subscribeFacts(sessionId: string): FactsStream;
869
1100
  dispose(): void;
870
1101
  }
871
1102
 
1103
+ type ChatEngineEvent = {
1104
+ /** The findings of one session state; `[]` when the state has none. */
1105
+ diagnostics?: Diagnostic$1[];
1106
+ generate_error?: {
1107
+ message: string;
1108
+ diagnostics: Diagnostic$1[];
1109
+ };
1110
+ };
1111
+ interface FactsStream {
1112
+ on(ev: 'data', cb: (e: ChatEngineEvent) => void): void;
1113
+ on(ev: 'end', cb: () => void): void;
1114
+ on(ev: 'error', cb: (err: Error) => void): void;
1115
+ cancel(): void;
1116
+ }
1117
+ type FactsSource = Pick<LaceTransport, 'subscribeFacts'>;
1118
+
1119
+ type RpcErrorCategory = 'engine_unavailable' | 'server_error' | 'timeout';
1120
+ declare class RpcError extends Error {
1121
+ readonly category: RpcErrorCategory;
1122
+ readonly method: string;
1123
+ readonly cause?: unknown | undefined;
1124
+ constructor(message: string, category: RpcErrorCategory, method: string, cause?: unknown | undefined);
1125
+ }
1126
+ declare function classifyRpcError(err: unknown, method: string): RpcError;
1127
+ declare function requireClient<T>(client: T | null | undefined, action: string): T;
1128
+
872
1129
  type ServerManagerOpts = {
873
1130
  log: (msg: string) => void;
874
1131
  getBinaryPath: () => string;
@@ -895,35 +1152,4 @@ declare class ServerManager extends EventEmitter {
895
1152
  private maybeRestart;
896
1153
  }
897
1154
 
898
- type SubscribeCallbacks = {
899
- /**
900
- * Fires on every session-state change. The host forwards the raw
901
- * BundleState (Bundle + undo metadata — no layout state; arrangement
902
- * is consumer-owned view state that never travels over the wire) to
903
- * the webview via postMessage; the webview's engine projects locally.
904
- */
905
- onStateUpdated: (state: BundleState) => void;
906
- onGenerateProgress: (phase: string) => void;
907
- onGenerateSuccess: (files: string[]) => void;
908
- onGenerateError: (message: string, diagnostics: Diagnostic$1[]) => void;
909
- /**
910
- * Fires for every authoring-time policy preview emitted by the
911
- * session (debounced ~100ms after each apply, plus once on initial
912
- * Subscribe connect). Forwarded to the webview as a
913
- * `policyResolution` host message.
914
- */
915
- onPolicyResolution: (resolution: PolicyResolution) => void;
916
- onEnd: () => void;
917
- onError: (err: Error) => void;
918
- };
919
- /**
920
- * Wraps a gRPC server-streaming Subscribe call, dispatching typed
921
- * BundleStateEvent fields to callbacks.
922
- */
923
- declare class SubscribeHandler {
924
- private stream;
925
- start(stream: ClientReadableStream<BundleStateEvent>, callbacks: SubscribeCallbacks): void;
926
- stop(): void;
927
- }
928
-
929
- 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 };
1155
+ export { Action, ApplyActionRequest, BundleApplyResult, BundleState, BundleStateEvent, type ChatEngineEvent, type EngineHandshake, type EngineTransport, type FactsSource, type FactsStream, InitializeResponse, LaceTransport, RpcError, type RpcErrorCategory, ServerManager, type ServerState, classifyRpcError, requireClient, serveEngineBridge, spawnEngine };