@alumbwe/anvil 1.0.41 → 1.0.49

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/bin/anvil.js +18 -0
  2. package/package.json +13 -6
  3. package/src/agents/bundled-agents.generated.ts +1 -1
  4. package/src/entry.ts +5 -0
  5. package/src/index.tsx +27 -4
  6. package/src/login/plain-login.ts +60 -0
  7. package/src/login/supabase-auth.ts +346 -0
  8. package/src/pre-init/client-env.ts +17 -0
  9. package/src/utils/anvil-client.ts +4 -0
  10. package/src/utils/auth.ts +16 -4
  11. package/src/utils/client-env-defaults.ts +28 -0
  12. package/src/utils/config-dir.ts +1 -1
  13. package/vendor/@anvil/common/src/constants/deepseek-direct.ts +30 -1
  14. package/vendor/@anvil/common/src/util/project-ignore.ts +4 -3
  15. package/vendor/@anvil/sdk/dist/index.cjs +46 -10
  16. package/vendor/@anvil/sdk/dist/index.mjs +46 -10
  17. package/src/commands/__tests__/anvil-command-aliases.test.ts +0 -56
  18. package/src/commands/__tests__/bash-command.test.ts +0 -445
  19. package/src/commands/__tests__/command-args.test.ts +0 -349
  20. package/src/commands/__tests__/copy-conversation-clipboard.test.ts +0 -108
  21. package/src/commands/__tests__/copy-conversation.test.ts +0 -226
  22. package/src/commands/__tests__/diagnostics-command.test.ts +0 -35
  23. package/src/commands/__tests__/image.test.ts +0 -99
  24. package/src/commands/__tests__/init.test.ts +0 -456
  25. package/src/commands/__tests__/new-command-rotates-chat.test.ts +0 -91
  26. package/src/commands/__tests__/process-diagnostics.test.ts +0 -54
  27. package/src/commands/__tests__/prompt-builders.test.ts +0 -28
  28. package/src/commands/__tests__/router-input.test.ts +0 -298
  29. package/src/components/__tests__/ad-banner.test.tsx +0 -83
  30. package/src/components/__tests__/anvil-landing-heading-row.test.tsx +0 -91
  31. package/src/components/__tests__/anvil-model-selector.test.tsx +0 -519
  32. package/src/components/__tests__/anvil-offer-invariants.test.ts +0 -54
  33. package/src/components/__tests__/anvil-takeover-prompt.test.tsx +0 -212
  34. package/src/components/__tests__/chat-input-bar.test.tsx +0 -130
  35. package/src/components/__tests__/grid-layout.integration.test.tsx +0 -304
  36. package/src/components/__tests__/grid-layout.test.tsx +0 -1051
  37. package/src/components/__tests__/message-block.completion.test.tsx +0 -104
  38. package/src/components/__tests__/message-block.streaming.test.tsx +0 -78
  39. package/src/components/__tests__/message-with-agents.test.tsx +0 -579
  40. package/src/components/__tests__/multiline-input.test.tsx +0 -1132
  41. package/src/components/__tests__/queue-panel.test.tsx +0 -398
  42. package/src/components/__tests__/selectable-list.test.ts +0 -232
  43. package/src/components/__tests__/status-bar.test.tsx +0 -44
  44. package/src/components/__tests__/status-indicator.test.tsx +0 -204
  45. package/src/components/__tests__/terminal-thinking-orb.test.tsx +0 -111
  46. package/src/components/__tests__/user-error-banner.test.tsx +0 -102
  47. package/src/components/ask-user/__tests__/multiple-choice-form.test.ts +0 -432
  48. package/src/components/ask-user/__tests__/validation.test.ts +0 -213
  49. package/src/components/tools/__tests__/apply-patch.test.tsx +0 -84
  50. package/src/components/tools/__tests__/code-search.test.tsx +0 -45
  51. package/src/components/tools/__tests__/gravity-index.test.ts +0 -76
  52. package/src/components/tools/__tests__/render-ui.test.tsx +0 -92
  53. package/src/components/tools/__tests__/run-terminal-command.test.ts +0 -233
  54. package/src/contexts/__tests__/chat-runtime-context.test.tsx +0 -149
  55. package/src/data/slash-commands.test.ts +0 -24
  56. package/src/hooks/__tests__/holds-live-anvil-slot.test.ts +0 -49
  57. package/src/hooks/__tests__/session-fetch-signal.test.ts +0 -63
  58. package/src/hooks/__tests__/use-activity-query.test.ts +0 -1000
  59. package/src/hooks/__tests__/use-ask-user-bridge.test.ts +0 -176
  60. package/src/hooks/__tests__/use-auth-query.test.ts +0 -21
  61. package/src/hooks/__tests__/use-chat-input-remount.test.tsx +0 -66
  62. package/src/hooks/__tests__/use-clipboard.test.tsx +0 -73
  63. package/src/hooks/__tests__/use-connection-status.test.ts +0 -112
  64. package/src/hooks/__tests__/use-directory-browser.test.ts +0 -203
  65. package/src/hooks/__tests__/use-gravity-ad.test.ts +0 -73
  66. package/src/hooks/__tests__/use-grid-layout.test.ts +0 -349
  67. package/src/hooks/__tests__/use-input-history.test.ts +0 -699
  68. package/src/hooks/__tests__/use-message-queue-editing.test.tsx +0 -209
  69. package/src/hooks/__tests__/use-message-queue.test.tsx +0 -71
  70. package/src/hooks/__tests__/use-path-tab-completion.test.ts +0 -315
  71. package/src/hooks/__tests__/use-queue-controls.test.ts +0 -68
  72. package/src/hooks/__tests__/use-queue-ui.test.tsx +0 -83
  73. package/src/hooks/__tests__/use-searchable-list.test.ts +0 -359
  74. package/src/hooks/__tests__/use-send-message-timer.test.ts +0 -146
  75. package/src/hooks/__tests__/use-suggestion-engine-mention.test.ts +0 -361
  76. package/src/hooks/__tests__/use-suggestion-engine.test.ts +0 -485
  77. package/src/hooks/__tests__/use-terminal-focus.test.ts +0 -66
  78. package/src/hooks/__tests__/use-terminal-layout.test.ts +0 -675
  79. package/src/hooks/__tests__/use-timeout.test.ts +0 -330
  80. package/src/hooks/__tests__/use-usage-query.test.ts +0 -502
  81. package/src/hooks/__tests__/use-user-details-query.test.ts +0 -195
  82. package/src/hooks/helpers/__tests__/send-message.test.ts +0 -1918
  83. package/src/init/__tests__/init-direnv.test.ts +0 -526
  84. package/src/state/__tests__/chat-store-focus.test.ts +0 -22
  85. package/src/state/__tests__/feedback-store.test.ts +0 -257
  86. package/src/utils/__tests__/active-run.test.ts +0 -140
  87. package/src/utils/__tests__/activity-tracker.test.ts +0 -440
  88. package/src/utils/__tests__/agent-display.test.ts +0 -139
  89. package/src/utils/__tests__/analytics-client.test.ts +0 -262
  90. package/src/utils/__tests__/anonymous-id.test.ts +0 -74
  91. package/src/utils/__tests__/anvil-api.test.ts +0 -578
  92. package/src/utils/__tests__/anvil-instance-owner.test.ts +0 -69
  93. package/src/utils/__tests__/anvil-model-navigation.test.ts +0 -102
  94. package/src/utils/__tests__/anvil-premium-reset.test.ts +0 -79
  95. package/src/utils/__tests__/anvil-referral-cache.test.ts +0 -116
  96. package/src/utils/__tests__/anvil-session-api.test.ts +0 -215
  97. package/src/utils/__tests__/anvil-session-display.test.ts +0 -23
  98. package/src/utils/__tests__/anvil-streak-line.test.ts +0 -217
  99. package/src/utils/__tests__/arrays.test.ts +0 -264
  100. package/src/utils/__tests__/bash-context-processor.test.ts +0 -38
  101. package/src/utils/__tests__/block-processor.test.ts +0 -810
  102. package/src/utils/__tests__/chat-history.test.ts +0 -203
  103. package/src/utils/__tests__/chat-input-key-intercept.test.ts +0 -40
  104. package/src/utils/__tests__/chat-meta.test.ts +0 -130
  105. package/src/utils/__tests__/clipboard-linux.test.ts +0 -359
  106. package/src/utils/__tests__/clipboard.test.ts +0 -910
  107. package/src/utils/__tests__/code-search-summary.test.ts +0 -84
  108. package/src/utils/__tests__/collapse-helpers.test.ts +0 -1109
  109. package/src/utils/__tests__/error-handling.test.ts +0 -658
  110. package/src/utils/__tests__/exit-cleanly.test.ts +0 -110
  111. package/src/utils/__tests__/feedback-helpers.test.ts +0 -444
  112. package/src/utils/__tests__/feedback-submission.test.ts +0 -26
  113. package/src/utils/__tests__/fetch-usage.test.ts +0 -355
  114. package/src/utils/__tests__/fingerprint.test.ts +0 -144
  115. package/src/utils/__tests__/fixtures/terminal-command-broker-child.ts +0 -7
  116. package/src/utils/__tests__/fixtures/terminal-command-broker-entry.ts +0 -3
  117. package/src/utils/__tests__/fixtures/terminal-command-broker-owner.ts +0 -33
  118. package/src/utils/__tests__/format-elapsed-time.test.ts +0 -103
  119. package/src/utils/__tests__/format-timeout.test.ts +0 -87
  120. package/src/utils/__tests__/image-dimensions.test.ts +0 -249
  121. package/src/utils/__tests__/image-processor.test.ts +0 -209
  122. package/src/utils/__tests__/implementor-helpers.test.ts +0 -1458
  123. package/src/utils/__tests__/keyboard-actions.test.ts +0 -660
  124. package/src/utils/__tests__/layout-helpers.test.ts +0 -36
  125. package/src/utils/__tests__/lazy-response-ads.test.ts +0 -167
  126. package/src/utils/__tests__/log-shipper.test.ts +0 -53
  127. package/src/utils/__tests__/markdown-renderer.test.tsx +0 -421
  128. package/src/utils/__tests__/message-block-helpers.test.ts +0 -1263
  129. package/src/utils/__tests__/message-updater.test.ts +0 -645
  130. package/src/utils/__tests__/osc-timeout-scenarios.test.ts +0 -172
  131. package/src/utils/__tests__/pending-attachments.test.ts +0 -277
  132. package/src/utils/__tests__/polling-backoff.test.ts +0 -51
  133. package/src/utils/__tests__/queue-panel-actions.test.ts +0 -148
  134. package/src/utils/__tests__/run-state-storage.test.ts +0 -919
  135. package/src/utils/__tests__/safe-json.test.ts +0 -77
  136. package/src/utils/__tests__/sdk-event-handlers.test.ts +0 -685
  137. package/src/utils/__tests__/send-message-helpers.test.ts +0 -1898
  138. package/src/utils/__tests__/send-message-timer.test.ts +0 -64
  139. package/src/utils/__tests__/settings.test.ts +0 -99
  140. package/src/utils/__tests__/strings.test.ts +0 -192
  141. package/src/utils/__tests__/terminal-color-detection.test.ts +0 -425
  142. package/src/utils/__tests__/terminal-command-broker.test.ts +0 -528
  143. package/src/utils/__tests__/terminal-enter-detection.test.ts +0 -77
  144. package/src/utils/__tests__/terminal-io.test.ts +0 -137
  145. package/src/utils/__tests__/terminal-protocol-controller.test.ts +0 -119
  146. package/src/utils/__tests__/text-layout.test.ts +0 -82
  147. package/src/utils/__tests__/theme-platform-detection.test.ts +0 -125
  148. package/src/utils/__tests__/think-tag-parser.test.ts +0 -159
  149. package/src/utils/__tests__/trace-writer.test.ts +0 -223
  150. package/src/utils/__tests__/trim-chat-logs.test.ts +0 -78
  151. package/src/utils/__tests__/usage-banner-state.test.ts +0 -298
  152. package/src/utils/__tests__/validation-error-formatting.test.ts +0 -126
  153. package/src/utils/__tests__/windows-terminal-health.test.ts +0 -101
  154. package/src/utils/__tests__/write-file-atomic.test.ts +0 -127
  155. package/vendor/@anvil/common/src/__tests__/agent-validation.test.ts +0 -846
  156. package/vendor/@anvil/common/src/__tests__/anvil-model-availability.test.ts +0 -101
  157. package/vendor/@anvil/common/src/__tests__/anvil-models.test.ts +0 -1408
  158. package/vendor/@anvil/common/src/__tests__/anvil-public-data-use-copy.test.ts +0 -258
  159. package/vendor/@anvil/common/src/__tests__/anvil-referral-tiers.test.ts +0 -48
  160. package/vendor/@anvil/common/src/__tests__/anvil-spend-ceilings.test.ts +0 -282
  161. package/vendor/@anvil/common/src/__tests__/anvil-trust.test.ts +0 -526
  162. package/vendor/@anvil/common/src/__tests__/deepseek-direct.test.ts +0 -68
  163. package/vendor/@anvil/common/src/__tests__/disposable-email.test.ts +0 -132
  164. package/vendor/@anvil/common/src/__tests__/dynamic-agent-template-schema.test.ts +0 -422
  165. package/vendor/@anvil/common/src/__tests__/env-ci.test.ts +0 -167
  166. package/vendor/@anvil/common/src/__tests__/env-process.test.ts +0 -145
  167. package/vendor/@anvil/common/src/__tests__/foreign-client-shipped-agents.test.ts +0 -234
  168. package/vendor/@anvil/common/src/__tests__/foreign-client-signals.test.ts +0 -379
  169. package/vendor/@anvil/common/src/__tests__/free-agents.test.ts +0 -807
  170. package/vendor/@anvil/common/src/__tests__/gravity-capi.test.ts +0 -154
  171. package/vendor/@anvil/common/src/__tests__/handlesteps-parsing.test.ts +0 -246
  172. package/vendor/@anvil/common/src/__tests__/kimi-k3-god-only.test.ts +0 -77
  173. package/vendor/@anvil/common/src/__tests__/model-config.test.ts +0 -89
  174. package/vendor/@anvil/common/src/__tests__/project-file-tree.test.ts +0 -298
  175. package/vendor/@anvil/common/src/__tests__/provisioned-model-tiers.test.ts +0 -116
  176. package/vendor/@anvil/common/src/__tests__/reasoning-effort.test.ts +0 -167
  177. package/vendor/@anvil/common/src/__tests__/reddit-capi.test.ts +0 -132
  178. package/vendor/@anvil/common/src/__tests__/response-ad-positions.test.ts +0 -72
  179. package/vendor/@anvil/common/src/__tests__/user-state.test.ts +0 -30
  180. package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding-gate.test.ts +0 -63
  181. package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding.test.ts +0 -246
  182. package/vendor/@anvil/common/src/constants/__tests__/cf-worker-signals.test.ts +0 -106
  183. package/vendor/@anvil/common/src/testing/TESTING_PATTERNS.md +0 -351
  184. package/vendor/@anvil/common/src/testing/anvil-offer-invariants.ts +0 -169
  185. package/vendor/@anvil/common/src/testing/errors.ts +0 -33
  186. package/vendor/@anvil/common/src/testing/fixtures/agent-runtime.ts +0 -334
  187. package/vendor/@anvil/common/src/testing/impl/agent-runtime.ts +0 -6
  188. package/vendor/@anvil/common/src/testing/index.ts +0 -84
  189. package/vendor/@anvil/common/src/testing/mock-modules.ts +0 -53
  190. package/vendor/@anvil/common/src/testing/mock-types.ts +0 -123
  191. package/vendor/@anvil/common/src/testing/mocks/analytics.ts +0 -261
  192. package/vendor/@anvil/common/src/testing/mocks/child-process.ts +0 -93
  193. package/vendor/@anvil/common/src/testing/mocks/crypto.ts +0 -218
  194. package/vendor/@anvil/common/src/testing/mocks/database.ts +0 -337
  195. package/vendor/@anvil/common/src/testing/mocks/fetch.ts +0 -219
  196. package/vendor/@anvil/common/src/testing/mocks/filesystem.ts +0 -166
  197. package/vendor/@anvil/common/src/testing/mocks/index.ts +0 -101
  198. package/vendor/@anvil/common/src/testing/mocks/logger.ts +0 -135
  199. package/vendor/@anvil/common/src/testing/mocks/stream.ts +0 -313
  200. package/vendor/@anvil/common/src/testing/mocks/timers.ts +0 -132
  201. package/vendor/@anvil/common/src/testing/mocks/tree-sitter.ts +0 -127
  202. package/vendor/@anvil/common/src/testing/setup.ts +0 -282
  203. package/vendor/@anvil/common/src/tools/__tests__/compile-tool-definitions.test.ts +0 -34
  204. package/vendor/@anvil/common/src/tools/params/__tests__/coerce-to-array.test.ts +0 -213
  205. package/vendor/@anvil/common/src/tools/params/__tests__/read-docs.test.ts +0 -47
  206. package/vendor/@anvil/common/src/tools/params/__tests__/render-ui.test.ts +0 -65
  207. package/vendor/@anvil/common/src/tools/params/tool/__tests__/run-terminal-command-timeout.test.ts +0 -49
  208. package/vendor/@anvil/common/src/types/__tests__/dynamic-agent-template.test.ts +0 -20
  209. package/vendor/@anvil/common/src/util/__tests__/ad-user-agent.test.ts +0 -26
  210. package/vendor/@anvil/common/src/util/__tests__/analytics-dispatcher.test.ts +0 -122
  211. package/vendor/@anvil/common/src/util/__tests__/analytics-log.test.ts +0 -102
  212. package/vendor/@anvil/common/src/util/__tests__/analytics-sampling.test.ts +0 -143
  213. package/vendor/@anvil/common/src/util/__tests__/anvil-streak.test.ts +0 -202
  214. package/vendor/@anvil/common/src/util/__tests__/anvil-usage-summary.test.ts +0 -193
  215. package/vendor/@anvil/common/src/util/__tests__/axiom-only-log.test.ts +0 -140
  216. package/vendor/@anvil/common/src/util/__tests__/client-user-agent.test.ts +0 -148
  217. package/vendor/@anvil/common/src/util/__tests__/engagement-tracker.test.ts +0 -115
  218. package/vendor/@anvil/common/src/util/__tests__/env-file-path.test.ts +0 -57
  219. package/vendor/@anvil/common/src/util/__tests__/error-abort.test.ts +0 -774
  220. package/vendor/@anvil/common/src/util/__tests__/error-api-details.test.ts +0 -206
  221. package/vendor/@anvil/common/src/util/__tests__/file-read-limits.test.ts +0 -173
  222. package/vendor/@anvil/common/src/util/__tests__/format-code-search.test.ts +0 -60
  223. package/vendor/@anvil/common/src/util/__tests__/log-mirror.test.ts +0 -31
  224. package/vendor/@anvil/common/src/util/__tests__/messages.test.ts +0 -1252
  225. package/vendor/@anvil/common/src/util/__tests__/partial-json-delta.test.ts +0 -505
  226. package/vendor/@anvil/common/src/util/__tests__/path.test.ts +0 -22
  227. package/vendor/@anvil/common/src/util/__tests__/project-ignore.test.ts +0 -90
  228. package/vendor/@anvil/common/src/util/__tests__/promise.test.ts +0 -325
  229. package/vendor/@anvil/common/src/util/__tests__/rate-limit.test.ts +0 -28
  230. package/vendor/@anvil/common/src/util/__tests__/reddit-anvil-retention.test.ts +0 -130
  231. package/vendor/@anvil/common/src/util/__tests__/saxy.test.ts +0 -1008
  232. package/vendor/@anvil/common/src/util/__tests__/split-data.test.ts +0 -289
  233. package/vendor/@anvil/common/src/util/__tests__/string.test.ts +0 -239
  234. package/vendor/@anvil/common/src/util/__tests__/thread-title.test.ts +0 -70
  235. package/vendor/@anvil/common/src/util/__tests__/tool-result-media-order.test.ts +0 -108
  236. package/vendor/@anvil/common/src/util/__tests__/ttft-histogram.test.ts +0 -180
  237. package/vendor/@anvil/common/src/util/__tests__/with-timeout.test.ts +0 -24
  238. package/vendor/@anvil/common/src/util/__tests__/zoned-time.test.ts +0 -88
  239. package/vendor/@anvil/common/src/util/skills.test.ts +0 -44
  240. package/vendor/@anvil/sdk/dist/index.cjs.map +0 -440
  241. package/vendor/@anvil/sdk/dist/index.mjs.map +0 -440
@@ -1,846 +0,0 @@
1
- import { beforeEach, describe, expect, it, test } from 'bun:test'
2
-
3
- import { validateAgents } from '../templates/agent-validation'
4
- import { DynamicAgentDefinitionSchema } from '../types/dynamic-agent-template'
5
- import { getStubProjectFileContext } from '../util/file'
6
-
7
- import type { DynamicAgentTemplate } from '../types/dynamic-agent-template'
8
- import type { AgentState } from '../types/session-state'
9
- import type { ProjectFileContext } from '../util/file'
10
- import type { Logger } from '@anvil/common/types/contracts/logger'
11
-
12
- describe('Agent Validation', () => {
13
- let mockFileContext: ProjectFileContext
14
- let mockAgentTemplate: DynamicAgentTemplate
15
- const logger: Logger = {
16
- debug: () => {},
17
- error: () => {},
18
- info: () => {},
19
- warn: () => {},
20
- }
21
-
22
- beforeEach(() => {
23
- mockFileContext = getStubProjectFileContext()
24
-
25
- mockAgentTemplate = {
26
- id: 'test-agent',
27
- version: '1.0.0',
28
- displayName: 'Test Agent',
29
- spawnerPrompt: 'Testing',
30
- model: 'claude-3-5-sonnet-20241022',
31
- outputMode: 'structured_output' as const,
32
- mcpServers: {},
33
- toolNames: ['set_output'],
34
- spawnableAgents: [],
35
- includeMessageHistory: true,
36
- inheritParentSystemPrompt: false,
37
- systemPrompt: 'Test system prompt',
38
- instructionsPrompt: 'Test user prompt',
39
- stepPrompt: 'Test agent step prompt',
40
- }
41
- })
42
-
43
- describe('Dynamic Agent Loading', () => {
44
- it('should load valid dynamic agent template', async () => {
45
- const fileContext: ProjectFileContext = {
46
- ...mockFileContext,
47
- agentTemplates: {
48
- 'brainstormer.ts': {
49
- id: 'brainstormer',
50
- version: '1.0.0',
51
- displayName: 'Brainy',
52
- spawnerPrompt: 'Creative thought partner',
53
- model: 'anthropic/claude-4-sonnet-20250522',
54
- systemPrompt: 'You are a creative brainstormer.',
55
- instructionsPrompt: 'Help brainstorm ideas.',
56
- stepPrompt: 'Continue brainstorming.',
57
- toolNames: ['end_turn', 'spawn_agents'],
58
- spawnableAgents: ['thinker', 'researcher'],
59
- outputMode: 'last_message',
60
- includeMessageHistory: true,
61
- inheritParentSystemPrompt: false,
62
- },
63
- },
64
- }
65
-
66
- const result = validateAgents({
67
- agentTemplates: fileContext.agentTemplates || {},
68
- logger,
69
- })
70
-
71
- expect(result.validationErrors).toHaveLength(0)
72
- expect(result.templates).toHaveProperty('brainstormer')
73
- expect(result.templates.brainstormer.displayName).toBe('Brainy')
74
- expect(result.templates.brainstormer.id).toBe('brainstormer')
75
- })
76
-
77
- it('should merge static and dynamic templates', async () => {
78
- const fileContext: ProjectFileContext = {
79
- ...mockFileContext,
80
- agentTemplates: {
81
- 'custom.ts': {
82
- id: 'custom-agent',
83
- version: '1.0.0',
84
- displayName: 'Custom',
85
- spawnerPrompt: 'Custom agent',
86
- model: 'anthropic/claude-4-sonnet-20250522',
87
- systemPrompt: 'Custom system prompt',
88
- instructionsPrompt: 'Custom user prompt',
89
- stepPrompt: 'Custom step prompt',
90
- outputMode: 'last_message',
91
- includeMessageHistory: true,
92
- inheritParentSystemPrompt: false,
93
- toolNames: ['end_turn'],
94
- spawnableAgents: [],
95
- },
96
- },
97
- }
98
-
99
- const result = validateAgents({
100
- agentTemplates: fileContext.agentTemplates || {},
101
- logger,
102
- })
103
-
104
- // Should have dynamic templates
105
- expect(result.templates).toHaveProperty('custom-agent') // Dynamic
106
- })
107
-
108
- it('should handle agents with JSON schemas', async () => {
109
- const fileContext: ProjectFileContext = {
110
- ...mockFileContext,
111
- agentTemplates: {
112
- 'schema-agent.ts': {
113
- id: 'schema-agent',
114
- version: '1.0.0',
115
- displayName: 'Schema Agent',
116
- spawnerPrompt: 'Agent with JSON schemas',
117
- model: 'anthropic/claude-4-sonnet-20250522',
118
- systemPrompt: 'Test system prompt',
119
- instructionsPrompt: 'Test user prompt',
120
- stepPrompt: 'Test step prompt',
121
- inputSchema: {
122
- prompt: {
123
- type: 'string',
124
- description: 'A test prompt',
125
- },
126
- params: {
127
- type: 'object',
128
- properties: {
129
- temperature: { type: 'number', minimum: 0, maximum: 1 },
130
- },
131
- },
132
- },
133
- outputMode: 'last_message',
134
- includeMessageHistory: true,
135
- inheritParentSystemPrompt: false,
136
- toolNames: ['end_turn'],
137
- spawnableAgents: [],
138
- },
139
- },
140
- }
141
-
142
- const result = validateAgents({
143
- agentTemplates: fileContext.agentTemplates || {},
144
- logger,
145
- })
146
-
147
- expect(result.validationErrors).toHaveLength(0)
148
- expect(result.templates).toHaveProperty('schema-agent')
149
- expect(result.templates['schema-agent'].inputSchema.prompt).toBeDefined()
150
- expect(result.templates['schema-agent'].inputSchema.params).toBeDefined()
151
- })
152
-
153
- it('should return validation errors for invalid schemas', async () => {
154
- const fileContext: ProjectFileContext = {
155
- ...mockFileContext,
156
- agentTemplates: {
157
- 'invalid-schema-agent.ts': {
158
- id: 'invalid-schema-agent',
159
- version: '1.0.0',
160
- displayName: 'Invalid Schema Agent',
161
- spawnerPrompt: 'Agent with invalid schemas',
162
- model: 'anthropic/claude-4-sonnet-20250522',
163
- systemPrompt: 'Test system prompt',
164
- instructionsPrompt: 'Test user prompt',
165
- stepPrompt: 'Test step prompt',
166
- inputSchema: {
167
- prompt: {} as Record<string, never>, // invalid prompt schema
168
- },
169
- outputMode: 'last_message',
170
- includeMessageHistory: true,
171
- inheritParentSystemPrompt: false,
172
- toolNames: ['end_turn'],
173
- spawnableAgents: [],
174
- },
175
- },
176
- }
177
-
178
- const result = validateAgents({
179
- agentTemplates: fileContext.agentTemplates || {},
180
- logger,
181
- })
182
-
183
- expect(result.validationErrors).toHaveLength(1)
184
- expect(result.validationErrors[0].message).toContain(
185
- 'Schema validation failed',
186
- )
187
- expect(result.templates).not.toHaveProperty('invalid-schema-agent')
188
- })
189
-
190
- it('should handle missing override field as non-override template', async () => {
191
- const fileContext: ProjectFileContext = {
192
- ...mockFileContext,
193
- agentTemplates: {
194
- 'no-override-field.ts': {
195
- id: 'no-override-agent',
196
- version: '1.0.0',
197
- // No override field - should be treated as non-override
198
- displayName: 'No Override Agent',
199
- spawnerPrompt: 'Agent without override field',
200
- model: 'anthropic/claude-4-sonnet-20250522',
201
- systemPrompt: 'Test system prompt',
202
- instructionsPrompt: 'Test user prompt',
203
- stepPrompt: 'Test step prompt',
204
- outputMode: 'last_message',
205
- includeMessageHistory: true,
206
- inheritParentSystemPrompt: false,
207
- toolNames: ['end_turn'],
208
- spawnableAgents: [],
209
- },
210
- },
211
- }
212
-
213
- const result = validateAgents({
214
- agentTemplates: fileContext.agentTemplates || {},
215
- logger,
216
- })
217
-
218
- expect(result.validationErrors).toHaveLength(0)
219
- expect(result.templates).toHaveProperty('no-override-agent')
220
- })
221
-
222
- it('should validate spawnable agents including dynamic agents from first pass', async () => {
223
- const fileContext: ProjectFileContext = {
224
- ...mockFileContext,
225
- agentTemplates: {
226
- 'git-committer.ts': {
227
- id: 'anvilai-git-committer',
228
- version: '0.0.1',
229
- displayName: 'Git Committer',
230
- spawnerPrompt: 'A git committer agent',
231
- model: 'google/gemini-2.5-pro',
232
- systemPrompt: 'You are an expert software developer.',
233
- instructionsPrompt: 'Create a commit message.',
234
- stepPrompt: 'Make sure to end your response.',
235
- spawnableAgents: [], // No spawnable agents
236
- outputMode: 'last_message',
237
- includeMessageHistory: true,
238
- inheritParentSystemPrompt: false,
239
- toolNames: ['end_turn'],
240
- },
241
- 'spawner.ts': {
242
- id: 'spawner-agent',
243
- version: '1.0.0',
244
- displayName: 'Spawner Agent',
245
- spawnerPrompt: 'Agent that can spawn git-committer',
246
- model: 'anthropic/claude-4-sonnet-20250522',
247
- systemPrompt: 'Test system prompt',
248
- instructionsPrompt: 'Test user prompt',
249
- stepPrompt: 'Test step prompt',
250
- spawnableAgents: ['anvilai-git-committer'], // Should be valid after first pass
251
- outputMode: 'last_message',
252
- includeMessageHistory: true,
253
- inheritParentSystemPrompt: false,
254
- toolNames: ['end_turn', 'spawn_agents'],
255
- },
256
- },
257
- }
258
-
259
- const result = validateAgents({
260
- agentTemplates: fileContext.agentTemplates || {},
261
- logger,
262
- })
263
-
264
- expect(result.validationErrors).toHaveLength(0)
265
- expect(result.templates).toHaveProperty('anvilai-git-committer')
266
- expect(result.templates).toHaveProperty('spawner-agent')
267
- expect(result.templates['spawner-agent'].spawnableAgents).toContain(
268
- 'anvilai-git-committer', // Full agent ID with prefix
269
- )
270
- })
271
- })
272
-
273
- describe('Schema Validation', () => {
274
- describe('Default Schema Behavior', () => {
275
- it('should have no prompt schema when no inputSchema provided', async () => {
276
- const fileContext: ProjectFileContext = {
277
- ...mockFileContext,
278
- agentTemplates: {
279
- 'no-prompt-schema.ts': {
280
- id: 'no-prompt-schema-agent',
281
- version: '1.0.0',
282
- displayName: 'No Prompt Schema Agent',
283
- spawnerPrompt: 'Test agent without prompt schema',
284
- model: 'anthropic/claude-4-sonnet-20250522',
285
- systemPrompt: 'Test system prompt',
286
- instructionsPrompt: 'Test user prompt',
287
- stepPrompt: 'Test step prompt',
288
- outputMode: 'last_message',
289
- includeMessageHistory: true,
290
- inheritParentSystemPrompt: false,
291
- toolNames: ['end_turn'],
292
- spawnableAgents: [],
293
- // No inputSchema
294
- },
295
- },
296
- }
297
-
298
- const result = validateAgents({
299
- agentTemplates: fileContext.agentTemplates || {},
300
- logger,
301
- })
302
-
303
- expect(result.validationErrors).toHaveLength(0)
304
- expect(result.templates).toHaveProperty('no-prompt-schema-agent')
305
- expect(
306
- result.templates['no-prompt-schema-agent'].inputSchema.prompt,
307
- ).toBeUndefined()
308
- })
309
-
310
- it('should not have params schema when no paramsSchema provided', async () => {
311
- const fileContext: ProjectFileContext = {
312
- ...mockFileContext,
313
- agentTemplates: {
314
- 'no-params-schema.ts': {
315
- id: 'no-params-schema-agent',
316
- version: '1.0.0',
317
- displayName: 'No Params Schema Agent',
318
- spawnerPrompt: 'Test agent without params schema',
319
- model: 'anthropic/claude-4-sonnet-20250522',
320
- systemPrompt: 'Test system prompt',
321
- instructionsPrompt: 'Test user prompt',
322
- stepPrompt: 'Test step prompt',
323
- outputMode: 'last_message',
324
- includeMessageHistory: true,
325
- inheritParentSystemPrompt: false,
326
- toolNames: ['end_turn'],
327
- spawnableAgents: [],
328
- // No paramsSchema
329
- },
330
- },
331
- }
332
-
333
- const result = validateAgents({
334
- agentTemplates: fileContext.agentTemplates || {},
335
- logger,
336
- })
337
-
338
- expect(result.validationErrors).toHaveLength(0)
339
- expect(result.templates).toHaveProperty('no-params-schema-agent')
340
- expect(
341
- result.templates['no-params-schema-agent'].inputSchema.params,
342
- ).toBeUndefined()
343
- })
344
- })
345
-
346
- describe('Complex Schema Scenarios', () => {
347
- it('should handle both inputSchema prompt and params together', async () => {
348
- const fileContext: ProjectFileContext = {
349
- ...mockFileContext,
350
- agentTemplates: {
351
- 'both-schemas.ts': {
352
- id: 'both-schemas-agent',
353
- version: '1.0.0',
354
- displayName: 'Both Schemas Agent',
355
- spawnerPrompt: 'Test agent with both schemas',
356
- model: 'anthropic/claude-4-sonnet-20250522',
357
- systemPrompt: 'Test system prompt',
358
- instructionsPrompt: 'Test user prompt',
359
- stepPrompt: 'Test step prompt',
360
- inputSchema: {
361
- prompt: {
362
- type: 'string',
363
- minLength: 1,
364
- description: 'A required prompt',
365
- },
366
- params: {
367
- type: 'object',
368
- properties: {
369
- mode: {
370
- type: 'string',
371
- enum: ['fast', 'thorough'],
372
- },
373
- iterations: {
374
- type: 'integer',
375
- minimum: 1,
376
- maximum: 10,
377
- default: 3,
378
- },
379
- },
380
- required: ['mode'],
381
- },
382
- },
383
- spawnableAgents: [],
384
- outputMode: 'last_message',
385
- includeMessageHistory: true,
386
- inheritParentSystemPrompt: false,
387
- toolNames: ['end_turn'],
388
- },
389
- },
390
- }
391
-
392
- const result = validateAgents({
393
- agentTemplates: fileContext.agentTemplates || {},
394
- logger,
395
- })
396
-
397
- expect(result.validationErrors).toHaveLength(0)
398
- expect(result.templates).toHaveProperty('both-schemas-agent')
399
-
400
- const template = result.templates['both-schemas-agent']
401
- expect(template.inputSchema.prompt).toBeDefined()
402
- expect(template.inputSchema.params).toBeDefined()
403
-
404
- const inputPromptSchema = template.inputSchema.prompt!
405
- const paramsSchema = template.inputSchema.params!
406
-
407
- // Test prompt schema
408
- expect(inputPromptSchema.safeParse('valid prompt').success).toBe(true)
409
- expect(inputPromptSchema.safeParse('').success).toBe(false) // Too short
410
-
411
- // Test params schema
412
- expect(
413
- paramsSchema.safeParse({ mode: 'fast', iterations: 5 }).success,
414
- ).toBe(true)
415
- expect(paramsSchema.safeParse({ mode: 'invalid' }).success).toBe(false) // Invalid enum
416
- expect(paramsSchema.safeParse({ iterations: 5 }).success).toBe(false) // Missing required field
417
- })
418
-
419
- it('should handle schema with nested objects and arrays', async () => {
420
- const fileContext: ProjectFileContext = {
421
- ...mockFileContext,
422
- agentTemplates: {
423
- 'complex-schema.ts': {
424
- id: 'complex-schema-agent',
425
- version: '1.0.0',
426
- displayName: 'Complex Schema Agent',
427
- spawnerPrompt: 'Test agent with complex nested schema',
428
- model: 'anthropic/claude-4-sonnet-20250522',
429
- systemPrompt: 'Test system prompt',
430
- instructionsPrompt: 'Test user prompt',
431
- stepPrompt: 'Test step prompt',
432
- inputSchema: {
433
- params: {
434
- type: 'object',
435
- properties: {
436
- config: {
437
- type: 'object',
438
- properties: {
439
- name: { type: 'string' },
440
- settings: {
441
- type: 'array',
442
- items: {
443
- type: 'object',
444
- properties: {
445
- key: { type: 'string' },
446
- value: { type: 'string' },
447
- },
448
- required: ['key', 'value'],
449
- },
450
- },
451
- },
452
- required: ['name'],
453
- },
454
- },
455
- required: ['config'],
456
- },
457
- },
458
- outputMode: 'last_message',
459
- includeMessageHistory: true,
460
- inheritParentSystemPrompt: false,
461
- toolNames: ['end_turn'],
462
- spawnableAgents: [],
463
- },
464
- },
465
- }
466
-
467
- const result = validateAgents({
468
- agentTemplates: fileContext.agentTemplates || {},
469
- logger,
470
- })
471
-
472
- expect(result.validationErrors).toHaveLength(0)
473
- expect(result.templates).toHaveProperty('complex-schema-agent')
474
-
475
- const paramsSchema =
476
- result.templates['complex-schema-agent'].inputSchema.params!
477
-
478
- // Test valid complex object
479
- const validParams = {
480
- config: {
481
- name: 'test config',
482
- settings: [
483
- { key: 'setting1', value: 'value1' },
484
- { key: 'setting2', value: 'value2' },
485
- ],
486
- },
487
- }
488
- expect(paramsSchema.safeParse(validParams).success).toBe(true)
489
-
490
- // Test invalid nested structure
491
- const invalidParams = {
492
- config: {
493
- name: 'test config',
494
- settings: [
495
- { key: 'setting1' }, // Missing required 'value' field
496
- ],
497
- },
498
- }
499
- expect(paramsSchema.safeParse(invalidParams).success).toBe(false)
500
- })
501
- })
502
-
503
- describe('Error Message Quality', () => {
504
- it('should include file path in error messages', async () => {
505
- const fileContext: ProjectFileContext = {
506
- ...mockFileContext,
507
- agentTemplates: {
508
- 'error-context.ts': {
509
- id: 'error-context-agent',
510
- version: '1.0.0',
511
- displayName: 'Error Context Agent',
512
- spawnerPrompt: 'Test agent for error context',
513
- model: 'anthropic/claude-4-sonnet-20250522',
514
- systemPrompt: 'Test system prompt',
515
- instructionsPrompt: 'Test user prompt',
516
- stepPrompt: 'Test step prompt',
517
- inputSchema: {
518
- prompt: 10 as unknown as Record<string, never>, // Invalid - number schema
519
- },
520
- outputMode: 'last_message',
521
- includeMessageHistory: true,
522
- inheritParentSystemPrompt: false,
523
- toolNames: ['end_turn'],
524
- spawnableAgents: [],
525
- },
526
- },
527
- }
528
-
529
- const result = validateAgents({
530
- agentTemplates: fileContext.agentTemplates || {},
531
- logger,
532
- })
533
-
534
- expect(result.validationErrors).toHaveLength(1)
535
- expect(result.validationErrors[0].message).toContain(
536
- 'Schema validation failed',
537
- )
538
- expect(result.validationErrors[0].filePath).toBe('error-context.ts')
539
- })
540
- })
541
-
542
- describe('Edge Cases', () => {
543
- it('should handle git-committer agent schema correctly', async () => {
544
- const fileContext: ProjectFileContext = {
545
- ...mockFileContext,
546
- agentTemplates: {
547
- 'git-committer.ts': {
548
- id: 'anvilai-git-committer',
549
- version: '0.0.1',
550
- displayName: 'Git Committer',
551
- spawnerPrompt:
552
- 'A git committer agent specialized to commit current changes with an appropriate commit message.',
553
- model: 'google/gemini-2.5-pro',
554
- systemPrompt: 'Test system prompt',
555
- instructionsPrompt: 'Test user prompt',
556
- stepPrompt: 'Test step prompt',
557
- inputSchema: {
558
- prompt: {
559
- type: 'string',
560
- description: 'What changes to commit',
561
- },
562
- params: {
563
- type: 'object',
564
- properties: {
565
- message: {
566
- type: 'string',
567
- },
568
- },
569
- required: ['message'],
570
- },
571
- },
572
- outputMode: 'last_message',
573
- includeMessageHistory: true,
574
- inheritParentSystemPrompt: false,
575
- toolNames: ['end_turn'],
576
- spawnableAgents: [],
577
- },
578
- },
579
- }
580
-
581
- const result = validateAgents({
582
- agentTemplates: fileContext.agentTemplates || {},
583
- logger,
584
- })
585
-
586
- expect(result.validationErrors).toHaveLength(0)
587
- expect(result.templates).toHaveProperty('anvilai-git-committer')
588
-
589
- const template = result.templates['anvilai-git-committer']
590
- const paramsSchema = template.inputSchema.params!
591
-
592
- expect(paramsSchema.safeParse('').success).toBe(false) // Too short
593
- expect(template.inputSchema.params).toBeDefined()
594
- // Test that the params schema properly validates the message property
595
- // This should succeed with a message property
596
- const validResult = paramsSchema.safeParse({
597
- message: 'test commit message',
598
- })
599
- expect(validResult.success).toBe(true)
600
-
601
- // This should fail without the required message property
602
- const invalidResult = paramsSchema.safeParse({})
603
- expect(invalidResult.success).toBe(false)
604
- })
605
-
606
- it('should handle empty inputSchema object', async () => {
607
- const fileContext: ProjectFileContext = {
608
- ...mockFileContext,
609
- agentTemplates: {
610
- 'empty-schema.ts': {
611
- id: 'empty-schema-agent',
612
- version: '1.0.0',
613
- displayName: 'Empty Schema Agent',
614
- model: 'anthropic/claude-4-sonnet-20250522',
615
- systemPrompt: 'Test system prompt',
616
- instructionsPrompt: 'Test user prompt',
617
- stepPrompt: 'Test step prompt',
618
- spawnerPrompt: 'Test agent with empty schema',
619
- inputSchema: {},
620
- outputMode: 'last_message',
621
- includeMessageHistory: true,
622
- inheritParentSystemPrompt: false,
623
- toolNames: ['end_turn'],
624
- spawnableAgents: [],
625
- },
626
- },
627
- }
628
-
629
- const result = validateAgents({
630
- agentTemplates: fileContext.agentTemplates || {},
631
- logger,
632
- })
633
-
634
- expect(result.validationErrors).toHaveLength(0)
635
- expect(result.templates).toHaveProperty('empty-schema-agent')
636
-
637
- // Empty schemas should have no prompt schema
638
- expect(
639
- result.templates['empty-schema-agent'].inputSchema.prompt,
640
- ).toBeUndefined()
641
- })
642
- })
643
- })
644
-
645
- describe('HandleSteps Parsing', () => {
646
- test('should validate agent config with handleSteps function', () => {
647
- const agentConfig = {
648
- id: 'test-agent',
649
- version: '1.0.0',
650
- displayName: 'Test Agent',
651
- spawnerPrompt: 'Testing handleSteps',
652
- model: 'claude-3-5-sonnet-20241022',
653
- outputMode: 'structured_output' as const,
654
- toolNames: ['set_output'],
655
- systemPrompt: 'You are a test agent',
656
- instructionsPrompt: 'Process: {prompt}',
657
- stepPrompt: 'Continue processing',
658
- handleSteps: function* ({
659
- agentState,
660
- prompt,
661
- params,
662
- }: {
663
- agentState: AgentState
664
- prompt?: string
665
- params?: any
666
- }) {
667
- yield {
668
- toolName: 'set_output',
669
- input: { message: 'Test completed' },
670
- }
671
- },
672
- }
673
-
674
- const result = DynamicAgentDefinitionSchema.safeParse(agentConfig)
675
- expect(result.success).toBe(true)
676
-
677
- if (result.success) {
678
- expect(typeof result.data.handleSteps).toBe('function')
679
- }
680
- })
681
-
682
- test('should convert handleSteps function to string', async () => {
683
- const handleStepsFunction = function* ({
684
- agentState,
685
- prompt,
686
- params,
687
- }: {
688
- agentState: AgentState
689
- prompt?: string
690
- params?: any
691
- }) {
692
- yield {
693
- toolName: 'set_output',
694
- input: { message: 'Hello from generator' },
695
- }
696
- }
697
-
698
- const agentTemplates = {
699
- 'test-agent.ts': {
700
- ...mockAgentTemplate,
701
- handleSteps: handleStepsFunction.toString(),
702
- },
703
- }
704
-
705
- const fileContext: ProjectFileContext = {
706
- ...mockFileContext,
707
- agentTemplates,
708
- }
709
-
710
- const result = validateAgents({
711
- agentTemplates: fileContext.agentTemplates || {},
712
- logger,
713
- })
714
-
715
- expect(result.validationErrors).toHaveLength(0)
716
- expect(result.templates['test-agent']).toBeDefined()
717
- expect(typeof result.templates['test-agent'].handleSteps).toBe('string')
718
- })
719
-
720
- // Note: The validation that required set_output tool for structured_output mode was
721
- // intentionally disabled to allow handleSteps to use set_output while the LLM does not
722
- // have access to the set_output tool.
723
- test('should allow structured_output mode without set_output tool in toolNames', () => {
724
- const {
725
- DynamicAgentTemplateSchema,
726
- } = require('../types/dynamic-agent-template')
727
-
728
- const agentConfig = {
729
- id: 'test-agent',
730
- version: '1.0.0',
731
- displayName: 'Test Agent',
732
- spawnerPrompt: 'Testing',
733
- model: 'claude-3-5-sonnet-20241022',
734
- outputMode: 'structured_output' as const,
735
- systemPrompt: 'Test',
736
- instructionsPrompt: 'Test',
737
- stepPrompt: 'Test',
738
- toolNames: ['end_turn'], // Missing set_output - now allowed
739
- spawnableAgents: [],
740
- handleSteps:
741
- 'function* () { yield { toolName: "set_output", input: {} } }',
742
- }
743
-
744
- const result = DynamicAgentTemplateSchema.safeParse(agentConfig)
745
- expect(result.success).toBe(true)
746
- })
747
-
748
- // Note: The validation that rejected set_output without structured_output mode was
749
- // intentionally disabled to allow parent agents to have set_output tool with 'last_message'
750
- // outputMode while their subagents use 'structured_output' (preserves prompt caching).
751
- test('should allow set_output tool without structured_output mode', () => {
752
- const {
753
- DynamicAgentTemplateSchema,
754
- } = require('../types/dynamic-agent-template')
755
-
756
- const agentConfig = {
757
- id: 'test-agent',
758
- version: '1.0.0',
759
- displayName: 'Test Agent',
760
- spawnerPrompt: 'Testing',
761
- model: 'claude-3-5-sonnet-20241022',
762
- outputMode: 'last_message' as const, // Not structured_output
763
- toolNames: ['end_turn', 'set_output'], // Has set_output - now allowed
764
- spawnableAgents: [],
765
- systemPrompt: 'Test',
766
- instructionsPrompt: 'Test',
767
- stepPrompt: 'Test',
768
- }
769
-
770
- const result = DynamicAgentTemplateSchema.safeParse(agentConfig)
771
- expect(result.success).toBe(true)
772
- })
773
-
774
- test('should validate that handleSteps is a generator function', async () => {
775
- const agentTemplates = {
776
- 'test-agent.ts': {
777
- ...mockAgentTemplate,
778
- handleSteps: 'function () { return "not a generator" }', // Missing *
779
- },
780
- }
781
-
782
- const fileContext: ProjectFileContext = {
783
- ...mockFileContext,
784
- agentTemplates,
785
- }
786
-
787
- const result = validateAgents({
788
- agentTemplates: fileContext.agentTemplates || {},
789
- logger,
790
- })
791
-
792
- expect(result.validationErrors.length).toBeGreaterThan(0)
793
- expect(result.validationErrors[0].message).toContain('generator function')
794
- expect(result.validationErrors[0].message).toContain('function*')
795
- })
796
- test('should verify loaded template handleSteps matches original function toString', async () => {
797
- // Create a generator function
798
- const originalFunction = function* ({
799
- agentState,
800
- prompt,
801
- params,
802
- }: {
803
- agentState: AgentState
804
- prompt?: string
805
- params?: any
806
- }) {
807
- yield {
808
- toolName: 'set_output',
809
- input: { message: 'Test output', data: params },
810
- }
811
- }
812
-
813
- // Get the string representation
814
- const expectedStringified = originalFunction.toString()
815
-
816
- // Create agent templates with the function
817
- const agentTemplates = {
818
- 'test-agent.ts': {
819
- ...mockAgentTemplate,
820
- handleSteps: expectedStringified,
821
- },
822
- }
823
-
824
- const fileContext: ProjectFileContext = {
825
- ...mockFileContext,
826
- agentTemplates,
827
- }
828
-
829
- // Load agents through the service
830
- const result = validateAgents({
831
- agentTemplates: fileContext.agentTemplates || {},
832
- logger,
833
- })
834
-
835
- // Verify no validation errors
836
- expect(result.validationErrors).toHaveLength(0)
837
- expect(result.templates['test-agent']).toBeDefined()
838
-
839
- // Verify the loaded template's handleSteps field matches the original toString
840
- expect(result.templates['test-agent'].handleSteps).toBe(
841
- expectedStringified,
842
- )
843
- expect(typeof result.templates['test-agent'].handleSteps).toBe('string')
844
- })
845
- })
846
- })