@botonic/plugin-ai-agents 0.56.0-alpha.0 → 0.57.0-rslib-esm.1
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/{cjs/agents → agents}/base-agent.d.ts +4 -4
- package/lib/agents/base-agent.js +66 -0
- package/lib/agents/base-agent.js.map +1 -0
- package/lib/agents/index.d.ts +2 -0
- package/lib/agents/index.js +9 -0
- package/lib/agents/index.js.map +1 -0
- package/lib/{esm/agents → agents}/router-agent.d.ts +5 -5
- package/lib/agents/router-agent.js +50 -0
- package/lib/agents/router-agent.js.map +1 -0
- package/lib/{cjs/agents → agents}/specialist-agent.d.ts +5 -5
- package/lib/{cjs/agents → agents}/specialist-agent.js +65 -45
- package/lib/agents/specialist-agent.js.map +1 -0
- package/lib/{cjs/bot-config-tools.d.ts → bot-config-tools.d.ts} +1 -1
- package/lib/bot-config-tools.js +20 -0
- package/lib/bot-config-tools.js.map +1 -0
- package/lib/constants.js +26 -0
- package/lib/constants.js.map +1 -0
- package/lib/{esm/debug-logger.d.ts → debug-logger.d.ts} +1 -1
- package/lib/{cjs/debug-logger.js → debug-logger.js} +14 -9
- package/lib/debug-logger.js.map +1 -0
- package/lib/guardrails/index.d.ts +1 -0
- package/lib/guardrails/index.js +6 -0
- package/lib/guardrails/index.js.map +1 -0
- package/lib/{cjs/guardrails → guardrails}/input.d.ts +2 -2
- package/lib/guardrails/input.js +119 -0
- package/lib/guardrails/input.js.map +1 -0
- package/lib/{esm/index.d.ts → index.d.ts} +3 -3
- package/lib/{esm/index.js → index.js} +114 -74
- package/lib/index.js.map +1 -0
- package/lib/{cjs/llm-config.d.ts → llm-config.d.ts} +1 -1
- package/lib/llm-config.js +150 -0
- package/lib/llm-config.js.map +1 -0
- package/lib/{esm/runners → runners}/base-runner.d.ts +3 -3
- package/lib/{cjs/runners → runners}/base-runner.js +81 -69
- package/lib/runners/base-runner.js.map +1 -0
- package/lib/runners/index.d.ts +2 -0
- package/lib/runners/index.js +9 -0
- package/lib/runners/index.js.map +1 -0
- package/lib/{cjs/runners → runners}/router-runner.d.ts +2 -2
- package/lib/{cjs/runners → runners}/router-runner.js +19 -14
- package/lib/runners/router-runner.js.map +1 -0
- package/lib/{esm/runners → runners}/specialist-runner.d.ts +1 -1
- package/lib/runners/specialist-runner.js +10 -0
- package/lib/runners/specialist-runner.js.map +1 -0
- package/lib/{esm/services → services}/hubtype-api-client.d.ts +2 -2
- package/lib/services/hubtype-api-client.js +191 -0
- package/lib/services/hubtype-api-client.js.map +1 -0
- package/lib/{cjs/services → services}/types.d.ts +1 -1
- package/lib/services/types.js +13 -0
- package/lib/services/types.js.map +1 -0
- package/lib/structured-output/bot-executor.js +21 -0
- package/lib/structured-output/bot-executor.js.map +1 -0
- package/lib/structured-output/carousel.js +26 -0
- package/lib/structured-output/carousel.js.map +1 -0
- package/lib/structured-output/exit.js +14 -0
- package/lib/structured-output/exit.js.map +1 -0
- package/lib/{cjs/structured-output → structured-output}/index.d.ts +0 -10
- package/lib/structured-output/index.js +55 -0
- package/lib/structured-output/index.js.map +1 -0
- package/lib/structured-output/text-with-buttons.js +25 -0
- package/lib/structured-output/text-with-buttons.js.map +1 -0
- package/lib/structured-output/text.js +17 -0
- package/lib/structured-output/text.js.map +1 -0
- package/lib/{cjs/tools → tools}/index.d.ts +2 -2
- package/lib/tools/index.js +8 -0
- package/lib/tools/index.js.map +1 -0
- package/lib/{cjs/tools → tools}/retrieve-knowledge.d.ts +2 -2
- package/lib/tools/retrieve-knowledge.js +40 -0
- package/lib/tools/retrieve-knowledge.js.map +1 -0
- package/lib/{cjs/types.d.ts → types.d.ts} +3 -3
- package/lib/types.js +5 -0
- package/lib/types.js.map +1 -0
- package/package.json +10 -8
- package/src/structured-output/index.ts +0 -2
- package/src/types.ts +4 -4
- package/lib/cjs/agents/base-agent.js +0 -39
- package/lib/cjs/agents/base-agent.js.map +0 -1
- package/lib/cjs/agents/index.d.ts +0 -2
- package/lib/cjs/agents/index.js +0 -8
- package/lib/cjs/agents/index.js.map +0 -1
- package/lib/cjs/agents/router-agent.d.ts +0 -25
- package/lib/cjs/agents/router-agent.js +0 -33
- package/lib/cjs/agents/router-agent.js.map +0 -1
- package/lib/cjs/agents/specialist-agent.js.map +0 -1
- package/lib/cjs/bot-config-tools.js +0 -18
- package/lib/cjs/bot-config-tools.js.map +0 -1
- package/lib/cjs/constants.js +0 -25
- package/lib/cjs/constants.js.map +0 -1
- package/lib/cjs/debug-logger.d.ts +0 -33
- package/lib/cjs/debug-logger.js.map +0 -1
- package/lib/cjs/guardrails/index.d.ts +0 -1
- package/lib/cjs/guardrails/index.js +0 -5
- package/lib/cjs/guardrails/index.js.map +0 -1
- package/lib/cjs/guardrails/input.js +0 -96
- package/lib/cjs/guardrails/input.js.map +0 -1
- package/lib/cjs/index.d.ts +0 -22
- package/lib/cjs/index.js +0 -219
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/llm-config.js +0 -121
- package/lib/cjs/llm-config.js.map +0 -1
- package/lib/cjs/runners/base-runner.d.ts +0 -31
- package/lib/cjs/runners/base-runner.js.map +0 -1
- package/lib/cjs/runners/index.d.ts +0 -2
- package/lib/cjs/runners/index.js +0 -8
- package/lib/cjs/runners/index.js.map +0 -1
- package/lib/cjs/runners/router-runner.js.map +0 -1
- package/lib/cjs/runners/specialist-runner.d.ts +0 -4
- package/lib/cjs/runners/specialist-runner.js +0 -8
- package/lib/cjs/runners/specialist-runner.js.map +0 -1
- package/lib/cjs/services/hubtype-api-client.d.ts +0 -13
- package/lib/cjs/services/hubtype-api-client.js +0 -176
- package/lib/cjs/services/hubtype-api-client.js.map +0 -1
- package/lib/cjs/services/types.js +0 -13
- package/lib/cjs/services/types.js.map +0 -1
- package/lib/cjs/structured-output/bot-executor.js +0 -18
- package/lib/cjs/structured-output/bot-executor.js.map +0 -1
- package/lib/cjs/structured-output/carousel.js +0 -23
- package/lib/cjs/structured-output/carousel.js.map +0 -1
- package/lib/cjs/structured-output/exit.js +0 -11
- package/lib/cjs/structured-output/exit.js.map +0 -1
- package/lib/cjs/structured-output/index.js +0 -45
- package/lib/cjs/structured-output/index.js.map +0 -1
- package/lib/cjs/structured-output/request-contact-info.d.ts +0 -9
- package/lib/cjs/structured-output/request-contact-info.js +0 -14
- package/lib/cjs/structured-output/request-contact-info.js.map +0 -1
- package/lib/cjs/structured-output/text-with-buttons.js +0 -24
- package/lib/cjs/structured-output/text-with-buttons.js.map +0 -1
- package/lib/cjs/structured-output/text.js +0 -14
- package/lib/cjs/structured-output/text.js.map +0 -1
- package/lib/cjs/tools/index.js +0 -8
- package/lib/cjs/tools/index.js.map +0 -1
- package/lib/cjs/tools/retrieve-knowledge.js +0 -34
- package/lib/cjs/tools/retrieve-knowledge.js.map +0 -1
- package/lib/cjs/types.js +0 -3
- package/lib/cjs/types.js.map +0 -1
- package/lib/esm/agents/base-agent.d.ts +0 -28
- package/lib/esm/agents/base-agent.js +0 -39
- package/lib/esm/agents/base-agent.js.map +0 -1
- package/lib/esm/agents/index.d.ts +0 -2
- package/lib/esm/agents/index.js +0 -8
- package/lib/esm/agents/index.js.map +0 -1
- package/lib/esm/agents/router-agent.js +0 -33
- package/lib/esm/agents/router-agent.js.map +0 -1
- package/lib/esm/agents/specialist-agent.d.ts +0 -39
- package/lib/esm/agents/specialist-agent.js +0 -108
- package/lib/esm/agents/specialist-agent.js.map +0 -1
- package/lib/esm/bot-config-tools.d.ts +0 -7
- package/lib/esm/bot-config-tools.js +0 -18
- package/lib/esm/bot-config-tools.js.map +0 -1
- package/lib/esm/constants.d.ts +0 -21
- package/lib/esm/constants.js +0 -25
- package/lib/esm/constants.js.map +0 -1
- package/lib/esm/debug-logger.js +0 -116
- package/lib/esm/debug-logger.js.map +0 -1
- package/lib/esm/guardrails/index.d.ts +0 -1
- package/lib/esm/guardrails/index.js +0 -5
- package/lib/esm/guardrails/index.js.map +0 -1
- package/lib/esm/guardrails/input.d.ts +0 -10
- package/lib/esm/guardrails/input.js +0 -96
- package/lib/esm/guardrails/input.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/llm-config.d.ts +0 -30
- package/lib/esm/llm-config.js +0 -121
- package/lib/esm/llm-config.js.map +0 -1
- package/lib/esm/runners/base-runner.js +0 -189
- package/lib/esm/runners/base-runner.js.map +0 -1
- package/lib/esm/runners/index.d.ts +0 -2
- package/lib/esm/runners/index.js +0 -8
- package/lib/esm/runners/index.js.map +0 -1
- package/lib/esm/runners/router-runner.d.ts +0 -8
- package/lib/esm/runners/router-runner.js +0 -44
- package/lib/esm/runners/router-runner.js.map +0 -1
- package/lib/esm/runners/specialist-runner.js +0 -8
- package/lib/esm/runners/specialist-runner.js.map +0 -1
- package/lib/esm/services/hubtype-api-client.js +0 -176
- package/lib/esm/services/hubtype-api-client.js.map +0 -1
- package/lib/esm/services/types.d.ts +0 -72
- package/lib/esm/services/types.js +0 -13
- package/lib/esm/services/types.js.map +0 -1
- package/lib/esm/structured-output/bot-executor.d.ts +0 -13
- package/lib/esm/structured-output/bot-executor.js +0 -18
- package/lib/esm/structured-output/bot-executor.js.map +0 -1
- package/lib/esm/structured-output/carousel.d.ts +0 -18
- package/lib/esm/structured-output/carousel.js +0 -23
- package/lib/esm/structured-output/carousel.js.map +0 -1
- package/lib/esm/structured-output/exit.d.ts +0 -6
- package/lib/esm/structured-output/exit.js +0 -11
- package/lib/esm/structured-output/exit.js.map +0 -1
- package/lib/esm/structured-output/index.d.ts +0 -108
- package/lib/esm/structured-output/index.js +0 -45
- package/lib/esm/structured-output/index.js.map +0 -1
- package/lib/esm/structured-output/request-contact-info.d.ts +0 -9
- package/lib/esm/structured-output/request-contact-info.js +0 -14
- package/lib/esm/structured-output/request-contact-info.js.map +0 -1
- package/lib/esm/structured-output/text-with-buttons.d.ts +0 -17
- package/lib/esm/structured-output/text-with-buttons.js +0 -24
- package/lib/esm/structured-output/text-with-buttons.js.map +0 -1
- package/lib/esm/structured-output/text.d.ts +0 -9
- package/lib/esm/structured-output/text.js +0 -14
- package/lib/esm/structured-output/text.js.map +0 -1
- package/lib/esm/tools/index.d.ts +0 -3
- package/lib/esm/tools/index.js +0 -8
- package/lib/esm/tools/index.js.map +0 -1
- package/lib/esm/tools/retrieve-knowledge.d.ts +0 -6
- package/lib/esm/tools/retrieve-knowledge.js +0 -34
- package/lib/esm/tools/retrieve-knowledge.js.map +0 -1
- package/lib/esm/types.d.ts +0 -53
- package/lib/esm/types.js +0 -3
- package/lib/esm/types.js.map +0 -1
- package/src/structured-output/request-contact-info.ts +0 -18
- /package/lib/{cjs/constants.d.ts → constants.d.ts} +0 -0
- /package/lib/{cjs/structured-output → structured-output}/bot-executor.d.ts +0 -0
- /package/lib/{cjs/structured-output → structured-output}/carousel.d.ts +0 -0
- /package/lib/{cjs/structured-output → structured-output}/exit.d.ts +0 -0
- /package/lib/{cjs/structured-output → structured-output}/text-with-buttons.d.ts +0 -0
- /package/lib/{cjs/structured-output → structured-output}/text.d.ts +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { AgentOutputType, InputGuardrail, Model, ModelSettings } from '@openai/agents';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
|
-
import type { GuardrailTrackingContext } from '../guardrails/input';
|
|
4
|
-
import type { LLMConfig } from '../llm-config';
|
|
5
|
-
import { type OutputSchema } from '../structured-output';
|
|
6
|
-
import type { GuardrailRule } from '../types';
|
|
3
|
+
import type { GuardrailTrackingContext } from '../guardrails/input.js';
|
|
4
|
+
import type { LLMConfig } from '../llm-config.js';
|
|
5
|
+
import { type OutputSchema } from '../structured-output/index.js';
|
|
6
|
+
import type { GuardrailRule } from '../types.js';
|
|
7
7
|
export interface BaseAgentOptions {
|
|
8
8
|
name: string;
|
|
9
9
|
instructions: string;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createInputGuardrails } from "../guardrails/index.js";
|
|
2
|
+
import { getOutputInstructions, getOutputSchema } from "../structured-output/index.js";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function _define_property(obj, key, value) {
|
|
7
|
+
if (key in obj) {
|
|
8
|
+
Object.defineProperty(obj, key, {
|
|
9
|
+
value: value,
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true
|
|
13
|
+
});
|
|
14
|
+
} else obj[key] = value;
|
|
15
|
+
return obj;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class BaseAgent {
|
|
20
|
+
getAgentModelSettings() {
|
|
21
|
+
const modelSettings = {
|
|
22
|
+
...this.llmConfig.modelSettings
|
|
23
|
+
};
|
|
24
|
+
if (this.llmConfig.modelSettings.reasoning) {
|
|
25
|
+
modelSettings.reasoning = {
|
|
26
|
+
...this.llmConfig.modelSettings.reasoning
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (this.llmConfig.modelSettings.text) {
|
|
30
|
+
modelSettings.text = {
|
|
31
|
+
...this.llmConfig.modelSettings.text
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return modelSettings;
|
|
35
|
+
}
|
|
36
|
+
async getInputGuardrails() {
|
|
37
|
+
return await createInputGuardrails(this.inputGuardrailRules, this.llmConfig, this.guardrailTrackingContext);
|
|
38
|
+
}
|
|
39
|
+
getOutputType() {
|
|
40
|
+
return getOutputSchema(this.outputMessagesSchemas);
|
|
41
|
+
}
|
|
42
|
+
addOutputInstructions(instructions) {
|
|
43
|
+
return `${instructions}\n\n${getOutputInstructions()}`;
|
|
44
|
+
}
|
|
45
|
+
async getModel() {
|
|
46
|
+
return await this.llmConfig.getModel();
|
|
47
|
+
}
|
|
48
|
+
constructor(options){
|
|
49
|
+
_define_property(this, "name", void 0);
|
|
50
|
+
_define_property(this, "instructions", void 0);
|
|
51
|
+
_define_property(this, "llmConfig", void 0);
|
|
52
|
+
_define_property(this, "inputGuardrailRules", void 0);
|
|
53
|
+
_define_property(this, "outputMessagesSchemas", void 0);
|
|
54
|
+
_define_property(this, "guardrailTrackingContext", void 0);
|
|
55
|
+
this.name = options.name;
|
|
56
|
+
this.instructions = options.instructions;
|
|
57
|
+
this.llmConfig = options.llmConfig;
|
|
58
|
+
this.inputGuardrailRules = options.inputGuardrailRules;
|
|
59
|
+
this.outputMessagesSchemas = options.outputMessagesSchemas || [];
|
|
60
|
+
this.guardrailTrackingContext = options.guardrailTrackingContext;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { BaseAgent };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=base-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents/base-agent.js","sources":["../../src/agents/base-agent.ts"],"sourcesContent":["import type {\n AgentOutputType,\n InputGuardrail,\n Model,\n ModelSettings,\n} from '@openai/agents'\nimport type { z } from 'zod'\n\nimport { createInputGuardrails } from '../guardrails'\nimport type { GuardrailTrackingContext } from '../guardrails/input'\nimport type { LLMConfig } from '../llm-config'\nimport {\n getOutputInstructions,\n getOutputSchema,\n type OutputSchema,\n} from '../structured-output'\nimport type { GuardrailRule } from '../types'\n\nexport interface BaseAgentOptions {\n name: string\n instructions: string\n llmConfig: LLMConfig\n inputGuardrailRules: GuardrailRule[]\n outputMessagesSchemas?: z.ZodObject[]\n guardrailTrackingContext: GuardrailTrackingContext\n}\n\nexport abstract class BaseAgent {\n protected name: string\n protected instructions: string\n protected llmConfig: LLMConfig\n private inputGuardrailRules: GuardrailRule[]\n private outputMessagesSchemas: z.ZodObject[]\n private guardrailTrackingContext: GuardrailTrackingContext\n\n constructor(options: BaseAgentOptions) {\n this.name = options.name\n this.instructions = options.instructions\n this.llmConfig = options.llmConfig\n this.inputGuardrailRules = options.inputGuardrailRules\n this.outputMessagesSchemas = options.outputMessagesSchemas || []\n this.guardrailTrackingContext = options.guardrailTrackingContext\n }\n\n protected getAgentModelSettings(): ModelSettings {\n const modelSettings: ModelSettings = { ...this.llmConfig.modelSettings }\n\n if (this.llmConfig.modelSettings.reasoning) {\n modelSettings.reasoning = { ...this.llmConfig.modelSettings.reasoning }\n }\n\n if (this.llmConfig.modelSettings.text) {\n modelSettings.text = { ...this.llmConfig.modelSettings.text }\n }\n\n return modelSettings\n }\n\n protected async getInputGuardrails(): Promise<InputGuardrail[]> {\n return await createInputGuardrails(\n this.inputGuardrailRules,\n this.llmConfig,\n this.guardrailTrackingContext\n )\n }\n\n protected getOutputType(): AgentOutputType<typeof OutputSchema> {\n return getOutputSchema(this.outputMessagesSchemas)\n }\n\n protected addOutputInstructions(instructions: string): string {\n return `${instructions}\\n\\n${getOutputInstructions()}`\n }\n\n protected async getModel(): Promise<string | Model> {\n return await this.llmConfig.getModel()\n }\n}\n"],"names":["createInputGuardrails","getOutputInstructions","getOutputSchema","BaseAgent","modelSettings","instructions","options"],"mappings":";;;;;;;;;;;;;;;;AAQqD;AAOxB;AAYtB,MAAeG,SAASA;IAiBnB,wBAAuC;QAC/C,MAAMC,gBAA+B;YAAE,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa;QAAC;QAEvE,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,SAAS,EAAE;YAC1CA,cAAc,SAAS,GAAG;gBAAE,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,SAAS;YAAC;QACxE;QAEA,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE;YACrCA,cAAc,IAAI,GAAG;gBAAE,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI;YAAC;QAC9D;QAEA,OAAOA;IACT;IAEA,MAAgB,qBAAgD;QAC9D,OAAO,MAAMJ,qBAAqBA,CAChC,IAAI,CAAC,mBAAmB,EACxB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,wBAAwB;IAEjC;IAEU,gBAAsD;QAC9D,OAAOE,eAAeA,CAAC,IAAI,CAAC,qBAAqB;IACnD;IAEU,sBAAsBG,YAAoB,EAAU;QAC5D,OAAO,GAAGA,aAAa,IAAI,EAAEJ,qBAAqBA,IAAI;IACxD;IAEA,MAAgB,WAAoC;QAClD,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ;IACtC;IAzCA,YAAYK,OAAyB,CAAE;QAPvC,uBAAU,QAAV;QACA,uBAAU,gBAAV;QACA,uBAAU,aAAV;QACA,uBAAQ,uBAAR;QACA,uBAAQ,yBAAR;QACA,uBAAQ,4BAAR;QAGE,IAAI,CAAC,IAAI,GAAGA,QAAQ,IAAI;QACxB,IAAI,CAAC,YAAY,GAAGA,QAAQ,YAAY;QACxC,IAAI,CAAC,SAAS,GAAGA,QAAQ,SAAS;QAClC,IAAI,CAAC,mBAAmB,GAAGA,QAAQ,mBAAmB;QACtD,IAAI,CAAC,qBAAqB,GAAGA,QAAQ,qBAAqB,IAAI,EAAE;QAChE,IAAI,CAAC,wBAAwB,GAAGA,QAAQ,wBAAwB;IAClE;AAmCF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents/index.js","sources":["../../src/agents/index.ts"],"sourcesContent":["export { RouterAgent } from './router-agent'\nexport { SpecialistAgent } from './specialist-agent'\n"],"names":["RouterAgent","SpecialistAgent"],"mappings":";;AAA4C;AACQ"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ResolvedPlugins } from '@botonic/core';
|
|
2
2
|
import { type AgentOutputType, type Handoff } from '@openai/agents';
|
|
3
3
|
import type { z } from 'zod';
|
|
4
|
-
import type { GuardrailTrackingContext } from '../guardrails/input';
|
|
5
|
-
import type { LLMConfig } from '../llm-config';
|
|
6
|
-
import type { OutputSchema } from '../structured-output';
|
|
7
|
-
import type { AIAgent, Context, GuardrailRule } from '../types';
|
|
8
|
-
import { BaseAgent } from './base-agent';
|
|
4
|
+
import type { GuardrailTrackingContext } from '../guardrails/input.js';
|
|
5
|
+
import type { LLMConfig } from '../llm-config.js';
|
|
6
|
+
import type { OutputSchema } from '../structured-output/index.js';
|
|
7
|
+
import type { AIAgent, Context, GuardrailRule } from '../types.js';
|
|
8
|
+
import { BaseAgent } from './base-agent.js';
|
|
9
9
|
interface RouterAgentOptions<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = unknown> {
|
|
10
10
|
name: string;
|
|
11
11
|
instructions: string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Agent } from "@openai/agents";
|
|
2
|
+
import { RECOMMENDED_PROMPT_PREFIX } from "@openai/agents-core/extensions";
|
|
3
|
+
import { BaseAgent } from "./base-agent.js";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function _define_property(obj, key, value) {
|
|
9
|
+
if (key in obj) {
|
|
10
|
+
Object.defineProperty(obj, key, {
|
|
11
|
+
value: value,
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true
|
|
15
|
+
});
|
|
16
|
+
} else obj[key] = value;
|
|
17
|
+
return obj;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class RouterAgent extends BaseAgent {
|
|
23
|
+
static async create(options) {
|
|
24
|
+
const routerAgent = new RouterAgent(options);
|
|
25
|
+
const inputGuardrails = await routerAgent.getInputGuardrails();
|
|
26
|
+
// Agent.create is typed as Agent<UnknownContext>; we run with Context<TPlugins, TExtraData>.
|
|
27
|
+
const agent = Agent.create({
|
|
28
|
+
name: routerAgent.name,
|
|
29
|
+
model: await routerAgent.getModel(),
|
|
30
|
+
modelSettings: routerAgent.getAgentModelSettings(),
|
|
31
|
+
instructions: routerAgent.addOutputInstructions(`${RECOMMENDED_PROMPT_PREFIX}${routerAgent.instructions}`),
|
|
32
|
+
handoffs: routerAgent.handoffs,
|
|
33
|
+
outputType: routerAgent.getOutputType(),
|
|
34
|
+
inputGuardrails
|
|
35
|
+
});
|
|
36
|
+
routerAgent.agent = agent;
|
|
37
|
+
return routerAgent;
|
|
38
|
+
}
|
|
39
|
+
getAgent() {
|
|
40
|
+
return this.agent;
|
|
41
|
+
}
|
|
42
|
+
constructor(options){
|
|
43
|
+
super(options), _define_property(this, "handoffs", void 0), _define_property(this, "agent", void 0);
|
|
44
|
+
this.handoffs = options.handoffs;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { RouterAgent };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=router-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents/router-agent.js","sources":["../../src/agents/router-agent.ts"],"sourcesContent":["import type { ResolvedPlugins } from '@botonic/core'\nimport { Agent, type AgentOutputType, type Handoff } from '@openai/agents'\nimport { RECOMMENDED_PROMPT_PREFIX } from '@openai/agents-core/extensions'\nimport type { z } from 'zod'\nimport type { GuardrailTrackingContext } from '../guardrails/input'\nimport type { LLMConfig } from '../llm-config'\nimport type { OutputSchema } from '../structured-output'\nimport type { AIAgent, Context, GuardrailRule } from '../types'\nimport { BaseAgent } from './base-agent'\n\ninterface RouterAgentOptions<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = unknown,\n> {\n name: string\n instructions: string\n llmConfig: LLMConfig\n handoffs: Handoff<\n Context<TPlugins, TExtraData>,\n AgentOutputType<typeof OutputSchema>\n >[]\n inputGuardrailRules: GuardrailRule[]\n outputMessagesSchemas?: z.ZodObject[]\n guardrailTrackingContext: GuardrailTrackingContext\n}\n\nexport class RouterAgent<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = unknown,\n> extends BaseAgent {\n private handoffs: Handoff<\n Context<TPlugins, TExtraData>,\n AgentOutputType<typeof OutputSchema>\n >[]\n private agent!: AIAgent<TPlugins, TExtraData>\n\n private constructor(options: RouterAgentOptions<TPlugins, TExtraData>) {\n super(options)\n this.handoffs = options.handoffs\n }\n\n static async create<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = unknown,\n >(\n options: RouterAgentOptions<TPlugins, TExtraData>\n ): Promise<RouterAgent<TPlugins, TExtraData>> {\n const routerAgent = new RouterAgent<TPlugins, TExtraData>(options)\n const inputGuardrails = await routerAgent.getInputGuardrails()\n\n // Agent.create is typed as Agent<UnknownContext>; we run with Context<TPlugins, TExtraData>.\n const agent = Agent.create({\n name: routerAgent.name,\n model: await routerAgent.getModel(),\n modelSettings: routerAgent.getAgentModelSettings(),\n instructions: routerAgent.addOutputInstructions(\n `${RECOMMENDED_PROMPT_PREFIX}${routerAgent.instructions}`\n ),\n handoffs: routerAgent.handoffs,\n outputType: routerAgent.getOutputType(),\n inputGuardrails,\n }) as AIAgent<TPlugins, TExtraData>\n\n routerAgent.agent = agent\n return routerAgent\n }\n\n getAgent(): AIAgent<TPlugins, TExtraData> {\n return this.agent\n }\n}\n"],"names":["Agent","RECOMMENDED_PROMPT_PREFIX","BaseAgent","RouterAgent","options","routerAgent","inputGuardrails","agent"],"mappings":";;;;;;;;;;;;;;;;;;AAC0E;AACA;AAMlC;AAkBjC,MAAMG,WAAWA,SAGdD,SAASA;IAYjB,aAAa,OAIXE,OAAiD,EACL;QAC5C,MAAMC,cAAc,IAAIF,WAAWA,CAAuBC;QAC1D,MAAME,kBAAkB,MAAMD,YAAY,kBAAkB;QAE5D,6FAA6F;QAC7F,MAAME,QAAQP,YAAY,CAAC;YACzB,MAAMK,YAAY,IAAI;YACtB,OAAO,MAAMA,YAAY,QAAQ;YACjC,eAAeA,YAAY,qBAAqB;YAChD,cAAcA,YAAY,qBAAqB,CAC7C,GAAGJ,yBAAyBA,GAAGI,YAAY,YAAY,EAAE;YAE3D,UAAUA,YAAY,QAAQ;YAC9B,YAAYA,YAAY,aAAa;YACrCC;QACF;QAEAD,YAAY,KAAK,GAAGE;QACpB,OAAOF;IACT;IAEA,WAA0C;QACxC,OAAO,IAAI,CAAC,KAAK;IACnB;IAjCA,YAAoBD,OAAiD,CAAE;QACrE,KAAK,CAACA,UAPR,uBAAQ,YAAR,SAIA,uBAAQ,SAAR;QAIE,IAAI,CAAC,QAAQ,GAAGA,QAAQ,QAAQ;IAClC;AA+BF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { CampaignV2, ContactInfo, ResolvedPlugins } from '@botonic/core';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
|
-
import type { DebugLogger } from '../debug-logger';
|
|
4
|
-
import type { GuardrailTrackingContext } from '../guardrails/input';
|
|
5
|
-
import type { LLMConfig } from '../llm-config';
|
|
6
|
-
import type { AIAgent, GuardrailRule, Tool } from '../types';
|
|
7
|
-
import { BaseAgent } from './base-agent';
|
|
3
|
+
import type { DebugLogger } from '../debug-logger.js';
|
|
4
|
+
import type { GuardrailTrackingContext } from '../guardrails/input.js';
|
|
5
|
+
import type { LLMConfig } from '../llm-config.js';
|
|
6
|
+
import type { AIAgent, GuardrailRule, Tool } from '../types.js';
|
|
7
|
+
import { BaseAgent } from './base-agent.js';
|
|
8
8
|
interface SpecialistAgentOptions<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = unknown> {
|
|
9
9
|
name: string;
|
|
10
10
|
instructions: string;
|
|
@@ -1,42 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { Agent } from "@openai/agents";
|
|
2
|
+
import { LLM_PROVIDER } from "../constants.js";
|
|
3
|
+
import { RETRIEVE_KNOWLEDGE_TOOL_NAME, createRetrieveKnowledge, mandatoryTools } from "../tools/index.js";
|
|
4
|
+
import { BaseAgent } from "./base-agent.js";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
function _define_property(obj, key, value) {
|
|
11
|
+
if (key in obj) {
|
|
12
|
+
Object.defineProperty(obj, key, {
|
|
13
|
+
value: value,
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true
|
|
17
17
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
} else obj[key] = value;
|
|
19
|
+
return obj;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class SpecialistAgent extends BaseAgent {
|
|
24
26
|
static async create(options) {
|
|
25
27
|
const specialistAgent = new SpecialistAgent(options);
|
|
26
28
|
const model = specialistAgent.llmConfig.modelName;
|
|
27
29
|
const resolvedModel = await specialistAgent.getModel();
|
|
28
|
-
const hasRetrieveKnowledge = specialistAgent.tools.some(tool
|
|
30
|
+
const hasRetrieveKnowledge = specialistAgent.tools.some((tool)=>tool.name === RETRIEVE_KNOWLEDGE_TOOL_NAME);
|
|
29
31
|
const modelSettings = specialistAgent.getSpecialistModelSettings(hasRetrieveKnowledge);
|
|
30
32
|
const inputGuardrails = await specialistAgent.getInputGuardrails();
|
|
31
33
|
specialistAgent.logger.logModelSettings({
|
|
32
|
-
provider:
|
|
34
|
+
provider: LLM_PROVIDER,
|
|
33
35
|
model,
|
|
34
36
|
reasoning: modelSettings.reasoning,
|
|
35
37
|
text: modelSettings.text,
|
|
36
38
|
toolChoice: modelSettings.toolChoice,
|
|
37
|
-
hasRetrieveKnowledge
|
|
39
|
+
hasRetrieveKnowledge
|
|
38
40
|
});
|
|
39
|
-
const agent = new
|
|
41
|
+
const agent = new Agent({
|
|
40
42
|
name: specialistAgent.name,
|
|
41
43
|
model: resolvedModel,
|
|
42
44
|
modelSettings,
|
|
@@ -44,7 +46,7 @@ class SpecialistAgent extends base_agent_1.BaseAgent {
|
|
|
44
46
|
tools: specialistAgent.tools,
|
|
45
47
|
outputType: specialistAgent.getOutputType(),
|
|
46
48
|
inputGuardrails,
|
|
47
|
-
outputGuardrails: []
|
|
49
|
+
outputGuardrails: []
|
|
48
50
|
});
|
|
49
51
|
specialistAgent.agent = agent;
|
|
50
52
|
return specialistAgent;
|
|
@@ -54,11 +56,9 @@ class SpecialistAgent extends base_agent_1.BaseAgent {
|
|
|
54
56
|
}
|
|
55
57
|
getSpecialistModelSettings(hasRetrieveKnowledge) {
|
|
56
58
|
const modelSettings = this.getAgentModelSettings();
|
|
57
|
-
const forceRetrieveKnowledge = hasRetrieveKnowledge &&
|
|
58
|
-
!this.forceToolNameOverride &&
|
|
59
|
-
!this.disableForceRetrieveKnowledge;
|
|
59
|
+
const forceRetrieveKnowledge = hasRetrieveKnowledge && !this.forceToolNameOverride && !this.disableForceRetrieveKnowledge;
|
|
60
60
|
if (forceRetrieveKnowledge) {
|
|
61
|
-
modelSettings.toolChoice =
|
|
61
|
+
modelSettings.toolChoice = RETRIEVE_KNOWLEDGE_TOOL_NAME;
|
|
62
62
|
}
|
|
63
63
|
if (this.forceToolNameOverride) {
|
|
64
64
|
modelSettings.toolChoice = this.forceToolNameOverride;
|
|
@@ -70,15 +70,15 @@ class SpecialistAgent extends base_agent_1.BaseAgent {
|
|
|
70
70
|
`<instructions>\n${initialInstructions.trim()}\n</instructions>`,
|
|
71
71
|
this.getMetadataInstructions(),
|
|
72
72
|
this.getContactInfoInstructions(contactInfo),
|
|
73
|
-
this.getCampaignInstructions(campaignsContext)
|
|
74
|
-
].filter(section
|
|
73
|
+
this.getCampaignInstructions(campaignsContext)
|
|
74
|
+
].filter((section)=>section.length > 0);
|
|
75
75
|
return this.addOutputInstructions(sections.join('\n\n'));
|
|
76
76
|
}
|
|
77
77
|
getContactInfoInstructions(contactInfo) {
|
|
78
|
-
return `<contact_info_fields>${JSON.stringify(contactInfo.map(info
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
return `<contact_info_fields>${JSON.stringify(contactInfo.map((info)=>({
|
|
79
|
+
name: info.name,
|
|
80
|
+
value: info.value
|
|
81
|
+
})), null, 0)}</contact_info_fields>`;
|
|
82
82
|
}
|
|
83
83
|
getMetadataInstructions() {
|
|
84
84
|
const metadata = `Current Date: ${new Date().toISOString()}`;
|
|
@@ -88,21 +88,41 @@ class SpecialistAgent extends base_agent_1.BaseAgent {
|
|
|
88
88
|
if (!campaignsContext || campaignsContext.length === 0) {
|
|
89
89
|
return '';
|
|
90
90
|
}
|
|
91
|
-
const campaignsWithContext = campaignsContext.filter(campaign
|
|
91
|
+
const campaignsWithContext = campaignsContext.filter((campaign)=>campaign.agent_context);
|
|
92
92
|
if (campaignsWithContext.length === 0) {
|
|
93
93
|
return '';
|
|
94
94
|
}
|
|
95
|
-
return campaignsWithContext
|
|
96
|
-
.map((campaign, index) => `<campaign_context_${index + 1}>\n${campaign.agent_context}\n</campaign_context_${index + 1}>`)
|
|
97
|
-
.join('\n');
|
|
95
|
+
return campaignsWithContext.map((campaign, index)=>`<campaign_context_${index + 1}>\n${campaign.agent_context}\n</campaign_context_${index + 1}>`).join('\n');
|
|
98
96
|
}
|
|
99
97
|
addHubtypeTools(tools, sourceIds) {
|
|
100
|
-
const hubtypeTools = [
|
|
98
|
+
const hubtypeTools = [
|
|
99
|
+
...mandatoryTools
|
|
100
|
+
];
|
|
101
101
|
if (sourceIds.length > 0) {
|
|
102
|
-
hubtypeTools.push(
|
|
102
|
+
hubtypeTools.push(createRetrieveKnowledge(sourceIds));
|
|
103
103
|
}
|
|
104
|
-
return [
|
|
104
|
+
return [
|
|
105
|
+
...hubtypeTools,
|
|
106
|
+
...tools
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
constructor(options){
|
|
110
|
+
super({
|
|
111
|
+
name: options.name,
|
|
112
|
+
instructions: options.instructions,
|
|
113
|
+
llmConfig: options.llmConfig,
|
|
114
|
+
inputGuardrailRules: options.inputGuardrailRules,
|
|
115
|
+
outputMessagesSchemas: options.outputMessagesSchemas,
|
|
116
|
+
guardrailTrackingContext: options.guardrailTrackingContext
|
|
117
|
+
}), _define_property(this, "tools", void 0), _define_property(this, "logger", void 0), _define_property(this, "agent", void 0), _define_property(this, "forceToolNameOverride", void 0), _define_property(this, "disableForceRetrieveKnowledge", void 0);
|
|
118
|
+
this.instructions = this.addExtraInstructions(options.instructions, options.contactInfo, options.campaignsContext);
|
|
119
|
+
this.tools = this.addHubtypeTools(options.tools, options.sourceIds);
|
|
120
|
+
this.logger = options.logger;
|
|
121
|
+
this.forceToolNameOverride = options.forceToolNameOverride;
|
|
122
|
+
this.disableForceRetrieveKnowledge = options.disableForceRetrieveKnowledge;
|
|
105
123
|
}
|
|
106
124
|
}
|
|
107
|
-
|
|
125
|
+
|
|
126
|
+
export { SpecialistAgent };
|
|
127
|
+
|
|
108
128
|
//# sourceMappingURL=specialist-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents/specialist-agent.js","sources":["../../src/agents/specialist-agent.ts"],"sourcesContent":["import type { CampaignV2, ContactInfo, ResolvedPlugins } from '@botonic/core'\nimport { Agent, type AgentOutputType, type ModelSettings } from '@openai/agents'\nimport type { z } from 'zod'\nimport { LLM_PROVIDER } from '../constants'\nimport type { DebugLogger } from '../debug-logger'\nimport type { GuardrailTrackingContext } from '../guardrails/input'\nimport type { LLMConfig } from '../llm-config'\nimport type { OutputSchema } from '../structured-output'\nimport {\n createRetrieveKnowledge,\n mandatoryTools,\n RETRIEVE_KNOWLEDGE_TOOL_NAME,\n} from '../tools'\nimport type { AIAgent, Context, GuardrailRule, Tool } from '../types'\nimport { BaseAgent } from './base-agent'\n\ninterface SpecialistAgentOptions<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = unknown,\n> {\n name: string\n instructions: string\n tools: Tool<TPlugins, TExtraData>[]\n campaignsContext?: CampaignV2[]\n contactInfo: ContactInfo[]\n inputGuardrailRules: GuardrailRule[]\n sourceIds: string[]\n outputMessagesSchemas?: z.ZodObject[]\n llmConfig: LLMConfig\n logger: DebugLogger\n guardrailTrackingContext: GuardrailTrackingContext\n forceToolNameOverride?: string\n disableForceRetrieveKnowledge?: boolean\n}\n\nexport class SpecialistAgent<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = unknown,\n> extends BaseAgent {\n private tools: Tool<TPlugins, TExtraData>[]\n private logger: DebugLogger\n private agent!: AIAgent<TPlugins, TExtraData>\n private forceToolNameOverride?: string\n private disableForceRetrieveKnowledge?: boolean\n\n private constructor(options: SpecialistAgentOptions<TPlugins, TExtraData>) {\n super({\n name: options.name,\n instructions: options.instructions,\n llmConfig: options.llmConfig,\n inputGuardrailRules: options.inputGuardrailRules,\n outputMessagesSchemas: options.outputMessagesSchemas,\n guardrailTrackingContext: options.guardrailTrackingContext,\n })\n this.instructions = this.addExtraInstructions(\n options.instructions,\n options.contactInfo,\n options.campaignsContext\n )\n this.tools = this.addHubtypeTools(options.tools, options.sourceIds)\n this.logger = options.logger\n this.forceToolNameOverride = options.forceToolNameOverride\n this.disableForceRetrieveKnowledge = options.disableForceRetrieveKnowledge\n }\n\n static async create<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = unknown,\n >(\n options: SpecialistAgentOptions<TPlugins, TExtraData>\n ): Promise<SpecialistAgent<TPlugins, TExtraData>> {\n const specialistAgent = new SpecialistAgent<TPlugins, TExtraData>(options)\n const model = specialistAgent.llmConfig.modelName\n const resolvedModel = await specialistAgent.getModel()\n const hasRetrieveKnowledge = specialistAgent.tools.some(\n tool => tool.name === RETRIEVE_KNOWLEDGE_TOOL_NAME\n )\n const modelSettings =\n specialistAgent.getSpecialistModelSettings(hasRetrieveKnowledge)\n const inputGuardrails = await specialistAgent.getInputGuardrails()\n\n specialistAgent.logger.logModelSettings({\n provider: LLM_PROVIDER,\n model,\n reasoning: modelSettings.reasoning as { effort: string } | undefined,\n text: modelSettings.text as { verbosity: string } | undefined,\n toolChoice: modelSettings.toolChoice,\n hasRetrieveKnowledge,\n })\n\n const agent = new Agent<\n Context<TPlugins, TExtraData>,\n AgentOutputType<typeof OutputSchema>\n >({\n name: specialistAgent.name,\n model: resolvedModel,\n modelSettings,\n instructions: specialistAgent.instructions,\n tools: specialistAgent.tools,\n outputType: specialistAgent.getOutputType(),\n inputGuardrails,\n outputGuardrails: [],\n })\n\n specialistAgent.agent = agent\n return specialistAgent\n }\n\n getAgent(): AIAgent<TPlugins, TExtraData> {\n return this.agent\n }\n\n private getSpecialistModelSettings(\n hasRetrieveKnowledge: boolean\n ): ModelSettings {\n const modelSettings = this.getAgentModelSettings()\n const forceRetrieveKnowledge =\n hasRetrieveKnowledge &&\n !this.forceToolNameOverride &&\n !this.disableForceRetrieveKnowledge\n\n if (forceRetrieveKnowledge) {\n modelSettings.toolChoice = RETRIEVE_KNOWLEDGE_TOOL_NAME\n }\n\n if (this.forceToolNameOverride) {\n modelSettings.toolChoice = this.forceToolNameOverride\n }\n\n return modelSettings\n }\n\n private addExtraInstructions(\n initialInstructions: string,\n contactInfo: ContactInfo[],\n campaignsContext?: CampaignV2[]\n ): string {\n const sections = [\n `<instructions>\\n${initialInstructions.trim()}\\n</instructions>`,\n this.getMetadataInstructions(),\n this.getContactInfoInstructions(contactInfo),\n this.getCampaignInstructions(campaignsContext),\n ].filter(section => section.length > 0)\n\n return this.addOutputInstructions(sections.join('\\n\\n'))\n }\n\n private getContactInfoInstructions(contactInfo: ContactInfo[]): string {\n return `<contact_info_fields>${JSON.stringify(\n contactInfo.map(info => ({\n name: info.name,\n value: info.value,\n })),\n null,\n 0\n )}</contact_info_fields>`\n }\n\n private getMetadataInstructions(): string {\n const metadata = `Current Date: ${new Date().toISOString()}`\n return `<metadata>\\n${metadata}\\n</metadata>`\n }\n\n private getCampaignInstructions(campaignsContext?: CampaignV2[]): string {\n if (!campaignsContext || campaignsContext.length === 0) {\n return ''\n }\n const campaignsWithContext = campaignsContext.filter(\n campaign => campaign.agent_context\n )\n if (campaignsWithContext.length === 0) {\n return ''\n }\n return campaignsWithContext\n .map(\n (campaign, index) =>\n `<campaign_context_${index + 1}>\\n${campaign.agent_context}\\n</campaign_context_${index + 1}>`\n )\n .join('\\n')\n }\n\n private addHubtypeTools(\n tools: Tool<TPlugins, TExtraData>[],\n sourceIds: string[]\n ): Tool<TPlugins, TExtraData>[] {\n const hubtypeTools: Tool[] = [...mandatoryTools]\n if (sourceIds.length > 0) {\n hubtypeTools.push(createRetrieveKnowledge(sourceIds))\n }\n return [...hubtypeTools, ...tools]\n }\n}\n"],"names":["Agent","LLM_PROVIDER","createRetrieveKnowledge","mandatoryTools","RETRIEVE_KNOWLEDGE_TOOL_NAME","BaseAgent","SpecialistAgent","options","specialistAgent","model","resolvedModel","hasRetrieveKnowledge","tool","modelSettings","inputGuardrails","agent","forceRetrieveKnowledge","initialInstructions","contactInfo","campaignsContext","sections","section","JSON","info","metadata","Date","campaignsWithContext","campaign","index","tools","sourceIds","hubtypeTools"],"mappings":";;;;;;;;;;;;;;;;;;;;AACgF;AAErC;AAS1B;AAEuB;AAqBjC,MAAMM,eAAeA,SAGlBD,SAASA;IA2BjB,aAAa,OAIXE,OAAqD,EACL;QAChD,MAAMC,kBAAkB,IAAIF,eAAeA,CAAuBC;QAClE,MAAME,QAAQD,gBAAgB,SAAS,CAAC,SAAS;QACjD,MAAME,gBAAgB,MAAMF,gBAAgB,QAAQ;QACpD,MAAMG,uBAAuBH,gBAAgB,KAAK,CAAC,IAAI,CACrDI,CAAAA,OAAQA,KAAK,IAAI,KAAKR,4BAA4BA;QAEpD,MAAMS,gBACJL,gBAAgB,0BAA0B,CAACG;QAC7C,MAAMG,kBAAkB,MAAMN,gBAAgB,kBAAkB;QAEhEA,gBAAgB,MAAM,CAAC,gBAAgB,CAAC;YACtC,UAAUP,YAAYA;YACtBQ;YACA,WAAWI,cAAc,SAAS;YAClC,MAAMA,cAAc,IAAI;YACxB,YAAYA,cAAc,UAAU;YACpCF;QACF;QAEA,MAAMI,QAAQ,IAAIf,KAAKA,CAGrB;YACA,MAAMQ,gBAAgB,IAAI;YAC1B,OAAOE;YACPG;YACA,cAAcL,gBAAgB,YAAY;YAC1C,OAAOA,gBAAgB,KAAK;YAC5B,YAAYA,gBAAgB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B;IAC5E;AAgIF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ToolConfigJSON } from '@botonic/core';
|
|
2
|
-
import type { CustomTool } from './types';
|
|
2
|
+
import type { CustomTool } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Maps custom AI agent tools to the format expected by bot config (e.g. for flow-builder).
|
|
5
5
|
* Converts each tool's Zod schema to JSON Schema so it can be serialized in the config.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Maps custom AI agent tools to the format expected by bot config (e.g. for flow-builder).
|
|
7
|
+
* Converts each tool's Zod schema to JSON Schema so it can be serialized in the config.
|
|
8
|
+
*/ function getToolsForBotConfig(customTools) {
|
|
9
|
+
return customTools.map((tool)=>({
|
|
10
|
+
name: tool.name,
|
|
11
|
+
description: tool.description,
|
|
12
|
+
schema: z.toJSONSchema(tool.schema, {
|
|
13
|
+
target: 'draft-07'
|
|
14
|
+
})
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { getToolsForBotConfig };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=bot-config-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot-config-tools.js","sources":["../src/bot-config-tools.ts"],"sourcesContent":["import type { ToolConfigJSON } from '@botonic/core'\nimport { z } from 'zod'\n\nimport type { CustomTool } from './types'\n\n/**\n * Maps custom AI agent tools to the format expected by bot config (e.g. for flow-builder).\n * Converts each tool's Zod schema to JSON Schema so it can be serialized in the config.\n */\nexport function getToolsForBotConfig(\n customTools: CustomTool[]\n): ToolConfigJSON[] {\n return customTools.map(tool => ({\n name: tool.name,\n description: tool.description,\n schema: z.toJSONSchema(tool.schema, {\n target: 'draft-07',\n }) as ToolConfigJSON['schema'],\n }))\n}\n"],"names":["z","getToolsForBotConfig","customTools","tool"],"mappings":";;;AACuB;AAIvB;;;CAGC,GACM,SAASC,oBAAoBA,CAClCC,WAAyB;IAEzB,OAAOA,YAAY,GAAG,CAACC,CAAAA,OAAS;YAC9B,MAAMA,KAAK,IAAI;YACf,aAAaA,KAAK,WAAW;YAC7B,QAAQH,cAAc,CAACG,KAAK,MAAM,EAAE;gBAClC,QAAQ;YACV;QACF;AACF"}
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const HUBTYPE_API_URL = process.env.HUBTYPE_API_URL || 'https://api.hubtype.com';
|
|
2
|
+
// LLM Configuration (provider-agnostic; set LLM_PROVIDER=azure|openai)
|
|
3
|
+
const LLM_PROVIDERS = {
|
|
4
|
+
AZURE: 'azure',
|
|
5
|
+
OPENAI: 'openai',
|
|
6
|
+
LITELLM: 'litellm'
|
|
7
|
+
};
|
|
8
|
+
const LITELLM_TAG_KEYS = {
|
|
9
|
+
BOT_ID: 'bot_id',
|
|
10
|
+
ORG_ID: 'org_id',
|
|
11
|
+
SEPARATOR: ','
|
|
12
|
+
};
|
|
13
|
+
const LLM_PROVIDER = process.env.LLM_PROVIDER || LLM_PROVIDERS.AZURE;
|
|
14
|
+
const LLM_API_KEY = process.env.LLM_API_KEY // pragma: allowlist secret
|
|
15
|
+
;
|
|
16
|
+
const LLM_API_URL = process.env.LLM_API_URL;
|
|
17
|
+
const LLM_AZURE_API_VERSION = process.env.LLM_AZURE_API_VERSION || '2025-01-01-preview';
|
|
18
|
+
const LLM_OPENAI_MODEL = process.env.LLM_OPENAI_MODEL || 'gpt-4.1-mini';
|
|
19
|
+
const isProd = process.env.NODE_ENV === 'production';
|
|
20
|
+
const MAX_MEMORY_LENGTH = 25;
|
|
21
|
+
const DEFAULT_TIMEOUT_16_SECONDS = 16000;
|
|
22
|
+
const DEFAULT_MAX_RETRIES = 2;
|
|
23
|
+
|
|
24
|
+
export { DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_16_SECONDS, HUBTYPE_API_URL, LITELLM_TAG_KEYS, LLM_API_KEY, LLM_API_URL, LLM_AZURE_API_VERSION, LLM_OPENAI_MODEL, LLM_PROVIDER, LLM_PROVIDERS, MAX_MEMORY_LENGTH, isProd };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export const HUBTYPE_API_URL =\n process.env.HUBTYPE_API_URL || 'https://api.hubtype.com'\n\n// LLM Configuration (provider-agnostic; set LLM_PROVIDER=azure|openai)\nexport const LLM_PROVIDERS = {\n AZURE: 'azure',\n OPENAI: 'openai',\n LITELLM: 'litellm',\n} as const\n\nexport type LLMProviderType = (typeof LLM_PROVIDERS)[keyof typeof LLM_PROVIDERS]\n\nexport const LITELLM_TAG_KEYS = {\n BOT_ID: 'bot_id',\n ORG_ID: 'org_id',\n SEPARATOR: ',',\n} as const\n\nexport const LLM_PROVIDER: LLMProviderType =\n (process.env.LLM_PROVIDER as LLMProviderType) || LLM_PROVIDERS.AZURE\nexport const LLM_API_KEY = process.env.LLM_API_KEY // pragma: allowlist secret\nexport const LLM_API_URL = process.env.LLM_API_URL\nexport const LLM_AZURE_API_VERSION =\n process.env.LLM_AZURE_API_VERSION || '2025-01-01-preview'\nexport const LLM_OPENAI_MODEL = process.env.LLM_OPENAI_MODEL || 'gpt-4.1-mini'\n\nexport const isProd = process.env.NODE_ENV === 'production'\n\nexport const MAX_MEMORY_LENGTH = 25\n\nexport const DEFAULT_TIMEOUT_16_SECONDS = 16000\nexport const DEFAULT_MAX_RETRIES = 2\n"],"names":["HUBTYPE_API_URL","process","LLM_PROVIDERS","LITELLM_TAG_KEYS","LLM_PROVIDER","LLM_API_KEY","LLM_API_URL","LLM_AZURE_API_VERSION","LLM_OPENAI_MODEL","isProd","MAX_MEMORY_LENGTH","DEFAULT_TIMEOUT_16_SECONDS","DEFAULT_MAX_RETRIES"],"mappings":"AAAO,MAAMA,eAAeA,GAC1BC,QAAQ,GAAG,CAAC,eAAe,IAAI,0BAAyB;AAE1D,uEAAuE;AAChE,MAAMC,aAAaA,GAAG;IAC3B,OAAO;IACP,QAAQ;IACR,SAAS;AACX,EAAU;AAIH,MAAMC,gBAAgBA,GAAG;IAC9B,QAAQ;IACR,QAAQ;IACR,WAAW;AACb,EAAU;AAEH,MAAMC,YAAYA,GACtBH,QAAQ,GAAG,CAAC,YAAY,IAAwBC,aAAaA,CAAC,KAAK;AAC/D,MAAMG,WAAWA,GAAGJ,QAAQ,GAAG,CAAC,WAAW,CAAC,2BAA2B;CAA5B;AAC3C,MAAMK,WAAWA,GAAGL,QAAQ,GAAG,CAAC,WAAW;AAC3C,MAAMM,qBAAqBA,GAChCN,QAAQ,GAAG,CAAC,qBAAqB,IAAI,qBAAoB;AACpD,MAAMO,gBAAgBA,GAAGP,QAAQ,GAAG,CAAC,gBAAgB,IAAI,eAAc;AAEvE,MAAMQ,MAAMA,GAAGR,oBAAoB,KAAK,aAAY;AAEpD,MAAMS,iBAAiBA,GAAG,GAAE;AAE5B,MAAMC,0BAA0BA,GAAG,MAAK;AACxC,MAAMC,mBAAmBA,GAAG,EAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AiAgentArgs, type ToolExecution } from '@botonic/core';
|
|
2
2
|
import type { ModelSettings } from '@openai/agents';
|
|
3
|
-
import type { AgenticInputMessage, MemoryOptions, RunResult } from './types';
|
|
3
|
+
import type { AgenticInputMessage, MemoryOptions, RunResult } from './types.js';
|
|
4
4
|
export interface DebugLoggerConfig {
|
|
5
5
|
messageHistoryApiVersion: string;
|
|
6
6
|
maxRetries: number;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { AiAgentType } from "@botonic/core";
|
|
2
|
+
import { LLM_PROVIDER } from "./constants.js";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
6
8
|
const PREFIX = '[BotonicPluginAiAgents]';
|
|
7
9
|
class EnabledDebugLogger {
|
|
8
10
|
logInitialConfig(config) {
|
|
9
11
|
console.log(`${PREFIX} === Plugin Initialization ===`);
|
|
10
|
-
console.log(`${PREFIX} Provider: ${
|
|
12
|
+
console.log(`${PREFIX} Provider: ${LLM_PROVIDER}`);
|
|
11
13
|
console.log(`${PREFIX} Message History API Version: ${config.messageHistoryApiVersion}`);
|
|
12
14
|
console.log(`${PREFIX} Max Retries: ${config.maxRetries}`);
|
|
13
15
|
console.log(`${PREFIX} Timeout: ${config.timeout}ms`);
|
|
@@ -16,7 +18,7 @@ class EnabledDebugLogger {
|
|
|
16
18
|
maxMessages: config.memory.maxMessages,
|
|
17
19
|
includeToolCalls: config.memory.includeToolCalls,
|
|
18
20
|
maxFullToolResults: config.memory.maxFullToolResults,
|
|
19
|
-
debugMode: config.memory.debugMode
|
|
21
|
+
debugMode: config.memory.debugMode
|
|
20
22
|
});
|
|
21
23
|
console.log(`${PREFIX} === End Plugin Initialization ===`);
|
|
22
24
|
}
|
|
@@ -24,7 +26,7 @@ class EnabledDebugLogger {
|
|
|
24
26
|
console.log(`${PREFIX} === AI Agent Debug Info ===`);
|
|
25
27
|
console.log(`${PREFIX} Agent Name: ${aiAgentArgs.name}`);
|
|
26
28
|
console.log(`${PREFIX} Active Tools: ${JSON.stringify(toolNames)}`);
|
|
27
|
-
if (aiAgentArgs.type ===
|
|
29
|
+
if (aiAgentArgs.type === AiAgentType.Specialist) {
|
|
28
30
|
console.log(`${PREFIX} Source IDs: ${JSON.stringify(aiAgentArgs.sourceIds || [])}`);
|
|
29
31
|
}
|
|
30
32
|
console.log(`${PREFIX} Message History Count: ${messages.length}`);
|
|
@@ -59,7 +61,7 @@ class EnabledDebugLogger {
|
|
|
59
61
|
console.log(`${PREFIX} Output Messages Count: ${runResult.messages.length}`);
|
|
60
62
|
console.log(`${PREFIX} Exit: ${runResult.exit}`);
|
|
61
63
|
console.log(`${PREFIX} Error: ${runResult.error}`);
|
|
62
|
-
console.log(`${PREFIX} Tools Executed: ${JSON.stringify(runResult.toolsExecuted.map(t
|
|
64
|
+
console.log(`${PREFIX} Tools Executed: ${JSON.stringify(runResult.toolsExecuted.map((t)=>t.toolName))}`);
|
|
63
65
|
if (runResult.inputGuardrailsTriggered.length > 0) {
|
|
64
66
|
console.log(`${PREFIX} Input Guardrails Triggered: ${runResult.inputGuardrailsTriggered.length}`);
|
|
65
67
|
}
|
|
@@ -113,4 +115,7 @@ class DisabledDebugLogger {
|
|
|
113
115
|
function createDebugLogger(enableDebug) {
|
|
114
116
|
return enableDebug ? new EnabledDebugLogger() : new DisabledDebugLogger();
|
|
115
117
|
}
|
|
118
|
+
|
|
119
|
+
export { createDebugLogger };
|
|
120
|
+
|
|
116
121
|
//# sourceMappingURL=debug-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-logger.js","sources":["../src/debug-logger.ts"],"sourcesContent":["import {\n type AiAgentArgs,\n AiAgentType,\n type ToolExecution,\n} from '@botonic/core'\nimport type { ModelSettings } from '@openai/agents'\nimport { LLM_PROVIDER } from './constants'\nimport type { AgenticInputMessage, MemoryOptions, RunResult } from './types'\n\nconst PREFIX = '[BotonicPluginAiAgents]'\n\nexport interface DebugLoggerConfig {\n messageHistoryApiVersion: string\n maxRetries: number\n timeout: number\n customToolNames: string[]\n memory: MemoryOptions\n}\n\nexport interface ModelSettingsInfo {\n provider: string\n model: string | undefined\n reasoning?: { effort: string }\n text?: { verbosity: string }\n toolChoice?: string\n hasRetrieveKnowledge: boolean\n}\n\nexport interface DebugLogger {\n logInitialConfig(config: DebugLoggerConfig): void\n logAgentDebugInfo(\n aiAgentArgs: AiAgentArgs,\n toolNames: string[],\n messages: AgenticInputMessage[]\n ): void\n logModelSettings(settings: ModelSettingsInfo): void\n logRunnerStart(\n model: string,\n modelSettings: ModelSettings,\n prompt: string\n ): void\n logRunResult(runResult: RunResult, startTime: number): void\n logGuardrailTriggered(): void\n logRunnerError(startTime: number, error: unknown): void\n logToolExecution(toolExecution: ToolExecution): void\n}\n\nclass EnabledDebugLogger implements DebugLogger {\n logInitialConfig(config: DebugLoggerConfig): void {\n console.log(`${PREFIX} === Plugin Initialization ===`)\n console.log(`${PREFIX} Provider: ${LLM_PROVIDER}`)\n console.log(\n `${PREFIX} Message History API Version: ${config.messageHistoryApiVersion}`\n )\n console.log(`${PREFIX} Max Retries: ${config.maxRetries}`)\n console.log(`${PREFIX} Timeout: ${config.timeout}ms`)\n console.log(\n `${PREFIX} Custom Tools Registered: ${config.customToolNames.join(', ') || 'none'}`\n )\n console.log(`${PREFIX} Memory Options:`, {\n maxMessages: config.memory.maxMessages,\n includeToolCalls: config.memory.includeToolCalls,\n maxFullToolResults: config.memory.maxFullToolResults,\n debugMode: config.memory.debugMode,\n })\n console.log(`${PREFIX} === End Plugin Initialization ===`)\n }\n\n logAgentDebugInfo(\n aiAgentArgs: AiAgentArgs,\n toolNames: string[],\n messages: AgenticInputMessage[]\n ): void {\n console.log(`${PREFIX} === AI Agent Debug Info ===`)\n console.log(`${PREFIX} Agent Name: ${aiAgentArgs.name}`)\n console.log(`${PREFIX} Active Tools: ${JSON.stringify(toolNames)}`)\n if (aiAgentArgs.type === AiAgentType.Specialist) {\n console.log(\n `${PREFIX} Source IDs: ${JSON.stringify(aiAgentArgs.sourceIds || [])}`\n )\n }\n console.log(`${PREFIX} Message History Count: ${messages.length}`)\n console.log(`${PREFIX} Messages: ${JSON.stringify(messages, null, 2)}`)\n console.log(\n `${PREFIX} Input Guardrail Rules: ${aiAgentArgs.inputGuardrailRules?.length || 0}`\n )\n console.log(`${PREFIX} === End Debug Info ===`)\n }\n\n logModelSettings(settings: ModelSettingsInfo): void {\n console.log(`${PREFIX} === Agent Model Settings ===`)\n console.log(\n `${PREFIX} Has Retrieve Knowledge Tool: ${settings.hasRetrieveKnowledge}`\n )\n if (settings.reasoning) {\n console.log(`${PREFIX} Reasoning Effort: ${settings.reasoning.effort}`)\n }\n if (settings.text) {\n console.log(`${PREFIX} Text Verbosity: ${settings.text.verbosity}`)\n }\n if (settings.toolChoice) {\n console.log(`${PREFIX} Tool Choice: ${settings.toolChoice}`)\n }\n console.log(`${PREFIX} === End Model Settings ===`)\n }\n\n logRunnerStart(\n model: string,\n modelSettings: ModelSettings,\n prompt: string\n ): void {\n console.log(`${PREFIX} === Runner Execution Start ===`)\n console.log(`${PREFIX} Model: ${model}`)\n console.log(`${PREFIX} Model Settings: ${JSON.stringify(modelSettings)}`)\n console.log(`${PREFIX} Prompt: ${prompt}`)\n }\n\n logRunResult(runResult: RunResult, startTime: number): void {\n const elapsedMs = Date.now() - startTime\n\n console.log(`${PREFIX} === Runner Execution Complete ===`)\n console.log(`${PREFIX} Execution Time: ${elapsedMs}ms`)\n console.log(`${PREFIX} Output Messages Count: ${runResult.messages.length}`)\n console.log(`${PREFIX} Exit: ${runResult.exit}`)\n console.log(`${PREFIX} Error: ${runResult.error}`)\n console.log(\n `${PREFIX} Tools Executed: ${JSON.stringify(runResult.toolsExecuted.map(t => t.toolName))}`\n )\n if (runResult.inputGuardrailsTriggered.length > 0) {\n console.log(\n `${PREFIX} Input Guardrails Triggered: ${runResult.inputGuardrailsTriggered.length}`\n )\n }\n if (runResult.outputGuardrailsTriggered.length > 0) {\n console.log(\n `${PREFIX} Output Guardrails Triggered: ${runResult.outputGuardrailsTriggered.length}`\n )\n }\n console.log(`${PREFIX} === End Runner Execution ===`)\n }\n\n logGuardrailTriggered(): void {\n console.log(`${PREFIX} Input guardrail triggered`)\n }\n\n logRunnerError(startTime: number, error: unknown): void {\n const elapsedMs = Date.now() - startTime\n console.log(`${PREFIX} Runner execution failed after ${elapsedMs}ms`)\n console.log(`${PREFIX} Error:`, error)\n }\n\n logToolExecution(toolExecution: ToolExecution): void {\n console.log(`${PREFIX} Tool Execution: ${toolExecution.toolName}`)\n console.log(\n `${PREFIX} Tool Arguments: ${JSON.stringify(toolExecution.toolArguments)}`\n )\n console.log(`${PREFIX} Tool Results: ${toolExecution.toolResults}`)\n console.log(\n `${PREFIX} Knowledgebase Sources IDs: ${JSON.stringify(toolExecution.knowledgebaseSourcesIds)}`\n )\n console.log(\n `${PREFIX} Knowledgebase Chunks IDs: ${JSON.stringify(toolExecution.knowledgebaseChunksIds)}`\n )\n }\n}\n\nclass DisabledDebugLogger implements DebugLogger {\n logInitialConfig(): void {\n return\n }\n logAgentDebugInfo(): void {\n return\n }\n logModelSettings(): void {\n return\n }\n logRunnerStart(\n _model: string,\n _modelSettings: ModelSettings,\n _prompt: string\n ): void {\n return\n }\n logRunResult(): void {\n return\n }\n logGuardrailTriggered(): void {\n return\n }\n logRunnerError(): void {\n return\n }\n logToolExecution(): void {\n return\n }\n}\n\nexport function createDebugLogger(enableDebug: boolean): DebugLogger {\n return enableDebug ? new EnabledDebugLogger() : new DisabledDebugLogger()\n}\n"],"names":["AiAgentType","LLM_PROVIDER","PREFIX","EnabledDebugLogger","config","console","aiAgentArgs","toolNames","messages","JSON","settings","model","modelSettings","prompt","runResult","startTime","elapsedMs","Date","t","error","toolExecution","DisabledDebugLogger","_model","_modelSettings","_prompt","createDebugLogger","enableDebug"],"mappings":";;;;;AAIsB;AAEoB;AAG1C,MAAME,MAAMA,GAAG;AAsCf,MAAMC,kBAAkBA;IACtB,iBAAiBC,MAAyB,EAAQ;QAChDC,QAAQ,GAAG,CAAC,GAAGH,MAAMA,CAAC,8BAA8B,CAAC;QACrDG,QAAQ,GAAG,CAAC,GAAGH,MAAMA,CAAC,WAAW,EAAED,YAAYA,EAAE;QACjDI,QAAQ,GAAG,CACT,GAAGH,MAAMA,CAAC,8BAA8B,EAAEE,OAAO,wBAAwB,EAAE;QAE7EC,QAAQ,GAAG,CAAC,GAAGH,MAAMA,CAAC,cAAc,EAAEE,OAAO,UAAU,EAAE;QACzDC,QAAQ,GAAG,CAAC,GAAGH,MAAMA,CAAC,UAAU,EAAEE,OAAO,OAAO,CAAC,EAAE,CAA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GAAGH,MAAMA,CAAC,eAAe,EAAEkB,cAAc,WAAW,EAAE;QAClEf,QAAQ,GAAG,CACT,GAAGH,MAAMA,CAAC,4BAA4B,EAAEO,KAAK,SAAS,CAACW,cAAc,uBAAuB,GAAG;QAEjGf,QAAQ,GAAG,CACT,GAAGH,MAAMA,CAAC,2BAA2B,EAAEO,KAAK,SAAS,CAACW,cAAc,sBAAsB,GAAG;IAEjG;AACF;AAEA,MAAMC,mBAAmBA;IACvB,mBAAyB;QACvB;IACF;IACA,oBAA0B;QACxB;IACF;IACA,mBAAyB;QACvB;IACF;IACA,eACEC,MAAc,EACdC,cAA6B,EAC7BC,OAAe,EACT;QACN;IACF;IACA,eAAqB;QACnB;IACF;IACA,wBAA8B;QAC5B;IACF;IACA,iBAAuB;QACrB;IACF;IACA,mBAAyB;QACvB;IACF;AACF;AAEO,SAASC,iBAAiBA,CAACC,WAAoB;IACpD,OAAOA,cAAc,IAAIvB,kBAAkBA,KAAK,IAAIkB,mBAAmBA;AACzE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './input.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guardrails/index.js","sources":["../../src/guardrails/index.ts"],"sourcesContent":["export * from './input'\n"],"names":[],"mappings":";AAAuB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type InputGuardrail } from '@openai/agents';
|
|
2
|
-
import type { LLMConfig } from '../llm-config';
|
|
3
|
-
import type { GuardrailRule } from '../types';
|
|
2
|
+
import type { LLMConfig } from '../llm-config.js';
|
|
3
|
+
import type { GuardrailRule } from '../types.js';
|
|
4
4
|
export interface GuardrailTrackingContext {
|
|
5
5
|
botId: string;
|
|
6
6
|
isTest: boolean;
|