@123toto/ai-app-assistant-server 0.1.1 → 0.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/README.md +14 -14
- package/dist/{ai-sdk-QImICd56.d.cts → ai-sdk-qU3KgNu-.d.cts} +2 -2
- package/dist/{ai-sdk-QImICd56.d.ts → ai-sdk-qU3KgNu-.d.ts} +2 -2
- package/dist/ai-sdk.d.cts +1 -1
- package/dist/ai-sdk.d.ts +1 -1
- package/dist/{chunk-OA7OXUK7.js → chunk-Z4IVCZ5M.js} +15 -15
- package/dist/chunk-Z4IVCZ5M.js.map +1 -0
- package/dist/express.cjs +8 -8
- package/dist/express.cjs.map +1 -1
- package/dist/express.d.cts +11 -11
- package/dist/express.d.ts +11 -11
- package/dist/express.js +7 -7
- package/dist/express.js.map +1 -1
- package/dist/index.cjs +167 -167
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -33
- package/dist/index.d.ts +33 -33
- package/dist/index.js +142 -142
- package/dist/index.js.map +1 -1
- package/dist/{managed-server-7iurKxF1.d.cts → managed-server-BGQ-1jkx.d.ts} +148 -148
- package/dist/{managed-server-CrZumvVU.d.ts → managed-server-CthTKEQ6.d.cts} +148 -148
- package/dist/nest.cjs +31 -31
- package/dist/nest.cjs.map +1 -1
- package/dist/nest.d.cts +12 -12
- package/dist/nest.d.ts +12 -12
- package/dist/nest.js +28 -28
- package/dist/nest.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-OA7OXUK7.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
1
|
+
import { A as AiAppAssistant, a as AiAppAssistantStreamEvent, b as AiAppAssistantConfiguration, B as BuiltInProvider } from './managed-server-CthTKEQ6.cjs';
|
|
2
|
+
export { c as AiAppAssistantAccessRule, d as AiAppAssistantConfigurationActor, e as AiAppAssistantConfigurationAdministration, f as AiAppAssistantConfigurationAuditChange, g as AiAppAssistantConfigurationAuditEntry, h as AiAppAssistantConfigurationAuditField, i as AiAppAssistantConfigurationChangeEvent, j as AiAppAssistantConfigurationConflictError, k as AiAppAssistantConfigurationManager, l as AiAppAssistantConfigurationManagerOptions, m as AiAppAssistantConfigurationRepository, n as AiAppAssistantConfigurationSaveResult, o as AiAppAssistantConfigurationSynchronizer, p as AiAppAssistantConfigurationView, q as AiAppAssistantGenerationEvent, r as AiAppAssistantGenerationOperation, s as AiAppAssistantKeyValueStore, t as AiAppAssistantManagedConfigurationSetup, u as AiAppAssistantManagedStorage, v as AiAppAssistantManagementError, w as AiAppAssistantManagementErrorCode, x as AiAppAssistantQuotaPolicy, y as AiAppAssistantQuotaResult, z as AiAppAssistantQuotaStore, C as AiAppAssistantRecentFailure, D as AiAppAssistantRedisClient, E as AiAppAssistantRedisQuotaClient, F as AiAppAssistantRedisTelemetryClient, G as AiAppAssistantRuntimeIdentity, H as AiAppAssistantSecretProtector, I as AiAppAssistantTelemetryStore, J as AiAppAssistantTelemetrySummary, K as AiModelDiscoveryError, L as AiModelInfo, N as AiProviderInfo, O as CreateAiAppAssistantConfigurationRepositoryOptions, P as CreateManagedAiAppAssistantRuntimeOptions, Q as CreateManagedAiAppAssistantServerOptions, R as ListAiModelsOptions, S as ManagedAiAppAssistantFetchHandlerOptions, T as ManagedAiAppAssistantFetchHandlers, U as ManagedAiAppAssistantRuntime, M as ManagedAiAppAssistantServer, V as createAes256GcmSecretProtector, W as createAiAppAssistant, X as createAiAppAssistantConfigurationRepository, Y as createAiAppAssistantFailureEvent, Z as createDisabledSecretProtector, _ as createManagedAiAppAssistantFetchHandlers, $ as createManagedAiAppAssistantRuntime, a0 as createManagedAiAppAssistantServer, a1 as createMemoryAiAppAssistantQuotaStore, a2 as createMemoryAiAppAssistantStore, a3 as createMemoryAiAppAssistantTelemetryStore, a4 as createPollingAiAppAssistantConfigurationSynchronizer, a5 as createRedisAiAppAssistantQuotaStore, a6 as createRedisAiAppAssistantStore, a7 as createRedisAiAppAssistantTelemetryStore, a8 as listAiModels, a9 as listAiProviders, aa as validateAndSaveAiAppAssistantConfiguration } from './managed-server-CthTKEQ6.cjs';
|
|
3
|
+
import { AiAppAssistantRequest, AiAppAssistantResponse } from '@123toto/ai-app-assistant-contracts';
|
|
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';
|
|
6
|
-
import { A as AnswerGenerator, D as DocumentationSource, a as
|
|
7
|
-
export { b as AiSdkConfigurationError, c as AiSdkConnectionTestOptions, d as AiSdkConnectionTestResult, e as AiSdkFailureCode, f as AiSdkGenerationError, g as AiSdkGeneratorOptions, E as EvidenceBundle, h as EvidenceItem, G as GenerationOptions, i as GenerationProgress, M as ModelCapabilities, j as createAiSdkGenerator, n as normalizeAiSdkGenerationError, t as testAiSdkConnection } from './ai-sdk-
|
|
6
|
+
import { A as AnswerGenerator, D as DocumentationSource, a as AiAppAssistantOptions, O as OpenApiDocument } from './ai-sdk-qU3KgNu-.cjs';
|
|
7
|
+
export { b as AiSdkConfigurationError, c as AiSdkConnectionTestOptions, d as AiSdkConnectionTestResult, e as AiSdkFailureCode, f as AiSdkGenerationError, g as AiSdkGeneratorOptions, E as EvidenceBundle, h as EvidenceItem, G as GenerationOptions, i as GenerationProgress, M as ModelCapabilities, j as createAiSdkGenerator, n as normalizeAiSdkGenerationError, t as testAiSdkConnection } from './ai-sdk-qU3KgNu-.cjs';
|
|
8
8
|
import 'ai';
|
|
9
9
|
|
|
10
|
-
interface
|
|
11
|
-
assistant:
|
|
10
|
+
interface AiAppAssistantFetchHandlerOptions<TContext = undefined> {
|
|
11
|
+
assistant: AiAppAssistant;
|
|
12
12
|
/** Resolves framework-specific authentication into an application context. */
|
|
13
13
|
resolveContext?: (request: Request) => Promise<TContext> | TContext;
|
|
14
14
|
/** Optional application authorization executed before assistant work. */
|
|
@@ -16,24 +16,24 @@ interface AiDocsFetchHandlerOptions<TContext = undefined> {
|
|
|
16
16
|
/** Explicit opt-in for public prototypes without authentication hooks. */
|
|
17
17
|
allowAnonymous?: boolean;
|
|
18
18
|
/** Optional privacy/input policy applied after protocol validation. */
|
|
19
|
-
transformRequest?: (input:
|
|
19
|
+
transformRequest?: (input: AiAppAssistantRequest, context: TContext) => Promise<AiAppAssistantRequest> | AiAppAssistantRequest;
|
|
20
20
|
/** Optional privacy/output policy applied before serialization. */
|
|
21
|
-
transformResponse?: (response:
|
|
21
|
+
transformResponse?: (response: AiAppAssistantResponse, context: TContext) => Promise<AiAppAssistantResponse> | AiAppAssistantResponse;
|
|
22
22
|
/** Applies privacy rules to progressive text before it leaves the backend. */
|
|
23
|
-
transformStreamEvent?: (event:
|
|
23
|
+
transformStreamEvent?: (event: AiAppAssistantStreamEvent, context: TContext) => Promise<AiAppAssistantStreamEvent> | AiAppAssistantStreamEvent;
|
|
24
24
|
/** Maximum HTTP request size. Defaults slightly above the protocol limit. */
|
|
25
25
|
maxBodyBytes?: number;
|
|
26
26
|
/** Maps application errors without coupling the library to one framework. */
|
|
27
27
|
onError?: (error: unknown, request: Request) => Promise<Response> | Response;
|
|
28
28
|
}
|
|
29
|
-
interface
|
|
29
|
+
interface AiAppAssistantFetchHandlers {
|
|
30
30
|
ask(request: Request): Promise<Response>;
|
|
31
31
|
stream(request: Request): Promise<Response>;
|
|
32
32
|
/** Dispatches to `stream` when the pathname ends in `/stream`, otherwise to `ask`. */
|
|
33
33
|
handle(request: Request): Promise<Response>;
|
|
34
34
|
}
|
|
35
35
|
/** Explicit safe HTTP error that host authorization hooks can throw. */
|
|
36
|
-
declare class
|
|
36
|
+
declare class AiAppAssistantRequestError extends Error {
|
|
37
37
|
readonly status: number;
|
|
38
38
|
readonly code: string;
|
|
39
39
|
constructor(status: number, code: string, message: string);
|
|
@@ -42,27 +42,27 @@ declare class AiDocsRequestError extends Error {
|
|
|
42
42
|
* Creates Fetch API handlers usable by standards-based runtimes and thin
|
|
43
43
|
* Express, Fastify, Nest, Next.js, Hono, Bun or serverless adapters.
|
|
44
44
|
*/
|
|
45
|
-
declare function
|
|
45
|
+
declare function createAiAppAssistantFetchHandlers<TContext = undefined>(options: AiAppAssistantFetchHandlerOptions<TContext>): AiAppAssistantFetchHandlers;
|
|
46
46
|
|
|
47
|
-
interface
|
|
47
|
+
interface AiAppAssistantNodeHttpAdapterOptions {
|
|
48
48
|
/** Used when the incoming request does not expose an absolute URL. */
|
|
49
49
|
origin?: string;
|
|
50
50
|
/** Protects the adapter before constructing a Fetch API Request. */
|
|
51
51
|
maxBodyBytes?: number;
|
|
52
52
|
}
|
|
53
|
-
type
|
|
53
|
+
type AiAppAssistantNodeHttpListener = (request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
|
54
54
|
/** Minimal shape implemented by both basic and managed Fetch handlers. */
|
|
55
|
-
interface
|
|
55
|
+
interface AiAppAssistantNodeHttpHandler {
|
|
56
56
|
handle(request: Request): Promise<Response>;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Bridges Node's native HTTP objects to the framework-neutral Fetch handlers.
|
|
60
60
|
* Express, Nest-on-Express and Fastify can expose their raw request/response.
|
|
61
61
|
*/
|
|
62
|
-
declare function
|
|
62
|
+
declare function createAiAppAssistantNodeHttpListener(handlers: AiAppAssistantNodeHttpHandler, options?: AiAppAssistantNodeHttpAdapterOptions): AiAppAssistantNodeHttpListener;
|
|
63
63
|
|
|
64
|
-
type AssistantPolicies = NonNullable<
|
|
65
|
-
interface
|
|
64
|
+
type AssistantPolicies = NonNullable<AiAppAssistantOptions["policies"]>;
|
|
65
|
+
interface CreateAiAppAssistantServerOptions<TContext = undefined> {
|
|
66
66
|
/** A custom generator takes precedence over the provider:model shortcut. */
|
|
67
67
|
generator?: AnswerGenerator;
|
|
68
68
|
/** Provider-neutral model identifier, for example `mistral:mistral-small-latest`. */
|
|
@@ -73,36 +73,36 @@ interface CreateAiDocsServerOptions<TContext = undefined> {
|
|
|
73
73
|
maxRetries?: number;
|
|
74
74
|
documents?: DocumentationSource[];
|
|
75
75
|
policies?: AssistantPolicies;
|
|
76
|
-
http?: Omit<
|
|
76
|
+
http?: Omit<AiAppAssistantFetchHandlerOptions<TContext>, "assistant">;
|
|
77
77
|
}
|
|
78
|
-
interface
|
|
79
|
-
assistant:
|
|
80
|
-
fetch:
|
|
78
|
+
interface AiAppAssistantServer<TContext = undefined> {
|
|
79
|
+
assistant: AiAppAssistant;
|
|
80
|
+
fetch: AiAppAssistantFetchHandlers;
|
|
81
81
|
/** Retained for consumers that want direct programmatic calls. */
|
|
82
|
-
options: Readonly<
|
|
82
|
+
options: Readonly<CreateAiAppAssistantServerOptions<TContext>>;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* Minimal framework-neutral server factory. Applications can start with a
|
|
86
86
|
* model string and documents, then opt into auth, privacy and storage hooks.
|
|
87
87
|
*/
|
|
88
|
-
declare function
|
|
88
|
+
declare function createAiAppAssistantServer<TContext = undefined>(options: CreateAiAppAssistantServerOptions<TContext>): AiAppAssistantServer<TContext>;
|
|
89
89
|
|
|
90
|
-
interface
|
|
90
|
+
interface AiAppAssistantDeploymentDefaultsOptions {
|
|
91
91
|
enabled: boolean;
|
|
92
92
|
/** `provider:model`, for example `mistral:mistral-small-latest`. */
|
|
93
93
|
model?: string;
|
|
94
94
|
apiKeys?: Partial<Record<BuiltInProvider, string | undefined>>;
|
|
95
95
|
baseURLs?: Partial<Record<BuiltInProvider, string | undefined>>;
|
|
96
|
-
access?:
|
|
97
|
-
quota?:
|
|
96
|
+
access?: AiAppAssistantConfiguration["access"];
|
|
97
|
+
quota?: AiAppAssistantConfiguration["quota"];
|
|
98
98
|
maxConversationTurns?: number;
|
|
99
99
|
}
|
|
100
|
-
interface
|
|
101
|
-
configuration?:
|
|
100
|
+
interface AiAppAssistantDeploymentDefaults {
|
|
101
|
+
configuration?: AiAppAssistantConfiguration;
|
|
102
102
|
resolveApiKey(provider: BuiltInProvider): string | undefined;
|
|
103
103
|
}
|
|
104
104
|
/** Parses deployment defaults once while retaining provider-neutral runtime configuration. */
|
|
105
|
-
declare function
|
|
105
|
+
declare function createAiAppAssistantDeploymentDefaults(options: AiAppAssistantDeploymentDefaultsOptions): AiAppAssistantDeploymentDefaults;
|
|
106
106
|
|
|
107
107
|
interface FilterOpenApiContextOptions {
|
|
108
108
|
/** Path prefixes that must never be sent to the assistant. */
|
|
@@ -138,4 +138,4 @@ interface OpenAiCompatibleGeneratorOptions {
|
|
|
138
138
|
*/
|
|
139
139
|
declare function createOpenAiCompatibleGenerator(options: OpenAiCompatibleGeneratorOptions): AnswerGenerator;
|
|
140
140
|
|
|
141
|
-
export {
|
|
141
|
+
export { AiAppAssistant, AiAppAssistantConfiguration, type AiAppAssistantDeploymentDefaults, type AiAppAssistantDeploymentDefaultsOptions, type AiAppAssistantFetchHandlerOptions, type AiAppAssistantFetchHandlers, type AiAppAssistantNodeHttpAdapterOptions, type AiAppAssistantNodeHttpHandler, type AiAppAssistantNodeHttpListener, AiAppAssistantOptions, AiAppAssistantRequestError, type AiAppAssistantServer, AiAppAssistantStreamEvent, AnswerGenerator, BuiltInProvider, type CreateAiAppAssistantServerOptions, DocumentationSource, type FilterOpenApiContextOptions, type OpenAiCompatibleGeneratorOptions, OpenApiDocument, createAiAppAssistantDeploymentDefaults, createAiAppAssistantFetchHandlers, createAiAppAssistantNodeHttpListener, createAiAppAssistantServer, createOpenAiCompatibleGenerator, filterOpenApiContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
1
|
+
import { A as AiAppAssistant, a as AiAppAssistantStreamEvent, b as AiAppAssistantConfiguration, B as BuiltInProvider } from './managed-server-BGQ-1jkx.js';
|
|
2
|
+
export { c as AiAppAssistantAccessRule, d as AiAppAssistantConfigurationActor, e as AiAppAssistantConfigurationAdministration, f as AiAppAssistantConfigurationAuditChange, g as AiAppAssistantConfigurationAuditEntry, h as AiAppAssistantConfigurationAuditField, i as AiAppAssistantConfigurationChangeEvent, j as AiAppAssistantConfigurationConflictError, k as AiAppAssistantConfigurationManager, l as AiAppAssistantConfigurationManagerOptions, m as AiAppAssistantConfigurationRepository, n as AiAppAssistantConfigurationSaveResult, o as AiAppAssistantConfigurationSynchronizer, p as AiAppAssistantConfigurationView, q as AiAppAssistantGenerationEvent, r as AiAppAssistantGenerationOperation, s as AiAppAssistantKeyValueStore, t as AiAppAssistantManagedConfigurationSetup, u as AiAppAssistantManagedStorage, v as AiAppAssistantManagementError, w as AiAppAssistantManagementErrorCode, x as AiAppAssistantQuotaPolicy, y as AiAppAssistantQuotaResult, z as AiAppAssistantQuotaStore, C as AiAppAssistantRecentFailure, D as AiAppAssistantRedisClient, E as AiAppAssistantRedisQuotaClient, F as AiAppAssistantRedisTelemetryClient, G as AiAppAssistantRuntimeIdentity, H as AiAppAssistantSecretProtector, I as AiAppAssistantTelemetryStore, J as AiAppAssistantTelemetrySummary, K as AiModelDiscoveryError, L as AiModelInfo, N as AiProviderInfo, O as CreateAiAppAssistantConfigurationRepositoryOptions, P as CreateManagedAiAppAssistantRuntimeOptions, Q as CreateManagedAiAppAssistantServerOptions, R as ListAiModelsOptions, S as ManagedAiAppAssistantFetchHandlerOptions, T as ManagedAiAppAssistantFetchHandlers, U as ManagedAiAppAssistantRuntime, M as ManagedAiAppAssistantServer, V as createAes256GcmSecretProtector, W as createAiAppAssistant, X as createAiAppAssistantConfigurationRepository, Y as createAiAppAssistantFailureEvent, Z as createDisabledSecretProtector, _ as createManagedAiAppAssistantFetchHandlers, $ as createManagedAiAppAssistantRuntime, a0 as createManagedAiAppAssistantServer, a1 as createMemoryAiAppAssistantQuotaStore, a2 as createMemoryAiAppAssistantStore, a3 as createMemoryAiAppAssistantTelemetryStore, a4 as createPollingAiAppAssistantConfigurationSynchronizer, a5 as createRedisAiAppAssistantQuotaStore, a6 as createRedisAiAppAssistantStore, a7 as createRedisAiAppAssistantTelemetryStore, a8 as listAiModels, a9 as listAiProviders, aa as validateAndSaveAiAppAssistantConfiguration } from './managed-server-BGQ-1jkx.js';
|
|
3
|
+
import { AiAppAssistantRequest, AiAppAssistantResponse } from '@123toto/ai-app-assistant-contracts';
|
|
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';
|
|
6
|
-
import { A as AnswerGenerator, D as DocumentationSource, a as
|
|
7
|
-
export { b as AiSdkConfigurationError, c as AiSdkConnectionTestOptions, d as AiSdkConnectionTestResult, e as AiSdkFailureCode, f as AiSdkGenerationError, g as AiSdkGeneratorOptions, E as EvidenceBundle, h as EvidenceItem, G as GenerationOptions, i as GenerationProgress, M as ModelCapabilities, j as createAiSdkGenerator, n as normalizeAiSdkGenerationError, t as testAiSdkConnection } from './ai-sdk-
|
|
6
|
+
import { A as AnswerGenerator, D as DocumentationSource, a as AiAppAssistantOptions, O as OpenApiDocument } from './ai-sdk-qU3KgNu-.js';
|
|
7
|
+
export { b as AiSdkConfigurationError, c as AiSdkConnectionTestOptions, d as AiSdkConnectionTestResult, e as AiSdkFailureCode, f as AiSdkGenerationError, g as AiSdkGeneratorOptions, E as EvidenceBundle, h as EvidenceItem, G as GenerationOptions, i as GenerationProgress, M as ModelCapabilities, j as createAiSdkGenerator, n as normalizeAiSdkGenerationError, t as testAiSdkConnection } from './ai-sdk-qU3KgNu-.js';
|
|
8
8
|
import 'ai';
|
|
9
9
|
|
|
10
|
-
interface
|
|
11
|
-
assistant:
|
|
10
|
+
interface AiAppAssistantFetchHandlerOptions<TContext = undefined> {
|
|
11
|
+
assistant: AiAppAssistant;
|
|
12
12
|
/** Resolves framework-specific authentication into an application context. */
|
|
13
13
|
resolveContext?: (request: Request) => Promise<TContext> | TContext;
|
|
14
14
|
/** Optional application authorization executed before assistant work. */
|
|
@@ -16,24 +16,24 @@ interface AiDocsFetchHandlerOptions<TContext = undefined> {
|
|
|
16
16
|
/** Explicit opt-in for public prototypes without authentication hooks. */
|
|
17
17
|
allowAnonymous?: boolean;
|
|
18
18
|
/** Optional privacy/input policy applied after protocol validation. */
|
|
19
|
-
transformRequest?: (input:
|
|
19
|
+
transformRequest?: (input: AiAppAssistantRequest, context: TContext) => Promise<AiAppAssistantRequest> | AiAppAssistantRequest;
|
|
20
20
|
/** Optional privacy/output policy applied before serialization. */
|
|
21
|
-
transformResponse?: (response:
|
|
21
|
+
transformResponse?: (response: AiAppAssistantResponse, context: TContext) => Promise<AiAppAssistantResponse> | AiAppAssistantResponse;
|
|
22
22
|
/** Applies privacy rules to progressive text before it leaves the backend. */
|
|
23
|
-
transformStreamEvent?: (event:
|
|
23
|
+
transformStreamEvent?: (event: AiAppAssistantStreamEvent, context: TContext) => Promise<AiAppAssistantStreamEvent> | AiAppAssistantStreamEvent;
|
|
24
24
|
/** Maximum HTTP request size. Defaults slightly above the protocol limit. */
|
|
25
25
|
maxBodyBytes?: number;
|
|
26
26
|
/** Maps application errors without coupling the library to one framework. */
|
|
27
27
|
onError?: (error: unknown, request: Request) => Promise<Response> | Response;
|
|
28
28
|
}
|
|
29
|
-
interface
|
|
29
|
+
interface AiAppAssistantFetchHandlers {
|
|
30
30
|
ask(request: Request): Promise<Response>;
|
|
31
31
|
stream(request: Request): Promise<Response>;
|
|
32
32
|
/** Dispatches to `stream` when the pathname ends in `/stream`, otherwise to `ask`. */
|
|
33
33
|
handle(request: Request): Promise<Response>;
|
|
34
34
|
}
|
|
35
35
|
/** Explicit safe HTTP error that host authorization hooks can throw. */
|
|
36
|
-
declare class
|
|
36
|
+
declare class AiAppAssistantRequestError extends Error {
|
|
37
37
|
readonly status: number;
|
|
38
38
|
readonly code: string;
|
|
39
39
|
constructor(status: number, code: string, message: string);
|
|
@@ -42,27 +42,27 @@ declare class AiDocsRequestError extends Error {
|
|
|
42
42
|
* Creates Fetch API handlers usable by standards-based runtimes and thin
|
|
43
43
|
* Express, Fastify, Nest, Next.js, Hono, Bun or serverless adapters.
|
|
44
44
|
*/
|
|
45
|
-
declare function
|
|
45
|
+
declare function createAiAppAssistantFetchHandlers<TContext = undefined>(options: AiAppAssistantFetchHandlerOptions<TContext>): AiAppAssistantFetchHandlers;
|
|
46
46
|
|
|
47
|
-
interface
|
|
47
|
+
interface AiAppAssistantNodeHttpAdapterOptions {
|
|
48
48
|
/** Used when the incoming request does not expose an absolute URL. */
|
|
49
49
|
origin?: string;
|
|
50
50
|
/** Protects the adapter before constructing a Fetch API Request. */
|
|
51
51
|
maxBodyBytes?: number;
|
|
52
52
|
}
|
|
53
|
-
type
|
|
53
|
+
type AiAppAssistantNodeHttpListener = (request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
|
54
54
|
/** Minimal shape implemented by both basic and managed Fetch handlers. */
|
|
55
|
-
interface
|
|
55
|
+
interface AiAppAssistantNodeHttpHandler {
|
|
56
56
|
handle(request: Request): Promise<Response>;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Bridges Node's native HTTP objects to the framework-neutral Fetch handlers.
|
|
60
60
|
* Express, Nest-on-Express and Fastify can expose their raw request/response.
|
|
61
61
|
*/
|
|
62
|
-
declare function
|
|
62
|
+
declare function createAiAppAssistantNodeHttpListener(handlers: AiAppAssistantNodeHttpHandler, options?: AiAppAssistantNodeHttpAdapterOptions): AiAppAssistantNodeHttpListener;
|
|
63
63
|
|
|
64
|
-
type AssistantPolicies = NonNullable<
|
|
65
|
-
interface
|
|
64
|
+
type AssistantPolicies = NonNullable<AiAppAssistantOptions["policies"]>;
|
|
65
|
+
interface CreateAiAppAssistantServerOptions<TContext = undefined> {
|
|
66
66
|
/** A custom generator takes precedence over the provider:model shortcut. */
|
|
67
67
|
generator?: AnswerGenerator;
|
|
68
68
|
/** Provider-neutral model identifier, for example `mistral:mistral-small-latest`. */
|
|
@@ -73,36 +73,36 @@ interface CreateAiDocsServerOptions<TContext = undefined> {
|
|
|
73
73
|
maxRetries?: number;
|
|
74
74
|
documents?: DocumentationSource[];
|
|
75
75
|
policies?: AssistantPolicies;
|
|
76
|
-
http?: Omit<
|
|
76
|
+
http?: Omit<AiAppAssistantFetchHandlerOptions<TContext>, "assistant">;
|
|
77
77
|
}
|
|
78
|
-
interface
|
|
79
|
-
assistant:
|
|
80
|
-
fetch:
|
|
78
|
+
interface AiAppAssistantServer<TContext = undefined> {
|
|
79
|
+
assistant: AiAppAssistant;
|
|
80
|
+
fetch: AiAppAssistantFetchHandlers;
|
|
81
81
|
/** Retained for consumers that want direct programmatic calls. */
|
|
82
|
-
options: Readonly<
|
|
82
|
+
options: Readonly<CreateAiAppAssistantServerOptions<TContext>>;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* Minimal framework-neutral server factory. Applications can start with a
|
|
86
86
|
* model string and documents, then opt into auth, privacy and storage hooks.
|
|
87
87
|
*/
|
|
88
|
-
declare function
|
|
88
|
+
declare function createAiAppAssistantServer<TContext = undefined>(options: CreateAiAppAssistantServerOptions<TContext>): AiAppAssistantServer<TContext>;
|
|
89
89
|
|
|
90
|
-
interface
|
|
90
|
+
interface AiAppAssistantDeploymentDefaultsOptions {
|
|
91
91
|
enabled: boolean;
|
|
92
92
|
/** `provider:model`, for example `mistral:mistral-small-latest`. */
|
|
93
93
|
model?: string;
|
|
94
94
|
apiKeys?: Partial<Record<BuiltInProvider, string | undefined>>;
|
|
95
95
|
baseURLs?: Partial<Record<BuiltInProvider, string | undefined>>;
|
|
96
|
-
access?:
|
|
97
|
-
quota?:
|
|
96
|
+
access?: AiAppAssistantConfiguration["access"];
|
|
97
|
+
quota?: AiAppAssistantConfiguration["quota"];
|
|
98
98
|
maxConversationTurns?: number;
|
|
99
99
|
}
|
|
100
|
-
interface
|
|
101
|
-
configuration?:
|
|
100
|
+
interface AiAppAssistantDeploymentDefaults {
|
|
101
|
+
configuration?: AiAppAssistantConfiguration;
|
|
102
102
|
resolveApiKey(provider: BuiltInProvider): string | undefined;
|
|
103
103
|
}
|
|
104
104
|
/** Parses deployment defaults once while retaining provider-neutral runtime configuration. */
|
|
105
|
-
declare function
|
|
105
|
+
declare function createAiAppAssistantDeploymentDefaults(options: AiAppAssistantDeploymentDefaultsOptions): AiAppAssistantDeploymentDefaults;
|
|
106
106
|
|
|
107
107
|
interface FilterOpenApiContextOptions {
|
|
108
108
|
/** Path prefixes that must never be sent to the assistant. */
|
|
@@ -138,4 +138,4 @@ interface OpenAiCompatibleGeneratorOptions {
|
|
|
138
138
|
*/
|
|
139
139
|
declare function createOpenAiCompatibleGenerator(options: OpenAiCompatibleGeneratorOptions): AnswerGenerator;
|
|
140
140
|
|
|
141
|
-
export {
|
|
141
|
+
export { AiAppAssistant, AiAppAssistantConfiguration, type AiAppAssistantDeploymentDefaults, type AiAppAssistantDeploymentDefaultsOptions, type AiAppAssistantFetchHandlerOptions, type AiAppAssistantFetchHandlers, type AiAppAssistantNodeHttpAdapterOptions, type AiAppAssistantNodeHttpHandler, type AiAppAssistantNodeHttpListener, AiAppAssistantOptions, AiAppAssistantRequestError, type AiAppAssistantServer, AiAppAssistantStreamEvent, AnswerGenerator, BuiltInProvider, type CreateAiAppAssistantServerOptions, DocumentationSource, type FilterOpenApiContextOptions, type OpenAiCompatibleGeneratorOptions, OpenApiDocument, createAiAppAssistantDeploymentDefaults, createAiAppAssistantFetchHandlers, createAiAppAssistantNodeHttpListener, createAiAppAssistantServer, createOpenAiCompatibleGenerator, filterOpenApiContext };
|