@namzu/bedrock 4.0.0 → 4.0.1

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/CHANGELOG.md +29 -0
  2. package/package.json +12 -2
  3. package/dist/__tests__/bedrock.test.d.ts +0 -2
  4. package/dist/__tests__/bedrock.test.d.ts.map +0 -1
  5. package/dist/__tests__/bedrock.test.js +0 -94
  6. package/dist/__tests__/bedrock.test.js.map +0 -1
  7. package/dist/__tests__/error-taxonomy.test.d.ts +0 -17
  8. package/dist/__tests__/error-taxonomy.test.d.ts.map +0 -1
  9. package/dist/__tests__/error-taxonomy.test.js +0 -204
  10. package/dist/__tests__/error-taxonomy.test.js.map +0 -1
  11. package/dist/__tests__/model-reachability.test.d.ts +0 -2
  12. package/dist/__tests__/model-reachability.test.d.ts.map +0 -1
  13. package/dist/__tests__/model-reachability.test.js +0 -64
  14. package/dist/__tests__/model-reachability.test.js.map +0 -1
  15. package/dist/__tests__/prompt-cache.test.d.ts +0 -2
  16. package/dist/__tests__/prompt-cache.test.d.ts.map +0 -1
  17. package/dist/__tests__/prompt-cache.test.js +0 -68
  18. package/dist/__tests__/prompt-cache.test.js.map +0 -1
  19. package/dist/__tests__/thinking-refused.test.d.ts +0 -2
  20. package/dist/__tests__/thinking-refused.test.d.ts.map +0 -1
  21. package/dist/__tests__/thinking-refused.test.js +0 -35
  22. package/dist/__tests__/thinking-refused.test.js.map +0 -1
  23. package/dist/__tests__/tool-choice-none.test.d.ts +0 -2
  24. package/dist/__tests__/tool-choice-none.test.d.ts.map +0 -1
  25. package/dist/__tests__/tool-choice-none.test.js +0 -76
  26. package/dist/__tests__/tool-choice-none.test.js.map +0 -1
  27. package/dist/__tests__/tool-content-blocks.test.d.ts +0 -2
  28. package/dist/__tests__/tool-content-blocks.test.d.ts.map +0 -1
  29. package/dist/__tests__/tool-content-blocks.test.js +0 -92
  30. package/dist/__tests__/tool-content-blocks.test.js.map +0 -1
  31. package/dist/__tests__/tool-schema-dialect.test.d.ts +0 -2
  32. package/dist/__tests__/tool-schema-dialect.test.d.ts.map +0 -1
  33. package/dist/__tests__/tool-schema-dialect.test.js +0 -98
  34. package/dist/__tests__/tool-schema-dialect.test.js.map +0 -1
  35. package/dist/__tests__/vision.test.d.ts +0 -2
  36. package/dist/__tests__/vision.test.d.ts.map +0 -1
  37. package/dist/__tests__/vision.test.js +0 -77
  38. package/dist/__tests__/vision.test.js.map +0 -1
  39. package/src/__tests__/bedrock.test.ts +0 -103
  40. package/src/__tests__/error-taxonomy.test.ts +0 -248
  41. package/src/__tests__/model-reachability.test.ts +0 -74
  42. package/src/__tests__/prompt-cache.test.ts +0 -81
  43. package/src/__tests__/thinking-refused.test.ts +0 -44
  44. package/src/__tests__/tool-choice-none.test.ts +0 -87
  45. package/src/__tests__/tool-content-blocks.test.ts +0 -119
  46. package/src/__tests__/tool-schema-dialect.test.ts +0 -108
  47. package/src/__tests__/vision.test.ts +0 -98
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 48d9d67: Published tarballs no longer contain test files.
8
+
9
+ `files: ["dist", "src", ...]` reads as "the build output and the sources" and
10
+ means "everything the compiler emitted and everything in the tree", so every
11
+ compiled test, its declaration, and both source maps shipped to the registry —
12
+ and for the twelve packages that also ship `src`, the raw test sources went with
13
+ them.
14
+
15
+ Measured on the versions currently published:
16
+
17
+ | package | files | of which tests | unpacked |
18
+ | ------------ | ----------- | -------------- | ------------------ |
19
+ | `@namzu/sdk` | 3879 → 2239 | 1640 (42%) | 12.73 MB → 6.81 MB |
20
+ | `@namzu/cli` | 462 → 282 | 180 (39%) | 1.21 MB → 0.73 MB |
21
+
22
+ Nothing you can import changes. Every package restricts `exports` to `"."`, so
23
+ Node refused a deep subpath into those files already — they were weight in the
24
+ tarball and nothing else. Hence `patch`: there is no consumer-visible surface
25
+ here, only less to download.
26
+
27
+ The exclusions are at the packaging layer, not the compiler. Adding `exclude`
28
+ to `tsconfig.json` would have kept tests out of `dist` and also dropped them
29
+ from `tsc --noEmit`, silently ending type-checking of the entire test suite —
30
+ trading a packaging defect for a much worse one.
31
+
3
32
  ## 4.0.0
4
33
 
5
34
  ### Major Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namzu/bedrock",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "AWS Bedrock LLM provider for @namzu/sdk. Provides Converse API (chat + streaming) with full tool-use support.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "type": "module",
@@ -23,7 +23,17 @@
23
23
  },
24
24
  "files": [
25
25
  "dist",
26
+ "!dist/**/*.test.*",
27
+ "!dist/**/*.proc-test.*",
28
+ "!dist/**/__tests__",
29
+ "!dist/**/__fixtures__",
30
+ "!dist/**/test-setup.*",
26
31
  "src",
32
+ "!src/**/*.test.*",
33
+ "!src/**/*.proc-test.*",
34
+ "!src/**/__tests__",
35
+ "!src/**/__fixtures__",
36
+ "!src/**/test-setup.*",
27
37
  "LICENSE.md",
28
38
  "README.md",
29
39
  "CHANGELOG.md"
@@ -44,7 +54,7 @@
44
54
  "@types/node": "^22.19.17",
45
55
  "typescript": "^5.5.0",
46
56
  "vitest": "^3.2.6",
47
- "@namzu/sdk": "^6.0.0"
57
+ "@namzu/sdk": "^15.0.0"
48
58
  },
49
59
  "scripts": {
50
60
  "build": "tsc --build",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=bedrock.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bedrock.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/bedrock.test.ts"],"names":[],"mappings":""}
@@ -1,94 +0,0 @@
1
- import { DuplicateProviderError, ProviderRegistry } from '@namzu/sdk';
2
- import { beforeEach, describe, expect, it } from 'vitest';
3
- import { BEDROCK_CAPABILITIES, BedrockProvider, registerBedrock } from '../index.js';
4
- // Ensure a clean slate between tests. The sdk pre-registers 'mock' on import
5
- // via its sideEffects whitelist; we only need to clear 'bedrock' to make
6
- // re-registration deterministic across tests.
7
- beforeEach(() => {
8
- if (ProviderRegistry.isSupported('bedrock')) {
9
- ProviderRegistry.unregister('bedrock');
10
- }
11
- });
12
- describe('@namzu/bedrock', () => {
13
- describe('registerBedrock()', () => {
14
- it("adds 'bedrock' to the ProviderRegistry", () => {
15
- expect(ProviderRegistry.isSupported('bedrock')).toBe(false);
16
- registerBedrock();
17
- expect(ProviderRegistry.isSupported('bedrock')).toBe(true);
18
- expect(ProviderRegistry.listTypes()).toContain('bedrock');
19
- });
20
- it('throws DuplicateProviderError when called twice without options', () => {
21
- registerBedrock();
22
- expect(() => registerBedrock()).toThrowError(DuplicateProviderError);
23
- });
24
- it('allows re-registration when { replace: true } is passed', () => {
25
- registerBedrock();
26
- expect(() => registerBedrock({ replace: true })).not.toThrow();
27
- expect(ProviderRegistry.isSupported('bedrock')).toBe(true);
28
- });
29
- it('exposes capabilities through the registry after registration', () => {
30
- registerBedrock();
31
- const caps = ProviderRegistry.getCapabilities('bedrock');
32
- expect(caps).toEqual(BEDROCK_CAPABILITIES);
33
- });
34
- });
35
- describe('BEDROCK_CAPABILITIES', () => {
36
- it('declares the expected capability flags', () => {
37
- expect(BEDROCK_CAPABILITIES).toEqual({
38
- supportsTools: true,
39
- supportsStreaming: true,
40
- supportsFunctionCalling: true,
41
- supportsVision: false,
42
- supportsDocuments: false,
43
- });
44
- });
45
- it('is exposed on the provider instance for runtime negotiation', () => {
46
- const provider = new BedrockProvider({ region: 'us-east-1' });
47
- expect(provider.capabilities).toEqual(BEDROCK_CAPABILITIES);
48
- });
49
- });
50
- it('keeps the Namzu enforcement hint out of the Bedrock command', async () => {
51
- const provider = new BedrockProvider({ region: 'us-east-1' });
52
- let commandInput;
53
- provider.client = {
54
- send: async (command) => {
55
- commandInput = command.input;
56
- return {
57
- $metadata: { requestId: 'request-test' },
58
- stream: (async function* () { })(),
59
- };
60
- },
61
- };
62
- for await (const _chunk of provider.chatStream({
63
- model: 'anthropic.claude-sonnet-5-v1:0',
64
- messages: [{ role: 'user', content: 'edit' }],
65
- tools: [
66
- {
67
- type: 'function',
68
- function: {
69
- name: 'edit',
70
- description: 'Edit',
71
- parameters: { type: 'object' },
72
- },
73
- },
74
- ],
75
- enforceToolInputSchema: ['edit'],
76
- })) {
77
- // Drain the empty test stream.
78
- }
79
- expect(commandInput).not.toHaveProperty('enforceToolInputSchema');
80
- expect(commandInput?.toolConfig).toEqual({
81
- tools: [
82
- {
83
- toolSpec: {
84
- name: 'edit',
85
- description: 'Edit',
86
- inputSchema: { json: { type: 'object' } },
87
- },
88
- },
89
- ],
90
- toolChoice: { auto: {} },
91
- });
92
- });
93
- });
94
- //# sourceMappingURL=bedrock.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bedrock.test.js","sourceRoot":"","sources":["../../src/__tests__/bedrock.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AACzD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEpF,6EAA6E;AAC7E,yEAAyE;AACzE,8CAA8C;AAC9C,UAAU,CAAC,GAAG,EAAE;IACf,IAAI,gBAAgB,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7C,gBAAgB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;IACvC,CAAC;AACF,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC/B,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAClC,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;YACjD,MAAM,CAAC,gBAAgB,CAAC,WA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,sBAAsB,EAAE,CAAC,MAAM,CAAC;SAChC,CAAC,EAAE,CAAC;YACJ,+BAA+B;QAChC,CAAC;QAED,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAAA;QACjE,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,OAAO,CAAC;YACxC,KAAK,EAAE;gBACN;oBACC,QAAQ,EAAE;wBACT,IAAI,EAAE,MAAM;wBACZ,WAAW,EAAE,MAAM;wBACnB,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;qBACzC;iBACD;aACD;YACD,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;SACxB,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,17 +0,0 @@
1
- /**
2
- * Provider error taxonomy — Bedrock driver.
3
- *
4
- * `chatStream` awaits `this.client.send(command)` with no catch, so an AWS
5
- * `BedrockRuntimeServiceException` (`ThrottlingException`,
6
- * `ValidationException`, `ServiceUnavailableException`, …) escapes verbatim.
7
- * A caller cannot classify it without importing `@aws-sdk/client-bedrock-runtime`.
8
- *
9
- * Transport seam: `BedrockConfig` exposes no `requestHandler`/`endpoint`, so
10
- * unlike the fetch-based drivers there is nothing to inject at the HTTP
11
- * layer. The tests substitute the `BedrockRuntimeClient`'s `send` and reject
12
- * with the REAL AWS exception classes — which is exactly what the driver
13
- * sees from a live call, and the only surface the driver's (currently
14
- * absent) error mapping would act on.
15
- */
16
- export {};
17
- //# sourceMappingURL=error-taxonomy.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-taxonomy.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/error-taxonomy.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
@@ -1,204 +0,0 @@
1
- /**
2
- * Provider error taxonomy — Bedrock driver.
3
- *
4
- * `chatStream` awaits `this.client.send(command)` with no catch, so an AWS
5
- * `BedrockRuntimeServiceException` (`ThrottlingException`,
6
- * `ValidationException`, `ServiceUnavailableException`, …) escapes verbatim.
7
- * A caller cannot classify it without importing `@aws-sdk/client-bedrock-runtime`.
8
- *
9
- * Transport seam: `BedrockConfig` exposes no `requestHandler`/`endpoint`, so
10
- * unlike the fetch-based drivers there is nothing to inject at the HTTP
11
- * layer. The tests substitute the `BedrockRuntimeClient`'s `send` and reject
12
- * with the REAL AWS exception classes — which is exactly what the driver
13
- * sees from a live call, and the only surface the driver's (currently
14
- * absent) error mapping would act on.
15
- */
16
- import { AccessDeniedException, ModelErrorException, ServiceQuotaExceededException, ServiceUnavailableException, ThrottlingException, ValidationException, } from '@aws-sdk/client-bedrock-runtime';
17
- import { describe, expect, it } from 'vitest';
18
- import { BedrockProvider } from '../client.js';
19
- /** Replace the AWS client's `send` so it rejects with `err`. */
20
- function providerRejectingWith(err) {
21
- const provider = new BedrockProvider({ region: 'eu-west-1' });
22
- provider.client = {
23
- send: () => Promise.reject(err),
24
- };
25
- return provider;
26
- }
27
- function providerStreaming(...events) {
28
- const provider = new BedrockProvider({ region: 'eu-west-1' });
29
- provider.client = {
30
- send: async () => ({
31
- $metadata: { requestId: 'bedrock-test' },
32
- stream: (async function* () {
33
- yield* events;
34
- })(),
35
- }),
36
- };
37
- return provider;
38
- }
39
- async function captureChatStreamError(provider, signal) {
40
- try {
41
- for await (const _chunk of provider.chatStream({
42
- model: 'anthropic.claude-sonnet-4-5-20250929-v1:0',
43
- messages: [{ role: 'user', content: 'hi' }],
44
- signal,
45
- })) {
46
- // drain
47
- }
48
- }
49
- catch (err) {
50
- return err;
51
- }
52
- throw new Error('expected chatStream to throw');
53
- }
54
- describe('@namzu/bedrock — provider error taxonomy', () => {
55
- it('(a) ThrottlingException with `retry-after: 2` becomes a throttle-classified error carrying retryAfterMs', async () => {
56
- const aws = new ThrottlingException({
57
- message: 'Too many requests, please wait before trying again.',
58
- $metadata: { httpStatusCode: 429 },
59
- });
60
- aws.$response = {
61
- statusCode: 429,
62
- headers: { 'retry-after': '2' },
63
- };
64
- const err = await captureChatStreamError(providerRejectingWith(aws));
65
- expect(err).toMatchObject({
66
- name: 'ProviderRequestError',
67
- kind: 'throttle',
68
- status: 429,
69
- retryAfterMs: 2000,
70
- providerId: 'bedrock',
71
- });
72
- });
73
- it("(c) a ValidationException reporting too many input tokens classifies as 'context_overflow'", async () => {
74
- const aws = new ValidationException({
75
- message: 'Input is too long for requested model. The input token count exceeds the maximum for this model.',
76
- $metadata: { httpStatusCode: 400 },
77
- });
78
- const err = await captureChatStreamError(providerRejectingWith(aws));
79
- expect(err).toMatchObject({
80
- name: 'ProviderRequestError',
81
- kind: 'context_overflow',
82
- status: 400,
83
- providerId: 'bedrock',
84
- });
85
- });
86
- it("(c) a ValidationException that is not an overflow classifies as 'bad_request'", async () => {
87
- const aws = new ValidationException({
88
- message: 'The value at toolConfig.tools failed to satisfy constraint.',
89
- $metadata: { httpStatusCode: 400 },
90
- });
91
- const err = await captureChatStreamError(providerRejectingWith(aws));
92
- expect(err).toMatchObject({
93
- name: 'ProviderRequestError',
94
- kind: 'bad_request',
95
- status: 400,
96
- providerId: 'bedrock',
97
- });
98
- });
99
- it("an AccessDeniedException classifies as 'auth'", async () => {
100
- const aws = new AccessDeniedException({
101
- message: 'You do not have access to the model with the specified model ID.',
102
- $metadata: { httpStatusCode: 403 },
103
- });
104
- const err = await captureChatStreamError(providerRejectingWith(aws));
105
- expect(err).toMatchObject({
106
- name: 'ProviderRequestError',
107
- kind: 'auth',
108
- status: 403,
109
- providerId: 'bedrock',
110
- });
111
- });
112
- it("a ServiceUnavailableException classifies as 'server'", async () => {
113
- const aws = new ServiceUnavailableException({
114
- message: 'The service is unavailable, try again later.',
115
- $metadata: { httpStatusCode: 503 },
116
- });
117
- const err = await captureChatStreamError(providerRejectingWith(aws));
118
- expect(err).toMatchObject({
119
- name: 'ProviderRequestError',
120
- kind: 'server',
121
- status: 503,
122
- providerId: 'bedrock',
123
- });
124
- });
125
- it("a ModelErrorException with HTTP 424 still classifies as 'server'", async () => {
126
- const aws = new ModelErrorException({
127
- message: 'The model failed while processing the request.',
128
- originalStatusCode: 500,
129
- $metadata: { httpStatusCode: 424 },
130
- });
131
- const err = await captureChatStreamError(providerRejectingWith(aws));
132
- expect(err).toMatchObject({
133
- name: 'ProviderRequestError',
134
- kind: 'server',
135
- status: 424,
136
- providerId: 'bedrock',
137
- });
138
- });
139
- it("a ServiceQuotaExceededException classifies as 'throttle'", async () => {
140
- const aws = new ServiceQuotaExceededException({
141
- message: 'Account inference quota exceeded.',
142
- $metadata: { httpStatusCode: 400 },
143
- });
144
- const err = await captureChatStreamError(providerRejectingWith(aws));
145
- expect(err).toMatchObject({
146
- name: 'ProviderRequestError',
147
- kind: 'throttle',
148
- status: 400,
149
- providerId: 'bedrock',
150
- });
151
- });
152
- it('classifies a throttling exception delivered as a stream union event', async () => {
153
- const aws = new ThrottlingException({
154
- message: 'stream quota exceeded',
155
- $metadata: { httpStatusCode: 429 },
156
- });
157
- const err = await captureChatStreamError(providerStreaming({ throttlingException: aws }));
158
- expect(err).toMatchObject({
159
- name: 'ProviderRequestError',
160
- kind: 'throttle',
161
- status: 429,
162
- providerId: 'bedrock',
163
- });
164
- });
165
- it('keeps a validation stream event’s complaint, scrubbed, and still retains no cause', async () => {
166
- // This test used to assert the opposite half: that the vendor's sentence
167
- // was dropped whole. That was the safe-looking reading of "an error body
168
- // can echo a credential", and it cost a day of production downtime —
169
- // the wire had been naming the exact offending field the entire time and
170
- // the SDK deleted the sentence before anyone could read it.
171
- //
172
- // So the guarantee changed shape rather than weakening: what is scrubbed
173
- // is anything CREDENTIAL-SHAPED, and what survives is the complaint. The
174
- // `cause` half is unchanged and still matters — a `cause` survives every
175
- // logger that serializes an error chain, which is how the raw body would
176
- // get out regardless of what the message says.
177
- const key = 'AKIAIOSFODNN7EXAMPLE';
178
- const aws = new ValidationException({
179
- message: `inputSchema is invalid, echoed from key ${key}`,
180
- $metadata: { httpStatusCode: 400 },
181
- });
182
- const err = await captureChatStreamError(providerStreaming({ validationException: aws }));
183
- expect(err).toMatchObject({
184
- name: 'ProviderRequestError',
185
- kind: 'bad_request',
186
- providerId: 'bedrock',
187
- });
188
- expect(err.message).toContain('inputSchema is invalid');
189
- expect(err.message).not.toContain(key);
190
- expect('cause' in err).toBe(false);
191
- });
192
- it('preserves the caller abort reason when the SDK replaces the error object', async () => {
193
- const controller = new AbortController();
194
- const reason = new Error('user stopped');
195
- const sdkAbort = Object.assign(new Error('request aborted'), {
196
- name: 'AbortError',
197
- });
198
- controller.abort(reason);
199
- const err = await captureChatStreamError(providerRejectingWith(sdkAbort), controller.signal);
200
- expect(sdkAbort).not.toBe(reason);
201
- expect(err).toBe(reason);
202
- });
203
- });
204
- //# sourceMappingURL=error-taxonomy.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-taxonomy.test.js","sourceRoot":"","sources":["../../src/__tests__/error-taxonomy.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACN,qBAAqB,EACrB,mBAAmB,EACnB,6BAA6B,EAC7B,2BAA2B,EAC3B,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,iCAAiC,CAAA;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,gEAAgE;AAChE,SAAS,qBAAqB,CAAC,GAAY;IAC1C,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAC5D;IAAC,QAAkE,CAAC,MAAM,GAAG;QAC7E,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC;KAC/B,CAAA;IACD,OAAO,QAAQ,CAAA;AAChB,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAG,MAA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G,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACjC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACzB,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=model-reachability.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"model-reachability.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/model-reachability.test.ts"],"names":[],"mappings":""}
@@ -1,64 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { BedrockProvider } from '../client.js';
3
- import { assertModelReachable } from '../model-reachability.js';
4
- /**
5
- * This driver speaks Converse with ARN-versioned model ids. The current Claude
6
- * generation is served by a different Bedrock integration whose ids carry no
7
- * version suffix, and pointing this wire at one produced an opaque AWS
8
- * validation error naming neither the cause nor the remedy.
9
- */
10
- describe('model ids this wire can serve', () => {
11
- const reachable = [
12
- 'anthropic.claude-sonnet-4-5-20250929-v1:0',
13
- 'us.anthropic.claude-sonnet-4-5-20250929-v1:0',
14
- 'eu.anthropic.claude-opus-4-5-20251101-v1:0',
15
- 'global.anthropic.claude-opus-4-6-v1',
16
- 'apac.anthropic.claude-sonnet-4-20250514-v1:0',
17
- 'anthropic.claude-haiku-4-5-20251001-v1:0',
18
- ];
19
- for (const model of reachable) {
20
- it(`accepts ${model}`, () => {
21
- expect(() => assertModelReachable(model)).not.toThrow();
22
- });
23
- }
24
- const unreachable = [
25
- 'anthropic.claude-opus-5',
26
- 'anthropic.claude-sonnet-5',
27
- 'anthropic.claude-fable-5',
28
- 'anthropic.claude-opus-4-8',
29
- 'anthropic.claude-opus-4-7',
30
- 'us.anthropic.claude-opus-5',
31
- ];
32
- for (const model of unreachable) {
33
- it(`refuses ${model} and says why`, () => {
34
- expect(() => assertModelReachable(model)).toThrow(/cannot reach/);
35
- expect(() => assertModelReachable(model)).toThrow(/Converse API/);
36
- });
37
- }
38
- it('leaves a non-Claude model alone', () => {
39
- // This driver serves whatever Bedrock serves. The check is about one
40
- // vendor's id scheme, not about policing the catalogue.
41
- expect(() => assertModelReachable('amazon.nova-pro-v1:0')).not.toThrow();
42
- expect(() => assertModelReachable('meta.llama3-70b-instruct-v1:0')).not.toThrow();
43
- });
44
- it('accepts an unknown versioned Claude id', () => {
45
- // A model this file has never heard of passes as long as its id has
46
- // the shape this wire carries. A list that must be edited for every
47
- // new model is a list that is wrong before anyone reads it.
48
- expect(() => assertModelReachable('anthropic.claude-sonnet-9-20991231-v1:0')).not.toThrow();
49
- });
50
- });
51
- describe('the driver refuses before it calls AWS', () => {
52
- it('throws on an unreachable model with no credentials in play', async () => {
53
- const provider = new BedrockProvider({ region: 'us-east-1' });
54
- await expect(async () => {
55
- for await (const _ of provider.chatStream({
56
- model: 'anthropic.claude-opus-5',
57
- messages: [{ role: 'user', content: 'hi' }],
58
- })) {
59
- // drain
60
- }
61
- }).rejects.toThrow(/cannot reach "anthropic\.claude-opus-5"/);
62
- });
63
- });
64
- //# sourceMappingURL=model-reachability.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"model-reachability.test.js","sourceRoot":"","sources":["../../src/__tests__/model-reachability.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAE/D;;;;;GAKG;AAEH,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC9C,MAAM,SAAS,GAAG;QACjB,2CAA2C;QAC3C,8CAA8C;QAC9C,4CAA4C;QAC5C,qCAAqC;QACrC,8CAA8C;QAC9C,0CAA0C;KAC1C,CAAA;IAED,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC;QAC/B,EAAE,CAAC,WAAW,KAAK,EAAE,EAAE,GAAG,EA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AAC,4DAA4D,EAAE,KAAK,IAAI,EAAE;QAC3E,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC,EAAE,MAAM,EAAE,WAAW,EAAW,CAAC,CAAA;QAEtE,MAAM,MAAM,CAAC,KAAK,IAAI,EAAE;YACvB,IAAI,KAAK,EAAE,MAAM,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC;gBACzC,KAAK,EAAE,yBAAyB;gBAChC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;aACnB,CAAC,EAAE,CAAC;gBAC5B,QAAQ;YACT,CAAC;QACF,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,yCAAyC,CAAC,CAAA;IAC9D,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=prompt-cache.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompt-cache.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/prompt-cache.test.ts"],"names":[],"mappings":""}
@@ -1,68 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { parseBedrockUsage } from '../client.js';
3
- /**
4
- * Cache reads and cache writes are priced differently from ordinary input,
5
- * so folding either into the prompt count misreports what a run cost — and
6
- * misreports it silently, because the total still looks plausible.
7
- *
8
- * The counters are also the only evidence that the breakpoints are working
9
- * at all: a run whose cached count stays at zero is paying full price for
10
- * a prefix it believes is cached, and nothing else says so.
11
- */
12
- describe('cache counters are reported on their own axis', () => {
13
- it('keeps reads out of the prompt count', () => {
14
- const usage = parseBedrockUsage({
15
- inputTokens: 10,
16
- outputTokens: 2,
17
- cacheReadInputTokenCount: 900,
18
- });
19
- expect(usage.promptTokens).toBe(10);
20
- expect(usage.cachedTokens).toBe(900);
21
- });
22
- it('keeps writes on their own axis too', () => {
23
- const usage = parseBedrockUsage({
24
- inputTokens: 10,
25
- outputTokens: 2,
26
- cacheWriteInputTokenCount: 40,
27
- });
28
- expect(usage.cacheWriteTokens).toBe(40);
29
- expect(usage.promptTokens).toBe(10);
30
- });
31
- it('reports both when both happen in one turn', () => {
32
- const usage = parseBedrockUsage({
33
- inputTokens: 10,
34
- outputTokens: 2,
35
- cacheReadInputTokenCount: 900,
36
- cacheWriteInputTokenCount: 40,
37
- });
38
- expect(usage).toMatchObject({ cachedTokens: 900, cacheWriteTokens: 40 });
39
- });
40
- it('reads an absent counter as zero, not undefined', () => {
41
- const usage = parseBedrockUsage({ inputTokens: 5, outputTokens: 1 });
42
- // A consumer summing these must not have to guard every field; an
43
- // undefined here becomes NaN one addition later.
44
- expect(usage.cachedTokens).toBe(0);
45
- expect(usage.cacheWriteTokens).toBe(0);
46
- });
47
- it('totals input and output, and nothing else', () => {
48
- const usage = parseBedrockUsage({
49
- inputTokens: 10,
50
- outputTokens: 2,
51
- cacheReadInputTokenCount: 900,
52
- });
53
- // Cached reads are already counted upstream; adding them here would
54
- // double-count the same tokens in the run's own ledger.
55
- expect(usage.totalTokens).toBe(12);
56
- });
57
- it('reads a missing usage payload as all zeros', () => {
58
- const usage = parseBedrockUsage(undefined);
59
- expect(usage).toEqual({
60
- promptTokens: 0,
61
- completionTokens: 0,
62
- totalTokens: 0,
63
- cachedTokens: 0,
64
- cacheWriteTokens: 0,
65
- });
66
- });
67
- });
68
- //# sourceMappingURL=prompt-cache.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompt-cache.test.js","sourceRoot":"","sources":["../../src/__tests__/prompt-cache.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD;;;;;;;;GAQG;AAEH,QAAQ,CAAC,+CAA+C,EAAE,GAAG,EAAE;IAC9D,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC9C,MAA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,IAAI,CAAC,CAAC,CAAC,CAAA;QAClC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACpD,MAAM,KAAK,GAAG,iBAAiB,CAAC;YAC/B,WAAW,EAAE,EAAE;YACf,YAAY,EAAE,CAAC;YACf,wBAAwB,EAAE,GAAG;SAC7B,CAAC,CAAA;QAEF,oEAAoE;QACpE,wDAAwD;QACxD,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACnC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACrD,MAAM,KAAK,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAA;QAE1C,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;YACrB,YAAY,EAAE,CAAC;YACf,gBAAgB,EAAE,CAAC;YACnB,WAAW,EAAE,CAAC;YACd,YAAY,EAAE,CAAC;YACf,gBAAgB,EAAE,CAAC;SACnB,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=thinking-refused.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"thinking-refused.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/thinking-refused.test.ts"],"names":[],"mappings":""}
@@ -1,35 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { BedrockProvider } from '../client.js';
3
- /**
4
- * The shared guard's own tests pass whether or not this driver calls it, so
5
- * this drives the real `chatStream`. The defect being fixed was exactly a
6
- * declared parameter that no code path consumed — asserting the helper works
7
- * would have reproduced that shape one level up.
8
- *
9
- * The guard runs before any client work, so no credentials and no network are
10
- * involved: the request never gets that far.
11
- */
12
- const provider = new BedrockProvider({ region: 'us-east-1' });
13
- async function run(thinking) {
14
- for await (const _chunk of provider.chatStream({
15
- model: 'anthropic.claude-sonnet-4-5-20250929-v1:0',
16
- messages: [{ role: 'user', content: 'hi' }],
17
- ...(thinking ? { thinking } : {}),
18
- })) {
19
- // drain
20
- }
21
- }
22
- describe('BedrockProvider refuses a thinking request rather than dropping it', () => {
23
- it('throws on a manual thinking request', async () => {
24
- await expect(run({ type: 'enabled', budgetTokens: 10_000 })).rejects.toThrow(/BedrockProvider does not implement thinking/);
25
- });
26
- it('throws on an adaptive one', async () => {
27
- await expect(run({ type: 'adaptive' })).rejects.toThrow(/does not implement thinking/);
28
- });
29
- it('does not throw for an explicit disable', async () => {
30
- // Reaches the client and fails on credentials or network instead,
31
- // which is the point: the guard let it past.
32
- await expect(run({ type: 'disabled' })).rejects.not.toThrow(/does not implement thinking/);
33
- });
34
- });
35
- //# sourceMappingURL=thinking-refused.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"thinking-refused.test.js","sourceRoot":"","sources":["../../src/__tests__/thinking-refused.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C;;;;;;;;GAQG;AAEH,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC,EAAE,MAAM,EAAE,WAAW,EAAW,CAAC,CAAA;AAEtE,KAAK,UAAU,GAAG,CAAC,QAA2C;IAC7D,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,QAAQ,CAAC,UAAU,CAAC;QAC9C,KAAK,EAAE,2CAA2C;QAClD,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC3C,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACT,CAAC,EAAE,CAAC;QAC5B,QAAQ;IACT,CAAC;AACF,CAAC;AAED,QAAQ,CAAC,oEAAoE,EAAE,GAAG,EAAE;IACnF,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACpD,MAAM,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAC3E,6CAA6C,CAC7C,CAAA;IACF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QAC1C,MAAM,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAA;IACvF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACvD,kEAAkE;QAClE,6CAA6C;QAC7C,MAAM,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAA;IAC3F,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=tool-choice-none.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-choice-none.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/tool-choice-none.test.ts"],"names":[],"mappings":""}