@tangle-network/agent-app 4.0.0 → 4.0.2

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 (36) hide show
  1. package/dist/agent-profiles/d1.js +1 -1
  2. package/dist/agent-profiles/index.d.ts +2 -1
  3. package/dist/agent-profiles/index.js +1 -1
  4. package/dist/chat-routes/index.js +12 -17
  5. package/dist/chat-routes/index.js.map +1 -1
  6. package/dist/chat-routes/visible-text.d.ts +7 -0
  7. package/dist/{chunk-AFMLLZWU.js → chunk-GWATTXFR.js} +3 -3
  8. package/dist/{chunk-AFMLLZWU.js.map → chunk-GWATTXFR.js.map} +1 -1
  9. package/dist/{chunk-HES3IABJ.js → chunk-JKYCXQFI.js} +2 -2
  10. package/dist/{chunk-PABZALSD.js → chunk-LBMFQLBS.js} +9 -6
  11. package/dist/{chunk-PABZALSD.js.map → chunk-LBMFQLBS.js.map} +1 -1
  12. package/dist/{chunk-5DAEU3CP.js → chunk-SJKQUTGU.js} +11 -6
  13. package/dist/chunk-SJKQUTGU.js.map +1 -0
  14. package/dist/{chunk-JSWBJBPM.js → chunk-W5YQZEE4.js} +15 -10
  15. package/dist/chunk-W5YQZEE4.js.map +1 -0
  16. package/dist/{chunk-PISTUUEZ.js → chunk-XCUT2I52.js} +25 -12
  17. package/dist/{chunk-PISTUUEZ.js.map → chunk-XCUT2I52.js.map} +1 -1
  18. package/dist/{chunk-BRQ2SC6V.js → chunk-XKVJQVOT.js} +2 -1
  19. package/dist/chunk-XKVJQVOT.js.map +1 -0
  20. package/dist/conformance/cli.js +2 -2
  21. package/dist/conformance/cli.js.map +1 -1
  22. package/dist/conformance/index.js +1 -1
  23. package/dist/conformance/run.d.ts +3 -2
  24. package/dist/preset-cloudflare/index.js +2 -2
  25. package/dist/public-consultation/index.d.ts +1 -1
  26. package/dist/public-consultation/index.js +5 -3
  27. package/dist/public-consultation/index.js.map +1 -1
  28. package/dist/runtime/index.js +4 -2
  29. package/dist/runtime/index.js.map +1 -1
  30. package/dist/runtime/router-turn.d.ts +15 -0
  31. package/dist/runtime/router-turn.js +3 -1
  32. package/package.json +1 -1
  33. package/dist/chunk-5DAEU3CP.js.map +0 -1
  34. package/dist/chunk-BRQ2SC6V.js.map +0 -1
  35. package/dist/chunk-JSWBJBPM.js.map +0 -1
  36. /package/dist/{chunk-HES3IABJ.js.map → chunk-JKYCXQFI.js.map} +0 -0
@@ -532,6 +532,9 @@ function workspaceTurnCheckpoints(store, workspaceId, actor) {
532
532
  }
533
533
 
534
534
  // src/runtime/router-turn.ts
535
+ function narratesBefore(tool) {
536
+ return tool?.effect === "lookup";
537
+ }
535
538
  function placeRouterTurn(input) {
536
539
  return placeExecution({
537
540
  profile: input.profile,
@@ -640,6 +643,7 @@ async function runRouterTurn(options) {
640
643
  if (placement?.chosen === "sandbox") {
641
644
  return {
642
645
  text: "",
646
+ answer: "",
643
647
  servedModel: null,
644
648
  toolCalls: [],
645
649
  usage: { promptTokens: 0, completionTokens: 0, modelCalls: 0 },
@@ -652,6 +656,7 @@ async function runRouterTurn(options) {
652
656
  if (!apiKey) {
653
657
  return {
654
658
  text: "",
659
+ answer: "",
655
660
  servedModel: null,
656
661
  toolCalls: [],
657
662
  usage: { promptTokens: 0, completionTokens: 0, modelCalls: 0 },
@@ -711,6 +716,7 @@ async function runRouterTurn(options) {
711
716
  }
712
717
  });
713
718
  const segments = [];
719
+ const narrated = /* @__PURE__ */ new Set();
714
720
  const usage = { promptTokens: 0, completionTokens: 0, modelCalls: 0 };
715
721
  const reasoning = { deltas: 0, chars: 0 };
716
722
  const toolCalls = [];
@@ -811,8 +817,9 @@ async function runRouterTurn(options) {
811
817
  } else if (event.type === "tool_call_start") {
812
818
  emit({ type: "tool_start", toolName: byFunction.get(event.toolName)?.name ?? event.toolName });
813
819
  } else if (event.type === "tool_call") {
814
- segmentOpen = false;
815
820
  const tool = byFunction.get(event.call.toolName);
821
+ if (segmentOpen && narratesBefore(tool)) narrated.add(segments.length - 1);
822
+ segmentOpen = false;
816
823
  event.call.toolCallId ||= callIdOf(void 0, event.call.toolName);
817
824
  const callId = event.call.toolCallId;
818
825
  started.set(callId, Date.now());
@@ -861,16 +868,21 @@ async function runRouterTurn(options) {
861
868
  }
862
869
  return "completed";
863
870
  };
864
- const outcome = (failure) => ({
865
- text: joinText([options.continueFrom?.text ?? "", ...segments]),
866
- servedModel,
867
- toolCalls,
868
- usage: { ...usage },
869
- reasoning: { ...reasoning },
870
- toolEvents: [...toolEvents],
871
- ...placement ? { placement } : {},
872
- ...failure ? { failure } : {}
873
- });
871
+ const outcome = (failure) => {
872
+ const text = joinText([options.continueFrom?.text ?? "", ...segments]);
873
+ const answer = joinText(segments.filter((_segment, index) => !narrated.has(index)));
874
+ return {
875
+ text,
876
+ answer: answer || text,
877
+ servedModel,
878
+ toolCalls,
879
+ usage: { ...usage },
880
+ reasoning: { ...reasoning },
881
+ toolEvents: [...toolEvents],
882
+ ...placement ? { placement } : {},
883
+ ...failure ? { failure } : {}
884
+ };
885
+ };
874
886
  const repeat = options.repeat !== false;
875
887
  const repeats = !repeat ? [] : options.fallbackModels?.length ? [...options.fallbackModels] : [options.model];
876
888
  let stop;
@@ -978,6 +990,7 @@ export {
978
990
  DURABLE_HOP_BUDGET_MS,
979
991
  turnCheckpointPath,
980
992
  workspaceTurnCheckpoints,
993
+ narratesBefore,
981
994
  placeRouterTurn,
982
995
  routerFunctionName,
983
996
  perTurnPrefixBytes,
@@ -985,4 +998,4 @@ export {
985
998
  composeRouterTurnPrompt,
986
999
  runRouterTurn
987
1000
  };
988
- //# sourceMappingURL=chunk-PISTUUEZ.js.map
1001
+ //# sourceMappingURL=chunk-XCUT2I52.js.map