arona-agent 1.0.0

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.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +149 -0
  3. package/assets/blue-archive/arona/spine/arona_spr.atlas.txt +1168 -0
  4. package/assets/blue-archive/arona/spine/arona_spr.png +0 -0
  5. package/assets/blue-archive/arona/spine/arona_spr.skel +0 -0
  6. package/assets/blue-archive/arona/voice.mp3 +0 -0
  7. package/assets/blue-archive/hoshino/hoshino_spr.atlas.txt +174 -0
  8. package/assets/blue-archive/hoshino/hoshino_spr.json +15385 -0
  9. package/assets/blue-archive/hoshino/hoshino_spr.png +0 -0
  10. package/assets/blue-archive/hoshino/hoshino_spr.skel +0 -0
  11. package/assets/blue-archive/hoshino/robber/hoshino_robber_spr.atlas.txt +111 -0
  12. package/assets/blue-archive/hoshino/robber/hoshino_robber_spr.png +0 -0
  13. package/assets/blue-archive/hoshino/robber/hoshino_robber_spr.skel +0 -0
  14. package/assets/blue-archive/hoshino/swimsuit/hoshino_swimsuit_spr.atlas.txt +251 -0
  15. package/assets/blue-archive/hoshino/swimsuit/hoshino_swimsuit_spr.png +0 -0
  16. package/assets/blue-archive/hoshino/swimsuit/hoshino_swimsuit_spr.skel +0 -0
  17. package/assets/blue-archive/hoshino/voice.mp3 +0 -0
  18. package/assets/blue-archive/plana/spine/plana_spr.atlas.txt +1266 -0
  19. package/assets/blue-archive/plana/spine/plana_spr.png +0 -0
  20. package/assets/blue-archive/plana/spine/plana_spr.skel +0 -0
  21. package/assets/blue-archive/plana/voice.mp3 +0 -0
  22. package/assets/blue-archive/shiroko/ridingsuit/shiroko_ridingsuit_spr.atlas.txt +97 -0
  23. package/assets/blue-archive/shiroko/ridingsuit/shiroko_ridingsuit_spr.png +0 -0
  24. package/assets/blue-archive/shiroko/ridingsuit/shiroko_ridingsuit_spr.skel +0 -0
  25. package/assets/blue-archive/shiroko/robber/shiroko_robber_spr.atlas.txt +174 -0
  26. package/assets/blue-archive/shiroko/robber/shiroko_robber_spr.png +0 -0
  27. package/assets/blue-archive/shiroko/robber/shiroko_robber_spr.skel +0 -0
  28. package/assets/blue-archive/shiroko/shiroko_spr.atlas.txt +167 -0
  29. package/assets/blue-archive/shiroko/shiroko_spr.json +10702 -0
  30. package/assets/blue-archive/shiroko/shiroko_spr.png +0 -0
  31. package/assets/blue-archive/shiroko/shiroko_spr.skel +0 -0
  32. package/assets/blue-archive/shiroko/voice.mp3 +0 -0
  33. package/bin/arona.mjs +43 -0
  34. package/package.json +37 -0
  35. package/pet/agents.cjs +197 -0
  36. package/pet/main.cjs +462 -0
  37. package/pet/preload.cjs +21 -0
  38. package/pet/renderer/fx.html +30 -0
  39. package/pet/renderer/fx.js +41 -0
  40. package/pet/renderer/gallery.html +18 -0
  41. package/pet/renderer/gallery.js +31 -0
  42. package/pet/renderer/index.html +18 -0
  43. package/pet/renderer/renderer.js +382 -0
  44. package/pet/renderer/spine_layer.js +609 -0
  45. package/pet/renderer/spinetest.html +24 -0
  46. package/pet/renderer/spinetest.js +295 -0
  47. package/pet/renderer/style.css +63 -0
  48. package/pet/tools/gallery_capture.cjs +267 -0
  49. package/pet/tools/gen_sway.cjs +170 -0
  50. package/pet/tools/meshify_region.cjs +105 -0
  51. package/pet/tools/skel_inspect.cjs +112 -0
  52. package/pet/tools/skel_to_json.cjs +410 -0
  53. package/pet/tools/spine_node.cjs +69 -0
  54. package/pet/tools/visual_test.cjs +262 -0
  55. package/pet/vendor/spine/spine-canvas.js +8472 -0
  56. package/pet/vendor/spine/spine-webgl.js +10839 -0
  57. package/python/__pycache__/_i18n.cpython-313.pyc +0 -0
  58. package/python/__pycache__/_i18n.cpython-314.pyc +0 -0
  59. package/python/__pycache__/computer_use.cpython-314.pyc +0 -0
  60. package/python/__pycache__/hotkey.cpython-313.pyc +0 -0
  61. package/python/__pycache__/hotkey.cpython-314.pyc +0 -0
  62. package/python/__pycache__/stt.cpython-313.pyc +0 -0
  63. package/python/__pycache__/stt.cpython-314.pyc +0 -0
  64. package/python/__pycache__/tts.cpython-313.pyc +0 -0
  65. package/python/__pycache__/tts.cpython-314.pyc +0 -0
  66. package/python/__pycache__/tts_stream.cpython-313.pyc +0 -0
  67. package/python/__pycache__/tts_stream.cpython-314.pyc +0 -0
  68. package/python/__pycache__/voice_clone.cpython-314.pyc +0 -0
  69. package/python/_i18n.py +18 -0
  70. package/python/computer_use.py +190 -0
  71. package/python/hotkey.py +196 -0
  72. package/python/stt.py +240 -0
  73. package/python/tts_say.py +177 -0
  74. package/python/voice_clone.py +98 -0
  75. package/requirements.txt +6 -0
  76. package/src/agent.ts +791 -0
  77. package/src/agent_registry.ts +109 -0
  78. package/src/commands.ts +641 -0
  79. package/src/config.ts +245 -0
  80. package/src/in_memory_credentials.ts +61 -0
  81. package/src/index.ts +78 -0
  82. package/src/locale.ts +131 -0
  83. package/src/logo.ts +120 -0
  84. package/src/mcp.ts +192 -0
  85. package/src/memory.ts +303 -0
  86. package/src/pet.ts +346 -0
  87. package/src/renderer.ts +350 -0
  88. package/src/repl.ts +902 -0
  89. package/src/setup.ts +371 -0
  90. package/src/skills.ts +96 -0
  91. package/src/slash_menu.ts +371 -0
  92. package/src/slash_registry.ts +53 -0
  93. package/src/speaker_context.ts +41 -0
  94. package/src/text_split.ts +79 -0
  95. package/src/tools/computer_use.ts +142 -0
  96. package/src/tools/emotion_tool.ts +55 -0
  97. package/src/tools/keep_silent_tool.ts +26 -0
  98. package/src/tools/memory_tool.ts +24 -0
  99. package/src/tools/skill_tools.ts +100 -0
  100. package/src/tools/tavily_tools.ts +431 -0
  101. package/src/tools/voice_tools.ts +28 -0
  102. package/src/tts_stream.ts +260 -0
  103. package/src/tui_select.ts +146 -0
  104. package/src/undo.ts +451 -0
  105. package/src/utils/python.ts +211 -0
  106. package/src/utils/spawn.ts +56 -0
  107. package/src/voice.ts +83 -0
  108. package/src/voice_cli.ts +198 -0
  109. package/src/voices.ts +135 -0
@@ -0,0 +1,109 @@
1
+ // Agent 注册表:主 Agent + 子 Agent 的桌宠形象与人格。
2
+ // 主 Agent(arona | plana)由 /change-agent 单选,持久化到 settings.json#mainAgent。
3
+ // 子 Agent(shiroko | hoshino 及日后新增)由 /change-agent 多选,持久化到 settings.json#subAgents。
4
+ // 桌宠侧对应 pet/agents.cjs(ARONA_AGENT env 选主、ARONA_SUB_AGENTS env 选子窗口),
5
+ // 人格侧对应 agent.ts 的 buildPrompt* + initSubAgent。
6
+
7
+ import { existsSync, readFileSync, writeFileSync } from "fs";
8
+ import { SETTINGS_FILE } from "./config.ts";
9
+ import { t } from "./locale.ts";
10
+
11
+ export const MAIN_AGENT_IDS = ["arona", "plana"] as const;
12
+ export type MainAgentId = (typeof MAIN_AGENT_IDS)[number];
13
+
14
+ export const SUB_AGENT_IDS = ["shiroko", "hoshino"] as const;
15
+ export type SubAgentId = (typeof SUB_AGENT_IDS)[number];
16
+
17
+ export const AGENT_IDS = [...MAIN_AGENT_IDS, ...SUB_AGENT_IDS] as const;
18
+ export type AgentId = (typeof AGENT_IDS)[number];
19
+
20
+ /** 角色的中英双语显示名(供 TUI / 命令文案复用)。 */
21
+ export function getAgentLabel(id: AgentId): string {
22
+ switch (id) {
23
+ case "arona":
24
+ return t("阿洛娜", "Arona");
25
+ case "plana":
26
+ return t("普拉娜", "Plana");
27
+ case "shiroko":
28
+ return t("砂狼白子", "Shiroko");
29
+ case "hoshino":
30
+ return t("小鸟游星野", "Hoshino");
31
+ }
32
+ }
33
+
34
+ /** 校验 agent id(含类型收窄) */
35
+ export function isValidAgentId(id: string): id is AgentId {
36
+ return (AGENT_IDS as readonly string[]).includes(id);
37
+ }
38
+
39
+ /** 校验主 Agent id */
40
+ function isValidMainAgentId(id: string): id is MainAgentId {
41
+ return (MAIN_AGENT_IDS as readonly string[]).includes(id);
42
+ }
43
+
44
+ /** 校验子 Agent id */
45
+ function isValidSubAgentId(id: string): id is SubAgentId {
46
+ return (SUB_AGENT_IDS as readonly string[]).includes(id);
47
+ }
48
+
49
+ /** 当前主 Agent:读 settings.json 的 mainAgent 字段,非法/缺省回退 arona */
50
+ export function getMainAgent(): MainAgentId {
51
+ try {
52
+ if (existsSync(SETTINGS_FILE)) {
53
+ const s = JSON.parse(readFileSync(SETTINGS_FILE, "utf-8")) as { mainAgent?: unknown };
54
+ if (typeof s.mainAgent === "string" && isValidMainAgentId(s.mainAgent)) return s.mainAgent;
55
+ }
56
+ } catch {
57
+ // settings.json 损坏/不可读:回退默认
58
+ }
59
+ return "arona";
60
+ }
61
+
62
+ /** 当前启用的子 Agent 列表:读 settings.json 的 subAgents 数组,非法/缺省为空 */
63
+ export function getSubAgents(): SubAgentId[] {
64
+ try {
65
+ if (existsSync(SETTINGS_FILE)) {
66
+ const s = JSON.parse(readFileSync(SETTINGS_FILE, "utf-8")) as { subAgents?: unknown };
67
+ if (Array.isArray(s.subAgents)) {
68
+ const valid = s.subAgents.filter((x): x is SubAgentId => typeof x === "string" && isValidSubAgentId(x));
69
+ // 去重并按 SUB_AGENT_IDS 声明顺序排列,避免乱序导致子窗口位置漂移
70
+ return SUB_AGENT_IDS.filter((id) => valid.includes(id));
71
+ }
72
+ }
73
+ } catch {
74
+ // settings.json 损坏/不可读:返回空
75
+ }
76
+ return [];
77
+ }
78
+
79
+ /**
80
+ * 设置主 Agent 并写回 settings.json(read-modify-write,保留其它字段)。
81
+ */
82
+ export function setMainAgent(id: MainAgentId): void {
83
+ let settings: Record<string, unknown> = {};
84
+ try {
85
+ if (existsSync(SETTINGS_FILE)) {
86
+ settings = JSON.parse(readFileSync(SETTINGS_FILE, "utf-8")) as Record<string, unknown>;
87
+ }
88
+ } catch {
89
+ settings = {};
90
+ }
91
+ settings.mainAgent = id;
92
+ writeFileSync(SETTINGS_FILE, JSON.stringify(settings, null, 2) + "\n");
93
+ }
94
+
95
+ /**
96
+ * 设置启用的子 Agent 列表并写回 settings.json(read-modify-write,保留其它字段)。
97
+ */
98
+ export function setSubAgents(ids: readonly SubAgentId[]): void {
99
+ let settings: Record<string, unknown> = {};
100
+ try {
101
+ if (existsSync(SETTINGS_FILE)) {
102
+ settings = JSON.parse(readFileSync(SETTINGS_FILE, "utf-8")) as Record<string, unknown>;
103
+ }
104
+ } catch {
105
+ settings = {};
106
+ }
107
+ settings.subAgents = SUB_AGENT_IDS.filter((id) => (ids as readonly string[]).includes(id));
108
+ writeFileSync(SETTINGS_FILE, JSON.stringify(settings, null, 2) + "\n");
109
+ }