@marinoscar/platform-api 0.1.0-next.5 → 0.1.0-next.7
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 +19 -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,50 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* @stability experimental
|
|
6
|
-
*/
|
|
7
|
-
export type AiJsonSchema = Record<string, unknown>;
|
|
8
|
-
/**
|
|
9
|
-
* Converts a Zod schema to the JSON Schema a provider is sent.
|
|
10
|
-
*
|
|
11
|
-
* Uses zod's OUTPUT view — the shape the model must PRODUCE: every
|
|
12
|
-
* non-optional key is `required` and objects are closed
|
|
13
|
-
* (`additionalProperties: false`), which is what strict structured-output
|
|
14
|
-
* and strict function-calling modes require. The `$schema` marker is dropped
|
|
15
|
-
* because it describes the document, not the value, and some providers
|
|
16
|
-
* reject unknown top-level keywords.
|
|
17
|
-
*
|
|
18
|
-
* A schema JSON Schema cannot express (a `Date`, a `transform`, a function) is
|
|
19
|
-
* a programming error in the caller; it surfaces as
|
|
20
|
-
* `AiError('AI_INVALID_REQUEST')` so it follows the same error path as every
|
|
21
|
-
* other AI failure instead of escaping as a raw zod error.
|
|
22
|
-
*
|
|
23
|
-
* @stability experimental
|
|
24
|
-
*/
|
|
25
|
-
export declare function toJsonSchema(schema: z.ZodTypeAny): AiJsonSchema;
|
|
26
|
-
/**
|
|
27
|
-
* One validation problem, safe to return to a client (no model output echoed).
|
|
28
|
-
*
|
|
29
|
-
* @stability experimental
|
|
30
|
-
*/
|
|
31
|
-
export interface AiStructuredOutputIssue {
|
|
32
|
-
/** Where in the output the problem is. */
|
|
33
|
-
path: Array<string | number>;
|
|
34
|
-
/** Zod's issue code. */
|
|
35
|
-
code: string;
|
|
36
|
-
/** What is wrong, in words. */
|
|
37
|
-
message: string;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Parses a model's text output and validates it against `schema`.
|
|
41
|
-
*
|
|
42
|
-
* Throws `AiError('AI_STRUCTURED_OUTPUT_INVALID')` (502 — the PROVIDER
|
|
43
|
-
* returned something unusable, not the caller) with the issues in
|
|
44
|
-
* `details.issues`. The raw text is deliberately NOT included: it is model
|
|
45
|
-
* output derived from the user's prompt, and error bodies get logged.
|
|
46
|
-
*
|
|
47
|
-
* @stability experimental
|
|
48
|
-
*/
|
|
49
|
-
export declare function parseStructured<S extends z.ZodTypeAny>(schema: S, text: string): z.output<S>;
|
|
1
|
+
import './ai-error';
|
|
2
|
+
export { parseStructured, toJsonSchema, } from '@marinoscar/platform-ai-providers';
|
|
3
|
+
export type { AiJsonSchema, AiStructuredOutputIssue, } from '@marinoscar/platform-ai-providers';
|
|
50
4
|
//# sourceMappingURL=structured-output.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structured-output.d.ts","sourceRoot":"","sources":["../../../src/ai/core/structured-output.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"structured-output.d.ts","sourceRoot":"","sources":["../../../src/ai/core/structured-output.ts"],"names":[],"mappings":"AAKA,OAAO,YAAY,CAAC;AAEpB,OAAO,EACL,eAAe,EACf,YAAY,GACb,MAAM,mCAAmC,CAAC;AAE3C,YAAY,EACV,YAAY,EACZ,uBAAuB,GACxB,MAAM,mCAAmC,CAAC"}
|
|
@@ -1,83 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// A caller hands the AI layer a ZOD schema; a provider wants a JSON SCHEMA,
|
|
7
|
-
// and hands back TEXT. These two functions are the whole round trip, and the
|
|
8
|
-
// only place either conversion happens, so every adapter describes and
|
|
9
|
-
// validates schemas identically.
|
|
10
|
-
//
|
|
11
|
-
// The repository is on zod v4, which converts natively (`z.toJSONSchema`), so
|
|
12
|
-
// no extra dependency is needed.
|
|
13
|
-
// =============================================================================
|
|
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.
|
|
14
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.toJsonSchema =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* Converts a Zod schema to the JSON Schema a provider is sent.
|
|
21
|
-
*
|
|
22
|
-
* Uses zod's OUTPUT view — the shape the model must PRODUCE: every
|
|
23
|
-
* non-optional key is `required` and objects are closed
|
|
24
|
-
* (`additionalProperties: false`), which is what strict structured-output
|
|
25
|
-
* and strict function-calling modes require. The `$schema` marker is dropped
|
|
26
|
-
* because it describes the document, not the value, and some providers
|
|
27
|
-
* reject unknown top-level keywords.
|
|
28
|
-
*
|
|
29
|
-
* A schema JSON Schema cannot express (a `Date`, a `transform`, a function) is
|
|
30
|
-
* a programming error in the caller; it surfaces as
|
|
31
|
-
* `AiError('AI_INVALID_REQUEST')` so it follows the same error path as every
|
|
32
|
-
* other AI failure instead of escaping as a raw zod error.
|
|
33
|
-
*
|
|
34
|
-
* @stability experimental
|
|
35
|
-
*/
|
|
36
|
-
function toJsonSchema(schema) {
|
|
37
|
-
let json;
|
|
38
|
-
try {
|
|
39
|
-
json = zod_1.z.toJSONSchema(schema, { unrepresentable: 'throw' });
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
throw new ai_error_1.AiError('AI_INVALID_REQUEST', 'The schema cannot be represented as JSON Schema.', { cause: err, details: { detail: err instanceof Error ? err.message : String(err) } });
|
|
43
|
-
}
|
|
44
|
-
const { $schema: _ignored, ...rest } = json;
|
|
45
|
-
return rest;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Parses a model's text output and validates it against `schema`.
|
|
49
|
-
*
|
|
50
|
-
* Throws `AiError('AI_STRUCTURED_OUTPUT_INVALID')` (502 — the PROVIDER
|
|
51
|
-
* returned something unusable, not the caller) with the issues in
|
|
52
|
-
* `details.issues`. The raw text is deliberately NOT included: it is model
|
|
53
|
-
* output derived from the user's prompt, and error bodies get logged.
|
|
54
|
-
*
|
|
55
|
-
* @stability experimental
|
|
56
|
-
*/
|
|
57
|
-
function parseStructured(schema, text) {
|
|
58
|
-
let value;
|
|
59
|
-
try {
|
|
60
|
-
value = JSON.parse(text);
|
|
61
|
-
}
|
|
62
|
-
catch (err) {
|
|
63
|
-
const issues = [
|
|
64
|
-
{
|
|
65
|
-
path: [],
|
|
66
|
-
code: 'invalid_json',
|
|
67
|
-
message: err instanceof Error ? err.message : 'Output is not valid JSON',
|
|
68
|
-
},
|
|
69
|
-
];
|
|
70
|
-
throw new ai_error_1.AiError('AI_STRUCTURED_OUTPUT_INVALID', 'The model output is not valid JSON.', { cause: err, details: { issues } });
|
|
71
|
-
}
|
|
72
|
-
const result = schema.safeParse(value);
|
|
73
|
-
if (!result.success) {
|
|
74
|
-
const issues = result.error.issues.map((issue) => ({
|
|
75
|
-
path: issue.path.map((segment) => (typeof segment === 'symbol' ? String(segment) : segment)),
|
|
76
|
-
code: issue.code,
|
|
77
|
-
message: issue.message,
|
|
78
|
-
}));
|
|
79
|
-
throw new ai_error_1.AiError('AI_STRUCTURED_OUTPUT_INVALID', 'The model output does not match the requested schema.', { cause: result.error, details: { issues } });
|
|
80
|
-
}
|
|
81
|
-
return result.data;
|
|
82
|
-
}
|
|
7
|
+
exports.toJsonSchema = exports.parseStructured = void 0;
|
|
8
|
+
require("./ai-error");
|
|
9
|
+
var platform_ai_providers_1 = require("@marinoscar/platform-ai-providers");
|
|
10
|
+
Object.defineProperty(exports, "parseStructured", { enumerable: true, get: function () { return platform_ai_providers_1.parseStructured; } });
|
|
11
|
+
Object.defineProperty(exports, "toJsonSchema", { enumerable: true, get: function () { return platform_ai_providers_1.toJsonSchema; } });
|
|
83
12
|
//# sourceMappingURL=structured-output.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structured-output.js","sourceRoot":"","sources":["../../../src/ai/core/structured-output.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"structured-output.js","sourceRoot":"","sources":["../../../src/ai/core/structured-output.ts"],"names":[],"mappings":";AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,yEAAyE;AACzE,6EAA6E;;;AAE7E,sBAAoB;AAEpB,2EAG2C;AAFzC,wHAAA,eAAe,OAAA;AACf,qHAAA,YAAY,OAAA"}
|
package/dist/ai/core/tools.d.ts
CHANGED
|
@@ -1,94 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* What a tool's `execute` is called with besides its arguments.
|
|
5
|
-
*
|
|
6
|
-
* @stability experimental
|
|
7
|
-
*/
|
|
8
|
-
export interface AiToolExecutionContext {
|
|
9
|
-
/** The user on whose behalf the model is acting — scope every data access to it. */
|
|
10
|
-
userId: string;
|
|
11
|
-
/** Aborted when the request is. */
|
|
12
|
-
signal?: AbortSignal;
|
|
13
|
-
/** The request id, for logs. */
|
|
14
|
-
requestId?: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* What {@link defineTool} takes: a function tool and its implementation.
|
|
18
|
-
*
|
|
19
|
-
* @typeParam P - the parameters' Zod schema.
|
|
20
|
-
* @typeParam R - what the implementation returns.
|
|
21
|
-
*
|
|
22
|
-
* @stability experimental
|
|
23
|
-
*/
|
|
24
|
-
export interface AiToolDefinition<P extends z.ZodTypeAny, R> {
|
|
25
|
-
/** The name the model calls it by (`[a-zA-Z0-9_-]`, at most 64). */
|
|
26
|
-
name: string;
|
|
27
|
-
/** What it does, for the model. */
|
|
28
|
-
description: string;
|
|
29
|
-
/** The parameters' schema. */
|
|
30
|
-
parameters: P;
|
|
31
|
-
/** Ask the provider to enforce the schema exactly. Defaults to true. */
|
|
32
|
-
strict?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* The implementation.
|
|
35
|
-
*
|
|
36
|
-
* @param args - the validated arguments.
|
|
37
|
-
* @param ctx - the user and the signal.
|
|
38
|
-
*/
|
|
39
|
-
execute(args: z.output<P>, ctx: AiToolExecutionContext): Promise<R> | R;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* The outcome of parsing a model's raw arguments.
|
|
43
|
-
*
|
|
44
|
-
* @typeParam P - the parameters' Zod schema.
|
|
45
|
-
*
|
|
46
|
-
* @stability experimental
|
|
47
|
-
*/
|
|
48
|
-
export type AiToolArgumentsResult<P extends z.ZodTypeAny> = {
|
|
49
|
-
/** Parsed. */
|
|
50
|
-
success: true;
|
|
51
|
-
/** The validated arguments. */
|
|
52
|
-
data: z.output<P>;
|
|
53
|
-
} | {
|
|
54
|
-
/** Refused. */
|
|
55
|
-
success: false;
|
|
56
|
-
/** Why, suitable for a `function_call_output`. */
|
|
57
|
-
error: string;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* A defined function tool: the request half and the implementation half.
|
|
61
|
-
*
|
|
62
|
-
* @typeParam P - the parameters' Zod schema.
|
|
63
|
-
* @typeParam R - what the implementation returns.
|
|
64
|
-
*
|
|
65
|
-
* @stability experimental
|
|
66
|
-
*/
|
|
67
|
-
export interface AiDefinedTool<P extends z.ZodTypeAny = z.ZodTypeAny, R = unknown> {
|
|
68
|
-
/** Goes into `AiResponseRequest.tools`. */
|
|
69
|
-
tool: AiFunctionTool<P>;
|
|
70
|
-
/** Runs the implementation. Always async, whatever the definition returned. */
|
|
71
|
-
execute(args: z.output<P>, ctx: AiToolExecutionContext): Promise<R>;
|
|
72
|
-
/**
|
|
73
|
-
* Parses and validates a model's raw `arguments` string. Never throws: a
|
|
74
|
-
* failure is a message suitable for a `function_call_output`.
|
|
75
|
-
*/
|
|
76
|
-
parseArguments(raw: string): AiToolArgumentsResult<P>;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Defines a function tool.
|
|
80
|
-
*
|
|
81
|
-
* Throws (a plain `TypeError` — this is a programming error, found at
|
|
82
|
-
* definition time rather than on the first model call) when the name is not
|
|
83
|
-
* provider-safe or `parameters` does not describe a JSON object.
|
|
84
|
-
*
|
|
85
|
-
* @stability experimental
|
|
86
|
-
*/
|
|
87
|
-
export declare function defineTool<P extends z.ZodTypeAny, R>(def: AiToolDefinition<P, R>): AiDefinedTool<P, R>;
|
|
88
|
-
/**
|
|
89
|
-
* Narrows a request tool to a function tool (as opposed to a hosted one).
|
|
90
|
-
*
|
|
91
|
-
* @stability experimental
|
|
92
|
-
*/
|
|
93
|
-
export declare function isFunctionTool(tool: AiTool): tool is AiFunctionTool;
|
|
1
|
+
import './ai-error';
|
|
2
|
+
export { defineTool, isFunctionTool, } from '@marinoscar/platform-ai-providers';
|
|
3
|
+
export type { AiDefinedTool, AiToolArgumentsResult, AiToolDefinition, AiToolExecutionContext, } from '@marinoscar/platform-ai-providers';
|
|
94
4
|
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/ai/core/tools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/ai/core/tools.ts"],"names":[],"mappings":"AAKA,OAAO,YAAY,CAAC;AAEpB,OAAO,EACL,UAAU,EACV,cAAc,GACf,MAAM,mCAAmC,CAAC;AAE3C,YAAY,EACV,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,mCAAmC,CAAC"}
|
package/dist/ai/core/tools.js
CHANGED
|
@@ -1,76 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// `defineTool()` binds a function tool's description (what the provider is
|
|
7
|
-
// told) to its implementation (what runs when the model calls it) and to ONE
|
|
8
|
-
// Zod schema used for both the provider-facing JSON Schema and the validation
|
|
9
|
-
// of the model's arguments. The #432 agent loop consumes the result.
|
|
10
|
-
//
|
|
11
|
-
// Arguments from a model are untrusted input — they are validated before
|
|
12
|
-
// `execute` ever sees them, and a validation failure is returned as a string
|
|
13
|
-
// the loop can feed back to the model rather than thrown.
|
|
14
|
-
// =============================================================================
|
|
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.
|
|
15
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.defineTool =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Defines a function tool.
|
|
23
|
-
*
|
|
24
|
-
* Throws (a plain `TypeError` — this is a programming error, found at
|
|
25
|
-
* definition time rather than on the first model call) when the name is not
|
|
26
|
-
* provider-safe or `parameters` does not describe a JSON object.
|
|
27
|
-
*
|
|
28
|
-
* @stability experimental
|
|
29
|
-
*/
|
|
30
|
-
function defineTool(def) {
|
|
31
|
-
if (!TOOL_NAME.test(def.name)) {
|
|
32
|
-
throw new TypeError(`Invalid AI tool name "${def.name}": use 1-64 characters from [a-zA-Z0-9_-].`);
|
|
33
|
-
}
|
|
34
|
-
const jsonSchema = (0, structured_output_1.toJsonSchema)(def.parameters);
|
|
35
|
-
if (jsonSchema.type !== 'object') {
|
|
36
|
-
throw new TypeError(`AI tool "${def.name}" parameters must be an object schema.`);
|
|
37
|
-
}
|
|
38
|
-
const tool = {
|
|
39
|
-
type: 'function',
|
|
40
|
-
name: def.name,
|
|
41
|
-
description: def.description,
|
|
42
|
-
parameters: def.parameters,
|
|
43
|
-
strict: def.strict ?? true,
|
|
44
|
-
};
|
|
45
|
-
return {
|
|
46
|
-
tool,
|
|
47
|
-
execute: async (args, ctx) => def.execute(args, ctx),
|
|
48
|
-
parseArguments: (raw) => {
|
|
49
|
-
let value;
|
|
50
|
-
try {
|
|
51
|
-
// Some providers send an empty string for a no-argument call.
|
|
52
|
-
value = JSON.parse(raw.trim() === '' ? '{}' : raw);
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
return { success: false, error: `Arguments for "${def.name}" are not valid JSON.` };
|
|
56
|
-
}
|
|
57
|
-
const result = def.parameters.safeParse(value);
|
|
58
|
-
if (!result.success) {
|
|
59
|
-
const problems = result.error.issues
|
|
60
|
-
.map((issue) => `${issue.path.length ? issue.path.join('.') : '(root)'}: ${issue.message}`)
|
|
61
|
-
.join('; ');
|
|
62
|
-
return { success: false, error: `Invalid arguments for "${def.name}": ${problems}` };
|
|
63
|
-
}
|
|
64
|
-
return { success: true, data: result.data };
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Narrows a request tool to a function tool (as opposed to a hosted one).
|
|
70
|
-
*
|
|
71
|
-
* @stability experimental
|
|
72
|
-
*/
|
|
73
|
-
function isFunctionTool(tool) {
|
|
74
|
-
return tool.type === 'function';
|
|
75
|
-
}
|
|
7
|
+
exports.isFunctionTool = exports.defineTool = void 0;
|
|
8
|
+
require("./ai-error");
|
|
9
|
+
var platform_ai_providers_1 = require("@marinoscar/platform-ai-providers");
|
|
10
|
+
Object.defineProperty(exports, "defineTool", { enumerable: true, get: function () { return platform_ai_providers_1.defineTool; } });
|
|
11
|
+
Object.defineProperty(exports, "isFunctionTool", { enumerable: true, get: function () { return platform_ai_providers_1.isFunctionTool; } });
|
|
76
12
|
//# sourceMappingURL=tools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/ai/core/tools.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/ai/core/tools.ts"],"names":[],"mappings":";AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,yEAAyE;AACzE,6EAA6E;;;AAE7E,sBAAoB;AAEpB,2EAG2C;AAFzC,mHAAA,UAAU,OAAA;AACV,uHAAA,cAAc,OAAA"}
|
|
@@ -1,103 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* @stability experimental
|
|
6
|
-
*/
|
|
7
|
-
export declare const AI_STORAGE_INPUT_IMAGE_MAX_BYTES: number;
|
|
8
|
-
/**
|
|
9
|
-
* The largest non-image file a Responses request may reference by storage object (50 MiB).
|
|
10
|
-
*
|
|
11
|
-
* @stability experimental
|
|
12
|
-
*/
|
|
13
|
-
export declare const AI_STORAGE_INPUT_FILE_MAX_BYTES: number;
|
|
14
|
-
/**
|
|
15
|
-
* The most storage-object parts one request may carry.
|
|
16
|
-
*
|
|
17
|
-
* @stability experimental
|
|
18
|
-
*/
|
|
19
|
-
export declare const AI_STORAGE_INPUTS_MAX = 16;
|
|
20
|
-
/**
|
|
21
|
-
* How long a presigned input URL stays valid, in seconds (10 minutes).
|
|
22
|
-
*
|
|
23
|
-
* @stability experimental
|
|
24
|
-
*/
|
|
25
|
-
export declare const AI_STORAGE_INPUT_URL_TTL_SECONDS = 600;
|
|
26
|
-
/**
|
|
27
|
-
* Stored objects of these MIME types are IMAGES (they need `vision_input`
|
|
28
|
-
* and are capped at `AI_STORAGE_INPUT_IMAGE_MAX_BYTES`); every other type is
|
|
29
|
-
* a FILE (`file_input`, `AI_STORAGE_INPUT_FILE_MAX_BYTES`).
|
|
30
|
-
*
|
|
31
|
-
* @stability experimental
|
|
32
|
-
*/
|
|
33
|
-
export declare const AI_STORAGE_INPUT_IMAGE_MIME_TYPES: readonly ["image/png", "image/jpeg", "image/gif", "image/webp"];
|
|
34
|
-
/**
|
|
35
|
-
* What kind of input a stored object is, decided by its MIME type.
|
|
36
|
-
*
|
|
37
|
-
* @stability experimental
|
|
38
|
-
*/
|
|
39
|
-
export type AiStorageInputModality = 'image' | 'file';
|
|
40
|
-
/**
|
|
41
|
-
* How an adapter wants a resolved storage input delivered (see the file header).
|
|
42
|
-
*
|
|
43
|
-
* @stability experimental
|
|
44
|
-
*/
|
|
45
|
-
export type AiFileInputStrategy = 'presigned_url' | 'upload' | 'inline';
|
|
46
|
-
/**
|
|
47
|
-
* An adapter's delivery strategy per modality. Presence on the adapter IS the
|
|
48
|
-
* declaration that it accepts storage-object inputs at all; an adapter
|
|
49
|
-
* without one refuses them with `AI_CAPABILITY_UNSUPPORTED`.
|
|
50
|
-
*
|
|
51
|
-
* @stability experimental
|
|
52
|
-
*/
|
|
53
|
-
export type AiFileInputStrategies = Readonly<Record<AiStorageInputModality, AiFileInputStrategy>>;
|
|
54
|
-
/**
|
|
55
|
-
* The modality of a stored object with `mimeType`.
|
|
56
|
-
*
|
|
57
|
-
* @stability experimental
|
|
58
|
-
*/
|
|
59
|
-
export declare function storageInputModality(mimeType: string): AiStorageInputModality;
|
|
60
|
-
/**
|
|
61
|
-
* The size cap for a modality.
|
|
62
|
-
*
|
|
63
|
-
* @stability experimental
|
|
64
|
-
*/
|
|
65
|
-
export declare function storageInputMaxBytes(modality: AiStorageInputModality): number;
|
|
66
|
-
/**
|
|
67
|
-
* One storage-object input, resolved and authorised by the runtime for one
|
|
68
|
-
* provider call. Exactly what the adapter's declared strategy needs is set.
|
|
69
|
-
*
|
|
70
|
-
* @stability experimental
|
|
71
|
-
*/
|
|
72
|
-
export interface AiResolvedStorageInput {
|
|
73
|
-
/** The storage object. */
|
|
74
|
-
storageObjectId: string;
|
|
75
|
-
/** Whether it is an image or a file input. */
|
|
76
|
-
modality: AiStorageInputModality;
|
|
77
|
-
/** Normalised MIME type (lower case, no parameters). */
|
|
78
|
-
mimeType: string;
|
|
79
|
-
/** The object's display name — a provider-facing filename. */
|
|
80
|
-
filename: string;
|
|
81
|
-
/** The strategy this input was prepared for (the adapter's own declaration). */
|
|
82
|
-
strategy: AiFileInputStrategy;
|
|
83
|
-
/**
|
|
84
|
-
* `presigned_url` only: a signed GET URL valid for
|
|
85
|
-
* `AI_STORAGE_INPUT_URL_TTL_SECONDS`. ⚠ Never log, persist or return it.
|
|
86
|
-
*/
|
|
87
|
-
url?: string;
|
|
88
|
-
/**
|
|
89
|
-
* `upload`/`inline`: the object's bytes as a stream (a Node `Readable` in
|
|
90
|
-
* practice), failing with `AI_INVALID_REQUEST` once more than the
|
|
91
|
-
* modality's cap has arrived.
|
|
92
|
-
*/
|
|
93
|
-
open?(): Promise<AsyncIterable<Uint8Array>>;
|
|
94
|
-
/** `upload`/`inline`: the bytes buffered, with the same cap. */
|
|
95
|
-
read?(): Promise<AiBinaryPayload>;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Every resolved storage input of one call, keyed by storage object id.
|
|
99
|
-
*
|
|
100
|
-
* @stability experimental
|
|
101
|
-
*/
|
|
102
|
-
export type AiResolvedStorageInputs = ReadonlyMap<string, AiResolvedStorageInput>;
|
|
1
|
+
import '../ai-error';
|
|
2
|
+
export { AI_STORAGE_INPUT_FILE_MAX_BYTES, AI_STORAGE_INPUT_IMAGE_MAX_BYTES, AI_STORAGE_INPUT_IMAGE_MIME_TYPES, AI_STORAGE_INPUT_URL_TTL_SECONDS, AI_STORAGE_INPUTS_MAX, storageInputMaxBytes, storageInputModality, } from '@marinoscar/platform-ai-providers';
|
|
3
|
+
export type { AiFileInputStrategies, AiFileInputStrategy, AiResolvedStorageInput, AiResolvedStorageInputs, AiStorageInputModality, } from '@marinoscar/platform-ai-providers';
|
|
103
4
|
//# sourceMappingURL=file-inputs.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-inputs.types.d.ts","sourceRoot":"","sources":["../../../../src/ai/core/types/file-inputs.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-inputs.types.d.ts","sourceRoot":"","sources":["../../../../src/ai/core/types/file-inputs.types.ts"],"names":[],"mappings":"AAKA,OAAO,aAAa,CAAC;AAErB,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,iCAAiC,EACjC,gCAAgC,EAChC,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AAE3C,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,mCAAmC,CAAC"}
|
|
@@ -1,81 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// An `image`/`file` content part may name one of the caller's storage objects
|
|
7
|
-
// (`{ type: 'file', storageObjectId }`) instead of a public URL. The RUNTIME
|
|
8
|
-
// resolves it before the adapter is called — ownership, readiness, modality
|
|
9
|
-
// against the model's capabilities, size — and hands the adapter what its
|
|
10
|
-
// declared DELIVERY STRATEGY needs, through `AiCallContext.storageInputs`:
|
|
11
|
-
//
|
|
12
|
-
// presigned_url a short-lived signed GET URL the provider fetches itself
|
|
13
|
-
// (`AI_STORAGE_INPUT_URL_TTL_SECONDS`); the bytes never pass
|
|
14
|
-
// through this API.
|
|
15
|
-
// upload the adapter streams the bytes to the provider's own file
|
|
16
|
-
// store and deletes the provider-side copy afterwards.
|
|
17
|
-
// inline the adapter embeds the bytes in the request (base64).
|
|
18
|
-
//
|
|
19
|
-
// The request itself is never rewritten: it keeps `storageObjectId`, so what
|
|
20
|
-
// is logged (the opt-in prompt log), queued (`ai_runs.request`) or recorded
|
|
21
|
-
// never carries a URL or bytes. A background run resolves again when it
|
|
22
|
-
// executes, under the same checks, with a fresh URL.
|
|
23
|
-
//
|
|
24
|
-
// ⚠ A presigned URL is a bearer capability for the object: it lives only in
|
|
25
|
-
// `AiCallContext.storageInputs`, for one call, and must never be logged,
|
|
26
|
-
// persisted, put on a span, or returned — the same rule as `apiKey`.
|
|
27
|
-
// =============================================================================
|
|
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.
|
|
28
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
exports
|
|
38
|
-
|
|
39
|
-
* The largest non-image file a Responses request may reference by storage object (50 MiB).
|
|
40
|
-
*
|
|
41
|
-
* @stability experimental
|
|
42
|
-
*/
|
|
43
|
-
exports.AI_STORAGE_INPUT_FILE_MAX_BYTES = 50 * 1024 * 1024;
|
|
44
|
-
/**
|
|
45
|
-
* The most storage-object parts one request may carry.
|
|
46
|
-
*
|
|
47
|
-
* @stability experimental
|
|
48
|
-
*/
|
|
49
|
-
exports.AI_STORAGE_INPUTS_MAX = 16;
|
|
50
|
-
/**
|
|
51
|
-
* How long a presigned input URL stays valid, in seconds (10 minutes).
|
|
52
|
-
*
|
|
53
|
-
* @stability experimental
|
|
54
|
-
*/
|
|
55
|
-
exports.AI_STORAGE_INPUT_URL_TTL_SECONDS = 600;
|
|
56
|
-
/**
|
|
57
|
-
* Stored objects of these MIME types are IMAGES (they need `vision_input`
|
|
58
|
-
* and are capped at `AI_STORAGE_INPUT_IMAGE_MAX_BYTES`); every other type is
|
|
59
|
-
* a FILE (`file_input`, `AI_STORAGE_INPUT_FILE_MAX_BYTES`).
|
|
60
|
-
*
|
|
61
|
-
* @stability experimental
|
|
62
|
-
*/
|
|
63
|
-
exports.AI_STORAGE_INPUT_IMAGE_MIME_TYPES = ['image/png', 'image/jpeg', 'image/gif', 'image/webp'];
|
|
64
|
-
/**
|
|
65
|
-
* The modality of a stored object with `mimeType`.
|
|
66
|
-
*
|
|
67
|
-
* @stability experimental
|
|
68
|
-
*/
|
|
69
|
-
function storageInputModality(mimeType) {
|
|
70
|
-
const normalised = mimeType.split(';')[0].trim().toLowerCase();
|
|
71
|
-
return exports.AI_STORAGE_INPUT_IMAGE_MIME_TYPES.includes(normalised) ? 'image' : 'file';
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* The size cap for a modality.
|
|
75
|
-
*
|
|
76
|
-
* @stability experimental
|
|
77
|
-
*/
|
|
78
|
-
function storageInputMaxBytes(modality) {
|
|
79
|
-
return modality === 'image' ? exports.AI_STORAGE_INPUT_IMAGE_MAX_BYTES : exports.AI_STORAGE_INPUT_FILE_MAX_BYTES;
|
|
80
|
-
}
|
|
7
|
+
exports.storageInputModality = exports.storageInputMaxBytes = exports.AI_STORAGE_INPUTS_MAX = exports.AI_STORAGE_INPUT_URL_TTL_SECONDS = exports.AI_STORAGE_INPUT_IMAGE_MIME_TYPES = exports.AI_STORAGE_INPUT_IMAGE_MAX_BYTES = exports.AI_STORAGE_INPUT_FILE_MAX_BYTES = void 0;
|
|
8
|
+
require("../ai-error");
|
|
9
|
+
var platform_ai_providers_1 = require("@marinoscar/platform-ai-providers");
|
|
10
|
+
Object.defineProperty(exports, "AI_STORAGE_INPUT_FILE_MAX_BYTES", { enumerable: true, get: function () { return platform_ai_providers_1.AI_STORAGE_INPUT_FILE_MAX_BYTES; } });
|
|
11
|
+
Object.defineProperty(exports, "AI_STORAGE_INPUT_IMAGE_MAX_BYTES", { enumerable: true, get: function () { return platform_ai_providers_1.AI_STORAGE_INPUT_IMAGE_MAX_BYTES; } });
|
|
12
|
+
Object.defineProperty(exports, "AI_STORAGE_INPUT_IMAGE_MIME_TYPES", { enumerable: true, get: function () { return platform_ai_providers_1.AI_STORAGE_INPUT_IMAGE_MIME_TYPES; } });
|
|
13
|
+
Object.defineProperty(exports, "AI_STORAGE_INPUT_URL_TTL_SECONDS", { enumerable: true, get: function () { return platform_ai_providers_1.AI_STORAGE_INPUT_URL_TTL_SECONDS; } });
|
|
14
|
+
Object.defineProperty(exports, "AI_STORAGE_INPUTS_MAX", { enumerable: true, get: function () { return platform_ai_providers_1.AI_STORAGE_INPUTS_MAX; } });
|
|
15
|
+
Object.defineProperty(exports, "storageInputMaxBytes", { enumerable: true, get: function () { return platform_ai_providers_1.storageInputMaxBytes; } });
|
|
16
|
+
Object.defineProperty(exports, "storageInputModality", { enumerable: true, get: function () { return platform_ai_providers_1.storageInputModality; } });
|
|
81
17
|
//# sourceMappingURL=file-inputs.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-inputs.types.js","sourceRoot":"","sources":["../../../../src/ai/core/types/file-inputs.types.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"file-inputs.types.js","sourceRoot":"","sources":["../../../../src/ai/core/types/file-inputs.types.ts"],"names":[],"mappings":";AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,yEAAyE;AACzE,6EAA6E;;;AAE7E,uBAAqB;AAErB,2EAQ2C;AAPzC,wIAAA,+BAA+B,OAAA;AAC/B,yIAAA,gCAAgC,OAAA;AAChC,0IAAA,iCAAiC,OAAA;AACjC,yIAAA,gCAAgC,OAAA;AAChC,8HAAA,qBAAqB,OAAA;AACrB,6HAAA,oBAAoB,OAAA;AACpB,6HAAA,oBAAoB,OAAA"}
|