vanspod 0.4.15 → 0.4.16
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 +4 -4
- package/dist/classroomApp.js +55 -11
- package/dist/codexWebSearch.js +1 -1
- package/dist/deviceConnection.js +13 -2
- package/dist/html.js +12 -0
- package/dist/localCommands.js +82 -119
- package/dist/localToolApproval.js +81 -4
- package/dist/localTools.js +31 -8
- package/dist/modelStatus.js +8 -12
- package/dist/page.js +278 -124
- package/dist/remoteAgentLog.js +126 -0
- package/dist/remoteAgentLogView.js +421 -0
- package/dist/saveImage.js +26 -0
- package/dist/settingsActions.js +1 -1
- package/dist/start.js +59 -10
- package/dist/trayChannel.js +25 -6
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/scripts/tray.ps1 +141 -11
package/dist/localTools.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.localSystem = exports.MAX_READ_CHARS = exports.NO_PROJECT_FOLDER_NOTE = void 0;
|
|
7
7
|
exports.createLocalTools = createLocalTools;
|
|
8
8
|
exports.findGitBash = findGitBash;
|
|
9
|
-
// The Local Tools that a Device answers for Agent
|
|
9
|
+
// The Local Tools that a Device answers for a Remote Agent (ADR 0013).
|
|
10
10
|
// A tool that is not built yet answers `unknown_tool`.
|
|
11
11
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
12
12
|
const node_os_1 = __importDefault(require("node:os"));
|
|
@@ -15,6 +15,7 @@ const lineChanges_1 = require("./lineChanges");
|
|
|
15
15
|
const localCommands_1 = require("./localCommands");
|
|
16
16
|
const localToolApproval_1 = require("./localToolApproval");
|
|
17
17
|
const projectPath_1 = require("./projectPath");
|
|
18
|
+
const remoteAgentLog_1 = require("./remoteAgentLog");
|
|
18
19
|
const saveImage_1 = require("./saveImage");
|
|
19
20
|
const systemPath_1 = require("./systemPath");
|
|
20
21
|
const windowsEnvironmentSystem_1 = require("./windowsEnvironmentSystem");
|
|
@@ -116,17 +117,24 @@ async function writeFile(projectFolder, args, signal, context) {
|
|
|
116
117
|
return target;
|
|
117
118
|
let title = `寫入新檔案 ${target.relative}`;
|
|
118
119
|
let body = content;
|
|
120
|
+
let before;
|
|
119
121
|
if (target.exists) {
|
|
120
122
|
if ((await promises_1.default.stat(target.absolute)).isDirectory()) {
|
|
121
123
|
return { ok: false, error: "invalid_arguments", message: `「${target.relative}」是資料夾,不能寫成檔案。` };
|
|
122
124
|
}
|
|
123
125
|
const old = await promises_1.default.readFile(target.absolute);
|
|
124
126
|
title = `修改檔案 ${target.relative}`;
|
|
125
|
-
|
|
127
|
+
before = old.includes(0) ? undefined : old.toString("utf8");
|
|
128
|
+
body = before === undefined
|
|
126
129
|
? `(原本不是文字檔,整個檔案會換成下面的內容)\n${content}`
|
|
127
|
-
: (0, lineChanges_1.lineChanges)(
|
|
130
|
+
: (0, lineChanges_1.lineChanges)(before, content);
|
|
131
|
+
context.call.wrote(content, before, false);
|
|
128
132
|
}
|
|
129
|
-
|
|
133
|
+
else {
|
|
134
|
+
context.call.wrote(content, undefined, true);
|
|
135
|
+
}
|
|
136
|
+
const contents = before === undefined ? [content] : [content, before];
|
|
137
|
+
const refusal = await (0, localToolApproval_1.askApproval)(context.approver, { tool: "write_file", title, body, target: target.relative, folder: projectFolder, contents }, signal, NOT_WRITTEN);
|
|
130
138
|
if (refusal)
|
|
131
139
|
return refusal;
|
|
132
140
|
// Resolve again: the folder may have changed while the student decided.
|
|
@@ -150,9 +158,22 @@ const PROJECT_TOOLS = {
|
|
|
150
158
|
bash: localCommands_1.bashTool,
|
|
151
159
|
save_image: saveImage_1.saveImage,
|
|
152
160
|
};
|
|
161
|
+
/** The path or the command of a call, for the Remote Agent Log. */
|
|
162
|
+
function callTarget(tool, args) {
|
|
163
|
+
const text = (value) => typeof value === "string" ? value : "";
|
|
164
|
+
if (tool === "bash")
|
|
165
|
+
return text(args.command);
|
|
166
|
+
if (tool === "list_files")
|
|
167
|
+
return text(args.path ?? ".");
|
|
168
|
+
if (tool === "save_image")
|
|
169
|
+
return `images/${text(args.file_name)}`;
|
|
170
|
+
if (tool === "local_status")
|
|
171
|
+
return "";
|
|
172
|
+
return text(args.path);
|
|
173
|
+
}
|
|
153
174
|
function createLocalTools(options) {
|
|
154
|
-
const
|
|
155
|
-
return
|
|
175
|
+
const log = options.log ?? (0, remoteAgentLog_1.createRemoteAgentLog)();
|
|
176
|
+
return (tool, args, signal) => log.record(tool, callTarget(tool, args), async (call) => {
|
|
156
177
|
if (tool === "local_status")
|
|
157
178
|
return localStatus(options);
|
|
158
179
|
const projectTool = Object.hasOwn(PROJECT_TOOLS, tool) ? PROJECT_TOOLS[tool] : undefined;
|
|
@@ -160,10 +181,12 @@ function createLocalTools(options) {
|
|
|
160
181
|
const folder = options.projectFolder();
|
|
161
182
|
if (!folder)
|
|
162
183
|
return { ok: false, error: "no_project_folder", message: exports.NO_PROJECT_FOLDER_NOTE };
|
|
163
|
-
|
|
184
|
+
// The entry keeps how each Local Tool Approval ended.
|
|
185
|
+
const approver = { request: (request, abort) => call.ask(options.approver, request, abort) };
|
|
186
|
+
return projectTool(folder, args, signal, { approver, call, gitBash: () => options.system.gitBash() });
|
|
164
187
|
}
|
|
165
188
|
return { ok: false, error: "unknown_tool", message: `這台電腦的 VansPod 不認識工具「${tool}」,請更新 VansPod。` };
|
|
166
|
-
};
|
|
189
|
+
});
|
|
167
190
|
}
|
|
168
191
|
function osName() {
|
|
169
192
|
const release = node_os_1.default.release();
|
package/dist/modelStatus.js
CHANGED
|
@@ -16,18 +16,12 @@ exports.modelStatusScript = `
|
|
|
16
16
|
}
|
|
17
17
|
function applyModelStatus(status) {
|
|
18
18
|
if (status.localTools) {
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
localSwitch.textContent = status.localTools.on ? "開" : "關";
|
|
26
|
-
localSwitch.classList.toggle("on", status.localTools.on);
|
|
27
|
-
}
|
|
28
|
-
var commandList = document.querySelector("[data-local-commands]");
|
|
29
|
-
var commands = status.localTools.commands;
|
|
30
|
-
if (commandList && commands && (commandList.getAttribute("data-commands-key") || "") !== commands.key) commandList.outerHTML = commands.html;
|
|
19
|
+
var statusBar = document.querySelector("[data-remote-status]");
|
|
20
|
+
var remoteStatus = status.localTools.status;
|
|
21
|
+
if (statusBar && remoteStatus && (statusBar.getAttribute("data-status-key") || "") !== remoteStatus.key) statusBar.outerHTML = remoteStatus.html;
|
|
22
|
+
var logList = document.querySelector("[data-log-list]");
|
|
23
|
+
var log = status.localTools.log;
|
|
24
|
+
if (logList && log && (logList.getAttribute("data-log-key") || "") !== log.key && typeof replaceRemoteAgentLog === "function") replaceRemoteAgentLog(log);
|
|
31
25
|
var approvalBlock = document.querySelector("[data-local-approval]");
|
|
32
26
|
if (approvalBlock) {
|
|
33
27
|
var approval = status.localTools.approval;
|
|
@@ -36,6 +30,8 @@ exports.modelStatusScript = `
|
|
|
36
30
|
} else if (approval) {
|
|
37
31
|
var seconds = approvalBlock.querySelector("[data-approval-seconds]");
|
|
38
32
|
if (seconds) seconds.textContent = String(approval.secondsLeft);
|
|
33
|
+
var bar = approvalBlock.querySelector("[data-approval-bar]");
|
|
34
|
+
if (bar) bar.style.width = approval.bar;
|
|
39
35
|
}
|
|
40
36
|
}
|
|
41
37
|
}
|