@motebit/protocol 1.2.0 → 2.0.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.
Files changed (60) hide show
  1. package/README.md +4 -2
  2. package/dist/artifact-type.d.ts +144 -0
  3. package/dist/artifact-type.d.ts.map +1 -0
  4. package/dist/artifact-type.js +107 -0
  5. package/dist/artifact-type.js.map +1 -0
  6. package/dist/audience.d.ts +108 -0
  7. package/dist/audience.d.ts.map +1 -0
  8. package/dist/audience.js +104 -0
  9. package/dist/audience.js.map +1 -0
  10. package/dist/co-browse.d.ts +369 -0
  11. package/dist/co-browse.d.ts.map +1 -0
  12. package/dist/co-browse.js +64 -0
  13. package/dist/co-browse.js.map +1 -0
  14. package/dist/computer-use.d.ts +463 -3
  15. package/dist/computer-use.d.ts.map +1 -1
  16. package/dist/computer-use.js +40 -0
  17. package/dist/computer-use.js.map +1 -1
  18. package/dist/event-type.d.ts +62 -0
  19. package/dist/event-type.d.ts.map +1 -0
  20. package/dist/event-type.js +123 -0
  21. package/dist/event-type.js.map +1 -0
  22. package/dist/index.d.ts +257 -20
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +84 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/memory-events.d.ts +13 -0
  27. package/dist/memory-events.d.ts.map +1 -1
  28. package/dist/money.d.ts +33 -0
  29. package/dist/money.d.ts.map +1 -0
  30. package/dist/money.js +41 -0
  31. package/dist/money.js.map +1 -0
  32. package/dist/perception.d.ts +347 -0
  33. package/dist/perception.d.ts.map +1 -0
  34. package/dist/perception.js +9 -0
  35. package/dist/perception.js.map +1 -0
  36. package/dist/retention-policy.d.ts +8 -1
  37. package/dist/retention-policy.d.ts.map +1 -1
  38. package/dist/retention-policy.js +18 -0
  39. package/dist/retention-policy.js.map +1 -1
  40. package/dist/routing.d.ts +266 -0
  41. package/dist/routing.d.ts.map +1 -0
  42. package/dist/routing.js +88 -0
  43. package/dist/routing.js.map +1 -0
  44. package/dist/sensitivity.d.ts +123 -0
  45. package/dist/sensitivity.d.ts.map +1 -0
  46. package/dist/sensitivity.js +154 -0
  47. package/dist/sensitivity.js.map +1 -0
  48. package/dist/settlement-asset.d.ts +92 -0
  49. package/dist/settlement-asset.d.ts.map +1 -0
  50. package/dist/settlement-asset.js +82 -0
  51. package/dist/settlement-asset.js.map +1 -0
  52. package/dist/settlement-mode.d.ts +144 -13
  53. package/dist/settlement-mode.d.ts.map +1 -1
  54. package/dist/settlement-mode.js +45 -1
  55. package/dist/settlement-mode.js.map +1 -1
  56. package/dist/transparency.d.ts +116 -0
  57. package/dist/transparency.d.ts.map +1 -0
  58. package/dist/transparency.js +67 -0
  59. package/dist/transparency.js.map +1 -0
  60. package/package.json +1 -1
@@ -0,0 +1,123 @@
1
+ /**
2
+ * `EventType` canonical-registry tooling.
3
+ *
4
+ * The `EventType` enum (in `./index.ts`) is the closed vocabulary of
5
+ * event-log entry discriminators that flow through every motebit's
6
+ * append-only event substrate. Every `EventLogEntry` carries an
7
+ * `event_type` field; sync peers, federation participants, audit
8
+ * verifiers, and consolidation cycles dispatch on it. Cross-
9
+ * implementation drift would break interop — a motebit emitting an
10
+ * unknown event_type to a peer would surface as a silent
11
+ * type-narrowing failure on the receiving side.
12
+ *
13
+ * Promoted to a registered registry per
14
+ * `docs/doctrine/registry-pattern-canonical.md` on 2026-05-14 — the
15
+ * sixth instance after `SuiteId`, `TokenAudience`,
16
+ * `ContentArtifactType`, `TaskShape`, and `SensitivityLevel`. The
17
+ * arc validates the meta-gate's claim that adding a sixth registry
18
+ * is template growth, not new design.
19
+ *
20
+ * Same shape as `audience.ts`, `artifact-type.ts`, `routing.ts`'s
21
+ * `ALL_TASK_SHAPES`/`isTaskShape` pair, and `sensitivity.ts`'s
22
+ * `ALL_SENSITIVITY_LEVELS`/`isSensitivityLevel` pair.
23
+ *
24
+ * Pure deterministic data + type guard. Permissive-floor primitive
25
+ * per `packages/protocol/CLAUDE.md` rule 1 (closed-registry tooling
26
+ * is structural, not policy).
27
+ */
28
+ /**
29
+ * Canonical iteration order over `EventType`, frozen. The single
30
+ * source of truth for "every event type" — drift gates, exhaustive
31
+ * switches, sync filters, and the protocol's registry-coverage gate
32
+ * (`check-event-type-canonical`) all enumerate through this array.
33
+ *
34
+ * Ordered in declaration order from the enum in `index.ts`. The
35
+ * gate's sibling-alignment block verifies the array mirrors the
36
+ * enum exactly — a registry append in the enum without a
37
+ * corresponding array append fails CI.
38
+ *
39
+ * Same shape as `ALL_SUITE_IDS`, `ALL_TOKEN_AUDIENCES`,
40
+ * `ALL_CONTENT_ARTIFACT_TYPES`, `ALL_TASK_SHAPES`,
41
+ * `ALL_SENSITIVITY_LEVELS`. Adding an event type is intentional
42
+ * protocol-level work: new enum entry + new entry here + gate
43
+ * reference update + spec/event-log entry if wire-format-relevant.
44
+ *
45
+ * Values are the enum's string literals (not enum members) to avoid
46
+ * the init-order cycle the file's `import type` already documents.
47
+ */
48
+ export const ALL_EVENT_TYPES = Object.freeze([
49
+ "identity_created",
50
+ "state_updated",
51
+ "memory_formed",
52
+ "memory_decayed",
53
+ "memory_deleted",
54
+ "memory_accessed",
55
+ "provider_swapped",
56
+ "export_requested",
57
+ "delete_requested",
58
+ "sync_completed",
59
+ "audit_entry",
60
+ "tool_used",
61
+ "policy_violation",
62
+ "goal_created",
63
+ "goal_executed",
64
+ "goal_removed",
65
+ "approval_requested",
66
+ "approval_approved",
67
+ "approval_denied",
68
+ "approval_expired",
69
+ "goal_completed",
70
+ "goal_progress",
71
+ "memory_audit",
72
+ "memory_pinned",
73
+ "plan_created",
74
+ "plan_step_started",
75
+ "plan_step_completed",
76
+ "plan_step_failed",
77
+ "plan_completed",
78
+ "plan_step_delegated",
79
+ "credential_revoked",
80
+ "identity_revoked",
81
+ "plan_failed",
82
+ "housekeeping_run",
83
+ "reflection_completed",
84
+ "idle_tick_fired",
85
+ "memory_consolidated",
86
+ "memory_promoted",
87
+ "consolidation_cycle_run",
88
+ "consolidation_receipt_signed",
89
+ "consolidation_receipts_anchored",
90
+ "agent_task_completed",
91
+ "agent_task_failed",
92
+ "agent_task_denied",
93
+ "proposal_created",
94
+ "proposal_accepted",
95
+ "proposal_rejected",
96
+ "proposal_countered",
97
+ "collaborative_step_completed",
98
+ "chain_trust_computed",
99
+ "trust_level_changed",
100
+ "key_rotated",
101
+ "computer_session_opened",
102
+ "computer_session_closed",
103
+ "computer_session_summarized",
104
+ "co_browse_control_changed",
105
+ "user_input_forwarded",
106
+ "skill_loaded",
107
+ "sensitivity_gate_fired",
108
+ ]);
109
+ /**
110
+ * Type guard — narrows `unknown` to `EventType`. Drift-gate-driven
111
+ * literal scanners use this to validate values pulled from
112
+ * wire-format payloads; consumers that derive event types from
113
+ * external sources (sync intake, federation peer payloads) call
114
+ * this before dispatching so an unchecked cast is a fail-open path
115
+ * the type system can't catch.
116
+ *
117
+ * Same shape as `isSuiteId`, `isTokenAudience`,
118
+ * `isContentArtifactType`, `isTaskShape`, `isSensitivityLevel`.
119
+ */
120
+ export function isEventType(value) {
121
+ return typeof value === "string" && ALL_EVENT_TYPES.includes(value);
122
+ }
123
+ //# sourceMappingURL=event-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-type.js","sourceRoot":"","sources":["../src/event-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AASH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAyB,MAAM,CAAC,MAAM,CAAC;IACjE,kBAAkB;IAClB,eAAe;IACf,eAAe;IACf,gBAAgB;IAChB,gBAAgB;IAChB,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,gBAAgB;IAChB,aAAa;IACb,WAAW;IACX,kBAAkB;IAClB,cAAc;IACd,eAAe;IACf,cAAc;IACd,oBAAoB;IACpB,mBAAmB;IACnB,iBAAiB;IACjB,kBAAkB;IAClB,gBAAgB;IAChB,eAAe;IACf,cAAc;IACd,eAAe;IACf,cAAc;IACd,mBAAmB;IACnB,qBAAqB;IACrB,kBAAkB;IAClB,gBAAgB;IAChB,qBAAqB;IACrB,oBAAoB;IACpB,kBAAkB;IAClB,aAAa;IACb,kBAAkB;IAClB,sBAAsB;IACtB,iBAAiB;IACjB,qBAAqB;IACrB,iBAAiB;IACjB,yBAAyB;IACzB,8BAA8B;IAC9B,iCAAiC;IACjC,sBAAsB;IACtB,mBAAmB;IACnB,mBAAmB;IACnB,kBAAkB;IAClB,mBAAmB;IACnB,mBAAmB;IACnB,oBAAoB;IACpB,8BAA8B;IAC9B,sBAAsB;IACtB,qBAAqB;IACrB,aAAa;IACb,yBAAyB;IACzB,yBAAyB;IACzB,6BAA6B;IAC7B,2BAA2B;IAC3B,sBAAsB;IACtB,cAAc;IACd,wBAAwB;CACV,CAAC,CAAC;AAElB;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,eAAqC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7F,CAAC"}
package/dist/index.d.ts CHANGED
@@ -248,7 +248,11 @@ export declare enum EventType {
248
248
  KeyRotated = "key_rotated",
249
249
  ComputerSessionOpened = "computer_session_opened",
250
250
  ComputerSessionClosed = "computer_session_closed",
251
- SkillLoaded = "skill_loaded"
251
+ ComputerSessionSummarized = "computer_session_summarized",
252
+ CoBrowseControlChanged = "co_browse_control_changed",
253
+ UserInputForwarded = "user_input_forwarded",
254
+ SkillLoaded = "skill_loaded",
255
+ SensitivityGateFired = "sensitivity_gate_fired"
252
256
  }
253
257
  export declare enum MemoryType {
254
258
  Episodic = "episodic",
@@ -419,11 +423,82 @@ export interface ToolDefinition {
419
423
  * `check-sensitivity-routing` for the outbound enforcement gate.
420
424
  */
421
425
  outbound?: boolean;
426
+ /**
427
+ * Embodiment mode the slab item should stamp when this tool's
428
+ * activity lands on the slab. One of: `"mind"` | `"tool_result"` |
429
+ * `"virtual_browser"` | `"shared_gaze"` | `"desktop_drive"` |
430
+ * `"peer_viewport"`. The string union is canonically declared as
431
+ * `EmbodimentMode` in `@motebit/render-engine` (typed as `string`
432
+ * here to avoid the protocol→render-engine layer break — promoting
433
+ * the type into `@motebit/protocol` is a separate slice the doctrine
434
+ * names as deferred).
435
+ *
436
+ * Why this lives on the tool definition (not on each chunk): the
437
+ * embodiment is determined at registration time by the surface
438
+ * wiring the dispatcher. The `computer` tool's wire format is
439
+ * surface-agnostic but its embodiment is dispatcher-specific:
440
+ * `apps/web/src/computer-tool.ts` registers it with
441
+ * `embodimentMode: "virtual_browser"` (cloud Chromium); the desktop
442
+ * surface registers the same name with `embodimentMode:
443
+ * "desktop_drive"` (real OS). The runtime's slab-projection picks
444
+ * `chunk.mode` (sourced from this field) over `tool-policy.ts`'s
445
+ * generic floor — so the same tool name produces the right
446
+ * embodiment per surface without forcing surface-aware code into
447
+ * the central registry. Doctrine: motebit-computer.md §"v1
448
+ * implementation status — Deferred to v1.5+: per-dispatcher mode
449
+ * stamping" — landed as v1.1 of the virtual_browser arc.
450
+ */
451
+ embodimentMode?: string;
452
+ /**
453
+ * Slab-projection policy for this tool. Closed string-literal union:
454
+ *
455
+ * - `"tool_call"` (default when omitted) — open a generic
456
+ * `tool_call` slab item on each invocation. The familiar
457
+ * "REQUEST_X / calling…" card. Right for tools that produce
458
+ * body acts (web_search, read_file, computer).
459
+ * - `"none"` — do NOT open a slab item. The tool is **state
460
+ * chrome**, not a body act, and its visible representation is
461
+ * a different surface (e.g. `request_control`'s visible
462
+ * surface is the slab control band, not a tool_call card).
463
+ * Without this, state-chrome tools would render duplicate UI:
464
+ * the affordance card AND the chrome both visible, competing
465
+ * for attention and obscuring the band's Grant/Deny buttons.
466
+ *
467
+ * Doctrine: motebit-computer.md — slab content is body acts
468
+ * (browser, peer viewport, memory artifact, tool result, desktop
469
+ * surface). Slab CHROME is state-aware overlays (control band,
470
+ * address bar, halt indicator). State-chrome tools belong in the
471
+ * latter; the slab item projection is for the former.
472
+ *
473
+ * Plumbing: read on the tool_status chunk by ai-core's loop.ts
474
+ * and consumed by the runtime's slab-projection at open time.
475
+ * The closed-string-literal union keeps additions backward
476
+ * compatible (a future `"observation"` variant could narrow
477
+ * further without breaking existing consumers).
478
+ */
479
+ slabProjection?: "none" | "tool_call";
422
480
  }
423
481
  export interface ToolResult {
424
482
  ok: boolean;
425
483
  data?: unknown;
426
484
  error?: string;
485
+ /**
486
+ * Optional structured failure category, set by handlers that wrap
487
+ * a typed error carrying its own `reason` field (e.g.
488
+ * `ComputerDispatcherError`). Lets downstream consumers route on
489
+ * category without parsing the human-readable `error` text.
490
+ *
491
+ * v1 carriers:
492
+ * - `not_in_control` — Slice 1 co-browse gate denial. The
493
+ * runtime's slab projection uses this to suppress a body
494
+ * `tool_call` item: control-state denials' canonical surface
495
+ * is the slab control band (Slice 2b doorbell), not the body.
496
+ *
497
+ * Open string-literal — additive. New reason categories land
498
+ * without breaking existing callers (consumers either route on
499
+ * the value they care about or ignore the field).
500
+ */
501
+ reason?: string;
427
502
  /** Set by adapters that already applied boundary wrapping (e.g. MCP client). */
428
503
  _sanitized?: boolean;
429
504
  }
@@ -1164,7 +1239,13 @@ export interface ExecutionStepSummary {
1164
1239
  };
1165
1240
  }
1166
1241
  export interface GoalExecutionManifest {
1167
- spec: "motebit/execution-ledger@1.0";
1242
+ /**
1243
+ * `motebit/execution-ledger@1.0` for legacy ledgers, `motebit/execution-ledger@1.1`
1244
+ * for ledgers that embed byte-identical inner signed receipts via `signed_receipts`.
1245
+ * v1.1 is purely additive — every v1.0 consumer continues to parse v1.1 bodies
1246
+ * by ignoring the optional field. See `spec/execution-ledger-v1.md` §4.3.
1247
+ */
1248
+ spec: "motebit/execution-ledger@1.0" | "motebit/execution-ledger@1.1";
1168
1249
  motebit_id: string;
1169
1250
  goal_id: string;
1170
1251
  plan_id: string;
@@ -1174,6 +1255,19 @@ export interface GoalExecutionManifest {
1174
1255
  timeline: ExecutionTimelineEntry[];
1175
1256
  steps: ExecutionStepSummary[];
1176
1257
  delegation_receipts: DelegationReceiptSummary[];
1258
+ /**
1259
+ * Byte-identical canonical-JSON of each delegated motebit's signed
1260
+ * `ExecutionReceipt`. Optional and only present in v1.1 reconstructions
1261
+ * where the relay has the receipts archived (per
1262
+ * `services/relay/CLAUDE.md` Rule 11). Each element is the JSON-stringified
1263
+ * receipt the motebit signed; verifiers MAY parse + recursively verify
1264
+ * each one's Ed25519 signature independently. Closes the operator-trust
1265
+ * gap that v1.0 summaries leave open — a relay that lies about which
1266
+ * motebit did the work is detectable because the inner signature can be
1267
+ * checked against the named motebit's public key without trusting the
1268
+ * relay. See `spec/execution-ledger-v1.md` §4.3.
1269
+ */
1270
+ signed_receipts?: string[];
1177
1271
  content_hash: string;
1178
1272
  signature?: string;
1179
1273
  }
@@ -1186,6 +1280,14 @@ export interface DelegationReceiptSummary {
1186
1280
  tools_used: string[];
1187
1281
  signature_prefix: string;
1188
1282
  }
1283
+ /**
1284
+ * Canonical spec identifiers for the execution-ledger reconstruction.
1285
+ * v1.1 adds the optional `signed_receipts` field; the wire shape is
1286
+ * otherwise identical to v1.0. Verifiers that recognize v1.1 SHOULD
1287
+ * iterate `signed_receipts` and verify each inner signature when present.
1288
+ */
1289
+ export declare const EXECUTION_LEDGER_SPEC_V1_0: "motebit/execution-ledger@1.0";
1290
+ export declare const EXECUTION_LEDGER_SPEC_V1_1: "motebit/execution-ledger@1.1";
1189
1291
  export interface AgentCapabilities {
1190
1292
  motebit_id: MotebitId;
1191
1293
  public_key: string;
@@ -1287,6 +1389,22 @@ export interface SettlementRecord {
1287
1389
  platform_fee: number;
1288
1390
  /** Fee rate applied (e.g. 0.05 = 5%). Recorded per-settlement for auditability. */
1289
1391
  platform_fee_rate: number;
1392
+ /**
1393
+ * How the money moved for this settlement: `relay` (relay holds custody;
1394
+ * virtual-account credit/debit on the relay's books) or `p2p` (peer-to-
1395
+ * peer onchain transfer; relay records the audit but never held the
1396
+ * funds). Closed registry — see `SettlementMode` in `./settlement-mode.ts`.
1397
+ *
1398
+ * Carried in the signed body so the lane is part of the relay's
1399
+ * attestation, not a derivable side-fact. Auditors and counsel reading
1400
+ * the receipt see the custody posture directly; the relay cannot
1401
+ * silently re-label a custodied settlement as p2p after the fact.
1402
+ *
1403
+ * Treasury reconciliation (operator fee accrual vs. onchain balance)
1404
+ * is structurally NOT a settlement and never appears here — see
1405
+ * `docs/doctrine/settlement-rails.md` § "Lanes for external readers".
1406
+ */
1407
+ settlement_mode: SettlementMode;
1290
1408
  /** x402 payment transaction hash (when paid on-chain). */
1291
1409
  x402_tx_hash?: string;
1292
1410
  /** x402 network used for payment (CAIP-2 identifier). */
@@ -1391,6 +1509,26 @@ export interface GuestRail extends SettlementRail {
1391
1509
  readonly railType: "fiat" | "protocol" | "orchestration";
1392
1510
  /** Whether this rail supports proactive deposits. False for pay-per-request rails (x402, MPP). */
1393
1511
  readonly supportsDeposit: boolean;
1512
+ /**
1513
+ * Whether this rail supports user-facing withdrawal — i.e., the relay
1514
+ * may invoke `rail.withdraw(...)` to transmit user funds to an
1515
+ * external destination on the user's behalf. When `false`, the rail
1516
+ * is registered for other purposes (treasury orchestration, deposit
1517
+ * intake, anchor submission) but NEVER appears in the user-withdrawal
1518
+ * dispatch path.
1519
+ *
1520
+ * `BridgeSettlementRail.supportsWithdraw = false` is the structural
1521
+ * embodiment of the off-ramp doctrine: Motebit is not a transmitter
1522
+ * of user funds. Bridge stays registered for own-account treasury
1523
+ * conversion via `BridgeOfframpAdapter`, but the rail itself cannot
1524
+ * be a withdrawal target — `withdraw()` is structurally absent from
1525
+ * the type (it lives on `WithdrawableGuestRail`, not on the base).
1526
+ *
1527
+ * Mirrors `supportsDeposit` + `DepositableGuestRail` and `supportsBatch`
1528
+ * + `BatchableGuestRail` as a discriminant narrowing to
1529
+ * `WithdrawableGuestRail`.
1530
+ */
1531
+ readonly supportsWithdraw: boolean;
1394
1532
  /**
1395
1533
  * Whether the rail exposes a single-call batch withdrawal primitive.
1396
1534
  * When true, `withdrawBatch` MUST be implemented. When false (the
@@ -1399,21 +1537,11 @@ export interface GuestRail extends SettlementRail {
1399
1537
  * defers sub-threshold items and fires serially once the policy
1400
1538
  * clears — but the rail itself settles one item per call.
1401
1539
  * Mirrors `supportsDeposit` + `DepositableGuestRail` as a
1402
- * discriminant narrowing to `BatchableGuestRail`.
1540
+ * discriminant narrowing to `BatchableGuestRail`. Implies
1541
+ * `supportsWithdraw: true` — batch is a specialization of single
1542
+ * withdraw.
1403
1543
  */
1404
1544
  readonly supportsBatch: boolean;
1405
- /**
1406
- * Execute a withdrawal to an external destination.
1407
- * Fail-closed: throws on any error.
1408
- */
1409
- withdraw(motebitId: string, amount: number, currency: string, destination: string, idempotencyKey: string): Promise<WithdrawalResult>;
1410
- /**
1411
- * Submit multiple withdrawals in one rail call when the rail
1412
- * supports a native batch primitive (e.g., a future x402 multi-
1413
- * authorization, a Bridge bulk-transfer). Present only when
1414
- * `supportsBatch` is true — narrow with `isBatchableRail`.
1415
- */
1416
- withdrawBatch?(items: readonly BatchWithdrawalItem[]): Promise<BatchWithdrawalResult>;
1417
1545
  /**
1418
1546
  * Record a payment proof with a settlement (e.g., x402 tx hash, Stripe charge ID).
1419
1547
  * Called after settleOnReceipt() computes the settlement record.
@@ -1448,11 +1576,46 @@ export interface BatchWithdrawalResult {
1448
1576
  reason: string;
1449
1577
  }>;
1450
1578
  }
1579
+ /**
1580
+ * A guest rail that supports user-facing withdrawal — the relay may
1581
+ * invoke `withdraw()` to transmit user funds to an external destination.
1582
+ *
1583
+ * Use the `supportsWithdraw` discriminant for runtime narrowing from
1584
+ * `GuestRail`. The marker exists so `BridgeSettlementRail` (orchestration,
1585
+ * treasury-only) is structurally distinct from `StripeSettlementRail`
1586
+ * (fiat, user-facing) and `X402SettlementRail` (protocol, user-facing).
1587
+ *
1588
+ * The doctrinal frame: Motebit is not a transmitter of user funds. User-
1589
+ * facing withdrawal is permitted only to user-held wallets (the sovereign
1590
+ * Solana path via `OperatorSolanaTransfer` on the operator side, or to
1591
+ * a user-held EVM wallet via x402 on a `WithdrawableGuestRail`). Bridge
1592
+ * is excluded structurally — the method does not exist on its type, so
1593
+ * the relay cannot orchestrate user-facing transfers through Bridge no
1594
+ * matter what env vars are set. The doctrine is enforced by absence.
1595
+ */
1596
+ export interface WithdrawableGuestRail extends GuestRail {
1597
+ readonly supportsWithdraw: true;
1598
+ /**
1599
+ * Execute a withdrawal to an external destination.
1600
+ * Fail-closed: throws on any error.
1601
+ */
1602
+ withdraw(motebitId: string, amount: number, currency: string, destination: string, idempotencyKey: string): Promise<WithdrawalResult>;
1603
+ /**
1604
+ * Submit multiple withdrawals in one rail call when the rail
1605
+ * supports a native batch primitive (e.g., a future x402 multi-
1606
+ * authorization). Present only when `supportsBatch` is true — narrow
1607
+ * with `isBatchableRail`. A rail can be withdrawable without being
1608
+ * batchable, but the reverse is forbidden by the type hierarchy:
1609
+ * `BatchableGuestRail extends WithdrawableGuestRail`.
1610
+ */
1611
+ withdrawBatch?(items: readonly BatchWithdrawalItem[]): Promise<BatchWithdrawalResult>;
1612
+ }
1451
1613
  /**
1452
1614
  * A guest rail that supports batch withdrawal submission.
1453
1615
  * Use the `supportsBatch` discriminant for runtime narrowing from `GuestRail`.
1616
+ * Batchable implies withdrawable — batch is a specialization of single withdraw.
1454
1617
  */
1455
- export interface BatchableGuestRail extends GuestRail {
1618
+ export interface BatchableGuestRail extends WithdrawableGuestRail {
1456
1619
  readonly supportsBatch: true;
1457
1620
  withdrawBatch(items: readonly BatchWithdrawalItem[]): Promise<BatchWithdrawalResult>;
1458
1621
  }
@@ -1472,6 +1635,19 @@ export interface DepositableGuestRail extends GuestRail {
1472
1635
  }
1473
1636
  /** Type guard: narrows GuestRail to DepositableGuestRail. */
1474
1637
  export declare function isDepositableRail(rail: GuestRail): rail is DepositableGuestRail;
1638
+ /**
1639
+ * Type guard: narrows GuestRail to WithdrawableGuestRail.
1640
+ *
1641
+ * The relay's user-withdrawal dispatch (services/relay/src/budget.ts)
1642
+ * MUST narrow through this guard before calling `rail.withdraw(...)`.
1643
+ * Compile-time enforcement: `withdraw` does not exist on bare `GuestRail`,
1644
+ * so an un-narrowed call site fails to typecheck. Runtime defense-in-
1645
+ * depth: a rail with `supportsWithdraw: true` AND a non-function
1646
+ * `withdraw` property would shape-match the interface but fail this
1647
+ * guard, surfacing as "this rail does not support withdrawal" rather
1648
+ * than a `TypeError: rail.withdraw is not a function` at the dispatch.
1649
+ */
1650
+ export declare function isWithdrawableRail(rail: GuestRail): rail is WithdrawableGuestRail;
1475
1651
  /** Type guard: narrows GuestRail to BatchableGuestRail. */
1476
1652
  export declare function isBatchableRail(rail: GuestRail): rail is BatchableGuestRail;
1477
1653
  /**
@@ -1496,8 +1672,13 @@ export interface SovereignRail extends SettlementRail {
1496
1672
  readonly custody: "agent";
1497
1673
  /** Chain identifier (e.g., "solana"). Future: "aptos", "sui". */
1498
1674
  readonly chain: string;
1499
- /** Asset symbol (e.g., "USDC"). */
1500
- readonly asset: string;
1675
+ /**
1676
+ * Settlement asset this rail clears in. Closed union — see
1677
+ * `SettlementAsset` in `./settlement-asset.ts`. Sub-phase A: USDC
1678
+ * only at land; second-asset promotion lifts the registry to the
1679
+ * 8th registered registry per `registry-pattern-canonical.md`.
1680
+ */
1681
+ readonly asset: SettlementAsset;
1501
1682
  /** Agent's own address on this chain. Equals the motebit identity public key for Ed25519-native chains. */
1502
1683
  readonly address: string;
1503
1684
  /** Current balance in micro-units (1e6 = 1 unit of asset). */
@@ -1851,6 +2032,41 @@ export interface AuditStatsSince {
1851
2032
  blocked: number;
1852
2033
  failed: number;
1853
2034
  }
2035
+ /**
2036
+ * audit-chain — single entry in the hash-linked tamper-evident
2037
+ * audit trail. Each entry's `hash` is `SHA-256(canonical({
2038
+ * previous_hash, entry_id, timestamp, event_type, actor_id, data
2039
+ * }))`; `previous_hash` references the prior entry's `hash` (or
2040
+ * `"genesis"` for the first entry). The runtime computes hashes on
2041
+ * append; verifiers recompute and compare.
2042
+ *
2043
+ * Lives in protocol (permissive-floor wire-format type) so
2044
+ * `StorageAdapters.auditChainStore` can reference it without sdk
2045
+ * importing the BSL `@motebit/policy` package. The concrete
2046
+ * primitives (`appendAuditEntry`, `verifyAuditChain`, the
2047
+ * `crypto.subtle` hashing) live in `@motebit/policy`'s
2048
+ * `audit-chain.ts` — that's where the algorithm runs.
2049
+ */
2050
+ export interface AuditChainEntry {
2051
+ readonly entry_id: string;
2052
+ readonly timestamp: number;
2053
+ readonly event_type: string;
2054
+ readonly actor_id: string;
2055
+ readonly data: Record<string, unknown>;
2056
+ readonly previous_hash: string;
2057
+ readonly hash: string;
2058
+ }
2059
+ /**
2060
+ * audit-chain — minimal storage interface adapters implement.
2061
+ * Append-only — the chain breaks if entries are deleted or
2062
+ * reordered, which is the whole tamper-evidence point.
2063
+ */
2064
+ export interface AuditChainStoreAdapter {
2065
+ append(entry: AuditChainEntry): Promise<void>;
2066
+ getEntries(from?: number, to?: number): Promise<AuditChainEntry[]>;
2067
+ getHead(): Promise<AuditChainEntry | undefined>;
2068
+ count(): Promise<number>;
2069
+ }
1854
2070
  export interface AuditLogSink {
1855
2071
  append(entry: ToolAuditEntry): void;
1856
2072
  query(turnId: string): ToolAuditEntry[];
@@ -1926,7 +2142,10 @@ export type { AgentSettlementAnchorBatch, AgentSettlementChainAnchor, AgentSettl
1926
2142
  export type { RelayMetadata, RelayMetadataPeer, AgentResolutionResult } from "./discovery.js";
1927
2143
  export type { MigrationState, MigrationRequest, MigrationToken, DepartureAttestation, CredentialBundle, BalanceWaiver, MigrationPresentation, } from "./migration.js";
1928
2144
  export type { DisputeState, DisputeOutcome, DisputeCategory, DisputeFundAction, DisputeRequest, DisputeEvidence, DisputeEvidenceType, AdjudicatorVote, VoteRequest, DisputeResolution, DisputeAppeal, WitnessOmissionDispute, WitnessOmissionEvidence, WitnessOmissionInclusionProofEvidence, WitnessOmissionAlternativePeeringEvidence, } from "./dispute.js";
1929
- export type { SettlementMode, P2pPaymentProof, PaymentVerificationStatus, SettlementEligibility, SolvencyProof, } from "./settlement-mode.js";
2145
+ export type { SettlementMode, WritableSettlementMode, P2pPaymentProof, PaymentVerificationStatus, SettlementEligibility, SolvencyProof, } from "./settlement-mode.js";
2146
+ export { ALL_SETTLEMENT_MODES, isSettlementMode } from "./settlement-mode.js";
2147
+ export type { SettlementAsset } from "./settlement-asset.js";
2148
+ export { ALL_SETTLEMENT_ASSETS, isSettlementAsset } from "./settlement-asset.js";
1930
2149
  export type { SuiteId, SuiteEntry, SuiteStatus, SuiteAlgorithm, SuiteCanonicalization, SuiteSignatureEncoding, SuitePublicKeyEncoding, } from "./crypto-suite.js";
1931
2150
  export { SUITE_REGISTRY, ALL_SUITE_IDS, isSuiteId, getSuiteEntry } from "./crypto-suite.js";
1932
2151
  export { MAX_RETENTION_DAYS_BY_SENSITIVITY, REFERENCE_RETENTION_DAYS_BY_SENSITIVITY, RUNTIME_RETENTION_REGISTRY, EMPTY_FEDERATION_GRAPH_ANCHOR, } from "./retention-policy.js";
@@ -1934,11 +2153,29 @@ export type { RetentionCeilingDays, RetentionShape, RetentionShapeDeclaration, R
1934
2153
  export type { MemoryDecayedPayload, MemoryFormedPayload, MemoryAccessedPayload, MemoryPinnedPayload, MemoryDeletedPayload, MemoryConsolidatedPayload, MemoryAuditPayload, MemoryPromotedPayload, } from "./memory-events.js";
1935
2154
  export type { GoalCreatedPayload, GoalExecutedPayload, GoalProgressPayload, GoalCompletedPayload, GoalRemovedPayload, } from "./goal-lifecycle.js";
1936
2155
  export type { PlanCreatedPayload, PlanStepStartedPayload, PlanStepCompletedPayload, PlanStepFailedPayload, PlanStepDelegatedPayload, PlanCompletedPayload, PlanFailedPayload, } from "./plan-lifecycle.js";
1937
- export type { ComputerPoint, ComputerTargetHint, ScreenshotAction, CursorPositionAction, ClickAction, DoubleClickAction, MouseMoveAction, DragAction, TypeAction, KeyAction, ScrollAction, ComputerAction, ComputerActionKind, ComputerActionRequest, ComputerObservationResult, ComputerRedaction, ScreenshotObservation, CursorPositionObservation, ComputerSessionOpened, ComputerSessionClosed, ComputerFailureReason, } from "./computer-use.js";
2156
+ export type { ComputerPoint, ComputerTargetHint, ScreenshotAction, CursorPositionAction, ClickAction, DoubleClickAction, MouseMoveAction, DragAction, TypeAction, KeyAction, ScrollAction, NavigateAction, ClickElementAction, FocusElementAction, TypeIntoAction, ComputerAction, ComputerActionKind, ComputerActionRequest, ComputerObservationResult, ComputerRedaction, ScreenshotObservation, CursorPositionObservation, ReadPageResult, ReadPageHeading, ReadPageLink, ReadPageInput, ReadPageButton, ComputerSessionOpened, ComputerSessionClosed, ComputerFailureReason, ComputerSessionActionRecord, SignableComputerSessionReceipt, ComputerSessionReceipt, ScreencastFrame, ScreencastFrameSource, } from "./computer-use.js";
1938
2157
  export { COMPUTER_ACTION_KINDS, COMPUTER_FAILURE_REASONS } from "./computer-use.js";
2158
+ export type { ControlHolder, ControlState, CoBrowseTransitionKind, CoBrowseControlChangedPayload, KeyModifiers, UserInputEvent, UserInputForwardOutcome, UserInputRejectionReason, CharacterClass, KeyRole, UserInputForwardedDetail, UserInputForwardedPayload, } from "./co-browse.js";
2159
+ export { CO_BROWSE_TRANSITION_KINDS } from "./co-browse.js";
1939
2160
  export type { ToolMode } from "./tool-mode.js";
1940
2161
  export { TOOL_MODES, toolModePriority } from "./tool-mode.js";
2162
+ export type { DropPayloadKind, DropTarget, DropPayload, UserActionAttestation, SensitivityGateEntry, SensitivityElevationSource, SensitivityGateFiredPayload, } from "./perception.js";
2163
+ export { resolveDropTarget } from "./perception.js";
2164
+ export { rankSensitivity, maxSensitivity, sensitivityPermits, ALL_SENSITIVITY_LEVELS, isSensitivityLevel, } from "./sensitivity.js";
2165
+ export type { SensitivityCleared } from "./sensitivity.js";
2166
+ export { ALL_EVENT_TYPES, isEventType } from "./event-type.js";
2167
+ export { MICRO, CENTS, toMicro, fromMicro, toCents, fromCents } from "./money.js";
2168
+ export type { InferenceHost, ModelLab, Jurisdiction, TaskShape, ProviderCapability, RoutingConstraint, RoutingDecision, } from "./routing.js";
2169
+ export { ALL_TASK_SHAPES, isTaskShape, QUICK_TASK_SHAPE, CHAT_TASK_SHAPE, REASONING_TASK_SHAPE, CODE_TASK_SHAPE, RESEARCH_TASK_SHAPE, CREATIVE_TASK_SHAPE, MATH_TASK_SHAPE, } from "./routing.js";
2170
+ export type { TokenAudience } from "./audience.js";
2171
+ export { ALL_TOKEN_AUDIENCES, isTokenAudience, SYNC_AUDIENCE, DEVICE_AUTH_AUDIENCE, PAIR_AUDIENCE, ROTATE_KEY_AUDIENCE, PUSH_REGISTER_AUDIENCE, TASK_SUBMIT_AUDIENCE, ADMIN_QUERY_AUDIENCE, PROPOSAL_AUDIENCE, ACCOUNT_BALANCE_AUDIENCE, ACCOUNT_DEPOSIT_AUDIENCE, ACCOUNT_WITHDRAW_AUDIENCE, ACCOUNT_WITHDRAWALS_AUDIENCE, ACCOUNT_CHECKOUT_AUDIENCE, BROWSER_SANDBOX_GRANT_AUDIENCE, BROWSER_SANDBOX_AUDIENCE, } from "./audience.js";
2172
+ export type { ContentArtifactType } from "./artifact-type.js";
2173
+ export { ALL_CONTENT_ARTIFACT_TYPES, isContentArtifactType, STATE_SNAPSHOT_ARTIFACT, MEMORY_EXPORT_ARTIFACT, GOAL_LIST_ARTIFACT, CONVERSATION_LIST_ARTIFACT, CONVERSATION_MESSAGES_ARTIFACT, DEVICE_LIST_ARTIFACT, AUDIT_TRAIL_ARTIFACT, PLAN_LIST_ARTIFACT, PLAN_DETAIL_ARTIFACT, GRADIENT_HISTORY_ARTIFACT, SYNC_PULL_ARTIFACT, EXECUTION_LEDGER_ARTIFACT, GOAL_RESULT_ARTIFACT, } from "./artifact-type.js";
2174
+ export type { SignedTransparencyDeclaration, TransparencySignedPayload, TransparencyAnchorRecord, } from "./transparency.js";
2175
+ export { TRANSPARENCY_SUITE, TRANSPARENCY_ANCHOR_MEMO_PREFIX, TRANSPARENCY_SPEC_ID, isSignedTransparencyDeclaration, } from "./transparency.js";
1941
2176
  import type { ToolMode } from "./tool-mode.js";
2177
+ import type { SettlementMode } from "./settlement-mode.js";
2178
+ import type { SettlementAsset } from "./settlement-asset.js";
1942
2179
  export type { SkillSensitivity, SkillPlatform, SkillHardwareAttestationGate, SkillSignature, SkillManifestMetadata, SkillManifestMotebit, SkillManifest, SkillEnvelopeFile, SkillEnvelopeSkillRef, SkillEnvelope, SkillLoadPayload, } from "./skills.js";
1943
2180
  export { SKILL_SENSITIVITY_TIERS, SKILL_AUTO_LOADABLE_TIERS, SKILL_PLATFORMS } from "./skills.js";
1944
2181
  export type { SkillRegistryEntry, SkillRegistrySubmitRequest, SkillRegistrySubmitResponse, SkillRegistryListing, SkillRegistryBundle, } from "./skills.js";