@adminforth/agent 3.1.9 → 3.2.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.
Files changed (42) hide show
  1. package/README.md +71 -38
  2. package/dist/application/ports.d.ts +3 -1
  3. package/dist/application/runTurnUseCase.d.ts +3 -3
  4. package/dist/application/runTurnUseCase.js +8 -6
  5. package/dist/custom/ChatHeader.vue +1 -1
  6. package/dist/custom/{skills/charts/SKILL.md → charts.md} +2 -4
  7. package/dist/domain/systemPrompt.d.ts +3 -2
  8. package/dist/domain/systemPrompt.js +14 -53
  9. package/dist/index.d.ts +0 -3
  10. package/dist/index.js +24 -35
  11. package/dist/llm/agentRuntime.d.ts +9 -8
  12. package/dist/llm/agentRuntime.js +134 -106
  13. package/dist/llm/langGraphLlm.d.ts +3 -0
  14. package/dist/llm/langGraphLlm.js +10 -2
  15. package/dist/llm/middleware/mcpToolsMiddleware.d.ts +7 -0
  16. package/dist/llm/middleware/{apiToolsMiddleware.js → mcpToolsMiddleware.js} +16 -36
  17. package/dist/tools/agentToolProvider.d.ts +16 -5
  18. package/dist/tools/agentToolProvider.js +26 -10
  19. package/dist/tools/fetchToolSchema.d.ts +7 -3
  20. package/dist/tools/fetchToolSchema.js +29 -22
  21. package/dist/tools/mcpConnection.d.ts +38 -0
  22. package/dist/tools/mcpConnection.js +42 -0
  23. package/dist/tools/mcpTool.d.ts +3 -0
  24. package/dist/tools/{apiTool.js → mcpTool.js} +7 -23
  25. package/dist/tools/toolLabels.d.ts +5 -0
  26. package/dist/tools/toolLabels.js +49 -0
  27. package/dist/transport/http/context.d.ts +2 -2
  28. package/dist/transport/http/sessionEndpoints.js +1 -1
  29. package/package.json +6 -4
  30. package/dist/custom/skills/analyze_data/SKILL.md +0 -25
  31. package/dist/custom/skills/fetch_data/SKILL.md +0 -31
  32. package/dist/custom/skills/mutate_data/SKILL.md +0 -121
  33. package/dist/llm/middleware/apiToolsMiddleware.d.ts +0 -3
  34. package/dist/tools/apiBasedTools.d.ts +0 -30
  35. package/dist/tools/apiBasedTools.js +0 -488
  36. package/dist/tools/apiTool.d.ts +0 -6
  37. package/dist/tools/fetchSkill.d.ts +0 -8
  38. package/dist/tools/fetchSkill.js +0 -51
  39. package/dist/tools/index.d.ts +0 -4
  40. package/dist/tools/index.js +0 -32
  41. package/dist/tools/skills/registry.d.ts +0 -11
  42. package/dist/tools/skills/registry.js +0 -107
@@ -0,0 +1,38 @@
1
+ import { type Tool, type Transport } from "@modelcontextprotocol/client";
2
+ import type { AdminUser } from "adminforth";
3
+ export declare const MCP_PLUGIN_CLASS_NAME = "AdminForthMcpPlugin";
4
+ /** The `openConnection` session of @adminforth/mcp: a user this process already authenticated. */
5
+ type McpSession = {
6
+ adminUser: AdminUser;
7
+ /** Binds 2FA confirmations of the connection's actions to it. */
8
+ connection: {
9
+ id: string;
10
+ name: string;
11
+ };
12
+ readOnly: boolean;
13
+ headers: Record<string, string>;
14
+ requestUrl: string;
15
+ timeZone?: string;
16
+ };
17
+ /** The part of the @adminforth/mcp plugin the agent works through. */
18
+ export type McpPlugin = {
19
+ openConnection(session: McpSession): Promise<Transport>;
20
+ };
21
+ export type McpConnectionInput = {
22
+ adminUser: AdminUser;
23
+ sessionId: string;
24
+ userTimeZone?: string;
25
+ requestUrl: string;
26
+ };
27
+ /** One MCP connection of an agent turn, open until `close`. */
28
+ export type AgentMcpConnection = {
29
+ /** Server instructions: rules for every MCP client and the list of skills. */
30
+ instructions: string;
31
+ tools: Tool[];
32
+ /** Calls a tool and returns its YAML output; tool-level errors come back as output too. */
33
+ callTool(name: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<string>;
34
+ close(): Promise<void>;
35
+ };
36
+ /** The agent has exactly the permissions of the user it runs for, so its connections are never read-only. */
37
+ export declare function connectMcp(mcp: McpPlugin, input: McpConnectionInput): Promise<AgentMcpConnection>;
38
+ export {};
@@ -0,0 +1,42 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { Client } from "@modelcontextprotocol/client";
11
+ export const MCP_PLUGIN_CLASS_NAME = "AdminForthMcpPlugin";
12
+ // Shown in the audit log and on the 2FA confirmation page of the admin panel.
13
+ const AGENT_EXECUTED_BY = "af-agent";
14
+ const AGENT_CONNECTION_NAME = "AdminForth Agent";
15
+ const AGENT_CLIENT_INFO = { name: "adminforth-agent", version: "1.0.0" };
16
+ /** The agent has exactly the permissions of the user it runs for, so its connections are never read-only. */
17
+ export function connectMcp(mcp, input) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const client = new Client(AGENT_CLIENT_INFO);
20
+ yield client.connect(yield mcp.openConnection({
21
+ adminUser: Object.assign(Object.assign({}, input.adminUser), { executedBy: AGENT_EXECUTED_BY }),
22
+ connection: { id: `agent:${input.sessionId}`, name: AGENT_CONNECTION_NAME },
23
+ readOnly: false,
24
+ headers: {},
25
+ requestUrl: input.requestUrl,
26
+ timeZone: input.userTimeZone,
27
+ }));
28
+ const { tools } = yield client.listTools();
29
+ return {
30
+ instructions: client.getInstructions(),
31
+ tools,
32
+ callTool(name, args, signal) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ // The AdminForth MCP server answers every call with a single text block.
35
+ const { content } = yield client.callTool({ name, arguments: args }, { signal });
36
+ return content[0].text;
37
+ });
38
+ },
39
+ close: () => client.close(),
40
+ };
41
+ });
42
+ }
@@ -0,0 +1,3 @@
1
+ import type { Tool } from "@modelcontextprotocol/client";
2
+ import type { AgentMcpConnection } from "./mcpConnection.js";
3
+ export declare function createMcpTool(mcpTool: Tool, connection: AgentMcpConnection): import("langchain").DynamicStructuredTool<Record<string, unknown>, unknown, unknown, string, unknown, string>;
@@ -8,19 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { tool } from "langchain";
11
- const emptyToolSchema = {
12
- type: "object",
13
- properties: {},
14
- additionalProperties: true,
15
- };
11
+ // Model providers reject top-level composite keywords in tool schemas; the MCP server still validates them.
16
12
  function normalizeToolInputSchema(inputSchema) {
17
- if (!inputSchema || typeof inputSchema !== "object" || Array.isArray(inputSchema)) {
18
- return emptyToolSchema;
19
- }
20
- const schema = JSON.parse(JSON.stringify(inputSchema));
21
- if (schema.type !== "object") {
22
- return emptyToolSchema;
23
- }
13
+ const schema = structuredClone(inputSchema);
24
14
  const notes = [];
25
15
  if ("if" in schema || "then" in schema || "else" in schema || "allOf" in schema) {
26
16
  delete schema.if;
@@ -43,20 +33,14 @@ function normalizeToolInputSchema(inputSchema) {
43
33
  }
44
34
  return schema;
45
35
  }
46
- export function createApiTool(toolName, apiBasedTool) {
36
+ export function createMcpTool(mcpTool, connection) {
47
37
  var _a;
48
38
  return tool((input, runtime) => __awaiter(this, void 0, void 0, function* () {
49
- const normalizedInput = (input !== null && input !== void 0 ? input : {});
50
- return apiBasedTool.call({
51
- adminUser: runtime.context.adminUser,
52
- abortSignal: runtime.context.abortSignal,
53
- inputs: normalizedInput,
54
- userTimeZone: runtime.context.userTimeZone,
55
- });
39
+ return connection.callTool(mcpTool.name, input, runtime.context.abortSignal);
56
40
  }), {
57
- name: toolName,
58
- description: (_a = apiBasedTool.description) !== null && _a !== void 0 ? _a : `${toolName} tool`,
59
- schema: normalizeToolInputSchema(apiBasedTool.input_schema),
41
+ name: mcpTool.name,
42
+ description: (_a = mcpTool.description) !== null && _a !== void 0 ? _a : mcpTool.name,
43
+ schema: normalizeToolInputSchema(mcpTool.inputSchema),
60
44
  verboseParsingErrors: true,
61
45
  });
62
46
  }
@@ -0,0 +1,5 @@
1
+ import type { IAdminForth } from "adminforth";
2
+ type ToolInputs = Record<string, unknown>;
3
+ /** Human-readable label of a tool call for the processing timeline; undefined for tools without one. */
4
+ export declare function formatToolCall(adminforth: IAdminForth, toolName: string, inputs: ToolInputs): string;
5
+ export {};
@@ -0,0 +1,49 @@
1
+ function getInputString(inputs, key) {
2
+ const value = inputs[key];
3
+ return typeof value === "string" && value ? value : undefined;
4
+ }
5
+ function getInputArrayLength(inputs, key) {
6
+ const value = inputs[key];
7
+ return Array.isArray(value) ? value.length : undefined;
8
+ }
9
+ function resourceLabel(adminforth, inputs) {
10
+ var _a, _b;
11
+ const resourceId = getInputString(inputs, "resourceId");
12
+ const resource = adminforth.config.resources.find((res) => res.resourceId === resourceId);
13
+ return (_b = (_a = resource === null || resource === void 0 ? void 0 : resource.label) !== null && _a !== void 0 ? _a : resourceId) !== null && _b !== void 0 ? _b : "resource";
14
+ }
15
+ function getDataPrefix(inputs) {
16
+ const offset = typeof inputs.offset === "number" ? inputs.offset : undefined;
17
+ const limit = typeof inputs.limit === "number" ? inputs.limit : undefined;
18
+ if (offset !== undefined && limit !== undefined) {
19
+ return `${offset}-${offset + limit} `;
20
+ }
21
+ return limit === undefined ? "" : `${limit} `;
22
+ }
23
+ function actionText(inputs) {
24
+ const actionId = getInputString(inputs, "actionId");
25
+ return actionId ? ` action ${actionId}` : " action";
26
+ }
27
+ function bulkActionLabel({ inputs, resourceLabel }) {
28
+ const recordCount = getInputArrayLength(inputs, "recordIds");
29
+ const recordsText = recordCount === undefined ? "" : ` for ${recordCount} records`;
30
+ return `Run ${resourceLabel}${actionText(inputs)}${recordsText}`;
31
+ }
32
+ const TOOL_LABELS = {
33
+ fetch_skill: ({ inputs }) => `Load ${inputs.skillName.split("-").join(" ")} skill`,
34
+ fetch_tool_schema: ({ inputs }) => `Load ${inputs.toolName.split("_").join(" ")} tool`,
35
+ get_resource: ({ resourceLabel }) => `Get ${resourceLabel} resource`,
36
+ get_resource_data: ({ inputs, resourceLabel }) => `Get ${getDataPrefix(inputs)}${resourceLabel}`,
37
+ aggregate: ({ resourceLabel }) => `Aggregate ${resourceLabel}`,
38
+ start_custom_action: ({ inputs, resourceLabel }) => `Run ${resourceLabel}${actionText(inputs)}`,
39
+ start_custom_bulk_action: bulkActionLabel,
40
+ start_bulk_action: bulkActionLabel,
41
+ create_record: ({ resourceLabel }) => `Create ${resourceLabel}`,
42
+ update_record: ({ resourceLabel }) => `Update ${resourceLabel}`,
43
+ delete_record: ({ resourceLabel }) => `Delete ${resourceLabel}`,
44
+ };
45
+ /** Human-readable label of a tool call for the processing timeline; undefined for tools without one. */
46
+ export function formatToolCall(adminforth, toolName, inputs) {
47
+ var _a;
48
+ return (_a = TOOL_LABELS[toolName]) === null || _a === void 0 ? void 0 : _a.call(TOOL_LABELS, { inputs, resourceLabel: resourceLabel(adminforth, inputs) });
49
+ }
@@ -1,4 +1,4 @@
1
- import type { ChatSurfaceAdapter, ChatSurfaceEventSink, ChatSurfaceIncomingMessage, IAdminForth, IAdminForthEndpointHandlerInput } from "adminforth";
1
+ import type { AdminUser, ChatSurfaceAdapter, ChatSurfaceEventSink, ChatSurfaceIncomingMessage, IAdminForth, IAdminForthEndpointHandlerInput } from "adminforth";
2
2
  import type { HandleEditTurnInput, HandleSpeechTurnInput, HandleTurnInput, RunAndPersistAgentResponseInput, RunAndPersistAgentResponseResult } from "../../domain/turnTypes.js";
3
3
  import type { PluginOptions } from "../../types.js";
4
4
  import type { ApprovalDescription } from "../../tools/approvalFormatter.js";
@@ -23,7 +23,7 @@ export type AgentEndpointsContext = {
23
23
  }>;
24
24
  runAndPersistAgentResponse(input: RunAndPersistAgentResponseInput): Promise<RunAndPersistAgentResponseResult>;
25
25
  getSessionTurns(sessionId: string): Promise<SessionTurn[]>;
26
- getPendingApprovals(sessionId: string): Promise<ApprovalDescription[]>;
26
+ getPendingApprovals(sessionId: string, adminUser: AdminUser): Promise<ApprovalDescription[]>;
27
27
  createNewTurn(sessionId: string, prompt: string, response?: string): Promise<string>;
28
28
  createSystemTurn(sessionId: string, systemMessage: string): Promise<string>;
29
29
  appendSteerToCurrentTurn(sessionId: string, steerText: string): Promise<void>;
@@ -83,7 +83,7 @@ export function setupSessionEndpoints(ctx, server) {
83
83
  ctx.getSessionTurns(sessionId),
84
84
  // The approval prompt lives only in the browser, so a reload has to rebuild it
85
85
  // from the agent's persisted state — otherwise the user cannot answer it.
86
- ctx.getPendingApprovals(sessionId),
86
+ ctx.getPendingApprovals(sessionId, adminUser),
87
87
  ]);
88
88
  return {
89
89
  session: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/agent",
3
- "version": "3.1.9",
3
+ "version": "3.2.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -34,9 +34,10 @@
34
34
  "license": "MIT",
35
35
  "description": "AI agent plugin for AdminForth with tool-based workflows and persistent chat sessions",
36
36
  "devDependencies": {
37
+ "@modelcontextprotocol/server": "2.3.1",
37
38
  "@types/jest": "^30.0.0",
38
39
  "@types/node": "latest",
39
- "adminforth": "^4.7.3",
40
+ "adminforth": "^4.14.0",
40
41
  "jest": "^30.3.0",
41
42
  "semantic-release": "^24.2.1",
42
43
  "semantic-release-slack-bot": "^4.0.2",
@@ -47,7 +48,7 @@
47
48
  "@langchain/core": "1.2.5",
48
49
  "@langchain/langgraph": "1.2.8",
49
50
  "@langchain/langgraph-checkpoint": "1.0.1",
50
- "dayjs": "^1.11.20",
51
+ "@modelcontextprotocol/client": "2.3.1",
51
52
  "langchain": "1.3.3",
52
53
  "multer": "^2.1.1",
53
54
  "vue-i18n": "^11.4.0",
@@ -80,6 +81,7 @@
80
81
  }
81
82
  ],
82
83
  "peerDependencies": {
83
- "adminforth": "^4.7.3"
84
+ "adminforth": "^4.7.3",
85
+ "@adminforth/mcp": "^3.2.0"
84
86
  }
85
87
  }
@@ -1,25 +0,0 @@
1
- name: analyze_data
2
- description: Universal skill to analyze AdminForth resource data, summarize trends, and compare distributions from fetched rows.
3
- ---
4
-
5
- # Involved tools
6
-
7
- Always call `get_resource` first if you need to inspect resource structure and column names.
8
-
9
- Then you need to select between two main tools for fetching data:
10
-
11
- - Load and call `aggregate` tool to fetch data for analytics. This is the main tool for fast server-side aggregations, including filtered data, grouped metrics, and date buckets such as day, week, or month. Always prioritize this way of fetching data for analytics, as it is optimized for performance and reduces the amount of data transferred and processed in-memory.
12
-
13
- - Load and call `get_resource_data` tool only when the requested analysis cannot be answered with `aggregate`. When using it, pass `columns` with only the fields required for the calculation so large result sets do not include unrelated row data.
14
-
15
- # Instructions
16
-
17
- When the user asks for analytics, reports, trends, comparisons, or distributions:
18
-
19
- - Fetch the requested data using `aggregate` whenever possible.
20
- - If it is not possible to get the required aggregates using `aggregate`, fetch the underlying rows with `get_resource_data`.
21
- - Prefer narrow requests: use filters, sorting, pagination, and date ranges whenever possible.
22
- - Prefer narrow row payloads: include `columns` when only one or a few fields are needed.
23
- - If the request is ambiguous, clarify the resource, metric, grouping, or date range before fetching data.
24
- - Return a short written summary with the key finding and most important numbers.
25
- - If the user asks for a chart, or if a chart would help and you decide to produce one, invoke the `charts` skill for chart formatting and Vega-Lite requirements.
@@ -1,31 +0,0 @@
1
- name: fetch_data
2
- description: Fetch one or more records. Use to find records entities. To use this skill you first need to call get_resource tool to know resource column names. This tool returns only atomic record(s) not capable with any aggregations.
3
- ---
4
-
5
- # Involved tools
6
-
7
- You can use tool `get_resource_data` it returns one or more records and is capable of using filters
8
-
9
- When you only need specific fields, pass `columns` with the exact resource column names you need. This keeps large result sets small. For record links or user-facing record choices, include the primary key and enough display fields, or omit `columns` when you need the full row context.
10
-
11
- # Instructions
12
-
13
- To find specific data record you should use filters. ILIKE filters are preferred when we are unsure the input is clear. Pass raw search text to LIKE and ILIKE filters; never wrap filter values in SQL wildcards such as `%`. You can combine filters with OR if you want to search multiple fields. If user queries one record you should try to fetch up to 5 records and if more then one returned return output them all to user and ask to select one. When you communicate about record with user, show its several most important fields.
14
-
15
- Every record summary must be based on one exact row returned by `get_resource_data`.
16
-
17
- Never combine model/title/name, `_label`, primary key, link, or any field values from different rows.
18
-
19
- Never combine fields from different resources in one candidate.
20
-
21
- If results come from multiple resources, present them as separate groups with the resource label or resourceId.
22
-
23
- If several rows look similar, do not guess which one is "the same" record. Show them separately and ask user to choose.
24
-
25
- For long texts show only several first words and add "..." at the end (only if user did not request this field specifically).
26
-
27
- Never show information about more than 10 records in one message. If a tool returns more than 10 relevant records, summarize the total count if known, show only the 10 most relevant records, and offer to narrow filters, sort differently, or continue with the next 10.
28
-
29
- Also when you communicate with user about record, add related link to this record. Build it as `{ADMIN_BASE_PATH}resource/{resourceId}/show/{primary key}`. Use _label from `get_resource_data` as anchor text for link (use markdown link). Links should always be relative paths and must start with `ADMIN_BASE_PATH`. Do not add an extra slash after `ADMIN_BASE_PATH`.
30
-
31
- Before sending the link, verify that the `resourceId`, `{primary key}`, `_label`, and shown fields come from the same exact returned row.
@@ -1,121 +0,0 @@
1
- name: mutate_data
2
- description: Create/update/delete some record of resource or call actions on one or multiple records
3
- ---
4
-
5
- # Involved tools
6
-
7
- Use `create_record` for creating records.
8
-
9
- Use `update_record` for editing records.
10
-
11
- Use `delete_record` for deleting records.
12
-
13
- Use `start_custom_action` and `start_custom_bulk_action` for resource actions.
14
-
15
- # General rules
16
-
17
- - if there is a dedicated action for some routine (result of `get_resource` tool call, field actions), prefer this to manual updating of records, for example, if you want to approve some comment, prefer calling `approve` action instead of updating `approved` field of comment record (because in action there might be some additional logic like sending notification to user, updating some counters and so on)
18
-
19
- ## Mutation context
20
-
21
- Before performing any state mutation including action calls edit/delete please fetch record which is going to be edited/deleted and show user record in format field → value (show several most important fields which can help user to understand what exactly record he is going to edit or delete).
22
-
23
- Every mutation description must describe one exact fetched row. Never combine `_label`, primary key, link, or field values from different rows or different resources in one description.
24
-
25
- For field values with long texts show only several first words and add "..." at the end.
26
- Also please add related link to record with will be changed. Build it as `{ADMIN_BASE_PATH}resource/{resourceId}/show/{primary key}`. Use _label from `get_resource_data` as anchor text for link (use markdown link). Links should always be relative paths and must start with `ADMIN_BASE_PATH`. Do not add an extra slash after `ADMIN_BASE_PATH`.
27
-
28
- Before calling the mutation tool, verify that the `resourceId`, `{primary key}`, `_label`, and all shown fields come from the same exact fetched row.
29
-
30
- Never show information about more than 10 records in one message. If a mutation plan affects more than 10 records, show only the 10 most important examples plus the total count if known.
31
-
32
- When creating new record, show user all data which you gonna create.
33
-
34
- Do not ask user for textual confirmation. Dangerous tools are approved by the runtime approval UI.
35
-
36
- # Calling actions
37
-
38
- To call action on some record you can use `start_custom_action` tool, or `start_custom_bulk_action` if you need to perform action on several records at once.
39
-
40
- Before calling any of this action you should understand whether this action is allowed. User result of `get_resource` tool call and check `action.allowed` - if this attribute is true or is not exists, assume action is allowed. If this attribute is false, action is not allowed, you should warn user that this action is not allowed for him.
41
-
42
- ### Example
43
-
44
- If you want to block some user you can describe the action by saying:
45
-
46
- ```I am going to block user:
47
- * Username: john_doe
48
- * Email: john_doe@example.com
49
- * IP Country: USA
50
- * Currently blocked: No // show this field only if it exists in user record
51
-
52
- View [John Doe]({ADMIN_BASE_PATH}resource/users/show/123)
53
- ```
54
-
55
- ## Updating
56
-
57
- You can use tool `update_record` tool it updates fields of record. To update `allowedActions.edit` should be set to true and
58
- `updated` column `showIn.edit` should be true at the same time. If one of this condition is not met, explain to user that is not allowed to edit
59
-
60
- In addition to instructions above show user the table of edits (old value/new value)
61
-
62
- ### Examples
63
-
64
- For example if you gonna modify user record, please share full user info (not only username but also email, ip country - anything which help adminto check that that is correct user). Message could look like this:
65
-
66
- ```
67
- I am going to update user:
68
- * Username: john_doe
69
- * Email: john_doe@example.com
70
- * IP Country: USA
71
- I am going to change email from john_doe@example.com to new_email@example.com
72
-
73
- View [John Doe]({ADMIN_BASE_PATH}resource/users/show/123)
74
- ```
75
-
76
-
77
- ## Deleting
78
-
79
- To delete some record you can use `delete_record` tool. To delete record `allowedActions.delete` should be set to true.
80
-
81
- ### Example
82
-
83
- If you gonna delete user record, please share full user info (not only username but also email, ip country - anything which help adminto check that that is correct user). Message could look like this:
84
-
85
- ```I am going to delete user:
86
- * Username: john_doe
87
- * Email: john_doe@example.com
88
- * Signed up: 2024 Jan 1
89
- * IP Country: USA
90
-
91
- View [John Doe]({ADMIN_BASE_PATH}resource/users/show/123)
92
- ```
93
-
94
- ## Creating
95
-
96
- To create new record you can use tool `create_record`. To create record `allowedActions.create` should be set to true.
97
-
98
- When calling `create_record` tool pass only columns which have `showIn.create` set to true and `backendOnly` is not set to true.
99
-
100
- For decimal fields please use string values with dot as decimal separator.
101
-
102
- After creation of new record also show user a link to this record. If several records record were created, show links to all of them in list.
103
-
104
- If more than 10 records were created, show links or details for only 10 of them and summarize the remaining count.
105
-
106
- Omit any pictures or file paths, you are not capable of doing it. If they are not required all is good, if they are required, explain to user that you are not able to create record because of this reason.
107
-
108
- ### Working with dates
109
-
110
- When you create or update date or datetime fields, please use ISO format for this. For example, "2024-01-01" for date and "2024-01-01T12:00:00Z" for datetime. If user provides date in different format, try to parse it and convert to ISO format.
111
-
112
- ### Example
113
-
114
-
115
- ```
116
- I am going to create user:
117
- * Username: john_doe
118
- * Email: john_doe@example.com
119
-
120
- View [John Doe]({ADMIN_BASE_PATH}resource/users/show/421) # 421 is id of new created record
121
- ```
@@ -1,3 +0,0 @@
1
- import { type IAdminForth } from "adminforth";
2
- import { type ApiBasedTool } from "../../tools/apiBasedTools.js";
3
- export declare function createApiBasedToolsMiddleware(apiBasedTools: Record<string, ApiBasedTool>, adminforth: IAdminForth): import("langchain").AgentMiddleware<undefined, undefined, unknown, readonly (import("@langchain/core/tools").ClientTool | import("@langchain/core/tools").ServerTool)[]>;
@@ -1,30 +0,0 @@
1
- import { type AdminUser, type IAdminForth } from 'adminforth';
2
- type AgentToolMeta = {
3
- requiresHumanApproval?: boolean;
4
- /** @deprecated Older name of `requiresHumanApproval`, still set by endpoints built for earlier AdminForth versions. */
5
- isDangerous?: boolean;
6
- hiddenFromAgents?: boolean;
7
- };
8
- export type ApiBasedToolCallParams = {
9
- adminUser?: AdminUser;
10
- adminuser?: AdminUser;
11
- abortSignal?: AbortSignal;
12
- inputs?: Record<string, unknown>;
13
- userTimeZone?: string;
14
- acceptLanguage?: string;
15
- };
16
- export type ApiBasedTool = {
17
- description?: string;
18
- input_schema?: unknown;
19
- agent?: AgentToolMeta;
20
- call: (params?: ApiBasedToolCallParams) => Promise<string>;
21
- };
22
- export declare function formatApiBasedToolCall(params: {
23
- adminforth: IAdminForth;
24
- adminUser?: AdminUser;
25
- inputs?: Record<string, unknown>;
26
- toolName: string;
27
- userTimeZone?: string;
28
- }): Promise<string | undefined>;
29
- export declare function prepareApiBasedTools(adminforth: IAdminForth, hiddenResourceIds?: Iterable<string>): Record<string, ApiBasedTool>;
30
- export {};