@igorjpimenta/manifold 0.0.0-stage → 2026.11.22-beta.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/.migrations/ops/0000_futuristic_karma.sql +111 -0
- package/.migrations/ops/0001_low_maximus.sql +7 -0
- package/.migrations/ops/meta/0000_snapshot.json +763 -0
- package/.migrations/ops/meta/0001_snapshot.json +173 -0
- package/.migrations/ops/meta/_journal.json +20 -0
- package/.migrations/runtime/0000_real_boomer.sql +180 -0
- package/.migrations/runtime/0001_hot_dakota_north.sql +2 -0
- package/.migrations/runtime/0002_breezy_vertigo.sql +8 -0
- package/.migrations/runtime/0003_dashing_jack_flag.sql +5 -0
- package/.migrations/runtime/0004_panoramic_ego.sql +1 -0
- package/.migrations/runtime/0005_tidy_ben_grimm.sql +10 -0
- package/.migrations/runtime/0006_wet_nightmare.sql +57 -0
- package/.migrations/runtime/0007_ambiguous_chronomancer.sql +8 -0
- package/.migrations/runtime/0008_wealthy_thundra.sql +301 -0
- package/.migrations/runtime/0009_lying_shocker.sql +96 -0
- package/.migrations/runtime/0010_solid_phantom_reporter.sql +160 -0
- package/.migrations/runtime/0011_windy_demogoblin.sql +175 -0
- package/.migrations/runtime/0012_restore_harness_fks.sql +103 -0
- package/.migrations/runtime/meta/0000_snapshot.json +1181 -0
- package/.migrations/runtime/meta/0001_snapshot.json +1209 -0
- package/.migrations/runtime/meta/0002_snapshot.json +1261 -0
- package/.migrations/runtime/meta/0003_snapshot.json +1292 -0
- package/.migrations/runtime/meta/0004_snapshot.json +1240 -0
- package/.migrations/runtime/meta/0006_snapshot.json +1310 -0
- package/.migrations/runtime/meta/0007_snapshot.json +1362 -0
- package/.migrations/runtime/meta/0008_snapshot.json +1742 -0
- package/.migrations/runtime/meta/0009_snapshot.json +2413 -0
- package/.migrations/runtime/meta/0010_snapshot.json +2562 -0
- package/.migrations/runtime/meta/0011_snapshot.json +2812 -0
- package/.migrations/runtime/meta/0012_snapshot.json +2812 -0
- package/.migrations/runtime/meta/_journal.json +97 -0
- package/README.md +1583 -2
- package/RELEASING.md +89 -0
- package/agent/fleet.js +100 -0
- package/bin/cli.js +854 -0
- package/bin/manifold.js +4 -0
- package/boot/flow-revival.js +536 -0
- package/budget/index.js +495 -0
- package/budget/lib.js +59 -0
- package/dashboard/cost.js +528 -0
- package/dashboard/dist/assets/index-CUfp63sj.css +1 -0
- package/dashboard/dist/assets/index-Qy9JMpma.js +371 -0
- package/dashboard/dist/index.html +13 -0
- package/dashboard/event-log.js +267 -0
- package/dashboard/index.html +12 -0
- package/dashboard/package-lock.json +2877 -0
- package/dashboard/package.json +37 -0
- package/dashboard/pipeline-graph.js +131 -0
- package/dashboard/postcss.config.js +6 -0
- package/dashboard/search.js +183 -0
- package/dashboard/server.js +1015 -0
- package/dashboard/src/App.tsx +42 -0
- package/dashboard/src/api/client.ts +118 -0
- package/dashboard/src/api/types.ts +510 -0
- package/dashboard/src/api/ws.tsx +112 -0
- package/dashboard/src/components/CancelButton.tsx +63 -0
- package/dashboard/src/components/ClickToCopy.tsx +68 -0
- package/dashboard/src/components/CopyButton.tsx +61 -0
- package/dashboard/src/components/DailyCostTrend.tsx +85 -0
- package/dashboard/src/components/DailyTimeTrend.tsx +94 -0
- package/dashboard/src/components/Funnel.tsx +149 -0
- package/dashboard/src/components/GateForm.tsx +158 -0
- package/dashboard/src/components/GraphView.tsx +302 -0
- package/dashboard/src/components/GroupPathsSummary.tsx +47 -0
- package/dashboard/src/components/Histogram.tsx +292 -0
- package/dashboard/src/components/Layout.tsx +28 -0
- package/dashboard/src/components/NeedsAttention.tsx +98 -0
- package/dashboard/src/components/NodeContextCard.tsx +132 -0
- package/dashboard/src/components/PathTrail.tsx +35 -0
- package/dashboard/src/components/PipelineCostBreakdown.tsx +277 -0
- package/dashboard/src/components/RerunButton.tsx +46 -0
- package/dashboard/src/components/RunComparison.tsx +53 -0
- package/dashboard/src/components/Sparkline.tsx +94 -0
- package/dashboard/src/components/StatStrip.tsx +147 -0
- package/dashboard/src/components/StateTree.tsx +84 -0
- package/dashboard/src/components/StatusBadge.tsx +18 -0
- package/dashboard/src/components/SubflowPathPills.tsx +38 -0
- package/dashboard/src/components/SubflowSummary.tsx +24 -0
- package/dashboard/src/components/SubflowsCard.tsx +327 -0
- package/dashboard/src/components/TodayStrip.tsx +86 -0
- package/dashboard/src/components/TranscriptPane.tsx +99 -0
- package/dashboard/src/components/TranscriptRow.tsx +69 -0
- package/dashboard/src/components/ui/badge.tsx +38 -0
- package/dashboard/src/components/ui/button.tsx +28 -0
- package/dashboard/src/components/ui/card.tsx +42 -0
- package/dashboard/src/components/ui/skeleton.tsx +9 -0
- package/dashboard/src/components/ui/table.tsx +62 -0
- package/dashboard/src/index.css +26 -0
- package/dashboard/src/lib/anomaly.ts +42 -0
- package/dashboard/src/lib/format.ts +30 -0
- package/dashboard/src/lib/step-history.ts +13 -0
- package/dashboard/src/lib/subflow.ts +154 -0
- package/dashboard/src/lib/use-click-outside.ts +28 -0
- package/dashboard/src/lib/use-ignored-clusters.ts +67 -0
- package/dashboard/src/lib/utils.ts +6 -0
- package/dashboard/src/main.tsx +10 -0
- package/dashboard/src/types/shims.d.ts +4 -0
- package/dashboard/src/views/Home.tsx +478 -0
- package/dashboard/src/views/PipelineDetail.tsx +1185 -0
- package/dashboard/src/views/PipelinesList.tsx +111 -0
- package/dashboard/src/views/RunDetail.tsx +248 -0
- package/dashboard/src/views/Search.tsx +196 -0
- package/dashboard/stats.js +668 -0
- package/dashboard/tailwind.config.ts +43 -0
- package/dashboard/tree-stats.js +12 -0
- package/dashboard/tsconfig.json +25 -0
- package/dashboard/views.js +231 -0
- package/dashboard/vite.config.ts +34 -0
- package/drizzle.config.js +12 -0
- package/drizzle.config.ops.js +12 -0
- package/elevation.js +116 -0
- package/engine/admission-promotion-resume.js +127 -0
- package/engine/agent-dispatch.js +64 -0
- package/engine/child-resume-trigger.js +315 -0
- package/engine/executor-budget.js +87 -0
- package/engine/executor-cancel.js +83 -0
- package/engine/executor-errors.js +122 -0
- package/engine/executor-helpers.js +254 -0
- package/engine/executor-nodes.js +292 -0
- package/engine/executor-persist.js +212 -0
- package/engine/executor-subflow-children.js +275 -0
- package/engine/executor.js +1013 -0
- package/engine/global-concurrency.js +33 -0
- package/engine/loader.js +528 -0
- package/engine/needs-resolver.js +229 -0
- package/engine/pipelines-watcher.js +133 -0
- package/engine/result-replay.js +34 -0
- package/engine/revival-messages.js +11 -0
- package/engine/spawn-child.js +55 -0
- package/engine/wait-for-flow-settlement.js +109 -0
- package/events/catalog.js +26 -0
- package/events/emit.js +44 -0
- package/events/kinds.js +118 -0
- package/events/serve-ws.js +74 -0
- package/events/stream.js +35 -0
- package/events/ws-dialog.js +257 -0
- package/events/ws-frame.js +194 -0
- package/events/ws-run-events.js +70 -0
- package/events.js +32 -0
- package/gates/gate-resolver.js +576 -0
- package/gates/paused-flows.js +55 -0
- package/graphql/columns.js +67 -0
- package/graphql/schema.js +333 -0
- package/index.js +49 -0
- package/mcp/http.js +159 -0
- package/mcp/identity.js +94 -0
- package/mcp/stdio.js +80 -0
- package/mcp/tools.js +245 -0
- package/mcp/wire-ops.js +178 -0
- package/package.json +49 -4
- package/routes/bearer-auth.js +57 -0
- package/routes/discuss-audio.js +87 -0
- package/routes/discuss-component.js +39 -0
- package/routes/discuss-draft.js +159 -0
- package/routes/discuss-helpers.js +20 -0
- package/routes/discuss.js +848 -0
- package/routes/failures.js +104 -0
- package/routes/graphql.js +61 -0
- package/routes/health.js +54 -0
- package/routes/operator-discuss.js +193 -0
- package/routes/operator-resume.js +32 -0
- package/routes/operator-retry.js +301 -0
- package/routes/operator.js +539 -0
- package/routes/pipelines.js +118 -0
- package/routes/runs.js +1129 -0
- package/scripts/ci/import-check.mjs +50 -0
- package/scripts/link-core-self.mjs +31 -0
- package/scripts/with-guard.sh +24 -0
- package/server/app.js +503 -0
- package/server/registry.js +53 -0
- package/server/serve.js +163 -0
- package/state/admission-queue-store.js +325 -0
- package/state/attribution-registries.js +102 -0
- package/state/batch-writer.js +162 -0
- package/state/db-guard.js +63 -0
- package/state/db-health.js +27 -0
- package/state/db.js +122 -0
- package/state/discuss-store.js +299 -0
- package/state/failure-store.js +427 -0
- package/state/migrate.js +104 -0
- package/state/node-cost.js +67 -0
- package/state/node-executions.js +775 -0
- package/state/node-health-store.js +124 -0
- package/state/ops-merge.js +93 -0
- package/state/paths.js +146 -0
- package/state/pipeline-dirs.js +99 -0
- package/state/pipeline-registry.js +449 -0
- package/state/run-store.js +697 -0
- package/state/schema.js +438 -0
- package/state/schema.ops.js +44 -0
- package/state/session-index.js +177 -0
- package/state/session-keys.js +39 -0
- package/state/state-store.js +311 -0
- package/state/subflow-state.js +126 -0
- package/state/tool-handoff.js +169 -0
- package/telemetry/budget-alert.js +353 -0
- package/telemetry/cli.js +331 -0
- package/telemetry/grammar.js +119 -0
- package/telemetry/http-budget.js +132 -0
- package/telemetry/http-cost.js +670 -0
- package/telemetry/http-helpers.js +134 -0
- package/telemetry/http-tree.js +349 -0
- package/telemetry/http.js +44 -0
- package/telemetry/index.js +307 -0
- package/telemetry/ingest.js +134 -0
- package/telemetry/labels.js +115 -0
- package/telemetry/pricer.js +77 -0
- package/telemetry/resolver.js +314 -0
- package/telemetry/store.js +147 -0
- package/utils/run-patch.js +43 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
-- FK retrofit + pipelines registry.
|
|
2
|
+
--
|
|
3
|
+
-- SQLite has no ALTER TABLE ADD CONSTRAINT: every FK on an existing table is
|
|
4
|
+
-- applied by the 12-step rebuild (create __new, copy, DROP, RENAME). The
|
|
5
|
+
-- foreign_keys is off for the whole run, set by state/migrate.js before
|
|
6
|
+
-- drizzle begins its snapshot transaction (a PRAGMA inside that transaction
|
|
7
|
+
-- is a no-op). Existing rows already violate two of these edges (22
|
|
8
|
+
-- invocations without a run, 38 failure rows without an execution); they copy
|
|
9
|
+
-- as-is and stay violations until cleaned. pipelines is backfilled from the
|
|
10
|
+
-- union of every pipeline_id column before any rebuilt table references it.
|
|
11
|
+
|
|
12
|
+
CREATE TABLE IF NOT EXISTS `harnesses` (
|
|
13
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
14
|
+
`created_at` integer NOT NULL,
|
|
15
|
+
`updated_at` integer NOT NULL
|
|
16
|
+
);
|
|
17
|
+
--> statement-breakpoint
|
|
18
|
+
INSERT OR IGNORE INTO `harnesses` (`id`, `created_at`, `updated_at`)
|
|
19
|
+
SELECT `harness`, `created_at`, `created_at` FROM `pipeline_dirs` WHERE `harness` IS NOT NULL;--> statement-breakpoint
|
|
20
|
+
|
|
21
|
+
CREATE TABLE IF NOT EXISTS `pipelines` (
|
|
22
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
23
|
+
`name` text NOT NULL,
|
|
24
|
+
`harness` text,
|
|
25
|
+
`created_at` integer NOT NULL,
|
|
26
|
+
`updated_at` integer NOT NULL,
|
|
27
|
+
`deleted_at` integer,
|
|
28
|
+
FOREIGN KEY (`harness`) REFERENCES `harnesses`(`id`) ON UPDATE no action ON DELETE set null
|
|
29
|
+
);
|
|
30
|
+
--> statement-breakpoint
|
|
31
|
+
CREATE INDEX IF NOT EXISTS `idx_pipelines_harness_name` ON `pipelines` (`harness`,`name`);--> statement-breakpoint
|
|
32
|
+
INSERT OR IGNORE INTO `pipelines` (`id`, `name`, `harness`, `created_at`, `updated_at`)
|
|
33
|
+
SELECT `id`, `id`, NULL, CAST(strftime('%s','now') AS INTEGER) * 1000, CAST(strftime('%s','now') AS INTEGER) * 1000
|
|
34
|
+
FROM (
|
|
35
|
+
SELECT `pipeline_id` AS `id` FROM `flow_runs` WHERE `pipeline_id` IS NOT NULL
|
|
36
|
+
UNION SELECT `pipeline_id` FROM `pipeline_versions`
|
|
37
|
+
UNION SELECT `pipeline_id` FROM `pipeline_node_versions`
|
|
38
|
+
UNION SELECT `pipeline_id` FROM `node_health`
|
|
39
|
+
UNION SELECT `parent_pipeline_id` FROM `pipeline_versions` WHERE `parent_pipeline_id` IS NOT NULL
|
|
40
|
+
);--> statement-breakpoint
|
|
41
|
+
INSERT OR IGNORE INTO `harnesses` (`id`, `created_at`, `updated_at`)
|
|
42
|
+
SELECT `harness`, `created_at`, `created_at` FROM `pipelines` WHERE `harness` IS NOT NULL;--> statement-breakpoint
|
|
43
|
+
CREATE TABLE IF NOT EXISTS `__new_pipeline_dirs` (
|
|
44
|
+
`harness` text PRIMARY KEY NOT NULL,
|
|
45
|
+
`path` text NOT NULL,
|
|
46
|
+
`created_at` integer NOT NULL,
|
|
47
|
+
FOREIGN KEY (`harness`) REFERENCES `harnesses`(`id`) ON UPDATE no action ON DELETE cascade
|
|
48
|
+
);
|
|
49
|
+
--> statement-breakpoint
|
|
50
|
+
INSERT INTO `__new_pipeline_dirs`("harness", "path", "created_at") SELECT "harness", "path", "created_at" FROM `pipeline_dirs`;--> statement-breakpoint
|
|
51
|
+
DROP TABLE `pipeline_dirs`;--> statement-breakpoint
|
|
52
|
+
ALTER TABLE `__new_pipeline_dirs` RENAME TO `pipeline_dirs`;--> statement-breakpoint
|
|
53
|
+
CREATE TABLE IF NOT EXISTS `__new_pipeline_node_versions` (
|
|
54
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
55
|
+
`pipeline_version_id` text NOT NULL,
|
|
56
|
+
`pipeline_id` text NOT NULL,
|
|
57
|
+
`node_name` text NOT NULL,
|
|
58
|
+
`node_id` text,
|
|
59
|
+
`kind` text NOT NULL,
|
|
60
|
+
`agent` text,
|
|
61
|
+
`mode` text,
|
|
62
|
+
`content_hash` text NOT NULL,
|
|
63
|
+
`registered_at` integer NOT NULL,
|
|
64
|
+
`retired_at` integer,
|
|
65
|
+
FOREIGN KEY (`pipeline_version_id`) REFERENCES `pipeline_versions`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
66
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE restrict
|
|
67
|
+
);
|
|
68
|
+
--> statement-breakpoint
|
|
69
|
+
INSERT INTO `__new_pipeline_node_versions`("id", "pipeline_version_id", "pipeline_id", "node_name", "node_id", "kind", "agent", "mode", "content_hash", "registered_at", "retired_at") SELECT "id", "pipeline_version_id", "pipeline_id", "node_name", "node_id", "kind", "agent", "mode", "content_hash", "registered_at", "retired_at" FROM `pipeline_node_versions`;--> statement-breakpoint
|
|
70
|
+
DROP TABLE `pipeline_node_versions`;--> statement-breakpoint
|
|
71
|
+
ALTER TABLE `__new_pipeline_node_versions` RENAME TO `pipeline_node_versions`;--> statement-breakpoint
|
|
72
|
+
CREATE INDEX IF NOT EXISTS `idx_pnv_lookup` ON `pipeline_node_versions` (`pipeline_id`,`node_name`,`registered_at`);--> statement-breakpoint
|
|
73
|
+
CREATE UNIQUE INDEX IF NOT EXISTS `idx_pnv_active` ON `pipeline_node_versions` (`pipeline_id`,`node_name`) WHERE "pipeline_node_versions"."retired_at" IS NULL;--> statement-breakpoint
|
|
74
|
+
CREATE TABLE IF NOT EXISTS `__new_discuss_state` (
|
|
75
|
+
`flow_id` text NOT NULL,
|
|
76
|
+
`item_id` text NOT NULL,
|
|
77
|
+
`messages_json` text DEFAULT '[]' NOT NULL,
|
|
78
|
+
`turn_status` text DEFAULT 'idle' NOT NULL,
|
|
79
|
+
`active_turn_id` text,
|
|
80
|
+
`pending_json` text,
|
|
81
|
+
`updated_at` integer NOT NULL,
|
|
82
|
+
`components_json` text DEFAULT '[]' NOT NULL,
|
|
83
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
|
|
84
|
+
);
|
|
85
|
+
--> statement-breakpoint
|
|
86
|
+
INSERT INTO `__new_discuss_state`("flow_id", "item_id", "messages_json", "turn_status", "active_turn_id", "pending_json", "updated_at", "components_json") SELECT "flow_id", "item_id", "messages_json", "turn_status", "active_turn_id", "pending_json", "updated_at", "components_json" FROM `discuss_state`;--> statement-breakpoint
|
|
87
|
+
DROP TABLE `discuss_state`;--> statement-breakpoint
|
|
88
|
+
ALTER TABLE `__new_discuss_state` RENAME TO `discuss_state`;--> statement-breakpoint
|
|
89
|
+
CREATE INDEX IF NOT EXISTS `idx_discuss_updated` ON `discuss_state` (`updated_at`);--> statement-breakpoint
|
|
90
|
+
CREATE UNIQUE INDEX IF NOT EXISTS `idx_discuss_state_unique` ON `discuss_state` (`flow_id`,`item_id`);--> statement-breakpoint
|
|
91
|
+
CREATE TABLE IF NOT EXISTS `__new_discuss_threads` (
|
|
92
|
+
`flow_id` text NOT NULL,
|
|
93
|
+
`gate_node_id` text NOT NULL,
|
|
94
|
+
`item_id` text NOT NULL,
|
|
95
|
+
`agent_id` text,
|
|
96
|
+
`session_key` text NOT NULL,
|
|
97
|
+
`updated_at` integer NOT NULL,
|
|
98
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
|
|
99
|
+
);
|
|
100
|
+
--> statement-breakpoint
|
|
101
|
+
INSERT INTO `__new_discuss_threads`("flow_id", "gate_node_id", "item_id", "agent_id", "session_key", "updated_at") SELECT "flow_id", "gate_node_id", "item_id", "agent_id", "session_key", "updated_at" FROM `discuss_threads`;--> statement-breakpoint
|
|
102
|
+
DROP TABLE `discuss_threads`;--> statement-breakpoint
|
|
103
|
+
ALTER TABLE `__new_discuss_threads` RENAME TO `discuss_threads`;--> statement-breakpoint
|
|
104
|
+
CREATE UNIQUE INDEX IF NOT EXISTS `idx_discuss_threads_unique` ON `discuss_threads` (`flow_id`,`gate_node_id`,`item_id`);--> statement-breakpoint
|
|
105
|
+
CREATE TABLE IF NOT EXISTS `__new_failure_events` (
|
|
106
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
107
|
+
`flow_id` text NOT NULL,
|
|
108
|
+
`failed_at` integer NOT NULL,
|
|
109
|
+
`failure_summary` text NOT NULL,
|
|
110
|
+
`invocation_id` text,
|
|
111
|
+
`execution_id` text,
|
|
112
|
+
`error_type` text,
|
|
113
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade,
|
|
114
|
+
FOREIGN KEY (`invocation_id`) REFERENCES `flow_node_invocations`(`id`) ON UPDATE no action ON DELETE set null,
|
|
115
|
+
FOREIGN KEY (`execution_id`) REFERENCES `flow_node_executions`(`id`) ON UPDATE no action ON DELETE set null
|
|
116
|
+
);
|
|
117
|
+
--> statement-breakpoint
|
|
118
|
+
INSERT INTO `__new_failure_events`("id", "flow_id", "failed_at", "failure_summary", "invocation_id", "execution_id", "error_type") SELECT "id", "flow_id", "failed_at", "failure_summary", "invocation_id", "execution_id", "error_type" FROM `failure_events`;--> statement-breakpoint
|
|
119
|
+
DROP TABLE `failure_events`;--> statement-breakpoint
|
|
120
|
+
ALTER TABLE `__new_failure_events` RENAME TO `failure_events`;--> statement-breakpoint
|
|
121
|
+
CREATE INDEX IF NOT EXISTS `idx_failures_flow` ON `failure_events` (`flow_id`);--> statement-breakpoint
|
|
122
|
+
CREATE INDEX IF NOT EXISTS `idx_failures_failed_at` ON `failure_events` (`failed_at` DESC);--> statement-breakpoint
|
|
123
|
+
CREATE INDEX IF NOT EXISTS `idx_failures_invocation` ON `failure_events` (`invocation_id`);--> statement-breakpoint
|
|
124
|
+
CREATE UNIQUE INDEX IF NOT EXISTS `idx_failures_execution` ON `failure_events` (`execution_id`) WHERE "failure_events"."execution_id" IS NOT NULL;--> statement-breakpoint
|
|
125
|
+
CREATE TABLE IF NOT EXISTS `__new_flow_admission_queue` (
|
|
126
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
127
|
+
`kind` text NOT NULL,
|
|
128
|
+
`flow_id` text NOT NULL,
|
|
129
|
+
`node_id` text,
|
|
130
|
+
`status` text NOT NULL,
|
|
131
|
+
`created_at` integer NOT NULL,
|
|
132
|
+
`admitted_at` integer,
|
|
133
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
|
|
134
|
+
);
|
|
135
|
+
--> statement-breakpoint
|
|
136
|
+
INSERT INTO `__new_flow_admission_queue`("id", "kind", "flow_id", "node_id", "status", "created_at", "admitted_at") SELECT "id", "kind", "flow_id", "node_id", "status", "created_at", "admitted_at" FROM `flow_admission_queue`;--> statement-breakpoint
|
|
137
|
+
DROP TABLE `flow_admission_queue`;--> statement-breakpoint
|
|
138
|
+
ALTER TABLE `__new_flow_admission_queue` RENAME TO `flow_admission_queue`;--> statement-breakpoint
|
|
139
|
+
CREATE INDEX IF NOT EXISTS `idx_admission_status` ON `flow_admission_queue` (`status`);--> statement-breakpoint
|
|
140
|
+
CREATE INDEX IF NOT EXISTS `idx_admission_flow` ON `flow_admission_queue` (`flow_id`);--> statement-breakpoint
|
|
141
|
+
CREATE INDEX IF NOT EXISTS `idx_admission_status_created` ON `flow_admission_queue` (`status`,`created_at`);--> statement-breakpoint
|
|
142
|
+
CREATE TABLE IF NOT EXISTS `__new_flow_events` (
|
|
143
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
144
|
+
`flow_id` text NOT NULL,
|
|
145
|
+
`event_type` text NOT NULL,
|
|
146
|
+
`prev_step` text,
|
|
147
|
+
`curr_step` text,
|
|
148
|
+
`prev_status` text,
|
|
149
|
+
`curr_status` text,
|
|
150
|
+
`wait_kind` text,
|
|
151
|
+
`occurred_at` integer NOT NULL,
|
|
152
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
|
|
153
|
+
);
|
|
154
|
+
--> statement-breakpoint
|
|
155
|
+
INSERT INTO `__new_flow_events`("id", "flow_id", "event_type", "prev_step", "curr_step", "prev_status", "curr_status", "wait_kind", "occurred_at") SELECT "id", "flow_id", "event_type", "prev_step", "curr_step", "prev_status", "curr_status", "wait_kind", "occurred_at" FROM `flow_events`;--> statement-breakpoint
|
|
156
|
+
DROP TABLE `flow_events`;--> statement-breakpoint
|
|
157
|
+
ALTER TABLE `__new_flow_events` RENAME TO `flow_events`;--> statement-breakpoint
|
|
158
|
+
CREATE INDEX IF NOT EXISTS `idx_flow_events_flow_id` ON `flow_events` (`flow_id`);--> statement-breakpoint
|
|
159
|
+
CREATE INDEX IF NOT EXISTS `idx_flow_events_occurred_at` ON `flow_events` (`occurred_at`);--> statement-breakpoint
|
|
160
|
+
CREATE TABLE IF NOT EXISTS `__new_flow_node_executions` (
|
|
161
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
162
|
+
`invocation_id` text NOT NULL,
|
|
163
|
+
`entered_at` integer NOT NULL,
|
|
164
|
+
`exited_at` integer NOT NULL,
|
|
165
|
+
`kind` text DEFAULT 'legacy' NOT NULL,
|
|
166
|
+
FOREIGN KEY (`invocation_id`) REFERENCES `flow_node_invocations`(`id`) ON UPDATE no action ON DELETE cascade
|
|
167
|
+
);
|
|
168
|
+
--> statement-breakpoint
|
|
169
|
+
INSERT INTO `__new_flow_node_executions`("id", "invocation_id", "entered_at", "exited_at", "kind") SELECT "id", "invocation_id", "entered_at", "exited_at", "kind" FROM `flow_node_executions`;--> statement-breakpoint
|
|
170
|
+
DROP TABLE `flow_node_executions`;--> statement-breakpoint
|
|
171
|
+
ALTER TABLE `__new_flow_node_executions` RENAME TO `flow_node_executions`;--> statement-breakpoint
|
|
172
|
+
CREATE INDEX IF NOT EXISTS `idx_fne_invocation` ON `flow_node_executions` (`invocation_id`);--> statement-breakpoint
|
|
173
|
+
CREATE INDEX IF NOT EXISTS `idx_fne_exited` ON `flow_node_executions` (`exited_at`);--> statement-breakpoint
|
|
174
|
+
CREATE TABLE IF NOT EXISTS `__new_flow_node_invocations` (
|
|
175
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
176
|
+
`flow_id` text NOT NULL,
|
|
177
|
+
`pipeline_id` text,
|
|
178
|
+
`node_id` text NOT NULL,
|
|
179
|
+
`subflow_key` text,
|
|
180
|
+
`visit_seq` integer DEFAULT 1 NOT NULL,
|
|
181
|
+
`invoked_at` integer NOT NULL,
|
|
182
|
+
`result_json` text,
|
|
183
|
+
`result_written_at` integer,
|
|
184
|
+
`result_too_large_bytes` integer,
|
|
185
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
|
|
186
|
+
);
|
|
187
|
+
--> statement-breakpoint
|
|
188
|
+
INSERT INTO `__new_flow_node_invocations`("id", "flow_id", "pipeline_id", "node_id", "subflow_key", "visit_seq", "invoked_at", "result_json", "result_written_at", "result_too_large_bytes") SELECT "id", "flow_id", "pipeline_id", "node_id", "subflow_key", "visit_seq", "invoked_at", "result_json", "result_written_at", "result_too_large_bytes" FROM `flow_node_invocations`;--> statement-breakpoint
|
|
189
|
+
DROP TABLE `flow_node_invocations`;--> statement-breakpoint
|
|
190
|
+
ALTER TABLE `__new_flow_node_invocations` RENAME TO `flow_node_invocations`;--> statement-breakpoint
|
|
191
|
+
CREATE INDEX IF NOT EXISTS `idx_invocations_flow` ON `flow_node_invocations` (`flow_id`);--> statement-breakpoint
|
|
192
|
+
CREATE INDEX IF NOT EXISTS `idx_invocations_node_subflow` ON `flow_node_invocations` (`node_id`,`subflow_key`);--> statement-breakpoint
|
|
193
|
+
CREATE INDEX IF NOT EXISTS `idx_invocations_pipe_node` ON `flow_node_invocations` (`pipeline_id`,`node_id`);--> statement-breakpoint
|
|
194
|
+
CREATE UNIQUE INDEX IF NOT EXISTS `idx_invocations_identity` ON `flow_node_invocations` (`flow_id`,`node_id`,COALESCE(`subflow_key`, ''),`visit_seq`);--> statement-breakpoint
|
|
195
|
+
CREATE TABLE IF NOT EXISTS `__new_flow_runs` (
|
|
196
|
+
`flow_id` text PRIMARY KEY NOT NULL,
|
|
197
|
+
`owner_key` text DEFAULT '' NOT NULL,
|
|
198
|
+
`revision` integer DEFAULT 0 NOT NULL,
|
|
199
|
+
`status` text NOT NULL,
|
|
200
|
+
`last_step` text,
|
|
201
|
+
`status_reason` text,
|
|
202
|
+
`state_json` text DEFAULT '{}' NOT NULL,
|
|
203
|
+
`wait_json` text,
|
|
204
|
+
`cancel_requested_at` integer,
|
|
205
|
+
`created_at` integer NOT NULL,
|
|
206
|
+
`updated_at` integer NOT NULL,
|
|
207
|
+
`ended_at` integer,
|
|
208
|
+
`parent_invocation_id` text,
|
|
209
|
+
`pipeline_id` text,
|
|
210
|
+
FOREIGN KEY (`parent_invocation_id`) REFERENCES `flow_node_invocations`(`id`) ON UPDATE no action ON DELETE set null,
|
|
211
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null
|
|
212
|
+
);
|
|
213
|
+
--> statement-breakpoint
|
|
214
|
+
INSERT INTO `__new_flow_runs`("flow_id", "owner_key", "revision", "status", "last_step", "status_reason", "state_json", "wait_json", "cancel_requested_at", "created_at", "updated_at", "ended_at", "parent_invocation_id", "pipeline_id") SELECT "flow_id", "owner_key", "revision", "status", "last_step", "status_reason", "state_json", "wait_json", "cancel_requested_at", "created_at", "updated_at", "ended_at", "parent_invocation_id", "pipeline_id" FROM `flow_runs`;--> statement-breakpoint
|
|
215
|
+
DROP TABLE `flow_runs`;--> statement-breakpoint
|
|
216
|
+
ALTER TABLE `__new_flow_runs` RENAME TO `flow_runs`;--> statement-breakpoint
|
|
217
|
+
CREATE INDEX IF NOT EXISTS `idx_pfr_status` ON `flow_runs` (`status`) WHERE "flow_runs"."ended_at" IS NULL;--> statement-breakpoint
|
|
218
|
+
CREATE INDEX IF NOT EXISTS `idx_pfr_updated` ON `flow_runs` (`updated_at` DESC);--> statement-breakpoint
|
|
219
|
+
CREATE INDEX IF NOT EXISTS `idx_pfr_created` ON `flow_runs` (`created_at` DESC);--> statement-breakpoint
|
|
220
|
+
CREATE UNIQUE INDEX IF NOT EXISTS `idx_pfr_parent_invocation` ON `flow_runs` (`parent_invocation_id`) WHERE "flow_runs"."parent_invocation_id" IS NOT NULL;--> statement-breakpoint
|
|
221
|
+
CREATE INDEX IF NOT EXISTS `idx_flow_runs_pipeline_id` ON `flow_runs` (`pipeline_id`);--> statement-breakpoint
|
|
222
|
+
CREATE TABLE IF NOT EXISTS `__new_flow_sessions` (
|
|
223
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
224
|
+
`flow_id` text NOT NULL,
|
|
225
|
+
`session_key` text NOT NULL,
|
|
226
|
+
`node_id` text,
|
|
227
|
+
`branch_item_id` text,
|
|
228
|
+
`spawned_at` integer NOT NULL,
|
|
229
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
|
|
230
|
+
);
|
|
231
|
+
--> statement-breakpoint
|
|
232
|
+
INSERT INTO `__new_flow_sessions`("id", "flow_id", "session_key", "node_id", "branch_item_id", "spawned_at") SELECT "id", "flow_id", "session_key", "node_id", "branch_item_id", "spawned_at" FROM `flow_sessions`;--> statement-breakpoint
|
|
233
|
+
DROP TABLE `flow_sessions`;--> statement-breakpoint
|
|
234
|
+
ALTER TABLE `__new_flow_sessions` RENAME TO `flow_sessions`;--> statement-breakpoint
|
|
235
|
+
CREATE INDEX IF NOT EXISTS `idx_flow_sessions_flow_id` ON `flow_sessions` (`flow_id`);--> statement-breakpoint
|
|
236
|
+
CREATE UNIQUE INDEX IF NOT EXISTS `idx_flow_sessions_uniq` ON `flow_sessions` (`flow_id`,`session_key`);--> statement-breakpoint
|
|
237
|
+
CREATE TABLE IF NOT EXISTS `__new_gate_records` (
|
|
238
|
+
`flow_id` text NOT NULL,
|
|
239
|
+
`node_id` text NOT NULL,
|
|
240
|
+
`record_json` text NOT NULL,
|
|
241
|
+
`updated_at` integer NOT NULL,
|
|
242
|
+
PRIMARY KEY(`flow_id`, `node_id`),
|
|
243
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade
|
|
244
|
+
);
|
|
245
|
+
--> statement-breakpoint
|
|
246
|
+
INSERT INTO `__new_gate_records`("flow_id", "node_id", "record_json", "updated_at") SELECT "flow_id", "node_id", "record_json", "updated_at" FROM `gate_records`;--> statement-breakpoint
|
|
247
|
+
DROP TABLE `gate_records`;--> statement-breakpoint
|
|
248
|
+
ALTER TABLE `__new_gate_records` RENAME TO `gate_records`;--> statement-breakpoint
|
|
249
|
+
CREATE TABLE IF NOT EXISTS `__new_node_health` (
|
|
250
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
251
|
+
`pipeline_id` text NOT NULL,
|
|
252
|
+
`node_id` text NOT NULL,
|
|
253
|
+
`status` text NOT NULL,
|
|
254
|
+
`reason` text NOT NULL,
|
|
255
|
+
`blocked_by_flow_id` text,
|
|
256
|
+
`resolved_via` text,
|
|
257
|
+
`created_at` integer NOT NULL,
|
|
258
|
+
`updated_at` integer NOT NULL,
|
|
259
|
+
`ended_at` integer,
|
|
260
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
261
|
+
FOREIGN KEY (`blocked_by_flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
|
|
262
|
+
);
|
|
263
|
+
--> statement-breakpoint
|
|
264
|
+
INSERT INTO `__new_node_health`("id", "pipeline_id", "node_id", "status", "reason", "blocked_by_flow_id", "resolved_via", "created_at", "updated_at", "ended_at") SELECT "id", "pipeline_id", "node_id", "status", "reason", "blocked_by_flow_id", "resolved_via", "created_at", "updated_at", "ended_at" FROM `node_health`;--> statement-breakpoint
|
|
265
|
+
DROP TABLE `node_health`;--> statement-breakpoint
|
|
266
|
+
ALTER TABLE `__new_node_health` RENAME TO `node_health`;--> statement-breakpoint
|
|
267
|
+
CREATE UNIQUE INDEX IF NOT EXISTS `idx_node_health_one_active` ON `node_health` (`pipeline_id`,`node_id`) WHERE "node_health"."status" = 'blocked';--> statement-breakpoint
|
|
268
|
+
CREATE INDEX IF NOT EXISTS `idx_node_health_pipeline` ON `node_health` (`pipeline_id`,`status`);--> statement-breakpoint
|
|
269
|
+
CREATE TABLE IF NOT EXISTS `__new_pipeline_versions` (
|
|
270
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
271
|
+
`pipeline_id` text NOT NULL,
|
|
272
|
+
`kind` text,
|
|
273
|
+
`allow_concurrent` text,
|
|
274
|
+
`is_synthetic` integer NOT NULL,
|
|
275
|
+
`parent_pipeline_id` text,
|
|
276
|
+
`source_path` text,
|
|
277
|
+
`content_hash` text NOT NULL,
|
|
278
|
+
`registered_at` integer NOT NULL,
|
|
279
|
+
`retired_at` integer,
|
|
280
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
281
|
+
FOREIGN KEY (`parent_pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null
|
|
282
|
+
);
|
|
283
|
+
--> statement-breakpoint
|
|
284
|
+
INSERT INTO `__new_pipeline_versions`("id", "pipeline_id", "kind", "allow_concurrent", "is_synthetic", "parent_pipeline_id", "source_path", "content_hash", "registered_at", "retired_at") SELECT "id", "pipeline_id", "kind", "allow_concurrent", "is_synthetic", "parent_pipeline_id", "source_path", "content_hash", "registered_at", "retired_at" FROM `pipeline_versions`;--> statement-breakpoint
|
|
285
|
+
DROP TABLE `pipeline_versions`;--> statement-breakpoint
|
|
286
|
+
ALTER TABLE `__new_pipeline_versions` RENAME TO `pipeline_versions`;--> statement-breakpoint
|
|
287
|
+
CREATE INDEX IF NOT EXISTS `idx_pv_lookup` ON `pipeline_versions` (`pipeline_id`,`registered_at`);--> statement-breakpoint
|
|
288
|
+
CREATE UNIQUE INDEX IF NOT EXISTS `idx_pv_active` ON `pipeline_versions` (`pipeline_id`) WHERE "pipeline_versions"."retired_at" IS NULL;--> statement-breakpoint
|
|
289
|
+
CREATE TABLE IF NOT EXISTS `__new_tool_results` (
|
|
290
|
+
`session_key` text PRIMARY KEY NOT NULL,
|
|
291
|
+
`run_id` text,
|
|
292
|
+
`agent_id` text,
|
|
293
|
+
`kind` text,
|
|
294
|
+
`payload_json` text NOT NULL,
|
|
295
|
+
`updated_at` integer NOT NULL,
|
|
296
|
+
FOREIGN KEY (`run_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
|
|
297
|
+
);
|
|
298
|
+
--> statement-breakpoint
|
|
299
|
+
INSERT INTO `__new_tool_results`("session_key", "run_id", "agent_id", "kind", "payload_json", "updated_at") SELECT "session_key", "run_id", "agent_id", "kind", "payload_json", "updated_at" FROM `tool_results`;--> statement-breakpoint
|
|
300
|
+
DROP TABLE `tool_results`;--> statement-breakpoint
|
|
301
|
+
ALTER TABLE `__new_tool_results` RENAME TO `tool_results`;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
-- Move the lineage/cost tables into runtime so their flow_id/pipeline_id
|
|
2
|
+
-- columns can carry FKs (SQLite cannot constrain across database files).
|
|
3
|
+
-- Data is copied once by state/ops-merge.js after this snapshot runs; the
|
|
4
|
+
-- CREATEs stay IF NOT EXISTS so a retried migration is safe.
|
|
5
|
+
CREATE TABLE IF NOT EXISTS `cost_by_call` (
|
|
6
|
+
`session_id` text NOT NULL,
|
|
7
|
+
`msg_id` text NOT NULL,
|
|
8
|
+
`ts` integer NOT NULL,
|
|
9
|
+
`provider` text,
|
|
10
|
+
`model` text,
|
|
11
|
+
`input_tokens` integer,
|
|
12
|
+
`output_tokens` integer,
|
|
13
|
+
`cache_read_tokens` integer,
|
|
14
|
+
`cache_write_tokens` integer,
|
|
15
|
+
`total_tokens` integer,
|
|
16
|
+
`cost_input` real,
|
|
17
|
+
`cost_output` real,
|
|
18
|
+
`cost_cache_read` real,
|
|
19
|
+
`cost_cache_write` real,
|
|
20
|
+
`cost_total` real NOT NULL,
|
|
21
|
+
`session_key` text,
|
|
22
|
+
`agent_id` text,
|
|
23
|
+
`root_session_key` text,
|
|
24
|
+
`root_kind` text,
|
|
25
|
+
`root_label` text,
|
|
26
|
+
`pipeline_id` text,
|
|
27
|
+
`flow_id` text,
|
|
28
|
+
`node_id` text,
|
|
29
|
+
`item_key` text,
|
|
30
|
+
PRIMARY KEY(`session_id`, `msg_id`),
|
|
31
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
|
|
32
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
|
|
33
|
+
);
|
|
34
|
+
--> statement-breakpoint
|
|
35
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_ts` ON `cost_by_call` (`ts`);--> statement-breakpoint
|
|
36
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_root_key` ON `cost_by_call` (`root_session_key`);--> statement-breakpoint
|
|
37
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_root_kind_ts` ON `cost_by_call` (`root_kind`,`ts`);--> statement-breakpoint
|
|
38
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_pipeline_ts` ON `cost_by_call` (`pipeline_id`,`ts`);--> statement-breakpoint
|
|
39
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_flow_node` ON `cost_by_call` (`flow_id`,`node_id`);--> statement-breakpoint
|
|
40
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_model_ts` ON `cost_by_call` (`model`,`ts`);--> statement-breakpoint
|
|
41
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_session` ON `cost_by_call` (`session_id`);--> statement-breakpoint
|
|
42
|
+
CREATE TABLE IF NOT EXISTS `queue_items` (
|
|
43
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
44
|
+
`label` text NOT NULL,
|
|
45
|
+
`agent` text NOT NULL,
|
|
46
|
+
`agent_emoji` text DEFAULT '🤖' NOT NULL,
|
|
47
|
+
`trigger` text DEFAULT 'manual' NOT NULL,
|
|
48
|
+
`cost_low` real DEFAULT 0 NOT NULL,
|
|
49
|
+
`cost_high` real DEFAULT 0 NOT NULL,
|
|
50
|
+
`brief` text,
|
|
51
|
+
`model_chain` text,
|
|
52
|
+
`pipeline` text,
|
|
53
|
+
`node` text,
|
|
54
|
+
`token_estimate` integer,
|
|
55
|
+
`status` text DEFAULT 'pending' NOT NULL,
|
|
56
|
+
`created_at` integer NOT NULL,
|
|
57
|
+
`expires_at` integer,
|
|
58
|
+
`decided_at` integer,
|
|
59
|
+
`decision` text,
|
|
60
|
+
`pipeline_id` text,
|
|
61
|
+
`pipeline_args` text,
|
|
62
|
+
`flow_id` text,
|
|
63
|
+
`enqueuer_session_key` text,
|
|
64
|
+
`kind` text,
|
|
65
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
|
|
66
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
|
|
67
|
+
);
|
|
68
|
+
--> statement-breakpoint
|
|
69
|
+
CREATE INDEX IF NOT EXISTS `idx_status` ON `queue_items` (`status`);--> statement-breakpoint
|
|
70
|
+
CREATE INDEX IF NOT EXISTS `idx_created_at` ON `queue_items` ("created_at" desc);--> statement-breakpoint
|
|
71
|
+
CREATE INDEX IF NOT EXISTS `idx_flow_node` ON `queue_items` (`flow_id`,`node`);--> statement-breakpoint
|
|
72
|
+
CREATE TABLE IF NOT EXISTS `session_lineage` (
|
|
73
|
+
`child_session_key` text PRIMARY KEY NOT NULL,
|
|
74
|
+
`parent_session_key` text,
|
|
75
|
+
`root_session_key` text NOT NULL,
|
|
76
|
+
`kind` text NOT NULL,
|
|
77
|
+
`root_kind` text NOT NULL,
|
|
78
|
+
`root_label` text,
|
|
79
|
+
`agent_id` text,
|
|
80
|
+
`pipeline_id` text,
|
|
81
|
+
`flow_id` text,
|
|
82
|
+
`node_id` text,
|
|
83
|
+
`item_key` text,
|
|
84
|
+
`first_seen_at` integer NOT NULL,
|
|
85
|
+
`source` text NOT NULL,
|
|
86
|
+
`run_id` text,
|
|
87
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
|
|
88
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
|
|
89
|
+
);
|
|
90
|
+
--> statement-breakpoint
|
|
91
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_root` ON `session_lineage` (`root_session_key`);--> statement-breakpoint
|
|
92
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_parent` ON `session_lineage` (`parent_session_key`);--> statement-breakpoint
|
|
93
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_pipeline` ON `session_lineage` (`pipeline_id`);--> statement-breakpoint
|
|
94
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_flow` ON `session_lineage` (`flow_id`);--> statement-breakpoint
|
|
95
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_root_kind` ON `session_lineage` (`root_kind`);--> statement-breakpoint
|
|
96
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_run` ON `session_lineage` (`run_id`);
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS `sessions` (
|
|
2
|
+
`session_key` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`first_seen_at` integer NOT NULL
|
|
4
|
+
);
|
|
5
|
+
--> statement-breakpoint
|
|
6
|
+
CREATE INDEX IF NOT EXISTS `idx_sessions_first_seen` ON `sessions` (`first_seen_at`);--> statement-breakpoint
|
|
7
|
+
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
|
8
|
+
CREATE TABLE IF NOT EXISTS `__new_cost_by_call` (
|
|
9
|
+
`session_id` text NOT NULL,
|
|
10
|
+
`msg_id` text NOT NULL,
|
|
11
|
+
`ts` integer NOT NULL,
|
|
12
|
+
`provider` text,
|
|
13
|
+
`model` text,
|
|
14
|
+
`input_tokens` integer,
|
|
15
|
+
`output_tokens` integer,
|
|
16
|
+
`cache_read_tokens` integer,
|
|
17
|
+
`cache_write_tokens` integer,
|
|
18
|
+
`total_tokens` integer,
|
|
19
|
+
`cost_input` real,
|
|
20
|
+
`cost_output` real,
|
|
21
|
+
`cost_cache_read` real,
|
|
22
|
+
`cost_cache_write` real,
|
|
23
|
+
`cost_total` real NOT NULL,
|
|
24
|
+
`session_key` text,
|
|
25
|
+
`agent_id` text,
|
|
26
|
+
`root_session_key` text,
|
|
27
|
+
`root_kind` text,
|
|
28
|
+
`root_label` text,
|
|
29
|
+
`pipeline_id` text,
|
|
30
|
+
`flow_id` text,
|
|
31
|
+
`node_id` text,
|
|
32
|
+
`item_key` text,
|
|
33
|
+
PRIMARY KEY(`session_id`, `msg_id`),
|
|
34
|
+
FOREIGN KEY (`session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE set null,
|
|
35
|
+
FOREIGN KEY (`root_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE set null,
|
|
36
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
|
|
37
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
|
|
38
|
+
);
|
|
39
|
+
--> statement-breakpoint
|
|
40
|
+
INSERT INTO `__new_cost_by_call`("session_id", "msg_id", "ts", "provider", "model", "input_tokens", "output_tokens", "cache_read_tokens", "cache_write_tokens", "total_tokens", "cost_input", "cost_output", "cost_cache_read", "cost_cache_write", "cost_total", "session_key", "agent_id", "root_session_key", "root_kind", "root_label", "pipeline_id", "flow_id", "node_id", "item_key") SELECT "session_id", "msg_id", "ts", "provider", "model", "input_tokens", "output_tokens", "cache_read_tokens", "cache_write_tokens", "total_tokens", "cost_input", "cost_output", "cost_cache_read", "cost_cache_write", "cost_total", "session_key", "agent_id", "root_session_key", "root_kind", "root_label", "pipeline_id", "flow_id", "node_id", "item_key" FROM `cost_by_call`;--> statement-breakpoint
|
|
41
|
+
DROP TABLE `cost_by_call`;--> statement-breakpoint
|
|
42
|
+
ALTER TABLE `__new_cost_by_call` RENAME TO `cost_by_call`;--> statement-breakpoint
|
|
43
|
+
PRAGMA foreign_keys=ON;--> statement-breakpoint
|
|
44
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_ts` ON `cost_by_call` (`ts`);--> statement-breakpoint
|
|
45
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_root_key` ON `cost_by_call` (`root_session_key`);--> statement-breakpoint
|
|
46
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_root_kind_ts` ON `cost_by_call` (`root_kind`,`ts`);--> statement-breakpoint
|
|
47
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_pipeline_ts` ON `cost_by_call` (`pipeline_id`,`ts`);--> statement-breakpoint
|
|
48
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_flow_node` ON `cost_by_call` (`flow_id`,`node_id`);--> statement-breakpoint
|
|
49
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_model_ts` ON `cost_by_call` (`model`,`ts`);--> statement-breakpoint
|
|
50
|
+
CREATE INDEX IF NOT EXISTS `idx_cost_session` ON `cost_by_call` (`session_id`);--> statement-breakpoint
|
|
51
|
+
CREATE TABLE IF NOT EXISTS `__new_discuss_threads` (
|
|
52
|
+
`flow_id` text NOT NULL,
|
|
53
|
+
`gate_node_id` text NOT NULL,
|
|
54
|
+
`item_id` text NOT NULL,
|
|
55
|
+
`agent_id` text,
|
|
56
|
+
`session_key` text NOT NULL,
|
|
57
|
+
`updated_at` integer NOT NULL,
|
|
58
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade,
|
|
59
|
+
FOREIGN KEY (`session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE no action
|
|
60
|
+
);
|
|
61
|
+
--> statement-breakpoint
|
|
62
|
+
INSERT INTO `__new_discuss_threads`("flow_id", "gate_node_id", "item_id", "agent_id", "session_key", "updated_at") SELECT "flow_id", "gate_node_id", "item_id", "agent_id", "session_key", "updated_at" FROM `discuss_threads`;--> statement-breakpoint
|
|
63
|
+
DROP TABLE `discuss_threads`;--> statement-breakpoint
|
|
64
|
+
ALTER TABLE `__new_discuss_threads` RENAME TO `discuss_threads`;--> statement-breakpoint
|
|
65
|
+
CREATE UNIQUE INDEX IF NOT EXISTS `idx_discuss_threads_unique` ON `discuss_threads` (`flow_id`,`gate_node_id`,`item_id`);--> statement-breakpoint
|
|
66
|
+
CREATE TABLE IF NOT EXISTS `__new_flow_sessions` (
|
|
67
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
68
|
+
`flow_id` text NOT NULL,
|
|
69
|
+
`session_key` text NOT NULL,
|
|
70
|
+
`node_id` text,
|
|
71
|
+
`branch_item_id` text,
|
|
72
|
+
`spawned_at` integer NOT NULL,
|
|
73
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE cascade,
|
|
74
|
+
FOREIGN KEY (`session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE no action
|
|
75
|
+
);
|
|
76
|
+
--> statement-breakpoint
|
|
77
|
+
INSERT INTO `__new_flow_sessions`("id", "flow_id", "session_key", "node_id", "branch_item_id", "spawned_at") SELECT "id", "flow_id", "session_key", "node_id", "branch_item_id", "spawned_at" FROM `flow_sessions`;--> statement-breakpoint
|
|
78
|
+
DROP TABLE `flow_sessions`;--> statement-breakpoint
|
|
79
|
+
ALTER TABLE `__new_flow_sessions` RENAME TO `flow_sessions`;--> statement-breakpoint
|
|
80
|
+
CREATE INDEX IF NOT EXISTS `idx_flow_sessions_flow_id` ON `flow_sessions` (`flow_id`);--> statement-breakpoint
|
|
81
|
+
CREATE UNIQUE INDEX IF NOT EXISTS `idx_flow_sessions_uniq` ON `flow_sessions` (`flow_id`,`session_key`);--> statement-breakpoint
|
|
82
|
+
CREATE TABLE IF NOT EXISTS `__new_queue_items` (
|
|
83
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
84
|
+
`label` text NOT NULL,
|
|
85
|
+
`agent` text NOT NULL,
|
|
86
|
+
`agent_emoji` text DEFAULT '🤖' NOT NULL,
|
|
87
|
+
`trigger` text DEFAULT 'manual' NOT NULL,
|
|
88
|
+
`cost_low` real DEFAULT 0 NOT NULL,
|
|
89
|
+
`cost_high` real DEFAULT 0 NOT NULL,
|
|
90
|
+
`brief` text,
|
|
91
|
+
`model_chain` text,
|
|
92
|
+
`pipeline` text,
|
|
93
|
+
`node` text,
|
|
94
|
+
`token_estimate` integer,
|
|
95
|
+
`status` text DEFAULT 'pending' NOT NULL,
|
|
96
|
+
`created_at` integer NOT NULL,
|
|
97
|
+
`expires_at` integer,
|
|
98
|
+
`decided_at` integer,
|
|
99
|
+
`decision` text,
|
|
100
|
+
`pipeline_id` text,
|
|
101
|
+
`pipeline_args` text,
|
|
102
|
+
`flow_id` text,
|
|
103
|
+
`enqueuer_session_key` text,
|
|
104
|
+
`kind` text,
|
|
105
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
|
|
106
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null,
|
|
107
|
+
FOREIGN KEY (`enqueuer_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE set null
|
|
108
|
+
);
|
|
109
|
+
--> statement-breakpoint
|
|
110
|
+
INSERT INTO `__new_queue_items`("id", "label", "agent", "agent_emoji", "trigger", "cost_low", "cost_high", "brief", "model_chain", "pipeline", "node", "token_estimate", "status", "created_at", "expires_at", "decided_at", "decision", "pipeline_id", "pipeline_args", "flow_id", "enqueuer_session_key", "kind") SELECT "id", "label", "agent", "agent_emoji", "trigger", "cost_low", "cost_high", "brief", "model_chain", "pipeline", "node", "token_estimate", "status", "created_at", "expires_at", "decided_at", "decision", "pipeline_id", "pipeline_args", "flow_id", "enqueuer_session_key", "kind" FROM `queue_items`;--> statement-breakpoint
|
|
111
|
+
DROP TABLE `queue_items`;--> statement-breakpoint
|
|
112
|
+
ALTER TABLE `__new_queue_items` RENAME TO `queue_items`;--> statement-breakpoint
|
|
113
|
+
CREATE INDEX IF NOT EXISTS `idx_status` ON `queue_items` (`status`);--> statement-breakpoint
|
|
114
|
+
CREATE INDEX IF NOT EXISTS `idx_created_at` ON `queue_items` ("created_at" desc);--> statement-breakpoint
|
|
115
|
+
CREATE INDEX IF NOT EXISTS `idx_flow_node` ON `queue_items` (`flow_id`,`node`);--> statement-breakpoint
|
|
116
|
+
CREATE TABLE IF NOT EXISTS `__new_session_lineage` (
|
|
117
|
+
`child_session_key` text PRIMARY KEY NOT NULL,
|
|
118
|
+
`parent_session_key` text,
|
|
119
|
+
`root_session_key` text NOT NULL,
|
|
120
|
+
`kind` text NOT NULL,
|
|
121
|
+
`root_kind` text NOT NULL,
|
|
122
|
+
`root_label` text,
|
|
123
|
+
`agent_id` text,
|
|
124
|
+
`pipeline_id` text,
|
|
125
|
+
`flow_id` text,
|
|
126
|
+
`node_id` text,
|
|
127
|
+
`item_key` text,
|
|
128
|
+
`first_seen_at` integer NOT NULL,
|
|
129
|
+
`source` text NOT NULL,
|
|
130
|
+
`run_id` text,
|
|
131
|
+
FOREIGN KEY (`child_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE no action,
|
|
132
|
+
FOREIGN KEY (`parent_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE set null,
|
|
133
|
+
FOREIGN KEY (`root_session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE no action,
|
|
134
|
+
FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`) ON UPDATE no action ON DELETE set null,
|
|
135
|
+
FOREIGN KEY (`flow_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
|
|
136
|
+
);
|
|
137
|
+
--> statement-breakpoint
|
|
138
|
+
INSERT INTO `__new_session_lineage`("child_session_key", "parent_session_key", "root_session_key", "kind", "root_kind", "root_label", "agent_id", "pipeline_id", "flow_id", "node_id", "item_key", "first_seen_at", "source", "run_id") SELECT "child_session_key", "parent_session_key", "root_session_key", "kind", "root_kind", "root_label", "agent_id", "pipeline_id", "flow_id", "node_id", "item_key", "first_seen_at", "source", "run_id" FROM `session_lineage`;--> statement-breakpoint
|
|
139
|
+
DROP TABLE `session_lineage`;--> statement-breakpoint
|
|
140
|
+
ALTER TABLE `__new_session_lineage` RENAME TO `session_lineage`;--> statement-breakpoint
|
|
141
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_root` ON `session_lineage` (`root_session_key`);--> statement-breakpoint
|
|
142
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_parent` ON `session_lineage` (`parent_session_key`);--> statement-breakpoint
|
|
143
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_pipeline` ON `session_lineage` (`pipeline_id`);--> statement-breakpoint
|
|
144
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_flow` ON `session_lineage` (`flow_id`);--> statement-breakpoint
|
|
145
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_root_kind` ON `session_lineage` (`root_kind`);--> statement-breakpoint
|
|
146
|
+
CREATE INDEX IF NOT EXISTS `idx_lineage_run` ON `session_lineage` (`run_id`);--> statement-breakpoint
|
|
147
|
+
CREATE TABLE IF NOT EXISTS `__new_tool_results` (
|
|
148
|
+
`session_key` text PRIMARY KEY NOT NULL,
|
|
149
|
+
`run_id` text,
|
|
150
|
+
`agent_id` text,
|
|
151
|
+
`kind` text,
|
|
152
|
+
`payload_json` text NOT NULL,
|
|
153
|
+
`updated_at` integer NOT NULL,
|
|
154
|
+
FOREIGN KEY (`session_key`) REFERENCES `sessions`(`session_key`) ON UPDATE no action ON DELETE no action,
|
|
155
|
+
FOREIGN KEY (`run_id`) REFERENCES `flow_runs`(`flow_id`) ON UPDATE no action ON DELETE set null
|
|
156
|
+
);
|
|
157
|
+
--> statement-breakpoint
|
|
158
|
+
INSERT INTO `__new_tool_results`("session_key", "run_id", "agent_id", "kind", "payload_json", "updated_at") SELECT "session_key", "run_id", "agent_id", "kind", "payload_json", "updated_at" FROM `tool_results`;--> statement-breakpoint
|
|
159
|
+
DROP TABLE `tool_results`;--> statement-breakpoint
|
|
160
|
+
ALTER TABLE `__new_tool_results` RENAME TO `tool_results`;
|