@agimon-ai/po-db 0.0.0-alpha.61

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/LICENSE ADDED
@@ -0,0 +1,149 @@
1
+ License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
2
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
3
+
4
+ Parameters
5
+
6
+ Licensor: Agimon Pty Ltd
7
+ Licensed Work: Po, the software in the Po source repository and the
8
+ packages released from it, in each version released by
9
+ the Licensor.
10
+ The Licensed Work is (c) 2026 Agimon Pty Ltd.
11
+ Material identified as third-party in the "Third-party
12
+ components" section at the end of this file or in a
13
+ NOTICE file, and any package or directory whose own
14
+ license file grants a different license, is not part of
15
+ the Licensed Work and remains under its own license.
16
+ Additional Use Grant: You may make production use of the Licensed Work if
17
+ your use is Eligible Use. "Eligible Use" is production use that falls
18
+ within at least one of the following:
19
+
20
+ (a) Personal Use. Use by an individual for their own personal purposes,
21
+ and not on behalf of, or for the benefit of, an employer, client, or
22
+ other Organization. Use by an individual in the course of employment
23
+ or engagement by an Organization is use by that Organization.
24
+
25
+ (b) Small Organization Use. Use by or on behalf of an Organization whose
26
+ Annual Revenue is less than USD 1,000,000.
27
+
28
+ (c) Non-profit, Education and Research Use. Use, regardless of Annual
29
+ Revenue, by (i) an Organization registered or recognized as a
30
+ non-profit or charitable organization under the laws of its
31
+ jurisdiction, for its non-profit purposes; (ii) an accredited school,
32
+ college, or university, for teaching, learning, or academic research;
33
+ or (iii) a publicly funded research institution, for its research.
34
+
35
+ (d) Service Provider Use. Use by a consultant, contractor, agency, or other
36
+ service provider, regardless of its own Annual Revenue, solely to
37
+ build, deploy, host, operate, or support the Licensed Work for a client
38
+ whose own use would be Eligible Use under (a), (b), or (c). A service
39
+ provider's use for its own purposes is Eligible Use only if the service
40
+ provider itself qualifies under (b) or (c).
41
+
42
+
43
+ Hosted services. Offering the Licensed Work to third parties as a hosted
44
+ or managed service whose primary value is the Licensed Work is Eligible
45
+ Use only if each such third party's own use would be Eligible Use.
46
+
47
+ Definitions. "Organization" means any company, partnership, sole
48
+ proprietorship, trust, association, government body, or other entity, and
49
+ includes an individual acting in a business or professional capacity.
50
+ "Affiliate" means any entity that directly or indirectly controls, is
51
+ controlled by, or is under common control with an Organization, where
52
+ "control" means ownership of more than 50% of the voting interests of an
53
+ entity or the power to direct its management and policies by contract or
54
+ otherwise. "Annual Revenue" means the total gross revenue of an
55
+ Organization and all of its Affiliates combined, from all sources and
56
+ whether or not related to the Licensed Work, for its most recently
57
+ completed fiscal year, or, if it has not completed a fiscal year, for the
58
+ twelve months before the use (or since its formation, if shorter),
59
+ converted into US dollars at the average exchange rate for that period.
60
+ Proceeds of equity or debt financing are not revenue.
61
+
62
+ Threshold. If an Organization stops qualifying under (b), its existing
63
+ production use remains Eligible Use for 90 days after it stops
64
+ qualifying, after which it must obtain a commercial license or stop
65
+ production use. Use that was Eligible Use when it occurred never requires
66
+ a commercial license after the fact.
67
+ Change Date: Four years from the date a version of the Licensed Work
68
+ is first publicly released by the Licensor.
69
+ Change License: Apache License, Version 2.0
70
+
71
+ For information about alternative licensing arrangements for the Licensed
72
+ Work, please visit: https://agimon.ai/licensing
73
+
74
+ Notice
75
+
76
+ The Business Source License (this document, or the "License") is not an Open
77
+ Source license. However, the Licensed Work will eventually be made available
78
+ under an Open Source License, as stated in this License.
79
+
80
+ -----------------------------------------------------------------------------
81
+
82
+ Business Source License 1.1
83
+
84
+ Terms
85
+
86
+ The Licensor hereby grants you the right to copy, modify, create derivative
87
+ works, redistribute, and make non-production use of the Licensed Work. The
88
+ Licensor may make an Additional Use Grant, above, permitting limited
89
+ production use.
90
+
91
+ Effective on the Change Date, or the fourth anniversary of the first publicly
92
+ available distribution of a specific version of the Licensed Work under this
93
+ License, whichever comes first, the Licensor hereby grants you rights under
94
+ the terms of the Change License, and the rights granted in the paragraph
95
+ above terminate.
96
+
97
+ If your use of the Licensed Work does not comply with the requirements
98
+ currently in effect as described in this License, you must purchase a
99
+ commercial license from the Licensor, its affiliated entities, or authorized
100
+ resellers, or you must refrain from using the Licensed Work.
101
+
102
+ All copies of the original and modified Licensed Work, and derivative works
103
+ of the Licensed Work, are subject to this License. This License applies
104
+ separately for each version of the Licensed Work and the Change Date may vary
105
+ for each version of the Licensed Work released by Licensor.
106
+
107
+ You must conspicuously display this License on each original or modified copy
108
+ of the Licensed Work. If you receive the Licensed Work in original or
109
+ modified form from a third party, the terms and conditions set forth in this
110
+ License apply to your use of that work.
111
+
112
+ Any use of the Licensed Work in violation of this License will automatically
113
+ terminate your rights under this License for the current and all other
114
+ versions of the Licensed Work.
115
+
116
+ This License does not grant you any right in any trademark or logo of
117
+ Licensor or its affiliates (provided that you may use a trademark or logo of
118
+ Licensor as expressly required by this License).
119
+
120
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
121
+ AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
122
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
123
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
124
+ TITLE.
125
+
126
+ MariaDB hereby grants you permission to use this License’s text to license
127
+ your works, and to refer to it using the trademark “Business Source License”,
128
+ as long as you comply with the Covenants of Licensor below.
129
+
130
+ Covenants of Licensor
131
+
132
+ In consideration of the right to use this License’s text and the “Business
133
+ Source License” name and trademark, Licensor covenants to MariaDB, and to all
134
+ other recipients of the licensed work to be provided by Licensor:
135
+
136
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
137
+ or a license that is compatible with GPL Version 2.0 or a later version,
138
+ where “compatible” means that software provided under the Change License can
139
+ be included in a program with software provided under GPL Version 2.0 or a
140
+ later version. Licensor may specify additional Change Licenses without
141
+ limitation.
142
+
143
+ 2. To either: (a) specify an additional grant of rights to use that does not
144
+ impose any additional restriction on the right granted in this License, as
145
+ the Additional Use Grant; or (b) insert the text “None”.
146
+
147
+ 3. To specify a Change Date.
148
+
149
+ 4. Not to modify this License in any other way.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # @agimon-ai/po-db
2
+
3
+ One shared sqlite database for the Po packages that need one.
4
+
5
+ Po opens `<po home>/db/po.sqlite` once per process, in a folder only the owner can read, and binds it as the global `po/db` service. Every workspace and session resolves that same connection.
6
+
7
+ ## Rules for consumers
8
+
9
+ - **One shared connection.** Node's sqlite waits for a locked database synchronously. A second connection in the same process would block the event loop while the first one's transaction holds the write lock, so both stall. Use the `database` you are given; never open `po.sqlite` yourself.
10
+ - **`close()` does nothing.** The `database` you receive is a view of the shared connection. Only the po-db root closes the real one, when the server stops.
11
+ - **No network work inside a transaction.** A transaction holds the write lock for every package in every Po process. Read, call the network, then write in a short transaction or a single statement.
12
+ - **Own a prefix.** Each package picks one table prefix (lowercase words joined by `_`) and creates its schema through `migrate(prefix, migrations)`. Every table, index, view and trigger a migration creates must start with `<prefix>_`; anything else rolls the migration back. The schema version is kept in `<prefix>_migrations`.
13
+ - **No PRAGMA, no ATTACH, no paths.** Connection settings belong to the root.
14
+
15
+ ## Use
16
+
17
+ Declare the contract your root waits for, so a host without po-db shows a "waits for contract" notice instead of hanging:
18
+
19
+ ```ts
20
+ import { defineRoot } from '@agimon-ai/po-core/extensionFile';
21
+ import { PO_DB_CONTRACT, PO_DB_SERVICE, type PoDb } from '@agimon-ai/po-db';
22
+
23
+ export default defineRoot(createMyRoot, { inject: [PO_DB_CONTRACT] });
24
+
25
+ // inside the root, once `po/db` is injected:
26
+ const db = context.get(PO_DB_SERVICE) as PoDb;
27
+ await db.migrate('notes', [
28
+ { version: 1, statements: ['CREATE TABLE notes_items (id TEXT PRIMARY KEY, body TEXT NOT NULL) STRICT'] },
29
+ ]);
30
+ await db.database.run('INSERT INTO notes_items (id, body) VALUES (?, ?)', 'n1', 'hello');
31
+ ```
32
+
33
+ ## Testing
34
+
35
+ ```ts
36
+ import { createTestPoDb } from '@agimon-ai/po-db/testing';
37
+
38
+ const db = await createTestPoDb(); // in memory; pass a file path to share it across processes
39
+ await db.close();
40
+ ```
41
+
42
+ `./testing` runs on Node only.
43
+
44
+ ## Public API
45
+
46
+ - `@agimon-ai/po-db`: `PO_DB_SERVICE`, `PO_DB_CONTRACT`, `PO_DB_FILE`, `createPoDb`, and the `PoDb`, `PoDbHandle`, `PoDbMigration` types.
47
+ - `@agimon-ai/po-db/testing`: `createTestPoDb`.
48
+ - `@agimon-ai/po-db/extensions/server`: the native server entry, a fixed Po host package.
49
+
50
+ ## Requirements
51
+
52
+ - Node.js 24 or newer
@@ -0,0 +1,17 @@
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ //#region src/schemas/apiContracts.ts
6
+ /** This server plugin provides the po/db service only, with no separate HTTP or socket surface. */
7
+ const apiContracts = (0, require("@agimon-ai/po-core/apiContracts").defineApiContract)({
8
+ version: 1,
9
+ http: [],
10
+ sockets: [],
11
+ dynamic: []
12
+ });
13
+ //#endregion
14
+ exports.apiContracts = apiContracts;
15
+ exports.default = apiContracts;
16
+
17
+ //# sourceMappingURL=apiContracts.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiContracts.cjs","names":["defineApiContract"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract } from '@agimon-ai/po-core/apiContracts';\n\n/** This server plugin provides the po/db service only, with no separate HTTP or socket surface. */\nexport const apiContracts = defineApiContract({ version: 1, http: [], sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;;;;AAGA,MAAa,gBAAA,4CAAeA,CAAAA,CAAAA,kBAAAA,CAAkB;CAAE,SAAS;CAAG,MAAM,CAAC;CAAG,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
@@ -0,0 +1,53 @@
1
+ //#region src/schemas/apiContracts.d.ts
2
+ /** This server plugin provides the po/db service only, with no separate HTTP or socket surface. */
3
+ export declare const apiContracts: {
4
+ version: 1;
5
+ protocols?: Record<string, string> | undefined;
6
+ schemas?: Record<string, boolean | object> | undefined;
7
+ http: {
8
+ id: string;
9
+ scope: "global" | "session" | "workspace";
10
+ basePath?: string | undefined;
11
+ path: string;
12
+ method: "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT";
13
+ description: string;
14
+ availability?: string | undefined;
15
+ authentication: "device" | "none" | "owner";
16
+ parameters?: {
17
+ name: string;
18
+ in: "header" | "path" | "query";
19
+ required: boolean;
20
+ schema: boolean | object;
21
+ }[] | undefined;
22
+ body?: {
23
+ contentType: string;
24
+ contentTypes?: string[] | undefined;
25
+ required: boolean;
26
+ schema: boolean | object;
27
+ } | undefined;
28
+ responses: Record<string, {
29
+ description: string;
30
+ contentType?: string | undefined;
31
+ schema?: boolean | object | undefined;
32
+ events?: Record<string, boolean | object> | undefined;
33
+ }>;
34
+ }[];
35
+ sockets: {
36
+ id: string;
37
+ scope: "global" | "session" | "workspace";
38
+ description: string;
39
+ availability?: string | undefined;
40
+ service: string;
41
+ member: string;
42
+ direction: "client-to-server" | "server-to-client";
43
+ kind: "channel" | "method" | "state";
44
+ input: boolean | object;
45
+ output?: boolean | object | undefined;
46
+ errors?: boolean | object | undefined;
47
+ }[];
48
+ dynamic: string[];
49
+ gaps?: string[] | undefined;
50
+ };
51
+ //#endregion
52
+ export { apiContracts as default };
53
+ //# sourceMappingURL=apiContracts.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";;qBAGa"}
@@ -0,0 +1,13 @@
1
+ import { defineApiContract } from "@agimon-ai/po-core/apiContracts";
2
+ //#region src/schemas/apiContracts.ts
3
+ /** This server plugin provides the po/db service only, with no separate HTTP or socket surface. */
4
+ const apiContracts = defineApiContract({
5
+ version: 1,
6
+ http: [],
7
+ sockets: [],
8
+ dynamic: []
9
+ });
10
+ //#endregion
11
+ export { apiContracts, apiContracts as default };
12
+
13
+ //# sourceMappingURL=apiContracts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract } from '@agimon-ai/po-core/apiContracts';\n\n/** This server plugin provides the po/db service only, with no separate HTTP or socket surface. */\nexport const apiContracts = defineApiContract({ version: 1, http: [], sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;AAGA,MAAa,eAAe,kBAAkB;CAAE,SAAS;CAAG,MAAM,CAAC;CAAG,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { r as PO_DB_SERVICE } from "./poDb-D6K38Gpu.mjs";
2
+ import { defineServiceContract } from "@agimon-ai/po-core/extensionFile";
3
+ //#region src/schemas/contracts.ts
4
+ /** Bound once at the global level; every workspace and session resolves the same connection. */
5
+ const PO_DB_CONTRACT = defineServiceContract(PO_DB_SERVICE, { scope: "global" });
6
+ /** The shared database, for a caller that injected `po/db`; throws when no global root bound one. */
7
+ function requirePoDb(context) {
8
+ const db = context.get(PO_DB_SERVICE);
9
+ if (db === void 0) throw new Error("The Po database is unavailable. Install @agimon-ai/po-db at the global scope.");
10
+ return db;
11
+ }
12
+ //#endregion
13
+ export { requirePoDb as n, PO_DB_CONTRACT as t };
14
+
15
+ //# sourceMappingURL=contracts-Bv9-_vyc.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts-Bv9-_vyc.mjs","names":[],"sources":["../src/schemas/contracts.ts"],"sourcesContent":["import { defineServiceContract } from '@agimon-ai/po-core/extensionFile';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { PO_DB_SERVICE } from '../constants/db';\nimport type { PoDb } from '../services/poDb/type';\n\n/** Bound once at the global level; every workspace and session resolves the same connection. */\nexport const PO_DB_CONTRACT = defineServiceContract<PoDb>(PO_DB_SERVICE, { scope: 'global' });\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/db': PoDb;\n }\n}\n\n/** The shared database, for a caller that injected `po/db`; throws when no global root bound one. */\nexport function requirePoDb(context: Context): PoDb {\n const db = context.get(PO_DB_SERVICE) as PoDb | undefined;\n if (db === undefined)\n throw new Error('The Po database is unavailable. Install @agimon-ai/po-db at the global scope.');\n return db;\n}\n"],"mappings":";;;;AAOA,MAAa,iBAAiB,sBAA4B,eAAe,EAAE,OAAO,SAAS,CAAC;;AAS5F,SAAgB,YAAY,SAAwB;CAClD,MAAM,KAAK,QAAQ,IAAI,aAAa;CACpC,IAAI,OAAO,KAAA,GACT,MAAM,IAAI,MAAM,+EAA+E;CACjG,OAAO;AACT"}
@@ -0,0 +1,25 @@
1
+ const require_poDb = require("./poDb-BKBXJbTa.cjs");
2
+ //#region src/schemas/contracts.ts
3
+ /** Bound once at the global level; every workspace and session resolves the same connection. */
4
+ const PO_DB_CONTRACT = (0, require("@agimon-ai/po-core/extensionFile").defineServiceContract)(require_poDb.PO_DB_SERVICE, { scope: "global" });
5
+ /** The shared database, for a caller that injected `po/db`; throws when no global root bound one. */
6
+ function requirePoDb(context) {
7
+ const db = context.get(require_poDb.PO_DB_SERVICE);
8
+ if (db === void 0) throw new Error("The Po database is unavailable. Install @agimon-ai/po-db at the global scope.");
9
+ return db;
10
+ }
11
+ //#endregion
12
+ Object.defineProperty(exports, "PO_DB_CONTRACT", {
13
+ enumerable: true,
14
+ get: function() {
15
+ return PO_DB_CONTRACT;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "requirePoDb", {
19
+ enumerable: true,
20
+ get: function() {
21
+ return requirePoDb;
22
+ }
23
+ });
24
+
25
+ //# sourceMappingURL=contracts-C9sToxiM.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts-C9sToxiM.cjs","names":["defineServiceContract","PO_DB_SERVICE"],"sources":["../src/schemas/contracts.ts"],"sourcesContent":["import { defineServiceContract } from '@agimon-ai/po-core/extensionFile';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { PO_DB_SERVICE } from '../constants/db';\nimport type { PoDb } from '../services/poDb/type';\n\n/** Bound once at the global level; every workspace and session resolves the same connection. */\nexport const PO_DB_CONTRACT = defineServiceContract<PoDb>(PO_DB_SERVICE, { scope: 'global' });\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/db': PoDb;\n }\n}\n\n/** The shared database, for a caller that injected `po/db`; throws when no global root bound one. */\nexport function requirePoDb(context: Context): PoDb {\n const db = context.get(PO_DB_SERVICE) as PoDb | undefined;\n if (db === undefined)\n throw new Error('The Po database is unavailable. Install @agimon-ai/po-db at the global scope.');\n return db;\n}\n"],"mappings":";;;AAOA,MAAa,kBAAA,6CAAiBA,CAAAA,CAAAA,sBAAAA,CAA4BC,aAAAA,eAAe,EAAE,OAAO,SAAS,CAAC;;AAS5F,SAAgB,YAAY,SAAwB;CAClD,MAAM,KAAK,QAAQ,IAAIA,aAAAA,aAAa;CACpC,IAAI,OAAO,KAAA,GACT,MAAM,IAAI,MAAM,+EAA+E;CACjG,OAAO;AACT"}
@@ -0,0 +1,113 @@
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ //#region \0rolldown/runtime.js
6
+ var __create = Object.create;
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
+ key = keys[i];
15
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: ((k) => from[k]).bind(null, key),
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+ //#endregion
27
+ const require_poDb = require("../poDb-BKBXJbTa.cjs");
28
+ const require_contracts = require("../contracts-C9sToxiM.cjs");
29
+ let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
30
+ let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
31
+ let node_path = require("node:path");
32
+ node_path = __toESM(node_path, 1);
33
+ let _agimon_ai_po_core_piSettings = require("@agimon-ai/po-core/piSettings");
34
+ let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
35
+ //#region src/extensions/(backend)/_lib/root.server.ts
36
+ /**
37
+ * The process's one Po database, `<po home>/db/po.sqlite`, bound as `po/db` at the global level.
38
+ *
39
+ * Only a global host with a home directory opens it. Workspaces and sessions resolve the global
40
+ * binding through the server scope, so the process keeps a single connection: a second
41
+ * connection would block the event loop while it waits on the first one's write lock.
42
+ */
43
+ async function createPoDbGlobalRoot(plugin) {
44
+ const host = plugin.host;
45
+ const homeDirectory = host.context.homeDirectory;
46
+ if (host.scope !== "global" || homeDirectory === void 0) return { value: void 0 };
47
+ let handle;
48
+ const provider = plugin.context.inject([
49
+ _agimon_ai_po_core_serverPlugin.PO_SERVER_SCOPE_SERVICE,
50
+ _agimon_ai_po_core_platform.PO_FS_SERVICE,
51
+ _agimon_ai_po_core_platform.PO_SQLITE_SERVICE
52
+ ], async (injected) => {
53
+ if (handle === void 0) {
54
+ const directory = node_path.default.join((0, _agimon_ai_po_core_piSettings.poHomeDirectory)(homeDirectory, host.context.environment ?? {}), require_poDb.PO_DB_FILE[0]);
55
+ (0, _agimon_ai_po_core_platform.getOrThrow)(await (0, _agimon_ai_po_core_platform.requirePoFs)(injected).createDir(directory, { recursive: true }, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT));
56
+ await _agimon_ai_po_core_platform.nodeHost.setMode(directory, 448);
57
+ const database = await (0, _agimon_ai_po_core_platform.requirePoSqlite)(injected).open(node_path.default.join(directory, require_poDb.PO_DB_FILE[1]), _agimon_ai_po_core_platform.BACKGROUND_CONTEXT);
58
+ handle = require_poDb.createPoDb({ database });
59
+ }
60
+ return (0, _agimon_ai_po_core_serverPlugin.requirePoServerScope)(injected).provide(require_contracts.PO_DB_CONTRACT, handle);
61
+ });
62
+ await provider.await();
63
+ return {
64
+ value: handle,
65
+ onDispose: async () => {
66
+ await provider.dispose();
67
+ await handle?.close();
68
+ }
69
+ };
70
+ }
71
+ //#endregion
72
+ //#region src/extensions/(backend)/root.server.ts
73
+ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(createPoDbGlobalRoot);
74
+ //#endregion
75
+ //#region generated/server.ts
76
+ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
77
+ name: "@agimon-ai/po-db",
78
+ providerOverrides: (0, _agimon_ai_po_core_serverPlugin.composeServerProviderOverrides)(root_server_default),
79
+ injects: (0, _agimon_ai_po_core_extensionFile.composeRootInjects)({
80
+ global: [root_server_default],
81
+ workspace: [root_server_default],
82
+ session: [root_server_default]
83
+ }),
84
+ global: async (context) => {
85
+ const scopeGlobal = await context.scopeRoot("global", root_server_default, context);
86
+ return {
87
+ ...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeGlobal),
88
+ services: [...scopeGlobal.services ?? []]
89
+ };
90
+ },
91
+ workspace: async (context) => {
92
+ const scopeGlobal = await context.scopeRoot("global", root_server_default, context);
93
+ return {
94
+ ...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeGlobal),
95
+ services: [...scopeGlobal.services ?? []]
96
+ };
97
+ },
98
+ session: async (context) => {
99
+ const scopeGlobal = await context.scopeRoot("global", root_server_default, context);
100
+ return {
101
+ ...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeGlobal),
102
+ services: [...scopeGlobal.services ?? []],
103
+ get activities() {
104
+ return [...scopeGlobal.activities ?? []];
105
+ }
106
+ };
107
+ }
108
+ });
109
+ //#endregion
110
+ exports.default = serverPlugin;
111
+ exports.serverPlugin = serverPlugin;
112
+
113
+ //# sourceMappingURL=server.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.cjs","names":["PO_SERVER_SCOPE_SERVICE","PO_FS_SERVICE","PO_SQLITE_SERVICE","path","poHomeDirectory","PO_DB_FILE","requirePoFs","BACKGROUND_CONTEXT","nodeHost","requirePoSqlite","createPoDb","requirePoServerScope","PO_DB_CONTRACT","defineRoot","defineServerPlugin","composeServerProviderOverrides","rootGlobal","composeRootInjects","composeRootHooks"],"sources":["../../src/extensions/(backend)/_lib/root.server.ts","../../src/extensions/(backend)/root.server.ts","../../generated/server.ts"],"sourcesContent":["import path from 'node:path';\n\nimport type { RootDeclaration } from '@agimon-ai/po-core/extensionFile';\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\nimport {\n BACKGROUND_CONTEXT,\n getOrThrow,\n nodeHost,\n PO_FS_SERVICE,\n PO_SQLITE_SERVICE,\n requirePoFs,\n requirePoSqlite,\n} from '@agimon-ai/po-core/platform';\nimport {\n PO_SERVER_SCOPE_SERVICE,\n requirePoServerScope,\n type PoServerPluginContext,\n} from '@agimon-ai/po-core/serverPlugin';\n\nimport { PO_DB_DIRECTORY_MODE, PO_DB_FILE } from '../../../constants/db';\nimport { PO_DB_CONTRACT } from '../../../schemas/contracts';\nimport { createPoDb } from '../../../services/poDb';\nimport type { PoDbHandle } from '../../../services/poDb/type';\n\n/**\n * The process's one Po database, `<po home>/db/po.sqlite`, bound as `po/db` at the global level.\n *\n * Only a global host with a home directory opens it. Workspaces and sessions resolve the global\n * binding through the server scope, so the process keeps a single connection: a second\n * connection would block the event loop while it waits on the first one's write lock.\n */\nexport async function createPoDbGlobalRoot(\n plugin: PoServerPluginContext,\n): Promise<RootDeclaration<PoDbHandle | undefined, PoServerPluginContext>> {\n const host = plugin.host;\n const homeDirectory = host.context.homeDirectory;\n if (host.scope !== 'global' || homeDirectory === undefined) return { value: undefined };\n let handle: PoDbHandle | undefined;\n const provider = plugin.context.inject(\n [PO_SERVER_SCOPE_SERVICE, PO_FS_SERVICE, PO_SQLITE_SERVICE],\n async (injected) => {\n // The handle owns its file for the life of the mount; a re-run of this fiber only publishes it again.\n if (handle === undefined) {\n const directory = path.join(poHomeDirectory(homeDirectory, host.context.environment ?? {}), PO_DB_FILE[0]);\n getOrThrow(await requirePoFs(injected).createDir(directory, { recursive: true }, BACKGROUND_CONTEXT));\n await nodeHost.setMode(directory, PO_DB_DIRECTORY_MODE);\n const database = await requirePoSqlite(injected).open(path.join(directory, PO_DB_FILE[1]), BACKGROUND_CONTEXT);\n handle = createPoDb({ database });\n }\n return requirePoServerScope(injected).provide(PO_DB_CONTRACT, handle);\n },\n );\n await provider.await();\n return {\n value: handle,\n onDispose: async () => {\n await provider.dispose();\n await handle?.close();\n },\n };\n}\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { createPoDbGlobalRoot } from './_lib/root.server';\n\nexport default defineRoot(createPoDbGlobalRoot);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootGlobal from '../src/extensions/(backend)/root.server';\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-db',\n providerOverrides: composeServerProviderOverrides(rootGlobal),\n injects: composeRootInjects({ global: [rootGlobal], workspace: [rootGlobal], session: [rootGlobal] }),\n global: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n return {\n ...composeRootHooks(scopeGlobal),\n services: [...(scopeGlobal.services ?? [])],\n };\n },\n workspace: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n return {\n ...composeRootHooks(scopeGlobal),\n services: [...(scopeGlobal.services ?? [])],\n };\n },\n session: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n return {\n ...composeRootHooks(scopeGlobal),\n services: [...(scopeGlobal.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeGlobal.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,eAAsB,qBACpB,QACyE;CACzE,MAAM,OAAO,OAAO;CACpB,MAAM,gBAAgB,KAAK,QAAQ;CACnC,IAAI,KAAK,UAAU,YAAY,kBAAkB,KAAA,GAAW,OAAO,EAAE,OAAO,KAAA,EAAU;CACtF,IAAI;CACJ,MAAM,WAAW,OAAO,QAAQ,OAC9B;EAACA,gCAAAA;EAAyBC,4BAAAA;EAAeC,4BAAAA;CAAiB,GAC1D,OAAO,aAAa;EAElB,IAAI,WAAW,KAAA,GAAW;GACxB,MAAM,YAAYC,UAAAA,QAAK,MAAA,GAAKC,8BAAAA,gBAAAA,CAAgB,eAAe,KAAK,QAAQ,eAAe,CAAC,CAAC,GAAGC,aAAAA,WAAW,EAAE;GACzG,CAAA,GAAA,4BAAA,WAAA,CAAW,OAAA,GAAMC,4BAAAA,YAAAA,CAAY,QAAQ,CAAC,CAAC,UAAU,WAAW,EAAE,WAAW,KAAK,GAAGC,4BAAAA,kBAAkB,CAAC;GACpG,MAAMC,4BAAAA,SAAS,QAAQ,WAAA,GAA+B;GACtD,MAAM,WAAW,OAAA,GAAMC,4BAAAA,gBAAAA,CAAgB,QAAQ,CAAC,CAAC,KAAKN,UAAAA,QAAK,KAAK,WAAWE,aAAAA,WAAW,EAAE,GAAGE,4BAAAA,kBAAkB;GAC7G,SAASG,aAAAA,WAAW,EAAE,SAAS,CAAC;EAClC;EACA,QAAA,GAAOC,gCAAAA,qBAAAA,CAAqB,QAAQ,CAAC,CAAC,QAAQC,kBAAAA,gBAAgB,MAAM;CACtE,CACF;CACA,MAAM,SAAS,MAAM;CACrB,OAAO;EACL,OAAO;EACP,WAAW,YAAY;GACrB,MAAM,SAAS,QAAQ;GACvB,MAAM,QAAQ,MAAM;EACtB;CACF;AACF;;;ACxDA,IAAA,uBAAA,GAAeC,iCAAAA,WAAAA,CAAW,oBAAoB;;;ACG9C,MAAa,gBAAA,GAAeC,gCAAAA,mBAAAA,CAAmB;CAC7C,MAAM;CACN,oBAAA,GAAmBC,gCAAAA,+BAAAA,CAA+BC,mBAAU;CAC5D,UAAA,GAASC,iCAAAA,mBAAAA,CAAmB;EAAE,QAAQ,CAACD,mBAAU;EAAG,WAAW,CAACA,mBAAU;EAAG,SAAS,CAACA,mBAAU;CAAE,CAAC;CACpG,QAAQ,OAAO,YAAY;EACzB,MAAM,cAAc,MAAM,QAAQ,UAAU,UAAUA,qBAAY,OAAO;EACzE,OAAO;GACL,IAAA,GAAGE,iCAAAA,iBAAAA,CAAiB,WAAW;GAC/B,UAAU,CAAC,GAAI,YAAY,YAAY,CAAC,CAAE;EAC5C;CACF;CACA,WAAW,OAAO,YAAY;EAC5B,MAAM,cAAc,MAAM,QAAQ,UAAU,UAAUF,qBAAY,OAAO;EACzE,OAAO;GACL,IAAA,GAAGE,iCAAAA,iBAAAA,CAAiB,WAAW;GAC/B,UAAU,CAAC,GAAI,YAAY,YAAY,CAAC,CAAE;EAC5C;CACF;CACA,SAAS,OAAO,YAAY;EAC1B,MAAM,cAAc,MAAM,QAAQ,UAAU,UAAUF,qBAAY,OAAO;EACzE,OAAO;GACL,IAAA,GAAGE,iCAAAA,iBAAAA,CAAiB,WAAW;GAC/B,UAAU,CAAC,GAAI,YAAY,YAAY,CAAC,CAAE;GAC1C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,YAAY,cAAc,CAAC,CAAE;GAAG;EACtG;CACF;AACF,CAAC"}
@@ -0,0 +1,5 @@
1
+ //#region generated/server.d.ts
2
+ export declare const serverPlugin: import("@agimon-ai/po-core/serverPlugin").PoServerPlugin;
3
+ //#endregion
4
+ export { serverPlugin as default };
5
+ //# sourceMappingURL=server.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.mts","names":[],"sources":["../../generated/server.ts"],"mappings":";qBAOa,wDAAY"}
@@ -0,0 +1,85 @@
1
+ import { n as PO_DB_FILE, t as createPoDb } from "../poDb-D6K38Gpu.mjs";
2
+ import { t as PO_DB_CONTRACT } from "../contracts-Bv9-_vyc.mjs";
3
+ import { composeRootHooks, composeRootInjects, defineRoot } from "@agimon-ai/po-core/extensionFile";
4
+ import { PO_SERVER_SCOPE_SERVICE, composeServerProviderOverrides, defineServerPlugin, requirePoServerScope } from "@agimon-ai/po-core/serverPlugin";
5
+ import path from "node:path";
6
+ import { poHomeDirectory } from "@agimon-ai/po-core/piSettings";
7
+ import { BACKGROUND_CONTEXT, PO_FS_SERVICE, PO_SQLITE_SERVICE, getOrThrow, nodeHost, requirePoFs, requirePoSqlite } from "@agimon-ai/po-core/platform";
8
+ //#region src/extensions/(backend)/_lib/root.server.ts
9
+ /**
10
+ * The process's one Po database, `<po home>/db/po.sqlite`, bound as `po/db` at the global level.
11
+ *
12
+ * Only a global host with a home directory opens it. Workspaces and sessions resolve the global
13
+ * binding through the server scope, so the process keeps a single connection: a second
14
+ * connection would block the event loop while it waits on the first one's write lock.
15
+ */
16
+ async function createPoDbGlobalRoot(plugin) {
17
+ const host = plugin.host;
18
+ const homeDirectory = host.context.homeDirectory;
19
+ if (host.scope !== "global" || homeDirectory === void 0) return { value: void 0 };
20
+ let handle;
21
+ const provider = plugin.context.inject([
22
+ PO_SERVER_SCOPE_SERVICE,
23
+ PO_FS_SERVICE,
24
+ PO_SQLITE_SERVICE
25
+ ], async (injected) => {
26
+ if (handle === void 0) {
27
+ const directory = path.join(poHomeDirectory(homeDirectory, host.context.environment ?? {}), PO_DB_FILE[0]);
28
+ getOrThrow(await requirePoFs(injected).createDir(directory, { recursive: true }, BACKGROUND_CONTEXT));
29
+ await nodeHost.setMode(directory, 448);
30
+ const database = await requirePoSqlite(injected).open(path.join(directory, PO_DB_FILE[1]), BACKGROUND_CONTEXT);
31
+ handle = createPoDb({ database });
32
+ }
33
+ return requirePoServerScope(injected).provide(PO_DB_CONTRACT, handle);
34
+ });
35
+ await provider.await();
36
+ return {
37
+ value: handle,
38
+ onDispose: async () => {
39
+ await provider.dispose();
40
+ await handle?.close();
41
+ }
42
+ };
43
+ }
44
+ //#endregion
45
+ //#region src/extensions/(backend)/root.server.ts
46
+ var root_server_default = defineRoot(createPoDbGlobalRoot);
47
+ //#endregion
48
+ //#region generated/server.ts
49
+ const serverPlugin = defineServerPlugin({
50
+ name: "@agimon-ai/po-db",
51
+ providerOverrides: composeServerProviderOverrides(root_server_default),
52
+ injects: composeRootInjects({
53
+ global: [root_server_default],
54
+ workspace: [root_server_default],
55
+ session: [root_server_default]
56
+ }),
57
+ global: async (context) => {
58
+ const scopeGlobal = await context.scopeRoot("global", root_server_default, context);
59
+ return {
60
+ ...composeRootHooks(scopeGlobal),
61
+ services: [...scopeGlobal.services ?? []]
62
+ };
63
+ },
64
+ workspace: async (context) => {
65
+ const scopeGlobal = await context.scopeRoot("global", root_server_default, context);
66
+ return {
67
+ ...composeRootHooks(scopeGlobal),
68
+ services: [...scopeGlobal.services ?? []]
69
+ };
70
+ },
71
+ session: async (context) => {
72
+ const scopeGlobal = await context.scopeRoot("global", root_server_default, context);
73
+ return {
74
+ ...composeRootHooks(scopeGlobal),
75
+ services: [...scopeGlobal.services ?? []],
76
+ get activities() {
77
+ return [...scopeGlobal.activities ?? []];
78
+ }
79
+ };
80
+ }
81
+ });
82
+ //#endregion
83
+ export { serverPlugin as default, serverPlugin };
84
+
85
+ //# sourceMappingURL=server.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.mjs","names":["rootGlobal"],"sources":["../../src/extensions/(backend)/_lib/root.server.ts","../../src/extensions/(backend)/root.server.ts","../../generated/server.ts"],"sourcesContent":["import path from 'node:path';\n\nimport type { RootDeclaration } from '@agimon-ai/po-core/extensionFile';\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\nimport {\n BACKGROUND_CONTEXT,\n getOrThrow,\n nodeHost,\n PO_FS_SERVICE,\n PO_SQLITE_SERVICE,\n requirePoFs,\n requirePoSqlite,\n} from '@agimon-ai/po-core/platform';\nimport {\n PO_SERVER_SCOPE_SERVICE,\n requirePoServerScope,\n type PoServerPluginContext,\n} from '@agimon-ai/po-core/serverPlugin';\n\nimport { PO_DB_DIRECTORY_MODE, PO_DB_FILE } from '../../../constants/db';\nimport { PO_DB_CONTRACT } from '../../../schemas/contracts';\nimport { createPoDb } from '../../../services/poDb';\nimport type { PoDbHandle } from '../../../services/poDb/type';\n\n/**\n * The process's one Po database, `<po home>/db/po.sqlite`, bound as `po/db` at the global level.\n *\n * Only a global host with a home directory opens it. Workspaces and sessions resolve the global\n * binding through the server scope, so the process keeps a single connection: a second\n * connection would block the event loop while it waits on the first one's write lock.\n */\nexport async function createPoDbGlobalRoot(\n plugin: PoServerPluginContext,\n): Promise<RootDeclaration<PoDbHandle | undefined, PoServerPluginContext>> {\n const host = plugin.host;\n const homeDirectory = host.context.homeDirectory;\n if (host.scope !== 'global' || homeDirectory === undefined) return { value: undefined };\n let handle: PoDbHandle | undefined;\n const provider = plugin.context.inject(\n [PO_SERVER_SCOPE_SERVICE, PO_FS_SERVICE, PO_SQLITE_SERVICE],\n async (injected) => {\n // The handle owns its file for the life of the mount; a re-run of this fiber only publishes it again.\n if (handle === undefined) {\n const directory = path.join(poHomeDirectory(homeDirectory, host.context.environment ?? {}), PO_DB_FILE[0]);\n getOrThrow(await requirePoFs(injected).createDir(directory, { recursive: true }, BACKGROUND_CONTEXT));\n await nodeHost.setMode(directory, PO_DB_DIRECTORY_MODE);\n const database = await requirePoSqlite(injected).open(path.join(directory, PO_DB_FILE[1]), BACKGROUND_CONTEXT);\n handle = createPoDb({ database });\n }\n return requirePoServerScope(injected).provide(PO_DB_CONTRACT, handle);\n },\n );\n await provider.await();\n return {\n value: handle,\n onDispose: async () => {\n await provider.dispose();\n await handle?.close();\n },\n };\n}\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { createPoDbGlobalRoot } from './_lib/root.server';\n\nexport default defineRoot(createPoDbGlobalRoot);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootGlobal from '../src/extensions/(backend)/root.server';\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-db',\n providerOverrides: composeServerProviderOverrides(rootGlobal),\n injects: composeRootInjects({ global: [rootGlobal], workspace: [rootGlobal], session: [rootGlobal] }),\n global: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n return {\n ...composeRootHooks(scopeGlobal),\n services: [...(scopeGlobal.services ?? [])],\n };\n },\n workspace: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n return {\n ...composeRootHooks(scopeGlobal),\n services: [...(scopeGlobal.services ?? [])],\n };\n },\n session: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n return {\n ...composeRootHooks(scopeGlobal),\n services: [...(scopeGlobal.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeGlobal.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,eAAsB,qBACpB,QACyE;CACzE,MAAM,OAAO,OAAO;CACpB,MAAM,gBAAgB,KAAK,QAAQ;CACnC,IAAI,KAAK,UAAU,YAAY,kBAAkB,KAAA,GAAW,OAAO,EAAE,OAAO,KAAA,EAAU;CACtF,IAAI;CACJ,MAAM,WAAW,OAAO,QAAQ,OAC9B;EAAC;EAAyB;EAAe;CAAiB,GAC1D,OAAO,aAAa;EAElB,IAAI,WAAW,KAAA,GAAW;GACxB,MAAM,YAAY,KAAK,KAAK,gBAAgB,eAAe,KAAK,QAAQ,eAAe,CAAC,CAAC,GAAG,WAAW,EAAE;GACzG,WAAW,MAAM,YAAY,QAAQ,CAAC,CAAC,UAAU,WAAW,EAAE,WAAW,KAAK,GAAG,kBAAkB,CAAC;GACpG,MAAM,SAAS,QAAQ,WAAA,GAA+B;GACtD,MAAM,WAAW,MAAM,gBAAgB,QAAQ,CAAC,CAAC,KAAK,KAAK,KAAK,WAAW,WAAW,EAAE,GAAG,kBAAkB;GAC7G,SAAS,WAAW,EAAE,SAAS,CAAC;EAClC;EACA,OAAO,qBAAqB,QAAQ,CAAC,CAAC,QAAQ,gBAAgB,MAAM;CACtE,CACF;CACA,MAAM,SAAS,MAAM;CACrB,OAAO;EACL,OAAO;EACP,WAAW,YAAY;GACrB,MAAM,SAAS,QAAQ;GACvB,MAAM,QAAQ,MAAM;EACtB;CACF;AACF;;;ACxDA,IAAA,sBAAe,WAAW,oBAAoB;;;ACG9C,MAAa,eAAe,mBAAmB;CAC7C,MAAM;CACN,mBAAmB,+BAA+BA,mBAAU;CAC5D,SAAS,mBAAmB;EAAE,QAAQ,CAACA,mBAAU;EAAG,WAAW,CAACA,mBAAU;EAAG,SAAS,CAACA,mBAAU;CAAE,CAAC;CACpG,QAAQ,OAAO,YAAY;EACzB,MAAM,cAAc,MAAM,QAAQ,UAAU,UAAUA,qBAAY,OAAO;EACzE,OAAO;GACL,GAAG,iBAAiB,WAAW;GAC/B,UAAU,CAAC,GAAI,YAAY,YAAY,CAAC,CAAE;EAC5C;CACF;CACA,WAAW,OAAO,YAAY;EAC5B,MAAM,cAAc,MAAM,QAAQ,UAAU,UAAUA,qBAAY,OAAO;EACzE,OAAO;GACL,GAAG,iBAAiB,WAAW;GAC/B,UAAU,CAAC,GAAI,YAAY,YAAY,CAAC,CAAE;EAC5C;CACF;CACA,SAAS,OAAO,YAAY;EAC1B,MAAM,cAAc,MAAM,QAAQ,UAAU,UAAUA,qBAAY,OAAO;EACzE,OAAO;GACL,GAAG,iBAAiB,WAAW;GAC/B,UAAU,CAAC,GAAI,YAAY,YAAY,CAAC,CAAE;GAC1C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,YAAY,cAAc,CAAC,CAAE;GAAG;EACtG;CACF;AACF,CAAC"}
package/dist/index.cjs ADDED
@@ -0,0 +1,8 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_poDb = require("./poDb-BKBXJbTa.cjs");
3
+ const require_contracts = require("./contracts-C9sToxiM.cjs");
4
+ exports.PO_DB_CONTRACT = require_contracts.PO_DB_CONTRACT;
5
+ exports.PO_DB_FILE = require_poDb.PO_DB_FILE;
6
+ exports.PO_DB_SERVICE = require_poDb.PO_DB_SERVICE;
7
+ exports.createPoDb = require_poDb.createPoDb;
8
+ exports.requirePoDb = require_contracts.requirePoDb;
@@ -0,0 +1,23 @@
1
+ import { i as PoDbMigration, n as PoDb, r as PoDbHandle, t as CreatePoDbOptions } from "./type-DK6mNMz9.mjs";
2
+ import { Context } from "@deepseek-ai/cordis";
3
+ //#region src/constants/db.d.ts
4
+ export declare const PO_DB_SERVICE = "po/db";
5
+ /** The database file, as path segments under the Po home. */
6
+ export declare const PO_DB_FILE: readonly ['db', 'po.sqlite'];
7
+ //#endregion
8
+ //#region src/schemas/contracts.d.ts
9
+ /** Bound once at the global level; every workspace and session resolves the same connection. */
10
+ export declare const PO_DB_CONTRACT: import("@agimon-ai/po-core/serverPlugin").PoServiceContract<PoDb>;
11
+ declare module '@deepseek-ai/cordis' {
12
+ interface Context {
13
+ 'po/db': PoDb;
14
+ }
15
+ }
16
+ /** The shared database, for a caller that injected `po/db`; throws when no global root bound one. */
17
+ export declare function requirePoDb(context: Context): PoDb;
18
+ //#endregion
19
+ //#region src/services/poDb/index.d.ts
20
+ export declare function createPoDb(options: CreatePoDbOptions): PoDbHandle;
21
+ //#endregion
22
+ export type { CreatePoDbOptions, PoDb, PoDbHandle, PoDbMigration };
23
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/constants/db.ts","../src/schemas/contracts.ts","../src/services/poDb/index.ts"],"mappings":";;;qBAAa;;qBAEA;;;;qBCKA,0DAAc,kBAAA;;YAGf;IACR,SAAS;;;;wBAKG,YAAY,SAAS,UAAU;;;wBCyD/B,WAAW,SAAS,oBAAoB"}
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { n as PO_DB_FILE, r as PO_DB_SERVICE, t as createPoDb } from "./poDb-D6K38Gpu.mjs";
2
+ import { n as requirePoDb, t as PO_DB_CONTRACT } from "./contracts-Bv9-_vyc.mjs";
3
+ export { PO_DB_CONTRACT, PO_DB_FILE, PO_DB_SERVICE, createPoDb, requirePoDb };
@@ -0,0 +1,93 @@
1
+ let _earendil_works_chord_sqlite = require("@earendil-works/chord/sqlite");
2
+ //#region src/constants/db.ts
3
+ const PO_DB_SERVICE = "po/db";
4
+ /** The database file, as path segments under the Po home. */
5
+ const PO_DB_FILE = ["db", "po.sqlite"];
6
+ /** A table prefix: lowercase words joined by single underscores, never sqlite's own namespace. */
7
+ const PO_DB_PREFIX_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/u;
8
+ //#endregion
9
+ //#region src/services/poDb/index.ts
10
+ /** sqlite names its own automatic indexes `sqlite_autoindex_*`; nobody owns those. */
11
+ const SQLITE_INTERNAL = "sqlite_";
12
+ function assertPrefix(prefix) {
13
+ if (prefix.length > 48 || !PO_DB_PREFIX_PATTERN.test(prefix) || prefix === "sqlite" || prefix.startsWith(SQLITE_INTERNAL)) throw new Error(`Invalid po-db table prefix ${JSON.stringify(prefix)}.`);
14
+ }
15
+ async function schemaNames(executor) {
16
+ const rows = await executor.all("SELECT type, name FROM sqlite_master");
17
+ return new Set(rows.map((row) => `${row.type}\0${row.name}`));
18
+ }
19
+ /**
20
+ * A view of the shared connection that cannot close it.
21
+ *
22
+ * Consumers such as the calendar store call `close()` on the database they were given. One
23
+ * connection serves every package in the process, so only the owning handle may end it.
24
+ */
25
+ function sharedView(database) {
26
+ return {
27
+ exec: (sql) => database.exec(sql),
28
+ run: (sql, ...params) => database.run(sql, ...params),
29
+ get: (sql, ...params) => database.get(sql, ...params),
30
+ all: (sql, ...params) => database.all(sql, ...params),
31
+ transaction: (callback) => database.transaction(callback),
32
+ close: async () => void 0
33
+ };
34
+ }
35
+ /**
36
+ * Runs chord's migrator with every transaction it opens checking the schema it leaves.
37
+ *
38
+ * The check runs inside the migration's own transaction, so a migration that creates an
39
+ * object outside its prefix rolls back with everything else it did.
40
+ */
41
+ function prefixGuarded(database, prefix) {
42
+ const owned = `${prefix}_`;
43
+ return {
44
+ ...sharedView(database),
45
+ transaction: (callback) => database.transaction(async (transaction) => {
46
+ const before = await schemaNames(transaction);
47
+ const result = await callback(transaction);
48
+ for (const entry of await schemaNames(transaction)) {
49
+ if (before.has(entry)) continue;
50
+ const [type, name = ""] = entry.split("\0");
51
+ if (name.startsWith(owned) || name.startsWith(SQLITE_INTERNAL)) continue;
52
+ throw new Error(`po-db migration for ${JSON.stringify(prefix)} created ${type} ${JSON.stringify(name)} outside its prefix.`);
53
+ }
54
+ return result;
55
+ })
56
+ };
57
+ }
58
+ function createPoDb(options) {
59
+ const { database } = options;
60
+ let closing;
61
+ return {
62
+ database: sharedView(database),
63
+ async migrate(prefix, migrations) {
64
+ assertPrefix(prefix);
65
+ await (0, _earendil_works_chord_sqlite.applySqliteMigrations)(prefixGuarded(database, prefix), migrations, { table: `${prefix}_migrations` });
66
+ },
67
+ close() {
68
+ closing ??= database.close();
69
+ return closing;
70
+ }
71
+ };
72
+ }
73
+ //#endregion
74
+ Object.defineProperty(exports, "PO_DB_FILE", {
75
+ enumerable: true,
76
+ get: function() {
77
+ return PO_DB_FILE;
78
+ }
79
+ });
80
+ Object.defineProperty(exports, "PO_DB_SERVICE", {
81
+ enumerable: true,
82
+ get: function() {
83
+ return PO_DB_SERVICE;
84
+ }
85
+ });
86
+ Object.defineProperty(exports, "createPoDb", {
87
+ enumerable: true,
88
+ get: function() {
89
+ return createPoDb;
90
+ }
91
+ });
92
+
93
+ //# sourceMappingURL=poDb-BKBXJbTa.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poDb-BKBXJbTa.cjs","names":["applySqliteMigrations"],"sources":["../src/constants/db.ts","../src/services/poDb/index.ts"],"sourcesContent":["export const PO_DB_SERVICE = 'po/db';\n/** The database file, as path segments under the Po home. */\nexport const PO_DB_FILE = ['db', 'po.sqlite'] as const;\n/** Owner-only: the folder holds every package's rows, secrets included. */\nexport const PO_DB_DIRECTORY_MODE = 0o700;\n/** A table prefix: lowercase words joined by single underscores, never sqlite's own namespace. */\nexport const PO_DB_PREFIX_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/u;\nexport const PO_DB_PREFIX_MAX_LENGTH = 48;\n","import { applySqliteMigrations, type SqliteDatabase, type SqliteExecutor } from '@earendil-works/chord/sqlite';\n\nimport { PO_DB_PREFIX_MAX_LENGTH, PO_DB_PREFIX_PATTERN } from '../../constants/db';\nimport type { CreatePoDbOptions, PoDbHandle, PoDbMigration } from './type';\n\ninterface SchemaObject {\n readonly type: string;\n readonly name: string;\n}\n\n/** sqlite names its own automatic indexes `sqlite_autoindex_*`; nobody owns those. */\nconst SQLITE_INTERNAL = 'sqlite_';\n\nfunction assertPrefix(prefix: string): void {\n if (\n prefix.length > PO_DB_PREFIX_MAX_LENGTH ||\n !PO_DB_PREFIX_PATTERN.test(prefix) ||\n prefix === 'sqlite' ||\n prefix.startsWith(SQLITE_INTERNAL)\n ) {\n throw new Error(`Invalid po-db table prefix ${JSON.stringify(prefix)}.`);\n }\n}\n\nasync function schemaNames(executor: SqliteExecutor): Promise<Set<string>> {\n const rows = await executor.all<SchemaObject>('SELECT type, name FROM sqlite_master');\n return new Set(rows.map((row) => `${row.type}\\0${row.name}`));\n}\n\n/**\n * A view of the shared connection that cannot close it.\n *\n * Consumers such as the calendar store call `close()` on the database they were given. One\n * connection serves every package in the process, so only the owning handle may end it.\n */\nfunction sharedView(database: SqliteDatabase): SqliteDatabase {\n return {\n exec: (sql) => database.exec(sql),\n run: (sql, ...params) => database.run(sql, ...params),\n get: (sql, ...params) => database.get(sql, ...params),\n all: (sql, ...params) => database.all(sql, ...params),\n transaction: (callback) => database.transaction(callback),\n close: async () => undefined,\n };\n}\n\n/**\n * Runs chord's migrator with every transaction it opens checking the schema it leaves.\n *\n * The check runs inside the migration's own transaction, so a migration that creates an\n * object outside its prefix rolls back with everything else it did.\n */\nfunction prefixGuarded(database: SqliteDatabase, prefix: string): SqliteDatabase {\n const owned = `${prefix}_`;\n return {\n ...sharedView(database),\n transaction: (callback) =>\n database.transaction(async (transaction) => {\n const before = await schemaNames(transaction);\n const result = await callback(transaction);\n for (const entry of await schemaNames(transaction)) {\n if (before.has(entry)) continue;\n const [type, name = ''] = entry.split('\\0');\n if (name.startsWith(owned) || name.startsWith(SQLITE_INTERNAL)) continue;\n throw new Error(\n `po-db migration for ${JSON.stringify(prefix)} created ${type} ${JSON.stringify(name)} outside its prefix.`,\n );\n }\n return result;\n }),\n };\n}\n\nexport function createPoDb(options: CreatePoDbOptions): PoDbHandle {\n const { database } = options;\n let closing: Promise<void> | undefined;\n return {\n database: sharedView(database),\n async migrate(prefix: string, migrations: readonly PoDbMigration[]): Promise<void> {\n assertPrefix(prefix);\n await applySqliteMigrations(prefixGuarded(database, prefix), migrations, { table: `${prefix}_migrations` });\n },\n close(): Promise<void> {\n closing ??= database.close();\n return closing;\n },\n };\n}\n"],"mappings":";;AAAA,MAAa,gBAAgB;;AAE7B,MAAa,aAAa,CAAC,MAAM,WAAW;;AAI5C,MAAa,uBAAuB;;;;ACKpC,MAAM,kBAAkB;AAExB,SAAS,aAAa,QAAsB;CAC1C,IACE,OAAO,SAAA,MACP,CAAC,qBAAqB,KAAK,MAAM,KACjC,WAAW,YACX,OAAO,WAAW,eAAe,GAEjC,MAAM,IAAI,MAAM,8BAA8B,KAAK,UAAU,MAAM,EAAE,EAAE;AAE3E;AAEA,eAAe,YAAY,UAAgD;CACzE,MAAM,OAAO,MAAM,SAAS,IAAkB,sCAAsC;CACpF,OAAO,IAAI,IAAI,KAAK,KAAK,QAAQ,GAAG,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC;AAC9D;;;;;;;AAQA,SAAS,WAAW,UAA0C;CAC5D,OAAO;EACL,OAAO,QAAQ,SAAS,KAAK,GAAG;EAChC,MAAM,KAAK,GAAG,WAAW,SAAS,IAAI,KAAK,GAAG,MAAM;EACpD,MAAM,KAAK,GAAG,WAAW,SAAS,IAAI,KAAK,GAAG,MAAM;EACpD,MAAM,KAAK,GAAG,WAAW,SAAS,IAAI,KAAK,GAAG,MAAM;EACpD,cAAc,aAAa,SAAS,YAAY,QAAQ;EACxD,OAAO,YAAY,KAAA;CACrB;AACF;;;;;;;AAQA,SAAS,cAAc,UAA0B,QAAgC;CAC/E,MAAM,QAAQ,GAAG,OAAO;CACxB,OAAO;EACL,GAAG,WAAW,QAAQ;EACtB,cAAc,aACZ,SAAS,YAAY,OAAO,gBAAgB;GAC1C,MAAM,SAAS,MAAM,YAAY,WAAW;GAC5C,MAAM,SAAS,MAAM,SAAS,WAAW;GACzC,KAAK,MAAM,SAAS,MAAM,YAAY,WAAW,GAAG;IAClD,IAAI,OAAO,IAAI,KAAK,GAAG;IACvB,MAAM,CAAC,MAAM,OAAO,MAAM,MAAM,MAAM,IAAI;IAC1C,IAAI,KAAK,WAAW,KAAK,KAAK,KAAK,WAAW,eAAe,GAAG;IAChE,MAAM,IAAI,MACR,uBAAuB,KAAK,UAAU,MAAM,EAAE,WAAW,KAAK,GAAG,KAAK,UAAU,IAAI,EAAE,qBACxF;GACF;GACA,OAAO;EACT,CAAC;CACL;AACF;AAEA,SAAgB,WAAW,SAAwC;CACjE,MAAM,EAAE,aAAa;CACrB,IAAI;CACJ,OAAO;EACL,UAAU,WAAW,QAAQ;EAC7B,MAAM,QAAQ,QAAgB,YAAqD;GACjF,aAAa,MAAM;GACnB,OAAA,GAAMA,6BAAAA,sBAAAA,CAAsB,cAAc,UAAU,MAAM,GAAG,YAAY,EAAE,OAAO,GAAG,OAAO,aAAa,CAAC;EAC5G;EACA,QAAuB;GACrB,YAAY,SAAS,MAAM;GAC3B,OAAO;EACT;CACF;AACF"}
@@ -0,0 +1,76 @@
1
+ import { applySqliteMigrations } from "@earendil-works/chord/sqlite";
2
+ //#region src/constants/db.ts
3
+ const PO_DB_SERVICE = "po/db";
4
+ /** The database file, as path segments under the Po home. */
5
+ const PO_DB_FILE = ["db", "po.sqlite"];
6
+ /** A table prefix: lowercase words joined by single underscores, never sqlite's own namespace. */
7
+ const PO_DB_PREFIX_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/u;
8
+ //#endregion
9
+ //#region src/services/poDb/index.ts
10
+ /** sqlite names its own automatic indexes `sqlite_autoindex_*`; nobody owns those. */
11
+ const SQLITE_INTERNAL = "sqlite_";
12
+ function assertPrefix(prefix) {
13
+ if (prefix.length > 48 || !PO_DB_PREFIX_PATTERN.test(prefix) || prefix === "sqlite" || prefix.startsWith(SQLITE_INTERNAL)) throw new Error(`Invalid po-db table prefix ${JSON.stringify(prefix)}.`);
14
+ }
15
+ async function schemaNames(executor) {
16
+ const rows = await executor.all("SELECT type, name FROM sqlite_master");
17
+ return new Set(rows.map((row) => `${row.type}\0${row.name}`));
18
+ }
19
+ /**
20
+ * A view of the shared connection that cannot close it.
21
+ *
22
+ * Consumers such as the calendar store call `close()` on the database they were given. One
23
+ * connection serves every package in the process, so only the owning handle may end it.
24
+ */
25
+ function sharedView(database) {
26
+ return {
27
+ exec: (sql) => database.exec(sql),
28
+ run: (sql, ...params) => database.run(sql, ...params),
29
+ get: (sql, ...params) => database.get(sql, ...params),
30
+ all: (sql, ...params) => database.all(sql, ...params),
31
+ transaction: (callback) => database.transaction(callback),
32
+ close: async () => void 0
33
+ };
34
+ }
35
+ /**
36
+ * Runs chord's migrator with every transaction it opens checking the schema it leaves.
37
+ *
38
+ * The check runs inside the migration's own transaction, so a migration that creates an
39
+ * object outside its prefix rolls back with everything else it did.
40
+ */
41
+ function prefixGuarded(database, prefix) {
42
+ const owned = `${prefix}_`;
43
+ return {
44
+ ...sharedView(database),
45
+ transaction: (callback) => database.transaction(async (transaction) => {
46
+ const before = await schemaNames(transaction);
47
+ const result = await callback(transaction);
48
+ for (const entry of await schemaNames(transaction)) {
49
+ if (before.has(entry)) continue;
50
+ const [type, name = ""] = entry.split("\0");
51
+ if (name.startsWith(owned) || name.startsWith(SQLITE_INTERNAL)) continue;
52
+ throw new Error(`po-db migration for ${JSON.stringify(prefix)} created ${type} ${JSON.stringify(name)} outside its prefix.`);
53
+ }
54
+ return result;
55
+ })
56
+ };
57
+ }
58
+ function createPoDb(options) {
59
+ const { database } = options;
60
+ let closing;
61
+ return {
62
+ database: sharedView(database),
63
+ async migrate(prefix, migrations) {
64
+ assertPrefix(prefix);
65
+ await applySqliteMigrations(prefixGuarded(database, prefix), migrations, { table: `${prefix}_migrations` });
66
+ },
67
+ close() {
68
+ closing ??= database.close();
69
+ return closing;
70
+ }
71
+ };
72
+ }
73
+ //#endregion
74
+ export { PO_DB_FILE as n, PO_DB_SERVICE as r, createPoDb as t };
75
+
76
+ //# sourceMappingURL=poDb-D6K38Gpu.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poDb-D6K38Gpu.mjs","names":[],"sources":["../src/constants/db.ts","../src/services/poDb/index.ts"],"sourcesContent":["export const PO_DB_SERVICE = 'po/db';\n/** The database file, as path segments under the Po home. */\nexport const PO_DB_FILE = ['db', 'po.sqlite'] as const;\n/** Owner-only: the folder holds every package's rows, secrets included. */\nexport const PO_DB_DIRECTORY_MODE = 0o700;\n/** A table prefix: lowercase words joined by single underscores, never sqlite's own namespace. */\nexport const PO_DB_PREFIX_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/u;\nexport const PO_DB_PREFIX_MAX_LENGTH = 48;\n","import { applySqliteMigrations, type SqliteDatabase, type SqliteExecutor } from '@earendil-works/chord/sqlite';\n\nimport { PO_DB_PREFIX_MAX_LENGTH, PO_DB_PREFIX_PATTERN } from '../../constants/db';\nimport type { CreatePoDbOptions, PoDbHandle, PoDbMigration } from './type';\n\ninterface SchemaObject {\n readonly type: string;\n readonly name: string;\n}\n\n/** sqlite names its own automatic indexes `sqlite_autoindex_*`; nobody owns those. */\nconst SQLITE_INTERNAL = 'sqlite_';\n\nfunction assertPrefix(prefix: string): void {\n if (\n prefix.length > PO_DB_PREFIX_MAX_LENGTH ||\n !PO_DB_PREFIX_PATTERN.test(prefix) ||\n prefix === 'sqlite' ||\n prefix.startsWith(SQLITE_INTERNAL)\n ) {\n throw new Error(`Invalid po-db table prefix ${JSON.stringify(prefix)}.`);\n }\n}\n\nasync function schemaNames(executor: SqliteExecutor): Promise<Set<string>> {\n const rows = await executor.all<SchemaObject>('SELECT type, name FROM sqlite_master');\n return new Set(rows.map((row) => `${row.type}\\0${row.name}`));\n}\n\n/**\n * A view of the shared connection that cannot close it.\n *\n * Consumers such as the calendar store call `close()` on the database they were given. One\n * connection serves every package in the process, so only the owning handle may end it.\n */\nfunction sharedView(database: SqliteDatabase): SqliteDatabase {\n return {\n exec: (sql) => database.exec(sql),\n run: (sql, ...params) => database.run(sql, ...params),\n get: (sql, ...params) => database.get(sql, ...params),\n all: (sql, ...params) => database.all(sql, ...params),\n transaction: (callback) => database.transaction(callback),\n close: async () => undefined,\n };\n}\n\n/**\n * Runs chord's migrator with every transaction it opens checking the schema it leaves.\n *\n * The check runs inside the migration's own transaction, so a migration that creates an\n * object outside its prefix rolls back with everything else it did.\n */\nfunction prefixGuarded(database: SqliteDatabase, prefix: string): SqliteDatabase {\n const owned = `${prefix}_`;\n return {\n ...sharedView(database),\n transaction: (callback) =>\n database.transaction(async (transaction) => {\n const before = await schemaNames(transaction);\n const result = await callback(transaction);\n for (const entry of await schemaNames(transaction)) {\n if (before.has(entry)) continue;\n const [type, name = ''] = entry.split('\\0');\n if (name.startsWith(owned) || name.startsWith(SQLITE_INTERNAL)) continue;\n throw new Error(\n `po-db migration for ${JSON.stringify(prefix)} created ${type} ${JSON.stringify(name)} outside its prefix.`,\n );\n }\n return result;\n }),\n };\n}\n\nexport function createPoDb(options: CreatePoDbOptions): PoDbHandle {\n const { database } = options;\n let closing: Promise<void> | undefined;\n return {\n database: sharedView(database),\n async migrate(prefix: string, migrations: readonly PoDbMigration[]): Promise<void> {\n assertPrefix(prefix);\n await applySqliteMigrations(prefixGuarded(database, prefix), migrations, { table: `${prefix}_migrations` });\n },\n close(): Promise<void> {\n closing ??= database.close();\n return closing;\n },\n };\n}\n"],"mappings":";;AAAA,MAAa,gBAAgB;;AAE7B,MAAa,aAAa,CAAC,MAAM,WAAW;;AAI5C,MAAa,uBAAuB;;;;ACKpC,MAAM,kBAAkB;AAExB,SAAS,aAAa,QAAsB;CAC1C,IACE,OAAO,SAAA,MACP,CAAC,qBAAqB,KAAK,MAAM,KACjC,WAAW,YACX,OAAO,WAAW,eAAe,GAEjC,MAAM,IAAI,MAAM,8BAA8B,KAAK,UAAU,MAAM,EAAE,EAAE;AAE3E;AAEA,eAAe,YAAY,UAAgD;CACzE,MAAM,OAAO,MAAM,SAAS,IAAkB,sCAAsC;CACpF,OAAO,IAAI,IAAI,KAAK,KAAK,QAAQ,GAAG,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC;AAC9D;;;;;;;AAQA,SAAS,WAAW,UAA0C;CAC5D,OAAO;EACL,OAAO,QAAQ,SAAS,KAAK,GAAG;EAChC,MAAM,KAAK,GAAG,WAAW,SAAS,IAAI,KAAK,GAAG,MAAM;EACpD,MAAM,KAAK,GAAG,WAAW,SAAS,IAAI,KAAK,GAAG,MAAM;EACpD,MAAM,KAAK,GAAG,WAAW,SAAS,IAAI,KAAK,GAAG,MAAM;EACpD,cAAc,aAAa,SAAS,YAAY,QAAQ;EACxD,OAAO,YAAY,KAAA;CACrB;AACF;;;;;;;AAQA,SAAS,cAAc,UAA0B,QAAgC;CAC/E,MAAM,QAAQ,GAAG,OAAO;CACxB,OAAO;EACL,GAAG,WAAW,QAAQ;EACtB,cAAc,aACZ,SAAS,YAAY,OAAO,gBAAgB;GAC1C,MAAM,SAAS,MAAM,YAAY,WAAW;GAC5C,MAAM,SAAS,MAAM,SAAS,WAAW;GACzC,KAAK,MAAM,SAAS,MAAM,YAAY,WAAW,GAAG;IAClD,IAAI,OAAO,IAAI,KAAK,GAAG;IACvB,MAAM,CAAC,MAAM,OAAO,MAAM,MAAM,MAAM,IAAI;IAC1C,IAAI,KAAK,WAAW,KAAK,KAAK,KAAK,WAAW,eAAe,GAAG;IAChE,MAAM,IAAI,MACR,uBAAuB,KAAK,UAAU,MAAM,EAAE,WAAW,KAAK,GAAG,KAAK,UAAU,IAAI,EAAE,qBACxF;GACF;GACA,OAAO;EACT,CAAC;CACL;AACF;AAEA,SAAgB,WAAW,SAAwC;CACjE,MAAM,EAAE,aAAa;CACrB,IAAI;CACJ,OAAO;EACL,UAAU,WAAW,QAAQ;EAC7B,MAAM,QAAQ,QAAgB,YAAqD;GACjF,aAAa,MAAM;GACnB,MAAM,sBAAsB,cAAc,UAAU,MAAM,GAAG,YAAY,EAAE,OAAO,GAAG,OAAO,aAAa,CAAC;EAC5G;EACA,QAAuB;GACrB,YAAY,SAAS,MAAM;GAC3B,OAAO;EACT;CACF;AACF"}
@@ -0,0 +1,16 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_poDb = require("./poDb-BKBXJbTa.cjs");
3
+ let _earendil_works_chord_sqlite_node = require("@earendil-works/chord/sqlite/node");
4
+ //#region src/services/testPoDb/index.ts
5
+ /**
6
+ * A po-db on its own Node connection, for tests: in memory by default, or at `file`, which
7
+ * lets several processes share one database the way two Po processes share `po.sqlite`.
8
+ * Node only.
9
+ */
10
+ async function createTestPoDb(file = ":memory:") {
11
+ return require_poDb.createPoDb({ database: await (0, _earendil_works_chord_sqlite_node.openNodeSqliteDatabase)(file) });
12
+ }
13
+ //#endregion
14
+ exports.createTestPoDb = createTestPoDb;
15
+
16
+ //# sourceMappingURL=testing.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.cjs","names":["createPoDb","openNodeSqliteDatabase"],"sources":["../src/services/testPoDb/index.ts"],"sourcesContent":["import { openNodeSqliteDatabase } from '@earendil-works/chord/sqlite/node';\n\nimport { createPoDb } from '../poDb';\nimport type { PoDbHandle } from '../poDb/type';\n\n/**\n * A po-db on its own Node connection, for tests: in memory by default, or at `file`, which\n * lets several processes share one database the way two Po processes share `po.sqlite`.\n * Node only.\n */\nexport async function createTestPoDb(file = ':memory:'): Promise<PoDbHandle> {\n return createPoDb({ database: await openNodeSqliteDatabase(file) });\n}\n"],"mappings":";;;;;;;;;AAUA,eAAsB,eAAe,OAAO,YAAiC;CAC3E,OAAOA,aAAAA,WAAW,EAAE,UAAU,OAAA,GAAMC,kCAAAA,uBAAAA,CAAuB,IAAI,EAAE,CAAC;AACpE"}
@@ -0,0 +1,10 @@
1
+ import { r as PoDbHandle } from "./type-DK6mNMz9.mjs";
2
+ //#region src/services/testPoDb/index.d.ts
3
+ /**
4
+ * A po-db on its own Node connection, for tests: in memory by default, or at `file`, which
5
+ * lets several processes share one database the way two Po processes share `po.sqlite`.
6
+ * Node only.
7
+ */
8
+ export declare function createTestPoDb(file?: string): Promise<PoDbHandle>;
9
+ //#endregion
10
+ //# sourceMappingURL=testing.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.d.mts","names":[],"sources":["../src/services/testPoDb/index.ts"],"mappings":";;;;;;;wBAUsB,eAAe,gBAAoB,QAAQ"}
@@ -0,0 +1,15 @@
1
+ import { t as createPoDb } from "./poDb-D6K38Gpu.mjs";
2
+ import { openNodeSqliteDatabase } from "@earendil-works/chord/sqlite/node";
3
+ //#region src/services/testPoDb/index.ts
4
+ /**
5
+ * A po-db on its own Node connection, for tests: in memory by default, or at `file`, which
6
+ * lets several processes share one database the way two Po processes share `po.sqlite`.
7
+ * Node only.
8
+ */
9
+ async function createTestPoDb(file = ":memory:") {
10
+ return createPoDb({ database: await openNodeSqliteDatabase(file) });
11
+ }
12
+ //#endregion
13
+ export { createTestPoDb };
14
+
15
+ //# sourceMappingURL=testing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.mjs","names":[],"sources":["../src/services/testPoDb/index.ts"],"sourcesContent":["import { openNodeSqliteDatabase } from '@earendil-works/chord/sqlite/node';\n\nimport { createPoDb } from '../poDb';\nimport type { PoDbHandle } from '../poDb/type';\n\n/**\n * A po-db on its own Node connection, for tests: in memory by default, or at `file`, which\n * lets several processes share one database the way two Po processes share `po.sqlite`.\n * Node only.\n */\nexport async function createTestPoDb(file = ':memory:'): Promise<PoDbHandle> {\n return createPoDb({ database: await openNodeSqliteDatabase(file) });\n}\n"],"mappings":";;;;;;;;AAUA,eAAsB,eAAe,OAAO,YAAiC;CAC3E,OAAO,WAAW,EAAE,UAAU,MAAM,uBAAuB,IAAI,EAAE,CAAC;AACpE"}
@@ -0,0 +1,30 @@
1
+ import { SqliteDatabase } from "@earendil-works/chord/sqlite";
2
+ //#region src/services/poDb/type.d.ts
3
+ /** One schema step a package owns: applied once, in version order, inside one transaction. */
4
+ interface PoDbMigration {
5
+ readonly version: number;
6
+ readonly statements: readonly string[];
7
+ }
8
+ /**
9
+ * The process's shared Po database.
10
+ *
11
+ * Every package that keeps rows here owns one table prefix: its tables, indexes, views and
12
+ * triggers all start with `<prefix>_`, and its schema version lives in `<prefix>_migrations`.
13
+ */
14
+ interface PoDb {
15
+ /** The process's shared connection. `close()` is a no-op; no PRAGMA, no ATTACH, no paths. */
16
+ readonly database: SqliteDatabase;
17
+ /** Applies migrations in `<prefix>_migrations`; every new table and index must start with `<prefix>_`. */
18
+ migrate(prefix: string, migrations: readonly PoDbMigration[]): Promise<void>;
19
+ }
20
+ /** The owner's view: only the root that opened the connection closes it. */
21
+ interface PoDbHandle extends PoDb {
22
+ close(): Promise<void>;
23
+ }
24
+ interface CreatePoDbOptions {
25
+ /** The connection the handle owns. Its `close` runs once, from the handle. */
26
+ readonly database: SqliteDatabase;
27
+ }
28
+ //#endregion
29
+ export { PoDbMigration as i, PoDb as n, PoDbHandle as r, CreatePoDbOptions as t };
30
+ //# sourceMappingURL=type-DK6mNMz9.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-DK6mNMz9.d.mts","names":[],"sources":["../src/services/poDb/type.ts"],"mappings":";;;UAGiB;WACN;WACA;;;;;;;;UASM;;WAEN,UAAU;;EAEnB,QAAQ,gBAAgB,qBAAqB,kBAAkB;;;UAIhD,mBAAmB;EAClC,SAAS;;UAGM;;WAEN,UAAU"}
package/llms.txt ADDED
@@ -0,0 +1,7 @@
1
+ # @agimon-ai/po-db
2
+
3
+ One shared sqlite database, `<po home>/db/po.sqlite`, bound as the global `po/db` service for the Po packages that keep rows.
4
+
5
+ ## Resources
6
+
7
+ - [Package README](./README.md): the shared connection, the table prefix rule, migrations, and the test helper.
package/package.json ADDED
@@ -0,0 +1,100 @@
1
+ {
2
+ "name": "@agimon-ai/po-db",
3
+ "version": "0.0.0-alpha.61",
4
+ "description": "One shared sqlite database for the Po packages that need one",
5
+ "keywords": [
6
+ "ai",
7
+ "coding-agent",
8
+ "database",
9
+ "developer-tools",
10
+ "po",
11
+ "sqlite",
12
+ "typescript"
13
+ ],
14
+ "homepage": "https://agimon.ai",
15
+ "bugs": {
16
+ "url": "https://github.com/AgiFlow/po/issues"
17
+ },
18
+ "license": "BUSL-1.1",
19
+ "author": "Vuong Ngo",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/AgiFlow/po.git",
23
+ "directory": "packages/foundations/po-db"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "llms.txt",
28
+ "README.md",
29
+ "LICENSE",
30
+ "package.json"
31
+ ],
32
+ "type": "module",
33
+ "main": "./dist/index.cjs",
34
+ "module": "./dist/index.mjs",
35
+ "types": "./dist/index.d.mts",
36
+ "jsnext:main": "./dist/index.mjs",
37
+ "exports": {
38
+ ".": {
39
+ "types": "./dist/index.d.mts",
40
+ "import": "./dist/index.mjs",
41
+ "require": "./dist/index.cjs"
42
+ },
43
+ "./apiContracts": {
44
+ "types": "./dist/apiContracts.d.mts",
45
+ "import": "./dist/apiContracts.mjs",
46
+ "require": "./dist/apiContracts.cjs"
47
+ },
48
+ "./extensions/server": {
49
+ "types": "./dist/extensions/server.d.mts",
50
+ "import": "./dist/extensions/server.mjs",
51
+ "require": "./dist/extensions/server.cjs"
52
+ },
53
+ "./testing": {
54
+ "types": "./dist/testing.d.mts",
55
+ "import": "./dist/testing.mjs",
56
+ "require": "./dist/testing.cjs"
57
+ },
58
+ "./package.json": "./package.json"
59
+ },
60
+ "publishConfig": {
61
+ "access": "public"
62
+ },
63
+ "dependencies": {
64
+ "@agimon-ai/po-core": "0.0.0-alpha.61",
65
+ "@deepseek-ai/cordis": "4.0.5",
66
+ "@earendil-works/chord": "1.4.0"
67
+ },
68
+ "devDependencies": {
69
+ "@agimon-ai/po-build": "0.0.0-alpha.61",
70
+ "@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.61",
71
+ "@types/node": "26.6.5",
72
+ "@vitest/coverage-v8": "5.0.4",
73
+ "tsdown": "0.23.1",
74
+ "typescript": "7.0.2",
75
+ "vitest": "5.0.4"
76
+ },
77
+ "engines": {
78
+ "node": ">=24"
79
+ },
80
+ "poServer": {
81
+ "entry": "./generated/server.ts",
82
+ "dist": "./dist/extensions/server.mjs",
83
+ "scopes": [
84
+ "global",
85
+ "workspace",
86
+ "session"
87
+ ],
88
+ "contracts": {
89
+ "entry": "./src/exports/apiContracts.ts",
90
+ "dist": "./dist/apiContracts.mjs"
91
+ }
92
+ },
93
+ "scripts": {
94
+ "build": "tsdown",
95
+ "test": "vitest --run",
96
+ "typecheck": "tsrs --noEmit",
97
+ "lint": "oxlint . && oxfmt . --check",
98
+ "fixcode": "oxlint . --fix && oxfmt ."
99
+ }
100
+ }