@desplega.ai/agent-swarm 1.83.0 → 1.83.2

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 (67) hide show
  1. package/openapi.json +177 -10
  2. package/package.json +6 -6
  3. package/src/artifact-sdk/server.ts +23 -1
  4. package/src/be/budget-admission.ts +28 -4
  5. package/src/be/budget-refusal-notify.ts +19 -3
  6. package/src/be/db-queries/oauth.ts +43 -0
  7. package/src/be/db.ts +37 -4
  8. package/src/be/migrations/074_user_budget_scope.sql +85 -0
  9. package/src/be/schedules/validate.ts +21 -0
  10. package/src/be/skill-sync.ts +65 -15
  11. package/src/commands/resume-session.ts +118 -0
  12. package/src/commands/runner.ts +178 -121
  13. package/src/http/core.ts +4 -1
  14. package/src/http/index.ts +16 -0
  15. package/src/http/integrations.ts +26 -0
  16. package/src/http/mcp-user.ts +111 -0
  17. package/src/http/poll.ts +19 -5
  18. package/src/http/schedules.ts +35 -10
  19. package/src/http/skills.ts +27 -2
  20. package/src/http/users.ts +107 -2
  21. package/src/jira/client.ts +3 -5
  22. package/src/jira/oauth.ts +1 -0
  23. package/src/jira/sync.ts +2 -2
  24. package/src/oauth/ensure-token.ts +1 -0
  25. package/src/oauth/wrapper.ts +38 -7
  26. package/src/providers/claude-adapter.ts +7 -2
  27. package/src/providers/claude-managed-adapter.ts +1 -1
  28. package/src/providers/codex-adapter.ts +30 -0
  29. package/src/providers/opencode-adapter.ts +149 -14
  30. package/src/providers/pi-mono-adapter.ts +41 -1
  31. package/src/providers/types.ts +1 -1
  32. package/src/server-user.ts +117 -0
  33. package/src/tests/artifact-sdk.test.ts +23 -19
  34. package/src/tests/budget-user-scope.test.ts +376 -0
  35. package/src/tests/claude-managed-adapter.test.ts +6 -0
  36. package/src/tests/codex-adapter.test.ts +192 -0
  37. package/src/tests/codex-rate-limit-parse.test.ts +256 -0
  38. package/src/tests/db-queries-oauth.test.ts +43 -0
  39. package/src/tests/ensure-token.test.ts +93 -0
  40. package/src/tests/error-tracker.test.ts +52 -0
  41. package/src/tests/fetch-resolved-env.test.ts +33 -20
  42. package/src/tests/http-api-integration.test.ts +36 -0
  43. package/src/tests/http-users.test.ts +29 -1
  44. package/src/tests/mcp-user-route.test.ts +325 -0
  45. package/src/tests/opencode-adapter.test.ts +75 -0
  46. package/src/tests/pi-mono-adapter.test.ts +21 -1
  47. package/src/tests/rate-limit-event.test.ts +69 -6
  48. package/src/tests/resume-session.test.ts +93 -0
  49. package/src/tests/runner-skills-refresh.test.ts +200 -0
  50. package/src/tests/schedule-validation-helper.test.ts +51 -0
  51. package/src/tests/skill-sync.test.ts +73 -9
  52. package/src/tests/skills-signature.test.ts +141 -0
  53. package/src/tests/task-tools-ctx.test.ts +100 -0
  54. package/src/tests/task-tools-ownership.test.ts +167 -0
  55. package/src/tests/update-schedule-mcp-tool.test.ts +161 -0
  56. package/src/tests/user-token-routes.test.ts +221 -0
  57. package/src/tools/cancel-task.ts +137 -83
  58. package/src/tools/get-task-details.ts +73 -59
  59. package/src/tools/get-tasks.ts +134 -126
  60. package/src/tools/schedules/update-schedule.ts +48 -8
  61. package/src/tools/send-task.ts +312 -312
  62. package/src/tools/slack-upload-file.ts +17 -5
  63. package/src/tools/task-action.ts +464 -367
  64. package/src/tools/task-tool-ctx.ts +43 -0
  65. package/src/types.ts +6 -2
  66. package/src/utils/error-tracker.ts +122 -9
  67. package/src/utils/skills-refresh.ts +123 -0
@@ -7,6 +7,7 @@ import {
7
7
  getScheduledTaskByName,
8
8
  updateScheduledTask,
9
9
  } from "@/be/db";
10
+ import { mergeScheduleTiming, validateRecurringTiming } from "@/be/schedules/validate";
10
11
  import { calculateNextRun } from "@/scheduler";
11
12
  import { createToolRegistrar } from "@/tools/utils";
12
13
 
@@ -23,8 +24,18 @@ export const registerUpdateScheduleTool = (server: McpServer) => {
23
24
  name: z.string().optional().describe("Schedule name to update (alternative to ID)"),
24
25
  newName: z.string().min(1).max(100).optional().describe("New name for the schedule"),
25
26
  taskTemplate: z.string().min(1).optional().describe("New task template"),
26
- cronExpression: z.string().optional().describe("New cron expression"),
27
- intervalMs: z.number().int().positive().optional().describe("New interval in milliseconds"),
27
+ cronExpression: z
28
+ .string()
29
+ .nullable()
30
+ .optional()
31
+ .describe("New cron expression (null to clear)"),
32
+ intervalMs: z
33
+ .number()
34
+ .int()
35
+ .positive()
36
+ .nullable()
37
+ .optional()
38
+ .describe("New interval in milliseconds (null to clear)"),
28
39
  description: z.string().optional().describe("New description"),
29
40
  taskType: z.string().max(50).optional().describe("New task type"),
30
41
  tags: z.array(z.string()).optional().describe("New tags"),
@@ -215,6 +226,32 @@ export const registerUpdateScheduleTool = (server: McpServer) => {
215
226
  updateData.nextRunAt = undefined;
216
227
  }
217
228
  } else {
229
+ // Validate merged timing before recalc — runs BEFORE the enabled===false
230
+ // skip-recalc branch so disabling cannot bypass the invariant.
231
+ const timing = mergeScheduleTiming(
232
+ {
233
+ cronExpression: schedule.cronExpression ?? null,
234
+ intervalMs: schedule.intervalMs ?? null,
235
+ },
236
+ { cronExpression, intervalMs },
237
+ );
238
+ const timingError = validateRecurringTiming(timing);
239
+ if (timingError) {
240
+ return {
241
+ content: [
242
+ {
243
+ type: "text",
244
+ text: "At least one of intervalMs or cronExpression must be set for recurring schedules.",
245
+ },
246
+ ],
247
+ structuredContent: {
248
+ success: false,
249
+ message:
250
+ "At least one of intervalMs or cronExpression must be set for recurring schedules.",
251
+ },
252
+ };
253
+ }
254
+
218
255
  const needsNextRunRecalc =
219
256
  cronExpression !== undefined ||
220
257
  intervalMs !== undefined ||
@@ -222,12 +259,15 @@ export const registerUpdateScheduleTool = (server: McpServer) => {
222
259
  (enabled === true && !schedule.enabled);
223
260
 
224
261
  if (needsNextRunRecalc && enabled !== false) {
225
- const tempSchedule = {
226
- cronExpression: cronExpression ?? schedule.cronExpression,
227
- intervalMs: intervalMs ?? schedule.intervalMs,
228
- timezone: timezone ?? schedule.timezone,
229
- } as Parameters<typeof calculateNextRun>[0];
230
- updateData.nextRunAt = calculateNextRun(tempSchedule, new Date());
262
+ const mergedTimezone = timezone !== undefined ? timezone : schedule.timezone;
263
+ updateData.nextRunAt = calculateNextRun(
264
+ {
265
+ cronExpression: timing.mergedCron,
266
+ intervalMs: timing.mergedInterval,
267
+ timezone: mergedTimezone,
268
+ } as Parameters<typeof calculateNextRun>[0],
269
+ new Date(),
270
+ );
231
271
  } else if (enabled === false) {
232
272
  updateData.nextRunAt = undefined;
233
273
  }