@assemblyline-agents/supabase 1.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 OpenEve contributors
3
+ Copyright (c) 2026 Assembly Line contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Official Assembly Line Supabase connection plugin.
4
4
 
5
- It connects agents to Supabase, exposing project, database, and platform tools through Supabase's MCP server. The package exports `defineSupabaseConnection(options)` to declare the connection in an agent definition and an `assemblyLinePlugin` module so the Assembly Line CLI and compiler can discover the plugin's connection metadata. A bundled skill under `skills/` teaches agents how to use the connection's tools.
5
+ It connects agents to Supabase, exposing project, database, and platform tools through Supabase's MCP server. The package exports `defineSupabaseConnection(options)` to declare the connection in an agent definition and an `assemblyLinePlugin` module so the Assembly Line CLI and compiler can discover the plugin's connection metadata.
6
6
 
7
7
  ## Install
8
8
 
@@ -0,0 +1,3 @@
1
+ import { type ConnectionPluginEventAdapter } from "@assemblyline-agents/core";
2
+ export declare const supabaseEvents: ConnectionPluginEventAdapter;
3
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,KAAK,4BAA4B,EAElC,MAAM,2BAA2B,CAAC;AAInC,eAAO,MAAM,cAAc,EAAE,4BAqB5B,CAAC"}
package/dist/events.js ADDED
@@ -0,0 +1,49 @@
1
+ import { createHash, timingSafeEqual } from "node:crypto";
2
+ import { ConnectionEventError, headerValue, parseConnectionEventJson, providerJson, requireEnvironmentValue, stringField } from "@assemblyline-agents/core";
3
+ export const supabaseEvents = {
4
+ async reconcile(context) {
5
+ const resources = context.resources.map(tableResource);
6
+ if (!resources.length)
7
+ return { status: "needs_setup", instructions: "Add Supabase event resources with projectRef, schema, and table." };
8
+ const token = (await context.getToken()).token;
9
+ const secret = requireEnvironmentValue(context.env, "SUPABASE_WEBHOOK_SECRET");
10
+ for (const resource of resources)
11
+ await query(context.fetch, token, resource.projectRef, installSql(resource, context.callbackUrl, secret, context.selectedEvents));
12
+ return { status: "active", state: { resources }, detail: `${resources.length} Supabase database webhook${resources.length === 1 ? " is" : "s are"} active.` };
13
+ },
14
+ async remove(context) { const token = (await context.getToken()).token; for (const resource of context.resources.map(tableResource))
15
+ await query(context.fetch, token, resource.projectRef, removeSql(resource)); },
16
+ check(context) { const count = Array.isArray(context.state?.resources) ? context.state.resources.length : 0; return count ? { status: "active", detail: `${count} Supabase database webhook${count === 1 ? " is" : "s are"} configured.` } : { status: "needs_setup", detail: "No Supabase database webhooks are configured." }; },
17
+ ingress(request, context) {
18
+ const expected = `Bearer ${requireEnvironmentValue(context.env, "SUPABASE_WEBHOOK_SECRET")}`;
19
+ if (!safeEqual(expected, headerValue(request.headers, "authorization") ?? ""))
20
+ throw new ConnectionEventError("Supabase webhook bearer token is invalid.", 401);
21
+ const payload = parseConnectionEventJson(request.body);
22
+ const operation = stringField(payload, "type")?.toLowerCase();
23
+ const event = operation === "insert" ? "row.inserted" : operation === "update" ? "row.updated" : operation === "delete" ? "row.deleted" : undefined;
24
+ if (!event)
25
+ throw new ConnectionEventError("Supabase webhook operation is unsupported.");
26
+ const eventId = createHash("sha256").update(request.body).digest("hex");
27
+ return { events: [{ event, eventId, payload: payload }], response: { status: 200, body: { ok: true } }, audit: { event, schema: stringField(payload, "schema") ?? "unknown", table: stringField(payload, "table") ?? "unknown" } };
28
+ }
29
+ };
30
+ async function query(fetchImpl, token, projectRef, query) { await providerJson(fetchImpl, `https://api.supabase.com/v1/projects/${encodeURIComponent(projectRef)}/database/query`, { method: "POST", headers: { authorization: `Bearer ${token}`, "content-type": "application/json" }, body: JSON.stringify({ query }) }); }
31
+ function tableResource(resource) { const projectRef = stringField(resource, "projectRef"); const schema = identifier(stringField(resource, "schema") ?? "public"); const table = identifier(stringField(resource, "table")); if (!projectRef || !table)
32
+ throw new Error("Supabase event resources require projectRef and table."); const name = `assembly_line_${createHash("sha256").update(`${projectRef}:${schema}:${table}`).digest("hex").slice(0, 16)}`; return { projectRef, schema, table, name }; }
33
+ function identifier(value) { if (!value || !/^[A-Za-z_][A-Za-z0-9_]*$/u.test(value))
34
+ throw new Error(`Invalid Supabase SQL identifier: ${value ?? "(missing)"}.`); return value; }
35
+ function literal(value) { return `'${value.replaceAll("'", "''")}'`; }
36
+ function installSql(resource, callbackUrl, secret, events) {
37
+ const operations = events.map((event) => event === "row.inserted" ? "INSERT" : event === "row.updated" ? "UPDATE" : "DELETE").join(" OR ");
38
+ return `create extension if not exists pg_net with schema extensions;
39
+ create or replace function public.${resource.name}_fn() returns trigger language plpgsql security definer as $$
40
+ begin
41
+ perform net.http_post(url := ${literal(callbackUrl)}, headers := jsonb_build_object('Content-Type','application/json','Authorization',${literal(`Bearer ${secret}`)}), body := jsonb_build_object('type', TG_OP, 'table', TG_TABLE_NAME, 'schema', TG_TABLE_SCHEMA, 'record', case when TG_OP = 'DELETE' then null else to_jsonb(NEW) end, 'old_record', case when TG_OP = 'INSERT' then null else to_jsonb(OLD) end));
42
+ return coalesce(NEW, OLD);
43
+ end $$;
44
+ drop trigger if exists ${resource.name}_trigger on "${resource.schema}"."${resource.table}";
45
+ create trigger ${resource.name}_trigger after ${operations} on "${resource.schema}"."${resource.table}" for each row execute function public.${resource.name}_fn();`;
46
+ }
47
+ function removeSql(resource) { return `drop trigger if exists ${resource.name}_trigger on "${resource.schema}"."${resource.table}"; drop function if exists public.${resource.name}_fn();`; }
48
+ function safeEqual(left, right) { const a = Buffer.from(left); const b = Buffer.from(right); return a.length === b.length && timingSafeEqual(a, b); }
49
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRo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AC;AACnE,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,yEAAoN;AAC/R,eAAO,MAAM,kBAAkB,kDAA0C,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
- import { connectionPluginMetadata, defineMcpPluginConnection, definePlugin } from "@assemblyline-agents/core";
1
+ import { connectionPluginMetadata, defineConnectionPluginEvents, defineMcpPluginConnection, definePlugin } from "@assemblyline-agents/core";
2
+ import { supabaseEvents } from "./events.js";
2
3
  const PLUGIN = connectionPluginMetadata("supabase");
3
- export function defineSupabaseConnection(options) { return defineMcpPluginConnection(PLUGIN, options); }
4
+ export function defineSupabaseConnection(options) { const definition = defineMcpPluginConnection(PLUGIN, options); const events = defineConnectionPluginEvents(PLUGIN, options.events, supabaseEvents); if (events)
5
+ definition.events = events; return definition; }
4
6
  export const assemblyLinePlugin = definePlugin({ connections: [PLUGIN] });
5
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,YAAY,EAAmC,MAAM,2BAA2B,CAAC;AAC/I,MAAM,MAAM,GAAG,wBAAwB,CAAC,UAAU,CAAE,CAAC;AAErD,MAAM,UAAU,wBAAwB,CAAC,OAAkC,IAAI,OAAO,yBAAyB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AACnI,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,YAAY,EAAmC,MAAM,2BAA2B,CAAC;AAC7K,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,MAAM,MAAM,GAAG,wBAAwB,CAAC,UAAU,CAAE,CAAC;AAErD,MAAM,UAAU,wBAAwB,CAAC,OAAkC,IAAI,MAAM,UAAU,GAAG,yBAAyB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,MAAM,GAAG,4BAA4B,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,IAAI,MAAM;IAAE,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC;AAC/R,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assemblyline-agents/supabase",
3
- "version": "1.0.0",
3
+ "version": "3.0.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -9,12 +9,11 @@
9
9
  }
10
10
  },
11
11
  "dependencies": {
12
- "@assemblyline-agents/core": "1.0.0"
12
+ "@assemblyline-agents/core": "3.0.0"
13
13
  },
14
14
  "description": "Official Assembly Line Supabase connection plugin.",
15
15
  "files": [
16
- "dist",
17
- "skills"
16
+ "dist"
18
17
  ],
19
18
  "engines": {
20
19
  "node": ">=22.19.0"
@@ -1,8 +0,0 @@
1
- ---
2
- name: supabase
3
- description: Use configured Supabase tools for projects, databases, docs, logs, storage, and Edge Functions.
4
- ---
5
- # Supabase
6
- Resolve the organization and project first. Prefer read-only schema, docs, and log tools; bound database queries tightly.
7
-
8
- The deployment owner configures Supabase OAuth or project-scoped access. The scaffold is read-only; SQL execution, migrations, deployments, storage writes, and project changes require writes to be enabled with the configured approval gate.