28 lines
832 B
TypeScript
28 lines
832 B
TypeScript
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);
|