neuro-cli 4.1.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.
- package/LICENSE +21 -0
- package/README.md +510 -0
- package/dist/advisor/advisor.d.ts +50 -0
- package/dist/advisor/advisor.js +178 -0
- package/dist/agents/base.d.ts +62 -0
- package/dist/agents/base.js +215 -0
- package/dist/agents/orchestrator.d.ts +46 -0
- package/dist/agents/orchestrator.js +192 -0
- package/dist/agents/team.d.ts +51 -0
- package/dist/agents/team.js +210 -0
- package/dist/api/models.d.ts +23 -0
- package/dist/api/models.js +514 -0
- package/dist/api/ollama.d.ts +153 -0
- package/dist/api/ollama.js +751 -0
- package/dist/api/openrouter.d.ts +55 -0
- package/dist/api/openrouter.js +223 -0
- package/dist/commands/commands.d.ts +43 -0
- package/dist/commands/commands.js +308 -0
- package/dist/config/config.d.ts +8 -0
- package/dist/config/config.js +311 -0
- package/dist/context/compaction.d.ts +54 -0
- package/dist/context/compaction.js +251 -0
- package/dist/context/custom-agents.d.ts +107 -0
- package/dist/context/custom-agents.js +397 -0
- package/dist/context/custom-tools.d.ts +120 -0
- package/dist/context/custom-tools.js +564 -0
- package/dist/context/git-checkpoint.d.ts +52 -0
- package/dist/context/git-checkpoint.js +240 -0
- package/dist/context/neuro-md.d.ts +48 -0
- package/dist/context/neuro-md.js +202 -0
- package/dist/context/neuroignore.d.ts +102 -0
- package/dist/context/neuroignore.js +441 -0
- package/dist/context/repo-map.d.ts +38 -0
- package/dist/context/repo-map.js +220 -0
- package/dist/context/skill-standard.d.ts +262 -0
- package/dist/context/skill-standard.js +1156 -0
- package/dist/context/skill-system.d.ts +75 -0
- package/dist/context/skill-system.js +578 -0
- package/dist/context/tree-sitter.d.ts +99 -0
- package/dist/context/tree-sitter.js +1956 -0
- package/dist/core/acp.d.ts +325 -0
- package/dist/core/acp.js +1498 -0
- package/dist/core/api-server.d.ts +143 -0
- package/dist/core/api-server.js +550 -0
- package/dist/core/approval.d.ts +81 -0
- package/dist/core/approval.js +432 -0
- package/dist/core/auto-compact.d.ts +127 -0
- package/dist/core/auto-compact.js +436 -0
- package/dist/core/auto-mode.d.ts +232 -0
- package/dist/core/auto-mode.js +831 -0
- package/dist/core/background-session.d.ts +166 -0
- package/dist/core/background-session.js +696 -0
- package/dist/core/cicd.d.ts +257 -0
- package/dist/core/cicd.js +1443 -0
- package/dist/core/cloud-sync.d.ts +156 -0
- package/dist/core/cloud-sync.js +582 -0
- package/dist/core/code-review.d.ts +132 -0
- package/dist/core/code-review.js +1191 -0
- package/dist/core/completion.d.ts +49 -0
- package/dist/core/completion.js +384 -0
- package/dist/core/context.d.ts +38 -0
- package/dist/core/context.js +144 -0
- package/dist/core/diff-preview.d.ts +35 -0
- package/dist/core/diff-preview.js +173 -0
- package/dist/core/doom-loop.d.ts +51 -0
- package/dist/core/doom-loop.js +179 -0
- package/dist/core/engine.d.ts +183 -0
- package/dist/core/engine.js +942 -0
- package/dist/core/extended-thinking.d.ts +103 -0
- package/dist/core/extended-thinking.js +269 -0
- package/dist/core/fallback.d.ts +54 -0
- package/dist/core/fallback.js +104 -0
- package/dist/core/git-worktree.d.ts +139 -0
- package/dist/core/git-worktree.js +614 -0
- package/dist/core/headless.d.ts +30 -0
- package/dist/core/headless.js +101 -0
- package/dist/core/i18n.d.ts +83 -0
- package/dist/core/i18n.js +739 -0
- package/dist/core/linting.d.ts +129 -0
- package/dist/core/linting.js +699 -0
- package/dist/core/model-router.d.ts +109 -0
- package/dist/core/model-router.js +581 -0
- package/dist/core/multi-model.d.ts +243 -0
- package/dist/core/multi-model.js +1099 -0
- package/dist/core/multi-session.d.ts +144 -0
- package/dist/core/multi-session.js +442 -0
- package/dist/core/multimodal.d.ts +125 -0
- package/dist/core/multimodal.js +286 -0
- package/dist/core/observability.d.ts +93 -0
- package/dist/core/observability.js +737 -0
- package/dist/core/os-sandbox.d.ts +122 -0
- package/dist/core/os-sandbox.js +1193 -0
- package/dist/core/outcome-grading.d.ts +228 -0
- package/dist/core/outcome-grading.js +1123 -0
- package/dist/core/output-styles.d.ts +57 -0
- package/dist/core/output-styles.js +382 -0
- package/dist/core/parallel-agents.d.ts +183 -0
- package/dist/core/parallel-agents.js +563 -0
- package/dist/core/plugin-bundle.d.ts +236 -0
- package/dist/core/plugin-bundle.js +887 -0
- package/dist/core/plugin-sdk.d.ts +139 -0
- package/dist/core/plugin-sdk.js +273 -0
- package/dist/core/prompt-cache.d.ts +163 -0
- package/dist/core/prompt-cache.js +599 -0
- package/dist/core/sandbox.d.ts +127 -0
- package/dist/core/sandbox.js +369 -0
- package/dist/core/scheduled-tasks.d.ts +151 -0
- package/dist/core/scheduled-tasks.js +502 -0
- package/dist/core/security-scanner.d.ts +160 -0
- package/dist/core/security-scanner.js +1494 -0
- package/dist/core/session.d.ts +83 -0
- package/dist/core/session.js +269 -0
- package/dist/core/shell-completion.d.ts +51 -0
- package/dist/core/shell-completion.js +674 -0
- package/dist/core/smart-monitor.d.ts +146 -0
- package/dist/core/smart-monitor.js +1199 -0
- package/dist/core/spec-driven.d.ts +233 -0
- package/dist/core/spec-driven.js +1485 -0
- package/dist/core/spending-warnings.d.ts +123 -0
- package/dist/core/spending-warnings.js +456 -0
- package/dist/core/sub-agent.d.ts +298 -0
- package/dist/core/sub-agent.js +1023 -0
- package/dist/core/telemetry.d.ts +157 -0
- package/dist/core/telemetry.js +412 -0
- package/dist/core/terminal-ux.d.ts +134 -0
- package/dist/core/terminal-ux.js +649 -0
- package/dist/core/testing.d.ts +146 -0
- package/dist/core/testing.js +1200 -0
- package/dist/core/types.d.ts +439 -0
- package/dist/core/types.js +6 -0
- package/dist/core/undo-redo.d.ts +112 -0
- package/dist/core/undo-redo.js +290 -0
- package/dist/core/updater.d.ts +159 -0
- package/dist/core/updater.js +608 -0
- package/dist/core/vim-mode.d.ts +151 -0
- package/dist/core/vim-mode.js +771 -0
- package/dist/core/voice.d.ts +137 -0
- package/dist/core/voice.js +538 -0
- package/dist/core/web-dashboard.d.ts +109 -0
- package/dist/core/web-dashboard.js +484 -0
- package/dist/hooks/hooks.d.ts +74 -0
- package/dist/hooks/hooks.js +160 -0
- package/dist/hooks/llm-evaluator.d.ts +165 -0
- package/dist/hooks/llm-evaluator.js +560 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1186 -0
- package/dist/lsp/lsp-manager.d.ts +63 -0
- package/dist/lsp/lsp-manager.js +351 -0
- package/dist/mcp/client.d.ts +133 -0
- package/dist/mcp/client.js +684 -0
- package/dist/mcp/mcp-apps.d.ts +70 -0
- package/dist/mcp/mcp-apps.js +1007 -0
- package/dist/tools/bash.d.ts +5 -0
- package/dist/tools/bash.js +195 -0
- package/dist/tools/browser.d.ts +92 -0
- package/dist/tools/browser.js +1570 -0
- package/dist/tools/extended.d.ts +6 -0
- package/dist/tools/extended.js +191 -0
- package/dist/tools/file.d.ts +10 -0
- package/dist/tools/file.js +382 -0
- package/dist/tools/github.d.ts +389 -0
- package/dist/tools/github.js +759 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.js +40 -0
- package/dist/tools/memory.d.ts +6 -0
- package/dist/tools/memory.js +197 -0
- package/dist/tools/registry.d.ts +29 -0
- package/dist/tools/registry.js +64 -0
- package/dist/tools/web.d.ts +6 -0
- package/dist/tools/web.js +150 -0
- package/dist/ui/renderer.d.ts +97 -0
- package/dist/ui/renderer.js +279 -0
- package/dist/ui/theme.d.ts +27 -0
- package/dist/ui/theme.js +106 -0
- package/package.json +83 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// NeuroCLI - Image/Multimodal Support
|
|
3
|
+
// Base64 image encoding for API calls, image file detection,
|
|
4
|
+
// screenshot analysis, PNG/JPG/GIF/WebP support
|
|
5
|
+
// Integration with models that support vision
|
|
6
|
+
// ============================================================
|
|
7
|
+
import { readFileSync, existsSync, statSync } from 'fs';
|
|
8
|
+
import { join, extname, basename } from 'path';
|
|
9
|
+
import chalk from 'chalk';
|
|
10
|
+
// -----------------------------------------------------------
|
|
11
|
+
// Constants
|
|
12
|
+
// -----------------------------------------------------------
|
|
13
|
+
const FORMAT_MIME_MAP = {
|
|
14
|
+
png: 'image/png',
|
|
15
|
+
jpeg: 'image/jpeg',
|
|
16
|
+
gif: 'image/gif',
|
|
17
|
+
webp: 'image/webp',
|
|
18
|
+
};
|
|
19
|
+
const EXT_FORMAT_MAP = {
|
|
20
|
+
'.png': 'png',
|
|
21
|
+
'.jpg': 'jpeg',
|
|
22
|
+
'.jpeg': 'jpeg',
|
|
23
|
+
'.gif': 'gif',
|
|
24
|
+
'.webp': 'webp',
|
|
25
|
+
};
|
|
26
|
+
// Known vision-capable models
|
|
27
|
+
const VISION_MODELS = {
|
|
28
|
+
'openai/gpt-4o': { modelId: 'openai/gpt-4o', supportsVision: true, maxImages: 10 },
|
|
29
|
+
'openai/gpt-4o-mini': { modelId: 'openai/gpt-4o-mini', supportsVision: true, maxImages: 10 },
|
|
30
|
+
'anthropic/claude-3.5-sonnet': { modelId: 'anthropic/claude-3.5-sonnet', supportsVision: true, maxImages: 20 },
|
|
31
|
+
'google/gemini-pro-vision': { modelId: 'google/gemini-pro-vision', supportsVision: true, maxImages: 16 },
|
|
32
|
+
'meta-llama/llama-3.2-11b-vision-instruct': { modelId: 'meta-llama/llama-3.2-11b-vision-instruct', supportsVision: true, maxImages: 5 },
|
|
33
|
+
};
|
|
34
|
+
const DEFAULT_CONFIG = {
|
|
35
|
+
maxImageSize: 20 * 1024 * 1024, // 20MB
|
|
36
|
+
supportedFormats: ['png', 'jpeg', 'gif', 'webp'],
|
|
37
|
+
autoDetectImages: true,
|
|
38
|
+
autoResize: true,
|
|
39
|
+
maxDimension: 2048,
|
|
40
|
+
jpegQuality: 85,
|
|
41
|
+
};
|
|
42
|
+
// -----------------------------------------------------------
|
|
43
|
+
// MultimodalSupport
|
|
44
|
+
// -----------------------------------------------------------
|
|
45
|
+
export class MultimodalSupport {
|
|
46
|
+
config;
|
|
47
|
+
loadedImages = new Map();
|
|
48
|
+
constructor(config) {
|
|
49
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
50
|
+
}
|
|
51
|
+
// ----------------------------------------------------------
|
|
52
|
+
// Public API
|
|
53
|
+
// ----------------------------------------------------------
|
|
54
|
+
/**
|
|
55
|
+
* Load an image from a file path and return base64 encoded content
|
|
56
|
+
*/
|
|
57
|
+
loadImage(filePath) {
|
|
58
|
+
const resolvedPath = this.resolvePath(filePath);
|
|
59
|
+
if (!existsSync(resolvedPath)) {
|
|
60
|
+
throw new Error(`Image file not found: ${resolvedPath}`);
|
|
61
|
+
}
|
|
62
|
+
const stat = statSync(resolvedPath);
|
|
63
|
+
if (stat.size > this.config.maxImageSize) {
|
|
64
|
+
throw new Error(`Image file too large: ${stat.size} bytes (max: ${this.config.maxImageSize} bytes)`);
|
|
65
|
+
}
|
|
66
|
+
const ext = extname(resolvedPath).toLowerCase();
|
|
67
|
+
const format = EXT_FORMAT_MAP[ext];
|
|
68
|
+
if (!format || !this.config.supportedFormats.includes(format)) {
|
|
69
|
+
throw new Error(`Unsupported image format: ${ext}. Supported: ${this.config.supportedFormats.join(', ')}`);
|
|
70
|
+
}
|
|
71
|
+
const data = readFileSync(resolvedPath);
|
|
72
|
+
const base64 = data.toString('base64');
|
|
73
|
+
const mimeType = FORMAT_MIME_MAP[format];
|
|
74
|
+
const content = {
|
|
75
|
+
base64,
|
|
76
|
+
mimeType,
|
|
77
|
+
filePath: resolvedPath,
|
|
78
|
+
size: stat.size,
|
|
79
|
+
format,
|
|
80
|
+
};
|
|
81
|
+
// Cache the loaded image
|
|
82
|
+
this.loadedImages.set(resolvedPath, content);
|
|
83
|
+
return content;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Load multiple images from file paths
|
|
87
|
+
*/
|
|
88
|
+
loadImages(filePaths) {
|
|
89
|
+
const results = [];
|
|
90
|
+
for (const path of filePaths) {
|
|
91
|
+
try {
|
|
92
|
+
results.push(this.loadImage(path));
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
console.log(chalk.yellow(`Skipping image ${path}: ${error instanceof Error ? error.message : String(error)}`));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return results;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Build a multimodal message with text and images
|
|
102
|
+
*/
|
|
103
|
+
buildMessage(text, images, detail = 'auto') {
|
|
104
|
+
const parts = [];
|
|
105
|
+
// Add text part
|
|
106
|
+
if (text) {
|
|
107
|
+
parts.push({ type: 'text', text });
|
|
108
|
+
}
|
|
109
|
+
// Add image parts
|
|
110
|
+
for (const image of images) {
|
|
111
|
+
const dataUrl = `data:${image.mimeType};base64,${image.base64}`;
|
|
112
|
+
parts.push({
|
|
113
|
+
type: 'image_url',
|
|
114
|
+
image_url: { url: dataUrl, detail },
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
role: 'user',
|
|
119
|
+
content: parts,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Build a multimodal message from text and image file paths
|
|
124
|
+
*/
|
|
125
|
+
buildMessageFromPaths(text, imagePaths, detail) {
|
|
126
|
+
const images = this.loadImages(imagePaths);
|
|
127
|
+
return this.buildMessage(text, images, detail);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Detect image references in a text prompt
|
|
131
|
+
* Supports: @image:path, , file paths ending in image extensions
|
|
132
|
+
*/
|
|
133
|
+
detectImageReferences(text) {
|
|
134
|
+
if (!this.config.autoDetectImages)
|
|
135
|
+
return [];
|
|
136
|
+
const paths = [];
|
|
137
|
+
// Match @image:path syntax
|
|
138
|
+
const imageRefRegex = /@image:([^\s]+)/g;
|
|
139
|
+
let match;
|
|
140
|
+
while ((match = imageRefRegex.exec(text)) !== null) {
|
|
141
|
+
paths.push(match[1]);
|
|
142
|
+
}
|
|
143
|
+
// Match markdown image syntax 
|
|
144
|
+
const mdImageRegex = /!\[.*?\]\(([^)]+)\)/g;
|
|
145
|
+
while ((match = mdImageRegex.exec(text)) !== null) {
|
|
146
|
+
paths.push(match[1]);
|
|
147
|
+
}
|
|
148
|
+
// Match file paths ending in image extensions
|
|
149
|
+
const extPattern = this.config.supportedFormats
|
|
150
|
+
.flatMap(f => {
|
|
151
|
+
switch (f) {
|
|
152
|
+
case 'jpeg': return ['.jpg', '.jpeg'];
|
|
153
|
+
default: return [`.${f}`];
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
.join('|');
|
|
157
|
+
const pathRegex = new RegExp(`(?:^|\\s)([\\S]+(?:${extPattern}))(?:\\s|$)`, 'gi');
|
|
158
|
+
while ((match = pathRegex.exec(text)) !== null) {
|
|
159
|
+
const potentialPath = match[1];
|
|
160
|
+
// Only include if it looks like a file path (starts with ./, /, ~, or contains path separators)
|
|
161
|
+
if (potentialPath.startsWith('./') || potentialPath.startsWith('/') || potentialPath.startsWith('~') || potentialPath.includes('/')) {
|
|
162
|
+
paths.push(potentialPath);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return [...new Set(paths)];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Process a user prompt that may contain image references
|
|
169
|
+
* Returns the cleaned text and loaded images
|
|
170
|
+
*/
|
|
171
|
+
processPrompt(text) {
|
|
172
|
+
const imagePaths = this.detectImageReferences(text);
|
|
173
|
+
const images = [];
|
|
174
|
+
let cleanedText = text;
|
|
175
|
+
for (const path of imagePaths) {
|
|
176
|
+
try {
|
|
177
|
+
const image = this.loadImage(path);
|
|
178
|
+
images.push(image);
|
|
179
|
+
// Remove image reference syntax from text
|
|
180
|
+
cleanedText = cleanedText.replace(`@image:${path}`, `[image: ${basename(path)}]`);
|
|
181
|
+
cleanedText = cleanedText.replace(new RegExp(`!\\[.*?\\]\\(${path.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\)`, 'g'), `[image: ${basename(path)}]`);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
console.log(chalk.yellow(`Could not load image ${path}: ${error instanceof Error ? error.message : String(error)}`));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return { text: cleanedText.trim(), images };
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Check if a model supports vision
|
|
191
|
+
*/
|
|
192
|
+
isVisionModel(modelId) {
|
|
193
|
+
// Check known vision models
|
|
194
|
+
if (VISION_MODELS[modelId])
|
|
195
|
+
return VISION_MODELS[modelId].supportsVision;
|
|
196
|
+
// Check by model name patterns
|
|
197
|
+
const lower = modelId.toLowerCase();
|
|
198
|
+
return (lower.includes('vision') ||
|
|
199
|
+
lower.includes('gpt-4o') ||
|
|
200
|
+
lower.includes('claude-3') ||
|
|
201
|
+
lower.includes('gemini') ||
|
|
202
|
+
lower.includes('llama-3.2') ||
|
|
203
|
+
lower.includes('qwen-vl') ||
|
|
204
|
+
lower.includes('cogvlm') ||
|
|
205
|
+
lower.includes('llava'));
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Get vision model info
|
|
209
|
+
*/
|
|
210
|
+
getVisionModelInfo(modelId) {
|
|
211
|
+
if (VISION_MODELS[modelId])
|
|
212
|
+
return VISION_MODELS[modelId];
|
|
213
|
+
if (this.isVisionModel(modelId)) {
|
|
214
|
+
return { modelId, supportsVision: true, maxImages: 10 };
|
|
215
|
+
}
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Check if a file is a supported image
|
|
220
|
+
*/
|
|
221
|
+
isImageFile(filePath) {
|
|
222
|
+
const ext = extname(filePath).toLowerCase();
|
|
223
|
+
const format = EXT_FORMAT_MAP[ext];
|
|
224
|
+
return format !== undefined && this.config.supportedFormats.includes(format);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Get the format of an image file
|
|
228
|
+
*/
|
|
229
|
+
getImageFormat(filePath) {
|
|
230
|
+
const ext = extname(filePath).toLowerCase();
|
|
231
|
+
return EXT_FORMAT_MAP[ext] || null;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Get base64 data URL for an image
|
|
235
|
+
*/
|
|
236
|
+
getDataUrl(image) {
|
|
237
|
+
return `data:${image.mimeType};base64,${image.base64}`;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Get all loaded images
|
|
241
|
+
*/
|
|
242
|
+
getLoadedImages() {
|
|
243
|
+
return Array.from(this.loadedImages.values());
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Clear the image cache
|
|
247
|
+
*/
|
|
248
|
+
clearCache() {
|
|
249
|
+
this.loadedImages.clear();
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Get supported formats
|
|
253
|
+
*/
|
|
254
|
+
getSupportedFormats() {
|
|
255
|
+
return [...this.config.supportedFormats];
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Get config
|
|
259
|
+
*/
|
|
260
|
+
getConfig() {
|
|
261
|
+
return { ...this.config };
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Print multimodal status
|
|
265
|
+
*/
|
|
266
|
+
printStatus() {
|
|
267
|
+
console.log('');
|
|
268
|
+
console.log(chalk.bold('--- NeuroCLI Multimodal Support ---'));
|
|
269
|
+
console.log(` Supported formats: ${chalk.cyan(this.config.supportedFormats.join(', '))}`);
|
|
270
|
+
console.log(` Max image size: ${chalk.yellow(`${(this.config.maxImageSize / 1024 / 1024).toFixed(1)}MB`)}`);
|
|
271
|
+
console.log(` Auto-detect: ${this.config.autoDetectImages ? chalk.green('enabled') : chalk.gray('disabled')}`);
|
|
272
|
+
console.log(` Loaded images: ${this.loadedImages.size}`);
|
|
273
|
+
console.log('');
|
|
274
|
+
}
|
|
275
|
+
// ----------------------------------------------------------
|
|
276
|
+
// Private helpers
|
|
277
|
+
// ----------------------------------------------------------
|
|
278
|
+
resolvePath(filePath) {
|
|
279
|
+
if (filePath.startsWith('/'))
|
|
280
|
+
return filePath;
|
|
281
|
+
if (filePath.startsWith('~/'))
|
|
282
|
+
return join(require('os').homedir(), filePath.slice(2));
|
|
283
|
+
return join(process.cwd(), filePath);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=multimodal.js.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export interface ObservabilityConfig {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
serviceName: string;
|
|
4
|
+
endpoint: string;
|
|
5
|
+
headers: Record<string, string>;
|
|
6
|
+
exportInterval: number;
|
|
7
|
+
maxBatchSize: number;
|
|
8
|
+
consoleExporter: boolean;
|
|
9
|
+
sampleRate: number;
|
|
10
|
+
}
|
|
11
|
+
export interface SpanEvent {
|
|
12
|
+
name: string;
|
|
13
|
+
timestamp: number;
|
|
14
|
+
attributes: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface Span {
|
|
17
|
+
traceId: string;
|
|
18
|
+
spanId: string;
|
|
19
|
+
parentSpanId?: string;
|
|
20
|
+
name: string;
|
|
21
|
+
kind: 'internal' | 'client' | 'server';
|
|
22
|
+
startTime: number;
|
|
23
|
+
endTime: number;
|
|
24
|
+
attributes: Record<string, unknown>;
|
|
25
|
+
events: SpanEvent[];
|
|
26
|
+
status: {
|
|
27
|
+
code: 'ok' | 'error';
|
|
28
|
+
message?: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface Metric {
|
|
32
|
+
name: string;
|
|
33
|
+
type: 'counter' | 'gauge' | 'histogram';
|
|
34
|
+
value: number;
|
|
35
|
+
attributes: Record<string, unknown>;
|
|
36
|
+
timestamp: number;
|
|
37
|
+
}
|
|
38
|
+
export declare class ObservabilityManager {
|
|
39
|
+
private config;
|
|
40
|
+
private pendingSpans;
|
|
41
|
+
private pendingMetrics;
|
|
42
|
+
private spanBuffer;
|
|
43
|
+
private sessionTraceId;
|
|
44
|
+
private sessionRootSpanId;
|
|
45
|
+
private exportTimer;
|
|
46
|
+
private activeSpans;
|
|
47
|
+
private histogramBuckets;
|
|
48
|
+
private counters;
|
|
49
|
+
private gauges;
|
|
50
|
+
constructor(config: ObservabilityConfig);
|
|
51
|
+
start(): void;
|
|
52
|
+
stop(): Promise<void>;
|
|
53
|
+
private shouldSample;
|
|
54
|
+
startSpan(name: string, parent?: Span, attributes?: Record<string, unknown>): Span;
|
|
55
|
+
endSpan(span: Span, status?: Span['status']): void;
|
|
56
|
+
addEvent(span: Span, name: string, attributes?: Record<string, unknown>): void;
|
|
57
|
+
incrementCounter(name: string, value?: number, attributes?: Record<string, unknown>): void;
|
|
58
|
+
recordGauge(name: string, value: number, attributes?: Record<string, unknown>): void;
|
|
59
|
+
recordHistogram(name: string, value: number, attributes?: Record<string, unknown>): void;
|
|
60
|
+
traceLLMRequest(model: string, promptTokens: number, completionTokens: number, duration: number, cost: number): Span;
|
|
61
|
+
traceToolCall(tool: string, args: unknown, duration: number, success: boolean): Span;
|
|
62
|
+
traceAgentAction(agent: string, action: string, duration: number): Span;
|
|
63
|
+
flush(): Promise<void>;
|
|
64
|
+
getPendingCount(): {
|
|
65
|
+
spans: number;
|
|
66
|
+
metrics: number;
|
|
67
|
+
};
|
|
68
|
+
startSession(sessionName?: string): Span;
|
|
69
|
+
endSession(rootSpan: Span): void;
|
|
70
|
+
getSessionTrace(): Span[];
|
|
71
|
+
printTrace(): string;
|
|
72
|
+
getConfig(): ObservabilityConfig;
|
|
73
|
+
updateConfig(partial: Partial<ObservabilityConfig>): void;
|
|
74
|
+
getSessionTraceId(): string;
|
|
75
|
+
setSessionTraceId(traceId: string): void;
|
|
76
|
+
getActiveSpanCount(): number;
|
|
77
|
+
getCounterValue(name: string, attributes?: Record<string, unknown>): number;
|
|
78
|
+
getGaugeValue(name: string, attributes?: Record<string, unknown>): number | undefined;
|
|
79
|
+
getHistogramSummary(name: string, attributes?: Record<string, unknown>): {
|
|
80
|
+
count: number;
|
|
81
|
+
sum: number;
|
|
82
|
+
min: number;
|
|
83
|
+
max: number;
|
|
84
|
+
avg: number;
|
|
85
|
+
} | undefined;
|
|
86
|
+
private createNoopSpan;
|
|
87
|
+
private printSpanToConsole;
|
|
88
|
+
}
|
|
89
|
+
export declare function defaultObservabilityConfig(): ObservabilityConfig;
|
|
90
|
+
export declare function initObservability(config?: Partial<ObservabilityConfig>): ObservabilityManager;
|
|
91
|
+
export declare function getObservability(): ObservabilityManager | null;
|
|
92
|
+
export declare function resetObservability(): void;
|
|
93
|
+
//# sourceMappingURL=observability.d.ts.map
|