From a545726ff07ff31bbbabda84ad1754505e354957 Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Sat, 31 Aug 2024 19:30:43 -0700 Subject: [PATCH 1/3] docs(README): fix wrong key in usage code --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d49e9d..1509155 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ import { verifyRequestByKeyId } from "@copilot-extensions/preview-sdk"; const payloadIsVerified = await verifyRequestByKeyId( request.body, signature, - key, + keyId, { token: process.env.GITHUB_TOKEN, } From 03e203e3ab24a0a4ed2fedb56bd6c98b9c7de4eb Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Sat, 31 Aug 2024 19:32:41 -0700 Subject: [PATCH 2/3] docs(dreamcode): mention interop functionality and show code how requset parsing and the event API will work --- dreamcode.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dreamcode.md b/dreamcode.md index 352b848..2b6f3ba 100644 --- a/dreamcode.md +++ b/dreamcode.md @@ -70,6 +70,22 @@ createServer(createNodeMiddleware(copilotExtension)).listen(3000); copilotExtension.log.info("Listening on http://localhost:3000"); ``` +For other environments, these methods are available: + +```js +// verify the payload and call handlers +copilotExtension.verifyAndReceive({ payload, signature, keyId }); +// same, but skip verification +copilotExtension.receive({ payload }); + +// and if you don't want to use the event-based API +const { isValidRequest, payload } = await copilotExtension.verifyAndParse( + payload, + signature, + keyId +); +``` + ## Notes Regarding the context passed to event handlers @@ -77,6 +93,7 @@ Regarding the context passed to event handlers - `message` / `confirmation` / etc are objects as received by the user - `octokit` is a pre-authenticated octokit instance - `prompt` is based on my work at https://github.com/github/gr2m-projects/blob/167/github-models/167-github-models/README.md. A simple API to interact with GitHub models. I assume we will default the prompt URL to `https://api.githubcopilot.com/chat/completions` and the model to `gpt-4o` (or whatever our CAPI name for that is?) +- The `prompt` API will automatically apply interop transformations if the request is sent to an endpoint other than Copilot's chat complitions endpoint. - `respond` is an API to send different types of responses to the user - `log` is the logger as we use it in Octokit. See https://github.com/octokit/core.js?tab=readme-ov-file#logging From 26e5a3cbf48e50d426a4139603fe3eeee128fd2c Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Sat, 31 Aug 2024 19:36:38 -0700 Subject: [PATCH 3/3] Updates from editor --- dreamcode.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dreamcode.md b/dreamcode.md index 2b6f3ba..d5bc969 100644 --- a/dreamcode.md +++ b/dreamcode.md @@ -74,9 +74,9 @@ For other environments, these methods are available: ```js // verify the payload and call handlers -copilotExtension.verifyAndReceive({ payload, signature, keyId }); +await copilotExtension.verifyAndReceive({ payload, signature, keyId }); // same, but skip verification -copilotExtension.receive({ payload }); +await copilotExtension.receive({ payload }); // and if you don't want to use the event-based API const { isValidRequest, payload } = await copilotExtension.verifyAndParse(