@t2000/engine 1.24.8 → 1.24.9
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/index.js +46 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7814,6 +7814,7 @@ var QueryEngine = class {
|
|
|
7814
7814
|
* the fresh tool results and narrates from them.
|
|
7815
7815
|
*/
|
|
7816
7816
|
async *runPostWriteRefresh(action, response, signal) {
|
|
7817
|
+
const totalStart = Date.now();
|
|
7817
7818
|
const isBundle = Array.isArray(action.steps) && action.steps.length > 0;
|
|
7818
7819
|
const refreshSet = /* @__PURE__ */ new Set();
|
|
7819
7820
|
if (isBundle) {
|
|
@@ -7855,10 +7856,17 @@ var QueryEngine = class {
|
|
|
7855
7856
|
blockvisionApiKey: this.blockvisionApiKey,
|
|
7856
7857
|
portfolioCache: this.portfolioCache
|
|
7857
7858
|
};
|
|
7859
|
+
const cacheInvalidationStart = Date.now();
|
|
7858
7860
|
if (this.walletAddress) {
|
|
7859
7861
|
this.portfolioCache?.delete(this.walletAddress);
|
|
7860
7862
|
await clearPortfolioCacheFor(this.walletAddress);
|
|
7861
7863
|
}
|
|
7864
|
+
getTelemetrySink().histogram(
|
|
7865
|
+
"engine.pwr.cache_invalidation_ms",
|
|
7866
|
+
Date.now() - cacheInvalidationStart,
|
|
7867
|
+
{ has_wallet: this.walletAddress ? "1" : "0" }
|
|
7868
|
+
);
|
|
7869
|
+
const sleepStart = Date.now();
|
|
7862
7870
|
if (!signal.aborted) {
|
|
7863
7871
|
await new Promise((resolve) => {
|
|
7864
7872
|
const t = setTimeout(resolve, 1500);
|
|
@@ -7868,14 +7876,26 @@ var QueryEngine = class {
|
|
|
7868
7876
|
}, { once: true });
|
|
7869
7877
|
});
|
|
7870
7878
|
}
|
|
7879
|
+
getTelemetrySink().histogram(
|
|
7880
|
+
"engine.pwr.sleep_ms",
|
|
7881
|
+
Date.now() - sleepStart,
|
|
7882
|
+
{ aborted: signal.aborted ? "1" : "0" }
|
|
7883
|
+
);
|
|
7871
7884
|
if (signal.aborted) return;
|
|
7885
|
+
const refreshStart = Date.now();
|
|
7872
7886
|
const idStem = `pwr_${action.toolUseId.slice(-6)}`;
|
|
7873
7887
|
const refreshes = await Promise.all(
|
|
7874
7888
|
refreshTools.map(async (tool, idx) => {
|
|
7875
7889
|
const id = `${idStem}_${idx}_${tool.name}`;
|
|
7890
|
+
const toolStart = Date.now();
|
|
7876
7891
|
try {
|
|
7877
7892
|
const parsed = tool.inputSchema.safeParse({});
|
|
7878
7893
|
if (!parsed.success) {
|
|
7894
|
+
getTelemetrySink().histogram(
|
|
7895
|
+
"engine.pwr.tool_ms",
|
|
7896
|
+
Date.now() - toolStart,
|
|
7897
|
+
{ tool: tool.name, outcome: "invalid_input" }
|
|
7898
|
+
);
|
|
7879
7899
|
return {
|
|
7880
7900
|
tool,
|
|
7881
7901
|
id,
|
|
@@ -7888,6 +7908,11 @@ var QueryEngine = class {
|
|
|
7888
7908
|
}
|
|
7889
7909
|
const { context: toolCtx, readAttemptCount } = withRetryStats(context);
|
|
7890
7910
|
const result = await tool.call(parsed.data, toolCtx);
|
|
7911
|
+
getTelemetrySink().histogram(
|
|
7912
|
+
"engine.pwr.tool_ms",
|
|
7913
|
+
Date.now() - toolStart,
|
|
7914
|
+
{ tool: tool.name, outcome: "success" }
|
|
7915
|
+
);
|
|
7891
7916
|
return {
|
|
7892
7917
|
tool,
|
|
7893
7918
|
id,
|
|
@@ -7896,6 +7921,11 @@ var QueryEngine = class {
|
|
|
7896
7921
|
attemptCount: readAttemptCount()
|
|
7897
7922
|
};
|
|
7898
7923
|
} catch (err) {
|
|
7924
|
+
getTelemetrySink().histogram(
|
|
7925
|
+
"engine.pwr.tool_ms",
|
|
7926
|
+
Date.now() - toolStart,
|
|
7927
|
+
{ tool: tool.name, outcome: "error" }
|
|
7928
|
+
);
|
|
7899
7929
|
return {
|
|
7900
7930
|
tool,
|
|
7901
7931
|
id,
|
|
@@ -7908,6 +7938,14 @@ var QueryEngine = class {
|
|
|
7908
7938
|
}
|
|
7909
7939
|
})
|
|
7910
7940
|
);
|
|
7941
|
+
getTelemetrySink().histogram(
|
|
7942
|
+
"engine.pwr.refresh_total_ms",
|
|
7943
|
+
Date.now() - refreshStart,
|
|
7944
|
+
{
|
|
7945
|
+
tool_count: String(refreshTools.length),
|
|
7946
|
+
is_bundle: isBundle ? "1" : "0"
|
|
7947
|
+
}
|
|
7948
|
+
);
|
|
7911
7949
|
const refreshUses = refreshes.map((r) => ({
|
|
7912
7950
|
type: "tool_use",
|
|
7913
7951
|
id: r.id,
|
|
@@ -7939,6 +7977,14 @@ var QueryEngine = class {
|
|
|
7939
7977
|
...r.attemptCount !== void 0 ? { attemptCount: r.attemptCount } : {}
|
|
7940
7978
|
};
|
|
7941
7979
|
}
|
|
7980
|
+
getTelemetrySink().histogram(
|
|
7981
|
+
"engine.pwr.total_ms",
|
|
7982
|
+
Date.now() - totalStart,
|
|
7983
|
+
{
|
|
7984
|
+
tool_count: String(refreshTools.length),
|
|
7985
|
+
is_bundle: isBundle ? "1" : "0"
|
|
7986
|
+
}
|
|
7987
|
+
);
|
|
7942
7988
|
}
|
|
7943
7989
|
interrupt() {
|
|
7944
7990
|
this.abortController?.abort();
|