feat: initial Lam Agent extension (#1)

This commit was merged in pull request #1.
This commit is contained in:
2026-10-03 20:32:40 +00:00
parent 1d39aabb50
commit 8b507e7953
36 changed files with 7136 additions and 2 deletions
+48
View File
@@ -0,0 +1,48 @@
/**
* Vitest stub for `@vicinae/api`.
*
* The real package talks to the Vicinae runtime over JSON-RPC, which does not
* exist under test. `vitest.config.ts` aliases the package here.
*
* `LocalStorage` is backed by a real in-memory map rather than being a set of
* no-op spies, so the session store's read-after-write behaviour is actually
* exercised instead of being mocked into false confidence.
*/
type StorageValue = string | number | boolean;
const memory = new Map<string, StorageValue>();
export const LocalStorage = {
async getItem<T extends StorageValue>(key: string): Promise<T | undefined> {
return memory.get(key) as T | undefined;
},
async setItem(key: string, value: StorageValue): Promise<void> {
memory.set(key, value);
},
async removeItem(key: string): Promise<void> {
memory.delete(key);
},
async allItems(): Promise<Record<string, StorageValue>> {
return Object.fromEntries(memory);
},
async clear(): Promise<void> {
memory.clear();
},
};
/** Test-only helper: wipes the fake store between cases. */
export function __resetLocalStorage(): void {
memory.clear();
}
/** Returns whatever the test sets on the override, otherwise an empty object. */
let preferenceOverride: Record<string, unknown> = {};
export function __setPreferenceValues(values: Record<string, unknown>): void {
preferenceOverride = values;
}
export function getPreferenceValues<T = Record<string, unknown>>(): T {
return preferenceOverride as T;
}