@inkeep/agents-sdk 0.41.2 → 0.42.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 (41) hide show
  1. package/dist/agent.d.ts +84 -73
  2. package/dist/agent.js +40 -2
  3. package/dist/agentFullClient.d.ts +8 -8
  4. package/dist/agentFullClient.js +4 -4
  5. package/dist/artifact-component.d.ts +8 -8
  6. package/dist/artifact-component.js +2 -2
  7. package/dist/builderFunctions.d.ts +300 -248
  8. package/dist/builderFunctions.js +64 -1
  9. package/dist/builderFunctionsExperimental.d.ts +17 -17
  10. package/dist/builders.d.ts +48 -48
  11. package/dist/credential-provider.d.ts +93 -93
  12. package/dist/credential-ref.d.ts +37 -37
  13. package/dist/data-component.d.ts +9 -9
  14. package/dist/data-component.js +2 -2
  15. package/dist/environment-settings.d.ts +4 -4
  16. package/dist/evaluationClient.d.ts +78 -0
  17. package/dist/evaluationClient.js +1202 -0
  18. package/dist/external-agent.d.ts +17 -17
  19. package/dist/external-agent.js +2 -2
  20. package/dist/index.d.ts +4 -2
  21. package/dist/index.js +4 -2
  22. package/dist/module-hosted-tool-manager.d.ts +1 -1
  23. package/dist/module-hosted-tool-manager.js +1 -1
  24. package/dist/project.d.ts +83 -83
  25. package/dist/project.js +21 -2
  26. package/dist/projectFullClient.d.ts +8 -8
  27. package/dist/projectFullClient.js +4 -4
  28. package/dist/runner.d.ts +15 -15
  29. package/dist/status-component.d.ts +3 -3
  30. package/dist/subAgent.d.ts +2 -2
  31. package/dist/subAgent.js +7 -7
  32. package/dist/telemetry-provider.d.ts +76 -76
  33. package/dist/tool.d.ts +16 -16
  34. package/dist/tool.js +23 -3
  35. package/dist/trigger.d.ts +46 -0
  36. package/dist/trigger.js +65 -0
  37. package/dist/types.d.ts +31 -22
  38. package/dist/utils/generateIdFromName.d.ts +4 -4
  39. package/dist/utils/tool-normalization.d.ts +10 -10
  40. package/dist/utils/validateFunction.d.ts +5 -5
  41. package/package.json +2 -2
package/dist/agent.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Trigger, TriggerInterface } from "./trigger.js";
1
2
  import { AgentConfig, AgentInterface, AllDelegateInputInterface, GenerateOptions, MessageInput, ModelSettings, RunResult, StreamResponse, SubAgentInterface, subAgentTeamAgentInterface } from "./types.js";
2
3
  import { AgentStopWhen, FullAgentDefinition, StatusUpdateSettings } from "@inkeep/agents-core";
3
4
 
@@ -19,102 +20,112 @@ declare class Agent implements AgentInterface {
19
20
  private statusUpdateSettings?;
20
21
  private prompt?;
21
22
  private stopWhen?;
23
+ private triggers;
24
+ private triggerMap;
22
25
  constructor(config: AgentConfig);
23
26
  /**
24
- * Set or update the configuration (tenantId, projectId and apiUrl)
25
- * This is used by the CLI to inject configuration from inkeep.config.ts
26
- */
27
+ * Set or update the configuration (tenantId, projectId and apiUrl)
28
+ * This is used by the CLI to inject configuration from inkeep.config.ts
29
+ */
27
30
  setConfig(tenantId: string, projectId: string, apiUrl: string): void;
28
31
  /**
29
- * Convert the Agent to FullAgentDefinition format for the new agent endpoint
30
- */
32
+ * Convert the Agent to FullAgentDefinition format for the new agent endpoint
33
+ */
31
34
  toFullAgentDefinition(): Promise<FullAgentDefinition>;
32
35
  /**
33
- * Initialize all tools in all agents (especially IPCTools that need MCP server URLs)
34
- */
36
+ * Initialize all tools in all agents (especially IPCTools that need MCP server URLs)
37
+ */
35
38
  private initializeAllTools;
36
39
  /**
37
- * Initialize the agent and all agents in the backend using the new agent endpoint
38
- */
40
+ * Initialize the agent and all agents in the backend using the new agent endpoint
41
+ */
39
42
  init(): Promise<void>;
40
43
  /**
41
- * Generate a response using the default agent
42
- */
44
+ * Generate a response using the default agent
45
+ */
43
46
  generate(input: MessageInput, options?: GenerateOptions): Promise<string>;
44
47
  /**
45
- * Stream a response using the default agent
46
- */
48
+ * Stream a response using the default agent
49
+ */
47
50
  stream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
48
51
  /**
49
- * Alias for stream() method for consistency with naming patterns
50
- */
52
+ * Alias for stream() method for consistency with naming patterns
53
+ */
51
54
  generateStream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
52
55
  /**
53
- * Run with a specific agent from the agent
54
- */
56
+ * Run with a specific agent from the agent
57
+ */
55
58
  runWith(subAgentId: string, input: MessageInput, options?: GenerateOptions): Promise<RunResult>;
56
59
  /**
57
- * Get an agent by name (unified method for all agent types)
58
- */
60
+ * Get an agent by name (unified method for all agent types)
61
+ */
59
62
  getSubAgent(name: string): SubAgentInterface | undefined;
60
63
  /**
61
- * Add an agent to the agent
62
- */
64
+ * Add an agent to the agent
65
+ */
63
66
  addSubAgent(agent: SubAgentInterface): void;
64
67
  /**
65
- * Remove an agent from the agent
66
- */
68
+ * Remove an agent from the agent
69
+ */
67
70
  removeSubAgent(id: string): boolean;
68
71
  /**
69
- * Get all agents in the agent
70
- */
72
+ * Get all agents in the agent
73
+ */
71
74
  getSubAgents(): SubAgentInterface[];
72
75
  /**
73
- * Get all agent ids (unified method for all agent types)
74
- */
76
+ * Get all agent ids (unified method for all agent types)
77
+ */
75
78
  getSubAgentIds(): string[];
76
79
  /**
77
- * Set the default agent
78
- */
80
+ * Set the default agent
81
+ */
79
82
  setDefaultSubAgent(agent: SubAgentInterface): void;
80
83
  /**
81
- * Get the default agent
82
- */
84
+ * Get the default agent
85
+ */
83
86
  getDefaultSubAgent(): SubAgentInterface | undefined;
84
87
  /**
85
- * Get the agent ID
86
- */
88
+ * Get all triggers for this agent
89
+ */
90
+ getTriggers(): Record<string, Trigger>;
91
+ /**
92
+ * Add one or more triggers to the agent at runtime
93
+ */
94
+ addTrigger(...triggers: TriggerInterface[]): void;
95
+ /**
96
+ * Get the agent ID
97
+ */
87
98
  getId(): string;
88
99
  getName(): string;
89
100
  getDescription(): string | undefined;
90
101
  getTenantId(): string;
91
102
  /**
92
- * Get the agent's model settingsuration
93
- */
103
+ * Get the agent's model settingsuration
104
+ */
94
105
  getModels(): typeof this.models;
95
106
  /**
96
- * Set the agent's model settingsuration
97
- */
107
+ * Set the agent's model settingsuration
108
+ */
98
109
  setModels(models: typeof this.models): void;
99
110
  /**
100
- * Get the agent's prompt configuration
101
- */
111
+ * Get the agent's prompt configuration
112
+ */
102
113
  getPrompt(): string | undefined;
103
114
  /**
104
- * Get the agent's stopWhen configuration
105
- */
115
+ * Get the agent's stopWhen configuration
116
+ */
106
117
  getStopWhen(): AgentStopWhen;
107
118
  /**
108
- * Get the agent's status updates configuration
109
- */
119
+ * Get the agent's status updates configuration
120
+ */
110
121
  getStatusUpdateSettings(): StatusUpdateSettings | undefined;
111
122
  /**
112
- * Get the summarizer model from the agent's model settings
113
- */
123
+ * Get the summarizer model from the agent's model settings
124
+ */
114
125
  getSummarizerModel(): ModelSettings | undefined;
115
126
  /**
116
- * Get agent statistics
117
- */
127
+ * Get agent statistics
128
+ */
118
129
  getStats(): {
119
130
  agentCount: number;
120
131
  defaultSubAgent: string | null;
@@ -126,61 +137,61 @@ declare class Agent implements AgentInterface {
126
137
  headers?: Record<string, string>;
127
138
  }): subAgentTeamAgentInterface;
128
139
  /**
129
- * Validate the agent configuration
130
- */
140
+ * Validate the agent configuration
141
+ */
131
142
  validate(): {
132
143
  valid: boolean;
133
144
  errors: string[];
134
145
  };
135
146
  private _init;
136
147
  /**
137
- * Type guard to check if an agent is an internal AgentInterface
138
- */
148
+ * Type guard to check if an agent is an internal AgentInterface
149
+ */
139
150
  isInternalAgent(agent: AllDelegateInputInterface): agent is SubAgentInterface;
140
151
  /**
141
- * Get project-level model settingsuration defaults
142
- */
152
+ * Get project-level model settingsuration defaults
153
+ */
143
154
  private getProjectModelDefaults;
144
155
  /**
145
- * Get project-level stopWhen configuration defaults
146
- */
156
+ * Get project-level stopWhen configuration defaults
157
+ */
147
158
  private getProjectStopWhenDefaults;
148
159
  /**
149
- * Apply model inheritance hierarchy: Project -> Agent -> Agent
150
- */
160
+ * Apply model inheritance hierarchy: Project -> Agent -> Agent
161
+ */
151
162
  private applyModelInheritance;
152
163
  /**
153
- * Apply stopWhen inheritance hierarchy: Project -> Agent -> Agent
154
- */
164
+ * Apply stopWhen inheritance hierarchy: Project -> Agent -> Agent
165
+ */
155
166
  private applyStopWhenInheritance;
156
167
  /**
157
- * Propagate agent-level model settings to agents (supporting partial inheritance)
158
- */
168
+ * Propagate agent-level model settings to agents (supporting partial inheritance)
169
+ */
159
170
  private propagateModelSettingsToAgent;
160
171
  /**
161
- * Immediately propagate agent-level models to all agents during construction
162
- */
172
+ * Immediately propagate agent-level models to all agents during construction
173
+ */
163
174
  private propagateImmediateModelSettings;
164
175
  /**
165
- * Execute agent using the backend system instead of local runner
166
- */
176
+ * Execute agent using the backend system instead of local runner
177
+ */
167
178
  private executeWithBackend;
168
179
  /**
169
- * Parse streaming response in SSE format
170
- */
180
+ * Parse streaming response in SSE format
181
+ */
171
182
  private parseStreamingResponse;
172
183
  /**
173
- * Normalize input messages to the expected format
174
- */
184
+ * Normalize input messages to the expected format
185
+ */
175
186
  private normalizeMessages;
176
187
  }
177
188
  /**
178
- * Helper function to create agent - OpenAI style
179
- */
189
+ * Helper function to create agent - OpenAI style
190
+ */
180
191
  declare function agent(config: AgentConfig): Agent;
181
192
  /**
182
- * Factory function to create agent from configuration file
183
- */
193
+ * Factory function to create agent from configuration file
194
+ */
184
195
  declare function generateAgent(configPath: string): Promise<Agent>;
185
196
  //#endregion
186
197
  export { Agent, agent, generateAgent };
package/dist/agent.js CHANGED
@@ -27,6 +27,8 @@ var Agent = class {
27
27
  statusUpdateSettings;
28
28
  prompt;
29
29
  stopWhen;
30
+ triggers = [];
31
+ triggerMap = /* @__PURE__ */ new Map();
30
32
  constructor(config) {
31
33
  this.defaultSubAgent = config.defaultSubAgent;
32
34
  this.tenantId = "default";
@@ -43,6 +45,8 @@ var Agent = class {
43
45
  this.stopWhen = config.stopWhen ? { transferCountIs: config.stopWhen.transferCountIs } : void 0;
44
46
  this.subAgents = resolveGetter(config.subAgents) || [];
45
47
  this.agentMap = new Map(this.subAgents.map((agent$1) => [agent$1.getId(), agent$1]));
48
+ this.triggers = resolveGetter(config.triggers) || [];
49
+ this.triggerMap = new Map(this.triggers.map((trigger) => [trigger.getId(), trigger]));
46
50
  if (this.defaultSubAgent) {
47
51
  if (!this.subAgents.some((agent$1) => agent$1.getId() === this.defaultSubAgent?.getId())) this.subAgents.push(this.defaultSubAgent);
48
52
  this.agentMap.set(this.defaultSubAgent.getId(), this.defaultSubAgent);
@@ -52,7 +56,8 @@ var Agent = class {
52
56
  agentId: this.agentId,
53
57
  tenantId: this.tenantId,
54
58
  agentCount: this.subAgents.length,
55
- defaultSubAgent: this.defaultSubAgent?.getName()
59
+ defaultSubAgent: this.defaultSubAgent?.getName(),
60
+ triggerCount: this.triggers.length
56
61
  }, "Agent created");
57
62
  }
58
63
  /**
@@ -221,6 +226,16 @@ var Agent = class {
221
226
  }
222
227
  }
223
228
  }
229
+ const triggersObject = {};
230
+ for (const [triggerId, trigger] of this.triggerMap.entries()) {
231
+ const config = trigger.getConfig();
232
+ let processedInputSchema = config.inputSchema;
233
+ if (config.inputSchema && isZodSchema(config.inputSchema)) processedInputSchema = convertZodToJsonSchema(config.inputSchema);
234
+ triggersObject[triggerId] = {
235
+ ...config,
236
+ inputSchema: processedInputSchema
237
+ };
238
+ }
224
239
  return {
225
240
  id: this.agentId,
226
241
  name: this.agentName,
@@ -231,6 +246,7 @@ var Agent = class {
231
246
  contextConfig: this.contextConfig?.toObject(),
232
247
  ...Object.keys(functionToolsObject).length > 0 && { functionTools: functionToolsObject },
233
248
  ...Object.keys(functionsObject).length > 0 && { functions: functionsObject },
249
+ ...Object.keys(triggersObject).length > 0 && { triggers: triggersObject },
234
250
  models: this.models,
235
251
  stopWhen: this.stopWhen,
236
252
  statusUpdates: processedStatusUpdates,
@@ -437,6 +453,28 @@ var Agent = class {
437
453
  return this.defaultSubAgent;
438
454
  }
439
455
  /**
456
+ * Get all triggers for this agent
457
+ */
458
+ getTriggers() {
459
+ const triggersObject = {};
460
+ for (const [id, trigger] of this.triggerMap.entries()) triggersObject[id] = trigger;
461
+ return triggersObject;
462
+ }
463
+ /**
464
+ * Add one or more triggers to the agent at runtime
465
+ */
466
+ addTrigger(...triggers) {
467
+ for (const trigger of triggers) {
468
+ this.triggers.push(trigger);
469
+ this.triggerMap.set(trigger.getId(), trigger);
470
+ logger.info({
471
+ agentId: this.agentId,
472
+ triggerId: trigger.getId(),
473
+ triggerName: trigger.getName()
474
+ }, "Trigger added to agent");
475
+ }
476
+ }
477
+ /**
440
478
  * Get the agent ID
441
479
  */
442
480
  getId() {
@@ -624,7 +662,7 @@ var Agent = class {
624
662
  */
625
663
  async executeWithBackend(input, options) {
626
664
  const normalizedMessages = this.normalizeMessages(input);
627
- const url = `${this.baseURL}/tenants/${this.tenantId}/agent/${this.agentId}/v1/chat/completions`;
665
+ const url = `${this.baseURL}/run/v1/chat/completions`;
628
666
  logger.info({ url }, "Executing with backend");
629
667
  const requestBody = {
630
668
  model: "gpt-4o-mini",
@@ -3,20 +3,20 @@ import { FullAgentDefinition } from "@inkeep/agents-core";
3
3
  //#region src/agentFullClient.d.ts
4
4
 
5
5
  /**
6
- * Create a full agent via HTTP API
7
- */
6
+ * Create a full agent via HTTP API
7
+ */
8
8
  declare function createFullAgentViaAPI(tenantId: string, projectId: string, apiUrl: string, agentData: FullAgentDefinition): Promise<FullAgentDefinition>;
9
9
  /**
10
- * Update a full agent via HTTP API (upsert behavior)
11
- */
10
+ * Update a full agent via HTTP API (upsert behavior)
11
+ */
12
12
  declare function updateFullAgentViaAPI(tenantId: string, projectId: string, apiUrl: string, agentId: string, agentData: FullAgentDefinition): Promise<FullAgentDefinition>;
13
13
  /**
14
- * Get a full agent via HTTP API
15
- */
14
+ * Get a full agent via HTTP API
15
+ */
16
16
  declare function getFullAgentViaAPI(tenantId: string, projectId: string, apiUrl: string, agentId: string): Promise<FullAgentDefinition | null>;
17
17
  /**
18
- * Delete a full agent via HTTP API
19
- */
18
+ * Delete a full agent via HTTP API
19
+ */
20
20
  declare function deleteFullAgentViaAPI(tenantId: string, projectId: string, apiUrl: string, agentId: string): Promise<void>;
21
21
  //#endregion
22
22
  export { createFullAgentViaAPI, deleteFullAgentViaAPI, getFullAgentViaAPI, updateFullAgentViaAPI };
@@ -13,7 +13,7 @@ async function createFullAgentViaAPI(tenantId, projectId, apiUrl, agentData) {
13
13
  agentId: agentData.id,
14
14
  apiUrl
15
15
  }, "Creating full agent via API");
16
- const url = `${apiUrl}/tenants/${tenantId}/projects/${projectId}/agent`;
16
+ const url = `${apiUrl}/manage/tenants/${tenantId}/projects/${projectId}/agent`;
17
17
  const response = await fetch(url, {
18
18
  method: "POST",
19
19
  headers: { "Content-Type": "application/json" },
@@ -41,7 +41,7 @@ async function updateFullAgentViaAPI(tenantId, projectId, apiUrl, agentId, agent
41
41
  agentId,
42
42
  apiUrl
43
43
  }, "Updating full agent via API");
44
- const url = `${apiUrl}/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
44
+ const url = `${apiUrl}/manage/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
45
45
  const response = await fetch(url, {
46
46
  method: "PUT",
47
47
  headers: { "Content-Type": "application/json" },
@@ -69,7 +69,7 @@ async function getFullAgentViaAPI(tenantId, projectId, apiUrl, agentId) {
69
69
  agentId,
70
70
  apiUrl
71
71
  }, "Getting full agent via API");
72
- const url = `${apiUrl}/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
72
+ const url = `${apiUrl}/manage/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
73
73
  const response = await fetch(url, {
74
74
  method: "GET",
75
75
  headers: { "Content-Type": "application/json" }
@@ -100,7 +100,7 @@ async function deleteFullAgentViaAPI(tenantId, projectId, apiUrl, agentId) {
100
100
  agentId,
101
101
  apiUrl
102
102
  }, "Deleting full agent via API");
103
- const url = `${apiUrl}/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
103
+ const url = `${apiUrl}/manage/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
104
104
  const response = await fetch(url, {
105
105
  method: "DELETE",
106
106
  headers: { "Content-Type": "application/json" }
@@ -2,20 +2,20 @@ import { ArtifactComponentInsert } from "@inkeep/agents-core";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/artifact-component.d.ts
5
- type ArtifactComponentConfigWithZod = Omit<ArtifactComponentInsert, 'tenantId' | 'projectId' | 'props'> & {
5
+ type ArtifactComponentConfigWithZod = Omit<ArtifactComponentInsert, "tenantId" | "projectId" | "props"> & {
6
6
  props?: Record<string, unknown> | z.ZodObject<any> | null;
7
7
  };
8
8
  interface ArtifactComponentInterface {
9
- config: Omit<ArtifactComponentInsert, 'tenantId' | 'projectId'>;
9
+ config: Omit<ArtifactComponentInsert, "tenantId" | "projectId">;
10
10
  init(): Promise<void>;
11
- getId(): ArtifactComponentInsert['id'];
12
- getName(): ArtifactComponentInsert['name'];
13
- getDescription(): ArtifactComponentInsert['description'];
14
- getProps(): ArtifactComponentInsert['props'];
11
+ getId(): ArtifactComponentInsert["id"];
12
+ getName(): ArtifactComponentInsert["name"];
13
+ getDescription(): ArtifactComponentInsert["description"];
14
+ getProps(): ArtifactComponentInsert["props"];
15
15
  setContext(tenantId: string, projectId: string, baseURL?: string): void;
16
16
  }
17
17
  declare class ArtifactComponent implements ArtifactComponentInterface {
18
- config: Omit<ArtifactComponentInsert, 'tenantId' | 'projectId'>;
18
+ config: Omit<ArtifactComponentInsert, "tenantId" | "projectId">;
19
19
  private baseURL;
20
20
  private tenantId;
21
21
  private projectId;
@@ -26,7 +26,7 @@ declare class ArtifactComponent implements ArtifactComponentInterface {
26
26
  getId(): string;
27
27
  getName(): string;
28
28
  getDescription(): string;
29
- getProps(): ArtifactComponentInsert['props'];
29
+ getProps(): ArtifactComponentInsert["props"];
30
30
  init(): Promise<void>;
31
31
  private upsertArtifactComponent;
32
32
  }
@@ -68,7 +68,7 @@ var ArtifactComponent = class {
68
68
  props: this.config.props
69
69
  };
70
70
  logger.info({ artifactComponentData }, "artifactComponentData for create/update");
71
- const updateResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/artifact-components/${this.getId()}`, {
71
+ const updateResponse = await fetch(`${this.baseURL}/manage/tenants/${this.tenantId}/projects/${this.projectId}/artifact-components/${this.getId()}`, {
72
72
  method: "PUT",
73
73
  headers: { "Content-Type": "application/json" },
74
74
  body: JSON.stringify(artifactComponentData)
@@ -83,7 +83,7 @@ var ArtifactComponent = class {
83
83
  }
84
84
  if (updateResponse.status === 404) {
85
85
  logger.info({ artifactComponentId: this.getId() }, "ArtifactComponent not found, creating new artifact component");
86
- const createResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/artifact-components`, {
86
+ const createResponse = await fetch(`${this.baseURL}/manage/tenants/${this.tenantId}/projects/${this.projectId}/artifact-components`, {
87
87
  method: "POST",
88
88
  headers: { "Content-Type": "application/json" },
89
89
  body: JSON.stringify(artifactComponentData)