Automations workspace phase 1: sidebar groups, detail view, recompile-to-edit, named runs
Promotes Automations to a top-level sidebar group (below Bookmarks) with user-defined AgentGroup folders (migration 025, FK SET NULL on delete). The /automations page becomes master-detail: overview (composer + grouped list + named global runs) and per-task detail (original prompt, group assignment, run-now/pause/delete, per-task run timeline with true/false/ error pills). Editing recompiles through /api/agent/compile and confirms the proposal before a versioned PATCH applies spec+prompt — the model never writes. Tasks store prompt+groupId; projections add runCount/ errorCount; runs carry taskName. The engine is untouched: groups/prompt are metadata, the validated spec remains the only thing it executes. Chaining, refinements and dry-run stay phase 2. Verified: full DB integration suite under -race, db-converge + migration atomicity, web lint/SSR/build, and a rewritten browser regression covering the sidebar folder, detail prompt, per-task runs, recompile-to-edit and named global runs.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
-- 025_agent_groups.sql — Automations workspace (phase 1): user-defined
|
||||
-- groups and the original natural-language prompt stored alongside the
|
||||
-- compiled spec (editing recompiles through the same compile endpoint).
|
||||
--
|
||||
-- Additive and idempotent; schema.sql carries the identical shape, so this
|
||||
-- is a structural no-op on a fresh database (db-converge proves both paths
|
||||
-- land the same). Deleting a group ungroups its tasks (FK SET NULL) — it
|
||||
-- never deletes automations. The engine is untouched: groupId/prompt are
|
||||
-- metadata; the spec jsonb remains the only thing it executes.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "AgentGroup" (
|
||||
id text PRIMARY KEY,
|
||||
"ownerId" text NOT NULL REFERENCES "User"(id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
position integer NOT NULL DEFAULT 0,
|
||||
version integer NOT NULL DEFAULT 1,
|
||||
"createdAt" timestamptz NOT NULL DEFAULT now(),
|
||||
"updatedAt" timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "AgentGroup_ownerId_idx" ON "AgentGroup"("ownerId");
|
||||
|
||||
ALTER TABLE "AgentTask" ADD COLUMN IF NOT EXISTS "groupId" text REFERENCES "AgentGroup"(id) ON DELETE SET NULL;
|
||||
ALTER TABLE "AgentTask" ADD COLUMN IF NOT EXISTS prompt text NOT NULL DEFAULT '';
|
||||
CREATE INDEX IF NOT EXISTS "AgentTask_groupId_idx" ON "AgentTask"("groupId");
|
||||
@@ -441,11 +441,25 @@ CREATE INDEX "Notification_delivery_due_idx" ON "Notification"("status", "nextAt
|
||||
-- user-confirmed tasks. The spec jsonb is the ONLY thing the engine
|
||||
-- executes and it passes ValidateSpec on every write AND every load.
|
||||
-- AgentRun is the audit trail (kept to a bounded tail per task).
|
||||
-- AgentGroup (migration 025) is the user-defined folder; groupId/prompt
|
||||
-- are workspace metadata the engine never reads.
|
||||
CREATE TABLE "AgentGroup" (
|
||||
id text PRIMARY KEY,
|
||||
"ownerId" text NOT NULL REFERENCES "User"(id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
position integer NOT NULL DEFAULT 0,
|
||||
version integer NOT NULL DEFAULT 1,
|
||||
"createdAt" timestamptz NOT NULL DEFAULT now(),
|
||||
"updatedAt" timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
CREATE INDEX "AgentGroup_ownerId_idx" ON "AgentGroup"("ownerId");
|
||||
CREATE TABLE "AgentTask" (
|
||||
id text PRIMARY KEY,
|
||||
"ownerId" text NOT NULL REFERENCES "User"(id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
spec jsonb NOT NULL,
|
||||
"groupId" text REFERENCES "AgentGroup"(id) ON DELETE SET NULL,
|
||||
prompt text NOT NULL DEFAULT '',
|
||||
enabled boolean NOT NULL DEFAULT true,
|
||||
status text NOT NULL DEFAULT 'active' CHECK (status IN ('active','done','paused')),
|
||||
"lastCheckedAt" timestamptz,
|
||||
@@ -456,6 +470,7 @@ CREATE TABLE "AgentTask" (
|
||||
"updatedAt" timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
CREATE INDEX "AgentTask_ownerId_idx" ON "AgentTask"("ownerId");
|
||||
CREATE INDEX "AgentTask_groupId_idx" ON "AgentTask"("groupId");
|
||||
|
||||
CREATE TABLE "AgentRun" (
|
||||
id text PRIMARY KEY,
|
||||
|
||||
Reference in New Issue
Block a user