@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
package/build/function.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
const NOMINAL = Symbol();
|
|
2
2
|
export var Function;
|
|
3
3
|
(function (Function) {
|
|
4
4
|
class Call {
|
|
5
|
-
static NOMINAL = Symbol();
|
|
6
5
|
id;
|
|
7
6
|
name;
|
|
8
7
|
args;
|
|
@@ -11,62 +10,46 @@ export var Function;
|
|
|
11
10
|
this.name = fc.name;
|
|
12
11
|
this.args = fc.args;
|
|
13
12
|
}
|
|
14
|
-
static
|
|
15
|
-
return new Call(fc);
|
|
16
|
-
}
|
|
17
|
-
static restore(snapshot) {
|
|
18
|
-
return new Call(snapshot);
|
|
19
|
-
}
|
|
20
|
-
static capture(fc) {
|
|
21
|
-
return fc;
|
|
13
|
+
static of(fc) {
|
|
14
|
+
return new Function.Call(fc);
|
|
22
15
|
}
|
|
23
16
|
}
|
|
24
17
|
Function.Call = Call;
|
|
25
|
-
(function (Call) {
|
|
26
|
-
function validate(toolCalls, toolChoice, e) {
|
|
27
|
-
if (toolChoice === Function.ToolChoice.REQUIRED)
|
|
28
|
-
if (toolCalls.length) { }
|
|
29
|
-
else
|
|
30
|
-
throw e;
|
|
31
|
-
else if (toolChoice instanceof Array)
|
|
32
|
-
for (const fc of toolCalls) {
|
|
33
|
-
if (toolChoice.includes(fc.name)) { }
|
|
34
|
-
else
|
|
35
|
-
throw e;
|
|
36
|
-
}
|
|
37
|
-
else if (toolChoice === Function.ToolChoice.NONE)
|
|
38
|
-
if (!toolCalls.length) { }
|
|
39
|
-
else
|
|
40
|
-
throw e;
|
|
41
|
-
}
|
|
42
|
-
Call.validate = validate;
|
|
43
|
-
})(Call = Function.Call || (Function.Call = {}));
|
|
44
18
|
class Response {
|
|
45
|
-
static NOMINAL = Symbol();
|
|
46
19
|
id;
|
|
47
20
|
name;
|
|
48
|
-
text;
|
|
49
21
|
constructor(fr) {
|
|
50
22
|
this.id = fr.id;
|
|
51
23
|
this.name = fr.name;
|
|
52
|
-
this.text = fr.text;
|
|
53
|
-
}
|
|
54
|
-
static create(fr) {
|
|
55
|
-
return new Response(fr);
|
|
56
|
-
}
|
|
57
|
-
static capture(response) {
|
|
58
|
-
return response;
|
|
59
|
-
}
|
|
60
|
-
static restore(snapshot) {
|
|
61
|
-
return new Response(snapshot);
|
|
62
24
|
}
|
|
63
25
|
}
|
|
64
26
|
Function.Response = Response;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
27
|
+
(function (Response) {
|
|
28
|
+
class Successful extends Function.Response {
|
|
29
|
+
text;
|
|
30
|
+
constructor(fr) {
|
|
31
|
+
super(fr);
|
|
32
|
+
this.text = fr.text;
|
|
33
|
+
}
|
|
34
|
+
static of(fr) {
|
|
35
|
+
return new Function.Response.Successful(fr);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
Response.Successful = Successful;
|
|
39
|
+
class Failed extends Function.Response {
|
|
40
|
+
error;
|
|
41
|
+
constructor(fr) {
|
|
42
|
+
super(fr);
|
|
43
|
+
this.error = fr.error;
|
|
44
|
+
}
|
|
45
|
+
static of(fr) {
|
|
46
|
+
return new Function.Response.Failed(fr);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
Response.Failed = Failed;
|
|
50
|
+
})(Response = Function.Response || (Function.Response = {}));
|
|
51
|
+
class Error extends globalThis.Error {
|
|
52
|
+
}
|
|
53
|
+
Function.Error = Error;
|
|
71
54
|
})(Function || (Function = {}));
|
|
72
55
|
//# sourceMappingURL=function.js.map
|
package/build/function.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.js","sourceRoot":"","sources":["../src/function.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../src/function.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;AAMzB,MAAM,KAAW,QAAQ,CA6MxB;AA7MD,WAAiB,QAAQ;IAkFrB,MAAa,IAAI;QAEN,EAAE,CAAU;QACZ,IAAI,CAAa;QACjB,IAAI,CAA2B;QACtC,YAAsB,EAAyB;YAC3C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;YAChB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;YACpB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;QACxB,CAAC;QACM,MAAM,CAAC,EAAE,CACZ,EAAiC;YAEjC,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAA0B,CAAC;QAC1D,CAAC;KAEJ;IAhBY,aAAI,OAgBhB,CAAA;IAqBD,MAAsB,QAAQ;QACnB,EAAE,CAAU;QACZ,IAAI,CAAa;QACxB,YAAsB,EAAsC;YACxD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;YAChB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;QACxB,CAAC;KACJ;IAPqB,iBAAQ,WAO7B,CAAA;IACD,WAAiB,QAAQ;QAQrB,MAAa,UAAkD,SAAQ,QAAQ,CAAC,QAAY;YAEjF,IAAI,CAAS;YACpB,YAAsB,EAA4C;gBAC9D,KAAK,CAAC,EAAE,CAAC,CAAC;gBACV,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;YACxB,CAAC;YACM,MAAM,CAAC,EAAE,CACZ,EAAgD;gBAEhD,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAyC,CAAC;YACxF,CAAC;SACJ;QAZY,mBAAU,aAYtB,CAAA;QAoBD,MAAa,MAA8C,SAAQ,QAAQ,CAAC,QAAY;YAE7E,KAAK,CAAS;YACrB,YAAsB,EAAwC;gBAC1D,KAAK,CAAC,EAAE,CAAC,CAAC;gBACV,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC;YAC1B,CAAC;YACM,MAAM,CAAC,EAAE,CACZ,EAA4C;gBAE5C,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAqC,CAAC;YAChF,CAAC;SACJ;QAZY,eAAM,SAYlB,CAAA;IAmBL,CAAC,EAvEgB,QAAQ,GAAR,iBAAQ,KAAR,iBAAQ,QAuExB;IAMD,MAAa,KAAM,SAAQ,UAAU,CAAC,KAAK;KAAG;IAAjC,cAAK,QAA4B,CAAA;AAClD,CAAC,EA7MgB,QAAQ,KAAR,QAAQ,QA6MxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inference-context.js","sourceRoot":"","sources":["../src/inference-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inference-context.js","sourceRoot":"","sources":["../src/inference-context.ts"],"names":[],"mappings":""}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { RoleMessage, type Session } from '
|
|
2
|
-
import { Function } from '
|
|
1
|
+
import { RoleMessage, type Session } from './session.ts';
|
|
2
|
+
import { Function } from '../../function.ts';
|
|
3
3
|
import * as Google from '@google/genai';
|
|
4
|
-
import {
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
import { MessageCodec as CompatibleMessageCodec } from '../../compatible-engine.d/google/message-codec.ts';
|
|
5
|
+
import type { ToolCodec } from '../../api-types/google/tool-codec.ts';
|
|
6
|
+
import { Verbatim } from '../../verbatim.ts';
|
|
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
|
+
encodeAiMessage(aiMessage: RoleMessage.Ai.From<fdm, vdm>): Google.Content;
|
|
11
|
+
encodeUserMessage(userMessage: RoleMessage.User.From<fdm>): Google.Content;
|
|
12
|
+
encodeDeveloperMessage(developerMessage: RoleMessage.Developer): Google.Content;
|
|
13
|
+
encodeChatMessages(chatMessages: Session.ChatMessage.From<fdm, vdm>[]): Google.Content[];
|
|
14
|
+
decodeAiMessage(content: Google.Content): RoleMessage.Ai.From<fdm, vdm>;
|
|
14
15
|
}
|
|
15
|
-
export declare namespace
|
|
16
|
-
interface Context<fdm extends Function.
|
|
17
|
-
toolCodec:
|
|
18
|
-
compatibleMessageCodec:
|
|
16
|
+
export declare namespace MessageCodec {
|
|
17
|
+
interface Context<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> {
|
|
18
|
+
toolCodec: ToolCodec<fdm>;
|
|
19
|
+
compatibleMessageCodec: CompatibleMessageCodec<fdm, vdm>;
|
|
19
20
|
codeExecution: boolean;
|
|
21
|
+
vdm: vdm;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
@@ -1,69 +1,67 @@
|
|
|
1
|
-
import { ResponseInvalid } from
|
|
2
|
-
import { RoleMessage } from
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { GoogleCompatibleMessageCodec } from '#@/compatible.d/google/message-codec.ts';
|
|
6
|
-
export class GoogleNativeMessageCodec {
|
|
1
|
+
import { ResponseInvalid } from "../../engine.js";
|
|
2
|
+
import { RoleMessage } from "./session.js";
|
|
3
|
+
import * as VerbatimCodec from "../../verbatim/codec.js";
|
|
4
|
+
export class MessageCodec {
|
|
7
5
|
ctx;
|
|
8
6
|
constructor(ctx) {
|
|
9
7
|
this.ctx = ctx;
|
|
10
8
|
}
|
|
11
|
-
|
|
9
|
+
encodeAiMessage(aiMessage) {
|
|
12
10
|
return aiMessage.getRaw();
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
return this.ctx.compatibleMessageCodec.
|
|
12
|
+
encodeUserMessage(userMessage) {
|
|
13
|
+
return this.ctx.compatibleMessageCodec.encodeUserMessage(userMessage);
|
|
16
14
|
}
|
|
17
|
-
|
|
18
|
-
return this.ctx.compatibleMessageCodec.
|
|
15
|
+
encodeDeveloperMessage(developerMessage) {
|
|
16
|
+
return this.ctx.compatibleMessageCodec.encodeDeveloperMessage(developerMessage);
|
|
19
17
|
}
|
|
20
|
-
|
|
18
|
+
encodeChatMessages(chatMessages) {
|
|
21
19
|
return chatMessages.map(chatMessage => {
|
|
22
|
-
if (chatMessage instanceof RoleMessage.User
|
|
23
|
-
return this.
|
|
24
|
-
else if (chatMessage instanceof RoleMessage.Ai
|
|
25
|
-
return this.
|
|
20
|
+
if (chatMessage instanceof RoleMessage.User)
|
|
21
|
+
return this.encodeUserMessage(chatMessage);
|
|
22
|
+
else if (chatMessage instanceof RoleMessage.Ai)
|
|
23
|
+
return this.encodeAiMessage(chatMessage);
|
|
26
24
|
else
|
|
27
25
|
throw new Error();
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
|
-
|
|
28
|
+
decodeAiMessage(content) {
|
|
31
29
|
if (content.parts) { }
|
|
32
30
|
else
|
|
33
31
|
throw new Error();
|
|
34
|
-
|
|
32
|
+
const parts = content.parts.flatMap(part => {
|
|
35
33
|
const parts = [];
|
|
36
|
-
let payload = false;
|
|
37
34
|
if (part.text) {
|
|
38
|
-
|
|
39
|
-
parts.push(RoleMessage.Part.Text
|
|
35
|
+
const vrs = VerbatimCodec.Request.decode(part.text, this.ctx.vdm);
|
|
36
|
+
parts.push(new RoleMessage.Part.Text(part.text, vrs));
|
|
40
37
|
}
|
|
41
38
|
if (part.functionCall) {
|
|
42
|
-
|
|
43
|
-
parts.push(this.ctx.toolCodec.convertToFunctionCall(part.functionCall));
|
|
39
|
+
parts.push(this.ctx.toolCodec.decodeFunctionCall(part.functionCall));
|
|
44
40
|
}
|
|
45
|
-
if (
|
|
46
|
-
|
|
41
|
+
if (part.executableCode) {
|
|
42
|
+
if (this.ctx.codeExecution) { }
|
|
43
|
+
else
|
|
44
|
+
throw new ResponseInvalid('Unexpected code execution', { cause: content });
|
|
47
45
|
if (part.executableCode.code) { }
|
|
48
46
|
else
|
|
49
47
|
throw new Error();
|
|
50
48
|
if (part.executableCode.language) { }
|
|
51
49
|
else
|
|
52
50
|
throw new Error();
|
|
53
|
-
parts.push(RoleMessage.Ai.Part.ExecutableCode
|
|
51
|
+
parts.push(new RoleMessage.Ai.Part.ExecutableCode(part.executableCode.code, part.executableCode.language));
|
|
54
52
|
}
|
|
55
|
-
if (
|
|
56
|
-
|
|
53
|
+
if (part.codeExecutionResult) {
|
|
54
|
+
if (this.ctx.codeExecution) { }
|
|
55
|
+
else
|
|
56
|
+
throw new ResponseInvalid('Unexpected code execution result', { cause: content });
|
|
57
57
|
if (part.codeExecutionResult.outcome) { }
|
|
58
58
|
else
|
|
59
59
|
throw new Error();
|
|
60
|
-
parts.push(RoleMessage.Ai.Part.CodeExecutionResult
|
|
60
|
+
parts.push(new RoleMessage.Ai.Part.CodeExecutionResult(part.codeExecutionResult.outcome, part.codeExecutionResult.output));
|
|
61
61
|
}
|
|
62
|
-
if (payload) { }
|
|
63
|
-
else
|
|
64
|
-
throw new ResponseInvalid('Unknown content part', { cause: content });
|
|
65
62
|
return parts;
|
|
66
|
-
})
|
|
63
|
+
});
|
|
64
|
+
return new RoleMessage.Ai(parts, content);
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
67
|
//# sourceMappingURL=message-codec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-codec.js","sourceRoot":"","sources":["../../../src/native-engines.d/google/message-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"message-codec.js","sourceRoot":"","sources":["../../../src/native-engines.d/google/message-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAgB,MAAM,cAAc,CAAC;AAMzD,OAAO,KAAK,aAAa,MAAM,yBAAyB,CAAC;AAIzD,MAAM,OAAO,YAAY;IAIQ;IAA7B,YAA6B,GAAmC;QAAnC,QAAG,GAAH,GAAG,CAAgC;IAAG,CAAC;IAG7D,eAAe,CAClB,SAAwC;QAExC,OAAO,SAAS,CAAC,MAAM,EAAE,CAAC;IAC9B,CAAC;IAEM,iBAAiB,CACpB,WAAuC;QAEvC,OAAO,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAC1E,CAAC;IAEM,sBAAsB,CACzB,gBAAuC;QAEvC,OAAO,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;IACpF,CAAC;IAEM,kBAAkB,CACrB,YAAkD;QAElD,OAAO,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YAClC,IAAI,WAAW,YAAY,WAAW,CAAC,IAAI;gBAAE,OAAO,IA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ACxD,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAA,CAAC;;oBAAM,MAAM,IAAI,KAAK,EAAE,CAAC;gBAC5D,KAAK,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC/G,CAAC;YACD,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBAC3B,IAAI,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,CAAA,CAAC;;oBAAM,MAAM,IAAI,eAAe,CAAC,kCAAkC,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;gBACtH,IAAI,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC,CAAA,CAAC;;oBAAM,MAAM,IAAI,KAAK,EAAE,CAAC;gBAChE,KAAK,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;YAC/H,CAAC;YACD,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACJ"}
|
|
@@ -1,65 +1,58 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Function } from '
|
|
1
|
+
import { RoleMessage as CompatibleRoleMessage } from '../../compatible-engine/session.ts';
|
|
2
|
+
import { Function } from '../../function.ts';
|
|
3
3
|
import * as Google from '@google/genai';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
4
|
+
import type { Engine } from '../../engine.ts';
|
|
5
|
+
import { Verbatim } from '../../verbatim.ts';
|
|
6
|
+
declare const NOMINAL: unique symbol;
|
|
7
|
+
export interface Session<in out fdu extends Function.Decl.Proto, in out vdu extends Verbatim.Decl.Proto> extends Engine.Session<RoleMessage.User<fdu>, RoleMessage.Ai<fdu, vdu>, RoleMessage.Developer> {
|
|
6
8
|
}
|
|
7
9
|
export declare namespace Session {
|
|
8
|
-
type
|
|
10
|
+
type From<fdm extends Function.Decl.Map.Proto, vdm extends Verbatim.Decl.Map.Proto> = Session<Function.Decl.From<fdm>, Verbatim.Decl.From<vdm>>;
|
|
11
|
+
type ChatMessage<fdu extends Function.Decl.Proto, vdu extends Verbatim.Decl.Proto> = Engine.Session.ChatMessage<RoleMessage.User<fdu>, RoleMessage.Ai<fdu, vdu>>;
|
|
12
|
+
namespace ChatMessage {
|
|
13
|
+
type From<fdm extends Function.Decl.Map.Proto, vdm extends Verbatim.Decl.Map.Proto> = ChatMessage<Function.Decl.From<fdm>, Verbatim.Decl.From<vdm>>;
|
|
14
|
+
}
|
|
9
15
|
}
|
|
10
|
-
export type RoleMessage = RoleMessage.Instance;
|
|
11
16
|
export declare namespace RoleMessage {
|
|
12
|
-
abstract class Instance {
|
|
13
|
-
static readonly ROLE_MESSAGE_NOMINAL: unique symbol;
|
|
14
|
-
private readonly [Instance.ROLE_MESSAGE_NOMINAL];
|
|
15
|
-
abstract getText(): string;
|
|
16
|
-
abstract getOnlyText(): string;
|
|
17
|
-
}
|
|
18
17
|
namespace Part {
|
|
19
|
-
export import Text =
|
|
18
|
+
export import Text = CompatibleRoleMessage.Part.Text;
|
|
19
|
+
}
|
|
20
|
+
class Ai<in out fdu extends Function.Decl.Proto, in out vdu extends Verbatim.Decl.Proto> {
|
|
21
|
+
protected parts: RoleMessage.Ai.Part<fdu, vdu>[];
|
|
22
|
+
protected raw: Google.Content;
|
|
23
|
+
protected [NOMINAL]: never;
|
|
24
|
+
constructor(parts: RoleMessage.Ai.Part<fdu, vdu>[], raw: Google.Content);
|
|
25
|
+
getParts(): RoleMessage.Ai.Part<fdu, vdu>[];
|
|
26
|
+
getRaw(): Google.Content;
|
|
27
|
+
allChatPart(): boolean;
|
|
28
|
+
getChatParts(): RoleMessage.Ai.Part<fdu, vdu>[];
|
|
29
|
+
static encodeChatPart<fdu extends Function.Decl.Proto, vdu extends Verbatim.Decl.Proto>(part: RoleMessage.Ai.Part<fdu, vdu>): string;
|
|
30
|
+
getChatText(): string;
|
|
31
|
+
getFunctionCalls(): Function.Call.Of<fdu>[];
|
|
32
|
+
getVerbatimRequests(): Verbatim.Request.Of<vdu>[];
|
|
33
|
+
getOnlyFunctionCall(): Function.Call.Of<fdu>;
|
|
34
|
+
getOnlyVerbatimRequest(): Verbatim.Request.Of<vdu>;
|
|
20
35
|
}
|
|
21
|
-
type Ai<fdm extends Function.Declaration.Map> = Ai.Instance<fdm>;
|
|
22
36
|
namespace Ai {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class Instance<in out fdm extends Function.Declaration.Map> extends RoleMessage.Instance {
|
|
26
|
-
protected parts: RoleMessage.Ai.Part<fdm>[];
|
|
27
|
-
protected raw: Google.Content;
|
|
28
|
-
readonly [NOMINAL]: void;
|
|
29
|
-
constructor(parts: RoleMessage.Ai.Part<fdm>[], raw: Google.Content);
|
|
30
|
-
getParts(): RoleMessage.Ai.Part<fdm>[];
|
|
31
|
-
getRaw(): Google.Content;
|
|
32
|
-
getText(): string;
|
|
33
|
-
getOnlyText(): string;
|
|
34
|
-
getOnlyFunctionCall(): Function.Call.From<fdm>;
|
|
35
|
-
getFunctionCalls(): Function.Call.From<fdm>[];
|
|
36
|
-
}
|
|
37
|
-
type Part<fdm extends Function.Declaration.Map> = RoleMessage.Part.Text | Function.Call.From<fdm> | RoleMessage.Ai.Part.ExecutableCode | RoleMessage.Ai.Part.CodeExecutionResult;
|
|
37
|
+
type From<fdm extends Function.Decl.Map.Proto, vdm extends Verbatim.Decl.Map.Proto> = Ai<Function.Decl.From<fdm>, Verbatim.Decl.From<vdm>>;
|
|
38
|
+
type Part<fdu extends Function.Decl.Proto, vdu extends Verbatim.Decl.Proto> = RoleMessage.Part.Text<vdu> | Function.Call.Of<fdu> | RoleMessage.Ai.Part.ExecutableCode | RoleMessage.Ai.Part.CodeExecutionResult;
|
|
38
39
|
namespace Part {
|
|
39
|
-
type
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
private readonly [NOMINAL];
|
|
46
|
-
constructor(code: string, language: string);
|
|
47
|
-
}
|
|
48
|
-
function create(code: string, language: string): Instance;
|
|
40
|
+
type From<fdm extends Function.Decl.Map.Proto, vdm extends Verbatim.Decl.Map.Proto> = Part<Function.Decl.From<fdm>, Verbatim.Decl.From<vdm>>;
|
|
41
|
+
class ExecutableCode {
|
|
42
|
+
code: string;
|
|
43
|
+
language: string;
|
|
44
|
+
protected [NOMINAL]: never;
|
|
45
|
+
constructor(code: string, language: string);
|
|
49
46
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
output?: string | undefined;
|
|
56
|
-
private readonly [NOMINAL];
|
|
57
|
-
constructor(outcome: string, output?: string | undefined);
|
|
58
|
-
}
|
|
59
|
-
function create(outcome: string, output?: string): Instance;
|
|
47
|
+
class CodeExecutionResult {
|
|
48
|
+
outcome: string;
|
|
49
|
+
output?: string | undefined;
|
|
50
|
+
protected [NOMINAL]: never;
|
|
51
|
+
constructor(outcome: string, output?: string | undefined);
|
|
60
52
|
}
|
|
61
53
|
}
|
|
62
54
|
}
|
|
63
|
-
export import User =
|
|
64
|
-
export import Developer =
|
|
55
|
+
export import User = CompatibleRoleMessage.User;
|
|
56
|
+
export import Developer = CompatibleRoleMessage.Developer;
|
|
65
57
|
}
|
|
58
|
+
export {};
|
|
@@ -1,97 +1,101 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Function } from
|
|
3
|
-
|
|
1
|
+
import { RoleMessage as CompatibleRoleMessage } from "../../compatible-engine/session.js";
|
|
2
|
+
import { Function } from "../../function.js";
|
|
3
|
+
const NOMINAL = Symbol();
|
|
4
4
|
export var RoleMessage;
|
|
5
5
|
(function (RoleMessage) {
|
|
6
|
-
class Instance {
|
|
7
|
-
static ROLE_MESSAGE_NOMINAL = Symbol();
|
|
8
|
-
}
|
|
9
|
-
RoleMessage.Instance = Instance;
|
|
10
6
|
let Part;
|
|
11
7
|
(function (Part) {
|
|
12
|
-
Part.Text =
|
|
8
|
+
Part.Text = CompatibleRoleMessage.Part.Text;
|
|
13
9
|
})(Part = RoleMessage.Part || (RoleMessage.Part = {}));
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
class Ai {
|
|
11
|
+
parts;
|
|
12
|
+
raw;
|
|
13
|
+
constructor(parts, raw) {
|
|
14
|
+
this.parts = parts;
|
|
15
|
+
this.raw = raw;
|
|
18
16
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
raw;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (fcs.length === 1) { }
|
|
47
|
-
else
|
|
48
|
-
throw new Error();
|
|
49
|
-
return fcs[0];
|
|
50
|
-
}
|
|
51
|
-
getFunctionCalls() {
|
|
52
|
-
return this.parts.filter(part => part instanceof Function.Call);
|
|
17
|
+
getParts() {
|
|
18
|
+
return this.parts;
|
|
19
|
+
}
|
|
20
|
+
getRaw() {
|
|
21
|
+
return this.raw;
|
|
22
|
+
}
|
|
23
|
+
allChatPart() {
|
|
24
|
+
return this.parts.every(part => part instanceof RoleMessage.Part.Text ||
|
|
25
|
+
part instanceof RoleMessage.Ai.Part.ExecutableCode ||
|
|
26
|
+
part instanceof RoleMessage.Ai.Part.CodeExecutionResult);
|
|
27
|
+
}
|
|
28
|
+
getChatParts() {
|
|
29
|
+
return this.parts.filter(part => part instanceof RoleMessage.Part.Text ||
|
|
30
|
+
part instanceof RoleMessage.Ai.Part.ExecutableCode ||
|
|
31
|
+
part instanceof RoleMessage.Ai.Part.CodeExecutionResult);
|
|
32
|
+
}
|
|
33
|
+
static encodeChatPart(part) {
|
|
34
|
+
if (part instanceof RoleMessage.Part.Text)
|
|
35
|
+
return part.text;
|
|
36
|
+
else if (part instanceof RoleMessage.Ai.Part.ExecutableCode)
|
|
37
|
+
return RoleMessage.Part.Text.paragraph('```' + part.language + '\n' + part.code + '\n```').text;
|
|
38
|
+
else if (part instanceof RoleMessage.Ai.Part.CodeExecutionResult) {
|
|
39
|
+
const textParts = [];
|
|
40
|
+
if (part.output)
|
|
41
|
+
textParts.push(RoleMessage.Part.Text.paragraph('```\n' + part.output + '\n```'));
|
|
42
|
+
textParts.push(RoleMessage.Part.Text.paragraph(part.outcome));
|
|
43
|
+
return textParts.map(part => part.text).join('');
|
|
53
44
|
}
|
|
45
|
+
else
|
|
46
|
+
throw new Error();
|
|
54
47
|
}
|
|
55
|
-
|
|
48
|
+
getChatText() {
|
|
49
|
+
return this.getChatParts().map(part => RoleMessage.Ai.encodeChatPart(part)).join('');
|
|
50
|
+
}
|
|
51
|
+
getFunctionCalls() {
|
|
52
|
+
return this.parts.filter(part => part instanceof Function.Call);
|
|
53
|
+
}
|
|
54
|
+
getVerbatimRequests() {
|
|
55
|
+
return this.parts
|
|
56
|
+
.filter(part => part instanceof RoleMessage.Part.Text)
|
|
57
|
+
.flatMap(part => part.vrs);
|
|
58
|
+
}
|
|
59
|
+
getOnlyFunctionCall() {
|
|
60
|
+
const fcs = this.getFunctionCalls();
|
|
61
|
+
if (fcs.length === 1) { }
|
|
62
|
+
else
|
|
63
|
+
throw new Error();
|
|
64
|
+
return fcs[0];
|
|
65
|
+
}
|
|
66
|
+
getOnlyVerbatimRequest() {
|
|
67
|
+
const vrs = this.getVerbatimRequests();
|
|
68
|
+
if (vrs.length === 1) { }
|
|
69
|
+
else
|
|
70
|
+
throw new Error();
|
|
71
|
+
return vrs[0];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
RoleMessage.Ai = Ai;
|
|
75
|
+
(function (Ai) {
|
|
56
76
|
let Part;
|
|
57
77
|
(function (Part) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
code;
|
|
63
|
-
language;
|
|
64
|
-
constructor(code, language) {
|
|
65
|
-
this.code = code;
|
|
66
|
-
this.language = language;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
ExecutableCode.Instance = Instance;
|
|
70
|
-
function create(code, language) {
|
|
71
|
-
return new Instance(code, language);
|
|
72
|
-
}
|
|
73
|
-
ExecutableCode.create = create;
|
|
74
|
-
})(ExecutableCode = Part.ExecutableCode || (Part.ExecutableCode = {}));
|
|
75
|
-
let CodeExecutionResult;
|
|
76
|
-
(function (CodeExecutionResult) {
|
|
77
|
-
CodeExecutionResult.NOMINAL = Symbol();
|
|
78
|
-
class Instance {
|
|
79
|
-
outcome;
|
|
80
|
-
output;
|
|
81
|
-
constructor(outcome, output) {
|
|
82
|
-
this.outcome = outcome;
|
|
83
|
-
this.output = output;
|
|
84
|
-
}
|
|
78
|
+
class ExecutableCode {
|
|
79
|
+
code;
|
|
80
|
+
language;
|
|
81
|
+
constructor(code, language) {
|
|
82
|
+
this.code = code;
|
|
83
|
+
this.language = language;
|
|
85
84
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
}
|
|
86
|
+
Part.ExecutableCode = ExecutableCode;
|
|
87
|
+
class CodeExecutionResult {
|
|
88
|
+
outcome;
|
|
89
|
+
output;
|
|
90
|
+
constructor(outcome, output) {
|
|
91
|
+
this.outcome = outcome;
|
|
92
|
+
this.output = output;
|
|
89
93
|
}
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
}
|
|
95
|
+
Part.CodeExecutionResult = CodeExecutionResult;
|
|
92
96
|
})(Part = Ai.Part || (Ai.Part = {}));
|
|
93
97
|
})(Ai = RoleMessage.Ai || (RoleMessage.Ai = {}));
|
|
94
|
-
RoleMessage.User =
|
|
95
|
-
RoleMessage.Developer =
|
|
98
|
+
RoleMessage.User = CompatibleRoleMessage.User;
|
|
99
|
+
RoleMessage.Developer = CompatibleRoleMessage.Developer;
|
|
96
100
|
})(RoleMessage || (RoleMessage = {}));
|
|
97
101
|
//# sourceMappingURL=session.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/native-engines.d/google/session.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/native-engines.d/google/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAK7C,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;AAkCzB,MAAM,KAAW,WAAW,CAoH3B;AApHD,WAAiB,WAAW;IACxB,IAAiB,IAAI,CAEpB;IAFD,WAAiB,IAAI;QACH,SAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;IACzD,CAAC,EAFgB,IAAI,GAAJ,gBAAI,KAAJ,gBAAI,QAEpB;IAED,MAAa,EAAE;QAMG;QACA;QAFd,YACc,KAAsC,EACtC,GAAmB;YADnB,UAAK,GAAL,KAAK,CAAiC;YACtC,QAAG,GAAH,GAAG,CAAgB;QAC9B,CAAC;QAEG,QAAQ;YACX,OAAO,IAAI,CAAC,KAAK,CAAC;QACtB,CAAC;QACM,MAAM;YACT,OAAO,IAAI,CAAC,GAAG,CAAC;QACpB,CAAC;QACM,WAAW;YACd,OAAO,IAA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