@miosa/sdk 3.2.4 → 3.3.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,61 @@
1
+ /**
2
+ * Native HTTP/3 addon (napi-rs over quinn + h3). See index.js for the
3
+ * platform-binary loading strategy and README.md for which platforms
4
+ * actually have a prebuilt binary today.
5
+ */
6
+
7
+ export interface NativeH3Response {
8
+ status: number;
9
+ headers: Record<string, string>;
10
+ body: Buffer;
11
+ }
12
+
13
+ export interface NativeH3TestServer {
14
+ handle: number;
15
+ port: number;
16
+ }
17
+
18
+ export interface NativeH3Module {
19
+ available: boolean;
20
+ platformArchKey: () => string;
21
+
22
+ /**
23
+ * Opens one HTTP/3 connection to address:port with TLS SNI serverName.
24
+ * Returns an opaque handle for h3Request/h3Close. Rejects if the QUIC
25
+ * handshake (or h3 setup on top of it) doesn't complete within
26
+ * connectTimeoutMs.
27
+ */
28
+ h3Connect: (
29
+ address: string,
30
+ serverName: string,
31
+ port: number,
32
+ insecure: boolean,
33
+ connectTimeoutMs: number,
34
+ ) => Promise<number>;
35
+
36
+ h3Request: (
37
+ handle: number,
38
+ method: string,
39
+ authority: string,
40
+ path: string,
41
+ headers: Record<string, string>,
42
+ body: Buffer | undefined,
43
+ ) => Promise<NativeH3Response>;
44
+
45
+ /** No-op on an already-closed or unknown handle. */
46
+ h3Close: (handle: number) => Promise<void>;
47
+
48
+ /** Test-only: starts a throwaway local HTTP/3 server. */
49
+ h3TestServerStart: (
50
+ port: number,
51
+ serverName: string,
52
+ responseBody: string,
53
+ maxRequests: number,
54
+ ) => Promise<NativeH3TestServer>;
55
+
56
+ /** Test-only: awaits the server's own count of requests served. */
57
+ h3TestServerWait: (handle: number) => Promise<number>;
58
+ }
59
+
60
+ declare const nativeH3Module: NativeH3Module;
61
+ export = nativeH3Module;
@@ -0,0 +1,60 @@
1
+ // Loads the platform-specific prebuilt addon, the same way napi-rs's own
2
+ // generated loaders do: try the matching optional package by name first
3
+ // (what a real npm install resolves), then fall back to the binary
4
+ // sitting right next to this file under npm/<platform>-<arch>/ (what this
5
+ // workspace has today, with only darwin-arm64 actually built - see
6
+ // README.md for the platforms CI still needs to produce).
7
+ //
8
+ // Never throws. `require("./index.js")` returns `null` when nothing
9
+ // loadable is found, so callers (Http3Transport) can treat "no native
10
+ // addon for this platform" exactly like "HTTP/3 unavailable" - the same
11
+ // zero-cost fallback to HTTP/2 as every other unavailability reason.
12
+
13
+ "use strict";
14
+
15
+ const path = require("node:path");
16
+
17
+ function platformArchKey() {
18
+ const platform = process.platform;
19
+ const arch = process.arch;
20
+ if (platform === "linux") {
21
+ // musl vs glibc matters on Linux; napi-rs convention suffixes it.
22
+ const isMusl = (() => {
23
+ try {
24
+ return !!process.report?.getReport()?.header?.glibcVersionRuntime === false;
25
+ } catch {
26
+ return false;
27
+ }
28
+ })();
29
+ return `${platform}-${arch}-${isMusl ? "musl" : "gnu"}`;
30
+ }
31
+ if (platform === "win32") return `${platform}-${arch}-msvc`;
32
+ return `${platform}-${arch}`;
33
+ }
34
+
35
+ function load() {
36
+ const key = platformArchKey();
37
+ const attempts = [
38
+ () => require(`@miosa/h3-runner-${key}`),
39
+ () => require(path.join(__dirname, "npm", key, `h3-runner-native.${key}.node`)),
40
+ ];
41
+
42
+ for (const attempt of attempts) {
43
+ try {
44
+ return attempt();
45
+ } catch {
46
+ // try the next strategy
47
+ }
48
+ }
49
+ return null;
50
+ }
51
+
52
+ const loaded = load();
53
+ if (loaded) {
54
+ loaded.platformArchKey = platformArchKey;
55
+ loaded.available = true;
56
+ module.exports = loaded;
57
+ } else {
58
+ module.exports = { platformArchKey, available: false };
59
+ }
60
+
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@miosa/h3-runner-native",
3
+ "version": "0.1.0",
4
+ "description": "Native HTTP/3 (quinn + h3) client addon for the SOMA runner transport. Not published independently - consumed by @miosa/sdk's runner module via a relative path.",
5
+ "license": "MIT",
6
+ "private": true,
7
+ "main": "index.js",
8
+ "types": "index.d.ts"
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miosa/sdk",
3
- "version": "3.2.4",
3
+ "version": "3.3.0",
4
4
  "description": "TypeScript SDK for the MIOSA API - cloud VM desktop infrastructure for AI agents",
5
5
  "license": "MIT",
6
6
  "author": "MIOSA <hello@miosa.ai>",
@@ -29,18 +29,12 @@
29
29
  },
30
30
  "files": [
31
31
  "dist",
32
- "README.md"
32
+ "README.md",
33
+ "native/h3-runner/package.json",
34
+ "native/h3-runner/index.js",
35
+ "native/h3-runner/index.d.ts",
36
+ "native/h3-runner/npm/*/*.node"
33
37
  ],
34
- "scripts": {
35
- "build": "tsup",
36
- "dev": "tsup --watch",
37
- "typecheck": "tsc --noEmit",
38
- "test": "vitest run",
39
- "test:watch": "vitest",
40
- "test:coverage": "vitest run --coverage",
41
- "lint": "eslint src --ext .ts",
42
- "clean": "rm -rf dist"
43
- },
44
38
  "devDependencies": {
45
39
  "@types/node": "^20.0.0",
46
40
  "@types/ws": "^8.18.1",
@@ -63,5 +57,14 @@
63
57
  "overrides": {
64
58
  "esbuild": "^0.28.1"
65
59
  },
66
- "packageManager": "pnpm@9.15.9+sha512.68046141893c66fad01c079231128e9afb89ef87e2691d69e4d40eee228988295fd4682181bae55b58418c3a253bde65a505ec7c5f9403ece5cc3cd37dcf2531"
67
- }
60
+ "scripts": {
61
+ "build": "tsup",
62
+ "dev": "tsup --watch",
63
+ "typecheck": "tsc --noEmit",
64
+ "test": "vitest run",
65
+ "test:watch": "vitest",
66
+ "test:coverage": "vitest run --coverage",
67
+ "lint": "eslint src --ext .ts",
68
+ "clean": "rm -rf dist"
69
+ }
70
+ }