ubiquity-os / ubiquity-os-kernel

1 stars 19 forks source link

Cache for repo configs #111

Open Keyrxng opened 2 months ago

Keyrxng commented 2 months ago

It's kinda annoying that the kernel must fetch from both config locations on every request and more often than not only one is needed.

Cons:

Solution:

Do you think this would be a good thing to implement @whilefoo?

0x4007 commented 2 months ago

We need to minimize the use of KV and rely more on the GitHub API because we have tighter limits on the Cloudflare side.

Keyrxng commented 2 weeks ago

@UbiquityOS Explain how to install and run the kernel, and install text-conversation-rewards plugin

ubiquity-os-beta[bot] commented 2 weeks ago

Sure! Here's a step-by-step guide to installing and running the UbiquityOS kernel, as well as installing the text-conversation-rewards plugin.

1. Clone the UbiquityOS Kernel Repository

Begin by cloning the UbiquityOS kernel repository to your local machine:

git clone https://github.com/ubiquity-os/ubiquity-os-kernel.git
cd ubiquity-os-kernel

2. Install Dependencies

Ensure you have Bun installed, as it's required for managing dependencies and running the project.

bun install

3. Create and Configure a GitHub App

  1. Generate a GitHub App:

    • Navigate to your GitHub settings and create a new GitHub App.
    • Configure the necessary permissions:
      • Repository Permissions:
      • Actions: Read & Write
      • Contents: Read & Write
      • Issues: Read & Write
      • Pull Requests: Read & Write
      • Organization Permissions:
      • Members: Read-only
    • Subscribe to all relevant events your kernel will handle.
  2. Obtain Credentials:

    • App ID: Retrieve this from your GitHub App settings.

    • Private Key: Generate a private key in PKCS8 format. Use the following command to convert your PEM file:

      openssl pkcs8 -topk8 -inform pem -outform pem -nocrypt -in yourappprivatekey.pem -out appprivatekey.pem
    • Webhook Secret: Set this value in both your GitHub App settings and your kernel configuration.

4. Set Up Cloudflare Account and KV Namespace

  1. Create a Cloudflare Account: If you don't have one, sign up at Cloudflare.

  2. Install Wrangler CLI: Wrangler is Cloudflare's command-line tool for managing Workers.

    npm install -g wrangler
  3. Login to Cloudflare:

    wrangler login
  4. Create a KV Namespace:

    wrangler kvnamespace create pluginchainstate
    • Note the generated Namespace ID and add it to your wrangler.toml under the [env.dev] section:

      [env.dev]
      kv_namespaces = [{ binding = "PLUGINCHAINSTATE", id = "your-generated-id" }]

5. Manage Environment Secrets

Add the necessary environment variables and secrets required by the kernel:

  1. App Private Key:

    wrangler secret put appprivatekey --env dev < path/to/appprivatekey.pem
  2. Other Secrets:

    • appwebhooksecret: Your GitHub App's webhook secret.
    • appid: Your GitHub App ID.
    • webhookproxyurl: Only required for development purposes.

    Add these using:

    wrangler secret put appwebhooksecret --env dev
    wrangler secret put appid --env dev
    wrangler secret put webhookproxyurl --env dev

    You'll be prompted to enter the values for each secret.

6. Deploy the Kernel to Cloudflare Workers

Deploy your kernel using the following command:

bun run deploy-dev

This command will build and deploy your kernel to the Cloudflare Workers environment.

7. Install the text-conversation-rewards Plugin

  1. Clone or Fork the Plugin:

    • Ensure the text-conversation-rewards plugin is available within the ubiquity-os-marketplace organization. If it's an official plugin, transfer it there; otherwise, fork it.
  2. Fetch Plugin Manifests:

    • The kernel will fetch the manifest.json from each plugin repository to understand its configuration and dependencies.
  3. Update Kernel Configuration:

    • Edit the ubiquity-osconfig.yml file in your kernel repository to include the text-conversation-rewards plugin:

      plugins:
      - text-conversation-rewards
  4. Deploy Updated Configuration:

    bun run deploy-dev

8. Running the Kernel and Plugin

  1. Start the Kernel in Development Mode:

    bun dev
  2. Trigger Plugin Functionality:

    • For example, if the text-conversation-rewards plugin responds to issue comments, post a relevant comment in your GitHub repository to trigger the plugin.
  3. Verify Plugin Response:

    • Ensure that the plugin processes the event and responds as expected, such as posting a rewards summary.

9. Additional Configuration and Testing

10. Quick Start Example

Here’s a brief example to get you started with a "hello-world" plugin, which follows similar steps to the text-conversation-rewards plugin:

  1. Run the Kernel:

    bun dev
  2. Run the Hello-World Plugin:

    bun plugin hello-world
  3. Update Configuration:

    • Add the hello-world plugin to ubiquity-osconfig.yml:

      plugins:
      - hello-world-plugin
  4. Trigger the Plugin:

    • Post a /hello comment in any issue. The bot should respond with a "world" message.

Resources and References

Summary

By following the steps outlined above, you will set up the UbiquityOS kernel, configure necessary secrets and environment variables, deploy the kernel to Cloudflare Workers, and install the text-conversation-rewards plugin. Ensure you replace placeholder URLs and file paths with your actual configuration details. For any issues or further customization, refer to the linked resources and repository documentation.