@swifty.js/swifty 0.0.37 → 0.0.38
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/{acp-R22FJPVN.js → acp-K6UNT7R2.js} +1 -1
- package/dist/{agent-WOWGQDBG.js → agent-TVRVBK2C.js} +1 -1
- package/dist/{chunk-LW273HD5.js → chunk-AN6IJDRD.js} +1 -1
- package/dist/{chunk-S2VEXEVV.js → chunk-CJZX34IA.js} +1 -1
- package/dist/{chunk-ENZ5LHRN.js → chunk-CTLUJRU3.js} +2 -2
- package/dist/{chunk-R62BGTT4.js → chunk-FITQ5CCD.js} +2 -2
- package/dist/{chunk-FOPUR6OB.js → chunk-Z4QZQ7X6.js} +14 -17
- package/dist/lib/{agent-ZSFK66FQ.js → agent-N64HDJ3J.js} +2 -2
- package/dist/lib/{chunk-O35GIE35.js → chunk-5QBKDZYN.js} +1 -1
- package/dist/lib/{chunk-5OJV33Y2.js → chunk-FPULYNJL.js} +2 -3
- package/dist/lib/{chunk-GWZDEU27.js → chunk-OM7DYLTN.js} +0 -1
- package/dist/lib/index.d.ts +10 -82
- package/dist/lib/index.js +52 -429
- package/dist/lib/{providers-WQ3UOLMF.js → providers-YRULZPXI.js} +1 -1
- package/dist/lib/{tool-filter-S3ZZOXFD.js → tool-filter-UULMJRDQ.js} +1 -1
- package/dist/main.js +153 -201
- package/dist/{providers-NWLGMQOZ.js → providers-6YCHQM6N.js} +1 -1
- package/dist/{server-TINTK5DM.js → server-OHPTZAGM.js} +1 -1
- package/dist/{tool-filter-QETBQPHL.js → tool-filter-NRC4U62K.js} +1 -1
- package/package.json +1 -2
package/dist/lib/index.js
CHANGED
|
@@ -29,7 +29,6 @@ import {
|
|
|
29
29
|
loadSession,
|
|
30
30
|
maybeResizeAndDownsampleImage,
|
|
31
31
|
newSessionId,
|
|
32
|
-
persistLargeResult,
|
|
33
32
|
plan_file_exports,
|
|
34
33
|
plan_mode_exports,
|
|
35
34
|
prompts_exports,
|
|
@@ -43,11 +42,11 @@ import {
|
|
|
43
42
|
spillDir,
|
|
44
43
|
telemetry_exports,
|
|
45
44
|
tool_result_exports
|
|
46
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-FPULYNJL.js";
|
|
47
46
|
import {
|
|
48
47
|
version,
|
|
49
48
|
version_exports
|
|
50
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-5QBKDZYN.js";
|
|
51
50
|
import {
|
|
52
51
|
anthropic_exports,
|
|
53
52
|
decideAndApply,
|
|
@@ -117,7 +116,7 @@ import {
|
|
|
117
116
|
filterToolsForAgent,
|
|
118
117
|
registry_exports,
|
|
119
118
|
tool_filter_exports
|
|
120
|
-
} from "./chunk-
|
|
119
|
+
} from "./chunk-OM7DYLTN.js";
|
|
121
120
|
import {
|
|
122
121
|
bwrap_exports
|
|
123
122
|
} from "./chunk-YIWNQ7OA.js";
|
|
@@ -1936,8 +1935,6 @@ __export(descriptions_exports, {
|
|
|
1936
1935
|
EDIT_FILE_DESCRIPTION: () => EDIT_FILE_DESCRIPTION,
|
|
1937
1936
|
GLOB_DESCRIPTION: () => GLOB_DESCRIPTION,
|
|
1938
1937
|
GREP_DESCRIPTION: () => GREP_DESCRIPTION,
|
|
1939
|
-
JAVASCRIPT_BACKGROUND_DESCRIPTION: () => JAVASCRIPT_BACKGROUND_DESCRIPTION,
|
|
1940
|
-
JAVASCRIPT_DESCRIPTION: () => JAVASCRIPT_DESCRIPTION,
|
|
1941
1938
|
POWERSHELL_BACKGROUND_DESCRIPTION: () => POWERSHELL_BACKGROUND_DESCRIPTION,
|
|
1942
1939
|
POWERSHELL_DESCRIPTION: () => POWERSHELL_DESCRIPTION,
|
|
1943
1940
|
READ_FILE_DESCRIPTION: () => READ_FILE_DESCRIPTION,
|
|
@@ -1957,11 +1954,6 @@ var POWERSHELL_DESCRIPTION = `Execute command in PowerShell; return stdout and s
|
|
|
1957
1954
|
- Prefer dedicated file/search tools over Get-Content, Select-String, or Write-Output. Scope recursion to a directory, not a drive root. Diagnose failures rather than retrying in Start-Sleep loops.
|
|
1958
1955
|
${GIT_GUIDANCE}`;
|
|
1959
1956
|
var POWERSHELL_BACKGROUND_DESCRIPTION = `- Set run_in_background to true to run the command in the background. The call returns a task ID immediately and the result arrives later as a task notification; do not poll or Start-Sleep waiting for it. Use this for long-running commands you do not need the result of right away. Use TaskStop with the task_id to kill a background command early. A foreground command that exceeds its timeout is moved to the background automatically instead of being killed, unless it is a bare Start-Sleep.`;
|
|
1960
|
-
var JAVASCRIPT_DESCRIPTION = `Execute JavaScript in a fresh isolated V8 context for pure computation.
|
|
1961
|
-
- Provide a function body and use return to produce a JSON-compatible result. Optional input is available as globalThis.input.
|
|
1962
|
-
- No filesystem, network, process, require, imports, timers, or host callbacks are available. Use Bash for Node.js or system operations.
|
|
1963
|
-
- timeout_ms defaults to 1000 (max 10000); memory_limit_mb defaults to 64 (max 256). Requires Node.js 24 or newer.`;
|
|
1964
|
-
var JAVASCRIPT_BACKGROUND_DESCRIPTION = `- Set run_in_background to true to evaluate in the background. The call returns a task ID immediately and the result arrives later as a task notification; do not poll. timeout_ms still caps the evaluation (max 10000). Use TaskStop with the task_id to abort it early.`;
|
|
1965
1957
|
var READ_FILE_DESCRIPTION = `Read text with 1-based display line numbers, or images (png, jpg, jpeg, gif, webp) as visual content; not directories.
|
|
1966
1958
|
- file_path is absolute or relative to the Agent's working directory. offset skips lines (0-based, default 0); limit defaults to 2000 lines, with a 50KB text output cap. Displayed line 101 starts at offset=100. Follow continuation/readback instructions for partial output.
|
|
1967
1959
|
- Images ignore offset/limit. A successful read refreshes the file-state cache used by EditFile/WriteFile; re-read after an external-change error.`;
|
|
@@ -4660,7 +4652,7 @@ var TaskManager = class {
|
|
|
4660
4652
|
}
|
|
4661
4653
|
/**
|
|
4662
4654
|
* Wait for tasks to settle. An optional filter selects which tasks to wait
|
|
4663
|
-
* for (e.g. print-mode waits only for agent-kind tasks: shell
|
|
4655
|
+
* for (e.g. print-mode waits only for agent-kind tasks: shell tasks may
|
|
4664
4656
|
* run indefinitely and are stopped, not awaited, at exit).
|
|
4665
4657
|
*/
|
|
4666
4658
|
async waitAll(filter) {
|
|
@@ -6166,7 +6158,7 @@ ${prompt}`;
|
|
|
6166
6158
|
permissionChecker: ctx.permissionChecker?.forWorkDir(worktree.path)
|
|
6167
6159
|
};
|
|
6168
6160
|
}
|
|
6169
|
-
const { cloneRegistryForFork } = await import("./tool-filter-
|
|
6161
|
+
const { cloneRegistryForFork } = await import("./tool-filter-UULMJRDQ.js");
|
|
6170
6162
|
const forkedRegistry = cloneRegistryForFork(this.registry);
|
|
6171
6163
|
const snapshot = conversationSnapshot ?? this.conversation.fork();
|
|
6172
6164
|
const output = await this.forkHandler(
|
|
@@ -7107,7 +7099,7 @@ var TaskStopTool = class {
|
|
|
7107
7099
|
teamManager;
|
|
7108
7100
|
taskManager;
|
|
7109
7101
|
name = "TaskStop";
|
|
7110
|
-
description = "Stop a running teammate or background task (Agent, Bash, PowerShell
|
|
7102
|
+
description = "Stop a running teammate or background task (Agent, Bash, PowerShell). Pass exactly one of teammate or task_id.";
|
|
7111
7103
|
category = "command";
|
|
7112
7104
|
schema() {
|
|
7113
7105
|
return {
|
|
@@ -7122,7 +7114,7 @@ var TaskStopTool = class {
|
|
|
7122
7114
|
},
|
|
7123
7115
|
task_id: {
|
|
7124
7116
|
type: "string",
|
|
7125
|
-
description: "ID of a background task (Agent, Bash, PowerShell
|
|
7117
|
+
description: "ID of a background task (Agent, Bash, PowerShell)"
|
|
7126
7118
|
}
|
|
7127
7119
|
}
|
|
7128
7120
|
}
|
|
@@ -8616,7 +8608,7 @@ ${buildPersistedOutputPreview(size, annotate ? annotate(preview2) : preview2, ou
|
|
|
8616
8608
|
}
|
|
8617
8609
|
return result;
|
|
8618
8610
|
}
|
|
8619
|
-
var BACKGROUNDABLE_TOOL_NAMES = ["Bash", "PowerShell"
|
|
8611
|
+
var BACKGROUNDABLE_TOOL_NAMES = ["Bash", "PowerShell"];
|
|
8620
8612
|
function asBackgroundable(tool) {
|
|
8621
8613
|
if (typeof tool === "object" && tool !== null && "taskManager" in tool && "backgroundForegroundTasks" in tool) {
|
|
8622
8614
|
return tool;
|
|
@@ -11370,7 +11362,7 @@ async function createRemoteAgent(opts) {
|
|
|
11370
11362
|
throw new Error("no llm client (provider not initialized)");
|
|
11371
11363
|
}
|
|
11372
11364
|
const { PermissionChecker: PC } = await import("./permissions-77UJQITR.js");
|
|
11373
|
-
const { Agent: AgentClass } = await import("./agent-
|
|
11365
|
+
const { Agent: AgentClass } = await import("./agent-N64HDJ3J.js");
|
|
11374
11366
|
const subConv = new ConversationManager();
|
|
11375
11367
|
subConv.addUserMessage(prompt);
|
|
11376
11368
|
const taskManager = new TaskManager();
|
|
@@ -12987,373 +12979,6 @@ __export(tool_registry_exports, {
|
|
|
12987
12979
|
wireSkillsToRegistry: () => wireSkillsToRegistry
|
|
12988
12980
|
});
|
|
12989
12981
|
|
|
12990
|
-
// src/tools/javascript.ts
|
|
12991
|
-
var javascript_exports = {};
|
|
12992
|
-
__export(javascript_exports, {
|
|
12993
|
-
JavaScriptTool: () => JavaScriptTool,
|
|
12994
|
-
evaluateJavaScript: () => evaluateJavaScript,
|
|
12995
|
-
isolatedVmSupported: () => isolatedVmSupported
|
|
12996
|
-
});
|
|
12997
|
-
import { randomBytes as randomBytes4 } from "crypto";
|
|
12998
|
-
import { z as z16 } from "zod";
|
|
12999
|
-
var DEFAULT_TIMEOUT_MS = 1e3;
|
|
13000
|
-
var MAX_TIMEOUT_MS = 1e4;
|
|
13001
|
-
var DEFAULT_MEMORY_LIMIT_MB = 64;
|
|
13002
|
-
var MAX_MEMORY_LIMIT_MB = 256;
|
|
13003
|
-
var MAX_CODE_BYTES = 256 * 1024;
|
|
13004
|
-
var MAX_LOG_CHARS = 64 * 1024;
|
|
13005
|
-
var MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
13006
|
-
var JavaScriptArgumentsSchema = z16.object({
|
|
13007
|
-
code: z16.string().min(1),
|
|
13008
|
-
input: z16.json().optional(),
|
|
13009
|
-
timeout_ms: z16.number().int().min(1).max(MAX_TIMEOUT_MS).default(DEFAULT_TIMEOUT_MS),
|
|
13010
|
-
memory_limit_mb: z16.number().int().min(8).max(MAX_MEMORY_LIMIT_MB).default(DEFAULT_MEMORY_LIMIT_MB),
|
|
13011
|
-
// Accepted even when backgrounding is unavailable (then simply ignored):
|
|
13012
|
-
// the JSON schema gates what the model sees per host.
|
|
13013
|
-
run_in_background: z16.boolean().optional()
|
|
13014
|
-
});
|
|
13015
|
-
var JavaScriptEvaluationOptionsSchema = z16.object({
|
|
13016
|
-
input: z16.json().optional(),
|
|
13017
|
-
timeoutMs: z16.number().int().min(1).max(MAX_TIMEOUT_MS).default(DEFAULT_TIMEOUT_MS),
|
|
13018
|
-
memoryLimitMb: z16.number().int().min(8).max(MAX_MEMORY_LIMIT_MB).default(DEFAULT_MEMORY_LIMIT_MB)
|
|
13019
|
-
});
|
|
13020
|
-
var JavaScriptEvaluationSchema = z16.object({
|
|
13021
|
-
logs: z16.array(z16.string()),
|
|
13022
|
-
value: z16.json(),
|
|
13023
|
-
logsTruncated: z16.boolean()
|
|
13024
|
-
});
|
|
13025
|
-
function isolatedVmSupported(nodeVersion = process.versions.node) {
|
|
13026
|
-
const major = Number.parseInt(nodeVersion.split(".")[0] ?? "", 10);
|
|
13027
|
-
return Number.isFinite(major) && major >= 24;
|
|
13028
|
-
}
|
|
13029
|
-
async function evaluateJavaScript(code, options = {}) {
|
|
13030
|
-
const { abortSignal, ...values } = options;
|
|
13031
|
-
const parsed = JavaScriptEvaluationOptionsSchema.parse(values);
|
|
13032
|
-
return await runJavaScript(
|
|
13033
|
-
code,
|
|
13034
|
-
parsed.input,
|
|
13035
|
-
parsed.timeoutMs,
|
|
13036
|
-
parsed.memoryLimitMb,
|
|
13037
|
-
abortSignal
|
|
13038
|
-
);
|
|
13039
|
-
}
|
|
13040
|
-
async function runJavaScript(code, input, timeoutMs, memoryLimitMb, abortSignal) {
|
|
13041
|
-
if (!isolatedVmSupported()) {
|
|
13042
|
-
throw new Error("isolated-vm requires Node.js 24 or newer");
|
|
13043
|
-
}
|
|
13044
|
-
if (Buffer.byteLength(code) > MAX_CODE_BYTES) {
|
|
13045
|
-
throw new Error(`JavaScript source exceeds the ${String(MAX_CODE_BYTES)} byte limit`);
|
|
13046
|
-
}
|
|
13047
|
-
abortSignal?.throwIfAborted();
|
|
13048
|
-
const module = await import("isolated-vm");
|
|
13049
|
-
abortSignal?.throwIfAborted();
|
|
13050
|
-
const ivm = module.default;
|
|
13051
|
-
const isolate = new ivm.Isolate({ memoryLimit: memoryLimitMb });
|
|
13052
|
-
const context = await isolate.createContext();
|
|
13053
|
-
const onAbort = () => {
|
|
13054
|
-
if (!isolate.isDisposed) {
|
|
13055
|
-
isolate.dispose();
|
|
13056
|
-
}
|
|
13057
|
-
};
|
|
13058
|
-
abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
13059
|
-
let wallTimer;
|
|
13060
|
-
try {
|
|
13061
|
-
if (abortSignal?.aborted) {
|
|
13062
|
-
onAbort();
|
|
13063
|
-
abortSignal.throwIfAborted();
|
|
13064
|
-
}
|
|
13065
|
-
await context.global.set("input", input ?? null, { copy: true });
|
|
13066
|
-
const source = `
|
|
13067
|
-
(async () => {
|
|
13068
|
-
"use strict";
|
|
13069
|
-
const __logs = [];
|
|
13070
|
-
let __logChars = 0;
|
|
13071
|
-
let __logsTruncated = false;
|
|
13072
|
-
const __format = (value) => {
|
|
13073
|
-
if (typeof value === "string") return value;
|
|
13074
|
-
if (typeof value === "bigint") return String(value) + "n";
|
|
13075
|
-
try {
|
|
13076
|
-
const encoded = JSON.stringify(value);
|
|
13077
|
-
return encoded === undefined ? String(value) : encoded;
|
|
13078
|
-
} catch {
|
|
13079
|
-
try { return String(value); } catch { return "[unprintable]"; }
|
|
13080
|
-
}
|
|
13081
|
-
};
|
|
13082
|
-
const __write = (...values) => {
|
|
13083
|
-
if (__logsTruncated) return;
|
|
13084
|
-
const line = values.map(__format).join(" ");
|
|
13085
|
-
const remaining = ${String(MAX_LOG_CHARS)} - __logChars;
|
|
13086
|
-
if (line.length > remaining) {
|
|
13087
|
-
if (remaining > 0) __logs.push(line.slice(0, remaining));
|
|
13088
|
-
__logChars = ${String(MAX_LOG_CHARS)};
|
|
13089
|
-
__logsTruncated = true;
|
|
13090
|
-
return;
|
|
13091
|
-
}
|
|
13092
|
-
__logs.push(line);
|
|
13093
|
-
__logChars += line.length;
|
|
13094
|
-
};
|
|
13095
|
-
const console = Object.freeze({ log: __write, info: __write, warn: __write, error: __write });
|
|
13096
|
-
const __value = await (async () => {
|
|
13097
|
-
${code}
|
|
13098
|
-
})();
|
|
13099
|
-
const __payload = JSON.stringify({
|
|
13100
|
-
logs: __logs,
|
|
13101
|
-
value: __value === undefined ? null : __value,
|
|
13102
|
-
logsTruncated: __logsTruncated,
|
|
13103
|
-
});
|
|
13104
|
-
if (__payload === undefined) throw new Error("Result is not JSON serializable");
|
|
13105
|
-
if (__payload.length > ${String(MAX_OUTPUT_BYTES)}) throw new Error("Result exceeds output limit");
|
|
13106
|
-
return __payload;
|
|
13107
|
-
})()
|
|
13108
|
-
`;
|
|
13109
|
-
const evaluation = context.eval(source, {
|
|
13110
|
-
timeout: timeoutMs,
|
|
13111
|
-
promise: true,
|
|
13112
|
-
copy: true,
|
|
13113
|
-
filename: "swifty-sandbox.js"
|
|
13114
|
-
});
|
|
13115
|
-
const deadline = new Promise((_, reject) => {
|
|
13116
|
-
wallTimer = setTimeout(() => {
|
|
13117
|
-
reject(new Error(`JavaScript evaluation timed out after ${String(timeoutMs)}ms`));
|
|
13118
|
-
onAbort();
|
|
13119
|
-
}, timeoutMs);
|
|
13120
|
-
});
|
|
13121
|
-
const raw = await Promise.race([evaluation, deadline]);
|
|
13122
|
-
if (typeof raw !== "string") {
|
|
13123
|
-
throw new Error("JavaScript sandbox returned an invalid result");
|
|
13124
|
-
}
|
|
13125
|
-
if (Buffer.byteLength(raw) > MAX_OUTPUT_BYTES) {
|
|
13126
|
-
throw new Error("JavaScript sandbox result exceeds output limit");
|
|
13127
|
-
}
|
|
13128
|
-
const decoded = JSON.parse(raw);
|
|
13129
|
-
return JavaScriptEvaluationSchema.parse(decoded);
|
|
13130
|
-
} finally {
|
|
13131
|
-
clearTimeout(wallTimer);
|
|
13132
|
-
abortSignal?.removeEventListener("abort", onAbort);
|
|
13133
|
-
try {
|
|
13134
|
-
context.release();
|
|
13135
|
-
} catch {
|
|
13136
|
-
}
|
|
13137
|
-
if (!isolate.isDisposed) {
|
|
13138
|
-
isolate.dispose();
|
|
13139
|
-
}
|
|
13140
|
-
}
|
|
13141
|
-
}
|
|
13142
|
-
function formatEvaluation(result) {
|
|
13143
|
-
const sections = [];
|
|
13144
|
-
if (result.logs.length > 0) {
|
|
13145
|
-
sections.push(`Console:
|
|
13146
|
-
${result.logs.join("\n")}`);
|
|
13147
|
-
}
|
|
13148
|
-
if (result.logsTruncated) {
|
|
13149
|
-
sections.push("Console output truncated");
|
|
13150
|
-
}
|
|
13151
|
-
sections.push(`Result:
|
|
13152
|
-
${JSON.stringify(result.value, null, 2)}`);
|
|
13153
|
-
return sections.join("\n\n");
|
|
13154
|
-
}
|
|
13155
|
-
function jsBackgroundMessage(reason, taskId) {
|
|
13156
|
-
return reason === "user" ? `JavaScript evaluation was manually backgrounded by the user (task_id: ${taskId}). It is still running \u2014 you will be notified when it completes.` : `JavaScript running in background (task_id: ${taskId}). You will be notified when it completes; do not poll. Use TaskStop with task_id to abort it early.`;
|
|
13157
|
-
}
|
|
13158
|
-
var JavaScriptTool = class {
|
|
13159
|
-
name = "JavaScript";
|
|
13160
|
-
description = JAVASCRIPT_DESCRIPTION;
|
|
13161
|
-
category = "command";
|
|
13162
|
-
/**
|
|
13163
|
-
* Background task registry, injected by the host — same contract as
|
|
13164
|
-
* BashTool.taskManager. Unlike the shell tools there is no timeout
|
|
13165
|
-
* auto-background: timeout_ms is the isolate's hard safety cap — V8 kills a
|
|
13166
|
-
* synchronous script at the cap, and a wall-clock deadline disposes the
|
|
13167
|
-
* isolate when an evaluation is suspended on a promise — so nothing is left
|
|
13168
|
-
* to keep running.
|
|
13169
|
-
*/
|
|
13170
|
-
taskManager = null;
|
|
13171
|
-
/** Running foreground evaluations eligible for manual backgrounding (Ctrl+B). */
|
|
13172
|
-
foreground = /* @__PURE__ */ new Map();
|
|
13173
|
-
nextForegroundId = 1;
|
|
13174
|
-
/** Instance-level background gate; see BashTool.backgroundEnabled. */
|
|
13175
|
-
backgroundEnabled() {
|
|
13176
|
-
return this.taskManager !== null && process.env.SWIFTY_DISABLE_BACKGROUND_TASKS !== "1";
|
|
13177
|
-
}
|
|
13178
|
-
/** True while at least one foreground evaluation runs. */
|
|
13179
|
-
hasForegroundTasks() {
|
|
13180
|
-
return this.foreground.size > 0;
|
|
13181
|
-
}
|
|
13182
|
-
/** Move every running foreground evaluation to the background (Ctrl+B). */
|
|
13183
|
-
backgroundForegroundTasks() {
|
|
13184
|
-
let count = 0;
|
|
13185
|
-
for (const entry of [...this.foreground.values()]) {
|
|
13186
|
-
if (entry.background()) {
|
|
13187
|
-
count++;
|
|
13188
|
-
}
|
|
13189
|
-
}
|
|
13190
|
-
return count;
|
|
13191
|
-
}
|
|
13192
|
-
schema() {
|
|
13193
|
-
const properties = {
|
|
13194
|
-
code: {
|
|
13195
|
-
type: "string",
|
|
13196
|
-
description: "JavaScript function body to execute; use return to produce a result"
|
|
13197
|
-
},
|
|
13198
|
-
input: {
|
|
13199
|
-
description: "Optional JSON-compatible value exposed as globalThis.input"
|
|
13200
|
-
},
|
|
13201
|
-
timeout_ms: {
|
|
13202
|
-
type: "integer",
|
|
13203
|
-
minimum: 1,
|
|
13204
|
-
maximum: MAX_TIMEOUT_MS,
|
|
13205
|
-
default: DEFAULT_TIMEOUT_MS
|
|
13206
|
-
},
|
|
13207
|
-
memory_limit_mb: {
|
|
13208
|
-
type: "integer",
|
|
13209
|
-
minimum: 8,
|
|
13210
|
-
maximum: MAX_MEMORY_LIMIT_MB,
|
|
13211
|
-
default: DEFAULT_MEMORY_LIMIT_MB
|
|
13212
|
-
}
|
|
13213
|
-
};
|
|
13214
|
-
let description = this.description;
|
|
13215
|
-
if (this.backgroundEnabled()) {
|
|
13216
|
-
properties.run_in_background = {
|
|
13217
|
-
type: "boolean",
|
|
13218
|
-
description: "Run the evaluation in the background. Returns a task ID immediately; the result arrives later as a task notification.",
|
|
13219
|
-
default: false
|
|
13220
|
-
};
|
|
13221
|
-
description = `${this.description}
|
|
13222
|
-
${JAVASCRIPT_BACKGROUND_DESCRIPTION}`;
|
|
13223
|
-
}
|
|
13224
|
-
return {
|
|
13225
|
-
name: this.name,
|
|
13226
|
-
description,
|
|
13227
|
-
input_schema: {
|
|
13228
|
-
type: "object",
|
|
13229
|
-
properties,
|
|
13230
|
-
required: ["code"],
|
|
13231
|
-
additionalProperties: false
|
|
13232
|
-
}
|
|
13233
|
-
};
|
|
13234
|
-
}
|
|
13235
|
-
async execute(ctx, args) {
|
|
13236
|
-
const parsed = JavaScriptArgumentsSchema.safeParse(args);
|
|
13237
|
-
if (!parsed.success) {
|
|
13238
|
-
return { output: `Error: ${parsed.error.message}`, isError: true };
|
|
13239
|
-
}
|
|
13240
|
-
const manager = ctx.taskManager !== void 0 ? ctx.taskManager : this.taskManager;
|
|
13241
|
-
const backgroundAvailable = manager !== null && process.env.SWIFTY_DISABLE_BACKGROUND_TASKS !== "1";
|
|
13242
|
-
const runInBackground = parsed.data.run_in_background === true && backgroundAvailable;
|
|
13243
|
-
const handle = this.startEvaluation(ctx, parsed.data, manager, backgroundAvailable);
|
|
13244
|
-
if (runInBackground) {
|
|
13245
|
-
const taskId = handle.background("explicit");
|
|
13246
|
-
if (taskId !== null) {
|
|
13247
|
-
return {
|
|
13248
|
-
output: jsBackgroundMessage("explicit", taskId),
|
|
13249
|
-
isError: false
|
|
13250
|
-
};
|
|
13251
|
-
}
|
|
13252
|
-
}
|
|
13253
|
-
return handle.result;
|
|
13254
|
-
}
|
|
13255
|
-
/**
|
|
13256
|
-
* Start the isolated evaluation. The returned handle mirrors the shell
|
|
13257
|
-
* tools: background() transitions the pending evaluation into a TaskManager
|
|
13258
|
-
* task — the isolate keeps running on its own thread, the tool call
|
|
13259
|
-
* resolves immediately, and completion arrives as a task notification.
|
|
13260
|
-
* While foreground, the caller's abort signal (Esc) disposes the isolate;
|
|
13261
|
-
* once backgrounded, only TaskStop or session shutdown can abort it.
|
|
13262
|
-
*/
|
|
13263
|
-
startEvaluation(ctx, data, manager, backgroundAvailable) {
|
|
13264
|
-
let backgroundFn;
|
|
13265
|
-
const result = new Promise((resolve12) => {
|
|
13266
|
-
let settled = false;
|
|
13267
|
-
let backgrounded = false;
|
|
13268
|
-
const controller = new AbortController();
|
|
13269
|
-
const onCallerAbort = () => {
|
|
13270
|
-
controller.abort();
|
|
13271
|
-
};
|
|
13272
|
-
if (ctx.abortSignal?.aborted) {
|
|
13273
|
-
resolve12({ output: "Error: command interrupted", isError: true });
|
|
13274
|
-
return;
|
|
13275
|
-
}
|
|
13276
|
-
ctx.abortSignal?.addEventListener("abort", onCallerAbort, { once: true });
|
|
13277
|
-
const evalPromise = runJavaScript(
|
|
13278
|
-
data.code,
|
|
13279
|
-
data.input,
|
|
13280
|
-
data.timeout_ms,
|
|
13281
|
-
data.memory_limit_mb,
|
|
13282
|
-
controller.signal
|
|
13283
|
-
);
|
|
13284
|
-
const foregroundKey = `js-${String(this.nextForegroundId++)}`;
|
|
13285
|
-
const settle = (finalResult) => {
|
|
13286
|
-
if (settled) {
|
|
13287
|
-
return;
|
|
13288
|
-
}
|
|
13289
|
-
settled = true;
|
|
13290
|
-
ctx.abortSignal?.removeEventListener("abort", onCallerAbort);
|
|
13291
|
-
this.foreground.delete(foregroundKey);
|
|
13292
|
-
resolve12(finalResult);
|
|
13293
|
-
};
|
|
13294
|
-
const backgroundExecution = (reason) => {
|
|
13295
|
-
if (backgrounded || settled || controller.signal.aborted || !manager || !backgroundAvailable) {
|
|
13296
|
-
return null;
|
|
13297
|
-
}
|
|
13298
|
-
backgrounded = true;
|
|
13299
|
-
settled = true;
|
|
13300
|
-
ctx.abortSignal?.removeEventListener("abort", onCallerAbort);
|
|
13301
|
-
this.foreground.delete(foregroundKey);
|
|
13302
|
-
const task = manager.create(
|
|
13303
|
-
backgroundTaskName(data.code),
|
|
13304
|
-
async (backgroundTask) => {
|
|
13305
|
-
const cap = (text) => text.length > BACKGROUND_NOTIFICATION_CHARS ? persistLargeResult(
|
|
13306
|
-
ctx.workDir,
|
|
13307
|
-
ctx.sessionId ?? "",
|
|
13308
|
-
`${backgroundTask.id}-${randomBytes4(4).toString("hex")}`,
|
|
13309
|
-
text
|
|
13310
|
-
) : text;
|
|
13311
|
-
try {
|
|
13312
|
-
const evaluation = await evalPromise;
|
|
13313
|
-
return cap(formatEvaluation(evaluation));
|
|
13314
|
-
} catch (error) {
|
|
13315
|
-
if (backgroundTask.status === "cancelled") {
|
|
13316
|
-
throw error;
|
|
13317
|
-
}
|
|
13318
|
-
throw new TaskFailure(cap(`Error executing JavaScript: ${asErrorString(error)}`));
|
|
13319
|
-
}
|
|
13320
|
-
},
|
|
13321
|
-
() => {
|
|
13322
|
-
controller.abort();
|
|
13323
|
-
},
|
|
13324
|
-
{ originToolCallId: ctx.toolCallId, idPrefix: "js", kind: "js" }
|
|
13325
|
-
);
|
|
13326
|
-
resolve12({
|
|
13327
|
-
output: jsBackgroundMessage(reason, task.id),
|
|
13328
|
-
isError: false
|
|
13329
|
-
});
|
|
13330
|
-
return task.id;
|
|
13331
|
-
};
|
|
13332
|
-
if (backgroundAvailable) {
|
|
13333
|
-
this.foreground.set(foregroundKey, {
|
|
13334
|
-
background: () => backgroundExecution("user") !== null
|
|
13335
|
-
});
|
|
13336
|
-
}
|
|
13337
|
-
evalPromise.then(
|
|
13338
|
-
(evaluation) => {
|
|
13339
|
-
settle({ output: formatEvaluation(evaluation), isError: false });
|
|
13340
|
-
},
|
|
13341
|
-
(error) => {
|
|
13342
|
-
settle({
|
|
13343
|
-
output: `Error executing JavaScript: ${asErrorString(error)}`,
|
|
13344
|
-
isError: true
|
|
13345
|
-
});
|
|
13346
|
-
}
|
|
13347
|
-
);
|
|
13348
|
-
backgroundFn = backgroundExecution;
|
|
13349
|
-
});
|
|
13350
|
-
return {
|
|
13351
|
-
result,
|
|
13352
|
-
background: (reason) => backgroundFn?.(reason) ?? null
|
|
13353
|
-
};
|
|
13354
|
-
}
|
|
13355
|
-
};
|
|
13356
|
-
|
|
13357
12982
|
// src/tools/web-fetch.ts
|
|
13358
12983
|
var web_fetch_exports = {};
|
|
13359
12984
|
__export(web_fetch_exports, {
|
|
@@ -13589,7 +13214,6 @@ function createToolRegistry(workDir, taskList) {
|
|
|
13589
13214
|
registry.register(new WriteFileTool());
|
|
13590
13215
|
registry.register(new GlobTool());
|
|
13591
13216
|
registry.register(new GrepTool());
|
|
13592
|
-
registry.register(new JavaScriptTool());
|
|
13593
13217
|
registry.register(new WebFetchTool());
|
|
13594
13218
|
return registry;
|
|
13595
13219
|
}
|
|
@@ -14361,20 +13985,20 @@ __export(manager_exports3, {
|
|
|
14361
13985
|
});
|
|
14362
13986
|
import { readFileSync as readFileSync17, writeFileSync as writeFileSync11, existsSync as existsSync18, mkdirSync as mkdirSync13 } from "fs";
|
|
14363
13987
|
import { join as join22 } from "path";
|
|
14364
|
-
import
|
|
13988
|
+
import z16 from "zod";
|
|
14365
13989
|
var log30 = createChildLogger({ module: "code-review" });
|
|
14366
|
-
var CodeReviewMemberSchema =
|
|
14367
|
-
name:
|
|
14368
|
-
email:
|
|
14369
|
-
role:
|
|
14370
|
-
expertise:
|
|
14371
|
-
active:
|
|
14372
|
-
});
|
|
14373
|
-
var CodeReviewTeamSchema =
|
|
14374
|
-
name:
|
|
14375
|
-
members:
|
|
14376
|
-
createdAt:
|
|
14377
|
-
lastActive:
|
|
13990
|
+
var CodeReviewMemberSchema = z16.object({
|
|
13991
|
+
name: z16.string(),
|
|
13992
|
+
email: z16.string(),
|
|
13993
|
+
role: z16.enum(["reviewer", "lead", "junior", "critic"]),
|
|
13994
|
+
expertise: z16.array(z16.string()),
|
|
13995
|
+
active: z16.boolean()
|
|
13996
|
+
});
|
|
13997
|
+
var CodeReviewTeamSchema = z16.object({
|
|
13998
|
+
name: z16.string(),
|
|
13999
|
+
members: z16.array(CodeReviewMemberSchema),
|
|
14000
|
+
createdAt: z16.string(),
|
|
14001
|
+
lastActive: z16.string()
|
|
14378
14002
|
});
|
|
14379
14003
|
var CodeReviewManager = class {
|
|
14380
14004
|
teams = /* @__PURE__ */ new Map();
|
|
@@ -14552,11 +14176,11 @@ __export(usage_tracker_exports, {
|
|
|
14552
14176
|
});
|
|
14553
14177
|
import { readFileSync as readFileSync18, writeFileSync as writeFileSync12, mkdirSync as mkdirSync14, existsSync as existsSync19 } from "fs";
|
|
14554
14178
|
import { join as join23, dirname as dirname9 } from "path";
|
|
14555
|
-
import { safeParse as safeParse3, z as
|
|
14179
|
+
import { safeParse as safeParse3, z as z17 } from "zod";
|
|
14556
14180
|
var log31 = createChildLogger({ module: "commands" });
|
|
14557
|
-
var UsageEntrySchema =
|
|
14558
|
-
usageCount:
|
|
14559
|
-
lastUsedAt:
|
|
14181
|
+
var UsageEntrySchema = z17.object({
|
|
14182
|
+
usageCount: z17.coerce.number(),
|
|
14183
|
+
lastUsedAt: z17.coerce.number()
|
|
14560
14184
|
});
|
|
14561
14185
|
var CommandUsageTracker = class {
|
|
14562
14186
|
usage = /* @__PURE__ */ new Map();
|
|
@@ -14631,11 +14255,11 @@ __export(history_exports, {
|
|
|
14631
14255
|
});
|
|
14632
14256
|
import { readFileSync as readFileSync19, writeFileSync as writeFileSync13, mkdirSync as mkdirSync15, existsSync as existsSync20 } from "fs";
|
|
14633
14257
|
import { join as join24 } from "path";
|
|
14634
|
-
import { parse as parse8, z as
|
|
14258
|
+
import { parse as parse8, z as z18 } from "zod";
|
|
14635
14259
|
var log32 = createChildLogger({ module: "history" });
|
|
14636
14260
|
var MAX_HISTORY_ENTRIES = 200;
|
|
14637
14261
|
var FILENAME = "prompt_history.jsonl";
|
|
14638
|
-
var JSONLSchema =
|
|
14262
|
+
var JSONLSchema = z18.looseObject({ text: z18.string() });
|
|
14639
14263
|
function load(dir) {
|
|
14640
14264
|
const filePath = join24(dir, FILENAME);
|
|
14641
14265
|
if (!existsSync20(filePath)) {
|
|
@@ -14692,19 +14316,19 @@ __export(model_discovery_exports, {
|
|
|
14692
14316
|
discoverModels: () => discoverModels,
|
|
14693
14317
|
modelListUrl: () => modelListUrl
|
|
14694
14318
|
});
|
|
14695
|
-
import { z as
|
|
14319
|
+
import { z as z19 } from "zod";
|
|
14696
14320
|
var DISCOVERY_TIMEOUT_MS = 5e3;
|
|
14697
14321
|
var MAX_MODEL_PAGES = 10;
|
|
14698
|
-
var HttpUrlSchema =
|
|
14699
|
-
var ModelSchema =
|
|
14700
|
-
id:
|
|
14701
|
-
display_name:
|
|
14702
|
-
name:
|
|
14322
|
+
var HttpUrlSchema = z19.url();
|
|
14323
|
+
var ModelSchema = z19.object({
|
|
14324
|
+
id: z19.string().trim().min(1),
|
|
14325
|
+
display_name: z19.string().optional(),
|
|
14326
|
+
name: z19.string().optional()
|
|
14703
14327
|
});
|
|
14704
|
-
var ModelListSchema =
|
|
14705
|
-
data:
|
|
14706
|
-
has_more:
|
|
14707
|
-
last_id:
|
|
14328
|
+
var ModelListSchema = z19.object({
|
|
14329
|
+
data: z19.array(ModelSchema),
|
|
14330
|
+
has_more: z19.boolean().optional(),
|
|
14331
|
+
last_id: z19.string().trim().min(1).nullable().optional()
|
|
14708
14332
|
});
|
|
14709
14333
|
function modelListUrl(protocol, baseUrl) {
|
|
14710
14334
|
const parsed = HttpUrlSchema.safeParse(baseUrl);
|
|
@@ -15050,7 +14674,6 @@ __export(tools_exports3, {
|
|
|
15050
14674
|
Glob: () => glob_exports,
|
|
15051
14675
|
Grep: () => grep_exports,
|
|
15052
14676
|
IsDiffTool: () => is_diff_tool_exports,
|
|
15053
|
-
JavaScript: () => javascript_exports,
|
|
15054
14677
|
McpCall: () => mcp_call_exports,
|
|
15055
14678
|
PowerShell: () => powershell_exports,
|
|
15056
14679
|
ReadFile: () => read_file_exports,
|
|
@@ -15089,7 +14712,7 @@ __export(ide_client_exports, {
|
|
|
15089
14712
|
});
|
|
15090
14713
|
import { setTimeout as delay2 } from "timers/promises";
|
|
15091
14714
|
import { Client as Client2 } from "@modelcontextprotocol/sdk/client/index.js";
|
|
15092
|
-
import { z as
|
|
14715
|
+
import { z as z21 } from "zod";
|
|
15093
14716
|
|
|
15094
14717
|
// src/vscode/lockfile.ts
|
|
15095
14718
|
var lockfile_exports = {};
|
|
@@ -15099,14 +14722,14 @@ __export(lockfile_exports, {
|
|
|
15099
14722
|
import { readdir as readdir2, readFile as readFile5 } from "fs/promises";
|
|
15100
14723
|
import { homedir as homedir10 } from "os";
|
|
15101
14724
|
import { join as join26, resolve as resolve11, sep as sep2 } from "path";
|
|
15102
|
-
import { z as
|
|
14725
|
+
import { z as z20 } from "zod";
|
|
15103
14726
|
var log34 = createChildLogger({ module: "vscode" });
|
|
15104
|
-
var LockfileSchema =
|
|
15105
|
-
workspaceFolders:
|
|
15106
|
-
pid:
|
|
15107
|
-
ideName:
|
|
15108
|
-
transport:
|
|
15109
|
-
authToken:
|
|
14727
|
+
var LockfileSchema = z20.object({
|
|
14728
|
+
workspaceFolders: z20.array(z20.string()).optional(),
|
|
14729
|
+
pid: z20.number().optional(),
|
|
14730
|
+
ideName: z20.string().optional(),
|
|
14731
|
+
transport: z20.enum(["ws", "sse"]).optional(),
|
|
14732
|
+
authToken: z20.string().optional()
|
|
15110
14733
|
});
|
|
15111
14734
|
function ideLockDir() {
|
|
15112
14735
|
const configDir = process.env.CLAUDE_CONFIG_DIR ?? join26(homedir10(), ".claude");
|
|
@@ -15263,12 +14886,12 @@ var WebSocketTransport = class {
|
|
|
15263
14886
|
|
|
15264
14887
|
// src/vscode/ide-client.ts
|
|
15265
14888
|
var log35 = createChildLogger({ module: "vscode" });
|
|
15266
|
-
var AtMentionedSchema =
|
|
15267
|
-
method:
|
|
15268
|
-
params:
|
|
15269
|
-
filePath:
|
|
15270
|
-
lineStart:
|
|
15271
|
-
lineEnd:
|
|
14889
|
+
var AtMentionedSchema = z21.object({
|
|
14890
|
+
method: z21.literal("at_mentioned"),
|
|
14891
|
+
params: z21.object({
|
|
14892
|
+
filePath: z21.string(),
|
|
14893
|
+
lineStart: z21.number().optional(),
|
|
14894
|
+
lineEnd: z21.number().optional()
|
|
15272
14895
|
})
|
|
15273
14896
|
});
|
|
15274
14897
|
function inIdeTerminal() {
|