Skip to main content
Glama
context.ts1.32 kB
/** * Execution context for graph execution */ import type { ExecutionContext as ExprContext } from "../expressions/context.js"; import type { NodeExecutionRecord } from "../types/execution.js"; export class ExecutionContext { private data: ExprContext; private history: NodeExecutionRecord[]; constructor(toolInput: Record<string, unknown>) { // Initialize context with tool input available as $.input this.data = { input: toolInput, // Also make input properties directly accessible for convenience ...toolInput, }; this.history = []; } getData(): ExprContext { return this.data; } setNodeOutput(nodeId: string, output: unknown): void { // Store output with node ID as key for reference this.data[nodeId] = output; // Also store in a generic way for JSONata access this.data.output = output; this.data.last = output; } addHistory( nodeId: string, nodeType: string, input: unknown, output: unknown, startTime: number, endTime: number, error?: Error ): void { this.history.push({ nodeId, nodeType, input, output, startTime, endTime, duration: endTime - startTime, error, }); } getHistory(): NodeExecutionRecord[] { return this.history; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TeamSparkAI/mcpGraph'

If you have feedback or need assistance with the MCP directory API, please join our Discord server