@myrialabs/clopen 0.4.38 → 0.4.39

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.
Files changed (114) hide show
  1. package/backend/auth/permissions.ts +25 -0
  2. package/backend/chat/stream-manager.ts +1 -1
  3. package/backend/database/crypto/secret-columns.ts +5 -1
  4. package/backend/database/migrations/075_create_deploy_bindings.ts +54 -0
  5. package/backend/database/migrations/076_remove_memory_code_graph.ts +229 -0
  6. package/backend/database/migrations/077_create_integration_db_links.ts +150 -0
  7. package/backend/database/migrations/index.ts +21 -0
  8. package/backend/database/queries/db-client-connection-queries.ts +19 -0
  9. package/backend/database/queries/deploy-queries.ts +124 -0
  10. package/backend/database/queries/graph-queries.ts +291 -247
  11. package/backend/database/queries/index.ts +4 -0
  12. package/backend/database/queries/integration-db-link-queries.ts +168 -0
  13. package/backend/database/queries/integration-queries.ts +34 -6
  14. package/backend/db-client/integrations/index.ts +37 -0
  15. package/backend/db-client/integrations/links.ts +533 -0
  16. package/backend/db-client/integrations/projector.test.ts +280 -0
  17. package/backend/db-client/integrations/projector.ts +256 -0
  18. package/backend/db-client/integrations/supabase-service.ts +266 -0
  19. package/backend/db-client/providers/registry.ts +27 -0
  20. package/backend/db-client/providers/supabase/adapter.ts +500 -0
  21. package/backend/db-client/providers/supabase/api-types.ts +92 -0
  22. package/backend/db-client/providers/supabase/apply-migration.ts +104 -0
  23. package/backend/db-client/providers/supabase/client.ts +259 -0
  24. package/backend/db-client/providers/supabase/features.ts +502 -0
  25. package/backend/db-client/providers/supabase/local.test.ts +78 -0
  26. package/backend/db-client/providers/supabase/local.ts +137 -0
  27. package/backend/db-client/providers/types.ts +137 -0
  28. package/backend/deployments/bindings.test.ts +43 -0
  29. package/backend/deployments/bindings.ts +216 -0
  30. package/backend/deployments/index.ts +53 -0
  31. package/backend/deployments/log-streams.ts +214 -0
  32. package/backend/deployments/prompts.ts +70 -0
  33. package/backend/deployments/providers/vercel/adapter.ts +757 -0
  34. package/backend/deployments/providers/vercel/build-logs.test.ts +80 -0
  35. package/backend/deployments/providers/vercel/build-logs.ts +211 -0
  36. package/backend/deployments/providers/vercel/client.ts +203 -0
  37. package/backend/deployments/providers/vercel/list.test.ts +624 -0
  38. package/backend/deployments/providers/vercel/normalise.test.ts +115 -0
  39. package/backend/deployments/providers/vercel/normalise.ts +113 -0
  40. package/backend/deployments/providers/vercel/types.ts +104 -0
  41. package/backend/deployments/registry.ts +27 -0
  42. package/backend/deployments/service.ts +458 -0
  43. package/backend/deployments/types.ts +278 -0
  44. package/backend/index.ts +4 -0
  45. package/backend/integrations/projections/index.ts +0 -0
  46. package/backend/integrations/projections/mcp-projector.ts +7 -3
  47. package/backend/integrations/projections/types.ts +21 -9
  48. package/backend/integrations/registry/index.ts +5 -1
  49. package/backend/integrations/registry/providers/supabase.ts +61 -0
  50. package/backend/integrations/registry/providers/vercel.ts +46 -0
  51. package/backend/mcp/internal/servers/memory-graph/description.ts +3 -3
  52. package/backend/mcp/internal/servers/memory-graph/runner.ts +4 -9
  53. package/backend/mcp/internal/servers/memory-graph/schema.ts +0 -4
  54. package/backend/memory/README.md +57 -34
  55. package/backend/memory/compose.test.ts +3 -3
  56. package/backend/memory/compose.ts +6 -9
  57. package/backend/memory/config.ts +0 -5
  58. package/backend/memory/consolidate.ts +1 -2
  59. package/backend/memory/context.test.ts +8 -54
  60. package/backend/memory/context.ts +19 -25
  61. package/backend/memory/extract/episodic.ts +10 -12
  62. package/backend/memory/extract/index.ts +23 -52
  63. package/backend/memory/extract/scheduler.ts +3 -6
  64. package/backend/memory/index.ts +6 -5
  65. package/backend/memory/invalidate.ts +36 -48
  66. package/backend/memory/layout.ts +319 -130
  67. package/backend/memory/retention.ts +12 -42
  68. package/backend/memory/retrieval.eval.test.ts +2 -2
  69. package/backend/memory/retrieval.test.ts +228 -183
  70. package/backend/memory/retrieval.ts +22 -21
  71. package/backend/memory/revise.test.ts +62 -116
  72. package/backend/memory/revise.ts +0 -1
  73. package/backend/memory/view.ts +8 -5
  74. package/backend/snapshot/helpers.ts +35 -41
  75. package/backend/snapshot/snapshot-service.ts +90 -0
  76. package/backend/snapshot/turn-changes.test.ts +163 -0
  77. package/backend/snapshot/turn-changes.ts +131 -0
  78. package/backend/ws/db-client/accounts.ts +225 -0
  79. package/backend/ws/db-client/connections.ts +34 -3
  80. package/backend/ws/db-client/context.ts +37 -0
  81. package/backend/ws/db-client/index.ts +20 -1
  82. package/backend/ws/db-client/supabase.ts +188 -0
  83. package/backend/ws/deployments/actions.ts +360 -0
  84. package/backend/ws/deployments/context.ts +43 -0
  85. package/backend/ws/deployments/crud.ts +152 -0
  86. package/backend/ws/deployments/index.ts +15 -0
  87. package/backend/ws/deployments/schemas.ts +183 -0
  88. package/backend/ws/index.ts +6 -2
  89. package/backend/ws/memory/crud.ts +4 -16
  90. package/backend/ws/snapshot/changes.ts +279 -0
  91. package/backend/ws/snapshot/index.ts +4 -3
  92. package/dist/assets/{index-CyH7fSbR.js → index-BrF6nqld.js} +1 -1
  93. package/dist/assets/{index-DSHIANSy.js → index-C8Gi-b6U.js} +1 -1
  94. package/dist/assets/main-Bd3gb79F.css +1 -0
  95. package/dist/assets/main-Bo1hD7mt.js +1191 -0
  96. package/dist/index.html +2 -2
  97. package/package.json +1 -1
  98. package/shared/constants/tool-icons.ts +9 -0
  99. package/shared/types/db-client/connection.ts +6 -0
  100. package/shared/types/db-client/index.ts +2 -0
  101. package/shared/types/db-client/integrations.ts +174 -0
  102. package/shared/types/db-client/supabase.ts +131 -0
  103. package/shared/types/deployments.ts +382 -0
  104. package/shared/types/memory.ts +34 -51
  105. package/shared/types/ui/components.ts +1 -1
  106. package/shared/utils/diff-calculator.test.ts +89 -0
  107. package/shared/utils/diff-calculator.ts +30 -65
  108. package/shared/utils/logger.ts +1 -0
  109. package/backend/memory/extract/languages.ts +0 -176
  110. package/backend/memory/extract/structural.test.ts +0 -215
  111. package/backend/memory/extract/structural.ts +0 -364
  112. package/backend/ws/snapshot/content.ts +0 -85
  113. package/dist/assets/main-D2IOjftb.css +0 -1
  114. package/dist/assets/main-DM-tHKbW.js +0 -1152
@@ -0,0 +1,278 @@
1
+ /**
2
+ * Deploy-provider adapter contract.
3
+ *
4
+ * This is the interface `Task 3` exists to build. Vercel is the first provider
5
+ * behind it; Netlify, Railway, Fly.io, Render, Coolify/Dokploy and Cloudflare
6
+ * Pages are meant to land as another directory in `providers/` and one line in
7
+ * the registry. If any of them needs a change to the PANEL, this interface is
8
+ * what was wrong.
9
+ *
10
+ * Note what this is NOT: a projector. A projection derives a row on a surface
11
+ * that already has its own table — `mcp_servers` for agent tools,
12
+ * `db_client_connections` for a database. Deployments are never copied locally
13
+ * (see migration 075), so there is no derived row to keep in step. A deploy
14
+ * provider registers CODE here, and the account row itself is what makes it
15
+ * appear in the panel. That is the same conclusion the Issues surface reached.
16
+ *
17
+ * Every optional method is paired with a flag in `capabilities`. A caller must
18
+ * read the flag rather than probe for the method, because the panel renders its
19
+ * controls before any call is made.
20
+ */
21
+
22
+ import type {
23
+ BuildLogBundle,
24
+ Deployment,
25
+ DeploymentDetail,
26
+ DeploymentDraft,
27
+ DeploymentPage,
28
+ DeployBindingConfig,
29
+ DeployInfo,
30
+ DeployProjectStatus,
31
+ DeployProviderCapabilities,
32
+ DeployTarget,
33
+ NewProjectDraft
34
+ } from '$shared/types/deployments';
35
+ import type { IntegrationAccountRow } from '$backend/database/queries';
36
+
37
+ /**
38
+ * What an adapter can say about deployability.
39
+ *
40
+ * The client-facing `DeployInfo` also carries facts read from the LOCAL working
41
+ * tree — the suggested repository, the checked-out branch — which an adapter
42
+ * has no business knowing about, and the readiness verdict, which the route
43
+ * composes. This is deliberately the shared shape minus those rather than a
44
+ * second declaration that could drift.
45
+ */
46
+ export type AdapterDeployInfo = Omit<
47
+ DeployInfo,
48
+ 'suggestedRepo' | 'connectState' | 'connectHint' | 'connectUrl' | 'currentBranch'
49
+ >;
50
+
51
+ /**
52
+ * Whether a specific repository could be attached, and what to do if not.
53
+ *
54
+ * `unknown` is a first-class answer rather than an optimistic `true`: a check
55
+ * we could not read must not present itself as a green light, because the cost
56
+ * of being wrong is the exact failure the check exists to prevent.
57
+ */
58
+ export interface RepositoryAccess {
59
+ state: 'ready' | 'blocked' | 'unknown';
60
+ reason: string | null;
61
+ /** Provider settings page that fixes it, when there is one. */
62
+ actionUrl: string | null;
63
+ }
64
+
65
+ /** The remote project one account is pointed at, for one Clopen project. */
66
+ export interface ResolvedDeployBinding {
67
+ locator: string;
68
+ displayName: string;
69
+ detected: boolean;
70
+ teamId: string | null;
71
+ config: DeployBindingConfig;
72
+ }
73
+
74
+ /**
75
+ * Everything an adapter call needs.
76
+ *
77
+ * `credentials` is already decoded. It is assembled by the service from the
78
+ * account row and never leaves the backend — no route serialises it, and the
79
+ * adapter must not put it anywhere a `Deployment` can carry it back out.
80
+ */
81
+ export interface DeployContext {
82
+ projectId: string;
83
+ account: IntegrationAccountRow;
84
+ credentials: Record<string, string>;
85
+ binding: ResolvedDeployBinding;
86
+ }
87
+
88
+ /** Same, before a binding exists — the only calls that can run unbound. */
89
+ export interface UnboundDeployContext {
90
+ projectId: string;
91
+ account: IntegrationAccountRow;
92
+ credentials: Record<string, string>;
93
+ }
94
+
95
+ /** How the list is narrowed. Everything optional is "not set", never a default. */
96
+ export interface DeploymentQuery {
97
+ environment: 'production' | 'preview' | 'custom' | 'all';
98
+ branch?: string;
99
+ /** Opaque cursor from the previous page. */
100
+ cursor?: string;
101
+ limit?: number;
102
+ }
103
+
104
+ /** A live log follow, as the stream manager drives it. */
105
+ export interface LogStreamHandle {
106
+ /** Stop the follow and release whatever socket is behind it. */
107
+ stop: () => void;
108
+ }
109
+
110
+ export interface LogStreamCallbacks {
111
+ onChunk: (text: string) => void;
112
+ /**
113
+ * The build moved to a new stage.
114
+ *
115
+ * Separate from the log text because it answers a different question. A log
116
+ * says what a command printed; this says what the provider is DOING — and
117
+ * during the long quiet stretches of a build (uploading, provisioning,
118
+ * assigning domains) the log prints nothing at all, which is exactly when a
119
+ * watcher most needs to know it has not stalled.
120
+ */
121
+ onPhase?: (phase: string) => void;
122
+ /** Called exactly once, with a message when the follow ended badly. */
123
+ onEnd: (error: string | null) => void;
124
+ }
125
+
126
+ export interface DeployProviderAdapter {
127
+ /** Must match the `IntegrationProvider.id` this adapter serves. */
128
+ provider: string;
129
+ capabilities: DeployProviderCapabilities;
130
+
131
+ /**
132
+ * Read the provider's own CLI config out of the project, if it left one.
133
+ *
134
+ * This is what makes binding automatic for a project someone has already
135
+ * linked: `.vercel/project.json` names the project and the team, and asking
136
+ * the user to pick it from a dropdown would be asking them to retype a file
137
+ * that is sitting in their repository.
138
+ *
139
+ * Returns null when there is no such file, which is the ordinary case and
140
+ * not an error.
141
+ */
142
+ detectFromProject?(projectRoot: string): Promise<{ locator: string; teamId: string | null } | null>;
143
+
144
+ /**
145
+ * Remote projects this credential can reach.
146
+ *
147
+ * Used for the binding picker, and for the second detection pass: each
148
+ * target carries the git repository it is connected to, so a project whose
149
+ * `origin` matches one of them can be bound without the user choosing.
150
+ */
151
+ listTargets(context: UnboundDeployContext): Promise<DeployTarget[]>;
152
+
153
+ /** Resolve one target, so a stored locator can be given a display name. */
154
+ describeTarget(context: UnboundDeployContext, locator: string, teamId: string | null): Promise<DeployTarget | null>;
155
+
156
+ /**
157
+ * Is this credential good, and does it reach the bound project?
158
+ *
159
+ * Runs at connect time and from the hub's health button. A token that is
160
+ * valid but cannot see the bound project must fail HERE, naming which of the
161
+ * two it is — not later as an empty list that looks like "no deployments".
162
+ */
163
+ probe(context: UnboundDeployContext, binding: ResolvedDeployBinding | null): Promise<{
164
+ status: 'ok' | 'needs_auth' | 'needs_config' | 'error';
165
+ detail: string | null;
166
+ }>;
167
+
168
+ list(context: DeployContext, query: DeploymentQuery): Promise<DeploymentPage>;
169
+ get(context: DeployContext, id: string): Promise<DeploymentDetail>;
170
+
171
+ /** Build logs as one budgeted bundle — what the chat prompt is built from. */
172
+ fetchLogs?(context: DeployContext, id: string): Promise<BuildLogBundle>;
173
+
174
+ /**
175
+ * Follow a running build's logs.
176
+ *
177
+ * Only called when `capabilities.streamLogs` is set. The handle must stop
178
+ * the underlying request: the stream manager closes it when the last viewer
179
+ * leaves, and a follow nobody aborts is an open socket for the life of the
180
+ * process.
181
+ */
182
+ streamLogs?(context: DeployContext, id: string, callbacks: LogStreamCallbacks): Promise<LogStreamHandle>;
183
+
184
+ /**
185
+ * Outward-facing actions. Each is gated by its capability flag, and the
186
+ * caller has already confirmed with the user before any of these run.
187
+ *
188
+ * `rollback` and `promote` return `pending` rather than `done` when the
189
+ * provider moves traffic asynchronously, which Vercel does — reporting them
190
+ * as complete would tell someone their incident was over before it was.
191
+ */
192
+ redeploy?(context: DeployContext, id: string): Promise<{ deploymentId: string | null; message: string }>;
193
+ cancel?(context: DeployContext, id: string): Promise<{ message: string }>;
194
+ rollback?(context: DeployContext, id: string): Promise<{ status: 'done' | 'pending'; message: string }>;
195
+ promote?(context: DeployContext, id: string): Promise<{ status: 'done' | 'pending'; message: string }>;
196
+
197
+ /**
198
+ * What starting a build from here would need, and whether it is possible.
199
+ *
200
+ * Answered before the deploy dialog opens so the dialog can prefill the
201
+ * branch and refuse honestly, rather than offering a button whose failure is
202
+ * only discovered after someone presses it.
203
+ */
204
+ deployInfo?(context: DeployContext): Promise<AdapterDeployInfo>;
205
+
206
+ /**
207
+ * Start a NEW build from a branch.
208
+ *
209
+ * Distinct from `redeploy`, which copies an existing deployment: this is the
210
+ * only path available to a project that has never been deployed. Outward
211
+ * facing — the caller has confirmed first.
212
+ */
213
+ createDeployment?(
214
+ context: DeployContext,
215
+ draft: DeploymentDraft
216
+ ): Promise<{ deploymentId: string | null; message: string }>;
217
+
218
+ /**
219
+ * Create a remote project.
220
+ *
221
+ * Unbound on purpose: this is what a Clopen project with nothing to point at
222
+ * does, so there is no binding yet. The caller binds to the result.
223
+ */
224
+ createProject?(context: UnboundDeployContext, draft: NewProjectDraft): Promise<DeployTarget>;
225
+
226
+ /**
227
+ * Can this repository be attached, and if not, what would fix it.
228
+ *
229
+ * Asked before `connectRepository` is offered, and also before the new-project
230
+ * form offers to connect a repository to something that does not exist yet —
231
+ * which is why it takes an UNBOUND context. It reads a property of the
232
+ * account, not of any particular project.
233
+ *
234
+ * Attaching a repository needs the ACCOUNT to have git access of its own,
235
+ * established on the provider's site and impossible with an API token — the
236
+ * one prerequisite Clopen can detect but not satisfy. Naming it beats a
237
+ * button that fails.
238
+ */
239
+ repositoryAccess?(context: UnboundDeployContext, gitRepo: string): Promise<RepositoryAccess>;
240
+
241
+ /**
242
+ * Attach a git repository to the bound remote project.
243
+ *
244
+ * The escape hatch from "this project is not connected to a git repository,
245
+ * so it cannot be deployed from here" — which is otherwise a dead end that
246
+ * sends the user to the provider's dashboard.
247
+ */
248
+ connectRepository?(
249
+ context: DeployContext,
250
+ repo: { gitRepo: string; gitProvider: string }
251
+ ): Promise<void>;
252
+
253
+ /**
254
+ * Delete a deployment outright.
255
+ *
256
+ * Outward-facing and irreversible — the build, its logs and its URLs all go.
257
+ * The caller confirms, and must not offer it for whatever is currently
258
+ * serving production.
259
+ */
260
+ deleteDeployment?(context: DeployContext, id: string): Promise<{ message: string }>;
261
+
262
+ /**
263
+ * State that belongs to the target, not to any one build.
264
+ *
265
+ * Also carries the outcome of a rollback or promotion still in flight, which
266
+ * is the only way to turn the `pending` those actions return into an answer.
267
+ */
268
+ projectStatus?(context: DeployContext): Promise<DeployProjectStatus>;
269
+
270
+ /** Who the stored credential belongs to. Shown beside the account label. */
271
+ viewer?(context: UnboundDeployContext): Promise<string | null>;
272
+
273
+ /**
274
+ * The deployment currently serving production traffic, if the provider can
275
+ * answer it directly rather than by inference from the list.
276
+ */
277
+ currentProduction?(context: DeployContext): Promise<Deployment | null>;
278
+ }
package/backend/index.ts CHANGED
@@ -69,6 +69,7 @@ import { sessionCleanupScheduler } from './auth/session-cleanup';
69
69
  import { portMonitor } from './ports/monitor';
70
70
  import { containerMonitor } from './containers/monitor';
71
71
  import { stopAllLogStreams as stopAllContainerLogStreams } from './containers/logs';
72
+ import { stopAllBuildLogStreams } from './deployments/log-streams';
72
73
  import { uploadTempCleanup } from './http/upload-temp-cleanup';
73
74
  import { ws as wsServer } from './utils/ws';
74
75
  import { messageRateLimiter } from './ws/message-rate-limiter';
@@ -362,6 +363,9 @@ async function gracefulShutdown() {
362
363
  // Same for the container list, and the log streams it may still be pumping
363
364
  stopAllContainerLogStreams();
364
365
  containerMonitor.stop();
366
+ // Build-log follows are open HTTPS responses against a provider; nothing
367
+ // closes them but us.
368
+ stopAllBuildLogStreams();
365
369
  // Close MCP remote server (before engines, as they may still reference it)
366
370
  await closeMcpServer();
367
371
  // Cleanup browser preview sessions
@@ -2,6 +2,10 @@
2
2
  * The `agent-tools` projector: an account with agent tools owns one
3
3
  * `mcp_servers` row.
4
4
  *
5
+ * It returns a single-element list because the contract is plural, not because
6
+ * there is a second row coming: a preset names ONE slug, so an account either
7
+ * owns that row or owns nothing.
8
+ *
5
9
  * Nothing downstream of this row knows accounts exist. `resolveServerRow()`,
6
10
  * every per-engine config builder and the `/mcp/ext/<slug>` proxy read the row
7
11
  * exactly as they read a hand-installed one — which is the whole point of
@@ -72,7 +76,7 @@ export const mcpProjector: Projector = {
72
76
  capability: 'agent-tools',
73
77
  targetKind: 'mcp_server',
74
78
 
75
- project(context: ProjectionContext): ProjectionResult {
79
+ project(context: ProjectionContext): ProjectionResult[] {
76
80
  const preset = presetOf(context);
77
81
  const existing: McpServerRow | null = mcpServerQueries.getBySlug(preset.slug);
78
82
 
@@ -93,7 +97,7 @@ export const mcpProjector: Projector = {
93
97
  // an ordinary custom row rather than needing a fourth source value.
94
98
  source: 'custom'
95
99
  });
96
- return { targetKind: 'mcp_server', targetId: String(row.id), adopted: false, restore: null };
100
+ return [{ targetKind: 'mcp_server', targetId: String(row.id), adopted: false, restore: null }];
97
101
  }
98
102
 
99
103
  // ADOPT rather than create a sibling. A user who installed this server by
@@ -135,7 +139,7 @@ export const mcpProjector: Projector = {
135
139
  }
136
140
  }
137
141
 
138
- return { targetKind: 'mcp_server', targetId, adopted, restore };
142
+ return [{ targetKind: 'mcp_server', targetId, adopted, restore }];
139
143
  },
140
144
 
141
145
  release(context: ProjectionContext, targetId: string, adopted: boolean, restore: unknown | null): void {
@@ -7,15 +7,20 @@
7
7
  *
8
8
  * One projector per capability — but ONLY for capabilities whose surface owns a
9
9
  * table to write into. `agent-tools` writes an `mcp_servers` row, `database`
10
- * will write a `db_client_connections` one, and `deployments`,
11
- * `worktree-branching` and `notifications` are registered by the tasks that
12
- * build those surfaces.
10
+ * writes `db_client_connections` ones, and `worktree-branching` and
11
+ * `notifications` are registered by the tasks that build those surfaces.
13
12
  *
14
- * `work` deliberately has NO projector. Work items are never copied into the
13
+ * A projector returns a LIST. Agent tools happens to produce exactly one row
14
+ * per account, but that is a fact about MCP presets rather than about
15
+ * projection: one database credential reaches every project the token can see,
16
+ * and the user picks as many of them as they want (see migration 077).
17
+ *
18
+ * `work` and `deployments` deliberately have NO projector. Work items are never copied into the
15
19
  * database (see migration 074 for why), so there is no derived row to keep in
16
20
  * step — the Issues & PRs surface registers an ADAPTER in
17
- * `backend/issues/registry.ts` and reads the account directly. A capability
18
- * without a table is a capability without a projection.
21
+ * `backend/work/registry.ts` and reads the account directly, and Deployments
22
+ * does the same in `backend/deployments/registry.ts`. A capability without a
23
+ * table is a capability without a projection.
19
24
  */
20
25
 
21
26
  import type { IntegrationCapability, IntegrationTargetKind } from '$shared/types/integrations';
@@ -44,8 +49,15 @@ export interface ProjectionResult {
44
49
  export interface Projector {
45
50
  capability: IntegrationCapability;
46
51
  targetKind: IntegrationTargetKind;
47
- /** Create or refresh the derived row. Called on connect, credential change and capability enable. */
48
- project(context: ProjectionContext): ProjectionResult;
49
- /** Remove the derived row, or hand an adopted one back untouched. */
52
+ /**
53
+ * Create or refresh every derived row this account should own right now.
54
+ *
55
+ * Called on connect, credential change and capability enable. Anything the
56
+ * account previously projected that is NOT in the returned list gets
57
+ * released, so removing a link and disabling a capability are the same
58
+ * operation as far as the pass is concerned.
59
+ */
60
+ project(context: ProjectionContext): ProjectionResult[];
61
+ /** Remove one derived row, or hand an adopted one back untouched. */
50
62
  release(context: ProjectionContext, targetId: string, adopted: boolean, restore: unknown | null): void;
51
63
  }
@@ -10,6 +10,8 @@
10
10
  import context7 from './providers/context7';
11
11
  import firecrawl from './providers/firecrawl';
12
12
  import github from './providers/github';
13
+ import supabase from './providers/supabase';
14
+ import vercel from './providers/vercel';
13
15
  import type { IntegrationProvider } from './types';
14
16
  import type { IntegrationProviderInfo } from '$shared/types/integrations';
15
17
 
@@ -20,7 +22,9 @@ export { defineProvider } from './define';
20
22
  export const PROVIDERS: readonly IntegrationProvider[] = [
21
23
  context7,
22
24
  firecrawl,
23
- github
25
+ github,
26
+ supabase,
27
+ vercel
24
28
  ];
25
29
 
26
30
  const byId = new Map(PROVIDERS.map((provider) => [provider.id, provider]));
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Supabase — the first provider behind the `database` capability.
3
+ *
4
+ * ONE CREDENTIAL FIELD, for the reason Vercel has one. A personal access token
5
+ * reaches every project in every organisation its user belongs to, so "which
6
+ * project" is not a property of the credential — it is a choice, made as many
7
+ * times as the user has databases worth opening. Those choices live in
8
+ * `integration_db_links`, and each one projects a `db_client_connections` row.
9
+ *
10
+ * SCOPED TOKENS are the thing to know about this provider. Supabase is rolling
11
+ * out personal access tokens that carry only the permissions you pick, and they
12
+ * are prefixed `sbp_fc` where a classic full-access token is plain `sbp_`. A
13
+ * scoped token that is missing a permission fails with an undecorated
14
+ * "Forbidden" at the moment the feature is reached, so the client reads that
15
+ * prefix and says which scope is likely absent — the same trick `Task 2` used on
16
+ * GitHub's fine-grained token prefix, and for the same reason.
17
+ *
18
+ * The DATABASE PASSWORD is deliberately not a credential field here. It is not
19
+ * a property of the account either: every project has its own, and no API can
20
+ * read any of them back. It belongs to the link, which is where it is stored.
21
+ *
22
+ * NO `agent-tools`, even though Supabase ships an MCP server that takes exactly
23
+ * this token. That server is scoped with `--project-ref` to ONE project, and an
24
+ * account here can hold several — so there is no honest single row to project.
25
+ * A user who wants those tools installs the server from the MCP registry, which
26
+ * the hub still offers; the day this becomes a per-link capability rather than a
27
+ * per-account one it can be revisited.
28
+ *
29
+ * NO `inbound-events`. Supabase's webhooks are database triggers rather than a
30
+ * signed platform delivery, and `Task 7` is the first entry with a subscriber
31
+ * worth registering one for.
32
+ */
33
+
34
+ import { defineProvider } from '../define';
35
+
36
+ export default defineProvider({
37
+ id: 'supabase',
38
+ name: 'Supabase',
39
+ category: 'database',
40
+ description:
41
+ 'Postgres projects as connections in DB Client, with the Supabase surface on top: migrations and what is still pending, RLS policies and the security advisor, edge functions, storage buckets, auth users, and generated TypeScript types written into the project.',
42
+ docsUrl: 'https://supabase.com/dashboard/account/tokens',
43
+ authMethod: 'api-key',
44
+ capabilities: ['database'],
45
+ credentialFields: [
46
+ {
47
+ name: 'accessToken',
48
+ label: 'Personal access token',
49
+ placeholder: 'sbp_…',
50
+ // Names the PERMISSIONS rather than describing the screen. Supabase is
51
+ // rolling out scoped tokens, and a scoped token missing one permission
52
+ // fails at the moment the feature is used, with a bare "Forbidden" that
53
+ // says nothing about which scope is absent — so the fix has to be
54
+ // stated before the token is created, not diagnosed afterwards.
55
+ help:
56
+ 'Account Settings → Access Tokens. A classic token works as is. A SCOPED token (they start with sbp_fc) needs: Projects (account-wide) Read to list, Project Settings Read, and Database Read-write. Add Organizations Read and Organization Projects Read-write to create projects from here.',
57
+ isSecret: true,
58
+ isRequired: true
59
+ }
60
+ ]
61
+ });
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Vercel — the first provider behind the Deployments surface.
3
+ *
4
+ * ONE CREDENTIAL FIELD, deliberately. A Vercel token reaches the personal
5
+ * account and every team its user belongs to, so "which team" is not a property
6
+ * of the credential — it is a property of the project you picked. Putting a
7
+ * `teamId` field here would force a user with two teams to connect the same
8
+ * token twice, and would make the first project they bind decide the second.
9
+ * The team is stored on the binding instead, where it belongs.
10
+ *
11
+ * NO `agent-tools`. Vercel does run an MCP server, but it authenticates with
12
+ * its own OAuth rather than this REST token — a different audience, which the
13
+ * account layer treats as a second credential rather than a reuse of this one.
14
+ * Declaring the capability would mean projecting an MCP row we cannot fill from
15
+ * what is stored here. It stays addable later as its own provider entry.
16
+ *
17
+ * NO `inbound-events`. Vercel can sign webhooks, but a Clopen that is usually
18
+ * reached on localhost has no public URL to register, and `Task 7` is the first
19
+ * entry that builds a subscriber worth registering one for.
20
+ */
21
+
22
+ import { defineProvider } from '../define';
23
+
24
+ export default defineProvider({
25
+ id: 'vercel',
26
+ name: 'Vercel',
27
+ category: 'deployment',
28
+ description:
29
+ 'Deployments for the project this repository builds to. Watch a build as it runs, send a failed build log into the chat, open a preview build in the browser panel, and redeploy, cancel, roll back or promote from here.',
30
+ docsUrl: 'https://vercel.com/account/tokens',
31
+ authMethod: 'api-key',
32
+ capabilities: ['deployments'],
33
+ credentialFields: [
34
+ {
35
+ name: 'token',
36
+ label: 'Access token',
37
+ placeholder: 'Vercel access token',
38
+ // Scope guidance rather than a tutorial: the failure this prevents is
39
+ // a token scoped to one team that then cannot see another team's
40
+ // project, which arrives as an empty list rather than an error.
41
+ help: 'Account Settings → Tokens. A token scoped to a team only reaches that team\'s projects — pick "Full Account" if this Clopen deploys for more than one.',
42
+ isSecret: true,
43
+ isRequired: true
44
+ }
45
+ ]
46
+ });
@@ -4,7 +4,7 @@
4
4
  * as importantly, that it does not have to write anything.
5
5
  */
6
6
 
7
- export const memoryToolDescription = `Query and curate Clopen's Memory Graph — a persistent store of what has been decided, tried and learned across past sessions of this workspace, plus a map of the codebase those memories attach to. It is shared by every AI engine and survives session switches, so a memory written months ago by a different model is still here.
7
+ export const memoryToolDescription = `Query and curate Clopen's Memory Graph — a persistent store of what has been decided, tried and learned across past sessions of this workspace. It is shared by every AI engine and survives session switches, so a memory written months ago by a different model is still here.
8
8
 
9
9
  YOU DO NOT NEED TO RECORD ANYTHING. Memories are written automatically from each finished conversation turn, including anything the user asks you to remember — saying "remember that I prefer X" is enough on its own, and there is deliberately no action here that stores a new memory. That is one write path rather than two, so what ends up in the graph is predictable. This tool is for reading it and for correcting what is already there.
10
10
 
@@ -13,13 +13,13 @@ Reach for it when:
13
13
  - something is failing in a way that feels like it has failed before
14
14
  - you need to know why code looks the way it does, when the code itself does not say
15
15
  - the user refers to a past discussion, decision or preference
16
- - you want to know what a file or module is connected to before changing it
16
+ - you are about to change a file, and want to know what was decided about it
17
17
  - a memory you were shown is wrong, out of date, or filed under the wrong kind
18
18
 
19
19
  Relevant memories are already prepended to each turn automatically, so this tool is for going DEEPER than that: following up on something you have just discovered, asking about another project, or walking the graph. It is not a substitute for reading what you were given.
20
20
 
21
21
  Actions:
22
- - recall — natural-language search across memories and code entities. Runs keyword and semantic search together and expands into the graph, so it finds paraphrases as well as exact names. Use scope "all" to search every project, which is how you find that a problem was already solved in another repository.
22
+ - recall — natural-language search across the memories. Runs keyword and semantic search together and expands into the graph, so it finds paraphrases as well as exact names. Use scope "all" to search every project, which is how you find that a problem was already solved in another repository.
23
23
  - neighbours — walk outward from a node returned by recall. This is where the graph earns its keep: the memory you need is often adjacent to your match rather than being it.
24
24
  - timeline — recent memories in order, for "what have we been doing here".
25
25
  - update — correct a memory in place. Prefer this whenever an existing memory is nearly right: it keeps the node's connections and its history, where retiring it and letting a new one be written loses both.
@@ -69,10 +69,7 @@ function renderHit(hit: RetrievalHit, currentProjectId: string | null): string {
69
69
  : node.projectId !== currentProjectId
70
70
  ? 'learned in another project'
71
71
  : node.scope;
72
- const detail =
73
- node.kind === 'structural'
74
- ? (node.symbol ? `${node.symbol} — ${node.path}` : (node.path ?? ''))
75
- : node.body.split('\n')[0].slice(0, 260);
72
+ const detail = node.body.split('\n')[0].slice(0, 260);
76
73
 
77
74
  return [
78
75
  `[${node.id}] (${node.subkind}, ${where}, confidence ${node.confidence.toFixed(2)}, found by ${found})`,
@@ -84,7 +81,7 @@ function renderHit(hit: RetrievalHit, currentProjectId: string | null): string {
84
81
  }
85
82
 
86
83
  function renderNode(node: GraphNode, prefix = ''): string {
87
- const detail = node.kind === 'structural' ? (node.path ?? '') : node.body.split('\n')[0].slice(0, 200);
84
+ const detail = node.body.split('\n')[0].slice(0, 200);
88
85
  return `${prefix}[${node.id}] (${node.subkind}) ${node.label}${detail ? `\n${prefix} ${detail}` : ''}`;
89
86
  }
90
87
 
@@ -120,7 +117,6 @@ async function runOne(op: Operation, ctx: Context): Promise<OperationReport> {
120
117
  // case memory exists to cover.
121
118
  crossProject: true,
122
119
  sessionId: ctx.sessionId ?? undefined,
123
- kinds: op.kind && op.kind !== 'both' ? [op.kind] : undefined,
124
120
  limit: op.limit ?? 10,
125
121
  // An explicit lookup is answered with what MATCHES it, not with what
126
122
  // matches it plus everything one edge away. Expansion belongs to
@@ -260,7 +256,7 @@ async function runOne(op: Operation, ctx: Context): Promise<OperationReport> {
260
256
  ...(op.subkind !== undefined && { subkind: op.subkind })
261
257
  },
262
258
  // An agent's correction is an agent's correction. Recording it as the
263
- // user's would exempt the node from structural decay, from eviction and
259
+ // user's would exempt the node from staleness decay, from eviction and
264
260
  // from consolidation, and would tell every future turn a person had
265
261
  // stated it — authority the model did not earn by editing.
266
262
  'agent'
@@ -291,8 +287,7 @@ async function runOne(op: Operation, ctx: Context): Promise<OperationReport> {
291
287
  action: op.action,
292
288
  ok: true,
293
289
  text: [
294
- `${stats.nodes} nodes, ${stats.edges} edges`,
295
- ` episodic: ${stats.episodic} structural: ${stats.structural}`,
290
+ `${stats.nodes} memories, ${stats.edges} connections`,
296
291
  ` scope — session ${stats.byScope.session}, project ${stats.byScope.project}, global ${stats.byScope.global}`,
297
292
  ` ${stats.vectors} node(s) have semantic vectors`,
298
293
  ` ${stats.entities} canonical entity/entities, ${stats.confirmedUseful} confirmed useful`,
@@ -42,10 +42,6 @@ const recall = z.object({
42
42
  .describe(
43
43
  'project (default): this project plus global memories. all: every project — use when the question is not about the current codebase, or to find how something was solved elsewhere.'
44
44
  ),
45
- kind: z
46
- .enum(['episodic', 'structural', 'both'])
47
- .optional()
48
- .describe('episodic = decisions/patterns/failures; structural = files/symbols/dependencies; both (default)'),
49
45
  limit: z.number().int().min(1).max(40).optional().describe('Maximum results. Default 10.')
50
46
  });
51
47