@hasna/sandboxes 0.1.28 → 0.1.30
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/README.md +10 -5
- package/dist/cli/index.js +5494 -9379
- package/dist/cli/storage.d.ts +2 -0
- package/dist/db/database.d.ts +1 -0
- package/dist/db/pg-migrate.d.ts +7 -0
- package/dist/db/pg-migrations.d.ts +1 -1
- package/dist/db/remote-storage.d.ts +11 -0
- package/dist/db/storage-config.d.ts +26 -0
- package/dist/db/storage-sync.d.ts +35 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5662 -9769
- package/dist/lib/secrets.d.ts +1 -1
- package/dist/mcp/index.js +2025 -6786
- package/dist/mcp/storage-tools.d.ts +2 -0
- package/dist/server/index.js +2595 -7386
- package/dist/storage.d.ts +6 -0
- package/dist/storage.js +5654 -0
- package/package.json +9 -4
package/dist/db/database.d.ts
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class PgAdapterAsync {
|
|
2
|
+
private readonly pool;
|
|
3
|
+
constructor(connectionString: string);
|
|
4
|
+
run(sql: string, ...params: unknown[]): Promise<{
|
|
5
|
+
changes: number;
|
|
6
|
+
}>;
|
|
7
|
+
get(sql: string, ...params: unknown[]): Promise<unknown>;
|
|
8
|
+
all(sql: string, ...params: unknown[]): Promise<unknown[]>;
|
|
9
|
+
exec(sql: string): Promise<void>;
|
|
10
|
+
close(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type StorageMode = "local" | "hybrid" | "remote";
|
|
2
|
+
export interface StorageConfig {
|
|
3
|
+
mode: StorageMode;
|
|
4
|
+
rds: {
|
|
5
|
+
host: string;
|
|
6
|
+
port: number;
|
|
7
|
+
username: string;
|
|
8
|
+
password_env: string;
|
|
9
|
+
ssl: boolean;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface StorageEnv {
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const SANDBOXES_STORAGE_ENV = "HASNA_SANDBOXES_DATABASE_URL";
|
|
16
|
+
export declare const SANDBOXES_STORAGE_FALLBACK_ENV = "SANDBOXES_DATABASE_URL";
|
|
17
|
+
export declare const SANDBOXES_STORAGE_MODE_ENV = "HASNA_SANDBOXES_STORAGE_MODE";
|
|
18
|
+
export declare const SANDBOXES_STORAGE_MODE_FALLBACK_ENV = "SANDBOXES_STORAGE_MODE";
|
|
19
|
+
export declare const STORAGE_DATABASE_ENV: readonly ["HASNA_SANDBOXES_DATABASE_URL", "SANDBOXES_DATABASE_URL"];
|
|
20
|
+
export declare const STORAGE_MODE_ENV: readonly ["HASNA_SANDBOXES_STORAGE_MODE", "SANDBOXES_STORAGE_MODE"];
|
|
21
|
+
export declare function getStorageDatabaseEnvName(): (typeof STORAGE_DATABASE_ENV)[number] | null;
|
|
22
|
+
export declare function getStorageDatabaseEnv(): StorageEnv | null;
|
|
23
|
+
export declare function getStorageDatabaseUrl(): string | undefined;
|
|
24
|
+
export declare function getStorageConfig(): StorageConfig;
|
|
25
|
+
export declare function getStorageConnectionString(dbName?: string): string;
|
|
26
|
+
export declare const getConnectionString: typeof getStorageConnectionString;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Database } from "bun:sqlite";
|
|
2
|
+
import { STORAGE_DATABASE_ENV, type StorageMode } from "./storage-config.js";
|
|
3
|
+
import { PgAdapterAsync } from "./remote-storage.js";
|
|
4
|
+
export interface SyncResult {
|
|
5
|
+
table: string;
|
|
6
|
+
direction: "push" | "pull";
|
|
7
|
+
rowsRead: number;
|
|
8
|
+
rowsWritten: number;
|
|
9
|
+
errors: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface StorageStatus {
|
|
12
|
+
configured: boolean;
|
|
13
|
+
mode: StorageMode;
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
env: typeof STORAGE_DATABASE_ENV;
|
|
16
|
+
activeEnv: string | null;
|
|
17
|
+
service: "sandboxes";
|
|
18
|
+
db_path: string;
|
|
19
|
+
tables: Array<{
|
|
20
|
+
table: string;
|
|
21
|
+
rows: number;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
export declare const STORAGE_TABLES: readonly ["projects", "agents", "sandboxes", "sandbox_sessions", "sandbox_events", "webhooks", "templates", "snapshots", "feedback"];
|
|
25
|
+
export declare const SANDBOXES_STORAGE_TABLES: readonly ["projects", "agents", "sandboxes", "sandbox_sessions", "sandbox_events", "webhooks", "templates", "snapshots", "feedback"];
|
|
26
|
+
export declare function getStoragePg(): Promise<PgAdapterAsync>;
|
|
27
|
+
export declare function runStorageMigrations(remote: PgAdapterAsync): Promise<void>;
|
|
28
|
+
export declare function getStorageStatus(db?: Database): StorageStatus;
|
|
29
|
+
export declare function pushStorageChanges(tables?: string[]): Promise<SyncResult[]>;
|
|
30
|
+
export declare function pullStorageChanges(tables?: string[]): Promise<SyncResult[]>;
|
|
31
|
+
export declare function syncStorageChanges(tables?: string[]): Promise<{
|
|
32
|
+
push: SyncResult[];
|
|
33
|
+
pull: SyncResult[];
|
|
34
|
+
}>;
|
|
35
|
+
export declare function parseStorageTables(raw?: string): string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export * from "./types/index.js";
|
|
2
2
|
export { getDatabase, closeDatabase, resetDatabase, uuid, shortId, now, resolvePartialId } from "./db/database.js";
|
|
3
|
+
export { SANDBOXES_STORAGE_ENV, SANDBOXES_STORAGE_FALLBACK_ENV, SANDBOXES_STORAGE_MODE_ENV, SANDBOXES_STORAGE_MODE_FALLBACK_ENV, STORAGE_DATABASE_ENV, STORAGE_MODE_ENV, getConnectionString, getStorageConfig, getStorageConnectionString, getStorageDatabaseEnv, getStorageDatabaseEnvName, getStorageDatabaseUrl, type StorageConfig, type StorageEnv, type StorageMode, } from "./db/storage-config.js";
|
|
4
|
+
export { PgAdapterAsync } from "./db/remote-storage.js";
|
|
5
|
+
export { applyPgMigrations } from "./db/pg-migrate.js";
|
|
6
|
+
export { SANDBOXES_STORAGE_TABLES, STORAGE_TABLES, getStoragePg, getStorageStatus, parseStorageTables, pullStorageChanges, pushStorageChanges, runStorageMigrations, syncStorageChanges, } from "./db/storage-sync.js";
|
|
7
|
+
export type { StorageStatus, SyncResult } from "./db/storage-sync.js";
|
|
3
8
|
export { createSandbox, getSandbox, listSandboxes, updateSandbox, deleteSandbox } from "./db/sandboxes.js";
|
|
4
9
|
export { createSession, getSession, listSessions, updateSession, endSession } from "./db/sessions.js";
|
|
5
10
|
export { addEvent, listEvents } from "./db/events.js";
|