@open-mercato/ai-assistant 0.6.6-develop.6465.1.019f0fb26f → 0.6.6-develop.6471.1.9ab5bdd79a

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 (199) hide show
  1. package/dist/frontend/hooks/useCommandPalette.js +16 -14
  2. package/dist/frontend/hooks/useCommandPalette.js.map +2 -2
  3. package/dist/modules/ai_assistant/api/ai/actions/[id]/cancel/route.js +3 -1
  4. package/dist/modules/ai_assistant/api/ai/actions/[id]/cancel/route.js.map +2 -2
  5. package/dist/modules/ai_assistant/api/ai/actions/[id]/confirm/route.js +3 -1
  6. package/dist/modules/ai_assistant/api/ai/actions/[id]/confirm/route.js.map +2 -2
  7. package/dist/modules/ai_assistant/api/ai/actions/[id]/route.js +3 -1
  8. package/dist/modules/ai_assistant/api/ai/actions/[id]/route.js.map +2 -2
  9. package/dist/modules/ai_assistant/api/ai/agents/[agentId]/loop-override/route.js +5 -3
  10. package/dist/modules/ai_assistant/api/ai/agents/[agentId]/loop-override/route.js.map +2 -2
  11. package/dist/modules/ai_assistant/api/ai/agents/[agentId]/models/route.js +4 -2
  12. package/dist/modules/ai_assistant/api/ai/agents/[agentId]/models/route.js.map +2 -2
  13. package/dist/modules/ai_assistant/api/ai/agents/[agentId]/mutation-policy/route.js +5 -3
  14. package/dist/modules/ai_assistant/api/ai/agents/[agentId]/mutation-policy/route.js.map +2 -2
  15. package/dist/modules/ai_assistant/api/ai/agents/[agentId]/prompt-override/route.js +4 -2
  16. package/dist/modules/ai_assistant/api/ai/agents/[agentId]/prompt-override/route.js.map +2 -2
  17. package/dist/modules/ai_assistant/api/ai/agents/route.js +3 -1
  18. package/dist/modules/ai_assistant/api/ai/agents/route.js.map +2 -2
  19. package/dist/modules/ai_assistant/api/ai/chat/route.js +6 -7
  20. package/dist/modules/ai_assistant/api/ai/chat/route.js.map +2 -2
  21. package/dist/modules/ai_assistant/api/ai/conversations/[conversationId]/route.js +5 -3
  22. package/dist/modules/ai_assistant/api/ai/conversations/[conversationId]/route.js.map +2 -2
  23. package/dist/modules/ai_assistant/api/ai/conversations/import/route.js +3 -1
  24. package/dist/modules/ai_assistant/api/ai/conversations/import/route.js.map +2 -2
  25. package/dist/modules/ai_assistant/api/ai/conversations/route.js +4 -2
  26. package/dist/modules/ai_assistant/api/ai/conversations/route.js.map +2 -2
  27. package/dist/modules/ai_assistant/api/ai/run-object/route.js +3 -1
  28. package/dist/modules/ai_assistant/api/ai/run-object/route.js.map +2 -2
  29. package/dist/modules/ai_assistant/api/chat/route.js +23 -14
  30. package/dist/modules/ai_assistant/api/chat/route.js.map +2 -2
  31. package/dist/modules/ai_assistant/api/health/route.js +3 -1
  32. package/dist/modules/ai_assistant/api/health/route.js.map +2 -2
  33. package/dist/modules/ai_assistant/api/mcp-key/route.js +3 -1
  34. package/dist/modules/ai_assistant/api/mcp-key/route.js.map +2 -2
  35. package/dist/modules/ai_assistant/api/route/route.js +11 -9
  36. package/dist/modules/ai_assistant/api/route/route.js.map +2 -2
  37. package/dist/modules/ai_assistant/api/session-key/route.js +3 -1
  38. package/dist/modules/ai_assistant/api/session-key/route.js.map +2 -2
  39. package/dist/modules/ai_assistant/api/settings/allowlist/route.js +4 -2
  40. package/dist/modules/ai_assistant/api/settings/allowlist/route.js.map +2 -2
  41. package/dist/modules/ai_assistant/api/settings/route.js +6 -4
  42. package/dist/modules/ai_assistant/api/settings/route.js.map +2 -2
  43. package/dist/modules/ai_assistant/api/tools/execute/route.js +3 -1
  44. package/dist/modules/ai_assistant/api/tools/execute/route.js.map +2 -2
  45. package/dist/modules/ai_assistant/api/tools/route.js +3 -1
  46. package/dist/modules/ai_assistant/api/tools/route.js.map +2 -2
  47. package/dist/modules/ai_assistant/api/usage/daily/route.js +3 -1
  48. package/dist/modules/ai_assistant/api/usage/daily/route.js.map +2 -2
  49. package/dist/modules/ai_assistant/api/usage/sessions/[sessionId]/route.js +3 -1
  50. package/dist/modules/ai_assistant/api/usage/sessions/[sessionId]/route.js.map +2 -2
  51. package/dist/modules/ai_assistant/api/usage/sessions/route.js +3 -1
  52. package/dist/modules/ai_assistant/api/usage/sessions/route.js.map +2 -2
  53. package/dist/modules/ai_assistant/cli.js +3 -0
  54. package/dist/modules/ai_assistant/cli.js.map +2 -2
  55. package/dist/modules/ai_assistant/lib/agent-policy.js +7 -5
  56. package/dist/modules/ai_assistant/lib/agent-policy.js.map +2 -2
  57. package/dist/modules/ai_assistant/lib/agent-registry.js +11 -13
  58. package/dist/modules/ai_assistant/lib/agent-registry.js.map +2 -2
  59. package/dist/modules/ai_assistant/lib/agent-runtime.js +21 -44
  60. package/dist/modules/ai_assistant/lib/agent-runtime.js.map +2 -2
  61. package/dist/modules/ai_assistant/lib/agent-tools.js +5 -10
  62. package/dist/modules/ai_assistant/lib/agent-tools.js.map +2 -2
  63. package/dist/modules/ai_assistant/lib/ai-overrides.js +5 -9
  64. package/dist/modules/ai_assistant/lib/ai-overrides.js.map +2 -2
  65. package/dist/modules/ai_assistant/lib/api-endpoint-index.js +22 -22
  66. package/dist/modules/ai_assistant/lib/api-endpoint-index.js.map +2 -2
  67. package/dist/modules/ai_assistant/lib/attachment-parts.js +10 -26
  68. package/dist/modules/ai_assistant/lib/attachment-parts.js.map +2 -2
  69. package/dist/modules/ai_assistant/lib/auth.js +3 -1
  70. package/dist/modules/ai_assistant/lib/auth.js.map +2 -2
  71. package/dist/modules/ai_assistant/lib/codemode-tools.js +15 -17
  72. package/dist/modules/ai_assistant/lib/codemode-tools.js.map +2 -2
  73. package/dist/modules/ai_assistant/lib/entity-index.js +7 -5
  74. package/dist/modules/ai_assistant/lib/entity-index.js.map +2 -2
  75. package/dist/modules/ai_assistant/lib/generated-registry-loader.js +3 -4
  76. package/dist/modules/ai_assistant/lib/generated-registry-loader.js.map +2 -2
  77. package/dist/modules/ai_assistant/lib/http-server.js +45 -48
  78. package/dist/modules/ai_assistant/lib/http-server.js.map +2 -2
  79. package/dist/modules/ai_assistant/lib/llm-bootstrap.js +5 -12
  80. package/dist/modules/ai_assistant/lib/llm-bootstrap.js.map +2 -2
  81. package/dist/modules/ai_assistant/lib/mcp-client.js +3 -1
  82. package/dist/modules/ai_assistant/lib/mcp-client.js.map +2 -2
  83. package/dist/modules/ai_assistant/lib/mcp-dev-key-resolution.js +3 -1
  84. package/dist/modules/ai_assistant/lib/mcp-dev-key-resolution.js.map +2 -2
  85. package/dist/modules/ai_assistant/lib/mcp-dev-server.js +3 -1
  86. package/dist/modules/ai_assistant/lib/mcp-dev-server.js.map +2 -2
  87. package/dist/modules/ai_assistant/lib/mcp-server.js +24 -19
  88. package/dist/modules/ai_assistant/lib/mcp-server.js.map +2 -2
  89. package/dist/modules/ai_assistant/lib/mcp-tool-adapter.js +3 -1
  90. package/dist/modules/ai_assistant/lib/mcp-tool-adapter.js.map +2 -2
  91. package/dist/modules/ai_assistant/lib/model-factory.js +4 -2
  92. package/dist/modules/ai_assistant/lib/model-factory.js.map +2 -2
  93. package/dist/modules/ai_assistant/lib/opencode-client.js +5 -3
  94. package/dist/modules/ai_assistant/lib/opencode-client.js.map +2 -2
  95. package/dist/modules/ai_assistant/lib/opencode-handlers.js +30 -12
  96. package/dist/modules/ai_assistant/lib/opencode-handlers.js.map +2 -2
  97. package/dist/modules/ai_assistant/lib/pending-action-cancel.js +3 -1
  98. package/dist/modules/ai_assistant/lib/pending-action-cancel.js.map +2 -2
  99. package/dist/modules/ai_assistant/lib/pending-action-executor.js +3 -1
  100. package/dist/modules/ai_assistant/lib/pending-action-executor.js.map +2 -2
  101. package/dist/modules/ai_assistant/lib/prepare-mutation.js +4 -6
  102. package/dist/modules/ai_assistant/lib/prepare-mutation.js.map +2 -2
  103. package/dist/modules/ai_assistant/lib/schema-utils.js +3 -1
  104. package/dist/modules/ai_assistant/lib/schema-utils.js.map +2 -2
  105. package/dist/modules/ai_assistant/lib/token-usage-recorder.js +4 -8
  106. package/dist/modules/ai_assistant/lib/token-usage-recorder.js.map +2 -2
  107. package/dist/modules/ai_assistant/lib/tool-executor.js +3 -1
  108. package/dist/modules/ai_assistant/lib/tool-executor.js.map +2 -2
  109. package/dist/modules/ai_assistant/lib/tool-loader.js +18 -25
  110. package/dist/modules/ai_assistant/lib/tool-loader.js.map +2 -2
  111. package/dist/modules/ai_assistant/lib/tool-registry.js +3 -1
  112. package/dist/modules/ai_assistant/lib/tool-registry.js.map +2 -2
  113. package/dist/modules/ai_assistant/lib/tool-test-runner.js +3 -1
  114. package/dist/modules/ai_assistant/lib/tool-test-runner.js.map +2 -2
  115. package/dist/modules/ai_assistant/setup.js +4 -8
  116. package/dist/modules/ai_assistant/setup.js.map +2 -2
  117. package/dist/modules/ai_assistant/subscribers/conversation-shared-notify.js +3 -1
  118. package/dist/modules/ai_assistant/subscribers/conversation-shared-notify.js.map +2 -2
  119. package/dist/modules/ai_assistant/workers/ai-pending-action-cleanup.js +7 -19
  120. package/dist/modules/ai_assistant/workers/ai-pending-action-cleanup.js.map +2 -2
  121. package/dist/modules/ai_assistant/workers/ai-token-usage-prune.js +5 -11
  122. package/dist/modules/ai_assistant/workers/ai-token-usage-prune.js.map +2 -2
  123. package/package.json +6 -6
  124. package/src/frontend/hooks/useCommandPalette.ts +17 -16
  125. package/src/modules/ai_assistant/__tests__/events.test.ts +23 -5
  126. package/src/modules/ai_assistant/__tests__/integration/ws-c-attachment-bridge.test.ts +21 -3
  127. package/src/modules/ai_assistant/__tests__/integration/ws-c-policy-and-tools.test.ts +22 -3
  128. package/src/modules/ai_assistant/__tests__/token-usage-recorder.test.ts +26 -5
  129. package/src/modules/ai_assistant/api/ai/actions/[id]/cancel/route.ts +4 -1
  130. package/src/modules/ai_assistant/api/ai/actions/[id]/confirm/route.ts +4 -1
  131. package/src/modules/ai_assistant/api/ai/actions/[id]/route.ts +4 -1
  132. package/src/modules/ai_assistant/api/ai/agents/[agentId]/loop-override/route.ts +6 -3
  133. package/src/modules/ai_assistant/api/ai/agents/[agentId]/models/route.ts +5 -2
  134. package/src/modules/ai_assistant/api/ai/agents/[agentId]/mutation-policy/route.ts +6 -3
  135. package/src/modules/ai_assistant/api/ai/agents/[agentId]/prompt-override/route.ts +5 -2
  136. package/src/modules/ai_assistant/api/ai/agents/route.ts +4 -1
  137. package/src/modules/ai_assistant/api/ai/chat/route.ts +7 -7
  138. package/src/modules/ai_assistant/api/ai/conversations/[conversationId]/route.ts +6 -3
  139. package/src/modules/ai_assistant/api/ai/conversations/import/route.ts +4 -1
  140. package/src/modules/ai_assistant/api/ai/conversations/route.ts +5 -2
  141. package/src/modules/ai_assistant/api/ai/run-object/route.ts +4 -1
  142. package/src/modules/ai_assistant/api/chat/route.ts +24 -15
  143. package/src/modules/ai_assistant/api/health/route.ts +4 -1
  144. package/src/modules/ai_assistant/api/mcp-key/route.ts +4 -1
  145. package/src/modules/ai_assistant/api/route/route.ts +12 -9
  146. package/src/modules/ai_assistant/api/session-key/route.ts +4 -1
  147. package/src/modules/ai_assistant/api/settings/allowlist/route.ts +5 -2
  148. package/src/modules/ai_assistant/api/settings/route.ts +7 -4
  149. package/src/modules/ai_assistant/api/tools/execute/route.ts +4 -1
  150. package/src/modules/ai_assistant/api/tools/route.ts +4 -1
  151. package/src/modules/ai_assistant/api/usage/daily/route.ts +4 -1
  152. package/src/modules/ai_assistant/api/usage/sessions/[sessionId]/route.ts +4 -1
  153. package/src/modules/ai_assistant/api/usage/sessions/route.ts +4 -1
  154. package/src/modules/ai_assistant/cli.ts +5 -0
  155. package/src/modules/ai_assistant/lib/__tests__/agent-policy.mutation-override.test.ts +20 -2
  156. package/src/modules/ai_assistant/lib/__tests__/agent-registry.test.ts +25 -5
  157. package/src/modules/ai_assistant/lib/__tests__/agent-runtime-loop-phase0.test.ts +21 -2
  158. package/src/modules/ai_assistant/lib/__tests__/agent-runtime-parity.test.ts +23 -3
  159. package/src/modules/ai_assistant/lib/__tests__/agent-runtime-phase4a.test.ts +20 -2
  160. package/src/modules/ai_assistant/lib/__tests__/agent-tools.test.ts +22 -3
  161. package/src/modules/ai_assistant/lib/__tests__/ai-overrides.test.ts +23 -3
  162. package/src/modules/ai_assistant/lib/__tests__/attachment-parts.test.ts +25 -7
  163. package/src/modules/ai_assistant/lib/__tests__/model-factory.test.ts +25 -5
  164. package/src/modules/ai_assistant/lib/__tests__/pending-action-cancel.test.ts +19 -1
  165. package/src/modules/ai_assistant/lib/__tests__/prepare-mutation.test.ts +22 -3
  166. package/src/modules/ai_assistant/lib/agent-policy.ts +8 -5
  167. package/src/modules/ai_assistant/lib/agent-registry.ts +12 -15
  168. package/src/modules/ai_assistant/lib/agent-runtime.ts +23 -46
  169. package/src/modules/ai_assistant/lib/agent-tools.ts +7 -11
  170. package/src/modules/ai_assistant/lib/ai-overrides.ts +6 -9
  171. package/src/modules/ai_assistant/lib/api-endpoint-index.ts +23 -22
  172. package/src/modules/ai_assistant/lib/attachment-parts.ts +14 -29
  173. package/src/modules/ai_assistant/lib/auth.ts +4 -1
  174. package/src/modules/ai_assistant/lib/codemode-tools.ts +17 -17
  175. package/src/modules/ai_assistant/lib/entity-index.ts +8 -5
  176. package/src/modules/ai_assistant/lib/generated-registry-loader.ts +4 -4
  177. package/src/modules/ai_assistant/lib/http-server.ts +46 -48
  178. package/src/modules/ai_assistant/lib/llm-bootstrap.ts +7 -13
  179. package/src/modules/ai_assistant/lib/mcp-client.ts +4 -1
  180. package/src/modules/ai_assistant/lib/mcp-dev-key-resolution.ts +4 -1
  181. package/src/modules/ai_assistant/lib/mcp-dev-server.ts +4 -1
  182. package/src/modules/ai_assistant/lib/mcp-server.ts +27 -19
  183. package/src/modules/ai_assistant/lib/mcp-tool-adapter.ts +4 -1
  184. package/src/modules/ai_assistant/lib/model-factory.ts +6 -3
  185. package/src/modules/ai_assistant/lib/opencode-client.ts +6 -3
  186. package/src/modules/ai_assistant/lib/opencode-handlers.ts +32 -12
  187. package/src/modules/ai_assistant/lib/pending-action-cancel.ts +4 -1
  188. package/src/modules/ai_assistant/lib/pending-action-executor.ts +4 -1
  189. package/src/modules/ai_assistant/lib/prepare-mutation.ts +5 -6
  190. package/src/modules/ai_assistant/lib/schema-utils.ts +4 -1
  191. package/src/modules/ai_assistant/lib/token-usage-recorder.ts +5 -8
  192. package/src/modules/ai_assistant/lib/tool-executor.ts +4 -1
  193. package/src/modules/ai_assistant/lib/tool-loader.ts +19 -25
  194. package/src/modules/ai_assistant/lib/tool-registry.ts +4 -1
  195. package/src/modules/ai_assistant/lib/tool-test-runner.ts +4 -1
  196. package/src/modules/ai_assistant/setup.ts +5 -8
  197. package/src/modules/ai_assistant/subscribers/conversation-shared-notify.ts +4 -1
  198. package/src/modules/ai_assistant/workers/ai-pending-action-cleanup.ts +8 -19
  199. package/src/modules/ai_assistant/workers/ai-token-usage-prune.ts +6 -11
@@ -9,6 +9,23 @@ import {
9
9
  seedAgentRegistryForTests,
10
10
  } from '../agent-registry'
11
11
 
12
+ jest.mock('@open-mercato/shared/lib/logger', () => {
13
+ const mocked = {
14
+ debug: jest.fn(),
15
+ info: jest.fn(),
16
+ warn: jest.fn(),
17
+ error: jest.fn(),
18
+ child: jest.fn(),
19
+ }
20
+ mocked.child.mockImplementation(() => mocked)
21
+ return { createLogger: jest.fn(() => mocked) }
22
+ })
23
+
24
+ const testLogger = jest
25
+ .requireMock('@open-mercato/shared/lib/logger')
26
+ .createLogger('test') as Record<'debug' | 'info' | 'warn' | 'error', jest.Mock>
27
+
28
+
12
29
  function makeAgent(overrides: Partial<AiAgentDefinition> & Pick<AiAgentDefinition, 'id' | 'moduleId'>): AiAgentDefinition {
13
30
  return {
14
31
  label: `${overrides.id} label`,
@@ -29,7 +46,8 @@ describe('agent-registry', () => {
29
46
  })
30
47
 
31
48
  it('loads generated agents when present and otherwise falls back to an empty registry', async () => {
32
- const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {})
49
+ const errorSpy = testLogger.error
50
+ errorSpy.mockClear()
33
51
 
34
52
  await loadAgentRegistry()
35
53
 
@@ -37,7 +55,7 @@ describe('agent-registry', () => {
37
55
  if (errorSpy.mock.calls.length > 0) {
38
56
  expect(agents).toEqual([])
39
57
  expect(errorSpy).toHaveBeenCalledWith(
40
- expect.stringContaining('[AI Agents] Could not load ai-agents.generated.ts'),
58
+ expect.stringContaining('Could not load ai-agents.generated.ts'),
41
59
  expect.any(Object),
42
60
  )
43
61
  } else {
@@ -98,7 +116,8 @@ describe('agent-registry', () => {
98
116
  })
99
117
 
100
118
  it('skips malformed entries with a warning, valid entries still load', () => {
101
- const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {})
119
+ const warnSpy = testLogger.warn
120
+ warnSpy.mockClear()
102
121
 
103
122
  const valid = makeAgent({ id: 'catalog.merchandiser', moduleId: 'catalog' })
104
123
  const malformed = {
@@ -114,7 +133,7 @@ describe('agent-registry', () => {
114
133
  expect(getAgent('catalog.broken')).toBeUndefined()
115
134
  expect(getAgent('catalog.merchandiser')).toBe(valid)
116
135
  expect(warnSpy).toHaveBeenCalledWith(
117
- expect.stringContaining('[AI Agents] Skipping malformed agent entry')
136
+ expect.stringContaining('Skipping malformed agent entry')
118
137
  )
119
138
  warnSpy.mockRestore()
120
139
  })
@@ -263,7 +282,8 @@ describe('agent-registry', () => {
263
282
  })
264
283
 
265
284
  it('loadAgentRegistry is idempotent — repeat calls do not duplicate entries', async () => {
266
- const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {})
285
+ const errorSpy = testLogger.error
286
+ errorSpy.mockClear()
267
287
 
268
288
  await loadAgentRegistry()
269
289
  const firstIds = listAgents().map((agent) => agent.id)
@@ -33,6 +33,23 @@ import {
33
33
  } from '../agent-runtime'
34
34
  import { AgentPolicyError } from '../agent-tools'
35
35
 
36
+ jest.mock('@open-mercato/shared/lib/logger', () => {
37
+ const mocked = {
38
+ debug: jest.fn(),
39
+ info: jest.fn(),
40
+ warn: jest.fn(),
41
+ error: jest.fn(),
42
+ child: jest.fn(),
43
+ }
44
+ mocked.child.mockImplementation(() => mocked)
45
+ return { createLogger: jest.fn(() => mocked) }
46
+ })
47
+
48
+ const testLogger = jest
49
+ .requireMock('@open-mercato/shared/lib/logger')
50
+ .createLogger('test') as Record<'debug' | 'info' | 'warn' | 'error', jest.Mock>
51
+
52
+
36
53
  function makeAgent(
37
54
  overrides: Partial<AiAgentDefinition> & Pick<AiAgentDefinition, 'id' | 'moduleId'>,
38
55
  ): AiAgentDefinition {
@@ -273,7 +290,8 @@ describe('mergeStepOverrides', () => {
273
290
  })
274
291
 
275
292
  it('drops user tools not present in wrappedRegistry with a warning', () => {
276
- const consoleSpy = jest.spyOn(console, 'warn').mockImplementation(() => undefined)
293
+ const consoleSpy = testLogger.warn
294
+ consoleSpy.mockClear()
277
295
  const rawHandler = { execute: jest.fn() }
278
296
  const result = mergeStepOverrides(
279
297
  {},
@@ -283,7 +301,8 @@ describe('mergeStepOverrides', () => {
283
301
  )
284
302
  expect((result.tools as Record<string, unknown>)['unknown__tool']).toBeUndefined()
285
303
  expect(consoleSpy).toHaveBeenCalledWith(
286
- expect.stringContaining('unknown__tool'),
304
+ expect.any(String),
305
+ expect.objectContaining({ toolName: 'unknown__tool' }),
287
306
  )
288
307
  consoleSpy.mockRestore()
289
308
  })
@@ -62,6 +62,23 @@ import * as agentToolsModule from '../agent-tools'
62
62
  import { AgentPolicyError } from '../agent-tools'
63
63
  import { runAiAgentObject, runAiAgentText } from '../agent-runtime'
64
64
 
65
+ jest.mock('@open-mercato/shared/lib/logger', () => {
66
+ const mocked = {
67
+ debug: jest.fn(),
68
+ info: jest.fn(),
69
+ warn: jest.fn(),
70
+ error: jest.fn(),
71
+ child: jest.fn(),
72
+ }
73
+ mocked.child.mockImplementation(() => mocked)
74
+ return { createLogger: jest.fn(() => mocked) }
75
+ })
76
+
77
+ const testLogger = jest
78
+ .requireMock('@open-mercato/shared/lib/logger')
79
+ .createLogger('test') as Record<'debug' | 'info' | 'warn' | 'error', jest.Mock>
80
+
81
+
65
82
  function makeAgent(
66
83
  overrides: Partial<AiAgentDefinition> & Pick<AiAgentDefinition, 'id' | 'moduleId'>,
67
84
  ): AiAgentDefinition {
@@ -254,7 +271,8 @@ describe('agent runtime parity (chat-mode ≡ object-mode)', () => {
254
271
  })
255
272
 
256
273
  it('filters out isMutation tools on read-only agents (warn + continue)', async () => {
257
- const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {})
274
+ const warnSpy = testLogger.warn
275
+ warnSpy.mockClear()
258
276
  registerMcpTool(
259
277
  makeTool({ name: 'customers.update_person', isMutation: true }),
260
278
  { moduleId: 'customers' },
@@ -284,7 +302,8 @@ describe('agent runtime parity (chat-mode ≡ object-mode)', () => {
284
302
  // Mutation tool filtered out; read-only tool survives.
285
303
  expect(Object.keys(resolved.tools)).toEqual(['customers__list_people'])
286
304
  expect(warnSpy).toHaveBeenCalledWith(
287
- expect.stringContaining('customers.update_person'),
305
+ expect.any(String),
306
+ expect.objectContaining({ toolName: 'customers.update_person' }),
288
307
  )
289
308
 
290
309
  // Chat path forwards the filtered tools map to streamText; object path
@@ -348,7 +367,8 @@ describe('agent runtime parity (chat-mode ≡ object-mode)', () => {
348
367
  })
349
368
 
350
369
  it('does not fail the request if resolvePageContext throws', async () => {
351
- const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {})
370
+ const errorSpy = testLogger.error
371
+ errorSpy.mockClear()
352
372
  const resolvePageContext = jest.fn(async () => {
353
373
  throw new Error('boom')
354
374
  })
@@ -85,6 +85,23 @@ import { resetAgentRegistryForTests, seedAgentRegistryForTests } from '../agent-
85
85
  import { toolRegistry } from '../tool-registry'
86
86
  import { runAiAgentText, runAiAgentObject } from '../agent-runtime'
87
87
 
88
+ jest.mock('@open-mercato/shared/lib/logger', () => {
89
+ const mocked = {
90
+ debug: jest.fn(),
91
+ info: jest.fn(),
92
+ warn: jest.fn(),
93
+ error: jest.fn(),
94
+ child: jest.fn(),
95
+ }
96
+ mocked.child.mockImplementation(() => mocked)
97
+ return { createLogger: jest.fn(() => mocked) }
98
+ })
99
+
100
+ const testLogger = jest
101
+ .requireMock('@open-mercato/shared/lib/logger')
102
+ .createLogger('test') as Record<'debug' | 'info' | 'warn' | 'error', jest.Mock>
103
+
104
+
88
105
  function makeAgent(
89
106
  overrides: Partial<AiAgentDefinition> & Pick<AiAgentDefinition, 'id' | 'moduleId'>,
90
107
  ): AiAgentDefinition {
@@ -132,7 +149,7 @@ function makeContainer(em: ReturnType<typeof makeFakeEm>) {
132
149
  }
133
150
 
134
151
  describe('Phase 4a — runtime model override hydration in agent-runtime', () => {
135
- let warnSpy: jest.SpyInstance
152
+ let warnSpy: jest.Mock
136
153
 
137
154
  beforeEach(() => {
138
155
  jest.clearAllMocks()
@@ -140,7 +157,8 @@ describe('Phase 4a — runtime model override hydration in agent-runtime', () =>
140
157
  toolRegistry.clear()
141
158
  streamTextMock.mockImplementation(() => fakeStreamResult())
142
159
  generateObjectMock.mockResolvedValue({ object: { result: 'ok' }, finishReason: 'stop', usage: {} })
143
- warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {})
160
+ warnSpy = testLogger.warn
161
+ warnSpy.mockClear()
144
162
  })
145
163
 
146
164
  afterEach(() => {
@@ -8,6 +8,23 @@ import {
8
8
  } from '../agent-registry'
9
9
  import { toolRegistry, registerMcpTool } from '../tool-registry'
10
10
 
11
+ jest.mock('@open-mercato/shared/lib/logger', () => {
12
+ const mocked = {
13
+ debug: jest.fn(),
14
+ info: jest.fn(),
15
+ warn: jest.fn(),
16
+ error: jest.fn(),
17
+ child: jest.fn(),
18
+ }
19
+ mocked.child.mockImplementation(() => mocked)
20
+ return { createLogger: jest.fn(() => mocked) }
21
+ })
22
+
23
+ const testLogger = jest
24
+ .requireMock('@open-mercato/shared/lib/logger')
25
+ .createLogger('test') as Record<'debug' | 'info' | 'warn' | 'error', jest.Mock>
26
+
27
+
11
28
  function makeAgent(
12
29
  overrides: Partial<AiAgentDefinition> & Pick<AiAgentDefinition, 'id' | 'moduleId'>,
13
30
  ): AiAgentDefinition {
@@ -40,12 +57,13 @@ const baseAuth = {
40
57
  }
41
58
 
42
59
  describe('resolveAiAgentTools', () => {
43
- let warnSpy: jest.SpyInstance
60
+ let warnSpy: jest.Mock
44
61
 
45
62
  beforeEach(() => {
46
63
  resetAgentRegistryForTests()
47
64
  toolRegistry.clear()
48
- warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {})
65
+ warnSpy = testLogger.warn
66
+ warnSpy.mockClear()
49
67
  })
50
68
 
51
69
  afterEach(() => {
@@ -147,7 +165,8 @@ describe('resolveAiAgentTools', () => {
147
165
 
148
166
  expect(Object.keys(result.tools)).toEqual(['customers__list_people'])
149
167
  expect(warnSpy).toHaveBeenCalledWith(
150
- expect.stringContaining('catalog.list_products'),
168
+ expect.any(String),
169
+ expect.objectContaining({ toolName: 'catalog.list_products' }),
151
170
  )
152
171
  })
153
172
 
@@ -33,6 +33,23 @@ import type { AiAgentDefinition } from '../ai-agent-definition'
33
33
  import type { AiToolDefinition } from '../types'
34
34
  import { z } from 'zod'
35
35
 
36
+ jest.mock('@open-mercato/shared/lib/logger', () => {
37
+ const mocked = {
38
+ debug: jest.fn(),
39
+ info: jest.fn(),
40
+ warn: jest.fn(),
41
+ error: jest.fn(),
42
+ child: jest.fn(),
43
+ }
44
+ mocked.child.mockImplementation(() => mocked)
45
+ return { createLogger: jest.fn(() => mocked) }
46
+ })
47
+
48
+ const testLogger = jest
49
+ .requireMock('@open-mercato/shared/lib/logger')
50
+ .createLogger('test') as Record<'debug' | 'info' | 'warn' | 'error', jest.Mock>
51
+
52
+
36
53
  function makeAgent(id: string, overrides: Partial<AiAgentDefinition> = {}): AiAgentDefinition {
37
54
  return {
38
55
  id,
@@ -130,7 +147,8 @@ describe('applyAgentOverrideMap', () => {
130
147
  it('warns and skips a malformed override (id mismatch)', () => {
131
148
  const a = makeAgent('catalog.catalog_assistant')
132
149
  const malformed = makeAgent('catalog.merchandising_assistant')
133
- const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {})
150
+ const warnSpy = testLogger.warn
151
+ warnSpy.mockClear()
134
152
  const out = applyAgentOverrideMap([a], {
135
153
  // The map key says one id but the value carries another.
136
154
  'catalog.catalog_assistant': malformed,
@@ -143,7 +161,8 @@ describe('applyAgentOverrideMap', () => {
143
161
 
144
162
  it('warns when an override targets an id with no base entry but does not throw', () => {
145
163
  const replacement = makeAgent('catalog.unknown')
146
- const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {})
164
+ const warnSpy = testLogger.warn
165
+ warnSpy.mockClear()
147
166
  const out = applyAgentOverrideMap([], { 'catalog.unknown': replacement })
148
167
  expect(warnSpy).toHaveBeenCalled()
149
168
  // Override that registers a brand-new agent IS supported (synthetic agents)
@@ -264,7 +283,8 @@ describe('tool override map', () => {
264
283
  it('skips and warns on malformed overrides (name mismatch)', () => {
265
284
  const original = makeTool('customers.update_deal_stage')
266
285
  const malformed = makeTool('customers.list_people')
267
- const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {})
286
+ const warnSpy = testLogger.warn
287
+ warnSpy.mockClear()
268
288
  const base = new Map<string, AiToolDefinition>([['customers.update_deal_stage', original]])
269
289
  const out = applyToolOverrideMap(base, { 'customers.update_deal_stage': malformed })
270
290
  expect(warnSpy).toHaveBeenCalled()
@@ -49,6 +49,23 @@ import {
49
49
  type AttachmentSigner,
50
50
  } from '../attachment-parts'
51
51
 
52
+ jest.mock('@open-mercato/shared/lib/logger', () => {
53
+ const mocked = {
54
+ debug: jest.fn(),
55
+ info: jest.fn(),
56
+ warn: jest.fn(),
57
+ error: jest.fn(),
58
+ child: jest.fn(),
59
+ }
60
+ mocked.child.mockImplementation(() => mocked)
61
+ return { createLogger: jest.fn(() => mocked) }
62
+ })
63
+
64
+ const testLogger = jest
65
+ .requireMock('@open-mercato/shared/lib/logger')
66
+ .createLogger('test') as Record<'debug' | 'info' | 'warn' | 'error', jest.Mock>
67
+
68
+
52
69
  function makeAuth(overrides: Partial<AiChatRequestContext> = {}): AiChatRequestContext {
53
70
  return {
54
71
  tenantId: 'tenant-1',
@@ -261,8 +278,9 @@ describe('resolveAttachmentParts — acceptedMediaTypes whitelist', () => {
261
278
  })
262
279
 
263
280
  expect(parts.map((part) => part.attachmentId)).toEqual(['img-1', 'pdf-1'])
264
- expect(console.warn).toHaveBeenCalledWith(
265
- expect.stringContaining('bin-1'),
281
+ expect(testLogger.warn).toHaveBeenCalledWith(
282
+ expect.any(String),
283
+ expect.objectContaining({ attachmentId: 'bin-1' }),
266
284
  )
267
285
  })
268
286
 
@@ -312,7 +330,7 @@ describe('resolveAttachmentParts — tenant / org scope enforcement', () => {
312
330
 
313
331
  expect(parts).toEqual([])
314
332
  expect(fsReadFileMock).not.toHaveBeenCalled()
315
- expect(console.warn).toHaveBeenCalledWith(expect.stringContaining('out of scope'))
333
+ expect(testLogger.warn).toHaveBeenCalledWith(expect.stringContaining('out of scope'), expect.anything())
316
334
  })
317
335
 
318
336
  it('lets super-admin callers through regardless of tenant scope', async () => {
@@ -347,7 +365,7 @@ describe('resolveAttachmentParts — tenant / org scope enforcement', () => {
347
365
  })
348
366
 
349
367
  expect(parts).toEqual([])
350
- expect(console.warn).toHaveBeenCalledWith(expect.stringContaining('not found'))
368
+ expect(testLogger.warn).toHaveBeenCalledWith(expect.stringContaining('not found'), expect.anything())
351
369
  })
352
370
 
353
371
  // Regression for #2663 — null-scoped rows used to bypass the tenant check via
@@ -372,7 +390,7 @@ describe('resolveAttachmentParts — tenant / org scope enforcement', () => {
372
390
 
373
391
  expect(parts).toEqual([])
374
392
  expect(fsReadFileMock).not.toHaveBeenCalled()
375
- expect(console.warn).toHaveBeenCalledWith(expect.stringContaining('out of scope'))
393
+ expect(testLogger.warn).toHaveBeenCalledWith(expect.stringContaining('out of scope'), expect.anything())
376
394
  })
377
395
 
378
396
  // Regression for #2663 — `tenantId='X', organizationId=null` used to be
@@ -395,7 +413,7 @@ describe('resolveAttachmentParts — tenant / org scope enforcement', () => {
395
413
  })
396
414
 
397
415
  expect(parts).toEqual([])
398
- expect(console.warn).toHaveBeenCalledWith(expect.stringContaining('out of scope'))
416
+ expect(testLogger.warn).toHaveBeenCalledWith(expect.stringContaining('out of scope'), expect.anything())
399
417
  })
400
418
 
401
419
  it('lets a tenant-wide caller (null org) read any org within its tenant', async () => {
@@ -481,7 +499,7 @@ describe('resolveAttachmentParts — unavailable service graceful skip', () => {
481
499
 
482
500
  expect(parts).toEqual([])
483
501
  expect(findOneWithDecryptionMock).not.toHaveBeenCalled()
484
- expect(console.warn).toHaveBeenCalledWith(expect.stringContaining('without a DI container'))
502
+ expect(testLogger.warn).toHaveBeenCalledWith(expect.stringContaining('without a DI container'))
485
503
  })
486
504
 
487
505
  it('returns [] without throwing when the container cannot resolve `em`', async () => {
@@ -8,6 +8,23 @@ import {
8
8
  type CreateModelFactoryDependencies,
9
9
  } from '../model-factory'
10
10
 
11
+ jest.mock('@open-mercato/shared/lib/logger', () => {
12
+ const mocked = {
13
+ debug: jest.fn(),
14
+ info: jest.fn(),
15
+ warn: jest.fn(),
16
+ error: jest.fn(),
17
+ child: jest.fn(),
18
+ }
19
+ mocked.child.mockImplementation(() => mocked)
20
+ return { createLogger: jest.fn(() => mocked) }
21
+ })
22
+
23
+ const testLogger = jest
24
+ .requireMock('@open-mercato/shared/lib/logger')
25
+ .createLogger('test') as Record<'debug' | 'info' | 'warn' | 'error', jest.Mock>
26
+
27
+
11
28
  type FakeProvider = {
12
29
  id: string
13
30
  defaultModel: string
@@ -1001,9 +1018,10 @@ describe('Phase 4a — tenantOverride, requestOverride, allowRuntimeOverride (re
1001
1018
  })
1002
1019
 
1003
1020
  describe('Phase 1780-5 — OM_AI_AVAILABLE_PROVIDERS / OM_AI_AVAILABLE_MODELS_<PROVIDER>', () => {
1004
- let warnSpy: jest.SpyInstance
1021
+ let warnSpy: jest.Mock
1005
1022
  beforeEach(() => {
1006
- warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => undefined)
1023
+ warnSpy = testLogger.warn
1024
+ warnSpy.mockClear()
1007
1025
  })
1008
1026
  afterEach(() => {
1009
1027
  warnSpy.mockRestore()
@@ -1040,7 +1058,8 @@ describe('Phase 4a — tenantOverride, requestOverride, allowRuntimeOverride (re
1040
1058
  reason: expect.stringContaining('OM_AI_AVAILABLE_MODELS_OPENAI'),
1041
1059
  })
1042
1060
  expect(warnSpy).toHaveBeenCalledWith(
1043
- expect.stringContaining('[AI Model Factory]'),
1061
+ expect.stringContaining('Allowlist'),
1062
+ expect.anything(),
1044
1063
  )
1045
1064
  })
1046
1065
 
@@ -1096,9 +1115,10 @@ describe('Phase 4a — tenantOverride, requestOverride, allowRuntimeOverride (re
1096
1115
  })
1097
1116
 
1098
1117
  describe('Phase 1780-6 — tenantAllowlist clipping', () => {
1099
- let warnSpy: jest.SpyInstance
1118
+ let warnSpy: jest.Mock
1100
1119
  beforeEach(() => {
1101
- warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => undefined)
1120
+ warnSpy = testLogger.warn
1121
+ warnSpy.mockClear()
1102
1122
  })
1103
1123
  afterEach(() => {
1104
1124
  warnSpy.mockRestore()
@@ -10,6 +10,23 @@ import type {
10
10
  } from '../../events'
11
11
  import type { AiPendingAction } from '../../data/entities'
12
12
 
13
+ jest.mock('@open-mercato/shared/lib/logger', () => {
14
+ const mocked = {
15
+ debug: jest.fn(),
16
+ info: jest.fn(),
17
+ warn: jest.fn(),
18
+ error: jest.fn(),
19
+ child: jest.fn(),
20
+ }
21
+ mocked.child.mockImplementation(() => mocked)
22
+ return { createLogger: jest.fn(() => mocked) }
23
+ })
24
+
25
+ const testLogger = jest
26
+ .requireMock('@open-mercato/shared/lib/logger')
27
+ .createLogger('test') as Record<'debug' | 'info' | 'warn' | 'error', jest.Mock>
28
+
29
+
13
30
  function makeAction(overrides: Partial<AiPendingAction> = {}): AiPendingAction {
14
31
  return {
15
32
  id: 'pa_1',
@@ -217,7 +234,8 @@ describe('executePendingActionCancel', () => {
217
234
  it('swallows emit-event errors without failing the cancel', async () => {
218
235
  const repo = makeRepoStub(makeAction())
219
236
  const emitEvent = jest.fn().mockRejectedValue(new Error('bus down'))
220
- const consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {})
237
+ const consoleWarnSpy = testLogger.warn
238
+ consoleWarnSpy.mockClear()
221
239
  const clock = new Date('2026-04-18T10:05:00.000Z')
222
240
 
223
241
  const result = await executePendingActionCancel({
@@ -47,6 +47,23 @@ import type {
47
47
  AiPendingActionQueueMode,
48
48
  } from '../pending-action-types'
49
49
 
50
+ jest.mock('@open-mercato/shared/lib/logger', () => {
51
+ const mocked = {
52
+ debug: jest.fn(),
53
+ info: jest.fn(),
54
+ warn: jest.fn(),
55
+ error: jest.fn(),
56
+ child: jest.fn(),
57
+ }
58
+ mocked.child.mockImplementation(() => mocked)
59
+ return { createLogger: jest.fn(() => mocked) }
60
+ })
61
+
62
+ const testLogger = jest
63
+ .requireMock('@open-mercato/shared/lib/logger')
64
+ .createLogger('test') as Record<'debug' | 'info' | 'warn' | 'error', jest.Mock>
65
+
66
+
50
67
  type Row = {
51
68
  id: string
52
69
  tenantId: string
@@ -378,7 +395,8 @@ describe('prepareMutation', () => {
378
395
  it('missing loadBeforeRecord: ships fieldDiff=[] + sideEffectsSummary warning + still creates the pending row', async () => {
379
396
  const em = mockEm()
380
397
  const container = makeContainer(em)
381
- const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {})
398
+ const warnSpy = testLogger.warn
399
+ warnSpy.mockClear()
382
400
  const tool = makeTool({
383
401
  name: 'catalog.products.update',
384
402
  isMutation: true,
@@ -538,12 +556,13 @@ describe('prepareMutation', () => {
538
556
  })
539
557
 
540
558
  describe('resolveAiAgentTools mutation interception (Step 5.6)', () => {
541
- let warnSpy: jest.SpyInstance
559
+ let warnSpy: jest.Mock
542
560
 
543
561
  beforeEach(() => {
544
562
  resetAgentRegistryForTests()
545
563
  toolRegistry.clear()
546
- warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {})
564
+ warnSpy = testLogger.warn
565
+ warnSpy.mockClear()
547
566
  })
548
567
 
549
568
  afterEach(() => {
@@ -1,3 +1,4 @@
1
+ import { createLogger } from '@open-mercato/shared/lib/logger'
1
2
  import { getAgent } from './agent-registry'
2
3
  import { hasRequiredFeatures } from './auth'
3
4
  import { toolRegistry } from './tool-registry'
@@ -8,6 +9,8 @@ import type {
8
9
  } from './ai-agent-definition'
9
10
  import type { AiToolDefinition } from './types'
10
11
 
12
+ const logger = createLogger('ai_assistant')
13
+
11
14
  export type AgentPolicyDenyCode =
12
15
  | 'agent_unknown'
13
16
  | 'agent_features_denied'
@@ -92,11 +95,11 @@ export function resolveEffectiveMutationPolicy(
92
95
  codeDeclared && isKnownMutationPolicy(codeDeclared) ? codeDeclared : 'read-only'
93
96
  if (override === undefined || override === null) return base
94
97
  if (!isKnownMutationPolicy(override)) {
95
- console.warn(
96
- `[AI Agents] Ignoring corrupt mutationPolicy override for agent "${agentId ?? '<unknown>'}": ${String(
97
- override,
98
- )}. Falling back to code-declared policy "${base}".`,
99
- )
98
+ logger.warn('Ignoring corrupt mutationPolicy override; falling back to code-declared policy', {
99
+ agentId: agentId ?? '<unknown>',
100
+ override: String(override),
101
+ base,
102
+ })
100
103
  return base
101
104
  }
102
105
  const baseRank = POLICY_RESTRICTIVENESS[base]
@@ -1,3 +1,4 @@
1
+ import { createLogger } from '@open-mercato/shared/lib/logger'
1
2
  import { llmProviderRegistry } from '@open-mercato/shared/lib/ai/llm-provider-registry'
2
3
  import type { AiAgentDefinition, AiAgentExtension, AiAgentSuggestion } from './ai-agent-definition'
3
4
  import {
@@ -10,6 +11,8 @@ import {
10
11
  import { TASK_PLAN_TOOL_NAME } from './task-plan-labels'
11
12
  import { findGeneratedFile, compileAndImportGenerated } from './generated-registry-loader'
12
13
 
14
+ const logger = createLogger('ai_assistant')
15
+
13
16
  const agentsById = new Map<string, AiAgentDefinition>()
14
17
  let loaded = false
15
18
 
@@ -170,11 +173,10 @@ function validateAndNormalizeAgent(candidate: AiAgentDefinition): AiAgentDefinit
170
173
  const providerHint = rawProvider.trim()
171
174
  const registered = llmProviderRegistry.get(providerHint)
172
175
  if (!registered) {
173
- console.warn(
174
- `[AI Agents] Agent "${candidate.id}" declares defaultProvider "${providerHint}" which is not registered in llmProviderRegistry. ` +
175
- `The agent will be registered with defaultProvider: undefined so the resolution chain still works. ` +
176
- `Built-in provider ids: anthropic, google, openai, deepinfra, groq, together, fireworks, azure, litellm, ollama.`,
177
- )
176
+ logger.warn('Agent declares a defaultProvider not registered in llmProviderRegistry; registering with defaultProvider undefined', {
177
+ agentId: candidate.id,
178
+ defaultProvider: providerHint,
179
+ })
178
180
  return { ...taskPlanNormalized, defaultProvider: undefined }
179
181
  }
180
182
  return taskPlanNormalized
@@ -183,7 +185,7 @@ function validateAndNormalizeAgent(candidate: AiAgentDefinition): AiAgentDefinit
183
185
  function populateFromAgents(agents: unknown[]): void {
184
186
  for (const candidate of agents) {
185
187
  if (!isAiAgentDefinition(candidate)) {
186
- console.warn('[AI Agents] Skipping malformed agent entry in ai-agents.generated.ts')
188
+ logger.warn('AI Agents — Skipping malformed agent entry in ai-agents.generated.ts')
187
189
  continue
188
190
  }
189
191
  const existing = agentsById.get(candidate.id)
@@ -218,7 +220,7 @@ function applyOverridesToRegistry(entries: readonly AiAgentOverrideConfigEntry[]
218
220
  for (const agent of overridden) agentsById.set(agent.id, agent)
219
221
  for (const [id, value] of Object.entries(overrideMap)) {
220
222
  const verb = value === null ? 'disabled' : 'replaced'
221
- console.info(`[AI Overrides] Agent "${id}" ${verb} by override.`)
223
+ logger.info('Agent changed by override', { agentId: id, change: verb })
222
224
  }
223
225
  }
224
226
 
@@ -242,9 +244,7 @@ function applyExtensionsToRegistry(extensions: readonly AiAgentExtension[]): voi
242
244
  for (const extension of extensions) {
243
245
  const agent = agentsById.get(extension.targetAgentId)
244
246
  if (!agent) {
245
- console.warn(
246
- `[AI Agents] Skipping extension for unknown agent "${extension.targetAgentId}".`,
247
- )
247
+ logger.warn('Skipping extension for unknown agent', { agentId: extension.targetAgentId })
248
248
  continue
249
249
  }
250
250
 
@@ -284,10 +284,7 @@ export async function loadAgentRegistry(): Promise<void> {
284
284
  const agents = mod && Array.isArray(mod.allAiAgents) ? mod.allAiAgents : []
285
285
  populateFromAgents(agents)
286
286
  } catch (error) {
287
- console.error(
288
- '[AI Agents] Could not load ai-agents.generated.ts (agent registry empty):',
289
- error
290
- )
287
+ logger.error('AI Agents — Could not load ai-agents.generated.ts (agent registry empty)', { err: error })
291
288
  } finally {
292
289
  try {
293
290
  const overrideEntries = await loadOverrideEntries()
@@ -295,7 +292,7 @@ export async function loadAgentRegistry(): Promise<void> {
295
292
  const extensionEntries = await loadExtensionEntries()
296
293
  applyExtensionsToRegistry(extensionEntries)
297
294
  } catch (error) {
298
- console.error('[AI Agents] Failed to apply agent overrides/extensions:', error)
295
+ logger.error('AI Agents — Failed to apply agent overrides/extensions', { err: error })
299
296
  }
300
297
  loaded = true
301
298
  }