@brizz/sdk 0.2.0 → 0.2.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/CHANGELOG.md +430 -0
- package/LICENSE +194 -20
- package/README.md +36 -1
- package/dist/{chunk-B5IY6O4N.js → chunk-6OYS2GR3.js} +1 -1
- package/dist/{chunk-WC573FCI.cjs → chunk-C5OT6GAQ.cjs} +10 -2
- package/dist/{chunk-Y4HNUX3Q.js → chunk-CZDPIJTO.js} +8 -0
- package/dist/{chunk-EZCNPWKM.js → chunk-GITAPIVL.js} +9 -9
- package/dist/{chunk-NF52RMLW.cjs → chunk-IWSFMCHH.cjs} +5 -1
- package/dist/{chunk-GISL4K6Z.js → chunk-JMX23OHO.js} +4 -0
- package/dist/{chunk-5HCG3JKU.js → chunk-KJSZPKSN.js} +5 -5
- package/dist/{chunk-RD4XCYKT.cjs → chunk-P5OONZTF.cjs} +3 -3
- package/dist/{chunk-CNVK5RA3.cjs → chunk-QXHGMS5A.cjs} +13 -13
- package/dist/{chunk-4QNEI7VZ.cjs → chunk-UF4GMVEY.cjs} +142 -142
- package/dist/eve.cjs +2 -3
- package/dist/eve.js +1 -2
- package/dist/google-genai-6S5E7GZ4.cjs +10 -0
- package/dist/{google-genai-3ERJNC7Q.js → google-genai-H6TMOKRX.js} +2 -3
- package/dist/google-genai.cjs +3 -4
- package/dist/google-genai.js +2 -3
- package/dist/index.cjs +590 -299
- package/dist/index.js +371 -80
- package/dist/{mcp-5ERVMLSA.cjs → mcp-6LNVYVJQ.cjs} +39 -40
- package/dist/{mcp-EJAJTGIC.js → mcp-YTBE75NP.js} +5 -6
- package/dist/session.cjs +4 -5
- package/dist/session.js +3 -4
- package/dist/types/cjs/internal/instrumentation/auto-init.d.ts +0 -7
- package/dist/types/cjs/internal/instrumentation/registry.d.ts +2 -0
- package/dist/types/cjs/internal/instrumentation/vercel-ai/index.d.ts +28 -0
- package/dist/types/cjs/internal/instrumentation/vercel-ai/model-call-end.d.ts +1 -0
- package/dist/types/cjs/internal/sdk.d.ts +1 -0
- package/dist/types/cjs/internal/semantic-conventions.d.ts +2 -0
- package/dist/types/esm/internal/instrumentation/auto-init.d.ts +0 -7
- package/dist/types/esm/internal/instrumentation/registry.d.ts +2 -0
- package/dist/types/esm/internal/instrumentation/vercel-ai/index.d.ts +28 -0
- package/dist/types/esm/internal/instrumentation/vercel-ai/model-call-end.d.ts +1 -0
- package/dist/types/esm/internal/sdk.d.ts +1 -0
- package/dist/types/esm/internal/semantic-conventions.d.ts +2 -0
- package/package.json +28 -23
- package/dist/chunk-3RG5ZIWI.js +0 -10
- package/dist/chunk-6QXPHZEO.cjs +0 -130
- package/dist/chunk-GABRGNAU.js +0 -130
- package/dist/chunk-OBGZSXTJ.cjs +0 -10
- package/dist/google-genai-GVCKSJMR.cjs +0 -11
- package/dist/interrupt-36U5562Z.cjs +0 -12
- package/dist/interrupt-6BSXUK3O.js +0 -12
package/dist/chunk-6QXPHZEO.cjs
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
|
|
3
|
-
var _chunkNF52RMLWcjs = require('./chunk-NF52RMLW.cjs');
|
|
4
|
-
|
|
5
|
-
// src/internal/instrumentation/vercel-ai/interrupt.ts
|
|
6
|
-
var _api = require('@opentelemetry/api');
|
|
7
|
-
var INNER_OPERATION_IDS = /* @__PURE__ */ new Set([
|
|
8
|
-
"ai.generateText.doGenerate",
|
|
9
|
-
"ai.streamText.doStream"
|
|
10
|
-
]);
|
|
11
|
-
function isInnerLLMSpan(span) {
|
|
12
|
-
if (INNER_OPERATION_IDS.has(span.name)) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
const opId = span.attributes["ai.operationId"];
|
|
16
|
-
return typeof opId === "string" && INNER_OPERATION_IDS.has(opId);
|
|
17
|
-
}
|
|
18
|
-
var MAX_PENDING_ENTRIES = 1024;
|
|
19
|
-
var pendingByParentSpanId = /* @__PURE__ */ new Map();
|
|
20
|
-
var needsApprovalToolNames = /* @__PURE__ */ new Set();
|
|
21
|
-
var versionState = { sawActiveSpan: false };
|
|
22
|
-
function setPending(parentSpanId, value) {
|
|
23
|
-
pendingByParentSpanId.set(parentSpanId, value);
|
|
24
|
-
while (pendingByParentSpanId.size > MAX_PENDING_ENTRIES) {
|
|
25
|
-
const oldest = pendingByParentSpanId.keys().next().value;
|
|
26
|
-
if (oldest === void 0) {
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
pendingByParentSpanId.delete(oldest);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function extractInterruptTools(tools) {
|
|
33
|
-
if (!tools || typeof tools !== "object") {
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
return Object.entries(tools).filter(
|
|
37
|
-
([, t]) => !!t && typeof t === "object" && t.needsApproval
|
|
38
|
-
).map(([name]) => name);
|
|
39
|
-
}
|
|
40
|
-
function parsePromptToolNames(raw) {
|
|
41
|
-
if (!Array.isArray(raw)) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
const names = [];
|
|
45
|
-
for (const element of raw) {
|
|
46
|
-
if (typeof element !== "string") {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
try {
|
|
50
|
-
const parsed = JSON.parse(element);
|
|
51
|
-
if (parsed && typeof parsed.name === "string") {
|
|
52
|
-
names.push(parsed.name);
|
|
53
|
-
}
|
|
54
|
-
} catch (e) {
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return names.length > 0 ? names : null;
|
|
58
|
-
}
|
|
59
|
-
function createInterruptIntegration() {
|
|
60
|
-
const onStart = (event) => {
|
|
61
|
-
for (const name of extractInterruptTools(event.tools)) {
|
|
62
|
-
needsApprovalToolNames.add(name);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const onStepStart = (event) => {
|
|
66
|
-
const span = _api.trace.getActiveSpan();
|
|
67
|
-
if (span) {
|
|
68
|
-
versionState.sawActiveSpan = true;
|
|
69
|
-
}
|
|
70
|
-
const names = extractInterruptTools(event.tools);
|
|
71
|
-
if (names.length === 0) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
for (const name of names) {
|
|
75
|
-
needsApprovalToolNames.add(name);
|
|
76
|
-
}
|
|
77
|
-
if (!span) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const value = JSON.stringify(names);
|
|
81
|
-
span.setAttribute(_chunkNF52RMLWcjs.INTERRUPT_TOOLS, value);
|
|
82
|
-
setPending(span.spanContext().spanId, value);
|
|
83
|
-
};
|
|
84
|
-
return {
|
|
85
|
-
onStart,
|
|
86
|
-
onStepStart
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
var InterruptPropagator = class {
|
|
90
|
-
onStart(span, _parentContext) {
|
|
91
|
-
if (!isInnerLLMSpan(span)) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
const parentSpanId = _optionalChain([span, 'access', _ => _.parentSpanContext, 'optionalAccess', _2 => _2.spanId]);
|
|
95
|
-
const stashed = parentSpanId && pendingByParentSpanId.get(parentSpanId);
|
|
96
|
-
if (stashed) {
|
|
97
|
-
span.setAttribute(_chunkNF52RMLWcjs.INTERRUPT_TOOLS, stashed);
|
|
98
|
-
pendingByParentSpanId.delete(parentSpanId);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (versionState.sawActiveSpan || needsApprovalToolNames.size === 0) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const scoped = parsePromptToolNames(span.attributes["ai.prompt.tools"]);
|
|
105
|
-
const names = scoped === null ? [...needsApprovalToolNames] : scoped.filter((n) => needsApprovalToolNames.has(n));
|
|
106
|
-
if (names.length > 0) {
|
|
107
|
-
span.setAttribute(_chunkNF52RMLWcjs.INTERRUPT_TOOLS, JSON.stringify(names));
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
onEnd() {
|
|
111
|
-
}
|
|
112
|
-
async shutdown() {
|
|
113
|
-
}
|
|
114
|
-
async forceFlush() {
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
function _resetInterruptState() {
|
|
118
|
-
if (process.env["NODE_ENV"] !== "test") {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
pendingByParentSpanId.clear();
|
|
122
|
-
needsApprovalToolNames.clear();
|
|
123
|
-
versionState.sawActiveSpan = false;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
exports.createInterruptIntegration = createInterruptIntegration; exports.InterruptPropagator = InterruptPropagator; exports._resetInterruptState = _resetInterruptState;
|
package/dist/chunk-GABRGNAU.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
INTERRUPT_TOOLS
|
|
3
|
-
} from "./chunk-GISL4K6Z.js";
|
|
4
|
-
|
|
5
|
-
// src/internal/instrumentation/vercel-ai/interrupt.ts
|
|
6
|
-
import { trace } from "@opentelemetry/api";
|
|
7
|
-
var INNER_OPERATION_IDS = /* @__PURE__ */ new Set([
|
|
8
|
-
"ai.generateText.doGenerate",
|
|
9
|
-
"ai.streamText.doStream"
|
|
10
|
-
]);
|
|
11
|
-
function isInnerLLMSpan(span) {
|
|
12
|
-
if (INNER_OPERATION_IDS.has(span.name)) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
const opId = span.attributes["ai.operationId"];
|
|
16
|
-
return typeof opId === "string" && INNER_OPERATION_IDS.has(opId);
|
|
17
|
-
}
|
|
18
|
-
var MAX_PENDING_ENTRIES = 1024;
|
|
19
|
-
var pendingByParentSpanId = /* @__PURE__ */ new Map();
|
|
20
|
-
var needsApprovalToolNames = /* @__PURE__ */ new Set();
|
|
21
|
-
var versionState = { sawActiveSpan: false };
|
|
22
|
-
function setPending(parentSpanId, value) {
|
|
23
|
-
pendingByParentSpanId.set(parentSpanId, value);
|
|
24
|
-
while (pendingByParentSpanId.size > MAX_PENDING_ENTRIES) {
|
|
25
|
-
const oldest = pendingByParentSpanId.keys().next().value;
|
|
26
|
-
if (oldest === void 0) {
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
pendingByParentSpanId.delete(oldest);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function extractInterruptTools(tools) {
|
|
33
|
-
if (!tools || typeof tools !== "object") {
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
return Object.entries(tools).filter(
|
|
37
|
-
([, t]) => !!t && typeof t === "object" && t.needsApproval
|
|
38
|
-
).map(([name]) => name);
|
|
39
|
-
}
|
|
40
|
-
function parsePromptToolNames(raw) {
|
|
41
|
-
if (!Array.isArray(raw)) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
const names = [];
|
|
45
|
-
for (const element of raw) {
|
|
46
|
-
if (typeof element !== "string") {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
try {
|
|
50
|
-
const parsed = JSON.parse(element);
|
|
51
|
-
if (parsed && typeof parsed.name === "string") {
|
|
52
|
-
names.push(parsed.name);
|
|
53
|
-
}
|
|
54
|
-
} catch {
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return names.length > 0 ? names : null;
|
|
58
|
-
}
|
|
59
|
-
function createInterruptIntegration() {
|
|
60
|
-
const onStart = (event) => {
|
|
61
|
-
for (const name of extractInterruptTools(event.tools)) {
|
|
62
|
-
needsApprovalToolNames.add(name);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const onStepStart = (event) => {
|
|
66
|
-
const span = trace.getActiveSpan();
|
|
67
|
-
if (span) {
|
|
68
|
-
versionState.sawActiveSpan = true;
|
|
69
|
-
}
|
|
70
|
-
const names = extractInterruptTools(event.tools);
|
|
71
|
-
if (names.length === 0) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
for (const name of names) {
|
|
75
|
-
needsApprovalToolNames.add(name);
|
|
76
|
-
}
|
|
77
|
-
if (!span) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const value = JSON.stringify(names);
|
|
81
|
-
span.setAttribute(INTERRUPT_TOOLS, value);
|
|
82
|
-
setPending(span.spanContext().spanId, value);
|
|
83
|
-
};
|
|
84
|
-
return {
|
|
85
|
-
onStart,
|
|
86
|
-
onStepStart
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
var InterruptPropagator = class {
|
|
90
|
-
onStart(span, _parentContext) {
|
|
91
|
-
if (!isInnerLLMSpan(span)) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
const parentSpanId = span.parentSpanContext?.spanId;
|
|
95
|
-
const stashed = parentSpanId && pendingByParentSpanId.get(parentSpanId);
|
|
96
|
-
if (stashed) {
|
|
97
|
-
span.setAttribute(INTERRUPT_TOOLS, stashed);
|
|
98
|
-
pendingByParentSpanId.delete(parentSpanId);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (versionState.sawActiveSpan || needsApprovalToolNames.size === 0) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const scoped = parsePromptToolNames(span.attributes["ai.prompt.tools"]);
|
|
105
|
-
const names = scoped === null ? [...needsApprovalToolNames] : scoped.filter((n) => needsApprovalToolNames.has(n));
|
|
106
|
-
if (names.length > 0) {
|
|
107
|
-
span.setAttribute(INTERRUPT_TOOLS, JSON.stringify(names));
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
onEnd() {
|
|
111
|
-
}
|
|
112
|
-
async shutdown() {
|
|
113
|
-
}
|
|
114
|
-
async forceFlush() {
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
function _resetInterruptState() {
|
|
118
|
-
if (process.env["NODE_ENV"] !== "test") {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
pendingByParentSpanId.clear();
|
|
122
|
-
needsApprovalToolNames.clear();
|
|
123
|
-
versionState.sawActiveSpan = false;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export {
|
|
127
|
-
createInterruptIntegration,
|
|
128
|
-
InterruptPropagator,
|
|
129
|
-
_resetInterruptState
|
|
130
|
-
};
|
package/dist/chunk-OBGZSXTJ.cjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.__require = __require;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkRD4XCYKTcjs = require('./chunk-RD4XCYKT.cjs');
|
|
5
|
-
require('./chunk-DC2MFO65.cjs');
|
|
6
|
-
require('./chunk-WC573FCI.cjs');
|
|
7
|
-
require('./chunk-OBGZSXTJ.cjs');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.GoogleGenAIInstrumentation = _chunkRD4XCYKTcjs.GoogleGenAIInstrumentation; exports.instrumentGoogleGenAI = _chunkRD4XCYKTcjs.instrumentGoogleGenAI;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _chunk6QXPHZEOcjs = require('./chunk-6QXPHZEO.cjs');
|
|
6
|
-
require('./chunk-NF52RMLW.cjs');
|
|
7
|
-
require('./chunk-OBGZSXTJ.cjs');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.InterruptPropagator = _chunk6QXPHZEOcjs.InterruptPropagator; exports._resetInterruptState = _chunk6QXPHZEOcjs._resetInterruptState; exports.createInterruptIntegration = _chunk6QXPHZEOcjs.createInterruptIntegration;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
InterruptPropagator,
|
|
3
|
-
_resetInterruptState,
|
|
4
|
-
createInterruptIntegration
|
|
5
|
-
} from "./chunk-GABRGNAU.js";
|
|
6
|
-
import "./chunk-GISL4K6Z.js";
|
|
7
|
-
import "./chunk-3RG5ZIWI.js";
|
|
8
|
-
export {
|
|
9
|
-
InterruptPropagator,
|
|
10
|
-
_resetInterruptState,
|
|
11
|
-
createInterruptIntegration
|
|
12
|
-
};
|