@matrix-ai/sdk 1.6.0 → 1.6.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.
- package/dist/client.d.ts +4 -4
- package/dist/client.js +31 -5
- package/dist/gen/sdk.gen.d.ts +1 -1
- package/dist/gen/sdk.gen.js +1 -1
- package/dist/gen/types.gen.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/process.d.ts +3 -0
- package/dist/process.js +33 -0
- package/dist/server.d.ts +2 -2
- package/dist/server.js +30 -19
- package/dist/v2/client.d.ts +4 -4
- package/dist/v2/client.js +45 -8
- package/dist/v2/gen/sdk.gen.d.ts +79 -58
- package/dist/v2/gen/sdk.gen.js +124 -85
- package/dist/v2/gen/types.gen.d.ts +551 -417
- package/dist/v2/index.d.ts +2 -2
- package/dist/v2/index.js +5 -5
- package/dist/v2/server.d.ts +2 -2
- package/dist/v2/server.js +30 -19
- package/package.json +7 -4
package/dist/v2/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export * from "./client.js";
|
|
2
2
|
export * from "./server.js";
|
|
3
3
|
import type { ServerOptions } from "./server.js";
|
|
4
|
-
export declare function
|
|
5
|
-
client: import("./client.js").
|
|
4
|
+
export declare function createMatrix(options?: ServerOptions): Promise<{
|
|
5
|
+
client: import("./client.js").MatrixClient;
|
|
6
6
|
server: {
|
|
7
7
|
url: string;
|
|
8
8
|
close(): void;
|
package/dist/v2/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export * from "./client.js";
|
|
2
2
|
export * from "./server.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export async function
|
|
6
|
-
const server = await
|
|
3
|
+
import { createMatrixClient } from "./client.js";
|
|
4
|
+
import { createMatrixServer } from "./server.js";
|
|
5
|
+
export async function createMatrix(options) {
|
|
6
|
+
const server = await createMatrixServer({
|
|
7
7
|
...options,
|
|
8
8
|
});
|
|
9
|
-
const client =
|
|
9
|
+
const client = createMatrixClient({
|
|
10
10
|
baseUrl: server.url,
|
|
11
11
|
});
|
|
12
12
|
return {
|
package/dist/v2/server.d.ts
CHANGED
|
@@ -14,10 +14,10 @@ export type TuiOptions = {
|
|
|
14
14
|
signal?: AbortSignal;
|
|
15
15
|
config?: Config;
|
|
16
16
|
};
|
|
17
|
-
export declare function
|
|
17
|
+
export declare function createMatrixServer(options?: ServerOptions): Promise<{
|
|
18
18
|
url: string;
|
|
19
19
|
close(): void;
|
|
20
20
|
}>;
|
|
21
|
-
export declare function
|
|
21
|
+
export declare function createMatrixTui(options?: TuiOptions): {
|
|
22
22
|
close(): void;
|
|
23
23
|
};
|
package/dist/v2/server.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import launch from "cross-spawn";
|
|
2
|
+
import { stop, bindAbort } from "../process.js";
|
|
3
|
+
export async function createMatrixServer(options) {
|
|
3
4
|
options = Object.assign({
|
|
4
5
|
hostname: "127.0.0.1",
|
|
5
6
|
port: 4096,
|
|
@@ -8,28 +9,38 @@ export async function createOpencodeServer(options) {
|
|
|
8
9
|
const args = [`serve`, `--hostname=${options.hostname}`, `--port=${options.port}`];
|
|
9
10
|
if (options.config?.logLevel)
|
|
10
11
|
args.push(`--log-level=${options.config.logLevel}`);
|
|
11
|
-
const proc =
|
|
12
|
-
signal: options.signal,
|
|
12
|
+
const proc = launch(`matrix`, args, {
|
|
13
13
|
env: {
|
|
14
14
|
...process.env,
|
|
15
|
-
|
|
15
|
+
MATRIX_CONFIG_CONTENT: JSON.stringify(options.config ?? {}),
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
|
+
let clear = () => { };
|
|
18
19
|
const url = await new Promise((resolve, reject) => {
|
|
19
20
|
const id = setTimeout(() => {
|
|
21
|
+
clear();
|
|
22
|
+
stop(proc);
|
|
20
23
|
reject(new Error(`Timeout waiting for server to start after ${options.timeout}ms`));
|
|
21
24
|
}, options.timeout);
|
|
22
25
|
let output = "";
|
|
26
|
+
let resolved = false;
|
|
23
27
|
proc.stdout?.on("data", (chunk) => {
|
|
28
|
+
if (resolved)
|
|
29
|
+
return;
|
|
24
30
|
output += chunk.toString();
|
|
25
31
|
const lines = output.split("\n");
|
|
26
32
|
for (const line of lines) {
|
|
27
|
-
if (line.startsWith("
|
|
33
|
+
if (line.startsWith("matrix server listening")) {
|
|
28
34
|
const match = line.match(/on\s+(https?:\/\/[^\s]+)/);
|
|
29
35
|
if (!match) {
|
|
30
|
-
|
|
36
|
+
clear();
|
|
37
|
+
stop(proc);
|
|
38
|
+
clearTimeout(id);
|
|
39
|
+
reject(new Error(`Failed to parse server url from output: ${line}`));
|
|
40
|
+
return;
|
|
31
41
|
}
|
|
32
42
|
clearTimeout(id);
|
|
43
|
+
resolved = true;
|
|
33
44
|
resolve(match[1]);
|
|
34
45
|
return;
|
|
35
46
|
}
|
|
@@ -50,21 +61,20 @@ export async function createOpencodeServer(options) {
|
|
|
50
61
|
clearTimeout(id);
|
|
51
62
|
reject(error);
|
|
52
63
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
});
|
|
58
|
-
}
|
|
64
|
+
clear = bindAbort(proc, options.signal, () => {
|
|
65
|
+
clearTimeout(id);
|
|
66
|
+
reject(options.signal?.reason);
|
|
67
|
+
});
|
|
59
68
|
});
|
|
60
69
|
return {
|
|
61
70
|
url,
|
|
62
71
|
close() {
|
|
63
|
-
|
|
72
|
+
clear();
|
|
73
|
+
stop(proc);
|
|
64
74
|
},
|
|
65
75
|
};
|
|
66
76
|
}
|
|
67
|
-
export function
|
|
77
|
+
export function createMatrixTui(options) {
|
|
68
78
|
const args = [];
|
|
69
79
|
if (options?.project) {
|
|
70
80
|
args.push(`--project=${options.project}`);
|
|
@@ -78,17 +88,18 @@ export function createOpencodeTui(options) {
|
|
|
78
88
|
if (options?.agent) {
|
|
79
89
|
args.push(`--agent=${options.agent}`);
|
|
80
90
|
}
|
|
81
|
-
const proc =
|
|
82
|
-
signal: options?.signal,
|
|
91
|
+
const proc = launch(`matrix`, args, {
|
|
83
92
|
stdio: "inherit",
|
|
84
93
|
env: {
|
|
85
94
|
...process.env,
|
|
86
|
-
|
|
95
|
+
MATRIX_CONFIG_CONTENT: JSON.stringify(options?.config ?? {}),
|
|
87
96
|
},
|
|
88
97
|
});
|
|
98
|
+
const clear = bindAbort(proc, options?.signal);
|
|
89
99
|
return {
|
|
90
100
|
close() {
|
|
91
|
-
|
|
101
|
+
clear();
|
|
102
|
+
stop(proc);
|
|
92
103
|
},
|
|
93
104
|
};
|
|
94
105
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@matrix-ai/sdk",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
@@ -44,9 +44,12 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@hey-api/openapi-ts": "0.90.10",
|
|
46
46
|
"@tsconfig/node22": "22.0.2",
|
|
47
|
+
"@types/cross-spawn": "6.0.6",
|
|
47
48
|
"@types/node": "22.13.9",
|
|
48
|
-
"typescript": "
|
|
49
|
-
"
|
|
49
|
+
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
50
|
+
"typescript": "5.8.2"
|
|
50
51
|
},
|
|
51
|
-
"dependencies": {
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"cross-spawn": "7.0.6"
|
|
54
|
+
}
|
|
52
55
|
}
|