@kerolt/pi-im 0.1.0 → 0.1.1
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
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { PiImPaths } from "../config/paths.js";
|
|
2
|
-
import type { Bot } from "../domain/bot.js";
|
|
3
|
-
export interface PersonaSwitchRequest {
|
|
4
|
-
paths: PiImPaths;
|
|
5
|
-
botId: string;
|
|
6
|
-
personaId: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* 把 Bot 的默认人格写进配置文件。先持久化再返回新 Bot,
|
|
10
|
-
* 调用方拿到结果后才更新内存状态,避免内存与文件不一致。
|
|
11
|
-
* 配置文件缺失或其中没有该 Bot 时直接报错,不凭内存快照补写。
|
|
12
|
-
*/
|
|
13
|
-
export declare function persistBotPersona(request: PersonaSwitchRequest): Promise<Bot>;
|
|
14
|
-
//# sourceMappingURL=persona-switch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"persona-switch.d.ts","sourceRoot":"","sources":["../../../src/core/gateway/persona-switch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAG5C,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,CAqBnF"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { readPiImConfigOrDefault, withImDirLock, writePiImConfigAtomic } from "../config/store.js";
|
|
2
|
-
import { GatewayError } from "./errors.js";
|
|
3
|
-
/**
|
|
4
|
-
* 把 Bot 的默认人格写进配置文件。先持久化再返回新 Bot,
|
|
5
|
-
* 调用方拿到结果后才更新内存状态,避免内存与文件不一致。
|
|
6
|
-
* 配置文件缺失或其中没有该 Bot 时直接报错,不凭内存快照补写。
|
|
7
|
-
*/
|
|
8
|
-
export async function persistBotPersona(request) {
|
|
9
|
-
const { paths, botId, personaId } = request;
|
|
10
|
-
return withImDirLock(paths.imDir, async () => {
|
|
11
|
-
const config = await readPiImConfigOrDefault(paths.configPath);
|
|
12
|
-
const index = config.bots.findIndex((bot) => bot.id === botId);
|
|
13
|
-
const current = index >= 0 ? config.bots[index] : undefined;
|
|
14
|
-
if (current === undefined) {
|
|
15
|
-
throw new GatewayError(`配置文件 ${paths.configPath} 中没有 Bot ${botId},请用 pi-im service restart 重启服务后再试`);
|
|
16
|
-
}
|
|
17
|
-
const updated = { ...current, personaId };
|
|
18
|
-
const bots = config.bots.map((bot, position) => (position === index ? updated : bot));
|
|
19
|
-
await writePiImConfigAtomic(paths.configPath, { ...config, bots });
|
|
20
|
-
return updated;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=persona-switch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"persona-switch.js","sourceRoot":"","sources":["../../../src/core/gateway/persona-switch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEnG,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAQ3C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAA6B;IACnE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAE5C,OAAO,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;QAC3C,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAAC,KAAK,CAAC,UAAU,CAAC,CAA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