@inkeep/agents-core 0.22.9 → 0.22.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { subAgents, subAgentRelations, agents, tasks, taskRelations, tools, conversations, messages, contextCache, dataComponents, subAgentDataComponents, artifactComponents, subAgentArtifactComponents, externalAgents, apiKeys, credentialReferences, functionTools, functions, contextConfigs, subAgentToolRelations, ledgerArtifacts, projects } from './chunk-PR3DDXVU.js';
1
+ import { subAgents, subAgentRelations, agents, tasks, taskRelations, tools, conversations, messages, contextCache, dataComponents, subAgentDataComponents, artifactComponents, subAgentArtifactComponents, externalAgents, apiKeys, credentialReferences, functionTools, functions, contextConfigs, subAgentToolRelations, ledgerArtifacts, projects } from './chunk-5B6IOJZY.js';
2
2
  import { VALID_RELATION_TYPES, MCPTransportType, TOOL_STATUS_VALUES, CredentialStoreType, MCPServerType } from './chunk-YFHT5M2R.js';
3
3
  import { z } from '@hono/zod-openapi';
4
4
  import { createSelectSchema, createInsertSchema } from 'drizzle-zod';
@@ -266,6 +266,7 @@ var dataComponents = sqliteTable(
266
266
  ...projectScoped,
267
267
  ...uiProperties,
268
268
  props: blob("props", { mode: "json" }).$type(),
269
+ preview: blob("preview", { mode: "json" }).$type(),
269
270
  ...timestamps
270
271
  },
271
272
  (table) => [
@@ -1,44 +1,6 @@
1
- import { AgentWithinContextOfProjectSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-F3AFTJB7.js';
1
+ import { AgentWithinContextOfProjectSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-4SE2FOJY.js';
2
2
  import { z } from 'zod';
3
3
 
4
- var TransferDataSchema = z.object({
5
- fromSubAgent: z.string().describe("ID of the sub-agent transferring control"),
6
- targetSubAgent: z.string().describe("ID of the sub-agent receiving control"),
7
- reason: z.string().optional().describe("Reason for the transfer"),
8
- context: z.any().optional().describe("Additional context data")
9
- });
10
- var DelegationSentDataSchema = z.object({
11
- delegationId: z.string().describe("Unique identifier for this delegation"),
12
- fromSubAgent: z.string().describe("ID of the delegating sub-agent"),
13
- targetSubAgent: z.string().describe("ID of the sub-agent receiving the delegation"),
14
- taskDescription: z.string().describe("Description of the delegated task"),
15
- context: z.any().optional().describe("Additional context data")
16
- });
17
- var DelegationReturnedDataSchema = z.object({
18
- delegationId: z.string().describe("Unique identifier matching the original delegation"),
19
- fromSubAgent: z.string().describe("ID of the sub-agent that completed the task"),
20
- targetSubAgent: z.string().describe("ID of the sub-agent receiving the result"),
21
- result: z.any().optional().describe("Result data from the delegated task")
22
- });
23
- var DataOperationDetailsSchema = z.object({
24
- timestamp: z.number().describe("Unix timestamp in milliseconds"),
25
- subAgentId: z.string().describe("ID of the sub-agent that generated this data"),
26
- data: z.any().describe("The actual data payload")
27
- });
28
- var DataOperationEventSchema = z.object({
29
- type: z.string().describe("Event type identifier"),
30
- label: z.string().describe("Human-readable label for the event"),
31
- details: DataOperationDetailsSchema
32
- });
33
- var A2AMessageMetadataSchema = z.object({
34
- fromSubAgentId: z.string().optional().describe("ID of the sending sub-agent"),
35
- toSubAgentId: z.string().optional().describe("ID of the receiving sub-agent"),
36
- fromExternalAgentId: z.string().optional().describe("ID of the sending external agent"),
37
- toExternalAgentId: z.string().optional().describe("ID of the receiving external agent"),
38
- taskId: z.string().optional().describe("Associated task ID"),
39
- a2aTaskId: z.string().optional().describe("A2A-specific task ID")
40
- });
41
-
42
4
  // src/validation/agentFull.ts
43
5
  function isInternalAgent(agent) {
44
6
  return "prompt" in agent;
@@ -151,6 +113,43 @@ function validateAgentStructure(agentData, projectResources) {
151
113
  }
152
114
  validateAgentRelationships(agentData);
153
115
  }
116
+ var TransferDataSchema = z.object({
117
+ fromSubAgent: z.string().describe("ID of the sub-agent transferring control"),
118
+ targetSubAgent: z.string().describe("ID of the sub-agent receiving control"),
119
+ reason: z.string().optional().describe("Reason for the transfer"),
120
+ context: z.any().optional().describe("Additional context data")
121
+ });
122
+ var DelegationSentDataSchema = z.object({
123
+ delegationId: z.string().describe("Unique identifier for this delegation"),
124
+ fromSubAgent: z.string().describe("ID of the delegating sub-agent"),
125
+ targetSubAgent: z.string().describe("ID of the sub-agent receiving the delegation"),
126
+ taskDescription: z.string().describe("Description of the delegated task"),
127
+ context: z.any().optional().describe("Additional context data")
128
+ });
129
+ var DelegationReturnedDataSchema = z.object({
130
+ delegationId: z.string().describe("Unique identifier matching the original delegation"),
131
+ fromSubAgent: z.string().describe("ID of the sub-agent that completed the task"),
132
+ targetSubAgent: z.string().describe("ID of the sub-agent receiving the result"),
133
+ result: z.any().optional().describe("Result data from the delegated task")
134
+ });
135
+ var DataOperationDetailsSchema = z.object({
136
+ timestamp: z.number().describe("Unix timestamp in milliseconds"),
137
+ subAgentId: z.string().describe("ID of the sub-agent that generated this data"),
138
+ data: z.any().describe("The actual data payload")
139
+ });
140
+ var DataOperationEventSchema = z.object({
141
+ type: z.string().describe("Event type identifier"),
142
+ label: z.string().describe("Human-readable label for the event"),
143
+ details: DataOperationDetailsSchema
144
+ });
145
+ var A2AMessageMetadataSchema = z.object({
146
+ fromSubAgentId: z.string().optional().describe("ID of the sending sub-agent"),
147
+ toSubAgentId: z.string().optional().describe("ID of the receiving sub-agent"),
148
+ fromExternalAgentId: z.string().optional().describe("ID of the sending external agent"),
149
+ toExternalAgentId: z.string().optional().describe("ID of the receiving external agent"),
150
+ taskId: z.string().optional().describe("Associated task ID"),
151
+ a2aTaskId: z.string().optional().describe("A2A-specific task ID")
152
+ });
154
153
 
155
154
  // src/validation/id-validation.ts
156
155
  function isValidResourceId(id) {
@@ -170,4 +169,90 @@ function generateIdFromName(name) {
170
169
  return truncatedId;
171
170
  }
172
171
 
173
- export { A2AMessageMetadataSchema, DataOperationDetailsSchema, DataOperationEventSchema, DelegationReturnedDataSchema, DelegationSentDataSchema, TransferDataSchema, generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAgentStructure, validateAndTypeAgentData, validateArtifactComponentReferences, validateDataComponentReferences, validateToolReferences };
172
+ // src/validation/preview-validation.ts
173
+ var MAX_CODE_SIZE = 5e4;
174
+ var MAX_DATA_SIZE = 1e4;
175
+ var DANGEROUS_PATTERNS = [
176
+ /\beval\s*\(/i,
177
+ /\bFunction\s*\(/i,
178
+ /dangerouslySetInnerHTML/i,
179
+ /<script\b/i,
180
+ /\bon\w+\s*=/i,
181
+ // inline event handlers like onclick=
182
+ /document\.write/i,
183
+ /window\.location/i,
184
+ /\.innerHTML\s*=/i
185
+ ];
186
+ var ALLOWED_IMPORTS = ["lucide-react"];
187
+ function validatePreview(preview) {
188
+ const errors = [];
189
+ if (!preview.code || typeof preview.code !== "string") {
190
+ return {
191
+ isValid: false,
192
+ errors: [{ field: "preview.code", message: "Code must be a non-empty string" }]
193
+ };
194
+ }
195
+ if (!preview.data || typeof preview.data !== "object") {
196
+ return {
197
+ isValid: false,
198
+ errors: [{ field: "preview.data", message: "Data must be an object" }]
199
+ };
200
+ }
201
+ if (preview.code.length > MAX_CODE_SIZE) {
202
+ errors.push({
203
+ field: "preview.code",
204
+ message: `Code size exceeds maximum allowed (${MAX_CODE_SIZE} characters)`
205
+ });
206
+ }
207
+ const dataString = JSON.stringify(preview.data);
208
+ if (dataString.length > MAX_DATA_SIZE) {
209
+ errors.push({
210
+ field: "preview.data",
211
+ message: `Data size exceeds maximum allowed (${MAX_DATA_SIZE} characters)`
212
+ });
213
+ }
214
+ for (const pattern of DANGEROUS_PATTERNS) {
215
+ if (pattern.test(preview.code)) {
216
+ errors.push({
217
+ field: "preview.code",
218
+ message: `Code contains potentially dangerous pattern: ${pattern.source}`
219
+ });
220
+ }
221
+ }
222
+ const importMatches = preview.code.matchAll(/import\s+.*?\s+from\s+['"]([^'"]+)['"]/g);
223
+ for (const match of importMatches) {
224
+ const importPath = match[1];
225
+ if (!ALLOWED_IMPORTS.includes(importPath)) {
226
+ errors.push({
227
+ field: "preview.code",
228
+ message: `Import from "${importPath}" is not allowed. Only imports from ${ALLOWED_IMPORTS.join(", ")} are permitted`
229
+ });
230
+ }
231
+ }
232
+ const hasFunctionDeclaration = /function\s+\w+\s*\(/.test(preview.code);
233
+ if (!hasFunctionDeclaration) {
234
+ errors.push({
235
+ field: "preview.code",
236
+ message: "Code must contain a function declaration"
237
+ });
238
+ }
239
+ const hasReturn = /return\s*\(?\s*</.test(preview.code);
240
+ if (!hasReturn) {
241
+ errors.push({
242
+ field: "preview.code",
243
+ message: "Component function must have a return statement with JSX"
244
+ });
245
+ }
246
+ if (/\bexport\s+(default\s+)?/i.test(preview.code)) {
247
+ errors.push({
248
+ field: "preview.code",
249
+ message: "Code should not contain export statements"
250
+ });
251
+ }
252
+ return {
253
+ isValid: errors.length === 0,
254
+ errors
255
+ };
256
+ }
257
+
258
+ export { A2AMessageMetadataSchema, DataOperationDetailsSchema, DataOperationEventSchema, DelegationReturnedDataSchema, DelegationSentDataSchema, TransferDataSchema, generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAgentStructure, validateAndTypeAgentData, validateArtifactComponentReferences, validateDataComponentReferences, validatePreview, validateToolReferences };
@@ -243,6 +243,7 @@ var dataComponents = sqliteCore.sqliteTable(
243
243
  ...projectScoped,
244
244
  ...uiProperties,
245
245
  props: sqliteCore.blob("props", { mode: "json" }).$type(),
246
+ preview: sqliteCore.blob("preview", { mode: "json" }).$type(),
246
247
  ...timestamps
247
248
  },
248
249
  (table) => [
@@ -1,7 +1,7 @@
1
1
  export { h as ACTIVITY_NAMES, f as ACTIVITY_STATUS, e as ACTIVITY_TYPES, g as AGENT_IDS, o as AGGREGATE_OPERATORS, A as AI_OPERATIONS, i as AI_TOOL_TYPES, n as DATA_SOURCES, j as DATA_TYPES, D as DELEGATION_FROM_SUB_AGENT_ID, b as DELEGATION_ID, a as DELEGATION_TO_SUB_AGENT_ID, F as FIELD_TYPES, O as OPERATORS, l as ORDER_DIRECTIONS, P as PANEL_TYPES, p as QUERY_DEFAULTS, k as QUERY_EXPRESSIONS, Q as QUERY_FIELD_CONFIGS, m as QUERY_TYPES, R as REDUCE_OPERATIONS, d as SPAN_KEYS, S as SPAN_NAMES, T as TRANSFER_FROM_SUB_AGENT_ID, c as TRANSFER_TO_SUB_AGENT_ID, U as UNKNOWN_VALUE } from './signoz-queries-Bqpkx5sK.cjs';
2
2
  import { z } from 'zod';
3
- import { C as ConversationHistoryConfig, F as FunctionApiInsertSchema, A as ApiKeyApiUpdateSchema, a as FullAgentAgentInsertSchema } from './utility-DmLVF565.cjs';
4
- export { e as AgentStopWhen, b as AgentStopWhenSchema, h as CredentialStoreType, j as FunctionApiSelectSchema, k as FunctionApiUpdateSchema, i as MCPTransportType, g as ModelSettings, M as ModelSettingsSchema, d as StopWhen, S as StopWhenSchema, f as SubAgentStopWhen, c as SubAgentStopWhenSchema } from './utility-DmLVF565.cjs';
3
+ import { C as ConversationHistoryConfig, F as FunctionApiInsertSchema, A as ApiKeyApiUpdateSchema, a as FullAgentAgentInsertSchema } from './utility-06QUJeMa.cjs';
4
+ export { e as AgentStopWhen, b as AgentStopWhenSchema, h as CredentialStoreType, j as FunctionApiSelectSchema, k as FunctionApiUpdateSchema, i as MCPTransportType, g as ModelSettings, M as ModelSettingsSchema, d as StopWhen, S as StopWhenSchema, f as SubAgentStopWhen, c as SubAgentStopWhenSchema } from './utility-06QUJeMa.cjs';
5
5
  export { v as validatePropsAsJsonSchema } from './props-validation-BMR1qNiy.cjs';
6
6
  import 'drizzle-zod';
7
7
  import 'drizzle-orm/sqlite-core';
@@ -128,8 +128,8 @@ declare const DataComponentApiInsertSchema: z.ZodObject<{
128
128
  props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
129
129
  }, z.core.$strip>;
130
130
  declare const ArtifactComponentApiInsertSchema: z.ZodObject<{
131
- id: z.ZodString;
132
131
  name: z.ZodString;
132
+ id: z.ZodString;
133
133
  description: z.ZodString;
134
134
  props: z.ZodOptional<z.ZodNullable<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>>;
135
135
  }, {
@@ -164,12 +164,11 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
164
164
  description: z.ZodOptional<z.ZodString>;
165
165
  defaultSubAgentId: z.ZodOptional<z.ZodString>;
166
166
  subAgents: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
167
- id: z.ZodString;
168
167
  name: z.ZodString;
169
- description: z.ZodString;
170
- prompt: z.ZodString;
168
+ id: z.ZodString;
171
169
  createdAt: z.ZodOptional<z.ZodString>;
172
170
  updatedAt: z.ZodOptional<z.ZodString>;
171
+ description: z.ZodString;
173
172
  models: z.ZodOptional<z.ZodObject<{
174
173
  base: z.ZodOptional<z.ZodObject<{
175
174
  model: z.ZodOptional<z.ZodString>;
@@ -193,6 +192,7 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
193
192
  }, {
194
193
  stepCountIs?: number | undefined;
195
194
  }>>>>;
195
+ prompt: z.ZodString;
196
196
  conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
197
197
  type: z.ZodLiteral<"internal">;
198
198
  canUse: z.ZodArray<z.ZodObject<{
@@ -1,7 +1,7 @@
1
1
  export { h as ACTIVITY_NAMES, f as ACTIVITY_STATUS, e as ACTIVITY_TYPES, g as AGENT_IDS, o as AGGREGATE_OPERATORS, A as AI_OPERATIONS, i as AI_TOOL_TYPES, n as DATA_SOURCES, j as DATA_TYPES, D as DELEGATION_FROM_SUB_AGENT_ID, b as DELEGATION_ID, a as DELEGATION_TO_SUB_AGENT_ID, F as FIELD_TYPES, O as OPERATORS, l as ORDER_DIRECTIONS, P as PANEL_TYPES, p as QUERY_DEFAULTS, k as QUERY_EXPRESSIONS, Q as QUERY_FIELD_CONFIGS, m as QUERY_TYPES, R as REDUCE_OPERATIONS, d as SPAN_KEYS, S as SPAN_NAMES, T as TRANSFER_FROM_SUB_AGENT_ID, c as TRANSFER_TO_SUB_AGENT_ID, U as UNKNOWN_VALUE } from './signoz-queries-Bqpkx5sK.js';
2
2
  import { z } from 'zod';
3
- import { C as ConversationHistoryConfig, F as FunctionApiInsertSchema, A as ApiKeyApiUpdateSchema, a as FullAgentAgentInsertSchema } from './utility-DmLVF565.js';
4
- export { e as AgentStopWhen, b as AgentStopWhenSchema, h as CredentialStoreType, j as FunctionApiSelectSchema, k as FunctionApiUpdateSchema, i as MCPTransportType, g as ModelSettings, M as ModelSettingsSchema, d as StopWhen, S as StopWhenSchema, f as SubAgentStopWhen, c as SubAgentStopWhenSchema } from './utility-DmLVF565.js';
3
+ import { C as ConversationHistoryConfig, F as FunctionApiInsertSchema, A as ApiKeyApiUpdateSchema, a as FullAgentAgentInsertSchema } from './utility-06QUJeMa.js';
4
+ export { e as AgentStopWhen, b as AgentStopWhenSchema, h as CredentialStoreType, j as FunctionApiSelectSchema, k as FunctionApiUpdateSchema, i as MCPTransportType, g as ModelSettings, M as ModelSettingsSchema, d as StopWhen, S as StopWhenSchema, f as SubAgentStopWhen, c as SubAgentStopWhenSchema } from './utility-06QUJeMa.js';
5
5
  export { v as validatePropsAsJsonSchema } from './props-validation-BMR1qNiy.js';
6
6
  import 'drizzle-zod';
7
7
  import 'drizzle-orm/sqlite-core';
@@ -128,8 +128,8 @@ declare const DataComponentApiInsertSchema: z.ZodObject<{
128
128
  props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
129
129
  }, z.core.$strip>;
130
130
  declare const ArtifactComponentApiInsertSchema: z.ZodObject<{
131
- id: z.ZodString;
132
131
  name: z.ZodString;
132
+ id: z.ZodString;
133
133
  description: z.ZodString;
134
134
  props: z.ZodOptional<z.ZodNullable<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>>;
135
135
  }, {
@@ -164,12 +164,11 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
164
164
  description: z.ZodOptional<z.ZodString>;
165
165
  defaultSubAgentId: z.ZodOptional<z.ZodString>;
166
166
  subAgents: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
167
- id: z.ZodString;
168
167
  name: z.ZodString;
169
- description: z.ZodString;
170
- prompt: z.ZodString;
168
+ id: z.ZodString;
171
169
  createdAt: z.ZodOptional<z.ZodString>;
172
170
  updatedAt: z.ZodOptional<z.ZodString>;
171
+ description: z.ZodString;
173
172
  models: z.ZodOptional<z.ZodObject<{
174
173
  base: z.ZodOptional<z.ZodObject<{
175
174
  model: z.ZodOptional<z.ZodString>;
@@ -193,6 +192,7 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
193
192
  }, {
194
193
  stepCountIs?: number | undefined;
195
194
  }>>>>;
195
+ prompt: z.ZodString;
196
196
  conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
197
197
  type: z.ZodLiteral<"internal">;
198
198
  canUse: z.ZodArray<z.ZodObject<{
@@ -1,6 +1,6 @@
1
1
  export { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AGGREGATE_OPERATORS, AI_OPERATIONS, AI_TOOL_TYPES, DATA_SOURCES, DATA_TYPES, DELEGATION_FROM_SUB_AGENT_ID, DELEGATION_ID, DELEGATION_TO_SUB_AGENT_ID, FIELD_TYPES, OPERATORS, ORDER_DIRECTIONS, PANEL_TYPES, QUERY_DEFAULTS, QUERY_EXPRESSIONS, QUERY_FIELD_CONFIGS, QUERY_TYPES, REDUCE_OPERATIONS, SPAN_KEYS, SPAN_NAMES, TRANSFER_FROM_SUB_AGENT_ID, TRANSFER_TO_SUB_AGENT_ID, UNKNOWN_VALUE } from './chunk-QFIITHNT.js';
2
- import { ModelSettingsSchema, FullAgentAgentInsertSchema, ArtifactComponentApiInsertSchema } from './chunk-F3AFTJB7.js';
3
- export { AgentStopWhenSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, ModelSettingsSchema, StopWhenSchema, SubAgentStopWhenSchema, validatePropsAsJsonSchema } from './chunk-F3AFTJB7.js';
2
+ import { ModelSettingsSchema, FullAgentAgentInsertSchema, ArtifactComponentApiInsertSchema } from './chunk-4SE2FOJY.js';
3
+ export { AgentStopWhenSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, ModelSettingsSchema, StopWhenSchema, SubAgentStopWhenSchema, validatePropsAsJsonSchema } from './chunk-4SE2FOJY.js';
4
4
  import { CredentialStoreType } from './chunk-YFHT5M2R.js';
5
5
  export { CredentialStoreType, MCPTransportType } from './chunk-YFHT5M2R.js';
6
6
  import { z } from 'zod';
@@ -218,6 +218,7 @@ var dataComponents = sqliteCore.sqliteTable(
218
218
  ...projectScoped,
219
219
  ...uiProperties,
220
220
  props: sqliteCore.blob("props", { mode: "json" }).$type(),
221
+ preview: sqliteCore.blob("preview", { mode: "json" }).$type(),
221
222
  ...timestamps
222
223
  },
223
224
  (table) => [
@@ -1,7 +1,7 @@
1
1
  import 'drizzle-orm';
2
2
  import 'drizzle-orm/sqlite-core';
3
- import '../utility-DmLVF565.cjs';
4
- export { E as agentRelations, H as agentToolRelationsRelations, a as agents, w as apiKeys, G as apiKeysRelations, j as artifactComponents, M as artifactComponentsRelations, b as contextCache, C as contextCacheRelations, c as contextConfigs, B as contextConfigsRelations, r as conversations, K as conversationsRelations, x as credentialReferences, I as credentialReferencesRelations, h as dataComponents, O as dataComponentsRelations, f as externalAgents, F as externalAgentsRelations, m as functionTools, T as functionToolsRelations, n as functions, R as functionsRelations, v as ledgerArtifacts, Q as ledgerArtifactsRelations, u as messages, L as messagesRelations, p as projects, z as projectsRelations, k as subAgentArtifactComponents, N as subAgentArtifactComponentsRelations, i as subAgentDataComponents, P as subAgentDataComponentsRelations, q as subAgentFunctionToolRelations, U as subAgentFunctionToolRelationsRelations, e as subAgentRelations, S as subAgentRelationsRelations, o as subAgentToolRelations, d as subAgents, D as subAgentsRelations, g as taskRelations, A as taskRelationsRelations, t as tasks, y as tasksRelations, l as tools, J as toolsRelations } from '../schema-lnJ7dKE3.cjs';
3
+ import '../utility-06QUJeMa.cjs';
4
+ export { E as agentRelations, H as agentToolRelationsRelations, a as agents, w as apiKeys, G as apiKeysRelations, j as artifactComponents, M as artifactComponentsRelations, b as contextCache, C as contextCacheRelations, c as contextConfigs, B as contextConfigsRelations, r as conversations, K as conversationsRelations, x as credentialReferences, I as credentialReferencesRelations, h as dataComponents, O as dataComponentsRelations, f as externalAgents, F as externalAgentsRelations, m as functionTools, T as functionToolsRelations, n as functions, R as functionsRelations, v as ledgerArtifacts, Q as ledgerArtifactsRelations, u as messages, L as messagesRelations, p as projects, z as projectsRelations, k as subAgentArtifactComponents, N as subAgentArtifactComponentsRelations, i as subAgentDataComponents, P as subAgentDataComponentsRelations, q as subAgentFunctionToolRelations, U as subAgentFunctionToolRelationsRelations, e as subAgentRelations, S as subAgentRelationsRelations, o as subAgentToolRelations, d as subAgents, D as subAgentsRelations, g as taskRelations, A as taskRelationsRelations, t as tasks, y as tasksRelations, l as tools, J as toolsRelations } from '../schema-B8-O-pmG.cjs';
5
5
  import 'zod';
6
6
  import 'drizzle-zod';
7
7
  import '@hono/zod-openapi';
@@ -1,7 +1,7 @@
1
1
  import 'drizzle-orm';
2
2
  import 'drizzle-orm/sqlite-core';
3
- import '../utility-DmLVF565.js';
4
- export { E as agentRelations, H as agentToolRelationsRelations, a as agents, w as apiKeys, G as apiKeysRelations, j as artifactComponents, M as artifactComponentsRelations, b as contextCache, C as contextCacheRelations, c as contextConfigs, B as contextConfigsRelations, r as conversations, K as conversationsRelations, x as credentialReferences, I as credentialReferencesRelations, h as dataComponents, O as dataComponentsRelations, f as externalAgents, F as externalAgentsRelations, m as functionTools, T as functionToolsRelations, n as functions, R as functionsRelations, v as ledgerArtifacts, Q as ledgerArtifactsRelations, u as messages, L as messagesRelations, p as projects, z as projectsRelations, k as subAgentArtifactComponents, N as subAgentArtifactComponentsRelations, i as subAgentDataComponents, P as subAgentDataComponentsRelations, q as subAgentFunctionToolRelations, U as subAgentFunctionToolRelationsRelations, e as subAgentRelations, S as subAgentRelationsRelations, o as subAgentToolRelations, d as subAgents, D as subAgentsRelations, g as taskRelations, A as taskRelationsRelations, t as tasks, y as tasksRelations, l as tools, J as toolsRelations } from '../schema-9o975__r.js';
3
+ import '../utility-06QUJeMa.js';
4
+ export { E as agentRelations, H as agentToolRelationsRelations, a as agents, w as apiKeys, G as apiKeysRelations, j as artifactComponents, M as artifactComponentsRelations, b as contextCache, C as contextCacheRelations, c as contextConfigs, B as contextConfigsRelations, r as conversations, K as conversationsRelations, x as credentialReferences, I as credentialReferencesRelations, h as dataComponents, O as dataComponentsRelations, f as externalAgents, F as externalAgentsRelations, m as functionTools, T as functionToolsRelations, n as functions, R as functionsRelations, v as ledgerArtifacts, Q as ledgerArtifactsRelations, u as messages, L as messagesRelations, p as projects, z as projectsRelations, k as subAgentArtifactComponents, N as subAgentArtifactComponentsRelations, i as subAgentDataComponents, P as subAgentDataComponentsRelations, q as subAgentFunctionToolRelations, U as subAgentFunctionToolRelationsRelations, e as subAgentRelations, S as subAgentRelationsRelations, o as subAgentToolRelations, d as subAgents, D as subAgentsRelations, g as taskRelations, A as taskRelationsRelations, t as tasks, y as tasksRelations, l as tools, J as toolsRelations } from '../schema-BPRMaYtZ.js';
5
5
  import 'zod';
6
6
  import 'drizzle-zod';
7
7
  import '@hono/zod-openapi';
package/dist/db/schema.js CHANGED
@@ -1 +1 @@
1
- export { agentRelations, agentToolRelationsRelations, agents, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, functionTools, functionToolsRelations, functions, functionsRelations, ledgerArtifacts, ledgerArtifactsRelations, messages, messagesRelations, projects, projectsRelations, subAgentArtifactComponents, subAgentArtifactComponentsRelations, subAgentDataComponents, subAgentDataComponentsRelations, subAgentFunctionToolRelations, subAgentFunctionToolRelationsRelations, subAgentRelations, subAgentRelationsRelations, subAgentToolRelations, subAgents, subAgentsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations } from '../chunk-PR3DDXVU.js';
1
+ export { agentRelations, agentToolRelationsRelations, agents, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, functionTools, functionToolsRelations, functions, functionsRelations, ledgerArtifacts, ledgerArtifactsRelations, messages, messagesRelations, projects, projectsRelations, subAgentArtifactComponents, subAgentArtifactComponentsRelations, subAgentDataComponents, subAgentDataComponentsRelations, subAgentFunctionToolRelations, subAgentFunctionToolRelationsRelations, subAgentRelations, subAgentRelationsRelations, subAgentToolRelations, subAgents, subAgentsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations } from '../chunk-5B6IOJZY.js';
package/dist/index.cjs CHANGED
@@ -213694,6 +213694,7 @@ var dataComponents = sqliteCore.sqliteTable(
213694
213694
  ...projectScoped,
213695
213695
  ...uiProperties,
213696
213696
  props: sqliteCore.blob("props", { mode: "json" }).$type(),
213697
+ preview: sqliteCore.blob("preview", { mode: "json" }).$type(),
213697
213698
  ...timestamps
213698
213699
  },
213699
213700
  (table) => [
@@ -219649,6 +219650,94 @@ var setActiveAgentForThread = (db) => async ({
219649
219650
  subAgentId
219650
219651
  });
219651
219652
  };
219653
+
219654
+ // src/validation/preview-validation.ts
219655
+ var MAX_CODE_SIZE = 5e4;
219656
+ var MAX_DATA_SIZE = 1e4;
219657
+ var DANGEROUS_PATTERNS = [
219658
+ /\beval\s*\(/i,
219659
+ /\bFunction\s*\(/i,
219660
+ /dangerouslySetInnerHTML/i,
219661
+ /<script\b/i,
219662
+ /\bon\w+\s*=/i,
219663
+ // inline event handlers like onclick=
219664
+ /document\.write/i,
219665
+ /window\.location/i,
219666
+ /\.innerHTML\s*=/i
219667
+ ];
219668
+ var ALLOWED_IMPORTS = ["lucide-react"];
219669
+ function validatePreview(preview2) {
219670
+ const errors = [];
219671
+ if (!preview2.code || typeof preview2.code !== "string") {
219672
+ return {
219673
+ isValid: false,
219674
+ errors: [{ field: "preview.code", message: "Code must be a non-empty string" }]
219675
+ };
219676
+ }
219677
+ if (!preview2.data || typeof preview2.data !== "object") {
219678
+ return {
219679
+ isValid: false,
219680
+ errors: [{ field: "preview.data", message: "Data must be an object" }]
219681
+ };
219682
+ }
219683
+ if (preview2.code.length > MAX_CODE_SIZE) {
219684
+ errors.push({
219685
+ field: "preview.code",
219686
+ message: `Code size exceeds maximum allowed (${MAX_CODE_SIZE} characters)`
219687
+ });
219688
+ }
219689
+ const dataString = JSON.stringify(preview2.data);
219690
+ if (dataString.length > MAX_DATA_SIZE) {
219691
+ errors.push({
219692
+ field: "preview.data",
219693
+ message: `Data size exceeds maximum allowed (${MAX_DATA_SIZE} characters)`
219694
+ });
219695
+ }
219696
+ for (const pattern of DANGEROUS_PATTERNS) {
219697
+ if (pattern.test(preview2.code)) {
219698
+ errors.push({
219699
+ field: "preview.code",
219700
+ message: `Code contains potentially dangerous pattern: ${pattern.source}`
219701
+ });
219702
+ }
219703
+ }
219704
+ const importMatches = preview2.code.matchAll(/import\s+.*?\s+from\s+['"]([^'"]+)['"]/g);
219705
+ for (const match2 of importMatches) {
219706
+ const importPath = match2[1];
219707
+ if (!ALLOWED_IMPORTS.includes(importPath)) {
219708
+ errors.push({
219709
+ field: "preview.code",
219710
+ message: `Import from "${importPath}" is not allowed. Only imports from ${ALLOWED_IMPORTS.join(", ")} are permitted`
219711
+ });
219712
+ }
219713
+ }
219714
+ const hasFunctionDeclaration = /function\s+\w+\s*\(/.test(preview2.code);
219715
+ if (!hasFunctionDeclaration) {
219716
+ errors.push({
219717
+ field: "preview.code",
219718
+ message: "Code must contain a function declaration"
219719
+ });
219720
+ }
219721
+ const hasReturn = /return\s*\(?\s*</.test(preview2.code);
219722
+ if (!hasReturn) {
219723
+ errors.push({
219724
+ field: "preview.code",
219725
+ message: "Component function must have a return statement with JSX"
219726
+ });
219727
+ }
219728
+ if (/\bexport\s+(default\s+)?/i.test(preview2.code)) {
219729
+ errors.push({
219730
+ field: "preview.code",
219731
+ message: "Code should not contain export statements"
219732
+ });
219733
+ }
219734
+ return {
219735
+ isValid: errors.length === 0,
219736
+ errors
219737
+ };
219738
+ }
219739
+
219740
+ // src/data-access/dataComponents.ts
219652
219741
  var getDataComponent = (db) => async (params) => {
219653
219742
  const result = await db.query.dataComponents.findFirst({
219654
219743
  where: drizzleOrm.and(
@@ -219700,6 +219789,13 @@ var createDataComponent = (db) => async (params) => {
219700
219789
  throw new Error(`Invalid props schema: ${errorMessages}`);
219701
219790
  }
219702
219791
  }
219792
+ if (params.preview !== void 0 && params.preview !== null) {
219793
+ const previewValidation = validatePreview(params.preview);
219794
+ if (!previewValidation.isValid) {
219795
+ const errorMessages = previewValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ");
219796
+ throw new Error(`Invalid preview: ${errorMessages}`);
219797
+ }
219798
+ }
219703
219799
  const dataComponent = await db.insert(dataComponents).values(params).returning();
219704
219800
  return dataComponent[0];
219705
219801
  };
@@ -219711,6 +219807,13 @@ var updateDataComponent = (db) => async (params) => {
219711
219807
  throw new Error(`Invalid props schema: ${errorMessages}`);
219712
219808
  }
219713
219809
  }
219810
+ if (params.data.preview !== void 0 && params.data.preview !== null) {
219811
+ const previewValidation = validatePreview(params.data.preview);
219812
+ if (!previewValidation.isValid) {
219813
+ const errorMessages = previewValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ");
219814
+ throw new Error(`Invalid preview: ${errorMessages}`);
219815
+ }
219816
+ }
219714
219817
  const now = (/* @__PURE__ */ new Date()).toISOString();
219715
219818
  await db.update(dataComponents).set({
219716
219819
  ...params.data,
@@ -219746,7 +219849,8 @@ var getDataComponentsForAgent = (db) => async (params) => {
219746
219849
  description: dataComponents.description,
219747
219850
  props: dataComponents.props,
219748
219851
  createdAt: dataComponents.createdAt,
219749
- updatedAt: dataComponents.updatedAt
219852
+ updatedAt: dataComponents.updatedAt,
219853
+ preview: dataComponents.preview
219750
219854
  }).from(dataComponents).innerJoin(
219751
219855
  subAgentDataComponents,
219752
219856
  drizzleOrm.eq(dataComponents.id, subAgentDataComponents.dataComponentId)
@@ -225683,6 +225787,7 @@ exports.validateExternalAgent = validateExternalAgent;
225683
225787
  exports.validateHeaders = validateHeaders;
225684
225788
  exports.validateHttpRequestHeaders = validateHttpRequestHeaders;
225685
225789
  exports.validateInternalSubAgent = validateInternalSubAgent;
225790
+ exports.validatePreview = validatePreview;
225686
225791
  exports.validateProjectExists = validateProjectExists;
225687
225792
  exports.validatePropsAsJsonSchema = validatePropsAsJsonSchema;
225688
225793
  exports.validateToolReferences = validateToolReferences;