@independo/inderun-web 0.1.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.
@@ -0,0 +1,38 @@
1
+ import { createBrowserHostServices } from "./browser-host.js";
2
+ import { IndeRun } from "./engine.js";
3
+ import { DEFAULT_OPENAI_RESPONSES_ENDPOINT, OpenAIResponsesProvider } from "./openai-provider.js";
4
+ import { ProviderRegistry } from "./registry.js";
5
+ /**
6
+ * Creates a Web SDK instance with the OpenAI Responses provider registered.
7
+ *
8
+ * Use `openAI.auth = "none"` with a proxy endpoint for production browser apps so the OpenAI API key never ships
9
+ * to the client. Direct OpenAI calls require `allowDirectOpenAIEndpoint` and should resolve credentials through
10
+ * `authContextRef` and `SecureStorageService`.
11
+ *
12
+ * @param options - OpenAI provider configuration and optional host service overrides.
13
+ */
14
+ export function createIndeRunWeb(options) {
15
+ assertSafeOpenAIEndpoint(options);
16
+ const registry = new ProviderRegistry();
17
+ registry.register(new OpenAIResponsesProvider(options.openAI));
18
+ return new IndeRun(registry, createBrowserHostServices(options.hostServices));
19
+ }
20
+ function assertSafeOpenAIEndpoint(options) {
21
+ const endpointUrl = options.openAI.endpointUrl ?? DEFAULT_OPENAI_RESPONSES_ENDPOINT;
22
+ const auth = options.openAI.auth ?? "authContextRef";
23
+ const isDirectOpenAIEndpoint = isOpenAIResponsesEndpoint(endpointUrl);
24
+ if (isDirectOpenAIEndpoint && auth !== "none" && !options.allowDirectOpenAIEndpoint) {
25
+ 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
+ }
27
+ }
28
+ function isOpenAIResponsesEndpoint(endpointUrl) {
29
+ let parsed;
30
+ try {
31
+ parsed = new URL(endpointUrl);
32
+ }
33
+ catch {
34
+ return false;
35
+ }
36
+ const pathname = parsed.pathname.replace(/\/+$/u, "");
37
+ return parsed.hostname.toLowerCase() === "api.openai.com" && pathname === "/v1/responses";
38
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@independo/inderun-web",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript/Web SDK for IndeRun.",
5
+ "license": "MIT",
6
+ "engines": {
7
+ "node": ">=24"
8
+ },
9
+ "type": "module",
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./openai": {
18
+ "types": "./dist/openai.d.ts",
19
+ "default": "./dist/openai.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md"
25
+ ],
26
+ "dependencies": {
27
+ "@independo/inderun-route-core-wasm": "^0.1.0",
28
+ "@independo/inderun-contracts": "^0.1.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^24.13.2",
32
+ "typescript": "^6.0.3",
33
+ "vitest": "^3.2.6"
34
+ },
35
+ "scripts": {
36
+ "build": "tsc -p tsconfig.json",
37
+ "test": "vitest run"
38
+ }
39
+ }