cckit 0.3.0 → 0.3.3
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 +254 -13
- package/dist/commands.d.ts +13 -3
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +1 -564
- package/dist/commands.js.map +1 -1
- package/dist/config.d.ts +18 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -293
- package/dist/config.js.map +1 -1
- package/dist/i18n.js +1 -246
- package/dist/i18n.js.map +1 -1
- package/dist/index.js +1 -152
- package/dist/index.js.map +1 -1
- package/dist/providers.js +1 -196
- package/dist/providers.js.map +1 -1
- package/dist/proxy/chat-to-response.d.ts +9 -0
- package/dist/proxy/chat-to-response.d.ts.map +1 -0
- package/dist/proxy/chat-to-response.js +1 -0
- package/dist/proxy/chat-to-response.js.map +1 -0
- package/dist/proxy/constants.d.ts +2 -0
- package/dist/proxy/constants.d.ts.map +1 -0
- package/dist/proxy/constants.js +1 -0
- package/dist/proxy/constants.js.map +1 -0
- package/dist/proxy/proxy-manager.d.ts +61 -0
- package/dist/proxy/proxy-manager.d.ts.map +1 -0
- package/dist/proxy/proxy-manager.js +1 -0
- package/dist/proxy/proxy-manager.js.map +1 -0
- package/dist/tools/base-adapter.d.ts +31 -0
- package/dist/tools/base-adapter.d.ts.map +1 -0
- package/dist/tools/base-adapter.js +1 -0
- package/dist/tools/base-adapter.js.map +1 -0
- package/dist/tools/claude-code-adapter.d.ts +15 -0
- package/dist/tools/claude-code-adapter.d.ts.map +1 -0
- package/dist/tools/claude-code-adapter.js +1 -0
- package/dist/tools/claude-code-adapter.js.map +1 -0
- package/dist/tools/codex-adapter.d.ts +43 -0
- package/dist/tools/codex-adapter.d.ts.map +1 -0
- package/dist/tools/codex-adapter.js +1 -0
- package/dist/tools/codex-adapter.js.map +1 -0
- package/dist/tools/index.d.ts +20 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +1 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/opencode-adapter.d.ts +41 -0
- package/dist/tools/opencode-adapter.d.ts.map +1 -0
- package/dist/tools/opencode-adapter.js +1 -0
- package/dist/tools/opencode-adapter.js.map +1 -0
- package/dist/tools/types.d.ts +16 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +1 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/types.d.ts +42 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -2
- package/dist/types.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +1 -69
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/errors.js +1 -92
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/helpers.js +1 -117
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/index.js +1 -8
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logger.js +1 -68
- package/dist/utils/logger.js.map +1 -1
- package/package.json +2 -3
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ToolAdapter } from './types.js';
|
|
2
|
+
import { ToolType } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Get a tool adapter instance by tool type
|
|
5
|
+
*/
|
|
6
|
+
export declare function getToolAdapter(tool: ToolType): ToolAdapter;
|
|
7
|
+
/**
|
|
8
|
+
* Get all available tool adapters
|
|
9
|
+
*/
|
|
10
|
+
export declare function getAllToolAdapters(): ToolAdapter[];
|
|
11
|
+
/**
|
|
12
|
+
* Get list of supported tool types
|
|
13
|
+
*/
|
|
14
|
+
export declare function getSupportedTools(): ToolType[];
|
|
15
|
+
/**
|
|
16
|
+
* Check if a tool type is supported
|
|
17
|
+
*/
|
|
18
|
+
export declare function isToolSupported(tool: string): tool is ToolType;
|
|
19
|
+
export { ToolAdapter } from './types.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAevC;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,WAAW,CAS1D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,WAAW,EAAE,CAIlD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,QAAQ,EAAE,CAE9C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,QAAQ,CAE9D;AAGD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ClaudeCodeAdapter as e}from"./claude-code-adapter.js";import{OpenCodeAdapter as o}from"./opencode-adapter.js";import{CodexAdapter as t}from"./codex-adapter.js";const r={"claude-code":()=>new e,opencode:()=>new o,codex:()=>new t},n=new Map;export function getToolAdapter(e){if(!n.has(e)){const o=r[e];if(!o)throw new Error(`Unknown tool: ${e}`);n.set(e,o())}return n.get(e)}export function getAllToolAdapters(){return Object.keys(r).map(e=>getToolAdapter(e))}export function getSupportedTools(){return Object.keys(r)}export function isToolSupported(e){return e in r}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"/Users/qiutian00lw/Code/cckit_cli/cckit-node/dist/tools/index.js","names":["ClaudeCodeAdapter","OpenCodeAdapter","CodexAdapter","TOOL_ADAPTER_FACTORIES","opencode","codex","adapterCache","Map","getToolAdapter","tool","has","factory","Error","set","get","getAllToolAdapters","Object","keys","map","getSupportedTools","isToolSupported"],"sources":["../../src/tools/index.ts"],"mappings":"4BAESA,MAAyB,qDACzBC,MAAuB,+CACvBC,MAAoB,qBAG7B,MAAMC,EAA8D,CAClE,cAAe,IAAM,IAAIH,EACzBI,SAAY,IAAM,IAAIH,EACtBI,MAAS,IAAM,IAAIH,GAIfI,EAAe,IAAIC,WAKnB,SAAUC,eAAeC,GAC7B,IAAKH,EAAaI,IAAID,GAAO,CAC3B,MAAME,EAAUR,EAAuBM,GACvC,IAAKE,EACH,MAAM,IAAIC,MAAM,iBAAiBH,KAEnCH,EAAaO,IAAIJ,EAAME,IACzB,CACA,OAAOL,EAAaQ,IAAIL,EAC1B,QAKM,SAAUM,qBACd,OAAOC,OAAOC,KAAKd,GAAwBe,IAAKT,GAC9CD,eAAeC,GAEnB,QAKM,SAAUU,oBACd,OAAOH,OAAOC,KAAKd,EACrB,QAKM,SAAUiB,gBAAgBX,GAC9B,OAAOA,KAAQN,CACjB","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BaseToolAdapter } from './base-adapter.js';
|
|
2
|
+
import { ModelProvider, ToolConfig, ToolType } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* OpenCode CLI tool adapter
|
|
5
|
+
* Manages ~/.opencode.json configuration
|
|
6
|
+
*
|
|
7
|
+
* OpenCode config format:
|
|
8
|
+
* {
|
|
9
|
+
* "providers": {
|
|
10
|
+
* "anthropic": { "apiKey": "...", "disabled": false },
|
|
11
|
+
* "openai": { "apiKey": "...", "disabled": false }
|
|
12
|
+
* },
|
|
13
|
+
* "agents": {
|
|
14
|
+
* "coder": { "model": "claude-3-sonnet" },
|
|
15
|
+
* "task": { "model": "claude-3-sonnet" }
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
export declare class OpenCodeAdapter extends BaseToolAdapter {
|
|
20
|
+
readonly toolType: ToolType;
|
|
21
|
+
readonly toolConfig: ToolConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Get the config path, checking XDG location first
|
|
24
|
+
*/
|
|
25
|
+
getConfigPath(): string;
|
|
26
|
+
parseConfig(content: string): Record<string, unknown>;
|
|
27
|
+
serializeConfig(config: Record<string, unknown>): string;
|
|
28
|
+
/**
|
|
29
|
+
* Map cckit provider type to OpenCode provider name
|
|
30
|
+
*/
|
|
31
|
+
private getOpenCodeProviderName;
|
|
32
|
+
applyProvider(provider: ModelProvider): Promise<void>;
|
|
33
|
+
removeProvider(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Check if OpenCode is installed
|
|
36
|
+
*/
|
|
37
|
+
isInstalled(): boolean;
|
|
38
|
+
private getDefaultBaseUrl;
|
|
39
|
+
private getDefaultModel;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=opencode-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode-adapter.d.ts","sourceRoot":"","sources":["../../src/tools/opencode-adapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAkB,MAAM,aAAa,CAAC;AAElF;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,eAAgB,SAAQ,eAAe;IAClD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAc;IACzC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAK7B;IAEF;;OAEG;IACH,aAAa,IAAI,MAAM;IAWvB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQrD,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;IAIxD;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAmBzB,aAAa,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAwCrD,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAerC;;OAEG;IACH,WAAW,IAAI,OAAO;IAStB,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,eAAe;CAexB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"fs";import t from"path";import{homedir as i}from"os";import{BaseToolAdapter as o}from"./base-adapter.js";export class OpenCodeAdapter extends o{constructor(){super(...arguments),this.toolType="opencode",this.toolConfig={id:"opencode",display_name:"OpenCode",config_path:"~/.opencode.json",description:"OpenCode CLI - AI coding assistant"}}getConfigPath(){const o=process.env.XDG_CONFIG_HOME||t.join(i(),".config"),n=t.join(o,"opencode",".opencode.json");return e.existsSync(n)?n:t.join(i(),".opencode.json")}parseConfig(e){try{return JSON.parse(e)}catch{return{}}}serializeConfig(e){return JSON.stringify(e,null,2)}getOpenCodeProviderName(e){return{claude:"anthropic",zhipu:"cckit-zhipu",minimax:"cckit-minimax",kimi:"cckit-kimi",zenmux:"cckit-zenmux",streamlake:"cckit-streamlake",volcengine:"cckit-volcengine",aliyun:"cckit-aliyun",tencent:"cckit-tencent",xfyun:"cckit-xfyun",custom:`cckit-${e.name.toLowerCase().replace(/\s+/g,"-")}`}[e.provider_type]||`cckit-${e.provider_type}`}async applyProvider(e){const t=await this.loadConfig();t.providers=t.providers||{};const i=this.getOpenCodeProviderName(e),o=e.base_url||this.getDefaultBaseUrl(e.provider_type),n=e.current_model||e.models[0]||this.getDefaultModel(e.provider_type);t.providers[i]={apiKey:e.api_key,disabled:!1,...o&&{baseUrl:o}};for(const[e,o]of Object.entries(t.providers))e.startsWith("cckit-")&&e!==i&&(t.providers[e]={...o,disabled:!0});t.agents=t.agents||{},t.agents.coder=t.agents.coder||{},t.agents.coder.model=n,t.agents.task=t.agents.task||{},t.agents.task.model=n,await this.saveConfig(t)}async removeProvider(){const e=await this.loadConfig();if(e.providers)for(const t of Object.keys(e.providers))t.startsWith("cckit-")&&delete e.providers[t];await this.saveConfig(e)}isInstalled(){const o=t.join(i(),".opencode.json"),n=process.env.XDG_CONFIG_HOME||t.join(i(),".config"),a=t.join(n,"opencode",".opencode.json");return e.existsSync(o)||e.existsSync(a)}getDefaultBaseUrl(e){return{zhipu:"https://open.bigmodel.cn/api/anthropic",minimax:"https://api.minimaxi.com/anthropic",kimi:"https://api.kimi.com/coding/",zenmux:"https://zenmux.ai/api/anthropic",streamlake:"https://wanqing.streamlakeapi.com/api/gateway/v1/endpoints/kat-coder-pro-v1/claude-code-proxy",volcengine:"https://ark.cn-beijing.volces.com/api/coding",aliyun:"https://coding.dashscope.aliyuncs.com/apps/anthropic",tencent:"https://api.lkeap.cloud.tencent.com/coding/anthropic",xfyun:"https://maas-coding-api.cn-huabei-1.xf-yun.com/anthropic"}[e]}getDefaultModel(e){return{zhipu:"GLM-4.7",minimax:"MiniMax-M2",kimi:"kimi-for-coding",zenmux:"claude-3-5-sonnet-20241022",claude:"claude-3-5-sonnet-20241022",streamlake:"kat-coder-pro-v1",volcengine:"ark-code-latest",aliyun:"claude-sonnet-4-20250514",tencent:"GLM-5",xfyun:"GLM-5"}[e]||"claude-3-5-sonnet-20241022"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"/Users/qiutian00lw/Code/cckit_cli/cckit-node/dist/tools/opencode-adapter.js","names":["fs","path","homedir","BaseToolAdapter","OpenCodeAdapter","constructor","this","toolType","toolConfig","id","display_name","config_path","description","getConfigPath","xdgConfig","process","env","XDG_CONFIG_HOME","join","xdgPath","existsSync","parseConfig","content","JSON","parse","serializeConfig","config","stringify","getOpenCodeProviderName","provider","claude","zhipu","minimax","kimi","zenmux","streamlake","volcengine","aliyun","tencent","xfyun","custom","name","toLowerCase","replace","provider_type","applyProvider","loadConfig","providers","openCodeProviderName","baseUrl","base_url","getDefaultBaseUrl","activeModel","current_model","models","getDefaultModel","apiKey","api_key","disabled","prov","Object","entries","startsWith","agents","coder","model","task","saveConfig","removeProvider","keys","isInstalled","homeConfig","xdgConfigPath","providerType"],"sources":["../../src/tools/opencode-adapter.ts"],"mappings":"OAAOA,MAAQ,YACRC,MAAU,yBACRC,MAAe,+BACfC,MAAuB,2BAmB1B,MAAOC,wBAAwBD,EAArC,WAAAE,G,oBACWC,KAAAC,SAAqB,WACrBD,KAAAE,WAAyB,CAChCC,GAAI,W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EAAOqC,OAAOC,MAAQtC,EAAOqC,OAAOC,OAAS,GAC7CtC,EAAOqC,OAAOC,MAAMC,MAAQb,EAC5B1B,EAAOqC,OAAOG,KAAOxC,EAAOqC,OAAOG,MAAQ,GAC3CxC,EAAOqC,OAAOG,KAAKD,MAAQb,QAErB9C,KAAK6D,WAAWzC,EACxB,CAEA,oBAAM0C,GACJ,MAAM1C,QAAgBpB,KAAKwC,aAE3B,GAAIpB,EAAOqB,UAET,IAAK,MAAMN,KAAQmB,OAAOS,KAAK3C,EAAOqB,WAChCN,EAAKqB,WAAW,kBACXpC,EAAOqB,UAAUN,SAKxBnC,KAAK6D,WAAWzC,EACxB,CAKA,WAAA4C,GAEE,MAAMC,EAAatE,EAAKiB,KAAKhB,IAAW,kBAClCY,EAAYC,QAAQC,IAAIC,iBAAmBhB,EAAKiB,KAAKhB,IAAW,WAChEsE,EAAgBvE,EAAKiB,KAAKJ,EAAW,WAAY,kBAEvD,OAAOd,EAAGoB,WAAWmD,IAAevE,EAAGoB,WAAWoD,EACpD,CAEQ,iBAAArB,CAAkBsB,GAYxB,MAXqC,CACnC1C,MAAO,yCACPC,QAAS,qCACTC,KAAM,+BACNC,OAAQ,kCACRC,WAAY,gGACZC,WAAY,+CACZC,OAAQ,uDACRC,QAAS,uDACTC,MAAO,4DAEGkC,EACd,CAEQ,eAAAlB,CAAgBkB,GAatB,MAZuC,CACrC1C,MAAO,UACPC,QAAS,aACTC,KAAM,kBACNC,OAAQ,6BACRJ,OAAQ,6BACRK,WAAY,mBACZC,WAAY,kBACZC,OAAQ,2BACRC,QAAS,QACTC,MAAO,SAEKkC,IAAiB,4BACjC","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ModelProvider, ToolType, ToolConfig } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Tool adapter interface for CLI tool configuration management
|
|
4
|
+
* Each supported tool implements this interface
|
|
5
|
+
*/
|
|
6
|
+
export interface ToolAdapter {
|
|
7
|
+
readonly toolType: ToolType;
|
|
8
|
+
readonly toolConfig: ToolConfig;
|
|
9
|
+
getConfigPath(): string;
|
|
10
|
+
loadConfig(): Promise<Record<string, unknown>>;
|
|
11
|
+
saveConfig(config: Record<string, unknown>): Promise<void>;
|
|
12
|
+
applyProvider(provider: ModelProvider): Promise<void>;
|
|
13
|
+
removeProvider(): Promise<void>;
|
|
14
|
+
isInstalled(): boolean;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAElE;;;GAGG;AACH,MAAM,WAAW,WAAW;IAE1B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAGhC,aAAa,IAAI,MAAM,CAAC;IACxB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/C,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAG3D,aAAa,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAGhC,WAAW,IAAI,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"/Users/qiutian00lw/Code/cckit_cli/cckit-node/dist/tools/types.js","names":[],"sources":[],"mappings":"","ignoreList":[]}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type ProviderType = 'zhipu' | 'minimax' | 'kimi' | 'claude' | 'zenmux' | 'streamlake' | 'volcengine' | 'aliyun' | 'tencent' | 'xfyun' | 'custom';
|
|
2
|
+
export type ToolType = 'claude-code' | 'opencode' | 'codex';
|
|
2
3
|
export interface ModelProvider {
|
|
3
4
|
id: string;
|
|
4
5
|
name: string;
|
|
@@ -7,12 +8,16 @@ export interface ModelProvider {
|
|
|
7
8
|
base_url?: string;
|
|
8
9
|
models: string[];
|
|
9
10
|
current_model?: string;
|
|
11
|
+
default_sonnet_model?: string;
|
|
12
|
+
default_haiku_model?: string;
|
|
13
|
+
default_opus_model?: string;
|
|
10
14
|
created_at: string;
|
|
11
15
|
updated_at: string;
|
|
12
16
|
}
|
|
13
17
|
export interface CCKitConfig {
|
|
14
18
|
providers: ModelProvider[];
|
|
15
19
|
current_provider_id?: string;
|
|
20
|
+
tool_states?: ToolProviderState[];
|
|
16
21
|
version: string;
|
|
17
22
|
created_at: string;
|
|
18
23
|
updated_at: string;
|
|
@@ -45,4 +50,41 @@ export interface ClaudeSettings {
|
|
|
45
50
|
};
|
|
46
51
|
[key: string]: any;
|
|
47
52
|
}
|
|
53
|
+
export interface ToolProviderState {
|
|
54
|
+
tool_type: ToolType;
|
|
55
|
+
current_provider_id: string;
|
|
56
|
+
last_switched_at?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface ToolConfig {
|
|
59
|
+
id: ToolType;
|
|
60
|
+
display_name: string;
|
|
61
|
+
config_path: string;
|
|
62
|
+
description: string;
|
|
63
|
+
}
|
|
64
|
+
export interface OpenCodeConfig {
|
|
65
|
+
providers?: Record<string, {
|
|
66
|
+
apiKey?: string;
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
}>;
|
|
69
|
+
agents?: Record<string, {
|
|
70
|
+
model?: string;
|
|
71
|
+
maxTokens?: number;
|
|
72
|
+
}>;
|
|
73
|
+
[key: string]: any;
|
|
74
|
+
}
|
|
75
|
+
export interface CodexConfig {
|
|
76
|
+
model?: string;
|
|
77
|
+
model_provider?: string;
|
|
78
|
+
model_providers?: Record<string, {
|
|
79
|
+
name: string;
|
|
80
|
+
base_url?: string;
|
|
81
|
+
env_key?: string;
|
|
82
|
+
wire_api?: 'responses' | 'chat';
|
|
83
|
+
requires_openai_auth?: boolean;
|
|
84
|
+
env_http_headers?: Record<string, string>;
|
|
85
|
+
http_headers?: Record<string, string>;
|
|
86
|
+
experimental_bearer_token?: string;
|
|
87
|
+
}>;
|
|
88
|
+
[key: string]: any;
|
|
89
|
+
}
|
|
48
90
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAGxJ,MAAM,MAAM,QAAQ,GAAG,aAAa,GAAG,UAAU,GAAG,OAAO,CAAC;AAE5D,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,YAAY,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,oBAAoB,CAAC,EAAE,MAAM,CA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
|
|
2
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
export{};
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","
|
|
1
|
+
{"version":3,"file":"/Users/qiutian00lw/Code/cckit_cli/cckit-node/dist/types.js","names":[],"sources":[],"mappings":"","ignoreList":[]}
|
package/dist/utils/constants.js
CHANGED
|
@@ -1,69 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Application constants
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Current version of the application
|
|
6
|
-
* Injected by scripts/inject-version.js during build
|
|
7
|
-
*/
|
|
8
|
-
export const APP_VERSION = '0.3.0';
|
|
9
|
-
/**
|
|
10
|
-
* Default base URLs for providers
|
|
11
|
-
*/
|
|
12
|
-
export const DEFAULT_BASE_URLS = Object.freeze({
|
|
13
|
-
zhipu: 'https://open.bigmodel.cn/api/anthropic',
|
|
14
|
-
minimax: 'https://api.minimaxi.com/anthropic',
|
|
15
|
-
kimi: 'https://api.kimi.com/coding/',
|
|
16
|
-
zenmux: 'https://zenmux.ai/api/anthropic',
|
|
17
|
-
streamlake: 'https://wanqing.streamlakeapi.com/api/gateway/v1/endpoints/kat-coder-pro-v1/claude-code-proxy',
|
|
18
|
-
custom: '',
|
|
19
|
-
});
|
|
20
|
-
/**
|
|
21
|
-
* Default models for providers
|
|
22
|
-
*/
|
|
23
|
-
export const DEFAULT_MODELS = Object.freeze({
|
|
24
|
-
zhipu: 'GLM-4.7',
|
|
25
|
-
minimax: 'MiniMax-M2',
|
|
26
|
-
kimi: 'kimi-for-coding',
|
|
27
|
-
zenmux: 'claude-3-5-sonnet-20241022',
|
|
28
|
-
claude: 'claude-3-5-sonnet-20241022',
|
|
29
|
-
streamlake: 'kat-coder-pro-v1',
|
|
30
|
-
custom: '',
|
|
31
|
-
});
|
|
32
|
-
/**
|
|
33
|
-
* Provider type enum
|
|
34
|
-
*/
|
|
35
|
-
export var ProviderType;
|
|
36
|
-
(function (ProviderType) {
|
|
37
|
-
ProviderType["ZHIPU"] = "zhipu";
|
|
38
|
-
ProviderType["MINIMAX"] = "minimax";
|
|
39
|
-
ProviderType["KIMI"] = "kimi";
|
|
40
|
-
ProviderType["CLAUDE"] = "claude";
|
|
41
|
-
ProviderType["ZENMUX"] = "zenmux";
|
|
42
|
-
ProviderType["STREAMLAKE"] = "streamlake";
|
|
43
|
-
ProviderType["CUSTOM"] = "custom";
|
|
44
|
-
})(ProviderType || (ProviderType = {}));
|
|
45
|
-
/**
|
|
46
|
-
* File paths
|
|
47
|
-
*/
|
|
48
|
-
export const PATHS = Object.freeze({
|
|
49
|
-
CONFIG_DIR: '.cckit',
|
|
50
|
-
CONFIG_FILE: 'config.json',
|
|
51
|
-
CLAUDE_DIR: '.claude',
|
|
52
|
-
CLAUDE_SETTINGS: 'settings.json',
|
|
53
|
-
});
|
|
54
|
-
/**
|
|
55
|
-
* Timeouts in milliseconds
|
|
56
|
-
*/
|
|
57
|
-
export const TIMEOUTS = Object.freeze({
|
|
58
|
-
CLI_CHECK: 5000,
|
|
59
|
-
API_REQUEST: 10000,
|
|
60
|
-
USER_INPUT: 60000,
|
|
61
|
-
});
|
|
62
|
-
/**
|
|
63
|
-
* API registry mirrors
|
|
64
|
-
*/
|
|
65
|
-
export const NPM_REGISTRIES = Object.freeze({
|
|
66
|
-
DEFAULT: 'https://registry.npmjs.org',
|
|
67
|
-
NPMMIRROR: 'https://registry.npmmirror.com',
|
|
68
|
-
});
|
|
69
|
-
//# sourceMappingURL=constants.js.map
|
|
1
|
+
export const APP_VERSION="0.3.3";export const DEFAULT_BASE_URLS=Object.freeze({zhipu:"https://open.bigmodel.cn/api/anthropic",minimax:"https://api.minimaxi.com/anthropic",kimi:"https://api.kimi.com/coding/",zenmux:"https://zenmux.ai/api/anthropic",streamlake:"https://wanqing.streamlakeapi.com/api/gateway/v1/endpoints/kat-coder-pro-v1/claude-code-proxy",custom:""});export const DEFAULT_MODELS=Object.freeze({zhipu:"GLM-4.7",minimax:"MiniMax-M2",kimi:"kimi-for-coding",zenmux:"claude-3-5-sonnet-20241022",claude:"claude-3-5-sonnet-20241022",streamlake:"kat-coder-pro-v1",custom:""});export var ProviderType;!function(e){e.ZHIPU="zhipu",e.MINIMAX="minimax",e.KIMI="kimi",e.CLAUDE="claude",e.ZENMUX="zenmux",e.STREAMLAKE="streamlake",e.CUSTOM="custom"}(ProviderType||(ProviderType={}));export const PATHS=Object.freeze({CONFIG_DIR:".cckit",CONFIG_FILE:"config.json",CLAUDE_DIR:".claude",CLAUDE_SETTINGS:"settings.json"});export const TIMEOUTS=Object.freeze({CLI_CHECK:5e3,API_REQUEST:1e4,USER_INPUT:6e4});export const NPM_REGISTRIES=Object.freeze({DEFAULT:"https://registry.npmjs.org",NPMMIRROR:"https://registry.npmmirror.com"});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","
|
|
1
|
+
{"version":3,"file":"/Users/qiutian00lw/Code/cckit_cli/cckit-node/dist/utils/constants.js","names":["APP_VERSION","DEFAULT_BASE_URLS","Object","freeze","zhipu","minimax","kimi","zenmux","streamlake","custom","DEFAULT_MODELS","claude","ProviderType","PATHS","CONFIG_DIR","CONFIG_FILE","CLAUDE_DIR","CLAUDE_SETTINGS","TIMEOUTS","CLI_CHECK","API_REQUEST","USER_INPUT","NPM_REGISTRIES","DEFAULT","NPMMIRROR"],"sources":["../../src/utils/constants.ts"],"mappings":"OAQO,MAAMA,YAAc,eAKpB,MAAMC,kBAAoBC,OAAOC,OAAO,CAC7CC,MAAO,yCACPC,QAAS,qCACTC,KAAM,+BACNC,OAAQ,kCACRC,WAAY,gGACZC,OAAQ,YAMH,MAAMC,eAAiBR,OAAOC,OAAO,CAC1CC,MAAO,UACPC,QAAS,aACTC,KAAM,kBACNC,OAAQ,6BACRI,OAAQ,6BACRH,WAAY,mBACZC,OAAQ,YAMV,IAAYG,cAAZ,SAAYA,GACVA,EAAA,cACAA,EAAA,kBACAA,EAAA,YACAA,EAAA,gBACAA,EAAA,gBACAA,EAAA,wBACAA,EAAA,eACD,CARD,CAAYA,4BAAY,YAajB,MAAMC,MAAQX,OAAOC,OAAO,CACjCW,WAAY,SACZC,YAAa,cACbC,WAAY,UACZC,gBAAiB,yBAMZ,MAAMC,SAAWhB,OAAOC,OAAO,CACpCgB,UAAW,IACXC,YAAa,IACbC,WAAY,aAMP,MAAMC,eAAiBpB,OAAOC,OAAO,CAC1CoB,QAAS,6BACTC,UAAW","ignoreList":[]}
|
package/dist/utils/errors.js
CHANGED
|
@@ -1,92 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Custom error classes
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Base error class for application errors
|
|
6
|
-
*/
|
|
7
|
-
export class CCKitError extends Error {
|
|
8
|
-
constructor(message, code, details) {
|
|
9
|
-
super(message);
|
|
10
|
-
this.code = code;
|
|
11
|
-
this.details = details;
|
|
12
|
-
this.name = this.constructor.name;
|
|
13
|
-
Error.captureStackTrace(this, this.constructor);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Error thrown when a provider is not found
|
|
18
|
-
*/
|
|
19
|
-
export class ProviderNotFoundError extends CCKitError {
|
|
20
|
-
constructor(providerId) {
|
|
21
|
-
super(`Provider '${providerId}' not found`, 'PROVIDER_NOT_FOUND', { providerId });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Error thrown when a provider is not configured
|
|
26
|
-
*/
|
|
27
|
-
export class ProviderNotConfiguredError extends CCKitError {
|
|
28
|
-
constructor(providerId) {
|
|
29
|
-
super(`Provider '${providerId}' is not configured with an API key`, 'PROVIDER_NOT_CONFIGURED', { providerId });
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Error thrown when a model is not found in provider
|
|
34
|
-
*/
|
|
35
|
-
export class ModelNotFoundError extends CCKitError {
|
|
36
|
-
constructor(modelName, providerId) {
|
|
37
|
-
super(`Model '${modelName}' not found in provider '${providerId}'`, 'MODEL_NOT_FOUND', { modelName, providerId });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Error thrown when configuration file is invalid
|
|
42
|
-
*/
|
|
43
|
-
export class InvalidConfigError extends CCKitError {
|
|
44
|
-
constructor(message, filePath) {
|
|
45
|
-
super(`Invalid configuration: ${message}`, 'INVALID_CONFIG', { filePath });
|
|
46
|
-
this.filePath = filePath;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Error thrown when Claude Code installation check fails
|
|
51
|
-
*/
|
|
52
|
-
export class ClaudeCodeNotInstalledError extends CCKitError {
|
|
53
|
-
constructor() {
|
|
54
|
-
super('Claude Code is not installed', 'CLAUDE_CODE_NOT_INSTALLED');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Error thrown when an operation times out
|
|
59
|
-
*/
|
|
60
|
-
export class TimeoutError extends CCKitError {
|
|
61
|
-
constructor(operation, timeout) {
|
|
62
|
-
super(`${operation} timed out after ${timeout}ms`, 'TIMEOUT', { operation, timeout });
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Error thrown when file system operation fails
|
|
67
|
-
*/
|
|
68
|
-
export class FileSystemError extends CCKitError {
|
|
69
|
-
constructor(operation, filePath, originalError) {
|
|
70
|
-
super(`Failed to ${operation} file: ${filePath}`, 'FILESYSTEM_ERROR', { filePath, originalError: originalError?.message });
|
|
71
|
-
this.originalError = originalError;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Type guard to check if error is a CCKitError
|
|
76
|
-
*/
|
|
77
|
-
export function isCCKitError(error) {
|
|
78
|
-
return error instanceof CCKitError;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Gets a user-friendly error message
|
|
82
|
-
*/
|
|
83
|
-
export function getErrorMessage(error) {
|
|
84
|
-
if (isCCKitError(error)) {
|
|
85
|
-
return error.message;
|
|
86
|
-
}
|
|
87
|
-
if (error instanceof Error) {
|
|
88
|
-
return error.message;
|
|
89
|
-
}
|
|
90
|
-
return String(error);
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=errors.js.map
|
|
1
|
+
export class CCKitError extends Error{constructor(r,o,t){super(r),this.code=o,this.details=t,this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor)}}export class ProviderNotFoundError extends CCKitError{constructor(r){super(`Provider '${r}' not found`,"PROVIDER_NOT_FOUND",{providerId:r})}}export class ProviderNotConfiguredError extends CCKitError{constructor(r){super(`Provider '${r}' is not configured with an API key`,"PROVIDER_NOT_CONFIGURED",{providerId:r})}}export class ModelNotFoundError extends CCKitError{constructor(r,o){super(`Model '${r}' not found in provider '${o}'`,"MODEL_NOT_FOUND",{modelName:r,providerId:o})}}export class InvalidConfigError extends CCKitError{constructor(r,o){super(`Invalid configuration: ${r}`,"INVALID_CONFIG",{filePath:o}),this.filePath=o}}export class ClaudeCodeNotInstalledError extends CCKitError{constructor(){super("Claude Code is not installed","CLAUDE_CODE_NOT_INSTALLED")}}export class TimeoutError extends CCKitError{constructor(r,o){super(`${r} timed out after ${o}ms`,"TIMEOUT",{operation:r,timeout:o})}}export class FileSystemError extends CCKitError{constructor(r,o,t){super(`Failed to ${r} file: ${o}`,"FILESYSTEM_ERROR",{filePath:o,originalError:t?.message}),this.originalError=t}}export function isCCKitError(r){return r instanceof CCKitError}export function getErrorMessage(r){return isCCKitError(r)||r instanceof Error?r.message:String(r)}
|
package/dist/utils/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","
|
|
1
|
+
{"version":3,"file":"/Users/qiutian00lw/Code/cckit_cli/cckit-node/dist/utils/errors.js","names":["CCKitError","Error","constructor","message","code","details","super","this","name","captureStackTrace","ProviderNotFoundError","providerId","ProviderNotConfiguredError","ModelNotFoundError","modelName","InvalidConfigError","filePath","ClaudeCodeNotInstalledError","TimeoutError","operation","timeout","FileSystemError","originalError","isCCKitError","error","getErrorMessage","String"],"sources":["../../src/utils/errors.ts"],"mappings":"OAOM,MAAOA,mBAAmBC,MAC9B,WAAAC,CACEC,EACgBC,EACAC,GAEhBC,MAAMH,GAHUI,KAAAH,OACAG,KAAAF,UAGhBE,KAAKC,KAAOD,KAAKL,YAAYM,KAC7BP,MAAMQ,kBAAkBF,KAAMA,KAAKL,YACrC,SAMI,MAAOQ,8BAA8BV,WACzC,WAAAE,CAAYS,GACVL,MACE,aAAaK,eACb,qBACA,CAAEA,cAEN,SAMI,MAAOC,mCAAmCZ,WAC9C,WAAAE,CAAYS,GACVL,MACE,aAAaK,uCACb,0BACA,CAAEA,cAEN,SAMI,MAAOE,2BAA2Bb,WACtC,WAAAE,CAAYY,EAAmBH,GAC7BL,MACE,UAAUQ,6BAAqCH,KAC/C,kBACA,CAAEG,YAAWH,cAEjB,SAMI,MAAOI,2BAA2Bf,WACtC,WAAAE,CAAYC,EAAiCa,GAC3CV,MACE,0BAA0BH,IAC1B,iBACA,CAAEa,aAJuCT,KAAAS,UAM7C,SAMI,MAAOC,oCAAoCjB,WAC/C,WAAAE,GACEI,MACE,+BACA,4BAEJ,SAMI,MAAOY,qBAAqBlB,WAChC,WAAAE,CAAYiB,EAAmBC,GAC7Bd,MACE,GAAGa,qBAA6BC,MAChC,UACA,CAAED,YAAWC,WAEjB,SAMI,MAAOC,wBAAwBrB,WACnC,WAAAE,CACEiB,EACAH,EACgBM,GAEhBhB,MACE,aAAaa,WAAmBH,IAChC,mBACA,CAAEA,WAAUM,cAAeA,GAAenB,UAL5BI,KAAAe,eAOlB,SAMI,SAAUC,aAAaC,GAC3B,OAAOA,aAAiBxB,UAC1B,QAKM,SAAUyB,gBAAgBD,GAC9B,OAAID,aAAaC,IAIbA,aAAiBvB,MAHZuB,EAAMrB,QAORuB,OAAOF,EAChB","ignoreList":[]}
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,117 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Helper utility functions
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Masks an API key for secure display
|
|
6
|
-
* @param apiKey - The API key to mask
|
|
7
|
-
* @param visibleChars - Number of characters to show at the beginning (default: 8)
|
|
8
|
-
* @returns Masked API key string
|
|
9
|
-
*/
|
|
10
|
-
export function maskApiKey(apiKey, visibleChars = 8) {
|
|
11
|
-
if (!apiKey || apiKey.length <= visibleChars) {
|
|
12
|
-
return apiKey ? apiKey.substring(0, 4) + '***' : '***';
|
|
13
|
-
}
|
|
14
|
-
return apiKey.substring(0, visibleChars) + '***';
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Finds a provider by ID, name, or type
|
|
18
|
-
* @param providers - Array of providers to search
|
|
19
|
-
* @param identifier - Provider ID, name, or type
|
|
20
|
-
* @returns Found provider or undefined
|
|
21
|
-
*/
|
|
22
|
-
export function findProvider(providers, identifier) {
|
|
23
|
-
return providers.find((p) => p.id === identifier || p.name === identifier || p.provider_type === identifier);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Provider type mapping configuration
|
|
27
|
-
*/
|
|
28
|
-
export const PROVIDER_TYPE_MAP = {
|
|
29
|
-
zhipu: ['zhipu', '智谱 Coding Plan'],
|
|
30
|
-
'智谱': ['zhipu', '智谱 Coding Plan'],
|
|
31
|
-
minimax: ['minimax', 'MiniMax Coding Plan'],
|
|
32
|
-
kimi: ['kimi', 'Kimi Coding Plan'],
|
|
33
|
-
claude: ['claude', 'Claude (Official)'],
|
|
34
|
-
zenmux: ['zenmux', 'ZenMux.ai'],
|
|
35
|
-
streamlake: ['streamlake', '快手 StreamLake Coding Plan'],
|
|
36
|
-
kuaishou: ['streamlake', '快手 StreamLake Coding Plan'],
|
|
37
|
-
'快手': ['streamlake', '快手 StreamLake Coding Plan'],
|
|
38
|
-
volcengine: ['volcengine', '火山引擎 Coding Plan'],
|
|
39
|
-
'火山': ['volcengine', '火山引擎 Coding Plan'],
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Gets provider type and display name from identifier
|
|
43
|
-
* @param identifier - Provider identifier
|
|
44
|
-
* @returns Tuple of [providerType, displayName] or null
|
|
45
|
-
*/
|
|
46
|
-
export function getProviderTypeInfo(identifier) {
|
|
47
|
-
return PROVIDER_TYPE_MAP[identifier] || null;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Formats file size for display
|
|
51
|
-
* @param bytes - Size in bytes
|
|
52
|
-
* @returns Formatted size string
|
|
53
|
-
*/
|
|
54
|
-
export function formatBytes(bytes) {
|
|
55
|
-
if (bytes === 0)
|
|
56
|
-
return '0 B';
|
|
57
|
-
const k = 1024;
|
|
58
|
-
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
59
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
60
|
-
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Safely executes a function and handles errors
|
|
64
|
-
* @param fn - Function to execute
|
|
65
|
-
* @param errorHandler - Error handler function
|
|
66
|
-
* @returns Result or undefined if error occurred
|
|
67
|
-
*/
|
|
68
|
-
export function safeExecute(fn, errorHandler) {
|
|
69
|
-
try {
|
|
70
|
-
return fn();
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
74
|
-
if (errorHandler) {
|
|
75
|
-
errorHandler(err);
|
|
76
|
-
}
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Creates a promise that resolves after a delay
|
|
82
|
-
* @param ms - Milliseconds to delay
|
|
83
|
-
* @returns Promise that resolves after delay
|
|
84
|
-
*/
|
|
85
|
-
export function delay(ms) {
|
|
86
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Checks if a value is defined and not null
|
|
90
|
-
* @param value - Value to check
|
|
91
|
-
* @returns True if value is defined and not null
|
|
92
|
-
*/
|
|
93
|
-
export function isDefined(value) {
|
|
94
|
-
return value !== null && value !== undefined;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Gets the active model for a provider
|
|
98
|
-
* @param provider - Provider configuration
|
|
99
|
-
* @returns Active model name or undefined
|
|
100
|
-
*/
|
|
101
|
-
export function getActiveModel(provider) {
|
|
102
|
-
return provider.current_model || provider.models[0];
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Wraps an async function with timeout
|
|
106
|
-
* @param promise - Promise to wrap
|
|
107
|
-
* @param timeoutMs - Timeout in milliseconds
|
|
108
|
-
* @param errorMessage - Error message on timeout
|
|
109
|
-
* @returns Promise that rejects on timeout
|
|
110
|
-
*/
|
|
111
|
-
export function withTimeout(promise, timeoutMs, errorMessage = 'Operation timed out') {
|
|
112
|
-
return Promise.race([
|
|
113
|
-
promise,
|
|
114
|
-
new Promise((_, reject) => setTimeout(() => reject(new Error(errorMessage)), timeoutMs)),
|
|
115
|
-
]);
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=helpers.js.map
|
|
1
|
+
export function maskApiKey(e,n=8){return!e||e.length<=n?e?e.substring(0,4)+"***":"***":e.substring(0,n)+"***"}export function findProvider(e,n){return e.find(e=>e.id===n||e.name===n||e.provider_type===n)}export const PROVIDER_TYPE_MAP={zhipu:["zhipu","智谱 Coding Plan"],"智谱":["zhipu","智谱 Coding Plan"],minimax:["minimax","MiniMax Coding Plan"],kimi:["kimi","Kimi Coding Plan"],claude:["claude","Claude (Official)"],zenmux:["zenmux","ZenMux.ai"],streamlake:["streamlake","快手 StreamLake Coding Plan"],kuaishou:["streamlake","快手 StreamLake Coding Plan"],"快手":["streamlake","快手 StreamLake Coding Plan"],volcengine:["volcengine","火山引擎 Coding Plan"],"火山":["volcengine","火山引擎 Coding Plan"]};export function getProviderTypeInfo(e){return PROVIDER_TYPE_MAP[e]||null}export function formatBytes(e){if(0===e)return"0 B";const n=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,n)).toFixed(2))} ${["B","KB","MB","GB"][n]}`}export function safeExecute(e,n){try{return e()}catch(e){const t=e instanceof Error?e:new Error(String(e));return void(n&&n(t))}}export function delay(e){return new Promise(n=>setTimeout(n,e))}export function isDefined(e){return null!=e}export function getActiveModel(e){return e.current_model||e.models[0]}export function withTimeout(e,n,t="Operation timed out"){return Promise.race([e,new Promise((e,r)=>setTimeout(()=>r(new Error(t)),n))])}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","
|
|
1
|
+
{"version":3,"file":"/Users/qiutian00lw/Code/cckit_cli/cckit-node/dist/utils/helpers.js","names":["maskApiKey","apiKey","visibleChars","length","substring","findProvider","providers","identifier","find","p","id","name","provider_type","PROVIDER_TYPE_MAP","zhipu","minimax","kimi","claude","zenmux","streamlake","kuaishou","volcengine","getProviderTypeInfo","formatBytes","bytes","i","Math","floor","log","parseFloat","pow","toFixed","safeExecute","fn","errorHandler","error","err","Error","String","delay","ms","Promise","resolve","setTimeout","isDefined","value","getActiveModel","provider","current_model","models","withTimeout","promise","timeoutMs","errorMessage","race","_","reject"],"sources":["../../src/utils/helpers.ts"],"mappings":"OAYM,SAAUA,WAAWC,EAAgBC,EAAuB,GAChE,OAAKD,GAAUA,EAAOE,QAAUD,EACvBD,EAASA,EAAOG,UAAU,EAAG,GAAK,MAAQ,MAE5CH,EAAOG,UAAU,EAAGF,GAAgB,KAC7C,QAQM,SAAUG,aACdC,EACAC,GAEA,OAAOD,EAAUE,KACdC,GAAMA,EAAEC,KAAOH,GAAcE,EAAEE,OAASJ,GAAcE,EAAEG,gBAAkBL,EAE/E,QAKO,MAAMM,kBAAsD,CACjEC,MAAO,CAAC,QAAS,kBACjB,KAAM,CAAC,QAAS,kBAChBC,QAAS,CAAC,UAAW,uBACrBC,KAAM,CAAC,OAAQ,oBACfC,OAAQ,CAAC,SAAU,qBACnBC,OAAQ,CAAC,SAAU,aACnBC,WAAY,CAAC,aAAc,6BAC3BC,SAAU,CAAC,aAAc,6BACzB,KAAM,CAAC,aAAc,6BACrBC,WAAY,CAAC,aAAc,oBAC3B,KAAM,CAAC,aAAc,4BAQjB,SAAUC,oBACdf,GAEA,OAAOM,kBAAkBN,IAAe,IAC1C,QAOM,SAAUgB,YAAYC,GAC1B,GAAc,IAAVA,EAAa,MAAO,MACxB,MAEMC,EAAIC,KAAKC,MAAMD,KAAKE,IAAIJ,GAASE,KAAKE,IAFlC,OAGV,MAAO,GAAGC,YAAYL,EAAQE,KAAKI,IAHzB,KAGgCL,IAAIM,QAAQ,OAFxC,CAAC,IAAK,KAAM,KAAM,MAEmCN,IACrE,QAQM,SAAUO,YACdC,EACAC,GAEA,IACE,OAAOD,GACT,CAAE,MAAOE,GACP,MAAMC,EAAMD,aAAiBE,MAAQF,EAAQ,IAAIE,MAAMC,OAAOH,IAI9D,YAHID,GACFA,EAAaE,GAGjB,CACF,QAOM,SAAUG,MAAMC,GACpB,OAAO,IAAIC,QAASC,GAAYC,WAAWD,EAASF,GACtD,QAOM,SAAUI,UAAaC,GAC3B,OAAOA,OACT,QAOM,SAAUC,eAAeC,GAC7B,OAAOA,EAASC,eAAiBD,EAASE,OAAO,EACnD,QASM,SAAUC,YACdC,EACAC,EACAC,EAAuB,uBAEvB,OAAOZ,QAAQa,KAAK,CAClBH,EACA,IAAIV,QAAW,CAACc,EAAGC,IACjBb,WAAW,IAAMa,EAAO,IAAInB,MAAMgB,IAAgBD,KAGxD","ignoreList":[]}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Utilities index
|
|
3
|
-
*/
|
|
4
|
-
export * from './helpers.js';
|
|
5
|
-
export * from './constants.js';
|
|
6
|
-
export * from './errors.js';
|
|
7
|
-
export * from './logger.js';
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export*from"./helpers.js";export*from"./constants.js";export*from"./errors.js";export*from"./logger.js";
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"/Users/qiutian00lw/Code/cckit_cli/cckit-node/dist/utils/index.js","names":["from"],"sources":["../../src/utils/index.ts"],"mappings":"MAIAA,KAAc,qBACdA,KAAc,uBACdA,KAAc,oBACdA,KAAc","ignoreList":[]}
|