@use-lattice/litmus 0.121.3
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/LICENSE +19 -0
- package/dist/src/accounts-Bt1oJb1Z.cjs +219 -0
- package/dist/src/accounts-DjOU8Rm3.js +178 -0
- package/dist/src/agentic-utils-D03IiXQc.js +153 -0
- package/dist/src/agentic-utils-Dh7xaMQM.cjs +180 -0
- package/dist/src/agents-C6BIMlZa.js +231 -0
- package/dist/src/agents-DvIpNX1L.cjs +666 -0
- package/dist/src/agents-ZP0RP9vV.cjs +231 -0
- package/dist/src/agents-maJXdjbR.js +665 -0
- package/dist/src/aimlapi-BTbQjG2E.cjs +30 -0
- package/dist/src/aimlapi-CwMxqfXP.js +30 -0
- package/dist/src/audio-BBUdvsde.cjs +97 -0
- package/dist/src/audio-D5DPZ7I-.js +97 -0
- package/dist/src/base-BEysXrkq.cjs +222 -0
- package/dist/src/base-C451JQfq.js +193 -0
- package/dist/src/blobs-BY8MDmpo.js +230 -0
- package/dist/src/blobs-BgcNn97m.cjs +256 -0
- package/dist/src/cache-BBE_lsTA.cjs +4 -0
- package/dist/src/cache-BkrqU5Ba.js +237 -0
- package/dist/src/cache-DsCxFlsZ.cjs +297 -0
- package/dist/src/chat-CPJWDP6a.cjs +289 -0
- package/dist/src/chat-CXX3xzkk.cjs +811 -0
- package/dist/src/chat-CcDgZFJ4.js +787 -0
- package/dist/src/chat-Dz5ZeGO2.js +289 -0
- package/dist/src/chatkit-Dw0mKkML.cjs +1158 -0
- package/dist/src/chatkit-swAIVuea.js +1157 -0
- package/dist/src/chunk-DEq-mXcV.js +15 -0
- package/dist/src/claude-agent-sdk-BXZJtOg6.js +379 -0
- package/dist/src/claude-agent-sdk-CkfyjDoG.cjs +383 -0
- package/dist/src/cloudflare-ai-BzpJcqUH.js +161 -0
- package/dist/src/cloudflare-ai-Cmy_R1y2.cjs +161 -0
- package/dist/src/cloudflare-gateway-B9tVQKok.cjs +272 -0
- package/dist/src/cloudflare-gateway-DrD3ew3H.js +272 -0
- package/dist/src/codex-sdk-Dezj9Nwm.js +1056 -0
- package/dist/src/codex-sdk-Dl9D4k5B.cjs +1060 -0
- package/dist/src/cometapi-C-9YvCHC.js +54 -0
- package/dist/src/cometapi-DHgDKoO2.cjs +54 -0
- package/dist/src/completion-B8Ctyxpr.js +120 -0
- package/dist/src/completion-Cxrt08sj.cjs +131 -0
- package/dist/src/createHash-BwgE13yv.cjs +27 -0
- package/dist/src/createHash-DmPQkvBh.js +15 -0
- package/dist/src/docker-BiqcTwLv.js +80 -0
- package/dist/src/docker-C7tEJnP-.cjs +80 -0
- package/dist/src/esm-C62Zofr1.cjs +409 -0
- package/dist/src/esm-DMVc93eh.js +379 -0
- package/dist/src/evalResult-C3NJPQOo.cjs +301 -0
- package/dist/src/evalResult-C7JJAPBb.js +295 -0
- package/dist/src/evalResult-DoVTZZWI.cjs +2 -0
- package/dist/src/extractor-DnMD3fwt.cjs +391 -0
- package/dist/src/extractor-DtlL28vL.js +374 -0
- package/dist/src/fetch-BTxakTSg.cjs +1133 -0
- package/dist/src/fetch-DQckpUFz.js +928 -0
- package/dist/src/fileExtensions-DnqA1y9x.js +85 -0
- package/dist/src/fileExtensions-bYh77CN8.cjs +114 -0
- package/dist/src/genaiTracer-CyZrmaK0.cjs +268 -0
- package/dist/src/genaiTracer-D3fD9dNV.js +256 -0
- package/dist/src/graders-BNscxFrU.js +13644 -0
- package/dist/src/graders-D2oE9Msq.js +2 -0
- package/dist/src/graders-c0Ez_w-9.cjs +2 -0
- package/dist/src/graders-d0F2M3e9.cjs +14056 -0
- package/dist/src/image-0ZhE0VlR.cjs +280 -0
- package/dist/src/image-CWE1pdNv.js +257 -0
- package/dist/src/image-D9ZK6hwL.js +163 -0
- package/dist/src/image-DKZgZITg.cjs +163 -0
- package/dist/src/index.cjs +11366 -0
- package/dist/src/index.d.cts +19640 -0
- package/dist/src/index.d.ts +19641 -0
- package/dist/src/index.js +11306 -0
- package/dist/src/invariant-Ddh24eXh.js +25 -0
- package/dist/src/invariant-kfQ8Bu82.cjs +30 -0
- package/dist/src/knowledgeBase-BgPyGFUd.cjs +122 -0
- package/dist/src/knowledgeBase-DyHilYaP.js +122 -0
- package/dist/src/litellm-CyMeneHS.js +135 -0
- package/dist/src/litellm-DWDF73yF.cjs +135 -0
- package/dist/src/logger-C40ZGil9.js +717 -0
- package/dist/src/logger-DyfK9PBt.cjs +917 -0
- package/dist/src/luma-ray-BAU9X_ep.cjs +315 -0
- package/dist/src/luma-ray-nwVseBbv.js +313 -0
- package/dist/src/messages-B5ADWTTv.js +245 -0
- package/dist/src/messages-BCnZfqrS.cjs +257 -0
- package/dist/src/meteor-DLZZ3osF.cjs +134 -0
- package/dist/src/meteor-DUiCJRC-.js +134 -0
- package/dist/src/modelslab-00cveB8L.cjs +163 -0
- package/dist/src/modelslab-D9sCU_L7.js +163 -0
- package/dist/src/nova-reel-CTapvqYH.js +276 -0
- package/dist/src/nova-reel-DlWuuroF.cjs +278 -0
- package/dist/src/nova-sonic-5UPWfeMv.cjs +363 -0
- package/dist/src/nova-sonic-BhSwQNym.js +363 -0
- package/dist/src/openai-BWrJK9d8.cjs +52 -0
- package/dist/src/openai-DumO8WQn.js +47 -0
- package/dist/src/openclaw-B8brrjC_.cjs +577 -0
- package/dist/src/openclaw-Bkayww9q.js +571 -0
- package/dist/src/opencode-sdk-7xjoDNiM.cjs +562 -0
- package/dist/src/opencode-sdk-SGwAPxht.js +558 -0
- package/dist/src/otlpReceiver-CoAHfAN9.cjs +15 -0
- package/dist/src/otlpReceiver-oO3EQwI9.js +14 -0
- package/dist/src/providerRegistry-4yjhaEM8.js +45 -0
- package/dist/src/providerRegistry-DhV4rJIc.cjs +50 -0
- package/dist/src/providers-B5RJVG-7.cjs +33609 -0
- package/dist/src/providers-BdmZCLzV.js +33262 -0
- package/dist/src/providers-CxtRxn8e.js +2 -0
- package/dist/src/providers-DnQLNbx1.cjs +3 -0
- package/dist/src/pythonUtils-BD0druiM.cjs +275 -0
- package/dist/src/pythonUtils-IBhn5YGR.js +249 -0
- package/dist/src/quiverai-BDOwZBsM.cjs +213 -0
- package/dist/src/quiverai-D3JTF5lD.js +213 -0
- package/dist/src/responses-B2LCDCXZ.js +667 -0
- package/dist/src/responses-BvNm4Xv9.cjs +685 -0
- package/dist/src/rubyUtils-B0NwnfpY.cjs +245 -0
- package/dist/src/rubyUtils-BroxzZ7c.cjs +2 -0
- package/dist/src/rubyUtils-hqVw5UvJ.js +222 -0
- package/dist/src/sagemaker-Cno2V-Sx.js +689 -0
- package/dist/src/sagemaker-fV_KUgs5.cjs +691 -0
- package/dist/src/server-BOuAXb06.cjs +238 -0
- package/dist/src/server-CtI-EWzm.cjs +2 -0
- package/dist/src/server-Cy3DZymt.js +189 -0
- package/dist/src/slack-CP8xBePa.js +135 -0
- package/dist/src/slack-DSQ1yXVb.cjs +135 -0
- package/dist/src/store-BwDDaBjb.cjs +246 -0
- package/dist/src/store-DcbLC593.cjs +2 -0
- package/dist/src/store-IGpqMIkv.js +240 -0
- package/dist/src/tables-3Q2cL7So.cjs +373 -0
- package/dist/src/tables-Bi2fjr4W.js +288 -0
- package/dist/src/telemetry-Bg2WqF79.js +161 -0
- package/dist/src/telemetry-D0x6u5kX.cjs +166 -0
- package/dist/src/telemetry-DXNimrI0.cjs +2 -0
- package/dist/src/text-B_UCRPp2.js +22 -0
- package/dist/src/text-CW1cyrwj.cjs +33 -0
- package/dist/src/tokenUsageUtils-NYT-WKS6.js +138 -0
- package/dist/src/tokenUsageUtils-bVa1ga6f.cjs +173 -0
- package/dist/src/transcription-Cl_W16Pr.js +122 -0
- package/dist/src/transcription-yt1EecY8.cjs +124 -0
- package/dist/src/transform-BCtGrl_W.cjs +228 -0
- package/dist/src/transform-Bv6gG2MJ.cjs +1688 -0
- package/dist/src/transform-CY1wbpRy.js +1507 -0
- package/dist/src/transform-DU8rUL9P.cjs +2 -0
- package/dist/src/transform-yWaShiKr.js +216 -0
- package/dist/src/transformersAvailability-BGkzavwb.js +35 -0
- package/dist/src/transformersAvailability-DKoRtQLy.cjs +35 -0
- package/dist/src/types-5aqHpBwE.cjs +3769 -0
- package/dist/src/types-Bn6D9c4U.js +3300 -0
- package/dist/src/util-BkKlTkI2.js +293 -0
- package/dist/src/util-CTh0bfOm.cjs +1119 -0
- package/dist/src/util-D17oBwo7.cjs +328 -0
- package/dist/src/util-DsS_-v4p.js +613 -0
- package/dist/src/util-DuntT1Ga.js +951 -0
- package/dist/src/util-aWjdCYMI.cjs +667 -0
- package/dist/src/utils-CisQwpjA.js +94 -0
- package/dist/src/utils-yWamDvmz.cjs +123 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/drizzle/0000_lush_hellion.sql +36 -0
- package/drizzle/0001_wide_calypso.sql +3 -0
- package/drizzle/0002_tidy_juggernaut.sql +1 -0
- package/drizzle/0003_lively_naoko.sql +8 -0
- package/drizzle/0004_minor_peter_quill.sql +19 -0
- package/drizzle/0005_silky_millenium_guard.sql +2 -0
- package/drizzle/0006_harsh_caretaker.sql +42 -0
- package/drizzle/0007_cloudy_wong.sql +1 -0
- package/drizzle/0008_broad_boomer.sql +2 -0
- package/drizzle/0009_strong_marten_broadcloak.sql +19 -0
- package/drizzle/0010_needy_bishop.sql +11 -0
- package/drizzle/0011_moaning_millenium_guard.sql +1 -0
- package/drizzle/0012_late_marten_broadcloak.sql +2 -0
- package/drizzle/0013_previous_dormammu.sql +9 -0
- package/drizzle/0014_lazy_captain_universe.sql +2 -0
- package/drizzle/0015_zippy_wallop.sql +29 -0
- package/drizzle/0016_jazzy_zemo.sql +2 -0
- package/drizzle/0017_reflective_praxagora.sql +4 -0
- package/drizzle/0018_fat_vanisher.sql +22 -0
- package/drizzle/0019_new_clint_barton.sql +8 -0
- package/drizzle/0020_skinny_maverick.sql +1 -0
- package/drizzle/0021_mysterious_madelyne_pryor.sql +13 -0
- package/drizzle/0022_sleepy_ultimo.sql +25 -0
- package/drizzle/0023_wooden_mandrill.sql +2 -0
- package/drizzle/AGENTS.md +68 -0
- package/drizzle/CLAUDE.md +1 -0
- package/drizzle/meta/0000_snapshot.json +221 -0
- package/drizzle/meta/0001_snapshot.json +214 -0
- package/drizzle/meta/0002_snapshot.json +221 -0
- package/drizzle/meta/0005_snapshot.json +369 -0
- package/drizzle/meta/0006_snapshot.json +638 -0
- package/drizzle/meta/0007_snapshot.json +640 -0
- package/drizzle/meta/0008_snapshot.json +649 -0
- package/drizzle/meta/0009_snapshot.json +554 -0
- package/drizzle/meta/0010_snapshot.json +619 -0
- package/drizzle/meta/0011_snapshot.json +627 -0
- package/drizzle/meta/0012_snapshot.json +639 -0
- package/drizzle/meta/0013_snapshot.json +717 -0
- package/drizzle/meta/0014_snapshot.json +717 -0
- package/drizzle/meta/0015_snapshot.json +897 -0
- package/drizzle/meta/0016_snapshot.json +1031 -0
- package/drizzle/meta/0018_snapshot.json +1210 -0
- package/drizzle/meta/0019_snapshot.json +1165 -0
- package/drizzle/meta/0020_snapshot.json +1232 -0
- package/drizzle/meta/0021_snapshot.json +1311 -0
- package/drizzle/meta/0022_snapshot.json +1481 -0
- package/drizzle/meta/0023_snapshot.json +1496 -0
- package/drizzle/meta/_journal.json +174 -0
- package/package.json +240 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
const require_logger = require("./logger-DyfK9PBt.cjs");
|
|
2
|
+
const require_cache = require("./cache-DsCxFlsZ.cjs");
|
|
3
|
+
const require_telemetry = require("./telemetry-D0x6u5kX.cjs");
|
|
4
|
+
const require_base = require("./base-BEysXrkq.cjs");
|
|
5
|
+
//#region src/providers/bedrock/agents.ts
|
|
6
|
+
/**
|
|
7
|
+
* AWS Bedrock Agents provider for invoking deployed AI agents.
|
|
8
|
+
* Supports all Bedrock Agents features including memory, knowledge bases, action groups,
|
|
9
|
+
* guardrails, and session management.
|
|
10
|
+
*
|
|
11
|
+
* @example Basic usage
|
|
12
|
+
* ```yaml
|
|
13
|
+
* providers:
|
|
14
|
+
* - bedrock-agent:AGENT_ID
|
|
15
|
+
* config:
|
|
16
|
+
* agentAliasId: PROD_ALIAS
|
|
17
|
+
* region: us-east-1
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example With memory and session
|
|
21
|
+
* ```yaml
|
|
22
|
+
* providers:
|
|
23
|
+
* - bedrock-agent:AGENT_ID
|
|
24
|
+
* config:
|
|
25
|
+
* agentAliasId: PROD_ALIAS
|
|
26
|
+
* sessionId: user-session-123
|
|
27
|
+
* memoryId: LONG_TERM_MEMORY
|
|
28
|
+
* enableTrace: true
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example With guardrails and inference config
|
|
32
|
+
* ```yaml
|
|
33
|
+
* providers:
|
|
34
|
+
* - bedrock-agent:AGENT_ID
|
|
35
|
+
* config:
|
|
36
|
+
* agentAliasId: PROD_ALIAS
|
|
37
|
+
* guardrailConfiguration:
|
|
38
|
+
* guardrailId: GUARDRAIL_ID
|
|
39
|
+
* guardrailVersion: "1"
|
|
40
|
+
* temperature: 0.7 # Can be specified at root level for convenience
|
|
41
|
+
* topP: 0.9
|
|
42
|
+
* maximumLength: 2048
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
var AwsBedrockAgentsProvider = class extends require_base.AwsBedrockGenericProvider {
|
|
46
|
+
agentRuntimeClient;
|
|
47
|
+
config;
|
|
48
|
+
constructor(agentId, options = {}) {
|
|
49
|
+
super(agentId, options);
|
|
50
|
+
if (!agentId && !options.config?.agentId) throw new Error("Agent ID is required. Provide it in the provider path (bedrock-agent:AGENT_ID) or config.");
|
|
51
|
+
this.config = {
|
|
52
|
+
...options.config,
|
|
53
|
+
agentId: options.config?.agentId || agentId
|
|
54
|
+
};
|
|
55
|
+
require_telemetry.telemetry.record("feature_used", {
|
|
56
|
+
feature: "bedrock-agents",
|
|
57
|
+
provider: "bedrock"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
id() {
|
|
61
|
+
return `bedrock-agent:${this.config.agentId}`;
|
|
62
|
+
}
|
|
63
|
+
toString() {
|
|
64
|
+
return `[AWS Bedrock Agents Provider ${this.config.agentId}]`;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get or create the Bedrock Agent Runtime client
|
|
68
|
+
*/
|
|
69
|
+
async getAgentRuntimeClient() {
|
|
70
|
+
if (!this.agentRuntimeClient) {
|
|
71
|
+
const handler = require_base.hasProxyEnv() ? await require_base.createBedrockRequestHandler() : void 0;
|
|
72
|
+
try {
|
|
73
|
+
const { BedrockAgentRuntimeClient } = await import("@aws-sdk/client-bedrock-agent-runtime");
|
|
74
|
+
const credentials = await this.getCredentials();
|
|
75
|
+
this.agentRuntimeClient = new BedrockAgentRuntimeClient({
|
|
76
|
+
region: this.getRegion(),
|
|
77
|
+
maxAttempts: require_logger.getEnvInt("AWS_BEDROCK_MAX_RETRIES", 10),
|
|
78
|
+
retryMode: "adaptive",
|
|
79
|
+
...handler ? { requestHandler: handler } : {},
|
|
80
|
+
...credentials ? { credentials } : {}
|
|
81
|
+
});
|
|
82
|
+
} catch (err) {
|
|
83
|
+
require_logger.logger.error(`Error creating BedrockAgentRuntimeClient: ${err}`);
|
|
84
|
+
throw new Error("The @aws-sdk/client-bedrock-agent-runtime package is required. Please install it: npm install @aws-sdk/client-bedrock-agent-runtime");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return this.agentRuntimeClient;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Build the session state from configuration
|
|
91
|
+
*/
|
|
92
|
+
buildSessionState() {
|
|
93
|
+
if (!this.config.sessionState) return;
|
|
94
|
+
const sessionState = {
|
|
95
|
+
sessionAttributes: this.config.sessionState.sessionAttributes,
|
|
96
|
+
promptSessionAttributes: this.config.sessionState.promptSessionAttributes,
|
|
97
|
+
invocationId: this.config.sessionState.invocationId
|
|
98
|
+
};
|
|
99
|
+
if (this.config.sessionState.returnControlInvocationResults) sessionState.returnControlInvocationResults = this.config.sessionState.returnControlInvocationResults;
|
|
100
|
+
return sessionState;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Build inference configuration from both root-level and nested parameters
|
|
104
|
+
* Root-level parameters take precedence over nested ones for convenience
|
|
105
|
+
*/
|
|
106
|
+
buildInferenceConfig() {
|
|
107
|
+
const hasRootConfig = this.config.temperature !== void 0 || this.config.topP !== void 0 || this.config.topK !== void 0 || this.config.maximumLength !== void 0 || this.config.stopSequences !== void 0;
|
|
108
|
+
const hasNestedConfig = this.config.inferenceConfig !== void 0;
|
|
109
|
+
if (!hasRootConfig && !hasNestedConfig) return;
|
|
110
|
+
const inferenceConfig = {};
|
|
111
|
+
if (this.config.inferenceConfig) {
|
|
112
|
+
if (this.config.inferenceConfig.maximumLength !== void 0) inferenceConfig.maximumLength = this.config.inferenceConfig.maximumLength;
|
|
113
|
+
if (this.config.inferenceConfig.stopSequences !== void 0) inferenceConfig.stopSequences = this.config.inferenceConfig.stopSequences;
|
|
114
|
+
if (this.config.inferenceConfig.temperature !== void 0) inferenceConfig.temperature = this.config.inferenceConfig.temperature;
|
|
115
|
+
if (this.config.inferenceConfig.topP !== void 0) inferenceConfig.topP = this.config.inferenceConfig.topP;
|
|
116
|
+
if (this.config.inferenceConfig.topK !== void 0) inferenceConfig.topK = this.config.inferenceConfig.topK;
|
|
117
|
+
}
|
|
118
|
+
if (this.config.temperature !== void 0) inferenceConfig.temperature = this.config.temperature;
|
|
119
|
+
if (this.config.topP !== void 0) inferenceConfig.topP = this.config.topP;
|
|
120
|
+
if (this.config.topK !== void 0) inferenceConfig.topK = this.config.topK;
|
|
121
|
+
if (this.config.maximumLength !== void 0) inferenceConfig.maximumLength = this.config.maximumLength;
|
|
122
|
+
if (this.config.stopSequences !== void 0) inferenceConfig.stopSequences = this.config.stopSequences;
|
|
123
|
+
return inferenceConfig;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Process the streaming response from the agent
|
|
127
|
+
*/
|
|
128
|
+
async processResponse(response) {
|
|
129
|
+
let output = "";
|
|
130
|
+
const traces = [];
|
|
131
|
+
if (response.completion) {
|
|
132
|
+
const decoder = new TextDecoder();
|
|
133
|
+
try {
|
|
134
|
+
for await (const event of response.completion) {
|
|
135
|
+
if (event.chunk?.bytes) output += decoder.decode(event.chunk.bytes, { stream: true });
|
|
136
|
+
if (this.config.enableTrace && event.trace) traces.push(event.trace);
|
|
137
|
+
}
|
|
138
|
+
output += decoder.decode();
|
|
139
|
+
} catch (error) {
|
|
140
|
+
require_logger.logger.error(`Error processing agent response stream: ${error}`);
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
output,
|
|
146
|
+
trace: traces.length > 0 ? traces : void 0,
|
|
147
|
+
sessionId: response.sessionId
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Invoke the agent with the given prompt
|
|
152
|
+
*/
|
|
153
|
+
async callApi(prompt) {
|
|
154
|
+
if (!this.config.agentAliasId) return { error: "Agent Alias ID is required. Set agentAliasId in the provider config." };
|
|
155
|
+
const client = await this.getAgentRuntimeClient();
|
|
156
|
+
const sessionId = this.config.sessionId || (typeof crypto !== "undefined" && "randomUUID" in crypto ? `session-${crypto.randomUUID()}` : `session-${Date.now()}-${process.hrtime.bigint().toString(36)}`);
|
|
157
|
+
const input = {
|
|
158
|
+
agentId: this.config.agentId,
|
|
159
|
+
agentAliasId: this.config.agentAliasId,
|
|
160
|
+
sessionId,
|
|
161
|
+
inputText: prompt,
|
|
162
|
+
enableTrace: this.config.enableTrace,
|
|
163
|
+
endSession: this.config.endSession,
|
|
164
|
+
sessionState: this.buildSessionState(),
|
|
165
|
+
memoryId: this.config.memoryId,
|
|
166
|
+
...this.buildInferenceConfig() && { inferenceConfig: this.buildInferenceConfig() },
|
|
167
|
+
...this.config.guardrailConfiguration && { guardrailConfiguration: this.config.guardrailConfiguration },
|
|
168
|
+
...this.config.promptOverrideConfiguration && { promptOverrideConfiguration: this.config.promptOverrideConfiguration },
|
|
169
|
+
...this.config.knowledgeBaseConfigurations && { knowledgeBaseConfigurations: this.config.knowledgeBaseConfigurations },
|
|
170
|
+
...this.config.actionGroups && { actionGroups: this.config.actionGroups },
|
|
171
|
+
...this.config.inputDataConfig && { inputDataConfig: this.config.inputDataConfig }
|
|
172
|
+
};
|
|
173
|
+
require_logger.logger.debug(`Invoking Bedrock agent ${this.config.agentId} with session ${sessionId}`);
|
|
174
|
+
const cache = await require_cache.getCache();
|
|
175
|
+
const cacheKey = `bedrock-agent:${this.config.agentId}:${JSON.stringify({
|
|
176
|
+
prompt,
|
|
177
|
+
inferenceConfig: this.buildInferenceConfig(),
|
|
178
|
+
knowledgeBaseConfigurations: this.config.knowledgeBaseConfigurations
|
|
179
|
+
})}`;
|
|
180
|
+
if (require_cache.isCacheEnabled()) {
|
|
181
|
+
const cached = await cache.get(cacheKey);
|
|
182
|
+
if (cached) {
|
|
183
|
+
require_logger.logger.debug("Returning cached Bedrock Agents response");
|
|
184
|
+
try {
|
|
185
|
+
const parsed = JSON.parse(cached);
|
|
186
|
+
if (parsed && typeof parsed === "object") return {
|
|
187
|
+
...parsed,
|
|
188
|
+
cached: true
|
|
189
|
+
};
|
|
190
|
+
} catch {
|
|
191
|
+
require_logger.logger.warn("Failed to parse cached Bedrock Agents response, ignoring cache");
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
const { InvokeAgentCommand } = await import("@aws-sdk/client-bedrock-agent-runtime");
|
|
197
|
+
const response = await client.send(new InvokeAgentCommand(input));
|
|
198
|
+
const { output, trace, sessionId: responseSessionId } = await this.processResponse(response);
|
|
199
|
+
const result = {
|
|
200
|
+
output,
|
|
201
|
+
metadata: {
|
|
202
|
+
...responseSessionId && { sessionId: responseSessionId },
|
|
203
|
+
...trace && { trace },
|
|
204
|
+
...this.config.memoryId && { memoryId: this.config.memoryId },
|
|
205
|
+
...this.config.guardrailConfiguration && { guardrails: {
|
|
206
|
+
applied: true,
|
|
207
|
+
guardrailId: this.config.guardrailConfiguration.guardrailId,
|
|
208
|
+
guardrailVersion: this.config.guardrailConfiguration.guardrailVersion
|
|
209
|
+
} }
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
if (require_cache.isCacheEnabled()) try {
|
|
213
|
+
await cache.set(cacheKey, JSON.stringify(result));
|
|
214
|
+
} catch (err) {
|
|
215
|
+
require_logger.logger.error(`Failed to cache response: ${err}`);
|
|
216
|
+
}
|
|
217
|
+
return result;
|
|
218
|
+
} catch (error) {
|
|
219
|
+
require_logger.logger.error(`Bedrock Agents invocation failed: ${error}`);
|
|
220
|
+
if (error.name === "ResourceNotFoundException") return { error: `Agent or alias not found. Verify agentId: ${this.config.agentId} and agentAliasId: ${this.config.agentAliasId}` };
|
|
221
|
+
else if (error.name === "AccessDeniedException") return { error: "Access denied. Check IAM permissions for bedrock:InvokeAgent" };
|
|
222
|
+
else if (error.name === "ValidationException") return { error: `Invalid configuration: ${error.message}` };
|
|
223
|
+
else if (error.name === "ThrottlingException") return { error: "Rate limit exceeded. Please retry later." };
|
|
224
|
+
return { error: `Failed to invoke agent: ${error.message || String(error)}` };
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
//#endregion
|
|
229
|
+
exports.AwsBedrockAgentsProvider = AwsBedrockAgentsProvider;
|
|
230
|
+
|
|
231
|
+
//# sourceMappingURL=agents-ZP0RP9vV.cjs.map
|