UNPKG

backpackflow

Version:

A config-driven LLM framework built on top of PocketFlow

61 lines 1.91 kB
"use strict"; /** * Storage Capabilities System for BackpackFlow * * This defines reusable storage capabilities that nodes can depend on, * enabling a library of reusable nodes while keeping storage central. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.createStorage = createStorage; exports.updateStorage = updateStorage; exports.hasCapability = hasCapability; // ============================================================================ // STORAGE UTILITIES // ============================================================================ /** * Create a new storage instance with default values */ function createStorage(type, initialData) { const storage = new type(); // Set base properties if (!storage.id) storage.id = crypto.randomUUID(); if (!storage.createdAt) storage.createdAt = new Date(); storage.updatedAt = new Date(); if (!storage.metadata) storage.metadata = {}; if (!storage._flowState) storage._flowState = { executionPath: [] }; // Apply initial data if (initialData) { Object.assign(storage, initialData); } return storage; } /** * Update storage and track the change */ function updateStorage(storage, updates, nodeName) { // Track the update storage.updatedAt = new Date(); if (nodeName && storage._flowState) { if (!storage._flowState.executionPath) { storage._flowState.executionPath = []; } storage._flowState.executionPath.push(nodeName); storage._flowState.currentNode = nodeName; } // Apply updates Object.assign(storage, updates); return storage; } /** * Check if storage has a specific capability */ function hasCapability(storage, capability) { return capability in storage && storage[capability] !== undefined; } //# sourceMappingURL=capabilities.js.map