opencommand-plugin 0.0.7 → 0.0.8
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/index.d.ts +2 -3
- package/dist/index.js +8 -23
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -77,7 +77,6 @@ export declare class BrowserCookieExtractor {
|
|
|
77
77
|
export declare class OpenCommandPlugin {
|
|
78
78
|
private proxyManager;
|
|
79
79
|
private secretStorage;
|
|
80
|
-
private cookieExtractor;
|
|
81
80
|
private startPromise;
|
|
82
81
|
private preloadPromise;
|
|
83
82
|
private readonly commandCodeTokenKey;
|
|
@@ -92,7 +91,7 @@ export declare class OpenCommandPlugin {
|
|
|
92
91
|
deactivate(): Promise<void>;
|
|
93
92
|
getCurrentProxyConfig(): ProxyConfig | undefined;
|
|
94
93
|
private loadCommandCodeToken;
|
|
95
|
-
private
|
|
94
|
+
private loadConfiguredSessionCookie;
|
|
96
95
|
private saveOpenCodeConfig;
|
|
97
96
|
private persistProxyConfig;
|
|
98
97
|
setCommandCodeToken(token: string): Promise<void>;
|
|
@@ -126,7 +125,7 @@ export declare const OpenCommandOpenCodePlugin: () => Promise<{
|
|
|
126
125
|
loader: () => Promise<{
|
|
127
126
|
apiKey: string;
|
|
128
127
|
baseURL: string;
|
|
129
|
-
}>;
|
|
128
|
+
} | null>;
|
|
130
129
|
methods: never[];
|
|
131
130
|
};
|
|
132
131
|
config: (config: OpenCodeConfig) => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -566,7 +566,6 @@ export class OpenCommandPlugin {
|
|
|
566
566
|
this.proxyManager = new ProxyManager(proxyBinaryPath);
|
|
567
567
|
const dir = storageDir || `${process.env.HOME || "/tmp"}/.opencommand`;
|
|
568
568
|
this.secretStorage = new SecretStorage(dir);
|
|
569
|
-
this.cookieExtractor = new BrowserCookieExtractor();
|
|
570
569
|
}
|
|
571
570
|
async activate() {
|
|
572
571
|
debugLog("OpenCommand Plugin activating...");
|
|
@@ -621,10 +620,7 @@ export class OpenCommandPlugin {
|
|
|
621
620
|
debugWarn("No COMMAND_CODE_TOKEN found. Please configure your CommandCode API key.");
|
|
622
621
|
return undefined;
|
|
623
622
|
}
|
|
624
|
-
const sessionCookie = await this.
|
|
625
|
-
if (!sessionCookie) {
|
|
626
|
-
debugWarn("No CommandCode Studio cookie found. Inference works, but usage scraping may be unavailable.");
|
|
627
|
-
}
|
|
623
|
+
const sessionCookie = await this.loadConfiguredSessionCookie();
|
|
628
624
|
const config = await this.proxyManager.start({
|
|
629
625
|
commandCodeToken,
|
|
630
626
|
sessionCookie,
|
|
@@ -647,16 +643,8 @@ export class OpenCommandPlugin {
|
|
|
647
643
|
}
|
|
648
644
|
return token;
|
|
649
645
|
}
|
|
650
|
-
async
|
|
651
|
-
|
|
652
|
-
if (configured)
|
|
653
|
-
return configured;
|
|
654
|
-
const extracted = await this.cookieExtractor.extractCommandCodeCookie();
|
|
655
|
-
if (extracted) {
|
|
656
|
-
await this.secretStorage.set(this.sessionCookieKey, extracted);
|
|
657
|
-
debugLog("✓ CommandCode Studio cookie discovered from local browser profile");
|
|
658
|
-
}
|
|
659
|
-
return extracted;
|
|
646
|
+
async loadConfiguredSessionCookie() {
|
|
647
|
+
return firstDefined(process.env.CC_SESSION_COOKIE, await this.secretStorage.get(this.sessionCookieKey));
|
|
660
648
|
}
|
|
661
649
|
saveOpenCodeConfig(config) {
|
|
662
650
|
const proxyUrl = `http://localhost:${config.port}`;
|
|
@@ -697,7 +685,7 @@ export class OpenCommandPlugin {
|
|
|
697
685
|
await this.proxyManager.stop();
|
|
698
686
|
const config = await this.proxyManager.start({
|
|
699
687
|
commandCodeToken,
|
|
700
|
-
sessionCookie: await this.
|
|
688
|
+
sessionCookie: await this.loadConfiguredSessionCookie(),
|
|
701
689
|
});
|
|
702
690
|
this.saveOpenCodeConfig(config);
|
|
703
691
|
}
|
|
@@ -907,21 +895,18 @@ export const OpenCommandOpenCodePlugin = async () => ({
|
|
|
907
895
|
auth: {
|
|
908
896
|
provider: PROVIDER_ID,
|
|
909
897
|
loader: async () => {
|
|
910
|
-
const
|
|
911
|
-
|
|
912
|
-
|
|
898
|
+
const proxyConfig = await getRuntimePlugin().ensureStarted();
|
|
899
|
+
if (!proxyConfig)
|
|
900
|
+
return null;
|
|
913
901
|
return {
|
|
914
902
|
apiKey: PROVIDER_API_KEY_PLACEHOLDER,
|
|
915
|
-
baseURL: proxyConfig
|
|
916
|
-
? `http://localhost:${proxyConfig.port}/v1`
|
|
917
|
-
: DEFAULT_PROXY_BASE_URL,
|
|
903
|
+
baseURL: `http://localhost:${proxyConfig.port}/v1`,
|
|
918
904
|
};
|
|
919
905
|
},
|
|
920
906
|
methods: [],
|
|
921
907
|
},
|
|
922
908
|
config: async (config) => {
|
|
923
909
|
registerOpenCommandProvider(config, DEFAULT_PROXY_BASE_URL, readCachedOpenCommandModels() ?? COMMAND_CODE_GO_PLAN_MODELS);
|
|
924
|
-
getRuntimePlugin().preloadForOpenCode();
|
|
925
910
|
},
|
|
926
911
|
});
|
|
927
912
|
export default OpenCommandOpenCodePlugin;
|