@codexhost/cli-win32-arm64 0.13.0 → 0.13.1
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/THIRD_PARTY_NOTICES.txt +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +88 -44
- package/app/console-web.js +3681 -3948
- package/app/desktop-controller.mjs +8 -1
- package/app/host-runtime.mjs +457 -156
- package/app/plugins/antigravity/plugin.mjs +8 -1
- package/app/plugins/claude-code/plugin.mjs +34469 -23777
- package/app/plugins/codebuddy/plugin.mjs +47 -4
- package/app/plugins/codex-usage/plugin.mjs +639 -18
- package/app/plugins/cursor-cli/plugin.mjs +8 -1
- package/app/plugins/deepseek-harness/plugin.mjs +28 -3
- package/app/plugins/grok/plugin.mjs +43 -8
- package/app/plugins/hermes/plugin.mjs +8 -1
- package/app/plugins/kimi-code/plugin.mjs +8 -1
- package/app/plugins/kiro-cli/plugin.mjs +8 -1
- package/app/plugins/omp/plugin.mjs +31 -7
- package/app/plugins/opencode/plugin.mjs +34 -4
- package/app/plugins/pi/plugin.mjs +84 -43
- package/app/plugins/qoder/plugin.mjs +54 -4
- package/app/plugins/qoder-cn/plugin.mjs +54 -4
- package/app/plugins/workbuddy/plugin.mjs +47 -4
- package/app/plugins/zcode/plugin.mjs +37 -4
- package/app/renderer-extension.js +11568 -7287
- 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
|
@@ -415,6 +415,20 @@ import path4 from "node:path";
|
|
|
415
415
|
import { createInterface } from "node:readline";
|
|
416
416
|
var MAX_SESSION_ID_LENGTH = 512;
|
|
417
417
|
var MAX_CWD_LENGTH = 4096;
|
|
418
|
+
var MAX_SESSION_TITLE_LENGTH = 200;
|
|
419
|
+
function usageSessionTitle(value) {
|
|
420
|
+
if (typeof value !== "string")
|
|
421
|
+
return void 0;
|
|
422
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
423
|
+
if (!normalized)
|
|
424
|
+
return void 0;
|
|
425
|
+
if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
|
|
426
|
+
return normalized;
|
|
427
|
+
const characters = [...normalized];
|
|
428
|
+
if (characters.length <= MAX_SESSION_TITLE_LENGTH)
|
|
429
|
+
return normalized;
|
|
430
|
+
return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
|
|
431
|
+
}
|
|
418
432
|
function sessionIdOk(value) {
|
|
419
433
|
return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
|
|
420
434
|
}
|
|
@@ -424,12 +438,14 @@ function cwdOk(value) {
|
|
|
424
438
|
function withUsageSession(entry, session) {
|
|
425
439
|
const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
|
|
426
440
|
const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
|
|
441
|
+
const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
|
|
427
442
|
if (sessionId === void 0 && cwd === void 0)
|
|
428
443
|
return entry;
|
|
429
444
|
return {
|
|
430
445
|
...entry,
|
|
431
446
|
...sessionId !== void 0 ? { sessionId } : {},
|
|
432
|
-
...cwd !== void 0 ? { cwd } : {}
|
|
447
|
+
...cwd !== void 0 ? { cwd } : {},
|
|
448
|
+
...sessionTitle !== void 0 ? { sessionTitle } : {}
|
|
433
449
|
};
|
|
434
450
|
}
|
|
435
451
|
function usageEntryFromRequest(request, occurredAtMs) {
|
|
@@ -15203,6 +15219,8 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
|
|
|
15203
15219
|
harness,
|
|
15204
15220
|
sessionId: external_exports.string().min(1).max(512),
|
|
15205
15221
|
project: project.nullable(),
|
|
15222
|
+
/** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
|
|
15223
|
+
title: external_exports.string().min(1).max(200).optional(),
|
|
15206
15224
|
/** Models the session used, most requests first. */
|
|
15207
15225
|
models: external_exports.array(model).max(16),
|
|
15208
15226
|
firstAtMs: count,
|
|
@@ -15269,7 +15287,12 @@ var usageStatisticsResultSchema = external_exports.strictObject({
|
|
|
15269
15287
|
* The sessions that spent the most, by cost and by tokens without cache, all filters applied;
|
|
15270
15288
|
* requests without a native session are not listed here but count everywhere else.
|
|
15271
15289
|
*/
|
|
15272
|
-
sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
|
|
15290
|
+
sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
|
|
15291
|
+
/**
|
|
15292
|
+
* The sessions last active in the range, newest first, all filters applied. Optional for older
|
|
15293
|
+
* Hosts; missing is treated as no list rather than no sessions.
|
|
15294
|
+
*/
|
|
15295
|
+
recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
|
|
15273
15296
|
});
|
|
15274
15297
|
|
|
15275
15298
|
// ../../shared-contracts/dist/ids.js
|
|
@@ -17989,20 +18012,38 @@ function piUsageHistory(history) {
|
|
|
17989
18012
|
}
|
|
17990
18013
|
|
|
17991
18014
|
// dist/pi-usage-statistics.js
|
|
18015
|
+
function isRecord5(value) {
|
|
18016
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18017
|
+
}
|
|
18018
|
+
function piUserText(content) {
|
|
18019
|
+
if (typeof content === "string")
|
|
18020
|
+
return content;
|
|
18021
|
+
if (!Array.isArray(content))
|
|
18022
|
+
return void 0;
|
|
18023
|
+
return content.filter((block) => isRecord5(block) && block.type === "text" && typeof block.text === "string").map((block) => String(block.text)).join(" ");
|
|
18024
|
+
}
|
|
17992
18025
|
async function readPiUsage(file2, signal) {
|
|
17993
18026
|
const entries = [];
|
|
17994
18027
|
const header = await jsonlHeader(file2, (record7) => record7.type === "session", signal);
|
|
18028
|
+
let name;
|
|
17995
18029
|
const session = {
|
|
17996
18030
|
sessionId: typeof header?.id === "string" ? header.id : void 0,
|
|
17997
18031
|
cwd: typeof header?.cwd === "string" ? header.cwd : void 0
|
|
17998
18032
|
};
|
|
17999
|
-
for await (const line of jsonlRecords(file2, '"
|
|
18033
|
+
for await (const line of jsonlRecords(file2, '"type"', signal)) {
|
|
18034
|
+
if (line.type === "session_info") {
|
|
18035
|
+
name = usageSessionTitle(line.name) ?? name;
|
|
18036
|
+
continue;
|
|
18037
|
+
}
|
|
18000
18038
|
if (line.type !== "message")
|
|
18001
18039
|
continue;
|
|
18040
|
+
const message3 = line.message;
|
|
18041
|
+
if (!name && message3?.role === "user") {
|
|
18042
|
+
name = usageSessionTitle(piUserText(message3.content));
|
|
18043
|
+
}
|
|
18002
18044
|
const record7 = piUsageRecord(line.message);
|
|
18003
18045
|
if (record7?.kind !== "request")
|
|
18004
18046
|
continue;
|
|
18005
|
-
const message3 = line.message;
|
|
18006
18047
|
const at = nativeTimeMs(message3.timestamp) ?? nativeTimeMs(line.timestamp);
|
|
18007
18048
|
const entry = at !== null && usageEntryFromRequest(record7.request, at);
|
|
18008
18049
|
if (!entry)
|
|
@@ -18014,7 +18055,7 @@ async function readPiUsage(file2, signal) {
|
|
|
18014
18055
|
}
|
|
18015
18056
|
entries.push(withUsageSession(entry, session));
|
|
18016
18057
|
}
|
|
18017
|
-
return entries;
|
|
18058
|
+
return name ? entries.map((entry) => withUsageSession(entry, { ...session, title: name })) : entries;
|
|
18018
18059
|
}
|
|
18019
18060
|
function createPiUsageStatistics(environment) {
|
|
18020
18061
|
return Object.freeze({
|
|
@@ -18645,7 +18686,7 @@ import path10 from "node:path";
|
|
|
18645
18686
|
import { open, realpath as realpath3 } from "node:fs/promises";
|
|
18646
18687
|
var MAX_SESSION_HEADER_BYTES = 64 * 1024;
|
|
18647
18688
|
var utf8Decoder = new TextDecoder("utf-8", { fatal: true });
|
|
18648
|
-
function
|
|
18689
|
+
function isRecord6(value) {
|
|
18649
18690
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18650
18691
|
}
|
|
18651
18692
|
async function readPiSessionHeader(sessionFile) {
|
|
@@ -18665,7 +18706,7 @@ async function readPiSessionHeader(sessionFile) {
|
|
|
18665
18706
|
} catch {
|
|
18666
18707
|
throw new Error("Pi Session header is not valid JSON");
|
|
18667
18708
|
}
|
|
18668
|
-
if (!
|
|
18709
|
+
if (!isRecord6(parsed) || parsed.type !== "session" || typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
|
|
18669
18710
|
throw new Error("Pi Session header is invalid");
|
|
18670
18711
|
}
|
|
18671
18712
|
return {
|
|
@@ -19714,7 +19755,7 @@ var PiRpcUnsupportedCommandError = class extends Error {
|
|
|
19714
19755
|
}
|
|
19715
19756
|
};
|
|
19716
19757
|
var textDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
19717
|
-
function
|
|
19758
|
+
function isRecord7(value) {
|
|
19718
19759
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19719
19760
|
}
|
|
19720
19761
|
function message2(value) {
|
|
@@ -19726,13 +19767,13 @@ function nonBlankString(value) {
|
|
|
19726
19767
|
function parseNativeModel(value, context) {
|
|
19727
19768
|
if (value === null || value === void 0)
|
|
19728
19769
|
return null;
|
|
19729
|
-
if (!
|
|
19770
|
+
if (!isRecord7(value) || !nonBlankString(value.provider) || !nonBlankString(value.id)) {
|
|
19730
19771
|
throw new PiRpcFaultError("protocolError", `Pi RPC returned an invalid ${context} Model`);
|
|
19731
19772
|
}
|
|
19732
19773
|
return { provider: value.provider, id: value.id };
|
|
19733
19774
|
}
|
|
19734
19775
|
function sessionStateData(response) {
|
|
19735
|
-
const data =
|
|
19776
|
+
const data = isRecord7(response.data) ? response.data : null;
|
|
19736
19777
|
if (!data)
|
|
19737
19778
|
throw new PiRpcFaultError("protocolError", "Pi RPC state response has no data");
|
|
19738
19779
|
return data;
|
|
@@ -19764,13 +19805,13 @@ function parseSessionStreaming(response) {
|
|
|
19764
19805
|
return isStreaming;
|
|
19765
19806
|
}
|
|
19766
19807
|
function parseSessionHistory(response) {
|
|
19767
|
-
const data =
|
|
19808
|
+
const data = isRecord7(response.data) ? response.data : null;
|
|
19768
19809
|
if (!data || !Array.isArray(data.entries)) {
|
|
19769
19810
|
throw new PiRpcFaultError("protocolError", "Pi RPC entries response has no Entries");
|
|
19770
19811
|
}
|
|
19771
19812
|
const entries = data.entries.map((entry) => {
|
|
19772
19813
|
const parsed = jsonValueSchema.safeParse(entry);
|
|
19773
|
-
if (!parsed.success || !
|
|
19814
|
+
if (!parsed.success || !isRecord7(parsed.data)) {
|
|
19774
19815
|
throw new PiRpcFaultError("protocolError", "Pi RPC entries response contains an invalid Entry");
|
|
19775
19816
|
}
|
|
19776
19817
|
return parsed.data;
|
|
@@ -19781,7 +19822,7 @@ function parseSessionHistory(response) {
|
|
|
19781
19822
|
return { entries, leafId: data.leafId };
|
|
19782
19823
|
}
|
|
19783
19824
|
function parseAvailableThinkingLevels(response) {
|
|
19784
|
-
const data =
|
|
19825
|
+
const data = isRecord7(response.data) ? response.data : null;
|
|
19785
19826
|
if (!data || !Array.isArray(data.levels) || data.levels.length === 0) {
|
|
19786
19827
|
throw new PiRpcFaultError("protocolError", "Pi RPC Thinking catalog response has no levels");
|
|
19787
19828
|
}
|
|
@@ -19798,13 +19839,13 @@ function parseAvailableThinkingLevels(response) {
|
|
|
19798
19839
|
return levels;
|
|
19799
19840
|
}
|
|
19800
19841
|
function parseAvailableModels(response) {
|
|
19801
|
-
const data =
|
|
19842
|
+
const data = isRecord7(response.data) ? response.data : null;
|
|
19802
19843
|
if (!data || !Array.isArray(data.models)) {
|
|
19803
19844
|
throw new PiRpcFaultError("protocolError", "Pi RPC Model catalog response has no models");
|
|
19804
19845
|
}
|
|
19805
19846
|
return data.models.map((model2) => {
|
|
19806
19847
|
const parsed = parseNativeModel(model2, "catalog");
|
|
19807
|
-
if (!parsed || !
|
|
19848
|
+
if (!parsed || !isRecord7(model2) || typeof model2.reasoning !== "boolean") {
|
|
19808
19849
|
throw new PiRpcFaultError("protocolError", "Pi RPC catalog contains a Model without reasoning capability");
|
|
19809
19850
|
}
|
|
19810
19851
|
return {
|
|
@@ -19815,17 +19856,17 @@ function parseAvailableModels(response) {
|
|
|
19815
19856
|
});
|
|
19816
19857
|
}
|
|
19817
19858
|
function assistantText(value) {
|
|
19818
|
-
if (!
|
|
19859
|
+
if (!isRecord7(value) || value.role !== "assistant" || !Array.isArray(value.content))
|
|
19819
19860
|
return null;
|
|
19820
|
-
return value.content.filter((content) =>
|
|
19861
|
+
return value.content.filter((content) => isRecord7(content) && content.type === "text" && typeof content.text === "string").map((content) => content.text).join("");
|
|
19821
19862
|
}
|
|
19822
19863
|
function assistantMessageId(value) {
|
|
19823
|
-
if (!
|
|
19864
|
+
if (!isRecord7(value) || value.role !== "assistant")
|
|
19824
19865
|
return null;
|
|
19825
19866
|
return nonBlankString(value.responseId) ? value.responseId : null;
|
|
19826
19867
|
}
|
|
19827
19868
|
function extractReasoningText(content) {
|
|
19828
|
-
if (!
|
|
19869
|
+
if (!isRecord7(content))
|
|
19829
19870
|
return null;
|
|
19830
19871
|
const type = String(content.type ?? "");
|
|
19831
19872
|
if (type === "thinking" || type === "reasoning" || type === "thought") {
|
|
@@ -19835,12 +19876,12 @@ function extractReasoningText(content) {
|
|
|
19835
19876
|
return null;
|
|
19836
19877
|
}
|
|
19837
19878
|
function assistantReasoning(value) {
|
|
19838
|
-
if (!
|
|
19879
|
+
if (!isRecord7(value) || value.role !== "assistant" || !Array.isArray(value.content))
|
|
19839
19880
|
return null;
|
|
19840
19881
|
return value.content.map(extractReasoningText).filter((text2) => typeof text2 === "string").join("");
|
|
19841
19882
|
}
|
|
19842
19883
|
function assistantFailure(value) {
|
|
19843
|
-
if (!
|
|
19884
|
+
if (!isRecord7(value) || value.role !== "assistant")
|
|
19844
19885
|
return void 0;
|
|
19845
19886
|
if (value.stopReason !== "error" && value.stopReason !== "aborted")
|
|
19846
19887
|
return null;
|
|
@@ -19860,7 +19901,7 @@ function signalProcessTree(child, signal) {
|
|
|
19860
19901
|
try {
|
|
19861
19902
|
process.kill(-child.pid, signal);
|
|
19862
19903
|
} catch (error51) {
|
|
19863
|
-
if (!
|
|
19904
|
+
if (!isRecord7(error51) || error51.code !== "ESRCH")
|
|
19864
19905
|
throw error51;
|
|
19865
19906
|
}
|
|
19866
19907
|
}
|
|
@@ -19996,12 +20037,12 @@ var PiRpcSession = class {
|
|
|
19996
20037
|
}
|
|
19997
20038
|
if (value.type === "message_update") {
|
|
19998
20039
|
const event = value.assistantMessageEvent;
|
|
19999
|
-
if (this.#usageRequestStartedAtMs === null &&
|
|
20040
|
+
if (this.#usageRequestStartedAtMs === null && isRecord7(event) && typeof event.type === "string" && /^(text|thinking|reasoning|thought|toolcall)_(start|delta)$/u.test(event.type)) {
|
|
20000
20041
|
this.#usageRequestStartedAtMs = Date.now();
|
|
20001
20042
|
}
|
|
20002
20043
|
return;
|
|
20003
20044
|
}
|
|
20004
|
-
if (value.type === "message_end" &&
|
|
20045
|
+
if (value.type === "message_end" && isRecord7(value.message)) {
|
|
20005
20046
|
if (value.message.role !== "assistant")
|
|
20006
20047
|
return;
|
|
20007
20048
|
const startedAtMs = this.#usageRequestStartedAtMs;
|
|
@@ -20046,7 +20087,7 @@ var PiRpcSession = class {
|
|
|
20046
20087
|
this.#stderrTail = sanitizeDiagnosticTail(`${this.#stderrTail}${chunk.toString()}`);
|
|
20047
20088
|
});
|
|
20048
20089
|
child.once("error", (error51) => {
|
|
20049
|
-
const kind =
|
|
20090
|
+
const kind = isRecord7(error51) && error51.code === "ENOENT" ? "notInstalled" : "unavailable";
|
|
20050
20091
|
this.#fail(new PiRpcFaultError(kind, `Pi RPC failed to start: ${error51.message}`, this.stderrTail));
|
|
20051
20092
|
});
|
|
20052
20093
|
child.once("exit", (code, signal) => {
|
|
@@ -20355,7 +20396,7 @@ var PiRpcSession = class {
|
|
|
20355
20396
|
this.#buffer = this.#buffer.subarray(newline + 1);
|
|
20356
20397
|
try {
|
|
20357
20398
|
const value = JSON.parse(textDecoder.decode(frame));
|
|
20358
|
-
if (!
|
|
20399
|
+
if (!isRecord7(value) || typeof value.type !== "string") {
|
|
20359
20400
|
throw new PiRpcFaultError("protocolError", "Pi RPC returned an invalid envelope");
|
|
20360
20401
|
}
|
|
20361
20402
|
this.#handle(value);
|
|
@@ -20402,7 +20443,7 @@ var PiRpcSession = class {
|
|
|
20402
20443
|
this.#armCommandTimeout(id, pending);
|
|
20403
20444
|
}
|
|
20404
20445
|
}
|
|
20405
|
-
const outcome = value.aborted === true ? "cancelled" :
|
|
20446
|
+
const outcome = value.aborted === true ? "cancelled" : isRecord7(value.result) ? "succeeded" : "failed";
|
|
20406
20447
|
const event = {
|
|
20407
20448
|
type: "compaction.completed",
|
|
20408
20449
|
outcome,
|
|
@@ -20440,12 +20481,12 @@ var PiRpcSession = class {
|
|
|
20440
20481
|
this.#startAssistantMessage(active, value.message);
|
|
20441
20482
|
return;
|
|
20442
20483
|
}
|
|
20443
|
-
if (value.type === "message_update" &&
|
|
20484
|
+
if (value.type === "message_update" && isRecord7(value.assistantMessageEvent)) {
|
|
20444
20485
|
const event = value.assistantMessageEvent;
|
|
20445
20486
|
const eventType = String(event.type ?? "");
|
|
20446
20487
|
const isThinking = eventType === "thinking_delta" || eventType === "reasoning_delta" || eventType === "thought_delta" || eventType === "thinking" || eventType === "reasoning";
|
|
20447
20488
|
const isText = eventType === "text_delta" || eventType === "text" || eventType === "content_block_delta";
|
|
20448
|
-
const delta = typeof event.delta === "string" ? event.delta : typeof event.thinking === "string" ? event.thinking : typeof event.reasoning === "string" ? event.reasoning : typeof event.text === "string" ? event.text :
|
|
20489
|
+
const delta = typeof event.delta === "string" ? event.delta : typeof event.thinking === "string" ? event.thinking : typeof event.reasoning === "string" ? event.reasoning : typeof event.text === "string" ? event.text : isRecord7(event.delta) && typeof event.delta.thinking === "string" ? event.delta.thinking : isRecord7(event.delta) && typeof event.delta.text === "string" ? event.delta.text : null;
|
|
20449
20490
|
if (isThinking && delta !== null && delta.length > 0) {
|
|
20450
20491
|
const messageId = this.#ensureAssistantMessage(active, value.message);
|
|
20451
20492
|
active.reasoningMessageOpen = true;
|
|
@@ -20758,7 +20799,7 @@ var PiRpcSession = class {
|
|
|
20758
20799
|
return;
|
|
20759
20800
|
}
|
|
20760
20801
|
active.failure = failure;
|
|
20761
|
-
if (active.origin === "autonomous" &&
|
|
20802
|
+
if (active.origin === "autonomous" && isRecord7(value) && value.stopReason === "aborted") {
|
|
20762
20803
|
active.nativeCancellationObserved = true;
|
|
20763
20804
|
}
|
|
20764
20805
|
this.#latestCacheHitRatePercent = cacheHitRatePercent;
|
|
@@ -20919,7 +20960,7 @@ var piCommandCatalog = harnessCommandCatalogSchema.parse({
|
|
|
20919
20960
|
]
|
|
20920
20961
|
});
|
|
20921
20962
|
var DEFAULT_TOOL_OUTPUT_LIMIT = 64e3;
|
|
20922
|
-
function
|
|
20963
|
+
function isRecord8(value) {
|
|
20923
20964
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20924
20965
|
}
|
|
20925
20966
|
function errorMessage(error51) {
|
|
@@ -20934,7 +20975,7 @@ var PiAdapterFaultError = class extends Error {
|
|
|
20934
20975
|
}
|
|
20935
20976
|
};
|
|
20936
20977
|
function normalizedError(error51, fallbackCode) {
|
|
20937
|
-
if (
|
|
20978
|
+
if (isRecord8(error51) && error51.code === "ENOENT") {
|
|
20938
20979
|
return { code: "notInstalled", message: errorMessage(error51), retryable: false };
|
|
20939
20980
|
}
|
|
20940
20981
|
if (error51 instanceof PiAdapterFaultError)
|
|
@@ -20997,7 +21038,7 @@ function nativeModelForHistory(state2) {
|
|
|
20997
21038
|
return nativeModelFromState(state2);
|
|
20998
21039
|
}
|
|
20999
21040
|
function sessionFileFromRef(ref) {
|
|
21000
|
-
if (ref.harnessId !== piHarnessId2 || !
|
|
21041
|
+
if (ref.harnessId !== piHarnessId2 || !isRecord8(ref.locator) || typeof ref.locator.sessionFile !== "string" || ref.locator.sessionFile.length === 0) {
|
|
21001
21042
|
throw new Error("Pi Native Session Ref has no resumable Session file");
|
|
21002
21043
|
}
|
|
21003
21044
|
return ref.locator.sessionFile;
|
|
@@ -21012,9 +21053,9 @@ function toolFailure(toolName) {
|
|
|
21012
21053
|
function nativeText(value) {
|
|
21013
21054
|
if (typeof value === "string")
|
|
21014
21055
|
return value;
|
|
21015
|
-
if (!
|
|
21056
|
+
if (!isRecord8(value) || !Array.isArray(value.content))
|
|
21016
21057
|
return "";
|
|
21017
|
-
return value.content.filter((content) =>
|
|
21058
|
+
return value.content.filter((content) => isRecord8(content) && content.type === "text" && typeof content.text === "string").map(({ text: text2 }) => text2).join("");
|
|
21018
21059
|
}
|
|
21019
21060
|
function boundedOutput(value, limit) {
|
|
21020
21061
|
const text2 = nativeText(value);
|
|
@@ -21030,17 +21071,17 @@ function outputText(output) {
|
|
|
21030
21071
|
return output?.content.filter((content) => content.type === "text").map(({ text: text2 }) => text2).join("") ?? "";
|
|
21031
21072
|
}
|
|
21032
21073
|
function stringField(value, key) {
|
|
21033
|
-
if (!
|
|
21074
|
+
if (!isRecord8(value))
|
|
21034
21075
|
return void 0;
|
|
21035
21076
|
const field = value[key];
|
|
21036
21077
|
if (typeof field === "string" && field.length > 0)
|
|
21037
21078
|
return field;
|
|
21038
|
-
if (
|
|
21079
|
+
if (isRecord8(value.input)) {
|
|
21039
21080
|
const nested = value.input[key];
|
|
21040
21081
|
if (typeof nested === "string" && nested.length > 0)
|
|
21041
21082
|
return nested;
|
|
21042
21083
|
}
|
|
21043
|
-
if (
|
|
21084
|
+
if (isRecord8(value.arguments)) {
|
|
21044
21085
|
const nested = value.arguments[key];
|
|
21045
21086
|
if (typeof nested === "string" && nested.length > 0)
|
|
21046
21087
|
return nested;
|
|
@@ -21048,7 +21089,7 @@ function stringField(value, key) {
|
|
|
21048
21089
|
return void 0;
|
|
21049
21090
|
}
|
|
21050
21091
|
function numberField(value, key) {
|
|
21051
|
-
if (!
|
|
21092
|
+
if (!isRecord8(value))
|
|
21052
21093
|
return void 0;
|
|
21053
21094
|
const field = value[key];
|
|
21054
21095
|
return typeof field === "number" || field === null ? field : void 0;
|
|
@@ -21123,7 +21164,7 @@ function fileMutatingKind(toolName) {
|
|
|
21123
21164
|
return null;
|
|
21124
21165
|
}
|
|
21125
21166
|
function nestedToolString(value, keys) {
|
|
21126
|
-
if (!
|
|
21167
|
+
if (!isRecord8(value))
|
|
21127
21168
|
return void 0;
|
|
21128
21169
|
for (const key of keys) {
|
|
21129
21170
|
const field = value[key];
|
|
@@ -21138,14 +21179,14 @@ function nestedToolString(value, keys) {
|
|
|
21138
21179
|
return void 0;
|
|
21139
21180
|
}
|
|
21140
21181
|
function patchFromResult(result) {
|
|
21141
|
-
if (!
|
|
21182
|
+
if (!isRecord8(result))
|
|
21142
21183
|
return void 0;
|
|
21143
21184
|
for (const key of ["patch", "diff", "unifiedDiff"]) {
|
|
21144
21185
|
const field = result[key];
|
|
21145
21186
|
if (typeof field === "string" && field.length > 0)
|
|
21146
21187
|
return field;
|
|
21147
21188
|
}
|
|
21148
|
-
if (
|
|
21189
|
+
if (isRecord8(result.details)) {
|
|
21149
21190
|
for (const key of ["patch", "diff", "unifiedDiff"]) {
|
|
21150
21191
|
const field = result.details[key];
|
|
21151
21192
|
if (typeof field === "string" && field.length > 0)
|
|
@@ -22160,7 +22201,7 @@ var PiHarnessSession = class {
|
|
|
22160
22201
|
type: "question",
|
|
22161
22202
|
interactionId,
|
|
22162
22203
|
turnId: active.command.turnId,
|
|
22163
|
-
...associatedTool ? { itemId: associatedTool.item.itemId } : {},
|
|
22204
|
+
...associatedTool?.item.type === "toolExecution" ? { itemId: associatedTool.item.itemId } : {},
|
|
22164
22205
|
title: "Pi",
|
|
22165
22206
|
questions: [question],
|
|
22166
22207
|
...request.timeoutMs !== void 0 ? { expiresAt: new Date(Date.now() + request.timeoutMs).toISOString() } : {}
|
|
@@ -27668,6 +27668,8 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
|
|
|
27668
27668
|
harness,
|
|
27669
27669
|
sessionId: external_exports.string().min(1).max(512),
|
|
27670
27670
|
project: project.nullable(),
|
|
27671
|
+
/** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
|
|
27672
|
+
title: external_exports.string().min(1).max(200).optional(),
|
|
27671
27673
|
/** Models the session used, most requests first. */
|
|
27672
27674
|
models: external_exports.array(model).max(16),
|
|
27673
27675
|
firstAtMs: count,
|
|
@@ -27734,7 +27736,12 @@ var usageStatisticsResultSchema = external_exports.strictObject({
|
|
|
27734
27736
|
* The sessions that spent the most, by cost and by tokens without cache, all filters applied;
|
|
27735
27737
|
* requests without a native session are not listed here but count everywhere else.
|
|
27736
27738
|
*/
|
|
27737
|
-
sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
|
|
27739
|
+
sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
|
|
27740
|
+
/**
|
|
27741
|
+
* The sessions last active in the range, newest first, all filters applied. Optional for older
|
|
27742
|
+
* Hosts; missing is treated as no list rather than no sessions.
|
|
27743
|
+
*/
|
|
27744
|
+
recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
|
|
27738
27745
|
});
|
|
27739
27746
|
|
|
27740
27747
|
// ../../shared-contracts/dist/ids.js
|
|
@@ -52921,6 +52928,20 @@ import path6 from "node:path";
|
|
|
52921
52928
|
import { createInterface } from "node:readline";
|
|
52922
52929
|
var MAX_SESSION_ID_LENGTH = 512;
|
|
52923
52930
|
var MAX_CWD_LENGTH = 4096;
|
|
52931
|
+
var MAX_SESSION_TITLE_LENGTH = 200;
|
|
52932
|
+
function usageSessionTitle(value) {
|
|
52933
|
+
if (typeof value !== "string")
|
|
52934
|
+
return void 0;
|
|
52935
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
52936
|
+
if (!normalized)
|
|
52937
|
+
return void 0;
|
|
52938
|
+
if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
|
|
52939
|
+
return normalized;
|
|
52940
|
+
const characters = [...normalized];
|
|
52941
|
+
if (characters.length <= MAX_SESSION_TITLE_LENGTH)
|
|
52942
|
+
return normalized;
|
|
52943
|
+
return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
|
|
52944
|
+
}
|
|
52924
52945
|
function sessionIdOk(value) {
|
|
52925
52946
|
return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
|
|
52926
52947
|
}
|
|
@@ -52930,12 +52951,14 @@ function cwdOk(value) {
|
|
|
52930
52951
|
function withUsageSession(entry, session) {
|
|
52931
52952
|
const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
|
|
52932
52953
|
const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
|
|
52954
|
+
const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
|
|
52933
52955
|
if (sessionId === void 0 && cwd === void 0)
|
|
52934
52956
|
return entry;
|
|
52935
52957
|
return {
|
|
52936
52958
|
...entry,
|
|
52937
52959
|
...sessionId !== void 0 ? { sessionId } : {},
|
|
52938
|
-
...cwd !== void 0 ? { cwd } : {}
|
|
52960
|
+
...cwd !== void 0 ? { cwd } : {},
|
|
52961
|
+
...sessionTitle !== void 0 ? { sessionTitle } : {}
|
|
52939
52962
|
};
|
|
52940
52963
|
}
|
|
52941
52964
|
function tokenCount(value) {
|
|
@@ -52975,6 +52998,12 @@ function parseHarnessUsageEntry(value) {
|
|
|
52975
52998
|
return null;
|
|
52976
52999
|
if (entry.cwd !== void 0 && !cwdOk(entry.cwd))
|
|
52977
53000
|
return null;
|
|
53001
|
+
if (entry.sessionTitle !== void 0) {
|
|
53002
|
+
const sessionTitle = usageSessionTitle(entry.sessionTitle);
|
|
53003
|
+
if (sessionTitle === void 0)
|
|
53004
|
+
return null;
|
|
53005
|
+
entry.sessionTitle = sessionTitle;
|
|
53006
|
+
}
|
|
52978
53007
|
if (entry.tokensUnknown !== void 0 && entry.tokensUnknown !== true)
|
|
52979
53008
|
return null;
|
|
52980
53009
|
if (entry.costUsd !== void 0 && (typeof entry.costUsd !== "number" || !Number.isFinite(entry.costUsd) || entry.costUsd < 0)) {
|
|
@@ -53086,6 +53115,16 @@ function qoderProjectsDirectory(environment, variant) {
|
|
|
53086
53115
|
function isRecord2(value) {
|
|
53087
53116
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
53088
53117
|
}
|
|
53118
|
+
function qoderUserText(message) {
|
|
53119
|
+
if (!isRecord2(message))
|
|
53120
|
+
return void 0;
|
|
53121
|
+
const { content } = message;
|
|
53122
|
+
if (typeof content === "string")
|
|
53123
|
+
return content;
|
|
53124
|
+
if (!Array.isArray(content))
|
|
53125
|
+
return void 0;
|
|
53126
|
+
return content.filter((block) => isRecord2(block) && block.type === "text" && typeof block.text === "string").map((block) => String(block.text)).join(" ");
|
|
53127
|
+
}
|
|
53089
53128
|
function count2(value) {
|
|
53090
53129
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
53091
53130
|
}
|
|
@@ -53093,8 +53132,18 @@ async function readQoderUsage(file2, signal) {
|
|
|
53093
53132
|
const messages = /* @__PURE__ */ new Map();
|
|
53094
53133
|
let sessionId;
|
|
53095
53134
|
let cwd;
|
|
53096
|
-
|
|
53135
|
+
let customTitle;
|
|
53136
|
+
let summary;
|
|
53137
|
+
let firstPrompt;
|
|
53138
|
+
for await (const line of jsonlRecords(file2, '"type"', signal)) {
|
|
53097
53139
|
signal.throwIfAborted();
|
|
53140
|
+
if (line.type === "custom-title")
|
|
53141
|
+
customTitle = usageSessionTitle(line.customTitle);
|
|
53142
|
+
else if (!summary && line.type === "summary")
|
|
53143
|
+
summary = usageSessionTitle(line.summary);
|
|
53144
|
+
else if (!firstPrompt && line.type === "user") {
|
|
53145
|
+
firstPrompt = usageSessionTitle(qoderUserText(line.message));
|
|
53146
|
+
}
|
|
53098
53147
|
if (line.type !== "assistant" || !isRecord2(line.message))
|
|
53099
53148
|
continue;
|
|
53100
53149
|
sessionId ??= line.sessionId;
|
|
@@ -53138,7 +53187,8 @@ async function readQoderUsage(file2, signal) {
|
|
|
53138
53187
|
}
|
|
53139
53188
|
const session = {
|
|
53140
53189
|
sessionId: typeof sessionId === "string" ? sessionId : void 0,
|
|
53141
|
-
cwd: typeof cwd === "string" ? cwd : void 0
|
|
53190
|
+
cwd: typeof cwd === "string" ? cwd : void 0,
|
|
53191
|
+
title: customTitle ?? summary ?? firstPrompt
|
|
53142
53192
|
};
|
|
53143
53193
|
return [...messages.values()].flatMap(({ entry }) => entry ? [withUsageSession(entry, session)] : []);
|
|
53144
53194
|
}
|
|
@@ -27265,6 +27265,8 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
|
|
|
27265
27265
|
harness,
|
|
27266
27266
|
sessionId: external_exports.string().min(1).max(512),
|
|
27267
27267
|
project: project.nullable(),
|
|
27268
|
+
/** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
|
|
27269
|
+
title: external_exports.string().min(1).max(200).optional(),
|
|
27268
27270
|
/** Models the session used, most requests first. */
|
|
27269
27271
|
models: external_exports.array(model).max(16),
|
|
27270
27272
|
firstAtMs: count,
|
|
@@ -27331,7 +27333,12 @@ var usageStatisticsResultSchema = external_exports.strictObject({
|
|
|
27331
27333
|
* The sessions that spent the most, by cost and by tokens without cache, all filters applied;
|
|
27332
27334
|
* requests without a native session are not listed here but count everywhere else.
|
|
27333
27335
|
*/
|
|
27334
|
-
sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
|
|
27336
|
+
sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
|
|
27337
|
+
/**
|
|
27338
|
+
* The sessions last active in the range, newest first, all filters applied. Optional for older
|
|
27339
|
+
* Hosts; missing is treated as no list rather than no sessions.
|
|
27340
|
+
*/
|
|
27341
|
+
recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
|
|
27335
27342
|
});
|
|
27336
27343
|
|
|
27337
27344
|
// ../../shared-contracts/dist/ids.js
|
|
@@ -52923,6 +52930,20 @@ import path6 from "node:path";
|
|
|
52923
52930
|
import { createInterface } from "node:readline";
|
|
52924
52931
|
var MAX_SESSION_ID_LENGTH = 512;
|
|
52925
52932
|
var MAX_CWD_LENGTH = 4096;
|
|
52933
|
+
var MAX_SESSION_TITLE_LENGTH = 200;
|
|
52934
|
+
function usageSessionTitle(value) {
|
|
52935
|
+
if (typeof value !== "string")
|
|
52936
|
+
return void 0;
|
|
52937
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
52938
|
+
if (!normalized)
|
|
52939
|
+
return void 0;
|
|
52940
|
+
if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
|
|
52941
|
+
return normalized;
|
|
52942
|
+
const characters = [...normalized];
|
|
52943
|
+
if (characters.length <= MAX_SESSION_TITLE_LENGTH)
|
|
52944
|
+
return normalized;
|
|
52945
|
+
return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
|
|
52946
|
+
}
|
|
52926
52947
|
function sessionIdOk(value) {
|
|
52927
52948
|
return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
|
|
52928
52949
|
}
|
|
@@ -52932,12 +52953,14 @@ function cwdOk(value) {
|
|
|
52932
52953
|
function withUsageSession(entry, session) {
|
|
52933
52954
|
const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
|
|
52934
52955
|
const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
|
|
52956
|
+
const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
|
|
52935
52957
|
if (sessionId === void 0 && cwd === void 0)
|
|
52936
52958
|
return entry;
|
|
52937
52959
|
return {
|
|
52938
52960
|
...entry,
|
|
52939
52961
|
...sessionId !== void 0 ? { sessionId } : {},
|
|
52940
|
-
...cwd !== void 0 ? { cwd } : {}
|
|
52962
|
+
...cwd !== void 0 ? { cwd } : {},
|
|
52963
|
+
...sessionTitle !== void 0 ? { sessionTitle } : {}
|
|
52941
52964
|
};
|
|
52942
52965
|
}
|
|
52943
52966
|
function tokenCount(value) {
|
|
@@ -52977,6 +53000,12 @@ function parseHarnessUsageEntry(value) {
|
|
|
52977
53000
|
return null;
|
|
52978
53001
|
if (entry.cwd !== void 0 && !cwdOk(entry.cwd))
|
|
52979
53002
|
return null;
|
|
53003
|
+
if (entry.sessionTitle !== void 0) {
|
|
53004
|
+
const sessionTitle = usageSessionTitle(entry.sessionTitle);
|
|
53005
|
+
if (sessionTitle === void 0)
|
|
53006
|
+
return null;
|
|
53007
|
+
entry.sessionTitle = sessionTitle;
|
|
53008
|
+
}
|
|
52980
53009
|
if (entry.tokensUnknown !== void 0 && entry.tokensUnknown !== true)
|
|
52981
53010
|
return null;
|
|
52982
53011
|
if (entry.costUsd !== void 0 && (typeof entry.costUsd !== "number" || !Number.isFinite(entry.costUsd) || entry.costUsd < 0)) {
|
|
@@ -53088,6 +53117,16 @@ function qoderProjectsDirectory(environment, variant) {
|
|
|
53088
53117
|
function isRecord2(value) {
|
|
53089
53118
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
53090
53119
|
}
|
|
53120
|
+
function qoderUserText(message) {
|
|
53121
|
+
if (!isRecord2(message))
|
|
53122
|
+
return void 0;
|
|
53123
|
+
const { content } = message;
|
|
53124
|
+
if (typeof content === "string")
|
|
53125
|
+
return content;
|
|
53126
|
+
if (!Array.isArray(content))
|
|
53127
|
+
return void 0;
|
|
53128
|
+
return content.filter((block) => isRecord2(block) && block.type === "text" && typeof block.text === "string").map((block) => String(block.text)).join(" ");
|
|
53129
|
+
}
|
|
53091
53130
|
function count2(value) {
|
|
53092
53131
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
53093
53132
|
}
|
|
@@ -53095,8 +53134,18 @@ async function readQoderUsage(file2, signal) {
|
|
|
53095
53134
|
const messages = /* @__PURE__ */ new Map();
|
|
53096
53135
|
let sessionId;
|
|
53097
53136
|
let cwd;
|
|
53098
|
-
|
|
53137
|
+
let customTitle;
|
|
53138
|
+
let summary;
|
|
53139
|
+
let firstPrompt;
|
|
53140
|
+
for await (const line of jsonlRecords(file2, '"type"', signal)) {
|
|
53099
53141
|
signal.throwIfAborted();
|
|
53142
|
+
if (line.type === "custom-title")
|
|
53143
|
+
customTitle = usageSessionTitle(line.customTitle);
|
|
53144
|
+
else if (!summary && line.type === "summary")
|
|
53145
|
+
summary = usageSessionTitle(line.summary);
|
|
53146
|
+
else if (!firstPrompt && line.type === "user") {
|
|
53147
|
+
firstPrompt = usageSessionTitle(qoderUserText(line.message));
|
|
53148
|
+
}
|
|
53100
53149
|
if (line.type !== "assistant" || !isRecord2(line.message))
|
|
53101
53150
|
continue;
|
|
53102
53151
|
sessionId ??= line.sessionId;
|
|
@@ -53140,7 +53189,8 @@ async function readQoderUsage(file2, signal) {
|
|
|
53140
53189
|
}
|
|
53141
53190
|
const session = {
|
|
53142
53191
|
sessionId: typeof sessionId === "string" ? sessionId : void 0,
|
|
53143
|
-
cwd: typeof cwd === "string" ? cwd : void 0
|
|
53192
|
+
cwd: typeof cwd === "string" ? cwd : void 0,
|
|
53193
|
+
title: customTitle ?? summary ?? firstPrompt
|
|
53144
53194
|
};
|
|
53145
53195
|
return [...messages.values()].flatMap(({ entry }) => entry ? [withUsageSession(entry, session)] : []);
|
|
53146
53196
|
}
|