@cydm/pie 2.7.19 → 2.8.0
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 +6 -6
- package/dist/builtin/extensions/ask-user/README.md +117 -0
- package/dist/builtin/extensions/ask-user/index.js +3 -3
- package/dist/builtin/extensions/cron/index.js +166 -23
- package/dist/builtin/extensions/im-forward/README.md +297 -0
- package/dist/builtin/extensions/im-forward/index.js +319 -42
- package/dist/builtin/extensions/init/index.js +0 -6
- package/dist/builtin/extensions/mcp-adapter/README.md +27 -0
- package/dist/builtin/extensions/memory/index.js +323 -0
- package/dist/builtin/extensions/memory/package.json +18 -0
- package/dist/builtin/extensions/pie-ipc/README.md +21 -0
- package/dist/builtin/extensions/pie-ipc/index.js +16 -16
- package/dist/builtin/extensions/plan-mode/METHOD.md +70 -0
- package/dist/builtin/extensions/plan-mode/index.js +149 -82
- package/dist/builtin/extensions/subagent/README.md +315 -0
- package/dist/builtin/extensions/subagent/index.js +7 -5
- package/dist/builtin/extensions/todo/index.js +3 -3
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/{chunk-U75F4DPF.js → chunk-BNSAEVRT.js} +201 -77
- package/dist/builtin/skills/chrome-devtools-axi/{cli-4ITIR57L.js → cli-AO2ZTPRM.js} +57 -202
- package/dist/chunks/chunk-5353DEEC.js +130 -0
- package/dist/chunks/{chunk-2H2DD22Z.js → chunk-HGC25NYB.js} +1 -1
- package/dist/chunks/{chunk-X7UO6BA6.js → chunk-JNOFHHLZ.js} +156 -65
- package/dist/chunks/{chunk-UDCGB3LZ.js → chunk-LJXHECZ7.js} +12183 -10951
- package/dist/chunks/{chunk-TGCI5M6R.js → chunk-NEES4EBX.js} +19 -141
- package/dist/chunks/{src-GX4UBAYF.js → src-5XOKRS6F.js} +2 -2
- package/dist/chunks/{test-stream-AKIZNFCM.js → test-stream-5SDHKKDB.js} +1 -1
- package/dist/cli.js +127 -96
- package/package.json +2 -2
|
@@ -362,6 +362,48 @@ var AssistantMessageEventStream = class extends EventStream {
|
|
|
362
362
|
}
|
|
363
363
|
};
|
|
364
364
|
|
|
365
|
+
// ../../packages/ai/src/api-registry.ts
|
|
366
|
+
var apiProviderRegistry = /* @__PURE__ */ new Map();
|
|
367
|
+
function registerApiProvider(provider) {
|
|
368
|
+
apiProviderRegistry.set(provider.api, {
|
|
369
|
+
api: provider.api,
|
|
370
|
+
stream: (model, context, options) => provider.stream(model, context, options),
|
|
371
|
+
streamSimple: (model, context, options) => provider.streamSimple(model, context, options)
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
function getApiProvider(api) {
|
|
375
|
+
return apiProviderRegistry.get(api);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// ../../packages/ai/src/env-api-keys.ts
|
|
379
|
+
function getEnvApiKey(provider, explicitEnvVar) {
|
|
380
|
+
void provider;
|
|
381
|
+
const env = typeof process !== "undefined" ? process.env : {};
|
|
382
|
+
const explicitEnv = explicitEnvVar;
|
|
383
|
+
if (explicitEnv) {
|
|
384
|
+
const value = env[explicitEnv];
|
|
385
|
+
if (value) return value;
|
|
386
|
+
}
|
|
387
|
+
return void 0;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// ../../packages/ai/src/stream.ts
|
|
391
|
+
function resolveApiProvider(api) {
|
|
392
|
+
const provider = getApiProvider(api);
|
|
393
|
+
if (!provider) {
|
|
394
|
+
throw new Error(`No API provider registered for api: ${api}`);
|
|
395
|
+
}
|
|
396
|
+
return provider;
|
|
397
|
+
}
|
|
398
|
+
function streamSimple(model, context, options) {
|
|
399
|
+
const provider = resolveApiProvider(model.api);
|
|
400
|
+
return provider.streamSimple(model, context, options);
|
|
401
|
+
}
|
|
402
|
+
async function completeSimple(model, context, options) {
|
|
403
|
+
const s = streamSimple(model, context, options);
|
|
404
|
+
return s.result();
|
|
405
|
+
}
|
|
406
|
+
|
|
365
407
|
// ../../node_modules/@sinclair/typebox/build/esm/type/registry/format.mjs
|
|
366
408
|
var format_exports = {};
|
|
367
409
|
__export(format_exports, {
|
|
@@ -443,31 +485,6 @@ function ExtendsUndefinedCheck(schema) {
|
|
|
443
485
|
return schema[Kind] === "Intersect" ? Intersect(schema) : schema[Kind] === "Union" ? Union2(schema) : schema[Kind] === "Not" ? Not(schema) : schema[Kind] === "Undefined" ? true : false;
|
|
444
486
|
}
|
|
445
487
|
|
|
446
|
-
// ../../packages/ai/src/api-registry.ts
|
|
447
|
-
var apiProviderRegistry = /* @__PURE__ */ new Map();
|
|
448
|
-
function registerApiProvider(provider) {
|
|
449
|
-
apiProviderRegistry.set(provider.api, {
|
|
450
|
-
api: provider.api,
|
|
451
|
-
stream: (model, context, options) => provider.stream(model, context, options),
|
|
452
|
-
streamSimple: (model, context, options) => provider.streamSimple(model, context, options)
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
function getApiProvider(api) {
|
|
456
|
-
return apiProviderRegistry.get(api);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
// ../../packages/ai/src/env-api-keys.ts
|
|
460
|
-
function getEnvApiKey(provider, explicitEnvVar) {
|
|
461
|
-
void provider;
|
|
462
|
-
const env = typeof process !== "undefined" ? process.env : {};
|
|
463
|
-
const explicitEnv = explicitEnvVar;
|
|
464
|
-
if (explicitEnv) {
|
|
465
|
-
const value = env[explicitEnv];
|
|
466
|
-
if (value) return value;
|
|
467
|
-
}
|
|
468
|
-
return void 0;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
488
|
// ../../packages/ai/src/models.ts
|
|
472
489
|
function calculateCost(model, usage) {
|
|
473
490
|
const input = model.cost.input / 1e6 * usage.input;
|
|
@@ -2160,8 +2177,15 @@ function isAbortErrorMessage(message) {
|
|
|
2160
2177
|
}
|
|
2161
2178
|
var nodeHttps = null;
|
|
2162
2179
|
var nodeHttp = null;
|
|
2180
|
+
var nodeTls = null;
|
|
2163
2181
|
var nodeUrl = null;
|
|
2164
2182
|
var nodeStringDecoder = null;
|
|
2183
|
+
function getNodeTls() {
|
|
2184
|
+
if (!nodeTls) {
|
|
2185
|
+
nodeTls = require3("tls");
|
|
2186
|
+
}
|
|
2187
|
+
return nodeTls;
|
|
2188
|
+
}
|
|
2165
2189
|
function getNodeHttps() {
|
|
2166
2190
|
if (!nodeHttps) {
|
|
2167
2191
|
nodeHttps = require3("https");
|
|
@@ -2188,6 +2212,7 @@ function getNodeStringDecoder() {
|
|
|
2188
2212
|
}
|
|
2189
2213
|
var globalHttpsAgent = null;
|
|
2190
2214
|
var globalHttpAgent = null;
|
|
2215
|
+
var globalProxyTunnels = /* @__PURE__ */ new Map();
|
|
2191
2216
|
var agentStats = {
|
|
2192
2217
|
httpsRequests: 0,
|
|
2193
2218
|
httpsReusedConnections: 0,
|
|
@@ -2230,6 +2255,52 @@ function getHttpAgent() {
|
|
|
2230
2255
|
}
|
|
2231
2256
|
return globalHttpAgent;
|
|
2232
2257
|
}
|
|
2258
|
+
function getProxyTunnelAgent(targetHost) {
|
|
2259
|
+
const proxy = process.env.HTTPS_PROXY || process.env.https_proxy || process.env.ALL_PROXY || process.env.all_proxy || "";
|
|
2260
|
+
if (!proxy || !/^https?:\/\//i.test(proxy)) return null;
|
|
2261
|
+
const noProxy = (process.env.NO_PROXY || process.env.no_proxy || "").split(",").map((s) => s.trim().toLowerCase());
|
|
2262
|
+
if (noProxy.some((entry) => entry && (targetHost.toLowerCase() === entry || targetHost.toLowerCase().endsWith(`.${entry}`)))) {
|
|
2263
|
+
return null;
|
|
2264
|
+
}
|
|
2265
|
+
let agent = globalProxyTunnels.get(proxy);
|
|
2266
|
+
if (agent) return agent;
|
|
2267
|
+
const https = getNodeHttps();
|
|
2268
|
+
const parsed = new (getNodeUrl()).URL(proxy);
|
|
2269
|
+
const createConnection = (options, callback) => {
|
|
2270
|
+
const http = getNodeHttp();
|
|
2271
|
+
const connect = http.request({
|
|
2272
|
+
host: parsed.hostname,
|
|
2273
|
+
port: Number(parsed.port) || 80,
|
|
2274
|
+
method: "CONNECT",
|
|
2275
|
+
path: `${options.host}:${options.port}`,
|
|
2276
|
+
timeout: 15e3,
|
|
2277
|
+
headers: parsed.username ? { "proxy-authorization": `Basic ${Buffer.from(`${decodeURIComponent(parsed.username)}:${decodeURIComponent(parsed.password)}`).toString("base64")}` } : {}
|
|
2278
|
+
});
|
|
2279
|
+
connect.on("connect", (res, socket) => {
|
|
2280
|
+
if (!res.statusCode || res.statusCode < 200 || res.statusCode >= 300) {
|
|
2281
|
+
callback(new Error(`proxy CONNECT failed with ${res.statusCode}`));
|
|
2282
|
+
return;
|
|
2283
|
+
}
|
|
2284
|
+
const tls = getNodeTls();
|
|
2285
|
+
const tlsSocket = tls.connect(
|
|
2286
|
+
{ socket, servername: options.servername || options.host },
|
|
2287
|
+
() => callback(null, tlsSocket)
|
|
2288
|
+
);
|
|
2289
|
+
tlsSocket.once("error", (error) => callback(error));
|
|
2290
|
+
});
|
|
2291
|
+
connect.on("timeout", () => connect.destroy(new Error("proxy CONNECT timed out")));
|
|
2292
|
+
connect.on("error", (error) => callback(error));
|
|
2293
|
+
connect.end();
|
|
2294
|
+
};
|
|
2295
|
+
agent = new https.Agent({
|
|
2296
|
+
keepAlive: true,
|
|
2297
|
+
maxSockets: 10
|
|
2298
|
+
});
|
|
2299
|
+
agent.createConnection = createConnection;
|
|
2300
|
+
globalProxyTunnels.set(proxy, agent);
|
|
2301
|
+
logHttp("INFO", `Proxy tunnel agent created for ${parsed.host} (HTTPS_PROXY)`);
|
|
2302
|
+
return agent;
|
|
2303
|
+
}
|
|
2233
2304
|
var NodeHttpClient = class {
|
|
2234
2305
|
/** The Node client never re-sends a request: one `request()` call is one submission. */
|
|
2235
2306
|
transportCapabilities = { singleAttempt: true };
|
|
@@ -2264,7 +2335,7 @@ var NodeHttpClient = class {
|
|
|
2264
2335
|
const parsedUrl = new (getNodeUrl()).URL(url);
|
|
2265
2336
|
const isHttps = parsedUrl.protocol === "https:";
|
|
2266
2337
|
const lib = isHttps ? getNodeHttps() : getNodeHttp();
|
|
2267
|
-
const agent = isHttps ? getHttpsAgent() : getHttpAgent();
|
|
2338
|
+
const agent = (isHttps ? getProxyTunnelAgent(parsedUrl.hostname) : null) ?? (isHttps ? getHttpsAgent() : getHttpAgent());
|
|
2268
2339
|
if (isHttps) {
|
|
2269
2340
|
agentStats.httpsRequests++;
|
|
2270
2341
|
} else {
|
|
@@ -2589,6 +2660,13 @@ var NodeHttpClient = class {
|
|
|
2589
2660
|
});
|
|
2590
2661
|
}
|
|
2591
2662
|
};
|
|
2663
|
+
function scheduleNextTick(callback, _delayMs) {
|
|
2664
|
+
if (typeof setTimeout === "function") {
|
|
2665
|
+
setTimeout(callback, _delayMs);
|
|
2666
|
+
return;
|
|
2667
|
+
}
|
|
2668
|
+
Promise.resolve().then(callback);
|
|
2669
|
+
}
|
|
2592
2670
|
var PuerTSHttpClient = class {
|
|
2593
2671
|
/** No internal re-send: each call starts exactly one bridge request. */
|
|
2594
2672
|
transportCapabilities = { singleAttempt: true };
|
|
@@ -2597,7 +2675,14 @@ var PuerTSHttpClient = class {
|
|
|
2597
2675
|
url: url.slice(0, 100),
|
|
2598
2676
|
method: options.method || "GET"
|
|
2599
2677
|
});
|
|
2600
|
-
|
|
2678
|
+
void scheduleNextTick;
|
|
2679
|
+
let legacyBridge = false;
|
|
2680
|
+
try {
|
|
2681
|
+
legacyBridge = typeof CS !== "undefined" && !!CS?.AgentBridge && typeof CS.AgentBridge.HttpPostAsyncStart === "function";
|
|
2682
|
+
} catch {
|
|
2683
|
+
legacyBridge = false;
|
|
2684
|
+
}
|
|
2685
|
+
if (legacyBridge) {
|
|
2601
2686
|
const method2 = options.method || "GET";
|
|
2602
2687
|
const body2 = options.body || "";
|
|
2603
2688
|
const auth = options.headers?.Authorization || options.headers?.authorization || "";
|
|
@@ -2667,9 +2752,42 @@ var PuerTSHttpClient = class {
|
|
|
2667
2752
|
request.SetRequestHeader(key, value);
|
|
2668
2753
|
}
|
|
2669
2754
|
if (body && ["POST", "PUT", "PATCH"].includes(method.toUpperCase())) {
|
|
2670
|
-
const
|
|
2671
|
-
|
|
2672
|
-
|
|
2755
|
+
const encodeUtf8 = (text) => {
|
|
2756
|
+
const out = [];
|
|
2757
|
+
for (let i = 0; i < text.length; i++) {
|
|
2758
|
+
let code = text.charCodeAt(i);
|
|
2759
|
+
if (code < 128) out.push(code);
|
|
2760
|
+
else {
|
|
2761
|
+
if (code >= 55296 && code <= 56319 && i + 1 < text.length) {
|
|
2762
|
+
const low = text.charCodeAt(i + 1);
|
|
2763
|
+
if (low >= 56320 && low <= 57343) {
|
|
2764
|
+
code = 65536 + (code - 55296 << 10) + (low - 56320);
|
|
2765
|
+
i++;
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
if (code < 2048) out.push(192 | code >> 6, 128 | code & 63);
|
|
2769
|
+
else if (code < 65536) out.push(224 | code >> 12, 128 | code >> 6 & 63, 128 | code & 63);
|
|
2770
|
+
else out.push(240 | code >> 18, 128 | code >> 12 & 63, 128 | code >> 6 & 63, 128 | code & 63);
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
return new Uint8Array(out);
|
|
2774
|
+
};
|
|
2775
|
+
const base64 = (bytes) => {
|
|
2776
|
+
let binary = "";
|
|
2777
|
+
const table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
2778
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
2779
|
+
const b0 = bytes[i], b1 = bytes[i + 1], b2 = bytes[i + 2];
|
|
2780
|
+
binary += table[b0 >> 2] + table[(b0 & 3) << 4 | (b1 ?? 0) >> 4];
|
|
2781
|
+
if (b1 === void 0) break;
|
|
2782
|
+
binary += table[(b1 & 15) << 2 | (b2 ?? 0) >> 6];
|
|
2783
|
+
if (b2 === void 0) break;
|
|
2784
|
+
binary += table[b2 & 63];
|
|
2785
|
+
}
|
|
2786
|
+
const pad = bytes.length % 3;
|
|
2787
|
+
return binary + (pad === 1 ? "==" : pad === 2 ? "=" : "");
|
|
2788
|
+
};
|
|
2789
|
+
const bodyBytes = CS.System.Convert.FromBase64String(base64(encodeUtf8(body)));
|
|
2790
|
+
request.uploadHandler = new UnityEngine.Networking.UploadHandlerRaw(bodyBytes);
|
|
2673
2791
|
}
|
|
2674
2792
|
request.downloadHandler = new UnityEngine.Networking.DownloadHandlerBuffer();
|
|
2675
2793
|
let aborted = false;
|
|
@@ -2682,6 +2800,12 @@ var PuerTSHttpClient = class {
|
|
|
2682
2800
|
options.signal.addEventListener("abort", onAbort, { once: true });
|
|
2683
2801
|
}
|
|
2684
2802
|
const asyncOp = request.SendWebRequest();
|
|
2803
|
+
const completed = new Promise((resolveCompleted) => {
|
|
2804
|
+
try {
|
|
2805
|
+
asyncOp.add_completed(() => resolveCompleted());
|
|
2806
|
+
} catch {
|
|
2807
|
+
}
|
|
2808
|
+
});
|
|
2685
2809
|
const checkComplete = () => {
|
|
2686
2810
|
if (aborted) return;
|
|
2687
2811
|
if (asyncOp.isDone) {
|
|
@@ -2727,26 +2851,10 @@ var PuerTSHttpClient = class {
|
|
|
2727
2851
|
}
|
|
2728
2852
|
});
|
|
2729
2853
|
} else {
|
|
2730
|
-
|
|
2731
|
-
setTimeout(checkComplete, 10);
|
|
2732
|
-
} else {
|
|
2733
|
-
const startWait = Date.now();
|
|
2734
|
-
const wait = () => {
|
|
2735
|
-
if (!asyncOp.isDone && Date.now() - startWait < 3e4) {
|
|
2736
|
-
if (typeof setImmediate !== "undefined") {
|
|
2737
|
-
setImmediate(wait);
|
|
2738
|
-
} else {
|
|
2739
|
-
checkComplete();
|
|
2740
|
-
}
|
|
2741
|
-
} else {
|
|
2742
|
-
checkComplete();
|
|
2743
|
-
}
|
|
2744
|
-
};
|
|
2745
|
-
wait();
|
|
2746
|
-
}
|
|
2854
|
+
void completed.then(() => checkComplete());
|
|
2747
2855
|
}
|
|
2748
2856
|
};
|
|
2749
|
-
checkComplete
|
|
2857
|
+
scheduleNextTick(checkComplete, 0);
|
|
2750
2858
|
});
|
|
2751
2859
|
}
|
|
2752
2860
|
};
|
|
@@ -7244,23 +7352,6 @@ var streamSimpleResponses = (model, context, options) => {
|
|
|
7244
7352
|
});
|
|
7245
7353
|
};
|
|
7246
7354
|
|
|
7247
|
-
// ../../packages/ai/src/stream.ts
|
|
7248
|
-
function resolveApiProvider(api) {
|
|
7249
|
-
const provider = getApiProvider(api);
|
|
7250
|
-
if (!provider) {
|
|
7251
|
-
throw new Error(`No API provider registered for api: ${api}`);
|
|
7252
|
-
}
|
|
7253
|
-
return provider;
|
|
7254
|
-
}
|
|
7255
|
-
function streamSimple(model, context, options) {
|
|
7256
|
-
const provider = resolveApiProvider(model.api);
|
|
7257
|
-
return provider.streamSimple(model, context, options);
|
|
7258
|
-
}
|
|
7259
|
-
async function completeSimple(model, context, options) {
|
|
7260
|
-
const s = streamSimple(model, context, options);
|
|
7261
|
-
return s.result();
|
|
7262
|
-
}
|
|
7263
|
-
|
|
7264
7355
|
// ../../packages/ai/src/tool-model-routing.ts
|
|
7265
7356
|
var MODEL_CLASS_FALLBACK_ORDER = ["balanced", "light", "strong"];
|
|
7266
7357
|
var WEB_SEARCH_CAPABILITY_PRIORITY = {
|