@cydm/pie 2.7.8 → 2.7.10
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/builtin/extensions/ask-user/index.js +3 -3
- package/dist/builtin/extensions/plan-mode/index.js +3 -18
- package/dist/builtin/extensions/subagent/index.js +10 -6
- package/dist/builtin/extensions/todo/index.js +3 -3
- package/dist/chunks/{chunk-2FEDB5GR.js → chunk-2B6VS2NH.js} +38 -19
- package/dist/chunks/{chunk-E6F4BTNN.js → chunk-5GUPRFNP.js} +11 -5
- package/dist/chunks/{chunk-P22SYVGO.js → chunk-C4LXD56O.js} +362 -175
- package/dist/chunks/{chunk-W5B3OXHQ.js → chunk-JO6EDWHP.js} +1 -1
- package/dist/chunks/{src-C2CBPEUY.js → src-WFN4JWLE.js} +2 -2
- package/dist/chunks/{test-stream-LDVUVSUP.js → test-stream-GXZ7NT4H.js} +1 -1
- package/dist/cli.js +133 -47
- package/package.json +2 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
createAskUserCapability
|
|
4
|
-
} from "../../../chunks/chunk-
|
|
5
|
-
import "../../../chunks/chunk-
|
|
6
|
-
import "../../../chunks/chunk-
|
|
4
|
+
} from "../../../chunks/chunk-C4LXD56O.js";
|
|
5
|
+
import "../../../chunks/chunk-JO6EDWHP.js";
|
|
6
|
+
import "../../../chunks/chunk-2B6VS2NH.js";
|
|
7
7
|
import "../../../chunks/chunk-XXGYUYXI.js";
|
|
8
8
|
import "../../../chunks/chunk-LZQXQOPJ.js";
|
|
9
9
|
|
|
@@ -4,13 +4,11 @@ import {
|
|
|
4
4
|
createExecutionStateFromPlan,
|
|
5
5
|
createPlanCapability,
|
|
6
6
|
extractPlanTodoItems,
|
|
7
|
-
getToolCapabilityMetadata,
|
|
8
|
-
isPlanModeSafeCommand,
|
|
9
7
|
markCompletedPlanSteps,
|
|
10
8
|
restoreExecutionState
|
|
11
|
-
} from "../../../chunks/chunk-
|
|
12
|
-
import "../../../chunks/chunk-
|
|
13
|
-
import "../../../chunks/chunk-
|
|
9
|
+
} from "../../../chunks/chunk-C4LXD56O.js";
|
|
10
|
+
import "../../../chunks/chunk-JO6EDWHP.js";
|
|
11
|
+
import "../../../chunks/chunk-2B6VS2NH.js";
|
|
14
12
|
import {
|
|
15
13
|
Type
|
|
16
14
|
} from "../../../chunks/chunk-XXGYUYXI.js";
|
|
@@ -258,19 +256,6 @@ Update the plan accordingly and call plan_submit again with the revised steps. D
|
|
|
258
256
|
togglePlanMode();
|
|
259
257
|
}
|
|
260
258
|
});
|
|
261
|
-
ctx.on("tool:call", async (event) => {
|
|
262
|
-
if (!planModeEnabled) return;
|
|
263
|
-
if (getToolCapabilityMetadata({ name: event.toolName })?.executesShell !== true) return;
|
|
264
|
-
const command = typeof event.args === "object" && event.args !== null ? event.args.command : void 0;
|
|
265
|
-
if (typeof command === "string" && !isPlanModeSafeCommand(command)) {
|
|
266
|
-
ctx.ui.notify(
|
|
267
|
-
`Plan mode: Command blocked. Use read-only commands or plan_scratch for temporary drafts; submit the finished plan with plan_submit. Use /tools/plan to leave Plan mode.
|
|
268
|
-
Command: ${command}`,
|
|
269
|
-
"error"
|
|
270
|
-
);
|
|
271
|
-
return { block: true, reason: `Plan mode: command "${command}" is not a read-only shell command. Use plan_scratch for temporary drafts, submit the finished plan with plan_submit, or use /tools/plan to leave Plan mode.` };
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
259
|
ctx.on("agent:start", async () => {
|
|
275
260
|
const persisted = readPersistedPlanMode();
|
|
276
261
|
applyPlanModeState(persisted);
|
|
@@ -4,14 +4,15 @@ import {
|
|
|
4
4
|
formatTransportLifecycle,
|
|
5
5
|
getConfigDir,
|
|
6
6
|
logTransportLifecycle
|
|
7
|
-
} from "../../../chunks/chunk-
|
|
7
|
+
} from "../../../chunks/chunk-5GUPRFNP.js";
|
|
8
8
|
import {
|
|
9
9
|
SUBAGENT_SESSION_RECORD_VERSION,
|
|
10
|
+
createPolicyEnforcedTools,
|
|
10
11
|
createSharedFileSystemTools,
|
|
11
12
|
createSubagentCapability
|
|
12
|
-
} from "../../../chunks/chunk-
|
|
13
|
-
import "../../../chunks/chunk-
|
|
14
|
-
import "../../../chunks/chunk-
|
|
13
|
+
} from "../../../chunks/chunk-C4LXD56O.js";
|
|
14
|
+
import "../../../chunks/chunk-JO6EDWHP.js";
|
|
15
|
+
import "../../../chunks/chunk-2B6VS2NH.js";
|
|
15
16
|
import "../../../chunks/chunk-XXGYUYXI.js";
|
|
16
17
|
import "../../../chunks/chunk-LZQXQOPJ.js";
|
|
17
18
|
|
|
@@ -232,7 +233,8 @@ function createSubagentSessionStore(sessionsDir, log, deps) {
|
|
|
232
233
|
let current;
|
|
233
234
|
try {
|
|
234
235
|
current = fs.readFileSync(lockPath, "utf8");
|
|
235
|
-
} catch {
|
|
236
|
+
} catch (recheckError) {
|
|
237
|
+
if (recheckError.code === "ENOENT") continue;
|
|
236
238
|
current = void 0;
|
|
237
239
|
}
|
|
238
240
|
if (current !== lockContent) {
|
|
@@ -428,7 +430,9 @@ function subagentExtension(ctx) {
|
|
|
428
430
|
};
|
|
429
431
|
const fsTools = createSharedFileSystemTools(ctx.cwd, fsOptions);
|
|
430
432
|
const cliHostCapabilities = createCliHostCapabilities(ctx.cwd);
|
|
431
|
-
return [...fsTools, ...cliHostCapabilities.tools]
|
|
433
|
+
return createPolicyEnforcedTools([...fsTools, ...cliHostCapabilities.tools], {
|
|
434
|
+
getContext: () => ({ mode: "normal", confirmationPolicy: "allow" })
|
|
435
|
+
});
|
|
432
436
|
}
|
|
433
437
|
});
|
|
434
438
|
ctx.registerCleanup?.(() => capability.dispose());
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
executeManageTodoList,
|
|
9
9
|
executionStateToTodos,
|
|
10
10
|
restoreExecutionState
|
|
11
|
-
} from "../../../chunks/chunk-
|
|
12
|
-
import "../../../chunks/chunk-
|
|
13
|
-
import "../../../chunks/chunk-
|
|
11
|
+
} from "../../../chunks/chunk-C4LXD56O.js";
|
|
12
|
+
import "../../../chunks/chunk-JO6EDWHP.js";
|
|
13
|
+
import "../../../chunks/chunk-2B6VS2NH.js";
|
|
14
14
|
import "../../../chunks/chunk-XXGYUYXI.js";
|
|
15
15
|
import "../../../chunks/chunk-LZQXQOPJ.js";
|
|
16
16
|
|
|
@@ -3170,8 +3170,8 @@ var FileSystemGateway = class {
|
|
|
3170
3170
|
throw new Error(`Directory not found: ${source}`);
|
|
3171
3171
|
}
|
|
3172
3172
|
if (CS.System.IO.Directory.Exists(destination)) {
|
|
3173
|
-
const destinationFiles =
|
|
3174
|
-
const destinationDirs =
|
|
3173
|
+
const destinationFiles = csharpStringArray(CS.System.IO.Directory.GetFiles(destination));
|
|
3174
|
+
const destinationDirs = csharpStringArray(CS.System.IO.Directory.GetDirectories(destination));
|
|
3175
3175
|
const isEmpty = destinationFiles.length === 0 && destinationDirs.length === 0;
|
|
3176
3176
|
if (!isEmpty) {
|
|
3177
3177
|
throw new Error(`Move target already exists: ${destination}`);
|
|
@@ -3225,14 +3225,10 @@ var FileSystemGateway = class {
|
|
|
3225
3225
|
}
|
|
3226
3226
|
const files = CS.System.IO.Directory.GetFiles(path);
|
|
3227
3227
|
const dirs = CS.System.IO.Directory.GetDirectories(path);
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
for (let i = 0; i < dirs.Length; i++) {
|
|
3233
|
-
result.push(this.basename(dirs[i]));
|
|
3234
|
-
}
|
|
3235
|
-
return result;
|
|
3228
|
+
return [
|
|
3229
|
+
...csharpStringArray(files).map((entry) => this.basename(entry)),
|
|
3230
|
+
...csharpStringArray(dirs).map((entry) => this.basename(entry))
|
|
3231
|
+
];
|
|
3236
3232
|
}
|
|
3237
3233
|
const fs = nodeRequire("fs");
|
|
3238
3234
|
if (!fs.existsSync(path)) {
|
|
@@ -3303,6 +3299,21 @@ var FileSystemGateway = class {
|
|
|
3303
3299
|
return this.config;
|
|
3304
3300
|
}
|
|
3305
3301
|
};
|
|
3302
|
+
function csharpStringArray(value) {
|
|
3303
|
+
if (Array.isArray(value)) {
|
|
3304
|
+
return value.map((entry) => String(entry ?? ""));
|
|
3305
|
+
}
|
|
3306
|
+
if (value && typeof value.Length === "number") {
|
|
3307
|
+
const array = value;
|
|
3308
|
+
const results = [];
|
|
3309
|
+
for (let i = 0; i < array.Length; i++) {
|
|
3310
|
+
const entry = typeof array.get_Item === "function" ? array.get_Item(i) : array[i];
|
|
3311
|
+
results.push(String(entry ?? ""));
|
|
3312
|
+
}
|
|
3313
|
+
return results;
|
|
3314
|
+
}
|
|
3315
|
+
return [];
|
|
3316
|
+
}
|
|
3306
3317
|
function movePuertsDirectoryContents(source, destination) {
|
|
3307
3318
|
const directory = CS.System.IO.Directory;
|
|
3308
3319
|
const file = CS.System.IO.File;
|
|
@@ -3317,16 +3328,16 @@ function movePuertsDirectoryContents(source, destination) {
|
|
|
3317
3328
|
);
|
|
3318
3329
|
}
|
|
3319
3330
|
directory.CreateDirectory(destination);
|
|
3320
|
-
for (const entry of
|
|
3331
|
+
for (const entry of csharpStringArray(directory.GetFiles(source))) {
|
|
3321
3332
|
const name = String(entry).replace(/\\/g, "/").split("/").pop();
|
|
3322
3333
|
file.Copy(String(entry), `${destination}/${name}`, true);
|
|
3323
3334
|
}
|
|
3324
|
-
for (const subdir of
|
|
3335
|
+
for (const subdir of csharpStringArray(directory.GetDirectories(source))) {
|
|
3325
3336
|
const name = String(subdir).replace(/\\/g, "/").split("/").pop();
|
|
3326
3337
|
if (isPuertsReparsePoint(String(subdir))) continue;
|
|
3327
3338
|
movePuertsDirectoryContents(String(subdir), `${destination}/${name}`);
|
|
3328
3339
|
}
|
|
3329
|
-
for (const entry of
|
|
3340
|
+
for (const entry of csharpStringArray(directory.GetFiles(source))) {
|
|
3330
3341
|
try {
|
|
3331
3342
|
file.Delete(String(entry));
|
|
3332
3343
|
} catch {
|
|
@@ -3382,8 +3393,8 @@ function deletePuertsDirectoryByEnumeration(path, recursive) {
|
|
|
3382
3393
|
`Refusing to delete '${path}' through a reparse point (symlink/junction); resolve the link or delete it directly`
|
|
3383
3394
|
);
|
|
3384
3395
|
}
|
|
3385
|
-
const files =
|
|
3386
|
-
const subdirs =
|
|
3396
|
+
const files = csharpStringArray(directory.GetFiles(path));
|
|
3397
|
+
const subdirs = csharpStringArray(directory.GetDirectories(path));
|
|
3387
3398
|
if (!recursive) {
|
|
3388
3399
|
if (files.length > 0 || subdirs.length > 0) {
|
|
3389
3400
|
throw new Error(`Directory not empty: ${path}`);
|
|
@@ -6342,12 +6353,15 @@ function streamResponsesSSE(model, context, options) {
|
|
|
6342
6353
|
message.replayEligible = true;
|
|
6343
6354
|
message.replayClass = receivedMessageCount === 0 ? "stream_lost" : "stream_lost_partial";
|
|
6344
6355
|
}
|
|
6345
|
-
if (
|
|
6356
|
+
if (streamLost && !message.remoteFailure) {
|
|
6357
|
+
message.replayClass = receivedMessageCount === 0 ? "stream_lost" : "stream_lost_partial";
|
|
6358
|
+
}
|
|
6359
|
+
if (!message.remoteFailure && !streamLost && (userAborted || (submitted || localFailure))) message.retryable = false;
|
|
6346
6360
|
phase = "cleanup";
|
|
6347
6361
|
lifecycle({
|
|
6348
6362
|
timeoutKind: internalTimeout,
|
|
6349
6363
|
retryAllowed: !userAborted && !localFailure && message.retryable !== false,
|
|
6350
|
-
retryDecision: message.remoteFailure ? `remote_${message.remoteFailure.category}` : streamLost ? receivedMessageCount === 0 ?
|
|
6364
|
+
retryDecision: message.remoteFailure ? `remote_${message.remoteFailure.category}` : streamLost ? message.replayEligible ? receivedMessageCount === 0 ? "replay_exempt_stream_lost" : "replay_exempt_after_submission" : receivedMessageCount === 0 ? "stream_lost_no_evidence" : "stream_lost_partial" : submitted ? "not_retryable_after_submission" : localFailure ? "local_configuration_error" : "not_submitted",
|
|
6351
6365
|
cancelSource: userAborted ? "user" : internalTimeout ? "internal_timeout" : "none",
|
|
6352
6366
|
cleanupOutcome: "request_abandoned"
|
|
6353
6367
|
});
|
|
@@ -6988,7 +7002,7 @@ function streamResponsesWS(model, context, options) {
|
|
|
6988
7002
|
const protocolFailure = !endedWithoutTerminal && (error instanceof ResponsesProtocolError || error instanceof SyntaxError || !transportLost && error instanceof TypeError || error instanceof WebSocketTransportError && (error.kind === "protocol" || error.kind === "overflow"));
|
|
6989
7003
|
const cause = providerRejected && error instanceof WebSocketTransportError ? `${error.message} (HTTP status ${error.status})` : timedOut && !protocolFailure ? `Responses request timeout (${timedOut}) after ${ageMs()}ms` : error instanceof Error ? error.message : String(error);
|
|
6990
7004
|
message.errorMessage = cause;
|
|
6991
|
-
const streamLost = (endedWithoutTerminal || transportLost) && !protocolFailure && sent && !timedOut && !providerRejected && message.stopReason === "error";
|
|
7005
|
+
const streamLost = (endedWithoutTerminal || transportLost) && !protocolFailure && !localFailure && sent && !timedOut && !providerRejected && message.stopReason === "error";
|
|
6992
7006
|
if (timedOut && timedOut !== "connect" && !message.remoteFailure && !protocolFailure && !localFailure && sent && !providerRejected && !userAborted && !ownerDisposed && compat.timeoutReplay) {
|
|
6993
7007
|
message.replayEligible = true;
|
|
6994
7008
|
message.replayClass = timedOut;
|
|
@@ -6996,12 +7010,17 @@ function streamResponsesWS(model, context, options) {
|
|
|
6996
7010
|
message.replayEligible = true;
|
|
6997
7011
|
message.replayClass = receivedMessageCount === 0 ? "stream_lost" : "stream_lost_partial";
|
|
6998
7012
|
}
|
|
6999
|
-
if (!message.remoteFailure
|
|
7013
|
+
if (streamLost && !message.remoteFailure) {
|
|
7014
|
+
message.replayClass = receivedMessageCount === 0 ? "stream_lost" : "stream_lost_partial";
|
|
7015
|
+
}
|
|
7016
|
+
if (!message.remoteFailure && !streamLost && (localFailure || providerRejected || protocolFailure || userAborted || ownerDisposed)) {
|
|
7000
7017
|
message.retryable = false;
|
|
7001
7018
|
}
|
|
7002
7019
|
if (sent) {
|
|
7003
7020
|
if (streamLost && receivedMessageCount === 0) {
|
|
7004
7021
|
retryDecision = message.replayEligible ? "replay_exempt_stream_lost" : "stream_lost_no_evidence";
|
|
7022
|
+
} else if (streamLost) {
|
|
7023
|
+
retryDecision = message.replayEligible ? "replay_exempt_after_submission" : "stream_lost_partial";
|
|
7005
7024
|
} else {
|
|
7006
7025
|
if (!message.remoteFailure) message.retryable = false;
|
|
7007
7026
|
if (!timedOut) retryDecision = message.replayEligible ? "replay_exempt_after_submission" : "not_retryable_after_submission";
|
|
@@ -4,12 +4,13 @@ import {
|
|
|
4
4
|
createSharedWebFetchTool,
|
|
5
5
|
createSharedWebResearchTool,
|
|
6
6
|
createSharedWebSearchTool,
|
|
7
|
+
defaultShellKindForPlatform,
|
|
7
8
|
interpretShellExit,
|
|
8
9
|
requestInteraction
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-C4LXD56O.js";
|
|
10
11
|
import {
|
|
11
12
|
getLogger
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-2B6VS2NH.js";
|
|
13
14
|
import {
|
|
14
15
|
Type
|
|
15
16
|
} from "./chunk-XXGYUYXI.js";
|
|
@@ -320,10 +321,11 @@ function truncateStringToBytesFromEnd(str, maxBytes) {
|
|
|
320
321
|
var WINDOWS_DIALECT_BLOCK = `On this host shell:auto runs Windows PowerShell 5.1 (powershell.exe). Write PowerShell syntax: separate statements with ';' (PS 5.1 has no && or || \u2014 chain with "if ($?) { ... }" or check $LASTEXITCODE after native commands). Nested quotes in inline "node -e" or "-Command" strings are fragile; write a temp script file with write_file and execute it instead. Heredocs do not exist; multi-line commands work, but long scripts run more reliably from a file. Judge outcomes by the exit code; stderr may carry PowerShell-generated records such as CLIXML. shell:"bash" runs the first real bash on PATH (Git Bash when installed) and fails with an actionable error when only the WSL stub exists; shell:"cmd" runs cmd.exe.`;
|
|
321
322
|
var POSIX_DIALECT_BLOCK = 'On this host shell:auto runs bash (bash -c). POSIX syntax applies: && and || chaining, heredocs, and standard quoting rules are available. shell:"powershell" uses pwsh when installed; shell:"cmd" is Windows-only.';
|
|
322
323
|
function buildShellToolContract(platform = process.platform) {
|
|
324
|
+
const defaultShell = defaultShellKindForPlatform(platform);
|
|
323
325
|
if (platform === "win32") {
|
|
324
326
|
return {
|
|
325
327
|
dialect: "powershell51",
|
|
326
|
-
defaultShell
|
|
328
|
+
defaultShell,
|
|
327
329
|
name: "shell",
|
|
328
330
|
label: "powershell",
|
|
329
331
|
dialectBlock: WINDOWS_DIALECT_BLOCK,
|
|
@@ -332,7 +334,7 @@ function buildShellToolContract(platform = process.platform) {
|
|
|
332
334
|
}
|
|
333
335
|
return {
|
|
334
336
|
dialect: "bash",
|
|
335
|
-
defaultShell
|
|
337
|
+
defaultShell,
|
|
336
338
|
name: "shell",
|
|
337
339
|
label: "bash",
|
|
338
340
|
dialectBlock: POSIX_DIALECT_BLOCK,
|
|
@@ -599,6 +601,9 @@ function resolveShell(shell, contract) {
|
|
|
599
601
|
if (!shell || shell === "auto") {
|
|
600
602
|
return contract.defaultShell;
|
|
601
603
|
}
|
|
604
|
+
if (shell !== "bash" && shell !== "powershell" && shell !== "cmd") {
|
|
605
|
+
throw new Error(`Unknown shell "${shell}". Supported: auto, bash, powershell, cmd.`);
|
|
606
|
+
}
|
|
602
607
|
return shell;
|
|
603
608
|
}
|
|
604
609
|
function buildBashDescription(contract) {
|
|
@@ -610,6 +615,7 @@ function buildBashDescription(contract) {
|
|
|
610
615
|
}
|
|
611
616
|
function buildSpawnCommand(shell, command) {
|
|
612
617
|
if (shell === "powershell") {
|
|
618
|
+
const childExe = process.platform === "win32" ? "powershell.exe" : "pwsh";
|
|
613
619
|
const childScript = [
|
|
614
620
|
"$ProgressPreference = 'SilentlyContinue'",
|
|
615
621
|
"[Console]::OutputEncoding = New-Object System.Text.UTF8Encoding; $OutputEncoding = [Console]::OutputEncoding",
|
|
@@ -618,7 +624,7 @@ function buildSpawnCommand(shell, command) {
|
|
|
618
624
|
].join("\n");
|
|
619
625
|
const script = [
|
|
620
626
|
"$ProgressPreference = 'SilentlyContinue'",
|
|
621
|
-
|
|
627
|
+
`${childExe} -NoProfile -NonInteractive -EncodedCommand ${Buffer.from(childScript, "utf16le").toString("base64")}`,
|
|
622
628
|
"$__pieCode = $LASTEXITCODE; $__pieOk = $?",
|
|
623
629
|
"if (-not $__pieOk -and (($null -eq $__pieCode) -or ($__pieCode -eq 0))) { exit 1 }",
|
|
624
630
|
"if (($null -ne $__pieCode) -and ($__pieCode -ne 0)) { exit $__pieCode }",
|