@zimtsui/brainswitch 0.0.56 → 0.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -54
- package/assets/verbatim/declarations.handlebars +11 -0
- package/assets/verbatim/instruction.md +49 -0
- package/build/adaptor.d.ts +40 -9
- package/build/adaptor.js +36 -38
- package/build/adaptor.js.map +1 -1
- package/build/api-types/anthropic/billing.d.ts +5 -5
- package/build/api-types/anthropic/billing.js +1 -2
- package/build/api-types/anthropic/billing.js.map +1 -1
- package/build/api-types/anthropic/tool-codec.d.ts +11 -12
- package/build/api-types/anthropic/tool-codec.js +27 -42
- package/build/api-types/anthropic/tool-codec.js.map +1 -1
- package/build/api-types/google/billing.d.ts +5 -5
- package/build/api-types/google/billing.js +2 -3
- package/build/api-types/google/billing.js.map +1 -1
- package/build/api-types/google/restful-request.d.ts +1 -1
- package/build/api-types/google/restful-request.js +0 -1
- package/build/api-types/google/restful-request.js.map +1 -1
- package/build/api-types/google/tool-codec.d.ts +11 -11
- package/build/api-types/google/tool-codec.js +21 -19
- package/build/api-types/google/tool-codec.js.map +1 -1
- package/build/api-types/{openai-chatcompletion → openai-chatcompletions}/billing.d.ts +2 -3
- package/build/api-types/{openai-chatcompletion → openai-chatcompletions}/billing.js +0 -2
- package/build/api-types/openai-chatcompletions/billing.js.map +1 -0
- package/build/api-types/openai-chatcompletions/tool-codec.d.ts +17 -0
- package/build/api-types/{openai-chatcompletion → openai-chatcompletions}/tool-codec.js +26 -32
- package/build/api-types/openai-chatcompletions/tool-codec.js.map +1 -0
- package/build/api-types/openai-responses/billing.d.ts +5 -5
- package/build/api-types/openai-responses/billing.js +1 -2
- package/build/api-types/openai-responses/billing.js.map +1 -1
- package/build/api-types/openai-responses/tool-codec.d.ts +11 -11
- package/build/api-types/openai-responses/tool-codec.js +36 -32
- package/build/api-types/openai-responses/tool-codec.js.map +1 -1
- package/build/assets.d.ts +7 -0
- package/build/assets.js +8 -0
- package/build/assets.js.map +1 -0
- package/build/compatible-engine/session.d.ts +67 -0
- package/build/compatible-engine/session.js +92 -0
- package/build/compatible-engine/session.js.map +1 -0
- package/build/compatible-engine/structuring.d.ts +36 -0
- package/build/compatible-engine/structuring.js +34 -0
- package/build/compatible-engine/structuring.js.map +1 -0
- package/build/compatible-engine/validation.d.ts +21 -0
- package/build/compatible-engine/validation.js +82 -0
- package/build/compatible-engine/validation.js.map +1 -0
- package/build/compatible-engine.d/agentloop.d.ts +12 -0
- package/build/compatible-engine.d/agentloop.js +52 -0
- package/build/compatible-engine.d/agentloop.js.map +1 -0
- package/build/compatible-engine.d/aliyun/transport.d.ts +12 -0
- package/build/compatible-engine.d/aliyun/transport.js +7 -0
- package/build/compatible-engine.d/aliyun/transport.js.map +1 -0
- package/build/compatible-engine.d/aliyun.d.ts +24 -0
- package/build/compatible-engine.d/aliyun.js +46 -0
- package/build/compatible-engine.d/aliyun.js.map +1 -0
- package/build/compatible-engine.d/anthropic/choice-codec.d.ts +5 -0
- package/build/compatible-engine.d/anthropic/choice-codec.js +26 -0
- package/build/compatible-engine.d/anthropic/choice-codec.js.map +1 -0
- package/build/compatible-engine.d/anthropic/message-codec.d.ts +36 -0
- package/build/compatible-engine.d/anthropic/message-codec.js +86 -0
- package/build/compatible-engine.d/anthropic/message-codec.js.map +1 -0
- package/build/compatible-engine.d/anthropic/transport.d.ts +34 -0
- package/build/compatible-engine.d/anthropic/transport.js +150 -0
- package/build/compatible-engine.d/anthropic/transport.js.map +1 -0
- package/build/compatible-engine.d/anthropic.d.ts +26 -0
- package/build/compatible-engine.d/anthropic.js +46 -0
- package/build/compatible-engine.d/anthropic.js.map +1 -0
- package/build/compatible-engine.d/google/choice-codec.d.ts +5 -0
- package/build/compatible-engine.d/google/choice-codec.js +27 -0
- package/build/compatible-engine.d/google/choice-codec.js.map +1 -0
- package/build/compatible-engine.d/google/message-codec.d.ts +36 -0
- package/build/compatible-engine.d/google/message-codec.js +94 -0
- package/build/compatible-engine.d/google/message-codec.js.map +1 -0
- package/build/compatible-engine.d/google/transport.d.ts +30 -0
- package/build/{compatible.d → compatible-engine.d}/google/transport.js +22 -18
- package/build/compatible-engine.d/google/transport.js.map +1 -0
- package/build/compatible-engine.d/google.d.ts +26 -0
- package/build/compatible-engine.d/google.js +50 -0
- package/build/compatible-engine.d/google.js.map +1 -0
- package/build/compatible-engine.d/openai-chatcompletions/choice-codec.d.ts +5 -0
- package/build/compatible-engine.d/openai-chatcompletions/choice-codec.js +31 -0
- package/build/compatible-engine.d/openai-chatcompletions/choice-codec.js.map +1 -0
- package/build/compatible-engine.d/openai-chatcompletions/message-codec.d.ts +24 -0
- package/build/compatible-engine.d/openai-chatcompletions/message-codec.js +71 -0
- package/build/compatible-engine.d/openai-chatcompletions/message-codec.js.map +1 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.d/monolith.d.ts +38 -0
- package/build/{compatible.d/openai-chatcompletions.d → compatible-engine.d/openai-chatcompletions/transport.d}/monolith.js +25 -22
- package/build/compatible-engine.d/openai-chatcompletions/transport.d/monolith.js.map +1 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.d/stream.d.ts +37 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.d/stream.js +190 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.d/stream.js.map +1 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.d.ts +10 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.js +11 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.js.map +1 -0
- package/build/compatible-engine.d/openai-chatcompletions.d.ts +17 -0
- package/build/compatible-engine.d/openai-chatcompletions.js +14 -0
- package/build/compatible-engine.d/openai-chatcompletions.js.map +1 -0
- package/build/compatible-engine.d/openai-responses/choice-codec.d.ts +5 -0
- package/build/compatible-engine.d/openai-responses/choice-codec.js +30 -0
- package/build/compatible-engine.d/openai-responses/choice-codec.js.map +1 -0
- package/build/compatible-engine.d/openai-responses/message-codec.d.ts +36 -0
- package/build/compatible-engine.d/openai-responses/message-codec.js +96 -0
- package/build/compatible-engine.d/openai-responses/message-codec.js.map +1 -0
- package/build/compatible-engine.d/openai-responses/transport.d.ts +35 -0
- package/build/{compatible.d → compatible-engine.d}/openai-responses/transport.js +21 -29
- package/build/compatible-engine.d/openai-responses/transport.js.map +1 -0
- package/build/compatible-engine.d/openai-responses.d.ts +26 -0
- package/build/compatible-engine.d/openai-responses.js +46 -0
- package/build/compatible-engine.d/openai-responses.js.map +1 -0
- package/build/compatible-engine.d.ts +22 -0
- package/build/compatible-engine.js +29 -0
- package/build/compatible-engine.js.map +1 -0
- package/build/config.d.ts +1 -0
- package/build/config.js +1 -2
- package/build/config.js.map +1 -1
- package/build/endpoint-spec.d.ts +1 -0
- package/build/endpoint-spec.js +2 -1
- package/build/endpoint-spec.js.map +1 -1
- package/build/engine/session.d.ts +7 -0
- package/build/{session.js.map → engine/session.js.map} +1 -1
- package/build/engine/transport.d.ts +5 -0
- package/build/engine/transport.js +1 -0
- package/build/engine/transport.js.map +1 -0
- package/build/engine/validation.d.ts +9 -0
- package/build/engine/validation.js +1 -0
- package/build/engine/validation.js.map +1 -0
- package/build/engine.d.ts +49 -40
- package/build/engine.js +88 -70
- package/build/engine.js.map +1 -1
- package/build/exports.d.ts +14 -14
- package/build/exports.js +14 -14
- package/build/exports.js.map +1 -1
- package/build/function.d.ts +79 -66
- package/build/function.js +30 -47
- package/build/function.js.map +1 -1
- package/build/inference-context.d.ts +2 -2
- package/build/inference-context.js +0 -1
- package/build/inference-context.js.map +1 -1
- package/build/native-engines.d/google/message-codec.d.ts +18 -16
- package/build/native-engines.d/google/message-codec.js +31 -33
- package/build/native-engines.d/google/message-codec.js.map +1 -1
- package/build/native-engines.d/google/session.d.ts +44 -51
- package/build/native-engines.d/google/session.js +85 -81
- package/build/native-engines.d/google/session.js.map +1 -1
- package/build/native-engines.d/google/transport.d.ts +22 -19
- package/build/native-engines.d/google/transport.js +13 -13
- package/build/native-engines.d/google/transport.js.map +1 -1
- package/build/native-engines.d/google/validation.d.ts +22 -0
- package/build/native-engines.d/google/validation.js +20 -0
- package/build/native-engines.d/google/validation.js.map +1 -0
- package/build/native-engines.d/google.d/agentloop.d.ts +12 -0
- package/build/native-engines.d/google.d/agentloop.js +57 -0
- package/build/native-engines.d/google.d/agentloop.js.map +1 -0
- package/build/native-engines.d/google.d/exports.d.ts +3 -0
- package/build/native-engines.d/google.d/exports.js +4 -0
- package/build/native-engines.d/google.d/exports.js.map +1 -0
- package/build/native-engines.d/google.d.ts +42 -0
- package/build/native-engines.d/google.js +83 -0
- package/build/native-engines.d/google.js.map +1 -0
- package/build/native-engines.d/openai-responses/choice-codec.d.ts +5 -0
- package/build/native-engines.d/openai-responses/choice-codec.js +30 -0
- package/build/native-engines.d/openai-responses/choice-codec.js.map +1 -0
- package/build/native-engines.d/openai-responses/message-codec.d.ts +19 -17
- package/build/native-engines.d/openai-responses/message-codec.js +31 -25
- package/build/native-engines.d/openai-responses/message-codec.js.map +1 -1
- package/build/native-engines.d/openai-responses/session.d.ts +47 -45
- package/build/native-engines.d/openai-responses/session.js +75 -105
- package/build/native-engines.d/openai-responses/session.js.map +1 -1
- package/build/native-engines.d/openai-responses/structuring.d.ts +19 -0
- package/build/native-engines.d/openai-responses/structuring.js +19 -0
- package/build/native-engines.d/openai-responses/structuring.js.map +1 -0
- package/build/native-engines.d/openai-responses/tool.d.ts +15 -12
- package/build/native-engines.d/openai-responses/tool.js +1 -12
- package/build/native-engines.d/openai-responses/tool.js.map +1 -1
- package/build/native-engines.d/openai-responses/transport.d.ts +24 -25
- package/build/native-engines.d/openai-responses/transport.js +21 -41
- package/build/native-engines.d/openai-responses/transport.js.map +1 -1
- package/build/native-engines.d/openai-responses/validation.d.ts +20 -0
- package/build/native-engines.d/openai-responses/validation.js +80 -0
- package/build/native-engines.d/openai-responses/validation.js.map +1 -0
- package/build/native-engines.d/openai-responses.d/agentloop.d.ts +12 -0
- package/build/native-engines.d/openai-responses.d/agentloop.js +61 -0
- package/build/native-engines.d/openai-responses.d/agentloop.js.map +1 -0
- package/build/native-engines.d/openai-responses.d/exports.d.ts +4 -0
- package/build/native-engines.d/openai-responses.d/exports.js +5 -0
- package/build/native-engines.d/openai-responses.d/exports.js.map +1 -0
- package/build/native-engines.d/openai-responses.d.ts +44 -0
- package/build/native-engines.d/openai-responses.js +78 -0
- package/build/native-engines.d/openai-responses.js.map +1 -0
- package/build/throttle.d.ts +6 -5
- package/build/throttle.js +17 -14
- package/build/throttle.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/verbatim/codec/declarations.d.ts +2 -0
- package/build/verbatim/codec/declarations.js +22 -0
- package/build/verbatim/codec/declarations.js.map +1 -0
- package/build/verbatim/codec/request.d.ts +7 -0
- package/build/verbatim/codec/request.js +53 -0
- package/build/verbatim/codec/request.js.map +1 -0
- package/build/verbatim/codec.d.ts +2 -0
- package/build/verbatim/codec.js +3 -0
- package/build/verbatim/codec.js.map +1 -0
- package/build/verbatim.d.ts +74 -0
- package/build/verbatim.js +17 -0
- package/build/verbatim.js.map +1 -0
- package/examples/agent.ts +65 -0
- package/examples/chat.ts +24 -0
- package/examples/config.ts +24 -0
- package/{test/src → examples}/tsconfig.json +6 -2
- package/examples/verbatim.ts +44 -0
- package/package.json +15 -13
- package/build/agentloop.d.ts +0 -12
- package/build/agentloop.js +0 -43
- package/build/agentloop.js.map +0 -1
- package/build/api-types/openai-chatcompletion/billing.js.map +0 -1
- package/build/api-types/openai-chatcompletion/tool-codec.d.ts +0 -18
- package/build/api-types/openai-chatcompletion/tool-codec.js.map +0 -1
- package/build/compatible/engine.d/aliyun.d.ts +0 -23
- package/build/compatible/engine.d/aliyun.js +0 -44
- package/build/compatible/engine.d/aliyun.js.map +0 -1
- package/build/compatible/engine.d/anthropic.d.ts +0 -23
- package/build/compatible/engine.d/anthropic.js +0 -41
- package/build/compatible/engine.d/anthropic.js.map +0 -1
- package/build/compatible/engine.d/google.d.ts +0 -23
- package/build/compatible/engine.d/google.js +0 -45
- package/build/compatible/engine.d/google.js.map +0 -1
- package/build/compatible/engine.d/openai-responses.d.ts +0 -23
- package/build/compatible/engine.d/openai-responses.js +0 -41
- package/build/compatible/engine.d/openai-responses.js.map +0 -1
- package/build/compatible/engine.d.ts +0 -18
- package/build/compatible/engine.js +0 -21
- package/build/compatible/engine.js.map +0 -1
- package/build/compatible/session.d.ts +0 -78
- package/build/compatible/session.js +0 -138
- package/build/compatible/session.js.map +0 -1
- package/build/compatible/tool-call-validator.d.ts +0 -11
- package/build/compatible/tool-call-validator.js +0 -12
- package/build/compatible/tool-call-validator.js.map +0 -1
- package/build/compatible.d/aliyun/transport.d.ts +0 -11
- package/build/compatible.d/aliyun/transport.js +0 -9
- package/build/compatible.d/aliyun/transport.js.map +0 -1
- package/build/compatible.d/anthropic/message-codec.d.ts +0 -31
- package/build/compatible.d/anthropic/message-codec.js +0 -88
- package/build/compatible.d/anthropic/message-codec.js.map +0 -1
- package/build/compatible.d/anthropic/transport.d.ts +0 -31
- package/build/compatible.d/anthropic/transport.js +0 -137
- package/build/compatible.d/anthropic/transport.js.map +0 -1
- package/build/compatible.d/google/message-codec.d.ts +0 -31
- package/build/compatible.d/google/message-codec.js +0 -98
- package/build/compatible.d/google/message-codec.js.map +0 -1
- package/build/compatible.d/google/transport.d.ts +0 -28
- package/build/compatible.d/google/transport.js.map +0 -1
- package/build/compatible.d/openai-chatcompletions/message-codec.d.ts +0 -19
- package/build/compatible.d/openai-chatcompletions/message-codec.js +0 -66
- package/build/compatible.d/openai-chatcompletions/message-codec.js.map +0 -1
- package/build/compatible.d/openai-chatcompletions/transport.d.ts +0 -9
- package/build/compatible.d/openai-chatcompletions/transport.js +0 -25
- package/build/compatible.d/openai-chatcompletions/transport.js.map +0 -1
- package/build/compatible.d/openai-chatcompletions.d/monolith.d.ts +0 -36
- package/build/compatible.d/openai-chatcompletions.d/monolith.js.map +0 -1
- package/build/compatible.d/openai-chatcompletions.d/stream.d.ts +0 -35
- package/build/compatible.d/openai-chatcompletions.d/stream.js +0 -196
- package/build/compatible.d/openai-chatcompletions.d/stream.js.map +0 -1
- package/build/compatible.d/openai-responses/message-codec.d.ts +0 -32
- package/build/compatible.d/openai-responses/message-codec.js +0 -105
- package/build/compatible.d/openai-responses/message-codec.js.map +0 -1
- package/build/compatible.d/openai-responses/transport.d.ts +0 -33
- package/build/compatible.d/openai-responses/transport.js.map +0 -1
- package/build/frontmatter.d.ts +0 -5
- package/build/frontmatter.js +0 -13
- package/build/frontmatter.js.map +0 -1
- package/build/native-engines.d/google/agentloop.d.ts +0 -12
- package/build/native-engines.d/google/agentloop.js +0 -42
- package/build/native-engines.d/google/agentloop.js.map +0 -1
- package/build/native-engines.d/google/engine.d.ts +0 -35
- package/build/native-engines.d/google/engine.js +0 -73
- package/build/native-engines.d/google/engine.js.map +0 -1
- package/build/native-engines.d/google/exports.d.ts +0 -5
- package/build/native-engines.d/google/exports.js +0 -6
- package/build/native-engines.d/google/exports.js.map +0 -1
- package/build/native-engines.d/openai-responses/agentloop.d.ts +0 -13
- package/build/native-engines.d/openai-responses/agentloop.js +0 -53
- package/build/native-engines.d/openai-responses/agentloop.js.map +0 -1
- package/build/native-engines.d/openai-responses/engine.d.ts +0 -32
- package/build/native-engines.d/openai-responses/engine.js +0 -63
- package/build/native-engines.d/openai-responses/engine.js.map +0 -1
- package/build/native-engines.d/openai-responses/exports.d.ts +0 -6
- package/build/native-engines.d/openai-responses/exports.js +0 -7
- package/build/native-engines.d/openai-responses/exports.js.map +0 -1
- package/build/native-engines.d/openai-responses/tool-call-validator.d.ts +0 -12
- package/build/native-engines.d/openai-responses/tool-call-validator.js +0 -33
- package/build/native-engines.d/openai-responses/tool-call-validator.js.map +0 -1
- package/build/session.d.ts +0 -7
- package/test/build/test-codecs.d.ts +0 -1
- package/test/build/test-codecs.js +0 -230
- package/test/build/test-codecs.js.map +0 -1
- package/test/build/test-compatible-engine.d.ts +0 -1
- package/test/build/test-compatible-engine.js +0 -27
- package/test/build/test-compatible-engine.js.map +0 -1
- package/test/build/test-compatible-engines.d.ts +0 -1
- package/test/build/test-compatible-engines.js +0 -112
- package/test/build/test-compatible-engines.js.map +0 -1
- package/test/build/test-engine.d.ts +0 -1
- package/test/build/test-engine.js +0 -97
- package/test/build/test-engine.js.map +0 -1
- package/test/build/test-helpers.d.ts +0 -46
- package/test/build/test-helpers.js +0 -45
- package/test/build/test-helpers.js.map +0 -1
- package/test/build/test-native-engines.d.ts +0 -1
- package/test/build/test-native-engines.js +0 -64
- package/test/build/test-native-engines.js.map +0 -1
- package/test/build/test.d.ts +0 -5
- package/test/build/test.js +0 -6
- package/test/build/test.js.map +0 -1
- package/test/build/tsconfig.tsbuildinfo +0 -1
- package/test/src/test-codecs.ts +0 -256
- package/test/src/test-compatible-engine.ts +0 -45
- package/test/src/test-compatible-engines.ts +0 -129
- package/test/src/test-engine.ts +0 -144
- package/test/src/test-helpers.ts +0 -53
- package/test/src/test-native-engines.ts +0 -75
- package/test/src/test.ts +0 -5
- /package/build/{session.js → engine/session.js} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CompatibleEngine } from "../compatible-engine.js";
|
|
2
|
+
import * as MessageCodecModule from "./openai-chatcompletions/message-codec.js";
|
|
3
|
+
import * as TransportModule from "./openai-chatcompletions/transport.js";
|
|
4
|
+
import * as ChoiceCodecModule from "./openai-chatcompletions/choice-codec.js";
|
|
5
|
+
export var OpenAIChatCompletionsCompatibleEngine;
|
|
6
|
+
(function (OpenAIChatCompletionsCompatibleEngine) {
|
|
7
|
+
class Instance extends CompatibleEngine.Instance {
|
|
8
|
+
}
|
|
9
|
+
OpenAIChatCompletionsCompatibleEngine.Instance = Instance;
|
|
10
|
+
OpenAIChatCompletionsCompatibleEngine.Transport = TransportModule.Transport;
|
|
11
|
+
OpenAIChatCompletionsCompatibleEngine.MessageCodec = MessageCodecModule.MessageCodec;
|
|
12
|
+
OpenAIChatCompletionsCompatibleEngine.ChoiceCodec = ChoiceCodecModule;
|
|
13
|
+
})(OpenAIChatCompletionsCompatibleEngine || (OpenAIChatCompletionsCompatibleEngine = {}));
|
|
14
|
+
//# sourceMappingURL=openai-chatcompletions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-chatcompletions.js","sourceRoot":"","sources":["../../src/compatible-engine.d/openai-chatcompletions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,kBAAkB,MAAM,2CAA2C,CAAC;AAChF,OAAO,KAAK,eAAe,MAAM,uCAAuC,CAAC;AAEzE,OAAO,KAAK,iBAAiB,MAAM,0CAA0C,CAAC;AAQ9E,MAAM,KAAW,qCAAqC,CAgBrD;AAhBD,WAAiB,qCAAqC;IAClD,MAAsB,QAGpB,SAAQ,gBAAgB,CAAC,QAAkB;KAE5C;IALqB,8CAAQ,WAK7B,CAAA;IAOa,+CAAS,GAAG,eAAe,CAAC,SAAS,CAAC;IACtC,kDAAY,GAAG,kBAAkB,CAAC,YAAY,CAAC;IAC/C,iDAAW,GAAG,iBAAiB,CAAC;AAClD,CAAC,EAhBgB,qCAAqC,KAArC,qCAAqC,QAgBrD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Structuring } from '../../compatible-engine/structuring.ts';
|
|
2
|
+
import type { Function } from '../../function.ts';
|
|
3
|
+
import type { Verbatim } from '../../verbatim.ts';
|
|
4
|
+
import type { OpenAI } from 'openai';
|
|
5
|
+
export declare function encode<fdu extends Function.Decl.Proto, vdu extends Verbatim.Decl.Proto>(choice: Structuring.Choice<fdu, vdu>): OpenAI.Responses.ToolChoiceOptions | OpenAI.Responses.ToolChoiceAllowed;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Structuring } from "../../compatible-engine/structuring.js";
|
|
2
|
+
export function encode(choice) {
|
|
3
|
+
if (choice === Structuring.Choice.NONE)
|
|
4
|
+
return 'none';
|
|
5
|
+
else if (choice === Structuring.Choice.REQUIRED)
|
|
6
|
+
return 'auto';
|
|
7
|
+
else if (choice === Structuring.Choice.ANYONE)
|
|
8
|
+
return 'auto';
|
|
9
|
+
else if (choice === Structuring.Choice.AUTO)
|
|
10
|
+
return 'auto';
|
|
11
|
+
else if (choice === Structuring.Choice.FCall.REQUIRED)
|
|
12
|
+
return 'required';
|
|
13
|
+
else if (choice === Structuring.Choice.FCall.ANYONE)
|
|
14
|
+
return 'required';
|
|
15
|
+
else if (choice instanceof Structuring.Choice.FCall)
|
|
16
|
+
return {
|
|
17
|
+
type: 'allowed_tools',
|
|
18
|
+
mode: 'required',
|
|
19
|
+
tools: [{ type: 'function', name: choice.name }],
|
|
20
|
+
};
|
|
21
|
+
else if (choice === Structuring.Choice.VRequest.REQUIRED)
|
|
22
|
+
return 'none';
|
|
23
|
+
else if (choice === Structuring.Choice.VRequest.ANYONE)
|
|
24
|
+
return 'none';
|
|
25
|
+
else if (choice instanceof Structuring.Choice.VRequest)
|
|
26
|
+
return 'none';
|
|
27
|
+
else
|
|
28
|
+
throw new Error();
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=choice-codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choice-codec.js","sourceRoot":"","sources":["../../../src/compatible-engine.d/openai-responses/choice-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAOrE,MAAM,UAAU,MAAM,CAIlB,MAAoC;IAEpC,IAAI,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC,IAAI;QAAE,OAAO,MAAM,CAAC;SACjD,IAAI,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC,QAAQ;QAAE,OAAO,MAAM,CAAC;SAC1D,IAAI,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC;SACxD,IAAI,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC,IAAI;QAAE,OAAO,MAAM,CAAC;SAEtD,IAAI,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ;QAAE,OAAO,UAAU,CAAC;SACpE,IAAI,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,UAAU,CAAC;SAClE,IAAI,MAAM,YAAY,WAAW,CAAC,MAAM,CAAC,KAAK;QAC/C,OAAO;YACH,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAiD;SACnG,CAAC;SAED,IAAI,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ;QAAE,OAAO,MAAM,CAAC;SACnE,IAAI,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC;SACjE,IAAI,MAAM,YAAY,WAAW,CAAC,MAAM,CAAC,QAAQ;QAAE,OAAO,MAAM,CAAC;;QAEjE,MAAM,IAAI,KAAK,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RoleMessage, type Session } from '../../compatible-engine/session.ts';
|
|
2
|
+
import { Function } from '../../function.ts';
|
|
3
|
+
import OpenAI from 'openai';
|
|
4
|
+
import type { ToolCodec } from '../../api-types/openai-responses/tool-codec.ts';
|
|
5
|
+
import type { Verbatim } from '../../verbatim.ts';
|
|
6
|
+
declare const NOMINAL: unique symbol;
|
|
7
|
+
export declare class MessageCodec<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> {
|
|
8
|
+
protected ctx: MessageCodec.Context<fdm, vdm>;
|
|
9
|
+
constructor(ctx: MessageCodec.Context<fdm, vdm>);
|
|
10
|
+
/**
|
|
11
|
+
* @throws {@link VerbatimCodec.Request.Invalid}
|
|
12
|
+
*/
|
|
13
|
+
decodeAiMessage(output: OpenAI.Responses.ResponseOutputItem[]): MessageCodec.Message.Ai.From<fdm, vdm>;
|
|
14
|
+
encodeUserMessage(userMessage: RoleMessage.User.From<fdm>): OpenAI.Responses.ResponseInput;
|
|
15
|
+
encodeAiMessage(aiMessage: RoleMessage.Ai.From<fdm, vdm>): OpenAI.Responses.ResponseInput;
|
|
16
|
+
encodeDeveloperMessage(developerMessage: RoleMessage.Developer): string;
|
|
17
|
+
encodeChatMessage(chatMessage: Session.ChatMessage.From<fdm, vdm>): OpenAI.Responses.ResponseInput;
|
|
18
|
+
}
|
|
19
|
+
export declare namespace MessageCodec {
|
|
20
|
+
interface Context<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> {
|
|
21
|
+
toolCodec: ToolCodec<fdm>;
|
|
22
|
+
vdm: vdm;
|
|
23
|
+
}
|
|
24
|
+
namespace Message {
|
|
25
|
+
class Ai<out fdu extends Function.Decl.Proto, out vdu extends Verbatim.Decl.Proto> extends RoleMessage.Ai<fdu, vdu> {
|
|
26
|
+
protected raw: OpenAI.Responses.ResponseOutputItem[];
|
|
27
|
+
[NOMINAL]: void;
|
|
28
|
+
constructor(parts: RoleMessage.Ai.Part<fdu, vdu>[], raw: OpenAI.Responses.ResponseOutputItem[]);
|
|
29
|
+
getRaw(): OpenAI.Responses.ResponseOutputItem[];
|
|
30
|
+
}
|
|
31
|
+
namespace Ai {
|
|
32
|
+
type From<fdm extends Function.Decl.Map.Proto, vdm extends Verbatim.Decl.Map.Proto> = Ai<Function.Decl.From<fdm>, Verbatim.Decl.From<vdm>>;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { RoleMessage } from "../../compatible-engine/session.js";
|
|
2
|
+
import { Function } from "../../function.js";
|
|
3
|
+
import * as VerbatimCodec from "../../verbatim/codec.js";
|
|
4
|
+
import { ResponseInvalid } from "../../engine.js";
|
|
5
|
+
const NOMINAL = Symbol();
|
|
6
|
+
export class MessageCodec {
|
|
7
|
+
ctx;
|
|
8
|
+
constructor(ctx) {
|
|
9
|
+
this.ctx = ctx;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @throws {@link VerbatimCodec.Request.Invalid}
|
|
13
|
+
*/
|
|
14
|
+
decodeAiMessage(output) {
|
|
15
|
+
const parts = output.flatMap((item) => {
|
|
16
|
+
if (item.type === 'message') {
|
|
17
|
+
if (item.content.every(part => part.type === 'output_text')) { }
|
|
18
|
+
else
|
|
19
|
+
throw new ResponseInvalid('Refusal', { cause: output });
|
|
20
|
+
const text = item.content.map(part => part.text).join('');
|
|
21
|
+
if (text) {
|
|
22
|
+
const vrs = VerbatimCodec.Request.decode(text, this.ctx.vdm);
|
|
23
|
+
return [new RoleMessage.Part.Text(text, vrs)];
|
|
24
|
+
}
|
|
25
|
+
else
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
else if (item.type === 'function_call')
|
|
29
|
+
return [this.ctx.toolCodec.decodeFunctionCall(item)];
|
|
30
|
+
else if (item.type === 'reasoning')
|
|
31
|
+
return [];
|
|
32
|
+
else
|
|
33
|
+
throw new Error();
|
|
34
|
+
});
|
|
35
|
+
return new MessageCodec.Message.Ai(parts, output);
|
|
36
|
+
}
|
|
37
|
+
encodeUserMessage(userMessage) {
|
|
38
|
+
return userMessage.getParts().map(part => {
|
|
39
|
+
if (part instanceof RoleMessage.Part.Text)
|
|
40
|
+
return {
|
|
41
|
+
type: 'message',
|
|
42
|
+
role: 'user',
|
|
43
|
+
content: part.text,
|
|
44
|
+
};
|
|
45
|
+
else if (part instanceof Function.Response)
|
|
46
|
+
return this.ctx.toolCodec.encodeFunctionResponse(part);
|
|
47
|
+
else
|
|
48
|
+
throw new Error();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
encodeAiMessage(aiMessage) {
|
|
52
|
+
if (aiMessage instanceof MessageCodec.Message.Ai)
|
|
53
|
+
return aiMessage.getRaw();
|
|
54
|
+
else {
|
|
55
|
+
return aiMessage.getParts().map(part => {
|
|
56
|
+
if (part instanceof RoleMessage.Part.Text)
|
|
57
|
+
return {
|
|
58
|
+
role: 'assistant',
|
|
59
|
+
content: part.text,
|
|
60
|
+
};
|
|
61
|
+
else if (part instanceof Function.Call)
|
|
62
|
+
return this.ctx.toolCodec.encodeFunctionCall(part);
|
|
63
|
+
else
|
|
64
|
+
throw new Error();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
encodeDeveloperMessage(developerMessage) {
|
|
69
|
+
return developerMessage.getText();
|
|
70
|
+
}
|
|
71
|
+
encodeChatMessage(chatMessage) {
|
|
72
|
+
if (chatMessage instanceof RoleMessage.User)
|
|
73
|
+
return this.encodeUserMessage(chatMessage);
|
|
74
|
+
else if (chatMessage instanceof RoleMessage.Ai)
|
|
75
|
+
return this.encodeAiMessage(chatMessage);
|
|
76
|
+
else
|
|
77
|
+
throw new Error();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
(function (MessageCodec) {
|
|
81
|
+
let Message;
|
|
82
|
+
(function (Message) {
|
|
83
|
+
class Ai extends RoleMessage.Ai {
|
|
84
|
+
raw;
|
|
85
|
+
constructor(parts, raw) {
|
|
86
|
+
super(parts);
|
|
87
|
+
this.raw = raw;
|
|
88
|
+
}
|
|
89
|
+
getRaw() {
|
|
90
|
+
return this.raw;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
Message.Ai = Ai;
|
|
94
|
+
})(Message = MessageCodec.Message || (MessageCodec.Message = {}));
|
|
95
|
+
})(MessageCodec || (MessageCodec = {}));
|
|
96
|
+
//# sourceMappingURL=message-codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-codec.js","sourceRoot":"","sources":["../../../src/compatible-engine.d/openai-responses/message-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAg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BAClD,MAAM,IAAI,KAAK,EAAE,CAAC;YAC3B,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAEM,sBAAsB,CAAC,gBAAuC;QACjE,OAAO,gBAAgB,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;IAEM,iBAAiB,CACpB,WAA+C;QAE/C,IAAI,WAAW,YAAY,WAAW,CAAC,IAAI;YACvC,OAAO,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;aAC1C,IAAI,WAAW,YAAY,WAAW,CAAC,EAAE;YAC1C,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;;YACxC,MAAM,IAAI,KAAK,EAAE,CAAC;IAC3B,CAAC;CACJ;AAED,WAAiB,YAAY;IASzB,IAAiB,OAAO,CA0BvB;IA1BD,WAAiB,OAAO;QACpB,MAAa,EAGX,SAAQ,WAAW,CAAC,EAAY;YAIhB;YAFd,YACI,KAAsC,EAC5B,GAA0C;gBAEpD,KAAK,CAAC,KAAK,CAAC,CAAC;gBAFH,QAAG,GAAH,GAAG,CAAuC;YAGxD,CAAC;YAEM,MAAM;gBACT,OAAO,IAAI,CAAC,GAAG,CAAC;YACpB,CAAC;SACJ;QAfY,UAAE,KAed,CAAA;IAUL,CAAC,EA1BgB,OAAO,GAAP,oBAAO,KAAP,oBAAO,QA0BvB;AACL,CAAC,EApCgB,YAAY,KAAZ,YAAY,QAoC5B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type InferenceParams, type ProviderSpec } from '../../engine.ts';
|
|
2
|
+
import { RoleMessage, type Session } from '../../compatible-engine/session.ts';
|
|
3
|
+
import { Function } from '../../function.ts';
|
|
4
|
+
import type OpenAI from 'openai';
|
|
5
|
+
import { type InferenceContext } from '../../inference-context.ts';
|
|
6
|
+
import { Throttle } from '../../throttle.ts';
|
|
7
|
+
import type { MessageCodec } from './message-codec.ts';
|
|
8
|
+
import type { ToolCodec } from '../../api-types/openai-responses/tool-codec.ts';
|
|
9
|
+
import type { Billing } from '../../api-types/openai-responses/billing.ts';
|
|
10
|
+
import type { Verbatim } from '../../verbatim.ts';
|
|
11
|
+
import { Validator } from '../../compatible-engine/validation.ts';
|
|
12
|
+
import type { Structuring } from '../../compatible-engine/structuring.ts';
|
|
13
|
+
import type { Engine } from '../../engine.ts';
|
|
14
|
+
export declare class Transport<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> implements Engine.Transport<RoleMessage.User.From<fdm>, RoleMessage.Ai.From<fdm, vdm>, RoleMessage.Developer, Session.From<fdm, vdm>> {
|
|
15
|
+
protected ctx: Transport.Context<fdm, vdm>;
|
|
16
|
+
protected apiURL: URL;
|
|
17
|
+
constructor(ctx: Transport.Context<fdm, vdm>);
|
|
18
|
+
protected makeParams(session: Session.From<fdm, vdm>): OpenAI.Responses.ResponseCreateParamsNonStreaming;
|
|
19
|
+
protected logAiMessage(output: OpenAI.Responses.ResponseOutputItem[]): void;
|
|
20
|
+
fetch(wfctx: InferenceContext, session: Session.From<fdm, vdm>, signal?: AbortSignal): Promise<RoleMessage.Ai.From<fdm, vdm>>;
|
|
21
|
+
}
|
|
22
|
+
export declare namespace Transport {
|
|
23
|
+
interface Context<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> {
|
|
24
|
+
inferenceSpec: InferenceParams;
|
|
25
|
+
providerSpec: ProviderSpec;
|
|
26
|
+
fdm: fdm;
|
|
27
|
+
throttle: Throttle;
|
|
28
|
+
choice: Structuring.Choice.From<fdm, vdm>;
|
|
29
|
+
parallelToolCall: boolean;
|
|
30
|
+
messageCodec: MessageCodec<fdm, vdm>;
|
|
31
|
+
toolCodec: ToolCodec<fdm>;
|
|
32
|
+
billing: Billing;
|
|
33
|
+
validator: Validator.From<fdm, vdm>;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { ResponseInvalid } from
|
|
2
|
-
import { RoleMessage } from '#@/compatible/session.ts';
|
|
3
|
-
import { Function } from '#@/function.ts';
|
|
4
|
-
import OpenAI from 'openai';
|
|
1
|
+
import { NetworkError, ResponseInvalid } from "../../engine.js";
|
|
5
2
|
import * as Undici from 'undici';
|
|
6
|
-
import {} from
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
export class OpenAIResponsesCompatibleTransport {
|
|
3
|
+
import { logger } from "../../telemetry.js";
|
|
4
|
+
import * as ChoiceCodec from "./choice-codec.js";
|
|
5
|
+
export class Transport {
|
|
10
6
|
ctx;
|
|
11
7
|
apiURL;
|
|
12
8
|
constructor(ctx) {
|
|
@@ -14,15 +10,15 @@ export class OpenAIResponsesCompatibleTransport {
|
|
|
14
10
|
this.apiURL = new URL(`${this.ctx.providerSpec.baseUrl}/responses`);
|
|
15
11
|
}
|
|
16
12
|
makeParams(session) {
|
|
17
|
-
const tools = this.ctx.toolCodec.
|
|
13
|
+
const tools = this.ctx.toolCodec.encodeFunctionDeclarationMap(this.ctx.fdm);
|
|
18
14
|
return {
|
|
19
15
|
model: this.ctx.inferenceSpec.model,
|
|
20
16
|
include: ['reasoning.encrypted_content'],
|
|
21
17
|
store: false,
|
|
22
|
-
input: session.chatMessages.flatMap(chatMessage => this.ctx.messageCodec.
|
|
23
|
-
instructions: session.developerMessage && this.ctx.messageCodec.
|
|
18
|
+
input: session.chatMessages.flatMap(chatMessage => this.ctx.messageCodec.encodeChatMessage(chatMessage)),
|
|
19
|
+
instructions: session.developerMessage && this.ctx.messageCodec.encodeDeveloperMessage(session.developerMessage),
|
|
24
20
|
tools: tools.length ? tools : undefined,
|
|
25
|
-
tool_choice: tools.length ?
|
|
21
|
+
tool_choice: tools.length ? ChoiceCodec.encode(this.ctx.choice) : undefined,
|
|
26
22
|
parallel_tool_calls: tools.length ? this.ctx.parallelToolCall : undefined,
|
|
27
23
|
max_output_tokens: this.ctx.inferenceSpec.maxTokens,
|
|
28
24
|
...this.ctx.inferenceSpec.additionalOptions,
|
|
@@ -39,10 +35,12 @@ export class OpenAIResponsesCompatibleTransport {
|
|
|
39
35
|
else if (item.type === 'function_call')
|
|
40
36
|
logger.message.debug(item);
|
|
41
37
|
}
|
|
42
|
-
async
|
|
38
|
+
async fetch(wfctx, session, signal) {
|
|
39
|
+
await this.ctx.throttle.requests(wfctx);
|
|
40
|
+
// Prepare request
|
|
43
41
|
const params = this.makeParams(session);
|
|
44
42
|
logger.message.trace(params);
|
|
45
|
-
|
|
43
|
+
// Send request
|
|
46
44
|
const res = await Undici.fetch(this.apiURL, {
|
|
47
45
|
method: 'POST',
|
|
48
46
|
headers: new Headers({
|
|
@@ -52,37 +50,31 @@ export class OpenAIResponsesCompatibleTransport {
|
|
|
52
50
|
body: JSON.stringify(params),
|
|
53
51
|
dispatcher: this.ctx.providerSpec.proxyAgent,
|
|
54
52
|
signal,
|
|
53
|
+
}).catch(e => {
|
|
54
|
+
if (e instanceof TypeError)
|
|
55
|
+
throw new NetworkError(undefined, { cause: e });
|
|
56
|
+
else
|
|
57
|
+
throw e;
|
|
55
58
|
});
|
|
59
|
+
// Get response
|
|
56
60
|
if (res.ok) { }
|
|
57
61
|
else
|
|
58
62
|
throw new Error(undefined, { cause: res });
|
|
59
63
|
const response = await res.json();
|
|
60
64
|
logger.message.trace(response);
|
|
65
|
+
// Validate response
|
|
61
66
|
if (response.status === 'incomplete' && response.incomplete_details?.reason === 'max_output_tokens')
|
|
62
67
|
throw new ResponseInvalid('Token limit exceeded.', { cause: response });
|
|
63
68
|
if (response.status === 'completed') { }
|
|
64
69
|
else
|
|
65
70
|
throw new ResponseInvalid('Abnormal response status', { cause: response });
|
|
66
|
-
this.logAiMessage(response.output);
|
|
67
71
|
if (response.usage) { }
|
|
68
72
|
else
|
|
69
73
|
throw new Error();
|
|
74
|
+
this.logAiMessage(response.output);
|
|
70
75
|
logger.message.debug(response.usage);
|
|
71
76
|
wfctx.cost?.(this.ctx.billing.charge(response.usage));
|
|
72
|
-
|
|
73
|
-
this.ctx.toolCallValidator.validate(aiMessage.getFunctionCalls());
|
|
74
|
-
return aiMessage;
|
|
75
|
-
}
|
|
76
|
-
async fetch(wfctx, session, signal) {
|
|
77
|
-
try {
|
|
78
|
-
return await this.fetchRaw(wfctx, session, signal);
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
if (e instanceof OpenAI.APIError)
|
|
82
|
-
throw new ResponseInvalid(undefined, { cause: e });
|
|
83
|
-
else
|
|
84
|
-
throw e;
|
|
85
|
-
}
|
|
77
|
+
return this.ctx.messageCodec.decodeAiMessage(response.output);
|
|
86
78
|
}
|
|
87
79
|
}
|
|
88
80
|
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/compatible-engine.d/openai-responses/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAA2C,MAAM,iBAAiB,CAAC;AAIzG,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAGjC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAM5C,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AAKjD,MAAM,OAAO,SAAS;IAWW;IAFnB,MAAM,CAAM;IAEtB,YAA6B,GAAgC;QAAhC,QAAG,GAAH,GAAG,CAA6B;QACzD,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;IACxE,CAAC;IAES,UAAU,CAChB,OAA+B;QAE/B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5E,OAAO;YACH,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK;YACnC,OAAO,EAAE,CAAC,6BAA6B,CAAC;YACxC,KAAK,EAAE,KAAK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CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE/B,oBAAoB;QACpB,IAAI,QAAQ,CAAC,MAAM,KAAK,YAAY,IAAI,QAAQ,CAAC,kBAAkB,EAAE,MAAM,KAAK,mBAAmB;YAC/F,MAAM,IAAI,eAAe,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5E,IAAI,QAAQ,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC,CAAA,CAAC;;YAClC,MAAM,IAAI,eAAe,CAAC,0BAA0B,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChF,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA,CAAC;;YAAM,MAAM,IAAI,KAAK,EAAE,CAAC;QAC9C,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QAEtD,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAClE,CAAC;CACJ"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CompatibleEngine } from '../compatible-engine.ts';
|
|
2
|
+
import { Function } from '../function.ts';
|
|
3
|
+
import { ToolCodec } from '../api-types/openai-responses/tool-codec.ts';
|
|
4
|
+
import { Billing } from '../api-types/openai-responses/billing.ts';
|
|
5
|
+
import { Validator } from '../compatible-engine/validation.ts';
|
|
6
|
+
import * as MessageCodecModule from './openai-responses/message-codec.ts';
|
|
7
|
+
import * as TransportModule from './openai-responses/transport.ts';
|
|
8
|
+
import type { Verbatim } from '../verbatim.ts';
|
|
9
|
+
import * as ChoiceCodecModule from './openai-responses/choice-codec.ts';
|
|
10
|
+
export type OpenAIResponsesCompatibleEngine<fdm extends Function.Decl.Map.Proto, vdm extends Verbatim.Decl.Map.Proto> = OpenAIResponsesCompatibleEngine.Instance<fdm, vdm>;
|
|
11
|
+
export declare namespace OpenAIResponsesCompatibleEngine {
|
|
12
|
+
class Instance<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> extends CompatibleEngine.Instance<fdm, vdm> {
|
|
13
|
+
protected toolCodec: ToolCodec<fdm>;
|
|
14
|
+
protected messageCodec: OpenAIResponsesCompatibleEngine.MessageCodec<fdm, vdm>;
|
|
15
|
+
protected billing: Billing;
|
|
16
|
+
protected validator: Validator.From<fdm, vdm>;
|
|
17
|
+
protected transport: OpenAIResponsesCompatibleEngine.Transport<fdm, vdm>;
|
|
18
|
+
protected parallelToolCall: boolean;
|
|
19
|
+
constructor(options: OpenAIResponsesCompatibleEngine.Options<fdm, vdm>);
|
|
20
|
+
}
|
|
21
|
+
interface Options<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> extends CompatibleEngine.Options<fdm, vdm> {
|
|
22
|
+
}
|
|
23
|
+
export import MessageCodec = MessageCodecModule.MessageCodec;
|
|
24
|
+
export import Transport = TransportModule.Transport;
|
|
25
|
+
export import ChoiceCodec = ChoiceCodecModule;
|
|
26
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { CompatibleEngine } from "../compatible-engine.js";
|
|
2
|
+
import { ToolCodec } from "../api-types/openai-responses/tool-codec.js";
|
|
3
|
+
import { Billing } from "../api-types/openai-responses/billing.js";
|
|
4
|
+
import { Validator } from "../compatible-engine/validation.js";
|
|
5
|
+
import * as MessageCodecModule from "./openai-responses/message-codec.js";
|
|
6
|
+
import * as TransportModule from "./openai-responses/transport.js";
|
|
7
|
+
import * as ChoiceCodecModule from "./openai-responses/choice-codec.js";
|
|
8
|
+
export var OpenAIResponsesCompatibleEngine;
|
|
9
|
+
(function (OpenAIResponsesCompatibleEngine) {
|
|
10
|
+
class Instance extends CompatibleEngine.Instance {
|
|
11
|
+
toolCodec;
|
|
12
|
+
messageCodec;
|
|
13
|
+
billing;
|
|
14
|
+
validator;
|
|
15
|
+
transport;
|
|
16
|
+
parallelToolCall;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
super(options);
|
|
19
|
+
this.parallelToolCall = options.parallelToolCall ?? false;
|
|
20
|
+
this.toolCodec = new ToolCodec({ fdm: this.fdm });
|
|
21
|
+
this.messageCodec = new OpenAIResponsesCompatibleEngine.MessageCodec({
|
|
22
|
+
toolCodec: this.toolCodec,
|
|
23
|
+
vdm: this.vdm,
|
|
24
|
+
});
|
|
25
|
+
this.billing = new Billing({ pricing: this.pricing });
|
|
26
|
+
this.validator = new Validator({ choice: this.choice });
|
|
27
|
+
this.transport = new OpenAIResponsesCompatibleEngine.Transport({
|
|
28
|
+
inferenceSpec: this.inferenceParams,
|
|
29
|
+
providerSpec: this.providerSpec,
|
|
30
|
+
fdm: this.fdm,
|
|
31
|
+
throttle: this.throttle,
|
|
32
|
+
choice: this.choice,
|
|
33
|
+
parallelToolCall: this.parallelToolCall,
|
|
34
|
+
messageCodec: this.messageCodec,
|
|
35
|
+
toolCodec: this.toolCodec,
|
|
36
|
+
billing: this.billing,
|
|
37
|
+
validator: this.validator,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
OpenAIResponsesCompatibleEngine.Instance = Instance;
|
|
42
|
+
OpenAIResponsesCompatibleEngine.MessageCodec = MessageCodecModule.MessageCodec;
|
|
43
|
+
OpenAIResponsesCompatibleEngine.Transport = TransportModule.Transport;
|
|
44
|
+
OpenAIResponsesCompatibleEngine.ChoiceCodec = ChoiceCodecModule;
|
|
45
|
+
})(OpenAIResponsesCompatibleEngine || (OpenAIResponsesCompatibleEngine = {}));
|
|
46
|
+
//# sourceMappingURL=openai-responses.js.map
|
|
@@ -0,0 +1 @@
|
|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,EAAE,CAAC,CAAC;YACxD,IAAI,CAAC,SAAS,GAAG,IAAI,+BAA+B,CAAC,SAAS,CAAC;gBAC3D,aAAa,EAAE,IAAI,CAAC,eAAe;gBACnC,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;gBACvC,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,SAAS,EAAE,IAAI,CAAC,SAAS;aAC5B,CAAC,CAAC;QACP,CAAC;KAEJ;IAnCY,wCAAQ,WAmCpB,CAAA;IAOa,4CAAY,GAAG,kBAAkB,CAAC,YAAY,CAAC;IAC/C,yCAAS,GAAG,eAAe,CAAC,SAAS,CAAC;IACtC,2CAAW,GAAG,iBAAiB,CAAC;AAClD,CAAC,EA9CgB,+BAA+B,KAA/B,+BAA+B,QA8C/C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Function } from './function.ts';
|
|
2
|
+
import { Engine } from './engine.ts';
|
|
3
|
+
import type { Verbatim } from './verbatim.ts';
|
|
4
|
+
import * as StructuringModule from './compatible-engine/structuring.ts';
|
|
5
|
+
import * as ValidationModule from './compatible-engine/validation.ts';
|
|
6
|
+
import * as SessionModule from './compatible-engine/session.ts';
|
|
7
|
+
export type CompatibleEngine<fdm extends Function.Decl.Map.Proto, vdm extends Verbatim.Decl.Map.Proto> = CompatibleEngine.Instance<fdm, vdm>;
|
|
8
|
+
export declare namespace CompatibleEngine {
|
|
9
|
+
abstract class Instance<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> extends Engine.Instance<fdm, vdm, CompatibleEngine.RoleMessage.User.From<fdm>, CompatibleEngine.RoleMessage.Ai.From<fdm, vdm>, CompatibleEngine.RoleMessage.Developer, CompatibleEngine.Session.From<fdm, vdm>> {
|
|
10
|
+
protected choice: CompatibleEngine.Structuring.Choice.From<fdm, vdm>;
|
|
11
|
+
constructor(options: CompatibleEngine.Options<fdm, vdm>);
|
|
12
|
+
appendUserMessage(session: CompatibleEngine.Session.From<fdm, vdm>, message: CompatibleEngine.RoleMessage.User.From<fdm>): CompatibleEngine.Session.From<fdm, vdm>;
|
|
13
|
+
pushUserMessage(session: CompatibleEngine.Session.From<fdm, vdm>, message: CompatibleEngine.RoleMessage.User.From<fdm>): CompatibleEngine.Session.From<fdm, vdm>;
|
|
14
|
+
}
|
|
15
|
+
interface Options<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> extends Engine.Options<fdm, vdm> {
|
|
16
|
+
structuringChoice?: CompatibleEngine.Structuring.Choice.From<fdm, vdm>;
|
|
17
|
+
}
|
|
18
|
+
export import Session = SessionModule.Session;
|
|
19
|
+
export import RoleMessage = SessionModule.RoleMessage;
|
|
20
|
+
export import Validator = ValidationModule.Validator;
|
|
21
|
+
export import Structuring = StructuringModule.Structuring;
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Engine } from "./engine.js";
|
|
2
|
+
import * as StructuringModule from "./compatible-engine/structuring.js";
|
|
3
|
+
import * as ValidationModule from "./compatible-engine/validation.js";
|
|
4
|
+
import * as SessionModule from "./compatible-engine/session.js";
|
|
5
|
+
export var CompatibleEngine;
|
|
6
|
+
(function (CompatibleEngine) {
|
|
7
|
+
class Instance extends Engine.Instance {
|
|
8
|
+
choice;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
super(options);
|
|
11
|
+
this.choice = options.structuringChoice ?? CompatibleEngine.Structuring.Choice.AUTO;
|
|
12
|
+
}
|
|
13
|
+
appendUserMessage(session, message) {
|
|
14
|
+
return {
|
|
15
|
+
developerMessage: session.developerMessage,
|
|
16
|
+
chatMessages: [...session.chatMessages, message],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
pushUserMessage(session, message) {
|
|
20
|
+
session.chatMessages.push(message);
|
|
21
|
+
return session;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
CompatibleEngine.Instance = Instance;
|
|
25
|
+
CompatibleEngine.RoleMessage = SessionModule.RoleMessage;
|
|
26
|
+
CompatibleEngine.Validator = ValidationModule.Validator;
|
|
27
|
+
CompatibleEngine.Structuring = StructuringModule.Structuring;
|
|
28
|
+
})(CompatibleEngine || (CompatibleEngine = {}));
|
|
29
|
+
//# sourceMappingURL=compatible-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatible-engine.js","sourceRoot":"","sources":["../src/compatible-engine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,iBAAiB,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,gBAAgB,MAAM,mCAAmC,CAAC;AACtE,OAAO,KAAK,aAAa,MAAM,gCAAgC,CAAC;AAQhE,MAAM,KAAW,gBAAgB,CAgDhC;AAhDD,WAAiB,gBAAgB;IAC7B,MAAsB,QAGpB,SAAQ,MAAM,CAAC,QAMhB;QACa,MAAM,CAAqD;QAErE,YAAmB,OAA2C;YAC1D,KAAK,CAAC,OAAO,CAAC,CAAC;YACf,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,iBAAiB,IAAI,gBAAgB,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;QACxF,CAAC;QAEe,iBAAiB,CAC7B,OAAgD,EAChD,OAAoD;YAEpD,OAAO;gBACH,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;gBAC1C,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC;aACnD,CAAC;QACN,CAAC;QAEe,eAAe,CAC3B,OAAgD,EAChD,OAAoD;YAEpD,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACnC,OAAO,OAAO,CAAC;QACnB,CAAC;KACJ;IAlCqB,yBAAQ,WAkC7B,CAAA;IAUa,4BAAW,GAAG,aAAa,CAAC,WAAW,CAAC;IACxC,0BAAS,GAAG,gBAAgB,CAAC,SAAS,CAAC;IACvC,4BAAW,GAAG,iBAAiB,CAAC,WAAW,CAAC;AAC9D,CAAC,EAhDgB,gBAAgB,KAAhB,gBAAgB,QAgDhC"}
|
package/build/config.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare namespace Config {
|
|
|
13
13
|
inputPrice: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
14
14
|
outputPrice: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
15
15
|
cachePrice: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
16
|
+
parallelToolCall: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
16
17
|
additionalOptions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TAny>>;
|
|
17
18
|
rpm: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
18
19
|
timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
package/build/config.js
CHANGED
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKlD,MAAM,KAAW,MAAM,CAMtB;AAND,WAAiB,MAAM;IACN,aAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC9B,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC;YACrB,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,YAAY,CAAC,MAAM,CAAC;SAC7D,CAAC;KACL,CAAC,CAAC;AACP,CAAC,EANgB,MAAM,KAAN,MAAM,QAMtB"}
|
package/build/endpoint-spec.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare namespace EndpointSpec {
|
|
|
11
11
|
inputPrice: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
12
12
|
outputPrice: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
13
13
|
cachePrice: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
14
|
+
parallelToolCall: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
14
15
|
additionalOptions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TAny>>;
|
|
15
16
|
rpm: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
16
17
|
timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
package/build/endpoint-spec.js
CHANGED
|
@@ -16,8 +16,9 @@ export var EndpointSpec;
|
|
|
16
16
|
inputPrice: Type.Optional(Type.Number()),
|
|
17
17
|
outputPrice: Type.Optional(Type.Number()),
|
|
18
18
|
cachePrice: Type.Optional(Type.Number()),
|
|
19
|
+
parallelToolCall: Type.Optional(Type.Boolean()),
|
|
19
20
|
additionalOptions: Type.Optional(Type.Record(Type.String(), Type.Any())),
|
|
20
|
-
rpm: Type.Optional(Type.Number({ minimum:
|
|
21
|
+
rpm: Type.Optional(Type.Number({ minimum: 1 })),
|
|
21
22
|
timeout: Type.Optional(Type.Number({ minimum: 0 })),
|
|
22
23
|
maxTokens: Type.Optional(Type.Number({ minimum: 0 })),
|
|
23
24
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-spec.js","sourceRoot":"","sources":["../src/endpoint-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AAItD,MAAM,KAAW,YAAY,
|
|
1
|
+
{"version":3,"file":"endpoint-spec.js","sourceRoot":"","sources":["../src/endpoint-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AAItD,MAAM,KAAW,YAAY,CAsB5B;AAtBD,WAAiB,YAAY;IACZ,mBAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC9B,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE;QACtB,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACnC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;QACrB,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE;QACpB,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;QACnB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;YAChC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;YACtB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;YACtB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;SAC5B,CAAC;QACF,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACxC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACzC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACxC,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAC/C,iBAAiB,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACxE,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;QAC/C,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;QACnD,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;KACxD,CAAC,CAAC;AACP,CAAC,EAtBgB,YAAY,KAAZ,YAAY,QAsB5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/engine/session.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type InferenceContext } from '../inference-context.ts';
|
|
2
|
+
import type { Session } from './session.ts';
|
|
3
|
+
export interface Transport<userm, aim, devm, session extends Session<userm, aim, devm>> {
|
|
4
|
+
fetch(wfctx: InferenceContext, session: session, signal?: AbortSignal): Promise<aim>;
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/engine/transport.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Function } from '../function.ts';
|
|
2
|
+
import type { Verbatim } from '../verbatim.ts';
|
|
3
|
+
export interface Validator<fdu extends Function.Decl.Proto, vdu extends Verbatim.Decl.Proto, aim> {
|
|
4
|
+
validateChoice(message: aim): void;
|
|
5
|
+
validateParts(message: aim): void;
|
|
6
|
+
}
|
|
7
|
+
export declare namespace Validator {
|
|
8
|
+
type From<fdm extends Function.Decl.Map.Proto, vdm extends Verbatim.Decl.Map.Proto, aim> = Validator<Function.Decl.From<fdm>, Verbatim.Decl.From<vdm>, aim>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/engine/validation.ts"],"names":[],"mappings":""}
|