@miosa/sdk 1.2.5 → 1.2.7
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/README.md +107 -59
- package/dist/index.d.ts +513 -193
- package/dist/index.js +1266 -891
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
- package/src/client.ts +0 -293
- package/src/errors.ts +0 -136
- package/src/http.test.ts +0 -374
- package/src/http.ts +0 -390
- package/src/index.ts +0 -569
- package/src/resources/admin.ts +0 -348
- package/src/resources/analytics.ts +0 -60
- package/src/resources/api-keys.ts +0 -119
- package/src/resources/audit-log.ts +0 -64
- package/src/resources/benchmarks.ts +0 -104
- package/src/resources/builder-sessions.ts +0 -75
- package/src/resources/channels.ts +0 -143
- package/src/resources/checkpoints.ts +0 -225
- package/src/resources/command-center.ts +0 -73
- package/src/resources/community.ts +0 -103
- package/src/resources/completions.ts +0 -104
- package/src/resources/computer-auto-stop.ts +0 -43
- package/src/resources/computer-env.ts +0 -76
- package/src/resources/computer-logs.ts +0 -50
- package/src/resources/computer-osa.ts +0 -76
- package/src/resources/computer-ports.ts +0 -91
- package/src/resources/computer-terminal.ts +0 -61
- package/src/resources/computer-volumes.ts +0 -64
- package/src/resources/computer.ts +0 -551
- package/src/resources/computers.ts +0 -75
- package/src/resources/credits.ts +0 -43
- package/src/resources/cron-jobs.ts +0 -191
- package/src/resources/custom_domains.ts +0 -123
- package/src/resources/dashboard.ts +0 -49
- package/src/resources/databases.ts +0 -218
- package/src/resources/deployments.test.ts +0 -197
- package/src/resources/deployments.ts +0 -1208
- package/src/resources/desktop.ts +0 -134
- package/src/resources/devices.test.ts +0 -92
- package/src/resources/devices.ts +0 -291
- package/src/resources/egress.test.ts +0 -318
- package/src/resources/egressAudit.ts +0 -245
- package/src/resources/egressNetwork.ts +0 -450
- package/src/resources/egressSecrets.ts +0 -577
- package/src/resources/email.ts +0 -212
- package/src/resources/embeddings.ts +0 -36
- package/src/resources/events.ts +0 -296
- package/src/resources/exec.ts +0 -319
- package/src/resources/external-keys.ts +0 -79
- package/src/resources/files.test.ts +0 -339
- package/src/resources/files.ts +0 -220
- package/src/resources/flat-custom-domains.ts +0 -127
- package/src/resources/functions.ts +0 -178
- package/src/resources/health-checks.ts +0 -165
- package/src/resources/integrations.ts +0 -183
- package/src/resources/mcp.ts +0 -70
- package/src/resources/models.ts +0 -45
- package/src/resources/network_policy.ts +0 -73
- package/src/resources/open-computers/agents.ts +0 -91
- package/src/resources/open-computers/apps.ts +0 -102
- package/src/resources/open-computers/clusters.ts +0 -88
- package/src/resources/open-computers/desktop.ts +0 -34
- package/src/resources/open-computers/files.ts +0 -97
- package/src/resources/open-computers/hosts.ts +0 -85
- package/src/resources/open-computers/index.ts +0 -98
- package/src/resources/open-computers/jobs.ts +0 -75
- package/src/resources/open-computers/open_computers.test.ts +0 -288
- package/src/resources/open-computers/secrets.ts +0 -115
- package/src/resources/open-computers/terminal.ts +0 -33
- package/src/resources/open-computers/tunnels.ts +0 -87
- package/src/resources/open-computers/types.ts +0 -343
- package/src/resources/open-computers/workspaces.ts +0 -135
- package/src/resources/org-invites.ts +0 -189
- package/src/resources/project-auth.ts +0 -142
- package/src/resources/project-integrations.ts +0 -133
- package/src/resources/provider-defaults.ts +0 -89
- package/src/resources/regions.ts +0 -94
- package/src/resources/sandbox-templates.ts +0 -195
- package/src/resources/sandboxes.live.test.ts +0 -92
- package/src/resources/sandboxes.test.ts +0 -655
- package/src/resources/sandboxes.ts +0 -1437
- package/src/resources/settings.ts +0 -143
- package/src/resources/snapshots-standalone.ts +0 -51
- package/src/resources/storage.ts +0 -221
- package/src/resources/tenant.ts +0 -66
- package/src/resources/usage.ts +0 -85
- package/src/resources/volumes.ts +0 -117
- package/src/resources/webhooks.ts +0 -239
- package/src/resources/workspace-invites.ts +0 -188
- package/src/resources/workspace-members.test.ts +0 -121
- package/src/resources/workspace-members.ts +0 -143
- package/src/types.ts +0 -463
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Functions resource — serverless edge functions.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { randomUUID } from "node:crypto";
|
|
6
|
-
|
|
7
|
-
import type { HttpClient } from "../http.js";
|
|
8
|
-
|
|
9
|
-
// ── Branded IDs ──────────────────────────────────────────────────────────────
|
|
10
|
-
|
|
11
|
-
export type FunctionId = string & { readonly __brand: "FunctionId" };
|
|
12
|
-
|
|
13
|
-
// ── Resource shapes ──────────────────────────────────────────────────────────
|
|
14
|
-
|
|
15
|
-
export interface FunctionData {
|
|
16
|
-
id: FunctionId;
|
|
17
|
-
tenant_id: string;
|
|
18
|
-
name: string;
|
|
19
|
-
state?: string;
|
|
20
|
-
runtime?: string | null;
|
|
21
|
-
handler?: string | null;
|
|
22
|
-
memory_mb?: number | null;
|
|
23
|
-
timeout_sec?: number | null;
|
|
24
|
-
env?: Record<string, string>;
|
|
25
|
-
created_at?: string;
|
|
26
|
-
updated_at?: string;
|
|
27
|
-
[key: string]: unknown;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// ── Request payloads ─────────────────────────────────────────────────────────
|
|
31
|
-
|
|
32
|
-
export interface FunctionListParams {
|
|
33
|
-
limit?: number;
|
|
34
|
-
cursor?: string;
|
|
35
|
-
state?: string;
|
|
36
|
-
[key: string]: string | number | boolean | undefined;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface FunctionCreateParams {
|
|
40
|
-
name: string;
|
|
41
|
-
runtime?: string;
|
|
42
|
-
handler?: string;
|
|
43
|
-
memory_mb?: number;
|
|
44
|
-
memoryMb?: number;
|
|
45
|
-
timeout_sec?: number;
|
|
46
|
-
timeoutSec?: number;
|
|
47
|
-
env?: Record<string, string>;
|
|
48
|
-
idempotencyKey?: string;
|
|
49
|
-
[key: string]: unknown;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface FunctionUpdateParams {
|
|
53
|
-
name?: string;
|
|
54
|
-
runtime?: string;
|
|
55
|
-
handler?: string;
|
|
56
|
-
memory_mb?: number;
|
|
57
|
-
memoryMb?: number;
|
|
58
|
-
timeout_sec?: number;
|
|
59
|
-
timeoutSec?: number;
|
|
60
|
-
env?: Record<string, string>;
|
|
61
|
-
[key: string]: unknown;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface FunctionInvokeParams {
|
|
65
|
-
payload?: Record<string, unknown>;
|
|
66
|
-
headers?: Record<string, string>;
|
|
67
|
-
idempotencyKey?: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
71
|
-
|
|
72
|
-
function unwrap<T>(payload: unknown): T {
|
|
73
|
-
if (payload && typeof payload === "object" && "data" in (payload as object)) {
|
|
74
|
-
return (payload as { data: T }).data;
|
|
75
|
-
}
|
|
76
|
-
return payload as T;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function listItems<T>(
|
|
80
|
-
payload: unknown,
|
|
81
|
-
candidateKeys: string[] = ["data", "functions", "items"],
|
|
82
|
-
): T[] {
|
|
83
|
-
if (Array.isArray(payload)) return payload;
|
|
84
|
-
if (!payload || typeof payload !== "object") return [];
|
|
85
|
-
const p = payload as Record<string, unknown>;
|
|
86
|
-
if (Array.isArray(p.data)) return p.data as T[];
|
|
87
|
-
for (const key of candidateKeys) {
|
|
88
|
-
if (Array.isArray(p[key])) return p[key] as T[];
|
|
89
|
-
}
|
|
90
|
-
return [];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function stripUndefined(
|
|
94
|
-
input: Record<string, unknown>,
|
|
95
|
-
): Record<string, unknown> {
|
|
96
|
-
return Object.fromEntries(
|
|
97
|
-
Object.entries(input).filter(([, v]) => v !== undefined),
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function idempotencyKey(key?: string): string {
|
|
102
|
-
return key ?? randomUUID();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// ── Main resource ─────────────────────────────────────────────────────────────
|
|
106
|
-
|
|
107
|
-
export class Functions {
|
|
108
|
-
constructor(private readonly http: HttpClient) {}
|
|
109
|
-
|
|
110
|
-
async list(params: FunctionListParams = {}): Promise<FunctionData[]> {
|
|
111
|
-
const query = stripUndefined({ ...params }) as Record<
|
|
112
|
-
string,
|
|
113
|
-
string | number | boolean | undefined
|
|
114
|
-
>;
|
|
115
|
-
const data = await this.http.get<unknown>("/functions", query);
|
|
116
|
-
return listItems<FunctionData>(data);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async get(functionId: string): Promise<FunctionData> {
|
|
120
|
-
const data = await this.http.get<unknown>(`/functions/${functionId}`);
|
|
121
|
-
return unwrap<FunctionData>(data);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
async create(params: FunctionCreateParams): Promise<FunctionData> {
|
|
125
|
-
const { idempotencyKey: ikey, memoryMb, timeoutSec, ...rest } = params;
|
|
126
|
-
const body = stripUndefined({
|
|
127
|
-
...rest,
|
|
128
|
-
memory_mb: memoryMb ?? rest.memory_mb,
|
|
129
|
-
timeout_sec: timeoutSec ?? rest.timeout_sec,
|
|
130
|
-
});
|
|
131
|
-
const data = await this.http.request<unknown>("/functions", {
|
|
132
|
-
method: "POST",
|
|
133
|
-
body,
|
|
134
|
-
headers: { "Idempotency-Key": idempotencyKey(ikey) },
|
|
135
|
-
});
|
|
136
|
-
return unwrap<FunctionData>(data);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
async update(
|
|
140
|
-
functionId: string,
|
|
141
|
-
params: FunctionUpdateParams,
|
|
142
|
-
): Promise<FunctionData> {
|
|
143
|
-
const { memoryMb, timeoutSec, ...rest } = params;
|
|
144
|
-
const body = stripUndefined({
|
|
145
|
-
...rest,
|
|
146
|
-
memory_mb: memoryMb ?? rest.memory_mb,
|
|
147
|
-
timeout_sec: timeoutSec ?? rest.timeout_sec,
|
|
148
|
-
});
|
|
149
|
-
const data = await this.http.patch<unknown>(
|
|
150
|
-
`/functions/${functionId}`,
|
|
151
|
-
body,
|
|
152
|
-
);
|
|
153
|
-
return unwrap<FunctionData>(data);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
async delete(functionId: string): Promise<void> {
|
|
157
|
-
await this.http.delete<unknown>(`/functions/${functionId}`);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
async invoke(
|
|
161
|
-
functionId: string,
|
|
162
|
-
params: FunctionInvokeParams = {},
|
|
163
|
-
): Promise<Record<string, unknown>> {
|
|
164
|
-
const { payload = {}, headers, idempotencyKey: ikey } = params;
|
|
165
|
-
const data = await this.http.request<unknown>(
|
|
166
|
-
`/functions/${functionId}/invoke`,
|
|
167
|
-
{
|
|
168
|
-
method: "POST",
|
|
169
|
-
body: payload,
|
|
170
|
-
headers: {
|
|
171
|
-
"Idempotency-Key": idempotencyKey(ikey),
|
|
172
|
-
...headers,
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
);
|
|
176
|
-
return (data ?? {}) as Record<string, unknown>;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HealthChecks resource — uptime monitoring.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { randomUUID } from "node:crypto";
|
|
6
|
-
|
|
7
|
-
import type { HttpClient } from "../http.js";
|
|
8
|
-
|
|
9
|
-
// ── Branded IDs ──────────────────────────────────────────────────────────────
|
|
10
|
-
|
|
11
|
-
export type HealthCheckId = string & { readonly __brand: "HealthCheckId" };
|
|
12
|
-
|
|
13
|
-
// ── Resource shapes ──────────────────────────────────────────────────────────
|
|
14
|
-
|
|
15
|
-
export interface HealthCheckData {
|
|
16
|
-
id: HealthCheckId;
|
|
17
|
-
tenant_id: string;
|
|
18
|
-
name: string;
|
|
19
|
-
url: string;
|
|
20
|
-
state?: string;
|
|
21
|
-
interval_sec?: number;
|
|
22
|
-
timeout_sec?: number;
|
|
23
|
-
method?: string;
|
|
24
|
-
expected_status?: number | null;
|
|
25
|
-
last_checked_at?: string | null;
|
|
26
|
-
last_status?: "up" | "down" | null;
|
|
27
|
-
created_at?: string;
|
|
28
|
-
updated_at?: string;
|
|
29
|
-
[key: string]: unknown;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// ── Request payloads ─────────────────────────────────────────────────────────
|
|
33
|
-
|
|
34
|
-
export interface HealthCheckListParams {
|
|
35
|
-
limit?: number;
|
|
36
|
-
cursor?: string;
|
|
37
|
-
state?: string;
|
|
38
|
-
[key: string]: string | number | boolean | undefined;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface HealthCheckCreateParams {
|
|
42
|
-
name: string;
|
|
43
|
-
url: string;
|
|
44
|
-
interval_sec?: number;
|
|
45
|
-
intervalSec?: number;
|
|
46
|
-
timeout_sec?: number;
|
|
47
|
-
timeoutSec?: number;
|
|
48
|
-
method?: string;
|
|
49
|
-
expected_status?: number;
|
|
50
|
-
expectedStatus?: number;
|
|
51
|
-
idempotencyKey?: string;
|
|
52
|
-
[key: string]: unknown;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface HealthCheckUpdateParams {
|
|
56
|
-
name?: string;
|
|
57
|
-
url?: string;
|
|
58
|
-
interval_sec?: number;
|
|
59
|
-
intervalSec?: number;
|
|
60
|
-
timeout_sec?: number;
|
|
61
|
-
timeoutSec?: number;
|
|
62
|
-
method?: string;
|
|
63
|
-
expected_status?: number;
|
|
64
|
-
expectedStatus?: number;
|
|
65
|
-
[key: string]: unknown;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
69
|
-
|
|
70
|
-
function unwrap<T>(payload: unknown): T {
|
|
71
|
-
if (payload && typeof payload === "object" && "data" in (payload as object)) {
|
|
72
|
-
return (payload as { data: T }).data;
|
|
73
|
-
}
|
|
74
|
-
return payload as T;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function listItems<T>(
|
|
78
|
-
payload: unknown,
|
|
79
|
-
candidateKeys: string[] = ["data", "health_checks", "items"],
|
|
80
|
-
): T[] {
|
|
81
|
-
if (Array.isArray(payload)) return payload;
|
|
82
|
-
if (!payload || typeof payload !== "object") return [];
|
|
83
|
-
const p = payload as Record<string, unknown>;
|
|
84
|
-
if (Array.isArray(p.data)) return p.data as T[];
|
|
85
|
-
for (const key of candidateKeys) {
|
|
86
|
-
if (Array.isArray(p[key])) return p[key] as T[];
|
|
87
|
-
}
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function stripUndefined(
|
|
92
|
-
input: Record<string, unknown>,
|
|
93
|
-
): Record<string, unknown> {
|
|
94
|
-
return Object.fromEntries(
|
|
95
|
-
Object.entries(input).filter(([, v]) => v !== undefined),
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function idempotencyKey(key?: string): string {
|
|
100
|
-
return key ?? randomUUID();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// ── Main resource ─────────────────────────────────────────────────────────────
|
|
104
|
-
|
|
105
|
-
export class HealthChecks {
|
|
106
|
-
constructor(private readonly http: HttpClient) {}
|
|
107
|
-
|
|
108
|
-
async list(params: HealthCheckListParams = {}): Promise<HealthCheckData[]> {
|
|
109
|
-
const query = stripUndefined({ ...params }) as Record<
|
|
110
|
-
string,
|
|
111
|
-
string | number | boolean | undefined
|
|
112
|
-
>;
|
|
113
|
-
const data = await this.http.get<unknown>("/health-checks", query);
|
|
114
|
-
return listItems<HealthCheckData>(data);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async get(checkId: string): Promise<HealthCheckData> {
|
|
118
|
-
const data = await this.http.get<unknown>(`/health-checks/${checkId}`);
|
|
119
|
-
return unwrap<HealthCheckData>(data);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
async create(params: HealthCheckCreateParams): Promise<HealthCheckData> {
|
|
123
|
-
const {
|
|
124
|
-
idempotencyKey: ikey,
|
|
125
|
-
intervalSec,
|
|
126
|
-
timeoutSec,
|
|
127
|
-
expectedStatus,
|
|
128
|
-
...rest
|
|
129
|
-
} = params;
|
|
130
|
-
const body = stripUndefined({
|
|
131
|
-
...rest,
|
|
132
|
-
interval_sec: intervalSec ?? rest.interval_sec,
|
|
133
|
-
timeout_sec: timeoutSec ?? rest.timeout_sec,
|
|
134
|
-
expected_status: expectedStatus ?? rest.expected_status,
|
|
135
|
-
});
|
|
136
|
-
const data = await this.http.request<unknown>("/health-checks", {
|
|
137
|
-
method: "POST",
|
|
138
|
-
body,
|
|
139
|
-
headers: { "Idempotency-Key": idempotencyKey(ikey) },
|
|
140
|
-
});
|
|
141
|
-
return unwrap<HealthCheckData>(data);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async update(
|
|
145
|
-
checkId: string,
|
|
146
|
-
params: HealthCheckUpdateParams,
|
|
147
|
-
): Promise<HealthCheckData> {
|
|
148
|
-
const { intervalSec, timeoutSec, expectedStatus, ...rest } = params;
|
|
149
|
-
const body = stripUndefined({
|
|
150
|
-
...rest,
|
|
151
|
-
interval_sec: intervalSec ?? rest.interval_sec,
|
|
152
|
-
timeout_sec: timeoutSec ?? rest.timeout_sec,
|
|
153
|
-
expected_status: expectedStatus ?? rest.expected_status,
|
|
154
|
-
});
|
|
155
|
-
const data = await this.http.patch<unknown>(
|
|
156
|
-
`/health-checks/${checkId}`,
|
|
157
|
-
body,
|
|
158
|
-
);
|
|
159
|
-
return unwrap<HealthCheckData>(data);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
async delete(checkId: string): Promise<void> {
|
|
163
|
-
await this.http.delete<unknown>(`/health-checks/${checkId}`);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Integrations — OAuth account-level connections (GitHub, Slack, Linear, Discord).
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { HttpClient } from "../http.js";
|
|
6
|
-
|
|
7
|
-
// ── Resource shapes ──────────────────────────────────────────────────────────
|
|
8
|
-
|
|
9
|
-
export interface IntegrationData {
|
|
10
|
-
id?: string;
|
|
11
|
-
provider?: string;
|
|
12
|
-
status?: string;
|
|
13
|
-
connected_at?: string;
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface IntegrationCatalogEntry {
|
|
18
|
-
provider?: string;
|
|
19
|
-
name?: string;
|
|
20
|
-
description?: string;
|
|
21
|
-
[key: string]: unknown;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface GithubRepo {
|
|
25
|
-
id?: number;
|
|
26
|
-
name?: string;
|
|
27
|
-
full_name?: string;
|
|
28
|
-
private?: boolean;
|
|
29
|
-
[key: string]: unknown;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface GithubSshKey {
|
|
33
|
-
id?: number;
|
|
34
|
-
title?: string;
|
|
35
|
-
key?: string;
|
|
36
|
-
[key: string]: unknown;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// ── Request payloads ─────────────────────────────────────────────────────────
|
|
40
|
-
|
|
41
|
-
export interface SlackSendTestParams {
|
|
42
|
-
message?: string;
|
|
43
|
-
channel?: string;
|
|
44
|
-
[key: string]: unknown;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface DiscordSendTestParams {
|
|
48
|
-
message?: string;
|
|
49
|
-
channel_id?: string;
|
|
50
|
-
[key: string]: unknown;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface LinearCreateIssueParams {
|
|
54
|
-
title?: string;
|
|
55
|
-
description?: string;
|
|
56
|
-
team_id?: string;
|
|
57
|
-
[key: string]: unknown;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
61
|
-
|
|
62
|
-
function unwrap<T>(payload: unknown): T {
|
|
63
|
-
if (payload && typeof payload === "object") {
|
|
64
|
-
const p = payload as Record<string, unknown>;
|
|
65
|
-
for (const k of ["data", "integrations", "catalog", "items"]) {
|
|
66
|
-
if (k in p) return p[k] as T;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return payload as T;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function listItems<T>(payload: unknown): T[] {
|
|
73
|
-
const result = unwrap<T[] | unknown>(payload);
|
|
74
|
-
if (Array.isArray(result)) return result;
|
|
75
|
-
return [];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function stripUndefined(
|
|
79
|
-
input: Record<string, unknown>,
|
|
80
|
-
): Record<string, unknown> {
|
|
81
|
-
return Object.fromEntries(
|
|
82
|
-
Object.entries(input).filter(([, v]) => v !== undefined),
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// ── Main resource ─────────────────────────────────────────────────────────────
|
|
87
|
-
|
|
88
|
-
export class Integrations {
|
|
89
|
-
constructor(private readonly http: HttpClient) {}
|
|
90
|
-
|
|
91
|
-
/** List active OAuth integrations for the tenant. */
|
|
92
|
-
async list(): Promise<IntegrationData[]> {
|
|
93
|
-
const data = await this.http.get<unknown>("/integrations");
|
|
94
|
-
return listItems<IntegrationData>(data);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** List available providers in the integration catalog. */
|
|
98
|
-
async catalog(): Promise<IntegrationCatalogEntry[]> {
|
|
99
|
-
const data = await this.http.get<unknown>("/integrations/catalog");
|
|
100
|
-
return listItems<IntegrationCatalogEntry>(data);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** Begin the OAuth flow for a provider — returns an authorize URL. */
|
|
104
|
-
async start(provider: string): Promise<Record<string, unknown>> {
|
|
105
|
-
const data = await this.http.get<unknown>(
|
|
106
|
-
`/integrations/${provider}/start`,
|
|
107
|
-
);
|
|
108
|
-
return unwrap<Record<string, unknown>>(data);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** Force-refresh the access token for a provider. */
|
|
112
|
-
async refresh(provider: string): Promise<Record<string, unknown>> {
|
|
113
|
-
const data = await this.http.post<unknown>(
|
|
114
|
-
`/integrations/${provider}/refresh`,
|
|
115
|
-
);
|
|
116
|
-
return unwrap<Record<string, unknown>>(data);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** Disconnect (revoke) an integration. */
|
|
120
|
-
async disconnect(provider: string): Promise<void> {
|
|
121
|
-
await this.http.delete<unknown>(`/integrations/${provider}`);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// ── GitHub-specific capabilities ───────────────────────────────────────────
|
|
125
|
-
|
|
126
|
-
/** List GitHub repositories accessible to this integration. */
|
|
127
|
-
async githubRepos(): Promise<GithubRepo[]> {
|
|
128
|
-
const data = await this.http.get<unknown>("/integrations/github/repos");
|
|
129
|
-
return listItems<GithubRepo>(data);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/** List configured GitHub deploy keys. */
|
|
133
|
-
async githubSshKeys(): Promise<GithubSshKey[]> {
|
|
134
|
-
const data = await this.http.get<unknown>("/integrations/github/ssh-keys");
|
|
135
|
-
return listItems<GithubSshKey>(data);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// ── Test hooks ─────────────────────────────────────────────────────────────
|
|
139
|
-
|
|
140
|
-
/** Send a test message to the connected Slack channel. */
|
|
141
|
-
async slackSendTest(
|
|
142
|
-
params: SlackSendTestParams = {},
|
|
143
|
-
): Promise<Record<string, unknown>> {
|
|
144
|
-
const body = stripUndefined(params as Record<string, unknown>);
|
|
145
|
-
const data = await this.http.post<unknown>(
|
|
146
|
-
"/integrations/slack/send-test",
|
|
147
|
-
body,
|
|
148
|
-
);
|
|
149
|
-
return unwrap<Record<string, unknown>>(data);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/** Send a test message to the connected Discord channel. */
|
|
153
|
-
async discordSendTest(
|
|
154
|
-
params: DiscordSendTestParams = {},
|
|
155
|
-
): Promise<Record<string, unknown>> {
|
|
156
|
-
const body = stripUndefined(params as Record<string, unknown>);
|
|
157
|
-
const data = await this.http.post<unknown>(
|
|
158
|
-
"/integrations/discord/send-test",
|
|
159
|
-
body,
|
|
160
|
-
);
|
|
161
|
-
return unwrap<Record<string, unknown>>(data);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// ── Linear dedicated controller ────────────────────────────────────────────
|
|
165
|
-
|
|
166
|
-
/** Begin Linear OAuth — Linear has provider-specific error shapes. */
|
|
167
|
-
async linearStart(): Promise<Record<string, unknown>> {
|
|
168
|
-
const data = await this.http.get<unknown>("/integrations/linear/start");
|
|
169
|
-
return unwrap<Record<string, unknown>>(data);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/** Create a Linear issue via the connected workspace. */
|
|
173
|
-
async linearCreateIssue(
|
|
174
|
-
params: LinearCreateIssueParams = {},
|
|
175
|
-
): Promise<Record<string, unknown>> {
|
|
176
|
-
const body = stripUndefined(params as Record<string, unknown>);
|
|
177
|
-
const data = await this.http.post<unknown>(
|
|
178
|
-
"/integrations/linear/create-issue",
|
|
179
|
-
body,
|
|
180
|
-
);
|
|
181
|
-
return unwrap<Record<string, unknown>>(data);
|
|
182
|
-
}
|
|
183
|
-
}
|
package/src/resources/mcp.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mcp — Model Context Protocol streamable-HTTP transport.
|
|
3
|
-
*
|
|
4
|
-
* Clients (Claude Code, Cursor, Gemini CLI, Copilot) point at /api/v1/mcp
|
|
5
|
-
* with a msk_* Bearer token and discover the MIOSA tool-belt.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { HttpClient } from "../http.js";
|
|
9
|
-
|
|
10
|
-
// ── Request payloads ─────────────────────────────────────────────────────────
|
|
11
|
-
|
|
12
|
-
export interface McpDispatchParams {
|
|
13
|
-
method?: string;
|
|
14
|
-
params?: Record<string, unknown>;
|
|
15
|
-
[key: string]: unknown;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
19
|
-
|
|
20
|
-
function unwrap<T>(payload: unknown): T {
|
|
21
|
-
if (payload && typeof payload === "object") {
|
|
22
|
-
const p = payload as Record<string, unknown>;
|
|
23
|
-
for (const k of ["data", "mcp", "result", "items"]) {
|
|
24
|
-
if (k in p) return p[k] as T;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return payload as T;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function stripUndefined(
|
|
31
|
-
input: Record<string, unknown>,
|
|
32
|
-
): Record<string, unknown> {
|
|
33
|
-
return Object.fromEntries(
|
|
34
|
-
Object.entries(input).filter(([, v]) => v !== undefined),
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// ── Main resource ─────────────────────────────────────────────────────────────
|
|
39
|
-
|
|
40
|
-
export class Mcp {
|
|
41
|
-
constructor(private readonly http: HttpClient) {}
|
|
42
|
-
|
|
43
|
-
/** Send a JSON-RPC request to the MCP endpoint. */
|
|
44
|
-
async dispatch(
|
|
45
|
-
params: McpDispatchParams = {},
|
|
46
|
-
): Promise<Record<string, unknown>> {
|
|
47
|
-
const body = stripUndefined(params as Record<string, unknown>);
|
|
48
|
-
const data = await this.http.post<unknown>(
|
|
49
|
-
"/mcp",
|
|
50
|
-
Object.keys(body).length > 0 ? body : undefined,
|
|
51
|
-
);
|
|
52
|
-
return unwrap<Record<string, unknown>>(data);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Open the MCP listen channel (GET).
|
|
57
|
-
*
|
|
58
|
-
* Returns whatever the server returns. For true SSE streaming, use
|
|
59
|
-
* `http.stream("/mcp")` directly.
|
|
60
|
-
*/
|
|
61
|
-
async listen(): Promise<unknown> {
|
|
62
|
-
const data = await this.http.get<unknown>("/mcp");
|
|
63
|
-
return unwrap(data);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** Close (terminate) the MCP session. */
|
|
67
|
-
async close(): Promise<void> {
|
|
68
|
-
await this.http.delete<unknown>("/mcp");
|
|
69
|
-
}
|
|
70
|
-
}
|
package/src/resources/models.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Models — list available LLMs across providers.
|
|
3
|
-
*
|
|
4
|
-
* Routes: GET /intelligence/models
|
|
5
|
-
* Requires an mki_* intelligence key or JWT.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { HttpClient } from "../http.js";
|
|
9
|
-
|
|
10
|
-
function unwrap(data: unknown): unknown[] {
|
|
11
|
-
if (Array.isArray(data)) return data;
|
|
12
|
-
if (data && typeof data === "object") {
|
|
13
|
-
const d = data as Record<string, unknown>;
|
|
14
|
-
for (const k of ["data", "models", "items"]) {
|
|
15
|
-
if (Array.isArray(d[k])) return d[k] as unknown[];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class Models {
|
|
22
|
-
constructor(private readonly http: HttpClient) {}
|
|
23
|
-
|
|
24
|
-
/** List all models available to the calling tenant (OpenAI-compatible shape). */
|
|
25
|
-
async list(
|
|
26
|
-
filters: Record<string, string | number | boolean | undefined> = {},
|
|
27
|
-
): Promise<Record<string, unknown>[]> {
|
|
28
|
-
const query = Object.fromEntries(
|
|
29
|
-
Object.entries(filters).filter(([, v]) => v !== undefined),
|
|
30
|
-
) as Record<string, string | number | boolean | undefined>;
|
|
31
|
-
const data = await this.http.get<unknown>("/intelligence/models", query);
|
|
32
|
-
return unwrap(data) as Record<string, unknown>[];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Get a single model by id.
|
|
37
|
-
*
|
|
38
|
-
* The platform router does not expose a per-model GET; this filters
|
|
39
|
-
* the list payload client-side.
|
|
40
|
-
*/
|
|
41
|
-
async get(modelId: string): Promise<Record<string, unknown>> {
|
|
42
|
-
const all = await this.list();
|
|
43
|
-
return all.find((m) => (m as Record<string, unknown>).id === modelId) ?? {};
|
|
44
|
-
}
|
|
45
|
-
}
|