dsclaw 0.1.7 → 0.1.9

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/dist/index.d.ts CHANGED
@@ -1,2 +1,687 @@
1
+ import pino from 'pino';
2
+ import { z } from 'zod';
3
+ import CircuitBreaker from 'opossum';
4
+ import pLimit from 'p-limit';
5
+ import { Job } from 'bullmq';
1
6
 
2
- export { }
7
+ /**
8
+ * Structured error classification for DropClaw.
9
+ * Every error flowing through the system must have a category
10
+ * so upstream layers (agents, channels) know how to react.
11
+ */
12
+ declare const ErrorCategory: {
13
+ readonly RETRYABLE: "RETRYABLE";
14
+ readonly NEEDS_HUMAN: "NEEDS_HUMAN";
15
+ readonly NEEDS_DATA: "NEEDS_DATA";
16
+ readonly FATAL: "FATAL";
17
+ readonly DEGRADED: "DEGRADED";
18
+ };
19
+ type ErrorCategory = (typeof ErrorCategory)[keyof typeof ErrorCategory];
20
+ interface StructuredError {
21
+ category: ErrorCategory;
22
+ code: string;
23
+ message: string;
24
+ retryable: boolean;
25
+ details?: Record<string, unknown>;
26
+ cause?: Error;
27
+ }
28
+ declare class DropClawError extends Error {
29
+ readonly category: ErrorCategory;
30
+ readonly code: string;
31
+ readonly retryable: boolean;
32
+ readonly details?: Record<string, unknown>;
33
+ constructor(opts: StructuredError);
34
+ toJSON(): StructuredError;
35
+ }
36
+
37
+ /**
38
+ * Structured logger powered by pino.
39
+ * Automatically injects traceId from AsyncLocalStorage.
40
+ */
41
+
42
+ declare function createLogger(module: string): pino.Logger;
43
+
44
+ /**
45
+ * Request-scoped tracing via AsyncLocalStorage.
46
+ * Every inbound message gets a traceId that propagates
47
+ * through agents, tools, API calls, and logs.
48
+ */
49
+ interface TraceContext {
50
+ traceId: string;
51
+ userId?: string;
52
+ channelId?: string;
53
+ sessionId?: string;
54
+ agentId?: string;
55
+ }
56
+ declare function runWithTrace<T>(ctx: Partial<TraceContext>, fn: () => T): T;
57
+ declare function getTraceContext(): TraceContext;
58
+ declare function getTraceId(): string;
59
+
60
+ /**
61
+ * Generate an idempotency key from operation parameters.
62
+ * Uses a 5-minute time bucket so the same operation within
63
+ * 5 minutes is considered duplicate.
64
+ */
65
+ declare function idempotencyKey(userId: string, action: string, params: Record<string, unknown>): string;
66
+ /**
67
+ * Sleep for a given number of milliseconds.
68
+ */
69
+ declare function sleep(ms: number): Promise<void>;
70
+ /**
71
+ * Parse Retry-After header value to milliseconds.
72
+ * Supports both seconds (integer) and HTTP-date formats.
73
+ */
74
+ declare function parseRetryAfter(value: string | null): number | null;
75
+
76
+ /**
77
+ * Audit log for tracking all write operations.
78
+ * Every action an agent takes is recorded so the user
79
+ * can always answer "what did the bot do?"
80
+ */
81
+ interface AuditEntry {
82
+ timestamp: string;
83
+ traceId: string;
84
+ userId: string;
85
+ agentId: string;
86
+ action: string;
87
+ target: string;
88
+ params?: Record<string, unknown>;
89
+ result: "success" | "failed" | "pending";
90
+ error?: string;
91
+ }
92
+ declare function writeAuditLog(entry: Omit<AuditEntry, "timestamp" | "traceId">): void;
93
+ declare function auditFilePath(date: string): string;
94
+
95
+ /**
96
+ * Configuration loader with JSON5 support and Zod validation.
97
+ * Sensitive fields are protected with chmod 0o600.
98
+ */
99
+
100
+ declare const ConfigSchema: z.ZodObject<{
101
+ dsers: z.ZodObject<{
102
+ apiKey: z.ZodString;
103
+ baseUrl: z.ZodDefault<z.ZodString>;
104
+ }, z.core.$strip>;
105
+ llm: z.ZodObject<{
106
+ provider: z.ZodDefault<z.ZodEnum<{
107
+ openai: "openai";
108
+ anthropic: "anthropic";
109
+ google: "google";
110
+ }>>;
111
+ apiKey: z.ZodString;
112
+ model: z.ZodDefault<z.ZodString>;
113
+ }, z.core.$strip>;
114
+ channels: z.ZodObject<{
115
+ telegram: z.ZodOptional<z.ZodObject<{
116
+ botToken: z.ZodString;
117
+ enabled: z.ZodDefault<z.ZodBoolean>;
118
+ }, z.core.$strip>>;
119
+ feishu: z.ZodOptional<z.ZodObject<{
120
+ appId: z.ZodString;
121
+ appSecret: z.ZodString;
122
+ enabled: z.ZodDefault<z.ZodBoolean>;
123
+ }, z.core.$strip>>;
124
+ whatsapp: z.ZodOptional<z.ZodObject<{
125
+ phoneNumberId: z.ZodString;
126
+ accessToken: z.ZodString;
127
+ enabled: z.ZodDefault<z.ZodBoolean>;
128
+ }, z.core.$strip>>;
129
+ }, z.core.$strip>;
130
+ memory: z.ZodDefault<z.ZodObject<{
131
+ provider: z.ZodDefault<z.ZodEnum<{
132
+ file: "file";
133
+ "mem0-cloud": "mem0-cloud";
134
+ "mem0-local": "mem0-local";
135
+ }>>;
136
+ apiKey: z.ZodOptional<z.ZodString>;
137
+ qdrantUrl: z.ZodOptional<z.ZodString>;
138
+ }, z.core.$strip>>;
139
+ resilience: z.ZodDefault<z.ZodObject<{
140
+ redis: z.ZodDefault<z.ZodString>;
141
+ circuitBreaker: z.ZodDefault<z.ZodObject<{
142
+ threshold: z.ZodDefault<z.ZodNumber>;
143
+ resetTimeout: z.ZodDefault<z.ZodNumber>;
144
+ }, z.core.$strip>>;
145
+ }, z.core.$strip>>;
146
+ scans: z.ZodDefault<z.ZodObject<{
147
+ logistics: z.ZodDefault<z.ZodObject<{
148
+ cron: z.ZodDefault<z.ZodString>;
149
+ enabled: z.ZodDefault<z.ZodBoolean>;
150
+ }, z.core.$strip>>;
151
+ inventory: z.ZodDefault<z.ZodObject<{
152
+ cron: z.ZodDefault<z.ZodString>;
153
+ enabled: z.ZodDefault<z.ZodBoolean>;
154
+ }, z.core.$strip>>;
155
+ profit: z.ZodDefault<z.ZodObject<{
156
+ cron: z.ZodDefault<z.ZodString>;
157
+ enabled: z.ZodDefault<z.ZodBoolean>;
158
+ }, z.core.$strip>>;
159
+ }, z.core.$strip>>;
160
+ agents: z.ZodDefault<z.ZodObject<{
161
+ navigator: z.ZodDefault<z.ZodObject<{
162
+ enabled: z.ZodDefault<z.ZodBoolean>;
163
+ }, z.core.$strip>>;
164
+ clawOps: z.ZodDefault<z.ZodObject<{
165
+ enabled: z.ZodDefault<z.ZodBoolean>;
166
+ }, z.core.$strip>>;
167
+ }, z.core.$strip>>;
168
+ }, z.core.$strip>;
169
+ type DropClawConfig = z.infer<typeof ConfigSchema>;
170
+ declare function loadConfig(path?: string): DropClawConfig;
171
+ declare function saveConfig(config: Record<string, unknown>): void;
172
+
173
+ /**
174
+ * DropClaw Gateway — central orchestrator.
175
+ * Wires: Config → DSers Client → Agent → Channel → Memory → Queue.
176
+ * Handles the message lifecycle from channel input to agent response.
177
+ */
178
+
179
+ declare class DropClawGateway {
180
+ private config;
181
+ private agent;
182
+ private channels;
183
+ private memory;
184
+ private dsers;
185
+ private running;
186
+ constructor(config: DropClawConfig);
187
+ start(): Promise<void>;
188
+ private handleMessage;
189
+ private processWithAgent;
190
+ stop(): Promise<void>;
191
+ isRunning(): boolean;
192
+ }
193
+
194
+ /**
195
+ * DSers API configuration.
196
+ * Adapted from dsers-mcp-product, simplified for DropClaw's
197
+ * config-file-first approach (no env-var credential resolution).
198
+ */
199
+ interface DSersClientConfig {
200
+ baseUrl: string;
201
+ apiKey: string;
202
+ sessionFile: string;
203
+ sessionId?: string;
204
+ sessionState?: string;
205
+ }
206
+ declare function createDSersConfig(apiKey: string, baseUrl?: string): DSersClientConfig;
207
+
208
+ /**
209
+ * Enhanced DSers HTTP client with:
210
+ * - Circuit breaker (opossum)
211
+ * - 429 Retry-After handling
212
+ * - 5xx exponential backoff (max 2 retries)
213
+ * - Structured error classification
214
+ * - traceId injection
215
+ */
216
+
217
+ declare class DSersClient {
218
+ private config;
219
+ private auth;
220
+ private limiter;
221
+ constructor(config: DSersClientConfig);
222
+ request(method: string, path: string, opts?: {
223
+ params?: Record<string, unknown>;
224
+ json?: Record<string, unknown>;
225
+ }, attempt?: number): Promise<Record<string, unknown>>;
226
+ get(path: string, params?: Record<string, unknown>): Promise<Record<string, unknown>>;
227
+ post(path: string, json?: Record<string, unknown>, params?: Record<string, unknown>): Promise<Record<string, unknown>>;
228
+ put(path: string, json?: Record<string, unknown>, params?: Record<string, unknown>): Promise<Record<string, unknown>>;
229
+ del(path: string, params?: Record<string, unknown>): Promise<Record<string, unknown>>;
230
+ }
231
+
232
+ /**
233
+ * Core DSers domain types extracted from the OpenAPI spec.
234
+ * Covers the essential entities for the DropClaw workflow.
235
+ */
236
+ interface DSersStore {
237
+ id: string;
238
+ name: string;
239
+ platform: string;
240
+ url?: string;
241
+ status?: string;
242
+ }
243
+ interface DSersProduct {
244
+ id: string;
245
+ title: string;
246
+ supplyProductId?: string;
247
+ supplyAppId?: number;
248
+ variants?: DSersVariant[];
249
+ images?: string[];
250
+ tags?: string[];
251
+ description?: string;
252
+ }
253
+ interface DSersVariant {
254
+ id: string;
255
+ title: string;
256
+ price: number;
257
+ compareAtPrice?: number;
258
+ cost?: number;
259
+ sku?: string;
260
+ inventory?: number;
261
+ image?: string;
262
+ }
263
+ interface DSersOrder {
264
+ id: string;
265
+ orderNumber?: string;
266
+ status: string;
267
+ storeId: string;
268
+ totalPrice?: number;
269
+ currency?: string;
270
+ createdAt?: string;
271
+ items?: DSersOrderItem[];
272
+ }
273
+ interface DSersOrderItem {
274
+ productId: string;
275
+ variantId: string;
276
+ title: string;
277
+ quantity: number;
278
+ price: number;
279
+ }
280
+ interface PushResult {
281
+ eventId: string;
282
+ status: "pending" | "processing" | "completed" | "failed";
283
+ successCount?: number;
284
+ failedCount?: number;
285
+ errors?: string[];
286
+ }
287
+
288
+ /**
289
+ * Agent base interface and types.
290
+ * All agents (Navigator, Claw-Ops, or the combined prototype)
291
+ * implement this contract.
292
+ */
293
+ interface AgentMessage {
294
+ role: "user" | "assistant" | "system";
295
+ content: string;
296
+ }
297
+ interface AgentTool {
298
+ name: string;
299
+ description: string;
300
+ parameters: Record<string, unknown>;
301
+ execute: (params: Record<string, unknown>) => Promise<AgentToolResult>;
302
+ }
303
+ interface AgentToolResult {
304
+ success: boolean;
305
+ data?: unknown;
306
+ error?: string;
307
+ }
308
+ interface AgentResponse {
309
+ text: string;
310
+ toolCalls?: Array<{
311
+ tool: string;
312
+ params: Record<string, unknown>;
313
+ result: AgentToolResult;
314
+ }>;
315
+ }
316
+ interface AgentContext {
317
+ userId: string;
318
+ sessionId: string;
319
+ channelId: string;
320
+ storeId?: string;
321
+ history: AgentMessage[];
322
+ }
323
+ interface AgentBase {
324
+ readonly id: string;
325
+ readonly name: string;
326
+ registerTool(tool: AgentTool): void;
327
+ removeTool(name: string): void;
328
+ getTools(): AgentTool[];
329
+ process(message: string, context: AgentContext): Promise<AgentResponse>;
330
+ }
331
+
332
+ /**
333
+ * Unified memory provider interface.
334
+ * Implementations: FileMemoryProvider (Plan B), Mem0CloudProvider (Plan C).
335
+ * The interface stays the same — swap implementations without changing agents.
336
+ */
337
+ interface MemoryMeta {
338
+ userId: string;
339
+ sessionId?: string;
340
+ agentId?: string;
341
+ category: MemoryCategory;
342
+ tags?: string[];
343
+ }
344
+ type MemoryCategory = "preference" | "pattern" | "fact";
345
+ interface Memory {
346
+ id: string;
347
+ content: string;
348
+ metadata: MemoryMeta;
349
+ score?: number;
350
+ createdAt: Date;
351
+ updatedAt: Date;
352
+ }
353
+ interface MemoryFilter {
354
+ userId?: string;
355
+ sessionId?: string;
356
+ category?: MemoryCategory;
357
+ tags?: string[];
358
+ limit?: number;
359
+ }
360
+ interface MemoryProvider {
361
+ readonly name: string;
362
+ readonly degraded: boolean;
363
+ add(content: string, metadata: MemoryMeta): Promise<string>;
364
+ search(query: string, filters: MemoryFilter): Promise<Memory[]>;
365
+ getAll(filters: MemoryFilter): Promise<Memory[]>;
366
+ update(id: string, content: string): Promise<void>;
367
+ delete(id: string): Promise<void>;
368
+ }
369
+
370
+ /**
371
+ * DropClaw Core Agent — unified prototype agent using Vercel AI SDK.
372
+ * Combines Navigator (strategy) and Claw-Ops (execution) capabilities.
373
+ * Will be split into two specialized agents in Plan C.
374
+ */
375
+
376
+ declare class DropClawCoreAgent implements AgentBase {
377
+ readonly id = "dropclaw-core";
378
+ readonly name = "DropClaw Core Agent";
379
+ private config;
380
+ private dsers;
381
+ private memory;
382
+ private customTools;
383
+ constructor(config: DropClawConfig, dsers: DSersClient, memory: MemoryProvider);
384
+ registerTool(t: AgentTool): void;
385
+ removeTool(name: string): void;
386
+ getTools(): AgentTool[];
387
+ process(message: string, context: AgentContext): Promise<AgentResponse>;
388
+ private buildAITools;
389
+ }
390
+
391
+ /**
392
+ * Unified channel adapter interface.
393
+ * Every messaging platform (Telegram, WhatsApp, Feishu)
394
+ * implements this contract so the gateway is platform-agnostic.
395
+ */
396
+ interface NormalizedMessage {
397
+ traceId: string;
398
+ channelId: string;
399
+ channelName: string;
400
+ userId: string;
401
+ userName?: string;
402
+ text: string;
403
+ attachments?: Attachment[];
404
+ replyTo?: string;
405
+ timestamp: Date;
406
+ metadata: Record<string, unknown>;
407
+ }
408
+ interface Attachment {
409
+ type: "image" | "file" | "link";
410
+ url?: string;
411
+ data?: Buffer;
412
+ mimeType?: string;
413
+ fileName?: string;
414
+ }
415
+ interface ActionCard {
416
+ title: string;
417
+ summary: string;
418
+ actions: ActionButton[];
419
+ jobId?: string;
420
+ progress?: number;
421
+ }
422
+ interface ActionButton {
423
+ label: string;
424
+ callbackData: string;
425
+ }
426
+ interface OutboundMessage {
427
+ text?: string;
428
+ card?: ActionCard;
429
+ replyToMessageId?: string;
430
+ }
431
+ type MessageHandler = (message: NormalizedMessage) => Promise<void>;
432
+ interface ChannelAdapter {
433
+ readonly name: string;
434
+ readonly connected: boolean;
435
+ connect(config: Record<string, unknown>): Promise<void>;
436
+ disconnect(): Promise<void>;
437
+ reconnect(): Promise<void>;
438
+ onMessage(handler: MessageHandler): void;
439
+ send(targetUserId: string, message: OutboundMessage): Promise<void>;
440
+ sendCard(targetUserId: string, card: ActionCard): Promise<void>;
441
+ }
442
+
443
+ /**
444
+ * Telegram channel adapter using grammY.
445
+ * Normalizes Telegram messages into the unified format,
446
+ * supports inline keyboards for confirmations, and auto-reconnects.
447
+ */
448
+
449
+ declare class TelegramAdapter implements ChannelAdapter {
450
+ readonly name = "telegram";
451
+ private bot;
452
+ private handler;
453
+ private _connected;
454
+ private botToken;
455
+ get connected(): boolean;
456
+ connect(config: Record<string, unknown>): Promise<void>;
457
+ disconnect(): Promise<void>;
458
+ reconnect(): Promise<void>;
459
+ onMessage(handler: MessageHandler): void;
460
+ send(targetUserId: string, message: OutboundMessage): Promise<void>;
461
+ sendCard(targetUserId: string, card: ActionCard): Promise<void>;
462
+ }
463
+
464
+ /**
465
+ * Local JSON-based memory provider.
466
+ * Stores memories as JSONL files, one per user.
467
+ * Simple keyword-based search (no vector embeddings).
468
+ * Replaced by mem0 in Plan C for production use.
469
+ */
470
+
471
+ declare class FileMemoryProvider implements MemoryProvider {
472
+ readonly name = "file";
473
+ readonly degraded = false;
474
+ constructor();
475
+ add(content: string, metadata: MemoryMeta): Promise<string>;
476
+ search(query: string, filters: MemoryFilter): Promise<Memory[]>;
477
+ getAll(filters: MemoryFilter): Promise<Memory[]>;
478
+ update(id: string, content: string): Promise<void>;
479
+ delete(id: string): Promise<void>;
480
+ private userFile;
481
+ }
482
+
483
+ /**
484
+ * Circuit breaker factory wrapping opossum.
485
+ * Each external dependency (DSers, LLM, mem0) gets its own breaker
486
+ * so a single bad dependency cannot take down the entire system.
487
+ */
488
+
489
+ interface BreakerOptions {
490
+ timeout?: number;
491
+ errorThresholdPercentage?: number;
492
+ resetTimeout?: number;
493
+ volumeThreshold?: number;
494
+ name: string;
495
+ }
496
+ declare function createCircuitBreaker<TArgs extends unknown[], TResult>(name: string, fn: (...args: TArgs) => Promise<TResult>, customOpts?: Partial<BreakerOptions>): CircuitBreaker<TArgs, TResult>;
497
+ declare function getAllBreakerStatus(): Record<string, {
498
+ state: string;
499
+ stats: CircuitBreaker.Stats;
500
+ }>;
501
+
502
+ /**
503
+ * Generic retry with exponential backoff + jitter.
504
+ * Respects workspace rule: same error no more than 2 retries.
505
+ */
506
+
507
+ interface RetryOptions {
508
+ maxRetries?: number;
509
+ baseDelay?: number;
510
+ maxDelay?: number;
511
+ retryableCategories?: ErrorCategory[];
512
+ }
513
+ declare function withRetry<T>(fn: () => Promise<T>, opts?: RetryOptions): Promise<T>;
514
+
515
+ /**
516
+ * Three-layer rate limiting:
517
+ * L1 Inbound: per-IP / per-channel flood protection
518
+ * L2 Tenant: per-userId session serialization + debounce
519
+ * L3 Outbound: per-service concurrency cap (DSers, LLM, mem0)
520
+ */
521
+
522
+ interface OutboundLimits {
523
+ dsers: number;
524
+ llm: number;
525
+ mem0: number;
526
+ }
527
+ declare function getOutboundLimiter(service: keyof OutboundLimits, customLimits?: Partial<OutboundLimits>): ReturnType<typeof pLimit>;
528
+ /**
529
+ * Ensure messages from the same user are processed serially.
530
+ * Returns a release function to call when processing is done.
531
+ */
532
+ declare function acquireUserLock(userId: string): Promise<() => void>;
533
+ /**
534
+ * Debounce rapid-fire messages from the same user.
535
+ * Resolves after `delayMs` of silence.
536
+ */
537
+ declare function debounceUser(userId: string, delayMs?: number): Promise<void>;
538
+ /**
539
+ * Check if an inbound source has exceeded the rate limit.
540
+ * @returns true if the request should be allowed, false if throttled.
541
+ */
542
+ declare function checkInboundLimit(sourceId: string, maxRequests?: number, windowMs?: number): boolean;
543
+
544
+ /**
545
+ * Degradation strategies for when external services are unavailable.
546
+ * Each service has a defined fallback path.
547
+ */
548
+ type ServiceName = "dsers" | "llm" | "mem0";
549
+ interface DegradationState {
550
+ service: ServiceName;
551
+ degraded: boolean;
552
+ reason?: string;
553
+ since?: Date;
554
+ fallbackActive: boolean;
555
+ }
556
+ declare function markDegraded(service: ServiceName, reason: string): void;
557
+ declare function markRecovered(service: ServiceName): void;
558
+ declare function isDegraded(service: ServiceName): boolean;
559
+ declare function getDegradationStatus(): DegradationState[];
560
+ /**
561
+ * Produce a user-friendly degradation message for channel output.
562
+ */
563
+ declare function degradationMessage(service: ServiceName): string;
564
+
565
+ /**
566
+ * Job manager interface for BullMQ task queue.
567
+ * Two queues: high-priority (queries, alerts) and low-priority (batch ops).
568
+ */
569
+ type JobPriority = "high" | "low";
570
+ interface JobPayload {
571
+ type: string;
572
+ userId: string;
573
+ agentId: string;
574
+ params: Record<string, unknown>;
575
+ idempotencyKey?: string;
576
+ }
577
+ interface JobStatus {
578
+ id: string;
579
+ state: "waiting" | "active" | "completed" | "failed" | "delayed";
580
+ progress: number;
581
+ result?: unknown;
582
+ error?: string;
583
+ createdAt: Date;
584
+ finishedAt?: Date;
585
+ }
586
+ interface JobManager {
587
+ enqueue(payload: JobPayload, priority?: JobPriority): Promise<string>;
588
+ getStatus(jobId: string): Promise<JobStatus | null>;
589
+ cancel(jobId: string): Promise<boolean>;
590
+ onComplete(handler: (jobId: string, result: unknown) => Promise<void>): void;
591
+ onFailed(handler: (jobId: string, error: string) => Promise<void>): void;
592
+ }
593
+
594
+ /**
595
+ * BullMQ queue manager — dual queues with priority separation.
596
+ * High: queries, alerts, short tasks (timeout 10s)
597
+ * Low: batch imports, sync, bulk operations (timeout 5min)
598
+ */
599
+
600
+ declare class BullMQJobManager implements JobManager {
601
+ private highQueue;
602
+ private lowQueue;
603
+ private connection;
604
+ private highWorker?;
605
+ private lowWorker?;
606
+ private completeHandlers;
607
+ private failedHandlers;
608
+ constructor(redisUrl: string);
609
+ connect(): Promise<void>;
610
+ startWorkers(processor: (job: Job<JobPayload>) => Promise<unknown>): void;
611
+ enqueue(payload: JobPayload, priority?: JobPriority): Promise<string>;
612
+ getStatus(jobId: string): Promise<JobStatus | null>;
613
+ cancel(jobId: string): Promise<boolean>;
614
+ onComplete(handler: (jobId: string, result: unknown) => Promise<void>): void;
615
+ onFailed(handler: (jobId: string, error: string) => Promise<void>): void;
616
+ shutdown(): Promise<void>;
617
+ }
618
+
619
+ /**
620
+ * Rule engine interface for deterministic operations.
621
+ * Rules bypass the LLM — they execute predictable logic
622
+ * like price tracking, inventory thresholds, and format validation.
623
+ */
624
+ interface Rule {
625
+ id: string;
626
+ name: string;
627
+ type: RuleType;
628
+ conditions: RuleCondition[];
629
+ actions: RuleAction[];
630
+ enabled: boolean;
631
+ priority: number;
632
+ }
633
+ type RuleType = "pricing" | "inventory" | "format" | "guard";
634
+ interface RuleCondition {
635
+ field: string;
636
+ operator: "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "contains" | "in";
637
+ value: unknown;
638
+ }
639
+ interface RuleAction {
640
+ type: string;
641
+ params: Record<string, unknown>;
642
+ }
643
+ interface RuleEvaluationResult {
644
+ matched: Rule[];
645
+ actions: RuleAction[];
646
+ warnings: string[];
647
+ blocked: string[];
648
+ }
649
+ interface RuleEngine {
650
+ addRule(rule: Rule): void;
651
+ removeRule(id: string): void;
652
+ getRules(): Rule[];
653
+ evaluate(context: Record<string, unknown>, ruleTypes?: RuleType[]): RuleEvaluationResult;
654
+ }
655
+
656
+ /**
657
+ * OpenClaw plugin manifest and version compatibility.
658
+ * DropClaw registers as an OpenClaw plugin via Plugin SDK
659
+ * when running inside an OpenClaw gateway.
660
+ */
661
+ interface PluginManifest {
662
+ id: string;
663
+ name: string;
664
+ description: string;
665
+ version: string;
666
+ configSchema: Record<string, unknown>;
667
+ kind?: "context-engine";
668
+ channels: string[];
669
+ providers: string[];
670
+ skills: string[];
671
+ }
672
+ declare const DROPCLAW_MANIFEST: PluginManifest;
673
+
674
+ /**
675
+ * Version compatibility check against OpenClaw runtime.
676
+ * Maintains a compatibility matrix to ensure safe upgrades.
677
+ */
678
+ interface CompatEntry {
679
+ openclawVersion: string;
680
+ dropclawVersion: string;
681
+ status: "tested" | "untested" | "incompatible";
682
+ notes?: string;
683
+ }
684
+ declare const COMPAT_MATRIX: CompatEntry[];
685
+ declare function checkCompatibility(openclawVersion: string): CompatEntry | null;
686
+
687
+ export { type ActionCard, type AgentBase, type AgentContext, type AgentResponse, type AgentTool, BullMQJobManager, COMPAT_MATRIX, type ChannelAdapter, ConfigSchema, DROPCLAW_MANIFEST, DSersClient, type DSersClientConfig, type DSersOrder, type DSersProduct, type DSersStore, type DSersVariant, type DropClawConfig, DropClawCoreAgent, DropClawError, DropClawGateway, ErrorCategory, FileMemoryProvider, type JobManager, type JobPayload, type JobStatus, type Memory, type MemoryFilter, type MemoryMeta, type MemoryProvider, type NormalizedMessage, type OutboundMessage, type PushResult, type RetryOptions, type Rule, type RuleEngine, type RuleEvaluationResult, type StructuredError, TelegramAdapter, acquireUserLock, auditFilePath, checkCompatibility, checkInboundLimit, createCircuitBreaker, createDSersConfig, createLogger, debounceUser, degradationMessage, getAllBreakerStatus, getDegradationStatus, getOutboundLimiter, getTraceContext, getTraceId, idempotencyKey, isDegraded, loadConfig, markDegraded, markRecovered, parseRetryAfter, runWithTrace, saveConfig, sleep, withRetry, writeAuditLog };