Skip to content

Commit 60621c2

Browse files
feat: add protocol source-of-truth schemas (TIER-1) (#52)
Introduce a new self-contained src/protocol/ directory that mirrors the private factory-mono-alpha protocol schemas/enums exactly (zod-only, no internal deps). This is the first step toward making droid-sdk-typescript the single source of truth for the wire protocol, eliminating manual drift. Covers TIER-1 foundation only: leaf enums, the JSON-RPC envelope family, HostId, SessionTag, TokenUsage, loop schemas, and the message content-block stack. Not yet wired into the public API (src/index.ts); existing files are untouched. Adds tests/protocol-dir.test.ts round-trip coverage. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
1 parent 36ba678 commit 60621c2

10 files changed

Lines changed: 1209 additions & 0 deletions

File tree

src/protocol/constants.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Source-of-truth mirror of factory-mono-alpha protocol constants.
2+
// Faithful copy of:
3+
// packages/common/src/droid/schemas/constants.ts
4+
// packages/common/src/droid/constants.ts (LOOP_INTERVAL_POLICY)
5+
// Keep shapes/values identical to the private monorepo to avoid protocol drift.
6+
7+
/**
8+
* Legacy envelope field for old JSON-RPC peers - `factoryApiVersion` must be set to this value.
9+
*
10+
* @deprecated Do not change this value; use `factoryProtocolVersion` for runtime compatibility.
11+
*/
12+
export const LEGACY_FACTORY_API_VERSION = '1.0.0' as const;
13+
14+
export const FACTORY_PROTOCOL_VERSION = '1.62.0' as const;
15+
16+
export const JSONRPC_VERSION = '2.0' as const;
17+
18+
const seconds = (value: number) => value * 1_000;
19+
const minutes = (value: number) => seconds(value * 60);
20+
const hours = (value: number) => minutes(value * 60);
21+
22+
export const LOOP_INTERVAL_POLICY = {
23+
minMs: seconds(5),
24+
maxMs: hours(24),
25+
displayRange: '5s–24h',
26+
examples: '5s, 5m, 30m, 2h',
27+
} as const;

0 commit comments

Comments
 (0)