+1
| API_KEY=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 |
| export declare const memoryRead: { | ||
| description: string; | ||
| prompt: string; | ||
| }; | ||
| export declare const memoryWrite: { | ||
| description: string; | ||
| prompt: string; | ||
| }; | ||
| export declare const memoryEdit: { | ||
| description: string; | ||
| prompt: string; | ||
| }; | ||
| export declare const memoryList: { | ||
| description: string; | ||
| prompt: string; | ||
| }; |
| import type { Store } from "../../utils/store"; | ||
| export declare function createMemoryTools(store: Store): { | ||
| MemoryReadTool: import("ai").Tool<{ | ||
| name: string; | ||
| }, { | ||
| success: boolean; | ||
| error: string; | ||
| content?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| content: string; | ||
| error?: undefined; | ||
| }>; | ||
| MemoryWriteTool: import("ai").Tool<{ | ||
| name: string; | ||
| content: string; | ||
| }, { | ||
| success: boolean; | ||
| message: string; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| message?: undefined; | ||
| }>; | ||
| MemoryEditTool: import("ai").Tool<{ | ||
| name: string; | ||
| old_string: string; | ||
| new_string: string; | ||
| }, { | ||
| success: boolean; | ||
| error: string; | ||
| message?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| message: string; | ||
| error?: undefined; | ||
| }>; | ||
| MemoryListTool: import("ai").Tool<Record<string, never>, { | ||
| success: boolean; | ||
| files: string[]; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| files?: undefined; | ||
| }>; | ||
| }; |
+0
-1
| export { runLLM } from "./utils/llm"; | ||
| export { getModel } from "./utils/model"; | ||
| export { buildProvider, type ProviderConfig, type ProviderType, } from "./utils/providers"; | ||
| export { createMode, agentMode, chatMode } from "./utils/mode"; | ||
| export { createClient } from "./utils/client"; |
| export { runLLM } from "../utils/llm"; | ||
| export { getModel } from "../utils/model"; | ||
| export { buildProvider, type ProviderConfig, type ProviderType, } from "../utils/providers"; | ||
| export { createMode, agentMode, chatMode } from "../utils/mode"; | ||
| export { createClient } from "../utils/client"; |
@@ -1,1 +0,2 @@ | ||
| export { BashTool, FileEditTool, FileReadTool, FileWriteTool, GlobTool, GrepTool, MemoryEditTool, MemoryReadTool, MemoryWriteTool, RecallTool, ThinkTool, } from "../tools/index"; | ||
| export { BashTool, FileEditTool, FileReadTool, FileWriteTool, GlobTool, GrepTool, RecallTool, ThinkTool, } from "../tools/index"; | ||
| export { createMemoryTools } from "../tools/Memory/tools"; |
@@ -5,3 +5,1 @@ export { createSession, listSessions, loadMemoryIntoSession, loadSession, saveSession, type Session, } from "../utils/session"; | ||
| export { type Store, createFileStore, createStore } from "../utils/store"; | ||
| export { createMode, agentMode, chatMode } from "../utils/mode"; | ||
| export type { Mode } from "../types"; |
+2
-1
@@ -1,1 +0,2 @@ | ||
| export { BashTool, FileEditTool, FileReadTool, FileWriteTool, GlobTool, GrepTool, MemoryEditTool, MemoryReadTool, MemoryWriteTool, RecallTool, ThinkTool, } from "./tools/index"; | ||
| export { BashTool, FileEditTool, FileReadTool, FileWriteTool, GlobTool, GrepTool, RecallTool, ThinkTool, } from "./tools/index"; | ||
| export { createMemoryTools } from "./tools/Memory/tools"; |
@@ -7,6 +7,3 @@ export { BashTool } from "./BashTool/tool"; | ||
| export { GrepTool } from "./GrepTool/tool"; | ||
| export { MemoryEditTool } from "./MemoryEditTool/tool"; | ||
| export { MemoryReadTool } from "./MemoryReadTool/tool"; | ||
| export { MemoryWriteTool } from "./MemoryWriteTool/tool"; | ||
| export { RecallTool } from "./RecallTool/tool"; | ||
| export { ThinkTool } from "./ThinkTool/tool"; |
+1
-5
| import type { LanguageModel, ToolSet } from "ai"; | ||
| import type { Session } from "./utils/session"; | ||
| import type { Store } from "./utils/store"; | ||
| export type Mode = { | ||
| name: string; | ||
| tools: ToolSet; | ||
| }; | ||
| export type ChatMessage = { | ||
@@ -53,3 +49,3 @@ id: string; | ||
| system?: string; | ||
| mode?: Mode; | ||
| tools?: ToolSet; | ||
| session?: Session; | ||
@@ -56,0 +52,0 @@ prompt: string; |
+0
-2
@@ -5,3 +5,1 @@ export { createSession, listSessions, loadMemoryIntoSession, loadSession, saveSession, type Session, } from "./utils/session"; | ||
| export { type Store, createFileStore, createStore } from "./utils/store"; | ||
| export { createMode, agentMode, chatMode } from "./utils/mode"; | ||
| export type { Mode } from "../types"; |
@@ -1,11 +0,10 @@ | ||
| import type { LanguageModel } from "ai"; | ||
| import type { LanguageModel, ToolSet } from "ai"; | ||
| import type { Store } from "./store"; | ||
| import type { Mode } from "../types"; | ||
| import { type RunLLMOptions } from "./llm"; | ||
| export declare function createClient({ provider, store, mode, }: { | ||
| export declare function createClient({ provider, store, tools, }: { | ||
| provider: LanguageModel; | ||
| store?: Store; | ||
| mode?: Mode; | ||
| tools?: ToolSet; | ||
| }): { | ||
| run: (opts: Omit<RunLLMOptions, "provider" | "sessionStore" | "mode">) => Promise<{ | ||
| run: (opts: Omit<RunLLMOptions, "provider" | "sessionStore">) => Promise<{ | ||
| text: string; | ||
@@ -12,0 +11,0 @@ session: import("./session").Session; |
@@ -7,8 +7,8 @@ import { type Session } from "./session"; | ||
| sessionId?: string; | ||
| sessionStore?: Store; | ||
| store?: Store; | ||
| memoryContent?: string; | ||
| }; | ||
| export declare function runLLM({ system, mode, session, sessionStore, sessionId, memoryContent, prompt, onToolCall, onToolResult, abortSignal, steps, provider, }: RunLLMOptions): Promise<{ | ||
| export declare function runLLM({ system, tools, session, store, sessionId, memoryContent, prompt, onToolCall, onToolResult, abortSignal, steps, provider, }: RunLLMOptions): Promise<{ | ||
| text: string; | ||
| session: Session; | ||
| }>; |
| import type { LanguageModel } from "ai"; | ||
| export type ProviderType = "groq" | "openai" | "anthropic" | "ollama" | "openrouter" | "google"; | ||
| export type ProviderType = "groq" | "openai" | "anthropic" | "ollama" | "openrouter" | "google" | "hackclub"; | ||
| export type ProviderConfig = { | ||
@@ -4,0 +4,0 @@ provider: ProviderType; |
+22
-14
| 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[]; | ||
| } | ||
| export interface SessionStore { | ||
| save: (session: Session) => void | Promise<void>; | ||
| load: (id: string) => Session | Promise<Session | null> | null; | ||
| list: () => Session[] | Promise<Session[]>; | ||
| } | ||
| export declare abstract class Store { | ||
| abstract save(session: Session): void; | ||
| abstract load(id: string): Session | null; | ||
| abstract list(): Session[]; | ||
| abstract session: SessionStore; | ||
| abstract memory: MemoryStore; | ||
| } | ||
| export declare function createStore({ list, load, save, }: { | ||
| save: (session: Session) => void; | ||
| load: (id: string) => Session | null; | ||
| list: () => Session[]; | ||
| export declare function createStore({ session, memory, }: { | ||
| session: SessionStore; | ||
| memory: MemoryStore; | ||
| }): { | ||
| save(session: Session): void; | ||
| load(id: string): Session | null; | ||
| list(): Session[]; | ||
| memory: MemoryStore; | ||
| session: SessionStore; | ||
| }; | ||
| export declare function createFileStore(options: SessionStoreOptions): { | ||
| save(session: Session): void; | ||
| load(id: string): Session | null; | ||
| list(): Session[]; | ||
| export declare function createFileStore(options: SessionStoreOptions & { | ||
| memoryDir?: string; | ||
| }): { | ||
| memory: MemoryStore; | ||
| session: SessionStore; | ||
| }; |
+1
-1
| { | ||
| "name": "@ridit/ai", | ||
| "version": "0.1.6", | ||
| "version": "0.1.7", | ||
| "description": "Your agents, in minutes.", | ||
@@ -5,0 +5,0 @@ "author": "Ridit Jangra <riditjangra09@gmail.com> (https://ridit.space)", |
+37
-6
@@ -106,3 +106,5 @@ # @ridit/ai | ||
| ```typescript | ||
| const storage = { | ||
| import { createStore } from "@ridit/ai/utils"; | ||
| const store = createStore({ | ||
| async save(session) { | ||
@@ -118,5 +120,5 @@ localStorage.setItem(session.id, JSON.stringify(session)); | ||
| }, | ||
| }; | ||
| }); | ||
| const { text, session } = await runLLM({ prompt: "hi", provider, storage }); | ||
| const { text, session } = await runLLM({ prompt: "hi", provider, store }); | ||
| ``` | ||
@@ -139,5 +141,2 @@ | ||
| ThinkTool, // internal reasoning step | ||
| MemoryReadTool, | ||
| MemoryWriteTool, | ||
| MemoryEditTool, | ||
| RecallTool, // semantic memory recall | ||
@@ -147,2 +146,13 @@ } from "@ridit/ai/tools"; | ||
| ## Memory tools | ||
| Memory tools need a store to store your memory. | ||
| ```typescript | ||
| import { createMemoryTools } from "@ridit/ai/tools"; | ||
| const { MemoryReadTool, MemoryWriteTool, MemoryEditTool } = | ||
| createMemoryTools(store); // your store | ||
| ``` | ||
| Create yours too! | ||
@@ -168,2 +178,23 @@ | ||
| ## client | ||
| create client 1 time, run as many times as your want without configuring multiple times. | ||
| ```typescript | ||
| const provider = buildProvider({ | ||
| model: "openai/gpt-oss-120b", | ||
| provider: "groq", | ||
| apiKey: "...", | ||
| }); | ||
| const client = createClient({ provider, tools: {} }); // tools is to set a global set of tools | ||
| const text = await client.run({ | ||
| prompt: "hey!", | ||
| tools: { FileReadTool, FileWriteTool }, // override global tools | ||
| }); | ||
| console.log(text); | ||
| ``` | ||
| --- | ||
@@ -170,0 +201,0 @@ |
| export declare const DESCRIPTION = "Edit a specific section of a persistent memory file."; | ||
| export declare const PROMPT = "Updates a specific part of a memory file without rewriting the whole thing.\n\nUse this to:\n- Update a preference that changed\n- Fix incorrect information\n- Append or modify a specific section\n\nPrefer this over MemoryWriteTool when only a small part needs to change."; |
| export declare const MemoryEditTool: import("ai").Tool<{ | ||
| name: string; | ||
| old_string: string; | ||
| new_string: string; | ||
| }, { | ||
| success: boolean; | ||
| message: string; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| message?: undefined; | ||
| }>; |
| export declare const DESCRIPTION = "Read a persistent memory file."; | ||
| export declare const PROMPT = "Reads memory to recall information from past sessions.\n\nUse this at the start of a session to load context about:\n- User preferences\n- Project conventions\n- Previously stored information\n\nIf the user says something that you don't know read the memory to find out more about the specific thing.\nEven if not found in memory tell the user you don't know about it or tell them to tell you the thing."; |
| export declare const MemoryReadTool: import("ai").Tool<{ | ||
| name: string; | ||
| }, { | ||
| success: boolean; | ||
| content: string; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| content?: undefined; | ||
| }>; |
| export declare const DESCRIPTION = "Read a persistent memory file."; | ||
| export declare const PROMPT = "Reads memory to recall information from past sessions.\n\nUse this when the user references something you don't recognize or remember.\nPass the name of the memory file you want to read.\nIf unsure what file to read, pass \"list\" to see all available memory files.\nEven if not found in memory, tell the user you don't know or ask them to tell you."; |
| export declare const MemoryWriteTool: import("ai").Tool<{ | ||
| content: string; | ||
| name: string; | ||
| }, { | ||
| success: boolean; | ||
| message: string; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| message?: undefined; | ||
| }>; |
| import type { ToolSet } from "ai"; | ||
| import type { Mode } from "../types"; | ||
| export declare function createMode(name: string, tools: ToolSet): Mode; | ||
| export declare const chatMode: Mode; | ||
| export declare const agentMode: Mode; |
| export declare const agentTools: { | ||
| FileReadTool: import("ai").Tool<{ | ||
| path: string; | ||
| line_start?: number | undefined; | ||
| line_end?: number | undefined; | ||
| }, { | ||
| success: boolean; | ||
| content: string; | ||
| totalLines: number; | ||
| error?: undefined; | ||
| suggestion?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| suggestion: string | undefined; | ||
| content?: undefined; | ||
| totalLines?: undefined; | ||
| }>; | ||
| FileWriteTool: import("ai").Tool<{ | ||
| path: string; | ||
| content: string; | ||
| }, { | ||
| success: boolean; | ||
| path: string; | ||
| content: string; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| path?: undefined; | ||
| content?: undefined; | ||
| }>; | ||
| FileEditTool: import("ai").Tool<{ | ||
| path: string; | ||
| old_string: string; | ||
| new_string: string; | ||
| }, { | ||
| success: boolean; | ||
| error: string; | ||
| path?: undefined; | ||
| patch?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| path: string; | ||
| patch: string; | ||
| error?: undefined; | ||
| }>; | ||
| GrepTool: import("ai").Tool<{ | ||
| pattern: string; | ||
| caseInsensitive: boolean; | ||
| path?: string | undefined; | ||
| include?: string | undefined; | ||
| }, { | ||
| success: boolean; | ||
| matches: never[]; | ||
| message: string; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| matches: import("./ripgrep").GrepMatch[]; | ||
| message?: undefined; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| matches?: undefined; | ||
| message?: undefined; | ||
| }>; | ||
| BashTool: import("ai").Tool<{ | ||
| command: string; | ||
| timeout?: number | undefined; | ||
| }, { | ||
| success: boolean; | ||
| error: string; | ||
| output?: undefined; | ||
| truncated?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| output: string; | ||
| truncated: boolean; | ||
| error?: undefined; | ||
| }>; | ||
| MemoryReadTool: import("ai").Tool<{ | ||
| name: string; | ||
| }, { | ||
| success: boolean; | ||
| content: string; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| content?: undefined; | ||
| }>; | ||
| MemoryWriteTool: import("ai").Tool<{ | ||
| content: string; | ||
| name: string; | ||
| }, { | ||
| success: boolean; | ||
| message: string; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| message?: undefined; | ||
| }>; | ||
| MemoryEditTool: import("ai").Tool<{ | ||
| name: string; | ||
| old_string: string; | ||
| new_string: string; | ||
| }, { | ||
| success: boolean; | ||
| message: string; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| message?: undefined; | ||
| }>; | ||
| ThinkTool: import("ai").Tool<{ | ||
| thought: string; | ||
| }, { | ||
| success: boolean; | ||
| thought: string; | ||
| }>; | ||
| GlobTool: import("ai").Tool<{ | ||
| pattern: string; | ||
| path?: string | undefined; | ||
| }, { | ||
| success: boolean; | ||
| files: string[]; | ||
| numFiles: number; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| files?: undefined; | ||
| numFiles?: undefined; | ||
| }>; | ||
| RecallTool: import("ai").Tool<{ | ||
| query: string; | ||
| max_results: number; | ||
| }, {}>; | ||
| }; | ||
| export declare const subagentTools: { | ||
| FileReadTool: import("ai").Tool<{ | ||
| path: string; | ||
| line_start?: number | undefined; | ||
| line_end?: number | undefined; | ||
| }, { | ||
| success: boolean; | ||
| content: string; | ||
| totalLines: number; | ||
| error?: undefined; | ||
| suggestion?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| suggestion: string | undefined; | ||
| content?: undefined; | ||
| totalLines?: undefined; | ||
| }>; | ||
| FileWriteTool: import("ai").Tool<{ | ||
| path: string; | ||
| content: string; | ||
| }, { | ||
| success: boolean; | ||
| path: string; | ||
| content: string; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| path?: undefined; | ||
| content?: undefined; | ||
| }>; | ||
| FileEditTool: import("ai").Tool<{ | ||
| path: string; | ||
| old_string: string; | ||
| new_string: string; | ||
| }, { | ||
| success: boolean; | ||
| error: string; | ||
| path?: undefined; | ||
| patch?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| path: string; | ||
| patch: string; | ||
| error?: undefined; | ||
| }>; | ||
| BashTool: import("ai").Tool<{ | ||
| command: string; | ||
| timeout?: number | undefined; | ||
| }, { | ||
| success: boolean; | ||
| error: string; | ||
| output?: undefined; | ||
| truncated?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| output: string; | ||
| truncated: boolean; | ||
| error?: undefined; | ||
| }>; | ||
| GrepTool: import("ai").Tool<{ | ||
| pattern: string; | ||
| caseInsensitive: boolean; | ||
| path?: string | undefined; | ||
| include?: string | undefined; | ||
| }, { | ||
| success: boolean; | ||
| matches: never[]; | ||
| message: string; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| matches: import("./ripgrep").GrepMatch[]; | ||
| message?: undefined; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| matches?: undefined; | ||
| message?: undefined; | ||
| }>; | ||
| GlobTool: import("ai").Tool<{ | ||
| pattern: string; | ||
| path?: string | undefined; | ||
| }, { | ||
| success: boolean; | ||
| files: string[]; | ||
| numFiles: number; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| files?: undefined; | ||
| numFiles?: undefined; | ||
| }>; | ||
| ThinkTool: import("ai").Tool<{ | ||
| thought: string; | ||
| }, { | ||
| success: boolean; | ||
| thought: string; | ||
| }>; | ||
| }; | ||
| export declare const chatTools: { | ||
| RecallTool: import("ai").Tool<{ | ||
| query: string; | ||
| max_results: number; | ||
| }, {}>; | ||
| FileReadTool: import("ai").Tool<{ | ||
| path: string; | ||
| line_start?: number | undefined; | ||
| line_end?: number | undefined; | ||
| }, { | ||
| success: boolean; | ||
| content: string; | ||
| totalLines: number; | ||
| error?: undefined; | ||
| suggestion?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| suggestion: string | undefined; | ||
| content?: undefined; | ||
| totalLines?: undefined; | ||
| }>; | ||
| GrepTool: import("ai").Tool<{ | ||
| pattern: string; | ||
| caseInsensitive: boolean; | ||
| path?: string | undefined; | ||
| include?: string | undefined; | ||
| }, { | ||
| success: boolean; | ||
| matches: never[]; | ||
| message: string; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| matches: import("./ripgrep").GrepMatch[]; | ||
| message?: undefined; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| matches?: undefined; | ||
| message?: undefined; | ||
| }>; | ||
| MemoryReadTool: import("ai").Tool<{ | ||
| name: string; | ||
| }, { | ||
| success: boolean; | ||
| content: string; | ||
| error?: undefined; | ||
| } | { | ||
| success: boolean; | ||
| error: string; | ||
| content?: undefined; | ||
| }>; | ||
| }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
245
14.49%3413912
-27.05%50
-9.09%98204
-27.48%5
150%1
Infinity%