@adminforth/agent 1.18.6 → 1.20.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.
@@ -165,7 +165,6 @@ function createAgentLlmMetricsLogger() {
165
165
  export function createAgentChatModel(params: {
166
166
  adapter: CompletionAdapter;
167
167
  maxTokens: number;
168
- modelName?: string;
169
168
  }) {
170
169
  const adapter = params.adapter as OpenAIBackedCompletionAdapter;
171
170
  const options = adapter.options ?? {};
@@ -176,7 +175,7 @@ export function createAgentChatModel(params: {
176
175
  );
177
176
  }
178
177
 
179
- const model = params.modelName ?? options.model ?? "gpt-5-nano";
178
+ const model = options.model ?? "gpt-5-nano";
180
179
  const baseURL = options.baseURL ?? options.baseUrl;
181
180
  const reasoning = options.extraRequestBodyParameters
182
181
  ?.reasoning as OpenAiReasoningConfig | undefined;
@@ -195,8 +194,8 @@ export function createAgentChatModel(params: {
195
194
  useResponsesApi: true,
196
195
  outputVersion: "v1",
197
196
  streaming: true,
198
- promptCacheKey: `adminforth-agent:${model}:system-v1:tools-v1`,
199
197
 
198
+ promptCacheKey: `adminforth-agent:${model}:system-v1:tools-v1`,
200
199
  promptCacheRetention: "in_memory",
201
200
 
202
201
  ...(reasoningConfig ? { reasoning: reasoningConfig } : {}),
package/build.log CHANGED
@@ -32,5 +32,5 @@ custom/skills/fetch_data/SKILL.md
32
32
  custom/skills/mutate_data/
33
33
  custom/skills/mutate_data/SKILL.md
34
34
 
35
- sent 187,526 bytes received 451 bytes 125,318.00 bytes/sec
36
- total size is 185,674 speedup is 0.99
35
+ sent 188,483 bytes received 451 bytes 377,868.00 bytes/sec
36
+ total size is 186,631 speedup is 0.99
@@ -10,6 +10,18 @@ You can use tool `get_resource_data` it returns one or more records and is capab
10
10
 
11
11
  To find specific data record you should use filters. ILIKE filters are preferred when we are unsure the input is clear.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.
12
12
 
13
+ Every record summary must be based on one exact row returned by `get_resource_data`.
14
+
15
+ Never combine model/title/name, `_label`, primary key, link, or any field values from different rows.
16
+
17
+ Never combine fields from different resources in one candidate.
18
+
19
+ If results come from multiple resources, present them as separate groups with the resource label or resourceId.
20
+
21
+ If several rows look similar, do not guess which one is "the same" record. Show them separately and ask user to choose.
22
+
13
23
  For long texts show only several first words and add "..." at the end (only if user did not request this field specifically).
14
24
 
15
25
  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`.
26
+
27
+ Before sending the link, verify that the `resourceId`, `{primary key}`, `_label`, and shown fields come from the same exact returned row.
@@ -20,9 +20,13 @@ Use `start_custom_action` and `start_custom_bulk_action` for resource actions.
20
20
 
21
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
22
 
23
+ Every confirmation must describe one exact fetched row. Never combine `_label`, primary key, link, or field values from different rows or different resources in one confirmation.
24
+
23
25
  For field values with long texts show only several first words and add "..." at the end.
24
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`.
25
27
 
28
+ Before sending the confirmation, verify that the `resourceId`, `{primary key}`, `_label`, and all shown fields come from the same exact fetched row.
29
+
26
30
  And in the same message ask user for final confirmation.
27
31
 
28
32
  When creating new record, show user all data which you gona create and in same message ask for confirmation.
@@ -102,15 +102,15 @@ function createAgentLlmMetricsLogger() {
102
102
  return new AgentLlmMetricsLogger();
103
103
  }
104
104
  export function createAgentChatModel(params) {
105
- var _a, _b, _c, _d, _e;
105
+ var _a, _b, _c, _d;
106
106
  const adapter = params.adapter;
107
107
  const options = (_a = adapter.options) !== null && _a !== void 0 ? _a : {};
108
108
  if (!options.openAiApiKey) {
109
109
  throw new Error("CompletionAdapter must expose options.openAiApiKey for ChatOpenAI");
110
110
  }
111
- const model = (_c = (_b = params.modelName) !== null && _b !== void 0 ? _b : options.model) !== null && _c !== void 0 ? _c : "gpt-5-nano";
112
- const baseURL = (_d = options.baseURL) !== null && _d !== void 0 ? _d : options.baseUrl;
113
- const reasoning = (_e = options.extraRequestBodyParameters) === null || _e === void 0 ? void 0 : _e.reasoning;
111
+ const model = (_b = options.model) !== null && _b !== void 0 ? _b : "gpt-5-nano";
112
+ const baseURL = (_c = options.baseURL) !== null && _c !== void 0 ? _c : options.baseUrl;
113
+ const reasoning = (_d = options.extraRequestBodyParameters) === null || _d === void 0 ? void 0 : _d.reasoning;
114
114
  const reasoningConfig = reasoning
115
115
  ? Object.assign(Object.assign({}, reasoning), { summary: "auto" }) : undefined;
116
116
  // @ts-ignore
@@ -10,6 +10,18 @@ You can use tool `get_resource_data` it returns one or more records and is capab
10
10
 
11
11
  To find specific data record you should use filters. ILIKE filters are preferred when we are unsure the input is clear.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.
12
12
 
13
+ Every record summary must be based on one exact row returned by `get_resource_data`.
14
+
15
+ Never combine model/title/name, `_label`, primary key, link, or any field values from different rows.
16
+
17
+ Never combine fields from different resources in one candidate.
18
+
19
+ If results come from multiple resources, present them as separate groups with the resource label or resourceId.
20
+
21
+ If several rows look similar, do not guess which one is "the same" record. Show them separately and ask user to choose.
22
+
13
23
  For long texts show only several first words and add "..." at the end (only if user did not request this field specifically).
14
24
 
15
25
  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`.
26
+
27
+ Before sending the link, verify that the `resourceId`, `{primary key}`, `_label`, and shown fields come from the same exact returned row.
@@ -20,9 +20,13 @@ Use `start_custom_action` and `start_custom_bulk_action` for resource actions.
20
20
 
21
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
22
 
23
+ Every confirmation must describe one exact fetched row. Never combine `_label`, primary key, link, or field values from different rows or different resources in one confirmation.
24
+
23
25
  For field values with long texts show only several first words and add "..." at the end.
24
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`.
25
27
 
28
+ Before sending the confirmation, verify that the `resourceId`, `{primary key}`, `_label`, and all shown fields come from the same exact fetched row.
29
+
26
30
  And in the same message ask user for final confirmation.
27
31
 
28
32
  When creating new record, show user all data which you gona create and in same message ask for confirmation.
package/dist/index.js CHANGED
@@ -371,7 +371,8 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
371
371
  path: `/agent/get-sessions`,
372
372
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser }) {
373
373
  const userId = adminUser.pk;
374
- const sessions = yield this.adminforth.resource(this.pluginOptions.sessionResource.resourceId).list([Filters.EQ(this.pluginOptions.sessionResource.askerIdField, userId)], undefined, undefined, [Sorts.DESC(this.pluginOptions.sessionResource.createdAtField)]);
374
+ const limit = typeof body.limit === 'number' ? body.limit : 20;
375
+ const sessions = yield this.adminforth.resource(this.pluginOptions.sessionResource.resourceId).list([Filters.EQ(this.pluginOptions.sessionResource.askerIdField, userId)], limit, undefined, [Sorts.DESC(this.pluginOptions.sessionResource.createdAtField)]);
375
376
  const sessionsToReturn = [];
376
377
  for (const session of sessions) {
377
378
  sessionsToReturn.push({
package/index.ts CHANGED
@@ -422,8 +422,9 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
422
422
  path: `/agent/get-sessions`,
423
423
  handler: async ({body, adminUser }) => {
424
424
  const userId = adminUser.pk;
425
+ const limit = typeof body.limit === 'number' ? body.limit : 20;
425
426
  const sessions = await this.adminforth.resource(this.pluginOptions.sessionResource.resourceId).list(
426
- [Filters.EQ(this.pluginOptions.sessionResource.askerIdField, userId)], undefined, undefined, [Sorts.DESC(this.pluginOptions.sessionResource.createdAtField)]
427
+ [Filters.EQ(this.pluginOptions.sessionResource.askerIdField, userId)], limit, undefined, [Sorts.DESC(this.pluginOptions.sessionResource.createdAtField)]
427
428
  );
428
429
  const sessionsToReturn = [];
429
430
  for (const session of sessions) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/agent",
3
- "version": "1.18.6",
3
+ "version": "1.20.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",