@botonic/plugin-ai-agents 0.43.0 → 0.44.0-alpha.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/lib/cjs/agent-builder.js +0 -1
- package/lib/cjs/agent-builder.js.map +1 -1
- package/lib/cjs/guardrails/input.js +4 -6
- package/lib/cjs/guardrails/input.js.map +1 -1
- package/lib/cjs/hubtype-api-client.js +94 -97
- package/lib/cjs/hubtype-api-client.js.map +1 -1
- package/lib/cjs/index.js +63 -70
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/openai.js +3 -4
- package/lib/cjs/openai.js.map +1 -1
- package/lib/cjs/runner.js +39 -41
- package/lib/cjs/runner.js.map +1 -1
- package/lib/cjs/tools/retrieve-knowledge.js +4 -5
- package/lib/cjs/tools/retrieve-knowledge.js.map +1 -1
- package/lib/esm/agent-builder.js +19 -16
- package/lib/esm/agent-builder.js.map +1 -1
- package/lib/esm/constants.js +13 -10
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/guardrails/index.js +4 -1
- package/lib/esm/guardrails/index.js.map +1 -1
- package/lib/esm/guardrails/input.js +11 -9
- package/lib/esm/guardrails/input.js.map +1 -1
- package/lib/esm/hubtype-api-client.js +102 -101
- package/lib/esm/hubtype-api-client.js.map +1 -1
- package/lib/esm/index.js +76 -80
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/openai.js +24 -20
- package/lib/esm/openai.js.map +1 -1
- package/lib/esm/runner.js +47 -45
- package/lib/esm/runner.js.map +1 -1
- package/lib/esm/structured-output/carousel.js +15 -12
- package/lib/esm/structured-output/carousel.js.map +1 -1
- package/lib/esm/structured-output/exit.js +7 -3
- package/lib/esm/structured-output/exit.js.map +1 -1
- package/lib/esm/structured-output/index.js +10 -7
- package/lib/esm/structured-output/index.js.map +1 -1
- package/lib/esm/structured-output/text-with-buttons.js +12 -8
- package/lib/esm/structured-output/text-with-buttons.js.map +1 -1
- package/lib/esm/structured-output/text.js +8 -5
- package/lib/esm/structured-output/text.js.map +1 -1
- package/lib/esm/tools/index.js +6 -2
- package/lib/esm/tools/index.js.map +1 -1
- package/lib/esm/tools/retrieve-knowledge.js +14 -12
- package/lib/esm/tools/retrieve-knowledge.js.map +1 -1
- package/lib/esm/types.js +2 -1
- package/package.json +5 -5
- package/src/agent-builder.ts +0 -1
- package/src/index.ts +1 -2
package/lib/cjs/runner.js
CHANGED
|
@@ -1,60 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AIAgentRunner = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const agents_1 = require("@openai/agents");
|
|
6
5
|
const tools_1 = require("./tools");
|
|
7
6
|
class AIAgentRunner {
|
|
8
7
|
constructor(agent) {
|
|
9
8
|
this.agent = agent;
|
|
10
9
|
}
|
|
11
|
-
run(messages, context) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
async run(messages, context) {
|
|
11
|
+
try {
|
|
12
|
+
const runner = new agents_1.Runner({
|
|
13
|
+
modelSettings: { temperature: 0 },
|
|
14
|
+
});
|
|
15
|
+
// Type assertion to bypass strict type checking - the actual return type from runner.run()
|
|
16
|
+
// doesn't perfectly match our interface, but the properties we access are compatible
|
|
17
|
+
const result = (await runner.run(this.agent, messages, {
|
|
18
|
+
context,
|
|
19
|
+
}));
|
|
20
|
+
const outputMessages = result.finalOutput?.messages || [];
|
|
21
|
+
const hasExit = outputMessages.length === 0 ||
|
|
22
|
+
outputMessages.some(message => message.type === 'exit');
|
|
23
|
+
const toolsExecuted = this.getToolsExecuted(result, context);
|
|
24
|
+
return {
|
|
25
|
+
messages: hasExit
|
|
26
|
+
? []
|
|
27
|
+
: outputMessages.filter(message => message.type !== 'exit'),
|
|
28
|
+
toolsExecuted,
|
|
29
|
+
exit: hasExit,
|
|
30
|
+
memoryLength: messages.length,
|
|
31
|
+
error: false,
|
|
32
|
+
inputGuardrailsTriggered: [],
|
|
33
|
+
outputGuardrailsTriggered: [],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (error instanceof agents_1.InputGuardrailTripwireTriggered) {
|
|
27
38
|
return {
|
|
28
|
-
messages:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
exit: hasExit,
|
|
33
|
-
memoryLength: messages.length,
|
|
39
|
+
messages: [],
|
|
40
|
+
memoryLength: 0,
|
|
41
|
+
toolsExecuted: [],
|
|
42
|
+
exit: true,
|
|
34
43
|
error: false,
|
|
35
|
-
inputGuardrailsTriggered:
|
|
44
|
+
inputGuardrailsTriggered: error.result.output.outputInfo,
|
|
36
45
|
outputGuardrailsTriggered: [],
|
|
37
46
|
};
|
|
38
47
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
messages: [],
|
|
43
|
-
memoryLength: 0,
|
|
44
|
-
toolsExecuted: [],
|
|
45
|
-
exit: true,
|
|
46
|
-
error: false,
|
|
47
|
-
inputGuardrailsTriggered: error.result.output.outputInfo,
|
|
48
|
-
outputGuardrailsTriggered: [],
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
54
50
|
}
|
|
55
51
|
getToolsExecuted(result, context) {
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
return (result.newItems
|
|
53
|
+
?.filter(item => item instanceof agents_1.RunToolCallItem)
|
|
54
|
+
.map((item) => this.getToolExecutionInfo(item, context))
|
|
55
|
+
.filter((toolExecution) => toolExecution.toolName !== '') || []);
|
|
58
56
|
}
|
|
59
57
|
getToolExecutionInfo(item, context) {
|
|
60
58
|
if (item.rawItem.type !== 'function_call') {
|
package/lib/cjs/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/runner.ts"],"names":[],"mappings":";;;AACA,2CAIuB;AAEvB,mCAA2C;AAkB3C,MAAa,aAAa;IAMxB,YAAY,KAAoC;QAC9C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,GAAG,CACP,QAA+B,EAC/B,OAAsC;QAEtC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;gBACxB,aAAa,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;aAClC,CAAC,CAAA;YACF,2FAA2F;YAC3F,qFAAqF;YACrF,MAAM,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE;gBACrD,OAAO;aACR,CAAC,CAAwB,CAAA;YAE1B,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,EAAE,QAAQ,IAAI,EAAE,CAAA;YACzD,MAAM,OAAO,GACX,cAAc,CAAC,MAAM,KAAK,CAAC;gBAC3B,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAA;YACzD,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;YAE5D,OAAO;gBACL,QAAQ,EAAE,OAAO;oBACf,CAAC,CAAC,EAAE;oBACJ,CAAC,CAAE,cAAc,CAAC,MAAM,CACpB,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CACR;gBAChC,aAAa;gBACb,IAAI,EAAE,OAAO;gBACb,YAAY,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vE,IAAI,QAAQ,KAAK,yBAAiB,CAAC,IAAI,EAAE,CAAC;YACxC,OAAO;gBACL,QAAQ;gBACR,aAAa;gBACb,uBAAuB,EAAE,OAAO,CAAC,aAAa,CAAC,SAAS;gBACxD,sBAAsB,EAAE,OAAO,CAAC,aAAa,CAAC,SAAS;aACxD,CAAA;QACH,CAAC;QAED,OAAO;YACL,QAAQ;YACR,aAAa;SACd,CAAA;IACH,CAAC;IAEO,oBAAoB,CAAC,gBAAwB;QACnD,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,CAAA;QACX,CAAC;IACH,CAAC;CACF;AA9GD,sCA8GC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.retrieveKnowledge = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const agents_1 = require("@openai/agents");
|
|
6
5
|
const zod_1 = require("zod");
|
|
7
6
|
const hubtype_api_client_1 = require("../hubtype-api-client");
|
|
@@ -11,15 +10,15 @@ exports.retrieveKnowledge = (0, agents_1.tool)({
|
|
|
11
10
|
parameters: zod_1.z.object({
|
|
12
11
|
query: zod_1.z.string().describe('The query to search the knowledge base for'),
|
|
13
12
|
}),
|
|
14
|
-
execute: (input, runContext) =>
|
|
15
|
-
const context = runContext
|
|
13
|
+
execute: async (input, runContext) => {
|
|
14
|
+
const context = runContext?.context;
|
|
16
15
|
const query = input.query;
|
|
17
16
|
if (!context) {
|
|
18
17
|
throw new Error('Context is required');
|
|
19
18
|
}
|
|
20
19
|
const sourceIds = context.sourceIds;
|
|
21
20
|
const client = new hubtype_api_client_1.HubtypeApiClient(context.authToken);
|
|
22
|
-
const chunks =
|
|
21
|
+
const chunks = await client.retrieveSimilarChunks(query, sourceIds);
|
|
23
22
|
const chunkTexts = chunks.map(chunk => chunk.text);
|
|
24
23
|
context.knowledgeUsed = {
|
|
25
24
|
query,
|
|
@@ -28,6 +27,6 @@ exports.retrieveKnowledge = (0, agents_1.tool)({
|
|
|
28
27
|
chunkTexts,
|
|
29
28
|
};
|
|
30
29
|
return chunkTexts;
|
|
31
|
-
}
|
|
30
|
+
},
|
|
32
31
|
});
|
|
33
32
|
//# sourceMappingURL=retrieve-knowledge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrieve-knowledge.js","sourceRoot":"","sources":["../../../src/tools/retrieve-knowledge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"retrieve-knowledge.js","sourceRoot":"","sources":["../../../src/tools/retrieve-knowledge.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AACjD,6BAAuB;AAEvB,8DAAwD;AAG3C,QAAA,iBAAiB,GAAG,IAAA,aAAI,EAAC;IACpC,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EACT,kIAAkI;IACpI,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC;QACnB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;KACzE,CAAC;IACF,OAAO,EAAE,KAAK,EACZ,KAAwB,EACxB,UAAgC,EACb,EAAE;QACrB,MAAM,OAAO,GAAG,UAAU,EAAE,OAAO,CAAA;QACnC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QACzB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;QACxC,CAAC;QACD,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;QACnC,MAAM,MAAM,GAAG,IAAI,qCAAgB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QACtD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;QACnE,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAElD,OAAO,CAAC,aAAa,GAAG;YACtB,KAAK;YACL,SAAS;YACT,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;YACxC,UAAU;SACX,CAAA;QAED,OAAO,UAAU,CAAA;IACnB,CAAC;CACF,CAAC,CAAA"}
|
package/lib/esm/agent-builder.js
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AIAgentBuilder = void 0;
|
|
4
|
+
const agents_1 = require("@openai/agents");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const guardrails_1 = require("./guardrails");
|
|
7
|
+
const structured_output_1 = require("./structured-output");
|
|
8
|
+
const tools_1 = require("./tools");
|
|
9
|
+
class AIAgentBuilder {
|
|
7
10
|
constructor(options) {
|
|
8
11
|
this.name = options.name;
|
|
9
12
|
this.instructions = this.addExtraInstructions(options.instructions, options.contactInfo, options.campaignContext);
|
|
10
13
|
this.tools = this.addHubtypeTools(options.tools, options.sourceIds);
|
|
11
14
|
this.inputGuardrails = [];
|
|
12
15
|
if (options.inputGuardrailRules.length > 0) {
|
|
13
|
-
const inputGuardrail = createInputGuardrail(options.inputGuardrailRules);
|
|
16
|
+
const inputGuardrail = (0, guardrails_1.createInputGuardrail)(options.inputGuardrailRules);
|
|
14
17
|
this.inputGuardrails.push(inputGuardrail);
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
20
|
build() {
|
|
18
21
|
const modelSettings = {};
|
|
19
|
-
if (OPENAI_PROVIDER === 'openai') {
|
|
20
|
-
// @ts-expect-error - reasoning.effort is valid but we need to update openai and typescript dependencies
|
|
22
|
+
if (constants_1.OPENAI_PROVIDER === 'openai') {
|
|
21
23
|
modelSettings.reasoning = { effort: 'none' };
|
|
22
24
|
modelSettings.text = { verbosity: 'medium' };
|
|
23
25
|
}
|
|
24
|
-
if (this.tools.includes(retrieveKnowledge) && OPENAI_PROVIDER === 'azure') {
|
|
25
|
-
modelSettings.toolChoice = retrieveKnowledge.name;
|
|
26
|
+
if (this.tools.includes(tools_1.retrieveKnowledge) && constants_1.OPENAI_PROVIDER === 'azure') {
|
|
27
|
+
modelSettings.toolChoice = tools_1.retrieveKnowledge.name;
|
|
26
28
|
}
|
|
27
29
|
// When using standard OpenAI API, we need to specify the model
|
|
28
30
|
// Azure OpenAI uses deployment name instead
|
|
29
|
-
const model = OPENAI_PROVIDER === 'openai' ? OPENAI_MODEL : undefined;
|
|
31
|
+
const model = constants_1.OPENAI_PROVIDER === 'openai' ? constants_1.OPENAI_MODEL : undefined;
|
|
30
32
|
// TODO: Improve type safety - replace AgentOutputType<any> with AgentOutputType<typeof OutputSchema>
|
|
31
33
|
// Currently using explicit type parameters to avoid type inference issues where Agent constructor
|
|
32
34
|
// infers ZodObject instead of AgentOutputType<typeof OutputSchema>. The explicit type parameters
|
|
@@ -34,12 +36,12 @@ export class AIAgentBuilder {
|
|
|
34
36
|
// 1. Update @openai/agents package to properly infer AgentOutputType from outputType parameter
|
|
35
37
|
// 2. Replace AgentOutputType<any> with AgentOutputType<typeof OutputSchema> once type system allows
|
|
36
38
|
// 3. Consider updating AIAgent type definition if @openai/agents types change significantly
|
|
37
|
-
return new Agent({
|
|
39
|
+
return new agents_1.Agent({
|
|
38
40
|
name: this.name,
|
|
39
41
|
model,
|
|
40
42
|
instructions: this.instructions,
|
|
41
43
|
tools: this.tools,
|
|
42
|
-
outputType: OutputSchema,
|
|
44
|
+
outputType: structured_output_1.OutputSchema,
|
|
43
45
|
inputGuardrails: this.inputGuardrails,
|
|
44
46
|
outputGuardrails: [],
|
|
45
47
|
modelSettings,
|
|
@@ -91,11 +93,12 @@ export class AIAgentBuilder {
|
|
|
91
93
|
return `<output>\n${output}\n</output>`;
|
|
92
94
|
}
|
|
93
95
|
addHubtypeTools(tools, sourceIds) {
|
|
94
|
-
const hubtypeTools = [...mandatoryTools];
|
|
96
|
+
const hubtypeTools = [...tools_1.mandatoryTools];
|
|
95
97
|
if (sourceIds.length > 0) {
|
|
96
|
-
hubtypeTools.push(retrieveKnowledge);
|
|
98
|
+
hubtypeTools.push(tools_1.retrieveKnowledge);
|
|
97
99
|
}
|
|
98
100
|
return [...hubtypeTools, ...tools];
|
|
99
101
|
}
|
|
100
102
|
}
|
|
103
|
+
exports.AIAgentBuilder = AIAgentBuilder;
|
|
101
104
|
//# sourceMappingURL=agent-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-builder.js","sourceRoot":"","sources":["../../src/agent-builder.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"agent-builder.js","sourceRoot":"","sources":["../../src/agent-builder.ts"],"names":[],"mappings":";;;AACA,2CAKuB;AAEvB,2CAA2D;AAC3D,6CAAmD;AACnD,2DAAkD;AAClD,mCAA2D;AAgB3D,MAAa,cAAc;IASzB,YAAY,OAAoD;QAC9D,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACxB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,oBAAoB,CAC3C,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,eAAe,CACxB,CAAA;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;QACnE,IAAI,CAAC,eAAe,GAAG,EAAE,CAAA;QACzB,IAAI,OAAO,CAAC,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3C,MAAM,cAAc,GAAG,IAAA,iCAAoB,EAAC,OA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SAAS,CAAC,OAAO,CAAC,cAAc,CAAA;QAC7L,OAAO,aAAa,MAAM,aAAa,CAAA;IACzC,CAAC;IAEO,eAAe,CACrB,KAAmC,EACnC,SAAmB;QAEnB,MAAM,YAAY,GAAW,CAAC,GAAG,sBAAc,CAAC,CAAA;QAChD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,YAAY,CAAC,IAAI,CAAC,yBAAiB,CAAC,CAAA;QACtC,CAAC;QACD,OAAO,CAAC,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC,CAAA;IACpC,CAAC;CACF;AA/HD,wCA+HC"}
|
package/lib/esm/constants.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_MEMORY_LENGTH = exports.isProd = exports.AZURE_OPENAI_API_VERSION = exports.AZURE_OPENAI_API_DEPLOYMENT_NAME = exports.AZURE_OPENAI_API_BASE = exports.AZURE_OPENAI_API_KEY = exports.OPENAI_PROVIDER = exports.OPENAI_MODEL = exports.OPENAI_API_KEY = exports.HUBTYPE_API_URL = void 0;
|
|
4
|
+
exports.HUBTYPE_API_URL = process.env.HUBTYPE_API_URL || 'https://api.hubtype.com';
|
|
2
5
|
// OpenAI Provider Configuration
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
exports.OPENAI_API_KEY = process.env.OPENAI_API_KEY; // pragma: allowlist secret
|
|
7
|
+
exports.OPENAI_MODEL = process.env.OPENAI_MODEL || 'gpt-4.1-mini';
|
|
8
|
+
exports.OPENAI_PROVIDER = process.env.OPENAI_PROVIDER || 'azure';
|
|
6
9
|
// Azure OpenAI Configuration
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
exports.AZURE_OPENAI_API_KEY = process.env.AZURE_OPENAI_API_KEY; // pragma: allowlist secret
|
|
11
|
+
exports.AZURE_OPENAI_API_BASE = process.env.AZURE_OPENAI_API_BASE;
|
|
12
|
+
exports.AZURE_OPENAI_API_DEPLOYMENT_NAME = process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME || 'gpt-41-mini_p1';
|
|
13
|
+
exports.AZURE_OPENAI_API_VERSION = process.env.AZURE_OPENAI_API_VERSION || '2025-01-01-preview';
|
|
14
|
+
exports.isProd = process.env.NODE_ENV === 'production';
|
|
15
|
+
exports.MAX_MEMORY_LENGTH = 25;
|
|
13
16
|
//# sourceMappingURL=constants.js.map
|
package/lib/esm/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAC1B,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAA;AAE1D,gCAAgC;AACnB,QAAA,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAA,CAAC,2BAA2B;AACvE,QAAA,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,cAAc,CAAA;AACzD,QAAA,eAAe,GACzB,OAAO,CAAC,GAAG,CAAC,eAAsC,IAAI,OAAO,CAAA;AAEhE,6BAA6B;AAChB,QAAA,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA,CAAC,2BAA2B;AACnF,QAAA,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAA;AACzD,QAAA,gCAAgC,GAC3C,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,gBAAgB,CAAA;AACrD,QAAA,wBAAwB,GACnC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,oBAAoB,CAAA;AAEjD,QAAA,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAA;AAE9C,QAAA,iBAAiB,GAAG,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/guardrails/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/guardrails/index.ts"],"names":[],"mappings":";;;AAAA,kDAAuB"}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInputGuardrail = createInputGuardrail;
|
|
4
|
+
const agents_1 = require("@openai/agents");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
function createInputGuardrail(rules) {
|
|
7
|
+
const outputType = zod_1.z.object(Object.fromEntries(rules.map(rule => [rule.name, zod_1.z.boolean().describe(rule.description)])));
|
|
8
|
+
const agent = new agents_1.Agent({
|
|
7
9
|
name: 'InputGuardrail',
|
|
8
10
|
instructions: 'Check if the user triggers some of the following guardrails.',
|
|
9
11
|
outputType,
|
|
10
12
|
});
|
|
11
13
|
return {
|
|
12
14
|
name: 'InputGuardrail',
|
|
13
|
-
execute: ({ input, context }) =>
|
|
15
|
+
execute: async ({ input, context }) => {
|
|
14
16
|
const lastMessage = input[input.length - 1];
|
|
15
|
-
const result =
|
|
17
|
+
const result = await (0, agents_1.run)(agent, [lastMessage], { context });
|
|
16
18
|
const finalOutput = result.finalOutput;
|
|
17
19
|
if (finalOutput === undefined) {
|
|
18
20
|
throw new Error('Guardrail agent failed to produce output');
|
|
@@ -23,7 +25,7 @@ export function createInputGuardrail(rules) {
|
|
|
23
25
|
outputInfo: triggeredGuardrails,
|
|
24
26
|
tripwireTriggered: triggered,
|
|
25
27
|
};
|
|
26
|
-
}
|
|
28
|
+
},
|
|
27
29
|
};
|
|
28
30
|
}
|
|
29
31
|
//# sourceMappingURL=input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/guardrails/input.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/guardrails/input.ts"],"names":[],"mappings":";;AAKA,oDAiCC;AAtCD,2CAA4E;AAC5E,6BAAuB;AAIvB,SAAgB,oBAAoB,CAAC,KAAsB;IACzD,MAAM,UAAU,GAAG,OAAC,CAAC,MAAM,CACzB,MAAM,CAAC,WAAW,CAChB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CACvE,CACF,CAAA;IAED,MAAM,KAAK,GAAG,IAAI,cAAK,CAAC;QACtB,IAAI,EAAE,gBAAgB;QACtB,YAAY,EACV,8DAA8D;QAChE,UAAU;KACX,CAAC,CAAA;IAEF,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE;YACpC,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAoB,CAAA;YAC9D,MAAM,MAAM,GAAG,MAAM,IAAA,YAAG,EAAC,KAAK,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;YAC3D,MAAM,WAAW,GAAG,MAAM,CAAC,WAAsC,CAAA;YACjE,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;YAC7D,CAAC;YACD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,CAAA;YAC1E,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CACzD,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,IAAI,CACjC,CAAA;YACD,OAAO;gBACL,UAAU,EAAE,mBAAmB;gBAC/B,iBAAiB,EAAE,SAAS;aAC7B,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HubtypeApiClient = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
class HubtypeApiClient {
|
|
5
8
|
constructor(authToken) {
|
|
6
9
|
this.authToken = authToken;
|
|
7
10
|
}
|
|
8
|
-
retrieveSimilarChunks(query, sourceIds) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return chunks;
|
|
26
|
-
});
|
|
11
|
+
async retrieveSimilarChunks(query, sourceIds) {
|
|
12
|
+
const url = `${constants_1.HUBTYPE_API_URL}/external/v1/ai/knowledge_base/similar_chunks/`;
|
|
13
|
+
const headers = {
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
Authorization: `Bearer ${this.authToken}`,
|
|
16
|
+
};
|
|
17
|
+
const params = {
|
|
18
|
+
query,
|
|
19
|
+
source_ids: sourceIds,
|
|
20
|
+
num_chunks: 5,
|
|
21
|
+
};
|
|
22
|
+
const response = await axios_1.default.post(url, params, { headers });
|
|
23
|
+
const chunks = response.data.chunks.map((chunk) => ({
|
|
24
|
+
id: chunk.id,
|
|
25
|
+
text: chunk.text,
|
|
26
|
+
}));
|
|
27
|
+
return chunks;
|
|
27
28
|
}
|
|
28
|
-
getLocalMessages(maxMemoryLength) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return filteredMessages.slice(-maxMemoryLength);
|
|
43
|
-
});
|
|
29
|
+
async getLocalMessages(maxMemoryLength) {
|
|
30
|
+
const localBotonicState = typeof globalThis !== 'undefined' && globalThis.localStorage
|
|
31
|
+
? globalThis.localStorage.getItem('botonicState')
|
|
32
|
+
: null;
|
|
33
|
+
const botonicState = JSON.parse(localBotonicState || '{}');
|
|
34
|
+
const messages = botonicState.messages;
|
|
35
|
+
const filteredMessages = messages
|
|
36
|
+
.filter(message => message.data.text)
|
|
37
|
+
.map(message => ({
|
|
38
|
+
role: message.sentBy === 'user' ? 'user' : 'assistant',
|
|
39
|
+
content: message.data.text,
|
|
40
|
+
}))
|
|
41
|
+
.map(message => this.formatMessage(message));
|
|
42
|
+
return filteredMessages.slice(-maxMemoryLength);
|
|
44
43
|
}
|
|
45
|
-
getMessages(request, maxMemoryLength) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
});
|
|
44
|
+
async getMessages(request, maxMemoryLength) {
|
|
45
|
+
const url = `${constants_1.HUBTYPE_API_URL}/external/v1/ai/agent/message_history/`;
|
|
46
|
+
const headers = {
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
Authorization: `Bearer ${this.authToken}`,
|
|
49
|
+
};
|
|
50
|
+
const params = {
|
|
51
|
+
last_message_id: request.input.message_id,
|
|
52
|
+
num_messages: maxMemoryLength,
|
|
53
|
+
};
|
|
54
|
+
try {
|
|
55
|
+
const response = await axios_1.default.get(url, {
|
|
56
|
+
headers,
|
|
57
|
+
params,
|
|
58
|
+
});
|
|
59
|
+
const messages = response.data.messages;
|
|
60
|
+
return messages.map(message => this.formatMessage(message));
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
console.error(error);
|
|
64
|
+
throw new Error('Failed to get messages from Hubtype');
|
|
65
|
+
}
|
|
69
66
|
}
|
|
70
|
-
getMessagesV2(request, options = {}) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
async getMessagesV2(request, options = {}) {
|
|
68
|
+
const url = `${constants_1.HUBTYPE_API_URL}/external/v2/ai/agent/message_history/`;
|
|
69
|
+
const headers = {
|
|
70
|
+
'Content-Type': 'application/json',
|
|
71
|
+
Authorization: `Bearer ${this.authToken}`,
|
|
72
|
+
};
|
|
73
|
+
const params = {
|
|
74
|
+
last_message_id: request.input.message_id,
|
|
75
|
+
...(options.maxMessages !== undefined && {
|
|
78
76
|
max_messages: options.maxMessages,
|
|
79
|
-
})
|
|
77
|
+
}),
|
|
78
|
+
...(options.includeToolCalls !== undefined && {
|
|
80
79
|
include_tool_calls: options.includeToolCalls,
|
|
81
|
-
})
|
|
80
|
+
}),
|
|
81
|
+
...(options.maxFullToolResults !== undefined && {
|
|
82
82
|
max_full_tool_results: options.maxFullToolResults,
|
|
83
|
-
})
|
|
83
|
+
}),
|
|
84
|
+
...(options.debugMode !== undefined && {
|
|
84
85
|
debug_mode: options.debugMode,
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
86
|
+
}),
|
|
87
|
+
};
|
|
88
|
+
try {
|
|
89
|
+
const response = await axios_1.default.get(url, {
|
|
90
|
+
headers,
|
|
91
|
+
params,
|
|
92
|
+
});
|
|
93
|
+
const { messages, conversation_id, truncated } = response.data;
|
|
94
|
+
const formattedMessages = messages
|
|
95
|
+
.map(message => this.formatMessageV2(message))
|
|
96
|
+
.filter((message) => message !== null);
|
|
97
|
+
return {
|
|
98
|
+
messages: formattedMessages,
|
|
99
|
+
conversationId: conversation_id,
|
|
100
|
+
truncated,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
console.error(error);
|
|
105
|
+
throw new Error('Failed to get messages from Hubtype V2 API');
|
|
106
|
+
}
|
|
106
107
|
}
|
|
107
108
|
formatMessageV2(message) {
|
|
108
|
-
var _a, _b, _c, _d, _e;
|
|
109
109
|
switch (message.role) {
|
|
110
110
|
case 'user':
|
|
111
111
|
return {
|
|
112
112
|
role: 'user',
|
|
113
|
-
content:
|
|
113
|
+
content: message.content ?? '',
|
|
114
114
|
};
|
|
115
115
|
case 'assistant': {
|
|
116
116
|
const assistantMessage = message;
|
|
@@ -121,7 +121,7 @@ export class HubtypeApiClient {
|
|
|
121
121
|
assistantMessage.tool_calls.length > 0) {
|
|
122
122
|
return {
|
|
123
123
|
role: 'assistant',
|
|
124
|
-
content:
|
|
124
|
+
content: assistantMessage.content ?? '',
|
|
125
125
|
tool_calls: assistantMessage.tool_calls.map(tc => ({
|
|
126
126
|
id: tc.id,
|
|
127
127
|
type: tc.type,
|
|
@@ -138,7 +138,7 @@ export class HubtypeApiClient {
|
|
|
138
138
|
content: [
|
|
139
139
|
{
|
|
140
140
|
type: 'output_text',
|
|
141
|
-
text:
|
|
141
|
+
text: assistantMessage.content ?? '',
|
|
142
142
|
},
|
|
143
143
|
],
|
|
144
144
|
status: 'completed',
|
|
@@ -152,13 +152,13 @@ export class HubtypeApiClient {
|
|
|
152
152
|
return {
|
|
153
153
|
role: 'tool',
|
|
154
154
|
tool_call_id: toolMessage.tool_call_id,
|
|
155
|
-
content:
|
|
155
|
+
content: toolMessage.content ?? '',
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
158
|
case 'system':
|
|
159
159
|
return {
|
|
160
160
|
role: 'system',
|
|
161
|
-
content:
|
|
161
|
+
content: message.content ?? '',
|
|
162
162
|
};
|
|
163
163
|
default:
|
|
164
164
|
throw new Error(`Invalid message role: ${message.role}`);
|
|
@@ -188,4 +188,5 @@ export class HubtypeApiClient {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
+
exports.HubtypeApiClient = HubtypeApiClient;
|
|
191
192
|
//# sourceMappingURL=hubtype-api-client.js.map
|