agent-relay 2.3.4 → 2.3.5

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 (297) hide show
  1. package/README.md +1 -1
  2. package/dist/src/cli/index.js +124 -7
  3. package/dist/src/cli/index.js.map +1 -1
  4. package/package.json +20 -26
  5. package/packages/acp-bridge/package.json +2 -2
  6. package/packages/bridge/package.json +7 -7
  7. package/packages/config/package.json +2 -2
  8. package/packages/continuity/package.json +2 -2
  9. package/packages/daemon/package.json +12 -12
  10. package/packages/hooks/package.json +4 -4
  11. package/packages/mcp/package.json +5 -5
  12. package/packages/memory/package.json +2 -2
  13. package/packages/policy/package.json +2 -2
  14. package/packages/protocol/package.json +1 -1
  15. package/packages/resiliency/package.json +1 -1
  16. package/packages/sdk/dist/index.d.ts +1 -29
  17. package/packages/sdk/dist/index.d.ts.map +1 -1
  18. package/packages/sdk/dist/index.js +1 -38
  19. package/packages/sdk/dist/index.js.map +1 -1
  20. package/packages/sdk/package.json +4 -25
  21. package/packages/sdk/src/index.ts +1 -69
  22. package/packages/sdk-py/README.md +56 -0
  23. package/packages/sdk-py/pyproject.toml +23 -0
  24. package/packages/sdk-py/src/agent_relay/__init__.py +27 -0
  25. package/packages/sdk-py/src/agent_relay/builder.py +367 -0
  26. package/packages/sdk-py/src/agent_relay/types.py +92 -0
  27. package/packages/sdk-py/tests/__init__.py +0 -0
  28. package/packages/sdk-py/tests/test_builder.py +101 -0
  29. package/packages/sdk-ts/dist/index.d.ts +1 -0
  30. package/packages/sdk-ts/dist/index.d.ts.map +1 -1
  31. package/packages/sdk-ts/dist/index.js +1 -0
  32. package/packages/sdk-ts/dist/index.js.map +1 -1
  33. package/packages/sdk-ts/dist/workflows/barrier.d.ts +72 -0
  34. package/packages/sdk-ts/dist/workflows/barrier.d.ts.map +1 -0
  35. package/packages/sdk-ts/dist/workflows/barrier.js +162 -0
  36. package/packages/sdk-ts/dist/workflows/barrier.js.map +1 -0
  37. package/packages/sdk-ts/dist/workflows/builder.d.ts +101 -0
  38. package/packages/sdk-ts/dist/workflows/builder.d.ts.map +1 -0
  39. package/packages/sdk-ts/dist/workflows/builder.js +179 -0
  40. package/packages/sdk-ts/dist/workflows/builder.js.map +1 -0
  41. package/packages/sdk-ts/dist/workflows/cli.d.ts +10 -0
  42. package/packages/sdk-ts/dist/workflows/cli.d.ts.map +1 -0
  43. package/packages/sdk-ts/dist/workflows/cli.js +82 -0
  44. package/packages/sdk-ts/dist/workflows/cli.js.map +1 -0
  45. package/packages/sdk-ts/dist/workflows/coordinator.d.ts +68 -0
  46. package/packages/sdk-ts/dist/workflows/coordinator.d.ts.map +1 -0
  47. package/packages/sdk-ts/dist/workflows/coordinator.js +353 -0
  48. package/packages/sdk-ts/dist/workflows/coordinator.js.map +1 -0
  49. package/packages/sdk-ts/dist/workflows/index.d.ts +10 -0
  50. package/packages/sdk-ts/dist/workflows/index.d.ts.map +1 -0
  51. package/packages/sdk-ts/dist/workflows/index.js +10 -0
  52. package/packages/sdk-ts/dist/workflows/index.js.map +1 -0
  53. package/packages/sdk-ts/dist/workflows/memory-db.d.ts +17 -0
  54. package/packages/sdk-ts/dist/workflows/memory-db.d.ts.map +1 -0
  55. package/packages/sdk-ts/dist/workflows/memory-db.js +33 -0
  56. package/packages/sdk-ts/dist/workflows/memory-db.js.map +1 -0
  57. package/packages/sdk-ts/dist/workflows/run.d.ts +31 -0
  58. package/packages/sdk-ts/dist/workflows/run.d.ts.map +1 -0
  59. package/packages/sdk-ts/dist/workflows/run.js +24 -0
  60. package/packages/sdk-ts/dist/workflows/run.js.map +1 -0
  61. package/packages/sdk-ts/dist/workflows/runner.d.ts +119 -0
  62. package/packages/sdk-ts/dist/workflows/runner.d.ts.map +1 -0
  63. package/packages/sdk-ts/dist/workflows/runner.js +650 -0
  64. package/packages/sdk-ts/dist/workflows/runner.js.map +1 -0
  65. package/packages/sdk-ts/dist/workflows/state.d.ts +77 -0
  66. package/packages/sdk-ts/dist/workflows/state.d.ts.map +1 -0
  67. package/packages/sdk-ts/dist/workflows/state.js +140 -0
  68. package/packages/sdk-ts/dist/workflows/state.js.map +1 -0
  69. package/packages/sdk-ts/dist/workflows/templates.d.ts +47 -0
  70. package/packages/sdk-ts/dist/workflows/templates.d.ts.map +1 -0
  71. package/packages/sdk-ts/dist/workflows/templates.js +395 -0
  72. package/packages/sdk-ts/dist/workflows/templates.js.map +1 -0
  73. package/packages/sdk-ts/dist/workflows/types.d.ts +126 -0
  74. package/packages/sdk-ts/dist/workflows/types.d.ts.map +1 -0
  75. package/packages/sdk-ts/dist/workflows/types.js +8 -0
  76. package/packages/sdk-ts/dist/workflows/types.js.map +1 -0
  77. package/packages/sdk-ts/package.json +8 -2
  78. package/packages/sdk-ts/src/__tests__/error-scenarios.test.ts +682 -0
  79. package/packages/sdk-ts/src/__tests__/swarm-coordinator.test.ts +416 -0
  80. package/packages/sdk-ts/src/__tests__/workflow-runner.test.ts +333 -0
  81. package/packages/sdk-ts/src/index.ts +1 -0
  82. package/packages/sdk-ts/src/workflows/README.md +450 -0
  83. package/packages/sdk-ts/src/workflows/barrier.ts +254 -0
  84. package/packages/sdk-ts/src/workflows/builder.ts +241 -0
  85. package/packages/sdk-ts/src/workflows/builtin-templates/bug-fix.yaml +75 -0
  86. package/packages/sdk-ts/src/workflows/builtin-templates/code-review.yaml +82 -0
  87. package/packages/sdk-ts/src/workflows/builtin-templates/documentation.yaml +70 -0
  88. package/packages/sdk-ts/src/workflows/builtin-templates/feature-dev.yaml +76 -0
  89. package/packages/sdk-ts/src/workflows/builtin-templates/refactor.yaml +82 -0
  90. package/packages/sdk-ts/src/workflows/builtin-templates/security-audit.yaml +84 -0
  91. package/packages/sdk-ts/src/workflows/cli.ts +93 -0
  92. package/packages/sdk-ts/src/workflows/coordinator.ts +520 -0
  93. package/packages/sdk-ts/src/workflows/index.ts +9 -0
  94. package/packages/sdk-ts/src/workflows/memory-db.ts +39 -0
  95. package/packages/sdk-ts/src/workflows/run.ts +47 -0
  96. package/packages/sdk-ts/src/workflows/runner.ts +873 -0
  97. package/packages/sdk-ts/src/workflows/schema.json +321 -0
  98. package/packages/sdk-ts/src/workflows/state.ts +279 -0
  99. package/packages/sdk-ts/src/workflows/templates.ts +544 -0
  100. package/packages/sdk-ts/src/workflows/types.ts +178 -0
  101. package/packages/sdk-ts/tsconfig.json +6 -1
  102. package/packages/spawner/package.json +1 -1
  103. package/packages/state/package.json +1 -1
  104. package/packages/storage/package.json +2 -2
  105. package/packages/telemetry/package.json +1 -1
  106. package/packages/trajectory/package.json +2 -2
  107. package/packages/user-directory/package.json +2 -2
  108. package/packages/utils/package.json +3 -3
  109. package/packages/wrapper/package.json +5 -6
  110. package/packages/api-types/.trajectories/active/traj_xbsvuzogscey.json +0 -15
  111. package/packages/api-types/.trajectories/index.json +0 -12
  112. package/packages/api-types/dist/index.d.ts +0 -21
  113. package/packages/api-types/dist/index.d.ts.map +0 -1
  114. package/packages/api-types/dist/index.js +0 -22
  115. package/packages/api-types/dist/index.js.map +0 -1
  116. package/packages/api-types/dist/schemas/agent.d.ts +0 -259
  117. package/packages/api-types/dist/schemas/agent.d.ts.map +0 -1
  118. package/packages/api-types/dist/schemas/agent.js +0 -102
  119. package/packages/api-types/dist/schemas/agent.js.map +0 -1
  120. package/packages/api-types/dist/schemas/api.d.ts +0 -290
  121. package/packages/api-types/dist/schemas/api.d.ts.map +0 -1
  122. package/packages/api-types/dist/schemas/api.js +0 -162
  123. package/packages/api-types/dist/schemas/api.js.map +0 -1
  124. package/packages/api-types/dist/schemas/decision.d.ts +0 -230
  125. package/packages/api-types/dist/schemas/decision.d.ts.map +0 -1
  126. package/packages/api-types/dist/schemas/decision.js +0 -104
  127. package/packages/api-types/dist/schemas/decision.js.map +0 -1
  128. package/packages/api-types/dist/schemas/fleet.d.ts +0 -615
  129. package/packages/api-types/dist/schemas/fleet.d.ts.map +0 -1
  130. package/packages/api-types/dist/schemas/fleet.js +0 -71
  131. package/packages/api-types/dist/schemas/fleet.js.map +0 -1
  132. package/packages/api-types/dist/schemas/history.d.ts +0 -180
  133. package/packages/api-types/dist/schemas/history.d.ts.map +0 -1
  134. package/packages/api-types/dist/schemas/history.js +0 -72
  135. package/packages/api-types/dist/schemas/history.js.map +0 -1
  136. package/packages/api-types/dist/schemas/index.d.ts +0 -14
  137. package/packages/api-types/dist/schemas/index.d.ts.map +0 -1
  138. package/packages/api-types/dist/schemas/index.js +0 -22
  139. package/packages/api-types/dist/schemas/index.js.map +0 -1
  140. package/packages/api-types/dist/schemas/message.d.ts +0 -456
  141. package/packages/api-types/dist/schemas/message.d.ts.map +0 -1
  142. package/packages/api-types/dist/schemas/message.js +0 -88
  143. package/packages/api-types/dist/schemas/message.js.map +0 -1
  144. package/packages/api-types/dist/schemas/session.d.ts +0 -60
  145. package/packages/api-types/dist/schemas/session.d.ts.map +0 -1
  146. package/packages/api-types/dist/schemas/session.js +0 -36
  147. package/packages/api-types/dist/schemas/session.js.map +0 -1
  148. package/packages/api-types/dist/schemas/task.d.ts +0 -111
  149. package/packages/api-types/dist/schemas/task.d.ts.map +0 -1
  150. package/packages/api-types/dist/schemas/task.js +0 -64
  151. package/packages/api-types/dist/schemas/task.js.map +0 -1
  152. package/packages/api-types/package.json +0 -61
  153. package/packages/api-types/scripts/generate-openapi.ts +0 -106
  154. package/packages/api-types/src/index.ts +0 -22
  155. package/packages/api-types/src/schemas/agent.test.ts +0 -164
  156. package/packages/api-types/src/schemas/agent.ts +0 -110
  157. package/packages/api-types/src/schemas/api.test.ts +0 -372
  158. package/packages/api-types/src/schemas/api.ts +0 -194
  159. package/packages/api-types/src/schemas/decision.test.ts +0 -324
  160. package/packages/api-types/src/schemas/decision.ts +0 -136
  161. package/packages/api-types/src/schemas/fleet.test.ts +0 -212
  162. package/packages/api-types/src/schemas/fleet.ts +0 -83
  163. package/packages/api-types/src/schemas/history.test.ts +0 -242
  164. package/packages/api-types/src/schemas/history.ts +0 -84
  165. package/packages/api-types/src/schemas/index.ts +0 -148
  166. package/packages/api-types/src/schemas/message.test.ts +0 -192
  167. package/packages/api-types/src/schemas/message.ts +0 -98
  168. package/packages/api-types/src/schemas/session.test.ts +0 -104
  169. package/packages/api-types/src/schemas/session.ts +0 -40
  170. package/packages/api-types/src/schemas/task.test.ts +0 -192
  171. package/packages/api-types/src/schemas/task.ts +0 -78
  172. package/packages/api-types/tsconfig.json +0 -19
  173. package/packages/api-types/vitest.config.ts +0 -9
  174. package/packages/benchmark/README.md +0 -200
  175. package/packages/benchmark/datasets/coding-tasks.yaml +0 -127
  176. package/packages/benchmark/datasets/coordination-tasks.yaml +0 -122
  177. package/packages/benchmark/datasets/quick-test.yaml +0 -20
  178. package/packages/benchmark/dist/benchmark.d.ts +0 -47
  179. package/packages/benchmark/dist/benchmark.d.ts.map +0 -1
  180. package/packages/benchmark/dist/benchmark.js +0 -224
  181. package/packages/benchmark/dist/benchmark.js.map +0 -1
  182. package/packages/benchmark/dist/cli.d.ts +0 -8
  183. package/packages/benchmark/dist/cli.d.ts.map +0 -1
  184. package/packages/benchmark/dist/cli.js +0 -185
  185. package/packages/benchmark/dist/cli.js.map +0 -1
  186. package/packages/benchmark/dist/harbor.d.ts +0 -53
  187. package/packages/benchmark/dist/harbor.d.ts.map +0 -1
  188. package/packages/benchmark/dist/harbor.js +0 -127
  189. package/packages/benchmark/dist/harbor.js.map +0 -1
  190. package/packages/benchmark/dist/index.d.ts +0 -48
  191. package/packages/benchmark/dist/index.d.ts.map +0 -1
  192. package/packages/benchmark/dist/index.js +0 -50
  193. package/packages/benchmark/dist/index.js.map +0 -1
  194. package/packages/benchmark/dist/runners/base.d.ts +0 -63
  195. package/packages/benchmark/dist/runners/base.d.ts.map +0 -1
  196. package/packages/benchmark/dist/runners/base.js +0 -156
  197. package/packages/benchmark/dist/runners/base.js.map +0 -1
  198. package/packages/benchmark/dist/runners/index.d.ts +0 -10
  199. package/packages/benchmark/dist/runners/index.d.ts.map +0 -1
  200. package/packages/benchmark/dist/runners/index.js +0 -10
  201. package/packages/benchmark/dist/runners/index.js.map +0 -1
  202. package/packages/benchmark/dist/runners/single.d.ts +0 -19
  203. package/packages/benchmark/dist/runners/single.d.ts.map +0 -1
  204. package/packages/benchmark/dist/runners/single.js +0 -111
  205. package/packages/benchmark/dist/runners/single.js.map +0 -1
  206. package/packages/benchmark/dist/runners/subagent.d.ts +0 -32
  207. package/packages/benchmark/dist/runners/subagent.d.ts.map +0 -1
  208. package/packages/benchmark/dist/runners/subagent.js +0 -212
  209. package/packages/benchmark/dist/runners/subagent.js.map +0 -1
  210. package/packages/benchmark/dist/runners/swarm.d.ts +0 -36
  211. package/packages/benchmark/dist/runners/swarm.d.ts.map +0 -1
  212. package/packages/benchmark/dist/runners/swarm.js +0 -273
  213. package/packages/benchmark/dist/runners/swarm.js.map +0 -1
  214. package/packages/benchmark/dist/types.d.ts +0 -178
  215. package/packages/benchmark/dist/types.d.ts.map +0 -1
  216. package/packages/benchmark/dist/types.js +0 -16
  217. package/packages/benchmark/dist/types.js.map +0 -1
  218. package/packages/benchmark/package.json +0 -80
  219. package/packages/benchmark/src/benchmark.ts +0 -298
  220. package/packages/benchmark/src/cli.ts +0 -240
  221. package/packages/benchmark/src/harbor.ts +0 -170
  222. package/packages/benchmark/src/index.ts +0 -73
  223. package/packages/benchmark/src/runners/base.ts +0 -205
  224. package/packages/benchmark/src/runners/index.ts +0 -10
  225. package/packages/benchmark/src/runners/single.ts +0 -121
  226. package/packages/benchmark/src/runners/subagent.ts +0 -240
  227. package/packages/benchmark/src/runners/swarm.ts +0 -326
  228. package/packages/benchmark/src/types.ts +0 -205
  229. package/packages/benchmark/tsconfig.json +0 -20
  230. package/packages/cli-tester/README.md +0 -277
  231. package/packages/cli-tester/dist/index.d.ts +0 -21
  232. package/packages/cli-tester/dist/index.d.ts.map +0 -1
  233. package/packages/cli-tester/dist/index.js +0 -21
  234. package/packages/cli-tester/dist/index.js.map +0 -1
  235. package/packages/cli-tester/dist/utils/credential-check.d.ts +0 -56
  236. package/packages/cli-tester/dist/utils/credential-check.d.ts.map +0 -1
  237. package/packages/cli-tester/dist/utils/credential-check.js +0 -230
  238. package/packages/cli-tester/dist/utils/credential-check.js.map +0 -1
  239. package/packages/cli-tester/dist/utils/socket-client.d.ts +0 -76
  240. package/packages/cli-tester/dist/utils/socket-client.d.ts.map +0 -1
  241. package/packages/cli-tester/dist/utils/socket-client.js +0 -153
  242. package/packages/cli-tester/dist/utils/socket-client.js.map +0 -1
  243. package/packages/cli-tester/docker/Dockerfile +0 -61
  244. package/packages/cli-tester/docker/docker-compose.yml +0 -71
  245. package/packages/cli-tester/docker/entrypoint.sh +0 -58
  246. package/packages/cli-tester/package.json +0 -32
  247. package/packages/cli-tester/scripts/clear-auth.sh +0 -101
  248. package/packages/cli-tester/scripts/inject-message.sh +0 -42
  249. package/packages/cli-tester/scripts/start.sh +0 -71
  250. package/packages/cli-tester/scripts/test-cli.sh +0 -56
  251. package/packages/cli-tester/scripts/test-full-spawn.sh +0 -238
  252. package/packages/cli-tester/scripts/test-registration.sh +0 -182
  253. package/packages/cli-tester/scripts/test-setup-flow.sh +0 -202
  254. package/packages/cli-tester/scripts/test-spawn.sh +0 -140
  255. package/packages/cli-tester/scripts/test-with-daemon.sh +0 -247
  256. package/packages/cli-tester/scripts/verify-auth.sh +0 -112
  257. package/packages/cli-tester/src/index.ts +0 -40
  258. package/packages/cli-tester/src/utils/credential-check.ts +0 -284
  259. package/packages/cli-tester/src/utils/socket-client.ts +0 -211
  260. package/packages/cli-tester/tests/credential-check.test.ts +0 -56
  261. package/packages/cli-tester/tsconfig.json +0 -11
  262. package/packages/sdk/dist/browser-client.d.ts +0 -212
  263. package/packages/sdk/dist/browser-client.d.ts.map +0 -1
  264. package/packages/sdk/dist/browser-client.js +0 -750
  265. package/packages/sdk/dist/browser-client.js.map +0 -1
  266. package/packages/sdk/dist/browser-framing.d.ts +0 -46
  267. package/packages/sdk/dist/browser-framing.d.ts.map +0 -1
  268. package/packages/sdk/dist/browser-framing.js +0 -122
  269. package/packages/sdk/dist/browser-framing.js.map +0 -1
  270. package/packages/sdk/dist/standalone.d.ts +0 -89
  271. package/packages/sdk/dist/standalone.d.ts.map +0 -1
  272. package/packages/sdk/dist/standalone.js +0 -131
  273. package/packages/sdk/dist/standalone.js.map +0 -1
  274. package/packages/sdk/dist/transports/index.d.ts +0 -92
  275. package/packages/sdk/dist/transports/index.d.ts.map +0 -1
  276. package/packages/sdk/dist/transports/index.js +0 -129
  277. package/packages/sdk/dist/transports/index.js.map +0 -1
  278. package/packages/sdk/dist/transports/socket-transport.d.ts +0 -30
  279. package/packages/sdk/dist/transports/socket-transport.d.ts.map +0 -1
  280. package/packages/sdk/dist/transports/socket-transport.js +0 -94
  281. package/packages/sdk/dist/transports/socket-transport.js.map +0 -1
  282. package/packages/sdk/dist/transports/types.d.ts +0 -69
  283. package/packages/sdk/dist/transports/types.d.ts.map +0 -1
  284. package/packages/sdk/dist/transports/types.js +0 -10
  285. package/packages/sdk/dist/transports/types.js.map +0 -1
  286. package/packages/sdk/dist/transports/websocket-transport.d.ts +0 -55
  287. package/packages/sdk/dist/transports/websocket-transport.d.ts.map +0 -1
  288. package/packages/sdk/dist/transports/websocket-transport.js +0 -180
  289. package/packages/sdk/dist/transports/websocket-transport.js.map +0 -1
  290. package/packages/sdk/src/browser-client.ts +0 -985
  291. package/packages/sdk/src/browser-framing.test.ts +0 -115
  292. package/packages/sdk/src/browser-framing.ts +0 -150
  293. package/packages/sdk/src/standalone.ts +0 -183
  294. package/packages/sdk/src/transports/index.ts +0 -197
  295. package/packages/sdk/src/transports/socket-transport.ts +0 -115
  296. package/packages/sdk/src/transports/types.ts +0 -77
  297. package/packages/sdk/src/transports/websocket-transport.ts +0 -245
@@ -1,192 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { z } from 'zod';
3
- import {
4
- MessageStatusSchema,
5
- AttachmentSchema,
6
- MessageSchema,
7
- ThreadSchema,
8
- type Message,
9
- type Attachment,
10
- type Thread,
11
- } from './message.js';
12
-
13
- describe('MessageStatusSchema', () => {
14
- it('accepts valid status values', () => {
15
- expect(MessageStatusSchema.parse('unread')).toBe('unread');
16
- expect(MessageStatusSchema.parse('read')).toBe('read');
17
- expect(MessageStatusSchema.parse('acked')).toBe('acked');
18
- expect(MessageStatusSchema.parse('sending')).toBe('sending');
19
- expect(MessageStatusSchema.parse('failed')).toBe('failed');
20
- });
21
-
22
- it('rejects invalid status values', () => {
23
- expect(() => MessageStatusSchema.parse('pending')).toThrow();
24
- expect(() => MessageStatusSchema.parse('')).toThrow();
25
- });
26
- });
27
-
28
- describe('AttachmentSchema', () => {
29
- it('accepts valid attachment', () => {
30
- const attachment: Attachment = {
31
- id: 'att-123',
32
- filename: 'screenshot.png',
33
- mimeType: 'image/png',
34
- size: 1024,
35
- url: 'https://example.com/att-123',
36
- };
37
- const result = AttachmentSchema.parse(attachment);
38
- expect(result).toEqual(attachment);
39
- });
40
-
41
- it('accepts attachment with all optional fields', () => {
42
- const attachment: Attachment = {
43
- id: 'att-123',
44
- filename: 'image.jpg',
45
- mimeType: 'image/jpeg',
46
- size: 2048,
47
- url: 'https://example.com/image.jpg',
48
- filePath: '/tmp/uploads/image.jpg',
49
- width: 800,
50
- height: 600,
51
- data: 'base64data...',
52
- };
53
- const result = AttachmentSchema.parse(attachment);
54
- expect(result.filePath).toBe('/tmp/uploads/image.jpg');
55
- expect(result.width).toBe(800);
56
- expect(result.height).toBe(600);
57
- expect(result.data).toBe('base64data...');
58
- });
59
-
60
- it('rejects attachment without required fields', () => {
61
- expect(() =>
62
- AttachmentSchema.parse({ id: 'att-123', filename: 'test.png' })
63
- ).toThrow();
64
- });
65
- });
66
-
67
- describe('MessageSchema', () => {
68
- it('accepts minimal valid message', () => {
69
- const message: Message = {
70
- id: 'msg-123',
71
- from: 'Agent1',
72
- to: 'Agent2',
73
- content: 'Hello!',
74
- timestamp: '2024-01-01T00:00:00Z',
75
- };
76
- const result = MessageSchema.parse(message);
77
- expect(result).toEqual(message);
78
- });
79
-
80
- it('accepts message with all optional fields', () => {
81
- const message: Message = {
82
- id: 'msg-123',
83
- from: 'Agent1',
84
- to: 'Agent2',
85
- content: 'Hello with thread!',
86
- timestamp: '2024-01-01T00:00:00Z',
87
- thread: 'thread-456',
88
- isBroadcast: false,
89
- isRead: true,
90
- replyCount: 5,
91
- threadSummary: {
92
- id: 'thread-456',
93
- rootMessage: 'Original message',
94
- participantCount: 3,
95
- messageCount: 10,
96
- lastActivityAt: '2024-01-02T00:00:00Z',
97
- },
98
- status: 'acked',
99
- attachments: [
100
- {
101
- id: 'att-1',
102
- filename: 'file.pdf',
103
- mimeType: 'application/pdf',
104
- size: 1024,
105
- url: 'https://example.com/file.pdf',
106
- },
107
- ],
108
- channel: 'general',
109
- };
110
- const result = MessageSchema.parse(message);
111
- expect(result.thread).toBe('thread-456');
112
- expect(result.status).toBe('acked');
113
- expect(result.attachments).toHaveLength(1);
114
- });
115
-
116
- it('rejects message without required id', () => {
117
- expect(() =>
118
- MessageSchema.parse({
119
- from: 'A',
120
- to: 'B',
121
- content: 'test',
122
- timestamp: '2024-01-01',
123
- })
124
- ).toThrow();
125
- });
126
-
127
- it('rejects message without required from', () => {
128
- expect(() =>
129
- MessageSchema.parse({
130
- id: '1',
131
- to: 'B',
132
- content: 'test',
133
- timestamp: '2024-01-01',
134
- })
135
- ).toThrow();
136
- });
137
- });
138
-
139
- describe('ThreadSchema', () => {
140
- it('accepts valid thread', () => {
141
- const thread: Thread = {
142
- id: 'thread-123',
143
- messages: [
144
- {
145
- id: 'msg-1',
146
- from: 'A',
147
- to: 'B',
148
- content: 'First',
149
- timestamp: '2024-01-01T00:00:00Z',
150
- },
151
- {
152
- id: 'msg-2',
153
- from: 'B',
154
- to: 'A',
155
- content: 'Reply',
156
- timestamp: '2024-01-01T00:01:00Z',
157
- },
158
- ],
159
- participants: ['A', 'B'],
160
- lastActivity: '2024-01-01T00:01:00Z',
161
- };
162
- const result = ThreadSchema.parse(thread);
163
- expect(result.messages).toHaveLength(2);
164
- expect(result.participants).toContain('A');
165
- expect(result.participants).toContain('B');
166
- });
167
-
168
- it('accepts thread with empty messages array', () => {
169
- const thread: Thread = {
170
- id: 'thread-123',
171
- messages: [],
172
- participants: ['A'],
173
- lastActivity: '2024-01-01T00:00:00Z',
174
- };
175
- const result = ThreadSchema.parse(thread);
176
- expect(result.messages).toHaveLength(0);
177
- });
178
- });
179
-
180
- describe('Type inference', () => {
181
- it('infers Message type correctly', () => {
182
- const message: Message = {
183
- id: '1',
184
- from: 'A',
185
- to: 'B',
186
- content: 'Test',
187
- timestamp: '2024-01-01',
188
- };
189
- const parsed: z.infer<typeof MessageSchema> = MessageSchema.parse(message);
190
- expect(parsed.content).toBe('Test');
191
- });
192
- });
@@ -1,98 +0,0 @@
1
- /**
2
- * Message Schemas
3
- *
4
- * Zod schemas for message-related types used across the dashboard and API.
5
- */
6
-
7
- import { z } from 'zod';
8
-
9
- /**
10
- * Message status enum
11
- */
12
- export const MessageStatusSchema = z.enum(['unread', 'read', 'acked', 'sending', 'failed']);
13
- export type MessageStatus = z.infer<typeof MessageStatusSchema>;
14
-
15
- /**
16
- * Attachment schema - files/images attached to messages
17
- */
18
- export const AttachmentSchema = z.object({
19
- /** Unique identifier for the attachment */
20
- id: z.string(),
21
- /** Original filename */
22
- filename: z.string(),
23
- /** MIME type (e.g., 'image/png', 'image/jpeg') */
24
- mimeType: z.string(),
25
- /** Size in bytes */
26
- size: z.number(),
27
- /** URL to access the attachment */
28
- url: z.string(),
29
- /** Absolute file path for agents to read the file directly */
30
- filePath: z.string().optional(),
31
- /** Width for images */
32
- width: z.number().optional(),
33
- /** Height for images */
34
- height: z.number().optional(),
35
- /** Base64-encoded data (for inline display, optional) */
36
- data: z.string().optional(),
37
- });
38
- export type Attachment = z.infer<typeof AttachmentSchema>;
39
-
40
- /**
41
- * Thread metadata schema
42
- */
43
- export const ThreadMetadataSchema = z.object({
44
- id: z.string(),
45
- rootMessage: z.string(),
46
- participantCount: z.number(),
47
- messageCount: z.number(),
48
- lastActivityAt: z.string(),
49
- });
50
- export type ThreadMetadata = z.infer<typeof ThreadMetadataSchema>;
51
-
52
- /**
53
- * Message schema
54
- */
55
- export const MessageSchema = z.object({
56
- /** Unique message ID */
57
- id: z.string(),
58
- /** Sender agent name */
59
- from: z.string(),
60
- /** Recipient agent name or '*' for broadcast */
61
- to: z.string(),
62
- /** Message content */
63
- content: z.string(),
64
- /** Timestamp (ISO string) */
65
- timestamp: z.string(),
66
- /** Optional thread ID for threading */
67
- thread: z.string().optional(),
68
- /** Whether this is a broadcast message */
69
- isBroadcast: z.boolean().optional(),
70
- /** Whether the message has been read */
71
- isRead: z.boolean().optional(),
72
- /** Number of replies in thread */
73
- replyCount: z.number().optional(),
74
- /** Thread summary metadata */
75
- threadSummary: ThreadMetadataSchema.optional(),
76
- /** Message delivery status */
77
- status: MessageStatusSchema.optional(),
78
- /** Attached files/images */
79
- attachments: z.array(AttachmentSchema).optional(),
80
- /** Channel context for routing */
81
- channel: z.string().optional(),
82
- });
83
- export type Message = z.infer<typeof MessageSchema>;
84
-
85
- /**
86
- * Thread schema - collection of messages
87
- */
88
- export const ThreadSchema = z.object({
89
- /** Thread ID */
90
- id: z.string(),
91
- /** Messages in the thread */
92
- messages: z.array(MessageSchema),
93
- /** Participant agent names */
94
- participants: z.array(z.string()),
95
- /** Last activity timestamp */
96
- lastActivity: z.string(),
97
- });
98
- export type Thread = z.infer<typeof ThreadSchema>;
@@ -1,104 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { z } from 'zod';
3
- import {
4
- SessionSchema,
5
- type Session,
6
- } from './session.js';
7
-
8
- describe('SessionSchema', () => {
9
- it('accepts minimal valid session', () => {
10
- const session: Session = {
11
- id: 'session-123',
12
- agentName: 'TestAgent',
13
- startedAt: '2024-01-01T00:00:00Z',
14
- messageCount: 0,
15
- isActive: true,
16
- };
17
- const result = SessionSchema.parse(session);
18
- expect(result.id).toBe('session-123');
19
- expect(result.agentName).toBe('TestAgent');
20
- expect(result.isActive).toBe(true);
21
- });
22
-
23
- it('accepts session with all optional fields', () => {
24
- const session: Session = {
25
- id: 'session-456',
26
- agentName: 'FullAgent',
27
- cli: 'claude',
28
- startedAt: '2024-01-01T00:00:00Z',
29
- endedAt: '2024-01-01T01:00:00Z',
30
- duration: '1 hour',
31
- messageCount: 42,
32
- summary: 'Completed feature implementation',
33
- isActive: false,
34
- closedBy: 'agent',
35
- };
36
- const result = SessionSchema.parse(session);
37
- expect(result.cli).toBe('claude');
38
- expect(result.endedAt).toBe('2024-01-01T01:00:00Z');
39
- expect(result.closedBy).toBe('agent');
40
- });
41
-
42
- it('accepts all closedBy values', () => {
43
- const base = {
44
- id: '1',
45
- agentName: 'Test',
46
- startedAt: '2024-01-01',
47
- messageCount: 0,
48
- isActive: false,
49
- };
50
-
51
- expect(SessionSchema.parse({ ...base, closedBy: 'agent' }).closedBy).toBe('agent');
52
- expect(SessionSchema.parse({ ...base, closedBy: 'disconnect' }).closedBy).toBe('disconnect');
53
- expect(SessionSchema.parse({ ...base, closedBy: 'error' }).closedBy).toBe('error');
54
- });
55
-
56
- it('rejects session without required id', () => {
57
- expect(() =>
58
- SessionSchema.parse({
59
- agentName: 'Test',
60
- startedAt: '2024-01-01',
61
- messageCount: 0,
62
- isActive: true,
63
- })
64
- ).toThrow();
65
- });
66
-
67
- it('rejects session without required agentName', () => {
68
- expect(() =>
69
- SessionSchema.parse({
70
- id: '1',
71
- startedAt: '2024-01-01',
72
- messageCount: 0,
73
- isActive: true,
74
- })
75
- ).toThrow();
76
- });
77
-
78
- it('rejects invalid closedBy value', () => {
79
- expect(() =>
80
- SessionSchema.parse({
81
- id: '1',
82
- agentName: 'Test',
83
- startedAt: '2024-01-01',
84
- messageCount: 0,
85
- isActive: false,
86
- closedBy: 'invalid',
87
- })
88
- ).toThrow();
89
- });
90
- });
91
-
92
- describe('Type inference', () => {
93
- it('infers Session type correctly', () => {
94
- const session: Session = {
95
- id: '1',
96
- agentName: 'Test',
97
- startedAt: '2024-01-01',
98
- messageCount: 0,
99
- isActive: true,
100
- };
101
- const parsed: z.infer<typeof SessionSchema> = SessionSchema.parse(session);
102
- expect(parsed.agentName).toBe('Test');
103
- });
104
- });
@@ -1,40 +0,0 @@
1
- /**
2
- * Session Schemas
3
- *
4
- * Zod schemas for session-related types used across the dashboard and API.
5
- */
6
-
7
- import { z } from 'zod';
8
-
9
- /**
10
- * Session closed by enum
11
- */
12
- export const SessionClosedBySchema = z.enum(['agent', 'disconnect', 'error']);
13
- export type SessionClosedBy = z.infer<typeof SessionClosedBySchema>;
14
-
15
- /**
16
- * Session schema - represents an agent session
17
- */
18
- export const SessionSchema = z.object({
19
- /** Unique session ID */
20
- id: z.string(),
21
- /** Agent name for this session */
22
- agentName: z.string(),
23
- /** CLI type used (claude, codex, gemini, etc.) */
24
- cli: z.string().optional(),
25
- /** Session start timestamp (ISO string) */
26
- startedAt: z.string(),
27
- /** Session end timestamp (ISO string) */
28
- endedAt: z.string().optional(),
29
- /** Human-readable duration string */
30
- duration: z.string().optional(),
31
- /** Total messages in session */
32
- messageCount: z.number(),
33
- /** Session summary text */
34
- summary: z.string().optional(),
35
- /** Whether session is currently active */
36
- isActive: z.boolean(),
37
- /** How the session was closed */
38
- closedBy: SessionClosedBySchema.optional(),
39
- });
40
- export type Session = z.infer<typeof SessionSchema>;
@@ -1,192 +0,0 @@
1
- /**
2
- * Task Schema Tests
3
- */
4
-
5
- import { describe, it, expect } from 'vitest';
6
- import {
7
- TaskStatusSchema,
8
- TaskPrioritySchema,
9
- TaskTypeSchema,
10
- TaskSchema,
11
- TaskAssignmentStatusSchema,
12
- TaskAssignmentPrioritySchema,
13
- TaskAssignmentSchema,
14
- } from './task.js';
15
-
16
- describe('Task Schemas', () => {
17
- describe('TaskStatusSchema', () => {
18
- it('should validate valid statuses', () => {
19
- expect(TaskStatusSchema.parse('open')).toBe('open');
20
- expect(TaskStatusSchema.parse('in_progress')).toBe('in_progress');
21
- expect(TaskStatusSchema.parse('completed')).toBe('completed');
22
- expect(TaskStatusSchema.parse('blocked')).toBe('blocked');
23
- });
24
-
25
- it('should reject invalid status', () => {
26
- expect(() => TaskStatusSchema.parse('done')).toThrow();
27
- expect(() => TaskStatusSchema.parse('pending')).toThrow();
28
- });
29
- });
30
-
31
- describe('TaskPrioritySchema', () => {
32
- it('should validate P1-P4 priorities', () => {
33
- expect(TaskPrioritySchema.parse('P1')).toBe('P1');
34
- expect(TaskPrioritySchema.parse('P2')).toBe('P2');
35
- expect(TaskPrioritySchema.parse('P3')).toBe('P3');
36
- expect(TaskPrioritySchema.parse('P4')).toBe('P4');
37
- });
38
-
39
- it('should reject invalid priorities', () => {
40
- expect(() => TaskPrioritySchema.parse('P0')).toThrow();
41
- expect(() => TaskPrioritySchema.parse('P5')).toThrow();
42
- expect(() => TaskPrioritySchema.parse('high')).toThrow();
43
- });
44
- });
45
-
46
- describe('TaskTypeSchema', () => {
47
- it('should validate task types', () => {
48
- expect(TaskTypeSchema.parse('task')).toBe('task');
49
- expect(TaskTypeSchema.parse('bug')).toBe('bug');
50
- expect(TaskTypeSchema.parse('feature')).toBe('feature');
51
- expect(TaskTypeSchema.parse('epic')).toBe('epic');
52
- });
53
-
54
- it('should reject invalid types', () => {
55
- expect(() => TaskTypeSchema.parse('story')).toThrow();
56
- expect(() => TaskTypeSchema.parse('issue')).toThrow();
57
- });
58
- });
59
-
60
- describe('TaskSchema', () => {
61
- it('should validate complete task', () => {
62
- const task = {
63
- id: 'beads-001',
64
- title: 'Implement user authentication',
65
- description: 'Add JWT-based authentication',
66
- status: 'in_progress',
67
- priority: 'P2',
68
- type: 'feature',
69
- assignee: 'FullStack',
70
- blockedBy: ['beads-000'],
71
- blocking: ['beads-002', 'beads-003'],
72
- created: '2025-01-20T10:00:00Z',
73
- updated: '2025-01-22T09:00:00Z',
74
- };
75
- const result = TaskSchema.parse(task);
76
- expect(result.id).toBe('beads-001');
77
- expect(result.status).toBe('in_progress');
78
- expect(result.blockedBy).toHaveLength(1);
79
- expect(result.blocking).toHaveLength(2);
80
- });
81
-
82
- it('should allow task without optional fields', () => {
83
- const task = {
84
- id: 'beads-002',
85
- title: 'Fix login bug',
86
- status: 'open',
87
- priority: 'P1',
88
- type: 'bug',
89
- created: '2025-01-22T08:00:00Z',
90
- updated: '2025-01-22T08:00:00Z',
91
- };
92
- const result = TaskSchema.parse(task);
93
- expect(result.description).toBeUndefined();
94
- expect(result.assignee).toBeUndefined();
95
- expect(result.blockedBy).toBeUndefined();
96
- });
97
-
98
- it('should reject task with missing required fields', () => {
99
- expect(() =>
100
- TaskSchema.parse({
101
- id: 'beads-003',
102
- title: 'Incomplete task',
103
- })
104
- ).toThrow();
105
- });
106
- });
107
-
108
- describe('TaskAssignmentStatusSchema', () => {
109
- it('should validate all assignment statuses', () => {
110
- expect(TaskAssignmentStatusSchema.parse('pending')).toBe('pending');
111
- expect(TaskAssignmentStatusSchema.parse('assigned')).toBe('assigned');
112
- expect(TaskAssignmentStatusSchema.parse('in_progress')).toBe('in_progress');
113
- expect(TaskAssignmentStatusSchema.parse('completed')).toBe('completed');
114
- expect(TaskAssignmentStatusSchema.parse('failed')).toBe('failed');
115
- });
116
- });
117
-
118
- describe('TaskAssignmentPrioritySchema', () => {
119
- it('should validate assignment priorities', () => {
120
- expect(TaskAssignmentPrioritySchema.parse('low')).toBe('low');
121
- expect(TaskAssignmentPrioritySchema.parse('medium')).toBe('medium');
122
- expect(TaskAssignmentPrioritySchema.parse('high')).toBe('high');
123
- expect(TaskAssignmentPrioritySchema.parse('critical')).toBe('critical');
124
- });
125
-
126
- it('should reject invalid priority', () => {
127
- expect(() => TaskAssignmentPrioritySchema.parse('urgent')).toThrow();
128
- });
129
- });
130
-
131
- describe('TaskAssignmentSchema', () => {
132
- it('should validate complete assignment', () => {
133
- const assignment = {
134
- id: 'task-assign-001',
135
- agentName: 'FullStack',
136
- title: 'Build API endpoint',
137
- description: 'Create REST endpoint for user data',
138
- priority: 'high',
139
- status: 'in_progress',
140
- createdAt: '2025-01-22T08:00:00Z',
141
- assignedAt: '2025-01-22T08:05:00Z',
142
- };
143
- const result = TaskAssignmentSchema.parse(assignment);
144
- expect(result.agentName).toBe('FullStack');
145
- expect(result.priority).toBe('high');
146
- expect(result.status).toBe('in_progress');
147
- });
148
-
149
- it('should validate completed assignment', () => {
150
- const assignment = {
151
- id: 'task-assign-002',
152
- agentName: 'Backend',
153
- title: 'Database migration',
154
- description: 'Run schema migrations',
155
- priority: 'medium',
156
- status: 'completed',
157
- createdAt: '2025-01-21T10:00:00Z',
158
- assignedAt: '2025-01-21T10:30:00Z',
159
- completedAt: '2025-01-21T12:00:00Z',
160
- result: 'Migration completed successfully. 3 tables updated.',
161
- };
162
- const result = TaskAssignmentSchema.parse(assignment);
163
- expect(result.status).toBe('completed');
164
- expect(result.completedAt).toBeDefined();
165
- expect(result.result).toContain('Migration');
166
- });
167
-
168
- it('should allow pending assignment without dates', () => {
169
- const assignment = {
170
- id: 'task-assign-003',
171
- agentName: 'Worker',
172
- title: 'Pending task',
173
- description: 'Waiting for assignment',
174
- priority: 'low',
175
- status: 'pending',
176
- createdAt: '2025-01-22T09:00:00Z',
177
- };
178
- const result = TaskAssignmentSchema.parse(assignment);
179
- expect(result.assignedAt).toBeUndefined();
180
- expect(result.completedAt).toBeUndefined();
181
- });
182
-
183
- it('should reject assignment with missing required fields', () => {
184
- expect(() =>
185
- TaskAssignmentSchema.parse({
186
- id: 'task-assign-004',
187
- agentName: 'Worker',
188
- })
189
- ).toThrow();
190
- });
191
- });
192
- });
@@ -1,78 +0,0 @@
1
- /**
2
- * Task Schemas
3
- *
4
- * Zod schemas for task-related types used across the dashboard and API.
5
- */
6
-
7
- import { z } from 'zod';
8
-
9
- /**
10
- * Task status enum
11
- */
12
- export const TaskStatusSchema = z.enum(['open', 'in_progress', 'completed', 'blocked']);
13
- export type TaskStatus = z.infer<typeof TaskStatusSchema>;
14
-
15
- /**
16
- * Task priority enum
17
- */
18
- export const TaskPrioritySchema = z.enum(['P1', 'P2', 'P3', 'P4']);
19
- export type TaskPriority = z.infer<typeof TaskPrioritySchema>;
20
-
21
- /**
22
- * Task type enum
23
- */
24
- export const TaskTypeSchema = z.enum(['task', 'bug', 'feature', 'epic']);
25
- export type TaskType = z.infer<typeof TaskTypeSchema>;
26
-
27
- /**
28
- * Task schema (Beads Integration)
29
- */
30
- export const TaskSchema = z.object({
31
- id: z.string(),
32
- title: z.string(),
33
- description: z.string().optional(),
34
- status: TaskStatusSchema,
35
- priority: TaskPrioritySchema,
36
- type: TaskTypeSchema,
37
- assignee: z.string().optional(),
38
- blockedBy: z.array(z.string()).optional(),
39
- blocking: z.array(z.string()).optional(),
40
- created: z.string(),
41
- updated: z.string(),
42
- });
43
- export type Task = z.infer<typeof TaskSchema>;
44
-
45
- /**
46
- * Task assignment status enum (for API)
47
- */
48
- export const TaskAssignmentStatusSchema = z.enum([
49
- 'pending',
50
- 'assigned',
51
- 'in_progress',
52
- 'completed',
53
- 'failed',
54
- ]);
55
- export type TaskAssignmentStatus = z.infer<typeof TaskAssignmentStatusSchema>;
56
-
57
- /**
58
- * Task assignment priority enum (for API)
59
- */
60
- export const TaskAssignmentPrioritySchema = z.enum(['low', 'medium', 'high', 'critical']);
61
- export type TaskAssignmentPriority = z.infer<typeof TaskAssignmentPrioritySchema>;
62
-
63
- /**
64
- * Task assignment schema (for /api/tasks endpoints)
65
- */
66
- export const TaskAssignmentSchema = z.object({
67
- id: z.string(),
68
- agentName: z.string(),
69
- title: z.string(),
70
- description: z.string(),
71
- priority: TaskAssignmentPrioritySchema,
72
- status: TaskAssignmentStatusSchema,
73
- createdAt: z.string(),
74
- assignedAt: z.string().optional(),
75
- completedAt: z.string().optional(),
76
- result: z.string().optional(),
77
- });
78
- export type TaskAssignment = z.infer<typeof TaskAssignmentSchema>;