@cap-js/agents 0.9.5 → 0.9.6

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/lib/compile.js CHANGED
@@ -1,10 +1,6 @@
1
1
  import cds from "@sap/cds"
2
- import {
3
- getDescription,
4
- getFilteredEntities,
5
- getFilteredActions,
6
- slugified,
7
- } from "./utils/utils.js"
2
+ import { getFilteredEntities, getFilteredActions } from "@cap-js/mcp/lib/utils/tools-shared.js"
3
+ import { getDescription, slugified } from "./utils/utils.js"
8
4
  import { buildAgentCard } from "./protocol/agent-card.js"
9
5
 
10
6
  const A2A_BASE_PATH = "/a2a"
@@ -1,12 +1,8 @@
1
1
  import cds from "@sap/cds"
2
2
  import { createRequire } from "node:module"
3
3
  const { path } = cds.utils
4
- import {
5
- getDescription,
6
- getFilteredEntities,
7
- getFilteredActions,
8
- slugified,
9
- } from "../utils/utils.js"
4
+ import { getFilteredEntities, getFilteredActions } from "@cap-js/mcp/lib/utils/tools-shared.js"
5
+ import { getDescription, slugified } from "../utils/utils.js"
10
6
  import {
11
7
  scanSkills,
12
8
  parseAgentMetadata,
@@ -1,14 +1,8 @@
1
1
  import cds from "@sap/cds"
2
2
  import { domainToASCII } from "node:url"
3
3
 
4
- function resolveI18n(value, locale) {
5
- if (!value) return undefined
6
- const match = /{i18n>([^}]+)}/.exec(value)
7
- if (match) {
8
- return cds.i18n?.labels?.texts4?.(locale)?.[match[1]] || value
9
- }
10
- return value
11
- }
4
+ import { resolveI18n, getFilteredEntities } from "@cap-js/mcp/lib/utils/tools-shared.js"
5
+ export { resolveI18n, getFilteredEntities }
12
6
 
13
7
  /**
14
8
  * Mirrors CAP's internal slug rules used for service path generation.
@@ -46,32 +40,6 @@ export function getDescription(obj, locale) {
46
40
  return result || undefined
47
41
  }
48
42
 
49
- export function getFilteredEntities(srv) {
50
- return Object.fromEntries(
51
- Object.entries(srv.entities || {})
52
- .filter(
53
- ([name, entity]) =>
54
- !entity["@cds.autoexposed"] &&
55
- !entity["@cds.api.ignore"] &&
56
- !name.endsWith("DraftAdministrativeData") &&
57
- !name.endsWith(".drafts") &&
58
- !name.endsWith(".texts"),
59
- )
60
- .sort(([a], [b]) => a.localeCompare(b)),
61
- )
62
- }
63
-
64
- export function getFilteredActions(srv) {
65
- const actions = {}
66
- for (const op of srv.actions || []) {
67
- if ((op.kind === "action" || op.kind === "function") && !op["@cds.api.ignore"]) {
68
- const localName = op.name.split(".").pop()
69
- actions[localName] = op
70
- }
71
- }
72
- return actions
73
- }
74
-
75
43
  /**
76
44
  * Sanitize an agent name into a valid LangChain/LLM tool name.
77
45
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/agents",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "description": "CDS plugin for building agents",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -42,7 +42,7 @@
42
42
  "dependencies": {
43
43
  "@a2a-js/sdk": "^0.3.12",
44
44
  "@cap-js/attachments": ">=3",
45
- "@cap-js/mcp": "^1.4",
45
+ "@cap-js/mcp": "^1.5",
46
46
  "@langchain/anthropic": "^1.5.1",
47
47
  "@langchain/core": "^1",
48
48
  "@langchain/langgraph": "^1",
@@ -11,7 +11,8 @@ import {
11
11
  executeCallActionTool,
12
12
  executePerActionTool,
13
13
  } from "@cap-js/mcp/lib/tools.js"
14
- import { getFilteredEntities, getFilteredActions } from "../../lib/utils/utils.js"
14
+
15
+ import { getFilteredEntities, getFilteredActions } from "@cap-js/mcp/lib/utils/tools-shared.js"
15
16
  import { isTextMime } from "../../lib/agents/markdown/backends/mime-utils.js"
16
17
  import { checkAuthorization } from "@cap-js/mcp/lib/auth.js"
17
18
 
@@ -78,8 +79,8 @@ class DescribeTool extends DynamicStructuredTool {
78
79
  description: def.description,
79
80
  schema: def.inputSchema,
80
81
  responseFormat: "content_and_artifact",
81
- func: async (args) => {
82
- return unwrap(await executeDescribe(srv, entities, actions, args))
82
+ func: (args) => {
83
+ return unwrap(executeDescribe(srv, entities, actions, args))
83
84
  },
84
85
  })
85
86
  this.srv = srv