@adofai-ipc/client 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KGH1113
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # @adofai-ipc/client
2
+
3
+ TypeScript client for the AdofaiIpc local HTTP IPC gateway.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @adofai-ipc/client
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { tryConnect } from "@adofai-ipc/client";
15
+
16
+ const client = await tryConnect();
17
+
18
+ const result = await client.call({
19
+ namespace: "tufhelper2",
20
+ method: "level.open-from-id",
21
+ params: {
22
+ id: "1234"
23
+ }
24
+ });
25
+ ```
26
+
27
+ You can also bind calls to a namespace.
28
+
29
+ ```ts
30
+ const tufhelper = client.namespace("tufhelper2");
31
+
32
+ await tufhelper.call("level.open-from-id", {
33
+ id: "1234"
34
+ });
35
+ ```
36
+
37
+ ## API
38
+
39
+ ### `tryConnect(options?)`
40
+
41
+ Finds a running AdofaiIpc server by probing `/ipc/health`.
42
+
43
+ Defaults:
44
+
45
+ - host: `127.0.0.1`
46
+ - startPort: `32145`
47
+ - endPort: `32155`
48
+ - timeoutMs: `500`
49
+
50
+ ### `new AdofaiIpcClient(options?)`
51
+
52
+ Creates a client for a known AdofaiIpc base URL.
53
+
54
+ ```ts
55
+ const client = new AdofaiIpcClient({
56
+ baseUrl: "http://127.0.0.1:32145"
57
+ });
58
+ ```
59
+
60
+ ### `client.call(options)`
61
+
62
+ Calls a namespace method through `POST /ipc`.
63
+
64
+ ### `client.namespace(name)`
65
+
66
+ Creates a namespace-bound helper.
67
+
68
+ ### `client.health()`
69
+
70
+ Calls `GET /ipc/health`.
71
+
72
+ ### `client.listNamespaces()`
73
+
74
+ Calls `GET /ipc/namespaces`.
75
+
76
+ ### `client.getNamespace(name)`
77
+
78
+ Calls `GET /ipc/namespaces/{name}`.
79
+
80
+ ## Notes
81
+
82
+ This package uses the global `fetch` API. Node.js 18 or newer is recommended.
83
+
84
+ Browser requests are still subject to AdofaiIpc namespace Origin policy.
package/dist/index.cjs ADDED
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AdofaiIpcClient: () => AdofaiIpcClient,
24
+ AdofaiIpcError: () => AdofaiIpcError,
25
+ AdofaiIpcNamespaceClient: () => AdofaiIpcNamespaceClient,
26
+ IpcConnectionError: () => IpcConnectionError,
27
+ IpcHttpError: () => IpcHttpError,
28
+ IpcResponseError: () => IpcResponseError,
29
+ tryConnect: () => tryConnect
30
+ });
31
+ module.exports = __toCommonJS(index_exports);
32
+
33
+ // src/errors.ts
34
+ var AdofaiIpcError = class extends Error {
35
+ constructor(message) {
36
+ super(message);
37
+ this.name = "AdofaiIpcError";
38
+ }
39
+ };
40
+ var IpcConnectionError = class extends AdofaiIpcError {
41
+ constructor(message = "Could not connect to AdofaiIpc.") {
42
+ super(message);
43
+ this.name = "IpcConnectionError";
44
+ }
45
+ };
46
+ var IpcHttpError = class extends AdofaiIpcError {
47
+ constructor(status, message) {
48
+ super(message);
49
+ this.name = "IpcHttpError";
50
+ this.status = status;
51
+ }
52
+ };
53
+ var IpcResponseError = class extends AdofaiIpcError {
54
+ constructor(error) {
55
+ super(error.message);
56
+ this.name = "IpcResponseError";
57
+ this.code = error.code;
58
+ this.error = error;
59
+ }
60
+ };
61
+
62
+ // src/client.ts
63
+ var DEFAULT_HOST = "127.0.0.1";
64
+ var DEFAULT_START_PORT = 32145;
65
+ var DEFAULT_END_PORT = 32155;
66
+ var DEFAULT_TIMEOUT_MS = 500;
67
+ var AdofaiIpcClient = class {
68
+ constructor(options = {}) {
69
+ this.baseUrl = normalizeBaseUrl(options.baseUrl ?? `http://${DEFAULT_HOST}:${DEFAULT_START_PORT}`);
70
+ this.fetchImpl = options.fetch ?? globalThis.fetch;
71
+ this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
72
+ if (!this.fetchImpl) {
73
+ throw new IpcConnectionError("A fetch implementation is required.");
74
+ }
75
+ }
76
+ static async connect(options = {}) {
77
+ return tryConnect(options);
78
+ }
79
+ async health() {
80
+ return this.get("/ipc/health");
81
+ }
82
+ async listNamespaces() {
83
+ return this.get("/ipc/namespaces");
84
+ }
85
+ async getNamespace(namespace) {
86
+ return this.get(`/ipc/namespaces/${encodeURIComponent(namespace)}`);
87
+ }
88
+ namespace(namespace) {
89
+ return new AdofaiIpcNamespaceClient(this, namespace);
90
+ }
91
+ async call(options) {
92
+ const response = await this.post("/ipc", {
93
+ namespace: options.namespace,
94
+ method: options.method,
95
+ params: options.params ?? {},
96
+ id: options.id ?? createRequestId()
97
+ });
98
+ if (!response.ok) {
99
+ throw new IpcResponseError(response.error);
100
+ }
101
+ return response.result;
102
+ }
103
+ async get(path) {
104
+ return this.request(path, {
105
+ method: "GET"
106
+ });
107
+ }
108
+ async post(path, body) {
109
+ return this.request(path, {
110
+ method: "POST",
111
+ headers: {
112
+ "Content-Type": "application/json"
113
+ },
114
+ body: JSON.stringify(body)
115
+ });
116
+ }
117
+ async request(path, init) {
118
+ const controller = new AbortController();
119
+ const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
120
+ try {
121
+ const response = await this.fetchImpl(`${this.baseUrl}${path}`, {
122
+ ...init,
123
+ signal: controller.signal
124
+ });
125
+ if (!response.ok) {
126
+ const text = await response.text();
127
+ throw new IpcHttpError(response.status, text || response.statusText);
128
+ }
129
+ return await response.json();
130
+ } catch (error) {
131
+ if (error instanceof IpcHttpError) throw error;
132
+ if (error instanceof Error) throw new IpcConnectionError(error.message);
133
+ throw new IpcConnectionError();
134
+ } finally {
135
+ clearTimeout(timeout);
136
+ }
137
+ }
138
+ };
139
+ var AdofaiIpcNamespaceClient = class {
140
+ constructor(client, namespace) {
141
+ this.client = client;
142
+ this.namespace = namespace;
143
+ }
144
+ async call(method, params, id) {
145
+ return this.client.call({
146
+ namespace: this.namespace,
147
+ method,
148
+ params,
149
+ id
150
+ });
151
+ }
152
+ };
153
+ async function tryConnect(options = {}) {
154
+ const host = options.host ?? DEFAULT_HOST;
155
+ const startPort = options.startPort ?? DEFAULT_START_PORT;
156
+ const endPort = options.endPort ?? DEFAULT_END_PORT;
157
+ for (let port = startPort; port <= endPort; port++) {
158
+ const client = new AdofaiIpcClient({
159
+ baseUrl: `http://${host}:${port}`,
160
+ fetch: options.fetch,
161
+ timeoutMs: options.timeoutMs
162
+ });
163
+ try {
164
+ const health = await client.health();
165
+ if (health.ok && health.server === "AdofaiIpc") {
166
+ return client;
167
+ }
168
+ } catch {
169
+ }
170
+ }
171
+ throw new IpcConnectionError(
172
+ `Could not connect to AdofaiIpc on ${host}:${startPort}-${endPort}.`
173
+ );
174
+ }
175
+ function normalizeBaseUrl(value) {
176
+ return value.replace(/\/+$/, "");
177
+ }
178
+ function createRequestId() {
179
+ return `adofai-ipc-${Date.now()}-${Math.random().toString(36).slice(2)}`;
180
+ }
181
+ // Annotate the CommonJS export names for ESM import in node:
182
+ 0 && (module.exports = {
183
+ AdofaiIpcClient,
184
+ AdofaiIpcError,
185
+ AdofaiIpcNamespaceClient,
186
+ IpcConnectionError,
187
+ IpcHttpError,
188
+ IpcResponseError,
189
+ tryConnect
190
+ });
191
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/client.ts"],"sourcesContent":["export {\n AdofaiIpcClient,\n AdofaiIpcNamespaceClient,\n tryConnect\n} from \"./client\";\n\nexport {\n AdofaiIpcError,\n IpcConnectionError,\n IpcHttpError,\n IpcResponseError\n} from \"./errors\";\n\nexport type {\n AdofaiIpcClientOptions,\n IpcCallOptions,\n IpcErrorInfo,\n IpcErrorResponse,\n IpcHealthResponse,\n IpcNamespaceDetail,\n IpcNamespacesResponse,\n IpcNamespaceSummary,\n IpcRequestId,\n IpcResponse,\n IpcSuccessResponse,\n TryConnectOptions\n} from \"./types\";\n","import type { IpcErrorInfo } from \"./types\";\n\nexport class AdofaiIpcError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"AdofaiIpcError\";\n }\n}\n\nexport class IpcConnectionError extends AdofaiIpcError {\n constructor(message = \"Could not connect to AdofaiIpc.\") {\n super(message);\n this.name = \"IpcConnectionError\";\n }\n}\n\nexport class IpcHttpError extends AdofaiIpcError {\n readonly status: number;\n\n constructor(status: number, message: string) {\n super(message);\n this.name = \"IpcHttpError\";\n this.status = status;\n }\n}\n\nexport class IpcResponseError extends AdofaiIpcError {\n readonly code: string;\n readonly error: IpcErrorInfo;\n\n constructor(error: IpcErrorInfo) {\n super(error.message);\n this.name = \"IpcResponseError\";\n this.code = error.code;\n this.error = error;\n }\n}\n","import { IpcConnectionError, IpcHttpError, IpcResponseError } from \"./errors\";\nimport type {\n AdofaiIpcClientOptions,\n IpcCallOptions,\n IpcHealthResponse,\n IpcNamespaceDetail,\n IpcNamespacesResponse,\n IpcResponse,\n TryConnectOptions\n} from \"./types\";\n\nconst DEFAULT_HOST = \"127.0.0.1\";\nconst DEFAULT_START_PORT = 32145;\nconst DEFAULT_END_PORT = 32155;\nconst DEFAULT_TIMEOUT_MS = 500;\n\nexport class AdofaiIpcClient {\n readonly baseUrl: string;\n\n private readonly fetchImpl: typeof fetch;\n private readonly timeoutMs: number;\n\n constructor(options: AdofaiIpcClientOptions = {}) {\n this.baseUrl = normalizeBaseUrl(options.baseUrl ?? `http://${DEFAULT_HOST}:${DEFAULT_START_PORT}`);\n this.fetchImpl = options.fetch ?? globalThis.fetch;\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n\n if (!this.fetchImpl) {\n throw new IpcConnectionError(\"A fetch implementation is required.\");\n }\n }\n\n static async connect(options: TryConnectOptions = {}): Promise<AdofaiIpcClient> {\n return tryConnect(options);\n }\n\n async health(): Promise<IpcHealthResponse> {\n return this.get<IpcHealthResponse>(\"/ipc/health\");\n }\n\n async listNamespaces(): Promise<IpcNamespacesResponse> {\n return this.get<IpcNamespacesResponse>(\"/ipc/namespaces\");\n }\n\n async getNamespace(namespace: string): Promise<IpcNamespaceDetail> {\n return this.get<IpcNamespaceDetail>(`/ipc/namespaces/${encodeURIComponent(namespace)}`);\n }\n\n namespace(namespace: string): AdofaiIpcNamespaceClient {\n return new AdofaiIpcNamespaceClient(this, namespace);\n }\n\n async call<TResult = unknown, TParams = unknown>(\n options: IpcCallOptions<TParams>\n ): Promise<TResult> {\n const response = await this.post<IpcResponse<TResult>>(\"/ipc\", {\n namespace: options.namespace,\n method: options.method,\n params: options.params ?? {},\n id: options.id ?? createRequestId()\n });\n\n if (!response.ok) {\n throw new IpcResponseError(response.error);\n }\n\n return response.result;\n }\n\n private async get<TResult>(path: string): Promise<TResult> {\n return this.request<TResult>(path, {\n method: \"GET\"\n });\n }\n\n private async post<TResult>(path: string, body: unknown): Promise<TResult> {\n return this.request<TResult>(path, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(body)\n });\n }\n\n private async request<TResult>(path: string, init: RequestInit): Promise<TResult> {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), this.timeoutMs);\n\n try {\n const response = await this.fetchImpl(`${this.baseUrl}${path}`, {\n ...init,\n signal: controller.signal\n });\n\n if (!response.ok) {\n const text = await response.text();\n throw new IpcHttpError(response.status, text || response.statusText);\n }\n\n return (await response.json()) as TResult;\n } catch (error) {\n if (error instanceof IpcHttpError) throw error;\n if (error instanceof Error) throw new IpcConnectionError(error.message);\n throw new IpcConnectionError();\n } finally {\n clearTimeout(timeout);\n }\n }\n}\n\nexport class AdofaiIpcNamespaceClient {\n constructor(\n private readonly client: AdofaiIpcClient,\n readonly namespace: string\n ) {\n }\n\n async call<TResult = unknown, TParams = unknown>(\n method: string,\n params?: TParams,\n id?: string\n ): Promise<TResult> {\n return this.client.call<TResult, TParams>({\n namespace: this.namespace,\n method,\n params,\n id\n });\n }\n}\n\nexport async function tryConnect(options: TryConnectOptions = {}): Promise<AdofaiIpcClient> {\n const host = options.host ?? DEFAULT_HOST;\n const startPort = options.startPort ?? DEFAULT_START_PORT;\n const endPort = options.endPort ?? DEFAULT_END_PORT;\n\n for (let port = startPort; port <= endPort; port++) {\n const client = new AdofaiIpcClient({\n baseUrl: `http://${host}:${port}`,\n fetch: options.fetch,\n timeoutMs: options.timeoutMs\n });\n\n try {\n const health = await client.health();\n\n if (health.ok && health.server === \"AdofaiIpc\") {\n return client;\n }\n } catch {\n }\n }\n\n throw new IpcConnectionError(\n `Could not connect to AdofaiIpc on ${host}:${startPort}-${endPort}.`\n );\n}\n\nfunction normalizeBaseUrl(value: string): string {\n return value.replace(/\\/+$/, \"\");\n}\n\nfunction createRequestId(): string {\n return `adofai-ipc-${Date.now()}-${Math.random().toString(36).slice(2)}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,qBAAN,cAAiC,eAAe;AAAA,EACrD,YAAY,UAAU,mCAAmC;AACvD,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,eAAN,cAA2B,eAAe;AAAA,EAG/C,YAAY,QAAgB,SAAiB;AAC3C,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AAEO,IAAM,mBAAN,cAA+B,eAAe;AAAA,EAInD,YAAY,OAAqB;AAC/B,UAAM,MAAM,OAAO;AACnB,SAAK,OAAO;AACZ,SAAK,OAAO,MAAM;AAClB,SAAK,QAAQ;AAAA,EACf;AACF;;;ACzBA,IAAM,eAAe;AACrB,IAAM,qBAAqB;AAC3B,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;AAEpB,IAAM,kBAAN,MAA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IAAI;AAAA,MAC/B,OAAO,QAAQ;AAAA,MACf,WAAW,QAAQ;AAAA,IACrB,CAAC;AAED,QAAI;AACF,YAAM,SAAS,MAAM,OAAO,OAAO;AAEnC,UAAI,OAAO,MAAM,OAAO,WAAW,aAAa;AAC9C,eAAO;AAAA,MACT;AAAA,IACF,QAAQ;AAAA,IACR;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR,qCAAqC,IAAI,IAAI,SAAS,IAAI,OAAO;AAAA,EACnE;AACF;AAEA,SAAS,iBAAiB,OAAuB;AAC/C,SAAO,MAAM,QAAQ,QAAQ,EAAE;AACjC;AAEA,SAAS,kBAA0B;AACjC,SAAO,cAAc,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AACxE;","names":[]}
@@ -0,0 +1,96 @@
1
+ type IpcRequestId = string | number | null;
2
+ interface IpcCallOptions<TParams = unknown> {
3
+ namespace: string;
4
+ method: string;
5
+ params?: TParams;
6
+ id?: IpcRequestId;
7
+ }
8
+ interface IpcSuccessResponse<TResult = unknown> {
9
+ ok: true;
10
+ result: TResult;
11
+ id?: IpcRequestId;
12
+ }
13
+ interface IpcErrorInfo {
14
+ code: string;
15
+ message: string;
16
+ }
17
+ interface IpcErrorResponse {
18
+ ok: false;
19
+ result?: null;
20
+ error: IpcErrorInfo;
21
+ id?: IpcRequestId;
22
+ }
23
+ type IpcResponse<TResult = unknown> = IpcSuccessResponse<TResult> | IpcErrorResponse;
24
+ interface IpcHealthResponse {
25
+ ok: true;
26
+ server: "AdofaiIpc";
27
+ protocolVersion: number;
28
+ port: number;
29
+ }
30
+ interface IpcNamespaceSummary {
31
+ name: string;
32
+ displayName: string;
33
+ version: string;
34
+ }
35
+ interface IpcNamespacesResponse {
36
+ namespaces: IpcNamespaceSummary[];
37
+ }
38
+ interface IpcNamespaceDetail {
39
+ namespace: string;
40
+ displayName: string;
41
+ version: string;
42
+ methods: string[];
43
+ }
44
+ interface AdofaiIpcClientOptions {
45
+ baseUrl?: string;
46
+ fetch?: typeof fetch;
47
+ timeoutMs?: number;
48
+ }
49
+ interface TryConnectOptions {
50
+ host?: string;
51
+ startPort?: number;
52
+ endPort?: number;
53
+ fetch?: typeof fetch;
54
+ timeoutMs?: number;
55
+ }
56
+
57
+ declare class AdofaiIpcClient {
58
+ readonly baseUrl: string;
59
+ private readonly fetchImpl;
60
+ private readonly timeoutMs;
61
+ constructor(options?: AdofaiIpcClientOptions);
62
+ static connect(options?: TryConnectOptions): Promise<AdofaiIpcClient>;
63
+ health(): Promise<IpcHealthResponse>;
64
+ listNamespaces(): Promise<IpcNamespacesResponse>;
65
+ getNamespace(namespace: string): Promise<IpcNamespaceDetail>;
66
+ namespace(namespace: string): AdofaiIpcNamespaceClient;
67
+ call<TResult = unknown, TParams = unknown>(options: IpcCallOptions<TParams>): Promise<TResult>;
68
+ private get;
69
+ private post;
70
+ private request;
71
+ }
72
+ declare class AdofaiIpcNamespaceClient {
73
+ private readonly client;
74
+ readonly namespace: string;
75
+ constructor(client: AdofaiIpcClient, namespace: string);
76
+ call<TResult = unknown, TParams = unknown>(method: string, params?: TParams, id?: string): Promise<TResult>;
77
+ }
78
+ declare function tryConnect(options?: TryConnectOptions): Promise<AdofaiIpcClient>;
79
+
80
+ declare class AdofaiIpcError extends Error {
81
+ constructor(message: string);
82
+ }
83
+ declare class IpcConnectionError extends AdofaiIpcError {
84
+ constructor(message?: string);
85
+ }
86
+ declare class IpcHttpError extends AdofaiIpcError {
87
+ readonly status: number;
88
+ constructor(status: number, message: string);
89
+ }
90
+ declare class IpcResponseError extends AdofaiIpcError {
91
+ readonly code: string;
92
+ readonly error: IpcErrorInfo;
93
+ constructor(error: IpcErrorInfo);
94
+ }
95
+
96
+ export { AdofaiIpcClient, type AdofaiIpcClientOptions, AdofaiIpcError, AdofaiIpcNamespaceClient, type IpcCallOptions, IpcConnectionError, type IpcErrorInfo, type IpcErrorResponse, type IpcHealthResponse, IpcHttpError, type IpcNamespaceDetail, type IpcNamespaceSummary, type IpcNamespacesResponse, type IpcRequestId, type IpcResponse, IpcResponseError, type IpcSuccessResponse, type TryConnectOptions, tryConnect };
@@ -0,0 +1,96 @@
1
+ type IpcRequestId = string | number | null;
2
+ interface IpcCallOptions<TParams = unknown> {
3
+ namespace: string;
4
+ method: string;
5
+ params?: TParams;
6
+ id?: IpcRequestId;
7
+ }
8
+ interface IpcSuccessResponse<TResult = unknown> {
9
+ ok: true;
10
+ result: TResult;
11
+ id?: IpcRequestId;
12
+ }
13
+ interface IpcErrorInfo {
14
+ code: string;
15
+ message: string;
16
+ }
17
+ interface IpcErrorResponse {
18
+ ok: false;
19
+ result?: null;
20
+ error: IpcErrorInfo;
21
+ id?: IpcRequestId;
22
+ }
23
+ type IpcResponse<TResult = unknown> = IpcSuccessResponse<TResult> | IpcErrorResponse;
24
+ interface IpcHealthResponse {
25
+ ok: true;
26
+ server: "AdofaiIpc";
27
+ protocolVersion: number;
28
+ port: number;
29
+ }
30
+ interface IpcNamespaceSummary {
31
+ name: string;
32
+ displayName: string;
33
+ version: string;
34
+ }
35
+ interface IpcNamespacesResponse {
36
+ namespaces: IpcNamespaceSummary[];
37
+ }
38
+ interface IpcNamespaceDetail {
39
+ namespace: string;
40
+ displayName: string;
41
+ version: string;
42
+ methods: string[];
43
+ }
44
+ interface AdofaiIpcClientOptions {
45
+ baseUrl?: string;
46
+ fetch?: typeof fetch;
47
+ timeoutMs?: number;
48
+ }
49
+ interface TryConnectOptions {
50
+ host?: string;
51
+ startPort?: number;
52
+ endPort?: number;
53
+ fetch?: typeof fetch;
54
+ timeoutMs?: number;
55
+ }
56
+
57
+ declare class AdofaiIpcClient {
58
+ readonly baseUrl: string;
59
+ private readonly fetchImpl;
60
+ private readonly timeoutMs;
61
+ constructor(options?: AdofaiIpcClientOptions);
62
+ static connect(options?: TryConnectOptions): Promise<AdofaiIpcClient>;
63
+ health(): Promise<IpcHealthResponse>;
64
+ listNamespaces(): Promise<IpcNamespacesResponse>;
65
+ getNamespace(namespace: string): Promise<IpcNamespaceDetail>;
66
+ namespace(namespace: string): AdofaiIpcNamespaceClient;
67
+ call<TResult = unknown, TParams = unknown>(options: IpcCallOptions<TParams>): Promise<TResult>;
68
+ private get;
69
+ private post;
70
+ private request;
71
+ }
72
+ declare class AdofaiIpcNamespaceClient {
73
+ private readonly client;
74
+ readonly namespace: string;
75
+ constructor(client: AdofaiIpcClient, namespace: string);
76
+ call<TResult = unknown, TParams = unknown>(method: string, params?: TParams, id?: string): Promise<TResult>;
77
+ }
78
+ declare function tryConnect(options?: TryConnectOptions): Promise<AdofaiIpcClient>;
79
+
80
+ declare class AdofaiIpcError extends Error {
81
+ constructor(message: string);
82
+ }
83
+ declare class IpcConnectionError extends AdofaiIpcError {
84
+ constructor(message?: string);
85
+ }
86
+ declare class IpcHttpError extends AdofaiIpcError {
87
+ readonly status: number;
88
+ constructor(status: number, message: string);
89
+ }
90
+ declare class IpcResponseError extends AdofaiIpcError {
91
+ readonly code: string;
92
+ readonly error: IpcErrorInfo;
93
+ constructor(error: IpcErrorInfo);
94
+ }
95
+
96
+ export { AdofaiIpcClient, type AdofaiIpcClientOptions, AdofaiIpcError, AdofaiIpcNamespaceClient, type IpcCallOptions, IpcConnectionError, type IpcErrorInfo, type IpcErrorResponse, type IpcHealthResponse, IpcHttpError, type IpcNamespaceDetail, type IpcNamespaceSummary, type IpcNamespacesResponse, type IpcRequestId, type IpcResponse, IpcResponseError, type IpcSuccessResponse, type TryConnectOptions, tryConnect };
package/dist/index.js ADDED
@@ -0,0 +1,158 @@
1
+ // src/errors.ts
2
+ var AdofaiIpcError = class extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ this.name = "AdofaiIpcError";
6
+ }
7
+ };
8
+ var IpcConnectionError = class extends AdofaiIpcError {
9
+ constructor(message = "Could not connect to AdofaiIpc.") {
10
+ super(message);
11
+ this.name = "IpcConnectionError";
12
+ }
13
+ };
14
+ var IpcHttpError = class extends AdofaiIpcError {
15
+ constructor(status, message) {
16
+ super(message);
17
+ this.name = "IpcHttpError";
18
+ this.status = status;
19
+ }
20
+ };
21
+ var IpcResponseError = class extends AdofaiIpcError {
22
+ constructor(error) {
23
+ super(error.message);
24
+ this.name = "IpcResponseError";
25
+ this.code = error.code;
26
+ this.error = error;
27
+ }
28
+ };
29
+
30
+ // src/client.ts
31
+ var DEFAULT_HOST = "127.0.0.1";
32
+ var DEFAULT_START_PORT = 32145;
33
+ var DEFAULT_END_PORT = 32155;
34
+ var DEFAULT_TIMEOUT_MS = 500;
35
+ var AdofaiIpcClient = class {
36
+ constructor(options = {}) {
37
+ this.baseUrl = normalizeBaseUrl(options.baseUrl ?? `http://${DEFAULT_HOST}:${DEFAULT_START_PORT}`);
38
+ this.fetchImpl = options.fetch ?? globalThis.fetch;
39
+ this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
40
+ if (!this.fetchImpl) {
41
+ throw new IpcConnectionError("A fetch implementation is required.");
42
+ }
43
+ }
44
+ static async connect(options = {}) {
45
+ return tryConnect(options);
46
+ }
47
+ async health() {
48
+ return this.get("/ipc/health");
49
+ }
50
+ async listNamespaces() {
51
+ return this.get("/ipc/namespaces");
52
+ }
53
+ async getNamespace(namespace) {
54
+ return this.get(`/ipc/namespaces/${encodeURIComponent(namespace)}`);
55
+ }
56
+ namespace(namespace) {
57
+ return new AdofaiIpcNamespaceClient(this, namespace);
58
+ }
59
+ async call(options) {
60
+ const response = await this.post("/ipc", {
61
+ namespace: options.namespace,
62
+ method: options.method,
63
+ params: options.params ?? {},
64
+ id: options.id ?? createRequestId()
65
+ });
66
+ if (!response.ok) {
67
+ throw new IpcResponseError(response.error);
68
+ }
69
+ return response.result;
70
+ }
71
+ async get(path) {
72
+ return this.request(path, {
73
+ method: "GET"
74
+ });
75
+ }
76
+ async post(path, body) {
77
+ return this.request(path, {
78
+ method: "POST",
79
+ headers: {
80
+ "Content-Type": "application/json"
81
+ },
82
+ body: JSON.stringify(body)
83
+ });
84
+ }
85
+ async request(path, init) {
86
+ const controller = new AbortController();
87
+ const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
88
+ try {
89
+ const response = await this.fetchImpl(`${this.baseUrl}${path}`, {
90
+ ...init,
91
+ signal: controller.signal
92
+ });
93
+ if (!response.ok) {
94
+ const text = await response.text();
95
+ throw new IpcHttpError(response.status, text || response.statusText);
96
+ }
97
+ return await response.json();
98
+ } catch (error) {
99
+ if (error instanceof IpcHttpError) throw error;
100
+ if (error instanceof Error) throw new IpcConnectionError(error.message);
101
+ throw new IpcConnectionError();
102
+ } finally {
103
+ clearTimeout(timeout);
104
+ }
105
+ }
106
+ };
107
+ var AdofaiIpcNamespaceClient = class {
108
+ constructor(client, namespace) {
109
+ this.client = client;
110
+ this.namespace = namespace;
111
+ }
112
+ async call(method, params, id) {
113
+ return this.client.call({
114
+ namespace: this.namespace,
115
+ method,
116
+ params,
117
+ id
118
+ });
119
+ }
120
+ };
121
+ async function tryConnect(options = {}) {
122
+ const host = options.host ?? DEFAULT_HOST;
123
+ const startPort = options.startPort ?? DEFAULT_START_PORT;
124
+ const endPort = options.endPort ?? DEFAULT_END_PORT;
125
+ for (let port = startPort; port <= endPort; port++) {
126
+ const client = new AdofaiIpcClient({
127
+ baseUrl: `http://${host}:${port}`,
128
+ fetch: options.fetch,
129
+ timeoutMs: options.timeoutMs
130
+ });
131
+ try {
132
+ const health = await client.health();
133
+ if (health.ok && health.server === "AdofaiIpc") {
134
+ return client;
135
+ }
136
+ } catch {
137
+ }
138
+ }
139
+ throw new IpcConnectionError(
140
+ `Could not connect to AdofaiIpc on ${host}:${startPort}-${endPort}.`
141
+ );
142
+ }
143
+ function normalizeBaseUrl(value) {
144
+ return value.replace(/\/+$/, "");
145
+ }
146
+ function createRequestId() {
147
+ return `adofai-ipc-${Date.now()}-${Math.random().toString(36).slice(2)}`;
148
+ }
149
+ export {
150
+ AdofaiIpcClient,
151
+ AdofaiIpcError,
152
+ AdofaiIpcNamespaceClient,
153
+ IpcConnectionError,
154
+ IpcHttpError,
155
+ IpcResponseError,
156
+ tryConnect
157
+ };
158
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts","../src/client.ts"],"sourcesContent":["import type { IpcErrorInfo } from \"./types\";\n\nexport class AdofaiIpcError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"AdofaiIpcError\";\n }\n}\n\nexport class IpcConnectionError extends AdofaiIpcError {\n constructor(message = \"Could not connect to AdofaiIpc.\") {\n super(message);\n this.name = \"IpcConnectionError\";\n }\n}\n\nexport class IpcHttpError extends AdofaiIpcError {\n readonly status: number;\n\n constructor(status: number, message: string) {\n super(message);\n this.name = \"IpcHttpError\";\n this.status = status;\n }\n}\n\nexport class IpcResponseError extends AdofaiIpcError {\n readonly code: string;\n readonly error: IpcErrorInfo;\n\n constructor(error: IpcErrorInfo) {\n super(error.message);\n this.name = \"IpcResponseError\";\n this.code = error.code;\n this.error = error;\n }\n}\n","import { IpcConnectionError, IpcHttpError, IpcResponseError } from \"./errors\";\nimport type {\n AdofaiIpcClientOptions,\n IpcCallOptions,\n IpcHealthResponse,\n IpcNamespaceDetail,\n IpcNamespacesResponse,\n IpcResponse,\n TryConnectOptions\n} from \"./types\";\n\nconst DEFAULT_HOST = \"127.0.0.1\";\nconst DEFAULT_START_PORT = 32145;\nconst DEFAULT_END_PORT = 32155;\nconst DEFAULT_TIMEOUT_MS = 500;\n\nexport class AdofaiIpcClient {\n readonly baseUrl: string;\n\n private readonly fetchImpl: typeof fetch;\n private readonly timeoutMs: number;\n\n constructor(options: AdofaiIpcClientOptions = {}) {\n this.baseUrl = normalizeBaseUrl(options.baseUrl ?? `http://${DEFAULT_HOST}:${DEFAULT_START_PORT}`);\n this.fetchImpl = options.fetch ?? globalThis.fetch;\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n\n if (!this.fetchImpl) {\n throw new IpcConnectionError(\"A fetch implementation is required.\");\n }\n }\n\n static async connect(options: TryConnectOptions = {}): Promise<AdofaiIpcClient> {\n return tryConnect(options);\n }\n\n async health(): Promise<IpcHealthResponse> {\n return this.get<IpcHealthResponse>(\"/ipc/health\");\n }\n\n async listNamespaces(): Promise<IpcNamespacesResponse> {\n return this.get<IpcNamespacesResponse>(\"/ipc/namespaces\");\n }\n\n async getNamespace(namespace: string): Promise<IpcNamespaceDetail> {\n return this.get<IpcNamespaceDetail>(`/ipc/namespaces/${encodeURIComponent(namespace)}`);\n }\n\n namespace(namespace: string): AdofaiIpcNamespaceClient {\n return new AdofaiIpcNamespaceClient(this, namespace);\n }\n\n async call<TResult = unknown, TParams = unknown>(\n options: IpcCallOptions<TParams>\n ): Promise<TResult> {\n const response = await this.post<IpcResponse<TResult>>(\"/ipc\", {\n namespace: options.namespace,\n method: options.method,\n params: options.params ?? {},\n id: options.id ?? createRequestId()\n });\n\n if (!response.ok) {\n throw new IpcResponseError(response.error);\n }\n\n return response.result;\n }\n\n private async get<TResult>(path: string): Promise<TResult> {\n return this.request<TResult>(path, {\n method: \"GET\"\n });\n }\n\n private async post<TResult>(path: string, body: unknown): Promise<TResult> {\n return this.request<TResult>(path, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(body)\n });\n }\n\n private async request<TResult>(path: string, init: RequestInit): Promise<TResult> {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), this.timeoutMs);\n\n try {\n const response = await this.fetchImpl(`${this.baseUrl}${path}`, {\n ...init,\n signal: controller.signal\n });\n\n if (!response.ok) {\n const text = await response.text();\n throw new IpcHttpError(response.status, text || response.statusText);\n }\n\n return (await response.json()) as TResult;\n } catch (error) {\n if (error instanceof IpcHttpError) throw error;\n if (error instanceof Error) throw new IpcConnectionError(error.message);\n throw new IpcConnectionError();\n } finally {\n clearTimeout(timeout);\n }\n }\n}\n\nexport class AdofaiIpcNamespaceClient {\n constructor(\n private readonly client: AdofaiIpcClient,\n readonly namespace: string\n ) {\n }\n\n async call<TResult = unknown, TParams = unknown>(\n method: string,\n params?: TParams,\n id?: string\n ): Promise<TResult> {\n return this.client.call<TResult, TParams>({\n namespace: this.namespace,\n method,\n params,\n id\n });\n }\n}\n\nexport async function tryConnect(options: TryConnectOptions = {}): Promise<AdofaiIpcClient> {\n const host = options.host ?? DEFAULT_HOST;\n const startPort = options.startPort ?? DEFAULT_START_PORT;\n const endPort = options.endPort ?? DEFAULT_END_PORT;\n\n for (let port = startPort; port <= endPort; port++) {\n const client = new AdofaiIpcClient({\n baseUrl: `http://${host}:${port}`,\n fetch: options.fetch,\n timeoutMs: options.timeoutMs\n });\n\n try {\n const health = await client.health();\n\n if (health.ok && health.server === \"AdofaiIpc\") {\n return client;\n }\n } catch {\n }\n }\n\n throw new IpcConnectionError(\n `Could not connect to AdofaiIpc on ${host}:${startPort}-${endPort}.`\n );\n}\n\nfunction normalizeBaseUrl(value: string): string {\n return value.replace(/\\/+$/, \"\");\n}\n\nfunction createRequestId(): string {\n return `adofai-ipc-${Date.now()}-${Math.random().toString(36).slice(2)}`;\n}\n"],"mappings":";AAEO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,qBAAN,cAAiC,eAAe;AAAA,EACrD,YAAY,UAAU,mCAAmC;AACvD,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,eAAN,cAA2B,eAAe;AAAA,EAG/C,YAAY,QAAgB,SAAiB;AAC3C,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AAEO,IAAM,mBAAN,cAA+B,eAAe;AAAA,EAInD,YAAY,OAAqB;AAC/B,UAAM,MAAM,OAAO;AACnB,SAAK,OAAO;AACZ,SAAK,OAAO,MAAM;AAClB,SAAK,QAAQ;AAAA,EACf;AACF;;;ACzBA,IAAM,eAAe;AACrB,IAAM,qB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Q;AAClD,UAAM,SAAS,IAAI,gBAAgB;AAAA,MACjC,SAAS,UAAU,IAAI,IAAI,IAAI;AAAA,MAC/B,OAAO,QAAQ;AAAA,MACf,WAAW,QAAQ;AAAA,IACrB,CAAC;AAED,QAAI;AACF,YAAM,SAAS,MAAM,OAAO,OAAO;AAEnC,UAAI,OAAO,MAAM,OAAO,WAAW,aAAa;AAC9C,eAAO;AAAA,MACT;AAAA,IACF,QAAQ;AAAA,IACR;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR,qCAAqC,IAAI,IAAI,SAAS,IAAI,OAAO;AAAA,EACnE;AACF;AAEA,SAAS,iBAAiB,OAAuB;AAC/C,SAAO,MAAM,QAAQ,QAAQ,EAAE;AACjC;AAEA,SAAS,kBAA0B;AACjC,SAAO,cAAc,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AACxE;","names":[]}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@adofai-ipc/client",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript client for the AdofaiIpc local HTTP IPC gateway.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/KGH1113/adofai-ipc.git",
10
+ "directory": "packages/client"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/KGH1113/adofai-ipc/issues"
14
+ },
15
+ "homepage": "https://github.com/KGH1113/adofai-ipc#readme",
16
+ "keywords": [
17
+ "adofai",
18
+ "ipc",
19
+ "localhost",
20
+ "typescript",
21
+ "unity",
22
+ "unitymodmanager"
23
+ ],
24
+ "sideEffects": false,
25
+ "main": "./dist/index.cjs",
26
+ "module": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js",
32
+ "require": "./dist/index.cjs"
33
+ }
34
+ },
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "engines": {
39
+ "node": ">=18"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "devDependencies": {
45
+ "tsup": "^8.3.5",
46
+ "typescript": "^5.6.3"
47
+ },
48
+ "scripts": {
49
+ "build": "tsup",
50
+ "check": "tsc --noEmit",
51
+ "clean": "rm -rf dist"
52
+ }
53
+ }