weflayr 0.26.1 → 0.27.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.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weflayr",
3
- "version": "0.26.1",
3
+ "version": "0.27.0",
4
4
  "description": "Weflayr JS/TS SDK — instrument any LLM client",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "generate-api": "openapi-ts && node scripts/generate_facade.mjs",
14
14
  "pretest": "npm run build",
15
15
  "prepublishOnly": "npm run build",
16
- "test": "node --test",
16
+ "test": "node --test \"dist/tests/**/*.test.js\"",
17
17
  "lint": "eslint src tests",
18
18
  "lint:fix": "eslint src tests --fix",
19
19
  "format": "prettier --write src tests",
@@ -31,19 +31,22 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@opentelemetry/api": "^1.9.1",
34
- "@opentelemetry/exporter-trace-otlp-http": "^0.219.0",
35
- "@opentelemetry/instrumentation": "^0.219.0",
34
+ "@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
35
+ "@opentelemetry/instrumentation": "^0.221.0",
36
36
  "@opentelemetry/resources": "^2.8.0",
37
37
  "@opentelemetry/sdk-trace-base": "^2.8.0",
38
38
  "@opentelemetry/sdk-trace-node": "^2.8.0",
39
39
  "async-retry": "^1.3.3"
40
40
  },
41
+ "overrides": {
42
+ "js-yaml": "^4.3.1"
43
+ },
41
44
  "devDependencies": {
42
45
  "@hey-api/openapi-ts": "^0.99.0",
43
46
  "@opentelemetry/context-async-hooks": "^2.8.0",
44
47
  "@types/async-retry": "^1.4.9",
45
48
  "@types/node": "^26.1.1",
46
- "eslint": "^9.18.0",
49
+ "eslint": "^10.8.0",
47
50
  "prettier": "^3.4.2",
48
51
  "typescript": "^6.0.3",
49
52
  "typescript-eslint": "^8.65.0"
@@ -11,16 +11,44 @@
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.BedrockInputMessageContentInstrumentor = void 0;
14
+ const _MEDIA_BLOCK_TYPES = ['image', 'document', 'video', 'audio'];
15
+ // A byte-less stub for a media content block, null when the block is not media.
16
+ // Anthropic-on-Bedrock names the media under `type` and carries its mime type in
17
+ // `source.media_type`; Nova puts the media under its own key
18
+ // (`{"image": {"format": "png", "source": {...}}}`) and states no mime type.
19
+ function _getMediaStubPart(block) {
20
+ if (_MEDIA_BLOCK_TYPES.includes(block.type)) {
21
+ const source = block.source;
22
+ const mediaType = source && typeof source === 'object' ? source.media_type : null;
23
+ return { type: 'blob', mime_type: String(mediaType || '') };
24
+ }
25
+ if (_MEDIA_BLOCK_TYPES.some((media) => block[media] && typeof block[media] === 'object')) {
26
+ return { type: 'blob', mime_type: '' };
27
+ }
28
+ return null;
29
+ }
30
+ // Text blocks keep their text; media blocks become a byte-less stub, so the
31
+ // payload stays off the span while the analyses reading these messages still see
32
+ // that the call carried content the stored text does not.
14
33
  function _contentToParts(content) {
15
34
  if (typeof content === 'string') {
16
35
  return [{ type: 'text', content }];
17
36
  }
18
- if (Array.isArray(content)) {
19
- return content
20
- .filter((block) => block && typeof block.text === 'string')
21
- .map((block) => ({ type: 'text', content: block.text }));
37
+ if (!Array.isArray(content))
38
+ return [];
39
+ const parts = [];
40
+ for (const block of content) {
41
+ if (!block || typeof block !== 'object')
42
+ continue;
43
+ if (typeof block.text === 'string') {
44
+ parts.push({ type: 'text', content: block.text });
45
+ continue;
46
+ }
47
+ const mediaStubPart = _getMediaStubPart(block);
48
+ if (mediaStubPart !== null)
49
+ parts.push(mediaStubPart);
22
50
  }
23
- return [];
51
+ return parts;
24
52
  }
25
53
  // Messages in the role+parts shape from an InvokeModel JSON body — the
26
54
  // `messages` schema (Nova, Anthropic-on-Bedrock) or the flat `inputText` /
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weflayr",
3
- "version": "0.26.1",
3
+ "version": "0.27.0",
4
4
  "description": "Weflayr JS/TS SDK — instrument any LLM client",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "generate-api": "openapi-ts && node scripts/generate_facade.mjs",
14
14
  "pretest": "npm run build",
15
15
  "prepublishOnly": "npm run build",
16
- "test": "node --test",
16
+ "test": "node --test \"dist/tests/**/*.test.js\"",
17
17
  "lint": "eslint src tests",
18
18
  "lint:fix": "eslint src tests --fix",
19
19
  "format": "prettier --write src tests",
@@ -31,19 +31,22 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@opentelemetry/api": "^1.9.1",
34
- "@opentelemetry/exporter-trace-otlp-http": "^0.219.0",
35
- "@opentelemetry/instrumentation": "^0.219.0",
34
+ "@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
35
+ "@opentelemetry/instrumentation": "^0.221.0",
36
36
  "@opentelemetry/resources": "^2.8.0",
37
37
  "@opentelemetry/sdk-trace-base": "^2.8.0",
38
38
  "@opentelemetry/sdk-trace-node": "^2.8.0",
39
39
  "async-retry": "^1.3.3"
40
40
  },
41
+ "overrides": {
42
+ "js-yaml": "^4.3.1"
43
+ },
41
44
  "devDependencies": {
42
45
  "@hey-api/openapi-ts": "^0.99.0",
43
46
  "@opentelemetry/context-async-hooks": "^2.8.0",
44
47
  "@types/async-retry": "^1.4.9",
45
48
  "@types/node": "^26.1.1",
46
- "eslint": "^9.18.0",
49
+ "eslint": "^10.8.0",
47
50
  "prettier": "^3.4.2",
48
51
  "typescript": "^6.0.3",
49
52
  "typescript-eslint": "^8.65.0"