opencode-claw 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +316 -0
  3. package/dist/channels/router.d.ts +18 -0
  4. package/dist/channels/router.js +188 -0
  5. package/dist/channels/slack.d.ts +4 -0
  6. package/dist/channels/slack.js +87 -0
  7. package/dist/channels/telegram.d.ts +4 -0
  8. package/dist/channels/telegram.js +79 -0
  9. package/dist/channels/types.d.ts +27 -0
  10. package/dist/channels/types.js +1 -0
  11. package/dist/channels/whatsapp.d.ts +4 -0
  12. package/dist/channels/whatsapp.js +136 -0
  13. package/dist/cli.d.ts +2 -0
  14. package/dist/cli.js +6 -0
  15. package/dist/compat.d.ts +12 -0
  16. package/dist/compat.js +63 -0
  17. package/dist/config/loader.d.ts +2 -0
  18. package/dist/config/loader.js +57 -0
  19. package/dist/config/schema.d.ts +482 -0
  20. package/dist/config/schema.js +108 -0
  21. package/dist/config/types.d.ts +14 -0
  22. package/dist/config/types.js +1 -0
  23. package/dist/cron/scheduler.d.ts +16 -0
  24. package/dist/cron/scheduler.js +113 -0
  25. package/dist/exports.d.ts +9 -0
  26. package/dist/exports.js +4 -0
  27. package/dist/health/server.d.ts +17 -0
  28. package/dist/health/server.js +68 -0
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.js +127 -0
  31. package/dist/memory/factory.d.ts +3 -0
  32. package/dist/memory/factory.js +14 -0
  33. package/dist/memory/openviking.d.ts +5 -0
  34. package/dist/memory/openviking.js +138 -0
  35. package/dist/memory/plugin-entry.d.ts +3 -0
  36. package/dist/memory/plugin-entry.js +11 -0
  37. package/dist/memory/plugin.d.ts +5 -0
  38. package/dist/memory/plugin.js +63 -0
  39. package/dist/memory/txt.d.ts +2 -0
  40. package/dist/memory/txt.js +137 -0
  41. package/dist/memory/types.d.ts +36 -0
  42. package/dist/memory/types.js +1 -0
  43. package/dist/outbox/drainer.d.ts +8 -0
  44. package/dist/outbox/drainer.js +140 -0
  45. package/dist/outbox/writer.d.ts +15 -0
  46. package/dist/outbox/writer.js +29 -0
  47. package/dist/sessions/manager.d.ts +20 -0
  48. package/dist/sessions/manager.js +68 -0
  49. package/dist/sessions/persistence.d.ts +4 -0
  50. package/dist/sessions/persistence.js +24 -0
  51. package/dist/utils/logger.d.ts +8 -0
  52. package/dist/utils/logger.js +33 -0
  53. package/dist/utils/reconnect.d.ts +16 -0
  54. package/dist/utils/reconnect.js +54 -0
  55. package/dist/utils/shutdown.d.ts +5 -0
  56. package/dist/utils/shutdown.js +27 -0
  57. package/opencode-claw.example.json +71 -0
  58. package/package.json +77 -0
@@ -0,0 +1,482 @@
1
+ import { z } from "zod";
2
+ export declare const configSchema: z.ZodObject<{
3
+ opencode: z.ZodDefault<z.ZodObject<{
4
+ configPath: z.ZodOptional<z.ZodString>;
5
+ port: z.ZodDefault<z.ZodNumber>;
6
+ directory: z.ZodOptional<z.ZodString>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ port: number;
9
+ directory?: string | undefined;
10
+ configPath?: string | undefined;
11
+ }, {
12
+ directory?: string | undefined;
13
+ configPath?: string | undefined;
14
+ port?: number | undefined;
15
+ }>>;
16
+ memory: z.ZodDefault<z.ZodObject<{
17
+ backend: z.ZodDefault<z.ZodEnum<["txt", "openviking"]>>;
18
+ txt: z.ZodDefault<z.ZodObject<{
19
+ directory: z.ZodDefault<z.ZodString>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ directory: string;
22
+ }, {
23
+ directory?: string | undefined;
24
+ }>>;
25
+ openviking: z.ZodOptional<z.ZodObject<{
26
+ mode: z.ZodDefault<z.ZodEnum<["http", "subprocess"]>>;
27
+ url: z.ZodDefault<z.ZodString>;
28
+ path: z.ZodOptional<z.ZodString>;
29
+ embedding: z.ZodOptional<z.ZodEnum<["openai", "volcengine"]>>;
30
+ fallback: z.ZodDefault<z.ZodBoolean>;
31
+ }, "strip", z.ZodTypeAny, {
32
+ mode: "http" | "subprocess";
33
+ url: string;
34
+ fallback: boolean;
35
+ path?: string | undefined;
36
+ embedding?: "openai" | "volcengine" | undefined;
37
+ }, {
38
+ path?: string | undefined;
39
+ mode?: "http" | "subprocess" | undefined;
40
+ url?: string | undefined;
41
+ embedding?: "openai" | "volcengine" | undefined;
42
+ fallback?: boolean | undefined;
43
+ }>>;
44
+ }, "strip", z.ZodTypeAny, {
45
+ txt: {
46
+ directory: string;
47
+ };
48
+ backend: "txt" | "openviking";
49
+ openviking?: {
50
+ mode: "http" | "subprocess";
51
+ url: string;
52
+ fallback: boolean;
53
+ path?: string | undefined;
54
+ embedding?: "openai" | "volcengine" | undefined;
55
+ } | undefined;
56
+ }, {
57
+ txt?: {
58
+ directory?: string | undefined;
59
+ } | undefined;
60
+ openviking?: {
61
+ path?: string | undefined;
62
+ mode?: "http" | "subprocess" | undefined;
63
+ url?: string | undefined;
64
+ embedding?: "openai" | "volcengine" | undefined;
65
+ fallback?: boolean | undefined;
66
+ } | undefined;
67
+ backend?: "txt" | "openviking" | undefined;
68
+ }>>;
69
+ channels: z.ZodObject<{
70
+ telegram: z.ZodOptional<z.ZodObject<{
71
+ enabled: z.ZodBoolean;
72
+ botToken: z.ZodString;
73
+ allowlist: z.ZodArray<z.ZodString, "many">;
74
+ mode: z.ZodDefault<z.ZodEnum<["polling", "webhook"]>>;
75
+ webhookUrl: z.ZodOptional<z.ZodString>;
76
+ rejectionBehavior: z.ZodDefault<z.ZodEnum<["ignore", "reject"]>>;
77
+ }, "strip", z.ZodTypeAny, {
78
+ enabled: boolean;
79
+ botToken: string;
80
+ allowlist: string[];
81
+ mode: "polling" | "webhook";
82
+ rejectionBehavior: "ignore" | "reject";
83
+ webhookUrl?: string | undefined;
84
+ }, {
85
+ enabled: boolean;
86
+ botToken: string;
87
+ allowlist: string[];
88
+ mode?: "polling" | "webhook" | undefined;
89
+ webhookUrl?: string | undefined;
90
+ rejectionBehavior?: "ignore" | "reject" | undefined;
91
+ }>>;
92
+ slack: z.ZodOptional<z.ZodObject<{
93
+ enabled: z.ZodBoolean;
94
+ botToken: z.ZodString;
95
+ appToken: z.ZodString;
96
+ allowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
97
+ mode: z.ZodDefault<z.ZodEnum<["socket", "http"]>>;
98
+ signingSecret: z.ZodOptional<z.ZodString>;
99
+ rejectionBehavior: z.ZodDefault<z.ZodEnum<["ignore", "reject"]>>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ enabled: boolean;
102
+ botToken: string;
103
+ mode: "socket" | "http";
104
+ rejectionBehavior: "ignore" | "reject";
105
+ appToken: string;
106
+ allowlist?: string[] | undefined;
107
+ signingSecret?: string | undefined;
108
+ }, {
109
+ enabled: boolean;
110
+ botToken: string;
111
+ appToken: string;
112
+ allowlist?: string[] | undefined;
113
+ mode?: "socket" | "http" | undefined;
114
+ rejectionBehavior?: "ignore" | "reject" | undefined;
115
+ signingSecret?: string | undefined;
116
+ }>>;
117
+ whatsapp: z.ZodOptional<z.ZodObject<{
118
+ enabled: z.ZodBoolean;
119
+ allowlist: z.ZodArray<z.ZodString, "many">;
120
+ authDir: z.ZodDefault<z.ZodString>;
121
+ debounceMs: z.ZodDefault<z.ZodNumber>;
122
+ rejectionBehavior: z.ZodDefault<z.ZodEnum<["ignore", "reject"]>>;
123
+ }, "strip", z.ZodTypeAny, {
124
+ enabled: boolean;
125
+ allowlist: string[];
126
+ rejectionBehavior: "ignore" | "reject";
127
+ authDir: string;
128
+ debounceMs: number;
129
+ }, {
130
+ enabled: boolean;
131
+ allowlist: string[];
132
+ rejectionBehavior?: "ignore" | "reject" | undefined;
133
+ authDir?: string | undefined;
134
+ debounceMs?: number | undefined;
135
+ }>>;
136
+ }, "strip", z.ZodTypeAny, {
137
+ slack?: {
138
+ enabled: boolean;
139
+ botToken: string;
140
+ mode: "socket" | "http";
141
+ rejectionBehavior: "ignore" | "reject";
142
+ appToken: string;
143
+ allowlist?: string[] | undefined;
144
+ signingSecret?: string | undefined;
145
+ } | undefined;
146
+ telegram?: {
147
+ enabled: boolean;
148
+ botToken: string;
149
+ allowlist: string[];
150
+ mode: "polling" | "webhook";
151
+ rejectionBehavior: "ignore" | "reject";
152
+ webhookUrl?: string | undefined;
153
+ } | undefined;
154
+ whatsapp?: {
155
+ enabled: boolean;
156
+ allowlist: string[];
157
+ rejectionBehavior: "ignore" | "reject";
158
+ authDir: string;
159
+ debounceMs: number;
160
+ } | undefined;
161
+ }, {
162
+ slack?: {
163
+ enabled: boolean;
164
+ botToken: string;
165
+ appToken: string;
166
+ allowlist?: string[] | undefined;
167
+ mode?: "socket" | "http" | undefined;
168
+ rejectionBehavior?: "ignore" | "reject" | undefined;
169
+ signingSecret?: string | undefined;
170
+ } | undefined;
171
+ telegram?: {
172
+ enabled: boolean;
173
+ botToken: string;
174
+ allowlist: string[];
175
+ mode?: "polling" | "webhook" | undefined;
176
+ webhookUrl?: string | undefined;
177
+ rejectionBehavior?: "ignore" | "reject" | undefined;
178
+ } | undefined;
179
+ whatsapp?: {
180
+ enabled: boolean;
181
+ allowlist: string[];
182
+ rejectionBehavior?: "ignore" | "reject" | undefined;
183
+ authDir?: string | undefined;
184
+ debounceMs?: number | undefined;
185
+ } | undefined;
186
+ }>;
187
+ cron: z.ZodOptional<z.ZodObject<{
188
+ enabled: z.ZodDefault<z.ZodBoolean>;
189
+ defaultTimeoutMs: z.ZodDefault<z.ZodNumber>;
190
+ jobs: z.ZodDefault<z.ZodArray<z.ZodObject<{
191
+ id: z.ZodString;
192
+ schedule: z.ZodString;
193
+ description: z.ZodString;
194
+ prompt: z.ZodString;
195
+ reportTo: z.ZodOptional<z.ZodObject<{
196
+ channel: z.ZodEnum<["slack", "telegram", "whatsapp"]>;
197
+ peerId: z.ZodString;
198
+ threadId: z.ZodOptional<z.ZodString>;
199
+ }, "strip", z.ZodTypeAny, {
200
+ channel: "slack" | "telegram" | "whatsapp";
201
+ peerId: string;
202
+ threadId?: string | undefined;
203
+ }, {
204
+ channel: "slack" | "telegram" | "whatsapp";
205
+ peerId: string;
206
+ threadId?: string | undefined;
207
+ }>>;
208
+ enabled: z.ZodDefault<z.ZodBoolean>;
209
+ timeoutMs: z.ZodDefault<z.ZodNumber>;
210
+ }, "strip", z.ZodTypeAny, {
211
+ enabled: boolean;
212
+ id: string;
213
+ schedule: string;
214
+ description: string;
215
+ prompt: string;
216
+ timeoutMs: number;
217
+ reportTo?: {
218
+ channel: "slack" | "telegram" | "whatsapp";
219
+ peerId: string;
220
+ threadId?: string | undefined;
221
+ } | undefined;
222
+ }, {
223
+ id: string;
224
+ schedule: string;
225
+ description: string;
226
+ prompt: string;
227
+ enabled?: boolean | undefined;
228
+ reportTo?: {
229
+ channel: "slack" | "telegram" | "whatsapp";
230
+ peerId: string;
231
+ threadId?: string | undefined;
232
+ } | undefined;
233
+ timeoutMs?: number | undefined;
234
+ }>, "many">>;
235
+ }, "strip", z.ZodTypeAny, {
236
+ enabled: boolean;
237
+ defaultTimeoutMs: number;
238
+ jobs: {
239
+ enabled: boolean;
240
+ id: string;
241
+ schedule: string;
242
+ description: string;
243
+ prompt: string;
244
+ timeoutMs: number;
245
+ reportTo?: {
246
+ channel: "slack" | "telegram" | "whatsapp";
247
+ peerId: string;
248
+ threadId?: string | undefined;
249
+ } | undefined;
250
+ }[];
251
+ }, {
252
+ enabled?: boolean | undefined;
253
+ defaultTimeoutMs?: number | undefined;
254
+ jobs?: {
255
+ id: string;
256
+ schedule: string;
257
+ description: string;
258
+ prompt: string;
259
+ enabled?: boolean | undefined;
260
+ reportTo?: {
261
+ channel: "slack" | "telegram" | "whatsapp";
262
+ peerId: string;
263
+ threadId?: string | undefined;
264
+ } | undefined;
265
+ timeoutMs?: number | undefined;
266
+ }[] | undefined;
267
+ }>>;
268
+ sessions: z.ZodDefault<z.ZodObject<{
269
+ titleTemplate: z.ZodDefault<z.ZodString>;
270
+ persistPath: z.ZodDefault<z.ZodString>;
271
+ }, "strip", z.ZodTypeAny, {
272
+ titleTemplate: string;
273
+ persistPath: string;
274
+ }, {
275
+ titleTemplate?: string | undefined;
276
+ persistPath?: string | undefined;
277
+ }>>;
278
+ outbox: z.ZodDefault<z.ZodObject<{
279
+ directory: z.ZodDefault<z.ZodString>;
280
+ pollIntervalMs: z.ZodDefault<z.ZodNumber>;
281
+ maxAttempts: z.ZodDefault<z.ZodNumber>;
282
+ }, "strip", z.ZodTypeAny, {
283
+ directory: string;
284
+ pollIntervalMs: number;
285
+ maxAttempts: number;
286
+ }, {
287
+ directory?: string | undefined;
288
+ pollIntervalMs?: number | undefined;
289
+ maxAttempts?: number | undefined;
290
+ }>>;
291
+ log: z.ZodDefault<z.ZodObject<{
292
+ level: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error"]>>;
293
+ file: z.ZodOptional<z.ZodString>;
294
+ }, "strip", z.ZodTypeAny, {
295
+ level: "debug" | "info" | "warn" | "error";
296
+ file?: string | undefined;
297
+ }, {
298
+ level?: "debug" | "info" | "warn" | "error" | undefined;
299
+ file?: string | undefined;
300
+ }>>;
301
+ health: z.ZodOptional<z.ZodObject<{
302
+ enabled: z.ZodDefault<z.ZodBoolean>;
303
+ port: z.ZodDefault<z.ZodNumber>;
304
+ }, "strip", z.ZodTypeAny, {
305
+ enabled: boolean;
306
+ port: number;
307
+ }, {
308
+ enabled?: boolean | undefined;
309
+ port?: number | undefined;
310
+ }>>;
311
+ router: z.ZodDefault<z.ZodObject<{
312
+ timeoutMs: z.ZodDefault<z.ZodNumber>;
313
+ }, "strip", z.ZodTypeAny, {
314
+ timeoutMs: number;
315
+ }, {
316
+ timeoutMs?: number | undefined;
317
+ }>>;
318
+ }, "strip", z.ZodTypeAny, {
319
+ opencode: {
320
+ port: number;
321
+ directory?: string | undefined;
322
+ configPath?: string | undefined;
323
+ };
324
+ memory: {
325
+ txt: {
326
+ directory: string;
327
+ };
328
+ backend: "txt" | "openviking";
329
+ openviking?: {
330
+ mode: "http" | "subprocess";
331
+ url: string;
332
+ fallback: boolean;
333
+ path?: string | undefined;
334
+ embedding?: "openai" | "volcengine" | undefined;
335
+ } | undefined;
336
+ };
337
+ channels: {
338
+ slack?: {
339
+ enabled: boolean;
340
+ botToken: string;
341
+ mode: "socket" | "http";
342
+ rejectionBehavior: "ignore" | "reject";
343
+ appToken: string;
344
+ allowlist?: string[] | undefined;
345
+ signingSecret?: string | undefined;
346
+ } | undefined;
347
+ telegram?: {
348
+ enabled: boolean;
349
+ botToken: string;
350
+ allowlist: string[];
351
+ mode: "polling" | "webhook";
352
+ rejectionBehavior: "ignore" | "reject";
353
+ webhookUrl?: string | undefined;
354
+ } | undefined;
355
+ whatsapp?: {
356
+ enabled: boolean;
357
+ allowlist: string[];
358
+ rejectionBehavior: "ignore" | "reject";
359
+ authDir: string;
360
+ debounceMs: number;
361
+ } | undefined;
362
+ };
363
+ sessions: {
364
+ titleTemplate: string;
365
+ persistPath: string;
366
+ };
367
+ outbox: {
368
+ directory: string;
369
+ pollIntervalMs: number;
370
+ maxAttempts: number;
371
+ };
372
+ log: {
373
+ level: "debug" | "info" | "warn" | "error";
374
+ file?: string | undefined;
375
+ };
376
+ router: {
377
+ timeoutMs: number;
378
+ };
379
+ cron?: {
380
+ enabled: boolean;
381
+ defaultTimeoutMs: number;
382
+ jobs: {
383
+ enabled: boolean;
384
+ id: string;
385
+ schedule: string;
386
+ description: string;
387
+ prompt: string;
388
+ timeoutMs: number;
389
+ reportTo?: {
390
+ channel: "slack" | "telegram" | "whatsapp";
391
+ peerId: string;
392
+ threadId?: string | undefined;
393
+ } | undefined;
394
+ }[];
395
+ } | undefined;
396
+ health?: {
397
+ enabled: boolean;
398
+ port: number;
399
+ } | undefined;
400
+ }, {
401
+ channels: {
402
+ slack?: {
403
+ enabled: boolean;
404
+ botToken: string;
405
+ appToken: string;
406
+ allowlist?: string[] | undefined;
407
+ mode?: "socket" | "http" | undefined;
408
+ rejectionBehavior?: "ignore" | "reject" | undefined;
409
+ signingSecret?: string | undefined;
410
+ } | undefined;
411
+ telegram?: {
412
+ enabled: boolean;
413
+ botToken: string;
414
+ allowlist: string[];
415
+ mode?: "polling" | "webhook" | undefined;
416
+ webhookUrl?: string | undefined;
417
+ rejectionBehavior?: "ignore" | "reject" | undefined;
418
+ } | undefined;
419
+ whatsapp?: {
420
+ enabled: boolean;
421
+ allowlist: string[];
422
+ rejectionBehavior?: "ignore" | "reject" | undefined;
423
+ authDir?: string | undefined;
424
+ debounceMs?: number | undefined;
425
+ } | undefined;
426
+ };
427
+ opencode?: {
428
+ directory?: string | undefined;
429
+ configPath?: string | undefined;
430
+ port?: number | undefined;
431
+ } | undefined;
432
+ memory?: {
433
+ txt?: {
434
+ directory?: string | undefined;
435
+ } | undefined;
436
+ openviking?: {
437
+ path?: string | undefined;
438
+ mode?: "http" | "subprocess" | undefined;
439
+ url?: string | undefined;
440
+ embedding?: "openai" | "volcengine" | undefined;
441
+ fallback?: boolean | undefined;
442
+ } | undefined;
443
+ backend?: "txt" | "openviking" | undefined;
444
+ } | undefined;
445
+ cron?: {
446
+ enabled?: boolean | undefined;
447
+ defaultTimeoutMs?: number | undefined;
448
+ jobs?: {
449
+ id: string;
450
+ schedule: string;
451
+ description: string;
452
+ prompt: string;
453
+ enabled?: boolean | undefined;
454
+ reportTo?: {
455
+ channel: "slack" | "telegram" | "whatsapp";
456
+ peerId: string;
457
+ threadId?: string | undefined;
458
+ } | undefined;
459
+ timeoutMs?: number | undefined;
460
+ }[] | undefined;
461
+ } | undefined;
462
+ sessions?: {
463
+ titleTemplate?: string | undefined;
464
+ persistPath?: string | undefined;
465
+ } | undefined;
466
+ outbox?: {
467
+ directory?: string | undefined;
468
+ pollIntervalMs?: number | undefined;
469
+ maxAttempts?: number | undefined;
470
+ } | undefined;
471
+ log?: {
472
+ level?: "debug" | "info" | "warn" | "error" | undefined;
473
+ file?: string | undefined;
474
+ } | undefined;
475
+ health?: {
476
+ enabled?: boolean | undefined;
477
+ port?: number | undefined;
478
+ } | undefined;
479
+ router?: {
480
+ timeoutMs?: number | undefined;
481
+ } | undefined;
482
+ }>;
@@ -0,0 +1,108 @@
1
+ import { z } from "zod";
2
+ const telegramSchema = z.object({
3
+ enabled: z.boolean(),
4
+ botToken: z.string().min(1),
5
+ allowlist: z.array(z.string()),
6
+ mode: z.enum(["polling", "webhook"]).default("polling"),
7
+ webhookUrl: z.string().url().optional(),
8
+ rejectionBehavior: z.enum(["ignore", "reject"]).default("ignore"),
9
+ });
10
+ const slackSchema = z.object({
11
+ enabled: z.boolean(),
12
+ botToken: z.string().min(1),
13
+ appToken: z.string().min(1),
14
+ allowlist: z.array(z.string()).optional(),
15
+ mode: z.enum(["socket", "http"]).default("socket"),
16
+ signingSecret: z.string().optional(),
17
+ rejectionBehavior: z.enum(["ignore", "reject"]).default("ignore"),
18
+ });
19
+ const whatsappSchema = z.object({
20
+ enabled: z.boolean(),
21
+ allowlist: z.array(z.string()),
22
+ authDir: z.string().default("./data/whatsapp/auth"),
23
+ debounceMs: z.number().int().min(0).default(1000),
24
+ rejectionBehavior: z.enum(["ignore", "reject"]).default("ignore"),
25
+ });
26
+ const memorySchema = z.object({
27
+ backend: z.enum(["txt", "openviking"]).default("txt"),
28
+ txt: z
29
+ .object({
30
+ directory: z.string().default("./data/memory"),
31
+ })
32
+ .default({}),
33
+ openviking: z
34
+ .object({
35
+ mode: z.enum(["http", "subprocess"]).default("http"),
36
+ url: z.string().url().default("http://localhost:8100"),
37
+ path: z.string().optional(),
38
+ embedding: z.enum(["openai", "volcengine"]).optional(),
39
+ fallback: z.boolean().default(true),
40
+ })
41
+ .optional(),
42
+ });
43
+ const cronJobSchema = z.object({
44
+ id: z.string().min(1),
45
+ schedule: z.string().min(1),
46
+ description: z.string(),
47
+ prompt: z.string().min(1),
48
+ reportTo: z
49
+ .object({
50
+ channel: z.enum(["slack", "telegram", "whatsapp"]),
51
+ peerId: z.string().min(1),
52
+ threadId: z.string().optional(),
53
+ })
54
+ .optional(),
55
+ enabled: z.boolean().default(true),
56
+ timeoutMs: z.number().int().min(1000).default(300_000),
57
+ });
58
+ const cronSchema = z.object({
59
+ enabled: z.boolean().default(true),
60
+ defaultTimeoutMs: z.number().int().min(1000).default(300_000),
61
+ jobs: z.array(cronJobSchema).default([]),
62
+ });
63
+ export const configSchema = z.object({
64
+ opencode: z
65
+ .object({
66
+ configPath: z.string().optional(),
67
+ port: z.number().int().min(0).default(0),
68
+ directory: z.string().optional(),
69
+ })
70
+ .default({}),
71
+ memory: memorySchema.default({ backend: "txt" }),
72
+ channels: z.object({
73
+ telegram: telegramSchema.optional(),
74
+ slack: slackSchema.optional(),
75
+ whatsapp: whatsappSchema.optional(),
76
+ }),
77
+ cron: cronSchema.optional(),
78
+ sessions: z
79
+ .object({
80
+ titleTemplate: z.string().default("{{channel}}:{{peerId}}"),
81
+ persistPath: z.string().default("./data/sessions.json"),
82
+ })
83
+ .default({}),
84
+ outbox: z
85
+ .object({
86
+ directory: z.string().default("./data/outbox"),
87
+ pollIntervalMs: z.number().int().min(100).default(500),
88
+ maxAttempts: z.number().int().min(1).default(3),
89
+ })
90
+ .default({}),
91
+ log: z
92
+ .object({
93
+ level: z.enum(["debug", "info", "warn", "error"]).default("info"),
94
+ file: z.string().optional(),
95
+ })
96
+ .default({}),
97
+ health: z
98
+ .object({
99
+ enabled: z.boolean().default(false),
100
+ port: z.number().int().min(1).default(9090),
101
+ })
102
+ .optional(),
103
+ router: z
104
+ .object({
105
+ timeoutMs: z.number().int().min(1000).default(300_000),
106
+ })
107
+ .default({}),
108
+ });
@@ -0,0 +1,14 @@
1
+ import type { z } from "zod";
2
+ import type { configSchema } from "./schema.js";
3
+ export type Config = z.infer<typeof configSchema>;
4
+ export type TelegramConfig = NonNullable<Config["channels"]["telegram"]>;
5
+ export type SlackConfig = NonNullable<Config["channels"]["slack"]>;
6
+ export type WhatsAppConfig = NonNullable<Config["channels"]["whatsapp"]>;
7
+ export type MemoryConfig = Config["memory"];
8
+ export type CronConfig = NonNullable<Config["cron"]>;
9
+ export type CronJobConfig = CronConfig["jobs"][number];
10
+ export type SessionsConfig = Config["sessions"];
11
+ export type OutboxConfig = Config["outbox"];
12
+ export type LogConfig = Config["log"];
13
+ export type HealthConfig = NonNullable<Config["health"]>;
14
+ export type RouterConfig = Config["router"];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { OpencodeClient } from "@opencode-ai/sdk";
2
+ import type { CronConfig } from "../config/types.js";
3
+ import type { OutboxWriter } from "../outbox/writer.js";
4
+ import type { Logger } from "../utils/logger.js";
5
+ type CronSchedulerDeps = {
6
+ client: OpencodeClient;
7
+ outbox: OutboxWriter;
8
+ config: CronConfig;
9
+ logger: Logger;
10
+ };
11
+ export declare function createCronScheduler(deps: CronSchedulerDeps): {
12
+ start: () => void;
13
+ stop: () => void;
14
+ };
15
+ export type CronScheduler = ReturnType<typeof createCronScheduler>;
16
+ export {};