@motebit/sdk 0.1.0 → 0.5.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 +1 -1
- package/README.md +99 -22
- package/dist/index.d.ts +800 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +219 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
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;
|
|
1
38
|
export declare enum TrustMode {
|
|
2
39
|
Full = "full",
|
|
3
40
|
Guarded = "guarded",
|
|
@@ -20,16 +57,87 @@ export declare enum MotebitType {
|
|
|
20
57
|
Service = "service",
|
|
21
58
|
Collaborative = "collaborative"
|
|
22
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
|
+
}
|
|
23
73
|
export interface AgentTrustRecord {
|
|
24
|
-
motebit_id:
|
|
25
|
-
remote_motebit_id:
|
|
74
|
+
motebit_id: MotebitId;
|
|
75
|
+
remote_motebit_id: MotebitId;
|
|
26
76
|
trust_level: AgentTrustLevel;
|
|
27
77
|
public_key?: string;
|
|
28
78
|
first_seen_at: number;
|
|
29
79
|
last_seen_at: number;
|
|
30
80
|
interaction_count: number;
|
|
81
|
+
successful_tasks?: number;
|
|
82
|
+
failed_tasks?: number;
|
|
31
83
|
notes?: string;
|
|
32
84
|
}
|
|
85
|
+
/** Canonical AgentTrustLevel → [0,1] mapping (single source of truth). */
|
|
86
|
+
export declare const TRUST_LEVEL_SCORES: Record<string, number>;
|
|
87
|
+
/** Convert a trust level to its numeric score. */
|
|
88
|
+
export declare function trustLevelToScore(level: AgentTrustLevel | string): number;
|
|
89
|
+
/** Semiring zero — annihilator for ⊗, identity for ⊕. */
|
|
90
|
+
export declare const TRUST_ZERO = 0;
|
|
91
|
+
/** Semiring one — identity for ⊗. */
|
|
92
|
+
export declare const TRUST_ONE = 1;
|
|
93
|
+
/** ⊕: parallel paths — pick the best route. */
|
|
94
|
+
export declare function trustAdd(a: number, b: number): number;
|
|
95
|
+
/** ⊗: serial chain — discount per hop. */
|
|
96
|
+
export declare function trustMultiply(a: number, b: number): number;
|
|
97
|
+
/** Fold a chain of trust scores with ⊗. Empty chain → 1.0 (identity). */
|
|
98
|
+
export declare function composeTrustChain(scores: number[]): number;
|
|
99
|
+
/** Fold parallel route scores with ⊕. No routes → 0.0 (identity). */
|
|
100
|
+
export declare function joinParallelRoutes(scores: number[]): number;
|
|
101
|
+
/** Thresholds for automatic trust level promotion/demotion. */
|
|
102
|
+
export interface TrustTransitionThresholds {
|
|
103
|
+
/** Min successful tasks for FirstContact → Verified (default 5) */
|
|
104
|
+
promoteToVerified_minTasks: number;
|
|
105
|
+
/** Min success rate for FirstContact → Verified (default 0.8) */
|
|
106
|
+
promoteToVerified_minRate: number;
|
|
107
|
+
/** Min successful tasks for Verified → Trusted (default 20) */
|
|
108
|
+
promoteToTrusted_minTasks: number;
|
|
109
|
+
/** Min success rate for Verified → Trusted (default 0.9) */
|
|
110
|
+
promoteToTrusted_minRate: number;
|
|
111
|
+
/** Success rate below this triggers demotion (default 0.5) */
|
|
112
|
+
demote_belowRate: number;
|
|
113
|
+
/** Min total tasks before demotion can trigger (default 3) */
|
|
114
|
+
demote_minTasks: number;
|
|
115
|
+
}
|
|
116
|
+
export declare const DEFAULT_TRUST_THRESHOLDS: TrustTransitionThresholds;
|
|
117
|
+
/**
|
|
118
|
+
* Pure: evaluate whether a trust record should transition levels.
|
|
119
|
+
*
|
|
120
|
+
* Promotion: sustained evidence of success (asymmetric — harder to earn).
|
|
121
|
+
* Demotion: success rate dropping below threshold (faster — protect the network).
|
|
122
|
+
* Blocked is never auto-assigned or auto-removed (security decision).
|
|
123
|
+
*
|
|
124
|
+
* Returns the new level, or null if no transition.
|
|
125
|
+
*/
|
|
126
|
+
export declare function evaluateTrustTransition(record: AgentTrustRecord, thresholds?: Partial<TrustTransitionThresholds>): AgentTrustLevel | null;
|
|
127
|
+
/** Structural type for recursive delegation receipt walking. */
|
|
128
|
+
export interface DelegationReceiptLike {
|
|
129
|
+
motebit_id: string;
|
|
130
|
+
delegation_receipts?: DelegationReceiptLike[];
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Compose trust through a delegation receipt tree.
|
|
134
|
+
*
|
|
135
|
+
* Walks `receipt.delegation_receipts` recursively:
|
|
136
|
+
* - Each sub-delegation: directTrust ⊗ getTrust(sub.motebit_id)
|
|
137
|
+
* - Parallel branches joined with ⊕ (best route wins)
|
|
138
|
+
* - No sub-delegations → returns directTrust unchanged.
|
|
139
|
+
*/
|
|
140
|
+
export declare function composeDelegationTrust(directTrust: number, receipt: DelegationReceiptLike, getTrust: (motebitId: string) => number): number;
|
|
33
141
|
export declare enum SensitivityLevel {
|
|
34
142
|
None = "none",
|
|
35
143
|
Personal = "personal",
|
|
@@ -67,13 +175,24 @@ export declare enum EventType {
|
|
|
67
175
|
PlanStepCompleted = "plan_step_completed",
|
|
68
176
|
PlanStepFailed = "plan_step_failed",
|
|
69
177
|
PlanCompleted = "plan_completed",
|
|
178
|
+
PlanStepDelegated = "plan_step_delegated",
|
|
179
|
+
CredentialRevoked = "credential_revoked",
|
|
180
|
+
IdentityRevoked = "identity_revoked",
|
|
70
181
|
PlanFailed = "plan_failed",
|
|
71
182
|
HousekeepingRun = "housekeeping_run",
|
|
72
183
|
ReflectionCompleted = "reflection_completed",
|
|
73
184
|
MemoryConsolidated = "memory_consolidated",
|
|
74
185
|
AgentTaskCompleted = "agent_task_completed",
|
|
75
186
|
AgentTaskFailed = "agent_task_failed",
|
|
76
|
-
AgentTaskDenied = "agent_task_denied"
|
|
187
|
+
AgentTaskDenied = "agent_task_denied",
|
|
188
|
+
ProposalCreated = "proposal_created",
|
|
189
|
+
ProposalAccepted = "proposal_accepted",
|
|
190
|
+
ProposalRejected = "proposal_rejected",
|
|
191
|
+
ProposalCountered = "proposal_countered",
|
|
192
|
+
CollaborativeStepCompleted = "collaborative_step_completed",
|
|
193
|
+
ChainTrustComputed = "chain_trust_computed",
|
|
194
|
+
TrustLevelChanged = "trust_level_changed",
|
|
195
|
+
KeyRotated = "key_rotated"
|
|
77
196
|
}
|
|
78
197
|
export declare enum RelationType {
|
|
79
198
|
Related = "related",
|
|
@@ -89,7 +208,7 @@ export declare enum MemoryType {
|
|
|
89
208
|
Semantic = "semantic"
|
|
90
209
|
}
|
|
91
210
|
export interface MotebitIdentity {
|
|
92
|
-
readonly motebit_id:
|
|
211
|
+
readonly motebit_id: MotebitId;
|
|
93
212
|
readonly created_at: number;
|
|
94
213
|
readonly owner_id: string;
|
|
95
214
|
version_clock: number;
|
|
@@ -120,26 +239,30 @@ export declare const SPECIES_CONSTRAINTS: Readonly<{
|
|
|
120
239
|
readonly DRIFT_VARIATION_MAX: 0.1;
|
|
121
240
|
}>;
|
|
122
241
|
export type SpeciesConstraints = typeof SPECIES_CONSTRAINTS;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
motebit_id: string;
|
|
242
|
+
/** Cognition-facing memory content — what the agent's mind sees. */
|
|
243
|
+
export interface MemoryContent {
|
|
126
244
|
content: string;
|
|
127
|
-
embedding: number[];
|
|
128
245
|
confidence: number;
|
|
129
246
|
sensitivity: SensitivityLevel;
|
|
247
|
+
memory_type?: MemoryType;
|
|
248
|
+
valid_from?: number;
|
|
249
|
+
valid_until?: number | null;
|
|
250
|
+
}
|
|
251
|
+
/** Full memory node including persistence metadata. */
|
|
252
|
+
export interface MemoryNode extends MemoryContent {
|
|
253
|
+
node_id: NodeId;
|
|
254
|
+
motebit_id: MotebitId;
|
|
255
|
+
embedding: number[];
|
|
130
256
|
created_at: number;
|
|
131
257
|
last_accessed: number;
|
|
132
258
|
half_life: number;
|
|
133
259
|
tombstoned: boolean;
|
|
134
260
|
pinned: boolean;
|
|
135
|
-
memory_type?: MemoryType;
|
|
136
|
-
valid_from?: number;
|
|
137
|
-
valid_until?: number | null;
|
|
138
261
|
}
|
|
139
262
|
export interface MemoryEdge {
|
|
140
263
|
edge_id: string;
|
|
141
|
-
source_id:
|
|
142
|
-
target_id:
|
|
264
|
+
source_id: NodeId;
|
|
265
|
+
target_id: NodeId;
|
|
143
266
|
relation_type: RelationType;
|
|
144
267
|
weight: number;
|
|
145
268
|
confidence: number;
|
|
@@ -151,10 +274,10 @@ export interface MemoryCandidate {
|
|
|
151
274
|
memory_type?: MemoryType;
|
|
152
275
|
}
|
|
153
276
|
export interface EventLogEntry {
|
|
154
|
-
event_id:
|
|
155
|
-
motebit_id:
|
|
277
|
+
event_id: EventId;
|
|
278
|
+
motebit_id: MotebitId;
|
|
156
279
|
/** Device that originated this event (for multi-device conflict resolution) */
|
|
157
|
-
device_id?:
|
|
280
|
+
device_id?: DeviceId;
|
|
158
281
|
timestamp: number;
|
|
159
282
|
event_type: EventType;
|
|
160
283
|
payload: Record<string, unknown>;
|
|
@@ -184,6 +307,15 @@ export interface ToolRiskProfile {
|
|
|
184
307
|
sideEffect: SideEffect;
|
|
185
308
|
requiresApproval: boolean;
|
|
186
309
|
}
|
|
310
|
+
/** M-of-N approval quorum configuration. */
|
|
311
|
+
export interface ApprovalQuorum {
|
|
312
|
+
/** Number of approvals required (M). */
|
|
313
|
+
threshold: number;
|
|
314
|
+
/** Authorized approver identifiers. */
|
|
315
|
+
approvers: string[];
|
|
316
|
+
/** Minimum risk level that triggers quorum (optional — default: all approval-required tools). */
|
|
317
|
+
risk_floor?: string;
|
|
318
|
+
}
|
|
187
319
|
export interface PolicyDecision {
|
|
188
320
|
allowed: boolean;
|
|
189
321
|
requiresApproval: boolean;
|
|
@@ -191,6 +323,13 @@ export interface PolicyDecision {
|
|
|
191
323
|
budgetRemaining?: {
|
|
192
324
|
calls: number;
|
|
193
325
|
timeMs: number;
|
|
326
|
+
cost: number;
|
|
327
|
+
};
|
|
328
|
+
/** When quorum is required, contains the quorum metadata. */
|
|
329
|
+
quorum?: {
|
|
330
|
+
required: number;
|
|
331
|
+
approvers: string[];
|
|
332
|
+
collected: string[];
|
|
194
333
|
};
|
|
195
334
|
}
|
|
196
335
|
export interface TurnContext {
|
|
@@ -205,6 +344,8 @@ export interface TurnContext {
|
|
|
205
344
|
callerTrustLevel?: AgentTrustLevel;
|
|
206
345
|
/** Type of the remote motebit making the call (personal/service/collaborative). */
|
|
207
346
|
remoteMotebitType?: string;
|
|
347
|
+
/** Delegation scope — when set, only tools within this scope are allowed. */
|
|
348
|
+
delegationScope?: string;
|
|
208
349
|
}
|
|
209
350
|
export interface InjectionWarning {
|
|
210
351
|
detected: boolean;
|
|
@@ -224,6 +365,7 @@ export interface ToolAuditEntry {
|
|
|
224
365
|
durationMs: number;
|
|
225
366
|
};
|
|
226
367
|
injection?: InjectionWarning;
|
|
368
|
+
costUnits?: number;
|
|
227
369
|
timestamp: number;
|
|
228
370
|
}
|
|
229
371
|
export interface ToolDefinition {
|
|
@@ -253,7 +395,7 @@ export interface ToolRegistry {
|
|
|
253
395
|
}
|
|
254
396
|
export interface ContextPack {
|
|
255
397
|
recent_events: EventLogEntry[];
|
|
256
|
-
relevant_memories:
|
|
398
|
+
relevant_memories: MemoryContent[];
|
|
257
399
|
current_state: MotebitState;
|
|
258
400
|
user_message: string;
|
|
259
401
|
conversation_history?: ConversationMessage[];
|
|
@@ -264,6 +406,17 @@ export interface ContextPack {
|
|
|
264
406
|
continued: boolean;
|
|
265
407
|
lastActiveAt: number;
|
|
266
408
|
};
|
|
409
|
+
/** Fading memories the agent might want to check in about, if relevant to conversation. */
|
|
410
|
+
curiosityHints?: Array<{
|
|
411
|
+
content: string;
|
|
412
|
+
daysSinceDiscussed: number;
|
|
413
|
+
}>;
|
|
414
|
+
/** Known agents this motebit has interacted with — trust levels, reputation, interaction history. */
|
|
415
|
+
knownAgents?: AgentTrustRecord[];
|
|
416
|
+
/** Capabilities per agent ID — used to enrich [Agents I Know] so the AI knows what each agent can do. */
|
|
417
|
+
agentCapabilities?: Record<string, string[]>;
|
|
418
|
+
/** Active inference precision context — modulates agent behavior based on intelligence gradient. */
|
|
419
|
+
precisionContext?: string;
|
|
267
420
|
}
|
|
268
421
|
export type ConversationMessage = {
|
|
269
422
|
role: "user";
|
|
@@ -301,7 +454,7 @@ export interface IntelligenceProvider {
|
|
|
301
454
|
}
|
|
302
455
|
export interface AuditRecord {
|
|
303
456
|
audit_id: string;
|
|
304
|
-
motebit_id:
|
|
457
|
+
motebit_id: MotebitId;
|
|
305
458
|
timestamp: number;
|
|
306
459
|
action: string;
|
|
307
460
|
target_type: string;
|
|
@@ -309,7 +462,7 @@ export interface AuditRecord {
|
|
|
309
462
|
details: Record<string, unknown>;
|
|
310
463
|
}
|
|
311
464
|
export interface ExportManifest {
|
|
312
|
-
motebit_id:
|
|
465
|
+
motebit_id: MotebitId;
|
|
313
466
|
exported_at: number;
|
|
314
467
|
identity: MotebitIdentity;
|
|
315
468
|
memories: MemoryNode[];
|
|
@@ -318,8 +471,8 @@ export interface ExportManifest {
|
|
|
318
471
|
audit_log: AuditRecord[];
|
|
319
472
|
}
|
|
320
473
|
export interface SyncCursor {
|
|
321
|
-
motebit_id:
|
|
322
|
-
last_event_id:
|
|
474
|
+
motebit_id: MotebitId;
|
|
475
|
+
last_event_id: EventId;
|
|
323
476
|
last_version_clock: number;
|
|
324
477
|
}
|
|
325
478
|
export interface ConflictEdge {
|
|
@@ -329,8 +482,8 @@ export interface ConflictEdge {
|
|
|
329
482
|
}
|
|
330
483
|
/** Conversation metadata for sync. Matches persistence Conversation shape using snake_case for wire format. */
|
|
331
484
|
export interface SyncConversation {
|
|
332
|
-
conversation_id:
|
|
333
|
-
motebit_id:
|
|
485
|
+
conversation_id: ConversationId;
|
|
486
|
+
motebit_id: MotebitId;
|
|
334
487
|
started_at: number;
|
|
335
488
|
last_active_at: number;
|
|
336
489
|
title: string | null;
|
|
@@ -340,8 +493,8 @@ export interface SyncConversation {
|
|
|
340
493
|
/** Conversation message for sync. Matches persistence ConversationMessage shape using snake_case for wire format. */
|
|
341
494
|
export interface SyncConversationMessage {
|
|
342
495
|
message_id: string;
|
|
343
|
-
conversation_id:
|
|
344
|
-
motebit_id:
|
|
496
|
+
conversation_id: ConversationId;
|
|
497
|
+
motebit_id: MotebitId;
|
|
345
498
|
role: string;
|
|
346
499
|
content: string;
|
|
347
500
|
tool_calls: string | null;
|
|
@@ -396,30 +549,89 @@ export declare enum StepStatus {
|
|
|
396
549
|
}
|
|
397
550
|
export interface PlanStep {
|
|
398
551
|
step_id: string;
|
|
399
|
-
plan_id:
|
|
552
|
+
plan_id: PlanId;
|
|
400
553
|
ordinal: number;
|
|
401
554
|
description: string;
|
|
402
555
|
prompt: string;
|
|
403
556
|
depends_on: string[];
|
|
404
557
|
optional: boolean;
|
|
405
558
|
status: StepStatus;
|
|
559
|
+
required_capabilities?: DeviceCapability[];
|
|
560
|
+
/** Task ID assigned by the relay when this step was delegated to a remote device. */
|
|
561
|
+
delegation_task_id?: string;
|
|
562
|
+
/** Motebit ID of the agent assigned to execute this step in collaborative plans. */
|
|
563
|
+
assigned_motebit_id?: MotebitId;
|
|
406
564
|
result_summary: string | null;
|
|
407
565
|
error_message: string | null;
|
|
408
566
|
tool_calls_made: number;
|
|
409
567
|
started_at: number | null;
|
|
410
568
|
completed_at: number | null;
|
|
411
569
|
retry_count: number;
|
|
570
|
+
updated_at: number;
|
|
412
571
|
}
|
|
413
572
|
export interface Plan {
|
|
414
|
-
plan_id:
|
|
415
|
-
goal_id:
|
|
416
|
-
motebit_id:
|
|
573
|
+
plan_id: PlanId;
|
|
574
|
+
goal_id: GoalId;
|
|
575
|
+
motebit_id: MotebitId;
|
|
576
|
+
title: string;
|
|
577
|
+
status: PlanStatus;
|
|
578
|
+
created_at: number;
|
|
579
|
+
updated_at: number;
|
|
580
|
+
current_step_index: number;
|
|
581
|
+
total_steps: number;
|
|
582
|
+
proposal_id?: ProposalId;
|
|
583
|
+
collaborative?: boolean;
|
|
584
|
+
}
|
|
585
|
+
/** Plan record for cross-device sync. Mirrors Plan but uses wire-format field names. */
|
|
586
|
+
export interface SyncPlan {
|
|
587
|
+
plan_id: PlanId;
|
|
588
|
+
goal_id: GoalId;
|
|
589
|
+
motebit_id: MotebitId;
|
|
417
590
|
title: string;
|
|
418
591
|
status: PlanStatus;
|
|
419
592
|
created_at: number;
|
|
420
593
|
updated_at: number;
|
|
421
594
|
current_step_index: number;
|
|
422
595
|
total_steps: number;
|
|
596
|
+
proposal_id: string | null;
|
|
597
|
+
collaborative: number;
|
|
598
|
+
}
|
|
599
|
+
/** Plan step record for cross-device sync. */
|
|
600
|
+
export interface SyncPlanStep {
|
|
601
|
+
step_id: string;
|
|
602
|
+
plan_id: PlanId;
|
|
603
|
+
motebit_id: MotebitId;
|
|
604
|
+
ordinal: number;
|
|
605
|
+
description: string;
|
|
606
|
+
prompt: string;
|
|
607
|
+
depends_on: string;
|
|
608
|
+
optional: boolean;
|
|
609
|
+
status: StepStatus;
|
|
610
|
+
required_capabilities: string | null;
|
|
611
|
+
delegation_task_id: string | null;
|
|
612
|
+
assigned_motebit_id: string | null;
|
|
613
|
+
result_summary: string | null;
|
|
614
|
+
error_message: string | null;
|
|
615
|
+
tool_calls_made: number;
|
|
616
|
+
started_at: number | null;
|
|
617
|
+
completed_at: number | null;
|
|
618
|
+
retry_count: number;
|
|
619
|
+
updated_at: number;
|
|
620
|
+
}
|
|
621
|
+
/** Result of a plan sync cycle. */
|
|
622
|
+
export interface PlanSyncResult {
|
|
623
|
+
plans_pushed: number;
|
|
624
|
+
plans_pulled: number;
|
|
625
|
+
steps_pushed: number;
|
|
626
|
+
steps_pulled: number;
|
|
627
|
+
}
|
|
628
|
+
export declare enum DeviceCapability {
|
|
629
|
+
StdioMcp = "stdio_mcp",
|
|
630
|
+
HttpMcp = "http_mcp",
|
|
631
|
+
FileSystem = "file_system",
|
|
632
|
+
Keyring = "keyring",
|
|
633
|
+
Background = "background",
|
|
634
|
+
LocalLlm = "local_llm"
|
|
423
635
|
}
|
|
424
636
|
export declare enum AgentTaskStatus {
|
|
425
637
|
Pending = "pending",
|
|
@@ -432,18 +644,24 @@ export declare enum AgentTaskStatus {
|
|
|
432
644
|
}
|
|
433
645
|
export interface AgentTask {
|
|
434
646
|
task_id: string;
|
|
435
|
-
motebit_id:
|
|
647
|
+
motebit_id: MotebitId;
|
|
436
648
|
prompt: string;
|
|
437
649
|
submitted_at: number;
|
|
438
650
|
submitted_by?: string;
|
|
439
651
|
wall_clock_ms?: number;
|
|
440
652
|
status: AgentTaskStatus;
|
|
441
653
|
claimed_by?: string;
|
|
654
|
+
required_capabilities?: DeviceCapability[];
|
|
655
|
+
step_id?: string;
|
|
656
|
+
/** Delegation scope — when set, restricts which tools the task can use. */
|
|
657
|
+
delegated_scope?: string;
|
|
442
658
|
}
|
|
443
659
|
export interface ExecutionReceipt {
|
|
444
660
|
task_id: string;
|
|
445
|
-
motebit_id:
|
|
446
|
-
|
|
661
|
+
motebit_id: MotebitId;
|
|
662
|
+
/** Signer's Ed25519 public key (hex). Enables verification without relay lookup. */
|
|
663
|
+
public_key?: string;
|
|
664
|
+
device_id: DeviceId;
|
|
447
665
|
submitted_at: number;
|
|
448
666
|
completed_at: number;
|
|
449
667
|
status: "completed" | "failed" | "denied";
|
|
@@ -453,11 +671,119 @@ export interface ExecutionReceipt {
|
|
|
453
671
|
prompt_hash: string;
|
|
454
672
|
result_hash: string;
|
|
455
673
|
delegation_receipts?: ExecutionReceipt[];
|
|
674
|
+
/** Cryptographic binding to the relay's economic identity for this task. */
|
|
675
|
+
relay_task_id?: string;
|
|
676
|
+
/** Scope from the delegation token that authorized this execution, if any. */
|
|
677
|
+
delegated_scope?: string;
|
|
456
678
|
signature: string;
|
|
457
679
|
}
|
|
458
|
-
export interface
|
|
680
|
+
export interface DelegatedStepResult {
|
|
681
|
+
step_id: string;
|
|
682
|
+
task_id: string;
|
|
683
|
+
receipt: ExecutionReceipt;
|
|
684
|
+
result_text: string;
|
|
685
|
+
/** Routing provenance from the relay — why this agent was selected. */
|
|
686
|
+
routing_choice?: {
|
|
687
|
+
selected_agent: string;
|
|
688
|
+
composite_score: number;
|
|
689
|
+
sub_scores: Record<string, number>;
|
|
690
|
+
routing_paths: string[][];
|
|
691
|
+
alternatives_considered: number;
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* A key succession record proving that one Ed25519 key has been replaced by another.
|
|
696
|
+
* Both the old and new keys sign the record, creating a cryptographic chain of custody.
|
|
697
|
+
* Structurally compatible with @motebit/crypto KeySuccessionRecord.
|
|
698
|
+
*/
|
|
699
|
+
export interface KeySuccessionRecord {
|
|
700
|
+
old_public_key: string;
|
|
701
|
+
new_public_key: string;
|
|
702
|
+
timestamp: number;
|
|
703
|
+
reason?: string;
|
|
704
|
+
old_key_signature: string;
|
|
705
|
+
new_key_signature: string;
|
|
706
|
+
}
|
|
707
|
+
/** Result of verifying a key succession chain. */
|
|
708
|
+
export interface SuccessionChainResult {
|
|
709
|
+
valid: boolean;
|
|
710
|
+
/** The original (genesis) public key. */
|
|
711
|
+
genesis_public_key: string;
|
|
712
|
+
/** The current (active) public key. */
|
|
713
|
+
current_public_key: string;
|
|
714
|
+
/** Number of key rotations. */
|
|
715
|
+
length: number;
|
|
716
|
+
/** If invalid, the index of the first broken link and error. */
|
|
717
|
+
error?: {
|
|
718
|
+
index: number;
|
|
719
|
+
message: string;
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
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";
|
|
723
|
+
export interface ExecutionTimelineEntry {
|
|
724
|
+
timestamp: number;
|
|
725
|
+
type: ExecutionTimelineType;
|
|
726
|
+
payload: Record<string, unknown>;
|
|
727
|
+
}
|
|
728
|
+
export interface ExecutionStepSummary {
|
|
729
|
+
step_id: string;
|
|
730
|
+
ordinal: number;
|
|
731
|
+
description: string;
|
|
732
|
+
status: string;
|
|
733
|
+
tools_used: string[];
|
|
734
|
+
tool_calls: number;
|
|
735
|
+
started_at: number | null;
|
|
736
|
+
completed_at: number | null;
|
|
737
|
+
delegation?: {
|
|
738
|
+
task_id: string;
|
|
739
|
+
receipt_hash?: string;
|
|
740
|
+
/** Routing provenance: why this agent was selected for delegation. */
|
|
741
|
+
routing_choice?: {
|
|
742
|
+
selected_agent: string;
|
|
743
|
+
composite_score: number;
|
|
744
|
+
sub_scores: {
|
|
745
|
+
trust: number;
|
|
746
|
+
success_rate: number;
|
|
747
|
+
latency: number;
|
|
748
|
+
price_efficiency: number;
|
|
749
|
+
capability_match: number;
|
|
750
|
+
availability: number;
|
|
751
|
+
};
|
|
752
|
+
/** Derivation paths through the agent graph. */
|
|
753
|
+
routing_paths: string[][];
|
|
754
|
+
/** Number of candidate agents that were scored. */
|
|
755
|
+
alternatives_considered: number;
|
|
756
|
+
};
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
export interface GoalExecutionManifest {
|
|
760
|
+
spec: "motebit/execution-ledger@1.0";
|
|
761
|
+
motebit_id: string;
|
|
762
|
+
goal_id: string;
|
|
763
|
+
plan_id: string;
|
|
764
|
+
started_at: number;
|
|
765
|
+
completed_at: number;
|
|
766
|
+
status: "completed" | "failed" | "paused" | "active";
|
|
767
|
+
timeline: ExecutionTimelineEntry[];
|
|
768
|
+
steps: ExecutionStepSummary[];
|
|
769
|
+
delegation_receipts: DelegationReceiptSummary[];
|
|
770
|
+
content_hash: string;
|
|
771
|
+
signature?: string;
|
|
772
|
+
}
|
|
773
|
+
export interface DelegationReceiptSummary {
|
|
774
|
+
task_id: string;
|
|
459
775
|
motebit_id: string;
|
|
776
|
+
device_id: string;
|
|
777
|
+
status: string;
|
|
778
|
+
completed_at: number;
|
|
779
|
+
tools_used: string[];
|
|
780
|
+
signature_prefix: string;
|
|
781
|
+
}
|
|
782
|
+
export interface AgentCapabilities {
|
|
783
|
+
motebit_id: MotebitId;
|
|
460
784
|
public_key: string;
|
|
785
|
+
/** W3C did:key URI derived from the Ed25519 public key. */
|
|
786
|
+
did?: string;
|
|
461
787
|
tools: string[];
|
|
462
788
|
governance: {
|
|
463
789
|
trust_mode: string;
|
|
@@ -467,4 +793,445 @@ export interface AgentCapabilities {
|
|
|
467
793
|
};
|
|
468
794
|
online_devices: number;
|
|
469
795
|
}
|
|
796
|
+
export interface CapabilityPrice {
|
|
797
|
+
capability: string;
|
|
798
|
+
unit_cost: number;
|
|
799
|
+
currency: string;
|
|
800
|
+
per: "task" | "tool_call" | "token";
|
|
801
|
+
}
|
|
802
|
+
export interface AgentServiceListing {
|
|
803
|
+
listing_id: ListingId;
|
|
804
|
+
motebit_id: MotebitId;
|
|
805
|
+
capabilities: string[];
|
|
806
|
+
pricing: CapabilityPrice[];
|
|
807
|
+
sla: {
|
|
808
|
+
max_latency_ms: number;
|
|
809
|
+
availability_guarantee: number;
|
|
810
|
+
};
|
|
811
|
+
description: string;
|
|
812
|
+
/** Wallet address for x402 on-chain payment settlement (e.g. "0x..." for EVM). */
|
|
813
|
+
pay_to_address?: string;
|
|
814
|
+
/**
|
|
815
|
+
* Self-declared regulatory risk score [0, ∞). 0 = no risk, higher = more risk.
|
|
816
|
+
* Accumulates along delegation chains via RegulatoryRiskSemiring (min, +).
|
|
817
|
+
* Sources: jurisdiction, data handling classification, compliance certifications,
|
|
818
|
+
* audit requirements. The score is declared by the agent; verification is via
|
|
819
|
+
* credentials (e.g. compliance attestation VCs).
|
|
820
|
+
*/
|
|
821
|
+
regulatory_risk?: number;
|
|
822
|
+
updated_at: number;
|
|
823
|
+
}
|
|
824
|
+
export interface RouteScore {
|
|
825
|
+
motebit_id: MotebitId;
|
|
826
|
+
composite: number;
|
|
827
|
+
sub_scores: {
|
|
828
|
+
trust: number;
|
|
829
|
+
success_rate: number;
|
|
830
|
+
latency: number;
|
|
831
|
+
price_efficiency: number;
|
|
832
|
+
capability_match: number;
|
|
833
|
+
availability: number;
|
|
834
|
+
};
|
|
835
|
+
selected: boolean;
|
|
836
|
+
}
|
|
837
|
+
export interface BudgetAllocation {
|
|
838
|
+
allocation_id: AllocationId;
|
|
839
|
+
goal_id: GoalId;
|
|
840
|
+
candidate_motebit_id: MotebitId;
|
|
841
|
+
amount_locked: number;
|
|
842
|
+
currency: string;
|
|
843
|
+
created_at: number;
|
|
844
|
+
status: "locked" | "settled" | "released" | "disputed";
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* The relay's settlement fee rate (5%).
|
|
848
|
+
* Applied to every completed or partial settlement that flows through the relay.
|
|
849
|
+
* This is the Stripe model: the relay proves the work happened, takes its cut.
|
|
850
|
+
*/
|
|
851
|
+
export declare const PLATFORM_FEE_RATE = 0.05;
|
|
852
|
+
export interface SettlementRecord {
|
|
853
|
+
settlement_id: SettlementId;
|
|
854
|
+
allocation_id: AllocationId;
|
|
855
|
+
receipt_hash: string;
|
|
856
|
+
ledger_hash: string | null;
|
|
857
|
+
/** Amount paid to the executing agent (after platform fee deduction). */
|
|
858
|
+
amount_settled: number;
|
|
859
|
+
/** Platform fee extracted by the relay. */
|
|
860
|
+
platform_fee: number;
|
|
861
|
+
/** Fee rate applied (e.g. 0.05 = 5%). Recorded per-settlement for auditability. */
|
|
862
|
+
platform_fee_rate: number;
|
|
863
|
+
/** x402 payment transaction hash (when paid on-chain). */
|
|
864
|
+
x402_tx_hash?: string;
|
|
865
|
+
/** x402 network used for payment (CAIP-2 identifier). */
|
|
866
|
+
x402_network?: string;
|
|
867
|
+
status: "completed" | "partial" | "refunded";
|
|
868
|
+
settled_at: number;
|
|
869
|
+
}
|
|
870
|
+
export interface CollaborativePlanProposal {
|
|
871
|
+
proposal_id: ProposalId;
|
|
872
|
+
plan_id: PlanId;
|
|
873
|
+
initiator_motebit_id: MotebitId;
|
|
874
|
+
participants: ProposalParticipant[];
|
|
875
|
+
status: ProposalStatus;
|
|
876
|
+
created_at: number;
|
|
877
|
+
expires_at: number;
|
|
878
|
+
updated_at: number;
|
|
879
|
+
}
|
|
880
|
+
export interface ProposalParticipant {
|
|
881
|
+
motebit_id: MotebitId;
|
|
882
|
+
assigned_steps: number[];
|
|
883
|
+
response: ProposalResponseType | null;
|
|
884
|
+
responded_at: number | null;
|
|
885
|
+
counter_steps?: ProposalStepCounter[];
|
|
886
|
+
}
|
|
887
|
+
export interface ProposalStepCounter {
|
|
888
|
+
ordinal: number;
|
|
889
|
+
description?: string;
|
|
890
|
+
prompt?: string;
|
|
891
|
+
reason: string;
|
|
892
|
+
}
|
|
893
|
+
export interface ProposalResponse {
|
|
894
|
+
proposal_id: ProposalId;
|
|
895
|
+
responder_motebit_id: MotebitId;
|
|
896
|
+
response: ProposalResponseType;
|
|
897
|
+
counter_steps?: ProposalStepCounter[];
|
|
898
|
+
signature: string;
|
|
899
|
+
}
|
|
900
|
+
export interface CollaborativeReceipt {
|
|
901
|
+
proposal_id: ProposalId;
|
|
902
|
+
plan_id: PlanId;
|
|
903
|
+
participant_receipts: ExecutionReceipt[];
|
|
904
|
+
content_hash: string;
|
|
905
|
+
initiator_signature: string;
|
|
906
|
+
}
|
|
907
|
+
export interface MarketConfig {
|
|
908
|
+
weight_trust: number;
|
|
909
|
+
weight_success_rate: number;
|
|
910
|
+
weight_latency: number;
|
|
911
|
+
weight_price_efficiency: number;
|
|
912
|
+
weight_capability_match: number;
|
|
913
|
+
weight_availability: number;
|
|
914
|
+
latency_norm_k: number;
|
|
915
|
+
max_candidates: number;
|
|
916
|
+
settlement_timeout_ms: number;
|
|
917
|
+
/** Exploration weight [0-1]: 0 = pure exploitation, 1 = pure exploration. Default 0. */
|
|
918
|
+
exploration_weight?: number;
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Precision weights derived from the intelligence gradient.
|
|
922
|
+
*
|
|
923
|
+
* In active inference, precision modulates the balance between epistemic value
|
|
924
|
+
* (exploration/curiosity) and pragmatic value (exploitation/reputation).
|
|
925
|
+
* The gradient measures model evidence; precision is the agent's confidence
|
|
926
|
+
* in its own generative model.
|
|
927
|
+
*
|
|
928
|
+
* High gradient → high self-trust → exploit known-good routes, trust memory.
|
|
929
|
+
* Low gradient → low self-trust → explore, diversify, question memory.
|
|
930
|
+
*/
|
|
931
|
+
export declare const VC_TYPE_GRADIENT = "AgentGradientCredential";
|
|
932
|
+
export declare const VC_TYPE_REPUTATION = "AgentReputationCredential";
|
|
933
|
+
export declare const VC_TYPE_TRUST = "AgentTrustCredential";
|
|
934
|
+
export interface GradientCredentialSubject {
|
|
935
|
+
id: string;
|
|
936
|
+
gradient: number;
|
|
937
|
+
knowledge_density: number;
|
|
938
|
+
knowledge_quality: number;
|
|
939
|
+
graph_connectivity: number;
|
|
940
|
+
temporal_stability: number;
|
|
941
|
+
retrieval_quality: number;
|
|
942
|
+
interaction_efficiency: number;
|
|
943
|
+
tool_efficiency: number;
|
|
944
|
+
curiosity_pressure: number;
|
|
945
|
+
measured_at: number;
|
|
946
|
+
}
|
|
947
|
+
export interface ReputationCredentialSubject {
|
|
948
|
+
id: string;
|
|
949
|
+
success_rate: number;
|
|
950
|
+
avg_latency_ms: number;
|
|
951
|
+
task_count: number;
|
|
952
|
+
trust_score: number;
|
|
953
|
+
availability: number;
|
|
954
|
+
sample_size: number;
|
|
955
|
+
measured_at: number;
|
|
956
|
+
}
|
|
957
|
+
export interface TrustCredentialSubject {
|
|
958
|
+
id: string;
|
|
959
|
+
trust_level: string;
|
|
960
|
+
interaction_count: number;
|
|
961
|
+
successful_tasks: number;
|
|
962
|
+
failed_tasks: number;
|
|
963
|
+
first_seen_at: number;
|
|
964
|
+
last_seen_at: number;
|
|
965
|
+
}
|
|
966
|
+
export interface PrecisionWeights {
|
|
967
|
+
/** Overall self-trust [0-1]. Sigmoid of composite gradient. */
|
|
968
|
+
selfTrust: number;
|
|
969
|
+
/** Exploration drive [0-1]. Inverse of self-trust, modulated by gradient delta. */
|
|
970
|
+
explorationDrive: number;
|
|
971
|
+
/** Memory retrieval precision [0-1]. High = trust similarity, low = diversify. */
|
|
972
|
+
retrievalPrecision: number;
|
|
973
|
+
/** Curiosity modulation [0-1]. Fed back into state vector curiosity field. */
|
|
974
|
+
curiosityModulation: number;
|
|
975
|
+
}
|
|
976
|
+
export interface ConversationStoreAdapter {
|
|
977
|
+
createConversation(motebitId: string): string;
|
|
978
|
+
appendMessage(conversationId: string, motebitId: string, msg: {
|
|
979
|
+
role: string;
|
|
980
|
+
content: string;
|
|
981
|
+
toolCalls?: string;
|
|
982
|
+
toolCallId?: string;
|
|
983
|
+
}): void;
|
|
984
|
+
loadMessages(conversationId: string, limit?: number): Array<{
|
|
985
|
+
messageId: string;
|
|
986
|
+
conversationId: string;
|
|
987
|
+
motebitId: string;
|
|
988
|
+
role: string;
|
|
989
|
+
content: string;
|
|
990
|
+
toolCalls: string | null;
|
|
991
|
+
toolCallId: string | null;
|
|
992
|
+
createdAt: number;
|
|
993
|
+
tokenEstimate: number;
|
|
994
|
+
}>;
|
|
995
|
+
getActiveConversation(motebitId: string): {
|
|
996
|
+
conversationId: string;
|
|
997
|
+
startedAt: number;
|
|
998
|
+
lastActiveAt: number;
|
|
999
|
+
summary: string | null;
|
|
1000
|
+
} | null;
|
|
1001
|
+
updateSummary(conversationId: string, summary: string): void;
|
|
1002
|
+
updateTitle(conversationId: string, title: string): void;
|
|
1003
|
+
listConversations(motebitId: string, limit?: number): Array<{
|
|
1004
|
+
conversationId: string;
|
|
1005
|
+
startedAt: number;
|
|
1006
|
+
lastActiveAt: number;
|
|
1007
|
+
title: string | null;
|
|
1008
|
+
messageCount: number;
|
|
1009
|
+
}>;
|
|
1010
|
+
deleteConversation(conversationId: string): void;
|
|
1011
|
+
}
|
|
1012
|
+
export interface StateSnapshotAdapter {
|
|
1013
|
+
saveState(motebitId: string, stateJson: string, versionClock?: number): void;
|
|
1014
|
+
loadState(motebitId: string): string | null;
|
|
1015
|
+
/** Version clock at last snapshot — used to determine what's safe to compact. */
|
|
1016
|
+
getSnapshotClock?(motebitId: string): number;
|
|
1017
|
+
}
|
|
1018
|
+
export interface KeyringAdapter {
|
|
1019
|
+
get(key: string): Promise<string | null>;
|
|
1020
|
+
set(key: string, value: string): Promise<void>;
|
|
1021
|
+
delete(key: string): Promise<void>;
|
|
1022
|
+
}
|
|
1023
|
+
export interface AgentTrustStoreAdapter {
|
|
1024
|
+
getAgentTrust(motebitId: string, remoteMotebitId: string): Promise<AgentTrustRecord | null>;
|
|
1025
|
+
setAgentTrust(record: AgentTrustRecord): Promise<void>;
|
|
1026
|
+
listAgentTrust(motebitId: string): Promise<AgentTrustRecord[]>;
|
|
1027
|
+
updateTrustLevel(motebitId: string, remoteMotebitId: string, level: AgentTrustLevel): Promise<void>;
|
|
1028
|
+
}
|
|
1029
|
+
export interface ServiceListingStoreAdapter {
|
|
1030
|
+
get(motebitId: string): Promise<AgentServiceListing | null>;
|
|
1031
|
+
set(listing: AgentServiceListing): Promise<void>;
|
|
1032
|
+
list(): Promise<AgentServiceListing[]>;
|
|
1033
|
+
delete(listingId: string): Promise<void>;
|
|
1034
|
+
}
|
|
1035
|
+
export interface BudgetAllocationStoreAdapter {
|
|
1036
|
+
get(allocationId: string): Promise<BudgetAllocation | null>;
|
|
1037
|
+
create(allocation: BudgetAllocation): Promise<void>;
|
|
1038
|
+
updateStatus(allocationId: string, status: string): Promise<void>;
|
|
1039
|
+
listByGoal(goalId: string): Promise<BudgetAllocation[]>;
|
|
1040
|
+
}
|
|
1041
|
+
export interface SettlementStoreAdapter {
|
|
1042
|
+
get(settlementId: string): Promise<SettlementRecord | null>;
|
|
1043
|
+
create(settlement: SettlementRecord): Promise<void>;
|
|
1044
|
+
listByAllocation(allocationId: string): Promise<SettlementRecord[]>;
|
|
1045
|
+
}
|
|
1046
|
+
export interface LatencyStatsStoreAdapter {
|
|
1047
|
+
record(motebitId: string, remoteMotebitId: string, latencyMs: number): Promise<void>;
|
|
1048
|
+
getStats(motebitId: string, remoteMotebitId: string, limit?: number): Promise<{
|
|
1049
|
+
avg_ms: number;
|
|
1050
|
+
p95_ms: number;
|
|
1051
|
+
sample_count: number;
|
|
1052
|
+
}>;
|
|
1053
|
+
}
|
|
1054
|
+
export interface GradientSnapshot {
|
|
1055
|
+
motebit_id: string;
|
|
1056
|
+
timestamp: number;
|
|
1057
|
+
gradient: number;
|
|
1058
|
+
delta: number;
|
|
1059
|
+
knowledge_density: number;
|
|
1060
|
+
knowledge_density_raw: number;
|
|
1061
|
+
knowledge_quality: number;
|
|
1062
|
+
graph_connectivity: number;
|
|
1063
|
+
graph_connectivity_raw: number;
|
|
1064
|
+
temporal_stability: number;
|
|
1065
|
+
retrieval_quality: number;
|
|
1066
|
+
interaction_efficiency: number;
|
|
1067
|
+
tool_efficiency: number;
|
|
1068
|
+
curiosity_pressure: number;
|
|
1069
|
+
stats: {
|
|
1070
|
+
live_nodes: number;
|
|
1071
|
+
live_edges: number;
|
|
1072
|
+
semantic_count: number;
|
|
1073
|
+
episodic_count: number;
|
|
1074
|
+
pinned_count: number;
|
|
1075
|
+
avg_confidence: number;
|
|
1076
|
+
avg_half_life: number;
|
|
1077
|
+
consolidation_add: number;
|
|
1078
|
+
consolidation_update: number;
|
|
1079
|
+
consolidation_reinforce: number;
|
|
1080
|
+
consolidation_noop: number;
|
|
1081
|
+
total_confidence_mass: number;
|
|
1082
|
+
avg_retrieval_score: number;
|
|
1083
|
+
retrieval_count: number;
|
|
1084
|
+
avg_iterations_per_turn: number;
|
|
1085
|
+
total_turns: number;
|
|
1086
|
+
tool_calls_succeeded: number;
|
|
1087
|
+
tool_calls_blocked: number;
|
|
1088
|
+
tool_calls_failed: number;
|
|
1089
|
+
curiosity_target_count: number;
|
|
1090
|
+
avg_curiosity_score: number;
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
export interface GradientStoreAdapter {
|
|
1094
|
+
save(snapshot: GradientSnapshot): void;
|
|
1095
|
+
latest(motebitId: string): GradientSnapshot | null;
|
|
1096
|
+
list(motebitId: string, limit?: number): GradientSnapshot[];
|
|
1097
|
+
}
|
|
1098
|
+
export interface EventFilter {
|
|
1099
|
+
motebit_id?: string;
|
|
1100
|
+
event_types?: EventType[];
|
|
1101
|
+
after_timestamp?: number;
|
|
1102
|
+
before_timestamp?: number;
|
|
1103
|
+
after_version_clock?: number;
|
|
1104
|
+
limit?: number;
|
|
1105
|
+
}
|
|
1106
|
+
export interface EventStoreAdapter {
|
|
1107
|
+
append(entry: EventLogEntry): Promise<void>;
|
|
1108
|
+
query(filter: EventFilter): Promise<EventLogEntry[]>;
|
|
1109
|
+
getLatestClock(motebitId: string): Promise<number>;
|
|
1110
|
+
tombstone(eventId: string, motebitId: string): Promise<void>;
|
|
1111
|
+
/** Delete events with version_clock <= beforeClock. Returns count deleted. */
|
|
1112
|
+
compact?(motebitId: string, beforeClock: number): Promise<number>;
|
|
1113
|
+
/** Count total events for a motebit. */
|
|
1114
|
+
countEvents?(motebitId: string): Promise<number>;
|
|
1115
|
+
}
|
|
1116
|
+
export interface MemoryQuery {
|
|
1117
|
+
motebit_id: string;
|
|
1118
|
+
min_confidence?: number;
|
|
1119
|
+
sensitivity_filter?: SensitivityLevel[];
|
|
1120
|
+
limit?: number;
|
|
1121
|
+
include_tombstoned?: boolean;
|
|
1122
|
+
pinned?: boolean;
|
|
1123
|
+
}
|
|
1124
|
+
export interface MemoryStorageAdapter {
|
|
1125
|
+
saveNode(node: MemoryNode): Promise<void>;
|
|
1126
|
+
getNode(nodeId: string): Promise<MemoryNode | null>;
|
|
1127
|
+
queryNodes(query: MemoryQuery): Promise<MemoryNode[]>;
|
|
1128
|
+
saveEdge(edge: MemoryEdge): Promise<void>;
|
|
1129
|
+
getEdges(nodeId: string): Promise<MemoryEdge[]>;
|
|
1130
|
+
tombstoneNode(nodeId: string): Promise<void>;
|
|
1131
|
+
/** Tombstone with ownership check. Returns true if the node existed and belonged to motebitId. */
|
|
1132
|
+
tombstoneNodeOwned?(nodeId: string, motebitId: string): Promise<boolean>;
|
|
1133
|
+
pinNode(nodeId: string, pinned: boolean): Promise<void>;
|
|
1134
|
+
getAllNodes(motebitId: string): Promise<MemoryNode[]>;
|
|
1135
|
+
getAllEdges(motebitId: string): Promise<MemoryEdge[]>;
|
|
1136
|
+
}
|
|
1137
|
+
export interface DeviceRegistration {
|
|
1138
|
+
device_id: string;
|
|
1139
|
+
motebit_id: string;
|
|
1140
|
+
device_token: string;
|
|
1141
|
+
public_key: string;
|
|
1142
|
+
registered_at: number;
|
|
1143
|
+
device_name?: string;
|
|
1144
|
+
}
|
|
1145
|
+
export interface IdentityStorage {
|
|
1146
|
+
save(identity: MotebitIdentity): Promise<void>;
|
|
1147
|
+
load(motebitId: string): Promise<MotebitIdentity | null>;
|
|
1148
|
+
loadByOwner(ownerId: string): Promise<MotebitIdentity | null>;
|
|
1149
|
+
saveDevice?(device: DeviceRegistration): Promise<void>;
|
|
1150
|
+
loadDevice?(deviceId: string): Promise<DeviceRegistration | null>;
|
|
1151
|
+
loadDeviceByToken?(token: string): Promise<DeviceRegistration | null>;
|
|
1152
|
+
listDevices?(motebitId: string): Promise<DeviceRegistration[]>;
|
|
1153
|
+
}
|
|
1154
|
+
export interface AuditLogAdapter {
|
|
1155
|
+
record(entry: AuditRecord): Promise<void>;
|
|
1156
|
+
query(motebitId: string, options?: {
|
|
1157
|
+
limit?: number;
|
|
1158
|
+
after?: number;
|
|
1159
|
+
}): Promise<AuditRecord[]>;
|
|
1160
|
+
}
|
|
1161
|
+
export interface AuditStatsSince {
|
|
1162
|
+
distinctTurns: number;
|
|
1163
|
+
totalToolCalls: number;
|
|
1164
|
+
succeeded: number;
|
|
1165
|
+
blocked: number;
|
|
1166
|
+
failed: number;
|
|
1167
|
+
}
|
|
1168
|
+
export interface AuditLogSink {
|
|
1169
|
+
append(entry: ToolAuditEntry): void;
|
|
1170
|
+
query(turnId: string): ToolAuditEntry[];
|
|
1171
|
+
getAll(): ToolAuditEntry[];
|
|
1172
|
+
queryStatsSince(afterTimestamp: number): AuditStatsSince;
|
|
1173
|
+
/** Query tool audit entries by run_id (plan execution). Optional — returns [] if not implemented. */
|
|
1174
|
+
queryByRunId?(runId: string): ToolAuditEntry[];
|
|
1175
|
+
}
|
|
1176
|
+
export interface PlanStoreAdapter {
|
|
1177
|
+
savePlan(plan: Plan): void;
|
|
1178
|
+
getPlan(planId: string): Plan | null;
|
|
1179
|
+
getPlanForGoal(goalId: string): Plan | null;
|
|
1180
|
+
updatePlan(planId: string, updates: Partial<Plan>): void;
|
|
1181
|
+
saveStep(step: PlanStep): void;
|
|
1182
|
+
getStep(stepId: string): PlanStep | null;
|
|
1183
|
+
getStepsForPlan(planId: string): PlanStep[];
|
|
1184
|
+
updateStep(stepId: string, updates: Partial<PlanStep>): void;
|
|
1185
|
+
getNextPendingStep(planId: string): PlanStep | null;
|
|
1186
|
+
/** List all active plans for a motebit. Optional — returns [] if not implemented. */
|
|
1187
|
+
listActivePlans?(motebitId: string): Plan[];
|
|
1188
|
+
}
|
|
1189
|
+
/** Stored credential record — JSON-serialized VC with metadata. */
|
|
1190
|
+
export interface StoredCredential {
|
|
1191
|
+
credential_id: string;
|
|
1192
|
+
/** The agent the credential is about (credentialSubject.id). */
|
|
1193
|
+
subject_motebit_id: string;
|
|
1194
|
+
/** did:key of the issuer. */
|
|
1195
|
+
issuer_did: string;
|
|
1196
|
+
/** e.g. "AgentReputationCredential", "AgentTrustCredential", "AgentGradientCredential". */
|
|
1197
|
+
credential_type: string;
|
|
1198
|
+
/** Full JSON-serialized VerifiableCredential. */
|
|
1199
|
+
credential_json: string;
|
|
1200
|
+
issued_at: number;
|
|
1201
|
+
}
|
|
1202
|
+
export interface CredentialStoreAdapter {
|
|
1203
|
+
save(credential: StoredCredential): void;
|
|
1204
|
+
/** List credentials about a specific subject agent. */
|
|
1205
|
+
listBySubject(subjectMotebitId: string, limit?: number): StoredCredential[];
|
|
1206
|
+
/** List all credentials, optionally filtered by type. */
|
|
1207
|
+
list(motebitId: string, type?: string, limit?: number): StoredCredential[];
|
|
1208
|
+
}
|
|
1209
|
+
export interface ApprovalStoreAdapter {
|
|
1210
|
+
/** Collect a quorum approval vote. Returns whether threshold is met and collected voter IDs. */
|
|
1211
|
+
collectApproval(approvalId: string, approverId: string): {
|
|
1212
|
+
met: boolean;
|
|
1213
|
+
collected: string[];
|
|
1214
|
+
};
|
|
1215
|
+
/** Set quorum metadata on a pending approval item. */
|
|
1216
|
+
setQuorum(approvalId: string, required: number, approvers: string[]): void;
|
|
1217
|
+
}
|
|
1218
|
+
export interface StorageAdapters {
|
|
1219
|
+
eventStore: EventStoreAdapter;
|
|
1220
|
+
memoryStorage: MemoryStorageAdapter;
|
|
1221
|
+
identityStorage: IdentityStorage;
|
|
1222
|
+
auditLog: AuditLogAdapter;
|
|
1223
|
+
stateSnapshot?: StateSnapshotAdapter;
|
|
1224
|
+
toolAuditSink?: AuditLogSink;
|
|
1225
|
+
conversationStore?: ConversationStoreAdapter;
|
|
1226
|
+
planStore?: PlanStoreAdapter;
|
|
1227
|
+
gradientStore?: GradientStoreAdapter;
|
|
1228
|
+
agentTrustStore?: AgentTrustStoreAdapter;
|
|
1229
|
+
serviceListingStore?: ServiceListingStoreAdapter;
|
|
1230
|
+
budgetAllocationStore?: BudgetAllocationStoreAdapter;
|
|
1231
|
+
settlementStore?: SettlementStoreAdapter;
|
|
1232
|
+
latencyStatsStore?: LatencyStatsStoreAdapter;
|
|
1233
|
+
credentialStore?: CredentialStoreAdapter;
|
|
1234
|
+
approvalStore?: ApprovalStoreAdapter;
|
|
1235
|
+
}
|
|
1236
|
+
export {};
|
|
470
1237
|
//# sourceMappingURL=index.d.ts.map
|