@inkeep/agents-core 0.0.0-dev-20260130091014 → 0.0.0-dev-20260130091101

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.
@@ -6,6 +6,7 @@ import { apiKeys, contextCache, conversations, datasetRun, datasetRunConversatio
6
6
  import { ResolvedRefSchema } from "./dolt-schemas.js";
7
7
  import { createInsertSchema, createSelectSchema, registerFieldSchemas } from "./drizzle-schema-helpers.js";
8
8
  import { z } from "@hono/zod-openapi";
9
+ import { parse } from "@babel/parser";
9
10
 
10
11
  //#region src/validation/schemas.ts
11
12
  const { AGENT_EXECUTION_TRANSFER_COUNT_MAX, AGENT_EXECUTION_TRANSFER_COUNT_MIN, CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT, STATUS_UPDATE_MAX_INTERVAL_SECONDS, STATUS_UPDATE_MAX_NUM_EVENTS, SUB_AGENT_TURN_GENERATION_STEPS_MAX, SUB_AGENT_TURN_GENERATION_STEPS_MIN, VALIDATION_AGENT_PROMPT_MAX_CHARS, VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS } = schemaValidationDefaults;
@@ -881,7 +882,35 @@ const FunctionSelectSchema = createSelectSchema(functions);
881
882
  const FunctionInsertSchema = createInsertSchema(functions).extend({ id: ResourceIdSchema });
882
883
  const FunctionUpdateSchema = FunctionInsertSchema.partial();
883
884
  const FunctionApiSelectSchema = createApiSchema(FunctionSelectSchema).openapi("Function");
884
- const FunctionApiInsertSchema = createApiInsertSchema(FunctionInsertSchema).openapi("FunctionCreate");
885
+ const validateExecuteCode = (val, ctx) => {
886
+ try {
887
+ const isAnonymousFunction = /^(async\s+)?function(\s+)?\(/.test(val);
888
+ if (isAnonymousFunction) val = `(${val})`;
889
+ const { body } = parse(val, { sourceType: "module" }).program;
890
+ for (const node of body) {
891
+ if (node.type === "ExportDefaultDeclaration") throw SyntaxError("Export default declarations are not supported. Provide a single function instead.");
892
+ if (node.type === "ExportNamedDeclaration") throw SyntaxError("Export declarations are not supported. Provide a single function instead.");
893
+ }
894
+ const functionsCount = body.filter((node) => {
895
+ if (node.type === "FunctionDeclaration") return true;
896
+ if (node.type === "ExpressionStatement") return node.expression.type === (isAnonymousFunction ? "FunctionExpression" : "ArrowFunctionExpression");
897
+ return false;
898
+ }).length;
899
+ if (!functionsCount) throw new SyntaxError("Must contain exactly one function.");
900
+ if (functionsCount > 1) throw new SyntaxError(`Must contain exactly one function (found ${functionsCount}).`);
901
+ } catch (error) {
902
+ let message = error instanceof Error ? error.message : JSON.stringify(error);
903
+ if (message.startsWith("'return' outside of function. (")) message = "Top-level return is not allowed.";
904
+ else if (message.startsWith("Unexpected token, expected \"")) message = "TypeScript syntax is not supported. Use plain JavaScript.";
905
+ else if (message.startsWith("This experimental syntax requires enabling one of the following parser plugin(s): \"jsx\", \"flow\", \"typescript\". (")) message = "JSX syntax is not supported. Use plain JavaScript.";
906
+ ctx.addIssue({
907
+ code: "custom",
908
+ message,
909
+ input: val
910
+ });
911
+ }
912
+ };
913
+ const FunctionApiInsertSchema = createApiInsertSchema(FunctionInsertSchema).openapi("FunctionCreate").extend({ executeCode: z.string().trim().nonempty().superRefine(validateExecuteCode) });
885
914
  const FunctionApiUpdateSchema = createApiUpdateSchema(FunctionUpdateSchema).openapi("FunctionUpdate");
886
915
  const FetchConfigSchema = z.object({
887
916
  url: z.string().min(1, "URL is required"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-core",
3
- "version": "0.0.0-dev-20260130091014",
3
+ "version": "0.0.0-dev-20260130091101",
4
4
  "description": "Agents Core contains the database schema, types, and validation schemas for Inkeep Agent Framework, along with core components.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -101,6 +101,7 @@
101
101
  "@ai-sdk/openai": "3.0.7",
102
102
  "@ai-sdk/openai-compatible": "2.0.4",
103
103
  "@authzed/authzed-node": "^1.6.1",
104
+ "@babel/parser": "^7.28.6",
104
105
  "@better-auth/sso": "~1.4.10",
105
106
  "@composio/core": "^0.2.4",
106
107
  "@electric-sql/pglite": "^0.3.13",