topchester-ai 0.33.0 → 0.35.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/dist/bin.mjs
CHANGED
|
@@ -5145,7 +5145,7 @@ async function consumeReasoningStream(stream, onReasoning) {
|
|
|
5145
5145
|
if (!part || typeof part !== "object") continue;
|
|
5146
5146
|
const typedPart = part;
|
|
5147
5147
|
if (typedPart.type === "error") throw typedPart.error;
|
|
5148
|
-
if (typedPart.type === "raw" &&
|
|
5148
|
+
if (typedPart.type === "raw" && hasUsageOrCostBody(typedPart.rawValue)) {
|
|
5149
5149
|
rawUsageBody = typedPart.rawValue;
|
|
5150
5150
|
continue;
|
|
5151
5151
|
}
|
|
@@ -5170,8 +5170,8 @@ async function emitReasoningSummary(onReasoning, sawReasoningDelta, reasoningTex
|
|
|
5170
5170
|
text: reasoningText
|
|
5171
5171
|
});
|
|
5172
5172
|
}
|
|
5173
|
-
function
|
|
5174
|
-
return Boolean(value && typeof value === "object" && "usage" in value && value.usage && typeof value.usage === "object");
|
|
5173
|
+
function hasUsageOrCostBody(value) {
|
|
5174
|
+
return Boolean(value && typeof value === "object" && ("usage" in value && value.usage && typeof value.usage === "object" || extractResponseCostUsd(value) !== void 0));
|
|
5175
5175
|
}
|
|
5176
5176
|
function withRawUsageBody(response, rawUsageBody) {
|
|
5177
5177
|
return rawUsageBody === void 0 ? response : {
|
|
@@ -5221,7 +5221,7 @@ function extractWarningMessages(warnings) {
|
|
|
5221
5221
|
return warnings.map((warning) => formatErrorMessage$2(warning));
|
|
5222
5222
|
}
|
|
5223
5223
|
function normalizeUsage(usage, context) {
|
|
5224
|
-
const costUsd =
|
|
5224
|
+
const costUsd = extractResponseCostUsd(context?.responseBody);
|
|
5225
5225
|
if (!usage) return costUsd === void 0 ? void 0 : { costUsd };
|
|
5226
5226
|
const normalized = {
|
|
5227
5227
|
...typeof usage.inputTokens === "number" ? { inputTokens: usage.inputTokens } : {},
|
|
@@ -5231,12 +5231,24 @@ function normalizeUsage(usage, context) {
|
|
|
5231
5231
|
};
|
|
5232
5232
|
return Object.keys(normalized).length > 0 ? normalized : void 0;
|
|
5233
5233
|
}
|
|
5234
|
-
function
|
|
5234
|
+
function extractResponseCostUsd(responseBody) {
|
|
5235
5235
|
if (!responseBody || typeof responseBody !== "object") return;
|
|
5236
5236
|
const usage = responseBody.usage;
|
|
5237
|
-
|
|
5238
|
-
const
|
|
5239
|
-
return
|
|
5237
|
+
const hiddenParams = responseBody.hidden_params;
|
|
5238
|
+
const privateHiddenParams = responseBody._hidden_params;
|
|
5239
|
+
return firstFiniteNumber(getObjectNumber(responseBody, "response_cost"), getObjectNumber(responseBody, "responseCost"), getObjectNumber(responseBody, "cost"), getObjectNumber(responseBody, "cost_usd"), getObjectNumber(responseBody, "costUsd"), getObjectNumber(usage, "cost"), getObjectNumber(usage, "response_cost"), getObjectNumber(usage, "responseCost"), getObjectNumber(usage, "cost_usd"), getObjectNumber(usage, "costUsd"), getObjectNumber(hiddenParams, "response_cost"), getObjectNumber(privateHiddenParams, "response_cost"));
|
|
5240
|
+
}
|
|
5241
|
+
function getObjectNumber(value, key) {
|
|
5242
|
+
if (!value || typeof value !== "object") return;
|
|
5243
|
+
const field = value[key];
|
|
5244
|
+
if (typeof field === "number" && Number.isFinite(field)) return field;
|
|
5245
|
+
if (typeof field === "string" && field.trim().length > 0) {
|
|
5246
|
+
const parsed = Number(field);
|
|
5247
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
5248
|
+
}
|
|
5249
|
+
}
|
|
5250
|
+
function firstFiniteNumber(...values) {
|
|
5251
|
+
return values.find((value) => value !== void 0);
|
|
5240
5252
|
}
|
|
5241
5253
|
function formatErrorMessage$2(error) {
|
|
5242
5254
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -6882,13 +6894,15 @@ async function syncKnowledgeBase(workspaceRoot, options = {}) {
|
|
|
6882
6894
|
const queue = createL1QueueFile(queuedFiles, generatedAt);
|
|
6883
6895
|
options.onProgress?.({ message: options.full ? "Writing full L1 sync queue and manifest..." : "Writing L1 sync queue and manifest..." });
|
|
6884
6896
|
await writeFile(queuePath, `${JSON.stringify(queue, null, 2)}\n`);
|
|
6897
|
+
const dirtyFilePaths = new Set(dirtyFiles.map((file) => file.path));
|
|
6898
|
+
const currentEntryCount = options.full ? 0 : inventory.files.filter((file) => !dirtyFilePaths.has(file.path)).length;
|
|
6885
6899
|
const l1 = {
|
|
6886
6900
|
queued: queuedFiles.length,
|
|
6887
6901
|
completed: 0,
|
|
6888
6902
|
failed: 0,
|
|
6889
6903
|
changed: 0,
|
|
6890
6904
|
missing: 0,
|
|
6891
|
-
currentEntries:
|
|
6905
|
+
currentEntries: currentEntryCount
|
|
6892
6906
|
};
|
|
6893
6907
|
await writeFile(manifestPath, `${JSON.stringify({
|
|
6894
6908
|
name: "topchester-kb",
|
|
@@ -13665,4 +13679,4 @@ function formatDryRunSyncStatus(status) {
|
|
|
13665
13679
|
//#endregion
|
|
13666
13680
|
export { runTopchesterCli as t };
|
|
13667
13681
|
|
|
13668
|
-
//# sourceMappingURL=cli-
|
|
13682
|
+
//# sourceMappingURL=cli-CGUyDhFW.mjs.map
|