@velmlabs/unstuck-protocol 0.1.2 → 0.1.4

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/index.d.ts CHANGED
@@ -161,6 +161,18 @@ type ViewerInput = Extract<ViewerToEngine, {
161
161
  }>;
162
162
  declare const ViewerErrorCodes: readonly ["token_invalid", "token_used", "expired", "session_closed", "bad_message", "code_required", "code_invalid"];
163
163
  type ViewerErrorCode = (typeof ViewerErrorCodes)[number];
164
+ /** What kind of field the person can type into, so the viewer can open the matching keyboard (never its value). */
165
+ declare const FieldKinds: readonly ["text", "numeric", "otp", "email", "password"];
166
+ type FieldKind = (typeof FieldKinds)[number];
167
+ /** A typable field's box in CSS pixels of the streamed viewport (the same space as `mouse` messages). */
168
+ declare const FieldSchema: _sinclair_typebox.TObject<{
169
+ x: _sinclair_typebox.TNumber;
170
+ y: _sinclair_typebox.TNumber;
171
+ w: _sinclair_typebox.TNumber;
172
+ h: _sinclair_typebox.TNumber;
173
+ kind: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"text" | "numeric" | "otp" | "email" | "password">[]>;
174
+ }>;
175
+ type Field = Static<typeof FieldSchema>;
164
176
  declare const EngineToViewerSchema: _sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
165
177
  t: _sinclair_typebox.TLiteral<"ready">;
166
178
  reason: _sinclair_typebox.TString;
@@ -176,6 +188,25 @@ declare const EngineToViewerSchema: _sinclair_typebox.TUnion<[_sinclair_typebox.
176
188
  message: _sinclair_typebox.TString;
177
189
  }>, _sinclair_typebox.TObject<{
178
190
  t: _sinclair_typebox.TLiteral<"pong">;
191
+ }>, _sinclair_typebox.TObject<{
192
+ t: _sinclair_typebox.TLiteral<"fields">;
193
+ fields: _sinclair_typebox.TArray<_sinclair_typebox.TObject<{
194
+ x: _sinclair_typebox.TNumber;
195
+ y: _sinclair_typebox.TNumber;
196
+ w: _sinclair_typebox.TNumber;
197
+ h: _sinclair_typebox.TNumber;
198
+ kind: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"text" | "numeric" | "otp" | "email" | "password">[]>;
199
+ }>>;
200
+ }>, _sinclair_typebox.TObject<{
201
+ t: _sinclair_typebox.TLiteral<"focus">;
202
+ kind: _sinclair_typebox.TUnion<[_sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"text" | "numeric" | "otp" | "email" | "password">[]>, _sinclair_typebox.TNull]>;
203
+ field: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
204
+ x: _sinclair_typebox.TNumber;
205
+ y: _sinclair_typebox.TNumber;
206
+ w: _sinclair_typebox.TNumber;
207
+ h: _sinclair_typebox.TNumber;
208
+ kind: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"text" | "numeric" | "otp" | "email" | "password">[]>;
209
+ }>>;
179
210
  }>]>;
180
211
  type EngineToViewer = {
181
212
  t: 'ready';
@@ -192,8 +223,22 @@ type EngineToViewer = {
192
223
  message: string;
193
224
  } | {
194
225
  t: 'pong';
226
+ } | {
227
+ t: 'fields';
228
+ fields: Field[];
229
+ }
230
+ /** `field`: where the focused field is (engine 0.1.3+), so the viewer can outline it; never its value. */
231
+ | {
232
+ t: 'focus';
233
+ kind: FieldKind | null;
234
+ field?: Field;
195
235
  };
196
236
  declare function parseViewerMessage(raw: string): ViewerToEngine | null;
237
+ /**
238
+ * How long a human who left the viewer (switched apps to read a code, lost signal) can come back and resume.
239
+ * The engine frees the agent after this; the viewer stops retrying after it.
240
+ */
241
+ declare const RESUME_WINDOW_MS: number;
197
242
 
198
243
  declare const RELAY_SUBPROTOCOL = "unstuck-relay.1";
199
244
  declare const KEY_SUBPROTOCOL_PREFIX = "key.";
@@ -281,5 +326,5 @@ declare function openMsg(key: CryptoKey, sessionId: string, dir: Direction, conn
281
326
  plain: Uint8Array;
282
327
  } | null>;
283
328
 
284
- export { EngineToViewerSchema, FRAME_TYPE_JPEG, KEY_SUBPROTOCOL_PREFIX, Methods, PROTOCOL_VERSION, RELAY_CLOSE, RELAY_LIMITS, RELAY_SUBPROTOCOL, RpcCallError, SESSION_ID_RE, SessionStatusSchema, ViewerErrorCodes, ViewerToEngineSchema, b64urlDecode, b64urlEncode, createRpcPeer, decodeEnvelope, decodeFrame, encodeEnvelope, encodeFrame, importE2eKey, isJsonPlaintext, newConnNonce, newE2eKey, open, openMsg, parseAgentToRelay, parseRelayToAgent, parseViewerMessage, seal, sealMsg };
285
- export type { AgentToRelay, CdpClosedParams, CdpEventParams, CdpSendParams, CdpSubscribeParams, Direction, EngineToViewer, Frame, HelloParams, HelloResult, PagePopupParams, RelayToAgent, RpcError, RpcNotification, RpcPeer, RpcRequest, RpcResponse, SessionStatus, TakeoverLinkParams, TakeoverParams, TakeoverResult, TakeoverStatus, ViewerErrorCode, ViewerInput, ViewerToEngine };
329
+ export { EngineToViewerSchema, FRAME_TYPE_JPEG, FieldKinds, FieldSchema, KEY_SUBPROTOCOL_PREFIX, Methods, PROTOCOL_VERSION, RELAY_CLOSE, RELAY_LIMITS, RELAY_SUBPROTOCOL, RESUME_WINDOW_MS, RpcCallError, SESSION_ID_RE, SessionStatusSchema, ViewerErrorCodes, ViewerToEngineSchema, b64urlDecode, b64urlEncode, createRpcPeer, decodeEnvelope, decodeFrame, encodeEnvelope, encodeFrame, importE2eKey, isJsonPlaintext, newConnNonce, newE2eKey, open, openMsg, parseAgentToRelay, parseRelayToAgent, parseViewerMessage, seal, sealMsg };
330
+ export type { AgentToRelay, CdpClosedParams, CdpEventParams, CdpSendParams, CdpSubscribeParams, Direction, EngineToViewer, Field, FieldKind, Frame, HelloParams, HelloResult, PagePopupParams, RelayToAgent, RpcError, RpcNotification, RpcPeer, RpcRequest, RpcResponse, SessionStatus, TakeoverLinkParams, TakeoverParams, TakeoverResult, TakeoverStatus, ViewerErrorCode, ViewerInput, ViewerToEngine };
package/dist/index.js CHANGED
@@ -159,11 +159,16 @@ var ViewerToEngineSchema = Type.Union([
159
159
  Type.Object({ t: Lit("ping") }, { additionalProperties: false })
160
160
  ]);
161
161
  var ViewerErrorCodes = ["token_invalid", "token_used", "expired", "session_closed", "bad_message", "code_required", "code_invalid"];
162
+ var FieldKinds = ["text", "numeric", "otp", "email", "password"];
163
+ var FieldKindSchema = Type.Union(FieldKinds.map((k) => Lit(k)));
164
+ var FieldSchema = Type.Object({ x: Num, y: Num, w: Num, h: Num, kind: FieldKindSchema }, { additionalProperties: false });
162
165
  var EngineToViewerSchema = Type.Union([
163
166
  Type.Object({ t: Lit("ready"), reason: Type.String(), site: Type.String(), expiresAt: Num, resumeKey: Type.String() }),
164
167
  Type.Object({ t: Lit("state"), status: SessionStatusSchema }),
165
168
  Type.Object({ t: Lit("error"), code: Type.Union(ViewerErrorCodes.map((c) => Lit(c))), message: Type.String() }),
166
- Type.Object({ t: Lit("pong") })
169
+ Type.Object({ t: Lit("pong") }),
170
+ Type.Object({ t: Lit("fields"), fields: Type.Array(FieldSchema, { maxItems: 30 }) }),
171
+ Type.Object({ t: Lit("focus"), kind: Type.Union([FieldKindSchema, Type.Null()]), field: Type.Optional(FieldSchema) })
167
172
  ]);
168
173
  function parseViewerMessage(raw) {
169
174
  let v;
@@ -174,6 +179,7 @@ function parseViewerMessage(raw) {
174
179
  }
175
180
  return Value.Check(ViewerToEngineSchema, v) ? v : null;
176
181
  }
182
+ var RESUME_WINDOW_MS = 5 * 6e4;
177
183
 
178
184
  // src/relay.ts
179
185
  import { Type as Type2 } from "@sinclair/typebox";
@@ -315,12 +321,15 @@ async function openMsg(key, sessionId, dir, conn, sealed) {
315
321
  export {
316
322
  EngineToViewerSchema,
317
323
  FRAME_TYPE_JPEG,
324
+ FieldKinds,
325
+ FieldSchema,
318
326
  KEY_SUBPROTOCOL_PREFIX,
319
327
  Methods,
320
328
  PROTOCOL_VERSION,
321
329
  RELAY_CLOSE,
322
330
  RELAY_LIMITS,
323
331
  RELAY_SUBPROTOCOL,
332
+ RESUME_WINDOW_MS,
324
333
  RpcCallError,
325
334
  SESSION_ID_RE,
326
335
  SessionStatusSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velmlabs/unstuck-protocol",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Wire protocol shared by the Unstuck engine, viewer and relays (frames, RPC, end-to-end encryption).",
5
5
  "keywords": [
6
6
  "ai",