swarmdo 1.4.8 → 1.6.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 (215) hide show
  1. package/.claude/helpers/statusline.cjs +7 -7
  2. package/README.md +9 -6
  3. package/package.json +5 -3
  4. package/v3/@swarmdo/cli/dist/src/commands/compact.d.ts +16 -0
  5. package/v3/@swarmdo/cli/dist/src/commands/compact.js +106 -0
  6. package/v3/@swarmdo/cli/dist/src/commands/hooks.js +26 -24
  7. package/v3/@swarmdo/cli/dist/src/commands/index.js +10 -3
  8. package/v3/@swarmdo/cli/dist/src/commands/integrations.d.ts +14 -0
  9. package/v3/@swarmdo/cli/dist/src/commands/integrations.js +158 -0
  10. package/v3/@swarmdo/cli/dist/src/commands/memory.js +50 -1
  11. package/v3/@swarmdo/cli/dist/src/commands/providers.js +3 -0
  12. package/v3/@swarmdo/cli/dist/src/commands/release.d.ts +15 -0
  13. package/v3/@swarmdo/cli/dist/src/commands/release.js +241 -0
  14. package/v3/@swarmdo/cli/dist/src/commands/security.js +14 -0
  15. package/v3/@swarmdo/cli/dist/src/commands/transcript.js +82 -1
  16. package/v3/@swarmdo/cli/dist/src/commands/usage.js +80 -1
  17. package/v3/@swarmdo/cli/dist/src/compact/compact.d.ts +60 -0
  18. package/v3/@swarmdo/cli/dist/src/compact/compact.js +170 -0
  19. package/v3/@swarmdo/cli/dist/src/config-lint/lint.js +11 -1
  20. package/v3/@swarmdo/cli/dist/src/index.js +4 -2
  21. package/v3/@swarmdo/cli/dist/src/init/statusline-generator.js +6 -6
  22. package/v3/@swarmdo/cli/dist/src/integrations/integrations.d.ts +54 -0
  23. package/v3/@swarmdo/cli/dist/src/integrations/integrations.js +162 -0
  24. package/v3/@swarmdo/cli/dist/src/mcp-tools/agent-execute-core.js +25 -3
  25. package/v3/@swarmdo/cli/dist/src/mcp-tools/agentdb-tools.js +8 -8
  26. package/v3/@swarmdo/cli/dist/src/memory/graph-edge-writer.d.ts +12 -0
  27. package/v3/@swarmdo/cli/dist/src/memory/graph-edge-writer.js +32 -1
  28. package/v3/@swarmdo/cli/dist/src/memory-vault/watch.d.ts +32 -0
  29. package/v3/@swarmdo/cli/dist/src/memory-vault/watch.js +66 -0
  30. package/v3/@swarmdo/cli/dist/src/providers/openrouter-config.d.ts +91 -0
  31. package/v3/@swarmdo/cli/dist/src/providers/openrouter-config.js +186 -0
  32. package/v3/@swarmdo/cli/dist/src/release/release.d.ts +72 -0
  33. package/v3/@swarmdo/cli/dist/src/release/release.js +86 -0
  34. package/v3/@swarmdo/cli/dist/src/resilience/backoff.d.ts +23 -0
  35. package/v3/@swarmdo/cli/dist/src/resilience/backoff.js +30 -0
  36. package/v3/@swarmdo/cli/dist/src/swarmvector/model-router.js +14 -0
  37. package/v3/@swarmdo/cli/dist/src/transcript/search.d.ts +39 -0
  38. package/v3/@swarmdo/cli/dist/src/transcript/search.js +67 -0
  39. package/v3/@swarmdo/cli/dist/src/usage/diff.d.ts +69 -0
  40. package/v3/@swarmdo/cli/dist/src/usage/diff.js +112 -0
  41. package/v3/@swarmdo/cli/package.json +4 -4
  42. package/v3/@swarmdo/cli-core/dist/src/index.js +1 -1
  43. package/v3/@swarmdo/codex/dist/cli.js +0 -0
  44. package/v3/@swarmdo/hooks/dist/cli/guidance-cli.js +0 -0
  45. package/v3/@swarmdo/hooks/dist/statusline/index.d.ts +3 -3
  46. package/v3/@swarmdo/hooks/dist/statusline/index.js +3 -3
  47. package/v3/@swarmdo/integration/dist/__tests__/agentic-flow-agent.test.js +4 -1
  48. package/v3/@swarmdo/neural/dist/flash-attention.d.ts +1 -1
  49. package/v3/@swarmdo/neural/dist/flash-attention.js +1 -1
  50. package/v3/@swarmdo/plugin-agent-federation/dist/plugin.js +1 -1
  51. package/v3/@swarmdo/plugin-agent-federation/dist/transport/midstream-aware-loader.js +2 -2
  52. package/v3/@swarmdo/providers/dist/swarmvector-provider.d.ts +1 -1
  53. package/v3/@swarmdo/providers/dist/swarmvector-provider.js +1 -1
  54. package/v3/@swarmdo/security/dist/input-validator.d.ts +6 -6
  55. package/v3/@swarmdo/shared/dist/hooks/safety/git-commit.js +1 -1
  56. package/v3/@swarmdo/shared/dist/mcp/transport/http.js +8 -1
  57. package/v3/vendor/agentdb/package.json +0 -1
  58. package/v3/vendor/agentic-flow/package.json +0 -1
  59. package/.claude/scheduled_tasks.lock +0 -1
  60. package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/__init__.cpython-314.pyc +0 -0
  61. package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/__main__.cpython-314.pyc +0 -0
  62. package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/cli.cpython-314.pyc +0 -0
  63. package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/compress.cpython-314.pyc +0 -0
  64. package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/detect.cpython-314.pyc +0 -0
  65. package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/validate.cpython-314.pyc +0 -0
  66. package/v3/@swarmdo/plugin-iot-cognitum/dist/application/index.d.ts +0 -2
  67. package/v3/@swarmdo/plugin-iot-cognitum/dist/application/index.js +0 -2
  68. package/v3/@swarmdo/plugin-iot-cognitum/dist/application/iot-coordinator.d.ts +0 -138
  69. package/v3/@swarmdo/plugin-iot-cognitum/dist/application/iot-coordinator.js +0 -418
  70. package/v3/@swarmdo/plugin-iot-cognitum/dist/bin.d.ts +0 -15
  71. package/v3/@swarmdo/plugin-iot-cognitum/dist/bin.js +0 -240
  72. package/v3/@swarmdo/plugin-iot-cognitum/dist/cli-commands.d.ts +0 -7
  73. package/v3/@swarmdo/plugin-iot-cognitum/dist/cli-commands.js +0 -508
  74. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-agent.d.ts +0 -54
  75. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-agent.js +0 -2
  76. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-fleet.d.ts +0 -46
  77. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-fleet.js +0 -2
  78. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-trust-level.d.ts +0 -18
  79. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-trust-level.js +0 -28
  80. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/index.d.ts +0 -5
  81. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/index.js +0 -2
  82. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/telemetry.d.ts +0 -35
  83. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/telemetry.js +0 -2
  84. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/device-repository.d.ts +0 -11
  85. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/device-repository.js +0 -2
  86. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/fleet-repository.d.ts +0 -9
  87. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/fleet-repository.js +0 -2
  88. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/index.d.ts +0 -5
  89. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/index.js +0 -2
  90. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/telemetry-repository.d.ts +0 -12
  91. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/telemetry-repository.js +0 -2
  92. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/trust-history-repository.d.ts +0 -19
  93. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/trust-history-repository.js +0 -2
  94. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/anomaly-detection-service.d.ts +0 -44
  95. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/anomaly-detection-service.js +0 -117
  96. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/device-lifecycle-service.d.ts +0 -70
  97. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/device-lifecycle-service.js +0 -194
  98. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/firmware-orchestration-service.d.ts +0 -69
  99. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/firmware-orchestration-service.js +0 -139
  100. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/fleet-topology-service.d.ts +0 -34
  101. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/fleet-topology-service.js +0 -101
  102. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/index.d.ts +0 -10
  103. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/index.js +0 -10
  104. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/mesh-service.d.ts +0 -64
  105. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/mesh-service.js +0 -70
  106. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/sona-integration-service.d.ts +0 -44
  107. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/sona-integration-service.js +0 -79
  108. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-ingestion-service.d.ts +0 -37
  109. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-ingestion-service.js +0 -39
  110. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-service.d.ts +0 -67
  111. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-service.js +0 -58
  112. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/witness-verification-service.d.ts +0 -45
  113. package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/witness-verification-service.js +0 -63
  114. package/v3/@swarmdo/plugin-iot-cognitum/dist/index.d.ts +0 -26
  115. package/v3/@swarmdo/plugin-iot-cognitum/dist/index.js +0 -17
  116. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/agentdb-telemetry-repository.d.ts +0 -51
  117. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/agentdb-telemetry-repository.js +0 -110
  118. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-device-repository.d.ts +0 -13
  119. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-device-repository.js +0 -25
  120. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-fleet-repository.d.ts +0 -11
  121. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-fleet-repository.js +0 -19
  122. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-trust-history-repository.d.ts +0 -11
  123. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-trust-history-repository.js +0 -27
  124. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/index.d.ts +0 -6
  125. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/index.js +0 -6
  126. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/seed-client-factory.d.ts +0 -41
  127. package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/seed-client-factory.js +0 -64
  128. package/v3/@swarmdo/plugin-iot-cognitum/dist/mcp-tools.d.ts +0 -8
  129. package/v3/@swarmdo/plugin-iot-cognitum/dist/mcp-tools.js +0 -703
  130. package/v3/@swarmdo/plugin-iot-cognitum/dist/plugin.d.ts +0 -23
  131. package/v3/@swarmdo/plugin-iot-cognitum/dist/plugin.js +0 -239
  132. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/anomaly-scan-worker.d.ts +0 -17
  133. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/anomaly-scan-worker.js +0 -42
  134. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/firmware-watch-worker.d.ts +0 -18
  135. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/firmware-watch-worker.js +0 -45
  136. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/health-probe-worker.d.ts +0 -19
  137. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/health-probe-worker.js +0 -50
  138. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/mesh-sync-worker.d.ts +0 -19
  139. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/mesh-sync-worker.js +0 -47
  140. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/telemetry-ingest-worker.d.ts +0 -17
  141. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/telemetry-ingest-worker.js +0 -40
  142. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/witness-audit-worker.d.ts +0 -18
  143. package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/witness-audit-worker.js +0 -51
  144. package/v3/@swarmdo/testing/dist/fixtures/agent-fixtures.d.ts +0 -214
  145. package/v3/@swarmdo/testing/dist/fixtures/agent-fixtures.js +0 -595
  146. package/v3/@swarmdo/testing/dist/fixtures/agents.d.ts +0 -76
  147. package/v3/@swarmdo/testing/dist/fixtures/agents.js +0 -158
  148. package/v3/@swarmdo/testing/dist/fixtures/configurations.d.ts +0 -157
  149. package/v3/@swarmdo/testing/dist/fixtures/configurations.js +0 -337
  150. package/v3/@swarmdo/testing/dist/fixtures/index.d.ts +0 -10
  151. package/v3/@swarmdo/testing/dist/fixtures/index.js +0 -17
  152. package/v3/@swarmdo/testing/dist/fixtures/mcp-fixtures.d.ts +0 -329
  153. package/v3/@swarmdo/testing/dist/fixtures/mcp-fixtures.js +0 -714
  154. package/v3/@swarmdo/testing/dist/fixtures/memory-entries.d.ts +0 -159
  155. package/v3/@swarmdo/testing/dist/fixtures/memory-entries.js +0 -262
  156. package/v3/@swarmdo/testing/dist/fixtures/memory-fixtures.d.ts +0 -290
  157. package/v3/@swarmdo/testing/dist/fixtures/memory-fixtures.js +0 -547
  158. package/v3/@swarmdo/testing/dist/fixtures/swarm-fixtures.d.ts +0 -289
  159. package/v3/@swarmdo/testing/dist/fixtures/swarm-fixtures.js +0 -534
  160. package/v3/@swarmdo/testing/dist/fixtures/tasks.d.ts +0 -106
  161. package/v3/@swarmdo/testing/dist/fixtures/tasks.js +0 -229
  162. package/v3/@swarmdo/testing/dist/helpers/assertion-helpers.d.ts +0 -213
  163. package/v3/@swarmdo/testing/dist/helpers/assertion-helpers.js +0 -435
  164. package/v3/@swarmdo/testing/dist/helpers/assertions.d.ts +0 -135
  165. package/v3/@swarmdo/testing/dist/helpers/assertions.js +0 -217
  166. package/v3/@swarmdo/testing/dist/helpers/create-mock.d.ts +0 -96
  167. package/v3/@swarmdo/testing/dist/helpers/create-mock.js +0 -164
  168. package/v3/@swarmdo/testing/dist/helpers/index.d.ts +0 -14
  169. package/v3/@swarmdo/testing/dist/helpers/index.js +0 -22
  170. package/v3/@swarmdo/testing/dist/helpers/mock-factory.d.ts +0 -323
  171. package/v3/@swarmdo/testing/dist/helpers/mock-factory.js +0 -350
  172. package/v3/@swarmdo/testing/dist/helpers/setup-teardown.d.ts +0 -271
  173. package/v3/@swarmdo/testing/dist/helpers/setup-teardown.js +0 -446
  174. package/v3/@swarmdo/testing/dist/helpers/swarm-instance.d.ts +0 -142
  175. package/v3/@swarmdo/testing/dist/helpers/swarm-instance.js +0 -205
  176. package/v3/@swarmdo/testing/dist/helpers/test-application.d.ts +0 -190
  177. package/v3/@swarmdo/testing/dist/helpers/test-application.js +0 -138
  178. package/v3/@swarmdo/testing/dist/helpers/test-utils.d.ts +0 -274
  179. package/v3/@swarmdo/testing/dist/helpers/test-utils.js +0 -456
  180. package/v3/@swarmdo/testing/dist/index.d.ts +0 -42
  181. package/v3/@swarmdo/testing/dist/index.js +0 -66
  182. package/v3/@swarmdo/testing/dist/mocks/index.d.ts +0 -8
  183. package/v3/@swarmdo/testing/dist/mocks/index.js +0 -10
  184. package/v3/@swarmdo/testing/dist/mocks/mock-mcp-client.d.ts +0 -206
  185. package/v3/@swarmdo/testing/dist/mocks/mock-mcp-client.js +0 -575
  186. package/v3/@swarmdo/testing/dist/mocks/mock-services.d.ts +0 -287
  187. package/v3/@swarmdo/testing/dist/mocks/mock-services.js +0 -563
  188. package/v3/@swarmdo/testing/dist/regression/api-contract.d.ts +0 -109
  189. package/v3/@swarmdo/testing/dist/regression/api-contract.js +0 -374
  190. package/v3/@swarmdo/testing/dist/regression/index.d.ts +0 -18
  191. package/v3/@swarmdo/testing/dist/regression/index.js +0 -18
  192. package/v3/@swarmdo/testing/dist/regression/integration-regression.d.ts +0 -67
  193. package/v3/@swarmdo/testing/dist/regression/integration-regression.js +0 -334
  194. package/v3/@swarmdo/testing/dist/regression/performance-baseline.d.ts +0 -106
  195. package/v3/@swarmdo/testing/dist/regression/performance-baseline.js +0 -268
  196. package/v3/@swarmdo/testing/dist/regression/regression-runner.d.ts +0 -124
  197. package/v3/@swarmdo/testing/dist/regression/regression-runner.js +0 -227
  198. package/v3/@swarmdo/testing/dist/regression/security-regression.d.ts +0 -73
  199. package/v3/@swarmdo/testing/dist/regression/security-regression.js +0 -258
  200. package/v3/@swarmdo/testing/dist/setup.d.ts +0 -43
  201. package/v3/@swarmdo/testing/dist/setup.js +0 -91
  202. package/v3/@swarmdo/testing/dist/v2-compat/api-compat.test.d.ts +0 -10
  203. package/v3/@swarmdo/testing/dist/v2-compat/api-compat.test.js +0 -433
  204. package/v3/@swarmdo/testing/dist/v2-compat/cli-compat.test.d.ts +0 -10
  205. package/v3/@swarmdo/testing/dist/v2-compat/cli-compat.test.js +0 -352
  206. package/v3/@swarmdo/testing/dist/v2-compat/compatibility-validator.d.ts +0 -206
  207. package/v3/@swarmdo/testing/dist/v2-compat/compatibility-validator.js +0 -839
  208. package/v3/@swarmdo/testing/dist/v2-compat/hooks-compat.test.d.ts +0 -10
  209. package/v3/@swarmdo/testing/dist/v2-compat/hooks-compat.test.js +0 -428
  210. package/v3/@swarmdo/testing/dist/v2-compat/index.d.ts +0 -38
  211. package/v3/@swarmdo/testing/dist/v2-compat/index.js +0 -41
  212. package/v3/@swarmdo/testing/dist/v2-compat/mcp-compat.test.d.ts +0 -10
  213. package/v3/@swarmdo/testing/dist/v2-compat/mcp-compat.test.js +0 -419
  214. package/v3/@swarmdo/testing/dist/v2-compat/report-generator.d.ts +0 -34
  215. package/v3/@swarmdo/testing/dist/v2-compat/report-generator.js +0 -372
@@ -1,271 +0,0 @@
1
- /**
2
- * @swarmdo/testing - Setup & Teardown Helpers
3
- *
4
- * Global setup and teardown utilities for V3 module testing.
5
- * Provides test isolation, resource cleanup, and environment management.
6
- */
7
- import { vi } from 'vitest';
8
- /**
9
- * Setup context for managing test resources
10
- */
11
- export interface SetupContext {
12
- /**
13
- * Register a cleanup function to be called during teardown
14
- */
15
- addCleanup(cleanup: CleanupFunction): void;
16
- /**
17
- * Register a resource that needs to be closed/disposed
18
- */
19
- registerResource<T extends Disposable>(resource: T): T;
20
- /**
21
- * Get a registered resource by name
22
- */
23
- getResource<T>(name: string): T | undefined;
24
- /**
25
- * Set a named resource
26
- */
27
- setResource<T>(name: string, resource: T): void;
28
- /**
29
- * Run all cleanup functions
30
- */
31
- runCleanup(): Promise<void>;
32
- }
33
- /**
34
- * Cleanup function type
35
- */
36
- export type CleanupFunction = () => void | Promise<void>;
37
- /**
38
- * Disposable interface
39
- */
40
- export interface Disposable {
41
- dispose?(): void | Promise<void>;
42
- close?(): void | Promise<void>;
43
- destroy?(): void | Promise<void>;
44
- shutdown?(): void | Promise<void>;
45
- }
46
- /**
47
- * Create a setup context for managing test resources
48
- *
49
- * @example
50
- * const ctx = createSetupContext();
51
- * ctx.addCleanup(() => server.close());
52
- * ctx.registerResource(database);
53
- * // ... run tests
54
- * await ctx.runCleanup();
55
- */
56
- export declare function createSetupContext(): SetupContext;
57
- /**
58
- * Get or create the global test context
59
- */
60
- export declare function getGlobalContext(): SetupContext;
61
- /**
62
- * Reset the global test context
63
- */
64
- export declare function resetGlobalContext(): Promise<void>;
65
- /**
66
- * Test environment configuration
67
- */
68
- export interface TestEnvironmentConfig {
69
- /**
70
- * Reset all mocks before each test
71
- */
72
- resetMocks?: boolean;
73
- /**
74
- * Use fake timers
75
- */
76
- fakeTimers?: boolean;
77
- /**
78
- * Initial fake time
79
- */
80
- initialTime?: Date | number;
81
- /**
82
- * Environment variables to set
83
- */
84
- env?: Record<string, string>;
85
- /**
86
- * Suppress console output during tests
87
- */
88
- suppressConsole?: boolean | ('log' | 'warn' | 'error' | 'info')[];
89
- /**
90
- * Timeout for async operations
91
- */
92
- timeout?: number;
93
- }
94
- /**
95
- * Configure test environment with standard settings
96
- *
97
- * @example
98
- * configureTestEnvironment({
99
- * resetMocks: true,
100
- * fakeTimers: true,
101
- * suppressConsole: ['log', 'warn'],
102
- * });
103
- */
104
- export declare function configureTestEnvironment(config?: TestEnvironmentConfig): void;
105
- /**
106
- * Create a test suite with automatic setup/teardown
107
- *
108
- * @example
109
- * const { beforeEachTest, afterEachTest, getContext } = createTestSuite({
110
- * resetMocks: true,
111
- * });
112
- */
113
- export declare function createTestSuite(config?: TestEnvironmentConfig): TestSuiteHelpers;
114
- /**
115
- * Test suite helpers interface
116
- */
117
- export interface TestSuiteHelpers {
118
- beforeEachTest: (fn: (ctx: SetupContext) => void | Promise<void>) => void;
119
- afterEachTest: (fn: (ctx: SetupContext) => void | Promise<void>) => void;
120
- getContext: () => SetupContext;
121
- }
122
- /**
123
- * Create isolated test scope
124
- *
125
- * @example
126
- * const scope = createTestScope();
127
- * scope.addMock(mockService);
128
- * await scope.run(async () => {
129
- * // test code
130
- * });
131
- */
132
- export declare function createTestScope(): TestScope;
133
- /**
134
- * Test scope interface
135
- */
136
- export interface TestScope {
137
- addMock<T extends ReturnType<typeof vi.fn>>(mock: T): T;
138
- addCleanup(cleanup: CleanupFunction): void;
139
- run<T>(fn: () => Promise<T>): Promise<T>;
140
- clear(): void;
141
- reset(): void;
142
- }
143
- /**
144
- * Database test helper for memory/agentdb testing
145
- */
146
- export interface DatabaseTestHelper {
147
- setup(): Promise<void>;
148
- teardown(): Promise<void>;
149
- clear(): Promise<void>;
150
- seed(data: Record<string, unknown[]>): Promise<void>;
151
- }
152
- /**
153
- * Create in-memory database helper for testing
154
- *
155
- * @example
156
- * const db = createInMemoryDatabaseHelper();
157
- * await db.setup();
158
- * await db.seed({ users: [{ id: 1, name: 'Test' }] });
159
- * // ... run tests
160
- * await db.teardown();
161
- */
162
- export declare function createInMemoryDatabaseHelper(): DatabaseTestHelper;
163
- /**
164
- * Network test helper for mocking HTTP/WebSocket
165
- */
166
- export interface NetworkTestHelper {
167
- mockFetch(responses: MockFetchResponse[]): void;
168
- mockWebSocket(handler: (message: unknown) => unknown): void;
169
- clearMocks(): void;
170
- }
171
- /**
172
- * Mock fetch response
173
- */
174
- export interface MockFetchResponse {
175
- url: string | RegExp;
176
- method?: string;
177
- status?: number;
178
- body?: unknown;
179
- headers?: Record<string, string>;
180
- delay?: number;
181
- }
182
- /**
183
- * Create network test helper
184
- *
185
- * @example
186
- * const network = createNetworkTestHelper();
187
- * network.mockFetch([
188
- * { url: '/api/users', body: [{ id: 1 }] },
189
- * ]);
190
- */
191
- export declare function createNetworkTestHelper(): NetworkTestHelper;
192
- /**
193
- * File system test helper
194
- */
195
- export interface FileSystemTestHelper {
196
- createTempDir(): Promise<string>;
197
- createFile(path: string, content: string): Promise<void>;
198
- readFile(path: string): Promise<string>;
199
- cleanup(): Promise<void>;
200
- }
201
- /**
202
- * Create in-memory file system helper
203
- *
204
- * @example
205
- * const fs = createInMemoryFileSystemHelper();
206
- * await fs.createFile('/test.txt', 'content');
207
- * const content = await fs.readFile('/test.txt');
208
- */
209
- export declare function createInMemoryFileSystemHelper(): FileSystemTestHelper;
210
- /**
211
- * Performance test helper
212
- */
213
- export interface PerformanceTestHelper {
214
- startMeasurement(name: string): void;
215
- endMeasurement(name: string): number;
216
- getMeasurements(): Record<string, number[]>;
217
- getStats(name: string): {
218
- min: number;
219
- max: number;
220
- avg: number;
221
- p95: number;
222
- };
223
- clear(): void;
224
- }
225
- /**
226
- * Create performance test helper
227
- *
228
- * @example
229
- * const perf = createPerformanceTestHelper();
230
- * perf.startMeasurement('search');
231
- * await search();
232
- * const duration = perf.endMeasurement('search');
233
- */
234
- export declare function createPerformanceTestHelper(): PerformanceTestHelper;
235
- /**
236
- * Standard V3 test setup
237
- *
238
- * @example
239
- * // In your test file:
240
- * setupV3Tests();
241
- *
242
- * describe('MyModule', () => {
243
- * // tests...
244
- * });
245
- */
246
- export declare function setupV3Tests(config?: V3TestConfig): void;
247
- /**
248
- * V3 test configuration
249
- */
250
- export interface V3TestConfig {
251
- suppressConsole?: boolean | ('log' | 'warn' | 'error' | 'info')[];
252
- env?: Record<string, string>;
253
- timeout?: number;
254
- }
255
- /**
256
- * Wait for all pending promises to resolve
257
- *
258
- * @example
259
- * await flushPromises();
260
- */
261
- export declare function flushPromises(): Promise<void>;
262
- /**
263
- * Run with timeout
264
- *
265
- * @example
266
- * await withTimeout(async () => {
267
- * await longRunningOperation();
268
- * }, 5000);
269
- */
270
- export declare function withTestTimeout<T>(fn: () => Promise<T>, timeoutMs?: number): Promise<T>;
271
- //# sourceMappingURL=setup-teardown.d.ts.map
@@ -1,446 +0,0 @@
1
- /**
2
- * @swarmdo/testing - Setup & Teardown Helpers
3
- *
4
- * Global setup and teardown utilities for V3 module testing.
5
- * Provides test isolation, resource cleanup, and environment management.
6
- */
7
- import { vi, beforeEach, afterEach, beforeAll, afterAll } from 'vitest';
8
- /**
9
- * Create a setup context for managing test resources
10
- *
11
- * @example
12
- * const ctx = createSetupContext();
13
- * ctx.addCleanup(() => server.close());
14
- * ctx.registerResource(database);
15
- * // ... run tests
16
- * await ctx.runCleanup();
17
- */
18
- export function createSetupContext() {
19
- const cleanups = [];
20
- const resources = new Map();
21
- const disposables = [];
22
- return {
23
- addCleanup(cleanup) {
24
- cleanups.push(cleanup);
25
- },
26
- registerResource(resource) {
27
- disposables.push(resource);
28
- return resource;
29
- },
30
- getResource(name) {
31
- return resources.get(name);
32
- },
33
- setResource(name, resource) {
34
- resources.set(name, resource);
35
- },
36
- async runCleanup() {
37
- // Run cleanups in reverse order
38
- for (const cleanup of cleanups.reverse()) {
39
- try {
40
- await cleanup();
41
- }
42
- catch (error) {
43
- console.error('Cleanup error:', error);
44
- }
45
- }
46
- // Dispose resources
47
- for (const resource of disposables) {
48
- try {
49
- if (resource.dispose) {
50
- await resource.dispose();
51
- }
52
- else if (resource.close) {
53
- await resource.close();
54
- }
55
- else if (resource.destroy) {
56
- await resource.destroy();
57
- }
58
- else if (resource.shutdown) {
59
- await resource.shutdown();
60
- }
61
- }
62
- catch (error) {
63
- console.error('Resource disposal error:', error);
64
- }
65
- }
66
- cleanups.length = 0;
67
- resources.clear();
68
- disposables.length = 0;
69
- },
70
- };
71
- }
72
- /**
73
- * Global test context that persists across test files
74
- */
75
- let globalContext = null;
76
- /**
77
- * Get or create the global test context
78
- */
79
- export function getGlobalContext() {
80
- if (!globalContext) {
81
- globalContext = createSetupContext();
82
- }
83
- return globalContext;
84
- }
85
- /**
86
- * Reset the global test context
87
- */
88
- export async function resetGlobalContext() {
89
- if (globalContext) {
90
- await globalContext.runCleanup();
91
- globalContext = null;
92
- }
93
- }
94
- /**
95
- * Configure test environment with standard settings
96
- *
97
- * @example
98
- * configureTestEnvironment({
99
- * resetMocks: true,
100
- * fakeTimers: true,
101
- * suppressConsole: ['log', 'warn'],
102
- * });
103
- */
104
- export function configureTestEnvironment(config = {}) {
105
- const { resetMocks = true, fakeTimers = false, initialTime, env = {}, suppressConsole = false, } = config;
106
- const originalEnv = {};
107
- const originalConsole = {};
108
- beforeAll(() => {
109
- // Set environment variables
110
- for (const [key, value] of Object.entries(env)) {
111
- originalEnv[key] = process.env[key];
112
- process.env[key] = value;
113
- }
114
- // Suppress console
115
- if (suppressConsole) {
116
- const methods = suppressConsole === true
117
- ? ['log', 'warn', 'error', 'info']
118
- : suppressConsole;
119
- for (const method of methods) {
120
- originalConsole[method] = console[method];
121
- console[method] = vi.fn();
122
- }
123
- }
124
- });
125
- afterAll(() => {
126
- // Restore environment variables
127
- for (const [key, value] of Object.entries(originalEnv)) {
128
- if (value === undefined) {
129
- delete process.env[key];
130
- }
131
- else {
132
- process.env[key] = value;
133
- }
134
- }
135
- // Restore console
136
- for (const [method, original] of Object.entries(originalConsole)) {
137
- if (original) {
138
- console[method] = original;
139
- }
140
- }
141
- });
142
- beforeEach(() => {
143
- if (resetMocks) {
144
- vi.clearAllMocks();
145
- }
146
- if (fakeTimers) {
147
- vi.useFakeTimers();
148
- if (initialTime) {
149
- vi.setSystemTime(initialTime);
150
- }
151
- }
152
- });
153
- afterEach(() => {
154
- if (fakeTimers) {
155
- vi.useRealTimers();
156
- }
157
- vi.restoreAllMocks();
158
- });
159
- }
160
- /**
161
- * Create a test suite with automatic setup/teardown
162
- *
163
- * @example
164
- * const { beforeEachTest, afterEachTest, getContext } = createTestSuite({
165
- * resetMocks: true,
166
- * });
167
- */
168
- export function createTestSuite(config = {}) {
169
- const context = createSetupContext();
170
- configureTestEnvironment(config);
171
- return {
172
- beforeEachTest: (fn) => {
173
- beforeEach(async () => {
174
- await fn(context);
175
- });
176
- },
177
- afterEachTest: (fn) => {
178
- afterEach(async () => {
179
- await fn(context);
180
- await context.runCleanup();
181
- });
182
- },
183
- getContext: () => context,
184
- };
185
- }
186
- /**
187
- * Create isolated test scope
188
- *
189
- * @example
190
- * const scope = createTestScope();
191
- * scope.addMock(mockService);
192
- * await scope.run(async () => {
193
- * // test code
194
- * });
195
- */
196
- export function createTestScope() {
197
- const mocks = [];
198
- const cleanups = [];
199
- return {
200
- addMock(mock) {
201
- mocks.push(mock);
202
- return mock;
203
- },
204
- addCleanup(cleanup) {
205
- cleanups.push(cleanup);
206
- },
207
- async run(fn) {
208
- try {
209
- return await fn();
210
- }
211
- finally {
212
- // Clear all mocks
213
- for (const mock of mocks) {
214
- mock.mockClear();
215
- }
216
- // Run cleanups
217
- for (const cleanup of cleanups.reverse()) {
218
- await cleanup();
219
- }
220
- }
221
- },
222
- clear() {
223
- for (const mock of mocks) {
224
- mock.mockClear();
225
- }
226
- },
227
- reset() {
228
- for (const mock of mocks) {
229
- mock.mockReset();
230
- }
231
- },
232
- };
233
- }
234
- /**
235
- * Create in-memory database helper for testing
236
- *
237
- * @example
238
- * const db = createInMemoryDatabaseHelper();
239
- * await db.setup();
240
- * await db.seed({ users: [{ id: 1, name: 'Test' }] });
241
- * // ... run tests
242
- * await db.teardown();
243
- */
244
- export function createInMemoryDatabaseHelper() {
245
- const data = new Map();
246
- return {
247
- async setup() {
248
- data.clear();
249
- },
250
- async teardown() {
251
- data.clear();
252
- },
253
- async clear() {
254
- data.clear();
255
- },
256
- async seed(seedData) {
257
- for (const [table, records] of Object.entries(seedData)) {
258
- data.set(table, [...records]);
259
- }
260
- },
261
- };
262
- }
263
- /**
264
- * Create network test helper
265
- *
266
- * @example
267
- * const network = createNetworkTestHelper();
268
- * network.mockFetch([
269
- * { url: '/api/users', body: [{ id: 1 }] },
270
- * ]);
271
- */
272
- export function createNetworkTestHelper() {
273
- const fetchResponses = [];
274
- let originalFetch;
275
- return {
276
- mockFetch(responses) {
277
- fetchResponses.push(...responses);
278
- if (!originalFetch) {
279
- originalFetch = global.fetch;
280
- global.fetch = vi.fn(async (input, init) => {
281
- const url = typeof input === 'string' ? input : input.toString();
282
- const method = init?.method ?? 'GET';
283
- const match = fetchResponses.find(r => {
284
- const urlMatch = typeof r.url === 'string'
285
- ? url.includes(r.url)
286
- : r.url.test(url);
287
- const methodMatch = !r.method || r.method === method;
288
- return urlMatch && methodMatch;
289
- });
290
- if (!match) {
291
- throw new Error(`No mock found for ${method} ${url}`);
292
- }
293
- if (match.delay) {
294
- await new Promise(resolve => setTimeout(resolve, match.delay));
295
- }
296
- return new Response(JSON.stringify(match.body), {
297
- status: match.status ?? 200,
298
- headers: match.headers ?? { 'Content-Type': 'application/json' },
299
- });
300
- });
301
- }
302
- },
303
- mockWebSocket(handler) {
304
- // WebSocket mocking would require more setup
305
- // This is a placeholder for the interface
306
- console.warn('WebSocket mocking not yet implemented');
307
- },
308
- clearMocks() {
309
- fetchResponses.length = 0;
310
- if (originalFetch) {
311
- global.fetch = originalFetch;
312
- }
313
- },
314
- };
315
- }
316
- /**
317
- * Create in-memory file system helper
318
- *
319
- * @example
320
- * const fs = createInMemoryFileSystemHelper();
321
- * await fs.createFile('/test.txt', 'content');
322
- * const content = await fs.readFile('/test.txt');
323
- */
324
- export function createInMemoryFileSystemHelper() {
325
- const files = new Map();
326
- const tempDirs = [];
327
- return {
328
- async createTempDir() {
329
- const dir = `/tmp/test-${Date.now()}-${Math.random().toString(36).slice(2)}`;
330
- tempDirs.push(dir);
331
- return dir;
332
- },
333
- async createFile(path, content) {
334
- files.set(path, content);
335
- },
336
- async readFile(path) {
337
- const content = files.get(path);
338
- if (content === undefined) {
339
- throw new Error(`File not found: ${path}`);
340
- }
341
- return content;
342
- },
343
- async cleanup() {
344
- files.clear();
345
- tempDirs.length = 0;
346
- },
347
- };
348
- }
349
- /**
350
- * Create performance test helper
351
- *
352
- * @example
353
- * const perf = createPerformanceTestHelper();
354
- * perf.startMeasurement('search');
355
- * await search();
356
- * const duration = perf.endMeasurement('search');
357
- */
358
- export function createPerformanceTestHelper() {
359
- const measurements = new Map();
360
- const starts = new Map();
361
- return {
362
- startMeasurement(name) {
363
- starts.set(name, performance.now());
364
- },
365
- endMeasurement(name) {
366
- const start = starts.get(name);
367
- if (start === undefined) {
368
- throw new Error(`No measurement started for: ${name}`);
369
- }
370
- const duration = performance.now() - start;
371
- starts.delete(name);
372
- if (!measurements.has(name)) {
373
- measurements.set(name, []);
374
- }
375
- measurements.get(name).push(duration);
376
- return duration;
377
- },
378
- getMeasurements() {
379
- return Object.fromEntries(measurements);
380
- },
381
- getStats(name) {
382
- const values = measurements.get(name);
383
- if (!values || values.length === 0) {
384
- return { min: 0, max: 0, avg: 0, p95: 0 };
385
- }
386
- const sorted = [...values].sort((a, b) => a - b);
387
- const sum = sorted.reduce((a, b) => a + b, 0);
388
- return {
389
- min: sorted[0],
390
- max: sorted[sorted.length - 1],
391
- avg: sum / sorted.length,
392
- p95: sorted[Math.floor(sorted.length * 0.95)],
393
- };
394
- },
395
- clear() {
396
- measurements.clear();
397
- starts.clear();
398
- },
399
- };
400
- }
401
- /**
402
- * Standard V3 test setup
403
- *
404
- * @example
405
- * // In your test file:
406
- * setupV3Tests();
407
- *
408
- * describe('MyModule', () => {
409
- * // tests...
410
- * });
411
- */
412
- export function setupV3Tests(config = {}) {
413
- configureTestEnvironment({
414
- resetMocks: true,
415
- suppressConsole: config.suppressConsole ?? false,
416
- env: {
417
- NODE_ENV: 'test',
418
- SWARMDO_MODE: 'test',
419
- ...config.env,
420
- },
421
- });
422
- }
423
- /**
424
- * Wait for all pending promises to resolve
425
- *
426
- * @example
427
- * await flushPromises();
428
- */
429
- export function flushPromises() {
430
- return new Promise(resolve => setImmediate(resolve));
431
- }
432
- /**
433
- * Run with timeout
434
- *
435
- * @example
436
- * await withTimeout(async () => {
437
- * await longRunningOperation();
438
- * }, 5000);
439
- */
440
- export async function withTestTimeout(fn, timeoutMs = 5000) {
441
- return Promise.race([
442
- fn(),
443
- new Promise((_, reject) => setTimeout(() => reject(new Error(`Test timed out after ${timeoutMs}ms`)), timeoutMs)),
444
- ]);
445
- }
446
- //# sourceMappingURL=setup-teardown.js.map