feat: Complete zCode CLI X with Telegram bot integration

- Add full Telegram bot functionality with Z.AI API integration
- Implement 4 tools: Bash, FileEdit, WebSearch, Git
- Add 3 agents: Code Reviewer, Architect, DevOps Engineer
- Add 6 skills for common coding tasks
- Add systemd service file for 24/7 operation
- Add nginx configuration for HTTPS webhook
- Add comprehensive documentation
- Implement WebSocket server for real-time updates
- Add logging system with Winston
- Add environment validation

🤖 zCode CLI X - Agentic coder with Z.AI + Telegram integration
This commit is contained in:
admin
2026-05-05 09:01:26 +00:00
Unverified
parent 4a7035dd92
commit 875c7f9b91
24688 changed files with 3224957 additions and 221 deletions

View File

@@ -0,0 +1,31 @@
import { createAggregatedClient } from "@smithy/smithy-client";
import { BedrockRuntimeClient } from "./BedrockRuntimeClient";
import { ApplyGuardrailCommand, } from "./commands/ApplyGuardrailCommand";
import { ConverseCommand } from "./commands/ConverseCommand";
import { ConverseStreamCommand, } from "./commands/ConverseStreamCommand";
import { CountTokensCommand, } from "./commands/CountTokensCommand";
import { GetAsyncInvokeCommand, } from "./commands/GetAsyncInvokeCommand";
import { InvokeModelCommand, } from "./commands/InvokeModelCommand";
import { InvokeModelWithBidirectionalStreamCommand, } from "./commands/InvokeModelWithBidirectionalStreamCommand";
import { InvokeModelWithResponseStreamCommand, } from "./commands/InvokeModelWithResponseStreamCommand";
import { ListAsyncInvokesCommand, } from "./commands/ListAsyncInvokesCommand";
import { StartAsyncInvokeCommand, } from "./commands/StartAsyncInvokeCommand";
import { paginateListAsyncInvokes } from "./pagination/ListAsyncInvokesPaginator";
const commands = {
ApplyGuardrailCommand,
ConverseCommand,
ConverseStreamCommand,
CountTokensCommand,
GetAsyncInvokeCommand,
InvokeModelCommand,
InvokeModelWithBidirectionalStreamCommand,
InvokeModelWithResponseStreamCommand,
ListAsyncInvokesCommand,
StartAsyncInvokeCommand,
};
const paginators = {
paginateListAsyncInvokes,
};
export class BedrockRuntime extends BedrockRuntimeClient {
}
createAggregatedClient(commands, BedrockRuntime, { paginators });

View File

@@ -0,0 +1,57 @@
import { resolveEventStreamConfig, } from "@aws-sdk/middleware-eventstream";
import { getHostHeaderPlugin, resolveHostHeaderConfig, } from "@aws-sdk/middleware-host-header";
import { getLoggerPlugin } from "@aws-sdk/middleware-logger";
import { getRecursionDetectionPlugin } from "@aws-sdk/middleware-recursion-detection";
import { getUserAgentPlugin, resolveUserAgentConfig, } from "@aws-sdk/middleware-user-agent";
import { resolveWebSocketConfig, } from "@aws-sdk/middleware-websocket";
import { resolveRegionConfig } from "@smithy/config-resolver";
import { DefaultIdentityProviderConfig, getHttpAuthSchemeEndpointRuleSetPlugin, getHttpSigningPlugin, } from "@smithy/core";
import { getSchemaSerdePlugin } from "@smithy/core/schema";
import { resolveEventStreamSerdeConfig, } from "@smithy/eventstream-serde-config-resolver";
import { getContentLengthPlugin } from "@smithy/middleware-content-length";
import { resolveEndpointConfig, } from "@smithy/middleware-endpoint";
import { getRetryPlugin, resolveRetryConfig, } from "@smithy/middleware-retry";
import { Client as __Client, } from "@smithy/smithy-client";
import { defaultBedrockRuntimeHttpAuthSchemeParametersProvider, resolveHttpAuthSchemeConfig, } from "./auth/httpAuthSchemeProvider";
import { resolveClientEndpointParameters, } from "./endpoint/EndpointParameters";
import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig";
import { resolveRuntimeExtensions } from "./runtimeExtensions";
export { __Client };
export class BedrockRuntimeClient extends __Client {
config;
constructor(...[configuration]) {
const _config_0 = __getRuntimeConfig(configuration || {});
super(_config_0);
this.initConfig = _config_0;
const _config_1 = resolveClientEndpointParameters(_config_0);
const _config_2 = resolveUserAgentConfig(_config_1);
const _config_3 = resolveRetryConfig(_config_2);
const _config_4 = resolveRegionConfig(_config_3);
const _config_5 = resolveHostHeaderConfig(_config_4);
const _config_6 = resolveEndpointConfig(_config_5);
const _config_7 = resolveEventStreamSerdeConfig(_config_6);
const _config_8 = resolveHttpAuthSchemeConfig(_config_7);
const _config_9 = resolveEventStreamConfig(_config_8);
const _config_10 = resolveWebSocketConfig(_config_9);
const _config_11 = resolveRuntimeExtensions(_config_10, configuration?.extensions || []);
this.config = _config_11;
this.middlewareStack.use(getSchemaSerdePlugin(this.config));
this.middlewareStack.use(getUserAgentPlugin(this.config));
this.middlewareStack.use(getRetryPlugin(this.config));
this.middlewareStack.use(getContentLengthPlugin(this.config));
this.middlewareStack.use(getHostHeaderPlugin(this.config));
this.middlewareStack.use(getLoggerPlugin(this.config));
this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
this.middlewareStack.use(getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
httpAuthSchemeParametersProvider: defaultBedrockRuntimeHttpAuthSchemeParametersProvider,
identityProviderConfigProvider: async (config) => new DefaultIdentityProviderConfig({
"aws.auth#sigv4": config.credentials,
"smithy.api#httpBearerAuth": config.token,
}),
}));
this.middlewareStack.use(getHttpSigningPlugin(this.config));
}
destroy() {
super.destroy();
}
}

View File

@@ -0,0 +1,46 @@
export const getHttpAuthExtensionConfiguration = (runtimeConfig) => {
const _httpAuthSchemes = runtimeConfig.httpAuthSchemes;
let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider;
let _credentials = runtimeConfig.credentials;
let _token = runtimeConfig.token;
return {
setHttpAuthScheme(httpAuthScheme) {
const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
if (index === -1) {
_httpAuthSchemes.push(httpAuthScheme);
}
else {
_httpAuthSchemes.splice(index, 1, httpAuthScheme);
}
},
httpAuthSchemes() {
return _httpAuthSchemes;
},
setHttpAuthSchemeProvider(httpAuthSchemeProvider) {
_httpAuthSchemeProvider = httpAuthSchemeProvider;
},
httpAuthSchemeProvider() {
return _httpAuthSchemeProvider;
},
setCredentials(credentials) {
_credentials = credentials;
},
credentials() {
return _credentials;
},
setToken(token) {
_token = token;
},
token() {
return _token;
},
};
};
export const resolveHttpAuthRuntimeConfig = (config) => {
return {
httpAuthSchemes: config.httpAuthSchemes(),
httpAuthSchemeProvider: config.httpAuthSchemeProvider(),
credentials: config.credentials(),
token: config.token(),
};
};

View File

@@ -0,0 +1,57 @@
import { resolveAwsSdkSigV4Config, } from "@aws-sdk/core/httpAuthSchemes";
import { doesIdentityRequireRefresh, isIdentityExpired, memoizeIdentityProvider } from "@smithy/core";
import { getSmithyContext, normalizeProvider } from "@smithy/util-middleware";
export const defaultBedrockRuntimeHttpAuthSchemeParametersProvider = async (config, context, input) => {
return {
operation: getSmithyContext(context).operation,
region: await normalizeProvider(config.region)() || (() => {
throw new Error("expected `region` to be configured for `aws.auth#sigv4`");
})(),
};
};
function createAwsAuthSigv4HttpAuthOption(authParameters) {
return {
schemeId: "aws.auth#sigv4",
signingProperties: {
name: "bedrock",
region: authParameters.region,
},
propertiesExtractor: (config, context) => ({
signingProperties: {
config,
context,
},
}),
};
}
function createSmithyApiHttpBearerAuthHttpAuthOption(authParameters) {
return {
schemeId: "smithy.api#httpBearerAuth",
propertiesExtractor: ({ profile, filepath, configFilepath, ignoreCache, }, context) => ({
identityProperties: {
profile,
filepath,
configFilepath,
ignoreCache,
},
}),
};
}
export const defaultBedrockRuntimeHttpAuthSchemeProvider = (authParameters) => {
const options = [];
switch (authParameters.operation) {
default: {
options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
options.push(createSmithyApiHttpBearerAuthHttpAuthOption(authParameters));
}
}
return options;
};
export const resolveHttpAuthSchemeConfig = (config) => {
const token = memoizeIdentityProvider(config.token, isIdentityExpired, doesIdentityRequireRefresh);
const config_0 = resolveAwsSdkSigV4Config(config);
return Object.assign(config_0, {
authSchemePreference: normalizeProvider(config.authSchemePreference ?? []),
token,
});
};

View File

@@ -0,0 +1,16 @@
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { Command as $Command } from "@smithy/smithy-client";
import { commonParams } from "../endpoint/EndpointParameters";
import { ApplyGuardrail$ } from "../schemas/schemas_0";
export { $Command };
export class ApplyGuardrailCommand extends $Command
.classBuilder()
.ep(commonParams)
.m(function (Command, cs, config, o) {
return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
})
.s("AmazonBedrockFrontendService", "ApplyGuardrail", {})
.n("BedrockRuntimeClient", "ApplyGuardrailCommand")
.sc(ApplyGuardrail$)
.build() {
}

View File

@@ -0,0 +1,16 @@
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { Command as $Command } from "@smithy/smithy-client";
import { commonParams } from "../endpoint/EndpointParameters";
import { Converse$ } from "../schemas/schemas_0";
export { $Command };
export class ConverseCommand extends $Command
.classBuilder()
.ep(commonParams)
.m(function (Command, cs, config, o) {
return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
})
.s("AmazonBedrockFrontendService", "Converse", {})
.n("BedrockRuntimeClient", "ConverseCommand")
.sc(Converse$)
.build() {
}

View File

@@ -0,0 +1,20 @@
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { Command as $Command } from "@smithy/smithy-client";
import { commonParams } from "../endpoint/EndpointParameters";
import { ConverseStream$ } from "../schemas/schemas_0";
export { $Command };
export class ConverseStreamCommand extends $Command
.classBuilder()
.ep(commonParams)
.m(function (Command, cs, config, o) {
return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
})
.s("AmazonBedrockFrontendService", "ConverseStream", {
eventStream: {
output: true,
},
})
.n("BedrockRuntimeClient", "ConverseStreamCommand")
.sc(ConverseStream$)
.build() {
}

View File

@@ -0,0 +1,16 @@
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { Command as $Command } from "@smithy/smithy-client";
import { commonParams } from "../endpoint/EndpointParameters";
import { CountTokens$ } from "../schemas/schemas_0";
export { $Command };
export class CountTokensCommand extends $Command
.classBuilder()
.ep(commonParams)
.m(function (Command, cs, config, o) {
return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
})
.s("AmazonBedrockFrontendService", "CountTokens", {})
.n("BedrockRuntimeClient", "CountTokensCommand")
.sc(CountTokens$)
.build() {
}

View File

@@ -0,0 +1,16 @@
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { Command as $Command } from "@smithy/smithy-client";
import { commonParams } from "../endpoint/EndpointParameters";
import { GetAsyncInvoke$ } from "../schemas/schemas_0";
export { $Command };
export class GetAsyncInvokeCommand extends $Command
.classBuilder()
.ep(commonParams)
.m(function (Command, cs, config, o) {
return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
})
.s("AmazonBedrockFrontendService", "GetAsyncInvoke", {})
.n("BedrockRuntimeClient", "GetAsyncInvokeCommand")
.sc(GetAsyncInvoke$)
.build() {
}

View File

@@ -0,0 +1,16 @@
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { Command as $Command } from "@smithy/smithy-client";
import { commonParams } from "../endpoint/EndpointParameters";
import { InvokeModel$ } from "../schemas/schemas_0";
export { $Command };
export class InvokeModelCommand extends $Command
.classBuilder()
.ep(commonParams)
.m(function (Command, cs, config, o) {
return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
})
.s("AmazonBedrockFrontendService", "InvokeModel", {})
.n("BedrockRuntimeClient", "InvokeModelCommand")
.sc(InvokeModel$)
.build() {
}

View File

@@ -0,0 +1,29 @@
import { getEventStreamPlugin } from "@aws-sdk/middleware-eventstream";
import { getWebSocketPlugin } from "@aws-sdk/middleware-websocket";
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { Command as $Command } from "@smithy/smithy-client";
import { commonParams } from "../endpoint/EndpointParameters";
import { InvokeModelWithBidirectionalStream$ } from "../schemas/schemas_0";
export { $Command };
export class InvokeModelWithBidirectionalStreamCommand extends $Command
.classBuilder()
.ep(commonParams)
.m(function (Command, cs, config, o) {
return [
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getEventStreamPlugin(config),
getWebSocketPlugin(config, {
headerPrefix: 'x-amz-bedrock-',
}),
];
})
.s("AmazonBedrockFrontendService", "InvokeModelWithBidirectionalStream", {
eventStream: {
input: true,
output: true,
},
})
.n("BedrockRuntimeClient", "InvokeModelWithBidirectionalStreamCommand")
.sc(InvokeModelWithBidirectionalStream$)
.build() {
}

View File

@@ -0,0 +1,20 @@
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { Command as $Command } from "@smithy/smithy-client";
import { commonParams } from "../endpoint/EndpointParameters";
import { InvokeModelWithResponseStream$ } from "../schemas/schemas_0";
export { $Command };
export class InvokeModelWithResponseStreamCommand extends $Command
.classBuilder()
.ep(commonParams)
.m(function (Command, cs, config, o) {
return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
})
.s("AmazonBedrockFrontendService", "InvokeModelWithResponseStream", {
eventStream: {
output: true,
},
})
.n("BedrockRuntimeClient", "InvokeModelWithResponseStreamCommand")
.sc(InvokeModelWithResponseStream$)
.build() {
}

View File

@@ -0,0 +1,16 @@
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { Command as $Command } from "@smithy/smithy-client";
import { commonParams } from "../endpoint/EndpointParameters";
import { ListAsyncInvokes$ } from "../schemas/schemas_0";
export { $Command };
export class ListAsyncInvokesCommand extends $Command
.classBuilder()
.ep(commonParams)
.m(function (Command, cs, config, o) {
return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
})
.s("AmazonBedrockFrontendService", "ListAsyncInvokes", {})
.n("BedrockRuntimeClient", "ListAsyncInvokesCommand")
.sc(ListAsyncInvokes$)
.build() {
}

View File

@@ -0,0 +1,16 @@
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { Command as $Command } from "@smithy/smithy-client";
import { commonParams } from "../endpoint/EndpointParameters";
import { StartAsyncInvoke$ } from "../schemas/schemas_0";
export { $Command };
export class StartAsyncInvokeCommand extends $Command
.classBuilder()
.ep(commonParams)
.m(function (Command, cs, config, o) {
return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
})
.s("AmazonBedrockFrontendService", "StartAsyncInvoke", {})
.n("BedrockRuntimeClient", "StartAsyncInvokeCommand")
.sc(StartAsyncInvoke$)
.build() {
}

View File

@@ -0,0 +1,10 @@
export * from "./ApplyGuardrailCommand";
export * from "./ConverseCommand";
export * from "./ConverseStreamCommand";
export * from "./CountTokensCommand";
export * from "./GetAsyncInvokeCommand";
export * from "./InvokeModelCommand";
export * from "./InvokeModelWithBidirectionalStreamCommand";
export * from "./InvokeModelWithResponseStreamCommand";
export * from "./ListAsyncInvokesCommand";
export * from "./StartAsyncInvokeCommand";

View File

@@ -0,0 +1,13 @@
export const resolveClientEndpointParameters = (options) => {
return Object.assign(options, {
useDualstackEndpoint: options.useDualstackEndpoint ?? false,
useFipsEndpoint: options.useFipsEndpoint ?? false,
defaultSigningName: "bedrock",
});
};
export const commonParams = {
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
Endpoint: { type: "builtInParams", name: "endpoint" },
Region: { type: "builtInParams", name: "region" },
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
};

View File

@@ -0,0 +1,14 @@
import { awsEndpointFunctions } from "@aws-sdk/util-endpoints";
import { customEndpointFunctions, EndpointCache, resolveEndpoint } from "@smithy/util-endpoints";
import { ruleSet } from "./ruleset";
const cache = new EndpointCache({
size: 50,
params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"],
});
export const defaultEndpointResolver = (endpointParams, context = {}) => {
return cache.get(endpointParams, () => resolveEndpoint(ruleSet, {
endpointParams: endpointParams,
logger: context.logger,
}));
};
customEndpointFunctions.aws = awsEndpointFunctions;

View File

@@ -0,0 +1,4 @@
const s = "required", t = "fn", u = "argv", v = "ref";
const a = true, b = "isSet", c = "booleanEquals", d = "error", e = "endpoint", f = "tree", g = "PartitionResult", h = { [s]: false, "type": "string" }, i = { [s]: true, "default": false, "type": "boolean" }, j = { [v]: "Endpoint" }, k = { [t]: c, [u]: [{ [v]: "UseFIPS" }, true] }, l = { [t]: c, [u]: [{ [v]: "UseDualStack" }, true] }, m = {}, n = { [t]: "getAttr", [u]: [{ [v]: g }, "supportsFIPS"] }, o = { [t]: c, [u]: [true, { [t]: "getAttr", [u]: [{ [v]: g }, "supportsDualStack"] }] }, p = [k], q = [l], r = [{ [v]: "Region" }];
const _data = { version: "1.0", parameters: { Region: h, UseDualStack: i, UseFIPS: i, Endpoint: h }, rules: [{ conditions: [{ [t]: b, [u]: [j] }], rules: [{ conditions: p, error: "Invalid Configuration: FIPS and custom endpoint are not supported", type: d }, { rules: [{ conditions: q, error: "Invalid Configuration: Dualstack and custom endpoint are not supported", type: d }, { endpoint: { url: j, properties: m, headers: m }, type: e }], type: f }], type: f }, { rules: [{ conditions: [{ [t]: b, [u]: r }], rules: [{ conditions: [{ [t]: "aws.partition", [u]: r, assign: g }], rules: [{ conditions: [k, l], rules: [{ conditions: [{ [t]: c, [u]: [a, n] }, o], rules: [{ rules: [{ endpoint: { url: "https://bedrock-runtime-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", properties: m, headers: m }, type: e }], type: f }], type: f }, { error: "FIPS and DualStack are enabled, but this partition does not support one or both", type: d }], type: f }, { conditions: p, rules: [{ conditions: [{ [t]: c, [u]: [n, a] }], rules: [{ rules: [{ endpoint: { url: "https://bedrock-runtime-fips.{Region}.{PartitionResult#dnsSuffix}", properties: m, headers: m }, type: e }], type: f }], type: f }, { error: "FIPS is enabled but this partition does not support FIPS", type: d }], type: f }, { conditions: q, rules: [{ conditions: [o], rules: [{ rules: [{ endpoint: { url: "https://bedrock-runtime.{Region}.{PartitionResult#dualStackDnsSuffix}", properties: m, headers: m }, type: e }], type: f }], type: f }, { error: "DualStack is enabled but this partition does not support DualStack", type: d }], type: f }, { rules: [{ endpoint: { url: "https://bedrock-runtime.{Region}.{PartitionResult#dnsSuffix}", properties: m, headers: m }, type: e }], type: f }], type: f }], type: f }, { error: "Invalid Configuration: Missing Region", type: d }], type: f }] };
export const ruleSet = _data;

View File

@@ -0,0 +1,9 @@
export * from "./BedrockRuntimeClient";
export * from "./BedrockRuntime";
export * from "./commands";
export * from "./schemas/schemas_0";
export * from "./pagination";
export * from "./models/enums";
export * from "./models/errors";
export * from "./models/models_0";
export { BedrockRuntimeServiceException } from "./models/BedrockRuntimeServiceException";

View File

@@ -0,0 +1,8 @@
import { ServiceException as __ServiceException, } from "@smithy/smithy-client";
export { __ServiceException };
export class BedrockRuntimeServiceException extends __ServiceException {
constructor(options) {
super(options);
Object.setPrototypeOf(this, BedrockRuntimeServiceException.prototype);
}
}

View File

@@ -0,0 +1,240 @@
export const AsyncInvokeStatus = {
COMPLETED: "Completed",
FAILED: "Failed",
IN_PROGRESS: "InProgress",
};
export const SortAsyncInvocationBy = {
SUBMISSION_TIME: "SubmissionTime",
};
export const SortOrder = {
ASCENDING: "Ascending",
DESCENDING: "Descending",
};
export const GuardrailImageFormat = {
JPEG: "jpeg",
PNG: "png",
};
export const GuardrailContentQualifier = {
GROUNDING_SOURCE: "grounding_source",
GUARD_CONTENT: "guard_content",
QUERY: "query",
};
export const GuardrailOutputScope = {
FULL: "FULL",
INTERVENTIONS: "INTERVENTIONS",
};
export const GuardrailContentSource = {
INPUT: "INPUT",
OUTPUT: "OUTPUT",
};
export const GuardrailAction = {
GUARDRAIL_INTERVENED: "GUARDRAIL_INTERVENED",
NONE: "NONE",
};
export const GuardrailOrigin = {
ACCOUNT_ENFORCED: "ACCOUNT_ENFORCED",
ORGANIZATION_ENFORCED: "ORGANIZATION_ENFORCED",
REQUEST: "REQUEST",
};
export const GuardrailOwnership = {
CROSS_ACCOUNT: "CROSS_ACCOUNT",
SELF: "SELF",
};
export const GuardrailAutomatedReasoningLogicWarningType = {
ALWAYS_FALSE: "ALWAYS_FALSE",
ALWAYS_TRUE: "ALWAYS_TRUE",
};
export const GuardrailContentPolicyAction = {
BLOCKED: "BLOCKED",
NONE: "NONE",
};
export const GuardrailContentFilterConfidence = {
HIGH: "HIGH",
LOW: "LOW",
MEDIUM: "MEDIUM",
NONE: "NONE",
};
export const GuardrailContentFilterStrength = {
HIGH: "HIGH",
LOW: "LOW",
MEDIUM: "MEDIUM",
NONE: "NONE",
};
export const GuardrailContentFilterType = {
HATE: "HATE",
INSULTS: "INSULTS",
MISCONDUCT: "MISCONDUCT",
PROMPT_ATTACK: "PROMPT_ATTACK",
SEXUAL: "SEXUAL",
VIOLENCE: "VIOLENCE",
};
export const GuardrailContextualGroundingPolicyAction = {
BLOCKED: "BLOCKED",
NONE: "NONE",
};
export const GuardrailContextualGroundingFilterType = {
GROUNDING: "GROUNDING",
RELEVANCE: "RELEVANCE",
};
export const GuardrailSensitiveInformationPolicyAction = {
ANONYMIZED: "ANONYMIZED",
BLOCKED: "BLOCKED",
NONE: "NONE",
};
export const GuardrailPiiEntityType = {
ADDRESS: "ADDRESS",
AGE: "AGE",
AWS_ACCESS_KEY: "AWS_ACCESS_KEY",
AWS_SECRET_KEY: "AWS_SECRET_KEY",
CA_HEALTH_NUMBER: "CA_HEALTH_NUMBER",
CA_SOCIAL_INSURANCE_NUMBER: "CA_SOCIAL_INSURANCE_NUMBER",
CREDIT_DEBIT_CARD_CVV: "CREDIT_DEBIT_CARD_CVV",
CREDIT_DEBIT_CARD_EXPIRY: "CREDIT_DEBIT_CARD_EXPIRY",
CREDIT_DEBIT_CARD_NUMBER: "CREDIT_DEBIT_CARD_NUMBER",
DRIVER_ID: "DRIVER_ID",
EMAIL: "EMAIL",
INTERNATIONAL_BANK_ACCOUNT_NUMBER: "INTERNATIONAL_BANK_ACCOUNT_NUMBER",
IP_ADDRESS: "IP_ADDRESS",
LICENSE_PLATE: "LICENSE_PLATE",
MAC_ADDRESS: "MAC_ADDRESS",
NAME: "NAME",
PASSWORD: "PASSWORD",
PHONE: "PHONE",
PIN: "PIN",
SWIFT_CODE: "SWIFT_CODE",
UK_NATIONAL_HEALTH_SERVICE_NUMBER: "UK_NATIONAL_HEALTH_SERVICE_NUMBER",
UK_NATIONAL_INSURANCE_NUMBER: "UK_NATIONAL_INSURANCE_NUMBER",
UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER: "UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER",
URL: "URL",
USERNAME: "USERNAME",
US_BANK_ACCOUNT_NUMBER: "US_BANK_ACCOUNT_NUMBER",
US_BANK_ROUTING_NUMBER: "US_BANK_ROUTING_NUMBER",
US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER: "US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER",
US_PASSPORT_NUMBER: "US_PASSPORT_NUMBER",
US_SOCIAL_SECURITY_NUMBER: "US_SOCIAL_SECURITY_NUMBER",
VEHICLE_IDENTIFICATION_NUMBER: "VEHICLE_IDENTIFICATION_NUMBER",
};
export const GuardrailTopicPolicyAction = {
BLOCKED: "BLOCKED",
NONE: "NONE",
};
export const GuardrailTopicType = {
DENY: "DENY",
};
export const GuardrailWordPolicyAction = {
BLOCKED: "BLOCKED",
NONE: "NONE",
};
export const GuardrailManagedWordType = {
PROFANITY: "PROFANITY",
};
export const GuardrailTrace = {
DISABLED: "disabled",
ENABLED: "enabled",
ENABLED_FULL: "enabled_full",
};
export const AudioFormat = {
AAC: "aac",
FLAC: "flac",
M4A: "m4a",
MKA: "mka",
MKV: "mkv",
MP3: "mp3",
MP4: "mp4",
MPEG: "mpeg",
MPGA: "mpga",
OGG: "ogg",
OPUS: "opus",
PCM: "pcm",
WAV: "wav",
WEBM: "webm",
X_AAC: "x-aac",
};
export const CacheTTL = {
FIVE_MINUTES: "5m",
ONE_HOUR: "1h",
};
export const CachePointType = {
DEFAULT: "default",
};
export const DocumentFormat = {
CSV: "csv",
DOC: "doc",
DOCX: "docx",
HTML: "html",
MD: "md",
PDF: "pdf",
TXT: "txt",
XLS: "xls",
XLSX: "xlsx",
};
export const GuardrailConverseImageFormat = {
JPEG: "jpeg",
PNG: "png",
};
export const GuardrailConverseContentQualifier = {
GROUNDING_SOURCE: "grounding_source",
GUARD_CONTENT: "guard_content",
QUERY: "query",
};
export const ImageFormat = {
GIF: "gif",
JPEG: "jpeg",
PNG: "png",
WEBP: "webp",
};
export const VideoFormat = {
FLV: "flv",
MKV: "mkv",
MOV: "mov",
MP4: "mp4",
MPEG: "mpeg",
MPG: "mpg",
THREE_GP: "three_gp",
WEBM: "webm",
WMV: "wmv",
};
export const ToolResultStatus = {
ERROR: "error",
SUCCESS: "success",
};
export const ToolUseType = {
SERVER_TOOL_USE: "server_tool_use",
};
export const ConversationRole = {
ASSISTANT: "assistant",
USER: "user",
};
export const OutputFormatType = {
JSON_SCHEMA: "json_schema",
};
export const PerformanceConfigLatency = {
OPTIMIZED: "optimized",
STANDARD: "standard",
};
export const ServiceTierType = {
DEFAULT: "default",
FLEX: "flex",
PRIORITY: "priority",
RESERVED: "reserved",
};
export const StopReason = {
CONTENT_FILTERED: "content_filtered",
END_TURN: "end_turn",
GUARDRAIL_INTERVENED: "guardrail_intervened",
MALFORMED_MODEL_OUTPUT: "malformed_model_output",
MALFORMED_TOOL_USE: "malformed_tool_use",
MAX_TOKENS: "max_tokens",
MODEL_CONTEXT_WINDOW_EXCEEDED: "model_context_window_exceeded",
STOP_SEQUENCE: "stop_sequence",
TOOL_USE: "tool_use",
};
export const GuardrailStreamProcessingMode = {
ASYNC: "async",
SYNC: "sync",
};
export const Trace = {
DISABLED: "DISABLED",
ENABLED: "ENABLED",
ENABLED_FULL: "ENABLED_FULL",
};

View File

@@ -0,0 +1,154 @@
import { BedrockRuntimeServiceException as __BaseException } from "./BedrockRuntimeServiceException";
export class AccessDeniedException extends __BaseException {
name = "AccessDeniedException";
$fault = "client";
constructor(opts) {
super({
name: "AccessDeniedException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, AccessDeniedException.prototype);
}
}
export class InternalServerException extends __BaseException {
name = "InternalServerException";
$fault = "server";
constructor(opts) {
super({
name: "InternalServerException",
$fault: "server",
...opts,
});
Object.setPrototypeOf(this, InternalServerException.prototype);
}
}
export class ThrottlingException extends __BaseException {
name = "ThrottlingException";
$fault = "client";
constructor(opts) {
super({
name: "ThrottlingException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ThrottlingException.prototype);
}
}
export class ValidationException extends __BaseException {
name = "ValidationException";
$fault = "client";
constructor(opts) {
super({
name: "ValidationException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ValidationException.prototype);
}
}
export class ConflictException extends __BaseException {
name = "ConflictException";
$fault = "client";
constructor(opts) {
super({
name: "ConflictException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ConflictException.prototype);
}
}
export class ResourceNotFoundException extends __BaseException {
name = "ResourceNotFoundException";
$fault = "client";
constructor(opts) {
super({
name: "ResourceNotFoundException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ResourceNotFoundException.prototype);
}
}
export class ServiceQuotaExceededException extends __BaseException {
name = "ServiceQuotaExceededException";
$fault = "client";
constructor(opts) {
super({
name: "ServiceQuotaExceededException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ServiceQuotaExceededException.prototype);
}
}
export class ServiceUnavailableException extends __BaseException {
name = "ServiceUnavailableException";
$fault = "server";
constructor(opts) {
super({
name: "ServiceUnavailableException",
$fault: "server",
...opts,
});
Object.setPrototypeOf(this, ServiceUnavailableException.prototype);
}
}
export class ModelErrorException extends __BaseException {
name = "ModelErrorException";
$fault = "client";
originalStatusCode;
resourceName;
constructor(opts) {
super({
name: "ModelErrorException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ModelErrorException.prototype);
this.originalStatusCode = opts.originalStatusCode;
this.resourceName = opts.resourceName;
}
}
export class ModelNotReadyException extends __BaseException {
name = "ModelNotReadyException";
$fault = "client";
$retryable = {};
constructor(opts) {
super({
name: "ModelNotReadyException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ModelNotReadyException.prototype);
}
}
export class ModelTimeoutException extends __BaseException {
name = "ModelTimeoutException";
$fault = "client";
constructor(opts) {
super({
name: "ModelTimeoutException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ModelTimeoutException.prototype);
}
}
export class ModelStreamErrorException extends __BaseException {
name = "ModelStreamErrorException";
$fault = "client";
originalStatusCode;
originalMessage;
constructor(opts) {
super({
name: "ModelStreamErrorException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ModelStreamErrorException.prototype);
this.originalStatusCode = opts.originalStatusCode;
this.originalMessage = opts.originalMessage;
}
}

View File

@@ -0,0 +1,4 @@
import { createPaginator } from "@smithy/core";
import { BedrockRuntimeClient } from "../BedrockRuntimeClient";
import { ListAsyncInvokesCommand, } from "../commands/ListAsyncInvokesCommand";
export const paginateListAsyncInvokes = createPaginator(BedrockRuntimeClient, ListAsyncInvokesCommand, "nextToken", "nextToken", "maxResults");

View File

@@ -0,0 +1,2 @@
export * from "./Interfaces";
export * from "./ListAsyncInvokesPaginator";

View File

@@ -0,0 +1,38 @@
import packageInfo from "../package.json";
import { Sha256 } from "@aws-crypto/sha256-browser";
import { eventStreamPayloadHandlerProvider, WebSocketFetchHandler as WebSocketRequestHandler, } from "@aws-sdk/middleware-websocket";
import { createDefaultUserAgentProvider } from "@aws-sdk/util-user-agent-browser";
import { DEFAULT_USE_DUALSTACK_ENDPOINT, DEFAULT_USE_FIPS_ENDPOINT } from "@smithy/config-resolver";
import { eventStreamSerdeProvider } from "@smithy/eventstream-serde-browser";
import { FetchHttpHandler as HttpRequestHandler, streamCollector } from "@smithy/fetch-http-handler";
import { invalidProvider } from "@smithy/invalid-dependency";
import { loadConfigsForDefaultMode } from "@smithy/smithy-client";
import { calculateBodyLength } from "@smithy/util-body-length-browser";
import { resolveDefaultsModeConfig } from "@smithy/util-defaults-mode-browser";
import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@smithy/util-retry";
import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared";
export const getRuntimeConfig = (config) => {
const defaultsMode = resolveDefaultsModeConfig(config);
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
const clientSharedValues = getSharedRuntimeConfig(config);
return {
...clientSharedValues,
...config,
runtime: "browser",
defaultsMode,
bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
credentialDefaultProvider: config?.credentialDefaultProvider ?? ((_) => () => Promise.reject(new Error("Credential is missing"))),
defaultUserAgentProvider: config?.defaultUserAgentProvider ?? createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
eventStreamPayloadHandlerProvider: config?.eventStreamPayloadHandlerProvider ?? eventStreamPayloadHandlerProvider,
eventStreamSerdeProvider: config?.eventStreamSerdeProvider ?? eventStreamSerdeProvider,
maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
region: config?.region ?? invalidProvider("Region is missing"),
requestHandler: WebSocketRequestHandler.create(config?.requestHandler
?? defaultConfigProvider, HttpRequestHandler.create(defaultConfigProvider)),
retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE),
sha256: config?.sha256 ?? Sha256,
streamCollector: config?.streamCollector ?? streamCollector,
useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)),
useFipsEndpoint: config?.useFipsEndpoint ?? (() => Promise.resolve(DEFAULT_USE_FIPS_ENDPOINT)),
};
};

View File

@@ -0,0 +1,78 @@
import packageInfo from "../package.json";
import { emitWarningIfUnsupportedVersion as awsCheckVersion } from "@aws-sdk/core/client";
import { AwsSdkSigV4Signer, NODE_AUTH_SCHEME_PREFERENCE_OPTIONS } from "@aws-sdk/core/httpAuthSchemes";
import { defaultProvider as credentialDefaultProvider } from "@aws-sdk/credential-provider-node";
import { eventStreamPayloadHandlerProvider } from "@aws-sdk/eventstream-handler-node";
import { fromEnvSigningName, nodeProvider } from "@aws-sdk/token-providers";
import { createDefaultUserAgentProvider, NODE_APP_ID_CONFIG_OPTIONS } from "@aws-sdk/util-user-agent-node";
import { NODE_REGION_CONFIG_FILE_OPTIONS, NODE_REGION_CONFIG_OPTIONS, NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, } from "@smithy/config-resolver";
import { HttpBearerAuthSigner } from "@smithy/core";
import { eventStreamSerdeProvider } from "@smithy/eventstream-serde-node";
import { Hash } from "@smithy/hash-node";
import { NODE_MAX_ATTEMPT_CONFIG_OPTIONS, NODE_RETRY_MODE_CONFIG_OPTIONS } from "@smithy/middleware-retry";
import { loadConfig as loadNodeConfig } from "@smithy/node-config-provider";
import { NodeHttp2Handler as RequestHandler, streamCollector } from "@smithy/node-http-handler";
import { emitWarningIfUnsupportedVersion, loadConfigsForDefaultMode } from "@smithy/smithy-client";
import { calculateBodyLength } from "@smithy/util-body-length-node";
import { resolveDefaultsModeConfig } from "@smithy/util-defaults-mode-node";
import { DEFAULT_RETRY_MODE } from "@smithy/util-retry";
import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared";
export const getRuntimeConfig = (config) => {
emitWarningIfUnsupportedVersion(process.version);
const defaultsMode = resolveDefaultsModeConfig(config);
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
const clientSharedValues = getSharedRuntimeConfig(config);
awsCheckVersion(process.version);
const loaderConfig = {
profile: config?.profile,
logger: clientSharedValues.logger,
signingName: "bedrock",
};
return {
...clientSharedValues,
...config,
runtime: "node",
defaultsMode,
authSchemePreference: config?.authSchemePreference ?? loadNodeConfig(NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, loaderConfig),
bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
credentialDefaultProvider: config?.credentialDefaultProvider ?? credentialDefaultProvider,
defaultUserAgentProvider: config?.defaultUserAgentProvider ?? createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
eventStreamPayloadHandlerProvider: config?.eventStreamPayloadHandlerProvider ?? eventStreamPayloadHandlerProvider,
eventStreamSerdeProvider: config?.eventStreamSerdeProvider ?? eventStreamSerdeProvider,
httpAuthSchemes: config?.httpAuthSchemes ?? [
{
schemeId: "aws.auth#sigv4",
identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4"),
signer: new AwsSdkSigV4Signer(),
},
{
schemeId: "smithy.api#httpBearerAuth",
identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#httpBearerAuth") || (async (idProps) => {
try {
return await fromEnvSigningName({ signingName: "bedrock" })();
}
catch (error) {
return await nodeProvider(idProps)(idProps);
}
}),
signer: new HttpBearerAuthSigner(),
},
],
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
region: config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, { ...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig }),
requestHandler: RequestHandler.create(config?.requestHandler ?? (async () => ({
...await defaultConfigProvider(),
disableConcurrentStreams: true
}))),
retryMode: config?.retryMode ??
loadNodeConfig({
...NODE_RETRY_MODE_CONFIG_OPTIONS,
default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE,
}, config),
sha256: config?.sha256 ?? Hash.bind(null, "sha256"),
streamCollector: config?.streamCollector ?? streamCollector,
useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
useFipsEndpoint: config?.useFipsEndpoint ?? loadNodeConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
userAgentAppId: config?.userAgentAppId ?? loadNodeConfig(NODE_APP_ID_CONFIG_OPTIONS, loaderConfig),
};
};

View File

@@ -0,0 +1,15 @@
import { Sha256 } from "@aws-crypto/sha256-js";
import { invalidFunction } from "@smithy/invalid-dependency";
import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser";
export const getRuntimeConfig = (config) => {
const browserDefaults = getBrowserRuntimeConfig(config);
return {
...browserDefaults,
...config,
runtime: "react-native",
eventStreamPayloadHandlerProvider: config?.eventStreamPayloadHandlerProvider ?? (() => ({
handle: invalidFunction("event stream request is not supported in ReactNative."),
})),
sha256: config?.sha256 ?? Sha256,
};
};

View File

@@ -0,0 +1,45 @@
import { AwsSdkSigV4Signer } from "@aws-sdk/core/httpAuthSchemes";
import { AwsRestJsonProtocol } from "@aws-sdk/core/protocols";
import { HttpBearerAuthSigner } from "@smithy/core";
import { NoOpLogger } from "@smithy/smithy-client";
import { parseUrl } from "@smithy/url-parser";
import { fromBase64, toBase64 } from "@smithy/util-base64";
import { fromUtf8, toUtf8 } from "@smithy/util-utf8";
import { defaultBedrockRuntimeHttpAuthSchemeProvider } from "./auth/httpAuthSchemeProvider";
import { defaultEndpointResolver } from "./endpoint/endpointResolver";
import { errorTypeRegistries } from "./schemas/schemas_0";
export const getRuntimeConfig = (config) => {
return {
apiVersion: "2023-09-30",
base64Decoder: config?.base64Decoder ?? fromBase64,
base64Encoder: config?.base64Encoder ?? toBase64,
disableHostPrefix: config?.disableHostPrefix ?? false,
endpointProvider: config?.endpointProvider ?? defaultEndpointResolver,
extensions: config?.extensions ?? [],
httpAuthSchemeProvider: config?.httpAuthSchemeProvider ?? defaultBedrockRuntimeHttpAuthSchemeProvider,
httpAuthSchemes: config?.httpAuthSchemes ?? [
{
schemeId: "aws.auth#sigv4",
identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4"),
signer: new AwsSdkSigV4Signer(),
},
{
schemeId: "smithy.api#httpBearerAuth",
identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#httpBearerAuth"),
signer: new HttpBearerAuthSigner(),
},
],
logger: config?.logger ?? new NoOpLogger(),
protocol: config?.protocol ?? AwsRestJsonProtocol,
protocolSettings: config?.protocolSettings ?? {
defaultNamespace: "com.amazonaws.bedrockruntime",
errorTypeRegistries,
version: "2023-09-30",
serviceTarget: "AmazonBedrockFrontendService",
},
serviceId: config?.serviceId ?? "Bedrock Runtime",
urlParser: config?.urlParser ?? parseUrl,
utf8Decoder: config?.utf8Decoder ?? fromUtf8,
utf8Encoder: config?.utf8Encoder ?? toUtf8,
};
};

View File

@@ -0,0 +1,9 @@
import { getAwsRegionExtensionConfiguration, resolveAwsRegionExtensionConfiguration, } from "@aws-sdk/region-config-resolver";
import { getHttpHandlerExtensionConfiguration, resolveHttpHandlerRuntimeConfig } from "@smithy/protocol-http";
import { getDefaultExtensionConfiguration, resolveDefaultRuntimeConfig } from "@smithy/smithy-client";
import { getHttpAuthExtensionConfiguration, resolveHttpAuthRuntimeConfig } from "./auth/httpAuthExtensionConfiguration";
export const resolveRuntimeExtensions = (runtimeConfig, extensions) => {
const extensionConfiguration = Object.assign(getAwsRegionExtensionConfiguration(runtimeConfig), getDefaultExtensionConfiguration(runtimeConfig), getHttpHandlerExtensionConfiguration(runtimeConfig), getHttpAuthExtensionConfiguration(runtimeConfig));
extensions.forEach((extension) => extension.configure(extensionConfiguration));
return Object.assign(runtimeConfig, resolveAwsRegionExtensionConfiguration(extensionConfiguration), resolveDefaultRuntimeConfig(extensionConfiguration), resolveHttpHandlerRuntimeConfig(extensionConfiguration), resolveHttpAuthRuntimeConfig(extensionConfiguration));
};