@cydm/pie 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/dist/builtin/extensions/ask-user/index.js +1 -1
- package/dist/builtin/extensions/computer-use/index.js +4015 -108
- package/dist/builtin/extensions/mcp-adapter/index.js +58 -13
- package/dist/builtin/extensions/plan-mode/index.js +1 -1
- package/dist/builtin/extensions/subagent/index.js +2 -2
- package/dist/builtin/extensions/todo/index.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/LICENSE +21 -0
- package/dist/builtin/skills/chrome-devtools-axi/SKILL.md +20 -1
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +20034 -0
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-cli.js +8 -2
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +26 -0
- package/dist/builtin/skills/chrome-devtools-axi/chunk-42SGITKJ.js +11 -0
- package/dist/builtin/skills/chrome-devtools-axi/chunk-OJ6N23UZ.js +47 -0
- package/dist/builtin/skills/chrome-devtools-axi/chunk-UPATXALW.js +215 -0
- package/dist/builtin/skills/chrome-devtools-axi/cli-F2VCSVL4.js +4424 -0
- package/dist/builtin/skills/skill-creator/SKILL.md +5 -2
- package/dist/builtin/skills/skill-creator/eval-viewer/generate_review.mjs +7 -20
- package/dist/builtin/skills/skill-creator/eval-viewer/viewer.html +15 -15
- package/dist/builtin/skills/skill-creator/scripts/aggregate_benchmark.mjs +20 -19
- package/dist/builtin/skills/skill-creator/scripts/generate_report.mjs +3 -3
- package/dist/builtin/skills/skill-creator/scripts/improve_description.mjs +12 -8
- package/dist/builtin/skills/skill-creator/scripts/package_skill.mjs +1 -0
- package/dist/builtin/skills/skill-creator/scripts/pie_runner.mjs +77 -31
- package/dist/builtin/skills/skill-creator/scripts/run_eval.mjs +38 -11
- package/dist/builtin/skills/skill-creator/scripts/run_loop.mjs +12 -6
- package/dist/builtin/skills/skill-creator/scripts/skill_metadata.mjs +12 -1
- package/dist/builtin/skills/tui-use/LICENSE +21 -0
- package/dist/builtin/skills/tui-use/README.md +13 -3
- package/dist/builtin/skills/tui-use/SKILL.md +87 -39
- package/dist/builtin/skills/tui-use/tui-use-cli.cjs +10626 -0
- package/dist/builtin/skills/tui-use/tui-use-cli.js +39 -0
- package/dist/builtin/skills/tui-use/tui-use-daemon.cjs +7929 -0
- package/dist/chunks/{chunk-G2POWIA5.js → chunk-G3SE3I2L.js} +64 -16
- package/dist/chunks/{chunk-PMPD56N2.js → chunk-HH2Q2SNX.js} +85 -26
- package/dist/cli.js +7558 -112
- package/package.json +26 -18
- package/scripts/repair-node-pty.mjs +45 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
+
getBuiltinDir,
|
|
3
4
|
getConfigDir
|
|
4
5
|
} from "./chunk-5353DEEC.js";
|
|
5
6
|
import {
|
|
@@ -11,7 +12,7 @@ import {
|
|
|
11
12
|
createSharedWebSearchTool,
|
|
12
13
|
interpretShellExit,
|
|
13
14
|
requestInteraction
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-HH2Q2SNX.js";
|
|
15
16
|
import {
|
|
16
17
|
Type
|
|
17
18
|
} from "./chunk-XXGYUYXI.js";
|
|
@@ -163,6 +164,7 @@ var bashSchema = Type.Object({
|
|
|
163
164
|
});
|
|
164
165
|
var DEFAULT_TIMEOUT_SECONDS = 120;
|
|
165
166
|
var MAX_GENERIC_TIMEOUT_SECONDS = 120;
|
|
167
|
+
var OUTPUT_DRAIN_TIMEOUT_MS = 1e3;
|
|
166
168
|
function resolveTimeoutPolicy(requestedTimeout, commandClass) {
|
|
167
169
|
const requestedSeconds = requestedTimeout ?? DEFAULT_TIMEOUT_SECONDS;
|
|
168
170
|
if (requestedSeconds > MAX_GENERIC_TIMEOUT_SECONDS && commandClass !== "package_manager" && commandClass !== "test_or_build") {
|
|
@@ -192,12 +194,15 @@ function validateBashCommand(command) {
|
|
|
192
194
|
throw new Error("Invalid bash command. The command argument must be only a real shell command, not tool-call markup.");
|
|
193
195
|
}
|
|
194
196
|
}
|
|
195
|
-
function buildEffectiveCommand(command, options) {
|
|
197
|
+
function buildEffectiveCommand(command, options, shell) {
|
|
196
198
|
const prefix = options?.commandPrefix?.trim();
|
|
197
199
|
if (!prefix) {
|
|
198
200
|
return command;
|
|
199
201
|
}
|
|
200
202
|
validateBashCommand(prefix);
|
|
203
|
+
if (shell === "powershell") {
|
|
204
|
+
return `& { ${prefix} }; if (-not $?) { exit 1 }; ${command}`;
|
|
205
|
+
}
|
|
201
206
|
return `${prefix} && ${command}`;
|
|
202
207
|
}
|
|
203
208
|
function resolveShell(shell) {
|
|
@@ -208,7 +213,8 @@ function resolveShell(shell) {
|
|
|
208
213
|
}
|
|
209
214
|
function buildSpawnCommand(shell, command) {
|
|
210
215
|
if (shell === "powershell") {
|
|
211
|
-
|
|
216
|
+
const utf8Command = `[Console]::OutputEncoding = New-Object System.Text.UTF8Encoding; $OutputEncoding = [Console]::OutputEncoding; ${command}`;
|
|
217
|
+
return { file: process.platform === "win32" ? "powershell.exe" : "pwsh", args: ["-NoProfile", "-NonInteractive", "-Command", utf8Command], shell: false };
|
|
212
218
|
}
|
|
213
219
|
if (shell === "cmd") {
|
|
214
220
|
return { file: "cmd.exe", args: ["/d", "/s", "/c", command], shell: false };
|
|
@@ -314,7 +320,11 @@ function finishTempFileStream(stream) {
|
|
|
314
320
|
if (!stream || stream.closed) return Promise.resolve();
|
|
315
321
|
return new Promise((resolve2, reject) => {
|
|
316
322
|
let done = false;
|
|
323
|
+
const timer = setTimeout(() => {
|
|
324
|
+
stream.destroy(new Error("Timed out flushing shell output."));
|
|
325
|
+
}, OUTPUT_DRAIN_TIMEOUT_MS);
|
|
317
326
|
const cleanup = () => {
|
|
327
|
+
clearTimeout(timer);
|
|
318
328
|
stream.off("close", onClose);
|
|
319
329
|
stream.off("error", onError);
|
|
320
330
|
};
|
|
@@ -347,7 +357,7 @@ function buildBashRecoveryHint(command, output) {
|
|
|
347
357
|
if (/\bnpm ERR!|\bnpm error\b/i.test(output) && /\b(?:ECONNRESET|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|fetch failed|socket hang up|registry|proxy)\b/i.test(output)) {
|
|
348
358
|
return "npm could not reach the registry. Treat this as an environment/network/proxy issue, not a source-code failure; retry npm install/npm ci when network is available or check npm proxy/registry settings.";
|
|
349
359
|
}
|
|
350
|
-
if (/\bnpm\s+run\b/.test(command) && (/(?:^|\n)\s*(?:sh|bash|zsh):\s+[\w@./-]+:\s+command not found\b/i.test(output) || /(?:^|\r?\n)\s*'[^']+'\s+is not recognized as an internal or external command\b/i.test(output))) {
|
|
360
|
+
if (/\bnpm\s+run\b/.test(command) && (/(?:^|\n)\s*(?:sh|bash|zsh):\s+[\w@./-]+:\s+command not found\b/i.test(output) || /(?:^|\r?\n)\s*'[^']+'\s+is not recognized as an internal or external command\b/i.test(output) || /\u4e0d\u662f\u5185\u90e8\u6216\u5916\u90e8\u547d\u4ee4/.test(output))) {
|
|
351
361
|
return "This npm script could not find a local executable. Check whether dependencies were installed successfully in cwd, whether node_modules exists, and whether a prior npm install/npm ci failed before treating this as a code failure.";
|
|
352
362
|
}
|
|
353
363
|
return void 0;
|
|
@@ -396,8 +406,9 @@ function killProcessTree(pid) {
|
|
|
396
406
|
try {
|
|
397
407
|
spawn("taskkill", ["/F", "/T", "/PID", String(pid)], {
|
|
398
408
|
stdio: "ignore",
|
|
399
|
-
|
|
400
|
-
})
|
|
409
|
+
windowsHide: true
|
|
410
|
+
}).on("error", () => {
|
|
411
|
+
}).unref();
|
|
401
412
|
} catch {
|
|
402
413
|
}
|
|
403
414
|
} else {
|
|
@@ -432,7 +443,7 @@ function createBashTool(defaultCwd, options) {
|
|
|
432
443
|
execute: async (_toolCallId, { command, timeout, cwd, shell }, signal, onUpdate) => {
|
|
433
444
|
validateBashCommand(command);
|
|
434
445
|
const resolvedShell = resolveShell(shell);
|
|
435
|
-
const effectiveCommand = buildEffectiveCommand(command, options);
|
|
446
|
+
const effectiveCommand = buildEffectiveCommand(command, options, resolvedShell);
|
|
436
447
|
const workingDir = normalizeWorkingDirectory(cwd, defaultCwd);
|
|
437
448
|
validateWorkingDirectory(workingDir);
|
|
438
449
|
const risk = classifyShellCommand(effectiveCommand, resolvedShell, {
|
|
@@ -495,25 +506,42 @@ function createBashTool(defaultCwd, options) {
|
|
|
495
506
|
headBytes += prefix.length;
|
|
496
507
|
};
|
|
497
508
|
let timedOut = false;
|
|
509
|
+
let processExited = false;
|
|
510
|
+
let exitCode = null;
|
|
511
|
+
let exitSignal = null;
|
|
512
|
+
let drainTimer;
|
|
498
513
|
const spawnCommand = buildSpawnCommand(resolvedShell, effectiveCommand);
|
|
499
514
|
const child = (options?.spawnProcess ?? spawn)(spawnCommand.file, spawnCommand.args, {
|
|
500
515
|
shell: spawnCommand.shell,
|
|
501
516
|
cwd: workingDir,
|
|
502
517
|
env: process.env,
|
|
503
|
-
detached: process.platform !== "win32"
|
|
518
|
+
detached: process.platform !== "win32",
|
|
519
|
+
windowsHide: true
|
|
504
520
|
});
|
|
521
|
+
const closePipes = () => {
|
|
522
|
+
child.stdin?.destroy();
|
|
523
|
+
child.stdout?.destroy();
|
|
524
|
+
child.stderr?.destroy();
|
|
525
|
+
};
|
|
505
526
|
const timeoutId = setTimeout(() => {
|
|
527
|
+
if (settled) return;
|
|
506
528
|
timedOut = true;
|
|
507
|
-
if (child.pid) {
|
|
529
|
+
if (child.pid && !processExited) {
|
|
508
530
|
killProcessTree(child.pid);
|
|
509
531
|
}
|
|
532
|
+
closePipes();
|
|
533
|
+
child.unref?.();
|
|
534
|
+
void finishExecution(exitCode, exitSignal, true);
|
|
510
535
|
}, timeoutMs);
|
|
511
536
|
const failExecution = (error) => {
|
|
512
537
|
if (settled) return;
|
|
513
538
|
settled = true;
|
|
514
539
|
clearTimeout(timeoutId);
|
|
540
|
+
if (drainTimer) clearTimeout(drainTimer);
|
|
515
541
|
signal?.removeEventListener("abort", onAbort);
|
|
516
|
-
if (child.pid) killProcessTree(child.pid);
|
|
542
|
+
if (child.pid && !processExited) killProcessTree(child.pid);
|
|
543
|
+
closePipes();
|
|
544
|
+
child.unref?.();
|
|
517
545
|
discardOutputArtifact(tempFilePath, tempFileStream);
|
|
518
546
|
reject(error);
|
|
519
547
|
};
|
|
@@ -605,11 +633,13 @@ function createBashTool(defaultCwd, options) {
|
|
|
605
633
|
chunksBytes -= removed.length;
|
|
606
634
|
}
|
|
607
635
|
});
|
|
608
|
-
|
|
636
|
+
const finishExecution = async (code, sig, stdioIncomplete = false) => {
|
|
637
|
+
if (settled) return;
|
|
638
|
+
settled = true;
|
|
609
639
|
try {
|
|
610
640
|
clearTimeout(timeoutId);
|
|
641
|
+
if (drainTimer) clearTimeout(drainTimer);
|
|
611
642
|
signal?.removeEventListener("abort", onAbort);
|
|
612
|
-
if (settled) return;
|
|
613
643
|
const fullBuffer = Buffer.concat(chunks);
|
|
614
644
|
let fullOutput = fullBuffer.toString("utf-8");
|
|
615
645
|
if (totalBytes > fullBuffer.length) {
|
|
@@ -641,6 +671,7 @@ ${fullOutput}`;
|
|
|
641
671
|
exitCode: code,
|
|
642
672
|
signal: sig?.toString() ?? null,
|
|
643
673
|
timedOut,
|
|
674
|
+
...stdioIncomplete ? { stdioIncomplete: true } : {},
|
|
644
675
|
shell: resolvedShell,
|
|
645
676
|
commandClass: risk.commandClass,
|
|
646
677
|
riskWarnings: risk.riskWarnings,
|
|
@@ -696,6 +727,9 @@ ${commandNonzeroHint}`;
|
|
|
696
727
|
[Command timed out after ${timeoutPolicy.effectiveSeconds} seconds]`;
|
|
697
728
|
outputText += "\n[Timeout hint: split custom searches or service polls into smaller bounded steps with progress output, inspect partial results/logs, then make a decision. Avoid repeating long waits. Reserve long timeouts for installs, builds, and tests.]";
|
|
698
729
|
}
|
|
730
|
+
if (stdioIncomplete && !timedOut) {
|
|
731
|
+
outputText += "\n\n[Output capture ended after the command exited because a descendant kept stdio open. Captured output may be incomplete.]";
|
|
732
|
+
}
|
|
699
733
|
if (timeoutPolicy.capped) {
|
|
700
734
|
outputText += `
|
|
701
735
|
|
|
@@ -716,13 +750,26 @@ ${commandNonzeroHint}`;
|
|
|
716
750
|
outputText += "\n\n[Repeat hint: this exact command already returned the same result in this session. If it proves the task, stop; otherwise change the command or inspect a different file/range.]";
|
|
717
751
|
}
|
|
718
752
|
const content = [{ type: "text", text: outputText }];
|
|
719
|
-
settled = true;
|
|
720
753
|
resolve2({ content, details, isError: outcome.toolFailure });
|
|
721
754
|
} catch (error) {
|
|
722
755
|
discardOutputArtifact(tempFilePath, tempFileStream);
|
|
723
|
-
settled = true;
|
|
724
756
|
reject(error);
|
|
725
757
|
}
|
|
758
|
+
};
|
|
759
|
+
child.on("exit", (code, sig) => {
|
|
760
|
+
processExited = true;
|
|
761
|
+
exitCode = code;
|
|
762
|
+
exitSignal = sig;
|
|
763
|
+
if (settled) return;
|
|
764
|
+
drainTimer = setTimeout(() => {
|
|
765
|
+
closePipes();
|
|
766
|
+
child.unref?.();
|
|
767
|
+
void finishExecution(code, sig, true);
|
|
768
|
+
}, OUTPUT_DRAIN_TIMEOUT_MS);
|
|
769
|
+
});
|
|
770
|
+
child.on("close", (code, sig) => {
|
|
771
|
+
processExited = true;
|
|
772
|
+
void finishExecution(code, sig);
|
|
726
773
|
});
|
|
727
774
|
child.on("error", (err) => {
|
|
728
775
|
failExecution(new Error(`Failed to start bash command in ${workingDir}: ${err.message}. Check that the command is executable and cwd exists.`));
|
|
@@ -912,8 +959,9 @@ import * as os from "node:os";
|
|
|
912
959
|
import * as path2 from "node:path";
|
|
913
960
|
var require2 = createRequire(import.meta.url);
|
|
914
961
|
function resolveAxiCli() {
|
|
915
|
-
const
|
|
916
|
-
|
|
962
|
+
const runtime = path2.join(getBuiltinDir(), "skills", "chrome-devtools-axi", "chrome-devtools-axi-runtime.js");
|
|
963
|
+
if (!fs2.existsSync(runtime)) throw new Error("Pie's packaged browser runtime is missing. Rebuild or reinstall Pie.");
|
|
964
|
+
return runtime;
|
|
917
965
|
}
|
|
918
966
|
function resolveMcpScript() {
|
|
919
967
|
const packageJson = require2.resolve("chrome-devtools-mcp/package.json");
|
|
@@ -4856,7 +4856,7 @@ var AgentSessionRetryController = class {
|
|
|
4856
4856
|
}
|
|
4857
4857
|
return;
|
|
4858
4858
|
}
|
|
4859
|
-
const maxRetries = this.retry.maxRetries ?? 3;
|
|
4859
|
+
const maxRetries = this.retry.maxRetriesForFailure?.(failure) ?? this.retry.maxRetries ?? 3;
|
|
4860
4860
|
this.retryAttempt += 1;
|
|
4861
4861
|
if (this.retryAttempt > maxRetries) {
|
|
4862
4862
|
const terminalFailure = asTerminalFailure(failure);
|
|
@@ -4869,7 +4869,8 @@ var AgentSessionRetryController = class {
|
|
|
4869
4869
|
return;
|
|
4870
4870
|
}
|
|
4871
4871
|
const attempt = this.retryAttempt;
|
|
4872
|
-
const
|
|
4872
|
+
const rawDelayMs = (this.retry.baseDelayMs ?? 2e3) * 2 ** (attempt - 1);
|
|
4873
|
+
const delayMs = this.retry.maxDelayMs !== void 0 ? Math.min(rawDelayMs, this.retry.maxDelayMs) : rawDelayMs;
|
|
4873
4874
|
this.ensurePending();
|
|
4874
4875
|
this.setRecoveryState("retry_pending");
|
|
4875
4876
|
this.emit({ type: "turn_recovery_pending", recovery: "retry", failure, attempt, maxRetries, delayMs });
|
|
@@ -6000,6 +6001,47 @@ function setExtensionEnabledInSettings(settingsObject, identity, enabled) {
|
|
|
6000
6001
|
return setEnablementInMap(settingsObject, "extensions", identity, enabled);
|
|
6001
6002
|
}
|
|
6002
6003
|
|
|
6004
|
+
// ../../packages/agent-framework/src/extensions/resources.ts
|
|
6005
|
+
var ExtensionResourceScope = class {
|
|
6006
|
+
handlers = /* @__PURE__ */ new Set();
|
|
6007
|
+
disposal;
|
|
6008
|
+
closed = false;
|
|
6009
|
+
register(handler) {
|
|
6010
|
+
if (this.closed) throw new Error("Extension resources are already closing.");
|
|
6011
|
+
this.handlers.add(handler);
|
|
6012
|
+
return () => {
|
|
6013
|
+
this.handlers.delete(handler);
|
|
6014
|
+
};
|
|
6015
|
+
}
|
|
6016
|
+
dispose(reason = "shutdown", timeoutMs = 7500) {
|
|
6017
|
+
if (this.disposal) return this.disposal;
|
|
6018
|
+
this.closed = true;
|
|
6019
|
+
const handlers = [...this.handlers].reverse();
|
|
6020
|
+
this.handlers.clear();
|
|
6021
|
+
const controller = new AbortController();
|
|
6022
|
+
this.disposal = (async () => {
|
|
6023
|
+
let timer;
|
|
6024
|
+
try {
|
|
6025
|
+
const results = await Promise.race([
|
|
6026
|
+
Promise.allSettled(handlers.map((handler) => Promise.resolve().then(() => handler(reason, controller.signal)))),
|
|
6027
|
+
new Promise((_, reject) => {
|
|
6028
|
+
timer = setTimeout(() => {
|
|
6029
|
+
controller.abort();
|
|
6030
|
+
reject(new Error(`Extension cleanup exceeded ${timeoutMs}ms.`));
|
|
6031
|
+
}, timeoutMs);
|
|
6032
|
+
})
|
|
6033
|
+
]);
|
|
6034
|
+
const errors = results.filter((result) => result.status === "rejected").map((result) => result.reason);
|
|
6035
|
+
if (errors.length) throw new AggregateError(errors, "Extension resource cleanup failed.");
|
|
6036
|
+
} finally {
|
|
6037
|
+
clearTimeout(timer);
|
|
6038
|
+
controller.abort();
|
|
6039
|
+
}
|
|
6040
|
+
})();
|
|
6041
|
+
return this.disposal;
|
|
6042
|
+
}
|
|
6043
|
+
};
|
|
6044
|
+
|
|
6003
6045
|
// ../../packages/agent-framework/src/interaction.ts
|
|
6004
6046
|
var InteractionUnavailableError = class extends Error {
|
|
6005
6047
|
request;
|
|
@@ -8832,6 +8874,8 @@ var commaPattern = /\\,/g;
|
|
|
8832
8874
|
var periodPattern = /\\\./g;
|
|
8833
8875
|
var EXPANSION_MAX = 1e5;
|
|
8834
8876
|
var EXPANSION_MAX_LENGTH = 4e6;
|
|
8877
|
+
var EXPANSION_MAX_DEPTH = 1e3;
|
|
8878
|
+
var EXPANSION_MAX_REWRITES = 1e3;
|
|
8835
8879
|
function numeric(str) {
|
|
8836
8880
|
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
|
8837
8881
|
}
|
|
@@ -8841,36 +8885,44 @@ function escapeBraces(str) {
|
|
|
8841
8885
|
function unescapeBraces(str) {
|
|
8842
8886
|
return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
|
|
8843
8887
|
}
|
|
8844
|
-
function
|
|
8845
|
-
|
|
8846
|
-
|
|
8888
|
+
function pushAll(target, items) {
|
|
8889
|
+
for (let i = 0; i < items.length; i++) {
|
|
8890
|
+
target.push(items[i]);
|
|
8847
8891
|
}
|
|
8892
|
+
}
|
|
8893
|
+
function parseCommaParts(str) {
|
|
8848
8894
|
const parts = [];
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
;
|
|
8859
|
-
p
|
|
8860
|
-
p
|
|
8861
|
-
|
|
8862
|
-
|
|
8863
|
-
|
|
8895
|
+
let carry = "";
|
|
8896
|
+
for (; ; ) {
|
|
8897
|
+
const m = balanced("{", "}", str);
|
|
8898
|
+
if (!m) {
|
|
8899
|
+
const tail = str.split(",");
|
|
8900
|
+
tail[0] = carry + tail[0];
|
|
8901
|
+
pushAll(parts, tail);
|
|
8902
|
+
return parts;
|
|
8903
|
+
}
|
|
8904
|
+
const { pre, body, post } = m;
|
|
8905
|
+
const p = pre.split(",");
|
|
8906
|
+
p[0] = carry + p[0];
|
|
8907
|
+
p[p.length - 1] += "{" + body + "}";
|
|
8908
|
+
if (!post.length) {
|
|
8909
|
+
pushAll(parts, p);
|
|
8910
|
+
return parts;
|
|
8911
|
+
}
|
|
8912
|
+
carry = p.pop();
|
|
8913
|
+
pushAll(parts, p);
|
|
8914
|
+
str = post;
|
|
8915
|
+
}
|
|
8864
8916
|
}
|
|
8865
8917
|
function expand(str, options = {}) {
|
|
8866
8918
|
if (!str) {
|
|
8867
8919
|
return [];
|
|
8868
8920
|
}
|
|
8869
|
-
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH } = options;
|
|
8921
|
+
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH, maxDepth = EXPANSION_MAX_DEPTH, maxRewrites = EXPANSION_MAX_REWRITES } = options;
|
|
8870
8922
|
if (str.slice(0, 2) === "{}") {
|
|
8871
8923
|
str = "\\{\\}" + str.slice(2);
|
|
8872
8924
|
}
|
|
8873
|
-
return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
|
8925
|
+
return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
|
8874
8926
|
}
|
|
8875
8927
|
function embrace(str) {
|
|
8876
8928
|
return "{" + str + "}";
|
|
@@ -8948,8 +9000,12 @@ function expandSequence(body, isAlphaSequence, max, maxLength) {
|
|
|
8948
9000
|
}
|
|
8949
9001
|
return N;
|
|
8950
9002
|
}
|
|
8951
|
-
function expand_(str, max, maxLength, isTop) {
|
|
9003
|
+
function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|
9004
|
+
if (depth > maxDepth) {
|
|
9005
|
+
return [str];
|
|
9006
|
+
}
|
|
8952
9007
|
let acc = [""];
|
|
9008
|
+
let rewrites = 0;
|
|
8953
9009
|
let dropEmpties = false;
|
|
8954
9010
|
let firstGroup = true;
|
|
8955
9011
|
for (; ; ) {
|
|
@@ -8971,7 +9027,8 @@ function expand_(str, max, maxLength, isTop) {
|
|
|
8971
9027
|
const isSequence = isNumericSequence || isAlphaSequence;
|
|
8972
9028
|
const isOptions = m.body.indexOf(",") >= 0;
|
|
8973
9029
|
if (!isSequence && !isOptions) {
|
|
8974
|
-
if (m.post.match(/,(?!,).*\}/)) {
|
|
9030
|
+
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
|
9031
|
+
rewrites++;
|
|
8975
9032
|
str = m.pre + "{" + m.body + escClose + m.post;
|
|
8976
9033
|
isTop = true;
|
|
8977
9034
|
continue;
|
|
@@ -8988,7 +9045,7 @@ function expand_(str, max, maxLength, isTop) {
|
|
|
8988
9045
|
} else {
|
|
8989
9046
|
let n = parseCommaParts(m.body);
|
|
8990
9047
|
if (n.length === 1 && n[0] !== void 0) {
|
|
8991
|
-
n = expand_(n[0], max, maxLength, false).map(embrace);
|
|
9048
|
+
n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
|
|
8992
9049
|
if (n.length === 1) {
|
|
8993
9050
|
acc = combine(acc, pre + n[0], [""], max, maxLength, dropEmpties && !m.post.length);
|
|
8994
9051
|
if (!m.post.length)
|
|
@@ -9006,7 +9063,7 @@ function expand_(str, max, maxLength, isTop) {
|
|
|
9006
9063
|
values = [];
|
|
9007
9064
|
let valuesLength = 0;
|
|
9008
9065
|
outer: for (let j = 0; j < n.length; j++) {
|
|
9009
|
-
const expanded = expand_(n[j], max, maxLength, false);
|
|
9066
|
+
const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false);
|
|
9010
9067
|
for (let k = 0; k < expanded.length; k++) {
|
|
9011
9068
|
const v = expanded[k];
|
|
9012
9069
|
if (dropsEmpties && !v)
|
|
@@ -15287,6 +15344,7 @@ export {
|
|
|
15287
15344
|
calculateTotalTokens,
|
|
15288
15345
|
estimateContextTokens,
|
|
15289
15346
|
getAutoCompactTokenLimit,
|
|
15347
|
+
isCompactSummaryMessage,
|
|
15290
15348
|
findFirstKeptEntryId,
|
|
15291
15349
|
createCompactionSummary,
|
|
15292
15350
|
generateEntryId,
|
|
@@ -15300,6 +15358,7 @@ export {
|
|
|
15300
15358
|
extractExtensionSettings,
|
|
15301
15359
|
setEnablementInMap,
|
|
15302
15360
|
setExtensionEnabledInSettings,
|
|
15361
|
+
ExtensionResourceScope,
|
|
15303
15362
|
registerInteractionHandler,
|
|
15304
15363
|
hasInteractionHandler,
|
|
15305
15364
|
requestInteraction,
|