@cydm/pie 2.7.13 → 2.7.15
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/README.md +16 -0
- package/dist/builtin/extensions/ask-user/index.js +3 -3
- package/dist/builtin/extensions/cron/index.js +669 -0
- package/dist/builtin/extensions/cron/package.json +11 -0
- package/dist/builtin/extensions/document-attachments/index.js +3 -0
- package/dist/builtin/extensions/im-forward/index.js +2278 -0
- package/dist/builtin/extensions/im-forward/package.json +11 -0
- package/dist/builtin/extensions/pie-ipc/index.js +1969 -0
- package/dist/builtin/extensions/pie-ipc/package.json +11 -0
- package/dist/builtin/extensions/plan-mode/index.js +3 -3
- package/dist/builtin/extensions/subagent/index.js +4 -4
- package/dist/builtin/extensions/todo/index.js +3 -3
- package/dist/chunks/{chunk-CIFC6QVB.js → chunk-C5UTDL3S.js} +339 -47
- package/dist/chunks/{chunk-D7RMNFVM.js → chunk-CLEPSTWH.js} +2 -2
- package/dist/chunks/chunk-F7EBZTZO.js +26 -0
- package/dist/chunks/{chunk-R46YPPTU.js → chunk-NM2JLPJ6.js} +156 -101
- package/dist/chunks/{chunk-HGUYS5SF.js → chunk-TDHVB2FH.js} +1 -1
- package/dist/chunks/{src-5JJZZ5H7.js → src-IY6TEIL7.js} +2 -2
- package/dist/chunks/{test-stream-ZBTSPU7J.js → test-stream-EXSL5TIO.js} +1 -1
- package/dist/cli.js +498 -136
- package/package.json +6 -2
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
defaultShellKindForPlatform,
|
|
8
8
|
interpretShellExit,
|
|
9
9
|
requestInteraction
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-C5UTDL3S.js";
|
|
11
11
|
import {
|
|
12
12
|
EMPTY_ASSISTANT_CONTENT_ERROR,
|
|
13
13
|
OPENAI_COMPAT_PROTOCOL_ERROR_CODE,
|
|
14
14
|
getLogger
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-NM2JLPJ6.js";
|
|
16
16
|
import {
|
|
17
17
|
Type
|
|
18
18
|
} from "./chunk-XXGYUYXI.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/files/image-format.ts
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
function detectImageMime(bytes) {
|
|
6
|
+
if (bytes.length >= 3 && bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255) return { mime: "image/jpeg", ext: ".jpg" };
|
|
7
|
+
if (bytes.length >= 8 && bytes.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))) return { mime: "image/png", ext: ".png" };
|
|
8
|
+
if (bytes.length >= 6 && (bytes.subarray(0, 6).equals(Buffer.from("GIF87a")) || bytes.subarray(0, 6).equals(Buffer.from("GIF89a")))) return { mime: "image/gif", ext: ".gif" };
|
|
9
|
+
if (bytes.length >= 12 && bytes.subarray(0, 4).equals(Buffer.from("RIFF")) && bytes.subarray(8, 12).equals(Buffer.from("WEBP"))) return { mime: "image/webp", ext: ".webp" };
|
|
10
|
+
return { mime: "application/octet-stream", ext: ".bin" };
|
|
11
|
+
}
|
|
12
|
+
function readImageFormat(filePath) {
|
|
13
|
+
const fd = fs.openSync(filePath, "r");
|
|
14
|
+
try {
|
|
15
|
+
const header = Buffer.alloc(16);
|
|
16
|
+
const count = fs.readSync(fd, header, 0, header.length, 0);
|
|
17
|
+
return detectImageMime(header.subarray(0, count));
|
|
18
|
+
} finally {
|
|
19
|
+
fs.closeSync(fd);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
detectImageMime,
|
|
25
|
+
readImageFormat
|
|
26
|
+
};
|
|
@@ -829,6 +829,14 @@ var SHA256 = class extends HashMD {
|
|
|
829
829
|
var sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
|
|
830
830
|
|
|
831
831
|
// ../../packages/platform/src/sha256.ts
|
|
832
|
+
var utf8Owner;
|
|
833
|
+
function tryCreateUtf8Sha256Hasher() {
|
|
834
|
+
try {
|
|
835
|
+
return utf8Owner?.factory();
|
|
836
|
+
} catch {
|
|
837
|
+
return void 0;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
832
840
|
function createSha256Hasher() {
|
|
833
841
|
const hash = sha256.create();
|
|
834
842
|
return {
|
|
@@ -2381,20 +2389,41 @@ var NodeHttpClient = class {
|
|
|
2381
2389
|
waiting = null;
|
|
2382
2390
|
w(value);
|
|
2383
2391
|
};
|
|
2392
|
+
let pendingFailureLog = null;
|
|
2393
|
+
let failureLogged = false;
|
|
2394
|
+
const classifyFailure = (e) => {
|
|
2395
|
+
if (signal?.aborted === true || isAbortErrorMessage(e.message)) {
|
|
2396
|
+
return { level: "INFO", message: `Request [${reqTag}] SSE stream aborted by caller`, extra: { error: e.message } };
|
|
2397
|
+
}
|
|
2398
|
+
if (requestTimeoutError) {
|
|
2399
|
+
return { level: "WARN", message: `Request [${reqTag}] SSE stream failed (request timeout)`, extra: { error: e.message } };
|
|
2400
|
+
}
|
|
2401
|
+
if (e.message === "SSE stream aborted" || e.message === "SSE stream closed before end" || e.message === "SSE stream ended before response completed") {
|
|
2402
|
+
return { level: "WARN", message: `Request [${reqTag}] SSE stream closed by remote`, extra: { error: e.message } };
|
|
2403
|
+
}
|
|
2404
|
+
return { level: "ERROR", message: `Request [${reqTag}] SSE stream error`, extra: { error: e.message } };
|
|
2405
|
+
};
|
|
2406
|
+
const logFailureIfDelivered = () => {
|
|
2407
|
+
if (failureLogged || !pendingFailureLog) return;
|
|
2408
|
+
failureLogged = true;
|
|
2409
|
+
const entry = pendingFailureLog;
|
|
2410
|
+
pendingFailureLog = null;
|
|
2411
|
+
logHttp(entry.level, entry.message, entry.extra);
|
|
2412
|
+
};
|
|
2413
|
+
const logUndeliveredFailure = () => {
|
|
2414
|
+
if (failureLogged || !pendingFailureLog) return;
|
|
2415
|
+
failureLogged = true;
|
|
2416
|
+
const entry = pendingFailureLog;
|
|
2417
|
+
pendingFailureLog = null;
|
|
2418
|
+
logHttp("DEBUG", `${entry.message} (not consumed by the reader)`, entry.extra);
|
|
2419
|
+
};
|
|
2384
2420
|
const failStream = (e) => {
|
|
2385
2421
|
if (done && error) return;
|
|
2422
|
+
const firstFailure = !error;
|
|
2386
2423
|
error = e;
|
|
2387
2424
|
done = true;
|
|
2425
|
+
if (firstFailure) pendingFailureLog = classifyFailure(e);
|
|
2388
2426
|
wake({ done: true, value: void 0 });
|
|
2389
|
-
if (signal?.aborted === true || isAbortErrorMessage(e.message)) {
|
|
2390
|
-
logHttp("INFO", `Request [${reqTag}] SSE stream aborted by caller`, { error: e.message });
|
|
2391
|
-
} else if (requestTimeoutError) {
|
|
2392
|
-
logHttp("WARN", `Request [${reqTag}] SSE stream failed (request timeout)`, { error: e.message });
|
|
2393
|
-
} else if (e.message === "SSE stream aborted" || e.message === "SSE stream closed before end" || e.message === "SSE stream ended before response completed") {
|
|
2394
|
-
logHttp("WARN", `Request [${reqTag}] SSE stream closed by remote`, { error: e.message });
|
|
2395
|
-
} else {
|
|
2396
|
-
logHttp("ERROR", `Request [${reqTag}] SSE stream error`, { error: e.message });
|
|
2397
|
-
}
|
|
2398
2427
|
};
|
|
2399
2428
|
const flushBuffer = (final = false) => {
|
|
2400
2429
|
if (final) {
|
|
@@ -2454,16 +2483,19 @@ var NodeHttpClient = class {
|
|
|
2454
2483
|
});
|
|
2455
2484
|
});
|
|
2456
2485
|
res.on("error", (e) => {
|
|
2486
|
+
if (/aborted|econnreset|socket hang up/i.test(e.message)) {
|
|
2487
|
+
failStream(requestTimeoutError ?? new Error("SSE stream aborted"));
|
|
2488
|
+
return;
|
|
2489
|
+
}
|
|
2457
2490
|
failStream(requestTimeoutError ?? e);
|
|
2458
2491
|
});
|
|
2459
2492
|
res.on("aborted", () => {
|
|
2493
|
+
if (consumerClosed || done) return;
|
|
2460
2494
|
failStream(requestTimeoutError ?? new Error("SSE stream aborted"));
|
|
2461
2495
|
});
|
|
2462
2496
|
res.on("close", () => {
|
|
2463
2497
|
if (consumerClosed) return;
|
|
2464
|
-
if (!done || !res.complete)
|
|
2465
|
-
failStream(requestTimeoutError ?? new Error("SSE stream closed before end"));
|
|
2466
|
-
}
|
|
2498
|
+
if (!done || !res.complete) failStream(requestTimeoutError ?? new Error("SSE stream closed before end"));
|
|
2467
2499
|
});
|
|
2468
2500
|
try {
|
|
2469
2501
|
while (true) {
|
|
@@ -2477,7 +2509,10 @@ var NodeHttpClient = class {
|
|
|
2477
2509
|
queueHead = 0;
|
|
2478
2510
|
}
|
|
2479
2511
|
if (done) {
|
|
2480
|
-
if (error)
|
|
2512
|
+
if (error) {
|
|
2513
|
+
logFailureIfDelivered();
|
|
2514
|
+
throw error;
|
|
2515
|
+
}
|
|
2481
2516
|
return;
|
|
2482
2517
|
}
|
|
2483
2518
|
const waitResult = await new Promise((r) => {
|
|
@@ -2487,6 +2522,7 @@ var NodeHttpClient = class {
|
|
|
2487
2522
|
}
|
|
2488
2523
|
} finally {
|
|
2489
2524
|
consumerClosed = true;
|
|
2525
|
+
logUndeliveredFailure();
|
|
2490
2526
|
if (signal && abortHandler) {
|
|
2491
2527
|
signal.removeEventListener("abort", abortHandler);
|
|
2492
2528
|
}
|
|
@@ -6462,100 +6498,119 @@ function jsonSha256(value) {
|
|
|
6462
6498
|
return hashJson(value);
|
|
6463
6499
|
}
|
|
6464
6500
|
function hashJson(value, parts) {
|
|
6465
|
-
const
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
used =
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6501
|
+
const utf8 = tryCreateUtf8Sha256Hasher();
|
|
6502
|
+
try {
|
|
6503
|
+
const hash = utf8 ? void 0 : createSha256Hasher();
|
|
6504
|
+
const bytes = new Uint8Array(utf8 ? 0 : 8192);
|
|
6505
|
+
let fragments = "";
|
|
6506
|
+
let used = 0;
|
|
6507
|
+
const byte = (n) => {
|
|
6508
|
+
bytes[used++] = n;
|
|
6509
|
+
if (used === bytes.length) {
|
|
6510
|
+
hash.update(bytes);
|
|
6511
|
+
used = 0;
|
|
6512
|
+
}
|
|
6513
|
+
};
|
|
6514
|
+
const emit = (text) => {
|
|
6515
|
+
if (utf8) {
|
|
6516
|
+
if (fragments.length + text.length > 8192) {
|
|
6517
|
+
if (fragments) utf8.updateUtf8(fragments);
|
|
6518
|
+
fragments = "";
|
|
6519
|
+
}
|
|
6520
|
+
if (text.length >= 8192) utf8.updateUtf8(text);
|
|
6521
|
+
else fragments += text;
|
|
6522
|
+
return;
|
|
6523
|
+
}
|
|
6524
|
+
for (let i = 0; i < text.length; i++) {
|
|
6525
|
+
const cp = text.codePointAt(i);
|
|
6526
|
+
if (cp < 128) byte(cp);
|
|
6527
|
+
else if (cp < 2048) {
|
|
6528
|
+
byte(192 | cp >> 6);
|
|
6529
|
+
byte(128 | cp & 63);
|
|
6530
|
+
} else if (cp < 65536) {
|
|
6531
|
+
byte(224 | cp >> 12);
|
|
6532
|
+
byte(128 | cp >> 6 & 63);
|
|
6533
|
+
byte(128 | cp & 63);
|
|
6534
|
+
} else {
|
|
6535
|
+
byte(240 | cp >> 18);
|
|
6536
|
+
byte(128 | cp >> 12 & 63);
|
|
6537
|
+
byte(128 | cp >> 6 & 63);
|
|
6538
|
+
byte(128 | cp & 63);
|
|
6539
|
+
i++;
|
|
6540
|
+
}
|
|
6541
|
+
}
|
|
6542
|
+
};
|
|
6543
|
+
const string = (text) => {
|
|
6544
|
+
emit('"');
|
|
6545
|
+
for (let start = 0; start < text.length; ) {
|
|
6546
|
+
let end = Math.min(start + 2048, text.length);
|
|
6547
|
+
if (end < text.length && text.charCodeAt(end - 1) >= 55296 && text.charCodeAt(end - 1) <= 56319) end--;
|
|
6548
|
+
const escaped = JSON.stringify(text.slice(start, end));
|
|
6549
|
+
emit(escaped.slice(1, -1));
|
|
6550
|
+
start = end;
|
|
6551
|
+
}
|
|
6552
|
+
emit('"');
|
|
6553
|
+
};
|
|
6554
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
6555
|
+
const omitted = (v) => v === void 0 || typeof v === "function" || typeof v === "symbol";
|
|
6556
|
+
const visit = (v) => {
|
|
6557
|
+
if (typeof v === "string") {
|
|
6558
|
+
string(v);
|
|
6559
|
+
return;
|
|
6560
|
+
}
|
|
6561
|
+
if (v === null || typeof v !== "object") {
|
|
6562
|
+
const encoded = JSON.stringify(v);
|
|
6563
|
+
if (encoded === void 0) throw new TypeError("Not a JSON value");
|
|
6564
|
+
emit(encoded);
|
|
6565
|
+
return;
|
|
6566
|
+
}
|
|
6567
|
+
const prototype = Object.getPrototypeOf(v);
|
|
6568
|
+
if (!Array.isArray(v) && prototype !== Object.prototype && prototype !== null || typeof v.toJSON === "function") throw new TypeError("Not a JSON snapshot");
|
|
6569
|
+
if (ancestors.has(v)) throw new TypeError("Circular JSON snapshot");
|
|
6570
|
+
ancestors.add(v);
|
|
6571
|
+
if (Array.isArray(v)) {
|
|
6572
|
+
emit("[");
|
|
6573
|
+
for (let i = 0; i < v.length; i++) {
|
|
6574
|
+
if (Object.getOwnPropertyDescriptor(v, i)?.get) throw new TypeError("Not a JSON snapshot");
|
|
6575
|
+
if (i) emit(",");
|
|
6576
|
+
visit(omitted(v[i]) ? null : v[i]);
|
|
6577
|
+
}
|
|
6578
|
+
emit("]");
|
|
6486
6579
|
} else {
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6580
|
+
emit("{");
|
|
6581
|
+
let first = true;
|
|
6582
|
+
for (const key of Object.keys(v)) {
|
|
6583
|
+
if (Object.getOwnPropertyDescriptor(v, key)?.get) throw new TypeError("Not a JSON snapshot");
|
|
6584
|
+
const entry = v[key];
|
|
6585
|
+
if (omitted(entry)) continue;
|
|
6586
|
+
if (!first) emit(",");
|
|
6587
|
+
first = false;
|
|
6588
|
+
string(key);
|
|
6589
|
+
emit(":");
|
|
6590
|
+
visit(entry);
|
|
6591
|
+
}
|
|
6592
|
+
emit("}");
|
|
6492
6593
|
}
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
emit('"');
|
|
6497
|
-
for (let start = 0; start < text.length; ) {
|
|
6498
|
-
let end = Math.min(start + 2048, text.length);
|
|
6499
|
-
if (end < text.length && text.charCodeAt(end - 1) >= 55296 && text.charCodeAt(end - 1) <= 56319) end--;
|
|
6500
|
-
const escaped = JSON.stringify(text.slice(start, end));
|
|
6501
|
-
emit(escaped.slice(1, -1));
|
|
6502
|
-
start = end;
|
|
6503
|
-
}
|
|
6504
|
-
emit('"');
|
|
6505
|
-
};
|
|
6506
|
-
const ancestors = /* @__PURE__ */ new Set();
|
|
6507
|
-
const omitted = (v) => v === void 0 || typeof v === "function" || typeof v === "symbol";
|
|
6508
|
-
const visit = (v) => {
|
|
6509
|
-
if (typeof v === "string") {
|
|
6510
|
-
string(v);
|
|
6511
|
-
return;
|
|
6512
|
-
}
|
|
6513
|
-
if (v === null || typeof v !== "object") {
|
|
6514
|
-
const encoded = JSON.stringify(v);
|
|
6515
|
-
if (encoded === void 0) throw new TypeError("Not a JSON value");
|
|
6516
|
-
emit(encoded);
|
|
6517
|
-
return;
|
|
6518
|
-
}
|
|
6519
|
-
const prototype = Object.getPrototypeOf(v);
|
|
6520
|
-
if (!Array.isArray(v) && prototype !== Object.prototype && prototype !== null || typeof v.toJSON === "function") throw new TypeError("Not a JSON snapshot");
|
|
6521
|
-
if (ancestors.has(v)) throw new TypeError("Circular JSON snapshot");
|
|
6522
|
-
ancestors.add(v);
|
|
6523
|
-
if (Array.isArray(v)) {
|
|
6594
|
+
ancestors.delete(v);
|
|
6595
|
+
};
|
|
6596
|
+
if (parts) {
|
|
6524
6597
|
emit("[");
|
|
6525
|
-
for (let i = 0; i <
|
|
6526
|
-
if (Object.getOwnPropertyDescriptor(v, i)?.get) throw new TypeError("Not a JSON snapshot");
|
|
6598
|
+
for (let i = 0; i < parts.count + parts.output.length; i++) {
|
|
6527
6599
|
if (i) emit(",");
|
|
6528
|
-
|
|
6600
|
+
const item = i < parts.count ? parts.input[i] : parts.output[i - parts.count];
|
|
6601
|
+
visit(omitted(item) ? null : item);
|
|
6529
6602
|
}
|
|
6530
6603
|
emit("]");
|
|
6531
|
-
} else
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
emit(":");
|
|
6542
|
-
visit(entry);
|
|
6543
|
-
}
|
|
6544
|
-
emit("}");
|
|
6545
|
-
}
|
|
6546
|
-
ancestors.delete(v);
|
|
6547
|
-
};
|
|
6548
|
-
if (parts) {
|
|
6549
|
-
emit("[");
|
|
6550
|
-
for (let i = 0; i < parts.count + parts.output.length; i++) {
|
|
6551
|
-
if (i) emit(",");
|
|
6552
|
-
const item = i < parts.count ? parts.input[i] : parts.output[i - parts.count];
|
|
6553
|
-
visit(omitted(item) ? null : item);
|
|
6554
|
-
}
|
|
6555
|
-
emit("]");
|
|
6556
|
-
} else visit(value);
|
|
6557
|
-
if (used) hash.update(bytes.subarray(0, used));
|
|
6558
|
-
return hash.digestHex();
|
|
6604
|
+
} else visit(value);
|
|
6605
|
+
if (utf8) {
|
|
6606
|
+
if (fragments) utf8.updateUtf8(fragments);
|
|
6607
|
+
return utf8.digestHex();
|
|
6608
|
+
}
|
|
6609
|
+
if (used) hash.update(bytes.subarray(0, used));
|
|
6610
|
+
return hash.digestHex();
|
|
6611
|
+
} finally {
|
|
6612
|
+
utf8?.dispose();
|
|
6613
|
+
}
|
|
6559
6614
|
}
|
|
6560
6615
|
function inputSha256(input, count = input.length, output = []) {
|
|
6561
6616
|
return hashJson(void 0, { input, count, output });
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
createToolCallerIdentity,
|
|
9
9
|
getAgentFailureMetadata,
|
|
10
10
|
getToolCallerIdentity
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-TDHVB2FH.js";
|
|
12
|
+
import "./chunk-NM2JLPJ6.js";
|
|
13
13
|
import "./chunk-XXGYUYXI.js";
|
|
14
14
|
import "./chunk-LZQXQOPJ.js";
|
|
15
15
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
EventStream
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NM2JLPJ6.js";
|
|
5
5
|
import "./chunk-XXGYUYXI.js";
|
|
6
6
|
import "./chunk-LZQXQOPJ.js";
|
|
7
7
|
|