swarm-mail 1.5.0 → 1.5.2
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/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +267 -16
- package/dist/libsql.convenience.d.ts.map +1 -1
- package/dist/migrate-pglite-to-libsql.d.ts +3 -0
- package/dist/migrate-pglite-to-libsql.d.ts.map +1 -1
- package/dist/pglite.d.ts +53 -6
- package/dist/pglite.d.ts.map +1 -1
- package/dist/streams/durable-adapter.d.ts +2 -1
- package/dist/streams/durable-adapter.d.ts.map +1 -1
- package/dist/streams/durable-server.d.ts +3 -1
- package/dist/streams/durable-server.d.ts.map +1 -1
- package/dist/streams/libsql-schema.d.ts +2 -0
- package/dist/streams/libsql-schema.d.ts.map +1 -1
- package/package.json +5 -2
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ export { createEvent } from "./streams/events";
|
|
|
33
33
|
export { appendEvent, clearAdapterCache, getActiveReservations, getAgent, getEvalRecords, getEvalStats, getOldProjectDbPaths, readEvents, } from "./streams/index";
|
|
34
34
|
export type { EvalRecord } from "./streams/projections-drizzle";
|
|
35
35
|
export { acknowledgeSwarmMessage, checkSwarmHealth as checkSwarmMailHealth, getSwarmInbox, initSwarmAgent, readSwarmMessage, releaseSwarmFiles, reserveSwarmFiles, sendSwarmMessage, } from "./streams/swarm-mail";
|
|
36
|
+
export { createDurableStreamAdapter, type DurableStreamAdapter, type StreamEvent, } from "./streams/durable-adapter.js";
|
|
37
|
+
export { createDurableStreamServer, type DurableStreamServer, type DurableStreamServerConfig, } from "./streams/durable-server.js";
|
|
36
38
|
export { agentActivity, checkpointFrequency, failedDecompositions, formatCSV, formatJSON, formatJSONL, formatTable, humanFeedback, lockContention, messageLatency, QueryBuilder, recoverySuccess, scopeViolations, strategySuccessRates, taskDuration, } from "./analytics/index.js";
|
|
37
39
|
export type { AgentActivityFilters, FailedDecompositionsFilters, LockContentionFilters, MessageLatencyFilters, OutputFormat, QueryResult, StrategySuccessRatesFilters, } from "./analytics/index.js";
|
|
38
40
|
export { ANALYTICS_QUERIES, runAnalyticsQuery } from "./analytics.js";
|
|
@@ -55,4 +57,5 @@ export { createDrizzleClient } from "./db/drizzle";
|
|
|
55
57
|
export { withSqliteRetry } from "./db/retry";
|
|
56
58
|
export { toDrizzleDb, toSwarmDb } from "./libsql.convenience";
|
|
57
59
|
export { type MigrationOptions as PGliteMigrationOptions, type MigrationResult as PGliteMigrationResult, migratePGliteToLibSQL, pgliteExists, } from "./migrate-pglite-to-libsql";
|
|
60
|
+
export { warnPGliteDeprecation, wrapPGlite, } from "./pglite";
|
|
58
61
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAM1C,OAAO,EAAE,GAAG,IAAI,QAAQ,EAAE,MAAM,SAAS,CAAC;AAM1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,YAAY,EACX,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,gBAAgB,GAChB,MAAM,SAAS,CAAC;AAMjB,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EACN,uBAAuB,EACvB,uBAAuB,IAAI,iBAAiB,EAAE,mCAAmC;AACjF,oBAAoB,EACpB,6BAA6B,EAC7B,6BAA6B,IAAI,uBAAuB,EAAE,mCAAmC;AAC7F,eAAe,IAAI,qBAAqB,EACxC,qBAAqB,I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
|
var EMBEDDING_DIM = 1024;
|
|
81333
81333
|
|
|
81334
|
+
// src/pglite.ts
|
|
81335
|
+
function warnPGliteDeprecation() {
|
|
81336
|
+
if (!_pgliteDeprecationWarned) {
|
|
81337
|
+
console.warn("[DEPRECATION] PGlite is deprecated and will be removed in the next major version. Please migrate to libSQL using migratePGliteToLibSQL().");
|
|
81338
|
+
_pgliteDeprecationWarned = true;
|
|
81339
|
+
}
|
|
81340
|
+
}
|
|
81341
|
+
function wrapPGlite(pglite) {
|
|
81342
|
+
warnPGliteDeprecation();
|
|
81343
|
+
return {
|
|
81344
|
+
async query(sql, params) {
|
|
81345
|
+
const result = await pglite.query(sql, params);
|
|
81346
|
+
return { rows: result.rows };
|
|
81347
|
+
},
|
|
81348
|
+
async exec(sql) {
|
|
81349
|
+
await pglite.exec(sql);
|
|
81350
|
+
},
|
|
81351
|
+
async transaction(fn2) {
|
|
81352
|
+
return await fn2(this);
|
|
81353
|
+
},
|
|
81354
|
+
async close() {
|
|
81355
|
+
await pglite.close();
|
|
81356
|
+
}
|
|
81357
|
+
};
|
|
81358
|
+
}
|
|
81359
|
+
var _pgliteDeprecationWarned = false;
|
|
81360
|
+
|
|
81334
81361
|
// src/migrate-pglite-to-libsql.ts
|
|
81335
81362
|
import { existsSync } from "node:fs";
|
|
81336
81363
|
import { join as join8 } from "node:path";
|
|
@@ -81340,6 +81367,7 @@ function pgliteExists(path2) {
|
|
|
81340
81367
|
return existsSync(pgVersionPath);
|
|
81341
81368
|
}
|
|
81342
81369
|
async function migratePGliteToLibSQL(options) {
|
|
81370
|
+
warnPGliteDeprecation();
|
|
81343
81371
|
const {
|
|
81344
81372
|
pglitePath,
|
|
81345
81373
|
libsqlPath,
|
|
@@ -82003,8 +82031,51 @@ async function createLibSQLStreamsSchema(db) {
|
|
|
82003
82031
|
CREATE INDEX IF NOT EXISTS idx_cursors_updated
|
|
82004
82032
|
ON cursors(updated_at)
|
|
82005
82033
|
`);
|
|
82034
|
+
await db.exec(`
|
|
82035
|
+
CREATE TABLE IF NOT EXISTS eval_records (
|
|
82036
|
+
id TEXT PRIMARY KEY,
|
|
82037
|
+
project_key TEXT NOT NULL,
|
|
82038
|
+
task TEXT NOT NULL,
|
|
82039
|
+
context TEXT,
|
|
82040
|
+
strategy TEXT NOT NULL,
|
|
82041
|
+
epic_title TEXT NOT NULL,
|
|
82042
|
+
subtasks TEXT NOT NULL,
|
|
82043
|
+
outcomes TEXT,
|
|
82044
|
+
overall_success INTEGER,
|
|
82045
|
+
total_duration_ms INTEGER,
|
|
82046
|
+
total_errors INTEGER,
|
|
82047
|
+
human_accepted INTEGER,
|
|
82048
|
+
human_modified INTEGER,
|
|
82049
|
+
human_notes TEXT,
|
|
82050
|
+
file_overlap_count INTEGER,
|
|
82051
|
+
scope_accuracy REAL,
|
|
82052
|
+
time_balance_ratio REAL,
|
|
82053
|
+
created_at INTEGER NOT NULL,
|
|
82054
|
+
updated_at INTEGER NOT NULL
|
|
82055
|
+
)
|
|
82056
|
+
`);
|
|
82057
|
+
await db.exec(`
|
|
82058
|
+
CREATE TABLE IF NOT EXISTS swarm_contexts (
|
|
82059
|
+
id TEXT PRIMARY KEY,
|
|
82060
|
+
project_key TEXT NOT NULL,
|
|
82061
|
+
epic_id TEXT NOT NULL,
|
|
82062
|
+
bead_id TEXT NOT NULL,
|
|
82063
|
+
strategy TEXT NOT NULL,
|
|
82064
|
+
files TEXT NOT NULL,
|
|
82065
|
+
dependencies TEXT NOT NULL,
|
|
82066
|
+
directives TEXT NOT NULL,
|
|
82067
|
+
recovery TEXT NOT NULL,
|
|
82068
|
+
created_at INTEGER NOT NULL,
|
|
82069
|
+
checkpointed_at INTEGER NOT NULL,
|
|
82070
|
+
recovered_at INTEGER,
|
|
82071
|
+
recovered_from_checkpoint INTEGER,
|
|
82072
|
+
updated_at INTEGER NOT NULL
|
|
82073
|
+
)
|
|
82074
|
+
`);
|
|
82006
82075
|
}
|
|
82007
82076
|
async function dropLibSQLStreamsSchema(db) {
|
|
82077
|
+
await db.exec("DROP TABLE IF EXISTS swarm_contexts");
|
|
82078
|
+
await db.exec("DROP TABLE IF EXISTS eval_records");
|
|
82008
82079
|
await db.exec("DROP TABLE IF EXISTS cursors");
|
|
82009
82080
|
await db.exec("DROP TABLE IF EXISTS locks");
|
|
82010
82081
|
await db.exec("DROP TABLE IF EXISTS message_recipients");
|
|
@@ -82017,9 +82088,9 @@ async function validateLibSQLStreamsSchema(db) {
|
|
|
82017
82088
|
try {
|
|
82018
82089
|
const tables = await db.query(`
|
|
82019
82090
|
SELECT name FROM sqlite_master
|
|
82020
|
-
WHERE type='table' AND name IN ('events', 'agents', 'messages', 'message_recipients', 'reservations', 'locks', 'cursors')
|
|
82091
|
+
WHERE type='table' AND name IN ('events', 'agents', 'messages', 'message_recipients', 'reservations', 'locks', 'cursors', 'eval_records', 'swarm_contexts')
|
|
82021
82092
|
`);
|
|
82022
|
-
if (tables.rows.length !==
|
|
82093
|
+
if (tables.rows.length !== 9)
|
|
82023
82094
|
return false;
|
|
82024
82095
|
const eventsCols = await db.query(`
|
|
82025
82096
|
PRAGMA table_xinfo('events')
|
|
@@ -95630,7 +95701,7 @@ var require_session2 = __commonJS((exports, module) => {
|
|
|
95630
95701
|
var import_session3 = require_session();
|
|
95631
95702
|
var import_sql18 = require_sql();
|
|
95632
95703
|
var import_utils13 = require_utils();
|
|
95633
|
-
var
|
|
95704
|
+
var import_pglite2 = __require("@electric-sql/pglite");
|
|
95634
95705
|
|
|
95635
95706
|
class PglitePreparedQuery extends import_session3.PgPreparedQuery {
|
|
95636
95707
|
constructor(client, queryString, params, logger2, fields, name2, _isResponseInArrayMode, customResultMapper) {
|
|
@@ -95645,10 +95716,10 @@ var require_session2 = __commonJS((exports, module) => {
|
|
|
95645
95716
|
this.rawQueryConfig = {
|
|
95646
95717
|
rowMode: "object",
|
|
95647
95718
|
parsers: {
|
|
95648
|
-
[
|
|
95649
|
-
[
|
|
95650
|
-
[
|
|
95651
|
-
[
|
|
95719
|
+
[import_pglite2.types.TIMESTAMP]: (value10) => value10,
|
|
95720
|
+
[import_pglite2.types.TIMESTAMPTZ]: (value10) => value10,
|
|
95721
|
+
[import_pglite2.types.INTERVAL]: (value10) => value10,
|
|
95722
|
+
[import_pglite2.types.DATE]: (value10) => value10,
|
|
95652
95723
|
[1231]: (value10) => value10,
|
|
95653
95724
|
[1115]: (value10) => value10,
|
|
95654
95725
|
[1185]: (value10) => value10,
|
|
@@ -95659,10 +95730,10 @@ var require_session2 = __commonJS((exports, module) => {
|
|
|
95659
95730
|
this.queryConfig = {
|
|
95660
95731
|
rowMode: "array",
|
|
95661
95732
|
parsers: {
|
|
95662
|
-
[
|
|
95663
|
-
[
|
|
95664
|
-
[
|
|
95665
|
-
[
|
|
95733
|
+
[import_pglite2.types.TIMESTAMP]: (value10) => value10,
|
|
95734
|
+
[import_pglite2.types.TIMESTAMPTZ]: (value10) => value10,
|
|
95735
|
+
[import_pglite2.types.INTERVAL]: (value10) => value10,
|
|
95736
|
+
[import_pglite2.types.DATE]: (value10) => value10,
|
|
95666
95737
|
[1231]: (value10) => value10,
|
|
95667
95738
|
[1115]: (value10) => value10,
|
|
95668
95739
|
[1185]: (value10) => value10,
|
|
@@ -95767,7 +95838,7 @@ var require_driver = __commonJS((exports, module) => {
|
|
|
95767
95838
|
drizzle: () => drizzle2
|
|
95768
95839
|
});
|
|
95769
95840
|
module.exports = __toCommonJS2(driver_exports);
|
|
95770
|
-
var
|
|
95841
|
+
var import_pglite2 = __require("@electric-sql/pglite");
|
|
95771
95842
|
var import_entity46 = require_entity();
|
|
95772
95843
|
var import_logger3 = require_logger();
|
|
95773
95844
|
var import_db3 = require_db();
|
|
@@ -95816,7 +95887,7 @@ var require_driver = __commonJS((exports, module) => {
|
|
|
95816
95887
|
}
|
|
95817
95888
|
function drizzle2(...params) {
|
|
95818
95889
|
if (params[0] === undefined || typeof params[0] === "string") {
|
|
95819
|
-
const instance = new
|
|
95890
|
+
const instance = new import_pglite2.PGlite(params[0]);
|
|
95820
95891
|
return construct2(instance, params[1]);
|
|
95821
95892
|
}
|
|
95822
95893
|
if ((0, import_utils13.isConfig)(params[0])) {
|
|
@@ -95825,10 +95896,10 @@ var require_driver = __commonJS((exports, module) => {
|
|
|
95825
95896
|
return construct2(client, drizzleConfig);
|
|
95826
95897
|
if (typeof connection === "object") {
|
|
95827
95898
|
const { dataDir, ...options } = connection;
|
|
95828
|
-
const instance2 = new
|
|
95899
|
+
const instance2 = new import_pglite2.PGlite(dataDir, options);
|
|
95829
95900
|
return construct2(instance2, drizzleConfig);
|
|
95830
95901
|
}
|
|
95831
|
-
const instance = new
|
|
95902
|
+
const instance = new import_pglite2.PGlite(connection);
|
|
95832
95903
|
return construct2(instance, drizzleConfig);
|
|
95833
95904
|
}
|
|
95834
95905
|
return construct2(params[0], params[1]);
|
|
@@ -95945,6 +96016,7 @@ function toDrizzleDb(db2) {
|
|
|
95945
96016
|
return createDrizzleClient(db2.getClient());
|
|
95946
96017
|
}
|
|
95947
96018
|
if (db2 && typeof db2.query === "function" && typeof db2.exec === "function") {
|
|
96019
|
+
warnPGliteDeprecation();
|
|
95948
96020
|
const { drizzle: drizzle2 } = require_pglite();
|
|
95949
96021
|
const { schema } = (init_schema(), __toCommonJS(exports_schema));
|
|
95950
96022
|
return drizzle2(db2, { schema });
|
|
@@ -99394,6 +99466,181 @@ init_events();
|
|
|
99394
99466
|
init_streams2();
|
|
99395
99467
|
init_swarm_mail();
|
|
99396
99468
|
|
|
99469
|
+
// src/streams/durable-adapter.ts
|
|
99470
|
+
function createDurableStreamAdapter(swarmMail, projectKey) {
|
|
99471
|
+
return {
|
|
99472
|
+
async read(offset, limit) {
|
|
99473
|
+
const events2 = await swarmMail.readEvents({
|
|
99474
|
+
projectKey,
|
|
99475
|
+
afterSequence: offset,
|
|
99476
|
+
limit
|
|
99477
|
+
});
|
|
99478
|
+
return events2.map((event) => ({
|
|
99479
|
+
offset: event.sequence,
|
|
99480
|
+
data: JSON.stringify(event),
|
|
99481
|
+
timestamp: event.timestamp
|
|
99482
|
+
}));
|
|
99483
|
+
},
|
|
99484
|
+
async head() {
|
|
99485
|
+
return await swarmMail.getLatestSequence(projectKey);
|
|
99486
|
+
},
|
|
99487
|
+
subscribe(callback, startOffset) {
|
|
99488
|
+
let lastSequence = startOffset ?? 0;
|
|
99489
|
+
let isActive3 = true;
|
|
99490
|
+
let initialized = startOffset !== undefined;
|
|
99491
|
+
if (!initialized) {
|
|
99492
|
+
(async () => {
|
|
99493
|
+
lastSequence = await swarmMail.getLatestSequence(projectKey);
|
|
99494
|
+
initialized = true;
|
|
99495
|
+
})();
|
|
99496
|
+
}
|
|
99497
|
+
const pollInterval = setInterval(async () => {
|
|
99498
|
+
if (!isActive3 || !initialized)
|
|
99499
|
+
return;
|
|
99500
|
+
try {
|
|
99501
|
+
const events2 = await swarmMail.readEvents({
|
|
99502
|
+
projectKey,
|
|
99503
|
+
afterSequence: lastSequence,
|
|
99504
|
+
limit: 100
|
|
99505
|
+
});
|
|
99506
|
+
for (const event of events2) {
|
|
99507
|
+
if (!isActive3)
|
|
99508
|
+
break;
|
|
99509
|
+
const streamEvent = {
|
|
99510
|
+
offset: event.sequence,
|
|
99511
|
+
data: JSON.stringify(event),
|
|
99512
|
+
timestamp: event.timestamp
|
|
99513
|
+
};
|
|
99514
|
+
callback(streamEvent);
|
|
99515
|
+
lastSequence = event.sequence;
|
|
99516
|
+
}
|
|
99517
|
+
} catch (error48) {
|
|
99518
|
+
console.error("[DurableStreamAdapter] Poll error:", error48);
|
|
99519
|
+
}
|
|
99520
|
+
}, 100);
|
|
99521
|
+
return () => {
|
|
99522
|
+
isActive3 = false;
|
|
99523
|
+
clearInterval(pollInterval);
|
|
99524
|
+
};
|
|
99525
|
+
}
|
|
99526
|
+
};
|
|
99527
|
+
}
|
|
99528
|
+
// src/streams/durable-server.ts
|
|
99529
|
+
function createDurableStreamServer(config3) {
|
|
99530
|
+
const { adapter: adapter5, port: port3 = 4483, projectKey: configProjectKey } = config3;
|
|
99531
|
+
let bunServer = null;
|
|
99532
|
+
const subscriptions = new Map;
|
|
99533
|
+
let subscriptionCounter = 0;
|
|
99534
|
+
const url4 = `http://localhost:${port3}`;
|
|
99535
|
+
async function start5() {
|
|
99536
|
+
if (bunServer) {
|
|
99537
|
+
throw new Error("Server is already running");
|
|
99538
|
+
}
|
|
99539
|
+
bunServer = Bun.serve({
|
|
99540
|
+
port: port3,
|
|
99541
|
+
idleTimeout: 120,
|
|
99542
|
+
async fetch(req) {
|
|
99543
|
+
const url5 = new URL(req.url);
|
|
99544
|
+
const match44 = url5.pathname.match(/^\/streams\/(.+)$/);
|
|
99545
|
+
if (!match44) {
|
|
99546
|
+
return new Response("Not Found", { status: 404 });
|
|
99547
|
+
}
|
|
99548
|
+
const requestedProjectKey = decodeURIComponent(match44[1]);
|
|
99549
|
+
if (configProjectKey && configProjectKey !== requestedProjectKey) {
|
|
99550
|
+
return new Response("Project not found", { status: 404 });
|
|
99551
|
+
}
|
|
99552
|
+
const offsetParam = url5.searchParams.get("offset");
|
|
99553
|
+
const liveParam = url5.searchParams.get("live");
|
|
99554
|
+
const limitParam = url5.searchParams.get("limit");
|
|
99555
|
+
const offset = offsetParam ? Number.parseInt(offsetParam, 10) : 0;
|
|
99556
|
+
const live6 = liveParam === "true";
|
|
99557
|
+
const limit = limitParam ? Number.parseInt(limitParam, 10) : 100;
|
|
99558
|
+
if (Number.isNaN(offset) || offset < 0) {
|
|
99559
|
+
return new Response("Invalid offset parameter", { status: 400 });
|
|
99560
|
+
}
|
|
99561
|
+
if (!live6) {
|
|
99562
|
+
const events2 = await adapter5.read(offset, limit);
|
|
99563
|
+
return new Response(JSON.stringify(events2), {
|
|
99564
|
+
status: 200,
|
|
99565
|
+
headers: {
|
|
99566
|
+
"Content-Type": "application/json"
|
|
99567
|
+
}
|
|
99568
|
+
});
|
|
99569
|
+
}
|
|
99570
|
+
const stream2 = new ReadableStream({
|
|
99571
|
+
async start(controller) {
|
|
99572
|
+
const encoder2 = new TextEncoder;
|
|
99573
|
+
controller.enqueue(encoder2.encode(`: connected
|
|
99574
|
+
|
|
99575
|
+
`));
|
|
99576
|
+
const existingEvents = await adapter5.read(offset, limit);
|
|
99577
|
+
for (const event of existingEvents) {
|
|
99578
|
+
const sse = `data: ${JSON.stringify(event)}
|
|
99579
|
+
|
|
99580
|
+
`;
|
|
99581
|
+
controller.enqueue(encoder2.encode(sse));
|
|
99582
|
+
}
|
|
99583
|
+
const subscriptionId = subscriptionCounter++;
|
|
99584
|
+
const unsubscribe = adapter5.subscribe((event) => {
|
|
99585
|
+
if (event.offset > offset) {
|
|
99586
|
+
try {
|
|
99587
|
+
const sse = `data: ${JSON.stringify(event)}
|
|
99588
|
+
|
|
99589
|
+
`;
|
|
99590
|
+
controller.enqueue(encoder2.encode(sse));
|
|
99591
|
+
} catch (error48) {
|
|
99592
|
+
console.error("Error sending event:", error48);
|
|
99593
|
+
}
|
|
99594
|
+
}
|
|
99595
|
+
}, offset);
|
|
99596
|
+
subscriptions.set(subscriptionId, { unsubscribe, controller });
|
|
99597
|
+
const cleanup = () => {
|
|
99598
|
+
const sub = subscriptions.get(subscriptionId);
|
|
99599
|
+
if (sub) {
|
|
99600
|
+
sub.unsubscribe();
|
|
99601
|
+
subscriptions.delete(subscriptionId);
|
|
99602
|
+
}
|
|
99603
|
+
};
|
|
99604
|
+
req.signal.addEventListener("abort", () => {
|
|
99605
|
+
cleanup();
|
|
99606
|
+
try {
|
|
99607
|
+
controller.close();
|
|
99608
|
+
} catch {}
|
|
99609
|
+
});
|
|
99610
|
+
},
|
|
99611
|
+
cancel() {}
|
|
99612
|
+
});
|
|
99613
|
+
return new Response(stream2, {
|
|
99614
|
+
status: 200,
|
|
99615
|
+
headers: {
|
|
99616
|
+
"Content-Type": "text/event-stream",
|
|
99617
|
+
"Cache-Control": "no-cache",
|
|
99618
|
+
Connection: "keep-alive"
|
|
99619
|
+
}
|
|
99620
|
+
});
|
|
99621
|
+
}
|
|
99622
|
+
});
|
|
99623
|
+
}
|
|
99624
|
+
async function stop3() {
|
|
99625
|
+
if (!bunServer) {
|
|
99626
|
+
return;
|
|
99627
|
+
}
|
|
99628
|
+
for (const { unsubscribe, controller } of subscriptions.values()) {
|
|
99629
|
+
unsubscribe();
|
|
99630
|
+
try {
|
|
99631
|
+
controller.close();
|
|
99632
|
+
} catch {}
|
|
99633
|
+
}
|
|
99634
|
+
subscriptions.clear();
|
|
99635
|
+
bunServer.stop();
|
|
99636
|
+
bunServer = null;
|
|
99637
|
+
}
|
|
99638
|
+
return {
|
|
99639
|
+
start: start5,
|
|
99640
|
+
stop: stop3,
|
|
99641
|
+
url: url4
|
|
99642
|
+
};
|
|
99643
|
+
}
|
|
99397
99644
|
// src/analytics/formatters.ts
|
|
99398
99645
|
function formatTable(result) {
|
|
99399
99646
|
const { columns: columns2, rows, rowCount } = result;
|
|
@@ -101502,7 +101749,7 @@ function getHiveDrizzle(db2) {
|
|
|
101502
101749
|
}
|
|
101503
101750
|
async function resolvePartialIdDrizzle(adapter5, projectKey, partialHash) {
|
|
101504
101751
|
const db2 = getHiveDrizzle(await adapter5.getDatabase());
|
|
101505
|
-
const pattern2 =
|
|
101752
|
+
const pattern2 = `%${partialHash}%`;
|
|
101506
101753
|
const results = await db2.select().from(beads).where(and3(eq(beads.project_key, projectKey), isNull2(beads.deleted_at), like(beads.id, pattern2)));
|
|
101507
101754
|
if (results.length === 0) {
|
|
101508
101755
|
return null;
|
|
@@ -102440,8 +102687,10 @@ init_libsql_convenience();
|
|
|
102440
102687
|
init_migrate_pglite_to_libsql();
|
|
102441
102688
|
var SWARM_MAIL_VERSION = "0.1.0";
|
|
102442
102689
|
export {
|
|
102690
|
+
wrapPGlite,
|
|
102443
102691
|
wouldCreateCycle,
|
|
102444
102692
|
withSqliteRetry,
|
|
102693
|
+
warnPGliteDeprecation,
|
|
102445
102694
|
validateLibSQLStreamsSchema,
|
|
102446
102695
|
validateLibSQLMemorySchema,
|
|
102447
102696
|
updateProjections,
|
|
@@ -102553,6 +102802,8 @@ export {
|
|
|
102553
102802
|
createInMemoryDb,
|
|
102554
102803
|
createHiveAdapter,
|
|
102555
102804
|
createEvent,
|
|
102805
|
+
createDurableStreamServer,
|
|
102806
|
+
createDurableStreamAdapter,
|
|
102556
102807
|
createDrizzleClient,
|
|
102557
102808
|
createHiveAdapter as createBeadsAdapter,
|
|
102558
102809
|
computeContentHash,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libsql.convenience.d.ts","sourceRoot":"","sources":["../src/libsql.convenience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAUH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"libsql.convenience.d.ts","sourceRoot":"","sources":["../src/libsql.convenience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAUH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAK9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAU3D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAajE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAa5D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAyB3B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,gBAAgB,CAAC,CAS3B;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAW7D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAO3D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CAiB5C"}
|
|
@@ -68,6 +68,9 @@ export interface MigrationResult {
|
|
|
68
68
|
export declare function pgliteExists(path: string): boolean;
|
|
69
69
|
/**
|
|
70
70
|
* Migrate all data from PGlite to libSQL
|
|
71
|
+
*
|
|
72
|
+
* @deprecated This is the last version supporting PGlite migration.
|
|
73
|
+
* PGlite support will be removed in the next major version.
|
|
71
74
|
*/
|
|
72
75
|
export declare function migratePGliteToLibSQL(options: MigrationOptions): Promise<MigrationResult>;
|
|
73
76
|
//# sourceMappingURL=migrate-pglite-to-libsql.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-pglite-to-libsql.d.ts","sourceRoot":"","sources":["../src/migrate-pglite-to-libsql.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;
|
|
1
|
+
{"version":3,"file":"migrate-pglite-to-libsql.d.ts","sourceRoot":"","sources":["../src/migrate-pglite-to-libsql.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAQH,MAAM,WAAW,gBAAgB;IAC/B,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D,QAAQ,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9D,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9D,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGlD;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,CA+E1B"}
|
package/dist/pglite.d.ts
CHANGED
|
@@ -1,16 +1,63 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* PGlite Adapter (DEPRECATED)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* This module provides backward compatibility for PGlite databases.
|
|
5
|
+
* It wraps PGlite instances as DatabaseAdapter and warns about deprecation.
|
|
6
6
|
*
|
|
7
|
-
* @deprecated
|
|
7
|
+
* @deprecated This entire module will be removed in the next major version.
|
|
8
|
+
* Migrate to libSQL using migratePGliteToLibSQL().
|
|
9
|
+
*
|
|
10
|
+
* @module pglite
|
|
8
11
|
*/
|
|
9
12
|
import type { DatabaseAdapter } from "./types/database.js";
|
|
13
|
+
/**
|
|
14
|
+
* Reset deprecation flag (for testing only)
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare function _resetDeprecationFlag(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Warn about PGlite deprecation (once per session)
|
|
20
|
+
*
|
|
21
|
+
* Logs a deprecation warning to console.warn() on first call.
|
|
22
|
+
* Subsequent calls are silent to avoid log spam.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { warnPGliteDeprecation } from 'swarm-mail';
|
|
27
|
+
*
|
|
28
|
+
* warnPGliteDeprecation(); // Warns
|
|
29
|
+
* warnPGliteDeprecation(); // Silent
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function warnPGliteDeprecation(): void;
|
|
10
33
|
/**
|
|
11
34
|
* Wrap a PGlite instance as a DatabaseAdapter
|
|
12
35
|
*
|
|
13
|
-
*
|
|
36
|
+
* Provides a DatabaseAdapter interface around a PGlite instance.
|
|
37
|
+
* Warns about deprecation on first call.
|
|
38
|
+
*
|
|
39
|
+
* @param pglite - PGlite database instance
|
|
40
|
+
* @returns DatabaseAdapter wrapping the PGlite instance
|
|
41
|
+
*
|
|
42
|
+
* @deprecated Use libSQL via createLibSQLAdapter() instead.
|
|
43
|
+
* This function will be removed in the next major version.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* import { PGlite } from '@electric-sql/pglite';
|
|
48
|
+
* import { wrapPGlite } from 'swarm-mail';
|
|
49
|
+
*
|
|
50
|
+
* const pglite = await PGlite.create({ dataDir: './data' });
|
|
51
|
+
* const adapter = wrapPGlite(pglite);
|
|
52
|
+
*
|
|
53
|
+
* await adapter.query('SELECT * FROM users');
|
|
54
|
+
* ```
|
|
14
55
|
*/
|
|
15
|
-
export declare function wrapPGlite(pglite:
|
|
56
|
+
export declare function wrapPGlite(pglite: {
|
|
57
|
+
query: (sql: string, params?: unknown[]) => Promise<{
|
|
58
|
+
rows: unknown[];
|
|
59
|
+
}>;
|
|
60
|
+
exec: (sql: string) => Promise<void>;
|
|
61
|
+
close: () => Promise<void>;
|
|
62
|
+
}): DatabaseAdapter;
|
|
16
63
|
//# sourceMappingURL=pglite.d.ts.map
|
package/dist/pglite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pglite.d.ts","sourceRoot":"","sources":["../src/pglite.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pglite.d.ts","sourceRoot":"","sources":["../src/pglite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQ3D;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAO5C;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE;IAClC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,CAAC;IACzE,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B,GAAG,eAAe,CAkBlB"}
|
|
@@ -53,9 +53,10 @@ export interface DurableStreamAdapter {
|
|
|
53
53
|
* Only delivers events that arrive AFTER subscription starts.
|
|
54
54
|
*
|
|
55
55
|
* @param callback - Called with each new event
|
|
56
|
+
* @param startOffset - Optional offset to start from (avoids async race)
|
|
56
57
|
* @returns Unsubscribe function
|
|
57
58
|
*/
|
|
58
|
-
subscribe(callback: (event: StreamEvent) => void): () => void;
|
|
59
|
+
subscribe(callback: (event: StreamEvent) => void, startOffset?: number): () => void;
|
|
59
60
|
}
|
|
60
61
|
/**
|
|
61
62
|
* Create a DurableStreamAdapter for a specific project
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durable-adapter.d.ts","sourceRoot":"","sources":["../../src/streams/durable-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG5D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAE5D;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAExB
|
|
1
|
+
{"version":3,"file":"durable-adapter.d.ts","sourceRoot":"","sources":["../../src/streams/durable-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG5D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAE5D;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAExB;;;;;;;;;OASG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,IAAI,CAAC;CACrF;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,gBAAgB,EAC3B,UAAU,EAAE,MAAM,GACjB,oBAAoB,CA0EtB"}
|
|
@@ -24,10 +24,12 @@ import type { DurableStreamAdapter } from "./durable-adapter.js";
|
|
|
24
24
|
* Configuration for the Durable Stream HTTP server
|
|
25
25
|
*/
|
|
26
26
|
export interface DurableStreamServerConfig {
|
|
27
|
-
/** Adapter for reading events */
|
|
27
|
+
/** Adapter for reading events (single project) */
|
|
28
28
|
adapter: DurableStreamAdapter;
|
|
29
29
|
/** Port to listen on (default 4483 - HIVE on phone keypad) */
|
|
30
30
|
port?: number;
|
|
31
|
+
/** Optional project key (for URL matching, defaults to "*" = any) */
|
|
32
|
+
projectKey?: string;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* Durable Stream HTTP server interface
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durable-server.d.ts","sourceRoot":"","sources":["../../src/streams/durable-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAe,MAAM,sBAAsB,CAAC;AAK9E;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,
|
|
1
|
+
{"version":3,"file":"durable-server.d.ts","sourceRoot":"","sources":["../../src/streams/durable-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAe,MAAM,sBAAsB,CAAC;AAK9E;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,kDAAkD;IAClD,OAAO,EAAE,oBAAoB,CAAC;IAC9B,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,4BAA4B;IAC5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,sDAAsD;IACtD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,6BAA6B;IAC7B,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,yBAAyB,GAChC,mBAAmB,CA+JrB"}
|
|
@@ -37,6 +37,8 @@ import type { DatabaseAdapter } from "../types/database.js";
|
|
|
37
37
|
* - reservations (file locks)
|
|
38
38
|
* - locks (distributed mutex)
|
|
39
39
|
* - cursors (stream positions)
|
|
40
|
+
* - eval_records (decomposition eval tracking)
|
|
41
|
+
* - swarm_contexts (swarm checkpoint tracking)
|
|
40
42
|
*
|
|
41
43
|
* Idempotent - safe to call multiple times.
|
|
42
44
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libsql-schema.d.ts","sourceRoot":"","sources":["../../src/streams/libsql-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D
|
|
1
|
+
{"version":3,"file":"libsql-schema.d.ts","sourceRoot":"","sources":["../../src/streams/libsql-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,yBAAyB,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAuRlF;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAWhF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,2BAA2B,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAkCvF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swarm-mail",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Event sourcing primitives for multi-agent coordination. Local-first, no external servers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@libsql/client": "^0.15.15",
|
|
43
|
-
"@libsql/darwin-arm64": "^0.5.22",
|
|
44
43
|
"debug": "^4.4.3",
|
|
45
44
|
"drizzle-orm": "^0.41.0",
|
|
46
45
|
"effect": "^3.19.12",
|
|
@@ -57,5 +56,9 @@
|
|
|
57
56
|
"drizzle-kit": "^0.31.0",
|
|
58
57
|
"typescript": "^5.7.2",
|
|
59
58
|
"vitest": "^2.1.8"
|
|
59
|
+
},
|
|
60
|
+
"optionalDependencies": {
|
|
61
|
+
"@libsql/darwin-arm64": "^0.5.22",
|
|
62
|
+
"@libsql/darwin-x64": "^0.5.22"
|
|
60
63
|
}
|
|
61
64
|
}
|