@motebit/sdk 0.6.11 → 0.8.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 (74) hide show
  1. package/README.md +15 -110
  2. package/dist/__tests__/appearance-config.test.d.ts +2 -0
  3. package/dist/__tests__/appearance-config.test.d.ts.map +1 -0
  4. package/dist/__tests__/appearance-config.test.js +104 -0
  5. package/dist/__tests__/appearance-config.test.js.map +1 -0
  6. package/dist/__tests__/branded-ids.test.d.ts +2 -0
  7. package/dist/__tests__/branded-ids.test.d.ts.map +1 -0
  8. package/dist/__tests__/branded-ids.test.js +70 -0
  9. package/dist/__tests__/branded-ids.test.js.map +1 -0
  10. package/dist/__tests__/index.test.d.ts +2 -0
  11. package/dist/__tests__/index.test.d.ts.map +1 -0
  12. package/dist/__tests__/index.test.js +194 -0
  13. package/dist/__tests__/index.test.js.map +1 -0
  14. package/dist/__tests__/provider-mode.test.d.ts +2 -0
  15. package/dist/__tests__/provider-mode.test.d.ts.map +1 -0
  16. package/dist/__tests__/provider-mode.test.js +180 -0
  17. package/dist/__tests__/provider-mode.test.js.map +1 -0
  18. package/dist/__tests__/provider-resolver.test.d.ts +2 -0
  19. package/dist/__tests__/provider-resolver.test.d.ts.map +1 -0
  20. package/dist/__tests__/provider-resolver.test.js +353 -0
  21. package/dist/__tests__/provider-resolver.test.js.map +1 -0
  22. package/dist/__tests__/voice-config.test.d.ts +2 -0
  23. package/dist/__tests__/voice-config.test.d.ts.map +1 -0
  24. package/dist/__tests__/voice-config.test.js +98 -0
  25. package/dist/__tests__/voice-config.test.js.map +1 -0
  26. package/dist/appearance-config.d.ts +55 -0
  27. package/dist/appearance-config.d.ts.map +1 -0
  28. package/dist/appearance-config.js +79 -0
  29. package/dist/appearance-config.js.map +1 -0
  30. package/dist/approval-presets.d.ts +16 -0
  31. package/dist/approval-presets.d.ts.map +1 -0
  32. package/dist/approval-presets.js +30 -0
  33. package/dist/approval-presets.js.map +1 -0
  34. package/dist/color-presets.d.ts +14 -0
  35. package/dist/color-presets.d.ts.map +1 -0
  36. package/dist/color-presets.js +17 -0
  37. package/dist/color-presets.js.map +1 -0
  38. package/dist/credential-types-doc.d.ts +73 -0
  39. package/dist/credential-types-doc.d.ts.map +1 -0
  40. package/dist/credential-types-doc.js +2 -0
  41. package/dist/credential-types-doc.js.map +1 -0
  42. package/dist/governance-config.d.ts +19 -0
  43. package/dist/governance-config.d.ts.map +1 -0
  44. package/dist/governance-config.js +15 -0
  45. package/dist/governance-config.js.map +1 -0
  46. package/dist/index.d.ts +97 -1045
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +12 -346
  49. package/dist/index.js.map +1 -1
  50. package/dist/models.d.ts +56 -0
  51. package/dist/models.d.ts.map +1 -0
  52. package/dist/models.js +85 -0
  53. package/dist/models.js.map +1 -0
  54. package/dist/provider-mode.d.ts +109 -0
  55. package/dist/provider-mode.d.ts.map +1 -0
  56. package/dist/provider-mode.js +179 -0
  57. package/dist/provider-mode.js.map +1 -0
  58. package/dist/provider-resolver.d.ts +179 -0
  59. package/dist/provider-resolver.d.ts.map +1 -0
  60. package/dist/provider-resolver.js +224 -0
  61. package/dist/provider-resolver.js.map +1 -0
  62. package/dist/risk-labels.d.ts +22 -0
  63. package/dist/risk-labels.d.ts.map +1 -0
  64. package/dist/risk-labels.js +28 -0
  65. package/dist/risk-labels.js.map +1 -0
  66. package/dist/surface-options.d.ts +34 -0
  67. package/dist/surface-options.d.ts.map +1 -0
  68. package/dist/surface-options.js +36 -0
  69. package/dist/surface-options.js.map +1 -0
  70. package/dist/voice-config.d.ts +52 -0
  71. package/dist/voice-config.d.ts.map +1 -0
  72. package/dist/voice-config.js +61 -0
  73. package/dist/voice-config.js.map +1 -0
  74. package/package.json +9 -6
package/dist/index.d.ts CHANGED
@@ -1,203 +1,15 @@
1
- declare const __brand: unique symbol;
2
- type Brand<T, B extends string> = T & {
3
- readonly [__brand]?: B;
4
- };
5
- export type MotebitId = Brand<string, "MotebitId">;
6
- export type DeviceId = Brand<string, "DeviceId">;
7
- export type NodeId = Brand<string, "NodeId">;
8
- export type GoalId = Brand<string, "GoalId">;
9
- export type EventId = Brand<string, "EventId">;
10
- export type ConversationId = Brand<string, "ConversationId">;
11
- export type PlanId = Brand<string, "PlanId">;
12
- export type AllocationId = Brand<string, "AllocationId">;
13
- export type SettlementId = Brand<string, "SettlementId">;
14
- export type ListingId = Brand<string, "ListingId">;
15
- export type ProposalId = Brand<string, "ProposalId">;
16
- /** Brand a string as a MotebitId after validation. */
17
- export declare function asMotebitId(id: string): MotebitId;
18
- /** Brand a string as a DeviceId after validation. */
19
- export declare function asDeviceId(id: string): DeviceId;
20
- /** Brand a string as a NodeId after validation. */
21
- export declare function asNodeId(id: string): NodeId;
22
- /** Brand a string as a GoalId after validation. */
23
- export declare function asGoalId(id: string): GoalId;
24
- /** Brand a string as an EventId after validation. */
25
- export declare function asEventId(id: string): EventId;
26
- /** Brand a string as a ConversationId after validation. */
27
- export declare function asConversationId(id: string): ConversationId;
28
- /** Brand a string as a PlanId after validation. */
29
- export declare function asPlanId(id: string): PlanId;
30
- /** Brand a string as an AllocationId after validation. */
31
- export declare function asAllocationId(id: string): AllocationId;
32
- /** Brand a string as a SettlementId after validation. */
33
- export declare function asSettlementId(id: string): SettlementId;
34
- /** Brand a string as a ListingId after validation. */
35
- export declare function asListingId(id: string): ListingId;
36
- /** Brand a string as a ProposalId after validation. */
37
- export declare function asProposalId(id: string): ProposalId;
38
- export declare enum TrustMode {
39
- Full = "full",
40
- Guarded = "guarded",
41
- Minimal = "minimal"
42
- }
43
- export declare enum BatteryMode {
44
- Normal = "normal",
45
- LowPower = "low_power",
46
- Critical = "critical"
47
- }
48
- export declare enum AgentTrustLevel {
49
- Unknown = "unknown",
50
- FirstContact = "first_contact",
51
- Verified = "verified",
52
- Trusted = "trusted",
53
- Blocked = "blocked"
54
- }
55
- export declare enum MotebitType {
56
- Personal = "personal",
57
- Service = "service",
58
- Collaborative = "collaborative"
59
- }
60
- export declare enum ProposalStatus {
61
- Pending = "pending",
62
- Accepted = "accepted",
63
- Countered = "countered",
64
- Rejected = "rejected",
65
- Withdrawn = "withdrawn",
66
- Expired = "expired"
67
- }
68
- export declare enum ProposalResponseType {
69
- Accept = "accept",
70
- Reject = "reject",
71
- Counter = "counter"
72
- }
73
- export interface AgentTrustRecord {
74
- motebit_id: MotebitId;
75
- remote_motebit_id: MotebitId;
76
- trust_level: AgentTrustLevel;
77
- public_key?: string;
78
- first_seen_at: number;
79
- last_seen_at: number;
80
- interaction_count: number;
81
- successful_tasks?: number;
82
- failed_tasks?: number;
83
- notes?: string;
84
- /** Exponential moving average of result quality [0, 1]. */
85
- avg_quality?: number;
86
- /** Number of quality samples collected. */
87
- quality_sample_count?: number;
88
- }
89
- /** Canonical AgentTrustLevel → [0,1] mapping (single source of truth). */
90
- export declare const TRUST_LEVEL_SCORES: Record<string, number>;
91
- /** Convert a trust level to its numeric score. */
92
- export declare function trustLevelToScore(level: AgentTrustLevel | string): number;
93
- /** Semiring zero — annihilator for ⊗, identity for ⊕. */
94
- export declare const TRUST_ZERO = 0;
95
- /** Semiring one — identity for ⊗. */
96
- export declare const TRUST_ONE = 1;
97
- /** ⊕: parallel paths — pick the best route. */
98
- export declare function trustAdd(a: number, b: number): number;
99
- /** ⊗: serial chain — discount per hop. */
100
- export declare function trustMultiply(a: number, b: number): number;
101
- /** Fold a chain of trust scores with ⊗. Empty chain → 1.0 (identity). */
102
- export declare function composeTrustChain(scores: number[]): number;
103
- /** Fold parallel route scores with ⊕. No routes → 0.0 (identity). */
104
- export declare function joinParallelRoutes(scores: number[]): number;
105
- /** Thresholds for automatic trust level promotion/demotion. */
106
- export interface TrustTransitionThresholds {
107
- /** Min successful tasks for FirstContact → Verified (default 5) */
108
- promoteToVerified_minTasks: number;
109
- /** Min success rate for FirstContact → Verified (default 0.8) */
110
- promoteToVerified_minRate: number;
111
- /** Min successful tasks for Verified → Trusted (default 20) */
112
- promoteToTrusted_minTasks: number;
113
- /** Min success rate for Verified → Trusted (default 0.9) */
114
- promoteToTrusted_minRate: number;
115
- /** Success rate below this triggers demotion (default 0.5) */
116
- demote_belowRate: number;
117
- /** Min total tasks before demotion can trigger (default 3) */
118
- demote_minTasks: number;
119
- }
120
- export declare const DEFAULT_TRUST_THRESHOLDS: TrustTransitionThresholds;
121
- /**
122
- * Pure: evaluate whether a trust record should transition levels.
123
- *
124
- * Promotion: sustained evidence of success (asymmetric — harder to earn).
125
- * Demotion: success rate dropping below threshold (faster — protect the network).
126
- * Blocked is never auto-assigned or auto-removed (security decision).
127
- *
128
- * Returns the new level, or null if no transition.
129
- */
130
- export declare function evaluateTrustTransition(record: AgentTrustRecord, thresholds?: Partial<TrustTransitionThresholds>): AgentTrustLevel | null;
131
- /** Structural type for recursive delegation receipt walking. */
132
- export interface DelegationReceiptLike {
133
- motebit_id: string;
134
- delegation_receipts?: DelegationReceiptLike[];
135
- }
136
- /**
137
- * Compose trust through a delegation receipt tree.
138
- *
139
- * Walks `receipt.delegation_receipts` recursively:
140
- * - Each sub-delegation: directTrust ⊗ getTrust(sub.motebit_id)
141
- * - Parallel branches joined with ⊕ (best route wins)
142
- * - No sub-delegations → returns directTrust unchanged.
143
- */
144
- export declare function composeDelegationTrust(directTrust: number, receipt: DelegationReceiptLike, getTrust: (motebitId: string) => number): number;
145
- export declare enum SensitivityLevel {
146
- None = "none",
147
- Personal = "personal",
148
- Medical = "medical",
149
- Financial = "financial",
150
- Secret = "secret"
151
- }
152
- export declare enum EventType {
153
- IdentityCreated = "identity_created",
154
- StateUpdated = "state_updated",
155
- MemoryFormed = "memory_formed",
156
- MemoryDecayed = "memory_decayed",
157
- MemoryDeleted = "memory_deleted",
158
- MemoryAccessed = "memory_accessed",
159
- ProviderSwapped = "provider_swapped",
160
- ExportRequested = "export_requested",
161
- DeleteRequested = "delete_requested",
162
- SyncCompleted = "sync_completed",
163
- AuditEntry = "audit_entry",
164
- ToolUsed = "tool_used",
165
- PolicyViolation = "policy_violation",
166
- GoalCreated = "goal_created",
167
- GoalExecuted = "goal_executed",
168
- GoalRemoved = "goal_removed",
169
- ApprovalRequested = "approval_requested",
170
- ApprovalApproved = "approval_approved",
171
- ApprovalDenied = "approval_denied",
172
- ApprovalExpired = "approval_expired",
173
- GoalCompleted = "goal_completed",
174
- GoalProgress = "goal_progress",
175
- MemoryAudit = "memory_audit",
176
- MemoryPinned = "memory_pinned",
177
- PlanCreated = "plan_created",
178
- PlanStepStarted = "plan_step_started",
179
- PlanStepCompleted = "plan_step_completed",
180
- PlanStepFailed = "plan_step_failed",
181
- PlanCompleted = "plan_completed",
182
- PlanStepDelegated = "plan_step_delegated",
183
- CredentialRevoked = "credential_revoked",
184
- IdentityRevoked = "identity_revoked",
185
- PlanFailed = "plan_failed",
186
- HousekeepingRun = "housekeeping_run",
187
- ReflectionCompleted = "reflection_completed",
188
- MemoryConsolidated = "memory_consolidated",
189
- AgentTaskCompleted = "agent_task_completed",
190
- AgentTaskFailed = "agent_task_failed",
191
- AgentTaskDenied = "agent_task_denied",
192
- ProposalCreated = "proposal_created",
193
- ProposalAccepted = "proposal_accepted",
194
- ProposalRejected = "proposal_rejected",
195
- ProposalCountered = "proposal_countered",
196
- CollaborativeStepCompleted = "collaborative_step_completed",
197
- ChainTrustComputed = "chain_trust_computed",
198
- TrustLevelChanged = "trust_level_changed",
199
- KeyRotated = "key_rotated"
200
- }
1
+ export * from "@motebit/protocol";
2
+ export * from "./models.js";
3
+ export * from "./provider-mode.js";
4
+ export * from "./provider-resolver.js";
5
+ export * from "./color-presets.js";
6
+ export * from "./approval-presets.js";
7
+ export * from "./risk-labels.js";
8
+ export * from "./surface-options.js";
9
+ export * from "./governance-config.js";
10
+ export * from "./voice-config.js";
11
+ export * from "./appearance-config.js";
12
+ import type { SensitivityLevel, NodeId, MotebitId, TrustMode, BatteryMode, EventLogEntry, MemoryContent, MemoryCandidate, ToolDefinition, AgentTrustRecord, EventStoreAdapter, IdentityStorage, AuditLogAdapter, StateSnapshotAdapter, AuditLogSink, ConversationStoreAdapter, PlanStoreAdapter, AgentTrustStoreAdapter, ServiceListingStoreAdapter, BudgetAllocationStoreAdapter, SettlementStoreAdapter, LatencyStatsStoreAdapter, CredentialStoreAdapter, ApprovalStoreAdapter, MotebitIdentity, AuditRecord } from "@motebit/protocol";
201
13
  export declare enum RelationType {
202
14
  Related = "related",
203
15
  CausedBy = "caused_by",
@@ -207,16 +19,6 @@ export declare enum RelationType {
207
19
  PartOf = "part_of",
208
20
  Supersedes = "supersedes"
209
21
  }
210
- export declare enum MemoryType {
211
- Episodic = "episodic",
212
- Semantic = "semantic"
213
- }
214
- export interface MotebitIdentity {
215
- readonly motebit_id: MotebitId;
216
- readonly created_at: number;
217
- readonly owner_id: string;
218
- version_clock: number;
219
- }
220
22
  export interface MotebitState {
221
23
  attention: number;
222
24
  processing: number;
@@ -243,15 +45,6 @@ export declare const SPECIES_CONSTRAINTS: Readonly<{
243
45
  readonly DRIFT_VARIATION_MAX: 0.1;
244
46
  }>;
245
47
  export type SpeciesConstraints = typeof SPECIES_CONSTRAINTS;
246
- /** Cognition-facing memory content — what the agent's mind sees. */
247
- export interface MemoryContent {
248
- content: string;
249
- confidence: number;
250
- sensitivity: SensitivityLevel;
251
- memory_type?: MemoryType;
252
- valid_from?: number;
253
- valid_until?: number | null;
254
- }
255
48
  /** Full memory node including persistence metadata. */
256
49
  export interface MemoryNode extends MemoryContent {
257
50
  node_id: NodeId;
@@ -271,135 +64,51 @@ export interface MemoryEdge {
271
64
  weight: number;
272
65
  confidence: number;
273
66
  }
274
- export interface MemoryCandidate {
275
- content: string;
276
- confidence: number;
277
- sensitivity: SensitivityLevel;
278
- memory_type?: MemoryType;
279
- }
280
- export interface EventLogEntry {
281
- event_id: EventId;
282
- motebit_id: MotebitId;
283
- /** Device that originated this event (for multi-device conflict resolution) */
284
- device_id?: DeviceId;
285
- timestamp: number;
286
- event_type: EventType;
287
- payload: Record<string, unknown>;
288
- version_clock: number;
289
- tombstoned: boolean;
290
- }
291
- export declare enum RiskLevel {
292
- R0_READ = 0,
293
- R1_DRAFT = 1,
294
- R2_WRITE = 2,
295
- R3_EXECUTE = 3,
296
- R4_MONEY = 4
297
- }
298
- export declare enum DataClass {
299
- PUBLIC = "public",
300
- PRIVATE = "private",
301
- SECRET = "secret"
302
- }
303
- export declare enum SideEffect {
304
- NONE = "none",
305
- REVERSIBLE = "reversible",
306
- IRREVERSIBLE = "irreversible"
307
- }
308
- export interface ToolRiskProfile {
309
- risk: RiskLevel;
310
- dataClass: DataClass;
311
- sideEffect: SideEffect;
312
- requiresApproval: boolean;
313
- }
314
- /** M-of-N approval quorum configuration. */
315
- export interface ApprovalQuorum {
316
- /** Number of approvals required (M). */
317
- threshold: number;
318
- /** Authorized approver identifiers. */
319
- approvers: string[];
320
- /** Minimum risk level that triggers quorum (optional — default: all approval-required tools). */
321
- risk_floor?: string;
322
- }
323
- export interface PolicyDecision {
324
- allowed: boolean;
325
- requiresApproval: boolean;
326
- reason?: string;
327
- budgetRemaining?: {
328
- calls: number;
329
- timeMs: number;
330
- cost: number;
331
- };
332
- /** When quorum is required, contains the quorum metadata. */
333
- quorum?: {
334
- required: number;
335
- approvers: string[];
336
- collected: string[];
337
- };
338
- }
339
- export interface TurnContext {
340
- turnId: string;
341
- runId?: string;
342
- toolCallCount: number;
343
- turnStartMs: number;
344
- costAccumulated: number;
345
- /** Caller motebit ID — set in MCP server mode when caller presents a signed token. */
346
- callerMotebitId?: string;
347
- /** Caller trust level — set in MCP server mode for identity-aware policy decisions. */
348
- callerTrustLevel?: AgentTrustLevel;
349
- /** Type of the remote motebit making the call (personal/service/collaborative). */
350
- remoteMotebitType?: string;
351
- /** Delegation scope — when set, only tools within this scope are allowed. */
352
- delegationScope?: string;
67
+ export interface MemoryQuery {
68
+ motebit_id: string;
69
+ min_confidence?: number;
70
+ sensitivity_filter?: SensitivityLevel[];
71
+ limit?: number;
72
+ include_tombstoned?: boolean;
73
+ pinned?: boolean;
353
74
  }
354
- export interface InjectionWarning {
355
- detected: boolean;
356
- patterns: string[];
357
- directiveDensity?: number;
358
- structuralFlags?: string[];
75
+ export interface MemoryStorageAdapter {
76
+ saveNode(node: MemoryNode): Promise<void>;
77
+ getNode(nodeId: string): Promise<MemoryNode | null>;
78
+ queryNodes(query: MemoryQuery): Promise<MemoryNode[]>;
79
+ saveEdge(edge: MemoryEdge): Promise<void>;
80
+ getEdges(nodeId: string): Promise<MemoryEdge[]>;
81
+ tombstoneNode(nodeId: string): Promise<void>;
82
+ /** Tombstone with ownership check. Returns true if the node existed and belonged to motebitId. */
83
+ tombstoneNodeOwned?(nodeId: string, motebitId: string): Promise<boolean>;
84
+ pinNode(nodeId: string, pinned: boolean): Promise<void>;
85
+ getAllNodes(motebitId: string): Promise<MemoryNode[]>;
86
+ getAllEdges(motebitId: string): Promise<MemoryEdge[]>;
359
87
  }
360
- export interface ToolAuditEntry {
361
- turnId: string;
362
- runId?: string;
363
- callId: string;
364
- tool: string;
365
- args: Record<string, unknown>;
366
- decision: PolicyDecision;
367
- result?: {
368
- ok: boolean;
369
- durationMs: number;
370
- };
371
- injection?: InjectionWarning;
372
- costUnits?: number;
373
- timestamp: number;
88
+ export interface RenderSpec {
89
+ geometry: GeometrySpec;
90
+ material: MaterialSpec;
91
+ lighting: LightingSpec;
374
92
  }
375
- export interface ToolDefinition {
376
- name: string;
377
- description: string;
378
- inputSchema: Record<string, unknown>;
379
- requiresApproval?: boolean;
380
- /** Risk hint for PolicyGate classification. If absent, inferred from name/description. */
381
- riskHint?: {
382
- risk?: RiskLevel;
383
- dataClass?: DataClass;
384
- sideEffect?: SideEffect;
385
- };
93
+ export interface GeometrySpec {
94
+ form: "droplet";
95
+ base_radius: number;
96
+ height: number;
386
97
  }
387
- export interface ToolResult {
388
- ok: boolean;
389
- data?: unknown;
390
- error?: string;
391
- /** Set by adapters that already applied boundary wrapping (e.g. MCP client). */
392
- _sanitized?: boolean;
98
+ export interface MaterialSpec {
99
+ ior: number;
100
+ subsurface: number;
101
+ roughness: number;
102
+ clearcoat: number;
103
+ surface_noise_amplitude: number;
104
+ base_color: [number, number, number];
105
+ emissive_intensity: number;
106
+ tint: [number, number, number];
393
107
  }
394
- export type ToolHandler = (args: Record<string, unknown>) => Promise<ToolResult>;
395
- export interface ToolRegistry {
396
- list(): ToolDefinition[];
397
- execute(name: string, args: Record<string, unknown>): Promise<ToolResult>;
398
- register(tool: ToolDefinition, handler: ToolHandler): void;
399
- /** Replace the handler for an existing tool, or register if new. */
400
- replace?(tool: ToolDefinition, handler: ToolHandler): void;
401
- /** Remove a tool from the registry. Returns true if it existed. */
402
- unregister?(name: string): boolean;
108
+ export interface LightingSpec {
109
+ environment: "hdri";
110
+ exposure: number;
111
+ ambient_intensity: number;
403
112
  }
404
113
  export interface ContextPack {
405
114
  recent_events: EventLogEntry[];
@@ -464,15 +173,6 @@ export interface IntelligenceProvider {
464
173
  estimateConfidence(): Promise<number>;
465
174
  extractMemoryCandidates(response: AIResponse): Promise<MemoryCandidate[]>;
466
175
  }
467
- export interface AuditRecord {
468
- audit_id: string;
469
- motebit_id: MotebitId;
470
- timestamp: number;
471
- action: string;
472
- target_type: string;
473
- target_id: string;
474
- details: Record<string, unknown>;
475
- }
476
176
  export interface ExportManifest {
477
177
  motebit_id: MotebitId;
478
178
  exported_at: number;
@@ -482,459 +182,6 @@ export interface ExportManifest {
482
182
  events: EventLogEntry[];
483
183
  audit_log: AuditRecord[];
484
184
  }
485
- export interface SyncCursor {
486
- motebit_id: MotebitId;
487
- last_event_id: EventId;
488
- last_version_clock: number;
489
- }
490
- export interface ConflictEdge {
491
- local_event: EventLogEntry;
492
- remote_event: EventLogEntry;
493
- resolution: "local_wins" | "remote_wins" | "merged" | "unresolved";
494
- }
495
- /** Conversation metadata for sync. Matches persistence Conversation shape using snake_case for wire format. */
496
- export interface SyncConversation {
497
- conversation_id: ConversationId;
498
- motebit_id: MotebitId;
499
- started_at: number;
500
- last_active_at: number;
501
- title: string | null;
502
- summary: string | null;
503
- message_count: number;
504
- }
505
- /** Conversation message for sync. Matches persistence ConversationMessage shape using snake_case for wire format. */
506
- export interface SyncConversationMessage {
507
- message_id: string;
508
- conversation_id: ConversationId;
509
- motebit_id: MotebitId;
510
- role: string;
511
- content: string;
512
- tool_calls: string | null;
513
- tool_call_id: string | null;
514
- created_at: number;
515
- token_estimate: number;
516
- }
517
- /** Result of a conversation sync cycle. */
518
- export interface ConversationSyncResult {
519
- conversations_pushed: number;
520
- conversations_pulled: number;
521
- messages_pushed: number;
522
- messages_pulled: number;
523
- }
524
- export interface RenderSpec {
525
- geometry: GeometrySpec;
526
- material: MaterialSpec;
527
- lighting: LightingSpec;
528
- }
529
- export interface GeometrySpec {
530
- form: "droplet";
531
- base_radius: number;
532
- height: number;
533
- }
534
- export interface MaterialSpec {
535
- ior: number;
536
- subsurface: number;
537
- roughness: number;
538
- clearcoat: number;
539
- surface_noise_amplitude: number;
540
- base_color: [number, number, number];
541
- emissive_intensity: number;
542
- tint: [number, number, number];
543
- }
544
- export interface LightingSpec {
545
- environment: "hdri";
546
- exposure: number;
547
- ambient_intensity: number;
548
- }
549
- export declare enum PlanStatus {
550
- Active = "active",
551
- Completed = "completed",
552
- Failed = "failed",
553
- Paused = "paused"
554
- }
555
- export declare enum StepStatus {
556
- Pending = "pending",
557
- Running = "running",
558
- Completed = "completed",
559
- Failed = "failed",
560
- Skipped = "skipped"
561
- }
562
- export interface PlanStep {
563
- step_id: string;
564
- plan_id: PlanId;
565
- ordinal: number;
566
- description: string;
567
- prompt: string;
568
- depends_on: string[];
569
- optional: boolean;
570
- status: StepStatus;
571
- required_capabilities?: DeviceCapability[];
572
- /** Task ID assigned by the relay when this step was delegated to a remote device. */
573
- delegation_task_id?: string;
574
- /** Motebit ID of the agent assigned to execute this step in collaborative plans. */
575
- assigned_motebit_id?: MotebitId;
576
- result_summary: string | null;
577
- error_message: string | null;
578
- tool_calls_made: number;
579
- started_at: number | null;
580
- completed_at: number | null;
581
- retry_count: number;
582
- updated_at: number;
583
- }
584
- export interface Plan {
585
- plan_id: PlanId;
586
- goal_id: GoalId;
587
- motebit_id: MotebitId;
588
- title: string;
589
- status: PlanStatus;
590
- created_at: number;
591
- updated_at: number;
592
- current_step_index: number;
593
- total_steps: number;
594
- proposal_id?: ProposalId;
595
- collaborative?: boolean;
596
- }
597
- /** Plan record for cross-device sync. Mirrors Plan but uses wire-format field names. */
598
- export interface SyncPlan {
599
- plan_id: PlanId;
600
- goal_id: GoalId;
601
- motebit_id: MotebitId;
602
- title: string;
603
- status: PlanStatus;
604
- created_at: number;
605
- updated_at: number;
606
- current_step_index: number;
607
- total_steps: number;
608
- proposal_id: string | null;
609
- collaborative: number;
610
- }
611
- /** Plan step record for cross-device sync. */
612
- export interface SyncPlanStep {
613
- step_id: string;
614
- plan_id: PlanId;
615
- motebit_id: MotebitId;
616
- ordinal: number;
617
- description: string;
618
- prompt: string;
619
- depends_on: string;
620
- optional: boolean;
621
- status: StepStatus;
622
- required_capabilities: string | null;
623
- delegation_task_id: string | null;
624
- assigned_motebit_id: string | null;
625
- result_summary: string | null;
626
- error_message: string | null;
627
- tool_calls_made: number;
628
- started_at: number | null;
629
- completed_at: number | null;
630
- retry_count: number;
631
- updated_at: number;
632
- }
633
- /** Result of a plan sync cycle. */
634
- export interface PlanSyncResult {
635
- plans_pushed: number;
636
- plans_pulled: number;
637
- steps_pushed: number;
638
- steps_pulled: number;
639
- }
640
- export declare enum DeviceCapability {
641
- StdioMcp = "stdio_mcp",
642
- HttpMcp = "http_mcp",
643
- FileSystem = "file_system",
644
- Keyring = "keyring",
645
- Background = "background",
646
- LocalLlm = "local_llm"
647
- }
648
- export declare enum AgentTaskStatus {
649
- Pending = "pending",
650
- Claimed = "claimed",
651
- Running = "running",
652
- Completed = "completed",
653
- Failed = "failed",
654
- Denied = "denied",
655
- Expired = "expired"
656
- }
657
- export interface AgentTask {
658
- task_id: string;
659
- motebit_id: MotebitId;
660
- prompt: string;
661
- submitted_at: number;
662
- submitted_by?: string;
663
- wall_clock_ms?: number;
664
- status: AgentTaskStatus;
665
- claimed_by?: string;
666
- required_capabilities?: DeviceCapability[];
667
- step_id?: string;
668
- /** Delegation scope — when set, restricts which tools the task can use. */
669
- delegated_scope?: string;
670
- }
671
- export interface ExecutionReceipt {
672
- task_id: string;
673
- motebit_id: MotebitId;
674
- /** Signer's Ed25519 public key (hex). Enables verification without relay lookup. */
675
- public_key?: string;
676
- device_id: DeviceId;
677
- submitted_at: number;
678
- completed_at: number;
679
- status: "completed" | "failed" | "denied";
680
- result: string;
681
- tools_used: string[];
682
- memories_formed: number;
683
- prompt_hash: string;
684
- result_hash: string;
685
- delegation_receipts?: ExecutionReceipt[];
686
- /**
687
- * Cryptographic binding to the relay's economic identity for this task.
688
- *
689
- * Optional for local (non-relay) execution. **Required** for relay-mediated
690
- * tasks — the relay rejects receipts without this field (HTTP 400). The value
691
- * is included in the Ed25519 signature, so tampering breaks verification.
692
- */
693
- relay_task_id?: string;
694
- /** Scope from the delegation token that authorized this execution, if any. */
695
- delegated_scope?: string;
696
- signature: string;
697
- }
698
- export interface DelegatedStepResult {
699
- step_id: string;
700
- task_id: string;
701
- receipt: ExecutionReceipt;
702
- result_text: string;
703
- /** Routing provenance from the relay — why this agent was selected. */
704
- routing_choice?: {
705
- selected_agent: string;
706
- composite_score: number;
707
- sub_scores: Record<string, number>;
708
- routing_paths: string[][];
709
- alternatives_considered: number;
710
- };
711
- }
712
- /**
713
- * A key succession record proving that one Ed25519 key has been replaced by another.
714
- * Both the old and new keys sign the record, creating a cryptographic chain of custody.
715
- * Structurally compatible with @motebit/crypto KeySuccessionRecord.
716
- */
717
- export interface KeySuccessionRecord {
718
- old_public_key: string;
719
- new_public_key: string;
720
- timestamp: number;
721
- reason?: string;
722
- old_key_signature: string;
723
- new_key_signature: string;
724
- }
725
- /** Result of verifying a key succession chain. */
726
- export interface SuccessionChainResult {
727
- valid: boolean;
728
- /** The original (genesis) public key. */
729
- genesis_public_key: string;
730
- /** The current (active) public key. */
731
- current_public_key: string;
732
- /** Number of key rotations. */
733
- length: number;
734
- /** If invalid, the index of the first broken link and error. */
735
- error?: {
736
- index: number;
737
- message: string;
738
- };
739
- }
740
- export type ExecutionTimelineType = "goal_started" | "plan_created" | "step_started" | "tool_invoked" | "tool_result" | "step_completed" | "step_failed" | "step_delegated" | "plan_completed" | "plan_failed" | "goal_completed" | "proposal_created" | "proposal_accepted" | "proposal_rejected" | "proposal_countered" | "collaborative_step_completed";
741
- export interface ExecutionTimelineEntry {
742
- timestamp: number;
743
- type: ExecutionTimelineType;
744
- payload: Record<string, unknown>;
745
- }
746
- export interface ExecutionStepSummary {
747
- step_id: string;
748
- ordinal: number;
749
- description: string;
750
- status: string;
751
- tools_used: string[];
752
- tool_calls: number;
753
- started_at: number | null;
754
- completed_at: number | null;
755
- delegation?: {
756
- task_id: string;
757
- receipt_hash?: string;
758
- /** Routing provenance: why this agent was selected for delegation. */
759
- routing_choice?: {
760
- selected_agent: string;
761
- composite_score: number;
762
- sub_scores: {
763
- trust: number;
764
- success_rate: number;
765
- latency: number;
766
- price_efficiency: number;
767
- capability_match: number;
768
- availability: number;
769
- };
770
- /** Derivation paths through the agent graph. */
771
- routing_paths: string[][];
772
- /** Number of candidate agents that were scored. */
773
- alternatives_considered: number;
774
- };
775
- };
776
- }
777
- export interface GoalExecutionManifest {
778
- spec: "motebit/execution-ledger@1.0";
779
- motebit_id: string;
780
- goal_id: string;
781
- plan_id: string;
782
- started_at: number;
783
- completed_at: number;
784
- status: "completed" | "failed" | "paused" | "active";
785
- timeline: ExecutionTimelineEntry[];
786
- steps: ExecutionStepSummary[];
787
- delegation_receipts: DelegationReceiptSummary[];
788
- content_hash: string;
789
- signature?: string;
790
- }
791
- export interface DelegationReceiptSummary {
792
- task_id: string;
793
- motebit_id: string;
794
- device_id: string;
795
- status: string;
796
- completed_at: number;
797
- tools_used: string[];
798
- signature_prefix: string;
799
- }
800
- export interface AgentCapabilities {
801
- motebit_id: MotebitId;
802
- public_key: string;
803
- /** W3C did:key URI derived from the Ed25519 public key. */
804
- did?: string;
805
- tools: string[];
806
- governance: {
807
- trust_mode: string;
808
- max_risk_auto: number;
809
- require_approval_above: number;
810
- deny_above: number;
811
- };
812
- online_devices: number;
813
- }
814
- export interface CapabilityPrice {
815
- capability: string;
816
- unit_cost: number;
817
- currency: string;
818
- per: "task" | "tool_call" | "token";
819
- }
820
- export interface AgentServiceListing {
821
- listing_id: ListingId;
822
- motebit_id: MotebitId;
823
- capabilities: string[];
824
- pricing: CapabilityPrice[];
825
- sla: {
826
- max_latency_ms: number;
827
- availability_guarantee: number;
828
- };
829
- description: string;
830
- /** Wallet address for x402 on-chain payment settlement (e.g. "0x..." for EVM). */
831
- pay_to_address?: string;
832
- /**
833
- * Self-declared regulatory risk score [0, ∞). 0 = no risk, higher = more risk.
834
- * Accumulates along delegation chains via RegulatoryRiskSemiring (min, +).
835
- * Sources: jurisdiction, data handling classification, compliance certifications,
836
- * audit requirements. The score is declared by the agent; verification is via
837
- * credentials (e.g. compliance attestation VCs).
838
- */
839
- regulatory_risk?: number;
840
- updated_at: number;
841
- }
842
- export interface RouteScore {
843
- motebit_id: MotebitId;
844
- composite: number;
845
- sub_scores: {
846
- trust: number;
847
- success_rate: number;
848
- latency: number;
849
- price_efficiency: number;
850
- capability_match: number;
851
- availability: number;
852
- };
853
- selected: boolean;
854
- }
855
- export interface BudgetAllocation {
856
- allocation_id: AllocationId;
857
- goal_id: GoalId;
858
- candidate_motebit_id: MotebitId;
859
- amount_locked: number;
860
- currency: string;
861
- created_at: number;
862
- status: "locked" | "settled" | "released" | "disputed";
863
- }
864
- /**
865
- * The relay's settlement fee rate (5%).
866
- * Applied to every completed or partial settlement that flows through the relay.
867
- * This is the Stripe model: the relay proves the work happened, takes its cut.
868
- */
869
- export declare const PLATFORM_FEE_RATE = 0.05;
870
- export interface SettlementRecord {
871
- settlement_id: SettlementId;
872
- allocation_id: AllocationId;
873
- receipt_hash: string;
874
- ledger_hash: string | null;
875
- /** Amount paid to the executing agent (after platform fee deduction). */
876
- amount_settled: number;
877
- /** Platform fee extracted by the relay. */
878
- platform_fee: number;
879
- /** Fee rate applied (e.g. 0.05 = 5%). Recorded per-settlement for auditability. */
880
- platform_fee_rate: number;
881
- /** x402 payment transaction hash (when paid on-chain). */
882
- x402_tx_hash?: string;
883
- /** x402 network used for payment (CAIP-2 identifier). */
884
- x402_network?: string;
885
- status: "completed" | "partial" | "refunded";
886
- settled_at: number;
887
- }
888
- export interface CollaborativePlanProposal {
889
- proposal_id: ProposalId;
890
- plan_id: PlanId;
891
- initiator_motebit_id: MotebitId;
892
- participants: ProposalParticipant[];
893
- status: ProposalStatus;
894
- created_at: number;
895
- expires_at: number;
896
- updated_at: number;
897
- }
898
- export interface ProposalParticipant {
899
- motebit_id: MotebitId;
900
- assigned_steps: number[];
901
- response: ProposalResponseType | null;
902
- responded_at: number | null;
903
- counter_steps?: ProposalStepCounter[];
904
- }
905
- export interface ProposalStepCounter {
906
- ordinal: number;
907
- description?: string;
908
- prompt?: string;
909
- reason: string;
910
- }
911
- export interface ProposalResponse {
912
- proposal_id: ProposalId;
913
- responder_motebit_id: MotebitId;
914
- response: ProposalResponseType;
915
- counter_steps?: ProposalStepCounter[];
916
- signature: string;
917
- }
918
- export interface CollaborativeReceipt {
919
- proposal_id: ProposalId;
920
- plan_id: PlanId;
921
- participant_receipts: ExecutionReceipt[];
922
- content_hash: string;
923
- initiator_signature: string;
924
- }
925
- export interface MarketConfig {
926
- weight_trust: number;
927
- weight_success_rate: number;
928
- weight_latency: number;
929
- weight_price_efficiency: number;
930
- weight_capability_match: number;
931
- weight_availability: number;
932
- latency_norm_k: number;
933
- max_candidates: number;
934
- settlement_timeout_ms: number;
935
- /** Exploration weight [0-1]: 0 = pure exploitation, 1 = pure exploration. Default 0. */
936
- exploration_weight?: number;
937
- }
938
185
  /**
939
186
  * Precision weights derived from the intelligence gradient.
940
187
  *
@@ -946,41 +193,6 @@ export interface MarketConfig {
946
193
  * High gradient → high self-trust → exploit known-good routes, trust memory.
947
194
  * Low gradient → low self-trust → explore, diversify, question memory.
948
195
  */
949
- export declare const VC_TYPE_GRADIENT = "AgentGradientCredential";
950
- export declare const VC_TYPE_REPUTATION = "AgentReputationCredential";
951
- export declare const VC_TYPE_TRUST = "AgentTrustCredential";
952
- export interface GradientCredentialSubject {
953
- id: string;
954
- gradient: number;
955
- knowledge_density: number;
956
- knowledge_quality: number;
957
- graph_connectivity: number;
958
- temporal_stability: number;
959
- retrieval_quality: number;
960
- interaction_efficiency: number;
961
- tool_efficiency: number;
962
- curiosity_pressure: number;
963
- measured_at: number;
964
- }
965
- export interface ReputationCredentialSubject {
966
- id: string;
967
- success_rate: number;
968
- avg_latency_ms: number;
969
- task_count: number;
970
- trust_score: number;
971
- availability: number;
972
- sample_size: number;
973
- measured_at: number;
974
- }
975
- export interface TrustCredentialSubject {
976
- id: string;
977
- trust_level: string;
978
- interaction_count: number;
979
- successful_tasks: number;
980
- failed_tasks: number;
981
- first_seen_at: number;
982
- last_seen_at: number;
983
- }
984
196
  export interface PrecisionWeights {
985
197
  /** Overall self-trust [0-1]. Sigmoid of composite gradient. */
986
198
  selfTrust: number;
@@ -991,84 +203,6 @@ export interface PrecisionWeights {
991
203
  /** Curiosity modulation [0-1]. Fed back into state vector curiosity field. */
992
204
  curiosityModulation: number;
993
205
  }
994
- export interface ConversationStoreAdapter {
995
- createConversation(motebitId: string): string;
996
- appendMessage(conversationId: string, motebitId: string, msg: {
997
- role: string;
998
- content: string;
999
- toolCalls?: string;
1000
- toolCallId?: string;
1001
- }): void;
1002
- loadMessages(conversationId: string, limit?: number): Array<{
1003
- messageId: string;
1004
- conversationId: string;
1005
- motebitId: string;
1006
- role: string;
1007
- content: string;
1008
- toolCalls: string | null;
1009
- toolCallId: string | null;
1010
- createdAt: number;
1011
- tokenEstimate: number;
1012
- }>;
1013
- getActiveConversation(motebitId: string): {
1014
- conversationId: string;
1015
- startedAt: number;
1016
- lastActiveAt: number;
1017
- summary: string | null;
1018
- } | null;
1019
- updateSummary(conversationId: string, summary: string): void;
1020
- updateTitle(conversationId: string, title: string): void;
1021
- listConversations(motebitId: string, limit?: number): Array<{
1022
- conversationId: string;
1023
- startedAt: number;
1024
- lastActiveAt: number;
1025
- title: string | null;
1026
- messageCount: number;
1027
- }>;
1028
- deleteConversation(conversationId: string): void;
1029
- }
1030
- export interface StateSnapshotAdapter {
1031
- saveState(motebitId: string, stateJson: string, versionClock?: number): void;
1032
- loadState(motebitId: string): string | null;
1033
- /** Version clock at last snapshot — used to determine what's safe to compact. */
1034
- getSnapshotClock?(motebitId: string): number;
1035
- }
1036
- export interface KeyringAdapter {
1037
- get(key: string): Promise<string | null>;
1038
- set(key: string, value: string): Promise<void>;
1039
- delete(key: string): Promise<void>;
1040
- }
1041
- export interface AgentTrustStoreAdapter {
1042
- getAgentTrust(motebitId: string, remoteMotebitId: string): Promise<AgentTrustRecord | null>;
1043
- setAgentTrust(record: AgentTrustRecord): Promise<void>;
1044
- listAgentTrust(motebitId: string): Promise<AgentTrustRecord[]>;
1045
- updateTrustLevel(motebitId: string, remoteMotebitId: string, level: AgentTrustLevel): Promise<void>;
1046
- }
1047
- export interface ServiceListingStoreAdapter {
1048
- get(motebitId: string): Promise<AgentServiceListing | null>;
1049
- set(listing: AgentServiceListing): Promise<void>;
1050
- list(): Promise<AgentServiceListing[]>;
1051
- delete(listingId: string): Promise<void>;
1052
- }
1053
- export interface BudgetAllocationStoreAdapter {
1054
- get(allocationId: string): Promise<BudgetAllocation | null>;
1055
- create(allocation: BudgetAllocation): Promise<void>;
1056
- updateStatus(allocationId: string, status: string): Promise<void>;
1057
- listByGoal(goalId: string): Promise<BudgetAllocation[]>;
1058
- }
1059
- export interface SettlementStoreAdapter {
1060
- get(settlementId: string): Promise<SettlementRecord | null>;
1061
- create(settlement: SettlementRecord): Promise<void>;
1062
- listByAllocation(allocationId: string): Promise<SettlementRecord[]>;
1063
- }
1064
- export interface LatencyStatsStoreAdapter {
1065
- record(motebitId: string, remoteMotebitId: string, latencyMs: number): Promise<void>;
1066
- getStats(motebitId: string, remoteMotebitId: string, limit?: number): Promise<{
1067
- avg_ms: number;
1068
- p95_ms: number;
1069
- sample_count: number;
1070
- }>;
1071
- }
1072
206
  export interface GradientSnapshot {
1073
207
  motebit_id: string;
1074
208
  timestamp: number;
@@ -1113,132 +247,6 @@ export interface GradientStoreAdapter {
1113
247
  latest(motebitId: string): GradientSnapshot | null;
1114
248
  list(motebitId: string, limit?: number): GradientSnapshot[];
1115
249
  }
1116
- export interface EventFilter {
1117
- motebit_id?: string;
1118
- event_types?: EventType[];
1119
- after_timestamp?: number;
1120
- before_timestamp?: number;
1121
- after_version_clock?: number;
1122
- limit?: number;
1123
- }
1124
- export interface EventStoreAdapter {
1125
- append(entry: EventLogEntry): Promise<void>;
1126
- /**
1127
- * Atomically assign the next version_clock and append the event.
1128
- * Eliminates the race condition in the getLatestClock() + clock+1 pattern.
1129
- * Returns the assigned version_clock.
1130
- */
1131
- appendWithClock?(entry: Omit<EventLogEntry, "version_clock">): Promise<number>;
1132
- query(filter: EventFilter): Promise<EventLogEntry[]>;
1133
- getLatestClock(motebitId: string): Promise<number>;
1134
- tombstone(eventId: string, motebitId: string): Promise<void>;
1135
- /** Delete events with version_clock <= beforeClock. Returns count deleted. */
1136
- compact?(motebitId: string, beforeClock: number): Promise<number>;
1137
- /** Count total events for a motebit. */
1138
- countEvents?(motebitId: string): Promise<number>;
1139
- }
1140
- export interface MemoryQuery {
1141
- motebit_id: string;
1142
- min_confidence?: number;
1143
- sensitivity_filter?: SensitivityLevel[];
1144
- limit?: number;
1145
- include_tombstoned?: boolean;
1146
- pinned?: boolean;
1147
- }
1148
- export interface MemoryStorageAdapter {
1149
- saveNode(node: MemoryNode): Promise<void>;
1150
- getNode(nodeId: string): Promise<MemoryNode | null>;
1151
- queryNodes(query: MemoryQuery): Promise<MemoryNode[]>;
1152
- saveEdge(edge: MemoryEdge): Promise<void>;
1153
- getEdges(nodeId: string): Promise<MemoryEdge[]>;
1154
- tombstoneNode(nodeId: string): Promise<void>;
1155
- /** Tombstone with ownership check. Returns true if the node existed and belonged to motebitId. */
1156
- tombstoneNodeOwned?(nodeId: string, motebitId: string): Promise<boolean>;
1157
- pinNode(nodeId: string, pinned: boolean): Promise<void>;
1158
- getAllNodes(motebitId: string): Promise<MemoryNode[]>;
1159
- getAllEdges(motebitId: string): Promise<MemoryEdge[]>;
1160
- }
1161
- export interface DeviceRegistration {
1162
- device_id: string;
1163
- motebit_id: string;
1164
- device_token: string;
1165
- public_key: string;
1166
- registered_at: number;
1167
- device_name?: string;
1168
- }
1169
- export interface IdentityStorage {
1170
- save(identity: MotebitIdentity): Promise<void>;
1171
- load(motebitId: string): Promise<MotebitIdentity | null>;
1172
- loadByOwner(ownerId: string): Promise<MotebitIdentity | null>;
1173
- saveDevice?(device: DeviceRegistration): Promise<void>;
1174
- loadDevice?(deviceId: string): Promise<DeviceRegistration | null>;
1175
- loadDeviceByToken?(token: string): Promise<DeviceRegistration | null>;
1176
- listDevices?(motebitId: string): Promise<DeviceRegistration[]>;
1177
- }
1178
- export interface AuditLogAdapter {
1179
- record(entry: AuditRecord): Promise<void>;
1180
- query(motebitId: string, options?: {
1181
- limit?: number;
1182
- after?: number;
1183
- }): Promise<AuditRecord[]>;
1184
- }
1185
- export interface AuditStatsSince {
1186
- distinctTurns: number;
1187
- totalToolCalls: number;
1188
- succeeded: number;
1189
- blocked: number;
1190
- failed: number;
1191
- }
1192
- export interface AuditLogSink {
1193
- append(entry: ToolAuditEntry): void;
1194
- query(turnId: string): ToolAuditEntry[];
1195
- getAll(): ToolAuditEntry[];
1196
- queryStatsSince(afterTimestamp: number): AuditStatsSince;
1197
- /** Query tool audit entries by run_id (plan execution). Optional — returns [] if not implemented. */
1198
- queryByRunId?(runId: string): ToolAuditEntry[];
1199
- }
1200
- export interface PlanStoreAdapter {
1201
- savePlan(plan: Plan): void;
1202
- getPlan(planId: string): Plan | null;
1203
- getPlanForGoal(goalId: string): Plan | null;
1204
- updatePlan(planId: string, updates: Partial<Plan>): void;
1205
- saveStep(step: PlanStep): void;
1206
- getStep(stepId: string): PlanStep | null;
1207
- getStepsForPlan(planId: string): PlanStep[];
1208
- updateStep(stepId: string, updates: Partial<PlanStep>): void;
1209
- getNextPendingStep(planId: string): PlanStep | null;
1210
- /** List all active plans for a motebit. Optional — returns [] if not implemented. */
1211
- listActivePlans?(motebitId: string): Plan[];
1212
- }
1213
- /** Stored credential record — JSON-serialized VC with metadata. */
1214
- export interface StoredCredential {
1215
- credential_id: string;
1216
- /** The agent the credential is about (credentialSubject.id). */
1217
- subject_motebit_id: string;
1218
- /** did:key of the issuer. */
1219
- issuer_did: string;
1220
- /** e.g. "AgentReputationCredential", "AgentTrustCredential", "AgentGradientCredential". */
1221
- credential_type: string;
1222
- /** Full JSON-serialized VerifiableCredential. */
1223
- credential_json: string;
1224
- issued_at: number;
1225
- }
1226
- export interface CredentialStoreAdapter {
1227
- save(credential: StoredCredential): void;
1228
- /** List credentials about a specific subject agent. */
1229
- listBySubject(subjectMotebitId: string, limit?: number): StoredCredential[];
1230
- /** List all credentials, optionally filtered by type. */
1231
- list(motebitId: string, type?: string, limit?: number): StoredCredential[];
1232
- }
1233
- export interface ApprovalStoreAdapter {
1234
- /** Collect a quorum approval vote. Returns whether threshold is met and collected voter IDs. */
1235
- collectApproval(approvalId: string, approverId: string): {
1236
- met: boolean;
1237
- collected: string[];
1238
- };
1239
- /** Set quorum metadata on a pending approval item. */
1240
- setQuorum(approvalId: string, required: number, approvers: string[]): void;
1241
- }
1242
250
  export interface StorageAdapters {
1243
251
  eventStore: EventStoreAdapter;
1244
252
  memoryStorage: MemoryStorageAdapter;
@@ -1257,5 +265,49 @@ export interface StorageAdapters {
1257
265
  credentialStore?: CredentialStoreAdapter;
1258
266
  approvalStore?: ApprovalStoreAdapter;
1259
267
  }
1260
- export {};
268
+ /** Context passed to CredentialSource when requesting a credential. */
269
+ export interface CredentialRequest {
270
+ /** URL of the MCP server being called. */
271
+ serverUrl: string;
272
+ /** Tool name being invoked, if known at credential-acquisition time. */
273
+ toolName?: string;
274
+ /** Requested scope or audience for scoped credentials. */
275
+ scope?: string;
276
+ /** Motebit ID of the calling agent, if available. */
277
+ agentId?: string;
278
+ }
279
+ /**
280
+ * Adapter interface for obtaining credentials at tool-call time.
281
+ * Implementations may read from OS keyring, external vaults, or wrap static tokens.
282
+ */
283
+ export interface CredentialSource {
284
+ getCredential(request: CredentialRequest): Promise<string | null>;
285
+ }
286
+ /** Config fields that server verifiers can update via VerificationResult. */
287
+ export interface VerifierConfigUpdates {
288
+ toolManifestHash?: string;
289
+ pinnedToolNames?: string[];
290
+ trusted?: boolean;
291
+ tlsCertFingerprint?: string;
292
+ }
293
+ /** Result of server verification. */
294
+ export interface VerificationResult {
295
+ ok: boolean;
296
+ error?: string;
297
+ configUpdates?: VerifierConfigUpdates;
298
+ }
299
+ /**
300
+ * Adapter interface for verifying an MCP server's integrity after connect.
301
+ * Fail-closed: ok:false or thrown errors should tear down the connection.
302
+ */
303
+ export interface ServerVerifier {
304
+ verify(config: {
305
+ name: string;
306
+ url?: string;
307
+ toolManifestHash?: string;
308
+ pinnedToolNames?: string[];
309
+ trusted?: boolean;
310
+ tlsCertFingerprint?: string;
311
+ }, tools: ToolDefinition[]): Promise<VerificationResult>;
312
+ }
1261
313
  //# sourceMappingURL=index.d.ts.map