shadow-claw 1.40.0 → 1.40.1
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/.well-known/mcp/server-card.json +2 -2
- package/.well-known/mcp/servers.json +1 -1
- package/.well-known/mcp.json +2 -2
- package/dist/cli/cli.js +2 -2
- package/dist/lib/components/index.js +2 -2
- package/dist/lib/components/shadow-claw-file-viewer/shadow-claw-file-viewer.d.ts +1 -1
- package/dist/lib/components/shadow-claw-file-viewer.js +1 -1
- package/dist/lib/components/shadow-claw.js +1 -1
- package/dist/lib/core/orchestrator/orchestrator-state.d.ts +2 -1
- package/dist/lib/core/orchestrator/orchestrator.d.ts +2 -1
- package/dist/lib/core/orchestrator/utils/operations/task.d.ts +1 -0
- package/dist/lib/index.js +2 -2
- package/dist/lib/{orchestrator-Bq9ft3uG.js → orchestrator-CMN43L0F.js} +9 -13
- package/dist/lib/orchestrator-CMN43L0F.js.map +1 -0
- package/dist/lib/orchestrator-D9f5fDCb.js.map +1 -1
- package/dist/lib/{shadow-claw-MumteAJy.js → shadow-claw-4x3LqlII.js} +2 -2
- package/dist/lib/{shadow-claw-MumteAJy.js.map → shadow-claw-4x3LqlII.js.map} +1 -1
- package/dist/lib/{shadow-claw-file-viewer-CMOnFmcP.js → shadow-claw-file-viewer-CuDhkVcL.js} +21 -21
- package/dist/lib/{shadow-claw-file-viewer-CMOnFmcP.js.map → shadow-claw-file-viewer-CuDhkVcL.js.map} +1 -1
- package/dist/lib/syncWebMcpRegistration-Bbph0XZl.js.map +1 -1
- package/dist/public/.well-known/mcp/server-card.json +2 -2
- package/dist/public/.well-known/mcp/servers.json +1 -1
- package/dist/public/.well-known/mcp.json +2 -2
- package/dist/public/docs/decisions/native-web-components-and-signals.md +1 -1
- package/dist/public/docs/example/article/index.html +2 -2
- package/dist/public/docs/publishing/index.html +2 -2
- package/dist/public/docs/skill-creator/index.html +2 -2
- package/dist/public/index.html +2 -2
- package/dist/public/index.js +1 -1
- package/dist/public/main/index.html +2 -2
- package/dist/public/main/memory/index.html +2 -2
- package/dist/public/{orchestrator-BLkS_jpm.js → orchestrator-Dc_Q73La.js} +1 -1
- package/dist/public/service-worker.js +1 -1
- package/dist/public/{shadow-claw-DmrxnX3Q.js → shadow-claw-Dabb2AEp.js} +2 -2
- package/dist/public/{shadow-claw-file-viewer-a_uRA30F.js → shadow-claw-file-viewer-CDs1QGXk.js} +1 -1
- package/dist/server.js +1 -1
- package/package.json +1 -1
- package/src/cli/cli.ts +2 -2
- package/src/components/shadow-claw-file-viewer/shadow-claw-file-viewer.ts +31 -31
- package/src/core/effect.test.ts +19 -0
- package/src/core/orchestrator/orchestrator-state.ts +2 -1
- package/src/core/orchestrator/orchestrator.test.ts +686 -5
- package/src/core/orchestrator/orchestrator.ts +3 -10
- package/src/core/orchestrator/utils/compactContext.test.ts +423 -121
- package/src/core/orchestrator/utils/configurePeerJs.test.ts +27 -0
- package/src/core/orchestrator/utils/deliverResponse.test.ts +127 -0
- package/src/core/orchestrator/utils/dispatchSubagentInvoke.test.ts +23 -0
- package/src/core/orchestrator/utils/enqueue.test.ts +520 -86
- package/src/core/orchestrator/utils/handleWorkerMessage.test.ts +664 -144
- package/src/core/orchestrator/utils/initTasks.node.test.ts +147 -0
- package/src/core/orchestrator/utils/initTasks.test.ts +926 -191
- package/src/core/orchestrator/utils/initTasks.ts +5 -4
- package/src/core/orchestrator/utils/invokeAgent.test.ts +563 -110
- package/src/core/orchestrator/utils/invokeAgent.ts +8 -10
- package/src/core/orchestrator/utils/loadChannelConfigurations.test.ts +50 -0
- package/src/core/orchestrator/utils/operations/channel.test.ts +377 -170
- package/src/core/orchestrator/utils/operations/provider.test.ts +663 -85
- package/src/core/orchestrator/utils/operations/room.test.ts +74 -11
- package/src/core/orchestrator/utils/operations/task.test.ts +452 -56
- package/src/core/orchestrator/utils/operations/task.ts +1 -1
- package/src/core/orchestrator/utils/operations/vm.test.ts +66 -7
- package/src/core/orchestrator/utils/parseDirectToolCommand.test.ts +6 -0
- package/src/core/orchestrator/utils/settings.test.ts +248 -81
- package/src/core/orchestrator/utils/setupPushTaskListener.test.ts +58 -0
- package/src/core/orchestrator/utils/syncWebMcpRegistration.test.ts +341 -65
- package/src/core/orchestrator/utils/syncWebMcpRegistration.ts +4 -2
- package/src/server/routes/mcp.ts +2 -2
- package/src/stores/file-viewer.test.ts +11 -0
- package/src/stores/theme.test.ts +41 -2
- package/src/stores/toast.test.ts +25 -0
- package/src/worker/tools/bash/native-bash-executor.test.ts +31 -1
- package/src/worker/tools/git/utils/extractConflictPaths.test.ts +24 -0
- package/src/worker/tools/git/utils/parseConflictRegions.test.ts +46 -0
- package/src/worker/tools/git/utils/resolveCorsProxy.test.ts +26 -5
- package/src/worker/tools/git/utils/truncateSnippet.test.ts +16 -0
- package/src/worker/tools/node-transformers-executor.test.ts +105 -6
- package/src/worker/tools/remote-mcp/remote-mcp.test.ts +172 -47
- package/src/worker/tools/remote-mcp/utils/formatListToolsOutput.test.ts +19 -0
- package/src/worker/tools/remote-mcp/utils/isMcpReauthError.test.ts +45 -0
- package/src/worker/tools/remote-mcp/utils/resolveMcpReauth.test.ts +48 -0
- package/src/worker/tools/rooms/list-room-members.test.ts +24 -10
- package/src/worker/tools/tasks/list-tasks.test.ts +39 -8
- package/src/worker/tools/tasks/update-task.test.ts +78 -14
- package/src/worker/tools/ui/javascript.test.ts +70 -17
- package/src/worker/tools/ui/list-tool-profiles.test.ts +31 -9
- package/dist/lib/orchestrator-Bq9ft3uG.js.map +0 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment node
|
|
3
|
+
*/
|
|
4
|
+
import { beforeEach, describe, expect, it, jest } from "@jest/globals";
|
|
5
|
+
|
|
6
|
+
import { CONFIG_KEYS } from "../../../config/config.js";
|
|
7
|
+
import type { ShadowClawDatabase } from "../../../db/db.js";
|
|
8
|
+
import type { Orchestrator } from "../orchestrator.js";
|
|
9
|
+
|
|
10
|
+
const mockFetchModelInfo = jest
|
|
11
|
+
.fn<() => Promise<void>>()
|
|
12
|
+
.mockResolvedValue(undefined);
|
|
13
|
+
const mockGetConfig =
|
|
14
|
+
jest.fn<
|
|
15
|
+
(db: ShadowClawDatabase, key: string) => Promise<string | undefined>
|
|
16
|
+
>();
|
|
17
|
+
|
|
18
|
+
const mockApplyLlamafileHeaders = jest.fn<(o: Orchestrator) => void>();
|
|
19
|
+
const mockApplyMeshLlmHeaders = jest.fn<(o: Orchestrator) => void>();
|
|
20
|
+
const mockGetApiKeyForHeaders = jest
|
|
21
|
+
.fn<(o: Orchestrator) => Promise<string | null>>()
|
|
22
|
+
.mockResolvedValue("key");
|
|
23
|
+
const mockGetProviderRuntimeHeaders = jest
|
|
24
|
+
.fn<(o: Orchestrator, prov: string) => Record<string, string>>()
|
|
25
|
+
.mockReturnValue({});
|
|
26
|
+
|
|
27
|
+
jest.unstable_mockModule("./operations/provider.js", () => ({
|
|
28
|
+
applyLlamafileHeaders: mockApplyLlamafileHeaders,
|
|
29
|
+
applyMeshLlmHeaders: mockApplyMeshLlmHeaders,
|
|
30
|
+
getApiKeyForHeaders: mockGetApiKeyForHeaders,
|
|
31
|
+
getApiKeyForRequest: jest.fn(),
|
|
32
|
+
getProviderRuntimeHeaders: mockGetProviderRuntimeHeaders,
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
jest.unstable_mockModule("./enqueue.js", () => ({
|
|
36
|
+
enqueue: jest.fn(),
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
jest.unstable_mockModule("./operations/channel.js", () => ({
|
|
40
|
+
applyAllChannelRunningStates: jest.fn(),
|
|
41
|
+
applyChannelRunningState: jest.fn(),
|
|
42
|
+
clearPeerJsTypingState: jest.fn(),
|
|
43
|
+
getChannelByType: jest.fn(),
|
|
44
|
+
getChannelEnabled: jest.fn(),
|
|
45
|
+
getChannelEnabledConfigKey: jest.fn(),
|
|
46
|
+
getChannelTypeForGroup: jest.fn(),
|
|
47
|
+
loadChannelEnabled: jest.fn(),
|
|
48
|
+
setChannelEnabled: jest.fn(),
|
|
49
|
+
shouldRunChannel: jest.fn(),
|
|
50
|
+
submitMessage: jest.fn(),
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
jest.unstable_mockModule("./operations/task.js", () => ({
|
|
54
|
+
deleteTaskFromServer: jest.fn(),
|
|
55
|
+
runTaskAsScheduled: jest.fn(),
|
|
56
|
+
shouldStartLocalScheduler: jest.fn(),
|
|
57
|
+
syncTaskToServer: jest.fn(),
|
|
58
|
+
warnIfNoPushSubscription: jest.fn(),
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
jest.unstable_mockModule("./operations/room.js", () => ({
|
|
62
|
+
handleRoomInvite: jest.fn(),
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
jest.unstable_mockModule("./handleWorkerMessage.js", () => ({
|
|
66
|
+
handleWorkerMessage: jest.fn(),
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
jest.unstable_mockModule("./loadChannelConfigurations.js", () => ({
|
|
70
|
+
loadChannelConfigurations: jest.fn(),
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
jest.unstable_mockModule("./setupPushTaskListener.js", () => ({
|
|
74
|
+
setupPushTaskListener: jest.fn(),
|
|
75
|
+
}));
|
|
76
|
+
|
|
77
|
+
jest.unstable_mockModule("./syncProxyConfigToServiceWorker.js", () => ({
|
|
78
|
+
syncProxyConfigToServiceWorker: jest.fn(),
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
jest.unstable_mockModule("../../../subsystems/mcp/webmcp.js", () => ({
|
|
82
|
+
setWebMcpMode: jest.fn(),
|
|
83
|
+
}));
|
|
84
|
+
|
|
85
|
+
jest.unstable_mockModule("../../../db/getConfig.js", () => ({
|
|
86
|
+
getConfig: mockGetConfig,
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
jest.unstable_mockModule(
|
|
90
|
+
"../../../subsystems/providers/model-registry.js",
|
|
91
|
+
() => ({
|
|
92
|
+
modelRegistry: {
|
|
93
|
+
fetchModelInfo: mockFetchModelInfo,
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const { initProviderAndModel } = await import("./initTasks.js");
|
|
99
|
+
|
|
100
|
+
describe("initTasks in node environment", () => {
|
|
101
|
+
let mockDb: ShadowClawDatabase;
|
|
102
|
+
let mockOrchestrator: {
|
|
103
|
+
provider: string;
|
|
104
|
+
model: string;
|
|
105
|
+
maxTokens: number;
|
|
106
|
+
maxIterations: number;
|
|
107
|
+
providerConfig: { defaultModel: string };
|
|
108
|
+
loadApiKeyForProvider: jest.Mock;
|
|
109
|
+
bedrockRegionFallback?: string;
|
|
110
|
+
bedrockProfileFallback?: string;
|
|
111
|
+
bedrockAuthMode?: string;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
beforeEach(() => {
|
|
115
|
+
jest.clearAllMocks();
|
|
116
|
+
mockDb = {} as unknown as ShadowClawDatabase;
|
|
117
|
+
mockOrchestrator = {
|
|
118
|
+
provider: "openrouter",
|
|
119
|
+
model: "openai/gpt-4o",
|
|
120
|
+
maxTokens: 2048,
|
|
121
|
+
maxIterations: 10,
|
|
122
|
+
providerConfig: { defaultModel: "openai/gpt-4o" },
|
|
123
|
+
loadApiKeyForProvider: jest
|
|
124
|
+
.fn<() => Promise<void>>()
|
|
125
|
+
.mockResolvedValue(undefined),
|
|
126
|
+
};
|
|
127
|
+
mockGetConfig.mockImplementation(async (_db, key) => {
|
|
128
|
+
if (key === CONFIG_KEYS.PROVIDER) return "openrouter";
|
|
129
|
+
return undefined;
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("should trigger scheduleFetch in node environment where window and document are undefined", async () => {
|
|
134
|
+
jest.useFakeTimers();
|
|
135
|
+
expect(typeof window).toBe("undefined");
|
|
136
|
+
expect(typeof document).toBe("undefined");
|
|
137
|
+
|
|
138
|
+
await initProviderAndModel(
|
|
139
|
+
mockOrchestrator as unknown as Orchestrator,
|
|
140
|
+
mockDb,
|
|
141
|
+
);
|
|
142
|
+
jest.advanceTimersByTime(2500);
|
|
143
|
+
await Promise.resolve();
|
|
144
|
+
expect(mockFetchModelInfo).toHaveBeenCalled();
|
|
145
|
+
jest.useRealTimers();
|
|
146
|
+
});
|
|
147
|
+
});
|