@xopcai/xopc 0.0.163 → 0.0.164
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-Xj95LzTv.js → activity-store-DkALQFJT.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-C-QeUFwU.js → agent-avatar-dicebear-RpxkQtQ3.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CxpwxMPE.js +2 -0
- package/dist/gateway/static/root/assets/{api-BTLmAm1_.js → api-DPIXEcIq.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-zc6Gf-S5.js → app-management-settings-panel-DLdjfMXB.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-0fMLnOWn.js → appearance-settings-C89-uxkq.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-k-tZbaRB.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-DOiR_E21.js → archive-plugin-CqbH5geE.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BxmYl1D1.js → attachment-load-CeU4Qiot.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-BhZOirad.js → automation-suggestion-card-WiOuqXq9.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-Bdn3dgC_.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DTTKsvgk.js → binary-plugins-C5TdzrhJ.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-C7se7iqg.js → block-editor-BjvWhphG.js} +47 -47
- package/dist/gateway/static/root/assets/browser-settings-page-GsVTGfGs.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-kxmStCcv.js → browser-workflow-inputs-DXmzQ3nk.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-CwYf9OM_.js → browser-workflows-page-C1-ptRe4.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-6d4kVjzl.js +2 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-BZKh2cWX.js → capability-presets-api-C0pVlUyc.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DCxy5Ls_.js +2 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-r7tdbnJE.js → channel-recipient-api-B5rLegwk.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-Bg3P8k0f.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-DZZq0upi.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-BpnQYAxA.js → connector-logo-CuI5w4qM.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-6UR7yhIZ.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-BvG8vDXZ.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-uv8Grtgk.js → desktop-pet-settings-CR__kZ8C.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-C4TTvf7p.js → directory-picker-path-field-BblWMz3e.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-CzJAUPvM.js → dreaming-settings-DHMPugDE.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-Ci2mOYUt.js → extension-debug-page-ByVY1gZg.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DeXdmhXQ.js → extension-page-DLCKKtbK.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-C93vaOsU.js → extension-settings-page-M-rhlFBC.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-C31Hlblp.js → gateway-config-api-DZHqhbXH.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-D3zS6RZh.js → gateway-settings-CZswIehx.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CSRvCqxh.js → gateway-startup-retry-ulwTJovP.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-TbyRfDas.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-B-QBVOf2.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-D4wYNRrf.js → goals-config-api-DMxG6f0N.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BGxki8BR.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-Bx2jVvhQ.js → goals-settings-G-w1gCYD.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-BEIF1eXy.js → heartbeat-settings-Csb90R59.js} +1 -1
- package/dist/gateway/static/root/assets/{index-HZdBKfk_.js → index-CGwuxvzr.js} +70 -70
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DOEDpvTM.js → keyboard-shortcuts-settings-C_Bl3YOr.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-BR2tBhO3.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-B0OpGpxv.js → local-apps-page-_8Rv-tSk.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Ys6RP7Be.js → locale-store-C_ax27uc.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-CwF0C_Z2.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-CEZwysCH.js → markdown-split-CZnZS6gq.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CpGKE7B0.js → media-plugins-C2XLYC6G.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-BzI9Wx30.js → messages-C96Zjb0V.js} +2 -2
- package/dist/gateway/static/root/assets/{notes-page-CdiuDZ5a.js → notes-page-BkuZxTFo.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-CD4FADi7.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-BkH5AVV2.js → page-tabs-DR2FGC4E.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CQai8f9D.js → preview-open-alternatives-B65O8wBL.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-B2kSdB2b.js → product-open-page-Cag-utLH.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-COKtUblD.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-QYmqanBN.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-BU_gBU0f.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-NGYnO7n7.js → save-bar-controls-DCWpFnPc.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-nLOphnv3.js → schedule-field-ClacZdvE.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-D0e90ndE.js → schema-form-BVlbEipU.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-u-Pjbzfm.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-1Yck1PKq.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-X2Sl-EAk.js → settings-form-section-GSNlQWSW.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DOnUabm7.js → settings-loading-skeleton-08Ae5sB_.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-C4UUNi1n.js → settings-page-BseJD4I-.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-C1yYqbT6.js → settings-page-layout-bSliH-Y3.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CGRhJVlt.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-Cfy_pH7V.js → share-preview-page-C114OpTx.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-BRFpWFgI.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-cVjU2GnN.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-CoMTjtRT.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-Da81RJ6G.js → system-settings-panel-El8cDcTY.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-DflSp9o4.js → theme-store-D37XLD_C.js} +1 -1
- package/dist/gateway/static/root/assets/{time-picker-BIkOW-2L.js → time-picker-CU7hhD8T.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib--HptwFcD.js → typed-models-lib-kToxD7Rc.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CMHY4ZfW.js → use-channel-catalog-DBh0dOC9.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-C0xYCSXB.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-nvIZerol.js → voice-api-key-field-DzEpwYaU.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-DakZqR85.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-CswqPbTT.js +1 -0
- package/dist/gateway/static/root/assets/work-page-DYRXEk8m.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-D96MHABy.js → workflow-run-setup-panel-BwSxyVMM.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CiLSYGuN.js +11 -0
- package/dist/gateway/static/root/index.html +6 -6
- package/dist/package.js +1 -1
- package/dist/src/agent/embedded/model-runtime.d.ts +4 -0
- package/dist/src/agent/embedded/model-runtime.js +49 -0
- package/dist/src/agent/embedded/session-runner.js +3 -3
- package/dist/src/auth/credentials.js +45 -2
- package/dist/src/auth/index.js +2 -1
- package/dist/src/auth/oauth/anthropic.js +27 -24
- package/dist/src/auth/oauth/github-copilot.js +20 -15
- package/dist/src/auth/oauth/google-antigravity.js +9 -2
- package/dist/src/auth/oauth/google-gemini-cli.js +9 -2
- package/dist/src/auth/oauth/google-oauth/google-antigravity.js +47 -40
- package/dist/src/auth/oauth/google-oauth/google-gemini-cli.js +48 -41
- package/dist/src/auth/oauth/google-oauth/oauth-page.js +7 -2
- package/dist/src/auth/oauth/google-oauth/pkce.js +4 -1
- package/dist/src/auth/oauth/index.d.ts +2 -0
- package/dist/src/auth/oauth/index.js +24 -10
- package/dist/src/auth/oauth/kimi-coding.js +76 -71
- package/dist/src/auth/oauth/minimax-cn.js +78 -73
- package/dist/src/auth/oauth/minimax.js +78 -73
- package/dist/src/auth/oauth/openai-codex.js +31 -25
- package/dist/src/auth/oauth/pkce.js +4 -1
- package/dist/src/auth/oauth/registry.d.ts +13 -0
- package/dist/src/auth/oauth/registry.js +65 -0
- package/dist/src/auth/oauth/xopc-cloud.d.ts +2 -0
- package/dist/src/auth/oauth/xopc-cloud.js +101 -0
- package/dist/src/auth/sync-provider-auth.js +5 -0
- package/dist/src/cli/utils/oauth-providers.d.ts +3 -26
- package/dist/src/cli/utils/oauth-providers.js +6 -80
- package/dist/src/config/models-json.js +8 -0
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/oauth-async.js +3 -19
- package/dist/src/gateway/hono/oauth.js +3 -19
- package/dist/src/gateway/hono/routes/models.js +1 -55
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/providers/domestic-presets.d.ts +0 -20
- package/dist/src/providers/domestic-presets.js +0 -25
- package/dist/src/providers/index.js +9 -0
- package/dist/src/providers/model-catalog-store.d.ts +20 -58
- package/dist/src/providers/model-catalog-store.js +18 -57
- package/dist/src/providers/model-catalog-sync-service.d.ts +3 -4
- package/dist/src/providers/model-catalog-sync-service.js +3 -13
- package/dist/src/providers/model-registry.js +0 -2
- package/dist/src/providers/xopc-cloud-model-source.d.ts +30 -0
- package/dist/src/providers/xopc-cloud-model-source.js +68 -0
- package/dist/src/work-discovery/analyzer.js +27 -14
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-DVKlWKJE.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-BZXEJDIV.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-B8CnkoXv.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-BCPWKI9V.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-C7lr_mX2.js +0 -2
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Ble9kHRu.js +0 -2
- package/dist/gateway/static/root/assets/channels-settings-CtQQQHrv.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-_VirfMKW.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BXWJSJeY.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-B86W4a5c.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-CWp2b7__.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-Dtm29FxD.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-jMzBJs6e.js +0 -2
- package/dist/gateway/static/root/assets/local-app-workbench-page-CseW9jD3.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-DVqPbth5.js +0 -7
- package/dist/gateway/static/root/assets/notes-workbench-mrc3xtpn.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-CfhPJLkH.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BfMoKjdm.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CrDtcsZ9.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-D3DbF3dV.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BZp0O2dH.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-84iao4DZ.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DtcwQvRG.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-L7j5Gc8Z.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-1Ps8PjsP.js +0 -2
- package/dist/gateway/static/root/assets/user-context-page-BYAAs2iW.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-J35JkJ7_.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-C4wYDYqV.js +0 -1
- package/dist/gateway/static/root/assets/work-page-DMvitV6c.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-JMN0nMbM.js +0 -11
- package/dist/src/agent/embedded/xopc-auth-storage.d.ts +0 -19
- package/dist/src/agent/embedded/xopc-auth-storage.js +0 -40
- package/dist/src/providers/xopc-cloud-connection.d.ts +0 -51
- package/dist/src/providers/xopc-cloud-connection.js +0 -196
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=20260713-1" />
|
|
12
12
|
<link rel="manifest" href="/site.webmanifest?v=20260713-1" />
|
|
13
13
|
<title>xopc</title>
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-CGwuxvzr.js"></script>
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-aKtaBQYM.js">
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-zJ_50EbN.js">
|
|
17
17
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-BOUWij0V.js">
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
<link rel="modulepreload" crossorigin href="/assets/check-DUBLcKHA.js">
|
|
25
25
|
<link rel="modulepreload" crossorigin href="/assets/circle-alert-BEjgurr2.js">
|
|
26
26
|
<link rel="modulepreload" crossorigin href="/assets/middleware-Pd0e8Igk.js">
|
|
27
|
-
<link rel="modulepreload" crossorigin href="/assets/messages-
|
|
28
|
-
<link rel="modulepreload" crossorigin href="/assets/locale-store-
|
|
27
|
+
<link rel="modulepreload" crossorigin href="/assets/messages-C96Zjb0V.js">
|
|
28
|
+
<link rel="modulepreload" crossorigin href="/assets/locale-store-C_ax27uc.js">
|
|
29
29
|
<link rel="modulepreload" crossorigin href="/assets/cn-JdwAhgNB.js">
|
|
30
30
|
<link rel="modulepreload" crossorigin href="/assets/schemas-DgQq6Z5S.js">
|
|
31
31
|
<link rel="modulepreload" crossorigin href="/assets/product-delivery-BTRT9kCS.js">
|
|
32
32
|
<link rel="modulepreload" crossorigin href="/assets/config-reload-event-Bjh2zoKp.js">
|
|
33
33
|
<link rel="modulepreload" crossorigin href="/assets/copy-to-clipboard-HOJ79TWv.js">
|
|
34
|
-
<link rel="modulepreload" crossorigin href="/assets/gateway-startup-retry-
|
|
35
|
-
<link rel="modulepreload" crossorigin href="/assets/activity-store-
|
|
36
|
-
<link rel="modulepreload" crossorigin href="/assets/theme-store-
|
|
34
|
+
<link rel="modulepreload" crossorigin href="/assets/gateway-startup-retry-ulwTJovP.js">
|
|
35
|
+
<link rel="modulepreload" crossorigin href="/assets/activity-store-DkALQFJT.js">
|
|
36
|
+
<link rel="modulepreload" crossorigin href="/assets/theme-store-D37XLD_C.js">
|
|
37
37
|
<link rel="stylesheet" crossorigin href="/assets/index-BXtJvaQl.css">
|
|
38
38
|
</head>
|
|
39
39
|
<body>
|
package/dist/package.js
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ModelRuntime } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
export declare function resolveEmbeddedProviderApiKeySync(providerId: string): string | undefined;
|
|
3
|
+
export declare function createEmbeddedModelRuntime(): Promise<ModelRuntime>;
|
|
4
|
+
export declare function applyEmbeddedProviderCredential(modelRuntime: Pick<ModelRuntime, 'setRuntimeApiKey'>, providerId: string): Promise<void>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { init_paths, resolveModelsJsonPath } from "../../config/paths.js";
|
|
2
|
+
import { init_sync_provider_auth, resolveProviderApiKeySync } from "../../auth/sync-provider-auth.js";
|
|
3
|
+
import { getModelCatalogStore, init_model_catalog_store } from "../../providers/model-catalog-store.js";
|
|
4
|
+
import { CredentialResolver, init_credentials } from "../../auth/credentials.js";
|
|
5
|
+
import { getApiKeySync, init_providers } from "../../providers/index.js";
|
|
6
|
+
import { ModelRuntime } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import { InMemoryCredentialStore, InMemoryModelsStore } from "@earendil-works/pi-ai";
|
|
8
|
+
//#region src/agent/embedded/model-runtime.ts
|
|
9
|
+
init_credentials();
|
|
10
|
+
init_sync_provider_auth();
|
|
11
|
+
init_paths();
|
|
12
|
+
init_providers();
|
|
13
|
+
init_model_catalog_store();
|
|
14
|
+
function resolveEmbeddedProviderApiKeySync(providerId) {
|
|
15
|
+
return resolveProviderApiKeySync(providerId) ?? getApiKeySync(providerId);
|
|
16
|
+
}
|
|
17
|
+
async function createEmbeddedModelRuntime() {
|
|
18
|
+
const modelRuntime = await ModelRuntime.create({
|
|
19
|
+
credentials: new InMemoryCredentialStore(),
|
|
20
|
+
modelsPath: resolveModelsJsonPath(),
|
|
21
|
+
modelsStore: new InMemoryModelsStore()
|
|
22
|
+
});
|
|
23
|
+
for (const source of Object.values(getModelCatalogStore().load().sources)) modelRuntime.registerProvider(source.providerId, {
|
|
24
|
+
name: source.providerId,
|
|
25
|
+
baseUrl: source.baseUrl,
|
|
26
|
+
api: source.api,
|
|
27
|
+
models: source.models.filter((model) => model.availability === "available").map((model) => ({
|
|
28
|
+
id: model.id,
|
|
29
|
+
name: model.name,
|
|
30
|
+
reasoning: false,
|
|
31
|
+
input: ["text"],
|
|
32
|
+
cost: {
|
|
33
|
+
input: 0,
|
|
34
|
+
output: 0,
|
|
35
|
+
cacheRead: 0,
|
|
36
|
+
cacheWrite: 0
|
|
37
|
+
},
|
|
38
|
+
contextWindow: 128e3,
|
|
39
|
+
maxTokens: model.maxOutputTokens ?? 16384
|
|
40
|
+
}))
|
|
41
|
+
});
|
|
42
|
+
return modelRuntime;
|
|
43
|
+
}
|
|
44
|
+
async function applyEmbeddedProviderCredential(modelRuntime, providerId) {
|
|
45
|
+
const key = await new CredentialResolver().resolveApiKey(providerId) ?? getApiKeySync(providerId);
|
|
46
|
+
if (key && key !== "extension-managed") await modelRuntime.setRuntimeApiKey(providerId, key, { allowNetwork: false });
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { applyEmbeddedProviderCredential, createEmbeddedModelRuntime, resolveEmbeddedProviderApiKeySync };
|
|
@@ -3,7 +3,7 @@ import { init_logger } from "../../utils/logger.js";
|
|
|
3
3
|
import { guardSessionManager } from "./session-tool-result-guard.js";
|
|
4
4
|
import { transformUserMessageForPersistence } from "../inbound/attachment-pipeline.js";
|
|
5
5
|
import { openSqliteHydratingSessionManager } from "./sqlite-hydrating-session-manager.js";
|
|
6
|
-
import {
|
|
6
|
+
import { applyEmbeddedProviderCredential, createEmbeddedModelRuntime, resolveEmbeddedProviderApiKeySync } from "./model-runtime.js";
|
|
7
7
|
import { wrapStreamFnForXopcExtensions } from "./xopc-stream-bridge.js";
|
|
8
8
|
import { xopcToolsToDefinitions } from "./xopc-tools-bridge.js";
|
|
9
9
|
import { applySystemPromptOverrideToSession } from "./system-prompt-override.js";
|
|
@@ -14,7 +14,7 @@ init_logger();
|
|
|
14
14
|
const log = createLogger("EmbeddedSessionRunner");
|
|
15
15
|
const DEFAULT_IDLE_TTL_MS = 5 * 6e4;
|
|
16
16
|
function providerCredentialRevision(providerId) {
|
|
17
|
-
const apiKey =
|
|
17
|
+
const apiKey = resolveEmbeddedProviderApiKeySync(providerId);
|
|
18
18
|
return apiKey ? createHash("sha256").update(apiKey).digest("base64url") : "none";
|
|
19
19
|
}
|
|
20
20
|
function buildEmbeddedRunnerFingerprint(input) {
|
|
@@ -175,7 +175,7 @@ var EmbeddedSessionRunnerPool = class {
|
|
|
175
175
|
const toolDefs = xopcToolsToDefinitions(tools);
|
|
176
176
|
const toolNames = tools.map((t) => t.name);
|
|
177
177
|
const modelRuntime = await createEmbeddedModelRuntime();
|
|
178
|
-
await
|
|
178
|
+
await applyEmbeddedProviderCredential(modelRuntime, model.provider);
|
|
179
179
|
const resourceLoader = new DefaultResourceLoader({
|
|
180
180
|
cwd: workspaceDir,
|
|
181
181
|
agentDir: getAgentDir(),
|
|
@@ -3,6 +3,7 @@ import { createLogger } from "../utils/logger/index.js";
|
|
|
3
3
|
import { init_logger } from "../utils/logger.js";
|
|
4
4
|
import { init_paths, resolveAgentAuthProfilesPath, resolveAuthProfilesPath, resolveCredentialsDir, resolveOAuthPath } from "../config/paths.js";
|
|
5
5
|
import { init_write_file_atomic, writeTextAtomic } from "../infra/write-file-atomic.js";
|
|
6
|
+
import { getOAuthProviderDefinition, init_registry } from "./oauth/registry.js";
|
|
6
7
|
import { getApiKeyFromEnv, init_env_keys } from "../providers/env-keys.js";
|
|
7
8
|
import { dirname, join } from "path";
|
|
8
9
|
import { mkdir, readFile, readdir, rm } from "fs/promises";
|
|
@@ -18,14 +19,16 @@ async function resolveApiKey(provider, options) {
|
|
|
18
19
|
async function hasCredentials(provider, options) {
|
|
19
20
|
return getCredentialResolver(options).hasCredentials(provider);
|
|
20
21
|
}
|
|
21
|
-
var log, warnedExpiredOAuthTokens, CredentialResolver, defaultResolver;
|
|
22
|
+
var log, warnedExpiredOAuthTokens, oauthRefreshes, CredentialResolver, defaultResolver;
|
|
22
23
|
var init_credentials = __esmMin((() => {
|
|
23
24
|
init_write_file_atomic();
|
|
24
25
|
init_logger();
|
|
25
26
|
init_env_keys();
|
|
26
27
|
init_paths();
|
|
28
|
+
init_registry();
|
|
27
29
|
log = createLogger("Credentials");
|
|
28
30
|
warnedExpiredOAuthTokens = /* @__PURE__ */ new Set();
|
|
31
|
+
oauthRefreshes = /* @__PURE__ */ new Map();
|
|
29
32
|
CredentialResolver = class {
|
|
30
33
|
credentialsDir;
|
|
31
34
|
agentId;
|
|
@@ -42,6 +45,7 @@ var init_credentials = __esmMin((() => {
|
|
|
42
45
|
*/
|
|
43
46
|
async resolveApiKey(provider) {
|
|
44
47
|
const normalizedProvider = provider.toLowerCase();
|
|
48
|
+
if (getOAuthProviderDefinition(normalizedProvider)?.oauthOnly) return (await this.loadOAuthToken(normalizedProvider))?.access ?? null;
|
|
45
49
|
if (this.agentId) {
|
|
46
50
|
const agentKey = await this.loadFromAgentCredentials(normalizedProvider);
|
|
47
51
|
if (agentKey) {
|
|
@@ -89,6 +93,7 @@ var init_credentials = __esmMin((() => {
|
|
|
89
93
|
*/
|
|
90
94
|
async resolveApiKeySource(provider) {
|
|
91
95
|
const normalizedProvider = provider.toLowerCase();
|
|
96
|
+
if (getOAuthProviderDefinition(normalizedProvider)?.oauthOnly) return await this.loadOAuthToken(normalizedProvider) ? "oauth" : null;
|
|
92
97
|
if (this.agentId) {
|
|
93
98
|
if (await this.loadFromAgentCredentials(normalizedProvider)) return "agent";
|
|
94
99
|
}
|
|
@@ -132,6 +137,7 @@ var init_credentials = __esmMin((() => {
|
|
|
132
137
|
*/
|
|
133
138
|
async saveApiKey(provider, key, options = {}) {
|
|
134
139
|
const normalizedProvider = provider.toLowerCase();
|
|
140
|
+
if (getOAuthProviderDefinition(normalizedProvider)?.oauthOnly) throw new Error(`${normalizedProvider} only supports OAuth credentials`);
|
|
135
141
|
const profileId = options.profileName ? `${normalizedProvider}:${options.profileName}` : `${normalizedProvider}:default`;
|
|
136
142
|
const profile = {
|
|
137
143
|
type: "api_key",
|
|
@@ -165,7 +171,44 @@ var init_credentials = __esmMin((() => {
|
|
|
165
171
|
async loadOAuthToken(provider) {
|
|
166
172
|
const token = await this.loadOAuthTokenRecord(provider);
|
|
167
173
|
if (!token) return null;
|
|
168
|
-
|
|
174
|
+
const expiresAt = token.expiresAt ?? Number.POSITIVE_INFINITY;
|
|
175
|
+
if (expiresAt <= Date.now() + 6e4 && token.refresh) {
|
|
176
|
+
const definition = getOAuthProviderDefinition(provider);
|
|
177
|
+
if (definition) {
|
|
178
|
+
let pending = oauthRefreshes.get(provider);
|
|
179
|
+
if (!pending) {
|
|
180
|
+
pending = definition.provider.refreshToken({
|
|
181
|
+
access: token.access,
|
|
182
|
+
refresh: token.refresh,
|
|
183
|
+
expires: expiresAt
|
|
184
|
+
}).then(async (refreshed) => {
|
|
185
|
+
const updated = {
|
|
186
|
+
...token,
|
|
187
|
+
access: definition.provider.getApiKey(refreshed),
|
|
188
|
+
refresh: refreshed.refresh,
|
|
189
|
+
expiresAt: refreshed.expires,
|
|
190
|
+
scope: Array.isArray(refreshed.scope) ? refreshed.scope.filter((value) => typeof value === "string") : token.scope,
|
|
191
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
192
|
+
};
|
|
193
|
+
await this.saveOAuthToken(provider, updated);
|
|
194
|
+
return updated;
|
|
195
|
+
}).finally(() => oauthRefreshes.delete(provider));
|
|
196
|
+
oauthRefreshes.set(provider, pending);
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
return await pending;
|
|
200
|
+
} catch (err) {
|
|
201
|
+
if (expiresAt > Date.now()) {
|
|
202
|
+
log.warn({
|
|
203
|
+
err,
|
|
204
|
+
provider
|
|
205
|
+
}, "OAuth refresh failed; using the current access token");
|
|
206
|
+
return token;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (expiresAt <= Date.now()) {
|
|
169
212
|
const warnKey = `${provider}:${token.expiresAt}`;
|
|
170
213
|
if (!warnedExpiredOAuthTokens.has(warnKey)) {
|
|
171
214
|
warnedExpiredOAuthTokens.add(warnKey);
|
package/dist/src/auth/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { anthropicOAuthProvider, init_anthropic } from "./oauth/anthropic.js";
|
|
1
2
|
import { CredentialResolver, getCredentialResolver, hasCredentials, init_credentials, resolveApiKey } from "./credentials.js";
|
|
2
|
-
import { anthropicOAuthProvider } from "./oauth/anthropic.js";
|
|
3
3
|
//#region src/auth/index.ts
|
|
4
4
|
init_credentials();
|
|
5
|
+
init_anthropic();
|
|
5
6
|
//#endregion
|
|
6
7
|
export { CredentialResolver, anthropicOAuthProvider, getCredentialResolver, hasCredentials, resolveApiKey };
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { generatePKCE, init_pkce } from "./pkce.js";
|
|
2
3
|
//#region src/auth/oauth/anthropic.ts
|
|
3
|
-
/**
|
|
4
|
-
* Anthropic OAuth flow (Claude Pro/Max)
|
|
5
|
-
*/
|
|
6
|
-
const decode = (s) => atob(s);
|
|
7
|
-
const CLIENT_ID = decode("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl");
|
|
8
|
-
const AUTHORIZE_URL = "https://claude.ai/oauth/authorize";
|
|
9
|
-
const TOKEN_URL = "https://console.anthropic.com/v1/oauth/token";
|
|
10
|
-
const REDIRECT_URI = "https://console.anthropic.com/oauth/code/callback";
|
|
11
|
-
const SCOPES = "org:create_api_key user:profile user:inference";
|
|
12
4
|
async function loginAnthropic(onAuthUrl, onPromptCode) {
|
|
13
5
|
const { verifier, challenge } = await generatePKCE();
|
|
14
6
|
onAuthUrl(`${AUTHORIZE_URL}?${new URLSearchParams({
|
|
@@ -69,18 +61,29 @@ async function refreshAnthropicToken(refreshToken) {
|
|
|
69
61
|
expires: Date.now() + data.expires_in * 1e3 - 300 * 1e3
|
|
70
62
|
};
|
|
71
63
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
64
|
+
var decode, CLIENT_ID, AUTHORIZE_URL, TOKEN_URL, REDIRECT_URI, SCOPES, anthropicOAuthProvider;
|
|
65
|
+
var init_anthropic = __esmMin((() => {
|
|
66
|
+
init_pkce();
|
|
67
|
+
decode = (s) => atob(s);
|
|
68
|
+
CLIENT_ID = decode("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl");
|
|
69
|
+
AUTHORIZE_URL = "https://claude.ai/oauth/authorize";
|
|
70
|
+
TOKEN_URL = "https://console.anthropic.com/v1/oauth/token";
|
|
71
|
+
REDIRECT_URI = "https://console.anthropic.com/oauth/code/callback";
|
|
72
|
+
SCOPES = "org:create_api_key user:profile user:inference";
|
|
73
|
+
anthropicOAuthProvider = {
|
|
74
|
+
id: "anthropic",
|
|
75
|
+
name: "Anthropic (Claude Pro/Max)",
|
|
76
|
+
async login(callbacks) {
|
|
77
|
+
return loginAnthropic((url) => callbacks.onAuth({ url }), () => callbacks.onPrompt({ message: "Paste the authorization code:" }));
|
|
78
|
+
},
|
|
79
|
+
async refreshToken(credentials) {
|
|
80
|
+
return refreshAnthropicToken(credentials.refresh);
|
|
81
|
+
},
|
|
82
|
+
getApiKey(credentials) {
|
|
83
|
+
return credentials.access;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}));
|
|
85
87
|
//#endregion
|
|
86
|
-
|
|
88
|
+
init_anthropic();
|
|
89
|
+
export { anthropicOAuthProvider, init_anthropic, loginAnthropic, refreshAnthropicToken };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
1
2
|
import { githubCopilotProvider } from "@earendil-works/pi-ai/providers/github-copilot";
|
|
2
3
|
//#region src/auth/oauth/github-copilot.ts
|
|
3
4
|
/** GitHub Copilot OAuth adapter for pi-ai's provider-auth API. */
|
|
@@ -46,19 +47,23 @@ function toAuthInteraction(callbacks) {
|
|
|
46
47
|
}
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
50
|
+
var githubCopilotOAuthProvider;
|
|
51
|
+
var init_github_copilot = __esmMin((() => {
|
|
52
|
+
githubCopilotOAuthProvider = {
|
|
53
|
+
id: "github-copilot",
|
|
54
|
+
name: "GitHub Copilot",
|
|
55
|
+
usesCallbackServer: false,
|
|
56
|
+
async login(callbacks) {
|
|
57
|
+
return fromPiCredential(await getCopilotOAuth().login(toAuthInteraction(callbacks)));
|
|
58
|
+
},
|
|
59
|
+
async refreshToken(credentials) {
|
|
60
|
+
return fromPiCredential(await getCopilotOAuth().refresh(toPiCredential(credentials)));
|
|
61
|
+
},
|
|
62
|
+
getApiKey(credentials) {
|
|
63
|
+
return credentials.access;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}));
|
|
63
67
|
//#endregion
|
|
64
|
-
|
|
68
|
+
init_github_copilot();
|
|
69
|
+
export { githubCopilotOAuthProvider, init_github_copilot };
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { antigravityOAuthProvider, init_google_antigravity as init_google_antigravity$1, loginAntigravity, refreshAntigravityToken } from "./google-oauth/google-antigravity.js";
|
|
3
|
+
//#region src/auth/oauth/google-antigravity.ts
|
|
4
|
+
var init_google_antigravity = __esmMin((() => {
|
|
5
|
+
init_google_antigravity$1();
|
|
6
|
+
}));
|
|
7
|
+
//#endregion
|
|
8
|
+
init_google_antigravity();
|
|
9
|
+
export { antigravityOAuthProvider as googleAntigravityOAuthProvider, init_google_antigravity, loginAntigravity, refreshAntigravityToken };
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { geminiCliOAuthProvider, init_google_gemini_cli as init_google_gemini_cli$1, loginGeminiCli, refreshGoogleCloudToken } from "./google-oauth/google-gemini-cli.js";
|
|
3
|
+
//#region src/auth/oauth/google-gemini-cli.ts
|
|
4
|
+
var init_google_gemini_cli = __esmMin((() => {
|
|
5
|
+
init_google_gemini_cli$1();
|
|
6
|
+
}));
|
|
7
|
+
//#endregion
|
|
8
|
+
init_google_gemini_cli();
|
|
9
|
+
export { geminiCliOAuthProvider as googleGeminiCliOAuthProvider, init_google_gemini_cli, loginGeminiCli, refreshGoogleCloudToken };
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { __esmMin } from "../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { init_oauth_page, oauthErrorHtml, oauthSuccessHtml } from "./oauth-page.js";
|
|
3
|
+
import { generatePKCE, init_pkce } from "./pkce.js";
|
|
3
4
|
//#region src/auth/oauth/google-oauth/google-antigravity.ts
|
|
4
|
-
let _createServer = null;
|
|
5
|
-
let _httpImportPromise = null;
|
|
6
|
-
if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) _httpImportPromise = import("node:http").then((m) => {
|
|
7
|
-
_createServer = m.createServer;
|
|
8
|
-
});
|
|
9
|
-
const ANTIGRAVITY_CLIENT_ID_ENV = "XOPC_GOOGLE_ANTIGRAVITY_OAUTH_CLIENT_ID";
|
|
10
|
-
const ANTIGRAVITY_CLIENT_SECRET_ENV = "XOPC_GOOGLE_ANTIGRAVITY_OAUTH_CLIENT_SECRET";
|
|
11
5
|
/** Desktop OAuth client for this flow — must be set locally (not committed; avoids GitHub push protection). */
|
|
12
6
|
function getAntigravityOAuthClient() {
|
|
13
7
|
const clientId = process.env[ANTIGRAVITY_CLIENT_ID_ENV]?.trim();
|
|
@@ -18,16 +12,6 @@ function getAntigravityOAuthClient() {
|
|
|
18
12
|
clientSecret
|
|
19
13
|
};
|
|
20
14
|
}
|
|
21
|
-
const REDIRECT_URI = "http://localhost:51121/oauth-callback";
|
|
22
|
-
const SCOPES = [
|
|
23
|
-
"https://www.googleapis.com/auth/cloud-platform",
|
|
24
|
-
"https://www.googleapis.com/auth/userinfo.email",
|
|
25
|
-
"https://www.googleapis.com/auth/userinfo.profile",
|
|
26
|
-
"https://www.googleapis.com/auth/cclog",
|
|
27
|
-
"https://www.googleapis.com/auth/experimentsandconfigs"
|
|
28
|
-
];
|
|
29
|
-
const AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
30
|
-
const TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
31
15
|
/**
|
|
32
16
|
* Start a local HTTP server to receive the OAuth callback
|
|
33
17
|
*/
|
|
@@ -278,25 +262,48 @@ async function loginAntigravity(onAuth, onProgress, onManualCodeInput) {
|
|
|
278
262
|
server.server.close();
|
|
279
263
|
}
|
|
280
264
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
265
|
+
var _createServer, _httpImportPromise, ANTIGRAVITY_CLIENT_ID_ENV, ANTIGRAVITY_CLIENT_SECRET_ENV, REDIRECT_URI, SCOPES, AUTH_URL, TOKEN_URL, antigravityOAuthProvider;
|
|
266
|
+
var init_google_antigravity = __esmMin((() => {
|
|
267
|
+
init_oauth_page();
|
|
268
|
+
init_pkce();
|
|
269
|
+
_createServer = null;
|
|
270
|
+
_httpImportPromise = null;
|
|
271
|
+
if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) _httpImportPromise = import("node:http").then((m) => {
|
|
272
|
+
_createServer = m.createServer;
|
|
273
|
+
});
|
|
274
|
+
ANTIGRAVITY_CLIENT_ID_ENV = "XOPC_GOOGLE_ANTIGRAVITY_OAUTH_CLIENT_ID";
|
|
275
|
+
ANTIGRAVITY_CLIENT_SECRET_ENV = "XOPC_GOOGLE_ANTIGRAVITY_OAUTH_CLIENT_SECRET";
|
|
276
|
+
REDIRECT_URI = "http://localhost:51121/oauth-callback";
|
|
277
|
+
SCOPES = [
|
|
278
|
+
"https://www.googleapis.com/auth/cloud-platform",
|
|
279
|
+
"https://www.googleapis.com/auth/userinfo.email",
|
|
280
|
+
"https://www.googleapis.com/auth/userinfo.profile",
|
|
281
|
+
"https://www.googleapis.com/auth/cclog",
|
|
282
|
+
"https://www.googleapis.com/auth/experimentsandconfigs"
|
|
283
|
+
];
|
|
284
|
+
AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
285
|
+
TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
286
|
+
antigravityOAuthProvider = {
|
|
287
|
+
id: "google-antigravity",
|
|
288
|
+
name: "Antigravity (Gemini 3, Claude, GPT-OSS)",
|
|
289
|
+
usesCallbackServer: true,
|
|
290
|
+
async login(callbacks) {
|
|
291
|
+
return loginAntigravity(callbacks.onAuth, callbacks.onProgress, callbacks.onManualCodeInput);
|
|
292
|
+
},
|
|
293
|
+
async refreshToken(credentials) {
|
|
294
|
+
const creds = credentials;
|
|
295
|
+
if (!creds.projectId) throw new Error("Antigravity credentials missing projectId");
|
|
296
|
+
return refreshAntigravityToken(creds.refresh, creds.projectId);
|
|
297
|
+
},
|
|
298
|
+
getApiKey(credentials) {
|
|
299
|
+
const creds = credentials;
|
|
300
|
+
return JSON.stringify({
|
|
301
|
+
token: creds.access,
|
|
302
|
+
projectId: creds.projectId
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
}));
|
|
301
307
|
//#endregion
|
|
302
|
-
|
|
308
|
+
init_google_antigravity();
|
|
309
|
+
export { antigravityOAuthProvider, init_google_antigravity, loginAntigravity, refreshAntigravityToken };
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { __esmMin } from "../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { init_oauth_page, oauthErrorHtml, oauthSuccessHtml } from "./oauth-page.js";
|
|
3
|
+
import { generatePKCE, init_pkce } from "./pkce.js";
|
|
3
4
|
//#region src/auth/oauth/google-oauth/google-gemini-cli.ts
|
|
4
|
-
let _createServer = null;
|
|
5
|
-
let _httpImportPromise = null;
|
|
6
|
-
if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) _httpImportPromise = import("node:http").then((m) => {
|
|
7
|
-
_createServer = m.createServer;
|
|
8
|
-
});
|
|
9
|
-
const GEMINI_CLI_CLIENT_ID_ENV = "XOPC_GOOGLE_GEMINI_CLI_OAUTH_CLIENT_ID";
|
|
10
|
-
const GEMINI_CLI_CLIENT_SECRET_ENV = "XOPC_GOOGLE_GEMINI_CLI_OAUTH_CLIENT_SECRET";
|
|
11
5
|
function getGeminiCliOAuthClient() {
|
|
12
6
|
const clientId = process.env[GEMINI_CLI_CLIENT_ID_ENV]?.trim();
|
|
13
7
|
const clientSecret = process.env[GEMINI_CLI_CLIENT_SECRET_ENV]?.trim();
|
|
@@ -17,15 +11,6 @@ function getGeminiCliOAuthClient() {
|
|
|
17
11
|
clientSecret
|
|
18
12
|
};
|
|
19
13
|
}
|
|
20
|
-
const REDIRECT_URI = "http://localhost:8085/oauth2callback";
|
|
21
|
-
const SCOPES = [
|
|
22
|
-
"https://www.googleapis.com/auth/cloud-platform",
|
|
23
|
-
"https://www.googleapis.com/auth/userinfo.email",
|
|
24
|
-
"https://www.googleapis.com/auth/userinfo.profile"
|
|
25
|
-
];
|
|
26
|
-
const AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
27
|
-
const TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
28
|
-
const CODE_ASSIST_ENDPOINT = "https://cloudcode-pa.googleapis.com";
|
|
29
14
|
/**
|
|
30
15
|
* Start a local HTTP server to receive the OAuth callback
|
|
31
16
|
*/
|
|
@@ -104,8 +89,6 @@ function parseRedirectUrl(input) {
|
|
|
104
89
|
return {};
|
|
105
90
|
}
|
|
106
91
|
}
|
|
107
|
-
const TIER_FREE = "free-tier";
|
|
108
|
-
const TIER_STANDARD = "standard-tier";
|
|
109
92
|
/**
|
|
110
93
|
* Wait helper for onboarding retries
|
|
111
94
|
*/
|
|
@@ -358,25 +341,49 @@ async function loginGeminiCli(onAuth, onProgress, onManualCodeInput) {
|
|
|
358
341
|
server.server.close();
|
|
359
342
|
}
|
|
360
343
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
344
|
+
var _createServer, _httpImportPromise, GEMINI_CLI_CLIENT_ID_ENV, GEMINI_CLI_CLIENT_SECRET_ENV, REDIRECT_URI, SCOPES, AUTH_URL, TOKEN_URL, CODE_ASSIST_ENDPOINT, TIER_FREE, TIER_STANDARD, geminiCliOAuthProvider;
|
|
345
|
+
var init_google_gemini_cli = __esmMin((() => {
|
|
346
|
+
init_oauth_page();
|
|
347
|
+
init_pkce();
|
|
348
|
+
_createServer = null;
|
|
349
|
+
_httpImportPromise = null;
|
|
350
|
+
if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) _httpImportPromise = import("node:http").then((m) => {
|
|
351
|
+
_createServer = m.createServer;
|
|
352
|
+
});
|
|
353
|
+
GEMINI_CLI_CLIENT_ID_ENV = "XOPC_GOOGLE_GEMINI_CLI_OAUTH_CLIENT_ID";
|
|
354
|
+
GEMINI_CLI_CLIENT_SECRET_ENV = "XOPC_GOOGLE_GEMINI_CLI_OAUTH_CLIENT_SECRET";
|
|
355
|
+
REDIRECT_URI = "http://localhost:8085/oauth2callback";
|
|
356
|
+
SCOPES = [
|
|
357
|
+
"https://www.googleapis.com/auth/cloud-platform",
|
|
358
|
+
"https://www.googleapis.com/auth/userinfo.email",
|
|
359
|
+
"https://www.googleapis.com/auth/userinfo.profile"
|
|
360
|
+
];
|
|
361
|
+
AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
362
|
+
TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
363
|
+
CODE_ASSIST_ENDPOINT = "https://cloudcode-pa.googleapis.com";
|
|
364
|
+
TIER_FREE = "free-tier";
|
|
365
|
+
TIER_STANDARD = "standard-tier";
|
|
366
|
+
geminiCliOAuthProvider = {
|
|
367
|
+
id: "google-gemini-cli",
|
|
368
|
+
name: "Google Cloud Code Assist (Gemini CLI)",
|
|
369
|
+
usesCallbackServer: true,
|
|
370
|
+
async login(callbacks) {
|
|
371
|
+
return loginGeminiCli(callbacks.onAuth, callbacks.onProgress, callbacks.onManualCodeInput);
|
|
372
|
+
},
|
|
373
|
+
async refreshToken(credentials) {
|
|
374
|
+
const creds = credentials;
|
|
375
|
+
if (!creds.projectId) throw new Error("Google Cloud credentials missing projectId");
|
|
376
|
+
return refreshGoogleCloudToken(creds.refresh, creds.projectId);
|
|
377
|
+
},
|
|
378
|
+
getApiKey(credentials) {
|
|
379
|
+
const creds = credentials;
|
|
380
|
+
return JSON.stringify({
|
|
381
|
+
token: creds.access,
|
|
382
|
+
projectId: creds.projectId
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
}));
|
|
381
387
|
//#endregion
|
|
382
|
-
|
|
388
|
+
init_google_gemini_cli();
|
|
389
|
+
export { geminiCliOAuthProvider, init_google_gemini_cli, loginGeminiCli, refreshGoogleCloudToken };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { __esmMin } from "../../../../_virtual/_rolldown/runtime.js";
|
|
1
2
|
//#region src/auth/oauth/google-oauth/oauth-page.ts
|
|
2
|
-
const LOGO_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 72 72" aria-hidden="true"><rect width="72" height="72" rx="20" fill="#2563eb"/><path d="M22 22l28 28M50 22L22 50" stroke="#fff" stroke-width="8" stroke-linecap="round"/></svg>`;
|
|
3
3
|
function escapeHtml(value) {
|
|
4
4
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
5
5
|
}
|
|
@@ -106,5 +106,10 @@ function oauthErrorHtml(message, details) {
|
|
|
106
106
|
details
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
+
var LOGO_SVG;
|
|
110
|
+
var init_oauth_page = __esmMin((() => {
|
|
111
|
+
LOGO_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 72 72" aria-hidden="true"><rect width="72" height="72" rx="20" fill="#2563eb"/><path d="M22 22l28 28M50 22L22 50" stroke="#fff" stroke-width="8" stroke-linecap="round"/></svg>`;
|
|
112
|
+
}));
|
|
109
113
|
//#endregion
|
|
110
|
-
|
|
114
|
+
init_oauth_page();
|
|
115
|
+
export { init_oauth_page, oauthErrorHtml, oauthSuccessHtml };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __esmMin } from "../../../../_virtual/_rolldown/runtime.js";
|
|
1
2
|
//#region src/auth/oauth/google-oauth/pkce.ts
|
|
2
3
|
/**
|
|
3
4
|
* PKCE utilities using Web Crypto API.
|
|
@@ -26,5 +27,7 @@ async function generatePKCE() {
|
|
|
26
27
|
challenge: base64urlEncode(new Uint8Array(hashBuffer))
|
|
27
28
|
};
|
|
28
29
|
}
|
|
30
|
+
var init_pkce = __esmMin((() => {}));
|
|
29
31
|
//#endregion
|
|
30
|
-
|
|
32
|
+
init_pkce();
|
|
33
|
+
export { generatePKCE, init_pkce };
|