@tangle-network/agent-app 4.0.27 → 4.0.28
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/chat-routes/index.js +2 -2
- package/dist/chat-routes/producer-trace.d.ts +12 -0
- package/dist/{chunk-U4HKZV5U.js → chunk-7TZX2KSH.js} +8 -9
- package/dist/chunk-7TZX2KSH.js.map +1 -0
- package/dist/{chunk-7ZNW7NOX.js → chunk-WXK2AKRZ.js} +25 -3
- package/dist/chunk-WXK2AKRZ.js.map +1 -0
- package/dist/public-consultation/index.d.ts +1 -1
- package/dist/public-consultation/index.js +2 -2
- package/dist/sandbox/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-7ZNW7NOX.js.map +0 -1
- package/dist/chunk-U4HKZV5U.js.map +0 -1
|
@@ -74,14 +74,14 @@ import {
|
|
|
74
74
|
turnPromptText,
|
|
75
75
|
valueRedactor,
|
|
76
76
|
withProducerStream
|
|
77
|
-
} from "../chunk-
|
|
77
|
+
} from "../chunk-WXK2AKRZ.js";
|
|
78
78
|
import "../chunk-SBHFMDR7.js";
|
|
79
79
|
import "../chunk-H6BRJU5M.js";
|
|
80
80
|
import "../chunk-4DBHC63F.js";
|
|
81
81
|
import "../chunk-RN4WPTBH.js";
|
|
82
82
|
import "../chunk-MM6RLOXF.js";
|
|
83
83
|
import "../chunk-M4QITAQV.js";
|
|
84
|
-
import "../chunk-
|
|
84
|
+
import "../chunk-7TZX2KSH.js";
|
|
85
85
|
import "../chunk-F4TUZYMX.js";
|
|
86
86
|
import {
|
|
87
87
|
redactErrorMessage
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The product producer's own time at either end of its stream. Before its first event it does its setup (keys, reads,
|
|
3
|
+
* prompt composition, a box it resolves itself); after its last it runs the cleanup its stream holds until it returns
|
|
4
|
+
* (revocations, a charge). Neither is inside a span the route records, so each was a gap no span named: 745 ms and
|
|
5
|
+
* 1,382 ms of a 12.6 s Tax Router turn, 2,720 ms and 1,296 ms of a 20.5 s box turn. A product that measures its own
|
|
6
|
+
* steps inside them (`trace.measure`) nests nothing here: these two spans only say whose time it was.
|
|
7
|
+
*/
|
|
8
|
+
import type { TurnTrace } from '../turn-trace/recorder.js';
|
|
9
|
+
/** A producer's stream, unchanged, recording `produce.setup` until its first event and `produce.settle` from the request
|
|
10
|
+
* after its last event until it ends. It only times `next`; `return` and `throw` reach the producer's own iterator
|
|
11
|
+
* untouched, so `yield*` over it behaves exactly as over the producer (a producer reads an early `return` as a stop). */
|
|
12
|
+
export declare function traceProducerStream<T>(stream: AsyncIterable<T>, trace: TurnTrace): AsyncIterable<T>;
|
|
@@ -74,15 +74,9 @@ function createPromptTrace(trace, parent, meta) {
|
|
|
74
74
|
let phases;
|
|
75
75
|
let events = 0;
|
|
76
76
|
const tools = /* @__PURE__ */ new Map();
|
|
77
|
+
const toolAttrs = (id, name) => ({ "gen_ai.tool.name": name, "tool.call_id": id, "call.index": nextCallIndex(trace, "tool.call"), where: "sandbox" });
|
|
77
78
|
const startTool = (id, name) => {
|
|
78
|
-
if (tools.has(id))
|
|
79
|
-
tools.set(id, trace.start("tool.call", "tool", {
|
|
80
|
-
"gen_ai.tool.name": name,
|
|
81
|
-
"tool.call_id": id,
|
|
82
|
-
"call.index": nextCallIndex(trace, "tool.call"),
|
|
83
|
-
where: "sandbox",
|
|
84
|
-
approx: true
|
|
85
|
-
}, generation ?? prompt));
|
|
79
|
+
if (!tools.has(id)) tools.set(id, trace.start("tool.call", "tool", { ...toolAttrs(id, name), approx: true }, generation ?? prompt));
|
|
86
80
|
};
|
|
87
81
|
const observe = (raw) => {
|
|
88
82
|
try {
|
|
@@ -127,6 +121,11 @@ function createPromptTrace(trace, parent, meta) {
|
|
|
127
121
|
if (!id) return;
|
|
128
122
|
const state = asRec(part?.state);
|
|
129
123
|
const status = String(state?.status ?? part?.status ?? "");
|
|
124
|
+
const ranMs = (asNum(asRec(state?.time)?.end) ?? NaN) - (asNum(asRec(state?.time)?.start) ?? NaN);
|
|
125
|
+
if (!tools.has(id) && (status === "completed" || status === "error") && ranMs >= 0) {
|
|
126
|
+
const attrs = { ...toolAttrs(id, String(part?.tool ?? "tool")), ...status === "error" ? { "tool.status": "error" } : {} };
|
|
127
|
+
return void tools.set(id, trace.record("tool.call", "tool", Math.max(startedAt, now - ranMs), now, attrs, generation ?? prompt));
|
|
128
|
+
}
|
|
130
129
|
startTool(id, String(part?.tool ?? "tool"));
|
|
131
130
|
if (status === "completed" || status === "error") tools.get(id)?.end(void 0, status === "error" ? "tool_error" : void 0);
|
|
132
131
|
}
|
|
@@ -4394,4 +4393,4 @@ export {
|
|
|
4394
4393
|
deleteSecret,
|
|
4395
4394
|
mintSandboxScopedToken
|
|
4396
4395
|
};
|
|
4397
|
-
//# sourceMappingURL=chunk-
|
|
4396
|
+
//# sourceMappingURL=chunk-7TZX2KSH.js.map
|