@lace-cloud/host 0.18.0 → 0.19.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/README.md CHANGED
@@ -5,9 +5,8 @@ Node.js. Provides the gRPC-JS transport, server lifecycle, handshake
5
5
  parser, RPC error classifier, and the engine bridge server that a
6
6
  webview (VS Code, JetBrains) talks to over `postMessage`.
7
7
 
8
- Consumed by the VS Code extension shell, `@lace-cloud/chat-core` (the
9
- proactivity watcher reads engine facts through `subscribeFacts`), and
10
- any future host adapter (portal BFF, JetBrains plugin host).
8
+ Consumed by the VS Code extension shell and any future host adapter
9
+ (portal BFF, JetBrains plugin host).
11
10
 
12
11
  ## Install
13
12
 
@@ -19,6 +18,7 @@ npm install @lace-cloud/host
19
18
 
20
19
  ```ts
21
20
  import {
21
+ EngineProtocolMismatchError,
22
22
  ServerManager,
23
23
  serveEngineBridge,
24
24
  classifyRpcError,
@@ -33,7 +33,25 @@ const server = new ServerManager({
33
33
  getAutoRestart: () => true,
34
34
  });
35
35
  server.on('state', (state) => console.log(`engine: ${state}`));
36
- await server.start();
36
+
37
+ // start() compares the protocol version on the engine's handshake with the
38
+ // one this library speaks before it sends any RPC. An engine that names
39
+ // another is ended and start() rejects with EngineProtocolMismatchError,
40
+ // which carries the engine's version and both protocol versions;
41
+ // `engineTooOld` says which side is behind. What to show is the host's.
42
+ try {
43
+ await server.start();
44
+ } catch (err) {
45
+ if (err instanceof EngineProtocolMismatchError && err.engineTooOld) {
46
+ console.error(`Lace CLI ${err.engineVersion} is too old for this host: update it`);
47
+ }
48
+ throw err;
49
+ }
50
+
51
+ // While the engine runs, what it printed on its handshake and what it
52
+ // answered Initialize with are readable; both are null once it stops or
53
+ // dies, and so is the transport.
54
+ console.log(server.handshake?.protocolVersion, server.initialized?.commandPaths);
37
55
 
38
56
  // LaceTransport is constructed by ServerManager once the handshake
39
57
  // completes. Read it via server.transport.
@@ -49,21 +67,17 @@ const dispose = serveEngineBridge(webviewBridge, transport);
49
67
  // … later, on webview dispose:
50
68
  dispose();
51
69
 
52
- // Engine facts for chat — the validator's findings of each session
53
- // state and generation failures, never the Bundle. Chat-core takes a
54
- // FactsSource (anything with subscribeFacts) and reads ChatEngineEvent.
55
- const facts = transport.subscribeFacts(sessionId);
56
- facts.on('data', (e) => {
57
- if (e.diagnostics) { /* this state's findings; [] when it has none */ }
58
- if (e.generate_error) { /* generation failed */ }
59
- });
70
+ // The manager's dispose is its stop: it resolves once the engine has
71
+ // exited, so a host that tears down can await the engine's end.
72
+ await server.dispose();
60
73
  ```
61
74
 
62
75
  ## Vscode-free contract
63
76
 
64
- This package never imports `vscode`. The VS Code-coupled host
65
- primitives (panel classes, webview-html builder, RPC-error toast) live
66
- in [`vs-code-extension/src/vscode/`](https://github.com/lace-cloud/vs-code-extension/tree/main/src/vscode).
77
+ This package never imports `vscode`. Everything that does (the webview
78
+ panels, their HTML, the dialogs and notices) lives in the VS Code
79
+ extension's own repository,
80
+ [`lace-cloud/vs-code-extension`](https://github.com/lace-cloud/vs-code-extension).
67
81
 
68
82
  ## License
69
83