+20
-14
@@ -308,3 +308,4 @@ import { createRequire } from "node:module"; | ||
| // src/utils/store.ts | ||
| import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, existsSync as existsSync2, mkdirSync as mkdirSync2 } from "fs"; | ||
| import { access, mkdir, readdir as readdir2, readFile as readFile2, writeFile } from "fs/promises"; | ||
| import { mkdirSync as mkdirSync2 } from "fs"; | ||
| import { join as join3, resolve } from "path"; | ||
@@ -327,17 +328,22 @@ | ||
| const memory = { | ||
| read(name) { | ||
| async read(name) { | ||
| const fullPath = safeJoin(memoryDir, name); | ||
| if (!fullPath || !existsSync2(fullPath)) | ||
| if (!fullPath) | ||
| return null; | ||
| return readFileSync2(fullPath, "utf-8"); | ||
| try { | ||
| await access(fullPath); | ||
| return await readFile2(fullPath, "utf-8"); | ||
| } catch { | ||
| return null; | ||
| } | ||
| }, | ||
| write(name, content) { | ||
| async write(name, content) { | ||
| const fullPath = safeJoin(memoryDir, name); | ||
| if (!fullPath) | ||
| throw new Error("Invalid memory path"); | ||
| mkdirSync2(join3(fullPath, ".."), { recursive: true }); | ||
| writeFileSync2(fullPath, content, "utf-8"); | ||
| await mkdir(join3(fullPath, ".."), { recursive: true }); | ||
| await writeFile(fullPath, content, "utf-8"); | ||
| }, | ||
| list() { | ||
| return readdirRecursive(memoryDir).map((f) => f.slice(memoryDir.length + 1)); | ||
| async list() { | ||
| return readdirRecursive(memoryDir).then((files) => files.map((f) => f.slice(memoryDir.length + 1))); | ||
| } | ||
@@ -365,9 +371,9 @@ }; | ||
| } | ||
| function readdirRecursive(dir) { | ||
| const { readdirSync: readdirSync2, statSync } = __require("fs"); | ||
| const entries = readdirSync2(dir, { withFileTypes: true }); | ||
| return entries.flatMap((e) => { | ||
| async function readdirRecursive(dir) { | ||
| const entries = await readdir2(dir, { withFileTypes: true }); | ||
| const results = await Promise.all(entries.map(async (e) => { | ||
| const full = join3(dir, e.name); | ||
| return e.isDirectory() ? readdirRecursive(full) : [full]; | ||
| }); | ||
| })); | ||
| return results.flat(); | ||
| } | ||
@@ -374,0 +380,0 @@ export { |
| import type { Session } from "./session"; | ||
| import { type SessionStoreOptions } from "./session"; | ||
| export interface MemoryStore { | ||
| read(name: string): string | null; | ||
| write(name: string, content: string): void; | ||
| list(): string[]; | ||
| read(name: string): string | null | Promise<string | null>; | ||
| write(name: string, content: string): void | Promise<void>; | ||
| list(): string[] | Promise<string[]>; | ||
| } | ||
@@ -8,0 +8,0 @@ export interface SessionStore { |
+1
-1
| { | ||
| "name": "@ridit/ai", | ||
| "version": "0.1.7", | ||
| "version": "0.1.81", | ||
| "description": "Your agents, in minutes.", | ||
@@ -5,0 +5,0 @@ "author": "Ridit Jangra <riditjangra09@gmail.com> (https://ridit.space)", |
-1
| API_KEY=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 |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
3414063
098210
0.01%49
-2%6
20%