UNPKG

@nomyx/assistant

Version:

A powerful assistant library and cli for your AI projects. works with Vertex AI (Claude and Gemini)

42 lines (41 loc) 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ContextManager = void 0; class ContextManager { constructor(logger) { this.logger = logger; this.context = {}; } setInitialContext(initialContext) { this.context = { ...initialContext }; this.logger?.info('Initial context set', { contextKeys: Object.keys(initialContext) }); } updateContext(newContext) { this.context = { ...this.context, ...newContext }; this.logger?.debug('Context updated', { updatedKeys: Object.keys(newContext) }); } getContext() { return { ...this.context }; } getFormattedContext() { return Object.entries(this.context) .map(([key, value]) => `${key}: ${JSON.stringify(value)}`) .join('\n'); } clearContext() { this.context = {}; this.logger?.info('Context cleared'); } getContextValue(key) { const value = this.context[key]; if (value === undefined) { this.logger?.warn(`Attempted to access undefined context key: ${key}`); } return value; } setContextValue(key, value) { this.context[key] = value; this.logger?.debug(`Context value set for key: ${key}`); } } exports.ContextManager = ContextManager;