agentfs-sdk 0.2.3-pre.7 → 0.2.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/index.d.ts CHANGED
@@ -45,6 +45,7 @@ export declare class AgentFS {
45
45
  * ```
46
46
  */
47
47
  static open(options: AgentFSOptions): Promise<AgentFS>;
48
+ static openWith(db: Database): Promise<AgentFS>;
48
49
  /**
49
50
  * Get the underlying Database instance
50
51
  */
package/dist/index.js CHANGED
@@ -58,6 +58,9 @@ class AgentFS {
58
58
  const db = new database_1.Database(dbPath);
59
59
  // Connect to the database to ensure it's created
60
60
  await db.connect();
61
+ return await AgentFS.openWith(db);
62
+ }
63
+ static async openWith(db) {
61
64
  // Create subsystems
62
65
  const kv = new kvstore_1.KvStore(db);
63
66
  const fs = new filesystem_1.Filesystem(db);
package/dist/kvstore.d.ts CHANGED
@@ -6,6 +6,10 @@ export declare class KvStore {
6
6
  private initialize;
7
7
  set(key: string, value: any): Promise<void>;
8
8
  get(key: string): Promise<any>;
9
+ list(prefix: string): Promise<{
10
+ key: string;
11
+ value: any;
12
+ }[]>;
9
13
  delete(key: string): Promise<void>;
10
14
  /**
11
15
  * Wait for initialization to complete
package/dist/kvstore.js CHANGED
@@ -56,6 +56,13 @@ class KvStore {
56
56
  // Deserialize the JSON value
57
57
  return JSON.parse(row.value);
58
58
  }
59
+ async list(prefix) {
60
+ await this.initialized;
61
+ const stmt = this.db.prepare(`SELECT key, value FROM kv_store WHERE key LIKE ? ESCAPE '\\'`);
62
+ const escaped = prefix.replace('\\', '\\\\').replace('%', '\\%').replace('_', '\\_');
63
+ const rows = await stmt.all(escaped + '%');
64
+ return rows.map(r => ({ key: r.key, value: JSON.parse(r.value) }));
65
+ }
59
66
  async delete(key) {
60
67
  await this.initialized;
61
68
  const stmt = this.db.prepare(`DELETE FROM kv_store WHERE key = ?`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentfs-sdk",
3
- "version": "0.2.3-pre.7",
3
+ "version": "0.2.3",
4
4
  "description": "AgentFS SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",