@inkeep/agents-core 0.0.0-dev-20251031184130 → 0.0.0-dev-20251031184231

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.
@@ -1,6 +1,51 @@
1
1
  import { AgentWithinContextOfProjectSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-37BY2EHU.js';
2
2
  import { z } from 'zod';
3
3
 
4
+ // src/validation/cycleDetection.ts
5
+ function detectDelegationCycles(agentData) {
6
+ const graph = buildDelegationGraph(agentData);
7
+ const cycles = [];
8
+ const visited = /* @__PURE__ */ new Set();
9
+ const stack = /* @__PURE__ */ new Set();
10
+ const path = [];
11
+ function dfs(node) {
12
+ visited.add(node);
13
+ stack.add(node);
14
+ path.push(node);
15
+ for (const neighbor of graph.get(node) || []) {
16
+ if (!visited.has(neighbor)) {
17
+ if (dfs(neighbor)) return true;
18
+ } else if (stack.has(neighbor)) {
19
+ const cycleStart = path.indexOf(neighbor);
20
+ cycles.push(`Circular delegation detected: ${[...path.slice(cycleStart), neighbor].join(" \u2192 ")}`);
21
+ return true;
22
+ }
23
+ }
24
+ stack.delete(node);
25
+ path.pop();
26
+ return false;
27
+ }
28
+ for (const node of graph.keys()) {
29
+ if (!visited.has(node)) {
30
+ path.length = 0;
31
+ dfs(node);
32
+ }
33
+ }
34
+ return cycles;
35
+ }
36
+ function buildDelegationGraph(agentData) {
37
+ const graph = /* @__PURE__ */ new Map();
38
+ for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
39
+ const delegates = subAgent.canDelegateTo?.filter(
40
+ (d) => typeof d === "string"
41
+ );
42
+ if (delegates?.length) {
43
+ graph.set(subAgentId, delegates);
44
+ }
45
+ }
46
+ return graph;
47
+ }
48
+
4
49
  // src/validation/agentFull.ts
5
50
  function validateAndTypeAgentData(data) {
6
51
  return AgentWithinContextOfProjectSchema.parse(data);
@@ -94,6 +139,10 @@ function validateAgentRelationships(agentData) {
94
139
  }
95
140
  }
96
141
  }
142
+ const cycles = detectDelegationCycles(agentData);
143
+ if (cycles.length > 0) {
144
+ errors.push(...cycles);
145
+ }
97
146
  if (errors.length > 0)
98
147
  throw new Error(`Agent relationship validation failed:
99
148
  ${errors.join("\n")}`);
@@ -1,7 +1,7 @@
1
1
  export { i as ACTIVITY_NAMES, g as ACTIVITY_STATUS, f as ACTIVITY_TYPES, h as AGENT_IDS, p as AGGREGATE_OPERATORS, A as AI_OPERATIONS, j as AI_TOOL_TYPES, o as DATA_SOURCES, k as DATA_TYPES, D as DELEGATION_FROM_SUB_AGENT_ID, b as DELEGATION_ID, a as DELEGATION_TO_SUB_AGENT_ID, F as FIELD_TYPES, O as OPERATORS, m as ORDER_DIRECTIONS, P as PANEL_TYPES, q as QUERY_DEFAULTS, l as QUERY_EXPRESSIONS, Q as QUERY_FIELD_CONFIGS, n as QUERY_TYPES, R as REDUCE_OPERATIONS, e as SPAN_KEYS, S as SPAN_NAMES, T as TRANSFER_FROM_SUB_AGENT_ID, c as TRANSFER_TO_SUB_AGENT_ID, U as UNKNOWN_VALUE, d as detectAuthenticationRequired } from './auth-detection-DtO-n2WD.cjs';
2
2
  import { z } from 'zod';
3
- import { C as ConversationHistoryConfig, F as FunctionApiInsertSchema, A as ApiKeyApiUpdateSchema, a as FullAgentAgentInsertSchema } from './utility-fD4C61M4.cjs';
4
- export { e as AgentStopWhen, b as AgentStopWhenSchema, h as CredentialStoreType, j as FunctionApiSelectSchema, k as FunctionApiUpdateSchema, i as MCPTransportType, g as ModelSettings, M as ModelSettingsSchema, d as StopWhen, S as StopWhenSchema, f as SubAgentStopWhen, c as SubAgentStopWhenSchema } from './utility-fD4C61M4.cjs';
3
+ import { C as ConversationHistoryConfig, F as FunctionApiInsertSchema, A as ApiKeyApiUpdateSchema, a as FullAgentAgentInsertSchema } from './utility-eADYCyd-.cjs';
4
+ export { e as AgentStopWhen, b as AgentStopWhenSchema, h as CredentialStoreType, j as FunctionApiSelectSchema, k as FunctionApiUpdateSchema, i as MCPTransportType, g as ModelSettings, M as ModelSettingsSchema, d as StopWhen, S as StopWhenSchema, f as SubAgentStopWhen, c as SubAgentStopWhenSchema } from './utility-eADYCyd-.cjs';
5
5
  export { v as validatePropsAsJsonSchema } from './props-validation-BMR1qNiy.cjs';
6
6
  import 'pino';
7
7
  import 'drizzle-zod';
@@ -134,8 +134,8 @@ declare const DataComponentApiInsertSchema: z.ZodObject<{
134
134
  }, z.core.$strip>>>;
135
135
  }, z.core.$strip>;
136
136
  declare const ArtifactComponentApiInsertSchema: z.ZodObject<{
137
- name: z.ZodString;
138
137
  id: z.ZodString;
138
+ name: z.ZodString;
139
139
  description: z.ZodString;
140
140
  props: z.ZodOptional<z.ZodNullable<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>>;
141
141
  }, {
@@ -170,11 +170,12 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
170
170
  description: z.ZodOptional<z.ZodString>;
171
171
  defaultSubAgentId: z.ZodOptional<z.ZodString>;
172
172
  subAgents: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
173
- name: z.ZodString;
174
173
  id: z.ZodString;
174
+ name: z.ZodString;
175
+ description: z.ZodString;
176
+ prompt: z.ZodString;
175
177
  createdAt: z.ZodOptional<z.ZodString>;
176
178
  updatedAt: z.ZodOptional<z.ZodString>;
177
- description: z.ZodString;
178
179
  models: z.ZodOptional<z.ZodObject<{
179
180
  base: z.ZodOptional<z.ZodObject<{
180
181
  model: z.ZodOptional<z.ZodString>;
@@ -198,7 +199,6 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
198
199
  }, {
199
200
  stepCountIs?: number | undefined;
200
201
  }>>>>;
201
- prompt: z.ZodString;
202
202
  conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
203
203
  type: z.ZodLiteral<"internal">;
204
204
  canUse: z.ZodArray<z.ZodObject<{
@@ -1,7 +1,7 @@
1
1
  export { i as ACTIVITY_NAMES, g as ACTIVITY_STATUS, f as ACTIVITY_TYPES, h as AGENT_IDS, p as AGGREGATE_OPERATORS, A as AI_OPERATIONS, j as AI_TOOL_TYPES, o as DATA_SOURCES, k as DATA_TYPES, D as DELEGATION_FROM_SUB_AGENT_ID, b as DELEGATION_ID, a as DELEGATION_TO_SUB_AGENT_ID, F as FIELD_TYPES, O as OPERATORS, m as ORDER_DIRECTIONS, P as PANEL_TYPES, q as QUERY_DEFAULTS, l as QUERY_EXPRESSIONS, Q as QUERY_FIELD_CONFIGS, n as QUERY_TYPES, R as REDUCE_OPERATIONS, e as SPAN_KEYS, S as SPAN_NAMES, T as TRANSFER_FROM_SUB_AGENT_ID, c as TRANSFER_TO_SUB_AGENT_ID, U as UNKNOWN_VALUE, d as detectAuthenticationRequired } from './auth-detection-DtO-n2WD.js';
2
2
  import { z } from 'zod';
3
- import { C as ConversationHistoryConfig, F as FunctionApiInsertSchema, A as ApiKeyApiUpdateSchema, a as FullAgentAgentInsertSchema } from './utility-fD4C61M4.js';
4
- export { e as AgentStopWhen, b as AgentStopWhenSchema, h as CredentialStoreType, j as FunctionApiSelectSchema, k as FunctionApiUpdateSchema, i as MCPTransportType, g as ModelSettings, M as ModelSettingsSchema, d as StopWhen, S as StopWhenSchema, f as SubAgentStopWhen, c as SubAgentStopWhenSchema } from './utility-fD4C61M4.js';
3
+ import { C as ConversationHistoryConfig, F as FunctionApiInsertSchema, A as ApiKeyApiUpdateSchema, a as FullAgentAgentInsertSchema } from './utility-eADYCyd-.js';
4
+ export { e as AgentStopWhen, b as AgentStopWhenSchema, h as CredentialStoreType, j as FunctionApiSelectSchema, k as FunctionApiUpdateSchema, i as MCPTransportType, g as ModelSettings, M as ModelSettingsSchema, d as StopWhen, S as StopWhenSchema, f as SubAgentStopWhen, c as SubAgentStopWhenSchema } from './utility-eADYCyd-.js';
5
5
  export { v as validatePropsAsJsonSchema } from './props-validation-BMR1qNiy.js';
6
6
  import 'pino';
7
7
  import 'drizzle-zod';
@@ -134,8 +134,8 @@ declare const DataComponentApiInsertSchema: z.ZodObject<{
134
134
  }, z.core.$strip>>>;
135
135
  }, z.core.$strip>;
136
136
  declare const ArtifactComponentApiInsertSchema: z.ZodObject<{
137
- name: z.ZodString;
138
137
  id: z.ZodString;
138
+ name: z.ZodString;
139
139
  description: z.ZodString;
140
140
  props: z.ZodOptional<z.ZodNullable<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>>;
141
141
  }, {
@@ -170,11 +170,12 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
170
170
  description: z.ZodOptional<z.ZodString>;
171
171
  defaultSubAgentId: z.ZodOptional<z.ZodString>;
172
172
  subAgents: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
173
- name: z.ZodString;
174
173
  id: z.ZodString;
174
+ name: z.ZodString;
175
+ description: z.ZodString;
176
+ prompt: z.ZodString;
175
177
  createdAt: z.ZodOptional<z.ZodString>;
176
178
  updatedAt: z.ZodOptional<z.ZodString>;
177
- description: z.ZodString;
178
179
  models: z.ZodOptional<z.ZodObject<{
179
180
  base: z.ZodOptional<z.ZodObject<{
180
181
  model: z.ZodOptional<z.ZodString>;
@@ -198,7 +199,6 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
198
199
  }, {
199
200
  stepCountIs?: number | undefined;
200
201
  }>>>>;
201
- prompt: z.ZodString;
202
202
  conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
203
203
  type: z.ZodLiteral<"internal">;
204
204
  canUse: z.ZodArray<z.ZodObject<{
@@ -1,7 +1,7 @@
1
1
  import 'drizzle-orm';
2
2
  import 'drizzle-orm/sqlite-core';
3
- import '../utility-fD4C61M4.cjs';
4
- export { G as agentRelations, J as agentToolRelationsRelations, a as agents, y as apiKeys, I as apiKeysRelations, j as artifactComponents, O as artifactComponentsRelations, b as contextCache, E as contextCacheRelations, c as contextConfigs, D as contextConfigsRelations, v as conversations, M as conversationsRelations, z as credentialReferences, K as credentialReferencesRelations, h as dataComponents, Q as dataComponentsRelations, f as externalAgents, H as externalAgentsRelations, m as functionTools, V as functionToolsRelations, n as functions, T as functionsRelations, x as ledgerArtifacts, S as ledgerArtifactsRelations, w as messages, N as messagesRelations, p as projects, B as projectsRelations, k as subAgentArtifactComponents, P as subAgentArtifactComponentsRelations, i as subAgentDataComponents, R as subAgentDataComponentsRelations, q as subAgentExternalAgentRelations, X as subAgentExternalAgentRelationsRelations, u as subAgentFunctionToolRelations, W as subAgentFunctionToolRelationsRelations, e as subAgentRelations, U as subAgentRelationsRelations, r as subAgentTeamAgentRelations, Y as subAgentTeamAgentRelationsRelations, o as subAgentToolRelations, d as subAgents, F as subAgentsRelations, g as taskRelations, C as taskRelationsRelations, t as tasks, A as tasksRelations, l as tools, L as toolsRelations } from '../schema-uPzoiY7F.cjs';
3
+ import '../utility-eADYCyd-.cjs';
4
+ export { G as agentRelations, J as agentToolRelationsRelations, a as agents, y as apiKeys, I as apiKeysRelations, j as artifactComponents, O as artifactComponentsRelations, b as contextCache, E as contextCacheRelations, c as contextConfigs, D as contextConfigsRelations, v as conversations, M as conversationsRelations, z as credentialReferences, K as credentialReferencesRelations, h as dataComponents, Q as dataComponentsRelations, f as externalAgents, H as externalAgentsRelations, m as functionTools, V as functionToolsRelations, n as functions, T as functionsRelations, x as ledgerArtifacts, S as ledgerArtifactsRelations, w as messages, N as messagesRelations, p as projects, B as projectsRelations, k as subAgentArtifactComponents, P as subAgentArtifactComponentsRelations, i as subAgentDataComponents, R as subAgentDataComponentsRelations, q as subAgentExternalAgentRelations, X as subAgentExternalAgentRelationsRelations, u as subAgentFunctionToolRelations, W as subAgentFunctionToolRelationsRelations, e as subAgentRelations, U as subAgentRelationsRelations, r as subAgentTeamAgentRelations, Y as subAgentTeamAgentRelationsRelations, o as subAgentToolRelations, d as subAgents, F as subAgentsRelations, g as taskRelations, C as taskRelationsRelations, t as tasks, A as tasksRelations, l as tools, L as toolsRelations } from '../schema-DgEdaA4i.cjs';
5
5
  import 'zod';
6
6
  import 'drizzle-zod';
7
7
  import '@hono/zod-openapi';
@@ -1,7 +1,7 @@
1
1
  import 'drizzle-orm';
2
2
  import 'drizzle-orm/sqlite-core';
3
- import '../utility-fD4C61M4.js';
4
- export { G as agentRelations, J as agentToolRelationsRelations, a as agents, y as apiKeys, I as apiKeysRelations, j as artifactComponents, O as artifactComponentsRelations, b as contextCache, E as contextCacheRelations, c as contextConfigs, D as contextConfigsRelations, v as conversations, M as conversationsRelations, z as credentialReferences, K as credentialReferencesRelations, h as dataComponents, Q as dataComponentsRelations, f as externalAgents, H as externalAgentsRelations, m as functionTools, V as functionToolsRelations, n as functions, T as functionsRelations, x as ledgerArtifacts, S as ledgerArtifactsRelations, w as messages, N as messagesRelations, p as projects, B as projectsRelations, k as subAgentArtifactComponents, P as subAgentArtifactComponentsRelations, i as subAgentDataComponents, R as subAgentDataComponentsRelations, q as subAgentExternalAgentRelations, X as subAgentExternalAgentRelationsRelations, u as subAgentFunctionToolRelations, W as subAgentFunctionToolRelationsRelations, e as subAgentRelations, U as subAgentRelationsRelations, r as subAgentTeamAgentRelations, Y as subAgentTeamAgentRelationsRelations, o as subAgentToolRelations, d as subAgents, F as subAgentsRelations, g as taskRelations, C as taskRelationsRelations, t as tasks, A as tasksRelations, l as tools, L as toolsRelations } from '../schema-BWDgXp-e.js';
3
+ import '../utility-eADYCyd-.js';
4
+ export { G as agentRelations, J as agentToolRelationsRelations, a as agents, y as apiKeys, I as apiKeysRelations, j as artifactComponents, O as artifactComponentsRelations, b as contextCache, E as contextCacheRelations, c as contextConfigs, D as contextConfigsRelations, v as conversations, M as conversationsRelations, z as credentialReferences, K as credentialReferencesRelations, h as dataComponents, Q as dataComponentsRelations, f as externalAgents, H as externalAgentsRelations, m as functionTools, V as functionToolsRelations, n as functions, T as functionsRelations, x as ledgerArtifacts, S as ledgerArtifactsRelations, w as messages, N as messagesRelations, p as projects, B as projectsRelations, k as subAgentArtifactComponents, P as subAgentArtifactComponentsRelations, i as subAgentDataComponents, R as subAgentDataComponentsRelations, q as subAgentExternalAgentRelations, X as subAgentExternalAgentRelationsRelations, u as subAgentFunctionToolRelations, W as subAgentFunctionToolRelationsRelations, e as subAgentRelations, U as subAgentRelationsRelations, r as subAgentTeamAgentRelations, Y as subAgentTeamAgentRelationsRelations, o as subAgentToolRelations, d as subAgents, F as subAgentsRelations, g as taskRelations, C as taskRelationsRelations, t as tasks, A as tasksRelations, l as tools, L as toolsRelations } from '../schema-DfnCgRwo.js';
5
5
  import 'zod';
6
6
  import 'drizzle-zod';
7
7
  import '@hono/zod-openapi';
package/dist/index.cjs CHANGED
@@ -215950,6 +215950,51 @@ function getConversationId() {
215950
215950
  return generateId();
215951
215951
  }
215952
215952
 
215953
+ // src/validation/cycleDetection.ts
215954
+ function detectDelegationCycles(agentData) {
215955
+ const graph = buildDelegationGraph(agentData);
215956
+ const cycles = [];
215957
+ const visited = /* @__PURE__ */ new Set();
215958
+ const stack = /* @__PURE__ */ new Set();
215959
+ const path2 = [];
215960
+ function dfs(node) {
215961
+ visited.add(node);
215962
+ stack.add(node);
215963
+ path2.push(node);
215964
+ for (const neighbor of graph.get(node) || []) {
215965
+ if (!visited.has(neighbor)) {
215966
+ if (dfs(neighbor)) return true;
215967
+ } else if (stack.has(neighbor)) {
215968
+ const cycleStart = path2.indexOf(neighbor);
215969
+ cycles.push(`Circular delegation detected: ${[...path2.slice(cycleStart), neighbor].join(" \u2192 ")}`);
215970
+ return true;
215971
+ }
215972
+ }
215973
+ stack.delete(node);
215974
+ path2.pop();
215975
+ return false;
215976
+ }
215977
+ for (const node of graph.keys()) {
215978
+ if (!visited.has(node)) {
215979
+ path2.length = 0;
215980
+ dfs(node);
215981
+ }
215982
+ }
215983
+ return cycles;
215984
+ }
215985
+ function buildDelegationGraph(agentData) {
215986
+ const graph = /* @__PURE__ */ new Map();
215987
+ for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
215988
+ const delegates = subAgent.canDelegateTo?.filter(
215989
+ (d) => typeof d === "string"
215990
+ );
215991
+ if (delegates?.length) {
215992
+ graph.set(subAgentId, delegates);
215993
+ }
215994
+ }
215995
+ return graph;
215996
+ }
215997
+
215953
215998
  // src/validation/agentFull.ts
215954
215999
  function validateAndTypeAgentData(data) {
215955
216000
  return AgentWithinContextOfProjectSchema.parse(data);
@@ -216043,6 +216088,10 @@ function validateAgentRelationships(agentData) {
216043
216088
  }
216044
216089
  }
216045
216090
  }
216091
+ const cycles = detectDelegationCycles(agentData);
216092
+ if (cycles.length > 0) {
216093
+ errors.push(...cycles);
216094
+ }
216046
216095
  if (errors.length > 0)
216047
216096
  throw new Error(`Agent relationship validation failed:
216048
216097
  ${errors.join("\n")}`);