@cleocode/contracts 2026.5.129 → 2026.5.131
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/__tests__/atomic-tools-contract.test.d.ts +14 -0
- package/dist/__tests__/atomic-tools-contract.test.d.ts.map +1 -0
- package/dist/__tests__/atomic-tools-contract.test.js +55 -0
- package/dist/__tests__/atomic-tools-contract.test.js.map +1 -0
- package/dist/__tests__/gateway-contract.test.d.ts +18 -0
- package/dist/__tests__/gateway-contract.test.d.ts.map +1 -0
- package/dist/__tests__/gateway-contract.test.js +187 -0
- package/dist/__tests__/gateway-contract.test.js.map +1 -0
- package/dist/__tests__/mvi.test.d.ts +17 -0
- package/dist/__tests__/mvi.test.d.ts.map +1 -0
- package/dist/__tests__/mvi.test.js +147 -0
- package/dist/__tests__/mvi.test.js.map +1 -0
- package/dist/__tests__/operation-def.test.js +1 -1
- package/dist/__tests__/operation-def.test.js.map +1 -1
- package/dist/boundary.d.ts +26 -0
- package/dist/boundary.d.ts.map +1 -1
- package/dist/boundary.js +42 -4
- package/dist/boundary.js.map +1 -1
- package/dist/branch-lock.d.ts +35 -1
- package/dist/branch-lock.d.ts.map +1 -1
- package/dist/branch-lock.js +23 -2
- package/dist/branch-lock.js.map +1 -1
- package/dist/daemon/__tests__/health-roundtrip.test.d.ts +13 -0
- package/dist/daemon/__tests__/health-roundtrip.test.d.ts.map +1 -0
- package/dist/daemon/__tests__/health-roundtrip.test.js +69 -0
- package/dist/daemon/__tests__/health-roundtrip.test.js.map +1 -0
- package/dist/daemon/health.d.ts +108 -0
- package/dist/daemon/health.d.ts.map +1 -0
- package/dist/daemon/health.js +95 -0
- package/dist/daemon/health.js.map +1 -0
- package/dist/daemon/index.d.ts +24 -0
- package/dist/daemon/index.d.ts.map +1 -0
- package/dist/daemon/index.js +22 -0
- package/dist/daemon/index.js.map +1 -0
- package/dist/daemon/subsystem.d.ts +121 -0
- package/dist/daemon/subsystem.d.ts.map +1 -0
- package/dist/daemon/subsystem.js +28 -0
- package/dist/daemon/subsystem.js.map +1 -0
- package/dist/daemon-ipc/__tests__/daemon-ipc-freeze.test.d.ts +15 -0
- package/dist/daemon-ipc/__tests__/daemon-ipc-freeze.test.d.ts.map +1 -0
- package/dist/daemon-ipc/__tests__/daemon-ipc-freeze.test.js +40 -0
- package/dist/daemon-ipc/__tests__/daemon-ipc-freeze.test.js.map +1 -0
- package/dist/daemon-ipc/index.d.ts +44 -0
- package/dist/daemon-ipc/index.d.ts.map +1 -0
- package/dist/daemon-ipc/index.js +43 -0
- package/dist/daemon-ipc/index.js.map +1 -0
- package/dist/db-inventory.json +8 -8
- package/dist/dispatch/identity.d.ts +1 -1
- package/dist/dispatch/identity.d.ts.map +1 -1
- package/dist/dispatch/identity.js +3 -0
- package/dist/dispatch/identity.js.map +1 -1
- package/dist/dispatch/operation-def.d.ts +16 -0
- package/dist/dispatch/operation-def.d.ts.map +1 -1
- package/dist/dispatch/operations-registry.d.ts.map +1 -1
- package/dist/dispatch/operations-registry.js +133 -0
- package/dist/dispatch/operations-registry.js.map +1 -1
- package/dist/exit-codes.d.ts +1 -1
- package/dist/exit-codes.js +1 -1
- package/dist/gateway/rpc/__tests__/freeze.test.d.ts +20 -0
- package/dist/gateway/rpc/__tests__/freeze.test.d.ts.map +1 -0
- package/dist/gateway/rpc/__tests__/freeze.test.js +122 -0
- package/dist/gateway/rpc/__tests__/freeze.test.js.map +1 -0
- package/dist/gateway/rpc/index.d.ts +23 -0
- package/dist/gateway/rpc/index.d.ts.map +1 -0
- package/dist/gateway/rpc/index.js +22 -0
- package/dist/gateway/rpc/index.js.map +1 -0
- package/dist/gateway/rpc/messages.d.ts +263 -0
- package/dist/gateway/rpc/messages.d.ts.map +1 -0
- package/dist/gateway/rpc/messages.js +152 -0
- package/dist/gateway/rpc/messages.js.map +1 -0
- package/dist/gateway/rpc/version.d.ts +39 -0
- package/dist/gateway/rpc/version.d.ts.map +1 -0
- package/dist/gateway/rpc/version.js +39 -0
- package/dist/gateway/rpc/version.js.map +1 -0
- package/dist/gateway.d.ts +239 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/gateway.js +171 -0
- package/dist/gateway.js.map +1 -0
- package/dist/goal.d.ts +314 -0
- package/dist/goal.d.ts.map +1 -0
- package/dist/goal.js +118 -0
- package/dist/goal.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/mvi.d.ts +209 -0
- package/dist/mvi.d.ts.map +1 -0
- package/dist/mvi.js +99 -0
- package/dist/mvi.js.map +1 -0
- package/dist/operations/attention.d.ts +114 -0
- package/dist/operations/attention.d.ts.map +1 -0
- package/dist/operations/attention.js +22 -0
- package/dist/operations/attention.js.map +1 -0
- package/dist/operations/docs.d.ts +7 -1
- package/dist/operations/docs.d.ts.map +1 -1
- package/dist/operations/docs.js.map +1 -1
- package/dist/operations/focus.d.ts +25 -0
- package/dist/operations/focus.d.ts.map +1 -1
- package/dist/operations/index.d.ts +1 -0
- package/dist/operations/index.d.ts.map +1 -1
- package/dist/operations/index.js +1 -0
- package/dist/operations/index.js.map +1 -1
- package/dist/operations/session.d.ts +11 -0
- package/dist/operations/session.d.ts.map +1 -1
- package/dist/sdk-tool.d.ts +1 -1
- package/dist/sdk-tool.js +1 -1
- package/dist/supervisor-ipc/__tests__/freeze.test.d.ts +15 -0
- package/dist/supervisor-ipc/__tests__/freeze.test.d.ts.map +1 -0
- package/dist/supervisor-ipc/__tests__/freeze.test.js +159 -0
- package/dist/supervisor-ipc/__tests__/freeze.test.js.map +1 -0
- package/dist/supervisor-ipc/index.d.ts +15 -0
- package/dist/supervisor-ipc/index.d.ts.map +1 -0
- package/dist/supervisor-ipc/index.js +14 -0
- package/dist/supervisor-ipc/index.js.map +1 -0
- package/dist/supervisor-ipc/messages.d.ts +457 -0
- package/dist/supervisor-ipc/messages.d.ts.map +1 -0
- package/dist/supervisor-ipc/messages.js +312 -0
- package/dist/supervisor-ipc/messages.js.map +1 -0
- package/dist/supervisor-ipc/version.d.ts +29 -0
- package/dist/supervisor-ipc/version.d.ts.map +1 -0
- package/dist/supervisor-ipc/version.js +29 -0
- package/dist/supervisor-ipc/version.js.map +1 -0
- package/dist/tools/__tests__/composite.test.d.ts +14 -0
- package/dist/tools/__tests__/composite.test.d.ts.map +1 -0
- package/dist/tools/__tests__/composite.test.js +75 -0
- package/dist/tools/__tests__/composite.test.js.map +1 -0
- package/dist/tools/atomic.d.ts +195 -0
- package/dist/tools/atomic.d.ts.map +1 -0
- package/dist/tools/atomic.js +82 -0
- package/dist/tools/atomic.js.map +1 -0
- package/dist/tools/composite.d.ts +128 -0
- package/dist/tools/composite.d.ts.map +1 -0
- package/dist/tools/composite.js +88 -0
- package/dist/tools/composite.js.map +1 -0
- package/package.json +35 -3
- package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
- package/src/__tests__/atomic-tools-contract.test.ts +67 -0
- package/src/__tests__/gateway-contract.test.ts +219 -0
- package/src/__tests__/mvi.test.ts +175 -0
- package/src/__tests__/operation-def.test.ts +2 -1
- package/src/boundary.ts +74 -4
- package/src/branch-lock.ts +49 -2
- package/src/daemon/__tests__/health-roundtrip.test.ts +84 -0
- package/src/daemon/health.ts +121 -0
- package/src/daemon/index.ts +35 -0
- package/src/daemon/subsystem.ts +126 -0
- package/src/daemon-ipc/__tests__/daemon-ipc-freeze.test.ts +53 -0
- package/src/daemon-ipc/index.ts +90 -0
- package/src/db-inventory.json +8 -8
- package/src/dispatch/identity.ts +3 -0
- package/src/dispatch/operation-def.ts +16 -0
- package/src/dispatch/operations-registry.ts +140 -0
- package/src/exit-codes.ts +1 -1
- package/src/gateway/rpc/__tests__/freeze.test.ts +139 -0
- package/src/gateway/rpc/index.ts +43 -0
- package/src/gateway/rpc/messages.ts +187 -0
- package/src/gateway/rpc/version.ts +40 -0
- package/src/gateway.ts +252 -0
- package/src/goal.ts +348 -0
- package/src/index.ts +109 -0
- package/src/mvi.ts +236 -0
- package/src/operations/attention.ts +117 -0
- package/src/operations/docs.ts +7 -1
- package/src/operations/focus.ts +26 -0
- package/src/operations/index.ts +1 -0
- package/src/operations/session.ts +11 -0
- package/src/sdk-tool.ts +1 -1
- package/src/supervisor-ipc/__tests__/freeze.test.ts +180 -0
- package/src/supervisor-ipc/index.ts +62 -0
- package/src/supervisor-ipc/messages.ts +396 -0
- package/src/supervisor-ipc/version.ts +30 -0
- package/src/tools/__tests__/composite.test.ts +88 -0
- package/src/tools/atomic.ts +274 -0
- package/src/tools/composite.ts +173 -0
package/dist/exit-codes.d.ts
CHANGED
|
@@ -281,7 +281,7 @@ export declare const E_WORKFLOW_NOT_FOUND: "E_WORKFLOW_NOT_FOUND";
|
|
|
281
281
|
* retry. Emitted by {@link withWriteRetry} (in `@cleocode/core`'s
|
|
282
282
|
* `store/with-retry.ts`) when a SQLite write transaction fails 4 consecutive
|
|
283
283
|
* attempts with `SQLITE_BUSY: database is locked` despite the engine-level
|
|
284
|
-
* `busy_timeout=
|
|
284
|
+
* `busy_timeout=30000ms` pragma.
|
|
285
285
|
*
|
|
286
286
|
* **Recovery**: retry the operation after a brief delay (the contended writer
|
|
287
287
|
* usually commits within 1-2 seconds). If the error reoccurs reliably, suspect
|
package/dist/exit-codes.js
CHANGED
|
@@ -309,7 +309,7 @@ export const E_WORKFLOW_NOT_FOUND = 'E_WORKFLOW_NOT_FOUND';
|
|
|
309
309
|
* retry. Emitted by {@link withWriteRetry} (in `@cleocode/core`'s
|
|
310
310
|
* `store/with-retry.ts`) when a SQLite write transaction fails 4 consecutive
|
|
311
311
|
* attempts with `SQLITE_BUSY: database is locked` despite the engine-level
|
|
312
|
-
* `busy_timeout=
|
|
312
|
+
* `busy_timeout=30000ms` pragma.
|
|
313
313
|
*
|
|
314
314
|
* **Recovery**: retry the operation after a brief delay (the contended writer
|
|
315
315
|
* usually commits within 1-2 seconds). If the error reoccurs reliably, suspect
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema-drift guard for the FROZEN `gateway/rpc` v1.0 contract (T11449 AC).
|
|
3
|
+
*
|
|
4
|
+
* Pins the v1.0 protocol version, the exact `direction` discriminator set, and
|
|
5
|
+
* the protocol-level transport error codes. If a future change adds, removes,
|
|
6
|
+
* or renames a direction/error code without bumping to a new contract revision,
|
|
7
|
+
* these assertions fail — forcing an explicit, reviewed decision rather than
|
|
8
|
+
* silent drift that would break the CLI-RPC adapter and its clients.
|
|
9
|
+
*
|
|
10
|
+
* Also asserts the NDJSON frame round-trips through the Zod schemas, proving
|
|
11
|
+
* the framing discipline borrowed from `supervisor-ipc` (versioned, correlated
|
|
12
|
+
* envelope discriminated by `direction`, one frame per line) holds for the
|
|
13
|
+
* gateway-dispatch payload.
|
|
14
|
+
*
|
|
15
|
+
* @task T11449
|
|
16
|
+
* @epic T11254
|
|
17
|
+
* @saga T11243
|
|
18
|
+
*/
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=freeze.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freeze.test.d.ts","sourceRoot":"","sources":["../../../../src/gateway/rpc/__tests__/freeze.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema-drift guard for the FROZEN `gateway/rpc` v1.0 contract (T11449 AC).
|
|
3
|
+
*
|
|
4
|
+
* Pins the v1.0 protocol version, the exact `direction` discriminator set, and
|
|
5
|
+
* the protocol-level transport error codes. If a future change adds, removes,
|
|
6
|
+
* or renames a direction/error code without bumping to a new contract revision,
|
|
7
|
+
* these assertions fail — forcing an explicit, reviewed decision rather than
|
|
8
|
+
* silent drift that would break the CLI-RPC adapter and its clients.
|
|
9
|
+
*
|
|
10
|
+
* Also asserts the NDJSON frame round-trips through the Zod schemas, proving
|
|
11
|
+
* the framing discipline borrowed from `supervisor-ipc` (versioned, correlated
|
|
12
|
+
* envelope discriminated by `direction`, one frame per line) holds for the
|
|
13
|
+
* gateway-dispatch payload.
|
|
14
|
+
*
|
|
15
|
+
* @task T11449
|
|
16
|
+
* @epic T11254
|
|
17
|
+
* @saga T11243
|
|
18
|
+
*/
|
|
19
|
+
import { describe, expect, it } from 'vitest';
|
|
20
|
+
import { GATEWAY_RPC_CHANNEL_BASENAME, GATEWAY_RPC_DIRECTIONS, GATEWAY_RPC_ERROR_CODES, GATEWAY_RPC_PROTOCOL_VERSION, GatewayRpcFrameSchema, isFrozenGatewayRpcVersion, } from '../index.js';
|
|
21
|
+
describe('gateway/rpc v1.0 freeze guard (T11449)', () => {
|
|
22
|
+
it('pins the frozen protocol version', () => {
|
|
23
|
+
expect(GATEWAY_RPC_PROTOCOL_VERSION).toBe('1.0.0');
|
|
24
|
+
});
|
|
25
|
+
it('pins the default channel basename', () => {
|
|
26
|
+
expect(GATEWAY_RPC_CHANNEL_BASENAME).toBe('cleo-gateway-rpc');
|
|
27
|
+
});
|
|
28
|
+
it('pins the EXACT frozen direction set', () => {
|
|
29
|
+
expect([...GATEWAY_RPC_DIRECTIONS]).toEqual(['request', 'response', 'error']);
|
|
30
|
+
});
|
|
31
|
+
it('pins the EXACT frozen protocol-level error-code set', () => {
|
|
32
|
+
expect([...GATEWAY_RPC_ERROR_CODES]).toEqual([
|
|
33
|
+
'E_RPC_PARSE',
|
|
34
|
+
'E_RPC_BAD_VERSION',
|
|
35
|
+
'E_RPC_BAD_FRAME',
|
|
36
|
+
'E_RPC_INTERNAL',
|
|
37
|
+
]);
|
|
38
|
+
});
|
|
39
|
+
it('isFrozenGatewayRpcVersion accepts only the frozen version', () => {
|
|
40
|
+
expect(isFrozenGatewayRpcVersion('1.0.0')).toBe(true);
|
|
41
|
+
expect(isFrozenGatewayRpcVersion('2.0.0')).toBe(false);
|
|
42
|
+
expect(isFrozenGatewayRpcVersion('0.9.0')).toBe(false);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
describe('gateway/rpc v1.0 NDJSON frame round-trip', () => {
|
|
46
|
+
it('parses a request frame wrapping a source:rpc DispatchRequest', () => {
|
|
47
|
+
const wire = {
|
|
48
|
+
protocol_version: '1.0.0',
|
|
49
|
+
id: 'abc',
|
|
50
|
+
direction: 'request',
|
|
51
|
+
request: {
|
|
52
|
+
gateway: 'query',
|
|
53
|
+
domain: 'tasks',
|
|
54
|
+
operation: 'show',
|
|
55
|
+
params: { id: 'T1' },
|
|
56
|
+
source: 'rpc',
|
|
57
|
+
requestId: 'abc',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
const parsed = GatewayRpcFrameSchema.safeParse(wire);
|
|
61
|
+
expect(parsed.success).toBe(true);
|
|
62
|
+
if (parsed.success && parsed.data.direction === 'request') {
|
|
63
|
+
expect(parsed.data.request.source).toBe('rpc');
|
|
64
|
+
expect(parsed.data.request.operation).toBe('show');
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
it('parses a response frame wrapping a LAFS DispatchResponse', () => {
|
|
68
|
+
const wire = {
|
|
69
|
+
protocol_version: '1.0.0',
|
|
70
|
+
id: 'abc',
|
|
71
|
+
direction: 'response',
|
|
72
|
+
response: {
|
|
73
|
+
meta: {
|
|
74
|
+
gateway: 'query',
|
|
75
|
+
domain: 'tasks',
|
|
76
|
+
operation: 'show',
|
|
77
|
+
timestamp: '2026-05-31T00:00:00.000Z',
|
|
78
|
+
duration_ms: 1,
|
|
79
|
+
source: 'rpc',
|
|
80
|
+
requestId: 'abc',
|
|
81
|
+
},
|
|
82
|
+
success: true,
|
|
83
|
+
data: { id: 'T1' },
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
expect(GatewayRpcFrameSchema.safeParse(wire).success).toBe(true);
|
|
87
|
+
});
|
|
88
|
+
it('parses a protocol-level error frame', () => {
|
|
89
|
+
const wire = {
|
|
90
|
+
protocol_version: '1.0.0',
|
|
91
|
+
id: '0',
|
|
92
|
+
direction: 'error',
|
|
93
|
+
error: { code: 'E_RPC_BAD_VERSION', message: 'unsupported protocol version' },
|
|
94
|
+
};
|
|
95
|
+
expect(GatewayRpcFrameSchema.safeParse(wire).success).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
it('rejects an unknown direction (proves the union is closed)', () => {
|
|
98
|
+
const wire = {
|
|
99
|
+
protocol_version: '1.0.0',
|
|
100
|
+
id: 'abc',
|
|
101
|
+
direction: 'teleport',
|
|
102
|
+
request: {},
|
|
103
|
+
};
|
|
104
|
+
expect(GatewayRpcFrameSchema.safeParse(wire).success).toBe(false);
|
|
105
|
+
});
|
|
106
|
+
it('rejects a request frame whose source is NOT rpc-shaped enum member', () => {
|
|
107
|
+
const wire = {
|
|
108
|
+
protocol_version: '1.0.0',
|
|
109
|
+
id: 'abc',
|
|
110
|
+
direction: 'request',
|
|
111
|
+
request: {
|
|
112
|
+
gateway: 'query',
|
|
113
|
+
domain: 'tasks',
|
|
114
|
+
operation: 'show',
|
|
115
|
+
source: 'carrier-pigeon',
|
|
116
|
+
requestId: 'abc',
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
expect(GatewayRpcFrameSchema.safeParse(wire).success).toBe(false);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=freeze.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freeze.test.js","sourceRoot":"","sources":["../../../../src/gateway/rpc/__tests__/freeze.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,uBAAuB,EACvB,4BAA4B,EAC5B,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AAErB,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;IACtD,EAAE,CAAC,kCAAkC,E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rel.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the version constants and Zod frame schemas + inferred types for
|
|
5
|
+
* the CLI-RPC transport (`@cleocode/runtime/gateway/rpc`): a long-lived
|
|
6
|
+
* unix-socket RPC server that decodes NDJSON {@link GatewayRpcFrame}s into a
|
|
7
|
+
* `source: 'rpc'` gateway request and routes them through the gateway handler.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors the `supervisor-ipc` contract structure (version.ts + messages.ts +
|
|
10
|
+
* this barrel + a freeze guard test) but carries gateway dispatch traffic, not
|
|
11
|
+
* supervisor process-control messages. The request/response PAYLOADS are owned
|
|
12
|
+
* by `@cleocode/contracts/gateway` (R3-T2 · T11446) and re-validated here at
|
|
13
|
+
* the untrusted RPC boundary.
|
|
14
|
+
*
|
|
15
|
+
* @task T11449
|
|
16
|
+
* @epic T11254
|
|
17
|
+
* @saga T11243
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
export type { GatewayRpcDirection, GatewayRpcError, GatewayRpcErrorCode, GatewayRpcErrorFrame, GatewayRpcFrame, GatewayRpcRequestFrame, GatewayRpcResponseFrame, } from './messages.js';
|
|
21
|
+
export { GATEWAY_RPC_DIRECTIONS, GATEWAY_RPC_ERROR_CODES, GatewayRpcErrorFrameSchema, GatewayRpcErrorSchema, GatewayRpcFrameSchema, GatewayRpcRequestFrameSchema, GatewayRpcResponseFrameSchema, isFrozenGatewayRpcVersion, } from './messages.js';
|
|
22
|
+
export { GATEWAY_RPC_CHANNEL_BASENAME, GATEWAY_RPC_PROTOCOL_VERSION, } from './version.js';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gateway/rpc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,4BAA4B,EAC5B,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `gateway/rpc` v1.0 — FROZEN CLI-RPC NDJSON contract barrel.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the version constants and Zod frame schemas + inferred types for
|
|
5
|
+
* the CLI-RPC transport (`@cleocode/runtime/gateway/rpc`): a long-lived
|
|
6
|
+
* unix-socket RPC server that decodes NDJSON {@link GatewayRpcFrame}s into a
|
|
7
|
+
* `source: 'rpc'` gateway request and routes them through the gateway handler.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors the `supervisor-ipc` contract structure (version.ts + messages.ts +
|
|
10
|
+
* this barrel + a freeze guard test) but carries gateway dispatch traffic, not
|
|
11
|
+
* supervisor process-control messages. The request/response PAYLOADS are owned
|
|
12
|
+
* by `@cleocode/contracts/gateway` (R3-T2 · T11446) and re-validated here at
|
|
13
|
+
* the untrusted RPC boundary.
|
|
14
|
+
*
|
|
15
|
+
* @task T11449
|
|
16
|
+
* @epic T11254
|
|
17
|
+
* @saga T11243
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
export { GATEWAY_RPC_DIRECTIONS, GATEWAY_RPC_ERROR_CODES, GatewayRpcErrorFrameSchema, GatewayRpcErrorSchema, GatewayRpcFrameSchema, GatewayRpcRequestFrameSchema, GatewayRpcResponseFrameSchema, isFrozenGatewayRpcVersion, } from './messages.js';
|
|
21
|
+
export { GATEWAY_RPC_CHANNEL_BASENAME, GATEWAY_RPC_PROTOCOL_VERSION, } from './version.js';
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/gateway/rpc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAWH,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,4BAA4B,EAC5B,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `gateway/rpc` v1.0 — FROZEN NDJSON message contract (Zod schemas).
|
|
3
|
+
*
|
|
4
|
+
* The CLI-RPC transport carries gateway dispatch traffic over a long-lived
|
|
5
|
+
* unix-domain socket. The wire format is newline-delimited JSON (NDJSON): one
|
|
6
|
+
* {@link GatewayRpcFrame} per line — exactly the framing discipline used by the
|
|
7
|
+
* FROZEN `supervisor-ipc` v1.0 contract, REUSED here (not edited): a versioned,
|
|
8
|
+
* correlation-id'd envelope discriminated by `direction`.
|
|
9
|
+
*
|
|
10
|
+
* The difference from supervisor-ipc is the PAYLOAD: this contract wraps the
|
|
11
|
+
* frozen gateway shapes ({@link dispatchRequestSchema} /
|
|
12
|
+
* {@link dispatchResponseSchema} from `@cleocode/contracts/gateway`) rather
|
|
13
|
+
* than supervisor process-control messages. So:
|
|
14
|
+
*
|
|
15
|
+
* ```jsonc
|
|
16
|
+
* // request frame (client → server)
|
|
17
|
+
* { "protocol_version": "1.0.0", "id": "abc", "direction": "request",
|
|
18
|
+
* "request": { "gateway": "query", "domain": "tasks", "operation": "show",
|
|
19
|
+
* "params": { "id": "T1" }, "source": "rpc",
|
|
20
|
+
* "requestId": "abc" } }
|
|
21
|
+
* // response frame (server → client)
|
|
22
|
+
* { "protocol_version": "1.0.0", "id": "abc", "direction": "response",
|
|
23
|
+
* "response": { "success": true, "data": {…}, "meta": {…} } }
|
|
24
|
+
* // error frame (server → client) — protocol-level (bad version / parse / unknown)
|
|
25
|
+
* { "protocol_version": "1.0.0", "id": "abc", "direction": "error",
|
|
26
|
+
* "error": { "code": "E_RPC_BAD_VERSION", "message": "…" } }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* FROZEN v1.0: the {@link GATEWAY_RPC_DIRECTIONS} set is pinned by the drift
|
|
30
|
+
* guard (`__tests__/freeze.test.ts`). Do not add/rename/remove directions in
|
|
31
|
+
* place — bump to a new versioned directory instead. The request/response
|
|
32
|
+
* PAYLOADS are owned by the gateway contract (R3-T2 · T11446) and re-validated
|
|
33
|
+
* here so an untrusted RPC boundary cannot inject a malformed dispatch request.
|
|
34
|
+
*
|
|
35
|
+
* @task T11449
|
|
36
|
+
* @epic T11254
|
|
37
|
+
* @saga T11243
|
|
38
|
+
* @packageDocumentation
|
|
39
|
+
*/
|
|
40
|
+
import { z } from 'zod';
|
|
41
|
+
import { GATEWAY_RPC_PROTOCOL_VERSION } from './version.js';
|
|
42
|
+
/**
|
|
43
|
+
* A protocol-level (transport) error returned when a frame cannot even reach
|
|
44
|
+
* the gateway: malformed JSON, a wrong `protocol_version`, or a frame the
|
|
45
|
+
* server cannot route. Distinct from a {@link dispatchResponseSchema} `error`
|
|
46
|
+
* field, which is a DOMAIN error produced by the handler itself.
|
|
47
|
+
*/
|
|
48
|
+
export declare const GatewayRpcErrorSchema: z.ZodObject<{
|
|
49
|
+
code: z.ZodString;
|
|
50
|
+
message: z.ZodString;
|
|
51
|
+
}, z.core.$strict>;
|
|
52
|
+
/** Protocol-level RPC error payload (inferred from {@link GatewayRpcErrorSchema}). */
|
|
53
|
+
export type GatewayRpcError = z.infer<typeof GatewayRpcErrorSchema>;
|
|
54
|
+
/**
|
|
55
|
+
* A client → server request frame: a versioned, correlated wrapper around a
|
|
56
|
+
* single frozen {@link dispatchRequestSchema}. The `direction` discriminator +
|
|
57
|
+
* flattened `request` payload mirror the supervisor-ipc envelope shape.
|
|
58
|
+
*/
|
|
59
|
+
export declare const GatewayRpcRequestFrameSchema: z.ZodObject<{
|
|
60
|
+
protocol_version: z.ZodString;
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
direction: z.ZodLiteral<"request">;
|
|
63
|
+
request: z.ZodObject<{
|
|
64
|
+
gateway: z.ZodCustom<import("../../gateway.js").Gateway, import("../../gateway.js").Gateway>;
|
|
65
|
+
domain: z.ZodString;
|
|
66
|
+
operation: z.ZodString;
|
|
67
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
68
|
+
source: z.ZodEnum<{
|
|
69
|
+
http: "http";
|
|
70
|
+
cli: "cli";
|
|
71
|
+
mcp: "mcp";
|
|
72
|
+
rpc: "rpc";
|
|
73
|
+
}>;
|
|
74
|
+
requestId: z.ZodString;
|
|
75
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
76
|
+
originSessionId: z.ZodOptional<z.ZodString>;
|
|
77
|
+
executionSessionId: z.ZodOptional<z.ZodString>;
|
|
78
|
+
_fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
79
|
+
_mvi: z.ZodOptional<z.ZodCustom<import("@cleocode/lafs").MVILevel, import("@cleocode/lafs").MVILevel>>;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
}, z.core.$strict>;
|
|
82
|
+
/** Request frame (inferred from {@link GatewayRpcRequestFrameSchema}). */
|
|
83
|
+
export type GatewayRpcRequestFrame = z.infer<typeof GatewayRpcRequestFrameSchema>;
|
|
84
|
+
/**
|
|
85
|
+
* A server → client response frame: a versioned, correlated wrapper around a
|
|
86
|
+
* single frozen {@link dispatchResponseSchema} (the LAFS envelope the handler
|
|
87
|
+
* produced).
|
|
88
|
+
*/
|
|
89
|
+
export declare const GatewayRpcResponseFrameSchema: z.ZodObject<{
|
|
90
|
+
protocol_version: z.ZodString;
|
|
91
|
+
id: z.ZodString;
|
|
92
|
+
direction: z.ZodLiteral<"response">;
|
|
93
|
+
response: z.ZodObject<{
|
|
94
|
+
meta: z.ZodObject<{
|
|
95
|
+
gateway: z.ZodCustom<import("../../gateway.js").Gateway, import("../../gateway.js").Gateway>;
|
|
96
|
+
domain: z.ZodString;
|
|
97
|
+
operation: z.ZodString;
|
|
98
|
+
timestamp: z.ZodString;
|
|
99
|
+
duration_ms: z.ZodNumber;
|
|
100
|
+
source: z.ZodEnum<{
|
|
101
|
+
http: "http";
|
|
102
|
+
cli: "cli";
|
|
103
|
+
mcp: "mcp";
|
|
104
|
+
rpc: "rpc";
|
|
105
|
+
}>;
|
|
106
|
+
requestId: z.ZodString;
|
|
107
|
+
rateLimit: z.ZodOptional<z.ZodObject<{
|
|
108
|
+
limit: z.ZodNumber;
|
|
109
|
+
remaining: z.ZodNumber;
|
|
110
|
+
resetMs: z.ZodNumber;
|
|
111
|
+
category: z.ZodString;
|
|
112
|
+
}, z.core.$strip>>;
|
|
113
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
114
|
+
originSessionId: z.ZodOptional<z.ZodString>;
|
|
115
|
+
executionSessionId: z.ZodOptional<z.ZodString>;
|
|
116
|
+
version: z.ZodOptional<z.ZodString>;
|
|
117
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
118
|
+
success: z.ZodBoolean;
|
|
119
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
120
|
+
page: z.ZodOptional<z.ZodCustom<import("@cleocode/lafs").LAFSPage, import("@cleocode/lafs").LAFSPage>>;
|
|
121
|
+
partial: z.ZodOptional<z.ZodBoolean>;
|
|
122
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
123
|
+
code: z.ZodString;
|
|
124
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
125
|
+
message: z.ZodString;
|
|
126
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
127
|
+
fix: z.ZodOptional<z.ZodString>;
|
|
128
|
+
alternatives: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
129
|
+
action: z.ZodString;
|
|
130
|
+
command: z.ZodString;
|
|
131
|
+
}, z.core.$strip>>>;
|
|
132
|
+
problemDetails: z.ZodOptional<z.ZodCustom<import("../../engine-result.js").ProblemDetails, import("../../engine-result.js").ProblemDetails>>;
|
|
133
|
+
}, z.core.$strip>>;
|
|
134
|
+
}, z.core.$strip>;
|
|
135
|
+
}, z.core.$strict>;
|
|
136
|
+
/** Response frame (inferred from {@link GatewayRpcResponseFrameSchema}). */
|
|
137
|
+
export type GatewayRpcResponseFrame = z.infer<typeof GatewayRpcResponseFrameSchema>;
|
|
138
|
+
/**
|
|
139
|
+
* A server → client protocol-level error frame, emitted when a request frame
|
|
140
|
+
* cannot be decoded or routed. Correlation `id` is best-effort (`'0'` when the
|
|
141
|
+
* frame was so malformed the id could not be recovered).
|
|
142
|
+
*/
|
|
143
|
+
export declare const GatewayRpcErrorFrameSchema: z.ZodObject<{
|
|
144
|
+
protocol_version: z.ZodString;
|
|
145
|
+
id: z.ZodString;
|
|
146
|
+
direction: z.ZodLiteral<"error">;
|
|
147
|
+
error: z.ZodObject<{
|
|
148
|
+
code: z.ZodString;
|
|
149
|
+
message: z.ZodString;
|
|
150
|
+
}, z.core.$strict>;
|
|
151
|
+
}, z.core.$strict>;
|
|
152
|
+
/** Error frame (inferred from {@link GatewayRpcErrorFrameSchema}). */
|
|
153
|
+
export type GatewayRpcErrorFrame = z.infer<typeof GatewayRpcErrorFrameSchema>;
|
|
154
|
+
/**
|
|
155
|
+
* The top-level RPC frame: a versioned, correlated wrapper that is a request,
|
|
156
|
+
* a response, or a protocol-level error, discriminated by `direction`. One
|
|
157
|
+
* frame per NDJSON line.
|
|
158
|
+
*/
|
|
159
|
+
export declare const GatewayRpcFrameSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
160
|
+
protocol_version: z.ZodString;
|
|
161
|
+
id: z.ZodString;
|
|
162
|
+
direction: z.ZodLiteral<"request">;
|
|
163
|
+
request: z.ZodObject<{
|
|
164
|
+
gateway: z.ZodCustom<import("../../gateway.js").Gateway, import("../../gateway.js").Gateway>;
|
|
165
|
+
domain: z.ZodString;
|
|
166
|
+
operation: z.ZodString;
|
|
167
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
168
|
+
source: z.ZodEnum<{
|
|
169
|
+
http: "http";
|
|
170
|
+
cli: "cli";
|
|
171
|
+
mcp: "mcp";
|
|
172
|
+
rpc: "rpc";
|
|
173
|
+
}>;
|
|
174
|
+
requestId: z.ZodString;
|
|
175
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
176
|
+
originSessionId: z.ZodOptional<z.ZodString>;
|
|
177
|
+
executionSessionId: z.ZodOptional<z.ZodString>;
|
|
178
|
+
_fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
179
|
+
_mvi: z.ZodOptional<z.ZodCustom<import("@cleocode/lafs").MVILevel, import("@cleocode/lafs").MVILevel>>;
|
|
180
|
+
}, z.core.$strip>;
|
|
181
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
182
|
+
protocol_version: z.ZodString;
|
|
183
|
+
id: z.ZodString;
|
|
184
|
+
direction: z.ZodLiteral<"response">;
|
|
185
|
+
response: z.ZodObject<{
|
|
186
|
+
meta: z.ZodObject<{
|
|
187
|
+
gateway: z.ZodCustom<import("../../gateway.js").Gateway, import("../../gateway.js").Gateway>;
|
|
188
|
+
domain: z.ZodString;
|
|
189
|
+
operation: z.ZodString;
|
|
190
|
+
timestamp: z.ZodString;
|
|
191
|
+
duration_ms: z.ZodNumber;
|
|
192
|
+
source: z.ZodEnum<{
|
|
193
|
+
http: "http";
|
|
194
|
+
cli: "cli";
|
|
195
|
+
mcp: "mcp";
|
|
196
|
+
rpc: "rpc";
|
|
197
|
+
}>;
|
|
198
|
+
requestId: z.ZodString;
|
|
199
|
+
rateLimit: z.ZodOptional<z.ZodObject<{
|
|
200
|
+
limit: z.ZodNumber;
|
|
201
|
+
remaining: z.ZodNumber;
|
|
202
|
+
resetMs: z.ZodNumber;
|
|
203
|
+
category: z.ZodString;
|
|
204
|
+
}, z.core.$strip>>;
|
|
205
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
206
|
+
originSessionId: z.ZodOptional<z.ZodString>;
|
|
207
|
+
executionSessionId: z.ZodOptional<z.ZodString>;
|
|
208
|
+
version: z.ZodOptional<z.ZodString>;
|
|
209
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
210
|
+
success: z.ZodBoolean;
|
|
211
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
212
|
+
page: z.ZodOptional<z.ZodCustom<import("@cleocode/lafs").LAFSPage, import("@cleocode/lafs").LAFSPage>>;
|
|
213
|
+
partial: z.ZodOptional<z.ZodBoolean>;
|
|
214
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
215
|
+
code: z.ZodString;
|
|
216
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
217
|
+
message: z.ZodString;
|
|
218
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
219
|
+
fix: z.ZodOptional<z.ZodString>;
|
|
220
|
+
alternatives: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
221
|
+
action: z.ZodString;
|
|
222
|
+
command: z.ZodString;
|
|
223
|
+
}, z.core.$strip>>>;
|
|
224
|
+
problemDetails: z.ZodOptional<z.ZodCustom<import("../../engine-result.js").ProblemDetails, import("../../engine-result.js").ProblemDetails>>;
|
|
225
|
+
}, z.core.$strip>>;
|
|
226
|
+
}, z.core.$strip>;
|
|
227
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
228
|
+
protocol_version: z.ZodString;
|
|
229
|
+
id: z.ZodString;
|
|
230
|
+
direction: z.ZodLiteral<"error">;
|
|
231
|
+
error: z.ZodObject<{
|
|
232
|
+
code: z.ZodString;
|
|
233
|
+
message: z.ZodString;
|
|
234
|
+
}, z.core.$strict>;
|
|
235
|
+
}, z.core.$strict>], "direction">;
|
|
236
|
+
/** Any RPC frame (inferred from {@link GatewayRpcFrameSchema}). */
|
|
237
|
+
export type GatewayRpcFrame = z.infer<typeof GatewayRpcFrameSchema>;
|
|
238
|
+
/**
|
|
239
|
+
* The FROZEN v1.0 `direction` discriminator values. The drift guard
|
|
240
|
+
* (`__tests__/freeze.test.ts`) pins this tuple; any addition/removal is a
|
|
241
|
+
* contract-breaking change requiring a new versioned directory.
|
|
242
|
+
*/
|
|
243
|
+
export declare const GATEWAY_RPC_DIRECTIONS: readonly ["request", "response", "error"];
|
|
244
|
+
/** A single frozen RPC frame direction. */
|
|
245
|
+
export type GatewayRpcDirection = (typeof GATEWAY_RPC_DIRECTIONS)[number];
|
|
246
|
+
/**
|
|
247
|
+
* The FROZEN v1.0 protocol-level transport error codes the adapter emits in an
|
|
248
|
+
* {@link GatewayRpcErrorFrameSchema}. Pinned by the drift guard.
|
|
249
|
+
*/
|
|
250
|
+
export declare const GATEWAY_RPC_ERROR_CODES: readonly ["E_RPC_PARSE", "E_RPC_BAD_VERSION", "E_RPC_BAD_FRAME", "E_RPC_INTERNAL"];
|
|
251
|
+
/** A single frozen RPC protocol-level error code. */
|
|
252
|
+
export type GatewayRpcErrorCode = (typeof GATEWAY_RPC_ERROR_CODES)[number];
|
|
253
|
+
/**
|
|
254
|
+
* Type guard: is `v` the frozen RPC protocol version this contract pins?
|
|
255
|
+
*
|
|
256
|
+
* Used by the adapter's version-negotiation step to reject mismatched frames
|
|
257
|
+
* with an `E_RPC_BAD_VERSION` error frame before any gateway routing.
|
|
258
|
+
*
|
|
259
|
+
* @param v - The candidate `protocol_version` string from an inbound frame.
|
|
260
|
+
* @returns `true` iff `v` equals {@link GATEWAY_RPC_PROTOCOL_VERSION}.
|
|
261
|
+
*/
|
|
262
|
+
export declare function isFrozenGatewayRpcVersion(v: string): v is typeof GATEWAY_RPC_PROTOCOL_VERSION;
|
|
263
|
+
//# sour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AC,CAAC;AAIpE;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,2CAA4C,CAAC;AAEhF,2CAA2C;AAC3C,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1E;;;GAGG;AACH,eAAO,MAAM,uBAAuB,oFAK1B,CAAC;AAEX,qDAAqD;AACrD,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3E;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,IAAI,OAAO,4BAA4B,CAE7F"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `gateway/rpc` v1.0 — FROZEN NDJSON message contract (Zod schemas).
|
|
3
|
+
*
|
|
4
|
+
* The CLI-RPC transport carries gateway dispatch traffic over a long-lived
|
|
5
|
+
* unix-domain socket. The wire format is newline-delimited JSON (NDJSON): one
|
|
6
|
+
* {@link GatewayRpcFrame} per line — exactly the framing discipline used by the
|
|
7
|
+
* FROZEN `supervisor-ipc` v1.0 contract, REUSED here (not edited): a versioned,
|
|
8
|
+
* correlation-id'd envelope discriminated by `direction`.
|
|
9
|
+
*
|
|
10
|
+
* The difference from supervisor-ipc is the PAYLOAD: this contract wraps the
|
|
11
|
+
* frozen gateway shapes ({@link dispatchRequestSchema} /
|
|
12
|
+
* {@link dispatchResponseSchema} from `@cleocode/contracts/gateway`) rather
|
|
13
|
+
* than supervisor process-control messages. So:
|
|
14
|
+
*
|
|
15
|
+
* ```jsonc
|
|
16
|
+
* // request frame (client → server)
|
|
17
|
+
* { "protocol_version": "1.0.0", "id": "abc", "direction": "request",
|
|
18
|
+
* "request": { "gateway": "query", "domain": "tasks", "operation": "show",
|
|
19
|
+
* "params": { "id": "T1" }, "source": "rpc",
|
|
20
|
+
* "requestId": "abc" } }
|
|
21
|
+
* // response frame (server → client)
|
|
22
|
+
* { "protocol_version": "1.0.0", "id": "abc", "direction": "response",
|
|
23
|
+
* "response": { "success": true, "data": {…}, "meta": {…} } }
|
|
24
|
+
* // error frame (server → client) — protocol-level (bad version / parse / unknown)
|
|
25
|
+
* { "protocol_version": "1.0.0", "id": "abc", "direction": "error",
|
|
26
|
+
* "error": { "code": "E_RPC_BAD_VERSION", "message": "…" } }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* FROZEN v1.0: the {@link GATEWAY_RPC_DIRECTIONS} set is pinned by the drift
|
|
30
|
+
* guard (`__tests__/freeze.test.ts`). Do not add/rename/remove directions in
|
|
31
|
+
* place — bump to a new versioned directory instead. The request/response
|
|
32
|
+
* PAYLOADS are owned by the gateway contract (R3-T2 · T11446) and re-validated
|
|
33
|
+
* here so an untrusted RPC boundary cannot inject a malformed dispatch request.
|
|
34
|
+
*
|
|
35
|
+
* @task T11449
|
|
36
|
+
* @epic T11254
|
|
37
|
+
* @saga T11243
|
|
38
|
+
* @packageDocumentation
|
|
39
|
+
*/
|
|
40
|
+
import { z } from 'zod';
|
|
41
|
+
import { dispatchRequestSchema, dispatchResponseSchema } from '../../gateway.js';
|
|
42
|
+
import { GATEWAY_RPC_PROTOCOL_VERSION } from './version.js';
|
|
43
|
+
// ─── Protocol-level error payload ──────────────────────────────────────────────
|
|
44
|
+
/**
|
|
45
|
+
* A protocol-level (transport) error returned when a frame cannot even reach
|
|
46
|
+
* the gateway: malformed JSON, a wrong `protocol_version`, or a frame the
|
|
47
|
+
* server cannot route. Distinct from a {@link dispatchResponseSchema} `error`
|
|
48
|
+
* field, which is a DOMAIN error produced by the handler itself.
|
|
49
|
+
*/
|
|
50
|
+
export const GatewayRpcErrorSchema = z
|
|
51
|
+
.object({
|
|
52
|
+
/** Machine-readable transport error code (e.g. `E_RPC_BAD_VERSION`). */
|
|
53
|
+
code: z.string().min(1),
|
|
54
|
+
/** Human-readable error message. */
|
|
55
|
+
message: z.string(),
|
|
56
|
+
})
|
|
57
|
+
.strict();
|
|
58
|
+
// ─── Request frame (client → server) ───────────────────────────────────────────
|
|
59
|
+
/**
|
|
60
|
+
* A client → server request frame: a versioned, correlated wrapper around a
|
|
61
|
+
* single frozen {@link dispatchRequestSchema}. The `direction` discriminator +
|
|
62
|
+
* flattened `request` payload mirror the supervisor-ipc envelope shape.
|
|
63
|
+
*/
|
|
64
|
+
export const GatewayRpcRequestFrameSchema = z
|
|
65
|
+
.object({
|
|
66
|
+
/** Frozen protocol version; rejected if it differs from the server's. */
|
|
67
|
+
protocol_version: z.string(),
|
|
68
|
+
/** Correlation id echoed back on the matching response/error frame. */
|
|
69
|
+
id: z.string().min(1),
|
|
70
|
+
/** Direction discriminator. */
|
|
71
|
+
direction: z.literal('request'),
|
|
72
|
+
/** The gateway dispatch request (re-validated at the untrusted boundary). */
|
|
73
|
+
request: dispatchRequestSchema,
|
|
74
|
+
})
|
|
75
|
+
.strict();
|
|
76
|
+
// ─── Response frame (server → client) ──────────────────────────────────────────
|
|
77
|
+
/**
|
|
78
|
+
* A server → client response frame: a versioned, correlated wrapper around a
|
|
79
|
+
* single frozen {@link dispatchResponseSchema} (the LAFS envelope the handler
|
|
80
|
+
* produced).
|
|
81
|
+
*/
|
|
82
|
+
export const GatewayRpcResponseFrameSchema = z
|
|
83
|
+
.object({
|
|
84
|
+
/** Frozen protocol version. */
|
|
85
|
+
protocol_version: z.string(),
|
|
86
|
+
/** Correlation id echoed from the originating request. */
|
|
87
|
+
id: z.string().min(1),
|
|
88
|
+
/** Direction discriminator. */
|
|
89
|
+
direction: z.literal('response'),
|
|
90
|
+
/** The gateway dispatch response (LAFS envelope). */
|
|
91
|
+
response: dispatchResponseSchema,
|
|
92
|
+
})
|
|
93
|
+
.strict();
|
|
94
|
+
// ─── Error frame (server → client) ─────────────────────────────────────────────
|
|
95
|
+
/**
|
|
96
|
+
* A server → client protocol-level error frame, emitted when a request frame
|
|
97
|
+
* cannot be decoded or routed. Correlation `id` is best-effort (`'0'` when the
|
|
98
|
+
* frame was so malformed the id could not be recovered).
|
|
99
|
+
*/
|
|
100
|
+
export const GatewayRpcErrorFrameSchema = z
|
|
101
|
+
.object({
|
|
102
|
+
/** Frozen protocol version. */
|
|
103
|
+
protocol_version: z.string(),
|
|
104
|
+
/** Correlation id (best-effort; `'0'` when unrecoverable). */
|
|
105
|
+
id: z.string().min(1),
|
|
106
|
+
/** Direction discriminator. */
|
|
107
|
+
direction: z.literal('error'),
|
|
108
|
+
/** The protocol-level error. */
|
|
109
|
+
error: GatewayRpcErrorSchema,
|
|
110
|
+
})
|
|
111
|
+
.strict();
|
|
112
|
+
// ─── Top-level frame union ─────────────────────────────────────────────────────
|
|
113
|
+
/**
|
|
114
|
+
* The top-level RPC frame: a versioned, correlated wrapper that is a request,
|
|
115
|
+
* a response, or a protocol-level error, discriminated by `direction`. One
|
|
116
|
+
* frame per NDJSON line.
|
|
117
|
+
*/
|
|
118
|
+
export const GatewayRpcFrameSchema = z.discriminatedUnion('direction', [
|
|
119
|
+
GatewayRpcRequestFrameSchema,
|
|
120
|
+
GatewayRpcResponseFrameSchema,
|
|
121
|
+
GatewayRpcErrorFrameSchema,
|
|
122
|
+
]);
|
|
123
|
+
// ─── Frozen direction-set guard ────────────────────────────────────────────────
|
|
124
|
+
/**
|
|
125
|
+
* The FROZEN v1.0 `direction` discriminator values. The drift guard
|
|
126
|
+
* (`__tests__/freeze.test.ts`) pins this tuple; any addition/removal is a
|
|
127
|
+
* contract-breaking change requiring a new versioned directory.
|
|
128
|
+
*/
|
|
129
|
+
export const GATEWAY_RPC_DIRECTIONS = ['request', 'response', 'error'];
|
|
130
|
+
/**
|
|
131
|
+
* The FROZEN v1.0 protocol-level transport error codes the adapter emits in an
|
|
132
|
+
* {@link GatewayRpcErrorFrameSchema}. Pinned by the drift guard.
|
|
133
|
+
*/
|
|
134
|
+
export const GATEWAY_RPC_ERROR_CODES = [
|
|
135
|
+
'E_RPC_PARSE',
|
|
136
|
+
'E_RPC_BAD_VERSION',
|
|
137
|
+
'E_RPC_BAD_FRAME',
|
|
138
|
+
'E_RPC_INTERNAL',
|
|
139
|
+
];
|
|
140
|
+
/**
|
|
141
|
+
* Type guard: is `v` the frozen RPC protocol version this contract pins?
|
|
142
|
+
*
|
|
143
|
+
* Used by the adapter's version-negotiation step to reject mismatched frames
|
|
144
|
+
* with an `E_RPC_BAD_VERSION` error frame before any gateway routing.
|
|
145
|
+
*
|
|
146
|
+
* @param v - The candidate `protocol_version` string from an inbound frame.
|
|
147
|
+
* @returns `true` iff `v` equals {@link GATEWAY_RPC_PROTOCOL_VERSION}.
|
|
148
|
+
*/
|
|
149
|
+
export function isFrozenGatewayRpcVersion(v) {
|
|
150
|
+
return v === GATEWAY_RPC_PROTOCOL_VERSION;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/gateway/rpc/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAE5D,kFAAkF;AAElF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC;KACnC,MAAM,CAAC;IACN,wEAAwE;IACxE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,oCAAoC;IACpC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC;KACD,MAAM,EAAE,CAAC;AAKZ,kFAAkF;AAElF;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC;KAC1C,MAAM,CAAC;IACN,yEAAyE;IACzE,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