@agent-team-foundation/first-tree-hub 0.5.0 → 0.6.0
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/dist/{bootstrap-BU_7B03u.mjs → bootstrap-BnlTKa0H.mjs} +88 -12
- package/dist/cli/index.mjs +409 -25
- package/dist/{core-jjk1xFW_.mjs → core-B9bH7EjM.mjs} +3962 -553
- package/dist/drizzle/0009_agent_runtime_m1.sql +31 -0
- package/dist/drizzle/0010_cloud_multi_tenancy.sql +34 -0
- package/dist/drizzle/0011_org_uuid_pk.sql +22 -0
- package/dist/drizzle/0012_session_level_state.sql +19 -0
- package/dist/drizzle/0013_hub_tasks.sql +38 -0
- package/dist/drizzle/0014_drop_task_fks.sql +9 -0
- package/dist/drizzle/0015_member_system.sql +34 -0
- package/dist/drizzle/0016_strange_havok.sql +25 -0
- package/dist/drizzle/0017_session_outputs_unique.sql +1 -0
- package/dist/drizzle/meta/0012_snapshot.json +1451 -0
- package/dist/drizzle/meta/0013_snapshot.json +1771 -0
- package/dist/drizzle/meta/0014_snapshot.json +1717 -0
- package/dist/drizzle/meta/0016_snapshot.json +1917 -0
- package/dist/drizzle/meta/_journal.json +63 -0
- package/dist/index.mjs +3 -3
- package/dist/web/assets/index--kyp_ZHv.css +1 -0
- package/dist/web/assets/index-C_FKYVro.js +310 -0
- package/dist/web/index.html +2 -2
- package/package.json +3 -2
- package/dist/web/assets/index-LFh6j4ki.js +0 -280
- package/dist/web/assets/index-vo2Sa6IQ.css +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
-- M1: Agent Runtime — Process Awareness
|
|
2
|
+
-- New clients table + agent_presence runtime columns
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS "clients" (
|
|
5
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
6
|
+
"status" text DEFAULT 'disconnected' NOT NULL,
|
|
7
|
+
"sdk_version" text,
|
|
8
|
+
"hostname" text,
|
|
9
|
+
"os" text,
|
|
10
|
+
"instance_id" text,
|
|
11
|
+
"connected_at" timestamp with time zone,
|
|
12
|
+
"last_seen_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
13
|
+
"metadata" jsonb
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
ALTER TABLE "agent_presence" ADD COLUMN "client_id" text;
|
|
17
|
+
ALTER TABLE "agent_presence" ADD COLUMN "runtime_type" text;
|
|
18
|
+
ALTER TABLE "agent_presence" ADD COLUMN "runtime_version" text;
|
|
19
|
+
ALTER TABLE "agent_presence" ADD COLUMN "runtime_state" text;
|
|
20
|
+
ALTER TABLE "agent_presence" ADD COLUMN "runtime_description" text;
|
|
21
|
+
ALTER TABLE "agent_presence" ADD COLUMN "active_sessions" integer;
|
|
22
|
+
ALTER TABLE "agent_presence" ADD COLUMN "total_sessions" integer;
|
|
23
|
+
ALTER TABLE "agent_presence" ADD COLUMN "error_message" text;
|
|
24
|
+
ALTER TABLE "agent_presence" ADD COLUMN "task_ref" text;
|
|
25
|
+
ALTER TABLE "agent_presence" ADD COLUMN "runtime_updated_at" timestamp with time zone;
|
|
26
|
+
|
|
27
|
+
DO $$ BEGIN
|
|
28
|
+
ALTER TABLE "agent_presence" ADD CONSTRAINT "agent_presence_client_id_clients_id_fk" FOREIGN KEY ("client_id") REFERENCES "public"."clients"("id") ON DELETE set null ON UPDATE no action;
|
|
29
|
+
EXCEPTION
|
|
30
|
+
WHEN duplicate_object THEN null;
|
|
31
|
+
END $$;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
-- Cloud Multi-Tenancy Phase 1: organizations table + agents/chats FK + new agent fields
|
|
2
|
+
|
|
3
|
+
-- 1. Create organizations table
|
|
4
|
+
CREATE TABLE IF NOT EXISTS "organizations" (
|
|
5
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
6
|
+
"display_name" text NOT NULL,
|
|
7
|
+
"max_agents" integer NOT NULL DEFAULT 0,
|
|
8
|
+
"max_messages_per_minute" integer NOT NULL DEFAULT 0,
|
|
9
|
+
"features" jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
10
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
11
|
+
"updated_at" timestamptz NOT NULL DEFAULT now()
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
-- 2. Insert default organization (idempotent — skip if exists)
|
|
15
|
+
INSERT INTO "organizations" ("id", "display_name")
|
|
16
|
+
VALUES ('default', 'Default Organization')
|
|
17
|
+
ON CONFLICT ("id") DO NOTHING;
|
|
18
|
+
|
|
19
|
+
-- 3. Add FK from agents.organization_id → organizations.id
|
|
20
|
+
ALTER TABLE "agents"
|
|
21
|
+
ADD CONSTRAINT "agents_organization_id_organizations_id_fk"
|
|
22
|
+
FOREIGN KEY ("organization_id") REFERENCES "organizations"("id")
|
|
23
|
+
ON DELETE NO ACTION ON UPDATE NO ACTION;
|
|
24
|
+
|
|
25
|
+
-- 4. Add FK from chats.organization_id → organizations.id
|
|
26
|
+
ALTER TABLE "chats"
|
|
27
|
+
ADD CONSTRAINT "chats_organization_id_organizations_id_fk"
|
|
28
|
+
FOREIGN KEY ("organization_id") REFERENCES "organizations"("id")
|
|
29
|
+
ON DELETE NO ACTION ON UPDATE NO ACTION;
|
|
30
|
+
|
|
31
|
+
-- 5. Add new columns to agents
|
|
32
|
+
ALTER TABLE "agents" ADD COLUMN "source" text;
|
|
33
|
+
ALTER TABLE "agents" ADD COLUMN "cloud_user_id" text;
|
|
34
|
+
ALTER TABLE "agents" ADD COLUMN "public" boolean NOT NULL DEFAULT false;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
-- Organization UUID PK: add name column with unique constraint, drop old defaults
|
|
2
|
+
|
|
3
|
+
-- Step 1: Add name column
|
|
4
|
+
ALTER TABLE "organizations" ADD COLUMN "name" text;
|
|
5
|
+
--> statement-breakpoint
|
|
6
|
+
|
|
7
|
+
-- Step 2: Backfill name from id for existing rows
|
|
8
|
+
UPDATE "organizations" SET "name" = "id" WHERE "name" IS NULL;
|
|
9
|
+
--> statement-breakpoint
|
|
10
|
+
|
|
11
|
+
-- Step 3: Make name NOT NULL
|
|
12
|
+
ALTER TABLE "organizations" ALTER COLUMN "name" SET NOT NULL;
|
|
13
|
+
--> statement-breakpoint
|
|
14
|
+
|
|
15
|
+
-- Step 4: Add UNIQUE constraint on name
|
|
16
|
+
ALTER TABLE "organizations" ADD CONSTRAINT "organizations_name_unique" UNIQUE("name");
|
|
17
|
+
--> statement-breakpoint
|
|
18
|
+
|
|
19
|
+
-- Step 5: Drop old default values on organization_id columns (was 'default' slug)
|
|
20
|
+
ALTER TABLE "agents" ALTER COLUMN "organization_id" DROP DEFAULT;
|
|
21
|
+
--> statement-breakpoint
|
|
22
|
+
ALTER TABLE "chats" ALTER COLUMN "organization_id" DROP DEFAULT;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
-- Session-level state reporting: new session table + drop unused presence columns
|
|
2
|
+
|
|
3
|
+
CREATE TABLE "agent_chat_sessions" (
|
|
4
|
+
"agent_id" text NOT NULL,
|
|
5
|
+
"chat_id" text NOT NULL,
|
|
6
|
+
"state" text NOT NULL,
|
|
7
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
8
|
+
CONSTRAINT "agent_chat_sessions_agent_id_chat_id_pk" PRIMARY KEY("agent_id","chat_id")
|
|
9
|
+
);
|
|
10
|
+
--> statement-breakpoint
|
|
11
|
+
ALTER TABLE "agent_chat_sessions" ADD CONSTRAINT "agent_chat_sessions_agent_id_agents_uuid_fk" FOREIGN KEY ("agent_id") REFERENCES "public"."agents"("uuid") ON DELETE cascade ON UPDATE no action;
|
|
12
|
+
--> statement-breakpoint
|
|
13
|
+
ALTER TABLE "agent_chat_sessions" ADD CONSTRAINT "agent_chat_sessions_chat_id_chats_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."chats"("id") ON DELETE cascade ON UPDATE no action;
|
|
14
|
+
--> statement-breakpoint
|
|
15
|
+
ALTER TABLE "agent_presence" DROP COLUMN IF EXISTS "runtime_description";
|
|
16
|
+
--> statement-breakpoint
|
|
17
|
+
ALTER TABLE "agent_presence" DROP COLUMN IF EXISTS "error_message";
|
|
18
|
+
--> statement-breakpoint
|
|
19
|
+
ALTER TABLE "agent_presence" DROP COLUMN IF EXISTS "task_ref";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
-- Hub Task — lightweight work units (tasks + task_chats)
|
|
2
|
+
|
|
3
|
+
CREATE TABLE "tasks" (
|
|
4
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
5
|
+
"organization_id" text NOT NULL,
|
|
6
|
+
"title" text NOT NULL,
|
|
7
|
+
"body" text DEFAULT '' NOT NULL,
|
|
8
|
+
"status" text NOT NULL,
|
|
9
|
+
"assignee_agent_id" text,
|
|
10
|
+
"created_by_type" text NOT NULL,
|
|
11
|
+
"created_by_id" text NOT NULL,
|
|
12
|
+
"origin_ref" text,
|
|
13
|
+
"result" text,
|
|
14
|
+
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
15
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
16
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
17
|
+
"cancelled_at" timestamp with time zone,
|
|
18
|
+
"cancelled_by_type" text,
|
|
19
|
+
"cancelled_by_id" text
|
|
20
|
+
);
|
|
21
|
+
--> statement-breakpoint
|
|
22
|
+
CREATE TABLE "task_chats" (
|
|
23
|
+
"task_id" text NOT NULL,
|
|
24
|
+
"chat_id" text NOT NULL,
|
|
25
|
+
"linked_by_agent_id" text,
|
|
26
|
+
"linked_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
27
|
+
CONSTRAINT "task_chats_task_id_chat_id_pk" PRIMARY KEY("task_id","chat_id")
|
|
28
|
+
);
|
|
29
|
+
--> statement-breakpoint
|
|
30
|
+
ALTER TABLE "tasks" ADD CONSTRAINT "tasks_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
31
|
+
ALTER TABLE "task_chats" ADD CONSTRAINT "task_chats_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
32
|
+
ALTER TABLE "task_chats" ADD CONSTRAINT "task_chats_chat_id_chats_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."chats"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
33
|
+
ALTER TABLE "task_chats" ADD CONSTRAINT "task_chats_linked_by_agent_id_agents_uuid_fk" FOREIGN KEY ("linked_by_agent_id") REFERENCES "public"."agents"("uuid") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
34
|
+
CREATE INDEX "idx_tasks_org_status" ON "tasks" USING btree ("organization_id","status");--> statement-breakpoint
|
|
35
|
+
CREATE INDEX "idx_tasks_assignee_status" ON "tasks" USING btree ("assignee_agent_id","status");--> statement-breakpoint
|
|
36
|
+
CREATE INDEX "idx_tasks_origin_ref" ON "tasks" USING btree ("origin_ref");--> statement-breakpoint
|
|
37
|
+
CREATE INDEX "idx_tasks_org_created_at" ON "tasks" USING btree ("organization_id","created_at");--> statement-breakpoint
|
|
38
|
+
CREATE INDEX "idx_task_chats_chat" ON "task_chats" USING btree ("chat_id");
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- Drop all FK constraints from the Hub Task tables.
|
|
2
|
+
-- Referential integrity for tasks/task_chats is enforced in the service layer;
|
|
3
|
+
-- DB-level FKs transfer the cost (cascade surprises, migration friction, test
|
|
4
|
+
-- setup complexity) onto the database without adding value here.
|
|
5
|
+
|
|
6
|
+
ALTER TABLE "tasks" DROP CONSTRAINT IF EXISTS "tasks_organization_id_organizations_id_fk";--> statement-breakpoint
|
|
7
|
+
ALTER TABLE "task_chats" DROP CONSTRAINT IF EXISTS "task_chats_task_id_tasks_id_fk";--> statement-breakpoint
|
|
8
|
+
ALTER TABLE "task_chats" DROP CONSTRAINT IF EXISTS "task_chats_chat_id_chats_id_fk";--> statement-breakpoint
|
|
9
|
+
ALTER TABLE "task_chats" DROP CONSTRAINT IF EXISTS "task_chats_linked_by_agent_id_agents_uuid_fk";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
-- Create users table (replaces admin_users)
|
|
2
|
+
CREATE TABLE "users" (
|
|
3
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
4
|
+
"username" text NOT NULL,
|
|
5
|
+
"password_hash" text NOT NULL,
|
|
6
|
+
"display_name" text NOT NULL,
|
|
7
|
+
"avatar_url" text,
|
|
8
|
+
"status" text DEFAULT 'active' NOT NULL,
|
|
9
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
10
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
11
|
+
CONSTRAINT "users_username_unique" UNIQUE("username")
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
-- Create members table
|
|
15
|
+
CREATE TABLE "members" (
|
|
16
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
17
|
+
"user_id" text NOT NULL REFERENCES "users"("id"),
|
|
18
|
+
"organization_id" text NOT NULL REFERENCES "organizations"("id"),
|
|
19
|
+
"agent_id" text NOT NULL REFERENCES "agents"("uuid"),
|
|
20
|
+
"role" text NOT NULL,
|
|
21
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
22
|
+
CONSTRAINT "members_agent_id_unique" UNIQUE("agent_id"),
|
|
23
|
+
CONSTRAINT "uq_members_user_org" UNIQUE("user_id", "organization_id")
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
CREATE INDEX "idx_members_user" ON "members" ("user_id");
|
|
27
|
+
CREATE INDEX "idx_members_org" ON "members" ("organization_id");
|
|
28
|
+
|
|
29
|
+
-- Add manager_id to agents with FK to members (FK in SQL only — not in Drizzle schema to avoid circular import)
|
|
30
|
+
ALTER TABLE "agents" ADD COLUMN "manager_id" text REFERENCES "members"("id") ON DELETE SET NULL;
|
|
31
|
+
CREATE INDEX "idx_agents_manager" ON "agents" ("manager_id");
|
|
32
|
+
|
|
33
|
+
-- Drop admin_users table
|
|
34
|
+
DROP TABLE "admin_users";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
CREATE TABLE "notifications" (
|
|
2
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
3
|
+
"organization_id" text NOT NULL,
|
|
4
|
+
"type" text NOT NULL,
|
|
5
|
+
"severity" text NOT NULL,
|
|
6
|
+
"agent_id" text,
|
|
7
|
+
"chat_id" text,
|
|
8
|
+
"message" text NOT NULL,
|
|
9
|
+
"read" boolean DEFAULT false NOT NULL,
|
|
10
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
11
|
+
);
|
|
12
|
+
--> statement-breakpoint
|
|
13
|
+
CREATE TABLE "session_outputs" (
|
|
14
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
15
|
+
"agent_id" text NOT NULL,
|
|
16
|
+
"chat_id" text NOT NULL,
|
|
17
|
+
"content" text DEFAULT '' NOT NULL,
|
|
18
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
19
|
+
);
|
|
20
|
+
--> statement-breakpoint
|
|
21
|
+
ALTER TABLE "messages" ADD COLUMN "source" text;--> statement-breakpoint
|
|
22
|
+
CREATE INDEX "idx_notifications_org_created" ON "notifications" USING btree ("organization_id","created_at");--> statement-breakpoint
|
|
23
|
+
CREATE INDEX "idx_notifications_agent" ON "notifications" USING btree ("agent_id");--> statement-breakpoint
|
|
24
|
+
CREATE INDEX "idx_notifications_org_read" ON "notifications" USING btree ("organization_id","read");--> statement-breakpoint
|
|
25
|
+
CREATE INDEX "idx_session_outputs_agent_chat" ON "session_outputs" USING btree ("agent_id","chat_id");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "session_outputs" ADD CONSTRAINT "uq_session_outputs_agent_chat" UNIQUE("agent_id","chat_id");
|