@telemetry-dev/bedrock 0.1.0 → 0.1.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.
package/dist/agents.d.mts CHANGED
@@ -2,7 +2,7 @@ import { t as BedrockInstrumentationOptions } from "./internal-_ZoDhB3-.mjs";
2
2
 
3
3
  //#region src/agents.d.ts
4
4
  interface WrappableBedrockAgentClient {
5
- send: (...args: never[]) => unknown;
5
+ send: (...args: never[]) => any;
6
6
  }
7
7
  declare function wrapBedrockAgents<T extends WrappableBedrockAgentClient>(client: T, options?: BedrockInstrumentationOptions): T;
8
8
  declare function instrumentBedrockAgents(options?: BedrockInstrumentationOptions): void;
package/dist/agents.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { r as createInstrumentedSend, t as AGENT_HANDLERS } from "./internal-handlers-BloMjBP8.mjs";
1
+ import { r as createInstrumentedSend, t as AGENT_HANDLERS } from "./internal-handlers-CJPJo9q3.mjs";
2
2
  import { BedrockAgentRuntimeClient } from "@aws-sdk/client-bedrock-agent-runtime";
3
3
  //#region src/agents.ts
4
4
  const WRAPPED = /* @__PURE__ */ new WeakSet();
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import { t as BedrockInstrumentationOptions } from "./internal-_ZoDhB3-.mjs";
2
2
 
3
3
  //#region src/index.d.ts
4
4
  interface WrappableBedrockClient {
5
- send: (...args: never[]) => unknown;
5
+ send: (...args: never[]) => any;
6
6
  }
7
7
  declare function wrapBedrock<T extends WrappableBedrockClient>(client: T, options?: BedrockInstrumentationOptions): T;
8
8
  declare function instrumentBedrock(options?: BedrockInstrumentationOptions): void;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as RUNTIME_HANDLERS, r as createInstrumentedSend } from "./internal-handlers-BloMjBP8.mjs";
1
+ import { n as RUNTIME_HANDLERS, r as createInstrumentedSend } from "./internal-handlers-CJPJo9q3.mjs";
2
2
  import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime";
3
3
  //#region src/index.ts
4
4
  const WRAPPED = /* @__PURE__ */ new WeakSet();
@@ -4,60 +4,64 @@ const PROVIDER = "amazon-bedrock";
4
4
  const STREAM_FINALIZER = typeof FinalizationRegistry === "function" ? new FinalizationRegistry((finish) => finish()) : void 0;
5
5
  function createInstrumentedSend(originalSend, options, handlers) {
6
6
  return function instrumentedSend(command, ...rest) {
7
- const name = command?.constructor?.name;
8
- const handler = typeof name === "string" ? handlers[name] : void 0;
9
- if (!handler) return originalSend.apply(this, [command, ...rest]);
10
- const input = commandInput(command);
7
+ const rawCommand = asJsonValue(command);
8
+ const rawRest = rest.map(asJsonValue);
9
+ const name = isRecord(rawCommand) ? rawCommand.constructor?.name : void 0;
10
+ const handler = String(name) === name ? handlers[name] : void 0;
11
+ if (!handler) return originalSend.apply(this, [rawCommand, ...rawRest]);
12
+ const input = commandInput(rawCommand);
11
13
  const t0 = performance.now();
12
14
  const spanType = safe(() => handler.spanType(input)) ?? "span";
13
15
  const span = startSpan(safe(() => handler.spanName(input)) ?? name ?? "bedrock", {
14
16
  type: spanType,
15
17
  ...safe(() => handler.requestFields(input, options)) ?? {}
16
18
  });
17
- const callbackIndex = rest.findIndex((arg) => typeof arg === "function");
19
+ const callbackIndex = rawRest.findIndex((arg) => arg instanceof Function);
18
20
  if (callbackIndex !== -1) {
19
- const callback = rest[callbackIndex];
20
- const wrappedRest = [...rest];
21
+ const callback = rawRest[callbackIndex];
22
+ const wrappedRest = [...rawRest];
21
23
  wrappedRest[callbackIndex] = (error, data) => {
22
- if (error != null) {
24
+ const rawError = error;
25
+ const rawData = data;
26
+ if (rawError != null) {
23
27
  endSpan(span, {
24
- ...awsMetadataFields(metadataOf(error)),
25
- error
28
+ ...awsMetadataFields(metadataOf(rawError)),
29
+ error: asError(rawError)
26
30
  });
27
- callback(error, data);
31
+ callback(asJsonValue(rawError), asJsonValue(rawData));
28
32
  return;
29
33
  }
30
- let nextData = data;
34
+ let nextData = asJsonValue(rawData);
31
35
  try {
32
- nextData = handler.onResult(data, span, t0, input, options);
36
+ nextData = handler.onResult(asJsonValue(rawData), span, t0, input, options);
33
37
  } catch {
34
- endSpan(span, awsMetadataFields(metadataOf(data)));
38
+ endSpan(span, awsMetadataFields(metadataOf(rawData)));
35
39
  }
36
- callback(error, nextData);
40
+ callback(asJsonValue(rawError), asJsonValue(nextData));
37
41
  };
38
42
  try {
39
- return originalSend.apply(this, [command, ...wrappedRest]);
43
+ return originalSend.apply(this, [rawCommand, ...wrappedRest]);
40
44
  } catch (error) {
41
45
  endSpan(span, {
42
46
  ...awsMetadataFields(metadataOf(error)),
43
- error
47
+ error: asError(error)
44
48
  });
45
49
  throw error;
46
50
  }
47
51
  }
48
52
  let result;
49
53
  try {
50
- result = originalSend.apply(this, [command, ...rest]);
54
+ result = originalSend.apply(this, [rawCommand, ...rawRest]);
51
55
  } catch (error) {
52
56
  endSpan(span, {
53
57
  ...awsMetadataFields(metadataOf(error)),
54
- error
58
+ error: asError(error)
55
59
  });
56
60
  throw error;
57
61
  }
58
62
  return Promise.resolve(result).then((resolved) => {
59
63
  try {
60
- return handler.onResult(resolved, span, t0, input, options);
64
+ return handler.onResult(asJsonValue(resolved), span, t0, input, options);
61
65
  } catch {
62
66
  endSpan(span, awsMetadataFields(metadataOf(resolved)));
63
67
  return resolved;
@@ -65,18 +69,18 @@ function createInstrumentedSend(originalSend, options, handlers) {
65
69
  }, (error) => {
66
70
  endSpan(span, {
67
71
  ...awsMetadataFields(metadataOf(error)),
68
- error
72
+ error: asError(error)
69
73
  });
70
74
  throw error;
71
75
  });
72
76
  };
73
77
  }
74
78
  function commandInput(command) {
75
- const value = command?.input;
76
- return isRecord(value) ? value : {};
79
+ if (!isRecord(command)) return {};
80
+ return isRecord(command.input) ? command.input : {};
77
81
  }
78
82
  function isRecord(value) {
79
- return value !== null && typeof value === "object" && !Array.isArray(value);
83
+ return value !== null && Object(value) === value && !Array.isArray(value);
80
84
  }
81
85
  function safe(fn) {
82
86
  try {
@@ -96,8 +100,8 @@ function updateSpan(span, fields) {
96
100
  } catch {}
97
101
  }
98
102
  function metadataOf(value) {
99
- if (isRecord(value) && isRecord(value.$metadata)) return value.$metadata;
100
- return value?.$metadata;
103
+ if (!isRecord(value)) return void 0;
104
+ return value.$metadata;
101
105
  }
102
106
  function modeledStreamError(event) {
103
107
  for (const [key, name] of Object.entries({
@@ -126,11 +130,12 @@ function modeledStreamError(event) {
126
130
  }
127
131
  }
128
132
  function awsMetadataFields(metadata) {
129
- if (!isRecord(metadata)) return {};
130
- const requestId = stringValue(metadata.requestId);
131
- const attempts = numberValue(metadata.attempts);
132
- const httpStatusCode = numberValue(metadata.httpStatusCode);
133
- const totalRetryDelay = numberValue(metadata.totalRetryDelay);
133
+ const raw = metadata;
134
+ if (!isRecord(raw)) return {};
135
+ const requestId = stringValue(raw.requestId);
136
+ const attempts = numberValue(raw.attempts);
137
+ const httpStatusCode = numberValue(raw.httpStatusCode);
138
+ const totalRetryDelay = numberValue(raw.totalRetryDelay);
134
139
  const attributes = {};
135
140
  if (httpStatusCode !== void 0) attributes["aws.http.status_code"] = httpStatusCode;
136
141
  if (attempts !== void 0 && attempts > 1) attributes["aws.request.attempts"] = attempts;
@@ -165,30 +170,33 @@ function omitUndefined(value) {
165
170
  return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0));
166
171
  }
167
172
  function stringValue(value) {
168
- return typeof value === "string" && value.length > 0 ? value : void 0;
173
+ const raw = value;
174
+ return String(raw) === raw && raw.length > 0 ? raw : void 0;
169
175
  }
170
176
  function numberValue(value) {
171
- return typeof value === "number" && Number.isFinite(value) ? value : void 0;
177
+ const raw = value;
178
+ return Number(raw) === raw && Number.isFinite(raw) ? raw : void 0;
172
179
  }
173
180
  function arrayValue(value) {
174
181
  return Array.isArray(value) ? value : void 0;
175
182
  }
176
183
  function bytesToString(value) {
177
- if (typeof value === "string") return value;
178
- if (value instanceof Uint8Array) return new TextDecoder().decode(value);
179
- if (ArrayBuffer.isView(value)) return new TextDecoder().decode(value);
184
+ const raw = value;
185
+ if (String(raw) === raw) return raw;
186
+ if (raw instanceof Uint8Array) return new TextDecoder().decode(raw);
187
+ if (ArrayBuffer.isView(raw)) return new TextDecoder().decode(new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength));
180
188
  }
181
189
  function parseJson(value) {
182
190
  const text = bytesToString(value);
183
191
  if (text === void 0) return void 0;
184
192
  try {
185
- return JSON.parse(text);
193
+ return asJsonValue(JSON.parse(text));
186
194
  } catch {
187
195
  return;
188
196
  }
189
197
  }
190
198
  function wrapAsyncIterable(iterable, state, span, t0, baseFields) {
191
- if (!iterable || typeof iterable[Symbol.asyncIterator] !== "function") {
199
+ if (!iterable || !isAsyncIterable(iterable)) {
192
200
  endSpan(span, baseFields);
193
201
  return iterable;
194
202
  }
@@ -201,11 +209,10 @@ function wrapAsyncIterable(iterable, state, span, t0, baseFields) {
201
209
  STREAM_FINALIZER?.unregister(unregisterToken);
202
210
  endSpan(span, mergeFields(baseFields, fields));
203
211
  };
204
- const source = iterable;
205
212
  const generator = async function* () {
206
213
  let completed = false;
207
214
  try {
208
- for await (const event of source) {
215
+ for await (const event of iterable) {
209
216
  if (!first) {
210
217
  first = true;
211
218
  updateSpan(span, { timeToFirstChunkMs: performance.now() - t0 });
@@ -215,7 +222,7 @@ function wrapAsyncIterable(iterable, state, span, t0, baseFields) {
215
222
  }
216
223
  completed = true;
217
224
  } catch (error) {
218
- endOnce(mergeFields(state.finish(true), awsMetadataFields(metadataOf(error)), { error }));
225
+ endOnce(mergeFields(state.finish(true), awsMetadataFields(metadataOf(error)), { error: asError(error) }));
219
226
  throw error;
220
227
  } finally {
221
228
  if (!ended) endOnce(state.finish(!completed));
@@ -232,6 +239,15 @@ function wrapAsyncIterable(iterable, state, span, t0, baseFields) {
232
239
  STREAM_FINALIZER?.register(wrapped, finishAbandoned, unregisterToken);
233
240
  return wrapped;
234
241
  }
242
+ function isAsyncIterable(value) {
243
+ return Object(value) === value && Symbol.asyncIterator in Object(value);
244
+ }
245
+ function asJsonValue(value) {
246
+ return value;
247
+ }
248
+ function asError(value) {
249
+ return value instanceof Error ? value : new Error(String(value));
250
+ }
235
251
  function basenameArn(value) {
236
252
  const text = stringValue(value);
237
253
  if (!text) return void 0;
@@ -286,23 +302,24 @@ var AgentStreamState = class {
286
302
  this.options = options;
287
303
  }
288
304
  feed(event) {
289
- if (!isRecord(event)) return;
290
- const streamError = modeledStreamError(event);
305
+ const raw = event;
306
+ if (!isRecord(raw)) return;
307
+ const streamError = modeledStreamError(raw);
291
308
  if (streamError) {
292
309
  this.error = streamError.error;
293
310
  this.errorFields = streamError.fields;
294
311
  return;
295
312
  }
296
- const chunk = isRecord(event.chunk) ? event.chunk : void 0;
313
+ const chunk = isRecord(raw.chunk) ? raw.chunk : void 0;
297
314
  const bytes = chunk?.bytes;
298
315
  if (bytes !== void 0) this.text += bytesToString(bytes) ?? "";
299
316
  const citations = arrayValue((isRecord(chunk?.attribution) ? chunk.attribution : void 0)?.citations);
300
317
  if (citations) this.citationCount += citations.length;
301
- const files = isRecord(event.files) ? arrayValue(event.files.files) : void 0;
318
+ const files = isRecord(raw.files) ? arrayValue(raw.files.files) : void 0;
302
319
  if (files) this.outputFiles.push(...files.map(sanitizeOutputFile));
303
- const returnControl = isRecord(event.returnControl) ? event.returnControl : void 0;
320
+ const returnControl = isRecord(raw.returnControl) ? raw.returnControl : void 0;
304
321
  if (returnControl) this.returnControl = returnControl;
305
- const traceEvent = isRecord(event.trace) ? event.trace : void 0;
322
+ const traceEvent = isRecord(raw.trace) ? raw.trace : void 0;
306
323
  if (traceEvent) {
307
324
  this.traceEventCount += 1;
308
325
  if (this.options.captureAgentTrace) this.traces.push(traceEvent);
@@ -337,10 +354,11 @@ var AgentStreamState = class {
337
354
  }), this.errorFields);
338
355
  }
339
356
  addUsage(value) {
340
- if (!isRecord(value)) return;
341
- const inputTokens = numberValue(value.inputTokens);
342
- const outputTokens = numberValue(value.outputTokens);
343
- const totalTokens = numberValue(value.totalTokens);
357
+ const raw = value;
358
+ if (!isRecord(raw)) return;
359
+ const inputTokens = numberValue(raw.inputTokens);
360
+ const outputTokens = numberValue(raw.outputTokens);
361
+ const totalTokens = numberValue(raw.totalTokens);
344
362
  if (inputTokens !== void 0) this.usage.inputTokens = (this.usage.inputTokens ?? 0) + inputTokens;
345
363
  if (outputTokens !== void 0) this.usage.outputTokens = (this.usage.outputTokens ?? 0) + outputTokens;
346
364
  if (totalTokens !== void 0) this.usage.totalTokens = (this.usage.totalTokens ?? 0) + totalTokens;
@@ -348,10 +366,11 @@ var AgentStreamState = class {
348
366
  }
349
367
  };
350
368
  function sanitizeOutputFile(value) {
351
- if (!isRecord(value)) return value;
369
+ const raw = value;
370
+ if (!isRecord(raw)) return void 0;
352
371
  return omitUndefined({
353
- name: stringValue(value.name),
354
- type: stringValue(value.type)
372
+ name: stringValue(raw.name),
373
+ type: stringValue(raw.type)
355
374
  });
356
375
  }
357
376
  function retrieveRequestFields(input) {
@@ -362,7 +381,8 @@ function retrieveRequestFields(input) {
362
381
  });
363
382
  }
364
383
  function retrieveResponseFields(output) {
365
- const result = isRecord(output) ? output : {};
384
+ const raw = output;
385
+ const result = isRecord(raw) ? raw : {};
366
386
  const retrievalResults = arrayValue(result.retrievalResults);
367
387
  return mergeFields(awsMetadataFields(result.$metadata), {
368
388
  output: retrievalResults,
@@ -394,7 +414,8 @@ function ragRequestFields(input) {
394
414
  });
395
415
  }
396
416
  function ragResponseFields(output) {
397
- const result = isRecord(output) ? output : {};
417
+ const raw = output;
418
+ const result = isRecord(raw) ? raw : {};
398
419
  const text = isRecord(result.output) ? stringValue(result.output.text) : void 0;
399
420
  return mergeFields(awsMetadataFields(result.$metadata), {
400
421
  output: text ? [{
@@ -418,17 +439,18 @@ var RagStreamState = class {
418
439
  error;
419
440
  errorFields;
420
441
  feed(event) {
421
- if (!isRecord(event)) return;
422
- const streamError = modeledStreamError(event);
442
+ const raw = event;
443
+ if (!isRecord(raw)) return;
444
+ const streamError = modeledStreamError(raw);
423
445
  if (streamError) {
424
446
  this.error = streamError.error;
425
447
  this.errorFields = streamError.fields;
426
448
  return;
427
449
  }
428
- const output = isRecord(event.output) ? event.output : void 0;
450
+ const output = isRecord(raw.output) ? raw.output : void 0;
429
451
  this.text += stringValue(output?.text) ?? "";
430
- if (event.citation) this.citationCount += 1;
431
- const guardrail = isRecord(event.guardrail) ? event.guardrail : void 0;
452
+ if (raw.citation) this.citationCount += 1;
453
+ const guardrail = isRecord(raw.guardrail) ? raw.guardrail : void 0;
432
454
  this.guardrailAction = stringValue(guardrail?.action) ?? this.guardrailAction;
433
455
  }
434
456
  finish() {
@@ -461,18 +483,19 @@ var FlowStreamState = class {
461
483
  error;
462
484
  errorFields;
463
485
  feed(event) {
464
- if (!isRecord(event)) return;
465
- const streamError = modeledStreamError(event);
486
+ const raw = event;
487
+ if (!isRecord(raw)) return;
488
+ const streamError = modeledStreamError(raw);
466
489
  if (streamError) {
467
490
  this.error = streamError.error;
468
491
  this.errorFields = streamError.fields;
469
492
  return;
470
493
  }
471
- const output = isRecord(event.flowOutputEvent) ? event.flowOutputEvent : void 0;
494
+ const output = isRecord(raw.flowOutputEvent) ? raw.flowOutputEvent : void 0;
472
495
  if (output) this.outputs.push(output.content);
473
- const inputRequest = isRecord(event.flowMultiTurnInputRequestEvent) ? event.flowMultiTurnInputRequestEvent : void 0;
496
+ const inputRequest = isRecord(raw.flowMultiTurnInputRequestEvent) ? raw.flowMultiTurnInputRequestEvent : void 0;
474
497
  if (inputRequest) this.outputs.push(inputRequest.content);
475
- const completion = isRecord(event.flowCompletionEvent) ? event.flowCompletionEvent : void 0;
498
+ const completion = isRecord(raw.flowCompletionEvent) ? raw.flowCompletionEvent : void 0;
476
499
  this.completionReason = stringValue(completion?.completionReason) ?? this.completionReason;
477
500
  }
478
501
  finish() {
@@ -490,16 +513,18 @@ function ragName(input) {
490
513
  return `retrieve_and_generate ${basenameArn(ragModel(input)) ?? "knowledge-base"}`;
491
514
  }
492
515
  function collectTrace(value, onUsage) {
493
- if (!isRecord(value)) return;
494
- const output = isRecord(value.modelInvocationOutput) ? value.modelInvocationOutput : void 0;
516
+ const raw = value;
517
+ if (!isRecord(raw)) return;
518
+ const output = isRecord(raw.modelInvocationOutput) ? raw.modelInvocationOutput : void 0;
495
519
  if (output) onUsage((isRecord(output.metadata) ? output.metadata : void 0)?.usage);
496
- for (const child of Object.values(value)) if (isRecord(child)) collectTrace(child, onUsage);
520
+ for (const child of Object.values(raw)) if (isRecord(child)) collectTrace(child, onUsage);
497
521
  else if (Array.isArray(child)) child.forEach((item) => collectTrace(item, onUsage));
498
522
  }
499
523
  function findKey(value, key) {
500
- if (!isRecord(value)) return void 0;
501
- if (value[key] !== void 0) return value[key];
502
- for (const child of Object.values(value)) {
524
+ const raw = value;
525
+ if (!isRecord(raw)) return void 0;
526
+ if (raw[key] !== void 0) return raw[key];
527
+ for (const child of Object.values(raw)) {
503
528
  const found = findKey(child, key);
504
529
  if (found !== void 0) return found;
505
530
  }
@@ -635,10 +660,13 @@ function normalizeContentBlock(block) {
635
660
  if (citationsContent) {
636
661
  const contentBlocks = arrayValue(citationsContent.content) ?? [];
637
662
  const citations = arrayValue(citationsContent.citations);
638
- return contentBlocks.flatMap((contentBlock) => normalizeContentBlock(citations ? {
639
- ...contentBlock,
640
- citations
641
- } : contentBlock));
663
+ return contentBlocks.flatMap((contentBlock) => {
664
+ if (!citations) return normalizeContentBlock(contentBlock);
665
+ return normalizeContentBlock({
666
+ ...contentBlock,
667
+ citations
668
+ });
669
+ });
642
670
  }
643
671
  const guardContent = isRecord(block.guardContent) ? block.guardContent : void 0;
644
672
  if (guardContent) {
@@ -662,8 +690,9 @@ function normalizeContentBlock(block) {
662
690
  }
663
691
  function simplifyToolResult(content) {
664
692
  const blocks = arrayValue(content);
665
- if (!blocks) return content;
666
- if (blocks.length === 1 && typeof blocks[0]?.text === "string") return blocks[0].text;
693
+ if (!blocks) return isJsonValue(content) ? content : void 0;
694
+ const text = stringValue(blocks[0]?.text);
695
+ if (blocks.length === 1 && text !== void 0) return text;
667
696
  return blocks.flatMap((block) => normalizeContentBlock(block));
668
697
  }
669
698
  function s3Uri(value) {
@@ -725,14 +754,16 @@ var ConverseStreamState = class {
725
754
  kind: "text",
726
755
  text: ""
727
756
  };
728
- if (typeof delta.text === "string") {
757
+ const text = stringValue(delta.text);
758
+ if (text !== void 0) {
729
759
  block.kind = "text";
730
- block.text = `${block.text ?? ""}${delta.text}`;
760
+ block.text = `${block.text ?? ""}${text}`;
731
761
  }
732
762
  const toolUse = isRecord(delta.toolUse) ? delta.toolUse : void 0;
733
- if (toolUse && typeof toolUse.input === "string") {
763
+ const input = stringValue(toolUse?.input);
764
+ if (toolUse && input !== void 0) {
734
765
  block.kind = "tool";
735
- block.input = `${block.input ?? ""}${toolUse.input}`;
766
+ block.input = `${block.input ?? ""}${input}`;
736
767
  }
737
768
  const reasoning = isRecord(delta.reasoningContent) ? delta.reasoningContent : void 0;
738
769
  if (reasoning) {
@@ -799,6 +830,9 @@ var ConverseStreamState = class {
799
830
  }), this.errorFields);
800
831
  }
801
832
  };
833
+ function isJsonValue(value) {
834
+ return value == null || String(value) === value || Number(value) === value || Boolean(value) === value || Array.isArray(value) || isRecord(value);
835
+ }
802
836
  function blockToPart(block) {
803
837
  if (block.kind === "tool") return omitUndefined({
804
838
  type: "tool_call",
@@ -857,7 +891,7 @@ function nativeSamplingFields(model, body) {
857
891
  temperature: numberValue(cfg.temperature),
858
892
  topP: numberValue(cfg.topP),
859
893
  maxTokens: numberValue(cfg.maxTokenCount),
860
- stopSequences: Array.isArray(cfg.stopSequences) ? cfg.stopSequences : void 0
894
+ stopSequences: arrayValue(cfg.stopSequences)
861
895
  });
862
896
  }
863
897
  if (lower.includes("amazon.nova")) {
@@ -867,7 +901,7 @@ function nativeSamplingFields(model, body) {
867
901
  topP: numberValue(cfg.topP) ?? numberValue(cfg.top_p),
868
902
  topK: numberValue(cfg.topK),
869
903
  maxTokens: numberValue(cfg.maxTokens) ?? numberValue(cfg.max_new_tokens),
870
- stopSequences: Array.isArray(cfg.stopSequences) ? cfg.stopSequences : void 0
904
+ stopSequences: arrayValue(cfg.stopSequences)
871
905
  });
872
906
  }
873
907
  if (lower.includes("anthropic.claude")) return omitUndefined({
@@ -875,7 +909,7 @@ function nativeSamplingFields(model, body) {
875
909
  topP: numberValue(body.top_p),
876
910
  topK: numberValue(body.top_k),
877
911
  maxTokens: numberValue(body.max_tokens),
878
- stopSequences: Array.isArray(body.stop_sequences) ? body.stop_sequences : void 0
912
+ stopSequences: arrayValue(body.stop_sequences)
879
913
  });
880
914
  if (lower.includes("meta.llama")) return omitUndefined({
881
915
  temperature: numberValue(body.temperature),
@@ -967,8 +1001,9 @@ function headerUsageFields(metadata) {
967
1001
  return { usage: Object.keys(usage).length > 0 ? usage : void 0 };
968
1002
  }
969
1003
  function headerNumber(value) {
970
- if (typeof value === "string") {
971
- const parsed = Number.parseInt(value, 10);
1004
+ const text = stringValue(value);
1005
+ if (text !== void 0) {
1006
+ const parsed = Number.parseInt(text, 10);
972
1007
  return Number.isFinite(parsed) ? parsed : void 0;
973
1008
  }
974
1009
  return numberValue(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telemetry-dev/bedrock",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "AWS Bedrock instrumentation for telemetry.dev: Converse, InvokeModel, and Bedrock Agents spans for AWS SDK v3 clients.",
5
5
  "keywords": [
6
6
  "aws",
@@ -49,17 +49,17 @@
49
49
  "@smithy/eventstream-codec": "^4.2.5",
50
50
  "@smithy/protocol-http": "^5.3.10",
51
51
  "@smithy/types": "^4.12.0",
52
+ "@telemetry-dev/sdk": "^0.1.1",
52
53
  "@types/node": "^25.5.0",
53
54
  "@typescript/native-preview": "7.0.0-dev.20260328.1",
54
55
  "typescript": "^6.0.2",
55
56
  "vite-plus": "0.1.20",
56
- "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.20",
57
- "@telemetry-dev/sdk": "^0.1.0"
57
+ "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.20"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@aws-sdk/client-bedrock-agent-runtime": ">=3.600.0 <4",
61
61
  "@aws-sdk/client-bedrock-runtime": ">=3.600.0 <4",
62
- "@telemetry-dev/sdk": "^0.1.0"
62
+ "@telemetry-dev/sdk": "^0.1.1"
63
63
  },
64
64
  "peerDependenciesMeta": {
65
65
  "@aws-sdk/client-bedrock-agent-runtime": {