@superbased/sdk 0.0.1-placeholder.0 → 0.1.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/NOTICE +4 -0
- package/README.md +434 -5
- package/dist/cjs/admit.d.ts +139 -0
- package/dist/cjs/admit.js +442 -0
- package/dist/cjs/admit.js.map +1 -0
- package/dist/cjs/attrs.d.ts +113 -0
- package/dist/cjs/attrs.js +183 -0
- package/dist/cjs/attrs.js.map +1 -0
- package/dist/cjs/config.d.ts +202 -0
- package/dist/cjs/config.js +386 -0
- package/dist/cjs/config.js.map +1 -0
- package/dist/cjs/context.d.ts +102 -0
- package/dist/cjs/context.js +234 -0
- package/dist/cjs/context.js.map +1 -0
- package/dist/cjs/control.d.ts +99 -0
- package/dist/cjs/control.js +243 -0
- package/dist/cjs/control.js.map +1 -0
- package/dist/cjs/cost.d.ts +108 -0
- package/dist/cjs/cost.js +211 -0
- package/dist/cjs/cost.js.map +1 -0
- package/dist/cjs/destination.d.ts +125 -0
- package/dist/cjs/destination.js +357 -0
- package/dist/cjs/destination.js.map +1 -0
- package/dist/cjs/experiments.d.ts +237 -0
- package/dist/cjs/experiments.js +678 -0
- package/dist/cjs/experiments.js.map +1 -0
- package/dist/cjs/export.d.ts +84 -0
- package/dist/cjs/export.js +328 -0
- package/dist/cjs/export.js.map +1 -0
- package/dist/cjs/index.d.ts +168 -0
- package/dist/cjs/index.js +581 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/instrument.d.ts +88 -0
- package/dist/cjs/instrument.js +397 -0
- package/dist/cjs/instrument.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/policy.d.ts +77 -0
- package/dist/cjs/policy.js +252 -0
- package/dist/cjs/policy.js.map +1 -0
- package/dist/cjs/prompts.d.ts +175 -0
- package/dist/cjs/prompts.js +476 -0
- package/dist/cjs/prompts.js.map +1 -0
- package/dist/cjs/propagation.d.ts +34 -0
- package/dist/cjs/propagation.js +151 -0
- package/dist/cjs/propagation.js.map +1 -0
- package/dist/cjs/req.d.ts +10 -0
- package/dist/cjs/req.js +3 -0
- package/dist/cjs/req.js.map +1 -0
- package/dist/cjs/runtime.d.ts +44 -0
- package/dist/cjs/runtime.js +67 -0
- package/dist/cjs/runtime.js.map +1 -0
- package/dist/cjs/scores.d.ts +102 -0
- package/dist/cjs/scores.js +226 -0
- package/dist/cjs/scores.js.map +1 -0
- package/dist/cjs/spans.d.ts +193 -0
- package/dist/cjs/spans.js +398 -0
- package/dist/cjs/spans.js.map +1 -0
- package/dist/cjs/vendor.d.ts +33 -0
- package/dist/cjs/vendor.js +67 -0
- package/dist/cjs/vendor.js.map +1 -0
- package/dist/esm/admit.d.ts +139 -0
- package/dist/esm/admit.js +432 -0
- package/dist/esm/admit.js.map +1 -0
- package/dist/esm/attrs.d.ts +113 -0
- package/dist/esm/attrs.js +179 -0
- package/dist/esm/attrs.js.map +1 -0
- package/dist/esm/config.d.ts +202 -0
- package/dist/esm/config.js +364 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/context.d.ts +102 -0
- package/dist/esm/context.js +221 -0
- package/dist/esm/context.js.map +1 -0
- package/dist/esm/control.d.ts +99 -0
- package/dist/esm/control.js +230 -0
- package/dist/esm/control.js.map +1 -0
- package/dist/esm/cost.d.ts +108 -0
- package/dist/esm/cost.js +202 -0
- package/dist/esm/cost.js.map +1 -0
- package/dist/esm/destination.d.ts +125 -0
- package/dist/esm/destination.js +346 -0
- package/dist/esm/destination.js.map +1 -0
- package/dist/esm/experiments.d.ts +237 -0
- package/dist/esm/experiments.js +666 -0
- package/dist/esm/experiments.js.map +1 -0
- package/dist/esm/export.d.ts +84 -0
- package/dist/esm/export.js +314 -0
- package/dist/esm/export.js.map +1 -0
- package/dist/esm/index.d.ts +168 -0
- package/dist/esm/index.js +500 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/instrument.d.ts +88 -0
- package/dist/esm/instrument.js +391 -0
- package/dist/esm/instrument.js.map +1 -0
- package/dist/esm/policy.d.ts +77 -0
- package/dist/esm/policy.js +240 -0
- package/dist/esm/policy.js.map +1 -0
- package/dist/esm/prompts.d.ts +175 -0
- package/dist/esm/prompts.js +460 -0
- package/dist/esm/prompts.js.map +1 -0
- package/dist/esm/propagation.d.ts +34 -0
- package/dist/esm/propagation.js +145 -0
- package/dist/esm/propagation.js.map +1 -0
- package/dist/esm/req.d.ts +10 -0
- package/dist/esm/req.js +2 -0
- package/dist/esm/req.js.map +1 -0
- package/dist/esm/runtime.d.ts +44 -0
- package/dist/esm/runtime.js +59 -0
- package/dist/esm/runtime.js.map +1 -0
- package/dist/esm/scores.d.ts +102 -0
- package/dist/esm/scores.js +219 -0
- package/dist/esm/scores.js.map +1 -0
- package/dist/esm/spans.d.ts +193 -0
- package/dist/esm/spans.js +378 -0
- package/dist/esm/spans.js.map +1 -0
- package/dist/esm/vendor.d.ts +33 -0
- package/dist/esm/vendor.js +61 -0
- package/dist/esm/vendor.js.map +1 -0
- package/package.json +121 -4
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* superbased SDK for TypeScript / Node: send LLM-app and agent traces to
|
|
4
|
+
* superbased over OpenTelemetry (OTLP/HTTP).
|
|
5
|
+
*
|
|
6
|
+
* A thin layer over OpenTelemetry JS 2.x that exports spans to the Observer
|
|
7
|
+
* on this machine (`http://127.0.0.1:4318/v1/traces` by default), to an org
|
|
8
|
+
* or SaaS OTLP gateway, or to both, and tags them with superbased attributes.
|
|
9
|
+
* Anything it does, a raw OTel exporter pointed at Observer does too.
|
|
10
|
+
*
|
|
11
|
+
* IMPORTANT: never set `sbo.emitted_by=observer`: that is Observer's own
|
|
12
|
+
* echo-guard marker and such a resource is DROPPED at ingestion.
|
|
13
|
+
*/
|
|
14
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.withAgentSpan = exports.setUsage = exports.setToolResult = exports.setRequestParams = exports.setOutput = exports.setInput = exports.setDocuments = exports.setContent = exports.observe = exports.getCurrentTraceId = exports.getCurrentSpanId = exports.Kind = exports.inject = exports.getTraceparent = exports.extract = exports.continueTrace = exports.TRUNCATED_MARK = exports.keepTrace = exports.readCredentialFile = exports.parseDiscovery = exports.isLoopbackUrl = exports.DISCOVERY_PATH = exports.propagateAttributes = exports.identify = exports.getCurrentAttributes = exports.SEMCONV_SCHEMA_URL = exports.SEMCONV_COMMIT = exports.REQUEST_PARAMS = exports.LIMITS = exports.Attr = exports.resolveSettings = exports.parseKvList = exports.destinations = exports.DESTINATION_CHOICES = exports.DEFAULT_SHUTDOWN_TIMEOUT_MS = exports.DEFAULT_SERVICE_NAME = exports.DEFAULT_PROMPT_CACHE_TTL_MS = exports.DEFAULT_NODE_URL = exports.DEFAULT_API_TIMEOUT_MS = exports.DEFAULT_MAX_CONTENT_CHARS = exports.DEFAULT_EXPORT_TIMEOUT_MS = exports.DEFAULT_ENDPOINT = exports.DEFAULT_DISCOVER_TIMEOUT_MS = exports.parseVerdict = exports.SDK_ADMIT_PATH = exports.DEFAULT_ADMIT_TIMEOUT_MS = exports.DEFAULT_ADMISSION_ENDPOINT = exports.Degraded = exports.admit = exports.VERSION = void 0;
|
|
30
|
+
exports.withToolSpan = exports.withSpan = exports.withRetrieverSpan = exports.withLlmSpan = exports.withEmbeddingSpan = void 0;
|
|
31
|
+
exports.spanProcessor = spanProcessor;
|
|
32
|
+
exports.init = init;
|
|
33
|
+
exports.ready = ready;
|
|
34
|
+
exports.settings = settings;
|
|
35
|
+
exports.flush = flush;
|
|
36
|
+
exports.shutdown = shutdown;
|
|
37
|
+
exports.diagnostics = diagnostics;
|
|
38
|
+
exports._resetForTests = _resetForTests;
|
|
39
|
+
const api_1 = require("@opentelemetry/api");
|
|
40
|
+
const exporter_trace_otlp_http_1 = require("@opentelemetry/exporter-trace-otlp-http");
|
|
41
|
+
const resources_1 = require("@opentelemetry/resources");
|
|
42
|
+
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
43
|
+
const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
|
|
44
|
+
const attrs_js_1 = require("./attrs.js");
|
|
45
|
+
const config_js_1 = require("./config.js");
|
|
46
|
+
const context_js_1 = require("./context.js");
|
|
47
|
+
const destination_js_1 = require("./destination.js");
|
|
48
|
+
const export_js_1 = require("./export.js");
|
|
49
|
+
const control_js_1 = require("./control.js");
|
|
50
|
+
const policy_js_1 = require("./policy.js");
|
|
51
|
+
const vendor_js_1 = require("./vendor.js");
|
|
52
|
+
const spans_js_1 = require("./spans.js");
|
|
53
|
+
const prompts_js_1 = require("./prompts.js");
|
|
54
|
+
const runtime_js_1 = require("./runtime.js");
|
|
55
|
+
var runtime_js_2 = require("./runtime.js");
|
|
56
|
+
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return runtime_js_2.VERSION; } });
|
|
57
|
+
var admit_js_1 = require("./admit.js");
|
|
58
|
+
Object.defineProperty(exports, "admit", { enumerable: true, get: function () { return admit_js_1.admit; } });
|
|
59
|
+
Object.defineProperty(exports, "Degraded", { enumerable: true, get: function () { return admit_js_1.Degraded; } });
|
|
60
|
+
Object.defineProperty(exports, "DEFAULT_ADMISSION_ENDPOINT", { enumerable: true, get: function () { return admit_js_1.DEFAULT_ADMISSION_ENDPOINT; } });
|
|
61
|
+
Object.defineProperty(exports, "DEFAULT_ADMIT_TIMEOUT_MS", { enumerable: true, get: function () { return admit_js_1.DEFAULT_ADMIT_TIMEOUT_MS; } });
|
|
62
|
+
Object.defineProperty(exports, "SDK_ADMIT_PATH", { enumerable: true, get: function () { return admit_js_1.SDK_ADMIT_PATH; } });
|
|
63
|
+
Object.defineProperty(exports, "parseVerdict", { enumerable: true, get: function () { return admit_js_1.parseVerdict; } });
|
|
64
|
+
const admit_js_2 = require("./admit.js");
|
|
65
|
+
var config_js_2 = require("./config.js");
|
|
66
|
+
Object.defineProperty(exports, "DEFAULT_DISCOVER_TIMEOUT_MS", { enumerable: true, get: function () { return config_js_2.DEFAULT_DISCOVER_TIMEOUT_MS; } });
|
|
67
|
+
Object.defineProperty(exports, "DEFAULT_ENDPOINT", { enumerable: true, get: function () { return config_js_2.DEFAULT_ENDPOINT; } });
|
|
68
|
+
Object.defineProperty(exports, "DEFAULT_EXPORT_TIMEOUT_MS", { enumerable: true, get: function () { return config_js_2.DEFAULT_EXPORT_TIMEOUT_MS; } });
|
|
69
|
+
Object.defineProperty(exports, "DEFAULT_MAX_CONTENT_CHARS", { enumerable: true, get: function () { return config_js_2.DEFAULT_MAX_CONTENT_CHARS; } });
|
|
70
|
+
Object.defineProperty(exports, "DEFAULT_API_TIMEOUT_MS", { enumerable: true, get: function () { return config_js_2.DEFAULT_API_TIMEOUT_MS; } });
|
|
71
|
+
Object.defineProperty(exports, "DEFAULT_NODE_URL", { enumerable: true, get: function () { return config_js_2.DEFAULT_NODE_URL; } });
|
|
72
|
+
Object.defineProperty(exports, "DEFAULT_PROMPT_CACHE_TTL_MS", { enumerable: true, get: function () { return config_js_2.DEFAULT_PROMPT_CACHE_TTL_MS; } });
|
|
73
|
+
Object.defineProperty(exports, "DEFAULT_SERVICE_NAME", { enumerable: true, get: function () { return config_js_2.DEFAULT_SERVICE_NAME; } });
|
|
74
|
+
Object.defineProperty(exports, "DEFAULT_SHUTDOWN_TIMEOUT_MS", { enumerable: true, get: function () { return config_js_2.DEFAULT_SHUTDOWN_TIMEOUT_MS; } });
|
|
75
|
+
Object.defineProperty(exports, "DESTINATION_CHOICES", { enumerable: true, get: function () { return config_js_2.DESTINATION_CHOICES; } });
|
|
76
|
+
Object.defineProperty(exports, "destinations", { enumerable: true, get: function () { return config_js_2.destinations; } });
|
|
77
|
+
Object.defineProperty(exports, "parseKvList", { enumerable: true, get: function () { return config_js_2.parseKvList; } });
|
|
78
|
+
Object.defineProperty(exports, "resolveSettings", { enumerable: true, get: function () { return config_js_2.resolveSettings; } });
|
|
79
|
+
var attrs_js_2 = require("./attrs.js");
|
|
80
|
+
Object.defineProperty(exports, "Attr", { enumerable: true, get: function () { return attrs_js_2.K; } });
|
|
81
|
+
Object.defineProperty(exports, "LIMITS", { enumerable: true, get: function () { return attrs_js_2.LIMITS; } });
|
|
82
|
+
Object.defineProperty(exports, "REQUEST_PARAMS", { enumerable: true, get: function () { return attrs_js_2.REQUEST_PARAMS; } });
|
|
83
|
+
Object.defineProperty(exports, "SEMCONV_COMMIT", { enumerable: true, get: function () { return attrs_js_2.SEMCONV_COMMIT; } });
|
|
84
|
+
Object.defineProperty(exports, "SEMCONV_SCHEMA_URL", { enumerable: true, get: function () { return attrs_js_2.SEMCONV_SCHEMA_URL; } });
|
|
85
|
+
var context_js_2 = require("./context.js");
|
|
86
|
+
Object.defineProperty(exports, "getCurrentAttributes", { enumerable: true, get: function () { return context_js_2.getCurrentAttributes; } });
|
|
87
|
+
Object.defineProperty(exports, "identify", { enumerable: true, get: function () { return context_js_2.identify; } });
|
|
88
|
+
Object.defineProperty(exports, "propagateAttributes", { enumerable: true, get: function () { return context_js_2.propagateAttributes; } });
|
|
89
|
+
var destination_js_2 = require("./destination.js");
|
|
90
|
+
Object.defineProperty(exports, "DISCOVERY_PATH", { enumerable: true, get: function () { return destination_js_2.DISCOVERY_PATH; } });
|
|
91
|
+
Object.defineProperty(exports, "isLoopbackUrl", { enumerable: true, get: function () { return destination_js_2.isLoopbackUrl; } });
|
|
92
|
+
Object.defineProperty(exports, "parseDiscovery", { enumerable: true, get: function () { return destination_js_2.parseDiscovery; } });
|
|
93
|
+
Object.defineProperty(exports, "readCredentialFile", { enumerable: true, get: function () { return destination_js_2.readCredentialFile; } });
|
|
94
|
+
var policy_js_2 = require("./policy.js");
|
|
95
|
+
Object.defineProperty(exports, "keepTrace", { enumerable: true, get: function () { return policy_js_2.keepTrace; } });
|
|
96
|
+
Object.defineProperty(exports, "TRUNCATED_MARK", { enumerable: true, get: function () { return policy_js_2.TRUNCATED_MARK; } });
|
|
97
|
+
var propagation_js_1 = require("./propagation.js");
|
|
98
|
+
Object.defineProperty(exports, "continueTrace", { enumerable: true, get: function () { return propagation_js_1.continueTrace; } });
|
|
99
|
+
Object.defineProperty(exports, "extract", { enumerable: true, get: function () { return propagation_js_1.extract; } });
|
|
100
|
+
Object.defineProperty(exports, "getTraceparent", { enumerable: true, get: function () { return propagation_js_1.getTraceparent; } });
|
|
101
|
+
Object.defineProperty(exports, "inject", { enumerable: true, get: function () { return propagation_js_1.inject; } });
|
|
102
|
+
var spans_js_2 = require("./spans.js");
|
|
103
|
+
Object.defineProperty(exports, "Kind", { enumerable: true, get: function () { return spans_js_2.Kind; } });
|
|
104
|
+
Object.defineProperty(exports, "getCurrentSpanId", { enumerable: true, get: function () { return spans_js_2.getCurrentSpanId; } });
|
|
105
|
+
Object.defineProperty(exports, "getCurrentTraceId", { enumerable: true, get: function () { return spans_js_2.getCurrentTraceId; } });
|
|
106
|
+
Object.defineProperty(exports, "observe", { enumerable: true, get: function () { return spans_js_2.observe; } });
|
|
107
|
+
Object.defineProperty(exports, "setContent", { enumerable: true, get: function () { return spans_js_2.setContent; } });
|
|
108
|
+
Object.defineProperty(exports, "setDocuments", { enumerable: true, get: function () { return spans_js_2.setDocuments; } });
|
|
109
|
+
Object.defineProperty(exports, "setInput", { enumerable: true, get: function () { return spans_js_2.setInput; } });
|
|
110
|
+
Object.defineProperty(exports, "setOutput", { enumerable: true, get: function () { return spans_js_2.setOutput; } });
|
|
111
|
+
Object.defineProperty(exports, "setRequestParams", { enumerable: true, get: function () { return spans_js_2.setRequestParams; } });
|
|
112
|
+
Object.defineProperty(exports, "setToolResult", { enumerable: true, get: function () { return spans_js_2.setToolResult; } });
|
|
113
|
+
Object.defineProperty(exports, "setUsage", { enumerable: true, get: function () { return spans_js_2.setUsage; } });
|
|
114
|
+
Object.defineProperty(exports, "withAgentSpan", { enumerable: true, get: function () { return spans_js_2.withAgentSpan; } });
|
|
115
|
+
Object.defineProperty(exports, "withEmbeddingSpan", { enumerable: true, get: function () { return spans_js_2.withEmbeddingSpan; } });
|
|
116
|
+
Object.defineProperty(exports, "withLlmSpan", { enumerable: true, get: function () { return spans_js_2.withLlmSpan; } });
|
|
117
|
+
Object.defineProperty(exports, "withRetrieverSpan", { enumerable: true, get: function () { return spans_js_2.withRetrieverSpan; } });
|
|
118
|
+
Object.defineProperty(exports, "withSpan", { enumerable: true, get: function () { return spans_js_2.withSpan; } });
|
|
119
|
+
Object.defineProperty(exports, "withToolSpan", { enumerable: true, get: function () { return spans_js_2.withToolSpan; } });
|
|
120
|
+
__exportStar(require("./scores.js"), exports);
|
|
121
|
+
__exportStar(require("./cost.js"), exports);
|
|
122
|
+
__exportStar(require("./prompts.js"), exports);
|
|
123
|
+
__exportStar(require("./experiments.js"), exports);
|
|
124
|
+
__exportStar(require("./instrument.js"), exports);
|
|
125
|
+
const processor = new export_js_1.SwitchableProcessor();
|
|
126
|
+
const sampler = new policy_js_1.SwitchableSampler();
|
|
127
|
+
let processorHandedOut = false;
|
|
128
|
+
const state = {
|
|
129
|
+
provider: null,
|
|
130
|
+
ownProvider: null,
|
|
131
|
+
mode: "",
|
|
132
|
+
configKey: "",
|
|
133
|
+
exitHooked: false,
|
|
134
|
+
active: [],
|
|
135
|
+
problems: [],
|
|
136
|
+
notes: [],
|
|
137
|
+
signedIn: null,
|
|
138
|
+
effective: null,
|
|
139
|
+
ready: Promise.resolve(),
|
|
140
|
+
vendorTracing: {},
|
|
141
|
+
};
|
|
142
|
+
let ownResource = {};
|
|
143
|
+
const objectIds = new WeakMap();
|
|
144
|
+
let nextObjectId = 1;
|
|
145
|
+
let initGeneration = 0;
|
|
146
|
+
function oid(o) {
|
|
147
|
+
if (!o)
|
|
148
|
+
return 0;
|
|
149
|
+
let id = objectIds.get(o);
|
|
150
|
+
if (!id) {
|
|
151
|
+
id = nextObjectId++;
|
|
152
|
+
objectIds.set(o, id);
|
|
153
|
+
}
|
|
154
|
+
return id;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The SDK's span processor, for an app on OpenTelemetry JS 2.x that builds its
|
|
158
|
+
* own provider (2.x providers take processors only at construction):
|
|
159
|
+
*
|
|
160
|
+
* ```ts
|
|
161
|
+
* const provider = new NodeTracerProvider({ spanProcessors: [spanProcessor(), ...yours] });
|
|
162
|
+
* provider.register();
|
|
163
|
+
* init({ serviceName: "my-app" }); // exports through that provider
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
function spanProcessor() {
|
|
167
|
+
processorHandedOut = true;
|
|
168
|
+
return processor;
|
|
169
|
+
}
|
|
170
|
+
function globalDelegate() {
|
|
171
|
+
const tp = api_1.trace.getTracerProvider();
|
|
172
|
+
const d = tp instanceof api_1.ProxyTracerProvider ? tp.getDelegate() : tp;
|
|
173
|
+
const noop = new api_1.ProxyTracerProvider().getDelegate();
|
|
174
|
+
if (!d || d.constructor === noop.constructor)
|
|
175
|
+
return null;
|
|
176
|
+
return d;
|
|
177
|
+
}
|
|
178
|
+
function addable(tp) {
|
|
179
|
+
return typeof tp.addSpanProcessor === "function";
|
|
180
|
+
}
|
|
181
|
+
function warnOnce(lines) {
|
|
182
|
+
for (const l of lines) {
|
|
183
|
+
export_js_1.stats.lastError = l;
|
|
184
|
+
export_js_1.stats.lastErrorAt = Date.now();
|
|
185
|
+
try {
|
|
186
|
+
console.warn(`@superbased/sdk: ${l}`);
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
// ignore
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/** One exporter per destination; each on its own batch processor, so one failing never blocks another. */
|
|
194
|
+
function buildDelegate(dests, exporter, console) {
|
|
195
|
+
const targets = exporter ? [dests[0] ?? { name: "local", endpoint: "", headers: {}, timeoutMs: 5000 }] : dests;
|
|
196
|
+
const procs = targets.map((d) => new sdk_trace_base_1.BatchSpanProcessor(new export_js_1.CountingExporter(exporter ?? new exporter_trace_otlp_http_1.OTLPTraceExporter({ url: d.endpoint, headers: d.headers, timeoutMillis: d.timeoutMs })), { exportTimeoutMillis: d.timeoutMs }));
|
|
197
|
+
if (console)
|
|
198
|
+
procs.push(new sdk_trace_base_1.SimpleSpanProcessor(new sdk_trace_base_1.ConsoleSpanExporter()));
|
|
199
|
+
if (procs.length === 0)
|
|
200
|
+
return null;
|
|
201
|
+
// Each destination's CountingExporter counts a span on its own; the console
|
|
202
|
+
// processor counts nothing (review E-31).
|
|
203
|
+
if (procs.length === 1 && targets.length === 1)
|
|
204
|
+
return procs[0];
|
|
205
|
+
return new export_js_1.Fanout(procs, targets.length);
|
|
206
|
+
}
|
|
207
|
+
/** A delegate that drops (and counts) every span: an online-only choice with no online URL. */
|
|
208
|
+
class DroppingProcessor {
|
|
209
|
+
onStart() { }
|
|
210
|
+
onEnd() {
|
|
211
|
+
export_js_1.stats.droppedSpans += 1;
|
|
212
|
+
}
|
|
213
|
+
async forceFlush() { }
|
|
214
|
+
async shutdown() { }
|
|
215
|
+
}
|
|
216
|
+
function installExitHook() {
|
|
217
|
+
if (state.exitHooked || typeof process === "undefined" || typeof process.on !== "function")
|
|
218
|
+
return;
|
|
219
|
+
state.exitHooked = true;
|
|
220
|
+
let running = false;
|
|
221
|
+
process.on("beforeExit", () => {
|
|
222
|
+
// beforeExit fires again after the flush's work drains; only flush when
|
|
223
|
+
// something is pending, so the loop ends.
|
|
224
|
+
if (running || !runtime_js_1.runtime.settings?.exitHook || !processor.active)
|
|
225
|
+
return;
|
|
226
|
+
if (Number((0, export_js_1.snapshot)().pendingSpans) === 0)
|
|
227
|
+
return;
|
|
228
|
+
running = true;
|
|
229
|
+
void flush().finally(() => {
|
|
230
|
+
running = false;
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* The destination when it can be known without the machine; null = ask the
|
|
236
|
+
* machine first (contract destination.md section 3; sdk-api-surface.md
|
|
237
|
+
* section 6). The machine is asked when nothing chose a destination, and
|
|
238
|
+
* also when an explicit `online` / `both` still lacks a gateway URL or a
|
|
239
|
+
* credential, which discovery supplies (review finding R-B09; Python does
|
|
240
|
+
* the same), and when an explicit `local` / `both` has no endpoint the app
|
|
241
|
+
* named for the local destination: the machine advertises its receiver
|
|
242
|
+
* (live finding L-01). A named endpoint (the option or
|
|
243
|
+
* SUPERBASED_OTLP_ENDPOINT, or under `local` an OTEL_* one) needs no answer.
|
|
244
|
+
*/
|
|
245
|
+
function syncChoice(opts, env, s) {
|
|
246
|
+
const chosen = (0, config_js_1.resolveDestinationChoice)(opts.destination, env);
|
|
247
|
+
const onlineGap = (c) => (c === "online" || c === "both") && (!s.orgUrl || !s.apiKey);
|
|
248
|
+
// A local destination the app named no endpoint for exports to the receiver
|
|
249
|
+
// the machine advertises (a machine on other ports; live finding L-01).
|
|
250
|
+
const localGap = (c) => (c === "local" || c === "both") && !(0, config_js_1.localEndpointNamed)(s, c);
|
|
251
|
+
const canAsk = s.discover && s.discoverTimeoutMs > 0;
|
|
252
|
+
// A caller-supplied exporter takes every span; control calls follow the choice ("" = online when configured, else local).
|
|
253
|
+
if (opts.exporter)
|
|
254
|
+
return [chosen.choice, "exporter"];
|
|
255
|
+
if (chosen.choice && !(canAsk && (onlineGap(chosen.choice) || localGap(chosen.choice))))
|
|
256
|
+
return [chosen.choice, chosen.source];
|
|
257
|
+
if (!canAsk)
|
|
258
|
+
return chosen.choice ? [chosen.choice, chosen.source] : s.orgUrl && s.apiKey ? ["online", "inferred"] : ["local", "default"];
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
/** No destination chosen and no machine answered: a gateway and a credential given to the app mean `online`. */
|
|
262
|
+
function inferred(s, otherwise) {
|
|
263
|
+
return s.orgUrl && s.apiKey ? "online" : otherwise;
|
|
264
|
+
}
|
|
265
|
+
function activate(s, choice, source, opts, printSpans, extraProblems = [], notes = [], signedIn = null) {
|
|
266
|
+
runtime_js_1.runtime.settings = s;
|
|
267
|
+
runtime_js_1.runtime.resourceService = ""; // a new init: the next span says which service
|
|
268
|
+
state.effective = s;
|
|
269
|
+
state.notes = notes;
|
|
270
|
+
state.signedIn = signedIn;
|
|
271
|
+
if (s.debug)
|
|
272
|
+
for (const n of notes)
|
|
273
|
+
console.info(`@superbased/sdk: ${n}`);
|
|
274
|
+
runtime_js_1.runtime.destination = choice;
|
|
275
|
+
runtime_js_1.runtime.destinationSource = source;
|
|
276
|
+
const dests = (0, config_js_1.destinations)(s, choice);
|
|
277
|
+
state.active = opts.exporter ? dests.slice(0, 1) : dests;
|
|
278
|
+
state.problems = [
|
|
279
|
+
...(s.destinationInvalid ? [s.destinationInvalid] : []),
|
|
280
|
+
...(s.samplingInvalid ? [s.samplingInvalid] : []),
|
|
281
|
+
...extraProblems,
|
|
282
|
+
...(opts.exporter ? [] : (0, config_js_1.destinationProblems)(s, choice)),
|
|
283
|
+
];
|
|
284
|
+
if (state.problems.length)
|
|
285
|
+
warnOnce(state.problems);
|
|
286
|
+
return buildDelegate(dests, opts.exporter, printSpans) ?? new DroppingProcessor();
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Configure tracing to export to superbased over OTLP/HTTP. Idempotent.
|
|
290
|
+
*
|
|
291
|
+
* Every option maps to an env var (`SUPERBASED_*`, then the standard `OTEL_*`
|
|
292
|
+
* one where it exists); an explicit option wins. See the README's settings
|
|
293
|
+
* table.
|
|
294
|
+
*
|
|
295
|
+
* Destination (D18): `local` (this machine), `online` (the org or SaaS
|
|
296
|
+
* gateway) or `both`, from the option, `SUPERBASED_DESTINATION`, the local
|
|
297
|
+
* Observer's default, then a fallback. See {@link ready}.
|
|
298
|
+
*
|
|
299
|
+
* - No provider registered yet: the SDK registers its own (mode `owned`).
|
|
300
|
+
* - An OTel JS 1.x SDK provider is registered: the SDK adds its processor to
|
|
301
|
+
* it (mode `attached`).
|
|
302
|
+
* - An OTel JS 2.x provider built with `spanProcessors: [spanProcessor()]`:
|
|
303
|
+
* the SDK exports through it (mode `attached`).
|
|
304
|
+
* - Any other provider is registered: the SDK keeps a private provider for
|
|
305
|
+
* its own spans (mode `standalone`); they still join the active trace.
|
|
306
|
+
*
|
|
307
|
+
* A second call with the same settings is a no-op; with different settings it
|
|
308
|
+
* replaces the SDK's exporters in place, shutting the previous ones down.
|
|
309
|
+
*/
|
|
310
|
+
function init(opts = {}) {
|
|
311
|
+
const { console: consoleOpt, exporter, tracerProvider, mask, shouldExport, ...input } = opts;
|
|
312
|
+
const env = (typeof process !== "undefined" ? process.env : {});
|
|
313
|
+
const s = (0, config_js_1.resolveSettings)(env, input);
|
|
314
|
+
const printSpans = consoleOpt ?? ["1", "true", "yes", "on"].includes((env.SUPERBASED_CONSOLE ?? "").toLowerCase());
|
|
315
|
+
runtime_js_1.runtime.settings = s;
|
|
316
|
+
runtime_js_1.runtime.resourceService = ""; // a new init: the next span says which service
|
|
317
|
+
runtime_js_1.runtime.captureContent = s.captureContent;
|
|
318
|
+
runtime_js_1.runtime.maxContentChars = s.maxContentChars;
|
|
319
|
+
export_js_1.stats.debug = s.debug;
|
|
320
|
+
sampler.set(s.sampleRate, s.parentBased);
|
|
321
|
+
// A model client library that traces itself (the Anthropic SDKs) would
|
|
322
|
+
// record every call a second time on the provider registered below.
|
|
323
|
+
state.vendorTracing = (0, vendor_js_1.applyVendorTracing)();
|
|
324
|
+
processor.policy = {
|
|
325
|
+
captureContent: s.captureContent,
|
|
326
|
+
maxContentChars: s.maxContentChars,
|
|
327
|
+
mask,
|
|
328
|
+
shouldExport,
|
|
329
|
+
exportRatio: state.mode === "attached" ? s.sampleRate : undefined,
|
|
330
|
+
dropScopePrefixes: (0, vendor_js_1.dropScopePrefixes)(state.vendorTracing),
|
|
331
|
+
};
|
|
332
|
+
const { captureContent: _c, maxContentChars: _m, exitHook: _e, debug: _d, sampleRate: _r, parentBased: _pb, discoverTimeoutMs: _t, apiTimeoutMs: _a, promptCacheTtlMs: _p, ...exportShape } = s;
|
|
333
|
+
const configKey = JSON.stringify([exportShape, printSpans, oid(exporter), oid(tracerProvider)]);
|
|
334
|
+
if (processor.active && configKey === state.configKey)
|
|
335
|
+
return publicView(s);
|
|
336
|
+
// Process-wide identity on the resource (contract section 2): release and
|
|
337
|
+
// environment as the standard service.version / deployment.environment.name.
|
|
338
|
+
const base = new context_js_1.Scope().merged({ tenant: s.tenant, user: s.user, sessionId: s.sessionId, tags: s.tags, metadata: s.metadata });
|
|
339
|
+
const ident = { [attrs_js_1.K.sdk]: runtime_js_1.SDK_MARKER, ...base.attributes() };
|
|
340
|
+
if (s.release)
|
|
341
|
+
ident[attrs_js_1.K.serviceVersion] = s.release;
|
|
342
|
+
if (s.environment)
|
|
343
|
+
ident[attrs_js_1.K.deploymentEnvironment] = s.environment;
|
|
344
|
+
if (!state.provider || (tracerProvider && tracerProvider !== state.provider)) {
|
|
345
|
+
const candidate = tracerProvider ?? globalDelegate();
|
|
346
|
+
if (candidate && candidate === state.ownProvider) {
|
|
347
|
+
state.provider = candidate;
|
|
348
|
+
state.mode = "owned";
|
|
349
|
+
}
|
|
350
|
+
else if (candidate && addable(candidate)) {
|
|
351
|
+
candidate.addSpanProcessor(processor);
|
|
352
|
+
state.provider = candidate;
|
|
353
|
+
state.mode = "attached";
|
|
354
|
+
}
|
|
355
|
+
else if (candidate && processorHandedOut) {
|
|
356
|
+
state.provider = candidate;
|
|
357
|
+
state.mode = "attached";
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
ownResource = { ...s.resourceAttributes, ...ident, "service.name": s.serviceName };
|
|
361
|
+
const own = new sdk_trace_node_1.NodeTracerProvider({
|
|
362
|
+
resource: (0, resources_1.defaultResource)().merge((0, resources_1.resourceFromAttributes)(ownResource)),
|
|
363
|
+
spanProcessors: [processor],
|
|
364
|
+
sampler,
|
|
365
|
+
});
|
|
366
|
+
state.ownProvider = own;
|
|
367
|
+
state.provider = own;
|
|
368
|
+
if (candidate) {
|
|
369
|
+
state.mode = "standalone";
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
own.register();
|
|
373
|
+
state.mode = "owned";
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
const provider = state.provider;
|
|
378
|
+
processor.policy.exportRatio = state.mode === "attached" ? s.sampleRate : undefined;
|
|
379
|
+
// Identity the holding provider's resource does not carry is stamped on spans.
|
|
380
|
+
const resAttrs = state.mode === "owned" || state.mode === "standalone" ? ownResource : {};
|
|
381
|
+
const stamp = {};
|
|
382
|
+
for (const [k, v] of Object.entries(ident)) {
|
|
383
|
+
if (JSON.stringify(resAttrs[k]) !== JSON.stringify(v))
|
|
384
|
+
stamp[k] = v;
|
|
385
|
+
}
|
|
386
|
+
processor.shutdownTimeoutMs = s.shutdownTimeoutMs;
|
|
387
|
+
const gen = ++initGeneration;
|
|
388
|
+
const sync = syncChoice(opts, env, s);
|
|
389
|
+
let delegate;
|
|
390
|
+
runtime_js_1.runtime.admissionUrl = "";
|
|
391
|
+
if (sync) {
|
|
392
|
+
delegate = activate(s, sync[0], sync[1], opts, printSpans);
|
|
393
|
+
state.ready = Promise.resolve();
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
const pending = new destination_js_1.PendingProcessor();
|
|
397
|
+
delegate = pending;
|
|
398
|
+
runtime_js_1.runtime.destination = "";
|
|
399
|
+
runtime_js_1.runtime.destinationSource = "discovering";
|
|
400
|
+
state.active = [];
|
|
401
|
+
state.problems = [];
|
|
402
|
+
const chosen = (0, config_js_1.resolveDestinationChoice)(opts.destination, env);
|
|
403
|
+
state.ready = (0, destination_js_1.discoverDestination)(s.nodeUrl, s.discoverTimeoutMs).then(({ found, error }) => {
|
|
404
|
+
if (gen !== initGeneration) {
|
|
405
|
+
pending.resolve(null);
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
const notes = error && error !== "discovery off" ? [error] : [];
|
|
409
|
+
if (!found) {
|
|
410
|
+
// No machine answered: the explicit choice, else inferred online, else local (a NOTE, not a warning).
|
|
411
|
+
const choice = chosen.choice || inferred(s, "local");
|
|
412
|
+
const source = chosen.choice ? chosen.source : choice === "online" ? "inferred" : "default";
|
|
413
|
+
pending.resolve(activate(s, choice, source, opts, printSpans, [], notes));
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
const choice = chosen.choice || found.destination;
|
|
417
|
+
const source = chosen.choice ? chosen.source : "machine";
|
|
418
|
+
const { settings: merged, problems } = (0, destination_js_1.withDiscovered)(s, found, choice);
|
|
419
|
+
runtime_js_1.runtime.admissionUrl = found.admissionUrl;
|
|
420
|
+
pending.resolve(activate(merged, choice, source, opts, printSpans, problems, notes, found.signedIn));
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
// Control calls wait for the destination (review E-33); never rejects.
|
|
424
|
+
runtime_js_1.runtime.ready = state.ready.then(() => undefined, () => undefined);
|
|
425
|
+
const old = processor.swap(delegate, stamp);
|
|
426
|
+
if (old)
|
|
427
|
+
void (0, export_js_1.shutdownBounded)(old, s.shutdownTimeoutMs);
|
|
428
|
+
state.configKey = configKey;
|
|
429
|
+
runtime_js_1.runtime.tracer = provider.getTracer(runtime_js_1.TRACER_NAME, runtime_js_1.VERSION);
|
|
430
|
+
runtime_js_1.runtime.provider = provider;
|
|
431
|
+
installExitHook();
|
|
432
|
+
return publicView(s);
|
|
433
|
+
}
|
|
434
|
+
const views = new WeakMap();
|
|
435
|
+
/** The fields that carry the credential (Python's repr=False fields). */
|
|
436
|
+
const SECRET_FIELDS = ["apiKey", "headers", "onlineHeaders"];
|
|
437
|
+
/**
|
|
438
|
+
* The settings as handed to the app: the same values, with the credential
|
|
439
|
+
* fields (`apiKey`, and the header maps, which may carry `Authorization`)
|
|
440
|
+
* readable but not enumerable, so `console.log`, `JSON.stringify` and a
|
|
441
|
+
* spread never print the key (as Python's Settings repr hides it; review
|
|
442
|
+
* R-C33). The SDK's own copy is unchanged.
|
|
443
|
+
*/
|
|
444
|
+
function publicView(s) {
|
|
445
|
+
let v = views.get(s);
|
|
446
|
+
if (!v) {
|
|
447
|
+
v = { ...s };
|
|
448
|
+
for (const f of SECRET_FIELDS)
|
|
449
|
+
Object.defineProperty(v, f, { value: s[f], enumerable: false, writable: false, configurable: false });
|
|
450
|
+
views.set(s, v);
|
|
451
|
+
}
|
|
452
|
+
return v;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Resolves once the destination is known (immediately unless init is asking
|
|
456
|
+
* the local Observer for its default, which takes at most
|
|
457
|
+
* `discoverTimeoutMs`). Spans finished before then are held, not lost.
|
|
458
|
+
*/
|
|
459
|
+
async function ready() {
|
|
460
|
+
await state.ready;
|
|
461
|
+
return runtime_js_1.runtime.destination;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* The settings the last `init()` resolved (null before init). `apiKey` and the
|
|
465
|
+
* header maps are readable but not enumerable, so logging the object never
|
|
466
|
+
* prints the credential.
|
|
467
|
+
*/
|
|
468
|
+
function settings() {
|
|
469
|
+
return runtime_js_1.runtime.settings ? publicView(runtime_js_1.runtime.settings) : null;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Export every finished span now. Bounded by `timeoutMs` (default: the
|
|
473
|
+
* shutdownTimeoutMs setting). Resolves true when everything went out in time;
|
|
474
|
+
* never rejects. Await it at the end of a serverless handler.
|
|
475
|
+
*/
|
|
476
|
+
async function flush(timeoutMs) {
|
|
477
|
+
const ms = timeoutMs ?? runtime_js_1.runtime.settings?.shutdownTimeoutMs ?? 2000;
|
|
478
|
+
const control = (0, export_js_1.bounded)((0, control_js_1.controlIdle)(), ms); // pending score / experiment writes
|
|
479
|
+
const d = processor.current;
|
|
480
|
+
let ok = true;
|
|
481
|
+
try {
|
|
482
|
+
if (d)
|
|
483
|
+
ok = await (0, export_js_1.flushBounded)(d, ms);
|
|
484
|
+
}
|
|
485
|
+
catch {
|
|
486
|
+
ok = false;
|
|
487
|
+
}
|
|
488
|
+
return (await control) && ok;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Flush and stop the SDK's exporters. Bounded by `timeoutMs` even when an
|
|
492
|
+
* endpoint is down; never rejects (ECONNREFUSED, 302 and 401 included). The
|
|
493
|
+
* host's provider, when the SDK attached to one, keeps running. A later
|
|
494
|
+
* `init()` starts exporting again.
|
|
495
|
+
*/
|
|
496
|
+
async function shutdown(timeoutMs) {
|
|
497
|
+
const old = processor.swap(null, {});
|
|
498
|
+
state.configKey = "";
|
|
499
|
+
if (!old)
|
|
500
|
+
return true;
|
|
501
|
+
try {
|
|
502
|
+
return await (0, export_js_1.shutdownBounded)(old, timeoutMs ?? runtime_js_1.runtime.settings?.shutdownTimeoutMs ?? 2000);
|
|
503
|
+
}
|
|
504
|
+
catch {
|
|
505
|
+
return false;
|
|
506
|
+
}
|
|
507
|
+
finally {
|
|
508
|
+
(0, export_js_1.maybeLogFailures)();
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
/** A snapshot of the SDK's export health. */
|
|
512
|
+
function diagnostics() {
|
|
513
|
+
const snap = (0, export_js_1.snapshot)();
|
|
514
|
+
return {
|
|
515
|
+
mode: state.mode,
|
|
516
|
+
initialized: processor.active,
|
|
517
|
+
destination: runtime_js_1.runtime.destination,
|
|
518
|
+
destinationSource: runtime_js_1.runtime.destinationSource,
|
|
519
|
+
destinations: state.active.map((d) => ({ name: d.name, endpoint: d.endpoint })),
|
|
520
|
+
destinationProblems: [...state.problems],
|
|
521
|
+
gatewayUrl: state.effective?.orgUrl ?? "",
|
|
522
|
+
degraded: state.effective && runtime_js_1.runtime.destination ? ((0, config_js_1.destinationProblems)(state.effective, runtime_js_1.runtime.destination)[0] ?? "") : "",
|
|
523
|
+
notes: [...state.notes],
|
|
524
|
+
signedIn: state.signedIn,
|
|
525
|
+
credentialSource: state.effective?.credentialSource ?? "",
|
|
526
|
+
pendingSpans: Number(snap.pendingSpans),
|
|
527
|
+
exportedSpans: Number(snap.exportedSpans),
|
|
528
|
+
failedExports: Number(snap.failedExports),
|
|
529
|
+
droppedSpans: Number(snap.droppedSpans),
|
|
530
|
+
sampledOutSpans: Number(snap.sampledOutSpans),
|
|
531
|
+
filteredSpans: Number(snap.filteredSpans),
|
|
532
|
+
shouldExportErrors: Number(snap.shouldExportErrors),
|
|
533
|
+
maskErrors: Number(snap.maskErrors),
|
|
534
|
+
lastHookError: String(snap.lastHookError),
|
|
535
|
+
lastError: String(snap.lastError),
|
|
536
|
+
lastErrorAt: Number(snap.lastErrorAt),
|
|
537
|
+
controlCalls: control_js_1.controlStats.calls,
|
|
538
|
+
controlFailures: control_js_1.controlStats.failures,
|
|
539
|
+
controlLastError: control_js_1.controlStats.lastError,
|
|
540
|
+
admissionDegraded: admit_js_2.admitStats.degraded,
|
|
541
|
+
admissionLastError: admit_js_2.admitStats.lastError,
|
|
542
|
+
admissionLastErrorAt: admit_js_2.admitStats.lastErrorAt,
|
|
543
|
+
vendorTracing: { ...state.vendorTracing },
|
|
544
|
+
vendorSpansDropped: policy_js_1.policyStats.vendorSpansDropped,
|
|
545
|
+
usageNetInputCorrected: policy_js_1.policyStats.usageNetInputCorrected,
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
/** Forget all SDK state (tests only). Does not touch the global provider. */
|
|
549
|
+
async function _resetForTests() {
|
|
550
|
+
const old = processor.swap(null, {});
|
|
551
|
+
if (old)
|
|
552
|
+
await (0, export_js_1.shutdownBounded)(old, 1000);
|
|
553
|
+
Object.assign(state, {
|
|
554
|
+
provider: null,
|
|
555
|
+
ownProvider: null,
|
|
556
|
+
mode: "",
|
|
557
|
+
configKey: "",
|
|
558
|
+
active: [],
|
|
559
|
+
problems: [],
|
|
560
|
+
notes: [],
|
|
561
|
+
signedIn: null,
|
|
562
|
+
effective: null,
|
|
563
|
+
ready: Promise.resolve(),
|
|
564
|
+
vendorTracing: {},
|
|
565
|
+
});
|
|
566
|
+
(0, vendor_js_1.resetVendorTracingForTests)();
|
|
567
|
+
(0, spans_js_1._resetNetInputWarningForTests)();
|
|
568
|
+
initGeneration++;
|
|
569
|
+
processorHandedOut = false;
|
|
570
|
+
ownResource = {};
|
|
571
|
+
processor.policy = { captureContent: true, maxContentChars: 0 };
|
|
572
|
+
sampler.set(1, true);
|
|
573
|
+
(0, runtime_js_1.resetRuntime)();
|
|
574
|
+
(0, export_js_1.resetStats)();
|
|
575
|
+
(0, policy_js_1.resetPolicyStats)();
|
|
576
|
+
(0, context_js_1._resetContextForTests)();
|
|
577
|
+
(0, control_js_1.resetControlForTests)();
|
|
578
|
+
(0, admit_js_2.resetAdmitStats)();
|
|
579
|
+
(0, prompts_js_1.clearPromptCache)();
|
|
580
|
+
}
|
|
581
|
+
//# sourceMappingURL=index.js.map
|