UNPKG

backpackflow

Version:

A config-driven LLM framework built on top of PocketFlow

95 lines 2.71 kB
"use strict"; /** * Event System Types for BackpackFlow * * Comprehensive type definitions for the hierarchical event streaming system. * Events follow the pattern: {namespace}:{category}:{action} */ Object.defineProperty(exports, "__esModule", { value: true }); exports.EVENT_ACTIONS = exports.EVENT_CATEGORIES = void 0; exports.isToolEvent = isToolEvent; exports.isContentEvent = isContentEvent; exports.isNodeEvent = isNodeEvent; exports.isFlowEvent = isFlowEvent; exports.isErrorEvent = isErrorEvent; exports.createEventName = createEventName; exports.createNamespacedEventName = createNamespacedEventName; exports.parseEventName = parseEventName; // Constants for event categories exports.EVENT_CATEGORIES = { TOOL: 'tool', CONTENT: 'content', NODE: 'node', FLOW: 'flow', USER: 'user', STORAGE: 'storage', LLM: 'llm', SYSTEM: 'system', ERROR: 'error' }; // Constants for event actions exports.EVENT_ACTIONS = { // Tool actions CALL_REQUESTED: 'call_requested', EXECUTED: 'executed', ERROR: 'error', // Content actions STREAM: 'stream', COMPLETE: 'complete', START: 'start', // Node actions CREATED: 'created', // Flow actions TRANSITION: 'transition', // User actions INPUT: 'input', INTERRUPT: 'interrupt', // Storage actions READ: 'read', WRITE: 'write', DELETE: 'delete', // LLM actions REQUEST: 'request', RESPONSE: 'response', // System actions WARNING: 'warning', INFO: 'info' }; // Type guards for event categorization function isToolEvent(eventName) { return eventName.includes('tool:'); } function isContentEvent(eventName) { return eventName.includes('content:'); } function isNodeEvent(eventName) { return eventName.includes('node:'); } function isFlowEvent(eventName) { return eventName.includes('flow:'); } function isErrorEvent(eventName) { return eventName.includes('error:'); } // Utility function to create event names function createEventName(category, action) { return `${category}:${action}`; } // Utility function to create namespaced event names function createNamespacedEventName(namespace, category, action) { return `${namespace}:${category}:${action}`; } // Utility function to parse event names function parseEventName(eventName) { const parts = eventName.split(':'); if (parts.length === 2) { return { category: parts[0], action: parts[1] }; } else if (parts.length === 3) { return { namespace: parts[0], category: parts[1], action: parts[2] }; } else { throw new Error(`Invalid event name format: ${eventName}`); } } //# sourceMappingURL=events.js.map