@botonic/plugin-ai-agents 2.28.0 → 2.30.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.
- package/CHANGELOG.md +26 -0
- package/package.json +7 -5
- package/src/index.d.ts +2 -1
- package/src/index.js +2 -1
- package/src/index.js.map +1 -1
- package/src/lib/agents/base-agent.d.ts +25 -0
- package/src/lib/agents/base-agent.js +39 -0
- package/src/lib/agents/base-agent.js.map +1 -0
- package/src/lib/agents/index.d.ts +2 -0
- package/src/lib/agents/index.js +3 -0
- package/src/lib/agents/index.js.map +1 -0
- package/src/lib/agents/router-agent.d.ts +23 -0
- package/src/lib/agents/router-agent.js +32 -0
- package/src/lib/agents/router-agent.js.map +1 -0
- package/src/lib/agents/specialist-agent.d.ts +33 -0
- package/src/lib/agents/specialist-agent.js +103 -0
- package/src/lib/agents/specialist-agent.js.map +1 -0
- package/src/lib/bot-config-tools.d.ts +7 -0
- package/src/lib/bot-config-tools.js +11 -0
- package/src/lib/bot-config-tools.js.map +1 -0
- package/src/lib/constants.d.ts +16 -6
- package/src/lib/constants.js +16 -8
- package/src/lib/constants.js.map +1 -1
- package/src/lib/debug-logger.d.ts +4 -2
- package/src/lib/debug-logger.js +20 -22
- package/src/lib/debug-logger.js.map +1 -1
- package/src/lib/guardrails/input.d.ts +9 -3
- package/src/lib/guardrails/input.js +100 -24
- package/src/lib/guardrails/input.js.map +1 -1
- package/src/lib/index.d.ts +9 -3
- package/src/lib/index.js +128 -36
- package/src/lib/index.js.map +1 -1
- package/src/lib/llm-config.d.ts +31 -0
- package/src/lib/llm-config.js +111 -0
- package/src/lib/llm-config.js.map +1 -0
- package/src/lib/runners/base-runner.d.ts +32 -0
- package/src/lib/runners/base-runner.js +182 -0
- package/src/lib/runners/base-runner.js.map +1 -0
- package/src/lib/runners/index.d.ts +2 -0
- package/src/lib/runners/index.js +3 -0
- package/src/lib/runners/index.js.map +1 -0
- package/src/lib/runners/router-runner.d.ts +8 -0
- package/src/lib/runners/router-runner.js +40 -0
- package/src/lib/runners/router-runner.js.map +1 -0
- package/src/lib/runners/specialist-runner.d.ts +4 -0
- package/src/lib/runners/specialist-runner.js +4 -0
- package/src/lib/runners/specialist-runner.js.map +1 -0
- package/src/lib/services/hubtype-api-client.d.ts +13 -0
- package/src/lib/{hubtype-api-client.js → services/hubtype-api-client.js} +32 -51
- package/src/lib/services/hubtype-api-client.js.map +1 -0
- package/src/lib/services/types.d.ts +71 -0
- package/src/lib/services/types.js +10 -0
- package/src/lib/services/types.js.map +1 -0
- package/src/lib/structured-output/bot-executor.d.ts +15 -0
- package/src/lib/structured-output/bot-executor.js +15 -0
- package/src/lib/structured-output/bot-executor.js.map +1 -0
- package/src/lib/structured-output/carousel.d.ts +8 -78
- package/src/lib/structured-output/carousel.js +2 -1
- package/src/lib/structured-output/carousel.js.map +1 -1
- package/src/lib/structured-output/exit.d.ts +5 -7
- package/src/lib/structured-output/exit.js +2 -1
- package/src/lib/structured-output/exit.js.map +1 -1
- package/src/lib/structured-output/flow-builder-content.d.ts +9 -0
- package/src/lib/structured-output/flow-builder-content.js +9 -0
- package/src/lib/structured-output/flow-builder-content.js.map +1 -0
- package/src/lib/structured-output/index.d.ts +103 -203
- package/src/lib/structured-output/index.js +30 -3
- package/src/lib/structured-output/index.js.map +1 -1
- package/src/lib/structured-output/text-with-buttons.d.ts +11 -41
- package/src/lib/structured-output/text-with-buttons.js +8 -1
- package/src/lib/structured-output/text-with-buttons.js.map +1 -1
- package/src/lib/structured-output/text.d.ts +6 -18
- package/src/lib/structured-output/text.js +2 -1
- package/src/lib/structured-output/text.js.map +1 -1
- package/src/lib/test-llm-config.d.ts +10 -0
- package/src/lib/test-llm-config.js +18 -0
- package/src/lib/test-llm-config.js.map +1 -0
- package/src/lib/tools/index.d.ts +1 -1
- package/src/lib/tools/index.js +1 -1
- package/src/lib/tools/index.js.map +1 -1
- package/src/lib/tools/retrieve-knowledge.d.ts +3 -6
- package/src/lib/tools/retrieve-knowledge.js +4 -4
- package/src/lib/tools/retrieve-knowledge.js.map +1 -1
- package/src/lib/types.d.ts +15 -9
- package/src/lib/agent-builder.d.ts +0 -30
- package/src/lib/agent-builder.js +0 -111
- package/src/lib/agent-builder.js.map +0 -1
- package/src/lib/hubtype-api-client.d.ts +0 -22
- package/src/lib/hubtype-api-client.js.map +0 -1
- package/src/lib/openai.d.ts +0 -1
- package/src/lib/openai.js +0 -21
- package/src/lib/openai.js.map +0 -1
- package/src/lib/runner.d.ts +0 -13
- package/src/lib/runner.js +0 -96
- package/src/lib/runner.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## 2.30.0 (2026-06-11)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- update botonic-basic-template ([#932](https://github.com/metis-ai/hubtype-product/pull/932))
|
|
6
|
+
- update plugins to last botonicV0 changes #BLT-2370 ([#920](https://github.com/metis-ai/hubtype-product/pull/920))
|
|
7
|
+
|
|
8
|
+
### ❤️ Thank You
|
|
9
|
+
|
|
10
|
+
- Oriol Raventós @Iru89
|
|
11
|
+
|
|
12
|
+
## 2.29.0 (2026-05-12)
|
|
13
|
+
|
|
14
|
+
### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- **botonic:** v2 refinements - update skills, serve-bot defaults, staging bot warning ([#888](https://github.com/metis-ai/hubtype-product/pull/888))
|
|
17
|
+
|
|
18
|
+
### 🩹 Fixes
|
|
19
|
+
|
|
20
|
+
- db_id instead of message_id ([#886](https://github.com/metis-ai/hubtype-product/pull/886))
|
|
21
|
+
|
|
22
|
+
### ❤️ Thank You
|
|
23
|
+
|
|
24
|
+
- David Hidalgo @Davidhidalgo
|
|
25
|
+
- Marc Rabat @vanbasten17
|
|
26
|
+
|
|
1
27
|
## 2.28.0 (2026-05-06)
|
|
2
28
|
|
|
3
29
|
This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/plugin-ai-agents",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.30.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./src/index.d.ts",
|
|
6
6
|
"module": "./src/index.js",
|
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@botonic/core": "2.
|
|
15
|
-
"@botonic/shared": "2.
|
|
16
|
-
"@openai/agents": "^0.
|
|
14
|
+
"@botonic/core": "2.30.0",
|
|
15
|
+
"@botonic/shared": "2.30.0",
|
|
16
|
+
"@openai/agents": "^0.10.1",
|
|
17
|
+
"@openai/agents-core": "^0.11.6",
|
|
17
18
|
"openai": "^6.0.0",
|
|
18
19
|
"tslib": "^2.3.0",
|
|
19
|
-
"
|
|
20
|
+
"uuid": "^11.1.0",
|
|
21
|
+
"zod": "^4.4.3"
|
|
20
22
|
},
|
|
21
23
|
"references": [
|
|
22
24
|
{
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/botonic/plugin-ai-agents/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/botonic/plugin-ai-agents/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA;AACrB,cAAc,wBAAwB,CAAA;AACtC,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AgentOutputType, InputGuardrail, Model, ModelSettings } from '@openai/agents';
|
|
2
|
+
import type { GuardrailTrackingContext } from '../guardrails/input';
|
|
3
|
+
import type { LLMConfig } from '../llm-config';
|
|
4
|
+
import { type OutputSchema } from '../structured-output';
|
|
5
|
+
import type { GuardrailRule } from '../types';
|
|
6
|
+
export interface BaseAgentOptions {
|
|
7
|
+
name: string;
|
|
8
|
+
instructions: string;
|
|
9
|
+
llmConfig: LLMConfig;
|
|
10
|
+
inputGuardrailRules: GuardrailRule[];
|
|
11
|
+
guardrailTrackingContext: GuardrailTrackingContext;
|
|
12
|
+
}
|
|
13
|
+
export declare abstract class BaseAgent {
|
|
14
|
+
protected name: string;
|
|
15
|
+
protected instructions: string;
|
|
16
|
+
protected llmConfig: LLMConfig;
|
|
17
|
+
private inputGuardrailRules;
|
|
18
|
+
private guardrailTrackingContext;
|
|
19
|
+
constructor(options: BaseAgentOptions);
|
|
20
|
+
protected getAgentModelSettings(): ModelSettings;
|
|
21
|
+
protected getInputGuardrails(): Promise<InputGuardrail[]>;
|
|
22
|
+
protected getOutputType(): AgentOutputType<typeof OutputSchema>;
|
|
23
|
+
protected addOutputInstructions(instructions: string): string;
|
|
24
|
+
protected getModel(): Promise<Model>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { createInputGuardrails } from '../guardrails';
|
|
3
|
+
import { getOutputInstructions, getOutputSchema, } from '../structured-output';
|
|
4
|
+
export class BaseAgent {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.name = options.name;
|
|
7
|
+
this.instructions = options.instructions;
|
|
8
|
+
this.llmConfig = options.llmConfig;
|
|
9
|
+
this.inputGuardrailRules = options.inputGuardrailRules;
|
|
10
|
+
this.guardrailTrackingContext = options.guardrailTrackingContext;
|
|
11
|
+
}
|
|
12
|
+
getAgentModelSettings() {
|
|
13
|
+
const modelSettings = Object.assign({}, this.llmConfig.modelSettings);
|
|
14
|
+
if (this.llmConfig.modelSettings.reasoning) {
|
|
15
|
+
modelSettings.reasoning = Object.assign({}, this.llmConfig.modelSettings.reasoning);
|
|
16
|
+
}
|
|
17
|
+
if (this.llmConfig.modelSettings.text) {
|
|
18
|
+
modelSettings.text = Object.assign({}, this.llmConfig.modelSettings.text);
|
|
19
|
+
}
|
|
20
|
+
return modelSettings;
|
|
21
|
+
}
|
|
22
|
+
getInputGuardrails() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return createInputGuardrails(this.inputGuardrailRules, this.llmConfig, this.guardrailTrackingContext);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
getOutputType() {
|
|
28
|
+
return getOutputSchema();
|
|
29
|
+
}
|
|
30
|
+
addOutputInstructions(instructions) {
|
|
31
|
+
return `${instructions}\n\n${getOutputInstructions()}`;
|
|
32
|
+
}
|
|
33
|
+
getModel() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
return yield this.llmConfig.getModel();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=base-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-agent.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/plugin-ai-agents/src/lib/agents/base-agent.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAGrD,OAAO,EACL,qBAAqB,EACrB,eAAe,GAEhB,MAAM,sBAAsB,CAAA;AAW7B,MAAM,OAAgB,SAAS;IAO7B,YAAY,OAAyB;QACnC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACxB,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;QACxC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;QAClC,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAA;QACtD,IAAI,CAAC,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAA;IAClE,CAAC;IAES,qBAAqB;QAC7B,MAAM,aAAa,qBAAuB,IAAI,CAAC,SAAS,CAAC,aAAa,CAAE,CAAA;QACxE,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;YAC3C,aAAa,CAAC,SAAS,qBAAQ,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,SAAS,CAAE,CAAA;QACzE,CAAC;QACD,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;YACtC,aAAa,CAAC,IAAI,qBAAQ,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAE,CAAA;QAC/D,CAAC;QACD,OAAO,aAAa,CAAA;IACtB,CAAC;IAEe,kBAAkB;;YAChC,OAAO,qBAAqB,CAC1B,IAAI,CAAC,mBAAmB,EACxB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,wBAAwB,CAC9B,CAAA;QACH,CAAC;KAAA;IAES,aAAa;QACrB,OAAO,eAAe,EAAE,CAAA;IAC1B,CAAC;IAES,qBAAqB,CAAC,YAAoB;QAClD,OAAO,GAAG,YAAY,OAAO,qBAAqB,EAAE,EAAE,CAAA;IACxD,CAAC;IAEe,QAAQ;;YACtB,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAA;QACxC,CAAC;KAAA;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/plugin-ai-agents/src/lib/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ResolvedPlugins, UserExtraData } from '@botonic/core';
|
|
2
|
+
import { type AgentOutputType, type Handoff } from '@openai/agents';
|
|
3
|
+
import type { GuardrailTrackingContext } from '../guardrails/input';
|
|
4
|
+
import type { LLMConfig } from '../llm-config';
|
|
5
|
+
import type { OutputSchema } from '../structured-output';
|
|
6
|
+
import type { AIAgent, AiAgentContext, GuardrailRule } from '../types';
|
|
7
|
+
import { BaseAgent } from './base-agent';
|
|
8
|
+
interface RouterAgentOptions<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData> {
|
|
9
|
+
name: string;
|
|
10
|
+
instructions: string;
|
|
11
|
+
llmConfig: LLMConfig;
|
|
12
|
+
handoffs: Handoff<AiAgentContext<TPlugins, TExtraData>, AgentOutputType<typeof OutputSchema>>[];
|
|
13
|
+
inputGuardrailRules: GuardrailRule[];
|
|
14
|
+
guardrailTrackingContext: GuardrailTrackingContext;
|
|
15
|
+
}
|
|
16
|
+
export declare class RouterAgent<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData> extends BaseAgent {
|
|
17
|
+
private handoffs;
|
|
18
|
+
private agent;
|
|
19
|
+
private constructor();
|
|
20
|
+
static create<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData>(options: RouterAgentOptions<TPlugins, TExtraData>): Promise<RouterAgent<TPlugins, TExtraData>>;
|
|
21
|
+
getAgent(): AIAgent<TPlugins, TExtraData>;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { Agent } from '@openai/agents';
|
|
3
|
+
import { RECOMMENDED_PROMPT_PREFIX } from '@openai/agents-core/extensions';
|
|
4
|
+
import { BaseAgent } from './base-agent';
|
|
5
|
+
export class RouterAgent extends BaseAgent {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super(options);
|
|
8
|
+
this.handoffs = options.handoffs;
|
|
9
|
+
}
|
|
10
|
+
static create(options) {
|
|
11
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
const routerAgent = new RouterAgent(options);
|
|
13
|
+
const inputGuardrails = yield routerAgent.getInputGuardrails();
|
|
14
|
+
const model = yield routerAgent.getModel();
|
|
15
|
+
const agent = Agent.create({
|
|
16
|
+
name: routerAgent.name,
|
|
17
|
+
model,
|
|
18
|
+
modelSettings: routerAgent.getAgentModelSettings(),
|
|
19
|
+
instructions: routerAgent.addOutputInstructions(`${RECOMMENDED_PROMPT_PREFIX}${routerAgent.instructions}`),
|
|
20
|
+
handoffs: routerAgent.handoffs,
|
|
21
|
+
outputType: routerAgent.getOutputType(),
|
|
22
|
+
inputGuardrails,
|
|
23
|
+
});
|
|
24
|
+
routerAgent.agent = agent;
|
|
25
|
+
return routerAgent;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
getAgent() {
|
|
29
|
+
return this.agent;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=router-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-agent.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/plugin-ai-agents/src/lib/agents/router-agent.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAsC,MAAM,gBAAgB,CAAA;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAM1E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAiBxC,MAAM,OAAO,WAGX,SAAQ,SAAS;IAOjB,YAAoB,OAAiD;QACnE,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;IAClC,CAAC;IAED,MAAM,CAAO,MAAM,CAIjB,OAAiD;;YAEjD,MAAM,WAAW,GAAG,IAAI,WAAW,CAAuB,OAAO,CAAC,CAAA;YAClE,MAAM,eAAe,GAAG,MAAM,WAAW,CAAC,kBAAkB,EAAE,CAAA;YAC9D,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAA;YAE1C,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;gBACzB,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,KAAK;gBACL,aAAa,EAAE,WAAW,CAAC,qBAAqB,EAAE;gBAClD,YAAY,EAAE,WAAW,CAAC,qBAAqB,CAC7C,GAAG,yBAAyB,GAAG,WAAW,CAAC,YAAY,EAAE,CAC1D;gBACD,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,UAAU,EAAE,WAAW,CAAC,aAAa,EAAE;gBACvC,eAAe;aAChB,CAAkC,CAAA;YAEnC,WAAW,CAAC,KAAK,GAAG,KAAK,CAAA;YACzB,OAAO,WAAW,CAAA;QACpB,CAAC;KAAA;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CampaignV2, ResolvedPlugins, UserExtraData } from '@botonic/core';
|
|
2
|
+
import type { DebugLogger } from '../debug-logger';
|
|
3
|
+
import type { GuardrailTrackingContext } from '../guardrails/input';
|
|
4
|
+
import type { LLMConfig } from '../llm-config';
|
|
5
|
+
import type { AIAgent, ContactInfo, GuardrailRule, Tool } from '../types';
|
|
6
|
+
import { BaseAgent } from './base-agent';
|
|
7
|
+
interface SpecialistAgentOptions<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData> {
|
|
8
|
+
name: string;
|
|
9
|
+
instructions: string;
|
|
10
|
+
tools: Tool<TPlugins, TExtraData>[];
|
|
11
|
+
campaignsContext?: CampaignV2[];
|
|
12
|
+
contactInfo: ContactInfo[];
|
|
13
|
+
inputGuardrailRules: GuardrailRule[];
|
|
14
|
+
sourceIds: string[];
|
|
15
|
+
llmConfig: LLMConfig;
|
|
16
|
+
logger: DebugLogger;
|
|
17
|
+
guardrailTrackingContext: GuardrailTrackingContext;
|
|
18
|
+
}
|
|
19
|
+
export declare class SpecialistAgent<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData> extends BaseAgent {
|
|
20
|
+
private tools;
|
|
21
|
+
private logger;
|
|
22
|
+
private agent;
|
|
23
|
+
private constructor();
|
|
24
|
+
static create<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData>(options: SpecialistAgentOptions<TPlugins, TExtraData>): Promise<SpecialistAgent<TPlugins, TExtraData>>;
|
|
25
|
+
getAgent(): AIAgent<TPlugins, TExtraData>;
|
|
26
|
+
private getSpecialistModelSettings;
|
|
27
|
+
private addExtraInstructions;
|
|
28
|
+
private getContactInfoInstructions;
|
|
29
|
+
private getMetadataInstructions;
|
|
30
|
+
private getCampaignInstructions;
|
|
31
|
+
private addHubtypeTools;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { Agent } from '@openai/agents';
|
|
3
|
+
import { createRetrieveKnowledge, mandatoryTools, RETRIEVE_KNOWLEDGE_TOOL_NAME, } from '../tools';
|
|
4
|
+
import { BaseAgent } from './base-agent';
|
|
5
|
+
export class SpecialistAgent extends BaseAgent {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super({
|
|
8
|
+
name: options.name,
|
|
9
|
+
instructions: options.instructions,
|
|
10
|
+
llmConfig: options.llmConfig,
|
|
11
|
+
inputGuardrailRules: options.inputGuardrailRules,
|
|
12
|
+
guardrailTrackingContext: options.guardrailTrackingContext,
|
|
13
|
+
});
|
|
14
|
+
this.instructions = this.addExtraInstructions(options.instructions, options.contactInfo, options.campaignsContext);
|
|
15
|
+
this.tools = this.addHubtypeTools(options.tools, options.sourceIds);
|
|
16
|
+
this.logger = options.logger;
|
|
17
|
+
}
|
|
18
|
+
static create(options) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const specialistAgent = new SpecialistAgent(options);
|
|
21
|
+
const model = specialistAgent.llmConfig.modelName;
|
|
22
|
+
const resolvedModel = yield specialistAgent.getModel();
|
|
23
|
+
const hasRetrieveKnowledge = specialistAgent.tools.some(tool => tool.name === RETRIEVE_KNOWLEDGE_TOOL_NAME);
|
|
24
|
+
const modelSettings = specialistAgent.getSpecialistModelSettings(hasRetrieveKnowledge);
|
|
25
|
+
const inputGuardrails = yield specialistAgent.getInputGuardrails();
|
|
26
|
+
specialistAgent.logger.logModelSettings({
|
|
27
|
+
provider: specialistAgent.llmConfig.getProviderName(),
|
|
28
|
+
model,
|
|
29
|
+
reasoning: modelSettings.reasoning,
|
|
30
|
+
text: modelSettings.text,
|
|
31
|
+
toolChoice: modelSettings.toolChoice,
|
|
32
|
+
hasRetrieveKnowledge,
|
|
33
|
+
});
|
|
34
|
+
const agent = new Agent({
|
|
35
|
+
name: specialistAgent.name,
|
|
36
|
+
model: resolvedModel,
|
|
37
|
+
modelSettings,
|
|
38
|
+
instructions: specialistAgent.instructions,
|
|
39
|
+
tools: specialistAgent.tools,
|
|
40
|
+
outputType: specialistAgent.getOutputType(),
|
|
41
|
+
inputGuardrails,
|
|
42
|
+
outputGuardrails: [],
|
|
43
|
+
});
|
|
44
|
+
specialistAgent.agent = agent;
|
|
45
|
+
return specialistAgent;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
getAgent() {
|
|
49
|
+
return this.agent;
|
|
50
|
+
}
|
|
51
|
+
getSpecialistModelSettings(hasRetrieveKnowledge) {
|
|
52
|
+
const modelSettings = this.getAgentModelSettings();
|
|
53
|
+
if (hasRetrieveKnowledge) {
|
|
54
|
+
modelSettings.toolChoice = RETRIEVE_KNOWLEDGE_TOOL_NAME;
|
|
55
|
+
}
|
|
56
|
+
return modelSettings;
|
|
57
|
+
}
|
|
58
|
+
addExtraInstructions(initialInstructions, contactInfo, campaignsContext) {
|
|
59
|
+
const instructions = `<instructions>\n${initialInstructions.trim()}\n</instructions>`;
|
|
60
|
+
const metadataInstructions = this.getMetadataInstructions();
|
|
61
|
+
const contactInfoInstructions = this.getContactInfoInstructions(contactInfo);
|
|
62
|
+
const campaignInstructions = this.getCampaignInstructions(campaignsContext);
|
|
63
|
+
return this.addOutputInstructions(`${instructions}\n\n${metadataInstructions}\n\n${contactInfoInstructions}\n\n${campaignInstructions}`);
|
|
64
|
+
}
|
|
65
|
+
getContactInfoInstructions(contactInfo) {
|
|
66
|
+
const structuredContactInfo = contactInfo
|
|
67
|
+
.map(info => ` <contact_info>
|
|
68
|
+
<name>${info.name}</name>
|
|
69
|
+
<value>${info.value}</value>
|
|
70
|
+
<type>${info.type}</type>
|
|
71
|
+
${info.description
|
|
72
|
+
? `<description>${info.description}</description>`
|
|
73
|
+
: ''}
|
|
74
|
+
</contact_info>`)
|
|
75
|
+
.join('\n');
|
|
76
|
+
return `<contact_info_fields>\n${structuredContactInfo}</contact_info_fields>`;
|
|
77
|
+
}
|
|
78
|
+
getMetadataInstructions() {
|
|
79
|
+
const metadata = `Current Date: ${new Date().toISOString()}`;
|
|
80
|
+
return `<metadata>\n${metadata}\n</metadata>`;
|
|
81
|
+
}
|
|
82
|
+
getCampaignInstructions(campaignsContext) {
|
|
83
|
+
if (!campaignsContext || campaignsContext.length === 0) {
|
|
84
|
+
return '';
|
|
85
|
+
}
|
|
86
|
+
const campaignsWithContext = campaignsContext.filter(campaign => campaign.agent_context);
|
|
87
|
+
if (campaignsWithContext.length === 0) {
|
|
88
|
+
return '';
|
|
89
|
+
}
|
|
90
|
+
return campaignsWithContext
|
|
91
|
+
.map((campaign, index) => `<campaign_context_${index + 1}>\n${campaign.agent_context}\n</campaign_context_${index + 1}>`)
|
|
92
|
+
.join('\n');
|
|
93
|
+
}
|
|
94
|
+
addHubtypeTools(tools, sourceIds) {
|
|
95
|
+
const hubtypeTools = [
|
|
96
|
+
...mandatoryTools,
|
|
97
|
+
...(sourceIds.length > 0 ? [createRetrieveKnowledge(sourceIds)] : []),
|
|
98
|
+
...tools,
|
|
99
|
+
];
|
|
100
|
+
return hubtypeTools;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=specialist-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specialist-agent.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/plugin-ai-agents/src/lib/agents/specialist-agent.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAA4C,MAAM,gBAAgB,CAAA;AAMhF,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,4BAA4B,GAC7B,MAAM,UAAU,CAAA;AAQjB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAkBxC,MAAM,OAAO,eAGX,SAAQ,SAAS;IAKjB,YAAoB,OAAqD;QACvE,KAAK,CAAC;YACJ,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;YAChD,wBAAwB,EAAE,OAAO,CAAC,wBAAwB;SAC3D,CAAC,CAAA;QACF,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,oBAAoB,CAC3C,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,gBAAgB,CACzB,CAAA;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;QACnE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAC9B,CAAC;IAED,MAAM,CAAO,MAAM,CAIjB,OAAqD;;YAErD,MAAM,eAAe,GAAG,IAAI,eAAe,CAAuB,OAAO,CAAC,CAAA;YAC1E,MAAM,KAAK,GAAG,eAAe,CAAC,SAAS,CAAC,SAAS,CAAA;YACjD,MAAM,aAAa,GAAG,MAAM,eAAe,CAAC,QAAQ,EAAE,CAAA;YACtD,MAAM,oBAAoB,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CACrD,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,4BAA4B,CACnD,CAAA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qB,KAAK,GAAG,CAAC,MAAM,QAAQ,CAAC,aAAa,wBAAwB,KAAK,GAAG,CAAC,GAAG,CACjG;aACA,IAAI,CAAC,IAAI,CAAC,CAAA;IACf,CAAC;IAEO,eAAe,CACrB,KAAmC,EACnC,SAAmB;QAEnB,MAAM,YAAY,GAAG;YACnB,GAAG,cAAc;YACjB,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACrE,GAAG,KAAK;SACuB,CAAA;QACjC,OAAO,YAAY,CAAA;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export function getToolsForBotConfig(customTools) {
|
|
3
|
+
return customTools.map(tool => ({
|
|
4
|
+
name: tool.name,
|
|
5
|
+
description: tool.description,
|
|
6
|
+
schema: z.toJSONSchema(tool.schema, {
|
|
7
|
+
target: 'draft-07',
|
|
8
|
+
}),
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=bot-config-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot-config-tools.js","sourceRoot":"","sources":["../../../../../../libs/botonic/plugin-ai-agents/src/lib/bot-config-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAUvB,MAAM,UAAU,oBAAoB,CAClC,WAAyB;IAEzB,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE;YAClC,MAAM,EAAE,UAAU;SACnB,CAA6B;KAC/B,CAAC,CAAC,CAAA;AACL,CAAC"}
|
package/src/lib/constants.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
export declare const LLM_PROVIDERS: {
|
|
2
|
+
readonly AZURE: "azure";
|
|
3
|
+
readonly OPENAI: "openai";
|
|
4
|
+
readonly LITELLM: "litellm";
|
|
5
|
+
};
|
|
6
|
+
export type LLMProviderType = (typeof LLM_PROVIDERS)[keyof typeof LLM_PROVIDERS];
|
|
7
|
+
export declare const LITELLM_TAG_KEYS: {
|
|
8
|
+
readonly BOT_ID: "bot_id";
|
|
9
|
+
readonly ORG_ID: "org_id";
|
|
10
|
+
readonly SEPARATOR: ",";
|
|
11
|
+
};
|
|
12
|
+
export declare const LLM_PROVIDER: LLMProviderType;
|
|
13
|
+
export declare const isProd: boolean;
|
|
14
|
+
export declare const MAX_MEMORY_LENGTH = 25;
|
|
15
|
+
export declare const DEFAULT_TIMEOUT_16_SECONDS = 16000;
|
|
16
|
+
export declare const DEFAULT_MAX_RETRIES = 2;
|
|
1
17
|
export declare const OPENAI_API_KEY: string | undefined;
|
|
2
18
|
export declare const OPENAI_MODEL: string;
|
|
3
|
-
export declare const OPENAI_PROVIDER: 'openai' | 'azure';
|
|
4
|
-
export declare const AZURE_OPENAI_API_KEY: string | undefined;
|
|
5
|
-
export declare const AZURE_OPENAI_API_BASE: string | undefined;
|
|
6
|
-
export declare const AZURE_OPENAI_API_DEPLOYMENT_NAME: string;
|
|
7
|
-
export declare const AZURE_OPENAI_API_VERSION: string;
|
|
8
|
-
export declare const MAX_MEMORY_LENGTH = 25;
|
package/src/lib/constants.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
var _a, _b
|
|
1
|
+
var _a, _b;
|
|
2
|
+
export const LLM_PROVIDERS = {
|
|
3
|
+
AZURE: 'azure',
|
|
4
|
+
OPENAI: 'openai',
|
|
5
|
+
LITELLM: 'litellm',
|
|
6
|
+
};
|
|
7
|
+
export const LITELLM_TAG_KEYS = {
|
|
8
|
+
BOT_ID: 'bot_id',
|
|
9
|
+
ORG_ID: 'org_id',
|
|
10
|
+
SEPARATOR: ',',
|
|
11
|
+
};
|
|
12
|
+
export const LLM_PROVIDER = process.env['LLM_PROVIDER'] || LLM_PROVIDERS.AZURE;
|
|
13
|
+
export const isProd = process.env['NODE_ENV'] === 'production';
|
|
14
|
+
export const MAX_MEMORY_LENGTH = 25;
|
|
15
|
+
export const DEFAULT_TIMEOUT_16_SECONDS = 16000;
|
|
16
|
+
export const DEFAULT_MAX_RETRIES = 2;
|
|
2
17
|
// OpenAI Provider Configuration
|
|
3
18
|
export const OPENAI_API_KEY = (_a = import.meta.env) === null || _a === void 0 ? void 0 : _a['VITE_OPENAI_API_KEY']; // pragma: allowlist secret
|
|
4
19
|
export const OPENAI_MODEL = ((_b = import.meta.env) === null || _b === void 0 ? void 0 : _b['VITE_OPENAI_MODEL']) || 'gpt-4.1-mini';
|
|
5
|
-
export const OPENAI_PROVIDER = ((_c = import.meta.env) === null || _c === void 0 ? void 0 : _c['VITE_OPENAI_PROVIDER']) || 'azure';
|
|
6
|
-
// Azure OpenAI Configuration
|
|
7
|
-
export const AZURE_OPENAI_API_KEY = (_d = import.meta.env) === null || _d === void 0 ? void 0 : _d['VITE_AZURE_OPENAI_API_KEY']; // pragma: allowlist secret
|
|
8
|
-
export const AZURE_OPENAI_API_BASE = (_e = import.meta.env) === null || _e === void 0 ? void 0 : _e['VITE_AZURE_OPENAI_API_BASE'];
|
|
9
|
-
export const AZURE_OPENAI_API_DEPLOYMENT_NAME = ((_f = import.meta.env) === null || _f === void 0 ? void 0 : _f['VITE_AZURE_OPENAI_API_DEPLOYMENT_NAME']) || 'gpt-41-mini_p1';
|
|
10
|
-
export const AZURE_OPENAI_API_VERSION = ((_g = import.meta.env) === null || _g === void 0 ? void 0 : _g['VITE_AZURE_OPENAI_API_VERSION']) || '2025-01-01-preview';
|
|
11
|
-
export const MAX_MEMORY_LENGTH = 25;
|
|
12
20
|
//# sourceMappingURL=constants.js.map
|
package/src/lib/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../libs/botonic/plugin-ai-agents/src/lib/constants.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../libs/botonic/plugin-ai-agents/src/lib/constants.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACV,CAAA;AAIV,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,GAAG;CACN,CAAA;AAEV,MAAM,CAAC,MAAM,YAAY,GACtB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAqB,IAAI,aAAa,CAAC,KAAK,CAAA;AAEzE,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,YAAY,CAAA;AAE9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AACnC,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAA;AAC/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAA;AAEpC,gCAAgC;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAA,MAAM,CAAC,IAAI,CAAC,GAAG,0CAAG,qBAAqB,CAAC,CAAA,CAAC,2BAA2B;AAClG,MAAM,CAAC,MAAM,YAAY,GACvB,CAAA,MAAA,MAAM,CAAC,IAAI,CAAC,GAAG,0CAAG,mBAAmB,CAAC,KAAI,cAAc,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AiAgentArgs } from '@botonic/shared';
|
|
1
|
+
import { AiAgentArgs, ToolExecution } from '@botonic/shared';
|
|
2
|
+
import type { ModelSettings } from '@openai/agents';
|
|
2
3
|
import { AgenticInputMessage, MemoryOptions, RunResult } from './types';
|
|
3
4
|
export interface DebugLoggerConfig {
|
|
4
5
|
messageHistoryApiVersion: string;
|
|
@@ -23,9 +24,10 @@ export interface DebugLogger {
|
|
|
23
24
|
logInitialConfig(config: DebugLoggerConfig): void;
|
|
24
25
|
logAgentDebugInfo(aiAgentArgs: AiAgentArgs, toolNames: string[], messages: AgenticInputMessage[]): void;
|
|
25
26
|
logModelSettings(settings: ModelSettingsInfo): void;
|
|
26
|
-
logRunnerStart(): void;
|
|
27
|
+
logRunnerStart(model: string, modelSettings: ModelSettings): void;
|
|
27
28
|
logRunResult(runResult: RunResult, startTime: number): void;
|
|
28
29
|
logGuardrailTriggered(): void;
|
|
29
30
|
logRunnerError(startTime: number, error: unknown): void;
|
|
31
|
+
logToolExecution(toolExecution: ToolExecution): void;
|
|
30
32
|
}
|
|
31
33
|
export declare function createDebugLogger(enableDebug: boolean): DebugLogger;
|
package/src/lib/debug-logger.js
CHANGED
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
import { AZURE_OPENAI_API_BASE, AZURE_OPENAI_API_DEPLOYMENT_NAME, MAX_MEMORY_LENGTH, OPENAI_MODEL, OPENAI_PROVIDER, } from './constants';
|
|
2
1
|
const PREFIX = '[BotonicPluginAiAgents]';
|
|
3
2
|
class EnabledDebugLogger {
|
|
4
|
-
getModelInfo() {
|
|
5
|
-
const model = OPENAI_PROVIDER === 'azure'
|
|
6
|
-
? AZURE_OPENAI_API_DEPLOYMENT_NAME
|
|
7
|
-
: OPENAI_MODEL;
|
|
8
|
-
const apiBase = OPENAI_PROVIDER === 'azure' && AZURE_OPENAI_API_BASE
|
|
9
|
-
? AZURE_OPENAI_API_BASE
|
|
10
|
-
: 'OpenAI API';
|
|
11
|
-
return { model, apiBase };
|
|
12
|
-
}
|
|
13
3
|
logInitialConfig(config) {
|
|
14
|
-
var _a, _b, _c, _d;
|
|
15
|
-
const { model, apiBase } = this.getModelInfo();
|
|
16
4
|
console.log(`${PREFIX} === Plugin Initialization ===`);
|
|
17
|
-
console.log(`${PREFIX} Provider: ${OPENAI_PROVIDER}`);
|
|
18
|
-
console.log(`${PREFIX} Model/Deployment: ${model}`);
|
|
19
|
-
console.log(`${PREFIX} API Base: ${apiBase}`);
|
|
20
5
|
console.log(`${PREFIX} Message History API Version: ${config.messageHistoryApiVersion}`);
|
|
21
6
|
console.log(`${PREFIX} Max Retries: ${config.maxRetries}`);
|
|
22
7
|
console.log(`${PREFIX} Timeout: ${config.timeout}ms`);
|
|
23
8
|
console.log(`${PREFIX} Custom Tools Registered: ${config.customToolNames.join(', ') || 'none'}`);
|
|
24
9
|
console.log(`${PREFIX} Memory Options:`, {
|
|
25
|
-
maxMessages:
|
|
26
|
-
includeToolCalls:
|
|
27
|
-
maxFullToolResults:
|
|
28
|
-
debugMode:
|
|
10
|
+
maxMessages: config.memory.maxMessages,
|
|
11
|
+
includeToolCalls: config.memory.includeToolCalls,
|
|
12
|
+
maxFullToolResults: config.memory.maxFullToolResults,
|
|
13
|
+
debugMode: config.memory.debugMode,
|
|
29
14
|
});
|
|
30
15
|
console.log(`${PREFIX} === End Plugin Initialization ===`);
|
|
31
16
|
}
|
|
@@ -34,7 +19,7 @@ class EnabledDebugLogger {
|
|
|
34
19
|
console.log(`${PREFIX} === AI Agent Debug Info ===`);
|
|
35
20
|
console.log(`${PREFIX} Agent Name: ${aiAgentArgs.name}`);
|
|
36
21
|
console.log(`${PREFIX} Active Tools: ${JSON.stringify(toolNames)}`);
|
|
37
|
-
console.log(`${PREFIX} Source IDs: ${JSON.stringify(aiAgentArgs.sourceIds || [])}`);
|
|
22
|
+
console.log(`${PREFIX} Source IDs: ${JSON.stringify('sourceIds' in aiAgentArgs ? aiAgentArgs.sourceIds || [] : [])}`);
|
|
38
23
|
console.log(`${PREFIX} Message History Count: ${messages.length}`);
|
|
39
24
|
console.log(`${PREFIX} Input Guardrail Rules: ${((_a = aiAgentArgs.inputGuardrailRules) === null || _a === void 0 ? void 0 : _a.length) || 0}`);
|
|
40
25
|
console.log(`${PREFIX} Instructions:`);
|
|
@@ -55,8 +40,10 @@ class EnabledDebugLogger {
|
|
|
55
40
|
}
|
|
56
41
|
console.log(`${PREFIX} === End Model Settings ===`);
|
|
57
42
|
}
|
|
58
|
-
logRunnerStart() {
|
|
43
|
+
logRunnerStart(model, modelSettings) {
|
|
59
44
|
console.log(`${PREFIX} === Runner Execution Start ===`);
|
|
45
|
+
console.log(`${PREFIX} Model: ${model}`);
|
|
46
|
+
console.log(`${PREFIX} Model Settings: ${JSON.stringify(modelSettings)}`);
|
|
60
47
|
}
|
|
61
48
|
logRunResult(runResult, startTime) {
|
|
62
49
|
const elapsedMs = Date.now() - startTime;
|
|
@@ -82,6 +69,13 @@ class EnabledDebugLogger {
|
|
|
82
69
|
console.log(`${PREFIX} Runner execution failed after ${elapsedMs}ms`);
|
|
83
70
|
console.log(`${PREFIX} Error:`, error);
|
|
84
71
|
}
|
|
72
|
+
logToolExecution(toolExecution) {
|
|
73
|
+
console.log(`${PREFIX} Tool Execution: ${toolExecution.toolName}`);
|
|
74
|
+
console.log(`${PREFIX} Tool Arguments: ${JSON.stringify(toolExecution.toolArguments)}`);
|
|
75
|
+
console.log(`${PREFIX} Tool Results: ${toolExecution.toolResults}`);
|
|
76
|
+
console.log(`${PREFIX} Knowledgebase Sources IDs: ${JSON.stringify(toolExecution.knowledgebaseSourcesIds)}`);
|
|
77
|
+
console.log(`${PREFIX} Knowledgebase Chunks IDs: ${JSON.stringify(toolExecution.knowledgebaseChunksIds)}`);
|
|
78
|
+
}
|
|
85
79
|
}
|
|
86
80
|
class DisabledDebugLogger {
|
|
87
81
|
logInitialConfig() {
|
|
@@ -93,7 +87,8 @@ class DisabledDebugLogger {
|
|
|
93
87
|
logModelSettings() {
|
|
94
88
|
return;
|
|
95
89
|
}
|
|
96
|
-
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
91
|
+
logRunnerStart(model, modelSettings) {
|
|
97
92
|
return;
|
|
98
93
|
}
|
|
99
94
|
logRunResult() {
|
|
@@ -105,6 +100,9 @@ class DisabledDebugLogger {
|
|
|
105
100
|
logRunnerError() {
|
|
106
101
|
return;
|
|
107
102
|
}
|
|
103
|
+
logToolExecution() {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
108
106
|
}
|
|
109
107
|
export function createDebugLogger(enableDebug) {
|
|
110
108
|
return enableDebug ? new EnabledDebugLogger() : new DisabledDebugLogger();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug-logger.js","sourceRoot":"","sources":["../../../../../../libs/botonic/plugin-ai-agents/src/lib/debug-logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debug-logger.js","sourceRoot":"","sources":["../../../../../../libs/botonic/plugin-ai-agents/src/lib/debug-logger.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,GAAG,yBAAyB,CAAA;AAkCxC,MAAM,kBAAkB;IACtB,gBAAgB,CAAC,MAAyB;QACxC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,gCAAgC,CAAC,CAAA;QACtD,OAAO,CAAC,GAAG,CACT,GAAG,MAAM,iCAAiC,MAAM,CAAC,wBAAwB,EAAE,CAC5E,CAAA;QACD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,iBAAiB,MAAM,CAAC,UAAU,EAAE,CAAC,CAAA;QAC1D,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,aAAa,MAAM,CAAC,OAAO,IAAI,CAAC,CAAA;QACrD,OAAO,CAAC,GAAG,CACT,GAAG,MAAM,6BAA6B,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,EAAE,CACpF,CAAA;QACD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,kBAAkB,EAAE;YACvC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW;YACtC,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,gBAAg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CAAC,GAAG,CACT,GAAG,MAAM,oBAAoB,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE,CAC3E,CAAA;QACD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,kBAAkB,aAAa,CAAC,WAAW,EAAE,CAAC,CAAA;QACnE,OAAO,CAAC,GAAG,CACT,GAAG,MAAM,+BAA+B,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,uBAAuB,CAAC,EAAE,CAChG,CAAA;QACD,OAAO,CAAC,GAAG,CACT,GAAG,MAAM,8BAA8B,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,sBAAsB,CAAC,EAAE,CAC9F,CAAA;IACH,CAAC;CACF;AAED,MAAM,mBAAmB;IACvB,gBAAgB;QACd,OAAM;IACR,CAAC;IACD,iBAAiB;QACf,OAAM;IACR,CAAC;IACD,gBAAgB;QACd,OAAM;IACR,CAAC;IACD,6DAA6D;IAC7D,cAAc,CAAC,KAAa,EAAE,aAA4B;QACxD,OAAM;IACR,CAAC;IACD,YAAY;QACV,OAAM;IACR,CAAC;IACD,qBAAqB;QACnB,OAAM;IACR,CAAC;IACD,cAAc;QACZ,OAAM;IACR,CAAC;IACD,gBAAgB;QACd,OAAM;IACR,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAC,WAAoB;IACpD,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,kBAAkB,EAAE,CAAC,CAAC,CAAC,IAAI,mBAAmB,EAAE,CAAA;AAC3E,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import { InputGuardrail } from '@openai/agents';
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { type InputGuardrail } from '@openai/agents';
|
|
2
|
+
import type { LLMConfig } from '../llm-config';
|
|
3
|
+
import type { GuardrailRule } from '../types';
|
|
4
|
+
export interface GuardrailTrackingContext {
|
|
5
|
+
botId: string;
|
|
6
|
+
isTest: boolean;
|
|
7
|
+
inferenceId: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function createInputGuardrails(rules: GuardrailRule[], llmConfig: LLMConfig, trackingContext: GuardrailTrackingContext): Promise<InputGuardrail[]>;
|