@inkeep/agents-core 0.17.0 → 0.18.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.
Files changed (36) hide show
  1. package/README.md +2 -2
  2. package/dist/{chunk-TO2HNKGP.js → chunk-E4SFK6AI.js} +143 -157
  3. package/dist/{chunk-VPJ6Z5QZ.js → chunk-ID4CFGVF.js} +202 -131
  4. package/dist/chunk-JTHQYGCX.js +173 -0
  5. package/dist/chunk-TCLX6C3C.js +271 -0
  6. package/dist/client-exports.cjs +622 -272
  7. package/dist/client-exports.d.cts +6 -5
  8. package/dist/client-exports.d.ts +6 -5
  9. package/dist/client-exports.js +5 -4
  10. package/dist/db/schema.cjs +201 -130
  11. package/dist/db/schema.d.cts +2 -2
  12. package/dist/db/schema.d.ts +2 -2
  13. package/dist/db/schema.js +1 -1
  14. package/dist/index.cjs +2734 -1831
  15. package/dist/index.d.cts +1664 -1544
  16. package/dist/index.d.ts +1664 -1544
  17. package/dist/index.js +1953 -1467
  18. package/dist/{schema-BQk_FMBV.d.ts → schema-Bjy5TkFv.d.cts} +473 -172
  19. package/dist/{schema-Ct2NlO81.d.cts → schema-CfWbqju2.d.ts} +473 -172
  20. package/dist/signoz-queries-CifqdbnO.d.cts +269 -0
  21. package/dist/signoz-queries-CifqdbnO.d.ts +269 -0
  22. package/dist/types/index.d.cts +2 -2
  23. package/dist/types/index.d.ts +2 -2
  24. package/dist/{utility-s9c5CVOe.d.cts → utility-Fxoh7s82.d.cts} +585 -384
  25. package/dist/{utility-s9c5CVOe.d.ts → utility-Fxoh7s82.d.ts} +585 -384
  26. package/dist/validation/index.cjs +429 -325
  27. package/dist/validation/index.d.cts +76 -4
  28. package/dist/validation/index.d.ts +76 -4
  29. package/dist/validation/index.js +2 -2
  30. package/drizzle/0005_wide_shriek.sql +127 -0
  31. package/drizzle/0006_damp_lenny_balinger.sql +52 -0
  32. package/drizzle/meta/0005_snapshot.json +2558 -0
  33. package/drizzle/meta/0006_snapshot.json +2751 -0
  34. package/drizzle/meta/_journal.json +14 -0
  35. package/package.json +1 -1
  36. package/dist/chunk-L53XWAYG.js +0 -134
@@ -0,0 +1,173 @@
1
+ import { GraphWithinContextOfProjectSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-E4SFK6AI.js';
2
+ import { z } from 'zod';
3
+
4
+ var TransferDataSchema = z.object({
5
+ fromSubAgent: z.string().describe("ID of the sub-agent transferring control"),
6
+ targetSubAgent: z.string().describe("ID of the sub-agent receiving control"),
7
+ reason: z.string().optional().describe("Reason for the transfer"),
8
+ context: z.any().optional().describe("Additional context data")
9
+ });
10
+ var DelegationSentDataSchema = z.object({
11
+ delegationId: z.string().describe("Unique identifier for this delegation"),
12
+ fromSubAgent: z.string().describe("ID of the delegating sub-agent"),
13
+ targetSubAgent: z.string().describe("ID of the sub-agent receiving the delegation"),
14
+ taskDescription: z.string().describe("Description of the delegated task"),
15
+ context: z.any().optional().describe("Additional context data")
16
+ });
17
+ var DelegationReturnedDataSchema = z.object({
18
+ delegationId: z.string().describe("Unique identifier matching the original delegation"),
19
+ fromSubAgent: z.string().describe("ID of the sub-agent that completed the task"),
20
+ targetSubAgent: z.string().describe("ID of the sub-agent receiving the result"),
21
+ result: z.any().optional().describe("Result data from the delegated task")
22
+ });
23
+ var DataOperationDetailsSchema = z.object({
24
+ timestamp: z.number().describe("Unix timestamp in milliseconds"),
25
+ subAgentId: z.string().describe("ID of the sub-agent that generated this data"),
26
+ data: z.any().describe("The actual data payload")
27
+ });
28
+ var DataOperationEventSchema = z.object({
29
+ type: z.string().describe("Event type identifier"),
30
+ label: z.string().describe("Human-readable label for the event"),
31
+ details: DataOperationDetailsSchema
32
+ });
33
+ var A2AMessageMetadataSchema = z.object({
34
+ fromSubAgentId: z.string().optional().describe("ID of the sending sub-agent"),
35
+ toSubAgentId: z.string().optional().describe("ID of the receiving sub-agent"),
36
+ fromExternalAgentId: z.string().optional().describe("ID of the sending external agent"),
37
+ toExternalAgentId: z.string().optional().describe("ID of the receiving external agent"),
38
+ taskId: z.string().optional().describe("Associated task ID"),
39
+ a2aTaskId: z.string().optional().describe("A2A-specific task ID")
40
+ });
41
+
42
+ // src/validation/graphFull.ts
43
+ function isInternalAgent(agent) {
44
+ return "prompt" in agent;
45
+ }
46
+ function isExternalAgent(agent) {
47
+ return "baseUrl" in agent;
48
+ }
49
+ function validateAndTypeGraphData(data) {
50
+ return GraphWithinContextOfProjectSchema.parse(data);
51
+ }
52
+ function validateToolReferences(graphData, availableToolIds) {
53
+ if (!availableToolIds) {
54
+ return;
55
+ }
56
+ const errors = [];
57
+ for (const [subAgentId, agentData] of Object.entries(graphData.subAgents)) {
58
+ if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
59
+ for (const canUseItem of agentData.canUse) {
60
+ if (!availableToolIds.has(canUseItem.toolId)) {
61
+ errors.push(`Agent '${subAgentId}' references non-existent tool '${canUseItem.toolId}'`);
62
+ }
63
+ }
64
+ }
65
+ }
66
+ if (errors.length > 0) {
67
+ throw new Error(`Tool reference validation failed:
68
+ ${errors.join("\n")}`);
69
+ }
70
+ }
71
+ function validateDataComponentReferences(graphData, availableDataComponentIds) {
72
+ if (!availableDataComponentIds) {
73
+ return;
74
+ }
75
+ const errors = [];
76
+ for (const [subAgentId, agentData] of Object.entries(graphData.subAgents)) {
77
+ if (isInternalAgent(agentData) && agentData.dataComponents) {
78
+ for (const dataComponentId of agentData.dataComponents) {
79
+ if (!availableDataComponentIds.has(dataComponentId)) {
80
+ errors.push(
81
+ `Agent '${subAgentId}' references non-existent dataComponent '${dataComponentId}'`
82
+ );
83
+ }
84
+ }
85
+ }
86
+ }
87
+ if (errors.length > 0) {
88
+ throw new Error(`DataComponent reference validation failed:
89
+ ${errors.join("\n")}`);
90
+ }
91
+ }
92
+ function validateArtifactComponentReferences(graphData, availableArtifactComponentIds) {
93
+ if (!availableArtifactComponentIds) {
94
+ return;
95
+ }
96
+ const errors = [];
97
+ for (const [subAgentId, agentData] of Object.entries(graphData.subAgents)) {
98
+ if (isInternalAgent(agentData) && agentData.artifactComponents) {
99
+ for (const artifactComponentId of agentData.artifactComponents) {
100
+ if (!availableArtifactComponentIds.has(artifactComponentId)) {
101
+ errors.push(
102
+ `Agent '${subAgentId}' references non-existent artifactComponent '${artifactComponentId}'`
103
+ );
104
+ }
105
+ }
106
+ }
107
+ }
108
+ if (errors.length > 0) {
109
+ throw new Error(`ArtifactComponent reference validation failed:
110
+ ${errors.join("\n")}`);
111
+ }
112
+ }
113
+ function validateAgentRelationships(graphData) {
114
+ const errors = [];
115
+ const availableAgentIds = new Set(Object.keys(graphData.subAgents));
116
+ for (const [subAgentId, agentData] of Object.entries(graphData.subAgents)) {
117
+ if (isInternalAgent(agentData)) {
118
+ if (agentData.canTransferTo && Array.isArray(agentData.canTransferTo)) {
119
+ for (const targetId of agentData.canTransferTo) {
120
+ if (!availableAgentIds.has(targetId)) {
121
+ errors.push(
122
+ `Agent '${subAgentId}' has transfer target '${targetId}' that doesn't exist in graph`
123
+ );
124
+ }
125
+ }
126
+ }
127
+ if (agentData.canDelegateTo && Array.isArray(agentData.canDelegateTo)) {
128
+ for (const targetId of agentData.canDelegateTo) {
129
+ if (!availableAgentIds.has(targetId)) {
130
+ errors.push(
131
+ `Agent '${subAgentId}' has delegation target '${targetId}' that doesn't exist in graph`
132
+ );
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ if (errors.length > 0) {
139
+ throw new Error(`Agent relationship validation failed:
140
+ ${errors.join("\n")}`);
141
+ }
142
+ }
143
+ function validateGraphStructure(graphData, projectResources) {
144
+ if (graphData.defaultSubAgentId && !graphData.subAgents[graphData.defaultSubAgentId]) {
145
+ throw new Error(`Default agent '${graphData.defaultSubAgentId}' does not exist in agents`);
146
+ }
147
+ if (projectResources) {
148
+ validateToolReferences(graphData, projectResources.toolIds);
149
+ validateDataComponentReferences(graphData, projectResources.dataComponentIds);
150
+ validateArtifactComponentReferences(graphData, projectResources.artifactComponentIds);
151
+ }
152
+ validateAgentRelationships(graphData);
153
+ }
154
+
155
+ // src/validation/id-validation.ts
156
+ function isValidResourceId(id) {
157
+ const result = resourceIdSchema.safeParse(id);
158
+ return result.success;
159
+ }
160
+ function generateIdFromName(name) {
161
+ const id = name.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-");
162
+ if (!id) {
163
+ throw new Error("Cannot generate valid ID from provided name");
164
+ }
165
+ const truncatedId = id.substring(0, MAX_ID_LENGTH);
166
+ const result = resourceIdSchema.safeParse(truncatedId);
167
+ if (!result.success) {
168
+ throw new Error(`Generated ID "${truncatedId}" is not valid: ${result.error.message}`);
169
+ }
170
+ return truncatedId;
171
+ }
172
+
173
+ export { A2AMessageMetadataSchema, DataOperationDetailsSchema, DataOperationEventSchema, DelegationReturnedDataSchema, DelegationSentDataSchema, TransferDataSchema, generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAndTypeGraphData, validateArtifactComponentReferences, validateDataComponentReferences, validateGraphStructure, validateToolReferences };
@@ -0,0 +1,271 @@
1
+ // src/constants/otel-attributes.ts
2
+ var DELEGATION_FROM_SUB_AGENT_ID = "delegation.from_sub_agent_id";
3
+ var DELEGATION_TO_SUB_AGENT_ID = "delegation.to_sub_agent_id";
4
+ var DELEGATION_ID = "delegation.id";
5
+ var TRANSFER_FROM_SUB_AGENT_ID = "transfer.from_sub_agent_id";
6
+ var TRANSFER_TO_SUB_AGENT_ID = "transfer.to_sub_agent_id";
7
+ var SPAN_NAMES = {
8
+ AI_TOOL_CALL: "ai.toolCall",
9
+ CONTEXT_RESOLUTION: "context-resolver.resolve_single_fetch_definition",
10
+ CONTEXT_HANDLE: "context.handle_context_resolution",
11
+ AGENT_GENERATION: "agent.generate",
12
+ CONTEXT_FETCHER: "context-fetcher.http-request"
13
+ };
14
+ var AI_OPERATIONS = {
15
+ GENERATE_TEXT: "ai.generateText.doGenerate",
16
+ STREAM_TEXT: "ai.streamText.doStream"
17
+ };
18
+ var SPAN_KEYS = {
19
+ // Core span attributes
20
+ SPAN_ID: "spanID",
21
+ TRACE_ID: "traceID",
22
+ DURATION_NANO: "durationNano",
23
+ TIMESTAMP: "timestamp",
24
+ HAS_ERROR: "hasError",
25
+ STATUS_MESSAGE: "status_message",
26
+ OTEL_STATUS_CODE: "otel.status_code",
27
+ OTEL_STATUS_DESCRIPTION: "otel.status_description",
28
+ // Graph attributes
29
+ GRAPH_ID: "graph.id",
30
+ GRAPH_NAME: "graph.name",
31
+ TENANT_ID: "tenant.id",
32
+ PROJECT_ID: "project.id",
33
+ // AI/Agent attributes
34
+ AI_AGENT_NAME: "ai.agentName",
35
+ AI_AGENT_NAME_ALT: "ai.agent.name",
36
+ AI_OPERATION_ID: "ai.operationId",
37
+ AI_RESPONSE_TIMESTAMP: "ai.response.timestamp",
38
+ AI_RESPONSE_CONTENT: "ai.response.content",
39
+ AI_RESPONSE_TEXT: "ai.response.text",
40
+ AI_RESPONSE_MODEL: "ai.response.model",
41
+ AI_RESPONSE_TOOL_CALLS: "ai.response.toolCalls",
42
+ AI_PROMPT_MESSAGES: "ai.prompt.messages",
43
+ AI_MODEL_PROVIDER: "ai.model.provider",
44
+ AI_TELEMETRY_FUNCTION_ID: "ai.telemetry.functionId",
45
+ AI_MODEL_ID: "ai.model.id",
46
+ // Tool attributes
47
+ AI_TOOL_CALL_NAME: "ai.toolCall.name",
48
+ AI_TOOL_CALL_RESULT: "ai.toolCall.result",
49
+ AI_TOOL_CALL_ARGS: "ai.toolCall.args",
50
+ AI_TOOL_CALL_ID: "ai.toolCall.id",
51
+ AI_TOOL_TYPE: "ai.toolType",
52
+ TOOL_PURPOSE: "tool.purpose",
53
+ // Agent attributes
54
+ AGENT_ID: "agent.id",
55
+ AGENT_NAME: "agent.name",
56
+ // Token usage
57
+ GEN_AI_USAGE_INPUT_TOKENS: "gen_ai.usage.input_tokens",
58
+ GEN_AI_USAGE_OUTPUT_TOKENS: "gen_ai.usage.output_tokens",
59
+ // Context attributes
60
+ CONTEXT_URL: "context.url",
61
+ CONTEXT_CONFIG_ID: "context.context_config_id",
62
+ CONTEXT_AGENT_GRAPH_ID: "context.agent_graph_id",
63
+ CONTEXT_HEADERS_KEYS: "context.headers_keys",
64
+ // Message attributes
65
+ MESSAGE_CONTENT: "message.content",
66
+ MESSAGE_TIMESTAMP: "message.timestamp",
67
+ MCP_TOOL_DESCRIPTION: "mcp.tool.description",
68
+ // Delegation/Transfer attributes
69
+ DELEGATION_FROM_SUB_AGENT_ID,
70
+ DELEGATION_TO_SUB_AGENT_ID,
71
+ DELEGATION_ID,
72
+ TRANSFER_FROM_SUB_AGENT_ID,
73
+ TRANSFER_TO_SUB_AGENT_ID,
74
+ // HTTP attributes
75
+ HTTP_URL: "http.url",
76
+ HTTP_STATUS_CODE: "http.status_code",
77
+ HTTP_RESPONSE_BODY_SIZE: "http.response.body_size",
78
+ // Core attributes
79
+ NAME: "name",
80
+ PARENT_SPAN_ID: "parentSpanID",
81
+ CONVERSATION_ID: "conversation.id"
82
+ };
83
+ var UNKNOWN_VALUE = "unknown";
84
+ var ACTIVITY_TYPES = {
85
+ TOOL_CALL: "tool_call",
86
+ AI_GENERATION: "ai_generation",
87
+ AGENT_GENERATION: "agent_generation",
88
+ CONTEXT_FETCH: "context_fetch",
89
+ CONTEXT_RESOLUTION: "context_resolution",
90
+ USER_MESSAGE: "user_message",
91
+ AI_ASSISTANT_MESSAGE: "ai_assistant_message",
92
+ AI_MODEL_STREAMED_TEXT: "ai_model_streamed_text"
93
+ };
94
+ var ACTIVITY_STATUS = {
95
+ SUCCESS: "success",
96
+ ERROR: "error",
97
+ PENDING: "pending"
98
+ };
99
+ var AGENT_IDS = {
100
+ USER: "user",
101
+ AI_ASSISTANT: "ai-assistant"
102
+ };
103
+ var ACTIVITY_NAMES = {
104
+ CONTEXT_FETCH: "Context Fetch",
105
+ USER_MESSAGE: "User Message",
106
+ AI_ASSISTANT_MESSAGE: "AI Assistant Message",
107
+ AI_TEXT_GENERATION: "AI Text Generation",
108
+ AI_STREAMING_TEXT: "AI Streaming Text",
109
+ UNKNOWN_AGENT: "Unknown Agent",
110
+ USER: "User"
111
+ };
112
+ var TOOL_NAMES = {
113
+ SAVE_TOOL_RESULT: "save_tool_result"
114
+ };
115
+ var AI_TOOL_TYPES = {
116
+ MCP: "mcp",
117
+ TRANSFER: "transfer",
118
+ DELEGATION: "delegation"
119
+ };
120
+
121
+ // src/constants/signoz-queries.ts
122
+ var DATA_TYPES = {
123
+ STRING: "string",
124
+ INT64: "int64",
125
+ FLOAT64: "float64",
126
+ BOOL: "bool"
127
+ };
128
+ var FIELD_TYPES = {
129
+ TAG: "tag",
130
+ RESOURCE: "resource"
131
+ };
132
+ var QUERY_FIELD_CONFIGS = {
133
+ // String tag fields
134
+ STRING_TAG: {
135
+ dataType: DATA_TYPES.STRING,
136
+ type: FIELD_TYPES.TAG,
137
+ isColumn: false
138
+ },
139
+ STRING_TAG_COLUMN: {
140
+ dataType: DATA_TYPES.STRING,
141
+ type: FIELD_TYPES.TAG,
142
+ isColumn: true
143
+ },
144
+ // Numeric tag fields
145
+ INT64_TAG: {
146
+ dataType: DATA_TYPES.INT64,
147
+ type: FIELD_TYPES.TAG,
148
+ isColumn: false
149
+ },
150
+ INT64_TAG_COLUMN: {
151
+ dataType: DATA_TYPES.INT64,
152
+ type: FIELD_TYPES.TAG,
153
+ isColumn: true
154
+ },
155
+ FLOAT64_TAG: {
156
+ dataType: DATA_TYPES.FLOAT64,
157
+ type: FIELD_TYPES.TAG,
158
+ isColumn: false
159
+ },
160
+ FLOAT64_TAG_COLUMN: {
161
+ dataType: DATA_TYPES.FLOAT64,
162
+ type: FIELD_TYPES.TAG,
163
+ isColumn: true
164
+ },
165
+ // Boolean tag fields
166
+ BOOL_TAG: {
167
+ dataType: DATA_TYPES.BOOL,
168
+ type: FIELD_TYPES.TAG,
169
+ isColumn: false
170
+ },
171
+ BOOL_TAG_COLUMN: {
172
+ dataType: DATA_TYPES.BOOL,
173
+ type: FIELD_TYPES.TAG,
174
+ isColumn: true
175
+ }
176
+ };
177
+ var OPERATORS = {
178
+ // Comparison operators
179
+ EQUALS: "=",
180
+ NOT_EQUALS: "!=",
181
+ LESS_THAN: "<",
182
+ GREATER_THAN: ">",
183
+ LESS_THAN_OR_EQUAL: "<=",
184
+ GREATER_THAN_OR_EQUAL: ">=",
185
+ // String operators
186
+ LIKE: "like",
187
+ NOT_LIKE: "nlike",
188
+ // Existence operators
189
+ EXISTS: "exists",
190
+ NOT_EXISTS: "nexists",
191
+ // Logical operators
192
+ AND: "AND",
193
+ OR: "OR"
194
+ };
195
+ var QUERY_EXPRESSIONS = {
196
+ SPAN_NAMES: "spanNames",
197
+ AGENT_MODEL_CALLS: "agentModelCalls",
198
+ MODEL_CALLS: "modelCalls",
199
+ LAST_ACTIVITY: "lastActivity",
200
+ CONVERSATION_METADATA: "conversationMetadata",
201
+ FILTERED_CONVERSATIONS: "filteredConversations",
202
+ TOOLS: "tools",
203
+ TRANSFERS: "transfers",
204
+ DELEGATIONS: "delegations",
205
+ AI_CALLS: "aiCalls",
206
+ CONTEXT_ERRORS: "contextErrors",
207
+ AGENT_GENERATION_ERRORS: "agentGenerationErrors",
208
+ USER_MESSAGES: "userMessages",
209
+ UNIQUE_GRAPHS: "uniqueGraphs",
210
+ UNIQUE_MODELS: "uniqueModels",
211
+ // Route-specific query names
212
+ TOOL_CALLS: "toolCalls",
213
+ CONTEXT_RESOLUTION: "contextResolution",
214
+ CONTEXT_HANDLE: "contextHandle",
215
+ AI_ASSISTANT_MESSAGES: "aiAssistantMessages",
216
+ AI_GENERATIONS: "aiGenerations",
217
+ AI_STREAMING_TEXT: "aiStreamingText",
218
+ CONTEXT_FETCHERS: "contextFetchers",
219
+ DURATION_SPANS: "durationSpans",
220
+ AGENT_GENERATIONS: "agentGenerations",
221
+ SPANS_WITH_ERRORS: "spansWithErrors"
222
+ };
223
+ var REDUCE_OPERATIONS = {
224
+ SUM: "sum",
225
+ MAX: "max",
226
+ MIN: "min",
227
+ AVG: "avg",
228
+ COUNT: "count"
229
+ };
230
+ var ORDER_DIRECTIONS = {
231
+ ASC: "asc",
232
+ DESC: "desc"
233
+ };
234
+ var QUERY_TYPES = {
235
+ BUILDER: "builder",
236
+ CLICKHOUSE: "clickhouse",
237
+ PROMQL: "promql"
238
+ };
239
+ var PANEL_TYPES = {
240
+ LIST: "list",
241
+ TABLE: "table",
242
+ GRAPH: "graph",
243
+ VALUE: "value"
244
+ };
245
+ var DATA_SOURCES = {
246
+ TRACES: "traces",
247
+ METRICS: "metrics",
248
+ LOGS: "logs"
249
+ };
250
+ var AGGREGATE_OPERATORS = {
251
+ COUNT: "count",
252
+ SUM: "sum",
253
+ AVG: "avg",
254
+ MIN: "min",
255
+ MAX: "max",
256
+ NOOP: "noop"
257
+ };
258
+ var QUERY_DEFAULTS = {
259
+ STEP: 60,
260
+ STEP_INTERVAL: 60,
261
+ OFFSET: 0,
262
+ DISABLED: false,
263
+ HAVING: [],
264
+ LEGEND: "",
265
+ LIMIT_NULL: null,
266
+ LIMIT_ZERO: 0,
267
+ LIMIT_1000: 1e3,
268
+ EMPTY_GROUP_BY: []
269
+ };
270
+
271
+ export { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AGGREGATE_OPERATORS, AI_OPERATIONS, AI_TOOL_TYPES, DATA_SOURCES, DATA_TYPES, DELEGATION_FROM_SUB_AGENT_ID, DELEGATION_ID, DELEGATION_TO_SUB_AGENT_ID, FIELD_TYPES, OPERATORS, ORDER_DIRECTIONS, PANEL_TYPES, QUERY_DEFAULTS, QUERY_EXPRESSIONS, QUERY_FIELD_CONFIGS, QUERY_TYPES, REDUCE_OPERATIONS, SPAN_KEYS, SPAN_NAMES, TOOL_NAMES, TRANSFER_FROM_SUB_AGENT_ID, TRANSFER_TO_SUB_AGENT_ID, UNKNOWN_VALUE };