@inkeep/agents-core 0.0.0-chat-to-edit-20251119071712

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 (57) hide show
  1. package/LICENSE.md +56 -0
  2. package/README.md +458 -0
  3. package/SUPPLEMENTAL_TERMS.md +40 -0
  4. package/dist/auth-detection-CGqhPDnj.d.cts +435 -0
  5. package/dist/auth-detection-CGqhPDnj.d.ts +435 -0
  6. package/dist/chunk-7CLFCY6J.js +36 -0
  7. package/dist/chunk-A6JWG7FI.js +1689 -0
  8. package/dist/chunk-CMNLBV2A.js +39 -0
  9. package/dist/chunk-E6R6PML7.js +19 -0
  10. package/dist/chunk-OP3KPT4T.js +442 -0
  11. package/dist/chunk-TLSKVSBR.js +1234 -0
  12. package/dist/chunk-WG46C2WU.js +394 -0
  13. package/dist/chunk-YECQCT5N.js +223 -0
  14. package/dist/chunk-YFHT5M2R.js +18 -0
  15. package/dist/client-exports.cjs +3421 -0
  16. package/dist/client-exports.d.cts +292 -0
  17. package/dist/client-exports.d.ts +292 -0
  18. package/dist/client-exports.js +178 -0
  19. package/dist/constants/models.cjs +40 -0
  20. package/dist/constants/models.d.cts +42 -0
  21. package/dist/constants/models.d.ts +42 -0
  22. package/dist/constants/models.js +1 -0
  23. package/dist/db/schema.cjs +1686 -0
  24. package/dist/db/schema.d.cts +7 -0
  25. package/dist/db/schema.d.ts +7 -0
  26. package/dist/db/schema.js +1 -0
  27. package/dist/index.cjs +229792 -0
  28. package/dist/index.d.cts +5138 -0
  29. package/dist/index.d.ts +5138 -0
  30. package/dist/index.js +224908 -0
  31. package/dist/props-validation-BMR1qNiy.d.cts +15 -0
  32. package/dist/props-validation-BMR1qNiy.d.ts +15 -0
  33. package/dist/schema-C90zXlqp.d.ts +8012 -0
  34. package/dist/schema-keglUDw0.d.cts +8012 -0
  35. package/dist/types/index.cjs +64 -0
  36. package/dist/types/index.d.cts +175 -0
  37. package/dist/types/index.d.ts +175 -0
  38. package/dist/types/index.js +2 -0
  39. package/dist/utility-CXEG5391.d.cts +17265 -0
  40. package/dist/utility-CXEG5391.d.ts +17265 -0
  41. package/dist/utils/schema-conversion.cjs +236 -0
  42. package/dist/utils/schema-conversion.d.cts +26 -0
  43. package/dist/utils/schema-conversion.d.ts +26 -0
  44. package/dist/utils/schema-conversion.js +1 -0
  45. package/dist/validation/index.cjs +3521 -0
  46. package/dist/validation/index.d.cts +279 -0
  47. package/dist/validation/index.d.ts +279 -0
  48. package/dist/validation/index.js +2 -0
  49. package/drizzle/0000_exotic_mysterio.sql +398 -0
  50. package/drizzle/0001_greedy_the_phantom.sql +4 -0
  51. package/drizzle/0002_add_evaluation_features.sql +252 -0
  52. package/drizzle/0003_brave_micromax.sql +2 -0
  53. package/drizzle/meta/0000_snapshot.json +2519 -0
  54. package/drizzle/meta/0001_snapshot.json +2892 -0
  55. package/drizzle/meta/0002_snapshot.json +4485 -0
  56. package/drizzle/meta/_journal.json +34 -0
  57. package/package.json +133 -0
@@ -0,0 +1,394 @@
1
+ import { AgentWithinContextOfProjectSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-TLSKVSBR.js';
2
+ import { z } from 'zod';
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(
21
+ `Circular delegation detected: ${[...path.slice(cycleStart), neighbor].join(" \u2192 ")}`
22
+ );
23
+ return true;
24
+ }
25
+ }
26
+ stack.delete(node);
27
+ path.pop();
28
+ return false;
29
+ }
30
+ for (const node of graph.keys()) {
31
+ if (!visited.has(node)) {
32
+ path.length = 0;
33
+ dfs(node);
34
+ }
35
+ }
36
+ return cycles;
37
+ }
38
+ function buildDelegationGraph(agentData) {
39
+ const graph = /* @__PURE__ */ new Map();
40
+ for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
41
+ const delegates = subAgent.canDelegateTo?.filter((d) => typeof d === "string");
42
+ if (delegates?.length) {
43
+ graph.set(subAgentId, delegates);
44
+ }
45
+ }
46
+ return graph;
47
+ }
48
+
49
+ // src/validation/agentFull.ts
50
+ function validateAndTypeAgentData(data) {
51
+ return AgentWithinContextOfProjectSchema.parse(data);
52
+ }
53
+ function validateToolReferences(agentData, availableToolIds) {
54
+ if (!availableToolIds) {
55
+ return;
56
+ }
57
+ const errors = [];
58
+ for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
59
+ if (subAgent.canUse && Array.isArray(subAgent.canUse)) {
60
+ for (const canUseItem of subAgent.canUse) {
61
+ if (!availableToolIds.has(canUseItem.toolId)) {
62
+ errors.push(`Agent '${subAgentId}' references non-existent tool '${canUseItem.toolId}'`);
63
+ }
64
+ }
65
+ }
66
+ }
67
+ if (errors.length > 0) {
68
+ throw new Error(`Tool reference validation failed:
69
+ ${errors.join("\n")}`);
70
+ }
71
+ }
72
+ function validateDataComponentReferences(agentData, availableDataComponentIds) {
73
+ if (!availableDataComponentIds) {
74
+ return;
75
+ }
76
+ const errors = [];
77
+ for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
78
+ if (subAgent.dataComponents) {
79
+ for (const dataComponentId of subAgent.dataComponents) {
80
+ if (!availableDataComponentIds.has(dataComponentId)) {
81
+ errors.push(
82
+ `Agent '${subAgentId}' references non-existent dataComponent '${dataComponentId}'`
83
+ );
84
+ }
85
+ }
86
+ }
87
+ }
88
+ if (errors.length > 0) {
89
+ throw new Error(`DataComponent reference validation failed:
90
+ ${errors.join("\n")}`);
91
+ }
92
+ }
93
+ function validateArtifactComponentReferences(agentData, availableArtifactComponentIds) {
94
+ if (!availableArtifactComponentIds) {
95
+ return;
96
+ }
97
+ const errors = [];
98
+ for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
99
+ if (subAgent.artifactComponents) {
100
+ for (const artifactComponentId of subAgent.artifactComponents) {
101
+ if (!availableArtifactComponentIds.has(artifactComponentId)) {
102
+ errors.push(
103
+ `Agent '${subAgentId}' references non-existent artifactComponent '${artifactComponentId}'`
104
+ );
105
+ }
106
+ }
107
+ }
108
+ }
109
+ if (errors.length > 0) {
110
+ throw new Error(`ArtifactComponent reference validation failed:
111
+ ${errors.join("\n")}`);
112
+ }
113
+ }
114
+ function validateAgentRelationships(agentData) {
115
+ const errors = [];
116
+ const availableAgentIds = new Set(Object.keys(agentData.subAgents));
117
+ const availableExternalAgentIds = new Set(Object.keys(agentData.externalAgents ?? {}));
118
+ for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
119
+ if (subAgent.canTransferTo && Array.isArray(subAgent.canTransferTo)) {
120
+ for (const targetId of subAgent.canTransferTo) {
121
+ if (!availableAgentIds.has(targetId)) {
122
+ errors.push(
123
+ `Agent '${subAgentId}' has transfer target '${targetId}' that doesn't exist in agent`
124
+ );
125
+ }
126
+ }
127
+ }
128
+ if (subAgent.canDelegateTo && Array.isArray(subAgent.canDelegateTo)) {
129
+ for (const targetItem of subAgent.canDelegateTo) {
130
+ console.log("targetItem", targetItem);
131
+ if (typeof targetItem === "string") {
132
+ console.log("targetItem is string", targetItem);
133
+ if (!availableAgentIds.has(targetItem) && !availableExternalAgentIds.has(targetItem)) {
134
+ errors.push(
135
+ `Agent '${subAgentId}' has delegation target '${targetItem}' that doesn't exist in agent`
136
+ );
137
+ }
138
+ }
139
+ }
140
+ }
141
+ }
142
+ const cycles = detectDelegationCycles(agentData);
143
+ if (cycles.length > 0) {
144
+ errors.push(...cycles);
145
+ }
146
+ if (errors.length > 0)
147
+ throw new Error(`Agent relationship validation failed:
148
+ ${errors.join("\n")}`);
149
+ }
150
+ function validateSubAgentExternalAgentRelations(agentData, availableExternalAgentIds) {
151
+ if (!availableExternalAgentIds) {
152
+ return;
153
+ }
154
+ const errors = [];
155
+ for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
156
+ if (subAgent.canDelegateTo && Array.isArray(subAgent.canDelegateTo)) {
157
+ for (const targetItem of subAgent.canDelegateTo) {
158
+ if (typeof targetItem === "object" && "externalAgentId" in targetItem) {
159
+ if (!availableExternalAgentIds.has(targetItem.externalAgentId)) {
160
+ errors.push(
161
+ `Agent '${subAgentId}' has delegation target '${targetItem.externalAgentId}' that doesn't exist in agent`
162
+ );
163
+ }
164
+ }
165
+ }
166
+ }
167
+ }
168
+ if (errors.length > 0)
169
+ throw new Error(`Sub agent external agent relation validation failed:
170
+ ${errors.join("\n")}`);
171
+ }
172
+ function validateAgentStructure(agentData, projectResources) {
173
+ if (agentData.defaultSubAgentId && !agentData.subAgents[agentData.defaultSubAgentId]) {
174
+ throw new Error(`Default agent '${agentData.defaultSubAgentId}' does not exist in agents`);
175
+ }
176
+ if (projectResources) {
177
+ validateToolReferences(agentData, projectResources.toolIds);
178
+ validateDataComponentReferences(agentData, projectResources.dataComponentIds);
179
+ validateArtifactComponentReferences(agentData, projectResources.artifactComponentIds);
180
+ validateSubAgentExternalAgentRelations(agentData, projectResources.externalAgentIds);
181
+ }
182
+ validateAgentRelationships(agentData);
183
+ }
184
+ var TransferDataSchema = z.object({
185
+ fromSubAgent: z.string().describe("ID of the sub-agent transferring control"),
186
+ targetSubAgent: z.string().describe("ID of the sub-agent receiving control"),
187
+ reason: z.string().optional().describe("Reason for the transfer"),
188
+ context: z.any().optional().describe("Additional context data")
189
+ });
190
+ var DelegationSentDataSchema = z.object({
191
+ delegationId: z.string().describe("Unique identifier for this delegation"),
192
+ fromSubAgent: z.string().describe("ID of the delegating sub-agent"),
193
+ targetSubAgent: z.string().describe("ID of the sub-agent receiving the delegation"),
194
+ taskDescription: z.string().describe("Description of the delegated task"),
195
+ context: z.any().optional().describe("Additional context data")
196
+ });
197
+ var DelegationReturnedDataSchema = z.object({
198
+ delegationId: z.string().describe("Unique identifier matching the original delegation"),
199
+ fromSubAgent: z.string().describe("ID of the sub-agent that completed the task"),
200
+ targetSubAgent: z.string().describe("ID of the sub-agent receiving the result"),
201
+ result: z.any().optional().describe("Result data from the delegated task")
202
+ });
203
+ var DataOperationDetailsSchema = z.object({
204
+ timestamp: z.number().describe("Unix timestamp in milliseconds"),
205
+ subAgentId: z.string().describe("ID of the sub-agent that generated this data"),
206
+ data: z.any().describe("The actual data payload")
207
+ });
208
+ var DataOperationEventSchema = z.object({
209
+ type: z.string().describe("Event type identifier"),
210
+ label: z.string().describe("Human-readable label for the event"),
211
+ details: DataOperationDetailsSchema
212
+ });
213
+ var A2AMessageMetadataSchema = z.object({
214
+ fromSubAgentId: z.string().optional().describe("ID of the sending sub-agent"),
215
+ toSubAgentId: z.string().optional().describe("ID of the receiving sub-agent"),
216
+ fromExternalAgentId: z.string().optional().describe("ID of the sending external agent"),
217
+ toExternalAgentId: z.string().optional().describe("ID of the receiving external agent"),
218
+ taskId: z.string().optional().describe("Associated task ID"),
219
+ a2aTaskId: z.string().optional().describe("A2A-specific task ID")
220
+ });
221
+
222
+ // src/validation/id-validation.ts
223
+ function isValidResourceId(id) {
224
+ const result = resourceIdSchema.safeParse(id);
225
+ return result.success;
226
+ }
227
+ function generateIdFromName(name) {
228
+ const id = name.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-");
229
+ if (!id) {
230
+ throw new Error("Cannot generate valid ID from provided name");
231
+ }
232
+ const truncatedId = id.substring(0, MAX_ID_LENGTH);
233
+ const result = resourceIdSchema.safeParse(truncatedId);
234
+ if (!result.success) {
235
+ throw new Error(`Generated ID "${truncatedId}" is not valid: ${result.error.message}`);
236
+ }
237
+ return truncatedId;
238
+ }
239
+
240
+ // src/validation/render-validation.ts
241
+ var MAX_CODE_SIZE = 5e4;
242
+ var MAX_DATA_SIZE = 1e4;
243
+ var DANGEROUS_PATTERNS = [
244
+ {
245
+ pattern: /\beval\s*\(/i,
246
+ message: "eval() is not allowed"
247
+ },
248
+ {
249
+ pattern: /\bFunction\s*\(/i,
250
+ message: "Function constructor is not allowed"
251
+ },
252
+ {
253
+ pattern: /dangerouslySetInnerHTML/i,
254
+ message: "dangerouslySetInnerHTML is not allowed"
255
+ },
256
+ {
257
+ pattern: /<script\b/i,
258
+ message: "Script tags are not allowed"
259
+ },
260
+ {
261
+ pattern: /\bon\w+\s*=/i,
262
+ message: "Inline event handlers (onClick=, onLoad=, etc.) are not allowed"
263
+ },
264
+ {
265
+ pattern: /document\.write/i,
266
+ message: "document.write is not allowed"
267
+ },
268
+ {
269
+ pattern: /window\.location/i,
270
+ message: "window.location is not allowed"
271
+ },
272
+ {
273
+ pattern: /\.innerHTML\s*=/i,
274
+ message: "innerHTML manipulation is not allowed"
275
+ }
276
+ ];
277
+ var ALLOWED_IMPORTS = ["lucide-react", "react"];
278
+ function validateRender(render) {
279
+ const errors = [];
280
+ if (!render.component || typeof render.component !== "string") {
281
+ return {
282
+ isValid: false,
283
+ errors: [{ field: "render.component", message: "Component must be a non-empty string" }]
284
+ };
285
+ }
286
+ if (!render.mockData || typeof render.mockData !== "object") {
287
+ return {
288
+ isValid: false,
289
+ errors: [{ field: "render.mockData", message: "MockData must be an object" }]
290
+ };
291
+ }
292
+ if (render.component.length > MAX_CODE_SIZE) {
293
+ errors.push({
294
+ field: "render.component",
295
+ message: `Component size exceeds maximum allowed (${MAX_CODE_SIZE} characters)`
296
+ });
297
+ }
298
+ const dataString = JSON.stringify(render.mockData);
299
+ if (dataString.length > MAX_DATA_SIZE) {
300
+ errors.push({
301
+ field: "render.mockData",
302
+ message: `MockData size exceeds maximum allowed (${MAX_DATA_SIZE} characters)`
303
+ });
304
+ }
305
+ for (const { pattern, message } of DANGEROUS_PATTERNS) {
306
+ if (pattern.test(render.component)) {
307
+ errors.push({
308
+ field: "render.component",
309
+ message: `Component contains potentially dangerous pattern: ${message}`
310
+ });
311
+ }
312
+ }
313
+ const importMatches = render.component.matchAll(/import\s+.*?\s+from\s+['"]([^'"]+)['"]/g);
314
+ for (const match of importMatches) {
315
+ const importPath = match[1];
316
+ if (!ALLOWED_IMPORTS.includes(importPath) && !importPath.startsWith(".")) {
317
+ errors.push({
318
+ field: "render.component",
319
+ message: `Import from "${importPath}" is not allowed. Only imports from ${ALLOWED_IMPORTS.join(", ")} are permitted`
320
+ });
321
+ }
322
+ }
323
+ const hasFunctionDeclaration = /function\s+\w+\s*\(/.test(render.component);
324
+ if (!hasFunctionDeclaration) {
325
+ errors.push({
326
+ field: "render.component",
327
+ message: "Component must contain a function declaration"
328
+ });
329
+ }
330
+ const hasReturn = /return\s*\(?\s*</.test(render.component);
331
+ if (!hasReturn) {
332
+ errors.push({
333
+ field: "render.component",
334
+ message: "Component function must have a return statement with JSX"
335
+ });
336
+ }
337
+ return {
338
+ isValid: errors.length === 0,
339
+ errors
340
+ };
341
+ }
342
+ var TextStartEventSchema = z.object({
343
+ type: z.literal("text-start"),
344
+ id: z.string()
345
+ });
346
+ var TextDeltaEventSchema = z.object({
347
+ type: z.literal("text-delta"),
348
+ id: z.string(),
349
+ delta: z.string()
350
+ });
351
+ var TextEndEventSchema = z.object({
352
+ type: z.literal("text-end"),
353
+ id: z.string()
354
+ });
355
+ var DataComponentStreamEventSchema = z.object({
356
+ type: z.literal("data-component"),
357
+ id: z.string(),
358
+ data: z.any()
359
+ });
360
+ var DataOperationStreamEventSchema = z.object({
361
+ type: z.literal("data-operation"),
362
+ data: z.any()
363
+ // Contains OperationEvent types (AgentInitializingEvent, CompletionEvent, etc.)
364
+ });
365
+ var DataSummaryStreamEventSchema = z.object({
366
+ type: z.literal("data-summary"),
367
+ data: z.any()
368
+ // Contains SummaryEvent from entities.ts
369
+ });
370
+ var StreamErrorEventSchema = z.object({
371
+ type: z.literal("error"),
372
+ error: z.string()
373
+ });
374
+ var StreamFinishEventSchema = z.object({
375
+ type: z.literal("finish"),
376
+ finishReason: z.string().optional(),
377
+ usage: z.object({
378
+ promptTokens: z.number().optional(),
379
+ completionTokens: z.number().optional(),
380
+ totalTokens: z.number().optional()
381
+ }).optional()
382
+ });
383
+ var StreamEventSchema = z.discriminatedUnion("type", [
384
+ TextStartEventSchema,
385
+ TextDeltaEventSchema,
386
+ TextEndEventSchema,
387
+ DataComponentStreamEventSchema,
388
+ DataOperationStreamEventSchema,
389
+ DataSummaryStreamEventSchema,
390
+ StreamErrorEventSchema,
391
+ StreamFinishEventSchema
392
+ ]);
393
+
394
+ export { A2AMessageMetadataSchema, DataComponentStreamEventSchema, DataOperationDetailsSchema, DataOperationEventSchema, DataOperationStreamEventSchema, DataSummaryStreamEventSchema, DelegationReturnedDataSchema, DelegationSentDataSchema, StreamErrorEventSchema, StreamEventSchema, StreamFinishEventSchema, TextDeltaEventSchema, TextEndEventSchema, TextStartEventSchema, TransferDataSchema, generateIdFromName, isValidResourceId, validateAgentRelationships, validateAgentStructure, validateAndTypeAgentData, validateArtifactComponentReferences, validateDataComponentReferences, validateRender, validateSubAgentExternalAgentRelations, validateToolReferences };
@@ -0,0 +1,223 @@
1
+ import { __publicField } from './chunk-E6R6PML7.js';
2
+ import { z } from 'zod';
3
+ import pino from 'pino';
4
+ import pinoPretty from 'pino-pretty';
5
+
6
+ var PinoLogger = class {
7
+ constructor(name, config = {}) {
8
+ this.name = name;
9
+ __publicField(this, "transportConfigs", []);
10
+ __publicField(this, "pinoInstance");
11
+ __publicField(this, "options");
12
+ this.options = {
13
+ name: this.name,
14
+ level: process.env.LOG_LEVEL || (process.env.ENVIRONMENT === "test" ? "silent" : "info"),
15
+ serializers: {
16
+ obj: (value) => ({ ...value })
17
+ },
18
+ redact: ["req.headers.authorization", 'req.headers["x-inkeep-admin-authentication"]'],
19
+ ...config.options
20
+ };
21
+ if (config.transportConfigs) {
22
+ this.transportConfigs = config.transportConfigs;
23
+ }
24
+ if (this.transportConfigs.length > 0) {
25
+ this.pinoInstance = pino(this.options, pino.transport({ targets: this.transportConfigs }));
26
+ } else {
27
+ try {
28
+ const prettyStream = pinoPretty({
29
+ colorize: true,
30
+ translateTime: "HH:MM:ss",
31
+ ignore: "pid,hostname"
32
+ });
33
+ this.pinoInstance = pino(this.options, prettyStream);
34
+ } catch (error) {
35
+ console.warn("Warning: pino-pretty failed, using standard JSON output:", error);
36
+ this.pinoInstance = pino(this.options);
37
+ }
38
+ }
39
+ }
40
+ /**
41
+ * Recreate the pino instance with current transports
42
+ */
43
+ recreateInstance() {
44
+ if (this.pinoInstance && typeof this.pinoInstance.flush === "function") {
45
+ this.pinoInstance.flush();
46
+ }
47
+ if (this.transportConfigs.length === 0) {
48
+ try {
49
+ const prettyStream = pinoPretty({
50
+ colorize: true,
51
+ translateTime: "HH:MM:ss",
52
+ ignore: "pid,hostname"
53
+ });
54
+ this.pinoInstance = pino(this.options, prettyStream);
55
+ } catch (error) {
56
+ console.warn("Warning: pino-pretty failed, using standard JSON output:", error);
57
+ this.pinoInstance = pino(this.options);
58
+ }
59
+ } else {
60
+ const multiTransport = { targets: this.transportConfigs };
61
+ const pinoTransport = pino.transport(multiTransport);
62
+ this.pinoInstance = pino(this.options, pinoTransport);
63
+ }
64
+ }
65
+ /**
66
+ * Add a new transport to the logger
67
+ */
68
+ addTransport(transportConfig) {
69
+ this.transportConfigs.push(transportConfig);
70
+ this.recreateInstance();
71
+ }
72
+ /**
73
+ * Remove a transport by index
74
+ */
75
+ removeTransport(index) {
76
+ if (index >= 0 && index < this.transportConfigs.length) {
77
+ this.transportConfigs.splice(index, 1);
78
+ this.recreateInstance();
79
+ }
80
+ }
81
+ /**
82
+ * Get current transports
83
+ */
84
+ getTransports() {
85
+ return [...this.transportConfigs];
86
+ }
87
+ /**
88
+ * Update logger options
89
+ */
90
+ updateOptions(options) {
91
+ this.options = {
92
+ ...this.options,
93
+ ...options
94
+ };
95
+ this.recreateInstance();
96
+ }
97
+ /**
98
+ * Get the underlying pino instance for advanced usage
99
+ */
100
+ getPinoInstance() {
101
+ return this.pinoInstance;
102
+ }
103
+ error(data, message) {
104
+ this.pinoInstance.error(data, message);
105
+ }
106
+ warn(data, message) {
107
+ this.pinoInstance.warn(data, message);
108
+ }
109
+ info(data, message) {
110
+ this.pinoInstance.info(data, message);
111
+ }
112
+ debug(data, message) {
113
+ this.pinoInstance.debug(data, message);
114
+ }
115
+ };
116
+ var LoggerFactory = class {
117
+ constructor() {
118
+ __publicField(this, "config", {});
119
+ __publicField(this, "loggers", /* @__PURE__ */ new Map());
120
+ }
121
+ /**
122
+ * Configure the logger factory
123
+ */
124
+ configure(config) {
125
+ this.config = config;
126
+ this.loggers.clear();
127
+ }
128
+ /**
129
+ * Get or create a logger instance
130
+ */
131
+ getLogger(name) {
132
+ if (this.loggers.has(name)) {
133
+ const logger3 = this.loggers.get(name);
134
+ if (!logger3) {
135
+ throw new Error(`Logger '${name}' not found in cache`);
136
+ }
137
+ return logger3;
138
+ }
139
+ let logger2;
140
+ if (this.config.loggerFactory) {
141
+ logger2 = this.config.loggerFactory(name);
142
+ } else if (this.config.defaultLogger) {
143
+ logger2 = this.config.defaultLogger;
144
+ } else {
145
+ logger2 = new PinoLogger(name, this.config.pinoConfig);
146
+ }
147
+ this.loggers.set(name, logger2);
148
+ return logger2;
149
+ }
150
+ /**
151
+ * Reset factory to default state
152
+ */
153
+ reset() {
154
+ this.config = {};
155
+ this.loggers.clear();
156
+ }
157
+ };
158
+ var loggerFactory = new LoggerFactory();
159
+ function getLogger(name) {
160
+ return loggerFactory.getLogger(name);
161
+ }
162
+
163
+ // src/utils/schema-conversion.ts
164
+ var logger = getLogger("schema-conversion");
165
+ function convertZodToJsonSchema(zodSchema) {
166
+ try {
167
+ const jsonSchema = z.toJSONSchema(zodSchema);
168
+ if (jsonSchema.$schema) {
169
+ delete jsonSchema.$schema;
170
+ }
171
+ return jsonSchema;
172
+ } catch (error) {
173
+ logger.error(
174
+ {
175
+ error: error instanceof Error ? error.message : "Unknown error",
176
+ stack: error instanceof Error ? error.stack : void 0
177
+ },
178
+ "Failed to convert Zod schema to JSON Schema"
179
+ );
180
+ throw new Error("Failed to convert Zod schema to JSON Schema");
181
+ }
182
+ }
183
+ var preview = (schema) => {
184
+ schema._def.inPreview = true;
185
+ return schema;
186
+ };
187
+ function convertZodToJsonSchemaWithPreview(zodSchema) {
188
+ const jsonSchema = convertZodToJsonSchema(zodSchema);
189
+ if (zodSchema instanceof z.ZodObject && jsonSchema.properties) {
190
+ const shape = zodSchema.shape;
191
+ for (const [key, fieldSchema] of Object.entries(shape)) {
192
+ if (fieldSchema?._def?.inPreview === true) {
193
+ jsonSchema.properties[key].inPreview = true;
194
+ }
195
+ }
196
+ }
197
+ return jsonSchema;
198
+ }
199
+ function isZodSchema(value) {
200
+ return value?._def?.type === "object";
201
+ }
202
+ function extractPreviewFields(schema) {
203
+ const previewFields = [];
204
+ if (schema instanceof z.ZodObject) {
205
+ const shape = schema.shape;
206
+ for (const [key, fieldSchema] of Object.entries(shape)) {
207
+ if (fieldSchema?._def?.inPreview === true) {
208
+ previewFields.push(key);
209
+ }
210
+ }
211
+ return previewFields;
212
+ }
213
+ if (schema?.type === "object" && schema.properties) {
214
+ for (const [key, prop] of Object.entries(schema.properties)) {
215
+ if (prop.inPreview === true) {
216
+ previewFields.push(key);
217
+ }
218
+ }
219
+ }
220
+ return previewFields;
221
+ }
222
+
223
+ export { PinoLogger, convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, extractPreviewFields, getLogger, isZodSchema, loggerFactory, preview };
@@ -0,0 +1,18 @@
1
+ // src/types/utility.ts
2
+ var TOOL_STATUS_VALUES = ["healthy", "unhealthy", "unknown", "needs_auth"];
3
+ var VALID_RELATION_TYPES = ["transfer", "delegate"];
4
+ var MCPTransportType = {
5
+ streamableHttp: "streamable_http",
6
+ sse: "sse"
7
+ };
8
+ var MCPServerType = {
9
+ nango: "nango",
10
+ generic: "generic"
11
+ };
12
+ var CredentialStoreType = {
13
+ memory: "memory",
14
+ keychain: "keychain",
15
+ nango: "nango"
16
+ };
17
+
18
+ export { CredentialStoreType, MCPServerType, MCPTransportType, TOOL_STATUS_VALUES, VALID_RELATION_TYPES };