@tangle-network/agent-app 0.60.199 → 0.60.200
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 +1 -1
- package/dist/{chunk-RJJRRR5Z.js → chunk-ZHJ2TDWA.js} +28 -14
- package/dist/chunk-ZHJ2TDWA.js.map +1 -0
- package/dist/sandbox/index.d.ts +1 -0
- package/dist/sandbox/index.js +3 -1
- package/dist/sandbox/prompt-trace.d.ts +12 -6
- package/package.json +1 -1
- package/dist/chunk-RJJRRR5Z.js.map +0 -1
|
@@ -149,6 +149,21 @@ function createPromptTrace(trace, parent, meta) {
|
|
|
149
149
|
};
|
|
150
150
|
return { observe, end };
|
|
151
151
|
}
|
|
152
|
+
async function* traceSandboxPromptEvents(events, options) {
|
|
153
|
+
const prompt = createPromptTrace(options.trace, options.parent, options.meta ?? {});
|
|
154
|
+
let failure;
|
|
155
|
+
try {
|
|
156
|
+
for await (const event of events) {
|
|
157
|
+
prompt.observe(event);
|
|
158
|
+
yield event;
|
|
159
|
+
}
|
|
160
|
+
} catch (error) {
|
|
161
|
+
failure = error;
|
|
162
|
+
throw error;
|
|
163
|
+
} finally {
|
|
164
|
+
prompt.end(failure);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
152
167
|
|
|
153
168
|
// src/sandbox/model.ts
|
|
154
169
|
function backendModelFields(model) {
|
|
@@ -3192,16 +3207,18 @@ async function* streamSandboxPrompt(shell, box, message, options) {
|
|
|
3192
3207
|
const stream = options?.lastEventId ? dispatch() : resendRefusedDispatch(dispatch, options?.signal);
|
|
3193
3208
|
emitSandboxActivity(options?.spend, box);
|
|
3194
3209
|
let severedFinishReason = null;
|
|
3195
|
-
const
|
|
3196
|
-
|
|
3197
|
-
...options.
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3210
|
+
const observed = options?.trace ? traceSandboxPromptEvents(stream, {
|
|
3211
|
+
trace: options.trace,
|
|
3212
|
+
...options.traceParent ? { parent: options.traceParent } : {},
|
|
3213
|
+
meta: {
|
|
3214
|
+
"sandbox.id": box.id,
|
|
3215
|
+
...options.model ? { "gen_ai.request.model": options.model } : {},
|
|
3216
|
+
...options.harness ? { "sandbox.harness": options.harness } : {},
|
|
3217
|
+
...options.detach ? { "sandbox.detached": true } : {}
|
|
3218
|
+
}
|
|
3219
|
+
}) : stream;
|
|
3202
3220
|
try {
|
|
3203
|
-
for await (const event of
|
|
3204
|
-
promptTrace?.observe(event);
|
|
3221
|
+
for await (const event of observed) {
|
|
3205
3222
|
const step = classifySeveredStream(event);
|
|
3206
3223
|
if (step) severedFinishReason = step.kind === "step-finish" && step.severed ? step.reason : null;
|
|
3207
3224
|
if (severedFinishReason && isTerminalPromptEvent(event)) {
|
|
@@ -3215,12 +3232,8 @@ async function* streamSandboxPrompt(shell, box, message, options) {
|
|
|
3215
3232
|
}
|
|
3216
3233
|
yield event;
|
|
3217
3234
|
}
|
|
3218
|
-
} catch (error) {
|
|
3219
|
-
promptError = error;
|
|
3220
|
-
throw error;
|
|
3221
3235
|
} finally {
|
|
3222
3236
|
emitSandboxActivity(options?.spend, box);
|
|
3223
|
-
promptTrace?.end(promptError);
|
|
3224
3237
|
}
|
|
3225
3238
|
if (severedFinishReason) {
|
|
3226
3239
|
throw new Error(`sandbox model stream severed mid-turn (reason="${severedFinishReason}")`);
|
|
@@ -3414,6 +3427,7 @@ function firstQuestionText(value) {
|
|
|
3414
3427
|
}
|
|
3415
3428
|
|
|
3416
3429
|
export {
|
|
3430
|
+
traceSandboxPromptEvents,
|
|
3417
3431
|
backendModelFields,
|
|
3418
3432
|
resolveModelSelection,
|
|
3419
3433
|
resolveModel,
|
|
@@ -3513,4 +3527,4 @@ export {
|
|
|
3513
3527
|
isTerminalPromptEvent,
|
|
3514
3528
|
detectInteractiveQuestion
|
|
3515
3529
|
};
|
|
3516
|
-
//# sourceMappingURL=chunk-
|
|
3530
|
+
//# sourceMappingURL=chunk-ZHJ2TDWA.js.map
|