@motebit/protocol 0.8.0 → 1.1.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/LICENSE +198 -18
- package/NOTICE +19 -0
- package/README.md +37 -5
- package/dist/agent-settlement-anchor.d.ts +102 -0
- package/dist/agent-settlement-anchor.d.ts.map +1 -0
- package/dist/agent-settlement-anchor.js +18 -0
- package/dist/agent-settlement-anchor.js.map +1 -0
- package/dist/computer-use.d.ts +312 -0
- package/dist/computer-use.d.ts.map +1 -0
- package/dist/computer-use.js +86 -0
- package/dist/computer-use.js.map +1 -0
- package/dist/credential-anchor.d.ts +17 -2
- package/dist/credential-anchor.d.ts.map +1 -1
- package/dist/credential-anchor.js +3 -2
- package/dist/credential-anchor.js.map +1 -1
- package/dist/crypto-suite.d.ts +100 -0
- package/dist/crypto-suite.d.ts.map +1 -0
- package/dist/crypto-suite.js +93 -0
- package/dist/crypto-suite.js.map +1 -0
- package/dist/discovery.d.ts +87 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +9 -0
- package/dist/discovery.js.map +1 -0
- package/dist/dispute.d.ts +176 -0
- package/dist/dispute.d.ts.map +1 -0
- package/dist/dispute.js +9 -0
- package/dist/dispute.js.map +1 -0
- package/dist/goal-lifecycle.d.ts +129 -0
- package/dist/goal-lifecycle.d.ts.map +1 -0
- package/dist/goal-lifecycle.js +29 -0
- package/dist/goal-lifecycle.js.map +1 -0
- package/dist/index.d.ts +704 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -3
- package/dist/index.js.map +1 -1
- package/dist/memory-events.d.ts +140 -0
- package/dist/memory-events.d.ts.map +1 -0
- package/dist/memory-events.js +29 -0
- package/dist/memory-events.js.map +1 -0
- package/dist/migration.d.ts +180 -0
- package/dist/migration.d.ts.map +1 -0
- package/dist/migration.js +9 -0
- package/dist/migration.js.map +1 -0
- package/dist/plan-lifecycle.d.ts +147 -0
- package/dist/plan-lifecycle.d.ts.map +1 -0
- package/dist/plan-lifecycle.js +36 -0
- package/dist/plan-lifecycle.js.map +1 -0
- package/dist/semiring.d.ts +16 -0
- package/dist/semiring.d.ts.map +1 -1
- package/dist/semiring.js +21 -0
- package/dist/semiring.js.map +1 -1
- package/dist/settlement-mode.d.ts +68 -0
- package/dist/settlement-mode.d.ts.map +1 -0
- package/dist/settlement-mode.js +8 -0
- package/dist/settlement-mode.js.map +1 -0
- package/dist/tool-mode.d.ts +46 -0
- package/dist/tool-mode.d.ts.map +1 -0
- package/dist/tool-mode.js +50 -0
- package/dist/tool-mode.js.map +1 -0
- package/dist/trust-algebra.d.ts +15 -0
- package/dist/trust-algebra.d.ts.map +1 -1
- package/dist/trust-algebra.js +32 -2
- package/dist/trust-algebra.js.map +1 -1
- package/package.json +8 -5
- package/dist/__tests__/branded-ids.test.d.ts +0 -2
- package/dist/__tests__/branded-ids.test.d.ts.map +0 -1
- package/dist/__tests__/branded-ids.test.js +0 -70
- package/dist/__tests__/branded-ids.test.js.map +0 -1
- package/dist/__tests__/semiring-laws.test.d.ts +0 -25
- package/dist/__tests__/semiring-laws.test.d.ts.map +0 -1
- package/dist/__tests__/semiring-laws.test.js +0 -231
- package/dist/__tests__/semiring-laws.test.js.map +0 -1
- package/dist/__tests__/semiring.test.d.ts +0 -2
- package/dist/__tests__/semiring.test.d.ts.map +0 -1
- package/dist/__tests__/semiring.test.js +0 -201
- package/dist/__tests__/semiring.test.js.map +0 -1
- package/dist/__tests__/traversal.test.d.ts +0 -2
- package/dist/__tests__/traversal.test.d.ts.map +0 -1
- package/dist/__tests__/traversal.test.js +0 -331
- package/dist/__tests__/traversal.test.js.map +0 -1
- package/dist/__tests__/trust-algebra.test.d.ts +0 -2
- package/dist/__tests__/trust-algebra.test.d.ts.map +0 -1
- package/dist/__tests__/trust-algebra.test.js +0 -105
- package/dist/__tests__/trust-algebra.test.js.map +0 -1
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computer-use payload types — wire format for `computer-use-v1.md`.
|
|
3
|
+
*
|
|
4
|
+
* A motebit with a desktop surface (Tauri) can observe and act on the user's
|
|
5
|
+
* computer: screenshot, move, click, type, scroll. This spec pins the wire
|
|
6
|
+
* format of each action and observation so the signed audit trail is
|
|
7
|
+
* implementation-agnostic — a non-TypeScript verifier can validate payloads
|
|
8
|
+
* against the committed JSON Schema rather than TypeScript's structural view.
|
|
9
|
+
*
|
|
10
|
+
* Shape: actions are a **nested discriminated union** (`action: { kind, ... }`)
|
|
11
|
+
* not a flat envelope. Impossible states are structurally unrepresentable —
|
|
12
|
+
* drag-only fields never appear on a click, type-only fields never appear on
|
|
13
|
+
* a scroll. Cross-language SDKs (Rust enums, Python tagged unions) map
|
|
14
|
+
* directly; JSON Schema emits clean `oneOf` branches; model output stays
|
|
15
|
+
* rigorous.
|
|
16
|
+
*
|
|
17
|
+
* Observation results carry **artifact references** (`artifact_id +
|
|
18
|
+
* artifact_sha256`) not inline bytes. The receipt artifact store (see
|
|
19
|
+
* `spec/execution-ledger-v1.md`) holds the bytes; the observation payload
|
|
20
|
+
* binds to them by hash. Keeps signed receipts O(bytes of metadata) instead
|
|
21
|
+
* of O(bytes of image). Git / IPFS / S3+hash pattern.
|
|
22
|
+
*
|
|
23
|
+
* Every type named here is referenced by a `### X.Y — Name` section under a
|
|
24
|
+
* `#### Wire format (foundation law)` block in `spec/computer-use-v1.md`,
|
|
25
|
+
* so `check-spec-coverage` (invariant #9) keeps the spec and types in
|
|
26
|
+
* lockstep.
|
|
27
|
+
*
|
|
28
|
+
* ── Release status ───────────────────────────────────────────────────
|
|
29
|
+
*
|
|
30
|
+
* Every export in this file carries `@alpha` — the wire format was revised
|
|
31
|
+
* on 2026-04-22 in response to external principal review (commit 54158b11,
|
|
32
|
+
* flat envelope → nested discriminated union) and has only soaked inside
|
|
33
|
+
* the monorepo since. `@alpha` carves these types out of `@motebit/protocol`'s
|
|
34
|
+
* SemVer contract for the 1.x series: the `check-api-surface` baseline still
|
|
35
|
+
* tracks their shape so unintended drift is caught, but a shape reshape does
|
|
36
|
+
* not force a major bump. Promote to `@beta` → `@public` once a second
|
|
37
|
+
* producer (cloud-browser surface, federation peer replaying an audit log)
|
|
38
|
+
* or a non-desktop-shim consumer exercises the format in anger.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* A point in primary-display logical pixel coordinates. `(0, 0)` = top-left.
|
|
42
|
+
* @alpha
|
|
43
|
+
*/
|
|
44
|
+
export interface ComputerPoint {
|
|
45
|
+
readonly x: number;
|
|
46
|
+
readonly y: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Optional semantic target information attached to pointer actions. When
|
|
50
|
+
* available from the accessibility layer or DOM, it lets verifiers and
|
|
51
|
+
* approval UX explain "motebit clicked the Send button" instead of only
|
|
52
|
+
* "(512, 384)". Execution still happens at the pixel coordinates in
|
|
53
|
+
* `target`; the hint is advisory.
|
|
54
|
+
* @alpha
|
|
55
|
+
*/
|
|
56
|
+
export interface ComputerTargetHint {
|
|
57
|
+
/** Role name. Examples: `"button"`, `"link"`, `"textbox"`, `"menuitem"`. */
|
|
58
|
+
readonly role?: string;
|
|
59
|
+
/** Accessible label or visible text. */
|
|
60
|
+
readonly label?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Where the hint came from. `"accessibility"` (OS AX API), `"dom"`
|
|
63
|
+
* (browser inspection), `"vision"` (OCR/ML), `"user_annotation"` (user
|
|
64
|
+
* labeled the region in-session).
|
|
65
|
+
*/
|
|
66
|
+
readonly source: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Capture the primary display's current frame.
|
|
70
|
+
* @alpha
|
|
71
|
+
*/
|
|
72
|
+
export interface ScreenshotAction {
|
|
73
|
+
readonly kind: "screenshot";
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Read the current cursor coordinates.
|
|
77
|
+
* @alpha
|
|
78
|
+
*/
|
|
79
|
+
export interface CursorPositionAction {
|
|
80
|
+
readonly kind: "cursor_position";
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Single mouse click at `target`.
|
|
84
|
+
* @alpha
|
|
85
|
+
*/
|
|
86
|
+
export interface ClickAction {
|
|
87
|
+
readonly kind: "click";
|
|
88
|
+
readonly target: ComputerPoint;
|
|
89
|
+
/** `"left" | "right" | "middle"`. Defaults to `"left"`. */
|
|
90
|
+
readonly button?: string;
|
|
91
|
+
/** Subset of `["cmd", "ctrl", "alt", "shift"]`. */
|
|
92
|
+
readonly modifiers?: readonly string[];
|
|
93
|
+
readonly target_hint?: ComputerTargetHint;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Two clicks in rapid succession at `target`.
|
|
97
|
+
* @alpha
|
|
98
|
+
*/
|
|
99
|
+
export interface DoubleClickAction {
|
|
100
|
+
readonly kind: "double_click";
|
|
101
|
+
readonly target: ComputerPoint;
|
|
102
|
+
readonly button?: string;
|
|
103
|
+
readonly modifiers?: readonly string[];
|
|
104
|
+
readonly target_hint?: ComputerTargetHint;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Move cursor to `target` without clicking.
|
|
108
|
+
* @alpha
|
|
109
|
+
*/
|
|
110
|
+
export interface MouseMoveAction {
|
|
111
|
+
readonly kind: "mouse_move";
|
|
112
|
+
readonly target: ComputerPoint;
|
|
113
|
+
readonly target_hint?: ComputerTargetHint;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Press at `from`, move to `to`, release.
|
|
117
|
+
* @alpha
|
|
118
|
+
*/
|
|
119
|
+
export interface DragAction {
|
|
120
|
+
readonly kind: "drag";
|
|
121
|
+
readonly from: ComputerPoint;
|
|
122
|
+
readonly to: ComputerPoint;
|
|
123
|
+
readonly button?: string;
|
|
124
|
+
readonly modifiers?: readonly string[];
|
|
125
|
+
/** Total drag duration in ms. Implementation may interpolate intermediate points. */
|
|
126
|
+
readonly duration_ms?: number;
|
|
127
|
+
readonly target_hint?: ComputerTargetHint;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Keyboard text input.
|
|
131
|
+
* @alpha
|
|
132
|
+
*/
|
|
133
|
+
export interface TypeAction {
|
|
134
|
+
readonly kind: "type";
|
|
135
|
+
readonly text: string;
|
|
136
|
+
/**
|
|
137
|
+
* Per-character delay in ms. Omitted = implementation default. Set to a
|
|
138
|
+
* stable value for deterministic replay of typing cadence.
|
|
139
|
+
*/
|
|
140
|
+
readonly per_char_delay_ms?: number;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Keyboard combination. Example: `"cmd+c"`, `"ctrl+shift+t"`, `"escape"`.
|
|
144
|
+
* @alpha
|
|
145
|
+
*/
|
|
146
|
+
export interface KeyAction {
|
|
147
|
+
readonly kind: "key";
|
|
148
|
+
readonly key: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Scroll at `target` by `(dx, dy)` wheel deltas.
|
|
152
|
+
* @alpha
|
|
153
|
+
*/
|
|
154
|
+
export interface ScrollAction {
|
|
155
|
+
readonly kind: "scroll";
|
|
156
|
+
readonly target: ComputerPoint;
|
|
157
|
+
readonly dx: number;
|
|
158
|
+
readonly dy: number;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Full action taxonomy. Every concrete action the motebit can request is
|
|
162
|
+
* one of these. Exhaustive discriminated union on `kind`.
|
|
163
|
+
* @alpha
|
|
164
|
+
*/
|
|
165
|
+
export type ComputerAction = ScreenshotAction | CursorPositionAction | ClickAction | DoubleClickAction | MouseMoveAction | DragAction | TypeAction | KeyAction | ScrollAction;
|
|
166
|
+
/**
|
|
167
|
+
* Discriminator values — useful for JSON Schema enum and runtime validation.
|
|
168
|
+
* @alpha
|
|
169
|
+
*/
|
|
170
|
+
export declare const COMPUTER_ACTION_KINDS: readonly ["screenshot", "cursor_position", "click", "double_click", "mouse_move", "drag", "type", "key", "scroll"];
|
|
171
|
+
/** @alpha */
|
|
172
|
+
export type ComputerActionKind = (typeof COMPUTER_ACTION_KINDS)[number];
|
|
173
|
+
/**
|
|
174
|
+
* One invocation of the `computer` tool. The `action` field holds a nested
|
|
175
|
+
* discriminated variant; all action-specific fields live inside that
|
|
176
|
+
* object. Impossible states are structurally unrepresentable.
|
|
177
|
+
* @alpha
|
|
178
|
+
*/
|
|
179
|
+
export interface ComputerActionRequest {
|
|
180
|
+
/** Open session the action belongs to. */
|
|
181
|
+
readonly session_id: string;
|
|
182
|
+
readonly action: ComputerAction;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Outcome of a successful observation action's execution. Returned as the
|
|
186
|
+
* `data` field of a `ToolResult`. Discriminated by `kind`.
|
|
187
|
+
* @alpha
|
|
188
|
+
*/
|
|
189
|
+
export type ComputerObservationResult = ScreenshotObservation | CursorPositionObservation;
|
|
190
|
+
/**
|
|
191
|
+
* Structured redaction metadata. Replaces a bare boolean — a verifier can
|
|
192
|
+
* now prove *what* was redacted, under *which* policy version, and whether
|
|
193
|
+
* the bytes the AI saw are raw or a projection.
|
|
194
|
+
* @alpha
|
|
195
|
+
*/
|
|
196
|
+
export interface ComputerRedaction {
|
|
197
|
+
/** `true` iff any region was classified as sensitive and masked. */
|
|
198
|
+
readonly applied: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Projection shape of the bytes the AI consumed. `"raw"` = unmodified
|
|
201
|
+
* capture, `"masked"` = regions replaced with solid fill,
|
|
202
|
+
* `"blurred"` = regions convolved, `"cropped"` = sensitive regions
|
|
203
|
+
* removed from frame. Surfaces MAY add projection kinds in v1.1.
|
|
204
|
+
*/
|
|
205
|
+
readonly projection_kind: string;
|
|
206
|
+
/** Version string of the sensitivity-classification policy that ran. */
|
|
207
|
+
readonly policy_version?: string;
|
|
208
|
+
/** Number of regions classified as sensitive in the raw frame. */
|
|
209
|
+
readonly classified_regions_count?: number;
|
|
210
|
+
/**
|
|
211
|
+
* SHA-256 digest of a canonical JSON array of classified regions
|
|
212
|
+
* (each region: `{ x, y, w, h, classification }`). Lets a verifier
|
|
213
|
+
* replay what was masked without exposing the region list in the
|
|
214
|
+
* receipt if policy dictates.
|
|
215
|
+
*/
|
|
216
|
+
readonly classified_regions_digest?: string;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Screenshot observation. Bytes live in the receipt artifact store keyed
|
|
220
|
+
* by `artifact_id` and bound by `artifact_sha256`. When redaction produces
|
|
221
|
+
* a distinct projection (e.g. masked image), both the raw and projection
|
|
222
|
+
* artifact IDs are referenced so a verifier can fetch either depending on
|
|
223
|
+
* authorization.
|
|
224
|
+
* @alpha
|
|
225
|
+
*/
|
|
226
|
+
export interface ScreenshotObservation {
|
|
227
|
+
readonly kind: "screenshot";
|
|
228
|
+
readonly session_id: string;
|
|
229
|
+
/** Artifact ID of the raw capture in the artifact store. */
|
|
230
|
+
readonly artifact_id: string;
|
|
231
|
+
/** SHA-256 of the raw capture's bytes. */
|
|
232
|
+
readonly artifact_sha256: string;
|
|
233
|
+
/** `"png" | "jpeg"`. */
|
|
234
|
+
readonly image_format: string;
|
|
235
|
+
/** Image width in logical pixels. */
|
|
236
|
+
readonly width: number;
|
|
237
|
+
/** Image height in logical pixels. */
|
|
238
|
+
readonly height: number;
|
|
239
|
+
/** Unix ms of the capture. */
|
|
240
|
+
readonly captured_at: number;
|
|
241
|
+
readonly redaction: ComputerRedaction;
|
|
242
|
+
/**
|
|
243
|
+
* Artifact ID of the redacted projection, when `redaction.applied` and
|
|
244
|
+
* the projection differs from the raw capture. When absent, the AI saw
|
|
245
|
+
* the raw bytes (redaction.projection_kind === "raw").
|
|
246
|
+
*/
|
|
247
|
+
readonly projection_artifact_id?: string;
|
|
248
|
+
/** SHA-256 of the projection bytes. Paired with `projection_artifact_id`. */
|
|
249
|
+
readonly projection_artifact_sha256?: string;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Cursor-position observation — single coordinate pair.
|
|
253
|
+
* @alpha
|
|
254
|
+
*/
|
|
255
|
+
export interface CursorPositionObservation {
|
|
256
|
+
readonly kind: "cursor_position";
|
|
257
|
+
readonly session_id: string;
|
|
258
|
+
readonly x: number;
|
|
259
|
+
readonly y: number;
|
|
260
|
+
readonly captured_at: number;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Signed event emitted when a computer-use session begins. Carries the
|
|
264
|
+
* primary display's dimensions and scaling factor so the AI knows the
|
|
265
|
+
* coordinate space subsequent actions will operate in.
|
|
266
|
+
*
|
|
267
|
+
* `display_width` and `display_height` are logical pixels (the dimensions
|
|
268
|
+
* action coordinates live in). `scaling_factor` is the logical-to-physical
|
|
269
|
+
* ratio (Retina = 2.0). Screenshot dimensions returned in observations
|
|
270
|
+
* match the logical dimensions, not the physical raster.
|
|
271
|
+
* @alpha
|
|
272
|
+
*/
|
|
273
|
+
export interface ComputerSessionOpened {
|
|
274
|
+
readonly session_id: string;
|
|
275
|
+
readonly motebit_id: string;
|
|
276
|
+
readonly display_width: number;
|
|
277
|
+
readonly display_height: number;
|
|
278
|
+
readonly scaling_factor: number;
|
|
279
|
+
readonly opened_at: number;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Signed event emitted when a computer-use session ends.
|
|
283
|
+
* @alpha
|
|
284
|
+
*/
|
|
285
|
+
export interface ComputerSessionClosed {
|
|
286
|
+
readonly session_id: string;
|
|
287
|
+
readonly closed_at: number;
|
|
288
|
+
/** Free-text code. Examples: `"user_closed"`, `"timeout"`, `"error"`. */
|
|
289
|
+
readonly reason?: string;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Structured failure reasons a computer-use action may return. Every
|
|
293
|
+
* implementation MUST emit one of these (or a v1.1-extended value) on
|
|
294
|
+
* failure so the motebit's reasoning loop and the governance audit can
|
|
295
|
+
* discriminate cases deterministically.
|
|
296
|
+
*
|
|
297
|
+
* policy_denied — governance classified the action as deny
|
|
298
|
+
* approval_required — governance classified as require_approval; no consent yet
|
|
299
|
+
* approval_expired — consent was obtained but its window elapsed
|
|
300
|
+
* permission_denied — OS refused (e.g. no Screen Recording permission on macOS)
|
|
301
|
+
* session_closed — action fired outside an open session
|
|
302
|
+
* target_not_found — element at `target` coords no longer exists (accessibility-verified fail)
|
|
303
|
+
* target_obscured — element exists but is covered (menu over it, etc.)
|
|
304
|
+
* user_preempted — physical user input interrupted mid-dispatch
|
|
305
|
+
* platform_blocked — OS blocked synthetic input (secure password field, elevation boundary)
|
|
306
|
+
* not_supported — surface cannot execute computer use at all
|
|
307
|
+
* @alpha
|
|
308
|
+
*/
|
|
309
|
+
export declare const COMPUTER_FAILURE_REASONS: readonly ["policy_denied", "approval_required", "approval_expired", "permission_denied", "session_closed", "target_not_found", "target_obscured", "user_preempted", "platform_blocked", "not_supported"];
|
|
310
|
+
/** @alpha */
|
|
311
|
+
export type ComputerFailureReason = (typeof COMPUTER_FAILURE_REASONS)[number];
|
|
312
|
+
//# sourceMappingURL=computer-use.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computer-use.d.ts","sourceRoot":"","sources":["../src/computer-use.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAIH;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAID;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,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C,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,yEAAyE;IACzE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAID;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,wBAAwB,0MAW3B,CAAC;AAEX,aAAa;AACb,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computer-use payload types — wire format for `computer-use-v1.md`.
|
|
3
|
+
*
|
|
4
|
+
* A motebit with a desktop surface (Tauri) can observe and act on the user's
|
|
5
|
+
* computer: screenshot, move, click, type, scroll. This spec pins the wire
|
|
6
|
+
* format of each action and observation so the signed audit trail is
|
|
7
|
+
* implementation-agnostic — a non-TypeScript verifier can validate payloads
|
|
8
|
+
* against the committed JSON Schema rather than TypeScript's structural view.
|
|
9
|
+
*
|
|
10
|
+
* Shape: actions are a **nested discriminated union** (`action: { kind, ... }`)
|
|
11
|
+
* not a flat envelope. Impossible states are structurally unrepresentable —
|
|
12
|
+
* drag-only fields never appear on a click, type-only fields never appear on
|
|
13
|
+
* a scroll. Cross-language SDKs (Rust enums, Python tagged unions) map
|
|
14
|
+
* directly; JSON Schema emits clean `oneOf` branches; model output stays
|
|
15
|
+
* rigorous.
|
|
16
|
+
*
|
|
17
|
+
* Observation results carry **artifact references** (`artifact_id +
|
|
18
|
+
* artifact_sha256`) not inline bytes. The receipt artifact store (see
|
|
19
|
+
* `spec/execution-ledger-v1.md`) holds the bytes; the observation payload
|
|
20
|
+
* binds to them by hash. Keeps signed receipts O(bytes of metadata) instead
|
|
21
|
+
* of O(bytes of image). Git / IPFS / S3+hash pattern.
|
|
22
|
+
*
|
|
23
|
+
* Every type named here is referenced by a `### X.Y — Name` section under a
|
|
24
|
+
* `#### Wire format (foundation law)` block in `spec/computer-use-v1.md`,
|
|
25
|
+
* so `check-spec-coverage` (invariant #9) keeps the spec and types in
|
|
26
|
+
* lockstep.
|
|
27
|
+
*
|
|
28
|
+
* ── Release status ───────────────────────────────────────────────────
|
|
29
|
+
*
|
|
30
|
+
* Every export in this file carries `@alpha` — the wire format was revised
|
|
31
|
+
* on 2026-04-22 in response to external principal review (commit 54158b11,
|
|
32
|
+
* flat envelope → nested discriminated union) and has only soaked inside
|
|
33
|
+
* the monorepo since. `@alpha` carves these types out of `@motebit/protocol`'s
|
|
34
|
+
* SemVer contract for the 1.x series: the `check-api-surface` baseline still
|
|
35
|
+
* tracks their shape so unintended drift is caught, but a shape reshape does
|
|
36
|
+
* not force a major bump. Promote to `@beta` → `@public` once a second
|
|
37
|
+
* producer (cloud-browser surface, federation peer replaying an audit log)
|
|
38
|
+
* or a non-desktop-shim consumer exercises the format in anger.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Discriminator values — useful for JSON Schema enum and runtime validation.
|
|
42
|
+
* @alpha
|
|
43
|
+
*/
|
|
44
|
+
export const COMPUTER_ACTION_KINDS = [
|
|
45
|
+
"screenshot",
|
|
46
|
+
"cursor_position",
|
|
47
|
+
"click",
|
|
48
|
+
"double_click",
|
|
49
|
+
"mouse_move",
|
|
50
|
+
"drag",
|
|
51
|
+
"type",
|
|
52
|
+
"key",
|
|
53
|
+
"scroll",
|
|
54
|
+
];
|
|
55
|
+
// ── Outcome taxonomy ─────────────────────────────────────────────────
|
|
56
|
+
/**
|
|
57
|
+
* Structured failure reasons a computer-use action may return. Every
|
|
58
|
+
* implementation MUST emit one of these (or a v1.1-extended value) on
|
|
59
|
+
* failure so the motebit's reasoning loop and the governance audit can
|
|
60
|
+
* discriminate cases deterministically.
|
|
61
|
+
*
|
|
62
|
+
* policy_denied — governance classified the action as deny
|
|
63
|
+
* approval_required — governance classified as require_approval; no consent yet
|
|
64
|
+
* approval_expired — consent was obtained but its window elapsed
|
|
65
|
+
* permission_denied — OS refused (e.g. no Screen Recording permission on macOS)
|
|
66
|
+
* session_closed — action fired outside an open session
|
|
67
|
+
* target_not_found — element at `target` coords no longer exists (accessibility-verified fail)
|
|
68
|
+
* target_obscured — element exists but is covered (menu over it, etc.)
|
|
69
|
+
* user_preempted — physical user input interrupted mid-dispatch
|
|
70
|
+
* platform_blocked — OS blocked synthetic input (secure password field, elevation boundary)
|
|
71
|
+
* not_supported — surface cannot execute computer use at all
|
|
72
|
+
* @alpha
|
|
73
|
+
*/
|
|
74
|
+
export const COMPUTER_FAILURE_REASONS = [
|
|
75
|
+
"policy_denied",
|
|
76
|
+
"approval_required",
|
|
77
|
+
"approval_expired",
|
|
78
|
+
"permission_denied",
|
|
79
|
+
"session_closed",
|
|
80
|
+
"target_not_found",
|
|
81
|
+
"target_obscured",
|
|
82
|
+
"user_preempted",
|
|
83
|
+
"platform_blocked",
|
|
84
|
+
"not_supported",
|
|
85
|
+
];
|
|
86
|
+
//# sourceMappingURL=computer-use.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computer-use.js","sourceRoot":"","sources":["../src/computer-use.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAyJH;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,YAAY;IACZ,iBAAiB;IACjB,OAAO;IACP,cAAc;IACd,YAAY;IACZ,MAAM;IACN,MAAM;IACN,KAAK;IACL,QAAQ;CACA,CAAC;AAwIX,wEAAwE;AAExE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,eAAe;IACf,mBAAmB;IACnB,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;IAChB,kBAAkB;IAClB,iBAAiB;IACjB,gBAAgB;IAChB,kBAAkB;IAClB,eAAe;CACP,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Credential anchor types — motebit/credential-anchor@1.0.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* Any implementation can produce and verify anchor
|
|
4
|
+
* Permissive floor (Apache-2.0): these types define the interoperable format
|
|
5
|
+
* for credential anchoring. Any implementation can produce and verify anchor
|
|
6
|
+
* proofs using these types.
|
|
6
7
|
*/
|
|
7
8
|
/** A batch of credential hashes anchored as a Merkle tree. */
|
|
8
9
|
export interface CredentialAnchorBatch {
|
|
@@ -18,6 +19,13 @@ export interface CredentialAnchorBatch {
|
|
|
18
19
|
first_issued_at: number;
|
|
19
20
|
/** Millisecond timestamp of the latest credential in the batch. */
|
|
20
21
|
last_issued_at: number;
|
|
22
|
+
/**
|
|
23
|
+
* Cryptosuite discriminator. Always `"motebit-jcs-ed25519-hex-v1"` —
|
|
24
|
+
* JCS canonicalization of the unsigned batch payload, Ed25519
|
|
25
|
+
* primitive, hex signature encoding, hex public-key encoding.
|
|
26
|
+
* Verifiers reject missing or unknown suite values fail-closed.
|
|
27
|
+
*/
|
|
28
|
+
suite: "motebit-jcs-ed25519-hex-v1";
|
|
21
29
|
/** Hex-encoded Ed25519 signature over the canonical batch payload. */
|
|
22
30
|
signature: string;
|
|
23
31
|
/** Onchain anchor metadata, or null if signed but not yet submitted. */
|
|
@@ -60,6 +68,13 @@ export interface CredentialAnchorProof {
|
|
|
60
68
|
relay_id: string;
|
|
61
69
|
/** Hex-encoded Ed25519 public key of the relay (for signature verification). */
|
|
62
70
|
relay_public_key: string;
|
|
71
|
+
/**
|
|
72
|
+
* Cryptosuite discriminator for `batch_signature`. Always
|
|
73
|
+
* `"motebit-jcs-ed25519-hex-v1"` — JCS canonicalization of the batch
|
|
74
|
+
* payload, Ed25519 primitive, hex signature encoding, hex public-key
|
|
75
|
+
* encoding. Verifiers reject missing or unknown suite values fail-closed.
|
|
76
|
+
*/
|
|
77
|
+
suite: "motebit-jcs-ed25519-hex-v1";
|
|
63
78
|
/** Hex-encoded Ed25519 signature over the canonical batch payload. */
|
|
64
79
|
batch_signature: string;
|
|
65
80
|
/** Onchain anchor metadata, or null if not yet submitted. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-anchor.d.ts","sourceRoot":"","sources":["../src/credential-anchor.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"credential-anchor.d.ts","sourceRoot":"","sources":["../src/credential-anchor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,8DAA8D;AAC9D,MAAM,WAAW,qBAAqB;IACpC,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,eAAe,EAAE,MAAM,CAAC;IACxB,mEAAmE;IACnE,cAAc,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,KAAK,EAAE,4BAA4B,CAAC;IACpC,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACtC;AAED,iDAAiD;AACjD,MAAM,WAAW,qBAAqB;IACpC,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,mFAAmF;IACnF,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB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
1
|
/**
|
|
2
2
|
* Credential anchor types — motebit/credential-anchor@1.0.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* Any implementation can produce and verify anchor
|
|
4
|
+
* Permissive floor (Apache-2.0): these types define the interoperable format
|
|
5
|
+
* for credential anchoring. Any implementation can produce and verify anchor
|
|
6
|
+
* proofs using these types.
|
|
6
7
|
*/
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=credential-anchor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-anchor.js","sourceRoot":"","sources":["../src/credential-anchor.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"credential-anchor.js","sourceRoot":"","sources":["../src/credential-anchor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cryptosuite registry — the protocol's open set of verification recipes.
|
|
3
|
+
*
|
|
4
|
+
* A cryptosuite is the complete specification of how a signature is
|
|
5
|
+
* produced and verified for a class of artifacts: which algorithm,
|
|
6
|
+
* which canonicalization, which signature and key encodings. Matches
|
|
7
|
+
* the pattern of W3C VC 2.0 (`cryptosuite: "eddsa-jcs-2022"`) and
|
|
8
|
+
* COSE/JOSE algorithm registries — one ID per full recipe, not just
|
|
9
|
+
* "which primitive."
|
|
10
|
+
*
|
|
11
|
+
* Every signed wire-format artifact in motebit MUST carry a `suite`
|
|
12
|
+
* field (see each artifact's `#### Wire format (foundation law)`
|
|
13
|
+
* subsection in `spec/*.md`). Verifiers dispatch on the suite value.
|
|
14
|
+
* Missing or unknown suites are rejected fail-closed. See the
|
|
15
|
+
* `check-suite-declared` (spec-side) and `check-suite-dispatch`
|
|
16
|
+
* (code-side) drift gates.
|
|
17
|
+
*
|
|
18
|
+
* Post-quantum migration becomes a new registry entry + dispatch arm
|
|
19
|
+
* in `@motebit/crypto/suite-dispatch.ts`, not a wire-format change.
|
|
20
|
+
*
|
|
21
|
+
* Permissive floor (Apache-2.0), type-only, zero runtime deps.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* The closed set of suite identifiers motebit currently supports.
|
|
25
|
+
*
|
|
26
|
+
* Four Ed25519 suites cover the four canonicalization/encoding bundles
|
|
27
|
+
* already used in the codebase (exploration 2026-04-13 found these
|
|
28
|
+
* were genuinely distinct recipes, not one). The fifth entry is the
|
|
29
|
+
* W3C standard suite used by Verifiable Credentials.
|
|
30
|
+
*
|
|
31
|
+
* Adding a new suite is an intentional protocol-level change: new
|
|
32
|
+
* string literal here, new dispatch arm in `verifyBySuite`, new
|
|
33
|
+
* `SUITE_REGISTRY` entry, a changeset bump, and (typically) a new spec
|
|
34
|
+
* paragraph naming which artifacts adopt it.
|
|
35
|
+
*/
|
|
36
|
+
export type SuiteId = "motebit-jcs-ed25519-b64-v1" | "motebit-jcs-ed25519-hex-v1" | "motebit-jwt-ed25519-v1" | "motebit-concat-ed25519-hex-v1" | "eddsa-jcs-2022";
|
|
37
|
+
/**
|
|
38
|
+
* Lifecycle status for each registered suite. Prevents today's bundles
|
|
39
|
+
* from calcifying into accidental permanent doctrine when PQ suites
|
|
40
|
+
* land — a demotion path is declared up front.
|
|
41
|
+
*
|
|
42
|
+
* - `preferred`: signers SHOULD emit under this suite; verifiers accept.
|
|
43
|
+
* - `allowed`: verifiers accept; signers MAY emit but `preferred` is
|
|
44
|
+
* recommended. Used during transition windows.
|
|
45
|
+
* - `legacy`: verifiers accept; signers MUST NOT emit. Migration-only.
|
|
46
|
+
*/
|
|
47
|
+
export type SuiteStatus = "preferred" | "allowed" | "legacy";
|
|
48
|
+
/**
|
|
49
|
+
* The primitive signature algorithm family. Separate from the suite
|
|
50
|
+
* name because several bundles share Ed25519 today, and the PQ world
|
|
51
|
+
* will introduce algorithms (ML-DSA-44, ML-DSA-65, SLH-DSA-SHA2-128s)
|
|
52
|
+
* that will each appear in multiple encoding variants.
|
|
53
|
+
*/
|
|
54
|
+
export type SuiteAlgorithm = "Ed25519" | "ML-DSA-44" | "ML-DSA-65" | "SLH-DSA-SHA2-128s";
|
|
55
|
+
/** Canonicalization used to produce signed bytes. */
|
|
56
|
+
export type SuiteCanonicalization = "jcs" | "json-stringify" | "utf8-concat";
|
|
57
|
+
/** On-wire encoding of the signature string. */
|
|
58
|
+
export type SuiteSignatureEncoding = "base64url" | "hex" | "multibase-base58btc";
|
|
59
|
+
/** On-wire encoding of the public key reference carried alongside the signature. */
|
|
60
|
+
export type SuitePublicKeyEncoding = "hex" | "multibase-did-key";
|
|
61
|
+
/**
|
|
62
|
+
* The complete verification recipe for one suite. Metadata is readable
|
|
63
|
+
* by verifiers and by documentation / CLI tooling; the dispatcher in
|
|
64
|
+
* `@motebit/crypto/suite-dispatch.ts` is the authority on actual
|
|
65
|
+
* verification semantics.
|
|
66
|
+
*/
|
|
67
|
+
export interface SuiteEntry {
|
|
68
|
+
readonly id: SuiteId;
|
|
69
|
+
readonly algorithm: SuiteAlgorithm;
|
|
70
|
+
readonly canonicalization: SuiteCanonicalization;
|
|
71
|
+
readonly signatureEncoding: SuiteSignatureEncoding;
|
|
72
|
+
readonly publicKeyEncoding: SuitePublicKeyEncoding;
|
|
73
|
+
readonly status: SuiteStatus;
|
|
74
|
+
/**
|
|
75
|
+
* Short prose description — surfaces in tooling (e.g. CLI `motebit
|
|
76
|
+
* inspect`), spec cross-references, and error messages.
|
|
77
|
+
*/
|
|
78
|
+
readonly description: string;
|
|
79
|
+
}
|
|
80
|
+
export declare const SUITE_REGISTRY: Readonly<Record<SuiteId, SuiteEntry>>;
|
|
81
|
+
/**
|
|
82
|
+
* Type guard — narrows `unknown` or arbitrary strings to `SuiteId`.
|
|
83
|
+
* Verifiers MUST call this before dispatching; an unchecked cast is a
|
|
84
|
+
* fail-open path that the `check-suite-dispatch` gate will flag.
|
|
85
|
+
*/
|
|
86
|
+
export declare function isSuiteId(value: unknown): value is SuiteId;
|
|
87
|
+
/**
|
|
88
|
+
* Look up a suite entry. Returns `undefined` for unknown IDs so
|
|
89
|
+
* callers can decide rejection semantics at their boundary (verifiers
|
|
90
|
+
* reject fail-closed; tooling may display "unknown suite").
|
|
91
|
+
*/
|
|
92
|
+
export declare function getSuiteEntry(id: SuiteId): SuiteEntry;
|
|
93
|
+
export declare function getSuiteEntry(id: string): SuiteEntry | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Canonical list of all registered suite IDs, frozen. Consumers that
|
|
96
|
+
* need to iterate (tooling, docs, tests) should use this instead of
|
|
97
|
+
* `Object.keys(SUITE_REGISTRY)` so TypeScript sees the narrow union.
|
|
98
|
+
*/
|
|
99
|
+
export declare const ALL_SUITE_IDS: readonly SuiteId[];
|
|
100
|
+
//# sourceMappingURL=crypto-suite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto-suite.d.ts","sourceRoot":"","sources":["../src/crypto-suite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,OAAO,GACf,4BAA4B,GAC5B,4BAA4B,GAC5B,wBAAwB,GACxB,+BAA+B,GAC/B,gBAAgB,CAAC;AAErB;;;;;;;;;GASG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,mBAAmB,CAAC;AAEzF,qDAAqD;AACrD,MAAM,MAAM,qBAAqB,GAC7B,KAAK,GACL,gBAAgB,GAChB,aAAa,CAAC;AAElB,gDAAgD;AAChD,MAAM,MAAM,sBAAsB,GAC9B,WAAW,GACX,KAAK,GACL,qBAAqB,CAAC;AAE1B,oFAAoF;AACpF,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,mBAAmB,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAA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