mac: bundle web chat assets
This commit is contained in:
33
apps/macos/Sources/Clawdis/Resources/WebChat/storage/app-storage.d.ts
vendored
Normal file
33
apps/macos/Sources/Clawdis/Resources/WebChat/storage/app-storage.d.ts
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { CustomProvidersStore } from "./stores/custom-providers-store.js";
|
||||
import type { ProviderKeysStore } from "./stores/provider-keys-store.js";
|
||||
import type { SessionsStore } from "./stores/sessions-store.js";
|
||||
import type { SettingsStore } from "./stores/settings-store.js";
|
||||
import type { StorageBackend } from "./types.js";
|
||||
/**
|
||||
* High-level storage API providing access to all storage operations.
|
||||
* Subclasses can extend this to add domain-specific stores.
|
||||
*/
|
||||
export declare class AppStorage {
|
||||
readonly backend: StorageBackend;
|
||||
readonly settings: SettingsStore;
|
||||
readonly providerKeys: ProviderKeysStore;
|
||||
readonly sessions: SessionsStore;
|
||||
readonly customProviders: CustomProvidersStore;
|
||||
constructor(settings: SettingsStore, providerKeys: ProviderKeysStore, sessions: SessionsStore, customProviders: CustomProvidersStore, backend: StorageBackend);
|
||||
getQuotaInfo(): Promise<{
|
||||
usage: number;
|
||||
quota: number;
|
||||
percent: number;
|
||||
}>;
|
||||
requestPersistence(): Promise<boolean>;
|
||||
}
|
||||
/**
|
||||
* Get the global AppStorage instance.
|
||||
* Throws if not initialized.
|
||||
*/
|
||||
export declare function getAppStorage(): AppStorage;
|
||||
/**
|
||||
* Set the global AppStorage instance.
|
||||
*/
|
||||
export declare function setAppStorage(storage: AppStorage): void;
|
||||
//# sourceMappingURL=app-storage.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"app-storage.d.ts","sourceRoot":"","sources":["../../src/storage/app-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;GAGG;AACH,qBAAa,UAAU;IACtB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,iBAAiB,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,eAAe,EAAE,oBAAoB,CAAC;gBAG9C,QAAQ,EAAE,aAAa,EACvB,YAAY,EAAE,iBAAiB,EAC/B,QAAQ,EAAE,aAAa,EACvB,eAAe,EAAE,oBAAoB,EACrC,OAAO,EAAE,cAAc;IASlB,YAAY,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAI1E,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;CAG5C;AAKD;;;GAGG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAK1C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAEvD"}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* High-level storage API providing access to all storage operations.
|
||||
* Subclasses can extend this to add domain-specific stores.
|
||||
*/
|
||||
export class AppStorage {
|
||||
constructor(settings, providerKeys, sessions, customProviders, backend) {
|
||||
this.settings = settings;
|
||||
this.providerKeys = providerKeys;
|
||||
this.sessions = sessions;
|
||||
this.customProviders = customProviders;
|
||||
this.backend = backend;
|
||||
}
|
||||
async getQuotaInfo() {
|
||||
return this.backend.getQuotaInfo();
|
||||
}
|
||||
async requestPersistence() {
|
||||
return this.backend.requestPersistence();
|
||||
}
|
||||
}
|
||||
// Global instance management
|
||||
let globalAppStorage = null;
|
||||
/**
|
||||
* Get the global AppStorage instance.
|
||||
* Throws if not initialized.
|
||||
*/
|
||||
export function getAppStorage() {
|
||||
if (!globalAppStorage) {
|
||||
throw new Error("AppStorage not initialized. Call setAppStorage() first.");
|
||||
}
|
||||
return globalAppStorage;
|
||||
}
|
||||
/**
|
||||
* Set the global AppStorage instance.
|
||||
*/
|
||||
export function setAppStorage(storage) {
|
||||
globalAppStorage = storage;
|
||||
}
|
||||
//# sourceMappingURL=app-storage.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"app-storage.js","sourceRoot":"","sources":["../../src/storage/app-storage.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,OAAO,UAAU;IAOtB,YACC,QAAuB,EACvB,YAA+B,EAC/B,QAAuB,EACvB,eAAqC,EACrC,OAAuB;QAEvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,YAAY;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,kBAAkB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAC1C,CAAC;CACD;AAED,6BAA6B;AAC7B,IAAI,gBAAgB,GAAsB,IAAI,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC5B,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,gBAAgB,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAmB;IAChD,gBAAgB,GAAG,OAAO,CAAC;AAC5B,CAAC"}
|
||||
27
apps/macos/Sources/Clawdis/Resources/WebChat/storage/backends/indexeddb-storage-backend.d.ts
vendored
Normal file
27
apps/macos/Sources/Clawdis/Resources/WebChat/storage/backends/indexeddb-storage-backend.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { IndexedDBConfig, StorageBackend, StorageTransaction } from "../types.js";
|
||||
/**
|
||||
* IndexedDB implementation of StorageBackend.
|
||||
* Provides multi-store key-value storage with transactions and quota management.
|
||||
*/
|
||||
export declare class IndexedDBStorageBackend implements StorageBackend {
|
||||
private config;
|
||||
private dbPromise;
|
||||
constructor(config: IndexedDBConfig);
|
||||
private getDB;
|
||||
private promisifyRequest;
|
||||
get<T = unknown>(storeName: string, key: string): Promise<T | null>;
|
||||
set<T = unknown>(storeName: string, key: string, value: T): Promise<void>;
|
||||
delete(storeName: string, key: string): Promise<void>;
|
||||
keys(storeName: string, prefix?: string): Promise<string[]>;
|
||||
getAllFromIndex<T = unknown>(storeName: string, indexName: string, direction?: "asc" | "desc"): Promise<T[]>;
|
||||
clear(storeName: string): Promise<void>;
|
||||
has(storeName: string, key: string): Promise<boolean>;
|
||||
transaction<T>(storeNames: string[], mode: "readonly" | "readwrite", operation: (tx: StorageTransaction) => Promise<T>): Promise<T>;
|
||||
getQuotaInfo(): Promise<{
|
||||
usage: number;
|
||||
quota: number;
|
||||
percent: number;
|
||||
}>;
|
||||
requestPersistence(): Promise<boolean>;
|
||||
}
|
||||
//# sourceMappingURL=indexeddb-storage-backend.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"indexeddb-storage-backend.d.ts","sourceRoot":"","sources":["../../../src/storage/backends/indexeddb-storage-backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEvF;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,cAAc;IAGjD,OAAO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kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;CAM5C"}
|
||||
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* IndexedDB implementation of StorageBackend.
|
||||
* Provides multi-store key-value storage with transactions and quota management.
|
||||
*/
|
||||
export class IndexedDBStorageBackend {
|
||||
constructor(config) {
|
||||
this.config = config;
|
||||
this.dbPromise = null;
|
||||
}
|
||||
async getDB() {
|
||||
if (!this.dbPromise) {
|
||||
this.dbPromise = new Promise((resolve, reject) => {
|
||||
const request = indexedDB.open(this.config.dbName, this.config.version);
|
||||
request.onerror = () => reject(request.error);
|
||||
request.onsuccess = () => resolve(request.result);
|
||||
request.onupgradeneeded = (_event) => {
|
||||
const db = request.result;
|
||||
// Create object stores from config
|
||||
for (const storeConfig of this.config.stores) {
|
||||
if (!db.objectStoreNames.contains(storeConfig.name)) {
|
||||
const store = db.createObjectStore(storeConfig.name, {
|
||||
keyPath: storeConfig.keyPath,
|
||||
autoIncrement: storeConfig.autoIncrement,
|
||||
});
|
||||
// Create indices
|
||||
if (storeConfig.indices) {
|
||||
for (const indexConfig of storeConfig.indices) {
|
||||
store.createIndex(indexConfig.name, indexConfig.keyPath, {
|
||||
unique: indexConfig.unique,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
return this.dbPromise;
|
||||
}
|
||||
promisifyRequest(request) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.onsuccess = () => resolve(request.result);
|
||||
request.onerror = () => reject(request.error);
|
||||
});
|
||||
}
|
||||
async get(storeName, key) {
|
||||
const db = await this.getDB();
|
||||
const tx = db.transaction(storeName, "readonly");
|
||||
const store = tx.objectStore(storeName);
|
||||
const result = await this.promisifyRequest(store.get(key));
|
||||
return result ?? null;
|
||||
}
|
||||
async set(storeName, key, value) {
|
||||
const db = await this.getDB();
|
||||
const tx = db.transaction(storeName, "readwrite");
|
||||
const store = tx.objectStore(storeName);
|
||||
// If store has keyPath, only pass value (in-line key)
|
||||
// Otherwise pass both value and key (out-of-line key)
|
||||
if (store.keyPath) {
|
||||
await this.promisifyRequest(store.put(value));
|
||||
}
|
||||
else {
|
||||
await this.promisifyRequest(store.put(value, key));
|
||||
}
|
||||
}
|
||||
async delete(storeName, key) {
|
||||
const db = await this.getDB();
|
||||
const tx = db.transaction(storeName, "readwrite");
|
||||
const store = tx.objectStore(storeName);
|
||||
await this.promisifyRequest(store.delete(key));
|
||||
}
|
||||
async keys(storeName, prefix) {
|
||||
const db = await this.getDB();
|
||||
const tx = db.transaction(storeName, "readonly");
|
||||
const store = tx.objectStore(storeName);
|
||||
if (prefix) {
|
||||
// Use IDBKeyRange for efficient prefix filtering
|
||||
const range = IDBKeyRange.bound(prefix, prefix + "\uffff", false, false);
|
||||
const keys = await this.promisifyRequest(store.getAllKeys(range));
|
||||
return keys.map((k) => String(k));
|
||||
}
|
||||
else {
|
||||
const keys = await this.promisifyRequest(store.getAllKeys());
|
||||
return keys.map((k) => String(k));
|
||||
}
|
||||
}
|
||||
async getAllFromIndex(storeName, indexName, direction = "asc") {
|
||||
const db = await this.getDB();
|
||||
const tx = db.transaction(storeName, "readonly");
|
||||
const store = tx.objectStore(storeName);
|
||||
const index = store.index(indexName);
|
||||
return new Promise((resolve, reject) => {
|
||||
const results = [];
|
||||
const request = index.openCursor(null, direction === "desc" ? "prev" : "next");
|
||||
request.onsuccess = () => {
|
||||
const cursor = request.result;
|
||||
if (cursor) {
|
||||
results.push(cursor.value);
|
||||
cursor.continue();
|
||||
}
|
||||
else {
|
||||
resolve(results);
|
||||
}
|
||||
};
|
||||
request.onerror = () => reject(request.error);
|
||||
});
|
||||
}
|
||||
async clear(storeName) {
|
||||
const db = await this.getDB();
|
||||
const tx = db.transaction(storeName, "readwrite");
|
||||
const store = tx.objectStore(storeName);
|
||||
await this.promisifyRequest(store.clear());
|
||||
}
|
||||
async has(storeName, key) {
|
||||
const db = await this.getDB();
|
||||
const tx = db.transaction(storeName, "readonly");
|
||||
const store = tx.objectStore(storeName);
|
||||
const result = await this.promisifyRequest(store.getKey(key));
|
||||
return result !== undefined;
|
||||
}
|
||||
async transaction(storeNames, mode, operation) {
|
||||
const db = await this.getDB();
|
||||
const idbTx = db.transaction(storeNames, mode);
|
||||
const storageTx = {
|
||||
get: async (storeName, key) => {
|
||||
const store = idbTx.objectStore(storeName);
|
||||
const result = await this.promisifyRequest(store.get(key));
|
||||
return (result ?? null);
|
||||
},
|
||||
set: async (storeName, key, value) => {
|
||||
const store = idbTx.objectStore(storeName);
|
||||
// If store has keyPath, only pass value (in-line key)
|
||||
// Otherwise pass both value and key (out-of-line key)
|
||||
if (store.keyPath) {
|
||||
await this.promisifyRequest(store.put(value));
|
||||
}
|
||||
else {
|
||||
await this.promisifyRequest(store.put(value, key));
|
||||
}
|
||||
},
|
||||
delete: async (storeName, key) => {
|
||||
const store = idbTx.objectStore(storeName);
|
||||
await this.promisifyRequest(store.delete(key));
|
||||
},
|
||||
};
|
||||
return operation(storageTx);
|
||||
}
|
||||
async getQuotaInfo() {
|
||||
if (navigator.storage?.estimate) {
|
||||
const estimate = await navigator.storage.estimate();
|
||||
return {
|
||||
usage: estimate.usage || 0,
|
||||
quota: estimate.quota || 0,
|
||||
percent: estimate.quota ? ((estimate.usage || 0) / estimate.quota) * 100 : 0,
|
||||
};
|
||||
}
|
||||
return { usage: 0, quota: 0, percent: 0 };
|
||||
}
|
||||
async requestPersistence() {
|
||||
if (navigator.storage?.persist) {
|
||||
return await navigator.storage.persist();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=indexeddb-storage-backend.js.map
|
||||
File diff suppressed because one or more lines are too long
23
apps/macos/Sources/Clawdis/Resources/WebChat/storage/store.d.ts
vendored
Normal file
23
apps/macos/Sources/Clawdis/Resources/WebChat/storage/store.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { StorageBackend, StoreConfig } from "./types.js";
|
||||
/**
|
||||
* Base class for all storage stores.
|
||||
* Each store defines its IndexedDB schema and provides domain-specific methods.
|
||||
*/
|
||||
export declare abstract class Store {
|
||||
private backend;
|
||||
/**
|
||||
* Returns the IndexedDB configuration for this store.
|
||||
* Defines store name, key path, and indices.
|
||||
*/
|
||||
abstract getConfig(): StoreConfig;
|
||||
/**
|
||||
* Sets the storage backend. Called by AppStorage after backend creation.
|
||||
*/
|
||||
setBackend(backend: StorageBackend): void;
|
||||
/**
|
||||
* Gets the storage backend. Throws if backend not set.
|
||||
* Concrete stores must use this to access the backend.
|
||||
*/
|
||||
protected getBackend(): StorageBackend;
|
||||
}
|
||||
//# sourceMappingURL=store.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/storage/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D;;;GAGG;AACH,8BAAsB,KAAK;IAC1B,OAAO,CAAC,OAAO,CAA+B;IAE9C;;;OAGG;IACH,QAAQ,CAAC,SAAS,IAAI,WAAW;IAEjC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAIzC;;;OAGG;IACH,SAAS,CAAC,UAAU,IAAI,cAAc;CAMtC"}
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Base class for all storage stores.
|
||||
* Each store defines its IndexedDB schema and provides domain-specific methods.
|
||||
*/
|
||||
export class Store {
|
||||
constructor() {
|
||||
this.backend = null;
|
||||
}
|
||||
/**
|
||||
* Sets the storage backend. Called by AppStorage after backend creation.
|
||||
*/
|
||||
setBackend(backend) {
|
||||
this.backend = backend;
|
||||
}
|
||||
/**
|
||||
* Gets the storage backend. Throws if backend not set.
|
||||
* Concrete stores must use this to access the backend.
|
||||
*/
|
||||
getBackend() {
|
||||
if (!this.backend) {
|
||||
throw new Error(`Backend not set on ${this.constructor.name}`);
|
||||
}
|
||||
return this.backend;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=store.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/storage/store.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAgB,KAAK;IAA3B;QACS,YAAO,GAA0B,IAAI,CAAC;IAyB/C,CAAC;IAjBA;;OAEG;IACH,UAAU,CAAC,OAAuB;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED;;;OAGG;IACO,UAAU;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;CACD"}
|
||||
25
apps/macos/Sources/Clawdis/Resources/WebChat/storage/stores/custom-providers-store.d.ts
vendored
Normal file
25
apps/macos/Sources/Clawdis/Resources/WebChat/storage/stores/custom-providers-store.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { Model } from "@mariozechner/pi-ai";
|
||||
import { Store } from "../store.js";
|
||||
import type { StoreConfig } from "../types.js";
|
||||
export type AutoDiscoveryProviderType = "ollama" | "llama.cpp" | "vllm" | "lmstudio";
|
||||
export type CustomProviderType = AutoDiscoveryProviderType | "openai-completions" | "openai-responses" | "anthropic-messages";
|
||||
export interface CustomProvider {
|
||||
id: string;
|
||||
name: string;
|
||||
type: CustomProviderType;
|
||||
baseUrl: string;
|
||||
apiKey?: string;
|
||||
models?: Model<any>[];
|
||||
}
|
||||
/**
|
||||
* Store for custom LLM providers (auto-discovery servers + manual providers).
|
||||
*/
|
||||
export declare class CustomProvidersStore extends Store {
|
||||
getConfig(): StoreConfig;
|
||||
get(id: string): Promise<CustomProvider | null>;
|
||||
set(provider: CustomProvider): Promise<void>;
|
||||
delete(id: string): Promise<void>;
|
||||
getAll(): Promise<CustomProvider[]>;
|
||||
has(id: string): Promise<boolean>;
|
||||
}
|
||||
//# sourceMappingURL=custom-providers-store.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"custom-providers-store.d.ts","sourceRoot":"","sources":["../../../src/storage/stores/custom-providers-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU,CAAC;AAErF,MAAM,MAAM,kBAAkB,GAC3B,yBAAyB,GACzB,oBAAoB,GACpB,kBAAkB,GAClB,oBAAoB,CAAC;AAExB,MAAM,WAAW,cAAc;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAIhB,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC9C,SAAS,IAAI,WAAW;IAMlB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAI/C,GAAG,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjC,MAAM,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAYnC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAGvC"}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { Store } from "../store.js";
|
||||
/**
|
||||
* Store for custom LLM providers (auto-discovery servers + manual providers).
|
||||
*/
|
||||
export class CustomProvidersStore extends Store {
|
||||
getConfig() {
|
||||
return {
|
||||
name: "custom-providers",
|
||||
};
|
||||
}
|
||||
async get(id) {
|
||||
return this.getBackend().get("custom-providers", id);
|
||||
}
|
||||
async set(provider) {
|
||||
await this.getBackend().set("custom-providers", provider.id, provider);
|
||||
}
|
||||
async delete(id) {
|
||||
await this.getBackend().delete("custom-providers", id);
|
||||
}
|
||||
async getAll() {
|
||||
const keys = await this.getBackend().keys("custom-providers");
|
||||
const providers = [];
|
||||
for (const key of keys) {
|
||||
const provider = await this.get(key);
|
||||
if (provider) {
|
||||
providers.push(provider);
|
||||
}
|
||||
}
|
||||
return providers;
|
||||
}
|
||||
async has(id) {
|
||||
return this.getBackend().has("custom-providers", id);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=custom-providers-store.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"custom-providers-store.js","sourceRoot":"","sources":["../../../src/storage/stores/custom-providers-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAuBpC;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC9C,SAAS;QACR,OAAO;YACN,IAAI,EAAE,kBAAkB;SACxB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QACnB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,QAAwB;QACjC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IACxE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACtB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,MAAM;QACX,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC9D,MAAM,SAAS,GAAqB,EAAE,CAAC;QACvC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACrC,IAAI,QAAQ,EAAE,CAAC;gBACd,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1B,CAAC;QACF,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QACnB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;CACD"}
|
||||
14
apps/macos/Sources/Clawdis/Resources/WebChat/storage/stores/provider-keys-store.d.ts
vendored
Normal file
14
apps/macos/Sources/Clawdis/Resources/WebChat/storage/stores/provider-keys-store.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Store } from "../store.js";
|
||||
import type { StoreConfig } from "../types.js";
|
||||
/**
|
||||
* Store for LLM provider API keys (Anthropic, OpenAI, etc.).
|
||||
*/
|
||||
export declare class ProviderKeysStore extends Store {
|
||||
getConfig(): StoreConfig;
|
||||
get(provider: string): Promise<string | null>;
|
||||
set(provider: string, key: string): Promise<void>;
|
||||
delete(provider: string): Promise<void>;
|
||||
list(): Promise<string[]>;
|
||||
has(provider: string): Promise<boolean>;
|
||||
}
|
||||
//# sourceMappingURL=provider-keys-store.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-keys-store.d.ts","sourceRoot":"","sources":["../../../src/storage/stores/provider-keys-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC3C,SAAS,IAAI,WAAW;IAMlB,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAI7C,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjD,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIzB,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAG7C"}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Store } from "../store.js";
|
||||
/**
|
||||
* Store for LLM provider API keys (Anthropic, OpenAI, etc.).
|
||||
*/
|
||||
export class ProviderKeysStore extends Store {
|
||||
getConfig() {
|
||||
return {
|
||||
name: "provider-keys",
|
||||
};
|
||||
}
|
||||
async get(provider) {
|
||||
return this.getBackend().get("provider-keys", provider);
|
||||
}
|
||||
async set(provider, key) {
|
||||
await this.getBackend().set("provider-keys", provider, key);
|
||||
}
|
||||
async delete(provider) {
|
||||
await this.getBackend().delete("provider-keys", provider);
|
||||
}
|
||||
async list() {
|
||||
return this.getBackend().keys("provider-keys");
|
||||
}
|
||||
async has(provider) {
|
||||
return this.getBackend().has("provider-keys", provider);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provider-keys-store.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-keys-store.js","sourceRoot":"","sources":["../../../src/storage/stores/provider-keys-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC3C,SAAS;QACR,OAAO;YACN,IAAI,EAAE,eAAe;SACrB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,QAAgB;QACzB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,QAAgB,EAAE,GAAW;QACtC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,eAAe,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAgB;QAC5B,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,IAAI;QACT,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,QAAgB;QACzB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;CACD"}
|
||||
32
apps/macos/Sources/Clawdis/Resources/WebChat/storage/stores/sessions-store.d.ts
vendored
Normal file
32
apps/macos/Sources/Clawdis/Resources/WebChat/storage/stores/sessions-store.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import type { AgentState } from "../../agent/agent.js";
|
||||
import { Store } from "../store.js";
|
||||
import type { SessionData, SessionMetadata, StoreConfig } from "../types.js";
|
||||
/**
|
||||
* Store for chat sessions (data and metadata).
|
||||
* Uses two object stores: sessions (full data) and sessions-metadata (lightweight).
|
||||
*/
|
||||
export declare class SessionsStore extends Store {
|
||||
getConfig(): StoreConfig;
|
||||
/**
|
||||
* Additional config for sessions-metadata store.
|
||||
* Must be included when creating the backend.
|
||||
*/
|
||||
static getMetadataConfig(): StoreConfig;
|
||||
save(data: SessionData, metadata: SessionMetadata): Promise<void>;
|
||||
get(id: string): Promise<SessionData | null>;
|
||||
getMetadata(id: string): Promise<SessionMetadata | null>;
|
||||
getAllMetadata(): Promise<SessionMetadata[]>;
|
||||
delete(id: string): Promise<void>;
|
||||
deleteSession(id: string): Promise<void>;
|
||||
updateTitle(id: string, title: string): Promise<void>;
|
||||
getQuotaInfo(): Promise<{
|
||||
usage: number;
|
||||
quota: number;
|
||||
percent: number;
|
||||
}>;
|
||||
requestPersistence(): Promise<boolean>;
|
||||
saveSession(id: string, state: AgentState, metadata: SessionMetadata | undefined, title?: string): Promise<void>;
|
||||
loadSession(id: string): Promise<SessionData | null>;
|
||||
getLatestSessionId(): Promise<string | null>;
|
||||
}
|
||||
//# sourceMappingURL=sessions-store.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sessions-store.d.ts","sourceRoot":"","sources":["../../../src/storage/stores/sessions-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE7E;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACvC,SAAS,IAAI,WAAW;IAQxB;;;OAGG;IACH,MAAM,CAAC,iBAAiB,IAAI,WAAW;IAQjC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjE,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAI5C,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAIxD,cAAc,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAK5C,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQjC,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAerD,YAAY,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAI1E,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAKtC,WAAW,CAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,eAAe,GAAG,SAAS,EACrC,KAAK,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAgCV,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAIpD,kBAAkB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAQlD"}
|
||||
@@ -0,0 +1,112 @@
|
||||
import { Store } from "../store.js";
|
||||
/**
|
||||
* Store for chat sessions (data and metadata).
|
||||
* Uses two object stores: sessions (full data) and sessions-metadata (lightweight).
|
||||
*/
|
||||
export class SessionsStore extends Store {
|
||||
getConfig() {
|
||||
return {
|
||||
name: "sessions",
|
||||
keyPath: "id",
|
||||
indices: [{ name: "lastModified", keyPath: "lastModified" }],
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Additional config for sessions-metadata store.
|
||||
* Must be included when creating the backend.
|
||||
*/
|
||||
static getMetadataConfig() {
|
||||
return {
|
||||
name: "sessions-metadata",
|
||||
keyPath: "id",
|
||||
indices: [{ name: "lastModified", keyPath: "lastModified" }],
|
||||
};
|
||||
}
|
||||
async save(data, metadata) {
|
||||
await this.getBackend().transaction(["sessions", "sessions-metadata"], "readwrite", async (tx) => {
|
||||
await tx.set("sessions", data.id, data);
|
||||
await tx.set("sessions-metadata", metadata.id, metadata);
|
||||
});
|
||||
}
|
||||
async get(id) {
|
||||
return this.getBackend().get("sessions", id);
|
||||
}
|
||||
async getMetadata(id) {
|
||||
return this.getBackend().get("sessions-metadata", id);
|
||||
}
|
||||
async getAllMetadata() {
|
||||
// Use the lastModified index to get sessions sorted by most recent first
|
||||
return this.getBackend().getAllFromIndex("sessions-metadata", "lastModified", "desc");
|
||||
}
|
||||
async delete(id) {
|
||||
await this.getBackend().transaction(["sessions", "sessions-metadata"], "readwrite", async (tx) => {
|
||||
await tx.delete("sessions", id);
|
||||
await tx.delete("sessions-metadata", id);
|
||||
});
|
||||
}
|
||||
// Alias for backward compatibility
|
||||
async deleteSession(id) {
|
||||
return this.delete(id);
|
||||
}
|
||||
async updateTitle(id, title) {
|
||||
const metadata = await this.getMetadata(id);
|
||||
if (metadata) {
|
||||
metadata.title = title;
|
||||
await this.getBackend().set("sessions-metadata", id, metadata);
|
||||
}
|
||||
// Also update in full session data
|
||||
const data = await this.get(id);
|
||||
if (data) {
|
||||
data.title = title;
|
||||
await this.getBackend().set("sessions", id, data);
|
||||
}
|
||||
}
|
||||
async getQuotaInfo() {
|
||||
return this.getBackend().getQuotaInfo();
|
||||
}
|
||||
async requestPersistence() {
|
||||
return this.getBackend().requestPersistence();
|
||||
}
|
||||
// Alias methods for backward compatibility
|
||||
async saveSession(id, state, metadata, title) {
|
||||
// If metadata is provided, use it; otherwise create it from state
|
||||
const meta = metadata || {
|
||||
id,
|
||||
title: title || "",
|
||||
createdAt: new Date().toISOString(),
|
||||
lastModified: new Date().toISOString(),
|
||||
messageCount: state.messages?.length || 0,
|
||||
usage: {
|
||||
input: 0,
|
||||
output: 0,
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
||||
},
|
||||
thinkingLevel: state.thinkingLevel || "off",
|
||||
preview: "",
|
||||
};
|
||||
const data = {
|
||||
id,
|
||||
title: title || meta.title,
|
||||
model: state.model,
|
||||
thinkingLevel: state.thinkingLevel,
|
||||
messages: state.messages || [],
|
||||
createdAt: meta.createdAt,
|
||||
lastModified: new Date().toISOString(),
|
||||
};
|
||||
await this.save(data, meta);
|
||||
}
|
||||
async loadSession(id) {
|
||||
return this.get(id);
|
||||
}
|
||||
async getLatestSessionId() {
|
||||
const allMetadata = await this.getAllMetadata();
|
||||
if (allMetadata.length === 0)
|
||||
return null;
|
||||
// Sort by lastModified descending
|
||||
allMetadata.sort((a, b) => b.lastModified.localeCompare(a.lastModified));
|
||||
return allMetadata[0].id;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=sessions-store.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sessions-store.js","sourceRoot":"","sources":["../../../src/storage/stores/sessions-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACvC,SAAS;QACR,OAAO;YACN,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;SAC5D,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,iBAAiB;QACvB,OAAO;YACN,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;SAC5D,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAiB,EAAE,QAAyB;QACtD,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,WAAW,CAAC,CAAC,UAAU,EAAE,mBAAmB,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;YAChG,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KAAK,EAAE,CAAC,EAAE;aACpE;YACD,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,KAAK;YAC3C,OAAO,EAAE,EAAE;SACX,CAAC;QAEF,MAAM,IAAI,GAAgB;YACzB,EAAE;YACF,KAAK,EAAE,KAAK,IAAI,IAAI,CAAC,KAAK;YAC1B,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,EAAE;YAC9B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACtC,CAAC;QAEF,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,EAAU;QAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,kBAAkB;QACvB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAChD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAE1C,kCAAkC;QAClC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;QACzE,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1B,CAAC;CACD"}
|
||||
14
apps/macos/Sources/Clawdis/Resources/WebChat/storage/stores/settings-store.d.ts
vendored
Normal file
14
apps/macos/Sources/Clawdis/Resources/WebChat/storage/stores/settings-store.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Store } from "../store.js";
|
||||
import type { StoreConfig } from "../types.js";
|
||||
/**
|
||||
* Store for application settings (theme, proxy config, etc.).
|
||||
*/
|
||||
export declare class SettingsStore extends Store {
|
||||
getConfig(): StoreConfig;
|
||||
get<T>(key: string): Promise<T | null>;
|
||||
set<T>(key: string, value: T): Promise<void>;
|
||||
delete(key: string): Promise<void>;
|
||||
list(): Promise<string[]>;
|
||||
clear(): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=settings-store.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"settings-store.d.ts","sourceRoot":"","sources":["../../../src/storage/stores/settings-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACvC,SAAS,IAAI,WAAW;IAOlB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAItC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Store } from "../store.js";
|
||||
/**
|
||||
* Store for application settings (theme, proxy config, etc.).
|
||||
*/
|
||||
export class SettingsStore extends Store {
|
||||
getConfig() {
|
||||
return {
|
||||
name: "settings",
|
||||
// No keyPath - uses out-of-line keys
|
||||
};
|
||||
}
|
||||
async get(key) {
|
||||
return this.getBackend().get("settings", key);
|
||||
}
|
||||
async set(key, value) {
|
||||
await this.getBackend().set("settings", key, value);
|
||||
}
|
||||
async delete(key) {
|
||||
await this.getBackend().delete("settings", key);
|
||||
}
|
||||
async list() {
|
||||
return this.getBackend().keys("settings");
|
||||
}
|
||||
async clear() {
|
||||
await this.getBackend().clear("settings");
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=settings-store.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"settings-store.js","sourceRoot":"","sources":["../../../src/storage/stores/settings-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACvC,SAAS;QACR,OAAO;YACN,IAAI,EAAE,UAAU;YAChB,qCAAqC;SACrC,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAI,GAAW;QACvB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,GAAG,CAAI,GAAW,EAAE,KAAQ;QACjC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACvB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,IAAI;QACT,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,KAAK;QACV,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;CACD"}
|
||||
175
apps/macos/Sources/Clawdis/Resources/WebChat/storage/types.d.ts
vendored
Normal file
175
apps/macos/Sources/Clawdis/Resources/WebChat/storage/types.d.ts
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
import type { Model } from "@mariozechner/pi-ai";
|
||||
import type { ThinkingLevel } from "../agent/agent.js";
|
||||
import type { AppMessage } from "../components/Messages.js";
|
||||
/**
|
||||
* Transaction interface for atomic operations across stores.
|
||||
*/
|
||||
export interface StorageTransaction {
|
||||
/**
|
||||
* Get a value by key from a specific store.
|
||||
*/
|
||||
get<T = unknown>(storeName: string, key: string): Promise<T | null>;
|
||||
/**
|
||||
* Set a value for a key in a specific store.
|
||||
*/
|
||||
set<T = unknown>(storeName: string, key: string, value: T): Promise<void>;
|
||||
/**
|
||||
* Delete a key from a specific store.
|
||||
*/
|
||||
delete(storeName: string, key: string): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Base interface for all storage backends.
|
||||
* Multi-store key-value storage abstraction that can be implemented
|
||||
* by IndexedDB, remote APIs, or any other multi-collection storage system.
|
||||
*/
|
||||
export interface StorageBackend {
|
||||
/**
|
||||
* Get a value by key from a specific store. Returns null if key doesn't exist.
|
||||
*/
|
||||
get<T = unknown>(storeName: string, key: string): Promise<T | null>;
|
||||
/**
|
||||
* Set a value for a key in a specific store.
|
||||
*/
|
||||
set<T = unknown>(storeName: string, key: string, value: T): Promise<void>;
|
||||
/**
|
||||
* Delete a key from a specific store.
|
||||
*/
|
||||
delete(storeName: string, key: string): Promise<void>;
|
||||
/**
|
||||
* Get all keys from a specific store, optionally filtered by prefix.
|
||||
*/
|
||||
keys(storeName: string, prefix?: string): Promise<string[]>;
|
||||
/**
|
||||
* Get all values from a specific store, ordered by an index.
|
||||
* @param storeName - The store to query
|
||||
* @param indexName - The index to use for ordering
|
||||
* @param direction - Sort direction ("asc" or "desc")
|
||||
*/
|
||||
getAllFromIndex<T = unknown>(storeName: string, indexName: string, direction?: "asc" | "desc"): Promise<T[]>;
|
||||
/**
|
||||
* Clear all data from a specific store.
|
||||
*/
|
||||
clear(storeName: string): Promise<void>;
|
||||
/**
|
||||
* Check if a key exists in a specific store.
|
||||
*/
|
||||
has(storeName: string, key: string): Promise<boolean>;
|
||||
/**
|
||||
* Execute atomic operations across multiple stores.
|
||||
*/
|
||||
transaction<T>(storeNames: string[], mode: "readonly" | "readwrite", operation: (tx: StorageTransaction) => Promise<T>): Promise<T>;
|
||||
/**
|
||||
* Get storage quota information.
|
||||
* Used for warning users when approaching limits.
|
||||
*/
|
||||
getQuotaInfo(): Promise<{
|
||||
usage: number;
|
||||
quota: number;
|
||||
percent: number;
|
||||
}>;
|
||||
/**
|
||||
* Request persistent storage (prevents eviction).
|
||||
* Returns true if granted, false otherwise.
|
||||
*/
|
||||
requestPersistence(): Promise<boolean>;
|
||||
}
|
||||
/**
|
||||
* Lightweight session metadata for listing and searching.
|
||||
* Stored separately from full session data for performance.
|
||||
*/
|
||||
export interface SessionMetadata {
|
||||
/** Unique session identifier (UUID v4) */
|
||||
id: string;
|
||||
/** User-defined title or auto-generated from first message */
|
||||
title: string;
|
||||
/** ISO 8601 UTC timestamp of creation */
|
||||
createdAt: string;
|
||||
/** ISO 8601 UTC timestamp of last modification */
|
||||
lastModified: string;
|
||||
/** Total number of messages (user + assistant + tool results) */
|
||||
messageCount: number;
|
||||
/** Cumulative usage statistics */
|
||||
usage: {
|
||||
/** Total input tokens */
|
||||
input: number;
|
||||
/** Total output tokens */
|
||||
output: number;
|
||||
/** Total cache read tokens */
|
||||
cacheRead: number;
|
||||
/** Total cache write tokens */
|
||||
cacheWrite: number;
|
||||
/** Total cost breakdown */
|
||||
cost: {
|
||||
input: number;
|
||||
output: number;
|
||||
cacheRead: number;
|
||||
cacheWrite: number;
|
||||
total: number;
|
||||
};
|
||||
};
|
||||
/** Last used thinking level */
|
||||
thinkingLevel: ThinkingLevel;
|
||||
/**
|
||||
* Preview text for search and display.
|
||||
* First 2KB of conversation text (user + assistant messages in sequence).
|
||||
* Tool calls and tool results are excluded.
|
||||
*/
|
||||
preview: string;
|
||||
}
|
||||
/**
|
||||
* Full session data including all messages.
|
||||
* Only loaded when user opens a specific session.
|
||||
*/
|
||||
export interface SessionData {
|
||||
/** Unique session identifier (UUID v4) */
|
||||
id: string;
|
||||
/** User-defined title or auto-generated from first message */
|
||||
title: string;
|
||||
/** Last selected model */
|
||||
model: Model<any>;
|
||||
/** Last selected thinking level */
|
||||
thinkingLevel: ThinkingLevel;
|
||||
/** Full conversation history (with attachments inline) */
|
||||
messages: AppMessage[];
|
||||
/** ISO 8601 UTC timestamp of creation */
|
||||
createdAt: string;
|
||||
/** ISO 8601 UTC timestamp of last modification */
|
||||
lastModified: string;
|
||||
}
|
||||
/**
|
||||
* Configuration for IndexedDB backend.
|
||||
*/
|
||||
export interface IndexedDBConfig {
|
||||
/** Database name */
|
||||
dbName: string;
|
||||
/** Database version */
|
||||
version: number;
|
||||
/** Object stores to create */
|
||||
stores: StoreConfig[];
|
||||
}
|
||||
/**
|
||||
* Configuration for an IndexedDB object store.
|
||||
*/
|
||||
export interface StoreConfig {
|
||||
/** Store name */
|
||||
name: string;
|
||||
/** Key path (optional, for auto-extracting keys from objects) */
|
||||
keyPath?: string;
|
||||
/** Auto-increment keys (optional) */
|
||||
autoIncrement?: boolean;
|
||||
/** Indices to create on this store */
|
||||
indices?: IndexConfig[];
|
||||
}
|
||||
/**
|
||||
* Configuration for an IndexedDB index.
|
||||
*/
|
||||
export interface IndexConfig {
|
||||
/** Index name */
|
||||
name: string;
|
||||
/** Key path to index on */
|
||||
keyPath: string;
|
||||
/** Unique constraint (optional) */
|
||||
unique?: boolean;
|
||||
}
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/storage/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,SAAS,EA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;IAE7B;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B,0CAA0C;IAC1C,EAAE,EAAE,MAAM,CAAC;IAEX,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IAEd,0BAA0B;IAC1B,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAElB,mCAAmC;IACnC,aAAa,EAAE,aAAa,CAAC;IAE7B,0DAA0D;IAC1D,QAAQ,EAAE,UAAU,EAAE,CAAC;IAEvB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAElB,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,oBAAoB;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,MAAM,EAAE,WAAW,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sCAAsC;IACtC,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB"}
|
||||
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=types.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/storage/types.ts"],"names":[],"mappings":""}
|
||||
Reference in New Issue
Block a user