xiaozuoassistant 0.1.55 → 0.1.56

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.
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🍇</text></svg>" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>xiaozuoAssistant</title>
8
- <script type="module" crossorigin src="/assets/index-DKrBHrNq.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-DOFAvfov.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-DJdLRlkB.css">
10
10
  </head>
11
11
  <body>
@@ -43,7 +43,7 @@
43
43
  "title": "Settings",
44
44
  "tabs": {
45
45
  "general": "General",
46
- "systemPrompt": "System Prompt",
46
+ "identity": "Identity",
47
47
  "scheduler": "Memory & Scheduler"
48
48
  },
49
49
  "general": {
@@ -60,7 +60,10 @@
60
60
  "name": "Name",
61
61
  "role": "Role",
62
62
  "company": "Company",
63
- "email": "Email"
63
+ "email": "Email",
64
+ "promptTitle": "Base prompt",
65
+ "promptPlaceholder": "E.g. how the assistant should work, output format, constraints...",
66
+ "promptHint": "System prompt is composed from user identity + base prompt and is loaded before new sessions."
64
67
  },
65
68
  "prompt": {
66
69
  "description": "Define how xiaozuoAssistant behaves and responds.",
@@ -43,7 +43,7 @@
43
43
  "title": "设置",
44
44
  "tabs": {
45
45
  "general": "常规",
46
- "systemPrompt": "系统提示词",
46
+ "identity": "用户身份管理",
47
47
  "scheduler": "记忆与调度"
48
48
  },
49
49
  "general": {
@@ -60,7 +60,10 @@
60
60
  "name": "姓名",
61
61
  "role": "岗位",
62
62
  "company": "公司",
63
- "email": "邮箱"
63
+ "email": "邮箱",
64
+ "promptTitle": "基本提示信息",
65
+ "promptPlaceholder": "例如:你希望助手的工作方式、输出格式、约束规则...",
66
+ "promptHint": "系统提示词将由“用户身份 + 基本提示信息”自动组成,并在新会话中预先加载。"
64
67
  },
65
68
  "prompt": {
66
69
  "description": "定义 xiaozuoAssistant 的行为和响应方式。",
@@ -105,6 +105,38 @@ app.post('/api/sessions', async (req, res) => {
105
105
  res.status(500).json({ error: e.message });
106
106
  }
107
107
  });
108
+ // 追加一条消息到会话(用于欢迎语/系统消息等)
109
+ app.post('/api/sessions/:id/messages', async (req, res) => {
110
+ try {
111
+ const role = String(req.body?.role || '').trim();
112
+ const content = String(req.body?.content || '');
113
+ const timestamp = req.body?.timestamp;
114
+ const name = req.body?.name;
115
+ if (!['system', 'user', 'assistant', 'tool'].includes(role)) {
116
+ res.status(400).json({ error: 'Invalid role' });
117
+ return;
118
+ }
119
+ if (!content.trim()) {
120
+ res.status(400).json({ error: 'Content cannot be empty' });
121
+ return;
122
+ }
123
+ await memory.addMessage(req.params.id, {
124
+ role: role,
125
+ content,
126
+ ...(timestamp ? { timestamp: Number(timestamp) } : {}),
127
+ ...(name ? { name: String(name) } : {})
128
+ });
129
+ res.json({ status: 'success' });
130
+ }
131
+ catch (e) {
132
+ const msg = String(e?.message || 'Unknown error');
133
+ if (msg.toLowerCase().includes('not found')) {
134
+ res.status(404).json({ error: 'Session not found' });
135
+ return;
136
+ }
137
+ res.status(500).json({ error: msg });
138
+ }
139
+ });
108
140
  // 更新会话元信息
109
141
  app.patch('/api/sessions/:id', async (req, res) => {
110
142
  try {
@@ -207,27 +239,7 @@ app.post('/api/config', async (req, res) => {
207
239
  newConfig.systemPrompt = systemPrompt;
208
240
  if (workspace !== undefined)
209
241
  newConfig.workspace = workspace;
210
- // Handle System Prompt update logic
211
- // We only update systemPrompt automatically if workspace changed OR it's a new config
212
- // But if user manually edited systemPrompt in the same request, we should respect that?
213
- // The current frontend sends all fields.
214
- // If workspace changed, we append/update it.
215
- // Simplification: Always ensure the workspace is in the system prompt if configured.
216
- if (newConfig.workspace) {
217
- const workspaceLine = `Current Workspace: ${newConfig.workspace}`;
218
- // If system prompt doesn't have it, append it.
219
- if (!newConfig.systemPrompt) {
220
- newConfig.systemPrompt = workspaceLine;
221
- }
222
- else if (!newConfig.systemPrompt.includes('Current Workspace:')) {
223
- newConfig.systemPrompt += `\n${workspaceLine}`;
224
- }
225
- else {
226
- // It has it, let's update it to match new workspace
227
- // We use a regex to replace the line
228
- newConfig.systemPrompt = newConfig.systemPrompt.replace(/Current Workspace: .*/, workspaceLine);
229
- }
230
- }
242
+ // System prompt is fully controlled by the UI (identity + base prompt).
231
243
  let restartScheduler = false;
232
244
  if (memoryMaintenanceCron !== undefined) {
233
245
  if (!newConfig.scheduler)
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "xiaozuoassistant",
3
3
  "private": false,
4
4
  "description": "Your personal, locally-hosted AI assistant for office productivity.",
5
- "version": "0.1.55",
5
+ "version": "0.1.56",
6
6
  "author": "mantle.lau",
7
7
  "license": "MIT",
8
8
  "repository": {
@@ -43,7 +43,7 @@
43
43
  "title": "Settings",
44
44
  "tabs": {
45
45
  "general": "General",
46
- "systemPrompt": "System Prompt",
46
+ "identity": "Identity",
47
47
  "scheduler": "Memory & Scheduler"
48
48
  },
49
49
  "general": {
@@ -60,7 +60,10 @@
60
60
  "name": "Name",
61
61
  "role": "Role",
62
62
  "company": "Company",
63
- "email": "Email"
63
+ "email": "Email",
64
+ "promptTitle": "Base prompt",
65
+ "promptPlaceholder": "E.g. how the assistant should work, output format, constraints...",
66
+ "promptHint": "System prompt is composed from user identity + base prompt and is loaded before new sessions."
64
67
  },
65
68
  "prompt": {
66
69
  "description": "Define how xiaozuoAssistant behaves and responds.",
@@ -43,7 +43,7 @@
43
43
  "title": "设置",
44
44
  "tabs": {
45
45
  "general": "常规",
46
- "systemPrompt": "系统提示词",
46
+ "identity": "用户身份管理",
47
47
  "scheduler": "记忆与调度"
48
48
  },
49
49
  "general": {
@@ -60,7 +60,10 @@
60
60
  "name": "姓名",
61
61
  "role": "岗位",
62
62
  "company": "公司",
63
- "email": "邮箱"
63
+ "email": "邮箱",
64
+ "promptTitle": "基本提示信息",
65
+ "promptPlaceholder": "例如:你希望助手的工作方式、输出格式、约束规则...",
66
+ "promptHint": "系统提示词将由“用户身份 + 基本提示信息”自动组成,并在新会话中预先加载。"
64
67
  },
65
68
  "prompt": {
66
69
  "description": "定义 xiaozuoAssistant 的行为和响应方式。",