@lace-cloud/host 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
+ import { MessageBridge } from '@lace-cloud/proto';
2
+ export { Diagnostic, EngineProtocolMismatchError } from '@lace-cloud/proto';
1
3
  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';
4
+ import { Metadata, ServiceError, Client, ClientUnaryCall, CallOptions, ClientReadableStream, ChannelCredentials, ClientOptions } from '@grpc/grpc-js';
5
5
  import { ChildProcess } from 'node:child_process';
6
6
  import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
7
7
  import { EventEmitter } from 'node:events';
@@ -13,7 +13,7 @@ type LiveCall = {
13
13
  type EngineStreamCall = LiveCall & {
14
14
  on(event: 'data', listener: (event: unknown) => void): unknown;
15
15
  on(event: 'end', listener: () => void): unknown;
16
- on(event: 'error', listener: (err: Error) => void): unknown;
16
+ on(event: 'error', listener: (err: ServiceError) => void): unknown;
17
17
  };
18
18
  /**
19
19
  * The subset of `LaceTransport` the bridge forwards through: the two
@@ -23,7 +23,7 @@ type EngineStreamCall = LiveCall & {
23
23
  */
24
24
  type EngineTransport = {
25
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;
26
+ makeUnaryRequest(method: string, serialize: (value: unknown) => Buffer, deserialize: (value: Buffer) => unknown, argument: unknown, metadata: Metadata, callback: (error: ServiceError | null, response?: unknown) => void): unknown;
27
27
  makeServerStreamRequest(method: string, serialize: (value: unknown) => Buffer, deserialize: (value: Buffer) => unknown, argument: unknown, metadata: Metadata): EngineStreamCall;
28
28
  };
29
29
  metadata(): Metadata;
@@ -40,6 +40,15 @@ type EngineHandshake = {
40
40
  port: number;
41
41
  token: string;
42
42
  };
43
+ type EngineInitialize = {
44
+ serverVersion: string;
45
+ protocolVersion: string;
46
+ commandPaths: readonly string[];
47
+ };
48
+ type EngineCredential = {
49
+ apiKey: string | undefined;
50
+ apiBaseUrl: string;
51
+ };
43
52
  type ServerState = 'stopped' | 'starting' | 'running' | 'error';
44
53
 
45
54
  /**
@@ -49,11 +58,214 @@ type ServerState = 'stopped' | 'starting' | 'running' | 'error';
49
58
  * LACE_ENGINE_PORT=<port>
50
59
  * LACE_ENGINE_TOKEN=<64 hex chars>
51
60
  * LACE_ENGINE_READY
61
+ *
62
+ * The engine's stdin is a pipe whose write end this process owns, and its
63
+ * lifetime is the engine's lifetime: the engine reads it and shuts down at end
64
+ * of file, so a spawner that dies — even by SIGKILL — takes its engine with it
65
+ * when the kernel closes the pipe. This module never ends the pipe on its own;
66
+ * the owner ends it through `endEngine` when the engine should stop, and only
67
+ * then, so the engine's own shutdown runs before any signal is sent.
52
68
  */
53
69
  declare function spawnEngine(binaryPath: string, log: (msg: string) => void): Promise<{
54
70
  process: ChildProcess;
55
71
  handshake: EngineHandshake;
56
72
  }>;
73
+ /**
74
+ * End an engine spawned by `spawnEngine`: close its stdin, which is the
75
+ * engine's signal to shut down and exit on its own, and resolve once it has.
76
+ * A signal is sent only to an engine still running after `graceMs`.
77
+ */
78
+ declare function endEngine(proc: ChildProcess, graceMs?: number): Promise<void>;
79
+
80
+ /**
81
+ * `Any` contains an arbitrary serialized protocol buffer message along with a
82
+ * URL that describes the type of the serialized message.
83
+ *
84
+ * Protobuf library provides support to pack/unpack Any values in the form
85
+ * of utility functions or additional generated methods of the Any type.
86
+ *
87
+ * Example 1: Pack and unpack a message in C++.
88
+ *
89
+ * Foo foo = ...;
90
+ * Any any;
91
+ * any.PackFrom(foo);
92
+ * ...
93
+ * if (any.UnpackTo(&foo)) {
94
+ * ...
95
+ * }
96
+ *
97
+ * Example 2: Pack and unpack a message in Java.
98
+ *
99
+ * Foo foo = ...;
100
+ * Any any = Any.pack(foo);
101
+ * ...
102
+ * if (any.is(Foo.class)) {
103
+ * foo = any.unpack(Foo.class);
104
+ * }
105
+ * // or ...
106
+ * if (any.isSameTypeAs(Foo.getDefaultInstance())) {
107
+ * foo = any.unpack(Foo.getDefaultInstance());
108
+ * }
109
+ *
110
+ * Example 3: Pack and unpack a message in Python.
111
+ *
112
+ * foo = Foo(...)
113
+ * any = Any()
114
+ * any.Pack(foo)
115
+ * ...
116
+ * if any.Is(Foo.DESCRIPTOR):
117
+ * any.Unpack(foo)
118
+ * ...
119
+ *
120
+ * Example 4: Pack and unpack a message in Go
121
+ *
122
+ * foo := &pb.Foo{...}
123
+ * any, err := anypb.New(foo)
124
+ * if err != nil {
125
+ * ...
126
+ * }
127
+ * ...
128
+ * foo := &pb.Foo{}
129
+ * if err := any.UnmarshalTo(foo); err != nil {
130
+ * ...
131
+ * }
132
+ *
133
+ * The pack methods provided by protobuf library will by default use
134
+ * 'type.googleapis.com/full.type.name' as the type URL and the unpack
135
+ * methods only use the fully qualified type name after the last '/'
136
+ * in the type URL, for example "foo.bar.com/x/y.z" will yield type
137
+ * name "y.z".
138
+ *
139
+ * JSON
140
+ * ====
141
+ * The JSON representation of an `Any` value uses the regular
142
+ * representation of the deserialized, embedded message, with an
143
+ * additional field `@type` which contains the type URL. Example:
144
+ *
145
+ * package google.profile;
146
+ * message Person {
147
+ * string first_name = 1;
148
+ * string last_name = 2;
149
+ * }
150
+ *
151
+ * {
152
+ * "@type": "type.googleapis.com/google.profile.Person",
153
+ * "firstName": <string>,
154
+ * "lastName": <string>
155
+ * }
156
+ *
157
+ * If the embedded message type is well-known and has a custom JSON
158
+ * representation, that representation will be embedded adding a field
159
+ * `value` which holds the custom JSON in addition to the `@type`
160
+ * field. Example (for message [google.protobuf.Duration][]):
161
+ *
162
+ * {
163
+ * "@type": "type.googleapis.com/google.protobuf.Duration",
164
+ * "value": "1.212s"
165
+ * }
166
+ */
167
+ interface Any {
168
+ /**
169
+ * A URL/resource name that uniquely identifies the type of the serialized
170
+ * protocol buffer message. This string must contain at least
171
+ * one "/" character. The last segment of the URL's path must represent
172
+ * the fully qualified name of the type (as in
173
+ * `path/google.protobuf.Duration`). The name should be in a canonical form
174
+ * (e.g., leading "." is not accepted).
175
+ *
176
+ * In practice, teams usually precompile into the binary all types that they
177
+ * expect it to use in the context of Any. However, for URLs which use the
178
+ * scheme `http`, `https`, or no scheme, one can optionally set up a type
179
+ * server that maps type URLs to message definitions as follows:
180
+ *
181
+ * * If no scheme is provided, `https` is assumed.
182
+ * * An HTTP GET on the URL must yield a [google.protobuf.Type][]
183
+ * value in binary format, or produce an error.
184
+ * * Applications are allowed to cache lookup results based on the
185
+ * URL, or have them precompiled into a binary to avoid any
186
+ * lookup. Therefore, binary compatibility needs to be preserved
187
+ * on changes to types. (Use versioned type names to manage
188
+ * breaking changes.)
189
+ *
190
+ * Note: this functionality is not currently available in the official
191
+ * protobuf release, and it is not used for type URLs beginning with
192
+ * type.googleapis.com. As of May 2023, there are no widely used type server
193
+ * implementations and no plans to implement one.
194
+ *
195
+ * Schemes other than `http`, `https` (or the empty scheme) might be
196
+ * used with implementation specific semantics.
197
+ */
198
+ type_url: string;
199
+ /** Must be a valid serialized protocol buffer of the above specified type. */
200
+ value: Buffer;
201
+ }
202
+ declare const Any: MessageFns$4<Any>;
203
+ type Builtin$4 = Date | Function | Uint8Array | string | number | boolean | undefined;
204
+ type DeepPartial$4<T> = T extends Builtin$4 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$4<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$4<U>> : T extends {} ? {
205
+ [K in keyof T]?: DeepPartial$4<T[K]>;
206
+ } : Partial<T>;
207
+ type KeysOfUnion$4<T> = T extends T ? keyof T : never;
208
+ type Exact$4<P, I extends P> = P extends Builtin$4 ? P : P & {
209
+ [K in keyof P]: Exact$4<P[K], I[K]>;
210
+ } & {
211
+ [K in Exclude<keyof I, KeysOfUnion$4<P>>]: never;
212
+ };
213
+ interface MessageFns$4<T> {
214
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
215
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
216
+ fromJSON(object: any): T;
217
+ toJSON(message: T): unknown;
218
+ create<I extends Exact$4<DeepPartial$4<T>, I>>(base?: I): T;
219
+ fromPartial<I extends Exact$4<DeepPartial$4<T>, I>>(object: I): T;
220
+ }
221
+
222
+ /**
223
+ * The `Status` type defines a logical error model that is suitable for
224
+ * different programming environments, including REST APIs and RPC APIs. It is
225
+ * used by [gRPC](https://github.com/grpc). Each `Status` message contains
226
+ * three pieces of data: error code, error message, and error details.
227
+ *
228
+ * You can find out more about this error model and how to work with it in the
229
+ * [API Design Guide](https://cloud.google.com/apis/design/errors).
230
+ */
231
+ interface Status {
232
+ /**
233
+ * The status code, which should be an enum value of
234
+ * [google.rpc.Code][google.rpc.Code].
235
+ */
236
+ code: number;
237
+ /**
238
+ * A developer-facing error message, which should be in English. Any
239
+ * user-facing error message should be localized and sent in the
240
+ * [google.rpc.Status.details][google.rpc.Status.details] field, or localized
241
+ * by the client.
242
+ */
243
+ message: string;
244
+ /**
245
+ * A list of messages that carry the error details. There is a common set of
246
+ * message types for APIs to use.
247
+ */
248
+ details: Any[];
249
+ }
250
+ declare const Status: MessageFns$3<Status>;
251
+ type Builtin$3 = Date | Function | Uint8Array | string | number | boolean | undefined;
252
+ type DeepPartial$3<T> = T extends Builtin$3 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$3<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$3<U>> : T extends {} ? {
253
+ [K in keyof T]?: DeepPartial$3<T[K]>;
254
+ } : Partial<T>;
255
+ type KeysOfUnion$3<T> = T extends T ? keyof T : never;
256
+ type Exact$3<P, I extends P> = P extends Builtin$3 ? P : P & {
257
+ [K in keyof P]: Exact$3<P[K], I[K]>;
258
+ } & {
259
+ [K in Exclude<keyof I, KeysOfUnion$3<P>>]: never;
260
+ };
261
+ interface MessageFns$3<T> {
262
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
263
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
264
+ fromJSON(object: any): T;
265
+ toJSON(message: T): unknown;
266
+ create<I extends Exact$3<DeepPartial$3<T>, I>>(base?: I): T;
267
+ fromPartial<I extends Exact$3<DeepPartial$3<T>, I>>(object: I): T;
268
+ }
57
269
 
58
270
  /**
59
271
  * A generic empty message that you can re-use to avoid defining duplicated
@@ -87,6 +299,11 @@ interface MessageFns$2<T> {
87
299
  }
88
300
 
89
301
  interface Bundle {
302
+ /**
303
+ * The format of this encoding: "2.0", at which every Expression carries
304
+ * the module references the engine read from it. The engine writes every
305
+ * Bundle at it; an encoding of an earlier version carries none.
306
+ */
90
307
  schema_version: string;
91
308
  kind: string;
92
309
  entry: string;
@@ -239,8 +456,33 @@ declare const OutputRef: MessageFns$1<OutputRef>;
239
456
  interface Expression {
240
457
  lang: string;
241
458
  value: string;
459
+ /**
460
+ * The module calls `value` reads, in source order: what the engine's
461
+ * one reader of references reads from the parse of `value`. The engine
462
+ * fills them each time it encodes an Expression and reads none back, so
463
+ * a consumer takes a reference from here and never from `value`.
464
+ */
465
+ module_references: ModuleReference[];
242
466
  }
243
467
  declare const Expression: MessageFns$1<Expression>;
468
+ /** ModuleReference is one module.<call> an expression reads. */
469
+ interface ModuleReference {
470
+ /** The call read: module.<call>. */
471
+ call: string;
472
+ /**
473
+ * The output read off the call: the first attribute after the call and
474
+ * any instance key in the text, module.<call>.<output> or
475
+ * module.<call>[0].<output>. Unset when the reference reads the whole
476
+ * call: module.<call> alone, through a splat, or by a key an expression
477
+ * computes.
478
+ */
479
+ output?: string | undefined;
480
+ /** An instance key follows the call: [0], ["k"] or [<expression>]. */
481
+ instance_key: boolean;
482
+ /** A splat follows the call or its instance key: [*] or .*. */
483
+ splat: boolean;
484
+ }
485
+ declare const ModuleReference: MessageFns$1<ModuleReference>;
244
486
  interface TerraformBlock {
245
487
  required_version: string;
246
488
  required_providers: {
@@ -307,19 +549,116 @@ declare enum DiagnosticSeverity {
307
549
  DIAGNOSTIC_SEVERITY_INFO = 3,
308
550
  UNRECOGNIZED = -1
309
551
  }
552
+ /**
553
+ * Reason is the one vocabulary of what a failure asks of the developer.
554
+ * The engine attaches it to a refused RPC as a `ReasonDetail` in the
555
+ * status' error details, and a command's failure document names it; a
556
+ * client branches on it, never on the message's text. A failure the API
557
+ * decided carries the API's own code (`ReasonDetail.api_code`), and a
558
+ * reason only where that code has one: every code that asks the developer
559
+ * to sign in again is `REASON_UNAUTHENTICATED`.
560
+ */
561
+ declare enum Reason {
562
+ REASON_UNSPECIFIED = 0,
563
+ /** REASON_NOT_LACE_FORM - Placement: the resolved tree's own certification verdict is not Lace-form. */
564
+ REASON_NOT_LACE_FORM = 1,
565
+ /** REASON_HASH_MISMATCH - Placement: the downloaded tree does not hash to what the registry vouched for. */
566
+ REASON_HASH_MISMATCH = 2,
567
+ /** REASON_REGISTRY_UNAVAILABLE - Placement: the registry could not be reached or answered with no verdict. */
568
+ REASON_REGISTRY_UNAVAILABLE = 3,
569
+ /** REASON_ROOT_LOCKED - SessionOpen: the root's canvas is open in another window. */
570
+ REASON_ROOT_LOCKED = 4,
571
+ /** REASON_UNSAVED - Generate: the session has unsaved edits; save first. */
572
+ REASON_UNSAVED = 5,
573
+ /** REASON_CONFLICT - Generate: the tree moved under the session's base; Keep or Reload first. */
574
+ REASON_CONFLICT = 6,
575
+ /**
576
+ * REASON_SOURCE_REFUSED - Every mutation, save and generate: the session's source tf is refused.
577
+ * module convert and stack import: the tree's tf does not parse, has a
578
+ * non-empty residual report, or its Bundle fails its own validation.
579
+ * stack apply / stack destroy / registry register: a source in the stack
580
+ * does not read, checked before the certification.
581
+ */
582
+ REASON_SOURCE_REFUSED = 7,
583
+ /**
584
+ * REASON_NOT_GIT_REPOSITORY - Generate, module convert, stack import and module fmt: the authoring
585
+ * root is not inside a git working tree.
586
+ */
587
+ REASON_NOT_GIT_REPOSITORY = 8,
588
+ /** REASON_GENERATE_IN_PROGRESS - Generate: a Generate is already running on the session. */
589
+ REASON_GENERATE_IN_PROGRESS = 9,
590
+ /** REASON_NO_ORGANIZATION - A scoped command: no organization is selected. */
591
+ REASON_NO_ORGANIZATION = 10,
592
+ /** REASON_NO_TEAM - A team-scoped command: no team is selected in the organization. */
593
+ REASON_NO_TEAM = 11,
594
+ /**
595
+ * REASON_NO_CERTIFICATION - stack apply / stack destroy / registry register: the root has no
596
+ * certification.
597
+ */
598
+ REASON_NO_CERTIFICATION = 12,
599
+ /**
600
+ * REASON_STALE_CERTIFICATION - stack apply / stack destroy / registry register: the certification
601
+ * does not certify the tree on disk — the tree changed since validate,
602
+ * another lace version wrote it, or its files are torn or mixed from two
603
+ * validates. Running validate again replaces it.
604
+ */
605
+ REASON_STALE_CERTIFICATION = 13,
606
+ /**
607
+ * REASON_TOOL_MISSING - module scan / module docs / module fmt / module validate / module
608
+ * convert / stack import / stack preview: the tool the command runs
609
+ * (tfsec, terraform-docs, the pinned terraform) is not available. convert
610
+ * and stack import run the pinned terraform through the validate each
611
+ * closes on.
612
+ */
613
+ REASON_TOOL_MISSING = 14,
614
+ /**
615
+ * REASON_CROSS_SCOPE - ApplyAction: a wire whose source and target are owned by different
616
+ * modules crosses a group's boundary, which no single-scope edit makes.
617
+ * It is a refusal of the batch's content, carried on its GraphError.
618
+ */
619
+ REASON_CROSS_SCOPE = 15,
620
+ /**
621
+ * REASON_UNAUTHENTICATED - The developer must sign in: a command or a placement that needs
622
+ * credentials finds none (no `lace login`, no LACE_TOKEN), decided
623
+ * before any request; or the API refuses the ones sent with its code
624
+ * `unauthenticated`, which `ReasonDetail.api_code` then names.
625
+ */
626
+ REASON_UNAUTHENTICATED = 16,
627
+ UNRECOGNIZED = -1
628
+ }
310
629
  declare enum ConflictChoice {
311
630
  CONFLICT_CHOICE_UNSPECIFIED = 0,
312
631
  CONFLICT_CHOICE_KEEP = 1,
313
632
  CONFLICT_CHOICE_RELOAD = 2,
314
633
  UNRECOGNIZED = -1
315
634
  }
635
+ /**
636
+ * ReasonDetail rides a refused RPC's status as its one error detail:
637
+ * `grpc-status-details-bin` over gRPC, `details[]` over Connect. A
638
+ * failure Lace decided sets `reason`; one the API decided sets `api_code`
639
+ * to the API's own closed code, passed through unchanged, with the status
640
+ * code that HTTP status maps to, and `reason` where that code has one
641
+ * (`REASON_UNAUTHENTICATED` for the API's `unauthenticated`).
642
+ */
643
+ interface ReasonDetail {
644
+ reason: Reason;
645
+ api_code: string;
646
+ }
647
+ declare const ReasonDetail: MessageFns<ReasonDetail>;
316
648
  interface InitializeRequest {
317
649
  client_version: string;
650
+ /**
651
+ * The protocol version the client speaks: the decimal of
652
+ * PROTOCOL_VERSION_CURRENT as the client was built with it. The engine
653
+ * refuses any other value than its own with FAILED_PRECONDITION, naming
654
+ * both.
655
+ */
318
656
  protocol_version: string;
319
657
  }
320
658
  declare const InitializeRequest: MessageFns<InitializeRequest>;
321
659
  interface InitializeResponse {
322
660
  server_version: string;
661
+ /** the decimal of PROTOCOL_VERSION_CURRENT as the engine was built with it */
323
662
  protocol_version: string;
324
663
  supported_protocols: string[];
325
664
  /** space-joined paths of the non-hidden command tree */
@@ -330,6 +669,17 @@ interface ShutdownResponse {
330
669
  status: string;
331
670
  }
332
671
  declare const ShutdownResponse: MessageFns<ShutdownResponse>;
672
+ interface ReadCredentialResponse {
673
+ /**
674
+ * Present exactly when the developer is signed in. A present key is never
675
+ * empty, so the bytes are those of a plain string field: field 1 is
676
+ * omitted while signed out and carries the key otherwise.
677
+ */
678
+ api_key?: string | undefined;
679
+ /** the API the engine's own commands call */
680
+ api_base_url: string;
681
+ }
682
+ declare const ReadCredentialResponse: MessageFns<ReadCredentialResponse>;
333
683
  interface SessionOpenRequest {
334
684
  ephemeral?: EphemeralSession | undefined;
335
685
  root?: RootSession | undefined;
@@ -360,6 +710,13 @@ interface SessionSaveRequest {
360
710
  }
361
711
  declare const SessionSaveRequest: MessageFns<SessionSaveRequest>;
362
712
  interface SessionSaveResponse {
713
+ /**
714
+ * The revision of the state the save left: the `BundleState.revision`
715
+ * of the frame that carries it, or the session's current revision when
716
+ * nothing was unsaved. A subscriber holds the save once it has received
717
+ * a frame at this revision or a later one.
718
+ */
719
+ revision: number;
363
720
  }
364
721
  declare const SessionSaveResponse: MessageFns<SessionSaveResponse>;
365
722
  interface SessionCloseRequest {
@@ -372,12 +729,25 @@ interface SessionCloseResponse {
372
729
  declare const SessionCloseResponse: MessageFns<SessionCloseResponse>;
373
730
  interface SessionGenerateRequest {
374
731
  session_id: string;
732
+ /**
733
+ * Client-chosen, unique per engine connection, as `invoke_id` is:
734
+ * required, and an id still live is AlreadyExists. Every generate event
735
+ * this call publishes carries it.
736
+ */
737
+ generate_id: string;
375
738
  }
376
739
  declare const SessionGenerateRequest: MessageFns<SessionGenerateRequest>;
377
740
  interface SessionGenerateResponse {
378
741
  files_written: string[];
379
742
  /** the `module validate -o json` document for the written tree */
380
743
  validate_json: string;
744
+ /**
745
+ * The revision of the state the Generate left: the
746
+ * `BundleState.revision` of the frame that carries it, or the session's
747
+ * current revision when it changed nothing. A subscriber holds the
748
+ * Generate once it has received a frame at this revision or a later one.
749
+ */
750
+ revision: number;
381
751
  }
382
752
  declare const SessionGenerateResponse: MessageFns<SessionGenerateResponse>;
383
753
  interface SessionResolveConflictRequest {
@@ -402,23 +772,51 @@ interface Diagnostic {
402
772
  module_key: string;
403
773
  instance_id: string;
404
774
  input_name: string;
775
+ /**
776
+ * The rule the finding breaks, when its source names one: a workspace
777
+ * rule's code, a scan's rule id. Empty for a finding with no rule.
778
+ */
779
+ code: string;
405
780
  }
406
781
  declare const Diagnostic: MessageFns<Diagnostic>;
782
+ /**
783
+ * ConnectAction wires `source`'s output to `target`'s input. A wire is an
784
+ * edit of one module: `scope` owns the target and `source_scope` owns the
785
+ * source, both required, and a wire whose two scopes differ crosses a
786
+ * group's boundary: the batch is refused (`success=false`) with a
787
+ * GraphError carrying `REASON_CROSS_SCOPE`.
788
+ */
407
789
  interface ConnectAction {
408
790
  source: string;
409
791
  target: string;
410
792
  source_output: string;
411
793
  target_input: string;
794
+ scope: string;
795
+ source_scope: string;
412
796
  }
413
797
  declare const ConnectAction: MessageFns<ConnectAction>;
798
+ /**
799
+ * AutoConnectAction wires `source` to `target` by the engine's matching
800
+ * rules, as one batch entry: every output of `source` is scored against
801
+ * every required input of `target` that has no binding
802
+ * (`WiringCandidate.score`), and the pairs are taken from the highest
803
+ * score down, each output and each input wired at most once. Pairs that
804
+ * tie at one score for an input or an output they share are not wired,
805
+ * nor is any port they name: they come back in `BundleApplyResult.ties`
806
+ * for the caller to choose between. A pair of instances with no scored
807
+ * pair at all is refused. Its two scopes are a ConnectAction's.
808
+ */
414
809
  interface AutoConnectAction {
415
810
  source: string;
416
811
  target: string;
812
+ scope: string;
813
+ source_scope: string;
417
814
  }
418
815
  declare const AutoConnectAction: MessageFns<AutoConnectAction>;
419
816
  interface DisconnectAction {
420
817
  target: string;
421
818
  input_name: string;
819
+ scope: string;
422
820
  }
423
821
  declare const DisconnectAction: MessageFns<DisconnectAction>;
424
822
  interface UpdateInputAction {
@@ -428,11 +826,13 @@ interface UpdateInputAction {
428
826
  value: any | undefined;
429
827
  variable: string;
430
828
  expression: string;
829
+ scope: string;
431
830
  }
432
831
  declare const UpdateInputAction: MessageFns<UpdateInputAction>;
433
832
  interface UpdateAllInputsAction {
434
833
  instance_id: string;
435
834
  inputs: InputEntry[];
835
+ scope: string;
436
836
  }
437
837
  declare const UpdateAllInputsAction: MessageFns<UpdateAllInputsAction>;
438
838
  interface InputEntry {
@@ -446,14 +846,17 @@ declare const InputEntry: MessageFns<InputEntry>;
446
846
  interface RenameInstanceAction {
447
847
  old_id: string;
448
848
  new_id: string;
849
+ scope: string;
449
850
  }
450
851
  declare const RenameInstanceAction: MessageFns<RenameInstanceAction>;
451
852
  interface DeleteInstanceAction {
452
853
  instance_id: string;
854
+ scope: string;
453
855
  }
454
856
  declare const DeleteInstanceAction: MessageFns<DeleteInstanceAction>;
455
857
  interface CopyInstancesAction {
456
858
  instance_ids: string[];
859
+ scope: string;
457
860
  }
458
861
  declare const CopyInstancesAction: MessageFns<CopyInstancesAction>;
459
862
  /**
@@ -464,15 +867,17 @@ declare const CopyInstancesAction: MessageFns<CopyInstancesAction>;
464
867
  */
465
868
  interface CreateGroupAction {
466
869
  node_ids: string[];
870
+ scope: string;
467
871
  }
468
872
  declare const CreateGroupAction: MessageFns<CreateGroupAction>;
469
873
  /**
470
- * UngroupAction dissolves the group `group_id` in the current scope: its
471
- * Use is removed and the module it pointed at has its children promoted
472
- * into the parent. Mirrors workspace.UngroupAction.
874
+ * UngroupAction dissolves the group `group_id` in `scope`: its Use is
875
+ * removed and the module it pointed at has its children promoted into
876
+ * the parent. Mirrors workspace.UngroupAction.
473
877
  */
474
878
  interface UngroupAction {
475
879
  group_id: string;
880
+ scope: string;
476
881
  }
477
882
  declare const UngroupAction: MessageFns<UngroupAction>;
478
883
  interface SetVariablesAction {
@@ -515,6 +920,7 @@ declare const LocalEntry: MessageFns<LocalEntry>;
515
920
  interface SetDependsOnAction {
516
921
  instance_id: string;
517
922
  depends_on: string[];
923
+ scope: string;
518
924
  }
519
925
  declare const SetDependsOnAction: MessageFns<SetDependsOnAction>;
520
926
  /**
@@ -528,6 +934,7 @@ interface SetUseProvidersAction {
528
934
  providers: {
529
935
  [key: string]: string;
530
936
  };
937
+ scope: string;
531
938
  }
532
939
  declare const SetUseProvidersAction: MessageFns<SetUseProvidersAction>;
533
940
  /**
@@ -584,15 +991,63 @@ interface ApplyActionRequest {
584
991
  actions: Action[];
585
992
  }
586
993
  declare const ApplyActionRequest: MessageFns<ApplyActionRequest>;
994
+ /**
995
+ * WiringCandidate is one output → input pair the matcher scores between
996
+ * two instances of one module: `source_instance`'s `output` could feed
997
+ * `target_instance`'s `input`, a required input with no binding. `score`
998
+ * is the matcher's: 100 for the same name, 90 for the same last
999
+ * `_`-separated word, 50 when one name contains the other, 30 for the
1000
+ * same type alone; a pair that scores nothing is no candidate.
1001
+ */
1002
+ interface WiringCandidate {
1003
+ source_instance: string;
1004
+ output: string;
1005
+ target_instance: string;
1006
+ input: string;
1007
+ score: number;
1008
+ }
1009
+ declare const WiringCandidate: MessageFns<WiringCandidate>;
1010
+ interface ReadWiringCandidatesRequest {
1011
+ session_id: string;
1012
+ /** The key of the module whose instances are matched (an action's `scope`). */
1013
+ scope: string;
1014
+ /**
1015
+ * Narrows the pairs to those reading this instance's outputs; unset,
1016
+ * every instance of the scope is a source.
1017
+ */
1018
+ source_instance?: string | undefined;
1019
+ /**
1020
+ * Narrows the pairs to those feeding this instance's inputs; unset,
1021
+ * every instance of the scope is a target.
1022
+ */
1023
+ target_instance?: string | undefined;
1024
+ }
1025
+ declare const ReadWiringCandidatesRequest: MessageFns<ReadWiringCandidatesRequest>;
1026
+ interface ReadWiringCandidatesResponse {
1027
+ /**
1028
+ * Highest score first; equal scores in source instance, output, target
1029
+ * instance, input order.
1030
+ */
1031
+ candidates: WiringCandidate[];
1032
+ }
1033
+ declare const ReadWiringCandidatesResponse: MessageFns<ReadWiringCandidatesResponse>;
587
1034
  interface InvokeRequest {
588
1035
  /** client-chosen, unique per engine connection */
589
1036
  invoke_id: string;
590
- /** empty ⇒ sessionless: Workspace commands exit 2 "requires a canvas session" */
591
- session_id: string;
592
1037
  /** e.g. ["stack","preview"] */
593
1038
  path: string[];
594
1039
  /** positionals + flags from toArgv; never -o/--output */
595
1040
  argv: string[];
1041
+ /**
1042
+ * The absolute directory the command runs in, as a terminal invocation
1043
+ * has one: every relative path argument resolves against it. Required,
1044
+ * and it must name an existing directory. The engine picks the
1045
+ * Workspace: the session's own when its pool holds a root session open
1046
+ * on this directory, whatever spelling names it, else the disk
1047
+ * Workspace a terminal invocation builds. A command that reads no
1048
+ * directory is sent with the developer's home.
1049
+ */
1050
+ working_directory: string;
596
1051
  }
597
1052
  declare const InvokeRequest: MessageFns<InvokeRequest>;
598
1053
  interface InvokeEvent {
@@ -604,6 +1059,15 @@ interface InvokeExit {
604
1059
  code: number;
605
1060
  /** tail ≤ 8 KiB */
606
1061
  stderr_tail: string;
1062
+ /**
1063
+ * The command's final document, as its `CommandResult` carries it: the
1064
+ * last JSON document the command wrote to stdout, compact. A failed
1065
+ * command's is its failure document, `{reason, message}` plus the
1066
+ * fields its reason carries; a client tells a failure from a result by
1067
+ * the document's own shape and never reads `stderr_tail` for why. Empty
1068
+ * when the command wrote none.
1069
+ */
1070
+ document: string;
607
1071
  }
608
1072
  declare const InvokeExit: MessageFns<InvokeExit>;
609
1073
  interface CancelInvokeRequest {
@@ -621,12 +1085,16 @@ declare const SubscribeRequest: MessageFns<SubscribeRequest>;
621
1085
  interface GenerateProgress {
622
1086
  stage: string;
623
1087
  message: string;
1088
+ /** the Generate this event belongs to */
1089
+ generate_id: string;
624
1090
  }
625
1091
  declare const GenerateProgress: MessageFns<GenerateProgress>;
626
1092
  interface GenerateSuccess {
627
1093
  files_written: string[];
628
1094
  /** the `module validate -o json` document for the written tree */
629
1095
  validate_json: string;
1096
+ /** the Generate this event belongs to */
1097
+ generate_id: string;
630
1098
  }
631
1099
  declare const GenerateSuccess: MessageFns<GenerateSuccess>;
632
1100
  interface GenerateError {
@@ -637,6 +1105,14 @@ interface GenerateError {
637
1105
  * precondition check or its pre-write re-walk.
638
1106
  */
639
1107
  conflict: Conflict | undefined;
1108
+ /** the Generate this event belongs to */
1109
+ generate_id: string;
1110
+ /**
1111
+ * Why the Generate was refused, the same reason its failed call carries
1112
+ * in its status' error details; unspecified for a failure with no entry
1113
+ * in the vocabulary.
1114
+ */
1115
+ reason: Reason;
640
1116
  }
641
1117
  declare const GenerateError: MessageFns<GenerateError>;
642
1118
  interface Conflict {
@@ -644,16 +1120,40 @@ interface Conflict {
644
1120
  tree_hash: string;
645
1121
  }
646
1122
  declare const Conflict: MessageFns<Conflict>;
1123
+ /**
1124
+ * CommandResult is the result of one command that ran in a session's
1125
+ * root: every `Invoke` whose working directory resolved to a session
1126
+ * publishes exactly one to that session's subscribers when the command
1127
+ * exits, and one whose working directory resolved to no session publishes
1128
+ * nothing. The engine has no knowledge of which command it was: the event
1129
+ * is the path, the exit code and the final document, whatever the
1130
+ * command. The session keeps the last one per path, and a subscriber that
1131
+ * joins later receives the kept set after its first state.
1132
+ */
1133
+ interface CommandResult {
1134
+ /** space-joined, as `command_paths` names it, e.g. "module validate" */
1135
+ path: string;
1136
+ exit_code: number;
1137
+ /**
1138
+ * The last JSON document the command wrote to stdout, compact: a
1139
+ * command that streams NDJSON publishes its closing document and none
1140
+ * of the lines before it. Empty when the command wrote none.
1141
+ */
1142
+ document: string;
1143
+ }
1144
+ declare const CommandResult: MessageFns<CommandResult>;
647
1145
  /**
648
1146
  * 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.
1147
+ * session-state change publishes a full BundleState; generate events and
1148
+ * command results pass through as their own cases. Conflict, unsaved,
1149
+ * ungenerated and the tree hash ride on BundleState.
651
1150
  */
652
1151
  interface BundleStateEvent {
653
1152
  state?: BundleState | undefined;
654
1153
  generate_progress?: GenerateProgress | undefined;
655
1154
  generate_success?: GenerateSuccess | undefined;
656
1155
  generate_error?: GenerateError | undefined;
1156
+ command_result?: CommandResult | undefined;
657
1157
  }
658
1158
  declare const BundleStateEvent: MessageFns<BundleStateEvent>;
659
1159
  /**
@@ -695,12 +1195,28 @@ interface BundleState {
695
1195
  ungenerated: boolean;
696
1196
  /**
697
1197
  * True when the source tf this session opened, or last observed live,
698
- * is refused (unparsable or a Lossless refusal). The engine refuses
1198
+ * is refused (unparsable or lossy). The engine refuses
699
1199
  * every mutation while this holds — edit, undo, redo, save, generate,
700
1200
  * and SessionResolveConflict's Keep/Reload alike — until a live tf
701
1201
  * change parses and clears it.
702
1202
  */
703
1203
  source_refused: boolean;
1204
+ /**
1205
+ * The hash of the root's tree as the session last observed it: the
1206
+ * same hash `module validate` reports as `treeHash`, so a client tells
1207
+ * whether the tree moved since a report by comparing the two. Empty
1208
+ * for an ephemeral session, and for a tree that cannot be hashed.
1209
+ */
1210
+ tree_hash: string;
1211
+ /**
1212
+ * The session's state revision: a per-session counter that advances by
1213
+ * one with every state frame the session publishes, and frames reach a
1214
+ * subscriber in revision order. The state a SessionOpen or a Subscribe
1215
+ * starts with carries the session's current revision. A client compares
1216
+ * it with `BundleApplyResult.revision` to tell whether the frame it
1217
+ * holds already shows a batch it applied.
1218
+ */
1219
+ revision: number;
704
1220
  }
705
1221
  declare const BundleState: MessageFns<BundleState>;
706
1222
  /**
@@ -720,6 +1236,20 @@ interface BundleApplyResult {
720
1236
  success: boolean;
721
1237
  errors: GraphError[];
722
1238
  created: CreatedRef[];
1239
+ /**
1240
+ * The revision of the state the batch produced: the
1241
+ * `BundleState.revision` of the frame that carries it. For a batch
1242
+ * that changed nothing or was refused, the session's current revision.
1243
+ * A subscriber holds the batch's own write once it has received a
1244
+ * frame at this revision or a later one.
1245
+ */
1246
+ revision: number;
1247
+ /**
1248
+ * The pairs an `auto_connect` of the batch did not wire because they
1249
+ * tie: two or more pairs at one score sharing an input or an output.
1250
+ * No port a tied pair names was wired.
1251
+ */
1252
+ ties: WiringCandidate[];
723
1253
  }
724
1254
  declare const BundleApplyResult: MessageFns<BundleApplyResult>;
725
1255
  /**
@@ -746,16 +1276,22 @@ interface CreatedRef {
746
1276
  }
747
1277
  declare const CreatedRef: MessageFns<CreatedRef>;
748
1278
  /**
749
- * GraphError describes an IR-level validation failure that rejected an
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.
1279
+ * GraphError is a refusal of a batch's content: one action the working IR
1280
+ * would not take, located at the module, instance and input it addressed,
1281
+ * with its sentence and, where the refusal has an entry in the one
1282
+ * vocabulary, its reason (`REASON_CROSS_SCOPE` for a wire across a
1283
+ * group's boundary; `REASON_UNSPECIFIED` otherwise). A client branches on
1284
+ * the reason, never on the message. Mutation-boundary errors never reach
1285
+ * the canvas; they are returned synchronously to the action RPC caller.
1286
+ * The canvas renders no validator of its own — it surfaces
1287
+ * BundleState.diagnostics.
753
1288
  */
754
1289
  interface GraphError {
755
1290
  module_key: string;
756
1291
  instance_id: string;
757
1292
  input_name: string;
758
1293
  message: string;
1294
+ reason: Reason;
759
1295
  }
760
1296
  declare const GraphError: MessageFns<GraphError>;
761
1297
  interface ProviderReqView {
@@ -842,6 +1378,28 @@ declare const LaceEngineService: {
842
1378
  readonly responseSerialize: (value: ShutdownResponse) => Buffer;
843
1379
  readonly responseDeserialize: (value: Buffer) => ShutdownResponse;
844
1380
  };
1381
+ /**
1382
+ * Answers the credential this engine holds: the API key `lace login`
1383
+ * saved or `LACE_TOKEN` supplies, read fresh on every call so a `lace
1384
+ * login` or `lace logout` takes effect at once (absent when signed out),
1385
+ * beside the base URL of the API that key is for, the one the engine's
1386
+ * own commands call (the CLI's `config.ResolveBaseURL`). The host
1387
+ * that spawned the engine builds its own authenticated transport to
1388
+ * Lace's API from the two, for the chat package, and never restates
1389
+ * which API; the engine knows nothing of what the host does with them. Served, like every RPC,
1390
+ * only to the bearer of the handshake's session token, and never
1391
+ * forwarded across the webview bridge (`BRIDGE_METHODS`,
1392
+ * @lace-cloud/proto's engine-bridge.ts).
1393
+ */
1394
+ readonly readCredential: {
1395
+ readonly path: "/lace.engine.LaceEngine/ReadCredential";
1396
+ readonly requestStream: false;
1397
+ readonly responseStream: false;
1398
+ readonly requestSerialize: (value: Empty) => Buffer;
1399
+ readonly requestDeserialize: (value: Buffer) => Empty;
1400
+ readonly responseSerialize: (value: ReadCredentialResponse) => Buffer;
1401
+ readonly responseDeserialize: (value: Buffer) => ReadCredentialResponse;
1402
+ };
845
1403
  /**
846
1404
  * Session lifecycle. Never fails on a refused source tf — a refused tf
847
1405
  * opens the session source-refused (`BundleState.source_refused`) with
@@ -891,7 +1449,11 @@ declare const LaceEngineService: {
891
1449
  * Writes the session's saved Bundle to HCL and re-bases the session
892
1450
  * onto the written tree's hash. Refuses (FailedPrecondition) while the
893
1451
  * session is ephemeral, holds the git guard, is source-refused, has an
894
- * open conflict, or has unsaved edits.
1452
+ * open conflict, has unsaved edits, or is already running a Generate
1453
+ * (one at a time per session). Every Generate that reaches a session
1454
+ * publishes its events to that session's subscribers under its own
1455
+ * `generate_id`: its progress, and exactly one closing `generate_success`
1456
+ * or `generate_error` — a refusal included, which also fails the call.
895
1457
  */
896
1458
  readonly sessionGenerate: {
897
1459
  readonly path: "/lace.engine.LaceEngine/SessionGenerate";
@@ -919,9 +1481,13 @@ declare const LaceEngineService: {
919
1481
  * Single unified mutation RPC. Every canvas mutation (connect, update
920
1482
  * input, create group, undo, redo, place module from registry, ...)
921
1483
  * 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
1484
+ * cases. Returns `BundleApplyResult { success, errors, created,
1485
+ * revision }`. A batch is applied whole or not at all: a batch any
1486
+ * action of which is refused is refused whole and publishes nothing; a
1487
+ * batch that changes nothing publishes nothing and adds no undo entry;
1488
+ * an applied batch is one undo entry and one `BundleState` frame,
1489
+ * published to every Subscribe stream on this session (including the
1490
+ * caller's) at the revision the result names. Refused
925
1491
  * (FailedPrecondition) while the session is source-refused.
926
1492
  */
927
1493
  readonly applyAction: {
@@ -933,6 +1499,22 @@ declare const LaceEngineService: {
933
1499
  readonly responseSerialize: (value: BundleApplyResult) => Buffer;
934
1500
  readonly responseDeserialize: (value: Buffer) => BundleApplyResult;
935
1501
  };
1502
+ /**
1503
+ * Reads the output → input pairs the engine's matcher scores between the
1504
+ * instances of one module of a session's working IR: the pairs an
1505
+ * `auto_connect` chooses among, with the scores it chooses by. The
1506
+ * matching rules have this one home; a client that picks a wire for a
1507
+ * request in words ranks these and sends the pair as a `connect`.
1508
+ */
1509
+ readonly readWiringCandidates: {
1510
+ readonly path: "/lace.engine.LaceEngine/ReadWiringCandidates";
1511
+ readonly requestStream: false;
1512
+ readonly responseStream: false;
1513
+ readonly requestSerialize: (value: ReadWiringCandidatesRequest) => Buffer;
1514
+ readonly requestDeserialize: (value: Buffer) => ReadWiringCandidatesRequest;
1515
+ readonly responseSerialize: (value: ReadWiringCandidatesResponse) => Buffer;
1516
+ readonly responseDeserialize: (value: Buffer) => ReadWiringCandidatesResponse;
1517
+ };
936
1518
  /**
937
1519
  * Runs one CLI command in-process against a fresh command tree. The command's `-o json` output is the stream:
938
1520
  * each top-level JSON value on stdout is one `json` event; `exit` is always last.
@@ -958,9 +1540,11 @@ declare const LaceEngineService: {
958
1540
  };
959
1541
  /**
960
1542
  * 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.
1543
+ * — full `BundleState` snapshots per session-state change, generate-phase
1544
+ * pass-throughs, and the result of every command that ran in the
1545
+ * session's root (`CommandResult`). Initial emission is the current
1546
+ * BundleState, which acts as the "subscribed" ready signal, followed by
1547
+ * the last `CommandResult` the session keeps per command path.
964
1548
  *
965
1549
  * Consumers (portal + extension canvas engines) project locally via
966
1550
  * `@lace-cloud/proto`'s `projectCanvasView(bundle, arrangement?, meta)`.
@@ -985,6 +1569,22 @@ interface LaceEngineClient extends Client {
985
1569
  shutdown(request: Empty, callback: (error: ServiceError | null, response: ShutdownResponse) => void): ClientUnaryCall;
986
1570
  shutdown(request: Empty, metadata: Metadata, callback: (error: ServiceError | null, response: ShutdownResponse) => void): ClientUnaryCall;
987
1571
  shutdown(request: Empty, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: ShutdownResponse) => void): ClientUnaryCall;
1572
+ /**
1573
+ * Answers the credential this engine holds: the API key `lace login`
1574
+ * saved or `LACE_TOKEN` supplies, read fresh on every call so a `lace
1575
+ * login` or `lace logout` takes effect at once (absent when signed out),
1576
+ * beside the base URL of the API that key is for, the one the engine's
1577
+ * own commands call (the CLI's `config.ResolveBaseURL`). The host
1578
+ * that spawned the engine builds its own authenticated transport to
1579
+ * Lace's API from the two, for the chat package, and never restates
1580
+ * which API; the engine knows nothing of what the host does with them. Served, like every RPC,
1581
+ * only to the bearer of the handshake's session token, and never
1582
+ * forwarded across the webview bridge (`BRIDGE_METHODS`,
1583
+ * @lace-cloud/proto's engine-bridge.ts).
1584
+ */
1585
+ readCredential(request: Empty, callback: (error: ServiceError | null, response: ReadCredentialResponse) => void): ClientUnaryCall;
1586
+ readCredential(request: Empty, metadata: Metadata, callback: (error: ServiceError | null, response: ReadCredentialResponse) => void): ClientUnaryCall;
1587
+ readCredential(request: Empty, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: ReadCredentialResponse) => void): ClientUnaryCall;
988
1588
  /**
989
1589
  * Session lifecycle. Never fails on a refused source tf — a refused tf
990
1590
  * opens the session source-refused (`BundleState.source_refused`) with
@@ -1010,7 +1610,11 @@ interface LaceEngineClient extends Client {
1010
1610
  * Writes the session's saved Bundle to HCL and re-bases the session
1011
1611
  * onto the written tree's hash. Refuses (FailedPrecondition) while the
1012
1612
  * session is ephemeral, holds the git guard, is source-refused, has an
1013
- * open conflict, or has unsaved edits.
1613
+ * open conflict, has unsaved edits, or is already running a Generate
1614
+ * (one at a time per session). Every Generate that reaches a session
1615
+ * publishes its events to that session's subscribers under its own
1616
+ * `generate_id`: its progress, and exactly one closing `generate_success`
1617
+ * or `generate_error` — a refusal included, which also fails the call.
1014
1618
  */
1015
1619
  sessionGenerate(request: SessionGenerateRequest, callback: (error: ServiceError | null, response: SessionGenerateResponse) => void): ClientUnaryCall;
1016
1620
  sessionGenerate(request: SessionGenerateRequest, metadata: Metadata, callback: (error: ServiceError | null, response: SessionGenerateResponse) => void): ClientUnaryCall;
@@ -1026,14 +1630,28 @@ interface LaceEngineClient extends Client {
1026
1630
  * Single unified mutation RPC. Every canvas mutation (connect, update
1027
1631
  * input, create group, undo, redo, place module from registry, ...)
1028
1632
  * 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
1633
+ * cases. Returns `BundleApplyResult { success, errors, created,
1634
+ * revision }`. A batch is applied whole or not at all: a batch any
1635
+ * action of which is refused is refused whole and publishes nothing; a
1636
+ * batch that changes nothing publishes nothing and adds no undo entry;
1637
+ * an applied batch is one undo entry and one `BundleState` frame,
1638
+ * published to every Subscribe stream on this session (including the
1639
+ * caller's) at the revision the result names. Refused
1032
1640
  * (FailedPrecondition) while the session is source-refused.
1033
1641
  */
1034
1642
  applyAction(request: ApplyActionRequest, callback: (error: ServiceError | null, response: BundleApplyResult) => void): ClientUnaryCall;
1035
1643
  applyAction(request: ApplyActionRequest, metadata: Metadata, callback: (error: ServiceError | null, response: BundleApplyResult) => void): ClientUnaryCall;
1036
1644
  applyAction(request: ApplyActionRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: BundleApplyResult) => void): ClientUnaryCall;
1645
+ /**
1646
+ * Reads the output → input pairs the engine's matcher scores between the
1647
+ * instances of one module of a session's working IR: the pairs an
1648
+ * `auto_connect` chooses among, with the scores it chooses by. The
1649
+ * matching rules have this one home; a client that picks a wire for a
1650
+ * request in words ranks these and sends the pair as a `connect`.
1651
+ */
1652
+ readWiringCandidates(request: ReadWiringCandidatesRequest, callback: (error: ServiceError | null, response: ReadWiringCandidatesResponse) => void): ClientUnaryCall;
1653
+ readWiringCandidates(request: ReadWiringCandidatesRequest, metadata: Metadata, callback: (error: ServiceError | null, response: ReadWiringCandidatesResponse) => void): ClientUnaryCall;
1654
+ readWiringCandidates(request: ReadWiringCandidatesRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: ReadWiringCandidatesResponse) => void): ClientUnaryCall;
1037
1655
  /**
1038
1656
  * Runs one CLI command in-process against a fresh command tree. The command's `-o json` output is the stream:
1039
1657
  * each top-level JSON value on stdout is one `json` event; `exit` is always last.
@@ -1046,9 +1664,11 @@ interface LaceEngineClient extends Client {
1046
1664
  cancelInvoke(request: CancelInvokeRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: CancelInvokeResponse) => void): ClientUnaryCall;
1047
1665
  /**
1048
1666
  * 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.
1667
+ * — full `BundleState` snapshots per session-state change, generate-phase
1668
+ * pass-throughs, and the result of every command that ran in the
1669
+ * session's root (`CommandResult`). Initial emission is the current
1670
+ * BundleState, which acts as the "subscribed" ready signal, followed by
1671
+ * the last `CommandResult` the session keeps per command path.
1052
1672
  *
1053
1673
  * Consumers (portal + extension canvas engines) project locally via
1054
1674
  * `@lace-cloud/proto`'s `projectCanvasView(bundle, arrangement?, meta)`.
@@ -1082,6 +1702,33 @@ interface MessageFns<T> {
1082
1702
  fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
1083
1703
  }
1084
1704
 
1705
+ type RpcErrorCategory = 'engine_unavailable' | 'server_error' | 'timeout';
1706
+ /**
1707
+ * A failed engine call, classified: `category` says how it failed (the
1708
+ * engine is gone, it timed out, or it answered with an error), `reason` and
1709
+ * `apiCode` why, as the engine's status details name it — the refusal's
1710
+ * entry in the one vocabulary (`REASON_UNSPECIFIED` when it named none or no
1711
+ * status came back) and, for a failure the API decided, the API's own code.
1712
+ * A host branches on these, never on `message`.
1713
+ */
1714
+ declare class RpcError extends Error {
1715
+ readonly category: RpcErrorCategory;
1716
+ readonly method: string;
1717
+ readonly cause?: unknown | undefined;
1718
+ readonly reason: Reason;
1719
+ readonly apiCode?: string | undefined;
1720
+ constructor(message: string, category: RpcErrorCategory, method: string, cause?: unknown | undefined, reason?: Reason, apiCode?: string | undefined);
1721
+ }
1722
+ /**
1723
+ * Classifies a failed engine call by data alone: a gRPC status by its code,
1724
+ * with the reason and API code its details carry (`readReasonDetail`, the
1725
+ * reader the bridge's error frame uses); an `RpcError` is already
1726
+ * classified and comes back as it is; anything else carries no status and
1727
+ * is `server_error`. No message text is read.
1728
+ */
1729
+ declare function classifyRpcError(err: unknown, method: string): RpcError;
1730
+ declare function requireClient<T>(client: T | null | undefined, action: string): T;
1731
+
1085
1732
  declare class LaceTransport {
1086
1733
  private inner;
1087
1734
  private token;
@@ -1090,42 +1737,13 @@ declare class LaceTransport {
1090
1737
  get client(): LaceEngineClient;
1091
1738
  metadata(): grpc.Metadata;
1092
1739
  private unary;
1093
- initialize(clientVersion: string): Promise<{
1094
- serverVersion: string;
1095
- }>;
1740
+ initialize(clientVersion: string): Promise<EngineInitialize>;
1096
1741
  shutdown(): Promise<void>;
1742
+ readCredential(): Promise<EngineCredential>;
1097
1743
  subscribeStream(sessionId: string): grpc.ClientReadableStream<BundleStateEvent>;
1098
- /** The Subscribe stream narrowed to the engine facts chat reads. */
1099
- subscribeFacts(sessionId: string): FactsStream;
1100
1744
  dispose(): void;
1101
1745
  }
1102
1746
 
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
-
1129
1747
  type ServerManagerOpts = {
1130
1748
  log: (msg: string) => void;
1131
1749
  getBinaryPath: () => string;
@@ -1134,6 +1752,8 @@ type ServerManagerOpts = {
1134
1752
  declare class ServerManager extends EventEmitter {
1135
1753
  private process;
1136
1754
  private _transport;
1755
+ private _handshake;
1756
+ private _initialized;
1137
1757
  private state;
1138
1758
  private restartCount;
1139
1759
  private restartScheduled;
@@ -1142,14 +1762,29 @@ declare class ServerManager extends EventEmitter {
1142
1762
  private readonly getBinaryPath;
1143
1763
  private readonly getAutoRestart;
1144
1764
  constructor(opts: ServerManagerOpts);
1765
+ /** The connection to the running engine; null whenever none is running. */
1145
1766
  get transport(): LaceTransport | null;
1767
+ /** What the running engine printed on its handshake; null whenever none is running. */
1768
+ get handshake(): EngineHandshake | null;
1769
+ /** What the running engine answered `Initialize` with; null whenever none is running. */
1770
+ get initialized(): EngineInitialize | null;
1146
1771
  get currentState(): ServerState;
1772
+ /**
1773
+ * Spawns the engine and connects to it. The handshake's protocol version
1774
+ * is compared with the one this library speaks before any RPC is sent
1775
+ * (`checkEngineProtocol`, `@lace-cloud/proto`, the check the canvas makes
1776
+ * of `Initialize`'s answer): an engine that names another rejects with
1777
+ * `EngineProtocolMismatchError`.
1778
+ * An engine a failed start spawned is ended before the rejection.
1779
+ */
1147
1780
  start(): Promise<void>;
1148
1781
  stop(): Promise<void>;
1149
1782
  restart(): Promise<void>;
1150
- dispose(): void;
1783
+ dispose(): Promise<void>;
1784
+ private engineEnded;
1785
+ private release;
1151
1786
  private setState;
1152
1787
  private maybeRestart;
1153
1788
  }
1154
1789
 
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 };
1790
+ export { Action, ApplyActionRequest, BundleApplyResult, BundleState, BundleStateEvent, type EngineCredential, type EngineHandshake, type EngineInitialize, type EngineTransport, InitializeResponse, InvokeRequest, LaceTransport, ReadWiringCandidatesRequest, ReadWiringCandidatesResponse, ReasonDetail, RpcError, type RpcErrorCategory, ServerManager, type ServerState, SessionCloseResponse, SessionOpenResponse, Status, classifyRpcError, endEngine, requireClient, serveEngineBridge, spawnEngine };