wickr-bedrock-bot
Version:
AWS Wickr's own Bedrock Bot
1,284 lines • 97.1 kB
JavaScript
import { awsExpectUnion as __expectUnion, loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody, } from "@aws-sdk/core";
import { requestBuilder as rb } from "@smithy/core";
import { _json, collectBody, decorateServiceException as __decorateServiceException, expectBoolean as __expectBoolean, expectInt32 as __expectInt32, expectLong as __expectLong, expectNonNull as __expectNonNull, expectObject as __expectObject, expectString as __expectString, isSerializableHeaderValue, limitedParseDouble as __limitedParseDouble, limitedParseFloat32 as __limitedParseFloat32, map, parseRfc3339DateTimeWithOffset as __parseRfc3339DateTimeWithOffset, serializeDateTime as __serializeDateTime, serializeFloat as __serializeFloat, take, withBaseException, } from "@smithy/smithy-client";
import { BedrockAgentRuntimeServiceException as __BaseException } from "../models/BedrockAgentRuntimeServiceException";
import { AccessDeniedException, BadGatewayException, BedrockSessionContentBlock, ConflictException, DependencyFailedException, FlowInputContent, ImageInputSource, ImageSource, InternalServerException, InvocationResultMember, InvocationStepPayload, ModelNotReadyException, ResourceNotFoundException, ServiceQuotaExceededException, ThrottlingException, ValidationException, } from "../models/models_0";
import { RetrievalFilter, } from "../models/models_1";
export const se_CreateInvocationCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/sessions/{sessionIdentifier}/invocations");
b.p("sessionIdentifier", () => input.sessionIdentifier, "{sessionIdentifier}", false);
let body;
body = JSON.stringify(take(input, {
description: [],
invocationId: [],
}));
b.m("PUT").h(headers).b(body);
return b.build();
};
export const se_CreateSessionCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/sessions");
let body;
body = JSON.stringify(take(input, {
encryptionKeyArn: [],
sessionMetadata: (_) => _json(_),
tags: (_) => _json(_),
}));
b.m("PUT").h(headers).b(body);
return b.build();
};
export const se_DeleteAgentMemoryCommand = async (input, context) => {
const b = rb(input, context);
const headers = {};
b.bp("/agents/{agentId}/agentAliases/{agentAliasId}/memories");
b.p("agentId", () => input.agentId, "{agentId}", false);
b.p("agentAliasId", () => input.agentAliasId, "{agentAliasId}", false);
const query = map({
[_mI]: [, input[_mI]],
[_sI]: [, input[_sI]],
});
let body;
b.m("DELETE").h(headers).q(query).b(body);
return b.build();
};
export const se_DeleteSessionCommand = async (input, context) => {
const b = rb(input, context);
const headers = {};
b.bp("/sessions/{sessionIdentifier}");
b.p("sessionIdentifier", () => input.sessionIdentifier, "{sessionIdentifier}", false);
let body;
b.m("DELETE").h(headers).b(body);
return b.build();
};
export const se_EndSessionCommand = async (input, context) => {
const b = rb(input, context);
const headers = {};
b.bp("/sessions/{sessionIdentifier}");
b.p("sessionIdentifier", () => input.sessionIdentifier, "{sessionIdentifier}", false);
let body;
b.m("PATCH").h(headers).b(body);
return b.build();
};
export const se_GenerateQueryCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/generateQuery");
let body;
body = JSON.stringify(take(input, {
queryGenerationInput: (_) => _json(_),
transformationConfiguration: (_) => _json(_),
}));
b.m("POST").h(headers).b(body);
return b.build();
};
export const se_GetAgentMemoryCommand = async (input, context) => {
const b = rb(input, context);
const headers = {};
b.bp("/agents/{agentId}/agentAliases/{agentAliasId}/memories");
b.p("agentId", () => input.agentId, "{agentId}", false);
b.p("agentAliasId", () => input.agentAliasId, "{agentAliasId}", false);
const query = map({
[_nT]: [, input[_nT]],
[_mIa]: [() => input.maxItems !== void 0, () => input[_mIa].toString()],
[_mT]: [, __expectNonNull(input[_mT], `memoryType`)],
[_mI]: [, __expectNonNull(input[_mI], `memoryId`)],
});
let body;
b.m("GET").h(headers).q(query).b(body);
return b.build();
};
export const se_GetInvocationStepCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/sessions/{sessionIdentifier}/invocationSteps/{invocationStepId}");
b.p("invocationStepId", () => input.invocationStepId, "{invocationStepId}", false);
b.p("sessionIdentifier", () => input.sessionIdentifier, "{sessionIdentifier}", false);
let body;
body = JSON.stringify(take(input, {
invocationIdentifier: [],
}));
b.m("POST").h(headers).b(body);
return b.build();
};
export const se_GetSessionCommand = async (input, context) => {
const b = rb(input, context);
const headers = {};
b.bp("/sessions/{sessionIdentifier}");
b.p("sessionIdentifier", () => input.sessionIdentifier, "{sessionIdentifier}", false);
let body;
b.m("GET").h(headers).b(body);
return b.build();
};
export const se_InvokeAgentCommand = async (input, context) => {
const b = rb(input, context);
const headers = map({}, isSerializableHeaderValue, {
"content-type": "application/json",
[_xasa]: input[_sA],
});
b.bp("/agents/{agentId}/agentAliases/{agentAliasId}/sessions/{sessionId}/text");
b.p("agentId", () => input.agentId, "{agentId}", false);
b.p("agentAliasId", () => input.agentAliasId, "{agentAliasId}", false);
b.p("sessionId", () => input.sessionId, "{sessionId}", false);
let body;
body = JSON.stringify(take(input, {
bedrockModelConfigurations: (_) => _json(_),
enableTrace: [],
endSession: [],
inputText: [],
memoryId: [],
sessionState: (_) => se_SessionState(_, context),
streamingConfigurations: (_) => _json(_),
}));
b.m("POST").h(headers).b(body);
return b.build();
};
export const se_InvokeFlowCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/flows/{flowIdentifier}/aliases/{flowAliasIdentifier}");
b.p("flowIdentifier", () => input.flowIdentifier, "{flowIdentifier}", false);
b.p("flowAliasIdentifier", () => input.flowAliasIdentifier, "{flowAliasIdentifier}", false);
let body;
body = JSON.stringify(take(input, {
enableTrace: [],
executionId: [],
inputs: (_) => se_FlowInputs(_, context),
modelPerformanceConfiguration: (_) => _json(_),
}));
b.m("POST").h(headers).b(body);
return b.build();
};
export const se_InvokeInlineAgentCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/agents/{sessionId}");
b.p("sessionId", () => input.sessionId, "{sessionId}", false);
let body;
body = JSON.stringify(take(input, {
actionGroups: (_) => _json(_),
agentCollaboration: [],
agentName: [],
bedrockModelConfigurations: (_) => _json(_),
collaboratorConfigurations: (_) => _json(_),
collaborators: (_) => se_Collaborators(_, context),
customOrchestration: (_) => _json(_),
customerEncryptionKeyArn: [],
enableTrace: [],
endSession: [],
foundationModel: [],
guardrailConfiguration: (_) => _json(_),
idleSessionTTLInSeconds: [],
inlineSessionState: (_) => se_InlineSessionState(_, context),
inputText: [],
instruction: [],
knowledgeBases: (_) => se_KnowledgeBases(_, context),
orchestrationType: [],
promptOverrideConfiguration: (_) => se_PromptOverrideConfiguration(_, context),
streamingConfigurations: (_) => _json(_),
}));
b.m("POST").h(headers).b(body);
return b.build();
};
export const se_ListInvocationsCommand = async (input, context) => {
const b = rb(input, context);
const headers = {};
b.bp("/sessions/{sessionIdentifier}/invocations");
b.p("sessionIdentifier", () => input.sessionIdentifier, "{sessionIdentifier}", false);
const query = map({
[_nT]: [, input[_nT]],
[_mR]: [() => input.maxResults !== void 0, () => input[_mR].toString()],
});
let body;
b.m("POST").h(headers).q(query).b(body);
return b.build();
};
export const se_ListInvocationStepsCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/sessions/{sessionIdentifier}/invocationSteps");
b.p("sessionIdentifier", () => input.sessionIdentifier, "{sessionIdentifier}", false);
const query = map({
[_nT]: [, input[_nT]],
[_mR]: [() => input.maxResults !== void 0, () => input[_mR].toString()],
});
let body;
body = JSON.stringify(take(input, {
invocationIdentifier: [],
}));
b.m("POST").h(headers).q(query).b(body);
return b.build();
};
export const se_ListSessionsCommand = async (input, context) => {
const b = rb(input, context);
const headers = {};
b.bp("/sessions");
const query = map({
[_mR]: [() => input.maxResults !== void 0, () => input[_mR].toString()],
[_nT]: [, input[_nT]],
});
let body;
b.m("POST").h(headers).q(query).b(body);
return b.build();
};
export const se_ListTagsForResourceCommand = async (input, context) => {
const b = rb(input, context);
const headers = {};
b.bp("/tags/{resourceArn}");
b.p("resourceArn", () => input.resourceArn, "{resourceArn}", false);
let body;
b.m("GET").h(headers).b(body);
return b.build();
};
export const se_OptimizePromptCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/optimize-prompt");
let body;
body = JSON.stringify(take(input, {
input: (_) => _json(_),
targetModelId: [],
}));
b.m("POST").h(headers).b(body);
return b.build();
};
export const se_PutInvocationStepCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/sessions/{sessionIdentifier}/invocationSteps");
b.p("sessionIdentifier", () => input.sessionIdentifier, "{sessionIdentifier}", false);
let body;
body = JSON.stringify(take(input, {
invocationIdentifier: [],
invocationStepId: [],
invocationStepTime: (_) => __serializeDateTime(_),
payload: (_) => se_InvocationStepPayload(_, context),
}));
b.m("PUT").h(headers).b(body);
return b.build();
};
export const se_RerankCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/rerank");
let body;
body = JSON.stringify(take(input, {
nextToken: [],
queries: (_) => _json(_),
rerankingConfiguration: (_) => se_RerankingConfiguration(_, context),
sources: (_) => se_RerankSourcesList(_, context),
}));
b.m("POST").h(headers).b(body);
return b.build();
};
export const se_RetrieveCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/knowledgebases/{knowledgeBaseId}/retrieve");
b.p("knowledgeBaseId", () => input.knowledgeBaseId, "{knowledgeBaseId}", false);
let body;
body = JSON.stringify(take(input, {
guardrailConfiguration: (_) => _json(_),
nextToken: [],
retrievalConfiguration: (_) => se_KnowledgeBaseRetrievalConfiguration(_, context),
retrievalQuery: (_) => _json(_),
}));
b.m("POST").h(headers).b(body);
return b.build();
};
export const se_RetrieveAndGenerateCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/retrieveAndGenerate");
let body;
body = JSON.stringify(take(input, {
input: (_) => _json(_),
retrieveAndGenerateConfiguration: (_) => se_RetrieveAndGenerateConfiguration(_, context),
sessionConfiguration: (_) => _json(_),
sessionId: [],
}));
b.m("POST").h(headers).b(body);
return b.build();
};
export const se_RetrieveAndGenerateStreamCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/retrieveAndGenerateStream");
let body;
body = JSON.stringify(take(input, {
input: (_) => _json(_),
retrieveAndGenerateConfiguration: (_) => se_RetrieveAndGenerateConfiguration(_, context),
sessionConfiguration: (_) => _json(_),
sessionId: [],
}));
b.m("POST").h(headers).b(body);
return b.build();
};
export const se_TagResourceCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/tags/{resourceArn}");
b.p("resourceArn", () => input.resourceArn, "{resourceArn}", false);
let body;
body = JSON.stringify(take(input, {
tags: (_) => _json(_),
}));
b.m("POST").h(headers).b(body);
return b.build();
};
export const se_UntagResourceCommand = async (input, context) => {
const b = rb(input, context);
const headers = {};
b.bp("/tags/{resourceArn}");
b.p("resourceArn", () => input.resourceArn, "{resourceArn}", false);
const query = map({
[_tK]: [__expectNonNull(input.tagKeys, `tagKeys`) != null, () => input[_tK] || []],
});
let body;
b.m("DELETE").h(headers).q(query).b(body);
return b.build();
};
export const se_UpdateSessionCommand = async (input, context) => {
const b = rb(input, context);
const headers = {
"content-type": "application/json",
};
b.bp("/sessions/{sessionIdentifier}");
b.p("sessionIdentifier", () => input.sessionIdentifier, "{sessionIdentifier}", false);
let body;
body = JSON.stringify(take(input, {
sessionMetadata: (_) => _json(_),
}));
b.m("PUT").h(headers).b(body);
return b.build();
};
export const de_CreateInvocationCommand = async (output, context) => {
if (output.statusCode !== 201 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
createdAt: (_) => __expectNonNull(__parseRfc3339DateTimeWithOffset(_)),
invocationId: __expectString,
sessionId: __expectString,
});
Object.assign(contents, doc);
return contents;
};
export const de_CreateSessionCommand = async (output, context) => {
if (output.statusCode !== 201 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
createdAt: (_) => __expectNonNull(__parseRfc3339DateTimeWithOffset(_)),
sessionArn: __expectString,
sessionId: __expectString,
sessionStatus: __expectString,
});
Object.assign(contents, doc);
return contents;
};
export const de_DeleteAgentMemoryCommand = async (output, context) => {
if (output.statusCode !== 202 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
await collectBody(output.body, context);
return contents;
};
export const de_DeleteSessionCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
await collectBody(output.body, context);
return contents;
};
export const de_EndSessionCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
sessionArn: __expectString,
sessionId: __expectString,
sessionStatus: __expectString,
});
Object.assign(contents, doc);
return contents;
};
export const de_GenerateQueryCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
queries: _json,
});
Object.assign(contents, doc);
return contents;
};
export const de_GetAgentMemoryCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
memoryContents: (_) => de_Memories(_, context),
nextToken: __expectString,
});
Object.assign(contents, doc);
return contents;
};
export const de_GetInvocationStepCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
invocationStep: (_) => de_InvocationStep(_, context),
});
Object.assign(contents, doc);
return contents;
};
export const de_GetSessionCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
createdAt: (_) => __expectNonNull(__parseRfc3339DateTimeWithOffset(_)),
encryptionKeyArn: __expectString,
lastUpdatedAt: (_) => __expectNonNull(__parseRfc3339DateTimeWithOffset(_)),
sessionArn: __expectString,
sessionId: __expectString,
sessionMetadata: _json,
sessionStatus: __expectString,
});
Object.assign(contents, doc);
return contents;
};
export const de_InvokeAgentCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
[_cT]: [, output.headers[_xabact]],
[_sI]: [, output.headers[_xabasi]],
[_mI]: [, output.headers[_xabami]],
});
const data = output.body;
contents.completion = de_ResponseStream(data, context);
return contents;
};
export const de_InvokeFlowCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
[_eI]: [, output.headers[_xabfei]],
});
const data = output.body;
contents.responseStream = de_FlowResponseStream(data, context);
return contents;
};
export const de_InvokeInlineAgentCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
[_cT]: [, output.headers[_xabact]],
[_sI]: [, output.headers[_xabasi]],
});
const data = output.body;
contents.completion = de_InlineAgentResponseStream(data, context);
return contents;
};
export const de_ListInvocationsCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
invocationSummaries: (_) => de_InvocationSummaries(_, context),
nextToken: __expectString,
});
Object.assign(contents, doc);
return contents;
};
export const de_ListInvocationStepsCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
invocationStepSummaries: (_) => de_InvocationStepSummaries(_, context),
nextToken: __expectString,
});
Object.assign(contents, doc);
return contents;
};
export const de_ListSessionsCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
nextToken: __expectString,
sessionSummaries: (_) => de_SessionSummaries(_, context),
});
Object.assign(contents, doc);
return contents;
};
export const de_ListTagsForResourceCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
tags: _json,
});
Object.assign(contents, doc);
return contents;
};
export const de_OptimizePromptCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = output.body;
contents.optimizedPrompt = de_OptimizedPromptStream(data, context);
return contents;
};
export const de_PutInvocationStepCommand = async (output, context) => {
if (output.statusCode !== 201 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
invocationStepId: __expectString,
});
Object.assign(contents, doc);
return contents;
};
export const de_RerankCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
nextToken: __expectString,
results: (_) => de_RerankResultsList(_, context),
});
Object.assign(contents, doc);
return contents;
};
export const de_RetrieveCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
guardrailAction: __expectString,
nextToken: __expectString,
retrievalResults: (_) => de_KnowledgeBaseRetrievalResults(_, context),
});
Object.assign(contents, doc);
return contents;
};
export const de_RetrieveAndGenerateCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
citations: (_) => de_Citations(_, context),
guardrailAction: __expectString,
output: _json,
sessionId: __expectString,
});
Object.assign(contents, doc);
return contents;
};
export const de_RetrieveAndGenerateStreamCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
[_sI]: [, output.headers[_xabkbsi]],
});
const data = output.body;
contents.stream = de_RetrieveAndGenerateStreamResponseOutput(data, context);
return contents;
};
export const de_TagResourceCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
await collectBody(output.body, context);
return contents;
};
export const de_UntagResourceCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
await collectBody(output.body, context);
return contents;
};
export const de_UpdateSessionCommand = async (output, context) => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents = map({
$metadata: deserializeMetadata(output),
});
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
createdAt: (_) => __expectNonNull(__parseRfc3339DateTimeWithOffset(_)),
lastUpdatedAt: (_) => __expectNonNull(__parseRfc3339DateTimeWithOffset(_)),
sessionArn: __expectString,
sessionId: __expectString,
sessionStatus: __expectString,
});
Object.assign(contents, doc);
return contents;
};
const de_CommandError = async (output, context) => {
const parsedOutput = {
...output,
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
case "AccessDeniedException":
case "com.amazonaws.bedrockagentruntime#AccessDeniedException":
throw await de_AccessDeniedExceptionRes(parsedOutput, context);
case "ConflictException":
case "com.amazonaws.bedrockagentruntime#ConflictException":
throw await de_ConflictExceptionRes(parsedOutput, context);
case "InternalServerException":
case "com.amazonaws.bedrockagentruntime#InternalServerException":
throw await de_InternalServerExceptionRes(parsedOutput, context);
case "ResourceNotFoundException":
case "com.amazonaws.bedrockagentruntime#ResourceNotFoundException":
throw await de_ResourceNotFoundExceptionRes(parsedOutput, context);
case "ServiceQuotaExceededException":
case "com.amazonaws.bedrockagentruntime#ServiceQuotaExceededException":
throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context);
case "ThrottlingException":
case "com.amazonaws.bedrockagentruntime#ThrottlingException":
throw await de_ThrottlingExceptionRes(parsedOutput, context);
case "ValidationException":
case "com.amazonaws.bedrockagentruntime#ValidationException":
throw await de_ValidationExceptionRes(parsedOutput, context);
case "BadGatewayException":
case "com.amazonaws.bedrockagentruntime#BadGatewayException":
throw await de_BadGatewayExceptionRes(parsedOutput, context);
case "DependencyFailedException":
case "com.amazonaws.bedrockagentruntime#DependencyFailedException":
throw await de_DependencyFailedExceptionRes(parsedOutput, context);
case "ModelNotReadyException":
case "com.amazonaws.bedrockagentruntime#ModelNotReadyException":
throw await de_ModelNotReadyExceptionRes(parsedOutput, context);
default:
const parsedBody = parsedOutput.body;
return throwDefaultError({
output,
parsedBody,
errorCode,
});
}
};
const throwDefaultError = withBaseException(__BaseException);
const de_AccessDeniedExceptionRes = async (parsedOutput, context) => {
const contents = map({});
const data = parsedOutput.body;
const doc = take(data, {
message: __expectString,
});
Object.assign(contents, doc);
const exception = new AccessDeniedException({
$metadata: deserializeMetadata(parsedOutput),
...contents,
});
return __decorateServiceException(exception, parsedOutput.body);
};
const de_BadGatewayExceptionRes = async (parsedOutput, context) => {
const contents = map({});
const data = parsedOutput.body;
const doc = take(data, {
message: __expectString,
resourceName: __expectString,
});
Object.assign(contents, doc);
const exception = new BadGatewayException({
$metadata: deserializeMetadata(parsedOutput),
...contents,
});
return __decorateServiceException(exception, parsedOutput.body);
};
const de_ConflictExceptionRes = async (parsedOutput, context) => {
const contents = map({});
const data = parsedOutput.body;
const doc = take(data, {
message: __expectString,
});
Object.assign(contents, doc);
const exception = new ConflictException({
$metadata: deserializeMetadata(parsedOutput),
...contents,
});
return __decorateServiceException(exception, parsedOutput.body);
};
const de_DependencyFailedExceptionRes = async (parsedOutput, context) => {
const contents = map({});
const data = parsedOutput.body;
const doc = take(data, {
message: __expectString,
resourceName: __expectString,
});
Object.assign(contents, doc);
const exception = new DependencyFailedException({
$metadata: deserializeMetadata(parsedOutput),
...contents,
});
return __decorateServiceException(exception, parsedOutput.body);
};
const de_InternalServerExceptionRes = async (parsedOutput, context) => {
const contents = map({});
const data = parsedOutput.body;
const doc = take(data, {
message: __expectString,
reason: __expectString,
});
Object.assign(contents, doc);
const exception = new InternalServerException({
$metadata: deserializeMetadata(parsedOutput),
...contents,
});
return __decorateServiceException(exception, parsedOutput.body);
};
const de_ModelNotReadyExceptionRes = async (parsedOutput, context) => {
const contents = map({});
const data = parsedOutput.body;
const doc = take(data, {
message: __expectString,
});
Object.assign(contents, doc);
const exception = new ModelNotReadyException({
$metadata: deserializeMetadata(parsedOutput),
...contents,
});
return __decorateServiceException(exception, parsedOutput.body);
};
const de_ResourceNotFoundExceptionRes = async (parsedOutput, context) => {
const contents = map({});
const data = parsedOutput.body;
const doc = take(data, {
message: __expectString,
});
Object.assign(contents, doc);
const exception = new ResourceNotFoundException({
$metadata: deserializeMetadata(parsedOutput),
...contents,
});
return __decorateServiceException(exception, parsedOutput.body);
};
const de_ServiceQuotaExceededExceptionRes = async (parsedOutput, context) => {
const contents = map({});
const data = parsedOutput.body;
const doc = take(data, {
message: __expectString,
});
Object.assign(contents, doc);
const exception = new ServiceQuotaExceededException({
$metadata: deserializeMetadata(parsedOutput),
...contents,
});
return __decorateServiceException(exception, parsedOutput.body);
};
const de_ThrottlingExceptionRes = async (parsedOutput, context) => {
const contents = map({});
const data = parsedOutput.body;
const doc = take(data, {
message: __expectString,
});
Object.assign(contents, doc);
const exception = new ThrottlingException({
$metadata: deserializeMetadata(parsedOutput),
...contents,
});
return __decorateServiceException(exception, parsedOutput.body);
};
const de_ValidationExceptionRes = async (parsedOutput, context) => {
const contents = map({});
const data = parsedOutput.body;
const doc = take(data, {
message: __expectString,
});
Object.assign(contents, doc);
const exception = new ValidationException({
$metadata: deserializeMetadata(parsedOutput),
...contents,
});
return __decorateServiceException(exception, parsedOutput.body);
};
const de_FlowResponseStream = (output, context) => {
return context.eventStreamMarshaller.deserialize(output, async (event) => {
if (event["flowOutputEvent"] != null) {
return {
flowOutputEvent: await de_FlowOutputEvent_event(event["flowOutputEvent"], context),
};
}
if (event["flowCompletionEvent"] != null) {
return {
flowCompletionEvent: await de_FlowCompletionEvent_event(event["flowCompletionEvent"], context),
};
}
if (event["flowTraceEvent"] != null) {
return {
flowTraceEvent: await de_FlowTraceEvent_event(event["flowTraceEvent"], context),
};
}
if (event["internalServerException"] != null) {
return {
internalServerException: await de_InternalServerException_event(event["internalServerException"], context),
};
}
if (event["validationException"] != null) {
return {
validationException: await de_ValidationException_event(event["validationException"], context),
};
}
if (event["resourceNotFoundException"] != null) {
return {
resourceNotFoundException: await de_ResourceNotFoundException_event(event["resourceNotFoundException"], context),
};
}
if (event["serviceQuotaExceededException"] != null) {
return {
serviceQuotaExceededException: await de_ServiceQuotaExceededException_event(event["serviceQuotaExceededException"], context),
};
}
if (event["throttlingException"] != null) {
return {
throttlingException: await de_ThrottlingException_event(event["throttlingException"], context),
};
}
if (event["accessDeniedException"] != null) {
return {
accessDeniedException: await de_AccessDeniedException_event(event["accessDeniedException"], context),
};
}
if (event["conflictException"] != null) {
return {
conflictException: await de_ConflictException_event(event["conflictException"], context),
};
}
if (event["dependencyFailedException"] != null) {
return {
dependencyFailedException: await de_DependencyFailedException_event(event["dependencyFailedException"], context),
};
}
if (event["badGatewayException"] != null) {
return {
badGatewayException: await de_BadGatewayException_event(event["badGatewayException"], context),
};
}
if (event["flowMultiTurnInputRequestEvent"] != null) {
return {
flowMultiTurnInputRequestEvent: await de_FlowMultiTurnInputRequestEvent_event(event["flowMultiTurnInputRequestEvent"], context),
};
}
return { $unknown: output };
});
};
const de_InlineAgentResponseStream = (output, context) => {
return context.eventStreamMarshaller.deserialize(output, async (event) => {
if (event["chunk"] != null) {
return {
chunk: await de_InlineAgentPayloadPart_event(event["chunk"], context),
};
}
if (event["trace"] != null) {
return {
trace: await de_InlineAgentTracePart_event(event["trace"], context),
};
}
if (event["returnControl"] != null) {
return {
returnControl: await de_InlineAgentReturnControlPayload_event(event["returnControl"], context),
};
}
if (event["internalServerException"] != null) {
return {
internalServerException: await de_InternalServerException_event(event["internalServerException"], context),
};
}
if (event["validationException"] != null) {
return {
validationException: await de_ValidationException_event(event["validationException"], context),
};
}
if (event["resourceNotFoundException"] != null) {
return {
resourceNotFoundException: await de_ResourceNotFoundException_event(event["resourceNotFoundException"], context),
};
}
if (event["serviceQuotaExceededException"] != null) {
return {
serviceQuotaExceededException: await de_ServiceQuotaExceededException_event(event["serviceQuotaExceededException"], context),
};
}
if (event["throttlingException"] != null) {
return {
throttlingException: await de_ThrottlingException_event(event["throttlingException"], context),
};
}
if (event["accessDeniedException"] != null) {
return {
accessDeniedException: await de_AccessDeniedException_event(event["accessDeniedException"], context),
};
}
if (event["conflictException"] != null) {
return {
conflictException: await de_ConflictException_event(event["conflictException"], context),
};
}
if (event["dependencyFailedException"] != null) {
return {
dependencyFailedException: await de_DependencyFailedException_event(event["dependencyFailedException"], context),
};
}
if (event["badGatewayException"] != null) {
return {
badGatewayException: await de_BadGatewayException_event(event["badGatewayException"], context),
};
}
if (event["files"] != null) {
return {
files: await de_InlineAgentFilePart_event(event["files"], context),
};
}
return { $unknown: output };
});
};
const de_OptimizedPromptStream = (output, context) => {
return context.eventStreamMarshaller.deserialize(output, async (event) => {
if (event["optimizedPromptEvent"] != null) {
return {
optimizedPromptEvent: await de_OptimizedPromptEvent_event(event["optimizedPromptEvent"], context),
};
}
if (event["analyzePromptEvent"] != null) {
return {
analyzePromptEvent: await de_AnalyzePromptEvent_event(event["analyzePromptEvent"], context),
};
}
if (event["internalServerException"] != null) {
return {
internalServerException: await de_InternalServerException_event(event["internalServerException"], context),
};
}
if (event["throttlingException"] != null) {
return {
throttlingException: await de_ThrottlingException_event(event["throttlingException"], context),
};
}
if (event["validationException"] != null) {
return {
validationException: await de_ValidationException_event(event["validationException"], context),
};
}
if (event["dependencyFailedException"] != null) {
return {
dependencyFailedException: await de_DependencyFailedException_event(event["dependencyFailedException"], context),
};
}
if (event["accessDeniedException"] != null) {
return {
accessDeniedException: await de_AccessDeniedException_event(event["accessDeniedException"], context),
};
}
if (event["badGatewayException"] != null) {
return {
badGatewayException: await de_BadGatewayException_event(event["badGatewayException"], context),
};
}
return { $unknown: output };
});
};
const de_ResponseStream = (output, context) => {
return context.eventStreamMarshaller.deserialize(output, async (event) => {
if (event["chunk"] != null) {
return {
chunk: await de_PayloadPart_event(event["chunk"], context),
};
}
if (event["trace"] != null) {
return {
trace: await de_TracePart_event(event["trace"], context),
};
}
if (event["returnControl"] != null) {
return {
returnControl: await de_ReturnControlPayload_event(event["returnControl"], context),
};
}
if (event["internalServerException"] != null) {
return {
internalServerException: await de_InternalServerException_event(event["internalServerException"], context),
};
}
if (event["validationException"] != null) {
return {
validationException: await de_ValidationException_event(event["validationException"], context),
};
}
if (event["resourceNotFoundException"] != null) {
return {
resourceNotFoundException: await de_ResourceNotFoundException_event(event["resourceNotFoundException"], context),
};
}
if (event["serviceQuotaExceededException"] != null) {
return {
serviceQuotaExceededException: await de_ServiceQuotaExceededException_event(event["serviceQuotaExceededException"], context),
};
}
if (event["throttlingException"] != null) {
return {
throttlingException: await de_ThrottlingException_event(event["throttlingException"], context),
};
}
if (event["accessDeniedException"] != null) {
return {
accessDeniedException: await de_AccessDeniedException_event(event["accessDeniedException"], context),
};
}
if (event["conflictException"] != null) {
return {
conflictException: await de_ConflictException_event(event["conflictException"], context),
};
}
if (event["dependencyFailedException"] != null) {
return {
dependencyFailedException: await de_DependencyFailedException_event(event["dependencyFailedException"], context),
};
}
if (event["badGatewayException"] != null) {
return {
badGatewayException: await de_BadGatewayException_event(event["badGatewayException"], context),
};
}
if (event["modelNotReadyException"] != null) {
return {
modelNotReadyException: await de_ModelNotReadyException_event(event["modelNotReadyException"], context),
};
}
if (event["files"] != null) {
return {
files: await de_FilePart_event(event["files"], context),
};
}
return { $unknown: output };
});
};
const de_RetrieveAndGenerateStreamResponseOutput = (output, context) => {
return context.eventStreamMarshaller.deserialize(output, async (event) => {
if (event["output"] != null) {
return {
output: await de_RetrieveAndGenerateOutputEvent_event(event["output"], context),
};
}
if (event["citation"] != null) {
return {
citation: await de_CitationEvent_event(event["citation"], context),
};
}
if (event["guardrail"] != null) {
return {
guardrail: await de_GuardrailEvent_event(event["guardrail"], context),
};
}
if (event["internalServerException"] != null) {
return {
internalServerException: await de_InternalServerException_event(event["internalServerException"], context),
};
}
if (event["validationException"] != null) {
return {
validationException: await de_ValidationException_event(event["validationException"], context),
};
}
if (event["resourceNotFoundException"] != null) {
return {
resourceNotFoundException: await de_ResourceNotFoundException_event(event["resourceNotFoundException"], context),
};
}
if (event["serviceQuotaExceededException"] != null) {
return {
serviceQuotaExceededException: await de_ServiceQuotaExceededException_event(event["serviceQuotaExceededException"], context),
};
}
if (event["throttlingException"] != null) {
return {
throttlingException: await de_ThrottlingException_event(event["throttlingException"], context),
};
}
if (event["accessDeniedException"] != null) {
return {
accessDeniedException: await de_AccessDeniedException_event(event["accessDeniedException"], context),
};
}
if (event["conflictException"] != null) {
return {
conflictException: await de_ConflictException_event(event["conflictException"], context),
};
}
if (event["dependencyFailedException"] != null) {
return {
dependencyFailedException: await de_DependencyFailedException_event(event["dependencyFailedException"], context),
};
}
if (event["badGatewayException"] != null) {
return {
badGatewayException: await de_BadGatewayException_event(event["badGatewayException"], context),
};
}
return { $unknown: output };
});
};
const de_AccessDeniedException_event = async (output, context) => {
const parsedOutput = {
...output,
body: await parseBody(output.body, context),
};
return de_AccessDeniedExceptionRes(parsedOutput, context);
};
const de_AnalyzePromptEvent_event = async (output, context) => {
const contents = {};
const data = await parseBody(output.body, context);
Object.assign(contents, _json(data));
return contents;
};
const de_BadGatewayException_event = async (output, context) => {
const parsedOutput = {
...output,
body: await parseBody(output.body, context),
};
return de_BadGatewayExceptionRes(parsedOutput, context);
};
const de_CitationEvent_event = async (output, context) => {
const contents = {};
const data = await parseBody(output.body, context);
Object.assign(contents, de_CitationEvent(data, context));
return contents;
};
const de_ConflictException_event = async (output, context) => {
const parsedOutput = {
...output,
body: await parseBody(output.body, context),
};
return de_ConflictExceptionRes(parsedOutput, context);
};
const de_DependencyFailedException_event = async (output, context) => {
const parsedOutput = {
...output,
body: await parseBody(output.body, context),
};
return de_DependencyFailedExceptionRes(parsedOutput, context);
};
const de_FilePart_event = async (output, context) => {
c