@adminforth/agent 1.15.0 → 1.16.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.
@@ -35,10 +35,21 @@ export const DEFAULT_AGENT_SYSTEM_PROMPT = [
35
35
  "If the confirmed plan has multiple steps, you may execute the whole confirmed plan without asking again between those steps.",
36
36
  "If the plan changes, expands, or you want to do anything beyond the confirmed plan, ask for confirmation again.",
37
37
  "Do not reuse an old confirmation for a new mutation plan.",
38
-
39
-
40
38
  ].join(" ");
41
39
 
40
+ export function appendCustomSystemPrompt(
41
+ systemPrompt: string,
42
+ customSystemPrompt?: string,
43
+ ) {
44
+ const normalizedCustomSystemPrompt = customSystemPrompt?.trim();
45
+
46
+ if (!normalizedCustomSystemPrompt) {
47
+ return systemPrompt;
48
+ }
49
+
50
+ return `${systemPrompt}\n\n${normalizedCustomSystemPrompt}`;
51
+ }
52
+
42
53
  function formatResources(resources: AdminForthResource[]) {
43
54
  return resources
44
55
  .map((resource) => `- resourceId: ${resource.resourceId}\n label: ${resource.label}`)
package/build.log CHANGED
@@ -31,5 +31,5 @@ custom/skills/fetch_data/SKILL.md
31
31
  custom/skills/mutate_data/
32
32
  custom/skills/mutate_data/SKILL.md
33
33
 
34
- sent 184,200 bytes received 436 bytes 369,272.00 bytes/sec
34
+ sent 184,204 bytes received 436 bytes 369,280.00 bytes/sec
35
35
  total size is 182,411 speedup is 0.99
@@ -35,6 +35,13 @@ export const DEFAULT_AGENT_SYSTEM_PROMPT = [
35
35
  "If the plan changes, expands, or you want to do anything beyond the confirmed plan, ask for confirmation again.",
36
36
  "Do not reuse an old confirmation for a new mutation plan.",
37
37
  ].join(" ");
38
+ export function appendCustomSystemPrompt(systemPrompt, customSystemPrompt) {
39
+ const normalizedCustomSystemPrompt = customSystemPrompt === null || customSystemPrompt === void 0 ? void 0 : customSystemPrompt.trim();
40
+ if (!normalizedCustomSystemPrompt) {
41
+ return systemPrompt;
42
+ }
43
+ return `${systemPrompt}\n\n${normalizedCustomSystemPrompt}`;
44
+ }
38
45
  function formatResources(resources) {
39
46
  return resources
40
47
  .map((resource) => `- resourceId: ${resource.resourceId}\n label: ${resource.label}`)
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ import { HumanMessage, SystemMessage } from "langchain";
20
20
  import { createAgentChatModel, callAgent } from "./agent/simpleAgent.js";
21
21
  import { createSequenceDebugCollector } from "./agent/middleware/sequenceDebug.js";
22
22
  import { prepareApiBasedTools as buildApiBasedTools, } from './apiBasedTools.js';
23
- import { buildAgentSystemPrompt, DEFAULT_AGENT_SYSTEM_PROMPT, } from "./agent/systemPrompt.js";
23
+ import { appendCustomSystemPrompt, buildAgentSystemPrompt, DEFAULT_AGENT_SYSTEM_PROMPT, } from "./agent/systemPrompt.js";
24
24
  import { ALWAYS_AVAILABLE_API_TOOL_NAMES } from "./agent/tools/index.js";
25
25
  function isAggregateErrorLike(error) {
26
26
  return typeof error === "object" && error !== null && Array.isArray(error.errors);
@@ -91,8 +91,8 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
91
91
  constructor(options) {
92
92
  super(options, import.meta.url);
93
93
  this.apiBasedTools = {};
94
- this.agentSystemPromptPromise = Promise.resolve(DEFAULT_AGENT_SYSTEM_PROMPT);
95
94
  this.options = options;
95
+ this.agentSystemPromptPromise = Promise.resolve(appendCustomSystemPrompt(DEFAULT_AGENT_SYSTEM_PROMPT, this.options.systemPrompt));
96
96
  this.shouldHaveSingleInstancePerWholeApp = () => false;
97
97
  }
98
98
  modifyResourceConfig(adminforth, resourceConfig) {
@@ -127,7 +127,8 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
127
127
  assertRequiredApiTool(this.apiBasedTools, toolName);
128
128
  }
129
129
  assertRequiredApiTool(this.apiBasedTools, "update_record");
130
- this.agentSystemPromptPromise = buildAgentSystemPrompt(adminforth);
130
+ this.agentSystemPromptPromise = buildAgentSystemPrompt(adminforth)
131
+ .then((systemPrompt) => appendCustomSystemPrompt(systemPrompt, this.options.systemPrompt));
131
132
  }
132
133
  instanceUniqueRepresentation(pluginOptions) {
133
134
  return `single`;
package/index.ts CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  } from './apiBasedTools.js';
17
17
  import type { ApiBasedTool } from './apiBasedTools.js';
18
18
  import {
19
+ appendCustomSystemPrompt,
19
20
  buildAgentSystemPrompt,
20
21
  DEFAULT_AGENT_SYSTEM_PROMPT,
21
22
  } from "./agent/systemPrompt.js";
@@ -67,7 +68,7 @@ function assertRequiredApiTool(
67
68
  export default class AdminForthAgentPlugin extends AdminForthPlugin {
68
69
  options: PluginOptions;
69
70
  apiBasedTools: Record<string, ApiBasedTool> = {};
70
- agentSystemPromptPromise = Promise.resolve(DEFAULT_AGENT_SYSTEM_PROMPT);
71
+ agentSystemPromptPromise: Promise<string>;
71
72
 
72
73
  private async createNewTurn(sessionId: string, prompt: string, response?: string) {
73
74
  const turnId = randomUUID();
@@ -109,6 +110,9 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
109
110
  constructor(options: PluginOptions) {
110
111
  super(options, import.meta.url);
111
112
  this.options = options;
113
+ this.agentSystemPromptPromise = Promise.resolve(
114
+ appendCustomSystemPrompt(DEFAULT_AGENT_SYSTEM_PROMPT, this.options.systemPrompt),
115
+ );
112
116
  this.shouldHaveSingleInstancePerWholeApp = () => false;
113
117
  }
114
118
 
@@ -139,7 +143,8 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
139
143
  assertRequiredApiTool(this.apiBasedTools, toolName);
140
144
  }
141
145
  assertRequiredApiTool(this.apiBasedTools, "update_record");
142
- this.agentSystemPromptPromise = buildAgentSystemPrompt(adminforth);
146
+ this.agentSystemPromptPromise = buildAgentSystemPrompt(adminforth)
147
+ .then((systemPrompt) => appendCustomSystemPrompt(systemPrompt, this.options.systemPrompt));
143
148
  }
144
149
 
145
150
  instanceUniqueRepresentation(pluginOptions: any) : string {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/agent",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
package/types.ts CHANGED
@@ -50,6 +50,11 @@ export interface PluginOptions extends PluginsCommonOptions {
50
50
  */
51
51
  maxTokens?: number;
52
52
 
53
+ /**
54
+ * Optional custom system prompt appended to the built-in agent system prompt.
55
+ */
56
+ systemPrompt?: string;
57
+
53
58
  /**
54
59
  * Response generation level.
55
60
  * Default is low