swarm-mail 1.5.4 → 1.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -113254,7 +113254,7 @@ function createDurableStreamAdapter(swarmMail, projectKey) {
113254
113254
  }
113255
113255
  // src/streams/durable-server.ts
113256
113256
  function createDurableStreamServer(config3) {
113257
- const { adapter: adapter5, port: port3 = 4483, projectKey: configProjectKey } = config3;
113257
+ const { adapter: adapter5, hiveAdapter, port: port3 = 4483, projectKey: configProjectKey } = config3;
113258
113258
  let bunServer = null;
113259
113259
  const subscriptions = new Map;
113260
113260
  let subscriptionCounter = 0;
@@ -113267,6 +113267,20 @@ function createDurableStreamServer(config3) {
113267
113267
  idleTimeout: 120,
113268
113268
  async fetch(req) {
113269
113269
  const url4 = new URL(req.url);
113270
+ if (url4.pathname === "/cells") {
113271
+ if (!hiveAdapter) {
113272
+ return new Response(JSON.stringify({ error: "HiveAdapter not configured" }), { status: 500, headers: { "Content-Type": "application/json" } });
113273
+ }
113274
+ try {
113275
+ const cells2 = await hiveAdapter.queryCells(configProjectKey || "", { include_children: true });
113276
+ return new Response(JSON.stringify(cells2), {
113277
+ status: 200,
113278
+ headers: { "Content-Type": "application/json" }
113279
+ });
113280
+ } catch (error48) {
113281
+ return new Response(JSON.stringify({ error: "Failed to query cells" }), { status: 500, headers: { "Content-Type": "application/json" } });
113282
+ }
113283
+ }
113270
113284
  const match44 = url4.pathname.match(/^\/streams\/(.+)$/);
113271
113285
  if (!match44) {
113272
113286
  return new Response("Not Found", { status: 404 });
@@ -8,6 +8,11 @@
8
8
  *
9
9
  * ## Endpoints
10
10
  *
11
+ * GET /cells
12
+ * - Returns all cells from the hive as JSON array
13
+ * - Requires hiveAdapter to be configured
14
+ * - Returns tree structure with parent-child relationships
15
+ *
11
16
  * GET /streams/:projectKey?offset=N&live=true
12
17
  * - offset: Start reading from this sequence (default 0)
13
18
  * - live: If true, keep connection open and stream new events via SSE
@@ -20,12 +25,15 @@
20
25
  * { offset: number, data: string, timestamp: number }
21
26
  */
22
27
  import type { DurableStreamAdapter } from "./durable-adapter.js";
28
+ import type { HiveAdapter } from "../types/hive-adapter.js";
23
29
  /**
24
30
  * Configuration for the Durable Stream HTTP server
25
31
  */
26
32
  export interface DurableStreamServerConfig {
27
33
  /** Adapter for reading events (single project) */
28
34
  adapter: DurableStreamAdapter;
35
+ /** Hive adapter for querying cells */
36
+ hiveAdapter?: HiveAdapter;
29
37
  /** Port to listen on (default 4483 - HIVE on phone keypad) */
30
38
  port?: number;
31
39
  /** Optional project key (for URL matching, defaults to "*" = any) */
@@ -47,10 +55,20 @@ export interface DurableStreamServer {
47
55
  *
48
56
  * @example
49
57
  * ```typescript
58
+ * const swarmMail = await createInMemorySwarmMailLibSQL("my-project");
50
59
  * const adapter = createDurableStreamAdapter(swarmMail, "/my/project");
51
- * const server = createDurableStreamServer({ adapter });
60
+ * const db = await swarmMail.getDatabase();
61
+ * const hiveAdapter = createHiveAdapter(db, "/my/project");
62
+ *
63
+ * const server = createDurableStreamServer({
64
+ * adapter,
65
+ * hiveAdapter,
66
+ * projectKey: "/my/project"
67
+ * });
52
68
  * await server.start();
69
+ *
53
70
  * console.log(`Streaming at ${server.url}/streams/my-project`);
71
+ * console.log(`Cells API at ${server.url}/cells`);
54
72
  * ```
55
73
  */
56
74
  export declare function createDurableStreamServer(config: DurableStreamServerConfig): DurableStreamServer;
@@ -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,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,CAiKrB"}
1
+ {"version":3,"file":"durable-server.d.ts","sourceRoot":"","sources":["../../src/streams/durable-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAe,MAAM,sBAAsB,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAK5D;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,kDAAkD;IAClD,OAAO,EAAE,oBAAoB,CAAC;IAC9B,sCAAsC;IACtC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,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;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,yBAAyB,GAChC,mBAAmB,CA2LrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swarm-mail",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
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",