wave-code 0.19.4 → 0.19.6
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/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/components/App.d.ts.map +1 -1
- package/dist/components/App.js +5 -5
- package/dist/contexts/useChat.d.ts.map +1 -1
- package/dist/contexts/useChat.js +16 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -10
- package/dist/print-cli.d.ts.map +1 -1
- package/dist/print-cli.js +15 -1
- package/dist/stdio/agentBridge.d.ts +2 -0
- package/dist/stdio/agentBridge.d.ts.map +1 -1
- package/dist/stdio/agentBridge.js +28 -1
- package/dist/stdio/protocol.d.ts +2 -2
- package/dist/stdio/protocol.d.ts.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/cli.tsx +2 -0
- package/src/components/App.tsx +5 -0
- package/src/contexts/useChat.tsx +18 -0
- package/src/index.ts +7 -15
- package/src/print-cli.ts +17 -0
- package/src/stdio/agentBridge.ts +46 -2
- package/src/stdio/protocol.ts +5 -1
- package/src/types.ts +2 -0
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,wBAAsB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,wBAAsB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAoEjE"}
|
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import { App } from "./components/App.js";
|
|
|
4
4
|
import { cleanupLogs } from "./utils/logger.js";
|
|
5
5
|
import { removeWorktree } from "./utils/worktree.js";
|
|
6
6
|
export async function startCli(options) {
|
|
7
|
-
const { restoreSessionId, continueLastSession, bypassPermissions, permissionMode, pluginDirs, tools, allowedTools, disallowedTools, worktreeSession, workdir, version, model, mcpServers, } = options;
|
|
7
|
+
const { restoreSessionId, continueLastSession, bypassPermissions, permissionMode, pluginDirs, tools, allowedTools, disallowedTools, worktreeSession, workdir, originalCwd, version, model, mcpServers, } = options;
|
|
8
8
|
// Continue with ink-based UI for normal mode
|
|
9
9
|
let shouldRemoveWorktree = false;
|
|
10
10
|
const handleExit = (shouldRemove) => {
|
|
@@ -12,7 +12,7 @@ export async function startCli(options) {
|
|
|
12
12
|
unmount();
|
|
13
13
|
};
|
|
14
14
|
// Render the application
|
|
15
|
-
const { unmount, waitUntilExit } = render(_jsx(App, { restoreSessionId: restoreSessionId, continueLastSession: continueLastSession, bypassPermissions: bypassPermissions, permissionMode: permissionMode, pluginDirs: pluginDirs, tools: tools, allowedTools: allowedTools, disallowedTools: disallowedTools, worktreeSession: worktreeSession, workdir: workdir, version: version, model: model, mcpServers: mcpServers, onExit: handleExit }), { exitOnCtrlC: false });
|
|
15
|
+
const { unmount, waitUntilExit } = render(_jsx(App, { restoreSessionId: restoreSessionId, continueLastSession: continueLastSession, bypassPermissions: bypassPermissions, permissionMode: permissionMode, pluginDirs: pluginDirs, tools: tools, allowedTools: allowedTools, disallowedTools: disallowedTools, worktreeSession: worktreeSession, workdir: workdir, originalCwd: originalCwd, version: version, model: model, mcpServers: mcpServers, onExit: handleExit }), { exitOnCtrlC: false });
|
|
16
16
|
// Wait for the app to finish unmounting
|
|
17
17
|
await waitUntilExit();
|
|
18
18
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/components/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAWhE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,UAAU,QAAS,SAAQ,YAAY;IACrC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,MAAM,EAAE,CAAC,YAAY,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC;
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/components/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAWhE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,UAAU,QAAS,SAAQ,YAAY;IACrC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,MAAM,EAAE,CAAC,YAAY,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC;AA2ID,eAAO,MAAM,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAuClC,CAAC"}
|
package/dist/components/App.js
CHANGED
|
@@ -50,7 +50,7 @@ const ChatWithExitPrompt = ({ worktreeSession, onExit }) => {
|
|
|
50
50
|
}
|
|
51
51
|
return _jsx(ChatInterface, {});
|
|
52
52
|
};
|
|
53
|
-
const AppWithProviders = ({ bypassPermissions, permissionMode, pluginDirs, tools, allowedTools, disallowedTools, worktreeSession, workdir, version, model, mcpServers, onExit, }) => {
|
|
53
|
+
const AppWithProviders = ({ bypassPermissions, permissionMode, pluginDirs, tools, allowedTools, disallowedTools, worktreeSession, workdir, originalCwd, version, model, mcpServers, onExit, }) => {
|
|
54
54
|
// Handle Ctrl-C for non-worktree sessions (immediate exit)
|
|
55
55
|
// Ink runs terminal in raw mode, so Ctrl+C arrives as useInput event, not SIGINT
|
|
56
56
|
useInput((input, key) => {
|
|
@@ -60,10 +60,10 @@ const AppWithProviders = ({ bypassPermissions, permissionMode, pluginDirs, tools
|
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
if (worktreeSession) {
|
|
63
|
-
return (_jsx(ChatProvider, { bypassPermissions: bypassPermissions, permissionMode: permissionMode, pluginDirs: pluginDirs, tools: tools, allowedTools: allowedTools, disallowedTools: disallowedTools, workdir: workdir, worktreeSession: worktreeSession, version: version, model: model, mcpServers: mcpServers, children: _jsx(ChatWithExitPrompt, { worktreeSession: worktreeSession, onExit: onExit }) }));
|
|
63
|
+
return (_jsx(ChatProvider, { bypassPermissions: bypassPermissions, permissionMode: permissionMode, pluginDirs: pluginDirs, tools: tools, allowedTools: allowedTools, disallowedTools: disallowedTools, workdir: workdir, worktreeSession: worktreeSession, originalCwd: originalCwd, version: version, model: model, mcpServers: mcpServers, children: _jsx(ChatWithExitPrompt, { worktreeSession: worktreeSession, onExit: onExit }) }));
|
|
64
64
|
}
|
|
65
|
-
return (_jsx(ChatProvider, { bypassPermissions: bypassPermissions, permissionMode: permissionMode, pluginDirs: pluginDirs, tools: tools, allowedTools: allowedTools, disallowedTools: disallowedTools, workdir: workdir, worktreeSession: worktreeSession, version: version, model: model, mcpServers: mcpServers, children: _jsx(ChatInterface, {}) }));
|
|
65
|
+
return (_jsx(ChatProvider, { bypassPermissions: bypassPermissions, permissionMode: permissionMode, pluginDirs: pluginDirs, tools: tools, allowedTools: allowedTools, disallowedTools: disallowedTools, workdir: workdir, worktreeSession: worktreeSession, originalCwd: originalCwd, version: version, model: model, mcpServers: mcpServers, children: _jsx(ChatInterface, {}) }));
|
|
66
66
|
};
|
|
67
|
-
export const App = ({ restoreSessionId, continueLastSession, bypassPermissions, permissionMode, pluginDirs, tools, allowedTools, disallowedTools, worktreeSession, workdir, version, model, mcpServers, onExit, }) => {
|
|
68
|
-
return (_jsx(AppProvider, { restoreSessionId: restoreSessionId, continueLastSession: continueLastSession, children: _jsx(AppWithProviders, { bypassPermissions: bypassPermissions, permissionMode: permissionMode, pluginDirs: pluginDirs, tools: tools, allowedTools: allowedTools, disallowedTools: disallowedTools, worktreeSession: worktreeSession, workdir: workdir, version: version, model: model, mcpServers: mcpServers, onExit: onExit }) }));
|
|
67
|
+
export const App = ({ restoreSessionId, continueLastSession, bypassPermissions, permissionMode, pluginDirs, tools, allowedTools, disallowedTools, worktreeSession, workdir, originalCwd, version, model, mcpServers, onExit, }) => {
|
|
68
|
+
return (_jsx(AppProvider, { restoreSessionId: restoreSessionId, continueLastSession: continueLastSession, children: _jsx(AppWithProviders, { bypassPermissions: bypassPermissions, permissionMode: permissionMode, pluginDirs: pluginDirs, tools: tools, allowedTools: allowedTools, disallowedTools: disallowedTools, worktreeSession: worktreeSession, workdir: workdir, originalCwd: originalCwd, version: version, model: model, mcpServers: mcpServers, onExit: onExit }) }));
|
|
69
69
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChat.d.ts","sourceRoot":"","sources":["../../src/contexts/useChat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAQN,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EACV,OAAO,EACP,eAAe,EACf,cAAc,EACd,IAAI,EACJ,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,WAAW,EACZ,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"useChat.d.ts","sourceRoot":"","sources":["../../src/contexts/useChat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAQN,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EACV,OAAO,EACP,eAAe,EACf,cAAc,EACd,IAAI,EACJ,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd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CAAC;AAEF,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAgwBpD,CAAC"}
|
package/dist/contexts/useChat.js
CHANGED
|
@@ -15,7 +15,7 @@ export const useChat = () => {
|
|
|
15
15
|
}
|
|
16
16
|
return context;
|
|
17
17
|
};
|
|
18
|
-
export const ChatProvider = ({ children, bypassPermissions, permissionMode: initialPermissionMode, pluginDirs, tools, allowedTools, disallowedTools, workdir, worktreeSession, version, model, mcpServers, }) => {
|
|
18
|
+
export const ChatProvider = ({ children, bypassPermissions, permissionMode: initialPermissionMode, pluginDirs, tools, allowedTools, disallowedTools, workdir, worktreeSession, originalCwd, version, model, mcpServers, }) => {
|
|
19
19
|
const { restoreSessionId, continueLastSession } = useAppConfig();
|
|
20
20
|
const { stdout } = useStdout();
|
|
21
21
|
// Message Display State
|
|
@@ -233,6 +233,20 @@ export const ChatProvider = ({ children, bypassPermissions, permissionMode: init
|
|
|
233
233
|
mcpServers,
|
|
234
234
|
});
|
|
235
235
|
agentRef.current = agent;
|
|
236
|
+
// Inject worktree session into this agent's own DI container so system
|
|
237
|
+
// prompts and permission checks reflect the CLI -w worktree. This state is
|
|
238
|
+
// per-session, not process-global (see specs/047-worktree.md FR-042).
|
|
239
|
+
if (worktreeSession) {
|
|
240
|
+
const session = {
|
|
241
|
+
originalCwd: originalCwd ?? worktreeSession.repoRoot,
|
|
242
|
+
worktreePath: worktreeSession.path,
|
|
243
|
+
worktreeBranch: worktreeSession.branch,
|
|
244
|
+
worktreeName: worktreeSession.name,
|
|
245
|
+
isNew: worktreeSession.isNew,
|
|
246
|
+
repoRoot: worktreeSession.repoRoot,
|
|
247
|
+
};
|
|
248
|
+
agent.setWorktreeSession(session);
|
|
249
|
+
}
|
|
236
250
|
// Get initial state
|
|
237
251
|
setSessionId(agent.sessionId);
|
|
238
252
|
setMessages(agent.messages);
|
|
@@ -266,6 +280,7 @@ export const ChatProvider = ({ children, bypassPermissions, permissionMode: init
|
|
|
266
280
|
disallowedTools,
|
|
267
281
|
workdir,
|
|
268
282
|
worktreeSession,
|
|
283
|
+
originalCwd,
|
|
269
284
|
model,
|
|
270
285
|
initialPermissionMode,
|
|
271
286
|
throttledSetMessages,
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,wBAAsB,IAAI,kBAmZzB;AAGD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,oBAAoB,GAC1B,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import yargs from "yargs";
|
|
2
2
|
import { hideBin } from "yargs/helpers";
|
|
3
3
|
import { startCli } from "./cli.js";
|
|
4
|
-
import { generateRandomName
|
|
4
|
+
import { generateRandomName } from "wave-agent-sdk";
|
|
5
5
|
import { createWorktree } from "./utils/worktree.js";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import { readFileSync } from "fs";
|
|
@@ -237,15 +237,9 @@ export async function main() {
|
|
|
237
237
|
name = generateRandomName();
|
|
238
238
|
}
|
|
239
239
|
worktreeSession = createWorktree(name, originalCwd);
|
|
240
|
-
//
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
worktreePath: worktreeSession.path,
|
|
244
|
-
worktreeBranch: worktreeSession.branch,
|
|
245
|
-
worktreeName: worktreeSession.name,
|
|
246
|
-
isNew: worktreeSession.isNew,
|
|
247
|
-
repoRoot: worktreeSession.repoRoot,
|
|
248
|
-
});
|
|
240
|
+
// Note: the full worktree session (originalCwd etc.) is injected into the
|
|
241
|
+
// agent's DI container after the agent is created in useChat.tsx. This keeps
|
|
242
|
+
// worktree state per-session instead of process-global.
|
|
249
243
|
}
|
|
250
244
|
const workdir = worktreeSession?.path || originalCwd;
|
|
251
245
|
if (worktreeSession) {
|
|
@@ -272,6 +266,7 @@ export async function main() {
|
|
|
272
266
|
disallowedTools,
|
|
273
267
|
worktreeSession,
|
|
274
268
|
workdir,
|
|
269
|
+
originalCwd,
|
|
275
270
|
version,
|
|
276
271
|
model: argv.model,
|
|
277
272
|
mcpServers,
|
|
@@ -293,6 +288,7 @@ export async function main() {
|
|
|
293
288
|
disallowedTools,
|
|
294
289
|
worktreeSession,
|
|
295
290
|
workdir,
|
|
291
|
+
originalCwd,
|
|
296
292
|
version,
|
|
297
293
|
model: argv.model,
|
|
298
294
|
mcpServers,
|
|
@@ -314,6 +310,7 @@ export async function main() {
|
|
|
314
310
|
disallowedTools,
|
|
315
311
|
worktreeSession,
|
|
316
312
|
workdir,
|
|
313
|
+
originalCwd,
|
|
317
314
|
version,
|
|
318
315
|
model: argv.model,
|
|
319
316
|
mcpServers,
|
package/dist/print-cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"print-cli.d.ts","sourceRoot":"","sources":["../src/print-cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"print-cli.d.ts","sourceRoot":"","sources":["../src/print-cli.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,gBAAgB,EAAE,eAAe,CAAC,CAAC;CACvE;AAgBD,wBAAsB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAqM3E"}
|
package/dist/print-cli.js
CHANGED
|
@@ -14,7 +14,7 @@ function displayTimingInfo(startTime, showStats) {
|
|
|
14
14
|
}
|
|
15
15
|
export async function startPrintCli(options) {
|
|
16
16
|
const startTime = new Date();
|
|
17
|
-
const { restoreSessionId, continueLastSession, message, showStats = false, bypassPermissions, permissionMode, pluginDirs, tools, allowedTools, disallowedTools, worktreeSession, workdir, model, mcpServers, } = options;
|
|
17
|
+
const { restoreSessionId, continueLastSession, message, showStats = false, bypassPermissions, permissionMode, pluginDirs, tools, allowedTools, disallowedTools, worktreeSession, workdir, originalCwd, model, mcpServers, } = options;
|
|
18
18
|
if ((typeof message !== "string" || message.trim() === "") &&
|
|
19
19
|
!continueLastSession &&
|
|
20
20
|
!restoreSessionId) {
|
|
@@ -81,10 +81,24 @@ export async function startPrintCli(options) {
|
|
|
81
81
|
allowedTools,
|
|
82
82
|
disallowedTools,
|
|
83
83
|
workdir,
|
|
84
|
+
worktreeName: worktreeSession?.name,
|
|
85
|
+
isNewWorktree: worktreeSession?.isNew,
|
|
84
86
|
model,
|
|
85
87
|
mcpServers,
|
|
86
88
|
// 保持流式模式以获得更好的命令行用户体验
|
|
87
89
|
});
|
|
90
|
+
// Inject worktree session into this agent's container (per-session, not global)
|
|
91
|
+
if (worktreeSession) {
|
|
92
|
+
const session = {
|
|
93
|
+
originalCwd: originalCwd ?? worktreeSession.repoRoot,
|
|
94
|
+
worktreePath: worktreeSession.path,
|
|
95
|
+
worktreeBranch: worktreeSession.branch,
|
|
96
|
+
worktreeName: worktreeSession.name,
|
|
97
|
+
isNew: worktreeSession.isNew,
|
|
98
|
+
repoRoot: worktreeSession.repoRoot,
|
|
99
|
+
};
|
|
100
|
+
agent.setWorktreeSession(session);
|
|
101
|
+
}
|
|
88
102
|
// Send message if provided and not empty
|
|
89
103
|
if (typeof message === "string" && message.trim() !== "") {
|
|
90
104
|
await agent.sendMessage(message);
|
|
@@ -41,6 +41,8 @@ export declare class AgentBridge {
|
|
|
41
41
|
private clearMessages;
|
|
42
42
|
private rewindToMessage;
|
|
43
43
|
private deleteQueuedMessage;
|
|
44
|
+
private updateQueuedMessage;
|
|
45
|
+
private deleteQueuedMessageById;
|
|
44
46
|
private getMessages;
|
|
45
47
|
private getFullMessageThread;
|
|
46
48
|
private setPermissionMode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentBridge.d.ts","sourceRoot":"","sources":["../../src/stdio/agentBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAuBH,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"agentBridge.d.ts","sourceRoot":"","sources":["../../src/stdio/agentBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAuBH,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,eAAe,CAAC;AAkBvB,MAAM,MAAM,mBAAmB,GAAG,CAChC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,EACf,SAAS,CAAC,EAAE,MAAM,KACf,IAAI,CAAC;AAEV,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAsDD,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,kBAAkB,CAGtB;IACJ,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,IAAI,CAAsB;IAClC,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,iBAAiB,CAAqB;gBAElC,OAAO,EAAE,kBAAkB;IAMjC,aAAa,CACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,EACf,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,CAAC;IAkKnB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;YAiB3C,UAAU;YAwDV,OAAO;YAWP,cAAc;YASd,YAAY;IAU1B,OAAO,CAAC,cAAc;YAiBR,YAAY;YAkDZ,WAAW;YA2BX,IAAI;YAMJ,YAAY;YAMZ,aAAa;YAMb,eAAe;IAuB7B,OAAO,CAAC,mBAAmB;IAM3B,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,uBAAuB;IAM/B,OAAO,CAAC,WAAW;YAKL,oBAAoB;YAUpB,iBAAiB;IAS/B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,aAAa;YAKP,gBAAgB;YAShB,mBAAmB;IAWjC,OAAO,CAAC,gBAAgB;YAOV,WAAW;YAYX,gBAAgB;YAYhB,mBAAmB;IAejC,OAAO,CAAC,UAAU;YA+BJ,aAAa;YAab,KAAK;YAaL,MAAM;IAQpB,OAAO,CAAC,aAAa;YAUP,WAAW;YAoBX,aAAa;YAYb,eAAe;YASf,YAAY;YASZ,aAAa;YAYb,YAAY;YAQZ,gBAAgB;YAIhB,cAAc;YASd,iBAAiB;YAUjB,iBAAiB;IAW/B,OAAO,CAAC,eAAe;IAoHvB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,cAAc;IAiBtB,OAAO,CAAC,iBAAiB;CAI1B;AAID,qBAAa,QAAS,SAAQ,KAAK;IACjC,IAAI,EAAE,MAAM,CAAC;gBACD,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAKzC,cAAc,IAAI,YAAY;CAG/B"}
|
|
@@ -19,6 +19,7 @@ import { INTERNAL_ERROR as PROTOCOL_INTERNAL_ERROR, METHOD_NOT_FOUND as PROTOCOL
|
|
|
19
19
|
import { readFileSync } from "fs";
|
|
20
20
|
import path from "path";
|
|
21
21
|
import { fileURLToPath } from "url";
|
|
22
|
+
import { logger } from "../utils/logger.js";
|
|
22
23
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
23
24
|
const CLI_VERSION = (() => {
|
|
24
25
|
try {
|
|
@@ -66,6 +67,10 @@ export class AgentBridge {
|
|
|
66
67
|
return this.rewindToMessage(p.messageId, sessionId);
|
|
67
68
|
case "deleteQueuedMessage":
|
|
68
69
|
return this.deleteQueuedMessage(p.index, sessionId);
|
|
70
|
+
case "updateQueuedMessage":
|
|
71
|
+
return this.updateQueuedMessage(p.id, p.text, p.images, sessionId);
|
|
72
|
+
case "deleteQueuedMessageById":
|
|
73
|
+
return this.deleteQueuedMessageById(p.id, sessionId);
|
|
69
74
|
case "getMessages":
|
|
70
75
|
return this.getMessages(sessionId);
|
|
71
76
|
case "getFullMessageThread":
|
|
@@ -141,6 +146,7 @@ export class AgentBridge {
|
|
|
141
146
|
const callbacks = this.createCallbacks(ctx);
|
|
142
147
|
const options = {
|
|
143
148
|
callbacks,
|
|
149
|
+
logger,
|
|
144
150
|
workdir: params.workdir,
|
|
145
151
|
restoreSessionId: params.restoreSessionId,
|
|
146
152
|
apiKey: params.apiKey,
|
|
@@ -165,7 +171,8 @@ export class AgentBridge {
|
|
|
165
171
|
storedConfig: { ...params },
|
|
166
172
|
});
|
|
167
173
|
if (params.clientVersion) {
|
|
168
|
-
|
|
174
|
+
// stdout 是 JSON-RPC 协议通道,诊断日志必须走 stderr 以免污染协议
|
|
175
|
+
process.stderr.write(`[agentBridge] clientVersion=${params.clientVersion} serverVersion=${CLI_VERSION}\n`);
|
|
169
176
|
}
|
|
170
177
|
return {
|
|
171
178
|
sessionId: agent.sessionId,
|
|
@@ -292,6 +299,19 @@ export class AgentBridge {
|
|
|
292
299
|
entry.agent.removeQueuedMessage(index);
|
|
293
300
|
return null;
|
|
294
301
|
}
|
|
302
|
+
updateQueuedMessage(id, text, images, sessionId) {
|
|
303
|
+
const entry = this.requireSession(sessionId);
|
|
304
|
+
const ok = entry.agent.updateQueuedMessageById(id, {
|
|
305
|
+
content: text,
|
|
306
|
+
images,
|
|
307
|
+
});
|
|
308
|
+
return { ok };
|
|
309
|
+
}
|
|
310
|
+
deleteQueuedMessageById(id, sessionId) {
|
|
311
|
+
const entry = this.requireSession(sessionId);
|
|
312
|
+
entry.agent.removeQueuedMessageById(id);
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
295
315
|
getMessages(sessionId) {
|
|
296
316
|
const entry = this.requireSession(sessionId);
|
|
297
317
|
return { messages: entry.agent.messages };
|
|
@@ -374,6 +394,7 @@ export class AgentBridge {
|
|
|
374
394
|
return {
|
|
375
395
|
isAuthenticated: authService.isSSOAuthenticated(),
|
|
376
396
|
user: authService.getAuthUser(),
|
|
397
|
+
serverUrl: authService.getServerUrl(),
|
|
377
398
|
};
|
|
378
399
|
}
|
|
379
400
|
async login(serverUrl) {
|
|
@@ -509,6 +530,9 @@ export class AgentBridge {
|
|
|
509
530
|
onPermissionModeChange: (mode) => {
|
|
510
531
|
this.emit("permissionModeChange", { mode }, ctx.registeredSessionId);
|
|
511
532
|
},
|
|
533
|
+
onWorkdirChange: (newCwd) => {
|
|
534
|
+
this.emit("workdirChange", { workdir: newCwd }, ctx.registeredSessionId);
|
|
535
|
+
},
|
|
512
536
|
onMcpServersChange: (servers) => {
|
|
513
537
|
this.emit("mcpServersChange", { servers }, ctx.registeredSessionId);
|
|
514
538
|
},
|
|
@@ -527,6 +551,9 @@ export class AgentBridge {
|
|
|
527
551
|
b.taskId === params.taskId));
|
|
528
552
|
this.emit("notificationMessageAdded", { ...params, message: msg }, ctx.registeredSessionId);
|
|
529
553
|
},
|
|
554
|
+
onCompactBlockAdded: (content) => {
|
|
555
|
+
this.emit("compactBlockAdded", { content }, ctx.registeredSessionId);
|
|
556
|
+
},
|
|
530
557
|
};
|
|
531
558
|
}
|
|
532
559
|
findLastUserMessage(agent) {
|
package/dist/stdio/protocol.d.ts
CHANGED
|
@@ -34,9 +34,9 @@ export declare const INVALID_REQUEST = -32600;
|
|
|
34
34
|
export declare const METHOD_NOT_FOUND = -32601;
|
|
35
35
|
export declare const INVALID_PARAMS = -32602;
|
|
36
36
|
export declare const INTERNAL_ERROR = -32603;
|
|
37
|
-
export type RequestMethod = "initialize" | "destroy" | "restoreSession" | "listSessions" | "getSessionInfo" | "sendMessage" | "bang" | "abortMessage" | "clearMessages" | "rewindToMessage" | "deleteQueuedMessage" | "getMessages" | "getFullMessageThread" | "setPermissionMode" | "getPermissionMode" | "getMcpServers" | "connectMcpServer" | "disconnectMcpServer" | "getSlashCommands" | "searchFiles" | "getPromptHistory" | "searchPromptHistory" | "updateConfig" | "getAuthStatus" | "login" | "logout" | "listPlugins" | "installPlugin" | "uninstallPlugin" | "enablePlugin" | "disablePlugin" | "updatePlugin" | "listMarketplaces" | "addMarketplace" | "removeMarketplace" | "updateMarketplace";
|
|
37
|
+
export type RequestMethod = "initialize" | "destroy" | "restoreSession" | "listSessions" | "getSessionInfo" | "sendMessage" | "bang" | "abortMessage" | "clearMessages" | "rewindToMessage" | "deleteQueuedMessage" | "updateQueuedMessage" | "deleteQueuedMessageById" | "getMessages" | "getFullMessageThread" | "setPermissionMode" | "getPermissionMode" | "getMcpServers" | "connectMcpServer" | "disconnectMcpServer" | "getSlashCommands" | "searchFiles" | "getPromptHistory" | "searchPromptHistory" | "updateConfig" | "getAuthStatus" | "login" | "logout" | "listPlugins" | "installPlugin" | "uninstallPlugin" | "enablePlugin" | "disablePlugin" | "updatePlugin" | "listMarketplaces" | "addMarketplace" | "removeMarketplace" | "updateMarketplace";
|
|
38
38
|
export type ClientNotificationMethod = "permissionResponse";
|
|
39
|
-
export type ServerNotificationMethod = "messagesChange" | "userMessageAdded" | "assistantMessageAdded" | "assistantContentUpdated" | "assistantReasoningUpdated" | "toolBlockUpdated" | "errorBlockAdded" | "loadingChange" | "commandRunningChange" | "queuedMessagesChange" | "tasksChange" | "sessionIdChange" | "permissionModeChange" | "mcpServersChange" | "bangMessageAdded" | "bangMessageUpdated" | "bangMessageCompleted" | "notificationMessageAdded" | "permissionRequest" | "authUrl";
|
|
39
|
+
export type ServerNotificationMethod = "messagesChange" | "userMessageAdded" | "assistantMessageAdded" | "assistantContentUpdated" | "assistantReasoningUpdated" | "toolBlockUpdated" | "errorBlockAdded" | "loadingChange" | "commandRunningChange" | "queuedMessagesChange" | "tasksChange" | "sessionIdChange" | "permissionModeChange" | "mcpServersChange" | "workdirChange" | "bangMessageAdded" | "bangMessageUpdated" | "bangMessageCompleted" | "notificationMessageAdded" | "permissionRequest" | "authUrl" | "compactBlockAdded";
|
|
40
40
|
export declare function isRequest(msg: unknown): msg is JsonRpcRequest;
|
|
41
41
|
export declare function isNotification(msg: unknown): msg is JsonRpcNotification;
|
|
42
42
|
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/stdio/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,eAAO,MAAM,WAAW,SAAS,CAAC;AAClC,eAAO,MAAM,eAAe,SAAS,CAAC;AACtC,eAAO,MAAM,gBAAgB,SAAS,CAAC;AACvC,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,cAAc,SAAS,CAAC;AAIrC,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,SAAS,GACT,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAChB,aAAa,GACb,MAAM,GACN,cAAc,GACd,eAAe,GACf,iBAAiB,GACjB,qBAAqB,GACrB,aAAa,GACb,sBAAsB,GACtB,mBAAmB,GACnB,mBAAmB,GACnB,eAAe,GACf,kBAAkB,GAClB,qBAAqB,GACrB,kBAAkB,GAClB,aAAa,GACb,kBAAkB,GAClB,qBAAqB,GACrB,cAAc,GAEd,eAAe,GACf,OAAO,GACP,QAAQ,GAER,aAAa,GACb,eAAe,GACf,iBAAiB,GACjB,cAAc,GACd,eAAe,GACf,cAAc,GACd,kBAAkB,GAClB,gBAAgB,GAChB,mBAAmB,GACnB,mBAAmB,CAAC;AAIxB,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AAI5D,MAAM,MAAM,wBAAwB,GAChC,gBAAgB,GAChB,kBAAkB,GAClB,uBAAuB,GACvB,yBAAyB,GACzB,2BAA2B,GAC3B,kBAAkB,GAClB,iBAAiB,GACjB,eAAe,GACf,sBAAsB,GACtB,sBAAsB,GACtB,aAAa,GACb,iBAAiB,GACjB,sBAAsB,GACtB,kBAAkB,GAClB,kBAAkB,GAClB,oBAAoB,GACpB,sBAAsB,GACtB,0BAA0B,GAC1B,mBAAmB,GACnB,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/stdio/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAA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oBAAoB,CAAC;AAI5D,MAAM,MAAM,wBAAwB,GAChC,gBAAgB,GAChB,kBAAkB,GAClB,uBAAuB,GACvB,yBAAyB,GACzB,2BAA2B,GAC3B,kBAAkB,GAClB,iBAAiB,GACjB,eAAe,GACf,sBAAsB,GACtB,sBAAsB,GACtB,aAAa,GACb,iBAAiB,GACjB,sBAAsB,GACtB,kBAAkB,GAClB,eAAe,GACf,kBAAkB,GAClB,oBAAoB,GACpB,sBAAsB,GACtB,0BAA0B,GAC1B,mBAAmB,GACnB,SAAS,GACT,mBAAmB,CAAC;AAIxB,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,cAAc,CAS7D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,mBAAmB,CAIvE"}
|
package/dist/types.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export interface BaseAppProps {
|
|
|
9
9
|
disallowedTools?: string[];
|
|
10
10
|
worktreeSession?: WorktreeSession;
|
|
11
11
|
workdir?: string;
|
|
12
|
+
/** The working directory before entering a worktree (CLI -w); injected into the agent's container. */
|
|
13
|
+
originalCwd?: string;
|
|
12
14
|
version?: string;
|
|
13
15
|
model?: string;
|
|
14
16
|
/** Optional MCP server configs to pass to Agent.create() */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjE,MAAM,WAAW,YAAY;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC9C"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjE,MAAM,WAAW,YAAY;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sGAAsG;IACtG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC9C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wave-code",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.6",
|
|
4
4
|
"description": "CLI-based code assistant powered by AI, built with React and Ink",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"semver": "^7.7.4",
|
|
42
42
|
"yargs": "^17.7.2",
|
|
43
43
|
"zod": "^3.23.8",
|
|
44
|
-
"wave-agent-sdk": "0.19.
|
|
44
|
+
"wave-agent-sdk": "0.19.6"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/react": "^19.1.8",
|
package/src/cli.tsx
CHANGED
|
@@ -22,6 +22,7 @@ export async function startCli(options: CliOptions): Promise<void> {
|
|
|
22
22
|
disallowedTools,
|
|
23
23
|
worktreeSession,
|
|
24
24
|
workdir,
|
|
25
|
+
originalCwd,
|
|
25
26
|
version,
|
|
26
27
|
model,
|
|
27
28
|
mcpServers,
|
|
@@ -48,6 +49,7 @@ export async function startCli(options: CliOptions): Promise<void> {
|
|
|
48
49
|
disallowedTools={disallowedTools}
|
|
49
50
|
worktreeSession={worktreeSession}
|
|
50
51
|
workdir={workdir}
|
|
52
|
+
originalCwd={originalCwd}
|
|
51
53
|
version={version}
|
|
52
54
|
model={model}
|
|
53
55
|
mcpServers={mcpServers}
|
package/src/components/App.tsx
CHANGED
|
@@ -98,6 +98,7 @@ const AppWithProviders: React.FC<AppWithProvidersProps> = ({
|
|
|
98
98
|
disallowedTools,
|
|
99
99
|
worktreeSession,
|
|
100
100
|
workdir,
|
|
101
|
+
originalCwd,
|
|
101
102
|
version,
|
|
102
103
|
model,
|
|
103
104
|
mcpServers,
|
|
@@ -123,6 +124,7 @@ const AppWithProviders: React.FC<AppWithProvidersProps> = ({
|
|
|
123
124
|
disallowedTools={disallowedTools}
|
|
124
125
|
workdir={workdir}
|
|
125
126
|
worktreeSession={worktreeSession}
|
|
127
|
+
originalCwd={originalCwd}
|
|
126
128
|
version={version}
|
|
127
129
|
model={model}
|
|
128
130
|
mcpServers={mcpServers}
|
|
@@ -142,6 +144,7 @@ const AppWithProviders: React.FC<AppWithProvidersProps> = ({
|
|
|
142
144
|
disallowedTools={disallowedTools}
|
|
143
145
|
workdir={workdir}
|
|
144
146
|
worktreeSession={worktreeSession}
|
|
147
|
+
originalCwd={originalCwd}
|
|
145
148
|
version={version}
|
|
146
149
|
model={model}
|
|
147
150
|
mcpServers={mcpServers}
|
|
@@ -162,6 +165,7 @@ export const App: React.FC<AppProps> = ({
|
|
|
162
165
|
disallowedTools,
|
|
163
166
|
worktreeSession,
|
|
164
167
|
workdir,
|
|
168
|
+
originalCwd,
|
|
165
169
|
version,
|
|
166
170
|
model,
|
|
167
171
|
mcpServers,
|
|
@@ -181,6 +185,7 @@ export const App: React.FC<AppProps> = ({
|
|
|
181
185
|
disallowedTools={disallowedTools}
|
|
182
186
|
worktreeSession={worktreeSession}
|
|
183
187
|
workdir={workdir}
|
|
188
|
+
originalCwd={originalCwd}
|
|
184
189
|
version={version}
|
|
185
190
|
model={model}
|
|
186
191
|
mcpServers={mcpServers}
|
package/src/contexts/useChat.tsx
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
Agent,
|
|
25
25
|
AgentCallbacks,
|
|
26
26
|
type ToolPermissionContext,
|
|
27
|
+
type WorktreeSession,
|
|
27
28
|
OPERATION_CANCELLED_BY_USER,
|
|
28
29
|
extractLatestTotalTokens,
|
|
29
30
|
} from "wave-agent-sdk";
|
|
@@ -161,6 +162,7 @@ export const ChatProvider: React.FC<ChatProviderProps> = ({
|
|
|
161
162
|
disallowedTools,
|
|
162
163
|
workdir,
|
|
163
164
|
worktreeSession,
|
|
165
|
+
originalCwd,
|
|
164
166
|
version,
|
|
165
167
|
model,
|
|
166
168
|
mcpServers,
|
|
@@ -478,6 +480,21 @@ export const ChatProvider: React.FC<ChatProviderProps> = ({
|
|
|
478
480
|
|
|
479
481
|
agentRef.current = agent;
|
|
480
482
|
|
|
483
|
+
// Inject worktree session into this agent's own DI container so system
|
|
484
|
+
// prompts and permission checks reflect the CLI -w worktree. This state is
|
|
485
|
+
// per-session, not process-global (see specs/047-worktree.md FR-042).
|
|
486
|
+
if (worktreeSession) {
|
|
487
|
+
const session: WorktreeSession = {
|
|
488
|
+
originalCwd: originalCwd ?? worktreeSession.repoRoot,
|
|
489
|
+
worktreePath: worktreeSession.path,
|
|
490
|
+
worktreeBranch: worktreeSession.branch,
|
|
491
|
+
worktreeName: worktreeSession.name,
|
|
492
|
+
isNew: worktreeSession.isNew,
|
|
493
|
+
repoRoot: worktreeSession.repoRoot,
|
|
494
|
+
};
|
|
495
|
+
agent.setWorktreeSession(session);
|
|
496
|
+
}
|
|
497
|
+
|
|
481
498
|
// Get initial state
|
|
482
499
|
setSessionId(agent.sessionId);
|
|
483
500
|
setMessages(agent.messages);
|
|
@@ -513,6 +530,7 @@ export const ChatProvider: React.FC<ChatProviderProps> = ({
|
|
|
513
530
|
disallowedTools,
|
|
514
531
|
workdir,
|
|
515
532
|
worktreeSession,
|
|
533
|
+
originalCwd,
|
|
516
534
|
model,
|
|
517
535
|
initialPermissionMode,
|
|
518
536
|
throttledSetMessages,
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import yargs from "yargs";
|
|
2
2
|
import { hideBin } from "yargs/helpers";
|
|
3
3
|
import { startCli } from "./cli.js";
|
|
4
|
-
import {
|
|
5
|
-
Scope,
|
|
6
|
-
generateRandomName,
|
|
7
|
-
type PermissionMode,
|
|
8
|
-
setCurrentWorktreeSession,
|
|
9
|
-
} from "wave-agent-sdk";
|
|
4
|
+
import { Scope, generateRandomName, type PermissionMode } from "wave-agent-sdk";
|
|
10
5
|
import { createWorktree, type WorktreeSession } from "./utils/worktree.js";
|
|
11
6
|
import path from "path";
|
|
12
7
|
import { readFileSync } from "fs";
|
|
@@ -327,15 +322,9 @@ export async function main() {
|
|
|
327
322
|
}
|
|
328
323
|
worktreeSession = createWorktree(name, originalCwd);
|
|
329
324
|
|
|
330
|
-
//
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
worktreePath: worktreeSession.path,
|
|
334
|
-
worktreeBranch: worktreeSession.branch,
|
|
335
|
-
worktreeName: worktreeSession.name,
|
|
336
|
-
isNew: worktreeSession.isNew,
|
|
337
|
-
repoRoot: worktreeSession.repoRoot,
|
|
338
|
-
});
|
|
325
|
+
// Note: the full worktree session (originalCwd etc.) is injected into the
|
|
326
|
+
// agent's DI container after the agent is created in useChat.tsx. This keeps
|
|
327
|
+
// worktree state per-session instead of process-global.
|
|
339
328
|
}
|
|
340
329
|
|
|
341
330
|
const workdir = worktreeSession?.path || originalCwd;
|
|
@@ -369,6 +358,7 @@ export async function main() {
|
|
|
369
358
|
disallowedTools,
|
|
370
359
|
worktreeSession,
|
|
371
360
|
workdir,
|
|
361
|
+
originalCwd,
|
|
372
362
|
version,
|
|
373
363
|
model: argv.model as string | undefined,
|
|
374
364
|
mcpServers,
|
|
@@ -393,6 +383,7 @@ export async function main() {
|
|
|
393
383
|
disallowedTools,
|
|
394
384
|
worktreeSession,
|
|
395
385
|
workdir,
|
|
386
|
+
originalCwd,
|
|
396
387
|
version,
|
|
397
388
|
model: argv.model as string | undefined,
|
|
398
389
|
mcpServers,
|
|
@@ -416,6 +407,7 @@ export async function main() {
|
|
|
416
407
|
disallowedTools,
|
|
417
408
|
worktreeSession,
|
|
418
409
|
workdir,
|
|
410
|
+
originalCwd,
|
|
419
411
|
version,
|
|
420
412
|
model: argv.model as string | undefined,
|
|
421
413
|
mcpServers,
|
package/src/print-cli.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
hasUncommittedChanges,
|
|
5
5
|
hasNewCommits,
|
|
6
6
|
getDefaultRemoteBranch,
|
|
7
|
+
type WorktreeSession,
|
|
7
8
|
} from "wave-agent-sdk";
|
|
8
9
|
import { displayUsageSummary } from "./utils/usageSummary.js";
|
|
9
10
|
import { removeWorktree } from "./utils/worktree.js";
|
|
@@ -47,6 +48,7 @@ export async function startPrintCli(options: PrintCliOptions): Promise<void> {
|
|
|
47
48
|
disallowedTools,
|
|
48
49
|
worktreeSession,
|
|
49
50
|
workdir,
|
|
51
|
+
originalCwd,
|
|
50
52
|
model,
|
|
51
53
|
mcpServers,
|
|
52
54
|
} = options;
|
|
@@ -126,11 +128,26 @@ export async function startPrintCli(options: PrintCliOptions): Promise<void> {
|
|
|
126
128
|
allowedTools,
|
|
127
129
|
disallowedTools,
|
|
128
130
|
workdir,
|
|
131
|
+
worktreeName: worktreeSession?.name,
|
|
132
|
+
isNewWorktree: worktreeSession?.isNew,
|
|
129
133
|
model,
|
|
130
134
|
mcpServers,
|
|
131
135
|
// 保持流式模式以获得更好的命令行用户体验
|
|
132
136
|
});
|
|
133
137
|
|
|
138
|
+
// Inject worktree session into this agent's container (per-session, not global)
|
|
139
|
+
if (worktreeSession) {
|
|
140
|
+
const session: WorktreeSession = {
|
|
141
|
+
originalCwd: originalCwd ?? worktreeSession.repoRoot,
|
|
142
|
+
worktreePath: worktreeSession.path,
|
|
143
|
+
worktreeBranch: worktreeSession.branch,
|
|
144
|
+
worktreeName: worktreeSession.name,
|
|
145
|
+
isNew: worktreeSession.isNew,
|
|
146
|
+
repoRoot: worktreeSession.repoRoot,
|
|
147
|
+
};
|
|
148
|
+
agent.setWorktreeSession(session);
|
|
149
|
+
}
|
|
150
|
+
|
|
134
151
|
// Send message if provided and not empty
|
|
135
152
|
if (typeof message === "string" && message.trim() !== "") {
|
|
136
153
|
await agent.sendMessage(message);
|
package/src/stdio/agentBridge.ts
CHANGED
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
import { readFileSync } from "fs";
|
|
45
45
|
import path from "path";
|
|
46
46
|
import { fileURLToPath } from "url";
|
|
47
|
+
import { logger } from "../utils/logger.js";
|
|
47
48
|
|
|
48
49
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
49
50
|
const CLI_VERSION: string = (() => {
|
|
@@ -177,6 +178,15 @@ export class AgentBridge {
|
|
|
177
178
|
return this.rewindToMessage(p.messageId as string, sessionId);
|
|
178
179
|
case "deleteQueuedMessage":
|
|
179
180
|
return this.deleteQueuedMessage(p.index as number, sessionId);
|
|
181
|
+
case "updateQueuedMessage":
|
|
182
|
+
return this.updateQueuedMessage(
|
|
183
|
+
p.id as string,
|
|
184
|
+
p.text as string,
|
|
185
|
+
p.images as Array<{ path: string; mimeType: string }> | undefined,
|
|
186
|
+
sessionId,
|
|
187
|
+
);
|
|
188
|
+
case "deleteQueuedMessageById":
|
|
189
|
+
return this.deleteQueuedMessageById(p.id as string, sessionId);
|
|
180
190
|
case "getMessages":
|
|
181
191
|
return this.getMessages(sessionId);
|
|
182
192
|
case "getFullMessageThread":
|
|
@@ -322,6 +332,7 @@ export class AgentBridge {
|
|
|
322
332
|
|
|
323
333
|
const options: AgentOptions = {
|
|
324
334
|
callbacks,
|
|
335
|
+
logger,
|
|
325
336
|
workdir: params.workdir,
|
|
326
337
|
restoreSessionId: params.restoreSessionId,
|
|
327
338
|
apiKey: params.apiKey,
|
|
@@ -350,8 +361,9 @@ export class AgentBridge {
|
|
|
350
361
|
});
|
|
351
362
|
|
|
352
363
|
if (params.clientVersion) {
|
|
353
|
-
|
|
354
|
-
|
|
364
|
+
// stdout 是 JSON-RPC 协议通道,诊断日志必须走 stderr 以免污染协议
|
|
365
|
+
process.stderr.write(
|
|
366
|
+
`[agentBridge] clientVersion=${params.clientVersion} serverVersion=${CLI_VERSION}\n`,
|
|
355
367
|
);
|
|
356
368
|
}
|
|
357
369
|
|
|
@@ -535,6 +547,26 @@ export class AgentBridge {
|
|
|
535
547
|
return null;
|
|
536
548
|
}
|
|
537
549
|
|
|
550
|
+
private updateQueuedMessage(
|
|
551
|
+
id: string,
|
|
552
|
+
text: string,
|
|
553
|
+
images: Array<{ path: string; mimeType: string }> | undefined,
|
|
554
|
+
sessionId?: string,
|
|
555
|
+
): { ok: boolean } {
|
|
556
|
+
const entry = this.requireSession(sessionId);
|
|
557
|
+
const ok = entry.agent.updateQueuedMessageById(id, {
|
|
558
|
+
content: text,
|
|
559
|
+
images,
|
|
560
|
+
});
|
|
561
|
+
return { ok };
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
private deleteQueuedMessageById(id: string, sessionId?: string): null {
|
|
565
|
+
const entry = this.requireSession(sessionId);
|
|
566
|
+
entry.agent.removeQueuedMessageById(id);
|
|
567
|
+
return null;
|
|
568
|
+
}
|
|
569
|
+
|
|
538
570
|
private getMessages(sessionId?: string): { messages: Message[] } {
|
|
539
571
|
const entry = this.requireSession(sessionId);
|
|
540
572
|
return { messages: entry.agent.messages };
|
|
@@ -671,11 +703,13 @@ export class AgentBridge {
|
|
|
671
703
|
private async getAuthStatus(): Promise<{
|
|
672
704
|
isAuthenticated: boolean;
|
|
673
705
|
user: { id: string; email?: string } | undefined;
|
|
706
|
+
serverUrl: string;
|
|
674
707
|
}> {
|
|
675
708
|
const authService = AuthService.getInstance();
|
|
676
709
|
return {
|
|
677
710
|
isAuthenticated: authService.isSSOAuthenticated(),
|
|
678
711
|
user: authService.getAuthUser(),
|
|
712
|
+
serverUrl: authService.getServerUrl(),
|
|
679
713
|
};
|
|
680
714
|
}
|
|
681
715
|
|
|
@@ -889,6 +923,13 @@ export class AgentBridge {
|
|
|
889
923
|
onPermissionModeChange: (mode: PermissionMode) => {
|
|
890
924
|
this.emit("permissionModeChange", { mode }, ctx.registeredSessionId);
|
|
891
925
|
},
|
|
926
|
+
onWorkdirChange: (newCwd: string) => {
|
|
927
|
+
this.emit(
|
|
928
|
+
"workdirChange",
|
|
929
|
+
{ workdir: newCwd },
|
|
930
|
+
ctx.registeredSessionId,
|
|
931
|
+
);
|
|
932
|
+
},
|
|
892
933
|
onMcpServersChange: (servers: McpServerStatus[]) => {
|
|
893
934
|
this.emit("mcpServersChange", { servers }, ctx.registeredSessionId);
|
|
894
935
|
},
|
|
@@ -917,6 +958,9 @@ export class AgentBridge {
|
|
|
917
958
|
ctx.registeredSessionId,
|
|
918
959
|
);
|
|
919
960
|
},
|
|
961
|
+
onCompactBlockAdded: (content: string) => {
|
|
962
|
+
this.emit("compactBlockAdded", { content }, ctx.registeredSessionId);
|
|
963
|
+
},
|
|
920
964
|
};
|
|
921
965
|
}
|
|
922
966
|
|
package/src/stdio/protocol.ts
CHANGED
|
@@ -58,6 +58,8 @@ export type RequestMethod =
|
|
|
58
58
|
| "clearMessages"
|
|
59
59
|
| "rewindToMessage"
|
|
60
60
|
| "deleteQueuedMessage"
|
|
61
|
+
| "updateQueuedMessage"
|
|
62
|
+
| "deleteQueuedMessageById"
|
|
61
63
|
| "getMessages"
|
|
62
64
|
| "getFullMessageThread"
|
|
63
65
|
| "setPermissionMode"
|
|
@@ -107,12 +109,14 @@ export type ServerNotificationMethod =
|
|
|
107
109
|
| "sessionIdChange"
|
|
108
110
|
| "permissionModeChange"
|
|
109
111
|
| "mcpServersChange"
|
|
112
|
+
| "workdirChange"
|
|
110
113
|
| "bangMessageAdded"
|
|
111
114
|
| "bangMessageUpdated"
|
|
112
115
|
| "bangMessageCompleted"
|
|
113
116
|
| "notificationMessageAdded"
|
|
114
117
|
| "permissionRequest"
|
|
115
|
-
| "authUrl"
|
|
118
|
+
| "authUrl"
|
|
119
|
+
| "compactBlockAdded";
|
|
116
120
|
|
|
117
121
|
// ── Helper: is this a request (has id)? ─────────────────────────
|
|
118
122
|
|
package/src/types.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface BaseAppProps {
|
|
|
10
10
|
disallowedTools?: string[];
|
|
11
11
|
worktreeSession?: WorktreeSession;
|
|
12
12
|
workdir?: string;
|
|
13
|
+
/** The working directory before entering a worktree (CLI -w); injected into the agent's container. */
|
|
14
|
+
originalCwd?: string;
|
|
13
15
|
version?: string;
|
|
14
16
|
model?: string;
|
|
15
17
|
/** Optional MCP server configs to pass to Agent.create() */
|