@inkeep/agents-core 0.23.5 → 0.24.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.
@@ -1,4 +1,4 @@
1
- import { AgentWithinContextOfProjectSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-HN77JIDP.js';
1
+ import { AgentWithinContextOfProjectSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-A7UJQKCD.js';
2
2
  import { z } from 'zod';
3
3
 
4
4
  // src/validation/agentFull.ts
@@ -173,15 +173,38 @@ function generateIdFromName(name) {
173
173
  var MAX_CODE_SIZE = 5e4;
174
174
  var MAX_DATA_SIZE = 1e4;
175
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
176
+ {
177
+ pattern: /\beval\s*\(/i,
178
+ message: "eval() is not allowed"
179
+ },
180
+ {
181
+ pattern: /\bFunction\s*\(/i,
182
+ message: "Function constructor is not allowed"
183
+ },
184
+ {
185
+ pattern: /dangerouslySetInnerHTML/i,
186
+ message: "dangerouslySetInnerHTML is not allowed"
187
+ },
188
+ {
189
+ pattern: /<script\b/i,
190
+ message: "Script tags are not allowed"
191
+ },
192
+ {
193
+ pattern: /\bon\w+\s*=/i,
194
+ message: "Inline event handlers (onClick=, onLoad=, etc.) are not allowed"
195
+ },
196
+ {
197
+ pattern: /document\.write/i,
198
+ message: "document.write is not allowed"
199
+ },
200
+ {
201
+ pattern: /window\.location/i,
202
+ message: "window.location is not allowed"
203
+ },
204
+ {
205
+ pattern: /\.innerHTML\s*=/i,
206
+ message: "innerHTML manipulation is not allowed"
207
+ }
185
208
  ];
186
209
  var ALLOWED_IMPORTS = ["lucide-react"];
187
210
  function validatePreview(preview) {
@@ -211,11 +234,11 @@ function validatePreview(preview) {
211
234
  message: `Data size exceeds maximum allowed (${MAX_DATA_SIZE} characters)`
212
235
  });
213
236
  }
214
- for (const pattern of DANGEROUS_PATTERNS) {
237
+ for (const { pattern, message } of DANGEROUS_PATTERNS) {
215
238
  if (pattern.test(preview.code)) {
216
239
  errors.push({
217
240
  field: "preview.code",
218
- message: `Code contains potentially dangerous pattern: ${pattern.source}`
241
+ message: `Code contains potentially dangerous pattern: ${message}`
219
242
  });
220
243
  }
221
244
  }
@@ -1,7 +1,7 @@
1
1
  export { i as ACTIVITY_NAMES, g as ACTIVITY_STATUS, f as ACTIVITY_TYPES, h as AGENT_IDS, p as AGGREGATE_OPERATORS, A as AI_OPERATIONS, j as AI_TOOL_TYPES, o as DATA_SOURCES, k 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, m as ORDER_DIRECTIONS, P as PANEL_TYPES, q as QUERY_DEFAULTS, l as QUERY_EXPRESSIONS, Q as QUERY_FIELD_CONFIGS, n as QUERY_TYPES, R as REDUCE_OPERATIONS, e 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, d as detectAuthenticationRequired } from './auth-detection-BO8bSpe4.cjs';
2
2
  import { z } from 'zod';
3
- import { C as ConversationHistoryConfig, F as FunctionApiInsertSchema, A as ApiKeyApiUpdateSchema, a as FullAgentAgentInsertSchema } from './utility-DVhMoRLZ.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-DVhMoRLZ.cjs';
3
+ import { C as ConversationHistoryConfig, F as FunctionApiInsertSchema, A as ApiKeyApiUpdateSchema, a as FullAgentAgentInsertSchema } from './utility-mGrlR4Ta.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-mGrlR4Ta.cjs';
5
5
  export { v as validatePropsAsJsonSchema } from './props-validation-BMR1qNiy.cjs';
6
6
  import 'pino';
7
7
  import 'drizzle-zod';
@@ -129,8 +129,8 @@ declare const DataComponentApiInsertSchema: z.ZodObject<{
129
129
  props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
130
130
  }, z.core.$strip>;
131
131
  declare const ArtifactComponentApiInsertSchema: z.ZodObject<{
132
- name: z.ZodString;
133
132
  id: z.ZodString;
133
+ name: z.ZodString;
134
134
  description: z.ZodString;
135
135
  props: z.ZodOptional<z.ZodNullable<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>>;
136
136
  }, {
@@ -165,11 +165,12 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
165
165
  description: z.ZodOptional<z.ZodString>;
166
166
  defaultSubAgentId: z.ZodOptional<z.ZodString>;
167
167
  subAgents: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
168
- name: z.ZodString;
169
168
  id: z.ZodString;
169
+ name: z.ZodString;
170
+ description: z.ZodString;
171
+ prompt: z.ZodString;
170
172
  createdAt: z.ZodOptional<z.ZodString>;
171
173
  updatedAt: z.ZodOptional<z.ZodString>;
172
- description: z.ZodString;
173
174
  models: z.ZodOptional<z.ZodObject<{
174
175
  base: z.ZodOptional<z.ZodObject<{
175
176
  model: z.ZodOptional<z.ZodString>;
@@ -193,7 +194,6 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
193
194
  }, {
194
195
  stepCountIs?: number | undefined;
195
196
  }>>>>;
196
- prompt: z.ZodString;
197
197
  conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
198
198
  type: z.ZodLiteral<"internal">;
199
199
  canUse: z.ZodArray<z.ZodObject<{
@@ -1,7 +1,7 @@
1
1
  export { i as ACTIVITY_NAMES, g as ACTIVITY_STATUS, f as ACTIVITY_TYPES, h as AGENT_IDS, p as AGGREGATE_OPERATORS, A as AI_OPERATIONS, j as AI_TOOL_TYPES, o as DATA_SOURCES, k 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, m as ORDER_DIRECTIONS, P as PANEL_TYPES, q as QUERY_DEFAULTS, l as QUERY_EXPRESSIONS, Q as QUERY_FIELD_CONFIGS, n as QUERY_TYPES, R as REDUCE_OPERATIONS, e 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, d as detectAuthenticationRequired } from './auth-detection-BO8bSpe4.js';
2
2
  import { z } from 'zod';
3
- import { C as ConversationHistoryConfig, F as FunctionApiInsertSchema, A as ApiKeyApiUpdateSchema, a as FullAgentAgentInsertSchema } from './utility-DVhMoRLZ.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-DVhMoRLZ.js';
3
+ import { C as ConversationHistoryConfig, F as FunctionApiInsertSchema, A as ApiKeyApiUpdateSchema, a as FullAgentAgentInsertSchema } from './utility-mGrlR4Ta.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-mGrlR4Ta.js';
5
5
  export { v as validatePropsAsJsonSchema } from './props-validation-BMR1qNiy.js';
6
6
  import 'pino';
7
7
  import 'drizzle-zod';
@@ -129,8 +129,8 @@ declare const DataComponentApiInsertSchema: z.ZodObject<{
129
129
  props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
130
130
  }, z.core.$strip>;
131
131
  declare const ArtifactComponentApiInsertSchema: z.ZodObject<{
132
- name: z.ZodString;
133
132
  id: z.ZodString;
133
+ name: z.ZodString;
134
134
  description: z.ZodString;
135
135
  props: z.ZodOptional<z.ZodNullable<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>>;
136
136
  }, {
@@ -165,11 +165,12 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
165
165
  description: z.ZodOptional<z.ZodString>;
166
166
  defaultSubAgentId: z.ZodOptional<z.ZodString>;
167
167
  subAgents: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
168
- name: z.ZodString;
169
168
  id: z.ZodString;
169
+ name: z.ZodString;
170
+ description: z.ZodString;
171
+ prompt: z.ZodString;
170
172
  createdAt: z.ZodOptional<z.ZodString>;
171
173
  updatedAt: z.ZodOptional<z.ZodString>;
172
- description: z.ZodString;
173
174
  models: z.ZodOptional<z.ZodObject<{
174
175
  base: z.ZodOptional<z.ZodObject<{
175
176
  model: z.ZodOptional<z.ZodString>;
@@ -193,7 +194,6 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
193
194
  }, {
194
195
  stepCountIs?: number | undefined;
195
196
  }>>>>;
196
- prompt: z.ZodString;
197
197
  conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
198
198
  type: z.ZodLiteral<"internal">;
199
199
  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, detectAuthenticationRequired } from './chunk-NJZ3ICNP.js';
2
- import { ModelSettingsSchema, FullAgentAgentInsertSchema, ArtifactComponentApiInsertSchema } from './chunk-HN77JIDP.js';
3
- export { AgentStopWhenSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, ModelSettingsSchema, StopWhenSchema, SubAgentStopWhenSchema, validatePropsAsJsonSchema } from './chunk-HN77JIDP.js';
2
+ import { ModelSettingsSchema, FullAgentAgentInsertSchema, ArtifactComponentApiInsertSchema } from './chunk-A7UJQKCD.js';
3
+ export { AgentStopWhenSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, ModelSettingsSchema, StopWhenSchema, SubAgentStopWhenSchema, validatePropsAsJsonSchema } from './chunk-A7UJQKCD.js';
4
4
  import { CredentialStoreType } from './chunk-YFHT5M2R.js';
5
5
  export { CredentialStoreType, MCPTransportType } from './chunk-YFHT5M2R.js';
6
6
  import { z } from 'zod';
@@ -1,7 +1,7 @@
1
1
  import 'drizzle-orm';
2
2
  import 'drizzle-orm/sqlite-core';
3
- import '../utility-DVhMoRLZ.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-DygzZEj3.cjs';
3
+ import '../utility-mGrlR4Ta.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-B8NMPwEM.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-DVhMoRLZ.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-CxJkXzMM.js';
3
+ import '../utility-mGrlR4Ta.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-PgBNwsV-.js';
5
5
  import 'zod';
6
6
  import 'drizzle-zod';
7
7
  import '@hono/zod-openapi';
package/dist/index.cjs CHANGED
@@ -215842,7 +215842,7 @@ var listContextConfigsPaginated = (db) => async (params) => {
215842
215842
  };
215843
215843
  };
215844
215844
  var createContextConfig = (db) => async (params) => {
215845
- const id = params.id || nanoid.nanoid();
215845
+ const id = params.id || generateId();
215846
215846
  const now = (/* @__PURE__ */ new Date()).toISOString();
215847
215847
  let contextVariables = params.contextVariables;
215848
215848
  if (contextVariables !== void 0 && contextVariables !== null && typeof contextVariables === "object" && Object.keys(contextVariables).length === 0) {
@@ -216402,7 +216402,7 @@ var addFunctionToolToSubAgent = (db) => {
216402
216402
  const { scopes, subAgentId, functionToolId } = params;
216403
216403
  const { tenantId, projectId, agentId } = scopes;
216404
216404
  try {
216405
- const relationId = nanoid.nanoid();
216405
+ const relationId = generateId();
216406
216406
  await db.insert(subAgentFunctionToolRelations).values({
216407
216407
  id: relationId,
216408
216408
  tenantId,
@@ -216705,7 +216705,7 @@ var deleteAgentRelationsByAgent = (db) => async (params) => {
216705
216705
  return (result.rowsAffected || 0) > 0;
216706
216706
  };
216707
216707
  var createAgentToolRelation = (db) => async (params) => {
216708
- const finalRelationId = params.relationId ?? nanoid.nanoid();
216708
+ const finalRelationId = params.relationId ?? generateId();
216709
216709
  const relation = await db.insert(subAgentToolRelations).values({
216710
216710
  id: finalRelationId,
216711
216711
  tenantId: params.scopes.tenantId,
@@ -217126,7 +217126,7 @@ async function generateApiKey() {
217126
217126
  const key = `sk_${publicId}.${secret}`;
217127
217127
  const keyPrefix = key.substring(0, 12);
217128
217128
  const keyHash = await hashApiKey(key);
217129
- const id = nanoid.nanoid();
217129
+ const id = generateId();
217130
217130
  return {
217131
217131
  id,
217132
217132
  publicId,
@@ -218259,7 +218259,7 @@ var deleteTool = (db) => async (params) => {
218259
218259
  return !!deleted;
218260
218260
  };
218261
218261
  var addToolToAgent = (db) => async (params) => {
218262
- const id = nanoid.nanoid();
218262
+ const id = generateId();
218263
218263
  const now = (/* @__PURE__ */ new Date()).toISOString();
218264
218264
  const [created] = await db.insert(subAgentToolRelations).values({
218265
218265
  id,
@@ -218838,7 +218838,7 @@ var getFullAgentDefinition = (db) => async ({
218838
218838
  return result;
218839
218839
  };
218840
218840
  var upsertAgent = (db) => async (params) => {
218841
- const agentId = params.data.id || nanoid.nanoid();
218841
+ const agentId = params.data.id || generateId();
218842
218842
  const scopes = { tenantId: params.data.tenantId, projectId: params.data.projectId, agentId };
218843
218843
  const existing = await getAgentById(db)({
218844
218844
  scopes
@@ -219242,7 +219242,7 @@ var getArtifactComponentsForAgent = (db) => async (params) => {
219242
219242
  };
219243
219243
  var associateArtifactComponentWithAgent = (db) => async (params) => {
219244
219244
  const [association] = await db.insert(subAgentArtifactComponents).values({
219245
- id: nanoid.nanoid(),
219245
+ id: generateId(),
219246
219246
  tenantId: params.scopes.tenantId,
219247
219247
  projectId: params.scopes.projectId,
219248
219248
  agentId: params.scopes.agentId,
@@ -219405,7 +219405,7 @@ var getCacheEntry = (db) => async (params) => {
219405
219405
  var setCacheEntry = (db) => async (entry) => {
219406
219406
  try {
219407
219407
  const cacheData = {
219408
- id: nanoid.nanoid(),
219408
+ id: generateId(),
219409
219409
  tenantId: entry.tenantId,
219410
219410
  projectId: entry.projectId,
219411
219411
  conversationId: entry.conversationId,
@@ -219729,15 +219729,38 @@ var setActiveAgentForThread = (db) => async ({
219729
219729
  var MAX_CODE_SIZE = 5e4;
219730
219730
  var MAX_DATA_SIZE = 1e4;
219731
219731
  var DANGEROUS_PATTERNS = [
219732
- /\beval\s*\(/i,
219733
- /\bFunction\s*\(/i,
219734
- /dangerouslySetInnerHTML/i,
219735
- /<script\b/i,
219736
- /\bon\w+\s*=/i,
219737
- // inline event handlers like onclick=
219738
- /document\.write/i,
219739
- /window\.location/i,
219740
- /\.innerHTML\s*=/i
219732
+ {
219733
+ pattern: /\beval\s*\(/i,
219734
+ message: "eval() is not allowed"
219735
+ },
219736
+ {
219737
+ pattern: /\bFunction\s*\(/i,
219738
+ message: "Function constructor is not allowed"
219739
+ },
219740
+ {
219741
+ pattern: /dangerouslySetInnerHTML/i,
219742
+ message: "dangerouslySetInnerHTML is not allowed"
219743
+ },
219744
+ {
219745
+ pattern: /<script\b/i,
219746
+ message: "Script tags are not allowed"
219747
+ },
219748
+ {
219749
+ pattern: /\bon\w+\s*=/i,
219750
+ message: "Inline event handlers (onClick=, onLoad=, etc.) are not allowed"
219751
+ },
219752
+ {
219753
+ pattern: /document\.write/i,
219754
+ message: "document.write is not allowed"
219755
+ },
219756
+ {
219757
+ pattern: /window\.location/i,
219758
+ message: "window.location is not allowed"
219759
+ },
219760
+ {
219761
+ pattern: /\.innerHTML\s*=/i,
219762
+ message: "innerHTML manipulation is not allowed"
219763
+ }
219741
219764
  ];
219742
219765
  var ALLOWED_IMPORTS = ["lucide-react"];
219743
219766
  function validatePreview(preview2) {
@@ -219767,11 +219790,11 @@ function validatePreview(preview2) {
219767
219790
  message: `Data size exceeds maximum allowed (${MAX_DATA_SIZE} characters)`
219768
219791
  });
219769
219792
  }
219770
- for (const pattern of DANGEROUS_PATTERNS) {
219793
+ for (const { pattern, message } of DANGEROUS_PATTERNS) {
219771
219794
  if (pattern.test(preview2.code)) {
219772
219795
  errors.push({
219773
219796
  field: "preview.code",
219774
- message: `Code contains potentially dangerous pattern: ${pattern.source}`
219797
+ message: `Code contains potentially dangerous pattern: ${message}`
219775
219798
  });
219776
219799
  }
219777
219800
  }
@@ -219939,7 +219962,7 @@ var getDataComponentsForAgent = (db) => async (params) => {
219939
219962
  };
219940
219963
  var associateDataComponentWithAgent = (db) => async (params) => {
219941
219964
  const association = await db.insert(subAgentDataComponents).values({
219942
- id: nanoid.nanoid(),
219965
+ id: generateId(),
219943
219966
  tenantId: params.scopes.tenantId,
219944
219967
  projectId: params.scopes.projectId,
219945
219968
  agentId: params.scopes.agentId,
@@ -220243,7 +220266,7 @@ var createFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
220243
220266
  logger14.info({}, "MCP Tools are project-scoped - skipping tool creation in agent");
220244
220267
  let finalAgentId;
220245
220268
  try {
220246
- const agentId = typed.id || nanoid.nanoid();
220269
+ const agentId = typed.id || generateId();
220247
220270
  logger14.info({ agentId }, "Creating agent metadata");
220248
220271
  const agent = await upsertAgent(db)({
220249
220272
  data: {
@@ -220629,7 +220652,7 @@ var createFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
220629
220652
  "Processing agent transfer relation"
220630
220653
  );
220631
220654
  await upsertSubAgentRelation(db)({
220632
- id: nanoid.nanoid(),
220655
+ id: generateId(),
220633
220656
  tenantId,
220634
220657
  projectId,
220635
220658
  agentId: finalAgentId,
@@ -220663,7 +220686,7 @@ var createFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
220663
220686
  "Processing agent delegation relation"
220664
220687
  );
220665
220688
  await upsertSubAgentRelation(db)({
220666
- id: nanoid.nanoid(),
220689
+ id: generateId(),
220667
220690
  tenantId,
220668
220691
  projectId,
220669
220692
  agentId: finalAgentId,
@@ -220746,7 +220769,7 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
220746
220769
  logger14.info({}, "MCP Tools are project-scoped - skipping tool creation in agent update");
220747
220770
  let finalAgentId;
220748
220771
  try {
220749
- const agentId = typedAgentDefinition.id || nanoid.nanoid();
220772
+ const agentId = typedAgentDefinition.id || generateId();
220750
220773
  logger14.info({ agentId }, "Getting/creating agent metadata");
220751
220774
  const agent = await upsertAgent(db)({
220752
220775
  data: {
@@ -221269,7 +221292,7 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
221269
221292
  const isTargetExternal = isExternalAgent(targetAgentData);
221270
221293
  const targetField = isTargetExternal ? "externalSubAgentId" : "targetSubAgentId";
221271
221294
  const relationData = {
221272
- id: nanoid.nanoid(),
221295
+ id: generateId(),
221273
221296
  agentId: typedAgentDefinition.id || "",
221274
221297
  sourceSubAgentId: subAgentId,
221275
221298
  relationType: "transfer",
@@ -221303,7 +221326,7 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
221303
221326
  (async () => {
221304
221327
  try {
221305
221328
  const relationData = {
221306
- id: nanoid.nanoid(),
221329
+ id: generateId(),
221307
221330
  agentId: typedAgentDefinition.id || "",
221308
221331
  sourceSubAgentId: subAgentId,
221309
221332
  relationType: "delegate",
@@ -221518,7 +221541,7 @@ var upsertLedgerArtifact = (db) => async (params) => {
221518
221541
  const sanitizedArt = sanitizeArtifactForDatabase(artifact);
221519
221542
  const now = (/* @__PURE__ */ new Date()).toISOString();
221520
221543
  const artifactRow = {
221521
- id: sanitizedArt.artifactId ?? nanoid.nanoid(),
221544
+ id: sanitizedArt.artifactId ?? generateId(),
221522
221545
  tenantId: scopes.tenantId,
221523
221546
  projectId: scopes.projectId,
221524
221547
  taskId,
@@ -221568,7 +221591,7 @@ var addLedgerArtifacts = (db) => async (params) => {
221568
221591
  const sanitizedArt = sanitizeArtifactForDatabase(art);
221569
221592
  const resolvedTaskId = taskId ?? sanitizedArt.taskId ?? sanitizedArt.metadata?.taskId ?? null;
221570
221593
  return {
221571
- id: sanitizedArt.artifactId ?? nanoid.nanoid(),
221594
+ id: sanitizedArt.artifactId ?? generateId(),
221572
221595
  tenantId: scopes.tenantId,
221573
221596
  projectId: scopes.projectId,
221574
221597
  taskId: resolvedTaskId,
@@ -222958,6 +222981,8 @@ var createValidatedDataAccess = (db, dataAccessFunctions) => {
222958
222981
 
222959
222982
  // src/utils/tracer.ts
222960
222983
  var tracer = getTracer("agents-core");
222984
+
222985
+ // src/context/contextCache.ts
222961
222986
  var logger8 = getLogger("context-cache");
222962
222987
  var ContextCache = class {
222963
222988
  constructor(tenantId, projectId, dbClient) {
@@ -223020,7 +223045,7 @@ var ContextCache = class {
223020
223045
  async set(entry) {
223021
223046
  try {
223022
223047
  const cacheData = {
223023
- id: nanoid.nanoid(),
223048
+ id: generateId(),
223024
223049
  tenantId: this.tenantId,
223025
223050
  projectId: this.projectId,
223026
223051
  conversationId: entry.conversationId,