pi-better-harness 0.30.0 → 0.30.1
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/extensions/minimal-output/index.ts +0 -6
- package/node_modules/pi-better-background-tasks/package.json +1 -1
- package/node_modules/pi-better-background-tasks/src/process.ts +5 -1
- package/node_modules/pi-better-background-tasks/src/shared-navigator.ts +3 -2
- package/node_modules/pi-better-background-tasks/src/shared-ssh-core/index.ts +50 -2
- package/node_modules/pi-better-background-tasks/src/types.ts +2 -0
- package/node_modules/pi-better-goal/package.json +1 -1
- package/node_modules/pi-better-goal/src/index.ts +2 -5
- package/node_modules/pi-better-sandbox/README.md +5 -6
- package/node_modules/pi-better-sandbox/index.ts +2 -15
- package/node_modules/pi-better-sandbox/package.json +1 -1
- package/node_modules/pi-better-ssh/package.json +1 -1
- package/node_modules/pi-better-ssh/src/shared-ssh-core/index.ts +50 -2
- package/node_modules/pi-better-subagents/index.ts +15 -2
- package/node_modules/pi-better-subagents/package.json +1 -1
- package/node_modules/pi-better-subagents/shared-navigator.ts +3 -2
- package/package.json +6 -6
|
@@ -21,10 +21,6 @@ export default function minimalOutputExtension(pi: ExtensionAPI): void {
|
|
|
21
21
|
return initialDefault = value?.enabled === true;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
function status(ctx: ExtensionContext): void {
|
|
25
|
-
ctx.ui.setStatus(ENTRY, enabled ? "tools: minimal" : undefined);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
24
|
function collapseTools(ctx: ExtensionContext): void {
|
|
29
25
|
// setToolsExpanded is a no-op when already false; force a redraw of restored transcript rows.
|
|
30
26
|
if (!ctx.ui.getToolsExpanded()) ctx.ui.setToolsExpanded(true);
|
|
@@ -77,7 +73,6 @@ export default function minimalOutputExtension(pi: ExtensionAPI): void {
|
|
|
77
73
|
if (enabled) collapseTools(ctx);
|
|
78
74
|
hook!.setEnabled(enabled);
|
|
79
75
|
} else enabled = false;
|
|
80
|
-
status(ctx);
|
|
81
76
|
}
|
|
82
77
|
|
|
83
78
|
async function change(value: string, ctx: ExtensionContext): Promise<void> {
|
|
@@ -98,7 +93,6 @@ export default function minimalOutputExtension(pi: ExtensionAPI): void {
|
|
|
98
93
|
if (enabled) collapseTools(ctx);
|
|
99
94
|
hook!.setEnabled(enabled);
|
|
100
95
|
if (enabled && !running) hook!.completeRun();
|
|
101
|
-
status(ctx);
|
|
102
96
|
}
|
|
103
97
|
|
|
104
98
|
const setting: SettingsControl = {
|
|
@@ -95,6 +95,10 @@ export function withWindowsLogRedirect(spec: CommandSpec, logPath: string): Comm
|
|
|
95
95
|
return {
|
|
96
96
|
...spec,
|
|
97
97
|
shell: true,
|
|
98
|
+
// The trampoline only redirects and execs an absolute program; sourcing
|
|
99
|
+
// the login profile (/etc/profile and friends) adds seconds of cold-start
|
|
100
|
+
// cost on a Windows runner and nothing the exec needs.
|
|
101
|
+
loginShell: false,
|
|
98
102
|
// The MSYS2 runtime rewrites POSIX-looking argv (e.g. `/c`, `/opt/x.sh`)
|
|
99
103
|
// when exec'ing native Windows binaries. Node spawn passed argv verbatim,
|
|
100
104
|
// so conversion is disabled to keep raw-argv semantics unchanged. The
|
|
@@ -404,7 +408,7 @@ export function commandExecution(spec: CommandSpec): { execPath: string; execArg
|
|
|
404
408
|
const [command, ...args] = spec.argv!;
|
|
405
409
|
return { execPath: command!, execArgs: args };
|
|
406
410
|
}
|
|
407
|
-
return { execPath: resolveDefaultShell(), execArgs: ["-lc", spec.command!] };
|
|
411
|
+
return { execPath: resolveDefaultShell(), execArgs: [spec.loginShell === false ? "-c" : "-lc", spec.command!] };
|
|
408
412
|
}
|
|
409
413
|
|
|
410
414
|
/** Stdio for a spawned task: stdin is always ignored; stdout/stderr are piped (collected) or ignored (redirected into the log by the child itself). */
|
|
@@ -174,8 +174,9 @@ export function isNavigatorUiAvailable(ctx: ExtensionContext | undefined): boole
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
export function navigatorFooterHint(
|
|
178
|
-
|
|
177
|
+
export function navigatorFooterHint(_count: number): string | null {
|
|
178
|
+
// Retain the compatibility helper so refresh/reload clears any old badge.
|
|
179
|
+
return null;
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
export function applyNavigatorFooter(ui: { setStatus(key: string, value: string | undefined): void }, count: number): string | null {
|
|
@@ -58,6 +58,8 @@ export interface ResolvedSshIdentity {
|
|
|
58
58
|
export const DEFAULT_SSH_CONNECT_TIMEOUT_SECONDS = 10;
|
|
59
59
|
export const DEFAULT_SSH_CONTROL_PERSIST_SECONDS = 600;
|
|
60
60
|
export const MAX_SSH_CONTROL_PATH_BYTES = 100;
|
|
61
|
+
/** The longest socket name under a ControlPath root: `cm-` plus a 32-char hash. */
|
|
62
|
+
const MUX_CONTROL_PATH_NAME_TEMPLATE = `cm-${"0".repeat(32)}`;
|
|
61
63
|
export const DEFAULT_TMUX_BOOTSTRAP_TIMEOUT_MS = 120_000;
|
|
62
64
|
|
|
63
65
|
export interface RemoteRunner {
|
|
@@ -111,18 +113,33 @@ export interface SshMuxCleanupResult {
|
|
|
111
113
|
commandResult: CommandResult;
|
|
112
114
|
}
|
|
113
115
|
|
|
116
|
+
export interface SshMuxForwardResult {
|
|
117
|
+
target: string;
|
|
118
|
+
localPath: string;
|
|
119
|
+
remotePath: string;
|
|
120
|
+
detail: string;
|
|
121
|
+
commandResult: CommandResult;
|
|
122
|
+
}
|
|
123
|
+
|
|
114
124
|
export interface SshMuxController {
|
|
115
125
|
readonly controlPath: string;
|
|
116
126
|
ensure(): Promise<SshMuxEnsureResult>;
|
|
127
|
+
/** Forward a local Unix socket to a remote Unix socket through the running ControlMaster (`ssh -O forward -L local:remote`). */
|
|
128
|
+
forwardUnixSocket(localPath: string, remotePath: string): Promise<SshMuxForwardResult>;
|
|
129
|
+
/** Cancel a forward made by `forwardUnixSocket` (`ssh -O cancel -L local:remote`) and remove the local socket file. */
|
|
130
|
+
cancelUnixSocketForward(localPath: string, remotePath: string): Promise<SshMuxForwardResult>;
|
|
117
131
|
status(): Promise<SshMuxStatus>;
|
|
118
132
|
cleanup(): Promise<SshMuxCleanupResult>;
|
|
119
133
|
withMux(commandSpec: CommandSpec): CommandSpec;
|
|
120
134
|
}
|
|
121
135
|
|
|
122
136
|
export class SshMuxError extends Error {
|
|
123
|
-
|
|
137
|
+
// Declared, not a parameter property: Node's native type stripping (pi-better-server) cannot run those.
|
|
138
|
+
readonly commandResult: CommandResult;
|
|
139
|
+
constructor(message: string, commandResult: CommandResult) {
|
|
124
140
|
super(message);
|
|
125
141
|
this.name = "SshMuxError";
|
|
142
|
+
this.commandResult = commandResult;
|
|
126
143
|
}
|
|
127
144
|
}
|
|
128
145
|
|
|
@@ -311,7 +328,10 @@ export function wrapRemoteBashCommand(input: RemoteBashCommandInput): string {
|
|
|
311
328
|
|
|
312
329
|
export function defaultSshControlPathRoot(): string {
|
|
313
330
|
const agentDirectory = process.env.PI_CODING_AGENT_DIR ?? join(homedir(), ".pi", "agent");
|
|
314
|
-
|
|
331
|
+
const root = join(agentDirectory, "ssh-control");
|
|
332
|
+
// A long agent directory would push the socket past the unix path limit; fall back to a short per-user root.
|
|
333
|
+
if (Buffer.byteLength(join(root, MUX_CONTROL_PATH_NAME_TEMPLATE)) <= MAX_SSH_CONTROL_PATH_BYTES) return root;
|
|
334
|
+
return join("/tmp", `pi-ssh-${process.getuid?.() ?? "user"}`);
|
|
315
335
|
}
|
|
316
336
|
|
|
317
337
|
/**
|
|
@@ -328,6 +348,26 @@ export function createSshMuxController(options: SshMuxControllerOptions): SshMux
|
|
|
328
348
|
const target = options.identity.target;
|
|
329
349
|
|
|
330
350
|
const prepareRoot = (): void => ensureControlPathRoot(controlPathRoot);
|
|
351
|
+
const forwardOperation = async (operation: "forward" | "cancel", localPath: string, remotePath: string): Promise<SshMuxForwardResult> => {
|
|
352
|
+
for (const [name, value] of [["localPath", localPath], ["remotePath", remotePath]] as const) {
|
|
353
|
+
if (!value || /[\s:]/.test(value)) throw new Error(`ssh forward ${name} must be non-empty and contain no whitespace or colon`);
|
|
354
|
+
}
|
|
355
|
+
prepareRoot();
|
|
356
|
+
const commandResult = await options.runner.runOnce(muxCommandSpec(options.commandSpec, target, [
|
|
357
|
+
"-o", "ControlMaster=no",
|
|
358
|
+
"-o", `ControlPath=${controlPath}`,
|
|
359
|
+
"-O", operation,
|
|
360
|
+
"-L", `${localPath}:${remotePath}`,
|
|
361
|
+
], false));
|
|
362
|
+
if (operation === "cancel") rmSync(localPath, { force: true });
|
|
363
|
+
if (!commandSucceeded(commandResult)) {
|
|
364
|
+
throw new SshMuxError(
|
|
365
|
+
`SSH ${operation} of ${localPath} -> ${target}:${remotePath} failed${resultDetail(commandResult) ? `: ${resultDetail(commandResult)}` : "."}`,
|
|
366
|
+
commandResult,
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
return { target, localPath, remotePath, detail: resultDetail(commandResult), commandResult };
|
|
370
|
+
};
|
|
331
371
|
const buildControlCommand = (operation: "check" | "exit"): CommandSpec => {
|
|
332
372
|
prepareRoot();
|
|
333
373
|
return muxCommandSpec(options.commandSpec, target, [
|
|
@@ -350,6 +390,11 @@ export function createSshMuxController(options: SshMuxControllerOptions): SshMux
|
|
|
350
390
|
return {
|
|
351
391
|
controlPath,
|
|
352
392
|
status,
|
|
393
|
+
forwardUnixSocket: async (localPath, remotePath) => {
|
|
394
|
+
rmSync(localPath, { force: true }); // ssh will not bind over a stale socket file
|
|
395
|
+
return await forwardOperation("forward", localPath, remotePath);
|
|
396
|
+
},
|
|
397
|
+
cancelUnixSocketForward: (localPath, remotePath) => forwardOperation("cancel", localPath, remotePath),
|
|
353
398
|
withMux: (commandSpec) => {
|
|
354
399
|
prepareRoot();
|
|
355
400
|
return muxCommandSpec(commandSpec, target, [
|
|
@@ -452,6 +497,9 @@ function ensureControlPathRoot(controlPathRoot: string): void {
|
|
|
452
497
|
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
453
498
|
throw new Error(`ssh mux ControlPath root must be a real directory: ${controlPathRoot}`);
|
|
454
499
|
}
|
|
500
|
+
if (process.getuid && stats.uid !== process.getuid()) {
|
|
501
|
+
throw new Error(`ssh mux ControlPath root must be owned by the current user: ${controlPathRoot}`);
|
|
502
|
+
}
|
|
455
503
|
chmodSync(controlPathRoot, 0o700);
|
|
456
504
|
}
|
|
457
505
|
|
|
@@ -22,6 +22,8 @@ export interface CommandSpec {
|
|
|
22
22
|
command?: string;
|
|
23
23
|
argv?: string[];
|
|
24
24
|
shell?: boolean;
|
|
25
|
+
/** Run the shell as a login shell (`bash -lc`, the default). False runs `bash -c`, skipping profile sourcing. */
|
|
26
|
+
loginShell?: boolean;
|
|
25
27
|
cwd?: string;
|
|
26
28
|
env?: Record<string, string>;
|
|
27
29
|
}
|
|
@@ -703,11 +703,8 @@ export default function (pi: ExtensionAPI): void {
|
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
705
|
if (waitingOnAnswer > 0) return `${waitingOnAnswer} background done; waiting on your answer`;
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
: undefined;
|
|
709
|
-
if (goal?.status === "paused") return background ? `${pausedGoalStatus(goal, preferences.conversationalResume)} · ${background}` : pausedGoalStatus(goal, preferences.conversationalResume);
|
|
710
|
-
if (background) return background;
|
|
706
|
+
if (goal?.status === "paused") return pausedGoalStatus(goal, preferences.conversationalResume);
|
|
707
|
+
if (snapshot?.backgroundRunning) return undefined;
|
|
711
708
|
const continuation = goal ? currentContinuationState(ctx, goal.goalId) : null;
|
|
712
709
|
if (continuation?.blocked) return "waiting: no progress";
|
|
713
710
|
const goalStall = observeGoalStall(goal, continuation, {
|
|
@@ -322,12 +322,11 @@ directory. Existing evidence is retained; enforcement is unaffected.
|
|
|
322
322
|
/sandbox rules open the write-denied paths editor
|
|
323
323
|
```
|
|
324
324
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
executable — never what was merely configured.
|
|
325
|
+
Sandbox status is not displayed in the footer. Use `/sandbox` to inspect the
|
|
326
|
+
permission table, or the text status report outside the TUI. Explicitly enabled
|
|
327
|
+
sessions still warn when protection cannot be applied. Status reports describe
|
|
328
|
+
what the runtime actually resolved, including the backend and executable, never
|
|
329
|
+
what was merely configured.
|
|
331
330
|
|
|
332
331
|
`/sandbox off` and `/sandbox default off` need interactive confirmation and are
|
|
333
332
|
refused outright when there is no interactive UI. There is no tool for changing
|
|
@@ -42,12 +42,9 @@ import { defaultSandboxPermissions, describeLoosening, type SandboxPermissionSet
|
|
|
42
42
|
import { openPermissionsPage } from "./permissions-page.ts";
|
|
43
43
|
import { appendSessionPermissions, readSessionPermissions } from "./session-permissions.ts";
|
|
44
44
|
|
|
45
|
-
import { footerTone, formatFooterStatus } from "./status.ts";
|
|
46
45
|
import { ForegroundSandboxController, type ForegroundSandboxStatus } from "./state.ts";
|
|
47
46
|
import { SandboxDiagnostics, diagnosticPackageVersion } from "./shared-sandbox-diagnostics.ts";
|
|
48
47
|
|
|
49
|
-
const FOOTER_KEY = "sandbox";
|
|
50
|
-
|
|
51
48
|
export default function piBetterSandbox(pi: ExtensionAPI): void {
|
|
52
49
|
const controller = new ForegroundSandboxController();
|
|
53
50
|
let diagnosticsWarning: ((error: unknown) => void) | undefined;
|
|
@@ -97,11 +94,8 @@ export default function piBetterSandbox(pi: ExtensionAPI): void {
|
|
|
97
94
|
}
|
|
98
95
|
});
|
|
99
96
|
|
|
100
|
-
let paintFooter: ((status: ForegroundSandboxStatus) => void) | undefined;
|
|
101
|
-
|
|
102
97
|
const announce = (status: ForegroundSandboxStatus): void => {
|
|
103
98
|
publishForegroundSandboxPolicy(pi.events, status);
|
|
104
|
-
paintFooter?.(status);
|
|
105
99
|
};
|
|
106
100
|
|
|
107
101
|
// A consumer that loaded after the last publication can ask for the current
|
|
@@ -115,13 +109,6 @@ export default function piBetterSandbox(pi: ExtensionAPI): void {
|
|
|
115
109
|
const denyRules = new DenyRuleManager({ controller, onStateChange: announce });
|
|
116
110
|
|
|
117
111
|
const restorePermissions = (ctx: ExtensionContext): void => {
|
|
118
|
-
paintFooter = (status) => {
|
|
119
|
-
ctx.ui.setStatus(
|
|
120
|
-
FOOTER_KEY,
|
|
121
|
-
formatFooterStatus(status, (tone, text) => ctx.ui.theme.fg(tone, text)),
|
|
122
|
-
);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
112
|
// Session policy takes precedence over global defaults. Never skip an
|
|
126
113
|
// invalid latest entry to recover an older, potentially broader policy.
|
|
127
114
|
let settings = defaultSandboxPermissions();
|
|
@@ -151,8 +138,8 @@ export default function piBetterSandbox(pi: ExtensionAPI): void {
|
|
|
151
138
|
|
|
152
139
|
// Then the rules are re-read and re-resolved, because the same global
|
|
153
140
|
// template set means different absolute paths in a different project.
|
|
154
|
-
// Loading
|
|
155
|
-
// the
|
|
141
|
+
// Loading announces the session's first policy, so consumers never see
|
|
142
|
+
// the pre-rule state.
|
|
156
143
|
const report = denyRules.load();
|
|
157
144
|
const status = report.status;
|
|
158
145
|
|
|
@@ -58,6 +58,8 @@ export interface ResolvedSshIdentity {
|
|
|
58
58
|
export const DEFAULT_SSH_CONNECT_TIMEOUT_SECONDS = 10;
|
|
59
59
|
export const DEFAULT_SSH_CONTROL_PERSIST_SECONDS = 600;
|
|
60
60
|
export const MAX_SSH_CONTROL_PATH_BYTES = 100;
|
|
61
|
+
/** The longest socket name under a ControlPath root: `cm-` plus a 32-char hash. */
|
|
62
|
+
const MUX_CONTROL_PATH_NAME_TEMPLATE = `cm-${"0".repeat(32)}`;
|
|
61
63
|
export const DEFAULT_TMUX_BOOTSTRAP_TIMEOUT_MS = 120_000;
|
|
62
64
|
|
|
63
65
|
export interface RemoteRunner {
|
|
@@ -111,18 +113,33 @@ export interface SshMuxCleanupResult {
|
|
|
111
113
|
commandResult: CommandResult;
|
|
112
114
|
}
|
|
113
115
|
|
|
116
|
+
export interface SshMuxForwardResult {
|
|
117
|
+
target: string;
|
|
118
|
+
localPath: string;
|
|
119
|
+
remotePath: string;
|
|
120
|
+
detail: string;
|
|
121
|
+
commandResult: CommandResult;
|
|
122
|
+
}
|
|
123
|
+
|
|
114
124
|
export interface SshMuxController {
|
|
115
125
|
readonly controlPath: string;
|
|
116
126
|
ensure(): Promise<SshMuxEnsureResult>;
|
|
127
|
+
/** Forward a local Unix socket to a remote Unix socket through the running ControlMaster (`ssh -O forward -L local:remote`). */
|
|
128
|
+
forwardUnixSocket(localPath: string, remotePath: string): Promise<SshMuxForwardResult>;
|
|
129
|
+
/** Cancel a forward made by `forwardUnixSocket` (`ssh -O cancel -L local:remote`) and remove the local socket file. */
|
|
130
|
+
cancelUnixSocketForward(localPath: string, remotePath: string): Promise<SshMuxForwardResult>;
|
|
117
131
|
status(): Promise<SshMuxStatus>;
|
|
118
132
|
cleanup(): Promise<SshMuxCleanupResult>;
|
|
119
133
|
withMux(commandSpec: CommandSpec): CommandSpec;
|
|
120
134
|
}
|
|
121
135
|
|
|
122
136
|
export class SshMuxError extends Error {
|
|
123
|
-
|
|
137
|
+
// Declared, not a parameter property: Node's native type stripping (pi-better-server) cannot run those.
|
|
138
|
+
readonly commandResult: CommandResult;
|
|
139
|
+
constructor(message: string, commandResult: CommandResult) {
|
|
124
140
|
super(message);
|
|
125
141
|
this.name = "SshMuxError";
|
|
142
|
+
this.commandResult = commandResult;
|
|
126
143
|
}
|
|
127
144
|
}
|
|
128
145
|
|
|
@@ -311,7 +328,10 @@ export function wrapRemoteBashCommand(input: RemoteBashCommandInput): string {
|
|
|
311
328
|
|
|
312
329
|
export function defaultSshControlPathRoot(): string {
|
|
313
330
|
const agentDirectory = process.env.PI_CODING_AGENT_DIR ?? join(homedir(), ".pi", "agent");
|
|
314
|
-
|
|
331
|
+
const root = join(agentDirectory, "ssh-control");
|
|
332
|
+
// A long agent directory would push the socket past the unix path limit; fall back to a short per-user root.
|
|
333
|
+
if (Buffer.byteLength(join(root, MUX_CONTROL_PATH_NAME_TEMPLATE)) <= MAX_SSH_CONTROL_PATH_BYTES) return root;
|
|
334
|
+
return join("/tmp", `pi-ssh-${process.getuid?.() ?? "user"}`);
|
|
315
335
|
}
|
|
316
336
|
|
|
317
337
|
/**
|
|
@@ -328,6 +348,26 @@ export function createSshMuxController(options: SshMuxControllerOptions): SshMux
|
|
|
328
348
|
const target = options.identity.target;
|
|
329
349
|
|
|
330
350
|
const prepareRoot = (): void => ensureControlPathRoot(controlPathRoot);
|
|
351
|
+
const forwardOperation = async (operation: "forward" | "cancel", localPath: string, remotePath: string): Promise<SshMuxForwardResult> => {
|
|
352
|
+
for (const [name, value] of [["localPath", localPath], ["remotePath", remotePath]] as const) {
|
|
353
|
+
if (!value || /[\s:]/.test(value)) throw new Error(`ssh forward ${name} must be non-empty and contain no whitespace or colon`);
|
|
354
|
+
}
|
|
355
|
+
prepareRoot();
|
|
356
|
+
const commandResult = await options.runner.runOnce(muxCommandSpec(options.commandSpec, target, [
|
|
357
|
+
"-o", "ControlMaster=no",
|
|
358
|
+
"-o", `ControlPath=${controlPath}`,
|
|
359
|
+
"-O", operation,
|
|
360
|
+
"-L", `${localPath}:${remotePath}`,
|
|
361
|
+
], false));
|
|
362
|
+
if (operation === "cancel") rmSync(localPath, { force: true });
|
|
363
|
+
if (!commandSucceeded(commandResult)) {
|
|
364
|
+
throw new SshMuxError(
|
|
365
|
+
`SSH ${operation} of ${localPath} -> ${target}:${remotePath} failed${resultDetail(commandResult) ? `: ${resultDetail(commandResult)}` : "."}`,
|
|
366
|
+
commandResult,
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
return { target, localPath, remotePath, detail: resultDetail(commandResult), commandResult };
|
|
370
|
+
};
|
|
331
371
|
const buildControlCommand = (operation: "check" | "exit"): CommandSpec => {
|
|
332
372
|
prepareRoot();
|
|
333
373
|
return muxCommandSpec(options.commandSpec, target, [
|
|
@@ -350,6 +390,11 @@ export function createSshMuxController(options: SshMuxControllerOptions): SshMux
|
|
|
350
390
|
return {
|
|
351
391
|
controlPath,
|
|
352
392
|
status,
|
|
393
|
+
forwardUnixSocket: async (localPath, remotePath) => {
|
|
394
|
+
rmSync(localPath, { force: true }); // ssh will not bind over a stale socket file
|
|
395
|
+
return await forwardOperation("forward", localPath, remotePath);
|
|
396
|
+
},
|
|
397
|
+
cancelUnixSocketForward: (localPath, remotePath) => forwardOperation("cancel", localPath, remotePath),
|
|
353
398
|
withMux: (commandSpec) => {
|
|
354
399
|
prepareRoot();
|
|
355
400
|
return muxCommandSpec(commandSpec, target, [
|
|
@@ -452,6 +497,9 @@ function ensureControlPathRoot(controlPathRoot: string): void {
|
|
|
452
497
|
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
453
498
|
throw new Error(`ssh mux ControlPath root must be a real directory: ${controlPathRoot}`);
|
|
454
499
|
}
|
|
500
|
+
if (process.getuid && stats.uid !== process.getuid()) {
|
|
501
|
+
throw new Error(`ssh mux ControlPath root must be owned by the current user: ${controlPathRoot}`);
|
|
502
|
+
}
|
|
455
503
|
chmodSync(controlPathRoot, 0o700);
|
|
456
504
|
}
|
|
457
505
|
|
|
@@ -572,7 +572,15 @@ function syncWidgetNavSelection(running: RunMeta[]): void {
|
|
|
572
572
|
*/
|
|
573
573
|
function renderWidget(): void {
|
|
574
574
|
const ctx = uiCtx;
|
|
575
|
-
if (!ctx
|
|
575
|
+
if (!ctx) return;
|
|
576
|
+
// A run can exit after Pi replaced the session that captured this ctx; Pi then throws on any
|
|
577
|
+
// property read. That session's UI is gone, so drop the ctx instead of failing the finalizer.
|
|
578
|
+
try {
|
|
579
|
+
if (!ctx.hasUI) return;
|
|
580
|
+
} catch {
|
|
581
|
+
if (uiCtx === ctx) uiCtx = undefined;
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
576
584
|
updateNavigatorFooter(ctx);
|
|
577
585
|
try { ctx.ui.setWidget("subagents", WIDGET_CLEAR); } catch { /* ignore */ }
|
|
578
586
|
spendCache.clear();
|
|
@@ -1847,7 +1855,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
1847
1855
|
const snapshot = taskRuntime ? takeRecoverySnapshot(taskRuntime.policy.permissions) : undefined;
|
|
1848
1856
|
if (snapshot?.started) {
|
|
1849
1857
|
void snapshot.done.then((outcome) => {
|
|
1850
|
-
if (
|
|
1858
|
+
if (outcome.ok) return;
|
|
1859
|
+
// The snapshot can finish after the session was replaced and ctx went stale.
|
|
1860
|
+
try { ctx.ui?.notify?.(`Subagent ${id}: recovery snapshot failed (run continues): ${outcome.detail}`, "warning"); } catch { /* ignore */ }
|
|
1851
1861
|
});
|
|
1852
1862
|
}
|
|
1853
1863
|
const cmd = taskRuntime ? { file: taskRuntime.file, fileArgs: [...taskRuntime.fileArgs, ...args] } : { file: piBin, fileArgs: args };
|
|
@@ -2497,6 +2507,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
2497
2507
|
// running/orphaned children before dropping the session origin, so they
|
|
2498
2508
|
// cannot become live process groups with no coordinator.
|
|
2499
2509
|
stopCurrentSessionSubagents(ctx);
|
|
2510
|
+
// The stopped children exit after this handler returns; their finalizers
|
|
2511
|
+
// must not reach for a ctx that Pi invalidates once the session is replaced.
|
|
2512
|
+
uiCtx = undefined;
|
|
2500
2513
|
agentSessionSettings.clear();
|
|
2501
2514
|
catalogModelRegistry = undefined;
|
|
2502
2515
|
activeCallbackOrigin = undefined;
|
|
@@ -174,8 +174,9 @@ export function isNavigatorUiAvailable(ctx: ExtensionContext | undefined): boole
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
export function navigatorFooterHint(
|
|
178
|
-
|
|
177
|
+
export function navigatorFooterHint(_count: number): string | null {
|
|
178
|
+
// Retain the compatibility helper so refresh/reload clears any old badge.
|
|
179
|
+
return null;
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
export function applyNavigatorFooter(ui: { setStatus(key: string, value: string | undefined): void }, count: number): string | null {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-better-harness",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"description": "Pi extension bundle for a write sandbox, subagents, background tasks, SSH, goals, and structured plans.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"test": "node --test test/*.test.mjs"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"pi-better-background-tasks": "0.9.
|
|
57
|
-
"pi-better-goal": "0.9.
|
|
56
|
+
"pi-better-background-tasks": "0.9.1",
|
|
57
|
+
"pi-better-goal": "0.9.1",
|
|
58
58
|
"pi-better-plan": "0.9.1",
|
|
59
|
-
"pi-better-sandbox": "0.12.
|
|
60
|
-
"pi-better-ssh": "0.1.
|
|
61
|
-
"pi-better-subagents": "0.19.
|
|
59
|
+
"pi-better-sandbox": "0.12.1",
|
|
60
|
+
"pi-better-ssh": "0.1.3",
|
|
61
|
+
"pi-better-subagents": "0.19.1",
|
|
62
62
|
"proper-lockfile": "^4.1.2",
|
|
63
63
|
"smol-toml": "1.9.0",
|
|
64
64
|
"yaml": "^2.9.1"
|