Skip to content

Commit 1ff2284

Browse files
committed
feat(js/protocol): add registerExposure + exposureRegistered envelopes
Phase 7.0 wire helpers — Python parity with zhub.protocol.register_exposure and exposure_registered. Standalone so callers wanting to drive the /ws/expose endpoint directly don't have to hand-build the envelope shape.
1 parent c048eb6 commit 1ff2284

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

js/src/protocol.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,33 @@ export function invokeResult(
113113
);
114114
}
115115

116+
export function registerExposure(
117+
name: string,
118+
manifest: Record<string, unknown>,
119+
deviceKey?: string | null,
120+
): Envelope {
121+
// Phase 7.0: device announces capabilities WITHOUT pairing to an AI.
122+
// Hub mints a `dx_` device key + `ex_` exposure id on first register;
123+
// re-registration with the same device_key restores the same exposure_id.
124+
return envelope('register-exposure', {
125+
name,
126+
manifest,
127+
device_key: deviceKey ?? null,
128+
});
129+
}
130+
131+
export function exposureRegistered(
132+
exposureId: string,
133+
deviceKey: string,
134+
name: string,
135+
): Envelope {
136+
return envelope('exposure-registered', {
137+
exposure_id: exposureId,
138+
device_key: deviceKey,
139+
name,
140+
});
141+
}
142+
116143
export function errorEnvelope(
117144
requestId: string,
118145
code: string,

0 commit comments

Comments
 (0)