@inkeep/agents-sdk 0.41.2 → 0.43.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/README.md +356 -2
- package/dist/agent.d.ts +84 -73
- package/dist/agent.js +42 -4
- package/dist/agentFullClient.d.ts +8 -8
- package/dist/agentFullClient.js +4 -4
- package/dist/artifact-component.d.ts +8 -8
- package/dist/artifact-component.js +2 -2
- package/dist/builderFunctions.d.ts +337 -248
- package/dist/builderFunctions.js +131 -2
- package/dist/builderFunctionsExperimental.d.ts +17 -17
- package/dist/builders.d.ts +48 -48
- package/dist/credential-provider.d.ts +93 -93
- package/dist/credential-provider.js +1 -1
- package/dist/credential-ref.d.ts +37 -37
- package/dist/data-component.d.ts +9 -9
- package/dist/data-component.js +2 -2
- package/dist/environment-settings.d.ts +4 -4
- package/dist/evaluationClient.d.ts +78 -0
- package/dist/evaluationClient.js +1202 -0
- package/dist/external-agent.d.ts +17 -17
- package/dist/external-agent.js +2 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -2
- package/dist/module-hosted-tool-manager.d.ts +1 -1
- package/dist/module-hosted-tool-manager.js +1 -1
- package/dist/project.d.ts +83 -83
- package/dist/project.js +23 -4
- package/dist/projectFullClient.d.ts +8 -8
- package/dist/projectFullClient.js +4 -4
- package/dist/runner.d.ts +15 -15
- package/dist/status-component.d.ts +3 -3
- package/dist/subAgent.d.ts +2 -2
- package/dist/subAgent.js +7 -7
- package/dist/telemetry-provider.d.ts +76 -76
- package/dist/tool.d.ts +16 -16
- package/dist/tool.js +23 -3
- package/dist/trigger.d.ts +46 -0
- package/dist/trigger.js +65 -0
- package/dist/types.d.ts +31 -22
- package/dist/utils/generateIdFromName.d.ts +4 -4
- package/dist/utils/tool-normalization.d.ts +10 -10
- package/dist/utils/validateFunction.d.ts +5 -5
- package/package.json +2 -2
package/dist/subAgent.js
CHANGED
|
@@ -209,7 +209,7 @@ var SubAgent = class {
|
|
|
209
209
|
models: this.config.models,
|
|
210
210
|
stopWhen: this.config.stopWhen
|
|
211
211
|
};
|
|
212
|
-
const updateResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/agents/${this.getId()}`, {
|
|
212
|
+
const updateResponse = await fetch(`${this.baseURL}/manage/tenants/${this.tenantId}/agents/${this.getId()}`, {
|
|
213
213
|
method: "PUT",
|
|
214
214
|
headers: { "Content-Type": "application/json" },
|
|
215
215
|
body: JSON.stringify(agentData)
|
|
@@ -220,7 +220,7 @@ var SubAgent = class {
|
|
|
220
220
|
}
|
|
221
221
|
if (updateResponse.status === 404) {
|
|
222
222
|
logger.info({ subAgentId: this.getId() }, "Agent not found, creating new agent");
|
|
223
|
-
const createResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/agents`, {
|
|
223
|
+
const createResponse = await fetch(`${this.baseURL}/manage/tenants/${this.tenantId}/agents`, {
|
|
224
224
|
method: "POST",
|
|
225
225
|
headers: { "Content-Type": "application/json" },
|
|
226
226
|
body: JSON.stringify(agentData)
|
|
@@ -369,7 +369,7 @@ var SubAgent = class {
|
|
|
369
369
|
try {
|
|
370
370
|
const functionData = functionTool.serializeFunction();
|
|
371
371
|
const toolData = functionTool.serializeTool();
|
|
372
|
-
const functionUrl = `${this.baseURL}/tenants/${this.tenantId}/crud/projects/${this.projectId}/functions`;
|
|
372
|
+
const functionUrl = `${this.baseURL}/manage/tenants/${this.tenantId}/crud/projects/${this.projectId}/functions`;
|
|
373
373
|
logger.info({
|
|
374
374
|
agentId: this.getId(),
|
|
375
375
|
toolId,
|
|
@@ -402,7 +402,7 @@ var SubAgent = class {
|
|
|
402
402
|
}, "Function creation failed");
|
|
403
403
|
throw new Error(`Failed to create function: ${functionResponse.status} ${errorText}`);
|
|
404
404
|
}
|
|
405
|
-
const toolUrl = `${this.baseURL}/tenants/${this.tenantId}/crud/projects/${this.projectId}/tools`;
|
|
405
|
+
const toolUrl = `${this.baseURL}/manage/tenants/${this.tenantId}/crud/projects/${this.projectId}/tools`;
|
|
406
406
|
logger.info({
|
|
407
407
|
agentId: this.getId(),
|
|
408
408
|
toolId,
|
|
@@ -553,7 +553,7 @@ var SubAgent = class {
|
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
555
|
async createAgentDataComponentRelation(dataComponentId) {
|
|
556
|
-
const relationResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/agent-data-components`, {
|
|
556
|
+
const relationResponse = await fetch(`${this.baseURL}/manage/tenants/${this.tenantId}/agent-data-components`, {
|
|
557
557
|
method: "POST",
|
|
558
558
|
headers: { "Content-Type": "application/json" },
|
|
559
559
|
body: JSON.stringify({
|
|
@@ -570,7 +570,7 @@ var SubAgent = class {
|
|
|
570
570
|
}, "Created agent-dataComponent relation");
|
|
571
571
|
}
|
|
572
572
|
async createAgentArtifactComponentRelation(artifactComponentId) {
|
|
573
|
-
const relationResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/agent-artifact-components`, {
|
|
573
|
+
const relationResponse = await fetch(`${this.baseURL}/manage/tenants/${this.tenantId}/agent-artifact-components`, {
|
|
574
574
|
method: "POST",
|
|
575
575
|
headers: { "Content-Type": "application/json" },
|
|
576
576
|
body: JSON.stringify({
|
|
@@ -597,7 +597,7 @@ var SubAgent = class {
|
|
|
597
597
|
if (selectedTools !== void 0) relationData.selectedTools = selectedTools;
|
|
598
598
|
if (headers !== void 0) relationData.headers = headers;
|
|
599
599
|
if (toolPolicies !== void 0 && Object.keys(toolPolicies).length > 0) relationData.toolPolicies = toolPolicies;
|
|
600
|
-
const relationResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/agent-tool-relations`, {
|
|
600
|
+
const relationResponse = await fetch(`${this.baseURL}/manage/tenants/${this.tenantId}/projects/${this.projectId}/agent-tool-relations`, {
|
|
601
601
|
method: "POST",
|
|
602
602
|
headers: { "Content-Type": "application/json" },
|
|
603
603
|
body: JSON.stringify(relationData)
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
//#region src/telemetry-provider.d.ts
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
3
|
+
* TelemetryProvider - Abstraction for Telemetry/Observability
|
|
4
|
+
*
|
|
5
|
+
* This module provides a clean abstraction over telemetry implementations.
|
|
6
|
+
* Cloud customers can use this without needing to install or configure
|
|
7
|
+
* OpenTelemetry or Signoz directly.
|
|
8
|
+
*
|
|
9
|
+
* Telemetry is OPT-IN - if not configured, a no-op provider is used.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Opt-in to telemetry with default console logger
|
|
14
|
+
* import { InkeepTelemetryProvider, createConsoleTelemetryProvider } from '@inkeep/agents-sdk'
|
|
15
|
+
*
|
|
16
|
+
* const telemetry = createConsoleTelemetryProvider()
|
|
17
|
+
*
|
|
18
|
+
* // Or with OpenTelemetry (requires @opentelemetry packages)
|
|
19
|
+
* const telemetry = createOpenTelemetryProvider({
|
|
20
|
+
* serviceName: 'my-agent',
|
|
21
|
+
* endpoint: 'http://localhost:4318'
|
|
22
|
+
* })
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Span status codes
|
|
27
|
+
*/
|
|
28
28
|
declare const SpanStatus: {
|
|
29
29
|
readonly OK: "ok";
|
|
30
30
|
readonly ERROR: "error";
|
|
@@ -32,8 +32,8 @@ declare const SpanStatus: {
|
|
|
32
32
|
};
|
|
33
33
|
type SpanStatusType = (typeof SpanStatus)[keyof typeof SpanStatus];
|
|
34
34
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
* Span interface for tracing
|
|
36
|
+
*/
|
|
37
37
|
interface TelemetrySpan {
|
|
38
38
|
/** Set span attributes */
|
|
39
39
|
setAttributes(attributes: Record<string, unknown>): TelemetrySpan;
|
|
@@ -53,8 +53,8 @@ interface TelemetrySpan {
|
|
|
53
53
|
updateName(name: string): TelemetrySpan;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
* Span options
|
|
57
|
+
*/
|
|
58
58
|
interface SpanOptions {
|
|
59
59
|
/** Span attributes */
|
|
60
60
|
attributes?: Record<string, unknown>;
|
|
@@ -62,8 +62,8 @@ interface SpanOptions {
|
|
|
62
62
|
parent?: TelemetrySpan;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
* Tracer interface for creating spans
|
|
66
|
+
*/
|
|
67
67
|
interface TelemetryTracer {
|
|
68
68
|
/** Start a new active span and execute callback */
|
|
69
69
|
startActiveSpan<T>(name: string, fn: (span: TelemetrySpan) => T): T;
|
|
@@ -72,8 +72,8 @@ interface TelemetryTracer {
|
|
|
72
72
|
startSpan(name: string, options?: SpanOptions): TelemetrySpan;
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
* Logger interface for structured logging
|
|
76
|
+
*/
|
|
77
77
|
interface TelemetryLogger {
|
|
78
78
|
debug(message: string, context?: Record<string, unknown>): void;
|
|
79
79
|
info(message: string, context?: Record<string, unknown>): void;
|
|
@@ -81,8 +81,8 @@ interface TelemetryLogger {
|
|
|
81
81
|
error(message: string, context?: Record<string, unknown>): void;
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
* Metrics interface for recording measurements
|
|
85
|
+
*/
|
|
86
86
|
interface TelemetryMetrics {
|
|
87
87
|
/** Increment a counter */
|
|
88
88
|
increment(name: string, value?: number, attributes?: Record<string, unknown>): void;
|
|
@@ -92,8 +92,8 @@ interface TelemetryMetrics {
|
|
|
92
92
|
histogram(name: string, value: number, attributes?: Record<string, unknown>): void;
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
* Main telemetry provider interface
|
|
96
|
+
*/
|
|
97
97
|
interface TelemetryProvider {
|
|
98
98
|
/** Get a tracer for creating spans */
|
|
99
99
|
getTracer(name: string, version?: string): TelemetryTracer;
|
|
@@ -107,8 +107,8 @@ interface TelemetryProvider {
|
|
|
107
107
|
isEnabled(): boolean;
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
* Configuration for telemetry provider
|
|
111
|
+
*/
|
|
112
112
|
interface TelemetryConfig {
|
|
113
113
|
/** Whether telemetry is enabled (default: false) */
|
|
114
114
|
enabled?: boolean;
|
|
@@ -120,8 +120,8 @@ interface TelemetryConfig {
|
|
|
120
120
|
provider?: TelemetryProvider;
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
* No-op telemetry provider (default)
|
|
124
|
+
*/
|
|
125
125
|
declare class NoOpTelemetryProvider implements TelemetryProvider {
|
|
126
126
|
getTracer(_name: string, _version?: string): TelemetryTracer;
|
|
127
127
|
getLogger(_name: string): TelemetryLogger;
|
|
@@ -130,8 +130,8 @@ declare class NoOpTelemetryProvider implements TelemetryProvider {
|
|
|
130
130
|
isEnabled(): boolean;
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
* Console-based telemetry provider for development/debugging
|
|
134
|
+
*/
|
|
135
135
|
declare class ConsoleTelemetryProvider implements TelemetryProvider {
|
|
136
136
|
private serviceName;
|
|
137
137
|
constructor(serviceName?: string);
|
|
@@ -142,62 +142,62 @@ declare class ConsoleTelemetryProvider implements TelemetryProvider {
|
|
|
142
142
|
isEnabled(): boolean;
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
* InkeepTelemetryProvider - Main telemetry management class
|
|
146
|
+
*
|
|
147
|
+
* Provides a unified interface for telemetry across the SDK.
|
|
148
|
+
* Telemetry is OPT-IN - by default, a no-op provider is used.
|
|
149
|
+
*/
|
|
150
150
|
declare class InkeepTelemetryProvider {
|
|
151
151
|
private provider;
|
|
152
152
|
constructor(config?: TelemetryConfig);
|
|
153
153
|
/**
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
* Get a tracer for creating spans
|
|
155
|
+
*/
|
|
156
156
|
getTracer(name: string, version?: string): TelemetryTracer;
|
|
157
157
|
/**
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
* Get a logger for structured logging
|
|
159
|
+
*/
|
|
160
160
|
getLogger(name: string): TelemetryLogger;
|
|
161
161
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
* Get metrics recorder
|
|
163
|
+
*/
|
|
164
164
|
getMetrics(name: string): TelemetryMetrics;
|
|
165
165
|
/**
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
* Check if telemetry is enabled
|
|
167
|
+
*/
|
|
168
168
|
isEnabled(): boolean;
|
|
169
169
|
/**
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
* Shutdown the provider
|
|
171
|
+
*/
|
|
172
172
|
shutdown(): Promise<void>;
|
|
173
173
|
/**
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
* Get the underlying provider
|
|
175
|
+
*/
|
|
176
176
|
getProvider(): TelemetryProvider;
|
|
177
177
|
/**
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
* Set as the global telemetry provider
|
|
179
|
+
*/
|
|
180
180
|
setAsGlobal(): void;
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
* Get the global telemetry provider
|
|
184
|
+
*/
|
|
185
185
|
declare function getGlobalTelemetryProvider(): TelemetryProvider;
|
|
186
186
|
/**
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
* Set the global telemetry provider
|
|
188
|
+
*/
|
|
189
189
|
declare function setGlobalTelemetryProvider(provider: TelemetryProvider): void;
|
|
190
190
|
/**
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
* Create a no-op telemetry provider (default, does nothing)
|
|
192
|
+
*/
|
|
193
193
|
declare function createNoOpTelemetryProvider(): InkeepTelemetryProvider;
|
|
194
194
|
/**
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
* Create a console-based telemetry provider for development
|
|
196
|
+
*/
|
|
197
197
|
declare function createConsoleTelemetryProvider(serviceName?: string): InkeepTelemetryProvider;
|
|
198
198
|
/**
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
* Configuration for OpenTelemetry provider
|
|
200
|
+
*/
|
|
201
201
|
interface OpenTelemetryConfig {
|
|
202
202
|
/** Service name */
|
|
203
203
|
serviceName: string;
|
|
@@ -209,10 +209,10 @@ interface OpenTelemetryConfig {
|
|
|
209
209
|
resourceAttributes?: Record<string, string>;
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
* Create an OpenTelemetry-based provider
|
|
213
|
+
*
|
|
214
|
+
* Note: Requires @opentelemetry packages to be installed
|
|
215
|
+
*/
|
|
216
216
|
declare function createOpenTelemetryProvider(config: OpenTelemetryConfig): Promise<InkeepTelemetryProvider>;
|
|
217
217
|
//#endregion
|
|
218
218
|
export { ConsoleTelemetryProvider, InkeepTelemetryProvider, NoOpTelemetryProvider, OpenTelemetryConfig, SpanOptions, SpanStatus, SpanStatusType, TelemetryConfig, TelemetryLogger, TelemetryMetrics, TelemetryProvider, TelemetrySpan, TelemetryTracer, createConsoleTelemetryProvider, createNoOpTelemetryProvider, createOpenTelemetryProvider, getGlobalTelemetryProvider, setGlobalTelemetryProvider };
|
package/dist/tool.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ declare class Tool implements ToolInterface {
|
|
|
19
19
|
private tenantId;
|
|
20
20
|
private initialized;
|
|
21
21
|
private projectId;
|
|
22
|
-
constructor(config: Omit<MCPToolConfig,
|
|
22
|
+
constructor(config: Omit<MCPToolConfig, "tenantId" | "projectId">);
|
|
23
23
|
setContext(tenantId: string, projectId: string, baseURL?: string): void;
|
|
24
24
|
getId(): string;
|
|
25
25
|
getName(): string;
|
|
@@ -32,21 +32,21 @@ declare class Tool implements ToolInterface {
|
|
|
32
32
|
}): Promise<void>;
|
|
33
33
|
private upsertTool;
|
|
34
34
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
* Creates a new AgentMcpConfig with the given configuration.
|
|
36
|
+
*
|
|
37
|
+
* @param config - The configuration for the AgentMcpConfig
|
|
38
|
+
* @returns A new AgentMcpConfig
|
|
39
|
+
*
|
|
40
|
+
* example:
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const tool = new Tool({
|
|
43
|
+
* id: 'tool-id',
|
|
44
|
+
* name: 'Tool Name',
|
|
45
|
+
* serverUrl: 'https://example.com/mcp',
|
|
46
|
+
* });
|
|
47
|
+
* const agentMcpConfig = tool.with({ selectedTools: ['tool-1', 'tool-2'], headers: { 'Authorization': 'Bearer token' } });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
50
|
with(config: AgentMcpConfigInput): AgentMcpConfig;
|
|
51
51
|
}
|
|
52
52
|
//#endregion
|
package/dist/tool.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getLogger, normalizeToolSelections } from "@inkeep/agents-core";
|
|
2
|
+
import { convertZodToJsonSchema, isZodSchema } from "@inkeep/agents-core/utils/schema-conversion";
|
|
2
3
|
|
|
3
4
|
//#region src/tool.ts
|
|
4
5
|
const logger = getLogger("tool");
|
|
@@ -56,6 +57,24 @@ var Tool = class {
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
async upsertTool() {
|
|
60
|
+
const convertedToolOverrides = this.config.toolOverrides ? Object.fromEntries(Object.entries(this.config.toolOverrides).map(([toolName, config]) => {
|
|
61
|
+
const originalSchema = config.schema;
|
|
62
|
+
const isZod = isZodSchema(originalSchema);
|
|
63
|
+
logger.info({
|
|
64
|
+
toolName,
|
|
65
|
+
isZod,
|
|
66
|
+
originalSchema: JSON.stringify(originalSchema, null, 2)
|
|
67
|
+
}, "SDK: Converting schema before storage");
|
|
68
|
+
const convertedSchema = isZod ? convertZodToJsonSchema(originalSchema) : originalSchema;
|
|
69
|
+
logger.info({
|
|
70
|
+
toolName,
|
|
71
|
+
convertedSchema: JSON.stringify(convertedSchema, null, 2)
|
|
72
|
+
}, "SDK: Schema after conversion");
|
|
73
|
+
return [toolName, {
|
|
74
|
+
...config,
|
|
75
|
+
schema: convertedSchema
|
|
76
|
+
}];
|
|
77
|
+
})) : this.config.toolOverrides;
|
|
59
78
|
const toolDataForUpdate = {
|
|
60
79
|
id: this.getId(),
|
|
61
80
|
name: this.config.name,
|
|
@@ -67,13 +86,14 @@ var Tool = class {
|
|
|
67
86
|
mcp: {
|
|
68
87
|
server: { url: this.config.serverUrl },
|
|
69
88
|
transport: this.config.transport,
|
|
70
|
-
activeTools: this.config.activeTools
|
|
89
|
+
activeTools: this.config.activeTools,
|
|
90
|
+
toolOverrides: convertedToolOverrides
|
|
71
91
|
}
|
|
72
92
|
}
|
|
73
93
|
};
|
|
74
94
|
const toolDataForCreate = { ...toolDataForUpdate };
|
|
75
95
|
logger.info({ toolDataForCreate }, "toolDataForCreate");
|
|
76
|
-
const updateResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/tools/${this.getId()}`, {
|
|
96
|
+
const updateResponse = await fetch(`${this.baseURL}/manage/tenants/${this.tenantId}/projects/${this.projectId}/tools/${this.getId()}`, {
|
|
77
97
|
method: "PUT",
|
|
78
98
|
headers: { "Content-Type": "application/json" },
|
|
79
99
|
body: JSON.stringify(toolDataForUpdate)
|
|
@@ -85,7 +105,7 @@ var Tool = class {
|
|
|
85
105
|
}
|
|
86
106
|
if (updateResponse.status === 404) {
|
|
87
107
|
logger.info({ toolId: this.getId() }, "Tool not found, creating new tool");
|
|
88
|
-
const createResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/tools`, {
|
|
108
|
+
const createResponse = await fetch(`${this.baseURL}/manage/tenants/${this.tenantId}/projects/${this.projectId}/tools`, {
|
|
89
109
|
method: "POST",
|
|
90
110
|
headers: { "Content-Type": "application/json" },
|
|
91
111
|
body: JSON.stringify(toolDataForCreate)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { TriggerApiInsert } from "@inkeep/agents-core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/trigger.d.ts
|
|
5
|
+
type TriggerConfig = Omit<TriggerApiInsert, "id" | "inputSchema"> & {
|
|
6
|
+
id?: string;
|
|
7
|
+
inputSchema?: Record<string, unknown> | z.ZodObject<any> | null;
|
|
8
|
+
};
|
|
9
|
+
type TriggerConfigWithZod = TriggerConfig;
|
|
10
|
+
interface TriggerInterface {
|
|
11
|
+
getId(): string;
|
|
12
|
+
getName(): string;
|
|
13
|
+
getConfig(): Omit<TriggerApiInsert, "id"> & {
|
|
14
|
+
id: string;
|
|
15
|
+
};
|
|
16
|
+
with(config: Partial<TriggerConfigWithZod>): Trigger;
|
|
17
|
+
}
|
|
18
|
+
declare class Trigger implements TriggerInterface {
|
|
19
|
+
private config;
|
|
20
|
+
private id;
|
|
21
|
+
constructor(config: TriggerConfigWithZod);
|
|
22
|
+
getId(): string;
|
|
23
|
+
getName(): string;
|
|
24
|
+
getConfig(): Omit<TriggerApiInsert, "id"> & {
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new Trigger with the given configuration overrides.
|
|
29
|
+
*
|
|
30
|
+
* @param config - Partial configuration to override
|
|
31
|
+
* @returns A new Trigger instance with the merged configuration
|
|
32
|
+
*
|
|
33
|
+
* example:
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const trigger = new Trigger({
|
|
36
|
+
* name: 'GitHub Webhook',
|
|
37
|
+
* messageTemplate: 'New event: {{action}}',
|
|
38
|
+
* authentication: { type: 'none' },
|
|
39
|
+
* });
|
|
40
|
+
* const customizedTrigger = trigger.with({ enabled: false });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
with(config: Partial<TriggerConfigWithZod>): Trigger;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { Trigger, TriggerConfig, TriggerInterface };
|
package/dist/trigger.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { generateIdFromName } from "./utils/generateIdFromName.js";
|
|
2
|
+
import { getLogger } from "@inkeep/agents-core";
|
|
3
|
+
import { convertZodToJsonSchema, isZodSchema } from "@inkeep/agents-core/utils/schema-conversion";
|
|
4
|
+
|
|
5
|
+
//#region src/trigger.ts
|
|
6
|
+
const logger = getLogger("trigger");
|
|
7
|
+
var Trigger = class Trigger {
|
|
8
|
+
config;
|
|
9
|
+
id;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.id = config.id || generateIdFromName(config.name);
|
|
12
|
+
let processedInputSchema;
|
|
13
|
+
if (config.inputSchema === null) processedInputSchema = void 0;
|
|
14
|
+
else if (config.inputSchema && isZodSchema(config.inputSchema)) processedInputSchema = convertZodToJsonSchema(config.inputSchema);
|
|
15
|
+
else processedInputSchema = config.inputSchema;
|
|
16
|
+
this.config = {
|
|
17
|
+
...config,
|
|
18
|
+
id: this.id,
|
|
19
|
+
inputSchema: processedInputSchema
|
|
20
|
+
};
|
|
21
|
+
logger.info({
|
|
22
|
+
triggerId: this.getId(),
|
|
23
|
+
triggerName: config.name
|
|
24
|
+
}, "Trigger constructor initialized");
|
|
25
|
+
}
|
|
26
|
+
getId() {
|
|
27
|
+
return this.id;
|
|
28
|
+
}
|
|
29
|
+
getName() {
|
|
30
|
+
return this.config.name;
|
|
31
|
+
}
|
|
32
|
+
getConfig() {
|
|
33
|
+
return this.config;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new Trigger with the given configuration overrides.
|
|
37
|
+
*
|
|
38
|
+
* @param config - Partial configuration to override
|
|
39
|
+
* @returns A new Trigger instance with the merged configuration
|
|
40
|
+
*
|
|
41
|
+
* example:
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const trigger = new Trigger({
|
|
44
|
+
* name: 'GitHub Webhook',
|
|
45
|
+
* messageTemplate: 'New event: {{action}}',
|
|
46
|
+
* authentication: { type: 'none' },
|
|
47
|
+
* });
|
|
48
|
+
* const customizedTrigger = trigger.with({ enabled: false });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
with(config) {
|
|
52
|
+
let processedInputSchema;
|
|
53
|
+
if (config.inputSchema !== void 0) if (config.inputSchema === null) processedInputSchema = void 0;
|
|
54
|
+
else if (isZodSchema(config.inputSchema)) processedInputSchema = convertZodToJsonSchema(config.inputSchema);
|
|
55
|
+
else processedInputSchema = config.inputSchema;
|
|
56
|
+
return new Trigger({
|
|
57
|
+
...this.config,
|
|
58
|
+
...config,
|
|
59
|
+
...processedInputSchema !== void 0 && { inputSchema: processedInputSchema }
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { Trigger };
|