@stackbone/sdk 0.1.0-alpha.3 → 0.1.0-alpha.5

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.
@@ -1,71 +0,0 @@
1
- 'use strict';
2
-
3
- // src/surfaces/agent-local/rag/migrations/index.ts
4
- var STACKBONE_RAG_MARKER_PREFIX = "-- @stackbone:rag@";
5
- var STACKBONE_RAG_MARKER_REGEX = /^-- @stackbone:rag@v(\d+)$/;
6
- var STACKBONE_RAG_V1_FILENAME_SUFFIX = "stackbone_rag_v1.sql";
7
- var STACKBONE_RAG_V1_SQL = `-- @stackbone:rag@v1
8
- CREATE EXTENSION IF NOT EXISTS vector;
9
- --> statement-breakpoint
10
- CREATE TABLE "stackbone_rag_collections" (
11
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
12
- "name" text NOT NULL,
13
- "metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
14
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
15
- CONSTRAINT "stackbone_rag_collections_name_unique" UNIQUE("name")
16
- );
17
- --> statement-breakpoint
18
- CREATE TABLE "stackbone_rag_documents" (
19
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
20
- "collection_id" uuid NOT NULL,
21
- "source" text NOT NULL,
22
- "content_hash" text NOT NULL,
23
- "metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
24
- "created_at" timestamp with time zone DEFAULT now() NOT NULL
25
- );
26
- --> statement-breakpoint
27
- CREATE TABLE "stackbone_rag_chunks" (
28
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
29
- "document_id" uuid NOT NULL,
30
- "ordinal" integer NOT NULL,
31
- "content" text NOT NULL,
32
- "embedding" vector(1536) NOT NULL,
33
- "metadata" jsonb DEFAULT '{}'::jsonb NOT NULL
34
- );
35
- --> statement-breakpoint
36
- CREATE TABLE "stackbone_rag_jobs" (
37
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
38
- "collection_id" uuid NOT NULL,
39
- "status" text DEFAULT 'queued' NOT NULL,
40
- "progress" jsonb DEFAULT '{"totalChunks":0,"processedChunks":0}'::jsonb NOT NULL,
41
- "error" text,
42
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
43
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
44
- CONSTRAINT "stackbone_rag_jobs_status_check" CHECK ("status" IN ('queued','running','succeeded','failed','cancelled'))
45
- );
46
- --> statement-breakpoint
47
- ALTER TABLE "stackbone_rag_documents" ADD CONSTRAINT "stackbone_rag_documents_collection_id_fk" FOREIGN KEY ("collection_id") REFERENCES "public"."stackbone_rag_collections"("id") ON DELETE cascade ON UPDATE no action;
48
- --> statement-breakpoint
49
- ALTER TABLE "stackbone_rag_chunks" ADD CONSTRAINT "stackbone_rag_chunks_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."stackbone_rag_documents"("id") ON DELETE cascade ON UPDATE no action;
50
- --> statement-breakpoint
51
- ALTER TABLE "stackbone_rag_jobs" ADD CONSTRAINT "stackbone_rag_jobs_collection_id_fk" FOREIGN KEY ("collection_id") REFERENCES "public"."stackbone_rag_collections"("id") ON DELETE cascade ON UPDATE no action;
52
- --> statement-breakpoint
53
- CREATE INDEX "stackbone_rag_documents_collection_idx" ON "stackbone_rag_documents" USING btree ("collection_id");
54
- --> statement-breakpoint
55
- CREATE INDEX "stackbone_rag_documents_hash_idx" ON "stackbone_rag_documents" USING btree ("collection_id","content_hash");
56
- --> statement-breakpoint
57
- CREATE INDEX "stackbone_rag_chunks_document_idx" ON "stackbone_rag_chunks" USING btree ("document_id");
58
- --> statement-breakpoint
59
- CREATE INDEX "stackbone_rag_chunks_embedding_hnsw" ON "stackbone_rag_chunks" USING hnsw ("embedding" vector_cosine_ops);
60
- --> statement-breakpoint
61
- CREATE INDEX "stackbone_rag_jobs_collection_idx" ON "stackbone_rag_jobs" USING btree ("collection_id");
62
- --> statement-breakpoint
63
- CREATE INDEX "stackbone_rag_jobs_status_idx" ON "stackbone_rag_jobs" USING btree ("status");
64
- `;
65
-
66
- exports.STACKBONE_RAG_MARKER_PREFIX = STACKBONE_RAG_MARKER_PREFIX;
67
- exports.STACKBONE_RAG_MARKER_REGEX = STACKBONE_RAG_MARKER_REGEX;
68
- exports.STACKBONE_RAG_V1_FILENAME_SUFFIX = STACKBONE_RAG_V1_FILENAME_SUFFIX;
69
- exports.STACKBONE_RAG_V1_SQL = STACKBONE_RAG_V1_SQL;
70
- //# sourceMappingURL=index.cjs.map
71
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../libs/sdk/src/surfaces/agent-local/rag/migrations/index.ts"],"names":["STACKBONE_RAG_MARKER_PREFIX","STACKBONE_RAG_MARKER_REGEX","STACKBONE_RAG_V1_FILENAME_SUFFIX","STACKBONE_RAG_V1_SQL"],"mappings":";;;AAqBO,IAAMA,2BAAAA,GAA8B;AAOpC,IAAMC,0BAAAA,GAA6B;AAGnC,IAAMC,gCAAAA,GAAmC;AAUzC,IAAMC,oBAAAA,GAAuB,CAAA","file":"index.cjs","sourcesContent":["// Runtime-resolvable bundle of the canonical RAG migrations. The CLI's\n// `add-rag` installer copies `STACKBONE_RAG_V1_SQL` verbatim into the\n// creator's `.stackbone/migrations/` directory. The literal `.sql` sibling\n// (`stackbone_rag_v1.sql`) is the human-readable source — a snapshot test\n// pins the two together so they cannot drift.\n//\n// We inline the body here (instead of `readFileSync`) because tsup bundles\n// the SDK into `dist/*.{js,cjs}` and does NOT copy `.sql` assets across.\n// Inlining sidesteps the runtime-asset question: any consumer that imports\n// `@stackbone/sdk/rag/migrations` gets the SQL as a plain string, no fs\n// access required, no path-resolution edge cases inside packed CLIs.\n\n/**\n * Header marker stamped on the first line of every Stackbone-managed RAG\n * migration. The `add-rag` installer is **idempotent** by detection of this\n * exact regex on the first line of any file under\n * `.stackbone/migrations/*.sql`.\n *\n * Format locked in ADR 2026-05-10 §D3: literal `-- @stackbone:rag@v<N>` with\n * no leading/trailing whitespace and no quoting.\n */\nexport const STACKBONE_RAG_MARKER_PREFIX = '-- @stackbone:rag@';\n\n/**\n * Regex matching the marker on the first line of a migration file. Group 1\n * is the integer version. Anchored on both ends so the match is robust to\n * accidental copy-paste of the marker into a comment further down the file.\n */\nexport const STACKBONE_RAG_MARKER_REGEX = /^-- @stackbone:rag@v(\\d+)$/;\n\n/** Filename used when bundling into `.stackbone/migrations/<NNNN>_stackbone_rag_v<N>.sql`. */\nexport const STACKBONE_RAG_V1_FILENAME_SUFFIX = 'stackbone_rag_v1.sql';\n\n/**\n * Canonical body of `stackbone_rag_v1.sql`. Generated from\n * `libs/sdk/src/modules/rag/schema.ts` via `drizzle-kit generate`, then\n * prefixed with the `-- @stackbone:rag@v1` marker required by the installer.\n *\n * The literal `.sql` sibling exists for tooling (drizzle-kit studio, manual\n * inspection); a snapshot test asserts the two stay byte-equal.\n */\nexport const STACKBONE_RAG_V1_SQL = `-- @stackbone:rag@v1\nCREATE EXTENSION IF NOT EXISTS vector;\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_collections\" (\n\\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\\t\"name\" text NOT NULL,\n\\t\"metadata\" jsonb DEFAULT '{}'::jsonb NOT NULL,\n\\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\\tCONSTRAINT \"stackbone_rag_collections_name_unique\" UNIQUE(\"name\")\n);\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_documents\" (\n\\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\\t\"collection_id\" uuid NOT NULL,\n\\t\"source\" text NOT NULL,\n\\t\"content_hash\" text NOT NULL,\n\\t\"metadata\" jsonb DEFAULT '{}'::jsonb NOT NULL,\n\\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_chunks\" (\n\\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\\t\"document_id\" uuid NOT NULL,\n\\t\"ordinal\" integer NOT NULL,\n\\t\"content\" text NOT NULL,\n\\t\"embedding\" vector(1536) NOT NULL,\n\\t\"metadata\" jsonb DEFAULT '{}'::jsonb NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_jobs\" (\n\\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\\t\"collection_id\" uuid NOT NULL,\n\\t\"status\" text DEFAULT 'queued' NOT NULL,\n\\t\"progress\" jsonb DEFAULT '{\"totalChunks\":0,\"processedChunks\":0}'::jsonb NOT NULL,\n\\t\"error\" text,\n\\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\\tCONSTRAINT \"stackbone_rag_jobs_status_check\" CHECK (\"status\" IN ('queued','running','succeeded','failed','cancelled'))\n);\n--> statement-breakpoint\nALTER TABLE \"stackbone_rag_documents\" ADD CONSTRAINT \"stackbone_rag_documents_collection_id_fk\" FOREIGN KEY (\"collection_id\") REFERENCES \"public\".\"stackbone_rag_collections\"(\"id\") ON DELETE cascade ON UPDATE no action;\n--> statement-breakpoint\nALTER TABLE \"stackbone_rag_chunks\" ADD CONSTRAINT \"stackbone_rag_chunks_document_id_fk\" FOREIGN KEY (\"document_id\") REFERENCES \"public\".\"stackbone_rag_documents\"(\"id\") ON DELETE cascade ON UPDATE no action;\n--> statement-breakpoint\nALTER TABLE \"stackbone_rag_jobs\" ADD CONSTRAINT \"stackbone_rag_jobs_collection_id_fk\" FOREIGN KEY (\"collection_id\") REFERENCES \"public\".\"stackbone_rag_collections\"(\"id\") ON DELETE cascade ON UPDATE no action;\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_documents_collection_idx\" ON \"stackbone_rag_documents\" USING btree (\"collection_id\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_documents_hash_idx\" ON \"stackbone_rag_documents\" USING btree (\"collection_id\",\"content_hash\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_chunks_document_idx\" ON \"stackbone_rag_chunks\" USING btree (\"document_id\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_chunks_embedding_hnsw\" ON \"stackbone_rag_chunks\" USING hnsw (\"embedding\" vector_cosine_ops);\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_jobs_collection_idx\" ON \"stackbone_rag_jobs\" USING btree (\"collection_id\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_jobs_status_idx\" ON \"stackbone_rag_jobs\" USING btree (\"status\");\n`;\n"]}
@@ -1,29 +0,0 @@
1
- /**
2
- * Header marker stamped on the first line of every Stackbone-managed RAG
3
- * migration. The `add-rag` installer is **idempotent** by detection of this
4
- * exact regex on the first line of any file under
5
- * `.stackbone/migrations/*.sql`.
6
- *
7
- * Format locked in ADR 2026-05-10 §D3: literal `-- @stackbone:rag@v<N>` with
8
- * no leading/trailing whitespace and no quoting.
9
- */
10
- declare const STACKBONE_RAG_MARKER_PREFIX = "-- @stackbone:rag@";
11
- /**
12
- * Regex matching the marker on the first line of a migration file. Group 1
13
- * is the integer version. Anchored on both ends so the match is robust to
14
- * accidental copy-paste of the marker into a comment further down the file.
15
- */
16
- declare const STACKBONE_RAG_MARKER_REGEX: RegExp;
17
- /** Filename used when bundling into `.stackbone/migrations/<NNNN>_stackbone_rag_v<N>.sql`. */
18
- declare const STACKBONE_RAG_V1_FILENAME_SUFFIX = "stackbone_rag_v1.sql";
19
- /**
20
- * Canonical body of `stackbone_rag_v1.sql`. Generated from
21
- * `libs/sdk/src/modules/rag/schema.ts` via `drizzle-kit generate`, then
22
- * prefixed with the `-- @stackbone:rag@v1` marker required by the installer.
23
- *
24
- * The literal `.sql` sibling exists for tooling (drizzle-kit studio, manual
25
- * inspection); a snapshot test asserts the two stay byte-equal.
26
- */
27
- declare const STACKBONE_RAG_V1_SQL = "-- @stackbone:rag@v1\nCREATE EXTENSION IF NOT EXISTS vector;\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_collections\" (\n\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\t\"name\" text NOT NULL,\n\t\"metadata\" jsonb DEFAULT '{}'::jsonb NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\tCONSTRAINT \"stackbone_rag_collections_name_unique\" UNIQUE(\"name\")\n);\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_documents\" (\n\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\t\"collection_id\" uuid NOT NULL,\n\t\"source\" text NOT NULL,\n\t\"content_hash\" text NOT NULL,\n\t\"metadata\" jsonb DEFAULT '{}'::jsonb NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_chunks\" (\n\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\t\"document_id\" uuid NOT NULL,\n\t\"ordinal\" integer NOT NULL,\n\t\"content\" text NOT NULL,\n\t\"embedding\" vector(1536) NOT NULL,\n\t\"metadata\" jsonb DEFAULT '{}'::jsonb NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_jobs\" (\n\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\t\"collection_id\" uuid NOT NULL,\n\t\"status\" text DEFAULT 'queued' NOT NULL,\n\t\"progress\" jsonb DEFAULT '{\"totalChunks\":0,\"processedChunks\":0}'::jsonb NOT NULL,\n\t\"error\" text,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\tCONSTRAINT \"stackbone_rag_jobs_status_check\" CHECK (\"status\" IN ('queued','running','succeeded','failed','cancelled'))\n);\n--> statement-breakpoint\nALTER TABLE \"stackbone_rag_documents\" ADD CONSTRAINT \"stackbone_rag_documents_collection_id_fk\" FOREIGN KEY (\"collection_id\") REFERENCES \"public\".\"stackbone_rag_collections\"(\"id\") ON DELETE cascade ON UPDATE no action;\n--> statement-breakpoint\nALTER TABLE \"stackbone_rag_chunks\" ADD CONSTRAINT \"stackbone_rag_chunks_document_id_fk\" FOREIGN KEY (\"document_id\") REFERENCES \"public\".\"stackbone_rag_documents\"(\"id\") ON DELETE cascade ON UPDATE no action;\n--> statement-breakpoint\nALTER TABLE \"stackbone_rag_jobs\" ADD CONSTRAINT \"stackbone_rag_jobs_collection_id_fk\" FOREIGN KEY (\"collection_id\") REFERENCES \"public\".\"stackbone_rag_collections\"(\"id\") ON DELETE cascade ON UPDATE no action;\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_documents_collection_idx\" ON \"stackbone_rag_documents\" USING btree (\"collection_id\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_documents_hash_idx\" ON \"stackbone_rag_documents\" USING btree (\"collection_id\",\"content_hash\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_chunks_document_idx\" ON \"stackbone_rag_chunks\" USING btree (\"document_id\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_chunks_embedding_hnsw\" ON \"stackbone_rag_chunks\" USING hnsw (\"embedding\" vector_cosine_ops);\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_jobs_collection_idx\" ON \"stackbone_rag_jobs\" USING btree (\"collection_id\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_jobs_status_idx\" ON \"stackbone_rag_jobs\" USING btree (\"status\");\n";
28
-
29
- export { STACKBONE_RAG_MARKER_PREFIX, STACKBONE_RAG_MARKER_REGEX, STACKBONE_RAG_V1_FILENAME_SUFFIX, STACKBONE_RAG_V1_SQL };
@@ -1,29 +0,0 @@
1
- /**
2
- * Header marker stamped on the first line of every Stackbone-managed RAG
3
- * migration. The `add-rag` installer is **idempotent** by detection of this
4
- * exact regex on the first line of any file under
5
- * `.stackbone/migrations/*.sql`.
6
- *
7
- * Format locked in ADR 2026-05-10 §D3: literal `-- @stackbone:rag@v<N>` with
8
- * no leading/trailing whitespace and no quoting.
9
- */
10
- declare const STACKBONE_RAG_MARKER_PREFIX = "-- @stackbone:rag@";
11
- /**
12
- * Regex matching the marker on the first line of a migration file. Group 1
13
- * is the integer version. Anchored on both ends so the match is robust to
14
- * accidental copy-paste of the marker into a comment further down the file.
15
- */
16
- declare const STACKBONE_RAG_MARKER_REGEX: RegExp;
17
- /** Filename used when bundling into `.stackbone/migrations/<NNNN>_stackbone_rag_v<N>.sql`. */
18
- declare const STACKBONE_RAG_V1_FILENAME_SUFFIX = "stackbone_rag_v1.sql";
19
- /**
20
- * Canonical body of `stackbone_rag_v1.sql`. Generated from
21
- * `libs/sdk/src/modules/rag/schema.ts` via `drizzle-kit generate`, then
22
- * prefixed with the `-- @stackbone:rag@v1` marker required by the installer.
23
- *
24
- * The literal `.sql` sibling exists for tooling (drizzle-kit studio, manual
25
- * inspection); a snapshot test asserts the two stay byte-equal.
26
- */
27
- declare const STACKBONE_RAG_V1_SQL = "-- @stackbone:rag@v1\nCREATE EXTENSION IF NOT EXISTS vector;\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_collections\" (\n\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\t\"name\" text NOT NULL,\n\t\"metadata\" jsonb DEFAULT '{}'::jsonb NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\tCONSTRAINT \"stackbone_rag_collections_name_unique\" UNIQUE(\"name\")\n);\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_documents\" (\n\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\t\"collection_id\" uuid NOT NULL,\n\t\"source\" text NOT NULL,\n\t\"content_hash\" text NOT NULL,\n\t\"metadata\" jsonb DEFAULT '{}'::jsonb NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_chunks\" (\n\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\t\"document_id\" uuid NOT NULL,\n\t\"ordinal\" integer NOT NULL,\n\t\"content\" text NOT NULL,\n\t\"embedding\" vector(1536) NOT NULL,\n\t\"metadata\" jsonb DEFAULT '{}'::jsonb NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_jobs\" (\n\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\t\"collection_id\" uuid NOT NULL,\n\t\"status\" text DEFAULT 'queued' NOT NULL,\n\t\"progress\" jsonb DEFAULT '{\"totalChunks\":0,\"processedChunks\":0}'::jsonb NOT NULL,\n\t\"error\" text,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\tCONSTRAINT \"stackbone_rag_jobs_status_check\" CHECK (\"status\" IN ('queued','running','succeeded','failed','cancelled'))\n);\n--> statement-breakpoint\nALTER TABLE \"stackbone_rag_documents\" ADD CONSTRAINT \"stackbone_rag_documents_collection_id_fk\" FOREIGN KEY (\"collection_id\") REFERENCES \"public\".\"stackbone_rag_collections\"(\"id\") ON DELETE cascade ON UPDATE no action;\n--> statement-breakpoint\nALTER TABLE \"stackbone_rag_chunks\" ADD CONSTRAINT \"stackbone_rag_chunks_document_id_fk\" FOREIGN KEY (\"document_id\") REFERENCES \"public\".\"stackbone_rag_documents\"(\"id\") ON DELETE cascade ON UPDATE no action;\n--> statement-breakpoint\nALTER TABLE \"stackbone_rag_jobs\" ADD CONSTRAINT \"stackbone_rag_jobs_collection_id_fk\" FOREIGN KEY (\"collection_id\") REFERENCES \"public\".\"stackbone_rag_collections\"(\"id\") ON DELETE cascade ON UPDATE no action;\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_documents_collection_idx\" ON \"stackbone_rag_documents\" USING btree (\"collection_id\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_documents_hash_idx\" ON \"stackbone_rag_documents\" USING btree (\"collection_id\",\"content_hash\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_chunks_document_idx\" ON \"stackbone_rag_chunks\" USING btree (\"document_id\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_chunks_embedding_hnsw\" ON \"stackbone_rag_chunks\" USING hnsw (\"embedding\" vector_cosine_ops);\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_jobs_collection_idx\" ON \"stackbone_rag_jobs\" USING btree (\"collection_id\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_jobs_status_idx\" ON \"stackbone_rag_jobs\" USING btree (\"status\");\n";
28
-
29
- export { STACKBONE_RAG_MARKER_PREFIX, STACKBONE_RAG_MARKER_REGEX, STACKBONE_RAG_V1_FILENAME_SUFFIX, STACKBONE_RAG_V1_SQL };
@@ -1,66 +0,0 @@
1
- // src/surfaces/agent-local/rag/migrations/index.ts
2
- var STACKBONE_RAG_MARKER_PREFIX = "-- @stackbone:rag@";
3
- var STACKBONE_RAG_MARKER_REGEX = /^-- @stackbone:rag@v(\d+)$/;
4
- var STACKBONE_RAG_V1_FILENAME_SUFFIX = "stackbone_rag_v1.sql";
5
- var STACKBONE_RAG_V1_SQL = `-- @stackbone:rag@v1
6
- CREATE EXTENSION IF NOT EXISTS vector;
7
- --> statement-breakpoint
8
- CREATE TABLE "stackbone_rag_collections" (
9
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
10
- "name" text NOT NULL,
11
- "metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
12
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
13
- CONSTRAINT "stackbone_rag_collections_name_unique" UNIQUE("name")
14
- );
15
- --> statement-breakpoint
16
- CREATE TABLE "stackbone_rag_documents" (
17
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
18
- "collection_id" uuid NOT NULL,
19
- "source" text NOT NULL,
20
- "content_hash" text NOT NULL,
21
- "metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
22
- "created_at" timestamp with time zone DEFAULT now() NOT NULL
23
- );
24
- --> statement-breakpoint
25
- CREATE TABLE "stackbone_rag_chunks" (
26
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
27
- "document_id" uuid NOT NULL,
28
- "ordinal" integer NOT NULL,
29
- "content" text NOT NULL,
30
- "embedding" vector(1536) NOT NULL,
31
- "metadata" jsonb DEFAULT '{}'::jsonb NOT NULL
32
- );
33
- --> statement-breakpoint
34
- CREATE TABLE "stackbone_rag_jobs" (
35
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
36
- "collection_id" uuid NOT NULL,
37
- "status" text DEFAULT 'queued' NOT NULL,
38
- "progress" jsonb DEFAULT '{"totalChunks":0,"processedChunks":0}'::jsonb NOT NULL,
39
- "error" text,
40
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
41
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
42
- CONSTRAINT "stackbone_rag_jobs_status_check" CHECK ("status" IN ('queued','running','succeeded','failed','cancelled'))
43
- );
44
- --> statement-breakpoint
45
- ALTER TABLE "stackbone_rag_documents" ADD CONSTRAINT "stackbone_rag_documents_collection_id_fk" FOREIGN KEY ("collection_id") REFERENCES "public"."stackbone_rag_collections"("id") ON DELETE cascade ON UPDATE no action;
46
- --> statement-breakpoint
47
- ALTER TABLE "stackbone_rag_chunks" ADD CONSTRAINT "stackbone_rag_chunks_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."stackbone_rag_documents"("id") ON DELETE cascade ON UPDATE no action;
48
- --> statement-breakpoint
49
- ALTER TABLE "stackbone_rag_jobs" ADD CONSTRAINT "stackbone_rag_jobs_collection_id_fk" FOREIGN KEY ("collection_id") REFERENCES "public"."stackbone_rag_collections"("id") ON DELETE cascade ON UPDATE no action;
50
- --> statement-breakpoint
51
- CREATE INDEX "stackbone_rag_documents_collection_idx" ON "stackbone_rag_documents" USING btree ("collection_id");
52
- --> statement-breakpoint
53
- CREATE INDEX "stackbone_rag_documents_hash_idx" ON "stackbone_rag_documents" USING btree ("collection_id","content_hash");
54
- --> statement-breakpoint
55
- CREATE INDEX "stackbone_rag_chunks_document_idx" ON "stackbone_rag_chunks" USING btree ("document_id");
56
- --> statement-breakpoint
57
- CREATE INDEX "stackbone_rag_chunks_embedding_hnsw" ON "stackbone_rag_chunks" USING hnsw ("embedding" vector_cosine_ops);
58
- --> statement-breakpoint
59
- CREATE INDEX "stackbone_rag_jobs_collection_idx" ON "stackbone_rag_jobs" USING btree ("collection_id");
60
- --> statement-breakpoint
61
- CREATE INDEX "stackbone_rag_jobs_status_idx" ON "stackbone_rag_jobs" USING btree ("status");
62
- `;
63
-
64
- export { STACKBONE_RAG_MARKER_PREFIX, STACKBONE_RAG_MARKER_REGEX, STACKBONE_RAG_V1_FILENAME_SUFFIX, STACKBONE_RAG_V1_SQL };
65
- //# sourceMappingURL=index.js.map
66
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../libs/sdk/src/surfaces/agent-local/rag/migrations/index.ts"],"names":["STACKBONE_RAG_MARKER_PREFIX","STACKBONE_RAG_MARKER_REGEX","STACKBONE_RAG_V1_FILENAME_SUFFIX","STACKBONE_RAG_V1_SQL"],"mappings":";AAqBO,IAAMA,2BAAAA,GAA8B;AAOpC,IAAMC,0BAAAA,GAA6B;AAGnC,IAAMC,gCAAAA,GAAmC;AAUzC,IAAMC,oBAAAA,GAAuB,CAAA","file":"index.js","sourcesContent":["// Runtime-resolvable bundle of the canonical RAG migrations. The CLI's\n// `add-rag` installer copies `STACKBONE_RAG_V1_SQL` verbatim into the\n// creator's `.stackbone/migrations/` directory. The literal `.sql` sibling\n// (`stackbone_rag_v1.sql`) is the human-readable source — a snapshot test\n// pins the two together so they cannot drift.\n//\n// We inline the body here (instead of `readFileSync`) because tsup bundles\n// the SDK into `dist/*.{js,cjs}` and does NOT copy `.sql` assets across.\n// Inlining sidesteps the runtime-asset question: any consumer that imports\n// `@stackbone/sdk/rag/migrations` gets the SQL as a plain string, no fs\n// access required, no path-resolution edge cases inside packed CLIs.\n\n/**\n * Header marker stamped on the first line of every Stackbone-managed RAG\n * migration. The `add-rag` installer is **idempotent** by detection of this\n * exact regex on the first line of any file under\n * `.stackbone/migrations/*.sql`.\n *\n * Format locked in ADR 2026-05-10 §D3: literal `-- @stackbone:rag@v<N>` with\n * no leading/trailing whitespace and no quoting.\n */\nexport const STACKBONE_RAG_MARKER_PREFIX = '-- @stackbone:rag@';\n\n/**\n * Regex matching the marker on the first line of a migration file. Group 1\n * is the integer version. Anchored on both ends so the match is robust to\n * accidental copy-paste of the marker into a comment further down the file.\n */\nexport const STACKBONE_RAG_MARKER_REGEX = /^-- @stackbone:rag@v(\\d+)$/;\n\n/** Filename used when bundling into `.stackbone/migrations/<NNNN>_stackbone_rag_v<N>.sql`. */\nexport const STACKBONE_RAG_V1_FILENAME_SUFFIX = 'stackbone_rag_v1.sql';\n\n/**\n * Canonical body of `stackbone_rag_v1.sql`. Generated from\n * `libs/sdk/src/modules/rag/schema.ts` via `drizzle-kit generate`, then\n * prefixed with the `-- @stackbone:rag@v1` marker required by the installer.\n *\n * The literal `.sql` sibling exists for tooling (drizzle-kit studio, manual\n * inspection); a snapshot test asserts the two stay byte-equal.\n */\nexport const STACKBONE_RAG_V1_SQL = `-- @stackbone:rag@v1\nCREATE EXTENSION IF NOT EXISTS vector;\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_collections\" (\n\\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\\t\"name\" text NOT NULL,\n\\t\"metadata\" jsonb DEFAULT '{}'::jsonb NOT NULL,\n\\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\\tCONSTRAINT \"stackbone_rag_collections_name_unique\" UNIQUE(\"name\")\n);\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_documents\" (\n\\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\\t\"collection_id\" uuid NOT NULL,\n\\t\"source\" text NOT NULL,\n\\t\"content_hash\" text NOT NULL,\n\\t\"metadata\" jsonb DEFAULT '{}'::jsonb NOT NULL,\n\\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_chunks\" (\n\\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\\t\"document_id\" uuid NOT NULL,\n\\t\"ordinal\" integer NOT NULL,\n\\t\"content\" text NOT NULL,\n\\t\"embedding\" vector(1536) NOT NULL,\n\\t\"metadata\" jsonb DEFAULT '{}'::jsonb NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE \"stackbone_rag_jobs\" (\n\\t\"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\n\\t\"collection_id\" uuid NOT NULL,\n\\t\"status\" text DEFAULT 'queued' NOT NULL,\n\\t\"progress\" jsonb DEFAULT '{\"totalChunks\":0,\"processedChunks\":0}'::jsonb NOT NULL,\n\\t\"error\" text,\n\\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\\tCONSTRAINT \"stackbone_rag_jobs_status_check\" CHECK (\"status\" IN ('queued','running','succeeded','failed','cancelled'))\n);\n--> statement-breakpoint\nALTER TABLE \"stackbone_rag_documents\" ADD CONSTRAINT \"stackbone_rag_documents_collection_id_fk\" FOREIGN KEY (\"collection_id\") REFERENCES \"public\".\"stackbone_rag_collections\"(\"id\") ON DELETE cascade ON UPDATE no action;\n--> statement-breakpoint\nALTER TABLE \"stackbone_rag_chunks\" ADD CONSTRAINT \"stackbone_rag_chunks_document_id_fk\" FOREIGN KEY (\"document_id\") REFERENCES \"public\".\"stackbone_rag_documents\"(\"id\") ON DELETE cascade ON UPDATE no action;\n--> statement-breakpoint\nALTER TABLE \"stackbone_rag_jobs\" ADD CONSTRAINT \"stackbone_rag_jobs_collection_id_fk\" FOREIGN KEY (\"collection_id\") REFERENCES \"public\".\"stackbone_rag_collections\"(\"id\") ON DELETE cascade ON UPDATE no action;\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_documents_collection_idx\" ON \"stackbone_rag_documents\" USING btree (\"collection_id\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_documents_hash_idx\" ON \"stackbone_rag_documents\" USING btree (\"collection_id\",\"content_hash\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_chunks_document_idx\" ON \"stackbone_rag_chunks\" USING btree (\"document_id\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_chunks_embedding_hnsw\" ON \"stackbone_rag_chunks\" USING hnsw (\"embedding\" vector_cosine_ops);\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_jobs_collection_idx\" ON \"stackbone_rag_jobs\" USING btree (\"collection_id\");\n--> statement-breakpoint\nCREATE INDEX \"stackbone_rag_jobs_status_idx\" ON \"stackbone_rag_jobs\" USING btree (\"status\");\n`;\n"]}
Binary file