@vite-hub/runtime 0.1.0 → 0.3.1
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 +151 -117
- 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-CbqHQTvn.js → errors-BEomN3fX.js} +1 -1
- package/dist/{execution-budget-D8SwJE8_.d.ts → execution-budget-BPXbISEt.d.ts} +9 -6
- package/dist/index-Bcl-Hr-a.d.ts +678 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +5 -4
- package/dist/internal/drain.d.ts +17 -0
- package/dist/internal/drain.js +75 -0
- package/dist/internal/execution-budget.d.ts +1 -1
- package/dist/internal/grant.js +2 -2
- package/dist/internal/h3.d.ts +42 -0
- package/dist/internal/h3.js +181 -0
- package/dist/{node.d.ts → internal/node.d.ts} +2 -2
- package/dist/{node.js → internal/node.js} +4 -4
- 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 +9 -2
- package/dist/internal/runtime-type.js +3 -2
- package/dist/{shutdown.d.ts → internal/shutdown.d.ts} +1 -1
- package/dist/{shutdown.js → internal/shutdown.js} +1 -1
- 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/{src-jy-gyPPu.js → request-context-CP9NhgLL.js} +635 -551
- package/dist/runtime-type-BftydMAf.js +88 -0
- package/package.json +61 -26
- package/dist/drain.d.ts +0 -1
- package/dist/drain.js +0 -69
- package/dist/error-diagnostics-Bkym4e6y.d.ts +0 -12
- package/dist/h3.d.ts +0 -49
- package/dist/h3.js +0 -404
- package/dist/index-Rl4DbP8B.d.ts +0 -574
- package/dist/runtime-type-CgfU6SWl.js +0 -52
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { defineDiagnostics } from "nostics";
|
|
2
|
+
//#region src/error-diagnostics.ts
|
|
3
|
+
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
4
|
+
const codes = {
|
|
5
|
+
RUNTIME_R0001: {
|
|
6
|
+
...dynamicError,
|
|
7
|
+
fix: "Pass `maxDepth` to `normalizeRuntimeDiagnosticError()` as an integer of 0 or more, or remove it to use the default."
|
|
8
|
+
},
|
|
9
|
+
RUNTIME_R0002: {
|
|
10
|
+
...dynamicError,
|
|
11
|
+
fix: "Pass `maxErrors` to `normalizeRuntimeDiagnosticError()` as an integer of 1 or more, or remove it to use the default."
|
|
12
|
+
},
|
|
13
|
+
RUNTIME_R0003: {
|
|
14
|
+
...dynamicError,
|
|
15
|
+
fix: "Pass `maxStringLength` to `normalizeRuntimeDiagnosticError()` as an integer of 64 or more, or remove it to use the default."
|
|
16
|
+
},
|
|
17
|
+
RUNTIME_R0004: {
|
|
18
|
+
...dynamicError,
|
|
19
|
+
fix: "Read the logs of the process that `vitehub drain` waited for to find why its drain failed, then fix that failure and run `vitehub drain` again."
|
|
20
|
+
},
|
|
21
|
+
RUNTIME_R0005: {
|
|
22
|
+
...dynamicError,
|
|
23
|
+
fix: "Read the logs of the process that the message names to find why it stopped, then start it again before you run `vitehub drain`."
|
|
24
|
+
},
|
|
25
|
+
RUNTIME_R0006: {
|
|
26
|
+
...dynamicError,
|
|
27
|
+
fix: "Pass `new ViteHubError()` a nonempty `code` and `message` string within the length limits, and plain JSON `details`."
|
|
28
|
+
},
|
|
29
|
+
RUNTIME_R0007: {
|
|
30
|
+
...dynamicError,
|
|
31
|
+
fix: "Give the execution authority a valid value for each of `credentials`, `environment`, `filesystem.access`, `filesystem.scope`, `isolation`, `network`, and `processes`."
|
|
32
|
+
},
|
|
33
|
+
RUNTIME_R0009: {
|
|
34
|
+
...dynamicError,
|
|
35
|
+
fix: "Set `intervalMs` of the process reconciler to a number of milliseconds from 1 to 2147483647."
|
|
36
|
+
},
|
|
37
|
+
RUNTIME_R0010: {
|
|
38
|
+
...dynamicError,
|
|
39
|
+
fix: "Give the process reconciler a `signal` other than `SIGKILL` or `SIGSTOP`, or set `signal: false`."
|
|
40
|
+
},
|
|
41
|
+
RUNTIME_R0011: {
|
|
42
|
+
...dynamicError,
|
|
43
|
+
fix: "Call `drain()` of the process reconciler after its callback returns, not from inside the callback."
|
|
44
|
+
},
|
|
45
|
+
RUNTIME_R0015: {
|
|
46
|
+
...dynamicError,
|
|
47
|
+
fix: "Pass the `Request` of a Fetchable handler, or the event of an H3 or Nitro route, to `getStandardContext()`."
|
|
48
|
+
},
|
|
49
|
+
RUNTIME_R0016: {
|
|
50
|
+
...dynamicError,
|
|
51
|
+
fix: "Return the body or a `Response` from the handler, in place of setting `~standard.res.body`."
|
|
52
|
+
},
|
|
53
|
+
RUNTIME_R0017: dynamicError,
|
|
54
|
+
RUNTIME_R0018: dynamicError,
|
|
55
|
+
RUNTIME_CONSOLE_PATH_INVALID: {
|
|
56
|
+
why: ({ value }) => `${value} is not a Console path. Use a path that starts with one /, such as /agents/<agent>.`,
|
|
57
|
+
fix: "Pass `hostedConsoleUrl()` a Console path that starts with one `/`, such as `/kv` or `/agents/<agent>/invocations/<id>`."
|
|
58
|
+
},
|
|
59
|
+
RUNTIME_CONSOLE_PROJECT_URL_INVALID: {
|
|
60
|
+
why: ({ value }) => `${value} is not a project URL. Use the https:// origin of the app, with its base path if it has one.`,
|
|
61
|
+
fix: "Pass `hostedConsoleUrl()` the `https://` origin of the app, or `http://localhost` in development, with its base path and without a user name or password."
|
|
62
|
+
},
|
|
63
|
+
RUNTIME_EXECUTION_BUDGET_AMOUNT_INVALID: {
|
|
64
|
+
why: ({ counter }) => `[vitehub] Execution budget ${counter} amount must be a finite non-negative number.`,
|
|
65
|
+
fix: "Pass `consume()` and the `record*()` methods of the execution budget a finite number of 0 or more."
|
|
66
|
+
},
|
|
67
|
+
RUNTIME_EXECUTION_BUDGET_EXCEEDED: {
|
|
68
|
+
why: ({ counter }) => `[vitehub] Execution budget exhausted for ${counter}.`,
|
|
69
|
+
fix: "Raise the `executionBudget` limit that `error.counter` names, such as `maxToolCalls`, `maxRetries`, `maxInputBytes`, or `maxOutputBytes`, or give the run less work."
|
|
70
|
+
},
|
|
71
|
+
RUNTIME_EXECUTION_BUDGET_LIMIT_INVALID: {
|
|
72
|
+
why: () => "[vitehub] Execution budget limits must be finite non-negative numbers.",
|
|
73
|
+
fix: "Set each limit of `executionBudget`, such as `maxToolCalls` or `maxOutputBytes`, to a finite number of 0 or more, or remove it."
|
|
74
|
+
},
|
|
75
|
+
RUNTIME_SERIALIZED_RESPONSE_INVALID: {
|
|
76
|
+
why: () => "Invalid serialized Response",
|
|
77
|
+
fix: "Pass `deserializeResponse()` the record that `serializeResponse()` returned, unchanged. Check it first with `isSerializedResponse()`."
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const runtimeErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
81
|
+
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
82
|
+
codes
|
|
83
|
+
});
|
|
84
|
+
//#endregion
|
|
85
|
+
export { runtimeErrorDiagnostics as t };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Diagnostics } from "nostics";
|
|
2
|
+
//#region src/error-diagnostics.d.ts
|
|
3
|
+
interface RuntimeCodeDefinition {
|
|
4
|
+
why: (params: {
|
|
5
|
+
counter?: string;
|
|
6
|
+
message?: unknown;
|
|
7
|
+
value?: string;
|
|
8
|
+
}) => string;
|
|
9
|
+
fix?: string;
|
|
10
|
+
}
|
|
11
|
+
type RuntimeErrorCode = "RUNTIME_R0001" | "RUNTIME_R0002" | "RUNTIME_R0003" | "RUNTIME_R0004" | "RUNTIME_R0005" | "RUNTIME_R0006" | "RUNTIME_R0007" | "RUNTIME_R0009" | "RUNTIME_R0010" | "RUNTIME_R0011" | "RUNTIME_R0015" | "RUNTIME_R0016" | "RUNTIME_R0017" | "RUNTIME_R0018" | "RUNTIME_CONSOLE_PATH_INVALID" | "RUNTIME_CONSOLE_PROJECT_URL_INVALID" | "RUNTIME_EXECUTION_BUDGET_AMOUNT_INVALID" | "RUNTIME_EXECUTION_BUDGET_EXCEEDED" | "RUNTIME_EXECUTION_BUDGET_LIMIT_INVALID" | "RUNTIME_SERIALIZED_RESPONSE_INVALID";
|
|
12
|
+
declare const codes: Record<RuntimeErrorCode, RuntimeCodeDefinition>;
|
|
13
|
+
declare const runtimeErrorDiagnostics: Diagnostics<typeof codes, []>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { runtimeErrorDiagnostics as t };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Diagnostic } from "nostics";
|
|
1
2
|
//#region src/execution-budget.d.ts
|
|
2
3
|
/** Counters that an Invocation can spend while it runs. */
|
|
3
4
|
type ExecutionBudgetCounter = "inputBytes" | "outputBytes" | "retries" | "toolCalls";
|
|
@@ -30,11 +31,13 @@ interface ExecutionBudgetSnapshot {
|
|
|
30
31
|
interface ExecutionBudgetOptions extends ExecutionBudgetLimits {
|
|
31
32
|
signal?: AbortSignal;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
34
|
+
/** `RUNTIME_EXECUTION_BUDGET_EXCEEDED`, with the counter and the limit that ran out. Agents read them. */
|
|
35
|
+
type ExecutionBudgetExceededError = Diagnostic & {
|
|
36
|
+
counter: ExecutionBudgetCounter;
|
|
37
|
+
limit?: number;
|
|
38
|
+
};
|
|
39
|
+
/** Whether `error` is the error of an execution budget that ran out. */
|
|
40
|
+
declare function isExecutionBudgetExceededError(error: unknown): error is ExecutionBudgetExceededError;
|
|
38
41
|
interface ExecutionBudget {
|
|
39
42
|
readonly signal: AbortSignal;
|
|
40
43
|
cancel(reason?: unknown): void;
|
|
@@ -50,4 +53,4 @@ interface ExecutionBudget {
|
|
|
50
53
|
}
|
|
51
54
|
declare function createExecutionBudget(options?: ExecutionBudgetOptions): ExecutionBudget;
|
|
52
55
|
//#endregion
|
|
53
|
-
export { ExecutionBudgetOptions as a, createExecutionBudget as c, ExecutionBudgetLimits as i, ExecutionBudgetCounter as n, ExecutionBudgetSnapshot as o, ExecutionBudgetExceededError as r, ExecutionBudgetUsage as s, ExecutionBudget as t };
|
|
56
|
+
export { ExecutionBudgetOptions as a, createExecutionBudget as c, ExecutionBudgetLimits as i, isExecutionBudgetExceededError as l, ExecutionBudgetCounter as n, ExecutionBudgetSnapshot as o, ExecutionBudgetExceededError as r, ExecutionBudgetUsage as s, ExecutionBudget as t };
|