Spaces:
Paused
Paused
Download packages/plugins/examples/plugin-authoring-smoke-example/src/worker.ts from GraziePrego/agent: direct link, hf CLI and curl.
- Browser
- Download file 832 Bytes
-
https://huggingface.co/spaces/GraziePrego/agent/resolve/main/packages/plugins/examples/plugin-authoring-smoke-example/src/worker.ts
- Command line
-
hf download hf://spaces/GraziePrego/agent/packages/plugins/examples/plugin-authoring-smoke-example/src/worker.ts
-
curl -L -o worker.ts https://huggingface.co/spaces/GraziePrego/agent/resolve/main/packages/plugins/examples/plugin-authoring-smoke-example/src/worker.ts
832 Bytes
| import { definePlugin, runWorker } from "@paperclipai/plugin-sdk"; | |
| const plugin = definePlugin({ | |
| async setup(ctx) { | |
| ctx.events.on("issue.created", async (event) => { | |
| const issueId = event.entityId ?? "unknown"; | |
| await ctx.state.set({ scopeKind: "issue", scopeId: issueId, stateKey: "seen" }, true); | |
| ctx.logger.info("Observed issue.created", { issueId }); | |
| }); | |
| ctx.data.register("health", async () => { | |
| return { status: "ok", checkedAt: new Date().toISOString() }; | |
| }); | |
| ctx.actions.register("ping", async () => { | |
| ctx.logger.info("Ping action invoked"); | |
| return { pong: true, at: new Date().toISOString() }; | |
| }); | |
| }, | |
| async onHealth() { | |
| return { status: "ok", message: "Plugin worker is running" }; | |
| } | |
| }); | |
| export default plugin; | |
| runWorker(plugin, import.meta.url); | |