@swifty.js/swifty 0.0.36 → 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/README.md +8 -8
- package/dist/{acp-ZU5LZRUP.js → acp-K6UNT7R2.js} +1 -1
- package/dist/{agent-YDU6HB4S.js → agent-TVRVBK2C.js} +1 -1
- package/dist/anthropic-3DXT42SN.js +4 -0
- package/dist/{chunk-EEEW3GG4.js → chunk-AN6IJDRD.js} +1 -1
- package/dist/chunk-CJZX34IA.js +4 -0
- package/dist/{chunk-MTAGHTBG.js → chunk-CTLUJRU3.js} +5 -5
- package/dist/{chunk-MNP6IJ7C.js → chunk-FITQ5CCD.js} +2 -2
- package/dist/{chunk-Q3NPRV5P.js → chunk-QBGGDF62.js} +1 -1
- package/dist/{chunk-H56UQALW.js → chunk-VN7HK3YD.js} +1 -1
- package/dist/chunk-YBS5ATGZ.js +4 -0
- package/dist/{chunk-RDVRYI56.js → chunk-Z4QZQ7X6.js} +16 -19
- package/dist/esm-VBV56AO5.js +229 -0
- package/dist/lib/{agent-ZMIS6IH6.js → agent-N64HDJ3J.js} +2 -2
- package/dist/lib/{anthropic-FKIGL7NL.js → anthropic-GD3ILYG6.js} +1 -1
- package/dist/lib/{chunk-PJ7354ZG.js → chunk-5QBKDZYN.js} +1 -1
- package/dist/lib/{chunk-YUDCYSKO.js → chunk-FPULYNJL.js} +17 -10
- package/dist/lib/{chunk-ALQHMYOZ.js → chunk-LKFJIK6F.js} +0 -3
- package/dist/lib/{chunk-LRN4MOQ3.js → chunk-OM7DYLTN.js} +0 -6
- package/dist/lib/{chunk-6V7RW6HA.js → chunk-TD7Z6L4D.js} +10 -13
- package/dist/lib/index.d.ts +224 -572
- package/dist/lib/index.js +64 -782
- package/dist/lib/{openai-ZWIYIBLC.js → openai-N6X7XUQJ.js} +1 -1
- package/dist/lib/{providers-5SJFTU2G.js → providers-YRULZPXI.js} +1 -1
- package/dist/lib/{tool-filter-QU4LOZII.js → tool-filter-UULMJRDQ.js} +1 -1
- package/dist/main.js +171 -219
- package/dist/{openai-7LMX5HKW.js → openai-XMJVVTTX.js} +1 -1
- package/dist/{providers-FQCJFM3Q.js → providers-6YCHQM6N.js} +1 -1
- package/dist/{server-C6H5ZWUG.js → server-OHPTZAGM.js} +1 -1
- package/dist/{tool-filter-U5SSL3LR.js → tool-filter-NRC4U62K.js} +1 -1
- package/package.json +2 -3
- package/dist/anthropic-GDT73MMP.js +0 -4
- package/dist/chunk-I7XJSLRI.js +0 -4
- package/dist/chunk-UJGMTIYO.js +0 -4
- package/dist/esm-PDXUGWFK.js +0 -229
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,23 +42,23 @@ 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,
|
|
54
53
|
strategy_exports
|
|
55
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-TD7Z6L4D.js";
|
|
56
55
|
import {
|
|
57
56
|
SKIP_DIRS,
|
|
58
57
|
types_exports
|
|
59
58
|
} from "./chunk-BQFVUVLI.js";
|
|
60
59
|
import {
|
|
61
60
|
openai_exports
|
|
62
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-LKFJIK6F.js";
|
|
63
62
|
import {
|
|
64
63
|
DEFAULT_CONTEXT_WINDOW,
|
|
65
64
|
DEFAULT_MAX_OUTPUT_TOKENS,
|
|
@@ -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";
|
|
@@ -1404,21 +1403,21 @@ __export(client_exports, {
|
|
|
1404
1403
|
async function createClient(config, systemPrompt) {
|
|
1405
1404
|
switch (config.protocol) {
|
|
1406
1405
|
case "anthropic": {
|
|
1407
|
-
const { AnthropicClient } = await import("./anthropic-
|
|
1406
|
+
const { AnthropicClient } = await import("./anthropic-GD3ILYG6.js");
|
|
1408
1407
|
return registerLlmClient(new AnthropicClient(config, systemPrompt), {
|
|
1409
1408
|
model: config.model,
|
|
1410
1409
|
protocol: config.protocol
|
|
1411
1410
|
});
|
|
1412
1411
|
}
|
|
1413
1412
|
case "openai": {
|
|
1414
|
-
const { OpenAIClient } = await import("./openai-
|
|
1413
|
+
const { OpenAIClient } = await import("./openai-N6X7XUQJ.js");
|
|
1415
1414
|
return registerLlmClient(new OpenAIClient(config, systemPrompt), {
|
|
1416
1415
|
model: config.model,
|
|
1417
1416
|
protocol: config.protocol
|
|
1418
1417
|
});
|
|
1419
1418
|
}
|
|
1420
1419
|
case "openai-compat": {
|
|
1421
|
-
const { OpenAICompatClient } = await import("./openai-
|
|
1420
|
+
const { OpenAICompatClient } = await import("./openai-N6X7XUQJ.js");
|
|
1422
1421
|
return registerLlmClient(new OpenAICompatClient(config, systemPrompt), {
|
|
1423
1422
|
model: config.model,
|
|
1424
1423
|
protocol: config.protocol
|
|
@@ -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;
|
|
@@ -8671,7 +8663,7 @@ var BashTool = class {
|
|
|
8671
8663
|
networkEnabled: true
|
|
8672
8664
|
};
|
|
8673
8665
|
/**
|
|
8674
|
-
* Background task registry, injected by the host (
|
|
8666
|
+
* Background task registry, injected by the host (UI / print mode / remote
|
|
8675
8667
|
* server) — the same instance the Agent tool uses, so completion
|
|
8676
8668
|
* notifications share one drain and TaskStop covers both. When null, Bash is
|
|
8677
8669
|
* foreground-only: run_in_background disappears from the schema, timeouts
|
|
@@ -9800,22 +9792,6 @@ var ComputerUseTool = class {
|
|
|
9800
9792
|
isConcurrencySafe(_args) {
|
|
9801
9793
|
return false;
|
|
9802
9794
|
}
|
|
9803
|
-
providerSchema(protocol) {
|
|
9804
|
-
if (protocol === "anthropic") {
|
|
9805
|
-
return {
|
|
9806
|
-
type: "computer_20251124",
|
|
9807
|
-
name: "computer",
|
|
9808
|
-
display_width_px: this.displayWidthPx,
|
|
9809
|
-
display_height_px: this.displayHeightPx,
|
|
9810
|
-
...this.displayNumber !== void 0 ? { display_number: this.displayNumber } : {},
|
|
9811
|
-
...this.enableZoom ? { enable_zoom: true } : {}
|
|
9812
|
-
};
|
|
9813
|
-
}
|
|
9814
|
-
if (protocol === "openai") {
|
|
9815
|
-
return { type: "computer" };
|
|
9816
|
-
}
|
|
9817
|
-
return void 0;
|
|
9818
|
-
}
|
|
9819
9795
|
schema() {
|
|
9820
9796
|
return {
|
|
9821
9797
|
name: this.name,
|
|
@@ -11386,7 +11362,7 @@ async function createRemoteAgent(opts) {
|
|
|
11386
11362
|
throw new Error("no llm client (provider not initialized)");
|
|
11387
11363
|
}
|
|
11388
11364
|
const { PermissionChecker: PC } = await import("./permissions-77UJQITR.js");
|
|
11389
|
-
const { Agent: AgentClass } = await import("./agent-
|
|
11365
|
+
const { Agent: AgentClass } = await import("./agent-N64HDJ3J.js");
|
|
11390
11366
|
const subConv = new ConversationManager();
|
|
11391
11367
|
subConv.addUserMessage(prompt);
|
|
11392
11368
|
const taskManager = new TaskManager();
|
|
@@ -13003,373 +12979,6 @@ __export(tool_registry_exports, {
|
|
|
13003
12979
|
wireSkillsToRegistry: () => wireSkillsToRegistry
|
|
13004
12980
|
});
|
|
13005
12981
|
|
|
13006
|
-
// src/tools/javascript.ts
|
|
13007
|
-
var javascript_exports = {};
|
|
13008
|
-
__export(javascript_exports, {
|
|
13009
|
-
JavaScriptTool: () => JavaScriptTool,
|
|
13010
|
-
evaluateJavaScript: () => evaluateJavaScript,
|
|
13011
|
-
isolatedVmSupported: () => isolatedVmSupported
|
|
13012
|
-
});
|
|
13013
|
-
import { randomBytes as randomBytes4 } from "crypto";
|
|
13014
|
-
import { z as z16 } from "zod";
|
|
13015
|
-
var DEFAULT_TIMEOUT_MS = 1e3;
|
|
13016
|
-
var MAX_TIMEOUT_MS = 1e4;
|
|
13017
|
-
var DEFAULT_MEMORY_LIMIT_MB = 64;
|
|
13018
|
-
var MAX_MEMORY_LIMIT_MB = 256;
|
|
13019
|
-
var MAX_CODE_BYTES = 256 * 1024;
|
|
13020
|
-
var MAX_LOG_CHARS = 64 * 1024;
|
|
13021
|
-
var MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
13022
|
-
var JavaScriptArgumentsSchema = z16.object({
|
|
13023
|
-
code: z16.string().min(1),
|
|
13024
|
-
input: z16.json().optional(),
|
|
13025
|
-
timeout_ms: z16.number().int().min(1).max(MAX_TIMEOUT_MS).default(DEFAULT_TIMEOUT_MS),
|
|
13026
|
-
memory_limit_mb: z16.number().int().min(8).max(MAX_MEMORY_LIMIT_MB).default(DEFAULT_MEMORY_LIMIT_MB),
|
|
13027
|
-
// Accepted even when backgrounding is unavailable (then simply ignored):
|
|
13028
|
-
// the JSON schema gates what the model sees per host.
|
|
13029
|
-
run_in_background: z16.boolean().optional()
|
|
13030
|
-
});
|
|
13031
|
-
var JavaScriptEvaluationOptionsSchema = z16.object({
|
|
13032
|
-
input: z16.json().optional(),
|
|
13033
|
-
timeoutMs: z16.number().int().min(1).max(MAX_TIMEOUT_MS).default(DEFAULT_TIMEOUT_MS),
|
|
13034
|
-
memoryLimitMb: z16.number().int().min(8).max(MAX_MEMORY_LIMIT_MB).default(DEFAULT_MEMORY_LIMIT_MB)
|
|
13035
|
-
});
|
|
13036
|
-
var JavaScriptEvaluationSchema = z16.object({
|
|
13037
|
-
logs: z16.array(z16.string()),
|
|
13038
|
-
value: z16.json(),
|
|
13039
|
-
logsTruncated: z16.boolean()
|
|
13040
|
-
});
|
|
13041
|
-
function isolatedVmSupported(nodeVersion = process.versions.node) {
|
|
13042
|
-
const major = Number.parseInt(nodeVersion.split(".")[0] ?? "", 10);
|
|
13043
|
-
return Number.isFinite(major) && major >= 24;
|
|
13044
|
-
}
|
|
13045
|
-
async function evaluateJavaScript(code, options = {}) {
|
|
13046
|
-
const { abortSignal, ...values } = options;
|
|
13047
|
-
const parsed = JavaScriptEvaluationOptionsSchema.parse(values);
|
|
13048
|
-
return await runJavaScript(
|
|
13049
|
-
code,
|
|
13050
|
-
parsed.input,
|
|
13051
|
-
parsed.timeoutMs,
|
|
13052
|
-
parsed.memoryLimitMb,
|
|
13053
|
-
abortSignal
|
|
13054
|
-
);
|
|
13055
|
-
}
|
|
13056
|
-
async function runJavaScript(code, input, timeoutMs, memoryLimitMb, abortSignal) {
|
|
13057
|
-
if (!isolatedVmSupported()) {
|
|
13058
|
-
throw new Error("isolated-vm requires Node.js 24 or newer");
|
|
13059
|
-
}
|
|
13060
|
-
if (Buffer.byteLength(code) > MAX_CODE_BYTES) {
|
|
13061
|
-
throw new Error(`JavaScript source exceeds the ${String(MAX_CODE_BYTES)} byte limit`);
|
|
13062
|
-
}
|
|
13063
|
-
abortSignal?.throwIfAborted();
|
|
13064
|
-
const module = await import("isolated-vm");
|
|
13065
|
-
abortSignal?.throwIfAborted();
|
|
13066
|
-
const ivm = module.default;
|
|
13067
|
-
const isolate = new ivm.Isolate({ memoryLimit: memoryLimitMb });
|
|
13068
|
-
const context = await isolate.createContext();
|
|
13069
|
-
const onAbort = () => {
|
|
13070
|
-
if (!isolate.isDisposed) {
|
|
13071
|
-
isolate.dispose();
|
|
13072
|
-
}
|
|
13073
|
-
};
|
|
13074
|
-
abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
13075
|
-
let wallTimer;
|
|
13076
|
-
try {
|
|
13077
|
-
if (abortSignal?.aborted) {
|
|
13078
|
-
onAbort();
|
|
13079
|
-
abortSignal.throwIfAborted();
|
|
13080
|
-
}
|
|
13081
|
-
await context.global.set("input", input ?? null, { copy: true });
|
|
13082
|
-
const source = `
|
|
13083
|
-
(async () => {
|
|
13084
|
-
"use strict";
|
|
13085
|
-
const __logs = [];
|
|
13086
|
-
let __logChars = 0;
|
|
13087
|
-
let __logsTruncated = false;
|
|
13088
|
-
const __format = (value) => {
|
|
13089
|
-
if (typeof value === "string") return value;
|
|
13090
|
-
if (typeof value === "bigint") return String(value) + "n";
|
|
13091
|
-
try {
|
|
13092
|
-
const encoded = JSON.stringify(value);
|
|
13093
|
-
return encoded === undefined ? String(value) : encoded;
|
|
13094
|
-
} catch {
|
|
13095
|
-
try { return String(value); } catch { return "[unprintable]"; }
|
|
13096
|
-
}
|
|
13097
|
-
};
|
|
13098
|
-
const __write = (...values) => {
|
|
13099
|
-
if (__logsTruncated) return;
|
|
13100
|
-
const line = values.map(__format).join(" ");
|
|
13101
|
-
const remaining = ${String(MAX_LOG_CHARS)} - __logChars;
|
|
13102
|
-
if (line.length > remaining) {
|
|
13103
|
-
if (remaining > 0) __logs.push(line.slice(0, remaining));
|
|
13104
|
-
__logChars = ${String(MAX_LOG_CHARS)};
|
|
13105
|
-
__logsTruncated = true;
|
|
13106
|
-
return;
|
|
13107
|
-
}
|
|
13108
|
-
__logs.push(line);
|
|
13109
|
-
__logChars += line.length;
|
|
13110
|
-
};
|
|
13111
|
-
const console = Object.freeze({ log: __write, info: __write, warn: __write, error: __write });
|
|
13112
|
-
const __value = await (async () => {
|
|
13113
|
-
${code}
|
|
13114
|
-
})();
|
|
13115
|
-
const __payload = JSON.stringify({
|
|
13116
|
-
logs: __logs,
|
|
13117
|
-
value: __value === undefined ? null : __value,
|
|
13118
|
-
logsTruncated: __logsTruncated,
|
|
13119
|
-
});
|
|
13120
|
-
if (__payload === undefined) throw new Error("Result is not JSON serializable");
|
|
13121
|
-
if (__payload.length > ${String(MAX_OUTPUT_BYTES)}) throw new Error("Result exceeds output limit");
|
|
13122
|
-
return __payload;
|
|
13123
|
-
})()
|
|
13124
|
-
`;
|
|
13125
|
-
const evaluation = context.eval(source, {
|
|
13126
|
-
timeout: timeoutMs,
|
|
13127
|
-
promise: true,
|
|
13128
|
-
copy: true,
|
|
13129
|
-
filename: "swifty-sandbox.js"
|
|
13130
|
-
});
|
|
13131
|
-
const deadline = new Promise((_, reject) => {
|
|
13132
|
-
wallTimer = setTimeout(() => {
|
|
13133
|
-
reject(new Error(`JavaScript evaluation timed out after ${String(timeoutMs)}ms`));
|
|
13134
|
-
onAbort();
|
|
13135
|
-
}, timeoutMs);
|
|
13136
|
-
});
|
|
13137
|
-
const raw = await Promise.race([evaluation, deadline]);
|
|
13138
|
-
if (typeof raw !== "string") {
|
|
13139
|
-
throw new Error("JavaScript sandbox returned an invalid result");
|
|
13140
|
-
}
|
|
13141
|
-
if (Buffer.byteLength(raw) > MAX_OUTPUT_BYTES) {
|
|
13142
|
-
throw new Error("JavaScript sandbox result exceeds output limit");
|
|
13143
|
-
}
|
|
13144
|
-
const decoded = JSON.parse(raw);
|
|
13145
|
-
return JavaScriptEvaluationSchema.parse(decoded);
|
|
13146
|
-
} finally {
|
|
13147
|
-
clearTimeout(wallTimer);
|
|
13148
|
-
abortSignal?.removeEventListener("abort", onAbort);
|
|
13149
|
-
try {
|
|
13150
|
-
context.release();
|
|
13151
|
-
} catch {
|
|
13152
|
-
}
|
|
13153
|
-
if (!isolate.isDisposed) {
|
|
13154
|
-
isolate.dispose();
|
|
13155
|
-
}
|
|
13156
|
-
}
|
|
13157
|
-
}
|
|
13158
|
-
function formatEvaluation(result) {
|
|
13159
|
-
const sections = [];
|
|
13160
|
-
if (result.logs.length > 0) {
|
|
13161
|
-
sections.push(`Console:
|
|
13162
|
-
${result.logs.join("\n")}`);
|
|
13163
|
-
}
|
|
13164
|
-
if (result.logsTruncated) {
|
|
13165
|
-
sections.push("Console output truncated");
|
|
13166
|
-
}
|
|
13167
|
-
sections.push(`Result:
|
|
13168
|
-
${JSON.stringify(result.value, null, 2)}`);
|
|
13169
|
-
return sections.join("\n\n");
|
|
13170
|
-
}
|
|
13171
|
-
function jsBackgroundMessage(reason, taskId) {
|
|
13172
|
-
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.`;
|
|
13173
|
-
}
|
|
13174
|
-
var JavaScriptTool = class {
|
|
13175
|
-
name = "JavaScript";
|
|
13176
|
-
description = JAVASCRIPT_DESCRIPTION;
|
|
13177
|
-
category = "command";
|
|
13178
|
-
/**
|
|
13179
|
-
* Background task registry, injected by the host — same contract as
|
|
13180
|
-
* BashTool.taskManager. Unlike the shell tools there is no timeout
|
|
13181
|
-
* auto-background: timeout_ms is the isolate's hard safety cap — V8 kills a
|
|
13182
|
-
* synchronous script at the cap, and a wall-clock deadline disposes the
|
|
13183
|
-
* isolate when an evaluation is suspended on a promise — so nothing is left
|
|
13184
|
-
* to keep running.
|
|
13185
|
-
*/
|
|
13186
|
-
taskManager = null;
|
|
13187
|
-
/** Running foreground evaluations eligible for manual backgrounding (Ctrl+B). */
|
|
13188
|
-
foreground = /* @__PURE__ */ new Map();
|
|
13189
|
-
nextForegroundId = 1;
|
|
13190
|
-
/** Instance-level background gate; see BashTool.backgroundEnabled. */
|
|
13191
|
-
backgroundEnabled() {
|
|
13192
|
-
return this.taskManager !== null && process.env.SWIFTY_DISABLE_BACKGROUND_TASKS !== "1";
|
|
13193
|
-
}
|
|
13194
|
-
/** True while at least one foreground evaluation runs. */
|
|
13195
|
-
hasForegroundTasks() {
|
|
13196
|
-
return this.foreground.size > 0;
|
|
13197
|
-
}
|
|
13198
|
-
/** Move every running foreground evaluation to the background (Ctrl+B). */
|
|
13199
|
-
backgroundForegroundTasks() {
|
|
13200
|
-
let count = 0;
|
|
13201
|
-
for (const entry of [...this.foreground.values()]) {
|
|
13202
|
-
if (entry.background()) {
|
|
13203
|
-
count++;
|
|
13204
|
-
}
|
|
13205
|
-
}
|
|
13206
|
-
return count;
|
|
13207
|
-
}
|
|
13208
|
-
schema() {
|
|
13209
|
-
const properties = {
|
|
13210
|
-
code: {
|
|
13211
|
-
type: "string",
|
|
13212
|
-
description: "JavaScript function body to execute; use return to produce a result"
|
|
13213
|
-
},
|
|
13214
|
-
input: {
|
|
13215
|
-
description: "Optional JSON-compatible value exposed as globalThis.input"
|
|
13216
|
-
},
|
|
13217
|
-
timeout_ms: {
|
|
13218
|
-
type: "integer",
|
|
13219
|
-
minimum: 1,
|
|
13220
|
-
maximum: MAX_TIMEOUT_MS,
|
|
13221
|
-
default: DEFAULT_TIMEOUT_MS
|
|
13222
|
-
},
|
|
13223
|
-
memory_limit_mb: {
|
|
13224
|
-
type: "integer",
|
|
13225
|
-
minimum: 8,
|
|
13226
|
-
maximum: MAX_MEMORY_LIMIT_MB,
|
|
13227
|
-
default: DEFAULT_MEMORY_LIMIT_MB
|
|
13228
|
-
}
|
|
13229
|
-
};
|
|
13230
|
-
let description = this.description;
|
|
13231
|
-
if (this.backgroundEnabled()) {
|
|
13232
|
-
properties.run_in_background = {
|
|
13233
|
-
type: "boolean",
|
|
13234
|
-
description: "Run the evaluation in the background. Returns a task ID immediately; the result arrives later as a task notification.",
|
|
13235
|
-
default: false
|
|
13236
|
-
};
|
|
13237
|
-
description = `${this.description}
|
|
13238
|
-
${JAVASCRIPT_BACKGROUND_DESCRIPTION}`;
|
|
13239
|
-
}
|
|
13240
|
-
return {
|
|
13241
|
-
name: this.name,
|
|
13242
|
-
description,
|
|
13243
|
-
input_schema: {
|
|
13244
|
-
type: "object",
|
|
13245
|
-
properties,
|
|
13246
|
-
required: ["code"],
|
|
13247
|
-
additionalProperties: false
|
|
13248
|
-
}
|
|
13249
|
-
};
|
|
13250
|
-
}
|
|
13251
|
-
async execute(ctx, args) {
|
|
13252
|
-
const parsed = JavaScriptArgumentsSchema.safeParse(args);
|
|
13253
|
-
if (!parsed.success) {
|
|
13254
|
-
return { output: `Error: ${parsed.error.message}`, isError: true };
|
|
13255
|
-
}
|
|
13256
|
-
const manager = ctx.taskManager !== void 0 ? ctx.taskManager : this.taskManager;
|
|
13257
|
-
const backgroundAvailable = manager !== null && process.env.SWIFTY_DISABLE_BACKGROUND_TASKS !== "1";
|
|
13258
|
-
const runInBackground = parsed.data.run_in_background === true && backgroundAvailable;
|
|
13259
|
-
const handle = this.startEvaluation(ctx, parsed.data, manager, backgroundAvailable);
|
|
13260
|
-
if (runInBackground) {
|
|
13261
|
-
const taskId = handle.background("explicit");
|
|
13262
|
-
if (taskId !== null) {
|
|
13263
|
-
return {
|
|
13264
|
-
output: jsBackgroundMessage("explicit", taskId),
|
|
13265
|
-
isError: false
|
|
13266
|
-
};
|
|
13267
|
-
}
|
|
13268
|
-
}
|
|
13269
|
-
return handle.result;
|
|
13270
|
-
}
|
|
13271
|
-
/**
|
|
13272
|
-
* Start the isolated evaluation. The returned handle mirrors the shell
|
|
13273
|
-
* tools: background() transitions the pending evaluation into a TaskManager
|
|
13274
|
-
* task — the isolate keeps running on its own thread, the tool call
|
|
13275
|
-
* resolves immediately, and completion arrives as a task notification.
|
|
13276
|
-
* While foreground, the caller's abort signal (Esc) disposes the isolate;
|
|
13277
|
-
* once backgrounded, only TaskStop or session shutdown can abort it.
|
|
13278
|
-
*/
|
|
13279
|
-
startEvaluation(ctx, data, manager, backgroundAvailable) {
|
|
13280
|
-
let backgroundFn;
|
|
13281
|
-
const result = new Promise((resolve12) => {
|
|
13282
|
-
let settled = false;
|
|
13283
|
-
let backgrounded = false;
|
|
13284
|
-
const controller = new AbortController();
|
|
13285
|
-
const onCallerAbort = () => {
|
|
13286
|
-
controller.abort();
|
|
13287
|
-
};
|
|
13288
|
-
if (ctx.abortSignal?.aborted) {
|
|
13289
|
-
resolve12({ output: "Error: command interrupted", isError: true });
|
|
13290
|
-
return;
|
|
13291
|
-
}
|
|
13292
|
-
ctx.abortSignal?.addEventListener("abort", onCallerAbort, { once: true });
|
|
13293
|
-
const evalPromise = runJavaScript(
|
|
13294
|
-
data.code,
|
|
13295
|
-
data.input,
|
|
13296
|
-
data.timeout_ms,
|
|
13297
|
-
data.memory_limit_mb,
|
|
13298
|
-
controller.signal
|
|
13299
|
-
);
|
|
13300
|
-
const foregroundKey = `js-${String(this.nextForegroundId++)}`;
|
|
13301
|
-
const settle = (finalResult) => {
|
|
13302
|
-
if (settled) {
|
|
13303
|
-
return;
|
|
13304
|
-
}
|
|
13305
|
-
settled = true;
|
|
13306
|
-
ctx.abortSignal?.removeEventListener("abort", onCallerAbort);
|
|
13307
|
-
this.foreground.delete(foregroundKey);
|
|
13308
|
-
resolve12(finalResult);
|
|
13309
|
-
};
|
|
13310
|
-
const backgroundExecution = (reason) => {
|
|
13311
|
-
if (backgrounded || settled || controller.signal.aborted || !manager || !backgroundAvailable) {
|
|
13312
|
-
return null;
|
|
13313
|
-
}
|
|
13314
|
-
backgrounded = true;
|
|
13315
|
-
settled = true;
|
|
13316
|
-
ctx.abortSignal?.removeEventListener("abort", onCallerAbort);
|
|
13317
|
-
this.foreground.delete(foregroundKey);
|
|
13318
|
-
const task = manager.create(
|
|
13319
|
-
backgroundTaskName(data.code),
|
|
13320
|
-
async (backgroundTask) => {
|
|
13321
|
-
const cap = (text) => text.length > BACKGROUND_NOTIFICATION_CHARS ? persistLargeResult(
|
|
13322
|
-
ctx.workDir,
|
|
13323
|
-
ctx.sessionId ?? "",
|
|
13324
|
-
`${backgroundTask.id}-${randomBytes4(4).toString("hex")}`,
|
|
13325
|
-
text
|
|
13326
|
-
) : text;
|
|
13327
|
-
try {
|
|
13328
|
-
const evaluation = await evalPromise;
|
|
13329
|
-
return cap(formatEvaluation(evaluation));
|
|
13330
|
-
} catch (error) {
|
|
13331
|
-
if (backgroundTask.status === "cancelled") {
|
|
13332
|
-
throw error;
|
|
13333
|
-
}
|
|
13334
|
-
throw new TaskFailure(cap(`Error executing JavaScript: ${asErrorString(error)}`));
|
|
13335
|
-
}
|
|
13336
|
-
},
|
|
13337
|
-
() => {
|
|
13338
|
-
controller.abort();
|
|
13339
|
-
},
|
|
13340
|
-
{ originToolCallId: ctx.toolCallId, idPrefix: "js", kind: "js" }
|
|
13341
|
-
);
|
|
13342
|
-
resolve12({
|
|
13343
|
-
output: jsBackgroundMessage(reason, task.id),
|
|
13344
|
-
isError: false
|
|
13345
|
-
});
|
|
13346
|
-
return task.id;
|
|
13347
|
-
};
|
|
13348
|
-
if (backgroundAvailable) {
|
|
13349
|
-
this.foreground.set(foregroundKey, {
|
|
13350
|
-
background: () => backgroundExecution("user") !== null
|
|
13351
|
-
});
|
|
13352
|
-
}
|
|
13353
|
-
evalPromise.then(
|
|
13354
|
-
(evaluation) => {
|
|
13355
|
-
settle({ output: formatEvaluation(evaluation), isError: false });
|
|
13356
|
-
},
|
|
13357
|
-
(error) => {
|
|
13358
|
-
settle({
|
|
13359
|
-
output: `Error executing JavaScript: ${asErrorString(error)}`,
|
|
13360
|
-
isError: true
|
|
13361
|
-
});
|
|
13362
|
-
}
|
|
13363
|
-
);
|
|
13364
|
-
backgroundFn = backgroundExecution;
|
|
13365
|
-
});
|
|
13366
|
-
return {
|
|
13367
|
-
result,
|
|
13368
|
-
background: (reason) => backgroundFn?.(reason) ?? null
|
|
13369
|
-
};
|
|
13370
|
-
}
|
|
13371
|
-
};
|
|
13372
|
-
|
|
13373
12982
|
// src/tools/web-fetch.ts
|
|
13374
12983
|
var web_fetch_exports = {};
|
|
13375
12984
|
__export(web_fetch_exports, {
|
|
@@ -13605,7 +13214,6 @@ function createToolRegistry(workDir, taskList) {
|
|
|
13605
13214
|
registry.register(new WriteFileTool());
|
|
13606
13215
|
registry.register(new GlobTool());
|
|
13607
13216
|
registry.register(new GrepTool());
|
|
13608
|
-
registry.register(new JavaScriptTool());
|
|
13609
13217
|
registry.register(new WebFetchTool());
|
|
13610
13218
|
return registry;
|
|
13611
13219
|
}
|
|
@@ -14377,20 +13985,20 @@ __export(manager_exports3, {
|
|
|
14377
13985
|
});
|
|
14378
13986
|
import { readFileSync as readFileSync17, writeFileSync as writeFileSync11, existsSync as existsSync18, mkdirSync as mkdirSync13 } from "fs";
|
|
14379
13987
|
import { join as join22 } from "path";
|
|
14380
|
-
import
|
|
13988
|
+
import z16 from "zod";
|
|
14381
13989
|
var log30 = createChildLogger({ module: "code-review" });
|
|
14382
|
-
var CodeReviewMemberSchema =
|
|
14383
|
-
name:
|
|
14384
|
-
email:
|
|
14385
|
-
role:
|
|
14386
|
-
expertise:
|
|
14387
|
-
active:
|
|
14388
|
-
});
|
|
14389
|
-
var CodeReviewTeamSchema =
|
|
14390
|
-
name:
|
|
14391
|
-
members:
|
|
14392
|
-
createdAt:
|
|
14393
|
-
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()
|
|
14394
14002
|
});
|
|
14395
14003
|
var CodeReviewManager = class {
|
|
14396
14004
|
teams = /* @__PURE__ */ new Map();
|
|
@@ -14568,11 +14176,11 @@ __export(usage_tracker_exports, {
|
|
|
14568
14176
|
});
|
|
14569
14177
|
import { readFileSync as readFileSync18, writeFileSync as writeFileSync12, mkdirSync as mkdirSync14, existsSync as existsSync19 } from "fs";
|
|
14570
14178
|
import { join as join23, dirname as dirname9 } from "path";
|
|
14571
|
-
import { safeParse as safeParse3, z as
|
|
14179
|
+
import { safeParse as safeParse3, z as z17 } from "zod";
|
|
14572
14180
|
var log31 = createChildLogger({ module: "commands" });
|
|
14573
|
-
var UsageEntrySchema =
|
|
14574
|
-
usageCount:
|
|
14575
|
-
lastUsedAt:
|
|
14181
|
+
var UsageEntrySchema = z17.object({
|
|
14182
|
+
usageCount: z17.coerce.number(),
|
|
14183
|
+
lastUsedAt: z17.coerce.number()
|
|
14576
14184
|
});
|
|
14577
14185
|
var CommandUsageTracker = class {
|
|
14578
14186
|
usage = /* @__PURE__ */ new Map();
|
|
@@ -14647,11 +14255,11 @@ __export(history_exports, {
|
|
|
14647
14255
|
});
|
|
14648
14256
|
import { readFileSync as readFileSync19, writeFileSync as writeFileSync13, mkdirSync as mkdirSync15, existsSync as existsSync20 } from "fs";
|
|
14649
14257
|
import { join as join24 } from "path";
|
|
14650
|
-
import { parse as parse8, z as
|
|
14258
|
+
import { parse as parse8, z as z18 } from "zod";
|
|
14651
14259
|
var log32 = createChildLogger({ module: "history" });
|
|
14652
14260
|
var MAX_HISTORY_ENTRIES = 200;
|
|
14653
14261
|
var FILENAME = "prompt_history.jsonl";
|
|
14654
|
-
var JSONLSchema =
|
|
14262
|
+
var JSONLSchema = z18.looseObject({ text: z18.string() });
|
|
14655
14263
|
function load(dir) {
|
|
14656
14264
|
const filePath = join24(dir, FILENAME);
|
|
14657
14265
|
if (!existsSync20(filePath)) {
|
|
@@ -14708,19 +14316,19 @@ __export(model_discovery_exports, {
|
|
|
14708
14316
|
discoverModels: () => discoverModels,
|
|
14709
14317
|
modelListUrl: () => modelListUrl
|
|
14710
14318
|
});
|
|
14711
|
-
import { z as
|
|
14319
|
+
import { z as z19 } from "zod";
|
|
14712
14320
|
var DISCOVERY_TIMEOUT_MS = 5e3;
|
|
14713
14321
|
var MAX_MODEL_PAGES = 10;
|
|
14714
|
-
var HttpUrlSchema =
|
|
14715
|
-
var ModelSchema =
|
|
14716
|
-
id:
|
|
14717
|
-
display_name:
|
|
14718
|
-
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()
|
|
14719
14327
|
});
|
|
14720
|
-
var ModelListSchema =
|
|
14721
|
-
data:
|
|
14722
|
-
has_more:
|
|
14723
|
-
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()
|
|
14724
14332
|
});
|
|
14725
14333
|
function modelListUrl(protocol, baseUrl) {
|
|
14726
14334
|
const parsed = HttpUrlSchema.safeParse(baseUrl);
|
|
@@ -15066,7 +14674,6 @@ __export(tools_exports3, {
|
|
|
15066
14674
|
Glob: () => glob_exports,
|
|
15067
14675
|
Grep: () => grep_exports,
|
|
15068
14676
|
IsDiffTool: () => is_diff_tool_exports,
|
|
15069
|
-
JavaScript: () => javascript_exports,
|
|
15070
14677
|
McpCall: () => mcp_call_exports,
|
|
15071
14678
|
PowerShell: () => powershell_exports,
|
|
15072
14679
|
ReadFile: () => read_file_exports,
|
|
@@ -15090,262 +14697,13 @@ function isDiffTool(toolName) {
|
|
|
15090
14697
|
return toolName === "EditFile";
|
|
15091
14698
|
}
|
|
15092
14699
|
|
|
15093
|
-
// src/
|
|
15094
|
-
var
|
|
15095
|
-
__export(
|
|
15096
|
-
|
|
15097
|
-
|
|
15098
|
-
|
|
15099
|
-
UseTeammateStates: () => use_teammate_states_exports
|
|
15100
|
-
});
|
|
15101
|
-
|
|
15102
|
-
// src/ui/styles.ts
|
|
15103
|
-
var styles_exports = {};
|
|
15104
|
-
__export(styles_exports, {
|
|
15105
|
-
DARK_THEME: () => DARK_THEME,
|
|
15106
|
-
ICONS: () => ICONS,
|
|
15107
|
-
LIGHT_THEME: () => LIGHT_THEME,
|
|
15108
|
-
THEME: () => THEME,
|
|
15109
|
-
activityStatusColor: () => activityStatusColor,
|
|
15110
|
-
setThemeMode: () => setThemeMode,
|
|
15111
|
-
thinkingLevelColor: () => thinkingLevelColor
|
|
15112
|
-
});
|
|
15113
|
-
var DARK_THEME = {
|
|
15114
|
-
accent: "#8abeb7",
|
|
15115
|
-
bashMode: "#b5bd68",
|
|
15116
|
-
border: "#5f87ff",
|
|
15117
|
-
borderAccent: "#00d7ff",
|
|
15118
|
-
borderMuted: "#505050",
|
|
15119
|
-
customMessageBg: "#2d2838",
|
|
15120
|
-
customMessageLabel: "#9575cd",
|
|
15121
|
-
dim: "#666666",
|
|
15122
|
-
error: "#cc6666",
|
|
15123
|
-
mdCode: "#8abeb7",
|
|
15124
|
-
mdCodeBlock: "#b5bd68",
|
|
15125
|
-
mdCodeBlockBorder: "#808080",
|
|
15126
|
-
mdHeading: "#f0c674",
|
|
15127
|
-
mdHr: "#808080",
|
|
15128
|
-
mdLink: "#81a2be",
|
|
15129
|
-
mdLinkUrl: "#666666",
|
|
15130
|
-
mdListBullet: "#8abeb7",
|
|
15131
|
-
mdQuote: "#808080",
|
|
15132
|
-
mdQuoteBorder: "#808080",
|
|
15133
|
-
muted: "#808080",
|
|
15134
|
-
searchMatchBg: "#3a3a4a",
|
|
15135
|
-
searchMatchText: "#d4d4d4",
|
|
15136
|
-
selectedBg: "#3a3a4a",
|
|
15137
|
-
success: "#b5bd68",
|
|
15138
|
-
syntaxComment: "#6A9955",
|
|
15139
|
-
syntaxFunction: "#DCDCAA",
|
|
15140
|
-
syntaxKeyword: "#569CD6",
|
|
15141
|
-
syntaxNumber: "#B5CEA8",
|
|
15142
|
-
syntaxOperator: "#D4D4D4",
|
|
15143
|
-
syntaxPunctuation: "#D4D4D4",
|
|
15144
|
-
syntaxString: "#CE9178",
|
|
15145
|
-
syntaxType: "#4EC9B0",
|
|
15146
|
-
syntaxVariable: "#9CDCFE",
|
|
15147
|
-
text: "#d4d4d4",
|
|
15148
|
-
thinking: "#808080",
|
|
15149
|
-
thinkingText: "#808080",
|
|
15150
|
-
thinkingHigh: "#b294bb",
|
|
15151
|
-
thinkingLow: "#5f87af",
|
|
15152
|
-
thinkingMax: "#ff5fff",
|
|
15153
|
-
thinkingMedium: "#81a2be",
|
|
15154
|
-
thinkingMinimal: "#6e6e6e",
|
|
15155
|
-
thinkingOff: "#505050",
|
|
15156
|
-
thinkingXHigh: "#d183e8",
|
|
15157
|
-
toolDiffAdded: "#b5bd68",
|
|
15158
|
-
toolDiffContext: "#808080",
|
|
15159
|
-
toolDiffRemoved: "#cc6666",
|
|
15160
|
-
toolErrorBg: "#3c2828",
|
|
15161
|
-
toolOutput: "#808080",
|
|
15162
|
-
toolPendingBg: "#282832",
|
|
15163
|
-
toolSuccessBg: "#283228",
|
|
15164
|
-
toolTitle: "#d4d4d4",
|
|
15165
|
-
customMessageText: "#d4d4d4",
|
|
15166
|
-
userMessageText: "#d4d4d4",
|
|
15167
|
-
userMessageBg: "#343541",
|
|
15168
|
-
warning: "#ffff00"
|
|
15169
|
-
};
|
|
15170
|
-
var LIGHT_THEME = {
|
|
15171
|
-
accent: "#5a8080",
|
|
15172
|
-
bashMode: "#588458",
|
|
15173
|
-
border: "#547da7",
|
|
15174
|
-
borderAccent: "#5a8080",
|
|
15175
|
-
borderMuted: "#b0b0b0",
|
|
15176
|
-
customMessageBg: "#ede7f6",
|
|
15177
|
-
customMessageLabel: "#7e57c2",
|
|
15178
|
-
dim: "#767676",
|
|
15179
|
-
error: "#aa5555",
|
|
15180
|
-
mdCode: "#5a8080",
|
|
15181
|
-
mdCodeBlock: "#588458",
|
|
15182
|
-
mdCodeBlockBorder: "#6c6c6c",
|
|
15183
|
-
mdHeading: "#9a7326",
|
|
15184
|
-
mdHr: "#6c6c6c",
|
|
15185
|
-
mdLink: "#547da7",
|
|
15186
|
-
mdLinkUrl: "#767676",
|
|
15187
|
-
mdListBullet: "#588458",
|
|
15188
|
-
mdQuote: "#6c6c6c",
|
|
15189
|
-
mdQuoteBorder: "#6c6c6c",
|
|
15190
|
-
muted: "#6c6c6c",
|
|
15191
|
-
searchMatchBg: "#d0d0e0",
|
|
15192
|
-
searchMatchText: "#1f2328",
|
|
15193
|
-
selectedBg: "#d0d0e0",
|
|
15194
|
-
success: "#588458",
|
|
15195
|
-
syntaxComment: "#008000",
|
|
15196
|
-
syntaxFunction: "#795E26",
|
|
15197
|
-
syntaxKeyword: "#0000FF",
|
|
15198
|
-
syntaxNumber: "#098658",
|
|
15199
|
-
syntaxOperator: "#000000",
|
|
15200
|
-
syntaxPunctuation: "#000000",
|
|
15201
|
-
syntaxString: "#A31515",
|
|
15202
|
-
syntaxType: "#267F99",
|
|
15203
|
-
syntaxVariable: "#001080",
|
|
15204
|
-
text: "#1f2328",
|
|
15205
|
-
thinking: "#6c6c6c",
|
|
15206
|
-
thinkingText: "#6c6c6c",
|
|
15207
|
-
thinkingHigh: "#875f87",
|
|
15208
|
-
thinkingLow: "#547da7",
|
|
15209
|
-
thinkingMax: "#af005f",
|
|
15210
|
-
thinkingMedium: "#5a8080",
|
|
15211
|
-
thinkingMinimal: "#767676",
|
|
15212
|
-
thinkingOff: "#b0b0b0",
|
|
15213
|
-
thinkingXHigh: "#8b008b",
|
|
15214
|
-
toolDiffAdded: "#588458",
|
|
15215
|
-
toolDiffContext: "#6c6c6c",
|
|
15216
|
-
toolDiffRemoved: "#aa5555",
|
|
15217
|
-
toolErrorBg: "#f0e8e8",
|
|
15218
|
-
toolOutput: "#6c6c6c",
|
|
15219
|
-
toolPendingBg: "#e8e8f0",
|
|
15220
|
-
toolSuccessBg: "#e8f0e8",
|
|
15221
|
-
toolTitle: "#1f2328",
|
|
15222
|
-
customMessageText: "#1f2328",
|
|
15223
|
-
userMessageText: "#1f2328",
|
|
15224
|
-
userMessageBg: "#e8e8e8",
|
|
15225
|
-
warning: "#9a7326"
|
|
15226
|
-
};
|
|
15227
|
-
var THEME = { ...DARK_THEME };
|
|
15228
|
-
function setThemeMode(mode) {
|
|
15229
|
-
Object.assign(THEME, mode === "light" ? LIGHT_THEME : DARK_THEME);
|
|
15230
|
-
}
|
|
15231
|
-
function thinkingLevelColor(level) {
|
|
15232
|
-
switch (level) {
|
|
15233
|
-
case "off":
|
|
15234
|
-
return THEME.thinkingOff;
|
|
15235
|
-
case "minimal":
|
|
15236
|
-
return THEME.thinkingMinimal;
|
|
15237
|
-
case "low":
|
|
15238
|
-
return THEME.thinkingLow;
|
|
15239
|
-
case "medium":
|
|
15240
|
-
return THEME.thinkingMedium;
|
|
15241
|
-
case "high":
|
|
15242
|
-
return THEME.thinkingHigh;
|
|
15243
|
-
case "xhigh":
|
|
15244
|
-
return THEME.thinkingXHigh;
|
|
15245
|
-
case "max":
|
|
15246
|
-
return THEME.thinkingMax;
|
|
15247
|
-
}
|
|
15248
|
-
}
|
|
15249
|
-
function activityStatusColor(status) {
|
|
15250
|
-
switch (status) {
|
|
15251
|
-
case "working":
|
|
15252
|
-
return THEME.thinkingHigh;
|
|
15253
|
-
case "retry":
|
|
15254
|
-
return THEME.warning;
|
|
15255
|
-
case "compacting":
|
|
15256
|
-
return THEME.accent;
|
|
15257
|
-
case "error":
|
|
15258
|
-
return THEME.error;
|
|
15259
|
-
case "idle":
|
|
15260
|
-
return THEME.borderMuted;
|
|
15261
|
-
}
|
|
15262
|
-
}
|
|
15263
|
-
var ICONS = {
|
|
15264
|
-
active: "\u25C9",
|
|
15265
|
-
arrow: "\u2192",
|
|
15266
|
-
branch: "\u251C\u2500",
|
|
15267
|
-
collapsed: "\u229E",
|
|
15268
|
-
expanded: "\u229F",
|
|
15269
|
-
inactive: "\u25CB",
|
|
15270
|
-
lastBranch: "\u2514\u2500",
|
|
15271
|
-
prompt: ">",
|
|
15272
|
-
success: "\u2713",
|
|
15273
|
-
tree: "\u2502"
|
|
15274
|
-
};
|
|
15275
|
-
|
|
15276
|
-
// src/ui/use-follow-up-queue.ts
|
|
15277
|
-
var use_follow_up_queue_exports = {};
|
|
15278
|
-
__export(use_follow_up_queue_exports, {
|
|
15279
|
-
useFollowUpQueue: () => useFollowUpQueue
|
|
15280
|
-
});
|
|
15281
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
15282
|
-
function useFollowUpQueue({ blocked, send, onError }) {
|
|
15283
|
-
const pending = useRef([]);
|
|
15284
|
-
const active = useRef(false);
|
|
15285
|
-
const mounted = useRef(true);
|
|
15286
|
-
const callbacks = useRef({ send, onError });
|
|
15287
|
-
callbacks.current = { send, onError };
|
|
15288
|
-
const [messages, setMessages] = useState([]);
|
|
15289
|
-
const [processing, setProcessing] = useState(false);
|
|
15290
|
-
const [paused, setPaused] = useState(false);
|
|
15291
|
-
useEffect(() => {
|
|
15292
|
-
mounted.current = true;
|
|
15293
|
-
return () => {
|
|
15294
|
-
mounted.current = false;
|
|
15295
|
-
};
|
|
15296
|
-
}, []);
|
|
15297
|
-
const enqueue = useCallback((message) => {
|
|
15298
|
-
if (!message.trim()) {
|
|
15299
|
-
return;
|
|
15300
|
-
}
|
|
15301
|
-
pending.current = [...pending.current, message];
|
|
15302
|
-
setMessages(pending.current);
|
|
15303
|
-
setPaused(false);
|
|
15304
|
-
}, []);
|
|
15305
|
-
const takeLast = useCallback(() => {
|
|
15306
|
-
const message = pending.current.at(-1);
|
|
15307
|
-
if (message === void 0) {
|
|
15308
|
-
return void 0;
|
|
15309
|
-
}
|
|
15310
|
-
pending.current = pending.current.slice(0, -1);
|
|
15311
|
-
setMessages(pending.current);
|
|
15312
|
-
return message;
|
|
15313
|
-
}, []);
|
|
15314
|
-
useEffect(() => {
|
|
15315
|
-
if (blocked || paused || active.current || pending.current.length === 0) {
|
|
15316
|
-
return;
|
|
15317
|
-
}
|
|
15318
|
-
const next = pending.current[0];
|
|
15319
|
-
pending.current = pending.current.slice(1);
|
|
15320
|
-
active.current = true;
|
|
15321
|
-
setMessages(pending.current);
|
|
15322
|
-
setProcessing(true);
|
|
15323
|
-
void (async () => {
|
|
15324
|
-
try {
|
|
15325
|
-
await callbacks.current.send(next);
|
|
15326
|
-
} catch (error) {
|
|
15327
|
-
if (mounted.current) {
|
|
15328
|
-
setPaused(true);
|
|
15329
|
-
callbacks.current.onError(error);
|
|
15330
|
-
}
|
|
15331
|
-
} finally {
|
|
15332
|
-
active.current = false;
|
|
15333
|
-
if (mounted.current) {
|
|
15334
|
-
setProcessing(false);
|
|
15335
|
-
}
|
|
15336
|
-
}
|
|
15337
|
-
})();
|
|
15338
|
-
}, [blocked, messages, paused, processing]);
|
|
15339
|
-
return { messages, enqueue, takeLast, processing, paused };
|
|
15340
|
-
}
|
|
15341
|
-
|
|
15342
|
-
// src/ui/use-ide-input.ts
|
|
15343
|
-
var use_ide_input_exports = {};
|
|
15344
|
-
__export(use_ide_input_exports, {
|
|
15345
|
-
useIdeInput: () => useIdeInput
|
|
14700
|
+
// src/vscode/index.ts
|
|
14701
|
+
var vscode_exports = {};
|
|
14702
|
+
__export(vscode_exports, {
|
|
14703
|
+
IdeClient: () => ide_client_exports,
|
|
14704
|
+
Lockfile: () => lockfile_exports,
|
|
14705
|
+
WsTransport: () => ws_transport_exports
|
|
15346
14706
|
});
|
|
15347
|
-
import { relative as relative4 } from "path";
|
|
15348
|
-
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
15349
14707
|
|
|
15350
14708
|
// src/vscode/ide-client.ts
|
|
15351
14709
|
var ide_client_exports = {};
|
|
@@ -15354,7 +14712,7 @@ __export(ide_client_exports, {
|
|
|
15354
14712
|
});
|
|
15355
14713
|
import { setTimeout as delay2 } from "timers/promises";
|
|
15356
14714
|
import { Client as Client2 } from "@modelcontextprotocol/sdk/client/index.js";
|
|
15357
|
-
import { z as
|
|
14715
|
+
import { z as z21 } from "zod";
|
|
15358
14716
|
|
|
15359
14717
|
// src/vscode/lockfile.ts
|
|
15360
14718
|
var lockfile_exports = {};
|
|
@@ -15364,14 +14722,14 @@ __export(lockfile_exports, {
|
|
|
15364
14722
|
import { readdir as readdir2, readFile as readFile5 } from "fs/promises";
|
|
15365
14723
|
import { homedir as homedir10 } from "os";
|
|
15366
14724
|
import { join as join26, resolve as resolve11, sep as sep2 } from "path";
|
|
15367
|
-
import { z as
|
|
14725
|
+
import { z as z20 } from "zod";
|
|
15368
14726
|
var log34 = createChildLogger({ module: "vscode" });
|
|
15369
|
-
var LockfileSchema =
|
|
15370
|
-
workspaceFolders:
|
|
15371
|
-
pid:
|
|
15372
|
-
ideName:
|
|
15373
|
-
transport:
|
|
15374
|
-
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()
|
|
15375
14733
|
});
|
|
15376
14734
|
function ideLockDir() {
|
|
15377
14735
|
const configDir = process.env.CLAUDE_CONFIG_DIR ?? join26(homedir10(), ".claude");
|
|
@@ -15528,12 +14886,12 @@ var WebSocketTransport = class {
|
|
|
15528
14886
|
|
|
15529
14887
|
// src/vscode/ide-client.ts
|
|
15530
14888
|
var log35 = createChildLogger({ module: "vscode" });
|
|
15531
|
-
var AtMentionedSchema =
|
|
15532
|
-
method:
|
|
15533
|
-
params:
|
|
15534
|
-
filePath:
|
|
15535
|
-
lineStart:
|
|
15536
|
-
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()
|
|
15537
14895
|
})
|
|
15538
14896
|
});
|
|
15539
14897
|
function inIdeTerminal() {
|
|
@@ -15610,81 +14968,6 @@ async function connectToIde(opts) {
|
|
|
15610
14968
|
};
|
|
15611
14969
|
}
|
|
15612
14970
|
|
|
15613
|
-
// src/ui/use-ide-input.ts
|
|
15614
|
-
function useIdeInput(workDir) {
|
|
15615
|
-
const insertInputTextRef = useRef2(null);
|
|
15616
|
-
const clearInputRef = useRef2(null);
|
|
15617
|
-
useEffect2(() => {
|
|
15618
|
-
let connection = null;
|
|
15619
|
-
let cancelled = false;
|
|
15620
|
-
const controller = new AbortController();
|
|
15621
|
-
void connectToIde({
|
|
15622
|
-
cwd: workDir,
|
|
15623
|
-
signal: controller.signal,
|
|
15624
|
-
onAtMentioned: ({ filePath, lineStart, lineEnd }) => {
|
|
15625
|
-
const rel = relative4(workDir, filePath);
|
|
15626
|
-
const shown = rel && !rel.startsWith("..") ? rel : filePath;
|
|
15627
|
-
let mention = `@${shown}`;
|
|
15628
|
-
if (lineStart !== void 0) {
|
|
15629
|
-
mention += `#L${String(lineStart)}`;
|
|
15630
|
-
if (lineEnd !== void 0 && lineEnd !== lineStart) {
|
|
15631
|
-
mention += `-${String(lineEnd)}`;
|
|
15632
|
-
}
|
|
15633
|
-
}
|
|
15634
|
-
insertInputTextRef.current?.(mention + " ");
|
|
15635
|
-
}
|
|
15636
|
-
}).then((connected) => {
|
|
15637
|
-
if (!connected) {
|
|
15638
|
-
return;
|
|
15639
|
-
}
|
|
15640
|
-
if (cancelled) {
|
|
15641
|
-
void connected.close();
|
|
15642
|
-
return;
|
|
15643
|
-
}
|
|
15644
|
-
connection = connected;
|
|
15645
|
-
});
|
|
15646
|
-
return () => {
|
|
15647
|
-
cancelled = true;
|
|
15648
|
-
controller.abort();
|
|
15649
|
-
void connection?.close();
|
|
15650
|
-
};
|
|
15651
|
-
}, [workDir]);
|
|
15652
|
-
return { insertInputTextRef, clearInputRef };
|
|
15653
|
-
}
|
|
15654
|
-
|
|
15655
|
-
// src/ui/use-teammate-states.ts
|
|
15656
|
-
var use_teammate_states_exports = {};
|
|
15657
|
-
__export(use_teammate_states_exports, {
|
|
15658
|
-
useTeammateStates: () => useTeammateStates
|
|
15659
|
-
});
|
|
15660
|
-
import { useEffect as useEffect3, useState as useState2 } from "react";
|
|
15661
|
-
function useTeammateStates(manager) {
|
|
15662
|
-
const [states, setStates] = useState2([]);
|
|
15663
|
-
useEffect3(() => {
|
|
15664
|
-
let signature = "";
|
|
15665
|
-
const timer = setInterval(() => {
|
|
15666
|
-
const next = manager.getAllTeammateStates();
|
|
15667
|
-
const nextSignature = JSON.stringify(next);
|
|
15668
|
-
if (nextSignature !== signature) {
|
|
15669
|
-
signature = nextSignature;
|
|
15670
|
-
setStates(next);
|
|
15671
|
-
}
|
|
15672
|
-
}, 500);
|
|
15673
|
-
return () => {
|
|
15674
|
-
clearInterval(timer);
|
|
15675
|
-
};
|
|
15676
|
-
}, [manager]);
|
|
15677
|
-
return states;
|
|
15678
|
-
}
|
|
15679
|
-
|
|
15680
|
-
// src/vscode/index.ts
|
|
15681
|
-
var vscode_exports = {};
|
|
15682
|
-
__export(vscode_exports, {
|
|
15683
|
-
IdeClient: () => ide_client_exports,
|
|
15684
|
-
Lockfile: () => lockfile_exports,
|
|
15685
|
-
WsTransport: () => ws_transport_exports
|
|
15686
|
-
});
|
|
15687
|
-
|
|
15688
14971
|
// src/print-mode.ts
|
|
15689
14972
|
var print_mode_exports = {};
|
|
15690
14973
|
__export(print_mode_exports, {
|
|
@@ -16303,7 +15586,6 @@ export {
|
|
|
16303
15586
|
todo_exports as Todo,
|
|
16304
15587
|
tool_result_exports as ToolResult,
|
|
16305
15588
|
tools_exports3 as Tools,
|
|
16306
|
-
ui_exports as UI,
|
|
16307
15589
|
utils_exports as Utils,
|
|
16308
15590
|
vscode_exports as VSCode,
|
|
16309
15591
|
version_exports as Version,
|