@questionbase/deskfree 0.3.0-alpha.2 → 0.3.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +24 -14
  2. package/dist/index.d.ts +723 -6
  3. package/dist/index.js +9014 -18
  4. package/dist/index.js.map +1 -1
  5. package/package.json +8 -9
  6. package/skills/deskfree/SKILL.md +339 -224
  7. package/skills/deskfree/references/tools.md +103 -0
  8. package/dist/channel.d.ts +0 -3
  9. package/dist/channel.d.ts.map +0 -1
  10. package/dist/channel.js +0 -505
  11. package/dist/channel.js.map +0 -1
  12. package/dist/client.d.ts +0 -143
  13. package/dist/client.d.ts.map +0 -1
  14. package/dist/client.js +0 -246
  15. package/dist/client.js.map +0 -1
  16. package/dist/deliver.d.ts +0 -22
  17. package/dist/deliver.d.ts.map +0 -1
  18. package/dist/deliver.js +0 -350
  19. package/dist/deliver.js.map +0 -1
  20. package/dist/gateway.d.ts +0 -13
  21. package/dist/gateway.d.ts.map +0 -1
  22. package/dist/gateway.js +0 -836
  23. package/dist/gateway.js.map +0 -1
  24. package/dist/index.d.ts.map +0 -1
  25. package/dist/llm-definitions.d.ts +0 -117
  26. package/dist/llm-definitions.d.ts.map +0 -1
  27. package/dist/llm-definitions.js +0 -121
  28. package/dist/llm-definitions.js.map +0 -1
  29. package/dist/offline-queue.d.ts +0 -45
  30. package/dist/offline-queue.d.ts.map +0 -1
  31. package/dist/offline-queue.js +0 -109
  32. package/dist/offline-queue.js.map +0 -1
  33. package/dist/paths.d.ts +0 -10
  34. package/dist/paths.d.ts.map +0 -1
  35. package/dist/paths.js +0 -29
  36. package/dist/paths.js.map +0 -1
  37. package/dist/runtime.d.ts +0 -17
  38. package/dist/runtime.d.ts.map +0 -1
  39. package/dist/runtime.js +0 -24
  40. package/dist/runtime.js.map +0 -1
  41. package/dist/tools.d.ts +0 -23
  42. package/dist/tools.d.ts.map +0 -1
  43. package/dist/tools.js +0 -437
  44. package/dist/tools.js.map +0 -1
  45. package/dist/types.d.ts +0 -438
  46. package/dist/types.d.ts.map +0 -1
  47. package/dist/types.js +0 -2
  48. package/dist/types.js.map +0 -1
  49. package/dist/workspace.d.ts +0 -18
  50. package/dist/workspace.d.ts.map +0 -1
  51. package/dist/workspace.js +0 -83
  52. package/dist/workspace.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,11 +1,728 @@
1
- import type { OpenClawPluginApi } from './types';
2
- export { DeskFreeClient, DeskFreeError } from './client';
3
- export { OfflineQueue } from './offline-queue';
4
- export type * from './types';
1
+ import { IncomingMessage, ServerResponse } from 'node:http';
2
+
3
+ /**
4
+ * Minimal type definitions for the OpenClaw plugin API.
5
+ * These mirror the actual OpenClaw types but are defined inline
6
+ * to avoid a hard dependency on the openclaw package at build time.
7
+ * At runtime, the real types are provided by OpenClaw.
8
+ */
9
+
10
+ interface AnyAgentTool {
11
+ name: string;
12
+ description: string;
13
+ parameters: Record<string, unknown>;
14
+ execute: (id: string, params: Record<string, unknown>) => Promise<{
15
+ content: Array<{
16
+ type: string;
17
+ text?: string;
18
+ }>;
19
+ }>;
20
+ optional?: boolean;
21
+ }
22
+ interface OpenClawPluginToolContext {
23
+ config?: unknown;
24
+ messageChannel?: unknown;
25
+ agentAccountId?: string;
26
+ sandboxed?: boolean;
27
+ }
28
+ type OpenClawPluginToolFactory = (ctx: OpenClawPluginToolContext) => AnyAgentTool | AnyAgentTool[] | null | undefined;
29
+ interface OpenClawPluginToolOptions {
30
+ optional?: boolean;
31
+ }
32
+ interface OpenClawConfig {
33
+ channels?: {
34
+ deskfree?: DeskFreeChannelConfig;
35
+ [key: string]: unknown;
36
+ };
37
+ plugins?: {
38
+ entries?: {
39
+ [pluginId: string]: {
40
+ enabled?: boolean;
41
+ [key: string]: unknown;
42
+ };
43
+ };
44
+ [key: string]: unknown;
45
+ };
46
+ [key: string]: unknown;
47
+ }
48
+ interface OpenClawPluginApi {
49
+ runtime: PluginRuntime;
50
+ config: OpenClawConfig;
51
+ pluginConfig: Record<string, unknown>;
52
+ logger: PluginLogger;
53
+ registerChannel(registration: {
54
+ plugin: ChannelPlugin;
55
+ }): void;
56
+ registerHttpRoute(params: {
57
+ path: string;
58
+ handler: (req: IncomingMessage, res: ServerResponse) => Promise<void> | void;
59
+ }): void;
60
+ registerTool(tool: AnyAgentTool | OpenClawPluginToolFactory, opts?: OpenClawPluginToolOptions): void;
61
+ registerHook(events: string | string[], handler: (event: Record<string, unknown>) => Promise<unknown> | unknown, opts?: {
62
+ priority?: number;
63
+ }): void;
64
+ on<K extends PluginHookName>(hookName: K, handler: PluginHookHandlerMap[K], opts?: {
65
+ priority?: number;
66
+ }): void;
67
+ }
68
+ type PluginHookName = 'before_agent_start' | 'llm_input' | 'llm_output' | 'agent_end' | 'before_compaction' | 'after_compaction' | 'before_reset' | 'message_received' | 'message_sending' | 'message_sent' | 'before_tool_call' | 'after_tool_call' | 'tool_result_persist' | 'session_start' | 'session_end' | 'gateway_start' | 'gateway_stop';
69
+ interface PluginHookAgentContext {
70
+ agentId?: string;
71
+ sessionKey?: string;
72
+ sessionId?: string;
73
+ workspaceDir?: string;
74
+ messageProvider?: string;
75
+ }
76
+ interface PluginHookBeforeAgentStartEvent {
77
+ prompt: string;
78
+ messages?: unknown[];
79
+ }
80
+ interface PluginHookBeforeAgentStartResult {
81
+ systemPrompt?: string;
82
+ prependContext?: string;
83
+ }
84
+ type PluginHookHandlerMap = {
85
+ before_agent_start: (event: PluginHookBeforeAgentStartEvent, ctx: PluginHookAgentContext) => Promise<PluginHookBeforeAgentStartResult | void> | PluginHookBeforeAgentStartResult | void;
86
+ llm_input: (event: Record<string, unknown>, ctx: PluginHookAgentContext) => Promise<void> | void;
87
+ llm_output: (event: Record<string, unknown>, ctx: PluginHookAgentContext) => Promise<void> | void;
88
+ agent_end: (event: Record<string, unknown>, ctx: PluginHookAgentContext) => Promise<void> | void;
89
+ before_compaction: (event: Record<string, unknown>, ctx: PluginHookAgentContext) => Promise<void> | void;
90
+ after_compaction: (event: Record<string, unknown>, ctx: PluginHookAgentContext) => Promise<void> | void;
91
+ before_reset: (event: Record<string, unknown>, ctx: PluginHookAgentContext) => Promise<void> | void;
92
+ message_received: (event: Record<string, unknown>, ctx: Record<string, unknown>) => Promise<void> | void;
93
+ message_sending: (event: Record<string, unknown>, ctx: Record<string, unknown>) => Promise<Record<string, unknown> | void> | Record<string, unknown> | void;
94
+ message_sent: (event: Record<string, unknown>, ctx: Record<string, unknown>) => Promise<void> | void;
95
+ before_tool_call: (event: Record<string, unknown>, ctx: Record<string, unknown>) => Promise<Record<string, unknown> | void> | Record<string, unknown> | void;
96
+ after_tool_call: (event: Record<string, unknown>, ctx: Record<string, unknown>) => Promise<void> | void;
97
+ tool_result_persist: (event: Record<string, unknown>, ctx: Record<string, unknown>) => Record<string, unknown> | void;
98
+ session_start: (event: Record<string, unknown>, ctx: Record<string, unknown>) => Promise<void> | void;
99
+ session_end: (event: Record<string, unknown>, ctx: Record<string, unknown>) => Promise<void> | void;
100
+ gateway_start: (event: Record<string, unknown>, ctx: Record<string, unknown>) => Promise<void> | void;
101
+ gateway_stop: (event: Record<string, unknown>, ctx: Record<string, unknown>) => Promise<void> | void;
102
+ };
103
+ interface PluginRuntime {
104
+ version: string;
105
+ config: {
106
+ loadConfig(): OpenClawConfig;
107
+ writeConfigFile(cfg: OpenClawConfig): Promise<void>;
108
+ };
109
+ channel: {
110
+ reply: {
111
+ finalizeInboundContext<T extends Record<string, unknown>>(ctx: T): T & FinalizedMsgContext;
112
+ dispatchReplyFromConfig(params: {
113
+ ctx: FinalizedMsgContext;
114
+ cfg: OpenClawConfig;
115
+ dispatcher: ReplyDispatcher;
116
+ replyOptions?: Record<string, unknown>;
117
+ }): Promise<{
118
+ queuedFinal: boolean;
119
+ }>;
120
+ createReplyDispatcherWithTyping(params: {
121
+ channel: string;
122
+ accountId: string;
123
+ deliver: (payload: {
124
+ text?: string;
125
+ body?: string;
126
+ }) => Promise<void>;
127
+ [key: string]: unknown;
128
+ }): {
129
+ dispatcher: ReplyDispatcher;
130
+ replyOptions: Record<string, unknown>;
131
+ markDispatchIdle: () => void;
132
+ };
133
+ };
134
+ text: {
135
+ chunkMarkdownText(text: string, limit: number): string[];
136
+ };
137
+ };
138
+ logging: {
139
+ createLogger(name: string): PluginLogger;
140
+ };
141
+ state: {
142
+ resolveStateDir(): string;
143
+ };
144
+ }
145
+ interface FinalizedMsgContext {
146
+ Body: string;
147
+ RawBody?: string;
148
+ ChatType: string;
149
+ Provider: string;
150
+ Surface: string;
151
+ From: string;
152
+ To: string;
153
+ MessageSid: string;
154
+ Timestamp?: string;
155
+ BodyForAgent?: string;
156
+ [key: string]: unknown;
157
+ }
158
+ interface ReplyDispatcher {
159
+ send(reply: unknown): Promise<void>;
160
+ getQueuedCounts(): unknown;
161
+ }
162
+ interface PluginLogger {
163
+ info(msg: string): void;
164
+ warn(msg: string): void;
165
+ error(msg: string): void;
166
+ debug(msg: string): void;
167
+ }
168
+ interface ChannelMessagingTargetResolver {
169
+ hint?: string;
170
+ looksLikeId?(raw: string, normalized?: string): boolean;
171
+ }
172
+ interface ChannelMessagingAdapter {
173
+ normalizeTarget?(raw: string): string | undefined;
174
+ targetResolver?: ChannelMessagingTargetResolver;
175
+ }
176
+ interface ChannelPlugin {
177
+ id: string;
178
+ meta: ChannelMeta;
179
+ capabilities: ChannelCapabilities;
180
+ config: ChannelConfigAdapter;
181
+ outbound?: ChannelOutboundAdapter;
182
+ gateway?: ChannelGatewayAdapter;
183
+ setup?: ChannelSetupAdapter;
184
+ security?: ChannelSecurityAdapter;
185
+ messaging?: ChannelMessagingAdapter;
186
+ onboarding?: ChannelOnboardingAdapter;
187
+ status?: ChannelStatusAdapter;
188
+ }
189
+ interface ChannelMeta {
190
+ name: string;
191
+ icon?: string;
192
+ description?: string;
193
+ }
194
+ interface ChannelCapabilities {
195
+ text: boolean;
196
+ media: boolean;
197
+ reactions: boolean;
198
+ threads: boolean;
199
+ editing: boolean;
200
+ }
201
+ interface ChannelConfigAdapter {
202
+ listAccountIds(cfg: OpenClawConfig): string[];
203
+ resolveAccount(cfg: OpenClawConfig, accountId?: string | null): ResolvedDeskFreeAccount;
204
+ isConfigured?(account: ResolvedDeskFreeAccount, cfg?: OpenClawConfig): boolean;
205
+ isEnabled?(account: ResolvedDeskFreeAccount, cfg?: OpenClawConfig): boolean;
206
+ describeAccount?(account: ResolvedDeskFreeAccount, cfg?: OpenClawConfig): ChannelAccountSnapshot;
207
+ }
208
+ interface ChannelOutboundAdapter {
209
+ deliveryMode: 'direct' | 'gateway' | 'hybrid';
210
+ resolveTarget?(target: string, ctx: {
211
+ cfg: OpenClawConfig;
212
+ accountId?: string | null;
213
+ }): {
214
+ to: string;
215
+ } | null;
216
+ sendText?(ctx: ChannelOutboundContext): Promise<OutboundDeliveryResult>;
217
+ textChunkLimit?: number;
218
+ chunkerMode?: 'text' | 'markdown';
219
+ }
220
+ interface ChannelGatewayAdapter {
221
+ startAccount?(ctx: ChannelGatewayContext): Promise<unknown>;
222
+ stopAccount?(ctx: ChannelGatewayContext): Promise<void>;
223
+ logoutAccount?(ctx: ChannelLogoutContext): Promise<ChannelLogoutResult>;
224
+ }
225
+ interface ChannelGatewayContext {
226
+ cfg: OpenClawConfig;
227
+ accountId: string;
228
+ account: ResolvedDeskFreeAccount;
229
+ runtime: PluginRuntime;
230
+ abortSignal: AbortSignal;
231
+ log?: PluginLogger;
232
+ getStatus(): ChannelAccountSnapshot;
233
+ setStatus(next: Partial<ChannelAccountSnapshot>): void;
234
+ }
235
+ interface ChannelSetupAdapter {
236
+ applyAccountConfig(params: {
237
+ cfg: OpenClawConfig;
238
+ accountId: string;
239
+ input: Record<string, string>;
240
+ }): OpenClawConfig;
241
+ validateInput?(params: {
242
+ cfg: OpenClawConfig;
243
+ accountId: string;
244
+ input: Record<string, string>;
245
+ }): string | null;
246
+ }
247
+ interface ChannelSecurityDmPolicy {
248
+ policy: string;
249
+ allowFrom?: Array<string | number> | null;
250
+ policyPath?: string;
251
+ allowFromPath: string;
252
+ approveHint: string;
253
+ normalizeEntry?: (raw: string) => string;
254
+ }
255
+ interface ChannelSecurityAdapter {
256
+ resolveDmPolicy?(ctx: {
257
+ cfg: OpenClawConfig;
258
+ accountId?: string | null;
259
+ account: ResolvedDeskFreeAccount;
260
+ }): ChannelSecurityDmPolicy | null;
261
+ collectWarnings?(ctx: {
262
+ cfg: OpenClawConfig;
263
+ accountId?: string | null;
264
+ account: ResolvedDeskFreeAccount;
265
+ }): Promise<string[]> | string[];
266
+ }
267
+ interface ChannelOutboundContext {
268
+ cfg: OpenClawConfig;
269
+ to: string;
270
+ text: string;
271
+ threadId?: string | number | null;
272
+ replyToId?: string | null;
273
+ accountId?: string | null;
274
+ }
275
+ interface OutboundDeliveryResult {
276
+ channel: string;
277
+ success: boolean;
278
+ threadId?: string;
279
+ }
280
+ interface ChannelAccountSnapshot {
281
+ accountId?: string;
282
+ enabled?: boolean;
283
+ configured?: boolean;
284
+ running?: boolean;
285
+ lastStartAt?: number;
286
+ lastStopAt?: number;
287
+ lastError?: string;
288
+ probe?: ChannelProbeResult;
289
+ }
290
+ interface ResolvedDeskFreeAccount {
291
+ accountId: string;
292
+ botToken: string;
293
+ apiUrl: string;
294
+ wsUrl: string;
295
+ userId: string;
296
+ enabled: boolean;
297
+ botName?: string;
298
+ humanName?: string;
299
+ }
300
+ interface DeskFreeChannelConfig {
301
+ enabled?: boolean;
302
+ botToken: string;
303
+ apiUrl: string;
304
+ wsUrl: string;
305
+ userId: string;
306
+ botName?: string;
307
+ humanName?: string;
308
+ accounts?: Record<string, Omit<DeskFreeChannelConfig, 'accounts'>>;
309
+ }
310
+ interface ChatMessageAttachment {
311
+ name: string;
312
+ contentType: string;
313
+ size: number;
314
+ url: string;
315
+ }
316
+ interface ChatMessage {
317
+ messageId: string;
318
+ botId: string;
319
+ humanId: string;
320
+ authorType: 'bot' | 'user';
321
+ content: string;
322
+ attachments?: ChatMessageAttachment[];
323
+ taskId?: string | null;
324
+ createdAt: string;
325
+ userName?: string | null;
326
+ botName?: string | null;
327
+ }
328
+ interface MessagesResponse {
329
+ items: ChatMessage[];
330
+ cursor: string | null;
331
+ hasMore: boolean;
332
+ }
333
+ interface WsTicketResponse {
334
+ ticket: string;
335
+ wsUrl: string;
336
+ expiresAt: string;
337
+ }
338
+ interface WizardPrompter {
339
+ text(params: {
340
+ message: string;
341
+ initialValue?: string;
342
+ placeholder?: string;
343
+ validate?: (value: string) => string | undefined;
344
+ }): Promise<string>;
345
+ confirm(params: {
346
+ message: string;
347
+ initialValue?: boolean;
348
+ }): Promise<boolean>;
349
+ note(message: string, title?: string): Promise<void>;
350
+ }
351
+ interface ChannelOnboardingStatus {
352
+ channel: string;
353
+ configured: boolean;
354
+ statusLines: string[];
355
+ selectionHint?: string;
356
+ quickstartScore?: number;
357
+ }
358
+ interface ChannelOnboardingResult {
359
+ cfg: OpenClawConfig;
360
+ accountId?: string;
361
+ }
362
+ interface ChannelOnboardingAdapter {
363
+ channel: string;
364
+ getStatus(ctx: {
365
+ cfg: OpenClawConfig;
366
+ }): Promise<ChannelOnboardingStatus>;
367
+ configure(ctx: {
368
+ cfg: OpenClawConfig;
369
+ runtime: PluginRuntime;
370
+ prompter: WizardPrompter;
371
+ accountOverrides: Record<string, string>;
372
+ shouldPromptAccountIds: boolean;
373
+ forceAllowFrom: boolean;
374
+ }): Promise<ChannelOnboardingResult>;
375
+ disable?(cfg: OpenClawConfig): OpenClawConfig;
376
+ }
377
+ interface ChannelProbeResult {
378
+ ok: boolean;
379
+ error?: string;
380
+ }
381
+ interface ChannelStatusIssue {
382
+ channel: string;
383
+ accountId: string;
384
+ kind: 'config' | 'auth' | 'runtime';
385
+ message: string;
386
+ fix?: string;
387
+ }
388
+ interface ChannelStatusAdapter {
389
+ probeAccount?(params: {
390
+ account: ResolvedDeskFreeAccount;
391
+ timeoutMs: number;
392
+ cfg: OpenClawConfig;
393
+ }): Promise<ChannelProbeResult>;
394
+ buildAccountSnapshot?(params: {
395
+ account: ResolvedDeskFreeAccount;
396
+ cfg: OpenClawConfig;
397
+ runtime?: ChannelAccountSnapshot;
398
+ probe?: ChannelProbeResult;
399
+ }): ChannelAccountSnapshot;
400
+ collectStatusIssues?(accounts: ChannelAccountSnapshot[]): ChannelStatusIssue[];
401
+ }
402
+ interface ChannelLogoutContext {
403
+ cfg: OpenClawConfig;
404
+ accountId: string;
405
+ account: ResolvedDeskFreeAccount;
406
+ runtime: PluginRuntime;
407
+ log?: PluginLogger;
408
+ }
409
+ interface ChannelLogoutResult {
410
+ cleared: boolean;
411
+ loggedOut?: boolean;
412
+ [key: string]: unknown;
413
+ }
414
+ interface WsNotification {
415
+ action: 'notify';
416
+ hint: string;
417
+ }
418
+ interface Task {
419
+ taskId: string;
420
+ title: string;
421
+ status: 'bot' | 'human' | 'done';
422
+ isWorking?: boolean;
423
+ instructions?: string;
424
+ createdAt: string;
425
+ updatedAt: string;
426
+ botId?: string | null;
427
+ createdById: string;
428
+ reason?: string | null;
429
+ deliverable?: string | null;
430
+ deliverableFormat?: 'markdown' | 'html' | null;
431
+ }
432
+ interface TaskMessage {
433
+ messageId: string;
434
+ authorType: 'bot' | 'user';
435
+ content: string;
436
+ attachments: ChatMessageAttachment[];
437
+ createdAt: string;
438
+ userName?: string | null;
439
+ }
440
+ interface TaskWithContext extends Task {
441
+ instructions: string;
442
+ deliverable: string;
443
+ messages: TaskMessage[];
444
+ }
445
+ /**
446
+ * Response from the tasks.create bot endpoint.
447
+ *
448
+ * The backend mutation (`trpc.bot.tasks.create`) returns the Task object
449
+ * directly (not wrapped in `{ task: ... }`).
450
+ */
451
+ type CreateTaskResponse = Task;
452
+ interface CompleteTaskInput {
453
+ taskId: string;
454
+ outcome: 'done' | 'blocked';
455
+ }
456
+ interface WorkspaceStateTask {
457
+ taskId: string;
458
+ title: string;
459
+ status: 'bot' | 'human' | 'done';
460
+ isWorking?: boolean;
461
+ instructions?: string | null;
462
+ deliverable?: string | null;
463
+ createdAt: string;
464
+ updatedAt: string;
465
+ }
466
+ interface WorkspaceState {
467
+ tasks: WorkspaceStateTask[];
468
+ recentlyDone: WorkspaceStateTask[];
469
+ waysOfWorking: string | null;
470
+ pendingEvaluations: Array<{
471
+ taskId: string;
472
+ taskNumber: number;
473
+ title: string;
474
+ }>;
475
+ }
476
+ interface EvaluationTaskMessage {
477
+ messageId: string;
478
+ authorType: string;
479
+ content: string;
480
+ createdAt: string;
481
+ userName: string | null;
482
+ }
483
+ interface ClaimEvaluationResponse {
484
+ task: Task & {
485
+ evaluationPending: boolean;
486
+ };
487
+ waysOfWorking: string | null;
488
+ currentVersion: number;
489
+ messages: EvaluationTaskMessage[];
490
+ }
491
+
492
+ /** Enhanced error class for DeskFree API errors with user-friendly messages */
493
+ declare class DeskFreeError extends Error {
494
+ readonly type: 'network' | 'auth' | 'server' | 'client' | 'timeout' | 'invalid_response';
495
+ readonly statusCode?: number;
496
+ readonly userMessage: string;
497
+ readonly procedure: string;
498
+ constructor(type: DeskFreeError['type'], procedure: string, message: string, userMessage: string, statusCode?: number);
499
+ static fromResponse(response: Response, procedure: string, responseText: string): DeskFreeError;
500
+ static timeout(procedure: string, timeoutMs: number): DeskFreeError;
501
+ static invalidResponse(procedure: string): DeskFreeError;
502
+ static network(procedure: string, originalError: Error): DeskFreeError;
503
+ }
504
+ declare class DeskFreeClient {
505
+ private botToken;
506
+ private apiUrl;
507
+ private requestTimeoutMs;
508
+ constructor(botToken: string, apiUrl: string, options?: {
509
+ requestTimeoutMs?: number;
510
+ });
511
+ private request;
512
+ /**
513
+ * Validates that a string parameter is non-empty.
514
+ * Catches invalid inputs before they hit the network.
515
+ */
516
+ private requireNonEmpty;
517
+ /**
518
+ * Update an existing bot message content (for streaming).
519
+ *
520
+ * @param input - messageId, new content, and streaming flag
521
+ */
522
+ updateMessage(input: {
523
+ messageId: string;
524
+ content: string;
525
+ streaming?: boolean;
526
+ }): Promise<{
527
+ messageId: string;
528
+ content: string;
529
+ }>;
530
+ /**
531
+ * Send a text message (with optional attachments or suggestions) to a DeskFree conversation.
532
+ *
533
+ * @param input - Message content, optional userId, taskId, attachments, and suggestions
534
+ */
535
+ sendMessage(input: {
536
+ userId?: string;
537
+ content?: string;
538
+ taskId?: string;
539
+ attachments?: Array<{
540
+ s3Key: string;
541
+ name: string;
542
+ contentType: string;
543
+ size: number;
544
+ }>;
545
+ suggestions?: Array<{
546
+ title: string;
547
+ instructions?: string;
548
+ }>;
549
+ }): Promise<{
550
+ messageId: string;
551
+ content: string;
552
+ }>;
553
+ /** Fetch paginated message history for a conversation. */
554
+ listMessages(input: {
555
+ userId?: string;
556
+ cursor?: string | null;
557
+ limit?: number;
558
+ }): Promise<MessagesResponse>;
559
+ /** Obtain a one-time WebSocket authentication ticket for real-time notifications. */
560
+ getWsTicket(): Promise<WsTicketResponse>;
561
+ /** Create a new task, optionally with a recurring schedule. */
562
+ createTask(input: {
563
+ title: string;
564
+ instructions?: string;
565
+ isRecurring?: boolean;
566
+ recurringSchedule?: {
567
+ frequency: 'daily' | 'weekly' | 'biweekly' | 'monthly';
568
+ dayOfWeek?: number;
569
+ dayOfMonth?: number;
570
+ time: string;
571
+ timezone?: string;
572
+ };
573
+ }): Promise<CreateTaskResponse>;
574
+ /** Claim a task so the bot can begin working on it. Returns enriched context. */
575
+ claimTask(input: {
576
+ taskId: string;
577
+ }): Promise<TaskWithContext>;
578
+ /** Update the deliverable (markdown or HTML content) for a task. */
579
+ updateDeliverable(input: {
580
+ taskId: string;
581
+ deliverable: string;
582
+ format?: 'markdown' | 'html';
583
+ }): Promise<void>;
584
+ /** Send an agent status update to DeskFree. */
585
+ statusUpdate(input: {
586
+ status: 'idle' | 'working' | 'responding';
587
+ activeSubAgents: Array<{
588
+ label: string;
589
+ status: 'running' | 'completed' | 'failed';
590
+ startedAt: string;
591
+ completedAt?: string;
592
+ tokenUsage?: number;
593
+ task?: string;
594
+ }>;
595
+ model?: string;
596
+ lastActivity?: string;
597
+ pluginVersion?: string;
598
+ openclawVersion?: string;
599
+ }): Promise<{
600
+ success: boolean;
601
+ }>;
602
+ /** Report error log entries to the backend for CloudWatch/Slack visibility. */
603
+ reportError(input: {
604
+ errors: Array<{
605
+ message: string;
606
+ level: 'warn' | 'error' | 'fatal';
607
+ timestamp: string;
608
+ metadata?: Record<string, unknown>;
609
+ }>;
610
+ }): Promise<{
611
+ accepted: number;
612
+ }>;
613
+ /** Get full workspace snapshot — active tasks and recently done. */
614
+ getState(): Promise<WorkspaceState>;
615
+ /** Report token usage for a task. Atomically increments rollup columns. */
616
+ reportUsage(input: {
617
+ taskId: string;
618
+ inputTokens: number;
619
+ outputTokens: number;
620
+ thinkingTokens: number;
621
+ model: string;
622
+ estimatedCost: number;
623
+ }): Promise<{
624
+ success: boolean;
625
+ }>;
626
+ /** Complete a task with an outcome. Moves task to human. */
627
+ completeTask(input: CompleteTaskInput): Promise<Task & {
628
+ outcome: 'done' | 'blocked';
629
+ }>;
630
+ /** Suggest new tasks for the human to review and approve (via messages.send with suggestions). */
631
+ suggestTasks(input: {
632
+ tasks: Array<{
633
+ title: string;
634
+ instructions?: string;
635
+ }>;
636
+ taskId?: string;
637
+ }): Promise<{
638
+ messageId: string;
639
+ content: string;
640
+ }>;
641
+ /**
642
+ * Claim a pending evaluation for a task. Atomically sets isWorking=true where
643
+ * evaluationPending=true and isWorking=false. Returns null if already claimed.
644
+ */
645
+ claimEvaluation(input: {
646
+ taskId: string;
647
+ }): Promise<ClaimEvaluationResponse | null>;
648
+ /**
649
+ * Submit the result of a ways-of-working evaluation.
650
+ * If hasChanges is true and updatedContent is provided, inserts a new version.
651
+ * Clears evaluationPending and isWorking on the task.
652
+ */
653
+ submitEvaluation(input: {
654
+ taskId: string;
655
+ updatedContent?: string;
656
+ reasoning: string;
657
+ hasChanges: boolean;
658
+ }): Promise<{
659
+ success: boolean;
660
+ version?: number;
661
+ }>;
662
+ /**
663
+ * Lightweight health check that verifies connectivity and authentication.
664
+ *
665
+ * @param timeoutMs - Maximum time to wait for the probe response
666
+ * @returns Probe result indicating success or a descriptive error
667
+ */
668
+ probe(timeoutMs: number): Promise<ChannelProbeResult>;
669
+ }
670
+
671
+ /**
672
+ * Convenience: report an error if the reporter is initialized.
673
+ * No-op if called before initErrorReporter(). Never throws.
674
+ */
675
+ declare function reportError(level: 'warn' | 'error' | 'fatal', message: string, metadata?: Record<string, unknown>): void;
676
+
677
+ /**
678
+ * Offline queue for failed API requests.
679
+ *
680
+ * When the DeskFree API is unreachable (network errors, timeouts),
681
+ * outbound requests are queued in memory and retried with exponential
682
+ * backoff when connectivity is restored.
683
+ */
684
+
685
+ /** A queued request that can be retried. */
686
+ interface QueuedRequest {
687
+ id: string;
688
+ /** Human-readable description for logging. */
689
+ label: string;
690
+ /** The function to execute. Must be idempotent for safe retries. */
691
+ execute: () => Promise<void>;
692
+ /** Number of retry attempts so far. */
693
+ attempts: number;
694
+ /** Timestamp when the request was first queued. */
695
+ queuedAt: number;
696
+ }
697
+ declare class OfflineQueue {
698
+ private queue;
699
+ private processing;
700
+ private retryTimer;
701
+ private log;
702
+ constructor(log: PluginLogger);
703
+ /** Number of requests currently queued. */
704
+ get size(): number;
705
+ /**
706
+ * Enqueue a failed request for later retry.
707
+ * Returns false if the queue is full.
708
+ */
709
+ enqueue(request: Omit<QueuedRequest, 'attempts' | 'queuedAt'>): boolean;
710
+ /**
711
+ * Attempt to flush all queued requests.
712
+ * Called when connectivity is restored (e.g., WebSocket reconnect).
713
+ */
714
+ flush(): Promise<void>;
715
+ /** Clear all queued requests. */
716
+ clear(): void;
717
+ /** Stop the retry timer (for cleanup). */
718
+ destroy(): void;
719
+ private scheduleRetry;
720
+ }
721
+
5
722
  declare const plugin: {
6
723
  id: string;
7
724
  name: string;
8
725
  register(api: OpenClawPluginApi): void;
9
726
  };
10
- export default plugin;
11
- //# sourceMappingURL=index.d.ts.map
727
+
728
+ export { type AnyAgentTool, type ChannelAccountSnapshot, type ChannelCapabilities, type ChannelConfigAdapter, type ChannelGatewayAdapter, type ChannelGatewayContext, type ChannelLogoutContext, type ChannelLogoutResult, type ChannelMessagingAdapter, type ChannelMessagingTargetResolver, type ChannelMeta, type ChannelOnboardingAdapter, type ChannelOnboardingResult, type ChannelOnboardingStatus, type ChannelOutboundAdapter, type ChannelOutboundContext, type ChannelPlugin, type ChannelProbeResult, type ChannelSecurityAdapter, type ChannelSecurityDmPolicy, type ChannelSetupAdapter, type ChannelStatusAdapter, type ChannelStatusIssue, type ChatMessage, type ChatMessageAttachment, type ClaimEvaluationResponse, type CompleteTaskInput, type CreateTaskResponse, type DeskFreeChannelConfig, DeskFreeClient, DeskFreeError, type EvaluationTaskMessage, type FinalizedMsgContext, type MessagesResponse, OfflineQueue, type OpenClawConfig, type OpenClawPluginApi, type OpenClawPluginToolContext, type OpenClawPluginToolFactory, type OpenClawPluginToolOptions, type OutboundDeliveryResult, type PluginHookAgentContext, type PluginHookBeforeAgentStartEvent, type PluginHookBeforeAgentStartResult, type PluginHookHandlerMap, type PluginHookName, type PluginLogger, type PluginRuntime, type ReplyDispatcher, type ResolvedDeskFreeAccount, type Task, type TaskMessage, type TaskWithContext, type WizardPrompter, type WorkspaceState, type WorkspaceStateTask, type WsNotification, type WsTicketResponse, plugin as default, reportError };