@karlorz/codexhost-cli-win32-x64 0.17.0-1 → 0.17.3-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 +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +15 -0
- package/app/console-web.js +16 -1
- package/app/cpa-live-voice-hook.js +51 -33
- package/app/desktop-controller.mjs +1182 -46
- package/app/host-runtime.mjs +1239 -59
- package/app/plugins/antigravity/plugin.mjs +42 -7
- package/app/plugins/claude-code/plugin.mjs +15 -0
- package/app/plugins/codebuddy/plugin.mjs +15 -0
- package/app/plugins/codex-usage/plugin.mjs +15 -0
- package/app/plugins/copilot/plugin.mjs +15 -0
- package/app/plugins/cursor-cli/plugin.mjs +34 -3
- package/app/plugins/deepseek-harness/plugin.mjs +15 -0
- package/app/plugins/devin/plugin.mjs +15 -0
- package/app/plugins/grok/plugin.mjs +383 -70
- package/app/plugins/hermes/plugin.mjs +15 -0
- package/app/plugins/kimi-code/plugin.mjs +65 -3
- package/app/plugins/kiro-cli/plugin.mjs +15 -0
- package/app/plugins/omp/plugin.mjs +15 -0
- package/app/plugins/opencode/plugin.mjs +15 -0
- package/app/plugins/pi/plugin.mjs +223 -88
- package/app/plugins/qoder/plugin.mjs +15 -0
- package/app/plugins/qoder-cn/plugin.mjs +15 -0
- package/app/plugins/qwen-code/plugin.mjs +15 -0
- package/app/plugins/workbuddy/plugin.mjs +15 -0
- package/app/plugins/zcode/plugin.mjs +157 -9
- package/app/renderer-extension.js +594 -251
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
|
@@ -1317,10 +1317,10 @@ function mergeDefs(...defs) {
|
|
|
1317
1317
|
function cloneDef(schema) {
|
|
1318
1318
|
return mergeDefs(schema._zod.def);
|
|
1319
1319
|
}
|
|
1320
|
-
function getElementAtPath(obj,
|
|
1321
|
-
if (!
|
|
1320
|
+
function getElementAtPath(obj, path18) {
|
|
1321
|
+
if (!path18)
|
|
1322
1322
|
return obj;
|
|
1323
|
-
return
|
|
1323
|
+
return path18.reduce((acc, key) => acc?.[key], obj);
|
|
1324
1324
|
}
|
|
1325
1325
|
function promiseAllObject(promisesObj) {
|
|
1326
1326
|
const keys = Object.keys(promisesObj);
|
|
@@ -1729,11 +1729,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1729
1729
|
}
|
|
1730
1730
|
return false;
|
|
1731
1731
|
}
|
|
1732
|
-
function prefixIssues(
|
|
1732
|
+
function prefixIssues(path18, issues) {
|
|
1733
1733
|
return issues.map((iss) => {
|
|
1734
1734
|
var _a3;
|
|
1735
1735
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1736
|
-
iss.path.unshift(
|
|
1736
|
+
iss.path.unshift(path18);
|
|
1737
1737
|
return iss;
|
|
1738
1738
|
});
|
|
1739
1739
|
}
|
|
@@ -1880,16 +1880,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1880
1880
|
}
|
|
1881
1881
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1882
1882
|
const fieldErrors = { _errors: [] };
|
|
1883
|
-
const processError = (error52,
|
|
1883
|
+
const processError = (error52, path18 = []) => {
|
|
1884
1884
|
for (const issue2 of error52.issues) {
|
|
1885
1885
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1886
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1886
|
+
issue2.errors.map((issues) => processError({ issues }, [...path18, ...issue2.path]));
|
|
1887
1887
|
} else if (issue2.code === "invalid_key") {
|
|
1888
|
-
processError({ issues: issue2.issues }, [...
|
|
1888
|
+
processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
|
|
1889
1889
|
} else if (issue2.code === "invalid_element") {
|
|
1890
|
-
processError({ issues: issue2.issues }, [...
|
|
1890
|
+
processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
|
|
1891
1891
|
} else {
|
|
1892
|
-
const fullpath = [...
|
|
1892
|
+
const fullpath = [...path18, ...issue2.path];
|
|
1893
1893
|
if (fullpath.length === 0) {
|
|
1894
1894
|
fieldErrors._errors.push(mapper(issue2));
|
|
1895
1895
|
} else {
|
|
@@ -1916,17 +1916,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1916
1916
|
}
|
|
1917
1917
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1918
1918
|
const result = { errors: [] };
|
|
1919
|
-
const processError = (error52,
|
|
1919
|
+
const processError = (error52, path18 = []) => {
|
|
1920
1920
|
var _a3, _b;
|
|
1921
1921
|
for (const issue2 of error52.issues) {
|
|
1922
1922
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1923
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1923
|
+
issue2.errors.map((issues) => processError({ issues }, [...path18, ...issue2.path]));
|
|
1924
1924
|
} else if (issue2.code === "invalid_key") {
|
|
1925
|
-
processError({ issues: issue2.issues }, [...
|
|
1925
|
+
processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
|
|
1926
1926
|
} else if (issue2.code === "invalid_element") {
|
|
1927
|
-
processError({ issues: issue2.issues }, [...
|
|
1927
|
+
processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
|
|
1928
1928
|
} else {
|
|
1929
|
-
const fullpath = [...
|
|
1929
|
+
const fullpath = [...path18, ...issue2.path];
|
|
1930
1930
|
if (fullpath.length === 0) {
|
|
1931
1931
|
result.errors.push(mapper(issue2));
|
|
1932
1932
|
continue;
|
|
@@ -1958,8 +1958,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1958
1958
|
}
|
|
1959
1959
|
function toDotPath(_path) {
|
|
1960
1960
|
const segs = [];
|
|
1961
|
-
const
|
|
1962
|
-
for (const seg of
|
|
1961
|
+
const path18 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1962
|
+
for (const seg of path18) {
|
|
1963
1963
|
if (typeof seg === "number")
|
|
1964
1964
|
segs.push(`[${seg}]`);
|
|
1965
1965
|
else if (typeof seg === "symbol")
|
|
@@ -8189,8 +8189,8 @@ function ko_default() {
|
|
|
8189
8189
|
}
|
|
8190
8190
|
|
|
8191
8191
|
// ../../../node_modules/zod/v4/locales/lt.js
|
|
8192
|
-
var capitalizeFirstCharacter = (
|
|
8193
|
-
return
|
|
8192
|
+
var capitalizeFirstCharacter = (text4) => {
|
|
8193
|
+
return text4.charAt(0).toUpperCase() + text4.slice(1);
|
|
8194
8194
|
};
|
|
8195
8195
|
function getUnitTypeFromNumber(number4) {
|
|
8196
8196
|
const abs = Math.abs(number4);
|
|
@@ -14651,13 +14651,13 @@ function resolveRef(ref, ctx) {
|
|
|
14651
14651
|
if (!ref.startsWith("#")) {
|
|
14652
14652
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14653
14653
|
}
|
|
14654
|
-
const
|
|
14655
|
-
if (
|
|
14654
|
+
const path18 = ref.slice(1).split("/").filter(Boolean);
|
|
14655
|
+
if (path18.length === 0) {
|
|
14656
14656
|
return ctx.rootSchema;
|
|
14657
14657
|
}
|
|
14658
14658
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14659
|
-
if (
|
|
14660
|
-
const key =
|
|
14659
|
+
if (path18[0] === defsKey) {
|
|
14660
|
+
const key = path18[1];
|
|
14661
14661
|
if (!key || !ctx.defs[key]) {
|
|
14662
14662
|
throw new Error(`Reference not found: ${ref}`);
|
|
14663
14663
|
}
|
|
@@ -15173,7 +15173,7 @@ var harnessDisplaySetSchema = external_exports.strictObject({
|
|
|
15173
15173
|
|
|
15174
15174
|
// ../../shared-contracts/dist/harness-presentation.js
|
|
15175
15175
|
var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
|
|
15176
|
-
var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((
|
|
15176
|
+
var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text4) => text4.trim().length > 0);
|
|
15177
15177
|
var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
|
|
15178
15178
|
label: displayText(256).optional(),
|
|
15179
15179
|
description: displayText(1024).optional()
|
|
@@ -15545,7 +15545,7 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
|
15545
15545
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
15546
15546
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
15547
15547
|
var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
|
|
15548
|
-
var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((
|
|
15548
|
+
var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text4) => text4.length <= maximum));
|
|
15549
15549
|
var composerIndicatorsSchema = external_exports.array(external_exports.object({
|
|
15550
15550
|
kind: external_exports.literal("countdown"),
|
|
15551
15551
|
id: external_exports.string().min(1).max(64),
|
|
@@ -16105,6 +16105,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
16105
16105
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
16106
16106
|
text: external_exports.string().optional()
|
|
16107
16107
|
}).strict();
|
|
16108
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
16109
|
+
kind: external_exports.literal("application"),
|
|
16110
|
+
value: external_exports.string().transform((text4, context) => {
|
|
16111
|
+
try {
|
|
16112
|
+
return JSON.parse(text4);
|
|
16113
|
+
} catch {
|
|
16114
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
16115
|
+
return external_exports.NEVER;
|
|
16116
|
+
}
|
|
16117
|
+
}).pipe(external_exports.object({
|
|
16118
|
+
expectedTurnId: hostTurnIdSchema,
|
|
16119
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
16120
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
16121
|
+
}).strict())
|
|
16122
|
+
}).strict().transform((context) => context.value);
|
|
16108
16123
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
16109
16124
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
16110
16125
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -16889,8 +16904,8 @@ async function readCandidate(file2, signal) {
|
|
|
16889
16904
|
const message3 = isRecord(entry.message) ? entry.message : null;
|
|
16890
16905
|
if (!firstMessage && entry.type === "message" && message3?.role === "user") {
|
|
16891
16906
|
const content = message3.content;
|
|
16892
|
-
const
|
|
16893
|
-
firstMessage = sessionImportTitle(
|
|
16907
|
+
const text4 = typeof content === "string" ? content : Array.isArray(content) ? content.filter((block) => isRecord(block) && block.type === "text" && typeof block.text === "string").map((block) => block.text).join(" ") : "";
|
|
16908
|
+
firstMessage = sessionImportTitle(text4);
|
|
16894
16909
|
}
|
|
16895
16910
|
hasUser = entry.type === "message" && message3?.role === "user" || typeof entry.parentId === "string" && entries.get(entry.parentId) === true;
|
|
16896
16911
|
entries.set(entry.id, hasUser);
|
|
@@ -17406,8 +17421,8 @@ function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
|
|
|
17406
17421
|
const descriptor = catalog.commands.find(({ id }) => id === commandId);
|
|
17407
17422
|
if (!descriptor)
|
|
17408
17423
|
return null;
|
|
17409
|
-
const
|
|
17410
|
-
return
|
|
17424
|
+
const text4 = typeof argumentText === "string" ? argumentText.trim() : "";
|
|
17425
|
+
return text4 ? `${descriptor.invocation} ${text4}` : descriptor.invocation;
|
|
17411
17426
|
}
|
|
17412
17427
|
function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
17413
17428
|
if (!live)
|
|
@@ -17543,16 +17558,16 @@ var Diff = class {
|
|
|
17543
17558
|
}
|
|
17544
17559
|
}
|
|
17545
17560
|
}
|
|
17546
|
-
addToPath(
|
|
17547
|
-
const last =
|
|
17561
|
+
addToPath(path18, added, removed, oldPosInc, options) {
|
|
17562
|
+
const last = path18.lastComponent;
|
|
17548
17563
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
17549
17564
|
return {
|
|
17550
|
-
oldPos:
|
|
17565
|
+
oldPos: path18.oldPos + oldPosInc,
|
|
17551
17566
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
17552
17567
|
};
|
|
17553
17568
|
} else {
|
|
17554
17569
|
return {
|
|
17555
|
-
oldPos:
|
|
17570
|
+
oldPos: path18.oldPos + oldPosInc,
|
|
17556
17571
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
17557
17572
|
};
|
|
17558
17573
|
}
|
|
@@ -17952,9 +17967,9 @@ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader
|
|
|
17952
17967
|
} }));
|
|
17953
17968
|
}
|
|
17954
17969
|
}
|
|
17955
|
-
function splitLines(
|
|
17956
|
-
const hasTrailingNl =
|
|
17957
|
-
const result =
|
|
17970
|
+
function splitLines(text4) {
|
|
17971
|
+
const hasTrailingNl = text4.endsWith("\n");
|
|
17972
|
+
const result = text4.split("\n").map((line) => line + "\n");
|
|
17958
17973
|
if (hasTrailingNl) {
|
|
17959
17974
|
result.pop();
|
|
17960
17975
|
} else {
|
|
@@ -18917,11 +18932,11 @@ ${entry.text}`);
|
|
|
18917
18932
|
formatVersion: 1
|
|
18918
18933
|
}),
|
|
18919
18934
|
input: reply.task ? [{ type: "text", text: reply.task }] : [],
|
|
18920
|
-
items: texts.map((
|
|
18935
|
+
items: texts.map((text4, index) => ({
|
|
18921
18936
|
item: {
|
|
18922
18937
|
type: "agentMessage",
|
|
18923
|
-
text:
|
|
18924
|
-
itemId: hostItemIdSchema.parse(`pi-subagent-${createHash3("sha256").update(`${id}:${index}:${
|
|
18938
|
+
text: text4,
|
|
18939
|
+
itemId: hostItemIdSchema.parse(`pi-subagent-${createHash3("sha256").update(`${id}:${index}:${text4}`).digest("hex")}`)
|
|
18925
18940
|
},
|
|
18926
18941
|
outcome: { status: "succeeded" }
|
|
18927
18942
|
})),
|
|
@@ -19081,13 +19096,13 @@ function textContent(content) {
|
|
|
19081
19096
|
return "";
|
|
19082
19097
|
return content.filter((part) => record4(part) && part.type === "text" && typeof part.text === "string").map((part) => part.text).join("");
|
|
19083
19098
|
}
|
|
19084
|
-
function boundedPiProgress(
|
|
19099
|
+
function boundedPiProgress(text4) {
|
|
19085
19100
|
const limit = 64e3;
|
|
19086
|
-
return
|
|
19101
|
+
return text4.length <= limit ? text4 : `${text4.slice(0, limit)}
|
|
19087
19102
|
[Pi notification truncated]`;
|
|
19088
19103
|
}
|
|
19089
|
-
function visibleText(
|
|
19090
|
-
return
|
|
19104
|
+
function visibleText(text4) {
|
|
19105
|
+
return text4.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
19091
19106
|
}
|
|
19092
19107
|
function noticeDisplay(value, fallback) {
|
|
19093
19108
|
if (!record4(value) || !record4(value.details) || typeof value.details.summary !== "string")
|
|
@@ -19108,10 +19123,10 @@ function noticeDisplay(value, fallback) {
|
|
|
19108
19123
|
function piCustomNoticeKey(value) {
|
|
19109
19124
|
if (!record4(value) || value.type !== "custom_message" && value.role !== "custom" || value.display !== true || typeof value.customType !== "string")
|
|
19110
19125
|
return null;
|
|
19111
|
-
const
|
|
19112
|
-
if (
|
|
19126
|
+
const text4 = textContent(value.content);
|
|
19127
|
+
if (text4.trim().length === 0)
|
|
19113
19128
|
return null;
|
|
19114
|
-
return JSON.stringify([value.customType,
|
|
19129
|
+
return JSON.stringify([value.customType, text4]);
|
|
19115
19130
|
}
|
|
19116
19131
|
function piCustomNotice(value, sessionId, occurrences) {
|
|
19117
19132
|
const key = piCustomNoticeKey(value);
|
|
@@ -19120,13 +19135,13 @@ function piCustomNotice(value, sessionId, occurrences) {
|
|
|
19120
19135
|
const occurrence = occurrences.get(key) ?? 0;
|
|
19121
19136
|
occurrences.set(key, occurrence + 1);
|
|
19122
19137
|
const digest = createHash4("sha256").update(JSON.stringify([sessionId, key, occurrence])).digest("hex");
|
|
19123
|
-
const [customType,
|
|
19138
|
+
const [customType, text4] = JSON.parse(key);
|
|
19124
19139
|
return {
|
|
19125
19140
|
type: "progress.message",
|
|
19126
19141
|
itemId: hostItemIdSchema.parse(`pi-notice-v1-${digest}`),
|
|
19127
19142
|
text: boundedPiProgress(`Pi notification (${visibleText(customType)})
|
|
19128
19143
|
|
|
19129
|
-
${noticeDisplay(value,
|
|
19144
|
+
${noticeDisplay(value, text4)}`)
|
|
19130
19145
|
};
|
|
19131
19146
|
}
|
|
19132
19147
|
function piHistoryNotices(sessionId, entries) {
|
|
@@ -19287,8 +19302,8 @@ function itemOutcome(outcome) {
|
|
|
19287
19302
|
return { status: "succeeded" };
|
|
19288
19303
|
}
|
|
19289
19304
|
function toolOutput(value) {
|
|
19290
|
-
const
|
|
19291
|
-
return
|
|
19305
|
+
const text4 = textContent2(value);
|
|
19306
|
+
return text4.length > 0 ? { content: [{ type: "text", text: text4 }] } : void 0;
|
|
19292
19307
|
}
|
|
19293
19308
|
function historicalFileChanges(call, nativeMessage, toolItemId, cwd) {
|
|
19294
19309
|
const items = [];
|
|
@@ -19333,7 +19348,7 @@ function snapshotItems(entries, messageIdentities, notices, outcome, subagents,
|
|
|
19333
19348
|
continue;
|
|
19334
19349
|
const content = Array.isArray(nativeMessage.content) ? nativeMessage.content : [];
|
|
19335
19350
|
if (nativeMessage.role === "assistant") {
|
|
19336
|
-
const
|
|
19351
|
+
const text4 = textContent2(content);
|
|
19337
19352
|
const reasoning = thinkingContent(content);
|
|
19338
19353
|
let projectedText = false;
|
|
19339
19354
|
let projectedReasoning = false;
|
|
@@ -19350,12 +19365,12 @@ function snapshotItems(entries, messageIdentities, notices, outcome, subagents,
|
|
|
19350
19365
|
projectedReasoning = true;
|
|
19351
19366
|
continue;
|
|
19352
19367
|
}
|
|
19353
|
-
if (part.type === "text" && !projectedText &&
|
|
19368
|
+
if (part.type === "text" && !projectedText && text4.length > 0) {
|
|
19354
19369
|
const phase = piAssistantPhase(nativeMessage);
|
|
19355
19370
|
const item2 = {
|
|
19356
19371
|
type: "agentMessage",
|
|
19357
19372
|
itemId: piMessageItemId(messageIdentities.get(entry.id), "assistant") ?? itemId(entry.id, "assistant", 0),
|
|
19358
|
-
text:
|
|
19373
|
+
text: text4,
|
|
19359
19374
|
...phase ? { phase } : {}
|
|
19360
19375
|
};
|
|
19361
19376
|
snapshots.push({ item: item2, outcome: itemOutcome(outcome) });
|
|
@@ -20494,7 +20509,7 @@ async function readPiEmptySessionConfiguration(sessionFile) {
|
|
|
20494
20509
|
|
|
20495
20510
|
// dist/pi-adapter.js
|
|
20496
20511
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
20497
|
-
import
|
|
20512
|
+
import path17 from "node:path";
|
|
20498
20513
|
|
|
20499
20514
|
// dist/pi-workflow-child-history.js
|
|
20500
20515
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -20801,7 +20816,7 @@ async function rollbackPiLastTurn(transport, sourceSessionId, cwd) {
|
|
|
20801
20816
|
// dist/pi-rpc-session.js
|
|
20802
20817
|
import { spawn, spawnSync } from "node:child_process";
|
|
20803
20818
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
20804
|
-
import
|
|
20819
|
+
import path16 from "node:path";
|
|
20805
20820
|
|
|
20806
20821
|
// dist/pi-slash-commands.js
|
|
20807
20822
|
var DYNAMIC_ID_PREFIX = "pi.slash.";
|
|
@@ -20847,6 +20862,118 @@ function piDynamicCommandPrompt(catalog, commandId, argumentText) {
|
|
|
20847
20862
|
return liveHarnessCommandPrompt(catalog, DYNAMIC_ID_PREFIX, commandId, argumentText);
|
|
20848
20863
|
}
|
|
20849
20864
|
|
|
20865
|
+
// dist/pi-unc-launch.js
|
|
20866
|
+
import fs3 from "node:fs";
|
|
20867
|
+
import path15 from "node:path";
|
|
20868
|
+
function isWindowsUncDirectory(directory) {
|
|
20869
|
+
return /^\\\\(?:\?\\UNC\\)?(?![?.]\\)[^\\]+\\[^\\]+(?:\\|$)/iu.test(path15.win32.normalize(directory));
|
|
20870
|
+
}
|
|
20871
|
+
function text3(file2) {
|
|
20872
|
+
try {
|
|
20873
|
+
return fs3.readFileSync(file2, "utf8").replace(/^\uFEFF/u, "").replaceAll("\r\n", "\n").trim();
|
|
20874
|
+
} catch {
|
|
20875
|
+
return void 0;
|
|
20876
|
+
}
|
|
20877
|
+
}
|
|
20878
|
+
function isFile(file2) {
|
|
20879
|
+
try {
|
|
20880
|
+
return fs3.statSync(file2).isFile();
|
|
20881
|
+
} catch {
|
|
20882
|
+
return false;
|
|
20883
|
+
}
|
|
20884
|
+
}
|
|
20885
|
+
function nodeOnPath(environment) {
|
|
20886
|
+
for (const directory of pathDirectories(environment, "win32")) {
|
|
20887
|
+
for (const extension of executableExtensions("node", "win32", environment)) {
|
|
20888
|
+
const suffix = extension.toLowerCase();
|
|
20889
|
+
const candidate = path15.join(directory, `node${suffix}`);
|
|
20890
|
+
if (!isFile(candidate))
|
|
20891
|
+
continue;
|
|
20892
|
+
if (suffix !== ".exe" && suffix !== ".com") {
|
|
20893
|
+
throw new Error("Pi PATH Node launcher cannot safely bypass CMD in a UNC directory");
|
|
20894
|
+
}
|
|
20895
|
+
return candidate;
|
|
20896
|
+
}
|
|
20897
|
+
}
|
|
20898
|
+
return process.execPath;
|
|
20899
|
+
}
|
|
20900
|
+
function npmShim(target, pathExtFix = false) {
|
|
20901
|
+
return `@ECHO off
|
|
20902
|
+
GOTO start
|
|
20903
|
+
:find_dp0
|
|
20904
|
+
SET dp0=%~dp0
|
|
20905
|
+
EXIT /b
|
|
20906
|
+
:start
|
|
20907
|
+
SETLOCAL
|
|
20908
|
+
CALL :find_dp0
|
|
20909
|
+
|
|
20910
|
+
IF EXIST "%dp0%\\node.exe" (
|
|
20911
|
+
SET "_prog=%dp0%\\node.exe"
|
|
20912
|
+
) ELSE (
|
|
20913
|
+
SET "_prog=node"
|
|
20914
|
+
${pathExtFix ? "" : " SET PATHEXT=%PATHEXT:;.JS;=;%\n"})
|
|
20915
|
+
|
|
20916
|
+
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & ${pathExtFix ? "set PATHEXT=%PATHEXT:;.JS;=;% & " : ""}"%_prog%" "%dp0%\\${target}" %*`;
|
|
20917
|
+
}
|
|
20918
|
+
var standaloneNodeSetup = 'IF EXIST "%LOCALAPPDATA%\\pi-node\\current\\node.exe" SET "node=%LOCALAPPDATA%\\pi-node\\current\\node.exe"';
|
|
20919
|
+
function managedShim(standalone) {
|
|
20920
|
+
return `@ECHO off
|
|
20921
|
+
SETLOCAL
|
|
20922
|
+
SET "node=node"
|
|
20923
|
+
${standalone ? `${standaloneNodeSetup}
|
|
20924
|
+
` : ""}"%node%" "%~dp0pi-launcher.js" %*
|
|
20925
|
+
SET "pi_exit_code=%ERRORLEVEL%"
|
|
20926
|
+
IF "%pi_exit_code%"=="9009" (
|
|
20927
|
+
IF "%node%"=="node" (
|
|
20928
|
+
"%SystemRoot%\\System32\\where.exe" /Q node
|
|
20929
|
+
IF ERRORLEVEL 1 GOTO node_missing
|
|
20930
|
+
) ELSE IF NOT EXIST "%node%" GOTO node_missing
|
|
20931
|
+
)
|
|
20932
|
+
EXIT /B %pi_exit_code%
|
|
20933
|
+
:node_missing
|
|
20934
|
+
ECHO Pi could not find Node.js. Install Node.js 22.19.0 or newer, or rerun the installer at https://pi.dev. 1>&2
|
|
20935
|
+
EXIT /B %pi_exit_code%`;
|
|
20936
|
+
}
|
|
20937
|
+
function piUncNodeInvocation(command, arguments_, environment) {
|
|
20938
|
+
const directory = path15.dirname(command);
|
|
20939
|
+
const source = text3(command);
|
|
20940
|
+
if (path15.isAbsolute(command) && path15.win32.basename(command).toLowerCase() === "pi.cmd" && source !== void 0) {
|
|
20941
|
+
const packageDirectory = path15.join(directory, "node_modules", "@earendil-works", "pi-coding-agent");
|
|
20942
|
+
try {
|
|
20943
|
+
const manifest = JSON.parse(text3(path15.join(packageDirectory, "package.json")) ?? "");
|
|
20944
|
+
if (typeof manifest === "object" && manifest !== null && "name" in manifest && manifest.name === "@earendil-works/pi-coding-agent") {
|
|
20945
|
+
const entry = findPiCliEntry(packageDirectory);
|
|
20946
|
+
const target = entry && path15.relative(directory, entry).replaceAll("/", "\\");
|
|
20947
|
+
if (entry && target && [npmShim(target), npmShim(target, true)].includes(source)) {
|
|
20948
|
+
const localNode = path15.join(directory, "node.exe");
|
|
20949
|
+
return {
|
|
20950
|
+
command: isFile(localNode) ? localNode : nodeOnPath(environment),
|
|
20951
|
+
arguments: [entry, ...arguments_],
|
|
20952
|
+
windowsVerbatimArguments: false
|
|
20953
|
+
};
|
|
20954
|
+
}
|
|
20955
|
+
}
|
|
20956
|
+
} catch {
|
|
20957
|
+
}
|
|
20958
|
+
const launcher = path15.join(directory, "pi-launcher.js");
|
|
20959
|
+
try {
|
|
20960
|
+
const marker = JSON.parse(text3(path15.join(path15.dirname(directory), "install", "managed-install.json")) ?? "");
|
|
20961
|
+
if (typeof marker === "object" && marker !== null && "kind" in marker && marker.kind === "pi-managed-install" && "schemaVersion" in marker && marker.schemaVersion === 1 && "layout" in marker && marker.layout === "releases-v1" && "entrypoint" in marker && typeof marker.entrypoint === "object" && marker.entrypoint !== null && "type" in marker.entrypoint && marker.entrypoint.type === "script" && "path" in marker.entrypoint && typeof marker.entrypoint.path === "string" && path15.isAbsolute(marker.entrypoint.path) && path15.resolve(marker.entrypoint.path).toLowerCase() === path15.resolve(command).toLowerCase() && isFile(launcher) && (source === managedShim(false) || source === managedShim(true))) {
|
|
20962
|
+
const localAppData = environmentValue(environment, "LOCALAPPDATA");
|
|
20963
|
+
const standaloneNode = localAppData ? path15.join(localAppData, "pi-node", "current", "node.exe") : void 0;
|
|
20964
|
+
return {
|
|
20965
|
+
command: source === managedShim(true) && standaloneNode && isFile(standaloneNode) ? standaloneNode : nodeOnPath(environment),
|
|
20966
|
+
// The native launcher reads current-version and sets PI_MANAGED_INSTALL_ROOT itself.
|
|
20967
|
+
arguments: [launcher, ...arguments_],
|
|
20968
|
+
windowsVerbatimArguments: false
|
|
20969
|
+
};
|
|
20970
|
+
}
|
|
20971
|
+
} catch {
|
|
20972
|
+
}
|
|
20973
|
+
}
|
|
20974
|
+
throw new Error("Pi batch launcher cannot safely start in a UNC working directory. Use a standard npm or managed Pi installation, a native Pi executable, or a Host running inside WSL; custom Pi or PATH Node batch launchers are not bypassed.");
|
|
20975
|
+
}
|
|
20976
|
+
|
|
20850
20977
|
// dist/pi-content-stream.js
|
|
20851
20978
|
var PiContentStreamConflictError = class extends Error {
|
|
20852
20979
|
};
|
|
@@ -20874,7 +21001,7 @@ var PiContentStream = class {
|
|
|
20874
21001
|
}
|
|
20875
21002
|
finalize(blocks) {
|
|
20876
21003
|
if (this.#indexed !== true) {
|
|
20877
|
-
blocks = this.#legacyBlockIndex > 0 ? blocks.map(({ text:
|
|
21004
|
+
blocks = this.#legacyBlockIndex > 0 ? blocks.map(({ text: text4 }, index) => ({ index, text: text4 })) : [{ index: 0, text: blocks.map(({ text: text4 }) => text4).join("") }];
|
|
20878
21005
|
}
|
|
20879
21006
|
const indices = new Set(blocks.map(({ index }) => index));
|
|
20880
21007
|
for (const [index, block] of this.#blocks) {
|
|
@@ -20884,8 +21011,8 @@ var PiContentStream = class {
|
|
|
20884
21011
|
this.#conflict();
|
|
20885
21012
|
this.#blocks.delete(index);
|
|
20886
21013
|
}
|
|
20887
|
-
for (const { index, text:
|
|
20888
|
-
this.#finish(index,
|
|
21014
|
+
for (const { index, text: text4 } of blocks)
|
|
21015
|
+
this.#finish(index, text4);
|
|
20889
21016
|
return this.#flush();
|
|
20890
21017
|
}
|
|
20891
21018
|
#key(index) {
|
|
@@ -21167,15 +21294,15 @@ function extractReasoningText(content) {
|
|
|
21167
21294
|
return null;
|
|
21168
21295
|
const type = String(content.type ?? "");
|
|
21169
21296
|
if (type === "thinking" || type === "reasoning" || type === "thought") {
|
|
21170
|
-
const
|
|
21171
|
-
return typeof
|
|
21297
|
+
const text4 = content.thinking ?? content.reasoning ?? content.text ?? content.delta;
|
|
21298
|
+
return typeof text4 === "string" ? text4 : null;
|
|
21172
21299
|
}
|
|
21173
21300
|
return null;
|
|
21174
21301
|
}
|
|
21175
21302
|
function assistantReasoning(value) {
|
|
21176
21303
|
if (!isRecord9(value) || value.role !== "assistant" || !Array.isArray(value.content))
|
|
21177
21304
|
return null;
|
|
21178
|
-
return value.content.map(extractReasoningText).filter((
|
|
21305
|
+
return value.content.map(extractReasoningText).filter((text4) => typeof text4 === "string").join("");
|
|
21179
21306
|
}
|
|
21180
21307
|
function assistantFailure(value) {
|
|
21181
21308
|
if (!isRecord9(value) || value.role !== "assistant")
|
|
@@ -21242,10 +21369,17 @@ function piRpcProcessCommand(options, dependencies = {}) {
|
|
|
21242
21369
|
...thinkingArguments,
|
|
21243
21370
|
...sessionArguments
|
|
21244
21371
|
];
|
|
21245
|
-
const extension =
|
|
21372
|
+
const extension = path16.win32.extname(command).toLowerCase();
|
|
21246
21373
|
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
|
|
21247
21374
|
return { command, arguments: arguments_, windowsVerbatimArguments: false };
|
|
21248
21375
|
}
|
|
21376
|
+
if (isWindowsUncDirectory(options.cwd)) {
|
|
21377
|
+
try {
|
|
21378
|
+
return piUncNodeInvocation(command, arguments_, options.environment);
|
|
21379
|
+
} catch (error51) {
|
|
21380
|
+
throw new PiRpcFaultError("unavailable", message2(error51));
|
|
21381
|
+
}
|
|
21382
|
+
}
|
|
21249
21383
|
const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
|
|
21250
21384
|
const commandLine = [command, ...arguments_].map(quote).join(" ");
|
|
21251
21385
|
return {
|
|
@@ -21599,13 +21733,13 @@ var PiRpcSession = class {
|
|
|
21599
21733
|
throw fault;
|
|
21600
21734
|
}
|
|
21601
21735
|
}
|
|
21602
|
-
async runTurn(
|
|
21736
|
+
async runTurn(text4, onEvent) {
|
|
21603
21737
|
if (!this.#child || !this.#state || this.#closed || this.#failed) {
|
|
21604
21738
|
throw new Error("Pi RPC Session is unavailable");
|
|
21605
21739
|
}
|
|
21606
21740
|
if (this.isBusy)
|
|
21607
21741
|
throw new PiRpcBusyError();
|
|
21608
|
-
if (
|
|
21742
|
+
if (text4.length === 0)
|
|
21609
21743
|
throw new Error("Pi text Turn must not be empty");
|
|
21610
21744
|
const settled = new Promise((resolve, reject) => {
|
|
21611
21745
|
this.#activeTurn = {
|
|
@@ -21640,7 +21774,7 @@ var PiRpcSession = class {
|
|
|
21640
21774
|
});
|
|
21641
21775
|
try {
|
|
21642
21776
|
this.#drainProgress(onEvent);
|
|
21643
|
-
await this.#send("prompt", { message:
|
|
21777
|
+
await this.#send("prompt", { message: text4 });
|
|
21644
21778
|
} catch (error51) {
|
|
21645
21779
|
this.#rejectActiveTurn(error51 instanceof Error ? error51 : new Error(message2(error51)));
|
|
21646
21780
|
}
|
|
@@ -21992,16 +22126,17 @@ var PiRpcSession = class {
|
|
|
21992
22126
|
return true;
|
|
21993
22127
|
this.#extensionStatuses.set(value.statusKey, value.statusText);
|
|
21994
22128
|
}
|
|
22129
|
+
return true;
|
|
21995
22130
|
}
|
|
21996
|
-
const
|
|
21997
|
-
if (!
|
|
22131
|
+
const text4 = piStatusText(value);
|
|
22132
|
+
if (!text4)
|
|
21998
22133
|
return false;
|
|
21999
22134
|
if (value.type === "extension_ui_request" && typeof value.id === "string" && !this.#acceptNoticeFrame(JSON.stringify([value.type, value.id])))
|
|
22000
22135
|
return true;
|
|
22001
22136
|
this.#publishProgress({
|
|
22002
22137
|
type: "progress.message",
|
|
22003
22138
|
itemId: hostItemIdSchema.parse(`pi-progress-${randomUUID6()}`),
|
|
22004
|
-
text:
|
|
22139
|
+
text: text4
|
|
22005
22140
|
}, value.method === "setStatus" && typeof value.statusKey === "string" ? value.statusKey : void 0);
|
|
22006
22141
|
return true;
|
|
22007
22142
|
}
|
|
@@ -22404,8 +22539,8 @@ var PiRpcSession = class {
|
|
|
22404
22539
|
const content = value.content;
|
|
22405
22540
|
if (failure === null || !active.sawStreamedMessageReasoning) {
|
|
22406
22541
|
this.#emitContent(active, true, active.reasoningStream.finalize(content.flatMap((part, index) => {
|
|
22407
|
-
const
|
|
22408
|
-
return
|
|
22542
|
+
const text4 = extractReasoningText(part);
|
|
22543
|
+
return text4 === null ? [] : [{ index, text: text4 }];
|
|
22409
22544
|
})));
|
|
22410
22545
|
}
|
|
22411
22546
|
if (active.reasoningMessageOpen && active.failure === null) {
|
|
@@ -22672,20 +22807,20 @@ function nativeText(value) {
|
|
|
22672
22807
|
return value;
|
|
22673
22808
|
if (!isRecord10(value) || !Array.isArray(value.content))
|
|
22674
22809
|
return "";
|
|
22675
|
-
return value.content.filter((content) => isRecord10(content) && content.type === "text" && typeof content.text === "string").map(({ text:
|
|
22810
|
+
return value.content.filter((content) => isRecord10(content) && content.type === "text" && typeof content.text === "string").map(({ text: text4 }) => text4).join("");
|
|
22676
22811
|
}
|
|
22677
22812
|
function boundedOutput(value, limit) {
|
|
22678
|
-
const
|
|
22679
|
-
if (
|
|
22813
|
+
const text4 = nativeText(value);
|
|
22814
|
+
if (text4.length === 0)
|
|
22680
22815
|
return void 0;
|
|
22681
|
-
const truncated =
|
|
22816
|
+
const truncated = text4.length > limit;
|
|
22682
22817
|
return {
|
|
22683
|
-
content: [{ type: "text", text: truncated ?
|
|
22818
|
+
content: [{ type: "text", text: truncated ? text4.slice(0, limit) : text4 }],
|
|
22684
22819
|
...truncated ? { truncated: true } : {}
|
|
22685
22820
|
};
|
|
22686
22821
|
}
|
|
22687
22822
|
function outputText(output) {
|
|
22688
|
-
return output?.content.filter((content) => content.type === "text").map(({ text:
|
|
22823
|
+
return output?.content.filter((content) => content.type === "text").map(({ text: text4 }) => text4).join("") ?? "";
|
|
22689
22824
|
}
|
|
22690
22825
|
function numberField(value, key) {
|
|
22691
22826
|
if (!isRecord10(value))
|
|
@@ -22770,7 +22905,7 @@ var PiHarnessSession = class {
|
|
|
22770
22905
|
return this.#transport?.state.sessionId === id;
|
|
22771
22906
|
}
|
|
22772
22907
|
async readSubagentHistory(cwd) {
|
|
22773
|
-
if (this.#phase !== "open" ||
|
|
22908
|
+
if (this.#phase !== "open" || path17.resolve(cwd) !== path17.resolve(this.#cwd)) {
|
|
22774
22909
|
throw new Error("Pi Subagent parent workspace or Session is unavailable");
|
|
22775
22910
|
}
|
|
22776
22911
|
return (await this.#ensureTransport()).getEntries();
|
|
@@ -22783,7 +22918,7 @@ var PiHarnessSession = class {
|
|
|
22783
22918
|
return readGotgenesChild(history, transport.state.sessionId, id, this.#subagents.gotgenes.records.get(id));
|
|
22784
22919
|
}
|
|
22785
22920
|
async inspectSubagent(id, cwd) {
|
|
22786
|
-
if (this.#phase !== "open" ||
|
|
22921
|
+
if (this.#phase !== "open" || path17.resolve(cwd) !== path17.resolve(this.#cwd)) {
|
|
22787
22922
|
throw new Error("Pi Subagent parent workspace or Session is unavailable");
|
|
22788
22923
|
}
|
|
22789
22924
|
const transport = await this.#ensureTransport();
|
|
@@ -22861,8 +22996,8 @@ var PiHarnessSession = class {
|
|
|
22861
22996
|
}
|
|
22862
22997
|
};
|
|
22863
22998
|
}
|
|
22864
|
-
const
|
|
22865
|
-
if (
|
|
22999
|
+
const text4 = command.input.map((input) => input.text).join("\n");
|
|
23000
|
+
if (text4.length === 0) {
|
|
22866
23001
|
return {
|
|
22867
23002
|
ok: false,
|
|
22868
23003
|
error: {
|
|
@@ -22924,7 +23059,7 @@ var PiHarnessSession = class {
|
|
|
22924
23059
|
this.#active = active;
|
|
22925
23060
|
this.#event({ type: "turn.started", turnId: command.turnId });
|
|
22926
23061
|
this.#event({ type: "item.started", turnId: command.turnId, item });
|
|
22927
|
-
void transport.runTurn(
|
|
23062
|
+
void transport.runTurn(text4, (event) => this.#handleTurnEvent(active, event)).then(async (result) => {
|
|
22928
23063
|
active.settling = true;
|
|
22929
23064
|
try {
|
|
22930
23065
|
const identity = await this.#completedTurnIdentity(active, transport);
|
|
@@ -23823,16 +23958,16 @@ var PiHarnessSession = class {
|
|
|
23823
23958
|
}
|
|
23824
23959
|
active.agentMessageId = messageId;
|
|
23825
23960
|
}
|
|
23826
|
-
#appendText(active,
|
|
23961
|
+
#appendText(active, text4) {
|
|
23827
23962
|
if (active.agentMessageId === null || !active.agentItem) {
|
|
23828
23963
|
throw new Error("Pi Assistant text arrived outside an active message");
|
|
23829
23964
|
}
|
|
23830
|
-
active.agentItem = { ...active.agentItem, text: active.agentItem.text +
|
|
23965
|
+
active.agentItem = { ...active.agentItem, text: active.agentItem.text + text4 };
|
|
23831
23966
|
this.#event({
|
|
23832
23967
|
type: "item.updated",
|
|
23833
23968
|
turnId: active.command.turnId,
|
|
23834
23969
|
itemId: active.agentItem.itemId,
|
|
23835
|
-
update: { type: "text.append", text:
|
|
23970
|
+
update: { type: "text.append", text: text4 }
|
|
23836
23971
|
});
|
|
23837
23972
|
}
|
|
23838
23973
|
#completeAgentItem(active, outcome, completeEmpty) {
|
|
@@ -23843,8 +23978,8 @@ var PiHarnessSession = class {
|
|
|
23843
23978
|
active.agentItem = null;
|
|
23844
23979
|
this.#completeItem(active, item, outcome);
|
|
23845
23980
|
}
|
|
23846
|
-
#appendReasoning(active,
|
|
23847
|
-
if (
|
|
23981
|
+
#appendReasoning(active, text4, nativeMessageIdentity2) {
|
|
23982
|
+
if (text4.length === 0)
|
|
23848
23983
|
return;
|
|
23849
23984
|
if (!active.reasoningItem) {
|
|
23850
23985
|
active.reasoningItem = {
|
|
@@ -23860,13 +23995,13 @@ var PiHarnessSession = class {
|
|
|
23860
23995
|
}
|
|
23861
23996
|
active.reasoningItem = {
|
|
23862
23997
|
...active.reasoningItem,
|
|
23863
|
-
text: active.reasoningItem.text +
|
|
23998
|
+
text: active.reasoningItem.text + text4
|
|
23864
23999
|
};
|
|
23865
24000
|
this.#event({
|
|
23866
24001
|
type: "item.updated",
|
|
23867
24002
|
turnId: active.command.turnId,
|
|
23868
24003
|
itemId: active.reasoningItem.itemId,
|
|
23869
|
-
update: { type: "text.append", text:
|
|
24004
|
+
update: { type: "text.append", text: text4 }
|
|
23870
24005
|
});
|
|
23871
24006
|
}
|
|
23872
24007
|
#completeReasoning(active, outcome) {
|