@xopcai/xopc 0.0.484 → 0.0.485
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 +842 -830
- package/dist/gateway/server/chunks.json +1 -1
- package/dist/gateway/static/root/assets/{automations-page-B1Ri4sh8.js → automations-page-uY_wmZY1.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-CNSza6ir.js → automations-workspace-DyQq55Rh.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-page-EENl65YY.js → capabilities-page-WCl7Fdce.js} +2 -2
- package/dist/gateway/static/root/assets/{chat-page-LOR5JxDh.js → chat-page-3fVhP77N.js} +30 -30
- package/dist/gateway/static/root/assets/command-palette-api-UrqPvWR1.js +1 -0
- package/dist/gateway/static/root/assets/{index-DE6GguFZ.js → index-790PGhZb.js} +4 -4
- package/dist/gateway/static/root/assets/{note-detail-panel-DXzfoiyk.js → note-detail-panel-Bwm_aehq.js} +2 -2
- package/dist/gateway/static/root/assets/{notes-page-BNTgiHSk.js → notes-page-DkZWV3Ds.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-D7zTHQ0K.js → personal-page-cauym9hr.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-Dgs8ImMC.js → project-detail-page-D9WKZe3z.js} +1 -1
- package/dist/gateway/static/root/assets/{route-preload-7WVrzJca.js → route-preload-DF8LOfKW.js} +2 -2
- package/dist/gateway/static/root/assets/{settings-page-BOzzOS6k.js → settings-page-Cd9WZ-Ac.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-CKVuhV2i.js → space-page-DlJB7GT1.js} +2 -2
- package/dist/gateway/static/root/assets/{task-detail-page-DEpYIaok.js → task-detail-page-BFa0Px-B.js} +1 -1
- package/dist/gateway/static/root/assets/{task-header-title-Cdgp2rCs.js → task-header-title-qzNctGl5.js} +1 -1
- package/dist/gateway/static/root/assets/{use-personal-work-Dd2jRUpz.js → use-personal-work-B1DWeBnm.js} +1 -1
- package/dist/gateway/static/root/index.html +6 -6
- package/dist/package.js +1 -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/service/direct-turn-helpers.js +9 -24
- 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/config/schema.d.ts +54 -4
- package/dist/src/config/schema.js +3 -1
- package/dist/src/gateway/hono/routes/home.js +1 -1
- 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 +929 -0
- 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/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/service/config-coordinator.d.ts +14 -1
- package/dist/src/gateway/service.js +4 -4
- package/dist/src/home-intelligence/host.js +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/session/reset-triggers.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/command-palette-api-YP0zV_Ol.js +0 -1
|
@@ -570,6 +570,7 @@ export declare const GatewayConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
570
570
|
noProxy: z.ZodDefault<z.ZodString>;
|
|
571
571
|
}, z.core.$strict>>;
|
|
572
572
|
deviceProvidersEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
573
|
+
mobileMcpAllowStdio: z.ZodOptional<z.ZodBoolean>;
|
|
573
574
|
bind: z.ZodOptional<z.ZodEnum<{
|
|
574
575
|
custom: "custom";
|
|
575
576
|
auto: "auto";
|
|
@@ -1177,7 +1178,19 @@ export declare const CommandsConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
|
1177
1178
|
export type CommandsConfig = z.infer<typeof CommandsConfigSchema>;
|
|
1178
1179
|
export declare const McpOAuthConfigSchema: z.ZodObject<{
|
|
1179
1180
|
clientId: z.ZodOptional<z.ZodString>;
|
|
1180
|
-
clientSecret: z.ZodOptional<z.ZodString
|
|
1181
|
+
clientSecret: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
1182
|
+
xopcSecretRef: z.ZodObject<{
|
|
1183
|
+
provider: z.ZodString;
|
|
1184
|
+
fieldKey: z.ZodString;
|
|
1185
|
+
prefix: z.ZodOptional<z.ZodString>;
|
|
1186
|
+
suffix: z.ZodOptional<z.ZodString>;
|
|
1187
|
+
urlPolicy: z.ZodOptional<z.ZodObject<{
|
|
1188
|
+
domains: z.ZodArray<z.ZodString>;
|
|
1189
|
+
pathPrefixes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1190
|
+
encodeValue: z.ZodOptional<z.ZodBoolean>;
|
|
1191
|
+
}, z.core.$strict>>;
|
|
1192
|
+
}, z.core.$strip>;
|
|
1193
|
+
}, z.core.$strip>]>>;
|
|
1181
1194
|
callbackPort: z.ZodOptional<z.ZodNumber>;
|
|
1182
1195
|
callbackUrl: z.ZodOptional<z.ZodString>;
|
|
1183
1196
|
scope: z.ZodOptional<z.ZodString>;
|
|
@@ -1241,7 +1254,19 @@ export declare const McpServerSchema: z.ZodObject<{
|
|
|
1241
1254
|
}, z.core.$strip>]>>>;
|
|
1242
1255
|
oauth: z.ZodOptional<z.ZodObject<{
|
|
1243
1256
|
clientId: z.ZodOptional<z.ZodString>;
|
|
1244
|
-
clientSecret: z.ZodOptional<z.ZodString
|
|
1257
|
+
clientSecret: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
1258
|
+
xopcSecretRef: z.ZodObject<{
|
|
1259
|
+
provider: z.ZodString;
|
|
1260
|
+
fieldKey: z.ZodString;
|
|
1261
|
+
prefix: z.ZodOptional<z.ZodString>;
|
|
1262
|
+
suffix: z.ZodOptional<z.ZodString>;
|
|
1263
|
+
urlPolicy: z.ZodOptional<z.ZodObject<{
|
|
1264
|
+
domains: z.ZodArray<z.ZodString>;
|
|
1265
|
+
pathPrefixes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1266
|
+
encodeValue: z.ZodOptional<z.ZodBoolean>;
|
|
1267
|
+
}, z.core.$strict>>;
|
|
1268
|
+
}, z.core.$strip>;
|
|
1269
|
+
}, z.core.$strip>]>>;
|
|
1245
1270
|
callbackPort: z.ZodOptional<z.ZodNumber>;
|
|
1246
1271
|
callbackUrl: z.ZodOptional<z.ZodString>;
|
|
1247
1272
|
scope: z.ZodOptional<z.ZodString>;
|
|
@@ -1329,7 +1354,19 @@ export declare const McpConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
|
1329
1354
|
}, z.core.$strip>]>>>;
|
|
1330
1355
|
oauth: z.ZodOptional<z.ZodObject<{
|
|
1331
1356
|
clientId: z.ZodOptional<z.ZodString>;
|
|
1332
|
-
clientSecret: z.ZodOptional<z.ZodString
|
|
1357
|
+
clientSecret: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
1358
|
+
xopcSecretRef: z.ZodObject<{
|
|
1359
|
+
provider: z.ZodString;
|
|
1360
|
+
fieldKey: z.ZodString;
|
|
1361
|
+
prefix: z.ZodOptional<z.ZodString>;
|
|
1362
|
+
suffix: z.ZodOptional<z.ZodString>;
|
|
1363
|
+
urlPolicy: z.ZodOptional<z.ZodObject<{
|
|
1364
|
+
domains: z.ZodArray<z.ZodString>;
|
|
1365
|
+
pathPrefixes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1366
|
+
encodeValue: z.ZodOptional<z.ZodBoolean>;
|
|
1367
|
+
}, z.core.$strict>>;
|
|
1368
|
+
}, z.core.$strip>;
|
|
1369
|
+
}, z.core.$strip>]>>;
|
|
1333
1370
|
callbackPort: z.ZodOptional<z.ZodNumber>;
|
|
1334
1371
|
callbackUrl: z.ZodOptional<z.ZodString>;
|
|
1335
1372
|
scope: z.ZodOptional<z.ZodString>;
|
|
@@ -1618,6 +1655,7 @@ export declare const ConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
1618
1655
|
noProxy: z.ZodDefault<z.ZodString>;
|
|
1619
1656
|
}, z.core.$strict>>;
|
|
1620
1657
|
deviceProvidersEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
1658
|
+
mobileMcpAllowStdio: z.ZodOptional<z.ZodBoolean>;
|
|
1621
1659
|
bind: z.ZodOptional<z.ZodEnum<{
|
|
1622
1660
|
custom: "custom";
|
|
1623
1661
|
auto: "auto";
|
|
@@ -2061,7 +2099,19 @@ export declare const ConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
2061
2099
|
}, z.core.$strip>]>>>;
|
|
2062
2100
|
oauth: z.ZodOptional<z.ZodObject<{
|
|
2063
2101
|
clientId: z.ZodOptional<z.ZodString>;
|
|
2064
|
-
clientSecret: z.ZodOptional<z.ZodString
|
|
2102
|
+
clientSecret: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
2103
|
+
xopcSecretRef: z.ZodObject<{
|
|
2104
|
+
provider: z.ZodString;
|
|
2105
|
+
fieldKey: z.ZodString;
|
|
2106
|
+
prefix: z.ZodOptional<z.ZodString>;
|
|
2107
|
+
suffix: z.ZodOptional<z.ZodString>;
|
|
2108
|
+
urlPolicy: z.ZodOptional<z.ZodObject<{
|
|
2109
|
+
domains: z.ZodArray<z.ZodString>;
|
|
2110
|
+
pathPrefixes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2111
|
+
encodeValue: z.ZodOptional<z.ZodBoolean>;
|
|
2112
|
+
}, z.core.$strict>>;
|
|
2113
|
+
}, z.core.$strip>;
|
|
2114
|
+
}, z.core.$strip>]>>;
|
|
2065
2115
|
callbackPort: z.ZodOptional<z.ZodNumber>;
|
|
2066
2116
|
callbackUrl: z.ZodOptional<z.ZodString>;
|
|
2067
2117
|
scope: z.ZodOptional<z.ZodString>;
|
|
@@ -463,6 +463,8 @@ activityDetailDefault: z.enum([
|
|
|
463
463
|
GatewayConfigSchema = z.object({
|
|
464
464
|
outboundProxy: OutboundProxySchema.optional(),
|
|
465
465
|
deviceProvidersEnabled: z.boolean().optional(),
|
|
466
|
+
/** Allow paired phones to review and launch stdio MCP processes on this Gateway. */
|
|
467
|
+
mobileMcpAllowStdio: z.boolean().optional(),
|
|
466
468
|
/** Semantic bind mode. */
|
|
467
469
|
bind: GatewayBindModeSchema.optional(),
|
|
468
470
|
/** IPv4 listen address when `bind` is `custom`. */
|
|
@@ -972,7 +974,7 @@ tts: TTSConfigSchema.optional() }).optional();
|
|
|
972
974
|
]);
|
|
973
975
|
McpOAuthConfigSchema = z.object({
|
|
974
976
|
clientId: z.string().min(1).optional(),
|
|
975
|
-
clientSecret:
|
|
977
|
+
clientSecret: McpConfigScalarSchema.optional(),
|
|
976
978
|
callbackPort: z.number().int().min(1).max(65535).optional(),
|
|
977
979
|
callbackUrl: z.string().url().optional(),
|
|
978
980
|
scope: z.string().optional(),
|
|
@@ -8,8 +8,8 @@ import { acknowledgeHomeAttention } from "../../../storage/sqlite/home-attention
|
|
|
8
8
|
import "../../../storage/sqlite/index.js";
|
|
9
9
|
import { HomeQueryService, buildHomeWorkbench, decisionFromTask } from "../../../tasks/home-query-service.js";
|
|
10
10
|
import { resumeApprovedConnectorAction } from "../../../connectors/approval-resume.js";
|
|
11
|
-
import { ObservationConflictError } from "../../../home-intelligence/observation.js";
|
|
12
11
|
import { HomeOpportunityActionError, HomeOpportunityNotFoundError } from "../../../home-intelligence/application-service.js";
|
|
12
|
+
import { ObservationConflictError } from "../../../home-intelligence/observation.js";
|
|
13
13
|
//#region src/gateway/hono/routes/home.ts
|
|
14
14
|
init_src();
|
|
15
15
|
/** Register the unified work-home read model and its decision actions. */
|
|
@@ -1,6 +1,73 @@
|
|
|
1
1
|
import type { Context, Hono } from 'hono';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { McpConnectionDrafts } from '../../../agent/mcp/connection-drafts.js';
|
|
3
4
|
import type { AuthenticatedRouteDeps } from './deps.js';
|
|
5
|
+
declare const schema: z.ZodObject<{
|
|
6
|
+
action: z.ZodString;
|
|
7
|
+
values: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
8
|
+
flow: z.ZodOptional<z.ZodString>;
|
|
9
|
+
revision: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
}, z.core.$strict>;
|
|
11
|
+
type Visibility = {
|
|
12
|
+
field: string;
|
|
13
|
+
value: string;
|
|
14
|
+
};
|
|
15
|
+
export type Field = {
|
|
16
|
+
id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
type: 'text' | 'multiline' | 'secret' | 'toggle' | 'select' | 'list' | 'headers';
|
|
19
|
+
value?: string;
|
|
20
|
+
hint?: string;
|
|
21
|
+
advanced?: boolean;
|
|
22
|
+
visibleWhen?: Visibility;
|
|
23
|
+
presentation?: 'segmented';
|
|
24
|
+
retain?: boolean;
|
|
25
|
+
options?: {
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
}[];
|
|
29
|
+
};
|
|
30
|
+
export type PanelAction = {
|
|
31
|
+
id: string;
|
|
32
|
+
label: string;
|
|
33
|
+
confirmation?: string;
|
|
34
|
+
inlineReview?: boolean;
|
|
35
|
+
advanced?: boolean;
|
|
36
|
+
visibleWhen?: Visibility;
|
|
37
|
+
dismiss?: boolean;
|
|
38
|
+
};
|
|
39
|
+
type SkillResult = {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
summary?: string;
|
|
43
|
+
source: string;
|
|
44
|
+
iconUrl?: string;
|
|
45
|
+
action?: PanelAction;
|
|
46
|
+
};
|
|
47
|
+
export type Panel = {
|
|
48
|
+
available?: boolean;
|
|
49
|
+
fields?: Field[];
|
|
50
|
+
actions?: PanelAction[];
|
|
51
|
+
headline?: string;
|
|
52
|
+
subtitle?: string;
|
|
53
|
+
reviewText?: string;
|
|
54
|
+
tone?: 'success';
|
|
55
|
+
advancedLabel?: string;
|
|
56
|
+
detailsLabel?: string;
|
|
57
|
+
message?: string;
|
|
58
|
+
details?: string;
|
|
59
|
+
flow?: string;
|
|
60
|
+
revision?: number;
|
|
61
|
+
authorizationUrl?: string;
|
|
62
|
+
deviceVerificationCode?: string;
|
|
63
|
+
qrUrl?: string;
|
|
64
|
+
expiresAt?: number;
|
|
65
|
+
pollAction?: string;
|
|
66
|
+
results?: SkillResult[];
|
|
67
|
+
chatPrompt?: string;
|
|
68
|
+
};
|
|
69
|
+
export type Translator = (zh: string, en: string) => string;
|
|
70
|
+
export type Command = z.output<typeof schema>;
|
|
4
71
|
type SkillMarket = {
|
|
5
72
|
search: (c: Context, query: string) => Promise<{
|
|
6
73
|
items: {
|
|
@@ -12,7 +12,6 @@ import { assertComposioAccessConfigured } from "../../../connectors/composio-ses
|
|
|
12
12
|
import { listComposioConnections, revokeComposioConnection } from "../../../connectors/composio.js";
|
|
13
13
|
import { getConnectorDefinition } from "../../../connectors/catalog.js";
|
|
14
14
|
import { connectorPrincipalForSession } from "../../../connectors/principal.js";
|
|
15
|
-
import { checkUrlSafety } from "../../../agent/tools/url-safety.js";
|
|
16
15
|
import { connectorSecretProviderId } from "../../../connectors/secret-store.js";
|
|
17
16
|
import { materializeConnectorMcpServer } from "../../../connectors/materialize.js";
|
|
18
17
|
import { getInstalledConnectorDefinition, listConnectorInstances } from "../../../connectors/instances.js";
|
|
@@ -36,7 +35,8 @@ import { withAgentPluginSource } from "../../../extensions/agent-plugins/sources
|
|
|
36
35
|
import { getGatewayPrincipal, getPersonalOwnerId } from "../../security/gateway-principal.js";
|
|
37
36
|
import { patchPersonalProfile } from "../../../personal-agent/service.js";
|
|
38
37
|
import { removePluginCredentials } from "../../../extensions/agent-plugins/credentials.js";
|
|
39
|
-
import {
|
|
38
|
+
import { assertMobileStdioAllowed, createMobileMcpSetup } from "./mobile-mcp-setup.js";
|
|
39
|
+
import { randomUUID } from "node:crypto";
|
|
40
40
|
import { isDeepStrictEqual } from "node:util";
|
|
41
41
|
import { z } from "zod";
|
|
42
42
|
//#region src/gateway/hono/routes/mobile-capability-panels.ts
|
|
@@ -53,7 +53,11 @@ const stableId = z.string().regex(/^[\p{L}\p{M}\p{N}_@./: -]{1,160}$/u).refine((
|
|
|
53
53
|
].includes(part.toLowerCase())));
|
|
54
54
|
const schema = z.strictObject({
|
|
55
55
|
action: z.string().min(1).max(240),
|
|
56
|
-
values: z.record(z.string().max(160), z.string().
|
|
56
|
+
values: z.record(z.string().max(160), z.string()).refine((values) => Object.entries(values).every(([key, value]) => value.length <= ([
|
|
57
|
+
"mcp-json",
|
|
58
|
+
"requestHeaders",
|
|
59
|
+
"mcp-env"
|
|
60
|
+
].includes(key) ? 32768 : 8192))).default({}),
|
|
57
61
|
flow: z.string().max(160).optional(),
|
|
58
62
|
revision: z.number().int().optional()
|
|
59
63
|
});
|
|
@@ -165,6 +169,14 @@ function connectorInput(definition, values) {
|
|
|
165
169
|
};
|
|
166
170
|
}
|
|
167
171
|
function registerMobileCapabilityPanels(app, { service, strictRateLimitMiddleware }, drafts, skillMarket) {
|
|
172
|
+
const allowStdio = () => service.currentConfig.gateway?.mobileMcpAllowStdio === true;
|
|
173
|
+
const mobileMcpSetup = createMobileMcpSetup(drafts, () => ({
|
|
174
|
+
allowStdio: allowStdio(),
|
|
175
|
+
workspace: getWorkspacePath(service.currentConfig) || process.cwd()
|
|
176
|
+
}), (owner, id, enable, stdio, t) => withGatewayConfigWriteLock(service, () => {
|
|
177
|
+
if (stdio) assertMobileStdioAllowed(allowStdio(), t);
|
|
178
|
+
return drafts.commit(owner, id, enable);
|
|
179
|
+
}));
|
|
168
180
|
const store = new AgentPluginStore();
|
|
169
181
|
const setup = new PluginSetupService(store);
|
|
170
182
|
const setupOwner = "gateway-owner";
|
|
@@ -409,134 +421,7 @@ function registerMobileCapabilityPanels(app, { service, strictRateLimitMiddlewar
|
|
|
409
421
|
}, cancel]
|
|
410
422
|
};
|
|
411
423
|
}
|
|
412
|
-
if (id === "mcp:setup")
|
|
413
|
-
const owner = getGatewayPrincipal(c).principalId;
|
|
414
|
-
const flow = command?.flow;
|
|
415
|
-
const form = (url = "", name = "") => ({
|
|
416
|
-
fields: [
|
|
417
|
-
{
|
|
418
|
-
...text("url", t("MCP 服务地址", "MCP server URL"), url),
|
|
419
|
-
hint: "https://"
|
|
420
|
-
},
|
|
421
|
-
text("id", t("名称(选填)", "Name (optional)"), name),
|
|
422
|
-
{
|
|
423
|
-
...text("token", t("Bearer 令牌(选填)", "Bearer token (optional)"), "", "secret"),
|
|
424
|
-
advanced: true
|
|
425
|
-
}
|
|
426
|
-
],
|
|
427
|
-
actions: [{
|
|
428
|
-
id: "create",
|
|
429
|
-
label: t("测试并连接", "Test and connect")
|
|
430
|
-
}]
|
|
431
|
-
});
|
|
432
|
-
if (flow) {
|
|
433
|
-
const complete = async () => {
|
|
434
|
-
const result = await withGatewayConfigWriteLock(service, () => drafts.commit(owner, flow, true)).catch((error) => {
|
|
435
|
-
if (error instanceof McpDraftError && error.status === 500) return void 0;
|
|
436
|
-
throw error;
|
|
437
|
-
});
|
|
438
|
-
if (!result) return {
|
|
439
|
-
flow,
|
|
440
|
-
message: t("验证通过,暂未保存连接。", "Verification passed. The connection could not be saved."),
|
|
441
|
-
actions: [{
|
|
442
|
-
id: "save",
|
|
443
|
-
label: t("重试保存", "Retry save")
|
|
444
|
-
}, {
|
|
445
|
-
id: "cancel",
|
|
446
|
-
label: t("取消连接", "Cancel connection")
|
|
447
|
-
}]
|
|
448
|
-
};
|
|
449
|
-
if (result.reloadRequired) return { message: t("连接已保存,重启网关后生效。", "Connection saved. Restart the Gateway to apply it.") };
|
|
450
|
-
return {
|
|
451
|
-
message: t("连接已添加", "Connection added"),
|
|
452
|
-
chatPrompt: useCapability(service.currentConfig.mcp?.servers?.[result.serverId]?.displayName ?? result.serverId, result.serverId, t)
|
|
453
|
-
};
|
|
454
|
-
};
|
|
455
|
-
if (command.action === "save") return complete();
|
|
456
|
-
if (command.action === "cancel") {
|
|
457
|
-
drafts.remove(owner, flow);
|
|
458
|
-
return connection(c, id, t);
|
|
459
|
-
}
|
|
460
|
-
let current;
|
|
461
|
-
switch (command.action) {
|
|
462
|
-
case "probe":
|
|
463
|
-
current = await drafts.probe(owner, flow);
|
|
464
|
-
break;
|
|
465
|
-
case "authorize":
|
|
466
|
-
current = drafts.authorize(owner, flow);
|
|
467
|
-
break;
|
|
468
|
-
case "callback":
|
|
469
|
-
drafts.redirect(owner, flow, z.url().max(8192).parse(command.values.callback));
|
|
470
|
-
current = drafts.authorization(owner, flow);
|
|
471
|
-
break;
|
|
472
|
-
case "status":
|
|
473
|
-
current = drafts.authorization(owner, flow);
|
|
474
|
-
break;
|
|
475
|
-
default: throw new McpDraftError(400, "Unknown connection action.");
|
|
476
|
-
}
|
|
477
|
-
if (current.state === "connected") return complete();
|
|
478
|
-
const authorizing = current.state === "authorizing" || current.state === "starting";
|
|
479
|
-
const canAuthorize = current.state === "oauth_required" || current.state === "auth_unknown" || current.state === "error" && command.action !== "probe";
|
|
480
|
-
if (!authorizing && !canAuthorize) {
|
|
481
|
-
const { url, id: name, token } = command.values;
|
|
482
|
-
drafts.remove(owner, flow);
|
|
483
|
-
return {
|
|
484
|
-
...form(url, name),
|
|
485
|
-
message: current.state === "token_required" || token ? t("连接验证失败。请检查服务地址、令牌和访问权限。", "Verification failed. Check the server URL, token and permissions.") : t("无法建立连接。请检查服务地址后重试。", "Could not connect. Check the server URL and try again.")
|
|
486
|
-
};
|
|
487
|
-
}
|
|
488
|
-
return {
|
|
489
|
-
flow,
|
|
490
|
-
message: authorizing ? t("请在服务商页面完成授权。返回后会自动添加。", "Finish signing in with the provider. The connection will be added automatically.") : current.state === "auth_unknown" ? t("此服务需要授权。可以尝试登录,或修改配置并填写服务商提供的令牌。", "This server requires authorization. Sign in or edit the connection to enter the provider’s token.") : current.state === "error" ? t("授权未完成。请重试或修改连接配置。", "Sign-in did not complete. Retry or edit the connection settings.") : t("此连接需要服务商授权。", "This connection needs provider authorization."),
|
|
491
|
-
authorizationUrl: authorizing ? safeLink(current.authorizationUrl) : void 0,
|
|
492
|
-
pollAction: authorizing ? "status" : void 0,
|
|
493
|
-
fields: authorizing && current.acceptsRedirect ? [{
|
|
494
|
-
...text("callback", t("浏览器最后打开的地址", "Address shown in your browser")),
|
|
495
|
-
hint: t("只有在授权未自动完成时才需要。", "Only needed if authorization does not finish automatically."),
|
|
496
|
-
advanced: true
|
|
497
|
-
}] : void 0,
|
|
498
|
-
actions: [
|
|
499
|
-
...!authorizing ? [{
|
|
500
|
-
id: "authorize",
|
|
501
|
-
label: t("连接账号", "Connect account")
|
|
502
|
-
}] : [],
|
|
503
|
-
...authorizing && current.acceptsRedirect ? [{
|
|
504
|
-
id: "callback",
|
|
505
|
-
label: t("完成授权", "Finish authorization"),
|
|
506
|
-
advanced: true
|
|
507
|
-
}] : [],
|
|
508
|
-
{
|
|
509
|
-
id: "cancel",
|
|
510
|
-
label: authorizing ? t("取消连接", "Cancel connection") : t("修改连接配置", "Edit connection settings")
|
|
511
|
-
}
|
|
512
|
-
]
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
if (command?.action === "create") {
|
|
516
|
-
const displayName = z.string().trim().max(64).parse(command.values.id ?? "");
|
|
517
|
-
const address = z.url().max(2048).safeParse(command.values.url?.trim());
|
|
518
|
-
if (!address.success) throw new McpDraftError(400, t("请输入完整的 HTTPS 地址。", "Enter the full HTTPS address."));
|
|
519
|
-
const url = new URL(address.data);
|
|
520
|
-
if (url.protocol !== "https:" || url.username || url.password || url.search || url.hash || !checkUrlSafety(url.href).safe) throw new McpDraftError(400, t("请输入不含账号或参数的公共 HTTPS 地址。", "Use a public HTTPS address without a username, password, or parameters."));
|
|
521
|
-
const token = command.values.token?.trim();
|
|
522
|
-
if (token && !/^[!-~]+$/.test(token)) throw new McpDraftError(400, t("请输入服务商提供的 Bearer 令牌。", "Enter the Bearer token provided by the service."));
|
|
523
|
-
const serverId = url.hostname.toLowerCase().replace(/[^a-z0-9-]/g, "-").slice(0, 42) + "-" + createHash("sha256").update(url.href).digest("hex").slice(0, 12);
|
|
524
|
-
return connection(c, id, t, {
|
|
525
|
-
action: "probe",
|
|
526
|
-
flow: (await drafts.create(owner, {
|
|
527
|
-
serverId,
|
|
528
|
-
server: {
|
|
529
|
-
type: "http",
|
|
530
|
-
url: url.href,
|
|
531
|
-
displayName: displayName || url.hostname,
|
|
532
|
-
xopcPublicOnly: true
|
|
533
|
-
}
|
|
534
|
-
}, token)).id,
|
|
535
|
-
values: command.values
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
return form();
|
|
539
|
-
}
|
|
424
|
+
if (id === "mcp:setup") return mobileMcpSetup(getGatewayPrincipal(c).principalId, t, command);
|
|
540
425
|
if (id.startsWith("mcp:")) {
|
|
541
426
|
const key = id === "mcp:server:setup" ? "setup" : id.slice(4);
|
|
542
427
|
const server = Object.hasOwn(service.currentConfig.mcp?.servers ?? {}, key) ? service.currentConfig.mcp?.servers?.[key] : void 0;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type McpConnectionDrafts } from '../../../agent/mcp/connection-drafts.js';
|
|
2
|
+
import type { Command, Panel, Translator } from './mobile-capability-panels.js';
|
|
3
|
+
type McpSetupHost = {
|
|
4
|
+
allowStdio: boolean;
|
|
5
|
+
workspace: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function createMobileMcpSetup(drafts: McpConnectionDrafts, readHost: () => McpSetupHost, publish: (owner: string, draftId: string, enable: boolean, stdio: boolean, t: Translator) => ReturnType<McpConnectionDrafts['commit']>): (owner: string, t: Translator, command?: Command) => Promise<Panel>;
|
|
8
|
+
export declare function assertMobileStdioAllowed(allowed: boolean, t: Translator): void;
|
|
9
|
+
export {};
|