@tensorcost/sdk 0.3.1 → 0.6.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/CHANGELOG.md +74 -0
- package/README.md +65 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +22 -0
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts +20 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +22 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic.d.ts +2 -1
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +104 -12
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/bedrock.d.ts +48 -0
- package/dist/providers/bedrock.d.ts.map +1 -0
- package/dist/providers/bedrock.js +293 -0
- package/dist/providers/bedrock.js.map +1 -0
- package/dist/providers/detect.d.ts +9 -3
- package/dist/providers/detect.d.ts.map +1 -1
- package/dist/providers/detect.js +39 -6
- package/dist/providers/detect.js.map +1 -1
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +2 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/openai.d.ts +2 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +158 -14
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/vertex.d.ts +14 -0
- package/dist/providers/vertex.d.ts.map +1 -0
- package/dist/providers/vertex.js +167 -0
- package/dist/providers/vertex.js.map +1 -0
- package/dist/proxy-client.d.ts +24 -0
- package/dist/proxy-client.d.ts.map +1 -1
- package/dist/proxy-client.js +66 -1
- package/dist/proxy-client.js.map +1 -1
- package/dist/transport.d.ts +3 -0
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +9 -2
- package/dist/transport.js.map +1 -1
- package/dist/types.d.ts +108 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/wrap.d.ts +8 -0
- package/dist/wrap.d.ts.map +1 -1
- package/dist/wrap.js +38 -3
- package/dist/wrap.js.map +1 -1
- package/package.json +17 -2
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS Bedrock observe-only client wrapping.
|
|
3
|
+
*
|
|
4
|
+
* Bedrock differs fundamentally from OpenAI and Anthropic: requests go through
|
|
5
|
+
* the AWS Smithy client's `send()` method rather than named sub-resource methods
|
|
6
|
+
* like `chat.completions.create`. The Smithy client also handles SigV4 signing
|
|
7
|
+
* internally, so we cannot intercept the HTTP layer with a baseURL redirect the
|
|
8
|
+
* way applied mode does for the HTTP-Bearer providers.
|
|
9
|
+
*
|
|
10
|
+
* What we CAN do: register a Smithy middleware on `client.middlewareStack` that
|
|
11
|
+
* wraps the inner `next()` handler. Every `client.send(command)` call passes
|
|
12
|
+
* through the middleware stack, so this gives us a clean before/after hook with
|
|
13
|
+
* access to the command input and the resolved output.
|
|
14
|
+
*
|
|
15
|
+
* Supported commands (non-streaming):
|
|
16
|
+
* - InvokeModelCommand → operation "bedrock.invoke_model"
|
|
17
|
+
* - ConverseCommand → operation "bedrock.converse"
|
|
18
|
+
*
|
|
19
|
+
* Streaming commands (token accounting deferred):
|
|
20
|
+
* - InvokeModelWithResponseStreamCommand → operation "bedrock.invoke_model_stream"
|
|
21
|
+
* - ConverseStreamCommand → operation "bedrock.converse_stream"
|
|
22
|
+
*
|
|
23
|
+
* For streaming commands we emit an observation with input_tokens=null,
|
|
24
|
+
* output_tokens=null, and a note in error_message that per-chunk token
|
|
25
|
+
* accounting is not yet implemented. The observation still records latency
|
|
26
|
+
* and success/error status — enough for cost attribution once per-model
|
|
27
|
+
* pricing and a token estimator are wired in.
|
|
28
|
+
*
|
|
29
|
+
* Token-count extraction:
|
|
30
|
+
* Bedrock does not standardise usage across model families. We probe three
|
|
31
|
+
* common shapes in order:
|
|
32
|
+
* 1. Anthropic-on-Bedrock (InvokeModel): body JSON → usage.input_tokens / output_tokens
|
|
33
|
+
* 2. Amazon Nova / Titan (InvokeModel): body JSON → usage.inputTokens / outputTokens
|
|
34
|
+
* 3. Converse API (any model): response.usage.inputTokens / outputTokens
|
|
35
|
+
* If none match we emit 0/0 and log a warning so operators can report gaps.
|
|
36
|
+
*
|
|
37
|
+
* Applied mode:
|
|
38
|
+
* Not supported. SigV4 signing happens inside the AWS SDK before our
|
|
39
|
+
* middleware sees the request, and the signed URL/headers are region-specific.
|
|
40
|
+
* wrap(bedrockClient, { appliedMode: true }) throws TensorCostConfigError
|
|
41
|
+
* immediately in wrap.ts (before this module is called).
|
|
42
|
+
*/
|
|
43
|
+
import type { ObservationTransport } from "../transport.js";
|
|
44
|
+
export declare function install(client: unknown, transport: ObservationTransport, tenantId: string | null, environment: string | null, connectionId: string | null, deployment?: string | null, promptTemplateId?: string | null, agentId?: string | null, workflowId?: string | null): void;
|
|
45
|
+
export declare const __test__: {
|
|
46
|
+
MIDDLEWARE_NAME: string;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=bedrock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bedrock.d.ts","sourceRoot":"","sources":["../../src/providers/bedrock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAgK5D,wBAAgB,OAAO,CACrB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,oBAAoB,EAC/B,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,UAAU,GAAE,MAAM,GAAG,IAAW,EAChC,gBAAgB,GAAE,MAAM,GAAG,IAAW,EACtC,OAAO,GAAE,MAAM,GAAG,IAAW,EAC7B,UAAU,GAAE,MAAM,GAAG,IAAW,GAC/B,IAAI,CAmJN;AAED,eAAO,MAAM,QAAQ;;CAAsB,CAAC"}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS Bedrock observe-only client wrapping.
|
|
3
|
+
*
|
|
4
|
+
* Bedrock differs fundamentally from OpenAI and Anthropic: requests go through
|
|
5
|
+
* the AWS Smithy client's `send()` method rather than named sub-resource methods
|
|
6
|
+
* like `chat.completions.create`. The Smithy client also handles SigV4 signing
|
|
7
|
+
* internally, so we cannot intercept the HTTP layer with a baseURL redirect the
|
|
8
|
+
* way applied mode does for the HTTP-Bearer providers.
|
|
9
|
+
*
|
|
10
|
+
* What we CAN do: register a Smithy middleware on `client.middlewareStack` that
|
|
11
|
+
* wraps the inner `next()` handler. Every `client.send(command)` call passes
|
|
12
|
+
* through the middleware stack, so this gives us a clean before/after hook with
|
|
13
|
+
* access to the command input and the resolved output.
|
|
14
|
+
*
|
|
15
|
+
* Supported commands (non-streaming):
|
|
16
|
+
* - InvokeModelCommand → operation "bedrock.invoke_model"
|
|
17
|
+
* - ConverseCommand → operation "bedrock.converse"
|
|
18
|
+
*
|
|
19
|
+
* Streaming commands (token accounting deferred):
|
|
20
|
+
* - InvokeModelWithResponseStreamCommand → operation "bedrock.invoke_model_stream"
|
|
21
|
+
* - ConverseStreamCommand → operation "bedrock.converse_stream"
|
|
22
|
+
*
|
|
23
|
+
* For streaming commands we emit an observation with input_tokens=null,
|
|
24
|
+
* output_tokens=null, and a note in error_message that per-chunk token
|
|
25
|
+
* accounting is not yet implemented. The observation still records latency
|
|
26
|
+
* and success/error status — enough for cost attribution once per-model
|
|
27
|
+
* pricing and a token estimator are wired in.
|
|
28
|
+
*
|
|
29
|
+
* Token-count extraction:
|
|
30
|
+
* Bedrock does not standardise usage across model families. We probe three
|
|
31
|
+
* common shapes in order:
|
|
32
|
+
* 1. Anthropic-on-Bedrock (InvokeModel): body JSON → usage.input_tokens / output_tokens
|
|
33
|
+
* 2. Amazon Nova / Titan (InvokeModel): body JSON → usage.inputTokens / outputTokens
|
|
34
|
+
* 3. Converse API (any model): response.usage.inputTokens / outputTokens
|
|
35
|
+
* If none match we emit 0/0 and log a warning so operators can report gaps.
|
|
36
|
+
*
|
|
37
|
+
* Applied mode:
|
|
38
|
+
* Not supported. SigV4 signing happens inside the AWS SDK before our
|
|
39
|
+
* middleware sees the request, and the signed URL/headers are region-specific.
|
|
40
|
+
* wrap(bedrockClient, { appliedMode: true }) throws TensorCostConfigError
|
|
41
|
+
* immediately in wrap.ts (before this module is called).
|
|
42
|
+
*/
|
|
43
|
+
import { randomUUID } from "node:crypto";
|
|
44
|
+
const SDK_VERSION = "tensorcost-node/0.6.0";
|
|
45
|
+
// Marker placed on the middleware to prevent double-registration when
|
|
46
|
+
// wrap() is called twice on the same client.
|
|
47
|
+
const MIDDLEWARE_NAME = "__tensorcost_bedrock_observe__";
|
|
48
|
+
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
49
|
+
function nowIso() {
|
|
50
|
+
return new Date().toISOString();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Map a Smithy commandName string to the Operation we record in the
|
|
54
|
+
* observation envelope. Falls through to "bedrock.invoke_model" for
|
|
55
|
+
* unknown command names so we always record something.
|
|
56
|
+
*/
|
|
57
|
+
function commandToOperation(commandName) {
|
|
58
|
+
switch (commandName) {
|
|
59
|
+
case "InvokeModelCommand":
|
|
60
|
+
return { operation: "bedrock.invoke_model", isStreaming: false };
|
|
61
|
+
case "ConverseCommand":
|
|
62
|
+
return { operation: "bedrock.converse", isStreaming: false };
|
|
63
|
+
case "InvokeModelWithResponseStreamCommand":
|
|
64
|
+
return { operation: "bedrock.invoke_model_stream", isStreaming: true };
|
|
65
|
+
case "ConverseStreamCommand":
|
|
66
|
+
return { operation: "bedrock.converse_stream", isStreaming: true };
|
|
67
|
+
default:
|
|
68
|
+
// Unknown Bedrock command — record it under invoke_model so it still
|
|
69
|
+
// shows up in the dashboard rather than being silently dropped.
|
|
70
|
+
return { operation: "bedrock.invoke_model", isStreaming: false };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Extract token counts from an InvokeModel response body.
|
|
75
|
+
*
|
|
76
|
+
* The response body is a Uint8Array containing a JSON document whose
|
|
77
|
+
* shape depends on the model family. We try two common shapes and fall
|
|
78
|
+
* back to null/null rather than throwing.
|
|
79
|
+
*/
|
|
80
|
+
function extractInvokeModelTokens(output) {
|
|
81
|
+
// The `body` field is a Uint8Array (or Buffer in Node).
|
|
82
|
+
const rawBody = output.body;
|
|
83
|
+
if (!rawBody)
|
|
84
|
+
return { input: null, output: null };
|
|
85
|
+
let parsed;
|
|
86
|
+
try {
|
|
87
|
+
const text = typeof rawBody === "string"
|
|
88
|
+
? rawBody
|
|
89
|
+
: Buffer.from(rawBody).toString("utf-8");
|
|
90
|
+
parsed = JSON.parse(text);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
console.warn("tensorcost: could not parse Bedrock InvokeModel response body for token counts");
|
|
94
|
+
return { input: null, output: null };
|
|
95
|
+
}
|
|
96
|
+
const usage = parsed.usage;
|
|
97
|
+
if (!usage || typeof usage !== "object") {
|
|
98
|
+
console.warn("tensorcost: Bedrock InvokeModel response has no usage field — " +
|
|
99
|
+
"token counts will be missing. If this is a new model family, " +
|
|
100
|
+
"please open an issue at https://github.com/vaadhlabs/tensorcost.");
|
|
101
|
+
return { input: null, output: null };
|
|
102
|
+
}
|
|
103
|
+
// Anthropic-on-Bedrock: usage.input_tokens / output_tokens
|
|
104
|
+
if (typeof usage.input_tokens === "number" ||
|
|
105
|
+
typeof usage.output_tokens === "number") {
|
|
106
|
+
return {
|
|
107
|
+
input: typeof usage.input_tokens === "number" ? usage.input_tokens : null,
|
|
108
|
+
output: typeof usage.output_tokens === "number" ? usage.output_tokens : null,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// Amazon Nova / Titan: usage.inputTokens / outputTokens
|
|
112
|
+
if (typeof usage.inputTokens === "number" ||
|
|
113
|
+
typeof usage.outputTokens === "number") {
|
|
114
|
+
return {
|
|
115
|
+
input: typeof usage.inputTokens === "number" ? usage.inputTokens : null,
|
|
116
|
+
output: typeof usage.outputTokens === "number" ? usage.outputTokens : null,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
console.warn("tensorcost: Bedrock InvokeModel usage shape not recognised — " +
|
|
120
|
+
"token counts will be missing. Known shapes: " +
|
|
121
|
+
"Anthropic (usage.input_tokens/output_tokens), " +
|
|
122
|
+
"Nova/Titan (usage.inputTokens/outputTokens).");
|
|
123
|
+
return { input: null, output: null };
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Extract token counts from a Converse API response.
|
|
127
|
+
*
|
|
128
|
+
* The Converse API has a standardised usage block regardless of model
|
|
129
|
+
* family: response.usage.inputTokens / outputTokens.
|
|
130
|
+
*/
|
|
131
|
+
function extractConverseTokens(output) {
|
|
132
|
+
const usage = output.usage;
|
|
133
|
+
if (!usage || typeof usage !== "object") {
|
|
134
|
+
return { input: null, output: null };
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
input: typeof usage.inputTokens === "number" ? usage.inputTokens : null,
|
|
138
|
+
output: typeof usage.outputTokens === "number" ? usage.outputTokens : null,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
// ── Public install() ──────────────────────────────────────────────────────────
|
|
142
|
+
export function install(client, transport, tenantId, environment, connectionId, deployment = null, promptTemplateId = null, agentId = null, workflowId = null) {
|
|
143
|
+
if (!client || typeof client !== "object")
|
|
144
|
+
return;
|
|
145
|
+
const c = client;
|
|
146
|
+
const middlewareStack = c.middlewareStack;
|
|
147
|
+
if (!middlewareStack || typeof middlewareStack.add !== "function") {
|
|
148
|
+
console.warn("tensorcost: BedrockRuntimeClient does not expose a middlewareStack — " +
|
|
149
|
+
"observations will not be recorded. Is @aws-sdk/client-bedrock-runtime >= 3.x installed?");
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
// Guard against double-registration when wrap() is called twice on the
|
|
153
|
+
// same client. The identify() API is available from SDK v3 onwards.
|
|
154
|
+
if (typeof middlewareStack.identify === "function") {
|
|
155
|
+
const existing = middlewareStack.identify();
|
|
156
|
+
const alreadyInstalled = existing.some(([name]) => name === MIDDLEWARE_NAME);
|
|
157
|
+
if (alreadyInstalled)
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const middleware = (next, context) => async (args) => {
|
|
161
|
+
const startedAt = performance.now();
|
|
162
|
+
const requestAt = nowIso();
|
|
163
|
+
const correlationId = randomUUID();
|
|
164
|
+
// modelId lives in the command input for both InvokeModel and Converse.
|
|
165
|
+
const modelId = typeof args.input.modelId === "string" ? args.input.modelId : "unknown";
|
|
166
|
+
const { operation, isStreaming } = commandToOperation(context.commandName);
|
|
167
|
+
// Build wrap-time metadata bag (deployment + promptTemplateId).
|
|
168
|
+
const bedrockMeta = {};
|
|
169
|
+
if (deployment !== null)
|
|
170
|
+
bedrockMeta.deployment = deployment;
|
|
171
|
+
if (promptTemplateId !== null)
|
|
172
|
+
bedrockMeta.prompt_template_id = promptTemplateId;
|
|
173
|
+
const metaSpread = Object.keys(bedrockMeta).length > 0 ? { metadata: bedrockMeta } : {};
|
|
174
|
+
// Per-agent-run attribution — wrap-time only. Bedrock has no per-call
|
|
175
|
+
// hook (the Smithy middleware is registered once at wrap() time, and
|
|
176
|
+
// there is no withMeta() proxy for Bedrock clients), so agent_id /
|
|
177
|
+
// workflow_id are constant for the lifetime of this wrapped client.
|
|
178
|
+
// A customer who needs a distinct workflow_id per run must construct
|
|
179
|
+
// a new BedrockRuntimeClient (and re-wrap) per run — see
|
|
180
|
+
// Observation.workflow_id doc in types.ts.
|
|
181
|
+
const commonFields = {
|
|
182
|
+
sdk_version: SDK_VERSION,
|
|
183
|
+
provider: "bedrock",
|
|
184
|
+
model: modelId,
|
|
185
|
+
operation,
|
|
186
|
+
request_at: requestAt,
|
|
187
|
+
correlation_id: correlationId,
|
|
188
|
+
...(environment !== null ? { environment } : {}),
|
|
189
|
+
...(connectionId !== null ? { connection_id: connectionId } : {}),
|
|
190
|
+
...(agentId !== null ? { agent_id: agentId } : {}),
|
|
191
|
+
...(workflowId !== null ? { workflow_id: workflowId } : {}),
|
|
192
|
+
...metaSpread,
|
|
193
|
+
};
|
|
194
|
+
// Streaming commands: we cannot aggregate tokens across chunks without
|
|
195
|
+
// collecting the full stream. Emit a placeholder observation now —
|
|
196
|
+
// per-chunk token accounting is a follow-up workstream.
|
|
197
|
+
if (isStreaming) {
|
|
198
|
+
let status = "success";
|
|
199
|
+
let errorMessage = null;
|
|
200
|
+
let result;
|
|
201
|
+
try {
|
|
202
|
+
result = await next(args);
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
status = "error";
|
|
206
|
+
errorMessage = `${err.name}: ${err.message}`;
|
|
207
|
+
const latencyMs = performance.now() - startedAt;
|
|
208
|
+
const obs = {
|
|
209
|
+
...commonFields,
|
|
210
|
+
response_at: nowIso(),
|
|
211
|
+
input_tokens: null,
|
|
212
|
+
output_tokens: null,
|
|
213
|
+
cost_usd_cents: null,
|
|
214
|
+
status: "error",
|
|
215
|
+
error_message: errorMessage,
|
|
216
|
+
};
|
|
217
|
+
try {
|
|
218
|
+
transport.post(obs);
|
|
219
|
+
}
|
|
220
|
+
catch { /* fail-open */ }
|
|
221
|
+
throw err;
|
|
222
|
+
}
|
|
223
|
+
const latencyMs = performance.now() - startedAt;
|
|
224
|
+
void latencyMs; // recorded via response_at timestamp difference
|
|
225
|
+
const obs = {
|
|
226
|
+
...commonFields,
|
|
227
|
+
response_at: nowIso(),
|
|
228
|
+
input_tokens: null,
|
|
229
|
+
output_tokens: null,
|
|
230
|
+
cost_usd_cents: null,
|
|
231
|
+
status,
|
|
232
|
+
// Signal to operators that this is a streaming placeholder, not a gap.
|
|
233
|
+
error_message: "streaming: per-chunk token accounting not yet implemented",
|
|
234
|
+
};
|
|
235
|
+
try {
|
|
236
|
+
transport.post(obs);
|
|
237
|
+
}
|
|
238
|
+
catch { /* fail-open */ }
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
241
|
+
// Non-streaming path: InvokeModel + Converse.
|
|
242
|
+
try {
|
|
243
|
+
const result = await next(args);
|
|
244
|
+
const latencyMs = performance.now() - startedAt;
|
|
245
|
+
void latencyMs;
|
|
246
|
+
let input = null;
|
|
247
|
+
let output = null;
|
|
248
|
+
if (operation === "bedrock.converse") {
|
|
249
|
+
({ input, output } = extractConverseTokens(result.output));
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
({ input, output } = extractInvokeModelTokens(result.output));
|
|
253
|
+
}
|
|
254
|
+
const obs = {
|
|
255
|
+
...commonFields,
|
|
256
|
+
response_at: nowIso(),
|
|
257
|
+
input_tokens: input,
|
|
258
|
+
output_tokens: output,
|
|
259
|
+
cost_usd_cents: null,
|
|
260
|
+
status: "success",
|
|
261
|
+
error_message: null,
|
|
262
|
+
};
|
|
263
|
+
try {
|
|
264
|
+
transport.post(obs);
|
|
265
|
+
}
|
|
266
|
+
catch { /* fail-open */ }
|
|
267
|
+
return result;
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
const obs = {
|
|
271
|
+
...commonFields,
|
|
272
|
+
response_at: nowIso(),
|
|
273
|
+
input_tokens: null,
|
|
274
|
+
output_tokens: null,
|
|
275
|
+
cost_usd_cents: null,
|
|
276
|
+
status: "error",
|
|
277
|
+
error_message: `${err.name}: ${err.message}`,
|
|
278
|
+
};
|
|
279
|
+
try {
|
|
280
|
+
transport.post(obs);
|
|
281
|
+
}
|
|
282
|
+
catch { /* fail-open */ }
|
|
283
|
+
throw err;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
middlewareStack.add(middleware, {
|
|
287
|
+
step: "build",
|
|
288
|
+
name: MIDDLEWARE_NAME,
|
|
289
|
+
priority: "normal",
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
export const __test__ = {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IAAI,EAAE,OAAO;QACb,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,QAAQ;KACnB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Provider detection — duck-typed.
|
|
3
3
|
*
|
|
4
|
-
* We avoid importing `openai
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* We avoid importing `openai`, `@anthropic-ai/sdk`, or
|
|
5
|
+
* `@aws-sdk/client-bedrock-runtime` at runtime so that the SDK has zero
|
|
6
|
+
* peer-dep cost when the customer only uses one provider. Detection
|
|
7
|
+
* inspects the shape of the client object instead.
|
|
8
|
+
*
|
|
9
|
+
* Bedrock detection uses the Smithy-generated `config.serviceId` field,
|
|
10
|
+
* which is the most precise available discriminator — it's set by the
|
|
11
|
+
* AWS SDK generator and does not depend on the constructor name (which
|
|
12
|
+
* minifiers can change).
|
|
7
13
|
*/
|
|
8
14
|
import type { Provider } from "../types.js";
|
|
9
15
|
export declare class UnsupportedClientError extends Error {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../src/providers/detect.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../src/providers/detect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,QAAQ,CAoExD"}
|
package/dist/providers/detect.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Provider detection — duck-typed.
|
|
3
3
|
*
|
|
4
|
-
* We avoid importing `openai
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* We avoid importing `openai`, `@anthropic-ai/sdk`, or
|
|
5
|
+
* `@aws-sdk/client-bedrock-runtime` at runtime so that the SDK has zero
|
|
6
|
+
* peer-dep cost when the customer only uses one provider. Detection
|
|
7
|
+
* inspects the shape of the client object instead.
|
|
8
|
+
*
|
|
9
|
+
* Bedrock detection uses the Smithy-generated `config.serviceId` field,
|
|
10
|
+
* which is the most precise available discriminator — it's set by the
|
|
11
|
+
* AWS SDK generator and does not depend on the constructor name (which
|
|
12
|
+
* minifiers can change).
|
|
7
13
|
*/
|
|
8
14
|
export class UnsupportedClientError extends Error {
|
|
9
15
|
constructor(message) {
|
|
@@ -13,9 +19,34 @@ export class UnsupportedClientError extends Error {
|
|
|
13
19
|
}
|
|
14
20
|
export function detectProvider(client) {
|
|
15
21
|
if (client === null || typeof client !== "object") {
|
|
16
|
-
throw new UnsupportedClientError("tensorcost: wrap() requires an object (an OpenAI or
|
|
22
|
+
throw new UnsupportedClientError("tensorcost: wrap() requires an object (an OpenAI, Anthropic, or BedrockRuntimeClient instance).");
|
|
17
23
|
}
|
|
18
24
|
const c = client;
|
|
25
|
+
// BedrockRuntimeClient (AWS SDK v3 / Smithy): has a `send()` method AND
|
|
26
|
+
// config.serviceId === "Bedrock Runtime". We check this first because
|
|
27
|
+
// Smithy clients have a generic enough shape that the OpenAI/Anthropic
|
|
28
|
+
// checks could theoretically collide on oddly-named properties.
|
|
29
|
+
const hasBedrockShape = typeof c.send === "function" &&
|
|
30
|
+
c.config != null &&
|
|
31
|
+
typeof c.config === "object" &&
|
|
32
|
+
c.config.serviceId === "Bedrock Runtime";
|
|
33
|
+
if (hasBedrockShape) {
|
|
34
|
+
return "bedrock";
|
|
35
|
+
}
|
|
36
|
+
// google-genai Client in Vertex mode: vertexai=true + models.generate_content.
|
|
37
|
+
const apiClient = c._apiClient;
|
|
38
|
+
const vertexaiFlag = c.vertexai === true ||
|
|
39
|
+
(apiClient != null &&
|
|
40
|
+
typeof apiClient === "object" &&
|
|
41
|
+
apiClient.vertexai === true);
|
|
42
|
+
const models = c.models;
|
|
43
|
+
const hasVertexShape = vertexaiFlag &&
|
|
44
|
+
models != null &&
|
|
45
|
+
typeof models === "object" &&
|
|
46
|
+
typeof models.generateContent === "function";
|
|
47
|
+
if (hasVertexShape) {
|
|
48
|
+
return "vertex";
|
|
49
|
+
}
|
|
19
50
|
// OpenAI: has chat.completions.create OR completions.create
|
|
20
51
|
const chat = c.chat;
|
|
21
52
|
const chatCompletions = chat && typeof chat === "object" ? chat.completions : undefined;
|
|
@@ -33,7 +64,9 @@ export function detectProvider(client) {
|
|
|
33
64
|
if (hasAnthropicShape) {
|
|
34
65
|
return "anthropic";
|
|
35
66
|
}
|
|
36
|
-
throw new UnsupportedClientError("tensorcost: client does not look like an OpenAI
|
|
37
|
-
"
|
|
67
|
+
throw new UnsupportedClientError("tensorcost: client does not look like an OpenAI, Anthropic, BedrockRuntimeClient, " +
|
|
68
|
+
"or Vertex AI Client instance " +
|
|
69
|
+
"(missing chat.completions.create / completions.create / messages.create / " +
|
|
70
|
+
"send+config.serviceId='Bedrock Runtime' / vertexai=true+models.generateContent).");
|
|
38
71
|
}
|
|
39
72
|
//# sourceMappingURL=detect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../../src/providers/detect.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../../src/providers/detect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,MAAM,UAAU,cAAc,CAAC,MAAe;IAC5C,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO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AAC,CAAC,WAAW,IAAI,OAAO,CAAC,CAAC,WAAW,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC;IAEhE,iCAAiC;IACjC,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;IAC5B,MAAM,iBAAiB,GACrB,QAAQ,IAAI,OAAO,QAAQ,CAAC,MAAM,KAAK,UAAU,CAAC;IAEpD,wEAAwE;IACxE,qEAAqE;IACrE,sEAAsE;IACtE,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,iBAAiB,EAAE,CAAC;QACtB,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,MAAM,IAAI,sBAAsB,CAC9B,oFAAoF;QAClF,+BAA+B;QAC/B,4EAA4E;QAC5E,kFAAkF,CACrF,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { detectProvider, UnsupportedClientError } from "./detect.js";
|
|
2
2
|
export * as openaiProvider from "./openai.js";
|
|
3
3
|
export * as anthropicProvider from "./anthropic.js";
|
|
4
|
+
export * as bedrockProvider from "./bedrock.js";
|
|
5
|
+
export * as vertexProvider from "./vertex.js";
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,cAAc,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,iBAAiB,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,cAAc,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,iBAAiB,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,eAAe,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,cAAc,MAAM,aAAa,CAAC"}
|
package/dist/providers/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { detectProvider, UnsupportedClientError } from "./detect.js";
|
|
2
2
|
export * as openaiProvider from "./openai.js";
|
|
3
3
|
export * as anthropicProvider from "./anthropic.js";
|
|
4
|
+
export * as bedrockProvider from "./bedrock.js";
|
|
5
|
+
export * as vertexProvider from "./vertex.js";
|
|
4
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,cAAc,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,iBAAiB,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,cAAc,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,iBAAiB,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,eAAe,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,cAAc,MAAM,aAAa,CAAC"}
|
|
@@ -27,8 +27,9 @@ export interface AppliedModeHardeningOpts {
|
|
|
27
27
|
failOpenEnabled: boolean;
|
|
28
28
|
circuit: CircuitBreaker;
|
|
29
29
|
}
|
|
30
|
-
export declare function install(client: unknown, transport: ObservationTransport, tenantId: string | null, environment: string | null, connectionId: string | null, hardening: AppliedModeHardeningOpts): void;
|
|
30
|
+
export declare function install(client: unknown, transport: ObservationTransport, tenantId: string | null, environment: string | null, connectionId: string | null, hardening: AppliedModeHardeningOpts, deployment?: string | null, promptTemplateId?: string | null, agentId?: string | null, workflowId?: string | null): void;
|
|
31
31
|
export declare const __test__: {
|
|
32
32
|
MARKER: string;
|
|
33
|
+
WITH_META_MARKER: string;
|
|
33
34
|
};
|
|
34
35
|
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAG5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAG5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM/C,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,sBAAsB,GAAG,SAAS,CAAC;IACrD,eAAe,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,cAAc,CAAC;CACzB;AAkWD,wBAAgB,OAAO,CACrB,MAAM,EAAE,OAAO,EACf,SAAS,EA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