Changesets · Branches · Tags · Compare
| Changeset | 578c9023eefabb81c8b4b77c09a9b2d27e5e07f5de5266dcc4d803b15020e97b |
|---|---|
| Author | Nate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-09-22 19:54 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-09-22 19:54 -07:00 |
| Parents | 6c2aba15fe99 |
14 files changed
modified .vscode/launch.json +7 −2
| @@ -136,8 +136,9 @@ | ||
| 136 | 136 | "name": "Debug CLI", |
| 137 | 137 | "type": "node", |
| 138 | 138 | "request": "launch", |
| 139 | - "program": "${workspaceFolder}/extensions/cli/src/index.ts", | |
| 139 | + "program": "${workspaceFolder}/extensions/cli/dist/cn.js", | |
| 140 | 140 | "args": [], |
| 141 | + "runtimeArgs": ["--enable-source-maps"], | |
| 141 | 142 | "env": { |
| 142 | 143 | "NODE_ENV": "development" |
| 143 | 144 | // "CONTINUE_API_BASE": "http://localhost:3001/", |
| @@ -147,8 +148,12 @@ | ||
| 147 | 148 | "console": "integratedTerminal", |
| 148 | 149 | "internalConsoleOptions": "neverOpen", |
| 149 | 150 | "skipFiles": ["<node_internals>/**"], |
| 150 | - "runtimeArgs": ["--loader", "ts-node/esm"], | |
| 151 | 151 | "sourceMaps": true, |
| 152 | + "outFiles": ["${workspaceFolder}/extensions/cli/dist/**/*.js"], | |
| 153 | + "sourceMapPathOverrides": { | |
| 154 | + "../src/*": "${workspaceFolder}/extensions/cli/src/*", | |
| 155 | + "../../core/*": "${workspaceFolder}/core/*" | |
| 156 | + }, | |
| 152 | 157 | "resolveSourceMapLocations": [ |
| 153 | 158 | "${workspaceFolder}/**", |
| 154 | 159 | "!**/node_modules/**" |
modified core/package-lock.json +0 −0
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
modified extensions/cli/build.mjs +2 −2
| @@ -81,8 +81,8 @@ | ||
| 81 | 81 | |
| 82 | 82 | // Add banner to create require for CommonJS packages |
| 83 | 83 | banner: { |
| 84 | - js: `import { createRequire } from 'module'; | |
| 85 | -const require = createRequire(import.meta.url);`, | |
| 84 | + js: `import { createRequire as __createRequire } from 'module'; | |
| 85 | +const require = __createRequire(import.meta.url);`, | |
| 86 | 86 | }, |
| 87 | 87 | }); |
| 88 | 88 |
modified extensions/cli/package-lock.json +0 −0
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
modified extensions/cli/src/commands/ls.ts +9 −6
| @@ -30,13 +30,16 @@ | ||
| 30 | 30 | const authConfig = loadAuthConfig(); |
| 31 | 31 | const accessToken = getAccessToken(authConfig); |
| 32 | 32 | |
| 33 | - const resp = await fetch(`${env.apiBase}agents/devboxes/${agentId}/tunnel`, { | |
| 34 | - method: "POST", | |
| 35 | - headers: { | |
| 36 | - "Content-Type": "application/json", | |
| 37 | - Authorization: `Bearer ${accessToken}`, | |
| 33 | + const resp = await fetch( | |
| 34 | + new URL(`agents/${encodeURIComponent(agentId)}/tunnel`, env.apiBase), | |
| 35 | + { | |
| 36 | + method: "POST", | |
| 37 | + headers: { | |
| 38 | + "Content-Type": "application/json", | |
| 39 | + Authorization: `Bearer ${accessToken}`, | |
| 40 | + }, | |
| 38 | 41 | }, |
| 39 | - }); | |
| 42 | + ); | |
| 40 | 43 | if (!resp.ok) { |
| 41 | 44 | throw new Error( |
| 42 | 45 | `Failed to get tunnel for agent ${agentId}: ${await resp.text()}`, |
modified extensions/cli/src/commands/remote.test.ts +7 −7
| @@ -78,7 +78,7 @@ | ||
| 78 | 78 | await remote("test prompt", { idempotencyKey: testIdempotencyKey }); |
| 79 | 79 | |
| 80 | 80 | expect(mockFetch).toHaveBeenCalledWith( |
| 81 | - new URL("agents/devboxes", mockEnv.env.apiBase), | |
| 81 | + new URL("agents", mockEnv.env.apiBase), | |
| 82 | 82 | expect.objectContaining({ |
| 83 | 83 | method: "POST", |
| 84 | 84 | headers: { |
| @@ -96,7 +96,7 @@ | ||
| 96 | 96 | await remote("test prompt", {}); |
| 97 | 97 | |
| 98 | 98 | expect(mockFetch).toHaveBeenCalledWith( |
| 99 | - new URL("agents/devboxes", mockEnv.env.apiBase), | |
| 99 | + new URL("agents", mockEnv.env.apiBase), | |
| 100 | 100 | expect.objectContaining({ |
| 101 | 101 | method: "POST", |
| 102 | 102 | headers: { |
| @@ -190,7 +190,7 @@ | ||
| 190 | 190 | await remote("test prompt", { branch: testBranch }); |
| 191 | 191 | |
| 192 | 192 | expect(mockFetch).toHaveBeenCalledWith( |
| 193 | - new URL("agents/devboxes", mockEnv.env.apiBase), | |
| 193 | + new URL("agents", mockEnv.env.apiBase), | |
| 194 | 194 | expect.objectContaining({ |
| 195 | 195 | method: "POST", |
| 196 | 196 | headers: { |
| @@ -206,7 +206,7 @@ | ||
| 206 | 206 | await remote("test prompt", {}); |
| 207 | 207 | |
| 208 | 208 | expect(mockFetch).toHaveBeenCalledWith( |
| 209 | - new URL("agents/devboxes", mockEnv.env.apiBase), | |
| 209 | + new URL("agents", mockEnv.env.apiBase), | |
| 210 | 210 | expect.objectContaining({ |
| 211 | 211 | method: "POST", |
| 212 | 212 | headers: { |
| @@ -247,7 +247,7 @@ | ||
| 247 | 247 | await remote("test prompt", { config: testConfig }); |
| 248 | 248 | |
| 249 | 249 | expect(mockFetch).toHaveBeenCalledWith( |
| 250 | - new URL("agents/devboxes", mockEnv.env.apiBase), | |
| 250 | + new URL("agents", mockEnv.env.apiBase), | |
| 251 | 251 | expect.objectContaining({ |
| 252 | 252 | method: "POST", |
| 253 | 253 | headers: { |
| @@ -259,7 +259,7 @@ | ||
| 259 | 259 | ); |
| 260 | 260 | |
| 261 | 261 | expect(mockFetch).toHaveBeenCalledWith( |
| 262 | - new URL("agents/devboxes", mockEnv.env.apiBase), | |
| 262 | + new URL("agents", mockEnv.env.apiBase), | |
| 263 | 263 | expect.objectContaining({ |
| 264 | 264 | body: expect.stringContaining(`"agent":"${testConfig}"`), |
| 265 | 265 | }), |
| @@ -332,7 +332,7 @@ | ||
| 332 | 332 | |
| 333 | 333 | // Should make POST request to create environment |
| 334 | 334 | expect(mockFetch).toHaveBeenCalledWith( |
| 335 | - new URL("agents/devboxes", mockEnv.env.apiBase), | |
| 335 | + new URL("agents", mockEnv.env.apiBase), | |
| 336 | 336 | expect.objectContaining({ |
| 337 | 337 | method: "POST", |
| 338 | 338 | headers: { |
modified extensions/cli/src/commands/remote.ts +1 −1
| @@ -95,7 +95,7 @@ | ||
| 95 | 95 | requestBody.branchName = options.branch; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - const response = await fetch(new URL("agents/devboxes", env.apiBase), { | |
| 98 | + const response = await fetch(new URL("agents", env.apiBase), { | |
| 99 | 99 | method: "POST", |
| 100 | 100 | headers: { |
| 101 | 101 | "Content-Type": "application/json", |
modified extensions/cli/src/commands/serve.ts +10 −0
| @@ -382,11 +382,13 @@ | ||
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | async function processMessages(state: ServerState, llmApi: any) { |
| 385 | + let processedMessage = false; | |
| 385 | 386 | while (state.messageQueue.length > 0 && state.serverRunning) { |
| 386 | 387 | const userMessage = state.messageQueue.shift()!; |
| 387 | 388 | state.isProcessing = true; |
| 388 | 389 | state.shouldInterrupt = false; |
| 389 | 390 | state.lastActivity = Date.now(); |
| 391 | + processedMessage = true; | |
| 390 | 392 | |
| 391 | 393 | // Add user message via ChatHistoryService (single source of truth) |
| 392 | 394 | try { |
| @@ -437,6 +439,14 @@ | ||
| 437 | 439 | state.isProcessing = false; |
| 438 | 440 | } |
| 439 | 441 | } |
| 442 | + | |
| 443 | + if ( | |
| 444 | + processedMessage && | |
| 445 | + state.serverRunning && | |
| 446 | + state.messageQueue.length === 0 | |
| 447 | + ) { | |
| 448 | + await storageSyncService.markAgentStatusUnread(); | |
| 449 | + } | |
| 440 | 450 | } |
| 441 | 451 | |
| 442 | 452 | // Check for inactivity and shutdown |
modified extensions/cli/src/services/ServiceContainer.test.ts +6 −1
| @@ -1,4 +1,4 @@ | ||
| 1 | -import { describe, expect, test, beforeEach, vi } from "vitest"; | |
| 1 | +import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"; | |
| 2 | 2 | |
| 3 | 3 | import { ServiceContainer } from "./ServiceContainer.js"; |
| 4 | 4 | |
| @@ -10,6 +10,11 @@ | ||
| 10 | 10 | vi.clearAllMocks(); |
| 11 | 11 | }); |
| 12 | 12 | |
| 13 | + afterEach(() => { | |
| 14 | + // Clean up listeners to prevent memory leaks | |
| 15 | + container?.removeAllListeners(); | |
| 16 | + }); | |
| 17 | + | |
| 13 | 18 | describe("Dependency Cascade Reloading", () => { |
| 14 | 19 | test("should automatically reload all transitive dependents", async () => { |
| 15 | 20 | // Setup service dependency chain: auth -> apiClient -> config -> model |
modified extensions/cli/src/services/StorageSyncService.test.ts +77 −1
| @@ -177,6 +177,7 @@ | ||
| 177 | 177 | ok: false, |
| 178 | 178 | status: 403, |
| 179 | 179 | statusText: "Forbidden", |
| 180 | + text: async () => "Access denied", | |
| 180 | 181 | }); |
| 181 | 182 | gitDiffMock.mockResolvedValue({ diff: "", repoFound: true }); |
| 182 | 183 | |
| @@ -191,7 +192,7 @@ | ||
| 191 | 192 | |
| 192 | 193 | expect(result).toBe(true); |
| 193 | 194 | expect(warnSpy).toHaveBeenCalledWith( |
| 194 | - expect.stringContaining("Storage upload failed"), | |
| 195 | + expect.stringContaining("Storage sync upload failed"), | |
| 195 | 196 | ); |
| 196 | 197 | const state = service.getState(); |
| 197 | 198 | expect(state.isEnabled).toBe(true); |
| @@ -200,4 +201,79 @@ | ||
| 200 | 201 | service.stop(); |
| 201 | 202 | warnSpy.mockRestore(); |
| 202 | 203 | }); |
| 204 | + | |
| 205 | + it("does nothing when markAgentStatusUnread has no storage context", async () => { | |
| 206 | + await service.markAgentStatusUnread(); | |
| 207 | + expect(fetchMock).not.toHaveBeenCalled(); | |
| 208 | + }); | |
| 209 | + | |
| 210 | + it("marks the agent session as unread", async () => { | |
| 211 | + (service as unknown as { options: any }).options = { | |
| 212 | + storageId: "session-123", | |
| 213 | + accessToken: "token", | |
| 214 | + }; | |
| 215 | + | |
| 216 | + fetchMock.mockResolvedValueOnce({ ok: true }); | |
| 217 | + | |
| 218 | + await service.markAgentStatusUnread(); | |
| 219 | + | |
| 220 | + expect(fetchMock).toHaveBeenCalledTimes(1); | |
| 221 | + const [url, init] = fetchMock.mock.calls[0]; | |
| 222 | + expect(url).toBeInstanceOf(URL); | |
| 223 | + expect((url as URL).toString()).toBe( | |
| 224 | + "https://api.test/agents/session-123/read-status", | |
| 225 | + ); | |
| 226 | + expect(init).toMatchObject({ | |
| 227 | + method: "POST", | |
| 228 | + body: JSON.stringify({ unread: true }), | |
| 229 | + headers: { | |
| 230 | + Authorization: "Bearer token", | |
| 231 | + "Content-Type": "application/json", | |
| 232 | + }, | |
| 233 | + }); | |
| 234 | + }); | |
| 235 | + | |
| 236 | + it("includes server-side encryption header when required by signed headers", async () => { | |
| 237 | + const syncSessionHistory = vi.fn(); | |
| 238 | + const getSessionSnapshot = vi.fn().mockReturnValue({ test: "data" }); | |
| 239 | + | |
| 240 | + // Mock presign response with server-side encryption in signed headers | |
| 241 | + const sessionUrlWithSSE = | |
| 242 | + "https://upload/session?X-Amz-SignedHeaders=host%3Bx-amz-server-side-encryption"; | |
| 243 | + const diffUrl = "https://upload/diff"; | |
| 244 | + | |
| 245 | + fetchMock.mockResolvedValueOnce({ | |
| 246 | + ok: true, | |
| 247 | + json: async () => ({ | |
| 248 | + session: { putUrl: sessionUrlWithSSE, key: "session.json" }, | |
| 249 | + diff: { putUrl: diffUrl, key: "diff.txt" }, | |
| 250 | + }), | |
| 251 | + }); | |
| 252 | + fetchMock.mockResolvedValue({ ok: true }); | |
| 253 | + gitDiffMock.mockResolvedValue({ diff: "test diff", repoFound: true }); | |
| 254 | + | |
| 255 | + const result = await service.startFromOptions({ | |
| 256 | + storageOption: "session-123", | |
| 257 | + accessToken: "token", | |
| 258 | + syncSessionHistory, | |
| 259 | + getSessionSnapshot, | |
| 260 | + isActive: () => true, | |
| 261 | + }); | |
| 262 | + | |
| 263 | + expect(result).toBe(true); | |
| 264 | + expect(fetchMock).toHaveBeenCalledTimes(3); | |
| 265 | + | |
| 266 | + // Check session upload includes server-side encryption header | |
| 267 | + const sessionCall = fetchMock.mock.calls[1]; | |
| 268 | + expect(sessionCall[0]).toBe(sessionUrlWithSSE); | |
| 269 | + expect(sessionCall[1]).toMatchObject({ | |
| 270 | + method: "PUT", | |
| 271 | + headers: { | |
| 272 | + "Content-Type": "application/json", | |
| 273 | + "x-amz-server-side-encryption": "AES256", | |
| 274 | + }, | |
| 275 | + }); | |
| 276 | + | |
| 277 | + service.stop(); | |
| 278 | + }); | |
| 203 | 279 | }); |
modified extensions/cli/src/services/StorageSyncService.ts +51 −4
| @@ -139,6 +139,42 @@ | ||
| 139 | 139 | return true; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | + async markAgentStatusUnread(): Promise<void> { | |
| 143 | + const storageId = this.options?.storageId; | |
| 144 | + const accessToken = this.options?.accessToken; | |
| 145 | + | |
| 146 | + if (!storageId || !accessToken) { | |
| 147 | + return; | |
| 148 | + } | |
| 149 | + | |
| 150 | + const url = new URL( | |
| 151 | + `agents/${encodeURIComponent(storageId)}/read-status`, | |
| 152 | + env.apiBase, | |
| 153 | + ); | |
| 154 | + | |
| 155 | + try { | |
| 156 | + const response = await fetch(url, { | |
| 157 | + method: "POST", | |
| 158 | + headers: { | |
| 159 | + "Content-Type": "application/json", | |
| 160 | + Authorization: `Bearer ${accessToken}`, | |
| 161 | + }, | |
| 162 | + body: JSON.stringify({ unread: true }), | |
| 163 | + }); | |
| 164 | + | |
| 165 | + if (!response.ok) { | |
| 166 | + const statusText = `${response.status} ${response.statusText}`.trim(); | |
| 167 | + logger.debug( | |
| 168 | + `Failed to mark agent session unread (${statusText || "unknown error"}).`, | |
| 169 | + ); | |
| 170 | + } | |
| 171 | + } catch (error) { | |
| 172 | + logger.debug( | |
| 173 | + `Failed to mark agent session unread: ${formatError(error)}`, | |
| 174 | + ); | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 142 | 178 | stop(): void { |
| 143 | 179 | this.stopped = true; |
| 144 | 180 | this.targets = null; |
| @@ -214,17 +250,28 @@ | ||
| 214 | 250 | body: string, |
| 215 | 251 | contentType: string, |
| 216 | 252 | ): Promise<void> { |
| 253 | + // Parse the URL to extract any required headers from the query parameters | |
| 254 | + const parsedUrl = new URL(url); | |
| 255 | + const headers: Record<string, string> = { | |
| 256 | + "Content-Type": contentType, | |
| 257 | + }; | |
| 258 | + | |
| 259 | + // Check if the presigned URL includes server-side encryption in signed headers | |
| 260 | + const signedHeaders = parsedUrl.searchParams.get("X-Amz-SignedHeaders"); | |
| 261 | + if (signedHeaders?.includes("x-amz-server-side-encryption")) { | |
| 262 | + headers["x-amz-server-side-encryption"] = "AES256"; | |
| 263 | + } | |
| 264 | + | |
| 217 | 265 | const response = await fetch(url, { |
| 218 | 266 | method: "PUT", |
| 219 | - headers: { | |
| 220 | - "Content-Type": contentType, | |
| 221 | - }, | |
| 267 | + headers, | |
| 222 | 268 | body, |
| 223 | 269 | }); |
| 224 | 270 | |
| 225 | 271 | if (!response.ok) { |
| 226 | 272 | const statusText = `${response.status} ${response.statusText}`.trim(); |
| 227 | - throw new Error(`Storage upload failed (${statusText})`); | |
| 273 | + const responseBody = await response.text(); | |
| 274 | + throw new Error(`Storage upload failed (${statusText}): ${responseBody}`); | |
| 228 | 275 | } |
| 229 | 276 | } |
| 230 | 277 |
modified extensions/cli/src/session.ts +1 −1
| @@ -321,7 +321,7 @@ | ||
| 321 | 321 | return []; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - const response = await fetch(new URL("agents/devboxes", env.apiBase), { | |
| 324 | + const response = await fetch(new URL("agents", env.apiBase), { | |
| 325 | 325 | method: "GET", |
| 326 | 326 | headers: { |
| 327 | 327 | "Content-Type": "application/json", |
modified extensions/cli/src/tools/edit.test.ts +16 −7
| @@ -3,18 +3,19 @@ | ||
| 3 | 3 | import { ContinueError, ContinueErrorReason } from "core/util/errors.js"; |
| 4 | 4 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
| 5 | 5 | |
| 6 | +import { | |
| 7 | + calculateLinesOfCodeDiff, | |
| 8 | + getLanguageFromFilePath, | |
| 9 | +} from "../telemetry/utils.js"; | |
| 10 | + | |
| 6 | 11 | import { editTool } from "./edit.js"; |
| 7 | 12 | import { markFileAsRead, readFilesSet } from "./readFile.js"; |
| 13 | +import { generateDiff } from "./writeFile.js"; | |
| 8 | 14 | |
| 9 | 15 | // Mock the dependencies |
| 10 | 16 | vi.mock("../telemetry/telemetryService.js"); |
| 11 | -vi.mock("../telemetry/utils.js", () => ({ | |
| 12 | - calculateLinesOfCodeDiff: vi.fn().mockReturnValue({ added: 1, removed: 0 }), | |
| 13 | - getLanguageFromFilePath: vi.fn().mockReturnValue("javascript"), | |
| 14 | -})); | |
| 15 | -vi.mock("./writeFile.js", () => ({ | |
| 16 | - generateDiff: vi.fn().mockReturnValue("mocked diff"), | |
| 17 | -})); | |
| 17 | +vi.mock("../telemetry/utils.js"); | |
| 18 | +vi.mock("./writeFile.js"); | |
| 18 | 19 | vi.mock("fs", async () => { |
| 19 | 20 | const actual = await vi.importActual("fs"); |
| 20 | 21 | return { |
| @@ -38,6 +39,14 @@ | ||
| 38 | 39 | vi.mocked(fs.readFileSync).mockReturnValue(originalContent); |
| 39 | 40 | vi.mocked(fs.writeFileSync).mockImplementation(() => {}); |
| 40 | 41 | vi.mocked(fs.realpathSync).mockImplementation((path) => path.toString()); |
| 42 | + | |
| 43 | + // Setup utility mocks with proper return values | |
| 44 | + vi.mocked(calculateLinesOfCodeDiff).mockReturnValue({ | |
| 45 | + added: 1, | |
| 46 | + removed: 0, | |
| 47 | + }); | |
| 48 | + vi.mocked(getLanguageFromFilePath).mockReturnValue("javascript"); | |
| 49 | + vi.mocked(generateDiff).mockReturnValue("mocked diff"); | |
| 41 | 50 | }); |
| 42 | 51 | |
| 43 | 52 | afterEach(() => { |
modified extensions/cli/src/tools/multiEdit.test.ts +14 −0
| @@ -4,8 +4,14 @@ | ||
| 4 | 4 | import { ContinueError, ContinueErrorReason } from "core/util/errors.js"; |
| 5 | 5 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
| 6 | 6 | |
| 7 | +import { | |
| 8 | + calculateLinesOfCodeDiff, | |
| 9 | + getLanguageFromFilePath, | |
| 10 | +} from "../telemetry/utils.js"; | |
| 11 | + | |
| 7 | 12 | import { multiEditTool } from "./multiEdit.js"; |
| 8 | 13 | import { markFileAsRead } from "./readFile.js"; |
| 14 | +import { generateDiff } from "./writeFile.js"; | |
| 9 | 15 | |
| 10 | 16 | // Mock the dependencies |
| 11 | 17 | vi.mock("../telemetry/telemetryService.js"); |
| @@ -40,6 +46,14 @@ | ||
| 40 | 46 | vi.mocked(fs.readFileSync).mockReturnValue(originalContent); |
| 41 | 47 | vi.mocked(fs.writeFileSync).mockImplementation(() => {}); |
| 42 | 48 | vi.mocked(fs.realpathSync).mockImplementation((path) => path.toString()); |
| 49 | + | |
| 50 | + // Setup utility mocks with proper return values | |
| 51 | + vi.mocked(calculateLinesOfCodeDiff).mockReturnValue({ | |
| 52 | + added: 1, | |
| 53 | + removed: 0, | |
| 54 | + }); | |
| 55 | + vi.mocked(getLanguageFromFilePath).mockReturnValue("javascript"); | |
| 56 | + vi.mocked(generateDiff).mockReturnValue("mocked diff"); | |
| 43 | 57 | }); |
| 44 | 58 | |
| 45 | 59 | afterEach(() => { |