@opencode-ai/sdk 0.0.0-snapshot-kmdr-debug-202512052155 → 0.0.0-snapshot-kmdr-debug-202512081538
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 +1 -1
- package/dist/client.js +7 -6
- package/dist/gen/sdk.gen.d.ts +24 -7
- package/dist/gen/sdk.gen.js +56 -15
- package/dist/gen/types.gen.d.ts +146 -1
- package/dist/v2/client.d.ts +7 -0
- package/dist/v2/client.js +25 -0
- package/dist/v2/gen/client/client.gen.d.ts +2 -0
- package/dist/v2/gen/client/client.gen.js +225 -0
- package/dist/v2/gen/client/index.d.ts +8 -0
- package/dist/v2/gen/client/index.js +6 -0
- package/dist/v2/gen/client/types.gen.d.ts +117 -0
- package/dist/v2/gen/client/types.gen.js +2 -0
- package/dist/v2/gen/client/utils.gen.d.ts +33 -0
- package/dist/v2/gen/client/utils.gen.js +226 -0
- package/dist/v2/gen/client.gen.d.ts +12 -0
- package/dist/v2/gen/client.gen.js +3 -0
- package/dist/v2/gen/core/auth.gen.d.ts +18 -0
- package/dist/v2/gen/core/auth.gen.js +14 -0
- package/dist/v2/gen/core/bodySerializer.gen.d.ts +25 -0
- package/dist/v2/gen/core/bodySerializer.gen.js +57 -0
- package/dist/v2/gen/core/params.gen.d.ts +43 -0
- package/dist/v2/gen/core/params.gen.js +102 -0
- package/dist/v2/gen/core/pathSerializer.gen.d.ts +33 -0
- package/dist/v2/gen/core/pathSerializer.gen.js +106 -0
- package/dist/v2/gen/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/v2/gen/core/queryKeySerializer.gen.js +93 -0
- package/dist/v2/gen/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/v2/gen/core/serverSentEvents.gen.js +131 -0
- package/dist/v2/gen/core/types.gen.d.ts +78 -0
- package/dist/v2/gen/core/types.gen.js +2 -0
- package/dist/v2/gen/core/utils.gen.d.ts +19 -0
- package/dist/v2/gen/core/utils.gen.js +87 -0
- package/dist/v2/gen/sdk.gen.d.ts +836 -0
- package/dist/v2/gen/sdk.gen.js +1590 -0
- package/dist/v2/gen/types.gen.d.ts +3322 -0
- package/dist/v2/gen/types.gen.js +2 -0
- package/dist/v2/index.d.ts +10 -0
- package/dist/v2/index.js +16 -0
- package/dist/v2/server.d.ts +23 -0
- package/dist/v2/server.js +91 -0
- package/package.json +15 -3
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./gen/types.gen.js";
|
|
2
|
-
export { type Config as OpencodeClientConfig, OpencodeClient };
|
|
3
2
|
import { type Config } from "./gen/client/types.gen.js";
|
|
4
3
|
import { OpencodeClient } from "./gen/sdk.gen.js";
|
|
4
|
+
export { type Config as OpencodeClientConfig, OpencodeClient };
|
|
5
5
|
export declare function createOpencodeClient(config?: Config & {
|
|
6
6
|
directory?: string;
|
|
7
7
|
}): OpencodeClient;
|
package/dist/client.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
export * from "./gen/types.gen.js";
|
|
2
|
-
export { OpencodeClient };
|
|
3
2
|
import { createClient } from "./gen/client/client.gen.js";
|
|
4
3
|
import { OpencodeClient } from "./gen/sdk.gen.js";
|
|
4
|
+
export { OpencodeClient };
|
|
5
5
|
export function createOpencodeClient(config) {
|
|
6
6
|
if (!config?.fetch) {
|
|
7
|
+
const customFetch = (req) => {
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
req.timeout = false;
|
|
10
|
+
return fetch(req);
|
|
11
|
+
};
|
|
7
12
|
config = {
|
|
8
13
|
...config,
|
|
9
|
-
fetch:
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
req.timeout = false;
|
|
12
|
-
return fetch(req);
|
|
13
|
-
},
|
|
14
|
+
fetch: customFetch,
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
17
|
if (config?.directory) {
|
package/dist/gen/sdk.gen.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Options as ClientOptions, TDataShape, Client } from "./client/index.js";
|
|
2
|
-
import type { GlobalEventData, GlobalEventResponses, ProjectListData, ProjectListResponses, ProjectCurrentData, ProjectCurrentResponses, PtyListData, PtyListResponses, PtyCreateData, PtyCreateResponses, PtyCreateErrors, PtyRemoveData, PtyRemoveResponses, PtyRemoveErrors, PtyGetData, PtyGetResponses, PtyGetErrors, PtyUpdateData, PtyUpdateResponses, PtyUpdateErrors, PtyConnectData, PtyConnectResponses, PtyConnectErrors, ConfigGetData, ConfigGetResponses, ConfigUpdateData, ConfigUpdateResponses, ConfigUpdateErrors, ToolIdsData, ToolIdsResponses, ToolIdsErrors, ToolListData, ToolListResponses, ToolListErrors, InstanceDisposeData, InstanceDisposeResponses, PathGetData, PathGetResponses, VcsGetData, VcsGetResponses, SessionListData, SessionListResponses, SessionCreateData, SessionCreateResponses, SessionCreateErrors, SessionStatusData, SessionStatusResponses, SessionStatusErrors, SessionDeleteData, SessionDeleteResponses, SessionDeleteErrors, SessionGetData, SessionGetResponses, SessionGetErrors, SessionUpdateData, SessionUpdateResponses, SessionUpdateErrors, SessionChildrenData, SessionChildrenResponses, SessionChildrenErrors, SessionTodoData, SessionTodoResponses, SessionTodoErrors, SessionInitData, SessionInitResponses, SessionInitErrors, SessionForkData, SessionForkResponses, SessionAbortData, SessionAbortResponses, SessionAbortErrors, SessionUnshareData, SessionUnshareResponses, SessionUnshareErrors, SessionShareData, SessionShareResponses, SessionShareErrors, SessionDiffData, SessionDiffResponses, SessionDiffErrors, SessionSummarizeData, SessionSummarizeResponses, SessionSummarizeErrors, SessionMessagesData, SessionMessagesResponses, SessionMessagesErrors, SessionPromptData, SessionPromptResponses, SessionPromptErrors, SessionMessageData, SessionMessageResponses, SessionMessageErrors, SessionPromptAsyncData, SessionPromptAsyncResponses, SessionPromptAsyncErrors, SessionCommandData, SessionCommandResponses, SessionCommandErrors, SessionShellData, SessionShellResponses, SessionShellErrors, SessionRevertData, SessionRevertResponses, SessionRevertErrors, SessionUnrevertData, SessionUnrevertResponses, SessionUnrevertErrors, PostSessionIdPermissionsPermissionIdData, PostSessionIdPermissionsPermissionIdResponses, PostSessionIdPermissionsPermissionIdErrors, CommandListData, CommandListResponses, ConfigProvidersData, ConfigProvidersResponses, ProviderListData, ProviderListResponses, ProviderAuthData, ProviderAuthResponses, ProviderOauthAuthorizeData, ProviderOauthAuthorizeResponses, ProviderOauthAuthorizeErrors, ProviderOauthCallbackData, ProviderOauthCallbackResponses, ProviderOauthCallbackErrors, FindTextData, FindTextResponses, FindFilesData, FindFilesResponses, FindSymbolsData, FindSymbolsResponses, FileListData, FileListResponses, FileReadData, FileReadResponses, FileStatusData, FileStatusResponses, AppLogData, AppLogResponses, AppLogErrors, AppAgentsData, AppAgentsResponses, McpStatusData, McpStatusResponses, McpAddData, McpAddResponses, McpAddErrors, LspStatusData, LspStatusResponses, FormatterStatusData, FormatterStatusResponses, TuiAppendPromptData, TuiAppendPromptResponses, TuiAppendPromptErrors, TuiOpenHelpData, TuiOpenHelpResponses, TuiOpenSessionsData, TuiOpenSessionsResponses, TuiOpenThemesData, TuiOpenThemesResponses, TuiOpenModelsData, TuiOpenModelsResponses, TuiSubmitPromptData, TuiSubmitPromptResponses, TuiClearPromptData, TuiClearPromptResponses, TuiExecuteCommandData, TuiExecuteCommandResponses, TuiExecuteCommandErrors, TuiShowToastData, TuiShowToastResponses, TuiPublishData, TuiPublishResponses, TuiPublishErrors, TuiControlNextData, TuiControlNextResponses, TuiControlResponseData, TuiControlResponseResponses, AuthSetData, AuthSetResponses, AuthSetErrors, EventSubscribeData, EventSubscribeResponses } from "./types.gen.js";
|
|
2
|
+
import type { GlobalEventData, GlobalEventResponses, ProjectListData, ProjectListResponses, ProjectCurrentData, ProjectCurrentResponses, PtyListData, PtyListResponses, PtyCreateData, PtyCreateResponses, PtyCreateErrors, PtyRemoveData, PtyRemoveResponses, PtyRemoveErrors, PtyGetData, PtyGetResponses, PtyGetErrors, PtyUpdateData, PtyUpdateResponses, PtyUpdateErrors, PtyConnectData, PtyConnectResponses, PtyConnectErrors, ConfigGetData, ConfigGetResponses, ConfigUpdateData, ConfigUpdateResponses, ConfigUpdateErrors, ToolIdsData, ToolIdsResponses, ToolIdsErrors, ToolListData, ToolListResponses, ToolListErrors, InstanceDisposeData, InstanceDisposeResponses, PathGetData, PathGetResponses, VcsGetData, VcsGetResponses, SessionListData, SessionListResponses, SessionCreateData, SessionCreateResponses, SessionCreateErrors, SessionStatusData, SessionStatusResponses, SessionStatusErrors, SessionDeleteData, SessionDeleteResponses, SessionDeleteErrors, SessionGetData, SessionGetResponses, SessionGetErrors, SessionUpdateData, SessionUpdateResponses, SessionUpdateErrors, SessionChildrenData, SessionChildrenResponses, SessionChildrenErrors, SessionTodoData, SessionTodoResponses, SessionTodoErrors, SessionInitData, SessionInitResponses, SessionInitErrors, SessionForkData, SessionForkResponses, SessionAbortData, SessionAbortResponses, SessionAbortErrors, SessionUnshareData, SessionUnshareResponses, SessionUnshareErrors, SessionShareData, SessionShareResponses, SessionShareErrors, SessionDiffData, SessionDiffResponses, SessionDiffErrors, SessionSummarizeData, SessionSummarizeResponses, SessionSummarizeErrors, SessionMessagesData, SessionMessagesResponses, SessionMessagesErrors, SessionPromptData, SessionPromptResponses, SessionPromptErrors, SessionMessageData, SessionMessageResponses, SessionMessageErrors, SessionPromptAsyncData, SessionPromptAsyncResponses, SessionPromptAsyncErrors, SessionCommandData, SessionCommandResponses, SessionCommandErrors, SessionShellData, SessionShellResponses, SessionShellErrors, SessionRevertData, SessionRevertResponses, SessionRevertErrors, SessionUnrevertData, SessionUnrevertResponses, SessionUnrevertErrors, PostSessionIdPermissionsPermissionIdData, PostSessionIdPermissionsPermissionIdResponses, PostSessionIdPermissionsPermissionIdErrors, CommandListData, CommandListResponses, ConfigProvidersData, ConfigProvidersResponses, ProviderListData, ProviderListResponses, ProviderAuthData, ProviderAuthResponses, ProviderOauthAuthorizeData, ProviderOauthAuthorizeResponses, ProviderOauthAuthorizeErrors, ProviderOauthCallbackData, ProviderOauthCallbackResponses, ProviderOauthCallbackErrors, FindTextData, FindTextResponses, FindFilesData, FindFilesResponses, FindSymbolsData, FindSymbolsResponses, FileListData, FileListResponses, FileReadData, FileReadResponses, FileStatusData, FileStatusResponses, AppLogData, AppLogResponses, AppLogErrors, AppAgentsData, AppAgentsResponses, McpStatusData, McpStatusResponses, McpAddData, McpAddResponses, McpAddErrors, McpAuthRemoveData, McpAuthRemoveResponses, McpAuthRemoveErrors, McpAuthStartData, McpAuthStartResponses, McpAuthStartErrors, McpAuthCallbackData, McpAuthCallbackResponses, McpAuthCallbackErrors, McpAuthAuthenticateData, McpAuthAuthenticateResponses, McpAuthAuthenticateErrors, LspStatusData, LspStatusResponses, FormatterStatusData, FormatterStatusResponses, TuiAppendPromptData, TuiAppendPromptResponses, TuiAppendPromptErrors, TuiOpenHelpData, TuiOpenHelpResponses, TuiOpenSessionsData, TuiOpenSessionsResponses, TuiOpenThemesData, TuiOpenThemesResponses, TuiOpenModelsData, TuiOpenModelsResponses, TuiSubmitPromptData, TuiSubmitPromptResponses, TuiClearPromptData, TuiClearPromptResponses, TuiExecuteCommandData, TuiExecuteCommandResponses, TuiExecuteCommandErrors, TuiShowToastData, TuiShowToastResponses, TuiPublishData, TuiPublishResponses, TuiPublishErrors, TuiControlNextData, TuiControlNextResponses, TuiControlResponseData, TuiControlResponseResponses, AuthSetData, AuthSetResponses, AuthSetErrors, EventSubscribeData, EventSubscribeResponses } from "./types.gen.js";
|
|
3
3
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
|
|
4
4
|
/**
|
|
5
5
|
* You can provide a client instance returned by `createClient()` instead of
|
|
@@ -262,6 +262,28 @@ declare class App extends _HeyApiClient {
|
|
|
262
262
|
*/
|
|
263
263
|
agents<ThrowOnError extends boolean = false>(options?: Options<AppAgentsData, ThrowOnError>): import("./client/types.gen.js").RequestResult<AppAgentsResponses, unknown, ThrowOnError, "fields">;
|
|
264
264
|
}
|
|
265
|
+
declare class Auth extends _HeyApiClient {
|
|
266
|
+
/**
|
|
267
|
+
* Remove OAuth credentials for an MCP server
|
|
268
|
+
*/
|
|
269
|
+
remove<ThrowOnError extends boolean = false>(options: Options<McpAuthRemoveData, ThrowOnError>): import("./client/types.gen.js").RequestResult<McpAuthRemoveResponses, McpAuthRemoveErrors, ThrowOnError, "fields">;
|
|
270
|
+
/**
|
|
271
|
+
* Start OAuth authentication flow for an MCP server
|
|
272
|
+
*/
|
|
273
|
+
start<ThrowOnError extends boolean = false>(options: Options<McpAuthStartData, ThrowOnError>): import("./client/types.gen.js").RequestResult<McpAuthStartResponses, McpAuthStartErrors, ThrowOnError, "fields">;
|
|
274
|
+
/**
|
|
275
|
+
* Complete OAuth authentication with authorization code
|
|
276
|
+
*/
|
|
277
|
+
callback<ThrowOnError extends boolean = false>(options: Options<McpAuthCallbackData, ThrowOnError>): import("./client/types.gen.js").RequestResult<McpAuthCallbackResponses, McpAuthCallbackErrors, ThrowOnError, "fields">;
|
|
278
|
+
/**
|
|
279
|
+
* Start OAuth flow and wait for callback (opens browser)
|
|
280
|
+
*/
|
|
281
|
+
authenticate<ThrowOnError extends boolean = false>(options: Options<McpAuthAuthenticateData, ThrowOnError>): import("./client/types.gen.js").RequestResult<McpAuthAuthenticateResponses, McpAuthAuthenticateErrors, ThrowOnError, "fields">;
|
|
282
|
+
/**
|
|
283
|
+
* Set authentication credentials
|
|
284
|
+
*/
|
|
285
|
+
set<ThrowOnError extends boolean = false>(options: Options<AuthSetData, ThrowOnError>): import("./client/types.gen.js").RequestResult<AuthSetResponses, AuthSetErrors, ThrowOnError, "fields">;
|
|
286
|
+
}
|
|
265
287
|
declare class Mcp extends _HeyApiClient {
|
|
266
288
|
/**
|
|
267
289
|
* Get MCP server status
|
|
@@ -271,6 +293,7 @@ declare class Mcp extends _HeyApiClient {
|
|
|
271
293
|
* Add MCP server dynamically
|
|
272
294
|
*/
|
|
273
295
|
add<ThrowOnError extends boolean = false>(options?: Options<McpAddData, ThrowOnError>): import("./client/types.gen.js").RequestResult<McpAddResponses, McpAddErrors, ThrowOnError, "fields">;
|
|
296
|
+
auth: Auth;
|
|
274
297
|
}
|
|
275
298
|
declare class Lsp extends _HeyApiClient {
|
|
276
299
|
/**
|
|
@@ -337,12 +360,6 @@ declare class Tui extends _HeyApiClient {
|
|
|
337
360
|
publish<ThrowOnError extends boolean = false>(options?: Options<TuiPublishData, ThrowOnError>): import("./client/types.gen.js").RequestResult<TuiPublishResponses, TuiPublishErrors, ThrowOnError, "fields">;
|
|
338
361
|
control: Control;
|
|
339
362
|
}
|
|
340
|
-
declare class Auth extends _HeyApiClient {
|
|
341
|
-
/**
|
|
342
|
-
* Set authentication credentials
|
|
343
|
-
*/
|
|
344
|
-
set<ThrowOnError extends boolean = false>(options: Options<AuthSetData, ThrowOnError>): import("./client/types.gen.js").RequestResult<AuthSetResponses, AuthSetErrors, ThrowOnError, "fields">;
|
|
345
|
-
}
|
|
346
363
|
declare class Event extends _HeyApiClient {
|
|
347
364
|
/**
|
|
348
365
|
* Get events
|
package/dist/gen/sdk.gen.js
CHANGED
|
@@ -580,6 +580,61 @@ class App extends _HeyApiClient {
|
|
|
580
580
|
});
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
|
+
class Auth extends _HeyApiClient {
|
|
584
|
+
/**
|
|
585
|
+
* Remove OAuth credentials for an MCP server
|
|
586
|
+
*/
|
|
587
|
+
remove(options) {
|
|
588
|
+
return (options.client ?? this._client).delete({
|
|
589
|
+
url: "/mcp/{name}/auth",
|
|
590
|
+
...options,
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Start OAuth authentication flow for an MCP server
|
|
595
|
+
*/
|
|
596
|
+
start(options) {
|
|
597
|
+
return (options.client ?? this._client).post({
|
|
598
|
+
url: "/mcp/{name}/auth",
|
|
599
|
+
...options,
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Complete OAuth authentication with authorization code
|
|
604
|
+
*/
|
|
605
|
+
callback(options) {
|
|
606
|
+
return (options.client ?? this._client).post({
|
|
607
|
+
url: "/mcp/{name}/auth/callback",
|
|
608
|
+
...options,
|
|
609
|
+
headers: {
|
|
610
|
+
"Content-Type": "application/json",
|
|
611
|
+
...options.headers,
|
|
612
|
+
},
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Start OAuth flow and wait for callback (opens browser)
|
|
617
|
+
*/
|
|
618
|
+
authenticate(options) {
|
|
619
|
+
return (options.client ?? this._client).post({
|
|
620
|
+
url: "/mcp/{name}/auth/authenticate",
|
|
621
|
+
...options,
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Set authentication credentials
|
|
626
|
+
*/
|
|
627
|
+
set(options) {
|
|
628
|
+
return (options.client ?? this._client).put({
|
|
629
|
+
url: "/auth/{id}",
|
|
630
|
+
...options,
|
|
631
|
+
headers: {
|
|
632
|
+
"Content-Type": "application/json",
|
|
633
|
+
...options.headers,
|
|
634
|
+
},
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
}
|
|
583
638
|
class Mcp extends _HeyApiClient {
|
|
584
639
|
/**
|
|
585
640
|
* Get MCP server status
|
|
@@ -603,6 +658,7 @@ class Mcp extends _HeyApiClient {
|
|
|
603
658
|
},
|
|
604
659
|
});
|
|
605
660
|
}
|
|
661
|
+
auth = new Auth({ client: this._client });
|
|
606
662
|
}
|
|
607
663
|
class Lsp extends _HeyApiClient {
|
|
608
664
|
/**
|
|
@@ -759,21 +815,6 @@ class Tui extends _HeyApiClient {
|
|
|
759
815
|
}
|
|
760
816
|
control = new Control({ client: this._client });
|
|
761
817
|
}
|
|
762
|
-
class Auth extends _HeyApiClient {
|
|
763
|
-
/**
|
|
764
|
-
* Set authentication credentials
|
|
765
|
-
*/
|
|
766
|
-
set(options) {
|
|
767
|
-
return (options.client ?? this._client).put({
|
|
768
|
-
url: "/auth/{id}",
|
|
769
|
-
...options,
|
|
770
|
-
headers: {
|
|
771
|
-
"Content-Type": "application/json",
|
|
772
|
-
...options.headers,
|
|
773
|
-
},
|
|
774
|
-
});
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
818
|
class Event extends _HeyApiClient {
|
|
778
819
|
/**
|
|
779
820
|
* Get events
|
package/dist/gen/types.gen.d.ts
CHANGED
|
@@ -947,6 +947,20 @@ export type McpLocalConfig = {
|
|
|
947
947
|
*/
|
|
948
948
|
timeout?: number;
|
|
949
949
|
};
|
|
950
|
+
export type McpOAuthConfig = {
|
|
951
|
+
/**
|
|
952
|
+
* OAuth client ID. If not provided, dynamic client registration (RFC 7591) will be attempted.
|
|
953
|
+
*/
|
|
954
|
+
clientId?: string;
|
|
955
|
+
/**
|
|
956
|
+
* OAuth client secret (if required by the authorization server)
|
|
957
|
+
*/
|
|
958
|
+
clientSecret?: string;
|
|
959
|
+
/**
|
|
960
|
+
* OAuth scopes to request during authorization
|
|
961
|
+
*/
|
|
962
|
+
scope?: string;
|
|
963
|
+
};
|
|
950
964
|
export type McpRemoteConfig = {
|
|
951
965
|
/**
|
|
952
966
|
* Type of MCP server connection
|
|
@@ -966,6 +980,10 @@ export type McpRemoteConfig = {
|
|
|
966
980
|
headers?: {
|
|
967
981
|
[key: string]: string;
|
|
968
982
|
};
|
|
983
|
+
/**
|
|
984
|
+
* OAuth authentication configuration for the MCP server. Set to false to disable OAuth auto-detection.
|
|
985
|
+
*/
|
|
986
|
+
oauth?: McpOAuthConfig | false;
|
|
969
987
|
/**
|
|
970
988
|
* Timeout in ms for fetching tools from the MCP server. Defaults to 5000 (5 seconds) if not specified.
|
|
971
989
|
*/
|
|
@@ -1394,7 +1412,14 @@ export type McpStatusFailed = {
|
|
|
1394
1412
|
status: "failed";
|
|
1395
1413
|
error: string;
|
|
1396
1414
|
};
|
|
1397
|
-
export type
|
|
1415
|
+
export type McpStatusNeedsAuth = {
|
|
1416
|
+
status: "needs_auth";
|
|
1417
|
+
};
|
|
1418
|
+
export type McpStatusNeedsClientRegistration = {
|
|
1419
|
+
status: "needs_client_registration";
|
|
1420
|
+
error: string;
|
|
1421
|
+
};
|
|
1422
|
+
export type McpStatus = McpStatusConnected | McpStatusDisabled | McpStatusFailed | McpStatusNeedsAuth | McpStatusNeedsClientRegistration;
|
|
1398
1423
|
export type LspStatus = {
|
|
1399
1424
|
id: string;
|
|
1400
1425
|
name: string;
|
|
@@ -2887,6 +2912,126 @@ export type McpAddResponses = {
|
|
|
2887
2912
|
};
|
|
2888
2913
|
};
|
|
2889
2914
|
export type McpAddResponse = McpAddResponses[keyof McpAddResponses];
|
|
2915
|
+
export type McpAuthRemoveData = {
|
|
2916
|
+
body?: never;
|
|
2917
|
+
path: {
|
|
2918
|
+
name: string;
|
|
2919
|
+
};
|
|
2920
|
+
query?: {
|
|
2921
|
+
directory?: string;
|
|
2922
|
+
};
|
|
2923
|
+
url: "/mcp/{name}/auth";
|
|
2924
|
+
};
|
|
2925
|
+
export type McpAuthRemoveErrors = {
|
|
2926
|
+
/**
|
|
2927
|
+
* Not found
|
|
2928
|
+
*/
|
|
2929
|
+
404: NotFoundError;
|
|
2930
|
+
};
|
|
2931
|
+
export type McpAuthRemoveError = McpAuthRemoveErrors[keyof McpAuthRemoveErrors];
|
|
2932
|
+
export type McpAuthRemoveResponses = {
|
|
2933
|
+
/**
|
|
2934
|
+
* OAuth credentials removed
|
|
2935
|
+
*/
|
|
2936
|
+
200: {
|
|
2937
|
+
success: true;
|
|
2938
|
+
};
|
|
2939
|
+
};
|
|
2940
|
+
export type McpAuthRemoveResponse = McpAuthRemoveResponses[keyof McpAuthRemoveResponses];
|
|
2941
|
+
export type McpAuthStartData = {
|
|
2942
|
+
body?: never;
|
|
2943
|
+
path: {
|
|
2944
|
+
name: string;
|
|
2945
|
+
};
|
|
2946
|
+
query?: {
|
|
2947
|
+
directory?: string;
|
|
2948
|
+
};
|
|
2949
|
+
url: "/mcp/{name}/auth";
|
|
2950
|
+
};
|
|
2951
|
+
export type McpAuthStartErrors = {
|
|
2952
|
+
/**
|
|
2953
|
+
* Bad request
|
|
2954
|
+
*/
|
|
2955
|
+
400: BadRequestError;
|
|
2956
|
+
/**
|
|
2957
|
+
* Not found
|
|
2958
|
+
*/
|
|
2959
|
+
404: NotFoundError;
|
|
2960
|
+
};
|
|
2961
|
+
export type McpAuthStartError = McpAuthStartErrors[keyof McpAuthStartErrors];
|
|
2962
|
+
export type McpAuthStartResponses = {
|
|
2963
|
+
/**
|
|
2964
|
+
* OAuth flow started
|
|
2965
|
+
*/
|
|
2966
|
+
200: {
|
|
2967
|
+
/**
|
|
2968
|
+
* URL to open in browser for authorization
|
|
2969
|
+
*/
|
|
2970
|
+
authorizationUrl: string;
|
|
2971
|
+
};
|
|
2972
|
+
};
|
|
2973
|
+
export type McpAuthStartResponse = McpAuthStartResponses[keyof McpAuthStartResponses];
|
|
2974
|
+
export type McpAuthCallbackData = {
|
|
2975
|
+
body?: {
|
|
2976
|
+
/**
|
|
2977
|
+
* Authorization code from OAuth callback
|
|
2978
|
+
*/
|
|
2979
|
+
code: string;
|
|
2980
|
+
};
|
|
2981
|
+
path: {
|
|
2982
|
+
name: string;
|
|
2983
|
+
};
|
|
2984
|
+
query?: {
|
|
2985
|
+
directory?: string;
|
|
2986
|
+
};
|
|
2987
|
+
url: "/mcp/{name}/auth/callback";
|
|
2988
|
+
};
|
|
2989
|
+
export type McpAuthCallbackErrors = {
|
|
2990
|
+
/**
|
|
2991
|
+
* Bad request
|
|
2992
|
+
*/
|
|
2993
|
+
400: BadRequestError;
|
|
2994
|
+
/**
|
|
2995
|
+
* Not found
|
|
2996
|
+
*/
|
|
2997
|
+
404: NotFoundError;
|
|
2998
|
+
};
|
|
2999
|
+
export type McpAuthCallbackError = McpAuthCallbackErrors[keyof McpAuthCallbackErrors];
|
|
3000
|
+
export type McpAuthCallbackResponses = {
|
|
3001
|
+
/**
|
|
3002
|
+
* OAuth authentication completed
|
|
3003
|
+
*/
|
|
3004
|
+
200: McpStatus;
|
|
3005
|
+
};
|
|
3006
|
+
export type McpAuthCallbackResponse = McpAuthCallbackResponses[keyof McpAuthCallbackResponses];
|
|
3007
|
+
export type McpAuthAuthenticateData = {
|
|
3008
|
+
body?: never;
|
|
3009
|
+
path: {
|
|
3010
|
+
name: string;
|
|
3011
|
+
};
|
|
3012
|
+
query?: {
|
|
3013
|
+
directory?: string;
|
|
3014
|
+
};
|
|
3015
|
+
url: "/mcp/{name}/auth/authenticate";
|
|
3016
|
+
};
|
|
3017
|
+
export type McpAuthAuthenticateErrors = {
|
|
3018
|
+
/**
|
|
3019
|
+
* Bad request
|
|
3020
|
+
*/
|
|
3021
|
+
400: BadRequestError;
|
|
3022
|
+
/**
|
|
3023
|
+
* Not found
|
|
3024
|
+
*/
|
|
3025
|
+
404: NotFoundError;
|
|
3026
|
+
};
|
|
3027
|
+
export type McpAuthAuthenticateError = McpAuthAuthenticateErrors[keyof McpAuthAuthenticateErrors];
|
|
3028
|
+
export type McpAuthAuthenticateResponses = {
|
|
3029
|
+
/**
|
|
3030
|
+
* OAuth authentication completed
|
|
3031
|
+
*/
|
|
3032
|
+
200: McpStatus;
|
|
3033
|
+
};
|
|
3034
|
+
export type McpAuthAuthenticateResponse = McpAuthAuthenticateResponses[keyof McpAuthAuthenticateResponses];
|
|
2890
3035
|
export type LspStatusData = {
|
|
2891
3036
|
body?: never;
|
|
2892
3037
|
path?: never;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./gen/types.gen.js";
|
|
2
|
+
import { type Config } from "./gen/client/types.gen.js";
|
|
3
|
+
import { OpencodeClient } from "./gen/sdk.gen.js";
|
|
4
|
+
export { type Config as OpencodeClientConfig, OpencodeClient };
|
|
5
|
+
export declare function createOpencodeClient(config?: Config & {
|
|
6
|
+
directory?: string;
|
|
7
|
+
}): OpencodeClient;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export * from "./gen/types.gen.js";
|
|
2
|
+
import { createClient } from "./gen/client/client.gen.js";
|
|
3
|
+
import { OpencodeClient } from "./gen/sdk.gen.js";
|
|
4
|
+
export { OpencodeClient };
|
|
5
|
+
export function createOpencodeClient(config) {
|
|
6
|
+
if (!config?.fetch) {
|
|
7
|
+
const customFetch = (req) => {
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
req.timeout = false;
|
|
10
|
+
return fetch(req);
|
|
11
|
+
};
|
|
12
|
+
config = {
|
|
13
|
+
...config,
|
|
14
|
+
fetch: customFetch,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
if (config?.directory) {
|
|
18
|
+
config.headers = {
|
|
19
|
+
...config.headers,
|
|
20
|
+
"x-opencode-directory": config.directory,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const client = createClient(config);
|
|
24
|
+
return new OpencodeClient({ client });
|
|
25
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
import { createSseClient } from "../core/serverSentEvents.gen.js";
|
|
3
|
+
import { getValidRequestBody } from "../core/utils.gen.js";
|
|
4
|
+
import { buildUrl, createConfig, createInterceptors, getParseAs, mergeConfigs, mergeHeaders, setAuthParams, } from "./utils.gen.js";
|
|
5
|
+
export const createClient = (config = {}) => {
|
|
6
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
7
|
+
const getConfig = () => ({ ..._config });
|
|
8
|
+
const setConfig = (config) => {
|
|
9
|
+
_config = mergeConfigs(_config, config);
|
|
10
|
+
return getConfig();
|
|
11
|
+
};
|
|
12
|
+
const interceptors = createInterceptors();
|
|
13
|
+
const beforeRequest = async (options) => {
|
|
14
|
+
const opts = {
|
|
15
|
+
..._config,
|
|
16
|
+
...options,
|
|
17
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
18
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
19
|
+
serializedBody: undefined,
|
|
20
|
+
};
|
|
21
|
+
if (opts.security) {
|
|
22
|
+
await setAuthParams({
|
|
23
|
+
...opts,
|
|
24
|
+
security: opts.security,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (opts.requestValidator) {
|
|
28
|
+
await opts.requestValidator(opts);
|
|
29
|
+
}
|
|
30
|
+
if (opts.body !== undefined && opts.bodySerializer) {
|
|
31
|
+
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
32
|
+
}
|
|
33
|
+
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
34
|
+
if (opts.body === undefined || opts.serializedBody === "") {
|
|
35
|
+
opts.headers.delete("Content-Type");
|
|
36
|
+
}
|
|
37
|
+
const url = buildUrl(opts);
|
|
38
|
+
return { opts, url };
|
|
39
|
+
};
|
|
40
|
+
const request = async (options) => {
|
|
41
|
+
// @ts-expect-error
|
|
42
|
+
const { opts, url } = await beforeRequest(options);
|
|
43
|
+
const requestInit = {
|
|
44
|
+
redirect: "follow",
|
|
45
|
+
...opts,
|
|
46
|
+
body: getValidRequestBody(opts),
|
|
47
|
+
};
|
|
48
|
+
let request = new Request(url, requestInit);
|
|
49
|
+
for (const fn of interceptors.request.fns) {
|
|
50
|
+
if (fn) {
|
|
51
|
+
request = await fn(request, opts);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// fetch must be assigned here, otherwise it would throw the error:
|
|
55
|
+
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
56
|
+
const _fetch = opts.fetch;
|
|
57
|
+
let response;
|
|
58
|
+
try {
|
|
59
|
+
response = await _fetch(request);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
// Handle fetch exceptions (AbortError, network errors, etc.)
|
|
63
|
+
let finalError = error;
|
|
64
|
+
for (const fn of interceptors.error.fns) {
|
|
65
|
+
if (fn) {
|
|
66
|
+
finalError = (await fn(error, undefined, request, opts));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
finalError = finalError || {};
|
|
70
|
+
if (opts.throwOnError) {
|
|
71
|
+
throw finalError;
|
|
72
|
+
}
|
|
73
|
+
// Return error response
|
|
74
|
+
return opts.responseStyle === "data"
|
|
75
|
+
? undefined
|
|
76
|
+
: {
|
|
77
|
+
error: finalError,
|
|
78
|
+
request,
|
|
79
|
+
response: undefined,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
for (const fn of interceptors.response.fns) {
|
|
83
|
+
if (fn) {
|
|
84
|
+
response = await fn(response, request, opts);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const result = {
|
|
88
|
+
request,
|
|
89
|
+
response,
|
|
90
|
+
};
|
|
91
|
+
if (response.ok) {
|
|
92
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
93
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
94
|
+
let emptyData;
|
|
95
|
+
switch (parseAs) {
|
|
96
|
+
case "arrayBuffer":
|
|
97
|
+
case "blob":
|
|
98
|
+
case "text":
|
|
99
|
+
emptyData = await response[parseAs]();
|
|
100
|
+
break;
|
|
101
|
+
case "formData":
|
|
102
|
+
emptyData = new FormData();
|
|
103
|
+
break;
|
|
104
|
+
case "stream":
|
|
105
|
+
emptyData = response.body;
|
|
106
|
+
break;
|
|
107
|
+
case "json":
|
|
108
|
+
default:
|
|
109
|
+
emptyData = {};
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
return opts.responseStyle === "data"
|
|
113
|
+
? emptyData
|
|
114
|
+
: {
|
|
115
|
+
data: emptyData,
|
|
116
|
+
...result,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
let data;
|
|
120
|
+
switch (parseAs) {
|
|
121
|
+
case "arrayBuffer":
|
|
122
|
+
case "blob":
|
|
123
|
+
case "formData":
|
|
124
|
+
case "json":
|
|
125
|
+
case "text":
|
|
126
|
+
data = await response[parseAs]();
|
|
127
|
+
break;
|
|
128
|
+
case "stream":
|
|
129
|
+
return opts.responseStyle === "data"
|
|
130
|
+
? response.body
|
|
131
|
+
: {
|
|
132
|
+
data: response.body,
|
|
133
|
+
...result,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (parseAs === "json") {
|
|
137
|
+
if (opts.responseValidator) {
|
|
138
|
+
await opts.responseValidator(data);
|
|
139
|
+
}
|
|
140
|
+
if (opts.responseTransformer) {
|
|
141
|
+
data = await opts.responseTransformer(data);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return opts.responseStyle === "data"
|
|
145
|
+
? data
|
|
146
|
+
: {
|
|
147
|
+
data,
|
|
148
|
+
...result,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
const textError = await response.text();
|
|
152
|
+
let jsonError;
|
|
153
|
+
try {
|
|
154
|
+
jsonError = JSON.parse(textError);
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
// noop
|
|
158
|
+
}
|
|
159
|
+
const error = jsonError ?? textError;
|
|
160
|
+
let finalError = error;
|
|
161
|
+
for (const fn of interceptors.error.fns) {
|
|
162
|
+
if (fn) {
|
|
163
|
+
finalError = (await fn(error, response, request, opts));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
finalError = finalError || {};
|
|
167
|
+
if (opts.throwOnError) {
|
|
168
|
+
throw finalError;
|
|
169
|
+
}
|
|
170
|
+
// TODO: we probably want to return error and improve types
|
|
171
|
+
return opts.responseStyle === "data"
|
|
172
|
+
? undefined
|
|
173
|
+
: {
|
|
174
|
+
error: finalError,
|
|
175
|
+
...result,
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
179
|
+
const makeSseFn = (method) => async (options) => {
|
|
180
|
+
const { opts, url } = await beforeRequest(options);
|
|
181
|
+
return createSseClient({
|
|
182
|
+
...opts,
|
|
183
|
+
body: opts.body,
|
|
184
|
+
headers: opts.headers,
|
|
185
|
+
method,
|
|
186
|
+
onRequest: async (url, init) => {
|
|
187
|
+
let request = new Request(url, init);
|
|
188
|
+
for (const fn of interceptors.request.fns) {
|
|
189
|
+
if (fn) {
|
|
190
|
+
request = await fn(request, opts);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return request;
|
|
194
|
+
},
|
|
195
|
+
url,
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
return {
|
|
199
|
+
buildUrl,
|
|
200
|
+
connect: makeMethodFn("CONNECT"),
|
|
201
|
+
delete: makeMethodFn("DELETE"),
|
|
202
|
+
get: makeMethodFn("GET"),
|
|
203
|
+
getConfig,
|
|
204
|
+
head: makeMethodFn("HEAD"),
|
|
205
|
+
interceptors,
|
|
206
|
+
options: makeMethodFn("OPTIONS"),
|
|
207
|
+
patch: makeMethodFn("PATCH"),
|
|
208
|
+
post: makeMethodFn("POST"),
|
|
209
|
+
put: makeMethodFn("PUT"),
|
|
210
|
+
request,
|
|
211
|
+
setConfig,
|
|
212
|
+
sse: {
|
|
213
|
+
connect: makeSseFn("CONNECT"),
|
|
214
|
+
delete: makeSseFn("DELETE"),
|
|
215
|
+
get: makeSseFn("GET"),
|
|
216
|
+
head: makeSseFn("HEAD"),
|
|
217
|
+
options: makeSseFn("OPTIONS"),
|
|
218
|
+
patch: makeSseFn("PATCH"),
|
|
219
|
+
post: makeSseFn("POST"),
|
|
220
|
+
put: makeSseFn("PUT"),
|
|
221
|
+
trace: makeSseFn("TRACE"),
|
|
222
|
+
},
|
|
223
|
+
trace: makeMethodFn("TRACE"),
|
|
224
|
+
};
|
|
225
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { Auth } from "../core/auth.gen.js";
|
|
2
|
+
export type { QuerySerializerOptions } from "../core/bodySerializer.gen.js";
|
|
3
|
+
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from "../core/bodySerializer.gen.js";
|
|
4
|
+
export { buildClientParams } from "../core/params.gen.js";
|
|
5
|
+
export { serializeQueryKeyValue } from "../core/queryKeySerializer.gen.js";
|
|
6
|
+
export { createClient } from "./client.gen.js";
|
|
7
|
+
export type { Client, ClientOptions, Config, CreateClientConfig, Options, RequestOptions, RequestResult, ResolvedRequestOptions, ResponseStyle, TDataShape, } from "./types.gen.js";
|
|
8
|
+
export { createConfig, mergeHeaders } from "./utils.gen.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from "../core/bodySerializer.gen.js";
|
|
3
|
+
export { buildClientParams } from "../core/params.gen.js";
|
|
4
|
+
export { serializeQueryKeyValue } from "../core/queryKeySerializer.gen.js";
|
|
5
|
+
export { createClient } from "./client.gen.js";
|
|
6
|
+
export { createConfig, mergeHeaders } from "./utils.gen.js";
|