@motebit/protocol 0.7.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 +26 -0
- package/README.md +28 -0
- package/dist/index.d.ts +992 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +228 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,992 @@
|
|
|
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
|
+
/** Thresholds for automatic trust level promotion/demotion. */
|
|
90
|
+
export interface TrustTransitionThresholds {
|
|
91
|
+
/** Min successful tasks for FirstContact → Verified (default 5) */
|
|
92
|
+
promoteToVerified_minTasks: number;
|
|
93
|
+
/** Min success rate for FirstContact → Verified (default 0.8) */
|
|
94
|
+
promoteToVerified_minRate: number;
|
|
95
|
+
/** Min successful tasks for Verified → Trusted (default 20) */
|
|
96
|
+
promoteToTrusted_minTasks: number;
|
|
97
|
+
/** Min success rate for Verified → Trusted (default 0.9) */
|
|
98
|
+
promoteToTrusted_minRate: number;
|
|
99
|
+
/** Success rate below this triggers demotion (default 0.5) */
|
|
100
|
+
demote_belowRate: number;
|
|
101
|
+
/** Min total tasks before demotion can trigger (default 3) */
|
|
102
|
+
demote_minTasks: number;
|
|
103
|
+
}
|
|
104
|
+
/** Structural type for recursive delegation receipt walking. */
|
|
105
|
+
export interface DelegationReceiptLike {
|
|
106
|
+
motebit_id: string;
|
|
107
|
+
delegation_receipts?: DelegationReceiptLike[];
|
|
108
|
+
}
|
|
109
|
+
export declare enum SensitivityLevel {
|
|
110
|
+
None = "none",
|
|
111
|
+
Personal = "personal",
|
|
112
|
+
Medical = "medical",
|
|
113
|
+
Financial = "financial",
|
|
114
|
+
Secret = "secret"
|
|
115
|
+
}
|
|
116
|
+
export declare enum EventType {
|
|
117
|
+
IdentityCreated = "identity_created",
|
|
118
|
+
StateUpdated = "state_updated",
|
|
119
|
+
MemoryFormed = "memory_formed",
|
|
120
|
+
MemoryDecayed = "memory_decayed",
|
|
121
|
+
MemoryDeleted = "memory_deleted",
|
|
122
|
+
MemoryAccessed = "memory_accessed",
|
|
123
|
+
ProviderSwapped = "provider_swapped",
|
|
124
|
+
ExportRequested = "export_requested",
|
|
125
|
+
DeleteRequested = "delete_requested",
|
|
126
|
+
SyncCompleted = "sync_completed",
|
|
127
|
+
AuditEntry = "audit_entry",
|
|
128
|
+
ToolUsed = "tool_used",
|
|
129
|
+
PolicyViolation = "policy_violation",
|
|
130
|
+
GoalCreated = "goal_created",
|
|
131
|
+
GoalExecuted = "goal_executed",
|
|
132
|
+
GoalRemoved = "goal_removed",
|
|
133
|
+
ApprovalRequested = "approval_requested",
|
|
134
|
+
ApprovalApproved = "approval_approved",
|
|
135
|
+
ApprovalDenied = "approval_denied",
|
|
136
|
+
ApprovalExpired = "approval_expired",
|
|
137
|
+
GoalCompleted = "goal_completed",
|
|
138
|
+
GoalProgress = "goal_progress",
|
|
139
|
+
MemoryAudit = "memory_audit",
|
|
140
|
+
MemoryPinned = "memory_pinned",
|
|
141
|
+
PlanCreated = "plan_created",
|
|
142
|
+
PlanStepStarted = "plan_step_started",
|
|
143
|
+
PlanStepCompleted = "plan_step_completed",
|
|
144
|
+
PlanStepFailed = "plan_step_failed",
|
|
145
|
+
PlanCompleted = "plan_completed",
|
|
146
|
+
PlanStepDelegated = "plan_step_delegated",
|
|
147
|
+
CredentialRevoked = "credential_revoked",
|
|
148
|
+
IdentityRevoked = "identity_revoked",
|
|
149
|
+
PlanFailed = "plan_failed",
|
|
150
|
+
HousekeepingRun = "housekeeping_run",
|
|
151
|
+
ReflectionCompleted = "reflection_completed",
|
|
152
|
+
MemoryConsolidated = "memory_consolidated",
|
|
153
|
+
AgentTaskCompleted = "agent_task_completed",
|
|
154
|
+
AgentTaskFailed = "agent_task_failed",
|
|
155
|
+
AgentTaskDenied = "agent_task_denied",
|
|
156
|
+
ProposalCreated = "proposal_created",
|
|
157
|
+
ProposalAccepted = "proposal_accepted",
|
|
158
|
+
ProposalRejected = "proposal_rejected",
|
|
159
|
+
ProposalCountered = "proposal_countered",
|
|
160
|
+
CollaborativeStepCompleted = "collaborative_step_completed",
|
|
161
|
+
ChainTrustComputed = "chain_trust_computed",
|
|
162
|
+
TrustLevelChanged = "trust_level_changed",
|
|
163
|
+
KeyRotated = "key_rotated"
|
|
164
|
+
}
|
|
165
|
+
export declare enum MemoryType {
|
|
166
|
+
Episodic = "episodic",
|
|
167
|
+
Semantic = "semantic"
|
|
168
|
+
}
|
|
169
|
+
export interface MotebitIdentity {
|
|
170
|
+
readonly motebit_id: MotebitId;
|
|
171
|
+
readonly created_at: number;
|
|
172
|
+
readonly owner_id: string;
|
|
173
|
+
version_clock: number;
|
|
174
|
+
}
|
|
175
|
+
/** Cognition-facing memory content — what the agent's mind sees. */
|
|
176
|
+
export interface MemoryContent {
|
|
177
|
+
content: string;
|
|
178
|
+
confidence: number;
|
|
179
|
+
sensitivity: SensitivityLevel;
|
|
180
|
+
memory_type?: MemoryType;
|
|
181
|
+
valid_from?: number;
|
|
182
|
+
valid_until?: number | null;
|
|
183
|
+
}
|
|
184
|
+
export interface MemoryCandidate {
|
|
185
|
+
content: string;
|
|
186
|
+
confidence: number;
|
|
187
|
+
sensitivity: SensitivityLevel;
|
|
188
|
+
memory_type?: MemoryType;
|
|
189
|
+
}
|
|
190
|
+
export interface EventLogEntry {
|
|
191
|
+
event_id: EventId;
|
|
192
|
+
motebit_id: MotebitId;
|
|
193
|
+
/** Device that originated this event (for multi-device conflict resolution) */
|
|
194
|
+
device_id?: DeviceId;
|
|
195
|
+
timestamp: number;
|
|
196
|
+
event_type: EventType;
|
|
197
|
+
payload: Record<string, unknown>;
|
|
198
|
+
version_clock: number;
|
|
199
|
+
tombstoned: boolean;
|
|
200
|
+
}
|
|
201
|
+
export declare enum RiskLevel {
|
|
202
|
+
R0_READ = 0,
|
|
203
|
+
R1_DRAFT = 1,
|
|
204
|
+
R2_WRITE = 2,
|
|
205
|
+
R3_EXECUTE = 3,
|
|
206
|
+
R4_MONEY = 4
|
|
207
|
+
}
|
|
208
|
+
export declare enum DataClass {
|
|
209
|
+
PUBLIC = "public",
|
|
210
|
+
PRIVATE = "private",
|
|
211
|
+
SECRET = "secret"
|
|
212
|
+
}
|
|
213
|
+
export declare enum SideEffect {
|
|
214
|
+
NONE = "none",
|
|
215
|
+
REVERSIBLE = "reversible",
|
|
216
|
+
IRREVERSIBLE = "irreversible"
|
|
217
|
+
}
|
|
218
|
+
export interface ToolRiskProfile {
|
|
219
|
+
risk: RiskLevel;
|
|
220
|
+
dataClass: DataClass;
|
|
221
|
+
sideEffect: SideEffect;
|
|
222
|
+
requiresApproval: boolean;
|
|
223
|
+
}
|
|
224
|
+
/** M-of-N approval quorum configuration. */
|
|
225
|
+
export interface ApprovalQuorum {
|
|
226
|
+
/** Number of approvals required (M). */
|
|
227
|
+
threshold: number;
|
|
228
|
+
/** Authorized approver identifiers. */
|
|
229
|
+
approvers: string[];
|
|
230
|
+
/** Minimum risk level that triggers quorum (optional — default: all approval-required tools). */
|
|
231
|
+
risk_floor?: string;
|
|
232
|
+
}
|
|
233
|
+
export interface PolicyDecision {
|
|
234
|
+
allowed: boolean;
|
|
235
|
+
requiresApproval: boolean;
|
|
236
|
+
reason?: string;
|
|
237
|
+
budgetRemaining?: {
|
|
238
|
+
calls: number;
|
|
239
|
+
timeMs: number;
|
|
240
|
+
cost: number;
|
|
241
|
+
};
|
|
242
|
+
/** When quorum is required, contains the quorum metadata. */
|
|
243
|
+
quorum?: {
|
|
244
|
+
required: number;
|
|
245
|
+
approvers: string[];
|
|
246
|
+
collected: string[];
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
export interface TurnContext {
|
|
250
|
+
turnId: string;
|
|
251
|
+
runId?: string;
|
|
252
|
+
toolCallCount: number;
|
|
253
|
+
turnStartMs: number;
|
|
254
|
+
costAccumulated: number;
|
|
255
|
+
/** Caller motebit ID — set in MCP server mode when caller presents a signed token. */
|
|
256
|
+
callerMotebitId?: string;
|
|
257
|
+
/** Caller trust level — set in MCP server mode for identity-aware policy decisions. */
|
|
258
|
+
callerTrustLevel?: AgentTrustLevel;
|
|
259
|
+
/** Type of the remote motebit making the call (personal/service/collaborative). */
|
|
260
|
+
remoteMotebitType?: string;
|
|
261
|
+
/** Delegation scope — when set, only tools within this scope are allowed. */
|
|
262
|
+
delegationScope?: string;
|
|
263
|
+
}
|
|
264
|
+
export interface InjectionWarning {
|
|
265
|
+
detected: boolean;
|
|
266
|
+
patterns: string[];
|
|
267
|
+
directiveDensity?: number;
|
|
268
|
+
structuralFlags?: string[];
|
|
269
|
+
}
|
|
270
|
+
export interface ToolAuditEntry {
|
|
271
|
+
turnId: string;
|
|
272
|
+
runId?: string;
|
|
273
|
+
callId: string;
|
|
274
|
+
tool: string;
|
|
275
|
+
args: Record<string, unknown>;
|
|
276
|
+
decision: PolicyDecision;
|
|
277
|
+
result?: {
|
|
278
|
+
ok: boolean;
|
|
279
|
+
durationMs: number;
|
|
280
|
+
};
|
|
281
|
+
injection?: InjectionWarning;
|
|
282
|
+
costUnits?: number;
|
|
283
|
+
timestamp: number;
|
|
284
|
+
}
|
|
285
|
+
export interface ToolDefinition {
|
|
286
|
+
name: string;
|
|
287
|
+
description: string;
|
|
288
|
+
inputSchema: Record<string, unknown>;
|
|
289
|
+
requiresApproval?: boolean;
|
|
290
|
+
/** Risk hint for PolicyGate classification. If absent, inferred from name/description. */
|
|
291
|
+
riskHint?: {
|
|
292
|
+
risk?: RiskLevel;
|
|
293
|
+
dataClass?: DataClass;
|
|
294
|
+
sideEffect?: SideEffect;
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
export interface ToolResult {
|
|
298
|
+
ok: boolean;
|
|
299
|
+
data?: unknown;
|
|
300
|
+
error?: string;
|
|
301
|
+
/** Set by adapters that already applied boundary wrapping (e.g. MCP client). */
|
|
302
|
+
_sanitized?: boolean;
|
|
303
|
+
}
|
|
304
|
+
export type ToolHandler = (args: Record<string, unknown>) => Promise<ToolResult>;
|
|
305
|
+
export interface ToolRegistry {
|
|
306
|
+
list(): ToolDefinition[];
|
|
307
|
+
execute(name: string, args: Record<string, unknown>): Promise<ToolResult>;
|
|
308
|
+
register(tool: ToolDefinition, handler: ToolHandler): void;
|
|
309
|
+
/** Replace the handler for an existing tool, or register if new. */
|
|
310
|
+
replace?(tool: ToolDefinition, handler: ToolHandler): void;
|
|
311
|
+
/** Remove a tool from the registry. Returns true if it existed. */
|
|
312
|
+
unregister?(name: string): boolean;
|
|
313
|
+
}
|
|
314
|
+
export interface AuditRecord {
|
|
315
|
+
audit_id: string;
|
|
316
|
+
motebit_id: MotebitId;
|
|
317
|
+
timestamp: number;
|
|
318
|
+
action: string;
|
|
319
|
+
target_type: string;
|
|
320
|
+
target_id: string;
|
|
321
|
+
details: Record<string, unknown>;
|
|
322
|
+
}
|
|
323
|
+
export interface SyncCursor {
|
|
324
|
+
motebit_id: MotebitId;
|
|
325
|
+
last_event_id: EventId;
|
|
326
|
+
last_version_clock: number;
|
|
327
|
+
}
|
|
328
|
+
export interface ConflictEdge {
|
|
329
|
+
local_event: EventLogEntry;
|
|
330
|
+
remote_event: EventLogEntry;
|
|
331
|
+
resolution: "local_wins" | "remote_wins" | "merged" | "unresolved";
|
|
332
|
+
}
|
|
333
|
+
/** Conversation metadata for sync. Matches persistence Conversation shape using snake_case for wire format. */
|
|
334
|
+
export interface SyncConversation {
|
|
335
|
+
conversation_id: ConversationId;
|
|
336
|
+
motebit_id: MotebitId;
|
|
337
|
+
started_at: number;
|
|
338
|
+
last_active_at: number;
|
|
339
|
+
title: string | null;
|
|
340
|
+
summary: string | null;
|
|
341
|
+
message_count: number;
|
|
342
|
+
}
|
|
343
|
+
/** Conversation message for sync. Matches persistence ConversationMessage shape using snake_case for wire format. */
|
|
344
|
+
export interface SyncConversationMessage {
|
|
345
|
+
message_id: string;
|
|
346
|
+
conversation_id: ConversationId;
|
|
347
|
+
motebit_id: MotebitId;
|
|
348
|
+
role: string;
|
|
349
|
+
content: string;
|
|
350
|
+
tool_calls: string | null;
|
|
351
|
+
tool_call_id: string | null;
|
|
352
|
+
created_at: number;
|
|
353
|
+
token_estimate: number;
|
|
354
|
+
}
|
|
355
|
+
/** Result of a conversation sync cycle. */
|
|
356
|
+
export interface ConversationSyncResult {
|
|
357
|
+
conversations_pushed: number;
|
|
358
|
+
conversations_pulled: number;
|
|
359
|
+
messages_pushed: number;
|
|
360
|
+
messages_pulled: number;
|
|
361
|
+
}
|
|
362
|
+
export declare enum PlanStatus {
|
|
363
|
+
Active = "active",
|
|
364
|
+
Completed = "completed",
|
|
365
|
+
Failed = "failed",
|
|
366
|
+
Paused = "paused"
|
|
367
|
+
}
|
|
368
|
+
export declare enum StepStatus {
|
|
369
|
+
Pending = "pending",
|
|
370
|
+
Running = "running",
|
|
371
|
+
Completed = "completed",
|
|
372
|
+
Failed = "failed",
|
|
373
|
+
Skipped = "skipped"
|
|
374
|
+
}
|
|
375
|
+
export interface PlanStep {
|
|
376
|
+
step_id: string;
|
|
377
|
+
plan_id: PlanId;
|
|
378
|
+
ordinal: number;
|
|
379
|
+
description: string;
|
|
380
|
+
prompt: string;
|
|
381
|
+
depends_on: string[];
|
|
382
|
+
optional: boolean;
|
|
383
|
+
status: StepStatus;
|
|
384
|
+
required_capabilities?: DeviceCapability[];
|
|
385
|
+
/** Task ID assigned by the relay when this step was delegated to a remote device. */
|
|
386
|
+
delegation_task_id?: string;
|
|
387
|
+
/** Motebit ID of the agent assigned to execute this step in collaborative plans. */
|
|
388
|
+
assigned_motebit_id?: MotebitId;
|
|
389
|
+
result_summary: string | null;
|
|
390
|
+
error_message: string | null;
|
|
391
|
+
tool_calls_made: number;
|
|
392
|
+
started_at: number | null;
|
|
393
|
+
completed_at: number | null;
|
|
394
|
+
retry_count: number;
|
|
395
|
+
updated_at: number;
|
|
396
|
+
}
|
|
397
|
+
export interface Plan {
|
|
398
|
+
plan_id: PlanId;
|
|
399
|
+
goal_id: GoalId;
|
|
400
|
+
motebit_id: MotebitId;
|
|
401
|
+
title: string;
|
|
402
|
+
status: PlanStatus;
|
|
403
|
+
created_at: number;
|
|
404
|
+
updated_at: number;
|
|
405
|
+
current_step_index: number;
|
|
406
|
+
total_steps: number;
|
|
407
|
+
proposal_id?: ProposalId;
|
|
408
|
+
collaborative?: boolean;
|
|
409
|
+
}
|
|
410
|
+
/** Plan record for cross-device sync. Mirrors Plan but uses wire-format field names. */
|
|
411
|
+
export interface SyncPlan {
|
|
412
|
+
plan_id: PlanId;
|
|
413
|
+
goal_id: GoalId;
|
|
414
|
+
motebit_id: MotebitId;
|
|
415
|
+
title: string;
|
|
416
|
+
status: PlanStatus;
|
|
417
|
+
created_at: number;
|
|
418
|
+
updated_at: number;
|
|
419
|
+
current_step_index: number;
|
|
420
|
+
total_steps: number;
|
|
421
|
+
proposal_id: string | null;
|
|
422
|
+
collaborative: number;
|
|
423
|
+
}
|
|
424
|
+
/** Plan step record for cross-device sync. */
|
|
425
|
+
export interface SyncPlanStep {
|
|
426
|
+
step_id: string;
|
|
427
|
+
plan_id: PlanId;
|
|
428
|
+
motebit_id: MotebitId;
|
|
429
|
+
ordinal: number;
|
|
430
|
+
description: string;
|
|
431
|
+
prompt: string;
|
|
432
|
+
depends_on: string;
|
|
433
|
+
optional: boolean;
|
|
434
|
+
status: StepStatus;
|
|
435
|
+
required_capabilities: string | null;
|
|
436
|
+
delegation_task_id: string | null;
|
|
437
|
+
assigned_motebit_id: string | null;
|
|
438
|
+
result_summary: string | null;
|
|
439
|
+
error_message: string | null;
|
|
440
|
+
tool_calls_made: number;
|
|
441
|
+
started_at: number | null;
|
|
442
|
+
completed_at: number | null;
|
|
443
|
+
retry_count: number;
|
|
444
|
+
updated_at: number;
|
|
445
|
+
}
|
|
446
|
+
/** Result of a plan sync cycle. */
|
|
447
|
+
export interface PlanSyncResult {
|
|
448
|
+
plans_pushed: number;
|
|
449
|
+
plans_pulled: number;
|
|
450
|
+
steps_pushed: number;
|
|
451
|
+
steps_pulled: number;
|
|
452
|
+
}
|
|
453
|
+
export declare enum DeviceCapability {
|
|
454
|
+
StdioMcp = "stdio_mcp",
|
|
455
|
+
HttpMcp = "http_mcp",
|
|
456
|
+
FileSystem = "file_system",
|
|
457
|
+
Keyring = "keyring",
|
|
458
|
+
Background = "background",
|
|
459
|
+
LocalLlm = "local_llm"
|
|
460
|
+
}
|
|
461
|
+
export declare enum AgentTaskStatus {
|
|
462
|
+
Pending = "pending",
|
|
463
|
+
Claimed = "claimed",
|
|
464
|
+
Running = "running",
|
|
465
|
+
Completed = "completed",
|
|
466
|
+
Failed = "failed",
|
|
467
|
+
Denied = "denied",
|
|
468
|
+
Expired = "expired"
|
|
469
|
+
}
|
|
470
|
+
export interface AgentTask {
|
|
471
|
+
task_id: string;
|
|
472
|
+
motebit_id: MotebitId;
|
|
473
|
+
prompt: string;
|
|
474
|
+
submitted_at: number;
|
|
475
|
+
submitted_by?: string;
|
|
476
|
+
wall_clock_ms?: number;
|
|
477
|
+
status: AgentTaskStatus;
|
|
478
|
+
claimed_by?: string;
|
|
479
|
+
required_capabilities?: DeviceCapability[];
|
|
480
|
+
step_id?: string;
|
|
481
|
+
/** Delegation scope — when set, restricts which tools the task can use. */
|
|
482
|
+
delegated_scope?: string;
|
|
483
|
+
}
|
|
484
|
+
export interface ExecutionReceipt {
|
|
485
|
+
task_id: string;
|
|
486
|
+
motebit_id: MotebitId;
|
|
487
|
+
/** Signer's Ed25519 public key (hex). Enables verification without relay lookup. */
|
|
488
|
+
public_key?: string;
|
|
489
|
+
device_id: DeviceId;
|
|
490
|
+
submitted_at: number;
|
|
491
|
+
completed_at: number;
|
|
492
|
+
status: "completed" | "failed" | "denied";
|
|
493
|
+
result: string;
|
|
494
|
+
tools_used: string[];
|
|
495
|
+
memories_formed: number;
|
|
496
|
+
prompt_hash: string;
|
|
497
|
+
result_hash: string;
|
|
498
|
+
delegation_receipts?: ExecutionReceipt[];
|
|
499
|
+
/**
|
|
500
|
+
* Cryptographic binding to the relay's economic identity for this task.
|
|
501
|
+
*
|
|
502
|
+
* Optional for local (non-relay) execution. **Required** for relay-mediated
|
|
503
|
+
* tasks — the relay rejects receipts without this field (HTTP 400). The value
|
|
504
|
+
* is included in the Ed25519 signature, so tampering breaks verification.
|
|
505
|
+
*/
|
|
506
|
+
relay_task_id?: string;
|
|
507
|
+
/** Scope from the delegation token that authorized this execution, if any. */
|
|
508
|
+
delegated_scope?: string;
|
|
509
|
+
signature: string;
|
|
510
|
+
}
|
|
511
|
+
export interface DelegatedStepResult {
|
|
512
|
+
step_id: string;
|
|
513
|
+
task_id: string;
|
|
514
|
+
receipt: ExecutionReceipt;
|
|
515
|
+
result_text: string;
|
|
516
|
+
/** Routing provenance from the relay — why this agent was selected. */
|
|
517
|
+
routing_choice?: {
|
|
518
|
+
selected_agent: string;
|
|
519
|
+
composite_score: number;
|
|
520
|
+
sub_scores: Record<string, number>;
|
|
521
|
+
routing_paths: string[][];
|
|
522
|
+
alternatives_considered: number;
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* A key succession record proving that one Ed25519 key has been replaced by another.
|
|
527
|
+
* Both the old and new keys sign the record, creating a cryptographic chain of custody.
|
|
528
|
+
* Structurally compatible with @motebit/crypto KeySuccessionRecord.
|
|
529
|
+
*
|
|
530
|
+
* Guardian recovery records have `recovery: true` and `guardian_signature` instead of
|
|
531
|
+
* `old_key_signature`. This allows identity recovery when the primary key is compromised.
|
|
532
|
+
*/
|
|
533
|
+
export interface KeySuccessionRecord {
|
|
534
|
+
old_public_key: string;
|
|
535
|
+
new_public_key: string;
|
|
536
|
+
timestamp: number;
|
|
537
|
+
reason?: string;
|
|
538
|
+
old_key_signature?: string;
|
|
539
|
+
new_key_signature: string;
|
|
540
|
+
/** Guardian recovery: true when succession was authorized by guardian, not old key. */
|
|
541
|
+
recovery?: boolean;
|
|
542
|
+
/** Guardian signature — present only when recovery is true. */
|
|
543
|
+
guardian_signature?: string;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Organizational guardian — enables key recovery and organizational custody.
|
|
547
|
+
* The guardian's private key is held by the organization (cold storage).
|
|
548
|
+
* When present, the guardian can sign succession records on behalf of a compromised key.
|
|
549
|
+
*/
|
|
550
|
+
export interface IdentityGuardian {
|
|
551
|
+
/** Ed25519 public key of the guardian (hex). */
|
|
552
|
+
public_key: string;
|
|
553
|
+
/** Human-readable organization name. */
|
|
554
|
+
organization?: string;
|
|
555
|
+
/** Machine-readable organization identifier. */
|
|
556
|
+
organization_id?: string;
|
|
557
|
+
/** ISO 8601 timestamp when guardianship was established. */
|
|
558
|
+
established_at: string;
|
|
559
|
+
}
|
|
560
|
+
/** Result of verifying a key succession chain. */
|
|
561
|
+
export interface SuccessionChainResult {
|
|
562
|
+
valid: boolean;
|
|
563
|
+
/** The original (genesis) public key. */
|
|
564
|
+
genesis_public_key: string;
|
|
565
|
+
/** The current (active) public key. */
|
|
566
|
+
current_public_key: string;
|
|
567
|
+
/** Number of key rotations. */
|
|
568
|
+
length: number;
|
|
569
|
+
/** If invalid, the index of the first broken link and error. */
|
|
570
|
+
error?: {
|
|
571
|
+
index: number;
|
|
572
|
+
message: string;
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
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";
|
|
576
|
+
export interface ExecutionTimelineEntry {
|
|
577
|
+
timestamp: number;
|
|
578
|
+
type: ExecutionTimelineType;
|
|
579
|
+
payload: Record<string, unknown>;
|
|
580
|
+
}
|
|
581
|
+
export interface ExecutionStepSummary {
|
|
582
|
+
step_id: string;
|
|
583
|
+
ordinal: number;
|
|
584
|
+
description: string;
|
|
585
|
+
status: string;
|
|
586
|
+
tools_used: string[];
|
|
587
|
+
tool_calls: number;
|
|
588
|
+
started_at: number | null;
|
|
589
|
+
completed_at: number | null;
|
|
590
|
+
delegation?: {
|
|
591
|
+
task_id: string;
|
|
592
|
+
receipt_hash?: string;
|
|
593
|
+
/** Routing provenance: why this agent was selected for delegation. */
|
|
594
|
+
routing_choice?: {
|
|
595
|
+
selected_agent: string;
|
|
596
|
+
composite_score: number;
|
|
597
|
+
sub_scores: {
|
|
598
|
+
trust: number;
|
|
599
|
+
success_rate: number;
|
|
600
|
+
latency: number;
|
|
601
|
+
price_efficiency: number;
|
|
602
|
+
capability_match: number;
|
|
603
|
+
availability: number;
|
|
604
|
+
};
|
|
605
|
+
/** Derivation paths through the agent graph. */
|
|
606
|
+
routing_paths: string[][];
|
|
607
|
+
/** Number of candidate agents that were scored. */
|
|
608
|
+
alternatives_considered: number;
|
|
609
|
+
};
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
export interface GoalExecutionManifest {
|
|
613
|
+
spec: "motebit/execution-ledger@1.0";
|
|
614
|
+
motebit_id: string;
|
|
615
|
+
goal_id: string;
|
|
616
|
+
plan_id: string;
|
|
617
|
+
started_at: number;
|
|
618
|
+
completed_at: number;
|
|
619
|
+
status: "completed" | "failed" | "paused" | "active";
|
|
620
|
+
timeline: ExecutionTimelineEntry[];
|
|
621
|
+
steps: ExecutionStepSummary[];
|
|
622
|
+
delegation_receipts: DelegationReceiptSummary[];
|
|
623
|
+
content_hash: string;
|
|
624
|
+
signature?: string;
|
|
625
|
+
}
|
|
626
|
+
export interface DelegationReceiptSummary {
|
|
627
|
+
task_id: string;
|
|
628
|
+
motebit_id: string;
|
|
629
|
+
device_id: string;
|
|
630
|
+
status: string;
|
|
631
|
+
completed_at: number;
|
|
632
|
+
tools_used: string[];
|
|
633
|
+
signature_prefix: string;
|
|
634
|
+
}
|
|
635
|
+
export interface AgentCapabilities {
|
|
636
|
+
motebit_id: MotebitId;
|
|
637
|
+
public_key: string;
|
|
638
|
+
/** W3C did:key URI derived from the Ed25519 public key. */
|
|
639
|
+
did?: string;
|
|
640
|
+
tools: string[];
|
|
641
|
+
governance: {
|
|
642
|
+
trust_mode: string;
|
|
643
|
+
max_risk_auto: number;
|
|
644
|
+
require_approval_above: number;
|
|
645
|
+
deny_above: number;
|
|
646
|
+
};
|
|
647
|
+
online_devices: number;
|
|
648
|
+
}
|
|
649
|
+
export interface CapabilityPrice {
|
|
650
|
+
capability: string;
|
|
651
|
+
unit_cost: number;
|
|
652
|
+
currency: string;
|
|
653
|
+
per: "task" | "tool_call" | "token";
|
|
654
|
+
}
|
|
655
|
+
export interface AgentServiceListing {
|
|
656
|
+
listing_id: ListingId;
|
|
657
|
+
motebit_id: MotebitId;
|
|
658
|
+
capabilities: string[];
|
|
659
|
+
pricing: CapabilityPrice[];
|
|
660
|
+
sla: {
|
|
661
|
+
max_latency_ms: number;
|
|
662
|
+
availability_guarantee: number;
|
|
663
|
+
};
|
|
664
|
+
description: string;
|
|
665
|
+
/** Wallet address for x402 on-chain payment settlement (e.g. "0x..." for EVM). */
|
|
666
|
+
pay_to_address?: string;
|
|
667
|
+
/**
|
|
668
|
+
* Self-declared regulatory risk score [0, ∞). 0 = no risk, higher = more risk.
|
|
669
|
+
* Accumulates along delegation chains via RegulatoryRiskSemiring (min, +).
|
|
670
|
+
* Sources: jurisdiction, data handling classification, compliance certifications,
|
|
671
|
+
* audit requirements. The score is declared by the agent; verification is via
|
|
672
|
+
* credentials (e.g. compliance attestation VCs).
|
|
673
|
+
*/
|
|
674
|
+
regulatory_risk?: number;
|
|
675
|
+
updated_at: number;
|
|
676
|
+
}
|
|
677
|
+
export interface RouteScore {
|
|
678
|
+
motebit_id: MotebitId;
|
|
679
|
+
composite: number;
|
|
680
|
+
sub_scores: {
|
|
681
|
+
trust: number;
|
|
682
|
+
success_rate: number;
|
|
683
|
+
latency: number;
|
|
684
|
+
price_efficiency: number;
|
|
685
|
+
capability_match: number;
|
|
686
|
+
availability: number;
|
|
687
|
+
};
|
|
688
|
+
selected: boolean;
|
|
689
|
+
}
|
|
690
|
+
export interface BudgetAllocation {
|
|
691
|
+
allocation_id: AllocationId;
|
|
692
|
+
goal_id: GoalId;
|
|
693
|
+
candidate_motebit_id: MotebitId;
|
|
694
|
+
amount_locked: number;
|
|
695
|
+
currency: string;
|
|
696
|
+
created_at: number;
|
|
697
|
+
status: "locked" | "settled" | "released" | "disputed";
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Default platform fee rate (5%) — used by the reference relay deployment.
|
|
701
|
+
* The protocol supports any fee structure; relays configure their own rate
|
|
702
|
+
* via MOTEBIT_PLATFORM_FEE_RATE env or config.platformFeeRate.
|
|
703
|
+
*/
|
|
704
|
+
export declare const PLATFORM_FEE_RATE = 0.05;
|
|
705
|
+
export interface SettlementRecord {
|
|
706
|
+
settlement_id: SettlementId;
|
|
707
|
+
allocation_id: AllocationId;
|
|
708
|
+
receipt_hash: string;
|
|
709
|
+
ledger_hash: string | null;
|
|
710
|
+
/** Amount paid to the executing agent (after platform fee deduction). */
|
|
711
|
+
amount_settled: number;
|
|
712
|
+
/** Platform fee extracted by the relay. */
|
|
713
|
+
platform_fee: number;
|
|
714
|
+
/** Fee rate applied (e.g. 0.05 = 5%). Recorded per-settlement for auditability. */
|
|
715
|
+
platform_fee_rate: number;
|
|
716
|
+
/** x402 payment transaction hash (when paid on-chain). */
|
|
717
|
+
x402_tx_hash?: string;
|
|
718
|
+
/** x402 network used for payment (CAIP-2 identifier). */
|
|
719
|
+
x402_network?: string;
|
|
720
|
+
status: "completed" | "partial" | "refunded";
|
|
721
|
+
settled_at: number;
|
|
722
|
+
}
|
|
723
|
+
export interface CollaborativePlanProposal {
|
|
724
|
+
proposal_id: ProposalId;
|
|
725
|
+
plan_id: PlanId;
|
|
726
|
+
initiator_motebit_id: MotebitId;
|
|
727
|
+
participants: ProposalParticipant[];
|
|
728
|
+
status: ProposalStatus;
|
|
729
|
+
created_at: number;
|
|
730
|
+
expires_at: number;
|
|
731
|
+
updated_at: number;
|
|
732
|
+
}
|
|
733
|
+
export interface ProposalParticipant {
|
|
734
|
+
motebit_id: MotebitId;
|
|
735
|
+
assigned_steps: number[];
|
|
736
|
+
response: ProposalResponseType | null;
|
|
737
|
+
responded_at: number | null;
|
|
738
|
+
counter_steps?: ProposalStepCounter[];
|
|
739
|
+
}
|
|
740
|
+
export interface ProposalStepCounter {
|
|
741
|
+
ordinal: number;
|
|
742
|
+
description?: string;
|
|
743
|
+
prompt?: string;
|
|
744
|
+
reason: string;
|
|
745
|
+
}
|
|
746
|
+
export interface ProposalResponse {
|
|
747
|
+
proposal_id: ProposalId;
|
|
748
|
+
responder_motebit_id: MotebitId;
|
|
749
|
+
response: ProposalResponseType;
|
|
750
|
+
counter_steps?: ProposalStepCounter[];
|
|
751
|
+
signature: string;
|
|
752
|
+
}
|
|
753
|
+
export interface CollaborativeReceipt {
|
|
754
|
+
proposal_id: ProposalId;
|
|
755
|
+
plan_id: PlanId;
|
|
756
|
+
participant_receipts: ExecutionReceipt[];
|
|
757
|
+
content_hash: string;
|
|
758
|
+
initiator_signature: string;
|
|
759
|
+
}
|
|
760
|
+
export interface MarketConfig {
|
|
761
|
+
weight_trust: number;
|
|
762
|
+
weight_success_rate: number;
|
|
763
|
+
weight_latency: number;
|
|
764
|
+
weight_price_efficiency: number;
|
|
765
|
+
weight_capability_match: number;
|
|
766
|
+
weight_availability: number;
|
|
767
|
+
latency_norm_k: number;
|
|
768
|
+
max_candidates: number;
|
|
769
|
+
settlement_timeout_ms: number;
|
|
770
|
+
/** Exploration weight [0-1]: 0 = pure exploitation, 1 = pure exploration. Default 0. */
|
|
771
|
+
exploration_weight?: number;
|
|
772
|
+
}
|
|
773
|
+
export declare const VC_TYPE_GRADIENT = "AgentGradientCredential";
|
|
774
|
+
export declare const VC_TYPE_REPUTATION = "AgentReputationCredential";
|
|
775
|
+
export declare const VC_TYPE_TRUST = "AgentTrustCredential";
|
|
776
|
+
export interface ReputationCredentialSubject {
|
|
777
|
+
id: string;
|
|
778
|
+
success_rate: number;
|
|
779
|
+
avg_latency_ms: number;
|
|
780
|
+
task_count: number;
|
|
781
|
+
trust_score: number;
|
|
782
|
+
availability: number;
|
|
783
|
+
sample_size: number;
|
|
784
|
+
measured_at: number;
|
|
785
|
+
}
|
|
786
|
+
export interface TrustCredentialSubject {
|
|
787
|
+
id: string;
|
|
788
|
+
trust_level: string;
|
|
789
|
+
interaction_count: number;
|
|
790
|
+
successful_tasks: number;
|
|
791
|
+
failed_tasks: number;
|
|
792
|
+
first_seen_at: number;
|
|
793
|
+
last_seen_at: number;
|
|
794
|
+
}
|
|
795
|
+
export interface GradientCredentialSubject {
|
|
796
|
+
id: string;
|
|
797
|
+
gradient: number;
|
|
798
|
+
knowledge_density: number;
|
|
799
|
+
knowledge_quality: number;
|
|
800
|
+
graph_connectivity: number;
|
|
801
|
+
temporal_stability: number;
|
|
802
|
+
retrieval_quality: number;
|
|
803
|
+
interaction_efficiency: number;
|
|
804
|
+
tool_efficiency: number;
|
|
805
|
+
curiosity_pressure: number;
|
|
806
|
+
measured_at: number;
|
|
807
|
+
}
|
|
808
|
+
export interface ConversationStoreAdapter {
|
|
809
|
+
createConversation(motebitId: string): string;
|
|
810
|
+
appendMessage(conversationId: string, motebitId: string, msg: {
|
|
811
|
+
role: string;
|
|
812
|
+
content: string;
|
|
813
|
+
toolCalls?: string;
|
|
814
|
+
toolCallId?: string;
|
|
815
|
+
}): void;
|
|
816
|
+
loadMessages(conversationId: string, limit?: number): Array<{
|
|
817
|
+
messageId: string;
|
|
818
|
+
conversationId: string;
|
|
819
|
+
motebitId: string;
|
|
820
|
+
role: string;
|
|
821
|
+
content: string;
|
|
822
|
+
toolCalls: string | null;
|
|
823
|
+
toolCallId: string | null;
|
|
824
|
+
createdAt: number;
|
|
825
|
+
tokenEstimate: number;
|
|
826
|
+
}>;
|
|
827
|
+
getActiveConversation(motebitId: string): {
|
|
828
|
+
conversationId: string;
|
|
829
|
+
startedAt: number;
|
|
830
|
+
lastActiveAt: number;
|
|
831
|
+
summary: string | null;
|
|
832
|
+
} | null;
|
|
833
|
+
updateSummary(conversationId: string, summary: string): void;
|
|
834
|
+
updateTitle(conversationId: string, title: string): void;
|
|
835
|
+
listConversations(motebitId: string, limit?: number): Array<{
|
|
836
|
+
conversationId: string;
|
|
837
|
+
startedAt: number;
|
|
838
|
+
lastActiveAt: number;
|
|
839
|
+
title: string | null;
|
|
840
|
+
messageCount: number;
|
|
841
|
+
}>;
|
|
842
|
+
deleteConversation(conversationId: string): void;
|
|
843
|
+
}
|
|
844
|
+
export interface StateSnapshotAdapter {
|
|
845
|
+
saveState(motebitId: string, stateJson: string, versionClock?: number): void;
|
|
846
|
+
loadState(motebitId: string): string | null;
|
|
847
|
+
/** Version clock at last snapshot — used to determine what's safe to compact. */
|
|
848
|
+
getSnapshotClock?(motebitId: string): number;
|
|
849
|
+
}
|
|
850
|
+
export interface KeyringAdapter {
|
|
851
|
+
get(key: string): Promise<string | null>;
|
|
852
|
+
set(key: string, value: string): Promise<void>;
|
|
853
|
+
delete(key: string): Promise<void>;
|
|
854
|
+
}
|
|
855
|
+
export interface AgentTrustStoreAdapter {
|
|
856
|
+
getAgentTrust(motebitId: string, remoteMotebitId: string): Promise<AgentTrustRecord | null>;
|
|
857
|
+
setAgentTrust(record: AgentTrustRecord): Promise<void>;
|
|
858
|
+
listAgentTrust(motebitId: string): Promise<AgentTrustRecord[]>;
|
|
859
|
+
updateTrustLevel(motebitId: string, remoteMotebitId: string, level: AgentTrustLevel): Promise<void>;
|
|
860
|
+
}
|
|
861
|
+
export interface ServiceListingStoreAdapter {
|
|
862
|
+
get(motebitId: string): Promise<AgentServiceListing | null>;
|
|
863
|
+
set(listing: AgentServiceListing): Promise<void>;
|
|
864
|
+
list(): Promise<AgentServiceListing[]>;
|
|
865
|
+
delete(listingId: string): Promise<void>;
|
|
866
|
+
}
|
|
867
|
+
export interface BudgetAllocationStoreAdapter {
|
|
868
|
+
get(allocationId: string): Promise<BudgetAllocation | null>;
|
|
869
|
+
create(allocation: BudgetAllocation): Promise<void>;
|
|
870
|
+
updateStatus(allocationId: string, status: string): Promise<void>;
|
|
871
|
+
listByGoal(goalId: string): Promise<BudgetAllocation[]>;
|
|
872
|
+
}
|
|
873
|
+
export interface SettlementStoreAdapter {
|
|
874
|
+
get(settlementId: string): Promise<SettlementRecord | null>;
|
|
875
|
+
create(settlement: SettlementRecord): Promise<void>;
|
|
876
|
+
listByAllocation(allocationId: string): Promise<SettlementRecord[]>;
|
|
877
|
+
}
|
|
878
|
+
export interface LatencyStatsStoreAdapter {
|
|
879
|
+
record(motebitId: string, remoteMotebitId: string, latencyMs: number): Promise<void>;
|
|
880
|
+
getStats(motebitId: string, remoteMotebitId: string, limit?: number): Promise<{
|
|
881
|
+
avg_ms: number;
|
|
882
|
+
p95_ms: number;
|
|
883
|
+
sample_count: number;
|
|
884
|
+
}>;
|
|
885
|
+
}
|
|
886
|
+
export interface EventFilter {
|
|
887
|
+
motebit_id?: string;
|
|
888
|
+
event_types?: EventType[];
|
|
889
|
+
after_timestamp?: number;
|
|
890
|
+
before_timestamp?: number;
|
|
891
|
+
after_version_clock?: number;
|
|
892
|
+
limit?: number;
|
|
893
|
+
}
|
|
894
|
+
export interface EventStoreAdapter {
|
|
895
|
+
append(entry: EventLogEntry): Promise<void>;
|
|
896
|
+
/**
|
|
897
|
+
* Atomically assign the next version_clock and append the event.
|
|
898
|
+
* Eliminates the race condition in the getLatestClock() + clock+1 pattern.
|
|
899
|
+
* Returns the assigned version_clock.
|
|
900
|
+
*/
|
|
901
|
+
appendWithClock?(entry: Omit<EventLogEntry, "version_clock">): Promise<number>;
|
|
902
|
+
query(filter: EventFilter): Promise<EventLogEntry[]>;
|
|
903
|
+
getLatestClock(motebitId: string): Promise<number>;
|
|
904
|
+
tombstone(eventId: string, motebitId: string): Promise<void>;
|
|
905
|
+
/** Delete events with version_clock <= beforeClock. Returns count deleted. */
|
|
906
|
+
compact?(motebitId: string, beforeClock: number): Promise<number>;
|
|
907
|
+
/** Count total events for a motebit. */
|
|
908
|
+
countEvents?(motebitId: string): Promise<number>;
|
|
909
|
+
}
|
|
910
|
+
export interface DeviceRegistration {
|
|
911
|
+
device_id: string;
|
|
912
|
+
motebit_id: string;
|
|
913
|
+
device_token?: string;
|
|
914
|
+
public_key: string;
|
|
915
|
+
registered_at: number;
|
|
916
|
+
device_name?: string;
|
|
917
|
+
}
|
|
918
|
+
export interface IdentityStorage {
|
|
919
|
+
save(identity: MotebitIdentity): Promise<void>;
|
|
920
|
+
load(motebitId: string): Promise<MotebitIdentity | null>;
|
|
921
|
+
loadByOwner(ownerId: string): Promise<MotebitIdentity | null>;
|
|
922
|
+
saveDevice?(device: DeviceRegistration): Promise<void>;
|
|
923
|
+
loadDevice?(deviceId: string): Promise<DeviceRegistration | null>;
|
|
924
|
+
loadDeviceByToken?(token: string): Promise<DeviceRegistration | null>;
|
|
925
|
+
listDevices?(motebitId: string): Promise<DeviceRegistration[]>;
|
|
926
|
+
}
|
|
927
|
+
export interface AuditLogAdapter {
|
|
928
|
+
record(entry: AuditRecord): Promise<void>;
|
|
929
|
+
query(motebitId: string, options?: {
|
|
930
|
+
limit?: number;
|
|
931
|
+
after?: number;
|
|
932
|
+
}): Promise<AuditRecord[]>;
|
|
933
|
+
}
|
|
934
|
+
export interface AuditStatsSince {
|
|
935
|
+
distinctTurns: number;
|
|
936
|
+
totalToolCalls: number;
|
|
937
|
+
succeeded: number;
|
|
938
|
+
blocked: number;
|
|
939
|
+
failed: number;
|
|
940
|
+
}
|
|
941
|
+
export interface AuditLogSink {
|
|
942
|
+
append(entry: ToolAuditEntry): void;
|
|
943
|
+
query(turnId: string): ToolAuditEntry[];
|
|
944
|
+
getAll(): ToolAuditEntry[];
|
|
945
|
+
queryStatsSince(afterTimestamp: number): AuditStatsSince;
|
|
946
|
+
/** Query tool audit entries by run_id (plan execution). Optional — returns [] if not implemented. */
|
|
947
|
+
queryByRunId?(runId: string): ToolAuditEntry[];
|
|
948
|
+
}
|
|
949
|
+
export interface PlanStoreAdapter {
|
|
950
|
+
savePlan(plan: Plan): void;
|
|
951
|
+
getPlan(planId: string): Plan | null;
|
|
952
|
+
getPlanForGoal(goalId: string): Plan | null;
|
|
953
|
+
updatePlan(planId: string, updates: Partial<Plan>): void;
|
|
954
|
+
saveStep(step: PlanStep): void;
|
|
955
|
+
getStep(stepId: string): PlanStep | null;
|
|
956
|
+
getStepsForPlan(planId: string): PlanStep[];
|
|
957
|
+
updateStep(stepId: string, updates: Partial<PlanStep>): void;
|
|
958
|
+
getNextPendingStep(planId: string): PlanStep | null;
|
|
959
|
+
/** List all active plans for a motebit. Optional — returns [] if not implemented. */
|
|
960
|
+
listActivePlans?(motebitId: string): Plan[];
|
|
961
|
+
}
|
|
962
|
+
/** Stored credential record — JSON-serialized VC with metadata. */
|
|
963
|
+
export interface StoredCredential {
|
|
964
|
+
credential_id: string;
|
|
965
|
+
/** The agent the credential is about (credentialSubject.id). */
|
|
966
|
+
subject_motebit_id: string;
|
|
967
|
+
/** did:key of the issuer. */
|
|
968
|
+
issuer_did: string;
|
|
969
|
+
/** e.g. "AgentReputationCredential", "AgentTrustCredential", "AgentGradientCredential". */
|
|
970
|
+
credential_type: string;
|
|
971
|
+
/** Full JSON-serialized VerifiableCredential. */
|
|
972
|
+
credential_json: string;
|
|
973
|
+
issued_at: number;
|
|
974
|
+
}
|
|
975
|
+
export interface CredentialStoreAdapter {
|
|
976
|
+
save(credential: StoredCredential): void;
|
|
977
|
+
/** List credentials about a specific subject agent. */
|
|
978
|
+
listBySubject(subjectMotebitId: string, limit?: number): StoredCredential[];
|
|
979
|
+
/** List all credentials, optionally filtered by type. */
|
|
980
|
+
list(motebitId: string, type?: string, limit?: number): StoredCredential[];
|
|
981
|
+
}
|
|
982
|
+
export interface ApprovalStoreAdapter {
|
|
983
|
+
/** Collect a quorum approval vote. Returns whether threshold is met and collected voter IDs. */
|
|
984
|
+
collectApproval(approvalId: string, approverId: string): {
|
|
985
|
+
met: boolean;
|
|
986
|
+
collected: string[];
|
|
987
|
+
};
|
|
988
|
+
/** Set quorum metadata on a pending approval item. */
|
|
989
|
+
setQuorum(approvalId: string, required: number, approvers: string[]): void;
|
|
990
|
+
}
|
|
991
|
+
export {};
|
|
992
|
+
//# sourceMappingURL=index.d.ts.map
|