@vite-hub/runtime 0.0.3 → 0.0.4

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/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { n as isRuntimeObject, t as hasRuntimeType } from "./runtime-type-ovvOd6m5.js";
1
2
  //#region src/errors.ts
2
3
  const MAX_DETAIL_DEPTH = 8;
3
4
  const MAX_DETAIL_ENTRIES = 128;
@@ -186,6 +187,139 @@ function isViteHubError(value) {
186
187
  return getViteHubErrorShape(value) !== void 0;
187
188
  }
188
189
  //#endregion
190
+ //#region src/diagnostics.ts
191
+ function boundedString(value, state) {
192
+ if (!hasRuntimeType(value, "string")) return;
193
+ const maximum = Math.min(state.maxStringLength, state.remainingStringLength);
194
+ if (maximum <= 0) return;
195
+ if (value.length <= maximum) {
196
+ state.remainingStringLength -= value.length;
197
+ return value;
198
+ }
199
+ const suffix = `… [${value.length - maximum} chars omitted]`;
200
+ const bounded = maximum > suffix.length ? `${value.slice(0, maximum - suffix.length)}${suffix}` : value.slice(0, maximum);
201
+ state.remainingStringLength -= bounded.length;
202
+ return bounded;
203
+ }
204
+ function safeString(value) {
205
+ try {
206
+ return String(value);
207
+ } catch {
208
+ return "Unknown error";
209
+ }
210
+ }
211
+ function readProperty(value, key) {
212
+ if (!isRuntimeObject(value)) return void 0;
213
+ try {
214
+ return value[key];
215
+ } catch {
216
+ return;
217
+ }
218
+ }
219
+ function scalarProperty(value, key, state) {
220
+ const property = readProperty(value, key);
221
+ if (hasRuntimeType(property, "string")) return boundedString(property, state);
222
+ return hasRuntimeType(property, "number") && Number.isFinite(property) ? property : void 0;
223
+ }
224
+ function errorChildren(value, maximum) {
225
+ try {
226
+ if (!Array.isArray(value)) return;
227
+ const length = Math.min(value.length, maximum);
228
+ return Array.from({ length }, (_item, index) => readProperty(value, index));
229
+ } catch {
230
+ return [];
231
+ }
232
+ }
233
+ function normalizeDetailValue(value, state, depth) {
234
+ if (state.remainingNodes <= 0) return;
235
+ state.remainingNodes -= 1;
236
+ if (value === null || hasRuntimeType(value, "boolean")) return value;
237
+ if (hasRuntimeType(value, "number")) return Number.isFinite(value) ? value : void 0;
238
+ if (hasRuntimeType(value, "string")) return boundedString(value, state);
239
+ if (depth > state.maxDepth) return boundedString("[Detail depth exceeded]", state);
240
+ if (Array.isArray(value)) return value.flatMap((item) => {
241
+ const normalized = normalizeDetailValue(item, state, depth + 1);
242
+ return normalized === void 0 ? [] : [normalized];
243
+ });
244
+ if (!isRuntimeObject(value)) return;
245
+ const normalized = {};
246
+ let keys;
247
+ try {
248
+ keys = Object.keys(value);
249
+ } catch {
250
+ return normalized;
251
+ }
252
+ for (const key of keys) {
253
+ const normalizedKey = boundedString(key, state);
254
+ if (!normalizedKey) break;
255
+ const child = normalizeDetailValue(readProperty(value, key), state, depth + 1);
256
+ if (child !== void 0) normalized[normalizedKey] = child;
257
+ }
258
+ return normalized;
259
+ }
260
+ function normalizeDetails(details, state, depth) {
261
+ const normalized = normalizeDetailValue(details, state, depth);
262
+ if (!isRuntimeObject(normalized) || Array.isArray(normalized)) return;
263
+ return normalized;
264
+ }
265
+ function normalizeError(value, state, depth) {
266
+ if (state.remainingNodes <= 0) return;
267
+ state.remainingNodes -= 1;
268
+ if (hasRuntimeType(value, "string")) return { message: boundedString(value, state) || "Error" };
269
+ if (!value || !hasRuntimeType(value, "object")) return { message: boundedString(safeString(value), state) || "Error" };
270
+ if (state.ancestors.has(value)) return { message: boundedString("[Circular error cause]", state) || "Error" };
271
+ if (depth > state.maxDepth) return { message: boundedString("[Error cause depth exceeded]", state) || "Error" };
272
+ state.ancestors.add(value);
273
+ try {
274
+ const publicError = getViteHubErrorShape(value);
275
+ const message = boundedString(readProperty(value, "message"), state) || boundedString(safeString(value), state) || "Error";
276
+ const name = boundedString(readProperty(value, "name"), state) || boundedString(readProperty(readProperty(value, "constructor") || {}, "name"), state);
277
+ const result = {
278
+ message,
279
+ ...name ? { name } : {}
280
+ };
281
+ const code = publicError?.code ? boundedString(publicError.code, state) : scalarProperty(value, "code", state);
282
+ const requestId = publicError?.requestId ? boundedString(publicError.requestId, state) : boundedString(readProperty(value, "requestId"), state);
283
+ const status = scalarProperty(value, "status", state);
284
+ const statusCode = scalarProperty(value, "statusCode", state);
285
+ const stack = state.includeStack ? boundedString(readProperty(value, "stack"), state) : void 0;
286
+ if (code !== void 0) result.code = code;
287
+ if (requestId) result.requestId = requestId;
288
+ if (stack) result.stack = stack;
289
+ if (status !== void 0) result.status = status;
290
+ if (statusCode !== void 0) result.statusCode = statusCode;
291
+ const cause = readProperty(value, "cause");
292
+ const normalizedCause = cause === void 0 ? void 0 : normalizeError(cause, state, depth + 1);
293
+ if (normalizedCause) result.cause = normalizedCause;
294
+ const normalizedErrors = errorChildren(readProperty(value, "errors"), state.remainingNodes)?.flatMap((error) => {
295
+ const normalized = normalizeError(error, state, depth + 1);
296
+ return normalized ? [normalized] : [];
297
+ });
298
+ if (normalizedErrors?.length) result.errors = normalizedErrors;
299
+ const details = publicError?.details ? normalizeDetails(publicError.details, state, depth + 1) : void 0;
300
+ if (details) result.details = details;
301
+ return result;
302
+ } finally {
303
+ state.ancestors.delete(value);
304
+ }
305
+ }
306
+ function normalizeRuntimeDiagnosticError(error, options = {}) {
307
+ const maxDepth = options.maxDepth ?? 4;
308
+ const maxErrors = options.maxErrors ?? 8;
309
+ const maxStringLength = options.maxStringLength ?? 4096;
310
+ if (!Number.isInteger(maxDepth) || maxDepth < 0) throw new TypeError("[vitehub:runtime] Diagnostic error maxDepth must be a non-negative integer.");
311
+ if (!Number.isInteger(maxErrors) || maxErrors < 1) throw new TypeError("[vitehub:runtime] Diagnostic error maxErrors must be a positive integer.");
312
+ if (!Number.isInteger(maxStringLength) || maxStringLength < 64) throw new TypeError("[vitehub:runtime] Diagnostic error maxStringLength must be an integer of at least 64.");
313
+ return normalizeError(error, {
314
+ ancestors: /* @__PURE__ */ new Set(),
315
+ includeStack: options.includeStack === true,
316
+ maxDepth,
317
+ maxStringLength,
318
+ remainingNodes: maxErrors + 1,
319
+ remainingStringLength: maxStringLength * (maxErrors + 1)
320
+ }, 0);
321
+ }
322
+ //#endregion
189
323
  //#region src/index.ts
190
324
  const noExecutionAuthority = Object.freeze({
191
325
  credentials: "none",
@@ -210,44 +344,44 @@ const unknownExecutionAuthority = Object.freeze({
210
344
  processes: "unknown"
211
345
  });
212
346
  function isExecutionAuthority(value) {
213
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
347
+ if (!value || !hasRuntimeType(value, "object") || Array.isArray(value)) return false;
214
348
  const authority = value;
215
349
  const filesystem = authority.filesystem;
216
- if (!filesystem || typeof filesystem !== "object" || Array.isArray(filesystem)) return false;
350
+ if (!filesystem || !hasRuntimeType(filesystem, "object") || Array.isArray(filesystem)) return false;
217
351
  const files = filesystem;
218
- return typeof authority.credentials === "string" && [
352
+ return hasRuntimeType(authority.credentials, "string") && [
219
353
  "ambient",
220
354
  "none",
221
355
  "provisioned",
222
356
  "unknown"
223
- ].includes(authority.credentials) && typeof authority.environment === "string" && [
357
+ ].includes(authority.credentials) && hasRuntimeType(authority.environment, "string") && [
224
358
  "ambient",
225
359
  "none",
226
360
  "selected",
227
361
  "unknown"
228
- ].includes(authority.environment) && typeof files.access === "string" && [
362
+ ].includes(authority.environment) && hasRuntimeType(files.access, "string") && [
229
363
  "none",
230
364
  "read-only",
231
365
  "read-write",
232
366
  "unknown"
233
- ].includes(files.access) && typeof files.scope === "string" && [
367
+ ].includes(files.access) && hasRuntimeType(files.scope, "string") && [
234
368
  "host",
235
369
  "none",
236
370
  "sandbox",
237
371
  "unknown",
238
372
  "workspace"
239
- ].includes(files.scope) && typeof authority.isolation === "string" && [
373
+ ].includes(files.scope) && hasRuntimeType(authority.isolation, "string") && [
240
374
  "container",
241
375
  "microvm",
242
376
  "none",
243
377
  "process",
244
378
  "unknown"
245
- ].includes(authority.isolation) && typeof authority.network === "string" && [
379
+ ].includes(authority.isolation) && hasRuntimeType(authority.network, "string") && [
246
380
  "none",
247
381
  "restricted",
248
382
  "unrestricted",
249
383
  "unknown"
250
- ].includes(authority.network) && typeof authority.processes === "string" && [
384
+ ].includes(authority.network) && hasRuntimeType(authority.processes, "string") && [
251
385
  "arbitrary",
252
386
  "none",
253
387
  "restricted",
@@ -277,10 +411,11 @@ function normalizeExecutionAuthority(value) {
277
411
  });
278
412
  }
279
413
  function hasCanonicalFrozenProperties(value, keys) {
414
+ if (!isRuntimeObject(value)) return false;
280
415
  const prototype = Object.getPrototypeOf(value);
281
416
  if (!Object.isFrozen(value) || prototype !== Object.prototype && prototype !== null) return false;
282
417
  const ownKeys = Reflect.ownKeys(value);
283
- if (ownKeys.length !== keys.length || ownKeys.some((key) => typeof key !== "string" || !keys.includes(key))) return false;
418
+ if (ownKeys.length !== keys.length || ownKeys.some((key) => !hasRuntimeType(key, "string") || !keys.includes(key))) return false;
284
419
  return keys.every((key) => {
285
420
  const descriptor = Object.getOwnPropertyDescriptor(value, key);
286
421
  return descriptor !== void 0 && "value" in descriptor && descriptor.enumerable;
@@ -296,45 +431,58 @@ const contentAttributeKeys = new Set([
296
431
  "messages",
297
432
  "output",
298
433
  "payload",
434
+ "progress",
299
435
  "prompt",
300
436
  "raw",
301
437
  "request",
302
438
  "response",
303
439
  "result",
304
- "text"
440
+ "text",
441
+ "title"
305
442
  ]);
306
- function isContentAttributeKey(key) {
443
+ function isTraceContentAttributeKey(key) {
307
444
  if (key === "error.message") return false;
308
445
  if (contentAttributeKeys.has(key)) return true;
309
446
  return key.split(".").some((part, index) => index > 0 && contentAttributeKeys.has(part));
310
447
  }
311
- function isPlainRecord(value) {
312
- return Boolean(value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype);
313
- }
314
- function metadataValue(value) {
315
- if (Array.isArray(value)) return value.map(metadataValue);
316
- if (!isPlainRecord(value)) return value;
448
+ function metadataValue(value, seen = /* @__PURE__ */ new WeakSet()) {
449
+ if (!value || !hasRuntimeType(value, "object")) return value;
450
+ if (seen.has(value)) return "[Circular]";
451
+ seen.add(value);
452
+ if (Array.isArray(value)) {
453
+ const next = value.map((child) => metadataValue(child, seen));
454
+ seen.delete(value);
455
+ return next;
456
+ }
317
457
  const omitted = [];
318
- const next = Object.fromEntries(Object.entries(value).flatMap(([key, child]) => {
319
- if (isContentAttributeKey(key)) {
458
+ let entries;
459
+ try {
460
+ entries = Object.entries(value);
461
+ } catch {
462
+ seen.delete(value);
463
+ return;
464
+ }
465
+ const next = Object.fromEntries(entries.flatMap(([key, child]) => {
466
+ if (isTraceContentAttributeKey(key)) {
320
467
  omitted.push(key);
321
468
  return [];
322
469
  }
323
- return [[key, metadataValue(child)]];
470
+ return [[key, metadataValue(child, seen)]];
324
471
  }));
472
+ seen.delete(value);
325
473
  if (omitted.length) next["content.omitted"] = omitted;
326
474
  return next;
327
475
  }
328
476
  function timestamp(value) {
329
477
  if (value instanceof Date) return value.toISOString();
330
- if (typeof value === "string") return value;
478
+ if (hasRuntimeType(value, "string")) return value;
331
479
  return (/* @__PURE__ */ new Date()).toISOString();
332
480
  }
333
481
  function metadataAttributes(attributes) {
334
482
  if (!attributes) return void 0;
335
483
  const omitted = [];
336
484
  const next = Object.fromEntries(Object.entries(attributes).flatMap(([key, value]) => {
337
- if (isContentAttributeKey(key)) {
485
+ if (isTraceContentAttributeKey(key)) {
338
486
  omitted.push(key);
339
487
  return [];
340
488
  }
@@ -343,10 +491,316 @@ function metadataAttributes(attributes) {
343
491
  if (omitted.length) next["content.omitted"] = omitted;
344
492
  return Object.keys(next).length ? next : void 0;
345
493
  }
494
+ function normalizedTraceActivity(activity) {
495
+ if (!activity || !hasRuntimeType(activity, "object")) return;
496
+ try {
497
+ if (Array.isArray(activity)) return;
498
+ const owner = Object.getOwnPropertyDescriptor(activity, "owner");
499
+ const phase = Object.getOwnPropertyDescriptor(activity, "phase");
500
+ if (!owner || !("value" in owner) || !phase || !("value" in phase)) return;
501
+ if (owner.value !== "agent" && owner.value !== "vitehub") return;
502
+ if (![
503
+ "delivery",
504
+ "execution",
505
+ "setup",
506
+ "teardown"
507
+ ].includes(phase.value)) return;
508
+ return {
509
+ owner: owner.value,
510
+ phase: phase.value
511
+ };
512
+ } catch {
513
+ return;
514
+ }
515
+ }
516
+ function reflectedMapEntries(value) {
517
+ if (!value || !hasRuntimeType(value, "object")) return;
518
+ try {
519
+ return Array.from(Map.prototype.entries.call(value));
520
+ } catch {
521
+ return;
522
+ }
523
+ }
524
+ function reflectedSetValues(value) {
525
+ if (!value || !hasRuntimeType(value, "object")) return;
526
+ try {
527
+ return Array.from(Set.prototype.values.call(value));
528
+ } catch {
529
+ return;
530
+ }
531
+ }
532
+ function isCryptoKey(value) {
533
+ if (!value || !hasRuntimeType(value, "object")) return false;
534
+ const CryptoKeyConstructor = Object.getOwnPropertyDescriptor(globalThis, "CryptoKey")?.value;
535
+ return hasRuntimeType(CryptoKeyConstructor, "function") && value instanceof CryptoKeyConstructor;
536
+ }
537
+ function isWebAssemblyModule(value) {
538
+ if (!value || !hasRuntimeType(value, "object")) return false;
539
+ const namespace = Object.getOwnPropertyDescriptor(globalThis, "WebAssembly")?.value;
540
+ const constructor = hasRuntimeType(namespace, "object") ? Object.getOwnPropertyDescriptor(namespace, "Module")?.value : void 0;
541
+ return hasRuntimeType(constructor, "function") && value instanceof constructor;
542
+ }
543
+ function isSharedArrayBuffer(value) {
544
+ if (!value || !hasRuntimeType(value, "object")) return false;
545
+ const constructor = Object.getOwnPropertyDescriptor(globalThis, "SharedArrayBuffer")?.value;
546
+ if (hasRuntimeType(constructor, "function") && value instanceof constructor) return true;
547
+ return Object.prototype.toString.call(value) === "[object SharedArrayBuffer]";
548
+ }
549
+ function containsSharedArrayBuffer(value, seen = /* @__PURE__ */ new Set()) {
550
+ if (!value || !hasRuntimeType(value, "object")) return false;
551
+ if (isSharedArrayBuffer(value)) return true;
552
+ const WebAssemblyMemory = globalThis.WebAssembly?.Memory;
553
+ if (WebAssemblyMemory && value instanceof WebAssemblyMemory) return isSharedArrayBuffer(value.buffer);
554
+ if (seen.has(value)) return false;
555
+ seen.add(value);
556
+ if (ArrayBuffer.isView(value)) return containsSharedArrayBuffer(value.buffer, seen);
557
+ const mapEntries = reflectedMapEntries(value);
558
+ if (mapEntries) return mapEntries.some(([key, entry]) => containsSharedArrayBuffer(key, seen) || containsSharedArrayBuffer(entry, seen));
559
+ const setValues = reflectedSetValues(value);
560
+ if (setValues) return setValues.some((entry) => containsSharedArrayBuffer(entry, seen));
561
+ return Reflect.ownKeys(value).some((key) => {
562
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
563
+ return descriptor !== void 0 && "value" in descriptor && containsSharedArrayBuffer(descriptor.value, seen);
564
+ });
565
+ }
566
+ function reflectedRegExpState(value) {
567
+ if (!value || !hasRuntimeType(value, "object")) return;
568
+ try {
569
+ const source = Object.getOwnPropertyDescriptor(RegExp.prototype, "source")?.get?.call(value);
570
+ const flags = Object.getOwnPropertyDescriptor(RegExp.prototype, "flags")?.get?.call(value);
571
+ const lastIndex = Reflect.get(value, "lastIndex");
572
+ if (!hasRuntimeType(source, "string") || !hasRuntimeType(flags, "string") || !hasRuntimeType(lastIndex, "number")) return;
573
+ return {
574
+ flags,
575
+ lastIndex,
576
+ source
577
+ };
578
+ } catch {
579
+ return;
580
+ }
581
+ }
582
+ function reflectedBlobState(value) {
583
+ const BlobConstructor = globalThis.Blob;
584
+ if (!hasRuntimeType(BlobConstructor, "function") || !(value instanceof BlobConstructor)) return;
585
+ try {
586
+ const FileConstructor = globalThis.File;
587
+ const file = hasRuntimeType(FileConstructor, "function") && value instanceof FileConstructor ? value : void 0;
588
+ const intrinsic = file ? new FileConstructor([], "") : new BlobConstructor([]);
589
+ const size = Object.getOwnPropertyDescriptor(BlobConstructor.prototype, "size")?.get?.call(value);
590
+ const type = Object.getOwnPropertyDescriptor(BlobConstructor.prototype, "type")?.get?.call(value);
591
+ if (!hasRuntimeType(size, "number") || !hasRuntimeType(type, "string")) return;
592
+ const state = {
593
+ intrinsicSymbols: new Set(Reflect.ownKeys(intrinsic).filter((key) => hasRuntimeType(key, "symbol") && Object.getOwnPropertyDescriptor(intrinsic, key)?.enumerable === true)),
594
+ size,
595
+ type
596
+ };
597
+ if (file) {
598
+ const lastModified = Object.getOwnPropertyDescriptor(FileConstructor.prototype, "lastModified")?.get?.call(file);
599
+ const name = Object.getOwnPropertyDescriptor(FileConstructor.prototype, "name")?.get?.call(file);
600
+ if (!hasRuntimeType(lastModified, "number") || !hasRuntimeType(name, "string")) return;
601
+ state.lastModified = lastModified;
602
+ state.name = name;
603
+ }
604
+ return state;
605
+ } catch {
606
+ return;
607
+ }
608
+ }
609
+ function containsUnsafeStructuredCloneState(value, seen = /* @__PURE__ */ new Set()) {
610
+ if (!value || !hasRuntimeType(value, "object") || seen.has(value)) return false;
611
+ if (isCryptoKey(value) || isWebAssemblyModule(value)) return true;
612
+ seen.add(value);
613
+ for (const key of Reflect.ownKeys(value)) {
614
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
615
+ if (!descriptor?.enumerable) continue;
616
+ if (!("value" in descriptor) || containsUnsafeStructuredCloneState(descriptor.value, seen)) return true;
617
+ }
618
+ for (const key of ["cause", "errors"]) {
619
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
620
+ if (descriptor && (!("value" in descriptor) || containsUnsafeStructuredCloneState(descriptor.value, seen))) return true;
621
+ }
622
+ const mapEntries = reflectedMapEntries(value);
623
+ if (mapEntries) {
624
+ for (const [key, entry] of mapEntries) if (containsUnsafeStructuredCloneState(key, seen) || containsUnsafeStructuredCloneState(entry, seen)) return true;
625
+ } else {
626
+ const setValues = reflectedSetValues(value);
627
+ if (setValues) {
628
+ for (const entry of setValues) if (containsUnsafeStructuredCloneState(entry, seen)) return true;
629
+ }
630
+ }
631
+ return false;
632
+ }
633
+ function preservesEnumerableFields(source, snapshot, seen = /* @__PURE__ */ new Map()) {
634
+ if (!source || !hasRuntimeType(source, "object")) return true;
635
+ if (!snapshot || !hasRuntimeType(snapshot, "object")) return false;
636
+ if (seen.has(source)) return seen.get(source) === snapshot;
637
+ seen.set(source, snapshot);
638
+ if (ArrayBuffer.isView(source) && (!ArrayBuffer.isView(snapshot) || Object.getPrototypeOf(source) !== Object.getPrototypeOf(snapshot) || source.byteLength !== snapshot.byteLength)) return false;
639
+ if (source instanceof Date && (!(snapshot instanceof Date) || !Object.is(source.getTime(), snapshot.getTime()))) return false;
640
+ const sourceRegExp = reflectedRegExpState(source);
641
+ if (sourceRegExp) {
642
+ const snapshotRegExp = reflectedRegExpState(snapshot);
643
+ if (!snapshotRegExp || sourceRegExp.source !== snapshotRegExp.source || sourceRegExp.flags !== snapshotRegExp.flags || sourceRegExp.lastIndex !== snapshotRegExp.lastIndex) return false;
644
+ }
645
+ const sourceBlob = reflectedBlobState(source);
646
+ if (sourceBlob) {
647
+ const snapshotBlob = reflectedBlobState(snapshot);
648
+ if (!snapshotBlob || sourceBlob.size !== snapshotBlob.size || sourceBlob.type !== snapshotBlob.type || sourceBlob.name !== snapshotBlob.name || sourceBlob.lastModified !== snapshotBlob.lastModified) return false;
649
+ }
650
+ const sourceAggregateErrors = Object.getOwnPropertyDescriptor(source, "errors");
651
+ if (sourceAggregateErrors && "value" in sourceAggregateErrors) {
652
+ const snapshotAggregateErrors = Object.getOwnPropertyDescriptor(snapshot, "errors");
653
+ if (!snapshotAggregateErrors || !("value" in snapshotAggregateErrors) || !preservesEnumerableFields(sourceAggregateErrors.value, snapshotAggregateErrors.value, seen)) return false;
654
+ }
655
+ if (source instanceof AggregateError) {
656
+ if (!(snapshot instanceof AggregateError) || source.name !== snapshot.name || source.message !== snapshot.message || !preservesEnumerableFields(source.errors, snapshot.errors, seen) || !preservesEnumerableFields(source.cause, snapshot.cause, seen)) return false;
657
+ } else if (source instanceof DOMException) {
658
+ if (!(snapshot instanceof DOMException) || source.name !== snapshot.name || source.message !== snapshot.message || source.code !== snapshot.code) return false;
659
+ } else if (source instanceof Error) {
660
+ if (!(snapshot instanceof Error) || source.name !== snapshot.name || source.message !== snapshot.message || !preservesEnumerableFields(source.cause, snapshot.cause, seen)) return false;
661
+ }
662
+ for (const key of Reflect.ownKeys(source)) {
663
+ const sourceDescriptor = Object.getOwnPropertyDescriptor(source, key);
664
+ if (!sourceDescriptor?.enumerable) continue;
665
+ if (hasRuntimeType(key, "symbol")) {
666
+ if (sourceBlob?.intrinsicSymbols.has(key)) continue;
667
+ return false;
668
+ }
669
+ if (!("value" in sourceDescriptor)) return false;
670
+ const snapshotDescriptor = Object.getOwnPropertyDescriptor(snapshot, key);
671
+ if (!snapshotDescriptor || !("value" in snapshotDescriptor)) return false;
672
+ if (!preservesEnumerableFields(sourceDescriptor.value, snapshotDescriptor.value, seen)) return false;
673
+ }
674
+ const sourceMapEntries = reflectedMapEntries(source);
675
+ if (sourceMapEntries) {
676
+ const snapshotEntries = reflectedMapEntries(snapshot);
677
+ if (!snapshotEntries || sourceMapEntries.length !== snapshotEntries.length) return false;
678
+ return sourceMapEntries.every(([key, value], index) => {
679
+ const snapshotEntry = snapshotEntries[index];
680
+ return snapshotEntry !== void 0 && preservesEnumerableFields(key, snapshotEntry[0], seen) && preservesEnumerableFields(value, snapshotEntry[1], seen);
681
+ });
682
+ }
683
+ const sourceSetValues = reflectedSetValues(source);
684
+ if (sourceSetValues) {
685
+ const snapshotValues = reflectedSetValues(snapshot);
686
+ if (!snapshotValues || sourceSetValues.length !== snapshotValues.length) return false;
687
+ return sourceSetValues.every((value, index) => preservesEnumerableFields(value, snapshotValues[index], seen));
688
+ }
689
+ return true;
690
+ }
691
+ function normalizedTracePayload(payload) {
692
+ if (payload === void 0) return;
693
+ if (!payload || !hasRuntimeType(payload, "object")) return { visibility: "private" };
694
+ try {
695
+ if (Array.isArray(payload)) return { visibility: "private" };
696
+ const visibility = Object.getOwnPropertyDescriptor(payload, "visibility");
697
+ if (!visibility || !("value" in visibility)) return { visibility: "private" };
698
+ if (visibility.value === "public") {
699
+ const value = Object.getOwnPropertyDescriptor(payload, "value");
700
+ if (value && "value" in value && !containsUnsafeStructuredCloneState(value.value)) {
701
+ const snapshot = structuredClone(value.value);
702
+ if (preservesEnumerableFields(value.value, snapshot) && !containsSharedArrayBuffer(snapshot)) return {
703
+ value: snapshot,
704
+ visibility: "public"
705
+ };
706
+ }
707
+ }
708
+ if (visibility.value === "summary") {
709
+ const summary = Object.getOwnPropertyDescriptor(payload, "summary");
710
+ if (summary && "value" in summary && hasRuntimeType(summary.value, "string")) return {
711
+ summary: summary.value,
712
+ visibility: "summary"
713
+ };
714
+ }
715
+ if (visibility.value === "redacted") return { visibility: "redacted" };
716
+ } catch {
717
+ return { visibility: "private" };
718
+ }
719
+ return { visibility: "private" };
720
+ }
721
+ function traceEventAttributes(event, content, normalized = false) {
722
+ const activity = normalized ? event.activity : normalizedTraceActivity(event.activity);
723
+ const payload = normalized ? event.payload : normalizedTracePayload(event.payload);
724
+ let source = {};
725
+ const skippedMetadataContent = /* @__PURE__ */ new Set();
726
+ try {
727
+ for (const key of Reflect.ownKeys(event.attributes || {})) {
728
+ if (!hasRuntimeType(key, "string")) continue;
729
+ const descriptor = Object.getOwnPropertyDescriptor(event.attributes, key);
730
+ if (descriptor?.enumerable && "value" in descriptor) source[key] = descriptor.value;
731
+ else if (content === "metadata" && descriptor?.enumerable && isTraceContentAttributeKey(key)) skippedMetadataContent.add(key);
732
+ }
733
+ } catch {
734
+ source = {};
735
+ }
736
+ delete source["vitehub.activity.owner"];
737
+ delete source["vitehub.activity.phase"];
738
+ delete source["vitehub.payload.summary"];
739
+ delete source["vitehub.payload.value"];
740
+ delete source["vitehub.payload.visibility"];
741
+ try {
742
+ if (Array.isArray(source["content.omitted"])) {
743
+ const omitted = source["content.omitted"].filter((key) => hasRuntimeType(key, "string") && ![
744
+ "vitehub.activity.owner",
745
+ "vitehub.activity.phase",
746
+ "vitehub.payload.summary",
747
+ "vitehub.payload.value",
748
+ "vitehub.payload.visibility"
749
+ ].includes(key));
750
+ if (omitted.length) source["content.omitted"] = omitted;
751
+ else delete source["content.omitted"];
752
+ }
753
+ } catch {
754
+ delete source["content.omitted"];
755
+ }
756
+ if (skippedMetadataContent.size) {
757
+ const omitted = new Set(Array.isArray(source["content.omitted"]) ? source["content.omitted"] : []);
758
+ for (const key of skippedMetadataContent) omitted.add(key);
759
+ source["content.omitted"] = [...omitted];
760
+ }
761
+ const next = { ...content === "metadata" ? metadataAttributes(source) : source };
762
+ if (activity) {
763
+ next["vitehub.activity.owner"] = activity.owner;
764
+ next["vitehub.activity.phase"] = activity.phase;
765
+ }
766
+ if (payload) {
767
+ next["vitehub.payload.visibility"] = payload.visibility;
768
+ if (payload.visibility === "public") next["vitehub.payload.value"] = payload.value;
769
+ if (payload.visibility === "summary") next["vitehub.payload.summary"] = payload.summary;
770
+ }
771
+ return Object.keys(next).length ? next : void 0;
772
+ }
773
+ function aggregateTraceAttributes(attributes) {
774
+ if (!attributes) return void 0;
775
+ const next = { ...attributes };
776
+ delete next["vitehub.activity.owner"];
777
+ delete next["vitehub.activity.phase"];
778
+ delete next["vitehub.payload.summary"];
779
+ delete next["vitehub.payload.value"];
780
+ delete next["vitehub.payload.visibility"];
781
+ return Object.keys(next).length ? next : void 0;
782
+ }
783
+ function stepTraceAttributes(attributes) {
784
+ if (!attributes) return void 0;
785
+ const next = { ...attributes };
786
+ delete next["vitehub.activity.owner"];
787
+ delete next["vitehub.activity.phase"];
788
+ return Object.keys(next).length ? next : void 0;
789
+ }
346
790
  function normalizeTraceEvent(event, sequence, content) {
791
+ const { activity: rawActivity, attributes: _attributes, payload: rawPayload, ...rest } = event;
792
+ const activity = normalizedTraceActivity(rawActivity);
793
+ const payload = normalizedTracePayload(rawPayload);
794
+ const attributes = traceEventAttributes({
795
+ activity,
796
+ attributes: event.attributes,
797
+ payload
798
+ }, content, true);
347
799
  return {
348
- ...event,
349
- ...content === "metadata" ? { attributes: metadataAttributes(event.attributes) } : {},
800
+ ...rest,
801
+ ...activity ? { activity } : {},
802
+ ...attributes ? { attributes } : {},
803
+ ...payload ? { payload } : {},
350
804
  sequence,
351
805
  timestamp: timestamp(event.timestamp)
352
806
  };
@@ -360,15 +814,35 @@ async function emitTraceEvent(context, event) {
360
814
  function createTraceEventLog(options = {}) {
361
815
  const content = options.content || "metadata";
362
816
  const entries = [];
817
+ const cloneAttributes = (attributes) => {
818
+ if (!attributes) return void 0;
819
+ return { ...attributes };
820
+ };
821
+ const cloneEntry = (entry) => {
822
+ const publicValue = entry.attributes?.["vitehub.payload.value"];
823
+ const cloneable = structuredClone({
824
+ activity: entry.activity,
825
+ payload: entry.payload,
826
+ publicValue
827
+ });
828
+ const attributes = cloneAttributes(entry.attributes);
829
+ if (attributes && "vitehub.payload.value" in attributes) attributes["vitehub.payload.value"] = cloneable.publicValue;
830
+ return {
831
+ ...entry,
832
+ ...cloneable.activity ? { activity: cloneable.activity } : {},
833
+ ...attributes ? { attributes } : {},
834
+ ...cloneable.payload ? { payload: cloneable.payload } : {}
835
+ };
836
+ };
363
837
  return {
364
838
  async append(event) {
365
839
  const entry = normalizeTraceEvent(event, entries.length + 1, content);
366
840
  entries.push(entry);
367
- await options.onEntry?.(entry);
368
- return entry;
841
+ await options.onEntry?.(cloneEntry(entry));
842
+ return cloneEntry(entry);
369
843
  },
370
844
  entries() {
371
- return entries.slice();
845
+ return entries.map(cloneEntry);
372
846
  }
373
847
  };
374
848
  }
@@ -382,7 +856,7 @@ function durationMs(startTime, endTime) {
382
856
  return Number.isFinite(duration) && duration >= 0 ? duration : void 0;
383
857
  }
384
858
  function firstString(...values) {
385
- return values.find((value) => typeof value === "string" && value.length > 0);
859
+ return values.find((value) => hasRuntimeType(value, "string") && value.length > 0);
386
860
  }
387
861
  function runId(event) {
388
862
  return firstString(event.attributes?.["agent.run.id"], event.attributes?.["run.id"], event.attributes?.runId, event.trace?.id) || "default";
@@ -391,13 +865,19 @@ function stepId(event) {
391
865
  return firstString(event.attributes?.["step.id"], event.attributes?.["tool.id"], event.attributes?.["approval.id"], event.attributes?.["model.call.id"]);
392
866
  }
393
867
  function stepStatus(event) {
394
- return event.type === "error" || event.name.endsWith(".error") ? "failed" : event.name.endsWith(".start") || event.name.endsWith(".request") ? "running" : "completed";
868
+ return event.type === "error" || /\.(?:cancelled|error|failed)$/.test(event.name) ? "failed" : /\.(?:output|progress|request|start|started|summary|updated)$/.test(event.name) ? "running" : "completed";
395
869
  }
396
870
  function isTraceRunFinish(event) {
397
- return event.name === "agent.invocation.finish" || event.name === "run.finish";
871
+ return event.name === "agent.invocation.cancelled" || event.name === "agent.invocation.finish" || event.name === "run.finish";
398
872
  }
399
873
  function isTraceRunError(event) {
400
- return event.name === "agent.invocation.error" || event.name === "agent.stream.error" || event.name === "run.error";
874
+ return event.name === "agent.invocation.error" || event.name === "agent.stream.error" && event.attributes?.["error.recoverable"] !== true || event.name === "run.error";
875
+ }
876
+ function isTraceRunTerminal(event) {
877
+ return isTraceRunFinish(event) || isTraceRunError(event);
878
+ }
879
+ function isTraceRunFailureEvidence(event) {
880
+ return event.name === "run.error" || event.name === "agent.stream.error" && event.attributes?.["error.recoverable"] !== true;
401
881
  }
402
882
  function deriveTraceRuns(events) {
403
883
  const groups = /* @__PURE__ */ new Map();
@@ -416,11 +896,11 @@ function deriveTraceRuns(events) {
416
896
  const status = stepStatus(event);
417
897
  if (!existing) {
418
898
  steps.set(id, {
419
- attributes: event.attributes,
899
+ attributes: stepTraceAttributes(event.attributes),
420
900
  endTime: status === "running" ? void 0 : event.timestamp,
421
901
  events: [event],
422
902
  id,
423
- name: event.name.replace(/\.(start|finish|end|error|request|decision|recorded)$/, ""),
903
+ name: event.name.replace(/\.(start|started|progress|finish|completed|failed|cancelled|end|error|request|decision|recorded)$/, ""),
424
904
  startTime: event.timestamp,
425
905
  status,
426
906
  type: event.type
@@ -428,18 +908,24 @@ function deriveTraceRuns(events) {
428
908
  continue;
429
909
  }
430
910
  existing.events.push(event);
431
- existing.attributes = {
432
- ...existing.attributes,
911
+ const attributes = { ...existing.attributes };
912
+ if (event.attributes?.["vitehub.payload.visibility"] !== void 0) {
913
+ delete attributes["vitehub.payload.summary"];
914
+ delete attributes["vitehub.payload.value"];
915
+ delete attributes["vitehub.payload.visibility"];
916
+ }
917
+ existing.attributes = stepTraceAttributes({
918
+ ...attributes,
433
919
  ...event.attributes
434
- };
920
+ });
435
921
  if (status !== "running") {
436
922
  existing.endTime = event.timestamp;
437
923
  existing.status = status;
438
924
  existing.durationMs = durationMs(existing.startTime, existing.endTime);
439
925
  }
440
926
  }
441
- const terminal = sorted.slice().reverse().find((event) => isTraceRunError(event) || isTraceRunFinish(event));
442
- const status = sorted.some(isTraceRunError) ? "failed" : terminal ? "completed" : "running";
927
+ const terminal = sorted.slice().reverse().find(isTraceRunTerminal);
928
+ const status = sorted.some(isTraceRunFailureEvidence) || terminal && isTraceRunError(terminal) ? "failed" : terminal?.name === "agent.invocation.cancelled" ? "cancelled" : terminal ? "completed" : "running";
443
929
  const endTime = status === "running" ? void 0 : terminal?.timestamp;
444
930
  return {
445
931
  durationMs: durationMs(first.timestamp, endTime),
@@ -458,6 +944,9 @@ function traceRunTraceId(run) {
458
944
  function traceRunParentId(run) {
459
945
  return firstString(...run.events.map((event) => event.trace?.parentId));
460
946
  }
947
+ function traceRunSpanId(run) {
948
+ return firstString(...run.events.map((event) => event.attributes?.["agent.invocation.id"]), run.id) || run.id;
949
+ }
461
950
  function isOpenTelemetryId(value, length) {
462
951
  return value.length === length && /^[0-9a-f]+$/.test(value);
463
952
  }
@@ -477,56 +966,139 @@ function openTelemetryId(value, length) {
477
966
  const id = output.slice(0, length);
478
967
  return /^0+$/.test(id) ? `1${id.slice(1)}` : id;
479
968
  }
480
- function traceEventsToOpenTelemetrySpans(events) {
481
- return deriveTraceRuns(events).flatMap((run) => {
969
+ function traceEventsToOpenTelemetryLogRecords(events, options = {}) {
970
+ return deriveTraceRuns([...events]).flatMap((run) => {
971
+ const spanId = openTelemetryId(traceRunSpanId(run), 16);
972
+ const traceId = openTelemetryId(traceRunTraceId(run), 32);
973
+ return run.events.map((event) => {
974
+ const id = stepId(event);
975
+ const attributes = traceEventAttributes(event, options.content === "metadata" ? "metadata" : "content");
976
+ const error = event.type === "error" || /\.(?:cancelled|error|failed)$/.test(event.name);
977
+ return {
978
+ attributes: {
979
+ ...attributes,
980
+ "vitehub.event.sequence": event.sequence,
981
+ "vitehub.event.type": event.type,
982
+ "vitehub.run.id": run.id,
983
+ ...id ? { "vitehub.step.id": id } : {}
984
+ },
985
+ eventName: event.name,
986
+ ...error ? {
987
+ severityNumber: 17,
988
+ severityText: "ERROR"
989
+ } : {},
990
+ spanId: id ? openTelemetryId(`${spanId}:${id}`, 16) : spanId,
991
+ time: event.timestamp,
992
+ traceId
993
+ };
994
+ });
995
+ });
996
+ }
997
+ function traceEventsToOpenTelemetrySpans(events, options = {}) {
998
+ const maxEntries = 1024;
999
+ const firstEntries = maxEntries / 2;
1000
+ const tailEntries = maxEntries / 2;
1001
+ const entriesByRun = /* @__PURE__ */ new Map();
1002
+ for (const entry of events) {
1003
+ const id = runId(entry);
1004
+ let run = entriesByRun.get(id);
1005
+ if (!run) {
1006
+ run = {
1007
+ count: 0,
1008
+ first: [],
1009
+ tail: Array.from({ length: tailEntries })
1010
+ };
1011
+ entriesByRun.set(id, run);
1012
+ }
1013
+ const indexed = {
1014
+ entry,
1015
+ index: run.count
1016
+ };
1017
+ if (run.count < firstEntries) run.first.push(indexed);
1018
+ else run.tail[(run.count - firstEntries) % tailEntries] = indexed;
1019
+ if (isTraceRunFailureEvidence(entry)) run.failure = indexed;
1020
+ if (isTraceRunTerminal(entry)) run.terminal = indexed;
1021
+ run.count += 1;
1022
+ }
1023
+ return deriveTraceRuns([...entriesByRun.values()].flatMap((run) => {
1024
+ const tail = run.tail.filter((entry) => entry !== void 0).sort((left, right) => left.index - right.index);
1025
+ const evidence = [run.failure, run.terminal].filter((entry) => entry !== void 0);
1026
+ const indexed = run.count <= maxEntries ? [...run.first, ...tail] : [
1027
+ ...run.first,
1028
+ ...tail.slice(evidence.length),
1029
+ ...evidence
1030
+ ];
1031
+ const entries = [...new Map(indexed.map((value) => [value.index, value])).values()].sort((left, right) => left.index - right.index).map((value) => value.entry);
1032
+ if (run.count <= maxEntries) return entries;
1033
+ return entries.map((entry, index) => index === 0 ? {
1034
+ ...entry,
1035
+ attributes: {
1036
+ ...entry.attributes,
1037
+ "vitehub.trace.originalEventCount": run.count,
1038
+ "vitehub.trace.truncated": true
1039
+ }
1040
+ } : entry);
1041
+ }).map((entry) => ({
1042
+ ...entry,
1043
+ attributes: traceEventAttributes(entry, options.content === "metadata" ? "metadata" : "content")
1044
+ }))).flatMap((run) => {
482
1045
  const rawParentSpanId = traceRunParentId(run);
483
1046
  const rawTraceId = traceRunTraceId(run);
484
1047
  const parentSpanId = rawParentSpanId ? openTelemetryId(rawParentSpanId, 16) : void 0;
485
- const spanId = openTelemetryId(run.id, 16);
1048
+ const spanId = openTelemetryId(traceRunSpanId(run), 16);
486
1049
  const traceId = openTelemetryId(rawTraceId, 32);
1050
+ const attributes = aggregateTraceAttributes(Object.assign({}, ...run.events.filter((event) => !stepId(event)).map((event) => event.attributes || {})));
1051
+ const spanEvents = (events) => events.map((event) => ({
1052
+ ...event.attributes ? { attributes: event.attributes } : {},
1053
+ name: event.name,
1054
+ time: event.timestamp
1055
+ }));
1056
+ const errorMessage = firstString(...run.events.slice().reverse().map((event) => event.attributes?.["error.message"]));
487
1057
  return [{
488
1058
  attributes: {
1059
+ ...attributes,
489
1060
  "vitehub.run.id": run.id,
490
1061
  ...rawParentSpanId ? { "vitehub.trace.parentId": rawParentSpanId } : {},
491
1062
  "vitehub.trace.id": rawTraceId
492
1063
  },
493
1064
  endTime: run.endTime,
1065
+ events: spanEvents(run.events.filter((event) => !stepId(event))),
494
1066
  name: "vitehub.run",
495
1067
  ...parentSpanId ? { parentSpanId } : {},
496
1068
  spanId,
497
1069
  startTime: run.startTime,
498
- status: { code: run.status === "failed" ? "ERROR" : "OK" },
1070
+ status: {
1071
+ code: run.status === "failed" ? "ERROR" : run.status === "completed" ? "OK" : "UNSET",
1072
+ ...run.status === "failed" && errorMessage ? { message: errorMessage } : {}
1073
+ },
499
1074
  traceId
500
1075
  }, ...run.steps.map((step) => ({
501
1076
  attributes: {
502
- ...step.attributes,
1077
+ ...aggregateTraceAttributes(step.attributes),
503
1078
  "vitehub.run.id": run.id,
504
1079
  "vitehub.step.id": step.id
505
1080
  },
506
- endTime: step.endTime,
1081
+ endTime: step.endTime || run.endTime,
1082
+ events: spanEvents(step.events),
507
1083
  name: step.name,
508
1084
  parentSpanId: spanId,
509
- spanId: openTelemetryId(`${run.id}:${step.id}`, 16),
1085
+ spanId: openTelemetryId(`${spanId}:${step.id}`, 16),
510
1086
  startTime: step.startTime,
511
- status: { code: step.status === "failed" ? "ERROR" : "OK" },
1087
+ status: {
1088
+ code: step.status === "failed" || !step.endTime && run.status === "failed" ? "ERROR" : step.endTime || run.status === "completed" ? "OK" : "UNSET",
1089
+ ...hasRuntimeType(step.attributes?.["error.message"], "string") ? { message: step.attributes["error.message"] } : {}
1090
+ },
512
1091
  traceId
513
1092
  }))];
514
1093
  });
515
1094
  }
516
1095
  function createExecutionContext(context) {
517
- return resolveExecutionContext(context);
518
- }
519
- function resolveExecutionContext(context) {
520
- return {
521
- ...context,
522
- capabilities: context.capabilities || {},
523
- runtimeConfig: context.runtimeConfig || {}
524
- };
525
- }
526
- function resolveRuntimeContext(context) {
1096
+ const capabilities = context.capabilities ?? {};
1097
+ const runtimeConfig = context.runtimeConfig ?? {};
527
1098
  return {
528
1099
  ...context,
529
- runtimeConfig: context.runtimeConfig || {}
1100
+ capabilities,
1101
+ runtimeConfig
530
1102
  };
531
1103
  }
532
1104
  function defineCapability(kind, value, options = {}) {
@@ -540,7 +1112,18 @@ function createRuntimeWaitUntilController(options = {}) {
540
1112
  const pending = [];
541
1113
  return {
542
1114
  async flushWaitUntil() {
543
- while (pending.length > 0) await Promise.all(pending.splice(0));
1115
+ let error;
1116
+ let failed = false;
1117
+ while (pending.length > 0) await Promise.all(pending.splice(0).map(async (task) => {
1118
+ try {
1119
+ await task;
1120
+ } catch (reason) {
1121
+ if (failed) return;
1122
+ error = reason;
1123
+ failed = true;
1124
+ }
1125
+ }));
1126
+ if (failed) throw error;
544
1127
  },
545
1128
  waitUntil(task) {
546
1129
  pending.push(task);
@@ -549,7 +1132,7 @@ function createRuntimeWaitUntilController(options = {}) {
549
1132
  };
550
1133
  }
551
1134
  function isCapabilityHandle(value) {
552
- return typeof value === "object" && value !== null && "kind" in value && typeof value.kind === "string" && "value" in value;
1135
+ return hasRuntimeType(value, "object") && value !== null && "kind" in value && hasRuntimeType(value.kind, "string") && "value" in value;
553
1136
  }
554
1137
  function hasCapability(context, name) {
555
1138
  return !!context.capabilities && name in context.capabilities;
@@ -561,16 +1144,16 @@ function getCapability(context, name) {
561
1144
  return defineCapability(name, value, { name });
562
1145
  }
563
1146
  function isResolvable(value) {
564
- return typeof value === "object" && value !== null && "resolve" in value && typeof value.resolve === "function";
1147
+ return hasRuntimeType(value, "object") && value !== null && "resolve" in value && hasRuntimeType(value.resolve, "function");
565
1148
  }
566
1149
  async function resolveRuntimeValue(value, context) {
567
1150
  if (isResolvable(value)) return await value.resolve(context);
568
- if (typeof value === "function") return await value(context);
1151
+ if (hasRuntimeType(value, "function")) return await value(context);
569
1152
  return value;
570
1153
  }
571
1154
  async function resolveCapabilityPolicy(policy, context) {
572
1155
  if (!policy) return "allow";
573
- return typeof policy === "function" ? await policy(context) : policy;
1156
+ return hasRuntimeType(policy, "function") ? await policy(context) : policy;
574
1157
  }
575
1158
  //#endregion
576
- export { ViteHubError, createExecutionContext, createRuntimeWaitUntilController, createTraceEventLog, defineCapability, deriveTraceRuns, emitTraceEvent, getCapability, getViteHubErrorShape, hasCapability, isExecutionAuthority, isResolvable, isViteHubError, noExecutionAuthority, normalizeExecutionAuthority, resolveCapabilityPolicy, resolveExecutionContext, resolveRuntimeContext, resolveRuntimeValue, traceEventsToOpenTelemetrySpans, unknownExecutionAuthority };
1159
+ export { ViteHubError, createExecutionContext, createRuntimeWaitUntilController, createTraceEventLog, defineCapability, deriveTraceRuns, emitTraceEvent, getCapability, getViteHubErrorShape, hasCapability, isExecutionAuthority, isResolvable, isTraceContentAttributeKey, isViteHubError, noExecutionAuthority, normalizeExecutionAuthority, normalizeRuntimeDiagnosticError, resolveCapabilityPolicy, resolveRuntimeValue, traceEventsToOpenTelemetryLogRecords, traceEventsToOpenTelemetrySpans, unknownExecutionAuthority };