@almadar/agent 1.0.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/persistence/memory-backend.ts","../../src/persistence/firestore-checkpointer.ts","../../src/persistence/firestore-session-store.ts","../../src/persistence/firestore-store.ts"],"names":[],"mappings":";;;AAgBO,IAAM,uBAAN,MAA2B;AAAA,EAA3B,WAAA,GAAA;AACL,IAAA,IAAA,CAAQ,QAAA,uBAAe,GAAA,EAA6B;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAKpD,KAAA,CAAM,UAAkB,QAAA,EAAiC;AACvD,IAAA,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,QAAA,EAAU,QAAQ,CAAA;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,QAAA,EAA+C;AACjD,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,QAAQ,CAAA;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,QAAA,EAA2B;AAChC,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,MAAA,CAAO,QAAQ,CAAA;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA,EAKA,IAAA,GAAwB;AACtB,IAAA,OAAO,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,QAAA,CAAS,OAAA,EAAS,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,QAAA,EAAU,IAAI,CAAA,MAAO;AAAA,MACpE,QAAA;AAAA,MACA,GAAG;AAAA,KACL,CAAE,CAAA;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,QAAA,EAA2B;AAC7B,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,QAAQ,CAAA;AAAA,EACnC;AACF;ACuGO,IAAM,qBAAA,GAAN,cAAoC,mBAAA,CAAoB;AAAA,EAK7D,YAAY,OAAA,EAA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AmB,GAAA,EAAY;AAErC,IAAA,KAAA,MAAW,GAAA,IAAO,SAAS,IAAA,EAAM;AAC/B,MAAA,MAAM,IAAA,GAAO,IAAI,IAAA,EAAK;AACtB,MAAA,MAAM,YAAY,IAAA,CAAK,SAAA;AAGvB,MAAA,IAAI,GAAG,QAAA,KAAa,MAAA,IAAa,SAAA,CAAU,MAAA,GAAS,GAAG,QAAA,EAAU;AAC/D,QAAA,YAAA,CAAa,GAAA,CAAI,UAAU,KAAA,CAAM,CAAA,EAAG,GAAG,QAAQ,CAAA,CAAE,IAAA,CAAK,GAAG,CAAC,CAAA;AAAA,MAC5D,CAAA,MAAO;AACL,QAAA,YAAA,CAAa,GAAA,CAAI,SAAA,CAAU,IAAA,CAAK,GAAG,CAAC,CAAA;AAAA,MACtC;AAAA,IACF;AAEA,IAAA,MAAM,aAAa,KAAA,CAAM,IAAA,CAAK,YAAY,CAAA,CACvC,IAAI,CAAC,EAAA,KAAO,EAAA,CAAG,KAAA,CAAM,GAAG,CAAC,CAAA,CACzB,KAAA,CAAM,MAAA,EAAQ,SAAS,KAAK,CAAA;AAE/B,IAAA,OAAO,UAAA;AAAA,EACT;AACF","file":"index.js","sourcesContent":["/**\n * In-Memory Persistence Backend\n *\n * Provides in-memory session metadata storage for development.\n * Data is lost on process restart.\n */\n\nimport type { SessionMetadata, SessionRecord } from './types.js';\n\n// ============================================================================\n// MemorySessionBackend\n// ============================================================================\n\n/**\n * In-memory session metadata store.\n */\nexport class MemorySessionBackend {\n private sessions = new Map<string, SessionMetadata>();\n\n /**\n * Store session metadata.\n */\n store(threadId: string, metadata: SessionMetadata): void {\n this.sessions.set(threadId, metadata);\n }\n\n /**\n * Get session metadata.\n */\n get(threadId: string): SessionMetadata | undefined {\n return this.sessions.get(threadId);\n }\n\n /**\n * Delete session metadata.\n */\n delete(threadId: string): boolean {\n return this.sessions.delete(threadId);\n }\n\n /**\n * List all sessions.\n */\n list(): SessionRecord[] {\n return Array.from(this.sessions.entries()).map(([threadId, meta]) => ({\n threadId,\n ...meta,\n }));\n }\n\n /**\n * Check if a session exists.\n */\n has(threadId: string): boolean {\n return this.sessions.has(threadId);\n }\n}\n","/**\n * Firestore Checkpointer for LangGraph\n *\n * Custom implementation of BaseCheckpointSaver using Firebase Firestore.\n * This is required because LangGraph only provides Postgres/Redis savers.\n *\n * IMPORTANT: This module does NOT import firebase-admin directly.\n * The Firestore `db` instance must be injected via constructor options.\n * This keeps the @almadar/agent package free of firebase-admin as a direct dependency.\n */\n\nimport {\n BaseCheckpointSaver,\n type Checkpoint,\n type CheckpointTuple,\n type CheckpointMetadata,\n type CheckpointListOptions,\n type PendingWrite,\n} from '@langchain/langgraph-checkpoint';\nimport type { RunnableConfig } from '@langchain/core/runnables';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Minimal Firestore interface to avoid importing firebase-admin.\n * Consumers pass their own Firestore instance.\n */\nexport interface FirestoreDb {\n collection(path: string): FirestoreCollectionRef;\n batch(): FirestoreBatch;\n}\n\nexport interface FirestoreCollectionRef {\n doc(id: string): FirestoreDocRef;\n where(field: string, op: string, value: unknown): FirestoreQuery;\n orderBy(field: string, direction?: string): FirestoreQuery;\n limit(n: number): FirestoreQuery;\n}\n\nexport interface FirestoreDocRef {\n set(data: unknown): Promise<unknown>;\n get(): Promise<FirestoreDocSnapshot>;\n update(data: unknown): Promise<unknown>;\n delete(): Promise<unknown>;\n readonly ref: unknown;\n}\n\nexport interface FirestoreDocSnapshot {\n exists: boolean;\n data(): Record<string, unknown> | undefined;\n readonly ref: unknown;\n}\n\nexport interface FirestoreQuery {\n where(field: string, op: string, value: unknown): FirestoreQuery;\n orderBy(field: string, direction?: string): FirestoreQuery;\n limit(n: number): FirestoreQuery;\n startAfter(doc: unknown): FirestoreQuery;\n get(): Promise<FirestoreQuerySnapshot>;\n}\n\nexport interface FirestoreQuerySnapshot {\n empty: boolean;\n docs: FirestoreQueryDocSnapshot[];\n size: number;\n}\n\nexport interface FirestoreQueryDocSnapshot {\n data(): Record<string, unknown>;\n readonly ref: unknown;\n}\n\nexport interface FirestoreBatch {\n set(ref: unknown, data: unknown): void;\n delete(ref: unknown): void;\n commit(): Promise<unknown>;\n}\n\n/**\n * Firestore Timestamp-like interface.\n */\nexport interface FirestoreTimestamp {\n toDate(): Date;\n}\n\n/**\n * Options for FirestoreCheckpointer.\n */\nexport interface FirestoreCheckpointerOptions {\n /**\n * Firestore instance. Required — injected by consumer.\n */\n db: FirestoreDb;\n\n /**\n * Collection name for checkpoints.\n * @default 'agent_checkpoints'\n */\n checkpointsCollection?: string;\n\n /**\n * Collection name for pending writes.\n * @default 'agent_writes'\n */\n writesCollection?: string;\n}\n\n/**\n * Document structure for checkpoint storage.\n */\ninterface CheckpointDocument {\n threadId: string;\n checkpointId: string;\n parentCheckpointId?: string;\n checkpoint: Checkpoint;\n metadata: CheckpointMetadata;\n createdAt: unknown;\n updatedAt: unknown;\n}\n\n/**\n * Document structure for pending writes.\n */\ninterface WriteDocument {\n threadId: string;\n checkpointId: string;\n taskId: string;\n channel: string;\n value: unknown;\n createdAt: unknown;\n}\n\n// ============================================================================\n// FirestoreCheckpointer\n// ============================================================================\n\n/**\n * Firestore-backed checkpointer for LangGraph agents.\n *\n * Provides persistent checkpoint storage across server restarts.\n * Thread checkpoints are stored as Firestore documents.\n *\n * @example\n * ```typescript\n * import { getFirestore } from 'firebase-admin/firestore';\n *\n * const checkpointer = new FirestoreCheckpointer({\n * db: getFirestore(),\n * checkpointsCollection: 'agent_checkpoints',\n * });\n *\n * const agent = createDeepAgent({\n * // ...\n * checkpointer,\n * });\n * ```\n */\nexport class FirestoreCheckpointer extends BaseCheckpointSaver {\n private db: FirestoreDb;\n private checkpointsCollection: string;\n private writesCollection: string;\n\n constructor(options: FirestoreCheckpointerOptions) {\n super();\n this.db = options.db;\n this.checkpointsCollection = options.checkpointsCollection ?? 'agent_checkpoints';\n this.writesCollection = options.writesCollection ?? 'agent_writes';\n }\n\n /**\n * Get thread ID from config.\n */\n private getThreadId(config: RunnableConfig): string {\n const threadId = config.configurable?.thread_id;\n if (!threadId || typeof threadId !== 'string') {\n throw new Error('thread_id is required in config.configurable');\n }\n return threadId;\n }\n\n /**\n * Get checkpoint ID from config, or undefined for latest.\n */\n private getCheckpointId(config: RunnableConfig): string | undefined {\n return config.configurable?.checkpoint_id as string | undefined;\n }\n\n /**\n * Get checkpoint by config.\n */\n async getTuple(config: RunnableConfig): Promise<CheckpointTuple | undefined> {\n const threadId = this.getThreadId(config);\n const checkpointId = this.getCheckpointId(config);\n\n let query = this.db\n .collection(this.checkpointsCollection)\n .where('threadId', '==', threadId);\n\n if (checkpointId) {\n query = query.where('checkpointId', '==', checkpointId);\n } else {\n query = query.orderBy('createdAt', 'desc').limit(1);\n }\n\n const snapshot = await query.get();\n if (snapshot.empty) {\n return undefined;\n }\n\n const doc = snapshot.docs[0];\n const data = doc.data() as unknown as CheckpointDocument;\n\n // Get pending writes for this checkpoint\n const writesSnapshot = await this.db\n .collection(this.writesCollection)\n .where('threadId', '==', threadId)\n .where('checkpointId', '==', data.checkpointId)\n .get();\n\n const pendingWrites = writesSnapshot.docs.map((writeDoc) => {\n const writeData = writeDoc.data() as unknown as WriteDocument;\n return [writeData.taskId, writeData.channel, writeData.value] as [string, string, unknown];\n });\n\n // Build parent config if available\n const parentConfig = data.parentCheckpointId\n ? {\n configurable: {\n thread_id: threadId,\n checkpoint_id: data.parentCheckpointId,\n },\n }\n : undefined;\n\n return {\n config: {\n configurable: {\n thread_id: threadId,\n checkpoint_id: data.checkpointId,\n },\n },\n checkpoint: data.checkpoint,\n metadata: data.metadata,\n parentConfig,\n pendingWrites,\n };\n }\n\n /**\n * List checkpoints for a thread.\n */\n async *list(\n config: RunnableConfig,\n options?: CheckpointListOptions\n ): AsyncGenerator<CheckpointTuple> {\n const threadId = this.getThreadId(config);\n const limit = options?.limit ?? 10;\n\n let query = this.db\n .collection(this.checkpointsCollection)\n .where('threadId', '==', threadId)\n .orderBy('createdAt', 'desc')\n .limit(limit);\n\n // Apply filter if provided\n if (options?.filter) {\n for (const [key, value] of Object.entries(options.filter)) {\n query = query.where(`metadata.${key}`, '==', value);\n }\n }\n\n // Apply before cursor if provided\n if (options?.before?.configurable?.checkpoint_id) {\n const beforeDoc = await this.db\n .collection(this.checkpointsCollection)\n .where('threadId', '==', threadId)\n .where('checkpointId', '==', options.before.configurable.checkpoint_id)\n .get();\n\n if (!beforeDoc.empty) {\n query = query.startAfter(beforeDoc.docs[0]);\n }\n }\n\n const snapshot = await query.get();\n\n for (const doc of snapshot.docs) {\n const data = doc.data() as unknown as CheckpointDocument;\n\n const parentConfig = data.parentCheckpointId\n ? {\n configurable: {\n thread_id: threadId,\n checkpoint_id: data.parentCheckpointId,\n },\n }\n : undefined;\n\n yield {\n config: {\n configurable: {\n thread_id: threadId,\n checkpoint_id: data.checkpointId,\n },\n },\n checkpoint: data.checkpoint,\n metadata: data.metadata,\n parentConfig,\n };\n }\n }\n\n /**\n * Save a checkpoint.\n */\n async put(\n config: RunnableConfig,\n checkpoint: Checkpoint,\n metadata: CheckpointMetadata,\n _newVersions: Record<string, number | string>\n ): Promise<RunnableConfig> {\n const threadId = this.getThreadId(config);\n const checkpointId = checkpoint.id;\n const parentCheckpointId = this.getCheckpointId(config);\n\n const now = new Date();\n\n const docData: CheckpointDocument = {\n threadId,\n checkpointId,\n parentCheckpointId,\n checkpoint,\n metadata,\n createdAt: now,\n updatedAt: now,\n };\n\n // Use checkpointId as document ID for easy lookup\n const docId = `${threadId}_${checkpointId}`;\n await this.db.collection(this.checkpointsCollection).doc(docId).set(docData);\n\n return {\n configurable: {\n thread_id: threadId,\n checkpoint_id: checkpointId,\n },\n };\n }\n\n /**\n * Store pending writes for a checkpoint.\n */\n async putWrites(\n config: RunnableConfig,\n writes: PendingWrite[],\n taskId: string\n ): Promise<void> {\n const threadId = this.getThreadId(config);\n const checkpointId = this.getCheckpointId(config);\n\n if (!checkpointId) {\n throw new Error('checkpoint_id is required for putWrites');\n }\n\n const batch = this.db.batch();\n const now = new Date();\n\n for (const [idx, [channel, value]] of writes.entries()) {\n const docId = `${threadId}_${checkpointId}_${taskId}_${idx}`;\n const docRef = this.db.collection(this.writesCollection).doc(docId);\n\n const writeData: WriteDocument = {\n threadId,\n checkpointId,\n taskId,\n channel,\n value,\n createdAt: now,\n };\n\n batch.set(docRef, writeData);\n }\n\n await batch.commit();\n }\n\n /**\n * Delete all checkpoints and writes for a thread.\n */\n async deleteThread(threadId: string): Promise<void> {\n // Delete checkpoints\n const checkpointsSnapshot = await this.db\n .collection(this.checkpointsCollection)\n .where('threadId', '==', threadId)\n .get();\n\n const checkpointBatch = this.db.batch();\n for (const doc of checkpointsSnapshot.docs) {\n checkpointBatch.delete(doc.ref);\n }\n await checkpointBatch.commit();\n\n // Delete writes\n const writesSnapshot = await this.db\n .collection(this.writesCollection)\n .where('threadId', '==', threadId)\n .get();\n\n const writesBatch = this.db.batch();\n for (const doc of writesSnapshot.docs) {\n writesBatch.delete(doc.ref);\n }\n await writesBatch.commit();\n }\n}\n","/**\n * Firestore Session Store for DeepAgent\n *\n * Provides persistent session storage for skill-based agents.\n * Sessions are stored in Firestore and persist across server restarts.\n *\n * IMPORTANT: This module does NOT import firebase-admin directly.\n * The Firestore `db` instance must be injected via constructor options.\n */\n\nimport type { Session } from './types.js';\nimport type { FirestoreDb, FirestoreTimestamp } from './firestore-checkpointer.js';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Options for FirestoreSessionStore.\n */\nexport interface FirestoreSessionStoreOptions {\n /**\n * Firestore instance. Required — injected by consumer.\n */\n db: FirestoreDb;\n\n /**\n * Collection name for sessions.\n * @default 'agent_sessions'\n */\n collection?: string;\n}\n\n/**\n * Document structure for session storage.\n */\ninterface SessionDocument {\n threadId: string;\n skill: string;\n workDir: string;\n userId?: string;\n createdAt: FirestoreTimestamp;\n lastActivityAt: FirestoreTimestamp;\n}\n\n// ============================================================================\n// FirestoreSessionStore\n// ============================================================================\n\n/**\n * Firestore-backed session store for skill agents.\n *\n * @example\n * ```typescript\n * const sessionStore = new FirestoreSessionStore({ db: getFirestore() });\n *\n * await sessionStore.save({\n * threadId: 'abc-123',\n * skill: 'kflow-generating-m',\n * workDir: '/tmp/workspace',\n * createdAt: new Date(),\n * lastActivityAt: new Date(),\n * });\n *\n * const session = await sessionStore.get('abc-123');\n * ```\n */\nexport class FirestoreSessionStore {\n private db: FirestoreDb;\n private collection: string;\n\n constructor(options: FirestoreSessionStoreOptions) {\n this.db = options.db;\n this.collection = options.collection ?? 'agent_sessions';\n }\n\n /**\n * Save a session.\n */\n async save(session: Session): Promise<void> {\n const now = new Date();\n\n const docData = {\n threadId: session.threadId,\n skill: session.skill,\n workDir: session.workDir,\n userId: session.userId,\n createdAt: session.createdAt,\n lastActivityAt: now,\n };\n\n await this.db.collection(this.collection).doc(session.threadId).set(docData);\n }\n\n /**\n * Get a session by thread ID.\n */\n async get(threadId: string): Promise<Session | null> {\n const doc = await this.db.collection(this.collection).doc(threadId).get();\n\n if (!doc.exists) {\n return null;\n }\n\n const data = doc.data() as unknown as SessionDocument;\n return {\n threadId: data.threadId,\n skill: data.skill,\n workDir: data.workDir,\n userId: data.userId,\n createdAt: data.createdAt?.toDate?.() ?? new Date(data.createdAt as unknown as string),\n lastActivityAt: data.lastActivityAt?.toDate?.() ?? new Date(data.lastActivityAt as unknown as string),\n };\n }\n\n /**\n * Update session's last activity timestamp.\n */\n async touch(threadId: string): Promise<void> {\n await this.db.collection(this.collection).doc(threadId).update({\n lastActivityAt: new Date(),\n });\n }\n\n /**\n * Delete a session.\n */\n async delete(threadId: string): Promise<void> {\n await this.db.collection(this.collection).doc(threadId).delete();\n }\n\n /**\n * List sessions, optionally filtered by user ID.\n */\n async list(options?: { userId?: string; limit?: number }): Promise<Session[]> {\n let query = this.db\n .collection(this.collection)\n .orderBy('lastActivityAt', 'desc');\n\n if (options?.userId) {\n query = query.where('userId', '==', options.userId);\n }\n\n const limit = options?.limit ?? 100;\n query = query.limit(limit);\n\n const snapshot = await query.get();\n\n return snapshot.docs.map((doc) => {\n const data = doc.data() as unknown as SessionDocument;\n return {\n threadId: data.threadId,\n skill: data.skill,\n workDir: data.workDir,\n userId: data.userId,\n createdAt: data.createdAt?.toDate?.() ?? new Date(data.createdAt as unknown as string),\n lastActivityAt: data.lastActivityAt?.toDate?.() ?? new Date(data.lastActivityAt as unknown as string),\n };\n });\n }\n\n /**\n * Delete expired sessions (older than specified hours).\n */\n async deleteExpired(maxAgeHours: number = 24): Promise<number> {\n const cutoff = new Date(Date.now() - maxAgeHours * 60 * 60 * 1000);\n\n const snapshot = await this.db\n .collection(this.collection)\n .where('lastActivityAt', '<', cutoff)\n .get();\n\n const batch = this.db.batch();\n for (const doc of snapshot.docs) {\n batch.delete(doc.ref);\n }\n\n await batch.commit();\n return snapshot.size;\n }\n}\n","/**\n * Firestore Store for LangGraph\n *\n * Custom implementation of BaseStore using Firebase Firestore.\n * This provides persistent key-value storage for agent memories.\n *\n * IMPORTANT: This module does NOT import firebase-admin directly.\n * The Firestore `db` instance must be injected via constructor options.\n */\n\nimport {\n BaseStore,\n type Item,\n type GetOperation,\n type SearchOperation,\n type PutOperation,\n type ListNamespacesOperation,\n type Operation,\n type OperationResults,\n type SearchItem,\n} from '@langchain/langgraph-checkpoint';\n\nimport type { FirestoreDb, FirestoreTimestamp } from './firestore-checkpointer.js';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Options for FirestoreStore.\n */\nexport interface FirestoreStoreOptions {\n /**\n * Firestore instance. Required — injected by consumer.\n */\n db: FirestoreDb;\n\n /**\n * Collection name for store items.\n * @default 'agent_memories'\n */\n collection?: string;\n}\n\n/**\n * Document structure for store items.\n */\ninterface StoreDocument {\n namespace: string[];\n namespaceKey: string; // Joined namespace for querying\n key: string;\n value: Record<string, unknown>;\n createdAt: FirestoreTimestamp;\n updatedAt: FirestoreTimestamp;\n}\n\n// ============================================================================\n// FirestoreStore\n// ============================================================================\n\n/**\n * Firestore-backed store for LangGraph agent memories.\n *\n * Provides persistent key-value storage that can be shared across threads.\n * Items are organized by hierarchical namespaces.\n *\n * @example\n * ```typescript\n * import { getFirestore } from 'firebase-admin/firestore';\n *\n * const store = new FirestoreStore({\n * db: getFirestore(),\n * collection: 'agent_memories',\n * });\n *\n * // Store a memory\n * await store.put(['agent', 'patterns'], 'schema-best-practices', {\n * content: 'Always validate schemas before saving',\n * });\n *\n * // Retrieve a memory\n * const item = await store.get(['agent', 'patterns'], 'schema-best-practices');\n * ```\n */\nexport class FirestoreStore extends BaseStore {\n private db: FirestoreDb;\n private collection: string;\n\n constructor(options: FirestoreStoreOptions) {\n super();\n this.db = options.db;\n this.collection = options.collection ?? 'agent_memories';\n }\n\n /**\n * Create document ID from namespace and key.\n */\n private makeDocId(namespace: string[], key: string): string {\n return [...namespace, key].join('/');\n }\n\n /**\n * Create namespace key for querying.\n */\n private makeNamespaceKey(namespace: string[]): string {\n return namespace.join('/');\n }\n\n /**\n * Execute multiple operations in a batch.\n */\n async batch<Op extends Operation[]>(operations: Op): Promise<OperationResults<Op>> {\n const results: unknown[] = [];\n\n for (const op of operations) {\n if ('key' in op && 'namespace' in op && !('namespacePrefix' in op)) {\n if ('value' in op) {\n // PutOperation\n const putOp = op as PutOperation;\n if (putOp.value === null) {\n await this.deleteItem(putOp.namespace, putOp.key);\n } else {\n await this.putItem(putOp.namespace, putOp.key, putOp.value);\n }\n results.push(undefined);\n } else {\n // GetOperation\n const getOp = op as GetOperation;\n const item = await this.getItem(getOp.namespace, getOp.key);\n results.push(item);\n }\n } else if ('namespacePrefix' in op) {\n // SearchOperation\n const searchOp = op as SearchOperation;\n const items = await this.searchItems(searchOp);\n results.push(items);\n } else if ('matchConditions' in op || ('limit' in op && 'offset' in op && !('namespacePrefix' in op))) {\n // ListNamespacesOperation\n const listOp = op as ListNamespacesOperation;\n const namespaces = await this.listNamespacesItems(listOp);\n results.push(namespaces);\n }\n }\n\n return results as OperationResults<Op>;\n }\n\n /**\n * Get an item by namespace and key.\n */\n private async getItem(namespace: string[], key: string): Promise<Item | null> {\n const docId = this.makeDocId(namespace, key);\n const doc = await this.db.collection(this.collection).doc(docId).get();\n\n if (!doc.exists) {\n return null;\n }\n\n const data = doc.data() as unknown as StoreDocument;\n return {\n namespace: data.namespace,\n key: data.key,\n value: data.value,\n createdAt: data.createdAt?.toDate?.() ?? new Date(data.createdAt as unknown as string),\n updatedAt: data.updatedAt?.toDate?.() ?? new Date(data.updatedAt as unknown as string),\n };\n }\n\n /**\n * Put an item.\n */\n private async putItem(\n namespace: string[],\n key: string,\n value: Record<string, unknown>\n ): Promise<void> {\n const docId = this.makeDocId(namespace, key);\n const now = new Date();\n\n const existingDoc = await this.db.collection(this.collection).doc(docId).get();\n const createdAt = existingDoc.exists\n ? ((existingDoc.data() as unknown as StoreDocument).createdAt as unknown as Date)\n : now;\n\n const docData = {\n namespace,\n namespaceKey: this.makeNamespaceKey(namespace),\n key,\n value,\n createdAt,\n updatedAt: now,\n };\n\n await this.db.collection(this.collection).doc(docId).set(docData);\n }\n\n /**\n * Delete an item.\n */\n private async deleteItem(namespace: string[], key: string): Promise<void> {\n const docId = this.makeDocId(namespace, key);\n await this.db.collection(this.collection).doc(docId).delete();\n }\n\n /**\n * Search for items.\n */\n private async searchItems(op: SearchOperation): Promise<SearchItem[]> {\n const namespacePrefix = this.makeNamespaceKey(op.namespacePrefix);\n const limit = op.limit ?? 10;\n const offset = op.offset ?? 0;\n\n // Query by namespace prefix\n let query = this.db.collection(this.collection) as unknown as {\n where(field: string, op: string, value: unknown): typeof query;\n limit(n: number): typeof query;\n get(): Promise<{ docs: Array<{ data(): Record<string, unknown> }> }>;\n };\n\n if (namespacePrefix) {\n // Use range query for prefix matching\n query = query\n .where('namespaceKey', '>=', namespacePrefix)\n .where('namespaceKey', '<', namespacePrefix + '\\uffff');\n }\n\n // Apply filters\n if (op.filter) {\n for (const [key, filterValue] of Object.entries(op.filter)) {\n if (typeof filterValue === 'object' && filterValue !== null) {\n // Handle comparison operators\n for (const [operator, value] of Object.entries(filterValue as Record<string, unknown>)) {\n switch (operator) {\n case '$eq':\n query = query.where(`value.${key}`, '==', value);\n break;\n case '$ne':\n query = query.where(`value.${key}`, '!=', value);\n break;\n case '$gt':\n query = query.where(`value.${key}`, '>', value);\n break;\n case '$gte':\n query = query.where(`value.${key}`, '>=', value);\n break;\n case '$lt':\n query = query.where(`value.${key}`, '<', value);\n break;\n case '$lte':\n query = query.where(`value.${key}`, '<=', value);\n break;\n }\n }\n } else {\n // Direct equality\n query = query.where(`value.${key}`, '==', filterValue);\n }\n }\n }\n\n // Apply pagination\n query = query.limit(limit + offset);\n\n const snapshot = await query.get();\n const docs = snapshot.docs.slice(offset);\n\n return docs.map((doc) => {\n const data = doc.data() as unknown as StoreDocument;\n return {\n namespace: data.namespace,\n key: data.key,\n value: data.value,\n createdAt: data.createdAt?.toDate?.() ?? new Date(data.createdAt as unknown as string),\n updatedAt: data.updatedAt?.toDate?.() ?? new Date(data.updatedAt as unknown as string),\n };\n });\n }\n\n /**\n * List namespaces.\n */\n private async listNamespacesItems(op: ListNamespacesOperation): Promise<string[][]> {\n const limit = op.limit ?? 10;\n const offset = op.offset ?? 0;\n\n let query = this.db.collection(this.collection) as unknown as {\n where(field: string, op: string, value: unknown): typeof query;\n get(): Promise<{ docs: Array<{ data(): Record<string, unknown> }> }>;\n };\n\n // Apply match conditions\n if (op.matchConditions) {\n for (const condition of op.matchConditions) {\n const path = condition.path.filter((p) => p !== '*').join('/');\n if (condition.matchType === 'prefix') {\n query = query\n .where('namespaceKey', '>=', path)\n .where('namespaceKey', '<', path + '\\uffff');\n }\n // suffix matching done in memory\n }\n }\n\n // Get all documents and extract unique namespaces\n const snapshot = await query.get();\n const namespaceSet = new Set<string>();\n\n for (const doc of snapshot.docs) {\n const data = doc.data() as unknown as StoreDocument;\n const namespace = data.namespace;\n\n // Apply max depth if specified\n if (op.maxDepth !== undefined && namespace.length > op.maxDepth) {\n namespaceSet.add(namespace.slice(0, op.maxDepth).join('/'));\n } else {\n namespaceSet.add(namespace.join('/'));\n }\n }\n\n const namespaces = Array.from(namespaceSet)\n .map((ns) => ns.split('/'))\n .slice(offset, offset + limit);\n\n return namespaces;\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * KFlow DeepAgent System Prompt
3
+ *
4
+ * System prompts for the agent. Uses @almadar/skills for the
5
+ * schema reference documentation.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /**
10
+ * Create the system prompt for the KFlow schema generator agent.
11
+ *
12
+ * This prompt instructs the agent to:
13
+ * 1. Generate KFlow schemas from natural language
14
+ * 2. Use the KFlow CLI for validation and compilation
15
+ * 3. Exit once the app compiles successfully
16
+ */
17
+ declare function createSystemPrompt(): string;
18
+ /**
19
+ * Create a compact version of the system prompt for smaller context windows.
20
+ */
21
+ declare function createCompactSystemPrompt(): string;
22
+
23
+ export { createCompactSystemPrompt, createSystemPrompt };
@@ -0,0 +1,126 @@
1
+ import { getArchitectureSection, getMinimalTypeReference } from '@almadar/skills';
2
+
3
+ // src/prompts/system-prompt.ts
4
+ function getSchemaReference() {
5
+ return `## KFlow Schema Reference
6
+
7
+ ${getArchitectureSection()}
8
+
9
+ ${getMinimalTypeReference()}`;
10
+ }
11
+ function createSystemPrompt() {
12
+ const SCHEMA_REFERENCE = getSchemaReference();
13
+ return `You are a KFlow application generator. You create working applications by generating valid KFlow schemas.
14
+
15
+ ${SCHEMA_REFERENCE}
16
+
17
+ ## File System
18
+
19
+ You have access to a virtual filesystem rooted at your workspace directory.
20
+ - All file paths should start with / (e.g., /schema.json, /app)
21
+ - You can only access files within your workspace
22
+ - Use /schema.json as your main schema file
23
+ - Use /app as the output directory for compiled apps
24
+
25
+ ## CRITICAL: Path Handling for CLI Commands
26
+
27
+ The file system tools (write_file, read_file, edit_file) use virtual paths starting with /.
28
+ However, the CLI tools run in the real filesystem and need ABSOLUTE paths.
29
+
30
+ **ALWAYS follow this pattern for CLI commands:**
31
+
32
+ 1. First, run \`pwd\` to get your workspace's absolute path
33
+ 2. Use the full absolute path for ALL CLI commands
34
+
35
+ **Correct:**
36
+ \`\`\`bash
37
+ pwd
38
+ orbital validate /home/user/.../workspaces/session-id/schema.json --json
39
+ npx kflow compile /home/user/.../workspaces/session-id/schema.json -o /home/user/.../workspaces/session-id/app --verify
40
+ \`\`\`
41
+
42
+ **WRONG:**
43
+ \`\`\`bash
44
+ orbital validate /schema.json --json
45
+ orbital validate ./schema.json --json
46
+ \`\`\`
47
+
48
+ ## Your Workflow
49
+
50
+ 1. **Get workspace path**: Run \`pwd\` to get your absolute workspace path
51
+ 2. **Analyze** the user's request to understand what application they want
52
+ 3. **Plan** using write_todos to break down the work
53
+ 4. **Generate** a KFlow schema and write it to /schema.json
54
+ 5. **Validate** using: orbital validate {WORKSPACE_PATH}/schema.json --json
55
+ 6. **Fix** any validation errors by editing /schema.json
56
+ 7. **Compile** using: npx kflow compile {WORKSPACE_PATH}/schema.json -o {WORKSPACE_PATH}/app --verify
57
+ 8. **Install** dependencies: cd {WORKSPACE_PATH}/app && npm install
58
+ 9. **Write Summary**: Write /summary.json with a summary of your work
59
+ 10. **Complete** when the app compiles successfully and summary is written
60
+
61
+ ## Summary File Format
62
+
63
+ \`\`\`json
64
+ {
65
+ "success": true,
66
+ "request": "Brief description of what the user asked for",
67
+ "schemaGenerated": {
68
+ "name": "AppName",
69
+ "entities": ["Entity1", "Entity2"],
70
+ "states": ["state1", "state2"],
71
+ "pages": ["page1", "page2"]
72
+ },
73
+ "iterations": {
74
+ "validationAttempts": 2,
75
+ "compilationAttempts": 1
76
+ },
77
+ "issues": [
78
+ {
79
+ "type": "validation|compilation|other",
80
+ "description": "What went wrong",
81
+ "resolution": "How you fixed it"
82
+ }
83
+ ],
84
+ "insights": "Any observations about the schema format"
85
+ }
86
+ \`\`\`
87
+
88
+ ## Important Guidelines
89
+
90
+ - **ALWAYS run \`pwd\` first** and use the full path for CLI commands
91
+ - Always validate after writing or editing /schema.json
92
+ - Parse JSON output from validate command
93
+ - Loop until compilation succeeds
94
+ - Use write_todos to track progress
95
+ `;
96
+ }
97
+ function createCompactSystemPrompt() {
98
+ const SCHEMA_REFERENCE = getSchemaReference();
99
+ return `You are a KFlow app generator.
100
+
101
+ ${SCHEMA_REFERENCE}
102
+
103
+ File System: All paths start with / (e.g., /schema.json, /app). You can only access your workspace.
104
+
105
+ CRITICAL - Path Handling:
106
+ - File tools use virtual paths (/schema.json)
107
+ - CLI tools need ABSOLUTE paths from \`pwd\` for BOTH input AND output
108
+ - ALWAYS run \`pwd\` first, then use full path for everything
109
+
110
+ Workflow:
111
+ 1. Run \`pwd\` to get workspace path
112
+ 2. Write /schema.json
113
+ 3. Validate: orbital validate {PWD}/schema.json --json
114
+ 4. Fix errors if any
115
+ 5. Compile: npx kflow compile {PWD}/schema.json -o {PWD}/app --verify
116
+ 6. Install: cd {PWD}/app && npm install
117
+ 7. Write /summary.json
118
+ 8. Done when compilation succeeds
119
+
120
+ Use write_todos to plan. Follow the schema reference for valid structure.
121
+ `;
122
+ }
123
+
124
+ export { createCompactSystemPrompt, createSystemPrompt };
125
+ //# sourceMappingURL=index.js.map
126
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/prompts/system-prompt.ts"],"names":[],"mappings":";;;AAiBA,SAAS,kBAAA,GAA6B;AACpC,EAAA,OAAO,CAAA;;AAAA,EAEP,wBAAwB;;AAAA,EAExB,yBAAyB,CAAA,CAAA;AAC3B;AAUO,SAAS,kBAAA,GAA6B;AAC3C,EAAA,MAAM,mBAAmB,kBAAA,EAAmB;AAE5C,EAAA,OAAO,CAAA;;AAAA,EAEP,gBAAgB;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAiFlB;AAKO,SAAS,yBAAA,GAAoC;AAClD,EAAA,MAAM,mBAAmB,kBAAA,EAAmB;AAE5C,EAAA,OAAO,CAAA;;AAAA,EAEP,gBAAgB;;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA,CAAA;AAqBlB","file":"index.js","sourcesContent":["/**\n * KFlow DeepAgent System Prompt\n *\n * System prompts for the agent. Uses @almadar/skills for the\n * schema reference documentation.\n *\n * @packageDocumentation\n */\n\nimport {\n getMinimalTypeReference,\n getArchitectureSection,\n} from '@almadar/skills';\n\n/**\n * Build a comprehensive schema reference from @almadar/skills.\n */\nfunction getSchemaReference(): string {\n return `## KFlow Schema Reference\n\n${getArchitectureSection()}\n\n${getMinimalTypeReference()}`;\n}\n\n/**\n * Create the system prompt for the KFlow schema generator agent.\n *\n * This prompt instructs the agent to:\n * 1. Generate KFlow schemas from natural language\n * 2. Use the KFlow CLI for validation and compilation\n * 3. Exit once the app compiles successfully\n */\nexport function createSystemPrompt(): string {\n const SCHEMA_REFERENCE = getSchemaReference();\n\n return `You are a KFlow application generator. You create working applications by generating valid KFlow schemas.\n\n${SCHEMA_REFERENCE}\n\n## File System\n\nYou have access to a virtual filesystem rooted at your workspace directory.\n- All file paths should start with / (e.g., /schema.json, /app)\n- You can only access files within your workspace\n- Use /schema.json as your main schema file\n- Use /app as the output directory for compiled apps\n\n## CRITICAL: Path Handling for CLI Commands\n\nThe file system tools (write_file, read_file, edit_file) use virtual paths starting with /.\nHowever, the CLI tools run in the real filesystem and need ABSOLUTE paths.\n\n**ALWAYS follow this pattern for CLI commands:**\n\n1. First, run \\`pwd\\` to get your workspace's absolute path\n2. Use the full absolute path for ALL CLI commands\n\n**Correct:**\n\\`\\`\\`bash\npwd\norbital validate /home/user/.../workspaces/session-id/schema.json --json\nnpx kflow compile /home/user/.../workspaces/session-id/schema.json -o /home/user/.../workspaces/session-id/app --verify\n\\`\\`\\`\n\n**WRONG:**\n\\`\\`\\`bash\norbital validate /schema.json --json\norbital validate ./schema.json --json\n\\`\\`\\`\n\n## Your Workflow\n\n1. **Get workspace path**: Run \\`pwd\\` to get your absolute workspace path\n2. **Analyze** the user's request to understand what application they want\n3. **Plan** using write_todos to break down the work\n4. **Generate** a KFlow schema and write it to /schema.json\n5. **Validate** using: orbital validate {WORKSPACE_PATH}/schema.json --json\n6. **Fix** any validation errors by editing /schema.json\n7. **Compile** using: npx kflow compile {WORKSPACE_PATH}/schema.json -o {WORKSPACE_PATH}/app --verify\n8. **Install** dependencies: cd {WORKSPACE_PATH}/app && npm install\n9. **Write Summary**: Write /summary.json with a summary of your work\n10. **Complete** when the app compiles successfully and summary is written\n\n## Summary File Format\n\n\\`\\`\\`json\n{\n \"success\": true,\n \"request\": \"Brief description of what the user asked for\",\n \"schemaGenerated\": {\n \"name\": \"AppName\",\n \"entities\": [\"Entity1\", \"Entity2\"],\n \"states\": [\"state1\", \"state2\"],\n \"pages\": [\"page1\", \"page2\"]\n },\n \"iterations\": {\n \"validationAttempts\": 2,\n \"compilationAttempts\": 1\n },\n \"issues\": [\n {\n \"type\": \"validation|compilation|other\",\n \"description\": \"What went wrong\",\n \"resolution\": \"How you fixed it\"\n }\n ],\n \"insights\": \"Any observations about the schema format\"\n}\n\\`\\`\\`\n\n## Important Guidelines\n\n- **ALWAYS run \\`pwd\\` first** and use the full path for CLI commands\n- Always validate after writing or editing /schema.json\n- Parse JSON output from validate command\n- Loop until compilation succeeds\n- Use write_todos to track progress\n`;\n}\n\n/**\n * Create a compact version of the system prompt for smaller context windows.\n */\nexport function createCompactSystemPrompt(): string {\n const SCHEMA_REFERENCE = getSchemaReference();\n\n return `You are a KFlow app generator.\n\n${SCHEMA_REFERENCE}\n\nFile System: All paths start with / (e.g., /schema.json, /app). You can only access your workspace.\n\nCRITICAL - Path Handling:\n- File tools use virtual paths (/schema.json)\n- CLI tools need ABSOLUTE paths from \\`pwd\\` for BOTH input AND output\n- ALWAYS run \\`pwd\\` first, then use full path for everything\n\nWorkflow:\n1. Run \\`pwd\\` to get workspace path\n2. Write /schema.json\n3. Validate: orbital validate {PWD}/schema.json --json\n4. Fix errors if any\n5. Compile: npx kflow compile {PWD}/schema.json -o {PWD}/app --verify\n6. Install: cd {PWD}/app && npm install\n7. Write /summary.json\n8. Done when compilation succeeds\n\nUse write_todos to plan. Follow the schema reference for valid structure.\n`;\n}\n"]}