@independo/inderun-web 0.2.0-dev.2 → 0.2.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/route-planner.d.ts +31 -8
- package/dist/route-planner.d.ts.map +1 -1
- package/dist/route-planner.js +46 -17
- package/dist/router.d.ts +11 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +11 -9
- package/package.json +4 -4
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGjD,OAAO,EAAuB,KAAK,gBAAgB,EAAwB,MAAM,gBAAgB,CAAC;AAElG;;;;GAIG;AACH,qBAAa,OAAO;IAWhB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,YAAY;IAXtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAmB;IAE3C;;;;;OAKG;gBAEO,QAAQ,EAAE,gBAAgB,EAC1B,YAAY,EAAE,YAAY,EAClC,gBAAgB,CAAC,EAAE,gBAAgB;IAOrC;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAShB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAoBxB;;;;;;;OAOG;IACG,GAAG,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGjD,OAAO,EAAuB,KAAK,gBAAgB,EAAwB,MAAM,gBAAgB,CAAC;AAElG;;;;GAIG;AACH,qBAAa,OAAO;IAWhB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,YAAY;IAXtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAmB;IAE3C;;;;;OAKG;gBAEO,QAAQ,EAAE,gBAAgB,EAC1B,YAAY,EAAE,YAAY,EAClC,gBAAgB,CAAC,EAAE,gBAAgB;IAOrC;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAShB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAoBxB;;;;;;;OAOG;IACG,GAAG,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;CAsIrD"}
|
package/dist/engine.js
CHANGED
|
@@ -101,7 +101,9 @@ export class IndeRun {
|
|
|
101
101
|
taskKind: request.task.kind,
|
|
102
102
|
explanation: routeSelection.explanation,
|
|
103
103
|
constraints: request.constraints ?? null,
|
|
104
|
-
preferences: request.preferences ?? null
|
|
104
|
+
preferences: request.preferences ?? null,
|
|
105
|
+
plannerSource: routeSelection.plannerSource,
|
|
106
|
+
plannerUnavailableReason: routeSelection.plannerUnavailableReason ?? null
|
|
105
107
|
}
|
|
106
108
|
});
|
|
107
109
|
// 3. Execute the run task using the planned provider chain
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { type ConnectivityService, type DeviceConstraintsService, type SecureSto
|
|
|
2
2
|
export { type ProviderDescriptor, type ProviderDynamicCapabilities, type RunContext, type ProviderAdapter } from "./provider.js";
|
|
3
3
|
export { ProviderRegistry } from "./registry.js";
|
|
4
4
|
export { type RouteSelection, Router } from "./router.js";
|
|
5
|
-
export { type RoutePlanner, type SharedPlannerInput, type SharedPlannerRoutePlan, WasmRoutePlanner } from "./route-planner.js";
|
|
5
|
+
export { type RoutePlanner, type PlannerOutcome, type WasmUnavailableReason, type SharedPlannerInput, type SharedPlannerRoutePlan, WasmRoutePlanner } from "./route-planner.js";
|
|
6
6
|
export { type IndeRunExceptionParams, IndeRunException, createCapabilityMismatch, createOffline, createAuthError, createRateLimited, createTimeout, createUnavailable, createInternal, toIndeRunException } from "./errors.js";
|
|
7
7
|
export { IndeRun } from "./engine.js";
|
|
8
8
|
export { type TelemetryEventType, type TelemetryEvent, type TelemetryService, NoOpTelemetryService } from "./telemetry.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,KAAK,sBAAsB,EAC3B,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,iBAAi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B,EACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,gCAAgC,EACrC,KAAK,sBAAsB,EAC5B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/route-planner.d.ts
CHANGED
|
@@ -12,11 +12,28 @@ export interface SharedPlannerModule {
|
|
|
12
12
|
planRouteJson: (inputJson: string) => string | Promise<string>;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* Coarse, privacy-safe reason the WASM planner produced no route plan. Used
|
|
16
|
+
* only for observability (telemetry/logging) — callers still fall back to
|
|
17
|
+
* local selection regardless of which reason fired.
|
|
18
|
+
*/
|
|
19
|
+
export type WasmUnavailableReason = "import_failed" | "invalid_module_shape" | "init_failed" | "plan_failed";
|
|
20
|
+
/**
|
|
21
|
+
* Result of a {@link RoutePlanner} attempt. `routePlan` is `null` when the
|
|
22
|
+
* planner could not produce a plan, in which case `source` is `"unavailable"`
|
|
23
|
+
* and `unavailableReason` narrows down why, so callers can log/emit telemetry
|
|
24
|
+
* instead of silently swapping planners.
|
|
25
|
+
*/
|
|
26
|
+
export interface PlannerOutcome {
|
|
27
|
+
routePlan: SharedPlannerRoutePlan | null;
|
|
28
|
+
source: "wasm" | "unavailable";
|
|
29
|
+
unavailableReason?: WasmUnavailableReason;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Strategy that turns planner input into a deterministic route plan, or an
|
|
33
|
+
* "unavailable" outcome (callers then fall back to local selection).
|
|
17
34
|
*/
|
|
18
35
|
export interface RoutePlanner {
|
|
19
|
-
planRoute(input: SharedPlannerInput): Promise<
|
|
36
|
+
planRoute(input: SharedPlannerInput): Promise<PlannerOutcome>;
|
|
20
37
|
}
|
|
21
38
|
/**
|
|
22
39
|
* A provider paired with the descriptor/capability projection the shared route
|
|
@@ -29,16 +46,22 @@ export interface ProviderRuntimeSnapshot {
|
|
|
29
46
|
}
|
|
30
47
|
/**
|
|
31
48
|
* {@link RoutePlanner} backed by the Rust route core compiled to WASM. The
|
|
32
|
-
* module is
|
|
33
|
-
*
|
|
49
|
+
* module specifier is a static literal (not configurable) so bundlers such as
|
|
50
|
+
* Vite/webpack/Rollup can statically resolve and chunk it — a variable
|
|
51
|
+
* specifier defeats bundler analysis and silently never loads in the browser
|
|
52
|
+
* (see issue #109). The module is imported lazily and memoized; if it cannot
|
|
53
|
+
* be loaded, `planRoute` resolves an "unavailable" outcome so the engine can
|
|
54
|
+
* fall back to local selection, and logs once via `console.warn` so the
|
|
55
|
+
* degradation is never fully silent.
|
|
34
56
|
*/
|
|
35
57
|
export declare class WasmRoutePlanner implements RoutePlanner {
|
|
36
|
-
private readonly moduleSpecifier;
|
|
37
58
|
private modulePromise?;
|
|
38
|
-
|
|
39
|
-
|
|
59
|
+
private loadFailureReason?;
|
|
60
|
+
private hasWarned;
|
|
61
|
+
planRoute(input: SharedPlannerInput): Promise<PlannerOutcome>;
|
|
40
62
|
private loadModule;
|
|
41
63
|
private importModule;
|
|
64
|
+
private warnOnce;
|
|
42
65
|
}
|
|
43
66
|
/**
|
|
44
67
|
* Describes each provider and evaluates its dynamic capabilities against the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-planner.d.ts","sourceRoot":"","sources":["../src/route-planner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,IAAI,sBAAsB,EACnC,iBAAiB,IAAI,kBAAkB,EACvC,WAAW,EACZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,YAA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AE,qBAAqB,CAAC;CAC3C;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC/D;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,kBAAkB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IAClE,YAAY,EAAE,kBAAkB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,CAAC;CACvE;AAED;;;;;;;;;GASG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IACnD,OAAO,CAAC,aAAa,CAAC,CAAsC;IAC5D,OAAO,CAAC,iBAAiB,CAAC,CAAwB;IAClD,OAAO,CAAC,SAAS,CAAS;IAEpB,SAAS,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;YAkBrD,UAAU;YAOV,YAAY;IA6B1B,OAAO,CAAC,QAAQ;CAUjB;AAED;;;GAGG;AACH,wBAAsB,+BAA+B,CACnD,iBAAiB,EAAE,eAAe,EAAE,EACpC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAepC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,uBAAuB,EAAE,EACpC,aAAa,EAAE,OAAO,GACrB,kBAAkB,CAsBpB"}
|
package/dist/route-planner.js
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
const DEFAULT_WASM_SPECIFIER = "@independo/inderun-route-core-wasm";
|
|
2
1
|
/**
|
|
3
2
|
* {@link RoutePlanner} backed by the Rust route core compiled to WASM. The
|
|
4
|
-
* module is
|
|
5
|
-
*
|
|
3
|
+
* module specifier is a static literal (not configurable) so bundlers such as
|
|
4
|
+
* Vite/webpack/Rollup can statically resolve and chunk it — a variable
|
|
5
|
+
* specifier defeats bundler analysis and silently never loads in the browser
|
|
6
|
+
* (see issue #109). The module is imported lazily and memoized; if it cannot
|
|
7
|
+
* be loaded, `planRoute` resolves an "unavailable" outcome so the engine can
|
|
8
|
+
* fall back to local selection, and logs once via `console.warn` so the
|
|
9
|
+
* degradation is never fully silent.
|
|
6
10
|
*/
|
|
7
11
|
export class WasmRoutePlanner {
|
|
8
|
-
moduleSpecifier;
|
|
9
12
|
modulePromise;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
+
loadFailureReason;
|
|
14
|
+
hasWarned = false;
|
|
13
15
|
async planRoute(input) {
|
|
14
16
|
const module = await this.loadModule();
|
|
15
17
|
if (!module) {
|
|
16
|
-
|
|
18
|
+
const unavailableReason = this.loadFailureReason ?? "import_failed";
|
|
19
|
+
this.warnOnce(unavailableReason);
|
|
20
|
+
return { routePlan: null, source: "unavailable", unavailableReason };
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const json = JSON.stringify(input);
|
|
24
|
+
const result = await module.planRouteJson(json);
|
|
25
|
+
return { routePlan: JSON.parse(result), source: "wasm" };
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
this.warnOnce("plan_failed", error);
|
|
29
|
+
return { routePlan: null, source: "unavailable", unavailableReason: "plan_failed" };
|
|
17
30
|
}
|
|
18
|
-
const json = JSON.stringify(input);
|
|
19
|
-
const result = await module.planRouteJson(json);
|
|
20
|
-
return JSON.parse(result);
|
|
21
31
|
}
|
|
22
32
|
async loadModule() {
|
|
23
33
|
if (!this.modulePromise) {
|
|
@@ -26,19 +36,38 @@ export class WasmRoutePlanner {
|
|
|
26
36
|
return this.modulePromise;
|
|
27
37
|
}
|
|
28
38
|
async importModule() {
|
|
39
|
+
let mod;
|
|
29
40
|
try {
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
mod = (await import("@independo/inderun-route-core-wasm"));
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
this.loadFailureReason = "import_failed";
|
|
45
|
+
this.warnOnce("import_failed", error);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
if (typeof mod.planRouteJson !== "function") {
|
|
49
|
+
this.loadFailureReason = "invalid_module_shape";
|
|
50
|
+
this.warnOnce("invalid_module_shape");
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (mod.initSharedCore) {
|
|
54
|
+
try {
|
|
32
55
|
await mod.initSharedCore();
|
|
33
56
|
}
|
|
34
|
-
|
|
57
|
+
catch (error) {
|
|
58
|
+
this.loadFailureReason = "init_failed";
|
|
59
|
+
this.warnOnce("init_failed", error);
|
|
35
60
|
return null;
|
|
36
61
|
}
|
|
37
|
-
return mod;
|
|
38
62
|
}
|
|
39
|
-
|
|
40
|
-
|
|
63
|
+
return mod;
|
|
64
|
+
}
|
|
65
|
+
warnOnce(reason, error) {
|
|
66
|
+
if (this.hasWarned) {
|
|
67
|
+
return;
|
|
41
68
|
}
|
|
69
|
+
this.hasWarned = true;
|
|
70
|
+
console.warn(`[IndeRun] WASM route planner unavailable (${reason}); falling back to local route selection.`, error);
|
|
42
71
|
}
|
|
43
72
|
}
|
|
44
73
|
/**
|
package/dist/router.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { TaskRequest } from "@independo/inderun-contracts";
|
|
|
2
2
|
import type { HostServices } from "./host.js";
|
|
3
3
|
import type { ProviderAdapter } from "./provider.js";
|
|
4
4
|
import type { ProviderRegistry } from "./registry.js";
|
|
5
|
-
import { type RoutePlanner, type SharedPlannerRoutePlan } from "./route-planner.js";
|
|
5
|
+
import { type RoutePlanner, type SharedPlannerRoutePlan, type WasmUnavailableReason } from "./route-planner.js";
|
|
6
6
|
/**
|
|
7
7
|
* Output structure from the Router containing the chosen provider and a route selection description.
|
|
8
8
|
*/
|
|
@@ -23,6 +23,16 @@ export interface RouteSelection {
|
|
|
23
23
|
* Explanation detailing the selection decision. Useful for debugging and telemetry.
|
|
24
24
|
*/
|
|
25
25
|
explanation: string;
|
|
26
|
+
/**
|
|
27
|
+
* Which planner produced `routePlan`: the shared Rust/WASM core, or the
|
|
28
|
+
* local TypeScript fallback used when the WASM planner is unavailable.
|
|
29
|
+
*/
|
|
30
|
+
plannerSource: "wasm" | "fallback";
|
|
31
|
+
/**
|
|
32
|
+
* Set when `plannerSource` is `"fallback"` because the WASM planner failed;
|
|
33
|
+
* `undefined` when the fallback was not caused by a planner failure.
|
|
34
|
+
*/
|
|
35
|
+
plannerUnavailableReason?: WasmUnavailableReason;
|
|
26
36
|
}
|
|
27
37
|
/**
|
|
28
38
|
* Routing engine module. Filters registered providers against task types, request constraints,
|
package/dist/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAOtD,OAAO,EAIL,KAAK,YAAY,EAEjB,KAAK,sBAAsB,
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAOtD,OAAO,EAIL,KAAK,YAAY,EAEjB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAE3B,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,QAAQ,EAAE,eAAe,CAAC;IAC1B;;OAEG;IACH,iBAAiB,EAAE,eAAe,EAAE,CAAC;IACrC;;OAEG;IACH,SAAS,EAAE,sBAAsB,CAAC;IAClC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,aAAa,EAAE,MAAM,GAAG,UAAU,CAAC;IACnC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,qBAAqB,CAAC;CAClD;AAED;;;;GAIG;AACH,qBAAa,MAAM;IAEf,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,OAAO;gBADP,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,GAAE,YAAqC;IAGxD;;;;;;;;;OASG;IACG,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;IAc5F,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,2BAA2B;IA2BnC,OAAO,CAAC,kBAAkB;IA0F1B,OAAO,CAAC,2BAA2B;IAiCnC,OAAO,CAAC,gBAAgB;CAYzB"}
|
package/dist/router.js
CHANGED
|
@@ -26,26 +26,26 @@ export class Router {
|
|
|
26
26
|
const online = await hostServices.connectivity.isOnline();
|
|
27
27
|
const snapshots = await collectProviderRuntimeSnapshots(this.registry.list(), hostServices);
|
|
28
28
|
const planInput = buildSharedPlannerInput(request, snapshots, online);
|
|
29
|
-
const
|
|
30
|
-
if (routePlan) {
|
|
31
|
-
return this.selectFromSharedPlan(snapshots, routePlan);
|
|
29
|
+
const outcome = await this.planner.planRoute(planInput);
|
|
30
|
+
if (outcome.routePlan) {
|
|
31
|
+
return this.selectFromSharedPlan(snapshots, outcome.routePlan);
|
|
32
32
|
}
|
|
33
|
-
return this.selectFallbackRoute(request, snapshots, online);
|
|
33
|
+
return this.selectFallbackRoute(request, snapshots, online, outcome.unavailableReason);
|
|
34
34
|
}
|
|
35
35
|
selectFromSharedPlan(snapshots, routePlan) {
|
|
36
36
|
if (!routePlan.selectedProviderId) {
|
|
37
37
|
throw this.routePlanFailure(routePlan);
|
|
38
38
|
}
|
|
39
|
-
return this.buildSelectionFromRoutePlan(snapshots, routePlan);
|
|
39
|
+
return this.buildSelectionFromRoutePlan(snapshots, routePlan, "wasm");
|
|
40
40
|
}
|
|
41
|
-
selectFallbackRoute(request, snapshots, online) {
|
|
41
|
+
selectFallbackRoute(request, snapshots, online, plannerUnavailableReason) {
|
|
42
42
|
const plan = this.createFallbackPlan(request, snapshots, online);
|
|
43
43
|
if (!plan.selectedProviderId) {
|
|
44
44
|
throw this.routePlanFailure(plan);
|
|
45
45
|
}
|
|
46
|
-
return this.buildSelectionFromRoutePlan(snapshots, plan);
|
|
46
|
+
return this.buildSelectionFromRoutePlan(snapshots, plan, "fallback", plannerUnavailableReason);
|
|
47
47
|
}
|
|
48
|
-
buildSelectionFromRoutePlan(snapshots, routePlan) {
|
|
48
|
+
buildSelectionFromRoutePlan(snapshots, routePlan, plannerSource, plannerUnavailableReason) {
|
|
49
49
|
const orderedProviders = routePlan.candidates
|
|
50
50
|
.map((candidate) => snapshots.find((snapshot) => snapshot.descriptor.id === candidate.providerId))
|
|
51
51
|
.filter((snapshot) => snapshot !== undefined);
|
|
@@ -57,7 +57,9 @@ export class Router {
|
|
|
57
57
|
provider: selected.provider,
|
|
58
58
|
fallbackProviders: orderedProviders.slice(1).map((snapshot) => snapshot.provider),
|
|
59
59
|
routePlan,
|
|
60
|
-
explanation: routePlan.explanation.summary
|
|
60
|
+
explanation: routePlan.explanation.summary,
|
|
61
|
+
plannerSource,
|
|
62
|
+
...(plannerUnavailableReason ? { plannerUnavailableReason } : {})
|
|
61
63
|
};
|
|
62
64
|
}
|
|
63
65
|
createFallbackPlan(request, snapshots, online) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@independo/inderun-web",
|
|
3
|
-
"version": "0.2.0-dev.
|
|
3
|
+
"version": "0.2.0-dev.4",
|
|
4
4
|
"description": "TypeScript/Web SDK for IndeRun.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"README.md"
|
|
52
52
|
],
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@independo/inderun-contracts": "^0.2.0-dev.
|
|
55
|
-
"@independo/inderun-route-core-wasm": "^0.2.0-dev.
|
|
54
|
+
"@independo/inderun-contracts": "^0.2.0-dev.4",
|
|
55
|
+
"@independo/inderun-route-core-wasm": "^0.2.0-dev.4"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@huggingface/transformers": "^4.0.0"
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/node": "^26.1.1",
|
|
67
67
|
"typescript": "^6.0.3",
|
|
68
|
-
"vitest": "^
|
|
68
|
+
"vitest": "^4.1.10"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "tsc -p tsconfig.json",
|