@inkeep/agents-run-api 0.3.0 → 0.6.0

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
@@ -1,13 +1,6 @@
1
- import { env, __publicField, dbClient_default, getFormattedConversationHistory, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-7PHUFKNP.js';
2
- import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
3
- import { BaggageSpanProcessor, ALLOW_ALL_BAGGAGE_KEYS } from '@opentelemetry/baggage-span-processor';
4
- import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';
5
- import { CompositePropagator, W3CTraceContextPropagator, W3CBaggagePropagator } from '@opentelemetry/core';
6
- import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
7
- import { resourceFromAttributes } from '@opentelemetry/resources';
8
- import { NodeSDK } from '@opentelemetry/sdk-node';
9
- import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
10
- import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
1
+ import { defaultBatchProcessor } from './chunk-5RGAMXUL.js';
2
+ import { dbClient_default, getFormattedConversationHistory, env, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-HIGMADTA.js';
3
+ import { __publicField } from './chunk-PKBMQBKP.js';
11
4
  import { getLogger, getTracer, HeadersScopeSchema, getRequestExecutionContext, createApiError, getAgentGraphWithDefaultAgent, contextValidationMiddleware, getFullGraph, createOrGetConversation, getActiveAgentForConversation, setActiveAgentForConversation, getAgentById, handleContextResolution, createMessage, commonGetErrorResponses, loggerFactory, createDefaultCredentialStores, CredentialStoreRegistry, listTaskIdsByContextId, getTask, getLedgerArtifacts, getAgentGraphById, createTask, updateTask, setSpanWithError, updateConversation, handleApiError, TaskState, setActiveAgentForThread, getConversation, getRelatedAgentsForGraph, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, validateAndGetApiKey, getProject, ContextResolver, CredentialStuffer, MCPServerType, getCredentialReference, McpClient, getContextConfigById, getFullGraphDefinition, TemplateEngine, graphHasArtifactComponents, MCPTransportType, getExternalAgent } from '@inkeep/agents-core';
12
5
  import { otel } from '@hono/otel';
13
6
  import { OpenAPIHono, createRoute, z as z$1 } from '@hono/zod-openapi';
@@ -23,56 +16,18 @@ import { streamSSE, stream } from 'hono/streaming';
23
16
  import { nanoid } from 'nanoid';
24
17
  import destr from 'destr';
25
18
  import traverse from 'traverse';
26
- import { createUIMessageStream, JsonToSseTransformStream, parsePartialJson, generateText, generateObject, tool, streamText, streamObject } from 'ai';
19
+ import { createUIMessageStream, JsonToSseTransformStream, parsePartialJson, generateObject, tool, streamText, generateText, streamObject } from 'ai';
27
20
  import { createAnthropic, anthropic } from '@ai-sdk/anthropic';
21
+ import { createGateway, gateway } from '@ai-sdk/gateway';
28
22
  import { createGoogleGenerativeAI, google } from '@ai-sdk/google';
29
23
  import { createOpenAI, openai } from '@ai-sdk/openai';
24
+ import { createOpenRouter, openrouter } from '@openrouter/ai-sdk-provider';
30
25
  import jmespath from 'jmespath';
31
26
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
32
27
  import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
33
28
  import { z as z$2 } from 'zod/v3';
34
29
  import { toReqRes, toFetchResponse } from 'fetch-to-node';
35
30
 
36
- var maxExportBatchSize = env.OTEL_MAX_EXPORT_BATCH_SIZE ?? (env.ENVIRONMENT === "development" ? 1 : 512);
37
- var otlpExporter = new OTLPTraceExporter();
38
- var batchProcessor = new BatchSpanProcessor(otlpExporter, {
39
- maxExportBatchSize
40
- });
41
- var resource = resourceFromAttributes({
42
- [ATTR_SERVICE_NAME]: "inkeep-agents-run-api"
43
- });
44
- var sdk = new NodeSDK({
45
- resource,
46
- contextManager: new AsyncLocalStorageContextManager(),
47
- textMapPropagator: new CompositePropagator({
48
- propagators: [new W3CTraceContextPropagator(), new W3CBaggagePropagator()]
49
- }),
50
- spanProcessors: [new BaggageSpanProcessor(ALLOW_ALL_BAGGAGE_KEYS), batchProcessor],
51
- instrumentations: [
52
- getNodeAutoInstrumentations({
53
- "@opentelemetry/instrumentation-http": {
54
- enabled: true,
55
- requestHook: (span, request) => {
56
- const url = request?.url ?? request?.path;
57
- if (!url) return;
58
- const u = new URL(url, "http://localhost");
59
- span.updateName(`${request?.method || "UNKNOWN"} ${u.pathname}`);
60
- }
61
- },
62
- "@opentelemetry/instrumentation-undici": {
63
- requestHook: (span) => {
64
- const method = span.attributes?.["http.request.method"];
65
- const host = span.attributes?.["server.address"];
66
- const path = span.attributes?.["url.path"];
67
- if (method && path)
68
- span.updateName(host ? `${method} ${host}${path}` : `${method} ${path}`);
69
- }
70
- }
71
- })
72
- ]
73
- });
74
- sdk.start();
75
-
76
31
  // src/types/execution-context.ts
77
32
  function createExecutionContext(params) {
78
33
  return {
@@ -1127,6 +1082,17 @@ __publicField(_ArtifactReferenceSchema, "ARTIFACT_PROPS_SCHEMA", {
1127
1082
  required: ["artifact_id", "task_id"]
1128
1083
  });
1129
1084
  var ArtifactReferenceSchema = _ArtifactReferenceSchema;
1085
+
1086
+ // src/utils/default-status-schemas.ts
1087
+ var retrieveStatusSchema = {
1088
+ type: "retrieve",
1089
+ description: 'Use this when the system found or retrieved specific information from searches, queries, or lookups. ONLY report ACTUAL findings that appear explicitly in the tool results - never make up data, names, numbers, or details. The label must state the SPECIFIC discovery (e.g., "Found 3 authentication methods", "Database contains 500 records", "API supports JSON format") not the act of searching. Every detail must be traceable to actual tool output. NEVER invent placeholder names, fictional data, or information not present in the activities.'
1090
+ };
1091
+ var actionStatusSchema = {
1092
+ type: "action",
1093
+ description: 'Use this when the system executed a tool or performed an operation that modified state or had side effects. ONLY report ACTUAL tool executions and their results as they appear in the tool outputs - never make up tool names, parameters, or outcomes. The label must describe what specific action was performed and its concrete result based on actual tool execution data. DO NOT make up examples like "Ran test suite with X passes" unless a test suite was ACTUALLY run and reported X passes. DO NOT say "Executed database query" unless a database query was ACTUALLY executed. Only report what literally happened. NEVER invent tool names, execution results, or details not explicitly present in the tool execution activities. If a tool failed, report the actual failure, not imagined success.'
1094
+ };
1095
+ var defaultStatusSchemas = [retrieveStatusSchema, actionStatusSchema];
1130
1096
  var logger5 = getLogger("ModelFactory");
1131
1097
  var _ModelFactory = class _ModelFactory {
1132
1098
  /**
@@ -1140,6 +1106,18 @@ var _ModelFactory = class _ModelFactory {
1140
1106
  return createOpenAI(config);
1141
1107
  case "google":
1142
1108
  return createGoogleGenerativeAI(config);
1109
+ case "openrouter":
1110
+ return {
1111
+ ...createOpenRouter(config),
1112
+ textEmbeddingModel: () => {
1113
+ throw new Error("OpenRouter does not support text embeddings");
1114
+ },
1115
+ imageModel: () => {
1116
+ throw new Error("OpenRouter does not support image generation");
1117
+ }
1118
+ };
1119
+ case "gateway":
1120
+ return createGateway(config);
1143
1121
  default:
1144
1122
  throw new Error(`Unsupported provider: ${provider}`);
1145
1123
  }
@@ -1199,26 +1177,29 @@ var _ModelFactory = class _ModelFactory {
1199
1177
  return openai(modelName);
1200
1178
  case "google":
1201
1179
  return google(modelName);
1180
+ case "openrouter":
1181
+ return openrouter(modelName);
1182
+ case "gateway":
1183
+ return gateway(modelName);
1202
1184
  default:
1203
- throw new Error(`Unsupported provider: ${provider}`);
1185
+ throw new Error(
1186
+ `Unsupported provider: ${provider}. Supported providers are: ${_ModelFactory.BUILT_IN_PROVIDERS.join(", ")}. To access other models, use OpenRouter (openrouter/model-id) or Vercel AI Gateway (gateway/model-id).`
1187
+ );
1204
1188
  }
1205
1189
  }
1206
1190
  /**
1207
1191
  * Parse model string to extract provider and model name
1208
1192
  * Examples: "anthropic/claude-sonnet-4" -> { provider: "anthropic", modelName: "claude-sonnet-4" }
1193
+ * "openrouter/anthropic/claude-sonnet-4" -> { provider: "openrouter", modelName: "anthropic/claude-sonnet-4" }
1209
1194
  * "claude-sonnet-4" -> { provider: "anthropic", modelName: "claude-sonnet-4" } (default to anthropic)
1210
1195
  */
1211
1196
  static parseModelString(modelString) {
1212
1197
  if (modelString.includes("/")) {
1213
1198
  const [provider, ...modelParts] = modelString.split("/");
1214
1199
  const normalizedProvider = provider.toLowerCase();
1215
- if (!_ModelFactory.SUPPORTED_PROVIDERS.includes(normalizedProvider)) {
1216
- logger5.error(
1217
- { provider: normalizedProvider, modelName: modelParts.join("/") },
1218
- "Unsupported provider detected, falling back to anthropic"
1219
- );
1200
+ if (!_ModelFactory.BUILT_IN_PROVIDERS.includes(normalizedProvider)) {
1220
1201
  throw new Error(
1221
- `Unsupported provider: ${normalizedProvider}. Please provide a model in the format of provider/model-name.`
1202
+ `Unsupported provider: ${normalizedProvider}. Supported providers are: ${_ModelFactory.BUILT_IN_PROVIDERS.join(", ")}. To access other models, use OpenRouter (openrouter/model-id) or Vercel AI Gateway (gateway/model-id).`
1222
1203
  );
1223
1204
  }
1224
1205
  return {
@@ -1227,9 +1208,7 @@ var _ModelFactory = class _ModelFactory {
1227
1208
  // In case model name has slashes
1228
1209
  };
1229
1210
  }
1230
- throw new Error(
1231
- `Invalid model provided: ${modelString}. Please provide a model in the format of provider/model-name.`
1232
- );
1211
+ throw new Error(`No provider specified in model string: ${modelString}`);
1233
1212
  }
1234
1213
  /**
1235
1214
  * Get generation parameters from provider options
@@ -1293,9 +1272,15 @@ var _ModelFactory = class _ModelFactory {
1293
1272
  }
1294
1273
  };
1295
1274
  /**
1296
- * Supported providers for security validation
1275
+ * Built-in providers that have special handling
1297
1276
  */
1298
- __publicField(_ModelFactory, "SUPPORTED_PROVIDERS", ["anthropic", "openai", "google"]);
1277
+ __publicField(_ModelFactory, "BUILT_IN_PROVIDERS", [
1278
+ "anthropic",
1279
+ "openai",
1280
+ "google",
1281
+ "openrouter",
1282
+ "gateway"
1283
+ ]);
1299
1284
  var ModelFactory = _ModelFactory;
1300
1285
 
1301
1286
  // src/utils/stream-registry.ts
@@ -1633,68 +1618,52 @@ var GraphSession = class {
1633
1618
  }
1634
1619
  const now = Date.now();
1635
1620
  const elapsedTime = now - statusUpdateState.startTime;
1636
- let summaryToSend;
1637
- if (statusUpdateState.config.statusComponents && statusUpdateState.config.statusComponents.length > 0) {
1638
- const result = await this.generateStructuredStatusUpdate(
1639
- this.events.slice(statusUpdateState.lastEventCount),
1640
- elapsedTime,
1641
- statusUpdateState.config.statusComponents,
1642
- statusUpdateState.summarizerModel,
1643
- this.previousSummaries
1644
- );
1645
- if (result.summaries && result.summaries.length > 0) {
1646
- for (const summary of result.summaries) {
1647
- if (!summary || !summary.type || !summary.data || !summary.data.label || Object.keys(summary.data).length === 0) {
1648
- logger6.warn(
1649
- {
1650
- sessionId: this.sessionId,
1651
- summary
1652
- },
1653
- "Skipping empty or invalid structured operation"
1654
- );
1655
- continue;
1656
- }
1657
- const summaryToSend2 = {
1658
- type: summary.data.type || summary.type,
1659
- // Preserve the actual custom type from LLM
1660
- label: summary.data.label,
1661
- details: Object.fromEntries(
1662
- Object.entries(summary.data).filter(([key]) => !["label", "type"].includes(key))
1663
- )
1664
- };
1665
- await streamHelper.writeSummary(summaryToSend2);
1666
- }
1667
- const summaryTexts = result.summaries.map(
1668
- (summary) => JSON.stringify({ type: summary.type, data: summary.data })
1669
- );
1670
- this.previousSummaries.push(...summaryTexts);
1671
- if (this.statusUpdateState) {
1672
- this.statusUpdateState.lastUpdateTime = now;
1673
- this.statusUpdateState.lastEventCount = this.events.length;
1621
+ const statusComponents = statusUpdateState.config.statusComponents && statusUpdateState.config.statusComponents.length > 0 ? statusUpdateState.config.statusComponents : defaultStatusSchemas;
1622
+ const result = await this.generateStructuredStatusUpdate(
1623
+ this.events.slice(statusUpdateState.lastEventCount),
1624
+ elapsedTime,
1625
+ statusComponents,
1626
+ statusUpdateState.summarizerModel,
1627
+ this.previousSummaries
1628
+ );
1629
+ if (result.summaries && result.summaries.length > 0) {
1630
+ for (const summary of result.summaries) {
1631
+ if (!summary || !summary.type || !summary.data || !summary.data.label || Object.keys(summary.data).length === 0) {
1632
+ logger6.warn(
1633
+ {
1634
+ sessionId: this.sessionId,
1635
+ summary
1636
+ },
1637
+ "Skipping empty or invalid structured operation"
1638
+ );
1639
+ continue;
1674
1640
  }
1675
- return;
1641
+ const summaryToSend = {
1642
+ type: summary.data.type || summary.type,
1643
+ // Preserve the actual custom type from LLM
1644
+ label: summary.data.label,
1645
+ details: Object.fromEntries(
1646
+ Object.entries(summary.data).filter(([key]) => !["label", "type"].includes(key))
1647
+ )
1648
+ };
1649
+ await streamHelper.writeSummary(summaryToSend);
1676
1650
  }
1677
- } else {
1678
- const summary = await this.generateProgressSummary(
1679
- this.events.slice(statusUpdateState.lastEventCount),
1680
- elapsedTime,
1681
- statusUpdateState.summarizerModel,
1682
- this.previousSummaries
1651
+ const summaryTexts = result.summaries.map(
1652
+ (summary) => JSON.stringify({ type: summary.type, data: summary.data })
1683
1653
  );
1684
- this.previousSummaries.push(summary);
1654
+ this.previousSummaries.push(...summaryTexts);
1655
+ if (this.statusUpdateState) {
1656
+ this.statusUpdateState.lastUpdateTime = now;
1657
+ this.statusUpdateState.lastEventCount = this.events.length;
1658
+ }
1659
+ return;
1685
1660
  }
1686
1661
  if (this.previousSummaries.length > 3) {
1687
1662
  this.previousSummaries.shift();
1688
1663
  }
1689
- {
1690
- logger6.warn(
1691
- {
1692
- sessionId: this.sessionId,
1693
- summaryToSend
1694
- },
1695
- "Skipping empty or invalid status update operation"
1696
- );
1697
- return;
1664
+ if (this.statusUpdateState) {
1665
+ this.statusUpdateState.lastUpdateTime = now;
1666
+ this.statusUpdateState.lastEventCount = this.events.length;
1698
1667
  }
1699
1668
  } catch (error) {
1700
1669
  logger6.error(
@@ -1775,106 +1744,6 @@ var GraphSession = class {
1775
1744
  this.statusUpdateState.updateLock = false;
1776
1745
  }
1777
1746
  }
1778
- /**
1779
- * Generate user-focused progress summary hiding internal operations
1780
- */
1781
- async generateProgressSummary(newEvents, elapsedTime, summarizerModel, previousSummaries = []) {
1782
- return tracer.startActiveSpan(
1783
- "graph_session.generate_progress_summary",
1784
- {
1785
- attributes: {
1786
- "graph_session.id": this.sessionId,
1787
- "events.count": newEvents.length,
1788
- "elapsed_time.seconds": Math.round(elapsedTime / 1e3),
1789
- "llm.model": summarizerModel?.model,
1790
- "previous_summaries.count": previousSummaries.length
1791
- }
1792
- },
1793
- async (span) => {
1794
- try {
1795
- const userVisibleActivities = this.extractUserVisibleActivities(newEvents);
1796
- let conversationContext = "";
1797
- if (this.tenantId && this.projectId) {
1798
- try {
1799
- const conversationHistory = await getFormattedConversationHistory({
1800
- tenantId: this.tenantId,
1801
- projectId: this.projectId,
1802
- conversationId: this.sessionId,
1803
- options: {
1804
- limit: 10,
1805
- // Get recent conversation context
1806
- maxOutputTokens: 2e3
1807
- },
1808
- filters: {}
1809
- });
1810
- conversationContext = conversationHistory.trim() ? `
1811
- User's Question/Context:
1812
- ${conversationHistory}
1813
- ` : "";
1814
- } catch (error) {
1815
- logger6.warn(
1816
- { sessionId: this.sessionId, error },
1817
- "Failed to fetch conversation history for status update"
1818
- );
1819
- }
1820
- }
1821
- const previousSummaryContext = previousSummaries.length > 0 ? `
1822
- Previous updates provided to user:
1823
- ${previousSummaries.map((s, i) => `${i + 1}. ${s}`).join("\n")}
1824
- ` : "";
1825
- const basePrompt = `Generate a meaningful status update that tells the user what specific information or result was just found/achieved.${conversationContext}${previousSummaries.length > 0 ? `
1826
- ${previousSummaryContext}` : ""}
1827
-
1828
- Activities:
1829
- ${userVisibleActivities.join("\n") || "No New Activities"}
1830
-
1831
- Create a short 3-5 word label describing the ACTUAL finding. Use sentence case (only capitalize the first word and proper nouns). Examples: "Found admin permissions needed", "Identified three channel types", "OAuth token required".
1832
-
1833
- ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
1834
- const prompt = basePrompt;
1835
- let modelToUse = summarizerModel;
1836
- if (!summarizerModel?.model?.trim()) {
1837
- if (!this.statusUpdateState?.baseModel?.model?.trim()) {
1838
- throw new Error(
1839
- "Either summarizer or base model is required for progress summary generation. Please configure models at the project level."
1840
- );
1841
- }
1842
- modelToUse = this.statusUpdateState.baseModel;
1843
- }
1844
- if (!modelToUse) {
1845
- throw new Error("No model configuration available");
1846
- }
1847
- const model = ModelFactory.createModel(modelToUse);
1848
- const { text } = await generateText({
1849
- model,
1850
- prompt,
1851
- experimental_telemetry: {
1852
- isEnabled: true,
1853
- functionId: `status_update_${this.sessionId}`,
1854
- recordInputs: true,
1855
- recordOutputs: true,
1856
- metadata: {
1857
- operation: "progress_summary_generation",
1858
- sessionId: this.sessionId
1859
- }
1860
- }
1861
- });
1862
- span.setAttributes({
1863
- "summary.length": text.trim().length,
1864
- "user_activities.count": userVisibleActivities.length
1865
- });
1866
- span.setStatus({ code: SpanStatusCode.OK });
1867
- return text.trim();
1868
- } catch (error) {
1869
- setSpanWithError(span, error);
1870
- logger6.error({ error }, "Failed to generate summary, using fallback");
1871
- return this.generateFallbackSummary(newEvents, elapsedTime);
1872
- } finally {
1873
- span.end();
1874
- }
1875
- }
1876
- );
1877
- }
1878
1747
  /**
1879
1748
  * Generate structured status update using configured data components
1880
1749
  */
@@ -1953,17 +1822,45 @@ Rules:
1953
1822
  - Fill in data for relevant components only
1954
1823
  - Use 'no_relevant_updates' if nothing substantially new to report. DO NOT WRITE LABELS OR USE OTHER COMPONENTS IF YOU USE THIS COMPONENT.
1955
1824
  - Never repeat previous values, make every update EXTREMELY unique. If you cannot do that the update is not worth mentioning.
1956
- - Labels MUST be short 3-5 word phrases with ACTUAL information discovered. NEVER MAKE UP SOMETHING WITHOUT BACKING IT UP WITH ACTUAL INFORMATION.
1825
+ - Labels MUST be short 3-7 word phrases with ACTUAL information discovered. NEVER MAKE UP SOMETHING WITHOUT BACKING IT UP WITH ACTUAL INFORMATION.
1957
1826
  - Use sentence case: only capitalize the first word and proper nouns (e.g., "Admin permissions required", not "Admin Permissions Required"). ALWAYS capitalize the first word of the label.
1958
1827
  - DO NOT use action words like "Searching", "Processing", "Analyzing" - state what was FOUND
1959
1828
  - Include specific details, numbers, requirements, or insights discovered
1960
1829
  - Examples: "Admin permissions required", "Three OAuth steps found", "Token expires daily"
1961
- - You are ONE unified AI system - NEVER mention agents, transfers, delegations, or routing
1962
- - CRITICAL: NEVER use the words "transfer", "delegation", "agent", "routing", "artifact", or any internal system terminology in labels or any names of agents, tools, or systems.
1963
- - Present all operations as seamless actions by a single system
1964
- - Anonymize all internal operations so that the information appears descriptive and USER FRIENDLY. HIDE ALL INTERNAL OPERATIONS!
1965
- - Bad examples: "Transferring to search agent", "continuing transfer to qa agent", "Delegating task", "Routing request", "Processing request", "Artifact found", "Artifact saved", or not using the no_relevant_updates
1966
- - Good examples: "Slack bot needs admin privileges", "Found 3-step OAuth flow required", "Channel limit is 500 per workspace", or use the no_relevant_updates component if nothing new to report.
1830
+
1831
+ CRITICAL - HIDE ALL INTERNAL SYSTEM OPERATIONS:
1832
+ - You are ONE unified AI system presenting results to the user
1833
+ - ABSOLUTELY FORBIDDEN WORDS/PHRASES: "transfer", "transferring", "delegation", "delegating", "delegate", "agent", "routing", "route", "artifact", "saving artifact", "stored artifact", "artifact saved", "continuing", "passing to", "handing off", "switching to"
1834
+ - NEVER reveal internal architecture: No mentions of different agents, components, systems, or modules working together
1835
+ - NEVER mention artifact operations: Users don't need to know about data being saved, stored, or organized internally
1836
+ - NEVER describe handoffs or transitions: Present everything as one seamless operation
1837
+ - If you see "transfer", "delegation_sent", "delegation_returned", or "artifact_saved" events - IGNORE THEM or translate to user-facing information only
1838
+ - Focus ONLY on actual discoveries, findings, and results that matter to the user
1839
+
1840
+ - Bad examples:
1841
+ * "Transferring to search agent"
1842
+ * "Delegating research task"
1843
+ * "Routing to QA specialist"
1844
+ * "Artifact saved successfully"
1845
+ * "Storing results for later"
1846
+ * "Passing request to tool handler"
1847
+ * "Continuing with analysis"
1848
+ * "Handing off to processor"
1849
+ - Good examples:
1850
+ * "Slack bot needs admin privileges"
1851
+ * "Found 3-step OAuth flow required"
1852
+ * "Channel limit is 500 per workspace"
1853
+ * Use no_relevant_updates if nothing new to report
1854
+
1855
+ CRITICAL ANTI-HALLUCINATION RULES:
1856
+ - NEVER MAKE UP SOMETHING WITHOUT BACKING IT UP WITH ACTUAL INFORMATION. EVERY SINGLE UPDATE MUST BE BACKED UP WITH ACTUAL INFORMATION.
1857
+ - DO NOT MAKE UP PEOPLE, NAMES, PLACES, THINGS, ORGANIZATIONS, OR INFORMATION. IT IS OBVIOUS WHEN A PERSON/ENTITY DOES NOT EXIST.
1858
+ - Only report facts that are EXPLICITLY mentioned in the activities or tool results
1859
+ - If you don't have concrete information about something, DO NOT mention it
1860
+ - Never invent names like "John Doe", "Alice", "Bob", or any other placeholder names
1861
+ - Never create fictional companies, products, or services
1862
+ - If a tool returned no results or an error, DO NOT pretend it found something
1863
+ - Every detail in your status update must be traceable back to the actual activities provided
1967
1864
 
1968
1865
  REMEMBER YOU CAN ONLY USE 'no_relevant_updates' ALONE! IT CANNOT BE CONCATENATED WITH OTHER STATUS UPDATES!
1969
1866
 
@@ -2036,7 +1933,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2036
1933
  }
2037
1934
  return z.object({
2038
1935
  label: z.string().describe(
2039
- 'A short 3-5 word phrase, that is a descriptive label for the update component. This Label must be EXTREMELY unique to represent the UNIQUE update we are providing. The ACTUAL finding or result, not the action. What specific information was discovered? (e.g., "Slack requires OAuth 2.0 setup", "Found 5 integration methods", "API rate limit is 100/minute"). Include the actual detail or insight, not just that you searched or processed.'
1936
+ 'A short 3-5 word phrase, that is a descriptive label for the update component. This Label must be EXTREMELY unique to represent the UNIQUE update we are providing. The ACTUAL finding or result, not the action. What specific information was discovered? (e.g., "Slack requires OAuth 2.0 setup", "Found 5 integration methods", "API rate limit is 100/minute"). Include the actual detail or insight, not just that you searched or processed. CRITICAL: Only use facts explicitly found in the activities - NEVER invent names, people, organizations, or details that are not present in the actual tool results.'
2040
1937
  )
2041
1938
  });
2042
1939
  }
@@ -2046,7 +1943,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2046
1943
  buildZodSchemaFromJson(jsonSchema) {
2047
1944
  const properties = {};
2048
1945
  properties["label"] = z.string().describe(
2049
- 'A short 3-5 word phrase, that is a descriptive label for the update component. This Label must be EXTREMELY unique to represent the UNIQUE update we are providing. The SPECIFIC finding, result, or insight discovered (e.g., "Slack bot needs workspace admin role", "Found ingestion requires 3 steps", "Channel history limited to 10k messages"). State the ACTUAL information found, not that you searched. What did you LEARN or DISCOVER? What specific detail is now known?'
1946
+ 'A short 3-5 word phrase, that is a descriptive label for the update component. This Label must be EXTREMELY unique to represent the UNIQUE update we are providing. The SPECIFIC finding, result, or insight discovered (e.g., "Slack bot needs workspace admin role", "Found ingestion requires 3 steps", "Channel history limited to 10k messages"). State the ACTUAL information found, not that you searched. What did you LEARN or DISCOVER? What specific detail is now known? CRITICAL: Only use facts explicitly found in the activities - NEVER invent names, people, organizations, or details that are not present in the actual tool results.'
2050
1947
  );
2051
1948
  for (const [key, value] of Object.entries(jsonSchema.properties)) {
2052
1949
  let zodType;
@@ -2123,41 +2020,12 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2123
2020
  );
2124
2021
  break;
2125
2022
  }
2126
- case "transfer": {
2127
- const data = event.data;
2128
- activities.push(
2129
- `\u{1F504} **Continuing**: ${data.reason || "Processing request"}
2130
- ${data.context ? `Context: ${JSON.stringify(data.context, null, 2)}` : ""}`
2131
- );
2023
+ // INTERNAL OPERATIONS - DO NOT EXPOSE TO STATUS UPDATES
2024
+ case "transfer":
2025
+ case "delegation_sent":
2026
+ case "delegation_returned":
2027
+ case "artifact_saved":
2132
2028
  break;
2133
- }
2134
- case "delegation_sent": {
2135
- const data = event.data;
2136
- activities.push(
2137
- `\u{1F4E4} **Processing**: ${data.taskDescription}
2138
- ${data.context ? `Context: ${JSON.stringify(data.context, null, 2)}` : ""}`
2139
- );
2140
- break;
2141
- }
2142
- case "delegation_returned": {
2143
- const data = event.data;
2144
- activities.push(
2145
- `\u{1F4E5} **Completed subtask**
2146
- Result: ${JSON.stringify(data.result, null, 2)}`
2147
- );
2148
- break;
2149
- }
2150
- case "artifact_saved": {
2151
- const data = event.data;
2152
- activities.push(
2153
- `\u{1F4BE} **Artifact Saved**: ${data.artifactType}
2154
- ID: ${data.artifactId}
2155
- Task: ${data.taskId}
2156
- ${data.summaryData ? `Summary: ${data.summaryData}` : ""}
2157
- ${data.fullData ? `Full Data: ${data.fullData}` : ""}`
2158
- );
2159
- break;
2160
- }
2161
2029
  case "agent_reasoning": {
2162
2030
  const data = event.data;
2163
2031
  activities.push(
@@ -2182,21 +2050,6 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2182
2050
  }
2183
2051
  return activities;
2184
2052
  }
2185
- /**
2186
- * Generate fallback summary when LLM fails
2187
- */
2188
- generateFallbackSummary(events, elapsedTime) {
2189
- const timeStr = Math.round(elapsedTime / 1e3);
2190
- const toolCalls = events.filter((e) => e.eventType === "tool_execution").length;
2191
- const artifacts = events.filter((e) => e.eventType === "artifact_saved").length;
2192
- if (artifacts > 0) {
2193
- return `Generated ${artifacts} result${artifacts > 1 ? "s" : ""} so far (${timeStr}s elapsed)`;
2194
- } else if (toolCalls > 0) {
2195
- return `Used ${toolCalls} tool${toolCalls > 1 ? "s" : ""} to gather information (${timeStr}s elapsed)`;
2196
- } else {
2197
- return `Processing your request... (${timeStr}s elapsed)`;
2198
- }
2199
- }
2200
2053
  /**
2201
2054
  * Process a single artifact to generate name and description using conversation context
2202
2055
  */
@@ -2233,7 +2086,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2233
2086
  );
2234
2087
  }
2235
2088
  span.setAttributes({ "validation.passed": true });
2236
- const { getFormattedConversationHistory: getFormattedConversationHistory2 } = await import('./conversations-WDOIWO7W.js');
2089
+ const { getFormattedConversationHistory: getFormattedConversationHistory2 } = await import('./conversations-OVETKXSP.js');
2237
2090
  const conversationHistory = await getFormattedConversationHistory2({
2238
2091
  tenantId: artifactData.tenantId,
2239
2092
  projectId: artifactData.projectId,
@@ -2947,7 +2800,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
2947
2800
  await this.streamPart(part);
2948
2801
  }
2949
2802
  if (this.pendingTextBuffer) {
2950
- const cleanedText = this.pendingTextBuffer.replace(/<\/?artifact:ref(?:\s[^>]*)?>\/?>/g, "").replace(/<\/?artifact(?:\s[^>]*)?>\/?>/g, "").replace(/<\/(?:\w+:)?artifact>/g, "");
2803
+ const cleanedText = this.pendingTextBuffer.replace(/<\/?artifact:ref(?:\s[^>]*)?>\/?>/g, "").replace(/<\/?artifact(?:\s[^>]*)?>\/?>/g, "").replace(/<\/artifact:ref>/g, "").replace(/<\/(?:\w+:)?artifact>/g, "");
2951
2804
  if (cleanedText) {
2952
2805
  this.collectedParts.push({
2953
2806
  kind: "text",
@@ -3025,7 +2878,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3025
2878
  if (part.kind === "text" && part.text) {
3026
2879
  this.pendingTextBuffer += part.text;
3027
2880
  if (!this.artifactParser.hasIncompleteArtifact(this.pendingTextBuffer)) {
3028
- const cleanedText = this.pendingTextBuffer.replace(/<\/?artifact:ref(?:\s[^>]*)?>\/?>/g, "").replace(/<\/?artifact(?:\s[^>]*)?>\/?>/g, "").replace(/<\/(?:\w+:)?artifact>/g, "");
2881
+ const cleanedText = this.pendingTextBuffer.replace(/<\/?artifact:ref(?:\s[^>]*)?>\/?>/g, "").replace(/<\/?artifact(?:\s[^>]*)?>\/?>/g, "").replace(/<\/artifact:ref>/g, "").replace(/<\/(?:\w+:)?artifact>/g, "");
3029
2882
  if (cleanedText) {
3030
2883
  await this.streamHelper.streamText(cleanedText, 50);
3031
2884
  }
@@ -3033,7 +2886,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3033
2886
  }
3034
2887
  } else if (part.kind === "data" && part.data) {
3035
2888
  if (this.pendingTextBuffer) {
3036
- const cleanedText = this.pendingTextBuffer.replace(/<\/?artifact:ref(?:\s[^>]*)?>\/?>/g, "").replace(/<\/?artifact(?:\s[^>]*)?>\/?>/g, "").replace(/<\/(?:\w+:)?artifact>/g, "");
2889
+ const cleanedText = this.pendingTextBuffer.replace(/<\/?artifact:ref(?:\s[^>]*)?>\/?>/g, "").replace(/<\/?artifact(?:\s[^>]*)?>\/?>/g, "").replace(/<\/artifact:ref>/g, "").replace(/<\/(?:\w+:)?artifact>/g, "");
3037
2890
  if (cleanedText) {
3038
2891
  await this.streamHelper.streamText(cleanedText, 50);
3039
2892
  }
@@ -7007,7 +6860,7 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
7007
6860
  __publicField(this, "queuedEvents", []);
7008
6861
  // Timing tracking for text sequences (text-end to text-start gap)
7009
6862
  __publicField(this, "lastTextEndTimestamp", 0);
7010
- __publicField(this, "TEXT_GAP_THRESHOLD", 50);
6863
+ __publicField(this, "TEXT_GAP_THRESHOLD", 2e3);
7011
6864
  // milliseconds - if gap between text sequences is less than this, queue operations
7012
6865
  // Connection management and forced cleanup
7013
6866
  __publicField(this, "connectionDropTimer");
@@ -9017,21 +8870,21 @@ function createExecutionHono(serverConfig, credentialStores) {
9017
8870
  app6.route("/v1/mcp", mcp_default);
9018
8871
  app6.route("/agents", agents_default);
9019
8872
  setupOpenAPIRoutes(app6);
9020
- app6.use("/tenants/*", async (c, next) => {
8873
+ app6.use("/tenants/*", async (_c, next) => {
9021
8874
  await next();
9022
- await batchProcessor.forceFlush();
8875
+ await defaultBatchProcessor.forceFlush();
9023
8876
  });
9024
- app6.use("/agents/*", async (c, next) => {
8877
+ app6.use("/agents/*", async (_c, next) => {
9025
8878
  await next();
9026
- await batchProcessor.forceFlush();
8879
+ await defaultBatchProcessor.forceFlush();
9027
8880
  });
9028
- app6.use("/v1/*", async (c, next) => {
8881
+ app6.use("/v1/*", async (_c, next) => {
9029
8882
  await next();
9030
- await batchProcessor.forceFlush();
8883
+ await defaultBatchProcessor.forceFlush();
9031
8884
  });
9032
- app6.use("/api/*", async (c, next) => {
8885
+ app6.use("/api/*", async (_c, next) => {
9033
8886
  await next();
9034
- await batchProcessor.forceFlush();
8887
+ await defaultBatchProcessor.forceFlush();
9035
8888
  });
9036
8889
  const baseApp = new Hono();
9037
8890
  baseApp.route("/", app6);