@pstdio/pocketcoder-cli 0.6.0 → 0.6.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.
package/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  The operator and diagnostics CLI for PocketCoder.
4
4
 
5
+ It gives operators one supported interface to run the server, manage database
6
+ state and access, validate templates, inspect workspaces, and diagnose a
7
+ deployment without writing control-plane API calls by hand.
8
+
5
9
  ## Install
6
10
 
7
11
  pcd requires Bun 1.3.14 or newer:
@@ -25,3 +29,10 @@ does not build workspace images, generate templates, start a model gateway, or
25
29
  initialize deployment prerequisites.
26
30
 
27
31
  See the full [CLI reference](https://github.com/pufflyai/pocketcoder/blob/main/docs/cli.md).
32
+
33
+ ## Command layout
34
+
35
+ Each command lives under `src/commands/<resource>/<action>.ts`. The resource
36
+ registers its actions with yargs, and each action owns its options and handler.
37
+ This keeps help scoped to the selected resource or action and lets
38
+ `parseAsync()` run the command directly.
@@ -0,0 +1,109 @@
1
+ CREATE TABLE "event_outbox" (
2
+ "id" uuid PRIMARY KEY,
3
+ "workspace_id" uuid NOT NULL,
4
+ "event_type" text NOT NULL,
5
+ "payload" jsonb NOT NULL,
6
+ "occurred_at" timestamp with time zone NOT NULL,
7
+ "next_attempt_at" timestamp with time zone NOT NULL,
8
+ "attempt_count" integer DEFAULT 0 NOT NULL,
9
+ "delivered_at" timestamp with time zone,
10
+ "last_error_code" text
11
+ );
12
+ --> statement-breakpoint
13
+ CREATE TABLE "machine_keys" (
14
+ "id" uuid PRIMARY KEY,
15
+ "principal_id" uuid NOT NULL,
16
+ "secret_digest" bytea NOT NULL,
17
+ "scopes" text[] NOT NULL,
18
+ "created_at" timestamp with time zone NOT NULL,
19
+ "expires_at" timestamp with time zone,
20
+ "revoked_at" timestamp with time zone,
21
+ "last_used_at" timestamp with time zone
22
+ );
23
+ --> statement-breakpoint
24
+ CREATE TABLE "principals" (
25
+ "id" uuid PRIMARY KEY,
26
+ "name" text NOT NULL UNIQUE,
27
+ "scopes" text[] NOT NULL,
28
+ "template_names" text[] NOT NULL,
29
+ "disabled_at" timestamp with time zone,
30
+ "created_at" timestamp with time zone NOT NULL
31
+ );
32
+ --> statement-breakpoint
33
+ CREATE TABLE "templates" (
34
+ "id" uuid PRIMARY KEY,
35
+ "name" text NOT NULL,
36
+ "version" text NOT NULL,
37
+ "digest" text NOT NULL UNIQUE,
38
+ "description" text,
39
+ "spec" jsonb NOT NULL,
40
+ "status" text NOT NULL,
41
+ "created_at" timestamp with time zone NOT NULL,
42
+ "retired_at" timestamp with time zone,
43
+ CONSTRAINT "templates_name_version_unique" UNIQUE("name","version")
44
+ );
45
+ --> statement-breakpoint
46
+ CREATE TABLE "workspace_logs" (
47
+ "workspace_id" uuid,
48
+ "seq" bigint,
49
+ "stream" text NOT NULL,
50
+ "occurred_at" timestamp with time zone NOT NULL,
51
+ "content" bytea NOT NULL,
52
+ CONSTRAINT "workspace_logs_pkey" PRIMARY KEY("workspace_id","seq")
53
+ );
54
+ --> statement-breakpoint
55
+ CREATE TABLE "workspace_state_history" (
56
+ "id" uuid PRIMARY KEY,
57
+ "workspace_id" uuid NOT NULL,
58
+ "from_state" text,
59
+ "to_state" text NOT NULL,
60
+ "reason_code" text,
61
+ "occurred_at" timestamp with time zone NOT NULL
62
+ );
63
+ --> statement-breakpoint
64
+ CREATE TABLE "workspaces" (
65
+ "id" uuid PRIMARY KEY,
66
+ "principal_id" uuid NOT NULL,
67
+ "external_id" text NOT NULL,
68
+ "idempotency_key" text NOT NULL,
69
+ "request_digest" text NOT NULL,
70
+ "template_id" uuid NOT NULL,
71
+ "template_name" text NOT NULL,
72
+ "template_version" text NOT NULL,
73
+ "template_digest" text NOT NULL,
74
+ "template_snapshot" jsonb NOT NULL,
75
+ "state" text NOT NULL,
76
+ "reason_code" text,
77
+ "terminal_intent" text,
78
+ "launch_input" jsonb,
79
+ "provider_kind" text,
80
+ "provider_ref" jsonb,
81
+ "registration_digest" bytea,
82
+ "registration_expires_at" timestamp with time zone,
83
+ "reconnect_digest" bytea,
84
+ "connection_epoch" integer DEFAULT 0 NOT NULL,
85
+ "connected_at" timestamp with time zone,
86
+ "disconnected_at" timestamp with time zone,
87
+ "ready_at" timestamp with time zone,
88
+ "last_activity_at" timestamp with time zone,
89
+ "launch_attempts" integer DEFAULT 0 NOT NULL,
90
+ "health" jsonb DEFAULT '{}' NOT NULL,
91
+ "metadata" jsonb DEFAULT '{}' NOT NULL,
92
+ "deadline_at" timestamp with time zone NOT NULL,
93
+ "created_at" timestamp with time zone NOT NULL,
94
+ "updated_at" timestamp with time zone NOT NULL,
95
+ "terminal_at" timestamp with time zone,
96
+ CONSTRAINT "workspaces_principal_id_idempotency_key_unique" UNIQUE("principal_id","idempotency_key")
97
+ );
98
+ --> statement-breakpoint
99
+ CREATE INDEX "event_outbox_due" ON "event_outbox" ("next_attempt_at") WHERE "delivered_at" IS NULL;--> statement-breakpoint
100
+ CREATE INDEX "workspace_state_history_ws" ON "workspace_state_history" ("workspace_id","occurred_at");--> statement-breakpoint
101
+ CREATE UNIQUE INDEX "workspaces_principal_external_active" ON "workspaces" ("principal_id","external_id") WHERE "state" NOT IN ('succeeded', 'failed', 'canceled', 'expired');--> statement-breakpoint
102
+ CREATE INDEX "workspaces_state_created" ON "workspaces" ("state","created_at");--> statement-breakpoint
103
+ CREATE INDEX "workspaces_deadline" ON "workspaces" ("deadline_at") WHERE "state" NOT IN ('succeeded', 'failed', 'canceled', 'expired');--> statement-breakpoint
104
+ ALTER TABLE "event_outbox" ADD CONSTRAINT "event_outbox_workspace_id_workspaces_id_fkey" FOREIGN KEY ("workspace_id") REFERENCES "workspaces"("id");--> statement-breakpoint
105
+ ALTER TABLE "machine_keys" ADD CONSTRAINT "machine_keys_principal_id_principals_id_fkey" FOREIGN KEY ("principal_id") REFERENCES "principals"("id");--> statement-breakpoint
106
+ ALTER TABLE "workspace_logs" ADD CONSTRAINT "workspace_logs_workspace_id_workspaces_id_fkey" FOREIGN KEY ("workspace_id") REFERENCES "workspaces"("id");--> statement-breakpoint
107
+ ALTER TABLE "workspace_state_history" ADD CONSTRAINT "workspace_state_history_workspace_id_workspaces_id_fkey" FOREIGN KEY ("workspace_id") REFERENCES "workspaces"("id");--> statement-breakpoint
108
+ ALTER TABLE "workspaces" ADD CONSTRAINT "workspaces_principal_id_principals_id_fkey" FOREIGN KEY ("principal_id") REFERENCES "principals"("id");--> statement-breakpoint
109
+ ALTER TABLE "workspaces" ADD CONSTRAINT "workspaces_template_id_templates_id_fkey" FOREIGN KEY ("template_id") REFERENCES "templates"("id");