@123toto/ai-app-assistant-server 0.2.0 → 0.2.2
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/README.md +21 -0
- package/dist/express.d.cts +1 -1
- package/dist/express.d.ts +1 -1
- package/dist/index.cjs +60 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +59 -8
- package/dist/index.js.map +1 -1
- package/dist/{managed-server-BGQ-1jkx.d.ts → managed-server-CusQWWBB.d.ts} +10 -3
- package/dist/{managed-server-CthTKEQ6.d.cts → managed-server-wXfu_9rp.d.cts} +10 -3
- package/dist/nest.d.cts +1 -1
- package/dist/nest.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AiAppAssistant, a as AiAppAssistantStreamEvent, b as AiAppAssistantConfiguration, B as BuiltInProvider } from './managed-server-
|
|
2
|
-
export { c as
|
|
1
|
+
import { A as AiAppAssistant, a as AiAppAssistantStreamEvent, b as AiAppAssistantConfiguration, B as BuiltInProvider } from './managed-server-wXfu_9rp.cjs';
|
|
2
|
+
export { c as AI_APP_ASSISTANT_PROVIDERS, d as AiAppAssistantAccessRule, e as AiAppAssistantConfigurationActor, f as AiAppAssistantConfigurationAdministration, g as AiAppAssistantConfigurationAuditChange, h as AiAppAssistantConfigurationAuditEntry, i as AiAppAssistantConfigurationAuditField, j as AiAppAssistantConfigurationChangeEvent, k as AiAppAssistantConfigurationConflictError, l as AiAppAssistantConfigurationManager, m as AiAppAssistantConfigurationManagerOptions, n as AiAppAssistantConfigurationRepository, o as AiAppAssistantConfigurationSaveResult, p as AiAppAssistantConfigurationSynchronizer, q as AiAppAssistantConfigurationView, r as AiAppAssistantGenerationEvent, s as AiAppAssistantGenerationOperation, t as AiAppAssistantKeyValueStore, u as AiAppAssistantManagedConfigurationSetup, v as AiAppAssistantManagedStorage, w as AiAppAssistantManagementError, x as AiAppAssistantManagementErrorCode, y as AiAppAssistantQuotaPolicy, z as AiAppAssistantQuotaResult, C as AiAppAssistantQuotaStore, D as AiAppAssistantRecentFailure, E as AiAppAssistantRedisClient, F as AiAppAssistantRedisQuotaClient, G as AiAppAssistantRedisTelemetryClient, H as AiAppAssistantRuntimeIdentity, I as AiAppAssistantSecretProtector, J as AiAppAssistantTelemetryStore, K as AiAppAssistantTelemetrySummary, L as AiModelDiscoveryError, N as AiModelInfo, O as AiProviderInfo, P as CreateAiAppAssistantConfigurationRepositoryOptions, Q as CreateManagedAiAppAssistantRuntimeOptions, R as CreateManagedAiAppAssistantServerOptions, S as ListAiModelsOptions, T as ManagedAiAppAssistantFetchHandlerOptions, U as ManagedAiAppAssistantFetchHandlers, V as ManagedAiAppAssistantRuntime, M as ManagedAiAppAssistantServer, W as createAes256GcmSecretProtector, X as createAiAppAssistant, Y as createAiAppAssistantConfigurationRepository, Z as createAiAppAssistantFailureEvent, _ as createDisabledSecretProtector, $ as createManagedAiAppAssistantFetchHandlers, a0 as createManagedAiAppAssistantRuntime, a1 as createManagedAiAppAssistantServer, a2 as createMemoryAiAppAssistantQuotaStore, a3 as createMemoryAiAppAssistantStore, a4 as createMemoryAiAppAssistantTelemetryStore, a5 as createPollingAiAppAssistantConfigurationSynchronizer, a6 as createRedisAiAppAssistantQuotaStore, a7 as createRedisAiAppAssistantStore, a8 as createRedisAiAppAssistantTelemetryStore, a9 as listAiModels, aa as listAiProviders, ab as validateAndSaveAiAppAssistantConfiguration } from './managed-server-wXfu_9rp.cjs';
|
|
3
3
|
import { AiAppAssistantRequest, AiAppAssistantResponse } from '@123toto/ai-app-assistant-contracts';
|
|
4
4
|
export { AiAppAssistantConfigurationFieldSource, AiAppAssistantConfigurationInput, AiAppAssistantConfigurationOptions, AiAppAssistantConnectionResult, AiAppAssistantConnectionTestInput, AiAppAssistantCredentials, AiAppAssistantManagedConfigurationView, AiAppAssistantModelInfoContract, AiAppAssistantProvider, AiAppAssistantProviderInfoContract, AiAppAssistantRequest, AiAppAssistantResponse, AiAppAssistantRuntimeConnection, AiAppAssistantRuntimeConnectionStatus, AiAppAssistantTransportEvent, EvidenceSource, GeneratedAnswer, PROTOCOL_VERSION, aiAppAssistantAccessRuleSchema, aiAppAssistantConfigurationInputSchema, aiAppAssistantConfigurationOptionsSchema, aiAppAssistantConfigurationSaveResultSchema, aiAppAssistantConnectionResultSchema, aiAppAssistantConnectionTestInputSchema, aiAppAssistantCredentialsSchema, aiAppAssistantManagedConfigurationViewSchema, aiAppAssistantModelInfoSchema, aiAppAssistantProviderInfoSchema, aiAppAssistantProviderSchema, aiAppAssistantRequestSchema, aiAppAssistantResponseSchema, aiAppAssistantTransportEventSchema } from '@123toto/ai-app-assistant-contracts';
|
|
5
5
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
@@ -89,9 +89,17 @@ declare function createAiAppAssistantServer<TContext = undefined>(options: Creat
|
|
|
89
89
|
|
|
90
90
|
interface AiAppAssistantDeploymentDefaultsOptions {
|
|
91
91
|
enabled: boolean;
|
|
92
|
-
/** `
|
|
92
|
+
/** Provider selected by the host application. Allows `model` to remain a plain model identifier. */
|
|
93
|
+
provider?: BuiltInProvider;
|
|
94
|
+
/** Plain model identifier when `provider` is set, or legacy `provider:model` identifier. */
|
|
93
95
|
model?: string;
|
|
96
|
+
/** API key for the selected provider. Prefer this for one-provider deployments. */
|
|
97
|
+
apiKey?: string;
|
|
98
|
+
/** Provider endpoint override. Required by local providers such as Ollama. */
|
|
99
|
+
baseURL?: string;
|
|
100
|
+
/** @deprecated Prefer `provider` with the singular `apiKey` option. */
|
|
94
101
|
apiKeys?: Partial<Record<BuiltInProvider, string | undefined>>;
|
|
102
|
+
/** @deprecated Prefer `provider` with the singular `baseURL` option. */
|
|
95
103
|
baseURLs?: Partial<Record<BuiltInProvider, string | undefined>>;
|
|
96
104
|
access?: AiAppAssistantConfiguration["access"];
|
|
97
105
|
quota?: AiAppAssistantConfiguration["quota"];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AiAppAssistant, a as AiAppAssistantStreamEvent, b as AiAppAssistantConfiguration, B as BuiltInProvider } from './managed-server-
|
|
2
|
-
export { c as
|
|
1
|
+
import { A as AiAppAssistant, a as AiAppAssistantStreamEvent, b as AiAppAssistantConfiguration, B as BuiltInProvider } from './managed-server-CusQWWBB.js';
|
|
2
|
+
export { c as AI_APP_ASSISTANT_PROVIDERS, d as AiAppAssistantAccessRule, e as AiAppAssistantConfigurationActor, f as AiAppAssistantConfigurationAdministration, g as AiAppAssistantConfigurationAuditChange, h as AiAppAssistantConfigurationAuditEntry, i as AiAppAssistantConfigurationAuditField, j as AiAppAssistantConfigurationChangeEvent, k as AiAppAssistantConfigurationConflictError, l as AiAppAssistantConfigurationManager, m as AiAppAssistantConfigurationManagerOptions, n as AiAppAssistantConfigurationRepository, o as AiAppAssistantConfigurationSaveResult, p as AiAppAssistantConfigurationSynchronizer, q as AiAppAssistantConfigurationView, r as AiAppAssistantGenerationEvent, s as AiAppAssistantGenerationOperation, t as AiAppAssistantKeyValueStore, u as AiAppAssistantManagedConfigurationSetup, v as AiAppAssistantManagedStorage, w as AiAppAssistantManagementError, x as AiAppAssistantManagementErrorCode, y as AiAppAssistantQuotaPolicy, z as AiAppAssistantQuotaResult, C as AiAppAssistantQuotaStore, D as AiAppAssistantRecentFailure, E as AiAppAssistantRedisClient, F as AiAppAssistantRedisQuotaClient, G as AiAppAssistantRedisTelemetryClient, H as AiAppAssistantRuntimeIdentity, I as AiAppAssistantSecretProtector, J as AiAppAssistantTelemetryStore, K as AiAppAssistantTelemetrySummary, L as AiModelDiscoveryError, N as AiModelInfo, O as AiProviderInfo, P as CreateAiAppAssistantConfigurationRepositoryOptions, Q as CreateManagedAiAppAssistantRuntimeOptions, R as CreateManagedAiAppAssistantServerOptions, S as ListAiModelsOptions, T as ManagedAiAppAssistantFetchHandlerOptions, U as ManagedAiAppAssistantFetchHandlers, V as ManagedAiAppAssistantRuntime, M as ManagedAiAppAssistantServer, W as createAes256GcmSecretProtector, X as createAiAppAssistant, Y as createAiAppAssistantConfigurationRepository, Z as createAiAppAssistantFailureEvent, _ as createDisabledSecretProtector, $ as createManagedAiAppAssistantFetchHandlers, a0 as createManagedAiAppAssistantRuntime, a1 as createManagedAiAppAssistantServer, a2 as createMemoryAiAppAssistantQuotaStore, a3 as createMemoryAiAppAssistantStore, a4 as createMemoryAiAppAssistantTelemetryStore, a5 as createPollingAiAppAssistantConfigurationSynchronizer, a6 as createRedisAiAppAssistantQuotaStore, a7 as createRedisAiAppAssistantStore, a8 as createRedisAiAppAssistantTelemetryStore, a9 as listAiModels, aa as listAiProviders, ab as validateAndSaveAiAppAssistantConfiguration } from './managed-server-CusQWWBB.js';
|
|
3
3
|
import { AiAppAssistantRequest, AiAppAssistantResponse } from '@123toto/ai-app-assistant-contracts';
|
|
4
4
|
export { AiAppAssistantConfigurationFieldSource, AiAppAssistantConfigurationInput, AiAppAssistantConfigurationOptions, AiAppAssistantConnectionResult, AiAppAssistantConnectionTestInput, AiAppAssistantCredentials, AiAppAssistantManagedConfigurationView, AiAppAssistantModelInfoContract, AiAppAssistantProvider, AiAppAssistantProviderInfoContract, AiAppAssistantRequest, AiAppAssistantResponse, AiAppAssistantRuntimeConnection, AiAppAssistantRuntimeConnectionStatus, AiAppAssistantTransportEvent, EvidenceSource, GeneratedAnswer, PROTOCOL_VERSION, aiAppAssistantAccessRuleSchema, aiAppAssistantConfigurationInputSchema, aiAppAssistantConfigurationOptionsSchema, aiAppAssistantConfigurationSaveResultSchema, aiAppAssistantConnectionResultSchema, aiAppAssistantConnectionTestInputSchema, aiAppAssistantCredentialsSchema, aiAppAssistantManagedConfigurationViewSchema, aiAppAssistantModelInfoSchema, aiAppAssistantProviderInfoSchema, aiAppAssistantProviderSchema, aiAppAssistantRequestSchema, aiAppAssistantResponseSchema, aiAppAssistantTransportEventSchema } from '@123toto/ai-app-assistant-contracts';
|
|
5
5
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
@@ -89,9 +89,17 @@ declare function createAiAppAssistantServer<TContext = undefined>(options: Creat
|
|
|
89
89
|
|
|
90
90
|
interface AiAppAssistantDeploymentDefaultsOptions {
|
|
91
91
|
enabled: boolean;
|
|
92
|
-
/** `
|
|
92
|
+
/** Provider selected by the host application. Allows `model` to remain a plain model identifier. */
|
|
93
|
+
provider?: BuiltInProvider;
|
|
94
|
+
/** Plain model identifier when `provider` is set, or legacy `provider:model` identifier. */
|
|
93
95
|
model?: string;
|
|
96
|
+
/** API key for the selected provider. Prefer this for one-provider deployments. */
|
|
97
|
+
apiKey?: string;
|
|
98
|
+
/** Provider endpoint override. Required by local providers such as Ollama. */
|
|
99
|
+
baseURL?: string;
|
|
100
|
+
/** @deprecated Prefer `provider` with the singular `apiKey` option. */
|
|
94
101
|
apiKeys?: Partial<Record<BuiltInProvider, string | undefined>>;
|
|
102
|
+
/** @deprecated Prefer `provider` with the singular `baseURL` option. */
|
|
95
103
|
baseURLs?: Partial<Record<BuiltInProvider, string | undefined>>;
|
|
96
104
|
access?: AiAppAssistantConfiguration["access"];
|
|
97
105
|
quota?: AiAppAssistantConfiguration["quota"];
|
package/dist/index.js
CHANGED
|
@@ -751,6 +751,7 @@ function quotaResult(count, resetAt, maxRequests, now) {
|
|
|
751
751
|
}
|
|
752
752
|
|
|
753
753
|
// src/provider-catalog.ts
|
|
754
|
+
var AI_APP_ASSISTANT_PROVIDERS = ["anthropic", "google", "mistral", "ollama", "openai"];
|
|
754
755
|
var PROVIDERS = Object.freeze([
|
|
755
756
|
{ id: "anthropic", label: "Anthropic", requiresApiKey: true, supportsModelDiscovery: true },
|
|
756
757
|
{ id: "google", label: "Google Gemini", requiresApiKey: true, supportsModelDiscovery: true },
|
|
@@ -896,12 +897,17 @@ var AiAppAssistantConfigurationManager = class {
|
|
|
896
897
|
this.#repository = options.repository;
|
|
897
898
|
this.#quotaStore = options.quotaStore ?? createMemoryAiAppAssistantQuotaStore();
|
|
898
899
|
}
|
|
900
|
+
/** Returns the current state of the host-controlled global kill switch. */
|
|
901
|
+
isEnabled() {
|
|
902
|
+
return typeof this.#options.enabled === "function" ? this.#options.enabled() : this.#options.enabled ?? true;
|
|
903
|
+
}
|
|
899
904
|
/** Returns the built-in provider catalogue; no credentials are exposed. */
|
|
900
905
|
listProviders() {
|
|
901
906
|
return listAiProviders();
|
|
902
907
|
}
|
|
903
908
|
/** Discovers models with an explicit key or the currently configured secret. */
|
|
904
909
|
async listModels(input) {
|
|
910
|
+
this.assertEnabled();
|
|
905
911
|
const apiKey = await this.resolveApiKey(input.provider, input.apiKey);
|
|
906
912
|
if (this.#options.listModels) {
|
|
907
913
|
return this.#options.listModels({ ...input, ...apiKey ? { apiKey } : {} });
|
|
@@ -927,7 +933,10 @@ var AiAppAssistantConfigurationManager = class {
|
|
|
927
933
|
let connected = event.connectionValidated;
|
|
928
934
|
if (event.reloadRequired) {
|
|
929
935
|
this.#recentConnectionValidation = void 0;
|
|
930
|
-
if (
|
|
936
|
+
if (!this.isEnabled()) {
|
|
937
|
+
connected = false;
|
|
938
|
+
this.#runtimeConnection = { status: "disabled", checkedAt: this.now() };
|
|
939
|
+
} else if (connected) {
|
|
931
940
|
const configuration = await this.getRuntimeConfiguration();
|
|
932
941
|
this.#runtimeConnection = configuration ? {
|
|
933
942
|
status: "connected",
|
|
@@ -957,6 +966,7 @@ var AiAppAssistantConfigurationManager = class {
|
|
|
957
966
|
}
|
|
958
967
|
/** Tests credentials and briefly caches a successful result for the next save. */
|
|
959
968
|
async testConnection(input) {
|
|
969
|
+
this.assertEnabled();
|
|
960
970
|
const apiKey = await this.resolveApiKey(input.provider, input.apiKey);
|
|
961
971
|
const connection = this.#options.testConnection ? await this.#options.testConnection({ ...input, ...apiKey ? { apiKey } : {} }) : await testAiSdkConnection({
|
|
962
972
|
model: `${input.provider}:${input.model}`,
|
|
@@ -985,6 +995,10 @@ var AiAppAssistantConfigurationManager = class {
|
|
|
985
995
|
/** Checks the effective stored/deployment connection used by live questions. */
|
|
986
996
|
async validateRuntimeConnection() {
|
|
987
997
|
this.#lastReconnectAttempt = Date.now();
|
|
998
|
+
if (!this.isEnabled()) {
|
|
999
|
+
this.#runtimeConnection = { status: "disabled", checkedAt: this.now() };
|
|
1000
|
+
return false;
|
|
1001
|
+
}
|
|
988
1002
|
const configuration = await this.getRuntimeConfiguration();
|
|
989
1003
|
if (!configuration || configuration.provider !== "ollama" && !configuration.apiKey) {
|
|
990
1004
|
this.#runtimeConnection = {
|
|
@@ -1027,6 +1041,7 @@ var AiAppAssistantConfigurationManager = class {
|
|
|
1027
1041
|
const initialActive = this.effectiveConfiguration(initial);
|
|
1028
1042
|
const initialApiKey = input.apiKey ?? (initialActive?.provider === input.provider ? initialActive.apiKey : void 0) ?? this.resolveDefaultApiKey(input.provider);
|
|
1029
1043
|
const initialConnectionChanged = connectionChanged(initialActive, input);
|
|
1044
|
+
if (!this.isEnabled() && initialConnectionChanged) throw disabled();
|
|
1030
1045
|
let connection = initialConnectionChanged ? await this.validateConnectionForSave(input, initialApiKey) : this.lastKnownConnection(input.provider, input.model);
|
|
1031
1046
|
if (initialConnectionChanged && !connection.success) {
|
|
1032
1047
|
return { saved: false, connection, reloadRequired: false };
|
|
@@ -1255,6 +1270,7 @@ var AiAppAssistantConfigurationManager = class {
|
|
|
1255
1270
|
}
|
|
1256
1271
|
/** Combines configuration, provider health and application access rules. */
|
|
1257
1272
|
async canUse(identity) {
|
|
1273
|
+
if (!this.isEnabled()) return false;
|
|
1258
1274
|
const configuration = await this.getRuntimeConfiguration();
|
|
1259
1275
|
if (!configuration || configuration.provider !== "ollama" && !configuration.apiKey) return false;
|
|
1260
1276
|
if (!await this.ensureRuntimeConnection()) return false;
|
|
@@ -1273,6 +1289,7 @@ var AiAppAssistantConfigurationManager = class {
|
|
|
1273
1289
|
}
|
|
1274
1290
|
/** Enforces access and quota immediately before any model call. */
|
|
1275
1291
|
async assertCanAsk(identity) {
|
|
1292
|
+
this.assertEnabled();
|
|
1276
1293
|
if (!await this.canUse(identity)) {
|
|
1277
1294
|
throw forbidden("AI assistant access is not enabled for this user");
|
|
1278
1295
|
}
|
|
@@ -1288,6 +1305,7 @@ var AiAppAssistantConfigurationManager = class {
|
|
|
1288
1305
|
}
|
|
1289
1306
|
/** Retries a failed provider lazily, with a shared backoff across requests. */
|
|
1290
1307
|
async ensureRuntimeConnection() {
|
|
1308
|
+
if (!this.isEnabled()) return false;
|
|
1291
1309
|
if (this.#runtimeConnection.status === "connected") return true;
|
|
1292
1310
|
const intervalMs = Math.max(1e3, this.#options.reconnectIntervalMs ?? 3e4);
|
|
1293
1311
|
if (Date.now() - this.#lastReconnectAttempt < intervalMs) return false;
|
|
@@ -1395,6 +1413,9 @@ var AiAppAssistantConfigurationManager = class {
|
|
|
1395
1413
|
now() {
|
|
1396
1414
|
return (this.#options.now?.() ?? /* @__PURE__ */ new Date()).toISOString();
|
|
1397
1415
|
}
|
|
1416
|
+
assertEnabled() {
|
|
1417
|
+
if (!this.isEnabled()) throw disabled();
|
|
1418
|
+
}
|
|
1398
1419
|
async publishAndEmit(event) {
|
|
1399
1420
|
await this.#options.synchronizer?.publish(event);
|
|
1400
1421
|
await this.emit(event);
|
|
@@ -1518,6 +1539,13 @@ function configurationChanges(previous, input, allowModelChangesByOthers) {
|
|
|
1518
1539
|
function forbidden(message) {
|
|
1519
1540
|
return new AiAppAssistantManagementError(403, "forbidden", message);
|
|
1520
1541
|
}
|
|
1542
|
+
function disabled() {
|
|
1543
|
+
return new AiAppAssistantManagementError(
|
|
1544
|
+
503,
|
|
1545
|
+
"assistant_disabled",
|
|
1546
|
+
"AI assistant is disabled"
|
|
1547
|
+
);
|
|
1548
|
+
}
|
|
1521
1549
|
|
|
1522
1550
|
// src/telemetry.ts
|
|
1523
1551
|
function createMemoryAiAppAssistantTelemetryStore(options) {
|
|
@@ -1687,6 +1715,11 @@ function createManagedAiAppAssistantRuntime(options) {
|
|
|
1687
1715
|
return reloadQueue;
|
|
1688
1716
|
});
|
|
1689
1717
|
const rebuild = async (event) => {
|
|
1718
|
+
if (!options.configuration.isEnabled()) {
|
|
1719
|
+
assistant = void 0;
|
|
1720
|
+
activeGenerator = void 0;
|
|
1721
|
+
return;
|
|
1722
|
+
}
|
|
1690
1723
|
const connected = event.connectionValidated || await options.configuration.validateRuntimeConnection();
|
|
1691
1724
|
const configuration = await options.configuration.getRuntimeConfiguration();
|
|
1692
1725
|
if (!connected || !configuration) {
|
|
@@ -2078,21 +2111,38 @@ function createAiAppAssistantDeploymentDefaults(options) {
|
|
|
2078
2111
|
const apiKeys = Object.fromEntries(
|
|
2079
2112
|
Object.entries(options.apiKeys ?? {}).map(([provider2, value]) => [provider2, value?.trim() || void 0])
|
|
2080
2113
|
);
|
|
2081
|
-
const
|
|
2114
|
+
const selectedProvider = options.provider;
|
|
2115
|
+
const selectedApiKey = options.apiKey?.trim() || void 0;
|
|
2116
|
+
const resolveApiKey = (provider2) => provider2 === selectedProvider ? selectedApiKey ?? apiKeys[provider2] : apiKeys[provider2];
|
|
2082
2117
|
if (!options.enabled || !options.model?.trim()) return { resolveApiKey };
|
|
2083
|
-
const
|
|
2084
|
-
|
|
2085
|
-
const
|
|
2118
|
+
const rawModel = options.model.trim();
|
|
2119
|
+
const legacyMatch = selectedProvider ? void 0 : rawModel.match(/^([^:/]+)[:/](.+)$/);
|
|
2120
|
+
const explicitMatch = selectedProvider ? rawModel.match(/^([^:]+):(.+)$/) : void 0;
|
|
2121
|
+
if (!selectedProvider && !legacyMatch) {
|
|
2122
|
+
throw new TypeError(`Invalid AI App Assistant model identifier: ${options.model}`);
|
|
2123
|
+
}
|
|
2124
|
+
const parsedProvider = legacyMatch?.[1] ?? explicitMatch?.[1];
|
|
2125
|
+
const modelProvider = parsedProvider === "gemini" ? "google" : parsedProvider ?? selectedProvider;
|
|
2126
|
+
const provider = modelProvider;
|
|
2086
2127
|
if (!listAiProviders().some((candidate) => candidate.id === provider)) {
|
|
2087
|
-
throw new TypeError(`Unsupported AI App Assistant provider: ${
|
|
2128
|
+
throw new TypeError(`Unsupported AI App Assistant provider: ${modelProvider}`);
|
|
2129
|
+
}
|
|
2130
|
+
if (selectedProvider && explicitMatch && provider !== selectedProvider) {
|
|
2131
|
+
throw new TypeError(
|
|
2132
|
+
`AI App Assistant provider '${selectedProvider}' does not match model identifier '${options.model}'`
|
|
2133
|
+
);
|
|
2088
2134
|
}
|
|
2135
|
+
const model = legacyMatch?.[2]?.trim() ?? explicitMatch?.[2]?.trim() ?? rawModel;
|
|
2089
2136
|
const apiKey = resolveApiKey(provider);
|
|
2090
|
-
const baseURL = options.baseURLs?.[provider]?.trim() || void 0;
|
|
2137
|
+
const baseURL = (provider === selectedProvider ? options.baseURL?.trim() : void 0) || options.baseURLs?.[provider]?.trim() || void 0;
|
|
2138
|
+
if (provider === "ollama" && !baseURL) {
|
|
2139
|
+
throw new TypeError("AI App Assistant local provider 'ollama' requires a base URL");
|
|
2140
|
+
}
|
|
2091
2141
|
return {
|
|
2092
2142
|
resolveApiKey,
|
|
2093
2143
|
configuration: {
|
|
2094
2144
|
provider,
|
|
2095
|
-
model
|
|
2145
|
+
model,
|
|
2096
2146
|
connectionSource: "environment",
|
|
2097
2147
|
...apiKey ? { apiKey } : {},
|
|
2098
2148
|
...baseURL ? { baseURL } : {},
|
|
@@ -2319,6 +2369,7 @@ import {
|
|
|
2319
2369
|
aiAppAssistantTransportEventSchema
|
|
2320
2370
|
} from "@123toto/ai-app-assistant-contracts";
|
|
2321
2371
|
export {
|
|
2372
|
+
AI_APP_ASSISTANT_PROVIDERS,
|
|
2322
2373
|
AiAppAssistantConfigurationConflictError,
|
|
2323
2374
|
AiAppAssistantConfigurationManager,
|
|
2324
2375
|
AiAppAssistantManagementError,
|