@vite-hub/runtime 0.0.2 → 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/LICENSE +201 -0
- package/README.md +130 -31
- package/dist/drain.d.ts +1 -0
- package/dist/drain.js +52 -0
- package/dist/index-tBKyUP1T.d.ts +314 -0
- package/dist/index.d.ts +2 -213
- package/dist/index.js +647 -64
- package/dist/node.d.ts +35 -0
- package/dist/node.js +396 -0
- package/dist/runtime-type-ovvOd6m5.js +37 -0
- package/package.json +8 -2
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
//#region src/diagnostics.d.ts
|
|
2
|
+
type RuntimeDiagnosticLevel = "debug" | "error" | "info" | "warn";
|
|
3
|
+
type RuntimeResourceScope = "container" | "host" | "process" | "service" | "workload";
|
|
4
|
+
type RuntimeResourceUnit = "bytes" | "count" | "microseconds" | "ratio";
|
|
5
|
+
interface RuntimeDiagnosticError {
|
|
6
|
+
cause?: RuntimeDiagnosticError;
|
|
7
|
+
code?: number | string;
|
|
8
|
+
details?: Readonly<Record<string, unknown>>;
|
|
9
|
+
errors?: readonly RuntimeDiagnosticError[];
|
|
10
|
+
message: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
requestId?: string;
|
|
13
|
+
stack?: string;
|
|
14
|
+
status?: number | string;
|
|
15
|
+
statusCode?: number | string;
|
|
16
|
+
}
|
|
17
|
+
interface RuntimeDiagnosticEvent {
|
|
18
|
+
attributes?: Readonly<Record<string, unknown>>;
|
|
19
|
+
component: string;
|
|
20
|
+
error?: RuntimeDiagnosticError;
|
|
21
|
+
level: RuntimeDiagnosticLevel;
|
|
22
|
+
name: string;
|
|
23
|
+
timestamp: string;
|
|
24
|
+
}
|
|
25
|
+
type RuntimeDiagnosticReporter = (event: RuntimeDiagnosticEvent) => MaybePromise<void>;
|
|
26
|
+
interface RuntimeResourceObservation {
|
|
27
|
+
name: string;
|
|
28
|
+
scope: RuntimeResourceScope;
|
|
29
|
+
source: string;
|
|
30
|
+
unit: RuntimeResourceUnit;
|
|
31
|
+
value: number;
|
|
32
|
+
}
|
|
33
|
+
interface RuntimeResourceSupport {
|
|
34
|
+
reason?: "collection-failed" | "not-isolated" | "permission-denied" | "unsupported-runtime" | (string & {});
|
|
35
|
+
scope: RuntimeResourceScope;
|
|
36
|
+
source: string;
|
|
37
|
+
supported: boolean;
|
|
38
|
+
}
|
|
39
|
+
interface RuntimeResourceSnapshot {
|
|
40
|
+
observedAt: string;
|
|
41
|
+
observations: readonly RuntimeResourceObservation[];
|
|
42
|
+
support?: readonly RuntimeResourceSupport[];
|
|
43
|
+
}
|
|
44
|
+
interface RuntimeResourceInspector {
|
|
45
|
+
inspect(options?: {
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
}): MaybePromise<RuntimeResourceSnapshot>;
|
|
48
|
+
}
|
|
49
|
+
interface RuntimeDiagnosticErrorOptions {
|
|
50
|
+
includeStack?: boolean;
|
|
51
|
+
maxDepth?: number;
|
|
52
|
+
maxErrors?: number;
|
|
53
|
+
maxStringLength?: number;
|
|
54
|
+
}
|
|
55
|
+
declare function normalizeRuntimeDiagnosticError(error: unknown, options?: RuntimeDiagnosticErrorOptions): RuntimeDiagnosticError;
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/errors.d.ts
|
|
58
|
+
type ViteHubErrorDetail = boolean | null | number | string | readonly ViteHubErrorDetail[] | {
|
|
59
|
+
readonly [key: string]: ViteHubErrorDetail | undefined;
|
|
60
|
+
};
|
|
61
|
+
type ViteHubErrorDetails = Readonly<Record<string, ViteHubErrorDetail | undefined>>;
|
|
62
|
+
interface ViteHubErrorShape<TCode extends string = string, TDetails extends ViteHubErrorDetails = ViteHubErrorDetails> {
|
|
63
|
+
code: TCode;
|
|
64
|
+
details?: TDetails;
|
|
65
|
+
message: string;
|
|
66
|
+
name: "ViteHubError";
|
|
67
|
+
requestId?: string;
|
|
68
|
+
}
|
|
69
|
+
interface ViteHubErrorOptions<TDetails extends ViteHubErrorDetails = ViteHubErrorDetails> extends ErrorOptions {
|
|
70
|
+
details?: TDetails;
|
|
71
|
+
requestId?: string;
|
|
72
|
+
}
|
|
73
|
+
declare class ViteHubError<TCode extends string = string, TDetails extends ViteHubErrorDetails = ViteHubErrorDetails> extends Error {
|
|
74
|
+
readonly code: TCode;
|
|
75
|
+
readonly details?: TDetails;
|
|
76
|
+
readonly requestId?: string;
|
|
77
|
+
constructor(code: TCode, message: string, options?: ViteHubErrorOptions<TDetails>);
|
|
78
|
+
toJSON(): ViteHubErrorShape<TCode, TDetails>;
|
|
79
|
+
}
|
|
80
|
+
declare function getViteHubErrorShape(value: unknown): ViteHubErrorShape | undefined;
|
|
81
|
+
declare function isViteHubError(value: unknown): value is ViteHubErrorShape;
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/index.d.ts
|
|
84
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
85
|
+
interface ExecutionAuthority {
|
|
86
|
+
readonly credentials: "ambient" | "none" | "provisioned" | "unknown";
|
|
87
|
+
readonly environment: "ambient" | "none" | "selected" | "unknown";
|
|
88
|
+
readonly filesystem: {
|
|
89
|
+
readonly access: "none" | "read-only" | "read-write" | "unknown";
|
|
90
|
+
readonly scope: "host" | "none" | "sandbox" | "unknown" | "workspace";
|
|
91
|
+
};
|
|
92
|
+
readonly isolation: "container" | "microvm" | "none" | "process" | "unknown";
|
|
93
|
+
readonly network: "none" | "restricted" | "unrestricted" | "unknown";
|
|
94
|
+
readonly processes: "arbitrary" | "none" | "restricted" | "unknown";
|
|
95
|
+
}
|
|
96
|
+
declare const noExecutionAuthority: ExecutionAuthority;
|
|
97
|
+
declare const unknownExecutionAuthority: ExecutionAuthority;
|
|
98
|
+
declare function isExecutionAuthority(value: unknown): value is ExecutionAuthority;
|
|
99
|
+
declare function normalizeExecutionAuthority(value: unknown): ExecutionAuthority;
|
|
100
|
+
type RuntimeWaitUntil = (task: Promise<unknown>) => void;
|
|
101
|
+
interface RuntimeWaitUntilController {
|
|
102
|
+
flushWaitUntil(): Promise<void>;
|
|
103
|
+
waitUntil: RuntimeWaitUntil;
|
|
104
|
+
}
|
|
105
|
+
interface TraceContext {
|
|
106
|
+
id: string;
|
|
107
|
+
parentId?: string;
|
|
108
|
+
sampled?: boolean;
|
|
109
|
+
}
|
|
110
|
+
type TraceActivityOwner = "agent" | "vitehub";
|
|
111
|
+
type TraceActivityPhase = "delivery" | "execution" | "setup" | "teardown";
|
|
112
|
+
interface TraceActivityContext {
|
|
113
|
+
owner: TraceActivityOwner;
|
|
114
|
+
phase: TraceActivityPhase;
|
|
115
|
+
}
|
|
116
|
+
type TracePayloadVisibility = "private" | "public" | "redacted" | "summary";
|
|
117
|
+
type TraceEventPayload = {
|
|
118
|
+
value: unknown;
|
|
119
|
+
visibility: "public";
|
|
120
|
+
} | {
|
|
121
|
+
summary: string;
|
|
122
|
+
visibility: "summary";
|
|
123
|
+
} | {
|
|
124
|
+
visibility: "redacted";
|
|
125
|
+
} | {
|
|
126
|
+
visibility: "private";
|
|
127
|
+
};
|
|
128
|
+
type TraceEventContentPolicy = "content" | "metadata";
|
|
129
|
+
type TraceRunStatus = "cancelled" | "completed" | "failed" | "running";
|
|
130
|
+
type TraceStepStatus = "completed" | "failed" | "running";
|
|
131
|
+
interface TraceEvent {
|
|
132
|
+
activity?: TraceActivityContext;
|
|
133
|
+
attributes?: Record<string, unknown>;
|
|
134
|
+
name: string;
|
|
135
|
+
payload?: TraceEventPayload;
|
|
136
|
+
timestamp?: Date | string;
|
|
137
|
+
trace?: TraceContext;
|
|
138
|
+
type: "approval" | "capability" | "error" | "lifecycle" | "policy" | "run";
|
|
139
|
+
}
|
|
140
|
+
interface TraceEventLogEntry extends TraceEvent {
|
|
141
|
+
sequence: number;
|
|
142
|
+
timestamp: string;
|
|
143
|
+
}
|
|
144
|
+
interface TraceEventLog {
|
|
145
|
+
append(event: TraceEvent): MaybePromise<TraceEventLogEntry>;
|
|
146
|
+
entries(): readonly TraceEventLogEntry[];
|
|
147
|
+
}
|
|
148
|
+
interface TraceEventLogOptions {
|
|
149
|
+
content?: TraceEventContentPolicy;
|
|
150
|
+
onEntry?: (entry: TraceEventLogEntry) => MaybePromise<void>;
|
|
151
|
+
}
|
|
152
|
+
interface TraceStepView {
|
|
153
|
+
attributes?: Record<string, unknown>;
|
|
154
|
+
durationMs?: number;
|
|
155
|
+
endTime?: string;
|
|
156
|
+
events: TraceEventLogEntry[];
|
|
157
|
+
id: string;
|
|
158
|
+
name: string;
|
|
159
|
+
startTime: string;
|
|
160
|
+
status: TraceStepStatus;
|
|
161
|
+
type: TraceEvent["type"];
|
|
162
|
+
}
|
|
163
|
+
interface TraceRunView {
|
|
164
|
+
durationMs?: number;
|
|
165
|
+
endTime?: string;
|
|
166
|
+
events: TraceEventLogEntry[];
|
|
167
|
+
id: string;
|
|
168
|
+
startTime: string;
|
|
169
|
+
status: TraceRunStatus;
|
|
170
|
+
steps: TraceStepView[];
|
|
171
|
+
}
|
|
172
|
+
interface OpenTelemetrySpanView {
|
|
173
|
+
attributes?: Record<string, unknown>;
|
|
174
|
+
endTime?: string;
|
|
175
|
+
events?: OpenTelemetrySpanEventView[];
|
|
176
|
+
name: string;
|
|
177
|
+
parentSpanId?: string;
|
|
178
|
+
spanId: string;
|
|
179
|
+
startTime: string;
|
|
180
|
+
status: {
|
|
181
|
+
code: "ERROR" | "OK" | "UNSET";
|
|
182
|
+
message?: string;
|
|
183
|
+
};
|
|
184
|
+
traceId: string;
|
|
185
|
+
}
|
|
186
|
+
interface OpenTelemetrySpanEventView {
|
|
187
|
+
attributes?: Record<string, unknown>;
|
|
188
|
+
name: string;
|
|
189
|
+
time: string;
|
|
190
|
+
}
|
|
191
|
+
interface OpenTelemetryLogRecordView {
|
|
192
|
+
attributes?: Record<string, unknown>;
|
|
193
|
+
eventName: string;
|
|
194
|
+
severityNumber?: number;
|
|
195
|
+
severityText?: string;
|
|
196
|
+
spanId: string;
|
|
197
|
+
time: string;
|
|
198
|
+
traceId: string;
|
|
199
|
+
}
|
|
200
|
+
interface OpenTelemetrySpanViewOptions {
|
|
201
|
+
content?: TraceEventContentPolicy;
|
|
202
|
+
}
|
|
203
|
+
interface RuntimeHostContext<TRuntimeConfig = Record<string, unknown>> {
|
|
204
|
+
capabilities?: RuntimeCapabilities;
|
|
205
|
+
cloudflare?: {
|
|
206
|
+
context?: unknown;
|
|
207
|
+
durableObjectStateName?: string;
|
|
208
|
+
env?: Record<string, unknown>;
|
|
209
|
+
};
|
|
210
|
+
event?: unknown;
|
|
211
|
+
memo<T>(key: string, create: () => T): T;
|
|
212
|
+
platform?: string;
|
|
213
|
+
request?: Request;
|
|
214
|
+
runtime: string;
|
|
215
|
+
runtimeConfig?: TRuntimeConfig;
|
|
216
|
+
trace?: TraceContext;
|
|
217
|
+
traceLog?: TraceEventLog;
|
|
218
|
+
vercel?: {
|
|
219
|
+
waitUntil?: RuntimeWaitUntil;
|
|
220
|
+
};
|
|
221
|
+
flushWaitUntil?: () => Promise<void>;
|
|
222
|
+
waitUntil: RuntimeWaitUntil;
|
|
223
|
+
}
|
|
224
|
+
type ExecutionContext<TRuntimeConfig = Record<string, unknown>> = RuntimeHostContext<TRuntimeConfig> & {
|
|
225
|
+
capabilities: RuntimeCapabilities;
|
|
226
|
+
runtimeConfig: TRuntimeConfig;
|
|
227
|
+
};
|
|
228
|
+
interface CapabilityHandle<TKind extends string = string, TValue = unknown> {
|
|
229
|
+
kind: TKind;
|
|
230
|
+
name?: string;
|
|
231
|
+
value: TValue;
|
|
232
|
+
}
|
|
233
|
+
type RuntimeCapabilityHandle<TKind extends string = string, TValue = unknown> = CapabilityHandle<TKind, TValue>;
|
|
234
|
+
type RuntimeCapabilities = Record<string, CapabilityHandle | unknown>;
|
|
235
|
+
interface CapabilityDefinition<TKind extends string = string, TValue = unknown> {
|
|
236
|
+
handle: CapabilityHandle<TKind, TValue>;
|
|
237
|
+
resolve(context: ExecutionContext): MaybePromise<CapabilityHandle<TKind, TValue>>;
|
|
238
|
+
}
|
|
239
|
+
interface Resolvable<T, TContext extends RuntimeHostContext<any> = RuntimeHostContext> {
|
|
240
|
+
resolve(context: TContext): MaybePromise<T>;
|
|
241
|
+
}
|
|
242
|
+
type MaybeResolvable<T, TContext extends RuntimeHostContext<any> = RuntimeHostContext> = T | Resolvable<T, TContext> | ((context: TContext) => MaybePromise<T>);
|
|
243
|
+
interface PolicyContext {
|
|
244
|
+
capability?: string;
|
|
245
|
+
input?: unknown;
|
|
246
|
+
operation?: string;
|
|
247
|
+
runtime?: string;
|
|
248
|
+
subject?: unknown;
|
|
249
|
+
trace?: TraceContext;
|
|
250
|
+
}
|
|
251
|
+
type PolicyDecision = "allow" | "deny" | "require-approval" | "retryable-failure";
|
|
252
|
+
type CapabilityPolicy = PolicyDecision | ((context: PolicyContext) => MaybePromise<PolicyDecision>);
|
|
253
|
+
type ApprovalState = "proposed" | "awaiting-approval" | "approved" | "denied" | "executing" | "completed" | "failed";
|
|
254
|
+
interface ApprovalRequest<TInput = unknown> {
|
|
255
|
+
id: string;
|
|
256
|
+
capability?: string;
|
|
257
|
+
input?: TInput;
|
|
258
|
+
reason?: string;
|
|
259
|
+
state: Extract<ApprovalState, "awaiting-approval" | "proposed">;
|
|
260
|
+
trace?: TraceContext;
|
|
261
|
+
}
|
|
262
|
+
interface ApprovalDecision {
|
|
263
|
+
approved: boolean;
|
|
264
|
+
decidedAt?: Date | string;
|
|
265
|
+
reason?: string;
|
|
266
|
+
requestId: string;
|
|
267
|
+
state: Extract<ApprovalState, "approved" | "denied">;
|
|
268
|
+
}
|
|
269
|
+
interface RunLifecycleHooks<TContext extends RuntimeHostContext<any> = RuntimeHostContext> {
|
|
270
|
+
approval?: (request: ApprovalRequest, context: TContext) => MaybePromise<void>;
|
|
271
|
+
error?: (error: unknown, context: TContext) => MaybePromise<void>;
|
|
272
|
+
finish?: (context: TContext) => MaybePromise<void>;
|
|
273
|
+
request?: (context: TContext) => MaybePromise<void>;
|
|
274
|
+
trace?: (event: TraceEvent, context: TContext) => MaybePromise<void>;
|
|
275
|
+
}
|
|
276
|
+
declare function isTraceContentAttributeKey(key: string): boolean;
|
|
277
|
+
declare function emitTraceEvent<TContext extends RuntimeHostContext<any>>(context: TContext, event: TraceEvent): Promise<TraceEventLogEntry | undefined>;
|
|
278
|
+
declare function createTraceEventLog(options?: TraceEventLogOptions): TraceEventLog;
|
|
279
|
+
declare function deriveTraceRuns(events: Iterable<TraceEventLogEntry>): TraceRunView[];
|
|
280
|
+
declare function traceEventsToOpenTelemetryLogRecords(events: Iterable<TraceEventLogEntry>, options?: OpenTelemetrySpanViewOptions): OpenTelemetryLogRecordView[];
|
|
281
|
+
declare function traceEventsToOpenTelemetrySpans(events: Iterable<TraceEventLogEntry>, options?: OpenTelemetrySpanViewOptions): OpenTelemetrySpanView[];
|
|
282
|
+
interface Lease {
|
|
283
|
+
expiresAt?: Date | string;
|
|
284
|
+
id: string;
|
|
285
|
+
key: string;
|
|
286
|
+
release(): MaybePromise<void>;
|
|
287
|
+
}
|
|
288
|
+
interface LeaseStore {
|
|
289
|
+
acquire(key: string, options?: {
|
|
290
|
+
owner?: string;
|
|
291
|
+
ttl?: number;
|
|
292
|
+
}): MaybePromise<Lease>;
|
|
293
|
+
}
|
|
294
|
+
type NormalizedRuntimeConfig<TConfig> = Exclude<TConfig, null | undefined> extends Record<string, unknown> ? Record<string, unknown> : Exclude<TConfig, null | undefined> | Record<string, unknown>;
|
|
295
|
+
type RuntimeConfigOf<TContext extends RuntimeHostContext<any>> = "runtimeConfig" extends keyof TContext ? undefined extends TContext["runtimeConfig"] ? NormalizedRuntimeConfig<TContext["runtimeConfig"]> : null extends TContext["runtimeConfig"] ? NormalizedRuntimeConfig<TContext["runtimeConfig"]> : TContext["runtimeConfig"] : Record<string, unknown>;
|
|
296
|
+
type RuntimeCapabilitiesOf<TContext extends RuntimeHostContext<any>> = "capabilities" extends keyof TContext ? undefined extends TContext["capabilities"] ? RuntimeCapabilities : TContext["capabilities"] : RuntimeCapabilities;
|
|
297
|
+
type CreatedExecutionContext<TContext extends RuntimeHostContext<any>> = TContext extends unknown ? Omit<TContext, "capabilities" | "runtimeConfig"> & {
|
|
298
|
+
capabilities: RuntimeCapabilitiesOf<TContext>;
|
|
299
|
+
runtimeConfig: RuntimeConfigOf<TContext>;
|
|
300
|
+
} : never;
|
|
301
|
+
declare function createExecutionContext<TContext extends RuntimeHostContext<any>>(context: TContext): CreatedExecutionContext<TContext>;
|
|
302
|
+
declare function defineCapability<TKind extends string, TValue>(kind: TKind, value: TValue, options?: {
|
|
303
|
+
name?: string;
|
|
304
|
+
}): CapabilityHandle<TKind, TValue>;
|
|
305
|
+
declare function createRuntimeWaitUntilController(options?: {
|
|
306
|
+
forward?: RuntimeWaitUntil;
|
|
307
|
+
}): RuntimeWaitUntilController;
|
|
308
|
+
declare function hasCapability(context: RuntimeHostContext, name: string): boolean;
|
|
309
|
+
declare function getCapability(context: RuntimeHostContext<any>, name: string): CapabilityHandle;
|
|
310
|
+
declare function isResolvable<T, TContext extends RuntimeHostContext<any>>(value: MaybeResolvable<T, TContext>): value is Resolvable<T, TContext>;
|
|
311
|
+
declare function resolveRuntimeValue<T, TContext extends RuntimeHostContext<any>>(value: MaybeResolvable<T, TContext>, context: TContext): Promise<T>;
|
|
312
|
+
declare function resolveCapabilityPolicy(policy: CapabilityPolicy | undefined, context: PolicyContext): Promise<PolicyDecision>;
|
|
313
|
+
//#endregion
|
|
314
|
+
export { normalizeExecutionAuthority as $, TraceEvent as A, TraceStepView as B, RuntimeHostContext as C, normalizeRuntimeDiagnosticError as Ct, TraceActivityOwner as D, TraceActivityContext as E, TraceEventPayload as F, deriveTraceRuns as G, createRuntimeWaitUntilController as H, TracePayloadVisibility as I, hasCapability as J, emitTraceEvent as K, TraceRunStatus as L, TraceEventLog as M, TraceEventLogEntry as N, TraceActivityPhase as O, TraceEventLogOptions as P, noExecutionAuthority as Q, TraceRunView as R, RuntimeCapabilityHandle as S, RuntimeResourceUnit as St, RuntimeWaitUntilController as T, createTraceEventLog as U, createExecutionContext as V, defineCapability as W, isResolvable as X, isExecutionAuthority as Y, isTraceContentAttributeKey as Z, PolicyContext as _, RuntimeResourceInspector as _t, CapabilityHandle as a, ViteHubError as at, RunLifecycleHooks as b, RuntimeResourceSnapshot as bt, ExecutionContext as c, ViteHubErrorOptions as ct, MaybePromise as d, isViteHubError as dt, resolveCapabilityPolicy as et, MaybeResolvable as f, RuntimeDiagnosticError as ft, OpenTelemetrySpanViewOptions as g, RuntimeDiagnosticReporter as gt, OpenTelemetrySpanView as h, RuntimeDiagnosticLevel as ht, CapabilityDefinition as i, unknownExecutionAuthority as it, TraceEventContentPolicy as j, TraceContext as k, Lease as l, ViteHubErrorShape as lt, OpenTelemetrySpanEventView as m, RuntimeDiagnosticEvent as mt, ApprovalRequest as n, traceEventsToOpenTelemetryLogRecords as nt, CapabilityPolicy as o, ViteHubErrorDetail as ot, OpenTelemetryLogRecordView as p, RuntimeDiagnosticErrorOptions as pt, getCapability as q, ApprovalState as r, traceEventsToOpenTelemetrySpans as rt, ExecutionAuthority as s, ViteHubErrorDetails as st, ApprovalDecision as t, resolveRuntimeValue as tt, LeaseStore as u, getViteHubErrorShape as ut, PolicyDecision as v, RuntimeResourceObservation as vt, RuntimeWaitUntil as w, RuntimeCapabilities as x, RuntimeResourceSupport as xt, Resolvable as y, RuntimeResourceScope as yt, TraceStepStatus as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,213 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
3
|
-
readonly [key: string]: ViteHubErrorDetail | undefined;
|
|
4
|
-
};
|
|
5
|
-
type ViteHubErrorDetails = Readonly<Record<string, ViteHubErrorDetail | undefined>>;
|
|
6
|
-
interface ViteHubErrorShape<TCode extends string = string, TDetails extends ViteHubErrorDetails = ViteHubErrorDetails> {
|
|
7
|
-
code: TCode;
|
|
8
|
-
details?: TDetails;
|
|
9
|
-
message: string;
|
|
10
|
-
name: "ViteHubError";
|
|
11
|
-
requestId?: string;
|
|
12
|
-
}
|
|
13
|
-
interface ViteHubErrorOptions<TDetails extends ViteHubErrorDetails = ViteHubErrorDetails> extends ErrorOptions {
|
|
14
|
-
details?: TDetails;
|
|
15
|
-
requestId?: string;
|
|
16
|
-
}
|
|
17
|
-
declare class ViteHubError<TCode extends string = string, TDetails extends ViteHubErrorDetails = ViteHubErrorDetails> extends Error {
|
|
18
|
-
readonly code: TCode;
|
|
19
|
-
readonly details?: TDetails;
|
|
20
|
-
readonly requestId?: string;
|
|
21
|
-
constructor(code: TCode, message: string, options?: ViteHubErrorOptions<TDetails>);
|
|
22
|
-
toJSON(): ViteHubErrorShape<TCode, TDetails>;
|
|
23
|
-
}
|
|
24
|
-
declare function getViteHubErrorShape(value: unknown): ViteHubErrorShape | undefined;
|
|
25
|
-
declare function isViteHubError(value: unknown): value is ViteHubErrorShape;
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/index.d.ts
|
|
28
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
29
|
-
interface ExecutionAuthority {
|
|
30
|
-
readonly credentials: "ambient" | "none" | "provisioned" | "unknown";
|
|
31
|
-
readonly environment: "ambient" | "none" | "selected" | "unknown";
|
|
32
|
-
readonly filesystem: {
|
|
33
|
-
readonly access: "none" | "read-only" | "read-write" | "unknown";
|
|
34
|
-
readonly scope: "host" | "none" | "sandbox" | "unknown" | "workspace";
|
|
35
|
-
};
|
|
36
|
-
readonly isolation: "container" | "microvm" | "none" | "process" | "unknown";
|
|
37
|
-
readonly network: "none" | "restricted" | "unrestricted" | "unknown";
|
|
38
|
-
readonly processes: "arbitrary" | "none" | "restricted" | "unknown";
|
|
39
|
-
}
|
|
40
|
-
declare const noExecutionAuthority: ExecutionAuthority;
|
|
41
|
-
declare const unknownExecutionAuthority: ExecutionAuthority;
|
|
42
|
-
declare function isExecutionAuthority(value: unknown): value is ExecutionAuthority;
|
|
43
|
-
declare function normalizeExecutionAuthority(value: unknown): ExecutionAuthority;
|
|
44
|
-
type RuntimeWaitUntil = (task: Promise<unknown>) => void;
|
|
45
|
-
interface RuntimeWaitUntilController {
|
|
46
|
-
flushWaitUntil(): Promise<void>;
|
|
47
|
-
waitUntil: RuntimeWaitUntil;
|
|
48
|
-
}
|
|
49
|
-
interface TraceContext {
|
|
50
|
-
id: string;
|
|
51
|
-
parentId?: string;
|
|
52
|
-
sampled?: boolean;
|
|
53
|
-
}
|
|
54
|
-
type TraceEventContentPolicy = "content" | "metadata";
|
|
55
|
-
type TraceRunStatus = "completed" | "failed" | "running";
|
|
56
|
-
type TraceStepStatus = "completed" | "failed" | "running";
|
|
57
|
-
interface TraceEvent {
|
|
58
|
-
attributes?: Record<string, unknown>;
|
|
59
|
-
name: string;
|
|
60
|
-
timestamp?: Date | string;
|
|
61
|
-
trace?: TraceContext;
|
|
62
|
-
type: "approval" | "capability" | "error" | "lifecycle" | "policy" | "run";
|
|
63
|
-
}
|
|
64
|
-
interface TraceEventLogEntry extends TraceEvent {
|
|
65
|
-
sequence: number;
|
|
66
|
-
timestamp: string;
|
|
67
|
-
}
|
|
68
|
-
interface TraceEventLog {
|
|
69
|
-
append(event: TraceEvent): MaybePromise<TraceEventLogEntry>;
|
|
70
|
-
entries(): readonly TraceEventLogEntry[];
|
|
71
|
-
}
|
|
72
|
-
interface TraceEventLogOptions {
|
|
73
|
-
content?: TraceEventContentPolicy;
|
|
74
|
-
onEntry?: (entry: TraceEventLogEntry) => MaybePromise<void>;
|
|
75
|
-
}
|
|
76
|
-
interface TraceStepView {
|
|
77
|
-
attributes?: Record<string, unknown>;
|
|
78
|
-
durationMs?: number;
|
|
79
|
-
endTime?: string;
|
|
80
|
-
events: TraceEventLogEntry[];
|
|
81
|
-
id: string;
|
|
82
|
-
name: string;
|
|
83
|
-
startTime: string;
|
|
84
|
-
status: TraceStepStatus;
|
|
85
|
-
type: TraceEvent["type"];
|
|
86
|
-
}
|
|
87
|
-
interface TraceRunView {
|
|
88
|
-
durationMs?: number;
|
|
89
|
-
endTime?: string;
|
|
90
|
-
events: TraceEventLogEntry[];
|
|
91
|
-
id: string;
|
|
92
|
-
startTime: string;
|
|
93
|
-
status: TraceRunStatus;
|
|
94
|
-
steps: TraceStepView[];
|
|
95
|
-
}
|
|
96
|
-
interface OpenTelemetrySpanView {
|
|
97
|
-
attributes?: Record<string, unknown>;
|
|
98
|
-
endTime?: string;
|
|
99
|
-
name: string;
|
|
100
|
-
parentSpanId?: string;
|
|
101
|
-
spanId: string;
|
|
102
|
-
startTime: string;
|
|
103
|
-
status: {
|
|
104
|
-
code: "ERROR" | "OK";
|
|
105
|
-
message?: string;
|
|
106
|
-
};
|
|
107
|
-
traceId: string;
|
|
108
|
-
}
|
|
109
|
-
interface RuntimeHostContext<TRuntimeConfig = Record<string, unknown>> {
|
|
110
|
-
capabilities?: RuntimeCapabilities;
|
|
111
|
-
cloudflare?: {
|
|
112
|
-
context?: unknown;
|
|
113
|
-
durableObjectStateName?: string;
|
|
114
|
-
env?: Record<string, unknown>;
|
|
115
|
-
};
|
|
116
|
-
event?: unknown;
|
|
117
|
-
memo<T>(key: string, create: () => T): T;
|
|
118
|
-
platform?: string;
|
|
119
|
-
request?: Request;
|
|
120
|
-
runtime: string;
|
|
121
|
-
runtimeConfig?: TRuntimeConfig;
|
|
122
|
-
trace?: TraceContext;
|
|
123
|
-
traceLog?: TraceEventLog;
|
|
124
|
-
vercel?: {
|
|
125
|
-
waitUntil?: RuntimeWaitUntil;
|
|
126
|
-
};
|
|
127
|
-
flushWaitUntil?: () => Promise<void>;
|
|
128
|
-
waitUntil: RuntimeWaitUntil;
|
|
129
|
-
}
|
|
130
|
-
type ExecutionContext<TRuntimeConfig = Record<string, unknown>> = RuntimeHostContext<TRuntimeConfig> & {
|
|
131
|
-
runtimeConfig: TRuntimeConfig;
|
|
132
|
-
};
|
|
133
|
-
type ResolvedRuntimeHostContext<TRuntimeConfig = Record<string, unknown>> = ExecutionContext<TRuntimeConfig>;
|
|
134
|
-
interface CapabilityHandle<TKind extends string = string, TValue = unknown> {
|
|
135
|
-
kind: TKind;
|
|
136
|
-
name?: string;
|
|
137
|
-
value: TValue;
|
|
138
|
-
}
|
|
139
|
-
type RuntimeCapabilityHandle<TKind extends string = string, TValue = unknown> = CapabilityHandle<TKind, TValue>;
|
|
140
|
-
type RuntimeCapabilities = Record<string, CapabilityHandle | unknown>;
|
|
141
|
-
interface CapabilityDefinition<TKind extends string = string, TValue = unknown> {
|
|
142
|
-
handle: CapabilityHandle<TKind, TValue>;
|
|
143
|
-
resolve(context: ExecutionContext): MaybePromise<CapabilityHandle<TKind, TValue>>;
|
|
144
|
-
}
|
|
145
|
-
interface Resolvable<T, TContext extends RuntimeHostContext<any> = RuntimeHostContext> {
|
|
146
|
-
resolve(context: TContext): MaybePromise<T>;
|
|
147
|
-
}
|
|
148
|
-
type MaybeResolvable<T, TContext extends RuntimeHostContext<any> = RuntimeHostContext> = T | Resolvable<T, TContext> | ((context: TContext) => MaybePromise<T>);
|
|
149
|
-
interface PolicyContext {
|
|
150
|
-
capability?: string;
|
|
151
|
-
input?: unknown;
|
|
152
|
-
operation?: string;
|
|
153
|
-
runtime?: string;
|
|
154
|
-
subject?: unknown;
|
|
155
|
-
trace?: TraceContext;
|
|
156
|
-
}
|
|
157
|
-
type PolicyDecision = "allow" | "deny" | "require-approval" | "retryable-failure";
|
|
158
|
-
type CapabilityPolicy = PolicyDecision | ((context: PolicyContext) => MaybePromise<PolicyDecision>);
|
|
159
|
-
type ApprovalState = "proposed" | "awaiting-approval" | "approved" | "denied" | "executing" | "completed" | "failed";
|
|
160
|
-
interface ApprovalRequest<TInput = unknown> {
|
|
161
|
-
id: string;
|
|
162
|
-
capability?: string;
|
|
163
|
-
input?: TInput;
|
|
164
|
-
reason?: string;
|
|
165
|
-
state: Extract<ApprovalState, "awaiting-approval" | "proposed">;
|
|
166
|
-
trace?: TraceContext;
|
|
167
|
-
}
|
|
168
|
-
interface ApprovalDecision {
|
|
169
|
-
approved: boolean;
|
|
170
|
-
decidedAt?: Date | string;
|
|
171
|
-
reason?: string;
|
|
172
|
-
requestId: string;
|
|
173
|
-
state: Extract<ApprovalState, "approved" | "denied">;
|
|
174
|
-
}
|
|
175
|
-
interface RunLifecycleHooks<TContext extends RuntimeHostContext<any> = RuntimeHostContext> {
|
|
176
|
-
approval?: (request: ApprovalRequest, context: TContext) => MaybePromise<void>;
|
|
177
|
-
error?: (error: unknown, context: TContext) => MaybePromise<void>;
|
|
178
|
-
finish?: (context: TContext) => MaybePromise<void>;
|
|
179
|
-
request?: (context: TContext) => MaybePromise<void>;
|
|
180
|
-
trace?: (event: TraceEvent, context: TContext) => MaybePromise<void>;
|
|
181
|
-
}
|
|
182
|
-
declare function emitTraceEvent<TContext extends RuntimeHostContext<any>>(context: TContext, event: TraceEvent): Promise<TraceEventLogEntry | undefined>;
|
|
183
|
-
declare function createTraceEventLog(options?: TraceEventLogOptions): TraceEventLog;
|
|
184
|
-
declare function deriveTraceRuns(events: Iterable<TraceEventLogEntry>): TraceRunView[];
|
|
185
|
-
declare function traceEventsToOpenTelemetrySpans(events: Iterable<TraceEventLogEntry>): OpenTelemetrySpanView[];
|
|
186
|
-
interface Lease {
|
|
187
|
-
expiresAt?: Date | string;
|
|
188
|
-
id: string;
|
|
189
|
-
key: string;
|
|
190
|
-
release(): MaybePromise<void>;
|
|
191
|
-
}
|
|
192
|
-
interface LeaseStore {
|
|
193
|
-
acquire(key: string, options?: {
|
|
194
|
-
owner?: string;
|
|
195
|
-
ttl?: number;
|
|
196
|
-
}): MaybePromise<Lease>;
|
|
197
|
-
}
|
|
198
|
-
declare function createExecutionContext<TRuntimeConfig = Record<string, unknown>, TContext extends RuntimeHostContext<TRuntimeConfig> = RuntimeHostContext<TRuntimeConfig>>(context: TContext): TContext & ExecutionContext<TRuntimeConfig>;
|
|
199
|
-
declare function resolveExecutionContext<TRuntimeConfig = Record<string, unknown>, TContext extends RuntimeHostContext<TRuntimeConfig> = RuntimeHostContext<TRuntimeConfig>>(context: TContext): TContext & ExecutionContext<TRuntimeConfig>;
|
|
200
|
-
declare function resolveRuntimeContext<TRuntimeConfig = Record<string, unknown>, TContext extends RuntimeHostContext<TRuntimeConfig> = RuntimeHostContext<TRuntimeConfig>>(context: TContext): TContext & ExecutionContext<TRuntimeConfig>;
|
|
201
|
-
declare function defineCapability<TKind extends string, TValue>(kind: TKind, value: TValue, options?: {
|
|
202
|
-
name?: string;
|
|
203
|
-
}): CapabilityHandle<TKind, TValue>;
|
|
204
|
-
declare function createRuntimeWaitUntilController(options?: {
|
|
205
|
-
forward?: RuntimeWaitUntil;
|
|
206
|
-
}): RuntimeWaitUntilController;
|
|
207
|
-
declare function hasCapability(context: RuntimeHostContext, name: string): boolean;
|
|
208
|
-
declare function getCapability<TKind extends string = string, TValue = unknown>(context: RuntimeHostContext, name: string): CapabilityHandle<TKind, TValue>;
|
|
209
|
-
declare function isResolvable<T, TContext extends RuntimeHostContext<any>>(value: MaybeResolvable<T, TContext>): value is Resolvable<T, TContext>;
|
|
210
|
-
declare function resolveRuntimeValue<T, TContext extends RuntimeHostContext<any>>(value: MaybeResolvable<T, TContext>, context: TContext): Promise<T>;
|
|
211
|
-
declare function resolveCapabilityPolicy(policy: CapabilityPolicy | undefined, context: PolicyContext): Promise<PolicyDecision>;
|
|
212
|
-
//#endregion
|
|
213
|
-
export { ApprovalDecision, ApprovalRequest, ApprovalState, CapabilityDefinition, CapabilityHandle, CapabilityPolicy, ExecutionAuthority, ExecutionContext, Lease, LeaseStore, MaybePromise, MaybeResolvable, OpenTelemetrySpanView, PolicyContext, PolicyDecision, Resolvable, ResolvedRuntimeHostContext, RunLifecycleHooks, RuntimeCapabilities, RuntimeCapabilityHandle, RuntimeHostContext, RuntimeWaitUntil, RuntimeWaitUntilController, TraceContext, TraceEvent, TraceEventContentPolicy, TraceEventLog, TraceEventLogEntry, TraceEventLogOptions, TraceRunStatus, TraceRunView, TraceStepStatus, TraceStepView, ViteHubError, type ViteHubErrorDetail, type ViteHubErrorDetails, type ViteHubErrorOptions, type ViteHubErrorShape, createExecutionContext, createRuntimeWaitUntilController, createTraceEventLog, defineCapability, deriveTraceRuns, emitTraceEvent, getCapability, getViteHubErrorShape, hasCapability, isExecutionAuthority, isResolvable, isViteHubError, noExecutionAuthority, normalizeExecutionAuthority, resolveCapabilityPolicy, resolveExecutionContext, resolveRuntimeContext, resolveRuntimeValue, traceEventsToOpenTelemetrySpans, unknownExecutionAuthority };
|
|
1
|
+
import { $ as normalizeExecutionAuthority, A as TraceEvent, B as TraceStepView, C as RuntimeHostContext, Ct as normalizeRuntimeDiagnosticError, D as TraceActivityOwner, E as TraceActivityContext, F as TraceEventPayload, G as deriveTraceRuns, H as createRuntimeWaitUntilController, I as TracePayloadVisibility, J as hasCapability, K as emitTraceEvent, L as TraceRunStatus, M as TraceEventLog, N as TraceEventLogEntry, O as TraceActivityPhase, P as TraceEventLogOptions, Q as noExecutionAuthority, R as TraceRunView, S as RuntimeCapabilityHandle, St as RuntimeResourceUnit, T as RuntimeWaitUntilController, U as createTraceEventLog, V as createExecutionContext, W as defineCapability, X as isResolvable, Y as isExecutionAuthority, Z as isTraceContentAttributeKey, _ as PolicyContext, _t as RuntimeResourceInspector, a as CapabilityHandle, at as ViteHubError, b as RunLifecycleHooks, bt as RuntimeResourceSnapshot, c as ExecutionContext, ct as ViteHubErrorOptions, d as MaybePromise, dt as isViteHubError, et as resolveCapabilityPolicy, f as MaybeResolvable, ft as RuntimeDiagnosticError, g as OpenTelemetrySpanViewOptions, gt as RuntimeDiagnosticReporter, h as OpenTelemetrySpanView, ht as RuntimeDiagnosticLevel, i as CapabilityDefinition, it as unknownExecutionAuthority, j as TraceEventContentPolicy, k as TraceContext, l as Lease, lt as ViteHubErrorShape, m as OpenTelemetrySpanEventView, mt as RuntimeDiagnosticEvent, n as ApprovalRequest, nt as traceEventsToOpenTelemetryLogRecords, o as CapabilityPolicy, ot as ViteHubErrorDetail, p as OpenTelemetryLogRecordView, pt as RuntimeDiagnosticErrorOptions, q as getCapability, r as ApprovalState, rt as traceEventsToOpenTelemetrySpans, s as ExecutionAuthority, st as ViteHubErrorDetails, t as ApprovalDecision, tt as resolveRuntimeValue, u as LeaseStore, ut as getViteHubErrorShape, v as PolicyDecision, vt as RuntimeResourceObservation, w as RuntimeWaitUntil, x as RuntimeCapabilities, xt as RuntimeResourceSupport, y as Resolvable, yt as RuntimeResourceScope, z as TraceStepStatus } from "./index-tBKyUP1T.js";
|
|
2
|
+
export { ApprovalDecision, ApprovalRequest, ApprovalState, CapabilityDefinition, CapabilityHandle, CapabilityPolicy, ExecutionAuthority, ExecutionContext, Lease, LeaseStore, MaybePromise, MaybeResolvable, OpenTelemetryLogRecordView, OpenTelemetrySpanEventView, OpenTelemetrySpanView, OpenTelemetrySpanViewOptions, PolicyContext, PolicyDecision, Resolvable, RunLifecycleHooks, RuntimeCapabilities, RuntimeCapabilityHandle, type RuntimeDiagnosticError, type RuntimeDiagnosticErrorOptions, type RuntimeDiagnosticEvent, type RuntimeDiagnosticLevel, type RuntimeDiagnosticReporter, RuntimeHostContext, type RuntimeResourceInspector, type RuntimeResourceObservation, type RuntimeResourceScope, type RuntimeResourceSnapshot, type RuntimeResourceSupport, type RuntimeResourceUnit, RuntimeWaitUntil, RuntimeWaitUntilController, TraceActivityContext, TraceActivityOwner, TraceActivityPhase, TraceContext, TraceEvent, TraceEventContentPolicy, TraceEventLog, TraceEventLogEntry, TraceEventLogOptions, TraceEventPayload, TracePayloadVisibility, TraceRunStatus, TraceRunView, TraceStepStatus, TraceStepView, ViteHubError, type ViteHubErrorDetail, type ViteHubErrorDetails, type ViteHubErrorOptions, type ViteHubErrorShape, createExecutionContext, createRuntimeWaitUntilController, createTraceEventLog, defineCapability, deriveTraceRuns, emitTraceEvent, getCapability, getViteHubErrorShape, hasCapability, isExecutionAuthority, isResolvable, isTraceContentAttributeKey, isViteHubError, noExecutionAuthority, normalizeExecutionAuthority, normalizeRuntimeDiagnosticError, resolveCapabilityPolicy, resolveRuntimeValue, traceEventsToOpenTelemetryLogRecords, traceEventsToOpenTelemetrySpans, unknownExecutionAuthority };
|