@everworker/oneringai 0.4.0 → 0.4.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.
package/dist/index.js CHANGED
@@ -11911,6 +11911,9 @@ var ToolManager = class extends EventEmitter {
11911
11911
  }
11912
11912
  };
11913
11913
 
11914
+ // src/core/context-nextgen/AgentContextNextGen.ts
11915
+ init_Logger();
11916
+
11914
11917
  // src/core/Vendor.ts
11915
11918
  var Vendor = {
11916
11919
  OpenAI: "openai",
@@ -13284,6 +13287,7 @@ var ContentType = /* @__PURE__ */ ((ContentType2) => {
13284
13287
  ContentType2["OUTPUT_TEXT"] = "output_text";
13285
13288
  ContentType2["TOOL_USE"] = "tool_use";
13286
13289
  ContentType2["TOOL_RESULT"] = "tool_result";
13290
+ ContentType2["THINKING"] = "thinking";
13287
13291
  return ContentType2;
13288
13292
  })(ContentType || {});
13289
13293
 
@@ -13546,6 +13550,11 @@ var BasePluginNextGen = class {
13546
13550
  }
13547
13551
  };
13548
13552
 
13553
+ // src/core/context-nextgen/snapshot.ts
13554
+ function formatPluginDisplayName(name) {
13555
+ return name.split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
13556
+ }
13557
+
13549
13558
  // src/core/context-nextgen/AgentContextNextGen.ts
13550
13559
  init_Connector();
13551
13560
 
@@ -14473,7 +14482,7 @@ var PRIORITY_VALUES = {
14473
14482
  };
14474
14483
  var DEFAULT_CONFIG = {
14475
14484
  maxEntries: 20,
14476
- maxTotalTokens: 4e3,
14485
+ maxTotalTokens: 4e4,
14477
14486
  defaultPriority: "normal",
14478
14487
  showTimestamps: false
14479
14488
  };
@@ -16224,8 +16233,11 @@ var AlgorithmicCompactionStrategy = class {
16224
16233
  * Emergency compaction when context exceeds threshold.
16225
16234
  *
16226
16235
  * Strategy:
16227
- * 1. Run consolidate() first to move tool results to memory
16236
+ * 1. Run consolidate() first to move tool results to memory (if working memory available)
16228
16237
  * 2. If still need space, apply rolling window (remove oldest messages)
16238
+ *
16239
+ * Gracefully degrades: if working memory plugin is not registered,
16240
+ * skips step 1 and only uses rolling window compaction.
16229
16241
  */
16230
16242
  async compact(context, targetToFree) {
16231
16243
  const log = [];
@@ -16238,7 +16250,7 @@ var AlgorithmicCompactionStrategy = class {
16238
16250
  tokensFreed += Math.abs(consolidateResult.tokensChanged);
16239
16251
  log.push(...consolidateResult.actions);
16240
16252
  }
16241
- let remaining = targetToFree - tokensFreed;
16253
+ const remaining = targetToFree - tokensFreed;
16242
16254
  if (remaining > 0 && context.conversation.length > 0) {
16243
16255
  log.push(`Rolling window: need to free ~${remaining} more tokens`);
16244
16256
  const result = await this.applyRollingWindow(context, remaining, log);
@@ -16252,8 +16264,11 @@ var AlgorithmicCompactionStrategy = class {
16252
16264
  * Post-cycle consolidation.
16253
16265
  *
16254
16266
  * 1. Find all tool pairs in conversation
16255
- * 2. Move large tool results (> threshold) to Working Memory
16267
+ * 2. Move large tool results (> threshold) to Working Memory (if available)
16256
16268
  * 3. Limit remaining tool pairs to maxToolPairs
16269
+ *
16270
+ * Gracefully degrades: if working memory is not available, skips step 2
16271
+ * and only limits tool pairs + removes excess via rolling window.
16257
16272
  */
16258
16273
  async consolidate(context) {
16259
16274
  const log = [];
@@ -16264,23 +16279,25 @@ var AlgorithmicCompactionStrategy = class {
16264
16279
  return { performed: false, tokensChanged: 0, actions: [] };
16265
16280
  }
16266
16281
  const indicesToRemove = [];
16267
- for (const pair of toolPairs) {
16268
- if (pair.resultSizeBytes > this.toolResultSizeThreshold) {
16269
- const key = this.generateKey(pair.toolName, pair.toolUseId);
16270
- const desc = this.generateDescription(pair.toolName, pair.toolArgs);
16271
- await memory.store(key, desc, pair.resultContent, {
16272
- tier: "raw",
16273
- priority: "normal"
16274
- });
16275
- if (!indicesToRemove.includes(pair.toolUseIndex)) {
16276
- indicesToRemove.push(pair.toolUseIndex);
16277
- }
16278
- if (!indicesToRemove.includes(pair.toolResultIndex)) {
16279
- indicesToRemove.push(pair.toolResultIndex);
16282
+ if (memory) {
16283
+ for (const pair of toolPairs) {
16284
+ if (pair.resultSizeBytes > this.toolResultSizeThreshold) {
16285
+ const key = this.generateKey(pair.toolName, pair.toolUseId);
16286
+ const desc = this.generateDescription(pair.toolName, pair.toolArgs);
16287
+ await memory.store(key, desc, pair.resultContent, {
16288
+ tier: "raw",
16289
+ priority: "normal"
16290
+ });
16291
+ if (!indicesToRemove.includes(pair.toolUseIndex)) {
16292
+ indicesToRemove.push(pair.toolUseIndex);
16293
+ }
16294
+ if (!indicesToRemove.includes(pair.toolResultIndex)) {
16295
+ indicesToRemove.push(pair.toolResultIndex);
16296
+ }
16297
+ log.push(
16298
+ `Moved ${pair.toolName} result (${this.formatBytes(pair.resultSizeBytes)}) to memory: ${key}`
16299
+ );
16280
16300
  }
16281
- log.push(
16282
- `Moved ${pair.toolName} result (${this.formatBytes(pair.resultSizeBytes)}) to memory: ${key}`
16283
- );
16284
16301
  }
16285
16302
  }
16286
16303
  const remainingPairs = toolPairs.filter(
@@ -16309,15 +16326,12 @@ var AlgorithmicCompactionStrategy = class {
16309
16326
  };
16310
16327
  }
16311
16328
  /**
16312
- * Get the Working Memory plugin from context.
16313
- * @throws Error if plugin is not available
16329
+ * Get the Working Memory plugin from context, or null if not available.
16330
+ * When null, the strategy degrades gracefully (skips memory operations).
16314
16331
  */
16315
16332
  getWorkingMemory(context) {
16316
16333
  const plugin = context.plugins.find((p) => p.name === "working_memory");
16317
- if (!plugin) {
16318
- throw new Error("AlgorithmicCompactionStrategy requires working_memory plugin");
16319
- }
16320
- return plugin;
16334
+ return plugin ? plugin : null;
16321
16335
  }
16322
16336
  /**
16323
16337
  * Find all tool_use/tool_result pairs in conversation.
@@ -16658,7 +16672,7 @@ var StrategyRegistry = class {
16658
16672
  // src/core/context-nextgen/types.ts
16659
16673
  var DEFAULT_FEATURES = {
16660
16674
  workingMemory: true,
16661
- inContextMemory: false,
16675
+ inContextMemory: true,
16662
16676
  persistentInstructions: false,
16663
16677
  userInfo: false
16664
16678
  };
@@ -16702,6 +16716,8 @@ var AgentContextNextGen = class _AgentContextNextGen extends EventEmitter {
16702
16716
  _storage;
16703
16717
  /** Destroyed flag */
16704
16718
  _destroyed = false;
16719
+ /** Last thinking/reasoning content from the most recent assistant response */
16720
+ _lastThinking = null;
16705
16721
  /** Cached budget from last prepare() call */
16706
16722
  _cachedBudget = null;
16707
16723
  /** Callback for beforeCompaction hook (set by Agent) */
@@ -16789,15 +16805,16 @@ var AgentContextNextGen = class _AgentContextNextGen extends EventEmitter {
16789
16805
  }
16790
16806
  /**
16791
16807
  * Validate that a strategy's required plugins are registered.
16792
- * @throws Error if any required plugin is missing
16808
+ * Logs a warning if required plugins are missing — the strategy should degrade gracefully.
16793
16809
  */
16794
16810
  validateStrategyDependencies(strategy) {
16795
16811
  if (!strategy.requiredPlugins?.length) return;
16796
16812
  const availablePlugins = new Set(this._plugins.keys());
16797
16813
  const missing = strategy.requiredPlugins.filter((name) => !availablePlugins.has(name));
16798
16814
  if (missing.length > 0) {
16799
- throw new Error(
16800
- `Strategy '${strategy.name}' requires plugins that are not registered: ${missing.join(", ")}. Available plugins: ${Array.from(availablePlugins).join(", ") || "none"}`
16815
+ logger.warn(
16816
+ { strategy: strategy.name, missing, available: Array.from(availablePlugins) },
16817
+ `Strategy '${strategy.name}' recommends plugins that are not registered: ${missing.join(", ")}. Strategy will degrade gracefully.`
16801
16818
  );
16802
16819
  }
16803
16820
  }
@@ -16913,6 +16930,13 @@ var AgentContextNextGen = class _AgentContextNextGen extends EventEmitter {
16913
16930
  get storage() {
16914
16931
  return this._storage ?? null;
16915
16932
  }
16933
+ /**
16934
+ * Get the last thinking/reasoning content from the most recent assistant response.
16935
+ * Updated on every assistant response, always available regardless of persistence setting.
16936
+ */
16937
+ get lastThinking() {
16938
+ return this._lastThinking;
16939
+ }
16916
16940
  /** Get max context tokens */
16917
16941
  get maxContextTokens() {
16918
16942
  return this._maxContextTokens;
@@ -17094,6 +17118,7 @@ var AgentContextNextGen = class _AgentContextNextGen extends EventEmitter {
17094
17118
  }
17095
17119
  const id = this.generateId();
17096
17120
  const contentArray = [];
17121
+ let thinkingText = null;
17097
17122
  for (const item of output) {
17098
17123
  if (item.type === "message" && "content" in item) {
17099
17124
  const msg = item;
@@ -17105,12 +17130,19 @@ var AgentContextNextGen = class _AgentContextNextGen extends EventEmitter {
17105
17130
  });
17106
17131
  } else if (c.type === "tool_use" /* TOOL_USE */) {
17107
17132
  contentArray.push(c);
17133
+ } else if (c.type === "thinking" /* THINKING */) {
17134
+ const thinking = c;
17135
+ thinkingText = thinking.thinking;
17136
+ if (thinking.persistInHistory) {
17137
+ contentArray.push(c);
17138
+ }
17108
17139
  }
17109
17140
  }
17110
17141
  } else if (item.type === "compaction" || item.type === "reasoning") {
17111
17142
  continue;
17112
17143
  }
17113
17144
  }
17145
+ this._lastThinking = thinkingText;
17114
17146
  if (contentArray.length > 0) {
17115
17147
  const message = {
17116
17148
  type: "message",
@@ -17209,6 +17241,7 @@ var AgentContextNextGen = class _AgentContextNextGen extends EventEmitter {
17209
17241
  */
17210
17242
  async prepare() {
17211
17243
  this.assertNotDestroyed();
17244
+ this._lastThinking = null;
17212
17245
  const compactionLog = [];
17213
17246
  const toolsTokens = this.calculateToolsTokens();
17214
17247
  const availableForContent = this._maxContextTokens - this._config.responseReserve - toolsTokens;
@@ -17421,6 +17454,8 @@ ${content}`);
17421
17454
  total += this._estimateImageTokens();
17422
17455
  }
17423
17456
  }
17457
+ } else if (c.type === "thinking" /* THINKING */) {
17458
+ total += this._estimator.estimateTokens(c.thinking || "");
17424
17459
  } else if (c.type === "input_image_url" /* INPUT_IMAGE_URL */) {
17425
17460
  const imgContent = c;
17426
17461
  const detail = imgContent.image_url?.detail;
@@ -17918,6 +17953,188 @@ ${content}`);
17918
17953
  get strategy() {
17919
17954
  return this._compactionStrategy.name;
17920
17955
  }
17956
+ /**
17957
+ * Get a complete, serializable snapshot of the context state.
17958
+ *
17959
+ * Returns all data needed by UI "Look Inside" panels without reaching
17960
+ * into plugin internals. Plugin data is auto-discovered from the plugin
17961
+ * registry — new/custom plugins appear automatically.
17962
+ *
17963
+ * @param toolStats - Optional tool usage stats (from ToolManager.getStats())
17964
+ * @returns Serializable context snapshot
17965
+ */
17966
+ async getSnapshot(toolStats) {
17967
+ const resolveContents = async (raw) => {
17968
+ const resolved = raw instanceof Promise ? await raw : raw;
17969
+ if (resolved instanceof Map) return Array.from(resolved.values());
17970
+ return resolved;
17971
+ };
17972
+ if (this._destroyed) {
17973
+ const emptyBudget = this._cachedBudget ?? {
17974
+ maxTokens: this._maxContextTokens,
17975
+ responseReserve: this._config.responseReserve,
17976
+ systemMessageTokens: 0,
17977
+ toolsTokens: 0,
17978
+ conversationTokens: 0,
17979
+ currentInputTokens: 0,
17980
+ totalUsed: 0,
17981
+ available: this._maxContextTokens - this._config.responseReserve,
17982
+ utilizationPercent: 0,
17983
+ breakdown: {
17984
+ systemPrompt: 0,
17985
+ persistentInstructions: 0,
17986
+ pluginInstructions: 0,
17987
+ pluginContents: {},
17988
+ tools: 0,
17989
+ conversation: 0,
17990
+ currentInput: 0
17991
+ }
17992
+ };
17993
+ return {
17994
+ available: false,
17995
+ agentId: this._agentId,
17996
+ model: this._config.model,
17997
+ features: this._config.features,
17998
+ budget: emptyBudget,
17999
+ strategy: this._compactionStrategy.name,
18000
+ messagesCount: 0,
18001
+ toolCallsCount: 0,
18002
+ systemPrompt: null,
18003
+ plugins: [],
18004
+ tools: []
18005
+ };
18006
+ }
18007
+ const budget = await this.calculateBudget();
18008
+ const plugins = [];
18009
+ for (const plugin of this._plugins.values()) {
18010
+ let formattedContent = null;
18011
+ try {
18012
+ formattedContent = await plugin.getContent();
18013
+ } catch {
18014
+ }
18015
+ plugins.push({
18016
+ name: plugin.name,
18017
+ displayName: formatPluginDisplayName(plugin.name),
18018
+ enabled: true,
18019
+ tokenSize: plugin.getTokenSize(),
18020
+ instructionsTokenSize: plugin.getInstructionsTokenSize(),
18021
+ compactable: plugin.isCompactable(),
18022
+ contents: await resolveContents(plugin.getContents()),
18023
+ formattedContent
18024
+ });
18025
+ }
18026
+ const usageCounts = /* @__PURE__ */ new Map();
18027
+ if (toolStats?.mostUsed) {
18028
+ for (const { name, count } of toolStats.mostUsed) {
18029
+ usageCounts.set(name, count);
18030
+ }
18031
+ }
18032
+ const tools = [];
18033
+ for (const toolName of this._tools.list()) {
18034
+ const reg = this._tools.getRegistration(toolName);
18035
+ if (!reg) continue;
18036
+ tools.push({
18037
+ name: toolName,
18038
+ description: reg.tool.definition.function.description || "",
18039
+ enabled: reg.enabled,
18040
+ callCount: reg.metadata.usageCount ?? usageCounts.get(toolName) ?? 0,
18041
+ namespace: reg.namespace || void 0
18042
+ });
18043
+ }
18044
+ let toolCallsCount = 0;
18045
+ for (const item of this._conversation) {
18046
+ if (item.type === "message" && item.role === "assistant" /* ASSISTANT */) {
18047
+ for (const c of item.content) {
18048
+ if (c.type === "tool_use" /* TOOL_USE */) toolCallsCount++;
18049
+ }
18050
+ }
18051
+ }
18052
+ return {
18053
+ available: true,
18054
+ agentId: this._agentId,
18055
+ model: this._config.model,
18056
+ features: this._config.features,
18057
+ budget,
18058
+ strategy: this._compactionStrategy.name,
18059
+ messagesCount: this._conversation.length,
18060
+ toolCallsCount,
18061
+ systemPrompt: this._systemPrompt ?? null,
18062
+ plugins,
18063
+ tools
18064
+ };
18065
+ }
18066
+ /**
18067
+ * Get a human-readable breakdown of the prepared context.
18068
+ *
18069
+ * Calls `prepare()` internally, then maps each InputItem to a named
18070
+ * component with content text and token estimate. Used by "View Full Context" UIs.
18071
+ *
18072
+ * @returns View context data with components and raw text for "Copy All"
18073
+ */
18074
+ async getViewContext() {
18075
+ if (this._destroyed) {
18076
+ return { available: false, components: [], totalTokens: 0, rawContext: "" };
18077
+ }
18078
+ const { input, budget } = await this.prepare();
18079
+ const components = [];
18080
+ let rawParts = [];
18081
+ for (const item of input) {
18082
+ if (item.type === "compaction") {
18083
+ components.push({
18084
+ name: "Compaction Block",
18085
+ content: "[Compacted content]",
18086
+ tokenEstimate: 0
18087
+ });
18088
+ continue;
18089
+ }
18090
+ const msg = item;
18091
+ const roleName = msg.role === "developer" /* DEVELOPER */ ? "System Message" : msg.role === "user" /* USER */ ? "User Message" : "Assistant Message";
18092
+ for (const block of msg.content) {
18093
+ let name = roleName;
18094
+ let text = "";
18095
+ switch (block.type) {
18096
+ case "input_text" /* INPUT_TEXT */:
18097
+ text = block.text;
18098
+ break;
18099
+ case "output_text" /* OUTPUT_TEXT */:
18100
+ text = block.text;
18101
+ break;
18102
+ case "tool_use" /* TOOL_USE */:
18103
+ name = `Tool Call: ${block.name}`;
18104
+ text = `${block.name}(${block.arguments})`;
18105
+ break;
18106
+ case "tool_result" /* TOOL_RESULT */:
18107
+ name = `Tool Result: ${block.tool_use_id}`;
18108
+ text = typeof block.content === "string" ? block.content : JSON.stringify(block.content, null, 2);
18109
+ if (block.error) text = `[Error] ${block.error}
18110
+ ${text}`;
18111
+ break;
18112
+ case "input_image_url" /* INPUT_IMAGE_URL */:
18113
+ name = "Image Input";
18114
+ text = `[Image: ${block.image_url.url.substring(0, 100)}...]`;
18115
+ break;
18116
+ case "input_file" /* INPUT_FILE */:
18117
+ name = "File Input";
18118
+ text = `[File: ${block.file_id}]`;
18119
+ break;
18120
+ case "thinking" /* THINKING */:
18121
+ name = "Thinking";
18122
+ text = block.thinking || "";
18123
+ break;
18124
+ }
18125
+ const tokenEstimate = this._estimator.estimateTokens(text);
18126
+ components.push({ name, content: text, tokenEstimate });
18127
+ rawParts.push(`--- ${name} ---
18128
+ ${text}`);
18129
+ }
18130
+ }
18131
+ return {
18132
+ available: true,
18133
+ components,
18134
+ totalTokens: budget.totalUsed,
18135
+ rawContext: rawParts.join("\n\n")
18136
+ };
18137
+ }
17921
18138
  // ============================================================================
17922
18139
  // Utilities
17923
18140
  // ============================================================================
@@ -18176,6 +18393,13 @@ var BaseTextProvider = class extends BaseProvider {
18176
18393
  }
18177
18394
  return textParts.join("\n");
18178
18395
  }
18396
+ /**
18397
+ * List available models from the provider's API.
18398
+ * Default returns empty array; providers override when they have SDK support.
18399
+ */
18400
+ async listModels() {
18401
+ return [];
18402
+ }
18179
18403
  /**
18180
18404
  * Clean up provider resources (circuit breaker listeners, etc.)
18181
18405
  * Should be called when the provider is no longer needed.
@@ -18328,12 +18552,21 @@ var OpenAIResponsesConverter = class {
18328
18552
  } else if (item.type === "reasoning") {
18329
18553
  const reasoning = item;
18330
18554
  if (reasoning.summary) {
18331
- content.push({
18332
- type: "reasoning",
18333
- summary: reasoning.summary,
18334
- // effort field may not exist in all versions
18335
- ..."effort" in reasoning && { effort: reasoning.effort }
18336
- });
18555
+ let summaryText;
18556
+ if (typeof reasoning.summary === "string") {
18557
+ summaryText = reasoning.summary;
18558
+ } else if (Array.isArray(reasoning.summary)) {
18559
+ summaryText = reasoning.summary.map((s) => s.text || "").filter(Boolean).join("\n");
18560
+ } else {
18561
+ summaryText = "";
18562
+ }
18563
+ if (summaryText) {
18564
+ content.push({
18565
+ type: "thinking" /* THINKING */,
18566
+ thinking: summaryText,
18567
+ persistInHistory: false
18568
+ });
18569
+ }
18337
18570
  }
18338
18571
  }
18339
18572
  }
@@ -18356,10 +18589,20 @@ var OpenAIResponsesConverter = class {
18356
18589
  }
18357
18590
  ],
18358
18591
  output_text: outputText,
18592
+ // Extract thinking text from content for convenience field
18593
+ ...(() => {
18594
+ const thinkingTexts = content.filter((c) => c.type === "thinking" /* THINKING */).map((c) => c.thinking).filter(Boolean);
18595
+ return thinkingTexts.length > 0 ? { thinking: thinkingTexts.join("\n") } : {};
18596
+ })(),
18359
18597
  usage: {
18360
18598
  input_tokens: response.usage?.input_tokens || 0,
18361
18599
  output_tokens: response.usage?.output_tokens || 0,
18362
- total_tokens: response.usage?.total_tokens || 0
18600
+ total_tokens: response.usage?.total_tokens || 0,
18601
+ ...response.usage?.output_tokens_details?.reasoning_tokens != null && {
18602
+ output_tokens_details: {
18603
+ reasoning_tokens: response.usage.output_tokens_details.reasoning_tokens
18604
+ }
18605
+ }
18363
18606
  }
18364
18607
  };
18365
18608
  }
@@ -18464,6 +18707,8 @@ var StreamEventType = /* @__PURE__ */ ((StreamEventType2) => {
18464
18707
  StreamEventType2["TOOL_EXECUTION_START"] = "response.tool_execution.start";
18465
18708
  StreamEventType2["TOOL_EXECUTION_DONE"] = "response.tool_execution.done";
18466
18709
  StreamEventType2["ITERATION_COMPLETE"] = "response.iteration.complete";
18710
+ StreamEventType2["REASONING_DELTA"] = "response.reasoning.delta";
18711
+ StreamEventType2["REASONING_DONE"] = "response.reasoning.done";
18467
18712
  StreamEventType2["RESPONSE_COMPLETE"] = "response.complete";
18468
18713
  StreamEventType2["ERROR"] = "response.error";
18469
18714
  return StreamEventType2;
@@ -18483,6 +18728,12 @@ function isToolCallArgumentsDelta(event) {
18483
18728
  function isToolCallArgumentsDone(event) {
18484
18729
  return event.type === "response.tool_call_arguments.done" /* TOOL_CALL_ARGUMENTS_DONE */;
18485
18730
  }
18731
+ function isReasoningDelta(event) {
18732
+ return event.type === "response.reasoning.delta" /* REASONING_DELTA */;
18733
+ }
18734
+ function isReasoningDone(event) {
18735
+ return event.type === "response.reasoning.done" /* REASONING_DONE */;
18736
+ }
18486
18737
  function isResponseComplete(event) {
18487
18738
  return event.type === "response.complete" /* RESPONSE_COMPLETE */;
18488
18739
  }
@@ -18500,6 +18751,8 @@ var OpenAIResponsesStreamConverter = class {
18500
18751
  let sequenceNumber = 0;
18501
18752
  const activeItems = /* @__PURE__ */ new Map();
18502
18753
  const toolCallBuffers = /* @__PURE__ */ new Map();
18754
+ const reasoningBuffers = /* @__PURE__ */ new Map();
18755
+ const reasoningDoneEmitted = /* @__PURE__ */ new Set();
18503
18756
  for await (const event of stream) {
18504
18757
  if (process.env.DEBUG_OPENAI) {
18505
18758
  console.error("[DEBUG] Responses API event:", event.type);
@@ -18521,6 +18774,12 @@ var OpenAIResponsesStreamConverter = class {
18521
18774
  activeItems.set(addedEvent.output_index.toString(), {
18522
18775
  type: item.type
18523
18776
  });
18777
+ if (item.type === "reasoning") {
18778
+ activeItems.set(addedEvent.output_index.toString(), {
18779
+ type: "reasoning"
18780
+ });
18781
+ reasoningBuffers.set(addedEvent.output_index.toString(), []);
18782
+ }
18524
18783
  if (item.type === "function_call") {
18525
18784
  const functionCall = item;
18526
18785
  const toolCallId = functionCall.call_id;
@@ -18578,9 +18837,53 @@ var OpenAIResponsesStreamConverter = class {
18578
18837
  }
18579
18838
  break;
18580
18839
  }
18840
+ case "response.reasoning_summary_text.delta":
18841
+ case "response.reasoning_text.delta": {
18842
+ const reasoningEvent = event;
18843
+ const outputIdx = reasoningEvent.output_index?.toString();
18844
+ const buffer = outputIdx ? reasoningBuffers.get(outputIdx) : void 0;
18845
+ if (buffer) {
18846
+ buffer.push(reasoningEvent.delta || "");
18847
+ }
18848
+ yield {
18849
+ type: "response.reasoning.delta" /* REASONING_DELTA */,
18850
+ response_id: responseId,
18851
+ item_id: reasoningEvent.item_id || `reasoning_${responseId}`,
18852
+ delta: reasoningEvent.delta || "",
18853
+ sequence_number: sequenceNumber++
18854
+ };
18855
+ break;
18856
+ }
18857
+ case "response.reasoning_text.done": {
18858
+ const doneEvent = event;
18859
+ const outputIdx = doneEvent.output_index.toString();
18860
+ const rBuf = reasoningBuffers.get(outputIdx);
18861
+ const thinkingText = rBuf ? rBuf.join("") : doneEvent.text || "";
18862
+ reasoningDoneEmitted.add(outputIdx);
18863
+ yield {
18864
+ type: "response.reasoning.done" /* REASONING_DONE */,
18865
+ response_id: responseId,
18866
+ item_id: doneEvent.item_id || `reasoning_${responseId}`,
18867
+ thinking: thinkingText
18868
+ };
18869
+ break;
18870
+ }
18581
18871
  case "response.output_item.done": {
18582
18872
  const doneEvent = event;
18583
18873
  const item = doneEvent.item;
18874
+ if (item.type === "reasoning") {
18875
+ const outputIdx = doneEvent.output_index.toString();
18876
+ if (!reasoningDoneEmitted.has(outputIdx)) {
18877
+ const rBuf = reasoningBuffers.get(outputIdx);
18878
+ const thinkingText = rBuf ? rBuf.join("") : "";
18879
+ yield {
18880
+ type: "response.reasoning.done" /* REASONING_DONE */,
18881
+ response_id: responseId,
18882
+ item_id: item.id || `reasoning_${responseId}`,
18883
+ thinking: thinkingText
18884
+ };
18885
+ }
18886
+ }
18584
18887
  if (item.type === "function_call") {
18585
18888
  const functionCall = item;
18586
18889
  const buffer = toolCallBuffers.get(functionCall.call_id);
@@ -18612,7 +18915,12 @@ var OpenAIResponsesStreamConverter = class {
18612
18915
  usage: {
18613
18916
  input_tokens: response.usage?.input_tokens || 0,
18614
18917
  output_tokens: response.usage?.output_tokens || 0,
18615
- total_tokens: response.usage?.total_tokens || 0
18918
+ total_tokens: response.usage?.total_tokens || 0,
18919
+ ...response.usage?.output_tokens_details?.reasoning_tokens != null && {
18920
+ output_tokens_details: {
18921
+ reasoning_tokens: response.usage.output_tokens_details.reasoning_tokens
18922
+ }
18923
+ }
18616
18924
  },
18617
18925
  iterations: 1
18618
18926
  };
@@ -18653,6 +18961,26 @@ function resolveMaxContextTokens(model, fallback) {
18653
18961
  return info ? info.features.input.tokens : fallback;
18654
18962
  }
18655
18963
 
18964
+ // src/infrastructure/providers/shared/validateThinkingConfig.ts
18965
+ function validateThinkingConfig(thinking) {
18966
+ if (!thinking.enabled) return;
18967
+ if (thinking.budgetTokens !== void 0) {
18968
+ if (typeof thinking.budgetTokens !== "number" || thinking.budgetTokens < 1) {
18969
+ throw new Error(
18970
+ `Invalid thinking budgetTokens: ${thinking.budgetTokens}. Must be a positive number.`
18971
+ );
18972
+ }
18973
+ }
18974
+ if (thinking.effort !== void 0) {
18975
+ const validEfforts = ["low", "medium", "high"];
18976
+ if (!validEfforts.includes(thinking.effort)) {
18977
+ throw new Error(
18978
+ `Invalid thinking effort: '${thinking.effort}'. Must be one of: ${validEfforts.join(", ")}`
18979
+ );
18980
+ }
18981
+ }
18982
+ }
18983
+
18656
18984
  // src/infrastructure/providers/openai/OpenAITextProvider.ts
18657
18985
  var OpenAITextProvider = class extends BaseTextProvider {
18658
18986
  name = "openai";
@@ -18720,6 +19048,7 @@ var OpenAITextProvider = class extends BaseTextProvider {
18720
19048
  },
18721
19049
  ...options.metadata && { metadata: options.metadata }
18722
19050
  };
19051
+ this.applyReasoningConfig(params, options);
18723
19052
  const response = await this.client.responses.create(params);
18724
19053
  return this.converter.convertResponse(response);
18725
19054
  } catch (error) {
@@ -18761,6 +19090,7 @@ var OpenAITextProvider = class extends BaseTextProvider {
18761
19090
  ...options.metadata && { metadata: options.metadata },
18762
19091
  stream: true
18763
19092
  };
19093
+ this.applyReasoningConfig(params, options);
18764
19094
  const stream = await this.client.responses.create(params);
18765
19095
  yield* this.streamConverter.convertStream(stream);
18766
19096
  } catch (error) {
@@ -18782,6 +19112,27 @@ var OpenAITextProvider = class extends BaseTextProvider {
18782
19112
  maxOutputTokens: 16384
18783
19113
  });
18784
19114
  }
19115
+ /**
19116
+ * List available models from the OpenAI API
19117
+ */
19118
+ async listModels() {
19119
+ const models = [];
19120
+ for await (const model of this.client.models.list()) {
19121
+ models.push(model.id);
19122
+ }
19123
+ return models.sort();
19124
+ }
19125
+ /**
19126
+ * Apply reasoning config from unified thinking option to request params
19127
+ */
19128
+ applyReasoningConfig(params, options) {
19129
+ if (options.thinking?.enabled) {
19130
+ validateThinkingConfig(options.thinking);
19131
+ params.reasoning = {
19132
+ effort: options.thinking.effort || "medium"
19133
+ };
19134
+ }
19135
+ }
18785
19136
  /**
18786
19137
  * Handle OpenAI-specific errors
18787
19138
  */
@@ -18824,6 +19175,7 @@ function buildLLMResponse(options) {
18824
19175
  }
18825
19176
  ];
18826
19177
  const outputText = extractTextFromContent(content);
19178
+ const thinking = extractThinkingFromContent(content);
18827
19179
  return {
18828
19180
  id: responseId,
18829
19181
  object: "response",
@@ -18832,6 +19184,7 @@ function buildLLMResponse(options) {
18832
19184
  model,
18833
19185
  output,
18834
19186
  output_text: outputText,
19187
+ ...thinking && { thinking },
18835
19188
  usage: {
18836
19189
  input_tokens: usage.inputTokens,
18837
19190
  output_tokens: usage.outputTokens,
@@ -18844,6 +19197,10 @@ function extractTextFromContent(content) {
18844
19197
  (c) => c.type === "output_text" /* OUTPUT_TEXT */
18845
19198
  ).map((c) => c.text).join("\n");
18846
19199
  }
19200
+ function extractThinkingFromContent(content) {
19201
+ const thinkingTexts = content.filter((c) => c.type === "thinking" /* THINKING */).map((c) => c.thinking).filter(Boolean);
19202
+ return thinkingTexts.length > 0 ? thinkingTexts.join("\n") : void 0;
19203
+ }
18847
19204
  function createTextContent(text) {
18848
19205
  return {
18849
19206
  type: "output_text" /* OUTPUT_TEXT */,
@@ -19093,7 +19450,15 @@ var AnthropicConverter = class extends BaseConverter {
19093
19450
  if (tools && tools.length > 0) {
19094
19451
  params.tools = tools;
19095
19452
  }
19096
- if (options.temperature !== void 0) {
19453
+ if (options.thinking?.enabled) {
19454
+ validateThinkingConfig(options.thinking);
19455
+ const budgetTokens = options.thinking.budgetTokens || 1e4;
19456
+ params.thinking = {
19457
+ type: "enabled",
19458
+ budget_tokens: budgetTokens
19459
+ };
19460
+ params.temperature = 1;
19461
+ } else if (options.temperature !== void 0) {
19097
19462
  params.temperature = options.temperature;
19098
19463
  }
19099
19464
  return params;
@@ -19139,6 +19504,14 @@ var AnthropicConverter = class extends BaseConverter {
19139
19504
  content.push(this.createText(block.text));
19140
19505
  } else if (block.type === "tool_use") {
19141
19506
  content.push(this.createToolUse(block.id, block.name, block.input));
19507
+ } else if (block.type === "thinking") {
19508
+ const thinkingBlock = block;
19509
+ content.push({
19510
+ type: "thinking" /* THINKING */,
19511
+ thinking: thinkingBlock.thinking || "",
19512
+ signature: thinkingBlock.signature,
19513
+ persistInHistory: true
19514
+ });
19142
19515
  }
19143
19516
  }
19144
19517
  return content;
@@ -19217,6 +19590,17 @@ var AnthropicConverter = class extends BaseConverter {
19217
19590
  });
19218
19591
  break;
19219
19592
  }
19593
+ case "thinking" /* THINKING */: {
19594
+ const thinkingContent = c;
19595
+ if (thinkingContent.signature) {
19596
+ blocks.push({
19597
+ type: "thinking",
19598
+ thinking: thinkingContent.thinking,
19599
+ signature: thinkingContent.signature
19600
+ });
19601
+ }
19602
+ break;
19603
+ }
19220
19604
  }
19221
19605
  }
19222
19606
  if (blocks.length === 1 && blocks[0]?.type === "text") {
@@ -19349,6 +19733,8 @@ var BaseStreamConverter = class {
19349
19733
  usage = { inputTokens: 0, outputTokens: 0 };
19350
19734
  /** Buffers for accumulating tool call arguments */
19351
19735
  toolCallBuffers = /* @__PURE__ */ new Map();
19736
+ /** Buffer for accumulating reasoning/thinking content */
19737
+ reasoningBuffer = "";
19352
19738
  // ==========================================================================
19353
19739
  // Public API
19354
19740
  // ==========================================================================
@@ -19383,6 +19769,7 @@ var BaseStreamConverter = class {
19383
19769
  this.sequenceNumber = 0;
19384
19770
  this.usage = { inputTokens: 0, outputTokens: 0 };
19385
19771
  this.toolCallBuffers.clear();
19772
+ this.reasoningBuffer = "";
19386
19773
  }
19387
19774
  /**
19388
19775
  * Reset converter state for a new stream
@@ -19437,6 +19824,33 @@ var BaseStreamConverter = class {
19437
19824
  sequence_number: this.nextSequence()
19438
19825
  };
19439
19826
  }
19827
+ /**
19828
+ * Create REASONING_DELTA event and accumulate reasoning buffer
19829
+ */
19830
+ emitReasoningDelta(delta, itemId) {
19831
+ this.reasoningBuffer += delta;
19832
+ return {
19833
+ type: "response.reasoning.delta" /* REASONING_DELTA */,
19834
+ response_id: this.responseId,
19835
+ item_id: itemId || `reasoning_${this.responseId}`,
19836
+ delta,
19837
+ sequence_number: this.nextSequence()
19838
+ };
19839
+ }
19840
+ /**
19841
+ * Create REASONING_DONE event with accumulated reasoning
19842
+ */
19843
+ emitReasoningDone(itemId) {
19844
+ const id = itemId || `reasoning_${this.responseId}`;
19845
+ const thinking = this.reasoningBuffer;
19846
+ this.reasoningBuffer = "";
19847
+ return {
19848
+ type: "response.reasoning.done" /* REASONING_DONE */,
19849
+ response_id: this.responseId,
19850
+ item_id: id,
19851
+ thinking
19852
+ };
19853
+ }
19440
19854
  /**
19441
19855
  * Create TOOL_CALL_START event
19442
19856
  */
@@ -19581,7 +19995,10 @@ var AnthropicStreamConverter = class extends BaseStreamConverter {
19581
19995
  handleContentBlockStart(event) {
19582
19996
  const index = event.index;
19583
19997
  const block = event.content_block;
19584
- if (block.type === "text") {
19998
+ if (block.type === "thinking") {
19999
+ this.contentBlockIndex.set(index, { type: "thinking" });
20000
+ return [];
20001
+ } else if (block.type === "text") {
19585
20002
  this.contentBlockIndex.set(index, { type: "text" });
19586
20003
  return [];
19587
20004
  } else if (block.type === "tool_use") {
@@ -19602,7 +20019,12 @@ var AnthropicStreamConverter = class extends BaseStreamConverter {
19602
20019
  const delta = event.delta;
19603
20020
  const blockInfo = this.contentBlockIndex.get(index);
19604
20021
  if (!blockInfo) return [];
19605
- if (delta.type === "text_delta") {
20022
+ if (delta.type === "thinking_delta") {
20023
+ const thinkingDelta = delta;
20024
+ return [
20025
+ this.emitReasoningDelta(thinkingDelta.thinking || "", `thinking_${this.responseId}`)
20026
+ ];
20027
+ } else if (delta.type === "text_delta") {
19606
20028
  return [
19607
20029
  this.emitTextDelta(delta.text, {
19608
20030
  itemId: `msg_${this.responseId}`,
@@ -19622,6 +20044,9 @@ var AnthropicStreamConverter = class extends BaseStreamConverter {
19622
20044
  const index = event.index;
19623
20045
  const blockInfo = this.contentBlockIndex.get(index);
19624
20046
  if (!blockInfo) return [];
20047
+ if (blockInfo.type === "thinking") {
20048
+ return [this.emitReasoningDone(`thinking_${this.responseId}`)];
20049
+ }
19625
20050
  if (blockInfo.type === "tool_use") {
19626
20051
  return [this.emitToolCallArgsDone(blockInfo.id || "", blockInfo.name)];
19627
20052
  }
@@ -19720,6 +20145,16 @@ var AnthropicTextProvider = class extends BaseTextProvider {
19720
20145
  caps.supportsJSONSchema = false;
19721
20146
  return caps;
19722
20147
  }
20148
+ /**
20149
+ * List available models from the Anthropic API
20150
+ */
20151
+ async listModels() {
20152
+ const models = [];
20153
+ for await (const model of this.client.models.list()) {
20154
+ models.push(model.id);
20155
+ }
20156
+ return models.sort();
20157
+ }
19723
20158
  /**
19724
20159
  * Handle Anthropic-specific errors
19725
20160
  */
@@ -19898,6 +20333,11 @@ var GoogleConverter = class {
19898
20333
  request.generationConfig.thinkingConfig = {
19899
20334
  thinkingLevel: options.vendorOptions.thinkingLevel
19900
20335
  };
20336
+ } else if (options.thinking?.enabled) {
20337
+ validateThinkingConfig(options.thinking);
20338
+ request.generationConfig.thinkingConfig = {
20339
+ thinkingBudget: options.thinking.budgetTokens || 8192
20340
+ };
19901
20341
  }
19902
20342
  if (tools && tools.length > 0) {
19903
20343
  request.generationConfig.allowCodeExecution = false;
@@ -20113,7 +20553,13 @@ var GoogleConverter = class {
20113
20553
  convertGeminiPartsToContent(parts) {
20114
20554
  const content = [];
20115
20555
  for (const part of parts) {
20116
- if ("text" in part && part.text) {
20556
+ if ("thought" in part && part.thought === true && "text" in part && part.text) {
20557
+ content.push({
20558
+ type: "thinking" /* THINKING */,
20559
+ thinking: part.text,
20560
+ persistInHistory: false
20561
+ });
20562
+ } else if ("text" in part && part.text) {
20117
20563
  content.push(createTextContent(part.text));
20118
20564
  } else if ("functionCall" in part && part.functionCall) {
20119
20565
  const toolId = generateToolCallId("google");
@@ -20191,6 +20637,8 @@ var GoogleStreamConverter = class {
20191
20637
  isFirst = true;
20192
20638
  toolCallBuffers = /* @__PURE__ */ new Map();
20193
20639
  hadToolCalls = false;
20640
+ reasoningBuffer = "";
20641
+ wasThinking = false;
20194
20642
  // External storage for thought signatures (shared with GoogleConverter)
20195
20643
  thoughtSignatureStorage = null;
20196
20644
  // External storage for tool call ID → name mapping (shared with GoogleConverter)
@@ -20218,6 +20666,8 @@ var GoogleStreamConverter = class {
20218
20666
  this.isFirst = true;
20219
20667
  this.toolCallBuffers.clear();
20220
20668
  this.hadToolCalls = false;
20669
+ this.reasoningBuffer = "";
20670
+ this.wasThinking = false;
20221
20671
  let lastUsage = {
20222
20672
  input_tokens: 0,
20223
20673
  output_tokens: 0,
@@ -20243,6 +20693,16 @@ var GoogleStreamConverter = class {
20243
20693
  yield event;
20244
20694
  }
20245
20695
  }
20696
+ if (this.wasThinking && this.reasoningBuffer) {
20697
+ yield {
20698
+ type: "response.reasoning.done" /* REASONING_DONE */,
20699
+ response_id: this.responseId,
20700
+ item_id: `thinking_${this.responseId}`,
20701
+ thinking: this.reasoningBuffer
20702
+ };
20703
+ this.reasoningBuffer = "";
20704
+ this.wasThinking = false;
20705
+ }
20246
20706
  if (this.toolCallBuffers.size > 0) {
20247
20707
  for (const [toolCallId, buffer] of this.toolCallBuffers) {
20248
20708
  yield {
@@ -20282,7 +20742,28 @@ var GoogleStreamConverter = class {
20282
20742
  const candidate = chunk.candidates?.[0];
20283
20743
  if (!candidate?.content?.parts) return events;
20284
20744
  for (const part of candidate.content.parts) {
20285
- if (part.text) {
20745
+ const isThought = "thought" in part && part.thought === true;
20746
+ if (isThought && part.text) {
20747
+ this.wasThinking = true;
20748
+ this.reasoningBuffer += part.text;
20749
+ events.push({
20750
+ type: "response.reasoning.delta" /* REASONING_DELTA */,
20751
+ response_id: this.responseId,
20752
+ item_id: `thinking_${this.responseId}`,
20753
+ delta: part.text,
20754
+ sequence_number: this.sequenceNumber++
20755
+ });
20756
+ } else if (part.text) {
20757
+ if (this.wasThinking) {
20758
+ this.wasThinking = false;
20759
+ events.push({
20760
+ type: "response.reasoning.done" /* REASONING_DONE */,
20761
+ response_id: this.responseId,
20762
+ item_id: `thinking_${this.responseId}`,
20763
+ thinking: this.reasoningBuffer
20764
+ });
20765
+ this.reasoningBuffer = "";
20766
+ }
20286
20767
  events.push({
20287
20768
  type: "response.output_text.delta" /* OUTPUT_TEXT_DELTA */,
20288
20769
  response_id: this.responseId,
@@ -20381,6 +20862,8 @@ var GoogleStreamConverter = class {
20381
20862
  this.isFirst = true;
20382
20863
  this.toolCallBuffers.clear();
20383
20864
  this.hadToolCalls = false;
20865
+ this.reasoningBuffer = "";
20866
+ this.wasThinking = false;
20384
20867
  }
20385
20868
  /**
20386
20869
  * Reset converter state for a new stream
@@ -20510,6 +20993,18 @@ var GoogleTextProvider = class extends BaseTextProvider {
20510
20993
  maxOutputTokens: 65536
20511
20994
  });
20512
20995
  }
20996
+ /**
20997
+ * List available models from the Google Gemini API
20998
+ */
20999
+ async listModels() {
21000
+ const models = [];
21001
+ const pager = await this.client.models.list();
21002
+ for await (const model of pager) {
21003
+ const name = model.name?.replace(/^models\//, "") ?? "";
21004
+ if (name) models.push(name);
21005
+ }
21006
+ return models.sort();
21007
+ }
20513
21008
  /**
20514
21009
  * Handle Google-specific errors
20515
21010
  */
@@ -20617,6 +21112,18 @@ var VertexAITextProvider = class extends BaseTextProvider {
20617
21112
  maxOutputTokens: 65536
20618
21113
  });
20619
21114
  }
21115
+ /**
21116
+ * List available models from the Vertex AI API
21117
+ */
21118
+ async listModels() {
21119
+ const models = [];
21120
+ const pager = await this.client.models.list();
21121
+ for await (const model of pager) {
21122
+ const name = model.name?.replace(/^models\//, "") ?? "";
21123
+ if (name) models.push(name);
21124
+ }
21125
+ return models.sort();
21126
+ }
20620
21127
  /**
20621
21128
  * Handle Vertex AI-specific errors
20622
21129
  */
@@ -20662,6 +21169,23 @@ var GenericOpenAIProvider = class extends OpenAITextProvider {
20662
21169
  };
20663
21170
  }
20664
21171
  }
21172
+ /**
21173
+ * Override API key validation for generic providers.
21174
+ * Services like Ollama don't require authentication, so accept any key including mock/placeholder keys.
21175
+ */
21176
+ validateApiKey() {
21177
+ return { isValid: true };
21178
+ }
21179
+ /**
21180
+ * Override listModels for error safety — some OpenAI-compatible APIs may not support /v1/models
21181
+ */
21182
+ async listModels() {
21183
+ try {
21184
+ return await super.listModels();
21185
+ } catch {
21186
+ return [];
21187
+ }
21188
+ }
20665
21189
  /**
20666
21190
  * Override model capabilities for generic providers (registry-driven with conservative defaults)
20667
21191
  */
@@ -21106,6 +21630,34 @@ var BaseAgent = class extends EventEmitter {
21106
21630
  return tool.definition;
21107
21631
  });
21108
21632
  }
21633
+ // ===== Model Discovery =====
21634
+ /**
21635
+ * List available models from the provider's API.
21636
+ * Useful for discovering models dynamically (e.g., Ollama local models).
21637
+ */
21638
+ async listModels() {
21639
+ return this._provider.listModels();
21640
+ }
21641
+ // ===== Snapshot / Inspection =====
21642
+ /**
21643
+ * Get a complete, serializable snapshot of the agent's context state.
21644
+ *
21645
+ * Convenience method that auto-wires tool usage stats from ToolManager.
21646
+ * Used by UI "Look Inside" panels.
21647
+ */
21648
+ async getSnapshot() {
21649
+ const stats = this._agentContext.tools.getStats();
21650
+ return this._agentContext.getSnapshot({ mostUsed: stats.mostUsed });
21651
+ }
21652
+ /**
21653
+ * Get a human-readable breakdown of the prepared context.
21654
+ *
21655
+ * Convenience method that delegates to AgentContextNextGen.
21656
+ * Used by "View Full Context" UI panels.
21657
+ */
21658
+ async getViewContext() {
21659
+ return this._agentContext.getViewContext();
21660
+ }
21109
21661
  // ===== Direct LLM Access (Bypasses AgentContext) =====
21110
21662
  /**
21111
21663
  * Get the provider for LLM calls.
@@ -21869,6 +22421,8 @@ var StreamState = class {
21869
22421
  createdAt;
21870
22422
  // Text accumulation: item_id -> text chunks
21871
22423
  textBuffers;
22424
+ // Reasoning accumulation: item_id -> reasoning chunks
22425
+ reasoningBuffers;
21872
22426
  // Tool call accumulation: tool_call_id -> buffer
21873
22427
  toolCallBuffers;
21874
22428
  // Completed tool calls
@@ -21890,6 +22444,7 @@ var StreamState = class {
21890
22444
  this.model = model;
21891
22445
  this.createdAt = createdAt || Date.now();
21892
22446
  this.textBuffers = /* @__PURE__ */ new Map();
22447
+ this.reasoningBuffers = /* @__PURE__ */ new Map();
21893
22448
  this.toolCallBuffers = /* @__PURE__ */ new Map();
21894
22449
  this.completedToolCalls = [];
21895
22450
  this.toolResults = /* @__PURE__ */ new Map();
@@ -21933,6 +22488,39 @@ var StreamState = class {
21933
22488
  }
21934
22489
  return allText.join("");
21935
22490
  }
22491
+ /**
22492
+ * Accumulate reasoning delta for a specific item
22493
+ */
22494
+ accumulateReasoningDelta(itemId, delta) {
22495
+ if (!this.reasoningBuffers.has(itemId)) {
22496
+ this.reasoningBuffers.set(itemId, []);
22497
+ }
22498
+ this.reasoningBuffers.get(itemId).push(delta);
22499
+ this.totalChunks++;
22500
+ }
22501
+ /**
22502
+ * Get complete accumulated reasoning for an item
22503
+ */
22504
+ getCompleteReasoning(itemId) {
22505
+ const chunks = this.reasoningBuffers.get(itemId);
22506
+ return chunks ? chunks.join("") : "";
22507
+ }
22508
+ /**
22509
+ * Get all accumulated reasoning (all items concatenated)
22510
+ */
22511
+ getAllReasoning() {
22512
+ const allReasoning = [];
22513
+ for (const chunks of this.reasoningBuffers.values()) {
22514
+ allReasoning.push(chunks.join(""));
22515
+ }
22516
+ return allReasoning.join("");
22517
+ }
22518
+ /**
22519
+ * Check if stream has any accumulated reasoning
22520
+ */
22521
+ hasReasoning() {
22522
+ return this.reasoningBuffers.size > 0;
22523
+ }
21936
22524
  /**
21937
22525
  * Start accumulating tool call arguments
21938
22526
  */
@@ -22101,6 +22689,7 @@ var StreamState = class {
22101
22689
  */
22102
22690
  clear() {
22103
22691
  this.textBuffers.clear();
22692
+ this.reasoningBuffers.clear();
22104
22693
  this.toolCallBuffers.clear();
22105
22694
  this.completedToolCalls = [];
22106
22695
  this.toolResults.clear();
@@ -22114,6 +22703,7 @@ var StreamState = class {
22114
22703
  model: this.model,
22115
22704
  createdAt: this.createdAt,
22116
22705
  textBuffers: new Map(this.textBuffers),
22706
+ reasoningBuffers: new Map(this.reasoningBuffers),
22117
22707
  toolCallBuffers: new Map(this.toolCallBuffers),
22118
22708
  completedToolCalls: [...this.completedToolCalls],
22119
22709
  toolResults: new Map(this.toolResults),
@@ -22543,6 +23133,20 @@ var Agent = class _Agent extends BaseAgent {
22543
23133
  _addStreamingAssistantMessage(streamState, toolCalls) {
22544
23134
  const assistantText = streamState.getAllText();
22545
23135
  const assistantContent = [];
23136
+ if (streamState.hasReasoning()) {
23137
+ const reasoning = streamState.getAllReasoning();
23138
+ if (reasoning) {
23139
+ const isAnthropic = this.connector.vendor === Vendor.Anthropic;
23140
+ assistantContent.push({
23141
+ type: "thinking" /* THINKING */,
23142
+ thinking: reasoning,
23143
+ // Streaming doesn't carry Anthropic signatures, so signature is undefined here.
23144
+ // Non-streaming responses (via convertResponse) capture signatures correctly.
23145
+ signature: void 0,
23146
+ persistInHistory: isAnthropic
23147
+ });
23148
+ }
23149
+ }
22546
23150
  if (assistantText && assistantText.trim()) {
22547
23151
  assistantContent.push({
22548
23152
  type: "output_text" /* OUTPUT_TEXT */,
@@ -22781,6 +23385,7 @@ var Agent = class _Agent extends BaseAgent {
22781
23385
  tools: this.getEnabledToolDefinitions(),
22782
23386
  tool_choice: "auto",
22783
23387
  temperature: this._config.temperature,
23388
+ thinking: this._config.thinking,
22784
23389
  vendorOptions: this._config.vendorOptions
22785
23390
  };
22786
23391
  const beforeLLM = await this.hookManager.executeHooks("before:llm", {
@@ -22846,6 +23451,7 @@ var Agent = class _Agent extends BaseAgent {
22846
23451
  tools: this.getEnabledToolDefinitions(),
22847
23452
  tool_choice: "auto",
22848
23453
  temperature: this._config.temperature,
23454
+ thinking: this._config.thinking,
22849
23455
  vendorOptions: this._config.vendorOptions
22850
23456
  };
22851
23457
  await this.hookManager.executeHooks("before:llm", {
@@ -22863,7 +23469,9 @@ var Agent = class _Agent extends BaseAgent {
22863
23469
  });
22864
23470
  try {
22865
23471
  for await (const event of this._provider.streamGenerate(generateOptions)) {
22866
- if (event.type === "response.output_text.delta" /* OUTPUT_TEXT_DELTA */) {
23472
+ if (isReasoningDelta(event)) {
23473
+ streamState.accumulateReasoningDelta(event.item_id, event.delta);
23474
+ } else if (event.type === "response.output_text.delta" /* OUTPUT_TEXT_DELTA */) {
22867
23475
  streamState.accumulateTextDelta(event.item_id, event.delta);
22868
23476
  } else if (event.type === "response.tool_call.start" /* TOOL_CALL_START */) {
22869
23477
  streamState.startToolCall(event.tool_call_id, event.tool_name);
@@ -23899,6 +24507,12 @@ function defaultTaskPrompt(task) {
23899
24507
  }
23900
24508
  parts.push("");
23901
24509
  }
24510
+ if (task.dependsOn.length > 0) {
24511
+ parts.push("Note: Results from prerequisite tasks are available in your live context.");
24512
+ parts.push("Small results appear directly; larger results are in working memory \u2014 use memory_retrieve to access them.");
24513
+ parts.push("Review the plan overview and dependency results before starting.");
24514
+ parts.push("");
24515
+ }
23902
24516
  parts.push("After completing the work, store key results in memory once, then respond with a text summary (no more tool calls).");
23903
24517
  return parts.join("\n");
23904
24518
  }
@@ -23982,6 +24596,127 @@ async function collectValidationContext(agent, responseText) {
23982
24596
  toolCallLog
23983
24597
  };
23984
24598
  }
24599
+ function estimateTokens(text) {
24600
+ return Math.ceil(text.length / 4);
24601
+ }
24602
+ function buildPlanOverview(execution, definition, currentTaskId) {
24603
+ const parts = [];
24604
+ const progress = execution.progress ?? 0;
24605
+ parts.push(`Routine: ${definition.name}`);
24606
+ if (definition.description) {
24607
+ parts.push(`Goal: ${definition.description}`);
24608
+ }
24609
+ parts.push(`Progress: ${Math.round(progress * 100)}%`);
24610
+ parts.push("");
24611
+ parts.push("Tasks:");
24612
+ for (const task of execution.plan.tasks) {
24613
+ let statusIcon;
24614
+ switch (task.status) {
24615
+ case "completed":
24616
+ statusIcon = "[x]";
24617
+ break;
24618
+ case "in_progress":
24619
+ statusIcon = "[>]";
24620
+ break;
24621
+ case "failed":
24622
+ statusIcon = "[!]";
24623
+ break;
24624
+ case "skipped":
24625
+ statusIcon = "[-]";
24626
+ break;
24627
+ default:
24628
+ statusIcon = "[ ]";
24629
+ }
24630
+ let line = `${statusIcon} ${task.name}`;
24631
+ if (task.dependsOn.length > 0) {
24632
+ const depNames = task.dependsOn.map((depId) => execution.plan.tasks.find((t) => t.id === depId)?.name ?? depId).join(", ");
24633
+ line += ` (after: ${depNames})`;
24634
+ }
24635
+ if (task.id === currentTaskId) {
24636
+ line += " \u2190 CURRENT";
24637
+ }
24638
+ parts.push(line);
24639
+ }
24640
+ return parts.join("\n");
24641
+ }
24642
+ async function injectRoutineContext(agent, execution, definition, currentTask) {
24643
+ const icmPlugin = agent.context.getPlugin("in_context_memory");
24644
+ const wmPlugin = agent.context.memory;
24645
+ if (!icmPlugin && !wmPlugin) {
24646
+ logger.warn("injectRoutineContext: No ICM or WM plugin available \u2014 skipping context injection");
24647
+ return;
24648
+ }
24649
+ const planOverview = buildPlanOverview(execution, definition, currentTask.id);
24650
+ if (icmPlugin) {
24651
+ icmPlugin.set("__routine_plan", "Routine plan overview with task statuses", planOverview, "high");
24652
+ }
24653
+ if (icmPlugin) {
24654
+ for (const entry of icmPlugin.list()) {
24655
+ if (entry.key.startsWith("__dep_result_") || entry.key === "__routine_deps") {
24656
+ icmPlugin.delete(entry.key);
24657
+ }
24658
+ }
24659
+ }
24660
+ if (wmPlugin) {
24661
+ const { entries: wmEntries } = await wmPlugin.query();
24662
+ for (const entry of wmEntries) {
24663
+ if (entry.key.startsWith("__dep_result_") || entry.key.startsWith("findings/__dep_result_")) {
24664
+ await wmPlugin.delete(entry.key);
24665
+ }
24666
+ }
24667
+ }
24668
+ if (currentTask.dependsOn.length === 0) return;
24669
+ const inContextDeps = [];
24670
+ const workingMemoryDeps = [];
24671
+ for (const depId of currentTask.dependsOn) {
24672
+ const depTask = execution.plan.tasks.find((t) => t.id === depId);
24673
+ if (!depTask?.result?.output) continue;
24674
+ const output = typeof depTask.result.output === "string" ? depTask.result.output : JSON.stringify(depTask.result.output);
24675
+ const tokens = estimateTokens(output);
24676
+ const depKey = `__dep_result_${depId}`;
24677
+ const depLabel = `Result from task "${depTask.name}"`;
24678
+ if (tokens < 5e3 && icmPlugin) {
24679
+ icmPlugin.set(depKey, depLabel, output, "high");
24680
+ inContextDeps.push(depTask.name);
24681
+ } else if (wmPlugin) {
24682
+ await wmPlugin.store(depKey, depLabel, output, { tier: "findings" });
24683
+ workingMemoryDeps.push(depTask.name);
24684
+ } else if (icmPlugin) {
24685
+ const truncated = output.slice(0, 2e4) + "\n... (truncated, full result not available)";
24686
+ icmPlugin.set(depKey, depLabel, truncated, "high");
24687
+ inContextDeps.push(depTask.name + " (truncated)");
24688
+ }
24689
+ }
24690
+ if (icmPlugin && (inContextDeps.length > 0 || workingMemoryDeps.length > 0)) {
24691
+ const summaryParts = ["Dependency results available:"];
24692
+ if (inContextDeps.length > 0) {
24693
+ summaryParts.push(`In context (visible now): ${inContextDeps.join(", ")}`);
24694
+ }
24695
+ if (workingMemoryDeps.length > 0) {
24696
+ summaryParts.push(`In working memory (use memory_retrieve): ${workingMemoryDeps.join(", ")}`);
24697
+ }
24698
+ icmPlugin.set("__routine_deps", "Dependency results location guide", summaryParts.join("\n"), "high");
24699
+ }
24700
+ }
24701
+ async function cleanupRoutineContext(agent) {
24702
+ const icmPlugin = agent.context.getPlugin("in_context_memory");
24703
+ const wmPlugin = agent.context.memory;
24704
+ if (icmPlugin) {
24705
+ for (const entry of icmPlugin.list()) {
24706
+ if (entry.key.startsWith("__routine_") || entry.key.startsWith("__dep_result_")) {
24707
+ icmPlugin.delete(entry.key);
24708
+ }
24709
+ }
24710
+ }
24711
+ if (wmPlugin) {
24712
+ const { entries: wmEntries } = await wmPlugin.query();
24713
+ for (const entry of wmEntries) {
24714
+ if (entry.key.startsWith("__dep_result_") || entry.key.startsWith("findings/__dep_result_")) {
24715
+ await wmPlugin.delete(entry.key);
24716
+ }
24717
+ }
24718
+ }
24719
+ }
23985
24720
  async function validateTaskCompletion(agent, task, responseText, validationPromptBuilder) {
23986
24721
  const hasExplicitValidation = task.validation?.skipReflection === false && task.validation?.completionCriteria && task.validation.completionCriteria.length > 0;
23987
24722
  if (!hasExplicitValidation) {
@@ -24118,7 +24853,7 @@ async function executeRoutine(options) {
24118
24853
  execution.lastUpdatedAt = Date.now();
24119
24854
  onTaskStarted?.(execution.plan.tasks[taskIndex], execution);
24120
24855
  let taskCompleted = false;
24121
- const maxTaskIterations = task.execution?.maxIterations ?? 15;
24856
+ const maxTaskIterations = task.execution?.maxIterations ?? 50;
24122
24857
  const iterationLimiter = async (ctx) => {
24123
24858
  if (ctx.iteration >= maxTaskIterations) {
24124
24859
  agent.cancel(`Task "${task.name}" exceeded max iterations (${maxTaskIterations})`);
@@ -24127,6 +24862,7 @@ async function executeRoutine(options) {
24127
24862
  };
24128
24863
  agent.registerHook("pause:check", iterationLimiter);
24129
24864
  const getTask = () => execution.plan.tasks[taskIndex];
24865
+ await injectRoutineContext(agent, execution, definition, getTask());
24130
24866
  while (!taskCompleted) {
24131
24867
  try {
24132
24868
  const taskPrompt = buildTaskPrompt(getTask());
@@ -24229,6 +24965,10 @@ async function executeRoutine(options) {
24229
24965
  );
24230
24966
  return execution;
24231
24967
  } finally {
24968
+ try {
24969
+ await cleanupRoutineContext(agent);
24970
+ } catch {
24971
+ }
24232
24972
  for (const { name, hook } of registeredHooks) {
24233
24973
  try {
24234
24974
  agent.unregisterHook(name, hook);
@@ -38756,6 +39496,42 @@ var StreamHelpers = class {
38756
39496
  }
38757
39497
  return chunks.join("");
38758
39498
  }
39499
+ /**
39500
+ * Get only reasoning/thinking deltas from stream
39501
+ * Filters out all other event types
39502
+ */
39503
+ static async *thinkingOnly(stream) {
39504
+ for await (const event of stream) {
39505
+ if (isReasoningDelta(event)) {
39506
+ yield event.delta;
39507
+ }
39508
+ }
39509
+ }
39510
+ /**
39511
+ * Get both text and thinking deltas from stream
39512
+ * Yields tagged objects so consumers can distinguish them
39513
+ */
39514
+ static async *textAndThinking(stream) {
39515
+ for await (const event of stream) {
39516
+ if (isOutputTextDelta(event)) {
39517
+ yield { type: "text", delta: event.delta };
39518
+ } else if (isReasoningDelta(event)) {
39519
+ yield { type: "thinking", delta: event.delta };
39520
+ }
39521
+ }
39522
+ }
39523
+ /**
39524
+ * Accumulate all thinking/reasoning content from stream into a single string
39525
+ */
39526
+ static async accumulateThinking(stream) {
39527
+ const chunks = [];
39528
+ for await (const event of stream) {
39529
+ if (isReasoningDelta(event)) {
39530
+ chunks.push(event.delta);
39531
+ }
39532
+ }
39533
+ return chunks.join("");
39534
+ }
38759
39535
  /**
38760
39536
  * Buffer stream events into batches
38761
39537
  */
@@ -38815,6 +39591,11 @@ var StreamHelpers = class {
38815
39591
  case "response.output_text.delta" /* OUTPUT_TEXT_DELTA */:
38816
39592
  state.accumulateTextDelta(event.item_id, event.delta);
38817
39593
  break;
39594
+ case "response.reasoning.delta" /* REASONING_DELTA */:
39595
+ state.accumulateReasoningDelta(event.item_id, event.delta);
39596
+ break;
39597
+ case "response.reasoning.done" /* REASONING_DONE */:
39598
+ break;
38818
39599
  case "response.tool_call.start" /* TOOL_CALL_START */:
38819
39600
  state.startToolCall(event.tool_call_id, event.tool_name);
38820
39601
  break;
@@ -38845,21 +39626,36 @@ var StreamHelpers = class {
38845
39626
  */
38846
39627
  static reconstructLLMResponse(state) {
38847
39628
  const output = [];
39629
+ const contentParts = [];
39630
+ let thinkingText;
39631
+ if (state.hasReasoning()) {
39632
+ const reasoning = state.getAllReasoning();
39633
+ if (reasoning) {
39634
+ thinkingText = reasoning;
39635
+ contentParts.push({
39636
+ type: "thinking" /* THINKING */,
39637
+ thinking: reasoning,
39638
+ persistInHistory: false
39639
+ // Vendor-agnostic default; caller can adjust
39640
+ });
39641
+ }
39642
+ }
38848
39643
  if (state.hasText()) {
38849
39644
  const textContent = state.getAllText();
38850
39645
  if (textContent) {
38851
- output.push({
38852
- type: "message",
38853
- role: "assistant" /* ASSISTANT */,
38854
- content: [
38855
- {
38856
- type: "output_text" /* OUTPUT_TEXT */,
38857
- text: textContent
38858
- }
38859
- ]
39646
+ contentParts.push({
39647
+ type: "output_text" /* OUTPUT_TEXT */,
39648
+ text: textContent
38860
39649
  });
38861
39650
  }
38862
39651
  }
39652
+ if (contentParts.length > 0) {
39653
+ output.push({
39654
+ type: "message",
39655
+ role: "assistant" /* ASSISTANT */,
39656
+ content: contentParts
39657
+ });
39658
+ }
38863
39659
  const toolCalls = state.getCompletedToolCalls();
38864
39660
  if (toolCalls.length > 0) {
38865
39661
  const toolUseContent = toolCalls.map((tc) => ({
@@ -38888,6 +39684,7 @@ var StreamHelpers = class {
38888
39684
  model: state.model,
38889
39685
  output,
38890
39686
  output_text: outputText,
39687
+ thinking: thinkingText,
38891
39688
  usage: state.usage
38892
39689
  };
38893
39690
  }
@@ -50091,6 +50888,6 @@ REMEMBER: Keep it conversational, ask one question at a time, and only output th
50091
50888
  }
50092
50889
  };
50093
50890
 
50094
- export { AGENT_DEFINITION_FORMAT_VERSION, AIError, APPROVAL_STATE_VERSION, Agent, AgentContextNextGen, ApproximateTokenEstimator, BaseMediaProvider, BasePluginNextGen, BaseProvider, BaseTextProvider, BraveProvider, CONNECTOR_CONFIG_VERSION, CONTEXT_SESSION_FORMAT_VERSION, CUSTOM_TOOL_DEFINITION_VERSION, CheckpointManager, CircuitBreaker, CircuitOpenError, Connector, ConnectorConfigStore, ConnectorTools, ConsoleMetrics, ContentType, ContextOverflowError, DEFAULT_ALLOWLIST, DEFAULT_BACKOFF_CONFIG, DEFAULT_BASE_DELAY_MS, DEFAULT_CHECKPOINT_STRATEGY, DEFAULT_CIRCUIT_BREAKER_CONFIG, DEFAULT_CONFIG2 as DEFAULT_CONFIG, DEFAULT_CONNECTOR_TIMEOUT, DEFAULT_CONTEXT_CONFIG, DEFAULT_DESKTOP_CONFIG, DEFAULT_FEATURES, DEFAULT_FILESYSTEM_CONFIG, DEFAULT_HISTORY_MANAGER_CONFIG, DEFAULT_MAX_DELAY_MS, DEFAULT_MAX_RETRIES, DEFAULT_MEMORY_CONFIG, DEFAULT_PERMISSION_CONFIG, DEFAULT_RATE_LIMITER_CONFIG, DEFAULT_RETRYABLE_STATUSES, DEFAULT_SHELL_CONFIG, DESKTOP_TOOL_NAMES, DefaultCompactionStrategy, DependencyCycleError, DocumentReader, ErrorHandler, ExecutionContext, ExternalDependencyHandler, FileAgentDefinitionStorage, FileConnectorStorage, FileContextStorage, FileCustomToolStorage, FileMediaStorage as FileMediaOutputHandler, FileMediaStorage, FilePersistentInstructionsStorage, FileRoutineDefinitionStorage, FileStorage, FileUserInfoStorage, FormatDetector, FrameworkLogger, HookManager, IMAGE_MODELS, IMAGE_MODEL_REGISTRY, ImageGeneration, InContextMemoryPluginNextGen, InMemoryAgentStateStorage, InMemoryHistoryStorage, InMemoryMetrics, InMemoryPlanStorage, InMemoryStorage, InvalidConfigError, InvalidToolArgumentsError, LLM_MODELS, LoggingPlugin, MCPClient, MCPConnectionError, MCPError, MCPProtocolError, MCPRegistry, MCPResourceError, MCPTimeoutError, MCPToolError, MEMORY_PRIORITY_VALUES, MODEL_REGISTRY, MemoryConnectorStorage, MemoryEvictionCompactor, MemoryStorage, MessageBuilder, MessageRole, ModelNotSupportedError, NoOpMetrics, NutTreeDriver, OAuthManager, ParallelTasksError, PersistentInstructionsPluginNextGen, PlanningAgent, ProviderAuthError, ProviderConfigAgent, ProviderContextLengthError, ProviderError, ProviderErrorMapper, ProviderNotFoundError, ProviderRateLimitError, RapidAPIProvider, RateLimitError, SERVICE_DEFINITIONS, SERVICE_INFO, SERVICE_URL_PATTERNS, SIMPLE_ICONS_CDN, STT_MODELS, STT_MODEL_REGISTRY, ScopedConnectorRegistry, ScrapeProvider, SearchProvider, SerperProvider, Services, SpeechToText, StorageRegistry, StrategyRegistry, StreamEventType, StreamHelpers, StreamState, SummarizeCompactor, TERMINAL_TASK_STATUSES, TTS_MODELS, TTS_MODEL_REGISTRY, TaskTimeoutError, TaskValidationError, TavilyProvider, TextToSpeech, TokenBucketRateLimiter, ToolCallState, ToolExecutionError, ToolExecutionPipeline, ToolManager, ToolNotFoundError, ToolPermissionManager, ToolRegistry, ToolTimeoutError, TruncateCompactor, UserInfoPluginNextGen, VENDORS, VENDOR_ICON_MAP, VIDEO_MODELS, VIDEO_MODEL_REGISTRY, Vendor, VideoGeneration, WorkingMemory, WorkingMemoryPluginNextGen, addJitter, allVendorTemplates, assertNotDestroyed, authenticatedFetch, backoffSequence, backoffWait, bash, buildAuthConfig, buildEndpointWithQuery, buildQueryString, calculateBackoff, calculateCost, calculateEntrySize, calculateImageCost, calculateSTTCost, calculateTTSCost, calculateVideoCost, canTaskExecute, createAgentStorage, createAuthenticatedFetch, createBashTool, createConnectorFromTemplate, createCreatePRTool, createCustomToolDelete, createCustomToolDraft, createCustomToolList, createCustomToolLoad, createCustomToolMetaTools, createCustomToolSave, createCustomToolTest, createDesktopGetCursorTool, createDesktopGetScreenSizeTool, createDesktopKeyboardKeyTool, createDesktopKeyboardTypeTool, createDesktopMouseClickTool, createDesktopMouseDragTool, createDesktopMouseMoveTool, createDesktopMouseScrollTool, createDesktopScreenshotTool, createDesktopWindowFocusTool, createDesktopWindowListTool, createDraftEmailTool, createEditFileTool, createEditMeetingTool, createEstimator, createExecuteJavaScriptTool, createFileAgentDefinitionStorage, createFileContextStorage, createFileCustomToolStorage, createFileMediaStorage, createFileRoutineDefinitionStorage, createFindMeetingSlotsTool, createGetMeetingTranscriptTool, createGetPRTool, createGitHubReadFileTool, createGlobTool, createGrepTool, createImageGenerationTool, createImageProvider, createListDirectoryTool, createMeetingTool, createMessageWithImages, createMetricsCollector, createPRCommentsTool, createPRFilesTool, createPlan, createProvider, createReadFileTool, createRoutineDefinition, createRoutineExecution, createSearchCodeTool, createSearchFilesTool, createSendEmailTool, createSpeechToTextTool, createTask, createTextMessage, createTextToSpeechTool, createVideoProvider, createVideoTools, createWriteFileTool, customToolDelete, customToolDraft, customToolList, customToolLoad, customToolSave, customToolTest, defaultDescribeCall, desktopGetCursor, desktopGetScreenSize, desktopKeyboardKey, desktopKeyboardType, desktopMouseClick, desktopMouseDrag, desktopMouseMove, desktopMouseScroll, desktopScreenshot, desktopTools, desktopWindowFocus, desktopWindowList, detectDependencyCycle, detectServiceFromURL, developerTools, documentToContent, editFile, evaluateCondition, executeRoutine, extractJSON, extractJSONField, extractNumber, findConnectorByServiceTypes, forPlan, forTasks, formatAttendees, formatRecipients, generateEncryptionKey, generateSimplePlan, generateWebAPITool, getActiveImageModels, getActiveModels, getActiveSTTModels, getActiveTTSModels, getActiveVideoModels, getAllBuiltInTools, getAllServiceIds, getAllVendorLogos, getAllVendorTemplates, getBackgroundOutput, getConnectorTools, getCredentialsSetupURL, getDesktopDriver, getDocsURL, getImageModelInfo, getImageModelsByVendor, getImageModelsWithFeature, getMediaOutputHandler, getMediaStorage, getModelInfo, getModelsByVendor, getNextExecutableTasks, getRegisteredScrapeProviders, getRoutineProgress, getSTTModelInfo, getSTTModelsByVendor, getSTTModelsWithFeature, getServiceDefinition, getServiceInfo, getServicesByCategory, getTTSModelInfo, getTTSModelsByVendor, getTTSModelsWithFeature, getTaskDependencies, getToolByName, getToolCallDescription, getToolCategories, getToolRegistry, getToolsByCategory, getToolsRequiringConnector, getUserPathPrefix, getVendorAuthTemplate, getVendorColor, getVendorDefaultBaseURL, getVendorInfo, getVendorLogo, getVendorLogoCdnUrl, getVendorLogoSvg, getVendorTemplate, getVideoModelInfo, getVideoModelsByVendor, getVideoModelsWithAudio, getVideoModelsWithFeature, glob, globalErrorHandler, grep, hasClipboardImage, hasVendorLogo, hydrateCustomTool, isBlockedCommand, isErrorEvent, isExcludedExtension, isKnownService, isOutputTextDelta, isResponseComplete, isSimpleScope, isStreamEvent, isTaskAwareScope, isTaskBlocked, isTeamsMeetingUrl, isTerminalMemoryStatus, isTerminalStatus, isToolCallArgumentsDelta, isToolCallArgumentsDone, isToolCallStart, isVendor, killBackgroundProcess, listConnectorsByServiceTypes, listDirectory, listVendorIds, listVendors, listVendorsByAuthType, listVendorsByCategory, listVendorsWithLogos, logger, mergeTextPieces, metrics, microsoftFetch, normalizeEmails, parseKeyCombo, parseRepository, readClipboardImage, readDocumentAsContent, readFile5 as readFile, registerScrapeProvider, resetDefaultDriver, resolveConnector, resolveDependencies, resolveMaxContextTokens, resolveMeetingId, resolveModelCapabilities, resolveRepository, retryWithBackoff, sanitizeToolName, scopeEquals, scopeMatches, setMediaOutputHandler, setMediaStorage, setMetricsCollector, simpleTokenEstimator, toConnectorOptions, toolRegistry, tools_exports as tools, updateTaskStatus, validatePath, writeFile5 as writeFile };
50891
+ export { AGENT_DEFINITION_FORMAT_VERSION, AIError, APPROVAL_STATE_VERSION, Agent, AgentContextNextGen, ApproximateTokenEstimator, BaseMediaProvider, BasePluginNextGen, BaseProvider, BaseTextProvider, BraveProvider, CONNECTOR_CONFIG_VERSION, CONTEXT_SESSION_FORMAT_VERSION, CUSTOM_TOOL_DEFINITION_VERSION, CheckpointManager, CircuitBreaker, CircuitOpenError, Connector, ConnectorConfigStore, ConnectorTools, ConsoleMetrics, ContentType, ContextOverflowError, DEFAULT_ALLOWLIST, DEFAULT_BACKOFF_CONFIG, DEFAULT_BASE_DELAY_MS, DEFAULT_CHECKPOINT_STRATEGY, DEFAULT_CIRCUIT_BREAKER_CONFIG, DEFAULT_CONFIG2 as DEFAULT_CONFIG, DEFAULT_CONNECTOR_TIMEOUT, DEFAULT_CONTEXT_CONFIG, DEFAULT_DESKTOP_CONFIG, DEFAULT_FEATURES, DEFAULT_FILESYSTEM_CONFIG, DEFAULT_HISTORY_MANAGER_CONFIG, DEFAULT_MAX_DELAY_MS, DEFAULT_MAX_RETRIES, DEFAULT_MEMORY_CONFIG, DEFAULT_PERMISSION_CONFIG, DEFAULT_RATE_LIMITER_CONFIG, DEFAULT_RETRYABLE_STATUSES, DEFAULT_SHELL_CONFIG, DESKTOP_TOOL_NAMES, DefaultCompactionStrategy, DependencyCycleError, DocumentReader, ErrorHandler, ExecutionContext, ExternalDependencyHandler, FileAgentDefinitionStorage, FileConnectorStorage, FileContextStorage, FileCustomToolStorage, FileMediaStorage as FileMediaOutputHandler, FileMediaStorage, FilePersistentInstructionsStorage, FileRoutineDefinitionStorage, FileStorage, FileUserInfoStorage, FormatDetector, FrameworkLogger, HookManager, IMAGE_MODELS, IMAGE_MODEL_REGISTRY, ImageGeneration, InContextMemoryPluginNextGen, InMemoryAgentStateStorage, InMemoryHistoryStorage, InMemoryMetrics, InMemoryPlanStorage, InMemoryStorage, InvalidConfigError, InvalidToolArgumentsError, LLM_MODELS, LoggingPlugin, MCPClient, MCPConnectionError, MCPError, MCPProtocolError, MCPRegistry, MCPResourceError, MCPTimeoutError, MCPToolError, MEMORY_PRIORITY_VALUES, MODEL_REGISTRY, MemoryConnectorStorage, MemoryEvictionCompactor, MemoryStorage, MessageBuilder, MessageRole, ModelNotSupportedError, NoOpMetrics, NutTreeDriver, OAuthManager, ParallelTasksError, PersistentInstructionsPluginNextGen, PlanningAgent, ProviderAuthError, ProviderConfigAgent, ProviderContextLengthError, ProviderError, ProviderErrorMapper, ProviderNotFoundError, ProviderRateLimitError, RapidAPIProvider, RateLimitError, SERVICE_DEFINITIONS, SERVICE_INFO, SERVICE_URL_PATTERNS, SIMPLE_ICONS_CDN, STT_MODELS, STT_MODEL_REGISTRY, ScopedConnectorRegistry, ScrapeProvider, SearchProvider, SerperProvider, Services, SpeechToText, StorageRegistry, StrategyRegistry, StreamEventType, StreamHelpers, StreamState, SummarizeCompactor, TERMINAL_TASK_STATUSES, TTS_MODELS, TTS_MODEL_REGISTRY, TaskTimeoutError, TaskValidationError, TavilyProvider, TextToSpeech, TokenBucketRateLimiter, ToolCallState, ToolExecutionError, ToolExecutionPipeline, ToolManager, ToolNotFoundError, ToolPermissionManager, ToolRegistry, ToolTimeoutError, TruncateCompactor, UserInfoPluginNextGen, VENDORS, VENDOR_ICON_MAP, VIDEO_MODELS, VIDEO_MODEL_REGISTRY, Vendor, VideoGeneration, WorkingMemory, WorkingMemoryPluginNextGen, addJitter, allVendorTemplates, assertNotDestroyed, authenticatedFetch, backoffSequence, backoffWait, bash, buildAuthConfig, buildEndpointWithQuery, buildQueryString, calculateBackoff, calculateCost, calculateEntrySize, calculateImageCost, calculateSTTCost, calculateTTSCost, calculateVideoCost, canTaskExecute, createAgentStorage, createAuthenticatedFetch, createBashTool, createConnectorFromTemplate, createCreatePRTool, createCustomToolDelete, createCustomToolDraft, createCustomToolList, createCustomToolLoad, createCustomToolMetaTools, createCustomToolSave, createCustomToolTest, createDesktopGetCursorTool, createDesktopGetScreenSizeTool, createDesktopKeyboardKeyTool, createDesktopKeyboardTypeTool, createDesktopMouseClickTool, createDesktopMouseDragTool, createDesktopMouseMoveTool, createDesktopMouseScrollTool, createDesktopScreenshotTool, createDesktopWindowFocusTool, createDesktopWindowListTool, createDraftEmailTool, createEditFileTool, createEditMeetingTool, createEstimator, createExecuteJavaScriptTool, createFileAgentDefinitionStorage, createFileContextStorage, createFileCustomToolStorage, createFileMediaStorage, createFileRoutineDefinitionStorage, createFindMeetingSlotsTool, createGetMeetingTranscriptTool, createGetPRTool, createGitHubReadFileTool, createGlobTool, createGrepTool, createImageGenerationTool, createImageProvider, createListDirectoryTool, createMeetingTool, createMessageWithImages, createMetricsCollector, createPRCommentsTool, createPRFilesTool, createPlan, createProvider, createReadFileTool, createRoutineDefinition, createRoutineExecution, createSearchCodeTool, createSearchFilesTool, createSendEmailTool, createSpeechToTextTool, createTask, createTextMessage, createTextToSpeechTool, createVideoProvider, createVideoTools, createWriteFileTool, customToolDelete, customToolDraft, customToolList, customToolLoad, customToolSave, customToolTest, defaultDescribeCall, desktopGetCursor, desktopGetScreenSize, desktopKeyboardKey, desktopKeyboardType, desktopMouseClick, desktopMouseDrag, desktopMouseMove, desktopMouseScroll, desktopScreenshot, desktopTools, desktopWindowFocus, desktopWindowList, detectDependencyCycle, detectServiceFromURL, developerTools, documentToContent, editFile, evaluateCondition, executeRoutine, extractJSON, extractJSONField, extractNumber, findConnectorByServiceTypes, forPlan, forTasks, formatAttendees, formatPluginDisplayName, formatRecipients, generateEncryptionKey, generateSimplePlan, generateWebAPITool, getActiveImageModels, getActiveModels, getActiveSTTModels, getActiveTTSModels, getActiveVideoModels, getAllBuiltInTools, getAllServiceIds, getAllVendorLogos, getAllVendorTemplates, getBackgroundOutput, getConnectorTools, getCredentialsSetupURL, getDesktopDriver, getDocsURL, getImageModelInfo, getImageModelsByVendor, getImageModelsWithFeature, getMediaOutputHandler, getMediaStorage, getModelInfo, getModelsByVendor, getNextExecutableTasks, getRegisteredScrapeProviders, getRoutineProgress, getSTTModelInfo, getSTTModelsByVendor, getSTTModelsWithFeature, getServiceDefinition, getServiceInfo, getServicesByCategory, getTTSModelInfo, getTTSModelsByVendor, getTTSModelsWithFeature, getTaskDependencies, getToolByName, getToolCallDescription, getToolCategories, getToolRegistry, getToolsByCategory, getToolsRequiringConnector, getUserPathPrefix, getVendorAuthTemplate, getVendorColor, getVendorDefaultBaseURL, getVendorInfo, getVendorLogo, getVendorLogoCdnUrl, getVendorLogoSvg, getVendorTemplate, getVideoModelInfo, getVideoModelsByVendor, getVideoModelsWithAudio, getVideoModelsWithFeature, glob, globalErrorHandler, grep, hasClipboardImage, hasVendorLogo, hydrateCustomTool, isBlockedCommand, isErrorEvent, isExcludedExtension, isKnownService, isOutputTextDelta, isReasoningDelta, isReasoningDone, isResponseComplete, isSimpleScope, isStreamEvent, isTaskAwareScope, isTaskBlocked, isTeamsMeetingUrl, isTerminalMemoryStatus, isTerminalStatus, isToolCallArgumentsDelta, isToolCallArgumentsDone, isToolCallStart, isVendor, killBackgroundProcess, listConnectorsByServiceTypes, listDirectory, listVendorIds, listVendors, listVendorsByAuthType, listVendorsByCategory, listVendorsWithLogos, logger, mergeTextPieces, metrics, microsoftFetch, normalizeEmails, parseKeyCombo, parseRepository, readClipboardImage, readDocumentAsContent, readFile5 as readFile, registerScrapeProvider, resetDefaultDriver, resolveConnector, resolveDependencies, resolveMaxContextTokens, resolveMeetingId, resolveModelCapabilities, resolveRepository, retryWithBackoff, sanitizeToolName, scopeEquals, scopeMatches, setMediaOutputHandler, setMediaStorage, setMetricsCollector, simpleTokenEstimator, toConnectorOptions, toolRegistry, tools_exports as tools, updateTaskStatus, validatePath, writeFile5 as writeFile };
50095
50892
  //# sourceMappingURL=index.js.map
50096
50893
  //# sourceMappingURL=index.js.map