@zimtsui/typechat 0.0.94 → 0.0.96

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 (164) hide show
  1. package/DEVELOPMENT.md +0 -6
  2. package/README.md +26 -36
  3. package/assets/verbatim/instruction.md +27 -25
  4. package/assets/verbatim/quotation.handlebars +1 -1
  5. package/assets/verbatim/system.handlebars +1 -0
  6. package/build/adaptor.d.ts +5 -23
  7. package/build/adaptor.js +14 -25
  8. package/build/adaptor.js.map +1 -1
  9. package/build/api-types/anthropic/billing.d.ts +3 -3
  10. package/build/api-types/anthropic/billing.js +6 -6
  11. package/build/api-types/anthropic/billing.js.map +1 -1
  12. package/build/api-types/anthropic/tool-codec.d.ts +3 -3
  13. package/build/api-types/anthropic/tool-codec.js +15 -11
  14. package/build/api-types/anthropic/tool-codec.js.map +1 -1
  15. package/build/api-types/google/billing.d.ts +3 -3
  16. package/build/api-types/google/billing.js +7 -7
  17. package/build/api-types/google/billing.js.map +1 -1
  18. package/build/api-types/google/tool-codec.d.ts +3 -3
  19. package/build/api-types/google/tool-codec.js +16 -34
  20. package/build/api-types/google/tool-codec.js.map +1 -1
  21. package/build/api-types/openai-chatcompletions/billing.d.ts +5 -5
  22. package/build/api-types/openai-chatcompletions/billing.js +7 -7
  23. package/build/api-types/openai-chatcompletions/billing.js.map +1 -1
  24. package/build/api-types/openai-chatcompletions/tool-codec.d.ts +5 -5
  25. package/build/api-types/openai-chatcompletions/tool-codec.js +17 -13
  26. package/build/api-types/openai-chatcompletions/tool-codec.js.map +1 -1
  27. package/build/api-types/openai-responses/billing.d.ts +3 -3
  28. package/build/api-types/openai-responses/billing.js +6 -6
  29. package/build/api-types/openai-responses/billing.js.map +1 -1
  30. package/build/api-types/openai-responses/tool-codec.d.ts +3 -3
  31. package/build/api-types/openai-responses/tool-codec.js +16 -12
  32. package/build/api-types/openai-responses/tool-codec.js.map +1 -1
  33. package/build/assets.d.ts +1 -1
  34. package/build/assets.js +6 -5
  35. package/build/assets.js.map +1 -1
  36. package/build/compatible-engine/session.d.ts +4 -16
  37. package/build/compatible-engine/session.js +8 -15
  38. package/build/compatible-engine/session.js.map +1 -1
  39. package/build/compatible-engine/validation.d.ts +7 -7
  40. package/build/compatible-engine/validation.js +33 -34
  41. package/build/compatible-engine/validation.js.map +1 -1
  42. package/build/compatible-engine.d/anthropic/message-codec.d.ts +4 -3
  43. package/build/compatible-engine.d/anthropic/message-codec.js +16 -22
  44. package/build/compatible-engine.d/anthropic/message-codec.js.map +1 -1
  45. package/build/compatible-engine.d/anthropic/transport.d.ts +10 -3
  46. package/build/compatible-engine.d/anthropic/transport.js +105 -101
  47. package/build/compatible-engine.d/anthropic/transport.js.map +1 -1
  48. package/build/compatible-engine.d/anthropic.d.ts +2 -0
  49. package/build/compatible-engine.d/anthropic.js +9 -1
  50. package/build/compatible-engine.d/anthropic.js.map +1 -1
  51. package/build/compatible-engine.d/google/message-codec.d.ts +4 -3
  52. package/build/compatible-engine.d/google/message-codec.js +16 -22
  53. package/build/compatible-engine.d/google/message-codec.js.map +1 -1
  54. package/build/compatible-engine.d/google/transport.d.ts +10 -3
  55. package/build/compatible-engine.d/google/transport.js +32 -24
  56. package/build/compatible-engine.d/google/transport.js.map +1 -1
  57. package/build/compatible-engine.d/google.d.ts +2 -0
  58. package/build/compatible-engine.d/google.js +23 -2
  59. package/build/compatible-engine.d/google.js.map +1 -1
  60. package/build/compatible-engine.d/openai-chatcompletions/message-codec.d.ts +6 -5
  61. package/build/compatible-engine.d/openai-chatcompletions/message-codec.js +17 -24
  62. package/build/compatible-engine.d/openai-chatcompletions/message-codec.js.map +1 -1
  63. package/build/compatible-engine.d/openai-chatcompletions/transport.d.ts +33 -3
  64. package/build/compatible-engine.d/openai-chatcompletions/transport.js +182 -6
  65. package/build/compatible-engine.d/openai-chatcompletions/transport.js.map +1 -1
  66. package/build/compatible-engine.d/openai-chatcompletions.d.ts +10 -2
  67. package/build/compatible-engine.d/openai-chatcompletions.js +35 -0
  68. package/build/compatible-engine.d/openai-chatcompletions.js.map +1 -1
  69. package/build/compatible-engine.d/openai-responses/message-codec.d.ts +4 -6
  70. package/build/compatible-engine.d/openai-responses/message-codec.js +70 -74
  71. package/build/compatible-engine.d/openai-responses/message-codec.js.map +1 -1
  72. package/build/compatible-engine.d/openai-responses/transport.d.ts +14 -8
  73. package/build/compatible-engine.d/openai-responses/transport.js +64 -64
  74. package/build/compatible-engine.d/openai-responses/transport.js.map +1 -1
  75. package/build/compatible-engine.d/openai-responses.d.ts +2 -0
  76. package/build/compatible-engine.d/openai-responses.js +10 -2
  77. package/build/compatible-engine.d/openai-responses.js.map +1 -1
  78. package/build/compatible-engine.d.ts +2 -1
  79. package/build/compatible-engine.js +3 -3
  80. package/build/compatible-engine.js.map +1 -1
  81. package/build/config.d.ts +17 -19
  82. package/build/config.js +2 -4
  83. package/build/config.js.map +1 -1
  84. package/build/endpoint-spec.d.ts +15 -15
  85. package/build/endpoint-spec.js +2 -2
  86. package/build/endpoint-spec.js.map +1 -1
  87. package/build/engine/session.d.ts +31 -0
  88. package/build/engine/session.js +19 -0
  89. package/build/engine/session.js.map +1 -1
  90. package/build/engine/validation.d.ts +1 -7
  91. package/build/engine.d.ts +37 -20
  92. package/build/engine.js +154 -87
  93. package/build/engine.js.map +1 -1
  94. package/build/function.d.ts +1 -1
  95. package/build/native-engines.d/google/message-codec.d.ts +6 -3
  96. package/build/native-engines.d/google/message-codec.js +23 -27
  97. package/build/native-engines.d/google/message-codec.js.map +1 -1
  98. package/build/native-engines.d/google/transport.d.ts +13 -3
  99. package/build/native-engines.d/google/transport.js +41 -27
  100. package/build/native-engines.d/google/transport.js.map +1 -1
  101. package/build/native-engines.d/google/validation.d.ts +5 -6
  102. package/build/native-engines.d/google/validation.js +3 -6
  103. package/build/native-engines.d/google/validation.js.map +1 -1
  104. package/build/native-engines.d/google.d.ts +2 -2
  105. package/build/native-engines.d/google.js +22 -4
  106. package/build/native-engines.d/google.js.map +1 -1
  107. package/build/native-engines.d/openai-responses/choice-codec.d.ts +1 -1
  108. package/build/native-engines.d/openai-responses/choice-codec.js +12 -12
  109. package/build/native-engines.d/openai-responses/choice-codec.js.map +1 -1
  110. package/build/native-engines.d/openai-responses/message-codec.d.ts +5 -3
  111. package/build/native-engines.d/openai-responses/message-codec.js +59 -48
  112. package/build/native-engines.d/openai-responses/message-codec.js.map +1 -1
  113. package/build/native-engines.d/openai-responses/transport.d.ts +14 -6
  114. package/build/native-engines.d/openai-responses/transport.js +56 -54
  115. package/build/native-engines.d/openai-responses/transport.js.map +1 -1
  116. package/build/native-engines.d/openai-responses/validation.d.ts +7 -7
  117. package/build/native-engines.d/openai-responses/validation.js +31 -32
  118. package/build/native-engines.d/openai-responses/validation.js.map +1 -1
  119. package/build/native-engines.d/openai-responses.d.ts +2 -2
  120. package/build/native-engines.d/openai-responses.js +9 -4
  121. package/build/native-engines.d/openai-responses.js.map +1 -1
  122. package/build/repetition.d.ts +2 -1
  123. package/build/repetition.js +7 -42
  124. package/build/repetition.js.map +1 -1
  125. package/build/telemetry.d.ts +1 -0
  126. package/build/telemetry.js +1 -0
  127. package/build/telemetry.js.map +1 -1
  128. package/build/tsconfig.tsbuildinfo +1 -1
  129. package/build/verbatim/codec/declarations.d.ts +0 -1
  130. package/build/verbatim/codec/declarations.js +1 -2
  131. package/build/verbatim/codec/declarations.js.map +1 -1
  132. package/build/verbatim/codec/helpers.d.ts +2 -0
  133. package/build/verbatim/codec/{escape.js → helpers.js} +5 -1
  134. package/build/verbatim/codec/helpers.js.map +1 -0
  135. package/build/verbatim/codec/quotation.d.ts +1 -2
  136. package/build/verbatim/codec/quotation.js +3 -4
  137. package/build/verbatim/codec/quotation.js.map +1 -1
  138. package/build/verbatim/codec/response.d.ts +0 -1
  139. package/build/verbatim/codec/response.js +1 -2
  140. package/build/verbatim/codec/response.js.map +1 -1
  141. package/build/verbatim/codec/{meta.d.ts → system.d.ts} +0 -1
  142. package/build/verbatim/codec/system.js +7 -0
  143. package/build/verbatim/codec/system.js.map +1 -0
  144. package/build/verbatim/codec.d.ts +1 -1
  145. package/build/verbatim/codec.js +1 -1
  146. package/build/verbatim/codec.js.map +1 -1
  147. package/package.json +8 -9
  148. package/assets/verbatim/meta.handlebars +0 -1
  149. package/build/compatible-engine.d/aliyun/transport.d.ts +0 -12
  150. package/build/compatible-engine.d/aliyun/transport.js +0 -7
  151. package/build/compatible-engine.d/aliyun/transport.js.map +0 -1
  152. package/build/compatible-engine.d/aliyun.d.ts +0 -21
  153. package/build/compatible-engine.d/aliyun.js +0 -38
  154. package/build/compatible-engine.d/aliyun.js.map +0 -1
  155. package/build/compatible-engine.d/openai-chatcompletions/transport.d/monolith.d.ts +0 -31
  156. package/build/compatible-engine.d/openai-chatcompletions/transport.d/monolith.js +0 -88
  157. package/build/compatible-engine.d/openai-chatcompletions/transport.d/monolith.js.map +0 -1
  158. package/build/compatible-engine.d/openai-chatcompletions/transport.d/stream.d.ts +0 -34
  159. package/build/compatible-engine.d/openai-chatcompletions/transport.d/stream.js +0 -190
  160. package/build/compatible-engine.d/openai-chatcompletions/transport.d/stream.js.map +0 -1
  161. package/build/verbatim/codec/escape.d.ts +0 -1
  162. package/build/verbatim/codec/escape.js.map +0 -1
  163. package/build/verbatim/codec/meta.js +0 -8
  164. package/build/verbatim/codec/meta.js.map +0 -1
@@ -1,12 +1,11 @@
1
1
  import { Structuring } from "./structuring.js";
2
2
  import { RoleMessage } from "./session.js";
3
- import { ResponseInvalid } from "../engine.js";
4
3
  import * as VerbatimCodec from "../verbatim/codec.js";
5
4
  import { isRepeating } from "../repetition.js";
6
5
  export class StructuringValidator {
7
- ctx;
8
- constructor(ctx) {
9
- this.ctx = ctx;
6
+ structuringChoice;
7
+ constructor(options) {
8
+ this.structuringChoice = options.structuringChoice;
10
9
  }
11
10
  validate(aiMessage) {
12
11
  const fcs = aiMessage.getFunctionCalls();
@@ -14,76 +13,76 @@ export class StructuringValidator {
14
13
  return this.validateStructuring(fcs, vrs);
15
14
  }
16
15
  validateStructuring(fcs, vrs) {
17
- if (this.ctx.choice === Structuring.Choice.FCall.REQUIRED) {
16
+ if (this.structuringChoice === Structuring.Choice.FCall.REQUIRED) {
18
17
  if (!fcs.length)
19
- throw new ResponseInvalid('Function call required.');
18
+ throw new SyntaxError('Function call required.');
20
19
  }
21
- else if (this.ctx.choice === Structuring.Choice.FCall.ANYONE) {
20
+ else if (this.structuringChoice === Structuring.Choice.FCall.ANYONE) {
22
21
  if (!fcs.length)
23
- throw new ResponseInvalid('Function call required.');
22
+ throw new SyntaxError('Function call required.');
24
23
  if (fcs.length > 1)
25
- throw new ResponseInvalid('Only one function call allowed.');
24
+ throw new SyntaxError('Only one function call allowed.');
26
25
  }
27
- else if (this.ctx.choice instanceof Structuring.Choice.FCall) {
26
+ else if (this.structuringChoice instanceof Structuring.Choice.FCall) {
28
27
  if (!fcs.length)
29
- throw new ResponseInvalid(`Function call of ${this.ctx.choice.name} required.`);
28
+ throw new SyntaxError(`Function call of ${this.structuringChoice.name} required.`);
30
29
  if (fcs.length > 1)
31
- throw new ResponseInvalid('Only one function call allowed.');
32
- if (fcs[0].name !== this.ctx.choice.name)
33
- throw new ResponseInvalid(`Only function call of ${this.ctx.choice.name} allowed.`);
30
+ throw new SyntaxError('Only one function call allowed.');
31
+ if (fcs[0].name !== this.structuringChoice.name)
32
+ throw new SyntaxError(`Only function call of ${this.structuringChoice.name} allowed.`);
34
33
  }
35
- else if (this.ctx.choice === Structuring.Choice.VRequest.REQUIRED) {
34
+ else if (this.structuringChoice === Structuring.Choice.VRequest.REQUIRED) {
36
35
  if (!vrs.length)
37
36
  return new RoleMessage.User([
38
- RoleMessage.Part.Text.paragraph(VerbatimCodec.Meta.encode(`Error: No valid verbatim request found. Check your output format.`)),
37
+ RoleMessage.Part.Text.paragraph(VerbatimCodec.System.encode(`Error: No valid verbatim request found. Check your output format.`)),
39
38
  ]);
40
39
  }
41
- else if (this.ctx.choice === Structuring.Choice.VRequest.ANYONE) {
40
+ else if (this.structuringChoice === Structuring.Choice.VRequest.ANYONE) {
42
41
  if (!vrs.length)
43
42
  return new RoleMessage.User([
44
- RoleMessage.Part.Text.paragraph(VerbatimCodec.Meta.encode(`Error: No valid verbatim request found. Check your output format.`)),
43
+ RoleMessage.Part.Text.paragraph(VerbatimCodec.System.encode(`Error: No valid verbatim request found. Check your output format.`)),
45
44
  ]);
46
45
  if (vrs.length > 1)
47
46
  return new RoleMessage.User([
48
- RoleMessage.Part.Text.paragraph(VerbatimCodec.Meta.encode(`Error: Only 1 verbatim request allowed, but multiple found.`)),
47
+ RoleMessage.Part.Text.paragraph(VerbatimCodec.System.encode(`Error: Only 1 verbatim request allowed, but multiple found.`)),
49
48
  ]);
50
49
  }
51
- else if (this.ctx.choice instanceof Structuring.Choice.VRequest) {
50
+ else if (this.structuringChoice instanceof Structuring.Choice.VRequest) {
52
51
  if (!vrs.length)
53
52
  return new RoleMessage.User([
54
- RoleMessage.Part.Text.paragraph(VerbatimCodec.Meta.encode(`Error: No valid verbatim request through channel \`${this.ctx.choice.name}\` found. Check your output format.`)),
53
+ RoleMessage.Part.Text.paragraph(VerbatimCodec.System.encode(`Error: No valid verbatim request through channel \`${this.structuringChoice.name}\` found. Check your output format.`)),
55
54
  ]);
56
55
  if (vrs.length > 1)
57
56
  return new RoleMessage.User([
58
- RoleMessage.Part.Text.paragraph(VerbatimCodec.Meta.encode(`Error: Only 1 verbatim request through channel \`${this.ctx.choice.name}\` allowed.`)),
57
+ RoleMessage.Part.Text.paragraph(VerbatimCodec.System.encode(`Error: Only 1 verbatim request through channel \`${this.structuringChoice.name}\` allowed.`)),
59
58
  ]);
60
- if (vrs[0].name !== this.ctx.choice.name)
59
+ if (vrs[0].name !== this.structuringChoice.name)
61
60
  return new RoleMessage.User([
62
- RoleMessage.Part.Text.paragraph(VerbatimCodec.Meta.encode(`Error: Only verbatim request through channel \`${this.ctx.choice.name}\` allowed.`)),
61
+ RoleMessage.Part.Text.paragraph(VerbatimCodec.System.encode(`Error: Only verbatim request through channel \`${this.structuringChoice.name}\` allowed.`)),
63
62
  ]);
64
63
  }
65
- else if (this.ctx.choice === Structuring.Choice.REQUIRED) {
64
+ else if (this.structuringChoice === Structuring.Choice.REQUIRED) {
66
65
  if (fcs.length + vrs.length) { }
67
66
  else
68
67
  return new RoleMessage.User([
69
- RoleMessage.Part.Text.paragraph(VerbatimCodec.Meta.encode(`Error: No function call or valid verbatim request found. Check your output format.`)),
68
+ RoleMessage.Part.Text.paragraph(VerbatimCodec.System.encode(`Error: No function call or valid verbatim request found. Check your output format.`)),
70
69
  ]);
71
70
  }
72
- else if (this.ctx.choice === Structuring.Choice.ANYONE) {
71
+ else if (this.structuringChoice === Structuring.Choice.ANYONE) {
73
72
  if (fcs.length + vrs.length) { }
74
73
  else
75
74
  return new RoleMessage.User([
76
- RoleMessage.Part.Text.paragraph(VerbatimCodec.Meta.encode(`Error: No function call or valid verbatim request found. Check your output format.`)),
75
+ RoleMessage.Part.Text.paragraph(VerbatimCodec.System.encode(`Error: No function call or valid verbatim request found. Check your output format.`)),
77
76
  ]);
78
77
  if (fcs.length + vrs.length > 1)
79
78
  return new RoleMessage.User([
80
- RoleMessage.Part.Text.paragraph(VerbatimCodec.Meta.encode(`Error: Only 1 function call or verbatim request allowed, but multiple found.`)),
79
+ RoleMessage.Part.Text.paragraph(VerbatimCodec.System.encode(`Error: Only 1 function call or verbatim request allowed, but multiple found.`)),
81
80
  ]);
82
81
  }
83
- else if (this.ctx.choice === Structuring.Choice.NONE) {
82
+ else if (this.structuringChoice === Structuring.Choice.NONE) {
84
83
  if (fcs.length + vrs.length)
85
84
  return new RoleMessage.User([
86
- RoleMessage.Part.Text.paragraph(VerbatimCodec.Meta.encode(`Error: Neither function call nor verbatim request allowed.`)),
85
+ RoleMessage.Part.Text.paragraph(VerbatimCodec.System.encode(`Error: Neither function call nor verbatim request allowed.`)),
87
86
  ]);
88
87
  }
89
88
  }
@@ -92,13 +91,13 @@ export class PartsValidator {
92
91
  constructor() { }
93
92
  validateMessageTextParts(parts) {
94
93
  for (const part of parts)
95
- if (isRepeating(part.text, 2, 20))
96
- throw new ResponseInvalid('Repeating');
94
+ if (isRepeating(part.text))
95
+ throw new SyntaxError('Repeating');
97
96
  }
98
97
  validate(message) {
99
98
  if (message.getParts().length) { }
100
99
  else
101
- throw new ResponseInvalid('Empty message.');
100
+ throw new SyntaxError('Empty message.');
102
101
  this.validateMessageTextParts(message.getTextParts());
103
102
  }
104
103
  }
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/compatible-engine/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,aAAa,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,MAAM,OAAO,oBAAoB;IAIA;IAA7B,YAA6B,GAA2C;QAA3C,QAAG,GAAH,GAAG,CAAwC;IAAG,CAAC;IAErE,QAAQ,CACX,SAAmC;QAEnC,MAAM,GAAG,GAAG,SAAS,CAAC,gBAAgB,EAAE,CAAC;QACzC,MAAM,GAAG,GAAG,SAAS,CAAC,mBAAmB,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC9C,CAAC;IAEM,mBAAmB,CACtB,GAA4B,EAC5B,GAA+B;QAE/B,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACxD,IAAI,CAAC,GAAG,CAAC,MAAM;gBAAE,MAAM,IAAI,eAAe,CAAC,yBAAyB,CAAC,CAAC;QAE1E,CAAC;aAAM,IAAI,IAAI,CAAC,GAAG,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AAW,CAAC,IAAI,CAAM;oBAC7B,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAC3B,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,8EAA8E,CAAC,CAC9G;iBACJ,CAAC,CAAC;QAEX,CAAC;aAAM,IAAI,IAAI,CAAC,iBAAiB,KAAK,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5D,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM;gBACvB,OAAO,IAAI,WAAW,CAAC,IAAI,CAAM;oBAC7B,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAC3B,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,4DAA4D,CAAC,CAC5F;iBACJ,CAAC,CAAC;QACX,CAAC;IACL,CAAC;CACJ;AAqBD,MAAM,OAAO,cAAc;IAIvB,gBAAsB,CAAC;IAEhB,wBAAwB,CAC3B,KAAmC;QAEnC,KAAK,MAAM,IAAI,IAAI,KAAK;YACpB,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;gBACtB,MAAM,IAAI,WAAW,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;IAEM,QAAQ,CACX,OAAiC;QAEjC,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA,CAAC;;YAAM,MAAM,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAC/E,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IAC1D,CAAC;CAEJ"}
@@ -5,8 +5,9 @@ import type { ToolCodec } from '../../api-types/anthropic/tool-codec.ts';
5
5
  import type { Verbatim } from '../../verbatim.ts';
6
6
  declare const NOMINAL: unique symbol;
7
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>);
8
+ protected toolCodec: ToolCodec<fdm>;
9
+ protected vdm: vdm;
10
+ constructor(options: MessageCodec.Options<fdm, vdm>);
10
11
  encodeUserMessage(userMessage: RoleMessage.User.From<fdm>): Anthropic.ContentBlockParam[];
11
12
  encodeAiMessage(aiMessage: RoleMessage.Ai.From<fdm, vdm>): Anthropic.ContentBlockParam[];
12
13
  encodeDeveloperMessage(developerMessage: RoleMessage.Developer): Anthropic.TextBlockParam[];
@@ -14,7 +15,7 @@ export declare class MessageCodec<in out fdm extends Function.Decl.Map.Proto, in
14
15
  decodeAiMessage(raw: Anthropic.ContentBlock[]): MessageCodec.Message.Ai.From<fdm, vdm>;
15
16
  }
16
17
  export declare namespace MessageCodec {
17
- interface Context<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> {
18
+ interface Options<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> {
18
19
  toolCodec: ToolCodec<fdm>;
19
20
  vdm: vdm;
20
21
  }
@@ -1,12 +1,13 @@
1
1
  import { RoleMessage } from "../../compatible-engine/session.js";
2
2
  import { Function } from "../../function.js";
3
3
  import * as VerbatimCodec from "../../verbatim/codec.js";
4
- import { ResponseInvalid } from "../../engine.js";
5
4
  const NOMINAL = Symbol();
6
5
  export class MessageCodec {
7
- ctx;
8
- constructor(ctx) {
9
- this.ctx = ctx;
6
+ toolCodec;
7
+ vdm;
8
+ constructor(options) {
9
+ this.toolCodec = options.toolCodec;
10
+ this.vdm = options.vdm;
10
11
  }
11
12
  encodeUserMessage(userMessage) {
12
13
  return userMessage.getParts().map(part => {
@@ -16,7 +17,7 @@ export class MessageCodec {
16
17
  text: part.text,
17
18
  };
18
19
  else if (part instanceof Function.Response)
19
- return this.ctx.toolCodec.encodeFunctionResponse(part);
20
+ return this.toolCodec.encodeFunctionResponse(part);
20
21
  else
21
22
  throw new Error();
22
23
  });
@@ -32,7 +33,7 @@ export class MessageCodec {
32
33
  text: part.text,
33
34
  };
34
35
  else if (part instanceof Function.Call)
35
- return this.ctx.toolCodec.encodeFunctionCall(part);
36
+ return this.toolCodec.encodeFunctionCall(part);
36
37
  else
37
38
  throw new Error();
38
39
  });
@@ -50,25 +51,18 @@ export class MessageCodec {
50
51
  throw new Error('Unsupported chat message type.');
51
52
  }
52
53
  decodeAiMessage(raw) {
53
- const parts = raw.flatMap((item) => {
54
- if (item.type === 'text')
55
- try {
56
- const vrs = VerbatimCodec.Request.decode(item.text, this.ctx.vdm);
57
- return [new RoleMessage.Part.Text(item.text, vrs)];
58
- }
59
- catch (e) {
60
- if (e instanceof SyntaxError)
61
- throw new ResponseInvalid('Invalid verbatim message', { cause: raw });
62
- else
63
- throw e;
64
- }
54
+ const parts = [];
55
+ for (const item of raw) {
56
+ if (item.type === 'text') {
57
+ const vrs = VerbatimCodec.Request.decode(item.text, this.vdm);
58
+ parts.push(new RoleMessage.Part.Text(item.text, vrs));
59
+ }
65
60
  else if (item.type === 'tool_use')
66
- return [this.ctx.toolCodec.decodeFunctionCall(item)];
67
- else if (item.type === 'thinking')
68
- return [];
61
+ parts.push(this.toolCodec.decodeFunctionCall(item));
62
+ else if (item.type === 'thinking') { }
69
63
  else
70
64
  throw new Error();
71
- });
65
+ }
72
66
  return new MessageCodec.Message.Ai(parts, raw);
73
67
  }
74
68
  }
@@ -1 +1 @@
1
- {"version":3,"file":"message-codec.js","sourceRoot":"","sources":["../../../src/compatible-engine.d/anthropic/message-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,OAAO,KAAK,aAAa,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;AAGzB,MAAM,OAAO,YAAY;IAIQ;IAA7B,YAA6B,GAAmC;QAAnC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AO,IAAI,CAAC,GAAG,CAAC;YACpB,CAAC;SACJ;QAhBY,UAAE,KAgBd,CAAA;IAOL,CAAC,EAxBgB,OAAO,GAAP,oBAAO,KAAP,oBAAO,QAwBvB;AACL,CAAC,EAlCgB,YAAY,KAAZ,YAAY,QAkC5B"}
@@ -11,14 +11,21 @@ import type { Verbatim } from '../../verbatim.ts';
11
11
  import type { Structuring } from '../../compatible-engine/structuring.ts';
12
12
  import type { Engine } from '../../engine.ts';
13
13
  export declare class Transport<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> implements Engine.Transport<RoleMessage.User.From<fdm>, RoleMessage.Ai.From<fdm, vdm>, RoleMessage.Developer, Session.From<fdm, vdm>> {
14
- protected ctx: Transport.Context<fdm, vdm>;
15
14
  protected client: Anthropic;
16
- constructor(ctx: Transport.Context<fdm, vdm>);
15
+ protected providerSpec: ProviderSpec;
16
+ protected inferenceSpec: InferenceParams;
17
+ protected fdm: fdm;
18
+ protected throttle: Throttle;
19
+ protected structuringChoice: Structuring.Choice.From<fdm, vdm>;
20
+ protected messageCodec: MessageCodec<fdm, vdm>;
21
+ protected toolCodec: ToolCodec<fdm>;
22
+ protected billing: Billing;
23
+ constructor(options: Transport.Options<fdm, vdm>);
17
24
  protected makeParams(session: Session.From<fdm, vdm>): Anthropic.MessageCreateParamsStreaming;
18
25
  fetch(wfctx: InferenceContext, session: Session.From<fdm, vdm>, signal?: AbortSignal): Promise<RoleMessage.Ai.From<fdm, vdm>>;
19
26
  }
20
27
  export declare namespace Transport {
21
- interface Context<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> {
28
+ interface Options<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> {
22
29
  providerSpec: ProviderSpec;
23
30
  inferenceSpec: InferenceParams;
24
31
  fdm: fdm;
@@ -1,148 +1,152 @@
1
- import { NetworkError, ResponseInvalid } from "../../engine.js";
2
1
  import Anthropic from '@anthropic-ai/sdk';
3
2
  import { loggers } from "../../telemetry.js";
4
3
  import * as ChoiceCodec from "./choice-codec.js";
4
+ import * as Undici from 'undici';
5
5
  export class Transport {
6
- ctx;
7
6
  client;
8
- constructor(ctx) {
9
- this.ctx = ctx;
7
+ providerSpec;
8
+ inferenceSpec;
9
+ fdm;
10
+ throttle;
11
+ structuringChoice;
12
+ messageCodec;
13
+ toolCodec;
14
+ billing;
15
+ constructor(options) {
10
16
  this.client = new Anthropic({
11
- baseURL: this.ctx.providerSpec.baseUrl,
12
- apiKey: this.ctx.providerSpec.apiKey,
13
- fetchOptions: { dispatcher: this.ctx.providerSpec.dispatcher },
17
+ baseURL: options.providerSpec.baseUrl,
18
+ apiKey: options.providerSpec.apiKey,
19
+ fetch: Undici.fetch,
20
+ fetchOptions: { dispatcher: options.providerSpec.dispatcher },
14
21
  });
22
+ this.providerSpec = options.providerSpec;
23
+ this.inferenceSpec = options.inferenceSpec;
24
+ this.fdm = options.fdm;
25
+ this.throttle = options.throttle;
26
+ this.structuringChoice = options.choice;
27
+ this.messageCodec = options.messageCodec;
28
+ this.toolCodec = options.toolCodec;
29
+ this.billing = options.billing;
15
30
  }
16
31
  makeParams(session) {
17
- const tools = this.ctx.toolCodec.encodeFunctionDeclarationMap(this.ctx.fdm);
32
+ const tools = this.toolCodec.encodeFunctionDeclarationMap(this.fdm);
18
33
  return {
19
- model: this.ctx.inferenceSpec.model,
34
+ model: this.inferenceSpec.model,
20
35
  stream: true,
21
- messages: session.chatMessages.map(chatMessage => this.ctx.messageCodec.encodeChatMessage(chatMessage)),
22
- system: session.developerMessage && this.ctx.messageCodec.encodeDeveloperMessage(session.developerMessage),
36
+ messages: session.chatMessages.map(chatMessage => this.messageCodec.encodeChatMessage(chatMessage)),
37
+ system: session.developerMessage && this.messageCodec.encodeDeveloperMessage(session.developerMessage),
23
38
  tools: tools.length ? tools : undefined,
24
- tool_choice: tools.length ? ChoiceCodec.encode(this.ctx.choice, this.ctx.inferenceSpec.parallelToolCall) : undefined,
39
+ tool_choice: tools.length ? ChoiceCodec.encode(this.structuringChoice, this.inferenceSpec.parallelToolCall) : undefined,
25
40
  max_tokens: 64 * 1024,
26
- ...this.ctx.inferenceSpec.additionalOptions,
41
+ ...this.inferenceSpec.additionalOptions,
27
42
  };
28
43
  }
29
44
  async fetch(wfctx, session, signal) {
30
- await this.ctx.throttle.requests(wfctx);
45
+ await this.throttle.requests(wfctx);
31
46
  // Prepare request
32
47
  const params = this.makeParams(session);
33
48
  loggers.message.debug(params);
34
49
  // Send request
35
50
  const stream = this.client.messages.stream(params, {
36
51
  signal,
37
- fetchOptions: { dispatcher: this.ctx.providerSpec.dispatcher },
52
+ fetchOptions: { dispatcher: this.providerSpec.dispatcher },
38
53
  });
39
54
  // Get response
40
55
  let response = null;
41
- try {
42
- for await (const event of stream) {
43
- if (event.type === 'message_start') {
44
- loggers.message.debug(event);
45
- response = structuredClone(event.message);
56
+ for await (const event of stream) {
57
+ loggers.stream.trace(event);
58
+ if (event.type === 'message_start') {
59
+ response = structuredClone(event.message);
60
+ }
61
+ else {
62
+ if (response) { }
63
+ else
64
+ throw new Error();
65
+ if (event.type === 'message_delta') {
66
+ response.stop_sequence = event.delta.stop_sequence ?? response.stop_sequence;
67
+ response.stop_reason = event.delta.stop_reason ?? response.stop_reason;
68
+ response.usage.input_tokens = event.usage.input_tokens ?? response.usage.input_tokens;
69
+ response.usage.output_tokens = event.usage.output_tokens;
70
+ response.usage.cache_read_input_tokens = event.usage.cache_read_input_tokens ?? response.usage.cache_read_input_tokens;
71
+ response.usage.cache_creation_input_tokens = event.usage.cache_creation_input_tokens ?? response.usage.cache_creation_input_tokens;
72
+ response.usage.server_tool_use = event.usage.server_tool_use ?? response.usage.server_tool_use;
46
73
  }
47
- else {
48
- if (response) { }
49
- else
50
- throw new Error();
51
- if (event.type === 'message_delta') {
52
- loggers.message.debug(event);
53
- response.stop_sequence = event.delta.stop_sequence ?? response.stop_sequence;
54
- response.stop_reason = event.delta.stop_reason ?? response.stop_reason;
55
- response.usage.input_tokens = event.usage.input_tokens ?? response.usage.input_tokens;
56
- response.usage.output_tokens = event.usage.output_tokens;
57
- response.usage.cache_read_input_tokens = event.usage.cache_read_input_tokens ?? response.usage.cache_read_input_tokens;
58
- response.usage.cache_creation_input_tokens = event.usage.cache_creation_input_tokens ?? response.usage.cache_creation_input_tokens;
59
- response.usage.server_tool_use = event.usage.server_tool_use ?? response.usage.server_tool_use;
74
+ else if (event.type === 'message_stop') {
75
+ }
76
+ else if (event.type === 'content_block_start') {
77
+ const contentBlock = structuredClone(event.content_block);
78
+ response.content.push(contentBlock);
79
+ if (contentBlock.type === 'tool_use')
80
+ contentBlock.input = '';
81
+ }
82
+ else if (event.type === 'content_block_delta') {
83
+ const contentBlock = response.content[event.index];
84
+ if (event.delta.type === 'text_delta') {
85
+ if (contentBlock?.type === 'text') { }
86
+ else
87
+ throw new Error();
88
+ contentBlock.text += event.delta.text;
60
89
  }
61
- else if (event.type === 'message_stop') {
62
- loggers.message.debug(event);
90
+ else if (event.delta.type === 'thinking_delta') {
91
+ if (contentBlock?.type === 'thinking') { }
92
+ else
93
+ throw new Error();
94
+ contentBlock.thinking += event.delta.thinking;
63
95
  }
64
- else if (event.type === 'content_block_start') {
65
- loggers.message.debug(event);
66
- const contentBlock = structuredClone(event.content_block);
67
- response.content.push(contentBlock);
68
- if (contentBlock.type === 'tool_use')
69
- contentBlock.input = '';
96
+ else if (event.delta.type === 'signature_delta') {
97
+ if (contentBlock?.type === 'thinking') { }
98
+ else
99
+ throw new Error();
100
+ contentBlock.signature += event.delta.signature;
70
101
  }
71
- else if (event.type === 'content_block_delta') {
72
- const contentBlock = response.content[event.index];
73
- if (event.delta.type === 'text_delta') {
74
- if (contentBlock?.type === 'text') { }
75
- else
76
- throw new Error();
77
- contentBlock.text += event.delta.text;
78
- }
79
- else if (event.delta.type === 'thinking_delta') {
80
- if (contentBlock?.type === 'thinking') { }
81
- else
82
- throw new Error();
83
- contentBlock.thinking += event.delta.thinking;
84
- }
85
- else if (event.delta.type === 'signature_delta') {
86
- if (contentBlock?.type === 'thinking') { }
87
- else
88
- throw new Error();
89
- contentBlock.signature += event.delta.signature;
90
- }
91
- else if (event.delta.type === 'input_json_delta') {
92
- if (contentBlock?.type === 'tool_use') { }
93
- else
94
- throw new Error();
95
- if (typeof contentBlock.input === 'string') { }
96
- else
97
- throw new Error();
98
- contentBlock.input += event.delta.partial_json;
99
- }
102
+ else if (event.delta.type === 'input_json_delta') {
103
+ if (contentBlock?.type === 'tool_use') { }
104
+ else
105
+ throw new Error();
106
+ if (typeof contentBlock.input === 'string') { }
100
107
  else
101
- throw new Error('Unknown type of content block delta', { cause: event.delta });
108
+ throw new Error();
109
+ contentBlock.input += event.delta.partial_json;
102
110
  }
103
- else if (event.type === 'content_block_stop') {
104
- const contentBlock = response.content[event.index];
105
- if (contentBlock?.type === 'text')
106
- loggers.inference.info(contentBlock.text);
107
- else if (contentBlock?.type === 'thinking')
108
- loggers.inference.debug(contentBlock.thinking);
109
- loggers.message.debug(event);
110
- if (contentBlock?.type === 'tool_use') {
111
- if (typeof contentBlock.input === 'string') { }
112
- else
113
- throw new Error();
114
- try {
115
- contentBlock.input = JSON.parse(contentBlock.input);
116
- }
117
- catch (e) {
118
- throw new ResponseInvalid('Invalid JSON of tool use input', { cause: contentBlock.input });
119
- }
120
- loggers.message.info(contentBlock);
111
+ else
112
+ throw new Error('Unknown type of content block delta', { cause: event.delta });
113
+ }
114
+ else if (event.type === 'content_block_stop') {
115
+ const contentBlock = response.content[event.index];
116
+ if (contentBlock?.type === 'text')
117
+ loggers.inference.info(contentBlock.text);
118
+ else if (contentBlock?.type === 'thinking')
119
+ loggers.inference.debug(contentBlock.thinking);
120
+ if (contentBlock?.type === 'tool_use') {
121
+ if (typeof contentBlock.input === 'string') { }
122
+ else
123
+ throw new Error();
124
+ try {
125
+ contentBlock.input = JSON.parse(contentBlock.input);
126
+ }
127
+ catch (e) {
128
+ throw new SyntaxError('Invalid JSON of tool use input', { cause: contentBlock.input });
121
129
  }
130
+ loggers.message.info(contentBlock);
122
131
  }
123
- else
124
- throw new Error('Unknown stream event', { cause: event });
125
132
  }
133
+ else
134
+ throw new Error('Unknown stream event', { cause: event });
126
135
  }
127
136
  }
128
- catch (e) {
129
- if (e instanceof TypeError)
130
- throw new NetworkError(undefined, { cause: e });
131
- else
132
- throw e;
133
- }
134
137
  // Validate response
135
138
  if (response) { }
136
139
  else
137
140
  throw new Error();
141
+ loggers.message.debug(response);
138
142
  if (response.stop_reason === 'max_tokens')
139
- throw new ResponseInvalid('Token limit exceeded.', { cause: response });
143
+ throw new SyntaxError('Token limit exceeded.', { cause: response });
140
144
  if (response.stop_reason === 'end_turn' || response.stop_reason === 'tool_use') { }
141
145
  else
142
- throw new ResponseInvalid('Abnormal stop reason', { cause: response });
146
+ throw new SyntaxError('Abnormal stop reason', { cause: response });
143
147
  loggers.message.info(response.usage);
144
- wfctx.cost?.(this.ctx.billing.charge(response.usage));
145
- return this.ctx.messageCodec.decodeAiMessage(response.content);
148
+ wfctx.cost?.(this.billing.charge(response.usage));
149
+ return this.messageCodec.decodeAiMessage(response.content);
146
150
  }
147
151
  }
148
152
  //# sourceMappingURL=transport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/compatible-engine.d/anthropic/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAA2C,MAAM,iBAAiB,CAAC;AAGzG,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAK7C,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AAKjD,MAAM,OAAO,SAAS;IAWW;IAFnB,MAAM,CAAY;IAE5B,YAA6B,GAAgC;QAAhC,QAAG,GAAH,GAAG,CAA6B;QACzD,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC;YACxB,OAAO,EAAE,IAAI,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AC,WAAW,KAAK,UAAU,IAAI,QAAQ,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC,CAAA,CAAC;;YAC9E,MAAM,IAAI,WAAW,CAAC,sBAAsB,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACvE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QAElD,OAAO,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC/D,CAAC;CACJ"}
@@ -9,11 +9,13 @@ import type { Verbatim } from '../verbatim.ts';
9
9
  export type AnthropicCompatibleEngine<fdm extends Function.Decl.Map.Proto, vdm extends Verbatim.Decl.Map.Proto> = AnthropicCompatibleEngine.Instance<fdm, vdm>;
10
10
  export declare namespace AnthropicCompatibleEngine {
11
11
  class Instance<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> extends CompatibleEngine.Instance<fdm, vdm> {
12
+ protected options: AnthropicCompatibleEngine.Options<fdm, vdm>;
12
13
  protected toolCodec: ToolCodec<fdm>;
13
14
  protected messageCodec: AnthropicCompatibleEngine.MessageCodec<fdm, vdm>;
14
15
  protected billing: Billing;
15
16
  protected transport: AnthropicCompatibleEngine.Transport<fdm, vdm>;
16
17
  constructor(options: AnthropicCompatibleEngine.Options<fdm, vdm>);
18
+ clone(): AnthropicCompatibleEngine<fdm, vdm>;
17
19
  }
18
20
  interface Options<in out fdm extends Function.Decl.Map.Proto, in out vdm extends Verbatim.Decl.Map.Proto> extends CompatibleEngine.Options<fdm, vdm> {
19
21
  }