@independo/inderun-web 0.2.0-dev.1 → 0.2.0-dev.3

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/web-sdk.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type CreateBrowserHostServicesOptions } from "./browser-host.js";
2
2
  import { IndeRun } from "./engine.js";
3
+ import { type OnnxProviderOptions } from "./onnx-provider.js";
3
4
  import { type OpenAIProviderOptions } from "./openai-provider.js";
4
5
  /**
5
6
  * Configuration for the default Web SDK factory.
@@ -8,7 +9,12 @@ export interface CreateIndeRunWebOptions {
8
9
  /**
9
10
  * OpenAI Responses provider configuration registered by the factory.
10
11
  */
11
- openAI: OpenAIProviderOptions;
12
+ openAI?: OpenAIProviderOptions;
13
+ /**
14
+ * Web ONNX Runtime provider configuration registered by the factory, for developer-supplied
15
+ * local models. Registering it is what makes `constraints.privacy = "local_required"` routable.
16
+ */
17
+ onnx?: OnnxProviderOptions;
12
18
  /**
13
19
  * Optional browser host service overrides.
14
20
  */
@@ -23,13 +29,16 @@ export interface CreateIndeRunWebOptions {
23
29
  allowDirectOpenAIEndpoint?: boolean;
24
30
  }
25
31
  /**
26
- * Creates a Web SDK instance with the OpenAI Responses provider registered.
32
+ * Creates a Web SDK instance with the configured providers registered.
33
+ *
34
+ * Pass `openAI` for cloud execution, `onnx` for developer-supplied local models, or both to let
35
+ * routing choose between them; at least one is required.
27
36
  *
28
37
  * Use `openAI.auth = "none"` with a proxy endpoint for production browser apps so the OpenAI API key never ships
29
38
  * to the client. Direct OpenAI calls require `allowDirectOpenAIEndpoint` and should resolve credentials through
30
39
  * `authContextRef` and `SecureStorageService`.
31
40
  *
32
- * @param options - OpenAI provider configuration and optional host service overrides.
41
+ * @param options - Provider configuration and optional host service overrides.
33
42
  */
34
43
  export declare function createIndeRunWeb(options: CreateIndeRunWebOptions): IndeRun;
35
44
  //# sourceMappingURL=web-sdk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-sdk.d.ts","sourceRoot":"","sources":["../src/web-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,sBAAsB,CAAC;AAG9B;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,MAAM,EAAE,qBAAqB,CAAC;IAC9B;;OAEG;IACH,YAAY,CAAC,EAAE,gCAAgC,CAAC;IAChD;;;;;;OAMG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAO1E"}
1
+ {"version":3,"file":"web-sdk.d.ts","sourceRoot":"","sources":["../src/web-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAA0B,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,sBAAsB,CAAC;AAG9B;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B;;;OAGG;IACH,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B;;OAEG;IACH,YAAY,CAAC,EAAE,gCAAgC,CAAC;IAChD;;;;;;OAMG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAmB1E"}
package/dist/web-sdk.js CHANGED
@@ -1,27 +1,39 @@
1
1
  import { createBrowserHostServices } from "./browser-host.js";
2
2
  import { IndeRun } from "./engine.js";
3
+ import { OnnxRuntimeWebProvider } from "./onnx-provider.js";
3
4
  import { DEFAULT_OPENAI_RESPONSES_ENDPOINT, OpenAIResponsesProvider } from "./openai-provider.js";
4
5
  import { ProviderRegistry } from "./registry.js";
5
6
  /**
6
- * Creates a Web SDK instance with the OpenAI Responses provider registered.
7
+ * Creates a Web SDK instance with the configured providers registered.
8
+ *
9
+ * Pass `openAI` for cloud execution, `onnx` for developer-supplied local models, or both to let
10
+ * routing choose between them; at least one is required.
7
11
  *
8
12
  * Use `openAI.auth = "none"` with a proxy endpoint for production browser apps so the OpenAI API key never ships
9
13
  * to the client. Direct OpenAI calls require `allowDirectOpenAIEndpoint` and should resolve credentials through
10
14
  * `authContextRef` and `SecureStorageService`.
11
15
  *
12
- * @param options - OpenAI provider configuration and optional host service overrides.
16
+ * @param options - Provider configuration and optional host service overrides.
13
17
  */
14
18
  export function createIndeRunWeb(options) {
15
- assertSafeOpenAIEndpoint(options);
19
+ if (!options.openAI && !options.onnx) {
20
+ throw new Error("createIndeRunWeb requires at least one provider configuration (openAI and/or onnx).");
21
+ }
16
22
  const registry = new ProviderRegistry();
17
- registry.register(new OpenAIResponsesProvider(options.openAI));
23
+ if (options.openAI) {
24
+ assertSafeOpenAIEndpoint(options.openAI, options.allowDirectOpenAIEndpoint);
25
+ registry.register(new OpenAIResponsesProvider(options.openAI));
26
+ }
27
+ if (options.onnx) {
28
+ registry.register(new OnnxRuntimeWebProvider(options.onnx));
29
+ }
18
30
  return new IndeRun(registry, createBrowserHostServices(options.hostServices));
19
31
  }
20
- function assertSafeOpenAIEndpoint(options) {
21
- const endpointUrl = options.openAI.endpointUrl ?? DEFAULT_OPENAI_RESPONSES_ENDPOINT;
22
- const auth = options.openAI.auth ?? "authContextRef";
32
+ function assertSafeOpenAIEndpoint(openAI, allowDirectOpenAIEndpoint) {
33
+ const endpointUrl = openAI.endpointUrl ?? DEFAULT_OPENAI_RESPONSES_ENDPOINT;
34
+ const auth = openAI.auth ?? "authContextRef";
23
35
  const isDirectOpenAIEndpoint = isOpenAIResponsesEndpoint(endpointUrl);
24
- if (isDirectOpenAIEndpoint && auth !== "none" && !options.allowDirectOpenAIEndpoint) {
36
+ if (isDirectOpenAIEndpoint && auth !== "none" && !allowDirectOpenAIEndpoint) {
25
37
  throw new Error('createIndeRunWeb is proxy-first for browser safety. Configure openAI.endpointUrl to a server-side proxy with auth: "none", or set allowDirectOpenAIEndpoint: true for controlled direct OpenAI calls.');
26
38
  }
27
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@independo/inderun-web",
3
- "version": "0.2.0-dev.1",
3
+ "version": "0.2.0-dev.3",
4
4
  "description": "TypeScript/Web SDK for IndeRun.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -40,6 +40,10 @@
40
40
  "./openai": {
41
41
  "types": "./dist/openai.d.ts",
42
42
  "default": "./dist/openai.js"
43
+ },
44
+ "./onnx": {
45
+ "types": "./dist/onnx.d.ts",
46
+ "default": "./dist/onnx.js"
43
47
  }
44
48
  },
45
49
  "files": [
@@ -47,8 +51,16 @@
47
51
  "README.md"
48
52
  ],
49
53
  "dependencies": {
50
- "@independo/inderun-contracts": "^0.2.0-dev.1",
51
- "@independo/inderun-route-core-wasm": "^0.2.0-dev.1"
54
+ "@independo/inderun-contracts": "^0.2.0-dev.3",
55
+ "@independo/inderun-route-core-wasm": "^0.2.0-dev.3"
56
+ },
57
+ "peerDependencies": {
58
+ "@huggingface/transformers": "^4.0.0"
59
+ },
60
+ "peerDependenciesMeta": {
61
+ "@huggingface/transformers": {
62
+ "optional": true
63
+ }
52
64
  },
53
65
  "devDependencies": {
54
66
  "@types/node": "^26.1.1",