@inkeep/agents-sdk 0.39.5 → 0.41.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 (59) hide show
  1. package/dist/_virtual/rolldown_runtime.js +7 -0
  2. package/dist/agent.d.ts +186 -0
  3. package/dist/agent.js +720 -0
  4. package/dist/agentFullClient.d.ts +22 -0
  5. package/dist/agentFullClient.js +120 -0
  6. package/dist/artifact-component.d.ts +34 -0
  7. package/dist/artifact-component.js +104 -0
  8. package/dist/builderFunctions.d.ts +283 -0
  9. package/dist/builderFunctions.js +327 -0
  10. package/dist/builderFunctionsExperimental.d.ts +24 -0
  11. package/dist/builderFunctionsExperimental.js +27 -0
  12. package/dist/builders.d.ts +111 -0
  13. package/dist/builders.js +52 -0
  14. package/dist/credential-provider.d.ts +176 -0
  15. package/dist/credential-provider.js +237 -0
  16. package/dist/credential-ref.d.ts +60 -0
  17. package/dist/credential-ref.js +33 -0
  18. package/dist/data-component.d.ts +39 -0
  19. package/dist/data-component.js +109 -0
  20. package/dist/environment-settings.d.ts +27 -0
  21. package/dist/environment-settings.js +41 -0
  22. package/dist/external-agent.d.ts +64 -0
  23. package/dist/external-agent.js +156 -0
  24. package/dist/function-tool.d.ts +37 -0
  25. package/dist/function-tool.js +66 -0
  26. package/dist/index.d.ts +19 -1825
  27. package/dist/index.js +19 -4058
  28. package/dist/module-hosted-tool-manager.d.ts +40 -0
  29. package/dist/module-hosted-tool-manager.js +359 -0
  30. package/dist/project.d.ts +214 -0
  31. package/dist/project.js +615 -0
  32. package/dist/projectFullClient.d.ts +23 -0
  33. package/dist/projectFullClient.js +162 -0
  34. package/dist/runner.d.ts +41 -0
  35. package/dist/runner.js +145 -0
  36. package/dist/status-component.d.ts +22 -0
  37. package/dist/status-component.js +36 -0
  38. package/dist/subAgent.d.ts +52 -0
  39. package/dist/subAgent.js +616 -0
  40. package/dist/telemetry-provider.d.ts +218 -0
  41. package/dist/telemetry-provider.js +390 -0
  42. package/dist/tool.d.ts +53 -0
  43. package/dist/tool.js +130 -0
  44. package/dist/types.d.ts +296 -0
  45. package/dist/types.js +39 -0
  46. package/dist/utils/generateIdFromName.d.ts +9 -0
  47. package/dist/utils/generateIdFromName.js +12 -0
  48. package/dist/utils/getFunctionToolDeps.d.ts +17 -0
  49. package/dist/utils/getFunctionToolDeps.js +131 -0
  50. package/dist/utils/tool-normalization.d.ts +42 -0
  51. package/dist/utils/tool-normalization.js +41 -0
  52. package/dist/utils/validateFunction.d.ts +10 -0
  53. package/dist/utils/validateFunction.js +13 -0
  54. package/package.json +11 -16
  55. package/dist/index.cjs +0 -4147
  56. package/dist/index.d.cts +0 -1825
  57. package/dist/index.d.cts.map +0 -1
  58. package/dist/index.d.ts.map +0 -1
  59. package/dist/index.js.map +0 -1
@@ -0,0 +1,176 @@
1
+ //#region src/credential-provider.d.ts
2
+ /**
3
+ * InkeepCredentialProvider - Abstraction for Credential Management
4
+ *
5
+ * This module provides a clean abstraction over credential provider implementations.
6
+ * Cloud customers can use this without needing to know about or install internal
7
+ * dependencies like Nango.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * // Simple usage with environment variables (default)
12
+ * import { InkeepCredentialProvider } from '@inkeep/agents-sdk'
13
+ *
14
+ * const credentials = new InkeepCredentialProvider()
15
+ *
16
+ * // With custom configuration
17
+ * const credentials = new InkeepCredentialProvider({
18
+ * type: 'memory',
19
+ * id: 'my-store'
20
+ * })
21
+ * ```
22
+ */
23
+ /**
24
+ * Base interface for all credential stores
25
+ * This is a simplified version for SDK customers
26
+ */
27
+ interface CredentialStore {
28
+ /** Unique identifier for this credential store */
29
+ readonly id: string;
30
+ /** Type of credential store */
31
+ readonly type: CredentialProviderType;
32
+ /** Get a credential by key */
33
+ get(key: string): Promise<string | null>;
34
+ /** Set a credential */
35
+ set(key: string, value: string, metadata?: Record<string, string>): Promise<void>;
36
+ /** Check if a credential exists */
37
+ has(key: string): Promise<boolean>;
38
+ /** Delete a credential */
39
+ delete(key: string): Promise<boolean>;
40
+ /** Check if the credential store is available */
41
+ checkAvailability(): Promise<{
42
+ available: boolean;
43
+ reason?: string;
44
+ }>;
45
+ }
46
+ /**
47
+ * Supported credential provider types
48
+ */
49
+ type CredentialProviderType = 'memory' | 'keychain' | 'nango' | 'custom';
50
+ /**
51
+ * Configuration for memory-based credential storage
52
+ */
53
+ interface MemoryCredentialConfig {
54
+ type: 'memory';
55
+ /** Optional store ID (defaults to 'memory-default') */
56
+ id?: string;
57
+ }
58
+ /**
59
+ * Configuration for keychain-based credential storage
60
+ */
61
+ interface KeychainCredentialConfig {
62
+ type: 'keychain';
63
+ /** Optional store ID (defaults to 'keychain-default') */
64
+ id?: string;
65
+ /** Optional service name for keychain entries */
66
+ serviceName?: string;
67
+ }
68
+ /**
69
+ * Configuration for Nango-based credential storage (OAuth management)
70
+ * Note: Using Nango requires the @nangohq/node package to be installed
71
+ */
72
+ interface NangoCredentialConfig {
73
+ type: 'nango';
74
+ /** Optional store ID (defaults to 'nango-default') */
75
+ id?: string;
76
+ /** Nango secret key (defaults to NANGO_SECRET_KEY env var) */
77
+ secretKey?: string;
78
+ /** Nango API URL (defaults to https://api.nango.dev) */
79
+ apiUrl?: string;
80
+ }
81
+ /**
82
+ * Configuration for custom credential provider
83
+ */
84
+ interface CustomCredentialConfig {
85
+ type: 'custom';
86
+ /** Custom credential store implementation */
87
+ store: CredentialStore;
88
+ }
89
+ /**
90
+ * Union type for all credential provider configurations
91
+ */
92
+ type CredentialProviderConfig = MemoryCredentialConfig | KeychainCredentialConfig | NangoCredentialConfig | CustomCredentialConfig;
93
+ /**
94
+ * InkeepCredentialProvider - Unified credential management for Inkeep SDK
95
+ *
96
+ * Provides a clean abstraction over various credential storage backends.
97
+ * Cloud customers can use simple memory-based storage, while advanced
98
+ * users can integrate with OAuth providers like Nango.
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * // Default memory-based storage
103
+ * const provider = new InkeepCredentialProvider()
104
+ *
105
+ * // Store and retrieve credentials
106
+ * await provider.set('my-api-key', 'secret-value')
107
+ * const key = await provider.get('my-api-key')
108
+ *
109
+ * // Use environment variables automatically
110
+ * process.env.MY_TOKEN = 'env-token'
111
+ * const token = await provider.get('MY_TOKEN') // Returns 'env-token'
112
+ * ```
113
+ */
114
+ declare class InkeepCredentialProvider implements CredentialStore {
115
+ private store;
116
+ constructor(config?: CredentialProviderConfig);
117
+ /**
118
+ * Create the appropriate store based on configuration
119
+ */
120
+ private createStore;
121
+ /**
122
+ * Create keychain store with dynamic import
123
+ */
124
+ private createKeychainStore;
125
+ /**
126
+ * Create Nango store with dynamic import
127
+ */
128
+ private createNangoStore;
129
+ get id(): string;
130
+ get type(): CredentialProviderType;
131
+ /**
132
+ * Get a credential by key
133
+ * @param key - The credential key
134
+ * @returns The credential value or null if not found
135
+ */
136
+ get(key: string): Promise<string | null>;
137
+ /**
138
+ * Set a credential
139
+ * @param key - The credential key
140
+ * @param value - The credential value
141
+ * @param metadata - Optional metadata
142
+ */
143
+ set(key: string, value: string, metadata?: Record<string, string>): Promise<void>;
144
+ /**
145
+ * Check if a credential exists
146
+ * @param key - The credential key
147
+ * @returns True if the credential exists
148
+ */
149
+ has(key: string): Promise<boolean>;
150
+ /**
151
+ * Delete a credential
152
+ * @param key - The credential key
153
+ * @returns True if the credential was deleted
154
+ */
155
+ delete(key: string): Promise<boolean>;
156
+ /**
157
+ * Check if the credential store is available and functional
158
+ * @returns Availability status
159
+ */
160
+ checkAvailability(): Promise<{
161
+ available: boolean;
162
+ reason?: string;
163
+ }>;
164
+ /**
165
+ * Get the underlying store (for advanced use cases)
166
+ */
167
+ getStore(): CredentialStore;
168
+ }
169
+ /**
170
+ * Factory function to create an InkeepCredentialProvider
171
+ * @param config - Configuration options
172
+ * @returns A new InkeepCredentialProvider instance
173
+ */
174
+ declare function createCredentialProvider(config?: CredentialProviderConfig): InkeepCredentialProvider;
175
+ //#endregion
176
+ export { CredentialProviderConfig, CredentialProviderType, CredentialStore, CustomCredentialConfig, InkeepCredentialProvider, KeychainCredentialConfig, MemoryCredentialConfig, NangoCredentialConfig, createCredentialProvider };
@@ -0,0 +1,237 @@
1
+ //#region src/credential-provider.ts
2
+ /**
3
+ * Default configuration using memory store
4
+ */
5
+ const DEFAULT_CONFIG = {
6
+ type: "memory",
7
+ id: "memory-default"
8
+ };
9
+ /**
10
+ * Simple in-memory credential store implementation
11
+ * Automatically loads from environment variables as fallback
12
+ */
13
+ var InMemoryStore = class {
14
+ id;
15
+ type = "memory";
16
+ credentials = /* @__PURE__ */ new Map();
17
+ constructor(id = "memory-default") {
18
+ this.id = id;
19
+ }
20
+ async get(key) {
21
+ const credential = this.credentials.get(key);
22
+ if (!credential) {
23
+ const envValue = process.env[key];
24
+ if (envValue) {
25
+ this.credentials.set(key, envValue);
26
+ return envValue;
27
+ }
28
+ return null;
29
+ }
30
+ return credential;
31
+ }
32
+ async set(key, value, _metadata) {
33
+ this.credentials.set(key, value);
34
+ }
35
+ async has(key) {
36
+ return this.credentials.has(key) || !!process.env[key];
37
+ }
38
+ async delete(key) {
39
+ return this.credentials.delete(key);
40
+ }
41
+ async checkAvailability() {
42
+ return { available: true };
43
+ }
44
+ };
45
+ /**
46
+ * InkeepCredentialProvider - Unified credential management for Inkeep SDK
47
+ *
48
+ * Provides a clean abstraction over various credential storage backends.
49
+ * Cloud customers can use simple memory-based storage, while advanced
50
+ * users can integrate with OAuth providers like Nango.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * // Default memory-based storage
55
+ * const provider = new InkeepCredentialProvider()
56
+ *
57
+ * // Store and retrieve credentials
58
+ * await provider.set('my-api-key', 'secret-value')
59
+ * const key = await provider.get('my-api-key')
60
+ *
61
+ * // Use environment variables automatically
62
+ * process.env.MY_TOKEN = 'env-token'
63
+ * const token = await provider.get('MY_TOKEN') // Returns 'env-token'
64
+ * ```
65
+ */
66
+ var InkeepCredentialProvider = class {
67
+ store;
68
+ constructor(config = DEFAULT_CONFIG) {
69
+ this.store = this.createStore(config);
70
+ }
71
+ /**
72
+ * Create the appropriate store based on configuration
73
+ */
74
+ createStore(config) {
75
+ switch (config.type) {
76
+ case "memory": return new InMemoryStore(config.id);
77
+ case "keychain": return this.createKeychainStore(config);
78
+ case "nango": return this.createNangoStore(config);
79
+ case "custom": return config.store;
80
+ default: throw new Error(`Unknown credential provider type: ${config.type}`);
81
+ }
82
+ }
83
+ /**
84
+ * Create keychain store with dynamic import
85
+ */
86
+ createKeychainStore(config) {
87
+ const storeId = config.id || "keychain-default";
88
+ return {
89
+ id: storeId,
90
+ type: "keychain",
91
+ get: async (key) => {
92
+ const { createKeyChainStore } = await import("@inkeep/agents-core/credential-stores");
93
+ return createKeyChainStore(storeId).get(key);
94
+ },
95
+ set: async (key, value, metadata) => {
96
+ const { createKeyChainStore } = await import("@inkeep/agents-core/credential-stores");
97
+ return createKeyChainStore(storeId).set(key, value, metadata);
98
+ },
99
+ has: async (key) => {
100
+ const { createKeyChainStore } = await import("@inkeep/agents-core/credential-stores");
101
+ return createKeyChainStore(storeId).has(key);
102
+ },
103
+ delete: async (key) => {
104
+ const { createKeyChainStore } = await import("@inkeep/agents-core/credential-stores");
105
+ return createKeyChainStore(storeId).delete(key);
106
+ },
107
+ checkAvailability: async () => {
108
+ try {
109
+ const { createKeyChainStore } = await import("@inkeep/agents-core/credential-stores");
110
+ return createKeyChainStore(storeId).checkAvailability();
111
+ } catch {
112
+ return {
113
+ available: false,
114
+ reason: "Keychain store requires keytar package to be installed"
115
+ };
116
+ }
117
+ }
118
+ };
119
+ }
120
+ /**
121
+ * Create Nango store with dynamic import
122
+ */
123
+ createNangoStore(config) {
124
+ const storeId = config.id || "nango-default";
125
+ const secretKey = config.secretKey;
126
+ const apiUrl = config.apiUrl;
127
+ return {
128
+ id: storeId,
129
+ type: "nango",
130
+ get: async (key) => {
131
+ const { createNangoCredentialStore } = await import("@inkeep/agents-core/credential-stores");
132
+ return createNangoCredentialStore(storeId, {
133
+ secretKey,
134
+ apiUrl
135
+ }).get(key);
136
+ },
137
+ set: async (key, value, metadata) => {
138
+ const { createNangoCredentialStore } = await import("@inkeep/agents-core/credential-stores");
139
+ return createNangoCredentialStore(storeId, {
140
+ secretKey,
141
+ apiUrl
142
+ }).set(key, value, metadata);
143
+ },
144
+ has: async (key) => {
145
+ const { createNangoCredentialStore } = await import("@inkeep/agents-core/credential-stores");
146
+ return createNangoCredentialStore(storeId, {
147
+ secretKey,
148
+ apiUrl
149
+ }).has(key);
150
+ },
151
+ delete: async (key) => {
152
+ const { createNangoCredentialStore } = await import("@inkeep/agents-core/credential-stores");
153
+ return createNangoCredentialStore(storeId, {
154
+ secretKey,
155
+ apiUrl
156
+ }).delete(key);
157
+ },
158
+ checkAvailability: async () => {
159
+ try {
160
+ const { createNangoCredentialStore } = await import("@inkeep/agents-core/credential-stores");
161
+ return createNangoCredentialStore(storeId, {
162
+ secretKey,
163
+ apiUrl
164
+ }).checkAvailability();
165
+ } catch (error) {
166
+ return {
167
+ available: false,
168
+ reason: error instanceof Error ? error.message : "Nango store requires @nangohq/node package and NANGO_SECRET_KEY"
169
+ };
170
+ }
171
+ }
172
+ };
173
+ }
174
+ get id() {
175
+ return this.store.id;
176
+ }
177
+ get type() {
178
+ return this.store.type;
179
+ }
180
+ /**
181
+ * Get a credential by key
182
+ * @param key - The credential key
183
+ * @returns The credential value or null if not found
184
+ */
185
+ async get(key) {
186
+ return this.store.get(key);
187
+ }
188
+ /**
189
+ * Set a credential
190
+ * @param key - The credential key
191
+ * @param value - The credential value
192
+ * @param metadata - Optional metadata
193
+ */
194
+ async set(key, value, metadata) {
195
+ return this.store.set(key, value, metadata);
196
+ }
197
+ /**
198
+ * Check if a credential exists
199
+ * @param key - The credential key
200
+ * @returns True if the credential exists
201
+ */
202
+ async has(key) {
203
+ return this.store.has(key);
204
+ }
205
+ /**
206
+ * Delete a credential
207
+ * @param key - The credential key
208
+ * @returns True if the credential was deleted
209
+ */
210
+ async delete(key) {
211
+ return this.store.delete(key);
212
+ }
213
+ /**
214
+ * Check if the credential store is available and functional
215
+ * @returns Availability status
216
+ */
217
+ async checkAvailability() {
218
+ return this.store.checkAvailability();
219
+ }
220
+ /**
221
+ * Get the underlying store (for advanced use cases)
222
+ */
223
+ getStore() {
224
+ return this.store;
225
+ }
226
+ };
227
+ /**
228
+ * Factory function to create an InkeepCredentialProvider
229
+ * @param config - Configuration options
230
+ * @returns A new InkeepCredentialProvider instance
231
+ */
232
+ function createCredentialProvider(config = DEFAULT_CONFIG) {
233
+ return new InkeepCredentialProvider(config);
234
+ }
235
+
236
+ //#endregion
237
+ export { InkeepCredentialProvider, createCredentialProvider };
@@ -0,0 +1,60 @@
1
+ //#region src/credential-ref.d.ts
2
+ /**
3
+ * Credential Reference System
4
+ *
5
+ * This module provides a way to reference credentials by ID without including
6
+ * the full credential definition in the code. Credentials are resolved from
7
+ * environment files at runtime during the push operation.
8
+ */
9
+ /**
10
+ * Represents a reference to a credential by its ID.
11
+ * The actual credential will be resolved from the environment file at push time.
12
+ */
13
+ interface CredentialReference {
14
+ __type: 'credential-ref';
15
+ id: string;
16
+ }
17
+ /**
18
+ * Create a reference to a credential by its ID.
19
+ * The credential must be defined in the environment files.
20
+ *
21
+ * @param id - The ID of the credential to reference
22
+ * @returns A credential reference that will be resolved at push time
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const apiKeyRef = credentialRef('api-key');
27
+ *
28
+ * const fetchDef = fetchDefinition({
29
+ * credential: apiKeyRef,
30
+ * // ...
31
+ * });
32
+ * ```
33
+ */
34
+ declare function credentialRef<T extends string = string>(id: T): CredentialReference;
35
+ /**
36
+ * Type guard to check if a value is a credential reference
37
+ */
38
+ declare function isCredentialReference(value: any): value is CredentialReference;
39
+ /**
40
+ * Type helper to extract credential IDs from environment configuration
41
+ */
42
+ type ExtractCredentialIds<T> = T extends {
43
+ credentials?: infer C;
44
+ } ? C extends Record<string, any> ? keyof C : never : never;
45
+ /**
46
+ * Type helper to create a union of all available credential IDs from multiple environments
47
+ */
48
+ type UnionCredentialIds<T extends Record<string, any>> = { [K in keyof T]: ExtractCredentialIds<T[K]> }[keyof T];
49
+ /**
50
+ * Type helper to extract tool IDs from environment configuration
51
+ */
52
+ type ExtractMcpServerIds<T> = T extends {
53
+ mcpServers?: infer T;
54
+ } ? T extends Record<string, any> ? keyof T : never : never;
55
+ /**
56
+ * Type helper to create a union of all available tool IDs from multiple environments
57
+ */
58
+ type UnionMcpServerIds<T extends Record<string, any>> = { [K in keyof T]: ExtractMcpServerIds<T[K]> }[keyof T];
59
+ //#endregion
60
+ export { CredentialReference, ExtractCredentialIds, ExtractMcpServerIds, UnionCredentialIds, UnionMcpServerIds, credentialRef, isCredentialReference };
@@ -0,0 +1,33 @@
1
+ //#region src/credential-ref.ts
2
+ /**
3
+ * Create a reference to a credential by its ID.
4
+ * The credential must be defined in the environment files.
5
+ *
6
+ * @param id - The ID of the credential to reference
7
+ * @returns A credential reference that will be resolved at push time
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const apiKeyRef = credentialRef('api-key');
12
+ *
13
+ * const fetchDef = fetchDefinition({
14
+ * credential: apiKeyRef,
15
+ * // ...
16
+ * });
17
+ * ```
18
+ */
19
+ function credentialRef(id) {
20
+ return {
21
+ __type: "credential-ref",
22
+ id
23
+ };
24
+ }
25
+ /**
26
+ * Type guard to check if a value is a credential reference
27
+ */
28
+ function isCredentialReference(value) {
29
+ return value && typeof value === "object" && value.__type === "credential-ref";
30
+ }
31
+
32
+ //#endregion
33
+ export { credentialRef, isCredentialReference };
@@ -0,0 +1,39 @@
1
+ import { DataComponentInsert } from "@inkeep/agents-core";
2
+ import { z } from "zod";
3
+
4
+ //#region src/data-component.d.ts
5
+ type DataComponentConfigWithZod = Omit<DataComponentInsert, 'tenantId' | 'projectId' | 'props' | 'render'> & {
6
+ props?: Record<string, unknown> | z.ZodObject<any> | null;
7
+ render?: {
8
+ component: string;
9
+ mockData: Record<string, unknown>;
10
+ } | null;
11
+ };
12
+ interface DataComponentInterface {
13
+ config: Omit<DataComponentInsert, 'tenantId' | 'projectId'>;
14
+ init(): Promise<void>;
15
+ getId(): DataComponentInsert['id'];
16
+ getName(): DataComponentInsert['name'];
17
+ getDescription(): DataComponentInsert['description'];
18
+ getProps(): DataComponentInsert['props'];
19
+ setContext(tenantId: string, projectId: string, baseURL?: string): void;
20
+ }
21
+ declare class DataComponent implements DataComponentInterface {
22
+ config: Omit<DataComponentInsert, 'tenantId' | 'projectId'>;
23
+ private baseURL;
24
+ private tenantId;
25
+ private projectId;
26
+ private initialized;
27
+ private id;
28
+ constructor(config: DataComponentConfigWithZod);
29
+ setContext(tenantId: string, projectId: string, baseURL?: string): void;
30
+ getId(): string;
31
+ getName(): string;
32
+ getDescription(): string;
33
+ getProps(): DataComponentInsert['props'];
34
+ getRender(): DataComponentInsert['render'];
35
+ init(): Promise<void>;
36
+ private upsertDataComponent;
37
+ }
38
+ //#endregion
39
+ export { DataComponent, DataComponentInterface };
@@ -0,0 +1,109 @@
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/data-component.ts
6
+ const logger = getLogger("dataComponent");
7
+ var DataComponent = class {
8
+ config;
9
+ baseURL;
10
+ tenantId;
11
+ projectId;
12
+ initialized = false;
13
+ id;
14
+ constructor(config) {
15
+ this.id = config.id || generateIdFromName(config.name);
16
+ let processedProps;
17
+ if (config.props && isZodSchema(config.props)) processedProps = convertZodToJsonSchema(config.props);
18
+ else processedProps = config.props;
19
+ this.config = {
20
+ ...config,
21
+ id: this.id,
22
+ props: processedProps,
23
+ render: config.render || null
24
+ };
25
+ this.baseURL = process.env.INKEEP_API_URL || "http://localhost:3002";
26
+ this.tenantId = "default";
27
+ this.projectId = "default";
28
+ logger.info({
29
+ dataComponentId: this.getId(),
30
+ dataComponentName: config.name
31
+ }, "DataComponent constructor initialized");
32
+ }
33
+ setContext(tenantId, projectId, baseURL) {
34
+ this.tenantId = tenantId;
35
+ this.projectId = projectId;
36
+ if (baseURL) this.baseURL = baseURL;
37
+ }
38
+ getId() {
39
+ return this.id;
40
+ }
41
+ getName() {
42
+ return this.config.name;
43
+ }
44
+ getDescription() {
45
+ return this.config.description || "";
46
+ }
47
+ getProps() {
48
+ return this.config.props;
49
+ }
50
+ getRender() {
51
+ return this.config.render;
52
+ }
53
+ async init() {
54
+ if (this.initialized) return;
55
+ try {
56
+ await this.upsertDataComponent();
57
+ logger.info({ dataComponentId: this.getId() }, "DataComponent initialized successfully");
58
+ this.initialized = true;
59
+ } catch (error) {
60
+ logger.error({
61
+ dataComponentId: this.getId(),
62
+ error: error instanceof Error ? error.message : "Unknown error"
63
+ }, "Failed to initialize data component");
64
+ throw error;
65
+ }
66
+ }
67
+ async upsertDataComponent() {
68
+ const dataComponentData = {
69
+ id: this.getId(),
70
+ name: this.config.name,
71
+ description: this.config.description,
72
+ props: this.config.props,
73
+ render: this.config.render
74
+ };
75
+ logger.info({ dataComponentData }, "dataComponentData for create/update");
76
+ const updateResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/data-components/${this.getId()}`, {
77
+ method: "PUT",
78
+ headers: { "Content-Type": "application/json" },
79
+ body: JSON.stringify(dataComponentData)
80
+ });
81
+ logger.info({
82
+ status: updateResponse.status,
83
+ dataComponentId: this.getId()
84
+ }, "data component updateResponse");
85
+ if (updateResponse.ok) {
86
+ logger.info({ dataComponentId: this.getId() }, "DataComponent updated successfully");
87
+ return;
88
+ }
89
+ if (updateResponse.status === 404) {
90
+ logger.info({ dataComponentId: this.getId() }, "DataComponent not found, creating new data component");
91
+ const createResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/data-components`, {
92
+ method: "POST",
93
+ headers: { "Content-Type": "application/json" },
94
+ body: JSON.stringify(dataComponentData)
95
+ });
96
+ if (!createResponse.ok) {
97
+ const errorText$1 = await createResponse.text().catch(() => "Unknown error");
98
+ throw new Error(`Failed to create data component: ${createResponse.status} ${createResponse.statusText} - ${errorText$1}`);
99
+ }
100
+ logger.info({ dataComponentId: this.getId() }, "DataComponent created successfully");
101
+ return;
102
+ }
103
+ const errorText = await updateResponse.text().catch(() => "Unknown error");
104
+ throw new Error(`Failed to update data component: ${updateResponse.status} ${updateResponse.statusText} - ${errorText}`);
105
+ }
106
+ };
107
+
108
+ //#endregion
109
+ export { DataComponent };
@@ -0,0 +1,27 @@
1
+ import { Tool } from "./tool.js";
2
+ import { ExtractCredentialIds, ExtractMcpServerIds, UnionCredentialIds, UnionMcpServerIds } from "./credential-ref.js";
3
+ import { CredentialReferenceApiInsert } from "@inkeep/agents-core";
4
+
5
+ //#region src/environment-settings.d.ts
6
+ interface EnvironmentSettingsConfig {
7
+ credentials?: {
8
+ [settingId: string]: CredentialReferenceApiInsert;
9
+ };
10
+ mcpServers?: {
11
+ [mcpServerId: string]: Tool;
12
+ };
13
+ }
14
+ /**
15
+ * Create a setting helper with TypeScript autocomplete
16
+ */
17
+ declare function createEnvironmentSettings<T extends Record<string, EnvironmentSettingsConfig>>(environments: T): {
18
+ getEnvironmentCredential: (key: UnionCredentialIds<T>) => CredentialReferenceApiInsert;
19
+ getEnvironmentMcp: (key: UnionMcpServerIds<T>) => Tool;
20
+ getEnvironmentSetting: (key: UnionCredentialIds<T>) => CredentialReferenceApiInsert;
21
+ };
22
+ /**
23
+ * Create type-safe environment configurations
24
+ */
25
+ declare function registerEnvironmentSettings<T extends EnvironmentSettingsConfig>(config: T): T;
26
+ //#endregion
27
+ export { type ExtractCredentialIds, type ExtractMcpServerIds, type UnionCredentialIds, type UnionMcpServerIds, createEnvironmentSettings, registerEnvironmentSettings };