@123toto/ai-app-assistant-server 0.1.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/LICENSE +21 -0
- package/README.md +88 -0
- package/dist/ai-sdk-QImICd56.d.cts +188 -0
- package/dist/ai-sdk-QImICd56.d.ts +188 -0
- package/dist/ai-sdk.cjs +564 -0
- package/dist/ai-sdk.cjs.map +1 -0
- package/dist/ai-sdk.d.cts +3 -0
- package/dist/ai-sdk.d.ts +3 -0
- package/dist/ai-sdk.js +17 -0
- package/dist/ai-sdk.js.map +1 -0
- package/dist/chunk-NIF6AW6I.js +537 -0
- package/dist/chunk-NIF6AW6I.js.map +1 -0
- package/dist/chunk-OA7OXUK7.js +136 -0
- package/dist/chunk-OA7OXUK7.js.map +1 -0
- package/dist/express.cjs +137 -0
- package/dist/express.cjs.map +1 -0
- package/dist/express.d.cts +49 -0
- package/dist/express.d.ts +49 -0
- package/dist/express.js +100 -0
- package/dist/express.js.map +1 -0
- package/dist/index.cjs +3063 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +141 -0
- package/dist/index.d.ts +141 -0
- package/dist/index.js +2372 -0
- package/dist/index.js.map +1 -0
- package/dist/managed-server-7iurKxF1.d.cts +533 -0
- package/dist/managed-server-CrZumvVU.d.ts +533 -0
- package/dist/nest.cjs +141 -0
- package/dist/nest.cjs.map +1 -0
- package/dist/nest.d.cts +47 -0
- package/dist/nest.d.ts +47 -0
- package/dist/nest.js +122 -0
- package/dist/nest.js.map +1 -0
- package/package.json +110 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { D as DocsAssistant, a as DocsAssistantStreamEvent, A as AiDocsConfiguration, B as BuiltInProvider } from './managed-server-7iurKxF1.cjs';
|
|
2
|
+
export { b as AiDocsAccessRule, c as AiDocsConfigurationActor, d as AiDocsConfigurationAdministration, e as AiDocsConfigurationAuditChange, f as AiDocsConfigurationAuditEntry, g as AiDocsConfigurationAuditField, h as AiDocsConfigurationChangeEvent, i as AiDocsConfigurationConflictError, j as AiDocsConfigurationManager, k as AiDocsConfigurationManagerOptions, l as AiDocsConfigurationRepository, m as AiDocsConfigurationSaveResult, n as AiDocsConfigurationSynchronizer, o as AiDocsConfigurationView, p as AiDocsGenerationEvent, q as AiDocsGenerationOperation, r as AiDocsKeyValueStore, s as AiDocsManagedConfigurationSetup, t as AiDocsManagedStorage, u as AiDocsManagementError, v as AiDocsManagementErrorCode, w as AiDocsQuotaPolicy, x as AiDocsQuotaResult, y as AiDocsQuotaStore, z as AiDocsRecentFailure, C as AiDocsRedisClient, E as AiDocsRedisQuotaClient, F as AiDocsRedisTelemetryClient, G as AiDocsRuntimeIdentity, H as AiDocsSecretProtector, I as AiDocsTelemetryStore, J as AiDocsTelemetrySummary, K as AiModelDiscoveryError, L as AiModelInfo, N as AiProviderInfo, O as CreateAiDocsConfigurationRepositoryOptions, P as CreateManagedAiDocsRuntimeOptions, Q as CreateManagedAiDocsServerOptions, R as ListAiModelsOptions, S as ManagedAiDocsFetchHandlerOptions, T as ManagedAiDocsFetchHandlers, U as ManagedAiDocsRuntime, M as ManagedAiDocsServer, V as createAes256GcmSecretProtector, W as createAiDocsConfigurationRepository, X as createAiDocsFailureEvent, Y as createDisabledSecretProtector, Z as createDocsAssistant, _ as createManagedAiDocsFetchHandlers, $ as createManagedAiDocsRuntime, a0 as createManagedAiDocsServer, a1 as createMemoryAiDocsQuotaStore, a2 as createMemoryAiDocsStore, a3 as createMemoryAiDocsTelemetryStore, a4 as createPollingAiDocsConfigurationSynchronizer, a5 as createRedisAiDocsQuotaStore, a6 as createRedisAiDocsStore, a7 as createRedisAiDocsTelemetryStore, a8 as listAiModels, a9 as listAiProviders, aa as validateAndSaveAiDocsConfiguration } from './managed-server-7iurKxF1.cjs';
|
|
3
|
+
import { AskDocumentationRequest, AskDocumentationResponse } from '@123toto/ai-app-assistant-contracts';
|
|
4
|
+
export { AiDocsConfigurationFieldSource, AiDocsConfigurationInput, AiDocsConfigurationOptions, AiDocsConnectionResult, AiDocsConnectionTestInput, AiDocsCredentials, AiDocsManagedConfigurationView, AiDocsModelInfoContract, AiDocsProvider, AiDocsProviderInfoContract, AiDocsRuntimeConnection, AiDocsRuntimeConnectionStatus, AskDocumentationRequest, AskDocumentationResponse, AskDocumentationStreamEvent, EvidenceSource, GeneratedAnswer, PROTOCOL_VERSION, aiDocsAccessRuleSchema, aiDocsConfigurationInputSchema, aiDocsConfigurationOptionsSchema, aiDocsConfigurationSaveResultSchema, aiDocsConnectionResultSchema, aiDocsConnectionTestInputSchema, aiDocsCredentialsSchema, aiDocsManagedConfigurationViewSchema, aiDocsModelInfoSchema, aiDocsProviderInfoSchema, aiDocsProviderSchema, askDocumentationRequestSchema, askDocumentationResponseSchema, askDocumentationStreamEventSchema } from '@123toto/ai-app-assistant-contracts';
|
|
5
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
6
|
+
import { A as AnswerGenerator, D as DocumentationSource, a as DocsAssistantOptions, O as OpenApiDocument } from './ai-sdk-QImICd56.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-QImICd56.cjs';
|
|
8
|
+
import 'ai';
|
|
9
|
+
|
|
10
|
+
interface AiDocsFetchHandlerOptions<TContext = undefined> {
|
|
11
|
+
assistant: DocsAssistant;
|
|
12
|
+
/** Resolves framework-specific authentication into an application context. */
|
|
13
|
+
resolveContext?: (request: Request) => Promise<TContext> | TContext;
|
|
14
|
+
/** Optional application authorization executed before assistant work. */
|
|
15
|
+
authorize?: (context: TContext, request: Request) => Promise<void> | void;
|
|
16
|
+
/** Explicit opt-in for public prototypes without authentication hooks. */
|
|
17
|
+
allowAnonymous?: boolean;
|
|
18
|
+
/** Optional privacy/input policy applied after protocol validation. */
|
|
19
|
+
transformRequest?: (input: AskDocumentationRequest, context: TContext) => Promise<AskDocumentationRequest> | AskDocumentationRequest;
|
|
20
|
+
/** Optional privacy/output policy applied before serialization. */
|
|
21
|
+
transformResponse?: (response: AskDocumentationResponse, context: TContext) => Promise<AskDocumentationResponse> | AskDocumentationResponse;
|
|
22
|
+
/** Applies privacy rules to progressive text before it leaves the backend. */
|
|
23
|
+
transformStreamEvent?: (event: DocsAssistantStreamEvent, context: TContext) => Promise<DocsAssistantStreamEvent> | DocsAssistantStreamEvent;
|
|
24
|
+
/** Maximum HTTP request size. Defaults slightly above the protocol limit. */
|
|
25
|
+
maxBodyBytes?: number;
|
|
26
|
+
/** Maps application errors without coupling the library to one framework. */
|
|
27
|
+
onError?: (error: unknown, request: Request) => Promise<Response> | Response;
|
|
28
|
+
}
|
|
29
|
+
interface AiDocsFetchHandlers {
|
|
30
|
+
ask(request: Request): Promise<Response>;
|
|
31
|
+
stream(request: Request): Promise<Response>;
|
|
32
|
+
/** Dispatches to `stream` when the pathname ends in `/stream`, otherwise to `ask`. */
|
|
33
|
+
handle(request: Request): Promise<Response>;
|
|
34
|
+
}
|
|
35
|
+
/** Explicit safe HTTP error that host authorization hooks can throw. */
|
|
36
|
+
declare class AiDocsRequestError extends Error {
|
|
37
|
+
readonly status: number;
|
|
38
|
+
readonly code: string;
|
|
39
|
+
constructor(status: number, code: string, message: string);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates Fetch API handlers usable by standards-based runtimes and thin
|
|
43
|
+
* Express, Fastify, Nest, Next.js, Hono, Bun or serverless adapters.
|
|
44
|
+
*/
|
|
45
|
+
declare function createAiDocsFetchHandlers<TContext = undefined>(options: AiDocsFetchHandlerOptions<TContext>): AiDocsFetchHandlers;
|
|
46
|
+
|
|
47
|
+
interface AiDocsNodeHttpAdapterOptions {
|
|
48
|
+
/** Used when the incoming request does not expose an absolute URL. */
|
|
49
|
+
origin?: string;
|
|
50
|
+
/** Protects the adapter before constructing a Fetch API Request. */
|
|
51
|
+
maxBodyBytes?: number;
|
|
52
|
+
}
|
|
53
|
+
type AiDocsNodeHttpListener = (request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
|
54
|
+
/** Minimal shape implemented by both basic and managed Fetch handlers. */
|
|
55
|
+
interface AiDocsNodeHttpHandler {
|
|
56
|
+
handle(request: Request): Promise<Response>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Bridges Node's native HTTP objects to the framework-neutral Fetch handlers.
|
|
60
|
+
* Express, Nest-on-Express and Fastify can expose their raw request/response.
|
|
61
|
+
*/
|
|
62
|
+
declare function createAiDocsNodeHttpListener(handlers: AiDocsNodeHttpHandler, options?: AiDocsNodeHttpAdapterOptions): AiDocsNodeHttpListener;
|
|
63
|
+
|
|
64
|
+
type AssistantPolicies = NonNullable<DocsAssistantOptions["policies"]>;
|
|
65
|
+
interface CreateAiDocsServerOptions<TContext = undefined> {
|
|
66
|
+
/** A custom generator takes precedence over the provider:model shortcut. */
|
|
67
|
+
generator?: AnswerGenerator;
|
|
68
|
+
/** Provider-neutral model identifier, for example `mistral:mistral-small-latest`. */
|
|
69
|
+
model?: string;
|
|
70
|
+
apiKey?: string;
|
|
71
|
+
baseURL?: string;
|
|
72
|
+
timeoutMs?: number;
|
|
73
|
+
maxRetries?: number;
|
|
74
|
+
documents?: DocumentationSource[];
|
|
75
|
+
policies?: AssistantPolicies;
|
|
76
|
+
http?: Omit<AiDocsFetchHandlerOptions<TContext>, "assistant">;
|
|
77
|
+
}
|
|
78
|
+
interface AiDocsServer<TContext = undefined> {
|
|
79
|
+
assistant: DocsAssistant;
|
|
80
|
+
fetch: AiDocsFetchHandlers;
|
|
81
|
+
/** Retained for consumers that want direct programmatic calls. */
|
|
82
|
+
options: Readonly<CreateAiDocsServerOptions<TContext>>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Minimal framework-neutral server factory. Applications can start with a
|
|
86
|
+
* model string and documents, then opt into auth, privacy and storage hooks.
|
|
87
|
+
*/
|
|
88
|
+
declare function createAiDocsServer<TContext = undefined>(options: CreateAiDocsServerOptions<TContext>): AiDocsServer<TContext>;
|
|
89
|
+
|
|
90
|
+
interface AiDocsDeploymentDefaultsOptions {
|
|
91
|
+
enabled: boolean;
|
|
92
|
+
/** `provider:model`, for example `mistral:mistral-small-latest`. */
|
|
93
|
+
model?: string;
|
|
94
|
+
apiKeys?: Partial<Record<BuiltInProvider, string | undefined>>;
|
|
95
|
+
baseURLs?: Partial<Record<BuiltInProvider, string | undefined>>;
|
|
96
|
+
access?: AiDocsConfiguration["access"];
|
|
97
|
+
quota?: AiDocsConfiguration["quota"];
|
|
98
|
+
maxConversationTurns?: number;
|
|
99
|
+
}
|
|
100
|
+
interface AiDocsDeploymentDefaults {
|
|
101
|
+
configuration?: AiDocsConfiguration;
|
|
102
|
+
resolveApiKey(provider: BuiltInProvider): string | undefined;
|
|
103
|
+
}
|
|
104
|
+
/** Parses deployment defaults once while retaining provider-neutral runtime configuration. */
|
|
105
|
+
declare function createAiDocsDeploymentDefaults(options: AiDocsDeploymentDefaultsOptions): AiDocsDeploymentDefaults;
|
|
106
|
+
|
|
107
|
+
interface FilterOpenApiContextOptions {
|
|
108
|
+
/** Path prefixes that must never be sent to the assistant. */
|
|
109
|
+
excludePathPrefixes?: string[];
|
|
110
|
+
/** Schema names that must never be sent to the assistant. */
|
|
111
|
+
excludeSchemaNames?: RegExp;
|
|
112
|
+
/** Tag names that must never be sent to the assistant. */
|
|
113
|
+
excludeTagNames?: RegExp;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Returns a copy of an OpenAPI document stripped of operational assistant APIs
|
|
117
|
+
* or any other host-defined paths that should not become model context.
|
|
118
|
+
*/
|
|
119
|
+
declare function filterOpenApiContext(document: OpenApiDocument, options?: FilterOpenApiContextOptions): OpenApiDocument;
|
|
120
|
+
|
|
121
|
+
interface OpenAiCompatibleGeneratorOptions {
|
|
122
|
+
endpoint: string;
|
|
123
|
+
model: string;
|
|
124
|
+
apiKey?: string;
|
|
125
|
+
apiKeyHeader?: string;
|
|
126
|
+
apiKeyPrefix?: string;
|
|
127
|
+
modelId?: string;
|
|
128
|
+
timeoutMs?: number;
|
|
129
|
+
maxOutputTokens?: number;
|
|
130
|
+
temperature?: number;
|
|
131
|
+
responseFormat?: "json-object" | "prompt-only";
|
|
132
|
+
headers?: Record<string, string>;
|
|
133
|
+
fetch?: typeof fetch;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Creates a small dependency-free adapter for OpenAI-compatible chat APIs.
|
|
137
|
+
* Credentials stay in the host backend and are never read from browser input.
|
|
138
|
+
*/
|
|
139
|
+
declare function createOpenAiCompatibleGenerator(options: OpenAiCompatibleGeneratorOptions): AnswerGenerator;
|
|
140
|
+
|
|
141
|
+
export { AiDocsConfiguration, type AiDocsDeploymentDefaults, type AiDocsDeploymentDefaultsOptions, type AiDocsFetchHandlerOptions, type AiDocsFetchHandlers, type AiDocsNodeHttpAdapterOptions, type AiDocsNodeHttpHandler, type AiDocsNodeHttpListener, AiDocsRequestError, type AiDocsServer, AnswerGenerator, BuiltInProvider, type CreateAiDocsServerOptions, DocsAssistant, DocsAssistantOptions, DocsAssistantStreamEvent, DocumentationSource, type FilterOpenApiContextOptions, type OpenAiCompatibleGeneratorOptions, OpenApiDocument, createAiDocsDeploymentDefaults, createAiDocsFetchHandlers, createAiDocsNodeHttpListener, createAiDocsServer, createOpenAiCompatibleGenerator, filterOpenApiContext };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { D as DocsAssistant, a as DocsAssistantStreamEvent, A as AiDocsConfiguration, B as BuiltInProvider } from './managed-server-CrZumvVU.js';
|
|
2
|
+
export { b as AiDocsAccessRule, c as AiDocsConfigurationActor, d as AiDocsConfigurationAdministration, e as AiDocsConfigurationAuditChange, f as AiDocsConfigurationAuditEntry, g as AiDocsConfigurationAuditField, h as AiDocsConfigurationChangeEvent, i as AiDocsConfigurationConflictError, j as AiDocsConfigurationManager, k as AiDocsConfigurationManagerOptions, l as AiDocsConfigurationRepository, m as AiDocsConfigurationSaveResult, n as AiDocsConfigurationSynchronizer, o as AiDocsConfigurationView, p as AiDocsGenerationEvent, q as AiDocsGenerationOperation, r as AiDocsKeyValueStore, s as AiDocsManagedConfigurationSetup, t as AiDocsManagedStorage, u as AiDocsManagementError, v as AiDocsManagementErrorCode, w as AiDocsQuotaPolicy, x as AiDocsQuotaResult, y as AiDocsQuotaStore, z as AiDocsRecentFailure, C as AiDocsRedisClient, E as AiDocsRedisQuotaClient, F as AiDocsRedisTelemetryClient, G as AiDocsRuntimeIdentity, H as AiDocsSecretProtector, I as AiDocsTelemetryStore, J as AiDocsTelemetrySummary, K as AiModelDiscoveryError, L as AiModelInfo, N as AiProviderInfo, O as CreateAiDocsConfigurationRepositoryOptions, P as CreateManagedAiDocsRuntimeOptions, Q as CreateManagedAiDocsServerOptions, R as ListAiModelsOptions, S as ManagedAiDocsFetchHandlerOptions, T as ManagedAiDocsFetchHandlers, U as ManagedAiDocsRuntime, M as ManagedAiDocsServer, V as createAes256GcmSecretProtector, W as createAiDocsConfigurationRepository, X as createAiDocsFailureEvent, Y as createDisabledSecretProtector, Z as createDocsAssistant, _ as createManagedAiDocsFetchHandlers, $ as createManagedAiDocsRuntime, a0 as createManagedAiDocsServer, a1 as createMemoryAiDocsQuotaStore, a2 as createMemoryAiDocsStore, a3 as createMemoryAiDocsTelemetryStore, a4 as createPollingAiDocsConfigurationSynchronizer, a5 as createRedisAiDocsQuotaStore, a6 as createRedisAiDocsStore, a7 as createRedisAiDocsTelemetryStore, a8 as listAiModels, a9 as listAiProviders, aa as validateAndSaveAiDocsConfiguration } from './managed-server-CrZumvVU.js';
|
|
3
|
+
import { AskDocumentationRequest, AskDocumentationResponse } from '@123toto/ai-app-assistant-contracts';
|
|
4
|
+
export { AiDocsConfigurationFieldSource, AiDocsConfigurationInput, AiDocsConfigurationOptions, AiDocsConnectionResult, AiDocsConnectionTestInput, AiDocsCredentials, AiDocsManagedConfigurationView, AiDocsModelInfoContract, AiDocsProvider, AiDocsProviderInfoContract, AiDocsRuntimeConnection, AiDocsRuntimeConnectionStatus, AskDocumentationRequest, AskDocumentationResponse, AskDocumentationStreamEvent, EvidenceSource, GeneratedAnswer, PROTOCOL_VERSION, aiDocsAccessRuleSchema, aiDocsConfigurationInputSchema, aiDocsConfigurationOptionsSchema, aiDocsConfigurationSaveResultSchema, aiDocsConnectionResultSchema, aiDocsConnectionTestInputSchema, aiDocsCredentialsSchema, aiDocsManagedConfigurationViewSchema, aiDocsModelInfoSchema, aiDocsProviderInfoSchema, aiDocsProviderSchema, askDocumentationRequestSchema, askDocumentationResponseSchema, askDocumentationStreamEventSchema } from '@123toto/ai-app-assistant-contracts';
|
|
5
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
6
|
+
import { A as AnswerGenerator, D as DocumentationSource, a as DocsAssistantOptions, O as OpenApiDocument } from './ai-sdk-QImICd56.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-QImICd56.js';
|
|
8
|
+
import 'ai';
|
|
9
|
+
|
|
10
|
+
interface AiDocsFetchHandlerOptions<TContext = undefined> {
|
|
11
|
+
assistant: DocsAssistant;
|
|
12
|
+
/** Resolves framework-specific authentication into an application context. */
|
|
13
|
+
resolveContext?: (request: Request) => Promise<TContext> | TContext;
|
|
14
|
+
/** Optional application authorization executed before assistant work. */
|
|
15
|
+
authorize?: (context: TContext, request: Request) => Promise<void> | void;
|
|
16
|
+
/** Explicit opt-in for public prototypes without authentication hooks. */
|
|
17
|
+
allowAnonymous?: boolean;
|
|
18
|
+
/** Optional privacy/input policy applied after protocol validation. */
|
|
19
|
+
transformRequest?: (input: AskDocumentationRequest, context: TContext) => Promise<AskDocumentationRequest> | AskDocumentationRequest;
|
|
20
|
+
/** Optional privacy/output policy applied before serialization. */
|
|
21
|
+
transformResponse?: (response: AskDocumentationResponse, context: TContext) => Promise<AskDocumentationResponse> | AskDocumentationResponse;
|
|
22
|
+
/** Applies privacy rules to progressive text before it leaves the backend. */
|
|
23
|
+
transformStreamEvent?: (event: DocsAssistantStreamEvent, context: TContext) => Promise<DocsAssistantStreamEvent> | DocsAssistantStreamEvent;
|
|
24
|
+
/** Maximum HTTP request size. Defaults slightly above the protocol limit. */
|
|
25
|
+
maxBodyBytes?: number;
|
|
26
|
+
/** Maps application errors without coupling the library to one framework. */
|
|
27
|
+
onError?: (error: unknown, request: Request) => Promise<Response> | Response;
|
|
28
|
+
}
|
|
29
|
+
interface AiDocsFetchHandlers {
|
|
30
|
+
ask(request: Request): Promise<Response>;
|
|
31
|
+
stream(request: Request): Promise<Response>;
|
|
32
|
+
/** Dispatches to `stream` when the pathname ends in `/stream`, otherwise to `ask`. */
|
|
33
|
+
handle(request: Request): Promise<Response>;
|
|
34
|
+
}
|
|
35
|
+
/** Explicit safe HTTP error that host authorization hooks can throw. */
|
|
36
|
+
declare class AiDocsRequestError extends Error {
|
|
37
|
+
readonly status: number;
|
|
38
|
+
readonly code: string;
|
|
39
|
+
constructor(status: number, code: string, message: string);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates Fetch API handlers usable by standards-based runtimes and thin
|
|
43
|
+
* Express, Fastify, Nest, Next.js, Hono, Bun or serverless adapters.
|
|
44
|
+
*/
|
|
45
|
+
declare function createAiDocsFetchHandlers<TContext = undefined>(options: AiDocsFetchHandlerOptions<TContext>): AiDocsFetchHandlers;
|
|
46
|
+
|
|
47
|
+
interface AiDocsNodeHttpAdapterOptions {
|
|
48
|
+
/** Used when the incoming request does not expose an absolute URL. */
|
|
49
|
+
origin?: string;
|
|
50
|
+
/** Protects the adapter before constructing a Fetch API Request. */
|
|
51
|
+
maxBodyBytes?: number;
|
|
52
|
+
}
|
|
53
|
+
type AiDocsNodeHttpListener = (request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
|
54
|
+
/** Minimal shape implemented by both basic and managed Fetch handlers. */
|
|
55
|
+
interface AiDocsNodeHttpHandler {
|
|
56
|
+
handle(request: Request): Promise<Response>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Bridges Node's native HTTP objects to the framework-neutral Fetch handlers.
|
|
60
|
+
* Express, Nest-on-Express and Fastify can expose their raw request/response.
|
|
61
|
+
*/
|
|
62
|
+
declare function createAiDocsNodeHttpListener(handlers: AiDocsNodeHttpHandler, options?: AiDocsNodeHttpAdapterOptions): AiDocsNodeHttpListener;
|
|
63
|
+
|
|
64
|
+
type AssistantPolicies = NonNullable<DocsAssistantOptions["policies"]>;
|
|
65
|
+
interface CreateAiDocsServerOptions<TContext = undefined> {
|
|
66
|
+
/** A custom generator takes precedence over the provider:model shortcut. */
|
|
67
|
+
generator?: AnswerGenerator;
|
|
68
|
+
/** Provider-neutral model identifier, for example `mistral:mistral-small-latest`. */
|
|
69
|
+
model?: string;
|
|
70
|
+
apiKey?: string;
|
|
71
|
+
baseURL?: string;
|
|
72
|
+
timeoutMs?: number;
|
|
73
|
+
maxRetries?: number;
|
|
74
|
+
documents?: DocumentationSource[];
|
|
75
|
+
policies?: AssistantPolicies;
|
|
76
|
+
http?: Omit<AiDocsFetchHandlerOptions<TContext>, "assistant">;
|
|
77
|
+
}
|
|
78
|
+
interface AiDocsServer<TContext = undefined> {
|
|
79
|
+
assistant: DocsAssistant;
|
|
80
|
+
fetch: AiDocsFetchHandlers;
|
|
81
|
+
/** Retained for consumers that want direct programmatic calls. */
|
|
82
|
+
options: Readonly<CreateAiDocsServerOptions<TContext>>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Minimal framework-neutral server factory. Applications can start with a
|
|
86
|
+
* model string and documents, then opt into auth, privacy and storage hooks.
|
|
87
|
+
*/
|
|
88
|
+
declare function createAiDocsServer<TContext = undefined>(options: CreateAiDocsServerOptions<TContext>): AiDocsServer<TContext>;
|
|
89
|
+
|
|
90
|
+
interface AiDocsDeploymentDefaultsOptions {
|
|
91
|
+
enabled: boolean;
|
|
92
|
+
/** `provider:model`, for example `mistral:mistral-small-latest`. */
|
|
93
|
+
model?: string;
|
|
94
|
+
apiKeys?: Partial<Record<BuiltInProvider, string | undefined>>;
|
|
95
|
+
baseURLs?: Partial<Record<BuiltInProvider, string | undefined>>;
|
|
96
|
+
access?: AiDocsConfiguration["access"];
|
|
97
|
+
quota?: AiDocsConfiguration["quota"];
|
|
98
|
+
maxConversationTurns?: number;
|
|
99
|
+
}
|
|
100
|
+
interface AiDocsDeploymentDefaults {
|
|
101
|
+
configuration?: AiDocsConfiguration;
|
|
102
|
+
resolveApiKey(provider: BuiltInProvider): string | undefined;
|
|
103
|
+
}
|
|
104
|
+
/** Parses deployment defaults once while retaining provider-neutral runtime configuration. */
|
|
105
|
+
declare function createAiDocsDeploymentDefaults(options: AiDocsDeploymentDefaultsOptions): AiDocsDeploymentDefaults;
|
|
106
|
+
|
|
107
|
+
interface FilterOpenApiContextOptions {
|
|
108
|
+
/** Path prefixes that must never be sent to the assistant. */
|
|
109
|
+
excludePathPrefixes?: string[];
|
|
110
|
+
/** Schema names that must never be sent to the assistant. */
|
|
111
|
+
excludeSchemaNames?: RegExp;
|
|
112
|
+
/** Tag names that must never be sent to the assistant. */
|
|
113
|
+
excludeTagNames?: RegExp;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Returns a copy of an OpenAPI document stripped of operational assistant APIs
|
|
117
|
+
* or any other host-defined paths that should not become model context.
|
|
118
|
+
*/
|
|
119
|
+
declare function filterOpenApiContext(document: OpenApiDocument, options?: FilterOpenApiContextOptions): OpenApiDocument;
|
|
120
|
+
|
|
121
|
+
interface OpenAiCompatibleGeneratorOptions {
|
|
122
|
+
endpoint: string;
|
|
123
|
+
model: string;
|
|
124
|
+
apiKey?: string;
|
|
125
|
+
apiKeyHeader?: string;
|
|
126
|
+
apiKeyPrefix?: string;
|
|
127
|
+
modelId?: string;
|
|
128
|
+
timeoutMs?: number;
|
|
129
|
+
maxOutputTokens?: number;
|
|
130
|
+
temperature?: number;
|
|
131
|
+
responseFormat?: "json-object" | "prompt-only";
|
|
132
|
+
headers?: Record<string, string>;
|
|
133
|
+
fetch?: typeof fetch;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Creates a small dependency-free adapter for OpenAI-compatible chat APIs.
|
|
137
|
+
* Credentials stay in the host backend and are never read from browser input.
|
|
138
|
+
*/
|
|
139
|
+
declare function createOpenAiCompatibleGenerator(options: OpenAiCompatibleGeneratorOptions): AnswerGenerator;
|
|
140
|
+
|
|
141
|
+
export { AiDocsConfiguration, type AiDocsDeploymentDefaults, type AiDocsDeploymentDefaultsOptions, type AiDocsFetchHandlerOptions, type AiDocsFetchHandlers, type AiDocsNodeHttpAdapterOptions, type AiDocsNodeHttpHandler, type AiDocsNodeHttpListener, AiDocsRequestError, type AiDocsServer, AnswerGenerator, BuiltInProvider, type CreateAiDocsServerOptions, DocsAssistant, DocsAssistantOptions, DocsAssistantStreamEvent, DocumentationSource, type FilterOpenApiContextOptions, type OpenAiCompatibleGeneratorOptions, OpenApiDocument, createAiDocsDeploymentDefaults, createAiDocsFetchHandlers, createAiDocsNodeHttpListener, createAiDocsServer, createOpenAiCompatibleGenerator, filterOpenApiContext };
|