@xopcai/xopc 0.0.484 → 0.0.486
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/src/inbound-processor.js +4 -6
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/messaging/process-message.js +2 -1
- package/dist/gateway/server/chunks.bin +1166 -1121
- package/dist/gateway/server/chunks.json +1 -1
- package/dist/gateway/static/root/assets/agent-run-error-parser-DsXmcKt-.js +1 -0
- package/dist/gateway/static/root/assets/{api-CGs641OT.js → api-CGrHK9ij.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-CH9wENBj.js → apps-page-6xeWvMpF.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-B1Ri4sh8.js → automations-page-BLFBqaPX.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-CNSza6ir.js → automations-workspace-DiO3Iyuj.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-abgigXV1.js → capabilities-CW-vdkz6.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-BaKHutgZ.js → capabilities-DZrjA95P.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-DQrfkrBA.js +2 -0
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-BOwbZn9X.js → capabilities-settings-panel-DIT2dvtc.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-DlnXbcOj.js → channels-Dcr5dgqw.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-page-LOR5JxDh.js → chat-page-DWZCzxY7.js} +31 -31
- package/dist/gateway/static/root/assets/{chat-terminal-dock-DE8j-K9d.js → chat-terminal-dock-DCUuwiTt.js} +1 -1
- package/dist/gateway/static/root/assets/command-palette-api-UrqPvWR1.js +1 -0
- package/dist/gateway/static/root/assets/composer-payload-handoff-a0quQ25p.js +1 -0
- package/dist/gateway/static/root/assets/connected-providers-grid-BJKEp0SE.js +1 -0
- package/dist/gateway/static/root/assets/{connectors-page-BJm1jjct.js → connectors-page-BteRI1XM.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-D3X7SlzG.js → extension-debug-page-4jJ1uVQJ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-CIAq7PSn.js → extension-iframe-host-CJV5JETm.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-message-router-B2wbucV7.js → extension-message-router-B4I-Y6qs.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-qwY7r1_p.js → extension-page-lc7a84nG.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-DFcRbTHI.js → extension-provider-D8_mIBI0.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-Cpnh9lcZ.js → extension-settings-page-Uw2lfWRh.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-BusNFHe-.js → home-page-mSRCU81k.js} +4 -4
- package/dist/gateway/static/root/assets/{home-task-actions-C8Fi6GBq.js → home-task-actions-_ZAc57Y7.js} +1 -1
- package/dist/gateway/static/root/assets/{index-DE6GguFZ.js → index-CJAEAcZV.js} +7 -7
- package/dist/gateway/static/root/assets/{local-app-workbench-page-B9uSL1Mi.js → local-app-workbench-page-C3Lqi8E1.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-DXzfoiyk.js → note-detail-panel-uc-5k3a2.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-BNTgiHSk.js → notes-page-RPfvHnl6.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-BXSBeGms.js → page-context-capture-button-CVHz9b6c.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-D7zTHQ0K.js → personal-page-Dt1d3tQT.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-profile-settings-TcI0Zfwr.js → personal-profile-settings-XiT1MgTK.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-settings-panel-BJ46T7ZO.js → personal-settings-panel-bcw04REt.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-runtime-C1U57WSM.js → preview-runtime-FtWOW5i4.js} +1 -1
- package/dist/gateway/static/root/assets/{product-automation-feedback-GA_YPLkr.js → product-automation-feedback-DdFoCDzG.js} +1 -1
- package/dist/gateway/static/root/assets/product-preview-content-B3mzl6-f.js +1 -0
- package/dist/gateway/static/root/assets/product-preview-modal-5kTp_7Qk.js +2 -0
- package/dist/gateway/static/root/assets/project-detail-page-DGPfKx5M.js +7 -0
- package/dist/gateway/static/root/assets/{projects-page-BHQxQGTd.js → projects-page-C-9x23LR.js} +1 -1
- package/dist/gateway/static/root/assets/route-preload-CzorjVc9.js +2 -0
- package/dist/gateway/static/root/assets/routine-panel-n4IstC8Y.js +2 -0
- package/dist/gateway/static/root/assets/session-manager-C2MCS4C5.js +28 -0
- package/dist/gateway/static/root/assets/{settings-page-BOzzOS6k.js → settings-page-DsM_f07M.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-Di5_ukH8.js → share-preview-page-C32Mq-BY.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-CirGM67m.js → shares-settings-BDGbs8wz.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-gGU0LZ5e.js → skills-page-kL8E5zgi.js} +1 -1
- package/dist/gateway/static/root/assets/space-page-DwyuUvI3.js +2 -0
- package/dist/gateway/static/root/assets/task-copy-CtcqCQ78.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-DdCpNW8K.js +3 -0
- package/dist/gateway/static/root/assets/{task-header-title-Cdgp2rCs.js → task-header-title-CLt_lmjb.js} +1 -1
- package/dist/gateway/static/root/assets/task-result-presentation-CgvcqEMD.js +1 -0
- package/dist/gateway/static/root/assets/task-run-issue-notice-8FX876PP.js +1 -0
- package/dist/gateway/static/root/assets/tasks-CvOAtEHv.js +1 -0
- package/dist/gateway/static/root/assets/turn-outcome-Dtw6OgwL.js +1 -0
- package/dist/gateway/static/root/assets/{use-composer-attachments-DJsIzJ1c.js → use-composer-attachments-BEuyorVm.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-BFF2vXm5.js → use-file-preview-expanded-Cehu0745.js} +1 -1
- package/dist/gateway/static/root/assets/use-personal-work-B25WRGHj.js +1 -0
- package/dist/gateway/static/root/assets/{use-realtime-voice-9OvLwHzk.js → use-realtime-voice-CV3GIt_T.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-LCIT1H-D.js → use-workspace-tree-C0C861cb.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-settings-j8o-hGTm.js → voice-settings-JpPo3BvX.js} +1 -1
- package/dist/gateway/static/root/assets/workspace-api-CQOuWbVv.js +2 -0
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-DwVWTehC.js → workspace-file-preview-dialog-CmMueTmW.js} +1 -1
- package/dist/gateway/static/root/index.html +30 -28
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/index.js +3 -1
- package/dist/packages/gateway-contract/src/notifications.js +1 -8
- package/dist/packages/gateway-contract/src/task-display.js +9 -2
- package/dist/packages/gateway-contract/src/task-lifecycle.js +1 -0
- package/dist/packages/gateway-contract/src/task-research-result.js +2 -1
- package/dist/packages/gateway-contract/src/tasks.js +6 -1
- package/dist/packages/gateway-contract/src/user-message-text.js +64 -0
- package/dist/src/agent/embedded/run-for-session.js +27 -28
- package/dist/src/agent/embedded/session-runner.js +14 -1
- package/dist/src/agent/fallback/candidates.d.ts +1 -0
- package/dist/src/agent/fallback/candidates.js +1 -1
- package/dist/src/agent/image/generation/provider-registry.js +3 -1
- package/dist/src/agent/mcp/connection-drafts.d.ts +3 -1
- package/dist/src/agent/mcp/connection-drafts.js +24 -11
- package/dist/src/agent/mcp/connection-setup.js +13 -10
- package/dist/src/agent/mcp/native-mcp.js +1 -0
- package/dist/src/agent/mcp/network-policy.d.ts +6 -0
- package/dist/src/agent/mcp/network-policy.js +49 -0
- package/dist/src/agent/mcp/transport.js +14 -7
- package/dist/src/agent/messaging/message-router.js +2 -2
- package/dist/src/agent/models/manager.d.ts +1 -1
- package/dist/src/agent/models/manager.js +2 -1
- package/dist/src/agent/models/turn-candidates.d.ts +16 -0
- package/dist/src/agent/models/turn-candidates.js +55 -0
- package/dist/src/agent/service/direct-turn-helpers.js +9 -24
- package/dist/src/agent/service.d.ts +1 -0
- package/dist/src/agent/service.js +12 -0
- package/dist/src/agent/skills/installer.js +2 -2
- package/dist/src/auth/credentials.js +3 -1
- package/dist/src/auth/oauth/index.d.ts +0 -1
- package/dist/src/auth/oauth/index.js +1 -4
- package/dist/src/auth/oauth/registry.js +0 -4
- package/dist/src/auth/oauth/xopc-cloud.js +1 -1
- package/dist/src/chat-commands/command-parse.d.ts +1 -0
- package/dist/src/chat-commands/command-parse.js +8 -10
- package/dist/src/chat-commands/registry.d.ts +5 -0
- package/dist/src/chat-commands/registry.js +8 -0
- package/dist/src/cli/command-manifest.js +1 -1
- package/dist/src/cli/commands/auth.js +4 -2
- package/dist/src/cli/commands/models.js +12 -10
- package/dist/src/config/models-json.js +1 -2
- package/dist/src/config/schema.d.ts +54 -4
- package/dist/src/config/schema.js +3 -1
- package/dist/src/gateway/agent-reactions/reaction.d.ts +1 -2
- package/dist/src/gateway/agent-reactions/reaction.js +10 -21
- package/dist/src/gateway/custom-image-providers.js +4 -1
- package/dist/src/gateway/hono/oauth.js +3 -0
- package/dist/src/gateway/hono/routes/device-push.js +55 -15
- package/dist/src/gateway/hono/routes/mobile-capability-panels.d.ts +67 -0
- package/dist/src/gateway/hono/routes/mobile-capability-panels.js +16 -131
- package/dist/src/gateway/hono/routes/mobile-mcp-setup.d.ts +9 -0
- package/dist/src/gateway/hono/routes/mobile-mcp-setup.js +949 -0
- package/dist/src/gateway/hono/routes/notifications.js +12 -1
- package/dist/src/gateway/hono/routes/session-command-handler.js +1 -4
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -4
- package/dist/src/gateway/hono/routes/sessions.js +1 -13
- package/dist/src/gateway/next-turn-suggestions/generator.js +16 -2
- package/dist/src/gateway/next-turn-suggestions/service.d.ts +2 -1
- package/dist/src/gateway/next-turn-suggestions/service.js +17 -5
- package/dist/src/gateway/next-turn-suggestions/snapshot.d.ts +11 -0
- package/dist/src/gateway/next-turn-suggestions/snapshot.js +31 -2
- package/dist/src/gateway/security/gateway-scopes.js +1 -0
- package/dist/src/gateway/service/config-coordinator.d.ts +14 -1
- package/dist/src/gateway/service/run-gateway-agent.js +2 -13
- package/dist/src/gateway/service.js +80 -60
- package/dist/src/local-apps/capabilities/projections.d.ts +5 -5
- package/dist/src/media/generation-changes.d.ts +4 -0
- package/dist/src/media/generation-changes.js +37 -0
- package/dist/src/music-generation/repository.js +12 -6
- package/dist/src/notifications/device-store.d.ts +3 -0
- package/dist/src/notifications/device-store.js +14 -1
- package/dist/src/notifications/platform-push.d.ts +17 -0
- package/dist/src/notifications/platform-push.js +58 -0
- package/dist/src/notifications/service.d.ts +2 -2
- package/dist/src/notifications/service.js +26 -12
- package/dist/src/notifications/store.d.ts +1 -1
- package/dist/src/notifications/store.js +3 -2
- package/dist/src/providers/env-keys.js +0 -1
- package/dist/src/providers/index.js +1 -7
- package/dist/src/providers/model-catalog-sync-service.js +3 -1
- package/dist/src/providers/model-registry.js +6 -2
- package/dist/src/providers/presentation.js +1 -2
- package/dist/src/providers/provider-policy.js +2 -1
- package/dist/src/session/client-history.js +3 -3
- package/dist/src/session/reset-triggers.js +1 -1
- package/dist/src/session/user-message-display.js +3 -2
- package/dist/src/storage/sqlite/agent-reaction-repository.d.ts +2 -4
- package/dist/src/storage/sqlite/agent-reaction-repository.js +18 -13
- package/dist/src/storage/sqlite/device-access-repository.js +2 -1
- package/dist/src/tasks/capabilities/write.d.ts +2 -0
- package/dist/src/tasks/home-query-service.js +2 -1
- package/dist/src/tasks/task-contract-planner.js +1 -0
- package/dist/src/tasks/task-conversation-summary.d.ts +1 -1
- package/dist/src/tasks/task-delivery-checks.d.ts +12 -0
- package/dist/src/tasks/task-delivery-checks.js +91 -0
- package/dist/src/tasks/task-final-reply.d.ts +3 -1
- package/dist/src/tasks/task-final-reply.js +17 -4
- package/dist/src/tasks/task-model-call.js +4 -2
- package/dist/src/tasks/task-origin-repository.d.ts +1 -1
- package/dist/src/tasks/task-read-model-projector.js +24 -7
- package/dist/src/tasks/task-research-result.js +12 -27
- package/dist/src/tasks/task-result-delivery-repository.js +3 -2
- package/dist/src/tasks/task-retry-service.js +2 -1
- package/dist/src/tasks/task-run-coordinator.js +14 -4
- package/dist/src/tasks/task-run-dispatcher.d.ts +1 -0
- package/dist/src/tasks/task-run-dispatcher.js +78 -48
- package/dist/src/tasks/task-run-repository.js +1 -1
- package/dist/src/tui/tui-commands.d.ts +2 -1
- package/dist/src/tui/tui-commands.js +3 -3
- package/dist/src/tui/tui-submit.d.ts +1 -1
- package/dist/src/tui/tui-submit.js +2 -4
- package/dist/src/video-generation/drafts.js +2 -0
- package/dist/src/video-generation/repository.js +13 -6
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-EENl65YY.js +0 -2
- package/dist/gateway/static/root/assets/command-palette-api-YP0zV_Ol.js +0 -1
- package/dist/gateway/static/root/assets/composer-payload-handoff-ClWsunJ2.js +0 -1
- package/dist/gateway/static/root/assets/connected-providers-grid-BgW-ioIt.js +0 -1
- package/dist/gateway/static/root/assets/product-preview-content-BOq3gtSJ.js +0 -1
- package/dist/gateway/static/root/assets/product-preview-modal-DIh_CsXp.js +0 -2
- package/dist/gateway/static/root/assets/project-detail-page-Dgs8ImMC.js +0 -7
- package/dist/gateway/static/root/assets/route-preload-7WVrzJca.js +0 -2
- package/dist/gateway/static/root/assets/routine-panel-Bfbiz0IN.js +0 -2
- package/dist/gateway/static/root/assets/session-manager-DUWeBdeG.js +0 -28
- package/dist/gateway/static/root/assets/space-page-CKVuhV2i.js +0 -2
- package/dist/gateway/static/root/assets/task-detail-page-DEpYIaok.js +0 -3
- package/dist/gateway/static/root/assets/task-run-issue-notice-CGrUMy0s.js +0 -1
- package/dist/gateway/static/root/assets/tasks-CwyNaa-j.js +0 -1
- package/dist/gateway/static/root/assets/turn-outcome-BSbEJx8h.js +0 -1
- package/dist/gateway/static/root/assets/use-personal-work-Dd2jRUpz.js +0 -1
- package/dist/gateway/static/root/assets/workspace-api-BuNWyNvA.js +0 -2
- package/dist/src/auth/oauth/google-antigravity.d.ts +0 -4
- package/dist/src/auth/oauth/google-antigravity.js +0 -9
- package/dist/src/auth/oauth/google-oauth/google-antigravity.d.ts +0 -25
- package/dist/src/auth/oauth/google-oauth/google-antigravity.js +0 -309
- package/dist/src/notifications/harmony-push.d.ts +0 -27
- package/dist/src/notifications/harmony-push.js +0 -96
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
-
import { checkUrlSafety } from "../tools/url-safety.js";
|
|
4
3
|
import { isManagedConnectorServer } from "../../connectors/materialize.js";
|
|
5
4
|
import { resolveMcpSetupConfig } from "./effective-server.js";
|
|
6
5
|
import { classifyMcpConnectionError } from "./connection-errors.js";
|
|
7
6
|
import { prepareNativeMcpConfig } from "./native-mcp.js";
|
|
8
7
|
import { McpAuthenticationRequiredError, discoverMcpTools, signInNativeMcp } from "./tool-catalog.js";
|
|
8
|
+
import { isPrivateMcpIp, isPrivateMcpTarget, isPublicMcpIp, isPublicMcpTarget } from "./network-policy.js";
|
|
9
9
|
import { createHash, randomUUID } from "node:crypto";
|
|
10
10
|
import { lookup } from "node:dns";
|
|
11
11
|
import { Agent } from "undici";
|
|
@@ -17,9 +17,10 @@ function httpUrl(value) {
|
|
|
17
17
|
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) throw new Error("Use an HTTP or HTTPS MCP address without embedded credentials.");
|
|
18
18
|
return url;
|
|
19
19
|
}
|
|
20
|
-
async function metadata(url, endpoint, signal, publicOnly = false) {
|
|
21
|
-
const
|
|
22
|
-
|
|
20
|
+
async function metadata(url, endpoint, signal, publicOnly = false, privateNetwork = false) {
|
|
21
|
+
const local = endpoint.origin === url.origin && !publicOnly;
|
|
22
|
+
const privateOrigin = local && privateNetwork;
|
|
23
|
+
if (privateOrigin ? !isPrivateMcpTarget(url) : !local && !isPublicMcpTarget(url)) return { state: "invalid" };
|
|
23
24
|
const { retryAfter } = await import("./transport.js");
|
|
24
25
|
signal?.throwIfAborted();
|
|
25
26
|
const dispatcher = new Agent({ connect: { lookup(host, options, callback) {
|
|
@@ -28,8 +29,9 @@ async function metadata(url, endpoint, signal, publicOnly = false) {
|
|
|
28
29
|
callback(error, "", 4);
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const allowed = privateOrigin ? isPrivateMcpIp : isPublicMcpIp;
|
|
33
|
+
if ((!local || privateOrigin) && addresses.some((address) => !allowed(address.address))) {
|
|
34
|
+
callback(/* @__PURE__ */ new Error("Authorization metadata resolved outside its approved network"), "", 4);
|
|
33
35
|
return;
|
|
34
36
|
}
|
|
35
37
|
if (options.all) callback(null, addresses);
|
|
@@ -90,15 +92,16 @@ async function authentication(config, workspace, serverId, failure, options) {
|
|
|
90
92
|
options?.signal?.throwIfAborted();
|
|
91
93
|
const url = httpUrl(entry.config.url);
|
|
92
94
|
const publicOnly = config.mcp?.servers?.[serverId]?.xopcPublicOnly === true;
|
|
95
|
+
const privateNetwork = config.mcp?.servers?.[serverId]?.xopcPrivateNetwork === true;
|
|
93
96
|
const allowedIssuer = (value) => {
|
|
94
97
|
try {
|
|
95
98
|
if (typeof value !== "string") return false;
|
|
96
99
|
const issuer = httpUrl(value);
|
|
97
|
-
return !issuer.hash && (issuer.protocol === "https:" &&
|
|
100
|
+
return !issuer.hash && (issuer.protocol === "https:" && isPublicMcpTarget(issuer) || !publicOnly && issuer.origin === url.origin && (privateNetwork ? issuer.protocol === "https:" && isPrivateMcpTarget(issuer) : [
|
|
98
101
|
"localhost",
|
|
99
102
|
"127.0.0.1",
|
|
100
103
|
"[::1]"
|
|
101
|
-
].includes(issuer.hostname));
|
|
104
|
+
].includes(issuer.hostname)));
|
|
102
105
|
} catch {
|
|
103
106
|
return false;
|
|
104
107
|
}
|
|
@@ -119,11 +122,11 @@ async function authentication(config, workspace, serverId, failure, options) {
|
|
|
119
122
|
method: "GET",
|
|
120
123
|
stage: "authorization_metadata"
|
|
121
124
|
});
|
|
122
|
-
return metadata(target, url, options?.signal, publicOnly);
|
|
125
|
+
return metadata(target, url, options?.signal, publicOnly, privateNetwork);
|
|
123
126
|
};
|
|
124
127
|
let issuer;
|
|
125
128
|
for (const candidate of new Map(candidates.map((c) => [c.href, c])).values()) {
|
|
126
|
-
if (!allowedIssuer(candidate.href)) {
|
|
129
|
+
if (!(privateNetwork && candidate.origin === url.origin && !candidate.username && !candidate.password && !candidate.hash && isPrivateMcpTarget(candidate)) && !allowedIssuer(candidate.href)) {
|
|
127
130
|
state = "invalid";
|
|
128
131
|
continue;
|
|
129
132
|
}
|
|
@@ -69,6 +69,7 @@ async function prepareNativeMcpConfig(config, workspaceDir, agentId) {
|
|
|
69
69
|
"toolExposure",
|
|
70
70
|
"description",
|
|
71
71
|
"xopcPublicOnly",
|
|
72
|
+
"xopcPrivateNetwork",
|
|
72
73
|
"xopcManagedStdio"
|
|
73
74
|
].filter((key) => value[key] !== void 0).map((key) => [key, value[key]]));
|
|
74
75
|
if (typeof value.displayName === "string" && value.displayName.trim()) projected.description = `Service: ${value.displayName.trim()}. ${typeof value.description === "string" ? value.description : ""}`.trim();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function mcpHostname(hostname: string): string;
|
|
2
|
+
export declare function isPrivateMcpIp(value: string): boolean;
|
|
3
|
+
export declare function suggestsPrivateMcpHostname(value: string): boolean;
|
|
4
|
+
export declare function isPrivateMcpTarget(url: URL): boolean;
|
|
5
|
+
export declare function isPublicMcpTarget(url: URL): boolean;
|
|
6
|
+
export declare function isPublicMcpIp(address: string): boolean;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { checkUrlSafety } from "../tools/url-safety.js";
|
|
2
|
+
import { BlockList, isIP } from "node:net";
|
|
3
|
+
//#region src/agent/mcp/network-policy.ts
|
|
4
|
+
const privateIps = new BlockList();
|
|
5
|
+
for (const [prefix, bits] of [
|
|
6
|
+
["10.0.0.0", 8],
|
|
7
|
+
["127.0.0.0", 8],
|
|
8
|
+
["172.16.0.0", 12],
|
|
9
|
+
["192.168.0.0", 16],
|
|
10
|
+
["100.64.0.0", 10]
|
|
11
|
+
]) privateIps.addSubnet(prefix, bits);
|
|
12
|
+
privateIps.addAddress("::1", "ipv6");
|
|
13
|
+
privateIps.addSubnet("fc00::", 7, "ipv6");
|
|
14
|
+
const blockedIpv6 = new BlockList();
|
|
15
|
+
blockedIpv6.addSubnet("::ffff:0:0", 96, "ipv6");
|
|
16
|
+
blockedIpv6.addAddress("::", "ipv6");
|
|
17
|
+
blockedIpv6.addSubnet("fe80::", 10, "ipv6");
|
|
18
|
+
blockedIpv6.addSubnet("ff00::", 8, "ipv6");
|
|
19
|
+
function mcpHostname(hostname) {
|
|
20
|
+
return hostname.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
|
|
21
|
+
}
|
|
22
|
+
function isPrivateMcpIp(value) {
|
|
23
|
+
const host = mcpHostname(value);
|
|
24
|
+
const family = isIP(host);
|
|
25
|
+
const type = family === 6 ? "ipv6" : "ipv4";
|
|
26
|
+
return family !== 0 && host !== "100.100.100.200" && (family !== 6 || !blockedIpv6.check(host, "ipv6")) && privateIps.check(host, type);
|
|
27
|
+
}
|
|
28
|
+
function suggestsPrivateMcpHostname(value) {
|
|
29
|
+
const host = mcpHostname(value);
|
|
30
|
+
return isPrivateMcpIp(host) || isIP(host) === 0 && (!host.includes(".") || /\.(?:localhost|local|lan|internal|home\.arpa)$/.test(host));
|
|
31
|
+
}
|
|
32
|
+
function isPrivateMcpTarget(url) {
|
|
33
|
+
const host = mcpHostname(url.hostname);
|
|
34
|
+
if (host === "metadata.google.internal" || host === "metadata.goog") return false;
|
|
35
|
+
return isIP(host) ? isPrivateMcpIp(host) : Boolean(host);
|
|
36
|
+
}
|
|
37
|
+
function isPublicMcpTarget(url) {
|
|
38
|
+
const host = mcpHostname(url.hostname);
|
|
39
|
+
const family = isIP(host);
|
|
40
|
+
if (suggestsPrivateMcpHostname(host) || family === 6 && blockedIpv6.check(host, "ipv6")) return false;
|
|
41
|
+
const normalized = new URL(url);
|
|
42
|
+
if (host !== url.hostname && isIP(host) !== 6) normalized.hostname = host;
|
|
43
|
+
return checkUrlSafety(normalized.href).safe;
|
|
44
|
+
}
|
|
45
|
+
function isPublicMcpIp(address) {
|
|
46
|
+
return isPublicMcpTarget(new URL(`http://${isIP(address) === 6 ? `[${address}]` : address}`));
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { isPrivateMcpIp, isPrivateMcpTarget, isPublicMcpIp, isPublicMcpTarget, mcpHostname, suggestsPrivateMcpHostname };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isPrivateMcpIp, isPrivateMcpTarget, isPublicMcpIp, isPublicMcpTarget, mcpHostname } from "./network-policy.js";
|
|
2
2
|
import { mcpStdioSupervisor } from "../../process/mcp-stdio-supervisor.js";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import { lookup } from "node:dns";
|
|
@@ -73,14 +73,18 @@ function createXopcMcpTransport(diagnostics = {}, assertPluginCallAccess) {
|
|
|
73
73
|
}
|
|
74
74
|
const url = new URL(String(config.url));
|
|
75
75
|
const headers = config.headers;
|
|
76
|
-
const
|
|
76
|
+
const privateNetwork = config.xopcPrivateNetwork === true;
|
|
77
|
+
const publicOnly = config.xopcPublicOnly === true;
|
|
78
|
+
const makeDispatcher = (policy) => new Agent({ connect: { lookup(host, options, callback) {
|
|
77
79
|
lookup(host, { all: true }, (error, addresses) => {
|
|
78
80
|
if (error) {
|
|
79
81
|
callback(error, "", 4);
|
|
80
82
|
return;
|
|
81
83
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
const local = policy === "legacy" && mcpHostname(host) === mcpHostname(url.hostname);
|
|
85
|
+
const allowed = policy === "private" ? isPrivateMcpIp : isPublicMcpIp;
|
|
86
|
+
if (!local && addresses.some((address) => !allowed(address.address))) {
|
|
87
|
+
callback(/* @__PURE__ */ new Error("MCP destination resolved outside its approved network"), "", 4);
|
|
84
88
|
return;
|
|
85
89
|
}
|
|
86
90
|
if (options.all) callback(null, addresses);
|
|
@@ -88,6 +92,8 @@ function createXopcMcpTransport(diagnostics = {}, assertPluginCallAccess) {
|
|
|
88
92
|
else callback(/* @__PURE__ */ new Error("MCP destination has no address"), "", 4);
|
|
89
93
|
});
|
|
90
94
|
} } });
|
|
95
|
+
const dispatcher = makeDispatcher(privateNetwork ? "private" : publicOnly ? "public" : "legacy");
|
|
96
|
+
const externalDispatcher = privateNetwork ? makeDispatcher("public") : void 0;
|
|
91
97
|
const fetcher = async (input, init) => {
|
|
92
98
|
const method = init?.method ?? "GET";
|
|
93
99
|
let stage = method === "GET" ? "stream" : "request";
|
|
@@ -99,11 +105,12 @@ function createXopcMcpTransport(diagnostics = {}, assertPluginCallAccess) {
|
|
|
99
105
|
stage
|
|
100
106
|
});
|
|
101
107
|
const target = new URL(input);
|
|
102
|
-
|
|
108
|
+
const sameOrigin = target.origin === url.origin;
|
|
109
|
+
if (!(privateNetwork && sameOrigin ? isPrivateMcpTarget(target) : !sameOrigin || publicOnly ? isPublicMcpTarget(target) && (!privateNetwork || target.protocol === "https:") : true)) throw new Error("MCP network policy refused this destination");
|
|
103
110
|
const response = await fetch(input, {
|
|
104
111
|
...init,
|
|
105
112
|
redirect: "error",
|
|
106
|
-
dispatcher
|
|
113
|
+
dispatcher: sameOrigin ? dispatcher : externalDispatcher ?? dispatcher
|
|
107
114
|
});
|
|
108
115
|
const media = (response.headers.get("content-type") ?? "").split(";")[0].toLowerCase();
|
|
109
116
|
diagnostics.observe?.({
|
|
@@ -135,7 +142,7 @@ function createXopcMcpTransport(diagnostics = {}, assertPluginCallAccess) {
|
|
|
135
142
|
try {
|
|
136
143
|
await close();
|
|
137
144
|
} finally {
|
|
138
|
-
await dispatcher.close();
|
|
145
|
+
await Promise.all([dispatcher.close(), externalDispatcher?.close()]);
|
|
139
146
|
}
|
|
140
147
|
};
|
|
141
148
|
return guard(transport);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { commandRegistry } from "../../chat-commands/registry.js";
|
|
2
2
|
//#region src/agent/messaging/message-router.ts
|
|
3
3
|
var MessageRouter = class {
|
|
4
4
|
/**
|
|
@@ -13,7 +13,7 @@ var MessageRouter = class {
|
|
|
13
13
|
senderId: msg.metadata?.senderId || msg.sender_id,
|
|
14
14
|
isGroup: msg.metadata?.isGroup || false
|
|
15
15
|
};
|
|
16
|
-
const commandInfo =
|
|
16
|
+
const commandInfo = commandRegistry.parseRegisteredSlashCommand(msg.content);
|
|
17
17
|
return {
|
|
18
18
|
context,
|
|
19
19
|
isCommand: commandInfo !== null,
|
|
@@ -70,7 +70,7 @@ export declare class ModelManager {
|
|
|
70
70
|
/**
|
|
71
71
|
* Ordered model candidates for the session.
|
|
72
72
|
*/
|
|
73
|
-
getFallbackCandidatesForSession(conversationId: string): ModelCandidate[];
|
|
73
|
+
getFallbackCandidatesForSession(conversationId: string, includeUnconfigured?: boolean): ModelCandidate[];
|
|
74
74
|
/**
|
|
75
75
|
* Apply a resolved pi-ai model and sync {@link currentModelName} / {@link currentProvider}.
|
|
76
76
|
*/
|
|
@@ -152,7 +152,7 @@ var ModelManager = class {
|
|
|
152
152
|
/**
|
|
153
153
|
* Ordered model candidates for the session.
|
|
154
154
|
*/
|
|
155
|
-
getFallbackCandidatesForSession(conversationId) {
|
|
155
|
+
getFallbackCandidatesForSession(conversationId, includeUnconfigured = false) {
|
|
156
156
|
const parsed = parseModelRef(this.getModelForSession(conversationId));
|
|
157
157
|
if (!parsed) return [];
|
|
158
158
|
if (this.fixedSessionModels.has(conversationId)) return [parsed];
|
|
@@ -160,6 +160,7 @@ var ModelManager = class {
|
|
|
160
160
|
cfg: this.config,
|
|
161
161
|
provider: parsed.provider,
|
|
162
162
|
model: parsed.model,
|
|
163
|
+
includeUnconfigured,
|
|
163
164
|
fallbacksOverride: this.sessionModels.has(conversationId) ? void 0 : this.sessionProfileFallbacks.get(conversationId)
|
|
164
165
|
});
|
|
165
166
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { EffectiveAgentConfig } from '../../agent-config/index.js';
|
|
2
|
+
import type { ModelManager } from './manager.js';
|
|
3
|
+
export declare function resolveTurnModelRefs(modelManager: ModelManager, conversationId: string, effective?: EffectiveAgentConfig, voiceModelRef?: string, checkCredentials?: boolean): {
|
|
4
|
+
configured: string;
|
|
5
|
+
selected: string;
|
|
6
|
+
refs: string[];
|
|
7
|
+
useSessionModel: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare class TaskModelPreflightError extends Error {
|
|
10
|
+
readonly code: 'provider_setup_required' | 'provider_auth_invalid' | 'task_model_unavailable';
|
|
11
|
+
readonly modelRef: string;
|
|
12
|
+
readonly provider?: string;
|
|
13
|
+
constructor(code: 'provider_setup_required' | 'provider_auth_invalid' | 'task_model_unavailable', modelRef: string, provider?: string);
|
|
14
|
+
}
|
|
15
|
+
/** Resolve the configured background candidates without sending a model request. */
|
|
16
|
+
export declare function resolveAvailableTaskModels(refs: string[], selected: string): Promise<any[]>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { assertProviderUsage, getModelUsageOrigin, init_model_usage } from "../../providers/model-usage.js";
|
|
2
|
+
import { getApiKey, init_providers, resolveModel } from "../../providers/index.js";
|
|
3
|
+
//#region src/agent/models/turn-candidates.ts
|
|
4
|
+
init_providers();
|
|
5
|
+
init_model_usage();
|
|
6
|
+
function resolveTurnModelRefs(modelManager, conversationId, effective, voiceModelRef, checkCredentials = false) {
|
|
7
|
+
const configured = modelManager.getModelForSession(conversationId);
|
|
8
|
+
const background = !voiceModelRef && getModelUsageOrigin() === "background" && !modelManager.hasSessionModelOverride?.(conversationId) && configured === effective?.models.chat.primary ? effective.models.background : void 0;
|
|
9
|
+
const candidates = modelManager.getFallbackCandidatesForSession?.(conversationId, checkCredentials);
|
|
10
|
+
return {
|
|
11
|
+
configured,
|
|
12
|
+
selected: voiceModelRef ?? background?.primary ?? configured,
|
|
13
|
+
refs: voiceModelRef ? [voiceModelRef] : background ? [background.primary, ...background.fallbacks] : candidates?.length ? candidates.map((candidate) => `${candidate.provider}/${candidate.model}`) : [configured],
|
|
14
|
+
useSessionModel: !voiceModelRef && !background
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
var TaskModelPreflightError = class extends Error {
|
|
18
|
+
constructor(code, modelRef, provider) {
|
|
19
|
+
super(`No usable credentials or model for task execution (${modelRef})`);
|
|
20
|
+
this.code = code;
|
|
21
|
+
this.modelRef = modelRef;
|
|
22
|
+
this.provider = provider;
|
|
23
|
+
this.name = "TaskModelPreflightError";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/** Resolve the configured background candidates without sending a model request. */
|
|
27
|
+
async function resolveAvailableTaskModels(refs, selected) {
|
|
28
|
+
const authByProvider = /* @__PURE__ */ new Map();
|
|
29
|
+
const candidates = [];
|
|
30
|
+
let authFailure;
|
|
31
|
+
for (const ref of new Set(refs)) {
|
|
32
|
+
let model;
|
|
33
|
+
try {
|
|
34
|
+
model = resolveModel(ref);
|
|
35
|
+
assertProviderUsage(model.provider, model.baseUrl);
|
|
36
|
+
} catch {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
let auth = authByProvider.get(model.provider);
|
|
40
|
+
if (!auth) {
|
|
41
|
+
auth = getApiKey(model.provider).then((key) => key?.trim() ? "ready" : "missing", () => "invalid");
|
|
42
|
+
authByProvider.set(model.provider, auth);
|
|
43
|
+
}
|
|
44
|
+
const status = await auth;
|
|
45
|
+
if (status === "ready") candidates.push({
|
|
46
|
+
ref,
|
|
47
|
+
model
|
|
48
|
+
});
|
|
49
|
+
else authFailure ??= new TaskModelPreflightError(status === "missing" ? "provider_setup_required" : "provider_auth_invalid", ref, model.provider);
|
|
50
|
+
}
|
|
51
|
+
if (candidates.length === 0) throw authFailure ?? new TaskModelPreflightError("task_model_unavailable", selected);
|
|
52
|
+
return candidates;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { TaskModelPreflightError, resolveAvailableTaskModels, resolveTurnModelRefs };
|
|
@@ -8,10 +8,8 @@ import { phoneResumeForRun } from "../../phone/assistance.js";
|
|
|
8
8
|
import { buildDelegatedTaskDirective, buildTaskExecutionDirective } from "../../tasks/task-context-assembler.js";
|
|
9
9
|
import { getMcpSetupResumeInput } from "../mcp/continuation-input.js";
|
|
10
10
|
import { shouldSkipResetOverlapCommand } from "../../session/reset-triggers.js";
|
|
11
|
-
import { parseSlashCommand } from "../../chat-commands/command-parse.js";
|
|
12
11
|
import { personalCommandRejection } from "../../chat-commands/personal-command-policy.js";
|
|
13
12
|
import { commandRegistry } from "../../chat-commands/registry.js";
|
|
14
|
-
import "../../chat-commands/index.js";
|
|
15
13
|
import { getTaskContinuation } from "../../tasks/task-continuation.js";
|
|
16
14
|
import { runEmbeddedTurnForSession } from "../embedded/run-for-session.js";
|
|
17
15
|
import crypto from "node:crypto";
|
|
@@ -42,18 +40,13 @@ async function tryRunSlashCommand(deps, ctx, content, options) {
|
|
|
42
40
|
aggregatedText: ""
|
|
43
41
|
};
|
|
44
42
|
const personal = isPersonalConversation(ctx.conversationId);
|
|
45
|
-
const parsed =
|
|
43
|
+
const parsed = commandRegistry.parseRegisteredSlashCommand(personal ? content.trim().split(/\r?\n/, 1)[0] : content);
|
|
46
44
|
if (!parsed) return {
|
|
47
45
|
matched: false,
|
|
48
46
|
aggregatedText: ""
|
|
49
47
|
};
|
|
50
48
|
if (personal) {
|
|
51
|
-
const
|
|
52
|
-
if (!command && !parsed.command.startsWith("skill:")) return {
|
|
53
|
-
matched: false,
|
|
54
|
-
aggregatedText: ""
|
|
55
|
-
};
|
|
56
|
-
const rejection = personalCommandRejection(ctx.conversationId, command?.id ?? "skill.invoke", parsed.command);
|
|
49
|
+
const rejection = personalCommandRejection(ctx.conversationId, parsed.definition.id, parsed.command);
|
|
57
50
|
if (rejection) return {
|
|
58
51
|
matched: true,
|
|
59
52
|
aggregatedText: rejection,
|
|
@@ -64,25 +57,13 @@ async function tryRunSlashCommand(deps, ctx, content, options) {
|
|
|
64
57
|
matched: false,
|
|
65
58
|
aggregatedText: ""
|
|
66
59
|
};
|
|
67
|
-
if (!
|
|
68
|
-
if (parsed.command.startsWith("skill:")) return {
|
|
69
|
-
matched: false,
|
|
70
|
-
aggregatedText: ""
|
|
71
|
-
};
|
|
72
|
-
return {
|
|
73
|
-
matched: true,
|
|
74
|
-
aggregatedText: `Unknown command: /${parsed.command}\nType /help to see available commands.`,
|
|
75
|
-
command: parsed.command
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
const command = commandRegistry.findByName(parsed.command);
|
|
79
|
-
if (options?.sourceContexts?.length && !command?.acceptsContext) return {
|
|
60
|
+
if (options?.sourceContexts?.length && !parsed.definition.acceptsContext) return {
|
|
80
61
|
matched: true,
|
|
81
62
|
aggregatedText: `Command /${parsed.command} does not accept Note context. Remove the Note reference or use it with a regular prompt.`,
|
|
82
63
|
command: parsed.command
|
|
83
64
|
};
|
|
84
65
|
try {
|
|
85
|
-
const { aggregatedText, metadata } = await deps.commandHandler.executeCommandAndAggregateReply(parsed.command, parsed.args, {
|
|
66
|
+
const { handled, aggregatedText, metadata } = await deps.commandHandler.executeCommandAndAggregateReply(parsed.command, parsed.args, {
|
|
86
67
|
conversationId: ctx.conversationId,
|
|
87
68
|
channel: ctx.channel,
|
|
88
69
|
chatId: ctx.chatId,
|
|
@@ -91,9 +72,13 @@ async function tryRunSlashCommand(deps, ctx, content, options) {
|
|
|
91
72
|
inboundMetadata: ctx.inboundMetadata ?? {},
|
|
92
73
|
sourceContexts: options?.sourceContexts
|
|
93
74
|
}, { emitEvent: options?.emitEvent });
|
|
75
|
+
if (!handled) return {
|
|
76
|
+
matched: false,
|
|
77
|
+
aggregatedText: ""
|
|
78
|
+
};
|
|
94
79
|
return {
|
|
95
80
|
matched: true,
|
|
96
|
-
aggregatedText
|
|
81
|
+
aggregatedText,
|
|
97
82
|
command: parsed.command,
|
|
98
83
|
metadata
|
|
99
84
|
};
|
|
@@ -128,6 +128,7 @@ export declare class AgentService {
|
|
|
128
128
|
refreshUserProfileContext(): void;
|
|
129
129
|
getMemoryManager(): import("./memory/manager.js").MemoryManager;
|
|
130
130
|
getModelForSession(conversationId: string): string;
|
|
131
|
+
preflightTaskModel(conversationId: string): Promise<void>;
|
|
131
132
|
getThinkingLevelForSession(conversationId: string): ThinkingLevel;
|
|
132
133
|
/** Run a full tool-capable turn against a caller-owned, non-persistent transcript. */
|
|
133
134
|
runEphemeralTurn(params: {
|
|
@@ -2,6 +2,7 @@ import { createLogger } from "../utils/logger/index.js";
|
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
3
|
import { init_agent_scope, resolveAgentHomeDir, resolveDefaultAgentId } from "./agent-scope.js";
|
|
4
4
|
import { parseNoteAttachmentTarget } from "../notes/attachment-ref.js";
|
|
5
|
+
import { init_model_usage, withModelUsageOrigin } from "../providers/model-usage.js";
|
|
5
6
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
6
7
|
import { init_agent_session_key, resolveAgentIdFromConversationId } from "../routing/agent-session-key.js";
|
|
7
8
|
import { extractProfileAgentId, resolveEffectiveAgentConfigForSession } from "../config/agent-profile.js";
|
|
@@ -23,6 +24,7 @@ import { persistInboundAttachments } from "../channels/attachments/inbound-persi
|
|
|
23
24
|
import { buildTranscriptUserMessage, hydrateUserTurnForLlm } from "./inbound/attachment-pipeline.js";
|
|
24
25
|
import { runWithEmbeddedExecutionSession } from "./embedded/execution-context.js";
|
|
25
26
|
import { resolveResponseLanguageForSession } from "./prompt/response-language.js";
|
|
27
|
+
import { resolveAvailableTaskModels, resolveTurnModelRefs } from "./models/turn-candidates.js";
|
|
26
28
|
import { normalizeSkillInstallTarget } from "./skills/install-target.js";
|
|
27
29
|
import { drainEmbeddedSessionRunnerShutdowns } from "./embedded/session-runner.js";
|
|
28
30
|
import { AgentManager } from "./agent-manager.js";
|
|
@@ -74,6 +76,7 @@ import { readFile } from "node:fs/promises";
|
|
|
74
76
|
init_agent_session_key();
|
|
75
77
|
init_schema();
|
|
76
78
|
init_logger();
|
|
79
|
+
init_model_usage();
|
|
77
80
|
init_agent_scope();
|
|
78
81
|
init_providers();
|
|
79
82
|
const log = createLogger("AgentService");
|
|
@@ -591,6 +594,15 @@ var AgentService = class {
|
|
|
591
594
|
getModelForSession(conversationId) {
|
|
592
595
|
return this.modelManager.getModelForSession(conversationId);
|
|
593
596
|
}
|
|
597
|
+
async preflightTaskModel(conversationId) {
|
|
598
|
+
const { config } = resolveEffectiveAgentConfigForSession(conversationId);
|
|
599
|
+
this.modelManager.setSessionProfileDefault(conversationId, config.models.chat.primary, config.models.chat.fallbacks);
|
|
600
|
+
await this.sessionHydrator.model(conversationId);
|
|
601
|
+
await withModelUsageOrigin("background", async () => {
|
|
602
|
+
const { refs, selected } = resolveTurnModelRefs(this.modelManager, conversationId, config, void 0, true);
|
|
603
|
+
await resolveAvailableTaskModels(refs, selected);
|
|
604
|
+
});
|
|
605
|
+
}
|
|
594
606
|
getThinkingLevelForSession(conversationId) {
|
|
595
607
|
return this.agentManager.getOrCreateAgent(conversationId).state.thinkingLevel ?? "medium";
|
|
596
608
|
}
|
|
@@ -5,7 +5,7 @@ import { ManagedRuntimeManager } from "../../runtime-tools/manager.js";
|
|
|
5
5
|
import { buildRuntimeEnvironment } from "../../runtime-tools/environment.js";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import { delimiter, join } from "path";
|
|
8
|
-
import { accessSync, constants
|
|
8
|
+
import { accessSync, constants, existsSync } from "fs";
|
|
9
9
|
import { access, mkdir, writeFile } from "fs/promises";
|
|
10
10
|
import { promisify } from "util";
|
|
11
11
|
import { execFile } from "child_process";
|
|
@@ -36,7 +36,7 @@ function hasBinary(name) {
|
|
|
36
36
|
for (const dir of pathEntries) for (const ext of extensions) {
|
|
37
37
|
const candidate = join(dir, `${name}${ext}`);
|
|
38
38
|
try {
|
|
39
|
-
accessSync(candidate, constants
|
|
39
|
+
accessSync(candidate, constants.X_OK);
|
|
40
40
|
return true;
|
|
41
41
|
} catch {}
|
|
42
42
|
}
|
|
@@ -3,7 +3,7 @@ import { createLogger } from "../utils/logger/index.js";
|
|
|
3
3
|
import { init_logger } from "../utils/logger.js";
|
|
4
4
|
import { init_write_file_atomic, writeTextAtomic } from "../infra/write-file-atomic.js";
|
|
5
5
|
import { init_paths, resolveAgentAuthProfilesPath, resolveAuthProfilesPath, resolveCredentialsDir, resolveOAuthPath } from "../config/paths.js";
|
|
6
|
-
import { assertCurrentModelProvider, init_provider_policy } from "../providers/provider-policy.js";
|
|
6
|
+
import { assertCurrentModelProvider, init_provider_policy, isRetiredModelProvider } from "../providers/provider-policy.js";
|
|
7
7
|
import { getApiKeyFromEnv, init_env_keys } from "../providers/env-keys.js";
|
|
8
8
|
import { init_oauth_provider_lock, withOAuthProviderLock } from "./oauth-provider-lock.js";
|
|
9
9
|
import { getOAuthProviderDefinition, init_registry } from "./oauth/registry.js";
|
|
@@ -189,6 +189,7 @@ var init_credentials = __esmMin((() => {
|
|
|
189
189
|
*/
|
|
190
190
|
async loadOAuthToken(provider) {
|
|
191
191
|
const normalizedProvider = provider.toLowerCase();
|
|
192
|
+
if (isRetiredModelProvider(normalizedProvider)) return null;
|
|
192
193
|
let token = await this.loadOAuthTokenRecord(normalizedProvider);
|
|
193
194
|
if (!token) return null;
|
|
194
195
|
let expiresAt = token.expiresAt ?? Number.POSITIVE_INFINITY;
|
|
@@ -309,6 +310,7 @@ var init_credentials = __esmMin((() => {
|
|
|
309
310
|
*/
|
|
310
311
|
async saveOAuthToken(provider, token) {
|
|
311
312
|
const normalizedProvider = provider.toLowerCase();
|
|
313
|
+
assertCurrentModelProvider(normalizedProvider);
|
|
312
314
|
await withOAuthProviderLock(normalizedProvider, async () => {
|
|
313
315
|
const oauthPath = resolveOAuthPath(normalizedProvider);
|
|
314
316
|
await mkdir(dirname(oauthPath), { recursive: true });
|
|
@@ -8,7 +8,6 @@ export * from './anthropic.js';
|
|
|
8
8
|
export * from './kimi-coding.js';
|
|
9
9
|
export * from './github-copilot.js';
|
|
10
10
|
export * from './google-gemini-cli.js';
|
|
11
|
-
export * from './google-antigravity.js';
|
|
12
11
|
export * from './openai.js';
|
|
13
12
|
export * from './xopc-cloud.js';
|
|
14
13
|
export * from './registry.js';
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { anthropicOAuthProvider, init_anthropic } from "./anthropic.js";
|
|
2
2
|
import { githubCopilotOAuthProvider, init_github_copilot } from "./github-copilot.js";
|
|
3
|
-
import { antigravityOAuthProvider, loginAntigravity, refreshAntigravityToken } from "./google-oauth/google-antigravity.js";
|
|
4
|
-
import { init_google_antigravity } from "./google-antigravity.js";
|
|
5
3
|
import { geminiCliOAuthProvider, loginGeminiCli, refreshGoogleCloudToken } from "./google-oauth/google-gemini-cli.js";
|
|
6
4
|
import { init_google_gemini_cli } from "./google-gemini-cli.js";
|
|
7
5
|
import { init_kimi_coding, kimiCodingOAuthProvider } from "./kimi-coding.js";
|
|
@@ -13,9 +11,8 @@ init_anthropic();
|
|
|
13
11
|
init_kimi_coding();
|
|
14
12
|
init_github_copilot();
|
|
15
13
|
init_google_gemini_cli();
|
|
16
|
-
init_google_antigravity();
|
|
17
14
|
init_openai();
|
|
18
15
|
init_xopc_cloud();
|
|
19
16
|
init_registry();
|
|
20
17
|
//#endregion
|
|
21
|
-
export { OAUTH_PROVIDER_DEFINITIONS, anthropicOAuthProvider, getModelOAuthProviderIds, getOAuthProviderDefinition, getOAuthProviderIds, getOAuthProviderInterfaces, githubCopilotOAuthProvider,
|
|
18
|
+
export { OAUTH_PROVIDER_DEFINITIONS, anthropicOAuthProvider, getModelOAuthProviderIds, getOAuthProviderDefinition, getOAuthProviderIds, getOAuthProviderInterfaces, githubCopilotOAuthProvider, geminiCliOAuthProvider as googleGeminiCliOAuthProvider, isOAuthOnlyProvider, kimiCodingOAuthProvider, loginGeminiCli, openaiOAuthProvider, refreshGoogleCloudToken, xopcCloudOAuthProvider, xopcShareOAuthProvider, xopcTunnelOAuthProvider };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { anthropicOAuthProvider, init_anthropic } from "./anthropic.js";
|
|
3
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
4
|
import { geminiCliOAuthProvider } from "./google-oauth/google-gemini-cli.js";
|
|
7
5
|
import { init_google_gemini_cli } from "./google-gemini-cli.js";
|
|
8
6
|
import { init_kimi_coding, kimiCodingOAuthProvider } from "./kimi-coding.js";
|
|
@@ -37,7 +35,6 @@ var OAUTH_PROVIDER_DEFINITIONS;
|
|
|
37
35
|
var init_registry = __esmMin((() => {
|
|
38
36
|
init_anthropic();
|
|
39
37
|
init_github_copilot();
|
|
40
|
-
init_google_antigravity();
|
|
41
38
|
init_google_gemini_cli();
|
|
42
39
|
init_kimi_coding();
|
|
43
40
|
init_openai();
|
|
@@ -59,7 +56,6 @@ var init_registry = __esmMin((() => {
|
|
|
59
56
|
"kimi-coding": definition(kimiCodingOAuthProvider, "models", "Kimi For Coding (月之暗面)"),
|
|
60
57
|
"github-copilot": definition(githubCopilotOAuthProvider, "models"),
|
|
61
58
|
"google-gemini-cli": definition(geminiCliOAuthProvider, "models"),
|
|
62
|
-
"google-antigravity": definition(antigravityOAuthProvider, "models"),
|
|
63
59
|
openai: definition(openaiOAuthProvider, "models")
|
|
64
60
|
};
|
|
65
61
|
}));
|
|
@@ -405,7 +405,7 @@ var init_xopc_cloud = __esmMin((() => {
|
|
|
405
405
|
init_resolution();
|
|
406
406
|
CLIENT_ID = "xopc-native";
|
|
407
407
|
DEFAULT_CONSOLE_URL = "https://console.xopc.ai";
|
|
408
|
-
MODEL_SERVICE_SCOPE = "models:read models:invoke account:usage connectors:read connectors:manage connectors:execute offline_access";
|
|
408
|
+
MODEL_SERVICE_SCOPE = "models:read models:invoke account:usage connectors:read connectors:manage connectors:execute push:manage offline_access";
|
|
409
409
|
TUNNEL_REGISTRATION_SCOPE = "tunnel:register";
|
|
410
410
|
HOSTED_SHARE_SCOPE = "shares:read shares:write offline_access";
|
|
411
411
|
CALLBACK_PATH = "/oauth/callback";
|
|
@@ -7,6 +7,7 @@ export declare function normalizeTelegramCommandName(command: string): string;
|
|
|
7
7
|
* Parse a `/command` from message text. Handles:
|
|
8
8
|
* - `/cmd@BotName` and arguments
|
|
9
9
|
* - Multiline: voice STT text before a line that starts with `/` (Telegram caption after transcript)
|
|
10
|
+
* A leading path or bare slash leaves the message as ordinary input.
|
|
10
11
|
*/
|
|
11
12
|
export declare function parseSlashCommand(text: string): {
|
|
12
13
|
command: string;
|
|
@@ -11,6 +11,7 @@ function normalizeTelegramCommandName(command) {
|
|
|
11
11
|
* Parse a `/command` from message text. Handles:
|
|
12
12
|
* - `/cmd@BotName` and arguments
|
|
13
13
|
* - Multiline: voice STT text before a line that starts with `/` (Telegram caption after transcript)
|
|
14
|
+
* A leading path or bare slash leaves the message as ordinary input.
|
|
14
15
|
*/
|
|
15
16
|
function parseSlashCommand(text) {
|
|
16
17
|
const trimmed = text.trim();
|
|
@@ -18,16 +19,13 @@ function parseSlashCommand(text) {
|
|
|
18
19
|
for (const part of trimmed.split(/\r?\n/)) {
|
|
19
20
|
const line = part.trim();
|
|
20
21
|
if (!line.startsWith("/")) continue;
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
command: normalizeTelegramCommandName(withoutPrefix.slice(0, whitespaceIndex)),
|
|
29
|
-
args: withoutPrefix.slice(whitespaceIndex + 1).trim()
|
|
30
|
-
};
|
|
22
|
+
const match = /^\/([^/\s]+)(?:\s+([\s\S]*))?$/.exec(line);
|
|
23
|
+
if (!match) return null;
|
|
24
|
+
const command = normalizeTelegramCommandName(match[1]);
|
|
25
|
+
return command ? {
|
|
26
|
+
command,
|
|
27
|
+
args: match[2]?.trim() ?? ""
|
|
28
|
+
} : null;
|
|
31
29
|
}
|
|
32
30
|
return null;
|
|
33
31
|
}
|
|
@@ -30,6 +30,11 @@ export declare class CommandRegistry {
|
|
|
30
30
|
* Check if a command exists (by name or alias)
|
|
31
31
|
*/
|
|
32
32
|
has(name: string): boolean;
|
|
33
|
+
parseRegisteredSlashCommand(text: string): {
|
|
34
|
+
command: string;
|
|
35
|
+
args: string;
|
|
36
|
+
definition: CommandDefinition;
|
|
37
|
+
} | null;
|
|
33
38
|
/**
|
|
34
39
|
* Get all registered commands
|
|
35
40
|
*/
|
|
@@ -71,6 +71,14 @@ var CommandRegistry = class CommandRegistry {
|
|
|
71
71
|
has(name) {
|
|
72
72
|
return !!this.findByName(name);
|
|
73
73
|
}
|
|
74
|
+
parseRegisteredSlashCommand(text) {
|
|
75
|
+
const parsed = parseSlashCommand(text);
|
|
76
|
+
const definition = parsed && this.findByName(parsed.command);
|
|
77
|
+
return parsed && definition ? {
|
|
78
|
+
...parsed,
|
|
79
|
+
definition
|
|
80
|
+
} : null;
|
|
81
|
+
}
|
|
74
82
|
/**
|
|
75
83
|
* Get all registered commands
|
|
76
84
|
*/
|