@saltpub/agent-autoloop 0.0.0-stage → 0.1.3

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 (177) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/INSTALL.md +120 -0
  3. package/LICENSE +21 -0
  4. package/README.en.md +268 -0
  5. package/README.md +264 -2
  6. package/SECURITY.md +49 -0
  7. package/dist/bin/agent-autoloop.js +2 -0
  8. package/dist/cli/agents.js +14 -0
  9. package/dist/cli/backup.js +144 -0
  10. package/dist/cli/dashboard/app.js +424 -0
  11. package/dist/cli/dashboard/index.html +15 -0
  12. package/dist/cli/dashboard/style.css +629 -0
  13. package/dist/cli/dashboard.js +94 -0
  14. package/dist/cli/explain.js +84 -0
  15. package/dist/cli/main.js +1142 -0
  16. package/dist/cli/mcp.js +151 -0
  17. package/dist/cli/runs.js +40 -0
  18. package/dist/cli/spend.js +21 -0
  19. package/dist/cli/status.js +272 -0
  20. package/dist/cli/try.js +6 -0
  21. package/dist/cli/ui.js +75 -0
  22. package/dist/cli/uninstall.js +86 -0
  23. package/dist/cli/update.js +65 -0
  24. package/dist/cli/why.js +115 -0
  25. package/dist/host/background-launcher.js +12 -0
  26. package/dist/host/background.js +24 -0
  27. package/dist/host/channels.js +4 -0
  28. package/dist/host/command.js +98 -0
  29. package/dist/host/config.js +37 -0
  30. package/dist/host/files.js +22 -0
  31. package/dist/host/home.js +5 -0
  32. package/dist/host/http.js +45 -0
  33. package/dist/host/launcher.js +188 -0
  34. package/dist/host/lines.js +15 -0
  35. package/dist/host/node-path.js +33 -0
  36. package/dist/host/npm.js +28 -0
  37. package/dist/host/plugins.js +26 -0
  38. package/dist/host/program.js +14 -0
  39. package/dist/host/runtime.js +179 -0
  40. package/dist/host/server.js +159 -0
  41. package/dist/host/service.js +325 -0
  42. package/dist/host/state.js +203 -0
  43. package/dist/host/up.js +162 -0
  44. package/dist/host/update.js +286 -0
  45. package/dist/host/version.js +81 -0
  46. package/dist/kernel/card-page.js +54 -0
  47. package/dist/kernel/credentials.js +16 -0
  48. package/dist/kernel/cron.js +135 -0
  49. package/dist/kernel/decide.js +826 -0
  50. package/dist/kernel/due.js +73 -0
  51. package/dist/kernel/errors.js +9 -0
  52. package/dist/kernel/evolve.js +264 -0
  53. package/dist/kernel/http.js +357 -0
  54. package/dist/kernel/query.js +202 -0
  55. package/dist/kernel/rules.js +20 -0
  56. package/dist/kernel/store.js +52 -0
  57. package/dist/plugins/acp/agent.js +32 -0
  58. package/dist/plugins/acp/bridge.js +204 -0
  59. package/dist/plugins/claude/agent.js +113 -0
  60. package/dist/plugins/codex/agent.js +105 -0
  61. package/dist/plugins/command/agent.js +25 -0
  62. package/dist/plugins/delivery/action.js +25 -0
  63. package/dist/plugins/delivery/agent.js +13 -0
  64. package/dist/plugins/delivery/delivery.js +388 -0
  65. package/dist/plugins/delivery/github.js +201 -0
  66. package/dist/plugins/delivery/handoff.js +50 -0
  67. package/dist/plugins/delivery/input.js +47 -0
  68. package/dist/plugins/delivery/poll.js +72 -0
  69. package/dist/plugins/delivery/project.js +144 -0
  70. package/dist/plugins/delivery/review-ledger.js +82 -0
  71. package/dist/plugins/delivery/review-policy.js +99 -0
  72. package/dist/plugins/delivery/review.js +280 -0
  73. package/dist/plugins/delivery/run.js +204 -0
  74. package/dist/plugins/desktop/channel.js +94 -0
  75. package/dist/plugins/dsh/agent.js +116 -0
  76. package/dist/plugins/feishu/channel.js +245 -0
  77. package/dist/plugins/github/source.js +30 -0
  78. package/dist/plugins/gitlab/source.js +30 -0
  79. package/dist/plugins/omp/agent.js +3 -0
  80. package/dist/plugins/opencode/agent.js +88 -0
  81. package/dist/plugins/pi/agent.js +92 -0
  82. package/dist/plugins/webhook/channel.js +70 -0
  83. package/dist/plugins/webhook/templates.js +34 -0
  84. package/dist/plugins/xiaojiu/channel.js +410 -0
  85. package/dist/plugins/zcode/agent.js +102 -0
  86. package/dist/protocol/client.js +56 -0
  87. package/dist/protocol/conformance.js +184 -0
  88. package/dist/protocol/job.js +1 -0
  89. package/dist/protocol/rules.js +230 -0
  90. package/dist/protocol/schema.js +70 -0
  91. package/dist/protocol/schema.json +985 -0
  92. package/dist/protocol/validate.js +150 -0
  93. package/dist/worker/agents.js +47 -0
  94. package/dist/worker/contract.js +178 -0
  95. package/dist/worker/run.js +52 -0
  96. package/dist/worker/usage.js +45 -0
  97. package/dist/worker/windows.ps1 +48 -0
  98. package/dist/worker/worker.js +595 -0
  99. package/docs/architecture.en.svg +178 -0
  100. package/docs/architecture.svg +178 -0
  101. package/docs/auto-update.md +53 -0
  102. package/docs/plugins.md +139 -0
  103. package/docs/protocol.md +582 -0
  104. package/docs/state-machines.md +77 -0
  105. package/examples/channel.sh +15 -0
  106. package/examples/plugins/hello-agent/agent.ts +40 -0
  107. package/examples/plugins/hello-channel/channel.ts +54 -0
  108. package/examples/plugins/hello-source/source.ts +19 -0
  109. package/examples/recipes/browser-handoff/README.md +44 -0
  110. package/examples/recipes/browser-handoff/SKILL.md +22 -0
  111. package/examples/recipes/browser-handoff/browser.json +10 -0
  112. package/examples/recipes/browser-handoff/handoff.ts +44 -0
  113. package/examples/recipes/browser-handoff/rules.json +19 -0
  114. package/examples/recipes/feedback/README.md +34 -0
  115. package/examples/recipes/feedback/SKILL.md +22 -0
  116. package/examples/recipes/feedback/event.json +8 -0
  117. package/examples/recipes/feedback/rules.json +37 -0
  118. package/examples/recipes/feishu-brief/README.md +28 -0
  119. package/examples/recipes/feishu-brief/SKILL.md +16 -0
  120. package/examples/recipes/feishu-brief/collect.ts +164 -0
  121. package/examples/recipes/feishu-brief/rules.json +57 -0
  122. package/examples/recipes/feishu-brief/sources.json +13 -0
  123. package/examples/recipes/github-issues/README.md +17 -0
  124. package/examples/recipes/github-issues/SKILL.md +18 -0
  125. package/examples/recipes/github-issues/rules.json +30 -0
  126. package/examples/recipes/inbox-triage/README.md +36 -0
  127. package/examples/recipes/inbox-triage/SKILL.md +19 -0
  128. package/examples/recipes/inbox-triage/collect.ts +191 -0
  129. package/examples/recipes/inbox-triage/rules.json +57 -0
  130. package/examples/recipes/inbox-triage/sources.json +8 -0
  131. package/examples/recipes/morning-brief/README.md +17 -0
  132. package/examples/recipes/morning-brief/SKILL.md +17 -0
  133. package/examples/recipes/morning-brief/rules.json +16 -0
  134. package/examples/recipes/ops-alerts/README.md +18 -0
  135. package/examples/recipes/ops-alerts/SKILL.md +34 -0
  136. package/examples/recipes/ops-alerts/restart.sh +5 -0
  137. package/examples/recipes/ops-alerts/rules.json +29 -0
  138. package/examples/recipes/website-watch/README.md +26 -0
  139. package/examples/recipes/website-watch/SKILL.md +19 -0
  140. package/examples/recipes/website-watch/check.ts +86 -0
  141. package/examples/recipes/website-watch/rules.json +56 -0
  142. package/examples/recipes/website-watch/site.json +6 -0
  143. package/examples/skills/weekly-sweep/SKILL.md +17 -0
  144. package/examples/watch-github-issues.sh +23 -0
  145. package/examples/worker.sh +18 -0
  146. package/package.json +57 -4
  147. package/plugins/acp/agent.ts +31 -0
  148. package/plugins/acp/bridge.ts +190 -0
  149. package/plugins/claude/agent.ts +121 -0
  150. package/plugins/codex/agent.ts +103 -0
  151. package/plugins/command/agent.ts +25 -0
  152. package/plugins/delivery/action.ts +29 -0
  153. package/plugins/delivery/action.yml +28 -0
  154. package/plugins/delivery/agent.ts +15 -0
  155. package/plugins/delivery/delivery.ts +408 -0
  156. package/plugins/delivery/github.ts +207 -0
  157. package/plugins/delivery/handoff.ts +72 -0
  158. package/plugins/delivery/input.ts +55 -0
  159. package/plugins/delivery/poll.ts +65 -0
  160. package/plugins/delivery/project.ts +161 -0
  161. package/plugins/delivery/review-ledger.ts +90 -0
  162. package/plugins/delivery/review-policy.ts +126 -0
  163. package/plugins/delivery/review.ts +324 -0
  164. package/plugins/delivery/run.ts +219 -0
  165. package/plugins/desktop/channel.ts +100 -0
  166. package/plugins/dsh/agent.ts +100 -0
  167. package/plugins/feishu/channel.ts +243 -0
  168. package/plugins/github/source.ts +33 -0
  169. package/plugins/gitlab/source.ts +32 -0
  170. package/plugins/omp/agent.ts +4 -0
  171. package/plugins/opencode/agent.ts +78 -0
  172. package/plugins/pi/agent.ts +80 -0
  173. package/plugins/webhook/channel.ts +74 -0
  174. package/plugins/webhook/templates.ts +32 -0
  175. package/plugins/xiaojiu/channel.ts +426 -0
  176. package/plugins/zcode/agent.ts +96 -0
  177. package/skills/agent-autoloop/SKILL.md +260 -0
@@ -0,0 +1,985 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:agent-autoloop:protocol:v1",
4
+ "$defs": {
5
+ "event": {
6
+ "type": "object",
7
+ "properties": {
8
+ "id": {
9
+ "type": "string",
10
+ "maxLength": 200,
11
+ "minLength": 1
12
+ },
13
+ "type": {
14
+ "type": "string",
15
+ "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
16
+ },
17
+ "subject": {
18
+ "type": ["string", "null"],
19
+ "maxLength": 100,
20
+ "pattern": "^[A-Za-z0-9#._:\\/@-]*$"
21
+ },
22
+ "summary": {
23
+ "type": ["string", "null"],
24
+ "maxLength": 200
25
+ },
26
+ "detail": {
27
+ "type": ["string", "null"],
28
+ "maxLength": 4000
29
+ },
30
+ "link": {
31
+ "type": ["string", "null"],
32
+ "maxLength": 500,
33
+ "pattern": "^(https?://[\\x21-\\x7e]+)?$"
34
+ },
35
+ "hops": {
36
+ "type": "integer",
37
+ "minimum": 0,
38
+ "maximum": 9007199254740991
39
+ }
40
+ },
41
+ "required": ["id", "type"],
42
+ "additionalProperties": false
43
+ },
44
+ "usage": {
45
+ "type": "object",
46
+ "additionalProperties": {
47
+ "type": "number",
48
+ "minimum": 0
49
+ }
50
+ },
51
+ "ask": {
52
+ "type": "object",
53
+ "properties": {
54
+ "title": {
55
+ "type": "string",
56
+ "maxLength": 200,
57
+ "minLength": 1,
58
+ "pattern": "\\S"
59
+ },
60
+ "text": {
61
+ "type": "string",
62
+ "maxLength": 4000,
63
+ "minLength": 1,
64
+ "pattern": "\\S"
65
+ },
66
+ "options": {
67
+ "type": "array",
68
+ "items": {
69
+ "type": "string",
70
+ "maxLength": 200,
71
+ "minLength": 1,
72
+ "pattern": "\\S"
73
+ },
74
+ "minItems": 2,
75
+ "maxItems": 5
76
+ },
77
+ "recommend": {
78
+ "type": "integer",
79
+ "minimum": 0,
80
+ "maximum": 4
81
+ },
82
+ "about": {
83
+ "type": "string",
84
+ "maxLength": 4000
85
+ },
86
+ "key": {
87
+ "type": "string",
88
+ "maxLength": 100
89
+ }
90
+ },
91
+ "required": ["title", "text", "options"],
92
+ "additionalProperties": false,
93
+ "oneOf": [
94
+ {
95
+ "properties": {
96
+ "options": {
97
+ "type": "array",
98
+ "minItems": 2,
99
+ "maxItems": 2
100
+ },
101
+ "recommend": {
102
+ "type": "integer",
103
+ "maximum": 1
104
+ }
105
+ }
106
+ },
107
+ {
108
+ "properties": {
109
+ "options": {
110
+ "type": "array",
111
+ "minItems": 3,
112
+ "maxItems": 3
113
+ },
114
+ "recommend": {
115
+ "type": "integer",
116
+ "maximum": 2
117
+ }
118
+ }
119
+ },
120
+ {
121
+ "properties": {
122
+ "options": {
123
+ "type": "array",
124
+ "minItems": 4,
125
+ "maxItems": 4
126
+ },
127
+ "recommend": {
128
+ "type": "integer",
129
+ "maximum": 3
130
+ }
131
+ }
132
+ },
133
+ {
134
+ "properties": {
135
+ "options": {
136
+ "type": "array",
137
+ "minItems": 5,
138
+ "maxItems": 5
139
+ },
140
+ "recommend": {
141
+ "type": "integer",
142
+ "maximum": 4
143
+ }
144
+ }
145
+ }
146
+ ]
147
+ },
148
+ "notice": {
149
+ "type": "object",
150
+ "properties": {
151
+ "title": {
152
+ "type": "string",
153
+ "maxLength": 200,
154
+ "minLength": 1,
155
+ "pattern": "\\S"
156
+ },
157
+ "text": {
158
+ "type": "string",
159
+ "maxLength": 4000,
160
+ "minLength": 1,
161
+ "pattern": "\\S"
162
+ },
163
+ "key": {
164
+ "type": "string",
165
+ "maxLength": 100
166
+ },
167
+ "fyi": {
168
+ "type": "boolean"
169
+ }
170
+ },
171
+ "required": ["title", "text"],
172
+ "additionalProperties": false
173
+ },
174
+ "resolve": {
175
+ "type": "object",
176
+ "properties": {
177
+ "card": {
178
+ "type": "integer",
179
+ "minimum": 1
180
+ },
181
+ "reason": {
182
+ "type": "string",
183
+ "maxLength": 1000,
184
+ "minLength": 1,
185
+ "pattern": "\\S"
186
+ }
187
+ },
188
+ "required": ["card", "reason"],
189
+ "additionalProperties": false
190
+ },
191
+ "later": {
192
+ "oneOf": [
193
+ {
194
+ "type": "object",
195
+ "properties": {
196
+ "key": {
197
+ "type": "string",
198
+ "maxLength": 100,
199
+ "minLength": 1,
200
+ "pattern": "\\S"
201
+ },
202
+ "cancel": {
203
+ "const": true
204
+ },
205
+ "about": {}
206
+ },
207
+ "required": ["key", "cancel"],
208
+ "additionalProperties": false
209
+ },
210
+ {
211
+ "type": "object",
212
+ "properties": {
213
+ "key": {
214
+ "type": "string",
215
+ "maxLength": 100,
216
+ "minLength": 1,
217
+ "pattern": "\\S"
218
+ },
219
+ "at": {
220
+ "type": "string",
221
+ "format": "date-time",
222
+ "pattern": "(Z|[+-]\\d\\d:\\d\\d)$"
223
+ },
224
+ "about": {
225
+ "type": "string",
226
+ "maxLength": 4000,
227
+ "minLength": 1,
228
+ "pattern": "\\S"
229
+ }
230
+ },
231
+ "required": ["key", "at", "about"],
232
+ "additionalProperties": false
233
+ }
234
+ ]
235
+ },
236
+ "result": {
237
+ "type": "object",
238
+ "properties": {
239
+ "outcome": {
240
+ "enum": ["done", "nothing", "failed", "cancelled"]
241
+ },
242
+ "summary": {
243
+ "type": "string",
244
+ "maxLength": 500
245
+ },
246
+ "error": {
247
+ "type": "string",
248
+ "maxLength": 500
249
+ },
250
+ "session": {
251
+ "type": "string",
252
+ "maxLength": 500
253
+ },
254
+ "usage": {
255
+ "$ref": "#/$defs/usage"
256
+ },
257
+ "ask": {
258
+ "type": "array",
259
+ "items": {
260
+ "$ref": "#/$defs/ask"
261
+ },
262
+ "maxItems": 5
263
+ },
264
+ "notice": {
265
+ "type": "array",
266
+ "items": {
267
+ "$ref": "#/$defs/notice"
268
+ },
269
+ "maxItems": 10
270
+ },
271
+ "resolve": {
272
+ "type": "array",
273
+ "items": {
274
+ "$ref": "#/$defs/resolve"
275
+ },
276
+ "maxItems": 50
277
+ },
278
+ "later": {
279
+ "type": "array",
280
+ "items": {
281
+ "$ref": "#/$defs/later"
282
+ },
283
+ "maxItems": 10
284
+ },
285
+ "events": {
286
+ "type": "array",
287
+ "items": {
288
+ "$ref": "#/$defs/event"
289
+ },
290
+ "maxItems": 100
291
+ }
292
+ },
293
+ "required": ["outcome"],
294
+ "additionalProperties": false
295
+ },
296
+ "started": {
297
+ "type": "object",
298
+ "properties": {
299
+ "session": {
300
+ "type": "string",
301
+ "maxLength": 500
302
+ },
303
+ "link": {
304
+ "type": "string",
305
+ "maxLength": 500
306
+ }
307
+ },
308
+ "required": [],
309
+ "additionalProperties": true
310
+ },
311
+ "answer": {
312
+ "type": "object",
313
+ "properties": {
314
+ "choice": {
315
+ "type": "integer",
316
+ "minimum": 0
317
+ },
318
+ "text": {
319
+ "type": "string",
320
+ "maxLength": 4000
321
+ },
322
+ "by": {
323
+ "type": "string",
324
+ "maxLength": 500
325
+ },
326
+ "ref": {
327
+ "type": "string",
328
+ "maxLength": 500
329
+ }
330
+ },
331
+ "required": [],
332
+ "additionalProperties": true
333
+ },
334
+ "delivered": {
335
+ "type": "object",
336
+ "properties": {
337
+ "version": {
338
+ "type": "integer",
339
+ "minimum": 1
340
+ },
341
+ "ref": {
342
+ "type": ["string", "null"],
343
+ "maxLength": 500
344
+ }
345
+ },
346
+ "required": ["version"],
347
+ "additionalProperties": false
348
+ },
349
+ "failed": {
350
+ "type": "object",
351
+ "properties": {
352
+ "version": {
353
+ "type": "integer",
354
+ "minimum": 1
355
+ },
356
+ "error": {
357
+ "type": "string",
358
+ "maxLength": 300
359
+ }
360
+ },
361
+ "required": ["version", "error"],
362
+ "additionalProperties": false
363
+ },
364
+ "tell-source": {
365
+ "type": "object",
366
+ "properties": {
367
+ "key": {
368
+ "type": "string",
369
+ "pattern": "^[a-z0-9][a-z0-9._-]{0,63}$"
370
+ },
371
+ "text": {
372
+ "type": "string",
373
+ "maxLength": 20000,
374
+ "minLength": 1,
375
+ "pattern": "\\S"
376
+ }
377
+ },
378
+ "required": ["key", "text"],
379
+ "additionalProperties": false
380
+ },
381
+ "tell-worker": {
382
+ "type": "object",
383
+ "properties": {
384
+ "key": {
385
+ "type": "string",
386
+ "pattern": "^[a-z0-9][a-z0-9._-]{0,63}$"
387
+ },
388
+ "text": {
389
+ "type": "string",
390
+ "maxLength": 20000,
391
+ "minLength": 1,
392
+ "pattern": "\\S"
393
+ },
394
+ "task": {
395
+ "type": "string",
396
+ "maxLength": 200,
397
+ "minLength": 1,
398
+ "pattern": "\\S"
399
+ }
400
+ },
401
+ "required": ["key", "text", "task"],
402
+ "additionalProperties": false
403
+ },
404
+ "ask-worker": {
405
+ "type": "object",
406
+ "properties": {
407
+ "task": {
408
+ "type": "string",
409
+ "maxLength": 200,
410
+ "minLength": 1,
411
+ "pattern": "\\S"
412
+ },
413
+ "ask": { "$ref": "#/$defs/ask" }
414
+ },
415
+ "required": ["task", "ask"],
416
+ "additionalProperties": false
417
+ },
418
+ "job": {
419
+ "type": "object",
420
+ "properties": {
421
+ "run": {
422
+ "type": "integer",
423
+ "minimum": 1
424
+ },
425
+ "token": {
426
+ "type": "string",
427
+ "maxLength": 100,
428
+ "minLength": 1,
429
+ "pattern": "\\S"
430
+ },
431
+ "rule": {
432
+ "type": "object",
433
+ "properties": {
434
+ "name": {
435
+ "type": "string"
436
+ },
437
+ "cwd": {
438
+ "type": "string"
439
+ },
440
+ "skill": {
441
+ "type": "string"
442
+ },
443
+ "prompt": {
444
+ "type": "string"
445
+ },
446
+ "title": {
447
+ "type": "string"
448
+ },
449
+ "emits": {
450
+ "type": "object",
451
+ "properties": {
452
+ "source": {
453
+ "type": "string"
454
+ },
455
+ "types": {
456
+ "type": "array",
457
+ "items": {
458
+ "type": "string"
459
+ }
460
+ }
461
+ },
462
+ "required": ["source", "types"],
463
+ "additionalProperties": true
464
+ }
465
+ },
466
+ "required": ["name", "cwd"],
467
+ "additionalProperties": true
468
+ },
469
+ "agent": {
470
+ "type": "object",
471
+ "properties": {
472
+ "id": {
473
+ "type": "string"
474
+ },
475
+ "name": {
476
+ "type": "string"
477
+ },
478
+ "use": {
479
+ "type": "string"
480
+ },
481
+ "worker": {
482
+ "type": "string"
483
+ },
484
+ "model": {
485
+ "type": "string"
486
+ },
487
+ "effort": {
488
+ "type": "string"
489
+ },
490
+ "tier": {
491
+ "type": "string"
492
+ },
493
+ "access": {
494
+ "enum": ["read", "edit", "full"]
495
+ },
496
+ "command": {
497
+ "type": "array",
498
+ "items": {
499
+ "type": "string"
500
+ }
501
+ },
502
+ "program": {
503
+ "type": "string"
504
+ },
505
+ "timeout": {
506
+ "type": "integer",
507
+ "minimum": 1
508
+ }
509
+ },
510
+ "required": ["id", "name", "use", "access"],
511
+ "additionalProperties": true
512
+ },
513
+ "context": {
514
+ "type": "object",
515
+ "properties": {
516
+ "events": {
517
+ "type": "array",
518
+ "items": {
519
+ "$ref": "#/$defs/context-event"
520
+ }
521
+ },
522
+ "answers": {
523
+ "type": "array",
524
+ "items": {
525
+ "$ref": "#/$defs/context-answer"
526
+ }
527
+ },
528
+ "timers": {
529
+ "type": "array",
530
+ "items": {
531
+ "$ref": "#/$defs/context-timer"
532
+ }
533
+ },
534
+ "waiting": {
535
+ "type": "array",
536
+ "items": {
537
+ "$ref": "#/$defs/context-timer"
538
+ }
539
+ },
540
+ "open": {
541
+ "type": "array",
542
+ "items": {
543
+ "$ref": "#/$defs/context-open"
544
+ }
545
+ },
546
+ "decided": {
547
+ "type": "array",
548
+ "items": {
549
+ "$ref": "#/$defs/context-decided"
550
+ }
551
+ }
552
+ },
553
+ "required": ["events", "answers", "timers", "waiting", "open", "decided"],
554
+ "additionalProperties": true
555
+ },
556
+ "session": {
557
+ "type": ["string", "null"]
558
+ },
559
+ "attempt": {
560
+ "type": "integer",
561
+ "minimum": 1
562
+ },
563
+ "askFirst": {
564
+ "type": "array",
565
+ "items": {
566
+ "type": "string"
567
+ }
568
+ }
569
+ },
570
+ "required": ["run", "token", "attempt", "rule", "agent", "session", "askFirst", "context"],
571
+ "additionalProperties": true
572
+ },
573
+ "card": {
574
+ "type": "object",
575
+ "properties": {
576
+ "id": {
577
+ "type": "integer",
578
+ "minimum": 1
579
+ },
580
+ "version": {
581
+ "type": "integer",
582
+ "minimum": 1
583
+ },
584
+ "kind": {
585
+ "enum": ["ask", "notice"]
586
+ },
587
+ "state": {
588
+ "enum": ["open", "decided", "done", "closed"]
589
+ },
590
+ "title": {
591
+ "type": "string"
592
+ },
593
+ "text": {
594
+ "type": "string"
595
+ },
596
+ "options": {
597
+ "type": "array",
598
+ "items": {
599
+ "type": "string"
600
+ }
601
+ },
602
+ "ref": {
603
+ "type": ["string", "null"]
604
+ },
605
+ "recommend": {
606
+ "type": ["integer", "null"],
607
+ "minimum": 0
608
+ },
609
+ "choice": {
610
+ "type": ["integer", "null"],
611
+ "minimum": 0
612
+ },
613
+ "answer": {
614
+ "type": ["string", "null"]
615
+ },
616
+ "by": {
617
+ "type": ["string", "null"]
618
+ },
619
+ "result": {
620
+ "type": ["string", "null"]
621
+ },
622
+ "link": {
623
+ "type": ["string", "null"]
624
+ }
625
+ },
626
+ "required": [
627
+ "id",
628
+ "version",
629
+ "kind",
630
+ "state",
631
+ "title",
632
+ "text",
633
+ "options",
634
+ "ref",
635
+ "recommend",
636
+ "choice",
637
+ "answer",
638
+ "by",
639
+ "result",
640
+ "link"
641
+ ],
642
+ "additionalProperties": true,
643
+ "oneOf": [
644
+ {
645
+ "properties": {
646
+ "kind": {
647
+ "const": "ask"
648
+ },
649
+ "options": {
650
+ "type": "array",
651
+ "minItems": 2,
652
+ "maxItems": 5
653
+ }
654
+ }
655
+ },
656
+ {
657
+ "properties": {
658
+ "kind": {
659
+ "const": "notice"
660
+ }
661
+ }
662
+ }
663
+ ]
664
+ },
665
+ "work": {
666
+ "type": "object",
667
+ "properties": {
668
+ "job": {
669
+ "anyOf": [
670
+ {
671
+ "$ref": "#/$defs/job"
672
+ },
673
+ {
674
+ "type": "null"
675
+ }
676
+ ]
677
+ },
678
+ "cancel": {
679
+ "type": "array",
680
+ "items": {
681
+ "type": "integer",
682
+ "minimum": 1
683
+ }
684
+ }
685
+ },
686
+ "required": ["job", "cancel"],
687
+ "additionalProperties": false
688
+ },
689
+ "eventAck": {
690
+ "type": "object",
691
+ "properties": {
692
+ "event": {
693
+ "type": "integer",
694
+ "minimum": 1
695
+ },
696
+ "duplicate": {
697
+ "type": "boolean"
698
+ },
699
+ "routed": {
700
+ "type": "array",
701
+ "items": {
702
+ "type": "string",
703
+ "maxLength": 200
704
+ }
705
+ },
706
+ "paused": {
707
+ "description": "Rules that match the event but are paused, so it was recorded for them and not dispatched.",
708
+ "type": "array",
709
+ "items": {
710
+ "type": "string",
711
+ "maxLength": 200
712
+ }
713
+ }
714
+ },
715
+ "required": ["event", "duplicate", "routed"],
716
+ "additionalProperties": false
717
+ },
718
+ "eventOutcome": {
719
+ "description": "What became of an event, read with the key of the source that sent it.",
720
+ "type": "object",
721
+ "properties": {
722
+ "event": { "type": "integer", "minimum": 1 },
723
+ "routed": { "type": "array", "items": { "type": "string", "maxLength": 200 } },
724
+ "paused": { "type": "array", "items": { "type": "string", "maxLength": 200 } },
725
+ "runs": {
726
+ "type": "array",
727
+ "items": {
728
+ "type": "object",
729
+ "properties": {
730
+ "run": { "type": "integer", "minimum": 1 },
731
+ "rule": { "type": "string", "maxLength": 200 },
732
+ "state": { "enum": ["queued", "claimed", "unknown", "done", "nothing", "cancelled"] },
733
+ "attempts": { "type": "integer", "minimum": 0 },
734
+ "error": { "type": ["string", "null"] },
735
+ "finishedAt": { "anyOf": [{ "type": "null" }, { "type": "string", "format": "date-time" }] },
736
+ "summary": {
737
+ "description": "Null until it ends, and whenever the run also took another source's events.",
738
+ "type": ["string", "null"]
739
+ },
740
+ "events": {
741
+ "description": "What its receipt sent; null whenever the run also took another source's events.",
742
+ "anyOf": [{ "type": "null" }, { "type": "array", "items": { "$ref": "#/$defs/event" } }]
743
+ }
744
+ },
745
+ "required": ["run", "rule", "state", "attempts", "error", "finishedAt", "summary", "events"],
746
+ "additionalProperties": false
747
+ }
748
+ }
749
+ },
750
+ "required": ["event", "routed", "paused", "runs"],
751
+ "additionalProperties": false
752
+ },
753
+ "receiptAck": {
754
+ "type": "object",
755
+ "properties": {
756
+ "rejected": {
757
+ "type": "array",
758
+ "items": {
759
+ "type": "object",
760
+ "properties": {
761
+ "card": {
762
+ "type": "integer",
763
+ "minimum": 1
764
+ },
765
+ "what": {
766
+ "type": "string",
767
+ "maxLength": 500
768
+ },
769
+ "reason": {
770
+ "type": "string",
771
+ "maxLength": 1000
772
+ }
773
+ },
774
+ "required": ["reason"],
775
+ "additionalProperties": false
776
+ }
777
+ },
778
+ "duplicate": {
779
+ "type": "boolean"
780
+ }
781
+ },
782
+ "required": ["rejected"],
783
+ "additionalProperties": false
784
+ },
785
+ "fact": {
786
+ "type": "object",
787
+ "properties": {
788
+ "version": {
789
+ "const": 1
790
+ },
791
+ "seq": {
792
+ "type": "integer",
793
+ "minimum": 1
794
+ },
795
+ "at": {
796
+ "type": "number"
797
+ },
798
+ "type": {
799
+ "type": "string",
800
+ "maxLength": 100
801
+ },
802
+ "changes": {
803
+ "type": "array",
804
+ "items": {
805
+ "type": "object",
806
+ "properties": {
807
+ "table": {
808
+ "type": "string",
809
+ "maxLength": 100
810
+ },
811
+ "key": {
812
+ "type": "string",
813
+ "maxLength": 500
814
+ },
815
+ "row": {
816
+ "type": ["object", "null"]
817
+ }
818
+ },
819
+ "required": ["table", "key", "row"],
820
+ "additionalProperties": false
821
+ }
822
+ }
823
+ },
824
+ "required": ["version", "seq", "at", "type", "changes"],
825
+ "additionalProperties": false
826
+ },
827
+ "error": {
828
+ "type": "object",
829
+ "properties": {
830
+ "error": {
831
+ "type": "string",
832
+ "maxLength": 4000
833
+ }
834
+ },
835
+ "required": ["error"],
836
+ "additionalProperties": false
837
+ },
838
+ "context-event": {
839
+ "type": "object",
840
+ "properties": {
841
+ "id": {
842
+ "type": "string"
843
+ },
844
+ "source": {
845
+ "type": "string"
846
+ },
847
+ "sourceName": {
848
+ "type": "string"
849
+ },
850
+ "type": {
851
+ "type": "string"
852
+ },
853
+ "subject": {
854
+ "type": "string"
855
+ },
856
+ "summary": {
857
+ "type": "string"
858
+ },
859
+ "detail": {
860
+ "type": "string"
861
+ },
862
+ "link": {
863
+ "type": "string"
864
+ },
865
+ "receivedAt": {
866
+ "type": "string"
867
+ },
868
+ "hops": {
869
+ "type": "integer",
870
+ "minimum": 0,
871
+ "maximum": 9007199254740991
872
+ }
873
+ },
874
+ "required": ["id", "source", "sourceName", "type", "subject", "summary", "detail", "link", "receivedAt"],
875
+ "additionalProperties": true
876
+ },
877
+ "context-answer": {
878
+ "type": "object",
879
+ "properties": {
880
+ "card": {
881
+ "type": "integer",
882
+ "minimum": 1
883
+ },
884
+ "title": {
885
+ "type": "string"
886
+ },
887
+ "options": {
888
+ "type": "array",
889
+ "items": {
890
+ "type": "string"
891
+ }
892
+ },
893
+ "choice": {
894
+ "type": ["integer", "null"],
895
+ "minimum": 0
896
+ },
897
+ "chosen": {
898
+ "type": ["string", "null"]
899
+ },
900
+ "text": {
901
+ "type": ["string", "null"]
902
+ },
903
+ "about": {
904
+ "type": "string"
905
+ },
906
+ "by": {
907
+ "type": ["string", "null"]
908
+ },
909
+ "at": {
910
+ "type": "string"
911
+ },
912
+ "events": {
913
+ "type": "array",
914
+ "items": {
915
+ "type": "string"
916
+ }
917
+ }
918
+ },
919
+ "required": ["card", "title", "options", "choice", "chosen", "text", "about", "by", "at", "events"],
920
+ "additionalProperties": true
921
+ },
922
+ "context-timer": {
923
+ "type": "object",
924
+ "properties": {
925
+ "key": {
926
+ "type": "string"
927
+ },
928
+ "about": {
929
+ "type": "string"
930
+ },
931
+ "at": {
932
+ "type": "string"
933
+ },
934
+ "events": {
935
+ "type": "array",
936
+ "items": {
937
+ "type": "string"
938
+ }
939
+ }
940
+ },
941
+ "required": ["key", "about", "at", "events"],
942
+ "additionalProperties": true
943
+ },
944
+ "context-open": {
945
+ "type": "object",
946
+ "properties": {
947
+ "card": {
948
+ "type": "integer",
949
+ "minimum": 1
950
+ },
951
+ "title": {
952
+ "type": "string"
953
+ },
954
+ "text": {
955
+ "type": "string"
956
+ },
957
+ "at": {
958
+ "type": "string"
959
+ }
960
+ },
961
+ "required": ["card", "title", "text", "at"],
962
+ "additionalProperties": true
963
+ },
964
+ "context-decided": {
965
+ "type": "object",
966
+ "properties": {
967
+ "card": {
968
+ "type": "integer",
969
+ "minimum": 1
970
+ },
971
+ "title": {
972
+ "type": "string"
973
+ },
974
+ "choice": {
975
+ "type": ["string", "null"]
976
+ },
977
+ "at": {
978
+ "type": "string"
979
+ }
980
+ },
981
+ "required": ["card", "title", "choice", "at"],
982
+ "additionalProperties": true
983
+ }
984
+ }
985
+ }