@probelabs/probe 0.6.0-rc305 → 0.6.0-rc307
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/bin/binaries/{probe-v0.6.0-rc305-aarch64-apple-darwin.tar.gz → probe-v0.6.0-rc307-aarch64-apple-darwin.tar.gz} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc305-aarch64-unknown-linux-musl.tar.gz → probe-v0.6.0-rc307-aarch64-unknown-linux-musl.tar.gz} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc305-x86_64-apple-darwin.tar.gz → probe-v0.6.0-rc307-x86_64-apple-darwin.tar.gz} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc305-x86_64-pc-windows-msvc.zip → probe-v0.6.0-rc307-x86_64-pc-windows-msvc.zip} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc305-x86_64-unknown-linux-musl.tar.gz → probe-v0.6.0-rc307-x86_64-unknown-linux-musl.tar.gz} +0 -0
- package/build/agent/ProbeAgent.js +137 -101
- package/build/agent/mediaConfig.js +122 -0
- package/build/agent/tools.js +2 -0
- package/build/delegate.js +6 -2
- package/build/index.js +2 -0
- package/build/tools/common.js +4 -0
- package/build/tools/index.js +1 -0
- package/build/tools/vercel.js +4 -1
- package/cjs/agent/ProbeAgent.cjs +157 -83
- package/cjs/index.cjs +160 -83
- package/package.json +1 -1
- package/src/agent/ProbeAgent.js +137 -101
- package/src/agent/mediaConfig.js +122 -0
- package/src/agent/tools.js +2 -0
- package/src/delegate.js +6 -2
- package/src/index.js +2 -0
- package/src/tools/common.js +4 -0
- package/src/tools/index.js +1 -0
- package/src/tools/vercel.js +4 -1
package/cjs/index.cjs
CHANGED
|
@@ -19578,10 +19578,10 @@ var init_dist2 = __esm({
|
|
|
19578
19578
|
"ETIMEDOUT",
|
|
19579
19579
|
"EPIPE"
|
|
19580
19580
|
];
|
|
19581
|
-
VERSION = true ? "4.0.
|
|
19581
|
+
VERSION = true ? "4.0.21" : "0.0.0-test";
|
|
19582
19582
|
suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
19583
19583
|
suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
19584
|
-
ignoreOverride = Symbol(
|
|
19584
|
+
ignoreOverride = /* @__PURE__ */ Symbol(
|
|
19585
19585
|
"Let zodToJsonSchema decide on which parser to use"
|
|
19586
19586
|
);
|
|
19587
19587
|
defaultOptions = {
|
|
@@ -19917,7 +19917,7 @@ var init_dist2 = __esm({
|
|
|
19917
19917
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
19918
19918
|
return combined;
|
|
19919
19919
|
};
|
|
19920
|
-
schemaSymbol = Symbol.for("vercel.ai.schema");
|
|
19920
|
+
schemaSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
19921
19921
|
getOriginalFetch2 = () => globalThis.fetch;
|
|
19922
19922
|
postJsonToApi = async ({
|
|
19923
19923
|
url: url2,
|
|
@@ -22009,7 +22009,8 @@ async function prepareTools({
|
|
|
22009
22009
|
} = await (0, import_internal2.prepareTools)({
|
|
22010
22010
|
tools: ProviderTools,
|
|
22011
22011
|
toolChoice,
|
|
22012
|
-
supportsStructuredOutput: false
|
|
22012
|
+
supportsStructuredOutput: false,
|
|
22013
|
+
supportsStrictTools: false
|
|
22013
22014
|
});
|
|
22014
22015
|
toolWarnings.push(...anthropicToolWarnings);
|
|
22015
22016
|
anthropicBetas.forEach((beta) => betas.add(beta));
|
|
@@ -24029,7 +24030,7 @@ var init_dist3 = __esm({
|
|
|
24029
24030
|
details: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
24030
24031
|
preview: external_exports.unknown().optional()
|
|
24031
24032
|
});
|
|
24032
|
-
VERSION2 = true ? "4.0.
|
|
24033
|
+
VERSION2 = true ? "4.0.82" : "0.0.0-test";
|
|
24033
24034
|
bedrockRerankingResponseSchema = lazySchema(
|
|
24034
24035
|
() => zodSchema(
|
|
24035
24036
|
external_exports.object({
|
|
@@ -26761,7 +26762,10 @@ var init_HookManager = __esm({
|
|
|
26761
26762
|
}
|
|
26762
26763
|
});
|
|
26763
26764
|
|
|
26764
|
-
// src/agent/
|
|
26765
|
+
// src/agent/mediaConfig.js
|
|
26766
|
+
function isDocumentExtension(extension) {
|
|
26767
|
+
return SUPPORTED_DOCUMENT_EXTENSIONS.includes(extension?.toLowerCase());
|
|
26768
|
+
}
|
|
26765
26769
|
function isFormatSupportedByProvider(extension, provider) {
|
|
26766
26770
|
if (!extension || typeof extension !== "string") {
|
|
26767
26771
|
return false;
|
|
@@ -26770,7 +26774,7 @@ function isFormatSupportedByProvider(extension, provider) {
|
|
|
26770
26774
|
return false;
|
|
26771
26775
|
}
|
|
26772
26776
|
const ext2 = extension.toLowerCase();
|
|
26773
|
-
if (!
|
|
26777
|
+
if (!SUPPORTED_MEDIA_EXTENSIONS.includes(ext2)) {
|
|
26774
26778
|
return false;
|
|
26775
26779
|
}
|
|
26776
26780
|
if (!provider || typeof provider !== "string") {
|
|
@@ -26782,18 +26786,21 @@ function isFormatSupportedByProvider(extension, provider) {
|
|
|
26782
26786
|
}
|
|
26783
26787
|
return true;
|
|
26784
26788
|
}
|
|
26785
|
-
var SUPPORTED_IMAGE_EXTENSIONS,
|
|
26786
|
-
var
|
|
26787
|
-
"src/agent/
|
|
26789
|
+
var SUPPORTED_IMAGE_EXTENSIONS, SUPPORTED_DOCUMENT_EXTENSIONS, SUPPORTED_MEDIA_EXTENSIONS, MEDIA_MIME_TYPES, PROVIDER_UNSUPPORTED_FORMATS;
|
|
26790
|
+
var init_mediaConfig = __esm({
|
|
26791
|
+
"src/agent/mediaConfig.js"() {
|
|
26788
26792
|
"use strict";
|
|
26789
26793
|
SUPPORTED_IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "webp", "bmp", "svg"];
|
|
26790
|
-
|
|
26794
|
+
SUPPORTED_DOCUMENT_EXTENSIONS = ["pdf"];
|
|
26795
|
+
SUPPORTED_MEDIA_EXTENSIONS = [...SUPPORTED_IMAGE_EXTENSIONS, ...SUPPORTED_DOCUMENT_EXTENSIONS];
|
|
26796
|
+
MEDIA_MIME_TYPES = {
|
|
26791
26797
|
"png": "image/png",
|
|
26792
26798
|
"jpg": "image/jpeg",
|
|
26793
26799
|
"jpeg": "image/jpeg",
|
|
26794
26800
|
"webp": "image/webp",
|
|
26795
26801
|
"bmp": "image/bmp",
|
|
26796
|
-
"svg": "image/svg+xml"
|
|
26802
|
+
"svg": "image/svg+xml",
|
|
26803
|
+
"pdf": "application/pdf"
|
|
26797
26804
|
};
|
|
26798
26805
|
PROVIDER_UNSUPPORTED_FORMATS = {
|
|
26799
26806
|
"google": ["svg"]
|
|
@@ -27806,7 +27813,7 @@ function resolveTargetPath(target, cwd) {
|
|
|
27806
27813
|
}
|
|
27807
27814
|
return filePart + suffix;
|
|
27808
27815
|
}
|
|
27809
|
-
var import_path6, searchDelegateSchema, searchSchema, searchAllSchema, querySchema, extractSchema, delegateSchema, listSkillsSchema, useSkillSchema, listFilesSchema, searchFilesSchema, readImageSchema, bashSchema, analyzeAllSchema, executePlanSchema, cleanupExecutePlanSchema, searchDescription, searchDelegateDescription, queryDescription, extractDescription, delegateDescription, bashDescription, analyzeAllDescription;
|
|
27816
|
+
var import_path6, searchDelegateSchema, searchSchema, searchAllSchema, querySchema, extractSchema, delegateSchema, listSkillsSchema, useSkillSchema, listFilesSchema, searchFilesSchema, readImageSchema, readMediaSchema, bashSchema, analyzeAllSchema, executePlanSchema, cleanupExecutePlanSchema, searchDescription, searchDelegateDescription, queryDescription, extractDescription, delegateDescription, bashDescription, analyzeAllDescription;
|
|
27810
27817
|
var init_common = __esm({
|
|
27811
27818
|
"src/tools/common.js"() {
|
|
27812
27819
|
"use strict";
|
|
@@ -27862,6 +27869,9 @@ var init_common = __esm({
|
|
|
27862
27869
|
readImageSchema = external_exports2.object({
|
|
27863
27870
|
path: external_exports2.string().describe("Path to the image file to read. Supports png, jpg, jpeg, webp, bmp, and svg formats.")
|
|
27864
27871
|
});
|
|
27872
|
+
readMediaSchema = external_exports2.object({
|
|
27873
|
+
path: external_exports2.string().describe("Path to the media file to read. Supports images (png, jpg, jpeg, webp, bmp, svg) and documents (pdf).")
|
|
27874
|
+
});
|
|
27865
27875
|
bashSchema = external_exports2.object({
|
|
27866
27876
|
command: external_exports2.string().describe("The bash command to execute"),
|
|
27867
27877
|
workingDirectory: external_exports2.string().optional().describe("Directory to execute the command in (optional)"),
|
|
@@ -97485,7 +97495,7 @@ function debugLogToolResults(toolResults) {
|
|
|
97485
97495
|
console.log(`[DEBUG] tool: ${tr.toolName} | args: ${debugTruncate(argsStr)} | result: ${debugTruncate(resultStr)}`);
|
|
97486
97496
|
}
|
|
97487
97497
|
}
|
|
97488
|
-
var import_dotenv, import_ai4, import_crypto8, import_events4, import_fs11, import_promises6, import_path16, ENGINE_ACTIVITY_TIMEOUT_DEFAULT, ENGINE_ACTIVITY_TIMEOUT_MIN, ENGINE_ACTIVITY_TIMEOUT_MAX, MAX_TOOL_ITERATIONS, MAX_HISTORY_MESSAGES, MAX_IMAGE_FILE_SIZE, ProbeAgent;
|
|
97498
|
+
var import_dotenv, import_ai4, import_crypto8, import_events4, import_fs11, import_promises6, import_path16, ENGINE_ACTIVITY_TIMEOUT_DEFAULT, ENGINE_ACTIVITY_TIMEOUT_MIN, ENGINE_ACTIVITY_TIMEOUT_MAX, MAX_TOOL_ITERATIONS, MAX_HISTORY_MESSAGES, MAX_IMAGE_FILE_SIZE, MAX_DOCUMENT_FILE_SIZE, ProbeAgent;
|
|
97489
97499
|
var init_ProbeAgent = __esm({
|
|
97490
97500
|
"src/agent/ProbeAgent.js"() {
|
|
97491
97501
|
"use strict";
|
|
@@ -97501,7 +97511,7 @@ var init_ProbeAgent = __esm({
|
|
|
97501
97511
|
init_simpleTelemetry();
|
|
97502
97512
|
init_InMemoryStorageAdapter();
|
|
97503
97513
|
init_HookManager();
|
|
97504
|
-
|
|
97514
|
+
init_mediaConfig();
|
|
97505
97515
|
init_tools();
|
|
97506
97516
|
init_common();
|
|
97507
97517
|
init_taskTool();
|
|
@@ -97539,6 +97549,7 @@ var init_ProbeAgent = __esm({
|
|
|
97539
97549
|
})();
|
|
97540
97550
|
MAX_HISTORY_MESSAGES = 100;
|
|
97541
97551
|
MAX_IMAGE_FILE_SIZE = 20 * 1024 * 1024;
|
|
97552
|
+
MAX_DOCUMENT_FILE_SIZE = 32 * 1024 * 1024;
|
|
97542
97553
|
ProbeAgent = class _ProbeAgent {
|
|
97543
97554
|
/**
|
|
97544
97555
|
* Create a new ProbeAgent instance
|
|
@@ -98107,6 +98118,18 @@ var init_ProbeAgent = __esm({
|
|
|
98107
98118
|
concurrencyLimiter: this.concurrencyLimiter,
|
|
98108
98119
|
// Global AI concurrency limiter
|
|
98109
98120
|
isToolAllowed,
|
|
98121
|
+
// MCP config for delegate subagents — these are set in constructor before tools init,
|
|
98122
|
+
// so they're available here. The delegate tool closure needs them to pass to subagents
|
|
98123
|
+
// so they can create their own MCPXmlBridge instances.
|
|
98124
|
+
enableMcp: this.enableMcp,
|
|
98125
|
+
mcpConfig: this.mcpConfig,
|
|
98126
|
+
mcpConfigPath: this.mcpConfigPath,
|
|
98127
|
+
// Pass parent's prompt settings so delegate subagents inherit the same persona/capabilities.
|
|
98128
|
+
// Without promptType, delegate() defaulted to 'code-researcher' which doesn't exist,
|
|
98129
|
+
// causing fallback to the read-only 'code-explorer' prompt.
|
|
98130
|
+
promptType: this.promptType,
|
|
98131
|
+
customPrompt: this.customPrompt,
|
|
98132
|
+
completionPrompt: this.completionPrompt,
|
|
98110
98133
|
// Lazy MCP getters — MCP is initialized after tools are created, so we use
|
|
98111
98134
|
// getter functions that resolve at call-time to get the current MCP state
|
|
98112
98135
|
getMcpBridge: () => this.mcpBridge,
|
|
@@ -98155,28 +98178,29 @@ var init_ProbeAgent = __esm({
|
|
|
98155
98178
|
this.toolImplementations.useSkill = useSkillToolInstance;
|
|
98156
98179
|
}
|
|
98157
98180
|
}
|
|
98158
|
-
|
|
98159
|
-
|
|
98160
|
-
|
|
98161
|
-
|
|
98162
|
-
|
|
98163
|
-
|
|
98164
|
-
|
|
98165
|
-
|
|
98166
|
-
|
|
98167
|
-
|
|
98168
|
-
|
|
98169
|
-
|
|
98170
|
-
|
|
98171
|
-
|
|
98172
|
-
|
|
98173
|
-
|
|
98174
|
-
|
|
98175
|
-
|
|
98176
|
-
|
|
98177
|
-
|
|
98178
|
-
|
|
98179
|
-
};
|
|
98181
|
+
const readMediaExecute = async (params) => {
|
|
98182
|
+
const mediaPath = params.path;
|
|
98183
|
+
if (!mediaPath) {
|
|
98184
|
+
throw new Error("File path is required");
|
|
98185
|
+
}
|
|
98186
|
+
const filename = (0, import_path16.basename)(mediaPath);
|
|
98187
|
+
const extension = filename.toLowerCase().split(".").pop();
|
|
98188
|
+
if (!extension || !SUPPORTED_MEDIA_EXTENSIONS.includes(extension)) {
|
|
98189
|
+
throw new Error(`Unsupported file format: ${extension}. Supported formats: ${SUPPORTED_MEDIA_EXTENSIONS.join(", ")}`);
|
|
98190
|
+
}
|
|
98191
|
+
if (this.apiType && !isFormatSupportedByProvider(extension, this.apiType)) {
|
|
98192
|
+
throw new Error(`File format '${extension}' is not supported by the current AI provider (${this.apiType}). Try converting to a different format.`);
|
|
98193
|
+
}
|
|
98194
|
+
const loaded = await this.loadMediaIfValid(mediaPath);
|
|
98195
|
+
if (!loaded) {
|
|
98196
|
+
throw new Error(`Failed to load file: ${mediaPath}. The file may not exist, be too large, have an unsupported format, or be outside allowed directories.`);
|
|
98197
|
+
}
|
|
98198
|
+
const mediaType = isDocumentExtension(extension) ? "Document" : "Image";
|
|
98199
|
+
return `${mediaType} loaded successfully: ${mediaPath}. The file is now available for analysis in the conversation.`;
|
|
98200
|
+
};
|
|
98201
|
+
if (isToolAllowed("readMedia") || isToolAllowed("readImage")) {
|
|
98202
|
+
this.toolImplementations.readMedia = { execute: readMediaExecute };
|
|
98203
|
+
this.toolImplementations.readImage = { execute: readMediaExecute };
|
|
98180
98204
|
}
|
|
98181
98205
|
if (this.enableBash && wrappedTools.bashToolInstance && isToolAllowed("bash")) {
|
|
98182
98206
|
this.toolImplementations.bash = wrappedTools.bashToolInstance;
|
|
@@ -99172,9 +99196,9 @@ var init_ProbeAgent = __esm({
|
|
|
99172
99196
|
schema: searchFilesSchema,
|
|
99173
99197
|
description: "Find files matching a glob pattern with recursive search capability."
|
|
99174
99198
|
},
|
|
99175
|
-
|
|
99176
|
-
schema:
|
|
99177
|
-
description: "Read and load
|
|
99199
|
+
readMedia: {
|
|
99200
|
+
schema: readMediaSchema,
|
|
99201
|
+
description: "Read and load a media file (image or PDF document) for AI analysis. Supports: png, jpg, jpeg, webp, bmp, svg, pdf."
|
|
99178
99202
|
},
|
|
99179
99203
|
listSkills: {
|
|
99180
99204
|
schema: listSkillsSchema,
|
|
@@ -99319,7 +99343,7 @@ var init_ProbeAgent = __esm({
|
|
|
99319
99343
|
async processImageReferences(content) {
|
|
99320
99344
|
if (!content) return;
|
|
99321
99345
|
const listFilesDirectories = this.extractListFilesDirectories(content);
|
|
99322
|
-
const extensionsPattern = `(?:${
|
|
99346
|
+
const extensionsPattern = `(?:${SUPPORTED_MEDIA_EXTENSIONS.join("|")})`;
|
|
99323
99347
|
const imagePatterns = [
|
|
99324
99348
|
// Direct file path mentions: "./screenshot.png", "/path/to/image.jpg", etc.
|
|
99325
99349
|
new RegExp(`(?:\\.?\\.\\/)?[^\\s"'<>\\[\\]]+\\.${extensionsPattern}(?!\\w)`, "gi"),
|
|
@@ -99401,23 +99425,23 @@ var init_ProbeAgent = __esm({
|
|
|
99401
99425
|
return directories;
|
|
99402
99426
|
}
|
|
99403
99427
|
/**
|
|
99404
|
-
* Load and cache
|
|
99405
|
-
* @param {string}
|
|
99406
|
-
* @returns {Promise<boolean>} - True if
|
|
99428
|
+
* Load and cache a media file (image or PDF) if it's valid and accessible
|
|
99429
|
+
* @param {string} mediaPath - Path to the media file
|
|
99430
|
+
* @returns {Promise<boolean>} - True if file was loaded successfully
|
|
99407
99431
|
*/
|
|
99408
|
-
async
|
|
99432
|
+
async loadMediaIfValid(mediaPath) {
|
|
99409
99433
|
try {
|
|
99410
|
-
if (this.pendingImages.has(
|
|
99434
|
+
if (this.pendingImages.has(mediaPath)) {
|
|
99411
99435
|
if (this.debug) {
|
|
99412
|
-
console.log(`[DEBUG]
|
|
99436
|
+
console.log(`[DEBUG] Media already loaded: ${mediaPath}`);
|
|
99413
99437
|
}
|
|
99414
99438
|
return true;
|
|
99415
99439
|
}
|
|
99416
99440
|
const allowedDirs = this.allowedFolders && this.allowedFolders.length > 0 ? this.allowedFolders : [process.cwd()];
|
|
99417
99441
|
let absolutePath;
|
|
99418
99442
|
let isPathAllowed2 = false;
|
|
99419
|
-
if ((0, import_path16.isAbsolute)(
|
|
99420
|
-
absolutePath = safeRealpath((0, import_path16.resolve)(
|
|
99443
|
+
if ((0, import_path16.isAbsolute)(mediaPath)) {
|
|
99444
|
+
absolutePath = safeRealpath((0, import_path16.resolve)(mediaPath));
|
|
99421
99445
|
isPathAllowed2 = allowedDirs.some((dir) => {
|
|
99422
99446
|
const resolvedDir = safeRealpath(dir);
|
|
99423
99447
|
return absolutePath === resolvedDir || absolutePath.startsWith(resolvedDir + import_path16.sep);
|
|
@@ -99425,7 +99449,7 @@ var init_ProbeAgent = __esm({
|
|
|
99425
99449
|
} else {
|
|
99426
99450
|
for (const dir of allowedDirs) {
|
|
99427
99451
|
const resolvedDir = safeRealpath(dir);
|
|
99428
|
-
const resolvedPath = safeRealpath((0, import_path16.resolve)(dir,
|
|
99452
|
+
const resolvedPath = safeRealpath((0, import_path16.resolve)(dir, mediaPath));
|
|
99429
99453
|
if (resolvedPath === resolvedDir || resolvedPath.startsWith(resolvedDir + import_path16.sep)) {
|
|
99430
99454
|
absolutePath = resolvedPath;
|
|
99431
99455
|
isPathAllowed2 = true;
|
|
@@ -99435,7 +99459,7 @@ var init_ProbeAgent = __esm({
|
|
|
99435
99459
|
}
|
|
99436
99460
|
if (!isPathAllowed2) {
|
|
99437
99461
|
if (this.debug) {
|
|
99438
|
-
console.log(`[DEBUG]
|
|
99462
|
+
console.log(`[DEBUG] Media path outside allowed directories: ${mediaPath}`);
|
|
99439
99463
|
}
|
|
99440
99464
|
return false;
|
|
99441
99465
|
}
|
|
@@ -99444,91 +99468,126 @@ var init_ProbeAgent = __esm({
|
|
|
99444
99468
|
fileStats = await (0, import_promises6.stat)(absolutePath);
|
|
99445
99469
|
} catch (error40) {
|
|
99446
99470
|
if (this.debug) {
|
|
99447
|
-
console.log(`[DEBUG]
|
|
99471
|
+
console.log(`[DEBUG] Media file not found: ${absolutePath}`);
|
|
99448
99472
|
}
|
|
99449
99473
|
return false;
|
|
99450
99474
|
}
|
|
99451
|
-
|
|
99475
|
+
const extension = absolutePath.toLowerCase().split(".").pop();
|
|
99476
|
+
if (!SUPPORTED_MEDIA_EXTENSIONS.includes(extension)) {
|
|
99452
99477
|
if (this.debug) {
|
|
99453
|
-
console.log(`[DEBUG]
|
|
99478
|
+
console.log(`[DEBUG] Unsupported media format: ${extension}`);
|
|
99454
99479
|
}
|
|
99455
99480
|
return false;
|
|
99456
99481
|
}
|
|
99457
|
-
const
|
|
99458
|
-
if (
|
|
99482
|
+
const maxSize = isDocumentExtension(extension) ? MAX_DOCUMENT_FILE_SIZE : MAX_IMAGE_FILE_SIZE;
|
|
99483
|
+
if (fileStats.size > maxSize) {
|
|
99459
99484
|
if (this.debug) {
|
|
99460
|
-
console.log(`[DEBUG]
|
|
99485
|
+
console.log(`[DEBUG] Media file too large: ${absolutePath} (${fileStats.size} bytes, max: ${maxSize})`);
|
|
99461
99486
|
}
|
|
99462
99487
|
return false;
|
|
99463
99488
|
}
|
|
99464
|
-
const mimeType =
|
|
99489
|
+
const mimeType = MEDIA_MIME_TYPES[extension];
|
|
99465
99490
|
const fileBuffer = await (0, import_promises6.readFile)(absolutePath);
|
|
99466
99491
|
const base64Data = fileBuffer.toString("base64");
|
|
99467
|
-
|
|
99468
|
-
|
|
99492
|
+
if (isDocumentExtension(extension)) {
|
|
99493
|
+
this.pendingImages.set(mediaPath, {
|
|
99494
|
+
type: "document",
|
|
99495
|
+
mimeType,
|
|
99496
|
+
data: base64Data,
|
|
99497
|
+
filename: (0, import_path16.basename)(mediaPath)
|
|
99498
|
+
});
|
|
99499
|
+
} else {
|
|
99500
|
+
const dataUrl = `data:${mimeType};base64,${base64Data}`;
|
|
99501
|
+
this.pendingImages.set(mediaPath, dataUrl);
|
|
99502
|
+
}
|
|
99469
99503
|
if (this.debug) {
|
|
99470
|
-
console.log(`[DEBUG] Successfully loaded
|
|
99504
|
+
console.log(`[DEBUG] Successfully loaded media: ${mediaPath} (${fileBuffer.length} bytes, ${mimeType})`);
|
|
99471
99505
|
}
|
|
99472
99506
|
return true;
|
|
99473
99507
|
} catch (error40) {
|
|
99474
99508
|
if (this.debug) {
|
|
99475
|
-
console.log(`[DEBUG] Failed to load
|
|
99509
|
+
console.log(`[DEBUG] Failed to load media ${mediaPath}: ${error40.message}`);
|
|
99476
99510
|
}
|
|
99477
99511
|
return false;
|
|
99478
99512
|
}
|
|
99479
99513
|
}
|
|
99514
|
+
/**
|
|
99515
|
+
* Backward-compatible alias for loadMediaIfValid
|
|
99516
|
+
* @param {string} imagePath - Path to the image file
|
|
99517
|
+
* @returns {Promise<boolean>}
|
|
99518
|
+
*/
|
|
99519
|
+
async loadImageIfValid(imagePath) {
|
|
99520
|
+
return this.loadMediaIfValid(imagePath);
|
|
99521
|
+
}
|
|
99480
99522
|
/**
|
|
99481
99523
|
* Get all currently loaded images as an array for AI model consumption
|
|
99482
|
-
* @returns {Array<string>} - Array of base64 data URLs
|
|
99524
|
+
* @returns {Array<string>} - Array of base64 data URLs (images only, for backward compat)
|
|
99483
99525
|
*/
|
|
99484
99526
|
getCurrentImages() {
|
|
99485
|
-
return Array.from(this.pendingImages.values());
|
|
99527
|
+
return Array.from(this.pendingImages.values()).filter((v) => typeof v === "string");
|
|
99528
|
+
}
|
|
99529
|
+
/**
|
|
99530
|
+
* Get all currently loaded media as an array of content parts
|
|
99531
|
+
* @returns {Array<Object>} - Array of Vercel AI SDK content parts
|
|
99532
|
+
*/
|
|
99533
|
+
getCurrentMedia() {
|
|
99534
|
+
const parts = [];
|
|
99535
|
+
for (const entry of this.pendingImages.values()) {
|
|
99536
|
+
if (typeof entry === "string") {
|
|
99537
|
+
parts.push({ type: "image", image: entry });
|
|
99538
|
+
} else if (entry && entry.type === "document") {
|
|
99539
|
+
parts.push({
|
|
99540
|
+
type: "file",
|
|
99541
|
+
mediaType: entry.mimeType,
|
|
99542
|
+
data: entry.data,
|
|
99543
|
+
filename: entry.filename
|
|
99544
|
+
});
|
|
99545
|
+
}
|
|
99546
|
+
}
|
|
99547
|
+
return parts;
|
|
99486
99548
|
}
|
|
99487
99549
|
/**
|
|
99488
|
-
* Clear loaded
|
|
99550
|
+
* Clear loaded media (useful for new conversations)
|
|
99489
99551
|
*/
|
|
99490
99552
|
clearLoadedImages() {
|
|
99491
99553
|
this.pendingImages.clear();
|
|
99492
99554
|
this.currentImages = [];
|
|
99493
99555
|
if (this.debug) {
|
|
99494
|
-
console.log("[DEBUG] Cleared all loaded
|
|
99556
|
+
console.log("[DEBUG] Cleared all loaded media");
|
|
99495
99557
|
}
|
|
99496
99558
|
}
|
|
99497
99559
|
/**
|
|
99498
|
-
* Prepare messages for AI consumption, adding
|
|
99560
|
+
* Prepare messages for AI consumption, adding media to the latest user message if available
|
|
99499
99561
|
* @param {Array} messages - Current conversation messages
|
|
99500
|
-
* @returns {Array} - Messages formatted for AI SDK with potential
|
|
99562
|
+
* @returns {Array} - Messages formatted for AI SDK with potential media content
|
|
99501
99563
|
*/
|
|
99502
99564
|
prepareMessagesWithImages(messages) {
|
|
99503
|
-
const
|
|
99504
|
-
if (
|
|
99565
|
+
const mediaParts = this.getCurrentMedia();
|
|
99566
|
+
if (mediaParts.length === 0) {
|
|
99505
99567
|
return messages;
|
|
99506
99568
|
}
|
|
99507
|
-
const
|
|
99508
|
-
const lastUserMessageIndex =
|
|
99569
|
+
const messagesWithMedia = [...messages];
|
|
99570
|
+
const lastUserMessageIndex = messagesWithMedia.map((m) => m.role).lastIndexOf("user");
|
|
99509
99571
|
if (lastUserMessageIndex === -1) {
|
|
99510
99572
|
if (this.debug) {
|
|
99511
|
-
console.log("[DEBUG] No user messages found to attach
|
|
99573
|
+
console.log("[DEBUG] No user messages found to attach media to");
|
|
99512
99574
|
}
|
|
99513
99575
|
return messages;
|
|
99514
99576
|
}
|
|
99515
|
-
const lastUserMessage =
|
|
99577
|
+
const lastUserMessage = messagesWithMedia[lastUserMessageIndex];
|
|
99516
99578
|
if (typeof lastUserMessage.content === "string") {
|
|
99517
|
-
|
|
99579
|
+
messagesWithMedia[lastUserMessageIndex] = {
|
|
99518
99580
|
...lastUserMessage,
|
|
99519
99581
|
content: [
|
|
99520
99582
|
{ type: "text", text: lastUserMessage.content },
|
|
99521
|
-
...
|
|
99522
|
-
type: "image",
|
|
99523
|
-
image: imageData
|
|
99524
|
-
}))
|
|
99583
|
+
...mediaParts
|
|
99525
99584
|
]
|
|
99526
99585
|
};
|
|
99527
99586
|
if (this.debug) {
|
|
99528
|
-
console.log(`[DEBUG] Added ${
|
|
99587
|
+
console.log(`[DEBUG] Added ${mediaParts.length} media items to the latest user message`);
|
|
99529
99588
|
}
|
|
99530
99589
|
}
|
|
99531
|
-
return
|
|
99590
|
+
return messagesWithMedia;
|
|
99532
99591
|
}
|
|
99533
99592
|
/**
|
|
99534
99593
|
* Initialize mock model for testing
|
|
@@ -101912,7 +101971,9 @@ async function delegate({
|
|
|
101912
101971
|
bashConfig = null,
|
|
101913
101972
|
allowEdit = false,
|
|
101914
101973
|
architectureFileName = null,
|
|
101915
|
-
promptType =
|
|
101974
|
+
promptType = void 0,
|
|
101975
|
+
customPrompt = null,
|
|
101976
|
+
completionPrompt = null,
|
|
101916
101977
|
allowedTools = null,
|
|
101917
101978
|
disableTools = false,
|
|
101918
101979
|
searchDelegate = void 0,
|
|
@@ -101978,7 +102039,11 @@ async function delegate({
|
|
|
101978
102039
|
const subagent = new ProbeAgent({
|
|
101979
102040
|
sessionId,
|
|
101980
102041
|
promptType,
|
|
101981
|
-
//
|
|
102042
|
+
// Inherit from parent (or use parent's default)
|
|
102043
|
+
customPrompt,
|
|
102044
|
+
// Inherit custom system prompt from parent
|
|
102045
|
+
completionPrompt,
|
|
102046
|
+
// Inherit completion prompt from parent
|
|
101982
102047
|
enableDelegate: false,
|
|
101983
102048
|
// Explicitly disable delegation to prevent recursion
|
|
101984
102049
|
disableMermaidValidation: true,
|
|
@@ -103849,6 +103914,9 @@ Do NOT search for analogies or loosely related concepts. If the feature does not
|
|
|
103849
103914
|
enableMcp = false,
|
|
103850
103915
|
mcpConfig = null,
|
|
103851
103916
|
mcpConfigPath = null,
|
|
103917
|
+
promptType: parentPromptType,
|
|
103918
|
+
customPrompt: parentCustomPrompt = null,
|
|
103919
|
+
completionPrompt: parentCompletionPrompt = null,
|
|
103852
103920
|
delegationManager = null,
|
|
103853
103921
|
// Timeout settings inherited from parent agent
|
|
103854
103922
|
timeoutBehavior,
|
|
@@ -103942,6 +104010,12 @@ Do NOT search for analogies or loosely related concepts. If the feature does not
|
|
|
103942
104010
|
allowEdit,
|
|
103943
104011
|
bashConfig,
|
|
103944
104012
|
architectureFileName,
|
|
104013
|
+
promptType: parentPromptType,
|
|
104014
|
+
// Inherit parent's prompt type
|
|
104015
|
+
customPrompt: parentCustomPrompt,
|
|
104016
|
+
// Inherit parent's custom system prompt
|
|
104017
|
+
completionPrompt: parentCompletionPrompt,
|
|
104018
|
+
// Inherit parent's completion prompt
|
|
103945
104019
|
searchDelegate,
|
|
103946
104020
|
enableMcp,
|
|
103947
104021
|
mcpConfig,
|
|
@@ -105294,6 +105368,7 @@ __export(tools_exports, {
|
|
|
105294
105368
|
querySchema: () => querySchema,
|
|
105295
105369
|
queryTool: () => queryTool,
|
|
105296
105370
|
readImageSchema: () => readImageSchema,
|
|
105371
|
+
readMediaSchema: () => readMediaSchema,
|
|
105297
105372
|
resolveTargetPath: () => resolveTargetPath,
|
|
105298
105373
|
searchFilesSchema: () => searchFilesSchema,
|
|
105299
105374
|
searchSchema: () => searchSchema,
|
|
@@ -105499,6 +105574,7 @@ __export(index_exports, {
|
|
|
105499
105574
|
querySchema: () => querySchema,
|
|
105500
105575
|
queryTool: () => queryTool,
|
|
105501
105576
|
readImageSchema: () => readImageSchema,
|
|
105577
|
+
readMediaSchema: () => readMediaSchema,
|
|
105502
105578
|
search: () => search,
|
|
105503
105579
|
searchFilesSchema: () => searchFilesSchema,
|
|
105504
105580
|
searchFilesToolInstance: () => searchFilesToolInstance,
|
|
@@ -105588,6 +105664,7 @@ init_index();
|
|
|
105588
105664
|
querySchema,
|
|
105589
105665
|
queryTool,
|
|
105590
105666
|
readImageSchema,
|
|
105667
|
+
readMediaSchema,
|
|
105591
105668
|
search,
|
|
105592
105669
|
searchFilesSchema,
|
|
105593
105670
|
searchFilesToolInstance,
|