@hasna/assistants 1.1.85 → 1.1.86
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/dist/index.js +1302 -647
- package/dist/index.js.map +16 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25508,9 +25508,9 @@ var init_path_validator = __esm(() => {
|
|
|
25508
25508
|
});
|
|
25509
25509
|
|
|
25510
25510
|
// packages/core/src/tools/filesystem.ts
|
|
25511
|
-
import { join as join14, resolve as resolve4, dirname as dirname6, sep } from "path";
|
|
25511
|
+
import { join as join14, resolve as resolve4, dirname as dirname6, sep, isAbsolute as isAbsolute3 } from "path";
|
|
25512
25512
|
import { homedir as homedir9 } from "os";
|
|
25513
|
-
import { mkdir as mkdir4 } from "fs/promises";
|
|
25513
|
+
import { mkdir as mkdir4, copyFile, stat } from "fs/promises";
|
|
25514
25514
|
function getScriptsFolder(cwd, sessionId) {
|
|
25515
25515
|
const resolvedSessionId = sessionId || currentSessionId;
|
|
25516
25516
|
return join14(getProjectDataDir(cwd), "scripts", resolvedSessionId);
|
|
@@ -25584,6 +25584,7 @@ var init_filesystem = __esm(async () => {
|
|
|
25584
25584
|
registry.register(this.globTool, this.globExecutor);
|
|
25585
25585
|
registry.register(this.grepTool, this.grepExecutor);
|
|
25586
25586
|
registry.register(this.readPdfTool, this.readPdfExecutor);
|
|
25587
|
+
registry.register(this.fileCopyTool, this.fileCopyExecutor);
|
|
25587
25588
|
}
|
|
25588
25589
|
static setSessionId(sessionId) {
|
|
25589
25590
|
currentSessionId = sessionId;
|
|
@@ -25820,7 +25821,11 @@ var init_filesystem = __esm(async () => {
|
|
|
25820
25821
|
const mode = currentWorkspaceConfig.mode || "sandbox";
|
|
25821
25822
|
let resolvedPath;
|
|
25822
25823
|
let allowedRoot;
|
|
25823
|
-
|
|
25824
|
+
const tmpResolved = isAbsolute3(filename) ? resolve4(filename) : null;
|
|
25825
|
+
if (tmpResolved && isWithinDir(tmpResolved, "/tmp")) {
|
|
25826
|
+
resolvedPath = tmpResolved;
|
|
25827
|
+
allowedRoot = "/tmp";
|
|
25828
|
+
} else if (mode === "sandbox") {
|
|
25824
25829
|
const scriptsFolder = getScriptsFolder(baseCwd, input.sessionId);
|
|
25825
25830
|
const sanitizedFilename = filename.replace(/\.\.[/\\]/g, "").replace(/\.\./g, "").replace(/^[/\\]+/, "");
|
|
25826
25831
|
resolvedPath = join14(scriptsFolder, sanitizedFilename);
|
|
@@ -26284,6 +26289,247 @@ var init_filesystem = __esm(async () => {
|
|
|
26284
26289
|
});
|
|
26285
26290
|
}
|
|
26286
26291
|
};
|
|
26292
|
+
static COPY_ALLOWED_SOURCES = [
|
|
26293
|
+
"/tmp",
|
|
26294
|
+
join14(homedir9(), ".connect"),
|
|
26295
|
+
join14(homedir9(), "Downloads")
|
|
26296
|
+
];
|
|
26297
|
+
static fileCopyTool = {
|
|
26298
|
+
name: "file_copy",
|
|
26299
|
+
description: "Copy a file from an allowed external location into the project workspace. " + "Allowed source locations: /tmp, ~/.connect/*, ~/Downloads, and the project .assistants-data/ directory. " + "The destination must be within the current workspace (sandbox scripts folder, project directory, or custom path depending on workspace.mode).",
|
|
26300
|
+
parameters: {
|
|
26301
|
+
type: "object",
|
|
26302
|
+
properties: {
|
|
26303
|
+
source: {
|
|
26304
|
+
type: "string",
|
|
26305
|
+
description: "Absolute path to the source file (must be in /tmp, ~/.connect, ~/Downloads, or .assistants-data/)"
|
|
26306
|
+
},
|
|
26307
|
+
destination: {
|
|
26308
|
+
type: "string",
|
|
26309
|
+
description: "Destination path within the workspace (relative or absolute)"
|
|
26310
|
+
},
|
|
26311
|
+
cwd: {
|
|
26312
|
+
type: "string",
|
|
26313
|
+
description: "Base working directory for the project (optional)"
|
|
26314
|
+
}
|
|
26315
|
+
},
|
|
26316
|
+
required: ["source", "destination"]
|
|
26317
|
+
}
|
|
26318
|
+
};
|
|
26319
|
+
static fileCopyExecutor = async (input) => {
|
|
26320
|
+
const baseCwd = input.cwd || process.cwd();
|
|
26321
|
+
const rawSource = String(input.source || "").trim();
|
|
26322
|
+
const rawDestination = String(input.destination || "").trim();
|
|
26323
|
+
if (!rawSource) {
|
|
26324
|
+
throw new ToolExecutionError("Source path is required", {
|
|
26325
|
+
toolName: "file_copy",
|
|
26326
|
+
toolInput: input,
|
|
26327
|
+
code: ErrorCodes.VALIDATION_OUT_OF_RANGE,
|
|
26328
|
+
recoverable: false,
|
|
26329
|
+
retryable: false,
|
|
26330
|
+
suggestion: "Provide an absolute path to the source file."
|
|
26331
|
+
});
|
|
26332
|
+
}
|
|
26333
|
+
if (!rawDestination) {
|
|
26334
|
+
throw new ToolExecutionError("Destination path is required", {
|
|
26335
|
+
toolName: "file_copy",
|
|
26336
|
+
toolInput: input,
|
|
26337
|
+
code: ErrorCodes.VALIDATION_OUT_OF_RANGE,
|
|
26338
|
+
recoverable: false,
|
|
26339
|
+
retryable: false,
|
|
26340
|
+
suggestion: "Provide a destination path within the workspace."
|
|
26341
|
+
});
|
|
26342
|
+
}
|
|
26343
|
+
const sourcePath = FilesystemTools.resolveInputPath(baseCwd, rawSource);
|
|
26344
|
+
const allowedSources = [
|
|
26345
|
+
...FilesystemTools.COPY_ALLOWED_SOURCES,
|
|
26346
|
+
getProjectDataDir(baseCwd)
|
|
26347
|
+
];
|
|
26348
|
+
let sourceAllowed = false;
|
|
26349
|
+
for (const allowed of allowedSources) {
|
|
26350
|
+
if (isWithinDir(sourcePath, allowed)) {
|
|
26351
|
+
sourceAllowed = true;
|
|
26352
|
+
break;
|
|
26353
|
+
}
|
|
26354
|
+
}
|
|
26355
|
+
if (!sourceAllowed) {
|
|
26356
|
+
getSecurityLogger().log({
|
|
26357
|
+
eventType: "path_violation",
|
|
26358
|
+
severity: "high",
|
|
26359
|
+
details: {
|
|
26360
|
+
tool: "file_copy",
|
|
26361
|
+
path: sourcePath,
|
|
26362
|
+
reason: "Source path not in allowed locations"
|
|
26363
|
+
},
|
|
26364
|
+
sessionId: input.sessionId || "unknown"
|
|
26365
|
+
});
|
|
26366
|
+
throw new ToolExecutionError(`Source path is not in an allowed location. Allowed: /tmp, ~/.connect, ~/Downloads, .assistants-data/. Got: ${sourcePath}`, {
|
|
26367
|
+
toolName: "file_copy",
|
|
26368
|
+
toolInput: input,
|
|
26369
|
+
code: ErrorCodes.TOOL_PERMISSION_DENIED,
|
|
26370
|
+
recoverable: false,
|
|
26371
|
+
retryable: false,
|
|
26372
|
+
suggestion: "Copy files only from /tmp, ~/.connect/*, ~/Downloads, or .assistants-data/."
|
|
26373
|
+
});
|
|
26374
|
+
}
|
|
26375
|
+
const sourceSafety = await isPathSafe(sourcePath, "read", { cwd: baseCwd, allowedPaths: allowedSources });
|
|
26376
|
+
if (!sourceSafety.safe) {
|
|
26377
|
+
getSecurityLogger().log({
|
|
26378
|
+
eventType: "path_violation",
|
|
26379
|
+
severity: "high",
|
|
26380
|
+
details: {
|
|
26381
|
+
tool: "file_copy",
|
|
26382
|
+
path: sourcePath,
|
|
26383
|
+
reason: sourceSafety.reason || "Blocked source path"
|
|
26384
|
+
},
|
|
26385
|
+
sessionId: input.sessionId || "unknown"
|
|
26386
|
+
});
|
|
26387
|
+
throw new ToolExecutionError(sourceSafety.reason || "Blocked source path", {
|
|
26388
|
+
toolName: "file_copy",
|
|
26389
|
+
toolInput: input,
|
|
26390
|
+
code: ErrorCodes.TOOL_PERMISSION_DENIED,
|
|
26391
|
+
recoverable: false,
|
|
26392
|
+
retryable: false
|
|
26393
|
+
});
|
|
26394
|
+
}
|
|
26395
|
+
try {
|
|
26396
|
+
const srcStat = await stat(sourcePath);
|
|
26397
|
+
if (!srcStat.isFile()) {
|
|
26398
|
+
throw new ToolExecutionError(`Source is not a file: ${sourcePath}`, {
|
|
26399
|
+
toolName: "file_copy",
|
|
26400
|
+
toolInput: input,
|
|
26401
|
+
code: ErrorCodes.TOOL_EXECUTION_FAILED,
|
|
26402
|
+
recoverable: false,
|
|
26403
|
+
retryable: false,
|
|
26404
|
+
suggestion: "Provide a path to a regular file, not a directory."
|
|
26405
|
+
});
|
|
26406
|
+
}
|
|
26407
|
+
} catch (error2) {
|
|
26408
|
+
if (error2 instanceof ToolExecutionError)
|
|
26409
|
+
throw error2;
|
|
26410
|
+
throw new ToolExecutionError(`Source file not found: ${sourcePath}`, {
|
|
26411
|
+
toolName: "file_copy",
|
|
26412
|
+
toolInput: input,
|
|
26413
|
+
code: ErrorCodes.TOOL_EXECUTION_FAILED,
|
|
26414
|
+
recoverable: false,
|
|
26415
|
+
retryable: false,
|
|
26416
|
+
suggestion: "Check the source file path and try again."
|
|
26417
|
+
});
|
|
26418
|
+
}
|
|
26419
|
+
const mode = currentWorkspaceConfig.mode || "sandbox";
|
|
26420
|
+
let resolvedDest;
|
|
26421
|
+
let allowedRoot;
|
|
26422
|
+
if (mode === "sandbox") {
|
|
26423
|
+
const scriptsFolder = getScriptsFolder(baseCwd, input.sessionId);
|
|
26424
|
+
const sanitizedDest = rawDestination.replace(/\.\.[/\\]/g, "").replace(/\.\./g, "").replace(/^[/\\]+/, "");
|
|
26425
|
+
resolvedDest = join14(scriptsFolder, sanitizedDest);
|
|
26426
|
+
allowedRoot = scriptsFolder;
|
|
26427
|
+
if (!isInScriptsFolder(resolvedDest, baseCwd, input.sessionId)) {
|
|
26428
|
+
throw new ToolExecutionError(`Cannot copy outside scripts folder. Files are saved to ${scriptsFolder}`, {
|
|
26429
|
+
toolName: "file_copy",
|
|
26430
|
+
toolInput: input,
|
|
26431
|
+
code: ErrorCodes.TOOL_PERMISSION_DENIED,
|
|
26432
|
+
recoverable: false,
|
|
26433
|
+
retryable: false,
|
|
26434
|
+
suggestion: "Copy only within the project scripts folder."
|
|
26435
|
+
});
|
|
26436
|
+
}
|
|
26437
|
+
} else if (mode === "project") {
|
|
26438
|
+
resolvedDest = FilesystemTools.resolveInputPath(baseCwd, rawDestination);
|
|
26439
|
+
allowedRoot = resolve4(baseCwd);
|
|
26440
|
+
if (!isWithinDir(resolvedDest, allowedRoot)) {
|
|
26441
|
+
throw new ToolExecutionError(`Cannot copy outside the project directory (${allowedRoot}).`, {
|
|
26442
|
+
toolName: "file_copy",
|
|
26443
|
+
toolInput: input,
|
|
26444
|
+
code: ErrorCodes.TOOL_PERMISSION_DENIED,
|
|
26445
|
+
recoverable: false,
|
|
26446
|
+
retryable: false,
|
|
26447
|
+
suggestion: "Provide a destination within the project directory."
|
|
26448
|
+
});
|
|
26449
|
+
}
|
|
26450
|
+
} else if (mode === "custom") {
|
|
26451
|
+
const customPath = currentWorkspaceConfig.customPath;
|
|
26452
|
+
if (!customPath) {
|
|
26453
|
+
throw new ToolExecutionError('Workspace mode is "custom" but no customPath is configured.', {
|
|
26454
|
+
toolName: "file_copy",
|
|
26455
|
+
toolInput: input,
|
|
26456
|
+
code: ErrorCodes.TOOL_EXECUTION_FAILED,
|
|
26457
|
+
recoverable: false,
|
|
26458
|
+
retryable: false,
|
|
26459
|
+
suggestion: "Set workspace.customPath to an absolute path in config."
|
|
26460
|
+
});
|
|
26461
|
+
}
|
|
26462
|
+
allowedRoot = resolve4(customPath);
|
|
26463
|
+
resolvedDest = FilesystemTools.resolveInputPath(allowedRoot, rawDestination);
|
|
26464
|
+
if (!isWithinDir(resolvedDest, allowedRoot)) {
|
|
26465
|
+
throw new ToolExecutionError(`Cannot copy outside the custom workspace (${allowedRoot}).`, {
|
|
26466
|
+
toolName: "file_copy",
|
|
26467
|
+
toolInput: input,
|
|
26468
|
+
code: ErrorCodes.TOOL_PERMISSION_DENIED,
|
|
26469
|
+
recoverable: false,
|
|
26470
|
+
retryable: false,
|
|
26471
|
+
suggestion: `Provide a destination within ${allowedRoot}.`
|
|
26472
|
+
});
|
|
26473
|
+
}
|
|
26474
|
+
} else {
|
|
26475
|
+
throw new ToolExecutionError(`Unknown workspace mode: "${mode}".`, {
|
|
26476
|
+
toolName: "file_copy",
|
|
26477
|
+
toolInput: input,
|
|
26478
|
+
code: ErrorCodes.VALIDATION_OUT_OF_RANGE,
|
|
26479
|
+
recoverable: false,
|
|
26480
|
+
retryable: false
|
|
26481
|
+
});
|
|
26482
|
+
}
|
|
26483
|
+
const dangerousReason = isDangerousPath(resolvedDest);
|
|
26484
|
+
if (dangerousReason) {
|
|
26485
|
+
throw new ToolExecutionError(dangerousReason, {
|
|
26486
|
+
toolName: "file_copy",
|
|
26487
|
+
toolInput: input,
|
|
26488
|
+
code: ErrorCodes.TOOL_PERMISSION_DENIED,
|
|
26489
|
+
recoverable: false,
|
|
26490
|
+
retryable: false,
|
|
26491
|
+
suggestion: "Choose a different destination that avoids system directories."
|
|
26492
|
+
});
|
|
26493
|
+
}
|
|
26494
|
+
const destSafety = await isPathSafe(resolvedDest, "write", { cwd: baseCwd });
|
|
26495
|
+
if (!destSafety.safe) {
|
|
26496
|
+
getSecurityLogger().log({
|
|
26497
|
+
eventType: "path_violation",
|
|
26498
|
+
severity: "high",
|
|
26499
|
+
details: {
|
|
26500
|
+
tool: "file_copy",
|
|
26501
|
+
path: resolvedDest,
|
|
26502
|
+
reason: destSafety.reason || "Blocked destination path"
|
|
26503
|
+
},
|
|
26504
|
+
sessionId: input.sessionId || "unknown"
|
|
26505
|
+
});
|
|
26506
|
+
throw new ToolExecutionError(destSafety.reason || "Blocked destination path", {
|
|
26507
|
+
toolName: "file_copy",
|
|
26508
|
+
toolInput: input,
|
|
26509
|
+
code: ErrorCodes.TOOL_PERMISSION_DENIED,
|
|
26510
|
+
recoverable: false,
|
|
26511
|
+
retryable: false
|
|
26512
|
+
});
|
|
26513
|
+
}
|
|
26514
|
+
try {
|
|
26515
|
+
const destDir = dirname6(resolvedDest);
|
|
26516
|
+
await mkdir4(destDir, { recursive: true });
|
|
26517
|
+
await copyFile(sourcePath, resolvedDest);
|
|
26518
|
+
const srcStat = await stat(resolvedDest);
|
|
26519
|
+
const sizeKB = (srcStat.size / 1024).toFixed(1);
|
|
26520
|
+
return `Successfully copied ${sourcePath} \u2192 ${resolvedDest} (${sizeKB} KB)`;
|
|
26521
|
+
} catch (error2) {
|
|
26522
|
+
if (error2 instanceof ToolExecutionError)
|
|
26523
|
+
throw error2;
|
|
26524
|
+
throw new ToolExecutionError(error2 instanceof Error ? error2.message : String(error2), {
|
|
26525
|
+
toolName: "file_copy",
|
|
26526
|
+
toolInput: input,
|
|
26527
|
+
code: ErrorCodes.TOOL_EXECUTION_FAILED,
|
|
26528
|
+
recoverable: true,
|
|
26529
|
+
retryable: false
|
|
26530
|
+
});
|
|
26531
|
+
}
|
|
26532
|
+
};
|
|
26287
26533
|
};
|
|
26288
26534
|
});
|
|
26289
26535
|
|
|
@@ -26359,6 +26605,89 @@ var init_fetch_with_timeout = __esm(() => {
|
|
|
26359
26605
|
init_errors();
|
|
26360
26606
|
});
|
|
26361
26607
|
|
|
26608
|
+
// packages/core/src/features.ts
|
|
26609
|
+
function isAWSConfigured() {
|
|
26610
|
+
return !!(process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION || process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY);
|
|
26611
|
+
}
|
|
26612
|
+
function isElevenLabsConfigured() {
|
|
26613
|
+
return !!process.env.ELEVENLABS_API_KEY;
|
|
26614
|
+
}
|
|
26615
|
+
function isOpenAIConfigured() {
|
|
26616
|
+
return !!process.env.OPENAI_API_KEY;
|
|
26617
|
+
}
|
|
26618
|
+
function isAnyLLMConfigured() {
|
|
26619
|
+
return LLM_PROVIDERS.some((provider) => !!process.env[provider.apiKeyEnv]);
|
|
26620
|
+
}
|
|
26621
|
+
function isExaConfigured() {
|
|
26622
|
+
return !!process.env.EXA_API_KEY;
|
|
26623
|
+
}
|
|
26624
|
+
function isSystemVoiceAvailable() {
|
|
26625
|
+
return process.platform === "darwin";
|
|
26626
|
+
}
|
|
26627
|
+
function getFeatureAvailability() {
|
|
26628
|
+
return {
|
|
26629
|
+
coreChat: isAnyLLMConfigured(),
|
|
26630
|
+
awsFeatures: isAWSConfigured(),
|
|
26631
|
+
elevenLabsTTS: isElevenLabsConfigured(),
|
|
26632
|
+
whisperSTT: isOpenAIConfigured(),
|
|
26633
|
+
exaSearch: isExaConfigured(),
|
|
26634
|
+
systemVoice: isSystemVoiceAvailable()
|
|
26635
|
+
};
|
|
26636
|
+
}
|
|
26637
|
+
function getFeatureStatusMessage() {
|
|
26638
|
+
const features = getFeatureAvailability();
|
|
26639
|
+
const lines = [];
|
|
26640
|
+
if (!features.coreChat) {
|
|
26641
|
+
lines.push("\u26A0\uFE0F ANTHROPIC_API_KEY not set - core chat disabled");
|
|
26642
|
+
} else {
|
|
26643
|
+
lines.push("\u2713 Core chat enabled");
|
|
26644
|
+
}
|
|
26645
|
+
if (features.awsFeatures) {
|
|
26646
|
+
lines.push("\u2713 AWS features available (inbox, wallet, secrets)");
|
|
26647
|
+
} else {
|
|
26648
|
+
lines.push("\u25CB AWS features disabled (set AWS_REGION to enable)");
|
|
26649
|
+
}
|
|
26650
|
+
if (features.elevenLabsTTS) {
|
|
26651
|
+
lines.push("\u2713 ElevenLabs TTS available");
|
|
26652
|
+
}
|
|
26653
|
+
if (features.whisperSTT) {
|
|
26654
|
+
lines.push("\u2713 Whisper STT available");
|
|
26655
|
+
}
|
|
26656
|
+
if (features.systemVoice) {
|
|
26657
|
+
lines.push("\u2713 System voice available (macOS)");
|
|
26658
|
+
}
|
|
26659
|
+
if (features.exaSearch) {
|
|
26660
|
+
lines.push("\u2713 Exa enhanced search available");
|
|
26661
|
+
}
|
|
26662
|
+
return lines.join(`
|
|
26663
|
+
`);
|
|
26664
|
+
}
|
|
26665
|
+
function validateFeatureEnvVars(config) {
|
|
26666
|
+
const warnings = [];
|
|
26667
|
+
if (config.inbox?.enabled && !isAWSConfigured()) {
|
|
26668
|
+
warnings.push("inbox.enabled is true but AWS credentials are not configured");
|
|
26669
|
+
}
|
|
26670
|
+
if (config.wallet?.enabled && !isAWSConfigured()) {
|
|
26671
|
+
warnings.push("wallet.enabled is true but AWS credentials are not configured");
|
|
26672
|
+
}
|
|
26673
|
+
const secretsProvider = config.secrets?.storage?.provider || "local";
|
|
26674
|
+
if (config.secrets?.enabled && secretsProvider === "aws" && !isAWSConfigured()) {
|
|
26675
|
+
warnings.push("secrets.enabled is true but AWS credentials are not configured");
|
|
26676
|
+
}
|
|
26677
|
+
if (config.voice?.enabled) {
|
|
26678
|
+
if (config.voice.tts?.provider === "elevenlabs" && !isElevenLabsConfigured()) {
|
|
26679
|
+
warnings.push("voice.tts.provider is elevenlabs but ELEVENLABS_API_KEY is not set");
|
|
26680
|
+
}
|
|
26681
|
+
if (config.voice.stt?.provider === "whisper" && !isOpenAIConfigured()) {
|
|
26682
|
+
warnings.push("voice.stt.provider is whisper but OPENAI_API_KEY is not set");
|
|
26683
|
+
}
|
|
26684
|
+
}
|
|
26685
|
+
return warnings;
|
|
26686
|
+
}
|
|
26687
|
+
var init_features = __esm(() => {
|
|
26688
|
+
init_src2();
|
|
26689
|
+
});
|
|
26690
|
+
|
|
26362
26691
|
// packages/core/src/tools/web.ts
|
|
26363
26692
|
async function readResponseWithLimit(response, maxBytes = MAX_RESPONSE_BYTES) {
|
|
26364
26693
|
const reader = response.body?.getReader();
|
|
@@ -26437,7 +26766,65 @@ function parseDuckDuckGoResults(html, maxResults) {
|
|
|
26437
26766
|
}
|
|
26438
26767
|
function isLikelyBotChallenge(html) {
|
|
26439
26768
|
const lower = html.toLowerCase();
|
|
26440
|
-
return lower.includes("anomaly.js") || lower.includes("anomaly-modal") || lower.includes("challenge-form");
|
|
26769
|
+
return lower.includes("anomaly.js") || lower.includes("anomaly-modal") || lower.includes("challenge-form") || lower.includes("bots use duckduckgo") || lower.includes("challenge to confirm") || lower.includes("select all squares") || lower.includes("anomaly/images/challenge");
|
|
26770
|
+
}
|
|
26771
|
+
function formatSearchResults(query, results) {
|
|
26772
|
+
let output = `Search results for "${query}":
|
|
26773
|
+
|
|
26774
|
+
`;
|
|
26775
|
+
for (let i = 0;i < results.length; i++) {
|
|
26776
|
+
const r = results[i];
|
|
26777
|
+
output += `${i + 1}. ${r.title}
|
|
26778
|
+
`;
|
|
26779
|
+
output += ` ${r.url}
|
|
26780
|
+
`;
|
|
26781
|
+
if (r.snippet) {
|
|
26782
|
+
output += ` ${r.snippet}
|
|
26783
|
+
`;
|
|
26784
|
+
}
|
|
26785
|
+
output += `
|
|
26786
|
+
`;
|
|
26787
|
+
}
|
|
26788
|
+
return output.trim();
|
|
26789
|
+
}
|
|
26790
|
+
async function fetchExaSearchResults(query, maxResults, timeout, signal) {
|
|
26791
|
+
const apiKey = process.env.EXA_API_KEY;
|
|
26792
|
+
if (!apiKey)
|
|
26793
|
+
return [];
|
|
26794
|
+
try {
|
|
26795
|
+
const response = await fetchWithTimeout("https://api.exa.ai/search", {
|
|
26796
|
+
timeout,
|
|
26797
|
+
method: "POST",
|
|
26798
|
+
headers: {
|
|
26799
|
+
"Content-Type": "application/json",
|
|
26800
|
+
"x-api-key": apiKey,
|
|
26801
|
+
Accept: "application/json"
|
|
26802
|
+
},
|
|
26803
|
+
body: JSON.stringify({
|
|
26804
|
+
query,
|
|
26805
|
+
numResults: maxResults,
|
|
26806
|
+
type: "keyword",
|
|
26807
|
+
contents: {
|
|
26808
|
+
text: { maxCharacters: 200 }
|
|
26809
|
+
}
|
|
26810
|
+
}),
|
|
26811
|
+
signal,
|
|
26812
|
+
toolName: "web_search",
|
|
26813
|
+
toolInput: { query }
|
|
26814
|
+
});
|
|
26815
|
+
if (!response.ok)
|
|
26816
|
+
return [];
|
|
26817
|
+
const data = await response.json();
|
|
26818
|
+
if (!data.results || !Array.isArray(data.results))
|
|
26819
|
+
return [];
|
|
26820
|
+
return data.results.filter((r) => r.url && r.title).slice(0, maxResults).map((r) => ({
|
|
26821
|
+
title: (r.title || "").trim(),
|
|
26822
|
+
url: (r.url || "").trim(),
|
|
26823
|
+
snippet: (r.text || "").trim()
|
|
26824
|
+
}));
|
|
26825
|
+
} catch {
|
|
26826
|
+
return [];
|
|
26827
|
+
}
|
|
26441
26828
|
}
|
|
26442
26829
|
async function fetchInstantAnswerResults(query, maxResults, timeout, signal) {
|
|
26443
26830
|
const apiUrl = `https://api.duckduckgo.com/?q=${encodeURIComponent(query)}&format=json&no_html=1&skip_disambig=1`;
|
|
@@ -26526,6 +26913,7 @@ var init_web = __esm(() => {
|
|
|
26526
26913
|
init_errors();
|
|
26527
26914
|
init_network_validator();
|
|
26528
26915
|
init_fetch_with_timeout();
|
|
26916
|
+
init_features();
|
|
26529
26917
|
MAX_RESPONSE_BYTES = 5 * 1024 * 1024;
|
|
26530
26918
|
WebFetchTool = class WebFetchTool {
|
|
26531
26919
|
static tool = {
|
|
@@ -26764,12 +27152,19 @@ var init_web = __esm(() => {
|
|
|
26764
27152
|
const timeoutInput = Number(input.timeout);
|
|
26765
27153
|
const timeout = Number.isFinite(timeoutInput) && timeoutInput > 0 ? timeoutInput : 15000;
|
|
26766
27154
|
try {
|
|
27155
|
+
if (isExaConfigured()) {
|
|
27156
|
+
const exaResults = await fetchExaSearchResults(query, maxResults, timeout, signal);
|
|
27157
|
+
if (exaResults.length > 0) {
|
|
27158
|
+
return formatSearchResults(query, exaResults);
|
|
27159
|
+
}
|
|
27160
|
+
}
|
|
26767
27161
|
const searchUrl = `https://html.duckduckgo.com/html/?q=${encodeURIComponent(query)}`;
|
|
26768
27162
|
const response = await fetchWithTimeout(searchUrl, {
|
|
26769
27163
|
timeout,
|
|
26770
27164
|
headers: {
|
|
26771
|
-
"User-Agent": "
|
|
26772
|
-
Accept: "text/html"
|
|
27165
|
+
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
|
27166
|
+
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
|
27167
|
+
"Accept-Language": "en-US,en;q=0.9"
|
|
26773
27168
|
},
|
|
26774
27169
|
signal,
|
|
26775
27170
|
toolName: "web_search",
|
|
@@ -26793,25 +27188,12 @@ var init_web = __esm(() => {
|
|
|
26793
27188
|
}
|
|
26794
27189
|
}
|
|
26795
27190
|
if (results.length === 0) {
|
|
26796
|
-
|
|
26797
|
-
|
|
26798
|
-
let output = `Search results for "${query}":
|
|
26799
|
-
|
|
26800
|
-
`;
|
|
26801
|
-
for (let i = 0;i < results.length; i++) {
|
|
26802
|
-
const r = results[i];
|
|
26803
|
-
output += `${i + 1}. ${r.title}
|
|
26804
|
-
`;
|
|
26805
|
-
output += ` ${r.url}
|
|
26806
|
-
`;
|
|
26807
|
-
if (r.snippet) {
|
|
26808
|
-
output += ` ${r.snippet}
|
|
26809
|
-
`;
|
|
27191
|
+
if (isLikelyBotChallenge(html)) {
|
|
27192
|
+
return `Web search is currently blocked by DuckDuckGo's bot protection. To enable reliable web search, set EXA_API_KEY in your environment (~/.secrets). Get a key at https://exa.ai`;
|
|
26810
27193
|
}
|
|
26811
|
-
|
|
26812
|
-
`;
|
|
27194
|
+
return `No results found for "${query}". For more reliable search, set EXA_API_KEY in your environment (~/.secrets). Get a key at https://exa.ai`;
|
|
26813
27195
|
}
|
|
26814
|
-
return
|
|
27196
|
+
return formatSearchResults(query, results);
|
|
26815
27197
|
} catch (error2) {
|
|
26816
27198
|
if (error2 instanceof ToolExecutionError)
|
|
26817
27199
|
throw error2;
|
|
@@ -44632,7 +45014,7 @@ var require_gray_matter = __commonJS((exports, module) => {
|
|
|
44632
45014
|
// packages/core/src/tools/markdown.ts
|
|
44633
45015
|
import { resolve as resolve6, join as join18 } from "path";
|
|
44634
45016
|
import { homedir as homedir12 } from "os";
|
|
44635
|
-
import { writeFile as writeFile2, stat } from "fs/promises";
|
|
45017
|
+
import { writeFile as writeFile2, stat as stat2 } from "fs/promises";
|
|
44636
45018
|
function resolveInputPath2(baseCwd, inputPath) {
|
|
44637
45019
|
const envHome = process.env.HOME || process.env.USERPROFILE;
|
|
44638
45020
|
const home = envHome && envHome.trim().length > 0 ? envHome : homedir12();
|
|
@@ -45403,7 +45785,7 @@ ${newContent}
|
|
|
45403
45785
|
regex = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "gi");
|
|
45404
45786
|
}
|
|
45405
45787
|
const matches = [];
|
|
45406
|
-
const fileStat = await
|
|
45788
|
+
const fileStat = await stat2(resolvedPath);
|
|
45407
45789
|
const files = [];
|
|
45408
45790
|
if (fileStat.isDirectory()) {
|
|
45409
45791
|
for await (const file of runtime.glob(globPattern, { cwd: resolvedPath })) {
|
|
@@ -45638,7 +46020,7 @@ ${newContent}
|
|
|
45638
46020
|
try {
|
|
45639
46021
|
const resolvedPath = await resolveAndValidate(rawPath, baseCwd, "md_outline", input);
|
|
45640
46022
|
const runtime = getRuntime();
|
|
45641
|
-
const fileStat = await
|
|
46023
|
+
const fileStat = await stat2(resolvedPath);
|
|
45642
46024
|
const files = [];
|
|
45643
46025
|
if (fileStat.isDirectory()) {
|
|
45644
46026
|
for await (const file of runtime.glob(globPattern, { cwd: resolvedPath })) {
|
|
@@ -47224,7 +47606,7 @@ var init_workflows2 = __esm(async () => {
|
|
|
47224
47606
|
// packages/core/src/skills/create.ts
|
|
47225
47607
|
import { join as join19, dirname as dirname8 } from "path";
|
|
47226
47608
|
import { homedir as homedir15 } from "os";
|
|
47227
|
-
import { mkdir as mkdir5, stat as
|
|
47609
|
+
import { mkdir as mkdir5, stat as stat3, writeFile as writeFile3, rm } from "fs/promises";
|
|
47228
47610
|
function slugify(input) {
|
|
47229
47611
|
return input.trim().toLowerCase().replace(/[^a-z0-9\s_-]/g, "").replace(/[\s_]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
47230
47612
|
}
|
|
@@ -47286,7 +47668,7 @@ function resolveSkillRoot(scope, cwd) {
|
|
|
47286
47668
|
}
|
|
47287
47669
|
async function pathExists(path3) {
|
|
47288
47670
|
try {
|
|
47289
|
-
const stats = await
|
|
47671
|
+
const stats = await stat3(path3);
|
|
47290
47672
|
return stats.isFile() || stats.isDirectory();
|
|
47291
47673
|
} catch {
|
|
47292
47674
|
return false;
|
|
@@ -47383,7 +47765,7 @@ var init_executor3 = __esm(async () => {
|
|
|
47383
47765
|
// packages/core/src/skills/installer.ts
|
|
47384
47766
|
import { join as join20 } from "path";
|
|
47385
47767
|
import { homedir as homedir16 } from "os";
|
|
47386
|
-
import { mkdir as mkdir6, readFile as readFile4, writeFile as writeFile4, stat as
|
|
47768
|
+
import { mkdir as mkdir6, readFile as readFile4, writeFile as writeFile4, stat as stat4 } from "fs/promises";
|
|
47387
47769
|
function resolveSkillRoot2(scope, cwd) {
|
|
47388
47770
|
if (scope === "global") {
|
|
47389
47771
|
return join20(homedir16(), ".skill");
|
|
@@ -47394,14 +47776,14 @@ async function ensurePackageJson(dir) {
|
|
|
47394
47776
|
await mkdir6(dir, { recursive: true });
|
|
47395
47777
|
const pkgPath = join20(dir, "package.json");
|
|
47396
47778
|
try {
|
|
47397
|
-
await
|
|
47779
|
+
await stat4(pkgPath);
|
|
47398
47780
|
} catch {
|
|
47399
47781
|
await writeFile4(pkgPath, JSON.stringify({ name: "assistants-skills", private: true, dependencies: {} }, null, 2) + `
|
|
47400
47782
|
`);
|
|
47401
47783
|
}
|
|
47402
47784
|
const gitignorePath = join20(dir, ".gitignore");
|
|
47403
47785
|
try {
|
|
47404
|
-
await
|
|
47786
|
+
await stat4(gitignorePath);
|
|
47405
47787
|
} catch {
|
|
47406
47788
|
await writeFile4(gitignorePath, `node_modules/
|
|
47407
47789
|
`);
|
|
@@ -48187,8 +48569,84 @@ var init_wait = __esm(() => {
|
|
|
48187
48569
|
};
|
|
48188
48570
|
});
|
|
48189
48571
|
|
|
48572
|
+
// packages/core/src/tools/notify.ts
|
|
48573
|
+
import { exec } from "child_process";
|
|
48574
|
+
function escapeShellArg(str3) {
|
|
48575
|
+
return str3.replace(/'/g, "'\\''");
|
|
48576
|
+
}
|
|
48577
|
+
function buildCommand(input) {
|
|
48578
|
+
const platform2 = process.platform;
|
|
48579
|
+
const title = escapeShellArg(input.title);
|
|
48580
|
+
const message = escapeShellArg(input.message);
|
|
48581
|
+
if (platform2 === "darwin") {
|
|
48582
|
+
const soundClause = input.sound ? ' sound name "default"' : "";
|
|
48583
|
+
return `osascript -e 'display notification "${message}" with title "${title}"${soundClause}'`;
|
|
48584
|
+
}
|
|
48585
|
+
if (platform2 === "linux") {
|
|
48586
|
+
return `notify-send '${title}' '${message}'`;
|
|
48587
|
+
}
|
|
48588
|
+
if (platform2 === "win32") {
|
|
48589
|
+
const ps = `[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') | Out-Null; ` + `$n = New-Object System.Windows.Forms.NotifyIcon; ` + `$n.Icon = [System.Drawing.SystemIcons]::Information; ` + `$n.Visible = $true; ` + `$n.ShowBalloonTip(5000, '${title}', '${message}', 'Info')`;
|
|
48590
|
+
return `powershell -Command "${ps.replace(/"/g, "\\\"")}"`;
|
|
48591
|
+
}
|
|
48592
|
+
throw new Error(`Unsupported platform: ${platform2}`);
|
|
48593
|
+
}
|
|
48594
|
+
function execAsync(command) {
|
|
48595
|
+
return new Promise((resolve9, reject) => {
|
|
48596
|
+
exec(command, { timeout: 1e4 }, (error2, stdout, stderr) => {
|
|
48597
|
+
if (error2) {
|
|
48598
|
+
reject(error2);
|
|
48599
|
+
} else {
|
|
48600
|
+
resolve9({ stdout, stderr });
|
|
48601
|
+
}
|
|
48602
|
+
});
|
|
48603
|
+
});
|
|
48604
|
+
}
|
|
48605
|
+
var NotifyTool;
|
|
48606
|
+
var init_notify = __esm(() => {
|
|
48607
|
+
NotifyTool = class NotifyTool {
|
|
48608
|
+
static tool = {
|
|
48609
|
+
name: "notify",
|
|
48610
|
+
description: "Send a native desktop notification. Works on macOS (osascript), Linux (notify-send), and Windows (PowerShell).",
|
|
48611
|
+
parameters: {
|
|
48612
|
+
type: "object",
|
|
48613
|
+
properties: {
|
|
48614
|
+
title: {
|
|
48615
|
+
type: "string",
|
|
48616
|
+
description: "Notification title"
|
|
48617
|
+
},
|
|
48618
|
+
message: {
|
|
48619
|
+
type: "string",
|
|
48620
|
+
description: "Notification message body"
|
|
48621
|
+
},
|
|
48622
|
+
sound: {
|
|
48623
|
+
type: "boolean",
|
|
48624
|
+
description: "Play a sound with the notification (macOS only)",
|
|
48625
|
+
default: false
|
|
48626
|
+
}
|
|
48627
|
+
},
|
|
48628
|
+
required: ["title", "message"]
|
|
48629
|
+
}
|
|
48630
|
+
};
|
|
48631
|
+
static executor = async (input) => {
|
|
48632
|
+
const notifyInput = {
|
|
48633
|
+
title: String(input.title || "Notification"),
|
|
48634
|
+
message: String(input.message || ""),
|
|
48635
|
+
sound: input.sound === true
|
|
48636
|
+
};
|
|
48637
|
+
try {
|
|
48638
|
+
const command = buildCommand(notifyInput);
|
|
48639
|
+
await execAsync(command);
|
|
48640
|
+
return `Notification sent: "${notifyInput.title}" \u2014 ${notifyInput.message}`;
|
|
48641
|
+
} catch (error2) {
|
|
48642
|
+
return `Error sending notification: ${error2 instanceof Error ? error2.message : String(error2)}`;
|
|
48643
|
+
}
|
|
48644
|
+
};
|
|
48645
|
+
};
|
|
48646
|
+
});
|
|
48647
|
+
|
|
48190
48648
|
// packages/core/src/tools/tmux.ts
|
|
48191
|
-
async function
|
|
48649
|
+
async function exec2(args) {
|
|
48192
48650
|
const runtime = getRuntime();
|
|
48193
48651
|
const proc = runtime.spawn(["tmux", ...args], {
|
|
48194
48652
|
stdout: "pipe",
|
|
@@ -48310,12 +48768,12 @@ var init_tmux = __esm(async () => {
|
|
|
48310
48768
|
if (command) {
|
|
48311
48769
|
args.push(command);
|
|
48312
48770
|
}
|
|
48313
|
-
await
|
|
48771
|
+
await exec2(args);
|
|
48314
48772
|
return `Session "${name}" created${cwd ? ` in ${cwd}` : ""}`;
|
|
48315
48773
|
}
|
|
48316
48774
|
case "list_sessions": {
|
|
48317
48775
|
try {
|
|
48318
|
-
const out = await
|
|
48776
|
+
const out = await exec2(["list-sessions", "-F", "#{session_name}: #{session_windows} windows (created #{session_created_string})#{?session_attached, (attached),}"]);
|
|
48319
48777
|
const lines2 = out.trim().split(`
|
|
48320
48778
|
`);
|
|
48321
48779
|
const assistantSessions = lines2.filter((l) => l.startsWith(SESSION_PREFIX));
|
|
@@ -48332,7 +48790,7 @@ var init_tmux = __esm(async () => {
|
|
|
48332
48790
|
if (!session)
|
|
48333
48791
|
throw toolError("tmux", "session name is required for kill_session");
|
|
48334
48792
|
const name = prefixed(session);
|
|
48335
|
-
await
|
|
48793
|
+
await exec2(["kill-session", "-t", name]);
|
|
48336
48794
|
return `Session "${name}" killed.`;
|
|
48337
48795
|
}
|
|
48338
48796
|
case "send_command": {
|
|
@@ -48344,12 +48802,12 @@ var init_tmux = __esm(async () => {
|
|
|
48344
48802
|
if (wait) {
|
|
48345
48803
|
const marker = `asst-done-${Date.now()}`;
|
|
48346
48804
|
const wrappedCmd = `${command}; tmux wait-for -S ${marker}`;
|
|
48347
|
-
await
|
|
48348
|
-
await
|
|
48349
|
-
const out = await
|
|
48805
|
+
await exec2(["send-keys", "-t", t, wrappedCmd, "Enter"]);
|
|
48806
|
+
await exec2(["wait-for", marker]);
|
|
48807
|
+
const out = await exec2(["capture-pane", "-t", t, "-pJ", "-S", "-50"]);
|
|
48350
48808
|
return out.trim() || "Command completed (no output).";
|
|
48351
48809
|
}
|
|
48352
|
-
await
|
|
48810
|
+
await exec2(["send-keys", "-t", t, command, "Enter"]);
|
|
48353
48811
|
return `Command sent to ${t}.`;
|
|
48354
48812
|
}
|
|
48355
48813
|
case "capture_output": {
|
|
@@ -48357,7 +48815,7 @@ var init_tmux = __esm(async () => {
|
|
|
48357
48815
|
throw toolError("tmux", "target is required for capture_output");
|
|
48358
48816
|
const t = prefixTarget(target);
|
|
48359
48817
|
const startLine = -Math.abs(lines);
|
|
48360
|
-
const out = await
|
|
48818
|
+
const out = await exec2(["capture-pane", "-t", t, "-pJ", "-S", String(startLine)]);
|
|
48361
48819
|
const trimmed = out.trim();
|
|
48362
48820
|
return trimmed || "(empty \u2014 no output in scrollback)";
|
|
48363
48821
|
}
|
|
@@ -48365,7 +48823,7 @@ var init_tmux = __esm(async () => {
|
|
|
48365
48823
|
if (!target)
|
|
48366
48824
|
throw toolError("tmux", "target is required for get_status");
|
|
48367
48825
|
const t = prefixTarget(target);
|
|
48368
|
-
const out = await
|
|
48826
|
+
const out = await exec2([
|
|
48369
48827
|
"display-message",
|
|
48370
48828
|
"-t",
|
|
48371
48829
|
t,
|
|
@@ -48385,14 +48843,14 @@ var init_tmux = __esm(async () => {
|
|
|
48385
48843
|
if (cwd) {
|
|
48386
48844
|
args.push("-c", cwd);
|
|
48387
48845
|
}
|
|
48388
|
-
await
|
|
48846
|
+
await exec2(args);
|
|
48389
48847
|
return `Window${windowName ? ` "${windowName}"` : ""} created in session "${name}".`;
|
|
48390
48848
|
}
|
|
48391
48849
|
case "list_windows": {
|
|
48392
48850
|
if (!session)
|
|
48393
48851
|
throw toolError("tmux", "session name is required for list_windows");
|
|
48394
48852
|
const name = prefixed(session);
|
|
48395
|
-
const out = await
|
|
48853
|
+
const out = await exec2([
|
|
48396
48854
|
"list-windows",
|
|
48397
48855
|
"-t",
|
|
48398
48856
|
name,
|
|
@@ -48405,7 +48863,7 @@ var init_tmux = __esm(async () => {
|
|
|
48405
48863
|
if (!target)
|
|
48406
48864
|
throw toolError("tmux", "target is required for list_panes");
|
|
48407
48865
|
const t = prefixTarget(target);
|
|
48408
|
-
const out = await
|
|
48866
|
+
const out = await exec2([
|
|
48409
48867
|
"list-panes",
|
|
48410
48868
|
"-t",
|
|
48411
48869
|
t,
|
|
@@ -48423,14 +48881,14 @@ var init_tmux = __esm(async () => {
|
|
|
48423
48881
|
if (cwd) {
|
|
48424
48882
|
args.push("-c", cwd);
|
|
48425
48883
|
}
|
|
48426
|
-
await
|
|
48884
|
+
await exec2(args);
|
|
48427
48885
|
return `Pane split ${direction}ly in ${t}.`;
|
|
48428
48886
|
}
|
|
48429
48887
|
case "interrupt": {
|
|
48430
48888
|
if (!target)
|
|
48431
48889
|
throw toolError("tmux", "target is required for interrupt");
|
|
48432
48890
|
const t = prefixTarget(target);
|
|
48433
|
-
await
|
|
48891
|
+
await exec2(["send-keys", "-t", t, "C-c", ""]);
|
|
48434
48892
|
return `Ctrl+C sent to ${t}.`;
|
|
48435
48893
|
}
|
|
48436
48894
|
default:
|
|
@@ -48440,9 +48898,224 @@ var init_tmux = __esm(async () => {
|
|
|
48440
48898
|
};
|
|
48441
48899
|
});
|
|
48442
48900
|
|
|
48901
|
+
// packages/core/src/tools/diff.ts
|
|
48902
|
+
import { resolve as resolve9 } from "path";
|
|
48903
|
+
import { homedir as homedir17 } from "os";
|
|
48904
|
+
function resolveInputPath4(inputPath) {
|
|
48905
|
+
const envHome = process.env.HOME || process.env.USERPROFILE;
|
|
48906
|
+
const home = envHome && envHome.trim().length > 0 ? envHome : homedir17();
|
|
48907
|
+
if (inputPath === "~") {
|
|
48908
|
+
return home;
|
|
48909
|
+
}
|
|
48910
|
+
if (inputPath.startsWith("~/")) {
|
|
48911
|
+
return resolve9(home, inputPath.slice(2));
|
|
48912
|
+
}
|
|
48913
|
+
return resolve9(inputPath);
|
|
48914
|
+
}
|
|
48915
|
+
async function runDiff(runtime, args, signal) {
|
|
48916
|
+
const proc = runtime.spawn(["diff", ...args], {
|
|
48917
|
+
stdout: "pipe",
|
|
48918
|
+
stderr: "pipe"
|
|
48919
|
+
});
|
|
48920
|
+
let aborted = false;
|
|
48921
|
+
let handleAbort = null;
|
|
48922
|
+
if (signal) {
|
|
48923
|
+
handleAbort = () => {
|
|
48924
|
+
aborted = true;
|
|
48925
|
+
proc.kill();
|
|
48926
|
+
};
|
|
48927
|
+
signal.addEventListener("abort", handleAbort, { once: true });
|
|
48928
|
+
}
|
|
48929
|
+
try {
|
|
48930
|
+
const [stdout, stderr] = await Promise.all([
|
|
48931
|
+
proc.stdout ? new Response(proc.stdout).text() : "",
|
|
48932
|
+
proc.stderr ? new Response(proc.stderr).text() : ""
|
|
48933
|
+
]);
|
|
48934
|
+
const exitCode = await proc.exited;
|
|
48935
|
+
if (aborted) {
|
|
48936
|
+
throw new ToolExecutionError("Diff aborted.", {
|
|
48937
|
+
toolName: "diff",
|
|
48938
|
+
toolInput: {},
|
|
48939
|
+
code: ErrorCodes.TOOL_EXECUTION_FAILED,
|
|
48940
|
+
recoverable: false,
|
|
48941
|
+
retryable: true
|
|
48942
|
+
});
|
|
48943
|
+
}
|
|
48944
|
+
if (exitCode === 0) {
|
|
48945
|
+
return "Files are identical \u2014 no differences found.";
|
|
48946
|
+
}
|
|
48947
|
+
if (exitCode === 1) {
|
|
48948
|
+
return stdout;
|
|
48949
|
+
}
|
|
48950
|
+
throw new ToolExecutionError(`diff failed: ${stderr || stdout}`.trim(), {
|
|
48951
|
+
toolName: "diff",
|
|
48952
|
+
toolInput: {},
|
|
48953
|
+
code: ErrorCodes.TOOL_EXECUTION_FAILED,
|
|
48954
|
+
recoverable: false,
|
|
48955
|
+
retryable: false
|
|
48956
|
+
});
|
|
48957
|
+
} finally {
|
|
48958
|
+
if (signal && handleAbort) {
|
|
48959
|
+
signal.removeEventListener("abort", handleAbort);
|
|
48960
|
+
}
|
|
48961
|
+
}
|
|
48962
|
+
}
|
|
48963
|
+
async function runDiffWithStdin(runtime, args, stdinContent, signal) {
|
|
48964
|
+
const proc = runtime.spawn(["diff", ...args], {
|
|
48965
|
+
stdout: "pipe",
|
|
48966
|
+
stderr: "pipe",
|
|
48967
|
+
stdin: "pipe"
|
|
48968
|
+
});
|
|
48969
|
+
let aborted = false;
|
|
48970
|
+
let handleAbort = null;
|
|
48971
|
+
if (signal) {
|
|
48972
|
+
handleAbort = () => {
|
|
48973
|
+
aborted = true;
|
|
48974
|
+
proc.kill();
|
|
48975
|
+
};
|
|
48976
|
+
signal.addEventListener("abort", handleAbort, { once: true });
|
|
48977
|
+
}
|
|
48978
|
+
try {
|
|
48979
|
+
if (proc.stdin) {
|
|
48980
|
+
const writer = proc.stdin.getWriter();
|
|
48981
|
+
await writer.write(new TextEncoder().encode(stdinContent));
|
|
48982
|
+
await writer.close();
|
|
48983
|
+
}
|
|
48984
|
+
const [stdout, stderr] = await Promise.all([
|
|
48985
|
+
proc.stdout ? new Response(proc.stdout).text() : "",
|
|
48986
|
+
proc.stderr ? new Response(proc.stderr).text() : ""
|
|
48987
|
+
]);
|
|
48988
|
+
const exitCode = await proc.exited;
|
|
48989
|
+
if (aborted) {
|
|
48990
|
+
throw new ToolExecutionError("Diff aborted.", {
|
|
48991
|
+
toolName: "diff",
|
|
48992
|
+
toolInput: {},
|
|
48993
|
+
code: ErrorCodes.TOOL_EXECUTION_FAILED,
|
|
48994
|
+
recoverable: false,
|
|
48995
|
+
retryable: true
|
|
48996
|
+
});
|
|
48997
|
+
}
|
|
48998
|
+
if (exitCode === 0) {
|
|
48999
|
+
return "Content is identical to file \u2014 no differences found.";
|
|
49000
|
+
}
|
|
49001
|
+
if (exitCode === 1) {
|
|
49002
|
+
return stdout;
|
|
49003
|
+
}
|
|
49004
|
+
throw new ToolExecutionError(`diff failed: ${stderr || stdout}`.trim(), {
|
|
49005
|
+
toolName: "diff",
|
|
49006
|
+
toolInput: {},
|
|
49007
|
+
code: ErrorCodes.TOOL_EXECUTION_FAILED,
|
|
49008
|
+
recoverable: false,
|
|
49009
|
+
retryable: false
|
|
49010
|
+
});
|
|
49011
|
+
} finally {
|
|
49012
|
+
if (signal && handleAbort) {
|
|
49013
|
+
signal.removeEventListener("abort", handleAbort);
|
|
49014
|
+
}
|
|
49015
|
+
}
|
|
49016
|
+
}
|
|
49017
|
+
var diffTool, diffExecutor = async (input, signal) => {
|
|
49018
|
+
const fileA = input.file_a;
|
|
49019
|
+
const fileB = input.file_b;
|
|
49020
|
+
const contentB = input.content_b;
|
|
49021
|
+
const contextLines = typeof input.context_lines === "number" ? Math.max(0, Math.round(input.context_lines)) : 3;
|
|
49022
|
+
if (!fileA) {
|
|
49023
|
+
throw new ToolExecutionError("file_a is required.", {
|
|
49024
|
+
toolName: "diff",
|
|
49025
|
+
toolInput: input,
|
|
49026
|
+
code: ErrorCodes.VALIDATION_SCHEMA_ERROR,
|
|
49027
|
+
recoverable: false,
|
|
49028
|
+
retryable: false,
|
|
49029
|
+
suggestion: "Provide file_a as an absolute or relative path."
|
|
49030
|
+
});
|
|
49031
|
+
}
|
|
49032
|
+
if (!fileB && contentB === undefined) {
|
|
49033
|
+
throw new ToolExecutionError("Either file_b or content_b must be provided.", {
|
|
49034
|
+
toolName: "diff",
|
|
49035
|
+
toolInput: input,
|
|
49036
|
+
code: ErrorCodes.VALIDATION_SCHEMA_ERROR,
|
|
49037
|
+
recoverable: false,
|
|
49038
|
+
retryable: false,
|
|
49039
|
+
suggestion: "Provide file_b (path to second file) or content_b (string to compare against)."
|
|
49040
|
+
});
|
|
49041
|
+
}
|
|
49042
|
+
if (fileB && contentB !== undefined) {
|
|
49043
|
+
throw new ToolExecutionError("Provide either file_b or content_b, not both.", {
|
|
49044
|
+
toolName: "diff",
|
|
49045
|
+
toolInput: input,
|
|
49046
|
+
code: ErrorCodes.VALIDATION_SCHEMA_ERROR,
|
|
49047
|
+
recoverable: false,
|
|
49048
|
+
retryable: false,
|
|
49049
|
+
suggestion: "Use file_b to compare two files, or content_b to compare a file against a string."
|
|
49050
|
+
});
|
|
49051
|
+
}
|
|
49052
|
+
const resolvedA = resolveInputPath4(fileA);
|
|
49053
|
+
const safetyA = await isPathSafe(resolvedA, "read");
|
|
49054
|
+
if (!safetyA.safe) {
|
|
49055
|
+
throw new ToolExecutionError(`Cannot read file_a: ${safetyA.reason}`, {
|
|
49056
|
+
toolName: "diff",
|
|
49057
|
+
toolInput: input,
|
|
49058
|
+
code: ErrorCodes.TOOL_PERMISSION_DENIED,
|
|
49059
|
+
recoverable: false,
|
|
49060
|
+
retryable: false
|
|
49061
|
+
});
|
|
49062
|
+
}
|
|
49063
|
+
const runtime = getRuntime();
|
|
49064
|
+
if (fileB) {
|
|
49065
|
+
const resolvedB = resolveInputPath4(fileB);
|
|
49066
|
+
const safetyB = await isPathSafe(resolvedB, "read");
|
|
49067
|
+
if (!safetyB.safe) {
|
|
49068
|
+
throw new ToolExecutionError(`Cannot read file_b: ${safetyB.reason}`, {
|
|
49069
|
+
toolName: "diff",
|
|
49070
|
+
toolInput: input,
|
|
49071
|
+
code: ErrorCodes.TOOL_PERMISSION_DENIED,
|
|
49072
|
+
recoverable: false,
|
|
49073
|
+
retryable: false
|
|
49074
|
+
});
|
|
49075
|
+
}
|
|
49076
|
+
return runDiff(runtime, ["-u", `-U${contextLines}`, resolvedA, resolvedB], signal);
|
|
49077
|
+
}
|
|
49078
|
+
return runDiffWithStdin(runtime, ["-u", `-U${contextLines}`, resolvedA, "-"], contentB, signal);
|
|
49079
|
+
}, DiffTool;
|
|
49080
|
+
var init_diff = __esm(async () => {
|
|
49081
|
+
init_errors();
|
|
49082
|
+
init_path_validator();
|
|
49083
|
+
await init_runtime();
|
|
49084
|
+
diffTool = {
|
|
49085
|
+
name: "diff",
|
|
49086
|
+
description: "Compare two files and show differences in unified diff format. " + "Provide file_a and file_b to compare two files, or file_a and content_b to compare a file against a string.",
|
|
49087
|
+
parameters: {
|
|
49088
|
+
type: "object",
|
|
49089
|
+
properties: {
|
|
49090
|
+
file_a: {
|
|
49091
|
+
type: "string",
|
|
49092
|
+
description: "Path to the first file (required)."
|
|
49093
|
+
},
|
|
49094
|
+
file_b: {
|
|
49095
|
+
type: "string",
|
|
49096
|
+
description: "Path to the second file. Mutually exclusive with content_b."
|
|
49097
|
+
},
|
|
49098
|
+
content_b: {
|
|
49099
|
+
type: "string",
|
|
49100
|
+
description: "String content to compare against file_a. Mutually exclusive with file_b."
|
|
49101
|
+
},
|
|
49102
|
+
context_lines: {
|
|
49103
|
+
type: "number",
|
|
49104
|
+
description: "Number of context lines around changes (default: 3)."
|
|
49105
|
+
}
|
|
49106
|
+
},
|
|
49107
|
+
required: ["file_a"]
|
|
49108
|
+
}
|
|
49109
|
+
};
|
|
49110
|
+
DiffTool = class DiffTool {
|
|
49111
|
+
static tool = diffTool;
|
|
49112
|
+
static executor = diffExecutor;
|
|
49113
|
+
};
|
|
49114
|
+
});
|
|
49115
|
+
|
|
48443
49116
|
// packages/core/src/agent/subagent.ts
|
|
48444
49117
|
function sleepSafe(ms) {
|
|
48445
|
-
return new Promise((
|
|
49118
|
+
return new Promise((resolve10) => safeSetTimeout(resolve10, ms));
|
|
48446
49119
|
}
|
|
48447
49120
|
async function runHookAssistant(options2) {
|
|
48448
49121
|
const { hook, input, timeout, cwd, allowedTools, llmClient } = options2;
|
|
@@ -51571,7 +52244,7 @@ var require_pattern2 = __commonJS((exports) => {
|
|
|
51571
52244
|
const absolute = [];
|
|
51572
52245
|
const relative3 = [];
|
|
51573
52246
|
for (const pattern of patterns) {
|
|
51574
|
-
if (
|
|
52247
|
+
if (isAbsolute4(pattern)) {
|
|
51575
52248
|
absolute.push(pattern);
|
|
51576
52249
|
} else {
|
|
51577
52250
|
relative3.push(pattern);
|
|
@@ -51580,10 +52253,10 @@ var require_pattern2 = __commonJS((exports) => {
|
|
|
51580
52253
|
return [absolute, relative3];
|
|
51581
52254
|
}
|
|
51582
52255
|
exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
|
|
51583
|
-
function
|
|
52256
|
+
function isAbsolute4(pattern) {
|
|
51584
52257
|
return path3.isAbsolute(pattern);
|
|
51585
52258
|
}
|
|
51586
|
-
exports.isAbsolute =
|
|
52259
|
+
exports.isAbsolute = isAbsolute4;
|
|
51587
52260
|
});
|
|
51588
52261
|
|
|
51589
52262
|
// node_modules/.pnpm/merge2@1.4.1/node_modules/merge2/index.js
|
|
@@ -51853,7 +52526,7 @@ var require_async = __commonJS((exports) => {
|
|
|
51853
52526
|
callSuccessCallback(callback, lstat3);
|
|
51854
52527
|
return;
|
|
51855
52528
|
}
|
|
51856
|
-
settings.fs.stat(path3, (statError,
|
|
52529
|
+
settings.fs.stat(path3, (statError, stat5) => {
|
|
51857
52530
|
if (statError !== null) {
|
|
51858
52531
|
if (settings.throwErrorOnBrokenSymbolicLink) {
|
|
51859
52532
|
callFailureCallback(callback, statError);
|
|
@@ -51863,9 +52536,9 @@ var require_async = __commonJS((exports) => {
|
|
|
51863
52536
|
return;
|
|
51864
52537
|
}
|
|
51865
52538
|
if (settings.markSymbolicLink) {
|
|
51866
|
-
|
|
52539
|
+
stat5.isSymbolicLink = () => true;
|
|
51867
52540
|
}
|
|
51868
|
-
callSuccessCallback(callback,
|
|
52541
|
+
callSuccessCallback(callback, stat5);
|
|
51869
52542
|
});
|
|
51870
52543
|
});
|
|
51871
52544
|
}
|
|
@@ -51888,11 +52561,11 @@ var require_sync = __commonJS((exports) => {
|
|
|
51888
52561
|
return lstat3;
|
|
51889
52562
|
}
|
|
51890
52563
|
try {
|
|
51891
|
-
const
|
|
52564
|
+
const stat5 = settings.fs.statSync(path3);
|
|
51892
52565
|
if (settings.markSymbolicLink) {
|
|
51893
|
-
|
|
52566
|
+
stat5.isSymbolicLink = () => true;
|
|
51894
52567
|
}
|
|
51895
|
-
return
|
|
52568
|
+
return stat5;
|
|
51896
52569
|
} catch (error2) {
|
|
51897
52570
|
if (!settings.throwErrorOnBrokenSymbolicLink) {
|
|
51898
52571
|
return lstat3;
|
|
@@ -51951,14 +52624,14 @@ var require_out = __commonJS((exports) => {
|
|
|
51951
52624
|
var sync = require_sync();
|
|
51952
52625
|
var settings_1 = require_settings();
|
|
51953
52626
|
exports.Settings = settings_1.default;
|
|
51954
|
-
function
|
|
52627
|
+
function stat5(path3, optionsOrSettingsOrCallback, callback) {
|
|
51955
52628
|
if (typeof optionsOrSettingsOrCallback === "function") {
|
|
51956
52629
|
async.read(path3, getSettings(), optionsOrSettingsOrCallback);
|
|
51957
52630
|
return;
|
|
51958
52631
|
}
|
|
51959
52632
|
async.read(path3, getSettings(optionsOrSettingsOrCallback), callback);
|
|
51960
52633
|
}
|
|
51961
|
-
exports.stat =
|
|
52634
|
+
exports.stat = stat5;
|
|
51962
52635
|
function statSync4(path3, optionsOrSettings) {
|
|
51963
52636
|
const settings = getSettings(optionsOrSettings);
|
|
51964
52637
|
return sync.read(path3, settings);
|
|
@@ -52599,42 +53272,42 @@ var require_queue = __commonJS((exports, module) => {
|
|
|
52599
53272
|
queue.drained = drained;
|
|
52600
53273
|
return queue;
|
|
52601
53274
|
function push2(value2) {
|
|
52602
|
-
var p = new Promise(function(
|
|
53275
|
+
var p = new Promise(function(resolve10, reject) {
|
|
52603
53276
|
pushCb(value2, function(err, result) {
|
|
52604
53277
|
if (err) {
|
|
52605
53278
|
reject(err);
|
|
52606
53279
|
return;
|
|
52607
53280
|
}
|
|
52608
|
-
|
|
53281
|
+
resolve10(result);
|
|
52609
53282
|
});
|
|
52610
53283
|
});
|
|
52611
53284
|
p.catch(noop2);
|
|
52612
53285
|
return p;
|
|
52613
53286
|
}
|
|
52614
53287
|
function unshift(value2) {
|
|
52615
|
-
var p = new Promise(function(
|
|
53288
|
+
var p = new Promise(function(resolve10, reject) {
|
|
52616
53289
|
unshiftCb(value2, function(err, result) {
|
|
52617
53290
|
if (err) {
|
|
52618
53291
|
reject(err);
|
|
52619
53292
|
return;
|
|
52620
53293
|
}
|
|
52621
|
-
|
|
53294
|
+
resolve10(result);
|
|
52622
53295
|
});
|
|
52623
53296
|
});
|
|
52624
53297
|
p.catch(noop2);
|
|
52625
53298
|
return p;
|
|
52626
53299
|
}
|
|
52627
53300
|
function drained() {
|
|
52628
|
-
var p = new Promise(function(
|
|
53301
|
+
var p = new Promise(function(resolve10) {
|
|
52629
53302
|
process.nextTick(function() {
|
|
52630
53303
|
if (queue.idle()) {
|
|
52631
|
-
|
|
53304
|
+
resolve10();
|
|
52632
53305
|
} else {
|
|
52633
53306
|
var previousDrain = queue.drain;
|
|
52634
53307
|
queue.drain = function() {
|
|
52635
53308
|
if (typeof previousDrain === "function")
|
|
52636
53309
|
previousDrain();
|
|
52637
|
-
|
|
53310
|
+
resolve10();
|
|
52638
53311
|
queue.drain = previousDrain;
|
|
52639
53312
|
};
|
|
52640
53313
|
}
|
|
@@ -53095,9 +53768,9 @@ var require_stream3 = __commonJS((exports) => {
|
|
|
53095
53768
|
});
|
|
53096
53769
|
}
|
|
53097
53770
|
_getStat(filepath) {
|
|
53098
|
-
return new Promise((
|
|
53771
|
+
return new Promise((resolve10, reject) => {
|
|
53099
53772
|
this._stat(filepath, this._fsStatSettings, (error2, stats) => {
|
|
53100
|
-
return error2 === null ?
|
|
53773
|
+
return error2 === null ? resolve10(stats) : reject(error2);
|
|
53101
53774
|
});
|
|
53102
53775
|
});
|
|
53103
53776
|
}
|
|
@@ -53119,10 +53792,10 @@ var require_async5 = __commonJS((exports) => {
|
|
|
53119
53792
|
this._readerStream = new stream_1.default(this._settings);
|
|
53120
53793
|
}
|
|
53121
53794
|
dynamic(root2, options2) {
|
|
53122
|
-
return new Promise((
|
|
53795
|
+
return new Promise((resolve10, reject) => {
|
|
53123
53796
|
this._walkAsync(root2, options2, (error2, entries) => {
|
|
53124
53797
|
if (error2 === null) {
|
|
53125
|
-
|
|
53798
|
+
resolve10(entries);
|
|
53126
53799
|
} else {
|
|
53127
53800
|
reject(error2);
|
|
53128
53801
|
}
|
|
@@ -53132,10 +53805,10 @@ var require_async5 = __commonJS((exports) => {
|
|
|
53132
53805
|
async static(patterns, options2) {
|
|
53133
53806
|
const entries = [];
|
|
53134
53807
|
const stream = this._readerStream.static(patterns, options2);
|
|
53135
|
-
return new Promise((
|
|
53808
|
+
return new Promise((resolve10, reject) => {
|
|
53136
53809
|
stream.once("error", reject);
|
|
53137
53810
|
stream.on("data", (entry) => entries.push(entry));
|
|
53138
|
-
stream.once("end", () =>
|
|
53811
|
+
stream.once("end", () => resolve10(entries));
|
|
53139
53812
|
});
|
|
53140
53813
|
}
|
|
53141
53814
|
}
|
|
@@ -53765,15 +54438,15 @@ var require_out4 = __commonJS((exports, module) => {
|
|
|
53765
54438
|
|
|
53766
54439
|
// packages/core/src/skills/loader.ts
|
|
53767
54440
|
import { join as join21, basename as basename5, dirname as dirname10 } from "path";
|
|
53768
|
-
import { homedir as
|
|
53769
|
-
import { readFile as readFile5, stat as
|
|
54441
|
+
import { homedir as homedir18 } from "os";
|
|
54442
|
+
import { readFile as readFile5, stat as stat5 } from "fs/promises";
|
|
53770
54443
|
|
|
53771
54444
|
class SkillLoader {
|
|
53772
54445
|
skills = new Map;
|
|
53773
54446
|
async loadAll(projectDir = process.cwd(), options2 = {}) {
|
|
53774
54447
|
const includeContent = options2.includeContent ?? true;
|
|
53775
54448
|
const envHome = process.env.HOME || process.env.USERPROFILE;
|
|
53776
|
-
const userHome = envHome && envHome.trim().length > 0 ? envHome :
|
|
54449
|
+
const userHome = envHome && envHome.trim().length > 0 ? envHome : homedir18();
|
|
53777
54450
|
const globalRoot = join21(userHome, ".skill");
|
|
53778
54451
|
const projectRoot = join21(projectDir, ".skill");
|
|
53779
54452
|
await this.loadNpmSkills(globalRoot, { includeContent });
|
|
@@ -53786,7 +54459,7 @@ class SkillLoader {
|
|
|
53786
54459
|
try {
|
|
53787
54460
|
const nmDir = join21(skillRoot, "node_modules", "@hasnaxyz");
|
|
53788
54461
|
try {
|
|
53789
|
-
const stats = await
|
|
54462
|
+
const stats = await stat5(nmDir);
|
|
53790
54463
|
if (!stats.isDirectory())
|
|
53791
54464
|
return;
|
|
53792
54465
|
} catch {
|
|
@@ -53820,7 +54493,7 @@ class SkillLoader {
|
|
|
53820
54493
|
const includeContent = options2.includeContent ?? true;
|
|
53821
54494
|
try {
|
|
53822
54495
|
try {
|
|
53823
|
-
const stats = await
|
|
54496
|
+
const stats = await stat5(skillRoot);
|
|
53824
54497
|
if (!stats.isDirectory())
|
|
53825
54498
|
return;
|
|
53826
54499
|
} catch {
|
|
@@ -53841,7 +54514,7 @@ class SkillLoader {
|
|
|
53841
54514
|
const includeContent = options2.includeContent ?? true;
|
|
53842
54515
|
try {
|
|
53843
54516
|
try {
|
|
53844
|
-
const stats = await
|
|
54517
|
+
const stats = await stat5(dir);
|
|
53845
54518
|
if (!stats.isDirectory())
|
|
53846
54519
|
return;
|
|
53847
54520
|
} catch {
|
|
@@ -53982,7 +54655,7 @@ var init_loader3 = __esm(() => {
|
|
|
53982
54655
|
// packages/core/src/commands/loader.ts
|
|
53983
54656
|
import { existsSync as existsSync15, readdirSync as readdirSync6, statSync as statSync4 } from "fs";
|
|
53984
54657
|
import { join as join22, basename as basename6, extname as extname3 } from "path";
|
|
53985
|
-
import { homedir as
|
|
54658
|
+
import { homedir as homedir19 } from "os";
|
|
53986
54659
|
|
|
53987
54660
|
class CommandLoader {
|
|
53988
54661
|
commands = new Map;
|
|
@@ -53993,7 +54666,7 @@ class CommandLoader {
|
|
|
53993
54666
|
async loadAll() {
|
|
53994
54667
|
this.commands.clear();
|
|
53995
54668
|
const envHome = process.env.HOME || process.env.USERPROFILE;
|
|
53996
|
-
const homeDir = envHome && envHome.trim().length > 0 ? envHome :
|
|
54669
|
+
const homeDir = envHome && envHome.trim().length > 0 ? envHome : homedir19();
|
|
53997
54670
|
const globalDir = join22(homeDir, ".assistants", "commands");
|
|
53998
54671
|
await this.loadFromDirectory(globalDir, "global");
|
|
53999
54672
|
const projectDir = join22(this.cwd, ".assistants", "commands");
|
|
@@ -54005,11 +54678,11 @@ class CommandLoader {
|
|
|
54005
54678
|
const entries = readdirSync6(dir);
|
|
54006
54679
|
for (const entry of entries) {
|
|
54007
54680
|
const fullPath = join22(dir, entry);
|
|
54008
|
-
const
|
|
54009
|
-
if (
|
|
54681
|
+
const stat6 = statSync4(fullPath);
|
|
54682
|
+
if (stat6.isDirectory()) {
|
|
54010
54683
|
const newPrefix = prefix ? `${prefix}:${entry}` : entry;
|
|
54011
54684
|
await this.loadFromDirectory(fullPath, source, newPrefix);
|
|
54012
|
-
} else if (
|
|
54685
|
+
} else if (stat6.isFile() && extname3(entry) === ".md") {
|
|
54013
54686
|
const command = await this.loadCommandFile(fullPath, prefix);
|
|
54014
54687
|
if (command) {
|
|
54015
54688
|
this.commands.set(command.name, command);
|
|
@@ -54713,7 +55386,7 @@ class JobManager {
|
|
|
54713
55386
|
const startTime = Date.now();
|
|
54714
55387
|
const pollInterval = 500;
|
|
54715
55388
|
while (Date.now() - startTime < waitMs) {
|
|
54716
|
-
await new Promise((
|
|
55389
|
+
await new Promise((resolve10) => setTimeout(resolve10, pollInterval));
|
|
54717
55390
|
const currentJob = await readJob(jobId);
|
|
54718
55391
|
if (!currentJob)
|
|
54719
55392
|
return null;
|
|
@@ -55072,7 +55745,7 @@ var init_types4 = __esm(() => {
|
|
|
55072
55745
|
// node_modules/.pnpm/@hasna+todos@0.9.23_@types+react@19.2.14/node_modules/@hasna/todos/dist/index.js
|
|
55073
55746
|
import { Database as Database2 } from "bun:sqlite";
|
|
55074
55747
|
import { existsSync as existsSync16, mkdirSync as mkdirSync8 } from "fs";
|
|
55075
|
-
import { dirname as dirname11, join as join23, resolve as
|
|
55748
|
+
import { dirname as dirname11, join as join23, resolve as resolve10 } from "path";
|
|
55076
55749
|
import { existsSync as existsSync32 } from "fs";
|
|
55077
55750
|
import { join as join32 } from "path";
|
|
55078
55751
|
import { existsSync as existsSync22, mkdirSync as mkdirSync22, readFileSync as readFileSync8, readdirSync as readdirSync7, statSync as statSync5, writeFileSync as writeFileSync7 } from "fs";
|
|
@@ -55080,7 +55753,7 @@ function isInMemoryDb(path3) {
|
|
|
55080
55753
|
return path3 === ":memory:" || path3.startsWith("file::memory:");
|
|
55081
55754
|
}
|
|
55082
55755
|
function findNearestTodosDb(startDir) {
|
|
55083
|
-
let dir =
|
|
55756
|
+
let dir = resolve10(startDir);
|
|
55084
55757
|
while (true) {
|
|
55085
55758
|
const candidate = join23(dir, ".todos", "todos.db");
|
|
55086
55759
|
if (existsSync16(candidate))
|
|
@@ -55093,7 +55766,7 @@ function findNearestTodosDb(startDir) {
|
|
|
55093
55766
|
return null;
|
|
55094
55767
|
}
|
|
55095
55768
|
function findGitRoot(startDir) {
|
|
55096
|
-
let dir =
|
|
55769
|
+
let dir = resolve10(startDir);
|
|
55097
55770
|
while (true) {
|
|
55098
55771
|
if (existsSync16(join23(dir, ".git")))
|
|
55099
55772
|
return dir;
|
|
@@ -55124,7 +55797,7 @@ function getDbPath() {
|
|
|
55124
55797
|
function ensureDir(filePath) {
|
|
55125
55798
|
if (isInMemoryDb(filePath))
|
|
55126
55799
|
return;
|
|
55127
|
-
const dir = dirname11(
|
|
55800
|
+
const dir = dirname11(resolve10(filePath));
|
|
55128
55801
|
if (!existsSync16(dir)) {
|
|
55129
55802
|
mkdirSync8(dir, { recursive: true });
|
|
55130
55803
|
}
|
|
@@ -94556,8 +95229,8 @@ var require_simple_parser = __commonJS((exports, module) => {
|
|
|
94556
95229
|
}
|
|
94557
95230
|
let promise;
|
|
94558
95231
|
if (!callback) {
|
|
94559
|
-
promise = new Promise((
|
|
94560
|
-
callback = callbackPromise(
|
|
95232
|
+
promise = new Promise((resolve11, reject) => {
|
|
95233
|
+
callback = callbackPromise(resolve11, reject);
|
|
94561
95234
|
});
|
|
94562
95235
|
}
|
|
94563
95236
|
options2 = options2 || {};
|
|
@@ -94643,13 +95316,13 @@ var require_simple_parser = __commonJS((exports, module) => {
|
|
|
94643
95316
|
}
|
|
94644
95317
|
return promise;
|
|
94645
95318
|
};
|
|
94646
|
-
function callbackPromise(
|
|
95319
|
+
function callbackPromise(resolve11, reject) {
|
|
94647
95320
|
return function(...args) {
|
|
94648
95321
|
let err = args.shift();
|
|
94649
95322
|
if (err) {
|
|
94650
95323
|
reject(err);
|
|
94651
95324
|
} else {
|
|
94652
|
-
|
|
95325
|
+
resolve11(...args);
|
|
94653
95326
|
}
|
|
94654
95327
|
};
|
|
94655
95328
|
}
|
|
@@ -95557,7 +96230,19 @@ function createBudgetToolExecutors(getBudgetTracker) {
|
|
|
95557
96230
|
budget_status: async (input) => {
|
|
95558
96231
|
const tracker = getBudgetTracker();
|
|
95559
96232
|
if (!tracker) {
|
|
95560
|
-
return
|
|
96233
|
+
return [
|
|
96234
|
+
"## Budget Status",
|
|
96235
|
+
"",
|
|
96236
|
+
"No budget tracker is configured for this session.",
|
|
96237
|
+
"Budget tracking is available but not active \u2014 no budget limits have been set.",
|
|
96238
|
+
"",
|
|
96239
|
+
"To enable budget tracking, use the `budget_set` tool to configure limits:",
|
|
96240
|
+
' e.g., budget_set scope="session" maxTotalTokens=100000',
|
|
96241
|
+
"",
|
|
96242
|
+
"Available scopes: session, swarm, project",
|
|
96243
|
+
"Available limits: maxInputTokens, maxOutputTokens, maxTotalTokens, maxLlmCalls, maxToolCalls, maxDurationMs"
|
|
96244
|
+
].join(`
|
|
96245
|
+
`);
|
|
95561
96246
|
}
|
|
95562
96247
|
const scopeInput = normalizeScope2(input.scope || "session");
|
|
95563
96248
|
if (!isBudgetToolScope(scopeInput)) {
|
|
@@ -95608,7 +96293,7 @@ function createBudgetToolExecutors(getBudgetTracker) {
|
|
|
95608
96293
|
budget_get: async () => {
|
|
95609
96294
|
const tracker = getBudgetTracker();
|
|
95610
96295
|
if (!tracker) {
|
|
95611
|
-
return "
|
|
96296
|
+
return "No budget tracker is configured. Use `budget_set` to configure limits and enable tracking.";
|
|
95612
96297
|
}
|
|
95613
96298
|
const config = tracker.getConfig();
|
|
95614
96299
|
return JSON.stringify(config, null, 2);
|
|
@@ -95616,7 +96301,7 @@ function createBudgetToolExecutors(getBudgetTracker) {
|
|
|
95616
96301
|
budget_set: async (input) => {
|
|
95617
96302
|
const tracker = getBudgetTracker();
|
|
95618
96303
|
if (!tracker) {
|
|
95619
|
-
return "
|
|
96304
|
+
return "No budget tracker is configured. Budget limits cannot be set without an active tracker.";
|
|
95620
96305
|
}
|
|
95621
96306
|
const scopeInput = normalizeScope2(input.scope || "session");
|
|
95622
96307
|
if (!isBudgetToolScope(scopeInput)) {
|
|
@@ -95657,7 +96342,7 @@ ${JSON.stringify(applied, null, 2)}`;
|
|
|
95657
96342
|
budget_reset: async (input) => {
|
|
95658
96343
|
const tracker = getBudgetTracker();
|
|
95659
96344
|
if (!tracker) {
|
|
95660
|
-
return "
|
|
96345
|
+
return "No budget tracker is configured. Nothing to reset.";
|
|
95661
96346
|
}
|
|
95662
96347
|
const scope = normalizeScope2(input.scope || "session");
|
|
95663
96348
|
if (!isBudgetResetScope(scope)) {
|
|
@@ -97986,7 +98671,7 @@ class TaskGraphScheduler {
|
|
|
97986
98671
|
this.stopped = true;
|
|
97987
98672
|
}
|
|
97988
98673
|
sleep(ms) {
|
|
97989
|
-
return new Promise((
|
|
98674
|
+
return new Promise((resolve11) => setTimeout(resolve11, ms));
|
|
97990
98675
|
}
|
|
97991
98676
|
}
|
|
97992
98677
|
function aggregateTaskResults(graph, aggregationStrategy = "concatenate") {
|
|
@@ -99316,7 +100001,7 @@ ${task.description}`,
|
|
|
99316
100001
|
};
|
|
99317
100002
|
}
|
|
99318
100003
|
sleep(ms) {
|
|
99319
|
-
return new Promise((
|
|
100004
|
+
return new Promise((resolve11) => setTimeout(resolve11, ms));
|
|
99320
100005
|
}
|
|
99321
100006
|
}
|
|
99322
100007
|
function createSwarmDispatcher(subassistantManager, context, config) {
|
|
@@ -100822,10 +101507,10 @@ var init_swarm = __esm(() => {
|
|
|
100822
101507
|
|
|
100823
101508
|
// packages/core/src/commands/builtin.ts
|
|
100824
101509
|
import { join as join26 } from "path";
|
|
100825
|
-
import { homedir as
|
|
101510
|
+
import { homedir as homedir20, platform as platform2, release, arch as arch2 } from "os";
|
|
100826
101511
|
import { existsSync as existsSync19, mkdirSync as mkdirSync11, writeFileSync as writeFileSync8 } from "fs";
|
|
100827
|
-
function resolveAuthTimeout(
|
|
100828
|
-
|
|
101512
|
+
function resolveAuthTimeout(resolve11) {
|
|
101513
|
+
resolve11({ exitCode: 1, stdout: { toString: () => "{}" } });
|
|
100829
101514
|
}
|
|
100830
101515
|
function splitArgs(input) {
|
|
100831
101516
|
const args = [];
|
|
@@ -107200,8 +107885,8 @@ Options for install/uninstall:
|
|
|
107200
107885
|
`;
|
|
107201
107886
|
message += `| --- | --- | --- |
|
|
107202
107887
|
`;
|
|
107203
|
-
for (const
|
|
107204
|
-
message += `| ${
|
|
107888
|
+
for (const stat6 of errorStats.slice(0, 5)) {
|
|
107889
|
+
message += `| ${stat6.code} | ${stat6.count} | ${stat6.lastOccurrence} |
|
|
107205
107890
|
`;
|
|
107206
107891
|
}
|
|
107207
107892
|
}
|
|
@@ -107268,7 +107953,7 @@ Format the summary as a brief bullet-point list. This summary will replace the c
|
|
|
107268
107953
|
`;
|
|
107269
107954
|
}
|
|
107270
107955
|
const envHome = process.env.HOME || process.env.USERPROFILE;
|
|
107271
|
-
const homeDir = envHome && envHome.trim().length > 0 ? envHome :
|
|
107956
|
+
const homeDir = envHome && envHome.trim().length > 0 ? envHome : homedir20();
|
|
107272
107957
|
message += `
|
|
107273
107958
|
**Commands Directories:**
|
|
107274
107959
|
`;
|
|
@@ -109370,8 +110055,8 @@ Connector "${connectorName}" not found.
|
|
|
109370
110055
|
`;
|
|
109371
110056
|
try {
|
|
109372
110057
|
let timeoutId = null;
|
|
109373
|
-
const timeoutPromise = new Promise((
|
|
109374
|
-
timeoutId = setTimeout(resolveAuthTimeout, 1000,
|
|
110058
|
+
const timeoutPromise = new Promise((resolve11) => {
|
|
110059
|
+
timeoutId = setTimeout(resolveAuthTimeout, 1000, resolve11);
|
|
109375
110060
|
});
|
|
109376
110061
|
const runtime = getRuntime();
|
|
109377
110062
|
const cli2 = connector.cli || `connect-${connector.name}`;
|
|
@@ -109450,8 +110135,8 @@ Connector "${connectorName}" not found.
|
|
|
109450
110135
|
let timeoutId = null;
|
|
109451
110136
|
try {
|
|
109452
110137
|
const cli = connector.cli || `connect-${connector.name}`;
|
|
109453
|
-
const timeoutPromise = new Promise((
|
|
109454
|
-
timeoutId = setTimeout(resolveAuthTimeout, 1000,
|
|
110138
|
+
const timeoutPromise = new Promise((resolve11) => {
|
|
110139
|
+
timeoutId = setTimeout(resolveAuthTimeout, 1000, resolve11);
|
|
109455
110140
|
});
|
|
109456
110141
|
const runtime = getRuntime();
|
|
109457
110142
|
const execPromise = (async () => {
|
|
@@ -109704,9 +110389,9 @@ ${repoUrl}/issues/new
|
|
|
109704
110389
|
selfHandled: true,
|
|
109705
110390
|
content: "",
|
|
109706
110391
|
handler: async (args, context) => {
|
|
109707
|
-
const { exec:
|
|
110392
|
+
const { exec: exec3 } = await import("child_process");
|
|
109708
110393
|
const { promisify } = await import("util");
|
|
109709
|
-
const
|
|
110394
|
+
const execAsync2 = promisify(exec3);
|
|
109710
110395
|
const parts = splitArgs(args);
|
|
109711
110396
|
try {
|
|
109712
110397
|
let diffCmd = "git diff";
|
|
@@ -109727,8 +110412,8 @@ ${repoUrl}/issues/new
|
|
|
109727
110412
|
}
|
|
109728
110413
|
const opts = { cwd: context.cwd, maxBuffer: 1048576 };
|
|
109729
110414
|
const [statResult, diffResult] = await Promise.all([
|
|
109730
|
-
|
|
109731
|
-
|
|
110415
|
+
execAsync2(statCmd, opts).catch(() => ({ stdout: "" })),
|
|
110416
|
+
execAsync2(diffCmd, opts).catch(() => ({ stdout: "" }))
|
|
109732
110417
|
]);
|
|
109733
110418
|
const statOutput = (statResult.stdout || "").trim();
|
|
109734
110419
|
const diffOutput = (diffResult.stdout || "").trim();
|
|
@@ -109782,13 +110467,13 @@ Not a git repository or git not available.
|
|
|
109782
110467
|
for (const item of items) {
|
|
109783
110468
|
const fullPath = join26(dir, item);
|
|
109784
110469
|
try {
|
|
109785
|
-
const
|
|
109786
|
-
if (
|
|
110470
|
+
const stat6 = statSync6(fullPath);
|
|
110471
|
+
if (stat6.isDirectory()) {
|
|
109787
110472
|
walk(fullPath, prefix ? `${prefix}/${item}` : item);
|
|
109788
110473
|
} else {
|
|
109789
110474
|
entries.push({
|
|
109790
110475
|
relativePath: prefix ? `${prefix}/${item}` : item,
|
|
109791
|
-
size:
|
|
110476
|
+
size: stat6.size
|
|
109792
110477
|
});
|
|
109793
110478
|
}
|
|
109794
110479
|
} catch {}
|
|
@@ -109835,14 +110520,14 @@ No generated files yet.
|
|
|
109835
110520
|
selfHandled: true,
|
|
109836
110521
|
content: "",
|
|
109837
110522
|
handler: async (args, context) => {
|
|
109838
|
-
const { exec:
|
|
110523
|
+
const { exec: exec3 } = await import("child_process");
|
|
109839
110524
|
const { promisify } = await import("util");
|
|
109840
|
-
const
|
|
110525
|
+
const execAsync2 = promisify(exec3);
|
|
109841
110526
|
const parts = splitArgs(args);
|
|
109842
110527
|
const opts = { cwd: context.cwd };
|
|
109843
110528
|
try {
|
|
109844
110529
|
if (parts.length === 0) {
|
|
109845
|
-
const { stdout: stdout2 } = await
|
|
110530
|
+
const { stdout: stdout2 } = await execAsync2("git diff --stat", opts);
|
|
109846
110531
|
const statOutput = stdout2.trim();
|
|
109847
110532
|
if (!statOutput) {
|
|
109848
110533
|
context.emit("text", `
|
|
@@ -109859,7 +110544,7 @@ No uncommitted changes to undo.
|
|
|
109859
110544
|
return { handled: true };
|
|
109860
110545
|
}
|
|
109861
110546
|
if (parts[0] === "all") {
|
|
109862
|
-
const { stdout: stdout2 } = await
|
|
110547
|
+
const { stdout: stdout2 } = await execAsync2("git diff --stat", opts);
|
|
109863
110548
|
const statOutput = stdout2.trim();
|
|
109864
110549
|
if (!statOutput) {
|
|
109865
110550
|
context.emit("text", `
|
|
@@ -109868,13 +110553,13 @@ No uncommitted changes to undo.
|
|
|
109868
110553
|
context.emit("done");
|
|
109869
110554
|
return { handled: true };
|
|
109870
110555
|
}
|
|
109871
|
-
await
|
|
110556
|
+
await execAsync2("git checkout -- .", opts);
|
|
109872
110557
|
context.emit("text", "\n**Reverted all uncommitted changes:**\n```\n" + statOutput + "\n```\n");
|
|
109873
110558
|
context.emit("done");
|
|
109874
110559
|
return { handled: true };
|
|
109875
110560
|
}
|
|
109876
110561
|
const escaped = parts.map((f) => `'${f.replace(/'/g, "'\\''")}'`).join(" ");
|
|
109877
|
-
const { stdout } = await
|
|
110562
|
+
const { stdout } = await execAsync2(`git diff --stat -- ${escaped}`, opts);
|
|
109878
110563
|
const checkOutput = stdout.trim();
|
|
109879
110564
|
if (!checkOutput) {
|
|
109880
110565
|
context.emit("text", `
|
|
@@ -109883,7 +110568,7 @@ No changes found for: ${parts.join(" ")}
|
|
|
109883
110568
|
context.emit("done");
|
|
109884
110569
|
return { handled: true };
|
|
109885
110570
|
}
|
|
109886
|
-
await
|
|
110571
|
+
await execAsync2(`git checkout -- ${escaped}`, opts);
|
|
109887
110572
|
context.emit("text", `
|
|
109888
110573
|
**Reverted:** ${parts.join(" ")}
|
|
109889
110574
|
`);
|
|
@@ -109927,7 +110612,7 @@ Not a git repository or git not available.
|
|
|
109927
110612
|
context.setProjectContext(projectContext);
|
|
109928
110613
|
}
|
|
109929
110614
|
}
|
|
109930
|
-
var VERSION2 = "1.1.
|
|
110615
|
+
var VERSION2 = "1.1.86";
|
|
109931
110616
|
var init_builtin = __esm(async () => {
|
|
109932
110617
|
init_src2();
|
|
109933
110618
|
init_context3();
|
|
@@ -110150,7 +110835,7 @@ var init_values3 = __esm(() => {
|
|
|
110150
110835
|
});
|
|
110151
110836
|
|
|
110152
110837
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.74.0_zod@3.25.76/node_modules/@anthropic-ai/sdk/internal/utils/sleep.mjs
|
|
110153
|
-
var sleep4 = (ms) => new Promise((
|
|
110838
|
+
var sleep4 = (ms) => new Promise((resolve11) => setTimeout(resolve11, ms));
|
|
110154
110839
|
|
|
110155
110840
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.74.0_zod@3.25.76/node_modules/@anthropic-ai/sdk/version.mjs
|
|
110156
110841
|
var VERSION3 = "0.74.0";
|
|
@@ -110848,8 +111533,8 @@ var init_api_promise2 = __esm(() => {
|
|
|
110848
111533
|
init_parse3();
|
|
110849
111534
|
APIPromise2 = class APIPromise2 extends Promise {
|
|
110850
111535
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse2) {
|
|
110851
|
-
super((
|
|
110852
|
-
|
|
111536
|
+
super((resolve11) => {
|
|
111537
|
+
resolve11(null);
|
|
110853
111538
|
});
|
|
110854
111539
|
this.responsePromise = responsePromise;
|
|
110855
111540
|
this.parseResponse = parseResponse2;
|
|
@@ -111805,12 +112490,12 @@ var init_BetaMessageStream = __esm(() => {
|
|
|
111805
112490
|
}
|
|
111806
112491
|
return this._emit("error", new AnthropicError(String(error3)));
|
|
111807
112492
|
});
|
|
111808
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_connectedPromise, new Promise((
|
|
111809
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_resolveConnectedPromise,
|
|
112493
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_connectedPromise, new Promise((resolve11, reject) => {
|
|
112494
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_resolveConnectedPromise, resolve11, "f");
|
|
111810
112495
|
__classPrivateFieldSet2(this, _BetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
111811
112496
|
}), "f");
|
|
111812
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_endPromise, new Promise((
|
|
111813
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_resolveEndPromise,
|
|
112497
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_endPromise, new Promise((resolve11, reject) => {
|
|
112498
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_resolveEndPromise, resolve11, "f");
|
|
111814
112499
|
__classPrivateFieldSet2(this, _BetaMessageStream_rejectEndPromise, reject, "f");
|
|
111815
112500
|
}), "f");
|
|
111816
112501
|
__classPrivateFieldGet2(this, _BetaMessageStream_connectedPromise, "f").catch(() => {});
|
|
@@ -111931,11 +112616,11 @@ var init_BetaMessageStream = __esm(() => {
|
|
|
111931
112616
|
return this;
|
|
111932
112617
|
}
|
|
111933
112618
|
emitted(event) {
|
|
111934
|
-
return new Promise((
|
|
112619
|
+
return new Promise((resolve11, reject) => {
|
|
111935
112620
|
__classPrivateFieldSet2(this, _BetaMessageStream_catchingPromiseCreated, true, "f");
|
|
111936
112621
|
if (event !== "error")
|
|
111937
112622
|
this.once("error", reject);
|
|
111938
|
-
this.once(event,
|
|
112623
|
+
this.once(event, resolve11);
|
|
111939
112624
|
});
|
|
111940
112625
|
}
|
|
111941
112626
|
async done() {
|
|
@@ -112268,7 +112953,7 @@ var init_BetaMessageStream = __esm(() => {
|
|
|
112268
112953
|
if (done) {
|
|
112269
112954
|
return { value: undefined, done: true };
|
|
112270
112955
|
}
|
|
112271
|
-
return new Promise((
|
|
112956
|
+
return new Promise((resolve11, reject) => readQueue.push({ resolve: resolve11, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: undefined, done: true });
|
|
112272
112957
|
}
|
|
112273
112958
|
const chunk = pushQueue.shift();
|
|
112274
112959
|
return { value: chunk, done: false };
|
|
@@ -112330,13 +113015,13 @@ Wrap your summary in <summary></summary> tags.`;
|
|
|
112330
113015
|
|
|
112331
113016
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.74.0_zod@3.25.76/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.mjs
|
|
112332
113017
|
function promiseWithResolvers() {
|
|
112333
|
-
let
|
|
113018
|
+
let resolve11;
|
|
112334
113019
|
let reject;
|
|
112335
113020
|
const promise = new Promise((res, rej) => {
|
|
112336
|
-
|
|
113021
|
+
resolve11 = res;
|
|
112337
113022
|
reject = rej;
|
|
112338
113023
|
});
|
|
112339
|
-
return { promise, resolve:
|
|
113024
|
+
return { promise, resolve: resolve11, reject };
|
|
112340
113025
|
}
|
|
112341
113026
|
async function generateToolResponse(params, lastMessage = params.messages.at(-1)) {
|
|
112342
113027
|
if (!lastMessage || lastMessage.role !== "assistant" || !lastMessage.content || typeof lastMessage.content === "string") {
|
|
@@ -113091,12 +113776,12 @@ var init_MessageStream = __esm(() => {
|
|
|
113091
113776
|
}
|
|
113092
113777
|
return this._emit("error", new AnthropicError(String(error3)));
|
|
113093
113778
|
});
|
|
113094
|
-
__classPrivateFieldSet2(this, _MessageStream_connectedPromise, new Promise((
|
|
113095
|
-
__classPrivateFieldSet2(this, _MessageStream_resolveConnectedPromise,
|
|
113779
|
+
__classPrivateFieldSet2(this, _MessageStream_connectedPromise, new Promise((resolve11, reject) => {
|
|
113780
|
+
__classPrivateFieldSet2(this, _MessageStream_resolveConnectedPromise, resolve11, "f");
|
|
113096
113781
|
__classPrivateFieldSet2(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
113097
113782
|
}), "f");
|
|
113098
|
-
__classPrivateFieldSet2(this, _MessageStream_endPromise, new Promise((
|
|
113099
|
-
__classPrivateFieldSet2(this, _MessageStream_resolveEndPromise,
|
|
113783
|
+
__classPrivateFieldSet2(this, _MessageStream_endPromise, new Promise((resolve11, reject) => {
|
|
113784
|
+
__classPrivateFieldSet2(this, _MessageStream_resolveEndPromise, resolve11, "f");
|
|
113100
113785
|
__classPrivateFieldSet2(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
113101
113786
|
}), "f");
|
|
113102
113787
|
__classPrivateFieldGet2(this, _MessageStream_connectedPromise, "f").catch(() => {});
|
|
@@ -113217,11 +113902,11 @@ var init_MessageStream = __esm(() => {
|
|
|
113217
113902
|
return this;
|
|
113218
113903
|
}
|
|
113219
113904
|
emitted(event) {
|
|
113220
|
-
return new Promise((
|
|
113905
|
+
return new Promise((resolve11, reject) => {
|
|
113221
113906
|
__classPrivateFieldSet2(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
113222
113907
|
if (event !== "error")
|
|
113223
113908
|
this.once("error", reject);
|
|
113224
|
-
this.once(event,
|
|
113909
|
+
this.once(event, resolve11);
|
|
113225
113910
|
});
|
|
113226
113911
|
}
|
|
113227
113912
|
async done() {
|
|
@@ -113529,7 +114214,7 @@ var init_MessageStream = __esm(() => {
|
|
|
113529
114214
|
if (done) {
|
|
113530
114215
|
return { value: undefined, done: true };
|
|
113531
114216
|
}
|
|
113532
|
-
return new Promise((
|
|
114217
|
+
return new Promise((resolve11, reject) => readQueue.push({ resolve: resolve11, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: undefined, done: true });
|
|
113533
114218
|
}
|
|
113534
114219
|
const chunk = pushQueue.shift();
|
|
113535
114220
|
return { value: chunk, done: false };
|
|
@@ -115317,7 +116002,7 @@ var init_watchdog = __esm(async () => {
|
|
|
115317
116002
|
|
|
115318
116003
|
// packages/core/src/heartbeat/install-skills.ts
|
|
115319
116004
|
import { join as join27 } from "path";
|
|
115320
|
-
import { homedir as
|
|
116005
|
+
import { homedir as homedir21 } from "os";
|
|
115321
116006
|
async function writeSkillIfNeeded(dir, skillName, content3) {
|
|
115322
116007
|
const { mkdir: mkdir7, writeFile: writeFile6, readFile: readFile7 } = await import("fs/promises");
|
|
115323
116008
|
const skillDir = join27(dir, `skill-${skillName}`);
|
|
@@ -115340,7 +116025,7 @@ async function writeSkillIfNeeded(dir, skillName, content3) {
|
|
|
115340
116025
|
}
|
|
115341
116026
|
}
|
|
115342
116027
|
async function installHeartbeatSkills() {
|
|
115343
|
-
const sharedSkillsDir = join27(
|
|
116028
|
+
const sharedSkillsDir = join27(homedir21(), ".skill");
|
|
115344
116029
|
const installed = [];
|
|
115345
116030
|
const results = await Promise.all([
|
|
115346
116031
|
writeSkillIfNeeded(sharedSkillsDir, "main-loop", MAIN_LOOP_SKILL),
|
|
@@ -115761,14 +116446,14 @@ class AudioPlayer {
|
|
|
115761
116446
|
if (!player) {
|
|
115762
116447
|
throw new Error("No supported audio player found. Install afplay, ffplay, mpg123, or aplay.");
|
|
115763
116448
|
}
|
|
115764
|
-
await new Promise((
|
|
116449
|
+
await new Promise((resolve11, reject) => {
|
|
115765
116450
|
this.playing = true;
|
|
115766
116451
|
this.currentProcess = spawn2(player.command, [...player.args, tempFile], { stdio: "ignore" });
|
|
115767
116452
|
this.currentProcess.on("close", () => {
|
|
115768
116453
|
this.playing = false;
|
|
115769
116454
|
this.currentProcess = null;
|
|
115770
116455
|
unlink2(tempFile, () => {});
|
|
115771
|
-
|
|
116456
|
+
resolve11();
|
|
115772
116457
|
});
|
|
115773
116458
|
this.currentProcess.on("error", (error3) => {
|
|
115774
116459
|
this.playing = false;
|
|
@@ -115793,14 +116478,14 @@ class AudioPlayer {
|
|
|
115793
116478
|
unlink2(tempFile, () => {});
|
|
115794
116479
|
throw new Error("No supported audio player found.");
|
|
115795
116480
|
}
|
|
115796
|
-
return new Promise((
|
|
116481
|
+
return new Promise((resolve11, reject) => {
|
|
115797
116482
|
this.playing = true;
|
|
115798
116483
|
this.currentProcess = spawn2(player.command, [...player.args, tempFile]);
|
|
115799
116484
|
this.currentProcess.on("close", () => {
|
|
115800
116485
|
this.playing = false;
|
|
115801
116486
|
this.currentProcess = null;
|
|
115802
116487
|
unlink2(tempFile, () => {});
|
|
115803
|
-
|
|
116488
|
+
resolve11();
|
|
115804
116489
|
});
|
|
115805
116490
|
this.currentProcess.on("error", (error3) => {
|
|
115806
116491
|
this.playing = false;
|
|
@@ -115873,12 +116558,12 @@ class AudioRecorder {
|
|
|
115873
116558
|
if (!recorder) {
|
|
115874
116559
|
throw new Error("No supported audio recorder found. Install sox or ffmpeg.");
|
|
115875
116560
|
}
|
|
115876
|
-
await new Promise((
|
|
116561
|
+
await new Promise((resolve11, reject) => {
|
|
115877
116562
|
this.currentProcess = spawn3(recorder.command, recorder.args, { stdio: "ignore" });
|
|
115878
116563
|
this.currentProcess.on("close", (code3) => {
|
|
115879
116564
|
this.currentProcess = null;
|
|
115880
116565
|
if (code3 === 0 || this.stoppedIntentionally) {
|
|
115881
|
-
|
|
116566
|
+
resolve11();
|
|
115882
116567
|
} else {
|
|
115883
116568
|
reject(new Error("Audio recording failed."));
|
|
115884
116569
|
}
|
|
@@ -115911,12 +116596,12 @@ class AudioRecorder {
|
|
|
115911
116596
|
if (!recorder) {
|
|
115912
116597
|
return this.record({ ...options2, durationSeconds: options2.durationSeconds ?? 5 });
|
|
115913
116598
|
}
|
|
115914
|
-
await new Promise((
|
|
116599
|
+
await new Promise((resolve11, reject) => {
|
|
115915
116600
|
this.currentProcess = spawn3(recorder.command, recorder.args, { stdio: "ignore" });
|
|
115916
116601
|
this.currentProcess.on("close", (code3) => {
|
|
115917
116602
|
this.currentProcess = null;
|
|
115918
116603
|
if (code3 === 0 || this.stoppedIntentionally) {
|
|
115919
|
-
|
|
116604
|
+
resolve11();
|
|
115920
116605
|
} else {
|
|
115921
116606
|
reject(new Error("Audio recording failed."));
|
|
115922
116607
|
}
|
|
@@ -116154,7 +116839,7 @@ class VoiceManager {
|
|
|
116154
116839
|
}
|
|
116155
116840
|
async streamOneTurn(options2, autoSend) {
|
|
116156
116841
|
this.isListening = true;
|
|
116157
|
-
return new Promise(async (
|
|
116842
|
+
return new Promise(async (resolve11) => {
|
|
116158
116843
|
let resolved = false;
|
|
116159
116844
|
const finish = (text5) => {
|
|
116160
116845
|
if (resolved)
|
|
@@ -116162,7 +116847,7 @@ class VoiceManager {
|
|
|
116162
116847
|
resolved = true;
|
|
116163
116848
|
this.isListening = false;
|
|
116164
116849
|
this.streamingStop = null;
|
|
116165
|
-
|
|
116850
|
+
resolve11(text5);
|
|
116166
116851
|
};
|
|
116167
116852
|
try {
|
|
116168
116853
|
const { stop } = await this.stt.streamFromMic({
|
|
@@ -116193,7 +116878,7 @@ class VoiceManager {
|
|
|
116193
116878
|
};
|
|
116194
116879
|
} catch (err) {
|
|
116195
116880
|
this.isListening = false;
|
|
116196
|
-
|
|
116881
|
+
resolve11("");
|
|
116197
116882
|
}
|
|
116198
116883
|
});
|
|
116199
116884
|
}
|
|
@@ -117814,7 +118499,7 @@ var require_headStream = __commonJS((exports) => {
|
|
|
117814
118499
|
if ((0, stream_type_check_1.isReadableStream)(stream)) {
|
|
117815
118500
|
return (0, headStream_browser_1.headStream)(stream, bytes);
|
|
117816
118501
|
}
|
|
117817
|
-
return new Promise((
|
|
118502
|
+
return new Promise((resolve11, reject) => {
|
|
117818
118503
|
const collector = new Collector;
|
|
117819
118504
|
collector.limit = bytes;
|
|
117820
118505
|
stream.pipe(collector);
|
|
@@ -117825,7 +118510,7 @@ var require_headStream = __commonJS((exports) => {
|
|
|
117825
118510
|
collector.on("error", reject);
|
|
117826
118511
|
collector.on("finish", function() {
|
|
117827
118512
|
const bytes2 = new Uint8Array(Buffer.concat(this.buffers));
|
|
117828
|
-
|
|
118513
|
+
resolve11(bytes2);
|
|
117829
118514
|
});
|
|
117830
118515
|
});
|
|
117831
118516
|
};
|
|
@@ -118005,21 +118690,21 @@ var require_dist_cjs11 = __commonJS((exports) => {
|
|
|
118005
118690
|
let sendBody = true;
|
|
118006
118691
|
if (!externalAgent && expect === "100-continue") {
|
|
118007
118692
|
sendBody = await Promise.race([
|
|
118008
|
-
new Promise((
|
|
118009
|
-
timeoutId = Number(timing.setTimeout(() =>
|
|
118693
|
+
new Promise((resolve11) => {
|
|
118694
|
+
timeoutId = Number(timing.setTimeout(() => resolve11(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
118010
118695
|
}),
|
|
118011
|
-
new Promise((
|
|
118696
|
+
new Promise((resolve11) => {
|
|
118012
118697
|
httpRequest.on("continue", () => {
|
|
118013
118698
|
timing.clearTimeout(timeoutId);
|
|
118014
|
-
|
|
118699
|
+
resolve11(true);
|
|
118015
118700
|
});
|
|
118016
118701
|
httpRequest.on("response", () => {
|
|
118017
118702
|
timing.clearTimeout(timeoutId);
|
|
118018
|
-
|
|
118703
|
+
resolve11(false);
|
|
118019
118704
|
});
|
|
118020
118705
|
httpRequest.on("error", () => {
|
|
118021
118706
|
timing.clearTimeout(timeoutId);
|
|
118022
|
-
|
|
118707
|
+
resolve11(false);
|
|
118023
118708
|
});
|
|
118024
118709
|
})
|
|
118025
118710
|
]);
|
|
@@ -118092,13 +118777,13 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
118092
118777
|
return socketWarningTimestamp;
|
|
118093
118778
|
}
|
|
118094
118779
|
constructor(options2) {
|
|
118095
|
-
this.configProvider = new Promise((
|
|
118780
|
+
this.configProvider = new Promise((resolve11, reject) => {
|
|
118096
118781
|
if (typeof options2 === "function") {
|
|
118097
118782
|
options2().then((_options) => {
|
|
118098
|
-
|
|
118783
|
+
resolve11(this.resolveDefaultConfig(_options));
|
|
118099
118784
|
}).catch(reject);
|
|
118100
118785
|
} else {
|
|
118101
|
-
|
|
118786
|
+
resolve11(this.resolveDefaultConfig(options2));
|
|
118102
118787
|
}
|
|
118103
118788
|
});
|
|
118104
118789
|
}
|
|
@@ -118141,7 +118826,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
118141
118826
|
const config = this.config;
|
|
118142
118827
|
let writeRequestBodyPromise = undefined;
|
|
118143
118828
|
const timeouts = [];
|
|
118144
|
-
const
|
|
118829
|
+
const resolve11 = async (arg) => {
|
|
118145
118830
|
await writeRequestBodyPromise;
|
|
118146
118831
|
timeouts.forEach(timing.clearTimeout);
|
|
118147
118832
|
_resolve(arg);
|
|
@@ -118207,7 +118892,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
118207
118892
|
headers: getTransformedHeaders(res.headers),
|
|
118208
118893
|
body: res
|
|
118209
118894
|
});
|
|
118210
|
-
|
|
118895
|
+
resolve11({ response: httpResponse });
|
|
118211
118896
|
});
|
|
118212
118897
|
req.on("error", (err) => {
|
|
118213
118898
|
if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
|
|
@@ -118390,13 +119075,13 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
118390
119075
|
return new NodeHttp2Handler(instanceOrOptions);
|
|
118391
119076
|
}
|
|
118392
119077
|
constructor(options2) {
|
|
118393
|
-
this.configProvider = new Promise((
|
|
119078
|
+
this.configProvider = new Promise((resolve11, reject) => {
|
|
118394
119079
|
if (typeof options2 === "function") {
|
|
118395
119080
|
options2().then((opts) => {
|
|
118396
|
-
|
|
119081
|
+
resolve11(opts || {});
|
|
118397
119082
|
}).catch(reject);
|
|
118398
119083
|
} else {
|
|
118399
|
-
|
|
119084
|
+
resolve11(options2 || {});
|
|
118400
119085
|
}
|
|
118401
119086
|
});
|
|
118402
119087
|
}
|
|
@@ -118416,7 +119101,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
118416
119101
|
return new Promise((_resolve, _reject) => {
|
|
118417
119102
|
let fulfilled = false;
|
|
118418
119103
|
let writeRequestBodyPromise = undefined;
|
|
118419
|
-
const
|
|
119104
|
+
const resolve11 = async (arg) => {
|
|
118420
119105
|
await writeRequestBodyPromise;
|
|
118421
119106
|
_resolve(arg);
|
|
118422
119107
|
};
|
|
@@ -118472,7 +119157,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
118472
119157
|
body: req
|
|
118473
119158
|
});
|
|
118474
119159
|
fulfilled = true;
|
|
118475
|
-
|
|
119160
|
+
resolve11({ response: httpResponse });
|
|
118476
119161
|
if (disableConcurrentStreams) {
|
|
118477
119162
|
session.close();
|
|
118478
119163
|
this.connectionManager.deleteSession(authority, session);
|
|
@@ -118550,7 +119235,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
118550
119235
|
if (isReadableStreamInstance(stream2)) {
|
|
118551
119236
|
return collectReadableStream(stream2);
|
|
118552
119237
|
}
|
|
118553
|
-
return new Promise((
|
|
119238
|
+
return new Promise((resolve11, reject) => {
|
|
118554
119239
|
const collector = new Collector;
|
|
118555
119240
|
stream2.pipe(collector);
|
|
118556
119241
|
stream2.on("error", (err) => {
|
|
@@ -118560,7 +119245,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
118560
119245
|
collector.on("error", reject);
|
|
118561
119246
|
collector.on("finish", function() {
|
|
118562
119247
|
const bytes = new Uint8Array(Buffer.concat(this.bufferedBytes));
|
|
118563
|
-
|
|
119248
|
+
resolve11(bytes);
|
|
118564
119249
|
});
|
|
118565
119250
|
});
|
|
118566
119251
|
};
|
|
@@ -118601,7 +119286,7 @@ var require_dist_cjs12 = __commonJS((exports) => {
|
|
|
118601
119286
|
return new Request(url, requestOptions);
|
|
118602
119287
|
}
|
|
118603
119288
|
function requestTimeout(timeoutInMs = 0) {
|
|
118604
|
-
return new Promise((
|
|
119289
|
+
return new Promise((resolve11, reject) => {
|
|
118605
119290
|
if (timeoutInMs) {
|
|
118606
119291
|
setTimeout(() => {
|
|
118607
119292
|
const timeoutError = new Error(`Request did not complete within ${timeoutInMs} ms`);
|
|
@@ -118718,7 +119403,7 @@ var require_dist_cjs12 = __commonJS((exports) => {
|
|
|
118718
119403
|
requestTimeout(requestTimeoutInMs)
|
|
118719
119404
|
];
|
|
118720
119405
|
if (abortSignal) {
|
|
118721
|
-
raceOfPromises.push(new Promise((
|
|
119406
|
+
raceOfPromises.push(new Promise((resolve11, reject) => {
|
|
118722
119407
|
const onAbort = () => {
|
|
118723
119408
|
const abortError = new Error("Request aborted");
|
|
118724
119409
|
abortError.name = "AbortError";
|
|
@@ -118782,7 +119467,7 @@ var require_dist_cjs12 = __commonJS((exports) => {
|
|
|
118782
119467
|
return collected;
|
|
118783
119468
|
}
|
|
118784
119469
|
function readToBase64(blob) {
|
|
118785
|
-
return new Promise((
|
|
119470
|
+
return new Promise((resolve11, reject) => {
|
|
118786
119471
|
const reader = new FileReader;
|
|
118787
119472
|
reader.onloadend = () => {
|
|
118788
119473
|
if (reader.readyState !== 2) {
|
|
@@ -118791,7 +119476,7 @@ var require_dist_cjs12 = __commonJS((exports) => {
|
|
|
118791
119476
|
const result = reader.result ?? "";
|
|
118792
119477
|
const commaIndex = result.indexOf(",");
|
|
118793
119478
|
const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length;
|
|
118794
|
-
|
|
119479
|
+
resolve11(result.substring(dataOffset));
|
|
118795
119480
|
};
|
|
118796
119481
|
reader.onabort = () => reject(new Error("Read aborted"));
|
|
118797
119482
|
reader.onerror = () => reject(reader.error);
|
|
@@ -119909,11 +120594,11 @@ var require_tslib = __commonJS((exports, module) => {
|
|
|
119909
120594
|
};
|
|
119910
120595
|
__awaiter = function(thisArg, _arguments, P, generator) {
|
|
119911
120596
|
function adopt(value2) {
|
|
119912
|
-
return value2 instanceof P ? value2 : new P(function(
|
|
119913
|
-
|
|
120597
|
+
return value2 instanceof P ? value2 : new P(function(resolve11) {
|
|
120598
|
+
resolve11(value2);
|
|
119914
120599
|
});
|
|
119915
120600
|
}
|
|
119916
|
-
return new (P || (P = Promise))(function(
|
|
120601
|
+
return new (P || (P = Promise))(function(resolve11, reject) {
|
|
119917
120602
|
function fulfilled(value2) {
|
|
119918
120603
|
try {
|
|
119919
120604
|
step(generator.next(value2));
|
|
@@ -119929,7 +120614,7 @@ var require_tslib = __commonJS((exports, module) => {
|
|
|
119929
120614
|
}
|
|
119930
120615
|
}
|
|
119931
120616
|
function step(result) {
|
|
119932
|
-
result.done ?
|
|
120617
|
+
result.done ? resolve11(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
119933
120618
|
}
|
|
119934
120619
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
119935
120620
|
});
|
|
@@ -120158,14 +120843,14 @@ var require_tslib = __commonJS((exports, module) => {
|
|
|
120158
120843
|
}, i);
|
|
120159
120844
|
function verb(n) {
|
|
120160
120845
|
i[n] = o[n] && function(v) {
|
|
120161
|
-
return new Promise(function(
|
|
120162
|
-
v = o[n](v), settle(
|
|
120846
|
+
return new Promise(function(resolve11, reject) {
|
|
120847
|
+
v = o[n](v), settle(resolve11, reject, v.done, v.value);
|
|
120163
120848
|
});
|
|
120164
120849
|
};
|
|
120165
120850
|
}
|
|
120166
|
-
function settle(
|
|
120851
|
+
function settle(resolve11, reject, d, v) {
|
|
120167
120852
|
Promise.resolve(v).then(function(v2) {
|
|
120168
|
-
|
|
120853
|
+
resolve11({ value: v2, done: d });
|
|
120169
120854
|
}, reject);
|
|
120170
120855
|
}
|
|
120171
120856
|
};
|
|
@@ -132490,7 +133175,7 @@ var require_dist_cjs39 = __commonJS((exports) => {
|
|
|
132490
133175
|
this.refillTokenBucket();
|
|
132491
133176
|
if (amount > this.currentCapacity) {
|
|
132492
133177
|
const delay = (amount - this.currentCapacity) / this.fillRate * 1000;
|
|
132493
|
-
await new Promise((
|
|
133178
|
+
await new Promise((resolve11) => DefaultRateLimiter.setTimeoutFn(resolve11, delay));
|
|
132494
133179
|
}
|
|
132495
133180
|
this.currentCapacity = this.currentCapacity - amount;
|
|
132496
133181
|
}
|
|
@@ -132823,7 +133508,7 @@ var require_dist_cjs40 = __commonJS((exports) => {
|
|
|
132823
133508
|
const delayFromResponse = getDelayFromRetryAfterHeader(err.$response);
|
|
132824
133509
|
const delay = Math.max(delayFromResponse || 0, delayFromDecider);
|
|
132825
133510
|
totalDelay += delay;
|
|
132826
|
-
await new Promise((
|
|
133511
|
+
await new Promise((resolve11) => setTimeout(resolve11, delay));
|
|
132827
133512
|
continue;
|
|
132828
133513
|
}
|
|
132829
133514
|
if (!err.$metadata) {
|
|
@@ -132982,7 +133667,7 @@ var require_dist_cjs40 = __commonJS((exports) => {
|
|
|
132982
133667
|
attempts = retryToken.getRetryCount();
|
|
132983
133668
|
const delay = retryToken.getRetryDelay();
|
|
132984
133669
|
totalRetryDelay += delay;
|
|
132985
|
-
await new Promise((
|
|
133670
|
+
await new Promise((resolve11) => setTimeout(resolve11, delay));
|
|
132986
133671
|
}
|
|
132987
133672
|
}
|
|
132988
133673
|
} else {
|
|
@@ -138049,7 +138734,7 @@ var init_dist_es9 = __esm(() => {
|
|
|
138049
138734
|
import { Buffer as Buffer3 } from "buffer";
|
|
138050
138735
|
import { request } from "http";
|
|
138051
138736
|
function httpRequest(options2) {
|
|
138052
|
-
return new Promise((
|
|
138737
|
+
return new Promise((resolve11, reject) => {
|
|
138053
138738
|
const req = request({
|
|
138054
138739
|
method: "GET",
|
|
138055
138740
|
...options2,
|
|
@@ -138074,7 +138759,7 @@ function httpRequest(options2) {
|
|
|
138074
138759
|
chunks.push(chunk);
|
|
138075
138760
|
});
|
|
138076
138761
|
res.on("end", () => {
|
|
138077
|
-
|
|
138762
|
+
resolve11(Buffer3.concat(chunks));
|
|
138078
138763
|
req.destroy();
|
|
138079
138764
|
});
|
|
138080
138765
|
});
|
|
@@ -138535,7 +139220,7 @@ var retryWrapper = (toRetry, maxRetries, delayMs) => {
|
|
|
138535
139220
|
try {
|
|
138536
139221
|
return await toRetry();
|
|
138537
139222
|
} catch (e2) {
|
|
138538
|
-
await new Promise((
|
|
139223
|
+
await new Promise((resolve11) => setTimeout(resolve11, delayMs));
|
|
138539
139224
|
}
|
|
138540
139225
|
}
|
|
138541
139226
|
return await toRetry();
|
|
@@ -144439,7 +145124,7 @@ var require_signin = __commonJS((exports) => {
|
|
|
144439
145124
|
// node_modules/.pnpm/@aws-sdk+credential-provider-login@3.972.8/node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js
|
|
144440
145125
|
import { createHash as createHash5, createPrivateKey, createPublicKey, sign } from "crypto";
|
|
144441
145126
|
import { promises as fs2 } from "fs";
|
|
144442
|
-
import { homedir as
|
|
145127
|
+
import { homedir as homedir22 } from "os";
|
|
144443
145128
|
import { dirname as dirname13, join as join33 } from "path";
|
|
144444
145129
|
var import_property_provider18, import_protocol_http11, import_shared_ini_file_loader6, LoginCredentialsFetcher;
|
|
144445
145130
|
var init_LoginCredentialsFetcher = __esm(() => {
|
|
@@ -144600,7 +145285,7 @@ var init_LoginCredentialsFetcher = __esm(() => {
|
|
|
144600
145285
|
await fs2.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
|
|
144601
145286
|
}
|
|
144602
145287
|
getTokenFilePath() {
|
|
144603
|
-
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join33(
|
|
145288
|
+
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join33(homedir22(), ".aws", "login", "cache");
|
|
144604
145289
|
const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
|
|
144605
145290
|
const loginSessionSha256 = createHash5("sha256").update(loginSessionBytes).digest("hex");
|
|
144606
145291
|
return join33(directory, `${loginSessionSha256}.json`);
|
|
@@ -144777,14 +145462,14 @@ var init_getValidatedProcessCredentials = __esm(() => {
|
|
|
144777
145462
|
});
|
|
144778
145463
|
|
|
144779
145464
|
// node_modules/.pnpm/@aws-sdk+credential-provider-process@3.972.8/node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js
|
|
144780
|
-
import { exec as
|
|
145465
|
+
import { exec as exec3 } from "child_process";
|
|
144781
145466
|
import { promisify } from "util";
|
|
144782
145467
|
var import_property_provider20, import_shared_ini_file_loader8, resolveProcessCredentials = async (profileName, profiles, logger) => {
|
|
144783
145468
|
const profile = profiles[profileName];
|
|
144784
145469
|
if (profiles[profileName]) {
|
|
144785
145470
|
const credentialProcess = profile["credential_process"];
|
|
144786
145471
|
if (credentialProcess !== undefined) {
|
|
144787
|
-
const execPromise = promisify(import_shared_ini_file_loader8.externalDataInterceptor?.getTokenRecord?.().exec ??
|
|
145472
|
+
const execPromise = promisify(import_shared_ini_file_loader8.externalDataInterceptor?.getTokenRecord?.().exec ?? exec3);
|
|
144788
145473
|
try {
|
|
144789
145474
|
const { stdout } = await execPromise(credentialProcess);
|
|
144790
145475
|
let data;
|
|
@@ -145708,7 +146393,7 @@ async function* readabletoIterable(readStream) {
|
|
|
145708
146393
|
streamEnded = true;
|
|
145709
146394
|
});
|
|
145710
146395
|
while (!generationEnded) {
|
|
145711
|
-
const value2 = await new Promise((
|
|
146396
|
+
const value2 = await new Promise((resolve11) => setTimeout(() => resolve11(records.shift()), 0));
|
|
145712
146397
|
if (value2) {
|
|
145713
146398
|
yield value2;
|
|
145714
146399
|
}
|
|
@@ -145784,14 +146469,14 @@ var readableStreamHasher = (hashCtor, readableStream) => {
|
|
|
145784
146469
|
const hash = new hashCtor;
|
|
145785
146470
|
const hashCalculator = new HashCalculator(hash);
|
|
145786
146471
|
readableStream.pipe(hashCalculator);
|
|
145787
|
-
return new Promise((
|
|
146472
|
+
return new Promise((resolve11, reject) => {
|
|
145788
146473
|
readableStream.on("error", (err) => {
|
|
145789
146474
|
hashCalculator.end();
|
|
145790
146475
|
reject(err);
|
|
145791
146476
|
});
|
|
145792
146477
|
hashCalculator.on("error", reject);
|
|
145793
146478
|
hashCalculator.on("finish", () => {
|
|
145794
|
-
hash.digest().then(
|
|
146479
|
+
hash.digest().then(resolve11).catch(reject);
|
|
145795
146480
|
});
|
|
145796
146481
|
});
|
|
145797
146482
|
};
|
|
@@ -148446,7 +149131,7 @@ var getCircularReplacer = () => {
|
|
|
148446
149131
|
|
|
148447
149132
|
// node_modules/.pnpm/@smithy+util-waiter@4.2.8/node_modules/@smithy/util-waiter/dist-es/utils/sleep.js
|
|
148448
149133
|
var sleep5 = (seconds) => {
|
|
148449
|
-
return new Promise((
|
|
149134
|
+
return new Promise((resolve11) => setTimeout(resolve11, seconds * 1000));
|
|
148450
149135
|
};
|
|
148451
149136
|
|
|
148452
149137
|
// node_modules/.pnpm/@smithy+util-waiter@4.2.8/node_modules/@smithy/util-waiter/dist-es/waiter.js
|
|
@@ -148564,8 +149249,8 @@ var init_utils5 = () => {};
|
|
|
148564
149249
|
// node_modules/.pnpm/@smithy+util-waiter@4.2.8/node_modules/@smithy/util-waiter/dist-es/createWaiter.js
|
|
148565
149250
|
var abortTimeout = (abortSignal) => {
|
|
148566
149251
|
let onAbort;
|
|
148567
|
-
const promise = new Promise((
|
|
148568
|
-
onAbort = () =>
|
|
149252
|
+
const promise = new Promise((resolve11) => {
|
|
149253
|
+
onAbort = () => resolve11({ state: WaiterState.ABORTED });
|
|
148569
149254
|
if (typeof abortSignal.addEventListener === "function") {
|
|
148570
149255
|
abortSignal.addEventListener("abort", onAbort);
|
|
148571
149256
|
} else {
|
|
@@ -149261,7 +149946,7 @@ var init_s3_client = __esm(() => {
|
|
|
149261
149946
|
|
|
149262
149947
|
// packages/core/src/inbox/storage/local-cache.ts
|
|
149263
149948
|
import { join as join35, basename as basename7 } from "path";
|
|
149264
|
-
import { mkdir as mkdir8, readFile as readFile9, writeFile as writeFile8, rm as rm3, readdir, stat as
|
|
149949
|
+
import { mkdir as mkdir8, readFile as readFile9, writeFile as writeFile8, rm as rm3, readdir, stat as stat6 } from "fs/promises";
|
|
149265
149950
|
import { createHash as createHash6 } from "crypto";
|
|
149266
149951
|
function isValidAssistantId(id) {
|
|
149267
149952
|
return typeof id === "string" && id.length > 0 && STRICT_ID_PATTERN.test(id);
|
|
@@ -149425,7 +150110,7 @@ class LocalInboxCache {
|
|
|
149425
150110
|
}
|
|
149426
150111
|
try {
|
|
149427
150112
|
const attachmentPath = join35(this.cacheDir, "attachments", emailFilename, safeFilename);
|
|
149428
|
-
await
|
|
150113
|
+
await stat6(attachmentPath);
|
|
149429
150114
|
return attachmentPath;
|
|
149430
150115
|
} catch {
|
|
149431
150116
|
return null;
|
|
@@ -149465,7 +150150,7 @@ class LocalInboxCache {
|
|
|
149465
150150
|
const emailsDir = join35(this.cacheDir, "emails");
|
|
149466
150151
|
const files = await readdir(emailsDir);
|
|
149467
150152
|
for (const file of files) {
|
|
149468
|
-
const fileStat = await
|
|
150153
|
+
const fileStat = await stat6(join35(emailsDir, file));
|
|
149469
150154
|
totalSize += fileStat.size;
|
|
149470
150155
|
}
|
|
149471
150156
|
} catch {}
|
|
@@ -149475,7 +150160,7 @@ class LocalInboxCache {
|
|
|
149475
150160
|
for (const dir of dirs) {
|
|
149476
150161
|
const files = await readdir(join35(attachmentsDir, dir));
|
|
149477
150162
|
for (const file of files) {
|
|
149478
|
-
const fileStat = await
|
|
150163
|
+
const fileStat = await stat6(join35(attachmentsDir, dir, file));
|
|
149479
150164
|
totalSize += fileStat.size;
|
|
149480
150165
|
}
|
|
149481
150166
|
}
|
|
@@ -154245,9 +154930,9 @@ async function blobToArrayBuffer(blob) {
|
|
|
154245
154930
|
return await blob.arrayBuffer();
|
|
154246
154931
|
}
|
|
154247
154932
|
const fr = new FileReader;
|
|
154248
|
-
return new Promise((
|
|
154933
|
+
return new Promise((resolve11, reject) => {
|
|
154249
154934
|
fr.onload = function(e4) {
|
|
154250
|
-
|
|
154935
|
+
resolve11(e4.target.result);
|
|
154251
154936
|
};
|
|
154252
154937
|
fr.onerror = function(e4) {
|
|
154253
154938
|
reject(fr.error);
|
|
@@ -158822,11 +159507,11 @@ var require_dist = __commonJS((exports) => {
|
|
|
158822
159507
|
var require_request = __commonJS((exports) => {
|
|
158823
159508
|
var __awaiter2 = exports && exports.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
158824
159509
|
function adopt(value2) {
|
|
158825
|
-
return value2 instanceof P2 ? value2 : new P2(function(
|
|
158826
|
-
|
|
159510
|
+
return value2 instanceof P2 ? value2 : new P2(function(resolve11) {
|
|
159511
|
+
resolve11(value2);
|
|
158827
159512
|
});
|
|
158828
159513
|
}
|
|
158829
|
-
return new (P2 || (P2 = Promise))(function(
|
|
159514
|
+
return new (P2 || (P2 = Promise))(function(resolve11, reject) {
|
|
158830
159515
|
function fulfilled(value2) {
|
|
158831
159516
|
try {
|
|
158832
159517
|
step(generator.next(value2));
|
|
@@ -158842,7 +159527,7 @@ var require_request = __commonJS((exports) => {
|
|
|
158842
159527
|
}
|
|
158843
159528
|
}
|
|
158844
159529
|
function step(result) {
|
|
158845
|
-
result.done ?
|
|
159530
|
+
result.done ? resolve11(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
158846
159531
|
}
|
|
158847
159532
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
158848
159533
|
});
|
|
@@ -158972,7 +159657,7 @@ var require_request = __commonJS((exports) => {
|
|
|
158972
159657
|
}
|
|
158973
159658
|
function sendWithRetry(url, init, retryScheduleInMs, nextInterval = 50, triesLeft = 2, fetchImpl = fetch, retryCount = 1) {
|
|
158974
159659
|
return __awaiter2(this, undefined, undefined, function* () {
|
|
158975
|
-
const sleep7 = (interval) => new Promise((
|
|
159660
|
+
const sleep7 = (interval) => new Promise((resolve11) => setTimeout(resolve11, interval));
|
|
158976
159661
|
try {
|
|
158977
159662
|
const response = yield fetchImpl(url, init);
|
|
158978
159663
|
if (triesLeft <= 0 || response.status < 500) {
|
|
@@ -173708,7 +174393,7 @@ import { createInterface } from "readline";
|
|
|
173708
174393
|
import * as fs3 from "fs";
|
|
173709
174394
|
import { stat as statPromise, open as open2 } from "fs/promises";
|
|
173710
174395
|
import { join as join39 } from "path";
|
|
173711
|
-
import { homedir as
|
|
174396
|
+
import { homedir as homedir23 } from "os";
|
|
173712
174397
|
import { dirname as dirname14, join as join210 } from "path";
|
|
173713
174398
|
import { cwd } from "process";
|
|
173714
174399
|
import { realpathSync as realpathSync2 } from "fs";
|
|
@@ -173992,7 +174677,7 @@ function shouldShowDebugMessage(message, filter) {
|
|
|
173992
174677
|
return shouldShowDebugCategories(categories, filter);
|
|
173993
174678
|
}
|
|
173994
174679
|
function getClaudeConfigHomeDir() {
|
|
173995
|
-
return process.env.CLAUDE_CONFIG_DIR ?? join39(
|
|
174680
|
+
return process.env.CLAUDE_CONFIG_DIR ?? join39(homedir23(), ".claude");
|
|
173996
174681
|
}
|
|
173997
174682
|
function isEnvTruthy(envVar) {
|
|
173998
174683
|
if (!envVar)
|
|
@@ -174688,7 +175373,7 @@ class ProcessTransport {
|
|
|
174688
175373
|
}
|
|
174689
175374
|
return;
|
|
174690
175375
|
}
|
|
174691
|
-
return new Promise((
|
|
175376
|
+
return new Promise((resolve11, reject) => {
|
|
174692
175377
|
const exitHandler = (code3, signal) => {
|
|
174693
175378
|
if (this.abortController.signal.aborted) {
|
|
174694
175379
|
reject(new AbortError("Operation aborted"));
|
|
@@ -174698,7 +175383,7 @@ class ProcessTransport {
|
|
|
174698
175383
|
if (error3) {
|
|
174699
175384
|
reject(error3);
|
|
174700
175385
|
} else {
|
|
174701
|
-
|
|
175386
|
+
resolve11();
|
|
174702
175387
|
}
|
|
174703
175388
|
};
|
|
174704
175389
|
this.process.once("exit", exitHandler);
|
|
@@ -178945,7 +179630,7 @@ class Protocol {
|
|
|
178945
179630
|
return;
|
|
178946
179631
|
}
|
|
178947
179632
|
const pollInterval = (_c5 = (_a4 = task2.pollInterval) !== null && _a4 !== undefined ? _a4 : (_b = this._options) === null || _b === undefined ? undefined : _b.defaultTaskPollInterval) !== null && _c5 !== undefined ? _c5 : 1000;
|
|
178948
|
-
await new Promise((
|
|
179633
|
+
await new Promise((resolve11) => setTimeout(resolve11, pollInterval));
|
|
178949
179634
|
(_d2 = options2 === null || options2 === undefined ? undefined : options2.signal) === null || _d2 === undefined || _d2.throwIfAborted();
|
|
178950
179635
|
}
|
|
178951
179636
|
} catch (error22) {
|
|
@@ -178957,7 +179642,7 @@ class Protocol {
|
|
|
178957
179642
|
}
|
|
178958
179643
|
request(request2, resultSchema, options2) {
|
|
178959
179644
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options2 !== null && options2 !== undefined ? options2 : {};
|
|
178960
|
-
return new Promise((
|
|
179645
|
+
return new Promise((resolve11, reject) => {
|
|
178961
179646
|
var _a4, _b, _c5, _d2, _e5, _f, _g;
|
|
178962
179647
|
const earlyReject = (error22) => {
|
|
178963
179648
|
reject(error22);
|
|
@@ -179038,7 +179723,7 @@ class Protocol {
|
|
|
179038
179723
|
if (!parseResult.success) {
|
|
179039
179724
|
reject(parseResult.error);
|
|
179040
179725
|
} else {
|
|
179041
|
-
|
|
179726
|
+
resolve11(parseResult.data);
|
|
179042
179727
|
}
|
|
179043
179728
|
} catch (error22) {
|
|
179044
179729
|
reject(error22);
|
|
@@ -179234,12 +179919,12 @@ class Protocol {
|
|
|
179234
179919
|
interval = task.pollInterval;
|
|
179235
179920
|
}
|
|
179236
179921
|
} catch (_d2) {}
|
|
179237
|
-
return new Promise((
|
|
179922
|
+
return new Promise((resolve11, reject) => {
|
|
179238
179923
|
if (signal.aborted) {
|
|
179239
179924
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
179240
179925
|
return;
|
|
179241
179926
|
}
|
|
179242
|
-
const timeoutId = setTimeout(
|
|
179927
|
+
const timeoutId = setTimeout(resolve11, interval);
|
|
179243
179928
|
signal.addEventListener("abort", () => {
|
|
179244
179929
|
clearTimeout(timeoutId);
|
|
179245
179930
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -179690,7 +180375,7 @@ class McpServer {
|
|
|
179690
180375
|
let task = createTaskResult.task;
|
|
179691
180376
|
const pollInterval = (_a4 = task.pollInterval) !== null && _a4 !== undefined ? _a4 : 5000;
|
|
179692
180377
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
179693
|
-
await new Promise((
|
|
180378
|
+
await new Promise((resolve11) => setTimeout(resolve11, pollInterval));
|
|
179694
180379
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
179695
180380
|
if (!updatedTask) {
|
|
179696
180381
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -184001,7 +184686,7 @@ var init_sdk2 = __esm(() => {
|
|
|
184001
184686
|
const schOrFunc = root2.refs[ref];
|
|
184002
184687
|
if (schOrFunc)
|
|
184003
184688
|
return schOrFunc;
|
|
184004
|
-
let _sch =
|
|
184689
|
+
let _sch = resolve11.call(this, root2, ref);
|
|
184005
184690
|
if (_sch === undefined) {
|
|
184006
184691
|
const schema = (_a4 = root2.localRefs) === null || _a4 === undefined ? undefined : _a4[ref];
|
|
184007
184692
|
const { schemaId } = this.opts;
|
|
@@ -184028,7 +184713,7 @@ var init_sdk2 = __esm(() => {
|
|
|
184028
184713
|
function sameSchemaEnv(s1, s22) {
|
|
184029
184714
|
return s1.schema === s22.schema && s1.root === s22.root && s1.baseId === s22.baseId;
|
|
184030
184715
|
}
|
|
184031
|
-
function
|
|
184716
|
+
function resolve11(root2, ref) {
|
|
184032
184717
|
let sch;
|
|
184033
184718
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
184034
184719
|
ref = sch;
|
|
@@ -184526,7 +185211,7 @@ var init_sdk2 = __esm(() => {
|
|
|
184526
185211
|
}
|
|
184527
185212
|
return uri;
|
|
184528
185213
|
}
|
|
184529
|
-
function
|
|
185214
|
+
function resolve11(baseURI, relativeURI, options2) {
|
|
184530
185215
|
const schemelessOptions = Object.assign({ scheme: "null" }, options2);
|
|
184531
185216
|
const resolved = resolveComponents(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
184532
185217
|
return serialize2(resolved, { ...schemelessOptions, skipEscape: true });
|
|
@@ -184759,7 +185444,7 @@ var init_sdk2 = __esm(() => {
|
|
|
184759
185444
|
var fastUri = {
|
|
184760
185445
|
SCHEMES,
|
|
184761
185446
|
normalize: normalize2,
|
|
184762
|
-
resolve:
|
|
185447
|
+
resolve: resolve11,
|
|
184763
185448
|
resolveComponents,
|
|
184764
185449
|
equal,
|
|
184765
185450
|
serialize: serialize2,
|
|
@@ -187803,17 +188488,17 @@ var init_sdk2 = __esm(() => {
|
|
|
187803
188488
|
if (this.hasError) {
|
|
187804
188489
|
return Promise.reject(this.hasError);
|
|
187805
188490
|
}
|
|
187806
|
-
return new Promise((
|
|
187807
|
-
this.readResolve =
|
|
188491
|
+
return new Promise((resolve11, reject) => {
|
|
188492
|
+
this.readResolve = resolve11;
|
|
187808
188493
|
this.readReject = reject;
|
|
187809
188494
|
});
|
|
187810
188495
|
}
|
|
187811
188496
|
enqueue(value2) {
|
|
187812
188497
|
if (this.readResolve) {
|
|
187813
|
-
const
|
|
188498
|
+
const resolve11 = this.readResolve;
|
|
187814
188499
|
this.readResolve = undefined;
|
|
187815
188500
|
this.readReject = undefined;
|
|
187816
|
-
|
|
188501
|
+
resolve11({ done: false, value: value2 });
|
|
187817
188502
|
} else {
|
|
187818
188503
|
this.queue.push(value2);
|
|
187819
188504
|
}
|
|
@@ -187821,10 +188506,10 @@ var init_sdk2 = __esm(() => {
|
|
|
187821
188506
|
done() {
|
|
187822
188507
|
this.isDone = true;
|
|
187823
188508
|
if (this.readResolve) {
|
|
187824
|
-
const
|
|
188509
|
+
const resolve11 = this.readResolve;
|
|
187825
188510
|
this.readResolve = undefined;
|
|
187826
188511
|
this.readReject = undefined;
|
|
187827
|
-
|
|
188512
|
+
resolve11({ done: true, value: undefined });
|
|
187828
188513
|
}
|
|
187829
188514
|
}
|
|
187830
188515
|
error(error3) {
|
|
@@ -188128,10 +188813,10 @@ var init_sdk2 = __esm(() => {
|
|
|
188128
188813
|
type: "control_request",
|
|
188129
188814
|
request: request2
|
|
188130
188815
|
};
|
|
188131
|
-
return new Promise((
|
|
188816
|
+
return new Promise((resolve11, reject) => {
|
|
188132
188817
|
this.pendingControlResponses.set(requestId, (response) => {
|
|
188133
188818
|
if (response.subtype === "success") {
|
|
188134
|
-
|
|
188819
|
+
resolve11(response);
|
|
188135
188820
|
} else {
|
|
188136
188821
|
reject(new Error(response.error));
|
|
188137
188822
|
if (response.pending_permission_requests) {
|
|
@@ -188221,15 +188906,15 @@ var init_sdk2 = __esm(() => {
|
|
|
188221
188906
|
logForDebugging(`[Query.waitForFirstResult] Result already received, returning immediately`);
|
|
188222
188907
|
return Promise.resolve();
|
|
188223
188908
|
}
|
|
188224
|
-
return new Promise((
|
|
188909
|
+
return new Promise((resolve11) => {
|
|
188225
188910
|
if (this.abortController?.signal.aborted) {
|
|
188226
|
-
|
|
188911
|
+
resolve11();
|
|
188227
188912
|
return;
|
|
188228
188913
|
}
|
|
188229
|
-
this.abortController?.signal.addEventListener("abort", () =>
|
|
188914
|
+
this.abortController?.signal.addEventListener("abort", () => resolve11(), {
|
|
188230
188915
|
once: true
|
|
188231
188916
|
});
|
|
188232
|
-
this.firstResultReceivedResolve =
|
|
188917
|
+
this.firstResultReceivedResolve = resolve11;
|
|
188233
188918
|
});
|
|
188234
188919
|
}
|
|
188235
188920
|
handleHookCallbacks(callbackId, input, toolUseID, abortSignal) {
|
|
@@ -188280,13 +188965,13 @@ var init_sdk2 = __esm(() => {
|
|
|
188280
188965
|
handleMcpControlRequest(serverName, mcpRequest, transport) {
|
|
188281
188966
|
const messageId = "id" in mcpRequest.message ? mcpRequest.message.id : null;
|
|
188282
188967
|
const key = `${serverName}:${messageId}`;
|
|
188283
|
-
return new Promise((
|
|
188968
|
+
return new Promise((resolve11, reject) => {
|
|
188284
188969
|
const cleanup = () => {
|
|
188285
188970
|
this.pendingMcpResponses.delete(key);
|
|
188286
188971
|
};
|
|
188287
188972
|
const resolveAndCleanup = (response) => {
|
|
188288
188973
|
cleanup();
|
|
188289
|
-
|
|
188974
|
+
resolve11(response);
|
|
188290
188975
|
};
|
|
188291
188976
|
const rejectAndCleanup = (error3) => {
|
|
188292
188977
|
cleanup();
|
|
@@ -195116,8 +195801,8 @@ var Thread = class {
|
|
|
195116
195801
|
get id() {
|
|
195117
195802
|
return this._id;
|
|
195118
195803
|
}
|
|
195119
|
-
constructor(
|
|
195120
|
-
this._exec =
|
|
195804
|
+
constructor(exec4, options2, threadOptions, id = null) {
|
|
195805
|
+
this._exec = exec4;
|
|
195121
195806
|
this._options = options2;
|
|
195122
195807
|
this._id = id;
|
|
195123
195808
|
this._threadOptions = threadOptions;
|
|
@@ -195290,9 +195975,9 @@ var Thread = class {
|
|
|
195290
195975
|
stderrChunks.push(data);
|
|
195291
195976
|
});
|
|
195292
195977
|
}
|
|
195293
|
-
const exitPromise = new Promise((
|
|
195978
|
+
const exitPromise = new Promise((resolve11) => {
|
|
195294
195979
|
child.once("exit", (code3, signal) => {
|
|
195295
|
-
|
|
195980
|
+
resolve11({ code: code3, signal });
|
|
195296
195981
|
});
|
|
195297
195982
|
});
|
|
195298
195983
|
const rl = readline.createInterface({
|
|
@@ -196109,8 +196794,8 @@ class ChannelAgentPool {
|
|
|
196109
196794
|
this.clientFactory = options2?.clientFactory;
|
|
196110
196795
|
}
|
|
196111
196796
|
async triggerResponses(channelName, personName, message, channelMembers, excludeAssistantId) {
|
|
196112
|
-
return new Promise((
|
|
196113
|
-
this.queue.push({ channelName, personName, message, channelMembers, excludeAssistantId, resolve:
|
|
196797
|
+
return new Promise((resolve11, reject) => {
|
|
196798
|
+
this.queue.push({ channelName, personName, message, channelMembers, excludeAssistantId, resolve: resolve11, reject });
|
|
196114
196799
|
this.drainQueue();
|
|
196115
196800
|
});
|
|
196116
196801
|
}
|
|
@@ -197945,7 +198630,7 @@ class BridgeConnection {
|
|
|
197945
198630
|
}
|
|
197946
198631
|
async connect() {
|
|
197947
198632
|
const url = `${ELEVENLABS_WS_BASE}?agent_id=${this.config.elevenLabsAgentId}`;
|
|
197948
|
-
return new Promise((
|
|
198633
|
+
return new Promise((resolve11, reject) => {
|
|
197949
198634
|
try {
|
|
197950
198635
|
this.elevenLabsWs = new WebSocket(url, {
|
|
197951
198636
|
headers: {
|
|
@@ -197954,7 +198639,7 @@ class BridgeConnection {
|
|
|
197954
198639
|
});
|
|
197955
198640
|
this.elevenLabsWs.onopen = () => {
|
|
197956
198641
|
this.state = "active";
|
|
197957
|
-
|
|
198642
|
+
resolve11();
|
|
197958
198643
|
};
|
|
197959
198644
|
this.elevenLabsWs.onmessage = (event) => {
|
|
197960
198645
|
this.handleElevenLabsMessage(event.data);
|
|
@@ -202953,7 +203638,7 @@ function createSelfAwarenessToolExecutors(context) {
|
|
|
202953
203638
|
return JSON.stringify(response, null, 2);
|
|
202954
203639
|
},
|
|
202955
203640
|
workspace_map: async (input) => {
|
|
202956
|
-
const { readdir: readdir2, stat:
|
|
203641
|
+
const { readdir: readdir2, stat: stat7, access } = await import("fs/promises");
|
|
202957
203642
|
const { execSync } = await import("child_process");
|
|
202958
203643
|
const { join: join40, basename: basename8 } = await import("path");
|
|
202959
203644
|
const depth = input.depth ?? 3;
|
|
@@ -203062,7 +203747,7 @@ function createSelfAwarenessToolExecutors(context) {
|
|
|
203062
203747
|
const relPath = relativePath ? `${relativePath}/${entry.name}` : entry.name;
|
|
203063
203748
|
if (entry.isFile()) {
|
|
203064
203749
|
try {
|
|
203065
|
-
const stats = await
|
|
203750
|
+
const stats = await stat7(fullPath);
|
|
203066
203751
|
recentFiles.push({
|
|
203067
203752
|
path: relPath,
|
|
203068
203753
|
mtime: stats.mtime.toISOString()
|
|
@@ -204765,7 +205450,31 @@ function createCapabilitiesGetExecutor(context) {
|
|
|
204765
205450
|
return async (input) => {
|
|
204766
205451
|
const section = input.section || "all";
|
|
204767
205452
|
if (!context.isEnabled()) {
|
|
204768
|
-
|
|
205453
|
+
const lines2 = [];
|
|
205454
|
+
lines2.push("## Capabilities (enforcement disabled)");
|
|
205455
|
+
lines2.push("");
|
|
205456
|
+
lines2.push("Capability enforcement is not active \u2014 all tools and skills are available without restrictions.");
|
|
205457
|
+
lines2.push("");
|
|
205458
|
+
const orchestrationLevel = context.getOrchestrationLevel?.();
|
|
205459
|
+
if (orchestrationLevel) {
|
|
205460
|
+
lines2.push(`Orchestration level: ${orchestrationLevel}`);
|
|
205461
|
+
}
|
|
205462
|
+
const toolPolicy = context.getToolPolicy?.();
|
|
205463
|
+
if (toolPolicy) {
|
|
205464
|
+
lines2.push(`Tool access policy: ${toolPolicy}`);
|
|
205465
|
+
}
|
|
205466
|
+
const allowedTools = context.getAllowedTools?.();
|
|
205467
|
+
if (allowedTools && allowedTools.length > 0) {
|
|
205468
|
+
lines2.push(`Registered tools: ${allowedTools.length}`);
|
|
205469
|
+
}
|
|
205470
|
+
const deniedTools = context.getDeniedTools?.();
|
|
205471
|
+
if (deniedTools && deniedTools.length > 0) {
|
|
205472
|
+
lines2.push(`Denied tools: ${deniedTools.join(", ")}`);
|
|
205473
|
+
}
|
|
205474
|
+
lines2.push("");
|
|
205475
|
+
lines2.push("To enable capability enforcement, configure capabilities in the assistant settings.");
|
|
205476
|
+
return lines2.join(`
|
|
205477
|
+
`);
|
|
204769
205478
|
}
|
|
204770
205479
|
const capabilities = context.getCapabilities();
|
|
204771
205480
|
if (!capabilities) {
|
|
@@ -205953,15 +206662,15 @@ var init_types11 = __esm(() => {
|
|
|
205953
206662
|
// node_modules/.pnpm/@hasna+mementos@0.3.9_@types+react@19.2.14/node_modules/@hasna/mementos/dist/index.js
|
|
205954
206663
|
import { Database as Database3 } from "bun:sqlite";
|
|
205955
206664
|
import { existsSync as existsSync27, mkdirSync as mkdirSync14 } from "fs";
|
|
205956
|
-
import { dirname as dirname15, join as join40, resolve as
|
|
206665
|
+
import { dirname as dirname15, join as join40, resolve as resolve11 } from "path";
|
|
205957
206666
|
import { existsSync as existsSync28, mkdirSync as mkdirSync24, readFileSync as readFileSync13 } from "fs";
|
|
205958
|
-
import { homedir as
|
|
206667
|
+
import { homedir as homedir24 } from "os";
|
|
205959
206668
|
import { dirname as dirname22, join as join212, resolve as resolve22 } from "path";
|
|
205960
206669
|
function isInMemoryDb2(path5) {
|
|
205961
206670
|
return path5 === ":memory:" || path5.startsWith("file::memory:");
|
|
205962
206671
|
}
|
|
205963
206672
|
function findNearestMementosDb(startDir) {
|
|
205964
|
-
let dir =
|
|
206673
|
+
let dir = resolve11(startDir);
|
|
205965
206674
|
while (true) {
|
|
205966
206675
|
const candidate = join40(dir, ".mementos", "mementos.db");
|
|
205967
206676
|
if (existsSync27(candidate))
|
|
@@ -205974,7 +206683,7 @@ function findNearestMementosDb(startDir) {
|
|
|
205974
206683
|
return null;
|
|
205975
206684
|
}
|
|
205976
206685
|
function findGitRoot2(startDir) {
|
|
205977
|
-
let dir =
|
|
206686
|
+
let dir = resolve11(startDir);
|
|
205978
206687
|
while (true) {
|
|
205979
206688
|
if (existsSync27(join40(dir, ".git")))
|
|
205980
206689
|
return dir;
|
|
@@ -206005,7 +206714,7 @@ function getDbPath2() {
|
|
|
206005
206714
|
function ensureDir2(filePath) {
|
|
206006
206715
|
if (isInMemoryDb2(filePath))
|
|
206007
206716
|
return;
|
|
206008
|
-
const dir = dirname15(
|
|
206717
|
+
const dir = dirname15(resolve11(filePath));
|
|
206009
206718
|
if (!existsSync27(dir)) {
|
|
206010
206719
|
mkdirSync14(dir, { recursive: true });
|
|
206011
206720
|
}
|
|
@@ -206308,7 +207017,7 @@ function isValidCategory(value2) {
|
|
|
206308
207017
|
return VALID_CATEGORIES2.includes(value2);
|
|
206309
207018
|
}
|
|
206310
207019
|
function loadConfig5() {
|
|
206311
|
-
const configPath = join212(
|
|
207020
|
+
const configPath = join212(homedir24(), ".mementos", "config.json");
|
|
206312
207021
|
let fileConfig = {};
|
|
206313
207022
|
if (existsSync28(configPath)) {
|
|
206314
207023
|
try {
|
|
@@ -207791,12 +208500,12 @@ ${hookResult.additionalContext}` : hookResult.additionalContext
|
|
|
207791
208500
|
return resultWithId;
|
|
207792
208501
|
}
|
|
207793
208502
|
createTimeout(ms, runner, subassistantId) {
|
|
207794
|
-
return new Promise((
|
|
208503
|
+
return new Promise((resolve12) => {
|
|
207795
208504
|
const timerId = setTimeout(() => {
|
|
207796
208505
|
this.activeTimeouts.delete(subassistantId);
|
|
207797
208506
|
this.activeRunners.delete(subassistantId);
|
|
207798
208507
|
runner.stop();
|
|
207799
|
-
|
|
208508
|
+
resolve12({
|
|
207800
208509
|
success: false,
|
|
207801
208510
|
error: `Subassistant timed out after ${Math.round(ms / 1000)} seconds`,
|
|
207802
208511
|
turns: 0,
|
|
@@ -207815,7 +208524,7 @@ ${hookResult.additionalContext}` : hookResult.additionalContext
|
|
|
207815
208524
|
}
|
|
207816
208525
|
}
|
|
207817
208526
|
sleep(ms) {
|
|
207818
|
-
return new Promise((
|
|
208527
|
+
return new Promise((resolve12) => setTimeout(resolve12, ms));
|
|
207819
208528
|
}
|
|
207820
208529
|
}
|
|
207821
208530
|
var DEFAULT_MAX_DEPTH = 3, DEFAULT_MAX_CONCURRENT = 5, DEFAULT_MAX_TURNS = 10, MAX_ALLOWED_TURNS = 25, DEFAULT_TIMEOUT_MS3 = 120000, DEFAULT_SUBASSISTANT_TOOLS, FORBIDDEN_SUBASSISTANT_TOOLS;
|
|
@@ -207842,6 +208551,193 @@ var init_subagent_manager = __esm(() => {
|
|
|
207842
208551
|
];
|
|
207843
208552
|
});
|
|
207844
208553
|
|
|
208554
|
+
// packages/core/src/agent/stats.ts
|
|
208555
|
+
class StatsTracker {
|
|
208556
|
+
sessionId;
|
|
208557
|
+
startedAt;
|
|
208558
|
+
toolStats = new Map;
|
|
208559
|
+
pendingCalls = new Map;
|
|
208560
|
+
durations = new Map;
|
|
208561
|
+
lastCallEndTime = null;
|
|
208562
|
+
timeBetweenCalls = [];
|
|
208563
|
+
llmCallCount = 0;
|
|
208564
|
+
tokenUsage = {
|
|
208565
|
+
inputTokens: 0,
|
|
208566
|
+
outputTokens: 0,
|
|
208567
|
+
totalTokens: 0,
|
|
208568
|
+
maxContextTokens: 180000
|
|
208569
|
+
};
|
|
208570
|
+
constructor(sessionId) {
|
|
208571
|
+
this.sessionId = sessionId;
|
|
208572
|
+
this.startedAt = new Date().toISOString();
|
|
208573
|
+
}
|
|
208574
|
+
onToolStart(toolCall) {
|
|
208575
|
+
const startTime = Date.now();
|
|
208576
|
+
if (this.lastCallEndTime !== null) {
|
|
208577
|
+
const timeSinceLastCall = startTime - this.lastCallEndTime;
|
|
208578
|
+
this.timeBetweenCalls.push(timeSinceLastCall);
|
|
208579
|
+
}
|
|
208580
|
+
this.pendingCalls.set(toolCall.id, {
|
|
208581
|
+
toolCall,
|
|
208582
|
+
startTime
|
|
208583
|
+
});
|
|
208584
|
+
if (!this.toolStats.has(toolCall.name)) {
|
|
208585
|
+
this.toolStats.set(toolCall.name, {
|
|
208586
|
+
name: toolCall.name,
|
|
208587
|
+
callCount: 0,
|
|
208588
|
+
successCount: 0,
|
|
208589
|
+
failureCount: 0,
|
|
208590
|
+
totalDurationMs: 0,
|
|
208591
|
+
minDurationMs: Infinity,
|
|
208592
|
+
maxDurationMs: 0,
|
|
208593
|
+
avgDurationMs: 0,
|
|
208594
|
+
medianDurationMs: 0,
|
|
208595
|
+
lastDurationMs: 0,
|
|
208596
|
+
lastExecutedAt: "",
|
|
208597
|
+
truncatedCount: 0
|
|
208598
|
+
});
|
|
208599
|
+
this.durations.set(toolCall.name, []);
|
|
208600
|
+
}
|
|
208601
|
+
}
|
|
208602
|
+
onToolEnd(toolCall, result) {
|
|
208603
|
+
const endTime = Date.now();
|
|
208604
|
+
const pending = this.pendingCalls.get(toolCall.id);
|
|
208605
|
+
if (!pending) {
|
|
208606
|
+
return;
|
|
208607
|
+
}
|
|
208608
|
+
const duration3 = endTime - pending.startTime;
|
|
208609
|
+
this.lastCallEndTime = endTime;
|
|
208610
|
+
this.pendingCalls.delete(toolCall.id);
|
|
208611
|
+
const stats = this.toolStats.get(toolCall.name);
|
|
208612
|
+
if (stats) {
|
|
208613
|
+
stats.callCount++;
|
|
208614
|
+
stats.totalDurationMs += duration3;
|
|
208615
|
+
stats.minDurationMs = Math.min(stats.minDurationMs, duration3);
|
|
208616
|
+
stats.maxDurationMs = Math.max(stats.maxDurationMs, duration3);
|
|
208617
|
+
stats.lastDurationMs = duration3;
|
|
208618
|
+
stats.lastExecutedAt = new Date().toISOString();
|
|
208619
|
+
if (result.isError) {
|
|
208620
|
+
stats.failureCount++;
|
|
208621
|
+
} else {
|
|
208622
|
+
stats.successCount++;
|
|
208623
|
+
}
|
|
208624
|
+
if (result.truncated) {
|
|
208625
|
+
stats.truncatedCount++;
|
|
208626
|
+
}
|
|
208627
|
+
stats.avgDurationMs = Math.round(stats.totalDurationMs / stats.callCount);
|
|
208628
|
+
const durationsArray = this.durations.get(toolCall.name);
|
|
208629
|
+
if (durationsArray) {
|
|
208630
|
+
durationsArray.push(duration3);
|
|
208631
|
+
if (durationsArray.length > 100) {
|
|
208632
|
+
durationsArray.shift();
|
|
208633
|
+
}
|
|
208634
|
+
stats.medianDurationMs = this.calculateMedian(durationsArray);
|
|
208635
|
+
}
|
|
208636
|
+
}
|
|
208637
|
+
}
|
|
208638
|
+
onLlmCall() {
|
|
208639
|
+
this.llmCallCount++;
|
|
208640
|
+
}
|
|
208641
|
+
updateTokenUsage(usage) {
|
|
208642
|
+
if (usage.inputTokens !== undefined) {
|
|
208643
|
+
this.tokenUsage.inputTokens = usage.inputTokens;
|
|
208644
|
+
}
|
|
208645
|
+
if (usage.outputTokens !== undefined) {
|
|
208646
|
+
this.tokenUsage.outputTokens = usage.outputTokens;
|
|
208647
|
+
}
|
|
208648
|
+
if (usage.totalTokens !== undefined) {
|
|
208649
|
+
this.tokenUsage.totalTokens = usage.totalTokens;
|
|
208650
|
+
}
|
|
208651
|
+
if (usage.maxContextTokens !== undefined) {
|
|
208652
|
+
this.tokenUsage.maxContextTokens = usage.maxContextTokens;
|
|
208653
|
+
}
|
|
208654
|
+
if (usage.cacheReadTokens !== undefined) {
|
|
208655
|
+
this.tokenUsage.cacheReadTokens = usage.cacheReadTokens;
|
|
208656
|
+
}
|
|
208657
|
+
if (usage.cacheWriteTokens !== undefined) {
|
|
208658
|
+
this.tokenUsage.cacheWriteTokens = usage.cacheWriteTokens;
|
|
208659
|
+
}
|
|
208660
|
+
}
|
|
208661
|
+
getToolStats(toolName) {
|
|
208662
|
+
return this.toolStats.get(toolName) || null;
|
|
208663
|
+
}
|
|
208664
|
+
getAllToolStats() {
|
|
208665
|
+
return Array.from(this.toolStats.values());
|
|
208666
|
+
}
|
|
208667
|
+
getSessionStats() {
|
|
208668
|
+
let totalToolCalls = 0;
|
|
208669
|
+
let totalSuccessful = 0;
|
|
208670
|
+
let totalFailed = 0;
|
|
208671
|
+
let totalExecutionTimeMs = 0;
|
|
208672
|
+
const toolStatsRecord = {};
|
|
208673
|
+
for (const [name, stats] of this.toolStats) {
|
|
208674
|
+
totalToolCalls += stats.callCount;
|
|
208675
|
+
totalSuccessful += stats.successCount;
|
|
208676
|
+
totalFailed += stats.failureCount;
|
|
208677
|
+
totalExecutionTimeMs += stats.totalDurationMs;
|
|
208678
|
+
toolStatsRecord[name] = { ...stats };
|
|
208679
|
+
}
|
|
208680
|
+
return {
|
|
208681
|
+
sessionId: this.sessionId,
|
|
208682
|
+
startedAt: this.startedAt,
|
|
208683
|
+
totalToolCalls,
|
|
208684
|
+
totalSuccessful,
|
|
208685
|
+
totalFailed,
|
|
208686
|
+
totalExecutionTimeMs,
|
|
208687
|
+
avgTimeBetweenCallsMs: this.calculateAverage(this.timeBetweenCalls),
|
|
208688
|
+
totalLlmCalls: this.llmCallCount,
|
|
208689
|
+
tokenUsage: { ...this.tokenUsage },
|
|
208690
|
+
toolStats: toolStatsRecord
|
|
208691
|
+
};
|
|
208692
|
+
}
|
|
208693
|
+
getSummary() {
|
|
208694
|
+
const stats = this.getSessionStats();
|
|
208695
|
+
const successRate = stats.totalToolCalls > 0 ? Math.round(stats.totalSuccessful / stats.totalToolCalls * 100) : 100;
|
|
208696
|
+
const avgDurationMs = stats.totalToolCalls > 0 ? Math.round(stats.totalExecutionTimeMs / stats.totalToolCalls) : 0;
|
|
208697
|
+
const topTools = this.getAllToolStats().sort((a5, b5) => b5.callCount - a5.callCount).slice(0, 5).map((t9) => ({
|
|
208698
|
+
name: t9.name,
|
|
208699
|
+
count: t9.callCount,
|
|
208700
|
+
avgMs: t9.avgDurationMs
|
|
208701
|
+
}));
|
|
208702
|
+
return {
|
|
208703
|
+
totalToolCalls: stats.totalToolCalls,
|
|
208704
|
+
successRate,
|
|
208705
|
+
avgDurationMs,
|
|
208706
|
+
topTools,
|
|
208707
|
+
totalLlmCalls: this.llmCallCount,
|
|
208708
|
+
tokensUsed: stats.tokenUsage.totalTokens
|
|
208709
|
+
};
|
|
208710
|
+
}
|
|
208711
|
+
reset() {
|
|
208712
|
+
this.toolStats.clear();
|
|
208713
|
+
this.pendingCalls.clear();
|
|
208714
|
+
this.durations.clear();
|
|
208715
|
+
this.lastCallEndTime = null;
|
|
208716
|
+
this.timeBetweenCalls = [];
|
|
208717
|
+
this.llmCallCount = 0;
|
|
208718
|
+
this.tokenUsage = {
|
|
208719
|
+
inputTokens: 0,
|
|
208720
|
+
outputTokens: 0,
|
|
208721
|
+
totalTokens: 0,
|
|
208722
|
+
maxContextTokens: 180000
|
|
208723
|
+
};
|
|
208724
|
+
this.startedAt = new Date().toISOString();
|
|
208725
|
+
}
|
|
208726
|
+
calculateMedian(values3) {
|
|
208727
|
+
if (values3.length === 0)
|
|
208728
|
+
return 0;
|
|
208729
|
+
const sorted = [...values3].sort((a5, b5) => a5 - b5);
|
|
208730
|
+
const mid = Math.floor(sorted.length / 2);
|
|
208731
|
+
return sorted.length % 2 === 0 ? Math.round((sorted[mid - 1] + sorted[mid]) / 2) : sorted[mid];
|
|
208732
|
+
}
|
|
208733
|
+
calculateAverage(values3) {
|
|
208734
|
+
if (values3.length === 0)
|
|
208735
|
+
return 0;
|
|
208736
|
+
const sum = values3.reduce((a5, b5) => a5 + b5, 0);
|
|
208737
|
+
return Math.round(sum / values3.length);
|
|
208738
|
+
}
|
|
208739
|
+
}
|
|
208740
|
+
|
|
207845
208741
|
// packages/core/src/capabilities/types.ts
|
|
207846
208742
|
var ORCHESTRATION_DEFAULTS, DEFAULT_CAPABILITY_SET, RESTRICTED_CAPABILITY_SET, COORDINATOR_CAPABILITY_SET;
|
|
207847
208743
|
var init_types12 = __esm(() => {
|
|
@@ -208638,7 +209534,7 @@ __export(exports_dist2, {
|
|
|
208638
209534
|
});
|
|
208639
209535
|
import { existsSync as existsSync29, cpSync, mkdirSync as mkdirSync15, writeFileSync as writeFileSync10, rmSync as rmSync3, readdirSync as readdirSync12, statSync as statSync7, readFileSync as readFileSync14 } from "fs";
|
|
208640
209536
|
import { join as join41, dirname as dirname16 } from "path";
|
|
208641
|
-
import { homedir as
|
|
209537
|
+
import { homedir as homedir25 } from "os";
|
|
208642
209538
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
208643
209539
|
import { existsSync as existsSync210, readFileSync as readFileSync22, readdirSync as readdirSync22 } from "fs";
|
|
208644
209540
|
import { join as join213 } from "path";
|
|
@@ -208866,7 +209762,7 @@ function getAgentSkillsDir(agent, scope = "global", projectDir) {
|
|
|
208866
209762
|
if (scope === "project") {
|
|
208867
209763
|
return join41(projectDir || process.cwd(), agentDir, "skills");
|
|
208868
209764
|
}
|
|
208869
|
-
return join41(
|
|
209765
|
+
return join41(homedir25(), agentDir, "skills");
|
|
208870
209766
|
}
|
|
208871
209767
|
function getAgentSkillPath(name, agent, scope = "global", projectDir) {
|
|
208872
209768
|
const skillName = normalizeSkillName(name);
|
|
@@ -211617,6 +212513,7 @@ var init_loop = __esm(async () => {
|
|
|
211617
212513
|
init_image();
|
|
211618
212514
|
init_ask_user();
|
|
211619
212515
|
init_wait();
|
|
212516
|
+
init_notify();
|
|
211620
212517
|
init_loader3();
|
|
211621
212518
|
init_client3();
|
|
211622
212519
|
init_errors();
|
|
@@ -211654,6 +212551,7 @@ var init_loop = __esm(async () => {
|
|
|
211654
212551
|
init_workflows2(),
|
|
211655
212552
|
init_skills2(),
|
|
211656
212553
|
init_tmux(),
|
|
212554
|
+
init_diff(),
|
|
211657
212555
|
init_subagent(),
|
|
211658
212556
|
init_executor3(),
|
|
211659
212557
|
init_hooks(),
|
|
@@ -211777,6 +212675,7 @@ var init_loop = __esm(async () => {
|
|
|
211777
212675
|
registryService = null;
|
|
211778
212676
|
registeredAssistantId = null;
|
|
211779
212677
|
swarmCoordinator = null;
|
|
212678
|
+
statsTracker;
|
|
211780
212679
|
paused = false;
|
|
211781
212680
|
pauseResolve = null;
|
|
211782
212681
|
maxTurnsPerRun = 50;
|
|
@@ -211806,6 +212705,7 @@ var init_loop = __esm(async () => {
|
|
|
211806
212705
|
this.commandLoader = new CommandLoader(this.cwd);
|
|
211807
212706
|
this.commandExecutor = new CommandExecutor(this.commandLoader);
|
|
211808
212707
|
this.builtinCommands = new BuiltinCommands;
|
|
212708
|
+
this.statsTracker = new StatsTracker(this.sessionId);
|
|
211809
212709
|
this.allowedTools = this.normalizeAllowedTools(options2.allowedTools);
|
|
211810
212710
|
this.extraSystemPrompt = options2.extraSystemPrompt || null;
|
|
211811
212711
|
this.llmClient = options2.llmClient ?? null;
|
|
@@ -211985,7 +212885,9 @@ var init_loop = __esm(async () => {
|
|
|
211985
212885
|
}));
|
|
211986
212886
|
this.toolRegistry.register(WaitTool.tool, WaitTool.executor);
|
|
211987
212887
|
this.toolRegistry.register(SleepTool.tool, SleepTool.executor);
|
|
212888
|
+
this.toolRegistry.register(NotifyTool.tool, NotifyTool.executor);
|
|
211988
212889
|
this.toolRegistry.register(TmuxTools.tool, TmuxTools.executor);
|
|
212890
|
+
this.toolRegistry.register(DiffTool.tool, DiffTool.executor);
|
|
211989
212891
|
if (this.config?.inbox?.enabled) {
|
|
211990
212892
|
const { id: assistantId, name: assistantName } = this.getAssistantIdentity();
|
|
211991
212893
|
this.inboxManager = createInboxManager(assistantId, assistantName, this.config.inbox, this.storageDir);
|
|
@@ -212121,6 +213023,7 @@ var init_loop = __esm(async () => {
|
|
|
212121
213023
|
getAssistantManager: () => this.assistantManager,
|
|
212122
213024
|
getIdentityManager: () => this.identityManager,
|
|
212123
213025
|
getWalletManager: () => this.walletManager,
|
|
213026
|
+
getStatsTracker: () => this.statsTracker,
|
|
212124
213027
|
sessionId: this.sessionId,
|
|
212125
213028
|
model: this.config?.llm?.model
|
|
212126
213029
|
});
|
|
@@ -212562,8 +213465,8 @@ You are running in **autonomous mode**. You manage your own wakeup schedule.
|
|
|
212562
213465
|
this.emit({ type: "text", content: `
|
|
212563
213466
|
[Agent paused - budget exceeded. Use /budgets resume to continue.]
|
|
212564
213467
|
` });
|
|
212565
|
-
await new Promise((
|
|
212566
|
-
this.pauseResolve =
|
|
213468
|
+
await new Promise((resolve12) => {
|
|
213469
|
+
this.pauseResolve = resolve12;
|
|
212567
213470
|
});
|
|
212568
213471
|
this.pauseResolve = null;
|
|
212569
213472
|
if (this.shouldStop)
|
|
@@ -213068,12 +213971,14 @@ You are running in **autonomous mode**. You manage your own wakeup schedule.
|
|
|
213068
213971
|
this.recordHeartbeatActivity("tool");
|
|
213069
213972
|
this.lastToolName = toolCall.name;
|
|
213070
213973
|
this.pendingToolCalls.set(toolCall.id, toolCall.name);
|
|
213974
|
+
this.statsTracker.onToolStart(toolCall);
|
|
213071
213975
|
this.onToolStart?.(toolCall);
|
|
213072
213976
|
const toolStartTime = Date.now();
|
|
213073
213977
|
const result = await this.toolRegistry.execute(toolCall, signal);
|
|
213074
213978
|
const toolDuration = Date.now() - toolStartTime;
|
|
213075
213979
|
this.recordToolCallBudget(toolDuration);
|
|
213076
213980
|
const stopAfterTool = this.shouldStop;
|
|
213981
|
+
this.statsTracker.onToolEnd(toolCall, result);
|
|
213077
213982
|
this.onToolEnd?.(toolCall, result);
|
|
213078
213983
|
if (!stopAfterTool && !result.isError && toolCall.name === "bash") {
|
|
213079
213984
|
const command = toolCall.input?.command;
|
|
@@ -213698,6 +214603,8 @@ You are running in **autonomous mode**. You manage your own wakeup schedule.
|
|
|
213698
214603
|
}
|
|
213699
214604
|
updateTokenUsage(usage) {
|
|
213700
214605
|
this.builtinCommands.updateTokenUsage(usage);
|
|
214606
|
+
this.statsTracker.updateTokenUsage(usage);
|
|
214607
|
+
this.statsTracker.onLlmCall();
|
|
213701
214608
|
this.onTokenUsage?.(this.builtinCommands.getTokenUsage());
|
|
213702
214609
|
if (this.budgetTracker && (usage.inputTokens || usage.outputTokens)) {
|
|
213703
214610
|
this.budgetTracker.recordLlmCall(usage.inputTokens || 0, usage.outputTokens || 0, 0);
|
|
@@ -214546,196 +215453,9 @@ Be concise but thorough. Focus only on this task.`,
|
|
|
214546
215453
|
};
|
|
214547
215454
|
});
|
|
214548
215455
|
|
|
214549
|
-
// packages/core/src/agent/stats.ts
|
|
214550
|
-
class StatsTracker {
|
|
214551
|
-
sessionId;
|
|
214552
|
-
startedAt;
|
|
214553
|
-
toolStats = new Map;
|
|
214554
|
-
pendingCalls = new Map;
|
|
214555
|
-
durations = new Map;
|
|
214556
|
-
lastCallEndTime = null;
|
|
214557
|
-
timeBetweenCalls = [];
|
|
214558
|
-
llmCallCount = 0;
|
|
214559
|
-
tokenUsage = {
|
|
214560
|
-
inputTokens: 0,
|
|
214561
|
-
outputTokens: 0,
|
|
214562
|
-
totalTokens: 0,
|
|
214563
|
-
maxContextTokens: 180000
|
|
214564
|
-
};
|
|
214565
|
-
constructor(sessionId) {
|
|
214566
|
-
this.sessionId = sessionId;
|
|
214567
|
-
this.startedAt = new Date().toISOString();
|
|
214568
|
-
}
|
|
214569
|
-
onToolStart(toolCall) {
|
|
214570
|
-
const startTime = Date.now();
|
|
214571
|
-
if (this.lastCallEndTime !== null) {
|
|
214572
|
-
const timeSinceLastCall = startTime - this.lastCallEndTime;
|
|
214573
|
-
this.timeBetweenCalls.push(timeSinceLastCall);
|
|
214574
|
-
}
|
|
214575
|
-
this.pendingCalls.set(toolCall.id, {
|
|
214576
|
-
toolCall,
|
|
214577
|
-
startTime
|
|
214578
|
-
});
|
|
214579
|
-
if (!this.toolStats.has(toolCall.name)) {
|
|
214580
|
-
this.toolStats.set(toolCall.name, {
|
|
214581
|
-
name: toolCall.name,
|
|
214582
|
-
callCount: 0,
|
|
214583
|
-
successCount: 0,
|
|
214584
|
-
failureCount: 0,
|
|
214585
|
-
totalDurationMs: 0,
|
|
214586
|
-
minDurationMs: Infinity,
|
|
214587
|
-
maxDurationMs: 0,
|
|
214588
|
-
avgDurationMs: 0,
|
|
214589
|
-
medianDurationMs: 0,
|
|
214590
|
-
lastDurationMs: 0,
|
|
214591
|
-
lastExecutedAt: "",
|
|
214592
|
-
truncatedCount: 0
|
|
214593
|
-
});
|
|
214594
|
-
this.durations.set(toolCall.name, []);
|
|
214595
|
-
}
|
|
214596
|
-
}
|
|
214597
|
-
onToolEnd(toolCall, result) {
|
|
214598
|
-
const endTime = Date.now();
|
|
214599
|
-
const pending = this.pendingCalls.get(toolCall.id);
|
|
214600
|
-
if (!pending) {
|
|
214601
|
-
return;
|
|
214602
|
-
}
|
|
214603
|
-
const duration3 = endTime - pending.startTime;
|
|
214604
|
-
this.lastCallEndTime = endTime;
|
|
214605
|
-
this.pendingCalls.delete(toolCall.id);
|
|
214606
|
-
const stats = this.toolStats.get(toolCall.name);
|
|
214607
|
-
if (stats) {
|
|
214608
|
-
stats.callCount++;
|
|
214609
|
-
stats.totalDurationMs += duration3;
|
|
214610
|
-
stats.minDurationMs = Math.min(stats.minDurationMs, duration3);
|
|
214611
|
-
stats.maxDurationMs = Math.max(stats.maxDurationMs, duration3);
|
|
214612
|
-
stats.lastDurationMs = duration3;
|
|
214613
|
-
stats.lastExecutedAt = new Date().toISOString();
|
|
214614
|
-
if (result.isError) {
|
|
214615
|
-
stats.failureCount++;
|
|
214616
|
-
} else {
|
|
214617
|
-
stats.successCount++;
|
|
214618
|
-
}
|
|
214619
|
-
if (result.truncated) {
|
|
214620
|
-
stats.truncatedCount++;
|
|
214621
|
-
}
|
|
214622
|
-
stats.avgDurationMs = Math.round(stats.totalDurationMs / stats.callCount);
|
|
214623
|
-
const durationsArray = this.durations.get(toolCall.name);
|
|
214624
|
-
if (durationsArray) {
|
|
214625
|
-
durationsArray.push(duration3);
|
|
214626
|
-
if (durationsArray.length > 100) {
|
|
214627
|
-
durationsArray.shift();
|
|
214628
|
-
}
|
|
214629
|
-
stats.medianDurationMs = this.calculateMedian(durationsArray);
|
|
214630
|
-
}
|
|
214631
|
-
}
|
|
214632
|
-
}
|
|
214633
|
-
onLlmCall() {
|
|
214634
|
-
this.llmCallCount++;
|
|
214635
|
-
}
|
|
214636
|
-
updateTokenUsage(usage) {
|
|
214637
|
-
if (usage.inputTokens !== undefined) {
|
|
214638
|
-
this.tokenUsage.inputTokens = usage.inputTokens;
|
|
214639
|
-
}
|
|
214640
|
-
if (usage.outputTokens !== undefined) {
|
|
214641
|
-
this.tokenUsage.outputTokens = usage.outputTokens;
|
|
214642
|
-
}
|
|
214643
|
-
if (usage.totalTokens !== undefined) {
|
|
214644
|
-
this.tokenUsage.totalTokens = usage.totalTokens;
|
|
214645
|
-
}
|
|
214646
|
-
if (usage.maxContextTokens !== undefined) {
|
|
214647
|
-
this.tokenUsage.maxContextTokens = usage.maxContextTokens;
|
|
214648
|
-
}
|
|
214649
|
-
if (usage.cacheReadTokens !== undefined) {
|
|
214650
|
-
this.tokenUsage.cacheReadTokens = usage.cacheReadTokens;
|
|
214651
|
-
}
|
|
214652
|
-
if (usage.cacheWriteTokens !== undefined) {
|
|
214653
|
-
this.tokenUsage.cacheWriteTokens = usage.cacheWriteTokens;
|
|
214654
|
-
}
|
|
214655
|
-
}
|
|
214656
|
-
getToolStats(toolName) {
|
|
214657
|
-
return this.toolStats.get(toolName) || null;
|
|
214658
|
-
}
|
|
214659
|
-
getAllToolStats() {
|
|
214660
|
-
return Array.from(this.toolStats.values());
|
|
214661
|
-
}
|
|
214662
|
-
getSessionStats() {
|
|
214663
|
-
let totalToolCalls = 0;
|
|
214664
|
-
let totalSuccessful = 0;
|
|
214665
|
-
let totalFailed = 0;
|
|
214666
|
-
let totalExecutionTimeMs = 0;
|
|
214667
|
-
const toolStatsRecord = {};
|
|
214668
|
-
for (const [name, stats] of this.toolStats) {
|
|
214669
|
-
totalToolCalls += stats.callCount;
|
|
214670
|
-
totalSuccessful += stats.successCount;
|
|
214671
|
-
totalFailed += stats.failureCount;
|
|
214672
|
-
totalExecutionTimeMs += stats.totalDurationMs;
|
|
214673
|
-
toolStatsRecord[name] = { ...stats };
|
|
214674
|
-
}
|
|
214675
|
-
return {
|
|
214676
|
-
sessionId: this.sessionId,
|
|
214677
|
-
startedAt: this.startedAt,
|
|
214678
|
-
totalToolCalls,
|
|
214679
|
-
totalSuccessful,
|
|
214680
|
-
totalFailed,
|
|
214681
|
-
totalExecutionTimeMs,
|
|
214682
|
-
avgTimeBetweenCallsMs: this.calculateAverage(this.timeBetweenCalls),
|
|
214683
|
-
totalLlmCalls: this.llmCallCount,
|
|
214684
|
-
tokenUsage: { ...this.tokenUsage },
|
|
214685
|
-
toolStats: toolStatsRecord
|
|
214686
|
-
};
|
|
214687
|
-
}
|
|
214688
|
-
getSummary() {
|
|
214689
|
-
const stats = this.getSessionStats();
|
|
214690
|
-
const successRate = stats.totalToolCalls > 0 ? Math.round(stats.totalSuccessful / stats.totalToolCalls * 100) : 100;
|
|
214691
|
-
const avgDurationMs = stats.totalToolCalls > 0 ? Math.round(stats.totalExecutionTimeMs / stats.totalToolCalls) : 0;
|
|
214692
|
-
const topTools = this.getAllToolStats().sort((a5, b5) => b5.callCount - a5.callCount).slice(0, 5).map((t9) => ({
|
|
214693
|
-
name: t9.name,
|
|
214694
|
-
count: t9.callCount,
|
|
214695
|
-
avgMs: t9.avgDurationMs
|
|
214696
|
-
}));
|
|
214697
|
-
return {
|
|
214698
|
-
totalToolCalls: stats.totalToolCalls,
|
|
214699
|
-
successRate,
|
|
214700
|
-
avgDurationMs,
|
|
214701
|
-
topTools,
|
|
214702
|
-
totalLlmCalls: this.llmCallCount,
|
|
214703
|
-
tokensUsed: stats.tokenUsage.totalTokens
|
|
214704
|
-
};
|
|
214705
|
-
}
|
|
214706
|
-
reset() {
|
|
214707
|
-
this.toolStats.clear();
|
|
214708
|
-
this.pendingCalls.clear();
|
|
214709
|
-
this.durations.clear();
|
|
214710
|
-
this.lastCallEndTime = null;
|
|
214711
|
-
this.timeBetweenCalls = [];
|
|
214712
|
-
this.llmCallCount = 0;
|
|
214713
|
-
this.tokenUsage = {
|
|
214714
|
-
inputTokens: 0,
|
|
214715
|
-
outputTokens: 0,
|
|
214716
|
-
totalTokens: 0,
|
|
214717
|
-
maxContextTokens: 180000
|
|
214718
|
-
};
|
|
214719
|
-
this.startedAt = new Date().toISOString();
|
|
214720
|
-
}
|
|
214721
|
-
calculateMedian(values3) {
|
|
214722
|
-
if (values3.length === 0)
|
|
214723
|
-
return 0;
|
|
214724
|
-
const sorted = [...values3].sort((a5, b5) => a5 - b5);
|
|
214725
|
-
const mid = Math.floor(sorted.length / 2);
|
|
214726
|
-
return sorted.length % 2 === 0 ? Math.round((sorted[mid - 1] + sorted[mid]) / 2) : sorted[mid];
|
|
214727
|
-
}
|
|
214728
|
-
calculateAverage(values3) {
|
|
214729
|
-
if (values3.length === 0)
|
|
214730
|
-
return 0;
|
|
214731
|
-
const sum = values3.reduce((a5, b5) => a5 + b5, 0);
|
|
214732
|
-
return Math.round(sum / values3.length);
|
|
214733
|
-
}
|
|
214734
|
-
}
|
|
214735
|
-
|
|
214736
215456
|
// packages/core/src/tools/connector-index.ts
|
|
214737
215457
|
import { join as join45, dirname as dirname18 } from "path";
|
|
214738
|
-
import { homedir as
|
|
215458
|
+
import { homedir as homedir26 } from "os";
|
|
214739
215459
|
import { existsSync as existsSync33, mkdirSync as mkdirSync17, writeFileSync as writeFileSync12, readFileSync as readFileSync16 } from "fs";
|
|
214740
215460
|
var TAG_KEYWORDS, INDEX_VERSION = 1, INDEX_TTL_MS, ConnectorIndex;
|
|
214741
215461
|
var init_connector_index = __esm(() => {
|
|
@@ -214770,7 +215490,7 @@ var init_connector_index = __esm(() => {
|
|
|
214770
215490
|
}
|
|
214771
215491
|
getHomeDir() {
|
|
214772
215492
|
const envHome = process.env.HOME || process.env.USERPROFILE;
|
|
214773
|
-
return envHome && envHome.trim().length > 0 ? envHome :
|
|
215493
|
+
return envHome && envHome.trim().length > 0 ? envHome : homedir26();
|
|
214774
215494
|
}
|
|
214775
215495
|
getCachePath() {
|
|
214776
215496
|
return join45(this.getHomeDir(), ".assistants", "cache", "connector-index.json");
|
|
@@ -215160,7 +215880,7 @@ function inferToolMetadata(tool2) {
|
|
|
215160
215880
|
category = "skills";
|
|
215161
215881
|
} else if (name.startsWith("web_") || name === "curl") {
|
|
215162
215882
|
category = "web";
|
|
215163
|
-
} else if (["read", "write", "glob", "grep", "read_pdf"].includes(name)) {
|
|
215883
|
+
} else if (["read", "write", "glob", "grep", "read_pdf", "diff"].includes(name)) {
|
|
215164
215884
|
category = "filesystem";
|
|
215165
215885
|
} else if (name === "bash") {
|
|
215166
215886
|
category = "system";
|
|
@@ -215176,7 +215896,7 @@ function inferToolMetadata(tool2) {
|
|
|
215176
215896
|
category = "connectors";
|
|
215177
215897
|
source = "connector";
|
|
215178
215898
|
}
|
|
215179
|
-
if (!name.includes("_") && !["bash", "read", "write", "glob", "grep", "curl", "wait", "sleep", "feedback"].includes(name)) {
|
|
215899
|
+
if (!name.includes("_") && !["bash", "read", "write", "glob", "grep", "curl", "wait", "sleep", "feedback", "diff"].includes(name)) {
|
|
215180
215900
|
source = "connector";
|
|
215181
215901
|
category = "connectors";
|
|
215182
215902
|
}
|
|
@@ -216003,89 +216723,6 @@ var init_security2 = __esm(async () => {
|
|
|
216003
216723
|
init_network_validator();
|
|
216004
216724
|
});
|
|
216005
216725
|
|
|
216006
|
-
// packages/core/src/features.ts
|
|
216007
|
-
function isAWSConfigured() {
|
|
216008
|
-
return !!(process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION || process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY);
|
|
216009
|
-
}
|
|
216010
|
-
function isElevenLabsConfigured() {
|
|
216011
|
-
return !!process.env.ELEVENLABS_API_KEY;
|
|
216012
|
-
}
|
|
216013
|
-
function isOpenAIConfigured() {
|
|
216014
|
-
return !!process.env.OPENAI_API_KEY;
|
|
216015
|
-
}
|
|
216016
|
-
function isAnyLLMConfigured() {
|
|
216017
|
-
return LLM_PROVIDERS.some((provider3) => !!process.env[provider3.apiKeyEnv]);
|
|
216018
|
-
}
|
|
216019
|
-
function isExaConfigured() {
|
|
216020
|
-
return !!process.env.EXA_API_KEY;
|
|
216021
|
-
}
|
|
216022
|
-
function isSystemVoiceAvailable() {
|
|
216023
|
-
return process.platform === "darwin";
|
|
216024
|
-
}
|
|
216025
|
-
function getFeatureAvailability() {
|
|
216026
|
-
return {
|
|
216027
|
-
coreChat: isAnyLLMConfigured(),
|
|
216028
|
-
awsFeatures: isAWSConfigured(),
|
|
216029
|
-
elevenLabsTTS: isElevenLabsConfigured(),
|
|
216030
|
-
whisperSTT: isOpenAIConfigured(),
|
|
216031
|
-
exaSearch: isExaConfigured(),
|
|
216032
|
-
systemVoice: isSystemVoiceAvailable()
|
|
216033
|
-
};
|
|
216034
|
-
}
|
|
216035
|
-
function getFeatureStatusMessage() {
|
|
216036
|
-
const features = getFeatureAvailability();
|
|
216037
|
-
const lines = [];
|
|
216038
|
-
if (!features.coreChat) {
|
|
216039
|
-
lines.push("\u26A0\uFE0F ANTHROPIC_API_KEY not set - core chat disabled");
|
|
216040
|
-
} else {
|
|
216041
|
-
lines.push("\u2713 Core chat enabled");
|
|
216042
|
-
}
|
|
216043
|
-
if (features.awsFeatures) {
|
|
216044
|
-
lines.push("\u2713 AWS features available (inbox, wallet, secrets)");
|
|
216045
|
-
} else {
|
|
216046
|
-
lines.push("\u25CB AWS features disabled (set AWS_REGION to enable)");
|
|
216047
|
-
}
|
|
216048
|
-
if (features.elevenLabsTTS) {
|
|
216049
|
-
lines.push("\u2713 ElevenLabs TTS available");
|
|
216050
|
-
}
|
|
216051
|
-
if (features.whisperSTT) {
|
|
216052
|
-
lines.push("\u2713 Whisper STT available");
|
|
216053
|
-
}
|
|
216054
|
-
if (features.systemVoice) {
|
|
216055
|
-
lines.push("\u2713 System voice available (macOS)");
|
|
216056
|
-
}
|
|
216057
|
-
if (features.exaSearch) {
|
|
216058
|
-
lines.push("\u2713 Exa enhanced search available");
|
|
216059
|
-
}
|
|
216060
|
-
return lines.join(`
|
|
216061
|
-
`);
|
|
216062
|
-
}
|
|
216063
|
-
function validateFeatureEnvVars(config2) {
|
|
216064
|
-
const warnings = [];
|
|
216065
|
-
if (config2.inbox?.enabled && !isAWSConfigured()) {
|
|
216066
|
-
warnings.push("inbox.enabled is true but AWS credentials are not configured");
|
|
216067
|
-
}
|
|
216068
|
-
if (config2.wallet?.enabled && !isAWSConfigured()) {
|
|
216069
|
-
warnings.push("wallet.enabled is true but AWS credentials are not configured");
|
|
216070
|
-
}
|
|
216071
|
-
const secretsProvider = config2.secrets?.storage?.provider || "local";
|
|
216072
|
-
if (config2.secrets?.enabled && secretsProvider === "aws" && !isAWSConfigured()) {
|
|
216073
|
-
warnings.push("secrets.enabled is true but AWS credentials are not configured");
|
|
216074
|
-
}
|
|
216075
|
-
if (config2.voice?.enabled) {
|
|
216076
|
-
if (config2.voice.tts?.provider === "elevenlabs" && !isElevenLabsConfigured()) {
|
|
216077
|
-
warnings.push("voice.tts.provider is elevenlabs but ELEVENLABS_API_KEY is not set");
|
|
216078
|
-
}
|
|
216079
|
-
if (config2.voice.stt?.provider === "whisper" && !isOpenAIConfigured()) {
|
|
216080
|
-
warnings.push("voice.stt.provider is whisper but OPENAI_API_KEY is not set");
|
|
216081
|
-
}
|
|
216082
|
-
}
|
|
216083
|
-
return warnings;
|
|
216084
|
-
}
|
|
216085
|
-
var init_features = __esm(() => {
|
|
216086
|
-
init_src2();
|
|
216087
|
-
});
|
|
216088
|
-
|
|
216089
216726
|
// packages/core/src/index.ts
|
|
216090
216727
|
var exports_src3 = {};
|
|
216091
216728
|
__export(exports_src3, {
|
|
@@ -216654,6 +217291,7 @@ __export(exports_src3, {
|
|
|
216654
217291
|
EmailParser: () => EmailParser,
|
|
216655
217292
|
ElevenLabsTTS: () => ElevenLabsTTS,
|
|
216656
217293
|
ElevenLabsSTT: () => ElevenLabsSTT,
|
|
217294
|
+
DiffTool: () => DiffTool,
|
|
216657
217295
|
DEFAULT_WATCHDOG_INTERVAL_MS: () => DEFAULT_WATCHDOG_INTERVAL_MS,
|
|
216658
217296
|
DEFAULT_TOOL_RULES: () => DEFAULT_TOOL_RULES,
|
|
216659
217297
|
DEFAULT_SYSTEM_POLICY: () => DEFAULT_SYSTEM_POLICY,
|
|
@@ -216773,6 +217411,7 @@ var init_src3 = __esm(async () => {
|
|
|
216773
217411
|
init_workflows2(),
|
|
216774
217412
|
init_scheduler(),
|
|
216775
217413
|
init_tmux(),
|
|
217414
|
+
init_diff(),
|
|
216776
217415
|
init_projects(),
|
|
216777
217416
|
init_heartbeat(),
|
|
216778
217417
|
init_logs(),
|
|
@@ -217186,14 +217825,14 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
217186
217825
|
prevActScopeDepth !== actScopeDepth - 1 && console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. ");
|
|
217187
217826
|
actScopeDepth = prevActScopeDepth;
|
|
217188
217827
|
}
|
|
217189
|
-
function recursivelyFlushAsyncActWork(returnValue,
|
|
217828
|
+
function recursivelyFlushAsyncActWork(returnValue, resolve12, reject) {
|
|
217190
217829
|
var queue = ReactSharedInternals.actQueue;
|
|
217191
217830
|
if (queue !== null)
|
|
217192
217831
|
if (queue.length !== 0)
|
|
217193
217832
|
try {
|
|
217194
217833
|
flushActQueue(queue);
|
|
217195
217834
|
enqueueTask(function() {
|
|
217196
|
-
return recursivelyFlushAsyncActWork(returnValue,
|
|
217835
|
+
return recursivelyFlushAsyncActWork(returnValue, resolve12, reject);
|
|
217197
217836
|
});
|
|
217198
217837
|
return;
|
|
217199
217838
|
} catch (error4) {
|
|
@@ -217201,7 +217840,7 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
217201
217840
|
}
|
|
217202
217841
|
else
|
|
217203
217842
|
ReactSharedInternals.actQueue = null;
|
|
217204
|
-
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) :
|
|
217843
|
+
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve12(returnValue);
|
|
217205
217844
|
}
|
|
217206
217845
|
function flushActQueue(queue) {
|
|
217207
217846
|
if (!isFlushing) {
|
|
@@ -217377,14 +218016,14 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
217377
218016
|
didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"));
|
|
217378
218017
|
});
|
|
217379
218018
|
return {
|
|
217380
|
-
then: function(
|
|
218019
|
+
then: function(resolve12, reject) {
|
|
217381
218020
|
didAwaitActCall = true;
|
|
217382
218021
|
thenable.then(function(returnValue) {
|
|
217383
218022
|
popActScope(prevActQueue, prevActScopeDepth);
|
|
217384
218023
|
if (prevActScopeDepth === 0) {
|
|
217385
218024
|
try {
|
|
217386
218025
|
flushActQueue(queue), enqueueTask(function() {
|
|
217387
|
-
return recursivelyFlushAsyncActWork(returnValue,
|
|
218026
|
+
return recursivelyFlushAsyncActWork(returnValue, resolve12, reject);
|
|
217388
218027
|
});
|
|
217389
218028
|
} catch (error$0) {
|
|
217390
218029
|
ReactSharedInternals.thrownErrors.push(error$0);
|
|
@@ -217395,7 +218034,7 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
217395
218034
|
reject(_thrownError);
|
|
217396
218035
|
}
|
|
217397
218036
|
} else
|
|
217398
|
-
|
|
218037
|
+
resolve12(returnValue);
|
|
217399
218038
|
}, function(error4) {
|
|
217400
218039
|
popActScope(prevActQueue, prevActScopeDepth);
|
|
217401
218040
|
0 < ReactSharedInternals.thrownErrors.length ? (error4 = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(error4)) : reject(error4);
|
|
@@ -217411,11 +218050,11 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
217411
218050
|
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
217412
218051
|
throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
217413
218052
|
return {
|
|
217414
|
-
then: function(
|
|
218053
|
+
then: function(resolve12, reject) {
|
|
217415
218054
|
didAwaitActCall = true;
|
|
217416
218055
|
prevActScopeDepth === 0 ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
|
|
217417
|
-
return recursivelyFlushAsyncActWork(returnValue$jscomp$0,
|
|
217418
|
-
})) :
|
|
218056
|
+
return recursivelyFlushAsyncActWork(returnValue$jscomp$0, resolve12, reject);
|
|
218057
|
+
})) : resolve12(returnValue$jscomp$0);
|
|
217419
218058
|
}
|
|
217420
218059
|
};
|
|
217421
218060
|
};
|
|
@@ -220174,7 +220813,7 @@ function wrapAnsi(string4, columns, options2) {
|
|
|
220174
220813
|
return String(string4).normalize().replaceAll(`\r
|
|
220175
220814
|
`, `
|
|
220176
220815
|
`).split(`
|
|
220177
|
-
`).map((line) =>
|
|
220816
|
+
`).map((line) => exec4(line, columns, options2)).join(`
|
|
220178
220817
|
`);
|
|
220179
220818
|
}
|
|
220180
220819
|
var ESCAPES, END_CODE = 39, ANSI_ESCAPE_BELL = "\x07", ANSI_CSI = "[", ANSI_OSC = "]", ANSI_SGR_TERMINATOR = "m", ANSI_ESCAPE_LINK, wrapAnsiCode = (code3) => `${ESCAPES.values().next().value}${ANSI_CSI}${code3}${ANSI_SGR_TERMINATOR}`, wrapAnsiHyperlink = (url) => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`, wordLengths = (string4) => string4.split(" ").map((character) => stringWidth(character)), wrapWord = (rows, word, columns) => {
|
|
@@ -220228,7 +220867,7 @@ var ESCAPES, END_CODE = 39, ANSI_ESCAPE_BELL = "\x07", ANSI_CSI = "[", ANSI_OSC
|
|
|
220228
220867
|
return string4;
|
|
220229
220868
|
}
|
|
220230
220869
|
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
220231
|
-
},
|
|
220870
|
+
}, exec4 = (string4, columns, options2 = {}) => {
|
|
220232
220871
|
if (options2.trim !== false && string4.trim() === "") {
|
|
220233
220872
|
return "";
|
|
220234
220873
|
}
|
|
@@ -220354,7 +220993,7 @@ function terminalSize() {
|
|
|
220354
220993
|
}
|
|
220355
220994
|
return devTty() ?? tput() ?? resize() ?? fallback;
|
|
220356
220995
|
}
|
|
220357
|
-
var defaultColumns = 80, defaultRows = 24,
|
|
220996
|
+
var defaultColumns = 80, defaultRows = 24, exec5 = (command, arguments_, { shell, env: env3 } = {}) => execFileSync(command, arguments_, {
|
|
220358
220997
|
encoding: "utf8",
|
|
220359
220998
|
stdio: ["ignore", "pipe", "ignore"],
|
|
220360
220999
|
timeout: 500,
|
|
@@ -220403,8 +221042,8 @@ var defaultColumns = 80, defaultRows = 24, exec4 = (command, arguments_, { shell
|
|
|
220403
221042
|
} catch {}
|
|
220404
221043
|
}, tput = () => {
|
|
220405
221044
|
try {
|
|
220406
|
-
const columns =
|
|
220407
|
-
const rows =
|
|
221045
|
+
const columns = exec5("tput", ["cols"], { env: { TERM: "dumb", ...process3.env } });
|
|
221046
|
+
const rows = exec5("tput", ["lines"], { env: { TERM: "dumb", ...process3.env } });
|
|
220408
221047
|
if (columns && rows) {
|
|
220409
221048
|
return createIfNotDefault(columns, rows);
|
|
220410
221049
|
}
|
|
@@ -220414,7 +221053,7 @@ var defaultColumns = 80, defaultRows = 24, exec4 = (command, arguments_, { shell
|
|
|
220414
221053
|
if (!isForegroundProcess()) {
|
|
220415
221054
|
return;
|
|
220416
221055
|
}
|
|
220417
|
-
const size =
|
|
221056
|
+
const size = exec5("resize", ["-u"]).match(/\d+/g);
|
|
220418
221057
|
if (size.length === 2) {
|
|
220419
221058
|
return createIfNotDefault(size[0], size[1]);
|
|
220420
221059
|
}
|
|
@@ -222837,8 +223476,8 @@ It can also happen if the client has a browser extension installed which messes
|
|
|
222837
223476
|
currentEntangledActionThenable = {
|
|
222838
223477
|
status: "pending",
|
|
222839
223478
|
value: undefined,
|
|
222840
|
-
then: function(
|
|
222841
|
-
entangledListeners.push(
|
|
223479
|
+
then: function(resolve12) {
|
|
223480
|
+
entangledListeners.push(resolve12);
|
|
222842
223481
|
}
|
|
222843
223482
|
};
|
|
222844
223483
|
}
|
|
@@ -222862,8 +223501,8 @@ It can also happen if the client has a browser extension installed which messes
|
|
|
222862
223501
|
status: "pending",
|
|
222863
223502
|
value: null,
|
|
222864
223503
|
reason: null,
|
|
222865
|
-
then: function(
|
|
222866
|
-
listeners.push(
|
|
223504
|
+
then: function(resolve12) {
|
|
223505
|
+
listeners.push(resolve12);
|
|
222867
223506
|
}
|
|
222868
223507
|
};
|
|
222869
223508
|
thenable.then(function() {
|
|
@@ -233194,7 +233833,7 @@ function diffAnsiCodes(from, to) {
|
|
|
233194
233833
|
...to.filter((code3) => !startCodesInFrom.has(code3.code))
|
|
233195
233834
|
];
|
|
233196
233835
|
}
|
|
233197
|
-
var
|
|
233836
|
+
var init_diff2 = __esm(() => {
|
|
233198
233837
|
init_ansiCodes();
|
|
233199
233838
|
init_undo();
|
|
233200
233839
|
});
|
|
@@ -233233,7 +233872,7 @@ function styledCharsToString(chars) {
|
|
|
233233
233872
|
}
|
|
233234
233873
|
var init_styledChars = __esm(() => {
|
|
233235
233874
|
init_ansiCodes();
|
|
233236
|
-
|
|
233875
|
+
init_diff2();
|
|
233237
233876
|
init_reduce();
|
|
233238
233877
|
});
|
|
233239
233878
|
|
|
@@ -233366,7 +234005,7 @@ var init_tokenize = __esm(() => {
|
|
|
233366
234005
|
// node_modules/.pnpm/@alcalzone+ansi-tokenize@0.2.5/node_modules/@alcalzone/ansi-tokenize/build/index.js
|
|
233367
234006
|
var init_build = __esm(() => {
|
|
233368
234007
|
init_ansiCodes();
|
|
233369
|
-
|
|
234008
|
+
init_diff2();
|
|
233370
234009
|
init_reduce();
|
|
233371
234010
|
init_undo();
|
|
233372
234011
|
init_styledChars();
|
|
@@ -235148,8 +235787,8 @@ class Ink {
|
|
|
235148
235787
|
}
|
|
235149
235788
|
}
|
|
235150
235789
|
async waitUntilExit() {
|
|
235151
|
-
this.exitPromise ||= new Promise((
|
|
235152
|
-
this.resolveExitPromise =
|
|
235790
|
+
this.exitPromise ||= new Promise((resolve12, reject) => {
|
|
235791
|
+
this.resolveExitPromise = resolve12;
|
|
235153
235792
|
this.rejectExitPromise = reject;
|
|
235154
235793
|
});
|
|
235155
235794
|
if (!this.beforeExitHandler) {
|
|
@@ -236248,14 +236887,14 @@ var require_filesystem = __commonJS((exports, module) => {
|
|
|
236248
236887
|
fs7.close(fd, () => {});
|
|
236249
236888
|
return buffer.subarray(0, bytesRead);
|
|
236250
236889
|
};
|
|
236251
|
-
var readFile10 = (path5) => new Promise((
|
|
236890
|
+
var readFile10 = (path5) => new Promise((resolve12, reject) => {
|
|
236252
236891
|
fs7.open(path5, "r", (err, fd) => {
|
|
236253
236892
|
if (err) {
|
|
236254
236893
|
reject(err);
|
|
236255
236894
|
} else {
|
|
236256
236895
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
236257
236896
|
fs7.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
236258
|
-
|
|
236897
|
+
resolve12(buffer.subarray(0, bytesRead));
|
|
236259
236898
|
fs7.close(fd, () => {});
|
|
236260
236899
|
});
|
|
236261
236900
|
}
|
|
@@ -236316,10 +236955,10 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
236316
236955
|
var commandOut = "";
|
|
236317
236956
|
var safeCommand = () => {
|
|
236318
236957
|
if (!commandOut) {
|
|
236319
|
-
return new Promise((
|
|
236958
|
+
return new Promise((resolve12) => {
|
|
236320
236959
|
childProcess.exec(command, (err, out) => {
|
|
236321
236960
|
commandOut = err ? " " : out;
|
|
236322
|
-
|
|
236961
|
+
resolve12(commandOut);
|
|
236323
236962
|
});
|
|
236324
236963
|
});
|
|
236325
236964
|
}
|
|
@@ -238876,14 +239515,14 @@ var require_input = __commonJS((exports, module) => {
|
|
|
238876
239515
|
return this;
|
|
238877
239516
|
} else {
|
|
238878
239517
|
if (this._isStreamInput()) {
|
|
238879
|
-
return new Promise((
|
|
239518
|
+
return new Promise((resolve12, reject) => {
|
|
238880
239519
|
const finished = () => {
|
|
238881
239520
|
this._flattenBufferIn();
|
|
238882
239521
|
sharp.metadata(this.options, (err, metadata2) => {
|
|
238883
239522
|
if (err) {
|
|
238884
239523
|
reject(is2.nativeError(err, stack));
|
|
238885
239524
|
} else {
|
|
238886
|
-
|
|
239525
|
+
resolve12(metadata2);
|
|
238887
239526
|
}
|
|
238888
239527
|
});
|
|
238889
239528
|
};
|
|
@@ -238894,12 +239533,12 @@ var require_input = __commonJS((exports, module) => {
|
|
|
238894
239533
|
}
|
|
238895
239534
|
});
|
|
238896
239535
|
} else {
|
|
238897
|
-
return new Promise((
|
|
239536
|
+
return new Promise((resolve12, reject) => {
|
|
238898
239537
|
sharp.metadata(this.options, (err, metadata2) => {
|
|
238899
239538
|
if (err) {
|
|
238900
239539
|
reject(is2.nativeError(err, stack));
|
|
238901
239540
|
} else {
|
|
238902
|
-
|
|
239541
|
+
resolve12(metadata2);
|
|
238903
239542
|
}
|
|
238904
239543
|
});
|
|
238905
239544
|
});
|
|
@@ -238932,25 +239571,25 @@ var require_input = __commonJS((exports, module) => {
|
|
|
238932
239571
|
return this;
|
|
238933
239572
|
} else {
|
|
238934
239573
|
if (this._isStreamInput()) {
|
|
238935
|
-
return new Promise((
|
|
239574
|
+
return new Promise((resolve12, reject) => {
|
|
238936
239575
|
this.on("finish", function() {
|
|
238937
239576
|
this._flattenBufferIn();
|
|
238938
239577
|
sharp.stats(this.options, (err, stats2) => {
|
|
238939
239578
|
if (err) {
|
|
238940
239579
|
reject(is2.nativeError(err, stack));
|
|
238941
239580
|
} else {
|
|
238942
|
-
|
|
239581
|
+
resolve12(stats2);
|
|
238943
239582
|
}
|
|
238944
239583
|
});
|
|
238945
239584
|
});
|
|
238946
239585
|
});
|
|
238947
239586
|
} else {
|
|
238948
|
-
return new Promise((
|
|
239587
|
+
return new Promise((resolve12, reject) => {
|
|
238949
239588
|
sharp.stats(this.options, (err, stats2) => {
|
|
238950
239589
|
if (err) {
|
|
238951
239590
|
reject(is2.nativeError(err, stack));
|
|
238952
239591
|
} else {
|
|
238953
|
-
|
|
239592
|
+
resolve12(stats2);
|
|
238954
239593
|
}
|
|
238955
239594
|
});
|
|
238956
239595
|
});
|
|
@@ -242349,7 +242988,7 @@ var require_output = __commonJS((exports, module) => {
|
|
|
242349
242988
|
return this;
|
|
242350
242989
|
} else {
|
|
242351
242990
|
if (this._isStreamInput()) {
|
|
242352
|
-
return new Promise((
|
|
242991
|
+
return new Promise((resolve12, reject) => {
|
|
242353
242992
|
this.once("finish", () => {
|
|
242354
242993
|
this._flattenBufferIn();
|
|
242355
242994
|
sharp.pipeline(this.options, (err, data, info) => {
|
|
@@ -242357,24 +242996,24 @@ var require_output = __commonJS((exports, module) => {
|
|
|
242357
242996
|
reject(is2.nativeError(err, stack));
|
|
242358
242997
|
} else {
|
|
242359
242998
|
if (this.options.resolveWithObject) {
|
|
242360
|
-
|
|
242999
|
+
resolve12({ data, info });
|
|
242361
243000
|
} else {
|
|
242362
|
-
|
|
243001
|
+
resolve12(data);
|
|
242363
243002
|
}
|
|
242364
243003
|
}
|
|
242365
243004
|
});
|
|
242366
243005
|
});
|
|
242367
243006
|
});
|
|
242368
243007
|
} else {
|
|
242369
|
-
return new Promise((
|
|
243008
|
+
return new Promise((resolve12, reject) => {
|
|
242370
243009
|
sharp.pipeline(this.options, (err, data, info) => {
|
|
242371
243010
|
if (err) {
|
|
242372
243011
|
reject(is2.nativeError(err, stack));
|
|
242373
243012
|
} else {
|
|
242374
243013
|
if (this.options.resolveWithObject) {
|
|
242375
|
-
|
|
243014
|
+
resolve12({ data, info });
|
|
242376
243015
|
} else {
|
|
242377
|
-
|
|
243016
|
+
resolve12(data);
|
|
242378
243017
|
}
|
|
242379
243018
|
}
|
|
242380
243019
|
});
|
|
@@ -242610,7 +243249,7 @@ var init_image3 = __esm(() => {
|
|
|
242610
243249
|
|
|
242611
243250
|
// node_modules/.pnpm/ink-picture@1.3.3_ink@6.7.0_@types+react@19.2.14_react-devtools-core@7.0.1_react@19.2.4__react@19.2.4/node_modules/ink-picture/build/utils/queryEscapeSequence.js
|
|
242612
243251
|
function queryEscapeSequence(message, stdin, stdout, setRawMode) {
|
|
242613
|
-
return new Promise((
|
|
243252
|
+
return new Promise((resolve12) => {
|
|
242614
243253
|
const responseTimeout = 100;
|
|
242615
243254
|
let responseTimeoutId = undefined;
|
|
242616
243255
|
const timeoutBetweenReplies = 50;
|
|
@@ -242638,18 +243277,18 @@ function queryEscapeSequence(message, stdin, stdout, setRawMode) {
|
|
|
242638
243277
|
runningReply += data;
|
|
242639
243278
|
timeoutBetweenRepliesId = setTimeout(() => {
|
|
242640
243279
|
restoreState();
|
|
242641
|
-
|
|
243280
|
+
resolve12(runningReply.length > 0 ? runningReply : undefined);
|
|
242642
243281
|
}, timeoutBetweenReplies);
|
|
242643
243282
|
};
|
|
242644
243283
|
const onClose = () => {
|
|
242645
243284
|
restoreState();
|
|
242646
|
-
|
|
243285
|
+
resolve12(runningReply.length > 0 ? runningReply : undefined);
|
|
242647
243286
|
};
|
|
242648
243287
|
stdin.on("data", onData);
|
|
242649
243288
|
stdin.on("close", onClose);
|
|
242650
243289
|
responseTimeoutId = setTimeout(() => {
|
|
242651
243290
|
restoreState();
|
|
242652
|
-
|
|
243291
|
+
resolve12(undefined);
|
|
242653
243292
|
}, responseTimeout);
|
|
242654
243293
|
stdout.write(message);
|
|
242655
243294
|
});
|
|
@@ -242835,15 +243474,15 @@ var require_windows = __commonJS((exports, module) => {
|
|
|
242835
243474
|
}
|
|
242836
243475
|
return false;
|
|
242837
243476
|
}
|
|
242838
|
-
function checkStat(
|
|
242839
|
-
if (!
|
|
243477
|
+
function checkStat(stat7, path5, options2) {
|
|
243478
|
+
if (!stat7.isSymbolicLink() && !stat7.isFile()) {
|
|
242840
243479
|
return false;
|
|
242841
243480
|
}
|
|
242842
243481
|
return checkPathExt(path5, options2);
|
|
242843
243482
|
}
|
|
242844
243483
|
function isexe(path5, options2, cb2) {
|
|
242845
|
-
fs7.stat(path5, function(er,
|
|
242846
|
-
cb2(er, er ? false : checkStat(
|
|
243484
|
+
fs7.stat(path5, function(er, stat7) {
|
|
243485
|
+
cb2(er, er ? false : checkStat(stat7, path5, options2));
|
|
242847
243486
|
});
|
|
242848
243487
|
}
|
|
242849
243488
|
function sync(path5, options2) {
|
|
@@ -242857,20 +243496,20 @@ var require_mode = __commonJS((exports, module) => {
|
|
|
242857
243496
|
isexe.sync = sync;
|
|
242858
243497
|
var fs7 = __require("fs");
|
|
242859
243498
|
function isexe(path5, options2, cb2) {
|
|
242860
|
-
fs7.stat(path5, function(er,
|
|
242861
|
-
cb2(er, er ? false : checkStat(
|
|
243499
|
+
fs7.stat(path5, function(er, stat7) {
|
|
243500
|
+
cb2(er, er ? false : checkStat(stat7, options2));
|
|
242862
243501
|
});
|
|
242863
243502
|
}
|
|
242864
243503
|
function sync(path5, options2) {
|
|
242865
243504
|
return checkStat(fs7.statSync(path5), options2);
|
|
242866
243505
|
}
|
|
242867
|
-
function checkStat(
|
|
242868
|
-
return
|
|
243506
|
+
function checkStat(stat7, options2) {
|
|
243507
|
+
return stat7.isFile() && checkMode(stat7, options2);
|
|
242869
243508
|
}
|
|
242870
|
-
function checkMode(
|
|
242871
|
-
var mod =
|
|
242872
|
-
var uid =
|
|
242873
|
-
var gid =
|
|
243509
|
+
function checkMode(stat7, options2) {
|
|
243510
|
+
var mod = stat7.mode;
|
|
243511
|
+
var uid = stat7.uid;
|
|
243512
|
+
var gid = stat7.gid;
|
|
242874
243513
|
var myUid = options2.uid !== undefined ? options2.uid : process.getuid && process.getuid();
|
|
242875
243514
|
var myGid = options2.gid !== undefined ? options2.gid : process.getgid && process.getgid();
|
|
242876
243515
|
var u5 = parseInt("100", 8);
|
|
@@ -242902,12 +243541,12 @@ var require_isexe = __commonJS((exports, module) => {
|
|
|
242902
243541
|
if (typeof Promise !== "function") {
|
|
242903
243542
|
throw new TypeError("callback not provided");
|
|
242904
243543
|
}
|
|
242905
|
-
return new Promise(function(
|
|
243544
|
+
return new Promise(function(resolve12, reject) {
|
|
242906
243545
|
isexe(path5, options2 || {}, function(er, is2) {
|
|
242907
243546
|
if (er) {
|
|
242908
243547
|
reject(er);
|
|
242909
243548
|
} else {
|
|
242910
|
-
|
|
243549
|
+
resolve12(is2);
|
|
242911
243550
|
}
|
|
242912
243551
|
});
|
|
242913
243552
|
});
|
|
@@ -242969,27 +243608,27 @@ var require_which = __commonJS((exports, module) => {
|
|
|
242969
243608
|
opt = {};
|
|
242970
243609
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
242971
243610
|
const found = [];
|
|
242972
|
-
const step = (i6) => new Promise((
|
|
243611
|
+
const step = (i6) => new Promise((resolve12, reject) => {
|
|
242973
243612
|
if (i6 === pathEnv.length)
|
|
242974
|
-
return opt.all && found.length ?
|
|
243613
|
+
return opt.all && found.length ? resolve12(found) : reject(getNotFoundError(cmd));
|
|
242975
243614
|
const ppRaw = pathEnv[i6];
|
|
242976
243615
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
242977
243616
|
const pCmd = path5.join(pathPart, cmd);
|
|
242978
243617
|
const p5 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
242979
|
-
|
|
243618
|
+
resolve12(subStep(p5, i6, 0));
|
|
242980
243619
|
});
|
|
242981
|
-
const subStep = (p5, i6, ii) => new Promise((
|
|
243620
|
+
const subStep = (p5, i6, ii) => new Promise((resolve12, reject) => {
|
|
242982
243621
|
if (ii === pathExt.length)
|
|
242983
|
-
return
|
|
243622
|
+
return resolve12(step(i6 + 1));
|
|
242984
243623
|
const ext = pathExt[ii];
|
|
242985
243624
|
isexe(p5 + ext, { pathExt: pathExtExe }, (er, is2) => {
|
|
242986
243625
|
if (!er && is2) {
|
|
242987
243626
|
if (opt.all)
|
|
242988
243627
|
found.push(p5 + ext);
|
|
242989
243628
|
else
|
|
242990
|
-
return
|
|
243629
|
+
return resolve12(p5 + ext);
|
|
242991
243630
|
}
|
|
242992
|
-
return
|
|
243631
|
+
return resolve12(subStep(p5, i6, ii + 1));
|
|
242993
243632
|
});
|
|
242994
243633
|
});
|
|
242995
243634
|
return cb2 ? step(0).then((res) => cb2(null, res), cb2) : step(0);
|
|
@@ -243876,7 +244515,7 @@ var require_kill = __commonJS((exports, module) => {
|
|
|
243876
244515
|
return spawnedPromise;
|
|
243877
244516
|
}
|
|
243878
244517
|
let timeoutId;
|
|
243879
|
-
const timeoutPromise = new Promise((
|
|
244518
|
+
const timeoutPromise = new Promise((resolve12, reject) => {
|
|
243880
244519
|
timeoutId = setTimeout(() => {
|
|
243881
244520
|
timeoutKill(spawned, killSignal, reject);
|
|
243882
244521
|
}, timeout);
|
|
@@ -243987,7 +244626,7 @@ var require_get_stream = __commonJS((exports, module) => {
|
|
|
243987
244626
|
};
|
|
243988
244627
|
const { maxBuffer } = options2;
|
|
243989
244628
|
const stream2 = bufferStream(options2);
|
|
243990
|
-
await new Promise((
|
|
244629
|
+
await new Promise((resolve12, reject) => {
|
|
243991
244630
|
const rejectPromise = (error4) => {
|
|
243992
244631
|
if (error4 && stream2.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
|
|
243993
244632
|
error4.bufferedData = stream2.getBufferedValue();
|
|
@@ -243997,7 +244636,7 @@ var require_get_stream = __commonJS((exports, module) => {
|
|
|
243997
244636
|
(async () => {
|
|
243998
244637
|
try {
|
|
243999
244638
|
await streamPipelinePromisified(inputStream, stream2);
|
|
244000
|
-
|
|
244639
|
+
resolve12();
|
|
244001
244640
|
} catch (error4) {
|
|
244002
244641
|
rejectPromise(error4);
|
|
244003
244642
|
}
|
|
@@ -244144,9 +244783,9 @@ var require_promise = __commonJS((exports, module) => {
|
|
|
244144
244783
|
return spawned;
|
|
244145
244784
|
};
|
|
244146
244785
|
var getSpawnedPromise = (spawned) => {
|
|
244147
|
-
return new Promise((
|
|
244786
|
+
return new Promise((resolve12, reject) => {
|
|
244148
244787
|
spawned.on("exit", (exitCode, signal) => {
|
|
244149
|
-
|
|
244788
|
+
resolve12({ exitCode, signal });
|
|
244150
244789
|
});
|
|
244151
244790
|
spawned.on("error", (error4) => {
|
|
244152
244791
|
reject(error4);
|
|
@@ -257781,7 +258420,7 @@ await __promiseAll([
|
|
|
257781
258420
|
var import_react86 = __toESM(require_react(), 1);
|
|
257782
258421
|
import { spawn as spawn6 } from "child_process";
|
|
257783
258422
|
import { join as join48 } from "path";
|
|
257784
|
-
import { homedir as
|
|
258423
|
+
import { homedir as homedir27 } from "os";
|
|
257785
258424
|
|
|
257786
258425
|
// packages/terminal/src/components/Input.tsx
|
|
257787
258426
|
await init_build2();
|
|
@@ -258436,16 +259075,20 @@ var Input = import_react30.default.forwardRef(function Input2({
|
|
|
258436
259075
|
};
|
|
258437
259076
|
useSafeInput((input, key) => {
|
|
258438
259077
|
if (key.ctrl && input === "c") {
|
|
259078
|
+
if (isProcessing && onStopProcessing) {
|
|
259079
|
+
onStopProcessing();
|
|
259080
|
+
return;
|
|
259081
|
+
}
|
|
258439
259082
|
if (value2.length > 0) {
|
|
258440
259083
|
setValueAndCursor("");
|
|
258441
259084
|
}
|
|
258442
259085
|
return;
|
|
258443
259086
|
}
|
|
259087
|
+
if (key.escape && isProcessing && onStopProcessing) {
|
|
259088
|
+
onStopProcessing();
|
|
259089
|
+
return;
|
|
259090
|
+
}
|
|
258444
259091
|
if (key.escape && !isAskingUser) {
|
|
258445
|
-
if (isProcessing && onStopProcessing) {
|
|
258446
|
-
onStopProcessing();
|
|
258447
|
-
return;
|
|
258448
|
-
}
|
|
258449
259092
|
if (largePaste) {
|
|
258450
259093
|
setLargePaste(null);
|
|
258451
259094
|
setShowPastePreview(false);
|
|
@@ -262082,35 +262725,47 @@ function QueueIndicator({
|
|
|
262082
262725
|
const hasMore = totalCount > maxPreview;
|
|
262083
262726
|
const inlineCount = messages2.filter((msg) => msg.mode === "inline").length;
|
|
262084
262727
|
const queuedCount = messages2.filter((msg) => msg.mode === "queued").length;
|
|
262728
|
+
const parts = [];
|
|
262729
|
+
if (queuedCount > 0)
|
|
262730
|
+
parts.push(`${queuedCount} queued`);
|
|
262731
|
+
if (inlineCount > 0)
|
|
262732
|
+
parts.push(`${inlineCount} in-stream`);
|
|
262733
|
+
const summary = parts.join(", ");
|
|
262085
262734
|
return /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
262086
262735
|
flexDirection: "column",
|
|
262736
|
+
marginTop: 0,
|
|
262737
|
+
marginBottom: 0,
|
|
262087
262738
|
children: [
|
|
262088
|
-
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(
|
|
262089
|
-
dimColor: true,
|
|
262739
|
+
previewItems.map((msg) => /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
262090
262740
|
children: [
|
|
262091
|
-
|
|
262092
|
-
|
|
262093
|
-
|
|
262094
|
-
|
|
262095
|
-
|
|
262741
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
262742
|
+
color: msg.mode === "inline" ? "cyan" : "yellow",
|
|
262743
|
+
children: [
|
|
262744
|
+
msg.mode === "inline" ? "\u26A1" : "\u23F3",
|
|
262745
|
+
" ",
|
|
262746
|
+
msg.mode === "inline" ? "in-stream" : "queued",
|
|
262747
|
+
":",
|
|
262748
|
+
" "
|
|
262749
|
+
]
|
|
262750
|
+
}, undefined, true, undefined, this),
|
|
262751
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
262752
|
+
dimColor: true,
|
|
262753
|
+
children: [
|
|
262754
|
+
'"',
|
|
262755
|
+
truncateQueued(msg.content, 60),
|
|
262756
|
+
'"'
|
|
262757
|
+
]
|
|
262758
|
+
}, undefined, true, undefined, this)
|
|
262096
262759
|
]
|
|
262097
|
-
},
|
|
262098
|
-
previewItems.map((queued) => /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
262099
|
-
marginLeft: 2,
|
|
262100
|
-
children: /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
262101
|
-
dimColor: true,
|
|
262102
|
-
children: [
|
|
262103
|
-
"\u21B3 ",
|
|
262104
|
-
truncateQueued(queued.content)
|
|
262105
|
-
]
|
|
262106
|
-
}, undefined, true, undefined, this)
|
|
262107
|
-
}, queued.id, false, undefined, this)),
|
|
262760
|
+
}, msg.id, true, undefined, this)),
|
|
262108
262761
|
hasMore && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
262109
262762
|
dimColor: true,
|
|
262110
262763
|
children: [
|
|
262111
262764
|
" +",
|
|
262112
262765
|
totalCount - maxPreview,
|
|
262113
|
-
" more"
|
|
262766
|
+
" more (",
|
|
262767
|
+
summary,
|
|
262768
|
+
")"
|
|
262114
262769
|
]
|
|
262115
262770
|
}, undefined, true, undefined, this)
|
|
262116
262771
|
]
|
|
@@ -289347,7 +290002,7 @@ var HOOK_TYPE_SET = new Set(["command", "prompt", "assistant"]);
|
|
|
289347
290002
|
var HOOK_LOCATION_SET = new Set(["project", "user", "local"]);
|
|
289348
290003
|
var HOOK_EVENT_MAP = new Map(Array.from(HOOK_EVENT_SET).map((ev) => [ev.toLowerCase(), ev]));
|
|
289349
290004
|
async function runShellCommand(command, cwd3) {
|
|
289350
|
-
return new Promise((
|
|
290005
|
+
return new Promise((resolve12, reject) => {
|
|
289351
290006
|
const child = spawn6(command, { cwd: cwd3, shell: true, env: process.env });
|
|
289352
290007
|
const stdoutChunks = [];
|
|
289353
290008
|
const stderrChunks = [];
|
|
@@ -289376,7 +290031,7 @@ async function runShellCommand(command, cwd3) {
|
|
|
289376
290031
|
}
|
|
289377
290032
|
child.on("error", (error4) => reject(error4));
|
|
289378
290033
|
child.on("close", (code3) => {
|
|
289379
|
-
|
|
290034
|
+
resolve12({
|
|
289380
290035
|
stdout: Buffer.concat(stdoutChunks).toString("utf8").trimEnd(),
|
|
289381
290036
|
stderr: Buffer.concat(stderrChunks).toString("utf8").trimEnd(),
|
|
289382
290037
|
exitCode: code3,
|
|
@@ -289693,7 +290348,7 @@ function App2({ cwd: cwd3, version: version4 }) {
|
|
|
289693
290348
|
setInlinePending((prev) => prev.filter((msg) => msg.id !== id));
|
|
289694
290349
|
}, []);
|
|
289695
290350
|
const beginAskUser = import_react86.useCallback((sessionId, request2) => {
|
|
289696
|
-
return new Promise((
|
|
290351
|
+
return new Promise((resolve12, reject) => {
|
|
289697
290352
|
if (askUserStateRef.current.has(sessionId)) {
|
|
289698
290353
|
reject(new Error("Another interview is already in progress for this session."));
|
|
289699
290354
|
return;
|
|
@@ -289703,7 +290358,7 @@ function App2({ cwd: cwd3, version: version4 }) {
|
|
|
289703
290358
|
request: request2,
|
|
289704
290359
|
index: 0,
|
|
289705
290360
|
answers: {},
|
|
289706
|
-
resolve:
|
|
290361
|
+
resolve: resolve12,
|
|
289707
290362
|
reject
|
|
289708
290363
|
};
|
|
289709
290364
|
askUserStateRef.current.set(sessionId, state);
|
|
@@ -289774,7 +290429,7 @@ function App2({ cwd: cwd3, version: version4 }) {
|
|
|
289774
290429
|
}
|
|
289775
290430
|
}, [activeSessionId]);
|
|
289776
290431
|
const beginInterview = import_react86.useCallback((sessionId, request2) => {
|
|
289777
|
-
return new Promise((
|
|
290432
|
+
return new Promise((resolve12, reject) => {
|
|
289778
290433
|
if (interviewStateRef.current.has(sessionId)) {
|
|
289779
290434
|
reject(new Error("Another interview is already in progress for this session."));
|
|
289780
290435
|
return;
|
|
@@ -289791,7 +290446,7 @@ function App2({ cwd: cwd3, version: version4 }) {
|
|
|
289791
290446
|
sessionId,
|
|
289792
290447
|
interviewId,
|
|
289793
290448
|
request: request2,
|
|
289794
|
-
resolve:
|
|
290449
|
+
resolve: resolve12,
|
|
289795
290450
|
reject
|
|
289796
290451
|
};
|
|
289797
290452
|
interviewStateRef.current.set(sessionId, state);
|
|
@@ -289847,8 +290502,8 @@ function App2({ cwd: cwd3, version: version4 }) {
|
|
|
289847
290502
|
}
|
|
289848
290503
|
}, [isProcessing, processingStartTime]);
|
|
289849
290504
|
import_react86.useEffect(() => {
|
|
289850
|
-
const { exec:
|
|
289851
|
-
|
|
290505
|
+
const { exec: exec6 } = __require("child_process");
|
|
290506
|
+
exec6("git branch --show-current 2>/dev/null", { cwd: cwd3 }, (err, stdout2) => {
|
|
289852
290507
|
if (!err && stdout2?.trim()) {
|
|
289853
290508
|
setGitBranch(stdout2.trim());
|
|
289854
290509
|
}
|
|
@@ -291129,7 +291784,7 @@ function App2({ cwd: cwd3, version: version4 }) {
|
|
|
291129
291784
|
}, [recoverableSessions, createSessionFromRecovery, workspaceBaseDir]);
|
|
291130
291785
|
const handleOnboardingComplete = import_react86.useCallback(async (result) => {
|
|
291131
291786
|
const { existsSync: existsSync30, mkdirSync: mkdirSync19, readFileSync: readFileSync18, writeFileSync: writeFileSync13, appendFileSync: appendFileSync5 } = await import("fs");
|
|
291132
|
-
const secretsPath = join48(
|
|
291787
|
+
const secretsPath = join48(homedir27(), ".secrets");
|
|
291133
291788
|
const providerInfo = getProviderInfo(result.provider);
|
|
291134
291789
|
const envName = providerInfo?.apiKeyEnv || "ANTHROPIC_API_KEY";
|
|
291135
291790
|
const keyExport = `export ${envName}="${result.apiKey}"`;
|
|
@@ -294451,7 +295106,7 @@ process.on("unhandledRejection", (reason) => {
|
|
|
294451
295106
|
cleanup();
|
|
294452
295107
|
process.exit(1);
|
|
294453
295108
|
});
|
|
294454
|
-
var VERSION4 = "1.1.
|
|
295109
|
+
var VERSION4 = "1.1.86";
|
|
294455
295110
|
var SYNC_START = "\x1B[?2026h";
|
|
294456
295111
|
var SYNC_END = "\x1B[?2026l";
|
|
294457
295112
|
function enableSynchronizedOutput() {
|
|
@@ -294596,4 +295251,4 @@ export {
|
|
|
294596
295251
|
main
|
|
294597
295252
|
};
|
|
294598
295253
|
|
|
294599
|
-
//# debugId=
|
|
295254
|
+
//# debugId=27FD559CEE6360B064756E2164756E21
|