@veryfront/ext-content-mdx 0.1.1185 → 0.1.1188
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/esm/_dnt.polyfills.d.ts +6 -6
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/deno.d.ts +34 -0
- package/esm/deno.js +50 -9
- package/esm/src/config/defaults.d.ts +31 -24
- package/esm/src/config/defaults.d.ts.map +1 -1
- package/esm/src/config/defaults.js +25 -18
- package/esm/src/errors/diagnostic-policy.d.ts +35 -0
- package/esm/src/errors/diagnostic-policy.d.ts.map +1 -0
- package/esm/src/errors/diagnostic-policy.js +100 -0
- package/esm/src/errors/error-registry/boundary.d.ts +2 -0
- package/esm/src/errors/error-registry/boundary.d.ts.map +1 -1
- package/esm/src/errors/error-registry/boundary.js +8 -0
- package/esm/src/errors/error-registry/config.d.ts.map +1 -1
- package/esm/src/errors/error-registry/config.js +3 -3
- package/esm/src/errors/error-registry/deploy.js +1 -1
- package/esm/src/errors/error-registry/server.d.ts +2 -0
- package/esm/src/errors/error-registry/server.d.ts.map +1 -1
- package/esm/src/errors/error-registry/server.js +8 -0
- package/esm/src/errors/error-registry-helpers.d.ts +11 -2
- package/esm/src/errors/error-registry-helpers.d.ts.map +1 -1
- package/esm/src/errors/error-registry-helpers.js +70 -1
- package/esm/src/errors/error-registry.d.ts +87 -75
- package/esm/src/errors/error-registry.d.ts.map +1 -1
- package/esm/src/errors/error-registry.js +2 -14
- package/esm/src/errors/types.d.ts +44 -5
- package/esm/src/errors/types.d.ts.map +1 -1
- package/esm/src/errors/types.js +148 -24
- package/esm/src/errors/veryfront-error.d.ts +25 -2
- package/esm/src/errors/veryfront-error.d.ts.map +1 -1
- package/esm/src/errors/veryfront-error.js +638 -28
- package/esm/src/observability/limits.d.ts +20 -0
- package/esm/src/observability/limits.d.ts.map +1 -0
- package/esm/src/observability/limits.js +19 -0
- package/esm/src/observability/telemetry-error.d.ts +22 -0
- package/esm/src/observability/telemetry-error.d.ts.map +1 -0
- package/esm/src/observability/telemetry-error.js +377 -0
- package/esm/src/observability/tracing/api-shim.d.ts +39 -0
- package/esm/src/observability/tracing/api-shim.d.ts.map +1 -1
- package/esm/src/observability/tracing/api-shim.js +196 -69
- package/esm/src/observability/tracing/context-callback.d.ts +14 -0
- package/esm/src/observability/tracing/context-callback.d.ts.map +1 -0
- package/esm/src/observability/tracing/context-callback.js +111 -0
- package/esm/src/observability/tracing/otlp-setup.d.ts.map +1 -1
- package/esm/src/observability/tracing/otlp-setup.js +190 -46
- package/esm/src/platform/adapters/base.d.ts +63 -1
- package/esm/src/platform/adapters/base.d.ts.map +1 -1
- package/esm/src/platform/adapters/base.js +4 -2
- package/esm/src/platform/adapters/bounded-file-read.d.ts +43 -0
- package/esm/src/platform/adapters/bounded-file-read.d.ts.map +1 -0
- package/esm/src/platform/adapters/bounded-file-read.js +185 -0
- package/esm/src/platform/adapters/file-snapshot-error.d.ts +8 -0
- package/esm/src/platform/adapters/file-snapshot-error.d.ts.map +1 -0
- package/esm/src/platform/adapters/file-snapshot-error.js +13 -0
- package/esm/src/platform/adapters/file-system-capabilities.d.ts +74 -0
- package/esm/src/platform/adapters/file-system-capabilities.d.ts.map +1 -0
- package/esm/src/platform/adapters/file-system-capabilities.js +508 -0
- package/esm/src/platform/adapters/native-file-system-provenance.d.ts +6 -0
- package/esm/src/platform/adapters/native-file-system-provenance.d.ts.map +1 -0
- package/esm/src/platform/adapters/native-file-system-provenance.js +15 -0
- package/esm/src/platform/adapters/runtime/deno/filesystem-adapter.d.ts +45 -0
- package/esm/src/platform/adapters/runtime/deno/filesystem-adapter.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/deno/filesystem-adapter.js +291 -0
- package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.d.ts +71 -0
- package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.js +471 -0
- package/esm/src/platform/adapters/runtime/shared/shared-watcher.d.ts +16 -0
- package/esm/src/platform/adapters/runtime/shared/shared-watcher.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/shared/shared-watcher.js +140 -0
- package/esm/src/platform/adapters/runtime/shared/temp-dir.d.ts +2 -0
- package/esm/src/platform/adapters/runtime/shared/temp-dir.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/shared/temp-dir.js +10 -0
- package/esm/src/platform/adapters/runtime/shared/watcher-queue.d.ts +5 -0
- package/esm/src/platform/adapters/runtime/shared/watcher-queue.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/shared/watcher-queue.js +75 -0
- package/esm/src/platform/compat/abort-signal.d.ts +20 -0
- package/esm/src/platform/compat/abort-signal.d.ts.map +1 -0
- package/esm/src/platform/compat/abort-signal.js +64 -0
- package/esm/src/platform/compat/constants.d.ts +2 -2
- package/esm/src/platform/compat/constants.d.ts.map +1 -1
- package/esm/src/platform/compat/constants.js +2 -2
- package/esm/src/platform/compat/error-introspection.d.ts +37 -0
- package/esm/src/platform/compat/error-introspection.d.ts.map +1 -0
- package/esm/src/platform/compat/error-introspection.js +258 -0
- package/esm/src/platform/compat/fs.d.ts +33 -8
- package/esm/src/platform/compat/fs.d.ts.map +1 -1
- package/esm/src/platform/compat/fs.js +144 -42
- package/esm/src/platform/compat/native-brand-checks.d.ts +14 -0
- package/esm/src/platform/compat/native-brand-checks.d.ts.map +1 -0
- package/esm/src/platform/compat/native-brand-checks.js +68 -0
- package/esm/src/platform/compat/not-found-error.d.ts +12 -0
- package/esm/src/platform/compat/not-found-error.d.ts.map +1 -0
- package/esm/src/platform/compat/not-found-error.js +174 -0
- package/esm/src/platform/compat/path/security.d.ts.map +1 -1
- package/esm/src/platform/compat/path/security.js +3 -5
- package/esm/src/platform/compat/process/command.d.ts +24 -1
- package/esm/src/platform/compat/process/command.d.ts.map +1 -1
- package/esm/src/platform/compat/process/command.js +393 -78
- package/esm/src/platform/compat/process/env.d.ts +11 -0
- package/esm/src/platform/compat/process/env.d.ts.map +1 -1
- package/esm/src/platform/compat/process/env.js +28 -38
- package/esm/src/platform/compat/process/global-error.d.ts +19 -0
- package/esm/src/platform/compat/process/global-error.d.ts.map +1 -0
- package/esm/src/platform/compat/process/global-error.js +57 -0
- package/esm/src/platform/compat/process/lifecycle.d.ts +10 -3
- package/esm/src/platform/compat/process/lifecycle.d.ts.map +1 -1
- package/esm/src/platform/compat/process/lifecycle.js +74 -23
- package/esm/src/platform/compat/process/project-env-contract.d.ts +19 -0
- package/esm/src/platform/compat/process/project-env-contract.d.ts.map +1 -0
- package/esm/src/platform/compat/process/project-env-contract.js +19 -0
- package/esm/src/platform/compat/process.d.ts +1 -1
- package/esm/src/platform/compat/runtime.d.ts +14 -5
- package/esm/src/platform/compat/runtime.d.ts.map +1 -1
- package/esm/src/platform/compat/runtime.js +34 -9
- package/esm/src/platform/compat/std/front-matter-yaml.d.ts +12 -0
- package/esm/src/platform/compat/std/front-matter-yaml.d.ts.map +1 -1
- package/esm/src/platform/compat/std/front-matter-yaml.js +35 -3
- package/esm/src/platform/compat/temp-directory-prefix.d.ts +8 -0
- package/esm/src/platform/compat/temp-directory-prefix.d.ts.map +1 -0
- package/esm/src/platform/compat/temp-directory-prefix.js +15 -0
- package/esm/src/utils/abort.d.ts +10 -0
- package/esm/src/utils/abort.d.ts.map +1 -0
- package/esm/src/utils/abort.js +35 -0
- package/esm/src/utils/constants/build.d.ts +12 -0
- package/esm/src/utils/constants/build.d.ts.map +1 -1
- package/esm/src/utils/constants/build.js +13 -0
- package/esm/src/utils/constants/cache.d.ts +21 -0
- package/esm/src/utils/constants/cache.d.ts.map +1 -1
- package/esm/src/utils/constants/cache.js +101 -39
- package/esm/src/utils/constants/css.d.ts +20 -0
- package/esm/src/utils/constants/css.d.ts.map +1 -0
- package/esm/src/utils/constants/css.js +19 -0
- package/esm/src/utils/constants/index.d.ts +1 -1
- package/esm/src/utils/constants/index.d.ts.map +1 -1
- package/esm/src/utils/constants/index.js +1 -1
- package/esm/src/utils/constants/limits.d.ts +4 -0
- package/esm/src/utils/constants/limits.d.ts.map +1 -1
- package/esm/src/utils/constants/limits.js +4 -0
- package/esm/src/utils/constants/project-identity.d.ts +5 -0
- package/esm/src/utils/constants/project-identity.d.ts.map +1 -0
- package/esm/src/utils/constants/project-identity.js +4 -0
- package/esm/src/utils/constants/retry.d.ts +18 -0
- package/esm/src/utils/constants/retry.d.ts.map +1 -1
- package/esm/src/utils/constants/retry.js +18 -0
- package/esm/src/utils/constants/security.d.ts +4 -0
- package/esm/src/utils/constants/security.d.ts.map +1 -1
- package/esm/src/utils/constants/security.js +4 -0
- package/esm/src/utils/css-artifact-identity.d.ts +23 -0
- package/esm/src/utils/css-artifact-identity.d.ts.map +1 -0
- package/esm/src/utils/css-artifact-identity.js +77 -0
- package/esm/src/utils/index.d.ts +4 -1
- package/esm/src/utils/index.d.ts.map +1 -1
- package/esm/src/utils/index.js +4 -1
- package/esm/src/utils/logger/core.d.ts +5 -0
- package/esm/src/utils/logger/core.d.ts.map +1 -1
- package/esm/src/utils/logger/core.js +67 -2
- package/esm/src/utils/logger/redact.d.ts +36 -13
- package/esm/src/utils/logger/redact.d.ts.map +1 -1
- package/esm/src/utils/logger/redact.js +573 -83
- package/esm/src/utils/parallel.d.ts.map +1 -1
- package/esm/src/utils/parallel.js +11 -1
- package/esm/src/utils/project-identity.d.ts +11 -0
- package/esm/src/utils/project-identity.d.ts.map +1 -0
- package/esm/src/utils/project-identity.js +69 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +3 -3
|
@@ -12,9 +12,13 @@
|
|
|
12
12
|
* - OTEL_EXPORTER_OTLP_HEADERS: Auth headers
|
|
13
13
|
**************************/
|
|
14
14
|
import { isTruthyEnvValue } from "../../utils/constants/env.js";
|
|
15
|
-
import {
|
|
15
|
+
import { MAX_SPAN_NAME_LENGTH } from "../../utils/constants/index.js";
|
|
16
|
+
import { __registerTraceContextGetter, serverLogger } from "../../utils/logger/logger.js";
|
|
17
|
+
import { sanitizeUrlForSpan } from "../../utils/logger/redact.js";
|
|
16
18
|
import { context as shimContext, defaultTextMapGetter, defaultTextMapSetter, getTracer, getTracerProviderRevision, propagation as shimPropagation, SpanKind, SpanStatusCode, trace as shimTrace, } from "./api-shim.js";
|
|
17
19
|
import { getHostTelemetryEnv } from "./telemetry-env.js";
|
|
20
|
+
import { sanitizeErrorForTelemetry, sanitizeTelemetryAttributes, sanitizeTelemetryAttributeValue, sanitizeTelemetryText, } from "../telemetry-error.js";
|
|
21
|
+
import { runAsyncWithContextFallback, runSyncWithContextFallback } from "./context-callback.js";
|
|
18
22
|
const logger = serverLogger.component("otel");
|
|
19
23
|
function parseHeaders(headerString) {
|
|
20
24
|
if (!headerString)
|
|
@@ -89,22 +93,123 @@ export async function initializeOTLPWithApis() {
|
|
|
89
93
|
// ---------------------------------------------------------------------------
|
|
90
94
|
// Span helpers — delegate to shim (which delegates to SDK if wired)
|
|
91
95
|
// ---------------------------------------------------------------------------
|
|
96
|
+
function reportTelemetryFailure(failureMessage, error) {
|
|
97
|
+
try {
|
|
98
|
+
logger.debug(failureMessage, error);
|
|
99
|
+
}
|
|
100
|
+
catch (_) {
|
|
101
|
+
/* expected: telemetry and logging failures must not affect application work */
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function runTelemetryOperation(operation, failureMessage) {
|
|
105
|
+
try {
|
|
106
|
+
operation();
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
reportTelemetryFailure(failureMessage, error);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function createInertContext(entries = new Map()) {
|
|
113
|
+
const values = new Map(entries);
|
|
114
|
+
return Object.freeze({
|
|
115
|
+
getValue: (key) => values.get(key),
|
|
116
|
+
setValue(key, value) {
|
|
117
|
+
const next = new Map(values);
|
|
118
|
+
next.set(key, value);
|
|
119
|
+
return createInertContext(next);
|
|
120
|
+
},
|
|
121
|
+
deleteValue(key) {
|
|
122
|
+
const next = new Map(values);
|
|
123
|
+
next.delete(key);
|
|
124
|
+
return createInertContext(next);
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function createInertSpan() {
|
|
129
|
+
const spanContext = Object.freeze({
|
|
130
|
+
traceId: "00000000000000000000000000000000",
|
|
131
|
+
spanId: "0000000000000000",
|
|
132
|
+
traceFlags: 0,
|
|
133
|
+
});
|
|
134
|
+
const span = Object.freeze({
|
|
135
|
+
setAttribute: () => span,
|
|
136
|
+
setAttributes: () => span,
|
|
137
|
+
setStatus: () => span,
|
|
138
|
+
recordException: () => { },
|
|
139
|
+
addEvent: () => span,
|
|
140
|
+
end: () => { },
|
|
141
|
+
spanContext: () => spanContext,
|
|
142
|
+
updateName: () => { },
|
|
143
|
+
});
|
|
144
|
+
return span;
|
|
145
|
+
}
|
|
146
|
+
function isUsableSpan(value) {
|
|
147
|
+
if ((typeof value !== "object" && typeof value !== "function") || value === null)
|
|
148
|
+
return false;
|
|
149
|
+
try {
|
|
150
|
+
const candidate = value;
|
|
151
|
+
return typeof candidate.setAttribute === "function" &&
|
|
152
|
+
typeof candidate.setAttributes === "function" &&
|
|
153
|
+
typeof candidate.setStatus === "function" &&
|
|
154
|
+
typeof candidate.recordException === "function" &&
|
|
155
|
+
typeof candidate.addEvent === "function" &&
|
|
156
|
+
typeof candidate.end === "function" &&
|
|
157
|
+
typeof candidate.spanContext === "function" &&
|
|
158
|
+
typeof candidate.updateName === "function";
|
|
159
|
+
}
|
|
160
|
+
catch (_) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function getActiveContextSafely() {
|
|
165
|
+
try {
|
|
166
|
+
const activeContext = shimContext.active();
|
|
167
|
+
if (activeContext)
|
|
168
|
+
return activeContext;
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
reportTelemetryFailure("Failed to read active tracing context", error);
|
|
172
|
+
}
|
|
173
|
+
return createInertContext();
|
|
174
|
+
}
|
|
175
|
+
function startSpanWithFallback(name, attributes, options) {
|
|
176
|
+
const parentContext = getActiveContextSafely();
|
|
177
|
+
let span = createInertSpan();
|
|
178
|
+
try {
|
|
179
|
+
const candidate = getTracingRuntime().tracer.startSpan(sanitizeTelemetryText(name, MAX_SPAN_NAME_LENGTH), {
|
|
180
|
+
kind: options?.kind ?? SpanKind.INTERNAL,
|
|
181
|
+
attributes: sanitizeTelemetryAttributes(attributes),
|
|
182
|
+
}, parentContext);
|
|
183
|
+
if (!isUsableSpan(candidate)) {
|
|
184
|
+
throw new TypeError("Tracer returned an invalid span");
|
|
185
|
+
}
|
|
186
|
+
span = candidate;
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
reportTelemetryFailure("Failed to start span; using inert span", error);
|
|
190
|
+
}
|
|
191
|
+
let spanContext = parentContext;
|
|
192
|
+
try {
|
|
193
|
+
spanContext = shimTrace.setSpan(parentContext, span);
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
reportTelemetryFailure("Failed to associate span with context", error);
|
|
197
|
+
}
|
|
198
|
+
return { span, context: spanContext };
|
|
199
|
+
}
|
|
92
200
|
function setSpanErrorStatus(span, error) {
|
|
93
|
-
|
|
201
|
+
const telemetryError = sanitizeErrorForTelemetry(error);
|
|
202
|
+
runTelemetryOperation(() => span.setStatus({
|
|
94
203
|
code: SpanStatusCode.ERROR,
|
|
95
|
-
message:
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
span.recordException(error);
|
|
204
|
+
message: telemetryError.message,
|
|
205
|
+
}), "Failed to set span error status");
|
|
206
|
+
runTelemetryOperation(() => span.recordException(telemetryError), "Failed to record span exception");
|
|
99
207
|
}
|
|
100
208
|
/** Applies span. */
|
|
101
209
|
export async function withSpan(name, fn, attributes, options) {
|
|
102
|
-
const {
|
|
103
|
-
const parentContext = shimContext.active();
|
|
104
|
-
const span = tracer.startSpan(name, { kind: options?.kind ?? SpanKind.INTERNAL, attributes }, parentContext);
|
|
105
|
-
const spanContext = shimTrace.setSpan(parentContext, span);
|
|
210
|
+
const { span, context: spanContext } = startSpanWithFallback(name, attributes, options);
|
|
106
211
|
try {
|
|
107
|
-
const result = await shimContext.with(spanContext, () => fn(span));
|
|
212
|
+
const result = await runAsyncWithContextFallback((callback) => shimContext.with(spanContext, callback), () => fn(span), (error) => reportTelemetryFailure("Failed to activate span context", error));
|
|
108
213
|
return result;
|
|
109
214
|
}
|
|
110
215
|
catch (error) {
|
|
@@ -112,17 +217,15 @@ export async function withSpan(name, fn, attributes, options) {
|
|
|
112
217
|
throw error;
|
|
113
218
|
}
|
|
114
219
|
finally {
|
|
115
|
-
span.end();
|
|
220
|
+
runTelemetryOperation(() => span.end(), "Failed to end span");
|
|
116
221
|
}
|
|
117
222
|
}
|
|
118
223
|
/** Applies span sync. */
|
|
119
224
|
export function withSpanSync(name, fn, attributes, options) {
|
|
120
|
-
const {
|
|
121
|
-
const parentContext = shimContext.active();
|
|
122
|
-
const span = tracer.startSpan(name, { kind: options?.kind ?? SpanKind.INTERNAL, attributes }, parentContext);
|
|
225
|
+
const { span, context: spanContext } = startSpanWithFallback(name, attributes, options);
|
|
123
226
|
try {
|
|
124
|
-
const result = fn();
|
|
125
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
227
|
+
const result = runSyncWithContextFallback((callback) => shimContext.with(spanContext, callback), fn, (error) => reportTelemetryFailure("Failed to activate span context", error));
|
|
228
|
+
runTelemetryOperation(() => span.setStatus({ code: SpanStatusCode.OK }), "Failed to set span success status");
|
|
126
229
|
return result;
|
|
127
230
|
}
|
|
128
231
|
catch (error) {
|
|
@@ -130,73 +233,105 @@ export function withSpanSync(name, fn, attributes, options) {
|
|
|
130
233
|
throw error;
|
|
131
234
|
}
|
|
132
235
|
finally {
|
|
133
|
-
span.end();
|
|
236
|
+
runTelemetryOperation(() => span.end(), "Failed to end span");
|
|
134
237
|
}
|
|
135
238
|
}
|
|
136
239
|
/** Context for extract. */
|
|
137
240
|
export function extractContext(headers) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
241
|
+
try {
|
|
242
|
+
const carrier = {};
|
|
243
|
+
for (const [k, v] of headers)
|
|
244
|
+
carrier[k.toLowerCase()] = v;
|
|
245
|
+
return shimPropagation.extract(getActiveContextSafely(), carrier, defaultTextMapGetter);
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
reportTelemetryFailure("Failed to extract tracing context", error);
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
142
251
|
}
|
|
143
252
|
/** Context for inject. */
|
|
144
253
|
export function injectContext(headers) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
254
|
+
try {
|
|
255
|
+
const carrier = {};
|
|
256
|
+
shimPropagation.inject(getActiveContextSafely(), carrier, defaultTextMapSetter);
|
|
257
|
+
for (const [k, v] of Object.entries(carrier))
|
|
258
|
+
headers.set(k, v);
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
reportTelemetryFailure("Failed to inject tracing context", error);
|
|
262
|
+
}
|
|
149
263
|
}
|
|
150
264
|
/** Starts server span. */
|
|
151
265
|
export function startServerSpan(method, path, parentContext) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
266
|
+
let ctx;
|
|
267
|
+
let spanPath;
|
|
268
|
+
let span;
|
|
269
|
+
try {
|
|
270
|
+
ctx = (parentContext ?? getActiveContextSafely());
|
|
271
|
+
spanPath = sanitizeUrlForSpan(path);
|
|
272
|
+
const candidate = getTracingRuntime().tracer.startSpan(sanitizeTelemetryText(`${method} ${spanPath}`, MAX_SPAN_NAME_LENGTH), { kind: SpanKind.SERVER }, ctx);
|
|
273
|
+
if (!isUsableSpan(candidate))
|
|
274
|
+
throw new TypeError("Tracer returned an invalid server span");
|
|
275
|
+
span = candidate;
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
reportTelemetryFailure("Failed to start server span", error);
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
runTelemetryOperation(() => span.setAttribute("http.method", sanitizeTelemetryAttributeValue("http.method", method)), "Failed to set server span method");
|
|
282
|
+
runTelemetryOperation(() => span.setAttribute("http.target", sanitizeTelemetryAttributeValue("http.target", spanPath)), "Failed to set server span target");
|
|
283
|
+
let spanContext = ctx;
|
|
284
|
+
try {
|
|
285
|
+
spanContext = shimTrace.setSpan(ctx, span);
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
reportTelemetryFailure("Failed to associate server span with context", error);
|
|
289
|
+
}
|
|
290
|
+
return { span, context: spanContext };
|
|
158
291
|
}
|
|
159
292
|
/** End an active server tracing span. */
|
|
160
293
|
export function endServerSpan(span, statusCode, error) {
|
|
161
294
|
if (!span)
|
|
162
295
|
return;
|
|
163
296
|
const otelSpan = span;
|
|
164
|
-
otelSpan.setAttribute("http.status_code", statusCode);
|
|
297
|
+
runTelemetryOperation(() => otelSpan.setAttribute("http.status_code", statusCode), "Failed to set server span status code");
|
|
165
298
|
if (error) {
|
|
166
299
|
setSpanErrorStatus(otelSpan, error);
|
|
167
|
-
otelSpan.end();
|
|
300
|
+
runTelemetryOperation(() => otelSpan.end(), "Failed to end server span");
|
|
168
301
|
return;
|
|
169
302
|
}
|
|
170
303
|
if (statusCode >= 400) {
|
|
171
|
-
otelSpan.setStatus({ code: SpanStatusCode.ERROR });
|
|
172
|
-
otelSpan.end();
|
|
304
|
+
runTelemetryOperation(() => otelSpan.setStatus({ code: SpanStatusCode.ERROR }), "Failed to set server span error status");
|
|
305
|
+
runTelemetryOperation(() => otelSpan.end(), "Failed to end server span");
|
|
173
306
|
return;
|
|
174
307
|
}
|
|
175
|
-
otelSpan.setStatus({ code: SpanStatusCode.OK });
|
|
176
|
-
otelSpan.end();
|
|
308
|
+
runTelemetryOperation(() => otelSpan.setStatus({ code: SpanStatusCode.OK }), "Failed to set server span success status");
|
|
309
|
+
runTelemetryOperation(() => otelSpan.end(), "Failed to end server span");
|
|
177
310
|
}
|
|
178
311
|
/** Sets span attributes. */
|
|
179
312
|
export function setSpanAttributes(span, attributes) {
|
|
180
313
|
if (!span)
|
|
181
314
|
return;
|
|
182
315
|
const otelSpan = span;
|
|
183
|
-
for (const [key, value] of Object.entries(attributes))
|
|
184
|
-
otelSpan.setAttribute(key, value);
|
|
316
|
+
for (const [key, value] of Object.entries(sanitizeTelemetryAttributes(attributes))) {
|
|
317
|
+
runTelemetryOperation(() => otelSpan.setAttribute(key, value), "Failed to set span attribute");
|
|
318
|
+
}
|
|
185
319
|
}
|
|
186
320
|
/** Adds an event to a span. */
|
|
187
321
|
export function addSpanEvent(span, name, attributes) {
|
|
188
322
|
if (!span)
|
|
189
323
|
return;
|
|
190
324
|
const otelSpan = span;
|
|
191
|
-
otelSpan.addEvent(name, attributes);
|
|
325
|
+
runTelemetryOperation(() => otelSpan.addEvent(sanitizeTelemetryText(name, MAX_SPAN_NAME_LENGTH), sanitizeTelemetryAttributes(attributes)), "Failed to add span event");
|
|
192
326
|
}
|
|
193
327
|
/** Sets active span attributes. */
|
|
194
328
|
export function setActiveSpanAttributes(attributes) {
|
|
195
329
|
const span = shimTrace.getActiveSpan?.();
|
|
196
330
|
if (!span)
|
|
197
331
|
return;
|
|
198
|
-
for (const [key, value] of Object.entries(attributes))
|
|
199
|
-
span.setAttribute(key, value);
|
|
332
|
+
for (const [key, value] of Object.entries(sanitizeTelemetryAttributes(attributes))) {
|
|
333
|
+
runTelemetryOperation(() => span.setAttribute(key, value), "Failed to set active span attribute");
|
|
334
|
+
}
|
|
200
335
|
}
|
|
201
336
|
/** Marks the active span as failed. */
|
|
202
337
|
export function setActiveSpanErrorStatus(error) {
|
|
@@ -207,13 +342,22 @@ export function setActiveSpanErrorStatus(error) {
|
|
|
207
342
|
}
|
|
208
343
|
/** Context for with. */
|
|
209
344
|
export async function withContext(spanContext, fn) {
|
|
210
|
-
return shimContext.with(spanContext, fn);
|
|
345
|
+
return await runAsyncWithContextFallback((callback) => shimContext.with(spanContext, callback), fn, (error) => logger.debug("Failed to activate explicit span context", error));
|
|
211
346
|
}
|
|
212
347
|
/** Context for get trace. */
|
|
213
348
|
export function getTraceContext() {
|
|
214
349
|
const span = shimTrace.getActiveSpan?.();
|
|
215
350
|
if (!span)
|
|
216
351
|
return {};
|
|
217
|
-
|
|
218
|
-
|
|
352
|
+
try {
|
|
353
|
+
const ctx = span.spanContext();
|
|
354
|
+
return { traceId: ctx.traceId, spanId: ctx.spanId };
|
|
355
|
+
}
|
|
356
|
+
catch (_) {
|
|
357
|
+
return {};
|
|
358
|
+
}
|
|
219
359
|
}
|
|
360
|
+
// The higher observability layer owns this adapter registration. Keeping the
|
|
361
|
+
// dependency direction here prevents generic logging utilities from importing
|
|
362
|
+
// OpenTelemetry implementation code.
|
|
363
|
+
__registerTraceContextGetter(getTraceContext);
|
|
@@ -122,10 +122,61 @@ export interface Server {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
export interface FileSystemAdapter {
|
|
125
|
+
/**
|
|
126
|
+
* Explicitly declares that paths in this adapter cannot traverse symbolic
|
|
127
|
+
* links. The backing store may reject links or expose them only as inert
|
|
128
|
+
* entries, but it must never resolve a path through one. Native/local
|
|
129
|
+
* adapters must omit this marker and provide lstat and realPath instead.
|
|
130
|
+
*/
|
|
131
|
+
readonly symlinkSemantics?: "none";
|
|
132
|
+
/** Adapter is immutably bound to one project and needs no request scope. */
|
|
133
|
+
readonly projectContextSemantics?: "fixed";
|
|
125
134
|
readFile(path: string): Promise<string>;
|
|
126
135
|
/** Read raw bytes when binary-safe access is required */
|
|
127
136
|
readFileBytes?(path: string): Promise<Uint8Array>;
|
|
137
|
+
/**
|
|
138
|
+
* Fixed whole-object ceiling enforced by the backing store or transport
|
|
139
|
+
* before a complete response can be materialized.
|
|
140
|
+
*
|
|
141
|
+
* This capability is distinct from `readFileBytesBounded`: the caller does
|
|
142
|
+
* not choose the read size, and the implementation may materialize up to
|
|
143
|
+
* this advertised ceiling even for a smaller file. It may be advertised
|
|
144
|
+
* only alongside `readFileBytes` and only when the upstream boundary itself
|
|
145
|
+
* rejects larger objects before returning them.
|
|
146
|
+
*/
|
|
147
|
+
readonly maxWholeFileReadBytes?: number;
|
|
148
|
+
/**
|
|
149
|
+
* Read a prefix without materializing more than `byteLimit` bytes.
|
|
150
|
+
*
|
|
151
|
+
* Implementations must enforce the limit while reading from their backing
|
|
152
|
+
* store and continue until EOF or `byteLimit`; reading the complete object
|
|
153
|
+
* and slicing afterward does not satisfy this capability. Callers can
|
|
154
|
+
* request their accepted maximum plus one byte to distinguish an exact-size
|
|
155
|
+
* file from an oversized file. Non-native adapters used for bounded Skill
|
|
156
|
+
* discovery or strict Skill runtime reads must implement this capability.
|
|
157
|
+
*/
|
|
158
|
+
readFileBytesBounded?(path: string, byteLimit: number): Promise<Uint8Array>;
|
|
159
|
+
/**
|
|
160
|
+
* Read the complete file only when it is no larger than `byteLimit`.
|
|
161
|
+
*
|
|
162
|
+
* Implementations must enforce the limit while reading and reject when the
|
|
163
|
+
* source has even one additional byte. They must not implement this by
|
|
164
|
+
* materializing the whole object or by retaining a `byteLimit + 1` prefix.
|
|
165
|
+
* Oversized sources reject with `RangeError`; other I/O failures propagate.
|
|
166
|
+
*/
|
|
167
|
+
readFileBytesWithinLimit?(path: string, byteLimit: number): Promise<Uint8Array>;
|
|
168
|
+
/**
|
|
169
|
+
* Read one stable file snapshot beneath `containmentRoot` without following
|
|
170
|
+
* links and only when its complete contents fit within `byteLimit`.
|
|
171
|
+
*/
|
|
172
|
+
readFileSnapshotWithinLimit?(path: string, containmentRoot: string, byteLimit: number): Promise<Uint8Array>;
|
|
128
173
|
writeFile(path: string, content: string): Promise<void>;
|
|
174
|
+
/** Write raw bytes when binary-safe output is required. */
|
|
175
|
+
writeFileBytes?(path: string, content: Uint8Array): Promise<void>;
|
|
176
|
+
/** Create a new byte file without replacing an existing path. */
|
|
177
|
+
createFileBytesExclusive?(path: string, content: Uint8Array): Promise<void>;
|
|
178
|
+
/** Atomically replace a path when the runtime supports same-filesystem rename. */
|
|
179
|
+
rename?(from: string, to: string): Promise<void>;
|
|
129
180
|
exists(path: string): Promise<boolean>;
|
|
130
181
|
readDir(path: string): AsyncIterable<DirEntry>;
|
|
131
182
|
stat(path: string): Promise<FileInfo>;
|
|
@@ -168,6 +219,10 @@ export interface FileSystemAdapter {
|
|
|
168
219
|
*/
|
|
169
220
|
getSourceSnapshotVersion?(): number | undefined | Promise<number | undefined>;
|
|
170
221
|
}
|
|
222
|
+
/** A filesystem adapter that advertises genuine bounded byte reads. */
|
|
223
|
+
export type BoundedFileSystemAdapter = FileSystemAdapter & Required<Pick<FileSystemAdapter, "readFileBytesBounded">>;
|
|
224
|
+
/** A filesystem adapter that can return only complete, size-admitted files. */
|
|
225
|
+
export type ExactBoundedFileSystemAdapter = FileSystemAdapter & Required<Pick<FileSystemAdapter, "readFileBytesWithinLimit">>;
|
|
171
226
|
export interface ResolveFileOptions {
|
|
172
227
|
allowPagesPrefix?: boolean;
|
|
173
228
|
}
|
|
@@ -200,11 +255,18 @@ export interface FileChangeEvent {
|
|
|
200
255
|
}
|
|
201
256
|
export interface FileWatcher extends AsyncIterable<FileChangeEvent> {
|
|
202
257
|
close(): void;
|
|
258
|
+
/**
|
|
259
|
+
* Resolves once the underlying watcher has been installed and can observe
|
|
260
|
+
* subsequent filesystem changes. Rejects when any requested watch root
|
|
261
|
+
* cannot be acquired; callers must not advertise watching before it resolves.
|
|
262
|
+
*/
|
|
263
|
+
ready?: Promise<void>;
|
|
203
264
|
/**
|
|
204
265
|
* Resolves once the watcher's internal loop has fully stopped, including
|
|
205
266
|
* any in-flight filesystem operations. close() only signals shutdown;
|
|
206
267
|
* await this to guarantee no pending async ops remain (e.g. before test
|
|
207
|
-
* sanitizer checks or process exit).
|
|
268
|
+
* sanitizer checks or process exit). Rejects when the native watcher fails
|
|
269
|
+
* or teardown cannot complete cleanly.
|
|
208
270
|
*/
|
|
209
271
|
done?: Promise<void>;
|
|
210
272
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/adapters/base.ts"],"names":[],"mappings":"AAAA;;yBAEyB;AACzB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAEvF,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,GAAG,QAAQ,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,yCAAyC;IACzC,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IAEvB,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,iDAAiD;IACjD,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAE3C,4BAA4B;IAC5B,EAAE,EAAE,iBAAiB,CAAC;IAEtB,kCAAkC;IAClC,GAAG,EAAE,kBAAkB,CAAC;IAExB,6BAA6B;IAC7B,MAAM,EAAE,aAAa,CAAC;IAEtB,KAAK,CACH,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,EAC3D,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB,yCAAyC;IACzC,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB,+CAA+C;IAC/C,EAAE,CAAC,EAAE,cAAc,CAAC;IAEpB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAE7B,4DAA4D;IAC5D,UAAU,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7B,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,mBA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AAO,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;CACtE"}
|
|
@@ -52,8 +52,10 @@ export function isWebSocketUpgradeResponse(value) {
|
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
54
|
try {
|
|
55
|
-
//
|
|
56
|
-
//
|
|
55
|
+
// A structural object with a `get()` method is not a Headers instance and
|
|
56
|
+
// can run arbitrary code when the transport clones it. Invoke a captured
|
|
57
|
+
// Web IDL primordial to verify the native internal slot without consulting
|
|
58
|
+
// attacker-controlled properties or Symbol.hasInstance hooks.
|
|
57
59
|
Reflect.apply(headersGet, headers.value, ["upgrade"]);
|
|
58
60
|
}
|
|
59
61
|
catch {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal handle contract shared by native filesystem adapters.
|
|
3
|
+
*
|
|
4
|
+
* The caller supplies the handle factory so each runtime can choose its native
|
|
5
|
+
* open semantics while this helper owns bounded chunking and cleanup.
|
|
6
|
+
*/
|
|
7
|
+
export interface BoundedFileReader {
|
|
8
|
+
read(buffer: Uint8Array): Promise<number | null>;
|
|
9
|
+
}
|
|
10
|
+
export interface BoundedFileReadHandle extends BoundedFileReader {
|
|
11
|
+
close(): void | Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Run one operation against one opened file handle, then close it exactly once.
|
|
15
|
+
*
|
|
16
|
+
* When the operation and cleanup both fail, the aggregate retains the primary
|
|
17
|
+
* operation failure first and the cleanup failure second.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withFileHandle<THandle extends {
|
|
20
|
+
close(): void | Promise<void>;
|
|
21
|
+
}, TResult>(openHandle: () => Promise<THandle>, operation: (handle: THandle) => Promise<TResult>, aggregateFailureMessage: string): Promise<TResult>;
|
|
22
|
+
export declare function requireBoundedFileReadLimit(byteLimit: unknown): number;
|
|
23
|
+
/**
|
|
24
|
+
* Read at most `byteLimit` bytes without first materializing the whole file.
|
|
25
|
+
*
|
|
26
|
+
* A full-length result is intentionally ambiguous: callers that need to
|
|
27
|
+
* distinguish an exact-size file from an oversized file request their accepted
|
|
28
|
+
* maximum plus one byte.
|
|
29
|
+
*/
|
|
30
|
+
export declare function readBoundedFilePrefix(openHandle: () => Promise<BoundedFileReadHandle>, byteLimit: number): Promise<Uint8Array>;
|
|
31
|
+
/**
|
|
32
|
+
* Read the complete file only when it fits within `byteLimit`.
|
|
33
|
+
*
|
|
34
|
+
* Unlike a prefix read, reaching the limit triggers one additional EOF probe.
|
|
35
|
+
* The probe reuses the final byte of the accepted buffer, so the helper never
|
|
36
|
+
* retains more than `byteLimit` bytes from the source.
|
|
37
|
+
*/
|
|
38
|
+
export declare function readFileWithinLimit(openHandle: () => Promise<BoundedFileReadHandle>, byteLimit: number): Promise<Uint8Array>;
|
|
39
|
+
/** Read a bounded prefix while leaving ownership of the open handle to the caller. */
|
|
40
|
+
export declare function readBoundedFileHandlePrefix(reader: BoundedFileReader, byteLimit: number): Promise<Uint8Array>;
|
|
41
|
+
/** Read a complete bounded file while leaving ownership of the handle to the caller. */
|
|
42
|
+
export declare function readFileHandleWithinLimit(reader: BoundedFileReader, byteLimit: number): Promise<Uint8Array>;
|
|
43
|
+
//# sourceMappingURL=bounded-file-read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounded-file-read.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/adapters/bounded-file-read.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;C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