| 1 | -- Customize (docs.g1t.sh/guides/customize/): marketplaces a workspace |
| 2 | -- reads plugins from, the plugins it installed, and its connectors (MCP |
| 3 | -- servers connected once and given to agents). Formats are the open ones |
| 4 | -- Claude Code reads (@g1t/contracts claude-plugin.ts). Requests stay in |
| 5 | -- install_requests (0005), whose listings now name plugins, skills and |
| 6 | -- connectors too. extension_installs (0005) is no longer written. |
| 7 | |
| 8 | -- A marketplace: where it is (MarketplaceSource, JSON) and its manifest as |
| 9 | -- last read (marketplace.json, JSON), so Discover lists from the cache. |
| 10 | -- The built-in marketplaces (claude-plugins-official, anthropic-agent-skills) |
| 11 | -- have no row of their own per workspace: their manifests are cached |
| 12 | -- under workspace_id '' and read by every workspace. |
| 13 | CREATE TABLE marketplaces ( |
| 14 | id TEXT PRIMARY KEY, |
| 15 | workspace_id TEXT NOT NULL, |
| 16 | name TEXT NOT NULL, |
| 17 | source TEXT NOT NULL, |
| 18 | manifest TEXT, |
| 19 | fetched_at TEXT, |
| 20 | -- Why the manifest couldn't be read last time, if so. |
| 21 | problem TEXT, |
| 22 | added_by TEXT NOT NULL, |
| 23 | added_at TEXT NOT NULL |
| 24 | ); |
| 25 | CREATE UNIQUE INDEX marketplaces_name ON marketplaces (workspace_id, name); |
| 26 | |
| 27 | -- A plugin installed in a workspace: `name@marketplace`, where its files |
| 28 | -- were read from (FetchPlan, JSON) and at which commit, what it brought |
| 29 | -- (PluginComponents, JSON), and whether it is switched on. Uninstalling |
| 30 | -- keeps the row with when and by whom. |
| 31 | CREATE TABLE plugin_installs ( |
| 32 | id TEXT PRIMARY KEY, |
| 33 | workspace_id TEXT NOT NULL, |
| 34 | ref TEXT NOT NULL, |
| 35 | name TEXT NOT NULL, |
| 36 | marketplace TEXT NOT NULL, |
| 37 | display_name TEXT, |
| 38 | description TEXT NOT NULL DEFAULT '', |
| 39 | version TEXT, |
| 40 | sha TEXT, |
| 41 | fetch TEXT NOT NULL, |
| 42 | components TEXT NOT NULL DEFAULT '{}', |
| 43 | -- The subagents in full (SubagentFile[], JSON), as hireable templates. |
| 44 | agents TEXT NOT NULL DEFAULT '[]', |
| 45 | problems TEXT NOT NULL DEFAULT '[]', |
| 46 | enabled INTEGER NOT NULL DEFAULT 1, |
| 47 | installed_by TEXT NOT NULL, |
| 48 | installed_at TEXT NOT NULL, |
| 49 | updated_at TEXT NOT NULL, |
| 50 | uninstalled_by TEXT, |
| 51 | uninstalled_at TEXT |
| 52 | ); |
| 53 | CREATE UNIQUE INDEX plugin_installs_live ON plugin_installs (workspace_id, ref) WHERE uninstalled_at IS NULL; |
| 54 | |
| 55 | -- A library skill that came with a plugin keeps the plugin's ref, and its |
| 56 | -- name is unique within that plugin rather than the library: agents call |
| 57 | -- it as `plugin:name`. |
| 58 | ALTER TABLE skills ADD COLUMN plugin TEXT; |
| 59 | DROP INDEX skills_name; |
| 60 | CREATE UNIQUE INDEX skills_name ON skills (workspace_id, COALESCE(plugin, ''), name) WHERE archived_at IS NULL; |
| 61 | |
| 62 | -- A connector: an MCP server the workspace connected. Its secrets (a |
| 63 | -- header's value, OAuth tokens and the client registration) are sealed |
| 64 | -- with AES-GCM under CONNECTORS_KEY, bound to the connector's id, and |
| 65 | -- never returned. `from` says where it came from (ConnectorFrom, JSON); |
| 66 | -- `tools` is the server's tool list as last read (McpTool[], JSON). |
| 67 | CREATE TABLE connectors ( |
| 68 | id TEXT PRIMARY KEY, |
| 69 | workspace_id TEXT NOT NULL, |
| 70 | name TEXT NOT NULL, |
| 71 | title TEXT NOT NULL, |
| 72 | url TEXT NOT NULL, |
| 73 | category TEXT, |
| 74 | about TEXT, |
| 75 | -- none, header or oauth. |
| 76 | auth TEXT NOT NULL DEFAULT 'none', |
| 77 | header_name TEXT, |
| 78 | -- Sealed JSON: { header?: value, oauth?: { client_id, client_secret?, access_token, refresh_token?, expires_at?, token_endpoint, scopes? } }. |
| 79 | secrets TEXT, |
| 80 | -- What the server said about who signed in, when the sign-in was done. |
| 81 | signed_in_as TEXT, |
| 82 | signed_in_at TEXT, |
| 83 | -- An OAuth sign-in in progress: the state, the PKCE verifier and the endpoints, sealed; cleared when it completes. |
| 84 | pending TEXT, |
| 85 | pending_at TEXT, |
| 86 | from_json TEXT NOT NULL, |
| 87 | tools TEXT NOT NULL DEFAULT '[]', |
| 88 | checked_at TEXT, |
| 89 | problem TEXT, |
| 90 | added_by TEXT NOT NULL, |
| 91 | added_at TEXT NOT NULL, |
| 92 | updated_at TEXT NOT NULL, |
| 93 | removed_at TEXT |
| 94 | ); |
| 95 | CREATE UNIQUE INDEX connectors_name ON connectors (workspace_id, name) WHERE removed_at IS NULL; |
| 96 | |
| 97 | -- Where a connector reaches: every agent (scope workspace, target ''), a |
| 98 | -- team's agents (team, the team's slug), or one agent (agent, its id). |
| 99 | CREATE TABLE connector_grants ( |
| 100 | id TEXT PRIMARY KEY, |
| 101 | workspace_id TEXT NOT NULL, |
| 102 | connector_id TEXT NOT NULL, |
| 103 | scope TEXT NOT NULL, |
| 104 | target TEXT NOT NULL DEFAULT '', |
| 105 | granted_by TEXT NOT NULL, |
| 106 | granted_at TEXT NOT NULL |
| 107 | ); |
| 108 | CREATE UNIQUE INDEX connector_grants_once ON connector_grants (connector_id, scope, target); |
| 109 | CREATE INDEX connector_grants_reach ON connector_grants (workspace_id, scope, target); |