@jiggai/kitchen 0.3.1 → 0.3.3
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/server/app/_global-error.html +2 -2
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/channels.html +2 -2
- package/.next/server/app/channels.rsc +1 -1
- package/.next/server/app/channels.segments/_full.segment.rsc +1 -1
- package/.next/server/app/channels.segments/_head.segment.rsc +1 -1
- package/.next/server/app/channels.segments/_index.segment.rsc +1 -1
- package/.next/server/app/channels.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/channels.segments/channels/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/channels.segments/channels.segment.rsc +1 -1
- package/.next/server/app/cron-jobs.html +1 -1
- package/.next/server/app/cron-jobs.rsc +1 -1
- package/.next/server/app/cron-jobs.segments/_full.segment.rsc +1 -1
- package/.next/server/app/cron-jobs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/cron-jobs.segments/_index.segment.rsc +1 -1
- package/.next/server/app/cron-jobs.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/cron-jobs.segments/cron-jobs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/cron-jobs.segments/cron-jobs.segment.rsc +1 -1
- package/.next/server/app/goals/new.html +2 -2
- package/.next/server/app/goals/new.rsc +1 -1
- package/.next/server/app/goals/new.segments/_full.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/_head.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/_index.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/goals/new/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/goals/new.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/goals.segment.rsc +1 -1
- package/.next/server/app/goals.html +1 -1
- package/.next/server/app/goals.rsc +1 -1
- package/.next/server/app/goals.segments/_full.segment.rsc +1 -1
- package/.next/server/app/goals.segments/_head.segment.rsc +1 -1
- package/.next/server/app/goals.segments/_index.segment.rsc +1 -1
- package/.next/server/app/goals.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/goals.segments/goals/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/goals.segments/goals.segment.rsc +1 -1
- package/.next/server/app/settings.html +1 -1
- package/.next/server/app/settings.rsc +1 -1
- package/.next/server/app/settings.segments/_full.segment.rsc +1 -1
- package/.next/server/app/settings.segments/_head.segment.rsc +1 -1
- package/.next/server/app/settings.segments/_index.segment.rsc +1 -1
- package/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/settings.segments/settings.segment.rsc +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +2 -2
- package/package.json +1 -2
- package/src/app/HomeClient.tsx +0 -207
- package/src/app/agents/[agentId]/agent-editor-tabs.tsx +0 -298
- package/src/app/agents/[agentId]/agent-editor.tsx +0 -468
- package/src/app/agents/[agentId]/page.tsx +0 -32
- package/src/app/api/__tests__/agents-add-route.test.ts +0 -143
- package/src/app/api/__tests__/agents-file-route.test.ts +0 -117
- package/src/app/api/__tests__/agents-files-route.test.ts +0 -61
- package/src/app/api/__tests__/agents-id-route.test.ts +0 -104
- package/src/app/api/__tests__/agents-identity-route.test.ts +0 -92
- package/src/app/api/__tests__/agents-route.test.ts +0 -54
- package/src/app/api/__tests__/agents-skills-install-route.test.ts +0 -131
- package/src/app/api/__tests__/agents-skills-route.test.ts +0 -64
- package/src/app/api/__tests__/agents-update-route.test.ts +0 -95
- package/src/app/api/__tests__/channels-bindings-route.test.ts +0 -143
- package/src/app/api/__tests__/cron-delete-route.test.ts +0 -93
- package/src/app/api/__tests__/cron-job-route.test.ts +0 -78
- package/src/app/api/__tests__/cron-jobs-route.test.ts +0 -116
- package/src/app/api/__tests__/cron-recipe-installed-route.test.ts +0 -114
- package/src/app/api/__tests__/gateway-restart-route.test.ts +0 -36
- package/src/app/api/__tests__/goals-promote-route.test.ts +0 -200
- package/src/app/api/__tests__/goals-route.test.ts +0 -184
- package/src/app/api/__tests__/ids-check-route.test.ts +0 -188
- package/src/app/api/__tests__/marketplace-recipes-route.test.ts +0 -123
- package/src/app/api/__tests__/recipes-clone-route.test.ts +0 -221
- package/src/app/api/__tests__/recipes-delete-route.test.ts +0 -248
- package/src/app/api/__tests__/recipes-id-route.test.ts +0 -166
- package/src/app/api/__tests__/recipes-route.test.ts +0 -57
- package/src/app/api/__tests__/recipes-team-agents-route.test.ts +0 -135
- package/src/app/api/__tests__/scaffold-route.test.ts +0 -173
- package/src/app/api/__tests__/settings-cron-installation-route.test.ts +0 -82
- package/src/app/api/__tests__/skills-available-route.test.ts +0 -47
- package/src/app/api/__tests__/swarms-start-route.test.ts +0 -79
- package/src/app/api/__tests__/swarms-status-route.test.ts +0 -42
- package/src/app/api/__tests__/teams-file-route.test.ts +0 -129
- package/src/app/api/__tests__/teams-files-route.test.ts +0 -57
- package/src/app/api/__tests__/teams-meta-route.test.ts +0 -113
- package/src/app/api/__tests__/teams-orchestrator-install-route.test.ts +0 -66
- package/src/app/api/__tests__/teams-orchestrator-route.test.ts +0 -59
- package/src/app/api/__tests__/teams-remove-team-route.test.ts +0 -122
- package/src/app/api/__tests__/teams-skills-install-route.test.ts +0 -78
- package/src/app/api/__tests__/teams-skills-route.test.ts +0 -73
- package/src/app/api/__tests__/teams-workflow-runs-route.test.ts +0 -85
- package/src/app/api/__tests__/teams-workflows-route.test.ts +0 -110
- package/src/app/api/__tests__/tickets-move-route.test.ts +0 -60
- package/src/app/api/agents/[id]/route.ts +0 -83
- package/src/app/api/agents/add/route.ts +0 -114
- package/src/app/api/agents/file/route.ts +0 -45
- package/src/app/api/agents/files/route.ts +0 -23
- package/src/app/api/agents/identity/route.ts +0 -41
- package/src/app/api/agents/route.ts +0 -22
- package/src/app/api/agents/skills/install/route.ts +0 -34
- package/src/app/api/agents/skills/route.ts +0 -39
- package/src/app/api/agents/update/route.ts +0 -52
- package/src/app/api/channels/bindings/route.ts +0 -63
- package/src/app/api/cron/__tests__/helpers.test.ts +0 -164
- package/src/app/api/cron/delete/route.ts +0 -23
- package/src/app/api/cron/helpers.ts +0 -172
- package/src/app/api/cron/job/route.ts +0 -22
- package/src/app/api/cron/jobs/route.ts +0 -52
- package/src/app/api/cron/recipe-installed/route.ts +0 -65
- package/src/app/api/gateway/restart/route.ts +0 -20
- package/src/app/api/goals/[id]/promote/route.ts +0 -119
- package/src/app/api/goals/[id]/route.ts +0 -54
- package/src/app/api/goals/route.ts +0 -44
- package/src/app/api/ids/check/route.ts +0 -113
- package/src/app/api/marketplace/recipes/[slug]/route.ts +0 -16
- package/src/app/api/marketplace/recipes/route.ts +0 -22
- package/src/app/api/recipes/[id]/route.ts +0 -62
- package/src/app/api/recipes/clone/route.ts +0 -106
- package/src/app/api/recipes/custom-team/route.ts +0 -193
- package/src/app/api/recipes/delete/helpers.ts +0 -65
- package/src/app/api/recipes/delete/route.ts +0 -73
- package/src/app/api/recipes/route.ts +0 -21
- package/src/app/api/recipes/team-agents/__tests__/helpers.test.ts +0 -156
- package/src/app/api/recipes/team-agents/helpers.ts +0 -151
- package/src/app/api/recipes/team-agents/route.ts +0 -80
- package/src/app/api/scaffold/__tests__/helpers.test.ts +0 -186
- package/src/app/api/scaffold/helpers.ts +0 -214
- package/src/app/api/scaffold/route.ts +0 -95
- package/src/app/api/settings/cron-installation/route.ts +0 -58
- package/src/app/api/skills/available/route.ts +0 -23
- package/src/app/api/swarms/start/route.ts +0 -100
- package/src/app/api/swarms/status/route.ts +0 -31
- package/src/app/api/teams/[teamId]/tickets/assign/route.ts +0 -105
- package/src/app/api/teams/[teamId]/tickets/assignees/route.ts +0 -27
- package/src/app/api/teams/[teamId]/tickets/delete/route.ts +0 -55
- package/src/app/api/teams/[teamId]/tickets/move/route.ts +0 -70
- package/src/app/api/teams/[teamId]/tickets/move-to-goals/route.ts +0 -56
- package/src/app/api/teams/file/route.ts +0 -46
- package/src/app/api/teams/files/route.ts +0 -63
- package/src/app/api/teams/memory/route.ts +0 -250
- package/src/app/api/teams/meta/route.ts +0 -43
- package/src/app/api/teams/orchestrator/install/route.ts +0 -129
- package/src/app/api/teams/orchestrator/route.ts +0 -216
- package/src/app/api/teams/remove-team/route.ts +0 -37
- package/src/app/api/teams/skills/install/route.ts +0 -18
- package/src/app/api/teams/skills/route.ts +0 -25
- package/src/app/api/teams/workflow-runs/route.ts +0 -534
- package/src/app/api/teams/workflow-templates/route.ts +0 -71
- package/src/app/api/teams/workflows/route.ts +0 -55
- package/src/app/api/tickets/assign/route.ts +0 -94
- package/src/app/api/tickets/assignees/route.ts +0 -24
- package/src/app/api/tickets/move/route.ts +0 -69
- package/src/app/channels/channels-client.tsx +0 -271
- package/src/app/channels/page.tsx +0 -5
- package/src/app/cron-jobs/cron-jobs-client.tsx +0 -243
- package/src/app/cron-jobs/page.tsx +0 -34
- package/src/app/favicon.ico +0 -0
- package/src/app/global-error.tsx +0 -50
- package/src/app/globals.css +0 -153
- package/src/app/goals/[id]/goal-editor.tsx +0 -162
- package/src/app/goals/[id]/page.tsx +0 -6
- package/src/app/goals/goals-client.tsx +0 -201
- package/src/app/goals/new/page.tsx +0 -81
- package/src/app/goals/page.tsx +0 -10
- package/src/app/layout.tsx +0 -53
- package/src/app/manifest.ts +0 -15
- package/src/app/not-found.tsx +0 -8
- package/src/app/page.tsx +0 -33
- package/src/app/recipes/CreateAgentModal.tsx +0 -156
- package/src/app/recipes/CreateCustomTeamModal.tsx +0 -375
- package/src/app/recipes/CreateModalShell.tsx +0 -55
- package/src/app/recipes/CreateTeamModal.tsx +0 -91
- package/src/app/recipes/[id]/RecipeEditor/RecipeEditorCreateModal.tsx +0 -72
- package/src/app/recipes/[id]/RecipeEditor/RecipeEditorPanel.tsx +0 -216
- package/src/app/recipes/[id]/RecipeEditor/index.tsx +0 -271
- package/src/app/recipes/[id]/RecipeEditor/recipe-editor-utils.ts +0 -46
- package/src/app/recipes/[id]/RecipeEditor/types.ts +0 -52
- package/src/app/recipes/[id]/page.tsx +0 -37
- package/src/app/recipes/page.tsx +0 -101
- package/src/app/recipes/recipes-client.tsx +0 -620
- package/src/app/settings/page.tsx +0 -26
- package/src/app/settings/settings-client.tsx +0 -91
- package/src/app/teams/[teamId]/CloneTeamModal.tsx +0 -116
- package/src/app/teams/[teamId]/OrchestratorPanel.tsx +0 -255
- package/src/app/teams/[teamId]/OrchestratorSetupModal.tsx +0 -184
- package/src/app/teams/[teamId]/PublishChangesModal.tsx +0 -43
- package/src/app/teams/[teamId]/page.tsx +0 -49
- package/src/app/teams/[teamId]/team-editor/TeamAgentsTab.tsx +0 -145
- package/src/app/teams/[teamId]/team-editor/TeamCronTab.tsx +0 -72
- package/src/app/teams/[teamId]/team-editor/TeamFilesTab.tsx +0 -74
- package/src/app/teams/[teamId]/team-editor/TeamMemoryTab.tsx +0 -349
- package/src/app/teams/[teamId]/team-editor/TeamRecipeTab.tsx +0 -151
- package/src/app/teams/[teamId]/team-editor/TeamSkillsTab.tsx +0 -68
- package/src/app/teams/[teamId]/team-editor/index.tsx +0 -558
- package/src/app/teams/[teamId]/team-editor/team-editor-data.ts +0 -255
- package/src/app/teams/[teamId]/team-editor/team-editor-utils.ts +0 -78
- package/src/app/teams/[teamId]/team-editor/types.ts +0 -34
- package/src/app/teams/[teamId]/tickets/[ticket]/page.tsx +0 -35
- package/src/app/teams/[teamId]/tickets/page.tsx +0 -15
- package/src/app/teams/[teamId]/workflows/[workflowId]/WorkflowCanvas.tsx +0 -111
- package/src/app/teams/[teamId]/workflows/[workflowId]/page.tsx +0 -27
- package/src/app/teams/[teamId]/workflows/[workflowId]/workflows-editor-client.tsx +0 -1608
- package/src/app/teams/[teamId]/workflows/page.tsx +0 -40
- package/src/app/teams/[teamId]/workflows/workflows-client.tsx +0 -494
- package/src/app/tickets/TicketDetailClient.tsx +0 -147
- package/src/app/tickets/TicketsBoardClient.tsx +0 -200
- package/src/app/tickets/[ticket]/TicketAssignControl.tsx +0 -112
- package/src/app/tickets/[ticket]/page.tsx +0 -36
- package/src/app/tickets/page.tsx +0 -10
- package/src/components/AppShell.tsx +0 -286
- package/src/components/ConfirmationModal.tsx +0 -81
- package/src/components/DeleteEntityModal.tsx +0 -41
- package/src/components/ErrorBoundary.tsx +0 -70
- package/src/components/FileListWithOptionalToggle.tsx +0 -86
- package/src/components/GoalFormFields.tsx +0 -163
- package/src/components/ScaffoldOverlay.tsx +0 -78
- package/src/components/ThemeToggle.tsx +0 -53
- package/src/components/ToastProvider.tsx +0 -163
- package/src/components/__tests__/ConfirmationModal.test.tsx +0 -109
- package/src/components/__tests__/ErrorBoundary.test.tsx +0 -39
- package/src/components/__tests__/FileListWithOptionalToggle.test.tsx +0 -109
- package/src/components/__tests__/GoalFormFields.test.tsx +0 -117
- package/src/components/delete-modals.tsx +0 -59
- package/src/components/icons.tsx +0 -48
- package/src/lib/__tests__/agent-workspace.test.ts +0 -44
- package/src/lib/__tests__/agents.test.ts +0 -36
- package/src/lib/__tests__/api-route-helpers.test.ts +0 -188
- package/src/lib/__tests__/cron.test.ts +0 -45
- package/src/lib/__tests__/editor-utils.test.ts +0 -38
- package/src/lib/__tests__/errors.test.ts +0 -15
- package/src/lib/__tests__/exec.test.ts +0 -13
- package/src/lib/__tests__/fetch-json.test.ts +0 -118
- package/src/lib/__tests__/gateway.test.ts +0 -234
- package/src/lib/__tests__/goal-promote.test.ts +0 -39
- package/src/lib/__tests__/goals-client.test.ts +0 -26
- package/src/lib/__tests__/goals.test.ts +0 -275
- package/src/lib/__tests__/json.test.ts +0 -15
- package/src/lib/__tests__/kitchen-api.test.ts +0 -32
- package/src/lib/__tests__/marketplace.test.ts +0 -116
- package/src/lib/__tests__/openclaw.test.ts +0 -129
- package/src/lib/__tests__/paths.test.ts +0 -136
- package/src/lib/__tests__/poll.test.ts +0 -26
- package/src/lib/__tests__/recipe-clone.test.ts +0 -85
- package/src/lib/__tests__/recipe-team-agents.test.ts +0 -70
- package/src/lib/__tests__/recipes.test.ts +0 -199
- package/src/lib/__tests__/scaffold-client.test.ts +0 -106
- package/src/lib/__tests__/scaffold.test.ts +0 -64
- package/src/lib/__tests__/slugify.test.ts +0 -23
- package/src/lib/__tests__/tickets.test.ts +0 -158
- package/src/lib/__tests__/type-guards.test.ts +0 -18
- package/src/lib/__tests__/use-slugified-id.test.tsx +0 -120
- package/src/lib/agent-workspace.ts +0 -14
- package/src/lib/agents.ts +0 -17
- package/src/lib/api-route-helpers.ts +0 -157
- package/src/lib/cron.ts +0 -40
- package/src/lib/editor-utils.ts +0 -18
- package/src/lib/errors.ts +0 -7
- package/src/lib/exec.ts +0 -4
- package/src/lib/fetch-json.ts +0 -29
- package/src/lib/gateway.ts +0 -100
- package/src/lib/goal-promote.ts +0 -27
- package/src/lib/goals-client.ts +0 -69
- package/src/lib/goals.ts +0 -171
- package/src/lib/json.ts +0 -10
- package/src/lib/kitchen-api.ts +0 -19
- package/src/lib/marketplace.ts +0 -46
- package/src/lib/openclaw.ts +0 -59
- package/src/lib/paths.ts +0 -69
- package/src/lib/poll.ts +0 -18
- package/src/lib/recipe-clone.ts +0 -42
- package/src/lib/recipe-team-agents.ts +0 -30
- package/src/lib/recipes.ts +0 -95
- package/src/lib/scaffold-client.ts +0 -31
- package/src/lib/scaffold.ts +0 -37
- package/src/lib/slugify.ts +0 -25
- package/src/lib/swarms.ts +0 -25
- package/src/lib/tickets.ts +0 -192
- package/src/lib/type-guards.ts +0 -3
- package/src/lib/use-slugified-id.ts +0 -35
- package/src/lib/workflows/README.md +0 -11
- package/src/lib/workflows/__tests__/storage.test.ts +0 -129
- package/src/lib/workflows/__tests__/validate.test.ts +0 -92
- package/src/lib/workflows/api-handlers.ts +0 -35
- package/src/lib/workflows/readdir.ts +0 -23
- package/src/lib/workflows/runs-storage.ts +0 -59
- package/src/lib/workflows/runs-types.ts +0 -42
- package/src/lib/workflows/storage.ts +0 -70
- package/src/lib/workflows/templates/index.ts +0 -1
- package/src/lib/workflows/templates/marketing-cadence-v1.ts +0 -142
- package/src/lib/workflows/types.ts +0 -48
- package/src/lib/workflows/validate.ts +0 -92
- package/src/proxy.ts +0 -28
- /package/.next/static/{z86RoqzzXXrWnpi229zP6 → Jrrrm9HH5bKkSrQhe1j93}/_buildManifest.js +0 -0
- /package/.next/static/{z86RoqzzXXrWnpi229zP6 → Jrrrm9HH5bKkSrQhe1j93}/_clientMiddlewareManifest.json +0 -0
- /package/.next/static/{z86RoqzzXXrWnpi229zP6 → Jrrrm9HH5bKkSrQhe1j93}/_ssgManifest.js +0 -0
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { POST } from "../recipes/team-agents/route";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
|
|
5
|
-
vi.mock("@/lib/paths", () => ({ getWorkspaceRecipesDir: vi.fn() }));
|
|
6
|
-
vi.mock("node:fs/promises", () => ({
|
|
7
|
-
default: { readFile: vi.fn(), writeFile: vi.fn() },
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
import { getWorkspaceRecipesDir } from "@/lib/paths";
|
|
11
|
-
import fs from "node:fs/promises";
|
|
12
|
-
|
|
13
|
-
const teamRecipeMd = `---
|
|
14
|
-
kind: team
|
|
15
|
-
agents:
|
|
16
|
-
- role: lead
|
|
17
|
-
name: Lead
|
|
18
|
-
---
|
|
19
|
-
# Team body`;
|
|
20
|
-
|
|
21
|
-
describe("api recipes team-agents route", () => {
|
|
22
|
-
const dir = "/mock-workspace/recipes";
|
|
23
|
-
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
vi.mocked(getWorkspaceRecipesDir).mockReset();
|
|
26
|
-
vi.mocked(fs.readFile).mockReset();
|
|
27
|
-
vi.mocked(fs.writeFile).mockReset();
|
|
28
|
-
|
|
29
|
-
vi.mocked(getWorkspaceRecipesDir).mockResolvedValue(dir);
|
|
30
|
-
vi.mocked(fs.readFile).mockResolvedValue(teamRecipeMd);
|
|
31
|
-
vi.mocked(fs.writeFile).mockResolvedValue(undefined);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("returns 400 when recipeId missing", async () => {
|
|
35
|
-
const res = await POST(
|
|
36
|
-
new Request("https://test", {
|
|
37
|
-
method: "POST",
|
|
38
|
-
body: JSON.stringify({ op: "add", role: "qa" }),
|
|
39
|
-
})
|
|
40
|
-
);
|
|
41
|
-
expect(res.status).toBe(400);
|
|
42
|
-
const json = await res.json();
|
|
43
|
-
expect(json.error).toBe("recipeId is required");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("returns 400 when op invalid", async () => {
|
|
47
|
-
const res = await POST(
|
|
48
|
-
new Request("https://test", {
|
|
49
|
-
method: "POST",
|
|
50
|
-
body: JSON.stringify({ recipeId: "my-team", op: "invalid", role: "qa" }),
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
expect(res.status).toBe(400);
|
|
54
|
-
const json = await res.json();
|
|
55
|
-
expect(json.error).toBe("op must be add|remove|addLike");
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("throws when role invalid", async () => {
|
|
59
|
-
await expect(
|
|
60
|
-
POST(
|
|
61
|
-
new Request("https://test", {
|
|
62
|
-
method: "POST",
|
|
63
|
-
body: JSON.stringify({ recipeId: "my-team", op: "add", role: "" }),
|
|
64
|
-
})
|
|
65
|
-
)
|
|
66
|
-
).rejects.toThrow("role is required");
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("returns 400 when kind is not team", async () => {
|
|
70
|
-
vi.mocked(fs.readFile).mockResolvedValue(`---
|
|
71
|
-
kind: agent
|
|
72
|
-
---
|
|
73
|
-
# Body`);
|
|
74
|
-
|
|
75
|
-
const res = await POST(
|
|
76
|
-
new Request("https://test", {
|
|
77
|
-
method: "POST",
|
|
78
|
-
body: JSON.stringify({ recipeId: "agent-recipe", op: "add", role: "qa" }),
|
|
79
|
-
})
|
|
80
|
-
);
|
|
81
|
-
expect(res.status).toBe(400);
|
|
82
|
-
const json = await res.json();
|
|
83
|
-
expect(json.error).toContain("kind must be team");
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("adds agent and returns ok", async () => {
|
|
87
|
-
const res = await POST(
|
|
88
|
-
new Request("https://test", {
|
|
89
|
-
method: "POST",
|
|
90
|
-
body: JSON.stringify({
|
|
91
|
-
recipeId: "my-team",
|
|
92
|
-
op: "add",
|
|
93
|
-
role: "qa",
|
|
94
|
-
name: "QA",
|
|
95
|
-
}),
|
|
96
|
-
})
|
|
97
|
-
);
|
|
98
|
-
expect(res.status).toBe(200);
|
|
99
|
-
const json = await res.json();
|
|
100
|
-
expect(json.ok).toBe(true);
|
|
101
|
-
expect(json.recipeId).toBe("my-team");
|
|
102
|
-
expect(json.agents).toContainEqual(expect.objectContaining({ role: "qa", name: "QA" }));
|
|
103
|
-
expect(fs.writeFile).toHaveBeenCalledWith(
|
|
104
|
-
path.join(dir, "my-team.md"),
|
|
105
|
-
expect.stringContaining("role: qa"),
|
|
106
|
-
"utf8"
|
|
107
|
-
);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("removes agent", async () => {
|
|
111
|
-
const res = await POST(
|
|
112
|
-
new Request("https://test", {
|
|
113
|
-
method: "POST",
|
|
114
|
-
body: JSON.stringify({ recipeId: "my-team", op: "remove", role: "lead" }),
|
|
115
|
-
})
|
|
116
|
-
);
|
|
117
|
-
expect(res.status).toBe(200);
|
|
118
|
-
const json = await res.json();
|
|
119
|
-
expect(json.ok).toBe(true);
|
|
120
|
-
expect(json.agents).not.toContainEqual(expect.objectContaining({ role: "lead" }));
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it("throws when fs.readFile fails", async () => {
|
|
124
|
-
vi.mocked(fs.readFile).mockRejectedValue(new Error("ENOENT"));
|
|
125
|
-
|
|
126
|
-
await expect(
|
|
127
|
-
POST(
|
|
128
|
-
new Request("https://test", {
|
|
129
|
-
method: "POST",
|
|
130
|
-
body: JSON.stringify({ recipeId: "missing", op: "add", role: "qa" }),
|
|
131
|
-
})
|
|
132
|
-
)
|
|
133
|
-
).rejects.toThrow();
|
|
134
|
-
});
|
|
135
|
-
});
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { POST } from "../scaffold/route";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
|
|
5
|
-
vi.mock("@/lib/openclaw", () => ({ runOpenClaw: vi.fn() }));
|
|
6
|
-
vi.mock("@/lib/paths", async (importOriginal) => {
|
|
7
|
-
const actual = await importOriginal<typeof import("@/lib/paths")>();
|
|
8
|
-
return { ...actual, readOpenClawConfig: vi.fn() };
|
|
9
|
-
});
|
|
10
|
-
vi.mock("node:fs/promises", () => ({
|
|
11
|
-
default: { mkdir: vi.fn(), writeFile: vi.fn() },
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
import { runOpenClaw } from "@/lib/openclaw";
|
|
15
|
-
import { readOpenClawConfig } from "@/lib/paths";
|
|
16
|
-
import fs from "node:fs/promises";
|
|
17
|
-
|
|
18
|
-
describe("api scaffold route", () => {
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
vi.mocked(runOpenClaw).mockReset();
|
|
21
|
-
vi.mocked(readOpenClawConfig).mockReset();
|
|
22
|
-
vi.mocked(fs.mkdir).mockReset();
|
|
23
|
-
vi.mocked(fs.writeFile).mockReset();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("returns ok on agent scaffold success", async () => {
|
|
27
|
-
vi.mocked(runOpenClaw).mockResolvedValue({
|
|
28
|
-
ok: true,
|
|
29
|
-
exitCode: 0,
|
|
30
|
-
stdout: "Done",
|
|
31
|
-
stderr: "",
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const res = await POST(
|
|
35
|
-
new Request("https://test", {
|
|
36
|
-
method: "POST",
|
|
37
|
-
body: JSON.stringify({ kind: "agent", recipeId: "my-agent" }),
|
|
38
|
-
})
|
|
39
|
-
);
|
|
40
|
-
expect(res.status).toBe(200);
|
|
41
|
-
const json = await res.json();
|
|
42
|
-
expect(json.ok).toBe(true);
|
|
43
|
-
expect(json.args).toEqual(["recipes", "scaffold", "my-agent"]);
|
|
44
|
-
expect(runOpenClaw).toHaveBeenCalledWith(["recipes", "scaffold", "my-agent"]);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("returns ok on team scaffold success", async () => {
|
|
48
|
-
vi.mocked(runOpenClaw).mockResolvedValue({
|
|
49
|
-
ok: true,
|
|
50
|
-
exitCode: 0,
|
|
51
|
-
stdout: "Done",
|
|
52
|
-
stderr: "",
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const res = await POST(
|
|
56
|
-
new Request("https://test", {
|
|
57
|
-
method: "POST",
|
|
58
|
-
body: JSON.stringify({
|
|
59
|
-
kind: "team",
|
|
60
|
-
recipeId: "my-team",
|
|
61
|
-
teamId: "my-team",
|
|
62
|
-
}),
|
|
63
|
-
})
|
|
64
|
-
);
|
|
65
|
-
expect(res.status).toBe(200);
|
|
66
|
-
const json = await res.json();
|
|
67
|
-
expect(json.ok).toBe(true);
|
|
68
|
-
expect(json.args).toContain("scaffold-team");
|
|
69
|
-
expect(json.args).toContain("--team-id");
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("returns 500 when runOpenClaw throws", async () => {
|
|
73
|
-
vi.mocked(runOpenClaw).mockRejectedValue(new Error("Command failed"));
|
|
74
|
-
|
|
75
|
-
const res = await POST(
|
|
76
|
-
new Request("https://test", {
|
|
77
|
-
method: "POST",
|
|
78
|
-
body: JSON.stringify({ kind: "agent", recipeId: "my-agent" }),
|
|
79
|
-
})
|
|
80
|
-
);
|
|
81
|
-
expect(res.status).toBe(500);
|
|
82
|
-
const json = await res.json();
|
|
83
|
-
expect(json.ok).toBe(false);
|
|
84
|
-
expect(json.error).toBe("Command failed");
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("applies cron override when cronInstallChoice yes", async () => {
|
|
88
|
-
vi.mocked(runOpenClaw)
|
|
89
|
-
.mockResolvedValueOnce({ ok: true, exitCode: 0, stdout: "hash", stderr: "" })
|
|
90
|
-
.mockResolvedValueOnce({ ok: true, exitCode: 0, stdout: JSON.stringify([]), stderr: "" })
|
|
91
|
-
.mockResolvedValueOnce({ ok: true, exitCode: 0, stdout: "off", stderr: "" })
|
|
92
|
-
.mockResolvedValueOnce({ ok: true, exitCode: 0, stdout: "", stderr: "" })
|
|
93
|
-
.mockResolvedValueOnce({ ok: true, exitCode: 0, stdout: "Done", stderr: "" })
|
|
94
|
-
.mockResolvedValueOnce({ ok: true, exitCode: 0, stdout: "", stderr: "" });
|
|
95
|
-
|
|
96
|
-
const res = await POST(
|
|
97
|
-
new Request("https://test", {
|
|
98
|
-
method: "POST",
|
|
99
|
-
body: JSON.stringify({
|
|
100
|
-
kind: "agent",
|
|
101
|
-
recipeId: "my-agent",
|
|
102
|
-
cronInstallChoice: "yes",
|
|
103
|
-
}),
|
|
104
|
-
})
|
|
105
|
-
);
|
|
106
|
-
expect(res.status).toBe(200);
|
|
107
|
-
const calls = vi.mocked(runOpenClaw).mock.calls;
|
|
108
|
-
const configGetCalls = calls.filter((c) => c[0]?.[0] === "config" && c[0]?.[1] === "get");
|
|
109
|
-
const configSetCalls = calls.filter((c) => c[0]?.[0] === "config" && c[0]?.[1] === "set");
|
|
110
|
-
expect(configGetCalls.length).toBeGreaterThanOrEqual(1);
|
|
111
|
-
expect(configSetCalls.length).toBeGreaterThanOrEqual(2);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("persists team provenance on team scaffold", async () => {
|
|
115
|
-
vi.mocked(runOpenClaw).mockResolvedValue({
|
|
116
|
-
ok: true,
|
|
117
|
-
exitCode: 0,
|
|
118
|
-
stdout: "Done",
|
|
119
|
-
stderr: "",
|
|
120
|
-
});
|
|
121
|
-
vi.mocked(readOpenClawConfig).mockResolvedValue({
|
|
122
|
-
agents: { defaults: { workspace: "/mock-workspace" } },
|
|
123
|
-
});
|
|
124
|
-
vi.mocked(fs.mkdir).mockResolvedValue(undefined);
|
|
125
|
-
vi.mocked(fs.writeFile).mockResolvedValue(undefined);
|
|
126
|
-
|
|
127
|
-
const res = await POST(
|
|
128
|
-
new Request("https://test", {
|
|
129
|
-
method: "POST",
|
|
130
|
-
body: JSON.stringify({
|
|
131
|
-
kind: "team",
|
|
132
|
-
recipeId: "my-team",
|
|
133
|
-
teamId: "my-team",
|
|
134
|
-
}),
|
|
135
|
-
})
|
|
136
|
-
);
|
|
137
|
-
expect(res.status).toBe(200);
|
|
138
|
-
expect(fs.mkdir).toHaveBeenCalledWith(
|
|
139
|
-
path.resolve("/mock-workspace", "..", "workspace-my-team"),
|
|
140
|
-
{ recursive: true }
|
|
141
|
-
);
|
|
142
|
-
expect(fs.writeFile).toHaveBeenCalledWith(
|
|
143
|
-
path.join(path.resolve("/mock-workspace", "..", "workspace-my-team"), "team.json"),
|
|
144
|
-
expect.stringContaining("my-team"),
|
|
145
|
-
"utf8"
|
|
146
|
-
);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it("attempts cron restore in finally when scaffold throws after override", async () => {
|
|
150
|
-
vi.mocked(runOpenClaw)
|
|
151
|
-
.mockResolvedValueOnce({ ok: true, exitCode: 0, stdout: "hash", stderr: "" })
|
|
152
|
-
.mockResolvedValueOnce({ ok: true, exitCode: 0, stdout: JSON.stringify([]), stderr: "" })
|
|
153
|
-
.mockResolvedValueOnce({ ok: true, exitCode: 0, stdout: "off", stderr: "" })
|
|
154
|
-
.mockResolvedValueOnce({ ok: true, exitCode: 0, stdout: "", stderr: "" })
|
|
155
|
-
.mockRejectedValueOnce(new Error("Scaffold failed"))
|
|
156
|
-
.mockResolvedValueOnce({ ok: true, exitCode: 0, stdout: "", stderr: "" });
|
|
157
|
-
|
|
158
|
-
const res = await POST(
|
|
159
|
-
new Request("https://test", {
|
|
160
|
-
method: "POST",
|
|
161
|
-
body: JSON.stringify({
|
|
162
|
-
kind: "agent",
|
|
163
|
-
recipeId: "my-agent",
|
|
164
|
-
cronInstallChoice: "yes",
|
|
165
|
-
}),
|
|
166
|
-
})
|
|
167
|
-
);
|
|
168
|
-
expect(res.status).toBe(500);
|
|
169
|
-
const calls = vi.mocked(runOpenClaw).mock.calls;
|
|
170
|
-
const configSetCalls = calls.filter((c) => c[0]?.[0] === "config" && c[0]?.[1] === "set");
|
|
171
|
-
expect(configSetCalls.length).toBeGreaterThanOrEqual(2);
|
|
172
|
-
});
|
|
173
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { GET, PUT } from "../settings/cron-installation/route";
|
|
3
|
-
|
|
4
|
-
vi.mock("@/lib/gateway", () => ({
|
|
5
|
-
gatewayConfigGet: vi.fn(),
|
|
6
|
-
gatewayConfigPatch: vi.fn(),
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
import { gatewayConfigGet, gatewayConfigPatch } from "@/lib/gateway";
|
|
10
|
-
|
|
11
|
-
describe("api settings cron-installation route", () => {
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
vi.mocked(gatewayConfigGet).mockReset();
|
|
14
|
-
vi.mocked(gatewayConfigPatch).mockReset();
|
|
15
|
-
|
|
16
|
-
vi.mocked(gatewayConfigGet).mockResolvedValue({
|
|
17
|
-
raw: JSON.stringify({
|
|
18
|
-
plugins: {
|
|
19
|
-
entries: { recipes: { config: { cronInstallation: "prompt" } } },
|
|
20
|
-
},
|
|
21
|
-
}),
|
|
22
|
-
hash: "abc",
|
|
23
|
-
});
|
|
24
|
-
vi.mocked(gatewayConfigPatch).mockResolvedValue(undefined);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
describe("GET", () => {
|
|
28
|
-
it("returns path and value", async () => {
|
|
29
|
-
const res = await GET();
|
|
30
|
-
expect(res.status).toBe(200);
|
|
31
|
-
const json = await res.json();
|
|
32
|
-
expect(json.ok).toBe(true);
|
|
33
|
-
expect(json.path).toBe("plugins.entries.recipes.config.cronInstallation");
|
|
34
|
-
expect(json.value).toBe("prompt");
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe("PUT", () => {
|
|
39
|
-
it("returns 400 when value invalid", async () => {
|
|
40
|
-
const r1 = await PUT(
|
|
41
|
-
new Request("https://test", {
|
|
42
|
-
method: "PUT",
|
|
43
|
-
body: JSON.stringify({ value: "invalid" }),
|
|
44
|
-
})
|
|
45
|
-
);
|
|
46
|
-
expect(r1.status).toBe(400);
|
|
47
|
-
expect((await r1.json()).error).toContain("off|prompt|on");
|
|
48
|
-
|
|
49
|
-
const r2 = await PUT(
|
|
50
|
-
new Request("https://test", {
|
|
51
|
-
method: "PUT",
|
|
52
|
-
body: JSON.stringify({}),
|
|
53
|
-
})
|
|
54
|
-
);
|
|
55
|
-
expect(r2.status).toBe(400);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("returns ok and patches on valid value", async () => {
|
|
59
|
-
const res = await PUT(
|
|
60
|
-
new Request("https://test", {
|
|
61
|
-
method: "PUT",
|
|
62
|
-
body: JSON.stringify({ value: "on" }),
|
|
63
|
-
})
|
|
64
|
-
);
|
|
65
|
-
expect(res.status).toBe(200);
|
|
66
|
-
const json = await res.json();
|
|
67
|
-
expect(json.value).toBe("on");
|
|
68
|
-
expect(gatewayConfigPatch).toHaveBeenCalledWith(
|
|
69
|
-
expect.objectContaining({
|
|
70
|
-
plugins: {
|
|
71
|
-
entries: {
|
|
72
|
-
recipes: {
|
|
73
|
-
config: { cronInstallation: "on" },
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
}),
|
|
78
|
-
expect.any(String)
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { GET } from "../skills/available/route";
|
|
3
|
-
|
|
4
|
-
vi.mock("node:fs/promises", () => ({
|
|
5
|
-
default: { readdir: vi.fn() },
|
|
6
|
-
}));
|
|
7
|
-
vi.mock("node:os", () => ({
|
|
8
|
-
default: { homedir: () => "/home/user" },
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
import fs from "node:fs/promises";
|
|
12
|
-
|
|
13
|
-
describe("api skills available route", () => {
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
vi.mocked(fs.readdir).mockReset();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("returns skills from ~/.openclaw/skills", async () => {
|
|
19
|
-
vi.mocked(fs.readdir).mockResolvedValue([
|
|
20
|
-
{ name: "skill-a", isDirectory: () => true } as never,
|
|
21
|
-
{ name: "skill-b", isDirectory: () => true } as never,
|
|
22
|
-
{ name: "file.txt", isDirectory: () => false } as never,
|
|
23
|
-
] as never[]);
|
|
24
|
-
|
|
25
|
-
const res = await GET();
|
|
26
|
-
expect(res.status).toBe(200);
|
|
27
|
-
const json = await res.json();
|
|
28
|
-
expect(json.ok).toBe(true);
|
|
29
|
-
expect(json.skillsDir).toContain(".openclaw/skills");
|
|
30
|
-
expect(json.skills).toEqual(["skill-a", "skill-b"]);
|
|
31
|
-
expect(fs.readdir).toHaveBeenCalledWith(
|
|
32
|
-
expect.stringContaining(".openclaw/skills"),
|
|
33
|
-
{ withFileTypes: true }
|
|
34
|
-
);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("returns empty skills when dir missing", async () => {
|
|
38
|
-
vi.mocked(fs.readdir).mockRejectedValue(new Error("ENOENT"));
|
|
39
|
-
|
|
40
|
-
const res = await GET();
|
|
41
|
-
expect(res.status).toBe(200);
|
|
42
|
-
const json = await res.json();
|
|
43
|
-
expect(json.ok).toBe(true);
|
|
44
|
-
expect(json.skills).toEqual([]);
|
|
45
|
-
expect(json.note).toBe("ENOENT");
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { POST } from "../swarms/start/route";
|
|
3
|
-
|
|
4
|
-
vi.mock("@/lib/kitchen-api", () => ({
|
|
5
|
-
getKitchenApi: vi.fn(() => ({
|
|
6
|
-
runtime: {
|
|
7
|
-
system: {
|
|
8
|
-
runCommandWithTimeout: vi.fn().mockResolvedValue({ stdout: "", stderr: "" }),
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
})),
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
vi.mock("node:fs/promises", () => ({
|
|
15
|
-
default: {
|
|
16
|
-
access: vi.fn().mockResolvedValue(undefined),
|
|
17
|
-
writeFile: vi.fn().mockResolvedValue(undefined),
|
|
18
|
-
unlink: vi.fn().mockResolvedValue(undefined),
|
|
19
|
-
},
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
describe("api swarms start route", () => {
|
|
23
|
-
beforeEach(() => {
|
|
24
|
-
vi.clearAllMocks();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("returns 400 when orchestratorAgentId missing", async () => {
|
|
28
|
-
const res = await POST(
|
|
29
|
-
new Request("https://test", {
|
|
30
|
-
method: "POST",
|
|
31
|
-
body: JSON.stringify({ taskId: "t1", spec: "do something" }),
|
|
32
|
-
})
|
|
33
|
-
);
|
|
34
|
-
expect(res.status).toBe(400);
|
|
35
|
-
const json = await res.json();
|
|
36
|
-
expect(json.error).toMatch(/orchestratorAgentId.*required/i);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("returns 400 when taskId missing", async () => {
|
|
40
|
-
const res = await POST(
|
|
41
|
-
new Request("https://test", {
|
|
42
|
-
method: "POST",
|
|
43
|
-
body: JSON.stringify({ orchestratorAgentId: "team1-swarm-orchestrator", spec: "do something" }),
|
|
44
|
-
})
|
|
45
|
-
);
|
|
46
|
-
expect(res.status).toBe(400);
|
|
47
|
-
const json = await res.json();
|
|
48
|
-
expect(json.error).toMatch(/taskId.*required/i);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("returns 400 when neither spec nor specFile provided", async () => {
|
|
52
|
-
const res = await POST(
|
|
53
|
-
new Request("https://test", {
|
|
54
|
-
method: "POST",
|
|
55
|
-
body: JSON.stringify({ orchestratorAgentId: "team1-swarm-orchestrator", taskId: "t1" }),
|
|
56
|
-
})
|
|
57
|
-
);
|
|
58
|
-
expect(res.status).toBe(400);
|
|
59
|
-
const json = await res.json();
|
|
60
|
-
expect(json.error).toMatch(/spec|specFile/i);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("returns 400 when both spec and specFile provided", async () => {
|
|
64
|
-
const res = await POST(
|
|
65
|
-
new Request("https://test", {
|
|
66
|
-
method: "POST",
|
|
67
|
-
body: JSON.stringify({
|
|
68
|
-
orchestratorAgentId: "team1-swarm-orchestrator",
|
|
69
|
-
taskId: "t1",
|
|
70
|
-
spec: "x",
|
|
71
|
-
specFile: "/home/test/x.md",
|
|
72
|
-
}),
|
|
73
|
-
})
|
|
74
|
-
);
|
|
75
|
-
expect(res.status).toBe(400);
|
|
76
|
-
const json = await res.json();
|
|
77
|
-
expect(json.error).toMatch(/exactly one/i);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { GET } from "../swarms/status/route";
|
|
3
|
-
|
|
4
|
-
vi.mock("@/lib/kitchen-api", () => ({
|
|
5
|
-
getKitchenApi: vi.fn(() => ({
|
|
6
|
-
runtime: {
|
|
7
|
-
system: {
|
|
8
|
-
runCommandWithTimeout: vi.fn().mockResolvedValue({ stdout: "", stderr: "" }),
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
})),
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
vi.mock("node:fs/promises", () => ({
|
|
15
|
-
default: {
|
|
16
|
-
readFile: vi.fn().mockResolvedValue(JSON.stringify({ agents: { defaults: { workspace: "/home" } } })),
|
|
17
|
-
access: vi.fn().mockResolvedValue(undefined),
|
|
18
|
-
},
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
describe("api swarms status route", () => {
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
vi.clearAllMocks();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("returns 400 when orchestratorAgentId missing", async () => {
|
|
27
|
-
const res = await GET(new Request("https://test"));
|
|
28
|
-
expect(res.status).toBe(400);
|
|
29
|
-
const json = await res.json();
|
|
30
|
-
expect(json.error).toMatch(/orchestratorAgentId.*required/i);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("returns 200 when orchestratorAgentId provided", async () => {
|
|
34
|
-
const res = await GET(
|
|
35
|
-
new Request("https://test?orchestratorAgentId=team1-swarm-orchestrator")
|
|
36
|
-
);
|
|
37
|
-
expect(res.status).toBe(200);
|
|
38
|
-
const json = await res.json();
|
|
39
|
-
expect(json.ok).toBe(true);
|
|
40
|
-
expect(json.orchestratorWorkspace).toBeDefined();
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { GET, PUT } from "../teams/file/route";
|
|
3
|
-
|
|
4
|
-
vi.mock("@/lib/paths", async (importOriginal) => {
|
|
5
|
-
const actual = await importOriginal<typeof import("@/lib/paths")>();
|
|
6
|
-
return { ...actual, readOpenClawConfig: vi.fn() };
|
|
7
|
-
});
|
|
8
|
-
vi.mock("node:fs/promises", () => ({
|
|
9
|
-
default: {
|
|
10
|
-
readFile: vi.fn(),
|
|
11
|
-
mkdir: vi.fn(),
|
|
12
|
-
writeFile: vi.fn(),
|
|
13
|
-
},
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
import { readOpenClawConfig } from "@/lib/paths";
|
|
17
|
-
import fs from "node:fs/promises";
|
|
18
|
-
|
|
19
|
-
describe("api teams file route", () => {
|
|
20
|
-
const baseWorkspace = "/mock-workspace";
|
|
21
|
-
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
vi.mocked(readOpenClawConfig).mockReset();
|
|
24
|
-
vi.mocked(fs.readFile).mockReset();
|
|
25
|
-
vi.mocked(fs.mkdir).mockReset();
|
|
26
|
-
vi.mocked(fs.writeFile).mockReset();
|
|
27
|
-
|
|
28
|
-
vi.mocked(readOpenClawConfig).mockResolvedValue({
|
|
29
|
-
agents: { defaults: { workspace: baseWorkspace } },
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("returns 400 when teamId missing", async () => {
|
|
34
|
-
const res = await GET(new Request("https://test/api/teams/file?name=TEAM.md"));
|
|
35
|
-
expect(res.status).toBe(400);
|
|
36
|
-
const json = await res.json();
|
|
37
|
-
expect(json.error).toBe("teamId is required");
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("returns 400 when name missing", async () => {
|
|
41
|
-
const res = await GET(new Request("https://test/api/teams/file?teamId=my-team"));
|
|
42
|
-
expect(res.status).toBe(400);
|
|
43
|
-
const json = await res.json();
|
|
44
|
-
expect(json.error).toBe("name is required");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("returns 404 when file missing", async () => {
|
|
48
|
-
vi.mocked(fs.readFile).mockRejectedValue(new Error("ENOENT"));
|
|
49
|
-
|
|
50
|
-
const res = await GET(
|
|
51
|
-
new Request("https://test/api/teams/file?teamId=my-team&name=TEAM.md")
|
|
52
|
-
);
|
|
53
|
-
expect(res.status).toBe(404);
|
|
54
|
-
const json = await res.json();
|
|
55
|
-
expect(json.ok).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("returns content on success", async () => {
|
|
59
|
-
vi.mocked(fs.readFile).mockResolvedValue("# Team\n\nContent");
|
|
60
|
-
|
|
61
|
-
const res = await GET(
|
|
62
|
-
new Request("https://test/api/teams/file?teamId=my-team&name=TEAM.md")
|
|
63
|
-
);
|
|
64
|
-
expect(res.status).toBe(200);
|
|
65
|
-
const json = await res.json();
|
|
66
|
-
expect(json.ok).toBe(true);
|
|
67
|
-
expect(json.content).toBe("# Team\n\nContent");
|
|
68
|
-
expect(json.name).toBe("TEAM.md");
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("throws on path traversal in name", async () => {
|
|
72
|
-
await expect(
|
|
73
|
-
GET(new Request("https://test/api/teams/file?teamId=my-team&name=../etc/passwd"))
|
|
74
|
-
).rejects.toThrow("Invalid file name");
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe("PUT", () => {
|
|
78
|
-
it("returns 400 when teamId, name, or content missing", async () => {
|
|
79
|
-
const r1 = await PUT(
|
|
80
|
-
new Request("https://test", {
|
|
81
|
-
method: "PUT",
|
|
82
|
-
body: JSON.stringify({ name: "X", content: "c" }),
|
|
83
|
-
})
|
|
84
|
-
);
|
|
85
|
-
expect(r1.status).toBe(400);
|
|
86
|
-
|
|
87
|
-
const r2 = await PUT(
|
|
88
|
-
new Request("https://test", {
|
|
89
|
-
method: "PUT",
|
|
90
|
-
body: JSON.stringify({ teamId: "my-team", content: "c" }),
|
|
91
|
-
})
|
|
92
|
-
);
|
|
93
|
-
expect(r2.status).toBe(400);
|
|
94
|
-
|
|
95
|
-
const r3 = await PUT(
|
|
96
|
-
new Request("https://test", {
|
|
97
|
-
method: "PUT",
|
|
98
|
-
body: JSON.stringify({ teamId: "my-team", name: "TEAM.md" }),
|
|
99
|
-
})
|
|
100
|
-
);
|
|
101
|
-
expect(r3.status).toBe(400);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("writes file and returns ok", async () => {
|
|
105
|
-
vi.mocked(fs.mkdir).mockResolvedValue(undefined);
|
|
106
|
-
vi.mocked(fs.writeFile).mockResolvedValue(undefined);
|
|
107
|
-
|
|
108
|
-
const res = await PUT(
|
|
109
|
-
new Request("https://test", {
|
|
110
|
-
method: "PUT",
|
|
111
|
-
body: JSON.stringify({
|
|
112
|
-
teamId: "my-team",
|
|
113
|
-
name: "TEAM.md",
|
|
114
|
-
content: "# Team\n\nNew content",
|
|
115
|
-
}),
|
|
116
|
-
})
|
|
117
|
-
);
|
|
118
|
-
expect(res.status).toBe(200);
|
|
119
|
-
const json = await res.json();
|
|
120
|
-
expect(json.ok).toBe(true);
|
|
121
|
-
expect(json.name).toBe("TEAM.md");
|
|
122
|
-
expect(fs.writeFile).toHaveBeenCalledWith(
|
|
123
|
-
expect.stringContaining("TEAM.md"),
|
|
124
|
-
"# Team\n\nNew content",
|
|
125
|
-
"utf8"
|
|
126
|
-
);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|