Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement an event-based API to handle Copilot requests #4

Open
alexisabril opened this issue Aug 27, 2024 · 3 comments
Open

Implement an event-based API to handle Copilot requests #4

alexisabril opened this issue Aug 27, 2024 · 3 comments
Assignees

Comments

@alexisabril
Copy link

Similar to Octokit's webhook helpers, it could improve the quality of life for developers if incoming requests were parsed uniformly.

@gr2m
Copy link
Collaborator

gr2m commented Aug 27, 2024

I started speccing out what I think you (and I) have in mind, please let me know:
https://github.com/copilot-extensions/preview-sdk.js/blob/main/dreamcode.md#api

tl;dr:

import { createServer } from "http";
import {
  CopilotExtension,
  createNodeMiddleware,
} from "@octokit/copilot-extension";

const copilotExtension = new CopilotExtension({
  agent: "my-app-name"
});

copilotExtension.on(
  "message",
  async ({ message, octokit, prompt, respond, log }) => {
    await respond.text(`Hi!`);
  }
);

createServer(createNodeMiddleware(copilotExtension)).listen(3000);

The node middleware will be compatible with express' middleware API

@alexisabril
Copy link
Author

@gr2m, what would be the purpose for instantiating CopilotExtension with { agent: 'my-app-name' }? Wouldn't the receiver be agnostic?

@gr2m
Copy link
Collaborator

gr2m commented Aug 28, 2024

oops that should have been

  userAgent: "my-app-name"

(the value for the user-agent header. It should be unique per GitHub App. I'll update the dreamcode)

The userAgent value will be used for all requests made towards GitHub's API and CAPI. Does that make sense?

@gr2m gr2m changed the title Parse incoming request Implement an event-based API to handle Copilot requests Aug 29, 2024
@gr2m gr2m self-assigned this Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants