@cydm/pie 1.0.11 → 1.0.13
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 +2 -2
- package/dist/builtin/extensions/plan-mode/index.js +2 -2
- package/dist/builtin/extensions/subagent/index.js +3 -3
- package/dist/builtin/extensions/todo/index.js +2 -2
- package/dist/chunks/{chunk-QACYLY3B.js → chunk-D7NAXU7F.js} +143 -24
- package/dist/chunks/{chunk-GNHANWYT.js → chunk-EFG2MQFD.js} +2 -2
- package/dist/chunks/{chunk-H6PTIABA.js → chunk-LF5Q7BVU.js} +4463 -3947
- package/dist/chunks/{src-M32UEGIU.js → src-LZC56DRG.js} +1 -1
- package/dist/cli.js +3160 -2939
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
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-
|
|
4
|
+
} from "../../../chunks/chunk-LF5Q7BVU.js";
|
|
5
|
+
import "../../../chunks/chunk-D7NAXU7F.js";
|
|
6
6
|
import "../../../chunks/chunk-TG2EQLX2.js";
|
|
7
7
|
|
|
8
8
|
// builtin/extensions/ask-user/index.ts
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
isPlanModeSafeCommand,
|
|
8
8
|
markCompletedPlanSteps,
|
|
9
9
|
restoreExecutionState
|
|
10
|
-
} from "../../../chunks/chunk-
|
|
11
|
-
import "../../../chunks/chunk-
|
|
10
|
+
} from "../../../chunks/chunk-LF5Q7BVU.js";
|
|
11
|
+
import "../../../chunks/chunk-D7NAXU7F.js";
|
|
12
12
|
import "../../../chunks/chunk-TG2EQLX2.js";
|
|
13
13
|
|
|
14
14
|
// builtin/extensions/plan-mode/index.ts
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
createCliHostCapabilities
|
|
4
|
-
} from "../../../chunks/chunk-
|
|
4
|
+
} from "../../../chunks/chunk-EFG2MQFD.js";
|
|
5
5
|
import {
|
|
6
6
|
createSharedFileSystemTools,
|
|
7
7
|
createSubagentCapability
|
|
8
|
-
} from "../../../chunks/chunk-
|
|
9
|
-
import "../../../chunks/chunk-
|
|
8
|
+
} from "../../../chunks/chunk-LF5Q7BVU.js";
|
|
9
|
+
import "../../../chunks/chunk-D7NAXU7F.js";
|
|
10
10
|
import "../../../chunks/chunk-TG2EQLX2.js";
|
|
11
11
|
|
|
12
12
|
// builtin/extensions/subagent/index.ts
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
executeManageTodoList,
|
|
8
8
|
executionStateToTodos,
|
|
9
9
|
restoreExecutionState
|
|
10
|
-
} from "../../../chunks/chunk-
|
|
11
|
-
import "../../../chunks/chunk-
|
|
10
|
+
} from "../../../chunks/chunk-LF5Q7BVU.js";
|
|
11
|
+
import "../../../chunks/chunk-D7NAXU7F.js";
|
|
12
12
|
import "../../../chunks/chunk-TG2EQLX2.js";
|
|
13
13
|
|
|
14
14
|
// builtin/extensions/todo/index.ts
|
|
@@ -3758,6 +3758,7 @@ var NodeHttpClient = class {
|
|
|
3758
3758
|
async request(url, options = {}) {
|
|
3759
3759
|
const requestStartTime = Date.now();
|
|
3760
3760
|
const requestId = `${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;
|
|
3761
|
+
const requestTimeoutMs = options.timeoutMs ?? 6e4;
|
|
3761
3762
|
logHttp("DEBUG", `Request [${requestId}] started`, {
|
|
3762
3763
|
url: url.slice(0, 100),
|
|
3763
3764
|
method: options.method || "GET",
|
|
@@ -3857,13 +3858,32 @@ var NodeHttpClient = class {
|
|
|
3857
3858
|
let done = false;
|
|
3858
3859
|
let error = null;
|
|
3859
3860
|
let waiting = null;
|
|
3860
|
-
const
|
|
3861
|
+
const wake = (value) => {
|
|
3862
|
+
if (!waiting) return;
|
|
3863
|
+
const w = waiting;
|
|
3864
|
+
waiting = null;
|
|
3865
|
+
w(value);
|
|
3866
|
+
};
|
|
3867
|
+
const failStream = (e) => {
|
|
3868
|
+
if (done && error) return;
|
|
3869
|
+
error = e;
|
|
3870
|
+
done = true;
|
|
3871
|
+
wake({ done: true, value: void 0 });
|
|
3872
|
+
logHttp("ERROR", `Request [${requestId}] SSE stream error`, { error: e.message });
|
|
3873
|
+
};
|
|
3874
|
+
const flushBuffer = (final = false) => {
|
|
3861
3875
|
if (bufferLength === 0) return;
|
|
3862
3876
|
const buffer = Buffer.concat(bufferChunks, bufferLength);
|
|
3863
3877
|
const bufferStr = buffer.toString("utf-8");
|
|
3864
3878
|
const lines = bufferStr.split("\n");
|
|
3865
3879
|
const lastLine = lines.pop();
|
|
3866
|
-
if (
|
|
3880
|
+
if (final) {
|
|
3881
|
+
if (lastLine !== void 0 && lastLine.length > 0) {
|
|
3882
|
+
lines.push(lastLine);
|
|
3883
|
+
}
|
|
3884
|
+
bufferChunks = [];
|
|
3885
|
+
bufferLength = 0;
|
|
3886
|
+
} else if (lastLine !== void 0) {
|
|
3867
3887
|
bufferChunks = [Buffer.from(lastLine)];
|
|
3868
3888
|
bufferLength = lastLine.length;
|
|
3869
3889
|
} else {
|
|
@@ -3874,10 +3894,17 @@ var NodeHttpClient = class {
|
|
|
3874
3894
|
lineQueue.push(line);
|
|
3875
3895
|
}
|
|
3876
3896
|
};
|
|
3897
|
+
let abortHandler = null;
|
|
3877
3898
|
if (signal) {
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3899
|
+
abortHandler = () => {
|
|
3900
|
+
failStream(new Error("Request was aborted"));
|
|
3901
|
+
res.destroy(new Error("Request was aborted"));
|
|
3902
|
+
};
|
|
3903
|
+
if (signal.aborted) {
|
|
3904
|
+
abortHandler();
|
|
3905
|
+
} else {
|
|
3906
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
3907
|
+
}
|
|
3881
3908
|
}
|
|
3882
3909
|
res.on("data", (chunk) => {
|
|
3883
3910
|
totalBytes += chunk.length;
|
|
@@ -3886,22 +3913,18 @@ var NodeHttpClient = class {
|
|
|
3886
3913
|
if (bufferLength > 16384 || chunk.includes(10)) {
|
|
3887
3914
|
flushBuffer();
|
|
3888
3915
|
}
|
|
3889
|
-
|
|
3890
|
-
const w = waiting;
|
|
3891
|
-
waiting = null;
|
|
3892
|
-
w({ done: false, value: void 0 });
|
|
3893
|
-
}
|
|
3916
|
+
wake({ done: false, value: void 0 });
|
|
3894
3917
|
});
|
|
3895
3918
|
res.on("end", () => {
|
|
3896
3919
|
if (bufferLength > 0) {
|
|
3897
|
-
flushBuffer();
|
|
3920
|
+
flushBuffer(true);
|
|
3898
3921
|
}
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
waiting = null;
|
|
3903
|
-
w({ done: true, value: void 0 });
|
|
3922
|
+
if (!res.complete) {
|
|
3923
|
+
failStream(new Error("SSE stream ended before response completed"));
|
|
3924
|
+
return;
|
|
3904
3925
|
}
|
|
3926
|
+
done = true;
|
|
3927
|
+
wake({ done: true, value: void 0 });
|
|
3905
3928
|
logHttp("DEBUG", `Request [${requestId}] SSE stream ended`, {
|
|
3906
3929
|
totalBytes,
|
|
3907
3930
|
lineCount,
|
|
@@ -3909,14 +3932,15 @@ var NodeHttpClient = class {
|
|
|
3909
3932
|
});
|
|
3910
3933
|
});
|
|
3911
3934
|
res.on("error", (e) => {
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3935
|
+
failStream(e);
|
|
3936
|
+
});
|
|
3937
|
+
res.on("aborted", () => {
|
|
3938
|
+
failStream(new Error("SSE stream aborted"));
|
|
3939
|
+
});
|
|
3940
|
+
res.on("close", () => {
|
|
3941
|
+
if (!done || !res.complete) {
|
|
3942
|
+
failStream(new Error("SSE stream closed before end"));
|
|
3918
3943
|
}
|
|
3919
|
-
logHttp("ERROR", `Request [${requestId}] SSE stream error`, { error: e.message });
|
|
3920
3944
|
});
|
|
3921
3945
|
try {
|
|
3922
3946
|
while (true) {
|
|
@@ -3936,9 +3960,12 @@ var NodeHttpClient = class {
|
|
|
3936
3960
|
const waitResult = await new Promise((r) => {
|
|
3937
3961
|
waiting = r;
|
|
3938
3962
|
});
|
|
3939
|
-
|
|
3963
|
+
void waitResult;
|
|
3940
3964
|
}
|
|
3941
3965
|
} finally {
|
|
3966
|
+
if (signal && abortHandler) {
|
|
3967
|
+
signal.removeEventListener("abort", abortHandler);
|
|
3968
|
+
}
|
|
3942
3969
|
if (!done && !res.destroyed) {
|
|
3943
3970
|
res.destroy();
|
|
3944
3971
|
}
|
|
@@ -3965,6 +3992,7 @@ var NodeHttpClient = class {
|
|
|
3965
3992
|
logHttp("ERROR", `Request [${requestId}] timeout`);
|
|
3966
3993
|
req.destroy(new Error("Request timeout"));
|
|
3967
3994
|
});
|
|
3995
|
+
req.setTimeout(requestTimeoutMs);
|
|
3968
3996
|
if (options.signal) {
|
|
3969
3997
|
options.signal.addEventListener("abort", () => {
|
|
3970
3998
|
logHttp("DEBUG", `Request [${requestId}] aborted`);
|
|
@@ -4371,6 +4399,47 @@ var FileSystemGateway = class {
|
|
|
4371
4399
|
const fs = nodeRequire("fs");
|
|
4372
4400
|
fs.writeFileSync(path, content, encoding);
|
|
4373
4401
|
}
|
|
4402
|
+
/**
|
|
4403
|
+
* Copy a file.
|
|
4404
|
+
*/
|
|
4405
|
+
copyFile(source, destination) {
|
|
4406
|
+
if (!this.allowWrites) {
|
|
4407
|
+
throw new Error(`Writes not allowed: ${destination}`);
|
|
4408
|
+
}
|
|
4409
|
+
this.validatePath(source, "copy");
|
|
4410
|
+
this.validatePath(destination, "copy");
|
|
4411
|
+
const platform = detectPlatform();
|
|
4412
|
+
const dir = this.dirname(destination);
|
|
4413
|
+
this.mkdir(dir, { recursive: true });
|
|
4414
|
+
if (platform === "puerts" && typeof CS !== "undefined") {
|
|
4415
|
+
CS.System.IO.File.Copy(source, destination, true);
|
|
4416
|
+
return;
|
|
4417
|
+
}
|
|
4418
|
+
const fs = nodeRequire("fs");
|
|
4419
|
+
fs.copyFileSync(source, destination);
|
|
4420
|
+
}
|
|
4421
|
+
/**
|
|
4422
|
+
* Rename or move a file.
|
|
4423
|
+
*/
|
|
4424
|
+
renameFile(source, destination) {
|
|
4425
|
+
if (!this.allowWrites) {
|
|
4426
|
+
throw new Error(`Writes not allowed: ${destination}`);
|
|
4427
|
+
}
|
|
4428
|
+
this.validatePath(source, "rename");
|
|
4429
|
+
this.validatePath(destination, "rename");
|
|
4430
|
+
const platform = detectPlatform();
|
|
4431
|
+
const dir = this.dirname(destination);
|
|
4432
|
+
this.mkdir(dir, { recursive: true });
|
|
4433
|
+
if (platform === "puerts" && typeof CS !== "undefined") {
|
|
4434
|
+
if (CS.System.IO.File.Exists(destination)) {
|
|
4435
|
+
CS.System.IO.File.Delete(destination);
|
|
4436
|
+
}
|
|
4437
|
+
CS.System.IO.File.Move(source, destination);
|
|
4438
|
+
return;
|
|
4439
|
+
}
|
|
4440
|
+
const fs = nodeRequire("fs");
|
|
4441
|
+
fs.renameSync(source, destination);
|
|
4442
|
+
}
|
|
4374
4443
|
/**
|
|
4375
4444
|
* Delete file
|
|
4376
4445
|
*/
|
|
@@ -4937,6 +5006,52 @@ function mapOpenAIStopReason(reason) {
|
|
|
4937
5006
|
}
|
|
4938
5007
|
}
|
|
4939
5008
|
|
|
5009
|
+
// ../../packages/ai/src/providers/assistant-content-validation.ts
|
|
5010
|
+
var EMPTY_ASSISTANT_CONTENT_ERROR = "stream ended without assistant content";
|
|
5011
|
+
var EMPTY_ASSISTANT_CONTENT_ERROR_CODE = "empty_assistant_content";
|
|
5012
|
+
var EmptyAssistantContentError = class extends Error {
|
|
5013
|
+
code = EMPTY_ASSISTANT_CONTENT_ERROR_CODE;
|
|
5014
|
+
constructor(message = EMPTY_ASSISTANT_CONTENT_ERROR) {
|
|
5015
|
+
super(message);
|
|
5016
|
+
this.name = "EmptyAssistantContentError";
|
|
5017
|
+
}
|
|
5018
|
+
};
|
|
5019
|
+
function hasAssistantContent(message) {
|
|
5020
|
+
return message.content.some((block) => {
|
|
5021
|
+
if (block.type === "text") {
|
|
5022
|
+
return block.text.trim().length > 0;
|
|
5023
|
+
}
|
|
5024
|
+
if (block.type === "thinking") {
|
|
5025
|
+
return block.thinking.trim().length > 0;
|
|
5026
|
+
}
|
|
5027
|
+
if (block.type === "toolCall") {
|
|
5028
|
+
return block.name.trim().length > 0;
|
|
5029
|
+
}
|
|
5030
|
+
return false;
|
|
5031
|
+
});
|
|
5032
|
+
}
|
|
5033
|
+
function assertAssistantHasContent(message) {
|
|
5034
|
+
if (!hasAssistantContent(message)) {
|
|
5035
|
+
throw new EmptyAssistantContentError();
|
|
5036
|
+
}
|
|
5037
|
+
}
|
|
5038
|
+
function isEmptyAssistantContentError(error) {
|
|
5039
|
+
return error instanceof EmptyAssistantContentError || typeof error === "object" && error !== null && "code" in error && error.code === EMPTY_ASSISTANT_CONTENT_ERROR_CODE;
|
|
5040
|
+
}
|
|
5041
|
+
function logEmptyAssistantContentError(error, model, options) {
|
|
5042
|
+
if (!isEmptyAssistantContentError(error)) {
|
|
5043
|
+
return;
|
|
5044
|
+
}
|
|
5045
|
+
getLogger().child({ module: "ai.provider" }).warn(EMPTY_ASSISTANT_CONTENT_ERROR, {
|
|
5046
|
+
code: EMPTY_ASSISTANT_CONTENT_ERROR_CODE,
|
|
5047
|
+
provider: model.provider,
|
|
5048
|
+
model: model.id,
|
|
5049
|
+
api: model.api,
|
|
5050
|
+
sessionId: options?.sessionId,
|
|
5051
|
+
metadata: options?.metadata
|
|
5052
|
+
});
|
|
5053
|
+
}
|
|
5054
|
+
|
|
4940
5055
|
// ../../packages/ai/src/providers/openai-compat.ts
|
|
4941
5056
|
var streamOpenAICompletions = (model, context, options) => {
|
|
4942
5057
|
const stream = new AssistantMessageEventStream();
|
|
@@ -5172,9 +5287,11 @@ var streamOpenAICompletions = (model, context, options) => {
|
|
|
5172
5287
|
if (output.stopReason === "aborted" || output.stopReason === "error") {
|
|
5173
5288
|
throw new Error("An unknown error occurred");
|
|
5174
5289
|
}
|
|
5290
|
+
assertAssistantHasContent(output);
|
|
5175
5291
|
stream.push({ type: "done", reason: output.stopReason, message: output });
|
|
5176
5292
|
stream.end();
|
|
5177
5293
|
} catch (error) {
|
|
5294
|
+
logEmptyAssistantContentError(error, model, options);
|
|
5178
5295
|
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
5179
5296
|
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
5180
5297
|
stream.push({ type: "error", reason: output.stopReason, error: output });
|
|
@@ -5553,9 +5670,11 @@ var streamAnthropic = (model, context, options) => {
|
|
|
5553
5670
|
if (options?.signal?.aborted) {
|
|
5554
5671
|
throw new Error("Request was aborted");
|
|
5555
5672
|
}
|
|
5673
|
+
assertAssistantHasContent(output);
|
|
5556
5674
|
stream.push({ type: "done", reason: output.stopReason, message: output });
|
|
5557
5675
|
stream.end();
|
|
5558
5676
|
} catch (error) {
|
|
5677
|
+
logEmptyAssistantContentError(error, model, options);
|
|
5559
5678
|
for (const block of output.content) delete block.index;
|
|
5560
5679
|
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
5561
5680
|
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
createSharedWebSearchTool,
|
|
9
9
|
interpretShellExit,
|
|
10
10
|
requestInteraction
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-LF5Q7BVU.js";
|
|
12
12
|
import {
|
|
13
13
|
Type
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-D7NAXU7F.js";
|
|
15
15
|
|
|
16
16
|
// src/config.ts
|
|
17
17
|
import { existsSync, mkdirSync, readFileSync, renameSync } from "fs";
|