@lostgradient/weft 0.14.0 → 0.16.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 +3 -8
- package/dist/alerting/alert-manager.d.ts +2 -0
- package/dist/alerting/alert-manager.js +3 -0
- package/dist/cli/api.js +5 -19
- package/dist/cli/console.d.ts +12 -0
- package/dist/cli/console.js +62 -0
- package/dist/cli/generated/operation-catalog.snapshot.json +1061 -90
- package/dist/cli/generated/operation-client.generated.d.ts +29 -23
- package/dist/cli/generated/operation-client.generated.js +2 -0
- package/dist/cli/help-text.d.ts +1 -1
- package/dist/cli/help-text.js +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/cli/json-input.d.ts +20 -0
- package/dist/cli/json-input.js +33 -0
- package/dist/cli/parse-arguments.js +2 -0
- package/dist/cli/schedule.js +7 -9
- package/dist/cli/types.d.ts +1 -0
- package/dist/cli/workflow-commands.js +5 -25
- package/dist/cli-main.js +4 -2
- package/dist/core/aggregate-validation.d.ts +2 -5
- package/dist/core/aggregate-validation.js +2 -10
- package/dist/core/atomic-state.js +21 -24
- package/dist/core/engine/index.d.ts +3 -0
- package/dist/core/engine/index.js +3 -0
- package/dist/core/engine/schedules.js +4 -1
- package/dist/core/inline-execution-strategy.js +8 -46
- package/dist/core/list-filter-validation.d.ts +2 -5
- package/dist/core/list-filter-validation.js +2 -10
- package/dist/core/types/schedules.d.ts +13 -31
- package/dist/core/validation-issues.d.ts +13 -0
- package/dist/core/validation-issues.js +9 -0
- package/dist/diagnostics/recommendations.js +1 -9
- package/dist/http.js +2 -2
- package/dist/indexeddb.js +1 -1
- package/dist/mcp/session.js +2 -10
- package/dist/mcp/tools.js +2 -10
- package/dist/mcp/tuple-list-equality.d.ts +1 -0
- package/dist/mcp/tuple-list-equality.js +12 -0
- package/dist/server/authorization-scope.d.ts +1 -1
- package/dist/server/authorization-scope.js +0 -2
- package/dist/server/dashboard-assets.d.ts +26 -0
- package/dist/server/dashboard-assets.js +95 -0
- package/dist/server/index.d.ts +10 -1
- package/dist/server/index.js +11 -2
- package/dist/server/interactive-operations.js +1 -0
- package/dist/server/operation-catalog/types.d.ts +1 -1
- package/dist/server/operation-registry.d.ts +2 -31
- package/dist/server/operations/bulk-filter-helpers.d.ts +17 -17
- package/dist/server/operations/bulk-filter-helpers.js +16 -37
- package/dist/server/operations/bulk-mutate-workflow-tags.d.ts +27 -27
- package/dist/server/operations/bulk-signal-workflows.d.ts +26 -26
- package/dist/server/operations/create-schedule.js +26 -65
- package/dist/server/operations/event-stream-contracts.d.ts +20 -0
- package/dist/server/operations/event-stream-contracts.js +67 -0
- package/dist/server/operations/fleet-events-sse.js +21 -50
- package/dist/server/operations/fleet-events-subscription.js +8 -12
- package/dist/server/operations/list-alerts.d.ts +26 -0
- package/dist/server/operations/list-alerts.js +54 -0
- package/dist/server/operations/list-workflows.d.ts +43 -43
- package/dist/server/operations/list-workflows.js +9 -30
- package/dist/server/operations/purge-workflows.d.ts +11 -11
- package/dist/server/operations/schedule-faults.d.ts +9 -1
- package/dist/server/operations/schedule-faults.js +51 -0
- package/dist/server/operations/schedule-rest-body.d.ts +11 -0
- package/dist/server/operations/schedule-rest-body.js +28 -0
- package/dist/server/operations/update-schedule.js +13 -72
- package/dist/server/operations/workflow-events-sse.js +29 -67
- package/dist/server/operations/workflow-events-subscription.js +9 -27
- package/dist/server/rest-bindings.js +3 -0
- package/dist/server/runtime/task-polling.js +3 -5
- package/dist/server/task-state.d.ts +2 -8
- package/dist/server/task-state.js +10 -7
- package/dist/service-worker/index.d.ts +4 -1
- package/dist/service-worker/index.js +2 -2
- package/dist/service-worker/setup.d.ts +20 -0
- package/dist/service-worker/setup.js +5 -5
- package/dist/storage/bun-sql.js +65 -80
- package/dist/storage/conditional-batch-body.d.ts +7 -0
- package/dist/storage/conditional-batch-body.js +14 -0
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/neon.js +2 -2
- package/dist/storage/node-sqlite-loader.d.ts +2 -2
- package/dist/storage/node-sqlite.js +32 -17
- package/dist/storage/postgres.js +2 -2
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/testing.js +1 -1
- package/dist/storage/turso.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/web-extension.js +1 -1
- package/dist/worker/execute-with-interceptors.d.ts +1 -1
- package/dist/worker/execute-with-interceptors.js +2 -2
- package/dist/worker/index.js +5 -5
- package/dist/worker/long-poll.js +3 -4
- package/dist/worker/protocol-messages.d.ts +11 -19
- package/dist/worker/protocol-schemas.d.ts +8 -8
- package/dist/worker/protocol-schemas.js +4 -4
- package/dist/worker/protocol-task-result.d.ts +1 -0
- package/dist/worker/protocol-task-result.js +1 -3
- package/dist/worker/protocol.js +1 -1
- package/dist/worker/registry/types.d.ts +2 -7
- package/dist/worker/registry.d.ts +3 -9
- package/dist/worker/registry.js +2 -5
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Weft
|
|
2
2
|
|
|
3
|
-
A Bun-native durable execution engine. Current release: `0.
|
|
3
|
+
A Bun-native durable execution engine. Current release: `0.16.0`.
|
|
4
4
|
|
|
5
5
|
Install the library from npm as `@lostgradient/weft`:
|
|
6
6
|
|
|
@@ -43,14 +43,9 @@ Weft is a ground-up rethink: what would durable execution look like if you desig
|
|
|
43
43
|
|
|
44
44
|
## Stability Tiers
|
|
45
45
|
|
|
46
|
-
Weft is
|
|
46
|
+
Weft is pre-1.0. The [breaking-change policy](documentation/contributing/breaking-changes.md#stability-tiers) owns the current candidate-stable and experimental surface inventory; feature guides state local context without maintaining a second list.
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------- |
|
|
50
|
-
| Candidate-stable, provisional | Engine core, [`TestEngine`](documentation/guides/testing.md), Bun SQLite, Node SQLite, LMDB, [`RemoteWorker`](documentation/guides/remote-workers.md), [`serve()`](documentation/guides/server.md) and `/v1` REST, source/binary CLI commands `serve`, `doctor`, `version`, `--version`, and `-v`, exported public error codes | Suitable for serious trials. Pin the package version and read release notes before upgrading until the 1.0 contract lands. |
|
|
51
|
-
| Experimental | [Browser runtime](documentation/guides/service-worker.md), [MCP](documentation/reference/api-server.md#mcp-server), IndexedDB, WebExtension, HTTP and compressed storage, Turso pending conformance proof, CLI commands beyond `serve`, `doctor`, `version`, `--version`, and `-v` when running Weft from source or a standalone binary, [OpenTelemetry](documentation/guides/observability.md) metric names, externally supplied dashboard mounting, [`ctx.step()`](documentation/guides/workflows.md#getting-started-without-generators) sugar | API shape, storage guarantees, diagnostics, or compatibility behavior may change without a deprecation window before 1.0. |
|
|
52
|
-
|
|
53
|
-
If a surface is not named here, treat it as experimental. Stability is about compatibility and operational guarantees; it is not a statement that every candidate-stable surface is appropriate for every deployment.
|
|
48
|
+
Candidate-stable surfaces are suitable for serious trials, but the 1.0 compatibility promise is not final until the Tier-0 work is complete. Surfaces not named in the canonical inventory are experimental by default.
|
|
54
49
|
|
|
55
50
|
The public path to 1.0 is tracked in the [roadmap to 1.0](documentation/roadmap-to-1.0.md). The 1.0 compatibility promise will apply to the stable tier only; experimental surfaces may continue changing until they graduate.
|
|
56
51
|
|
|
@@ -40,5 +40,7 @@ export declare class AlertManager implements Disposable {
|
|
|
40
40
|
tick(): void;
|
|
41
41
|
/** Get current state of all alert rules (for debugging/testing). */
|
|
42
42
|
get states(): readonly AlertState[];
|
|
43
|
+
/** Get the alert rules that are currently firing. */
|
|
44
|
+
get activeStates(): readonly AlertState[];
|
|
43
45
|
[Symbol.dispose](): void;
|
|
44
46
|
}
|
|
@@ -155,6 +155,9 @@ export class AlertManager {
|
|
|
155
155
|
get states() {
|
|
156
156
|
return this.#states;
|
|
157
157
|
}
|
|
158
|
+
get activeStates() {
|
|
159
|
+
return this.#states.filter((state) => state.status === "firing");
|
|
160
|
+
}
|
|
158
161
|
[Symbol.dispose]() {
|
|
159
162
|
if (this.#tickInterval !== null) {
|
|
160
163
|
clearInterval(this.#tickInterval);
|
package/dist/cli/api.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createLiveOperationRegistry } from "../server/rest-bindings.js";
|
|
2
2
|
import { findNearestCandidate } from "./command-suggestions.js";
|
|
3
3
|
import snapshotData from "./generated/operation-catalog.snapshot.json";
|
|
4
|
+
import { loadJsonInput } from "./json-input.js";
|
|
4
5
|
import { sendJsonRpcRequest } from "./json-rpc-client.js";
|
|
5
6
|
const snapshot = snapshotData, operationByName = new Map(snapshot.operations.map((operation) => [operation.name, operation]));
|
|
6
7
|
export async function executeApi(command) {
|
|
@@ -107,25 +108,10 @@ function formatOperationDescription(operation) {
|
|
|
107
108
|
`);
|
|
108
109
|
}
|
|
109
110
|
async function readInput(command) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return parseInput(await Bun.stdin.text());
|
|
115
|
-
const file = Bun.file(command.inputFile);
|
|
116
|
-
if (!await file.exists())
|
|
117
|
-
return { ok: !1, output: usageError(`api: input file not found: ${command.inputFile}`) };
|
|
118
|
-
return parseInput(await file.text());
|
|
119
|
-
}
|
|
120
|
-
return { ok: !0, value: {} };
|
|
121
|
-
}
|
|
122
|
-
function parseInput(source) {
|
|
123
|
-
try {
|
|
124
|
-
return { ok: !0, value: JSON.parse(source) };
|
|
125
|
-
} catch (error) {
|
|
126
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
127
|
-
return { ok: !1, output: usageError(`api: invalid JSON input: ${message}`) };
|
|
128
|
-
}
|
|
111
|
+
const result = await loadJsonInput(command.input, command.inputFile);
|
|
112
|
+
if (!result.ok)
|
|
113
|
+
return { ok: !1, output: usageError(`api: ${result.error.message}`) };
|
|
114
|
+
return { ok: !0, value: result.value === void 0 ? {} : result.value };
|
|
129
115
|
}
|
|
130
116
|
function validateInput(operationName, input) {
|
|
131
117
|
const operation = createLiveOperationRegistry().get(operationName);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DashboardAssets, DashboardRouteTarget } from '../server/index.ts';
|
|
2
|
+
export interface ConsoleMount {
|
|
3
|
+
dashboard: DashboardRouteTarget;
|
|
4
|
+
dashboardAssets: DashboardAssets;
|
|
5
|
+
}
|
|
6
|
+
export interface ConsoleModuleLoaderOptions {
|
|
7
|
+
cwd?: string;
|
|
8
|
+
resolveModule?: (specifier: string, cwd: string) => string;
|
|
9
|
+
importModule?: (url: string) => Promise<unknown>;
|
|
10
|
+
}
|
|
11
|
+
/** Resolve and load the optional console from the CLI user's environment. */
|
|
12
|
+
export declare function loadConsoleMount(options?: ConsoleModuleLoaderOptions): Promise<ConsoleMount>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { statSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
const CONSOLE_PACKAGE_NAME = "@lostgradient/weft-console";
|
|
5
|
+
function defaultImportModule(url) {
|
|
6
|
+
return import(url);
|
|
7
|
+
}
|
|
8
|
+
function isDashboardRouteTarget(value) {
|
|
9
|
+
return typeof value === "function" || typeof value === "string" || value instanceof Response;
|
|
10
|
+
}
|
|
11
|
+
function isConsoleModule(value) {
|
|
12
|
+
return typeof value === "object" && value !== null;
|
|
13
|
+
}
|
|
14
|
+
function consoleError(message) {
|
|
15
|
+
return Error(`--console ${message}`);
|
|
16
|
+
}
|
|
17
|
+
function resolveConsoleEntry(cwd, resolveModule) {
|
|
18
|
+
try {
|
|
19
|
+
return resolveModule(CONSOLE_PACKAGE_NAME, cwd);
|
|
20
|
+
} catch {
|
|
21
|
+
throw consoleError(`requires ${CONSOLE_PACKAGE_NAME}. Install it in the CLI project: bun add ${CONSOLE_PACKAGE_NAME}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function importConsoleModule(resolvedEntry, importModule) {
|
|
25
|
+
try {
|
|
26
|
+
const loaded = await importModule(pathToFileURL(resolvedEntry).href);
|
|
27
|
+
if (!isConsoleModule(loaded))
|
|
28
|
+
throw Error("module is not an object");
|
|
29
|
+
return loaded;
|
|
30
|
+
} catch {
|
|
31
|
+
throw consoleError(`could not load ${CONSOLE_PACKAGE_NAME}; reinstall or update it, then retry, or remove --console`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function loadDashboard(module) {
|
|
35
|
+
if (typeof module.weftConsole !== "function")
|
|
36
|
+
throw consoleError(`${CONSOLE_PACKAGE_NAME} must export a weftConsole() function; update the package or remove --console`);
|
|
37
|
+
try {
|
|
38
|
+
const dashboard = module.weftConsole();
|
|
39
|
+
if (!isDashboardRouteTarget(dashboard))
|
|
40
|
+
throw Error("invalid dashboard route target");
|
|
41
|
+
return dashboard;
|
|
42
|
+
} catch {
|
|
43
|
+
throw consoleError(`${CONSOLE_PACKAGE_NAME} weftConsole() failed; reinstall or update it, then retry, or remove --console`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function resolveConsoleAssets(resolvedEntry) {
|
|
47
|
+
const directory = join(dirname(fileURLToPath(pathToFileURL(resolvedEntry))), "assets");
|
|
48
|
+
try {
|
|
49
|
+
if (!statSync(directory).isDirectory())
|
|
50
|
+
throw Error("not a directory");
|
|
51
|
+
} catch {
|
|
52
|
+
throw consoleError(`${CONSOLE_PACKAGE_NAME} is missing its built assets; reinstall or update it, then retry, or remove --console`);
|
|
53
|
+
}
|
|
54
|
+
return { prefix: "/assets", directory };
|
|
55
|
+
}
|
|
56
|
+
export async function loadConsoleMount(options = {}) {
|
|
57
|
+
const cwd = options.cwd ?? process.cwd(), resolveModule = options.resolveModule ?? Bun.resolveSync, importModule = options.importModule ?? defaultImportModule, resolvedEntry = resolveConsoleEntry(cwd, resolveModule), module = await importConsoleModule(resolvedEntry, importModule);
|
|
58
|
+
return {
|
|
59
|
+
dashboard: loadDashboard(module),
|
|
60
|
+
dashboardAssets: resolveConsoleAssets(resolvedEntry)
|
|
61
|
+
};
|
|
62
|
+
}
|