@getpaseo/plugin 0.11.0-beta.4 → 0.11.0-beta.5
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/server/acp-internal/connection.js +5 -5
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -1
- package/dist/server/process-internal/windows-command.d.ts +15 -0
- package/dist/server/process-internal/windows-command.js +41 -0
- package/dist/server/process.d.ts +25 -0
- package/dist/server/process.js +71 -0
- package/dist/server/usage.d.ts +2 -0
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawnProcess, terminateProcess } from "../process.js";
|
|
2
2
|
import { Readable, Writable } from "node:stream";
|
|
3
3
|
import { ClientSideConnection, CLIENT_METHODS, PROTOCOL_VERSION, ndJsonStream, } from "@agentclientprotocol/sdk";
|
|
4
4
|
import { z } from "zod";
|
|
@@ -269,9 +269,9 @@ class AcpRuntime {
|
|
|
269
269
|
args: options.options.command.slice(1),
|
|
270
270
|
env: process.env,
|
|
271
271
|
};
|
|
272
|
-
child =
|
|
272
|
+
child = spawnProcess(launch.command, launch.args, {
|
|
273
273
|
env: { ...launch.env, ...options.env },
|
|
274
|
-
stdio:
|
|
274
|
+
stdio: "pipe",
|
|
275
275
|
});
|
|
276
276
|
spawnFailure = new Promise((_resolve, reject) => child.once("error", reject));
|
|
277
277
|
child.stderr.on("data", () => undefined);
|
|
@@ -587,10 +587,10 @@ class AcpRuntime {
|
|
|
587
587
|
if (child.exitCode !== null || child.signalCode !== null)
|
|
588
588
|
return;
|
|
589
589
|
const closed = new Promise((resolve) => child.once("close", () => resolve()));
|
|
590
|
-
child
|
|
590
|
+
await terminateProcess(child, "SIGTERM");
|
|
591
591
|
if (await settlesWithin(closed, 1000))
|
|
592
592
|
return;
|
|
593
|
-
child
|
|
593
|
+
await terminateProcess(child);
|
|
594
594
|
if (!(await settlesWithin(closed, 1000))) {
|
|
595
595
|
throw new Error(`ACP provider ${this.options.options.id} did not terminate after SIGKILL`);
|
|
596
596
|
}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { UsageSourceRegistration, UsageReport, UsageWindow, UsageBalance, UsageDetail, } from "./usage.js";
|
|
2
2
|
export type { PluginHandlerContext, PluginServerContext, PluginServerContribution, PluginSettings, PluginSettingsState, } from "./contracts.js";
|
|
3
3
|
export type { PluginHookContext, PluginHookWorkspace, PluginHookAgent, PluginSessionOpenRequest, PluginTurnOutcome, PluginLifecycleEvents, PluginBeforeRequests, PluginLifecycleRegistration, } from "./lifecycle.js";
|
|
4
|
+
export { spawnProcess, execCommand, terminateProcess } from "./process.js";
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/server/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { spawnProcess, execCommand, terminateProcess } from "./process.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function isWindowsCommandScript(executablePath: string): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* When spawning with `shell: true` on Windows, the command is passed to
|
|
4
|
+
* `cmd.exe /d /s /c "command args"`. The `/s` strips outer quotes, so a
|
|
5
|
+
* command path with spaces (e.g. `C:\Program Files\...`) is split at the
|
|
6
|
+
* space. Wrapping it in quotes produces the correct `"C:\Program Files\..." args`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function quoteWindowsCommand(command: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* `spawn(..., { shell: true })` on Windows also passes argv through `cmd.exe`.
|
|
11
|
+
* Any argument containing spaces must be quoted or it will be split before the
|
|
12
|
+
* child process sees it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function quoteWindowsArgument(argument: string): string;
|
|
15
|
+
//# sourceMappingURL=windows-command.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { extname } from "node:path";
|
|
2
|
+
export function isWindowsCommandScript(executablePath) {
|
|
3
|
+
const extension = extname(executablePath).toLowerCase();
|
|
4
|
+
return process.platform === "win32" && (extension === ".cmd" || extension === ".bat");
|
|
5
|
+
}
|
|
6
|
+
function escapeWindowsCmdValue(value) {
|
|
7
|
+
if (process.platform !== "win32")
|
|
8
|
+
return value;
|
|
9
|
+
const isQuoted = value.startsWith('"') && value.endsWith('"');
|
|
10
|
+
const unquoted = isQuoted ? value.slice(1, -1) : value;
|
|
11
|
+
// Do NOT double `%` here. cmd.exe only collapses `%%` → `%` inside batch
|
|
12
|
+
// files; on the command line / `cmd /c "..."` `%%` stays literal, which
|
|
13
|
+
// breaks args like git's `--format=%(refname)` (git treats `%%` as the
|
|
14
|
+
// escape for a literal `%`, so the format atoms become literals).
|
|
15
|
+
const escaped = unquoted.replace(/([&|^<>()!])/g, "^$1");
|
|
16
|
+
if (isQuoted || /[\s"]/u.test(unquoted)) {
|
|
17
|
+
const quoted = escaped
|
|
18
|
+
.replace(/(\\*)"/g, (_match, slashes) => `${slashes}${slashes}\\"`)
|
|
19
|
+
.replace(/\\+$/u, (slashes) => `${slashes}${slashes}`);
|
|
20
|
+
return `"${quoted}"`;
|
|
21
|
+
}
|
|
22
|
+
return escaped;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* When spawning with `shell: true` on Windows, the command is passed to
|
|
26
|
+
* `cmd.exe /d /s /c "command args"`. The `/s` strips outer quotes, so a
|
|
27
|
+
* command path with spaces (e.g. `C:\Program Files\...`) is split at the
|
|
28
|
+
* space. Wrapping it in quotes produces the correct `"C:\Program Files\..." args`.
|
|
29
|
+
*/
|
|
30
|
+
export function quoteWindowsCommand(command) {
|
|
31
|
+
return escapeWindowsCmdValue(command);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `spawn(..., { shell: true })` on Windows also passes argv through `cmd.exe`.
|
|
35
|
+
* Any argument containing spaces must be quoted or it will be split before the
|
|
36
|
+
* child process sees it.
|
|
37
|
+
*/
|
|
38
|
+
export function quoteWindowsArgument(argument) {
|
|
39
|
+
return escapeWindowsCmdValue(argument);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=windows-command.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ChildProcess, type ChildProcessWithoutNullStreams, type SpawnOptions } from "node:child_process";
|
|
2
|
+
export interface ExecCommandOptions {
|
|
3
|
+
env?: NodeJS.ProcessEnv;
|
|
4
|
+
cwd?: string;
|
|
5
|
+
encoding?: BufferEncoding;
|
|
6
|
+
killSignal?: NodeJS.Signals;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
maxBuffer?: number;
|
|
9
|
+
shell?: boolean | string;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
interface ExecCommandResult {
|
|
13
|
+
stdout: string;
|
|
14
|
+
stderr: string;
|
|
15
|
+
}
|
|
16
|
+
/** Launch a CLI with Windows command-script handling and argv quoting. The caller owns env. */
|
|
17
|
+
export declare function spawnProcess(command: string, args: string[], options: SpawnOptions & {
|
|
18
|
+
stdio: "pipe";
|
|
19
|
+
}): ChildProcessWithoutNullStreams;
|
|
20
|
+
export declare function spawnProcess(command: string, args: string[], options?: SpawnOptions): ChildProcess;
|
|
21
|
+
export declare function execCommand(command: string, args: string[], options?: ExecCommandOptions): Promise<ExecCommandResult>;
|
|
22
|
+
/** Force-stop a CLI, including descendants behind Windows command-script launchers. */
|
|
23
|
+
export declare function terminateProcess(child: ChildProcess, signal?: NodeJS.Signals): Promise<void>;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=process.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { execFile, spawn, } from "node:child_process";
|
|
2
|
+
import { extname } from "node:path";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
import { isWindowsCommandScript, quoteWindowsArgument, quoteWindowsCommand, } from "./process-internal/windows-command.js";
|
|
5
|
+
const execFileAsync = promisify(execFile);
|
|
6
|
+
function hasPathSeparator(value) {
|
|
7
|
+
return value.includes("/") || value.includes("\\");
|
|
8
|
+
}
|
|
9
|
+
function shouldUseWindowsShell(command, requestedShell) {
|
|
10
|
+
if (isWindowsCommandScript(command)) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
if (requestedShell !== undefined) {
|
|
14
|
+
return requestedShell;
|
|
15
|
+
}
|
|
16
|
+
return process.platform === "win32" && !hasPathSeparator(command) && !extname(command);
|
|
17
|
+
}
|
|
18
|
+
export function spawnProcess(command, args, options) {
|
|
19
|
+
const spawnOptions = options ?? {};
|
|
20
|
+
const isWindows = process.platform === "win32";
|
|
21
|
+
const shell = shouldUseWindowsShell(command, spawnOptions.shell);
|
|
22
|
+
const shouldQuoteForShell = isWindows && shell !== false;
|
|
23
|
+
const resolvedCommand = shouldQuoteForShell ? quoteWindowsCommand(command) : command;
|
|
24
|
+
const resolvedArgs = shouldQuoteForShell ? args.map(quoteWindowsArgument) : args;
|
|
25
|
+
return spawn(resolvedCommand, resolvedArgs, {
|
|
26
|
+
...spawnOptions,
|
|
27
|
+
env: options?.env,
|
|
28
|
+
shell,
|
|
29
|
+
signal: options?.signal,
|
|
30
|
+
windowsHide: true,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export async function execCommand(command, args, options) {
|
|
34
|
+
const isWindows = process.platform === "win32";
|
|
35
|
+
const shell = shouldUseWindowsShell(command, options?.shell);
|
|
36
|
+
const shouldQuoteForShell = isWindows && shell !== false;
|
|
37
|
+
const resolvedCommand = shouldQuoteForShell ? quoteWindowsCommand(command) : command;
|
|
38
|
+
const resolvedArgs = shouldQuoteForShell ? args.map(quoteWindowsArgument) : args;
|
|
39
|
+
return execFileAsync(resolvedCommand, resolvedArgs, {
|
|
40
|
+
cwd: options?.cwd,
|
|
41
|
+
env: options?.env,
|
|
42
|
+
encoding: options?.encoding ?? "utf8",
|
|
43
|
+
signal: options?.signal,
|
|
44
|
+
killSignal: options?.killSignal,
|
|
45
|
+
timeout: options?.timeout,
|
|
46
|
+
maxBuffer: options?.maxBuffer,
|
|
47
|
+
shell,
|
|
48
|
+
windowsHide: true,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** Force-stop a CLI, including descendants behind Windows command-script launchers. */
|
|
52
|
+
export async function terminateProcess(child, signal = "SIGKILL") {
|
|
53
|
+
if (process.platform !== "win32") {
|
|
54
|
+
child.kill(signal);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (child.pid === undefined)
|
|
58
|
+
return;
|
|
59
|
+
try {
|
|
60
|
+
await execCommand("taskkill.exe", ["/PID", String(child.pid), "/T", "/F"], {
|
|
61
|
+
shell: false,
|
|
62
|
+
timeout: 5000,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
// The process can finish between its close check and taskkill.
|
|
67
|
+
if (!(error instanceof Error && "code" in error && error.code === 128))
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=process.js.map
|
package/dist/server/usage.d.ts
CHANGED
|
@@ -62,6 +62,8 @@ export interface UsageAccount {
|
|
|
62
62
|
/** Stable across token rotation; [A-Za-z0-9._-]{1,128}. Never a credential or raw email. */
|
|
63
63
|
key: string;
|
|
64
64
|
label?: string;
|
|
65
|
+
/** Harness owning this login, e.g. Codex, OpenCode, Pi or OMP. */
|
|
66
|
+
harness?: string;
|
|
65
67
|
/** Store locator, opaque to the daemon. */
|
|
66
68
|
input: JsonValue;
|
|
67
69
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpaseo/plugin",
|
|
3
|
-
"version": "0.11.0-beta.
|
|
3
|
+
"version": "0.11.0-beta.5",
|
|
4
4
|
"description": "Paseo plugin SDK package",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"use-sync-external-store": "^1.6.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@getpaseo/client": "0.11.0-beta.
|
|
74
|
-
"@getpaseo/protocol": "0.11.0-beta.
|
|
73
|
+
"@getpaseo/client": "0.11.0-beta.5",
|
|
74
|
+
"@getpaseo/protocol": "0.11.0-beta.5",
|
|
75
75
|
"@types/node": "^20.9.0",
|
|
76
76
|
"@types/react": "~19.2.0",
|
|
77
77
|
"react": "19.1.0",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"zod": "^4.4.3"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"@getpaseo/client": "0.11.0-beta.
|
|
85
|
-
"@getpaseo/protocol": "0.11.0-beta.
|
|
84
|
+
"@getpaseo/client": "0.11.0-beta.5",
|
|
85
|
+
"@getpaseo/protocol": "0.11.0-beta.5",
|
|
86
86
|
"react": "~19.1.0",
|
|
87
87
|
"react-native": ">=0.81.5",
|
|
88
88
|
"zod": "^4.4.3"
|