@itssimplereally/opencode-kimicode-auth 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 +22 -0
- package/README.md +87 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/src/constants.d.ts +69 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +207 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/kimi/oauth.d.ts +64 -0
- package/dist/src/kimi/oauth.d.ts.map +1 -0
- package/dist/src/kimi/oauth.js +130 -0
- package/dist/src/kimi/oauth.js.map +1 -0
- package/dist/src/plugin/accounts.d.ts +167 -0
- package/dist/src/plugin/accounts.d.ts.map +1 -0
- package/dist/src/plugin/accounts.js +843 -0
- package/dist/src/plugin/accounts.js.map +1 -0
- package/dist/src/plugin/auth.d.ts +13 -0
- package/dist/src/plugin/auth.d.ts.map +1 -0
- package/dist/src/plugin/auth.js +26 -0
- package/dist/src/plugin/auth.js.map +1 -0
- package/dist/src/plugin/cache.d.ts +14 -0
- package/dist/src/plugin/cache.d.ts.map +1 -0
- package/dist/src/plugin/cache.js +56 -0
- package/dist/src/plugin/cache.js.map +1 -0
- package/dist/src/plugin/cli.d.ts +21 -0
- package/dist/src/plugin/cli.d.ts.map +1 -0
- package/dist/src/plugin/cli.js +98 -0
- package/dist/src/plugin/cli.js.map +1 -0
- package/dist/src/plugin/config/index.d.ts +16 -0
- package/dist/src/plugin/config/index.d.ts.map +1 -0
- package/dist/src/plugin/config/index.js +16 -0
- package/dist/src/plugin/config/index.js.map +1 -0
- package/dist/src/plugin/config/loader.d.ts +36 -0
- package/dist/src/plugin/config/loader.d.ts.map +1 -0
- package/dist/src/plugin/config/loader.js +182 -0
- package/dist/src/plugin/config/loader.js.map +1 -0
- package/dist/src/plugin/config/models.d.ts +18 -0
- package/dist/src/plugin/config/models.d.ts.map +1 -0
- package/dist/src/plugin/config/models.js +26 -0
- package/dist/src/plugin/config/models.js.map +1 -0
- package/dist/src/plugin/config/schema.d.ts +107 -0
- package/dist/src/plugin/config/schema.d.ts.map +1 -0
- package/dist/src/plugin/config/schema.js +282 -0
- package/dist/src/plugin/config/schema.js.map +1 -0
- package/dist/src/plugin/config/updater.d.ts +55 -0
- package/dist/src/plugin/config/updater.d.ts.map +1 -0
- package/dist/src/plugin/config/updater.js +154 -0
- package/dist/src/plugin/config/updater.js.map +1 -0
- package/dist/src/plugin/debug.d.ts +92 -0
- package/dist/src/plugin/debug.d.ts.map +1 -0
- package/dist/src/plugin/debug.js +406 -0
- package/dist/src/plugin/debug.js.map +1 -0
- package/dist/src/plugin/errors.d.ts +28 -0
- package/dist/src/plugin/errors.d.ts.map +1 -0
- package/dist/src/plugin/errors.js +42 -0
- package/dist/src/plugin/errors.js.map +1 -0
- package/dist/src/plugin/fingerprint.d.ts +41 -0
- package/dist/src/plugin/fingerprint.d.ts.map +1 -0
- package/dist/src/plugin/fingerprint.js +94 -0
- package/dist/src/plugin/fingerprint.js.map +1 -0
- package/dist/src/plugin/logger.d.ts +54 -0
- package/dist/src/plugin/logger.d.ts.map +1 -0
- package/dist/src/plugin/logger.js +120 -0
- package/dist/src/plugin/logger.js.map +1 -0
- package/dist/src/plugin/recovery/constants.d.ts +26 -0
- package/dist/src/plugin/recovery/constants.d.ts.map +1 -0
- package/dist/src/plugin/recovery/constants.js +47 -0
- package/dist/src/plugin/recovery/constants.js.map +1 -0
- package/dist/src/plugin/recovery/index.d.ts +16 -0
- package/dist/src/plugin/recovery/index.d.ts.map +1 -0
- package/dist/src/plugin/recovery/index.js +16 -0
- package/dist/src/plugin/recovery/index.js.map +1 -0
- package/dist/src/plugin/recovery/storage.d.ts +24 -0
- package/dist/src/plugin/recovery/storage.d.ts.map +1 -0
- package/dist/src/plugin/recovery/storage.js +354 -0
- package/dist/src/plugin/recovery/storage.js.map +1 -0
- package/dist/src/plugin/recovery/types.d.ts +116 -0
- package/dist/src/plugin/recovery/types.d.ts.map +1 -0
- package/dist/src/plugin/recovery/types.js +6 -0
- package/dist/src/plugin/recovery/types.js.map +1 -0
- package/dist/src/plugin/recovery.d.ts +63 -0
- package/dist/src/plugin/recovery.d.ts.map +1 -0
- package/dist/src/plugin/recovery.js +331 -0
- package/dist/src/plugin/recovery.js.map +1 -0
- package/dist/src/plugin/refresh-queue.d.ts +101 -0
- package/dist/src/plugin/refresh-queue.d.ts.map +1 -0
- package/dist/src/plugin/refresh-queue.js +248 -0
- package/dist/src/plugin/refresh-queue.js.map +1 -0
- package/dist/src/plugin/rotation.d.ts +169 -0
- package/dist/src/plugin/rotation.d.ts.map +1 -0
- package/dist/src/plugin/rotation.js +328 -0
- package/dist/src/plugin/rotation.js.map +1 -0
- package/dist/src/plugin/storage.d.ts +90 -0
- package/dist/src/plugin/storage.d.ts.map +1 -0
- package/dist/src/plugin/storage.js +450 -0
- package/dist/src/plugin/storage.js.map +1 -0
- package/dist/src/plugin/token.d.ts +19 -0
- package/dist/src/plugin/token.d.ts.map +1 -0
- package/dist/src/plugin/token.js +112 -0
- package/dist/src/plugin/token.js.map +1 -0
- package/dist/src/plugin/types.d.ts +97 -0
- package/dist/src/plugin/types.d.ts.map +1 -0
- package/dist/src/plugin/types.js +1 -0
- package/dist/src/plugin/types.js.map +1 -0
- package/dist/src/plugin/version.d.ts +14 -0
- package/dist/src/plugin/version.d.ts.map +1 -0
- package/dist/src/plugin/version.js +20 -0
- package/dist/src/plugin/version.js.map +1 -0
- package/dist/src/plugin.d.ts +5 -0
- package/dist/src/plugin.d.ts.map +1 -0
- package/dist/src/plugin.js +1077 -0
- package/dist/src/plugin.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
export interface OAuthAuthDetails {
|
|
3
|
+
type: "oauth";
|
|
4
|
+
refresh: string;
|
|
5
|
+
access?: string;
|
|
6
|
+
expires?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ApiKeyAuthDetails {
|
|
9
|
+
type: "api_key";
|
|
10
|
+
key: string;
|
|
11
|
+
}
|
|
12
|
+
export interface NonOAuthAuthDetails {
|
|
13
|
+
type: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
export type AuthDetails = OAuthAuthDetails | ApiKeyAuthDetails | NonOAuthAuthDetails;
|
|
17
|
+
export type GetAuth = () => Promise<AuthDetails>;
|
|
18
|
+
export interface ProviderModel {
|
|
19
|
+
cost?: {
|
|
20
|
+
input: number;
|
|
21
|
+
output: number;
|
|
22
|
+
};
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
export interface Provider {
|
|
26
|
+
models?: Record<string, ProviderModel>;
|
|
27
|
+
}
|
|
28
|
+
export interface LoaderResult {
|
|
29
|
+
apiKey: string;
|
|
30
|
+
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
31
|
+
}
|
|
32
|
+
export type PluginClient = PluginInput["client"];
|
|
33
|
+
export interface PluginContext {
|
|
34
|
+
client: PluginClient;
|
|
35
|
+
directory: string;
|
|
36
|
+
}
|
|
37
|
+
export type AuthPrompt = {
|
|
38
|
+
type: "text";
|
|
39
|
+
key: string;
|
|
40
|
+
message: string;
|
|
41
|
+
placeholder?: string;
|
|
42
|
+
validate?: (value: string) => string | undefined;
|
|
43
|
+
condition?: (inputs: Record<string, string>) => boolean;
|
|
44
|
+
} | {
|
|
45
|
+
type: "select";
|
|
46
|
+
key: string;
|
|
47
|
+
message: string;
|
|
48
|
+
options: Array<{
|
|
49
|
+
label: string;
|
|
50
|
+
value: string;
|
|
51
|
+
hint?: string;
|
|
52
|
+
}>;
|
|
53
|
+
condition?: (inputs: Record<string, string>) => boolean;
|
|
54
|
+
};
|
|
55
|
+
export type OAuthCallbackResult = {
|
|
56
|
+
type: "success";
|
|
57
|
+
refresh: string;
|
|
58
|
+
access: string;
|
|
59
|
+
expires: number;
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
} | {
|
|
62
|
+
type: "failed";
|
|
63
|
+
error: string;
|
|
64
|
+
[key: string]: unknown;
|
|
65
|
+
};
|
|
66
|
+
export type OAuthAuthorizationResult = {
|
|
67
|
+
url: string;
|
|
68
|
+
instructions: string;
|
|
69
|
+
method: "auto";
|
|
70
|
+
callback: () => Promise<OAuthCallbackResult>;
|
|
71
|
+
};
|
|
72
|
+
export interface AuthMethod {
|
|
73
|
+
provider?: string;
|
|
74
|
+
label: string;
|
|
75
|
+
type: "oauth" | "api";
|
|
76
|
+
prompts?: AuthPrompt[];
|
|
77
|
+
authorize?: (inputs?: Record<string, string>) => Promise<OAuthAuthorizationResult>;
|
|
78
|
+
}
|
|
79
|
+
export interface PluginEventPayload {
|
|
80
|
+
event: {
|
|
81
|
+
type: string;
|
|
82
|
+
properties?: unknown;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export interface PluginResult {
|
|
86
|
+
auth: {
|
|
87
|
+
provider: string;
|
|
88
|
+
loader: (getAuth: GetAuth, provider: Provider) => Promise<LoaderResult | Record<string, unknown>>;
|
|
89
|
+
methods: AuthMethod[];
|
|
90
|
+
};
|
|
91
|
+
event?: (payload: PluginEventPayload) => void;
|
|
92
|
+
tool?: Record<string, unknown>;
|
|
93
|
+
}
|
|
94
|
+
export interface RefreshParts {
|
|
95
|
+
refreshToken: string;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugin/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,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AED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAClG,OAAO,EAAE,UAAU,EAAE,CAAC;KACvB,CAAC;IACF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plugin/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kimicode version resolver.
|
|
3
|
+
*
|
|
4
|
+
* The emulated kimi-cli version (used in User-Agent and X-Msh-Version) is
|
|
5
|
+
* configured in constants.ts and tracks a recent kimi-cli release.
|
|
6
|
+
* This module logs the active version at startup for debugging.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Log the active emulated kimi-cli version.
|
|
10
|
+
* The version itself is configured in constants.ts (KIMI_CLI_COMPAT_VERSION)
|
|
11
|
+
* and can be overridden via the KIMI_CODE_CLI_VERSION env var.
|
|
12
|
+
*/
|
|
13
|
+
export declare function initKimicodeVersion(): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/plugin/version.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;;GAIG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAIzD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kimicode version resolver.
|
|
3
|
+
*
|
|
4
|
+
* The emulated kimi-cli version (used in User-Agent and X-Msh-Version) is
|
|
5
|
+
* configured in constants.ts and tracks a recent kimi-cli release.
|
|
6
|
+
* This module logs the active version at startup for debugging.
|
|
7
|
+
*/
|
|
8
|
+
import { getKimiPluginVersion } from "../constants";
|
|
9
|
+
import { createLogger } from "./logger";
|
|
10
|
+
/**
|
|
11
|
+
* Log the active emulated kimi-cli version.
|
|
12
|
+
* The version itself is configured in constants.ts (KIMI_CLI_COMPAT_VERSION)
|
|
13
|
+
* and can be overridden via the KIMI_CODE_CLI_VERSION env var.
|
|
14
|
+
*/
|
|
15
|
+
export async function initKimicodeVersion() {
|
|
16
|
+
const log = createLogger("version");
|
|
17
|
+
const version = getKimiPluginVersion();
|
|
18
|
+
log.debug("kimicode-emulated-version", { version });
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/plugin/version.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,MAAM,GAAG,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IACpC,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAC;IACvC,GAAG,CAAC,KAAK,CAAC,2BAA2B,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PluginContext, PluginResult } from "./plugin/types";
|
|
2
|
+
export declare const createKimicodePlugin: (providerId: string) => ({ client, directory }: PluginContext) => Promise<PluginResult>;
|
|
3
|
+
export declare const KimicodeCLIOAuthPlugin: ({ client, directory }: PluginContext) => Promise<PluginResult>;
|
|
4
|
+
export declare const MoonshotAIOAuthPlugin: ({ client, directory }: PluginContext) => Promise<PluginResult>;
|
|
5
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAOV,aAAa,EAEb,YAAY,EAEb,MAAM,gBAAgB,CAAC;AAgexB,eAAO,MAAM,oBAAoB,GAAI,YAAY,MAAM,MACrD,uBAAuB,aAAa,KACnC,OAAO,CAAC,YAAY,CA+vBtB,CAAC;AAEF,eAAO,MAAM,sBAAsB,0BAlwBV,aAAa,KACnC,OAAO,CAAC,YAAY,CAiwBiD,CAAC;AAGzE,eAAO,MAAM,qBAAqB,0BArwBT,aAAa,KACnC,OAAO,CAAC,YAAY,CAowBoC,CAAC"}
|