@wingman-ai/gateway 0.5.2 → 0.5.4
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.
- package/dist/agent/config/agentConfig.cjs +4 -0
- package/dist/agent/config/agentConfig.d.ts +12 -0
- package/dist/agent/config/agentConfig.js +4 -0
- package/dist/agent/config/toolRegistry.cjs +75 -1
- package/dist/agent/config/toolRegistry.d.ts +3 -0
- package/dist/agent/config/toolRegistry.js +75 -1
- package/dist/agent/middleware/large-tool-results.cjs +207 -0
- package/dist/agent/middleware/large-tool-results.d.ts +16 -0
- package/dist/agent/middleware/large-tool-results.js +173 -0
- package/dist/agent/tools/browser_control.cjs +9 -1231
- package/dist/agent/tools/browser_control.d.ts +126 -234
- package/dist/agent/tools/browser_control.js +7 -1226
- package/dist/agent/tools/browser_runtime.cjs +1189 -0
- package/dist/agent/tools/browser_runtime.d.ts +560 -0
- package/dist/agent/tools/browser_runtime.js +1122 -0
- package/dist/agent/tools/browser_session.cjs +153 -0
- package/dist/agent/tools/browser_session.d.ts +741 -0
- package/dist/agent/tools/browser_session.js +110 -0
- package/dist/agent/tools/browser_session_manager.cjs +202 -0
- package/dist/agent/tools/browser_session_manager.d.ts +64 -0
- package/dist/agent/tools/browser_session_manager.js +165 -0
- package/dist/cli/commands/init.cjs +5 -1
- package/dist/cli/commands/init.js +5 -1
- package/dist/cli/config/loader.cjs +0 -5
- package/dist/cli/config/loader.js +0 -5
- package/dist/cli/config/schema.cjs +3 -7
- package/dist/cli/config/schema.d.ts +6 -6
- package/dist/cli/config/schema.js +3 -7
- package/dist/cli/core/agentInvoker.cjs +86 -22
- package/dist/cli/core/agentInvoker.d.ts +10 -3
- package/dist/cli/core/agentInvoker.js +86 -25
- package/dist/cli/core/outputManager.cjs +7 -2
- package/dist/cli/core/outputManager.d.ts +2 -2
- package/dist/cli/core/outputManager.js +7 -2
- package/dist/cli/types.d.ts +2 -1
- package/dist/webui/assets/index-XrEnkZiq.css +11 -0
- package/dist/webui/assets/index-mDs6HbKM.js +215 -0
- package/dist/webui/index.html +2 -2
- package/package.json +10 -10
- package/templates/agents/README.md +2 -1
- package/templates/agents/coding/agent.md +6 -13
- package/templates/agents/coding-v2/agent.md +6 -1
- package/templates/agents/game-dev/agent.md +8 -2
- package/templates/agents/game-dev/game-designer.md +4 -0
- package/templates/agents/game-dev/scene-engineer.md +4 -0
- package/templates/agents/main/agent.md +5 -0
- package/templates/agents/researcher/agent.md +11 -0
- package/templates/agents/stock-trader/agent.md +4 -0
- package/dist/agent/tests/agentConfig.test.cjs +0 -224
- package/dist/agent/tests/agentConfig.test.d.ts +0 -1
- package/dist/agent/tests/agentConfig.test.js +0 -218
- package/dist/agent/tests/agentLoader.test.cjs +0 -335
- package/dist/agent/tests/agentLoader.test.d.ts +0 -1
- package/dist/agent/tests/agentLoader.test.js +0 -329
- package/dist/agent/tests/backgroundTerminal.test.cjs +0 -70
- package/dist/agent/tests/backgroundTerminal.test.d.ts +0 -1
- package/dist/agent/tests/backgroundTerminal.test.js +0 -64
- package/dist/agent/tests/browserControlHelpers.test.cjs +0 -35
- package/dist/agent/tests/browserControlHelpers.test.d.ts +0 -1
- package/dist/agent/tests/browserControlHelpers.test.js +0 -29
- package/dist/agent/tests/browserControlTool.test.cjs +0 -2117
- package/dist/agent/tests/browserControlTool.test.d.ts +0 -1
- package/dist/agent/tests/browserControlTool.test.js +0 -2111
- package/dist/agent/tests/commandExecuteTool.test.cjs +0 -29
- package/dist/agent/tests/commandExecuteTool.test.d.ts +0 -1
- package/dist/agent/tests/commandExecuteTool.test.js +0 -23
- package/dist/agent/tests/internet_search.test.cjs +0 -107
- package/dist/agent/tests/internet_search.test.d.ts +0 -1
- package/dist/agent/tests/internet_search.test.js +0 -101
- package/dist/agent/tests/mcpClientManager.test.cjs +0 -290
- package/dist/agent/tests/mcpClientManager.test.d.ts +0 -1
- package/dist/agent/tests/mcpClientManager.test.js +0 -284
- package/dist/agent/tests/mcpResourceTools.test.cjs +0 -101
- package/dist/agent/tests/mcpResourceTools.test.d.ts +0 -1
- package/dist/agent/tests/mcpResourceTools.test.js +0 -95
- package/dist/agent/tests/modelFactory.test.cjs +0 -190
- package/dist/agent/tests/modelFactory.test.d.ts +0 -1
- package/dist/agent/tests/modelFactory.test.js +0 -184
- package/dist/agent/tests/terminalSessionManager.test.cjs +0 -121
- package/dist/agent/tests/terminalSessionManager.test.d.ts +0 -1
- package/dist/agent/tests/terminalSessionManager.test.js +0 -115
- package/dist/agent/tests/test-agent-loader.cjs +0 -33
- package/dist/agent/tests/test-agent-loader.d.ts +0 -1
- package/dist/agent/tests/test-agent-loader.js +0 -27
- package/dist/agent/tests/test-subagent-loading.cjs +0 -99
- package/dist/agent/tests/test-subagent-loading.d.ts +0 -1
- package/dist/agent/tests/test-subagent-loading.js +0 -93
- package/dist/agent/tests/toolRegistry.test.cjs +0 -147
- package/dist/agent/tests/toolRegistry.test.d.ts +0 -1
- package/dist/agent/tests/toolRegistry.test.js +0 -141
- package/dist/agent/tests/uiRegistryTools.test.cjs +0 -114
- package/dist/agent/tests/uiRegistryTools.test.d.ts +0 -1
- package/dist/agent/tests/uiRegistryTools.test.js +0 -105
- package/dist/agent/tests/xaiImageModel.test.cjs +0 -194
- package/dist/agent/tests/xaiImageModel.test.d.ts +0 -1
- package/dist/agent/tests/xaiImageModel.test.js +0 -188
- package/dist/tests/additionalMessageMiddleware.test.cjs +0 -216
- package/dist/tests/additionalMessageMiddleware.test.d.ts +0 -1
- package/dist/tests/additionalMessageMiddleware.test.js +0 -188
- package/dist/tests/agent-config-voice.test.cjs +0 -25
- package/dist/tests/agent-config-voice.test.d.ts +0 -1
- package/dist/tests/agent-config-voice.test.js +0 -19
- package/dist/tests/agentInvokerAttachments.test.cjs +0 -190
- package/dist/tests/agentInvokerAttachments.test.d.ts +0 -1
- package/dist/tests/agentInvokerAttachments.test.js +0 -184
- package/dist/tests/agentInvokerSummarization.test.cjs +0 -613
- package/dist/tests/agentInvokerSummarization.test.d.ts +0 -1
- package/dist/tests/agentInvokerSummarization.test.js +0 -607
- package/dist/tests/agentInvokerTokenUsage.test.cjs +0 -124
- package/dist/tests/agentInvokerTokenUsage.test.d.ts +0 -1
- package/dist/tests/agentInvokerTokenUsage.test.js +0 -118
- package/dist/tests/agentInvokerWorkdir.test.cjs +0 -150
- package/dist/tests/agentInvokerWorkdir.test.d.ts +0 -1
- package/dist/tests/agentInvokerWorkdir.test.js +0 -122
- package/dist/tests/agents-api.test.cjs +0 -324
- package/dist/tests/agents-api.test.d.ts +0 -1
- package/dist/tests/agents-api.test.js +0 -318
- package/dist/tests/attachments-utils.test.cjs +0 -46
- package/dist/tests/attachments-utils.test.d.ts +0 -1
- package/dist/tests/attachments-utils.test.js +0 -40
- package/dist/tests/browser-command.test.cjs +0 -264
- package/dist/tests/browser-command.test.d.ts +0 -1
- package/dist/tests/browser-command.test.js +0 -258
- package/dist/tests/browser-relay-server.test.cjs +0 -20
- package/dist/tests/browser-relay-server.test.d.ts +0 -1
- package/dist/tests/browser-relay-server.test.js +0 -14
- package/dist/tests/bunSqliteAdapter.test.cjs +0 -265
- package/dist/tests/bunSqliteAdapter.test.d.ts +0 -1
- package/dist/tests/bunSqliteAdapter.test.js +0 -259
- package/dist/tests/candleRange.test.cjs +0 -48
- package/dist/tests/candleRange.test.d.ts +0 -1
- package/dist/tests/candleRange.test.js +0 -42
- package/dist/tests/cli-config-loader.test.cjs +0 -532
- package/dist/tests/cli-config-loader.test.d.ts +0 -1
- package/dist/tests/cli-config-loader.test.js +0 -526
- package/dist/tests/cli-config-warnings.test.cjs +0 -94
- package/dist/tests/cli-config-warnings.test.d.ts +0 -1
- package/dist/tests/cli-config-warnings.test.js +0 -88
- package/dist/tests/cli-init.test.cjs +0 -225
- package/dist/tests/cli-init.test.d.ts +0 -1
- package/dist/tests/cli-init.test.js +0 -219
- package/dist/tests/cli-workspace-root.test.cjs +0 -114
- package/dist/tests/cli-workspace-root.test.d.ts +0 -1
- package/dist/tests/cli-workspace-root.test.js +0 -108
- package/dist/tests/codex-credentials-precedence.test.cjs +0 -94
- package/dist/tests/codex-credentials-precedence.test.d.ts +0 -1
- package/dist/tests/codex-credentials-precedence.test.js +0 -88
- package/dist/tests/codex-provider.test.cjs +0 -383
- package/dist/tests/codex-provider.test.d.ts +0 -1
- package/dist/tests/codex-provider.test.js +0 -377
- package/dist/tests/config-json-schema.test.cjs +0 -37
- package/dist/tests/config-json-schema.test.d.ts +0 -1
- package/dist/tests/config-json-schema.test.js +0 -31
- package/dist/tests/discord-adapter.test.cjs +0 -89
- package/dist/tests/discord-adapter.test.d.ts +0 -1
- package/dist/tests/discord-adapter.test.js +0 -83
- package/dist/tests/falRuntime.test.cjs +0 -78
- package/dist/tests/falRuntime.test.d.ts +0 -1
- package/dist/tests/falRuntime.test.js +0 -72
- package/dist/tests/falSummary.test.cjs +0 -51
- package/dist/tests/falSummary.test.d.ts +0 -1
- package/dist/tests/falSummary.test.js +0 -45
- package/dist/tests/fs-api.test.cjs +0 -138
- package/dist/tests/fs-api.test.d.ts +0 -1
- package/dist/tests/fs-api.test.js +0 -132
- package/dist/tests/gateway-command-workspace.test.cjs +0 -150
- package/dist/tests/gateway-command-workspace.test.d.ts +0 -1
- package/dist/tests/gateway-command-workspace.test.js +0 -144
- package/dist/tests/gateway-http-security.test.cjs +0 -318
- package/dist/tests/gateway-http-security.test.d.ts +0 -1
- package/dist/tests/gateway-http-security.test.js +0 -312
- package/dist/tests/gateway-node-mode.test.cjs +0 -174
- package/dist/tests/gateway-node-mode.test.d.ts +0 -1
- package/dist/tests/gateway-node-mode.test.js +0 -168
- package/dist/tests/gateway-origin-policy.test.cjs +0 -82
- package/dist/tests/gateway-origin-policy.test.d.ts +0 -1
- package/dist/tests/gateway-origin-policy.test.js +0 -76
- package/dist/tests/gateway-request-execution-overrides.test.cjs +0 -42
- package/dist/tests/gateway-request-execution-overrides.test.d.ts +0 -1
- package/dist/tests/gateway-request-execution-overrides.test.js +0 -36
- package/dist/tests/gateway.test.cjs +0 -700
- package/dist/tests/gateway.test.d.ts +0 -1
- package/dist/tests/gateway.test.js +0 -694
- package/dist/tests/hooks-matcher.test.cjs +0 -309
- package/dist/tests/hooks-matcher.test.d.ts +0 -1
- package/dist/tests/hooks-matcher.test.js +0 -303
- package/dist/tests/hooks-merger.test.cjs +0 -528
- package/dist/tests/hooks-merger.test.d.ts +0 -1
- package/dist/tests/hooks-merger.test.js +0 -522
- package/dist/tests/imagePersistence.test.cjs +0 -169
- package/dist/tests/imagePersistence.test.d.ts +0 -1
- package/dist/tests/imagePersistence.test.js +0 -163
- package/dist/tests/integration/agent-invocation.integration.test.cjs +0 -264
- package/dist/tests/integration/agent-invocation.integration.test.d.ts +0 -1
- package/dist/tests/integration/agent-invocation.integration.test.js +0 -258
- package/dist/tests/integration/finnhub-candles.integration.test.cjs +0 -98
- package/dist/tests/integration/finnhub-candles.integration.test.d.ts +0 -1
- package/dist/tests/integration/finnhub-candles.integration.test.js +0 -92
- package/dist/tests/integration/summarization-e2e.integration.test.cjs +0 -127
- package/dist/tests/integration/summarization-e2e.integration.test.d.ts +0 -1
- package/dist/tests/integration/summarization-e2e.integration.test.js +0 -121
- package/dist/tests/logger.test.cjs +0 -353
- package/dist/tests/logger.test.d.ts +0 -1
- package/dist/tests/logger.test.js +0 -347
- package/dist/tests/mediaCompatibilityMiddleware.test.cjs +0 -106
- package/dist/tests/mediaCompatibilityMiddleware.test.d.ts +0 -1
- package/dist/tests/mediaCompatibilityMiddleware.test.js +0 -100
- package/dist/tests/node-tools.test.cjs +0 -77
- package/dist/tests/node-tools.test.d.ts +0 -1
- package/dist/tests/node-tools.test.js +0 -71
- package/dist/tests/nodes-api.test.cjs +0 -86
- package/dist/tests/nodes-api.test.d.ts +0 -1
- package/dist/tests/nodes-api.test.js +0 -80
- package/dist/tests/outputManagerContextSummarized.test.cjs +0 -43
- package/dist/tests/outputManagerContextSummarized.test.d.ts +0 -1
- package/dist/tests/outputManagerContextSummarized.test.js +0 -37
- package/dist/tests/provider-command-codex.test.cjs +0 -57
- package/dist/tests/provider-command-codex.test.d.ts +0 -1
- package/dist/tests/provider-command-codex.test.js +0 -51
- package/dist/tests/routines-api.test.cjs +0 -107
- package/dist/tests/routines-api.test.d.ts +0 -1
- package/dist/tests/routines-api.test.js +0 -101
- package/dist/tests/run-terminal-bench-official-script.test.cjs +0 -61
- package/dist/tests/run-terminal-bench-official-script.test.d.ts +0 -1
- package/dist/tests/run-terminal-bench-official-script.test.js +0 -55
- package/dist/tests/sessionManager-uionly.test.cjs +0 -50
- package/dist/tests/sessionManager-uionly.test.d.ts +0 -1
- package/dist/tests/sessionManager-uionly.test.js +0 -44
- package/dist/tests/sessionMessageAttachments.test.cjs +0 -197
- package/dist/tests/sessionMessageAttachments.test.d.ts +0 -1
- package/dist/tests/sessionMessageAttachments.test.js +0 -191
- package/dist/tests/sessionMessageRole.test.cjs +0 -44
- package/dist/tests/sessionMessageRole.test.d.ts +0 -1
- package/dist/tests/sessionMessageRole.test.js +0 -38
- package/dist/tests/sessionStateMessages.test.cjs +0 -236
- package/dist/tests/sessionStateMessages.test.d.ts +0 -1
- package/dist/tests/sessionStateMessages.test.js +0 -230
- package/dist/tests/sessions-api.test.cjs +0 -250
- package/dist/tests/sessions-api.test.d.ts +0 -1
- package/dist/tests/sessions-api.test.js +0 -244
- package/dist/tests/skill-activation.test.cjs +0 -86
- package/dist/tests/skill-activation.test.d.ts +0 -1
- package/dist/tests/skill-activation.test.js +0 -80
- package/dist/tests/skill-metadata.test.cjs +0 -119
- package/dist/tests/skill-metadata.test.d.ts +0 -1
- package/dist/tests/skill-metadata.test.js +0 -113
- package/dist/tests/skill-repository.test.cjs +0 -469
- package/dist/tests/skill-repository.test.d.ts +0 -1
- package/dist/tests/skill-repository.test.js +0 -463
- package/dist/tests/skill-security-scanner.test.cjs +0 -126
- package/dist/tests/skill-security-scanner.test.d.ts +0 -1
- package/dist/tests/skill-security-scanner.test.js +0 -120
- package/dist/tests/sms-api.test.cjs +0 -183
- package/dist/tests/sms-api.test.d.ts +0 -1
- package/dist/tests/sms-api.test.js +0 -177
- package/dist/tests/sms-commands.test.cjs +0 -90
- package/dist/tests/sms-commands.test.d.ts +0 -1
- package/dist/tests/sms-commands.test.js +0 -84
- package/dist/tests/sms-policy-store.test.cjs +0 -69
- package/dist/tests/sms-policy-store.test.d.ts +0 -1
- package/dist/tests/sms-policy-store.test.js +0 -63
- package/dist/tests/teams-adapter.test.cjs +0 -58
- package/dist/tests/teams-adapter.test.d.ts +0 -1
- package/dist/tests/teams-adapter.test.js +0 -52
- package/dist/tests/technicalIndicators.test.cjs +0 -82
- package/dist/tests/technicalIndicators.test.d.ts +0 -1
- package/dist/tests/technicalIndicators.test.js +0 -76
- package/dist/tests/terminal-bench-adapters-helpers.test.cjs +0 -64
- package/dist/tests/terminal-bench-adapters-helpers.test.d.ts +0 -1
- package/dist/tests/terminal-bench-adapters-helpers.test.js +0 -58
- package/dist/tests/terminal-bench-cleanup.test.cjs +0 -93
- package/dist/tests/terminal-bench-cleanup.test.d.ts +0 -1
- package/dist/tests/terminal-bench-cleanup.test.js +0 -87
- package/dist/tests/terminal-bench-config.test.cjs +0 -62
- package/dist/tests/terminal-bench-config.test.d.ts +0 -1
- package/dist/tests/terminal-bench-config.test.js +0 -56
- package/dist/tests/terminal-bench-official.test.cjs +0 -194
- package/dist/tests/terminal-bench-official.test.d.ts +0 -1
- package/dist/tests/terminal-bench-official.test.js +0 -188
- package/dist/tests/terminal-bench-runner.test.cjs +0 -82
- package/dist/tests/terminal-bench-runner.test.d.ts +0 -1
- package/dist/tests/terminal-bench-runner.test.js +0 -76
- package/dist/tests/terminal-bench-scoring.test.cjs +0 -128
- package/dist/tests/terminal-bench-scoring.test.d.ts +0 -1
- package/dist/tests/terminal-bench-scoring.test.js +0 -122
- package/dist/tests/terminalProbe.test.cjs +0 -45
- package/dist/tests/terminalProbe.test.d.ts +0 -1
- package/dist/tests/terminalProbe.test.js +0 -39
- package/dist/tests/terminalProbeAuth.test.cjs +0 -85
- package/dist/tests/terminalProbeAuth.test.d.ts +0 -1
- package/dist/tests/terminalProbeAuth.test.js +0 -79
- package/dist/tests/toolDisplayHelpers.test.cjs +0 -46
- package/dist/tests/toolDisplayHelpers.test.d.ts +0 -1
- package/dist/tests/toolDisplayHelpers.test.js +0 -40
- package/dist/tests/uv.test.cjs +0 -47
- package/dist/tests/uv.test.d.ts +0 -1
- package/dist/tests/uv.test.js +0 -41
- package/dist/tests/voice-config.test.cjs +0 -35
- package/dist/tests/voice-config.test.d.ts +0 -1
- package/dist/tests/voice-config.test.js +0 -29
- package/dist/tests/websocket-transport.test.cjs +0 -31
- package/dist/tests/websocket-transport.test.d.ts +0 -1
- package/dist/tests/websocket-transport.test.js +0 -25
- package/dist/tests/yahooCandles.test.cjs +0 -111
- package/dist/tests/yahooCandles.test.d.ts +0 -1
- package/dist/tests/yahooCandles.test.js +0 -105
- package/dist/tools/finance/optionsAnalytics.test.cjs +0 -128
- package/dist/tools/finance/optionsAnalytics.test.d.ts +0 -1
- package/dist/tools/finance/optionsAnalytics.test.js +0 -122
- package/dist/webui/assets/index-D07GBGp0.js +0 -215
- package/dist/webui/assets/index-DV8IYeOw.css +0 -11
|
@@ -1,522 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { mergeHooks } from "../agent/middleware/hooks/merger.js";
|
|
3
|
-
describe("Hooks Configuration Merger", ()=>{
|
|
4
|
-
const mockHook1 = {
|
|
5
|
-
type: "command",
|
|
6
|
-
command: "echo 'global'",
|
|
7
|
-
timeout: 30
|
|
8
|
-
};
|
|
9
|
-
const mockHook2 = {
|
|
10
|
-
type: "command",
|
|
11
|
-
command: "echo 'agent'",
|
|
12
|
-
timeout: 60
|
|
13
|
-
};
|
|
14
|
-
const mockHook3 = {
|
|
15
|
-
type: "command",
|
|
16
|
-
command: "echo 'extra'"
|
|
17
|
-
};
|
|
18
|
-
describe("Empty configurations", ()=>{
|
|
19
|
-
it("should return undefined when both are undefined", ()=>{
|
|
20
|
-
const result = mergeHooks(void 0, void 0);
|
|
21
|
-
expect(result).toBeUndefined();
|
|
22
|
-
});
|
|
23
|
-
it("should return global hooks when agent hooks is undefined", ()=>{
|
|
24
|
-
const globalHooks = {
|
|
25
|
-
PreToolUse: [
|
|
26
|
-
{
|
|
27
|
-
matcher: "*",
|
|
28
|
-
hooks: [
|
|
29
|
-
mockHook1
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
};
|
|
34
|
-
const result = mergeHooks(globalHooks, void 0);
|
|
35
|
-
expect(result).toBe(globalHooks);
|
|
36
|
-
});
|
|
37
|
-
it("should return agent hooks when global hooks is undefined", ()=>{
|
|
38
|
-
const agentHooks = {
|
|
39
|
-
PreToolUse: [
|
|
40
|
-
{
|
|
41
|
-
matcher: "*",
|
|
42
|
-
hooks: [
|
|
43
|
-
mockHook1
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
};
|
|
48
|
-
const result = mergeHooks(void 0, agentHooks);
|
|
49
|
-
expect(result).toBe(agentHooks);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
describe("PreToolUse hooks merging", ()=>{
|
|
53
|
-
it("should merge PreToolUse hooks from both configs", ()=>{
|
|
54
|
-
const globalHooks = {
|
|
55
|
-
PreToolUse: [
|
|
56
|
-
{
|
|
57
|
-
matcher: "*",
|
|
58
|
-
hooks: [
|
|
59
|
-
mockHook1
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
};
|
|
64
|
-
const agentHooks = {
|
|
65
|
-
PreToolUse: [
|
|
66
|
-
{
|
|
67
|
-
matcher: "write_file",
|
|
68
|
-
hooks: [
|
|
69
|
-
mockHook2
|
|
70
|
-
]
|
|
71
|
-
}
|
|
72
|
-
]
|
|
73
|
-
};
|
|
74
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
75
|
-
expect(result?.PreToolUse).toHaveLength(2);
|
|
76
|
-
expect(result?.PreToolUse?.[0]).toBe(globalHooks.PreToolUse?.[0]);
|
|
77
|
-
expect(result?.PreToolUse?.[1]).toBe(agentHooks.PreToolUse?.[0]);
|
|
78
|
-
});
|
|
79
|
-
it("should include PreToolUse hooks from global only", ()=>{
|
|
80
|
-
const globalHooks = {
|
|
81
|
-
PreToolUse: [
|
|
82
|
-
{
|
|
83
|
-
matcher: "*",
|
|
84
|
-
hooks: [
|
|
85
|
-
mockHook1
|
|
86
|
-
]
|
|
87
|
-
}
|
|
88
|
-
]
|
|
89
|
-
};
|
|
90
|
-
const agentHooks = {};
|
|
91
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
92
|
-
expect(result?.PreToolUse).toHaveLength(1);
|
|
93
|
-
expect(result?.PreToolUse?.[0]).toBe(globalHooks.PreToolUse?.[0]);
|
|
94
|
-
});
|
|
95
|
-
it("should include PreToolUse hooks from agent only", ()=>{
|
|
96
|
-
const globalHooks = {};
|
|
97
|
-
const agentHooks = {
|
|
98
|
-
PreToolUse: [
|
|
99
|
-
{
|
|
100
|
-
matcher: "write_file",
|
|
101
|
-
hooks: [
|
|
102
|
-
mockHook2
|
|
103
|
-
]
|
|
104
|
-
}
|
|
105
|
-
]
|
|
106
|
-
};
|
|
107
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
108
|
-
expect(result?.PreToolUse).toHaveLength(1);
|
|
109
|
-
expect(result?.PreToolUse?.[0]).toBe(agentHooks.PreToolUse?.[0]);
|
|
110
|
-
});
|
|
111
|
-
it("should preserve order: global hooks first, then agent hooks", ()=>{
|
|
112
|
-
const globalMatcher = {
|
|
113
|
-
matcher: "*",
|
|
114
|
-
hooks: [
|
|
115
|
-
mockHook1
|
|
116
|
-
]
|
|
117
|
-
};
|
|
118
|
-
const agentMatcher = {
|
|
119
|
-
matcher: "write_file",
|
|
120
|
-
hooks: [
|
|
121
|
-
mockHook2
|
|
122
|
-
]
|
|
123
|
-
};
|
|
124
|
-
const globalHooks = {
|
|
125
|
-
PreToolUse: [
|
|
126
|
-
globalMatcher
|
|
127
|
-
]
|
|
128
|
-
};
|
|
129
|
-
const agentHooks = {
|
|
130
|
-
PreToolUse: [
|
|
131
|
-
agentMatcher
|
|
132
|
-
]
|
|
133
|
-
};
|
|
134
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
135
|
-
expect(result?.PreToolUse?.[0]).toBe(globalMatcher);
|
|
136
|
-
expect(result?.PreToolUse?.[1]).toBe(agentMatcher);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
describe("PostToolUse hooks merging", ()=>{
|
|
140
|
-
it("should merge PostToolUse hooks from both configs", ()=>{
|
|
141
|
-
const globalHooks = {
|
|
142
|
-
PostToolUse: [
|
|
143
|
-
{
|
|
144
|
-
matcher: "*",
|
|
145
|
-
hooks: [
|
|
146
|
-
mockHook1
|
|
147
|
-
]
|
|
148
|
-
}
|
|
149
|
-
]
|
|
150
|
-
};
|
|
151
|
-
const agentHooks = {
|
|
152
|
-
PostToolUse: [
|
|
153
|
-
{
|
|
154
|
-
matcher: "write_file",
|
|
155
|
-
hooks: [
|
|
156
|
-
mockHook2
|
|
157
|
-
]
|
|
158
|
-
}
|
|
159
|
-
]
|
|
160
|
-
};
|
|
161
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
162
|
-
expect(result?.PostToolUse).toHaveLength(2);
|
|
163
|
-
expect(result?.PostToolUse?.[0]).toBe(globalHooks.PostToolUse?.[0]);
|
|
164
|
-
expect(result?.PostToolUse?.[1]).toBe(agentHooks.PostToolUse?.[0]);
|
|
165
|
-
});
|
|
166
|
-
it("should include PostToolUse hooks from global only", ()=>{
|
|
167
|
-
const globalHooks = {
|
|
168
|
-
PostToolUse: [
|
|
169
|
-
{
|
|
170
|
-
matcher: "*",
|
|
171
|
-
hooks: [
|
|
172
|
-
mockHook1
|
|
173
|
-
]
|
|
174
|
-
}
|
|
175
|
-
]
|
|
176
|
-
};
|
|
177
|
-
const agentHooks = {};
|
|
178
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
179
|
-
expect(result?.PostToolUse).toHaveLength(1);
|
|
180
|
-
expect(result?.PostToolUse?.[0]).toBe(globalHooks.PostToolUse?.[0]);
|
|
181
|
-
});
|
|
182
|
-
it("should include PostToolUse hooks from agent only", ()=>{
|
|
183
|
-
const globalHooks = {};
|
|
184
|
-
const agentHooks = {
|
|
185
|
-
PostToolUse: [
|
|
186
|
-
{
|
|
187
|
-
matcher: "write_file",
|
|
188
|
-
hooks: [
|
|
189
|
-
mockHook2
|
|
190
|
-
]
|
|
191
|
-
}
|
|
192
|
-
]
|
|
193
|
-
};
|
|
194
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
195
|
-
expect(result?.PostToolUse).toHaveLength(1);
|
|
196
|
-
expect(result?.PostToolUse?.[0]).toBe(agentHooks.PostToolUse?.[0]);
|
|
197
|
-
});
|
|
198
|
-
it("should preserve order: global hooks first, then agent hooks", ()=>{
|
|
199
|
-
const globalMatcher = {
|
|
200
|
-
matcher: "*",
|
|
201
|
-
hooks: [
|
|
202
|
-
mockHook1
|
|
203
|
-
]
|
|
204
|
-
};
|
|
205
|
-
const agentMatcher = {
|
|
206
|
-
matcher: "write_file",
|
|
207
|
-
hooks: [
|
|
208
|
-
mockHook2
|
|
209
|
-
]
|
|
210
|
-
};
|
|
211
|
-
const globalHooks = {
|
|
212
|
-
PostToolUse: [
|
|
213
|
-
globalMatcher
|
|
214
|
-
]
|
|
215
|
-
};
|
|
216
|
-
const agentHooks = {
|
|
217
|
-
PostToolUse: [
|
|
218
|
-
agentMatcher
|
|
219
|
-
]
|
|
220
|
-
};
|
|
221
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
222
|
-
expect(result?.PostToolUse?.[0]).toBe(globalMatcher);
|
|
223
|
-
expect(result?.PostToolUse?.[1]).toBe(agentMatcher);
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
describe("Stop hooks merging", ()=>{
|
|
227
|
-
it("should merge Stop hooks from both configs", ()=>{
|
|
228
|
-
const globalHooks = {
|
|
229
|
-
Stop: [
|
|
230
|
-
{
|
|
231
|
-
hooks: [
|
|
232
|
-
mockHook1
|
|
233
|
-
]
|
|
234
|
-
}
|
|
235
|
-
]
|
|
236
|
-
};
|
|
237
|
-
const agentHooks = {
|
|
238
|
-
Stop: [
|
|
239
|
-
{
|
|
240
|
-
hooks: [
|
|
241
|
-
mockHook2
|
|
242
|
-
]
|
|
243
|
-
}
|
|
244
|
-
]
|
|
245
|
-
};
|
|
246
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
247
|
-
expect(result?.Stop).toHaveLength(2);
|
|
248
|
-
expect(result?.Stop?.[0]).toBe(globalHooks.Stop?.[0]);
|
|
249
|
-
expect(result?.Stop?.[1]).toBe(agentHooks.Stop?.[0]);
|
|
250
|
-
});
|
|
251
|
-
it("should include Stop hooks from global only", ()=>{
|
|
252
|
-
const globalHooks = {
|
|
253
|
-
Stop: [
|
|
254
|
-
{
|
|
255
|
-
hooks: [
|
|
256
|
-
mockHook1
|
|
257
|
-
]
|
|
258
|
-
}
|
|
259
|
-
]
|
|
260
|
-
};
|
|
261
|
-
const agentHooks = {};
|
|
262
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
263
|
-
expect(result?.Stop).toHaveLength(1);
|
|
264
|
-
expect(result?.Stop?.[0]).toBe(globalHooks.Stop?.[0]);
|
|
265
|
-
});
|
|
266
|
-
it("should include Stop hooks from agent only", ()=>{
|
|
267
|
-
const globalHooks = {};
|
|
268
|
-
const agentHooks = {
|
|
269
|
-
Stop: [
|
|
270
|
-
{
|
|
271
|
-
hooks: [
|
|
272
|
-
mockHook2
|
|
273
|
-
]
|
|
274
|
-
}
|
|
275
|
-
]
|
|
276
|
-
};
|
|
277
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
278
|
-
expect(result?.Stop).toHaveLength(1);
|
|
279
|
-
expect(result?.Stop?.[0]).toBe(agentHooks.Stop?.[0]);
|
|
280
|
-
});
|
|
281
|
-
it("should preserve order: global hooks first, then agent hooks", ()=>{
|
|
282
|
-
const globalStop = {
|
|
283
|
-
hooks: [
|
|
284
|
-
mockHook1
|
|
285
|
-
]
|
|
286
|
-
};
|
|
287
|
-
const agentStop = {
|
|
288
|
-
hooks: [
|
|
289
|
-
mockHook2
|
|
290
|
-
]
|
|
291
|
-
};
|
|
292
|
-
const globalHooks = {
|
|
293
|
-
Stop: [
|
|
294
|
-
globalStop
|
|
295
|
-
]
|
|
296
|
-
};
|
|
297
|
-
const agentHooks = {
|
|
298
|
-
Stop: [
|
|
299
|
-
agentStop
|
|
300
|
-
]
|
|
301
|
-
};
|
|
302
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
303
|
-
expect(result?.Stop?.[0]).toBe(globalStop);
|
|
304
|
-
expect(result?.Stop?.[1]).toBe(agentStop);
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
describe("Multi-event merging", ()=>{
|
|
308
|
-
it("should merge all hook types when both have all types", ()=>{
|
|
309
|
-
const globalHooks = {
|
|
310
|
-
PreToolUse: [
|
|
311
|
-
{
|
|
312
|
-
matcher: "*",
|
|
313
|
-
hooks: [
|
|
314
|
-
mockHook1
|
|
315
|
-
]
|
|
316
|
-
}
|
|
317
|
-
],
|
|
318
|
-
PostToolUse: [
|
|
319
|
-
{
|
|
320
|
-
matcher: "*",
|
|
321
|
-
hooks: [
|
|
322
|
-
mockHook1
|
|
323
|
-
]
|
|
324
|
-
}
|
|
325
|
-
],
|
|
326
|
-
Stop: [
|
|
327
|
-
{
|
|
328
|
-
hooks: [
|
|
329
|
-
mockHook1
|
|
330
|
-
]
|
|
331
|
-
}
|
|
332
|
-
]
|
|
333
|
-
};
|
|
334
|
-
const agentHooks = {
|
|
335
|
-
PreToolUse: [
|
|
336
|
-
{
|
|
337
|
-
matcher: "write_file",
|
|
338
|
-
hooks: [
|
|
339
|
-
mockHook2
|
|
340
|
-
]
|
|
341
|
-
}
|
|
342
|
-
],
|
|
343
|
-
PostToolUse: [
|
|
344
|
-
{
|
|
345
|
-
matcher: "write_file",
|
|
346
|
-
hooks: [
|
|
347
|
-
mockHook2
|
|
348
|
-
]
|
|
349
|
-
}
|
|
350
|
-
],
|
|
351
|
-
Stop: [
|
|
352
|
-
{
|
|
353
|
-
hooks: [
|
|
354
|
-
mockHook2
|
|
355
|
-
]
|
|
356
|
-
}
|
|
357
|
-
]
|
|
358
|
-
};
|
|
359
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
360
|
-
expect(result?.PreToolUse).toHaveLength(2);
|
|
361
|
-
expect(result?.PostToolUse).toHaveLength(2);
|
|
362
|
-
expect(result?.Stop).toHaveLength(2);
|
|
363
|
-
});
|
|
364
|
-
it("should merge only the hook types that are defined", ()=>{
|
|
365
|
-
const globalHooks = {
|
|
366
|
-
PreToolUse: [
|
|
367
|
-
{
|
|
368
|
-
matcher: "*",
|
|
369
|
-
hooks: [
|
|
370
|
-
mockHook1
|
|
371
|
-
]
|
|
372
|
-
}
|
|
373
|
-
]
|
|
374
|
-
};
|
|
375
|
-
const agentHooks = {
|
|
376
|
-
PostToolUse: [
|
|
377
|
-
{
|
|
378
|
-
matcher: "write_file",
|
|
379
|
-
hooks: [
|
|
380
|
-
mockHook2
|
|
381
|
-
]
|
|
382
|
-
}
|
|
383
|
-
],
|
|
384
|
-
Stop: [
|
|
385
|
-
{
|
|
386
|
-
hooks: [
|
|
387
|
-
mockHook3
|
|
388
|
-
]
|
|
389
|
-
}
|
|
390
|
-
]
|
|
391
|
-
};
|
|
392
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
393
|
-
expect(result?.PreToolUse).toHaveLength(1);
|
|
394
|
-
expect(result?.PostToolUse).toHaveLength(1);
|
|
395
|
-
expect(result?.Stop).toHaveLength(1);
|
|
396
|
-
});
|
|
397
|
-
it("should handle complex multi-matcher scenario", ()=>{
|
|
398
|
-
const globalHooks = {
|
|
399
|
-
PreToolUse: [
|
|
400
|
-
{
|
|
401
|
-
matcher: "*",
|
|
402
|
-
hooks: [
|
|
403
|
-
mockHook1
|
|
404
|
-
]
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
matcher: ".*_file",
|
|
408
|
-
hooks: [
|
|
409
|
-
mockHook2
|
|
410
|
-
]
|
|
411
|
-
}
|
|
412
|
-
],
|
|
413
|
-
PostToolUse: [
|
|
414
|
-
{
|
|
415
|
-
matcher: "write_file|read_file",
|
|
416
|
-
hooks: [
|
|
417
|
-
mockHook1
|
|
418
|
-
]
|
|
419
|
-
}
|
|
420
|
-
]
|
|
421
|
-
};
|
|
422
|
-
const agentHooks = {
|
|
423
|
-
PreToolUse: [
|
|
424
|
-
{
|
|
425
|
-
matcher: "write_file",
|
|
426
|
-
hooks: [
|
|
427
|
-
mockHook3
|
|
428
|
-
]
|
|
429
|
-
}
|
|
430
|
-
],
|
|
431
|
-
Stop: [
|
|
432
|
-
{
|
|
433
|
-
hooks: [
|
|
434
|
-
mockHook2,
|
|
435
|
-
mockHook3
|
|
436
|
-
]
|
|
437
|
-
}
|
|
438
|
-
]
|
|
439
|
-
};
|
|
440
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
441
|
-
expect(result?.PreToolUse).toHaveLength(3);
|
|
442
|
-
expect(result?.PostToolUse).toHaveLength(1);
|
|
443
|
-
expect(result?.Stop).toHaveLength(1);
|
|
444
|
-
});
|
|
445
|
-
});
|
|
446
|
-
describe("No duplication handling", ()=>{
|
|
447
|
-
it("should not deduplicate identical hooks", ()=>{
|
|
448
|
-
const sharedHook = {
|
|
449
|
-
type: "command",
|
|
450
|
-
command: "echo 'shared'"
|
|
451
|
-
};
|
|
452
|
-
const globalHooks = {
|
|
453
|
-
PreToolUse: [
|
|
454
|
-
{
|
|
455
|
-
matcher: "*",
|
|
456
|
-
hooks: [
|
|
457
|
-
sharedHook
|
|
458
|
-
]
|
|
459
|
-
}
|
|
460
|
-
]
|
|
461
|
-
};
|
|
462
|
-
const agentHooks = {
|
|
463
|
-
PreToolUse: [
|
|
464
|
-
{
|
|
465
|
-
matcher: "*",
|
|
466
|
-
hooks: [
|
|
467
|
-
sharedHook
|
|
468
|
-
]
|
|
469
|
-
}
|
|
470
|
-
]
|
|
471
|
-
};
|
|
472
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
473
|
-
expect(result?.PreToolUse).toHaveLength(2);
|
|
474
|
-
});
|
|
475
|
-
});
|
|
476
|
-
describe("Empty arrays", ()=>{
|
|
477
|
-
it("should handle empty hook arrays in global config", ()=>{
|
|
478
|
-
const globalHooks = {
|
|
479
|
-
PreToolUse: []
|
|
480
|
-
};
|
|
481
|
-
const agentHooks = {
|
|
482
|
-
PreToolUse: [
|
|
483
|
-
{
|
|
484
|
-
matcher: "*",
|
|
485
|
-
hooks: [
|
|
486
|
-
mockHook1
|
|
487
|
-
]
|
|
488
|
-
}
|
|
489
|
-
]
|
|
490
|
-
};
|
|
491
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
492
|
-
expect(result?.PreToolUse).toHaveLength(1);
|
|
493
|
-
});
|
|
494
|
-
it("should handle empty hook arrays in agent config", ()=>{
|
|
495
|
-
const globalHooks = {
|
|
496
|
-
PreToolUse: [
|
|
497
|
-
{
|
|
498
|
-
matcher: "*",
|
|
499
|
-
hooks: [
|
|
500
|
-
mockHook1
|
|
501
|
-
]
|
|
502
|
-
}
|
|
503
|
-
]
|
|
504
|
-
};
|
|
505
|
-
const agentHooks = {
|
|
506
|
-
PreToolUse: []
|
|
507
|
-
};
|
|
508
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
509
|
-
expect(result?.PreToolUse).toHaveLength(1);
|
|
510
|
-
});
|
|
511
|
-
it("should handle both having empty arrays", ()=>{
|
|
512
|
-
const globalHooks = {
|
|
513
|
-
PreToolUse: []
|
|
514
|
-
};
|
|
515
|
-
const agentHooks = {
|
|
516
|
-
PreToolUse: []
|
|
517
|
-
};
|
|
518
|
-
const result = mergeHooks(globalHooks, agentHooks);
|
|
519
|
-
expect(result?.PreToolUse).toHaveLength(0);
|
|
520
|
-
});
|
|
521
|
-
});
|
|
522
|
-
});
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_exports__ = {};
|
|
3
|
-
const external_node_fs_namespaceObject = require("node:fs");
|
|
4
|
-
const external_node_os_namespaceObject = require("node:os");
|
|
5
|
-
const external_node_path_namespaceObject = require("node:path");
|
|
6
|
-
const external_vitest_namespaceObject = require("vitest");
|
|
7
|
-
const imagePersistence_cjs_namespaceObject = require("../cli/core/imagePersistence.cjs");
|
|
8
|
-
const PNG_DATA_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO3X6S0AAAAASUVORK5CYII=";
|
|
9
|
-
(0, external_vitest_namespaceObject.describe)("imagePersistence", ()=>{
|
|
10
|
-
const tempDirs = [];
|
|
11
|
-
(0, external_vitest_namespaceObject.afterEach)(()=>{
|
|
12
|
-
for (const dir of tempDirs)(0, external_node_fs_namespaceObject.rmSync)(dir, {
|
|
13
|
-
recursive: true,
|
|
14
|
-
force: true
|
|
15
|
-
});
|
|
16
|
-
tempDirs.length = 0;
|
|
17
|
-
});
|
|
18
|
-
(0, external_vitest_namespaceObject.it)("persists assistant image data URLs to disk", ()=>{
|
|
19
|
-
const tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-image-store-"));
|
|
20
|
-
tempDirs.push(tempDir);
|
|
21
|
-
const dbPath = (0, external_node_path_namespaceObject.join)(tempDir, "wingman.db");
|
|
22
|
-
const messages = [
|
|
23
|
-
{
|
|
24
|
-
role: "assistant",
|
|
25
|
-
attachments: [
|
|
26
|
-
{
|
|
27
|
-
kind: "image",
|
|
28
|
-
dataUrl: PNG_DATA_URL
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
];
|
|
33
|
-
(0, imagePersistence_cjs_namespaceObject.persistAssistantImagesToDisk)({
|
|
34
|
-
dbPath,
|
|
35
|
-
sessionId: "session-123",
|
|
36
|
-
messages
|
|
37
|
-
});
|
|
38
|
-
const attachment = messages[0].attachments?.[0];
|
|
39
|
-
(0, external_vitest_namespaceObject.expect)(typeof attachment?.path).toBe("string");
|
|
40
|
-
(0, external_vitest_namespaceObject.expect)(attachment?.mimeType).toBe("image/png");
|
|
41
|
-
(0, external_vitest_namespaceObject.expect)(typeof attachment?.size).toBe("number");
|
|
42
|
-
(0, external_vitest_namespaceObject.expect)(attachment?.size).toBeGreaterThan(0);
|
|
43
|
-
(0, external_vitest_namespaceObject.expect)((0, external_node_fs_namespaceObject.existsSync)(attachment.path)).toBe(true);
|
|
44
|
-
(0, external_vitest_namespaceObject.expect)((0, external_node_fs_namespaceObject.readFileSync)(attachment.path).length).toBe(attachment?.size);
|
|
45
|
-
});
|
|
46
|
-
(0, external_vitest_namespaceObject.it)("does not persist non-assistant images", ()=>{
|
|
47
|
-
const tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-image-store-"));
|
|
48
|
-
tempDirs.push(tempDir);
|
|
49
|
-
const dbPath = (0, external_node_path_namespaceObject.join)(tempDir, "wingman.db");
|
|
50
|
-
const messages = [
|
|
51
|
-
{
|
|
52
|
-
role: "user",
|
|
53
|
-
attachments: [
|
|
54
|
-
{
|
|
55
|
-
kind: "image",
|
|
56
|
-
dataUrl: PNG_DATA_URL
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
];
|
|
61
|
-
(0, imagePersistence_cjs_namespaceObject.persistAssistantImagesToDisk)({
|
|
62
|
-
dbPath,
|
|
63
|
-
sessionId: "session-123",
|
|
64
|
-
messages
|
|
65
|
-
});
|
|
66
|
-
(0, external_vitest_namespaceObject.expect)(messages[0].attachments?.[0].path).toBeUndefined();
|
|
67
|
-
});
|
|
68
|
-
(0, external_vitest_namespaceObject.it)("keeps remote image URLs untouched", ()=>{
|
|
69
|
-
const tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-image-store-"));
|
|
70
|
-
tempDirs.push(tempDir);
|
|
71
|
-
const dbPath = (0, external_node_path_namespaceObject.join)(tempDir, "wingman.db");
|
|
72
|
-
const messages = [
|
|
73
|
-
{
|
|
74
|
-
role: "assistant",
|
|
75
|
-
attachments: [
|
|
76
|
-
{
|
|
77
|
-
kind: "image",
|
|
78
|
-
dataUrl: "https://example.com/image.png"
|
|
79
|
-
}
|
|
80
|
-
]
|
|
81
|
-
}
|
|
82
|
-
];
|
|
83
|
-
(0, imagePersistence_cjs_namespaceObject.persistAssistantImagesToDisk)({
|
|
84
|
-
dbPath,
|
|
85
|
-
sessionId: "session-123",
|
|
86
|
-
messages
|
|
87
|
-
});
|
|
88
|
-
(0, external_vitest_namespaceObject.expect)(messages[0].attachments?.[0].path).toBeUndefined();
|
|
89
|
-
});
|
|
90
|
-
(0, external_vitest_namespaceObject.it)("derives deterministic file paths for repeated image payloads", ()=>{
|
|
91
|
-
const tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-image-store-"));
|
|
92
|
-
tempDirs.push(tempDir);
|
|
93
|
-
const dbPath = (0, external_node_path_namespaceObject.join)(tempDir, "wingman.db");
|
|
94
|
-
const messages = [
|
|
95
|
-
{
|
|
96
|
-
role: "assistant",
|
|
97
|
-
attachments: [
|
|
98
|
-
{
|
|
99
|
-
kind: "image",
|
|
100
|
-
dataUrl: PNG_DATA_URL
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
}
|
|
104
|
-
];
|
|
105
|
-
(0, imagePersistence_cjs_namespaceObject.persistAssistantImagesToDisk)({
|
|
106
|
-
dbPath,
|
|
107
|
-
sessionId: "session-123",
|
|
108
|
-
messages
|
|
109
|
-
});
|
|
110
|
-
const firstPath = messages[0].attachments?.[0].path;
|
|
111
|
-
const nextMessages = [
|
|
112
|
-
{
|
|
113
|
-
role: "assistant",
|
|
114
|
-
attachments: [
|
|
115
|
-
{
|
|
116
|
-
kind: "image",
|
|
117
|
-
dataUrl: PNG_DATA_URL
|
|
118
|
-
}
|
|
119
|
-
]
|
|
120
|
-
}
|
|
121
|
-
];
|
|
122
|
-
(0, imagePersistence_cjs_namespaceObject.persistAssistantImagesToDisk)({
|
|
123
|
-
dbPath,
|
|
124
|
-
sessionId: "session-123",
|
|
125
|
-
messages: nextMessages
|
|
126
|
-
});
|
|
127
|
-
const secondPath = nextMessages[0].attachments?.[0].path;
|
|
128
|
-
(0, external_vitest_namespaceObject.expect)(firstPath).toBeTruthy();
|
|
129
|
-
(0, external_vitest_namespaceObject.expect)(secondPath).toBe(firstPath);
|
|
130
|
-
});
|
|
131
|
-
(0, external_vitest_namespaceObject.it)("removes persisted session media directory", ()=>{
|
|
132
|
-
const tempDir = (0, external_node_fs_namespaceObject.mkdtempSync)((0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), "wingman-image-store-"));
|
|
133
|
-
tempDirs.push(tempDir);
|
|
134
|
-
const dbPath = (0, external_node_path_namespaceObject.join)(tempDir, "wingman.db");
|
|
135
|
-
const sessionId = "session-cleanup";
|
|
136
|
-
const messages = [
|
|
137
|
-
{
|
|
138
|
-
role: "assistant",
|
|
139
|
-
attachments: [
|
|
140
|
-
{
|
|
141
|
-
kind: "image",
|
|
142
|
-
dataUrl: PNG_DATA_URL
|
|
143
|
-
}
|
|
144
|
-
]
|
|
145
|
-
}
|
|
146
|
-
];
|
|
147
|
-
(0, imagePersistence_cjs_namespaceObject.persistAssistantImagesToDisk)({
|
|
148
|
-
dbPath,
|
|
149
|
-
sessionId,
|
|
150
|
-
messages
|
|
151
|
-
});
|
|
152
|
-
const mediaDir = (0, imagePersistence_cjs_namespaceObject.getSessionMediaDirectory)(dbPath, sessionId);
|
|
153
|
-
(0, external_vitest_namespaceObject.expect)((0, external_node_fs_namespaceObject.existsSync)(mediaDir)).toBe(true);
|
|
154
|
-
(0, imagePersistence_cjs_namespaceObject.removeSessionMediaDirectory)(dbPath, sessionId);
|
|
155
|
-
(0, external_vitest_namespaceObject.expect)((0, external_node_fs_namespaceObject.existsSync)(mediaDir)).toBe(false);
|
|
156
|
-
});
|
|
157
|
-
(0, external_vitest_namespaceObject.it)("parses base64 data URLs and resolves extensions", ()=>{
|
|
158
|
-
const parsed = (0, imagePersistence_cjs_namespaceObject.parseBase64DataUrl)(PNG_DATA_URL);
|
|
159
|
-
(0, external_vitest_namespaceObject.expect)(parsed?.mimeType).toBe("image/png");
|
|
160
|
-
(0, external_vitest_namespaceObject.expect)(typeof parsed?.data).toBe("string");
|
|
161
|
-
(0, external_vitest_namespaceObject.expect)((0, imagePersistence_cjs_namespaceObject.resolveImageExtension)("image/jpeg")).toBe("jpg");
|
|
162
|
-
(0, external_vitest_namespaceObject.expect)((0, imagePersistence_cjs_namespaceObject.resolveImageExtension)("image/svg+xml")).toBe("svg");
|
|
163
|
-
(0, external_vitest_namespaceObject.expect)((0, imagePersistence_cjs_namespaceObject.resolveImageExtension)("image/custom+format")).toBe("customformat");
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
167
|
-
Object.defineProperty(exports, '__esModule', {
|
|
168
|
-
value: true
|
|
169
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|