@strands-agents/sdk 0.2.2 → 0.4.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 (241) hide show
  1. package/README.md +43 -0
  2. package/dist/src/__fixtures__/mock-hook-provider.d.ts +3 -7
  3. package/dist/src/__fixtures__/mock-hook-provider.d.ts.map +1 -1
  4. package/dist/src/__fixtures__/mock-hook-provider.js +3 -9
  5. package/dist/src/__fixtures__/mock-hook-provider.js.map +1 -1
  6. package/dist/src/__fixtures__/mock-message-model.d.ts +8 -2
  7. package/dist/src/__fixtures__/mock-message-model.d.ts.map +1 -1
  8. package/dist/src/__fixtures__/mock-message-model.js +1 -0
  9. package/dist/src/__fixtures__/mock-message-model.js.map +1 -1
  10. package/dist/src/__fixtures__/mock-storage-provider.d.ts +37 -0
  11. package/dist/src/__fixtures__/mock-storage-provider.d.ts.map +1 -0
  12. package/dist/src/__fixtures__/mock-storage-provider.js +105 -0
  13. package/dist/src/__fixtures__/mock-storage-provider.js.map +1 -0
  14. package/dist/src/__fixtures__/slim-types.d.ts +50 -0
  15. package/dist/src/__fixtures__/slim-types.d.ts.map +1 -0
  16. package/dist/src/__fixtures__/slim-types.js +6 -0
  17. package/dist/src/__fixtures__/slim-types.js.map +1 -0
  18. package/dist/src/__fixtures__/tool-helpers.d.ts +8 -3
  19. package/dist/src/__fixtures__/tool-helpers.d.ts.map +1 -1
  20. package/dist/src/__fixtures__/tool-helpers.js +1 -1
  21. package/dist/src/__fixtures__/tool-helpers.js.map +1 -1
  22. package/dist/src/agent/__tests__/agent.hook.test.js +18 -18
  23. package/dist/src/agent/__tests__/agent.hook.test.js.map +1 -1
  24. package/dist/src/agent/__tests__/agent.test.js +124 -8
  25. package/dist/src/agent/__tests__/agent.test.js.map +1 -1
  26. package/dist/src/agent/__tests__/printer.test.js +5 -9
  27. package/dist/src/agent/__tests__/printer.test.js.map +1 -1
  28. package/dist/src/agent/__tests__/snapshot.test.d.ts +2 -0
  29. package/dist/src/agent/__tests__/snapshot.test.d.ts.map +1 -0
  30. package/dist/src/agent/__tests__/snapshot.test.js +249 -0
  31. package/dist/src/agent/__tests__/snapshot.test.js.map +1 -0
  32. package/dist/src/agent/__tests__/state.test.js +19 -0
  33. package/dist/src/agent/__tests__/state.test.js.map +1 -1
  34. package/dist/src/agent/agent.d.ts +19 -4
  35. package/dist/src/agent/agent.d.ts.map +1 -1
  36. package/dist/src/agent/agent.js +104 -34
  37. package/dist/src/agent/agent.js.map +1 -1
  38. package/dist/src/agent/printer.d.ts +4 -0
  39. package/dist/src/agent/printer.d.ts.map +1 -1
  40. package/dist/src/agent/printer.js +18 -6
  41. package/dist/src/agent/printer.js.map +1 -1
  42. package/dist/src/agent/snapshot.d.ts +132 -0
  43. package/dist/src/agent/snapshot.d.ts.map +1 -0
  44. package/dist/src/agent/snapshot.js +151 -0
  45. package/dist/src/agent/snapshot.js.map +1 -0
  46. package/dist/src/agent/state.d.ts +14 -1
  47. package/dist/src/agent/state.d.ts.map +1 -1
  48. package/dist/src/agent/state.js +21 -0
  49. package/dist/src/agent/state.js.map +1 -1
  50. package/dist/src/errors.d.ts +15 -0
  51. package/dist/src/errors.d.ts.map +1 -1
  52. package/dist/src/errors.js +18 -0
  53. package/dist/src/errors.js.map +1 -1
  54. package/dist/src/hooks/__tests__/events.test.js +102 -21
  55. package/dist/src/hooks/__tests__/events.test.js.map +1 -1
  56. package/dist/src/hooks/events.d.ts +156 -22
  57. package/dist/src/hooks/events.d.ts.map +1 -1
  58. package/dist/src/hooks/events.js +158 -18
  59. package/dist/src/hooks/events.js.map +1 -1
  60. package/dist/src/hooks/index.d.ts +12 -4
  61. package/dist/src/hooks/index.d.ts.map +1 -1
  62. package/dist/src/hooks/index.js +11 -3
  63. package/dist/src/hooks/index.js.map +1 -1
  64. package/dist/src/hooks/registry.d.ts +5 -5
  65. package/dist/src/hooks/registry.d.ts.map +1 -1
  66. package/dist/src/hooks/registry.js.map +1 -1
  67. package/dist/src/hooks/types.d.ts +5 -5
  68. package/dist/src/hooks/types.d.ts.map +1 -1
  69. package/dist/src/index.d.ts +4 -2
  70. package/dist/src/index.d.ts.map +1 -1
  71. package/dist/src/index.js +4 -3
  72. package/dist/src/index.js.map +1 -1
  73. package/dist/src/models/__tests__/anthropic.test.js +31 -42
  74. package/dist/src/models/__tests__/anthropic.test.js.map +1 -1
  75. package/dist/src/models/__tests__/bedrock.test.js +70 -107
  76. package/dist/src/models/__tests__/bedrock.test.js.map +1 -1
  77. package/dist/src/models/__tests__/gemini.test.js +438 -141
  78. package/dist/src/models/__tests__/gemini.test.js.map +1 -1
  79. package/dist/src/models/__tests__/model.test.js +14 -13
  80. package/dist/src/models/__tests__/model.test.js.map +1 -1
  81. package/dist/src/models/__tests__/openai.test.js +73 -83
  82. package/dist/src/models/__tests__/openai.test.js.map +1 -1
  83. package/dist/src/models/gemini/adapters.d.ts +2 -1
  84. package/dist/src/models/gemini/adapters.d.ts.map +1 -1
  85. package/dist/src/models/gemini/adapters.js +97 -10
  86. package/dist/src/models/gemini/adapters.js.map +1 -1
  87. package/dist/src/models/gemini/model.d.ts.map +1 -1
  88. package/dist/src/models/gemini/model.js +37 -1
  89. package/dist/src/models/gemini/model.js.map +1 -1
  90. package/dist/src/models/gemini/types.d.ts +9 -1
  91. package/dist/src/models/gemini/types.d.ts.map +1 -1
  92. package/dist/src/models/model.d.ts.map +1 -1
  93. package/dist/src/models/model.js +4 -0
  94. package/dist/src/models/model.js.map +1 -1
  95. package/dist/src/models/streaming.d.ts +13 -0
  96. package/dist/src/models/streaming.d.ts.map +1 -1
  97. package/dist/src/models/streaming.js +17 -0
  98. package/dist/src/models/streaming.js.map +1 -1
  99. package/dist/src/multiagent/__tests__/nodes.test.d.ts +2 -0
  100. package/dist/src/multiagent/__tests__/nodes.test.d.ts.map +1 -0
  101. package/dist/src/multiagent/__tests__/nodes.test.js +98 -0
  102. package/dist/src/multiagent/__tests__/nodes.test.js.map +1 -0
  103. package/dist/src/multiagent/events.d.ts +24 -0
  104. package/dist/src/multiagent/events.d.ts.map +1 -0
  105. package/dist/src/multiagent/events.js +19 -0
  106. package/dist/src/multiagent/events.js.map +1 -0
  107. package/dist/src/multiagent/index.d.ts +11 -0
  108. package/dist/src/multiagent/index.d.ts.map +1 -0
  109. package/dist/src/multiagent/index.js +7 -0
  110. package/dist/src/multiagent/index.js.map +1 -0
  111. package/dist/src/multiagent/nodes.d.ts +75 -0
  112. package/dist/src/multiagent/nodes.d.ts.map +1 -0
  113. package/dist/src/multiagent/nodes.js +101 -0
  114. package/dist/src/multiagent/nodes.js.map +1 -0
  115. package/dist/src/multiagent/state.d.ts +55 -0
  116. package/dist/src/multiagent/state.d.ts.map +1 -0
  117. package/dist/src/multiagent/state.js +43 -0
  118. package/dist/src/multiagent/state.js.map +1 -0
  119. package/dist/src/multiagent/types.d.ts +5 -0
  120. package/dist/src/multiagent/types.d.ts.map +1 -0
  121. package/dist/src/multiagent/types.js +2 -0
  122. package/dist/src/multiagent/types.js.map +1 -0
  123. package/dist/src/registry/tool-registry.d.ts +2 -1
  124. package/dist/src/registry/tool-registry.d.ts.map +1 -1
  125. package/dist/src/registry/tool-registry.js +4 -2
  126. package/dist/src/registry/tool-registry.js.map +1 -1
  127. package/dist/src/session/__tests__/file-storage.test.node.d.ts +2 -0
  128. package/dist/src/session/__tests__/file-storage.test.node.d.ts.map +1 -0
  129. package/dist/src/session/__tests__/file-storage.test.node.js +218 -0
  130. package/dist/src/session/__tests__/file-storage.test.node.js.map +1 -0
  131. package/dist/src/session/__tests__/s3-storage.test.node.d.ts +2 -0
  132. package/dist/src/session/__tests__/s3-storage.test.node.d.ts.map +1 -0
  133. package/dist/src/session/__tests__/s3-storage.test.node.js +375 -0
  134. package/dist/src/session/__tests__/s3-storage.test.node.js.map +1 -0
  135. package/dist/src/session/__tests__/validation.test.d.ts +2 -0
  136. package/dist/src/session/__tests__/validation.test.d.ts.map +1 -0
  137. package/dist/src/session/__tests__/validation.test.js +20 -0
  138. package/dist/src/session/__tests__/validation.test.js.map +1 -0
  139. package/dist/src/session/file-storage.d.ts +79 -0
  140. package/dist/src/session/file-storage.d.ts.map +1 -0
  141. package/dist/src/session/file-storage.js +144 -0
  142. package/dist/src/session/file-storage.js.map +1 -0
  143. package/dist/src/session/index.d.ts +19 -0
  144. package/dist/src/session/index.d.ts.map +1 -0
  145. package/dist/src/session/index.js +18 -0
  146. package/dist/src/session/index.js.map +1 -0
  147. package/dist/src/session/s3-storage.d.ts +93 -0
  148. package/dist/src/session/s3-storage.d.ts.map +1 -0
  149. package/dist/src/session/s3-storage.js +150 -0
  150. package/dist/src/session/s3-storage.js.map +1 -0
  151. package/dist/src/session/storage.d.ts +91 -0
  152. package/dist/src/session/storage.d.ts.map +1 -0
  153. package/dist/src/session/storage.js +2 -0
  154. package/dist/src/session/storage.js.map +1 -0
  155. package/dist/src/session/types.d.ts +49 -0
  156. package/dist/src/session/types.d.ts.map +1 -0
  157. package/dist/src/session/types.js +2 -0
  158. package/dist/src/session/types.js.map +1 -0
  159. package/dist/src/session/validation.d.ts +10 -0
  160. package/dist/src/session/validation.d.ts.map +1 -0
  161. package/dist/src/session/validation.js +16 -0
  162. package/dist/src/session/validation.js.map +1 -0
  163. package/dist/src/structured-output/__tests__/context.test.d.ts +2 -0
  164. package/dist/src/structured-output/__tests__/context.test.d.ts.map +1 -0
  165. package/dist/src/structured-output/__tests__/context.test.js +201 -0
  166. package/dist/src/structured-output/__tests__/context.test.js.map +1 -0
  167. package/dist/src/structured-output/__tests__/exceptions.test.d.ts +2 -0
  168. package/dist/src/structured-output/__tests__/exceptions.test.d.ts.map +1 -0
  169. package/dist/src/structured-output/__tests__/exceptions.test.js +103 -0
  170. package/dist/src/structured-output/__tests__/exceptions.test.js.map +1 -0
  171. package/dist/src/structured-output/__tests__/tool.test.d.ts +2 -0
  172. package/dist/src/structured-output/__tests__/tool.test.d.ts.map +1 -0
  173. package/dist/src/structured-output/__tests__/tool.test.js +256 -0
  174. package/dist/src/structured-output/__tests__/tool.test.js.map +1 -0
  175. package/dist/src/structured-output/__tests__/utils.test.d.ts +2 -0
  176. package/dist/src/structured-output/__tests__/utils.test.d.ts.map +1 -0
  177. package/dist/src/structured-output/__tests__/utils.test.js +183 -0
  178. package/dist/src/structured-output/__tests__/utils.test.js.map +1 -0
  179. package/dist/src/structured-output/context.d.ts +91 -0
  180. package/dist/src/structured-output/context.d.ts.map +1 -0
  181. package/dist/src/structured-output/context.js +112 -0
  182. package/dist/src/structured-output/context.js.map +1 -0
  183. package/dist/src/structured-output/exceptions.d.ts +18 -0
  184. package/dist/src/structured-output/exceptions.d.ts.map +1 -0
  185. package/dist/src/structured-output/exceptions.js +28 -0
  186. package/dist/src/structured-output/exceptions.js.map +1 -0
  187. package/dist/src/structured-output/tool.d.ts +33 -0
  188. package/dist/src/structured-output/tool.d.ts.map +1 -0
  189. package/dist/src/structured-output/tool.js +73 -0
  190. package/dist/src/structured-output/tool.js.map +1 -0
  191. package/dist/src/structured-output/utils.d.ts +23 -0
  192. package/dist/src/structured-output/utils.d.ts.map +1 -0
  193. package/dist/src/structured-output/utils.js +104 -0
  194. package/dist/src/structured-output/utils.js.map +1 -0
  195. package/dist/src/tools/zod-tool.d.ts.map +1 -1
  196. package/dist/src/tools/zod-tool.js +2 -5
  197. package/dist/src/tools/zod-tool.js.map +1 -1
  198. package/dist/src/tsconfig.tsbuildinfo +1 -1
  199. package/dist/src/types/__tests__/media.test.js +216 -1
  200. package/dist/src/types/__tests__/media.test.js.map +1 -1
  201. package/dist/src/types/__tests__/messages.test.js +193 -4
  202. package/dist/src/types/__tests__/messages.test.js.map +1 -1
  203. package/dist/src/types/agent.d.ts +13 -7
  204. package/dist/src/types/agent.d.ts.map +1 -1
  205. package/dist/src/types/agent.js +8 -1
  206. package/dist/src/types/agent.js.map +1 -1
  207. package/dist/src/types/json.d.ts +61 -0
  208. package/dist/src/types/json.d.ts.map +1 -1
  209. package/dist/src/types/json.js +24 -0
  210. package/dist/src/types/json.js.map +1 -1
  211. package/dist/src/types/media.d.ts +84 -4
  212. package/dist/src/types/media.d.ts.map +1 -1
  213. package/dist/src/types/media.js +194 -0
  214. package/dist/src/types/media.js.map +1 -1
  215. package/dist/src/types/messages.d.ts +158 -9
  216. package/dist/src/types/messages.d.ts.map +1 -1
  217. package/dist/src/types/messages.js +242 -7
  218. package/dist/src/types/messages.js.map +1 -1
  219. package/dist/src/types/serializable.d.ts +31 -0
  220. package/dist/src/types/serializable.d.ts.map +1 -0
  221. package/dist/src/types/serializable.js +19 -0
  222. package/dist/src/types/serializable.js.map +1 -0
  223. package/dist/src/utils/zod.d.ts +11 -0
  224. package/dist/src/utils/zod.d.ts.map +1 -0
  225. package/dist/src/utils/zod.js +14 -0
  226. package/dist/src/utils/zod.js.map +1 -0
  227. package/dist/src/vended-tools/bash/__tests__/bash.test.node.d.ts +2 -0
  228. package/dist/src/vended-tools/bash/__tests__/bash.test.node.d.ts.map +1 -0
  229. package/dist/src/vended-tools/bash/__tests__/{bash.test.js → bash.test.node.js} +3 -4
  230. package/dist/src/vended-tools/bash/__tests__/bash.test.node.js.map +1 -0
  231. package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.node.d.ts +2 -0
  232. package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.node.d.ts.map +1 -0
  233. package/dist/src/vended-tools/file_editor/__tests__/{file-editor.test.js → file-editor.test.node.js} +1 -1
  234. package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.node.js.map +1 -0
  235. package/package.json +7 -2
  236. package/dist/src/vended-tools/bash/__tests__/bash.test.d.ts +0 -2
  237. package/dist/src/vended-tools/bash/__tests__/bash.test.d.ts.map +0 -1
  238. package/dist/src/vended-tools/bash/__tests__/bash.test.js.map +0 -1
  239. package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.d.ts +0 -2
  240. package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.d.ts.map +0 -1
  241. package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.js.map +0 -1
@@ -0,0 +1,375 @@
1
+ import { describe, expect, it, beforeEach, vi } from 'vitest';
2
+ import { S3Storage } from '../s3-storage.js';
3
+ import { SessionError } from '../../errors.js';
4
+ import { createTestSnapshot, createTestManifest, createTestScope } from '../../__fixtures__/mock-storage-provider.js';
5
+ vi.mock('@aws-sdk/client-s3', () => ({
6
+ S3Client: vi.fn().mockImplementation(function () {
7
+ return {
8
+ send: vi.fn(),
9
+ config: {},
10
+ };
11
+ }),
12
+ PutObjectCommand: vi.fn().mockImplementation(function (input) {
13
+ return { input };
14
+ }),
15
+ GetObjectCommand: vi.fn().mockImplementation(function (input) {
16
+ return { input };
17
+ }),
18
+ ListObjectsV2Command: vi.fn().mockImplementation(function (input) {
19
+ return { input };
20
+ }),
21
+ }));
22
+ const SCOPE_ID = 'test-agent';
23
+ describe('S3Storage', () => {
24
+ let storage;
25
+ let mockS3Client;
26
+ beforeEach(() => {
27
+ vi.clearAllMocks();
28
+ storage = new S3Storage({ bucket: 'test-bucket', region: 'us-east-1' });
29
+ mockS3Client = storage._s3;
30
+ });
31
+ describe('constructor', () => {
32
+ describe('S3SnapshotStorage_When_ValidConfig_Then_CreatesInstance', () => {
33
+ it('stores bucket and region configuration', () => {
34
+ const instance = new S3Storage({ bucket: 'test-bucket', region: 'us-west-2' });
35
+ expect(instance._bucket).toBe('test-bucket');
36
+ expect(instance._s3).toBeDefined();
37
+ });
38
+ it('stores prefix when provided', () => {
39
+ const instance = new S3Storage({ bucket: 'test-bucket', prefix: 'my-prefix', region: 'us-east-1' });
40
+ expect(instance._prefix).toBe('my-prefix');
41
+ });
42
+ it('uses provided S3 client instead of creating new one', () => {
43
+ const customClient = { send: vi.fn() };
44
+ const instance = new S3Storage({ bucket: 'test-bucket', s3Client: customClient });
45
+ expect(instance._s3).toBe(customClient);
46
+ });
47
+ it('throws error when both s3Client and region are provided', () => {
48
+ const config = { bucket: 'test-bucket', region: 'us-west-2', s3Client: { send: vi.fn() } };
49
+ expect(() => new S3Storage(config)).toThrow(SessionError);
50
+ expect(() => new S3Storage(config)).toThrow('Cannot specify both s3Client and region');
51
+ });
52
+ });
53
+ });
54
+ describe('saveSnapshot', () => {
55
+ describe('S3SnapshotStorage_When_saveSnapshot_Then_PutsObjects', () => {
56
+ it('saves snapshot to S3 history', async () => {
57
+ const location = { sessionId: 'test-session', scope: createTestScope(), scopeId: SCOPE_ID };
58
+ const snapshot = createTestSnapshot();
59
+ mockS3Client.send.mockResolvedValue({});
60
+ await storage.saveSnapshot({ location, snapshotId: '1', isLatest: false, snapshot });
61
+ expect(mockS3Client.send).toHaveBeenCalledWith(expect.objectContaining({
62
+ input: {
63
+ Bucket: 'test-bucket',
64
+ Key: `test-session/scopes/agent/${SCOPE_ID}/snapshots/immutable_history/snapshot_00001.json`,
65
+ Body: JSON.stringify(snapshot, null, 2),
66
+ ContentType: 'application/json',
67
+ },
68
+ }));
69
+ });
70
+ it('saves snapshot as latest when isLatest is true', async () => {
71
+ const location = { sessionId: 'test-session', scope: createTestScope(), scopeId: SCOPE_ID };
72
+ const snapshot = createTestSnapshot();
73
+ mockS3Client.send.mockResolvedValue({});
74
+ await storage.saveSnapshot({ location, snapshotId: '1', isLatest: true, snapshot });
75
+ expect(mockS3Client.send).toHaveBeenCalledTimes(2);
76
+ expect(mockS3Client.send).toHaveBeenCalledWith(expect.objectContaining({
77
+ input: expect.objectContaining({
78
+ Key: `test-session/scopes/agent/${SCOPE_ID}/snapshots/snapshot_latest.json`,
79
+ }),
80
+ }));
81
+ });
82
+ it('uses prefix when configured', async () => {
83
+ const storageWithPrefix = new S3Storage({ bucket: 'test-bucket', prefix: 'my-app', region: 'us-east-1' });
84
+ const mockPrefixS3Client = storageWithPrefix._s3;
85
+ const location = { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID };
86
+ const snapshot = createTestSnapshot();
87
+ mockPrefixS3Client.send.mockResolvedValue({});
88
+ await storageWithPrefix.saveSnapshot({ location, snapshotId: '1', isLatest: false, snapshot });
89
+ expect(mockPrefixS3Client.send).toHaveBeenCalledWith(expect.objectContaining({
90
+ input: expect.objectContaining({
91
+ Key: `my-app/test-session/scopes/agent/${SCOPE_ID}/snapshots/immutable_history/snapshot_00001.json`,
92
+ }),
93
+ }));
94
+ });
95
+ });
96
+ describe('S3SnapshotStorage_When_saveSnapshotFails_Then_ThrowsSessionError', () => {
97
+ it('throws SessionError when S3 put fails', async () => {
98
+ const location = { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID };
99
+ const snapshot = createTestSnapshot();
100
+ mockS3Client.send.mockRejectedValue(new Error('S3 error'));
101
+ await expect(storage.saveSnapshot({ location, snapshotId: '1', isLatest: false, snapshot })).rejects.toThrow('Failed to write S3 object');
102
+ });
103
+ });
104
+ describe('S3SnapshotStorage_When_MultiAgentScope_Then_SavesCorrectly', () => {
105
+ it('saves multi-agent snapshot to correct S3 key', async () => {
106
+ const location = { sessionId: 'multi-session', scope: 'multiAgent', scopeId: 'graph-1' };
107
+ const snapshot = createTestSnapshot({ scope: 'multiAgent' });
108
+ mockS3Client.send.mockResolvedValue({});
109
+ await storage.saveSnapshot({ location, snapshotId: '1', isLatest: true, snapshot });
110
+ expect(mockS3Client.send).toHaveBeenCalledWith(expect.objectContaining({
111
+ input: expect.objectContaining({
112
+ Key: 'multi-session/scopes/multiAgent/graph-1/snapshots/snapshot_latest.json',
113
+ }),
114
+ }));
115
+ });
116
+ });
117
+ });
118
+ describe('loadSnapshot', () => {
119
+ describe('S3SnapshotStorage_When_LoadLatestSnapshot_Then_ReturnsSnapshot', () => {
120
+ it('loads latest snapshot when snapshotId is undefined', async () => {
121
+ const location = { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID };
122
+ const snapshot = createTestSnapshot();
123
+ mockS3Client.send.mockResolvedValue({
124
+ Body: { transformToString: () => Promise.resolve(JSON.stringify(snapshot)) },
125
+ });
126
+ const result = await storage.loadSnapshot({ location });
127
+ expect(result).toEqual(snapshot);
128
+ expect(mockS3Client.send).toHaveBeenCalledWith(expect.objectContaining({
129
+ input: {
130
+ Bucket: 'test-bucket',
131
+ Key: `test-session/scopes/agent/${SCOPE_ID}/snapshots/snapshot_latest.json`,
132
+ },
133
+ }));
134
+ });
135
+ });
136
+ describe('S3SnapshotStorage_When_LoadSpecificSnapshot_Then_ReturnsSnapshot', () => {
137
+ it('loads specific snapshot by ID', async () => {
138
+ const location = { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID };
139
+ const snapshot = createTestSnapshot();
140
+ mockS3Client.send.mockResolvedValue({
141
+ Body: { transformToString: () => Promise.resolve(JSON.stringify(snapshot)) },
142
+ });
143
+ const result = await storage.loadSnapshot({ location, snapshotId: '5' });
144
+ expect(result).toEqual(snapshot);
145
+ expect(mockS3Client.send).toHaveBeenCalledWith(expect.objectContaining({
146
+ input: expect.objectContaining({
147
+ Key: `test-session/scopes/agent/${SCOPE_ID}/snapshots/immutable_history/snapshot_00005.json`,
148
+ }),
149
+ }));
150
+ });
151
+ });
152
+ describe('S3SnapshotStorage_When_SnapshotNotFound_Then_ReturnsNull', () => {
153
+ it('returns null when S3 object does not exist', async () => {
154
+ const noSuchKeyError = Object.assign(new Error('NoSuchKey'), { name: 'NoSuchKey' });
155
+ mockS3Client.send.mockRejectedValue(noSuchKeyError);
156
+ const result = await storage.loadSnapshot({
157
+ location: { sessionId: 'nonexistent', scope: 'agent', scopeId: SCOPE_ID },
158
+ });
159
+ expect(result).toBeNull();
160
+ });
161
+ it('returns null when S3 response has no body', async () => {
162
+ mockS3Client.send.mockResolvedValue({ Body: null });
163
+ const result = await storage.loadSnapshot({
164
+ location: { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID },
165
+ });
166
+ expect(result).toBeNull();
167
+ });
168
+ it('returns null when S3 response body is empty', async () => {
169
+ mockS3Client.send.mockResolvedValue({ Body: { transformToString: () => Promise.resolve('') } });
170
+ const result = await storage.loadSnapshot({
171
+ location: { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID },
172
+ });
173
+ expect(result).toBeNull();
174
+ });
175
+ });
176
+ describe('S3SnapshotStorage_When_InvalidJSON_Then_ThrowsSessionError', () => {
177
+ it('throws SessionError when JSON is invalid', async () => {
178
+ mockS3Client.send.mockResolvedValue({
179
+ Body: { transformToString: () => Promise.resolve('invalid json') },
180
+ });
181
+ await expect(storage.loadSnapshot({ location: { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID } })).rejects.toThrow('Invalid JSON in S3 object');
182
+ });
183
+ });
184
+ describe('S3SnapshotStorage_When_S3Error_Then_ThrowsSessionError', () => {
185
+ it('throws SessionError when S3 get fails', async () => {
186
+ mockS3Client.send.mockRejectedValue(new Error('S3 error'));
187
+ await expect(storage.loadSnapshot({ location: { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID } })).rejects.toThrow('S3 error reading');
188
+ });
189
+ });
190
+ });
191
+ describe('listSnapshots', () => {
192
+ describe('S3SnapshotStorage_When_listSnapshots_Then_ReturnsOrderedIds', () => {
193
+ it('returns sorted snapshot IDs', async () => {
194
+ mockS3Client.send.mockResolvedValue({
195
+ Contents: [
196
+ { Key: `test-session/scopes/agent/${SCOPE_ID}/snapshots/immutable_history/snapshot_00003.json` },
197
+ { Key: `test-session/scopes/agent/${SCOPE_ID}/snapshots/immutable_history/snapshot_00001.json` },
198
+ { Key: `test-session/scopes/agent/${SCOPE_ID}/snapshots/immutable_history/snapshot_00002.json` },
199
+ ],
200
+ });
201
+ const result = await storage.listSnapshotIds({
202
+ location: { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID },
203
+ });
204
+ expect(result).toEqual(['1', '2', '3']);
205
+ expect(mockS3Client.send).toHaveBeenCalledWith(expect.objectContaining({
206
+ input: {
207
+ Bucket: 'test-bucket',
208
+ Prefix: `test-session/scopes/agent/${SCOPE_ID}/snapshots/immutable_history/`,
209
+ },
210
+ }));
211
+ });
212
+ it('returns empty array when no objects exist', async () => {
213
+ mockS3Client.send.mockResolvedValue({ Contents: [] });
214
+ const result = await storage.listSnapshotIds({
215
+ location: { sessionId: 'empty-session', scope: 'agent', scopeId: SCOPE_ID },
216
+ });
217
+ expect(result).toEqual([]);
218
+ });
219
+ it('ignores non-snapshot objects', async () => {
220
+ mockS3Client.send.mockResolvedValue({
221
+ Contents: [
222
+ { Key: `test-session/scopes/agent/${SCOPE_ID}/snapshots/immutable_history/snapshot_00001.json` },
223
+ { Key: `test-session/scopes/agent/${SCOPE_ID}/snapshots/immutable_history/other-file.txt` },
224
+ { Key: `test-session/scopes/agent/${SCOPE_ID}/snapshots/immutable_history/snapshot_00002.json` },
225
+ ],
226
+ });
227
+ const result = await storage.listSnapshotIds({
228
+ location: { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID },
229
+ });
230
+ expect(result).toEqual(['1', '2']);
231
+ });
232
+ it('handles objects without Key property', async () => {
233
+ mockS3Client.send.mockResolvedValue({
234
+ Contents: [
235
+ { Key: `test-session/scopes/agent/${SCOPE_ID}/snapshots/immutable_history/snapshot_00001.json` },
236
+ {},
237
+ { Key: `test-session/scopes/agent/${SCOPE_ID}/snapshots/immutable_history/snapshot_00002.json` },
238
+ ],
239
+ });
240
+ const result = await storage.listSnapshotIds({
241
+ location: { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID },
242
+ });
243
+ expect(result).toEqual(['1', '2']);
244
+ });
245
+ });
246
+ describe('S3SnapshotStorage_When_ListObjectsFails_Then_ThrowsSessionError', () => {
247
+ it('throws SessionError when S3 list fails', async () => {
248
+ mockS3Client.send.mockRejectedValue(new Error('S3 list error'));
249
+ await expect(storage.listSnapshotIds({ location: { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID } })).rejects.toThrow('Failed to list snapshots for session test-session');
250
+ });
251
+ });
252
+ });
253
+ describe('loadManifest', () => {
254
+ describe('S3SnapshotStorage_When_LoadManifest_Then_ReturnsManifest', () => {
255
+ it('loads existing manifest', async () => {
256
+ const location = { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID };
257
+ const manifest = createTestManifest({ nextSnapshotId: '5' });
258
+ mockS3Client.send.mockResolvedValue({
259
+ Body: { transformToString: () => Promise.resolve(JSON.stringify(manifest)) },
260
+ });
261
+ const result = await storage.loadManifest({ location });
262
+ expect(result).toEqual(manifest);
263
+ expect(mockS3Client.send).toHaveBeenCalledWith(expect.objectContaining({
264
+ input: expect.objectContaining({
265
+ Key: `test-session/scopes/agent/${SCOPE_ID}/snapshots/manifest.json`,
266
+ }),
267
+ }));
268
+ });
269
+ });
270
+ describe('S3SnapshotStorage_When_ManifestNotFound_Then_ReturnsDefault', () => {
271
+ it('returns default manifest when S3 object does not exist', async () => {
272
+ const noSuchKeyError = Object.assign(new Error('NoSuchKey'), { name: 'NoSuchKey' });
273
+ mockS3Client.send.mockRejectedValue(noSuchKeyError);
274
+ const result = await storage.loadManifest({
275
+ location: { sessionId: 'nonexistent', scope: 'agent', scopeId: SCOPE_ID },
276
+ });
277
+ expect(result).toEqual({
278
+ schemaVersion: '1.0',
279
+ nextSnapshotId: '1',
280
+ updatedAt: expect.any(String),
281
+ });
282
+ });
283
+ });
284
+ describe('S3SnapshotStorage_When_InvalidManifestJSON_Then_ThrowsSessionError', () => {
285
+ it('throws SessionError when manifest JSON is invalid', async () => {
286
+ mockS3Client.send.mockResolvedValue({
287
+ Body: { transformToString: () => Promise.resolve('invalid json') },
288
+ });
289
+ await expect(storage.loadManifest({ location: { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID } })).rejects.toThrow(SessionError);
290
+ });
291
+ });
292
+ });
293
+ describe('saveManifest', () => {
294
+ describe('S3SnapshotStorage_When_SaveManifest_Then_PutsObject', () => {
295
+ it('saves manifest to S3', async () => {
296
+ const location = { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID };
297
+ const manifest = createTestManifest({ nextSnapshotId: '10' });
298
+ mockS3Client.send.mockResolvedValue({});
299
+ await storage.saveManifest({ location, manifest });
300
+ expect(mockS3Client.send).toHaveBeenCalledWith(expect.objectContaining({
301
+ input: {
302
+ Bucket: 'test-bucket',
303
+ Key: `test-session/scopes/agent/${SCOPE_ID}/snapshots/manifest.json`,
304
+ Body: JSON.stringify(manifest, null, 2),
305
+ ContentType: 'application/json',
306
+ },
307
+ }));
308
+ });
309
+ });
310
+ describe('S3SnapshotStorage_When_SaveManifestFails_Then_ThrowsSessionError', () => {
311
+ it('throws SessionError when S3 put fails', async () => {
312
+ mockS3Client.send.mockRejectedValue(new Error('S3 error'));
313
+ await expect(storage.saveManifest({
314
+ location: { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID },
315
+ manifest: createTestManifest(),
316
+ })).rejects.toThrow(SessionError);
317
+ });
318
+ });
319
+ });
320
+ describe('edge cases', () => {
321
+ describe('S3SnapshotStorage_When_InvalidIdentifiers_Then_ThrowsError', () => {
322
+ it('throws error for invalid session ID', async () => {
323
+ const snapshot = createTestSnapshot();
324
+ await expect(storage.saveSnapshot({
325
+ location: { sessionId: 'invalid/session', scope: 'agent', scopeId: SCOPE_ID },
326
+ snapshotId: '1',
327
+ isLatest: false,
328
+ snapshot,
329
+ })).rejects.toThrow();
330
+ });
331
+ it('throws error for invalid scopeId', async () => {
332
+ const snapshot = createTestSnapshot();
333
+ await expect(storage.saveSnapshot({
334
+ location: { sessionId: 'test-session', scope: 'agent', scopeId: 'invalid/agent' },
335
+ snapshotId: '1',
336
+ isLatest: false,
337
+ snapshot,
338
+ })).rejects.toThrow();
339
+ });
340
+ });
341
+ describe('S3SnapshotStorage_When_SpecialCharacters_Then_HandlesCorrectly', () => {
342
+ it('handles special characters in snapshot data', async () => {
343
+ const location = { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID };
344
+ const specialData = { emoji: '🚀', unicode: 'café', quotes: '"test"' };
345
+ const snapshot = createTestSnapshot({
346
+ data: { messages: [], state: specialData, systemPrompt: null },
347
+ });
348
+ mockS3Client.send
349
+ .mockResolvedValueOnce({})
350
+ .mockResolvedValueOnce({})
351
+ .mockResolvedValueOnce({ Body: { transformToString: () => Promise.resolve(JSON.stringify(snapshot)) } });
352
+ await storage.saveSnapshot({ location, snapshotId: '1', isLatest: true, snapshot });
353
+ const result = await storage.loadSnapshot({ location });
354
+ expect(result?.data.state).toEqual(specialData);
355
+ });
356
+ });
357
+ describe('S3SnapshotStorage_When_LargeSnapshot_Then_HandlesCorrectly', () => {
358
+ it('handles large snapshots', async () => {
359
+ const location = { sessionId: 'test-session', scope: 'agent', scopeId: SCOPE_ID };
360
+ const largeState = { data: 'x'.repeat(10000) };
361
+ const snapshot = createTestSnapshot({
362
+ data: { messages: [], state: largeState, systemPrompt: null },
363
+ });
364
+ mockS3Client.send
365
+ .mockResolvedValueOnce({})
366
+ .mockResolvedValueOnce({})
367
+ .mockResolvedValueOnce({ Body: { transformToString: () => Promise.resolve(JSON.stringify(snapshot)) } });
368
+ await storage.saveSnapshot({ location, snapshotId: '1', isLatest: true, snapshot });
369
+ const result = await storage.loadSnapshot({ location });
370
+ expect(result?.data.state).toEqual(largeState);
371
+ });
372
+ });
373
+ });
374
+ });
375
+ //# sourceMappingURL=s3-storage.test.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3-storage.test.node.js","sourceRoot":"","sources":["../../../../src/session/__tests__/s3-storage.test.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAuB,MAAM,QAAQ,CAAA;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAA;AAGrH,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE,GAAG,EAAE,CAAC,CAAC;IACnC,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC;QACnC,OAAO;YACL,IAAI,EAAE,EAAE,CAAC,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CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;gBACnF,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA;gBAEvD,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;YAChD,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=validation.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.test.d.ts","sourceRoot":"","sources":["../../../../src/session/__tests__/validation.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { validateIdentifier } from '../validation.js';
3
+ describe('validateIdentifier', () => {
4
+ describe('when identifier is valid', () => {
5
+ it('returns the identifier', () => {
6
+ expect(validateIdentifier('valid-id')).toBe('valid-id');
7
+ });
8
+ });
9
+ describe('when identifier contains forward slash', () => {
10
+ it('throws error', () => {
11
+ expect(() => validateIdentifier('invalid/id')).toThrow("Identifier 'invalid/id' can only contain lowercase letters, numbers, hyphens, and underscores");
12
+ });
13
+ });
14
+ describe('when identifier contains backslash', () => {
15
+ it('throws error', () => {
16
+ expect(() => validateIdentifier('invalid\\id')).toThrow("Identifier 'invalid\\id' can only contain lowercase letters, numbers, hyphens, and underscores");
17
+ });
18
+ });
19
+ });
20
+ //# sourceMappingURL=validation.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.test.js","sourceRoot":"","sources":["../../../../src/session/__tests__/validation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAErD,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;QACxC,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;YAChC,MAAM,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACzD,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;QACtD,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;YACtB,MAAM,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CACpD,+FAA+F,CAChG,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAClD,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;YACtB,MAAM,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CACrD,gGAAgG,CACjG,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,79 @@
1
+ import type { SnapshotStorage, SnapshotLocation } from './storage.js';
2
+ import type { Snapshot, SnapshotManifest } from './types.js';
3
+ /**
4
+ * File-based implementation of SnapshotStorage for persisting session snapshots
5
+ */
6
+ export declare class FileStorage implements SnapshotStorage {
7
+ /** Base directory path */
8
+ private readonly _baseDir;
9
+ /**
10
+ * Creates new FileStorage instance
11
+ * @param baseDir - Base directory path for storing snapshots
12
+ */
13
+ constructor(baseDir: string);
14
+ /**
15
+ * Generates file path for session scope snapshots
16
+ */
17
+ private _getPath;
18
+ /**
19
+ * Saves snapshot to file, optionally marking as latest
20
+ */
21
+ saveSnapshot(params: {
22
+ location: SnapshotLocation;
23
+ snapshotId: string;
24
+ isLatest: boolean;
25
+ snapshot: Snapshot;
26
+ }): Promise<void>;
27
+ /**
28
+ * Loads snapshot by ID or latest if null
29
+ */
30
+ loadSnapshot(params: {
31
+ location: SnapshotLocation;
32
+ snapshotId?: string;
33
+ }): Promise<Snapshot | null>;
34
+ /**
35
+ * Checks if an error is a file not found error (ENOENT)
36
+ */
37
+ private _isFileNotFoundError;
38
+ /**
39
+ * Lists all snapshot IDs for a session scope.
40
+ *
41
+ * TODO: Add pagination support for long-running agents with many snapshots.
42
+ * Future signature could be:
43
+ * ```typescript
44
+ * listSnapshots(params: {
45
+ * sessionId: string
46
+ * scope: Scope
47
+ * limit?: number // Max results to return (e.g., 100)
48
+ * startAfter?: string // Snapshot ID to start after (for cursor-based pagination)
49
+ * }): Promise<{ snapshotIds: string[]; nextToken?: string }>
50
+ * ```
51
+ */
52
+ listSnapshotIds(params: {
53
+ location: SnapshotLocation;
54
+ }): Promise<string[]>;
55
+ /**
56
+ * Loads manifest or returns default if not found
57
+ */
58
+ loadManifest(params: {
59
+ location: SnapshotLocation;
60
+ }): Promise<SnapshotManifest>;
61
+ /**
62
+ * Saves manifest to file
63
+ */
64
+ saveManifest(params: {
65
+ location: SnapshotLocation;
66
+ manifest: SnapshotManifest;
67
+ }): Promise<void>;
68
+ /**
69
+ * Writes JSON data to file atomically
70
+ */
71
+ private _writeJSON;
72
+ /**
73
+ * Reads and parses JSON from file
74
+ */
75
+ private _readJSON;
76
+ private _getLatestSnapshotPath;
77
+ private _getHistorySnapshotPath;
78
+ }
79
+ //# sourceMappingURL=file-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-storage.d.ts","sourceRoot":"","sources":["../../../src/session/file-storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MA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