@lace-cloud/host 0.24.0 → 0.26.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 +8 -1
- package/dist/index.cjs +113 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +50 -10
- package/dist/index.d.ts +50 -10
- package/dist/index.mjs +106 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -47,6 +47,17 @@ type EngineInitialize = {
|
|
|
47
47
|
};
|
|
48
48
|
type ServerState = 'stopped' | 'starting' | 'running' | 'error';
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* The engine binary could not be started, so no engine ran. `cause` is the
|
|
52
|
+
* spawn error itself and `code` its system code — `ENOENT` when no executable
|
|
53
|
+
* is found at the path or on PATH. A host branches on `code`, never on
|
|
54
|
+
* `message`.
|
|
55
|
+
*/
|
|
56
|
+
declare class EngineSpawnError extends Error {
|
|
57
|
+
readonly cause: NodeJS.ErrnoException;
|
|
58
|
+
constructor(cause: NodeJS.ErrnoException);
|
|
59
|
+
get code(): string | undefined;
|
|
60
|
+
}
|
|
50
61
|
/**
|
|
51
62
|
* Spawn `lace engine` and parse the 5-line handshake:
|
|
52
63
|
* LACE_ENGINE_VERSION=<semver>
|
|
@@ -55,6 +66,10 @@ type ServerState = 'stopped' | 'starting' | 'running' | 'error';
|
|
|
55
66
|
* LACE_ENGINE_TOKEN=<64 hex chars>
|
|
56
67
|
* LACE_ENGINE_READY
|
|
57
68
|
*
|
|
69
|
+
* Each stdout line is logged as the engine wrote it, except the token line,
|
|
70
|
+
* which is logged masked. A binary that cannot be started rejects with
|
|
71
|
+
* `EngineSpawnError`.
|
|
72
|
+
*
|
|
58
73
|
* The engine's stdin is a pipe whose write end this process owns, and its
|
|
59
74
|
* lifetime is the engine's lifetime: the engine reads it and shuts down at end
|
|
60
75
|
* of file, so a spawner that dies — even by SIGKILL — takes its engine with it
|
|
@@ -675,11 +690,15 @@ declare enum ConflictChoice {
|
|
|
675
690
|
* failure Lace decided sets `reason`; one the API decided sets `api_code`
|
|
676
691
|
* to the API's own closed code, passed through unchanged, with the status
|
|
677
692
|
* code that HTTP status maps to, and `reason` where that code has one
|
|
678
|
-
* (`REASON_UNAUTHENTICATED` for the API's `unauthenticated`)
|
|
693
|
+
* (`REASON_UNAUTHENTICATED` for the API's `unauthenticated`), and
|
|
694
|
+
* `request_id` to the id the API answered the refused request with, when
|
|
695
|
+
* it named one: the id a person quotes to Lace's support. The status
|
|
696
|
+
* message is the sentence the API wrote; neither field is spelled into it.
|
|
679
697
|
*/
|
|
680
698
|
interface ReasonDetail {
|
|
681
699
|
reason: Reason;
|
|
682
700
|
api_code: string;
|
|
701
|
+
request_id: string;
|
|
683
702
|
}
|
|
684
703
|
declare const ReasonDetail: MessageFns<ReasonDetail>;
|
|
685
704
|
interface InitializeRequest {
|
|
@@ -1174,8 +1193,22 @@ declare const InvokeRequest: MessageFns<InvokeRequest>;
|
|
|
1174
1193
|
interface InvokeEvent {
|
|
1175
1194
|
json?: string | undefined;
|
|
1176
1195
|
exit?: InvokeExit | undefined;
|
|
1196
|
+
/**
|
|
1197
|
+
* The engine accepted the request and runs the command: sent exactly
|
|
1198
|
+
* once, before any `json` or `exit`. A stream that fails before it
|
|
1199
|
+
* never ran the command; one that fails after it and before `exit` ran
|
|
1200
|
+
* the command to an outcome its client never received.
|
|
1201
|
+
*/
|
|
1202
|
+
started?: InvokeStarted | undefined;
|
|
1177
1203
|
}
|
|
1178
1204
|
declare const InvokeEvent: MessageFns<InvokeEvent>;
|
|
1205
|
+
/**
|
|
1206
|
+
* An Invoke's command is running. It carries nothing: its arrival is the
|
|
1207
|
+
* fact.
|
|
1208
|
+
*/
|
|
1209
|
+
interface InvokeStarted {
|
|
1210
|
+
}
|
|
1211
|
+
declare const InvokeStarted: MessageFns<InvokeStarted>;
|
|
1179
1212
|
interface InvokeExit {
|
|
1180
1213
|
code: number;
|
|
1181
1214
|
/** tail ≤ 8 KiB */
|
|
@@ -1641,8 +1674,9 @@ declare const LaceEngineService: {
|
|
|
1641
1674
|
readonly responseDeserialize: (value: Buffer) => ReadWiringCandidatesResponse;
|
|
1642
1675
|
};
|
|
1643
1676
|
/**
|
|
1644
|
-
* Runs one CLI command in-process against a fresh command tree.
|
|
1645
|
-
*
|
|
1677
|
+
* Runs one CLI command in-process against a fresh command tree. `started` is first, once the engine has accepted
|
|
1678
|
+
* the request and before the command runs; the command's `-o json` output follows: each top-level JSON value on
|
|
1679
|
+
* stdout is one `json` event; `exit` is always last.
|
|
1646
1680
|
*/
|
|
1647
1681
|
readonly invoke: {
|
|
1648
1682
|
readonly path: "/lace.engine.LaceEngine/Invoke";
|
|
@@ -1763,8 +1797,9 @@ interface LaceEngineClient extends Client {
|
|
|
1763
1797
|
readWiringCandidates(request: ReadWiringCandidatesRequest, metadata: Metadata, callback: (error: ServiceError | null, response: ReadWiringCandidatesResponse) => void): ClientUnaryCall;
|
|
1764
1798
|
readWiringCandidates(request: ReadWiringCandidatesRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: ReadWiringCandidatesResponse) => void): ClientUnaryCall;
|
|
1765
1799
|
/**
|
|
1766
|
-
* Runs one CLI command in-process against a fresh command tree.
|
|
1767
|
-
*
|
|
1800
|
+
* Runs one CLI command in-process against a fresh command tree. `started` is first, once the engine has accepted
|
|
1801
|
+
* the request and before the command runs; the command's `-o json` output follows: each top-level JSON value on
|
|
1802
|
+
* stdout is one `json` event; `exit` is always last.
|
|
1768
1803
|
*/
|
|
1769
1804
|
invoke(request: InvokeRequest, options?: Partial<CallOptions>): ClientReadableStream<InvokeEvent>;
|
|
1770
1805
|
invoke(request: InvokeRequest, metadata?: Metadata, options?: Partial<CallOptions>): ClientReadableStream<InvokeEvent>;
|
|
@@ -1818,8 +1853,10 @@ type RpcErrorCategory = 'engine_unavailable' | 'server_error' | 'timeout';
|
|
|
1818
1853
|
* engine is gone, it timed out, or it answered with an error), `reason` and
|
|
1819
1854
|
* `apiCode` why, as the engine's status details name it — the refusal's
|
|
1820
1855
|
* entry in the one vocabulary (`REASON_UNSPECIFIED` when it named none or no
|
|
1821
|
-
* status came back) and, for a failure the API decided, the API's own code
|
|
1822
|
-
*
|
|
1856
|
+
* status came back) and, for a failure the API decided, the API's own code —
|
|
1857
|
+
* and `requestId` the id the API answered the refused request with, the id
|
|
1858
|
+
* a person quotes to Lace's support. A host branches on these, never on
|
|
1859
|
+
* `message`.
|
|
1823
1860
|
*/
|
|
1824
1861
|
declare class RpcError extends Error {
|
|
1825
1862
|
readonly category: RpcErrorCategory;
|
|
@@ -1827,7 +1864,8 @@ declare class RpcError extends Error {
|
|
|
1827
1864
|
readonly cause?: unknown | undefined;
|
|
1828
1865
|
readonly reason: Reason;
|
|
1829
1866
|
readonly apiCode?: string | undefined;
|
|
1830
|
-
|
|
1867
|
+
readonly requestId?: string | undefined;
|
|
1868
|
+
constructor(message: string, category: RpcErrorCategory, method: string, cause?: unknown | undefined, reason?: Reason, apiCode?: string | undefined, requestId?: string | undefined);
|
|
1831
1869
|
}
|
|
1832
1870
|
/**
|
|
1833
1871
|
* Classifies a failed engine call by data alone: a gRPC status by its code,
|
|
@@ -1883,7 +1921,9 @@ declare class ServerManager extends EventEmitter {
|
|
|
1883
1921
|
* is compared with the one this library speaks before any RPC is sent
|
|
1884
1922
|
* (`checkEngineProtocol`, `@lace-cloud/proto`, the check the canvas makes
|
|
1885
1923
|
* of `Initialize`'s answer): an engine that names another rejects with
|
|
1886
|
-
* `EngineProtocolMismatchError`.
|
|
1924
|
+
* `EngineProtocolMismatchError`. A binary that cannot be started rejects
|
|
1925
|
+
* with `EngineSpawnError`, whose `code` is the spawn error's (`ENOENT`
|
|
1926
|
+
* when no executable is found).
|
|
1887
1927
|
* An engine a failed start spawned is ended before the rejection.
|
|
1888
1928
|
*/
|
|
1889
1929
|
start(): Promise<void>;
|
|
@@ -1896,4 +1936,4 @@ declare class ServerManager extends EventEmitter {
|
|
|
1896
1936
|
private maybeRestart;
|
|
1897
1937
|
}
|
|
1898
1938
|
|
|
1899
|
-
export { Action, ApplyActionRequest, BundleApplyResult, BundleState, BundleStateEvent, 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 };
|
|
1939
|
+
export { Action, ApplyActionRequest, BundleApplyResult, BundleState, BundleStateEvent, type EngineHandshake, type EngineInitialize, EngineSpawnError, type EngineTransport, InitializeResponse, InvokeEvent, InvokeRequest, LaceTransport, ReadWiringCandidatesRequest, ReadWiringCandidatesResponse, ReasonDetail, RpcError, type RpcErrorCategory, ServerManager, type ServerState, SessionCloseResponse, SessionOpenResponse, Status, classifyRpcError, endEngine, requireClient, serveEngineBridge, spawnEngine };
|
package/dist/index.d.ts
CHANGED
|
@@ -47,6 +47,17 @@ type EngineInitialize = {
|
|
|
47
47
|
};
|
|
48
48
|
type ServerState = 'stopped' | 'starting' | 'running' | 'error';
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* The engine binary could not be started, so no engine ran. `cause` is the
|
|
52
|
+
* spawn error itself and `code` its system code — `ENOENT` when no executable
|
|
53
|
+
* is found at the path or on PATH. A host branches on `code`, never on
|
|
54
|
+
* `message`.
|
|
55
|
+
*/
|
|
56
|
+
declare class EngineSpawnError extends Error {
|
|
57
|
+
readonly cause: NodeJS.ErrnoException;
|
|
58
|
+
constructor(cause: NodeJS.ErrnoException);
|
|
59
|
+
get code(): string | undefined;
|
|
60
|
+
}
|
|
50
61
|
/**
|
|
51
62
|
* Spawn `lace engine` and parse the 5-line handshake:
|
|
52
63
|
* LACE_ENGINE_VERSION=<semver>
|
|
@@ -55,6 +66,10 @@ type ServerState = 'stopped' | 'starting' | 'running' | 'error';
|
|
|
55
66
|
* LACE_ENGINE_TOKEN=<64 hex chars>
|
|
56
67
|
* LACE_ENGINE_READY
|
|
57
68
|
*
|
|
69
|
+
* Each stdout line is logged as the engine wrote it, except the token line,
|
|
70
|
+
* which is logged masked. A binary that cannot be started rejects with
|
|
71
|
+
* `EngineSpawnError`.
|
|
72
|
+
*
|
|
58
73
|
* The engine's stdin is a pipe whose write end this process owns, and its
|
|
59
74
|
* lifetime is the engine's lifetime: the engine reads it and shuts down at end
|
|
60
75
|
* of file, so a spawner that dies — even by SIGKILL — takes its engine with it
|
|
@@ -675,11 +690,15 @@ declare enum ConflictChoice {
|
|
|
675
690
|
* failure Lace decided sets `reason`; one the API decided sets `api_code`
|
|
676
691
|
* to the API's own closed code, passed through unchanged, with the status
|
|
677
692
|
* code that HTTP status maps to, and `reason` where that code has one
|
|
678
|
-
* (`REASON_UNAUTHENTICATED` for the API's `unauthenticated`)
|
|
693
|
+
* (`REASON_UNAUTHENTICATED` for the API's `unauthenticated`), and
|
|
694
|
+
* `request_id` to the id the API answered the refused request with, when
|
|
695
|
+
* it named one: the id a person quotes to Lace's support. The status
|
|
696
|
+
* message is the sentence the API wrote; neither field is spelled into it.
|
|
679
697
|
*/
|
|
680
698
|
interface ReasonDetail {
|
|
681
699
|
reason: Reason;
|
|
682
700
|
api_code: string;
|
|
701
|
+
request_id: string;
|
|
683
702
|
}
|
|
684
703
|
declare const ReasonDetail: MessageFns<ReasonDetail>;
|
|
685
704
|
interface InitializeRequest {
|
|
@@ -1174,8 +1193,22 @@ declare const InvokeRequest: MessageFns<InvokeRequest>;
|
|
|
1174
1193
|
interface InvokeEvent {
|
|
1175
1194
|
json?: string | undefined;
|
|
1176
1195
|
exit?: InvokeExit | undefined;
|
|
1196
|
+
/**
|
|
1197
|
+
* The engine accepted the request and runs the command: sent exactly
|
|
1198
|
+
* once, before any `json` or `exit`. A stream that fails before it
|
|
1199
|
+
* never ran the command; one that fails after it and before `exit` ran
|
|
1200
|
+
* the command to an outcome its client never received.
|
|
1201
|
+
*/
|
|
1202
|
+
started?: InvokeStarted | undefined;
|
|
1177
1203
|
}
|
|
1178
1204
|
declare const InvokeEvent: MessageFns<InvokeEvent>;
|
|
1205
|
+
/**
|
|
1206
|
+
* An Invoke's command is running. It carries nothing: its arrival is the
|
|
1207
|
+
* fact.
|
|
1208
|
+
*/
|
|
1209
|
+
interface InvokeStarted {
|
|
1210
|
+
}
|
|
1211
|
+
declare const InvokeStarted: MessageFns<InvokeStarted>;
|
|
1179
1212
|
interface InvokeExit {
|
|
1180
1213
|
code: number;
|
|
1181
1214
|
/** tail ≤ 8 KiB */
|
|
@@ -1641,8 +1674,9 @@ declare const LaceEngineService: {
|
|
|
1641
1674
|
readonly responseDeserialize: (value: Buffer) => ReadWiringCandidatesResponse;
|
|
1642
1675
|
};
|
|
1643
1676
|
/**
|
|
1644
|
-
* Runs one CLI command in-process against a fresh command tree.
|
|
1645
|
-
*
|
|
1677
|
+
* Runs one CLI command in-process against a fresh command tree. `started` is first, once the engine has accepted
|
|
1678
|
+
* the request and before the command runs; the command's `-o json` output follows: each top-level JSON value on
|
|
1679
|
+
* stdout is one `json` event; `exit` is always last.
|
|
1646
1680
|
*/
|
|
1647
1681
|
readonly invoke: {
|
|
1648
1682
|
readonly path: "/lace.engine.LaceEngine/Invoke";
|
|
@@ -1763,8 +1797,9 @@ interface LaceEngineClient extends Client {
|
|
|
1763
1797
|
readWiringCandidates(request: ReadWiringCandidatesRequest, metadata: Metadata, callback: (error: ServiceError | null, response: ReadWiringCandidatesResponse) => void): ClientUnaryCall;
|
|
1764
1798
|
readWiringCandidates(request: ReadWiringCandidatesRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: ReadWiringCandidatesResponse) => void): ClientUnaryCall;
|
|
1765
1799
|
/**
|
|
1766
|
-
* Runs one CLI command in-process against a fresh command tree.
|
|
1767
|
-
*
|
|
1800
|
+
* Runs one CLI command in-process against a fresh command tree. `started` is first, once the engine has accepted
|
|
1801
|
+
* the request and before the command runs; the command's `-o json` output follows: each top-level JSON value on
|
|
1802
|
+
* stdout is one `json` event; `exit` is always last.
|
|
1768
1803
|
*/
|
|
1769
1804
|
invoke(request: InvokeRequest, options?: Partial<CallOptions>): ClientReadableStream<InvokeEvent>;
|
|
1770
1805
|
invoke(request: InvokeRequest, metadata?: Metadata, options?: Partial<CallOptions>): ClientReadableStream<InvokeEvent>;
|
|
@@ -1818,8 +1853,10 @@ type RpcErrorCategory = 'engine_unavailable' | 'server_error' | 'timeout';
|
|
|
1818
1853
|
* engine is gone, it timed out, or it answered with an error), `reason` and
|
|
1819
1854
|
* `apiCode` why, as the engine's status details name it — the refusal's
|
|
1820
1855
|
* entry in the one vocabulary (`REASON_UNSPECIFIED` when it named none or no
|
|
1821
|
-
* status came back) and, for a failure the API decided, the API's own code
|
|
1822
|
-
*
|
|
1856
|
+
* status came back) and, for a failure the API decided, the API's own code —
|
|
1857
|
+
* and `requestId` the id the API answered the refused request with, the id
|
|
1858
|
+
* a person quotes to Lace's support. A host branches on these, never on
|
|
1859
|
+
* `message`.
|
|
1823
1860
|
*/
|
|
1824
1861
|
declare class RpcError extends Error {
|
|
1825
1862
|
readonly category: RpcErrorCategory;
|
|
@@ -1827,7 +1864,8 @@ declare class RpcError extends Error {
|
|
|
1827
1864
|
readonly cause?: unknown | undefined;
|
|
1828
1865
|
readonly reason: Reason;
|
|
1829
1866
|
readonly apiCode?: string | undefined;
|
|
1830
|
-
|
|
1867
|
+
readonly requestId?: string | undefined;
|
|
1868
|
+
constructor(message: string, category: RpcErrorCategory, method: string, cause?: unknown | undefined, reason?: Reason, apiCode?: string | undefined, requestId?: string | undefined);
|
|
1831
1869
|
}
|
|
1832
1870
|
/**
|
|
1833
1871
|
* Classifies a failed engine call by data alone: a gRPC status by its code,
|
|
@@ -1883,7 +1921,9 @@ declare class ServerManager extends EventEmitter {
|
|
|
1883
1921
|
* is compared with the one this library speaks before any RPC is sent
|
|
1884
1922
|
* (`checkEngineProtocol`, `@lace-cloud/proto`, the check the canvas makes
|
|
1885
1923
|
* of `Initialize`'s answer): an engine that names another rejects with
|
|
1886
|
-
* `EngineProtocolMismatchError`.
|
|
1924
|
+
* `EngineProtocolMismatchError`. A binary that cannot be started rejects
|
|
1925
|
+
* with `EngineSpawnError`, whose `code` is the spawn error's (`ENOENT`
|
|
1926
|
+
* when no executable is found).
|
|
1887
1927
|
* An engine a failed start spawned is ended before the rejection.
|
|
1888
1928
|
*/
|
|
1889
1929
|
start(): Promise<void>;
|
|
@@ -1896,4 +1936,4 @@ declare class ServerManager extends EventEmitter {
|
|
|
1896
1936
|
private maybeRestart;
|
|
1897
1937
|
}
|
|
1898
1938
|
|
|
1899
|
-
export { Action, ApplyActionRequest, BundleApplyResult, BundleState, BundleStateEvent, 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 };
|
|
1939
|
+
export { Action, ApplyActionRequest, BundleApplyResult, BundleState, BundleStateEvent, type EngineHandshake, type EngineInitialize, EngineSpawnError, type EngineTransport, InitializeResponse, InvokeEvent, InvokeRequest, LaceTransport, ReadWiringCandidatesRequest, ReadWiringCandidatesResponse, ReasonDetail, RpcError, type RpcErrorCategory, ServerManager, type ServerState, SessionCloseResponse, SessionOpenResponse, Status, classifyRpcError, endEngine, requireClient, serveEngineBridge, spawnEngine };
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { EngineProtocolMismatchError } from "@lace-cloud/proto";
|
|
|
3
3
|
|
|
4
4
|
// src/bridge-server.ts
|
|
5
5
|
import {
|
|
6
|
+
apiFields,
|
|
6
7
|
BRIDGE_METHODS,
|
|
7
8
|
CONNECT_CODE_NAMES,
|
|
8
9
|
ENGINE_STREAM_METHODS
|
|
@@ -3520,7 +3521,7 @@ function conflictChoiceToJSON(object) {
|
|
|
3520
3521
|
}
|
|
3521
3522
|
}
|
|
3522
3523
|
function createBaseReasonDetail() {
|
|
3523
|
-
return { reason: 0, api_code: "" };
|
|
3524
|
+
return { reason: 0, api_code: "", request_id: "" };
|
|
3524
3525
|
}
|
|
3525
3526
|
var ReasonDetail = {
|
|
3526
3527
|
encode(message, writer = new BinaryWriter4()) {
|
|
@@ -3530,6 +3531,9 @@ var ReasonDetail = {
|
|
|
3530
3531
|
if (message.api_code !== "") {
|
|
3531
3532
|
writer.uint32(18).string(message.api_code);
|
|
3532
3533
|
}
|
|
3534
|
+
if (message.request_id !== "") {
|
|
3535
|
+
writer.uint32(26).string(message.request_id);
|
|
3536
|
+
}
|
|
3533
3537
|
return writer;
|
|
3534
3538
|
},
|
|
3535
3539
|
decode(input, length) {
|
|
@@ -3553,6 +3557,13 @@ var ReasonDetail = {
|
|
|
3553
3557
|
message.api_code = reader.string();
|
|
3554
3558
|
continue;
|
|
3555
3559
|
}
|
|
3560
|
+
case 3: {
|
|
3561
|
+
if (tag !== 26) {
|
|
3562
|
+
break;
|
|
3563
|
+
}
|
|
3564
|
+
message.request_id = reader.string();
|
|
3565
|
+
continue;
|
|
3566
|
+
}
|
|
3556
3567
|
}
|
|
3557
3568
|
if ((tag & 7) === 4 || tag === 0) {
|
|
3558
3569
|
break;
|
|
@@ -3564,7 +3575,8 @@ var ReasonDetail = {
|
|
|
3564
3575
|
fromJSON(object) {
|
|
3565
3576
|
return {
|
|
3566
3577
|
reason: isSet3(object.reason) ? reasonFromJSON(object.reason) : 0,
|
|
3567
|
-
api_code: isSet3(object.apiCode) ? globalThis.String(object.apiCode) : isSet3(object.api_code) ? globalThis.String(object.api_code) : ""
|
|
3578
|
+
api_code: isSet3(object.apiCode) ? globalThis.String(object.apiCode) : isSet3(object.api_code) ? globalThis.String(object.api_code) : "",
|
|
3579
|
+
request_id: isSet3(object.requestId) ? globalThis.String(object.requestId) : isSet3(object.request_id) ? globalThis.String(object.request_id) : ""
|
|
3568
3580
|
};
|
|
3569
3581
|
},
|
|
3570
3582
|
toJSON(message) {
|
|
@@ -3575,6 +3587,9 @@ var ReasonDetail = {
|
|
|
3575
3587
|
if (message.api_code !== "") {
|
|
3576
3588
|
obj.apiCode = message.api_code;
|
|
3577
3589
|
}
|
|
3590
|
+
if (message.request_id !== "") {
|
|
3591
|
+
obj.requestId = message.request_id;
|
|
3592
|
+
}
|
|
3578
3593
|
return obj;
|
|
3579
3594
|
},
|
|
3580
3595
|
create(base) {
|
|
@@ -3584,6 +3599,7 @@ var ReasonDetail = {
|
|
|
3584
3599
|
const message = createBaseReasonDetail();
|
|
3585
3600
|
message.reason = object.reason ?? 0;
|
|
3586
3601
|
message.api_code = object.api_code ?? "";
|
|
3602
|
+
message.request_id = object.request_id ?? "";
|
|
3587
3603
|
return message;
|
|
3588
3604
|
}
|
|
3589
3605
|
};
|
|
@@ -7942,7 +7958,7 @@ var InvokeRequest = {
|
|
|
7942
7958
|
}
|
|
7943
7959
|
};
|
|
7944
7960
|
function createBaseInvokeEvent() {
|
|
7945
|
-
return { json: void 0, exit: void 0 };
|
|
7961
|
+
return { json: void 0, exit: void 0, started: void 0 };
|
|
7946
7962
|
}
|
|
7947
7963
|
var InvokeEvent = {
|
|
7948
7964
|
encode(message, writer = new BinaryWriter4()) {
|
|
@@ -7952,6 +7968,9 @@ var InvokeEvent = {
|
|
|
7952
7968
|
if (message.exit !== void 0) {
|
|
7953
7969
|
InvokeExit.encode(message.exit, writer.uint32(18).fork()).join();
|
|
7954
7970
|
}
|
|
7971
|
+
if (message.started !== void 0) {
|
|
7972
|
+
InvokeStarted.encode(message.started, writer.uint32(26).fork()).join();
|
|
7973
|
+
}
|
|
7955
7974
|
return writer;
|
|
7956
7975
|
},
|
|
7957
7976
|
decode(input, length) {
|
|
@@ -7975,6 +7994,13 @@ var InvokeEvent = {
|
|
|
7975
7994
|
message.exit = InvokeExit.decode(reader, reader.uint32());
|
|
7976
7995
|
continue;
|
|
7977
7996
|
}
|
|
7997
|
+
case 3: {
|
|
7998
|
+
if (tag !== 26) {
|
|
7999
|
+
break;
|
|
8000
|
+
}
|
|
8001
|
+
message.started = InvokeStarted.decode(reader, reader.uint32());
|
|
8002
|
+
continue;
|
|
8003
|
+
}
|
|
7978
8004
|
}
|
|
7979
8005
|
if ((tag & 7) === 4 || tag === 0) {
|
|
7980
8006
|
break;
|
|
@@ -7986,7 +8012,8 @@ var InvokeEvent = {
|
|
|
7986
8012
|
fromJSON(object) {
|
|
7987
8013
|
return {
|
|
7988
8014
|
json: isSet3(object.json) ? globalThis.String(object.json) : void 0,
|
|
7989
|
-
exit: isSet3(object.exit) ? InvokeExit.fromJSON(object.exit) : void 0
|
|
8015
|
+
exit: isSet3(object.exit) ? InvokeExit.fromJSON(object.exit) : void 0,
|
|
8016
|
+
started: isSet3(object.started) ? InvokeStarted.fromJSON(object.started) : void 0
|
|
7990
8017
|
};
|
|
7991
8018
|
},
|
|
7992
8019
|
toJSON(message) {
|
|
@@ -7997,6 +8024,9 @@ var InvokeEvent = {
|
|
|
7997
8024
|
if (message.exit !== void 0) {
|
|
7998
8025
|
obj.exit = InvokeExit.toJSON(message.exit);
|
|
7999
8026
|
}
|
|
8027
|
+
if (message.started !== void 0) {
|
|
8028
|
+
obj.started = InvokeStarted.toJSON(message.started);
|
|
8029
|
+
}
|
|
8000
8030
|
return obj;
|
|
8001
8031
|
},
|
|
8002
8032
|
create(base) {
|
|
@@ -8006,6 +8036,44 @@ var InvokeEvent = {
|
|
|
8006
8036
|
const message = createBaseInvokeEvent();
|
|
8007
8037
|
message.json = object.json ?? void 0;
|
|
8008
8038
|
message.exit = object.exit !== void 0 && object.exit !== null ? InvokeExit.fromPartial(object.exit) : void 0;
|
|
8039
|
+
message.started = object.started !== void 0 && object.started !== null ? InvokeStarted.fromPartial(object.started) : void 0;
|
|
8040
|
+
return message;
|
|
8041
|
+
}
|
|
8042
|
+
};
|
|
8043
|
+
function createBaseInvokeStarted() {
|
|
8044
|
+
return {};
|
|
8045
|
+
}
|
|
8046
|
+
var InvokeStarted = {
|
|
8047
|
+
encode(_, writer = new BinaryWriter4()) {
|
|
8048
|
+
return writer;
|
|
8049
|
+
},
|
|
8050
|
+
decode(input, length) {
|
|
8051
|
+
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
8052
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
8053
|
+
const message = createBaseInvokeStarted();
|
|
8054
|
+
while (reader.pos < end) {
|
|
8055
|
+
const tag = reader.uint32();
|
|
8056
|
+
switch (tag >>> 3) {
|
|
8057
|
+
}
|
|
8058
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
8059
|
+
break;
|
|
8060
|
+
}
|
|
8061
|
+
reader.skip(tag & 7);
|
|
8062
|
+
}
|
|
8063
|
+
return message;
|
|
8064
|
+
},
|
|
8065
|
+
fromJSON(_) {
|
|
8066
|
+
return {};
|
|
8067
|
+
},
|
|
8068
|
+
toJSON(_) {
|
|
8069
|
+
const obj = {};
|
|
8070
|
+
return obj;
|
|
8071
|
+
},
|
|
8072
|
+
create(base) {
|
|
8073
|
+
return InvokeStarted.fromPartial(base ?? {});
|
|
8074
|
+
},
|
|
8075
|
+
fromPartial(_) {
|
|
8076
|
+
const message = createBaseInvokeStarted();
|
|
8009
8077
|
return message;
|
|
8010
8078
|
}
|
|
8011
8079
|
};
|
|
@@ -10291,8 +10359,9 @@ var LaceEngineService = {
|
|
|
10291
10359
|
responseDeserialize: (value) => ReadWiringCandidatesResponse.decode(value)
|
|
10292
10360
|
},
|
|
10293
10361
|
/**
|
|
10294
|
-
* Runs one CLI command in-process against a fresh command tree.
|
|
10295
|
-
*
|
|
10362
|
+
* Runs one CLI command in-process against a fresh command tree. `started` is first, once the engine has accepted
|
|
10363
|
+
* the request and before the command runs; the command's `-o json` output follows: each top-level JSON value on
|
|
10364
|
+
* stdout is one `json` event; `exit` is always last.
|
|
10296
10365
|
*/
|
|
10297
10366
|
invoke: {
|
|
10298
10367
|
path: "/lace.engine.LaceEngine/Invoke",
|
|
@@ -10608,7 +10677,7 @@ function errorFrame(id, code, message, detail = ReasonDetail.create()) {
|
|
|
10608
10677
|
code,
|
|
10609
10678
|
message,
|
|
10610
10679
|
reason: reasonToJSON(detail.reason),
|
|
10611
|
-
|
|
10680
|
+
...apiFields(detail)
|
|
10612
10681
|
};
|
|
10613
10682
|
}
|
|
10614
10683
|
function statusFrame(id, err) {
|
|
@@ -10696,8 +10765,20 @@ var EXIT_GRACE_MS = 5e3;
|
|
|
10696
10765
|
var VERSION_RE = /^LACE_ENGINE_VERSION=(.+)$/;
|
|
10697
10766
|
var PROTOCOL_RE = /^LACE_ENGINE_PROTOCOL_VERSION=(\d+)$/;
|
|
10698
10767
|
var PORT_RE = /^LACE_ENGINE_PORT=(\d+)$/;
|
|
10699
|
-
var
|
|
10768
|
+
var TOKEN_PREFIX = "LACE_ENGINE_TOKEN=";
|
|
10769
|
+
var TOKEN_RE = new RegExp(`^${TOKEN_PREFIX}([0-9a-fA-F]{64})$`);
|
|
10700
10770
|
var READY_LINE = "LACE_ENGINE_READY";
|
|
10771
|
+
var loggable = (line) => line.startsWith(TOKEN_PREFIX) ? `${TOKEN_PREFIX}<redacted>` : line;
|
|
10772
|
+
var EngineSpawnError = class extends Error {
|
|
10773
|
+
constructor(cause) {
|
|
10774
|
+
super(`Failed to spawn engine: ${cause.message}`);
|
|
10775
|
+
this.cause = cause;
|
|
10776
|
+
this.name = "EngineSpawnError";
|
|
10777
|
+
}
|
|
10778
|
+
get code() {
|
|
10779
|
+
return this.cause.code;
|
|
10780
|
+
}
|
|
10781
|
+
};
|
|
10701
10782
|
function spawnEngine(binaryPath, log) {
|
|
10702
10783
|
return new Promise((resolve, reject) => {
|
|
10703
10784
|
log(`Spawning: ${binaryPath} engine`);
|
|
@@ -10723,17 +10804,17 @@ function spawnEngine(binaryPath, log) {
|
|
|
10723
10804
|
proc.kill();
|
|
10724
10805
|
reject(new Error("Timed out waiting for engine handshake"));
|
|
10725
10806
|
}, HANDSHAKE_TIMEOUT_MS);
|
|
10726
|
-
const fail = (
|
|
10807
|
+
const fail = (error) => {
|
|
10727
10808
|
if (settled) return;
|
|
10728
10809
|
settled = true;
|
|
10729
10810
|
clearTimeout(timer);
|
|
10730
10811
|
rl.close();
|
|
10731
10812
|
proc.kill();
|
|
10732
|
-
reject(
|
|
10813
|
+
reject(error);
|
|
10733
10814
|
};
|
|
10734
10815
|
rl.on("line", (line) => {
|
|
10735
10816
|
if (settled) return;
|
|
10736
|
-
log(`[stdout] ${line}`);
|
|
10817
|
+
log(`[stdout] ${loggable(line)}`);
|
|
10737
10818
|
let match;
|
|
10738
10819
|
match = line.match(VERSION_RE);
|
|
10739
10820
|
if (match) {
|
|
@@ -10757,7 +10838,7 @@ function spawnEngine(binaryPath, log) {
|
|
|
10757
10838
|
}
|
|
10758
10839
|
if (line === READY_LINE) {
|
|
10759
10840
|
if (!version || !protocolVersion || port === void 0 || !token) {
|
|
10760
|
-
fail("Received LACE_ENGINE_READY before all handshake fields were set");
|
|
10841
|
+
fail(new Error("Received LACE_ENGINE_READY before all handshake fields were set"));
|
|
10761
10842
|
return;
|
|
10762
10843
|
}
|
|
10763
10844
|
settled = true;
|
|
@@ -10770,10 +10851,10 @@ function spawnEngine(binaryPath, log) {
|
|
|
10770
10851
|
}
|
|
10771
10852
|
});
|
|
10772
10853
|
proc.on("error", (err) => {
|
|
10773
|
-
fail(
|
|
10854
|
+
fail(new EngineSpawnError(err));
|
|
10774
10855
|
});
|
|
10775
10856
|
proc.on("exit", (code) => {
|
|
10776
|
-
fail(`Engine exited with code ${code} before completing handshake`);
|
|
10857
|
+
fail(new Error(`Engine exited with code ${code} before completing handshake`));
|
|
10777
10858
|
});
|
|
10778
10859
|
});
|
|
10779
10860
|
}
|
|
@@ -10792,14 +10873,16 @@ function endEngine(proc, graceMs = EXIT_GRACE_MS) {
|
|
|
10792
10873
|
|
|
10793
10874
|
// src/rpc-errors.ts
|
|
10794
10875
|
import { status as GrpcStatus } from "@grpc/grpc-js";
|
|
10876
|
+
import { apiFields as apiFields2 } from "@lace-cloud/proto";
|
|
10795
10877
|
var RpcError = class extends Error {
|
|
10796
|
-
constructor(message, category, method, cause, reason = 0 /* REASON_UNSPECIFIED */, apiCode) {
|
|
10878
|
+
constructor(message, category, method, cause, reason = 0 /* REASON_UNSPECIFIED */, apiCode, requestId) {
|
|
10797
10879
|
super(message);
|
|
10798
10880
|
this.category = category;
|
|
10799
10881
|
this.method = method;
|
|
10800
10882
|
this.cause = cause;
|
|
10801
10883
|
this.reason = reason;
|
|
10802
10884
|
this.apiCode = apiCode;
|
|
10885
|
+
this.requestId = requestId;
|
|
10803
10886
|
this.name = "RpcError";
|
|
10804
10887
|
}
|
|
10805
10888
|
};
|
|
@@ -10815,13 +10898,15 @@ function classifyRpcError(err, method) {
|
|
|
10815
10898
|
if (err instanceof RpcError) return err;
|
|
10816
10899
|
if (isGrpcServiceError(err)) {
|
|
10817
10900
|
const detail = readReasonDetail(err.metadata);
|
|
10901
|
+
const { apiCode, requestId } = apiFields2(detail);
|
|
10818
10902
|
return new RpcError(
|
|
10819
10903
|
err.details || err.message,
|
|
10820
10904
|
STATUS_CATEGORIES[err.code] ?? "server_error",
|
|
10821
10905
|
method,
|
|
10822
10906
|
err,
|
|
10823
10907
|
detail.reason,
|
|
10824
|
-
|
|
10908
|
+
apiCode,
|
|
10909
|
+
requestId
|
|
10825
10910
|
);
|
|
10826
10911
|
}
|
|
10827
10912
|
return new RpcError(
|
|
@@ -10936,7 +11021,9 @@ var ServerManager = class extends EventEmitter {
|
|
|
10936
11021
|
* is compared with the one this library speaks before any RPC is sent
|
|
10937
11022
|
* (`checkEngineProtocol`, `@lace-cloud/proto`, the check the canvas makes
|
|
10938
11023
|
* of `Initialize`'s answer): an engine that names another rejects with
|
|
10939
|
-
* `EngineProtocolMismatchError`.
|
|
11024
|
+
* `EngineProtocolMismatchError`. A binary that cannot be started rejects
|
|
11025
|
+
* with `EngineSpawnError`, whose `code` is the spawn error's (`ENOENT`
|
|
11026
|
+
* when no executable is found).
|
|
10940
11027
|
* An engine a failed start spawned is ended before the rejection.
|
|
10941
11028
|
*/
|
|
10942
11029
|
async start() {
|
|
@@ -11046,7 +11133,9 @@ export {
|
|
|
11046
11133
|
BundleState,
|
|
11047
11134
|
BundleStateEvent,
|
|
11048
11135
|
EngineProtocolMismatchError,
|
|
11136
|
+
EngineSpawnError,
|
|
11049
11137
|
InitializeResponse,
|
|
11138
|
+
InvokeEvent,
|
|
11050
11139
|
InvokeRequest,
|
|
11051
11140
|
LaceTransport,
|
|
11052
11141
|
ReadWiringCandidatesRequest,
|