bailian-cli-core 1.1.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -731,24 +731,22 @@ interface McpToolResult {
731
731
  }>;
732
732
  isError?: boolean;
733
733
  }
734
+ /**
735
+ * Compose the streamable-HTTP MCP endpoint for a Bailian MCP server.
736
+ * The path is `/api/v1/mcps/<serverCode>/mcp`; the `serverCode` is taken
737
+ * verbatim from `bl mcp list` (e.g. `WebSearch`, `market-cmapi00073529`).
738
+ */
739
+ declare function bailianMcpUrl(baseUrl: string, serverCode: string): string;
734
740
  declare class McpClient {
735
- private baseUrl;
741
+ private url;
736
742
  private sessionId;
737
743
  private nextId;
738
744
  private config;
739
745
  private authToken;
740
- constructor(config: Config, baseUrl: string);
741
- /**
742
- * Initialize the MCP session. Must be called before any other method.
743
- */
746
+ constructor(config: Config, url: string);
747
+ /** Initialize the MCP session. Must be called before any other method. */
744
748
  initialize(): Promise<void>;
745
- /**
746
- * List available tools from the MCP server.
747
- */
748
749
  listTools(): Promise<McpTool[]>;
749
- /**
750
- * Call a tool on the MCP server.
751
- */
752
750
  callTool(name: string, args: Record<string, unknown>): Promise<McpToolResult>;
753
751
  private rpc;
754
752
  private notify;
@@ -783,6 +781,21 @@ declare function callConsoleGateway(config: Config, token: string | undefined, {
783
781
  region
784
782
  }: ConsoleGatewayRequest): Promise<unknown>;
785
783
  //#endregion
784
+ //#region src/console/models.d.ts
785
+ interface ModelListParams {
786
+ pageNo?: number;
787
+ pageSize?: number;
788
+ name?: string;
789
+ providers?: string[];
790
+ capabilities?: string[];
791
+ region?: string;
792
+ }
793
+ interface ModelListResult {
794
+ total: number;
795
+ models: Record<string, unknown>[];
796
+ }
797
+ declare function fetchModelList(config: Config, token: string, params?: ModelListParams): Promise<ModelListResult>;
798
+ //#endregion
786
799
  //#region src/types/flags.d.ts
787
800
  interface GlobalFlags {
788
801
  apiKey?: string;
@@ -944,6 +957,18 @@ declare function isCI(): boolean;
944
957
  */
945
958
  declare function stripUndefined<T extends Record<string, unknown>>(obj: T): T;
946
959
  //#endregion
960
+ //#region src/utils/boolean-flag.d.ts
961
+ /** Parse true/false from CLI flags (e.g. `--watermark <bool>`). */
962
+ declare function parseBooleanValue(value: unknown, label?: string): boolean;
963
+ declare function parseOptionalBooleanValue(value: unknown, label?: string): boolean | undefined;
964
+ /**
965
+ * Resolve a tri-state boolean CLI flag (`--name <bool>`).
966
+ * Returns `defaultWhenUnset` when the flag is omitted.
967
+ */
968
+ declare function resolveBooleanFlag(flagValue: unknown, defaultWhenUnset: boolean | undefined, label?: string): boolean | undefined;
969
+ /** Resolve `--watermark` flag; default true when unset. */
970
+ declare function resolveWatermark(flagValue: unknown): boolean;
971
+ //#endregion
947
972
  //#region src/telemetry/event.d.ts
948
973
  interface TrackingEvent {
949
974
  command: string;
@@ -993,4 +1018,191 @@ declare function remoteSink(event: TrackingEvent): Promise<void>;
993
1018
  //#region src/telemetry/tracker.d.ts
994
1019
  declare function trackCommandExecution(config: Config, commandPath: string[], flags: GlobalFlags, fn: () => Promise<void>): Promise<void>;
995
1020
  //#endregion
996
- export { AkSignConfig, type ApiErrorBody, AppCompletionRequest, AppCompletionResponse, AppStreamChunk, AuthMethod, BAILIAN_HOST, BailianError, CHANNEL, CONSOLE_GATEWAY_NO_TOKEN_MESSAGE, ChatChoice, ChatMessage, ChatMessageContent, ChatRequest, ChatResponse, ChatTool, Command, CommandSpec, Config, ConfigFile, ConsoleGatewayRequest, DOCS_HOSTS, DashScopeASRRequest, DashScopeASRTaskResult, DashScopeAsyncResponse, DashScopeImageRequest, DashScopeImageSyncResponse, DashScopeTTSRequest, DashScopeTTSResponse, DashScopeTTSStreamChunk, DashScopeTaskResponse, DashScopeVideoEditRequest, DashScopeVideoRefRequest, DashScopeVideoRequest, ExitCode, GLOBAL_OPTIONS, GlobalFlags, KnowledgeRetrieveRequest, KnowledgeRetrieveResponse, McpClient, McpTool, McpToolResult, MemoryAddRequest, MemoryAddResponse, MemoryMessage, MemoryNode, MemoryNodeListResponse, MemoryNodeUpdateRequest, MemorySearchRequest, MemorySearchResponse, OptionDef, OutputFormat, ProfileAttribute, ProfileSchemaCreateRequest, ProfileSchemaCreateResponse, REGIONS, Region, RequestOpts, ResolvedCredential, SOURCE_CONFIG, ServerSentEvent, StreamChoice, StreamChunk, TAGS, TrackingEvent, UserProfileResponse, appCompletionEndpoint, callConsoleGateway, chatEndpoint, clearApiKey, createTrackingEvent, defineCommand, detectOutputFormat, ensureConfigDir, flushTelemetry, formatErrorJson, formatJson, formatOutput, formatText, generateFilename, generateToolSchema, getConfigDir, getConfigPath, getCredentialsPath, imageEndpoint, imageSyncEndpoint, isCI, isInteractive, isLocalFile, loadApiKeyFromConfig, loadConfig, localSink, mapApiError, maskToken, mcpWebSearchEndpoint, memoryAddEndpoint, memoryListEndpoint, memoryNodeEndpoint, memorySearchEndpoint, parseConfigFile, parseSSE, profileSchemaEndpoint, readConfigFile, remoteSink, request, requestJson, resolveConsoleGatewayCredential, resolveCredential, resolveFileUrl, resolveOutputDir, saveApiKeyToConfig, signRequest, speechRecognizeEndpoint, speechSynthesizeEndpoint, stripUndefined, taskEndpoint, trackCommandExecution, trackingHeaders, uploadFile, userProfileEndpoint, videoGenerateEndpoint, writeConfigFile };
1021
+ //#region src/advisor/types.d.ts
1022
+ type Modality = "Text" | "Image" | "Video" | "Audio";
1023
+ type Complexity = "single" | "pipeline";
1024
+ type Budget = "low" | "medium" | "high";
1025
+ type ContextNeed = "standard" | "large" | "extra-large";
1026
+ type QualityPreference = "flagship" | "balanced" | "cost-optimized";
1027
+ type Capability = "TG" | "Reasoning" | "VU" | "IG" | "VG" | "TTS" | "ASR" | "Realtime-ASR" | "Realtime-Text-to-Speech" | "Realtime-Audio-Translate" | "Realtime-Omni" | "Multimodal-Omni" | "ME" | "TR" | "3D-generation";
1028
+ type Feature = "function-calling" | "web-search" | "structured-outputs" | "prefix-completion";
1029
+ type ModelCategory = "Flagship" | "Cost-optimized";
1030
+ type PreferenceMode = "unconstrained" | "scoped" | "comparison" | "alternative";
1031
+ interface ModelPreference {
1032
+ mode: PreferenceMode;
1033
+ targets?: string[];
1034
+ excludes?: string[];
1035
+ }
1036
+ declare const Modalities: {
1037
+ readonly Text: "Text";
1038
+ readonly Image: "Image";
1039
+ readonly Video: "Video";
1040
+ readonly Audio: "Audio";
1041
+ };
1042
+ declare const Complexities: {
1043
+ readonly Single: "single";
1044
+ readonly Pipeline: "pipeline";
1045
+ };
1046
+ declare const Budgets: {
1047
+ readonly Low: "low";
1048
+ readonly Medium: "medium";
1049
+ readonly High: "high";
1050
+ };
1051
+ declare const ContextNeeds: {
1052
+ readonly Standard: "standard";
1053
+ readonly Large: "large";
1054
+ readonly ExtraLarge: "extra-large";
1055
+ };
1056
+ declare const QualityPreferences: {
1057
+ readonly Flagship: "flagship";
1058
+ readonly Balanced: "balanced";
1059
+ readonly CostOptimized: "cost-optimized";
1060
+ };
1061
+ declare const Capabilities: {
1062
+ readonly TG: "TG";
1063
+ readonly Reasoning: "Reasoning";
1064
+ readonly VU: "VU";
1065
+ readonly IG: "IG";
1066
+ readonly VG: "VG";
1067
+ readonly TTS: "TTS";
1068
+ readonly ASR: "ASR";
1069
+ readonly RealtimeASR: "Realtime-ASR";
1070
+ readonly RealtimeTTS: "Realtime-Text-to-Speech";
1071
+ readonly RealtimeAudioTranslate: "Realtime-Audio-Translate";
1072
+ readonly RealtimeOmni: "Realtime-Omni";
1073
+ readonly MultimodalOmni: "Multimodal-Omni";
1074
+ readonly ME: "ME";
1075
+ readonly TR: "TR";
1076
+ readonly ThreeDGeneration: "3D-generation";
1077
+ };
1078
+ declare const Features: {
1079
+ readonly FunctionCalling: "function-calling";
1080
+ readonly WebSearch: "web-search";
1081
+ readonly StructuredOutputs: "structured-outputs";
1082
+ readonly PrefixCompletion: "prefix-completion";
1083
+ };
1084
+ declare const ModelCategories: {
1085
+ readonly Flagship: "Flagship";
1086
+ readonly CostOptimized: "Cost-optimized";
1087
+ };
1088
+ interface IntentSegment {
1089
+ step: string;
1090
+ inputModality: Modality[];
1091
+ outputModality: Modality[];
1092
+ requiredCapabilities: Capability[];
1093
+ }
1094
+ interface IntentProfile {
1095
+ complexity: Complexity;
1096
+ segments?: IntentSegment[];
1097
+ taskSummary: string;
1098
+ scenarioHints: string[];
1099
+ inputModality: Modality[];
1100
+ outputModality: Modality[];
1101
+ requiredCapabilities: Capability[];
1102
+ requiredFeatures: Feature[];
1103
+ budget: Budget;
1104
+ contextNeed: ContextNeed;
1105
+ qualityPreference: QualityPreference;
1106
+ confidence: number;
1107
+ modelPreference?: ModelPreference;
1108
+ }
1109
+ interface ModelPrice {
1110
+ type: string;
1111
+ unit: string;
1112
+ price: string;
1113
+ }
1114
+ interface QpmLimit {
1115
+ count_limit: number;
1116
+ count_limit_period: number;
1117
+ usage_limit: number;
1118
+ usage_limit_field: string;
1119
+ usage_limit_period: number;
1120
+ }
1121
+ interface ModelProfile {
1122
+ model: string;
1123
+ name: string;
1124
+ description: string;
1125
+ provider: string;
1126
+ capabilities: string[];
1127
+ features: string[];
1128
+ contextWindow?: number;
1129
+ maxOutputTokens?: number;
1130
+ docUrl?: string;
1131
+ inferenceMetadata?: {
1132
+ request_modality?: Modality[];
1133
+ response_modality?: Modality[];
1134
+ };
1135
+ shortDescription?: string;
1136
+ category?: ModelCategory;
1137
+ collectionTag?: string;
1138
+ maxInputTokens?: number;
1139
+ prices?: ModelPrice[];
1140
+ qpmInfo?: Record<string, QpmLimit>;
1141
+ versionTag?: string;
1142
+ openSource?: boolean;
1143
+ family?: string;
1144
+ familyName?: string;
1145
+ }
1146
+ interface RecommendedModel {
1147
+ model: string;
1148
+ name: string;
1149
+ reason: string;
1150
+ highlights: string[];
1151
+ category?: ModelCategory;
1152
+ contextWindow?: number;
1153
+ maxOutputTokens?: number;
1154
+ docUrl?: string;
1155
+ }
1156
+ interface PipelineStep {
1157
+ step: string;
1158
+ recommendations: RecommendedModel[];
1159
+ warnings?: string[];
1160
+ }
1161
+ interface SingleResult {
1162
+ type: "single";
1163
+ recommendations: RecommendedModel[];
1164
+ }
1165
+ interface PipelineResult {
1166
+ type: "pipeline";
1167
+ summary: string;
1168
+ steps: PipelineStep[];
1169
+ }
1170
+ type RecommendResult = SingleResult | PipelineResult;
1171
+ //#endregion
1172
+ //#region src/advisor/cache.d.ts
1173
+ interface GetModelsOptions {
1174
+ onPrepareStart?: () => void;
1175
+ }
1176
+ declare function getModels(config: Config, options?: GetModelsOptions): Promise<ModelProfile[]>;
1177
+ //#endregion
1178
+ //#region src/advisor/intent.d.ts
1179
+ declare function analyzeIntent(config: Config, input: string): Promise<IntentProfile>;
1180
+ //#endregion
1181
+ //#region src/advisor/recall.d.ts
1182
+ interface ScoredCandidate {
1183
+ model: ModelProfile;
1184
+ score: number;
1185
+ }
1186
+ declare function recallCandidates(models: ModelProfile[], intent: IntentProfile): ScoredCandidate[];
1187
+ //#endregion
1188
+ //#region src/advisor/recall-semantic.d.ts
1189
+ declare function isSemanticAvailable(): boolean;
1190
+ declare function recallSemantic(config: Config, models: ModelProfile[], query: string, topK: number, intent?: IntentProfile): Promise<ScoredCandidate[]>;
1191
+ //#endregion
1192
+ //#region src/advisor/recommend.d.ts
1193
+ interface RecommendOptions {
1194
+ onThinking?: (text: string) => void;
1195
+ onContentStart?: () => void;
1196
+ enableThinking?: boolean;
1197
+ }
1198
+ declare function buildDocLink(docUrl?: string): string | undefined;
1199
+ declare function rankModels(config: Config, candidates: ScoredCandidate[], intent: IntentProfile, userInput: string, top: number, options?: RecommendOptions): Promise<RecommendResult>;
1200
+ //#endregion
1201
+ //#region src/advisor/sources/types.d.ts
1202
+ interface ModelSource {
1203
+ name: string;
1204
+ available(): boolean;
1205
+ load(): Promise<ModelProfile[]>;
1206
+ }
1207
+ //#endregion
1208
+ export { AkSignConfig, type ApiErrorBody, AppCompletionRequest, AppCompletionResponse, AppStreamChunk, AuthMethod, BAILIAN_HOST, BailianError, Budget, Budgets, CHANNEL, CONSOLE_GATEWAY_NO_TOKEN_MESSAGE, Capabilities, Capability, ChatChoice, ChatMessage, ChatMessageContent, ChatRequest, ChatResponse, ChatTool, Command, CommandSpec, Complexities, Complexity, Config, ConfigFile, ConsoleGatewayRequest, ContextNeed, ContextNeeds, DOCS_HOSTS, DashScopeASRRequest, DashScopeASRTaskResult, DashScopeAsyncResponse, DashScopeImageRequest, DashScopeImageSyncResponse, DashScopeTTSRequest, DashScopeTTSResponse, DashScopeTTSStreamChunk, DashScopeTaskResponse, DashScopeVideoEditRequest, DashScopeVideoRefRequest, DashScopeVideoRequest, ExitCode, Feature, Features, GLOBAL_OPTIONS, GetModelsOptions, GlobalFlags, IntentProfile, IntentSegment, KnowledgeRetrieveRequest, KnowledgeRetrieveResponse, McpClient, McpTool, McpToolResult, MemoryAddRequest, MemoryAddResponse, MemoryMessage, MemoryNode, MemoryNodeListResponse, MemoryNodeUpdateRequest, MemorySearchRequest, MemorySearchResponse, Modalities, Modality, ModelCategories, ModelCategory, ModelListParams, ModelListResult, ModelPreference, ModelPrice, ModelProfile, ModelSource, OptionDef, OutputFormat, PipelineResult, PipelineStep, PreferenceMode, ProfileAttribute, ProfileSchemaCreateRequest, ProfileSchemaCreateResponse, QpmLimit, QualityPreference, QualityPreferences, REGIONS, RecommendOptions, RecommendResult, RecommendedModel, Region, RequestOpts, ResolvedCredential, SOURCE_CONFIG, ScoredCandidate, ServerSentEvent, SingleResult, StreamChoice, StreamChunk, TAGS, TrackingEvent, UserProfileResponse, analyzeIntent, appCompletionEndpoint, bailianMcpUrl, buildDocLink, callConsoleGateway, chatEndpoint, clearApiKey, createTrackingEvent, defineCommand, detectOutputFormat, ensureConfigDir, fetchModelList, flushTelemetry, formatErrorJson, formatJson, formatOutput, formatText, generateFilename, generateToolSchema, getConfigDir, getConfigPath, getCredentialsPath, getModels, imageEndpoint, imageSyncEndpoint, isCI, isInteractive, isLocalFile, isSemanticAvailable, loadApiKeyFromConfig, loadConfig, localSink, mapApiError, maskToken, mcpWebSearchEndpoint, memoryAddEndpoint, memoryListEndpoint, memoryNodeEndpoint, memorySearchEndpoint, parseBooleanValue, parseConfigFile, parseOptionalBooleanValue, parseSSE, profileSchemaEndpoint, rankModels, readConfigFile, recallCandidates, recallSemantic, remoteSink, request, requestJson, resolveBooleanFlag, resolveConsoleGatewayCredential, resolveCredential, resolveFileUrl, resolveOutputDir, resolveWatermark, saveApiKeyToConfig, signRequest, speechRecognizeEndpoint, speechSynthesizeEndpoint, stripUndefined, taskEndpoint, trackCommandExecution, trackingHeaders, uploadFile, userProfileEndpoint, videoGenerateEndpoint, writeConfigFile };