titan-agent 5.3.2 → 5.4.1

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 (48) hide show
  1. package/dist/agent/agent.js +11 -1
  2. package/dist/agent/agent.js.map +1 -1
  3. package/dist/agent/agentLoop.js +36 -1
  4. package/dist/agent/agentLoop.js.map +1 -1
  5. package/dist/agent/session.js +106 -5
  6. package/dist/agent/session.js.map +1 -1
  7. package/dist/agent/subAgent.js +62 -1
  8. package/dist/agent/subAgent.js.map +1 -1
  9. package/dist/config/config.js +30 -8
  10. package/dist/config/config.js.map +1 -1
  11. package/dist/config/schema.js +25 -2
  12. package/dist/config/schema.js.map +1 -1
  13. package/dist/gateway/server.js +32 -1
  14. package/dist/gateway/server.js.map +1 -1
  15. package/dist/memory/graph.js +49 -15
  16. package/dist/memory/graph.js.map +1 -1
  17. package/dist/memory/index.js +192 -0
  18. package/dist/memory/index.js.map +1 -0
  19. package/dist/memory/memory.js +1 -0
  20. package/dist/memory/memory.js.map +1 -1
  21. package/dist/mesh/transport.js +60 -8
  22. package/dist/mesh/transport.js.map +1 -1
  23. package/dist/providers/anthropic.js +3 -2
  24. package/dist/providers/anthropic.js.map +1 -1
  25. package/dist/providers/base.js.map +1 -1
  26. package/dist/providers/google.js +94 -20
  27. package/dist/providers/google.js.map +1 -1
  28. package/dist/providers/modelCapabilities.js +59 -0
  29. package/dist/providers/modelCapabilities.js.map +1 -0
  30. package/dist/providers/ollama.js +3 -2
  31. package/dist/providers/ollama.js.map +1 -1
  32. package/dist/providers/openai.js +4 -3
  33. package/dist/providers/openai.js.map +1 -1
  34. package/dist/providers/openai_compat.js +3 -2
  35. package/dist/providers/openai_compat.js.map +1 -1
  36. package/dist/providers/router.js +63 -21
  37. package/dist/providers/router.js.map +1 -1
  38. package/dist/safety/fabricationGuard.js +140 -0
  39. package/dist/safety/fabricationGuard.js.map +1 -0
  40. package/dist/skills/builtin/gepa.js +23 -1
  41. package/dist/skills/builtin/gepa.js.map +1 -1
  42. package/dist/skills/builtin/model_trainer.js +31 -4
  43. package/dist/skills/builtin/model_trainer.js.map +1 -1
  44. package/dist/skills/builtin/self_improve.js +50 -2
  45. package/dist/skills/builtin/self_improve.js.map +1 -1
  46. package/dist/utils/constants.js +2 -2
  47. package/dist/utils/constants.js.map +1 -1
  48. package/package.json +1 -1
@@ -26,6 +26,7 @@ async function chatWithTimeout(fn, label, timeoutMs = 3e5) {
26
26
  import { buildSmartContext } from "./contextManager.js";
27
27
  import { isKilled } from "../safety/killSwitch.js";
28
28
  import { estimateTokens } from "../utils/tokens.js";
29
+ import { DEFAULT_MAX_TOKENS } from "../utils/constants.js";
29
30
  import { getCachedResponse, setCachedResponse } from "./responseCache.js";
30
31
  import { shouldReflect, reflect, resetProgress, recordProgress, setProgressSession } from "./reflection.js";
31
32
  import { recordToolResult, classifyTaskType, recordToolPreference, getErrorResolution, recordErrorResolution } from "../memory/learning.js";
@@ -442,7 +443,7 @@ async function runAgentLoop(ctx) {
442
443
  let budgetWarningSent = false;
443
444
  let pendingToolCalls = [];
444
445
  let pendingAssistantContent = "";
445
- const tokenBudget = ctx.voiceFastPath ? 2e3 : ctx.config.agent.tokenBudget || 12e3;
446
+ const tokenBudget = ctx.voiceFastPath ? 2e3 : ctx.config.agent.tokenBudget || DEFAULT_MAX_TOKENS;
446
447
  globalSteerQueues.set(ctx.sessionId, ctx.steerQueue ?? []);
447
448
  const traceCtx = newTraceContext();
448
449
  initOtel();
@@ -663,6 +664,23 @@ Try a COMPLETELY DIFFERENT strategy. Do NOT repeat the same tools or approach.`
663
664
  ctx.streamCallbacks.onToolCall?.(chunk.toolCall.function.name, JSON.parse(chunk.toolCall.function.arguments || "{}"));
664
665
  } else if (chunk.type === "error") {
665
666
  logger.error(COMPONENT, `Stream error: ${chunk.error}`);
667
+ } else if (chunk.type === "retry") {
668
+ logger.warn(COMPONENT, `Stream retrying ${chunk.provider}/${chunk.model} (attempt ${chunk.attempt}/${chunk.maxRetries}, reason=${chunk.reason}, delay=${chunk.delayMs}ms)`);
669
+ ctx.streamCallbacks.onRetry?.({
670
+ attempt: chunk.attempt,
671
+ maxRetries: chunk.maxRetries,
672
+ reason: chunk.reason,
673
+ provider: chunk.provider,
674
+ model: chunk.model,
675
+ delayMs: chunk.delayMs
676
+ });
677
+ } else if (chunk.type === "failover") {
678
+ logger.warn(COMPONENT, `Stream failover from ${chunk.originalProvider}/${chunk.originalModel}${chunk.error ? ` (${chunk.error})` : ""}`);
679
+ ctx.streamCallbacks.onFailover?.({
680
+ originalProvider: chunk.originalProvider,
681
+ originalModel: chunk.originalModel,
682
+ error: chunk.error
683
+ });
666
684
  }
667
685
  }
668
686
  const estCompletionTokens = estimateTokens(streamContent + JSON.stringify(streamToolCalls));
@@ -1423,6 +1441,23 @@ Examples: use read_file instead of cat/head/tail/grep, and edit_file instead of
1423
1441
  ctx.streamCallbacks.onToken(chunk.content);
1424
1442
  } else if (chunk.type === "error") {
1425
1443
  logger.error(COMPONENT, `Stream error: ${chunk.error}`);
1444
+ } else if (chunk.type === "retry") {
1445
+ logger.warn(COMPONENT, `Respond-phase stream retrying ${chunk.provider}/${chunk.model} (attempt ${chunk.attempt}/${chunk.maxRetries}, reason=${chunk.reason})`);
1446
+ ctx.streamCallbacks.onRetry?.({
1447
+ attempt: chunk.attempt,
1448
+ maxRetries: chunk.maxRetries,
1449
+ reason: chunk.reason,
1450
+ provider: chunk.provider,
1451
+ model: chunk.model,
1452
+ delayMs: chunk.delayMs
1453
+ });
1454
+ } else if (chunk.type === "failover") {
1455
+ logger.warn(COMPONENT, `Respond-phase stream failover from ${chunk.originalProvider}/${chunk.originalModel}`);
1456
+ ctx.streamCallbacks.onFailover?.({
1457
+ originalProvider: chunk.originalProvider,
1458
+ originalModel: chunk.originalModel,
1459
+ error: chunk.error
1460
+ });
1426
1461
  }
1427
1462
  }
1428
1463
  response = {