@outputai/llm 0.11.1-next.da26845.0 → 0.12.0

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 (47) hide show
  1. package/package.json +7 -3
  2. package/src/agent.js +7 -2
  3. package/src/generate.js +1 -0
  4. package/src/index.d.ts +14 -6
  5. package/src/utils/wrap.js +35 -2
  6. package/src/agent.spec.js +0 -595
  7. package/src/ai_provider.spec.js +0 -217
  8. package/src/ai_sdk_options.spec.js +0 -390
  9. package/src/fixtures/image_response_v7_google_vertex.js +0 -72
  10. package/src/fixtures/image_response_v7_openai.js +0 -77
  11. package/src/fixtures/models_api_light.json +0 -675
  12. package/src/fixtures/models_api_v7_subset.json +0 -259
  13. package/src/fixtures/stream_response_v7_anthropic.js +0 -389
  14. package/src/fixtures/stream_response_v7_google_vertex.js +0 -462
  15. package/src/fixtures/stream_response_v7_openai.js +0 -353
  16. package/src/fixtures/stream_response_v7_perplexity.js +0 -671
  17. package/src/fixtures/text_response_v7_anthropic.js +0 -359
  18. package/src/fixtures/text_response_v7_anthropic_cache.js +0 -719
  19. package/src/fixtures/text_response_v7_google_vertex.js +0 -435
  20. package/src/fixtures/text_response_v7_openai.js +0 -347
  21. package/src/fixtures/text_response_v7_perplexity.js +0 -764
  22. package/src/generate.spec.js +0 -525
  23. package/src/prompt/content.spec.js +0 -208
  24. package/src/prompt/interpolations.spec.js +0 -109
  25. package/src/prompt/loader.full.spec.js +0 -309
  26. package/src/prompt/loader.spec.js +0 -258
  27. package/src/prompt/markup/attributes.spec.js +0 -132
  28. package/src/prompt/markup/nodes.spec.js +0 -333
  29. package/src/prompt/markup/tokenizer.spec.js +0 -149
  30. package/src/prompt/markup/tokens.spec.js +0 -250
  31. package/src/prompt/validations.spec.js +0 -812
  32. package/src/utils/cost.full.spec.js +0 -272
  33. package/src/utils/cost.spec.js +0 -290
  34. package/src/utils/error_handler.spec.js +0 -230
  35. package/src/utils/file.spec.js +0 -89
  36. package/src/utils/image.spec.js +0 -20
  37. package/src/utils/legacy_cost_attribute.spec.js +0 -278
  38. package/src/utils/models.spec.js +0 -119
  39. package/src/utils/models_pricing.spec.js +0 -162
  40. package/src/utils/skills.spec.js +0 -168
  41. package/src/utils/sources.spec.js +0 -122
  42. package/src/utils/stream.spec.js +0 -55
  43. package/src/utils/tools.spec.js +0 -167
  44. package/src/utils/usage.full.spec.js +0 -215
  45. package/src/utils/usage.spec.js +0 -246
  46. package/src/utils/wrap.spec.js +0 -467
  47. package/src/validations.spec.js +0 -631
@@ -1,250 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from 'vitest';
2
- import { extractAttributes } from './attributes.js';
3
- import {
4
- extractTag,
5
- isClosingTag,
6
- isComment,
7
- isEmptyText,
8
- isOpeningTag,
9
- isSelfClosingTag
10
- } from './tokens.js';
11
-
12
- vi.mock( './attributes.js', () => ( {
13
- extractAttributes: vi.fn()
14
- } ) );
15
-
16
- describe( 'extractTag', () => {
17
- beforeEach( () => {
18
- vi.mocked( extractAttributes ).mockReset().mockReturnValue( {} );
19
- } );
20
-
21
- it( 'extracts and lowercases an opening tag name', () => {
22
- expect( extractTag( '<User>' ) ).toEqual( {
23
- tagName: 'user',
24
- attributes: {}
25
- } );
26
- expect( extractAttributes ).not.toHaveBeenCalled();
27
- } );
28
-
29
- it( 'extracts a hyphenated tag name', () => {
30
- expect( extractTag( '<CUSTOM-BLOCK>' ) ).toEqual( {
31
- tagName: 'custom-block',
32
- attributes: {}
33
- } );
34
- } );
35
-
36
- it( 'extracts a closing tag name', () => {
37
- expect( extractTag( '</User>' ) ).toEqual( {
38
- tagName: 'user',
39
- attributes: {}
40
- } );
41
- } );
42
-
43
- it( 'supports whitespace inside closing tags', () => {
44
- expect( extractTag( '</ User >' ) ).toEqual( {
45
- tagName: 'user',
46
- attributes: {}
47
- } );
48
- expect( extractAttributes ).not.toHaveBeenCalled();
49
- } );
50
-
51
- it( 'delegates raw opening-tag attributes', () => {
52
- const attributes = { options: 'cached shared', pinned: true };
53
- vi.mocked( extractAttributes ).mockReturnValue( attributes );
54
-
55
- expect( extractTag( '<user options = "cached shared" pinned>' ) ).toEqual( {
56
- tagName: 'user',
57
- attributes
58
- } );
59
- expect( extractAttributes ).toHaveBeenCalledOnce();
60
- expect( extractAttributes ).toHaveBeenCalledWith( 'options = "cached shared" pinned' );
61
- } );
62
-
63
- it( 'propagates attribute parsing errors', () => {
64
- vi.mocked( extractAttributes ).mockImplementation( () => {
65
- throw new Error( 'invalid attributes' );
66
- } );
67
-
68
- expect( () => extractTag( '<user color="red>' ) ).toThrow( 'invalid attributes' );
69
- } );
70
-
71
- it( 'throws a descriptive error for a malformed token', () => {
72
- expect( () => extractTag( 'plain text' ) )
73
- .toThrow( /^Could not parse tag "plain text"\.$/ );
74
- } );
75
- } );
76
-
77
- describe( 'isOpeningTag', () => {
78
- it.each( [
79
- '<user>',
80
- '<user >',
81
- '<User options="cached">',
82
- '<custom-block mode=fast>',
83
- '<user\toptions=fast>',
84
- '<user\noptions="cached shared">',
85
- '<user condition="score > 10">',
86
- '<user color=\'red>'
87
- ] )( 'recognizes %s', token => {
88
- expect( isOpeningTag( token ) ).toBe( true );
89
- } );
90
-
91
- it.each( [
92
- '</user>',
93
- '< user>',
94
- '<>',
95
- '<,>',
96
- '<b,b>',
97
- '<b, b>',
98
- '<user,>',
99
- '<user=admin>',
100
- '<user.name>',
101
- '<1user>',
102
- '<_user>',
103
- '<üser>',
104
- '<user />',
105
- '<user/>',
106
- '<user options="cached" />',
107
- '<user / >',
108
- '<!-- note -->',
109
- '<!DOCTYPE html>',
110
- '<?xml version="1.0"?>',
111
- '<user',
112
- 'user>',
113
- '<user></user>',
114
- '<user<other>>',
115
- '<user condition="a < b">',
116
- 'plain text'
117
- ] )( 'rejects %s', token => {
118
- expect( isOpeningTag( token ) ).toBe( false );
119
- } );
120
- } );
121
-
122
- describe( 'isClosingTag', () => {
123
- it.each( [
124
- '</user>',
125
- '</User>',
126
- '</custom-block>',
127
- '</ user >',
128
- '</user >',
129
- '</\tuser\t>',
130
- '</\nuser\n>'
131
- ] )( 'recognizes %s', token => {
132
- expect( isClosingTag( token ) ).toBe( true );
133
- } );
134
-
135
- it.each( [
136
- '<user>',
137
- '<user />',
138
- '<!-- note -->',
139
- '</>',
140
- '< /user>',
141
- '</user',
142
- '</user/>',
143
- '</user / >',
144
- '</user options=ignored>',
145
- '</b,b>',
146
- '</1user>',
147
- '</_user>',
148
- '</üser>',
149
- '</user> suffix',
150
- 'prefix </user>',
151
- '</user></system>',
152
- '</user<system>>',
153
- 'plain text'
154
- ] )( 'rejects %s', token => {
155
- expect( isClosingTag( token ) ).toBe( false );
156
- } );
157
- } );
158
-
159
- describe( 'isSelfClosingTag', () => {
160
- it.each( [
161
- '<user/>',
162
- '<user />',
163
- '<CUSTOM-BLOCK />',
164
- '<image source="avatar.png" />',
165
- '<user options = "cached shared" />',
166
- '<user condition="score > 10"/>',
167
- '<user\tmode=fast\t/>',
168
- '<user\nmode=fast\n/>',
169
- '<user / >',
170
- '<user color=\'red />'
171
- ] )( 'recognizes %s', token => {
172
- expect( isSelfClosingTag( token ) ).toBe( true );
173
- } );
174
-
175
- it.each( [
176
- '<user>',
177
- '</user>',
178
- '<!-- note -->',
179
- '< user/>',
180
- '<>',
181
- '<,/>',
182
- '<b,b/>',
183
- '<user,/>',
184
- '<1user/>',
185
- '<_user/>',
186
- '<üser/>',
187
- '</user/>',
188
- '<user/',
189
- '<user/> suffix',
190
- 'prefix <user/>',
191
- '<user/><system/>',
192
- '<user<other>/>',
193
- '<!DOCTYPE html />',
194
- '<?xml version="1.0"?>',
195
- '<user path="/tmp">',
196
- '<user path="/" >',
197
- 'plain text'
198
- ] )( 'rejects %s', token => {
199
- expect( isSelfClosingTag( token ) ).toBe( false );
200
- } );
201
- } );
202
-
203
- describe( 'isComment', () => {
204
- it.each( [
205
- '<!---->',
206
- '<!-- -->',
207
- '<!-- note -->',
208
- '<!-- first\nsecond -->',
209
- '<!-- <user>text</user> -->',
210
- '<!-- a > b and c < d -->'
211
- ] )( 'recognizes %s', token => {
212
- expect( isComment( token ) ).toBe( true );
213
- } );
214
-
215
- it.each( [
216
- '<!-->',
217
- '<! -- note -->',
218
- '<!-- unfinished',
219
- '<!-- note -- >',
220
- '<!-- note --!>',
221
- 'prefix <!-- note -->',
222
- '<!-- note --> suffix',
223
- '<user><!-- note --></user>',
224
- '<!-- first --><!-- second -->',
225
- '<!-- first -->\n<!-- second -->',
226
- '<!-- -->text<!-- -->'
227
- ] )( 'rejects %s', token => {
228
- expect( isComment( token ) ).toBe( false );
229
- } );
230
- } );
231
-
232
- describe( 'isEmptyText', () => {
233
- it.each( [
234
- '',
235
- ' ',
236
- '\t',
237
- '\n\n',
238
- ' \n\t '
239
- ] )( 'recognizes whitespace-only text', token => {
240
- expect( isEmptyText( token ) ).toBe( true );
241
- } );
242
-
243
- it.each( [
244
- 'text',
245
- ' text ',
246
- '<user>'
247
- ] )( 'rejects non-whitespace text', token => {
248
- expect( isEmptyText( token ) ).toBe( false );
249
- } );
250
- } );