@marinoscar/platform-api 0.1.0-next.5 → 0.1.0-next.6
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/CHANGELOG.md +12 -0
- package/dist/ai/core/ai-error.d.ts +15 -158
- package/dist/ai/core/ai-error.d.ts.map +1 -1
- package/dist/ai/core/ai-error.js +58 -221
- package/dist/ai/core/ai-error.js.map +1 -1
- package/dist/ai/core/capabilities.d.ts +3 -126
- package/dist/ai/core/capabilities.d.ts.map +1 -1
- package/dist/ai/core/capabilities.js +13 -109
- package/dist/ai/core/capabilities.js.map +1 -1
- package/dist/ai/core/conversation.d.ts +2 -15
- package/dist/ai/core/conversation.d.ts.map +1 -1
- package/dist/ai/core/conversation.js +9 -54
- package/dist/ai/core/conversation.js.map +1 -1
- package/dist/ai/core/hosted-tools.d.ts +3 -172
- package/dist/ai/core/hosted-tools.d.ts.map +1 -1
- package/dist/ai/core/hosted-tools.js +20 -286
- package/dist/ai/core/hosted-tools.js.map +1 -1
- package/dist/ai/core/provider-adapter.interface.d.ts +3 -260
- package/dist/ai/core/provider-adapter.interface.d.ts.map +1 -1
- package/dist/ai/core/provider-adapter.interface.js +7 -29
- package/dist/ai/core/provider-adapter.interface.js.map +1 -1
- package/dist/ai/core/structured-output.d.ts +3 -49
- package/dist/ai/core/structured-output.d.ts.map +1 -1
- package/dist/ai/core/structured-output.js +9 -80
- package/dist/ai/core/structured-output.js.map +1 -1
- package/dist/ai/core/tools.d.ts +3 -93
- package/dist/ai/core/tools.d.ts.map +1 -1
- package/dist/ai/core/tools.js +9 -73
- package/dist/ai/core/tools.js.map +1 -1
- package/dist/ai/core/types/file-inputs.types.d.ts +3 -102
- package/dist/ai/core/types/file-inputs.types.d.ts.map +1 -1
- package/dist/ai/core/types/file-inputs.types.js +14 -78
- package/dist/ai/core/types/file-inputs.types.js.map +1 -1
- package/dist/ai/core/types/media.types.d.ts +3 -616
- package/dist/ai/core/types/media.types.d.ts.map +1 -1
- package/dist/ai/core/types/media.types.js +33 -203
- package/dist/ai/core/types/media.types.js.map +1 -1
- package/dist/ai/core/types/responses.types.d.ts +3 -619
- package/dist/ai/core/types/responses.types.d.ts.map +1 -1
- package/dist/ai/core/types/responses.types.js +9 -57
- package/dist/ai/core/types/responses.types.js.map +1 -1
- package/dist/ai/http/dto/ai-images.dto.d.ts +4 -4
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +3 -3
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/providers/anthropic/anthropic-client.factory.d.ts +13 -15
- package/dist/ai/providers/anthropic/anthropic-client.factory.d.ts.map +1 -1
- package/dist/ai/providers/anthropic/anthropic-client.factory.js +23 -52
- package/dist/ai/providers/anthropic/anthropic-client.factory.js.map +1 -1
- package/dist/ai/providers/anthropic/anthropic.adapter.d.ts +15 -51
- package/dist/ai/providers/anthropic/anthropic.adapter.d.ts.map +1 -1
- package/dist/ai/providers/anthropic/anthropic.adapter.js +29 -293
- package/dist/ai/providers/anthropic/anthropic.adapter.js.map +1 -1
- package/dist/ai/providers/azure-openai/azure-openai-client.factory.d.ts +10 -14
- package/dist/ai/providers/azure-openai/azure-openai-client.factory.d.ts.map +1 -1
- package/dist/ai/providers/azure-openai/azure-openai-client.factory.js +20 -53
- package/dist/ai/providers/azure-openai/azure-openai-client.factory.js.map +1 -1
- package/dist/ai/providers/azure-openai/azure-openai.adapter.d.ts +14 -31
- package/dist/ai/providers/azure-openai/azure-openai.adapter.d.ts.map +1 -1
- package/dist/ai/providers/azure-openai/azure-openai.adapter.js +25 -170
- package/dist/ai/providers/azure-openai/azure-openai.adapter.js.map +1 -1
- package/dist/ai/providers/gemini/gemini-client.factory.d.ts +13 -18
- package/dist/ai/providers/gemini/gemini-client.factory.d.ts.map +1 -1
- package/dist/ai/providers/gemini/gemini-client.factory.js +24 -68
- package/dist/ai/providers/gemini/gemini-client.factory.js.map +1 -1
- package/dist/ai/providers/gemini/gemini.adapter.d.ts +15 -58
- package/dist/ai/providers/gemini/gemini.adapter.d.ts.map +1 -1
- package/dist/ai/providers/gemini/gemini.adapter.js +29 -348
- package/dist/ai/providers/gemini/gemini.adapter.js.map +1 -1
- package/dist/ai/providers/openai/openai-client.factory.d.ts +13 -35
- package/dist/ai/providers/openai/openai-client.factory.d.ts.map +1 -1
- package/dist/ai/providers/openai/openai-client.factory.js +25 -64
- package/dist/ai/providers/openai/openai-client.factory.js.map +1 -1
- package/dist/ai/providers/openai/openai.adapter.d.ts +15 -48
- package/dist/ai/providers/openai/openai.adapter.d.ts.map +1 -1
- package/dist/ai/providers/openai/openai.adapter.js +27 -206
- package/dist/ai/providers/openai/openai.adapter.js.map +1 -1
- package/dist/ai/providers/openai-compatible/openai-compatible-client.factory.d.ts +11 -11
- package/dist/ai/providers/openai-compatible/openai-compatible-client.factory.d.ts.map +1 -1
- package/dist/ai/providers/openai-compatible/openai-compatible-client.factory.js +18 -41
- package/dist/ai/providers/openai-compatible/openai-compatible-client.factory.js.map +1 -1
- package/dist/ai/providers/openai-compatible/openai-compatible.adapter.d.ts +14 -32
- package/dist/ai/providers/openai-compatible/openai-compatible.adapter.d.ts.map +1 -1
- package/dist/ai/providers/openai-compatible/openai-compatible.adapter.js +25 -149
- package/dist/ai/providers/openai-compatible/openai-compatible.adapter.js.map +1 -1
- package/dist/ai/providers/platform-ai-tracer.d.ts +4 -0
- package/dist/ai/providers/platform-ai-tracer.d.ts.map +1 -0
- package/dist/ai/providers/platform-ai-tracer.js +20 -0
- package/dist/ai/providers/platform-ai-tracer.js.map +1 -0
- package/dist/ai/runtime/ai-image-run-request.d.ts +1 -1
- package/dist/ai/testing/conformance/ai-no-sdk-leak.suite.d.ts +28 -5
- package/dist/ai/testing/conformance/ai-no-sdk-leak.suite.d.ts.map +1 -1
- package/dist/ai/testing/conformance/ai-no-sdk-leak.suite.js +54 -9
- package/dist/ai/testing/conformance/ai-no-sdk-leak.suite.js.map +1 -1
- package/dist/ai/testing/index.d.ts +1 -1
- package/dist/ai/testing/index.d.ts.map +1 -1
- package/dist/ai/testing/index.js +2 -1
- package/dist/ai/testing/index.js.map +1 -1
- package/dist/jobs/rate-limit.error.d.ts +2 -26
- package/dist/jobs/rate-limit.error.d.ts.map +1 -1
- package/dist/jobs/rate-limit.error.js +4 -52
- package/dist/jobs/rate-limit.error.js.map +1 -1
- package/dist/storage/config/storage-config.controller.d.ts +1 -1
- package/package.json +3 -2
- package/dist/ai/providers/anthropic/anthropic-errors.d.ts +0 -16
- package/dist/ai/providers/anthropic/anthropic-errors.d.ts.map +0 -1
- package/dist/ai/providers/anthropic/anthropic-errors.js +0 -156
- package/dist/ai/providers/anthropic/anthropic-errors.js.map +0 -1
- package/dist/ai/providers/anthropic/anthropic-messages.mapper.d.ts +0 -80
- package/dist/ai/providers/anthropic/anthropic-messages.mapper.d.ts.map +0 -1
- package/dist/ai/providers/anthropic/anthropic-messages.mapper.js +0 -536
- package/dist/ai/providers/anthropic/anthropic-messages.mapper.js.map +0 -1
- package/dist/ai/providers/anthropic/anthropic-model-catalog.d.ts +0 -49
- package/dist/ai/providers/anthropic/anthropic-model-catalog.d.ts.map +0 -1
- package/dist/ai/providers/anthropic/anthropic-model-catalog.js +0 -198
- package/dist/ai/providers/anthropic/anthropic-model-catalog.js.map +0 -1
- package/dist/ai/providers/anthropic/anthropic-stream.mapper.d.ts +0 -35
- package/dist/ai/providers/anthropic/anthropic-stream.mapper.d.ts.map +0 -1
- package/dist/ai/providers/anthropic/anthropic-stream.mapper.js +0 -203
- package/dist/ai/providers/anthropic/anthropic-stream.mapper.js.map +0 -1
- package/dist/ai/providers/anthropic/testing/anthropic-fixtures.d.ts +0 -18
- package/dist/ai/providers/anthropic/testing/anthropic-fixtures.d.ts.map +0 -1
- package/dist/ai/providers/anthropic/testing/anthropic-fixtures.js +0 -120
- package/dist/ai/providers/anthropic/testing/anthropic-fixtures.js.map +0 -1
- package/dist/ai/providers/anthropic/testing/anthropic-mock-transport.d.ts +0 -59
- package/dist/ai/providers/anthropic/testing/anthropic-mock-transport.d.ts.map +0 -1
- package/dist/ai/providers/anthropic/testing/anthropic-mock-transport.js +0 -206
- package/dist/ai/providers/anthropic/testing/anthropic-mock-transport.js.map +0 -1
- package/dist/ai/providers/azure-openai/azure-openai-settings.d.ts +0 -23
- package/dist/ai/providers/azure-openai/azure-openai-settings.d.ts.map +0 -1
- package/dist/ai/providers/azure-openai/azure-openai-settings.js +0 -54
- package/dist/ai/providers/azure-openai/azure-openai-settings.js.map +0 -1
- package/dist/ai/providers/gemini/gemini-content.mapper.d.ts +0 -98
- package/dist/ai/providers/gemini/gemini-content.mapper.d.ts.map +0 -1
- package/dist/ai/providers/gemini/gemini-content.mapper.js +0 -665
- package/dist/ai/providers/gemini/gemini-content.mapper.js.map +0 -1
- package/dist/ai/providers/gemini/gemini-embeddings.mapper.d.ts +0 -13
- package/dist/ai/providers/gemini/gemini-embeddings.mapper.d.ts.map +0 -1
- package/dist/ai/providers/gemini/gemini-embeddings.mapper.js +0 -78
- package/dist/ai/providers/gemini/gemini-embeddings.mapper.js.map +0 -1
- package/dist/ai/providers/gemini/gemini-errors.d.ts +0 -32
- package/dist/ai/providers/gemini/gemini-errors.d.ts.map +0 -1
- package/dist/ai/providers/gemini/gemini-errors.js +0 -191
- package/dist/ai/providers/gemini/gemini-errors.js.map +0 -1
- package/dist/ai/providers/gemini/gemini-model-catalog.d.ts +0 -45
- package/dist/ai/providers/gemini/gemini-model-catalog.d.ts.map +0 -1
- package/dist/ai/providers/gemini/gemini-model-catalog.js +0 -264
- package/dist/ai/providers/gemini/gemini-model-catalog.js.map +0 -1
- package/dist/ai/providers/gemini/gemini-stream.mapper.d.ts +0 -31
- package/dist/ai/providers/gemini/gemini-stream.mapper.d.ts.map +0 -1
- package/dist/ai/providers/gemini/gemini-stream.mapper.js +0 -118
- package/dist/ai/providers/gemini/gemini-stream.mapper.js.map +0 -1
- package/dist/ai/providers/gemini/testing/gemini-fixtures.d.ts +0 -80
- package/dist/ai/providers/gemini/testing/gemini-fixtures.d.ts.map +0 -1
- package/dist/ai/providers/gemini/testing/gemini-fixtures.js +0 -118
- package/dist/ai/providers/gemini/testing/gemini-fixtures.js.map +0 -1
- package/dist/ai/providers/gemini/testing/gemini-mock-transport.d.ts +0 -82
- package/dist/ai/providers/gemini/testing/gemini-mock-transport.d.ts.map +0 -1
- package/dist/ai/providers/gemini/testing/gemini-mock-transport.js +0 -342
- package/dist/ai/providers/gemini/testing/gemini-mock-transport.js.map +0 -1
- package/dist/ai/providers/openai/openai-audio.mapper.d.ts +0 -42
- package/dist/ai/providers/openai/openai-audio.mapper.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-audio.mapper.js +0 -266
- package/dist/ai/providers/openai/openai-audio.mapper.js.map +0 -1
- package/dist/ai/providers/openai/openai-call-telemetry.d.ts +0 -25
- package/dist/ai/providers/openai/openai-call-telemetry.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-call-telemetry.js +0 -93
- package/dist/ai/providers/openai/openai-call-telemetry.js.map +0 -1
- package/dist/ai/providers/openai/openai-chat-completions-stream.mapper.d.ts +0 -41
- package/dist/ai/providers/openai/openai-chat-completions-stream.mapper.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-chat-completions-stream.mapper.js +0 -173
- package/dist/ai/providers/openai/openai-chat-completions-stream.mapper.js.map +0 -1
- package/dist/ai/providers/openai/openai-chat-completions.engine.d.ts +0 -33
- package/dist/ai/providers/openai/openai-chat-completions.engine.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-chat-completions.engine.js +0 -165
- package/dist/ai/providers/openai/openai-chat-completions.engine.js.map +0 -1
- package/dist/ai/providers/openai/openai-chat-completions.mapper.d.ts +0 -42
- package/dist/ai/providers/openai/openai-chat-completions.mapper.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-chat-completions.mapper.js +0 -304
- package/dist/ai/providers/openai/openai-chat-completions.mapper.js.map +0 -1
- package/dist/ai/providers/openai/openai-embeddings.mapper.d.ts +0 -25
- package/dist/ai/providers/openai/openai-embeddings.mapper.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-embeddings.mapper.js +0 -81
- package/dist/ai/providers/openai/openai-embeddings.mapper.js.map +0 -1
- package/dist/ai/providers/openai/openai-errors.d.ts +0 -45
- package/dist/ai/providers/openai/openai-errors.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-errors.js +0 -247
- package/dist/ai/providers/openai/openai-errors.js.map +0 -1
- package/dist/ai/providers/openai/openai-family-guards.d.ts +0 -4
- package/dist/ai/providers/openai/openai-family-guards.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-family-guards.js +0 -19
- package/dist/ai/providers/openai/openai-family-guards.js.map +0 -1
- package/dist/ai/providers/openai/openai-images.mapper.d.ts +0 -23
- package/dist/ai/providers/openai/openai-images.mapper.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-images.mapper.js +0 -164
- package/dist/ai/providers/openai/openai-images.mapper.js.map +0 -1
- package/dist/ai/providers/openai/openai-model-catalog.d.ts +0 -36
- package/dist/ai/providers/openai/openai-model-catalog.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-model-catalog.js +0 -209
- package/dist/ai/providers/openai/openai-model-catalog.js.map +0 -1
- package/dist/ai/providers/openai/openai-realtime.mapper.d.ts +0 -18
- package/dist/ai/providers/openai/openai-realtime.mapper.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-realtime.mapper.js +0 -159
- package/dist/ai/providers/openai/openai-realtime.mapper.js.map +0 -1
- package/dist/ai/providers/openai/openai-redirect-guard.d.ts +0 -9
- package/dist/ai/providers/openai/openai-redirect-guard.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-redirect-guard.js +0 -61
- package/dist/ai/providers/openai/openai-redirect-guard.js.map +0 -1
- package/dist/ai/providers/openai/openai-responses.engine.d.ts +0 -50
- package/dist/ai/providers/openai/openai-responses.engine.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-responses.engine.js +0 -206
- package/dist/ai/providers/openai/openai-responses.engine.js.map +0 -1
- package/dist/ai/providers/openai/openai-responses.mapper.d.ts +0 -64
- package/dist/ai/providers/openai/openai-responses.mapper.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-responses.mapper.js +0 -580
- package/dist/ai/providers/openai/openai-responses.mapper.js.map +0 -1
- package/dist/ai/providers/openai/openai-stream.mapper.d.ts +0 -28
- package/dist/ai/providers/openai/openai-stream.mapper.d.ts.map +0 -1
- package/dist/ai/providers/openai/openai-stream.mapper.js +0 -139
- package/dist/ai/providers/openai/openai-stream.mapper.js.map +0 -1
- package/dist/ai/providers/openai/testing/chat-completions-fixtures.d.ts +0 -24
- package/dist/ai/providers/openai/testing/chat-completions-fixtures.d.ts.map +0 -1
- package/dist/ai/providers/openai/testing/chat-completions-fixtures.js +0 -72
- package/dist/ai/providers/openai/testing/chat-completions-fixtures.js.map +0 -1
- package/dist/ai/providers/openai/testing/conformance-responders.d.ts +0 -7
- package/dist/ai/providers/openai/testing/conformance-responders.d.ts.map +0 -1
- package/dist/ai/providers/openai/testing/conformance-responders.js +0 -64
- package/dist/ai/providers/openai/testing/conformance-responders.js.map +0 -1
- package/dist/ai/providers/openai/testing/openai-fixtures.d.ts +0 -52
- package/dist/ai/providers/openai/testing/openai-fixtures.d.ts.map +0 -1
- package/dist/ai/providers/openai/testing/openai-fixtures.js +0 -208
- package/dist/ai/providers/openai/testing/openai-fixtures.js.map +0 -1
- package/dist/ai/providers/openai/testing/openai-mock-transport.d.ts +0 -242
- package/dist/ai/providers/openai/testing/openai-mock-transport.d.ts.map +0 -1
- package/dist/ai/providers/openai/testing/openai-mock-transport.js +0 -523
- package/dist/ai/providers/openai/testing/openai-mock-transport.js.map +0 -1
- package/dist/ai/providers/openai-compatible/openai-compatible-settings.d.ts +0 -13
- package/dist/ai/providers/openai-compatible/openai-compatible-settings.d.ts.map +0 -1
- package/dist/ai/providers/openai-compatible/openai-compatible-settings.js +0 -29
- package/dist/ai/providers/openai-compatible/openai-compatible-settings.js.map +0 -1
|
@@ -1,289 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// The typed `AiHostedTool` union lives in `types/responses.types.ts`; this file
|
|
7
|
-
// is everything that is DONE with one, provider-neutrally:
|
|
8
|
-
//
|
|
9
|
-
// - `aiHostedToolSchema` — the one runtime shape check, shared by the HTTP
|
|
10
|
-
// DTO (`POST /api/ai/responses`), the facade (in-process callers are
|
|
11
|
-
// typed, not validated) and the stored background-run request
|
|
12
|
-
// (`aiStoredHostedToolSchema`, which has NO `headers` field at all);
|
|
13
|
-
// - `assertHostedToolsAllowed` — the admin policy gate: a tool type an
|
|
14
|
-
// administrator has not switched on is `AI_TOOL_DISABLED` (403), and so is
|
|
15
|
-
// an MCP server outside `ai.hostedTools.mcpAllowedHosts` when that list is
|
|
16
|
-
// non-empty;
|
|
17
|
-
// - `mcpHeaderValues` / `redactSecretValues` — MCP `headers` are secret
|
|
18
|
-
// material (typically `Authorization: Bearer …` for the remote server).
|
|
19
|
-
// The facade collects their values before the call and scrubs every
|
|
20
|
-
// string of the response with them, so a server that echoes its own
|
|
21
|
-
// credential back cannot put it on the wire either.
|
|
22
|
-
//
|
|
23
|
-
// Everything here is DEFAULT-CLOSED: every tool type is off until an
|
|
24
|
-
// administrator turns it on (egress and cost risk — a web search or an MCP
|
|
25
|
-
// call reaches the internet on the deployment's or the user's bill).
|
|
26
|
-
// =============================================================================
|
|
2
|
+
// Moved to `@marinoscar/platform-ai-providers` (#991) so the AI provider
|
|
3
|
+
// adapters and their core types run without Nest. This path re-exports the
|
|
4
|
+
// names it always exported, unchanged, so platform imports keep working.
|
|
5
|
+
// The side-effect import runs the `AiError` integration (ai-error.ts) first.
|
|
27
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
exports.
|
|
32
|
-
exports.
|
|
33
|
-
exports.
|
|
34
|
-
exports.
|
|
35
|
-
exports.
|
|
36
|
-
exports.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
exports.AI_MCP_MAX_HEADERS = 16;
|
|
45
|
-
/**
|
|
46
|
-
* A label the provider accepts for an MCP server.
|
|
47
|
-
*
|
|
48
|
-
* @stability experimental
|
|
49
|
-
*/
|
|
50
|
-
exports.AI_MCP_SERVER_LABEL = /^[a-zA-Z0-9_-]{1,64}$/;
|
|
51
|
-
/** An HTTP header field name (RFC 9110 `token`). */
|
|
52
|
-
const HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]{1,128}$/;
|
|
53
|
-
/** `https://` only, and never with credentials in the URL — it is stored with a background run. */
|
|
54
|
-
const mcpServerUrl = zod_1.z
|
|
55
|
-
.url({ protocol: /^https$/, error: 'serverUrl must be an https:// URL' })
|
|
56
|
-
.max(2048)
|
|
57
|
-
.refine((value) => {
|
|
58
|
-
const url = new URL(value);
|
|
59
|
-
return url.username === '' && url.password === '';
|
|
60
|
-
}, 'serverUrl must not carry credentials; send them in headers');
|
|
61
|
-
const webSearchToolSchema = zod_1.z
|
|
62
|
-
.object({
|
|
63
|
-
type: zod_1.z.literal('web_search'),
|
|
64
|
-
searchContextSize: zod_1.z.enum(['low', 'medium', 'high']).optional(),
|
|
65
|
-
userLocation: zod_1.z
|
|
66
|
-
.object({
|
|
67
|
-
country: zod_1.z.string().regex(/^[A-Za-z]{2}$/, 'An ISO-3166 alpha-2 country code').optional(),
|
|
68
|
-
city: zod_1.z.string().min(1).max(100).optional(),
|
|
69
|
-
})
|
|
70
|
-
.strict()
|
|
71
|
-
.optional(),
|
|
72
|
-
})
|
|
73
|
-
.strict();
|
|
74
|
-
const fileSearchToolSchema = zod_1.z
|
|
75
|
-
.object({
|
|
76
|
-
type: zod_1.z.literal('file_search'),
|
|
77
|
-
vectorStoreIds: zod_1.z.array(zod_1.z.string().min(1).max(128)).min(1).max(16),
|
|
78
|
-
maxResults: zod_1.z.number().int().min(1).max(50).optional(),
|
|
79
|
-
})
|
|
80
|
-
.strict();
|
|
81
|
-
const codeInterpreterToolSchema = zod_1.z
|
|
82
|
-
.object({
|
|
83
|
-
type: zod_1.z.literal('code_interpreter'),
|
|
84
|
-
container: zod_1.z.object({ type: zod_1.z.literal('auto') }).strict().optional(),
|
|
85
|
-
})
|
|
86
|
-
.strict();
|
|
87
|
-
const imageGenerationToolSchema = zod_1.z
|
|
88
|
-
.object({
|
|
89
|
-
type: zod_1.z.literal('image_generation'),
|
|
90
|
-
size: zod_1.z.string().min(1).max(32).optional(),
|
|
91
|
-
quality: zod_1.z.string().min(1).max(16).optional(),
|
|
92
|
-
})
|
|
93
|
-
.strict();
|
|
94
|
-
const mcpToolFields = {
|
|
95
|
-
type: zod_1.z.literal('mcp'),
|
|
96
|
-
serverLabel: zod_1.z.string().regex(exports.AI_MCP_SERVER_LABEL, 'Use 1-64 of [a-zA-Z0-9_-]'),
|
|
97
|
-
serverUrl: mcpServerUrl,
|
|
98
|
-
allowedTools: zod_1.z.array(zod_1.z.string().min(1).max(128)).max(128).optional(),
|
|
99
|
-
requireApproval: zod_1.z.enum(['never', 'always']).optional(),
|
|
100
|
-
};
|
|
101
|
-
const mcpToolSchema = zod_1.z
|
|
102
|
-
.object({
|
|
103
|
-
...mcpToolFields,
|
|
104
|
-
headers: zod_1.z
|
|
105
|
-
.record(zod_1.z.string().regex(HEADER_NAME, 'Not a valid header name'), zod_1.z.string().max(8192))
|
|
106
|
-
.refine((headers) => Object.keys(headers).length <= exports.AI_MCP_MAX_HEADERS, {
|
|
107
|
-
message: `At most ${exports.AI_MCP_MAX_HEADERS} headers`,
|
|
108
|
-
})
|
|
109
|
-
.optional(),
|
|
110
|
-
})
|
|
111
|
-
.strict();
|
|
112
|
-
/**
|
|
113
|
-
* One hosted tool, as a request may carry it.
|
|
114
|
-
*
|
|
115
|
-
* @internal
|
|
116
|
-
*/
|
|
117
|
-
exports.aiHostedToolSchema = zod_1.z.discriminatedUnion('type', [
|
|
118
|
-
webSearchToolSchema,
|
|
119
|
-
fileSearchToolSchema,
|
|
120
|
-
codeInterpreterToolSchema,
|
|
121
|
-
imageGenerationToolSchema,
|
|
122
|
-
mcpToolSchema,
|
|
123
|
-
]);
|
|
124
|
-
/**
|
|
125
|
-
* One hosted tool as STORED with a background run (`ai_runs.request`). The
|
|
126
|
-
* MCP variant has no `headers` member, so the column cannot hold one: a run
|
|
127
|
-
* whose MCP tool needs headers is refused by `startRun` instead.
|
|
128
|
-
*
|
|
129
|
-
* @internal
|
|
130
|
-
*/
|
|
131
|
-
exports.aiStoredHostedToolSchema = zod_1.z.discriminatedUnion('type', [
|
|
132
|
-
webSearchToolSchema,
|
|
133
|
-
fileSearchToolSchema,
|
|
134
|
-
codeInterpreterToolSchema,
|
|
135
|
-
imageGenerationToolSchema,
|
|
136
|
-
zod_1.z.object(mcpToolFields).strict(),
|
|
137
|
-
]);
|
|
138
|
-
/**
|
|
139
|
-
* The hosted tools among a request's tools.
|
|
140
|
-
*
|
|
141
|
-
* @stability experimental
|
|
142
|
-
*/
|
|
143
|
-
function hostedToolsOf(tools) {
|
|
144
|
-
return (tools ?? []).filter((tool) => tool.type !== 'function');
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Validates every hosted tool's shape. In-process callers are only
|
|
148
|
-
* type-checked, so the facade runs this too. The error names the tool type
|
|
149
|
-
* and the offending path — never a value (a header value is a secret).
|
|
150
|
-
*
|
|
151
|
-
* @throws AiError('AI_INVALID_REQUEST')
|
|
152
|
-
*
|
|
153
|
-
* @stability experimental
|
|
154
|
-
*/
|
|
155
|
-
function assertHostedToolShapes(tools) {
|
|
156
|
-
for (const tool of hostedToolsOf(tools)) {
|
|
157
|
-
const parsed = exports.aiHostedToolSchema.safeParse(tool);
|
|
158
|
-
if (!parsed.success) {
|
|
159
|
-
const issue = parsed.error.issues[0];
|
|
160
|
-
throw new ai_error_1.AiError('AI_INVALID_REQUEST', `The "${tool.type}" hosted tool is invalid.`, {
|
|
161
|
-
details: { tool: tool.type, path: issue?.path.map(String).join('.') ?? '' },
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Lower-cased hostname of an MCP `serverUrl`, or `null` when it does not parse.
|
|
168
|
-
*
|
|
169
|
-
* @stability experimental
|
|
170
|
-
*/
|
|
171
|
-
function mcpHost(serverUrl) {
|
|
172
|
-
try {
|
|
173
|
-
return new URL(serverUrl).hostname.toLowerCase();
|
|
174
|
-
}
|
|
175
|
-
catch {
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Whether `host` passes `allowed`. An empty list allows any host (the
|
|
181
|
-
* `https://` rule still applies); `example.com` matches exactly that host;
|
|
182
|
-
* `*.example.com` matches any subdomain of it, not the apex.
|
|
183
|
-
*
|
|
184
|
-
* @stability experimental
|
|
185
|
-
*/
|
|
186
|
-
function isMcpHostAllowed(host, allowed) {
|
|
187
|
-
if (allowed.length === 0)
|
|
188
|
-
return true;
|
|
189
|
-
const target = host.toLowerCase();
|
|
190
|
-
return allowed.some((entry) => {
|
|
191
|
-
const pattern = entry.trim().toLowerCase();
|
|
192
|
-
if (pattern.startsWith('*.')) {
|
|
193
|
-
return target.endsWith(pattern.slice(1)) && target.length > pattern.length - 1;
|
|
194
|
-
}
|
|
195
|
-
return target === pattern;
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* The admin policy gate: every hosted tool's type must be switched on, and an
|
|
200
|
-
* MCP server's host must pass the allowlist.
|
|
201
|
-
*
|
|
202
|
-
* @throws AiError('AI_TOOL_DISABLED') (403)
|
|
203
|
-
*
|
|
204
|
-
* @stability experimental
|
|
205
|
-
*/
|
|
206
|
-
function assertHostedToolsAllowed(tools, policy) {
|
|
207
|
-
for (const tool of hostedToolsOf(tools)) {
|
|
208
|
-
if (!policy[tool.type]) {
|
|
209
|
-
throw new ai_error_1.AiError('AI_TOOL_DISABLED', `The "${tool.type}" hosted tool is not enabled in this deployment.`, {
|
|
210
|
-
details: { tool: tool.type },
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
if (tool.type === 'mcp') {
|
|
214
|
-
const host = mcpHost(tool.serverUrl);
|
|
215
|
-
if (!host || !isMcpHostAllowed(host, policy.mcpAllowedHosts)) {
|
|
216
|
-
throw new ai_error_1.AiError('AI_TOOL_DISABLED', 'This MCP server host is not allowed in this deployment.', {
|
|
217
|
-
details: { tool: 'mcp', host: host ?? '' },
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Whether any MCP tool in `tools` carries headers.
|
|
225
|
-
*
|
|
226
|
-
* @stability experimental
|
|
227
|
-
*/
|
|
228
|
-
function hasMcpHeaders(tools) {
|
|
229
|
-
return hostedToolsOf(tools).some((tool) => tool.type === 'mcp' && Object.keys(tool.headers ?? {}).length > 0);
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Every MCP header VALUE in `tools` worth scrubbing for (at least 4
|
|
233
|
-
* characters — shorter strings would redact ordinary text and are not
|
|
234
|
-
* credentials anyone could use).
|
|
235
|
-
*
|
|
236
|
-
* @stability experimental
|
|
237
|
-
*/
|
|
238
|
-
function mcpHeaderValues(tools) {
|
|
239
|
-
const values = new Set();
|
|
240
|
-
for (const tool of hostedToolsOf(tools)) {
|
|
241
|
-
if (tool.type !== 'mcp')
|
|
242
|
-
continue;
|
|
243
|
-
for (const value of Object.values(tool.headers ?? {})) {
|
|
244
|
-
const trimmed = value.trim();
|
|
245
|
-
if (trimmed.length >= 4)
|
|
246
|
-
values.add(trimmed);
|
|
247
|
-
// `Bearer <token>`: the token alone is the secret, and may be echoed without its scheme.
|
|
248
|
-
const [, token] = /^\S+\s+(\S{4,})$/.exec(trimmed) ?? [];
|
|
249
|
-
if (token)
|
|
250
|
-
values.add(token);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
return [...values];
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* The placeholder a scrubbed secret is replaced with.
|
|
257
|
-
*
|
|
258
|
-
* @stability experimental
|
|
259
|
-
*/
|
|
260
|
-
exports.AI_REDACTED = '[REDACTED]';
|
|
261
|
-
/**
|
|
262
|
-
* `value` with every occurrence of every string in `secrets` replaced by
|
|
263
|
-
* `[REDACTED]`, in every string reachable through plain objects and arrays.
|
|
264
|
-
* Returns `value` itself when `secrets` is empty; otherwise a copy (binary
|
|
265
|
-
* payloads are passed through untouched).
|
|
266
|
-
*
|
|
267
|
-
* @stability experimental
|
|
268
|
-
*/
|
|
269
|
-
function redactSecretValues(value, secrets) {
|
|
270
|
-
if (secrets.length === 0)
|
|
271
|
-
return value;
|
|
272
|
-
const ordered = [...secrets].sort((a, b) => b.length - a.length);
|
|
273
|
-
const walk = (node) => {
|
|
274
|
-
if (typeof node === 'string') {
|
|
275
|
-
let out = node;
|
|
276
|
-
for (const secret of ordered)
|
|
277
|
-
out = out.split(secret).join(exports.AI_REDACTED);
|
|
278
|
-
return out;
|
|
279
|
-
}
|
|
280
|
-
if (Array.isArray(node))
|
|
281
|
-
return node.map(walk);
|
|
282
|
-
if (node && typeof node === 'object' && !(node instanceof Uint8Array)) {
|
|
283
|
-
return Object.fromEntries(Object.entries(node).map(([key, child]) => [key, walk(child)]));
|
|
284
|
-
}
|
|
285
|
-
return node;
|
|
286
|
-
};
|
|
287
|
-
return walk(value);
|
|
288
|
-
}
|
|
7
|
+
exports.redactSecretValues = exports.mcpHost = exports.mcpHeaderValues = exports.isMcpHostAllowed = exports.hostedToolsOf = exports.hasMcpHeaders = exports.assertHostedToolShapes = exports.assertHostedToolsAllowed = exports.aiStoredHostedToolSchema = exports.aiHostedToolSchema = exports.AI_REDACTED = exports.AI_MCP_SERVER_LABEL = exports.AI_MCP_MAX_HEADERS = void 0;
|
|
8
|
+
require("./ai-error");
|
|
9
|
+
var platform_ai_providers_1 = require("@marinoscar/platform-ai-providers");
|
|
10
|
+
Object.defineProperty(exports, "AI_MCP_MAX_HEADERS", { enumerable: true, get: function () { return platform_ai_providers_1.AI_MCP_MAX_HEADERS; } });
|
|
11
|
+
Object.defineProperty(exports, "AI_MCP_SERVER_LABEL", { enumerable: true, get: function () { return platform_ai_providers_1.AI_MCP_SERVER_LABEL; } });
|
|
12
|
+
Object.defineProperty(exports, "AI_REDACTED", { enumerable: true, get: function () { return platform_ai_providers_1.AI_REDACTED; } });
|
|
13
|
+
Object.defineProperty(exports, "aiHostedToolSchema", { enumerable: true, get: function () { return platform_ai_providers_1.aiHostedToolSchema; } });
|
|
14
|
+
Object.defineProperty(exports, "aiStoredHostedToolSchema", { enumerable: true, get: function () { return platform_ai_providers_1.aiStoredHostedToolSchema; } });
|
|
15
|
+
Object.defineProperty(exports, "assertHostedToolsAllowed", { enumerable: true, get: function () { return platform_ai_providers_1.assertHostedToolsAllowed; } });
|
|
16
|
+
Object.defineProperty(exports, "assertHostedToolShapes", { enumerable: true, get: function () { return platform_ai_providers_1.assertHostedToolShapes; } });
|
|
17
|
+
Object.defineProperty(exports, "hasMcpHeaders", { enumerable: true, get: function () { return platform_ai_providers_1.hasMcpHeaders; } });
|
|
18
|
+
Object.defineProperty(exports, "hostedToolsOf", { enumerable: true, get: function () { return platform_ai_providers_1.hostedToolsOf; } });
|
|
19
|
+
Object.defineProperty(exports, "isMcpHostAllowed", { enumerable: true, get: function () { return platform_ai_providers_1.isMcpHostAllowed; } });
|
|
20
|
+
Object.defineProperty(exports, "mcpHeaderValues", { enumerable: true, get: function () { return platform_ai_providers_1.mcpHeaderValues; } });
|
|
21
|
+
Object.defineProperty(exports, "mcpHost", { enumerable: true, get: function () { return platform_ai_providers_1.mcpHost; } });
|
|
22
|
+
Object.defineProperty(exports, "redactSecretValues", { enumerable: true, get: function () { return platform_ai_providers_1.redactSecretValues; } });
|
|
289
23
|
//# sourceMappingURL=hosted-tools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-tools.js","sourceRoot":"","sources":["../../../src/ai/core/hosted-tools.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"hosted-tools.js","sourceRoot":"","sources":["../../../src/ai/core/hosted-tools.ts"],"names":[],"mappings":";AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,yEAAyE;AACzE,6EAA6E;;;AAE7E,sBAAoB;AAEpB,2EAc2C;AAbzC,2HAAA,kBAAkB,OAAA;AAClB,4HAAA,mBAAmB,OAAA;AACnB,oHAAA,WAAW,OAAA;AACX,2HAAA,kBAAkB,OAAA;AAClB,iIAAA,wBAAwB,OAAA;AACxB,iIAAA,wBAAwB,OAAA;AACxB,+HAAA,sBAAsB,OAAA;AACtB,sHAAA,aAAa,OAAA;AACb,sHAAA,aAAa,OAAA;AACb,yHAAA,gBAAgB,OAAA;AAChB,wHAAA,eAAe,OAAA;AACf,gHAAA,OAAO,OAAA;AACP,2HAAA,kBAAkB,OAAA"}
|
|
@@ -1,261 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type { AiAudioPort, AiEmbeddingsPort, AiImagesPort, AiRealtimePort } from './types/media.types';
|
|
5
|
-
import type { AiResponse, AiResponseRequest, AiStreamEvent } from './types/responses.types';
|
|
6
|
-
/**
|
|
7
|
-
* The `apiKey` a call carries when its provider needs none (#448): an
|
|
8
|
-
* OpenAI-compatible server the administrator marked `requiresKey: false`.
|
|
9
|
-
* The key resolver returns it with `keySource: 'none'`, and an adapter that
|
|
10
|
-
* sees it sends NO credential at all — it is a marker, never put on the wire,
|
|
11
|
-
* in a log line or in a row.
|
|
12
|
-
*
|
|
13
|
-
* @stability experimental
|
|
14
|
-
*/
|
|
15
|
-
export declare const AI_KEYLESS_API_KEY = "not-needed";
|
|
16
|
-
/**
|
|
17
|
-
* Per-call context. The key is resolved per call by the runtime (org key or
|
|
18
|
-
* the user's own key, per policy) and handed to the adapter — adapters hold
|
|
19
|
-
* no credentials of their own.
|
|
20
|
-
*
|
|
21
|
-
* ⚠ `apiKey` is secret material: it must never appear in a log line, an
|
|
22
|
-
* `AiError`'s details, or a persisted row.
|
|
23
|
-
*
|
|
24
|
-
* @stability experimental
|
|
25
|
-
*/
|
|
26
|
-
export interface AiCallContext {
|
|
27
|
-
/** The key this call is made under (`AI_KEYLESS_API_KEY` for a keyless server). ⚠ Secret. */
|
|
28
|
-
apiKey: string;
|
|
29
|
-
/** The administrator's endpoint override, when the provider slot carries one. */
|
|
30
|
-
baseUrl?: string;
|
|
31
|
-
/**
|
|
32
|
-
* The provider's other NON-SECRET settings from its `ai.providers.<id>`
|
|
33
|
-
* slot (#448) — Azure's `apiVersion`/`apiStyle`/`deployments`, an
|
|
34
|
-
* OpenAI-compatible server's `apiStyle`/`requiresKey` — absent when the
|
|
35
|
-
* slot carries none. Each adapter reads it with its own schema; the
|
|
36
|
-
* runtime passes it through without interpreting it.
|
|
37
|
-
*/
|
|
38
|
-
providerSettings?: Readonly<Record<string, unknown>>;
|
|
39
|
-
/** Aborts the provider call. */
|
|
40
|
-
signal?: AbortSignal;
|
|
41
|
-
/** The request id, for logs and the provider's metadata. */
|
|
42
|
-
requestId: string;
|
|
43
|
-
/**
|
|
44
|
-
* The request's storage-object inputs (#441), resolved and authorised by the
|
|
45
|
-
* runtime, keyed by `storageObjectId` — present only when the request
|
|
46
|
-
* carries any. ⚠ May hold presigned URLs: the same never-log rule as
|
|
47
|
-
* `apiKey` applies (see `types/file-inputs.types.ts`).
|
|
48
|
-
*/
|
|
49
|
-
storageInputs?: AiResolvedStorageInputs;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* The context a custom operation handler (`AiProviderAdapter.operations`)
|
|
53
|
-
* receives: the call's {@link AiCallContext} plus the model and operation the
|
|
54
|
-
* gate pipeline settled. ⚠ `apiKey` is secret material, as everywhere.
|
|
55
|
-
*
|
|
56
|
-
* @stability experimental
|
|
57
|
-
*/
|
|
58
|
-
export interface AiOperationContext extends AiCallContext {
|
|
59
|
-
/** The provider model id the call targets (already gated: enabled, reachable, declares the capability). */
|
|
60
|
-
readonly model: string;
|
|
61
|
-
/** The operation id being run (`audio.diarize`). */
|
|
62
|
-
readonly operation: string;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* A custom operation an adapter implements (PP-14.17, #935): one entry of
|
|
66
|
-
* `AiProviderAdapter.operations`. The input arrives already validated by the
|
|
67
|
-
* operation's `inputSchema` (`registerAiOperation`) and the returned value is
|
|
68
|
-
* validated by its `outputSchema` before it leaves the runtime, so a handler
|
|
69
|
-
* does neither. It must not log, return or throw the key or the input.
|
|
70
|
-
*
|
|
71
|
-
* @param input - the validated input.
|
|
72
|
-
* @param ctx - the call's key, endpoint, settings, signal, model and operation.
|
|
73
|
-
* @returns the output, in the shape the operation's `outputSchema` declares.
|
|
74
|
-
*
|
|
75
|
-
* @stability experimental
|
|
76
|
-
*/
|
|
77
|
-
export type AiOperationHandler = (input: unknown, ctx: AiOperationContext) => Promise<unknown>;
|
|
78
|
-
/**
|
|
79
|
-
* What a provider's model listing says about one model, beyond its id
|
|
80
|
-
* (#447). Every field is optional and PROVIDER-REPORTED: an adapter fills
|
|
81
|
-
* what its listing carries (Gemini reports token limits, supported methods
|
|
82
|
-
* and a thinking flag; OpenAI and Anthropic list ids only) and its own
|
|
83
|
-
* `classifyModel` is the only reader. It is never stored as-is — the
|
|
84
|
-
* classifier folds it into `AiModelCapabilities`, which is what the catalog
|
|
85
|
-
* keeps.
|
|
86
|
-
*
|
|
87
|
-
* @stability experimental
|
|
88
|
-
*/
|
|
89
|
-
export interface AiDiscoveredModelMetadata {
|
|
90
|
-
/** The provider's display name for the model. */
|
|
91
|
-
displayName?: string;
|
|
92
|
-
/** The most input tokens the provider says the model accepts. */
|
|
93
|
-
inputTokenLimit?: number;
|
|
94
|
-
/** The most output tokens the provider says the model produces. */
|
|
95
|
-
outputTokenLimit?: number;
|
|
96
|
-
/** Provider-named operations the model supports (Gemini: `generateContent`, `embedContent`, ...). */
|
|
97
|
-
supportedActions?: string[];
|
|
98
|
-
/** Whether the provider says the model thinks (extended reasoning). */
|
|
99
|
-
thinking?: boolean;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* One model of a provider's listing (`listModels`).
|
|
103
|
-
*
|
|
104
|
-
* @stability experimental
|
|
105
|
-
*/
|
|
106
|
-
export interface AiDiscoveredModel {
|
|
107
|
-
/** The provider's model id. */
|
|
108
|
-
id: string;
|
|
109
|
-
/** The owner the provider reports. */
|
|
110
|
-
ownedBy?: string;
|
|
111
|
-
/** When the provider says the model was published. */
|
|
112
|
-
createdAt?: Date;
|
|
113
|
-
/** Optional listing metadata the adapter's `classifyModel` may use (#447). */
|
|
114
|
-
metadata?: AiDiscoveredModelMetadata;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* The outcome of `verifyKey`. A rejected key is an ordinary answer
|
|
118
|
-
* (`ok: false, code: 'AI_KEY_INVALID'`), not an exception — the admin UI asks
|
|
119
|
-
* this question precisely when it expects "no" to be possible.
|
|
120
|
-
*
|
|
121
|
-
* @stability experimental
|
|
122
|
-
*/
|
|
123
|
-
export interface AiKeyVerification {
|
|
124
|
-
/** Whether the provider accepted the key. */
|
|
125
|
-
ok: boolean;
|
|
126
|
-
/** Why not (`AI_KEY_INVALID`, `AI_PROVIDER_UNAVAILABLE`, ...). */
|
|
127
|
-
code?: AiErrorCode;
|
|
128
|
-
/** A message safe to show (never the key). */
|
|
129
|
-
detail?: string;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* The responses port a provider adapter implements (`responses` and the
|
|
133
|
-
* capabilities riding on it).
|
|
134
|
-
*
|
|
135
|
-
* @stability experimental
|
|
136
|
-
*/
|
|
137
|
-
export interface AiResponsesPort {
|
|
138
|
-
/**
|
|
139
|
-
* One complete response.
|
|
140
|
-
*
|
|
141
|
-
* @param req - the request.
|
|
142
|
-
* @param ctx - the call's key and signal.
|
|
143
|
-
*/
|
|
144
|
-
create(req: AiResponseRequest, ctx: AiCallContext): Promise<AiResponse>;
|
|
145
|
-
/**
|
|
146
|
-
* One streamed response (see `AiStreamEvent` for the well-formedness rules).
|
|
147
|
-
*
|
|
148
|
-
* @param req - the request.
|
|
149
|
-
* @param ctx - the call's key and signal.
|
|
150
|
-
*/
|
|
151
|
-
stream(req: AiResponseRequest, ctx: AiCallContext): AsyncIterable<AiStreamEvent>;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* A provider adapter: the one place a provider SDK is called
|
|
155
|
-
* (`ai/providers/<provider>/`). It holds no key; every call receives one in
|
|
156
|
-
* its {@link AiCallContext}. Its capability ports' presence is the
|
|
157
|
-
* declaration of what it can do. Adding one: docs/specs/ai-platform.md §4.
|
|
158
|
-
*
|
|
159
|
-
* @stability experimental
|
|
160
|
-
*/
|
|
161
|
-
export interface AiProviderAdapter {
|
|
162
|
-
/** Stable identifier (`'openai'`). PERMANENT — stored in settings, catalog rows and usage rows. */
|
|
163
|
-
readonly id: string;
|
|
164
|
-
/** The name the admin UI shows. */
|
|
165
|
-
readonly displayName: string;
|
|
166
|
-
/**
|
|
167
|
-
* The provider's model listing, under the deployment's (or a probe's) key.
|
|
168
|
-
*
|
|
169
|
-
* @param ctx - the call's key and signal.
|
|
170
|
-
*/
|
|
171
|
-
listModels(ctx: AiCallContext): Promise<AiDiscoveredModel[]>;
|
|
172
|
-
/**
|
|
173
|
-
* Whether the key in `ctx` works. A rejected key is an answer, not a throw.
|
|
174
|
-
*
|
|
175
|
-
* @param ctx - the call's key and signal.
|
|
176
|
-
*/
|
|
177
|
-
verifyKey(ctx: AiCallContext): Promise<AiKeyVerification>;
|
|
178
|
-
/**
|
|
179
|
-
* `null` means "unclassified": the catalog stores it and an admin decides.
|
|
180
|
-
*
|
|
181
|
-
* `metadata` (#447) is what this adapter's own `listModels` reported for
|
|
182
|
-
* the id, passed back by the catalog sync so a classifier can ENRICH its
|
|
183
|
-
* rule table from provider facts (token limits, supported methods). It is
|
|
184
|
-
* absent everywhere else — a request-time lookup, a test, an adapter whose
|
|
185
|
-
* listing carries ids only — so a classifier must answer from the id alone
|
|
186
|
-
* when it is missing, and an adapter that ignores it stays correct.
|
|
187
|
-
*/
|
|
188
|
-
classifyModel(modelId: string, metadata?: AiDiscoveredModelMetadata): AiModelCapabilities | null;
|
|
189
|
-
/**
|
|
190
|
-
* How this adapter wants storage-object image/file inputs delivered (#441).
|
|
191
|
-
* Presence is the declaration that it accepts them at all; absent, a
|
|
192
|
-
* request carrying one is refused with `AI_CAPABILITY_UNSUPPORTED`.
|
|
193
|
-
*/
|
|
194
|
-
readonly fileInputStrategy?: AiFileInputStrategies;
|
|
195
|
-
/**
|
|
196
|
-
* Whether this provider stores responses, so a request may chain onto one
|
|
197
|
-
* with `AiResponseRequest.previousResponseId` (#446). ABSENT MEANS `true` —
|
|
198
|
-
* the Responses-shaped default, and what every adapter written before this
|
|
199
|
-
* flag (OpenAI, the fake provider) already does.
|
|
200
|
-
*
|
|
201
|
-
* A stateless provider (Anthropic's Messages API) declares `false`, and the
|
|
202
|
-
* runtime then:
|
|
203
|
-
* - refuses a caller-supplied `previousResponseId` with
|
|
204
|
-
* `AI_CAPABILITY_UNSUPPORTED` before any key is resolved (the caller
|
|
205
|
-
* must send the conversation as `input` instead);
|
|
206
|
-
* - runs the tool loop by RESENDING THE FULL HISTORY each round — the
|
|
207
|
-
* original input, the model's own `message`/`reasoning`/`function_call`
|
|
208
|
-
* items, and the tool outputs — instead of chaining.
|
|
209
|
-
*
|
|
210
|
-
* Unlike a capability port this is a behaviour flag, not a capability: the
|
|
211
|
-
* conversation still works, it just travels differently.
|
|
212
|
-
*/
|
|
213
|
-
readonly supportsPreviousResponseId?: boolean;
|
|
214
|
-
/**
|
|
215
|
-
* Whether this provider executes the neutral hosted tools (#442: web
|
|
216
|
-
* search, file search, code interpreter, image generation, MCP) inside a
|
|
217
|
-
* response. ABSENT MEANS `true` — the pre-flag derivation, and what OpenAI
|
|
218
|
-
* and the fake provider rely on.
|
|
219
|
-
*
|
|
220
|
-
* Why a flag and not a port: hosted tools run INSIDE the `responses` port,
|
|
221
|
-
* so there is no separate port whose presence could declare them, and
|
|
222
|
-
* `hosted_tools` used to be derived from the `responses` port alone. A
|
|
223
|
-
* provider with a responses port but none of these tools (Anthropic, whose
|
|
224
|
-
* server tools are a different, unmapped set) declares `false`, so
|
|
225
|
-
* `AiProviderRegistry.supports(id, 'hosted_tools')` — and the admin view's
|
|
226
|
-
* `supportedCapabilities`, and the usable-models gate — stop claiming a
|
|
227
|
-
* capability the adapter's mapper would refuse.
|
|
228
|
-
*/
|
|
229
|
-
readonly supportsHostedTools?: boolean;
|
|
230
|
-
/**
|
|
231
|
-
* The endpoint this adapter calls when the provider's settings slot carries
|
|
232
|
-
* no `baseUrl` (#773): the SDK default it passes to its client factory.
|
|
233
|
-
* Absent for a provider that has no default (Azure OpenAI and
|
|
234
|
-
* OpenAI-compatible need an administrator's endpoint). Read by the egress
|
|
235
|
-
* inventory (`network.egress`) to name the host a provider reaches, without
|
|
236
|
-
* a hard-coded table outside `ai/providers/`. Never a secret.
|
|
237
|
-
*/
|
|
238
|
-
readonly defaultBaseUrl?: string;
|
|
239
|
-
/** Text, reasoning, tools, structured output, streaming, vision and file input. */
|
|
240
|
-
readonly responses?: AiResponsesPort;
|
|
241
|
-
/** Image generation (and editing, when `edit` is present). */
|
|
242
|
-
readonly images?: AiImagesPort;
|
|
243
|
-
/** Transcription and/or speech. */
|
|
244
|
-
readonly audio?: AiAudioPort;
|
|
245
|
-
/** Embeddings. */
|
|
246
|
-
readonly embeddings?: AiEmbeddingsPort;
|
|
247
|
-
/** Realtime voice sessions. */
|
|
248
|
-
readonly realtime?: AiRealtimePort;
|
|
249
|
-
/**
|
|
250
|
-
* Custom operations, by operation id (PP-14.17, #935): the way a provider
|
|
251
|
-
* serves a kind of call the platform has no built-in port for (diarization,
|
|
252
|
-
* moderation, rerank, OCR). Each key is an id registered with
|
|
253
|
-
* `registerAiOperation`; `AiService.forUser(...).run(id, input)` runs it
|
|
254
|
-
* through the same gate pipeline as a built-in port. Presence is the
|
|
255
|
-
* declaration, as with the ports: the registry derives that the provider
|
|
256
|
-
* supports the operation's capability from the entry, and a registered
|
|
257
|
-
* operation the adapter does not implement is refused for it.
|
|
258
|
-
*/
|
|
259
|
-
readonly operations?: Readonly<Record<string, AiOperationHandler>>;
|
|
260
|
-
}
|
|
1
|
+
import './ai-error';
|
|
2
|
+
export { AI_KEYLESS_API_KEY, } from '@marinoscar/platform-ai-providers';
|
|
3
|
+
export type { AiCallContext, AiDiscoveredModel, AiDiscoveredModelMetadata, AiKeyVerification, AiOperationContext, AiOperationHandler, AiProviderAdapter, AiResponsesPort, } from '@marinoscar/platform-ai-providers';
|
|
261
4
|
//# sourceMappingURL=provider-adapter.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-adapter.interface.d.ts","sourceRoot":"","sources":["../../../src/ai/core/provider-adapter.interface.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider-adapter.interface.d.ts","sourceRoot":"","sources":["../../../src/ai/core/provider-adapter.interface.ts"],"names":[],"mappings":"AAKA,OAAO,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,GACnB,MAAM,mCAAmC,CAAC;AAE3C,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,GAChB,MAAM,mCAAmC,CAAC"}
|
|
@@ -1,33 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// One class per provider implements this and self-registers with
|
|
7
|
-
// `AiProviderRegistry` from its own `onModuleInit()` — the same explicit
|
|
8
|
-
// registration `JobHandler` uses (see `jobs/job-handler.registry.ts` for why
|
|
9
|
-
// explicit registration beats decorator discovery).
|
|
10
|
-
//
|
|
11
|
-
// CAPABILITY PORTS: PRESENCE IS THE DECLARATION. An adapter that can generate
|
|
12
|
-
// images carries an `images` port; one that cannot leaves it `undefined`.
|
|
13
|
-
// There is no `supportsImages: boolean` to disagree with the code — the same
|
|
14
|
-
// idiom as `JobHandler.nodeResultSchema` + `persistNodeResult`.
|
|
15
|
-
// `AiProviderRegistry.supports()` is the derivation.
|
|
16
|
-
//
|
|
17
|
-
// NO SDK TYPE CROSSES THIS BOUNDARY. Every method takes and returns the
|
|
18
|
-
// neutral types in `./types`, and every failure is an `AiError` — an adapter
|
|
19
|
-
// that lets a raw SDK error escape fails the conformance kit.
|
|
20
|
-
// =============================================================================
|
|
2
|
+
// Moved to `@marinoscar/platform-ai-providers` (#991) so the AI provider
|
|
3
|
+
// adapters and their core types run without Nest. This path re-exports the
|
|
4
|
+
// names it always exported, unchanged, so platform imports keep working.
|
|
5
|
+
// The side-effect import runs the `AiError` integration (ai-error.ts) first.
|
|
21
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
7
|
exports.AI_KEYLESS_API_KEY = void 0;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* The key resolver returns it with `keySource: 'none'`, and an adapter that
|
|
27
|
-
* sees it sends NO credential at all — it is a marker, never put on the wire,
|
|
28
|
-
* in a log line or in a row.
|
|
29
|
-
*
|
|
30
|
-
* @stability experimental
|
|
31
|
-
*/
|
|
32
|
-
exports.AI_KEYLESS_API_KEY = 'not-needed';
|
|
8
|
+
require("./ai-error");
|
|
9
|
+
var platform_ai_providers_1 = require("@marinoscar/platform-ai-providers");
|
|
10
|
+
Object.defineProperty(exports, "AI_KEYLESS_API_KEY", { enumerable: true, get: function () { return platform_ai_providers_1.AI_KEYLESS_API_KEY; } });
|
|
33
11
|
//# sourceMappingURL=provider-adapter.interface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-adapter.interface.js","sourceRoot":"","sources":["../../../src/ai/core/provider-adapter.interface.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"provider-adapter.interface.js","sourceRoot":"","sources":["../../../src/ai/core/provider-adapter.interface.ts"],"names":[],"mappings":";AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,yEAAyE;AACzE,6EAA6E;;;AAE7E,sBAAoB;AAEpB,2EAE2C;AADzC,2HAAA,kBAAkB,OAAA"}
|