weflayr 0.26.0 → 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.
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "weflayr",
|
|
3
|
+
"version": "0.27.0",
|
|
4
|
+
"description": "Weflayr JS/TS SDK — instrument any LLM client",
|
|
5
|
+
"main": "dist/src/index.js",
|
|
6
|
+
"types": "dist/src/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/src",
|
|
9
|
+
"dist/package.json"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"generate-api": "openapi-ts && node scripts/generate_facade.mjs",
|
|
14
|
+
"pretest": "npm run build",
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
16
|
+
"test": "node --test \"dist/tests/**/*.test.js\"",
|
|
17
|
+
"lint": "eslint src tests",
|
|
18
|
+
"lint:fix": "eslint src tests --fix",
|
|
19
|
+
"format": "prettier --write src tests",
|
|
20
|
+
"format:check": "prettier --check src tests"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"llm",
|
|
24
|
+
"observability",
|
|
25
|
+
"weflayr"
|
|
26
|
+
],
|
|
27
|
+
"author": "Weflayr <contact@weflayr.com>",
|
|
28
|
+
"license": "Elastic-2.0",
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18.0.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@opentelemetry/api": "^1.9.1",
|
|
34
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
|
|
35
|
+
"@opentelemetry/instrumentation": "^0.221.0",
|
|
36
|
+
"@opentelemetry/resources": "^2.8.0",
|
|
37
|
+
"@opentelemetry/sdk-trace-base": "^2.8.0",
|
|
38
|
+
"@opentelemetry/sdk-trace-node": "^2.8.0",
|
|
39
|
+
"async-retry": "^1.3.3"
|
|
40
|
+
},
|
|
41
|
+
"overrides": {
|
|
42
|
+
"js-yaml": "^4.3.1"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@hey-api/openapi-ts": "^0.99.0",
|
|
46
|
+
"@opentelemetry/context-async-hooks": "^2.8.0",
|
|
47
|
+
"@types/async-retry": "^1.4.9",
|
|
48
|
+
"@types/node": "^26.1.1",
|
|
49
|
+
"eslint": "^10.8.0",
|
|
50
|
+
"prettier": "^3.4.2",
|
|
51
|
+
"typescript": "^6.0.3",
|
|
52
|
+
"typescript-eslint": "^8.65.0"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -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
|
|
20
|
-
|
|
21
|
-
|
|
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,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weflayr",
|
|
3
|
-
"version": "0.
|
|
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",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist/src"
|
|
8
|
+
"dist/src",
|
|
9
|
+
"dist/package.json"
|
|
9
10
|
],
|
|
10
11
|
"scripts": {
|
|
11
12
|
"build": "tsc",
|
|
12
13
|
"generate-api": "openapi-ts && node scripts/generate_facade.mjs",
|
|
13
14
|
"pretest": "npm run build",
|
|
14
15
|
"prepublishOnly": "npm run build",
|
|
15
|
-
"test": "node --test",
|
|
16
|
+
"test": "node --test \"dist/tests/**/*.test.js\"",
|
|
16
17
|
"lint": "eslint src tests",
|
|
17
18
|
"lint:fix": "eslint src tests --fix",
|
|
18
19
|
"format": "prettier --write src tests",
|
|
@@ -30,19 +31,22 @@
|
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"@opentelemetry/api": "^1.9.1",
|
|
33
|
-
"@opentelemetry/exporter-trace-otlp-http": "^0.
|
|
34
|
-
"@opentelemetry/instrumentation": "^0.
|
|
34
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
|
|
35
|
+
"@opentelemetry/instrumentation": "^0.221.0",
|
|
35
36
|
"@opentelemetry/resources": "^2.8.0",
|
|
36
37
|
"@opentelemetry/sdk-trace-base": "^2.8.0",
|
|
37
38
|
"@opentelemetry/sdk-trace-node": "^2.8.0",
|
|
38
39
|
"async-retry": "^1.3.3"
|
|
39
40
|
},
|
|
41
|
+
"overrides": {
|
|
42
|
+
"js-yaml": "^4.3.1"
|
|
43
|
+
},
|
|
40
44
|
"devDependencies": {
|
|
41
45
|
"@hey-api/openapi-ts": "^0.99.0",
|
|
42
46
|
"@opentelemetry/context-async-hooks": "^2.8.0",
|
|
43
47
|
"@types/async-retry": "^1.4.9",
|
|
44
48
|
"@types/node": "^26.1.1",
|
|
45
|
-
"eslint": "^
|
|
49
|
+
"eslint": "^10.8.0",
|
|
46
50
|
"prettier": "^3.4.2",
|
|
47
51
|
"typescript": "^6.0.3",
|
|
48
52
|
"typescript-eslint": "^8.65.0"
|