@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
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { anthropicOAuthProvider, init_anthropic } from "./anthropic.js";
|
|
3
|
+
import { githubCopilotOAuthProvider, init_github_copilot } from "./github-copilot.js";
|
|
4
|
+
import { antigravityOAuthProvider } from "./google-oauth/google-antigravity.js";
|
|
5
|
+
import { init_google_antigravity } from "./google-antigravity.js";
|
|
6
|
+
import { geminiCliOAuthProvider } from "./google-oauth/google-gemini-cli.js";
|
|
7
|
+
import { init_google_gemini_cli } from "./google-gemini-cli.js";
|
|
8
|
+
import { init_kimi_coding, kimiCodingOAuthProvider } from "./kimi-coding.js";
|
|
9
|
+
import { init_minimax_cn, minimaxCnOAuthProvider } from "./minimax-cn.js";
|
|
10
|
+
import { init_minimax, minimaxOAuthProvider } from "./minimax.js";
|
|
11
|
+
import { init_openai_codex, openaiCodexOAuthProvider } from "./openai-codex.js";
|
|
12
|
+
import { init_xopc_cloud, xopcCloudOAuthProvider } from "./xopc-cloud.js";
|
|
13
|
+
//#region src/auth/oauth/registry.ts
|
|
14
|
+
function definition(provider, displayName = provider.name) {
|
|
15
|
+
return {
|
|
16
|
+
displayName,
|
|
17
|
+
provider,
|
|
18
|
+
profileId: `${provider.id}:default`,
|
|
19
|
+
urlPrompt: "🌐 Please open this URL in your browser:\n"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function getOAuthProviderDefinition(provider) {
|
|
23
|
+
return OAUTH_PROVIDER_DEFINITIONS[provider];
|
|
24
|
+
}
|
|
25
|
+
function getOAuthProviderInterfaces() {
|
|
26
|
+
return Object.fromEntries(Object.entries(OAUTH_PROVIDER_DEFINITIONS).map(([id, value]) => [id, value.provider]));
|
|
27
|
+
}
|
|
28
|
+
function getOAuthProviderIds() {
|
|
29
|
+
return Object.keys(OAUTH_PROVIDER_DEFINITIONS);
|
|
30
|
+
}
|
|
31
|
+
function isOAuthOnlyProvider(provider) {
|
|
32
|
+
return OAUTH_PROVIDER_DEFINITIONS[provider]?.oauthOnly === true;
|
|
33
|
+
}
|
|
34
|
+
var OAUTH_PROVIDER_DEFINITIONS;
|
|
35
|
+
var init_registry = __esmMin((() => {
|
|
36
|
+
init_anthropic();
|
|
37
|
+
init_github_copilot();
|
|
38
|
+
init_google_antigravity();
|
|
39
|
+
init_google_gemini_cli();
|
|
40
|
+
init_kimi_coding();
|
|
41
|
+
init_minimax_cn();
|
|
42
|
+
init_minimax();
|
|
43
|
+
init_openai_codex();
|
|
44
|
+
init_xopc_cloud();
|
|
45
|
+
OAUTH_PROVIDER_DEFINITIONS = {
|
|
46
|
+
"xopc-cloud": {
|
|
47
|
+
...definition(xopcCloudOAuthProvider),
|
|
48
|
+
oauthOnly: true
|
|
49
|
+
},
|
|
50
|
+
anthropic: definition(anthropicOAuthProvider, "Anthropic (Claude)"),
|
|
51
|
+
minimax: definition(minimaxOAuthProvider, "MiniMax (幂维智能)"),
|
|
52
|
+
"minimax-cn": {
|
|
53
|
+
...definition(minimaxCnOAuthProvider, "MiniMax CN"),
|
|
54
|
+
urlPrompt: "🌐 请在浏览器中打开以下 URL:\n"
|
|
55
|
+
},
|
|
56
|
+
"kimi-coding": definition(kimiCodingOAuthProvider, "Kimi For Coding (月之暗面)"),
|
|
57
|
+
"github-copilot": definition(githubCopilotOAuthProvider),
|
|
58
|
+
"google-gemini-cli": definition(geminiCliOAuthProvider),
|
|
59
|
+
"google-antigravity": definition(antigravityOAuthProvider),
|
|
60
|
+
"openai-codex": definition(openaiCodexOAuthProvider)
|
|
61
|
+
};
|
|
62
|
+
}));
|
|
63
|
+
//#endregion
|
|
64
|
+
init_registry();
|
|
65
|
+
export { OAUTH_PROVIDER_DEFINITIONS, getOAuthProviderDefinition, getOAuthProviderIds, getOAuthProviderInterfaces, init_registry, isOAuthOnlyProvider };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { hostname } from "node:os";
|
|
3
|
+
import { setTimeout } from "node:timers/promises";
|
|
4
|
+
//#region src/auth/oauth/xopc-cloud.ts
|
|
5
|
+
function consoleUrl() {
|
|
6
|
+
return (process.env.XOPC_CONSOLE_URL ?? DEFAULT_CONSOLE_URL).replace(/\/+$/, "");
|
|
7
|
+
}
|
|
8
|
+
async function readJson(response) {
|
|
9
|
+
const body = await response.json().catch(() => null);
|
|
10
|
+
return body && typeof body === "object" ? body : {};
|
|
11
|
+
}
|
|
12
|
+
function credentials(body) {
|
|
13
|
+
if (typeof body.access_token !== "string" || body.access_token.length === 0 || typeof body.refresh_token !== "string" || body.refresh_token.length === 0 || typeof body.expires_in !== "number" || !Number.isFinite(body.expires_in) || body.expires_in <= 0) throw new Error("XOPC OAuth token response is incomplete");
|
|
14
|
+
return {
|
|
15
|
+
access: body.access_token,
|
|
16
|
+
refresh: body.refresh_token,
|
|
17
|
+
expires: Date.now() + body.expires_in * 1e3,
|
|
18
|
+
scope: typeof body.scope === "string" ? body.scope.split(" ").filter(Boolean) : []
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
async function tokenRequest(body, signal) {
|
|
22
|
+
return fetch(`${consoleUrl()}/oauth/token`, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
headers: {
|
|
25
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
26
|
+
accept: "application/json"
|
|
27
|
+
},
|
|
28
|
+
body,
|
|
29
|
+
signal: signal ?? AbortSignal.timeout(3e4)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async function login(callbacks) {
|
|
33
|
+
const response = await fetch(`${consoleUrl()}/oauth/device_authorization`, {
|
|
34
|
+
method: "POST",
|
|
35
|
+
headers: {
|
|
36
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
37
|
+
accept: "application/json"
|
|
38
|
+
},
|
|
39
|
+
body: new URLSearchParams({
|
|
40
|
+
client_id: CLIENT_ID,
|
|
41
|
+
scope: DEFAULT_SCOPE,
|
|
42
|
+
device_name: hostname() || "XOPC client",
|
|
43
|
+
client_type: "cli"
|
|
44
|
+
}),
|
|
45
|
+
signal: callbacks.signal ?? AbortSignal.timeout(3e4)
|
|
46
|
+
});
|
|
47
|
+
const body = await readJson(response);
|
|
48
|
+
if (!response.ok) throw new Error(body.error_description ?? body.error ?? "XOPC OAuth authorization failed");
|
|
49
|
+
const deviceCode = typeof body.device_code === "string" ? body.device_code : "";
|
|
50
|
+
const userCode = typeof body.user_code === "string" ? body.user_code : "";
|
|
51
|
+
const verificationUri = typeof body.verification_uri_complete === "string" ? body.verification_uri_complete : typeof body.verification_uri === "string" ? body.verification_uri : "";
|
|
52
|
+
if (!deviceCode || !userCode || !verificationUri) throw new Error("XOPC OAuth response is incomplete");
|
|
53
|
+
const intervalMs = Math.max(1, Number(body.interval) || 5) * 1e3;
|
|
54
|
+
const expiresAt = Date.now() + Math.max(1, Number(body.expires_in) || 600) * 1e3;
|
|
55
|
+
callbacks.onDeviceCode({
|
|
56
|
+
userCode,
|
|
57
|
+
verificationUri,
|
|
58
|
+
intervalSeconds: intervalMs / 1e3,
|
|
59
|
+
expiresInSeconds: Math.floor((expiresAt - Date.now()) / 1e3)
|
|
60
|
+
});
|
|
61
|
+
while (Date.now() < expiresAt) {
|
|
62
|
+
if (callbacks.signal?.aborted) throw callbacks.signal.reason ?? /* @__PURE__ */ new Error("OAuth login cancelled");
|
|
63
|
+
await setTimeout(intervalMs, void 0, callbacks.signal ? { signal: callbacks.signal } : void 0);
|
|
64
|
+
const token = await tokenRequest(new URLSearchParams({
|
|
65
|
+
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
66
|
+
client_id: CLIENT_ID,
|
|
67
|
+
device_code: deviceCode
|
|
68
|
+
}), callbacks.signal);
|
|
69
|
+
const tokenBody = await readJson(token);
|
|
70
|
+
if (token.ok) return credentials(tokenBody);
|
|
71
|
+
if (tokenBody.error === "authorization_pending" || tokenBody.error === "slow_down") continue;
|
|
72
|
+
throw new Error(tokenBody.error_description ?? tokenBody.error ?? "XOPC OAuth token exchange failed");
|
|
73
|
+
}
|
|
74
|
+
throw new Error("XOPC OAuth authorization expired");
|
|
75
|
+
}
|
|
76
|
+
async function refreshToken(current) {
|
|
77
|
+
const response = await tokenRequest(new URLSearchParams({
|
|
78
|
+
grant_type: "refresh_token",
|
|
79
|
+
client_id: CLIENT_ID,
|
|
80
|
+
refresh_token: current.refresh
|
|
81
|
+
}));
|
|
82
|
+
const body = await readJson(response);
|
|
83
|
+
if (!response.ok) throw new Error(body.error_description ?? body.error ?? "XOPC OAuth refresh failed");
|
|
84
|
+
return credentials(body);
|
|
85
|
+
}
|
|
86
|
+
var CLIENT_ID, DEFAULT_CONSOLE_URL, DEFAULT_SCOPE, xopcCloudOAuthProvider;
|
|
87
|
+
var init_xopc_cloud = __esmMin((() => {
|
|
88
|
+
CLIENT_ID = "xopc-native";
|
|
89
|
+
DEFAULT_CONSOLE_URL = "https://console.xopc.ai";
|
|
90
|
+
DEFAULT_SCOPE = "models:read models:invoke account:usage offline_access";
|
|
91
|
+
xopcCloudOAuthProvider = {
|
|
92
|
+
id: "xopc-cloud",
|
|
93
|
+
name: "XOPC Model Service",
|
|
94
|
+
login,
|
|
95
|
+
refreshToken,
|
|
96
|
+
getApiKey: (value) => value.access
|
|
97
|
+
};
|
|
98
|
+
}));
|
|
99
|
+
//#endregion
|
|
100
|
+
init_xopc_cloud();
|
|
101
|
+
export { init_xopc_cloud, xopcCloudOAuthProvider };
|
|
@@ -2,6 +2,7 @@ import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
|
2
2
|
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
3
3
|
import { init_paths, resolveAgentAuthProfilesPath, resolveAuthProfilesPath, resolveOAuthPath } from "../config/paths.js";
|
|
4
4
|
import { init_loader, loadConfig } from "../config/loader.js";
|
|
5
|
+
import { init_registry, isOAuthOnlyProvider } from "./oauth/registry.js";
|
|
5
6
|
import { existsSync, readFileSync } from "node:fs";
|
|
6
7
|
//#region src/auth/sync-provider-auth.ts
|
|
7
8
|
/**
|
|
@@ -81,6 +82,7 @@ function readOAuthAccessTokenSync(provider) {
|
|
|
81
82
|
*/
|
|
82
83
|
function resolveProviderApiKeySync(provider) {
|
|
83
84
|
const normalized = provider.toLowerCase();
|
|
85
|
+
if (isOAuthOnlyProvider(normalized)) return readOAuthAccessTokenSync(normalized);
|
|
84
86
|
const cfg = loadConfig();
|
|
85
87
|
const fromAgent = readApiKeyFromProfilesFile(resolveAgentAuthProfilesPath(cfg, getDefaultAgentId(cfg)), normalized);
|
|
86
88
|
if (fromAgent) return fromAgent;
|
|
@@ -91,6 +93,7 @@ function resolveProviderApiKeySync(provider) {
|
|
|
91
93
|
/** Resolve one agent's private credential, then the shared credential and OAuth token. */
|
|
92
94
|
function resolveProviderApiKeyForAgentSync(provider, agentId, config) {
|
|
93
95
|
const normalized = provider.toLowerCase();
|
|
96
|
+
if (isOAuthOnlyProvider(normalized)) return readOAuthAccessTokenSync(normalized);
|
|
94
97
|
if (agentId?.trim()) {
|
|
95
98
|
const fromAgent = readApiKeyFromProfilesFile(resolveAgentAuthProfilesPath(config ?? loadConfig(), agentId.trim()), normalized);
|
|
96
99
|
if (fromAgent) return fromAgent;
|
|
@@ -104,6 +107,7 @@ function resolveProviderApiKeyForAgentSync(provider, agentId, config) {
|
|
|
104
107
|
* matching async CredentialResolver resolution (excluding env — callers check env separately).
|
|
105
108
|
*/
|
|
106
109
|
function hasProviderAuthOnDiskSync(provider) {
|
|
110
|
+
if (isOAuthOnlyProvider(provider.toLowerCase())) return hasOAuthTokenSync(provider);
|
|
107
111
|
const cfg = loadConfig();
|
|
108
112
|
if (hasApiKeyInProfilesFile(resolveAgentAuthProfilesPath(cfg, getDefaultAgentId(cfg)), provider)) return true;
|
|
109
113
|
if (hasApiKeyInProfilesFile(resolveAuthProfilesPath(), provider)) return true;
|
|
@@ -114,6 +118,7 @@ var init_sync_provider_auth = __esmMin((() => {
|
|
|
114
118
|
init_paths();
|
|
115
119
|
init_loader();
|
|
116
120
|
init_resolve_route();
|
|
121
|
+
init_registry();
|
|
117
122
|
}));
|
|
118
123
|
//#endregion
|
|
119
124
|
init_sync_provider_auth();
|
|
@@ -1,29 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Centralized OAuth provider definitions for CLI commands.
|
|
5
|
-
* Used by both auth.ts and onboard.ts to avoid duplication.
|
|
6
|
-
*/
|
|
7
|
-
import type { OAuthProviderInterface } from '../../auth/oauth/types.js';
|
|
8
|
-
export interface OAuthProviderConfig {
|
|
9
|
-
displayName: string;
|
|
10
|
-
provider: OAuthProviderInterface;
|
|
11
|
-
profileId: string;
|
|
12
|
-
urlPrompt: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Map of provider IDs to their OAuth configuration.
|
|
16
|
-
*/
|
|
17
|
-
export declare const OAUTH_PROVIDERS: Record<string, OAuthProviderConfig>;
|
|
18
|
-
/**
|
|
19
|
-
* Get supported OAuth provider IDs.
|
|
20
|
-
*/
|
|
1
|
+
import { type OAuthProviderDefinition } from '../../auth/oauth/registry.js';
|
|
2
|
+
export type OAuthProviderConfig = OAuthProviderDefinition;
|
|
3
|
+
export declare const OAUTH_PROVIDERS: Readonly<Record<string, OAuthProviderDefinition>>;
|
|
21
4
|
export declare function getSupportedOAuthProviders(): string[];
|
|
22
|
-
/**
|
|
23
|
-
* Check if a provider supports OAuth.
|
|
24
|
-
*/
|
|
25
5
|
export declare function supportsOAuth(provider: string): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Get OAuth provider config by ID.
|
|
28
|
-
*/
|
|
29
6
|
export declare function getOAuthProvider(provider: string): OAuthProviderConfig | undefined;
|
|
@@ -1,89 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { minimaxOAuthProvider } from "../../auth/oauth/minimax.js";
|
|
3
|
-
import { minimaxCnOAuthProvider } from "../../auth/oauth/minimax-cn.js";
|
|
4
|
-
import { kimiCodingOAuthProvider } from "../../auth/oauth/kimi-coding.js";
|
|
5
|
-
import { githubCopilotOAuthProvider } from "../../auth/oauth/github-copilot.js";
|
|
6
|
-
import { geminiCliOAuthProvider } from "../../auth/oauth/google-oauth/google-gemini-cli.js";
|
|
7
|
-
import { antigravityOAuthProvider } from "../../auth/oauth/google-oauth/google-antigravity.js";
|
|
8
|
-
import { openaiCodexOAuthProvider } from "../../auth/oauth/openai-codex.js";
|
|
9
|
-
import "../../auth/oauth/index.js";
|
|
1
|
+
import { OAUTH_PROVIDER_DEFINITIONS, getOAuthProviderDefinition, init_registry } from "../../auth/oauth/registry.js";
|
|
10
2
|
//#region src/cli/utils/oauth-providers.ts
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
* Centralized OAuth provider definitions for CLI commands.
|
|
15
|
-
* Used by both auth.ts and onboard.ts to avoid duplication.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Map of provider IDs to their OAuth configuration.
|
|
19
|
-
*/
|
|
20
|
-
const OAUTH_PROVIDERS = {
|
|
21
|
-
anthropic: {
|
|
22
|
-
displayName: "Anthropic (Claude)",
|
|
23
|
-
provider: anthropicOAuthProvider,
|
|
24
|
-
profileId: "anthropic:default",
|
|
25
|
-
urlPrompt: "🌐 Please open this URL in your browser:\n"
|
|
26
|
-
},
|
|
27
|
-
minimax: {
|
|
28
|
-
displayName: "MiniMax (幂维智能)",
|
|
29
|
-
provider: minimaxOAuthProvider,
|
|
30
|
-
profileId: "minimax:default",
|
|
31
|
-
urlPrompt: "🌐 Please open this URL in your browser:\n"
|
|
32
|
-
},
|
|
33
|
-
"minimax-cn": {
|
|
34
|
-
displayName: "MiniMax CN",
|
|
35
|
-
provider: minimaxCnOAuthProvider,
|
|
36
|
-
profileId: "minimax-cn:default",
|
|
37
|
-
urlPrompt: "🌐 请在浏览器中打开以下 URL:\n"
|
|
38
|
-
},
|
|
39
|
-
"kimi-coding": {
|
|
40
|
-
displayName: "Kimi For Coding (月之暗面)",
|
|
41
|
-
provider: kimiCodingOAuthProvider,
|
|
42
|
-
profileId: "kimi-coding:default",
|
|
43
|
-
urlPrompt: "🌐 Please open this URL in your browser:\n"
|
|
44
|
-
},
|
|
45
|
-
"github-copilot": {
|
|
46
|
-
displayName: "GitHub Copilot",
|
|
47
|
-
provider: githubCopilotOAuthProvider,
|
|
48
|
-
profileId: "github-copilot:default",
|
|
49
|
-
urlPrompt: "🌐 Please open this URL in your browser:\n"
|
|
50
|
-
},
|
|
51
|
-
"google-gemini-cli": {
|
|
52
|
-
displayName: "Google Gemini CLI",
|
|
53
|
-
provider: geminiCliOAuthProvider,
|
|
54
|
-
profileId: "google-gemini-cli:default",
|
|
55
|
-
urlPrompt: "🌐 Please open this URL in your browser:\n"
|
|
56
|
-
},
|
|
57
|
-
"google-antigravity": {
|
|
58
|
-
displayName: "Google Antigravity",
|
|
59
|
-
provider: antigravityOAuthProvider,
|
|
60
|
-
profileId: "google-antigravity:default",
|
|
61
|
-
urlPrompt: "🌐 Please open this URL in your browser:\n"
|
|
62
|
-
},
|
|
63
|
-
"openai-codex": {
|
|
64
|
-
displayName: "OpenAI Codex",
|
|
65
|
-
provider: openaiCodexOAuthProvider,
|
|
66
|
-
profileId: "openai-codex:default",
|
|
67
|
-
urlPrompt: "🌐 Please open this URL in your browser:\n"
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Get supported OAuth provider IDs.
|
|
72
|
-
*/
|
|
3
|
+
init_registry();
|
|
4
|
+
const OAUTH_PROVIDERS = OAUTH_PROVIDER_DEFINITIONS;
|
|
73
5
|
function getSupportedOAuthProviders() {
|
|
74
|
-
return Object.keys(
|
|
6
|
+
return Object.keys(OAUTH_PROVIDER_DEFINITIONS);
|
|
75
7
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Check if a provider supports OAuth.
|
|
78
|
-
*/
|
|
79
8
|
function supportsOAuth(provider) {
|
|
80
|
-
return provider
|
|
9
|
+
return Boolean(getOAuthProviderDefinition(provider));
|
|
81
10
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Get OAuth provider config by ID.
|
|
84
|
-
*/
|
|
85
11
|
function getOAuthProvider(provider) {
|
|
86
|
-
return
|
|
12
|
+
return getOAuthProviderDefinition(provider);
|
|
87
13
|
}
|
|
88
14
|
//#endregion
|
|
89
15
|
export { OAUTH_PROVIDERS, getOAuthProvider, getSupportedOAuthProviders, supportsOAuth };
|
|
@@ -27,6 +27,14 @@ function validateModelsConfig(config) {
|
|
|
27
27
|
}
|
|
28
28
|
const data = result.data;
|
|
29
29
|
for (const [providerName, providerConfig] of Object.entries(data.providers)) {
|
|
30
|
+
if (providerName === "xopc-cloud") {
|
|
31
|
+
errors.push({
|
|
32
|
+
path: "providers.xopc-cloud",
|
|
33
|
+
message: "xopc-cloud is managed by OAuth and the runtime model catalog; it cannot be configured in models.json",
|
|
34
|
+
severity: "error"
|
|
35
|
+
});
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
30
38
|
if (!PROVIDER_ID_REGEX.test(providerName)) errors.push({
|
|
31
39
|
path: `providers.${providerName}`,
|
|
32
40
|
message: "Provider ID must start/end with alphanumeric, contain only lowercase letters, numbers, hyphens, and underscores",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
3
|
import { shouldSilence, stripHeartbeatToken } from "../../heartbeat/tokens.js";
|
|
4
|
-
import { appendCronEventLines } from "../../heartbeat/event-prompt.js";
|
|
5
4
|
import { isWithinActiveHours } from "../../heartbeat/active-hours.js";
|
|
6
5
|
import { isHeartbeatContentEmpty } from "../../heartbeat/content-check.js";
|
|
6
|
+
import { appendCronEventLines } from "../../heartbeat/event-prompt.js";
|
|
7
7
|
import { createHeartbeatWake } from "../../heartbeat/wake.js";
|
|
8
8
|
import { resolveHeartbeatMdPath } from "../workspace-heartbeat-path.js";
|
|
9
9
|
import { readFile } from "fs/promises";
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { getOAuthProviderInterfaces, init_registry } from "../../auth/oauth/registry.js";
|
|
3
4
|
import { CredentialResolver, init_credentials } from "../../auth/credentials.js";
|
|
4
5
|
import { isLoopbackHost } from "../host.js";
|
|
5
6
|
import { resolveReverseProxyPublicUrl } from "../public-url.js";
|
|
6
|
-
import { anthropicOAuthProvider } from "../../auth/oauth/anthropic.js";
|
|
7
|
-
import { minimaxOAuthProvider } from "../../auth/oauth/minimax.js";
|
|
8
|
-
import { minimaxCnOAuthProvider } from "../../auth/oauth/minimax-cn.js";
|
|
9
|
-
import { kimiCodingOAuthProvider } from "../../auth/oauth/kimi-coding.js";
|
|
10
|
-
import { githubCopilotOAuthProvider } from "../../auth/oauth/github-copilot.js";
|
|
11
|
-
import { geminiCliOAuthProvider } from "../../auth/oauth/google-oauth/google-gemini-cli.js";
|
|
12
|
-
import { antigravityOAuthProvider } from "../../auth/oauth/google-oauth/google-antigravity.js";
|
|
13
|
-
import { openaiCodexOAuthProvider } from "../../auth/oauth/openai-codex.js";
|
|
14
|
-
import "../../auth/oauth/index.js";
|
|
15
7
|
import { Hono } from "hono";
|
|
16
8
|
//#region src/gateway/hono/oauth-async.ts
|
|
17
9
|
/**
|
|
@@ -21,6 +13,7 @@ import { Hono } from "hono";
|
|
|
21
13
|
* This allows OAuth flows that require user interaction (browser login)
|
|
22
14
|
* without blocking the HTTP request.
|
|
23
15
|
*/
|
|
16
|
+
init_registry();
|
|
24
17
|
init_credentials();
|
|
25
18
|
init_logger();
|
|
26
19
|
const log = createLogger("OAuthAsync");
|
|
@@ -32,16 +25,7 @@ function formatOAuthAsyncError(err) {
|
|
|
32
25
|
if (/^fetch failed$/i.test(base) || base.includes("fetch failed")) return `Network request failed${detail}. If the browser opened on another device, the redirect goes to that device's localhost — copy the full URL from the browser address bar after sign-in (starts with http://127.0.0.1 or http://localhost) and paste it below. Otherwise check VPN/proxy/DNS/firewall access to Google OAuth.`;
|
|
33
26
|
return base;
|
|
34
27
|
}
|
|
35
|
-
const OAUTH_PROVIDERS =
|
|
36
|
-
"kimi-coding": kimiCodingOAuthProvider,
|
|
37
|
-
"minimax": minimaxOAuthProvider,
|
|
38
|
-
"minimax-cn": minimaxCnOAuthProvider,
|
|
39
|
-
"anthropic": anthropicOAuthProvider,
|
|
40
|
-
"github-copilot": githubCopilotOAuthProvider,
|
|
41
|
-
"google-gemini-cli": geminiCliOAuthProvider,
|
|
42
|
-
"google-antigravity": antigravityOAuthProvider,
|
|
43
|
-
"openai-codex": openaiCodexOAuthProvider
|
|
44
|
-
};
|
|
28
|
+
const OAUTH_PROVIDERS = getOAuthProviderInterfaces();
|
|
45
29
|
const oauthSessions = /* @__PURE__ */ new Map();
|
|
46
30
|
const SESSION_TTL_MS = 600 * 1e3;
|
|
47
31
|
setInterval(() => {
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
+
import { getOAuthProviderInterfaces, init_registry } from "../../auth/oauth/registry.js";
|
|
1
2
|
import { CredentialResolver, init_credentials } from "../../auth/credentials.js";
|
|
2
3
|
import { getProviderAuthState, init_providers, isProviderConfigured } from "../../providers/index.js";
|
|
3
|
-
import { anthropicOAuthProvider } from "../../auth/oauth/anthropic.js";
|
|
4
|
-
import { minimaxOAuthProvider } from "../../auth/oauth/minimax.js";
|
|
5
|
-
import { minimaxCnOAuthProvider } from "../../auth/oauth/minimax-cn.js";
|
|
6
|
-
import { kimiCodingOAuthProvider } from "../../auth/oauth/kimi-coding.js";
|
|
7
|
-
import { githubCopilotOAuthProvider } from "../../auth/oauth/github-copilot.js";
|
|
8
|
-
import { geminiCliOAuthProvider } from "../../auth/oauth/google-oauth/google-gemini-cli.js";
|
|
9
|
-
import { antigravityOAuthProvider } from "../../auth/oauth/google-oauth/google-antigravity.js";
|
|
10
|
-
import { openaiCodexOAuthProvider } from "../../auth/oauth/openai-codex.js";
|
|
11
|
-
import "../../auth/oauth/index.js";
|
|
12
4
|
import { Hono } from "hono";
|
|
13
5
|
//#region src/gateway/hono/oauth.ts
|
|
14
6
|
/**
|
|
@@ -16,18 +8,10 @@ import { Hono } from "hono";
|
|
|
16
8
|
*
|
|
17
9
|
* Provides HTTP endpoints for OAuth login flow.
|
|
18
10
|
*/
|
|
11
|
+
init_registry();
|
|
19
12
|
init_credentials();
|
|
20
13
|
init_providers();
|
|
21
|
-
const OAUTH_PROVIDERS =
|
|
22
|
-
"kimi-coding": kimiCodingOAuthProvider,
|
|
23
|
-
"minimax": minimaxOAuthProvider,
|
|
24
|
-
"minimax-cn": minimaxCnOAuthProvider,
|
|
25
|
-
"anthropic": anthropicOAuthProvider,
|
|
26
|
-
"github-copilot": githubCopilotOAuthProvider,
|
|
27
|
-
"google-gemini-cli": geminiCliOAuthProvider,
|
|
28
|
-
"google-antigravity": antigravityOAuthProvider,
|
|
29
|
-
"openai-codex": openaiCodexOAuthProvider
|
|
30
|
-
};
|
|
14
|
+
const OAUTH_PROVIDERS = getOAuthProviderInterfaces();
|
|
31
15
|
const oauthCredentialsCache = /* @__PURE__ */ new Map();
|
|
32
16
|
function getOAuthCredentialsFromCache(provider) {
|
|
33
17
|
return oauthCredentialsCache.get(provider);
|
|
@@ -12,7 +12,6 @@ import { getDomesticProviderPreset, getDomesticProviderPresetIds } from "../../.
|
|
|
12
12
|
import { getOnboardingFeaturedProviders, getProviderHint, getRecommendedModelsForProvider, isRecommendedModel, sortModelsForPicker, sortProvidersForPicker } from "../../../providers/presentation.js";
|
|
13
13
|
import { getAgentImageGenerationConfig, getImageGenerationCatalog, prepareImageGenerationSetup, verifyImageGenerationCredential } from "../../image-generation-setup.js";
|
|
14
14
|
import { discoverProviderModels, isProviderApiDiscoverable } from "../../../providers/model-discovery.js";
|
|
15
|
-
import { XopcCloudHttpError } from "../../../providers/xopc-cloud-connection.js";
|
|
16
15
|
import { respondStartupUnavailable } from "../lib/startup-unavailable.js";
|
|
17
16
|
import { auditModelReferences } from "../../../providers/model-reference-auditor.js";
|
|
18
17
|
//#region src/gateway/hono/routes/models.ts
|
|
@@ -63,61 +62,8 @@ function mapPluginModel(providerId, model, available) {
|
|
|
63
62
|
};
|
|
64
63
|
}
|
|
65
64
|
function registerModelsRoutes(authenticated, deps) {
|
|
66
|
-
const { service, strictRateLimitMiddleware
|
|
65
|
+
const { service, strictRateLimitMiddleware } = deps;
|
|
67
66
|
const catalogSync = service.getModelCatalogSync();
|
|
68
|
-
const xopcCloud = catalogSync.getXopcCloudConnection();
|
|
69
|
-
authenticated.post("/api/models/xopc-cloud/connect", strictRateLimitMiddleware, async (c) => {
|
|
70
|
-
const body = await c.req.json().catch(() => ({}));
|
|
71
|
-
const clientType = body.clientType === "electron" || body.clientType === "cli" ? body.clientType : "web";
|
|
72
|
-
try {
|
|
73
|
-
return c.json({
|
|
74
|
-
ok: true,
|
|
75
|
-
payload: await xopcCloud.start(clientType)
|
|
76
|
-
}, 201);
|
|
77
|
-
} catch (error) {
|
|
78
|
-
return c.json({
|
|
79
|
-
ok: false,
|
|
80
|
-
error: { message: error instanceof Error ? error.message : "Connection failed" }
|
|
81
|
-
}, 502);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
authenticated.post("/api/models/xopc-cloud/connect/:requestId/poll", xopcCloudPollRateLimitMiddleware, async (c) => {
|
|
85
|
-
try {
|
|
86
|
-
const result = await xopcCloud.poll(c.req.param("requestId"));
|
|
87
|
-
if (result.status === "pending") return c.json({
|
|
88
|
-
ok: true,
|
|
89
|
-
payload: result
|
|
90
|
-
}, 202);
|
|
91
|
-
service.emit("model-catalog.updated", { modelCount: getModelRegistry().getAll().length });
|
|
92
|
-
return c.json({
|
|
93
|
-
ok: true,
|
|
94
|
-
payload: result
|
|
95
|
-
});
|
|
96
|
-
} catch (error) {
|
|
97
|
-
return c.json({
|
|
98
|
-
ok: false,
|
|
99
|
-
error: { message: error instanceof Error ? error.message : "Connection failed" }
|
|
100
|
-
}, 400);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
authenticated.post("/api/models/xopc-cloud/refresh", strictRateLimitMiddleware, async (c) => {
|
|
104
|
-
try {
|
|
105
|
-
const result = await catalogSync.refreshNow();
|
|
106
|
-
return c.json({
|
|
107
|
-
ok: true,
|
|
108
|
-
payload: result
|
|
109
|
-
});
|
|
110
|
-
} catch (error) {
|
|
111
|
-
const status = error instanceof XopcCloudHttpError && error.status === 401 ? 401 : error instanceof XopcCloudHttpError && error.status === 403 ? 403 : 502;
|
|
112
|
-
return c.json({
|
|
113
|
-
ok: false,
|
|
114
|
-
error: {
|
|
115
|
-
message: error instanceof Error ? error.message : "Refresh failed",
|
|
116
|
-
...error instanceof XopcCloudHttpError && error.code ? { code: error.code } : {}
|
|
117
|
-
}
|
|
118
|
-
}, status);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
67
|
authenticated.get("/api/models/catalog/status", (c) => c.json({
|
|
122
68
|
ok: true,
|
|
123
69
|
payload: catalogSync.getStatus()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_ACK_MAX_CHARS, HEARTBEAT_OK, NO_REPLY, shouldSilence, stripHeartbeatToken } from "./tokens.js";
|
|
2
|
-
import { appendCronEventLines } from "./event-prompt.js";
|
|
3
2
|
import { isWithinActiveHours } from "./active-hours.js";
|
|
4
3
|
import { isHeartbeatContentEmpty } from "./content-check.js";
|
|
4
|
+
import { appendCronEventLines } from "./event-prompt.js";
|
|
5
5
|
import { createHeartbeatWake } from "./wake.js";
|
|
6
6
|
export { DEFAULT_ACK_MAX_CHARS, HEARTBEAT_OK, NO_REPLY, appendCronEventLines, createHeartbeatWake, isHeartbeatContentEmpty, isWithinActiveHours, shouldSilence, stripHeartbeatToken };
|
|
@@ -34,26 +34,6 @@ export interface DomesticProviderPreset {
|
|
|
34
34
|
requiresModelDiscovery?: boolean;
|
|
35
35
|
}
|
|
36
36
|
export declare const DOMESTIC_PROVIDER_PRESETS: readonly [{
|
|
37
|
-
readonly id: "xopc-cloud";
|
|
38
|
-
readonly displayName: "XOPC Model Service";
|
|
39
|
-
readonly description: "Official XOPC OpenAI-compatible model service. Available models are loaded from your account.";
|
|
40
|
-
readonly docsUrl: "https://console.xopc.ai/models";
|
|
41
|
-
readonly apiKeyUrl: "https://console.xopc.ai/models";
|
|
42
|
-
readonly envVars: ["XOPC_MODEL_API_KEY"];
|
|
43
|
-
readonly api: "openai-completions";
|
|
44
|
-
readonly baseUrlPresets: [{
|
|
45
|
-
readonly id: "official";
|
|
46
|
-
readonly label: "XOPC Official";
|
|
47
|
-
readonly baseUrl: "https://router.xopc.ai/v1";
|
|
48
|
-
}];
|
|
49
|
-
readonly defaultBaseUrlPreset: "official";
|
|
50
|
-
readonly defaultModel: "";
|
|
51
|
-
readonly models: [];
|
|
52
|
-
readonly aliases: ["xopc", "xopc cloud", "xopc models"];
|
|
53
|
-
readonly onboardingIcon: "☁️";
|
|
54
|
-
readonly requiresModelDiscovery: true;
|
|
55
|
-
readonly quirks: ["Connect through XOPC Console; credentials and available models are configured automatically."];
|
|
56
|
-
}, {
|
|
57
37
|
readonly id: "dashscope-cn";
|
|
58
38
|
readonly displayName: "Alibaba Bailian / DashScope China";
|
|
59
39
|
readonly description: "Alibaba Bailian Qwen models through the China DashScope OpenAI-compatible endpoint.";
|
|
@@ -87,31 +87,6 @@ const MINIMAX_MODELS = [
|
|
|
87
87
|
}
|
|
88
88
|
];
|
|
89
89
|
const DOMESTIC_PROVIDER_PRESETS = [
|
|
90
|
-
{
|
|
91
|
-
id: "xopc-cloud",
|
|
92
|
-
displayName: "XOPC Model Service",
|
|
93
|
-
description: "Official XOPC OpenAI-compatible model service. Available models are loaded from your account.",
|
|
94
|
-
docsUrl: "https://console.xopc.ai/models",
|
|
95
|
-
apiKeyUrl: "https://console.xopc.ai/models",
|
|
96
|
-
envVars: ["XOPC_MODEL_API_KEY"],
|
|
97
|
-
api: "openai-completions",
|
|
98
|
-
baseUrlPresets: [{
|
|
99
|
-
id: "official",
|
|
100
|
-
label: "XOPC Official",
|
|
101
|
-
baseUrl: "https://router.xopc.ai/v1"
|
|
102
|
-
}],
|
|
103
|
-
defaultBaseUrlPreset: "official",
|
|
104
|
-
defaultModel: "",
|
|
105
|
-
models: [],
|
|
106
|
-
aliases: [
|
|
107
|
-
"xopc",
|
|
108
|
-
"xopc cloud",
|
|
109
|
-
"xopc models"
|
|
110
|
-
],
|
|
111
|
-
onboardingIcon: "☁️",
|
|
112
|
-
requiresModelDiscovery: true,
|
|
113
|
-
quirks: ["Connect through XOPC Console; credentials and available models are configured automatically."]
|
|
114
|
-
},
|
|
115
90
|
{
|
|
116
91
|
id: "dashscope-cn",
|
|
117
92
|
displayName: "Alibaba Bailian / DashScope China",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __esmMin, __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
3
|
+
import { getOAuthProviderIds, init_registry } from "../auth/oauth/registry.js";
|
|
3
4
|
import { hasProviderAuthOnDiskSync, init_sync_provider_auth } from "../auth/sync-provider-auth.js";
|
|
4
5
|
import { PROVIDER_ENV_MAP, getApiKeyFromEnv, init_env_keys } from "./env-keys.js";
|
|
5
6
|
import { ModelRegistry, getModelRegistry, init_model_registry, prewarmModelRegistry, resetModelRegistry } from "./model-registry.js";
|
|
@@ -136,6 +137,7 @@ function getAllProviders() {
|
|
|
136
137
|
for (const p of getProviders()) providers.add(p);
|
|
137
138
|
for (const m of registry.getAll()) providers.add(m.provider);
|
|
138
139
|
for (const plugin of getProviderRegistry().listAll()) providers.add(plugin.id);
|
|
140
|
+
for (const provider of getOAuthProviderIds()) providers.add(provider);
|
|
139
141
|
return Array.from(providers);
|
|
140
142
|
}
|
|
141
143
|
async function getApiKey(provider, credentialOptions) {
|
|
@@ -310,12 +312,19 @@ var init_providers = __esmMin((() => {
|
|
|
310
312
|
init_model_registry();
|
|
311
313
|
init_credentials();
|
|
312
314
|
init_sync_provider_auth();
|
|
315
|
+
init_registry();
|
|
313
316
|
init_env_keys();
|
|
314
317
|
init_constants();
|
|
315
318
|
init_model_supplements();
|
|
316
319
|
init_plugin_registry();
|
|
317
320
|
OPENAI_CODEX_CANONICAL_BASE_URL = "https://chatgpt.com/backend-api/codex";
|
|
318
321
|
PROVIDER_META = {
|
|
322
|
+
"xopc-cloud": {
|
|
323
|
+
name: "XOPC Model Service",
|
|
324
|
+
category: "oauth",
|
|
325
|
+
supportsOAuth: true,
|
|
326
|
+
supportsApiKey: false
|
|
327
|
+
},
|
|
319
328
|
"openai": {
|
|
320
329
|
name: "OpenAI",
|
|
321
330
|
category: "common",
|