@astrosheep/square 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/delivery-ledger-sqlite.d.ts +2 -0
- package/dist/delivery-ledger-sqlite.js +21 -1
- package/dist/plugins/opencode-v1/index.js +1 -1
- package/package.json +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/codex/.codex-plugin/plugin.json +1 -1
- package/plugins/opencode-v1/index.ts +1 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { DatabaseSync as NodeDatabaseSync } from 'node:sqlite';
|
|
2
|
+
export declare const DatabaseSync: typeof NodeDatabaseSync;
|
|
1
3
|
import type { DeliveryAttempt, DeliveryCard, DeliveryCorrelation, DeliveryHandoffRef, DeliveryHealth, DeliveryOutcome, DeliveryReceipt, DeliveryRoute, DeliverySession, PostResult, SuppressionResult } from './delivery-ledger.js';
|
|
2
4
|
/** All ledger file access and SQL are confined here. Transactions never span external effects. */
|
|
3
5
|
export declare class LedgerStore {
|
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
|
-
|
|
4
|
+
const bunSqlite = 'bun:sqlite';
|
|
5
|
+
export const { DatabaseSync } = await (process.versions.bun
|
|
6
|
+
? import(bunSqlite).then(({ Database }) => ({
|
|
7
|
+
DatabaseSync: class {
|
|
8
|
+
db;
|
|
9
|
+
constructor(location, options) {
|
|
10
|
+
this.db = new Database(location, options?.readOnly ? { readonly: true } : { create: true, readwrite: true });
|
|
11
|
+
}
|
|
12
|
+
exec(sql) { this.db.exec(sql); }
|
|
13
|
+
close() { this.db.close(); }
|
|
14
|
+
prepare(sql) {
|
|
15
|
+
const statement = this.db.prepare(sql);
|
|
16
|
+
return {
|
|
17
|
+
get: (...values) => statement.get(...values) ?? undefined,
|
|
18
|
+
all: (...values) => statement.all(...values),
|
|
19
|
+
run: (...values) => statement.run(...values),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
}))
|
|
24
|
+
: import('node:sqlite'));
|
|
5
25
|
import { inSqliteTransaction } from './sqlite-transaction.js';
|
|
6
26
|
import { validateSchema } from './sqlite-framing.js';
|
|
7
27
|
const FORMAT = 3;
|
|
@@ -21,7 +21,7 @@ export default async function squareOpenCodeV1(ctx) {
|
|
|
21
21
|
throw new Error('native version below resident floor or unknown');
|
|
22
22
|
if (typeof ctx.client?.session?.get !== 'function' || typeof ctx.client.session.promptAsync !== 'function')
|
|
23
23
|
throw new Error('native session API unavailable');
|
|
24
|
-
const { DatabaseSync } = await import('
|
|
24
|
+
const { DatabaseSync } = await import('../../delivery-ledger-sqlite.js');
|
|
25
25
|
const db = new DatabaseSync(':memory:');
|
|
26
26
|
try {
|
|
27
27
|
db.exec('CREATE TABLE capability (value TEXT)');
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ export default async function squareOpenCodeV1(ctx: LegacyContext) {
|
|
|
23
23
|
const match = typeof health.version === 'string' && /^(\d+)\.(\d+)\.(\d+)$/.exec(health.version);
|
|
24
24
|
if (!match || Number(match[1]) !== 1 || Number(match[2]) < 15 || (Number(match[2]) === 15 && Number(match[3]) < 11)) throw new Error('native version below resident floor or unknown');
|
|
25
25
|
if (typeof ctx.client?.session?.get !== 'function' || typeof ctx.client.session.promptAsync !== 'function') throw new Error('native session API unavailable');
|
|
26
|
-
const { DatabaseSync } = await import('
|
|
26
|
+
const { DatabaseSync } = await import('../../delivery-ledger-sqlite.js');
|
|
27
27
|
const db = new DatabaseSync(':memory:');
|
|
28
28
|
try { db.exec('CREATE TABLE capability (value TEXT)'); db.prepare('INSERT INTO capability VALUES (?)').run('ok'); db.prepare('SELECT value FROM capability').get(); }
|
|
29
29
|
finally { db.close(); }
|