@tangle-network/agent-app 4.0.26 → 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.
Files changed (39) hide show
  1. package/dist/assistant/index.js +2 -1
  2. package/dist/assistant/index.js.map +1 -1
  3. package/dist/chat-routes/draft-persistence.d.ts +1 -4
  4. package/dist/chat-routes/index.js +7 -5
  5. package/dist/chat-routes/index.js.map +1 -1
  6. package/dist/chat-routes/producer-trace.d.ts +12 -0
  7. package/dist/{chunk-U4HKZV5U.js → chunk-7TZX2KSH.js} +8 -9
  8. package/dist/chunk-7TZX2KSH.js.map +1 -0
  9. package/dist/chunk-IMSNXL2S.js +1 -0
  10. package/dist/{chunk-BQH5HAKO.js → chunk-O6MFZVNS.js} +1 -5
  11. package/dist/chunk-O6MFZVNS.js.map +1 -0
  12. package/dist/chunk-QM5TPZQY.js +18 -0
  13. package/dist/chunk-QM5TPZQY.js.map +1 -0
  14. package/dist/{chunk-M4LA7JMU.js → chunk-R57ZNKJB.js} +976 -784
  15. package/dist/chunk-R57ZNKJB.js.map +1 -0
  16. package/dist/{chunk-75DKKZQ3.js → chunk-UFR4BXCC.js} +2 -2
  17. package/dist/{chunk-4YRRHORE.js → chunk-WXK2AKRZ.js} +31 -6
  18. package/dist/chunk-WXK2AKRZ.js.map +1 -0
  19. package/dist/preset-cloudflare/index.js +6 -4
  20. package/dist/preset-cloudflare/index.js.map +1 -1
  21. package/dist/public-consultation/index.js +4 -3
  22. package/dist/public-consultation/index.js.map +1 -1
  23. package/dist/sandbox/index.js +1 -1
  24. package/dist/stories/fixtures/turn-trace.d.ts +1799 -0
  25. package/dist/turn-trace/index.d.ts +1 -0
  26. package/dist/turn-trace/index.js +8 -2
  27. package/dist/turn-trace/url.d.ts +12 -0
  28. package/dist/web-react/index.d.ts +2 -0
  29. package/dist/web-react/index.js +10 -1
  30. package/dist/web-react/turn-trace-drawer.d.ts +26 -0
  31. package/dist/web-react/turn-trace-flow.d.ts +20 -0
  32. package/package.json +1 -1
  33. package/dist/chunk-4YRRHORE.js.map +0 -1
  34. package/dist/chunk-BQH5HAKO.js.map +0 -1
  35. package/dist/chunk-KG2Y44XT.js +0 -1
  36. package/dist/chunk-M4LA7JMU.js.map +0 -1
  37. package/dist/chunk-U4HKZV5U.js.map +0 -1
  38. /package/dist/{chunk-KG2Y44XT.js.map → chunk-IMSNXL2S.js.map} +0 -0
  39. /package/dist/{chunk-75DKKZQ3.js.map → chunk-UFR4BXCC.js.map} +0 -0
@@ -2,7 +2,7 @@ import {
2
2
  TURN_USAGE_KEYS,
3
3
  addStepFinishUsage,
4
4
  withoutToolList
5
- } from "./chunk-BQH5HAKO.js";
5
+ } from "./chunk-O6MFZVNS.js";
6
6
  import {
7
7
  asRecord,
8
8
  asString,
@@ -447,4 +447,4 @@ export {
447
447
  TOOL_ABORTED_ERROR,
448
448
  observeNativeCompletion
449
449
  };
450
- //# sourceMappingURL=chunk-75DKKZQ3.js.map
450
+ //# sourceMappingURL=chunk-UFR4BXCC.js.map
@@ -30,7 +30,7 @@ import {
30
30
  sandboxRunFailureDetail,
31
31
  streamSandboxPrompt,
32
32
  turnStorageBindings
33
- } from "./chunk-U4HKZV5U.js";
33
+ } from "./chunk-7TZX2KSH.js";
34
34
  import {
35
35
  redactErrorMessage
36
36
  } from "./chunk-MH74DY2I.js";
@@ -40,7 +40,6 @@ import {
40
40
  WITHHELD_FAILURE,
41
41
  abortOnSignal,
42
42
  addStepFinishUsage,
43
- assistantRowIdForTurn,
44
43
  concatStreams,
45
44
  createAssistantDraftWriter,
46
45
  failureCode,
@@ -64,7 +63,11 @@ import {
64
63
  transformVisibleTextParts,
65
64
  withStreamHeartbeat,
66
65
  withoutToolList
67
- } from "./chunk-BQH5HAKO.js";
66
+ } from "./chunk-O6MFZVNS.js";
67
+ import {
68
+ assistantRowIdForTurn,
69
+ turnTraceUrl
70
+ } from "./chunk-QM5TPZQY.js";
68
71
  import {
69
72
  normalizeClientTurnId,
70
73
  resolveChatTurn
@@ -2019,7 +2022,7 @@ function turnTraceWiring(projectId, turnTrace) {
2019
2022
  const traceReader = turnTrace === false ? void 0 : traceOptions?.read ?? (traceOptions?.sink ? void 0 : createIntelligenceTurnTraceReader({ project: projectId }));
2020
2023
  const traceReceipt = (request, executionId) => ({
2021
2024
  ...traceSink ? { traceId: otlpTraceId(turnTraceId(executionId)) } : {},
2022
- ...traceReader ? { traceUrl: `${new URL(request.url).pathname.replace(/\/+$/, "")}/turns/${encodeURIComponent(executionId)}/trace` } : {}
2025
+ ...traceReader ? { traceUrl: turnTraceUrl(new URL(request.url).pathname, executionId) } : {}
2023
2026
  });
2024
2027
  return { traceOptions, traceSink, traceReader, traceReceipt };
2025
2028
  }
@@ -2099,6 +2102,28 @@ function startTurnPrefetch(prefetch, input) {
2099
2102
  // src/chat-routes/turn-execution.ts
2100
2103
  import { deriveExecutionId as deriveExecutionId2, handleChatTurn } from "@tangle-network/agent-runtime/durable";
2101
2104
 
2105
+ // src/chat-routes/producer-trace.ts
2106
+ function traceProducerStream(stream, trace) {
2107
+ return {
2108
+ [Symbol.asyncIterator]() {
2109
+ const inner = stream[Symbol.asyncIterator]();
2110
+ let first = true;
2111
+ return {
2112
+ async next(...args) {
2113
+ const asked = Date.now();
2114
+ const result = await inner.next(...args);
2115
+ if (first) trace.record("produce.setup", "other", asked, Date.now());
2116
+ else if (result.done) trace.record("produce.settle", "other", asked, Date.now());
2117
+ first = false;
2118
+ return result;
2119
+ },
2120
+ ...inner.return ? { return: inner.return.bind(inner) } : {},
2121
+ ...inner.throw ? { throw: inner.throw.bind(inner) } : {}
2122
+ };
2123
+ }
2124
+ };
2125
+ }
2126
+
2102
2127
  // src/chat-routes/native-turn-timing.ts
2103
2128
  function createNativeTimingTransfer(read, onError) {
2104
2129
  let persist;
@@ -2860,7 +2885,7 @@ function createTurnEngine(identity, ctx, log, state, dispatched, produceArgs, tr
2860
2885
  });
2861
2886
  }
2862
2887
  state.producer = await started;
2863
- yield* state.producer.stream;
2888
+ yield* traceProducerStream(state.producer.stream, trace);
2864
2889
  };
2865
2890
  let source = redact ? redactEvents(producerStream(), redact) : producerStream();
2866
2891
  if (options.cancel && state.cancellationAbort && !state.closeCancellation) {
@@ -3720,4 +3745,4 @@ export {
3720
3745
  createChatTurnRoutes,
3721
3746
  streamChatRouteAsSandboxEvents
3722
3747
  };
3723
- //# sourceMappingURL=chunk-4YRRHORE.js.map
3748
+ //# sourceMappingURL=chunk-WXK2AKRZ.js.map