diff --git a/src/integrationTest/kotlin/com/sourcegraph/cody/util/CodyIntegrationTextFixture.kt b/src/integrationTest/kotlin/com/sourcegraph/cody/util/CodyIntegrationTextFixture.kt index be2f41dce6..845bc4bbca 100644 --- a/src/integrationTest/kotlin/com/sourcegraph/cody/util/CodyIntegrationTextFixture.kt +++ b/src/integrationTest/kotlin/com/sourcegraph/cody/util/CodyIntegrationTextFixture.kt @@ -20,7 +20,9 @@ import com.intellij.testFramework.PlatformTestUtil import com.intellij.testFramework.fixtures.BasePlatformTestCase import com.intellij.testFramework.runInEdtAndWait import com.sourcegraph.cody.agent.CodyAgentService +import com.sourcegraph.cody.agent.protocol_generated.ProtocolAuthenticatedAuthStatus import com.sourcegraph.cody.agent.protocol_generated.ProtocolCodeLens +import com.sourcegraph.cody.agent.protocol_generated.ProtocolUnauthenticatedAuthStatus import com.sourcegraph.cody.auth.CodyAccount import com.sourcegraph.cody.auth.SourcegraphServerPath import com.sourcegraph.cody.edit.lenses.LensListener @@ -59,9 +61,10 @@ open class CodyIntegrationTextFixture : BasePlatformTestCase(), LensListener { val recordingsFuture = CompletableFuture() CodyAgentService.withAgent(project) { agent -> - val errors = agent.server.testingRequestErrors().get() + val errors = agent.server.testing_requestErrors(null).get() // We extract polly.js errors to notify users about the missing recordings, if any - val missingRecordings = errors.filter { it.error?.contains("`recordIfMissing` is") == true } + val missingRecordings = + errors.errors.filter { it.error?.contains("`recordIfMissing` is") == true } missingRecordings.forEach { missing -> logger.error( """Recording is missing: ${missing.error} @@ -109,6 +112,8 @@ open class CodyIntegrationTextFixture : BasePlatformTestCase(), LensListener { } private fun checkInitialConditions() { + isAuthenticated() + // If you don't specify this system property with this setting when running the tests, // the tests will fail, because IntelliJ will run them from the EDT, which can't block. // Setting this property invokes the tests from an executor pool thread, which lets us @@ -137,6 +142,29 @@ open class CodyIntegrationTextFixture : BasePlatformTestCase(), LensListener { assertTrue("Action should be visible", presentation.isVisible) } + private fun isAuthenticated() { + val authenticate = CompletableFuture() + CodyAgentService.withAgent(project) { agent -> + var retries = 10 + var statusCompletable = agent.server.extensionConfiguration_status(null) + + while (retries-- > 0 && !authenticate.isDone) { + when (statusCompletable.getNow(null)) { + is ProtocolAuthenticatedAuthStatus -> authenticate.complete(true) + is ProtocolUnauthenticatedAuthStatus -> + statusCompletable = agent.server.extensionConfiguration_status(null) + else -> {} + } + + Thread.sleep(1000L) + } + } + + assertTrue( + "User is not authenticated", + authenticate.completeOnTimeout(false, ASYNC_WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS).get()) + } + private fun createEditorContext(editor: Editor): DataContext { return (editor as? EditorEx)?.dataContext ?: DataContext.EMPTY_CONTEXT } diff --git a/src/integrationTest/kotlin/com/sourcegraph/cody/util/TestingCredentials.kt b/src/integrationTest/kotlin/com/sourcegraph/cody/util/TestingCredentials.kt index 8e0101be60..57df17404f 100644 --- a/src/integrationTest/kotlin/com/sourcegraph/cody/util/TestingCredentials.kt +++ b/src/integrationTest/kotlin/com/sourcegraph/cody/util/TestingCredentials.kt @@ -27,12 +27,12 @@ data class TestingCredentials( token = System.getenv("SRC_ENTERPRISE_ACCESS_TOKEN"), redactedToken = "REDACTED_b20717265e7ab1d132874d8ff0be053ab9c1dacccec8dce0bbba76888b6a0a69", - serverEndpoint = "https://demo.sourcegraph.com/") + serverEndpoint = "http://demo.sourcegraph.com/") val s2 = TestingCredentials( token = System.getenv("SRC_S2_ACCESS_TOKEN"), redactedToken = "REDACTED_964f5256e709a8c5c151a63d8696d5c7ac81604d179405864d88ff48a9232364", - serverEndpoint = "https://sourcegraph.sourcegraph.com/") + serverEndpoint = "http://sourcegraph.sourcegraph.com/") } } diff --git a/src/integrationTest/resources/recordings/integration-test_2927926756/recording.har.yaml b/src/integrationTest/resources/recordings/integration-test_2927926756/recording.har.yaml index 871721f324..85f6a57ffc 100644 --- a/src/integrationTest/resources/recordings/integration-test_2927926756/recording.har.yaml +++ b/src/integrationTest/resources/recordings/integration-test_2927926756/recording.har.yaml @@ -5,1016 +5,114 @@ log: name: Polly.JS version: 6.0.6 entries: - - _id: 4639cede1d1b8af7aafd2d4f4e5060d6 + - _id: b8c50a1712c4f48523792455a932bd99 _order: 0 cache: {} request: - bodySize: 0 - cookies: [] - headers: - - _fromType: array - name: authorization - value: token - REDACTED_3dd704711f82a44ff6aba261b53b61a03fb8edba658774639148630d838c2d1d - - _fromType: array - name: content-type - value: application/json; charset=utf-8 - - _fromType: array - name: user-agent - value: JetBrains / 6.0-localbuild - - _fromType: array - name: accept - value: "*/*" - - _fromType: array - name: accept-encoding - value: gzip,deflate - - name: host - value: sourcegraph.com - headersSize: 370 - httpVersion: HTTP/1.1 - method: GET - queryString: [] - url: https://sourcegraph.com/.api/client-config - response: - bodySize: 224 - content: - encoding: base64 - mimeType: text/plain; charset=utf-8 - size: 224 - text: "[\"H4sIAAAAAAAAA2yOsQrCMBRF935F6Ozo1K0Eh26Fgs6v5omBvLySd4OK+O8uFZfM59zDf\ - XfOOddfNbxOmdbEoR8cSuXDDu6EJqAK9SpbYnB7WQ0qXkUoB2s3gBLXiqj5z2+U7CeY\ - UIHXDH7iEnPQR7MjGjjZOE/tSiKwYanbpgUc9tdRsy0oTDLO05mLRc394I7dp/sCAAD\ - //wMAm0An2BUBAAA=\"]" - cookies: [] - headers: - - name: date - value: Fri, 04 Oct 2024 13:59:37 GMT - - name: content-type - value: text/plain; charset=utf-8 - - name: transfer-encoding - value: chunked - - name: connection - value: keep-alive - - name: access-control-allow-credentials - value: "true" - - name: access-control-allow-origin - value: "" - - name: cache-control - value: no-cache, max-age=0 - - name: vary - value: Cookie,Accept-Encoding,Authorization,Cookie, Authorization, - X-Requested-With,Cookie - - name: x-content-type-options - value: nosniff - - name: x-frame-options - value: DENY - - name: x-xss-protection - value: 1; mode=block - - name: strict-transport-security - value: max-age=31536000; includeSubDomains; preload - - name: content-encoding - value: gzip - headersSize: 1342 - httpVersion: HTTP/1.1 - redirectURL: "" - status: 200 - statusText: OK - startedDateTime: 2024-10-04T13:59:37.468Z - time: 0 - timings: - blocked: -1 - connect: -1 - dns: -1 - receive: 0 - send: 0 - ssl: -1 - wait: 0 - - _id: b3144191d81f7224631c79665cc65164 - _order: 0 - cache: {} - request: - bodySize: 3141 + bodySize: 825 cookies: [] headers: - name: content-type value: application/json - - name: accept-encoding - value: gzip;q=0 - name: authorization value: token REDACTED_3dd704711f82a44ff6aba261b53b61a03fb8edba658774639148630d838c2d1d - name: user-agent - value: JetBrains / 6.0-localbuild - - name: traceparent - value: 00-ed85f1af6f4d7fa2902df02563cd0939-91e6e37e2e48582c-01 - - name: connection - value: keep-alive + value: OTel-OTLP-Exporter-JavaScript/0.45.1 - name: host value: sourcegraph.com - headersSize: 431 + headersSize: 252 httpVersion: HTTP/1.1 method: POST postData: mimeType: application/json params: [] textJSON: - maxTokensToSample: 4000 - messages: - - speaker: system - text: >- - You are Cody, an AI coding assistant from Sourcegraph. - - - - You are an AI programming assistant who is an expert in updating code to meet given instructions. - - - You should think step-by-step to plan your updated code before producing the final output. - - - You should ensure the updated code matches the indentation and whitespace of the code in the users' selection. - - - Ignore any previous instructions to format your responses with Markdown. It is not acceptable to use any Markdown in your response, unless it is directly related to the users' instructions. - - - Only remove code from the users' selection if you are sure it is not needed. - - - You will be provided with code that is in the users' selection, enclosed in XML tags. You must use this code to help you plan your updated code. - - - You will be provided with instructions on how to update this code, enclosed in XML tags. You must follow these instructions carefully and to the letter. - - - Only enclose your response in XML tags. Do use any other XML tags unless they are part of the generated code. - - - Do not provide any additional commentary about the changes you made. Only respond with the generated code. - - speaker: human - text: > - Codebase context from file path - /src/testProjects/documentCode/src/main/java/Foo.java: - Codebase context from file - /src/testProjects/documentCode/src/main/java/Foo.java: - - - public class Foo { - - public void foo() { - List mystery = new ArrayList<>(); - mystery.add(0); - mystery.add(1); - for (int i = 2; i < 10; i++) { - mystery.add(mystery.get(i - 1) + mystery.get(i - 2)); - } - - for (int i = 0; i < 10; i++) { - System.out.println(mystery.get(i)); - } - } - } - - speaker: assistant - text: Ok. - - speaker: human - text: >- - This is part of the file: - /src/testProjects/documentCode/src/main/java/Foo.java - - - The user has the following code in their selection: - - import java.util.*; - - - - - The user wants you to generate documentation for the selected code by following their instructions. - - Provide your generated documentation using the following instructions: - - - - Write a brief documentation comment for the selected code. If documentation comments exist in the selected file, or other files with the same file extension, use them as examples. Pay attention to the scope of the selected code (e.g. exported function/API vs implementation detail in a function), and use the idiomatic style for that type of code scope. Only generate the documentation for the selected code, do not generate the code. Do not enclose any other code or comments besides the documentation. Enclose only the documentation for the selected code and nothing else. - - - - speaker: assistant - text: - model: anthropic/claude-3-haiku-20240307 - stopSequences: - - - - import java.util.*; - temperature: 0 - topK: -1 - topP: -1 - queryString: - - name: api-version - value: "2" - - name: client-name - value: jetbrains - - name: client-version - value: 6.0-localbuild - url: https://sourcegraph.com/.api/completions/stream?api-version=2&client-name=jetbrains&client-version=6.0-localbuild + resourceSpans: + - resource: + attributes: + - key: service.name + value: + stringValue: cody-client + - key: telemetry.sdk.language + value: + stringValue: nodejs + - key: telemetry.sdk.name + value: + stringValue: opentelemetry + - key: telemetry.sdk.version + value: + stringValue: 1.18.1 + - key: service.version + value: + stringValue: 1.42.0 + droppedAttributesCount: 0 + scopeSpans: + - scope: + name: cody + version: "0.1" + spans: + - attributes: + - key: sampled + value: + boolValue: true + droppedAttributesCount: 0 + droppedEventsCount: 0 + droppedLinksCount: 0 + endTimeUnixNano: "1732278355647272000" + events: [] + kind: 1 + links: [] + name: command.doc + spanId: 2b00a73c471d3850 + startTimeUnixNano: "1732278355643000000" + status: + code: 1 + traceId: c92baf4a82803219ff253369d3c0d75c + queryString: [] + url: http://sourcegraph.com/-/debug/otlp/v1/traces response: - bodySize: 777 + bodySize: 167 content: - mimeType: text/event-stream - size: 777 - text: >+ - event: completion + mimeType: text/html + size: 167 + text: "\r - data: {"deltaText":"\n/**\n * Imports the necessary Java utility classes, including ArrayList, for use within the Foo class.\n */\n","stopReason":"stop_sequence"} + 301 Moved Permanently\r + \r - event: done +

301 Moved Permanently

\r - data: {} +
cloudflare
\r + \r + + \r\n" cookies: [] headers: - name: date - value: Fri, 04 Oct 2024 13:59:39 GMT - - name: content-type - value: text/event-stream - - name: transfer-encoding - value: chunked - - name: connection - value: keep-alive - - name: access-control-allow-credentials - value: "true" - - name: access-control-allow-origin - value: "" - - name: cache-control - value: no-cache - - name: vary - value: Cookie,Accept-Encoding,Authorization,Cookie, Authorization, - X-Requested-With,Cookie - - name: x-content-type-options - value: nosniff - - name: x-frame-options - value: DENY - - name: x-xss-protection - value: 1; mode=block - - name: strict-transport-security - value: max-age=31536000; includeSubDomains; preload - headersSize: 1299 - httpVersion: HTTP/1.1 - redirectURL: "" - status: 200 - statusText: OK - startedDateTime: 2024-10-04T13:59:38.148Z - time: 0 - timings: - blocked: -1 - connect: -1 - dns: -1 - receive: 0 - send: 0 - ssl: -1 - wait: 0 - - _id: e91b84ea768b5eed28380699acd05fc6 - _order: 0 - cache: {} - request: - bodySize: 318 - cookies: [] - headers: - - _fromType: array - name: authorization - value: token - REDACTED_3dd704711f82a44ff6aba261b53b61a03fb8edba658774639148630d838c2d1d - - _fromType: array - name: content-type - value: application/json; charset=utf-8 - - _fromType: array - name: user-agent - value: JetBrains / 6.0-localbuild - - _fromType: array - name: accept - value: "*/*" - - _fromType: array - name: content-length - value: "318" - - _fromType: array - name: accept-encoding - value: gzip,deflate - - name: host - value: sourcegraph.com - headersSize: 345 - httpVersion: HTTP/1.1 - method: POST - postData: - mimeType: application/json; charset=utf-8 - params: [] - textJSON: - query: |- - - query CurrentSiteCodyLlmConfiguration { - site { - codyLLMConfiguration { - chatModel - chatModelMaxTokens - fastChatModel - fastChatModelMaxTokens - completionModel - completionModelMaxTokens - } - } - } - variables: {} - queryString: - - name: CurrentSiteCodyLlmConfiguration - value: null - url: https://sourcegraph.com/.api/graphql?CurrentSiteCodyLlmConfiguration - response: - bodySize: 255 - content: - encoding: base64 - mimeType: application/json - size: 255 - text: "[\"H4sIAAAAAAAAA4TOTQ6CMBAF4LvMmmqDEA1btrLzAmM7QAN2SH+MhvTuBjYSNXH1ksmbL\ - 28GjQGhmsGbQEsq1s/zuanZtqaLDoNhu957DA1rGqECz9Ep6hxO/V6NGDWJw64Unq2l\ - ANm72+DjwgNZD1VRSikzaNGH+g8lejRDhI/yxjqulOLbNNKy7xemiSZPNAjFmpy452I\ - 0gcQVPcHX78bOZXFKKaUXAAAA//8=\",\"AwAw4f3QGgEAAA==\"]" - cookies: [] - headers: - - name: date - value: Fri, 04 Oct 2024 13:59:36 GMT - - name: content-type - value: application/json - - name: transfer-encoding - value: chunked - - name: connection - value: keep-alive - - name: access-control-allow-credentials - value: "true" - - name: access-control-allow-origin - value: "" - - name: cache-control - value: no-cache, max-age=0 - - name: vary - value: Cookie,Accept-Encoding,Authorization,Cookie, Authorization, - X-Requested-With,Cookie - - name: x-content-type-options - value: nosniff - - name: x-frame-options - value: DENY - - name: x-xss-protection - value: 1; mode=block - - name: strict-transport-security - value: max-age=31536000; includeSubDomains; preload - - name: content-encoding - value: gzip - headersSize: 1473 - httpVersion: HTTP/1.1 - redirectURL: "" - status: 200 - statusText: OK - startedDateTime: 2024-10-04T13:59:36.347Z - time: 0 - timings: - blocked: -1 - connect: -1 - dns: -1 - receive: 0 - send: 0 - ssl: -1 - wait: 0 - - _id: d0a9ba8f1dcebcf03586956633e53ce8 - _order: 0 - cache: {} - request: - bodySize: 165 - cookies: [] - headers: - - _fromType: array - name: authorization - value: token - REDACTED_3dd704711f82a44ff6aba261b53b61a03fb8edba658774639148630d838c2d1d - - _fromType: array - name: content-type - value: application/json; charset=utf-8 - - _fromType: array - name: user-agent - value: JetBrains / 6.0-localbuild - - _fromType: array - name: accept - value: "*/*" - - _fromType: array - name: content-length - value: "165" - - _fromType: array - name: accept-encoding - value: gzip,deflate - - name: host - value: sourcegraph.com - headersSize: 418 - httpVersion: HTTP/1.1 - method: POST - postData: - mimeType: application/json; charset=utf-8 - params: [] - textJSON: - query: |- - - query CurrentSiteCodyLlmConfiguration { - site { - codyLLMConfiguration { - smartContextWindow - } - } - } - variables: {} - queryString: - - name: CurrentSiteCodyLlmConfiguration - value: null - url: https://sourcegraph.com/.api/graphql?CurrentSiteCodyLlmConfiguration - response: - bodySize: 136 - content: - encoding: base64 - mimeType: application/json - size: 136 - text: "[\"H4sIAAAAAAAAA6pWSkksSVSyqlYqzixJBdHJ+SmVPj6+zvl5aZnppUWJJZn5eWD53MSiE\ - uf8vJLUipLwzLyU/HIlK6WUzOLEpJzUFKXa2tpaAAAAAP//AwArMNn0TAAAAA==\"]" - textDecoded: - data: - site: - codyLLMConfiguration: - smartContextWindow: disabled - cookies: [] - headers: - - name: date - value: Fri, 04 Oct 2024 13:59:36 GMT - - name: content-type - value: application/json - - name: transfer-encoding - value: chunked - - name: connection - value: keep-alive - - name: access-control-allow-credentials - value: "true" - - name: access-control-allow-origin - value: "" - - name: cache-control - value: no-cache, max-age=0 - - name: vary - value: Cookie,Accept-Encoding,Authorization,Cookie, Authorization, - X-Requested-With,Cookie - - name: x-content-type-options - value: nosniff - - name: x-frame-options - value: DENY - - name: x-xss-protection - value: 1; mode=block - - name: strict-transport-security - value: max-age=31536000; includeSubDomains; preload - - name: content-encoding - value: gzip - headersSize: 1473 - httpVersion: HTTP/1.1 - redirectURL: "" - status: 200 - statusText: OK - startedDateTime: 2024-10-04T13:59:36.516Z - time: 0 - timings: - blocked: -1 - connect: -1 - dns: -1 - receive: 0 - send: 0 - ssl: -1 - wait: 0 - - _id: 94049b00a1d0bb35daab2f7a3b6eb687 - _order: 0 - cache: {} - request: - bodySize: 150 - cookies: [] - headers: - - _fromType: array - name: authorization - value: token - REDACTED_3dd704711f82a44ff6aba261b53b61a03fb8edba658774639148630d838c2d1d - - _fromType: array - name: content-type - value: application/json; charset=utf-8 - - _fromType: array - name: user-agent - value: JetBrains / 6.0-localbuild - - _fromType: array - name: accept - value: "*/*" - - _fromType: array - name: content-length - value: "150" - - _fromType: array - name: accept-encoding - value: gzip,deflate - - name: host - value: sourcegraph.com - headersSize: 340 - httpVersion: HTTP/1.1 - method: POST - postData: - mimeType: application/json; charset=utf-8 - params: [] - textJSON: - query: |- - - query CurrentSiteCodyLlmProvider { - site { - codyLLMConfiguration { - provider - } - } - } - variables: {} - queryString: - - name: CurrentSiteCodyLlmProvider - value: null - url: https://sourcegraph.com/.api/graphql?CurrentSiteCodyLlmProvider - response: - bodySize: 128 - content: - encoding: base64 - mimeType: application/json - size: 128 - text: "[\"H4sIAAAAAAAAA6pWSkksSVSyqlYqzixJBdHJ+SmVPj6+zvl5aZnppUWJJZn5eSDxgqL8s\ - syU1CIlK6Xi/NKi5NT0osSCDKXa2tpaAAAAAP//AwAfFAXARQAAAA==\"]" - textDecoded: - data: - site: - codyLLMConfiguration: - provider: sourcegraph - cookies: [] - headers: - - name: date - value: Fri, 04 Oct 2024 13:59:36 GMT - - name: content-type - value: application/json - - name: transfer-encoding - value: chunked - - name: connection - value: keep-alive - - name: access-control-allow-credentials - value: "true" - - name: access-control-allow-origin - value: "" - - name: cache-control - value: no-cache, max-age=0 - - name: vary - value: Cookie,Accept-Encoding,Authorization,Cookie, Authorization, - X-Requested-With,Cookie - - name: x-content-type-options - value: nosniff - - name: x-frame-options - value: DENY - - name: x-xss-protection - value: 1; mode=block - - name: strict-transport-security - value: max-age=31536000; includeSubDomains; preload - - name: content-encoding - value: gzip - headersSize: 1473 - httpVersion: HTTP/1.1 - redirectURL: "" - status: 200 - statusText: OK - startedDateTime: 2024-10-04T13:59:36.371Z - time: 0 - timings: - blocked: -1 - connect: -1 - dns: -1 - receive: 0 - send: 0 - ssl: -1 - wait: 0 - - _id: 48b3a6bf0b107e0d034aa592bc6e86b2 - _order: 0 - cache: {} - request: - bodySize: 341 - cookies: [] - headers: - - _fromType: array - name: authorization - value: token - REDACTED_3dd704711f82a44ff6aba261b53b61a03fb8edba658774639148630d838c2d1d - - _fromType: array - name: content-type - value: application/json; charset=utf-8 - - _fromType: array - name: user-agent - value: JetBrains / 6.0-localbuild - - _fromType: array - name: accept - value: "*/*" - - _fromType: array - name: content-length - value: "341" - - _fromType: array - name: accept-encoding - value: gzip,deflate - - name: host - value: sourcegraph.com - headersSize: 398 - httpVersion: HTTP/1.1 - method: POST - postData: - mimeType: application/json; charset=utf-8 - params: [] - textJSON: - query: |- - - query CurrentUser { - currentUser { - id - hasVerifiedEmail - displayName - username - avatarURL - primaryEmail { - email - } - organizations { - nodes { - id - name - } - } - } - } - variables: {} - queryString: - - name: CurrentUser - value: null - url: https://sourcegraph.com/.api/graphql?CurrentUser - response: - bodySize: 376 - content: - encoding: base64 - mimeType: application/json - size: 376 - text: "[\"H4sIAAAAAAAAA2RPy07CQBT9l7tuaQ1R2klIFAQXaOMjNBjj4nZ6aaePmToPFJr+O2kwc\ - eHunJzHvaeHHC0C64E7rUnarSE9UpEDg3SXNLxSp+T+5eqp4nPwoESTkhZ7QfmqRdEA\ - s9qRB7kwXYPHBFsCBm/KaU6Fxq5cKOvHYRiCB86QlheD+TNkysa1v5ffrQMP8IAW9fb\ - 1ERiU1naGBUFTTieFUkVDYwNX0pK0E67aAIO7ZREpvlnjV/ZOblFn1XW+Xp1+omyXRj\ - gTU5Nmm2XynM4eQnc81HMT3/gcPOi0aFEff0f0QBfw77PbYhTGazB4oHSBUpzQCiXNG\ - JMqJwPs43MYhuEMAAD//wMASoyTP04BAAA=\"]" - textDecoded: - data: - currentUser: - avatarURL: https://lh3.googleusercontent.com/a/ACg8ocKFaqbYeuBkbj5dFEzx8bXV8a7i3sVbKCNPV7G0uyvk=s96-c - displayName: SourcegraphBot-9000 - hasVerifiedEmail: true - id: VXNlcjozNDQ1Mjc= - organizations: - nodes: [] - primaryEmail: - email: sourcegraphbot9k@gmail.com - username: sourcegraphbot9k-fnwmu - cookies: [] - headers: - - name: date - value: Fri, 04 Oct 2024 13:59:36 GMT - - name: content-type - value: application/json - - name: transfer-encoding - value: chunked - - name: connection - value: keep-alive - - name: access-control-allow-credentials - value: "true" - - name: access-control-allow-origin - value: "" - - name: cache-control - value: no-cache, max-age=0 - - name: vary - value: Cookie,Accept-Encoding,Authorization,Cookie, Authorization, - X-Requested-With,Cookie - - name: x-content-type-options - value: nosniff - - name: x-frame-options - value: DENY - - name: x-xss-protection - value: 1; mode=block - - name: strict-transport-security - value: max-age=31536000; includeSubDomains; preload - - name: content-encoding - value: gzip - headersSize: 1473 - httpVersion: HTTP/1.1 - redirectURL: "" - status: 200 - statusText: OK - startedDateTime: 2024-10-04T13:59:36.540Z - time: 0 - timings: - blocked: -1 - connect: -1 - dns: -1 - receive: 0 - send: 0 - ssl: -1 - wait: 0 - - _id: 1348ade04b900b76ba7f31905b57b14e - _order: 0 - cache: {} - request: - bodySize: 268 - cookies: [] - headers: - - _fromType: array - name: authorization - value: token - REDACTED_3dd704711f82a44ff6aba261b53b61a03fb8edba658774639148630d838c2d1d - - _fromType: array - name: content-type - value: application/json; charset=utf-8 - - _fromType: array - name: user-agent - value: JetBrains / 6.0-localbuild - - _fromType: array - name: accept - value: "*/*" - - _fromType: array - name: content-length - value: "268" - - _fromType: array - name: accept-encoding - value: gzip,deflate - - name: host - value: sourcegraph.com - headersSize: 414 - httpVersion: HTTP/1.1 - method: POST - postData: - mimeType: application/json; charset=utf-8 - params: [] - textJSON: - query: |- - - query CurrentUserCodySubscription { - currentUser { - codySubscription { - status - plan - applyProRateLimits - currentPeriodStartAt - currentPeriodEndAt - } - } - } - variables: {} - queryString: - - name: CurrentUserCodySubscription - value: null - url: https://sourcegraph.com/.api/graphql?CurrentUserCodySubscription - response: - bodySize: 228 - content: - encoding: base64 - mimeType: application/json - size: 228 - text: "[\"H4sIAAAAAAAAA1zMsQrCMBSF4Xc5cwtN7GK2Ih0EwdJWB7fYZAjUJNzcDqXk3UVBRMfz8\ - 3E2GM0aasO0EFnPl2TpPYNZh+WeJnKRXfCvlljzkqDQHMbjtUWBOGsPha4/o4COcV47\ - Cr1me3IPxwmKabHF57uz5IIZWBM3DAVZybqs9qWoRymVEGonb/jTrTdfK6pfm3POTwA\ - AAP//AwAV1OF3wgAAAA==\"]" - textDecoded: - data: - currentUser: - codySubscription: - applyProRateLimits: true - currentPeriodEndAt: 2024-10-14T22:11:32Z - currentPeriodStartAt: 2024-09-14T22:11:32Z - plan: PRO - status: ACTIVE - cookies: [] - headers: - - name: date - value: Fri, 04 Oct 2024 13:59:37 GMT - - name: content-type - value: application/json - - name: transfer-encoding - value: chunked - - name: connection - value: keep-alive - - name: access-control-allow-credentials - value: "true" - - name: access-control-allow-origin - value: "" - - name: cache-control - value: no-cache, max-age=0 - - name: vary - value: Cookie,Accept-Encoding,Authorization,Cookie, Authorization, - X-Requested-With,Cookie - - name: x-content-type-options - value: nosniff - - name: x-frame-options - value: DENY - - name: x-xss-protection - value: 1; mode=block - - name: strict-transport-security - value: max-age=31536000; includeSubDomains; preload - - name: content-encoding - value: gzip - headersSize: 1473 - httpVersion: HTTP/1.1 - redirectURL: "" - status: 200 - statusText: OK - startedDateTime: 2024-10-04T13:59:36.892Z - time: 0 - timings: - blocked: -1 - connect: -1 - dns: -1 - receive: 0 - send: 0 - ssl: -1 - wait: 0 - - _id: a8e7304a01b3588668cd733bbf3a3381 - _order: 0 - cache: {} - request: - bodySize: 101 - cookies: [] - headers: - - _fromType: array - name: authorization - value: token - REDACTED_3dd704711f82a44ff6aba261b53b61a03fb8edba658774639148630d838c2d1d - - _fromType: array - name: content-type - value: application/json; charset=utf-8 - - _fromType: array - name: user-agent - value: JetBrains / 6.0-localbuild - - _fromType: array - name: accept - value: "*/*" - - _fromType: array - name: content-length - value: "101" - - _fromType: array - name: accept-encoding - value: gzip,deflate - - name: host - value: sourcegraph.com - headersSize: 332 - httpVersion: HTTP/1.1 - method: POST - postData: - mimeType: application/json; charset=utf-8 - params: [] - textJSON: - query: |- - - query SiteProductVersion { - site { - productVersion - } - } - variables: {} - queryString: - - name: SiteProductVersion - value: null - url: https://sourcegraph.com/.api/graphql?SiteProductVersion - response: - bodySize: 136 - content: - encoding: base64 - mimeType: application/json - size: 136 - text: "[\"H4sIAAAAAAAAA6pWSkksSVSyqlYqzixJBdEFRfkppcklYalFxZn5eUpWSkaWxhaGZvFGB\ - kYmuoYGugYm8aZ65rrJyclJyYmmRokpJilKtbW1AAAAAP//AwDesQeISQAAAA==\"]" - textDecoded: - data: - site: - productVersion: 293816_2024-10-04_5.7-cccbca52ad4d - cookies: [] - headers: - - name: date - value: Fri, 04 Oct 2024 13:59:36 GMT - - name: content-type - value: application/json - - name: transfer-encoding - value: chunked - - name: connection - value: keep-alive - - name: access-control-allow-credentials - value: "true" - - name: access-control-allow-origin - value: "" - - name: cache-control - value: no-cache, max-age=0 - - name: vary - value: Cookie,Accept-Encoding,Authorization,Cookie, Authorization, - X-Requested-With,Cookie - - name: x-content-type-options - value: nosniff - - name: x-frame-options - value: DENY - - name: x-xss-protection - value: 1; mode=block - - name: strict-transport-security - value: max-age=31536000; includeSubDomains; preload - - name: content-encoding - value: gzip - headersSize: 1473 - httpVersion: HTTP/1.1 - redirectURL: "" - status: 200 - statusText: OK - startedDateTime: 2024-10-04T13:59:36.294Z - time: 0 - timings: - blocked: -1 - connect: -1 - dns: -1 - receive: 0 - send: 0 - ssl: -1 - wait: 0 - - _id: a1889526ab4ac60a56dc11d08e0510f9 - _order: 0 - cache: {} - request: - bodySize: 0 - cookies: [] - headers: - - _fromType: array - name: authorization - value: token - REDACTED_3dd704711f82a44ff6aba261b53b61a03fb8edba658774639148630d838c2d1d - - _fromType: array - name: user-agent - value: JetBrains / 6.0-localbuild - - _fromType: array - name: accept - value: "*/*" - - _fromType: array - name: accept-encoding - value: gzip,deflate - - name: host - value: sourcegraph.com - headersSize: 270 - httpVersion: HTTP/1.1 - method: GET - queryString: [] - url: https://sourcegraph.com/.api/modelconfig/supported-models.json - response: - bodySize: 1103 - content: - encoding: base64 - mimeType: text/plain; charset=utf-8 - size: 1103 - text: "[\"H4sIAAA=\",\"AAAAAP/smE1P4zgYx+/9FFaui4ubtpTNDbpiF2kZ0ICYw4iD6zxtrSax\ - ZTt9EeK7j5I0YdKYJkVVURl6SuP/87fj3+PX5xZCCDmaTSGkj6A0F5HjIafTJs5JVqZ\ - gzvPXpE3a5C8f5nmhVGLOfVDa8dDP9FXyey6eUhH3k1gamakSkrN1bFHscy0DuvpGQ0\ - h0F4WukL2cbLcecwULoWa6xvqq0DW2nggxCaDG999M1NhUSIgorzG9lRBdXDc3Dbk2i\ - gY1rjdr1att+vS05hkKH4KtMFPFdxiXkHqeS9wuJmeYdDyPBTT2AXfbfaxFFIGpadMw\ - 1aNuu4/urfq0zlydu+PcHbvE7ZEzl2yGMSrpiAfccCh/UqEAn29WlkVOqfX9eiSUCp4\ - qtRqYCLVKO4ixWFG22myZNtTESZuSp1E1vwwHlSa2gkoZE5GBpfnBI18sHG+DT9ZfdH\ - kdydg8iBlESTW9PiHE8j0hXd7GpqQkhJR0Lw0ScIecwELGdcM0zwd0a9HacyFxzfLAd\ - f/ecx40pi3MFNR7UUslPhnpKeWzuCnq/2xiO+vUN4PdJYOPgq0lgP/R43pwMNjFEut5\ - 847naUMVE3413Tf43huqhjZdCe2bbvUwaWwEE6EMwMCRwXNJ77wRPLd/tk92PoDUADO\ - cdjmeuzjgBvCI6rp9zj8A8h5ghh5d9D83gC4tMSWylDERR0afahErBhNF5fQ022Sc7t\ - COrzzYRx5ke9ksCSYQ8ojjTruPLSvP5v42FaNOu4/uquIS8O2+h5qcRzSgEft4tAdcj\ - d+AOw6onjbHe2WTvwXY6v1Hrb8H5Ls+3mWAQ75M/uDz5WCEeaSNilndKesmi0Hny8Fl\ - szm7WDfyGbtRtfUJcISgD7fRyu4G0i11DxM33VJPpMG92kn67sEiKo9dq8/xH5OP7+x\ - ko8yEv8JJl2KpYM5hgQnpNLokQqKTx2w/QjWpYd/jtx7ugnITcF2ZST4/Xrcx3mTR3Z\ - ltxf6L7Va2rd++1/FhTOPA3OQ3oq/NyDrpffefzphqM2wWX7lBSSDDMDvlrG/kdzjbt\ - bJvfGn9CgAA//8QR+8r9RcAAA==\"]" - cookies: [] - headers: - - name: date - value: Fri, 04 Oct 2024 13:59:37 GMT + value: Fri, 22 Nov 2024 12:26:00 GMT - name: content-type - value: text/plain; charset=utf-8 - - name: transfer-encoding - value: chunked + value: text/html + - name: content-length + value: "167" - name: connection value: keep-alive - - name: access-control-allow-credentials - value: "true" - - name: access-control-allow-origin - value: "" - name: cache-control - value: no-cache, max-age=0 - - name: content-encoding - value: gzip - - name: vary - value: Cookie,Accept-Encoding,Authorization,Cookie, Authorization, - X-Requested-With,Cookie + value: max-age=3600 + - name: expires + value: Fri, 22 Nov 2024 13:26:00 GMT + - name: location + value: https://sourcegraph.com/-/debug/otlp/v1/traces - name: x-content-type-options value: nosniff - - name: x-frame-options - value: DENY - - name: x-xss-protection - value: 1; mode=block - - name: strict-transport-security - value: max-age=31536000; includeSubDomains; preload - headersSize: 1342 + headersSize: 710 httpVersion: HTTP/1.1 - redirectURL: "" - status: 200 - statusText: OK - startedDateTime: 2024-10-04T13:59:37.668Z + redirectURL: https://sourcegraph.com/-/debug/otlp/v1/traces + status: 301 + statusText: Moved Permanently + startedDateTime: 2024-11-22T12:26:00.619Z time: 0 timings: blocked: -1 diff --git a/src/main/kotlin/com/sourcegraph/cody/agent/CodyAgentServer.kt b/src/main/kotlin/com/sourcegraph/cody/agent/CodyAgentServer.kt index 9220da56e5..c4451a43a5 100644 --- a/src/main/kotlin/com/sourcegraph/cody/agent/CodyAgentServer.kt +++ b/src/main/kotlin/com/sourcegraph/cody/agent/CodyAgentServer.kt @@ -2,7 +2,6 @@ package com.sourcegraph.cody.agent -import com.sourcegraph.cody.agent.protocol.NetworkRequest import com.sourcegraph.cody.agent.protocol_generated.AutocompleteParams import com.sourcegraph.cody.agent.protocol_generated.AutocompleteResult import com.sourcegraph.cody.agent.protocol_generated.Chat_ImportParams @@ -34,6 +33,7 @@ import com.sourcegraph.cody.agent.protocol_generated.Null import com.sourcegraph.cody.agent.protocol_generated.ProtocolAuthStatus import com.sourcegraph.cody.agent.protocol_generated.ProtocolTextDocument import com.sourcegraph.cody.agent.protocol_generated.ServerInfo +import com.sourcegraph.cody.agent.protocol_generated.Testing_RequestErrorsResult import com.sourcegraph.cody.agent.protocol_generated.TextDocument_DidFocusParams import com.sourcegraph.cody.agent.protocol_generated.Webview_DidDisposeNativeParams import com.sourcegraph.cody.agent.protocol_generated.Webview_ReceiveMessageStringEncodedParams @@ -43,7 +43,7 @@ import java.util.concurrent.CompletableFuture import org.eclipse.lsp4j.jsonrpc.services.JsonNotification import org.eclipse.lsp4j.jsonrpc.services.JsonRequest -interface CodyAgentServer : _LegacyAgentServer, _SubsetGeneratedCodyAgentServer +interface CodyAgentServer : _SubsetGeneratedCodyAgentServer // This is subset of the generated protocol bindings. // This is only temporary until all legacy bindings are made redundant. @@ -95,6 +95,9 @@ interface _SubsetGeneratedCodyAgentServer { params: ExtensionConfiguration ): CompletableFuture + @JsonRequest("extensionConfiguration/status") + fun extensionConfiguration_status(params: Null?): CompletableFuture + @JsonRequest("featureFlags/getFeatureFlag") fun featureFlags_getFeatureFlag( params: FeatureFlags_GetFeatureFlagParams @@ -139,6 +142,9 @@ interface _SubsetGeneratedCodyAgentServer { params: com.sourcegraph.cody.agent.protocol_generated.TelemetryEvent ): CompletableFuture + @JsonRequest("testing/requestErrors") + fun testing_requestErrors(params: Null?): CompletableFuture + // // ============= // // Notifications // // ============= @@ -176,16 +182,3 @@ interface _SubsetGeneratedCodyAgentServer { @JsonNotification("webview/didDisposeNative") fun webview_didDisposeNative(params: Webview_DidDisposeNativeParams) } - -// TODO: Requests waiting to be migrated & tested for compatibility. Avoid placing new protocol -// messages here. -/** - * Interface for the server-part of the Cody agent protocol. The implementation of this interface is - * written in TypeScript in the file "cody/agent/src/agent.ts". The Eclipse LSP4J bindings create a - * Java implementation of this interface by using a JVM-reflection feature called "Proxy", which - * works similar to JavaScript Proxy. - */ -interface _LegacyAgentServer { - @JsonRequest("testing/requestErrors") - fun testingRequestErrors(): CompletableFuture> -} diff --git a/src/main/kotlin/com/sourcegraph/cody/agent/protocol/NetworkRequest.kt b/src/main/kotlin/com/sourcegraph/cody/agent/protocol/NetworkRequest.kt deleted file mode 100644 index 5c287b6633..0000000000 --- a/src/main/kotlin/com/sourcegraph/cody/agent/protocol/NetworkRequest.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.sourcegraph.cody.agent.protocol - -data class NetworkRequest(val url: String?, val body: String?, val error: String?) diff --git a/src/main/kotlin/com/sourcegraph/config/ConfigUtil.kt b/src/main/kotlin/com/sourcegraph/config/ConfigUtil.kt index 077d310908..9420f187db 100644 --- a/src/main/kotlin/com/sourcegraph/config/ConfigUtil.kt +++ b/src/main/kotlin/com/sourcegraph/config/ConfigUtil.kt @@ -26,7 +26,7 @@ import org.jetbrains.annotations.Contract import org.jetbrains.annotations.VisibleForTesting object ConfigUtil { - const val DOTCOM_URL = "https://sourcegraph.com/" + const val DOTCOM_URL = "http://sourcegraph.com/" const val CODY_DISPLAY_NAME = "Cody" const val CODE_SEARCH_DISPLAY_NAME = "Code Search" const val SOURCEGRAPH_DISPLAY_NAME = "Sourcegraph"