@zimtsui/brainswitch 0.0.54 → 0.0.56
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/DEVELOPMENT.md +13 -14
- package/README.md +7 -14
- package/build/adaptor.d.ts +5 -5
- package/build/adaptor.js +16 -16
- package/build/adaptor.js.map +1 -1
- package/build/agentloop.d.ts +5 -5
- package/build/agentloop.js +4 -4
- package/build/agentloop.js.map +1 -1
- package/build/api-types/anthropic/billing.d.ts +12 -0
- package/build/api-types/anthropic/billing.js +15 -0
- package/build/api-types/anthropic/billing.js.map +1 -0
- package/build/api-types/anthropic/tool-codec.d.ts +17 -0
- package/build/api-types/anthropic/tool-codec.js +73 -0
- package/build/api-types/anthropic/tool-codec.js.map +1 -0
- package/build/api-types/google/billing.d.ts +12 -0
- package/build/api-types/google/billing.js +24 -0
- package/build/api-types/google/billing.js.map +1 -0
- package/build/api-types/google/restful-request.d.ts +8 -0
- package/build/api-types/google/restful-request.js +2 -0
- package/build/api-types/google/restful-request.js.map +1 -0
- package/build/api-types/google/tool-codec.d.ts +16 -0
- package/build/api-types/{google.js → google/tool-codec.js} +27 -26
- package/build/api-types/google/tool-codec.js.map +1 -0
- package/build/api-types/openai-chatcompletion/billing.d.ts +13 -0
- package/build/api-types/openai-chatcompletion/billing.js +16 -0
- package/build/api-types/openai-chatcompletion/billing.js.map +1 -0
- package/build/api-types/openai-chatcompletion/tool-codec.d.ts +18 -0
- package/build/api-types/openai-chatcompletion/tool-codec.js +86 -0
- package/build/api-types/openai-chatcompletion/tool-codec.js.map +1 -0
- package/build/api-types/openai-responses/billing.d.ts +12 -0
- package/build/api-types/openai-responses/billing.js +15 -0
- package/build/api-types/openai-responses/billing.js.map +1 -0
- package/build/api-types/openai-responses/tool-codec.d.ts +16 -0
- package/build/api-types/openai-responses/tool-codec.js +72 -0
- package/build/api-types/openai-responses/tool-codec.js.map +1 -0
- package/build/compatible/engine.d/aliyun.d.ts +23 -0
- package/build/compatible/engine.d/aliyun.js +44 -0
- package/build/compatible/engine.d/aliyun.js.map +1 -0
- package/build/compatible/engine.d/anthropic.d.ts +23 -0
- package/build/compatible/engine.d/anthropic.js +41 -0
- package/build/compatible/engine.d/anthropic.js.map +1 -0
- package/build/compatible/engine.d/google.d.ts +23 -0
- package/build/compatible/engine.d/google.js +45 -0
- package/build/compatible/engine.d/google.js.map +1 -0
- package/build/compatible/engine.d/openai-responses.d.ts +23 -0
- package/build/compatible/engine.d/openai-responses.js +41 -0
- package/build/compatible/engine.d/openai-responses.js.map +1 -0
- package/build/compatible/engine.d.ts +18 -0
- package/build/compatible/engine.js +21 -0
- package/build/compatible/engine.js.map +1 -0
- package/build/compatible/session.d.ts +78 -0
- package/build/compatible/session.js +138 -0
- package/build/compatible/session.js.map +1 -0
- package/build/compatible/tool-call-validator.d.ts +11 -0
- package/build/compatible/tool-call-validator.js +12 -0
- package/build/compatible/tool-call-validator.js.map +1 -0
- package/build/compatible.d/aliyun/transport.d.ts +11 -0
- package/build/compatible.d/aliyun/transport.js +9 -0
- package/build/compatible.d/aliyun/transport.js.map +1 -0
- package/build/compatible.d/anthropic/message-codec.d.ts +31 -0
- package/build/compatible.d/anthropic/message-codec.js +88 -0
- package/build/compatible.d/anthropic/message-codec.js.map +1 -0
- package/build/compatible.d/anthropic/transport.d.ts +31 -0
- package/build/compatible.d/anthropic/transport.js +137 -0
- package/build/compatible.d/anthropic/transport.js.map +1 -0
- package/build/compatible.d/google/message-codec.d.ts +31 -0
- package/build/compatible.d/google/message-codec.js +98 -0
- package/build/compatible.d/google/message-codec.js.map +1 -0
- package/build/compatible.d/google/transport.d.ts +28 -0
- package/build/compatible.d/google/transport.js +74 -0
- package/build/compatible.d/google/transport.js.map +1 -0
- package/build/compatible.d/openai-chatcompletions/message-codec.d.ts +19 -0
- package/build/compatible.d/openai-chatcompletions/message-codec.js +66 -0
- package/build/compatible.d/openai-chatcompletions/message-codec.js.map +1 -0
- package/build/compatible.d/openai-chatcompletions/transport.d.ts +9 -0
- package/build/compatible.d/openai-chatcompletions/transport.js +25 -0
- package/build/compatible.d/openai-chatcompletions/transport.js.map +1 -0
- package/build/compatible.d/openai-chatcompletions.d/monolith.d.ts +36 -0
- package/build/compatible.d/openai-chatcompletions.d/monolith.js +74 -0
- package/build/compatible.d/openai-chatcompletions.d/monolith.js.map +1 -0
- package/build/compatible.d/openai-chatcompletions.d/stream.d.ts +35 -0
- package/build/{compatible-engines.d → compatible.d}/openai-chatcompletions.d/stream.js +52 -42
- package/build/compatible.d/openai-chatcompletions.d/stream.js.map +1 -0
- package/build/compatible.d/openai-responses/message-codec.d.ts +32 -0
- package/build/compatible.d/openai-responses/message-codec.js +105 -0
- package/build/compatible.d/openai-responses/message-codec.js.map +1 -0
- package/build/compatible.d/openai-responses/transport.d.ts +33 -0
- package/build/compatible.d/openai-responses/transport.js +88 -0
- package/build/compatible.d/openai-responses/transport.js.map +1 -0
- package/build/config.js +1 -1
- package/build/config.js.map +1 -1
- package/build/engine.d.ts +48 -26
- package/build/engine.js +78 -29
- package/build/engine.js.map +1 -1
- package/build/exports.d.ts +14 -13
- package/build/exports.js +14 -13
- package/build/exports.js.map +1 -1
- package/build/function.d.ts +25 -13
- package/build/function.js +2 -1
- package/build/function.js.map +1 -1
- package/build/inference-context.d.ts +1 -1
- package/build/native-engines.d/google/agentloop.d.ts +6 -6
- package/build/native-engines.d/google/agentloop.js +5 -5
- package/build/native-engines.d/google/agentloop.js.map +1 -1
- package/build/native-engines.d/google/engine.d.ts +28 -103
- package/build/native-engines.d/google/engine.js +63 -304
- package/build/native-engines.d/google/engine.js.map +1 -1
- package/build/native-engines.d/google/exports.d.ts +5 -5
- package/build/native-engines.d/google/exports.js +5 -5
- package/build/native-engines.d/google/exports.js.map +1 -1
- package/build/native-engines.d/google/message-codec.d.ts +21 -0
- package/build/native-engines.d/google/message-codec.js +69 -0
- package/build/native-engines.d/google/message-codec.js.map +1 -0
- package/build/native-engines.d/google/session.d.ts +16 -15
- package/build/native-engines.d/google/session.js +2 -2
- package/build/native-engines.d/google/session.js.map +1 -1
- package/build/native-engines.d/google/transport.d.ts +31 -0
- package/build/native-engines.d/google/transport.js +81 -0
- package/build/native-engines.d/google/transport.js.map +1 -0
- package/build/native-engines.d/openai-responses/agentloop.d.ts +7 -7
- package/build/native-engines.d/openai-responses/agentloop.js +6 -6
- package/build/native-engines.d/openai-responses/agentloop.js.map +1 -1
- package/build/native-engines.d/openai-responses/engine.d.ts +26 -106
- package/build/native-engines.d/openai-responses/engine.js +53 -334
- package/build/native-engines.d/openai-responses/engine.js.map +1 -1
- package/build/native-engines.d/openai-responses/exports.d.ts +6 -7
- package/build/native-engines.d/openai-responses/exports.js +6 -7
- package/build/native-engines.d/openai-responses/exports.js.map +1 -1
- package/build/native-engines.d/openai-responses/message-codec.d.ts +21 -0
- package/build/native-engines.d/openai-responses/message-codec.js +69 -0
- package/build/native-engines.d/openai-responses/message-codec.js.map +1 -0
- package/build/native-engines.d/openai-responses/session.d.ts +27 -26
- package/build/native-engines.d/openai-responses/session.js +3 -3
- package/build/native-engines.d/openai-responses/session.js.map +1 -1
- package/build/native-engines.d/openai-responses/tool-call-validator.d.ts +12 -0
- package/build/native-engines.d/openai-responses/tool-call-validator.js +33 -0
- package/build/native-engines.d/openai-responses/tool-call-validator.js.map +1 -0
- package/build/native-engines.d/openai-responses/tool.d.ts +3 -3
- package/build/native-engines.d/openai-responses/tool.js +1 -1
- package/build/native-engines.d/openai-responses/tool.js.map +1 -1
- package/build/native-engines.d/openai-responses/transport.d.ts +36 -0
- package/build/native-engines.d/openai-responses/transport.js +104 -0
- package/build/native-engines.d/openai-responses/transport.js.map +1 -0
- package/build/session.d.ts +5 -75
- package/build/session.js +0 -136
- package/build/session.js.map +1 -1
- package/build/throttle.d.ts +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/test/build/test-codecs.js +230 -0
- package/test/build/test-codecs.js.map +1 -0
- package/test/build/test-compatible-engine.d.ts +1 -0
- package/test/build/test-compatible-engine.js +27 -0
- package/test/build/test-compatible-engine.js.map +1 -0
- package/test/build/test-compatible-engines.d.ts +1 -0
- package/test/build/test-compatible-engines.js +112 -0
- package/test/build/test-compatible-engines.js.map +1 -0
- package/test/build/test-engine.d.ts +1 -0
- package/test/build/test-engine.js +97 -0
- package/test/build/test-engine.js.map +1 -0
- package/test/build/test-helpers.d.ts +46 -0
- package/test/build/test-helpers.js +45 -0
- package/test/build/test-helpers.js.map +1 -0
- package/test/build/test-native-engines.d.ts +1 -0
- package/test/build/test-native-engines.js +64 -0
- package/test/build/test-native-engines.js.map +1 -0
- package/test/build/test.d.ts +5 -0
- package/test/build/test.js +6 -0
- package/test/build/test.js.map +1 -0
- package/test/build/tsconfig.tsbuildinfo +1 -0
- package/test/src/test-codecs.ts +256 -0
- package/test/src/test-compatible-engine.ts +45 -0
- package/test/src/test-compatible-engines.ts +129 -0
- package/test/src/test-engine.ts +144 -0
- package/test/src/test-helpers.ts +53 -0
- package/test/src/test-native-engines.ts +75 -0
- package/test/src/test.ts +5 -0
- package/test/src/tsconfig.json +30 -0
- package/build/api-types/anthropic.d.ts +0 -29
- package/build/api-types/anthropic.js +0 -93
- package/build/api-types/anthropic.js.map +0 -1
- package/build/api-types/google.d.ts +0 -28
- package/build/api-types/google.js.map +0 -1
- package/build/api-types/openai-chat-completions.d.ts +0 -31
- package/build/api-types/openai-chat-completions.js +0 -113
- package/build/api-types/openai-chat-completions.js.map +0 -1
- package/build/api-types/openai-responses.d.ts +0 -23
- package/build/api-types/openai-responses.js +0 -71
- package/build/api-types/openai-responses.js.map +0 -1
- package/build/compatible-engine.d.ts +0 -51
- package/build/compatible-engine.js +0 -67
- package/build/compatible-engine.js.map +0 -1
- package/build/compatible-engines.d/aliyun.d.ts +0 -69
- package/build/compatible-engines.d/aliyun.js +0 -149
- package/build/compatible-engines.d/aliyun.js.map +0 -1
- package/build/compatible-engines.d/anthropic.d.ts +0 -78
- package/build/compatible-engines.d/anthropic.js +0 -312
- package/build/compatible-engines.d/anthropic.js.map +0 -1
- package/build/compatible-engines.d/google.d.ts +0 -83
- package/build/compatible-engines.d/google.js +0 -279
- package/build/compatible-engines.d/google.js.map +0 -1
- package/build/compatible-engines.d/openai-chatcompletions.d/monolith.d.ts +0 -15
- package/build/compatible-engines.d/openai-chatcompletions.d/monolith.js +0 -75
- package/build/compatible-engines.d/openai-chatcompletions.d/monolith.js.map +0 -1
- package/build/compatible-engines.d/openai-chatcompletions.d/stream.d.ts +0 -21
- package/build/compatible-engines.d/openai-chatcompletions.d/stream.js.map +0 -1
- package/build/compatible-engines.d/openai-chatcompletions.d.ts +0 -27
- package/build/compatible-engines.d/openai-chatcompletions.js +0 -76
- package/build/compatible-engines.d/openai-chatcompletions.js.map +0 -1
- package/build/compatible-engines.d/openai-responses.d.ts +0 -93
- package/build/compatible-engines.d/openai-responses.js +0 -300
- package/build/compatible-engines.d/openai-responses.js.map +0 -1
- package/build/test.js +0 -198
- package/build/test.js.map +0 -1
- /package/{build/test.d.ts → test/build/test-codecs.d.ts} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type InferenceParams, type ProviderSpec } from '#@/engine.ts';
|
|
2
|
+
import { RoleMessage, type Session } from '#@/native-engines.d/google/session.ts';
|
|
3
|
+
import { Function } from '#@/function.ts';
|
|
4
|
+
import { type InferenceContext } from '#@/inference-context.ts';
|
|
5
|
+
import { Throttle } from '#@/throttle.ts';
|
|
6
|
+
import type { GoogleNativeMessageCodec } from '#@/native-engines.d/google/message-codec.ts';
|
|
7
|
+
import type { GoogleToolCodec } from '#@/api-types/google/tool-codec.ts';
|
|
8
|
+
import type { GoogleBilling } from '#@/api-types/google/billing.ts';
|
|
9
|
+
import type { ToolCallValidator } from '#@/compatible/tool-call-validator.ts';
|
|
10
|
+
export declare class GoogleNativeTransport<fdm extends Function.Declaration.Map> {
|
|
11
|
+
protected ctx: GoogleNativeTransport.Context<fdm>;
|
|
12
|
+
protected apiURL: URL;
|
|
13
|
+
constructor(ctx: GoogleNativeTransport.Context<fdm>);
|
|
14
|
+
fetch(wfctx: InferenceContext, session: Session<fdm>, signal?: AbortSignal): Promise<RoleMessage.Ai<fdm>>;
|
|
15
|
+
}
|
|
16
|
+
export declare namespace GoogleNativeTransport {
|
|
17
|
+
interface Context<fdm extends Function.Declaration.Map> {
|
|
18
|
+
inferenceParams: InferenceParams;
|
|
19
|
+
providerSpec: ProviderSpec;
|
|
20
|
+
fdm: fdm;
|
|
21
|
+
throttle: Throttle;
|
|
22
|
+
toolChoice: Function.ToolChoice<fdm>;
|
|
23
|
+
codeExecution: boolean;
|
|
24
|
+
urlContext: boolean;
|
|
25
|
+
googleSearch: boolean;
|
|
26
|
+
messageCodec: GoogleNativeMessageCodec<fdm>;
|
|
27
|
+
toolCodec: GoogleToolCodec<fdm>;
|
|
28
|
+
billing: GoogleBilling;
|
|
29
|
+
toolCallValidator: ToolCallValidator<fdm>;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ResponseInvalid } from '#@/engine.ts';
|
|
2
|
+
import { RoleMessage } from '#@/native-engines.d/google/session.ts';
|
|
3
|
+
import { Function } from '#@/function.ts';
|
|
4
|
+
import * as Google from '@google/genai';
|
|
5
|
+
import * as Undici from 'undici';
|
|
6
|
+
import {} from '#@/inference-context.ts';
|
|
7
|
+
import { Throttle } from '#@/throttle.ts';
|
|
8
|
+
import { logger } from '#@/telemetry.ts';
|
|
9
|
+
export class GoogleNativeTransport {
|
|
10
|
+
ctx;
|
|
11
|
+
apiURL;
|
|
12
|
+
constructor(ctx) {
|
|
13
|
+
this.ctx = ctx;
|
|
14
|
+
this.apiURL = new URL(`${this.ctx.providerSpec.baseUrl}/v1beta/models/${this.ctx.inferenceParams.model}:generateContent`);
|
|
15
|
+
}
|
|
16
|
+
async fetch(wfctx, session, signal) {
|
|
17
|
+
const systemInstruction = session.developerMessage && this.ctx.messageCodec.convertFromDeveloperMessage(session.developerMessage);
|
|
18
|
+
const contents = this.ctx.messageCodec.convertFromChatMessages(session.chatMessages);
|
|
19
|
+
await this.ctx.throttle.requests(wfctx);
|
|
20
|
+
const functionDeclarations = this.ctx.toolCodec.convertFromFunctionDeclarationMap(this.ctx.fdm);
|
|
21
|
+
const tools = [];
|
|
22
|
+
if (functionDeclarations.length)
|
|
23
|
+
tools.push({ functionDeclarations });
|
|
24
|
+
if (this.ctx.urlContext)
|
|
25
|
+
tools.push({ urlContext: {} });
|
|
26
|
+
if (this.ctx.googleSearch)
|
|
27
|
+
tools.push({ googleSearch: {} });
|
|
28
|
+
if (this.ctx.codeExecution)
|
|
29
|
+
tools.push({ codeExecution: {} });
|
|
30
|
+
const reqbody = {
|
|
31
|
+
contents,
|
|
32
|
+
tools: tools.length ? tools : undefined,
|
|
33
|
+
toolConfig: functionDeclarations.length ? {
|
|
34
|
+
functionCallingConfig: this.ctx.toolCodec.convertFromToolChoice(this.ctx.toolChoice),
|
|
35
|
+
} : undefined,
|
|
36
|
+
systemInstruction,
|
|
37
|
+
generationConfig: this.ctx.inferenceParams.maxTokens || this.ctx.inferenceParams.additionalOptions ? {
|
|
38
|
+
maxOutputTokens: this.ctx.inferenceParams.maxTokens ?? undefined,
|
|
39
|
+
...this.ctx.inferenceParams.additionalOptions,
|
|
40
|
+
} : undefined,
|
|
41
|
+
};
|
|
42
|
+
logger.message.trace(reqbody);
|
|
43
|
+
const res = await Undici.fetch(this.apiURL, {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: new Headers({
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
'x-goog-api-key': this.ctx.providerSpec.apiKey,
|
|
48
|
+
}),
|
|
49
|
+
body: JSON.stringify(reqbody),
|
|
50
|
+
dispatcher: this.ctx.providerSpec.proxyAgent,
|
|
51
|
+
signal,
|
|
52
|
+
});
|
|
53
|
+
logger.message.trace(res);
|
|
54
|
+
if (res.ok) { }
|
|
55
|
+
else
|
|
56
|
+
throw new Error(undefined, { cause: res });
|
|
57
|
+
const response = await res.json();
|
|
58
|
+
if (response.candidates?.[0]?.content?.parts?.length) { }
|
|
59
|
+
else
|
|
60
|
+
throw new ResponseInvalid('Content missing', { cause: response });
|
|
61
|
+
if (response.candidates[0].finishReason === Google.FinishReason.MAX_TOKENS)
|
|
62
|
+
throw new ResponseInvalid('Token limit exceeded.', { cause: response });
|
|
63
|
+
if (response.candidates[0].finishReason === Google.FinishReason.STOP) { }
|
|
64
|
+
else
|
|
65
|
+
throw new ResponseInvalid('Abnormal finish reason', { cause: response });
|
|
66
|
+
for (const part of response.candidates[0].content.parts) {
|
|
67
|
+
if (part.text)
|
|
68
|
+
logger.inference.debug(part.text + '\n');
|
|
69
|
+
if (part.functionCall)
|
|
70
|
+
logger.message.debug(part.functionCall);
|
|
71
|
+
}
|
|
72
|
+
if (response.usageMetadata) { }
|
|
73
|
+
else
|
|
74
|
+
throw new ResponseInvalid('Usage metadata missing', { cause: response });
|
|
75
|
+
wfctx.cost?.(this.ctx.billing.charge(response.usageMetadata));
|
|
76
|
+
const aiMessage = this.ctx.messageCodec.convertToAiMessage(response.candidates[0].content);
|
|
77
|
+
this.ctx.toolCallValidator.validate(aiMessage.getFunctionCalls());
|
|
78
|
+
return aiMessage;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/native-engines.d/google/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA2C,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,WAAW,EAAgB,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAyB,MAAM,yBAAyB,CAAC;AAEhE,OAAO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AC;;YAAM,MAAM,IAAI,eAAe,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC7G,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;QAE9D,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,kBAAkB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC3F,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,CAAC;QAClE,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { type InferenceContext } from '
|
|
2
|
-
import { type Session } from '
|
|
3
|
-
import { Function } from '
|
|
4
|
-
import { Tool } from '
|
|
5
|
-
import { OpenAIResponsesNativeEngine } from '
|
|
6
|
-
import * as CompatibleAgentloopModule from '
|
|
1
|
+
import { type InferenceContext } from '#@/inference-context.ts';
|
|
2
|
+
import { type Session } from '#@/native-engines.d/openai-responses/session.ts';
|
|
3
|
+
import { Function } from '#@/function.ts';
|
|
4
|
+
import { Tool } from '#@/native-engines.d/openai-responses/tool.ts';
|
|
5
|
+
import { OpenAIResponsesNativeEngine } from '#@/native-engines.d/openai-responses/engine.ts';
|
|
6
|
+
import * as CompatibleAgentloopModule from '#@/agentloop.ts';
|
|
7
7
|
/**
|
|
8
8
|
* @param session mutable
|
|
9
9
|
*/
|
|
10
|
-
export declare function agentloop<fdm extends Function.Declaration.Map>(wfctx: InferenceContext, session: Session<
|
|
10
|
+
export declare function agentloop<fdm extends Function.Declaration.Map>(wfctx: InferenceContext, session: Session<fdm>, engine: OpenAIResponsesNativeEngine<fdm>, tlm: Tool.Map<fdm>, limit?: number): AsyncGenerator<string, string, void>;
|
|
11
11
|
export declare namespace agentloop {
|
|
12
12
|
export import FunctionCallLimitExceeded = CompatibleAgentloopModule.agentloop.FunctionCallLimitExceeded;
|
|
13
13
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {} from
|
|
2
|
-
import { RoleMessage } from
|
|
3
|
-
import { Function } from
|
|
4
|
-
import { Tool } from
|
|
5
|
-
import { OpenAIResponsesNativeEngine } from
|
|
6
|
-
import * as CompatibleAgentloopModule from
|
|
1
|
+
import {} from '#@/inference-context.ts';
|
|
2
|
+
import { RoleMessage } from '#@/native-engines.d/openai-responses/session.ts';
|
|
3
|
+
import { Function } from '#@/function.ts';
|
|
4
|
+
import { Tool } from '#@/native-engines.d/openai-responses/tool.ts';
|
|
5
|
+
import { OpenAIResponsesNativeEngine } from '#@/native-engines.d/openai-responses/engine.ts';
|
|
6
|
+
import * as CompatibleAgentloopModule from '#@/agentloop.ts';
|
|
7
7
|
/**
|
|
8
8
|
* @param session mutable
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentloop.js","sourceRoot":"","sources":["../../../src/native-engines.d/openai-responses/agentloop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,MAAM,
|
|
1
|
+
{"version":3,"file":"agentloop.js","sourceRoot":"","sources":["../../../src/native-engines.d/openai-responses/agentloop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAgB,MAAM,iDAAiD,CAAC;AAC5F,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,8CAA8C,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,yBAAyB,MAAM,iBAAiB,CAAC;AAG7D;;GAEG;AACH,MAAM,CAAC,KAAK,SAAU,CAAC,CAAA,SAAS,CAC5B,KAAuB,EACv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C,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;gBACxC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE;oBAClB,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC;wBACnC,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,OAAO;wBACnB,OAAO,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC;qBACjD,CAAC,CAAC;gBACP,CAAC,CAAC,EAAE,CAAC,CAAC;YACV,CAAC;;gBAAM,MAAM,IAAI,KAAK,EAAE,CAAC;QAC7B,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,MAAM,CAAM,GAAG,CAAC,CAAC,CAAC;IACvE,CAAC;IACD,MAAM,IAAI,SAAS,CAAC,yBAAyB,CAAC,+BAA+B,CAAC,CAAC;AACnF,CAAC;AAED,WAAiB,SAAS;IACR,mCAAyB,GAAG,yBAAyB,CAAC,SAAS,CAAC,yBAAyB,CAAC;AAC5G,CAAC,EAFgB,SAAS,KAAT,SAAS,QAEzB"}
|
|
@@ -1,112 +1,32 @@
|
|
|
1
|
-
import { Function } from '
|
|
2
|
-
import { RoleMessage, type
|
|
3
|
-
import { Tool } from '
|
|
4
|
-
import { Engine } from '
|
|
5
|
-
import { type InferenceContext } from '
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
pushUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
1
|
+
import { Function } from '#@/function.ts';
|
|
2
|
+
import { RoleMessage, type Session } from '#@/native-engines.d/openai-responses/session.ts';
|
|
3
|
+
import { Tool } from '#@/native-engines.d/openai-responses/tool.ts';
|
|
4
|
+
import { Engine } from '#@/engine.ts';
|
|
5
|
+
import { type InferenceContext } from '#@/inference-context.ts';
|
|
6
|
+
import { OpenAIResponsesToolCodec } from '#@/api-types/openai-responses/tool-codec.ts';
|
|
7
|
+
import { OpenAIResponsesBilling } from '#@/api-types/openai-responses/billing.ts';
|
|
8
|
+
import { OpenAIResponsesCompatibleMessageCodec } from '#@/compatible.d/openai-responses/message-codec.ts';
|
|
9
|
+
import { OpenAIResponsesNativeMessageCodec } from '#@/native-engines.d/openai-responses/message-codec.ts';
|
|
10
|
+
import { OpenAIResponsesNativeToolCallValidator } from '#@/native-engines.d/openai-responses/tool-call-validator.ts';
|
|
11
|
+
import { OpenAIResponsesNativeTransport } from '#@/native-engines.d/openai-responses/transport.ts';
|
|
12
|
+
export declare class OpenAIResponsesNativeEngine<in out fdm extends Function.Declaration.Map> extends Engine<fdm, RoleMessage.User<fdm>, RoleMessage.Ai<fdm>, RoleMessage.Developer, Session<fdm>> {
|
|
13
|
+
protected applyPatch: boolean;
|
|
14
|
+
protected toolChoice: Tool.Choice<fdm>;
|
|
15
|
+
protected toolCodec: OpenAIResponsesToolCodec<fdm>;
|
|
16
|
+
protected compatibleMessageCodec: OpenAIResponsesCompatibleMessageCodec<fdm>;
|
|
17
|
+
protected messageCodec: OpenAIResponsesNativeMessageCodec<fdm>;
|
|
18
|
+
protected billing: OpenAIResponsesBilling;
|
|
19
|
+
protected toolCallValidator: OpenAIResponsesNativeToolCallValidator<fdm>;
|
|
20
|
+
protected transport: OpenAIResponsesNativeTransport<fdm>;
|
|
21
|
+
protected parallelToolCall: boolean;
|
|
22
|
+
constructor(options: OpenAIResponsesNativeEngine.Options<fdm>);
|
|
23
|
+
protected infer(wfctx: InferenceContext, session: Session<fdm>, signal?: AbortSignal): Promise<RoleMessage.Ai<fdm>>;
|
|
24
|
+
appendUserMessage(session: Session<fdm>, message: RoleMessage.User<fdm>): Session<fdm>;
|
|
25
|
+
pushUserMessage(session: Session<fdm>, message: RoleMessage.User<fdm>): Session<fdm>;
|
|
27
26
|
}
|
|
28
27
|
export declare namespace OpenAIResponsesNativeEngine {
|
|
29
|
-
interface Options<in out fdm extends Function.Declaration.Map> extends Engine.Options<fdm
|
|
28
|
+
interface Options<in out fdm extends Function.Declaration.Map> extends Engine.Options<fdm> {
|
|
30
29
|
applyPatch?: boolean;
|
|
31
30
|
toolChoice?: Tool.Choice<fdm>;
|
|
32
31
|
}
|
|
33
|
-
interface ParentUnderhood<in out fdm extends Function.Declaration.Map> extends Engine.Underhood<fdm>, OpenAIResponsesEngine.Underhood<fdm> {
|
|
34
|
-
}
|
|
35
|
-
interface OwnProps<in out fdm extends Function.Declaration.Map> {
|
|
36
|
-
apiURL: URL;
|
|
37
|
-
toolChoice: Tool.Choice<fdm>;
|
|
38
|
-
applyPatch: boolean;
|
|
39
|
-
}
|
|
40
|
-
namespace OwnProps {
|
|
41
|
-
function init<fdm extends Function.Declaration.Map>(this: ParentUnderhood<fdm>, options: Options<fdm>): OwnProps<fdm>;
|
|
42
|
-
}
|
|
43
|
-
interface Underhood<in out fdm extends Function.Declaration.Map> extends ParentUnderhood<fdm>, OpenAIResponsesNativeEngine<fdm>, OwnProps<fdm> {
|
|
44
|
-
stateless(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
45
|
-
stateful(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
46
|
-
appendUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
47
|
-
pushUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
48
|
-
convertToAiMessage(output: OpenAI.Responses.ResponseOutputItem[]): RoleMessage.Ai<Function.Declaration.From<fdm>>;
|
|
49
|
-
convertFromUserMessage(userMessage: RoleMessage.User<Function.Declaration.From<fdm>>): OpenAI.Responses.ResponseInput;
|
|
50
|
-
convertFromDeveloperMessage(developerMessage: RoleMessage.Developer): string;
|
|
51
|
-
convertFromChatMessage(chatMessage: ChatMessage<Function.Declaration.From<fdm>>): OpenAI.Responses.ResponseInput;
|
|
52
|
-
convertFromToolChoice(toolChoice: Tool.Choice<fdm>): OpenAI.Responses.ToolChoiceOptions | OpenAI.Responses.ToolChoiceAllowed;
|
|
53
|
-
makeMonolithParams(session: Session<Function.Declaration.From<fdm>>): OpenAI.Responses.ResponseCreateParamsNonStreaming;
|
|
54
|
-
logAiMessage(output: OpenAI.Responses.ResponseOutputItem[]): void;
|
|
55
|
-
fetch(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
56
|
-
fetchRaw(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
57
|
-
validateToolCallsByToolChoice(toolCalls: Tool.Call<Function.Declaration.From<fdm>>[]): void;
|
|
58
|
-
}
|
|
59
|
-
function stateless<fdm extends Function.Declaration.Map>(this: OpenAIResponsesNativeEngine.Underhood<fdm>, wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
60
|
-
function stateful<fdm extends Function.Declaration.Map>(this: OpenAIResponsesNativeEngine.Underhood<fdm>, wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
61
|
-
function appendUserMessage<fdm extends Function.Declaration.Map>(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
62
|
-
function pushUserMessage<fdm extends Function.Declaration.Map>(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
63
|
-
function convertToAiMessage<fdm extends Function.Declaration.Map>(this: OpenAIResponsesEngine.Underhood<fdm>, output: OpenAI.Responses.ResponseOutputItem[]): RoleMessage.Ai<Function.Declaration.From<fdm>>;
|
|
64
|
-
function convertFromUserMessage<fdm extends Function.Declaration.Map>(this: OpenAIResponsesEngine.Underhood<fdm>, userMessage: RoleMessage.User<Function.Declaration.From<fdm>>): OpenAI.Responses.ResponseInput;
|
|
65
|
-
function convertFromDeveloperMessage(developerMessage: RoleMessage.Developer): string;
|
|
66
|
-
function convertFromChatMessage<fdm extends Function.Declaration.Map>(this: OpenAIResponsesNativeEngine.Underhood<fdm>, chatMessage: ChatMessage<Function.Declaration.From<fdm>>): OpenAI.Responses.ResponseInput;
|
|
67
|
-
function convertFromToolChoice<fdm extends Function.Declaration.Map>(toolChoice: Tool.Choice<fdm>): OpenAI.Responses.ToolChoiceOptions | OpenAI.Responses.ToolChoiceAllowed;
|
|
68
|
-
function makeMonolithParams<fdm extends Function.Declaration.Map>(this: OpenAIResponsesNativeEngine.Underhood<fdm>, session: Session<Function.Declaration.From<fdm>>): OpenAI.Responses.ResponseCreateParamsNonStreaming;
|
|
69
|
-
function logAiMessage<fdm extends Function.Declaration.Map>(this: Engine.Underhood<fdm>, output: OpenAI.Responses.ResponseOutputItem[]): void;
|
|
70
|
-
function fetch<fdm extends Function.Declaration.Map>(this: OpenAIResponsesNativeEngine.Underhood<fdm>, wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
71
|
-
function fetchRaw<fdm extends Function.Declaration.Map>(this: OpenAIResponsesNativeEngine.Underhood<fdm>, wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
72
|
-
function validateToolCallsByToolChoice<fdm extends Function.Declaration.Map>(this: OpenAIResponsesNativeEngine.Underhood<fdm>, toolCalls: Tool.Call<Function.Declaration.From<fdm>>[]): void;
|
|
73
|
-
class Instance<in out fdm extends Function.Declaration.Map> implements OpenAIResponsesNativeEngine.Underhood<fdm> {
|
|
74
|
-
baseUrl: string;
|
|
75
|
-
apiKey: string;
|
|
76
|
-
model: string;
|
|
77
|
-
name: string;
|
|
78
|
-
inputPrice: number;
|
|
79
|
-
outputPrice: number;
|
|
80
|
-
cachePrice: number;
|
|
81
|
-
fdm: fdm;
|
|
82
|
-
additionalOptions?: Record<string, unknown>;
|
|
83
|
-
throttle: Throttle;
|
|
84
|
-
timeout?: number;
|
|
85
|
-
maxTokens?: number;
|
|
86
|
-
proxyAgent?: Undici.ProxyAgent;
|
|
87
|
-
apiURL: URL;
|
|
88
|
-
parallelToolCall: boolean;
|
|
89
|
-
applyPatch: boolean;
|
|
90
|
-
toolChoice: Tool.Choice<fdm>;
|
|
91
|
-
constructor(options: OpenAIResponsesNativeEngine.Options<fdm>);
|
|
92
|
-
convertFromFunctionResponse(fr: Function.Response.Distributive<Function.Declaration.From<fdm>>): OpenAI.Responses.ResponseInputItem.FunctionCallOutput;
|
|
93
|
-
calcCost(usage: OpenAI.Responses.ResponseUsage): number;
|
|
94
|
-
convertFromFunctionDeclarationEntry(fdentry: Function.Declaration.Entry.From<fdm>): OpenAI.Responses.FunctionTool;
|
|
95
|
-
convertToFunctionCall(apifc: OpenAI.Responses.ResponseFunctionToolCall): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
96
|
-
stateless(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>>;
|
|
97
|
-
stateful(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>>;
|
|
98
|
-
appendUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>;
|
|
99
|
-
pushUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>;
|
|
100
|
-
fetch(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>>;
|
|
101
|
-
fetchRaw(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>>;
|
|
102
|
-
convertToAiMessage(output: OpenAI.Responses.ResponseOutputItem[]): RoleMessage.Ai<Function.Declaration.From<fdm>>;
|
|
103
|
-
convertFromChatMessage(chatMessage: ChatMessage<Function.Declaration.From<fdm>>): OpenAI.Responses.ResponseInput;
|
|
104
|
-
convertFromUserMessage(userMessage: RoleMessage.User<Function.Declaration.From<fdm>>): OpenAI.Responses.ResponseInput;
|
|
105
|
-
convertFromDeveloperMessage(developerMessage: RoleMessage.Developer): string;
|
|
106
|
-
convertFromToolChoice(toolChoice: Tool.Choice<fdm>): OpenAI.Responses.ToolChoiceOptions | OpenAI.Responses.ToolChoiceAllowed;
|
|
107
|
-
makeMonolithParams(session: Session<Function.Declaration.From<fdm>>): OpenAI.Responses.ResponseCreateParamsNonStreaming;
|
|
108
|
-
logAiMessage(output: OpenAI.Responses.ResponseOutputItem[]): void;
|
|
109
|
-
validateToolCallsByToolChoice(toolCalls: Tool.Call<Function.Declaration.From<fdm>>[]): void;
|
|
110
|
-
}
|
|
111
|
-
function create<fdm extends Function.Declaration.Map>(options: OpenAIResponsesNativeEngine.Options<fdm>): OpenAIResponsesNativeEngine<fdm>;
|
|
112
32
|
}
|