palmier 1.1.4 → 1.1.6
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/agents/kimi.js +2 -1
- package/dist/rpc-handler.js +3 -2
- package/dist/spawn-command.d.ts +9 -0
- package/dist/spawn-command.js +43 -7
- package/package.json +1 -1
package/dist/agents/kimi.js
CHANGED
|
@@ -4,7 +4,8 @@ export const kimiAgent = {
|
|
|
4
4
|
command: "kimi",
|
|
5
5
|
promptArgs: ["-p"],
|
|
6
6
|
probeArg: "--version",
|
|
7
|
-
supportsYolo:
|
|
7
|
+
supportsYolo: false,
|
|
8
|
+
npmPackage: "@moonshot-ai/kimi-code",
|
|
8
9
|
getTaskRunCommandLine(task, followupPrompt, extraPermissions) {
|
|
9
10
|
const yolo = extraPermissions === "yolo";
|
|
10
11
|
const prompt = followupPrompt ?? getAgentInstructions(task);
|
package/dist/rpc-handler.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as path from "path";
|
|
|
4
4
|
import { listTasks, parseTaskFile, writeTaskFile, getTaskDir, readTaskStatus, writeTaskStatus, readHistory, deleteHistoryEntry, appendTaskList, removeFromTaskList, isTaskInList, appendHistory, createRunDir, appendRunMessage, getRunDir, writeFollowupStatus, readFollowupStatus, deleteFollowupStatus, isRunStarred, setRunStarred } from "./task.js";
|
|
5
5
|
import { resolvePending, getPending, listPending } from "./pending-requests.js";
|
|
6
6
|
import { getPlatform } from "./platform/index.js";
|
|
7
|
-
import { spawnCommand } from "./spawn-command.js";
|
|
7
|
+
import { resolveCommand, spawnCommand } from "./spawn-command.js";
|
|
8
8
|
import crossSpawn from "cross-spawn";
|
|
9
9
|
import { getAgent, getPromptCommandLine, getNpmInstalledVersion } from "./agents/agent.js";
|
|
10
10
|
import { validateClient, revokeClient } from "./client-store.js";
|
|
@@ -404,7 +404,8 @@ export function createRpcHandler(config, nc) {
|
|
|
404
404
|
for (const f of followupFiles)
|
|
405
405
|
fs.writeFileSync(path.join(followupRunDir, f.path), f.content, "utf-8");
|
|
406
406
|
}
|
|
407
|
-
const
|
|
407
|
+
const resolved = resolveCommand(cmd, cmdArgs);
|
|
408
|
+
const child = crossSpawn(resolved.command, resolved.args, {
|
|
408
409
|
cwd: followupRunDir,
|
|
409
410
|
stdio: [stdin != null ? "pipe" : "ignore", "pipe", "pipe"],
|
|
410
411
|
env: { ...process.env, ...followupAgentEnv },
|
package/dist/spawn-command.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { type ChildProcess } from "child_process";
|
|
2
|
+
/**
|
|
3
|
+
* cross-spawn runs Windows .cmd shims through cmd.exe, which caps the command
|
|
4
|
+
* line at 8191 chars and can't carry newlines. For npm-installed CLIs, run the
|
|
5
|
+
* shim's node script directly so long multi-line prompts survive intact.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveCommand(command: string, args: string[]): {
|
|
8
|
+
command: string;
|
|
9
|
+
args: string[];
|
|
10
|
+
};
|
|
2
11
|
export interface SpawnStreamingOptions {
|
|
3
12
|
cwd: string;
|
|
4
13
|
env?: Record<string, string>;
|
package/dist/spawn-command.js
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
import crossSpawn from "cross-spawn";
|
|
2
2
|
import { execFileSync } from "child_process";
|
|
3
|
+
import * as fs from "fs";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
const NPM_NODE_SHIM_TARGET = /"%_prog%"\s+"%dp0%\\([^"]+)"\s+%\*\s*$/;
|
|
6
|
+
/**
|
|
7
|
+
* cross-spawn runs Windows .cmd shims through cmd.exe, which caps the command
|
|
8
|
+
* line at 8191 chars and can't carry newlines. For npm-installed CLIs, run the
|
|
9
|
+
* shim's node script directly so long multi-line prompts survive intact.
|
|
10
|
+
*/
|
|
11
|
+
export function resolveCommand(command, args) {
|
|
12
|
+
if (process.platform !== "win32")
|
|
13
|
+
return { command, args };
|
|
14
|
+
const shim = findNpmNodeShim(command);
|
|
15
|
+
if (shim)
|
|
16
|
+
return { command: shim.node, args: [shim.script, ...args] };
|
|
17
|
+
return { command, args: args.map((a) => a.replace(/[\r\n]+/g, " ")) };
|
|
18
|
+
}
|
|
19
|
+
function findNpmNodeShim(command) {
|
|
20
|
+
if (path.basename(command) !== command || path.extname(command))
|
|
21
|
+
return null;
|
|
22
|
+
const exts = (process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
|
|
23
|
+
for (const dir of (process.env.PATH ?? "").split(path.delimiter).filter(Boolean)) {
|
|
24
|
+
for (const ext of exts) {
|
|
25
|
+
const candidate = path.join(dir, command + ext);
|
|
26
|
+
if (!fs.existsSync(candidate))
|
|
27
|
+
continue;
|
|
28
|
+
if (ext.toLowerCase() !== ".cmd")
|
|
29
|
+
return null;
|
|
30
|
+
const match = fs.readFileSync(candidate, "utf-8").match(NPM_NODE_SHIM_TARGET);
|
|
31
|
+
if (!match)
|
|
32
|
+
return null;
|
|
33
|
+
const localNode = path.join(dir, "node.exe");
|
|
34
|
+
return {
|
|
35
|
+
node: fs.existsSync(localNode) ? localNode : process.execPath,
|
|
36
|
+
script: path.join(dir, match[1]),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
3
42
|
/** Kill a child process and its entire tree on Windows; plain kill elsewhere. */
|
|
4
43
|
function treeKill(child) {
|
|
5
44
|
if (process.platform === "win32" && child.pid) {
|
|
@@ -30,14 +69,11 @@ export function spawnStreamingCommand(command, opts) {
|
|
|
30
69
|
}
|
|
31
70
|
export function spawnCommand(command, args, opts) {
|
|
32
71
|
return new Promise((resolve, reject) => {
|
|
33
|
-
|
|
34
|
-
const finalArgs = process.platform === "win32"
|
|
35
|
-
? args.map((a) => a.replace(/[\r\n]+/g, " "))
|
|
36
|
-
: args;
|
|
72
|
+
const resolved = resolveCommand(command, args);
|
|
37
73
|
const truncate = (s, max = 100) => s.length > max ? s.slice(0, max) + "..." : s;
|
|
38
|
-
const displayArgs =
|
|
39
|
-
console.log(`[spawn] ${command} ${displayArgs.join(" ")}`);
|
|
40
|
-
const child = crossSpawn(command,
|
|
74
|
+
const displayArgs = resolved.args.map((arg) => truncate(arg));
|
|
75
|
+
console.log(`[spawn] ${resolved.command} ${displayArgs.join(" ")}`);
|
|
76
|
+
const child = crossSpawn(resolved.command, resolved.args, {
|
|
41
77
|
cwd: opts.cwd,
|
|
42
78
|
stdio: [opts.stdin != null ? "pipe" : "ignore", "pipe", "pipe"],
|
|
43
79
|
env: opts.env ? { ...process.env, ...opts.env } : undefined,
|