micro-models-agent 0.24.10 → 0.24.12
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/main.js +152 -43
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -3810,10 +3810,6 @@ var init_data_sanitizer = __esm(() => {
|
|
|
3810
3810
|
{
|
|
3811
3811
|
pattern: /Bearer\s+[a-zA-Z0-9_-]{20,}/gi,
|
|
3812
3812
|
replacement: "Bearer [REDACTED]"
|
|
3813
|
-
},
|
|
3814
|
-
{
|
|
3815
|
-
pattern: /\b([a-zA-Z0-9_-]{30,})\b/g,
|
|
3816
|
-
replacement: "[REDACTED]"
|
|
3817
3813
|
}
|
|
3818
3814
|
];
|
|
3819
3815
|
});
|
|
@@ -5012,6 +5008,14 @@ class ToolResultCache {
|
|
|
5012
5008
|
has(key) {
|
|
5013
5009
|
return this.get(key) !== undefined;
|
|
5014
5010
|
}
|
|
5011
|
+
cleanExpired() {
|
|
5012
|
+
const now = Date.now();
|
|
5013
|
+
for (const [key, entry] of this.cache) {
|
|
5014
|
+
if (now > entry.expiresAt) {
|
|
5015
|
+
this.cache.delete(key);
|
|
5016
|
+
}
|
|
5017
|
+
}
|
|
5018
|
+
}
|
|
5015
5019
|
clear() {
|
|
5016
5020
|
this.cache.clear();
|
|
5017
5021
|
}
|
|
@@ -5132,6 +5136,7 @@ class ToolExecutor {
|
|
|
5132
5136
|
this.cache.set(key, result.output);
|
|
5133
5137
|
this.ctx.logger.debug(`Tool ${call.name}: CACHED`);
|
|
5134
5138
|
}
|
|
5139
|
+
this.cache.cleanExpired();
|
|
5135
5140
|
this.ctx.logger.debug(`Tool ${call.name}: ${result.success ? "OK" : "FAIL"}`);
|
|
5136
5141
|
return result;
|
|
5137
5142
|
}
|
|
@@ -5147,6 +5152,9 @@ class ToolExecutor {
|
|
|
5147
5152
|
setScope(scope) {
|
|
5148
5153
|
this.ctx.scope = scope;
|
|
5149
5154
|
}
|
|
5155
|
+
setOnMeta(onMeta) {
|
|
5156
|
+
this.ctx.onMeta = onMeta;
|
|
5157
|
+
}
|
|
5150
5158
|
updateProvider(provider) {
|
|
5151
5159
|
this.ctx.llmProvider = provider;
|
|
5152
5160
|
}
|
|
@@ -6260,7 +6268,8 @@ var init_edit_file = __esm(() => {
|
|
|
6260
6268
|
output: t("file.string_not_found", { str: oldStr })
|
|
6261
6269
|
};
|
|
6262
6270
|
}
|
|
6263
|
-
const
|
|
6271
|
+
const occurrences = content.split(oldStr).length - 1;
|
|
6272
|
+
const updated = occurrences > 1 ? content.replaceAll(oldStr, newStr) : content.replace(oldStr, newStr);
|
|
6264
6273
|
const scanResult = scanContent(updated, path, ctx.config.security?.contentScan);
|
|
6265
6274
|
if (!scanResult.allowed) {
|
|
6266
6275
|
logSecurityBlock(ctx.sessionId, "file_write", scanResult.reason || "Content contains dangerous patterns", path);
|
|
@@ -6667,6 +6676,12 @@ var init_file_info = __esm(() => {
|
|
|
6667
6676
|
});
|
|
6668
6677
|
|
|
6669
6678
|
// src/modules/security/command-validator.ts
|
|
6679
|
+
function hasShellIndirection(command) {
|
|
6680
|
+
return /\$\{[^}]+\}/.test(command) || /\$\(/.test(command) || /`[^`]+`/.test(command) || /\$\(\(/.test(command) || /\$\{[!]/.test(command);
|
|
6681
|
+
}
|
|
6682
|
+
function hasEvalConstruct(command) {
|
|
6683
|
+
return /\beval\b/.test(command) || /\bsource\b/.test(command);
|
|
6684
|
+
}
|
|
6670
6685
|
function extractBaseCommand(trimmed) {
|
|
6671
6686
|
const tokens = trimmed.split(/\s+/);
|
|
6672
6687
|
let i = 0;
|
|
@@ -6722,6 +6737,18 @@ function isCommandAllowed(command, securityConfig) {
|
|
|
6722
6737
|
reason: `Shell wrapper "${baseForShellCheck}" is blocked — use the bash tool directly`
|
|
6723
6738
|
};
|
|
6724
6739
|
}
|
|
6740
|
+
if (hasShellIndirection(trimmedCommand)) {
|
|
6741
|
+
return {
|
|
6742
|
+
allowed: false,
|
|
6743
|
+
reason: `Shell indirection (variable expansion, command substitution, or backtick execution) is not allowed`
|
|
6744
|
+
};
|
|
6745
|
+
}
|
|
6746
|
+
if (hasEvalConstruct(trimmedCommand)) {
|
|
6747
|
+
return {
|
|
6748
|
+
allowed: false,
|
|
6749
|
+
reason: `eval/source constructs are not allowed`
|
|
6750
|
+
};
|
|
6751
|
+
}
|
|
6725
6752
|
if (config.blockDangerousFlags) {
|
|
6726
6753
|
for (const op of config.dangerousOperators || []) {
|
|
6727
6754
|
if (containsOperator(trimmedCommand, op)) {
|
|
@@ -6732,7 +6759,15 @@ function isCommandAllowed(command, securityConfig) {
|
|
|
6732
6759
|
}
|
|
6733
6760
|
}
|
|
6734
6761
|
}
|
|
6735
|
-
const baseCommand =
|
|
6762
|
+
const baseCommand = baseForShellCheck;
|
|
6763
|
+
if (!baseCommand || baseCommand === trimmedCommand.trim()) {
|
|
6764
|
+
if (baseCommand === "sudo" || baseCommand === "env" || baseCommand === "nohup" || baseCommand === "exec") {
|
|
6765
|
+
return {
|
|
6766
|
+
allowed: false,
|
|
6767
|
+
reason: `Prefix "${baseCommand}" requires a target command`
|
|
6768
|
+
};
|
|
6769
|
+
}
|
|
6770
|
+
}
|
|
6736
6771
|
if (config.whitelist.length > 0) {
|
|
6737
6772
|
if (!config.whitelist.includes(baseCommand)) {
|
|
6738
6773
|
return {
|
|
@@ -8408,7 +8443,12 @@ function validatePlan(plan, config) {
|
|
|
8408
8443
|
const warnings = [];
|
|
8409
8444
|
const autoFixes = [];
|
|
8410
8445
|
if (!plan.subtasks || plan.subtasks.length === 0) {
|
|
8411
|
-
return {
|
|
8446
|
+
return {
|
|
8447
|
+
valid: false,
|
|
8448
|
+
errors: ["Plan has no subtasks"],
|
|
8449
|
+
warnings: [],
|
|
8450
|
+
autoFixes: []
|
|
8451
|
+
};
|
|
8412
8452
|
}
|
|
8413
8453
|
errors.push(...expertTagsExist(plan.subtasks, config));
|
|
8414
8454
|
errors.push(...hasCycle(plan.subtasks));
|
|
@@ -8417,7 +8457,10 @@ function validatePlan(plan, config) {
|
|
|
8417
8457
|
const readOverlaps = deleteReadOverlap(plan.subtasks);
|
|
8418
8458
|
for (const overlap of readOverlaps) {
|
|
8419
8459
|
if (overlap.canAutoFix) {
|
|
8420
|
-
autoFixes.push({
|
|
8460
|
+
autoFixes.push({
|
|
8461
|
+
subtaskId: overlap.subtaskId,
|
|
8462
|
+
fix: `Add depends_on: ${overlap.dependsOn}`
|
|
8463
|
+
});
|
|
8421
8464
|
} else if (overlap.error) {
|
|
8422
8465
|
errors.push(overlap.error);
|
|
8423
8466
|
}
|
|
@@ -8463,7 +8506,6 @@ function hasCycle(subtasks) {
|
|
|
8463
8506
|
}
|
|
8464
8507
|
const errors = [];
|
|
8465
8508
|
for (const s of subtasks) {
|
|
8466
|
-
visited.clear();
|
|
8467
8509
|
inStack.clear();
|
|
8468
8510
|
if (dfs(s.id)) {
|
|
8469
8511
|
errors.push(`Cycle detected involving subtask "${s.id}"`);
|
|
@@ -8721,13 +8763,26 @@ class MoEExecutor {
|
|
|
8721
8763
|
constructor(deps) {
|
|
8722
8764
|
this.deps = deps;
|
|
8723
8765
|
}
|
|
8724
|
-
async executePlan(plan) {
|
|
8766
|
+
async executePlan(plan, signal) {
|
|
8725
8767
|
const results = [];
|
|
8726
8768
|
const errors = [];
|
|
8727
8769
|
const warnings = [];
|
|
8770
|
+
if (signal?.aborted) {
|
|
8771
|
+
return {
|
|
8772
|
+
success: false,
|
|
8773
|
+
results: [],
|
|
8774
|
+
errors: ["Execution aborted before start"],
|
|
8775
|
+
warnings: []
|
|
8776
|
+
};
|
|
8777
|
+
}
|
|
8728
8778
|
const waves = topologicalSort(plan.subtasks);
|
|
8729
8779
|
if (waves.length === 0) {
|
|
8730
|
-
return {
|
|
8780
|
+
return {
|
|
8781
|
+
success: false,
|
|
8782
|
+
results: [],
|
|
8783
|
+
errors: ["Failed to topologically sort subtasks (possible cycle)"],
|
|
8784
|
+
warnings: []
|
|
8785
|
+
};
|
|
8731
8786
|
}
|
|
8732
8787
|
const sortedCount = waves.flat().length;
|
|
8733
8788
|
if (sortedCount < plan.subtasks.length) {
|
|
@@ -8735,11 +8790,17 @@ class MoEExecutor {
|
|
|
8735
8790
|
return {
|
|
8736
8791
|
success: false,
|
|
8737
8792
|
results: [],
|
|
8738
|
-
errors: [
|
|
8793
|
+
errors: [
|
|
8794
|
+
`Missing subtasks after topological sort: ${missing.join(", ")} (dangling or invalid depends_on)`
|
|
8795
|
+
],
|
|
8739
8796
|
warnings: []
|
|
8740
8797
|
};
|
|
8741
8798
|
}
|
|
8742
8799
|
for (let waveIdx = 0;waveIdx < waves.length; waveIdx++) {
|
|
8800
|
+
if (signal?.aborted) {
|
|
8801
|
+
warnings.push(`Execution aborted during wave ${waveIdx + 1}/${waves.length}`);
|
|
8802
|
+
break;
|
|
8803
|
+
}
|
|
8743
8804
|
const wave = waves[waveIdx];
|
|
8744
8805
|
const wavePromises = wave.map((subtask) => executeSubtask(subtask, this.deps, plan.shared_context).then((result) => {
|
|
8745
8806
|
results.push(result);
|
|
@@ -8939,7 +9000,12 @@ var init_verifier = __esm(() => {
|
|
|
8939
9000
|
// src/core/agent-moe.ts
|
|
8940
9001
|
async function runWithMoE(deps, input, fallback, opts = {}) {
|
|
8941
9002
|
const { config, llmProvider, logger, toolExecutor, baseDir } = deps;
|
|
8942
|
-
const { onMeta, onPhase } = opts;
|
|
9003
|
+
const { onMeta, onPhase, signal } = opts;
|
|
9004
|
+
const abortCheck = () => {
|
|
9005
|
+
if (signal?.aborted)
|
|
9006
|
+
return true;
|
|
9007
|
+
return false;
|
|
9008
|
+
};
|
|
8943
9009
|
const orchestrator = new OrchestratorClient({
|
|
8944
9010
|
model: config.orchestrator.model,
|
|
8945
9011
|
provider: config.orchestrator.provider
|
|
@@ -8985,7 +9051,7 @@ async function runWithMoE(deps, input, fallback, opts = {}) {
|
|
|
8985
9051
|
const executor = new MoEExecutor(moeDeps);
|
|
8986
9052
|
onMeta?.(`⚙️ Executing ${plan.subtasks.length} subtasks...
|
|
8987
9053
|
`);
|
|
8988
|
-
const planResults = await executor.executePlan(plan);
|
|
9054
|
+
const planResults = await executor.executePlan(plan, signal);
|
|
8989
9055
|
onMeta?.(`✅ Execution complete: ${planResults.results.filter((r) => r.success).length}/${planResults.results.length} succeeded
|
|
8990
9056
|
`);
|
|
8991
9057
|
const verifier = new StepVerifier(baseDir);
|
|
@@ -9196,10 +9262,6 @@ class Agent {
|
|
|
9196
9262
|
const systemBudget = Math.floor(this.deps.config.contextWindow * this.deps.config.contextBudget.systemPrompt);
|
|
9197
9263
|
const builder = new PromptBuilder(systemBudget);
|
|
9198
9264
|
builder.addBlocks(this.deps.promptBlocks);
|
|
9199
|
-
const dynamic = this.deps.getDynamicPromptBlocks?.() ?? [];
|
|
9200
|
-
if (dynamic.length > 0) {
|
|
9201
|
-
builder.addBlocks(dynamic);
|
|
9202
|
-
}
|
|
9203
9265
|
const pluginBlocks = (this.deps.pluginManager.runOnBuildPrompt?.() ?? []).filter((s) => Boolean(s && s.trim() !== "")).map((content) => ({
|
|
9204
9266
|
content,
|
|
9205
9267
|
priority: "low",
|
|
@@ -9209,6 +9271,10 @@ class Agent {
|
|
|
9209
9271
|
if (pluginBlocks.length > 0) {
|
|
9210
9272
|
builder.addBlocks(pluginBlocks);
|
|
9211
9273
|
}
|
|
9274
|
+
const dynamic = this.deps.getDynamicPromptBlocks?.() ?? [];
|
|
9275
|
+
if (dynamic.length > 0) {
|
|
9276
|
+
builder.addBlocks(dynamic);
|
|
9277
|
+
}
|
|
9212
9278
|
return builder.build();
|
|
9213
9279
|
}
|
|
9214
9280
|
getSystemPromptInfo() {
|
|
@@ -9279,7 +9345,7 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
9279
9345
|
toolExecutor,
|
|
9280
9346
|
logger,
|
|
9281
9347
|
baseDir: this.deps.baseDir
|
|
9282
|
-
}, input, () => this.executeSingleAgentLoop(input, onChunk, onMeta, onTool, onPhase), { onMeta, onTool, onPhase });
|
|
9348
|
+
}, input, () => this.executeSingleAgentLoop(input, onChunk, onMeta, onTool, onPhase), { onMeta, onTool, onPhase, signal: this.abortController?.signal });
|
|
9283
9349
|
}
|
|
9284
9350
|
return this.executeSingleAgentLoop(input, onChunk, onMeta, onTool, onPhase);
|
|
9285
9351
|
}
|
|
@@ -9449,15 +9515,7 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
9449
9515
|
onTool?.({ type: "start", tool: call.name, args: call.arguments });
|
|
9450
9516
|
slog.logToolCall(call, iteration);
|
|
9451
9517
|
const tokensBeforeTool = contextManager.getEstimatedTokens();
|
|
9452
|
-
const toolCtx = this.deps.toolExecutor?.getContext?.();
|
|
9453
|
-
const prevOnMeta = toolCtx?.onMeta;
|
|
9454
|
-
if (toolCtx) {
|
|
9455
|
-
toolCtx.onMeta = onMeta;
|
|
9456
|
-
}
|
|
9457
9518
|
const result = await toolExecutor.execute(call, this.abortController?.signal);
|
|
9458
|
-
if (toolCtx) {
|
|
9459
|
-
toolCtx.onMeta = prevOnMeta;
|
|
9460
|
-
}
|
|
9461
9519
|
const duration = Date.now() - startTime;
|
|
9462
9520
|
pluginManager.runOnToolEnd({ iteration, logger }, { id: call.id, name: call.name, arguments: call.arguments }, result, duration);
|
|
9463
9521
|
return { call, result, duration, tokensBefore: tokensBeforeTool };
|
|
@@ -9510,11 +9568,12 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
9510
9568
|
if (config.session.autoSave) {
|
|
9511
9569
|
slog.logToolResult(call, result, duration, iteration);
|
|
9512
9570
|
}
|
|
9513
|
-
if (contextManager.needsCompaction()) {
|
|
9514
|
-
contextManager.compact();
|
|
9515
|
-
logger.debug("Context compacted after tool result");
|
|
9516
|
-
}
|
|
9517
9571
|
};
|
|
9572
|
+
const toolExecutorForMeta = this.deps.toolExecutor;
|
|
9573
|
+
const savedOnMeta = toolExecutorForMeta?.getContext?.()?.onMeta;
|
|
9574
|
+
if (toolExecutorForMeta?.setOnMeta) {
|
|
9575
|
+
toolExecutorForMeta.setOnMeta(onMeta);
|
|
9576
|
+
}
|
|
9518
9577
|
if (canRunInParallel(toolCalls)) {
|
|
9519
9578
|
const entries = await Promise.all(toolCalls.map(executeToolCall));
|
|
9520
9579
|
for (const entry of entries) {
|
|
@@ -9526,6 +9585,13 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
9526
9585
|
processToolResult(entry);
|
|
9527
9586
|
}
|
|
9528
9587
|
}
|
|
9588
|
+
if (toolExecutorForMeta?.setOnMeta) {
|
|
9589
|
+
toolExecutorForMeta.setOnMeta(savedOnMeta);
|
|
9590
|
+
}
|
|
9591
|
+
if (contextManager.needsCompaction()) {
|
|
9592
|
+
contextManager.compact();
|
|
9593
|
+
logger.debug("Context compacted after tool results");
|
|
9594
|
+
}
|
|
9529
9595
|
if (anyToolFailed) {
|
|
9530
9596
|
consecutiveToolFailures++;
|
|
9531
9597
|
} else {
|
|
@@ -10454,8 +10520,7 @@ var init_subagent = __esm(() => {
|
|
|
10454
10520
|
baseDir: ctx.baseDir,
|
|
10455
10521
|
scope,
|
|
10456
10522
|
toolTags,
|
|
10457
|
-
promptBlocks: [systemPrompt]
|
|
10458
|
-
recursionDepth: currentDepth + 1
|
|
10523
|
+
promptBlocks: [systemPrompt]
|
|
10459
10524
|
};
|
|
10460
10525
|
const subAgent = new Agent(subDeps);
|
|
10461
10526
|
const fullTask = context ? `${task}
|
|
@@ -25728,6 +25793,7 @@ init_colors();
|
|
|
25728
25793
|
init_colors();
|
|
25729
25794
|
init_i18n();
|
|
25730
25795
|
init_table();
|
|
25796
|
+
init_string_width();
|
|
25731
25797
|
var KW = /\b(import|export|from|const|let|var|function|return|if|else|for|while|do|switch|case|break|continue|new|class|extends|implements|interface|type|enum|namespace|module|declare|abstract|async|await|yield|throw|try|catch|finally|typeof|instanceof|in|of|as|is|keyof|readonly|static|private|public|protected|get|set|constructor|this|super|void|never|any|unknown|boolean|string|number|symbol|object|true|false|null|undefined|default)\b/g;
|
|
25732
25798
|
var STRING = /('[^']*'|"[^"]*"|`[^`]*`)/g;
|
|
25733
25799
|
var COMMENT = /(\/\/[^\n]*|\/\*[\s\S]*?\*\/|#[^\n]*)/g;
|
|
@@ -25776,9 +25842,13 @@ class FormattingStream {
|
|
|
25776
25842
|
tableBuffer = [];
|
|
25777
25843
|
onWrite;
|
|
25778
25844
|
width;
|
|
25779
|
-
|
|
25845
|
+
streaming;
|
|
25846
|
+
partialEmitted = false;
|
|
25847
|
+
lastPartial = "";
|
|
25848
|
+
constructor(onWrite, width, streaming = false) {
|
|
25780
25849
|
this.onWrite = onWrite;
|
|
25781
25850
|
this.width = width ?? getTerminalWidth();
|
|
25851
|
+
this.streaming = streaming;
|
|
25782
25852
|
}
|
|
25783
25853
|
write(chunk) {
|
|
25784
25854
|
this.buffer += chunk;
|
|
@@ -25787,10 +25857,13 @@ class FormattingStream {
|
|
|
25787
25857
|
`)) !== -1) {
|
|
25788
25858
|
const line = this.buffer.slice(0, idx);
|
|
25789
25859
|
this.buffer = this.buffer.slice(idx + 1);
|
|
25860
|
+
this.clearPartial();
|
|
25790
25861
|
this.processLine(line);
|
|
25791
25862
|
}
|
|
25863
|
+
this.emitPartial(this.buffer);
|
|
25792
25864
|
}
|
|
25793
25865
|
flush() {
|
|
25866
|
+
this.clearPartial();
|
|
25794
25867
|
if (this.inCodeBlock && this.codeLines.length > 0) {
|
|
25795
25868
|
this.emitCodeBlock();
|
|
25796
25869
|
}
|
|
@@ -25806,8 +25879,39 @@ class FormattingStream {
|
|
|
25806
25879
|
}
|
|
25807
25880
|
return;
|
|
25808
25881
|
}
|
|
25809
|
-
this.
|
|
25882
|
+
this.emitLine(this.formatLine(line));
|
|
25883
|
+
}
|
|
25884
|
+
}
|
|
25885
|
+
emitLine(text) {
|
|
25886
|
+
this.onWrite(text, true);
|
|
25887
|
+
}
|
|
25888
|
+
emitRaw(text) {
|
|
25889
|
+
this.onWrite(text, false);
|
|
25890
|
+
}
|
|
25891
|
+
clearPartial() {
|
|
25892
|
+
if (!this.streaming || !this.partialEmitted)
|
|
25893
|
+
return;
|
|
25894
|
+
const rows = Math.max(1, Math.ceil(stringWidth(this.lastPartial) / Math.max(1, this.width)));
|
|
25895
|
+
for (let i = 0;i < rows; i++) {
|
|
25896
|
+
this.emitRaw("\x1B[2K");
|
|
25897
|
+
if (i < rows - 1)
|
|
25898
|
+
this.emitRaw("\x1B[1A");
|
|
25899
|
+
}
|
|
25900
|
+
this.emitRaw("\r");
|
|
25901
|
+
this.lastPartial = "";
|
|
25902
|
+
this.partialEmitted = false;
|
|
25903
|
+
}
|
|
25904
|
+
emitPartial(text) {
|
|
25905
|
+
if (!this.streaming || !text)
|
|
25906
|
+
return;
|
|
25907
|
+
if (this.inCodeBlock || this.tableBuffer.length > 0) {
|
|
25908
|
+
this.clearPartial();
|
|
25909
|
+
return;
|
|
25810
25910
|
}
|
|
25911
|
+
this.clearPartial();
|
|
25912
|
+
this.emitRaw(text);
|
|
25913
|
+
this.lastPartial = text;
|
|
25914
|
+
this.partialEmitted = true;
|
|
25811
25915
|
}
|
|
25812
25916
|
processLine(line) {
|
|
25813
25917
|
if (line.trim() === "```" || line.trim().startsWith("```")) {
|
|
@@ -25831,7 +25935,7 @@ class FormattingStream {
|
|
|
25831
25935
|
if (this.tableBuffer.length > 0) {
|
|
25832
25936
|
this.flushTable();
|
|
25833
25937
|
}
|
|
25834
|
-
this.
|
|
25938
|
+
this.emitLine(this.formatLine(line));
|
|
25835
25939
|
}
|
|
25836
25940
|
flushTable() {
|
|
25837
25941
|
const lines = this.tableBuffer;
|
|
@@ -25839,11 +25943,11 @@ class FormattingStream {
|
|
|
25839
25943
|
const hasSeparator = lines.length >= 2 && /^\s*\|?[\s:|-]+\|?\s*$/.test(lines[1].trim());
|
|
25840
25944
|
if (hasSeparator) {
|
|
25841
25945
|
for (const l of formatTable(lines, { maxWidth: this.width })) {
|
|
25842
|
-
this.
|
|
25946
|
+
this.emitLine(l);
|
|
25843
25947
|
}
|
|
25844
25948
|
} else {
|
|
25845
25949
|
for (const l of lines) {
|
|
25846
|
-
this.
|
|
25950
|
+
this.emitLine(this.formatLine(l));
|
|
25847
25951
|
}
|
|
25848
25952
|
}
|
|
25849
25953
|
}
|
|
@@ -25855,12 +25959,12 @@ class FormattingStream {
|
|
|
25855
25959
|
const highlighted = highlight(code, this.codeLang);
|
|
25856
25960
|
const lang = this.codeLang ? ` ${this.codeLang} ` : " ";
|
|
25857
25961
|
const top = pc.dim(`┌─${lang}${"─".repeat(Math.max(0, this.width - 3 - lang.length))}┐`);
|
|
25858
|
-
this.
|
|
25962
|
+
this.emitLine(top);
|
|
25859
25963
|
for (const l of highlighted.split(`
|
|
25860
25964
|
`)) {
|
|
25861
|
-
this.
|
|
25965
|
+
this.emitLine(pc.dim("│ ") + l);
|
|
25862
25966
|
}
|
|
25863
|
-
this.
|
|
25967
|
+
this.emitLine(pc.dim(`└${"─".repeat(Math.max(0, this.width - 1))}┘`));
|
|
25864
25968
|
}
|
|
25865
25969
|
this.codeLines = [];
|
|
25866
25970
|
this.codeLang = "";
|
|
@@ -25972,8 +26076,8 @@ class Renderer {
|
|
|
25972
26076
|
stream: this.err,
|
|
25973
26077
|
width: this.width
|
|
25974
26078
|
});
|
|
25975
|
-
this.fmt = new FormattingStream((line) => this.out.write(`${line}
|
|
25976
|
-
`), this.width);
|
|
26079
|
+
this.fmt = new FormattingStream((line, eol) => this.out.write(eol ? `${line}
|
|
26080
|
+
` : line), this.width, this.rich);
|
|
25977
26081
|
}
|
|
25978
26082
|
text(chunk) {
|
|
25979
26083
|
this.endCard();
|
|
@@ -25982,6 +26086,7 @@ class Renderer {
|
|
|
25982
26086
|
}
|
|
25983
26087
|
meta(chunk) {
|
|
25984
26088
|
this.spinner.stop();
|
|
26089
|
+
this.fmt.clearPartial();
|
|
25985
26090
|
if (this.card) {
|
|
25986
26091
|
this.card.body.push(chunk);
|
|
25987
26092
|
} else {
|
|
@@ -25990,6 +26095,7 @@ class Renderer {
|
|
|
25990
26095
|
}
|
|
25991
26096
|
reasoning(chunk) {
|
|
25992
26097
|
this.spinner.stop();
|
|
26098
|
+
this.fmt.clearPartial();
|
|
25993
26099
|
this.out.write(pc.dim(chunk));
|
|
25994
26100
|
}
|
|
25995
26101
|
thinkingStart() {
|
|
@@ -26001,6 +26107,7 @@ class Renderer {
|
|
|
26001
26107
|
toolStart(tool, args) {
|
|
26002
26108
|
this.endCard();
|
|
26003
26109
|
this.spinner.stop();
|
|
26110
|
+
this.fmt.clearPartial();
|
|
26004
26111
|
const summary = summarizeArgs2(args);
|
|
26005
26112
|
if (!this.rich) {
|
|
26006
26113
|
this.out.write(`
|
|
@@ -26052,11 +26159,13 @@ ${pc.dim("⚙")} ${friendlyTool(tool)}${summary ? ` ${pc.dim(summary)}` : ""}
|
|
|
26052
26159
|
raw(text) {
|
|
26053
26160
|
this.endCard();
|
|
26054
26161
|
this.spinner.stop();
|
|
26162
|
+
this.fmt.clearPartial();
|
|
26055
26163
|
this.out.write(text);
|
|
26056
26164
|
}
|
|
26057
26165
|
error(text) {
|
|
26058
26166
|
this.endCard();
|
|
26059
26167
|
this.spinner.stop();
|
|
26168
|
+
this.fmt.clearPartial();
|
|
26060
26169
|
this.err.write(`${pc.red(text)}
|
|
26061
26170
|
`);
|
|
26062
26171
|
}
|