@stackbone/cli 0.1.0-alpha.10 → 0.1.0-alpha.12
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/CHANGELOG.md +54 -0
- package/main.js +4654 -808
- package/migrations/0001_runs.sql +1 -1
- package/migrations/0002_approvals.sql +1 -1
- package/migrations/0003_runs_is_playground_index.sql +1 -1
- package/migrations/0005_stackbone_viewer.sql +1 -1
- package/migrations/0006_secrets.sql +1 -1
- package/migrations/0007_agent_config_versions.sql +1 -1
- package/migrations/0014_rag.sql +1 -1
- package/migrations/0015_queue_jobs_lease.sql +60 -0
- package/migrations/0016_runs_job_trigger.sql +15 -0
- package/package.json +1 -1
- package/runtime-deps/@stackbone/agent-server/index.js +59 -413
- package/stackbone-cli-0.1.0-alpha.12.tgz +0 -0
- package/stackbone-cli-0.1.0-alpha.10.tgz +0 -0
package/migrations/0001_runs.sql
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
-- 0001_runs.sql — schema and tables for the run-level surface of Studio.
|
|
2
2
|
-- Spec: docs/arquitectura/specs/stackbone-agent-protocol-v1.md §6 (runs, run_steps).
|
|
3
|
-
-- ADR: docs/arquitectura/decisiones/2026-05-
|
|
3
|
+
-- ADR: docs/arquitectura/decisiones/2026-05-30-stackbone-studio.md §D2/D7/D9.
|
|
4
4
|
|
|
5
5
|
CREATE SCHEMA IF NOT EXISTS stackbone_platform;
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
-- 0002_approvals.sql — HITL approvals queue and audit trail.
|
|
2
2
|
-- Spec: docs/arquitectura/specs/stackbone-agent-protocol-v1.md §6.6/§6.7.
|
|
3
3
|
-- Component: docs/arquitectura/componentes/08-hitl-inbox.md.
|
|
4
|
-
-- ADR: docs/arquitectura/decisiones/2026-05-
|
|
4
|
+
-- ADR: docs/arquitectura/decisiones/2026-05-30-stackbone-studio.md §D2.
|
|
5
5
|
|
|
6
6
|
CREATE TABLE IF NOT EXISTS stackbone_platform.approvals (
|
|
7
7
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
-- 0003_runs_is_playground_index.sql — billing-friendly partial index over runs.
|
|
2
2
|
-- Spec: docs/tasks/Studio V5 - Playground e Invoke.md (V5#01).
|
|
3
|
-
-- ADR: docs/arquitectura/decisiones/2026-05-
|
|
3
|
+
-- ADR: docs/arquitectura/decisiones/2026-05-30-stackbone-studio.md §D5/D9.
|
|
4
4
|
--
|
|
5
5
|
-- The `is_playground` column itself already lives in 0001_runs.sql (F2 baked it
|
|
6
6
|
-- in defensively so playground writes had a place to land before V5 shipped).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
-- 0005_stackbone_viewer.sql — read-only role for the Studio DB Explorer.
|
|
2
2
|
-- Spec: docs/arquitectura/componentes/11-stackbone-studio.md §"DB Explorer".
|
|
3
3
|
-- Task: docs/tasks/Studio V6 - DB Explorer read-only.md (V6#01).
|
|
4
|
-
-- ADR: docs/arquitectura/decisiones/2026-05-
|
|
4
|
+
-- ADR: docs/arquitectura/decisiones/2026-05-30-stackbone-studio.md §D6.
|
|
5
5
|
--
|
|
6
6
|
-- The role is `NOLOGIN` because callers (apps/api, apps/cli emulator) reach it
|
|
7
7
|
-- via `SET ROLE stackbone_viewer` on a session opened with the regular owner
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
-- `stackbone dev` emulator (Studio V10).
|
|
3
3
|
-- Spec: docs/arquitectura/componentes/11-stackbone-studio.md §"Secrets".
|
|
4
4
|
-- Task: docs/tasks/Studio V10 - Secrets.md (V10#02).
|
|
5
|
-
-- ADR: docs/arquitectura/decisiones/2026-05-
|
|
5
|
+
-- ADR: docs/arquitectura/decisiones/2026-05-30-stackbone-studio.md
|
|
6
6
|
-- (decision V10#01 in the task itself: cloud secrets stay in
|
|
7
7
|
-- `installation_secret` of the control plane; local emulator stores
|
|
8
8
|
-- the same wire shape here so the Studio UI sees identical data.)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
-- payloads for Studio's Config dinámica screen (V11).
|
|
3
3
|
-- Spec: docs/arquitectura/componentes/11-stackbone-studio.md §"Mapa de pantallas / C.Config dinámica".
|
|
4
4
|
-- Task: docs/tasks/Studio V11 - Config dinámica.md (V11#01).
|
|
5
|
-
-- ADR: docs/arquitectura/decisiones/2026-05-
|
|
5
|
+
-- ADR: docs/arquitectura/decisiones/2026-05-30-stackbone-studio.md §D2/D7.
|
|
6
6
|
--
|
|
7
7
|
-- The current config is the row with the highest `version`. Older rows are
|
|
8
8
|
-- kept for the rollback action and the lateral history list. Hot-reload is
|
package/migrations/0014_rag.sql
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
-- 0014_rag.sql — the canonical RAG store (collections / documents / chunks /
|
|
2
2
|
-- jobs), moved into the platform schema.
|
|
3
|
-
-- ADR: docs/adr/2026-06-05-rag
|
|
3
|
+
-- ADR: docs/adr/2026-06-05-rag.md
|
|
4
4
|
--
|
|
5
5
|
-- Previously these four tables lived in `public` and were installed by the
|
|
6
6
|
-- creator's own migrator (`stackbone db migrate add-rag`). They are a
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
-- 0015_queue_jobs_lease.sql — lease columns + a terminal NOTIFY on the agent's
|
|
2
|
+
-- `_queue_jobs` journal (P1 "async jobs").
|
|
3
|
+
--
|
|
4
|
+
-- The wrapper around a dispatched handler now leases the in-flight row so the
|
|
5
|
+
-- control-plane reaper can tell a still-running job from a crashed one:
|
|
6
|
+
--
|
|
7
|
+
-- heartbeat_at — touched by the harness roughly every 15s while a dispatched
|
|
8
|
+
-- handler is running. A stale heartbeat is what lets the
|
|
9
|
+
-- reaper DERIVE the `lost` state (never written as a column —
|
|
10
|
+
-- the status CHECK stays `done` / `failed`).
|
|
11
|
+
-- deadline_at — started_at + the effective handler timeout; the hard ceiling
|
|
12
|
+
-- past which the reaper treats the lease as expired.
|
|
13
|
+
-- run_id — correlation key with the `runs` timeline so Studio can join
|
|
14
|
+
-- a journal row to its run.
|
|
15
|
+
--
|
|
16
|
+
-- All three are nullable and added IF NOT EXISTS: the install saga may re-apply
|
|
17
|
+
-- migrations on a redeploy, and a job journaled before this migration simply
|
|
18
|
+
-- carries NULL leases.
|
|
19
|
+
--
|
|
20
|
+
-- A terminal NOTIFY fans out the NULL→terminal transition on
|
|
21
|
+
-- `stackbone_platform_events` so the dispatcher's tracker can resolve a job the
|
|
22
|
+
-- instant its journal row flips, instead of polling. It mirrors the trigger
|
|
23
|
+
-- style of `0001_runs.sql`.
|
|
24
|
+
|
|
25
|
+
ALTER TABLE stackbone_platform._queue_jobs
|
|
26
|
+
ADD COLUMN IF NOT EXISTS heartbeat_at timestamptz;
|
|
27
|
+
ALTER TABLE stackbone_platform._queue_jobs
|
|
28
|
+
ADD COLUMN IF NOT EXISTS deadline_at timestamptz;
|
|
29
|
+
ALTER TABLE stackbone_platform._queue_jobs
|
|
30
|
+
ADD COLUMN IF NOT EXISTS run_id text;
|
|
31
|
+
|
|
32
|
+
-- AFTER UPDATE trigger fans out into pg_notify('stackbone_platform_events', ...)
|
|
33
|
+
-- ONLY on the NULL→terminal status transition (the job just finished). The
|
|
34
|
+
-- dispatcher's tracker LISTENs on this channel and resolves the in-flight job
|
|
35
|
+
-- the moment its journal row flips to `done` / `failed`.
|
|
36
|
+
CREATE OR REPLACE FUNCTION stackbone_platform.notify_queue_job_event() RETURNS trigger
|
|
37
|
+
LANGUAGE plpgsql AS $fn$
|
|
38
|
+
DECLARE
|
|
39
|
+
payload jsonb;
|
|
40
|
+
BEGIN
|
|
41
|
+
IF (OLD.status IS NULL) AND (NEW.status IS NOT NULL) THEN
|
|
42
|
+
payload := jsonb_build_object(
|
|
43
|
+
'type', 'queue_job.finished',
|
|
44
|
+
'dispatch_id', NEW.dispatch_id,
|
|
45
|
+
'run_id', NEW.run_id,
|
|
46
|
+
'status', NEW.status
|
|
47
|
+
);
|
|
48
|
+
ELSE
|
|
49
|
+
RETURN NULL;
|
|
50
|
+
END IF;
|
|
51
|
+
|
|
52
|
+
PERFORM pg_notify('stackbone_platform_events', payload::text);
|
|
53
|
+
RETURN NULL;
|
|
54
|
+
END;
|
|
55
|
+
$fn$;
|
|
56
|
+
|
|
57
|
+
DROP TRIGGER IF EXISTS queue_jobs_notify_au ON stackbone_platform._queue_jobs;
|
|
58
|
+
CREATE TRIGGER queue_jobs_notify_au
|
|
59
|
+
AFTER UPDATE ON stackbone_platform._queue_jobs
|
|
60
|
+
FOR EACH ROW EXECUTE FUNCTION stackbone_platform.notify_queue_job_event();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- 0016_runs_job_trigger.sql — allow `trigger = 'job'` on stackbone_platform.runs.
|
|
2
|
+
--
|
|
3
|
+
-- Dispatched queue jobs (ADR 2026-05-30) are first-class runs, but until now a
|
|
4
|
+
-- queue dispatch only wrote the `_queue_jobs` journal — it never inserted a
|
|
5
|
+
-- `runs` row. Two consequences: the dispatched run was INVISIBLE in the Studio
|
|
6
|
+
-- runs timeline, and `ctx.progress` / `ctx.step` inside a job handler hit the
|
|
7
|
+
-- `run_steps.run_id REFERENCES runs(id)` FK with no parent row, so the progress
|
|
8
|
+
-- note was silently dropped. The wrapper now materialises a `trigger='job'` run
|
|
9
|
+
-- row when it journals the job's started lifecycle, which fixes both — but the
|
|
10
|
+
-- original `0001_runs.sql` CHECK predates the `job` trigger and would reject the
|
|
11
|
+
-- insert. Widen it to match `runTriggerSchema` (which already carries `job`).
|
|
12
|
+
ALTER TABLE stackbone_platform.runs DROP CONSTRAINT IF EXISTS runs_trigger_check;
|
|
13
|
+
ALTER TABLE stackbone_platform.runs
|
|
14
|
+
ADD CONSTRAINT runs_trigger_check
|
|
15
|
+
CHECK (trigger IN ('manual', 'webhook', 'cron', 'event', 'job'));
|