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.
Files changed (86) hide show
  1. package/.well-known/mcp/server-card.json +2 -2
  2. package/.well-known/mcp/servers.json +1 -1
  3. package/.well-known/mcp.json +2 -2
  4. package/dist/cli/cli.js +2 -2
  5. package/dist/lib/components/index.js +2 -2
  6. package/dist/lib/components/shadow-claw-file-viewer/shadow-claw-file-viewer.d.ts +1 -1
  7. package/dist/lib/components/shadow-claw-file-viewer.js +1 -1
  8. package/dist/lib/components/shadow-claw.js +1 -1
  9. package/dist/lib/core/orchestrator/orchestrator-state.d.ts +2 -1
  10. package/dist/lib/core/orchestrator/orchestrator.d.ts +2 -1
  11. package/dist/lib/core/orchestrator/utils/operations/task.d.ts +1 -0
  12. package/dist/lib/index.js +2 -2
  13. package/dist/lib/{orchestrator-Bq9ft3uG.js → orchestrator-CMN43L0F.js} +9 -13
  14. package/dist/lib/orchestrator-CMN43L0F.js.map +1 -0
  15. package/dist/lib/orchestrator-D9f5fDCb.js.map +1 -1
  16. package/dist/lib/{shadow-claw-MumteAJy.js → shadow-claw-4x3LqlII.js} +2 -2
  17. package/dist/lib/{shadow-claw-MumteAJy.js.map → shadow-claw-4x3LqlII.js.map} +1 -1
  18. package/dist/lib/{shadow-claw-file-viewer-CMOnFmcP.js → shadow-claw-file-viewer-CuDhkVcL.js} +21 -21
  19. package/dist/lib/{shadow-claw-file-viewer-CMOnFmcP.js.map → shadow-claw-file-viewer-CuDhkVcL.js.map} +1 -1
  20. package/dist/lib/syncWebMcpRegistration-Bbph0XZl.js.map +1 -1
  21. package/dist/public/.well-known/mcp/server-card.json +2 -2
  22. package/dist/public/.well-known/mcp/servers.json +1 -1
  23. package/dist/public/.well-known/mcp.json +2 -2
  24. package/dist/public/docs/decisions/native-web-components-and-signals.md +1 -1
  25. package/dist/public/docs/example/article/index.html +2 -2
  26. package/dist/public/docs/publishing/index.html +2 -2
  27. package/dist/public/docs/skill-creator/index.html +2 -2
  28. package/dist/public/index.html +2 -2
  29. package/dist/public/index.js +1 -1
  30. package/dist/public/main/index.html +2 -2
  31. package/dist/public/main/memory/index.html +2 -2
  32. package/dist/public/{orchestrator-BLkS_jpm.js → orchestrator-Dc_Q73La.js} +1 -1
  33. package/dist/public/service-worker.js +1 -1
  34. package/dist/public/{shadow-claw-DmrxnX3Q.js → shadow-claw-Dabb2AEp.js} +2 -2
  35. package/dist/public/{shadow-claw-file-viewer-a_uRA30F.js → shadow-claw-file-viewer-CDs1QGXk.js} +1 -1
  36. package/dist/server.js +1 -1
  37. package/package.json +1 -1
  38. package/src/cli/cli.ts +2 -2
  39. package/src/components/shadow-claw-file-viewer/shadow-claw-file-viewer.ts +31 -31
  40. package/src/core/effect.test.ts +19 -0
  41. package/src/core/orchestrator/orchestrator-state.ts +2 -1
  42. package/src/core/orchestrator/orchestrator.test.ts +686 -5
  43. package/src/core/orchestrator/orchestrator.ts +3 -10
  44. package/src/core/orchestrator/utils/compactContext.test.ts +423 -121
  45. package/src/core/orchestrator/utils/configurePeerJs.test.ts +27 -0
  46. package/src/core/orchestrator/utils/deliverResponse.test.ts +127 -0
  47. package/src/core/orchestrator/utils/dispatchSubagentInvoke.test.ts +23 -0
  48. package/src/core/orchestrator/utils/enqueue.test.ts +520 -86
  49. package/src/core/orchestrator/utils/handleWorkerMessage.test.ts +664 -144
  50. package/src/core/orchestrator/utils/initTasks.node.test.ts +147 -0
  51. package/src/core/orchestrator/utils/initTasks.test.ts +926 -191
  52. package/src/core/orchestrator/utils/initTasks.ts +5 -4
  53. package/src/core/orchestrator/utils/invokeAgent.test.ts +563 -110
  54. package/src/core/orchestrator/utils/invokeAgent.ts +8 -10
  55. package/src/core/orchestrator/utils/loadChannelConfigurations.test.ts +50 -0
  56. package/src/core/orchestrator/utils/operations/channel.test.ts +377 -170
  57. package/src/core/orchestrator/utils/operations/provider.test.ts +663 -85
  58. package/src/core/orchestrator/utils/operations/room.test.ts +74 -11
  59. package/src/core/orchestrator/utils/operations/task.test.ts +452 -56
  60. package/src/core/orchestrator/utils/operations/task.ts +1 -1
  61. package/src/core/orchestrator/utils/operations/vm.test.ts +66 -7
  62. package/src/core/orchestrator/utils/parseDirectToolCommand.test.ts +6 -0
  63. package/src/core/orchestrator/utils/settings.test.ts +248 -81
  64. package/src/core/orchestrator/utils/setupPushTaskListener.test.ts +58 -0
  65. package/src/core/orchestrator/utils/syncWebMcpRegistration.test.ts +341 -65
  66. package/src/core/orchestrator/utils/syncWebMcpRegistration.ts +4 -2
  67. package/src/server/routes/mcp.ts +2 -2
  68. package/src/stores/file-viewer.test.ts +11 -0
  69. package/src/stores/theme.test.ts +41 -2
  70. package/src/stores/toast.test.ts +25 -0
  71. package/src/worker/tools/bash/native-bash-executor.test.ts +31 -1
  72. package/src/worker/tools/git/utils/extractConflictPaths.test.ts +24 -0
  73. package/src/worker/tools/git/utils/parseConflictRegions.test.ts +46 -0
  74. package/src/worker/tools/git/utils/resolveCorsProxy.test.ts +26 -5
  75. package/src/worker/tools/git/utils/truncateSnippet.test.ts +16 -0
  76. package/src/worker/tools/node-transformers-executor.test.ts +105 -6
  77. package/src/worker/tools/remote-mcp/remote-mcp.test.ts +172 -47
  78. package/src/worker/tools/remote-mcp/utils/formatListToolsOutput.test.ts +19 -0
  79. package/src/worker/tools/remote-mcp/utils/isMcpReauthError.test.ts +45 -0
  80. package/src/worker/tools/remote-mcp/utils/resolveMcpReauth.test.ts +48 -0
  81. package/src/worker/tools/rooms/list-room-members.test.ts +24 -10
  82. package/src/worker/tools/tasks/list-tasks.test.ts +39 -8
  83. package/src/worker/tools/tasks/update-task.test.ts +78 -14
  84. package/src/worker/tools/ui/javascript.test.ts +70 -17
  85. package/src/worker/tools/ui/list-tool-profiles.test.ts +31 -9
  86. package/dist/lib/orchestrator-Bq9ft3uG.js.map +0 -1
@@ -204,4 +204,31 @@ describe("configurePeerJs", () => {
204
204
 
205
205
  expect(mockOrchestrator.peerjs.start).not.toHaveBeenCalled();
206
206
  });
207
+
208
+ it("should handle non-finite port and empty path/port when serverHost is provided", async () => {
209
+ mockOrchestrator.getChannelEnabled.mockReturnValue(true);
210
+
211
+ await configurePeerJs(
212
+ mockOrchestrator,
213
+ mockDb,
214
+ "my-peer",
215
+ [],
216
+ "host.com",
217
+ NaN,
218
+ "",
219
+ true,
220
+ );
221
+
222
+ expect(mockOrchestrator.peerjsServerPort).toBe(0);
223
+ expect(mockOrchestrator.peerjs.configure).toHaveBeenCalledWith(
224
+ "my-peer",
225
+ ["trusted-1", "trusted-2"],
226
+ {
227
+ host: "host.com",
228
+ path: undefined,
229
+ port: undefined,
230
+ secure: true,
231
+ },
232
+ );
233
+ });
207
234
  });
@@ -81,6 +81,78 @@ describe("deliverResponse", () => {
81
81
 
82
82
  consoleSpy.mockRestore();
83
83
  });
84
+
85
+ it("should deliver intermediate response for browser channel without sending to router", async () => {
86
+ mockOrchestrator.channelRegistry.getChannelType.mockReturnValue(
87
+ "browser",
88
+ );
89
+
90
+ await deliverIntermediateResponse(
91
+ mockOrchestrator,
92
+ mockDb,
93
+ "group1",
94
+ "Hello browser",
95
+ );
96
+
97
+ expect(mockOrchestrator.router.send).not.toHaveBeenCalled();
98
+ expect(mockOrchestrator.events.emit).toHaveBeenCalledWith(
99
+ "message",
100
+ expect.objectContaining({
101
+ channel: "browser",
102
+ content: "Hello browser",
103
+ }),
104
+ );
105
+ });
106
+
107
+ it("should deliver intermediate response over non-browser channel successfully", async () => {
108
+ mockOrchestrator.channelRegistry.getChannelType.mockReturnValue(
109
+ "telegram",
110
+ );
111
+
112
+ await deliverIntermediateResponse(
113
+ mockOrchestrator,
114
+ mockDb,
115
+ "group1",
116
+ "Hello",
117
+ );
118
+
119
+ expect(mockOrchestrator.router.send).toHaveBeenCalledWith(
120
+ "group1",
121
+ "Hello",
122
+ );
123
+ expect(mockOrchestrator.events.emit).toHaveBeenCalledWith(
124
+ "message",
125
+ expect.objectContaining({
126
+ channel: "telegram",
127
+ content: "Hello",
128
+ }),
129
+ );
130
+ });
131
+
132
+ it("should handle non-Error throw in intermediate response", async () => {
133
+ mockOrchestrator.channelRegistry.getChannelType.mockReturnValue(
134
+ "telegram",
135
+ );
136
+ mockOrchestrator.router.send.mockRejectedValue("String failure");
137
+
138
+ const consoleSpy = (
139
+ jest.spyOn(console, "error") as any
140
+ ).mockImplementation();
141
+
142
+ await deliverIntermediateResponse(
143
+ mockOrchestrator,
144
+ mockDb,
145
+ "group1",
146
+ "Hello",
147
+ );
148
+
149
+ expect(mockOrchestrator.events.emit).toHaveBeenCalledWith("error", {
150
+ groupId: "group1",
151
+ error: "Failed to deliver response to telegram: String failure",
152
+ });
153
+
154
+ consoleSpy.mockRestore();
155
+ });
84
156
  });
85
157
 
86
158
  describe("deliverResponse", () => {
@@ -108,6 +180,34 @@ describe("deliverResponse", () => {
108
180
  consoleSpy.mockRestore();
109
181
  });
110
182
 
183
+ it("should handle non-Error rejection in deliverResponse", async () => {
184
+ mockOrchestrator.channelRegistry.getChannelType.mockReturnValue(
185
+ "telegram",
186
+ );
187
+ mockOrchestrator.router.send.mockRejectedValue("String error");
188
+
189
+ const consoleSpy = (
190
+ jest.spyOn(console, "error") as any
191
+ ).mockImplementation();
192
+
193
+ await deliverResponse(mockOrchestrator, mockDb, "group1", "Hello");
194
+
195
+ expect(mockOrchestrator.events.emit).toHaveBeenCalledWith("error", {
196
+ groupId: "group1",
197
+ error: "Failed to deliver response to telegram: String error",
198
+ });
199
+
200
+ consoleSpy.mockRestore();
201
+ });
202
+
203
+ it("should succeed when router is undefined", async () => {
204
+ mockOrchestrator.router = undefined;
205
+
206
+ await deliverResponse(mockOrchestrator, mockDb, "group1", "Hello");
207
+
208
+ expect(mockOrchestrator.setState).toHaveBeenCalledWith("idle", "group1");
209
+ });
210
+
111
211
  it("should play chime and clear pending scheduled task if present", async () => {
112
212
  mockOrchestrator.pendingScheduledTasks.add("group1");
113
213
 
@@ -127,5 +227,32 @@ describe("deliverResponse", () => {
127
227
  );
128
228
  expect(mockOrchestrator.peerCompletedContexts.has("peer:123")).toBe(true);
129
229
  });
230
+
231
+ it("should not add to peerCompletedContexts if completeActiveTask returns false", async () => {
232
+ mockOrchestrator.channelRegistry.getChannelType.mockReturnValue("peerjs");
233
+ mockOrchestrator.peerjs.completeActiveTask.mockReturnValue(false);
234
+
235
+ await deliverResponse(mockOrchestrator, mockDb, "peer:123", "Hello");
236
+
237
+ expect(mockOrchestrator.peerCompletedContexts.has("peer:123")).toBe(
238
+ false,
239
+ );
240
+ });
241
+
242
+ it("should not complete active task if group is peer: but deliveryError occurred", async () => {
243
+ mockOrchestrator.channelRegistry.getChannelType.mockReturnValue("peerjs");
244
+ mockOrchestrator.router.send.mockRejectedValue(
245
+ new Error("Peer send failed"),
246
+ );
247
+
248
+ const consoleSpy = (
249
+ jest.spyOn(console, "error") as any
250
+ ).mockImplementation();
251
+
252
+ await deliverResponse(mockOrchestrator, mockDb, "peer:123", "Hello");
253
+
254
+ expect(mockOrchestrator.peerjs.completeActiveTask).not.toHaveBeenCalled();
255
+ consoleSpy.mockRestore();
256
+ });
130
257
  });
131
258
  });
@@ -185,6 +185,29 @@ describe("dispatchSubagentInvoke", () => {
185
185
  expect(callArgs[6]).toBe(controller.signal);
186
186
  });
187
187
 
188
+ it("forwards emit callback messages to workerPost", async () => {
189
+ mockInvokeWithTransformersJs.mockImplementationOnce(
190
+ async (
191
+ _db: unknown,
192
+ _groupId: string,
193
+ _sys: string,
194
+ _msgs: unknown[],
195
+ _tokens: number,
196
+ emit: (msg: { type: string; content: string }) => Promise<void>,
197
+ ) => {
198
+ await emit({ type: "stream", content: "chunk" });
199
+ },
200
+ );
201
+
202
+ const payload = makePayload({ provider: "transformers_js_browser" });
203
+ await dispatchSubagentInvoke(mockDb, payload);
204
+
205
+ expect(mockWorkerPost).toHaveBeenCalledWith({
206
+ type: "stream",
207
+ content: "chunk",
208
+ });
209
+ });
210
+
188
211
  // ── prompt_api path ───────────────────────────────────────────────────────
189
212
 
190
213
  it("routes prompt_api to invokeWithPromptApi when supported", async () => {