@motebit/protocol 0.7.0 → 1.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.
- 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 +101 -0
- package/dist/credential-anchor.d.ts.map +1 -0
- package/dist/credential-anchor.js +9 -0
- package/dist/credential-anchor.js.map +1 -0
- 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/graph.d.ts +50 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +95 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +790 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -0
- 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 +104 -0
- package/dist/semiring.d.ts.map +1 -0
- package/dist/semiring.js +187 -0
- package/dist/semiring.js.map +1 -0
- 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/traversal.d.ts +60 -0
- package/dist/traversal.d.ts.map +1 -0
- package/dist/traversal.js +183 -0
- package/dist/traversal.js.map +1 -0
- package/dist/trust-algebra.d.ts +34 -0
- package/dist/trust-algebra.d.ts.map +1 -0
- package/dist/trust-algebra.js +58 -0
- package/dist/trust-algebra.js.map +1 -0
- package/package.json +13 -9
package/dist/index.d.ts
CHANGED
|
@@ -106,6 +106,39 @@ export interface DelegationReceiptLike {
|
|
|
106
106
|
motebit_id: string;
|
|
107
107
|
delegation_receipts?: DelegationReceiptLike[];
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* A signed delegation token authorizing one agent to act on behalf of
|
|
111
|
+
* another within a declared scope. The delegator signs the token body
|
|
112
|
+
* (everything except `signature`) with their private key.
|
|
113
|
+
*
|
|
114
|
+
* Public keys are hex-encoded, matching every other motebit artifact
|
|
115
|
+
* that carries an Ed25519 key; the signature is base64url-encoded per
|
|
116
|
+
* the `motebit-jcs-ed25519-b64-v1` suite. `@motebit/crypto` re-exports
|
|
117
|
+
* this type alongside `signDelegation` / `verifyDelegation` helpers;
|
|
118
|
+
* the shape itself is the binding wire format.
|
|
119
|
+
*
|
|
120
|
+
* See `spec/market-v1.md §12.1` for the full spec.
|
|
121
|
+
*/
|
|
122
|
+
export interface DelegationToken {
|
|
123
|
+
delegator_id: string;
|
|
124
|
+
/** Delegator's Ed25519 public key, hex-encoded (64 characters, lowercase). */
|
|
125
|
+
delegator_public_key: string;
|
|
126
|
+
delegate_id: string;
|
|
127
|
+
/** Delegate's Ed25519 public key, hex-encoded (64 characters, lowercase). */
|
|
128
|
+
delegate_public_key: string;
|
|
129
|
+
/** Comma-separated capability list, or `"*"` for wildcard. See market-v1 §12.3. */
|
|
130
|
+
scope: string;
|
|
131
|
+
issued_at: number;
|
|
132
|
+
expires_at: number;
|
|
133
|
+
/**
|
|
134
|
+
* Cryptosuite discriminator. Always `"motebit-jcs-ed25519-b64-v1"` for
|
|
135
|
+
* this artifact today. Part of the signed body — tampering breaks
|
|
136
|
+
* verification. Verifiers reject missing or unknown values fail-closed.
|
|
137
|
+
*/
|
|
138
|
+
suite: "motebit-jcs-ed25519-b64-v1";
|
|
139
|
+
/** Base64url-encoded Ed25519 signature. */
|
|
140
|
+
signature: string;
|
|
141
|
+
}
|
|
109
142
|
export declare enum SensitivityLevel {
|
|
110
143
|
None = "none",
|
|
111
144
|
Personal = "personal",
|
|
@@ -149,7 +182,12 @@ export declare enum EventType {
|
|
|
149
182
|
PlanFailed = "plan_failed",
|
|
150
183
|
HousekeepingRun = "housekeeping_run",
|
|
151
184
|
ReflectionCompleted = "reflection_completed",
|
|
185
|
+
IdleTickFired = "idle_tick_fired",
|
|
152
186
|
MemoryConsolidated = "memory_consolidated",
|
|
187
|
+
MemoryPromoted = "memory_promoted",
|
|
188
|
+
ConsolidationCycleRun = "consolidation_cycle_run",
|
|
189
|
+
ConsolidationReceiptSigned = "consolidation_receipt_signed",
|
|
190
|
+
ConsolidationReceiptsAnchored = "consolidation_receipts_anchored",
|
|
153
191
|
AgentTaskCompleted = "agent_task_completed",
|
|
154
192
|
AgentTaskFailed = "agent_task_failed",
|
|
155
193
|
AgentTaskDenied = "agent_task_denied",
|
|
@@ -160,7 +198,9 @@ export declare enum EventType {
|
|
|
160
198
|
CollaborativeStepCompleted = "collaborative_step_completed",
|
|
161
199
|
ChainTrustComputed = "chain_trust_computed",
|
|
162
200
|
TrustLevelChanged = "trust_level_changed",
|
|
163
|
-
KeyRotated = "key_rotated"
|
|
201
|
+
KeyRotated = "key_rotated",
|
|
202
|
+
ComputerSessionOpened = "computer_session_opened",
|
|
203
|
+
ComputerSessionClosed = "computer_session_closed"
|
|
164
204
|
}
|
|
165
205
|
export declare enum MemoryType {
|
|
166
206
|
Episodic = "episodic",
|
|
@@ -293,6 +333,13 @@ export interface ToolDefinition {
|
|
|
293
333
|
dataClass?: DataClass;
|
|
294
334
|
sideEffect?: SideEffect;
|
|
295
335
|
};
|
|
336
|
+
/**
|
|
337
|
+
* Cost-tier declaration driving registry sort order. `api` (cheap,
|
|
338
|
+
* structured) ranks above `ax` (structured accessibility tree) above
|
|
339
|
+
* `pixels` (screen capture + synthetic input). Untagged tools sort
|
|
340
|
+
* last. See `@motebit/protocol/tool-mode`.
|
|
341
|
+
*/
|
|
342
|
+
mode?: ToolMode;
|
|
296
343
|
}
|
|
297
344
|
export interface ToolResult {
|
|
298
345
|
ok: boolean;
|
|
@@ -456,7 +503,29 @@ export declare enum DeviceCapability {
|
|
|
456
503
|
FileSystem = "file_system",
|
|
457
504
|
Keyring = "keyring",
|
|
458
505
|
Background = "background",
|
|
459
|
-
LocalLlm = "local_llm"
|
|
506
|
+
LocalLlm = "local_llm",
|
|
507
|
+
/** Device supports push-triggered wake for background task execution. */
|
|
508
|
+
PushWake = "push_wake",
|
|
509
|
+
/**
|
|
510
|
+
* Device holds its identity key inside hardware (Secure Enclave / TPM /
|
|
511
|
+
* hardware keystore) and can produce signatures the private material
|
|
512
|
+
* never leaves. Consumed by `HardwareAttestationSemiring` to rank
|
|
513
|
+
* hardware-attested agents above software-only agents when the routing
|
|
514
|
+
* caller asks for the attestation dimension. Pairs with the
|
|
515
|
+
* `hardware_attestation` subject-field extension on `AgentTrustCredential`
|
|
516
|
+
* (spec/credential-v1.md §3.4).
|
|
517
|
+
*/
|
|
518
|
+
SecureEnclave = "secure_enclave"
|
|
519
|
+
}
|
|
520
|
+
/** Push notification platform for wake-on-demand mobile execution. */
|
|
521
|
+
export type PushPlatform = "fcm" | "apns" | "expo";
|
|
522
|
+
/** Push token registration payload — sent from device to relay. */
|
|
523
|
+
export interface PushTokenRegistration {
|
|
524
|
+
device_id: string;
|
|
525
|
+
push_token: string;
|
|
526
|
+
platform: PushPlatform;
|
|
527
|
+
/** Unix ms timestamp when the token was obtained. Used for staleness detection. */
|
|
528
|
+
registered_at: number;
|
|
460
529
|
}
|
|
461
530
|
export declare enum AgentTaskStatus {
|
|
462
531
|
Pending = "pending",
|
|
@@ -480,6 +549,14 @@ export interface AgentTask {
|
|
|
480
549
|
step_id?: string;
|
|
481
550
|
/** Delegation scope — when set, restricts which tools the task can use. */
|
|
482
551
|
delegated_scope?: string;
|
|
552
|
+
/**
|
|
553
|
+
* How this task was authorized for invocation. Propagated from the task
|
|
554
|
+
* submission body through the agent envelope to the outer receipt. See
|
|
555
|
+
* `IntentOrigin` for the closed value set and
|
|
556
|
+
* `docs/doctrine/surface-determinism.md` for the surface-determinism
|
|
557
|
+
* doctrine this discriminator supports.
|
|
558
|
+
*/
|
|
559
|
+
invocation_origin?: IntentOrigin;
|
|
483
560
|
}
|
|
484
561
|
export interface ExecutionReceipt {
|
|
485
562
|
task_id: string;
|
|
@@ -506,6 +583,365 @@ export interface ExecutionReceipt {
|
|
|
506
583
|
relay_task_id?: string;
|
|
507
584
|
/** Scope from the delegation token that authorized this execution, if any. */
|
|
508
585
|
delegated_scope?: string;
|
|
586
|
+
/**
|
|
587
|
+
* How this task was authorized for invocation. Discriminates user-explicit
|
|
588
|
+
* affordances (chip tap, slash command, scene click) from AI-mediated
|
|
589
|
+
* delegations (the model called `delegate_to_agent` in its loop) and from
|
|
590
|
+
* machine-driven origins (cron, agent-to-agent). Optional and additive —
|
|
591
|
+
* absent ≡ unknown origin (legacy receipts predate the field; no
|
|
592
|
+
* back-fill). When present, the value is signature-bound: verifiers
|
|
593
|
+
* reject any tampered substitution.
|
|
594
|
+
*
|
|
595
|
+
* Carried through to the relay's task-submission body and emitted on
|
|
596
|
+
* the agent's outer receipt by `buildServiceReceipt`. Surface determinism
|
|
597
|
+
* (CLAUDE.md principle): user-tap delegations MUST set `"user-tap"`.
|
|
598
|
+
*/
|
|
599
|
+
invocation_origin?: IntentOrigin;
|
|
600
|
+
/**
|
|
601
|
+
* Cryptosuite discriminator. Always `"motebit-jcs-ed25519-b64-v1"` for
|
|
602
|
+
* this artifact today — the verification recipe is JCS canonicalization
|
|
603
|
+
* of the unsigned body (this object without `signature`), Ed25519
|
|
604
|
+
* primitive, base64url signature encoding, hex public-key encoding.
|
|
605
|
+
*
|
|
606
|
+
* Narrowed to the single suite today so widening requires intentional
|
|
607
|
+
* registry + type change (the plan for post-quantum migration). Verifiers
|
|
608
|
+
* reject missing or unknown suite values fail-closed.
|
|
609
|
+
*/
|
|
610
|
+
suite: "motebit-jcs-ed25519-b64-v1";
|
|
611
|
+
signature: string;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Signed per-tool-call proof: one receipt per invocation of a tool during
|
|
615
|
+
* an agent turn. Complements `ExecutionReceipt` (which commits to the
|
|
616
|
+
* task as a whole) by committing to each individual tool call inside
|
|
617
|
+
* the task — the finer-grained audit granularity the agent-workstation
|
|
618
|
+
* surface needs to show the user exactly which tool ran, what it was
|
|
619
|
+
* given, and what it returned, with a signature per call.
|
|
620
|
+
*
|
|
621
|
+
* Why this exists as its own artifact instead of an inner field on
|
|
622
|
+
* `ExecutionReceipt`:
|
|
623
|
+
*
|
|
624
|
+
* - Third-party implementers verifying a single tool's output do not
|
|
625
|
+
* need the enclosing task's receipt — the per-call receipt is
|
|
626
|
+
* independently self-verifiable with just the signer's public key.
|
|
627
|
+
* - The workstation surface emits these live as tool calls complete,
|
|
628
|
+
* before the enclosing task finishes; nesting inside `ExecutionReceipt`
|
|
629
|
+
* would force the UI to wait for the outer receipt.
|
|
630
|
+
* - Delegation is recursive at the task level (`delegation_receipts`);
|
|
631
|
+
* keeping tool-invocation receipts separate avoids tangling two
|
|
632
|
+
* different recursion shapes in one artifact.
|
|
633
|
+
*
|
|
634
|
+
* Commits only to structural facts: tool name, canonical SHA-256 hashes
|
|
635
|
+
* of the args and the result, the result status, the motebit + device
|
|
636
|
+
* identities, and timestamps. The receipt does *not* carry the raw args
|
|
637
|
+
* or raw result bytes — those may contain sensitive content. A verifier
|
|
638
|
+
* who holds the raw bytes can recompute the hash and check against the
|
|
639
|
+
* signature; one who holds only the receipt can still prove the tool
|
|
640
|
+
* ran with *some* input at *some* time.
|
|
641
|
+
*
|
|
642
|
+
* Binding to the enclosing task is via `task_id` — the same task_id
|
|
643
|
+
* carried on the parent `ExecutionReceipt`. A verifier can gather all
|
|
644
|
+
* tool-invocation receipts for a task by matching task_id and verify
|
|
645
|
+
* them in parallel.
|
|
646
|
+
*/
|
|
647
|
+
export interface ToolInvocationReceipt {
|
|
648
|
+
/** Stable identifier for this invocation — UUID assigned when the tool is dispatched. */
|
|
649
|
+
invocation_id: string;
|
|
650
|
+
/** Task this invocation belongs to. Matches `ExecutionReceipt.task_id` when nested in a task. */
|
|
651
|
+
task_id: string;
|
|
652
|
+
motebit_id: MotebitId;
|
|
653
|
+
/** Signer's Ed25519 public key (hex). Enables verification without relay lookup. */
|
|
654
|
+
public_key?: string;
|
|
655
|
+
device_id: DeviceId;
|
|
656
|
+
/** Tool name as registered in the runtime's tool registry (e.g., "read_url", "web_search"). */
|
|
657
|
+
tool_name: string;
|
|
658
|
+
/** Unix ms when the tool was dispatched. */
|
|
659
|
+
started_at: number;
|
|
660
|
+
/** Unix ms when the tool reached terminal state. Equal to `started_at` for instantaneous tools. */
|
|
661
|
+
completed_at: number;
|
|
662
|
+
/** Terminal state of the tool invocation. */
|
|
663
|
+
status: "completed" | "failed" | "denied";
|
|
664
|
+
/**
|
|
665
|
+
* SHA-256 hex digest of the canonical JSON of the tool's arguments.
|
|
666
|
+
* A verifier with the raw args recomputes and matches; absence of raw
|
|
667
|
+
* args does not weaken the receipt's self-verifiability.
|
|
668
|
+
*/
|
|
669
|
+
args_hash: string;
|
|
670
|
+
/**
|
|
671
|
+
* SHA-256 hex digest of the canonical JSON of the tool's result (or of
|
|
672
|
+
* the error message string, when status is `failed` or `denied`).
|
|
673
|
+
*/
|
|
674
|
+
result_hash: string;
|
|
675
|
+
/**
|
|
676
|
+
* How this invocation was authorized. `user-tap` for explicit affordance
|
|
677
|
+
* invocations (surface-determinism); `ai-loop` for model-mediated calls
|
|
678
|
+
* inside a turn. Propagates the enclosing task's origin so per-call
|
|
679
|
+
* receipts can be audited independently of the task receipt.
|
|
680
|
+
*/
|
|
681
|
+
invocation_origin?: IntentOrigin;
|
|
682
|
+
/**
|
|
683
|
+
* Cryptosuite discriminator. Always `"motebit-jcs-ed25519-b64-v1"` today.
|
|
684
|
+
* Widening requires a registry change in `SuiteId` + a new dispatch
|
|
685
|
+
* arm in `@motebit/crypto`, not a wire-format break.
|
|
686
|
+
*/
|
|
687
|
+
suite: "motebit-jcs-ed25519-b64-v1";
|
|
688
|
+
signature: string;
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Signed proof that the motebit performed a consolidation cycle. The
|
|
692
|
+
* receipt commits to structural facts only — counts of memories merged,
|
|
693
|
+
* promoted, pruned, and the cycle's identity / timestamps — never to
|
|
694
|
+
* memory content, embeddings, or any sensitive identifier. Anyone with
|
|
695
|
+
* the signer's public key can verify; no relay contact required.
|
|
696
|
+
*
|
|
697
|
+
* Why this exists: every other proactive AI agent today binds the
|
|
698
|
+
* agent's identity to the operator's billing relationship. Motebit
|
|
699
|
+
* binds it to a sovereign Ed25519 identity, so the consolidation work
|
|
700
|
+
* the motebit performs while idle becomes self-attesting evidence the
|
|
701
|
+
* motebit can show to anyone — including itself, across time. The
|
|
702
|
+
* receipt is the evidence; anchoring it on a public ledger (Solana
|
|
703
|
+
* memo via `SolanaMemoSubmitter`, batched per `spec/credential-anchor-v1`)
|
|
704
|
+
* is the additive proof that the receipt existed at the time it claims.
|
|
705
|
+
*
|
|
706
|
+
* Doctrine: [`docs/doctrine/proactive-interior.md`](../../docs/doctrine/proactive-interior.md).
|
|
707
|
+
*/
|
|
708
|
+
export interface ConsolidationReceipt {
|
|
709
|
+
/** UUID — the receipt's own identity (separate from cycle_id). */
|
|
710
|
+
receipt_id: string;
|
|
711
|
+
/** The motebit that performed the cycle. */
|
|
712
|
+
motebit_id: MotebitId;
|
|
713
|
+
/** Signer's Ed25519 public key (hex). Embedded for portable verification
|
|
714
|
+
* — third parties verify without contacting any relay. */
|
|
715
|
+
public_key?: string;
|
|
716
|
+
/** Matches the `cycle_id` carried by the `consolidation_cycle_run` event
|
|
717
|
+
* emitted at cycle completion. Verifiers cross-reference. */
|
|
718
|
+
cycle_id: string;
|
|
719
|
+
/** Cycle timing — milliseconds since Unix epoch. */
|
|
720
|
+
started_at: number;
|
|
721
|
+
finished_at: number;
|
|
722
|
+
/** Phases that ran to completion. Closed union — adding a phase is a
|
|
723
|
+
* protocol-coordinated change. */
|
|
724
|
+
phases_run: ReadonlyArray<"orient" | "gather" | "consolidate" | "prune">;
|
|
725
|
+
/** Phases that yielded mid-execution because their AbortSignal fired
|
|
726
|
+
* (budget exhausted or parent signal aborted). Subset of `phases_run`. */
|
|
727
|
+
phases_yielded: ReadonlyArray<"orient" | "gather" | "consolidate" | "prune">;
|
|
728
|
+
/** Structural counts only — never memory content. The privacy boundary
|
|
729
|
+
* is the type: there is no field here that could leak a memory's text
|
|
730
|
+
* or embedding. Adding such a field is a protocol break. */
|
|
731
|
+
summary: {
|
|
732
|
+
orient_nodes?: number;
|
|
733
|
+
gather_clusters?: number;
|
|
734
|
+
gather_notable?: number;
|
|
735
|
+
consolidate_merged?: number;
|
|
736
|
+
pruned_decay?: number;
|
|
737
|
+
pruned_notability?: number;
|
|
738
|
+
pruned_retention?: number;
|
|
739
|
+
};
|
|
740
|
+
/**
|
|
741
|
+
* Cryptosuite discriminator. Always `"motebit-jcs-ed25519-b64-v1"` for
|
|
742
|
+
* this artifact today — the verification recipe is JCS canonicalization
|
|
743
|
+
* of the unsigned body (this object without `signature`), Ed25519
|
|
744
|
+
* primitive, base64url signature encoding, hex public-key encoding.
|
|
745
|
+
* Verifiers reject missing or unknown suite values fail-closed.
|
|
746
|
+
*/
|
|
747
|
+
suite: "motebit-jcs-ed25519-b64-v1";
|
|
748
|
+
signature: string;
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Merkle-batched anchor over signed `ConsolidationReceipt`s. The motebit
|
|
752
|
+
* batches its own receipts (no relay required), computes a Merkle root
|
|
753
|
+
* over canonical-JSON SHA-256 leaves, and optionally submits the root
|
|
754
|
+
* via a `ChainAnchorSubmitter` (the same primitive the relay uses for
|
|
755
|
+
* credential anchoring; `SolanaMemoSubmitter` is the reference impl).
|
|
756
|
+
*
|
|
757
|
+
* When `tx_hash` is populated the anchor is onchain — anyone can verify
|
|
758
|
+
* that the included receipts existed at `anchored_at` by recomputing
|
|
759
|
+
* their leaf hashes and checking inclusion against the root recorded in
|
|
760
|
+
* the Solana transaction memo (`motebit:anchor:v1:{root}:{leaf_count}`).
|
|
761
|
+
* When `tx_hash` is absent, the anchor is a local-only Merkle commitment
|
|
762
|
+
* — still verifiable by recomputation, just not timestamp-attested.
|
|
763
|
+
*
|
|
764
|
+
* The anchor itself is NOT separately signed. Its cryptographic load is
|
|
765
|
+
* carried by (a) the signatures on the receipts it groups, and (b) the
|
|
766
|
+
* onchain Solana transaction signed by the motebit's identity key (which
|
|
767
|
+
* IS the Solana address — Ed25519 curve coincidence, see
|
|
768
|
+
* `packages/wallet-solana/CLAUDE.md`). Adding a batch-level signature
|
|
769
|
+
* would be redundant.
|
|
770
|
+
*
|
|
771
|
+
* Doctrine: [`docs/doctrine/proactive-interior.md`](../../docs/doctrine/proactive-interior.md).
|
|
772
|
+
*/
|
|
773
|
+
export interface ConsolidationAnchor {
|
|
774
|
+
/** UUID identifying this anchor batch. */
|
|
775
|
+
batch_id: string;
|
|
776
|
+
/** Motebit that produced the receipts in this batch (and signed the
|
|
777
|
+
* Solana transaction that carries the root, when onchain). */
|
|
778
|
+
motebit_id: MotebitId;
|
|
779
|
+
/** Hex-encoded SHA-256 Merkle root over the receipts' canonical-body
|
|
780
|
+
* leaf hashes. Stable for a given ordered set of receipts. */
|
|
781
|
+
merkle_root: string;
|
|
782
|
+
/** Receipt IDs included in this batch, in the order their leaf hashes
|
|
783
|
+
* were inserted into the Merkle tree. Consumers recomputing inclusion
|
|
784
|
+
* proofs MUST preserve this order. */
|
|
785
|
+
receipt_ids: ReadonlyArray<string>;
|
|
786
|
+
/** leaf_count = receipt_ids.length (duplicated for parsers that don't
|
|
787
|
+
* want to count the array). */
|
|
788
|
+
leaf_count: number;
|
|
789
|
+
/** Milliseconds since Unix epoch when the anchor was produced. */
|
|
790
|
+
anchored_at: number;
|
|
791
|
+
/** On-chain transaction hash (Solana signature base58 for
|
|
792
|
+
* `SolanaMemoSubmitter`) if the anchor was submitted. Absent when the
|
|
793
|
+
* anchor was constructed without a submitter. */
|
|
794
|
+
tx_hash?: string;
|
|
795
|
+
/** CAIP-2 network identifier the anchor was submitted to (e.g.,
|
|
796
|
+
* `"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"` for mainnet). Paired
|
|
797
|
+
* with `tx_hash` — absent when `tx_hash` is absent. */
|
|
798
|
+
network?: string;
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Provenance discriminator on `ExecutionReceipt.invocation_origin` and on
|
|
802
|
+
* relay task-submission bodies. Closed string-literal union; verifiers and
|
|
803
|
+
* routers MAY use this to score, audit, or differentiate paths.
|
|
804
|
+
*
|
|
805
|
+
* - `"user-tap"` — explicit user authorization via a UI affordance
|
|
806
|
+
* (chip, button, slash command, scene-object click,
|
|
807
|
+
* voice opt-in). Strongest consent signal.
|
|
808
|
+
* - `"ai-loop"` — the AI loop chose to delegate (e.g., the model
|
|
809
|
+
* called `delegate_to_agent`). Weakest consent
|
|
810
|
+
* signal — the user authorized the conversation,
|
|
811
|
+
* not the specific delegation.
|
|
812
|
+
* - `"scheduled"` — a cron / scheduled trigger initiated the task.
|
|
813
|
+
* - `"agent-to-agent"` — a downstream agent initiated as part of its own
|
|
814
|
+
* handleAgentTask (composition).
|
|
815
|
+
*
|
|
816
|
+
* Doctrine: `docs/doctrine/surface-determinism.md`.
|
|
817
|
+
*/
|
|
818
|
+
export type IntentOrigin = "user-tap" | "ai-loop" | "scheduled" | "agent-to-agent";
|
|
819
|
+
/**
|
|
820
|
+
* Provenance tier for a citation's source. Mirrors the three-tier knowledge
|
|
821
|
+
* hierarchy of the answer engine:
|
|
822
|
+
*
|
|
823
|
+
* - `"interior"` — the motebit's own pre-built knowledge corpus
|
|
824
|
+
* (@motebit/self-knowledge). Offline, no delegation, no
|
|
825
|
+
* receipt — the source is the committed corpus itself.
|
|
826
|
+
* - `"federation"` — another motebit queried through the delegation graph.
|
|
827
|
+
* The `receipt_task_id` field binds the citation to a
|
|
828
|
+
* specific signed ExecutionReceipt in the parent
|
|
829
|
+
* receipt's `delegation_receipts` chain.
|
|
830
|
+
* - `"web"` — an external URL fetched through a read-url atom. The
|
|
831
|
+
* `receipt_task_id` binds to the read-url atom's signed
|
|
832
|
+
* receipt; the claim is "this motebit actually read that
|
|
833
|
+
* URL," not "this URL is correct."
|
|
834
|
+
*
|
|
835
|
+
* Verifiers treat `"interior"` as self-attested (trust the corpus checksum),
|
|
836
|
+
* `"federation"` and `"web"` as receipt-attested (verify the bound receipt's
|
|
837
|
+
* signature and match its `task_id`).
|
|
838
|
+
*/
|
|
839
|
+
export type CitationSource = "interior" | "federation" | "web";
|
|
840
|
+
/**
|
|
841
|
+
* One grounded citation in a `CitedAnswer`. The `text_excerpt` is the span
|
|
842
|
+
* actually incorporated into the answer; the `source` discriminator tells
|
|
843
|
+
* verifiers how to check it.
|
|
844
|
+
*
|
|
845
|
+
* Wire format (foundation law): this is the universal shape for "here is
|
|
846
|
+
* the source of one claim in my answer." Adding fields is additive; changing
|
|
847
|
+
* the discriminator or removing fields is a wire-format break.
|
|
848
|
+
*/
|
|
849
|
+
export interface Citation {
|
|
850
|
+
/** The span of source text the answer drew on. */
|
|
851
|
+
text_excerpt: string;
|
|
852
|
+
/** Which tier produced this source. */
|
|
853
|
+
source: CitationSource;
|
|
854
|
+
/**
|
|
855
|
+
* For `"web"`: the fetched URL.
|
|
856
|
+
* For `"interior"`: the doc path relative to the corpus (e.g., "README.md#section").
|
|
857
|
+
* For `"federation"`: the queried motebit's ID.
|
|
858
|
+
*/
|
|
859
|
+
locator: string;
|
|
860
|
+
/**
|
|
861
|
+
* For `"federation"` and `"web"` — the `task_id` of the bound
|
|
862
|
+
* `ExecutionReceipt` in the parent answer's `delegation_receipts`. Undefined
|
|
863
|
+
* for `"interior"` (the committed corpus is the provenance).
|
|
864
|
+
*/
|
|
865
|
+
receipt_task_id?: string;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* A grounded answer with per-claim citations. Emitted by the answer-engine
|
|
869
|
+
* path (research service today; any grounded-generation surface in future).
|
|
870
|
+
*
|
|
871
|
+
* Wire format: JCS-canonicalizable. Auditors with only `@motebit/protocol`
|
|
872
|
+
* and `@motebit/crypto` can verify:
|
|
873
|
+
* 1. The outer `receipt` signature.
|
|
874
|
+
* 2. Every `citation.receipt_task_id` resolves to a receipt in
|
|
875
|
+
* `receipt.delegation_receipts` whose own signature verifies.
|
|
876
|
+
* 3. For `"interior"` citations, the corpus hash matches the motebit's
|
|
877
|
+
* committed self-knowledge build.
|
|
878
|
+
*
|
|
879
|
+
* The answer text is a plain string; citation-to-text alignment is the
|
|
880
|
+
* renderer's concern (e.g., numbered markers like `[1]` in `answer`).
|
|
881
|
+
*/
|
|
882
|
+
export interface CitedAnswer {
|
|
883
|
+
/** Natural-language answer. */
|
|
884
|
+
answer: string;
|
|
885
|
+
/** Ordered list of sources. `answer` may reference them by index. */
|
|
886
|
+
citations: Citation[];
|
|
887
|
+
/**
|
|
888
|
+
* Outer receipt signed by the emitting motebit. Its
|
|
889
|
+
* `delegation_receipts` chain carries the per-atom signatures that
|
|
890
|
+
* back each `"federation"` / `"web"` citation.
|
|
891
|
+
*/
|
|
892
|
+
receipt: ExecutionReceipt;
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* Self-attesting device-to-relay registration request body.
|
|
896
|
+
*
|
|
897
|
+
* The cryptographic equivalent of a TOFU handshake: the device signs a
|
|
898
|
+
* canonical-JSON serialization of this object (with `signature` removed) using
|
|
899
|
+
* its Ed25519 private key, and the relay verifies the signature against the
|
|
900
|
+
* `public_key` carried in the same request. No prior trust anchor required —
|
|
901
|
+
* the signature proves key control, and key control proves the registrant
|
|
902
|
+
* controls this `motebit_id` going forward (until a key-rotation request
|
|
903
|
+
* explicitly changes the binding, per `spec/auth-token-v1.md` §9).
|
|
904
|
+
*
|
|
905
|
+
* Wire format (foundation law) — the spec lives at
|
|
906
|
+
* `spec/device-self-registration-v1.md`. Verifiers MUST reject requests that
|
|
907
|
+
* fall outside the ±5-minute timestamp window; the relay endpoint is
|
|
908
|
+
* intentionally auth-less because the signature IS the auth.
|
|
909
|
+
*
|
|
910
|
+
* Trust posture: a self-registered device starts at trust zero. Trust
|
|
911
|
+
* accrues through receipts, credentials, and onchain anchors — never
|
|
912
|
+
* through registration alone. See `docs/doctrine/protocol-model.md`.
|
|
913
|
+
*/
|
|
914
|
+
export interface DeviceRegistrationRequest {
|
|
915
|
+
/** Self-asserted identifier. Bound to `public_key` upon successful registration. */
|
|
916
|
+
motebit_id: MotebitId;
|
|
917
|
+
/** Self-asserted device identifier. Bound to `public_key` for the device's lifetime. */
|
|
918
|
+
device_id: string;
|
|
919
|
+
/** 64-char lowercase hex Ed25519 public key (32 bytes). */
|
|
920
|
+
public_key: string;
|
|
921
|
+
/** Optional human-readable label for operator panels and audit logs. */
|
|
922
|
+
device_name?: string;
|
|
923
|
+
/**
|
|
924
|
+
* Optional owner reference. Sovereign devices that own themselves SHOULD
|
|
925
|
+
* set `"self:<motebit_id>"`. Multi-tenant SDKs MAY set their tenant
|
|
926
|
+
* identifier. The relay defaults to `"self:<motebit_id>"` when absent.
|
|
927
|
+
*/
|
|
928
|
+
owner_id?: string;
|
|
929
|
+
/**
|
|
930
|
+
* Epoch milliseconds at request creation. Relay rejects requests where
|
|
931
|
+
* `abs(now - timestamp) > 5 minutes` — the only replay defense at the
|
|
932
|
+
* wire level. See spec §6.1 for the threat model this defends.
|
|
933
|
+
*/
|
|
934
|
+
timestamp: number;
|
|
935
|
+
/**
|
|
936
|
+
* Cryptosuite identifier. Routes through the suite-dispatch in
|
|
937
|
+
* `@motebit/crypto`; PQ migration is a registry addition, not a
|
|
938
|
+
* wire-format break.
|
|
939
|
+
*/
|
|
940
|
+
suite: import("./crypto-suite.js").SuiteId;
|
|
941
|
+
/**
|
|
942
|
+
* base64url-encoded Ed25519 signature over the canonical-JSON
|
|
943
|
+
* serialization of this object with `signature` removed.
|
|
944
|
+
*/
|
|
509
945
|
signature: string;
|
|
510
946
|
}
|
|
511
947
|
export interface DelegatedStepResult {
|
|
@@ -522,6 +958,25 @@ export interface DelegatedStepResult {
|
|
|
522
958
|
alternatives_considered: number;
|
|
523
959
|
};
|
|
524
960
|
}
|
|
961
|
+
/**
|
|
962
|
+
* Encrypted identity key transfer payload for multi-device pairing.
|
|
963
|
+
*
|
|
964
|
+
* Device A encrypts its Ed25519 identity seed using ephemeral X25519 key agreement
|
|
965
|
+
* and posts this payload through the relay. The relay sees only opaque ciphertext.
|
|
966
|
+
* Device B decrypts using its held ephemeral X25519 private key + the pairing code.
|
|
967
|
+
*/
|
|
968
|
+
export interface KeyTransferPayload {
|
|
969
|
+
/** Device A's ephemeral X25519 public key (64-char hex). */
|
|
970
|
+
x25519_pubkey: string;
|
|
971
|
+
/** AES-256-GCM encrypted 32-byte Ed25519 identity seed (hex). */
|
|
972
|
+
encrypted_seed: string;
|
|
973
|
+
/** AES-256-GCM nonce, 12 bytes (24-char hex). */
|
|
974
|
+
nonce: string;
|
|
975
|
+
/** AES-256-GCM auth tag, 16 bytes (32-char hex). */
|
|
976
|
+
tag: string;
|
|
977
|
+
/** Device A's Ed25519 identity public key for post-decryption verification (64-char hex). */
|
|
978
|
+
identity_pubkey_check: string;
|
|
979
|
+
}
|
|
525
980
|
/**
|
|
526
981
|
* A key succession record proving that one Ed25519 key has been replaced by another.
|
|
527
982
|
* Both the old and new keys sign the record, creating a cryptographic chain of custody.
|
|
@@ -535,6 +990,14 @@ export interface KeySuccessionRecord {
|
|
|
535
990
|
new_public_key: string;
|
|
536
991
|
timestamp: number;
|
|
537
992
|
reason?: string;
|
|
993
|
+
/**
|
|
994
|
+
* Cryptosuite discriminator. Always `"motebit-jcs-ed25519-hex-v1"` for
|
|
995
|
+
* this artifact today — JCS canonicalization of the unsigned payload,
|
|
996
|
+
* Ed25519 primitive, hex signature encoding, hex public-key encoding.
|
|
997
|
+
* The same suite as the identity frontmatter (spec/identity-v1.md §3.8).
|
|
998
|
+
* Verifiers reject missing or unknown suite values fail-closed.
|
|
999
|
+
*/
|
|
1000
|
+
suite: "motebit-jcs-ed25519-hex-v1";
|
|
538
1001
|
old_key_signature?: string;
|
|
539
1002
|
new_key_signature: string;
|
|
540
1003
|
/** Guardian recovery: true when succession was authorized by guardian, not old key. */
|
|
@@ -702,6 +1165,26 @@ export interface BudgetAllocation {
|
|
|
702
1165
|
* via MOTEBIT_PLATFORM_FEE_RATE env or config.platformFeeRate.
|
|
703
1166
|
*/
|
|
704
1167
|
export declare const PLATFORM_FEE_RATE = 0.05;
|
|
1168
|
+
/**
|
|
1169
|
+
* Per-task settlement bookkeeping artifact.
|
|
1170
|
+
*
|
|
1171
|
+
* Foundation Law (services/api/CLAUDE.md rule 6):
|
|
1172
|
+
* - Every truth the relay asserts (credential anchor proofs,
|
|
1173
|
+
* revocation memos, settlement receipts) is independently
|
|
1174
|
+
* verifiable onchain without relay contact.
|
|
1175
|
+
*
|
|
1176
|
+
* The settlement is signed by the issuing relay over the canonical
|
|
1177
|
+
* JSON of all fields except `signature`. Verifiers reconstruct the
|
|
1178
|
+
* canonical bytes (omitting `signature`) and check Ed25519 against
|
|
1179
|
+
* the issuing relay's public key. A malicious relay therefore
|
|
1180
|
+
* cannot issue inconsistent records to different observers — the
|
|
1181
|
+
* signature commits the relay to the exact (amount_settled,
|
|
1182
|
+
* platform_fee, platform_fee_rate, status) tuple it published.
|
|
1183
|
+
*
|
|
1184
|
+
* Federation settlements additionally get Merkle-batched and
|
|
1185
|
+
* onchain-anchored (relay-federation-v1.md §7.6); per-agent
|
|
1186
|
+
* settlements rely on the signature for self-attestation.
|
|
1187
|
+
*/
|
|
705
1188
|
export interface SettlementRecord {
|
|
706
1189
|
settlement_id: SettlementId;
|
|
707
1190
|
allocation_id: AllocationId;
|
|
@@ -719,6 +1202,215 @@ export interface SettlementRecord {
|
|
|
719
1202
|
x402_network?: string;
|
|
720
1203
|
status: "completed" | "partial" | "refunded";
|
|
721
1204
|
settled_at: number;
|
|
1205
|
+
/**
|
|
1206
|
+
* Issuing relay's motebit_id. The signer of this record. Must
|
|
1207
|
+
* match the public key resolvable through the relay's identity.
|
|
1208
|
+
*/
|
|
1209
|
+
issuer_relay_id: string;
|
|
1210
|
+
/**
|
|
1211
|
+
* Cryptosuite discriminator. Always `"motebit-jcs-ed25519-b64-v1"` —
|
|
1212
|
+
* JCS canonicalization, Ed25519 primitive, base64url signature
|
|
1213
|
+
* encoding. Verifiers reject missing or unknown values fail-closed.
|
|
1214
|
+
*/
|
|
1215
|
+
suite: "motebit-jcs-ed25519-b64-v1";
|
|
1216
|
+
/**
|
|
1217
|
+
* Base64url-encoded Ed25519 signature by the issuing relay over
|
|
1218
|
+
* canonical JSON of all fields except `signature`. Lets a worker
|
|
1219
|
+
* (or any auditor) prove what the relay claimed without trusting
|
|
1220
|
+
* the relay's word about it.
|
|
1221
|
+
*/
|
|
1222
|
+
signature: string;
|
|
1223
|
+
}
|
|
1224
|
+
/** Proof of payment from a settlement rail. */
|
|
1225
|
+
export interface PaymentProof {
|
|
1226
|
+
/** Transaction hash or reference ID from the rail. */
|
|
1227
|
+
reference: string;
|
|
1228
|
+
/** Rail type that produced this proof. */
|
|
1229
|
+
railType: "fiat" | "protocol" | "direct_asset" | "orchestration";
|
|
1230
|
+
/** Network identifier (CAIP-2 for onchain, "stripe" for fiat, etc.). */
|
|
1231
|
+
network?: string;
|
|
1232
|
+
/** ISO timestamp of when the payment was confirmed. */
|
|
1233
|
+
confirmedAt: number;
|
|
1234
|
+
}
|
|
1235
|
+
/** Deposit result from a settlement rail. */
|
|
1236
|
+
export interface DepositResult {
|
|
1237
|
+
/** Amount deposited in micro-units. */
|
|
1238
|
+
amount: number;
|
|
1239
|
+
/** Currency code (e.g., "USD", "USDC"). */
|
|
1240
|
+
currency: string;
|
|
1241
|
+
/** Payment proof for audit trail. */
|
|
1242
|
+
proof: PaymentProof;
|
|
1243
|
+
}
|
|
1244
|
+
/** Withdrawal result from a settlement rail. */
|
|
1245
|
+
export interface WithdrawalResult {
|
|
1246
|
+
/** Amount withdrawn in micro-units. */
|
|
1247
|
+
amount: number;
|
|
1248
|
+
/** Currency code. */
|
|
1249
|
+
currency: string;
|
|
1250
|
+
/** Payment proof for audit trail. */
|
|
1251
|
+
proof: PaymentProof;
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Settlement rail — the external money-movement boundary, split by custody.
|
|
1255
|
+
*
|
|
1256
|
+
* Every rail is either a GuestRail (relay holds the money, rail moves it in/out)
|
|
1257
|
+
* or a SovereignRail (the agent holds the keys, the rail is the agent's own wallet).
|
|
1258
|
+
* The `custody` discriminant makes this a compile-time distinction.
|
|
1259
|
+
*
|
|
1260
|
+
* Doctrine: the relay's rail registry accepts only GuestRails. SovereignRails live
|
|
1261
|
+
* in the agent's runtime process and are never registered at the relay, because
|
|
1262
|
+
* sovereign means the agent signs its own transactions and the relay is not in
|
|
1263
|
+
* the signing path. The type system enforces the doctrine — not prose.
|
|
1264
|
+
*
|
|
1265
|
+
* See GuestRail and SovereignRail below for their respective contracts.
|
|
1266
|
+
*/
|
|
1267
|
+
export interface SettlementRail {
|
|
1268
|
+
/** Human-readable name for logging and config (e.g., "stripe", "solana-wallet"). */
|
|
1269
|
+
readonly name: string;
|
|
1270
|
+
/** Who holds the keys/funds this rail moves. Compile-time custody boundary. */
|
|
1271
|
+
readonly custody: "relay" | "agent";
|
|
1272
|
+
/** Whether this rail is currently available (provider reachable, config valid). */
|
|
1273
|
+
isAvailable(): Promise<boolean>;
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
* GuestRail — relay-custody settlement rail.
|
|
1277
|
+
*
|
|
1278
|
+
* The relay holds the user's money in a virtual account; a GuestRail moves it
|
|
1279
|
+
* across the relay's boundary to an external system and back. The rail is a
|
|
1280
|
+
* guest in the relay's economic loop — it doesn't hold the permanent ledger,
|
|
1281
|
+
* it just carries money through the membrane.
|
|
1282
|
+
*
|
|
1283
|
+
* Three rail types:
|
|
1284
|
+
* - "fiat" — traditional payment processor (Stripe Checkout)
|
|
1285
|
+
* - "protocol" — HTTP-native agent payment protocols (MPP, x402)
|
|
1286
|
+
* - "orchestration" — fiat↔crypto bridging (Bridge)
|
|
1287
|
+
*
|
|
1288
|
+
* There is no "direct_asset" GuestRail — direct onchain transfer is always
|
|
1289
|
+
* sovereign (the agent signs) and belongs in SovereignRail.
|
|
1290
|
+
*
|
|
1291
|
+
* Not all rails support deposits. Fiat rails accept proactive deposits.
|
|
1292
|
+
* Protocol rails (x402, MPP) are pay-per-request — money moves at the HTTP
|
|
1293
|
+
* boundary, not through the rail. Use `supportsDeposit` discriminant for
|
|
1294
|
+
* runtime narrowing: `if (rail.supportsDeposit) rail.deposit(...)`.
|
|
1295
|
+
*
|
|
1296
|
+
* The relay picks the rail at routing time based on what the counterparty accepts.
|
|
1297
|
+
*/
|
|
1298
|
+
export interface GuestRail extends SettlementRail {
|
|
1299
|
+
readonly custody: "relay";
|
|
1300
|
+
readonly railType: "fiat" | "protocol" | "orchestration";
|
|
1301
|
+
/** Whether this rail supports proactive deposits. False for pay-per-request rails (x402, MPP). */
|
|
1302
|
+
readonly supportsDeposit: boolean;
|
|
1303
|
+
/**
|
|
1304
|
+
* Whether the rail exposes a single-call batch withdrawal primitive.
|
|
1305
|
+
* When true, `withdrawBatch` MUST be implemented. When false (the
|
|
1306
|
+
* default for every rail that ships in the reference relay today),
|
|
1307
|
+
* aggregation is still a win at the relay layer — the batch worker
|
|
1308
|
+
* defers sub-threshold items and fires serially once the policy
|
|
1309
|
+
* clears — but the rail itself settles one item per call.
|
|
1310
|
+
* Mirrors `supportsDeposit` + `DepositableGuestRail` as a
|
|
1311
|
+
* discriminant narrowing to `BatchableGuestRail`.
|
|
1312
|
+
*/
|
|
1313
|
+
readonly supportsBatch: boolean;
|
|
1314
|
+
/**
|
|
1315
|
+
* Execute a withdrawal to an external destination.
|
|
1316
|
+
* Fail-closed: throws on any error.
|
|
1317
|
+
*/
|
|
1318
|
+
withdraw(motebitId: string, amount: number, currency: string, destination: string, idempotencyKey: string): Promise<WithdrawalResult>;
|
|
1319
|
+
/**
|
|
1320
|
+
* Submit multiple withdrawals in one rail call when the rail
|
|
1321
|
+
* supports a native batch primitive (e.g., a future x402 multi-
|
|
1322
|
+
* authorization, a Bridge bulk-transfer). Present only when
|
|
1323
|
+
* `supportsBatch` is true — narrow with `isBatchableRail`.
|
|
1324
|
+
*/
|
|
1325
|
+
withdrawBatch?(items: readonly BatchWithdrawalItem[]): Promise<BatchWithdrawalResult>;
|
|
1326
|
+
/**
|
|
1327
|
+
* Record a payment proof with a settlement (e.g., x402 tx hash, Stripe charge ID).
|
|
1328
|
+
* Called after settleOnReceipt() computes the settlement record.
|
|
1329
|
+
*/
|
|
1330
|
+
attachProof(settlementId: string, proof: PaymentProof): Promise<void>;
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Single item within a batch withdrawal submission. Amounts are
|
|
1334
|
+
* micro-units (1_000_000 = 1 unit of asset). The relay constructs
|
|
1335
|
+
* one item per `relay_pending_withdrawals` row.
|
|
1336
|
+
*/
|
|
1337
|
+
export interface BatchWithdrawalItem {
|
|
1338
|
+
readonly motebit_id: string;
|
|
1339
|
+
readonly amount_micro: number;
|
|
1340
|
+
readonly currency: string;
|
|
1341
|
+
readonly destination: string;
|
|
1342
|
+
readonly idempotency_key: string;
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Per-item outcome of a batch withdrawal. Partial failure is
|
|
1346
|
+
* first-class: a rail MAY succeed on some items and fail on others.
|
|
1347
|
+
* `failed[i].reason` is a human-readable string — not part of the
|
|
1348
|
+
* signed proof, just operator telemetry.
|
|
1349
|
+
*/
|
|
1350
|
+
export interface BatchWithdrawalResult {
|
|
1351
|
+
readonly fired: ReadonlyArray<{
|
|
1352
|
+
item: BatchWithdrawalItem;
|
|
1353
|
+
result: WithdrawalResult;
|
|
1354
|
+
}>;
|
|
1355
|
+
readonly failed: ReadonlyArray<{
|
|
1356
|
+
item: BatchWithdrawalItem;
|
|
1357
|
+
reason: string;
|
|
1358
|
+
}>;
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* A guest rail that supports batch withdrawal submission.
|
|
1362
|
+
* Use the `supportsBatch` discriminant for runtime narrowing from `GuestRail`.
|
|
1363
|
+
*/
|
|
1364
|
+
export interface BatchableGuestRail extends GuestRail {
|
|
1365
|
+
readonly supportsBatch: true;
|
|
1366
|
+
withdrawBatch(items: readonly BatchWithdrawalItem[]): Promise<BatchWithdrawalResult>;
|
|
1367
|
+
}
|
|
1368
|
+
/**
|
|
1369
|
+
* A guest rail that supports proactive deposits (Stripe Checkout).
|
|
1370
|
+
* Use the `supportsDeposit` discriminant for runtime narrowing from `GuestRail`.
|
|
1371
|
+
*/
|
|
1372
|
+
export interface DepositableGuestRail extends GuestRail {
|
|
1373
|
+
readonly supportsDeposit: true;
|
|
1374
|
+
/**
|
|
1375
|
+
* Initiate a deposit. Returns a deposit result or a redirect URL
|
|
1376
|
+
* (for interactive flows like Stripe Checkout).
|
|
1377
|
+
*/
|
|
1378
|
+
deposit(motebitId: string, amount: number, currency: string, idempotencyKey: string): Promise<DepositResult | {
|
|
1379
|
+
redirectUrl: string;
|
|
1380
|
+
}>;
|
|
1381
|
+
}
|
|
1382
|
+
/** Type guard: narrows GuestRail to DepositableGuestRail. */
|
|
1383
|
+
export declare function isDepositableRail(rail: GuestRail): rail is DepositableGuestRail;
|
|
1384
|
+
/** Type guard: narrows GuestRail to BatchableGuestRail. */
|
|
1385
|
+
export declare function isBatchableRail(rail: GuestRail): rail is BatchableGuestRail;
|
|
1386
|
+
/**
|
|
1387
|
+
* SovereignRail — agent-custody settlement rail.
|
|
1388
|
+
*
|
|
1389
|
+
* The agent's identity key signs; the rail is the agent's own wallet. There is
|
|
1390
|
+
* no third-party custodian and the relay is not in the signing path. Withdrawal
|
|
1391
|
+
* from a sovereign rail is just a transfer — the funds never left the agent.
|
|
1392
|
+
*
|
|
1393
|
+
* Reference implementation: `SolanaWalletRail` in `@motebit/wallet-solana`.
|
|
1394
|
+
* The Ed25519 identity public key is natively a valid Solana address, so the
|
|
1395
|
+
* wallet address equals the motebit's identity — no second key, no key-derivation
|
|
1396
|
+
* ceremony, no vendor. Future Ed25519-native chains (Aptos, Sui) implement the
|
|
1397
|
+
* same interface.
|
|
1398
|
+
*
|
|
1399
|
+
* SovereignRails MUST NOT appear in the relay's guest rail registry. The type
|
|
1400
|
+
* split is mechanical: `SettlementRailRegistry.register` accepts only `GuestRail`,
|
|
1401
|
+
* so the compiler rejects attempts to register a sovereign rail at the relay.
|
|
1402
|
+
* This is the sovereignty doctrine expressed as a type.
|
|
1403
|
+
*/
|
|
1404
|
+
export interface SovereignRail extends SettlementRail {
|
|
1405
|
+
readonly custody: "agent";
|
|
1406
|
+
/** Chain identifier (e.g., "solana"). Future: "aptos", "sui". */
|
|
1407
|
+
readonly chain: string;
|
|
1408
|
+
/** Asset symbol (e.g., "USDC"). */
|
|
1409
|
+
readonly asset: string;
|
|
1410
|
+
/** Agent's own address on this chain. Equals the motebit identity public key for Ed25519-native chains. */
|
|
1411
|
+
readonly address: string;
|
|
1412
|
+
/** Current balance in micro-units (1e6 = 1 unit of asset). */
|
|
1413
|
+
getBalance(): Promise<bigint>;
|
|
722
1414
|
}
|
|
723
1415
|
export interface CollaborativePlanProposal {
|
|
724
1416
|
proposal_id: ProposalId;
|
|
@@ -755,6 +1447,13 @@ export interface CollaborativeReceipt {
|
|
|
755
1447
|
plan_id: PlanId;
|
|
756
1448
|
participant_receipts: ExecutionReceipt[];
|
|
757
1449
|
content_hash: string;
|
|
1450
|
+
/**
|
|
1451
|
+
* Cryptosuite discriminator for `initiator_signature`. Always
|
|
1452
|
+
* `"motebit-jcs-ed25519-b64-v1"` today — JCS canonicalization of the
|
|
1453
|
+
* aggregate payload, Ed25519 primitive, base64url signature encoding.
|
|
1454
|
+
* Verifiers reject missing or unknown suite values fail-closed.
|
|
1455
|
+
*/
|
|
1456
|
+
suite: "motebit-jcs-ed25519-b64-v1";
|
|
758
1457
|
initiator_signature: string;
|
|
759
1458
|
}
|
|
760
1459
|
export interface MarketConfig {
|
|
@@ -791,6 +1490,73 @@ export interface TrustCredentialSubject {
|
|
|
791
1490
|
failed_tasks: number;
|
|
792
1491
|
first_seen_at: number;
|
|
793
1492
|
last_seen_at: number;
|
|
1493
|
+
/**
|
|
1494
|
+
* Optional hardware-attestation claim. Present when the subject agent
|
|
1495
|
+
* demonstrated that its identity key lives inside a hardware keystore
|
|
1496
|
+
* (Secure Enclave, TPM, Android Keystore / Play Integrity, Apple
|
|
1497
|
+
* DeviceCheck). Consumed by `HardwareAttestationSemiring` in the
|
|
1498
|
+
* routing layer to rank hardware-attested agents above software-only
|
|
1499
|
+
* agents for sensitivity-aware delegation. See spec/credential-v1.md
|
|
1500
|
+
* §3.4 and `HardwareAttestationClaim`. Absence means "no claim"
|
|
1501
|
+
* (equivalent to `platform: "software"` for ranking purposes).
|
|
1502
|
+
*/
|
|
1503
|
+
hardware_attestation?: HardwareAttestationClaim;
|
|
1504
|
+
}
|
|
1505
|
+
/**
|
|
1506
|
+
* Hardware attestation claim embedded in `TrustCredentialSubject`. One claim
|
|
1507
|
+
* describes the subject agent's key-custody posture on the device that issued
|
|
1508
|
+
* the credential.
|
|
1509
|
+
*
|
|
1510
|
+
* Wire format (foundation law) — see spec/credential-v1.md §3.4 for the
|
|
1511
|
+
* binding subsection. Every conformant implementation MUST emit these
|
|
1512
|
+
* field names and types; the claim is carried inside the existing
|
|
1513
|
+
* `AgentTrustCredential` VC envelope so the outer `suite` field already
|
|
1514
|
+
* covers the signature.
|
|
1515
|
+
*
|
|
1516
|
+
* `platform` enumerates the attestation surface; `"software"` is the
|
|
1517
|
+
* sentinel for "no hardware-backed key" and is explicitly part of the
|
|
1518
|
+
* enum so credentials can truthfully claim "we tried, there was no
|
|
1519
|
+
* hardware" rather than omit the field (which is ambiguous between
|
|
1520
|
+
* "unknown" and "software").
|
|
1521
|
+
*
|
|
1522
|
+
* `key_exported` matters because even a hardware-generated key can be
|
|
1523
|
+
* exported to software storage (e.g. backup, pairing, migration). When
|
|
1524
|
+
* `true`, the claim is weaker — the private material left the hardware,
|
|
1525
|
+
* so the binding between "this key is signing" and "this hardware held
|
|
1526
|
+
* it" is broken for the lifetime of the export.
|
|
1527
|
+
*
|
|
1528
|
+
* `attestation_receipt` is an opaque platform-specific blob (Apple
|
|
1529
|
+
* DeviceCheck assertion, Google Play Integrity token, TPM quote) that
|
|
1530
|
+
* a verifier with the matching platform adapter can independently
|
|
1531
|
+
* verify. Motebit does not parse these — adapters are glucose per the
|
|
1532
|
+
* metabolic principle; this field just reserves wire-format space for
|
|
1533
|
+
* them. Absence does not invalidate the claim; it just means the
|
|
1534
|
+
* verifier has no side-channel proof beyond the credential signature.
|
|
1535
|
+
*/
|
|
1536
|
+
export interface HardwareAttestationClaim {
|
|
1537
|
+
/**
|
|
1538
|
+
* Attestation surface identifier. `"software"` is the explicit
|
|
1539
|
+
* no-hardware sentinel — a credential that carries a claim with
|
|
1540
|
+
* `platform: "software"` is truthfully claiming "this key is not
|
|
1541
|
+
* hardware-backed", distinct from an absent claim ("unknown").
|
|
1542
|
+
*/
|
|
1543
|
+
platform: "secure_enclave" | "tpm" | "play_integrity" | "device_check" | "webauthn" | "software";
|
|
1544
|
+
/**
|
|
1545
|
+
* True when the private key was exported from hardware to software
|
|
1546
|
+
* storage (backup, pairing). Weakens the claim — the hardware no
|
|
1547
|
+
* longer uniquely holds the material. Default false; absent ≡ false
|
|
1548
|
+
* for backward compatibility when a minting tool forgets to set it
|
|
1549
|
+
* on a software-only platform.
|
|
1550
|
+
*/
|
|
1551
|
+
key_exported?: boolean;
|
|
1552
|
+
/**
|
|
1553
|
+
* Opaque platform-specific attestation blob. Apple DeviceCheck
|
|
1554
|
+
* assertion, Google Play Integrity token, or TPM quote bytes encoded
|
|
1555
|
+
* as the platform expects (base64url by convention). Motebit does not
|
|
1556
|
+
* parse this — platform adapters at the verification boundary do.
|
|
1557
|
+
* Absent when no platform receipt is available.
|
|
1558
|
+
*/
|
|
1559
|
+
attestation_receipt?: string;
|
|
794
1560
|
}
|
|
795
1561
|
export interface GradientCredentialSubject {
|
|
796
1562
|
id: string;
|
|
@@ -988,5 +1754,26 @@ export interface ApprovalStoreAdapter {
|
|
|
988
1754
|
/** Set quorum metadata on a pending approval item. */
|
|
989
1755
|
setQuorum(approvalId: string, required: number, approvers: string[]): void;
|
|
990
1756
|
}
|
|
991
|
-
export {};
|
|
1757
|
+
export type { Semiring } from "./semiring.js";
|
|
1758
|
+
export { TrustSemiring, CostSemiring, LatencySemiring, BottleneckSemiring, ReliabilitySemiring, BooleanSemiring, RegulatoryRiskSemiring, MaxProductLogSemiring, productSemiring, recordSemiring, mappedSemiring, } from "./semiring.js";
|
|
1759
|
+
export type { Edge } from "./graph.js";
|
|
1760
|
+
export { WeightedDigraph } from "./graph.js";
|
|
1761
|
+
export { optimalPaths, optimalPath, transitiveClosure, optimalPathTrace } from "./traversal.js";
|
|
1762
|
+
export { TRUST_LEVEL_SCORES, trustLevelToScore, TRUST_ZERO, TRUST_ONE, trustAdd, trustMultiply, composeTrustChain, joinParallelRoutes, DEFAULT_TRUST_THRESHOLDS, } from "./trust-algebra.js";
|
|
1763
|
+
export type { CredentialAnchorBatch, CredentialChainAnchor, CredentialAnchorProof, ChainAnchorSubmitter, } from "./credential-anchor.js";
|
|
1764
|
+
export type { AgentSettlementAnchorBatch, AgentSettlementChainAnchor, AgentSettlementAnchorProof, } from "./agent-settlement-anchor.js";
|
|
1765
|
+
export type { RelayMetadata, RelayMetadataPeer, AgentResolutionResult } from "./discovery.js";
|
|
1766
|
+
export type { MigrationState, MigrationRequest, MigrationToken, DepartureAttestation, CredentialBundle, BalanceWaiver, MigrationPresentation, } from "./migration.js";
|
|
1767
|
+
export type { DisputeState, DisputeOutcome, DisputeCategory, DisputeFundAction, DisputeRequest, DisputeEvidence, DisputeEvidenceType, AdjudicatorVote, DisputeResolution, DisputeAppeal, } from "./dispute.js";
|
|
1768
|
+
export type { SettlementMode, P2pPaymentProof, PaymentVerificationStatus, SettlementEligibility, SolvencyProof, } from "./settlement-mode.js";
|
|
1769
|
+
export type { SuiteId, SuiteEntry, SuiteStatus, SuiteAlgorithm, SuiteCanonicalization, SuiteSignatureEncoding, SuitePublicKeyEncoding, } from "./crypto-suite.js";
|
|
1770
|
+
export { SUITE_REGISTRY, ALL_SUITE_IDS, isSuiteId, getSuiteEntry } from "./crypto-suite.js";
|
|
1771
|
+
export type { MemoryDecayedPayload, MemoryFormedPayload, MemoryAccessedPayload, MemoryPinnedPayload, MemoryDeletedPayload, MemoryConsolidatedPayload, MemoryAuditPayload, MemoryPromotedPayload, } from "./memory-events.js";
|
|
1772
|
+
export type { GoalCreatedPayload, GoalExecutedPayload, GoalProgressPayload, GoalCompletedPayload, GoalRemovedPayload, } from "./goal-lifecycle.js";
|
|
1773
|
+
export type { PlanCreatedPayload, PlanStepStartedPayload, PlanStepCompletedPayload, PlanStepFailedPayload, PlanStepDelegatedPayload, PlanCompletedPayload, PlanFailedPayload, } from "./plan-lifecycle.js";
|
|
1774
|
+
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";
|
|
1775
|
+
export { COMPUTER_ACTION_KINDS, COMPUTER_FAILURE_REASONS } from "./computer-use.js";
|
|
1776
|
+
export type { ToolMode } from "./tool-mode.js";
|
|
1777
|
+
export { TOOL_MODES, toolModePriority } from "./tool-mode.js";
|
|
1778
|
+
import type { ToolMode } from "./tool-mode.js";
|
|
992
1779
|
//# sourceMappingURL=index.d.ts.map
|