linco-connect 1.1.8 → 1.1.9
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/README.md +2 -0
- package/package.json +1 -1
- package/src/agents/openclaw.js +5 -1
- package/src/slashCommands.js +67 -0
package/README.md
CHANGED
|
@@ -175,6 +175,8 @@ Agent 需要把文件发给用户时,可先执行 `/base` 查看当前会话
|
|
|
175
175
|
| `/cd <路径>` | 切换工作目录并开启新 Agent 会话 |
|
|
176
176
|
| `/new` | 开启新 Agent 会话,清除上下文 |
|
|
177
177
|
| `/stop` | 停止当前 Agent 进程,保留可恢复会话 ID |
|
|
178
|
+
| `/reload` | 刷新当前 Agent 记忆,下次消息重新加载本地历史;也可使用 `/refresh` |
|
|
179
|
+
| `/pc` | 显示 PC 端打开当前 Claude 会话的命令;目前仅支持 Claude |
|
|
178
180
|
| `/base` | 显示运行目录、附件目录和 outbox 目录 |
|
|
179
181
|
| `/list [条数]` | 列出当前 IM 会话下最近的 Agent Session 历史 |
|
|
180
182
|
| `/switch <序号或ID>` | 切换到指定 Agent Session,恢复上下文 |
|
package/package.json
CHANGED
package/src/agents/openclaw.js
CHANGED
|
@@ -108,7 +108,11 @@ async function runOpenClawTurn(input, ws, session, config) {
|
|
|
108
108
|
await done;
|
|
109
109
|
} catch (err) {
|
|
110
110
|
if (session.isTurnActive) {
|
|
111
|
-
if (!isClosedAbort(err))
|
|
111
|
+
if (!isClosedAbort(err)) {
|
|
112
|
+
const message = `OpenClaw error: ${err.message}`;
|
|
113
|
+
sendError(ws, message);
|
|
114
|
+
sendTurnEnd(ws, session, 'error', { error: message });
|
|
115
|
+
}
|
|
112
116
|
finishTurn(ws, session, config, { drain: !isClosedAbort(err) });
|
|
113
117
|
}
|
|
114
118
|
}
|
package/src/slashCommands.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const os = require('os');
|
|
2
3
|
const path = require('path');
|
|
3
4
|
const { resetOutgoingAttachments, startOutboxWatcher, stopOutboxWatcher } = require('./outgoingAttachmentHandler');
|
|
4
5
|
const { sendError, sendSystem, sendTurnEnd } = require('./protocol');
|
|
@@ -16,6 +17,8 @@ function localCommandsHelp() {
|
|
|
16
17
|
/cd - 列出当前目录内容
|
|
17
18
|
/new - 开启新 Agent 会话(清除上下文)
|
|
18
19
|
/stop - 停止当前 Agent 进程,保留可恢复会话 ID
|
|
20
|
+
/reload - 刷新当前 Agent 记忆,下次消息重新 resume
|
|
21
|
+
/pc - 显示 PC 端 Claude Code 打开当前会话的命令
|
|
19
22
|
/base - 显示 Linco 运行目录信息
|
|
20
23
|
/list [条数] - 列出当前 IM 会话下最近的 Agent Session 历史(默认 10 条)
|
|
21
24
|
/switch <序号> - 切换到指定 Agent Session(恢复上下文)
|
|
@@ -77,6 +80,15 @@ function handleSlashCommand(text, ws, session, config) {
|
|
|
77
80
|
sendSystem(ws, '⏹️ 已停止当前 Agent 进程,下次消息会尝试恢复当前会话。');
|
|
78
81
|
return completeLocalCommand(ws, session);
|
|
79
82
|
|
|
83
|
+
case '/reload':
|
|
84
|
+
case '/refresh':
|
|
85
|
+
handleReload(ws, session);
|
|
86
|
+
return completeLocalCommand(ws, session);
|
|
87
|
+
|
|
88
|
+
case '/pc':
|
|
89
|
+
handlePc(ws, session);
|
|
90
|
+
return completeLocalCommand(ws, session);
|
|
91
|
+
|
|
80
92
|
case '/base':
|
|
81
93
|
sendSystem(ws, `🗄️ Linco 运行信息:
|
|
82
94
|
当前工作目录: ${session.workspace}
|
|
@@ -149,6 +161,61 @@ function sendHermesWorkspaceNotice(ws) {
|
|
|
149
161
|
sendSystem(ws, 'Hermes 模式下工作目录由 Hermes Gateway/Agent 自身决定,/pwd 与 /cd 不在插件侧处理。');
|
|
150
162
|
}
|
|
151
163
|
|
|
164
|
+
function handleReload(ws, session) {
|
|
165
|
+
const agentType = session.agentType || 'claude';
|
|
166
|
+
const resumeId = session.agentSessionId || session.claudeSessionId || '';
|
|
167
|
+
stopAgentProcess(session, { clearAgentSession: false });
|
|
168
|
+
sendSystem(ws, [
|
|
169
|
+
`🔄 已刷新当前 ${agentType} 会话。`,
|
|
170
|
+
resumeId ? `保留的 Session ID: ${resumeId}` : '当前还没有可恢复的 Session ID。',
|
|
171
|
+
'下次消息会重新加载本地 Agent 历史。'
|
|
172
|
+
].join('\n'));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function handlePc(ws, session) {
|
|
176
|
+
const agentType = session.agentType || 'claude';
|
|
177
|
+
if (agentType !== 'claude') {
|
|
178
|
+
sendError(ws, '/pc 目前只支持 Claude 模式。');
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const resumeId = session.agentSessionId || session.claudeSessionId;
|
|
183
|
+
if (!resumeId) {
|
|
184
|
+
sendError(ws, '当前还没有 Claude Session ID。请先发送一条消息建立会话后再使用 /pc。');
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const transcriptPath = resolveClaudeTranscriptPath(session.workspace, resumeId);
|
|
189
|
+
const transcriptStatus = fs.existsSync(transcriptPath) ? 'Claude 历史文件' : 'Claude 历史文件(预计位置,当前未检测到)';
|
|
190
|
+
|
|
191
|
+
sendSystem(ws, [
|
|
192
|
+
'💻 PC 端可以用下面的命令打开当前 Claude 会话:',
|
|
193
|
+
'',
|
|
194
|
+
'```powershell',
|
|
195
|
+
`claude --resume ${resumeId}`,
|
|
196
|
+
'```',
|
|
197
|
+
'',
|
|
198
|
+
`工作目录: ${session.workspace}`,
|
|
199
|
+
`${transcriptStatus}: ${transcriptPath}`,
|
|
200
|
+
'',
|
|
201
|
+
'如果 PowerShell 提示 claude.ps1 被执行策略拦截,可以改用:',
|
|
202
|
+
`cmd /c claude --resume ${resumeId}`,
|
|
203
|
+
'',
|
|
204
|
+
'PC 端聊完后,回到 IM 发送 /reload,再继续提问。'
|
|
205
|
+
].join('\n'));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function resolveClaudeTranscriptPath(workspace, sessionId) {
|
|
209
|
+
const projectDir = encodeClaudeProjectDir(workspace || process.cwd());
|
|
210
|
+
return path.join(os.homedir(), '.claude', 'projects', projectDir, `${sessionId}.jsonl`);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function encodeClaudeProjectDir(workspace) {
|
|
214
|
+
return path.resolve(workspace)
|
|
215
|
+
.replace(/:/g, '-')
|
|
216
|
+
.replace(/[\\/]/g, '-');
|
|
217
|
+
}
|
|
218
|
+
|
|
152
219
|
function handleCd(targetPath, ws, session, config) {
|
|
153
220
|
if (!targetPath) {
|
|
154
221
|
try {
|