@openviking/openclaw-plugin 2026.6.2 → 2026.6.17-dev.2
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/INSTALL-AGENT.md +4 -4
- package/INSTALL-ZH.md +68 -8
- package/INSTALL.md +12 -8
- package/README.md +45 -35
- package/adapters/http-transport.ts +3 -0
- package/adapters/resource-packager.ts +141 -0
- package/auto-recall.ts +258 -27
- package/client.ts +201 -177
- package/commands/setup.ts +200 -33
- package/config/feature-gates.json +10 -0
- package/config.ts +428 -85
- package/context-engine.ts +71 -1402
- package/dist/adapters/http-transport.js +1 -0
- package/dist/adapters/resource-packager.js +114 -0
- package/dist/auto-recall.js +201 -25
- package/dist/client.js +125 -161
- package/dist/commands/setup.js +170 -32
- package/dist/config.js +285 -64
- package/dist/context-engine.js +62 -1173
- package/dist/index.js +209 -1489
- package/dist/memory-ranking.js +35 -12
- package/dist/plugin/command-registration.js +5 -0
- package/dist/plugin/openviking-archive-tools.js +210 -0
- package/dist/plugin/openviking-bypass-runtime.js +8 -0
- package/dist/plugin/openviking-client-runtime.js +28 -0
- package/dist/plugin/openviking-command-args.js +146 -0
- package/dist/plugin/openviking-command-definitions.js +206 -0
- package/dist/plugin/openviking-context-engine-ref.js +11 -0
- package/dist/plugin/openviking-context-engine-registration.js +23 -0
- package/dist/plugin/openviking-feature-gates.js +250 -0
- package/dist/plugin/openviking-import-runtime.js +50 -0
- package/dist/plugin/openviking-import-tools.js +86 -0
- package/dist/plugin/openviking-lifecycle-hooks.js +33 -0
- package/dist/plugin/openviking-memory-recall-tools.js +233 -0
- package/dist/plugin/openviking-memory-tools.js +199 -0
- package/dist/plugin/openviking-query-config-command.js +203 -0
- package/dist/plugin/openviking-query-runtime.js +367 -0
- package/dist/plugin/openviking-query-tools.js +91 -0
- package/dist/plugin/openviking-recall-trace-runtime.js +387 -0
- package/dist/plugin/openviking-recall-trace-tools.js +38 -0
- package/dist/plugin/openviking-runtime-state.js +26 -0
- package/dist/plugin/openviking-runtime-utils.js +62 -0
- package/dist/plugin/openviking-services.js +20 -0
- package/dist/plugin/openviking-session-routing-runtime.js +61 -0
- package/dist/plugin/openviking-tool-result-tools.js +268 -0
- package/dist/plugin/recall-trace-routes.js +77 -0
- package/dist/plugin/tool-registration.js +23 -0
- package/dist/process-manager.js +1 -1
- package/dist/query-config.js +336 -0
- package/dist/recall-trace.js +309 -0
- package/dist/registries/recall-resource-types.js +58 -0
- package/dist/routing/identity-routing.js +152 -0
- package/dist/routing/memory-uri.js +7 -0
- package/dist/services/context-lifecycle-service.js +847 -0
- package/dist/services/context-message-adapter.js +340 -0
- package/dist/session-transcript-repair.js +0 -1
- package/dist/text-utils.js +14 -31
- package/index.ts +271 -1873
- package/install-manifest.json +10 -1
- package/memory-ranking.ts +46 -10
- package/openclaw.plugin.json +198 -36
- package/package.json +14 -4
- package/plugin/command-registration.ts +34 -0
- package/plugin/openviking-archive-tools.ts +301 -0
- package/plugin/openviking-bypass-runtime.ts +26 -0
- package/plugin/openviking-client-runtime.ts +74 -0
- package/plugin/openviking-command-args.ts +187 -0
- package/plugin/openviking-command-definitions.ts +294 -0
- package/plugin/openviking-context-engine-ref.ts +16 -0
- package/plugin/openviking-context-engine-registration.ts +97 -0
- package/plugin/openviking-feature-gates.ts +335 -0
- package/plugin/openviking-import-runtime.ts +105 -0
- package/plugin/openviking-import-tools.ts +133 -0
- package/plugin/openviking-lifecycle-hooks.ts +65 -0
- package/plugin/openviking-memory-recall-tools.ts +368 -0
- package/plugin/openviking-memory-tools.ts +299 -0
- package/plugin/openviking-query-config-command.ts +230 -0
- package/plugin/openviking-query-formatters.ts +108 -0
- package/plugin/openviking-query-runtime.ts +476 -0
- package/plugin/openviking-query-tools.ts +161 -0
- package/plugin/openviking-recall-trace-runtime.ts +482 -0
- package/plugin/openviking-recall-trace-tools.ts +99 -0
- package/plugin/openviking-runtime-state.ts +52 -0
- package/plugin/openviking-runtime-utils.ts +67 -0
- package/plugin/openviking-services.ts +49 -0
- package/plugin/openviking-session-routing-runtime.ts +105 -0
- package/plugin/openviking-tool-result-tools.ts +397 -0
- package/plugin/recall-trace-routes.ts +133 -0
- package/plugin/tool-registration.ts +51 -0
- package/process-manager.ts +1 -1
- package/query-config.ts +400 -0
- package/recall-trace.ts +442 -0
- package/registries/openviking-tools.ts +84 -0
- package/registries/recall-resource-types.ts +74 -0
- package/routing/identity-routing.ts +210 -0
- package/routing/memory-uri.ts +8 -0
- package/services/context-lifecycle-service.ts +1209 -0
- package/services/context-message-adapter.ts +375 -0
- package/services/setup/config-writer.ts +125 -0
- package/services/setup/exit-utils.ts +5 -0
- package/services/setup/package-metadata.ts +56 -0
- package/services/setup/probe-service.ts +143 -0
- package/services/setup/setup-flow.ts +306 -0
- package/services/setup/version-compatibility.ts +41 -0
- package/session-transcript-repair.ts +0 -2
- package/skills/install-openviking-memory/SKILL.md +123 -50
- package/skills/openviking-context-database/SKILL.md +286 -0
- package/text-utils.ts +15 -34
package/dist/commands/setup.js
CHANGED
|
@@ -53,6 +53,29 @@ function readCompatRangeFromManifest() {
|
|
|
53
53
|
}
|
|
54
54
|
const PLUGIN_VERSION = readPluginVersion();
|
|
55
55
|
const { min: COMPATIBLE_SERVER_MIN, max: COMPATIBLE_SERVER_MAX } = readCompatRangeFromManifest();
|
|
56
|
+
const CONFIG_KEYS_TO_PRESERVE = [
|
|
57
|
+
"targetUri",
|
|
58
|
+
"timeoutMs",
|
|
59
|
+
"autoCapture",
|
|
60
|
+
"captureMode",
|
|
61
|
+
"captureMaxLength",
|
|
62
|
+
"autoRecall",
|
|
63
|
+
"recallResources",
|
|
64
|
+
"recallTargetTypes",
|
|
65
|
+
"recallLimit",
|
|
66
|
+
"recallScoreThreshold",
|
|
67
|
+
"recallMaxInjectedChars",
|
|
68
|
+
"recallMaxContentChars",
|
|
69
|
+
"recallPreferAbstract",
|
|
70
|
+
"recallTokenBudget",
|
|
71
|
+
"commitTokenThreshold",
|
|
72
|
+
"commitKeepRecentCount",
|
|
73
|
+
"bypassSessionPatterns",
|
|
74
|
+
"emitStandardDiagnostics",
|
|
75
|
+
"logFindRequests",
|
|
76
|
+
];
|
|
77
|
+
const DEFAULT_SETUP_PEER_ROLE = "assistant";
|
|
78
|
+
const ALLOWED_RECALL_TARGET_TYPES = ["resource", "user", "agent"];
|
|
56
79
|
function tr(langZh, en, zh) {
|
|
57
80
|
return langZh ? zh : en;
|
|
58
81
|
}
|
|
@@ -61,17 +84,103 @@ function maskKey(key) {
|
|
|
61
84
|
return "****";
|
|
62
85
|
return `${key.slice(0, 4)}...${key.slice(-4)}`;
|
|
63
86
|
}
|
|
64
|
-
function
|
|
87
|
+
function isValidPeerPrefixInput(value) {
|
|
65
88
|
const trimmed = value.trim();
|
|
66
89
|
return !trimmed || /^[a-zA-Z0-9_-]+$/.test(trimmed);
|
|
67
90
|
}
|
|
68
|
-
|
|
91
|
+
function normalizePeerRole(value) {
|
|
92
|
+
if (typeof value !== "string")
|
|
93
|
+
return undefined;
|
|
94
|
+
const role = value.trim().toLowerCase();
|
|
95
|
+
if (role === "none" || role === "assistant" || role === "person")
|
|
96
|
+
return role;
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
function resolveExistingPeerRole(existing) {
|
|
100
|
+
const explicit = normalizePeerRole(existing?.peer_role);
|
|
101
|
+
if (explicit)
|
|
102
|
+
return explicit;
|
|
103
|
+
return DEFAULT_SETUP_PEER_ROLE;
|
|
104
|
+
}
|
|
105
|
+
function resolveExistingPeerPrefix(existing) {
|
|
106
|
+
const value = existing?.peer_prefix;
|
|
107
|
+
if (typeof value !== "string" || !value.trim())
|
|
108
|
+
return "";
|
|
109
|
+
const trimmed = value.trim();
|
|
110
|
+
return trimmed === "default" ? "" : trimmed;
|
|
111
|
+
}
|
|
112
|
+
function resolveSetupPeerRole(value) {
|
|
113
|
+
if (value === undefined)
|
|
114
|
+
return DEFAULT_SETUP_PEER_ROLE;
|
|
115
|
+
const role = normalizePeerRole(value);
|
|
116
|
+
if (role)
|
|
117
|
+
return role;
|
|
118
|
+
throw new Error('peer_role must be "none", "assistant", or "person"');
|
|
119
|
+
}
|
|
120
|
+
function normalizeSetupRecallTargetTypes(value) {
|
|
121
|
+
if (value === undefined || value === null || value === "") {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
const entries = Array.isArray(value)
|
|
125
|
+
? value
|
|
126
|
+
: typeof value === "string"
|
|
127
|
+
? value.split(/[,\n]/)
|
|
128
|
+
: [];
|
|
129
|
+
const seen = new Set();
|
|
130
|
+
const normalized = [];
|
|
131
|
+
const unknown = [];
|
|
132
|
+
for (const raw of entries) {
|
|
133
|
+
if (typeof raw !== "string") {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const entry = raw.trim();
|
|
137
|
+
if (!entry) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (ALLOWED_RECALL_TARGET_TYPES.includes(entry)) {
|
|
141
|
+
const typed = entry;
|
|
142
|
+
if (!seen.has(typed)) {
|
|
143
|
+
seen.add(typed);
|
|
144
|
+
normalized.push(typed);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
unknown.push(entry);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (unknown.length > 0) {
|
|
152
|
+
throw new Error(`recall-target-types contains unknown resource types: ${unknown.join(", ")}`);
|
|
153
|
+
}
|
|
154
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
155
|
+
}
|
|
156
|
+
function preserveCurrentConfig(existing) {
|
|
157
|
+
const config = {};
|
|
158
|
+
if (!existing) {
|
|
159
|
+
return config;
|
|
160
|
+
}
|
|
161
|
+
for (const key of CONFIG_KEYS_TO_PRESERVE) {
|
|
162
|
+
if (key in existing) {
|
|
163
|
+
config[key] = existing[key];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return config;
|
|
167
|
+
}
|
|
168
|
+
async function askPeerRole(zh, q, defaultValue) {
|
|
69
169
|
while (true) {
|
|
70
|
-
const value =
|
|
71
|
-
|
|
170
|
+
const value = await q(tr(zh, "Peer Role (none/assistant/person)", "Peer Role(none/assistant/person)"), defaultValue);
|
|
171
|
+
const role = normalizePeerRole(value);
|
|
172
|
+
if (role)
|
|
173
|
+
return role;
|
|
174
|
+
console.log(` ✗ ${tr(zh, 'Peer Role must be "none", "assistant", or "person".', 'Peer Role 必须是 "none"、"assistant" 或 "person"。')}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async function askPeerPrefix(zh, q, defaultValue) {
|
|
178
|
+
while (true) {
|
|
179
|
+
const value = (await q(tr(zh, "Peer Prefix (optional)", "Peer Prefix(可选)"), defaultValue)).trim();
|
|
180
|
+
if (isValidPeerPrefixInput(value)) {
|
|
72
181
|
return value;
|
|
73
182
|
}
|
|
74
|
-
console.log(` ✗ ${tr(zh, "
|
|
183
|
+
console.log(` ✗ ${tr(zh, "Peer Prefix may only contain letters, digits, underscores, and hyphens, or be empty.", "Peer Prefix 只能包含字母、数字、下划线和连字符,或留空。")}`);
|
|
75
184
|
}
|
|
76
185
|
}
|
|
77
186
|
function ask(rl, prompt, defaultValue = "") {
|
|
@@ -351,15 +460,17 @@ export function registerSetupCli(api) {
|
|
|
351
460
|
.option("--zh", "Chinese prompts")
|
|
352
461
|
.option("--base-url <url>", "OpenViking server URL (enables non-interactive mode)")
|
|
353
462
|
.option("--api-key <key>", "API key for authentication")
|
|
354
|
-
.option("--
|
|
463
|
+
.option("--peer-role <role>", "Peer ID role: none, assistant, or person")
|
|
464
|
+
.option("--peer-prefix <prefix>", "Prefix for assistant peer_id values")
|
|
355
465
|
.option("--account-id <id>", "Account ID (required for root API keys)")
|
|
356
466
|
.option("--user-id <id>", "User ID (required for root API keys)")
|
|
467
|
+
.option("--recall-target-types <types>", "Comma-separated recall target types: user, agent, resource")
|
|
357
468
|
.option("--allow-offline", "Allow config write even if server is unreachable")
|
|
358
469
|
.option("--force-slot", "Replace existing contextEngine slot even if owned by another plugin")
|
|
359
470
|
.option("--json", "Output result as JSON (machine-readable)")
|
|
360
471
|
.action(async (...args) => {
|
|
361
472
|
const options = (args[0] ?? {});
|
|
362
|
-
const { reconfigure, zh: zhOpt, baseUrl, apiKey,
|
|
473
|
+
const { reconfigure, zh: zhOpt, baseUrl, apiKey, peerRole, peerPrefix, accountId, userId, recallTargetTypes, allowOffline, forceSlot, json: jsonOpt, } = options;
|
|
363
474
|
const zh = detectLangZh(options);
|
|
364
475
|
const configPath = path.join(OPENCLAW_DIR, "openclaw.json");
|
|
365
476
|
const jsonMode = !!jsonOpt;
|
|
@@ -368,9 +479,11 @@ export function registerSetupCli(api) {
|
|
|
368
479
|
const result = await setupNonInteractive(configPath, {
|
|
369
480
|
baseUrl: baseUrl,
|
|
370
481
|
apiKey,
|
|
371
|
-
|
|
482
|
+
peerRole,
|
|
483
|
+
peerPrefix,
|
|
372
484
|
accountId,
|
|
373
485
|
userId,
|
|
486
|
+
recallTargetTypes: normalizeSetupRecallTargetTypes(recallTargetTypes),
|
|
374
487
|
allowOffline: !!allowOffline,
|
|
375
488
|
forceSlot: !!forceSlot,
|
|
376
489
|
});
|
|
@@ -414,8 +527,10 @@ export function registerSetupCli(api) {
|
|
|
414
527
|
console.log(` baseUrl: ${existing.baseUrl ?? DEFAULT_REMOTE_URL}`);
|
|
415
528
|
if (existing.apiKey)
|
|
416
529
|
console.log(` apiKey: ${maskKey(String(existing.apiKey))}`);
|
|
417
|
-
|
|
418
|
-
|
|
530
|
+
console.log(` peer_role: ${resolveExistingPeerRole(existing)}`);
|
|
531
|
+
const existingPeerPrefix = resolveExistingPeerPrefix(existing);
|
|
532
|
+
if (existingPeerPrefix)
|
|
533
|
+
console.log(` peer_prefix: ${existingPeerPrefix}`);
|
|
419
534
|
console.log("");
|
|
420
535
|
console.log(tr(zh, "Press Enter to keep existing values, or use --reconfigure to change.", "按 Enter 保留现有配置,或使用 --reconfigure 重新配置。"));
|
|
421
536
|
console.log("");
|
|
@@ -501,7 +616,12 @@ async function runRemoteCheck(zh, existing) {
|
|
|
501
616
|
}
|
|
502
617
|
async function setupNonInteractive(configPath, params) {
|
|
503
618
|
try {
|
|
504
|
-
const { baseUrl, apiKey,
|
|
619
|
+
const { baseUrl, apiKey, peerPrefix, accountId, userId, recallTargetTypes, allowOffline, forceSlot } = params;
|
|
620
|
+
const resolvedPeerRole = resolveSetupPeerRole(params.peerRole);
|
|
621
|
+
const resolvedPeerPrefix = (peerPrefix ?? "").trim();
|
|
622
|
+
if (!isValidPeerPrefixInput(resolvedPeerPrefix)) {
|
|
623
|
+
throw new Error("peer_prefix may only contain letters, digits, underscores, and hyphens, or be empty");
|
|
624
|
+
}
|
|
505
625
|
// Phase 1: validate connectivity and key type BEFORE writing config
|
|
506
626
|
const health = await checkServiceHealth(baseUrl, apiKey);
|
|
507
627
|
if (!health.ok && !allowOffline) {
|
|
@@ -539,12 +659,16 @@ async function setupNonInteractive(configPath, params) {
|
|
|
539
659
|
const pluginCfg = { mode: "remote", baseUrl };
|
|
540
660
|
if (apiKey)
|
|
541
661
|
pluginCfg.apiKey = apiKey;
|
|
542
|
-
|
|
543
|
-
|
|
662
|
+
pluginCfg.peer_role = resolvedPeerRole;
|
|
663
|
+
if (resolvedPeerPrefix)
|
|
664
|
+
pluginCfg.peer_prefix = resolvedPeerPrefix;
|
|
544
665
|
if (accountId)
|
|
545
666
|
pluginCfg.accountId = accountId;
|
|
546
667
|
if (userId)
|
|
547
668
|
pluginCfg.userId = userId;
|
|
669
|
+
if (recallTargetTypes && recallTargetTypes.length > 0) {
|
|
670
|
+
pluginCfg.recallTargetTypes = recallTargetTypes;
|
|
671
|
+
}
|
|
548
672
|
writeConfig(configPath, pluginCfg);
|
|
549
673
|
const slot = activateContextEngineSlot(configPath, !!forceSlot);
|
|
550
674
|
if (!slot.activated && slot.previousOwner) {
|
|
@@ -555,9 +679,11 @@ async function setupNonInteractive(configPath, params) {
|
|
|
555
679
|
mode: "remote",
|
|
556
680
|
baseUrl,
|
|
557
681
|
...(apiKey ? { apiKey: maskKey(apiKey) } : {}),
|
|
558
|
-
|
|
682
|
+
peer_role: resolvedPeerRole,
|
|
683
|
+
...(resolvedPeerPrefix ? { peer_prefix: resolvedPeerPrefix } : {}),
|
|
559
684
|
...(accountId ? { accountId } : {}),
|
|
560
685
|
...(userId ? { userId } : {}),
|
|
686
|
+
...(recallTargetTypes && recallTargetTypes.length > 0 ? { recallTargetTypes } : {}),
|
|
561
687
|
},
|
|
562
688
|
health,
|
|
563
689
|
keyProbe,
|
|
@@ -572,9 +698,11 @@ async function setupNonInteractive(configPath, params) {
|
|
|
572
698
|
mode: "remote",
|
|
573
699
|
baseUrl,
|
|
574
700
|
...(apiKey ? { apiKey: maskKey(apiKey) } : {}),
|
|
575
|
-
|
|
701
|
+
peer_role: resolvedPeerRole,
|
|
702
|
+
...(resolvedPeerPrefix ? { peer_prefix: resolvedPeerPrefix } : {}),
|
|
576
703
|
...(accountId ? { accountId } : {}),
|
|
577
704
|
...(userId ? { userId } : {}),
|
|
705
|
+
...(recallTargetTypes && recallTargetTypes.length > 0 ? { recallTargetTypes } : {}),
|
|
578
706
|
},
|
|
579
707
|
health,
|
|
580
708
|
keyProbe,
|
|
@@ -600,12 +728,15 @@ function printSetupResult(zh, result) {
|
|
|
600
728
|
console.log(` baseUrl: ${result.config.baseUrl}`);
|
|
601
729
|
if (result.config.apiKey)
|
|
602
730
|
console.log(` apiKey: ${result.config.apiKey}`);
|
|
603
|
-
|
|
604
|
-
|
|
731
|
+
console.log(` peer_role: ${result.config.peer_role ?? DEFAULT_SETUP_PEER_ROLE}`);
|
|
732
|
+
if (result.config.peer_prefix)
|
|
733
|
+
console.log(` peer_prefix: ${result.config.peer_prefix}`);
|
|
605
734
|
if (result.config.accountId)
|
|
606
735
|
console.log(` accountId: ${result.config.accountId}`);
|
|
607
736
|
if (result.config.userId)
|
|
608
737
|
console.log(` userId: ${result.config.userId}`);
|
|
738
|
+
if (result.config.recallTargetTypes)
|
|
739
|
+
console.log(` recallTargetTypes: ${result.config.recallTargetTypes.join(",")}`);
|
|
609
740
|
}
|
|
610
741
|
console.log("");
|
|
611
742
|
if (result.health?.ok) {
|
|
@@ -642,14 +773,15 @@ async function getStatus(configPath) {
|
|
|
642
773
|
const apiKey = existing.apiKey ? String(existing.apiKey) : undefined;
|
|
643
774
|
const health = await checkServiceHealth(baseUrl, apiKey);
|
|
644
775
|
const keyProbe = health.ok ? await probeApiKeyType(baseUrl, apiKey) : undefined;
|
|
645
|
-
const
|
|
776
|
+
const peerPrefix = resolveExistingPeerPrefix(existing);
|
|
646
777
|
return {
|
|
647
778
|
configured: true,
|
|
648
779
|
config: {
|
|
649
780
|
mode: String(existing.mode ?? "remote"),
|
|
650
781
|
baseUrl,
|
|
651
782
|
hasApiKey: !!existing.apiKey,
|
|
652
|
-
|
|
783
|
+
peer_role: resolveExistingPeerRole(existing),
|
|
784
|
+
...(peerPrefix ? { peer_prefix: peerPrefix } : {}),
|
|
653
785
|
hasAccountId: !!existing.accountId,
|
|
654
786
|
hasUserId: !!existing.userId,
|
|
655
787
|
},
|
|
@@ -695,8 +827,9 @@ function printStatus(zh, result) {
|
|
|
695
827
|
console.log(` mode: ${result.config.mode}`);
|
|
696
828
|
console.log(` baseUrl: ${result.config.baseUrl}`);
|
|
697
829
|
console.log(` apiKey: ${result.config.hasApiKey ? "set" : "not set"}`);
|
|
698
|
-
|
|
699
|
-
|
|
830
|
+
console.log(` peer_role: ${result.config.peer_role}`);
|
|
831
|
+
if (result.config.peer_prefix)
|
|
832
|
+
console.log(` peer_prefix: ${result.config.peer_prefix}`);
|
|
700
833
|
console.log(` accountId: ${result.config.hasAccountId ? "set" : "not set"}`);
|
|
701
834
|
console.log(` userId: ${result.config.hasUserId ? "set" : "not set"}`);
|
|
702
835
|
}
|
|
@@ -723,7 +856,8 @@ async function setupRemote(zh, configPath, existing, q) {
|
|
|
723
856
|
? String(existing.baseUrl)
|
|
724
857
|
: DEFAULT_REMOTE_URL;
|
|
725
858
|
const defaultApiKey = existing?.apiKey ? String(existing.apiKey) : "";
|
|
726
|
-
const
|
|
859
|
+
const defaultPeerRole = resolveExistingPeerRole(existing);
|
|
860
|
+
const defaultPeerPrefix = resolveExistingPeerPrefix(existing);
|
|
727
861
|
const baseUrl = await q(tr(zh, "OpenViking server URL", "OpenViking 服务器地址"), defaultUrl);
|
|
728
862
|
const apiKey = await q(tr(zh, "API Key (optional)", "API Key(可选)"), defaultApiKey);
|
|
729
863
|
let accountId = existing?.accountId ? String(existing.accountId) : "";
|
|
@@ -740,7 +874,10 @@ async function setupRemote(zh, configPath, existing, q) {
|
|
|
740
874
|
console.log(tr(zh, " ✓ User key verified", " ✓ User key 已验证"));
|
|
741
875
|
}
|
|
742
876
|
}
|
|
743
|
-
const
|
|
877
|
+
const peerRole = await askPeerRole(zh, q, defaultPeerRole);
|
|
878
|
+
const peerPrefix = peerRole === "assistant"
|
|
879
|
+
? await askPeerPrefix(zh, q, defaultPeerPrefix)
|
|
880
|
+
: "";
|
|
744
881
|
console.log("");
|
|
745
882
|
console.log(tr(zh, `Testing connectivity to ${baseUrl}...`, `正在测试连接 ${baseUrl}...`));
|
|
746
883
|
const health = await checkServiceHealth(baseUrl, apiKey || undefined);
|
|
@@ -756,7 +893,7 @@ async function setupRemote(zh, configPath, existing, q) {
|
|
|
756
893
|
}
|
|
757
894
|
console.log("");
|
|
758
895
|
const pluginCfg = {
|
|
759
|
-
...(existing
|
|
896
|
+
...preserveCurrentConfig(existing),
|
|
760
897
|
mode: "remote",
|
|
761
898
|
baseUrl,
|
|
762
899
|
};
|
|
@@ -764,10 +901,11 @@ async function setupRemote(zh, configPath, existing, q) {
|
|
|
764
901
|
pluginCfg.apiKey = apiKey;
|
|
765
902
|
else
|
|
766
903
|
delete pluginCfg.apiKey;
|
|
767
|
-
|
|
768
|
-
|
|
904
|
+
pluginCfg.peer_role = peerRole;
|
|
905
|
+
if (peerPrefix)
|
|
906
|
+
pluginCfg.peer_prefix = peerPrefix;
|
|
769
907
|
else
|
|
770
|
-
delete pluginCfg.
|
|
908
|
+
delete pluginCfg.peer_prefix;
|
|
771
909
|
if (accountId)
|
|
772
910
|
pluginCfg.accountId = accountId;
|
|
773
911
|
else
|
|
@@ -776,8 +914,6 @@ async function setupRemote(zh, configPath, existing, q) {
|
|
|
776
914
|
pluginCfg.userId = userId;
|
|
777
915
|
else
|
|
778
916
|
delete pluginCfg.userId;
|
|
779
|
-
delete pluginCfg.configPath;
|
|
780
|
-
delete pluginCfg.port;
|
|
781
917
|
writeConfig(configPath, pluginCfg);
|
|
782
918
|
const slotResult = activateContextEngineSlot(configPath);
|
|
783
919
|
console.log("");
|
|
@@ -785,8 +921,9 @@ async function setupRemote(zh, configPath, existing, q) {
|
|
|
785
921
|
console.log(` baseUrl: ${baseUrl}`);
|
|
786
922
|
if (apiKey)
|
|
787
923
|
console.log(` apiKey: ${maskKey(apiKey)}`);
|
|
788
|
-
|
|
789
|
-
|
|
924
|
+
console.log(` peer_role: ${peerRole}`);
|
|
925
|
+
if (peerPrefix)
|
|
926
|
+
console.log(` peer_prefix: ${peerPrefix}`);
|
|
790
927
|
if (accountId)
|
|
791
928
|
console.log(` accountId: ${accountId}`);
|
|
792
929
|
if (userId)
|
|
@@ -798,7 +935,8 @@ async function setupRemote(zh, configPath, existing, q) {
|
|
|
798
935
|
}
|
|
799
936
|
export const __test__ = {
|
|
800
937
|
isLegacyLocalMode,
|
|
801
|
-
|
|
938
|
+
isValidPeerPrefixInput,
|
|
939
|
+
normalizeSetupRecallTargetTypes,
|
|
802
940
|
activateContextEngineSlot,
|
|
803
941
|
isContextEngineSlotActive,
|
|
804
942
|
getStatus,
|