@vite-hub/runtime 0.0.4 → 0.3.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/README.md +278 -41
- package/dist/durability.d.ts +107 -0
- package/dist/durability.js +168 -0
- package/dist/error-diagnostics-BKICpwZp.js +85 -0
- package/dist/error-diagnostics-BsJr9VdW.d.ts +15 -0
- package/dist/errors-BEomN3fX.js +190 -0
- package/dist/execution-budget-BPXbISEt.d.ts +56 -0
- package/dist/index-Bcl-Hr-a.d.ts +678 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -1159
- package/dist/internal/drain.d.ts +17 -0
- package/dist/internal/drain.js +75 -0
- package/dist/internal/execution-budget.d.ts +10 -0
- package/dist/internal/execution-budget.js +17 -0
- package/dist/internal/grant.d.ts +36 -0
- package/dist/internal/grant.js +44 -0
- package/dist/internal/h3.d.ts +42 -0
- package/dist/internal/h3.js +181 -0
- package/dist/internal/node.d.ts +33 -0
- package/dist/{node.js → internal/node.js} +12 -9
- package/dist/internal/public-url.d.ts +2 -0
- package/dist/internal/public-url.js +2 -0
- package/dist/internal/run-scope.d.ts +11 -0
- package/dist/internal/run-scope.js +30 -0
- package/dist/internal/runtime-type.d.ts +26 -0
- package/dist/internal/runtime-type.js +3 -0
- package/dist/internal/shutdown.d.ts +84 -0
- package/dist/internal/shutdown.js +202 -0
- package/dist/internal/test-mode-setup.d.ts +7 -0
- package/dist/internal/test-mode-setup.js +114 -0
- package/dist/internal/test-mode.d.ts +32 -0
- package/dist/internal/test-mode.js +9 -0
- package/dist/operations.d.ts +167 -0
- package/dist/operations.js +406 -0
- package/dist/public-url-1WeOw54Z.d.ts +34 -0
- package/dist/public-url-B6x0HMgY.js +140 -0
- package/dist/request-context-CP9NhgLL.js +2274 -0
- package/dist/runtime-type-BftydMAf.js +88 -0
- package/package.json +92 -17
- package/dist/drain.d.ts +0 -1
- package/dist/drain.js +0 -52
- package/dist/index-tBKyUP1T.d.ts +0 -314
- package/dist/node.d.ts +0 -35
- package/dist/runtime-type-ovvOd6m5.js +0 -37
package/dist/index.js
CHANGED
|
@@ -1,1159 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const MAX_DETAIL_NODES = 1024;
|
|
7
|
-
const MAX_DETAIL_STRING_LENGTH = 16384;
|
|
8
|
-
const MAX_ERROR_CODE_LENGTH = 128;
|
|
9
|
-
const MAX_ERROR_MESSAGE_LENGTH = 16384;
|
|
10
|
-
const MAX_REQUEST_ID_LENGTH = 256;
|
|
11
|
-
const publicShapes = /* @__PURE__ */ new WeakMap();
|
|
12
|
-
function invalidPublicError() {
|
|
13
|
-
throw new TypeError("[vitehub] ViteHubError requires a valid public error contract.");
|
|
14
|
-
}
|
|
15
|
-
function isArray(value) {
|
|
16
|
-
try {
|
|
17
|
-
return Array.isArray(value);
|
|
18
|
-
} catch {
|
|
19
|
-
invalidPublicError();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function readOwnDataProperty(value, key, requireEnumerable = false) {
|
|
23
|
-
try {
|
|
24
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
25
|
-
if (descriptor === void 0) return void 0;
|
|
26
|
-
if (!("value" in descriptor) || requireEnumerable && !descriptor.enumerable) invalidPublicError();
|
|
27
|
-
return descriptor.value;
|
|
28
|
-
} catch {
|
|
29
|
-
invalidPublicError();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function clonePublicDetail(value, state, depth, allowUndefined) {
|
|
33
|
-
state.nodes += 1;
|
|
34
|
-
if (state.nodes > MAX_DETAIL_NODES) invalidPublicError();
|
|
35
|
-
if (value === void 0 && allowUndefined) return void 0;
|
|
36
|
-
if (value === null || typeof value === "boolean") return value;
|
|
37
|
-
if (typeof value === "string" && value.length <= MAX_DETAIL_STRING_LENGTH) return value;
|
|
38
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
39
|
-
if (typeof value !== "object" || depth > MAX_DETAIL_DEPTH || state.ancestors.has(value)) invalidPublicError();
|
|
40
|
-
let prototype;
|
|
41
|
-
let keys;
|
|
42
|
-
try {
|
|
43
|
-
prototype = Object.getPrototypeOf(value);
|
|
44
|
-
keys = Reflect.ownKeys(value);
|
|
45
|
-
} catch {
|
|
46
|
-
invalidPublicError();
|
|
47
|
-
}
|
|
48
|
-
state.ancestors.add(value);
|
|
49
|
-
try {
|
|
50
|
-
if (isArray(value)) {
|
|
51
|
-
const length = readOwnDataProperty(value, "length");
|
|
52
|
-
if (!Number.isSafeInteger(length) || length < 0 || length > MAX_DETAIL_ENTRIES || keys.length !== length + 1 || !keys.includes("length")) invalidPublicError();
|
|
53
|
-
const result = [];
|
|
54
|
-
for (let index = 0; index < length; index += 1) {
|
|
55
|
-
const key = String(index);
|
|
56
|
-
if (!keys.includes(key)) invalidPublicError();
|
|
57
|
-
result.push(clonePublicDetail(readOwnDataProperty(value, key, true), state, depth + 1, false));
|
|
58
|
-
}
|
|
59
|
-
return Object.freeze(result);
|
|
60
|
-
}
|
|
61
|
-
if (prototype !== Object.prototype && prototype !== null) invalidPublicError();
|
|
62
|
-
if (keys.length > MAX_DETAIL_ENTRIES || keys.some((key) => typeof key !== "string")) invalidPublicError();
|
|
63
|
-
const result = {};
|
|
64
|
-
for (const key of keys) {
|
|
65
|
-
if (key.length === 0 || key.length > MAX_DETAIL_KEY_LENGTH) invalidPublicError();
|
|
66
|
-
Object.defineProperty(result, key, {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
value: clonePublicDetail(readOwnDataProperty(value, key, true), state, depth + 1, true),
|
|
69
|
-
writable: true
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return Object.freeze(result);
|
|
73
|
-
} finally {
|
|
74
|
-
state.ancestors.delete(value);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function clonePublicDetails(value) {
|
|
78
|
-
if (value === void 0) return void 0;
|
|
79
|
-
if (typeof value !== "object" || value === null || isArray(value)) invalidPublicError();
|
|
80
|
-
return clonePublicDetail(value, {
|
|
81
|
-
ancestors: /* @__PURE__ */ new Set(),
|
|
82
|
-
nodes: 0
|
|
83
|
-
}, 0, false);
|
|
84
|
-
}
|
|
85
|
-
function normalizePublicError(code, message, options) {
|
|
86
|
-
if (typeof code !== "string" || code.length === 0 || code.length > MAX_ERROR_CODE_LENGTH) invalidPublicError();
|
|
87
|
-
if (typeof message !== "string" || message.length === 0 || message.length > MAX_ERROR_MESSAGE_LENGTH) invalidPublicError();
|
|
88
|
-
if (typeof options !== "object" || options === null || isArray(options)) invalidPublicError();
|
|
89
|
-
const cause = readOwnDataProperty(options, "cause");
|
|
90
|
-
const details = clonePublicDetails(readOwnDataProperty(options, "details"));
|
|
91
|
-
const requestId = readOwnDataProperty(options, "requestId");
|
|
92
|
-
if (requestId !== void 0 && (typeof requestId !== "string" || requestId.length === 0 || requestId.length > MAX_REQUEST_ID_LENGTH)) invalidPublicError();
|
|
93
|
-
return {
|
|
94
|
-
cause,
|
|
95
|
-
code,
|
|
96
|
-
details,
|
|
97
|
-
message,
|
|
98
|
-
name: "ViteHubError",
|
|
99
|
-
requestId,
|
|
100
|
-
shape: Object.freeze({
|
|
101
|
-
code,
|
|
102
|
-
...details === void 0 ? {} : { details },
|
|
103
|
-
message,
|
|
104
|
-
name: "ViteHubError",
|
|
105
|
-
...requestId === void 0 ? {} : { requestId }
|
|
106
|
-
})
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
var ViteHubError = class extends Error {
|
|
110
|
-
code;
|
|
111
|
-
details;
|
|
112
|
-
requestId;
|
|
113
|
-
constructor(code, message, options = {}) {
|
|
114
|
-
const normalized = normalizePublicError(code, message, options);
|
|
115
|
-
super(normalized.message, normalized.cause === void 0 ? void 0 : { cause: normalized.cause });
|
|
116
|
-
this.name = "ViteHubError";
|
|
117
|
-
this.code = normalized.code;
|
|
118
|
-
this.details = normalized.details;
|
|
119
|
-
this.requestId = normalized.requestId;
|
|
120
|
-
const toJSON = this.toJSON.bind(this);
|
|
121
|
-
Object.defineProperties(this, {
|
|
122
|
-
code: {
|
|
123
|
-
configurable: true,
|
|
124
|
-
enumerable: true,
|
|
125
|
-
value: normalized.code,
|
|
126
|
-
writable: false
|
|
127
|
-
},
|
|
128
|
-
details: {
|
|
129
|
-
configurable: true,
|
|
130
|
-
enumerable: true,
|
|
131
|
-
value: normalized.details,
|
|
132
|
-
writable: false
|
|
133
|
-
},
|
|
134
|
-
message: {
|
|
135
|
-
configurable: true,
|
|
136
|
-
enumerable: false,
|
|
137
|
-
value: normalized.message,
|
|
138
|
-
writable: false
|
|
139
|
-
},
|
|
140
|
-
name: {
|
|
141
|
-
configurable: false,
|
|
142
|
-
enumerable: false,
|
|
143
|
-
value: normalized.name,
|
|
144
|
-
writable: false
|
|
145
|
-
},
|
|
146
|
-
requestId: {
|
|
147
|
-
configurable: true,
|
|
148
|
-
enumerable: true,
|
|
149
|
-
value: normalized.requestId,
|
|
150
|
-
writable: false
|
|
151
|
-
},
|
|
152
|
-
toJSON: {
|
|
153
|
-
configurable: false,
|
|
154
|
-
enumerable: false,
|
|
155
|
-
value: toJSON,
|
|
156
|
-
writable: false
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
publicShapes.set(this, normalized.shape);
|
|
160
|
-
}
|
|
161
|
-
toJSON() {
|
|
162
|
-
const existing = publicShapes.get(this);
|
|
163
|
-
if (existing) return existing;
|
|
164
|
-
const normalized = normalizePublicError(readOwnDataProperty(this, "code"), readOwnDataProperty(this, "message"), {
|
|
165
|
-
details: readOwnDataProperty(this, "details"),
|
|
166
|
-
requestId: readOwnDataProperty(this, "requestId")
|
|
167
|
-
});
|
|
168
|
-
publicShapes.set(this, normalized.shape);
|
|
169
|
-
return normalized.shape;
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
function getViteHubErrorShape(value) {
|
|
173
|
-
if (typeof value !== "object" || value === null) return;
|
|
174
|
-
try {
|
|
175
|
-
const existing = publicShapes.get(value);
|
|
176
|
-
if (existing) return existing;
|
|
177
|
-
if (readOwnDataProperty(value, "name") !== "ViteHubError") return;
|
|
178
|
-
return normalizePublicError(readOwnDataProperty(value, "code"), readOwnDataProperty(value, "message"), {
|
|
179
|
-
details: readOwnDataProperty(value, "details"),
|
|
180
|
-
requestId: readOwnDataProperty(value, "requestId")
|
|
181
|
-
}).shape;
|
|
182
|
-
} catch {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
function isViteHubError(value) {
|
|
187
|
-
return getViteHubErrorShape(value) !== void 0;
|
|
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
|
|
323
|
-
//#region src/index.ts
|
|
324
|
-
const noExecutionAuthority = Object.freeze({
|
|
325
|
-
credentials: "none",
|
|
326
|
-
environment: "none",
|
|
327
|
-
filesystem: Object.freeze({
|
|
328
|
-
access: "none",
|
|
329
|
-
scope: "none"
|
|
330
|
-
}),
|
|
331
|
-
isolation: "none",
|
|
332
|
-
network: "none",
|
|
333
|
-
processes: "none"
|
|
334
|
-
});
|
|
335
|
-
const unknownExecutionAuthority = Object.freeze({
|
|
336
|
-
credentials: "unknown",
|
|
337
|
-
environment: "unknown",
|
|
338
|
-
filesystem: Object.freeze({
|
|
339
|
-
access: "unknown",
|
|
340
|
-
scope: "unknown"
|
|
341
|
-
}),
|
|
342
|
-
isolation: "unknown",
|
|
343
|
-
network: "unknown",
|
|
344
|
-
processes: "unknown"
|
|
345
|
-
});
|
|
346
|
-
function isExecutionAuthority(value) {
|
|
347
|
-
if (!value || !hasRuntimeType(value, "object") || Array.isArray(value)) return false;
|
|
348
|
-
const authority = value;
|
|
349
|
-
const filesystem = authority.filesystem;
|
|
350
|
-
if (!filesystem || !hasRuntimeType(filesystem, "object") || Array.isArray(filesystem)) return false;
|
|
351
|
-
const files = filesystem;
|
|
352
|
-
return hasRuntimeType(authority.credentials, "string") && [
|
|
353
|
-
"ambient",
|
|
354
|
-
"none",
|
|
355
|
-
"provisioned",
|
|
356
|
-
"unknown"
|
|
357
|
-
].includes(authority.credentials) && hasRuntimeType(authority.environment, "string") && [
|
|
358
|
-
"ambient",
|
|
359
|
-
"none",
|
|
360
|
-
"selected",
|
|
361
|
-
"unknown"
|
|
362
|
-
].includes(authority.environment) && hasRuntimeType(files.access, "string") && [
|
|
363
|
-
"none",
|
|
364
|
-
"read-only",
|
|
365
|
-
"read-write",
|
|
366
|
-
"unknown"
|
|
367
|
-
].includes(files.access) && hasRuntimeType(files.scope, "string") && [
|
|
368
|
-
"host",
|
|
369
|
-
"none",
|
|
370
|
-
"sandbox",
|
|
371
|
-
"unknown",
|
|
372
|
-
"workspace"
|
|
373
|
-
].includes(files.scope) && hasRuntimeType(authority.isolation, "string") && [
|
|
374
|
-
"container",
|
|
375
|
-
"microvm",
|
|
376
|
-
"none",
|
|
377
|
-
"process",
|
|
378
|
-
"unknown"
|
|
379
|
-
].includes(authority.isolation) && hasRuntimeType(authority.network, "string") && [
|
|
380
|
-
"none",
|
|
381
|
-
"restricted",
|
|
382
|
-
"unrestricted",
|
|
383
|
-
"unknown"
|
|
384
|
-
].includes(authority.network) && hasRuntimeType(authority.processes, "string") && [
|
|
385
|
-
"arbitrary",
|
|
386
|
-
"none",
|
|
387
|
-
"restricted",
|
|
388
|
-
"unknown"
|
|
389
|
-
].includes(authority.processes);
|
|
390
|
-
}
|
|
391
|
-
function normalizeExecutionAuthority(value) {
|
|
392
|
-
if (!isExecutionAuthority(value)) throw new TypeError("[vitehub] Invalid execution authority descriptor.");
|
|
393
|
-
if (hasCanonicalFrozenProperties(value, [
|
|
394
|
-
"credentials",
|
|
395
|
-
"environment",
|
|
396
|
-
"filesystem",
|
|
397
|
-
"isolation",
|
|
398
|
-
"network",
|
|
399
|
-
"processes"
|
|
400
|
-
]) && hasCanonicalFrozenProperties(value.filesystem, ["access", "scope"])) return value;
|
|
401
|
-
return Object.freeze({
|
|
402
|
-
credentials: value.credentials,
|
|
403
|
-
environment: value.environment,
|
|
404
|
-
filesystem: Object.freeze({
|
|
405
|
-
access: value.filesystem.access,
|
|
406
|
-
scope: value.filesystem.scope
|
|
407
|
-
}),
|
|
408
|
-
isolation: value.isolation,
|
|
409
|
-
network: value.network,
|
|
410
|
-
processes: value.processes
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
function hasCanonicalFrozenProperties(value, keys) {
|
|
414
|
-
if (!isRuntimeObject(value)) return false;
|
|
415
|
-
const prototype = Object.getPrototypeOf(value);
|
|
416
|
-
if (!Object.isFrozen(value) || prototype !== Object.prototype && prototype !== null) return false;
|
|
417
|
-
const ownKeys = Reflect.ownKeys(value);
|
|
418
|
-
if (ownKeys.length !== keys.length || ownKeys.some((key) => !hasRuntimeType(key, "string") || !keys.includes(key))) return false;
|
|
419
|
-
return keys.every((key) => {
|
|
420
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
421
|
-
return descriptor !== void 0 && "value" in descriptor && descriptor.enumerable;
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
const contentAttributeKeys = new Set([
|
|
425
|
-
"args",
|
|
426
|
-
"body",
|
|
427
|
-
"content",
|
|
428
|
-
"data",
|
|
429
|
-
"input",
|
|
430
|
-
"message",
|
|
431
|
-
"messages",
|
|
432
|
-
"output",
|
|
433
|
-
"payload",
|
|
434
|
-
"progress",
|
|
435
|
-
"prompt",
|
|
436
|
-
"raw",
|
|
437
|
-
"request",
|
|
438
|
-
"response",
|
|
439
|
-
"result",
|
|
440
|
-
"text",
|
|
441
|
-
"title"
|
|
442
|
-
]);
|
|
443
|
-
function isTraceContentAttributeKey(key) {
|
|
444
|
-
if (key === "error.message") return false;
|
|
445
|
-
if (contentAttributeKeys.has(key)) return true;
|
|
446
|
-
return key.split(".").some((part, index) => index > 0 && contentAttributeKeys.has(part));
|
|
447
|
-
}
|
|
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
|
-
}
|
|
457
|
-
const omitted = [];
|
|
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)) {
|
|
467
|
-
omitted.push(key);
|
|
468
|
-
return [];
|
|
469
|
-
}
|
|
470
|
-
return [[key, metadataValue(child, seen)]];
|
|
471
|
-
}));
|
|
472
|
-
seen.delete(value);
|
|
473
|
-
if (omitted.length) next["content.omitted"] = omitted;
|
|
474
|
-
return next;
|
|
475
|
-
}
|
|
476
|
-
function timestamp(value) {
|
|
477
|
-
if (value instanceof Date) return value.toISOString();
|
|
478
|
-
if (hasRuntimeType(value, "string")) return value;
|
|
479
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
480
|
-
}
|
|
481
|
-
function metadataAttributes(attributes) {
|
|
482
|
-
if (!attributes) return void 0;
|
|
483
|
-
const omitted = [];
|
|
484
|
-
const next = Object.fromEntries(Object.entries(attributes).flatMap(([key, value]) => {
|
|
485
|
-
if (isTraceContentAttributeKey(key)) {
|
|
486
|
-
omitted.push(key);
|
|
487
|
-
return [];
|
|
488
|
-
}
|
|
489
|
-
return [[key, metadataValue(value)]];
|
|
490
|
-
}));
|
|
491
|
-
if (omitted.length) next["content.omitted"] = omitted;
|
|
492
|
-
return Object.keys(next).length ? next : void 0;
|
|
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
|
-
}
|
|
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);
|
|
799
|
-
return {
|
|
800
|
-
...rest,
|
|
801
|
-
...activity ? { activity } : {},
|
|
802
|
-
...attributes ? { attributes } : {},
|
|
803
|
-
...payload ? { payload } : {},
|
|
804
|
-
sequence,
|
|
805
|
-
timestamp: timestamp(event.timestamp)
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
async function emitTraceEvent(context, event) {
|
|
809
|
-
return await context.traceLog?.append({
|
|
810
|
-
...event,
|
|
811
|
-
trace: event.trace || context.trace
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
function createTraceEventLog(options = {}) {
|
|
815
|
-
const content = options.content || "metadata";
|
|
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
|
-
};
|
|
837
|
-
return {
|
|
838
|
-
async append(event) {
|
|
839
|
-
const entry = normalizeTraceEvent(event, entries.length + 1, content);
|
|
840
|
-
entries.push(entry);
|
|
841
|
-
await options.onEntry?.(cloneEntry(entry));
|
|
842
|
-
return cloneEntry(entry);
|
|
843
|
-
},
|
|
844
|
-
entries() {
|
|
845
|
-
return entries.map(cloneEntry);
|
|
846
|
-
}
|
|
847
|
-
};
|
|
848
|
-
}
|
|
849
|
-
function millis(value) {
|
|
850
|
-
const parsed = Date.parse(value);
|
|
851
|
-
return Number.isFinite(parsed) ? parsed : 0;
|
|
852
|
-
}
|
|
853
|
-
function durationMs(startTime, endTime) {
|
|
854
|
-
if (!endTime) return void 0;
|
|
855
|
-
const duration = millis(endTime) - millis(startTime);
|
|
856
|
-
return Number.isFinite(duration) && duration >= 0 ? duration : void 0;
|
|
857
|
-
}
|
|
858
|
-
function firstString(...values) {
|
|
859
|
-
return values.find((value) => hasRuntimeType(value, "string") && value.length > 0);
|
|
860
|
-
}
|
|
861
|
-
function runId(event) {
|
|
862
|
-
return firstString(event.attributes?.["agent.run.id"], event.attributes?.["run.id"], event.attributes?.runId, event.trace?.id) || "default";
|
|
863
|
-
}
|
|
864
|
-
function stepId(event) {
|
|
865
|
-
return firstString(event.attributes?.["step.id"], event.attributes?.["tool.id"], event.attributes?.["approval.id"], event.attributes?.["model.call.id"]);
|
|
866
|
-
}
|
|
867
|
-
function stepStatus(event) {
|
|
868
|
-
return event.type === "error" || /\.(?:cancelled|error|failed)$/.test(event.name) ? "failed" : /\.(?:output|progress|request|start|started|summary|updated)$/.test(event.name) ? "running" : "completed";
|
|
869
|
-
}
|
|
870
|
-
function isTraceRunFinish(event) {
|
|
871
|
-
return event.name === "agent.invocation.cancelled" || event.name === "agent.invocation.finish" || event.name === "run.finish";
|
|
872
|
-
}
|
|
873
|
-
function isTraceRunError(event) {
|
|
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;
|
|
881
|
-
}
|
|
882
|
-
function deriveTraceRuns(events) {
|
|
883
|
-
const groups = /* @__PURE__ */ new Map();
|
|
884
|
-
for (const event of events) {
|
|
885
|
-
const id = runId(event);
|
|
886
|
-
groups.set(id, [...groups.get(id) || [], event]);
|
|
887
|
-
}
|
|
888
|
-
return [...groups.entries()].map(([id, group]) => {
|
|
889
|
-
const sorted = group.slice().sort((a, b) => a.sequence - b.sequence);
|
|
890
|
-
const first = sorted[0];
|
|
891
|
-
const steps = /* @__PURE__ */ new Map();
|
|
892
|
-
for (const event of sorted) {
|
|
893
|
-
const id = stepId(event);
|
|
894
|
-
if (!id) continue;
|
|
895
|
-
const existing = steps.get(id);
|
|
896
|
-
const status = stepStatus(event);
|
|
897
|
-
if (!existing) {
|
|
898
|
-
steps.set(id, {
|
|
899
|
-
attributes: stepTraceAttributes(event.attributes),
|
|
900
|
-
endTime: status === "running" ? void 0 : event.timestamp,
|
|
901
|
-
events: [event],
|
|
902
|
-
id,
|
|
903
|
-
name: event.name.replace(/\.(start|started|progress|finish|completed|failed|cancelled|end|error|request|decision|recorded)$/, ""),
|
|
904
|
-
startTime: event.timestamp,
|
|
905
|
-
status,
|
|
906
|
-
type: event.type
|
|
907
|
-
});
|
|
908
|
-
continue;
|
|
909
|
-
}
|
|
910
|
-
existing.events.push(event);
|
|
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,
|
|
919
|
-
...event.attributes
|
|
920
|
-
});
|
|
921
|
-
if (status !== "running") {
|
|
922
|
-
existing.endTime = event.timestamp;
|
|
923
|
-
existing.status = status;
|
|
924
|
-
existing.durationMs = durationMs(existing.startTime, existing.endTime);
|
|
925
|
-
}
|
|
926
|
-
}
|
|
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";
|
|
929
|
-
const endTime = status === "running" ? void 0 : terminal?.timestamp;
|
|
930
|
-
return {
|
|
931
|
-
durationMs: durationMs(first.timestamp, endTime),
|
|
932
|
-
endTime,
|
|
933
|
-
events: sorted,
|
|
934
|
-
id,
|
|
935
|
-
startTime: first.timestamp,
|
|
936
|
-
status,
|
|
937
|
-
steps: [...steps.values()]
|
|
938
|
-
};
|
|
939
|
-
});
|
|
940
|
-
}
|
|
941
|
-
function traceRunTraceId(run) {
|
|
942
|
-
return firstString(...run.events.map((event) => event.trace?.id), run.id) || run.id;
|
|
943
|
-
}
|
|
944
|
-
function traceRunParentId(run) {
|
|
945
|
-
return firstString(...run.events.map((event) => event.trace?.parentId));
|
|
946
|
-
}
|
|
947
|
-
function traceRunSpanId(run) {
|
|
948
|
-
return firstString(...run.events.map((event) => event.attributes?.["agent.invocation.id"]), run.id) || run.id;
|
|
949
|
-
}
|
|
950
|
-
function isOpenTelemetryId(value, length) {
|
|
951
|
-
return value.length === length && /^[0-9a-f]+$/.test(value);
|
|
952
|
-
}
|
|
953
|
-
function openTelemetryId(value, length) {
|
|
954
|
-
const normalized = value.toLowerCase();
|
|
955
|
-
if (isOpenTelemetryId(normalized, length)) return normalized;
|
|
956
|
-
let output = "";
|
|
957
|
-
for (let seed = 0; output.length < length; seed += 1) {
|
|
958
|
-
let hash = 2166136261;
|
|
959
|
-
const input = `${value}:${seed}`;
|
|
960
|
-
for (let index = 0; index < input.length; index += 1) {
|
|
961
|
-
hash ^= input.charCodeAt(index);
|
|
962
|
-
hash = Math.imul(hash, 16777619);
|
|
963
|
-
}
|
|
964
|
-
output += (hash >>> 0).toString(16).padStart(8, "0");
|
|
965
|
-
}
|
|
966
|
-
const id = output.slice(0, length);
|
|
967
|
-
return /^0+$/.test(id) ? `1${id.slice(1)}` : id;
|
|
968
|
-
}
|
|
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) => {
|
|
1045
|
-
const rawParentSpanId = traceRunParentId(run);
|
|
1046
|
-
const rawTraceId = traceRunTraceId(run);
|
|
1047
|
-
const parentSpanId = rawParentSpanId ? openTelemetryId(rawParentSpanId, 16) : void 0;
|
|
1048
|
-
const spanId = openTelemetryId(traceRunSpanId(run), 16);
|
|
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"]));
|
|
1057
|
-
return [{
|
|
1058
|
-
attributes: {
|
|
1059
|
-
...attributes,
|
|
1060
|
-
"vitehub.run.id": run.id,
|
|
1061
|
-
...rawParentSpanId ? { "vitehub.trace.parentId": rawParentSpanId } : {},
|
|
1062
|
-
"vitehub.trace.id": rawTraceId
|
|
1063
|
-
},
|
|
1064
|
-
endTime: run.endTime,
|
|
1065
|
-
events: spanEvents(run.events.filter((event) => !stepId(event))),
|
|
1066
|
-
name: "vitehub.run",
|
|
1067
|
-
...parentSpanId ? { parentSpanId } : {},
|
|
1068
|
-
spanId,
|
|
1069
|
-
startTime: run.startTime,
|
|
1070
|
-
status: {
|
|
1071
|
-
code: run.status === "failed" ? "ERROR" : run.status === "completed" ? "OK" : "UNSET",
|
|
1072
|
-
...run.status === "failed" && errorMessage ? { message: errorMessage } : {}
|
|
1073
|
-
},
|
|
1074
|
-
traceId
|
|
1075
|
-
}, ...run.steps.map((step) => ({
|
|
1076
|
-
attributes: {
|
|
1077
|
-
...aggregateTraceAttributes(step.attributes),
|
|
1078
|
-
"vitehub.run.id": run.id,
|
|
1079
|
-
"vitehub.step.id": step.id
|
|
1080
|
-
},
|
|
1081
|
-
endTime: step.endTime || run.endTime,
|
|
1082
|
-
events: spanEvents(step.events),
|
|
1083
|
-
name: step.name,
|
|
1084
|
-
parentSpanId: spanId,
|
|
1085
|
-
spanId: openTelemetryId(`${spanId}:${step.id}`, 16),
|
|
1086
|
-
startTime: step.startTime,
|
|
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
|
-
},
|
|
1091
|
-
traceId
|
|
1092
|
-
}))];
|
|
1093
|
-
});
|
|
1094
|
-
}
|
|
1095
|
-
function createExecutionContext(context) {
|
|
1096
|
-
const capabilities = context.capabilities ?? {};
|
|
1097
|
-
const runtimeConfig = context.runtimeConfig ?? {};
|
|
1098
|
-
return {
|
|
1099
|
-
...context,
|
|
1100
|
-
capabilities,
|
|
1101
|
-
runtimeConfig
|
|
1102
|
-
};
|
|
1103
|
-
}
|
|
1104
|
-
function defineCapability(kind, value, options = {}) {
|
|
1105
|
-
return {
|
|
1106
|
-
kind,
|
|
1107
|
-
name: options.name,
|
|
1108
|
-
value
|
|
1109
|
-
};
|
|
1110
|
-
}
|
|
1111
|
-
function createRuntimeWaitUntilController(options = {}) {
|
|
1112
|
-
const pending = [];
|
|
1113
|
-
return {
|
|
1114
|
-
async flushWaitUntil() {
|
|
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;
|
|
1127
|
-
},
|
|
1128
|
-
waitUntil(task) {
|
|
1129
|
-
pending.push(task);
|
|
1130
|
-
options.forward?.(task);
|
|
1131
|
-
}
|
|
1132
|
-
};
|
|
1133
|
-
}
|
|
1134
|
-
function isCapabilityHandle(value) {
|
|
1135
|
-
return hasRuntimeType(value, "object") && value !== null && "kind" in value && hasRuntimeType(value.kind, "string") && "value" in value;
|
|
1136
|
-
}
|
|
1137
|
-
function hasCapability(context, name) {
|
|
1138
|
-
return !!context.capabilities && name in context.capabilities;
|
|
1139
|
-
}
|
|
1140
|
-
function getCapability(context, name) {
|
|
1141
|
-
const value = context.capabilities?.[name];
|
|
1142
|
-
if (value === void 0) throw new ViteHubError("CAPABILITY_NOT_FOUND", `[vitehub:runtime] Capability "${name}" was not found.`, { details: { capability: name } });
|
|
1143
|
-
if (isCapabilityHandle(value)) return value;
|
|
1144
|
-
return defineCapability(name, value, { name });
|
|
1145
|
-
}
|
|
1146
|
-
function isResolvable(value) {
|
|
1147
|
-
return hasRuntimeType(value, "object") && value !== null && "resolve" in value && hasRuntimeType(value.resolve, "function");
|
|
1148
|
-
}
|
|
1149
|
-
async function resolveRuntimeValue(value, context) {
|
|
1150
|
-
if (isResolvable(value)) return await value.resolve(context);
|
|
1151
|
-
if (hasRuntimeType(value, "function")) return await value(context);
|
|
1152
|
-
return value;
|
|
1153
|
-
}
|
|
1154
|
-
async function resolveCapabilityPolicy(policy, context) {
|
|
1155
|
-
if (!policy) return "allow";
|
|
1156
|
-
return hasRuntimeType(policy, "function") ? await policy(context) : policy;
|
|
1157
|
-
}
|
|
1158
|
-
//#endregion
|
|
1159
|
-
export { ViteHubError, createExecutionContext, createRuntimeWaitUntilController, createTraceEventLog, defineCapability, deriveTraceRuns, emitTraceEvent, getCapability, getViteHubErrorShape, hasCapability, isExecutionAuthority, isResolvable, isTraceContentAttributeKey, isViteHubError, noExecutionAuthority, normalizeExecutionAuthority, normalizeRuntimeDiagnosticError, resolveCapabilityPolicy, resolveRuntimeValue, traceEventsToOpenTelemetryLogRecords, traceEventsToOpenTelemetrySpans, unknownExecutionAuthority };
|
|
1
|
+
import { A as isResponse, B as isRuntimeDiagnostic, C as resolveRuntimeValue, D as detectHost, E as unknownExecutionAuthority, F as createSqlLeaseStore, H as createExecutionBudget, I as leaseTable, L as defineErrors, M as serializeResponse, N as toResponse, O as getHostBinding, P as createMemoryLeaseStore, R as toResultError, S as resolveCapabilityPolicy, T as traceEventsToOpenTelemetrySpans, U as isExecutionBudgetExceededError, V as normalizeRuntimeDiagnosticError, W as isTraceContentAttributeKey, _ as hasCapability, b as noExecutionAuthority, d as createRuntimeWaitUntilController, f as createTraceEventLog, g as getCapability, h as emitTraceEvent, i as getStandardContext, j as isSerializedResponse, k as deserializeResponse, l as createExecutionContext, m as deriveTraceRuns, p as defineCapability, r as getRuntimeContext, u as createRuntimeContext, v as isExecutionAuthority, w as traceEventsToOpenTelemetryLogRecords, x as normalizeExecutionAuthority, y as isResolvable, z as formatRuntimeDiagnosticError } from "./request-context-CP9NhgLL.js";
|
|
2
|
+
import { t as runtimeErrorDiagnostics } from "./error-diagnostics-BKICpwZp.js";
|
|
3
|
+
import { n as getViteHubErrorShape, r as isViteHubError, t as ViteHubError } from "./errors-BEomN3fX.js";
|
|
4
|
+
import { a as hostedConsoleOrigin, c as normalizeConsoleProjectUrl, i as resolvePublicUrl, l as decodeRouteSegment, o as hostedConsoleUrl, s as normalizeConsolePath, t as consoleInvocationUrl, u as encodeRouteSegment } from "./public-url-B6x0HMgY.js";
|
|
5
|
+
export { ViteHubError, consoleInvocationUrl, createExecutionBudget, createExecutionContext, createMemoryLeaseStore, createRuntimeContext, createRuntimeWaitUntilController, createSqlLeaseStore, createTraceEventLog, decodeRouteSegment, defineCapability, defineErrors, deriveTraceRuns, deserializeResponse, detectHost, emitTraceEvent, encodeRouteSegment, formatRuntimeDiagnosticError, getCapability, getHostBinding, getRuntimeContext, getStandardContext, getViteHubErrorShape, hasCapability, hostedConsoleOrigin, hostedConsoleUrl, isExecutionAuthority, isExecutionBudgetExceededError, isResolvable, isResponse, isRuntimeDiagnostic, isSerializedResponse, isTraceContentAttributeKey, isViteHubError, leaseTable, noExecutionAuthority, normalizeConsolePath, normalizeConsoleProjectUrl, normalizeExecutionAuthority, normalizeRuntimeDiagnosticError, resolveCapabilityPolicy, resolvePublicUrl, resolveRuntimeValue, runtimeErrorDiagnostics, serializeResponse, toResponse, toResultError, traceEventsToOpenTelemetryLogRecords, traceEventsToOpenTelemetrySpans, unknownExecutionAuthority };
|