@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.
Files changed (215) hide show
  1. package/DEVELOPMENT.md +13 -14
  2. package/README.md +7 -14
  3. package/build/adaptor.d.ts +5 -5
  4. package/build/adaptor.js +16 -16
  5. package/build/adaptor.js.map +1 -1
  6. package/build/agentloop.d.ts +5 -5
  7. package/build/agentloop.js +4 -4
  8. package/build/agentloop.js.map +1 -1
  9. package/build/api-types/anthropic/billing.d.ts +12 -0
  10. package/build/api-types/anthropic/billing.js +15 -0
  11. package/build/api-types/anthropic/billing.js.map +1 -0
  12. package/build/api-types/anthropic/tool-codec.d.ts +17 -0
  13. package/build/api-types/anthropic/tool-codec.js +73 -0
  14. package/build/api-types/anthropic/tool-codec.js.map +1 -0
  15. package/build/api-types/google/billing.d.ts +12 -0
  16. package/build/api-types/google/billing.js +24 -0
  17. package/build/api-types/google/billing.js.map +1 -0
  18. package/build/api-types/google/restful-request.d.ts +8 -0
  19. package/build/api-types/google/restful-request.js +2 -0
  20. package/build/api-types/google/restful-request.js.map +1 -0
  21. package/build/api-types/google/tool-codec.d.ts +16 -0
  22. package/build/api-types/{google.js → google/tool-codec.js} +27 -26
  23. package/build/api-types/google/tool-codec.js.map +1 -0
  24. package/build/api-types/openai-chatcompletion/billing.d.ts +13 -0
  25. package/build/api-types/openai-chatcompletion/billing.js +16 -0
  26. package/build/api-types/openai-chatcompletion/billing.js.map +1 -0
  27. package/build/api-types/openai-chatcompletion/tool-codec.d.ts +18 -0
  28. package/build/api-types/openai-chatcompletion/tool-codec.js +86 -0
  29. package/build/api-types/openai-chatcompletion/tool-codec.js.map +1 -0
  30. package/build/api-types/openai-responses/billing.d.ts +12 -0
  31. package/build/api-types/openai-responses/billing.js +15 -0
  32. package/build/api-types/openai-responses/billing.js.map +1 -0
  33. package/build/api-types/openai-responses/tool-codec.d.ts +16 -0
  34. package/build/api-types/openai-responses/tool-codec.js +72 -0
  35. package/build/api-types/openai-responses/tool-codec.js.map +1 -0
  36. package/build/compatible/engine.d/aliyun.d.ts +23 -0
  37. package/build/compatible/engine.d/aliyun.js +44 -0
  38. package/build/compatible/engine.d/aliyun.js.map +1 -0
  39. package/build/compatible/engine.d/anthropic.d.ts +23 -0
  40. package/build/compatible/engine.d/anthropic.js +41 -0
  41. package/build/compatible/engine.d/anthropic.js.map +1 -0
  42. package/build/compatible/engine.d/google.d.ts +23 -0
  43. package/build/compatible/engine.d/google.js +45 -0
  44. package/build/compatible/engine.d/google.js.map +1 -0
  45. package/build/compatible/engine.d/openai-responses.d.ts +23 -0
  46. package/build/compatible/engine.d/openai-responses.js +41 -0
  47. package/build/compatible/engine.d/openai-responses.js.map +1 -0
  48. package/build/compatible/engine.d.ts +18 -0
  49. package/build/compatible/engine.js +21 -0
  50. package/build/compatible/engine.js.map +1 -0
  51. package/build/compatible/session.d.ts +78 -0
  52. package/build/compatible/session.js +138 -0
  53. package/build/compatible/session.js.map +1 -0
  54. package/build/compatible/tool-call-validator.d.ts +11 -0
  55. package/build/compatible/tool-call-validator.js +12 -0
  56. package/build/compatible/tool-call-validator.js.map +1 -0
  57. package/build/compatible.d/aliyun/transport.d.ts +11 -0
  58. package/build/compatible.d/aliyun/transport.js +9 -0
  59. package/build/compatible.d/aliyun/transport.js.map +1 -0
  60. package/build/compatible.d/anthropic/message-codec.d.ts +31 -0
  61. package/build/compatible.d/anthropic/message-codec.js +88 -0
  62. package/build/compatible.d/anthropic/message-codec.js.map +1 -0
  63. package/build/compatible.d/anthropic/transport.d.ts +31 -0
  64. package/build/compatible.d/anthropic/transport.js +137 -0
  65. package/build/compatible.d/anthropic/transport.js.map +1 -0
  66. package/build/compatible.d/google/message-codec.d.ts +31 -0
  67. package/build/compatible.d/google/message-codec.js +98 -0
  68. package/build/compatible.d/google/message-codec.js.map +1 -0
  69. package/build/compatible.d/google/transport.d.ts +28 -0
  70. package/build/compatible.d/google/transport.js +74 -0
  71. package/build/compatible.d/google/transport.js.map +1 -0
  72. package/build/compatible.d/openai-chatcompletions/message-codec.d.ts +19 -0
  73. package/build/compatible.d/openai-chatcompletions/message-codec.js +66 -0
  74. package/build/compatible.d/openai-chatcompletions/message-codec.js.map +1 -0
  75. package/build/compatible.d/openai-chatcompletions/transport.d.ts +9 -0
  76. package/build/compatible.d/openai-chatcompletions/transport.js +25 -0
  77. package/build/compatible.d/openai-chatcompletions/transport.js.map +1 -0
  78. package/build/compatible.d/openai-chatcompletions.d/monolith.d.ts +36 -0
  79. package/build/compatible.d/openai-chatcompletions.d/monolith.js +74 -0
  80. package/build/compatible.d/openai-chatcompletions.d/monolith.js.map +1 -0
  81. package/build/compatible.d/openai-chatcompletions.d/stream.d.ts +35 -0
  82. package/build/{compatible-engines.d → compatible.d}/openai-chatcompletions.d/stream.js +52 -42
  83. package/build/compatible.d/openai-chatcompletions.d/stream.js.map +1 -0
  84. package/build/compatible.d/openai-responses/message-codec.d.ts +32 -0
  85. package/build/compatible.d/openai-responses/message-codec.js +105 -0
  86. package/build/compatible.d/openai-responses/message-codec.js.map +1 -0
  87. package/build/compatible.d/openai-responses/transport.d.ts +33 -0
  88. package/build/compatible.d/openai-responses/transport.js +88 -0
  89. package/build/compatible.d/openai-responses/transport.js.map +1 -0
  90. package/build/config.js +1 -1
  91. package/build/config.js.map +1 -1
  92. package/build/engine.d.ts +48 -26
  93. package/build/engine.js +78 -29
  94. package/build/engine.js.map +1 -1
  95. package/build/exports.d.ts +14 -13
  96. package/build/exports.js +14 -13
  97. package/build/exports.js.map +1 -1
  98. package/build/function.d.ts +25 -13
  99. package/build/function.js +2 -1
  100. package/build/function.js.map +1 -1
  101. package/build/inference-context.d.ts +1 -1
  102. package/build/native-engines.d/google/agentloop.d.ts +6 -6
  103. package/build/native-engines.d/google/agentloop.js +5 -5
  104. package/build/native-engines.d/google/agentloop.js.map +1 -1
  105. package/build/native-engines.d/google/engine.d.ts +28 -103
  106. package/build/native-engines.d/google/engine.js +63 -304
  107. package/build/native-engines.d/google/engine.js.map +1 -1
  108. package/build/native-engines.d/google/exports.d.ts +5 -5
  109. package/build/native-engines.d/google/exports.js +5 -5
  110. package/build/native-engines.d/google/exports.js.map +1 -1
  111. package/build/native-engines.d/google/message-codec.d.ts +21 -0
  112. package/build/native-engines.d/google/message-codec.js +69 -0
  113. package/build/native-engines.d/google/message-codec.js.map +1 -0
  114. package/build/native-engines.d/google/session.d.ts +16 -15
  115. package/build/native-engines.d/google/session.js +2 -2
  116. package/build/native-engines.d/google/session.js.map +1 -1
  117. package/build/native-engines.d/google/transport.d.ts +31 -0
  118. package/build/native-engines.d/google/transport.js +81 -0
  119. package/build/native-engines.d/google/transport.js.map +1 -0
  120. package/build/native-engines.d/openai-responses/agentloop.d.ts +7 -7
  121. package/build/native-engines.d/openai-responses/agentloop.js +6 -6
  122. package/build/native-engines.d/openai-responses/agentloop.js.map +1 -1
  123. package/build/native-engines.d/openai-responses/engine.d.ts +26 -106
  124. package/build/native-engines.d/openai-responses/engine.js +53 -334
  125. package/build/native-engines.d/openai-responses/engine.js.map +1 -1
  126. package/build/native-engines.d/openai-responses/exports.d.ts +6 -7
  127. package/build/native-engines.d/openai-responses/exports.js +6 -7
  128. package/build/native-engines.d/openai-responses/exports.js.map +1 -1
  129. package/build/native-engines.d/openai-responses/message-codec.d.ts +21 -0
  130. package/build/native-engines.d/openai-responses/message-codec.js +69 -0
  131. package/build/native-engines.d/openai-responses/message-codec.js.map +1 -0
  132. package/build/native-engines.d/openai-responses/session.d.ts +27 -26
  133. package/build/native-engines.d/openai-responses/session.js +3 -3
  134. package/build/native-engines.d/openai-responses/session.js.map +1 -1
  135. package/build/native-engines.d/openai-responses/tool-call-validator.d.ts +12 -0
  136. package/build/native-engines.d/openai-responses/tool-call-validator.js +33 -0
  137. package/build/native-engines.d/openai-responses/tool-call-validator.js.map +1 -0
  138. package/build/native-engines.d/openai-responses/tool.d.ts +3 -3
  139. package/build/native-engines.d/openai-responses/tool.js +1 -1
  140. package/build/native-engines.d/openai-responses/tool.js.map +1 -1
  141. package/build/native-engines.d/openai-responses/transport.d.ts +36 -0
  142. package/build/native-engines.d/openai-responses/transport.js +104 -0
  143. package/build/native-engines.d/openai-responses/transport.js.map +1 -0
  144. package/build/session.d.ts +5 -75
  145. package/build/session.js +0 -136
  146. package/build/session.js.map +1 -1
  147. package/build/throttle.d.ts +1 -1
  148. package/build/tsconfig.tsbuildinfo +1 -1
  149. package/package.json +4 -4
  150. package/test/build/test-codecs.js +230 -0
  151. package/test/build/test-codecs.js.map +1 -0
  152. package/test/build/test-compatible-engine.d.ts +1 -0
  153. package/test/build/test-compatible-engine.js +27 -0
  154. package/test/build/test-compatible-engine.js.map +1 -0
  155. package/test/build/test-compatible-engines.d.ts +1 -0
  156. package/test/build/test-compatible-engines.js +112 -0
  157. package/test/build/test-compatible-engines.js.map +1 -0
  158. package/test/build/test-engine.d.ts +1 -0
  159. package/test/build/test-engine.js +97 -0
  160. package/test/build/test-engine.js.map +1 -0
  161. package/test/build/test-helpers.d.ts +46 -0
  162. package/test/build/test-helpers.js +45 -0
  163. package/test/build/test-helpers.js.map +1 -0
  164. package/test/build/test-native-engines.d.ts +1 -0
  165. package/test/build/test-native-engines.js +64 -0
  166. package/test/build/test-native-engines.js.map +1 -0
  167. package/test/build/test.d.ts +5 -0
  168. package/test/build/test.js +6 -0
  169. package/test/build/test.js.map +1 -0
  170. package/test/build/tsconfig.tsbuildinfo +1 -0
  171. package/test/src/test-codecs.ts +256 -0
  172. package/test/src/test-compatible-engine.ts +45 -0
  173. package/test/src/test-compatible-engines.ts +129 -0
  174. package/test/src/test-engine.ts +144 -0
  175. package/test/src/test-helpers.ts +53 -0
  176. package/test/src/test-native-engines.ts +75 -0
  177. package/test/src/test.ts +5 -0
  178. package/test/src/tsconfig.json +30 -0
  179. package/build/api-types/anthropic.d.ts +0 -29
  180. package/build/api-types/anthropic.js +0 -93
  181. package/build/api-types/anthropic.js.map +0 -1
  182. package/build/api-types/google.d.ts +0 -28
  183. package/build/api-types/google.js.map +0 -1
  184. package/build/api-types/openai-chat-completions.d.ts +0 -31
  185. package/build/api-types/openai-chat-completions.js +0 -113
  186. package/build/api-types/openai-chat-completions.js.map +0 -1
  187. package/build/api-types/openai-responses.d.ts +0 -23
  188. package/build/api-types/openai-responses.js +0 -71
  189. package/build/api-types/openai-responses.js.map +0 -1
  190. package/build/compatible-engine.d.ts +0 -51
  191. package/build/compatible-engine.js +0 -67
  192. package/build/compatible-engine.js.map +0 -1
  193. package/build/compatible-engines.d/aliyun.d.ts +0 -69
  194. package/build/compatible-engines.d/aliyun.js +0 -149
  195. package/build/compatible-engines.d/aliyun.js.map +0 -1
  196. package/build/compatible-engines.d/anthropic.d.ts +0 -78
  197. package/build/compatible-engines.d/anthropic.js +0 -312
  198. package/build/compatible-engines.d/anthropic.js.map +0 -1
  199. package/build/compatible-engines.d/google.d.ts +0 -83
  200. package/build/compatible-engines.d/google.js +0 -279
  201. package/build/compatible-engines.d/google.js.map +0 -1
  202. package/build/compatible-engines.d/openai-chatcompletions.d/monolith.d.ts +0 -15
  203. package/build/compatible-engines.d/openai-chatcompletions.d/monolith.js +0 -75
  204. package/build/compatible-engines.d/openai-chatcompletions.d/monolith.js.map +0 -1
  205. package/build/compatible-engines.d/openai-chatcompletions.d/stream.d.ts +0 -21
  206. package/build/compatible-engines.d/openai-chatcompletions.d/stream.js.map +0 -1
  207. package/build/compatible-engines.d/openai-chatcompletions.d.ts +0 -27
  208. package/build/compatible-engines.d/openai-chatcompletions.js +0 -76
  209. package/build/compatible-engines.d/openai-chatcompletions.js.map +0 -1
  210. package/build/compatible-engines.d/openai-responses.d.ts +0 -93
  211. package/build/compatible-engines.d/openai-responses.js +0 -300
  212. package/build/compatible-engines.d/openai-responses.js.map +0 -1
  213. package/build/test.js +0 -198
  214. package/build/test.js.map +0 -1
  215. /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,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAQzC,MAAM,OAAO,qBAAqB;IAGD;IAFnB,MAAM,CAAM;IAEtB,YAA6B,GAAuC;QAAvC,QAAG,GAAH,GAAG,CAAoC;QAChE,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,kBAA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AC,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 '../../inference-context.ts';
2
- import { type Session } from './session.ts';
3
- import { Function } from '../../function.ts';
4
- import { Tool } from './tool.ts';
5
- import { OpenAIResponsesNativeEngine } from './engine.ts';
6
- import * as CompatibleAgentloopModule from '../../agentloop.ts';
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<Function.Declaration.From<fdm>>, engine: OpenAIResponsesNativeEngine<fdm>, tlm: Tool.Map<fdm>, limit?: number): AsyncGenerator<string, string, void>;
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 "../../inference-context.js";
2
- import { RoleMessage } from "./session.js";
3
- import { Function } from "../../function.js";
4
- import { Tool } from "./tool.js";
5
- import { OpenAIResponsesNativeEngine } from "./engine.js";
6
- import * as CompatibleAgentloopModule from "../../agentloop.js";
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,4BAA4B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAgB,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,yBAAyB,MAAM,oBAAoB,CAAC;AAGhE;;GAEG;AACH,MAAM,CAAC,KAAK,SAAU,CAAC,CAAA,SAAS,CAC5B,KAAuB,EACvB,OAAgD,EAChD,MAAwC,EACxC,GAAkB,EAClB,KAAK,GAAG,MAAM,CAAC,iBAAiB;IAGhC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,GAAG,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAC;QACpC,IAAI,CAAC,GAAG,CAAC,MAAM;YAAE,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAkC,EAAE,CAAC;QAC/C,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC;YACrC,IAAI,IAAI,Y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C;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 '../../function.ts';
2
- import { RoleMessage, type ChatMessage, type Session } from './session.ts';
3
- import { Tool } from './tool.ts';
4
- import { Engine } from '../../engine.ts';
5
- import { type InferenceContext } from '../../inference-context.ts';
6
- import OpenAI from 'openai';
7
- import * as Undici from 'undici';
8
- import { OpenAIResponsesEngine } from '../../api-types/openai-responses.ts';
9
- import { Throttle } from '../../throttle.ts';
10
- export interface OpenAIResponsesNativeEngine<fdm extends Function.Declaration.Map> extends Engine {
11
- /**
12
- * @throws {@link USER_ABORTION} 用户中止
13
- * @throws {@link InferenceTimeout} 推理超时
14
- * @throws {@link ResponseInvalid} 模型抽风
15
- * @throws {TypeError} 网络故障
16
- */
17
- stateless(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
18
- /**
19
- * @param session mutable
20
- */
21
- stateful(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
22
- appendUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
23
- /**
24
- * @param session mutable
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>, OpenAIResponsesEngine.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
  }