@inkeep/agents-run-api 0.6.4 → 0.6.5

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.
package/dist/index.cjs CHANGED
@@ -5275,6 +5275,37 @@ var Agent = class {
5275
5275
  getMaxGenerationSteps() {
5276
5276
  return this.config.stopWhen?.stepCountIs ?? CONSTANTS.MAX_GENERATION_STEPS;
5277
5277
  }
5278
+ /**
5279
+ * Sanitizes tool names at runtime for AI SDK compatibility.
5280
+ * The AI SDK requires tool names to match pattern ^[a-zA-Z0-9_-]{1,128}$
5281
+ */
5282
+ sanitizeToolsForAISDK(tools) {
5283
+ const sanitizedTools = {};
5284
+ for (const [originalKey, toolDef] of Object.entries(tools)) {
5285
+ let sanitizedKey = originalKey.replace(/[^a-zA-Z0-9_-]/g, "_");
5286
+ sanitizedKey = sanitizedKey.replace(/_+/g, "_");
5287
+ sanitizedKey = sanitizedKey.replace(/^_+|_+$/g, "");
5288
+ if (!sanitizedKey || sanitizedKey.length === 0) {
5289
+ sanitizedKey = "unnamed_tool";
5290
+ }
5291
+ if (sanitizedKey.length > 100) {
5292
+ sanitizedKey = sanitizedKey.substring(0, 100);
5293
+ }
5294
+ const originalId = toolDef.id || originalKey;
5295
+ let sanitizedId = originalId.replace(/[^a-zA-Z0-9_.-]/g, "_");
5296
+ sanitizedId = sanitizedId.replace(/_+/g, "_");
5297
+ sanitizedId = sanitizedId.replace(/^_+|_+$/g, "");
5298
+ if (sanitizedId.length > 128) {
5299
+ sanitizedId = sanitizedId.substring(0, 128);
5300
+ }
5301
+ const sanitizedTool = {
5302
+ ...toolDef,
5303
+ id: sanitizedId
5304
+ };
5305
+ sanitizedTools[sanitizedKey] = sanitizedTool;
5306
+ }
5307
+ return sanitizedTools;
5308
+ }
5278
5309
  /**
5279
5310
  * Get the primary model settings for text generation and thinking
5280
5311
  * Requires model to be configured at project level
@@ -5971,6 +6002,7 @@ Key requirements:
5971
6002
  ...relationTools,
5972
6003
  ...defaultTools
5973
6004
  };
6005
+ const sanitizedTools = this.sanitizeToolsForAISDK(allTools);
5974
6006
  let conversationHistory = "";
5975
6007
  const historyConfig = this.config.conversationHistoryConfig ?? createDefaultConversationHistoryConfig();
5976
6008
  if (historyConfig && historyConfig.mode !== "none") {
@@ -6035,7 +6067,7 @@ Key requirements:
6035
6067
  const streamResult = ai.streamText({
6036
6068
  ...streamConfig,
6037
6069
  messages,
6038
- tools: allTools,
6070
+ tools: sanitizedTools,
6039
6071
  stopWhen: async ({ steps }) => {
6040
6072
  const last = steps.at(-1);
6041
6073
  if (last && "text" in last && last.text) {
@@ -6118,7 +6150,7 @@ Key requirements:
6118
6150
  response = await ai.generateText({
6119
6151
  ...genConfig,
6120
6152
  messages,
6121
- tools: allTools,
6153
+ tools: sanitizedTools,
6122
6154
  stopWhen: async ({ steps }) => {
6123
6155
  const last = steps.at(-1);
6124
6156
  if (last && "text" in last && last.text) {
package/dist/index.js CHANGED
@@ -4944,6 +4944,37 @@ var Agent = class {
4944
4944
  getMaxGenerationSteps() {
4945
4945
  return this.config.stopWhen?.stepCountIs ?? CONSTANTS.MAX_GENERATION_STEPS;
4946
4946
  }
4947
+ /**
4948
+ * Sanitizes tool names at runtime for AI SDK compatibility.
4949
+ * The AI SDK requires tool names to match pattern ^[a-zA-Z0-9_-]{1,128}$
4950
+ */
4951
+ sanitizeToolsForAISDK(tools) {
4952
+ const sanitizedTools = {};
4953
+ for (const [originalKey, toolDef] of Object.entries(tools)) {
4954
+ let sanitizedKey = originalKey.replace(/[^a-zA-Z0-9_-]/g, "_");
4955
+ sanitizedKey = sanitizedKey.replace(/_+/g, "_");
4956
+ sanitizedKey = sanitizedKey.replace(/^_+|_+$/g, "");
4957
+ if (!sanitizedKey || sanitizedKey.length === 0) {
4958
+ sanitizedKey = "unnamed_tool";
4959
+ }
4960
+ if (sanitizedKey.length > 100) {
4961
+ sanitizedKey = sanitizedKey.substring(0, 100);
4962
+ }
4963
+ const originalId = toolDef.id || originalKey;
4964
+ let sanitizedId = originalId.replace(/[^a-zA-Z0-9_.-]/g, "_");
4965
+ sanitizedId = sanitizedId.replace(/_+/g, "_");
4966
+ sanitizedId = sanitizedId.replace(/^_+|_+$/g, "");
4967
+ if (sanitizedId.length > 128) {
4968
+ sanitizedId = sanitizedId.substring(0, 128);
4969
+ }
4970
+ const sanitizedTool = {
4971
+ ...toolDef,
4972
+ id: sanitizedId
4973
+ };
4974
+ sanitizedTools[sanitizedKey] = sanitizedTool;
4975
+ }
4976
+ return sanitizedTools;
4977
+ }
4947
4978
  /**
4948
4979
  * Get the primary model settings for text generation and thinking
4949
4980
  * Requires model to be configured at project level
@@ -5640,6 +5671,7 @@ Key requirements:
5640
5671
  ...relationTools,
5641
5672
  ...defaultTools
5642
5673
  };
5674
+ const sanitizedTools = this.sanitizeToolsForAISDK(allTools);
5643
5675
  let conversationHistory = "";
5644
5676
  const historyConfig = this.config.conversationHistoryConfig ?? createDefaultConversationHistoryConfig();
5645
5677
  if (historyConfig && historyConfig.mode !== "none") {
@@ -5704,7 +5736,7 @@ Key requirements:
5704
5736
  const streamResult = streamText({
5705
5737
  ...streamConfig,
5706
5738
  messages,
5707
- tools: allTools,
5739
+ tools: sanitizedTools,
5708
5740
  stopWhen: async ({ steps }) => {
5709
5741
  const last = steps.at(-1);
5710
5742
  if (last && "text" in last && last.text) {
@@ -5787,7 +5819,7 @@ Key requirements:
5787
5819
  response = await generateText({
5788
5820
  ...genConfig,
5789
5821
  messages,
5790
- tools: allTools,
5822
+ tools: sanitizedTools,
5791
5823
  stopWhen: async ({ steps }) => {
5792
5824
  const last = steps.at(-1);
5793
5825
  if (last && "text" in last && last.text) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-run-api",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "Agents Run API for Inkeep Agent Framework - handles chat, agent execution, and streaming",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -52,7 +52,7 @@
52
52
  "traverse": "^0.6.11",
53
53
  "ts-pattern": "^5.7.1",
54
54
  "zod": "^4.1.5",
55
- "@inkeep/agents-core": "^0.6.4"
55
+ "@inkeep/agents-core": "^0.6.5"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@hono/vite-dev-server": "^0.20.1",