cicy-desktop 2.1.35 → 2.1.36
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/package.json +1 -1
- package/src/tools/chrome-tools.js +30 -12
package/package.json
CHANGED
|
@@ -97,10 +97,14 @@ function normalizePrivateChromeEntry(profileKey, accountIdx, entry) {
|
|
|
97
97
|
const port = typeof safeEntry.port === "number" ? safeEntry.port : null;
|
|
98
98
|
const proxyUrl = normalizePrivateProxy(safeEntry.proxy);
|
|
99
99
|
const platform = safeEntry.platform && typeof safeEntry.platform === "object" ? safeEntry.platform : {};
|
|
100
|
-
// Free-text
|
|
101
|
-
// `list profile with <svc>` — written via
|
|
100
|
+
// Free-text note + a service→account map (e.g. {github:"octocat",
|
|
101
|
+
// gmail:"me@gmail.com"}) for `list profile with <svc>` — written via
|
|
102
|
+
// chrome_set_profile_meta. Legacy array values normalize to {}.
|
|
102
103
|
const note = typeof safeEntry.note === "string" ? safeEntry.note : "";
|
|
103
|
-
const accounts =
|
|
104
|
+
const accounts =
|
|
105
|
+
safeEntry.accounts && typeof safeEntry.accounts === "object" && !Array.isArray(safeEntry.accounts)
|
|
106
|
+
? safeEntry.accounts
|
|
107
|
+
: {};
|
|
104
108
|
|
|
105
109
|
return {
|
|
106
110
|
profileKey,
|
|
@@ -662,11 +666,14 @@ function registerChromeTools(registerTool) {
|
|
|
662
666
|
|
|
663
667
|
registerTool(
|
|
664
668
|
"chrome_set_profile_meta",
|
|
665
|
-
"设置 ~/cicy-ai/db/chrome.json 中指定 accountIdx 的 note(备注)/ accounts
|
|
669
|
+
"设置 ~/cicy-ai/db/chrome.json 中指定 accountIdx 的 note(备注)/ accounts(服务→账号 map,用于 list profile with <svc>)",
|
|
666
670
|
z.object({
|
|
667
671
|
accountIdx: z.number().describe("账户索引"),
|
|
668
672
|
note: z.string().optional().describe("自由文本备注;省略则不动"),
|
|
669
|
-
accounts: z
|
|
673
|
+
accounts: z
|
|
674
|
+
.record(z.string())
|
|
675
|
+
.optional()
|
|
676
|
+
.describe("服务→账号 map,如 {github:'octocat',gmail:'me@gmail.com'};空值删除该服务;省略则整体不动;与现有合并"),
|
|
670
677
|
}),
|
|
671
678
|
async ({ accountIdx, note, accounts } = {}) => {
|
|
672
679
|
const data = readPrivateChromeConfig();
|
|
@@ -674,13 +681,24 @@ function registerChromeTools(registerTool) {
|
|
|
674
681
|
if (!data[key]) {
|
|
675
682
|
return toToolResult({ error: `Missing chrome.json entry: ${key}` }, { isError: true });
|
|
676
683
|
}
|
|
677
|
-
data[key]
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
+
const patch = { ...data[key], ...(note !== undefined ? { note: String(note) } : {}) };
|
|
685
|
+
if (accounts !== undefined) {
|
|
686
|
+
// Merge into the existing service→account map; empty value deletes a service.
|
|
687
|
+
const cur =
|
|
688
|
+
data[key].accounts && typeof data[key].accounts === "object" && !Array.isArray(data[key].accounts)
|
|
689
|
+
? data[key].accounts
|
|
690
|
+
: {};
|
|
691
|
+
const next = { ...cur };
|
|
692
|
+
for (const [k, v] of Object.entries(accounts)) {
|
|
693
|
+
const svc = String(k).trim().toLowerCase();
|
|
694
|
+
const val = String(v ?? "").trim();
|
|
695
|
+
if (!svc) continue;
|
|
696
|
+
if (val === "") delete next[svc];
|
|
697
|
+
else next[svc] = val;
|
|
698
|
+
}
|
|
699
|
+
patch.accounts = next;
|
|
700
|
+
}
|
|
701
|
+
data[key] = patch;
|
|
684
702
|
writePrivateChromeConfig(data);
|
|
685
703
|
return toToolResult({ success: true, profileKey: key, privateConfig: data[key] });
|
|
686
704
|
},
|