@independo/inderun-web 0.3.3 → 0.4.0-rc.2

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.
Files changed (52) hide show
  1. package/README.md +46 -9
  2. package/dist/core/engine.d.ts +26 -2
  3. package/dist/core/engine.d.ts.map +1 -1
  4. package/dist/core/engine.js +78 -34
  5. package/dist/core/errors.d.ts +13 -1
  6. package/dist/core/errors.d.ts.map +1 -1
  7. package/dist/core/errors.js +32 -0
  8. package/dist/core/model-profiles.d.ts +34 -0
  9. package/dist/core/model-profiles.d.ts.map +1 -0
  10. package/dist/core/model-profiles.js +49 -0
  11. package/dist/core/provenance.d.ts +32 -0
  12. package/dist/core/provenance.d.ts.map +1 -0
  13. package/dist/core/provenance.js +71 -0
  14. package/dist/core/provider.d.ts +13 -0
  15. package/dist/core/provider.d.ts.map +1 -1
  16. package/dist/core/route-planner.d.ts +1 -1
  17. package/dist/core/route-planner.d.ts.map +1 -1
  18. package/dist/core/route-planner.js +2 -1
  19. package/dist/core/router.d.ts +4 -3
  20. package/dist/core/router.d.ts.map +1 -1
  21. package/dist/core/router.js +4 -3
  22. package/dist/facade/text.d.ts +123 -0
  23. package/dist/facade/text.d.ts.map +1 -0
  24. package/dist/facade/text.js +234 -0
  25. package/dist/index.d.ts +36 -45
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +28 -38
  28. package/dist/provider.d.ts +34 -0
  29. package/dist/provider.d.ts.map +1 -0
  30. package/dist/provider.js +33 -0
  31. package/dist/providers/onnx/provider.d.ts.map +1 -1
  32. package/dist/providers/onnx/provider.js +1 -0
  33. package/dist/providers/openai/provider.d.ts +41 -11
  34. package/dist/providers/openai/provider.d.ts.map +1 -1
  35. package/dist/providers/openai/provider.js +168 -58
  36. package/dist/web-sdk.d.ts +21 -3
  37. package/dist/web-sdk.d.ts.map +1 -1
  38. package/dist/web-sdk.js +23 -6
  39. package/package.json +7 -3
  40. package/src/core/engine.ts +114 -35
  41. package/src/core/errors.ts +35 -1
  42. package/src/core/model-profiles.ts +70 -0
  43. package/src/core/provenance.ts +90 -0
  44. package/src/core/provider.ts +13 -0
  45. package/src/core/route-planner.ts +3 -1
  46. package/src/core/router.ts +12 -3
  47. package/src/facade/text.ts +349 -0
  48. package/src/index.ts +49 -95
  49. package/src/provider.ts +77 -0
  50. package/src/providers/onnx/provider.ts +1 -0
  51. package/src/providers/openai/provider.ts +232 -68
  52. package/src/web-sdk.ts +47 -10
package/dist/index.d.ts CHANGED
@@ -1,47 +1,42 @@
1
1
  /**
2
- * Unified entry point for the IndeRun Web SDK (`@independo/inderun-web`).
2
+ * Application entry point for the IndeRun Web SDK (`@independo/inderun-web`).
3
3
  *
4
- * Everything a browser app needs to run and stream tasks is exported from here:
5
- * the engine, the routing and provider seams, host services, error and telemetry
6
- * types, and the contract types the SDK's own signatures use. Provider adapters
7
- * are the deliberate exception — each ships from its own subpath
8
- * (`/openai`, `/onnx`, `/system-model`) so this surface stays provider-agnostic.
9
- */
10
- /**
11
- * Host services: the platform capabilities the engine reads and calls through,
12
- * and the seams an embedder overrides to supply its own (custom transport,
13
- * credential storage, clock).
4
+ * It leads with the primary text API (`generateText` / `streamText`) and the
5
+ * factory that builds a ready engine, then carries the advanced task API
6
+ * (`run()` / `stream()` / `checkCapabilities()`) and the contract, error and
7
+ * telemetry types those signatures use. See `docs/architecture/api-layering.md`.
8
+ *
9
+ * Two kinds of export live elsewhere on purpose:
10
+ * - provider-authoring and host-integration APIs ship from
11
+ * `@independo/inderun-web/provider`;
12
+ * - provider adapters ship from their own subpaths (`/openai`, `/onnx`,
13
+ * `/system-model`), so this surface stays provider-agnostic.
14
+ *
15
+ * The engine's internals (router, route planner bindings, Event Gate) are not
16
+ * exported at all.
14
17
  */
15
- export { type AbortSignalLike, type ConnectivityService, type DeviceConstraintsService, type SecureStorageService, type ClockService, type HttpClientService, type HttpRequest, type HttpResponse, type HttpStreamResponse, type HttpStreamingClientService, type HostServices, type ThermalState } from "./core/host.js";
16
18
  /**
17
- * The provider contract. Implement `ProviderAdapter` for a Mode 1 backend and add
18
- * a `stream` for Mode 2; the descriptor and dynamic capability check are what the
19
- * router plans against.
19
+ * The primary text API: one canonical request per call, over any `IndeRunApi`.
20
20
  */
21
- export { type ProviderDescriptor, type ProviderDynamicCapabilities, type ProviderCapabilitySnapshot, type RunContext, type ProviderAdapter, type ProviderStreamContext, type ProviderStreamEvent, type StreamRun } from "./core/provider.js";
21
+ export { generateText, streamText, toTaskRequest, TextStreamRetractedError, type GeneratedText, type StreamedText, type TextExecutionOptions, type TextGenerationOptions, type TextStream } from "./facade/text.js";
22
22
  /**
23
- * Per-run gatekeeper for a Mode 2 stream: assigns the sequence numbers callers
24
- * order by, and enforces that exactly one terminal outcome is produced with
25
- * nothing admitted after it. Exported for embedders driving a stream themselves.
23
+ * The recommended way in: builds host services, registers the providers named in
24
+ * the options, and returns a ready engine.
26
25
  */
27
- export { EventGate } from "./core/event-gate.js";
28
- /** Holds the provider adapters a given engine instance can route to. */
29
- export { ProviderRegistry } from "./core/registry.js";
26
+ export { createIndeRunWeb, type CreateIndeRunWebOptions, type OpenAIFactoryOptions } from "./web-sdk.js";
30
27
  /**
31
- * Route selection. `Router` turns a request plus a host capability snapshot into
32
- * a provider chain; `WasmRoutePlanner` is the shared Rust planner behind it, and
33
- * the only planner the Web SDK has — there is no JavaScript fallback.
28
+ * Model profiles: application-defined names for ordered sets of targets that a
29
+ * request can route within. `"auto"` is built in.
34
30
  */
35
- export { type RouteSelection, Router } from "./core/router.js";
36
- export { type RoutePlanner, type PlannerOutcome, type WasmUnavailableReason, type SharedPlannerInput, type SharedPlannerRoutePlan, WasmRoutePlanner } from "./core/route-planner.js";
31
+ export { AUTO_MODEL_PROFILE, type ModelProfiles } from "./core/model-profiles.js";
37
32
  /**
38
- * The normalized error taxonomy. Every failure the SDK surfaces is an
39
- * `IndeRunException` in one of these classes, whatever the provider raised.
33
+ * The advanced task API. `IndeRun` implements `IndeRunApi`; constructing one by
34
+ * hand takes a `ProviderRegistry` and `HostServices` from
35
+ * `@independo/inderun-web/provider`.
40
36
  */
41
- export { type IndeRunExceptionParams, IndeRunException, createCapabilityMismatch, createOffline, createAuthError, createRateLimited, createTimeout, createUnavailable, createInternal, toIndeRunException } from "./core/errors.js";
42
- /** The engine itself, and the app-facing API surface it implements. */
43
- export { IndeRun, type StreamHandleResult } from "./core/engine.js";
37
+ export { IndeRun, type IndeRunOptions, type StreamHandleResult } from "./core/engine.js";
44
38
  export type { IndeRunApi } from "./core/generated/inderun-api.js";
39
+ export type { ProviderCapabilitySnapshot, StreamRun } from "./core/provider.js";
45
40
  /**
46
41
  * The contract types this SDK's own signatures take and return.
47
42
  *
@@ -51,26 +46,22 @@ export type { IndeRunApi } from "./core/generated/inderun-api.js";
51
46
  * This is the npm counterpart of Gradle `api(...)` on Android and `@_exported
52
47
  * import` on Swift — see
53
48
  * {@link https://github.com/independo-gmbh/inderun/issues/189 | #189}. The
54
- * host-service and telemetry blocks in this file re-export their halves of the
55
- * same contract surface for the same reason.
49
+ * telemetry block below and the host-service block of the `/provider` entry
50
+ * point re-export their halves of the same contract surface for the same reason.
56
51
  *
57
52
  * Depend on `@independo/inderun-contracts` directly only for what is not
58
53
  * re-exported here: the JSON Schemas and the `get*ValidationIssues` validators.
59
54
  */
60
- export type { IndeRunError, IndeRunErrorClass, StreamEvent, StreamRunHandle, StreamTerminalOutcome, TaskRequest, TaskResult } from "@independo/inderun-contracts";
55
+ export type { ExecutionProvenance, IndeRunError, IndeRunErrorClass, StreamEvent, StreamRunHandle, StreamTerminalOutcome, TaskRequest, TaskResult } from "@independo/inderun-contracts";
56
+ /**
57
+ * The normalized error taxonomy. Every failure the SDK surfaces is an
58
+ * `IndeRunException` in one of these classes, whatever the provider raised.
59
+ * Provider authors create them with the `create*` helpers from `/provider`.
60
+ */
61
+ export { IndeRunException, toIndeRunException } from "./core/errors.js";
61
62
  /**
62
63
  * Telemetry. Pass a `TelemetryService` to observe routing decisions and attempt
63
64
  * outcomes; the engine defaults to `NoOpTelemetryService`.
64
65
  */
65
66
  export { type TelemetryEventType, type TelemetryEvent, type TelemetryService, NoOpTelemetryService } from "./core/telemetry.js";
66
- /**
67
- * The browser implementations of the host services above, and the factory that
68
- * assembles them. Use these directly only when constructing `IndeRun` by hand.
69
- */
70
- export { BrowserConnectivityService, FetchHttpClient, FetchStreamingHttpClient, SystemClockService, createBrowserHostServices, type CreateBrowserHostServicesOptions, type FetchHttpClientOptions } from "./core/browser-host.js";
71
- /**
72
- * The recommended way in: builds host services, registers the providers named in
73
- * the options, and returns a ready engine.
74
- */
75
- export { createIndeRunWeb, type CreateIndeRunWebOptions } from "./web-sdk.js";
76
67
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;GAIG;AACH,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAExB;;;;GAIG;AACH,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACf,MAAM,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,wEAAwE;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;GAIG;AACH,OAAO,EAAE,KAAK,cAAc,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,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAE1B;;;GAGG;AACH,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AAEtB;;;GAGG;AACH,OAAO,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAElF;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACzF,YAAY,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,YAAY,EAAE,0BAA0B,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEhF;;;;;;;;;;;;;;GAcG;AACH,YAAY,EACV,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,UAAU,EACX,MAAM,8BAA8B,CAAC;AAEtC;;;;GAIG;AACH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAExE;;;GAGG;AACH,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,oBAAoB,EACrB,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -1,58 +1,48 @@
1
1
  /**
2
- * Unified entry point for the IndeRun Web SDK (`@independo/inderun-web`).
2
+ * Application entry point for the IndeRun Web SDK (`@independo/inderun-web`).
3
3
  *
4
- * Everything a browser app needs to run and stream tasks is exported from here:
5
- * the engine, the routing and provider seams, host services, error and telemetry
6
- * types, and the contract types the SDK's own signatures use. Provider adapters
7
- * are the deliberate exception — each ships from its own subpath
8
- * (`/openai`, `/onnx`, `/system-model`) so this surface stays provider-agnostic.
4
+ * It leads with the primary text API (`generateText` / `streamText`) and the
5
+ * factory that builds a ready engine, then carries the advanced task API
6
+ * (`run()` / `stream()` / `checkCapabilities()`) and the contract, error and
7
+ * telemetry types those signatures use. See `docs/architecture/api-layering.md`.
8
+ *
9
+ * Two kinds of export live elsewhere on purpose:
10
+ * - provider-authoring and host-integration APIs ship from
11
+ * `@independo/inderun-web/provider`;
12
+ * - provider adapters ship from their own subpaths (`/openai`, `/onnx`,
13
+ * `/system-model`), so this surface stays provider-agnostic.
14
+ *
15
+ * The engine's internals (router, route planner bindings, Event Gate) are not
16
+ * exported at all.
9
17
  */
10
18
  /**
11
- * Host services: the platform capabilities the engine reads and calls through,
12
- * and the seams an embedder overrides to supply its own (custom transport,
13
- * credential storage, clock).
19
+ * The primary text API: one canonical request per call, over any `IndeRunApi`.
14
20
  */
15
- export {} from "./core/host.js";
21
+ export { generateText, streamText, toTaskRequest, TextStreamRetractedError } from "./facade/text.js";
16
22
  /**
17
- * The provider contract. Implement `ProviderAdapter` for a Mode 1 backend and add
18
- * a `stream` for Mode 2; the descriptor and dynamic capability check are what the
19
- * router plans against.
23
+ * The recommended way in: builds host services, registers the providers named in
24
+ * the options, and returns a ready engine.
20
25
  */
21
- export {} from "./core/provider.js";
26
+ export { createIndeRunWeb } from "./web-sdk.js";
22
27
  /**
23
- * Per-run gatekeeper for a Mode 2 stream: assigns the sequence numbers callers
24
- * order by, and enforces that exactly one terminal outcome is produced with
25
- * nothing admitted after it. Exported for embedders driving a stream themselves.
28
+ * Model profiles: application-defined names for ordered sets of targets that a
29
+ * request can route within. `"auto"` is built in.
26
30
  */
27
- export { EventGate } from "./core/event-gate.js";
28
- /** Holds the provider adapters a given engine instance can route to. */
29
- export { ProviderRegistry } from "./core/registry.js";
31
+ export { AUTO_MODEL_PROFILE } from "./core/model-profiles.js";
30
32
  /**
31
- * Route selection. `Router` turns a request plus a host capability snapshot into
32
- * a provider chain; `WasmRoutePlanner` is the shared Rust planner behind it, and
33
- * the only planner the Web SDK has — there is no JavaScript fallback.
33
+ * The advanced task API. `IndeRun` implements `IndeRunApi`; constructing one by
34
+ * hand takes a `ProviderRegistry` and `HostServices` from
35
+ * `@independo/inderun-web/provider`.
34
36
  */
35
- export { Router } from "./core/router.js";
36
- export { WasmRoutePlanner } from "./core/route-planner.js";
37
+ export { IndeRun } from "./core/engine.js";
37
38
  /**
38
39
  * The normalized error taxonomy. Every failure the SDK surfaces is an
39
40
  * `IndeRunException` in one of these classes, whatever the provider raised.
41
+ * Provider authors create them with the `create*` helpers from `/provider`.
40
42
  */
41
- export { IndeRunException, createCapabilityMismatch, createOffline, createAuthError, createRateLimited, createTimeout, createUnavailable, createInternal, toIndeRunException } from "./core/errors.js";
42
- /** The engine itself, and the app-facing API surface it implements. */
43
- export { IndeRun } from "./core/engine.js";
43
+ export { IndeRunException, toIndeRunException } from "./core/errors.js";
44
44
  /**
45
45
  * Telemetry. Pass a `TelemetryService` to observe routing decisions and attempt
46
46
  * outcomes; the engine defaults to `NoOpTelemetryService`.
47
47
  */
48
48
  export { NoOpTelemetryService } from "./core/telemetry.js";
49
- /**
50
- * The browser implementations of the host services above, and the factory that
51
- * assembles them. Use these directly only when constructing `IndeRun` by hand.
52
- */
53
- export { BrowserConnectivityService, FetchHttpClient, FetchStreamingHttpClient, SystemClockService, createBrowserHostServices } from "./core/browser-host.js";
54
- /**
55
- * The recommended way in: builds host services, registers the providers named in
56
- * the options, and returns a ready engine.
57
- */
58
- export { createIndeRunWeb } from "./web-sdk.js";
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Provider-authoring and host-integration entry point
3
+ * (`@independo/inderun-web/provider`).
4
+ *
5
+ * For code that extends the engine rather than calls it: custom provider
6
+ * adapters, custom host services (transport, credential storage, clock), and
7
+ * assembling an `IndeRun` by hand from a `ProviderRegistry`. Applications that
8
+ * only call `generateText` / `streamText` or `run()` / `stream()` need nothing
9
+ * from here. Changes to this surface are called out in release notes.
10
+ */
11
+ /**
12
+ * Host services: the platform capabilities the engine reads and calls through,
13
+ * and the seams an embedder overrides to supply its own.
14
+ */
15
+ export { type AbortSignalLike, type ConnectivityService, type DeviceConstraintsService, type SecureStorageService, type ClockService, type HttpClientService, type HttpRequest, type HttpResponse, type HttpStreamResponse, type HttpStreamingClientService, type HostServices, type ThermalState } from "./core/host.js";
16
+ /**
17
+ * The browser implementations of the host services above, and the factory that
18
+ * assembles them. Use these directly only when constructing `IndeRun` by hand.
19
+ */
20
+ export { BrowserConnectivityService, FetchHttpClient, FetchStreamingHttpClient, SystemClockService, createBrowserHostServices, type CreateBrowserHostServicesOptions, type FetchHttpClientOptions } from "./core/browser-host.js";
21
+ /**
22
+ * The provider contract. Implement `ProviderAdapter` for a Mode 1 backend and add
23
+ * a `stream` for Mode 2; the descriptor and dynamic capability check are what the
24
+ * router plans against.
25
+ */
26
+ export { type ProviderDescriptor, type ProviderDynamicCapabilities, type ProviderCapabilitySnapshot, type RunContext, type ProviderAdapter, type ProviderStreamContext, type ProviderStreamEvent, type StreamRun } from "./core/provider.js";
27
+ /** Holds the provider adapters a given engine instance can route to. */
28
+ export { ProviderRegistry } from "./core/registry.js";
29
+ /**
30
+ * Constructors for the normalized error taxonomy. A provider maps every failure
31
+ * onto one of these classes; the engine does the rest.
32
+ */
33
+ export { type IndeRunExceptionParams, createCapabilityMismatch, createOffline, createAuthError, createRateLimited, createTimeout, createUnavailable, createInternal } from "./core/errors.js";
34
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;GAGG;AACH,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,wBAAwB,EACxB,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,gCAAgC,EACrC,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC;;;;GAIG;AACH,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACf,MAAM,oBAAoB,CAAC;AAE5B,wEAAwE;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;GAGG;AACH,OAAO,EACL,KAAK,sBAAsB,EAC3B,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACf,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Provider-authoring and host-integration entry point
3
+ * (`@independo/inderun-web/provider`).
4
+ *
5
+ * For code that extends the engine rather than calls it: custom provider
6
+ * adapters, custom host services (transport, credential storage, clock), and
7
+ * assembling an `IndeRun` by hand from a `ProviderRegistry`. Applications that
8
+ * only call `generateText` / `streamText` or `run()` / `stream()` need nothing
9
+ * from here. Changes to this surface are called out in release notes.
10
+ */
11
+ /**
12
+ * Host services: the platform capabilities the engine reads and calls through,
13
+ * and the seams an embedder overrides to supply its own.
14
+ */
15
+ export {} from "./core/host.js";
16
+ /**
17
+ * The browser implementations of the host services above, and the factory that
18
+ * assembles them. Use these directly only when constructing `IndeRun` by hand.
19
+ */
20
+ export { BrowserConnectivityService, FetchHttpClient, FetchStreamingHttpClient, SystemClockService, createBrowserHostServices } from "./core/browser-host.js";
21
+ /**
22
+ * The provider contract. Implement `ProviderAdapter` for a Mode 1 backend and add
23
+ * a `stream` for Mode 2; the descriptor and dynamic capability check are what the
24
+ * router plans against.
25
+ */
26
+ export {} from "./core/provider.js";
27
+ /** Holds the provider adapters a given engine instance can route to. */
28
+ export { ProviderRegistry } from "./core/registry.js";
29
+ /**
30
+ * Constructors for the normalized error taxonomy. A provider maps every failure
31
+ * onto one of these classes; the engine does the rest.
32
+ */
33
+ export { createCapabilityMismatch, createOffline, createAuthError, createRateLimited, createTimeout, createUnavailable, createInternal } from "./core/errors.js";
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/providers/onnx/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,8BAA8B,CAAC;AAStC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAIL,KAAK,yBAAyB,EAC/B,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,2BAA2B,EAC3B,UAAU,EACX,MAAM,wBAAwB,CAAC;AAEhC,iFAAiF;AACjF,eAAO,MAAM,4BAA4B,yBAAyB,CAAC;AAKnE;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,EAAE,SAAS,eAAe,EAKtE,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,yBAAyB,CAAC;IACpC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,qBAAa,sBAAuB,YAAW,eAAe;IAShD,OAAO,CAAC,QAAQ,CAAC,OAAO;IARpC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAA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ARpC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;IAEpD;;;OAGG;gBAC0B,OAAO,EAAE,mBAAmB;IAMzD;;OAEG;IACH,QAAQ,IAAI,kBAAkB;IAuB9B;;;;;;;OAOG;IACG,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAoC7E;;;;;;OAMG;IACG,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAoEzE,OAAO,CAAC,eAAe;CA2BxB"}
@@ -49,6 +49,7 @@ export class OnnxRuntimeWebProvider {
49
49
  return {
50
50
  id: this.id,
51
51
  type: "local",
52
+ model: this.modelPackage.id,
52
53
  transport: "in_process",
53
54
  supports: {
54
55
  run: true,
@@ -101,7 +101,9 @@ export declare class OpenAIResponsesProvider implements ProviderAdapter {
101
101
  * - `response.completed` and `response.incomplete` become the terminal done,
102
102
  * with `finalText`, `usage`, and `finishReason` read off the embedded
103
103
  * response object by the same helpers Mode 1 uses — it has the same shape;
104
- * - `response.failed` and `error` become a terminal error;
104
+ * - `response.failed`, `response.error` and `error` become a terminal error,
105
+ * as does an untyped event carrying an `error` object (OpenRouter's
106
+ * documented mid-stream failure shape);
105
107
  * - every other event type is ignored, since the set is open and additive.
106
108
  *
107
109
  * @param request - Canonical IndeRun task request.
@@ -109,17 +111,31 @@ export declare class OpenAIResponsesProvider implements ProviderAdapter {
109
111
  */
110
112
  stream(request: TaskRequest, context: ProviderStreamContext): AsyncGenerator<ProviderStreamEvent>;
111
113
  /**
112
- * Maps a `response.failed` / `error` stream event onto the error taxonomy.
113
- * These arrive over an HTTP 200 body, so there is no status code to classify
114
- * from; OpenAI reports rate limiting and auth failures here with the same
115
- * `code` values it uses in unary error bodies.
114
+ * Maps a `response.failed` / `response.error` / `error` stream event onto the
115
+ * error taxonomy. These arrive over an HTTP 200 body, so there is no status
116
+ * code to classify from; the event's own `code` is classified instead.
116
117
  *
117
118
  * Two payload shapes exist and both are accepted: the standalone `error`
118
119
  * event carries `code`/`message` at its root, while `response.failed` nests
119
- * them under `response.error`. The root `type` is the event name rather than
120
- * an error type, so it is never read as one.
120
+ * them under `response.error` and some servers nest them under `error`. The
121
+ * root `type` is the event name rather than an error type, so it is never
122
+ * read as one. OpenRouter's typed classification comes from the embedded
123
+ * response (`response.failed`) or the error's metadata (untyped events).
121
124
  */
122
125
  private mapStreamError;
126
+ /**
127
+ * Classifies a failure reported in a body rather than by the HTTP status: a
128
+ * failed stream event or a 2xx run body whose status is `failed`. The most
129
+ * specific signal wins:
130
+ * 1. OpenRouter's typed `error_type`, classified by the HTTP status it
131
+ * documents for that type (see `openRouterErrorTypeStatus`);
132
+ * 2. an integer `code`, which is an HTTP status (OpenRouter's convention) and
133
+ * is classified exactly as `mapHttpError` classifies that status;
134
+ * 3. a string code, by OpenAI's names.
135
+ * Anything unrecognized is a transient `Unavailable`, since the server did
136
+ * accept the request.
137
+ */
138
+ private mapReportedError;
123
139
  /**
124
140
  * Resolves the request headers, including the bearer token behind
125
141
  * `authContextRef`. Shared by `run` and `stream`: the credential never travels
@@ -129,13 +145,27 @@ export declare class OpenAIResponsesProvider implements ProviderAdapter {
129
145
  private resolveHeaders;
130
146
  private createRequestBody;
131
147
  /**
132
- * Maps an OpenAI HTTP error response onto the IndeRun error taxonomy:
148
+ * Maps an OpenAI HTTP error response onto the IndeRun error taxonomy by its
149
+ * status (see `errorForStatus`), honoring `Retry-After` on whichever status
150
+ * carries it.
151
+ */
152
+ private mapHttpError;
153
+ /**
154
+ * The status classification shared by HTTP errors and numeric in-body codes:
133
155
  * - `401` / `403` → `AuthError`
134
- * - `429` → `RateLimited` (honors `Retry-After` when present)
156
+ * - `402` → `Unavailable`, not retryable: the account is out of credits, so
157
+ * this target cannot serve until someone tops it up. A 402 that carries
158
+ * `Retry-After` is the exception — OpenRouter documents it for its
159
+ * in-flight budget limit, a wait-and-retry case — and is `RateLimited`. Fallback is unaffected
160
+ * either way: the engine moves on to the next target whatever the class.
161
+ * - `429` → `RateLimited`
135
162
  * - `408` / `504` → `Timeout`
136
163
  * - `409` / `5xx` → `Unavailable`
137
- * - any other non-2xx status → `Internal`
164
+ * - any other status → `Internal`
165
+ *
166
+ * `retryAfterMs` travels on every retryable class; it is absent for numeric
167
+ * in-body codes, which have no header to read it from.
138
168
  */
139
- private mapHttpError;
169
+ private errorForStatus;
140
170
  }
141
171
  //# sourceMappingURL=provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/providers/openai/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAQ5E,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,mBAAmB,EACnB,UAAU,EACX,MAAM,wBAAwB,CAAC;AA4BhC,eAAO,MAAM,iCAAiC,wCAAwC,CAAC;AAKvF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,IAAI,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAC;IACjC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AA6BD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